github.com/mmatczuk/gohan@v0.0.0-20170206152520-30e45d9bdb69/public/webui/bundle.js (about) 1 /******/ (function(modules) { // webpackBootstrap 2 /******/ // The module cache 3 /******/ var installedModules = {}; 4 /******/ 5 /******/ // The require function 6 /******/ function __webpack_require__(moduleId) { 7 /******/ 8 /******/ // Check if module is in cache 9 /******/ if(installedModules[moduleId]) 10 /******/ return installedModules[moduleId].exports; 11 /******/ 12 /******/ // Create a new module (and put it into the cache) 13 /******/ var module = installedModules[moduleId] = { 14 /******/ exports: {}, 15 /******/ id: moduleId, 16 /******/ loaded: false 17 /******/ }; 18 /******/ 19 /******/ // Execute the module function 20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 /******/ 22 /******/ // Flag the module as loaded 23 /******/ module.loaded = true; 24 /******/ 25 /******/ // Return the exports of the module 26 /******/ return module.exports; 27 /******/ } 28 /******/ 29 /******/ 30 /******/ // expose the modules object (__webpack_modules__) 31 /******/ __webpack_require__.m = modules; 32 /******/ 33 /******/ // expose the module cache 34 /******/ __webpack_require__.c = installedModules; 35 /******/ 36 /******/ // __webpack_public_path__ 37 /******/ __webpack_require__.p = ""; 38 /******/ 39 /******/ // Load entry module and return exports 40 /******/ return __webpack_require__(0); 41 /******/ }) 42 /************************************************************************/ 43 /******/ ([ 44 /* 0 */ 45 /***/ function(module, exports, __webpack_require__) { 46 47 module.exports = __webpack_require__(33); 48 49 50 /***/ }, 51 /* 1 */ 52 /***/ function(module, exports, __webpack_require__) { 53 54 module.exports = __webpack_require__(87); 55 56 /***/ }, 57 /* 2 */ 58 /***/ function(module, exports, __webpack_require__) { 59 60 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(global) {// Backbone.js 1.3.3 61 62 // (c) 2010-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 63 // Backbone may be freely distributed under the MIT license. 64 // For all details and documentation: 65 // http://backbonejs.org 66 67 (function(factory) { 68 69 // Establish the root object, `window` (`self`) in the browser, or `global` on the server. 70 // We use `self` instead of `window` for `WebWorker` support. 71 var root = (typeof self == 'object' && self.self === self && self) || 72 (typeof global == 'object' && global.global === global && global); 73 74 // Set up Backbone appropriately for the environment. Start with AMD. 75 if (true) { 76 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4), __webpack_require__(1), exports], __WEBPACK_AMD_DEFINE_RESULT__ = function(_, $, exports) { 77 // Export global even in AMD case in case this script is loaded with 78 // others that may still expect a global Backbone. 79 root.Backbone = factory(root, exports, _, $); 80 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 81 82 // Next for Node.js or CommonJS. jQuery may not be needed as a module. 83 } else if (typeof exports !== 'undefined') { 84 var _ = require('underscore'), $; 85 try { $ = require('jquery'); } catch (e) {} 86 factory(root, exports, _, $); 87 88 // Finally, as a browser global. 89 } else { 90 root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$)); 91 } 92 93 })(function(root, Backbone, _, $) { 94 95 // Initial Setup 96 // ------------- 97 98 // Save the previous value of the `Backbone` variable, so that it can be 99 // restored later on, if `noConflict` is used. 100 var previousBackbone = root.Backbone; 101 102 // Create a local reference to a common array method we'll want to use later. 103 var slice = Array.prototype.slice; 104 105 // Current version of the library. Keep in sync with `package.json`. 106 Backbone.VERSION = '1.3.3'; 107 108 // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns 109 // the `$` variable. 110 Backbone.$ = $; 111 112 // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable 113 // to its previous owner. Returns a reference to this Backbone object. 114 Backbone.noConflict = function() { 115 root.Backbone = previousBackbone; 116 return this; 117 }; 118 119 // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option 120 // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and 121 // set a `X-Http-Method-Override` header. 122 Backbone.emulateHTTP = false; 123 124 // Turn on `emulateJSON` to support legacy servers that can't deal with direct 125 // `application/json` requests ... this will encode the body as 126 // `application/x-www-form-urlencoded` instead and will send the model in a 127 // form param named `model`. 128 Backbone.emulateJSON = false; 129 130 // Proxy Backbone class methods to Underscore functions, wrapping the model's 131 // `attributes` object or collection's `models` array behind the scenes. 132 // 133 // collection.filter(function(model) { return model.get('age') > 10 }); 134 // collection.each(this.addView); 135 // 136 // `Function#apply` can be slow so we use the method's arg count, if we know it. 137 var addMethod = function(length, method, attribute) { 138 switch (length) { 139 case 1: return function() { 140 return _[method](this[attribute]); 141 }; 142 case 2: return function(value) { 143 return _[method](this[attribute], value); 144 }; 145 case 3: return function(iteratee, context) { 146 return _[method](this[attribute], cb(iteratee, this), context); 147 }; 148 case 4: return function(iteratee, defaultVal, context) { 149 return _[method](this[attribute], cb(iteratee, this), defaultVal, context); 150 }; 151 default: return function() { 152 var args = slice.call(arguments); 153 args.unshift(this[attribute]); 154 return _[method].apply(_, args); 155 }; 156 } 157 }; 158 var addUnderscoreMethods = function(Class, methods, attribute) { 159 _.each(methods, function(length, method) { 160 if (_[method]) Class.prototype[method] = addMethod(length, method, attribute); 161 }); 162 }; 163 164 // Support `collection.sortBy('attr')` and `collection.findWhere({id: 1})`. 165 var cb = function(iteratee, instance) { 166 if (_.isFunction(iteratee)) return iteratee; 167 if (_.isObject(iteratee) && !instance._isModel(iteratee)) return modelMatcher(iteratee); 168 if (_.isString(iteratee)) return function(model) { return model.get(iteratee); }; 169 return iteratee; 170 }; 171 var modelMatcher = function(attrs) { 172 var matcher = _.matches(attrs); 173 return function(model) { 174 return matcher(model.attributes); 175 }; 176 }; 177 178 // Backbone.Events 179 // --------------- 180 181 // A module that can be mixed in to *any object* in order to provide it with 182 // a custom event channel. You may bind a callback to an event with `on` or 183 // remove with `off`; `trigger`-ing an event fires all callbacks in 184 // succession. 185 // 186 // var object = {}; 187 // _.extend(object, Backbone.Events); 188 // object.on('expand', function(){ alert('expanded'); }); 189 // object.trigger('expand'); 190 // 191 var Events = Backbone.Events = {}; 192 193 // Regular expression used to split event strings. 194 var eventSplitter = /\s+/; 195 196 // Iterates over the standard `event, callback` (as well as the fancy multiple 197 // space-separated events `"change blur", callback` and jQuery-style event 198 // maps `{event: callback}`). 199 var eventsApi = function(iteratee, events, name, callback, opts) { 200 var i = 0, names; 201 if (name && typeof name === 'object') { 202 // Handle event maps. 203 if (callback !== void 0 && 'context' in opts && opts.context === void 0) opts.context = callback; 204 for (names = _.keys(name); i < names.length ; i++) { 205 events = eventsApi(iteratee, events, names[i], name[names[i]], opts); 206 } 207 } else if (name && eventSplitter.test(name)) { 208 // Handle space-separated event names by delegating them individually. 209 for (names = name.split(eventSplitter); i < names.length; i++) { 210 events = iteratee(events, names[i], callback, opts); 211 } 212 } else { 213 // Finally, standard events. 214 events = iteratee(events, name, callback, opts); 215 } 216 return events; 217 }; 218 219 // Bind an event to a `callback` function. Passing `"all"` will bind 220 // the callback to all events fired. 221 Events.on = function(name, callback, context) { 222 return internalOn(this, name, callback, context); 223 }; 224 225 // Guard the `listening` argument from the public API. 226 var internalOn = function(obj, name, callback, context, listening) { 227 obj._events = eventsApi(onApi, obj._events || {}, name, callback, { 228 context: context, 229 ctx: obj, 230 listening: listening 231 }); 232 233 if (listening) { 234 var listeners = obj._listeners || (obj._listeners = {}); 235 listeners[listening.id] = listening; 236 } 237 238 return obj; 239 }; 240 241 // Inversion-of-control versions of `on`. Tell *this* object to listen to 242 // an event in another object... keeping track of what it's listening to 243 // for easier unbinding later. 244 Events.listenTo = function(obj, name, callback) { 245 if (!obj) return this; 246 var id = obj._listenId || (obj._listenId = _.uniqueId('l')); 247 var listeningTo = this._listeningTo || (this._listeningTo = {}); 248 var listening = listeningTo[id]; 249 250 // This object is not listening to any other events on `obj` yet. 251 // Setup the necessary references to track the listening callbacks. 252 if (!listening) { 253 var thisId = this._listenId || (this._listenId = _.uniqueId('l')); 254 listening = listeningTo[id] = {obj: obj, objId: id, id: thisId, listeningTo: listeningTo, count: 0}; 255 } 256 257 // Bind callbacks on obj, and keep track of them on listening. 258 internalOn(obj, name, callback, this, listening); 259 return this; 260 }; 261 262 // The reducing API that adds a callback to the `events` object. 263 var onApi = function(events, name, callback, options) { 264 if (callback) { 265 var handlers = events[name] || (events[name] = []); 266 var context = options.context, ctx = options.ctx, listening = options.listening; 267 if (listening) listening.count++; 268 269 handlers.push({callback: callback, context: context, ctx: context || ctx, listening: listening}); 270 } 271 return events; 272 }; 273 274 // Remove one or many callbacks. If `context` is null, removes all 275 // callbacks with that function. If `callback` is null, removes all 276 // callbacks for the event. If `name` is null, removes all bound 277 // callbacks for all events. 278 Events.off = function(name, callback, context) { 279 if (!this._events) return this; 280 this._events = eventsApi(offApi, this._events, name, callback, { 281 context: context, 282 listeners: this._listeners 283 }); 284 return this; 285 }; 286 287 // Tell this object to stop listening to either specific events ... or 288 // to every object it's currently listening to. 289 Events.stopListening = function(obj, name, callback) { 290 var listeningTo = this._listeningTo; 291 if (!listeningTo) return this; 292 293 var ids = obj ? [obj._listenId] : _.keys(listeningTo); 294 295 for (var i = 0; i < ids.length; i++) { 296 var listening = listeningTo[ids[i]]; 297 298 // If listening doesn't exist, this object is not currently 299 // listening to obj. Break out early. 300 if (!listening) break; 301 302 listening.obj.off(name, callback, this); 303 } 304 305 return this; 306 }; 307 308 // The reducing API that removes a callback from the `events` object. 309 var offApi = function(events, name, callback, options) { 310 if (!events) return; 311 312 var i = 0, listening; 313 var context = options.context, listeners = options.listeners; 314 315 // Delete all events listeners and "drop" events. 316 if (!name && !callback && !context) { 317 var ids = _.keys(listeners); 318 for (; i < ids.length; i++) { 319 listening = listeners[ids[i]]; 320 delete listeners[listening.id]; 321 delete listening.listeningTo[listening.objId]; 322 } 323 return; 324 } 325 326 var names = name ? [name] : _.keys(events); 327 for (; i < names.length; i++) { 328 name = names[i]; 329 var handlers = events[name]; 330 331 // Bail out if there are no events stored. 332 if (!handlers) break; 333 334 // Replace events if there are any remaining. Otherwise, clean up. 335 var remaining = []; 336 for (var j = 0; j < handlers.length; j++) { 337 var handler = handlers[j]; 338 if ( 339 callback && callback !== handler.callback && 340 callback !== handler.callback._callback || 341 context && context !== handler.context 342 ) { 343 remaining.push(handler); 344 } else { 345 listening = handler.listening; 346 if (listening && --listening.count === 0) { 347 delete listeners[listening.id]; 348 delete listening.listeningTo[listening.objId]; 349 } 350 } 351 } 352 353 // Update tail event if the list has any events. Otherwise, clean up. 354 if (remaining.length) { 355 events[name] = remaining; 356 } else { 357 delete events[name]; 358 } 359 } 360 return events; 361 }; 362 363 // Bind an event to only be triggered a single time. After the first time 364 // the callback is invoked, its listener will be removed. If multiple events 365 // are passed in using the space-separated syntax, the handler will fire 366 // once for each event, not once for a combination of all events. 367 Events.once = function(name, callback, context) { 368 // Map the event into a `{event: once}` object. 369 var events = eventsApi(onceMap, {}, name, callback, _.bind(this.off, this)); 370 if (typeof name === 'string' && context == null) callback = void 0; 371 return this.on(events, callback, context); 372 }; 373 374 // Inversion-of-control versions of `once`. 375 Events.listenToOnce = function(obj, name, callback) { 376 // Map the event into a `{event: once}` object. 377 var events = eventsApi(onceMap, {}, name, callback, _.bind(this.stopListening, this, obj)); 378 return this.listenTo(obj, events); 379 }; 380 381 // Reduces the event callbacks into a map of `{event: onceWrapper}`. 382 // `offer` unbinds the `onceWrapper` after it has been called. 383 var onceMap = function(map, name, callback, offer) { 384 if (callback) { 385 var once = map[name] = _.once(function() { 386 offer(name, once); 387 callback.apply(this, arguments); 388 }); 389 once._callback = callback; 390 } 391 return map; 392 }; 393 394 // Trigger one or many events, firing all bound callbacks. Callbacks are 395 // passed the same arguments as `trigger` is, apart from the event name 396 // (unless you're listening on `"all"`, which will cause your callback to 397 // receive the true name of the event as the first argument). 398 Events.trigger = function(name) { 399 if (!this._events) return this; 400 401 var length = Math.max(0, arguments.length - 1); 402 var args = Array(length); 403 for (var i = 0; i < length; i++) args[i] = arguments[i + 1]; 404 405 eventsApi(triggerApi, this._events, name, void 0, args); 406 return this; 407 }; 408 409 // Handles triggering the appropriate event callbacks. 410 var triggerApi = function(objEvents, name, callback, args) { 411 if (objEvents) { 412 var events = objEvents[name]; 413 var allEvents = objEvents.all; 414 if (events && allEvents) allEvents = allEvents.slice(); 415 if (events) triggerEvents(events, args); 416 if (allEvents) triggerEvents(allEvents, [name].concat(args)); 417 } 418 return objEvents; 419 }; 420 421 // A difficult-to-believe, but optimized internal dispatch function for 422 // triggering events. Tries to keep the usual cases speedy (most internal 423 // Backbone events have 3 arguments). 424 var triggerEvents = function(events, args) { 425 var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; 426 switch (args.length) { 427 case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; 428 case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return; 429 case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; 430 case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; 431 default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return; 432 } 433 }; 434 435 // Aliases for backwards compatibility. 436 Events.bind = Events.on; 437 Events.unbind = Events.off; 438 439 // Allow the `Backbone` object to serve as a global event bus, for folks who 440 // want global "pubsub" in a convenient place. 441 _.extend(Backbone, Events); 442 443 // Backbone.Model 444 // -------------- 445 446 // Backbone **Models** are the basic data object in the framework -- 447 // frequently representing a row in a table in a database on your server. 448 // A discrete chunk of data and a bunch of useful, related methods for 449 // performing computations and transformations on that data. 450 451 // Create a new model with the specified attributes. A client id (`cid`) 452 // is automatically generated and assigned for you. 453 var Model = Backbone.Model = function(attributes, options) { 454 var attrs = attributes || {}; 455 options || (options = {}); 456 this.cid = _.uniqueId(this.cidPrefix); 457 this.attributes = {}; 458 if (options.collection) this.collection = options.collection; 459 if (options.parse) attrs = this.parse(attrs, options) || {}; 460 var defaults = _.result(this, 'defaults'); 461 attrs = _.defaults(_.extend({}, defaults, attrs), defaults); 462 this.set(attrs, options); 463 this.changed = {}; 464 this.initialize.apply(this, arguments); 465 }; 466 467 // Attach all inheritable methods to the Model prototype. 468 _.extend(Model.prototype, Events, { 469 470 // A hash of attributes whose current and previous value differ. 471 changed: null, 472 473 // The value returned during the last failed validation. 474 validationError: null, 475 476 // The default name for the JSON `id` attribute is `"id"`. MongoDB and 477 // CouchDB users may want to set this to `"_id"`. 478 idAttribute: 'id', 479 480 // The prefix is used to create the client id which is used to identify models locally. 481 // You may want to override this if you're experiencing name clashes with model ids. 482 cidPrefix: 'c', 483 484 // Initialize is an empty function by default. Override it with your own 485 // initialization logic. 486 initialize: function(){}, 487 488 // Return a copy of the model's `attributes` object. 489 toJSON: function(options) { 490 return _.clone(this.attributes); 491 }, 492 493 // Proxy `Backbone.sync` by default -- but override this if you need 494 // custom syncing semantics for *this* particular model. 495 sync: function() { 496 return Backbone.sync.apply(this, arguments); 497 }, 498 499 // Get the value of an attribute. 500 get: function(attr) { 501 return this.attributes[attr]; 502 }, 503 504 // Get the HTML-escaped value of an attribute. 505 escape: function(attr) { 506 return _.escape(this.get(attr)); 507 }, 508 509 // Returns `true` if the attribute contains a value that is not null 510 // or undefined. 511 has: function(attr) { 512 return this.get(attr) != null; 513 }, 514 515 // Special-cased proxy to underscore's `_.matches` method. 516 matches: function(attrs) { 517 return !!_.iteratee(attrs, this)(this.attributes); 518 }, 519 520 // Set a hash of model attributes on the object, firing `"change"`. This is 521 // the core primitive operation of a model, updating the data and notifying 522 // anyone who needs to know about the change in state. The heart of the beast. 523 set: function(key, val, options) { 524 if (key == null) return this; 525 526 // Handle both `"key", value` and `{key: value}` -style arguments. 527 var attrs; 528 if (typeof key === 'object') { 529 attrs = key; 530 options = val; 531 } else { 532 (attrs = {})[key] = val; 533 } 534 535 options || (options = {}); 536 537 // Run validation. 538 if (!this._validate(attrs, options)) return false; 539 540 // Extract attributes and options. 541 var unset = options.unset; 542 var silent = options.silent; 543 var changes = []; 544 var changing = this._changing; 545 this._changing = true; 546 547 if (!changing) { 548 this._previousAttributes = _.clone(this.attributes); 549 this.changed = {}; 550 } 551 552 var current = this.attributes; 553 var changed = this.changed; 554 var prev = this._previousAttributes; 555 556 // For each `set` attribute, update or delete the current value. 557 for (var attr in attrs) { 558 val = attrs[attr]; 559 if (!_.isEqual(current[attr], val)) changes.push(attr); 560 if (!_.isEqual(prev[attr], val)) { 561 changed[attr] = val; 562 } else { 563 delete changed[attr]; 564 } 565 unset ? delete current[attr] : current[attr] = val; 566 } 567 568 // Update the `id`. 569 if (this.idAttribute in attrs) this.id = this.get(this.idAttribute); 570 571 // Trigger all relevant attribute changes. 572 if (!silent) { 573 if (changes.length) this._pending = options; 574 for (var i = 0; i < changes.length; i++) { 575 this.trigger('change:' + changes[i], this, current[changes[i]], options); 576 } 577 } 578 579 // You might be wondering why there's a `while` loop here. Changes can 580 // be recursively nested within `"change"` events. 581 if (changing) return this; 582 if (!silent) { 583 while (this._pending) { 584 options = this._pending; 585 this._pending = false; 586 this.trigger('change', this, options); 587 } 588 } 589 this._pending = false; 590 this._changing = false; 591 return this; 592 }, 593 594 // Remove an attribute from the model, firing `"change"`. `unset` is a noop 595 // if the attribute doesn't exist. 596 unset: function(attr, options) { 597 return this.set(attr, void 0, _.extend({}, options, {unset: true})); 598 }, 599 600 // Clear all attributes on the model, firing `"change"`. 601 clear: function(options) { 602 var attrs = {}; 603 for (var key in this.attributes) attrs[key] = void 0; 604 return this.set(attrs, _.extend({}, options, {unset: true})); 605 }, 606 607 // Determine if the model has changed since the last `"change"` event. 608 // If you specify an attribute name, determine if that attribute has changed. 609 hasChanged: function(attr) { 610 if (attr == null) return !_.isEmpty(this.changed); 611 return _.has(this.changed, attr); 612 }, 613 614 // Return an object containing all the attributes that have changed, or 615 // false if there are no changed attributes. Useful for determining what 616 // parts of a view need to be updated and/or what attributes need to be 617 // persisted to the server. Unset attributes will be set to undefined. 618 // You can also pass an attributes object to diff against the model, 619 // determining if there *would be* a change. 620 changedAttributes: function(diff) { 621 if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; 622 var old = this._changing ? this._previousAttributes : this.attributes; 623 var changed = {}; 624 for (var attr in diff) { 625 var val = diff[attr]; 626 if (_.isEqual(old[attr], val)) continue; 627 changed[attr] = val; 628 } 629 return _.size(changed) ? changed : false; 630 }, 631 632 // Get the previous value of an attribute, recorded at the time the last 633 // `"change"` event was fired. 634 previous: function(attr) { 635 if (attr == null || !this._previousAttributes) return null; 636 return this._previousAttributes[attr]; 637 }, 638 639 // Get all of the attributes of the model at the time of the previous 640 // `"change"` event. 641 previousAttributes: function() { 642 return _.clone(this._previousAttributes); 643 }, 644 645 // Fetch the model from the server, merging the response with the model's 646 // local attributes. Any changed attributes will trigger a "change" event. 647 fetch: function(options) { 648 options = _.extend({parse: true}, options); 649 var model = this; 650 var success = options.success; 651 options.success = function(resp) { 652 var serverAttrs = options.parse ? model.parse(resp, options) : resp; 653 if (!model.set(serverAttrs, options)) return false; 654 if (success) success.call(options.context, model, resp, options); 655 model.trigger('sync', model, resp, options); 656 }; 657 wrapError(this, options); 658 return this.sync('read', this, options); 659 }, 660 661 // Set a hash of model attributes, and sync the model to the server. 662 // If the server returns an attributes hash that differs, the model's 663 // state will be `set` again. 664 save: function(key, val, options) { 665 // Handle both `"key", value` and `{key: value}` -style arguments. 666 var attrs; 667 if (key == null || typeof key === 'object') { 668 attrs = key; 669 options = val; 670 } else { 671 (attrs = {})[key] = val; 672 } 673 674 options = _.extend({validate: true, parse: true}, options); 675 var wait = options.wait; 676 677 // If we're not waiting and attributes exist, save acts as 678 // `set(attr).save(null, opts)` with validation. Otherwise, check if 679 // the model will be valid when the attributes, if any, are set. 680 if (attrs && !wait) { 681 if (!this.set(attrs, options)) return false; 682 } else if (!this._validate(attrs, options)) { 683 return false; 684 } 685 686 // After a successful server-side save, the client is (optionally) 687 // updated with the server-side state. 688 var model = this; 689 var success = options.success; 690 var attributes = this.attributes; 691 options.success = function(resp) { 692 // Ensure attributes are restored during synchronous saves. 693 model.attributes = attributes; 694 var serverAttrs = options.parse ? model.parse(resp, options) : resp; 695 if (wait) serverAttrs = _.extend({}, attrs, serverAttrs); 696 if (serverAttrs && !model.set(serverAttrs, options)) return false; 697 if (success) success.call(options.context, model, resp, options); 698 model.trigger('sync', model, resp, options); 699 }; 700 wrapError(this, options); 701 702 // Set temporary attributes if `{wait: true}` to properly find new ids. 703 if (attrs && wait) this.attributes = _.extend({}, attributes, attrs); 704 705 var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); 706 if (method === 'patch' && !options.attrs) options.attrs = attrs; 707 var xhr = this.sync(method, this, options); 708 709 // Restore attributes. 710 this.attributes = attributes; 711 712 return xhr; 713 }, 714 715 // Destroy this model on the server if it was already persisted. 716 // Optimistically removes the model from its collection, if it has one. 717 // If `wait: true` is passed, waits for the server to respond before removal. 718 destroy: function(options) { 719 options = options ? _.clone(options) : {}; 720 var model = this; 721 var success = options.success; 722 var wait = options.wait; 723 724 var destroy = function() { 725 model.stopListening(); 726 model.trigger('destroy', model, model.collection, options); 727 }; 728 729 options.success = function(resp) { 730 if (wait) destroy(); 731 if (success) success.call(options.context, model, resp, options); 732 if (!model.isNew()) model.trigger('sync', model, resp, options); 733 }; 734 735 var xhr = false; 736 if (this.isNew()) { 737 _.defer(options.success); 738 } else { 739 wrapError(this, options); 740 xhr = this.sync('delete', this, options); 741 } 742 if (!wait) destroy(); 743 return xhr; 744 }, 745 746 // Default URL for the model's representation on the server -- if you're 747 // using Backbone's restful methods, override this to change the endpoint 748 // that will be called. 749 url: function() { 750 var base = 751 _.result(this, 'urlRoot') || 752 _.result(this.collection, 'url') || 753 urlError(); 754 if (this.isNew()) return base; 755 var id = this.get(this.idAttribute); 756 return base.replace(/[^\/]$/, '$&/') + encodeURIComponent(id); 757 }, 758 759 // **parse** converts a response into the hash of attributes to be `set` on 760 // the model. The default implementation is just to pass the response along. 761 parse: function(resp, options) { 762 return resp; 763 }, 764 765 // Create a new model with identical attributes to this one. 766 clone: function() { 767 return new this.constructor(this.attributes); 768 }, 769 770 // A model is new if it has never been saved to the server, and lacks an id. 771 isNew: function() { 772 return !this.has(this.idAttribute); 773 }, 774 775 // Check if the model is currently in a valid state. 776 isValid: function(options) { 777 return this._validate({}, _.extend({}, options, {validate: true})); 778 }, 779 780 // Run validation against the next complete set of model attributes, 781 // returning `true` if all is well. Otherwise, fire an `"invalid"` event. 782 _validate: function(attrs, options) { 783 if (!options.validate || !this.validate) return true; 784 attrs = _.extend({}, this.attributes, attrs); 785 var error = this.validationError = this.validate(attrs, options) || null; 786 if (!error) return true; 787 this.trigger('invalid', this, error, _.extend(options, {validationError: error})); 788 return false; 789 } 790 791 }); 792 793 // Underscore methods that we want to implement on the Model, mapped to the 794 // number of arguments they take. 795 var modelMethods = {keys: 1, values: 1, pairs: 1, invert: 1, pick: 0, 796 omit: 0, chain: 1, isEmpty: 1}; 797 798 // Mix in each Underscore method as a proxy to `Model#attributes`. 799 addUnderscoreMethods(Model, modelMethods, 'attributes'); 800 801 // Backbone.Collection 802 // ------------------- 803 804 // If models tend to represent a single row of data, a Backbone Collection is 805 // more analogous to a table full of data ... or a small slice or page of that 806 // table, or a collection of rows that belong together for a particular reason 807 // -- all of the messages in this particular folder, all of the documents 808 // belonging to this particular author, and so on. Collections maintain 809 // indexes of their models, both in order, and for lookup by `id`. 810 811 // Create a new **Collection**, perhaps to contain a specific type of `model`. 812 // If a `comparator` is specified, the Collection will maintain 813 // its models in sort order, as they're added and removed. 814 var Collection = Backbone.Collection = function(models, options) { 815 options || (options = {}); 816 if (options.model) this.model = options.model; 817 if (options.comparator !== void 0) this.comparator = options.comparator; 818 this._reset(); 819 this.initialize.apply(this, arguments); 820 if (models) this.reset(models, _.extend({silent: true}, options)); 821 }; 822 823 // Default options for `Collection#set`. 824 var setOptions = {add: true, remove: true, merge: true}; 825 var addOptions = {add: true, remove: false}; 826 827 // Splices `insert` into `array` at index `at`. 828 var splice = function(array, insert, at) { 829 at = Math.min(Math.max(at, 0), array.length); 830 var tail = Array(array.length - at); 831 var length = insert.length; 832 var i; 833 for (i = 0; i < tail.length; i++) tail[i] = array[i + at]; 834 for (i = 0; i < length; i++) array[i + at] = insert[i]; 835 for (i = 0; i < tail.length; i++) array[i + length + at] = tail[i]; 836 }; 837 838 // Define the Collection's inheritable methods. 839 _.extend(Collection.prototype, Events, { 840 841 // The default model for a collection is just a **Backbone.Model**. 842 // This should be overridden in most cases. 843 model: Model, 844 845 // Initialize is an empty function by default. Override it with your own 846 // initialization logic. 847 initialize: function(){}, 848 849 // The JSON representation of a Collection is an array of the 850 // models' attributes. 851 toJSON: function(options) { 852 return this.map(function(model) { return model.toJSON(options); }); 853 }, 854 855 // Proxy `Backbone.sync` by default. 856 sync: function() { 857 return Backbone.sync.apply(this, arguments); 858 }, 859 860 // Add a model, or list of models to the set. `models` may be Backbone 861 // Models or raw JavaScript objects to be converted to Models, or any 862 // combination of the two. 863 add: function(models, options) { 864 return this.set(models, _.extend({merge: false}, options, addOptions)); 865 }, 866 867 // Remove a model, or a list of models from the set. 868 remove: function(models, options) { 869 options = _.extend({}, options); 870 var singular = !_.isArray(models); 871 models = singular ? [models] : models.slice(); 872 var removed = this._removeModels(models, options); 873 if (!options.silent && removed.length) { 874 options.changes = {added: [], merged: [], removed: removed}; 875 this.trigger('update', this, options); 876 } 877 return singular ? removed[0] : removed; 878 }, 879 880 // Update a collection by `set`-ing a new list of models, adding new ones, 881 // removing models that are no longer present, and merging models that 882 // already exist in the collection, as necessary. Similar to **Model#set**, 883 // the core operation for updating the data contained by the collection. 884 set: function(models, options) { 885 if (models == null) return; 886 887 options = _.extend({}, setOptions, options); 888 if (options.parse && !this._isModel(models)) { 889 models = this.parse(models, options) || []; 890 } 891 892 var singular = !_.isArray(models); 893 models = singular ? [models] : models.slice(); 894 895 var at = options.at; 896 if (at != null) at = +at; 897 if (at > this.length) at = this.length; 898 if (at < 0) at += this.length + 1; 899 900 var set = []; 901 var toAdd = []; 902 var toMerge = []; 903 var toRemove = []; 904 var modelMap = {}; 905 906 var add = options.add; 907 var merge = options.merge; 908 var remove = options.remove; 909 910 var sort = false; 911 var sortable = this.comparator && at == null && options.sort !== false; 912 var sortAttr = _.isString(this.comparator) ? this.comparator : null; 913 914 // Turn bare objects into model references, and prevent invalid models 915 // from being added. 916 var model, i; 917 for (i = 0; i < models.length; i++) { 918 model = models[i]; 919 920 // If a duplicate is found, prevent it from being added and 921 // optionally merge it into the existing model. 922 var existing = this.get(model); 923 if (existing) { 924 if (merge && model !== existing) { 925 var attrs = this._isModel(model) ? model.attributes : model; 926 if (options.parse) attrs = existing.parse(attrs, options); 927 existing.set(attrs, options); 928 toMerge.push(existing); 929 if (sortable && !sort) sort = existing.hasChanged(sortAttr); 930 } 931 if (!modelMap[existing.cid]) { 932 modelMap[existing.cid] = true; 933 set.push(existing); 934 } 935 models[i] = existing; 936 937 // If this is a new, valid model, push it to the `toAdd` list. 938 } else if (add) { 939 model = models[i] = this._prepareModel(model, options); 940 if (model) { 941 toAdd.push(model); 942 this._addReference(model, options); 943 modelMap[model.cid] = true; 944 set.push(model); 945 } 946 } 947 } 948 949 // Remove stale models. 950 if (remove) { 951 for (i = 0; i < this.length; i++) { 952 model = this.models[i]; 953 if (!modelMap[model.cid]) toRemove.push(model); 954 } 955 if (toRemove.length) this._removeModels(toRemove, options); 956 } 957 958 // See if sorting is needed, update `length` and splice in new models. 959 var orderChanged = false; 960 var replace = !sortable && add && remove; 961 if (set.length && replace) { 962 orderChanged = this.length !== set.length || _.some(this.models, function(m, index) { 963 return m !== set[index]; 964 }); 965 this.models.length = 0; 966 splice(this.models, set, 0); 967 this.length = this.models.length; 968 } else if (toAdd.length) { 969 if (sortable) sort = true; 970 splice(this.models, toAdd, at == null ? this.length : at); 971 this.length = this.models.length; 972 } 973 974 // Silently sort the collection if appropriate. 975 if (sort) this.sort({silent: true}); 976 977 // Unless silenced, it's time to fire all appropriate add/sort/update events. 978 if (!options.silent) { 979 for (i = 0; i < toAdd.length; i++) { 980 if (at != null) options.index = at + i; 981 model = toAdd[i]; 982 model.trigger('add', model, this, options); 983 } 984 if (sort || orderChanged) this.trigger('sort', this, options); 985 if (toAdd.length || toRemove.length || toMerge.length) { 986 options.changes = { 987 added: toAdd, 988 removed: toRemove, 989 merged: toMerge 990 }; 991 this.trigger('update', this, options); 992 } 993 } 994 995 // Return the added (or merged) model (or models). 996 return singular ? models[0] : models; 997 }, 998 999 // When you have more items than you want to add or remove individually, 1000 // you can reset the entire set with a new list of models, without firing 1001 // any granular `add` or `remove` events. Fires `reset` when finished. 1002 // Useful for bulk operations and optimizations. 1003 reset: function(models, options) { 1004 options = options ? _.clone(options) : {}; 1005 for (var i = 0; i < this.models.length; i++) { 1006 this._removeReference(this.models[i], options); 1007 } 1008 options.previousModels = this.models; 1009 this._reset(); 1010 models = this.add(models, _.extend({silent: true}, options)); 1011 if (!options.silent) this.trigger('reset', this, options); 1012 return models; 1013 }, 1014 1015 // Add a model to the end of the collection. 1016 push: function(model, options) { 1017 return this.add(model, _.extend({at: this.length}, options)); 1018 }, 1019 1020 // Remove a model from the end of the collection. 1021 pop: function(options) { 1022 var model = this.at(this.length - 1); 1023 return this.remove(model, options); 1024 }, 1025 1026 // Add a model to the beginning of the collection. 1027 unshift: function(model, options) { 1028 return this.add(model, _.extend({at: 0}, options)); 1029 }, 1030 1031 // Remove a model from the beginning of the collection. 1032 shift: function(options) { 1033 var model = this.at(0); 1034 return this.remove(model, options); 1035 }, 1036 1037 // Slice out a sub-array of models from the collection. 1038 slice: function() { 1039 return slice.apply(this.models, arguments); 1040 }, 1041 1042 // Get a model from the set by id, cid, model object with id or cid 1043 // properties, or an attributes object that is transformed through modelId. 1044 get: function(obj) { 1045 if (obj == null) return void 0; 1046 return this._byId[obj] || 1047 this._byId[this.modelId(obj.attributes || obj)] || 1048 obj.cid && this._byId[obj.cid]; 1049 }, 1050 1051 // Returns `true` if the model is in the collection. 1052 has: function(obj) { 1053 return this.get(obj) != null; 1054 }, 1055 1056 // Get the model at the given index. 1057 at: function(index) { 1058 if (index < 0) index += this.length; 1059 return this.models[index]; 1060 }, 1061 1062 // Return models with matching attributes. Useful for simple cases of 1063 // `filter`. 1064 where: function(attrs, first) { 1065 return this[first ? 'find' : 'filter'](attrs); 1066 }, 1067 1068 // Return the first model with matching attributes. Useful for simple cases 1069 // of `find`. 1070 findWhere: function(attrs) { 1071 return this.where(attrs, true); 1072 }, 1073 1074 // Force the collection to re-sort itself. You don't need to call this under 1075 // normal circumstances, as the set will maintain sort order as each item 1076 // is added. 1077 sort: function(options) { 1078 var comparator = this.comparator; 1079 if (!comparator) throw new Error('Cannot sort a set without a comparator'); 1080 options || (options = {}); 1081 1082 var length = comparator.length; 1083 if (_.isFunction(comparator)) comparator = _.bind(comparator, this); 1084 1085 // Run sort based on type of `comparator`. 1086 if (length === 1 || _.isString(comparator)) { 1087 this.models = this.sortBy(comparator); 1088 } else { 1089 this.models.sort(comparator); 1090 } 1091 if (!options.silent) this.trigger('sort', this, options); 1092 return this; 1093 }, 1094 1095 // Pluck an attribute from each model in the collection. 1096 pluck: function(attr) { 1097 return this.map(attr + ''); 1098 }, 1099 1100 // Fetch the default set of models for this collection, resetting the 1101 // collection when they arrive. If `reset: true` is passed, the response 1102 // data will be passed through the `reset` method instead of `set`. 1103 fetch: function(options) { 1104 options = _.extend({parse: true}, options); 1105 var success = options.success; 1106 var collection = this; 1107 options.success = function(resp) { 1108 var method = options.reset ? 'reset' : 'set'; 1109 collection[method](resp, options); 1110 if (success) success.call(options.context, collection, resp, options); 1111 collection.trigger('sync', collection, resp, options); 1112 }; 1113 wrapError(this, options); 1114 return this.sync('read', this, options); 1115 }, 1116 1117 // Create a new instance of a model in this collection. Add the model to the 1118 // collection immediately, unless `wait: true` is passed, in which case we 1119 // wait for the server to agree. 1120 create: function(model, options) { 1121 options = options ? _.clone(options) : {}; 1122 var wait = options.wait; 1123 model = this._prepareModel(model, options); 1124 if (!model) return false; 1125 if (!wait) this.add(model, options); 1126 var collection = this; 1127 var success = options.success; 1128 options.success = function(m, resp, callbackOpts) { 1129 if (wait) collection.add(m, callbackOpts); 1130 if (success) success.call(callbackOpts.context, m, resp, callbackOpts); 1131 }; 1132 model.save(null, options); 1133 return model; 1134 }, 1135 1136 // **parse** converts a response into a list of models to be added to the 1137 // collection. The default implementation is just to pass it through. 1138 parse: function(resp, options) { 1139 return resp; 1140 }, 1141 1142 // Create a new collection with an identical list of models as this one. 1143 clone: function() { 1144 return new this.constructor(this.models, { 1145 model: this.model, 1146 comparator: this.comparator 1147 }); 1148 }, 1149 1150 // Define how to uniquely identify models in the collection. 1151 modelId: function(attrs) { 1152 return attrs[this.model.prototype.idAttribute || 'id']; 1153 }, 1154 1155 // Private method to reset all internal state. Called when the collection 1156 // is first initialized or reset. 1157 _reset: function() { 1158 this.length = 0; 1159 this.models = []; 1160 this._byId = {}; 1161 }, 1162 1163 // Prepare a hash of attributes (or other model) to be added to this 1164 // collection. 1165 _prepareModel: function(attrs, options) { 1166 if (this._isModel(attrs)) { 1167 if (!attrs.collection) attrs.collection = this; 1168 return attrs; 1169 } 1170 options = options ? _.clone(options) : {}; 1171 options.collection = this; 1172 var model = new this.model(attrs, options); 1173 if (!model.validationError) return model; 1174 this.trigger('invalid', this, model.validationError, options); 1175 return false; 1176 }, 1177 1178 // Internal method called by both remove and set. 1179 _removeModels: function(models, options) { 1180 var removed = []; 1181 for (var i = 0; i < models.length; i++) { 1182 var model = this.get(models[i]); 1183 if (!model) continue; 1184 1185 var index = this.indexOf(model); 1186 this.models.splice(index, 1); 1187 this.length--; 1188 1189 // Remove references before triggering 'remove' event to prevent an 1190 // infinite loop. #3693 1191 delete this._byId[model.cid]; 1192 var id = this.modelId(model.attributes); 1193 if (id != null) delete this._byId[id]; 1194 1195 if (!options.silent) { 1196 options.index = index; 1197 model.trigger('remove', model, this, options); 1198 } 1199 1200 removed.push(model); 1201 this._removeReference(model, options); 1202 } 1203 return removed; 1204 }, 1205 1206 // Method for checking whether an object should be considered a model for 1207 // the purposes of adding to the collection. 1208 _isModel: function(model) { 1209 return model instanceof Model; 1210 }, 1211 1212 // Internal method to create a model's ties to a collection. 1213 _addReference: function(model, options) { 1214 this._byId[model.cid] = model; 1215 var id = this.modelId(model.attributes); 1216 if (id != null) this._byId[id] = model; 1217 model.on('all', this._onModelEvent, this); 1218 }, 1219 1220 // Internal method to sever a model's ties to a collection. 1221 _removeReference: function(model, options) { 1222 delete this._byId[model.cid]; 1223 var id = this.modelId(model.attributes); 1224 if (id != null) delete this._byId[id]; 1225 if (this === model.collection) delete model.collection; 1226 model.off('all', this._onModelEvent, this); 1227 }, 1228 1229 // Internal method called every time a model in the set fires an event. 1230 // Sets need to update their indexes when models change ids. All other 1231 // events simply proxy through. "add" and "remove" events that originate 1232 // in other collections are ignored. 1233 _onModelEvent: function(event, model, collection, options) { 1234 if (model) { 1235 if ((event === 'add' || event === 'remove') && collection !== this) return; 1236 if (event === 'destroy') this.remove(model, options); 1237 if (event === 'change') { 1238 var prevId = this.modelId(model.previousAttributes()); 1239 var id = this.modelId(model.attributes); 1240 if (prevId !== id) { 1241 if (prevId != null) delete this._byId[prevId]; 1242 if (id != null) this._byId[id] = model; 1243 } 1244 } 1245 } 1246 this.trigger.apply(this, arguments); 1247 } 1248 1249 }); 1250 1251 // Underscore methods that we want to implement on the Collection. 1252 // 90% of the core usefulness of Backbone Collections is actually implemented 1253 // right here: 1254 var collectionMethods = {forEach: 3, each: 3, map: 3, collect: 3, reduce: 0, 1255 foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3, 1256 select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3, 1257 contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3, 1258 head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3, 1259 without: 0, difference: 0, indexOf: 3, shuffle: 1, lastIndexOf: 3, 1260 isEmpty: 1, chain: 1, sample: 3, partition: 3, groupBy: 3, countBy: 3, 1261 sortBy: 3, indexBy: 3, findIndex: 3, findLastIndex: 3}; 1262 1263 // Mix in each Underscore method as a proxy to `Collection#models`. 1264 addUnderscoreMethods(Collection, collectionMethods, 'models'); 1265 1266 // Backbone.View 1267 // ------------- 1268 1269 // Backbone Views are almost more convention than they are actual code. A View 1270 // is simply a JavaScript object that represents a logical chunk of UI in the 1271 // DOM. This might be a single item, an entire list, a sidebar or panel, or 1272 // even the surrounding frame which wraps your whole app. Defining a chunk of 1273 // UI as a **View** allows you to define your DOM events declaratively, without 1274 // having to worry about render order ... and makes it easy for the view to 1275 // react to specific changes in the state of your models. 1276 1277 // Creating a Backbone.View creates its initial element outside of the DOM, 1278 // if an existing element is not provided... 1279 var View = Backbone.View = function(options) { 1280 this.cid = _.uniqueId('view'); 1281 _.extend(this, _.pick(options, viewOptions)); 1282 this._ensureElement(); 1283 this.initialize.apply(this, arguments); 1284 }; 1285 1286 // Cached regex to split keys for `delegate`. 1287 var delegateEventSplitter = /^(\S+)\s*(.*)$/; 1288 1289 // List of view options to be set as properties. 1290 var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; 1291 1292 // Set up all inheritable **Backbone.View** properties and methods. 1293 _.extend(View.prototype, Events, { 1294 1295 // The default `tagName` of a View's element is `"div"`. 1296 tagName: 'div', 1297 1298 // jQuery delegate for element lookup, scoped to DOM elements within the 1299 // current view. This should be preferred to global lookups where possible. 1300 $: function(selector) { 1301 return this.$el.find(selector); 1302 }, 1303 1304 // Initialize is an empty function by default. Override it with your own 1305 // initialization logic. 1306 initialize: function(){}, 1307 1308 // **render** is the core function that your view should override, in order 1309 // to populate its element (`this.el`), with the appropriate HTML. The 1310 // convention is for **render** to always return `this`. 1311 render: function() { 1312 return this; 1313 }, 1314 1315 // Remove this view by taking the element out of the DOM, and removing any 1316 // applicable Backbone.Events listeners. 1317 remove: function() { 1318 this._removeElement(); 1319 this.stopListening(); 1320 return this; 1321 }, 1322 1323 // Remove this view's element from the document and all event listeners 1324 // attached to it. Exposed for subclasses using an alternative DOM 1325 // manipulation API. 1326 _removeElement: function() { 1327 this.$el.remove(); 1328 }, 1329 1330 // Change the view's element (`this.el` property) and re-delegate the 1331 // view's events on the new element. 1332 setElement: function(element) { 1333 this.undelegateEvents(); 1334 this._setElement(element); 1335 this.delegateEvents(); 1336 return this; 1337 }, 1338 1339 // Creates the `this.el` and `this.$el` references for this view using the 1340 // given `el`. `el` can be a CSS selector or an HTML string, a jQuery 1341 // context or an element. Subclasses can override this to utilize an 1342 // alternative DOM manipulation API and are only required to set the 1343 // `this.el` property. 1344 _setElement: function(el) { 1345 this.$el = el instanceof Backbone.$ ? el : Backbone.$(el); 1346 this.el = this.$el[0]; 1347 }, 1348 1349 // Set callbacks, where `this.events` is a hash of 1350 // 1351 // *{"event selector": "callback"}* 1352 // 1353 // { 1354 // 'mousedown .title': 'edit', 1355 // 'click .button': 'save', 1356 // 'click .open': function(e) { ... } 1357 // } 1358 // 1359 // pairs. Callbacks will be bound to the view, with `this` set properly. 1360 // Uses event delegation for efficiency. 1361 // Omitting the selector binds the event to `this.el`. 1362 delegateEvents: function(events) { 1363 events || (events = _.result(this, 'events')); 1364 if (!events) return this; 1365 this.undelegateEvents(); 1366 for (var key in events) { 1367 var method = events[key]; 1368 if (!_.isFunction(method)) method = this[method]; 1369 if (!method) continue; 1370 var match = key.match(delegateEventSplitter); 1371 this.delegate(match[1], match[2], _.bind(method, this)); 1372 } 1373 return this; 1374 }, 1375 1376 // Add a single event listener to the view's element (or a child element 1377 // using `selector`). This only works for delegate-able events: not `focus`, 1378 // `blur`, and not `change`, `submit`, and `reset` in Internet Explorer. 1379 delegate: function(eventName, selector, listener) { 1380 this.$el.on(eventName + '.delegateEvents' + this.cid, selector, listener); 1381 return this; 1382 }, 1383 1384 // Clears all callbacks previously bound to the view by `delegateEvents`. 1385 // You usually don't need to use this, but may wish to if you have multiple 1386 // Backbone views attached to the same DOM element. 1387 undelegateEvents: function() { 1388 if (this.$el) this.$el.off('.delegateEvents' + this.cid); 1389 return this; 1390 }, 1391 1392 // A finer-grained `undelegateEvents` for removing a single delegated event. 1393 // `selector` and `listener` are both optional. 1394 undelegate: function(eventName, selector, listener) { 1395 this.$el.off(eventName + '.delegateEvents' + this.cid, selector, listener); 1396 return this; 1397 }, 1398 1399 // Produces a DOM element to be assigned to your view. Exposed for 1400 // subclasses using an alternative DOM manipulation API. 1401 _createElement: function(tagName) { 1402 return document.createElement(tagName); 1403 }, 1404 1405 // Ensure that the View has a DOM element to render into. 1406 // If `this.el` is a string, pass it through `$()`, take the first 1407 // matching element, and re-assign it to `el`. Otherwise, create 1408 // an element from the `id`, `className` and `tagName` properties. 1409 _ensureElement: function() { 1410 if (!this.el) { 1411 var attrs = _.extend({}, _.result(this, 'attributes')); 1412 if (this.id) attrs.id = _.result(this, 'id'); 1413 if (this.className) attrs['class'] = _.result(this, 'className'); 1414 this.setElement(this._createElement(_.result(this, 'tagName'))); 1415 this._setAttributes(attrs); 1416 } else { 1417 this.setElement(_.result(this, 'el')); 1418 } 1419 }, 1420 1421 // Set attributes from a hash on this view's element. Exposed for 1422 // subclasses using an alternative DOM manipulation API. 1423 _setAttributes: function(attributes) { 1424 this.$el.attr(attributes); 1425 } 1426 1427 }); 1428 1429 // Backbone.sync 1430 // ------------- 1431 1432 // Override this function to change the manner in which Backbone persists 1433 // models to the server. You will be passed the type of request, and the 1434 // model in question. By default, makes a RESTful Ajax request 1435 // to the model's `url()`. Some possible customizations could be: 1436 // 1437 // * Use `setTimeout` to batch rapid-fire updates into a single request. 1438 // * Send up the models as XML instead of JSON. 1439 // * Persist models via WebSockets instead of Ajax. 1440 // 1441 // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests 1442 // as `POST`, with a `_method` parameter containing the true HTTP method, 1443 // as well as all requests with the body as `application/x-www-form-urlencoded` 1444 // instead of `application/json` with the model in a param named `model`. 1445 // Useful when interfacing with server-side languages like **PHP** that make 1446 // it difficult to read the body of `PUT` requests. 1447 Backbone.sync = function(method, model, options) { 1448 var type = methodMap[method]; 1449 1450 // Default options, unless specified. 1451 _.defaults(options || (options = {}), { 1452 emulateHTTP: Backbone.emulateHTTP, 1453 emulateJSON: Backbone.emulateJSON 1454 }); 1455 1456 // Default JSON-request options. 1457 var params = {type: type, dataType: 'json'}; 1458 1459 // Ensure that we have a URL. 1460 if (!options.url) { 1461 params.url = _.result(model, 'url') || urlError(); 1462 } 1463 1464 // Ensure that we have the appropriate request data. 1465 if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { 1466 params.contentType = 'application/json'; 1467 params.data = JSON.stringify(options.attrs || model.toJSON(options)); 1468 } 1469 1470 // For older servers, emulate JSON by encoding the request into an HTML-form. 1471 if (options.emulateJSON) { 1472 params.contentType = 'application/x-www-form-urlencoded'; 1473 params.data = params.data ? {model: params.data} : {}; 1474 } 1475 1476 // For older servers, emulate HTTP by mimicking the HTTP method with `_method` 1477 // And an `X-HTTP-Method-Override` header. 1478 if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { 1479 params.type = 'POST'; 1480 if (options.emulateJSON) params.data._method = type; 1481 var beforeSend = options.beforeSend; 1482 options.beforeSend = function(xhr) { 1483 xhr.setRequestHeader('X-HTTP-Method-Override', type); 1484 if (beforeSend) return beforeSend.apply(this, arguments); 1485 }; 1486 } 1487 1488 // Don't process data on a non-GET request. 1489 if (params.type !== 'GET' && !options.emulateJSON) { 1490 params.processData = false; 1491 } 1492 1493 // Pass along `textStatus` and `errorThrown` from jQuery. 1494 var error = options.error; 1495 options.error = function(xhr, textStatus, errorThrown) { 1496 options.textStatus = textStatus; 1497 options.errorThrown = errorThrown; 1498 if (error) error.call(options.context, xhr, textStatus, errorThrown); 1499 }; 1500 1501 // Make the request, allowing the user to override any Ajax options. 1502 var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); 1503 model.trigger('request', model, xhr, options); 1504 return xhr; 1505 }; 1506 1507 // Map from CRUD to HTTP for our default `Backbone.sync` implementation. 1508 var methodMap = { 1509 'create': 'POST', 1510 'update': 'PUT', 1511 'patch': 'PATCH', 1512 'delete': 'DELETE', 1513 'read': 'GET' 1514 }; 1515 1516 // Set the default implementation of `Backbone.ajax` to proxy through to `$`. 1517 // Override this if you'd like to use a different library. 1518 Backbone.ajax = function() { 1519 return Backbone.$.ajax.apply(Backbone.$, arguments); 1520 }; 1521 1522 // Backbone.Router 1523 // --------------- 1524 1525 // Routers map faux-URLs to actions, and fire events when routes are 1526 // matched. Creating a new one sets its `routes` hash, if not set statically. 1527 var Router = Backbone.Router = function(options) { 1528 options || (options = {}); 1529 if (options.routes) this.routes = options.routes; 1530 this._bindRoutes(); 1531 this.initialize.apply(this, arguments); 1532 }; 1533 1534 // Cached regular expressions for matching named param parts and splatted 1535 // parts of route strings. 1536 var optionalParam = /\((.*?)\)/g; 1537 var namedParam = /(\(\?)?:\w+/g; 1538 var splatParam = /\*\w+/g; 1539 var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; 1540 1541 // Set up all inheritable **Backbone.Router** properties and methods. 1542 _.extend(Router.prototype, Events, { 1543 1544 // Initialize is an empty function by default. Override it with your own 1545 // initialization logic. 1546 initialize: function(){}, 1547 1548 // Manually bind a single named route to a callback. For example: 1549 // 1550 // this.route('search/:query/p:num', 'search', function(query, num) { 1551 // ... 1552 // }); 1553 // 1554 route: function(route, name, callback) { 1555 if (!_.isRegExp(route)) route = this._routeToRegExp(route); 1556 if (_.isFunction(name)) { 1557 callback = name; 1558 name = ''; 1559 } 1560 if (!callback) callback = this[name]; 1561 var router = this; 1562 Backbone.history.route(route, function(fragment) { 1563 var args = router._extractParameters(route, fragment); 1564 if (router.execute(callback, args, name) !== false) { 1565 router.trigger.apply(router, ['route:' + name].concat(args)); 1566 router.trigger('route', name, args); 1567 Backbone.history.trigger('route', router, name, args); 1568 } 1569 }); 1570 return this; 1571 }, 1572 1573 // Execute a route handler with the provided parameters. This is an 1574 // excellent place to do pre-route setup or post-route cleanup. 1575 execute: function(callback, args, name) { 1576 if (callback) callback.apply(this, args); 1577 }, 1578 1579 // Simple proxy to `Backbone.history` to save a fragment into the history. 1580 navigate: function(fragment, options) { 1581 Backbone.history.navigate(fragment, options); 1582 return this; 1583 }, 1584 1585 // Bind all defined routes to `Backbone.history`. We have to reverse the 1586 // order of the routes here to support behavior where the most general 1587 // routes can be defined at the bottom of the route map. 1588 _bindRoutes: function() { 1589 if (!this.routes) return; 1590 this.routes = _.result(this, 'routes'); 1591 var route, routes = _.keys(this.routes); 1592 while ((route = routes.pop()) != null) { 1593 this.route(route, this.routes[route]); 1594 } 1595 }, 1596 1597 // Convert a route string into a regular expression, suitable for matching 1598 // against the current location hash. 1599 _routeToRegExp: function(route) { 1600 route = route.replace(escapeRegExp, '\\$&') 1601 .replace(optionalParam, '(?:$1)?') 1602 .replace(namedParam, function(match, optional) { 1603 return optional ? match : '([^/?]+)'; 1604 }) 1605 .replace(splatParam, '([^?]*?)'); 1606 return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$'); 1607 }, 1608 1609 // Given a route, and a URL fragment that it matches, return the array of 1610 // extracted decoded parameters. Empty or unmatched parameters will be 1611 // treated as `null` to normalize cross-browser behavior. 1612 _extractParameters: function(route, fragment) { 1613 var params = route.exec(fragment).slice(1); 1614 return _.map(params, function(param, i) { 1615 // Don't decode the search params. 1616 if (i === params.length - 1) return param || null; 1617 return param ? decodeURIComponent(param) : null; 1618 }); 1619 } 1620 1621 }); 1622 1623 // Backbone.History 1624 // ---------------- 1625 1626 // Handles cross-browser history management, based on either 1627 // [pushState](http://diveintohtml5.info/history.html) and real URLs, or 1628 // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange) 1629 // and URL fragments. If the browser supports neither (old IE, natch), 1630 // falls back to polling. 1631 var History = Backbone.History = function() { 1632 this.handlers = []; 1633 this.checkUrl = _.bind(this.checkUrl, this); 1634 1635 // Ensure that `History` can be used outside of the browser. 1636 if (typeof window !== 'undefined') { 1637 this.location = window.location; 1638 this.history = window.history; 1639 } 1640 }; 1641 1642 // Cached regex for stripping a leading hash/slash and trailing space. 1643 var routeStripper = /^[#\/]|\s+$/g; 1644 1645 // Cached regex for stripping leading and trailing slashes. 1646 var rootStripper = /^\/+|\/+$/g; 1647 1648 // Cached regex for stripping urls of hash. 1649 var pathStripper = /#.*$/; 1650 1651 // Has the history handling already been started? 1652 History.started = false; 1653 1654 // Set up all inheritable **Backbone.History** properties and methods. 1655 _.extend(History.prototype, Events, { 1656 1657 // The default interval to poll for hash changes, if necessary, is 1658 // twenty times a second. 1659 interval: 50, 1660 1661 // Are we at the app root? 1662 atRoot: function() { 1663 var path = this.location.pathname.replace(/[^\/]$/, '$&/'); 1664 return path === this.root && !this.getSearch(); 1665 }, 1666 1667 // Does the pathname match the root? 1668 matchRoot: function() { 1669 var path = this.decodeFragment(this.location.pathname); 1670 var rootPath = path.slice(0, this.root.length - 1) + '/'; 1671 return rootPath === this.root; 1672 }, 1673 1674 // Unicode characters in `location.pathname` are percent encoded so they're 1675 // decoded for comparison. `%25` should not be decoded since it may be part 1676 // of an encoded parameter. 1677 decodeFragment: function(fragment) { 1678 return decodeURI(fragment.replace(/%25/g, '%2525')); 1679 }, 1680 1681 // In IE6, the hash fragment and search params are incorrect if the 1682 // fragment contains `?`. 1683 getSearch: function() { 1684 var match = this.location.href.replace(/#.*/, '').match(/\?.+/); 1685 return match ? match[0] : ''; 1686 }, 1687 1688 // Gets the true hash value. Cannot use location.hash directly due to bug 1689 // in Firefox where location.hash will always be decoded. 1690 getHash: function(window) { 1691 var match = (window || this).location.href.match(/#(.*)$/); 1692 return match ? match[1] : ''; 1693 }, 1694 1695 // Get the pathname and search params, without the root. 1696 getPath: function() { 1697 var path = this.decodeFragment( 1698 this.location.pathname + this.getSearch() 1699 ).slice(this.root.length - 1); 1700 return path.charAt(0) === '/' ? path.slice(1) : path; 1701 }, 1702 1703 // Get the cross-browser normalized URL fragment from the path or hash. 1704 getFragment: function(fragment) { 1705 if (fragment == null) { 1706 if (this._usePushState || !this._wantsHashChange) { 1707 fragment = this.getPath(); 1708 } else { 1709 fragment = this.getHash(); 1710 } 1711 } 1712 return fragment.replace(routeStripper, ''); 1713 }, 1714 1715 // Start the hash change handling, returning `true` if the current URL matches 1716 // an existing route, and `false` otherwise. 1717 start: function(options) { 1718 if (History.started) throw new Error('Backbone.history has already been started'); 1719 History.started = true; 1720 1721 // Figure out the initial configuration. Do we need an iframe? 1722 // Is pushState desired ... is it available? 1723 this.options = _.extend({root: '/'}, this.options, options); 1724 this.root = this.options.root; 1725 this._wantsHashChange = this.options.hashChange !== false; 1726 this._hasHashChange = 'onhashchange' in window && (document.documentMode === void 0 || document.documentMode > 7); 1727 this._useHashChange = this._wantsHashChange && this._hasHashChange; 1728 this._wantsPushState = !!this.options.pushState; 1729 this._hasPushState = !!(this.history && this.history.pushState); 1730 this._usePushState = this._wantsPushState && this._hasPushState; 1731 this.fragment = this.getFragment(); 1732 1733 // Normalize root to always include a leading and trailing slash. 1734 this.root = ('/' + this.root + '/').replace(rootStripper, '/'); 1735 1736 // Transition from hashChange to pushState or vice versa if both are 1737 // requested. 1738 if (this._wantsHashChange && this._wantsPushState) { 1739 1740 // If we've started off with a route from a `pushState`-enabled 1741 // browser, but we're currently in a browser that doesn't support it... 1742 if (!this._hasPushState && !this.atRoot()) { 1743 var rootPath = this.root.slice(0, -1) || '/'; 1744 this.location.replace(rootPath + '#' + this.getPath()); 1745 // Return immediately as browser will do redirect to new url 1746 return true; 1747 1748 // Or if we've started out with a hash-based route, but we're currently 1749 // in a browser where it could be `pushState`-based instead... 1750 } else if (this._hasPushState && this.atRoot()) { 1751 this.navigate(this.getHash(), {replace: true}); 1752 } 1753 1754 } 1755 1756 // Proxy an iframe to handle location events if the browser doesn't 1757 // support the `hashchange` event, HTML5 history, or the user wants 1758 // `hashChange` but not `pushState`. 1759 if (!this._hasHashChange && this._wantsHashChange && !this._usePushState) { 1760 this.iframe = document.createElement('iframe'); 1761 this.iframe.src = 'javascript:0'; 1762 this.iframe.style.display = 'none'; 1763 this.iframe.tabIndex = -1; 1764 var body = document.body; 1765 // Using `appendChild` will throw on IE < 9 if the document is not ready. 1766 var iWindow = body.insertBefore(this.iframe, body.firstChild).contentWindow; 1767 iWindow.document.open(); 1768 iWindow.document.close(); 1769 iWindow.location.hash = '#' + this.fragment; 1770 } 1771 1772 // Add a cross-platform `addEventListener` shim for older browsers. 1773 var addEventListener = window.addEventListener || function(eventName, listener) { 1774 return attachEvent('on' + eventName, listener); 1775 }; 1776 1777 // Depending on whether we're using pushState or hashes, and whether 1778 // 'onhashchange' is supported, determine how we check the URL state. 1779 if (this._usePushState) { 1780 addEventListener('popstate', this.checkUrl, false); 1781 } else if (this._useHashChange && !this.iframe) { 1782 addEventListener('hashchange', this.checkUrl, false); 1783 } else if (this._wantsHashChange) { 1784 this._checkUrlInterval = setInterval(this.checkUrl, this.interval); 1785 } 1786 1787 if (!this.options.silent) return this.loadUrl(); 1788 }, 1789 1790 // Disable Backbone.history, perhaps temporarily. Not useful in a real app, 1791 // but possibly useful for unit testing Routers. 1792 stop: function() { 1793 // Add a cross-platform `removeEventListener` shim for older browsers. 1794 var removeEventListener = window.removeEventListener || function(eventName, listener) { 1795 return detachEvent('on' + eventName, listener); 1796 }; 1797 1798 // Remove window listeners. 1799 if (this._usePushState) { 1800 removeEventListener('popstate', this.checkUrl, false); 1801 } else if (this._useHashChange && !this.iframe) { 1802 removeEventListener('hashchange', this.checkUrl, false); 1803 } 1804 1805 // Clean up the iframe if necessary. 1806 if (this.iframe) { 1807 document.body.removeChild(this.iframe); 1808 this.iframe = null; 1809 } 1810 1811 // Some environments will throw when clearing an undefined interval. 1812 if (this._checkUrlInterval) clearInterval(this._checkUrlInterval); 1813 History.started = false; 1814 }, 1815 1816 // Add a route to be tested when the fragment changes. Routes added later 1817 // may override previous routes. 1818 route: function(route, callback) { 1819 this.handlers.unshift({route: route, callback: callback}); 1820 }, 1821 1822 // Checks the current URL to see if it has changed, and if it has, 1823 // calls `loadUrl`, normalizing across the hidden iframe. 1824 checkUrl: function(e) { 1825 var current = this.getFragment(); 1826 1827 // If the user pressed the back button, the iframe's hash will have 1828 // changed and we should use that for comparison. 1829 if (current === this.fragment && this.iframe) { 1830 current = this.getHash(this.iframe.contentWindow); 1831 } 1832 1833 if (current === this.fragment) return false; 1834 if (this.iframe) this.navigate(current); 1835 this.loadUrl(); 1836 }, 1837 1838 // Attempt to load the current URL fragment. If a route succeeds with a 1839 // match, returns `true`. If no defined routes matches the fragment, 1840 // returns `false`. 1841 loadUrl: function(fragment) { 1842 // If the root doesn't match, no routes can match either. 1843 if (!this.matchRoot()) return false; 1844 fragment = this.fragment = this.getFragment(fragment); 1845 return _.some(this.handlers, function(handler) { 1846 if (handler.route.test(fragment)) { 1847 handler.callback(fragment); 1848 return true; 1849 } 1850 }); 1851 }, 1852 1853 // Save a fragment into the hash history, or replace the URL state if the 1854 // 'replace' option is passed. You are responsible for properly URL-encoding 1855 // the fragment in advance. 1856 // 1857 // The options object can contain `trigger: true` if you wish to have the 1858 // route callback be fired (not usually desirable), or `replace: true`, if 1859 // you wish to modify the current URL without adding an entry to the history. 1860 navigate: function(fragment, options) { 1861 if (!History.started) return false; 1862 if (!options || options === true) options = {trigger: !!options}; 1863 1864 // Normalize the fragment. 1865 fragment = this.getFragment(fragment || ''); 1866 1867 // Don't include a trailing slash on the root. 1868 var rootPath = this.root; 1869 if (fragment === '' || fragment.charAt(0) === '?') { 1870 rootPath = rootPath.slice(0, -1) || '/'; 1871 } 1872 var url = rootPath + fragment; 1873 1874 // Strip the hash and decode for matching. 1875 fragment = this.decodeFragment(fragment.replace(pathStripper, '')); 1876 1877 if (this.fragment === fragment) return; 1878 this.fragment = fragment; 1879 1880 // If pushState is available, we use it to set the fragment as a real URL. 1881 if (this._usePushState) { 1882 this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url); 1883 1884 // If hash changes haven't been explicitly disabled, update the hash 1885 // fragment to store history. 1886 } else if (this._wantsHashChange) { 1887 this._updateHash(this.location, fragment, options.replace); 1888 if (this.iframe && fragment !== this.getHash(this.iframe.contentWindow)) { 1889 var iWindow = this.iframe.contentWindow; 1890 1891 // Opening and closing the iframe tricks IE7 and earlier to push a 1892 // history entry on hash-tag change. When replace is true, we don't 1893 // want this. 1894 if (!options.replace) { 1895 iWindow.document.open(); 1896 iWindow.document.close(); 1897 } 1898 1899 this._updateHash(iWindow.location, fragment, options.replace); 1900 } 1901 1902 // If you've told us that you explicitly don't want fallback hashchange- 1903 // based history, then `navigate` becomes a page refresh. 1904 } else { 1905 return this.location.assign(url); 1906 } 1907 if (options.trigger) return this.loadUrl(fragment); 1908 }, 1909 1910 // Update the hash location, either replacing the current entry, or adding 1911 // a new one to the browser history. 1912 _updateHash: function(location, fragment, replace) { 1913 if (replace) { 1914 var href = location.href.replace(/(javascript:|#).*$/, ''); 1915 location.replace(href + '#' + fragment); 1916 } else { 1917 // Some browsers require that `hash` contains a leading #. 1918 location.hash = '#' + fragment; 1919 } 1920 } 1921 1922 }); 1923 1924 // Create the default Backbone.history. 1925 Backbone.history = new History; 1926 1927 // Helpers 1928 // ------- 1929 1930 // Helper function to correctly set up the prototype chain for subclasses. 1931 // Similar to `goog.inherits`, but uses a hash of prototype properties and 1932 // class properties to be extended. 1933 var extend = function(protoProps, staticProps) { 1934 var parent = this; 1935 var child; 1936 1937 // The constructor function for the new subclass is either defined by you 1938 // (the "constructor" property in your `extend` definition), or defaulted 1939 // by us to simply call the parent constructor. 1940 if (protoProps && _.has(protoProps, 'constructor')) { 1941 child = protoProps.constructor; 1942 } else { 1943 child = function(){ return parent.apply(this, arguments); }; 1944 } 1945 1946 // Add static properties to the constructor function, if supplied. 1947 _.extend(child, parent, staticProps); 1948 1949 // Set the prototype chain to inherit from `parent`, without calling 1950 // `parent`'s constructor function and add the prototype properties. 1951 child.prototype = _.create(parent.prototype, protoProps); 1952 child.prototype.constructor = child; 1953 1954 // Set a convenience property in case the parent's prototype is needed 1955 // later. 1956 child.__super__ = parent.prototype; 1957 1958 return child; 1959 }; 1960 1961 // Set up inheritance for the model, collection, router, view and history. 1962 Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend; 1963 1964 // Throw an error when a URL is needed, and none is supplied. 1965 var urlError = function() { 1966 throw new Error('A "url" property or function must be specified'); 1967 }; 1968 1969 // Wrap an optional error callback with a fallback error event. 1970 var wrapError = function(model, options) { 1971 var error = options.error; 1972 options.error = function(resp) { 1973 if (error) error.call(options.context, model, resp, options); 1974 model.trigger('error', model, resp, options); 1975 }; 1976 }; 1977 1978 return Backbone; 1979 }); 1980 1981 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) 1982 1983 /***/ }, 1984 /* 3 */ 1985 /***/ function(module, exports, __webpack_require__) { 1986 1987 'use strict'; 1988 1989 var YAMLException = __webpack_require__(11); 1990 1991 var TYPE_CONSTRUCTOR_OPTIONS = [ 1992 'kind', 1993 'resolve', 1994 'construct', 1995 'instanceOf', 1996 'predicate', 1997 'represent', 1998 'defaultStyle', 1999 'styleAliases' 2000 ]; 2001 2002 var YAML_NODE_KINDS = [ 2003 'scalar', 2004 'sequence', 2005 'mapping' 2006 ]; 2007 2008 function compileStyleAliases(map) { 2009 var result = {}; 2010 2011 if (map !== null) { 2012 Object.keys(map).forEach(function (style) { 2013 map[style].forEach(function (alias) { 2014 result[String(alias)] = style; 2015 }); 2016 }); 2017 } 2018 2019 return result; 2020 } 2021 2022 function Type(tag, options) { 2023 options = options || {}; 2024 2025 Object.keys(options).forEach(function (name) { 2026 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { 2027 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); 2028 } 2029 }); 2030 2031 // TODO: Add tag format check. 2032 this.tag = tag; 2033 this.kind = options['kind'] || null; 2034 this.resolve = options['resolve'] || function () { return true; }; 2035 this.construct = options['construct'] || function (data) { return data; }; 2036 this.instanceOf = options['instanceOf'] || null; 2037 this.predicate = options['predicate'] || null; 2038 this.represent = options['represent'] || null; 2039 this.defaultStyle = options['defaultStyle'] || null; 2040 this.styleAliases = compileStyleAliases(options['styleAliases'] || null); 2041 2042 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { 2043 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); 2044 } 2045 } 2046 2047 module.exports = Type; 2048 2049 2050 /***/ }, 2051 /* 4 */ 2052 /***/ function(module, exports, __webpack_require__) { 2053 2054 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscore.js 1.8.3 2055 // http://underscorejs.org 2056 // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 2057 // Underscore may be freely distributed under the MIT license. 2058 2059 (function() { 2060 2061 // Baseline setup 2062 // -------------- 2063 2064 // Establish the root object, `window` in the browser, or `exports` on the server. 2065 var root = this; 2066 2067 // Save the previous value of the `_` variable. 2068 var previousUnderscore = root._; 2069 2070 // Save bytes in the minified (but not gzipped) version: 2071 var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; 2072 2073 // Create quick reference variables for speed access to core prototypes. 2074 var 2075 push = ArrayProto.push, 2076 slice = ArrayProto.slice, 2077 toString = ObjProto.toString, 2078 hasOwnProperty = ObjProto.hasOwnProperty; 2079 2080 // All **ECMAScript 5** native function implementations that we hope to use 2081 // are declared here. 2082 var 2083 nativeIsArray = Array.isArray, 2084 nativeKeys = Object.keys, 2085 nativeBind = FuncProto.bind, 2086 nativeCreate = Object.create; 2087 2088 // Naked function reference for surrogate-prototype-swapping. 2089 var Ctor = function(){}; 2090 2091 // Create a safe reference to the Underscore object for use below. 2092 var _ = function(obj) { 2093 if (obj instanceof _) return obj; 2094 if (!(this instanceof _)) return new _(obj); 2095 this._wrapped = obj; 2096 }; 2097 2098 // Export the Underscore object for **Node.js**, with 2099 // backwards-compatibility for the old `require()` API. If we're in 2100 // the browser, add `_` as a global object. 2101 if (true) { 2102 if (typeof module !== 'undefined' && module.exports) { 2103 exports = module.exports = _; 2104 } 2105 exports._ = _; 2106 } else { 2107 root._ = _; 2108 } 2109 2110 // Current version. 2111 _.VERSION = '1.8.3'; 2112 2113 // Internal function that returns an efficient (for current engines) version 2114 // of the passed-in callback, to be repeatedly applied in other Underscore 2115 // functions. 2116 var optimizeCb = function(func, context, argCount) { 2117 if (context === void 0) return func; 2118 switch (argCount == null ? 3 : argCount) { 2119 case 1: return function(value) { 2120 return func.call(context, value); 2121 }; 2122 case 2: return function(value, other) { 2123 return func.call(context, value, other); 2124 }; 2125 case 3: return function(value, index, collection) { 2126 return func.call(context, value, index, collection); 2127 }; 2128 case 4: return function(accumulator, value, index, collection) { 2129 return func.call(context, accumulator, value, index, collection); 2130 }; 2131 } 2132 return function() { 2133 return func.apply(context, arguments); 2134 }; 2135 }; 2136 2137 // A mostly-internal function to generate callbacks that can be applied 2138 // to each element in a collection, returning the desired result — either 2139 // identity, an arbitrary callback, a property matcher, or a property accessor. 2140 var cb = function(value, context, argCount) { 2141 if (value == null) return _.identity; 2142 if (_.isFunction(value)) return optimizeCb(value, context, argCount); 2143 if (_.isObject(value)) return _.matcher(value); 2144 return _.property(value); 2145 }; 2146 _.iteratee = function(value, context) { 2147 return cb(value, context, Infinity); 2148 }; 2149 2150 // An internal function for creating assigner functions. 2151 var createAssigner = function(keysFunc, undefinedOnly) { 2152 return function(obj) { 2153 var length = arguments.length; 2154 if (length < 2 || obj == null) return obj; 2155 for (var index = 1; index < length; index++) { 2156 var source = arguments[index], 2157 keys = keysFunc(source), 2158 l = keys.length; 2159 for (var i = 0; i < l; i++) { 2160 var key = keys[i]; 2161 if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; 2162 } 2163 } 2164 return obj; 2165 }; 2166 }; 2167 2168 // An internal function for creating a new object that inherits from another. 2169 var baseCreate = function(prototype) { 2170 if (!_.isObject(prototype)) return {}; 2171 if (nativeCreate) return nativeCreate(prototype); 2172 Ctor.prototype = prototype; 2173 var result = new Ctor; 2174 Ctor.prototype = null; 2175 return result; 2176 }; 2177 2178 var property = function(key) { 2179 return function(obj) { 2180 return obj == null ? void 0 : obj[key]; 2181 }; 2182 }; 2183 2184 // Helper for collection methods to determine whether a collection 2185 // should be iterated as an array or as an object 2186 // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength 2187 // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 2188 var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; 2189 var getLength = property('length'); 2190 var isArrayLike = function(collection) { 2191 var length = getLength(collection); 2192 return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX; 2193 }; 2194 2195 // Collection Functions 2196 // -------------------- 2197 2198 // The cornerstone, an `each` implementation, aka `forEach`. 2199 // Handles raw objects in addition to array-likes. Treats all 2200 // sparse array-likes as if they were dense. 2201 _.each = _.forEach = function(obj, iteratee, context) { 2202 iteratee = optimizeCb(iteratee, context); 2203 var i, length; 2204 if (isArrayLike(obj)) { 2205 for (i = 0, length = obj.length; i < length; i++) { 2206 iteratee(obj[i], i, obj); 2207 } 2208 } else { 2209 var keys = _.keys(obj); 2210 for (i = 0, length = keys.length; i < length; i++) { 2211 iteratee(obj[keys[i]], keys[i], obj); 2212 } 2213 } 2214 return obj; 2215 }; 2216 2217 // Return the results of applying the iteratee to each element. 2218 _.map = _.collect = function(obj, iteratee, context) { 2219 iteratee = cb(iteratee, context); 2220 var keys = !isArrayLike(obj) && _.keys(obj), 2221 length = (keys || obj).length, 2222 results = Array(length); 2223 for (var index = 0; index < length; index++) { 2224 var currentKey = keys ? keys[index] : index; 2225 results[index] = iteratee(obj[currentKey], currentKey, obj); 2226 } 2227 return results; 2228 }; 2229 2230 // Create a reducing function iterating left or right. 2231 function createReduce(dir) { 2232 // Optimized iterator function as using arguments.length 2233 // in the main function will deoptimize the, see #1991. 2234 function iterator(obj, iteratee, memo, keys, index, length) { 2235 for (; index >= 0 && index < length; index += dir) { 2236 var currentKey = keys ? keys[index] : index; 2237 memo = iteratee(memo, obj[currentKey], currentKey, obj); 2238 } 2239 return memo; 2240 } 2241 2242 return function(obj, iteratee, memo, context) { 2243 iteratee = optimizeCb(iteratee, context, 4); 2244 var keys = !isArrayLike(obj) && _.keys(obj), 2245 length = (keys || obj).length, 2246 index = dir > 0 ? 0 : length - 1; 2247 // Determine the initial value if none is provided. 2248 if (arguments.length < 3) { 2249 memo = obj[keys ? keys[index] : index]; 2250 index += dir; 2251 } 2252 return iterator(obj, iteratee, memo, keys, index, length); 2253 }; 2254 } 2255 2256 // **Reduce** builds up a single result from a list of values, aka `inject`, 2257 // or `foldl`. 2258 _.reduce = _.foldl = _.inject = createReduce(1); 2259 2260 // The right-associative version of reduce, also known as `foldr`. 2261 _.reduceRight = _.foldr = createReduce(-1); 2262 2263 // Return the first value which passes a truth test. Aliased as `detect`. 2264 _.find = _.detect = function(obj, predicate, context) { 2265 var key; 2266 if (isArrayLike(obj)) { 2267 key = _.findIndex(obj, predicate, context); 2268 } else { 2269 key = _.findKey(obj, predicate, context); 2270 } 2271 if (key !== void 0 && key !== -1) return obj[key]; 2272 }; 2273 2274 // Return all the elements that pass a truth test. 2275 // Aliased as `select`. 2276 _.filter = _.select = function(obj, predicate, context) { 2277 var results = []; 2278 predicate = cb(predicate, context); 2279 _.each(obj, function(value, index, list) { 2280 if (predicate(value, index, list)) results.push(value); 2281 }); 2282 return results; 2283 }; 2284 2285 // Return all the elements for which a truth test fails. 2286 _.reject = function(obj, predicate, context) { 2287 return _.filter(obj, _.negate(cb(predicate)), context); 2288 }; 2289 2290 // Determine whether all of the elements match a truth test. 2291 // Aliased as `all`. 2292 _.every = _.all = function(obj, predicate, context) { 2293 predicate = cb(predicate, context); 2294 var keys = !isArrayLike(obj) && _.keys(obj), 2295 length = (keys || obj).length; 2296 for (var index = 0; index < length; index++) { 2297 var currentKey = keys ? keys[index] : index; 2298 if (!predicate(obj[currentKey], currentKey, obj)) return false; 2299 } 2300 return true; 2301 }; 2302 2303 // Determine if at least one element in the object matches a truth test. 2304 // Aliased as `any`. 2305 _.some = _.any = function(obj, predicate, context) { 2306 predicate = cb(predicate, context); 2307 var keys = !isArrayLike(obj) && _.keys(obj), 2308 length = (keys || obj).length; 2309 for (var index = 0; index < length; index++) { 2310 var currentKey = keys ? keys[index] : index; 2311 if (predicate(obj[currentKey], currentKey, obj)) return true; 2312 } 2313 return false; 2314 }; 2315 2316 // Determine if the array or object contains a given item (using `===`). 2317 // Aliased as `includes` and `include`. 2318 _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { 2319 if (!isArrayLike(obj)) obj = _.values(obj); 2320 if (typeof fromIndex != 'number' || guard) fromIndex = 0; 2321 return _.indexOf(obj, item, fromIndex) >= 0; 2322 }; 2323 2324 // Invoke a method (with arguments) on every item in a collection. 2325 _.invoke = function(obj, method) { 2326 var args = slice.call(arguments, 2); 2327 var isFunc = _.isFunction(method); 2328 return _.map(obj, function(value) { 2329 var func = isFunc ? method : value[method]; 2330 return func == null ? func : func.apply(value, args); 2331 }); 2332 }; 2333 2334 // Convenience version of a common use case of `map`: fetching a property. 2335 _.pluck = function(obj, key) { 2336 return _.map(obj, _.property(key)); 2337 }; 2338 2339 // Convenience version of a common use case of `filter`: selecting only objects 2340 // containing specific `key:value` pairs. 2341 _.where = function(obj, attrs) { 2342 return _.filter(obj, _.matcher(attrs)); 2343 }; 2344 2345 // Convenience version of a common use case of `find`: getting the first object 2346 // containing specific `key:value` pairs. 2347 _.findWhere = function(obj, attrs) { 2348 return _.find(obj, _.matcher(attrs)); 2349 }; 2350 2351 // Return the maximum element (or element-based computation). 2352 _.max = function(obj, iteratee, context) { 2353 var result = -Infinity, lastComputed = -Infinity, 2354 value, computed; 2355 if (iteratee == null && obj != null) { 2356 obj = isArrayLike(obj) ? obj : _.values(obj); 2357 for (var i = 0, length = obj.length; i < length; i++) { 2358 value = obj[i]; 2359 if (value > result) { 2360 result = value; 2361 } 2362 } 2363 } else { 2364 iteratee = cb(iteratee, context); 2365 _.each(obj, function(value, index, list) { 2366 computed = iteratee(value, index, list); 2367 if (computed > lastComputed || computed === -Infinity && result === -Infinity) { 2368 result = value; 2369 lastComputed = computed; 2370 } 2371 }); 2372 } 2373 return result; 2374 }; 2375 2376 // Return the minimum element (or element-based computation). 2377 _.min = function(obj, iteratee, context) { 2378 var result = Infinity, lastComputed = Infinity, 2379 value, computed; 2380 if (iteratee == null && obj != null) { 2381 obj = isArrayLike(obj) ? obj : _.values(obj); 2382 for (var i = 0, length = obj.length; i < length; i++) { 2383 value = obj[i]; 2384 if (value < result) { 2385 result = value; 2386 } 2387 } 2388 } else { 2389 iteratee = cb(iteratee, context); 2390 _.each(obj, function(value, index, list) { 2391 computed = iteratee(value, index, list); 2392 if (computed < lastComputed || computed === Infinity && result === Infinity) { 2393 result = value; 2394 lastComputed = computed; 2395 } 2396 }); 2397 } 2398 return result; 2399 }; 2400 2401 // Shuffle a collection, using the modern version of the 2402 // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). 2403 _.shuffle = function(obj) { 2404 var set = isArrayLike(obj) ? obj : _.values(obj); 2405 var length = set.length; 2406 var shuffled = Array(length); 2407 for (var index = 0, rand; index < length; index++) { 2408 rand = _.random(0, index); 2409 if (rand !== index) shuffled[index] = shuffled[rand]; 2410 shuffled[rand] = set[index]; 2411 } 2412 return shuffled; 2413 }; 2414 2415 // Sample **n** random values from a collection. 2416 // If **n** is not specified, returns a single random element. 2417 // The internal `guard` argument allows it to work with `map`. 2418 _.sample = function(obj, n, guard) { 2419 if (n == null || guard) { 2420 if (!isArrayLike(obj)) obj = _.values(obj); 2421 return obj[_.random(obj.length - 1)]; 2422 } 2423 return _.shuffle(obj).slice(0, Math.max(0, n)); 2424 }; 2425 2426 // Sort the object's values by a criterion produced by an iteratee. 2427 _.sortBy = function(obj, iteratee, context) { 2428 iteratee = cb(iteratee, context); 2429 return _.pluck(_.map(obj, function(value, index, list) { 2430 return { 2431 value: value, 2432 index: index, 2433 criteria: iteratee(value, index, list) 2434 }; 2435 }).sort(function(left, right) { 2436 var a = left.criteria; 2437 var b = right.criteria; 2438 if (a !== b) { 2439 if (a > b || a === void 0) return 1; 2440 if (a < b || b === void 0) return -1; 2441 } 2442 return left.index - right.index; 2443 }), 'value'); 2444 }; 2445 2446 // An internal function used for aggregate "group by" operations. 2447 var group = function(behavior) { 2448 return function(obj, iteratee, context) { 2449 var result = {}; 2450 iteratee = cb(iteratee, context); 2451 _.each(obj, function(value, index) { 2452 var key = iteratee(value, index, obj); 2453 behavior(result, value, key); 2454 }); 2455 return result; 2456 }; 2457 }; 2458 2459 // Groups the object's values by a criterion. Pass either a string attribute 2460 // to group by, or a function that returns the criterion. 2461 _.groupBy = group(function(result, value, key) { 2462 if (_.has(result, key)) result[key].push(value); else result[key] = [value]; 2463 }); 2464 2465 // Indexes the object's values by a criterion, similar to `groupBy`, but for 2466 // when you know that your index values will be unique. 2467 _.indexBy = group(function(result, value, key) { 2468 result[key] = value; 2469 }); 2470 2471 // Counts instances of an object that group by a certain criterion. Pass 2472 // either a string attribute to count by, or a function that returns the 2473 // criterion. 2474 _.countBy = group(function(result, value, key) { 2475 if (_.has(result, key)) result[key]++; else result[key] = 1; 2476 }); 2477 2478 // Safely create a real, live array from anything iterable. 2479 _.toArray = function(obj) { 2480 if (!obj) return []; 2481 if (_.isArray(obj)) return slice.call(obj); 2482 if (isArrayLike(obj)) return _.map(obj, _.identity); 2483 return _.values(obj); 2484 }; 2485 2486 // Return the number of elements in an object. 2487 _.size = function(obj) { 2488 if (obj == null) return 0; 2489 return isArrayLike(obj) ? obj.length : _.keys(obj).length; 2490 }; 2491 2492 // Split a collection into two arrays: one whose elements all satisfy the given 2493 // predicate, and one whose elements all do not satisfy the predicate. 2494 _.partition = function(obj, predicate, context) { 2495 predicate = cb(predicate, context); 2496 var pass = [], fail = []; 2497 _.each(obj, function(value, key, obj) { 2498 (predicate(value, key, obj) ? pass : fail).push(value); 2499 }); 2500 return [pass, fail]; 2501 }; 2502 2503 // Array Functions 2504 // --------------- 2505 2506 // Get the first element of an array. Passing **n** will return the first N 2507 // values in the array. Aliased as `head` and `take`. The **guard** check 2508 // allows it to work with `_.map`. 2509 _.first = _.head = _.take = function(array, n, guard) { 2510 if (array == null) return void 0; 2511 if (n == null || guard) return array[0]; 2512 return _.initial(array, array.length - n); 2513 }; 2514 2515 // Returns everything but the last entry of the array. Especially useful on 2516 // the arguments object. Passing **n** will return all the values in 2517 // the array, excluding the last N. 2518 _.initial = function(array, n, guard) { 2519 return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); 2520 }; 2521 2522 // Get the last element of an array. Passing **n** will return the last N 2523 // values in the array. 2524 _.last = function(array, n, guard) { 2525 if (array == null) return void 0; 2526 if (n == null || guard) return array[array.length - 1]; 2527 return _.rest(array, Math.max(0, array.length - n)); 2528 }; 2529 2530 // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. 2531 // Especially useful on the arguments object. Passing an **n** will return 2532 // the rest N values in the array. 2533 _.rest = _.tail = _.drop = function(array, n, guard) { 2534 return slice.call(array, n == null || guard ? 1 : n); 2535 }; 2536 2537 // Trim out all falsy values from an array. 2538 _.compact = function(array) { 2539 return _.filter(array, _.identity); 2540 }; 2541 2542 // Internal implementation of a recursive `flatten` function. 2543 var flatten = function(input, shallow, strict, startIndex) { 2544 var output = [], idx = 0; 2545 for (var i = startIndex || 0, length = getLength(input); i < length; i++) { 2546 var value = input[i]; 2547 if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { 2548 //flatten current level of array or arguments object 2549 if (!shallow) value = flatten(value, shallow, strict); 2550 var j = 0, len = value.length; 2551 output.length += len; 2552 while (j < len) { 2553 output[idx++] = value[j++]; 2554 } 2555 } else if (!strict) { 2556 output[idx++] = value; 2557 } 2558 } 2559 return output; 2560 }; 2561 2562 // Flatten out an array, either recursively (by default), or just one level. 2563 _.flatten = function(array, shallow) { 2564 return flatten(array, shallow, false); 2565 }; 2566 2567 // Return a version of the array that does not contain the specified value(s). 2568 _.without = function(array) { 2569 return _.difference(array, slice.call(arguments, 1)); 2570 }; 2571 2572 // Produce a duplicate-free version of the array. If the array has already 2573 // been sorted, you have the option of using a faster algorithm. 2574 // Aliased as `unique`. 2575 _.uniq = _.unique = function(array, isSorted, iteratee, context) { 2576 if (!_.isBoolean(isSorted)) { 2577 context = iteratee; 2578 iteratee = isSorted; 2579 isSorted = false; 2580 } 2581 if (iteratee != null) iteratee = cb(iteratee, context); 2582 var result = []; 2583 var seen = []; 2584 for (var i = 0, length = getLength(array); i < length; i++) { 2585 var value = array[i], 2586 computed = iteratee ? iteratee(value, i, array) : value; 2587 if (isSorted) { 2588 if (!i || seen !== computed) result.push(value); 2589 seen = computed; 2590 } else if (iteratee) { 2591 if (!_.contains(seen, computed)) { 2592 seen.push(computed); 2593 result.push(value); 2594 } 2595 } else if (!_.contains(result, value)) { 2596 result.push(value); 2597 } 2598 } 2599 return result; 2600 }; 2601 2602 // Produce an array that contains the union: each distinct element from all of 2603 // the passed-in arrays. 2604 _.union = function() { 2605 return _.uniq(flatten(arguments, true, true)); 2606 }; 2607 2608 // Produce an array that contains every item shared between all the 2609 // passed-in arrays. 2610 _.intersection = function(array) { 2611 var result = []; 2612 var argsLength = arguments.length; 2613 for (var i = 0, length = getLength(array); i < length; i++) { 2614 var item = array[i]; 2615 if (_.contains(result, item)) continue; 2616 for (var j = 1; j < argsLength; j++) { 2617 if (!_.contains(arguments[j], item)) break; 2618 } 2619 if (j === argsLength) result.push(item); 2620 } 2621 return result; 2622 }; 2623 2624 // Take the difference between one array and a number of other arrays. 2625 // Only the elements present in just the first array will remain. 2626 _.difference = function(array) { 2627 var rest = flatten(arguments, true, true, 1); 2628 return _.filter(array, function(value){ 2629 return !_.contains(rest, value); 2630 }); 2631 }; 2632 2633 // Zip together multiple lists into a single array -- elements that share 2634 // an index go together. 2635 _.zip = function() { 2636 return _.unzip(arguments); 2637 }; 2638 2639 // Complement of _.zip. Unzip accepts an array of arrays and groups 2640 // each array's elements on shared indices 2641 _.unzip = function(array) { 2642 var length = array && _.max(array, getLength).length || 0; 2643 var result = Array(length); 2644 2645 for (var index = 0; index < length; index++) { 2646 result[index] = _.pluck(array, index); 2647 } 2648 return result; 2649 }; 2650 2651 // Converts lists into objects. Pass either a single array of `[key, value]` 2652 // pairs, or two parallel arrays of the same length -- one of keys, and one of 2653 // the corresponding values. 2654 _.object = function(list, values) { 2655 var result = {}; 2656 for (var i = 0, length = getLength(list); i < length; i++) { 2657 if (values) { 2658 result[list[i]] = values[i]; 2659 } else { 2660 result[list[i][0]] = list[i][1]; 2661 } 2662 } 2663 return result; 2664 }; 2665 2666 // Generator function to create the findIndex and findLastIndex functions 2667 function createPredicateIndexFinder(dir) { 2668 return function(array, predicate, context) { 2669 predicate = cb(predicate, context); 2670 var length = getLength(array); 2671 var index = dir > 0 ? 0 : length - 1; 2672 for (; index >= 0 && index < length; index += dir) { 2673 if (predicate(array[index], index, array)) return index; 2674 } 2675 return -1; 2676 }; 2677 } 2678 2679 // Returns the first index on an array-like that passes a predicate test 2680 _.findIndex = createPredicateIndexFinder(1); 2681 _.findLastIndex = createPredicateIndexFinder(-1); 2682 2683 // Use a comparator function to figure out the smallest index at which 2684 // an object should be inserted so as to maintain order. Uses binary search. 2685 _.sortedIndex = function(array, obj, iteratee, context) { 2686 iteratee = cb(iteratee, context, 1); 2687 var value = iteratee(obj); 2688 var low = 0, high = getLength(array); 2689 while (low < high) { 2690 var mid = Math.floor((low + high) / 2); 2691 if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; 2692 } 2693 return low; 2694 }; 2695 2696 // Generator function to create the indexOf and lastIndexOf functions 2697 function createIndexFinder(dir, predicateFind, sortedIndex) { 2698 return function(array, item, idx) { 2699 var i = 0, length = getLength(array); 2700 if (typeof idx == 'number') { 2701 if (dir > 0) { 2702 i = idx >= 0 ? idx : Math.max(idx + length, i); 2703 } else { 2704 length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; 2705 } 2706 } else if (sortedIndex && idx && length) { 2707 idx = sortedIndex(array, item); 2708 return array[idx] === item ? idx : -1; 2709 } 2710 if (item !== item) { 2711 idx = predicateFind(slice.call(array, i, length), _.isNaN); 2712 return idx >= 0 ? idx + i : -1; 2713 } 2714 for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { 2715 if (array[idx] === item) return idx; 2716 } 2717 return -1; 2718 }; 2719 } 2720 2721 // Return the position of the first occurrence of an item in an array, 2722 // or -1 if the item is not included in the array. 2723 // If the array is large and already in sort order, pass `true` 2724 // for **isSorted** to use binary search. 2725 _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); 2726 _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); 2727 2728 // Generate an integer Array containing an arithmetic progression. A port of 2729 // the native Python `range()` function. See 2730 // [the Python documentation](http://docs.python.org/library/functions.html#range). 2731 _.range = function(start, stop, step) { 2732 if (stop == null) { 2733 stop = start || 0; 2734 start = 0; 2735 } 2736 step = step || 1; 2737 2738 var length = Math.max(Math.ceil((stop - start) / step), 0); 2739 var range = Array(length); 2740 2741 for (var idx = 0; idx < length; idx++, start += step) { 2742 range[idx] = start; 2743 } 2744 2745 return range; 2746 }; 2747 2748 // Function (ahem) Functions 2749 // ------------------ 2750 2751 // Determines whether to execute a function as a constructor 2752 // or a normal function with the provided arguments 2753 var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { 2754 if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); 2755 var self = baseCreate(sourceFunc.prototype); 2756 var result = sourceFunc.apply(self, args); 2757 if (_.isObject(result)) return result; 2758 return self; 2759 }; 2760 2761 // Create a function bound to a given object (assigning `this`, and arguments, 2762 // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if 2763 // available. 2764 _.bind = function(func, context) { 2765 if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); 2766 if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); 2767 var args = slice.call(arguments, 2); 2768 var bound = function() { 2769 return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); 2770 }; 2771 return bound; 2772 }; 2773 2774 // Partially apply a function by creating a version that has had some of its 2775 // arguments pre-filled, without changing its dynamic `this` context. _ acts 2776 // as a placeholder, allowing any combination of arguments to be pre-filled. 2777 _.partial = function(func) { 2778 var boundArgs = slice.call(arguments, 1); 2779 var bound = function() { 2780 var position = 0, length = boundArgs.length; 2781 var args = Array(length); 2782 for (var i = 0; i < length; i++) { 2783 args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; 2784 } 2785 while (position < arguments.length) args.push(arguments[position++]); 2786 return executeBound(func, bound, this, this, args); 2787 }; 2788 return bound; 2789 }; 2790 2791 // Bind a number of an object's methods to that object. Remaining arguments 2792 // are the method names to be bound. Useful for ensuring that all callbacks 2793 // defined on an object belong to it. 2794 _.bindAll = function(obj) { 2795 var i, length = arguments.length, key; 2796 if (length <= 1) throw new Error('bindAll must be passed function names'); 2797 for (i = 1; i < length; i++) { 2798 key = arguments[i]; 2799 obj[key] = _.bind(obj[key], obj); 2800 } 2801 return obj; 2802 }; 2803 2804 // Memoize an expensive function by storing its results. 2805 _.memoize = function(func, hasher) { 2806 var memoize = function(key) { 2807 var cache = memoize.cache; 2808 var address = '' + (hasher ? hasher.apply(this, arguments) : key); 2809 if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); 2810 return cache[address]; 2811 }; 2812 memoize.cache = {}; 2813 return memoize; 2814 }; 2815 2816 // Delays a function for the given number of milliseconds, and then calls 2817 // it with the arguments supplied. 2818 _.delay = function(func, wait) { 2819 var args = slice.call(arguments, 2); 2820 return setTimeout(function(){ 2821 return func.apply(null, args); 2822 }, wait); 2823 }; 2824 2825 // Defers a function, scheduling it to run after the current call stack has 2826 // cleared. 2827 _.defer = _.partial(_.delay, _, 1); 2828 2829 // Returns a function, that, when invoked, will only be triggered at most once 2830 // during a given window of time. Normally, the throttled function will run 2831 // as much as it can, without ever going more than once per `wait` duration; 2832 // but if you'd like to disable the execution on the leading edge, pass 2833 // `{leading: false}`. To disable execution on the trailing edge, ditto. 2834 _.throttle = function(func, wait, options) { 2835 var context, args, result; 2836 var timeout = null; 2837 var previous = 0; 2838 if (!options) options = {}; 2839 var later = function() { 2840 previous = options.leading === false ? 0 : _.now(); 2841 timeout = null; 2842 result = func.apply(context, args); 2843 if (!timeout) context = args = null; 2844 }; 2845 return function() { 2846 var now = _.now(); 2847 if (!previous && options.leading === false) previous = now; 2848 var remaining = wait - (now - previous); 2849 context = this; 2850 args = arguments; 2851 if (remaining <= 0 || remaining > wait) { 2852 if (timeout) { 2853 clearTimeout(timeout); 2854 timeout = null; 2855 } 2856 previous = now; 2857 result = func.apply(context, args); 2858 if (!timeout) context = args = null; 2859 } else if (!timeout && options.trailing !== false) { 2860 timeout = setTimeout(later, remaining); 2861 } 2862 return result; 2863 }; 2864 }; 2865 2866 // Returns a function, that, as long as it continues to be invoked, will not 2867 // be triggered. The function will be called after it stops being called for 2868 // N milliseconds. If `immediate` is passed, trigger the function on the 2869 // leading edge, instead of the trailing. 2870 _.debounce = function(func, wait, immediate) { 2871 var timeout, args, context, timestamp, result; 2872 2873 var later = function() { 2874 var last = _.now() - timestamp; 2875 2876 if (last < wait && last >= 0) { 2877 timeout = setTimeout(later, wait - last); 2878 } else { 2879 timeout = null; 2880 if (!immediate) { 2881 result = func.apply(context, args); 2882 if (!timeout) context = args = null; 2883 } 2884 } 2885 }; 2886 2887 return function() { 2888 context = this; 2889 args = arguments; 2890 timestamp = _.now(); 2891 var callNow = immediate && !timeout; 2892 if (!timeout) timeout = setTimeout(later, wait); 2893 if (callNow) { 2894 result = func.apply(context, args); 2895 context = args = null; 2896 } 2897 2898 return result; 2899 }; 2900 }; 2901 2902 // Returns the first function passed as an argument to the second, 2903 // allowing you to adjust arguments, run code before and after, and 2904 // conditionally execute the original function. 2905 _.wrap = function(func, wrapper) { 2906 return _.partial(wrapper, func); 2907 }; 2908 2909 // Returns a negated version of the passed-in predicate. 2910 _.negate = function(predicate) { 2911 return function() { 2912 return !predicate.apply(this, arguments); 2913 }; 2914 }; 2915 2916 // Returns a function that is the composition of a list of functions, each 2917 // consuming the return value of the function that follows. 2918 _.compose = function() { 2919 var args = arguments; 2920 var start = args.length - 1; 2921 return function() { 2922 var i = start; 2923 var result = args[start].apply(this, arguments); 2924 while (i--) result = args[i].call(this, result); 2925 return result; 2926 }; 2927 }; 2928 2929 // Returns a function that will only be executed on and after the Nth call. 2930 _.after = function(times, func) { 2931 return function() { 2932 if (--times < 1) { 2933 return func.apply(this, arguments); 2934 } 2935 }; 2936 }; 2937 2938 // Returns a function that will only be executed up to (but not including) the Nth call. 2939 _.before = function(times, func) { 2940 var memo; 2941 return function() { 2942 if (--times > 0) { 2943 memo = func.apply(this, arguments); 2944 } 2945 if (times <= 1) func = null; 2946 return memo; 2947 }; 2948 }; 2949 2950 // Returns a function that will be executed at most one time, no matter how 2951 // often you call it. Useful for lazy initialization. 2952 _.once = _.partial(_.before, 2); 2953 2954 // Object Functions 2955 // ---------------- 2956 2957 // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. 2958 var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); 2959 var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', 2960 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; 2961 2962 function collectNonEnumProps(obj, keys) { 2963 var nonEnumIdx = nonEnumerableProps.length; 2964 var constructor = obj.constructor; 2965 var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto; 2966 2967 // Constructor is a special case. 2968 var prop = 'constructor'; 2969 if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); 2970 2971 while (nonEnumIdx--) { 2972 prop = nonEnumerableProps[nonEnumIdx]; 2973 if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { 2974 keys.push(prop); 2975 } 2976 } 2977 } 2978 2979 // Retrieve the names of an object's own properties. 2980 // Delegates to **ECMAScript 5**'s native `Object.keys` 2981 _.keys = function(obj) { 2982 if (!_.isObject(obj)) return []; 2983 if (nativeKeys) return nativeKeys(obj); 2984 var keys = []; 2985 for (var key in obj) if (_.has(obj, key)) keys.push(key); 2986 // Ahem, IE < 9. 2987 if (hasEnumBug) collectNonEnumProps(obj, keys); 2988 return keys; 2989 }; 2990 2991 // Retrieve all the property names of an object. 2992 _.allKeys = function(obj) { 2993 if (!_.isObject(obj)) return []; 2994 var keys = []; 2995 for (var key in obj) keys.push(key); 2996 // Ahem, IE < 9. 2997 if (hasEnumBug) collectNonEnumProps(obj, keys); 2998 return keys; 2999 }; 3000 3001 // Retrieve the values of an object's properties. 3002 _.values = function(obj) { 3003 var keys = _.keys(obj); 3004 var length = keys.length; 3005 var values = Array(length); 3006 for (var i = 0; i < length; i++) { 3007 values[i] = obj[keys[i]]; 3008 } 3009 return values; 3010 }; 3011 3012 // Returns the results of applying the iteratee to each element of the object 3013 // In contrast to _.map it returns an object 3014 _.mapObject = function(obj, iteratee, context) { 3015 iteratee = cb(iteratee, context); 3016 var keys = _.keys(obj), 3017 length = keys.length, 3018 results = {}, 3019 currentKey; 3020 for (var index = 0; index < length; index++) { 3021 currentKey = keys[index]; 3022 results[currentKey] = iteratee(obj[currentKey], currentKey, obj); 3023 } 3024 return results; 3025 }; 3026 3027 // Convert an object into a list of `[key, value]` pairs. 3028 _.pairs = function(obj) { 3029 var keys = _.keys(obj); 3030 var length = keys.length; 3031 var pairs = Array(length); 3032 for (var i = 0; i < length; i++) { 3033 pairs[i] = [keys[i], obj[keys[i]]]; 3034 } 3035 return pairs; 3036 }; 3037 3038 // Invert the keys and values of an object. The values must be serializable. 3039 _.invert = function(obj) { 3040 var result = {}; 3041 var keys = _.keys(obj); 3042 for (var i = 0, length = keys.length; i < length; i++) { 3043 result[obj[keys[i]]] = keys[i]; 3044 } 3045 return result; 3046 }; 3047 3048 // Return a sorted list of the function names available on the object. 3049 // Aliased as `methods` 3050 _.functions = _.methods = function(obj) { 3051 var names = []; 3052 for (var key in obj) { 3053 if (_.isFunction(obj[key])) names.push(key); 3054 } 3055 return names.sort(); 3056 }; 3057 3058 // Extend a given object with all the properties in passed-in object(s). 3059 _.extend = createAssigner(_.allKeys); 3060 3061 // Assigns a given object with all the own properties in the passed-in object(s) 3062 // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) 3063 _.extendOwn = _.assign = createAssigner(_.keys); 3064 3065 // Returns the first key on an object that passes a predicate test 3066 _.findKey = function(obj, predicate, context) { 3067 predicate = cb(predicate, context); 3068 var keys = _.keys(obj), key; 3069 for (var i = 0, length = keys.length; i < length; i++) { 3070 key = keys[i]; 3071 if (predicate(obj[key], key, obj)) return key; 3072 } 3073 }; 3074 3075 // Return a copy of the object only containing the whitelisted properties. 3076 _.pick = function(object, oiteratee, context) { 3077 var result = {}, obj = object, iteratee, keys; 3078 if (obj == null) return result; 3079 if (_.isFunction(oiteratee)) { 3080 keys = _.allKeys(obj); 3081 iteratee = optimizeCb(oiteratee, context); 3082 } else { 3083 keys = flatten(arguments, false, false, 1); 3084 iteratee = function(value, key, obj) { return key in obj; }; 3085 obj = Object(obj); 3086 } 3087 for (var i = 0, length = keys.length; i < length; i++) { 3088 var key = keys[i]; 3089 var value = obj[key]; 3090 if (iteratee(value, key, obj)) result[key] = value; 3091 } 3092 return result; 3093 }; 3094 3095 // Return a copy of the object without the blacklisted properties. 3096 _.omit = function(obj, iteratee, context) { 3097 if (_.isFunction(iteratee)) { 3098 iteratee = _.negate(iteratee); 3099 } else { 3100 var keys = _.map(flatten(arguments, false, false, 1), String); 3101 iteratee = function(value, key) { 3102 return !_.contains(keys, key); 3103 }; 3104 } 3105 return _.pick(obj, iteratee, context); 3106 }; 3107 3108 // Fill in a given object with default properties. 3109 _.defaults = createAssigner(_.allKeys, true); 3110 3111 // Creates an object that inherits from the given prototype object. 3112 // If additional properties are provided then they will be added to the 3113 // created object. 3114 _.create = function(prototype, props) { 3115 var result = baseCreate(prototype); 3116 if (props) _.extendOwn(result, props); 3117 return result; 3118 }; 3119 3120 // Create a (shallow-cloned) duplicate of an object. 3121 _.clone = function(obj) { 3122 if (!_.isObject(obj)) return obj; 3123 return _.isArray(obj) ? obj.slice() : _.extend({}, obj); 3124 }; 3125 3126 // Invokes interceptor with the obj, and then returns obj. 3127 // The primary purpose of this method is to "tap into" a method chain, in 3128 // order to perform operations on intermediate results within the chain. 3129 _.tap = function(obj, interceptor) { 3130 interceptor(obj); 3131 return obj; 3132 }; 3133 3134 // Returns whether an object has a given set of `key:value` pairs. 3135 _.isMatch = function(object, attrs) { 3136 var keys = _.keys(attrs), length = keys.length; 3137 if (object == null) return !length; 3138 var obj = Object(object); 3139 for (var i = 0; i < length; i++) { 3140 var key = keys[i]; 3141 if (attrs[key] !== obj[key] || !(key in obj)) return false; 3142 } 3143 return true; 3144 }; 3145 3146 3147 // Internal recursive comparison function for `isEqual`. 3148 var eq = function(a, b, aStack, bStack) { 3149 // Identical objects are equal. `0 === -0`, but they aren't identical. 3150 // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). 3151 if (a === b) return a !== 0 || 1 / a === 1 / b; 3152 // A strict comparison is necessary because `null == undefined`. 3153 if (a == null || b == null) return a === b; 3154 // Unwrap any wrapped objects. 3155 if (a instanceof _) a = a._wrapped; 3156 if (b instanceof _) b = b._wrapped; 3157 // Compare `[[Class]]` names. 3158 var className = toString.call(a); 3159 if (className !== toString.call(b)) return false; 3160 switch (className) { 3161 // Strings, numbers, regular expressions, dates, and booleans are compared by value. 3162 case '[object RegExp]': 3163 // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') 3164 case '[object String]': 3165 // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is 3166 // equivalent to `new String("5")`. 3167 return '' + a === '' + b; 3168 case '[object Number]': 3169 // `NaN`s are equivalent, but non-reflexive. 3170 // Object(NaN) is equivalent to NaN 3171 if (+a !== +a) return +b !== +b; 3172 // An `egal` comparison is performed for other numeric values. 3173 return +a === 0 ? 1 / +a === 1 / b : +a === +b; 3174 case '[object Date]': 3175 case '[object Boolean]': 3176 // Coerce dates and booleans to numeric primitive values. Dates are compared by their 3177 // millisecond representations. Note that invalid dates with millisecond representations 3178 // of `NaN` are not equivalent. 3179 return +a === +b; 3180 } 3181 3182 var areArrays = className === '[object Array]'; 3183 if (!areArrays) { 3184 if (typeof a != 'object' || typeof b != 'object') return false; 3185 3186 // Objects with different constructors are not equivalent, but `Object`s or `Array`s 3187 // from different frames are. 3188 var aCtor = a.constructor, bCtor = b.constructor; 3189 if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && 3190 _.isFunction(bCtor) && bCtor instanceof bCtor) 3191 && ('constructor' in a && 'constructor' in b)) { 3192 return false; 3193 } 3194 } 3195 // Assume equality for cyclic structures. The algorithm for detecting cyclic 3196 // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. 3197 3198 // Initializing stack of traversed objects. 3199 // It's done here since we only need them for objects and arrays comparison. 3200 aStack = aStack || []; 3201 bStack = bStack || []; 3202 var length = aStack.length; 3203 while (length--) { 3204 // Linear search. Performance is inversely proportional to the number of 3205 // unique nested structures. 3206 if (aStack[length] === a) return bStack[length] === b; 3207 } 3208 3209 // Add the first object to the stack of traversed objects. 3210 aStack.push(a); 3211 bStack.push(b); 3212 3213 // Recursively compare objects and arrays. 3214 if (areArrays) { 3215 // Compare array lengths to determine if a deep comparison is necessary. 3216 length = a.length; 3217 if (length !== b.length) return false; 3218 // Deep compare the contents, ignoring non-numeric properties. 3219 while (length--) { 3220 if (!eq(a[length], b[length], aStack, bStack)) return false; 3221 } 3222 } else { 3223 // Deep compare objects. 3224 var keys = _.keys(a), key; 3225 length = keys.length; 3226 // Ensure that both objects contain the same number of properties before comparing deep equality. 3227 if (_.keys(b).length !== length) return false; 3228 while (length--) { 3229 // Deep compare each member 3230 key = keys[length]; 3231 if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; 3232 } 3233 } 3234 // Remove the first object from the stack of traversed objects. 3235 aStack.pop(); 3236 bStack.pop(); 3237 return true; 3238 }; 3239 3240 // Perform a deep comparison to check if two objects are equal. 3241 _.isEqual = function(a, b) { 3242 return eq(a, b); 3243 }; 3244 3245 // Is a given array, string, or object empty? 3246 // An "empty" object has no enumerable own-properties. 3247 _.isEmpty = function(obj) { 3248 if (obj == null) return true; 3249 if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; 3250 return _.keys(obj).length === 0; 3251 }; 3252 3253 // Is a given value a DOM element? 3254 _.isElement = function(obj) { 3255 return !!(obj && obj.nodeType === 1); 3256 }; 3257 3258 // Is a given value an array? 3259 // Delegates to ECMA5's native Array.isArray 3260 _.isArray = nativeIsArray || function(obj) { 3261 return toString.call(obj) === '[object Array]'; 3262 }; 3263 3264 // Is a given variable an object? 3265 _.isObject = function(obj) { 3266 var type = typeof obj; 3267 return type === 'function' || type === 'object' && !!obj; 3268 }; 3269 3270 // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. 3271 _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) { 3272 _['is' + name] = function(obj) { 3273 return toString.call(obj) === '[object ' + name + ']'; 3274 }; 3275 }); 3276 3277 // Define a fallback version of the method in browsers (ahem, IE < 9), where 3278 // there isn't any inspectable "Arguments" type. 3279 if (!_.isArguments(arguments)) { 3280 _.isArguments = function(obj) { 3281 return _.has(obj, 'callee'); 3282 }; 3283 } 3284 3285 // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, 3286 // IE 11 (#1621), and in Safari 8 (#1929). 3287 if (typeof /./ != 'function' && typeof Int8Array != 'object') { 3288 _.isFunction = function(obj) { 3289 return typeof obj == 'function' || false; 3290 }; 3291 } 3292 3293 // Is a given object a finite number? 3294 _.isFinite = function(obj) { 3295 return isFinite(obj) && !isNaN(parseFloat(obj)); 3296 }; 3297 3298 // Is the given value `NaN`? (NaN is the only number which does not equal itself). 3299 _.isNaN = function(obj) { 3300 return _.isNumber(obj) && obj !== +obj; 3301 }; 3302 3303 // Is a given value a boolean? 3304 _.isBoolean = function(obj) { 3305 return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; 3306 }; 3307 3308 // Is a given value equal to null? 3309 _.isNull = function(obj) { 3310 return obj === null; 3311 }; 3312 3313 // Is a given variable undefined? 3314 _.isUndefined = function(obj) { 3315 return obj === void 0; 3316 }; 3317 3318 // Shortcut function for checking if an object has a given property directly 3319 // on itself (in other words, not on a prototype). 3320 _.has = function(obj, key) { 3321 return obj != null && hasOwnProperty.call(obj, key); 3322 }; 3323 3324 // Utility Functions 3325 // ----------------- 3326 3327 // Run Underscore.js in *noConflict* mode, returning the `_` variable to its 3328 // previous owner. Returns a reference to the Underscore object. 3329 _.noConflict = function() { 3330 root._ = previousUnderscore; 3331 return this; 3332 }; 3333 3334 // Keep the identity function around for default iteratees. 3335 _.identity = function(value) { 3336 return value; 3337 }; 3338 3339 // Predicate-generating functions. Often useful outside of Underscore. 3340 _.constant = function(value) { 3341 return function() { 3342 return value; 3343 }; 3344 }; 3345 3346 _.noop = function(){}; 3347 3348 _.property = property; 3349 3350 // Generates a function for a given object that returns a given property. 3351 _.propertyOf = function(obj) { 3352 return obj == null ? function(){} : function(key) { 3353 return obj[key]; 3354 }; 3355 }; 3356 3357 // Returns a predicate for checking whether an object has a given set of 3358 // `key:value` pairs. 3359 _.matcher = _.matches = function(attrs) { 3360 attrs = _.extendOwn({}, attrs); 3361 return function(obj) { 3362 return _.isMatch(obj, attrs); 3363 }; 3364 }; 3365 3366 // Run a function **n** times. 3367 _.times = function(n, iteratee, context) { 3368 var accum = Array(Math.max(0, n)); 3369 iteratee = optimizeCb(iteratee, context, 1); 3370 for (var i = 0; i < n; i++) accum[i] = iteratee(i); 3371 return accum; 3372 }; 3373 3374 // Return a random integer between min and max (inclusive). 3375 _.random = function(min, max) { 3376 if (max == null) { 3377 max = min; 3378 min = 0; 3379 } 3380 return min + Math.floor(Math.random() * (max - min + 1)); 3381 }; 3382 3383 // A (possibly faster) way to get the current timestamp as an integer. 3384 _.now = Date.now || function() { 3385 return new Date().getTime(); 3386 }; 3387 3388 // List of HTML entities for escaping. 3389 var escapeMap = { 3390 '&': '&', 3391 '<': '<', 3392 '>': '>', 3393 '"': '"', 3394 "'": ''', 3395 '`': '`' 3396 }; 3397 var unescapeMap = _.invert(escapeMap); 3398 3399 // Functions for escaping and unescaping strings to/from HTML interpolation. 3400 var createEscaper = function(map) { 3401 var escaper = function(match) { 3402 return map[match]; 3403 }; 3404 // Regexes for identifying a key that needs to be escaped 3405 var source = '(?:' + _.keys(map).join('|') + ')'; 3406 var testRegexp = RegExp(source); 3407 var replaceRegexp = RegExp(source, 'g'); 3408 return function(string) { 3409 string = string == null ? '' : '' + string; 3410 return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; 3411 }; 3412 }; 3413 _.escape = createEscaper(escapeMap); 3414 _.unescape = createEscaper(unescapeMap); 3415 3416 // If the value of the named `property` is a function then invoke it with the 3417 // `object` as context; otherwise, return it. 3418 _.result = function(object, property, fallback) { 3419 var value = object == null ? void 0 : object[property]; 3420 if (value === void 0) { 3421 value = fallback; 3422 } 3423 return _.isFunction(value) ? value.call(object) : value; 3424 }; 3425 3426 // Generate a unique integer id (unique within the entire client session). 3427 // Useful for temporary DOM ids. 3428 var idCounter = 0; 3429 _.uniqueId = function(prefix) { 3430 var id = ++idCounter + ''; 3431 return prefix ? prefix + id : id; 3432 }; 3433 3434 // By default, Underscore uses ERB-style template delimiters, change the 3435 // following template settings to use alternative delimiters. 3436 _.templateSettings = { 3437 evaluate : /<%([\s\S]+?)%>/g, 3438 interpolate : /<%=([\s\S]+?)%>/g, 3439 escape : /<%-([\s\S]+?)%>/g 3440 }; 3441 3442 // When customizing `templateSettings`, if you don't want to define an 3443 // interpolation, evaluation or escaping regex, we need one that is 3444 // guaranteed not to match. 3445 var noMatch = /(.)^/; 3446 3447 // Certain characters need to be escaped so that they can be put into a 3448 // string literal. 3449 var escapes = { 3450 "'": "'", 3451 '\\': '\\', 3452 '\r': 'r', 3453 '\n': 'n', 3454 '\u2028': 'u2028', 3455 '\u2029': 'u2029' 3456 }; 3457 3458 var escaper = /\\|'|\r|\n|\u2028|\u2029/g; 3459 3460 var escapeChar = function(match) { 3461 return '\\' + escapes[match]; 3462 }; 3463 3464 // JavaScript micro-templating, similar to John Resig's implementation. 3465 // Underscore templating handles arbitrary delimiters, preserves whitespace, 3466 // and correctly escapes quotes within interpolated code. 3467 // NB: `oldSettings` only exists for backwards compatibility. 3468 _.template = function(text, settings, oldSettings) { 3469 if (!settings && oldSettings) settings = oldSettings; 3470 settings = _.defaults({}, settings, _.templateSettings); 3471 3472 // Combine delimiters into one regular expression via alternation. 3473 var matcher = RegExp([ 3474 (settings.escape || noMatch).source, 3475 (settings.interpolate || noMatch).source, 3476 (settings.evaluate || noMatch).source 3477 ].join('|') + '|$', 'g'); 3478 3479 // Compile the template source, escaping string literals appropriately. 3480 var index = 0; 3481 var source = "__p+='"; 3482 text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { 3483 source += text.slice(index, offset).replace(escaper, escapeChar); 3484 index = offset + match.length; 3485 3486 if (escape) { 3487 source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; 3488 } else if (interpolate) { 3489 source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; 3490 } else if (evaluate) { 3491 source += "';\n" + evaluate + "\n__p+='"; 3492 } 3493 3494 // Adobe VMs need the match returned to produce the correct offest. 3495 return match; 3496 }); 3497 source += "';\n"; 3498 3499 // If a variable is not specified, place data values in local scope. 3500 if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; 3501 3502 source = "var __t,__p='',__j=Array.prototype.join," + 3503 "print=function(){__p+=__j.call(arguments,'');};\n" + 3504 source + 'return __p;\n'; 3505 3506 try { 3507 var render = new Function(settings.variable || 'obj', '_', source); 3508 } catch (e) { 3509 e.source = source; 3510 throw e; 3511 } 3512 3513 var template = function(data) { 3514 return render.call(this, data, _); 3515 }; 3516 3517 // Provide the compiled source as a convenience for precompilation. 3518 var argument = settings.variable || 'obj'; 3519 template.source = 'function(' + argument + '){\n' + source + '}'; 3520 3521 return template; 3522 }; 3523 3524 // Add a "chain" function. Start chaining a wrapped Underscore object. 3525 _.chain = function(obj) { 3526 var instance = _(obj); 3527 instance._chain = true; 3528 return instance; 3529 }; 3530 3531 // OOP 3532 // --------------- 3533 // If Underscore is called as a function, it returns a wrapped object that 3534 // can be used OO-style. This wrapper holds altered versions of all the 3535 // underscore functions. Wrapped objects may be chained. 3536 3537 // Helper function to continue chaining intermediate results. 3538 var result = function(instance, obj) { 3539 return instance._chain ? _(obj).chain() : obj; 3540 }; 3541 3542 // Add your own custom functions to the Underscore object. 3543 _.mixin = function(obj) { 3544 _.each(_.functions(obj), function(name) { 3545 var func = _[name] = obj[name]; 3546 _.prototype[name] = function() { 3547 var args = [this._wrapped]; 3548 push.apply(args, arguments); 3549 return result(this, func.apply(_, args)); 3550 }; 3551 }); 3552 }; 3553 3554 // Add all of the Underscore functions to the wrapper object. 3555 _.mixin(_); 3556 3557 // Add all mutator Array functions to the wrapper. 3558 _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { 3559 var method = ArrayProto[name]; 3560 _.prototype[name] = function() { 3561 var obj = this._wrapped; 3562 method.apply(obj, arguments); 3563 if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; 3564 return result(this, obj); 3565 }; 3566 }); 3567 3568 // Add all accessor Array functions to the wrapper. 3569 _.each(['concat', 'join', 'slice'], function(name) { 3570 var method = ArrayProto[name]; 3571 _.prototype[name] = function() { 3572 return result(this, method.apply(this._wrapped, arguments)); 3573 }; 3574 }); 3575 3576 // Extracts the result from a wrapped and chained object. 3577 _.prototype.value = function() { 3578 return this._wrapped; 3579 }; 3580 3581 // Provide unwrapping proxy for some methods used in engine operations 3582 // such as arithmetic and JSON stringification. 3583 _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; 3584 3585 _.prototype.toString = function() { 3586 return '' + this._wrapped; 3587 }; 3588 3589 // AMD registration happens at the end for compatibility with AMD loaders 3590 // that may not enforce next-turn semantics on modules. Even though general 3591 // practice for AMD registration is to be anonymous, underscore registers 3592 // as a named module because, like jQuery, it is a base library that is 3593 // popular enough to be bundled in a third party lib, but not be part of 3594 // an AMD load request. Those cases could generate an error when an 3595 // anonymous define() is called outside of a loader request. 3596 if (true) { 3597 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { 3598 return _; 3599 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 3600 } 3601 }.call(this)); 3602 3603 3604 /***/ }, 3605 /* 5 */ 3606 /***/ function(module, exports, __webpack_require__) { 3607 3608 module.exports = __webpack_require__(55); 3609 3610 /***/ }, 3611 /* 6 */ 3612 /***/ function(module, exports, __webpack_require__) { 3613 3614 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) { 3615 if ( true ) { 3616 3617 // AMD. Register as an anonymous module. 3618 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(1) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 3619 } else { 3620 3621 // Browser globals 3622 factory( jQuery ); 3623 } 3624 } ( function( $ ) { 3625 3626 $.ui = $.ui || {}; 3627 3628 return $.ui.version = "1.12.1"; 3629 3630 } ) ); 3631 3632 3633 /***/ }, 3634 /* 7 */ 3635 /***/ function(module, exports) { 3636 3637 'use strict'; 3638 3639 3640 function isNothing(subject) { 3641 return (typeof subject === 'undefined') || (subject === null); 3642 } 3643 3644 3645 function isObject(subject) { 3646 return (typeof subject === 'object') && (subject !== null); 3647 } 3648 3649 3650 function toArray(sequence) { 3651 if (Array.isArray(sequence)) return sequence; 3652 else if (isNothing(sequence)) return []; 3653 3654 return [ sequence ]; 3655 } 3656 3657 3658 function extend(target, source) { 3659 var index, length, key, sourceKeys; 3660 3661 if (source) { 3662 sourceKeys = Object.keys(source); 3663 3664 for (index = 0, length = sourceKeys.length; index < length; index += 1) { 3665 key = sourceKeys[index]; 3666 target[key] = source[key]; 3667 } 3668 } 3669 3670 return target; 3671 } 3672 3673 3674 function repeat(string, count) { 3675 var result = '', cycle; 3676 3677 for (cycle = 0; cycle < count; cycle += 1) { 3678 result += string; 3679 } 3680 3681 return result; 3682 } 3683 3684 3685 function isNegativeZero(number) { 3686 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); 3687 } 3688 3689 3690 module.exports.isNothing = isNothing; 3691 module.exports.isObject = isObject; 3692 module.exports.toArray = toArray; 3693 module.exports.repeat = repeat; 3694 module.exports.isNegativeZero = isNegativeZero; 3695 module.exports.extend = extend; 3696 3697 3698 /***/ }, 3699 /* 8 */ 3700 /***/ function(module, exports, __webpack_require__) { 3701 3702 'use strict'; 3703 3704 /*eslint-disable max-len*/ 3705 3706 var common = __webpack_require__(7); 3707 var YAMLException = __webpack_require__(11); 3708 var Type = __webpack_require__(3); 3709 3710 3711 function compileList(schema, name, result) { 3712 var exclude = []; 3713 3714 schema.include.forEach(function (includedSchema) { 3715 result = compileList(includedSchema, name, result); 3716 }); 3717 3718 schema[name].forEach(function (currentType) { 3719 result.forEach(function (previousType, previousIndex) { 3720 if (previousType.tag === currentType.tag) { 3721 exclude.push(previousIndex); 3722 } 3723 }); 3724 3725 result.push(currentType); 3726 }); 3727 3728 return result.filter(function (type, index) { 3729 return exclude.indexOf(index) === -1; 3730 }); 3731 } 3732 3733 3734 function compileMap(/* lists... */) { 3735 var result = {}, index, length; 3736 3737 function collectType(type) { 3738 result[type.tag] = type; 3739 } 3740 3741 for (index = 0, length = arguments.length; index < length; index += 1) { 3742 arguments[index].forEach(collectType); 3743 } 3744 3745 return result; 3746 } 3747 3748 3749 function Schema(definition) { 3750 this.include = definition.include || []; 3751 this.implicit = definition.implicit || []; 3752 this.explicit = definition.explicit || []; 3753 3754 this.implicit.forEach(function (type) { 3755 if (type.loadKind && type.loadKind !== 'scalar') { 3756 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); 3757 } 3758 }); 3759 3760 this.compiledImplicit = compileList(this, 'implicit', []); 3761 this.compiledExplicit = compileList(this, 'explicit', []); 3762 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit); 3763 } 3764 3765 3766 Schema.DEFAULT = null; 3767 3768 3769 Schema.create = function createSchema() { 3770 var schemas, types; 3771 3772 switch (arguments.length) { 3773 case 1: 3774 schemas = Schema.DEFAULT; 3775 types = arguments[0]; 3776 break; 3777 3778 case 2: 3779 schemas = arguments[0]; 3780 types = arguments[1]; 3781 break; 3782 3783 default: 3784 throw new YAMLException('Wrong number of arguments for Schema.create function'); 3785 } 3786 3787 schemas = common.toArray(schemas); 3788 types = common.toArray(types); 3789 3790 if (!schemas.every(function (schema) { return schema instanceof Schema; })) { 3791 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.'); 3792 } 3793 3794 if (!types.every(function (type) { return type instanceof Type; })) { 3795 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); 3796 } 3797 3798 return new Schema({ 3799 include: schemas, 3800 explicit: types 3801 }); 3802 }; 3803 3804 3805 module.exports = Schema; 3806 3807 3808 /***/ }, 3809 /* 9 */ 3810 /***/ function(module, exports, __webpack_require__) { 3811 3812 'use strict'; 3813 3814 Object.defineProperty(exports, "__esModule", { 3815 value: true 3816 }); 3817 3818 var _backbone = __webpack_require__(2); 3819 3820 var _error = __webpack_require__(112); 3821 3822 var _error2 = _interopRequireDefault(_error); 3823 3824 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3825 3826 /* global window */ 3827 class ErrorView extends _backbone.View { 3828 get tagName() { 3829 return 'div'; 3830 } 3831 3832 get events() { 3833 return { 3834 'click [data-gohan="reload"]': 'reload', 3835 'click [data-gohan="close"]': 'close' 3836 }; 3837 } 3838 3839 constructor() { 3840 super(); 3841 this.message = 'Unknown Error'; 3842 this.messageDetail = ''; 3843 } 3844 reload() { 3845 window.location.reload(); 3846 } 3847 render(...params) { 3848 const response = params.find(param => { 3849 return param.hasOwnProperty('status') && param.hasOwnProperty('readyState'); 3850 }); 3851 3852 if (response === undefined) { 3853 return; 3854 } 3855 3856 this.message = response.statusText; 3857 if (response.hasOwnProperty('responseJSON') && response.responseJSON) { 3858 if (response.responseJSON.hasOwnProperty('error')) { 3859 if (typeof response.responseJSON.error === 'object' && response.responseJSON.error.message) { 3860 this.messageDetail = response.responseJSON.error.message; 3861 } else { 3862 this.messageDetail = response.responseJSON.error; 3863 } 3864 } 3865 } 3866 3867 switch (response.status) { 3868 case 0: 3869 { 3870 this.message = 'Server Connection failed (<a href="#" data-gohan="reload" class="alert-link">Reload</a>)'; 3871 break; 3872 } 3873 case 400: 3874 { 3875 this.message = 'Bad Request'; 3876 break; 3877 } 3878 case 401: 3879 { 3880 this.message = 'Unauthorized Error'; 3881 break; 3882 } 3883 case 404: 3884 { 3885 this.message = 'Data Not Found'; 3886 break; 3887 } 3888 case 500: 3889 { 3890 this.message = 'Server Side Error'; 3891 break; 3892 } 3893 } 3894 3895 const html = (0, _error2.default)({ 3896 message: this.message, 3897 messageDetail: this.messageDetail 3898 }); 3899 3900 this.$el.html(html); 3901 this.delegateEvents(); 3902 return this; 3903 } 3904 3905 close() { 3906 this.$el.html('<div></div>'); 3907 } 3908 } 3909 exports.default = ErrorView; 3910 3911 /***/ }, 3912 /* 10 */ 3913 /***/ function(module, exports, __webpack_require__) { 3914 3915 'use strict'; 3916 3917 3918 var yaml = __webpack_require__(88); 3919 3920 3921 module.exports = yaml; 3922 3923 3924 /***/ }, 3925 /* 11 */ 3926 /***/ function(module, exports) { 3927 3928 // YAML error class. http://stackoverflow.com/questions/8458984 3929 // 3930 'use strict'; 3931 3932 function YAMLException(reason, mark) { 3933 // Super constructor 3934 Error.call(this); 3935 3936 // Include stack trace in error object 3937 if (Error.captureStackTrace) { 3938 // Chrome and NodeJS 3939 Error.captureStackTrace(this, this.constructor); 3940 } else { 3941 // FF, IE 10+ and Safari 6+. Fallback for others 3942 this.stack = (new Error()).stack || ''; 3943 } 3944 3945 this.name = 'YAMLException'; 3946 this.reason = reason; 3947 this.mark = mark; 3948 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : ''); 3949 } 3950 3951 3952 // Inherit from Error 3953 YAMLException.prototype = Object.create(Error.prototype); 3954 YAMLException.prototype.constructor = YAMLException; 3955 3956 3957 YAMLException.prototype.toString = function toString(compact) { 3958 var result = this.name + ': '; 3959 3960 result += this.reason || '(unknown reason)'; 3961 3962 if (!compact && this.mark) { 3963 result += ' ' + this.mark.toString(); 3964 } 3965 3966 return result; 3967 }; 3968 3969 3970 module.exports = YAMLException; 3971 3972 3973 /***/ }, 3974 /* 12 */ 3975 /***/ function(module, exports, __webpack_require__) { 3976 3977 // JS-YAML's default schema for `safeLoad` function. 3978 // It is not described in the YAML specification. 3979 // 3980 // This schema is based on standard YAML's Core schema and includes most of 3981 // extra types described at YAML tag repository. (http://yaml.org/type/) 3982 3983 3984 'use strict'; 3985 3986 3987 var Schema = __webpack_require__(8); 3988 3989 3990 module.exports = new Schema({ 3991 include: [ 3992 __webpack_require__(29) 3993 ], 3994 implicit: [ 3995 __webpack_require__(107), 3996 __webpack_require__(100) 3997 ], 3998 explicit: [ 3999 __webpack_require__(92), 4000 __webpack_require__(102), 4001 __webpack_require__(103), 4002 __webpack_require__(105) 4003 ] 4004 }); 4005 4006 4007 /***/ }, 4008 /* 13 */ 4009 /***/ function(module, exports, __webpack_require__) { 4010 4011 __webpack_require__(77); 4012 __webpack_require__(73); 4013 module.exports = __webpack_require__(58); 4014 4015 /***/ }, 4016 /* 14 */ 4017 /***/ function(module, exports, __webpack_require__) { 4018 4019 // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 4020 __webpack_require__(71) 4021 __webpack_require__(61) 4022 __webpack_require__(62) 4023 __webpack_require__(63) 4024 __webpack_require__(64) 4025 __webpack_require__(65) 4026 __webpack_require__(66) 4027 __webpack_require__(70) 4028 __webpack_require__(67) 4029 __webpack_require__(68) 4030 __webpack_require__(69) 4031 __webpack_require__(60) 4032 4033 /***/ }, 4034 /* 15 */ 4035 /***/ function(module, exports, __webpack_require__) { 4036 4037 // JS-YAML's default schema for `load` function. 4038 // It is not described in the YAML specification. 4039 // 4040 // This schema is based on JS-YAML's default safe schema and includes 4041 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function. 4042 // 4043 // Also this schema is used as default base schema at `Schema.create` function. 4044 4045 4046 'use strict'; 4047 4048 4049 var Schema = __webpack_require__(8); 4050 4051 4052 module.exports = Schema.DEFAULT = new Schema({ 4053 include: [ 4054 __webpack_require__(12) 4055 ], 4056 explicit: [ 4057 __webpack_require__(98), 4058 __webpack_require__(97), 4059 __webpack_require__(96) 4060 ] 4061 }); 4062 4063 4064 /***/ }, 4065 /* 16 */ 4066 /***/ function(module, exports, __webpack_require__) { 4067 4068 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 4069 4070 Object.defineProperty(exports, "__esModule", { 4071 value: true 4072 }); 4073 4074 var _backbone = __webpack_require__(2); 4075 4076 var _backbone2 = _interopRequireDefault(_backbone); 4077 4078 var _bootstrapDialog = __webpack_require__(13); 4079 4080 var _bootstrapDialog2 = _interopRequireDefault(_bootstrapDialog); 4081 4082 var _errorView = __webpack_require__(9); 4083 4084 var _errorView2 = _interopRequireDefault(_errorView); 4085 4086 __webpack_require__(5); 4087 4088 __webpack_require__(25); 4089 4090 __webpack_require__(43); 4091 4092 __webpack_require__(42); 4093 4094 __webpack_require__(47); 4095 4096 __webpack_require__(48); 4097 4098 __webpack_require__(46); 4099 4100 __webpack_require__(44); 4101 4102 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4103 4104 class DialogView extends _backbone.View { 4105 /** 4106 * Initialize of object properties. 4107 * 4108 * @class {DialogView} 4109 * @constructor 4110 * @param {string} options.action 4111 * @param {string} options.formTitle 4112 * @param {Object} options.data 4113 * @param {function} options.onsubmit 4114 * @param {Object} options.schema 4115 * @param {Object} options.parentProperty 4116 */ 4117 constructor(options) { 4118 super(options); 4119 4120 this.errorView = new _errorView2.default(); 4121 this.formTitle = options.formTitle; 4122 this.template = options.template; 4123 this.data = options.data; 4124 this.onshow = options.onshow; 4125 this.onsubmit = options.onsubmit; 4126 this.onhide = options.onhide; 4127 this.unformattedSchema = options.unformattedSchema; 4128 this.schema = options.schema; 4129 this.fields = options.fields; 4130 this.events = options.events; 4131 this.addingRelationDialog = this.unformattedSchema.addingRelationDialog || []; 4132 this.dialog = new _bootstrapDialog2.default({ 4133 size: _bootstrapDialog2.default.SIZE_WIDE, 4134 type: _bootstrapDialog2.default.TYPE_DEFAULT, 4135 title: this.formTitle, 4136 closeByKeyboard: false, 4137 spinicon: 'glyphicon glyphicon-refresh', 4138 onshown: () => { 4139 $('.modal-body').css({ 4140 'max-height': $(window).height() - 200 + 'px', 4141 'overflow-y': 'auto' 4142 }); 4143 this.form.focus(); 4144 }, 4145 onhide: this.onhide, 4146 onshow: this.onshow 4147 }); 4148 } 4149 4150 /** 4151 * Stops spin in button and enables buttons. 4152 */ 4153 stopSpin() { 4154 this.dialog.enableButtons(true); 4155 this.dialog.setClosable(true); 4156 this.dialog.getButton('submit').stopSpin(); 4157 } 4158 4159 /** 4160 * Closes dialog. 4161 */ 4162 close() { 4163 this.dialog.close(); 4164 this.remove(); 4165 this.off(); 4166 } 4167 4168 /** 4169 * Attaches event to form. 4170 * 4171 * @param {string} name 4172 * @param {function} callback 4173 */ 4174 on(name, callback) { 4175 if (this.form) { 4176 this.form.on(name, callback); 4177 } 4178 } 4179 4180 createRelationModel(passedSchema) { 4181 const data = passedSchema.toLocal({}); 4182 const formTitle = '<h4>Create ' + passedSchema.get('title') + '</h4>'; 4183 const action = 'create'; 4184 const onsubmit = values => { 4185 values = passedSchema.toServer(values); 4186 values.isNew = true; 4187 const collection = passedSchema.makeCollection(); 4188 4189 collection.create(values).then(params => { 4190 this.updateSelectEditor(params[1]); 4191 this.updateDialogSchema(); 4192 this.nestedDialog.close(); 4193 }, error => { 4194 this.nestedDialog.errorView.render(...error); 4195 this.nestedDialog.stopSpin(); 4196 }); 4197 }; 4198 const onhide = () => { 4199 const editor = this.form.fields[passedSchema.id + '_id'].editor; 4200 4201 if (editor.getValue() === 'addNew' + passedSchema.id) { 4202 editor.setValue(undefined); 4203 } 4204 }; 4205 4206 passedSchema.filterByAction(action, this.parentProperty).then(schema => { 4207 this.nestedDialog = new DialogView({ 4208 formTitle, 4209 data, 4210 onsubmit, 4211 onhide, 4212 schema: passedSchema.toFormJSON(schema), 4213 unformattedSchema: passedSchema, 4214 fields: schema.propertiesOrder 4215 }); 4216 this.nestedDialog.render(); 4217 }, error => { 4218 console.error(error); 4219 }); 4220 } 4221 4222 updateSelectEditor(params) { 4223 const schemaFieldName = Object.keys(params)[0]; 4224 const feedback = params[schemaFieldName]; 4225 const editor = this.form.fields[schemaFieldName + '_id'].editor; 4226 4227 this.schema[schemaFieldName + '_id'].options[feedback.id] = feedback.name; 4228 4229 editor.setOptions(this.schema[schemaFieldName + '_id'].options); 4230 editor.setValue(feedback.id); 4231 } 4232 4233 updateDialogSchema() { 4234 for (let key in this.schema) { 4235 if (this.schema.hasOwnProperty(key)) { 4236 const field = this.schema[key]; 4237 4238 const nestedCreationAllowed = this.addingRelationDialog.includes(field.title); 4239 4240 if (field.hasOwnProperty('relation') && field.type.toLowerCase() === 'select' && nestedCreationAllowed) { 4241 field.options['addNew' + field.relation] = ' + New ' + field.title; 4242 } 4243 } 4244 } 4245 } 4246 /** 4247 * Renders dialog view. 4248 * @returns {DialogView} 4249 */ 4250 render() { 4251 this.updateDialogSchema(); 4252 4253 this.form = new _backbone2.default.Form({ 4254 schema: this.schema, 4255 data: this.data, 4256 fields: this.fields.filter(item => Object.keys(this.schema).includes(item)), 4257 template: this.template 4258 }); 4259 4260 for (let key in this.schema) { 4261 if (this.schema.hasOwnProperty(key)) { 4262 const field = this.schema[key]; 4263 4264 if (field.type.toLowerCase() === 'select') { 4265 this.on(key + ':change', (form, element) => { 4266 const elementKey = element.getValue(); 4267 4268 if (elementKey.includes('addNew')) { 4269 const newSchema = this.unformattedSchema.collection.get(element.schema.relation); 4270 this.createRelationModel(newSchema); 4271 } 4272 }); 4273 } 4274 } 4275 } 4276 4277 if (this.events) { 4278 for (let key in this.events) { 4279 this.on(key, this.events[key]); 4280 } 4281 } 4282 this.form.render(); 4283 this.form.$el.prepend('<div data-gohan="error"></div>'); 4284 this.dialog.setMessage(this.form.el); 4285 this.dialog.addButton({ 4286 id: 'submit', 4287 label: 'Submit', 4288 cssClass: 'btn-primary', 4289 action: () => { 4290 var error = this.form.validate(); 4291 4292 if (error) { 4293 console.error(error); 4294 return; 4295 } 4296 this.dialog.enableButtons(false); 4297 this.dialog.setClosable(false); 4298 this.onsubmit(this.form.getValue()); 4299 } 4300 }); 4301 $('[data-gohan="error"]', this.form.el).append(this.errorView.el); 4302 this.dialog.open(); 4303 } 4304 } 4305 exports.default = DialogView; /* global $, window */ 4306 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 4307 4308 /***/ }, 4309 /* 17 */ 4310 /***/ function(module, exports, __webpack_require__) { 4311 4312 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 4313 4314 Object.defineProperty(exports, "__esModule", { 4315 value: true 4316 }); 4317 4318 var _backbone = __webpack_require__(2); 4319 4320 __webpack_require__(14); 4321 4322 var _jsYaml = __webpack_require__(10); 4323 4324 var _jsYaml2 = _interopRequireDefault(_jsYaml); 4325 4326 var _bootstrapDialog = __webpack_require__(13); 4327 4328 var _bootstrapDialog2 = _interopRequireDefault(_bootstrapDialog); 4329 4330 var _dialogView = __webpack_require__(16); 4331 4332 var _dialogView2 = _interopRequireDefault(_dialogView); 4333 4334 var _errorView = __webpack_require__(9); 4335 4336 var _errorView2 = _interopRequireDefault(_errorView); 4337 4338 var _loader = __webpack_require__(20); 4339 4340 var _loader2 = _interopRequireDefault(_loader); 4341 4342 var _dataPopup = __webpack_require__(110); 4343 4344 var _dataPopup2 = _interopRequireDefault(_dataPopup); 4345 4346 var _table = __webpack_require__(119); 4347 4348 var _table2 = _interopRequireDefault(_table); 4349 4350 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4351 4352 class TableView extends _backbone.View { 4353 get tagName() { 4354 return 'div'; 4355 } 4356 get className() { 4357 return 'tableview'; 4358 } 4359 get events() { 4360 return { 4361 'click [data-gohan="create"]': 'createModel', 4362 'click [data-gohan="delete"]': 'deleteModel', 4363 'click [data-gohan="update"]': 'updateModel', 4364 'click [data-gohan="sort-title"]': 'sortData', 4365 'keyup [data-gohan="search"]': 'searchByKey', 4366 'change [data-gohan="search"]': 'searchByField', 4367 'click [data-gohan="pagination"] li:not(.disabled) a': 'paginationHandler' 4368 }; 4369 } 4370 constructor(options) { 4371 super(options); 4372 4373 this.app = options.app; 4374 this.errorView = this.app.ErrorClass ? new this.app.ErrorClass() : new _errorView2.default(); 4375 this.template = options.template || _table2.default; 4376 this.loaderTemplate = options.loaderTemplate || _loader2.default; 4377 this.dialogTemplate = options.dialogTemplate; 4378 this.params = options.params; 4379 this.schema = options.schema; 4380 this.parent = options.parent; 4381 this.parentId = options.parentId; 4382 this.fragment = options.fragment; 4383 this.childview = options.childview; 4384 this.polling = options.polling; 4385 if (options.pageLimit !== undefined) { 4386 this.collection.pageLimit = Number(options.pageLimit); 4387 } 4388 if (this.params && this.params.page) { 4389 this.activePage = Number(this.params.page); 4390 } else { 4391 this.activePage = 1; 4392 } 4393 4394 this.paginationSettings = { 4395 start: 1, 4396 limit: 7 4397 }; 4398 this.activeSortFilter = { 4399 by: '', 4400 reverse: false 4401 }; 4402 this.searchQuery = { 4403 sortKey: '', 4404 propField: '' 4405 }; 4406 4407 this.searchDelay = 500; 4408 this.searchTimeout = undefined; 4409 4410 if (this.childview) { 4411 this.parentProperty = (this.parent || this.schema.get('parent')) + '_id'; 4412 } 4413 this.$el.html(this.loaderTemplate()); 4414 4415 if (this.collection !== undefined) { 4416 if (options.sortKey) { 4417 this.collection.sortKey = options.sortKey; 4418 } 4419 4420 if (options.sortOrder) { 4421 this.collection.sortOrder = options.sortOrder; 4422 } 4423 this.collection.getPage(this.activePage - 1).then(() => { 4424 this.render(); 4425 this.searchQuery.propField = $('[data-gohan="search"] select', this.$el).val(); 4426 if (this.polling) { 4427 this.collection.startLongPolling(); 4428 } 4429 }, error => { 4430 this.errorView.render(...error); 4431 }); 4432 4433 this.activeSortFilter.reverse = this.collection.sortOrder !== 'asc'; 4434 this.activeSortFilter.by = this.collection.sortKey; 4435 } 4436 4437 this.listenTo(this.collection, 'update', this.render); 4438 } 4439 searchByKey(event) { 4440 event.preventDefault(); 4441 event.stopPropagation(); 4442 4443 clearTimeout(this.searchTimeout); 4444 this.searchTimeout = setTimeout(() => { 4445 4446 this.fetchData(); 4447 }, this.searchDelay); 4448 } 4449 searchByField(event) { 4450 event.preventDefault(); 4451 event.stopPropagation(); 4452 4453 this.fetchData(); 4454 } 4455 fetchData() { 4456 const property = $('[data-gohan="search"] select', this.$el).val(); 4457 const value = $('[data-gohan="search"] input', this.$el).val(); 4458 4459 this.searchQuery = { 4460 sortKey: value, 4461 propField: property 4462 }; 4463 4464 if (value === '') { 4465 this.fetchByQuery(); 4466 } else { 4467 this.fetchByQuery(property, value); 4468 } 4469 } 4470 getPage(pageNo) { 4471 this.collection.getPage(pageNo - 1).then(() => { 4472 $('[data-gohan="search"] select', this.$el).val(this.searchQuery.propField); 4473 }, error => { 4474 this.errorView.render(...error); 4475 }); 4476 } 4477 fetchByQuery(property = 'name', value) { 4478 this.activePage = 1; 4479 4480 this.collection.resetFilters(); 4481 this.collection.filterByQuery(property, value).then(() => { 4482 $('[data-gohan="search"] select', this.$el).val(this.searchQuery.propField); 4483 $('[data-gohan="search"] input', this.$el).focus().val(this.searchQuery.sortKey); 4484 }, error => { 4485 this.errorView.render(...error); 4486 }); 4487 } 4488 4489 sortData(event) { 4490 event.preventDefault(); 4491 event.stopPropagation(); 4492 4493 const id = event.currentTarget.dataset.id; 4494 4495 if (this.activeSortFilter.by !== id) { 4496 this.activeSortFilter.by = id; 4497 this.activeSortFilter.reverse = false; 4498 } else if (this.activeSortFilter.by === id && !this.activeSortFilter.reverse) { 4499 this.activeSortFilter.reverse = true; 4500 } else { 4501 this.activeSortFilter.by = ''; 4502 this.activeSortFilter.reverse = false; 4503 } 4504 4505 const key = this.activeSortFilter.by; 4506 const order = this.activeSortFilter.reverse ? 'desc' : 'asc'; 4507 4508 this.collection.sort(key, order).then(() => {}, error => { 4509 this.errorView.render(...error); 4510 }); 4511 } 4512 paginationHandler(event) { 4513 event.preventDefault(); 4514 event.stopPropagation(); 4515 4516 let newActivePage = event.currentTarget.dataset.id; 4517 let showMorePages = event.currentTarget.dataset.more; 4518 4519 if (newActivePage === 'next') { 4520 newActivePage = Number(this.activePage) + 1; 4521 } else if (newActivePage === 'prev') { 4522 newActivePage = Number(this.activePage) - 1; 4523 } 4524 4525 if (this.activePage === Number(newActivePage)) { 4526 return; 4527 } 4528 4529 if (newActivePage === this.paginationSettings.start - 1) { 4530 showMorePages = 'left'; 4531 } else if (newActivePage === this.paginationSettings.start + this.paginationSettings.limit - 1) { 4532 showMorePages = 'right'; 4533 } 4534 4535 if (showMorePages === 'right') { 4536 this.paginationSettings.start = Number(newActivePage); 4537 } else if (showMorePages === 'left') { 4538 this.paginationSettings.start = this.paginationSettings.start - this.paginationSettings.limit + 1; 4539 if (this.paginationSettings.start < 1) this.paginationSettings.start = 1; 4540 } 4541 4542 this.activePage = Number(newActivePage); 4543 4544 if (!this.childview) { 4545 this.app.router.setQueryParams({ page: this.activePage }); 4546 } 4547 4548 this.getPage(Number(newActivePage)); 4549 } 4550 dialogForm(action, formTitle, data, onsubmit, onhide) { 4551 this.schema.filterByAction(action, this.parentProperty).then(schema => { 4552 this.dialog = new _dialogView2.default({ 4553 app: this.app, 4554 template: this.dialogTemplate, 4555 formTitle, 4556 data, 4557 onsubmit, 4558 onhide, 4559 schema: this.schema.toFormJSON(schema), 4560 unformattedSchema: this.schema, 4561 fields: schema.propertiesOrder 4562 }); 4563 this.dialog.render(); 4564 }); 4565 } 4566 toLocal(data) { 4567 return this.schema.toLocal(data); 4568 } 4569 toServer(data) { 4570 return this.schema.toServer(data); 4571 } 4572 createModel(event) { 4573 event.preventDefault(); 4574 event.stopPropagation(); 4575 event.currentTarget.disabled = true; 4576 4577 const data = this.toLocal({}); 4578 const formTitle = '<h4>Create ' + this.schema.get('title') + '</h4>'; 4579 const action = 'create'; 4580 const onhide = () => { 4581 event.currentTarget.disabled = false; 4582 }; 4583 const onsubmit = values => { 4584 values = this.toServer(values); 4585 values.isNew = true; 4586 if (this.parentId) { 4587 Object.assign(values, { [this.parent + '_id']: this.parentId }); 4588 } 4589 this.collection.create(values, { wait: true }).then(() => { 4590 this.dialog.close(); 4591 this.fetchData(); 4592 }, error => { 4593 this.dialog.errorView.render(...error); 4594 this.dialog.stopSpin(); 4595 }); 4596 }; 4597 4598 this.dialogForm(action, formTitle, data, onsubmit, onhide); 4599 } 4600 updateModel(event) { 4601 event.preventDefault(); 4602 event.stopPropagation(); 4603 event.currentTarget.disabled = true; 4604 4605 const $target = $(event.currentTarget); 4606 const id = $target.data('id'); 4607 const model = this.collection.get(String(id)); 4608 const data = this.toLocal(model.toJSON()); 4609 const action = 'update'; 4610 const formTitle = '<h4>Update ' + this.schema.get('title') + '</h4>'; 4611 const onhide = () => { 4612 event.currentTarget.disabled = false; 4613 }; 4614 const onsubmit = values => { 4615 values = this.toServer(values); 4616 4617 model.save(values, { wait: true }).then(() => { 4618 this.collection.trigger('update'); 4619 this.dialog.close(); 4620 event.currentTarget.disabled = false; 4621 }, error => { 4622 this.dialog.errorView.render(...error); 4623 this.dialog.stopSpin(); 4624 }); 4625 }; 4626 4627 this.dialogForm(action, formTitle, data, onsubmit, onhide); 4628 } 4629 deleteModel(event) { 4630 event.preventDefault(); 4631 event.stopPropagation(); 4632 4633 _bootstrapDialog2.default.confirm({ 4634 title: 'Delete', 4635 message: 'Are you sure to delete?', 4636 closable: true, 4637 btnOKLabel: 'Delete', 4638 callback: result => { 4639 if (result) { 4640 const $target = $(event.currentTarget); 4641 const id = $target.data('id'); 4642 const model = this.collection.get(String(id)); 4643 4644 model.destroy({ wait: true }).then(() => { 4645 this.collection.fetch().catch(error => this.errorView.render(...error)); 4646 }, error => this.errorView.render(...error)); 4647 } 4648 } 4649 }); 4650 } 4651 renderProperty(data, key) { 4652 let content; 4653 const property = this.schema.get('schema').properties[key]; 4654 const value = data[key]; 4655 4656 if (property === undefined) { 4657 return value; 4658 } 4659 4660 if (value === undefined) { 4661 return ''; 4662 } 4663 4664 const relatedObject = data[property.relation_property]; // jscs:ignore requireCamelCaseOrUpperCaseIdentifiers 4665 4666 if (relatedObject !== undefined) { 4667 if (relatedObject.name !== undefined) { 4668 return relatedObject.name; 4669 } 4670 } 4671 try { 4672 if (property.type === 'object' || property.originalType === 'object') { 4673 content = $('<pre style="width:500px;"></pre>').text('<pre>' + _jsYaml2.default.safeDump(value) + '</pre>').html(); 4674 content = content.replace('\'', '"'); 4675 return (0, _dataPopup2.default)({ 4676 content 4677 }); 4678 } 4679 } catch (error) { 4680 console.error(error); 4681 } 4682 4683 try { 4684 if (property.type === 'array') { 4685 return '<pre>' + _jsYaml2.default.safeDump(value) + '</pre>'; 4686 } 4687 } catch (error) { 4688 console.error(error); 4689 } 4690 4691 return value; 4692 } 4693 4694 render() { 4695 let list = this.collection.map(model => { 4696 const data = model.toJSON(); 4697 const result = Object.assign({}, data); 4698 4699 for (let key in data) { 4700 result[key] = this.renderProperty(data, key); 4701 } 4702 return result; 4703 }); 4704 if (this.app && !this.childview) { 4705 this.app.router.changeTitle(this.schema.get('title')); 4706 const parents = []; 4707 const fragment = this.collection.schema.get('url'); 4708 let schemaFragment; 4709 if (this.collection.schema.hasParent()) { 4710 schemaFragment = this.collection.schema.parent().get('url') + '/' + this.collection.parentId() + '/' + this.collection.schema.get('plural'); 4711 } else { 4712 schemaFragment = fragment; 4713 } 4714 parents.push({ 4715 title: this.collection.schema.get('title'), 4716 url: schemaFragment 4717 }); 4718 4719 parents.reverse(); 4720 this.app.breadCrumb.update(parents); 4721 } 4722 4723 this.$el.html(this.template({ 4724 data: list, 4725 activePage: this.activePage, 4726 pageCount: this.collection.getPageCount(), 4727 schema: this.schema.toJSON(), 4728 searchQuery: this.searchQuery, 4729 sort: this.activeSortFilter, 4730 parentProperty: this.parentProperty, 4731 pagination: this.paginationSettings, 4732 fragment: this.fragment 4733 })); 4734 this.$('a[data-toggle=popover]').popover(); 4735 $('[data-gohan="error"]', this.el).append(this.errorView.el); 4736 return this; 4737 } 4738 close() { 4739 if (!this.childview) { 4740 this.app.router.setQueryParams(); 4741 } 4742 if (this.polling) { 4743 this.collection.stopLongPolling(); 4744 } 4745 if (this.collection) { 4746 this.collection.resetFilters(); 4747 } 4748 this.remove(); 4749 } 4750 } 4751 exports.default = TableView; /* global $ */ 4752 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 4753 4754 /***/ }, 4755 /* 18 */ 4756 /***/ function(module, exports, __webpack_require__) { 4757 4758 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 4759 * jQuery UI Widget 1.12.1 4760 * http://jqueryui.com 4761 * 4762 * Copyright jQuery Foundation and other contributors 4763 * Released under the MIT license. 4764 * http://jquery.org/license 4765 */ 4766 4767 //>>label: Widget 4768 //>>group: Core 4769 //>>description: Provides a factory for creating stateful widgets with a common API. 4770 //>>docs: http://api.jqueryui.com/jQuery.widget/ 4771 //>>demos: http://jqueryui.com/widget/ 4772 4773 ( function( factory ) { 4774 if ( true ) { 4775 4776 // AMD. Register as an anonymous module. 4777 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(1), __webpack_require__(6) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 4778 } else { 4779 4780 // Browser globals 4781 factory( jQuery ); 4782 } 4783 }( function( $ ) { 4784 4785 var widgetUuid = 0; 4786 var widgetSlice = Array.prototype.slice; 4787 4788 $.cleanData = ( function( orig ) { 4789 return function( elems ) { 4790 var events, elem, i; 4791 for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { 4792 try { 4793 4794 // Only trigger remove when necessary to save time 4795 events = $._data( elem, "events" ); 4796 if ( events && events.remove ) { 4797 $( elem ).triggerHandler( "remove" ); 4798 } 4799 4800 // Http://bugs.jquery.com/ticket/8235 4801 } catch ( e ) {} 4802 } 4803 orig( elems ); 4804 }; 4805 } )( $.cleanData ); 4806 4807 $.widget = function( name, base, prototype ) { 4808 var existingConstructor, constructor, basePrototype; 4809 4810 // ProxiedPrototype allows the provided prototype to remain unmodified 4811 // so that it can be used as a mixin for multiple widgets (#8876) 4812 var proxiedPrototype = {}; 4813 4814 var namespace = name.split( "." )[ 0 ]; 4815 name = name.split( "." )[ 1 ]; 4816 var fullName = namespace + "-" + name; 4817 4818 if ( !prototype ) { 4819 prototype = base; 4820 base = $.Widget; 4821 } 4822 4823 if ( $.isArray( prototype ) ) { 4824 prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); 4825 } 4826 4827 // Create selector for plugin 4828 $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { 4829 return !!$.data( elem, fullName ); 4830 }; 4831 4832 $[ namespace ] = $[ namespace ] || {}; 4833 existingConstructor = $[ namespace ][ name ]; 4834 constructor = $[ namespace ][ name ] = function( options, element ) { 4835 4836 // Allow instantiation without "new" keyword 4837 if ( !this._createWidget ) { 4838 return new constructor( options, element ); 4839 } 4840 4841 // Allow instantiation without initializing for simple inheritance 4842 // must use "new" keyword (the code above always passes args) 4843 if ( arguments.length ) { 4844 this._createWidget( options, element ); 4845 } 4846 }; 4847 4848 // Extend with the existing constructor to carry over any static properties 4849 $.extend( constructor, existingConstructor, { 4850 version: prototype.version, 4851 4852 // Copy the object used to create the prototype in case we need to 4853 // redefine the widget later 4854 _proto: $.extend( {}, prototype ), 4855 4856 // Track widgets that inherit from this widget in case this widget is 4857 // redefined after a widget inherits from it 4858 _childConstructors: [] 4859 } ); 4860 4861 basePrototype = new base(); 4862 4863 // We need to make the options hash a property directly on the new instance 4864 // otherwise we'll modify the options hash on the prototype that we're 4865 // inheriting from 4866 basePrototype.options = $.widget.extend( {}, basePrototype.options ); 4867 $.each( prototype, function( prop, value ) { 4868 if ( !$.isFunction( value ) ) { 4869 proxiedPrototype[ prop ] = value; 4870 return; 4871 } 4872 proxiedPrototype[ prop ] = ( function() { 4873 function _super() { 4874 return base.prototype[ prop ].apply( this, arguments ); 4875 } 4876 4877 function _superApply( args ) { 4878 return base.prototype[ prop ].apply( this, args ); 4879 } 4880 4881 return function() { 4882 var __super = this._super; 4883 var __superApply = this._superApply; 4884 var returnValue; 4885 4886 this._super = _super; 4887 this._superApply = _superApply; 4888 4889 returnValue = value.apply( this, arguments ); 4890 4891 this._super = __super; 4892 this._superApply = __superApply; 4893 4894 return returnValue; 4895 }; 4896 } )(); 4897 } ); 4898 constructor.prototype = $.widget.extend( basePrototype, { 4899 4900 // TODO: remove support for widgetEventPrefix 4901 // always use the name + a colon as the prefix, e.g., draggable:start 4902 // don't prefix for widgets that aren't DOM-based 4903 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name 4904 }, proxiedPrototype, { 4905 constructor: constructor, 4906 namespace: namespace, 4907 widgetName: name, 4908 widgetFullName: fullName 4909 } ); 4910 4911 // If this widget is being redefined then we need to find all widgets that 4912 // are inheriting from it and redefine all of them so that they inherit from 4913 // the new version of this widget. We're essentially trying to replace one 4914 // level in the prototype chain. 4915 if ( existingConstructor ) { 4916 $.each( existingConstructor._childConstructors, function( i, child ) { 4917 var childPrototype = child.prototype; 4918 4919 // Redefine the child widget using the same prototype that was 4920 // originally used, but inherit from the new version of the base 4921 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, 4922 child._proto ); 4923 } ); 4924 4925 // Remove the list of existing child constructors from the old constructor 4926 // so the old child constructors can be garbage collected 4927 delete existingConstructor._childConstructors; 4928 } else { 4929 base._childConstructors.push( constructor ); 4930 } 4931 4932 $.widget.bridge( name, constructor ); 4933 4934 return constructor; 4935 }; 4936 4937 $.widget.extend = function( target ) { 4938 var input = widgetSlice.call( arguments, 1 ); 4939 var inputIndex = 0; 4940 var inputLength = input.length; 4941 var key; 4942 var value; 4943 4944 for ( ; inputIndex < inputLength; inputIndex++ ) { 4945 for ( key in input[ inputIndex ] ) { 4946 value = input[ inputIndex ][ key ]; 4947 if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { 4948 4949 // Clone objects 4950 if ( $.isPlainObject( value ) ) { 4951 target[ key ] = $.isPlainObject( target[ key ] ) ? 4952 $.widget.extend( {}, target[ key ], value ) : 4953 4954 // Don't extend strings, arrays, etc. with objects 4955 $.widget.extend( {}, value ); 4956 4957 // Copy everything else by reference 4958 } else { 4959 target[ key ] = value; 4960 } 4961 } 4962 } 4963 } 4964 return target; 4965 }; 4966 4967 $.widget.bridge = function( name, object ) { 4968 var fullName = object.prototype.widgetFullName || name; 4969 $.fn[ name ] = function( options ) { 4970 var isMethodCall = typeof options === "string"; 4971 var args = widgetSlice.call( arguments, 1 ); 4972 var returnValue = this; 4973 4974 if ( isMethodCall ) { 4975 4976 // If this is an empty collection, we need to have the instance method 4977 // return undefined instead of the jQuery instance 4978 if ( !this.length && options === "instance" ) { 4979 returnValue = undefined; 4980 } else { 4981 this.each( function() { 4982 var methodValue; 4983 var instance = $.data( this, fullName ); 4984 4985 if ( options === "instance" ) { 4986 returnValue = instance; 4987 return false; 4988 } 4989 4990 if ( !instance ) { 4991 return $.error( "cannot call methods on " + name + 4992 " prior to initialization; " + 4993 "attempted to call method '" + options + "'" ); 4994 } 4995 4996 if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { 4997 return $.error( "no such method '" + options + "' for " + name + 4998 " widget instance" ); 4999 } 5000 5001 methodValue = instance[ options ].apply( instance, args ); 5002 5003 if ( methodValue !== instance && methodValue !== undefined ) { 5004 returnValue = methodValue && methodValue.jquery ? 5005 returnValue.pushStack( methodValue.get() ) : 5006 methodValue; 5007 return false; 5008 } 5009 } ); 5010 } 5011 } else { 5012 5013 // Allow multiple hashes to be passed on init 5014 if ( args.length ) { 5015 options = $.widget.extend.apply( null, [ options ].concat( args ) ); 5016 } 5017 5018 this.each( function() { 5019 var instance = $.data( this, fullName ); 5020 if ( instance ) { 5021 instance.option( options || {} ); 5022 if ( instance._init ) { 5023 instance._init(); 5024 } 5025 } else { 5026 $.data( this, fullName, new object( options, this ) ); 5027 } 5028 } ); 5029 } 5030 5031 return returnValue; 5032 }; 5033 }; 5034 5035 $.Widget = function( /* options, element */ ) {}; 5036 $.Widget._childConstructors = []; 5037 5038 $.Widget.prototype = { 5039 widgetName: "widget", 5040 widgetEventPrefix: "", 5041 defaultElement: "<div>", 5042 5043 options: { 5044 classes: {}, 5045 disabled: false, 5046 5047 // Callbacks 5048 create: null 5049 }, 5050 5051 _createWidget: function( options, element ) { 5052 element = $( element || this.defaultElement || this )[ 0 ]; 5053 this.element = $( element ); 5054 this.uuid = widgetUuid++; 5055 this.eventNamespace = "." + this.widgetName + this.uuid; 5056 5057 this.bindings = $(); 5058 this.hoverable = $(); 5059 this.focusable = $(); 5060 this.classesElementLookup = {}; 5061 5062 if ( element !== this ) { 5063 $.data( element, this.widgetFullName, this ); 5064 this._on( true, this.element, { 5065 remove: function( event ) { 5066 if ( event.target === element ) { 5067 this.destroy(); 5068 } 5069 } 5070 } ); 5071 this.document = $( element.style ? 5072 5073 // Element within the document 5074 element.ownerDocument : 5075 5076 // Element is window or document 5077 element.document || element ); 5078 this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); 5079 } 5080 5081 this.options = $.widget.extend( {}, 5082 this.options, 5083 this._getCreateOptions(), 5084 options ); 5085 5086 this._create(); 5087 5088 if ( this.options.disabled ) { 5089 this._setOptionDisabled( this.options.disabled ); 5090 } 5091 5092 this._trigger( "create", null, this._getCreateEventData() ); 5093 this._init(); 5094 }, 5095 5096 _getCreateOptions: function() { 5097 return {}; 5098 }, 5099 5100 _getCreateEventData: $.noop, 5101 5102 _create: $.noop, 5103 5104 _init: $.noop, 5105 5106 destroy: function() { 5107 var that = this; 5108 5109 this._destroy(); 5110 $.each( this.classesElementLookup, function( key, value ) { 5111 that._removeClass( value, key ); 5112 } ); 5113 5114 // We can probably remove the unbind calls in 2.0 5115 // all event bindings should go through this._on() 5116 this.element 5117 .off( this.eventNamespace ) 5118 .removeData( this.widgetFullName ); 5119 this.widget() 5120 .off( this.eventNamespace ) 5121 .removeAttr( "aria-disabled" ); 5122 5123 // Clean up events and states 5124 this.bindings.off( this.eventNamespace ); 5125 }, 5126 5127 _destroy: $.noop, 5128 5129 widget: function() { 5130 return this.element; 5131 }, 5132 5133 option: function( key, value ) { 5134 var options = key; 5135 var parts; 5136 var curOption; 5137 var i; 5138 5139 if ( arguments.length === 0 ) { 5140 5141 // Don't return a reference to the internal hash 5142 return $.widget.extend( {}, this.options ); 5143 } 5144 5145 if ( typeof key === "string" ) { 5146 5147 // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 5148 options = {}; 5149 parts = key.split( "." ); 5150 key = parts.shift(); 5151 if ( parts.length ) { 5152 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); 5153 for ( i = 0; i < parts.length - 1; i++ ) { 5154 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; 5155 curOption = curOption[ parts[ i ] ]; 5156 } 5157 key = parts.pop(); 5158 if ( arguments.length === 1 ) { 5159 return curOption[ key ] === undefined ? null : curOption[ key ]; 5160 } 5161 curOption[ key ] = value; 5162 } else { 5163 if ( arguments.length === 1 ) { 5164 return this.options[ key ] === undefined ? null : this.options[ key ]; 5165 } 5166 options[ key ] = value; 5167 } 5168 } 5169 5170 this._setOptions( options ); 5171 5172 return this; 5173 }, 5174 5175 _setOptions: function( options ) { 5176 var key; 5177 5178 for ( key in options ) { 5179 this._setOption( key, options[ key ] ); 5180 } 5181 5182 return this; 5183 }, 5184 5185 _setOption: function( key, value ) { 5186 if ( key === "classes" ) { 5187 this._setOptionClasses( value ); 5188 } 5189 5190 this.options[ key ] = value; 5191 5192 if ( key === "disabled" ) { 5193 this._setOptionDisabled( value ); 5194 } 5195 5196 return this; 5197 }, 5198 5199 _setOptionClasses: function( value ) { 5200 var classKey, elements, currentElements; 5201 5202 for ( classKey in value ) { 5203 currentElements = this.classesElementLookup[ classKey ]; 5204 if ( value[ classKey ] === this.options.classes[ classKey ] || 5205 !currentElements || 5206 !currentElements.length ) { 5207 continue; 5208 } 5209 5210 // We are doing this to create a new jQuery object because the _removeClass() call 5211 // on the next line is going to destroy the reference to the current elements being 5212 // tracked. We need to save a copy of this collection so that we can add the new classes 5213 // below. 5214 elements = $( currentElements.get() ); 5215 this._removeClass( currentElements, classKey ); 5216 5217 // We don't use _addClass() here, because that uses this.options.classes 5218 // for generating the string of classes. We want to use the value passed in from 5219 // _setOption(), this is the new value of the classes option which was passed to 5220 // _setOption(). We pass this value directly to _classes(). 5221 elements.addClass( this._classes( { 5222 element: elements, 5223 keys: classKey, 5224 classes: value, 5225 add: true 5226 } ) ); 5227 } 5228 }, 5229 5230 _setOptionDisabled: function( value ) { 5231 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); 5232 5233 // If the widget is becoming disabled, then nothing is interactive 5234 if ( value ) { 5235 this._removeClass( this.hoverable, null, "ui-state-hover" ); 5236 this._removeClass( this.focusable, null, "ui-state-focus" ); 5237 } 5238 }, 5239 5240 enable: function() { 5241 return this._setOptions( { disabled: false } ); 5242 }, 5243 5244 disable: function() { 5245 return this._setOptions( { disabled: true } ); 5246 }, 5247 5248 _classes: function( options ) { 5249 var full = []; 5250 var that = this; 5251 5252 options = $.extend( { 5253 element: this.element, 5254 classes: this.options.classes || {} 5255 }, options ); 5256 5257 function processClassString( classes, checkOption ) { 5258 var current, i; 5259 for ( i = 0; i < classes.length; i++ ) { 5260 current = that.classesElementLookup[ classes[ i ] ] || $(); 5261 if ( options.add ) { 5262 current = $( $.unique( current.get().concat( options.element.get() ) ) ); 5263 } else { 5264 current = $( current.not( options.element ).get() ); 5265 } 5266 that.classesElementLookup[ classes[ i ] ] = current; 5267 full.push( classes[ i ] ); 5268 if ( checkOption && options.classes[ classes[ i ] ] ) { 5269 full.push( options.classes[ classes[ i ] ] ); 5270 } 5271 } 5272 } 5273 5274 this._on( options.element, { 5275 "remove": "_untrackClassesElement" 5276 } ); 5277 5278 if ( options.keys ) { 5279 processClassString( options.keys.match( /\S+/g ) || [], true ); 5280 } 5281 if ( options.extra ) { 5282 processClassString( options.extra.match( /\S+/g ) || [] ); 5283 } 5284 5285 return full.join( " " ); 5286 }, 5287 5288 _untrackClassesElement: function( event ) { 5289 var that = this; 5290 $.each( that.classesElementLookup, function( key, value ) { 5291 if ( $.inArray( event.target, value ) !== -1 ) { 5292 that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); 5293 } 5294 } ); 5295 }, 5296 5297 _removeClass: function( element, keys, extra ) { 5298 return this._toggleClass( element, keys, extra, false ); 5299 }, 5300 5301 _addClass: function( element, keys, extra ) { 5302 return this._toggleClass( element, keys, extra, true ); 5303 }, 5304 5305 _toggleClass: function( element, keys, extra, add ) { 5306 add = ( typeof add === "boolean" ) ? add : extra; 5307 var shift = ( typeof element === "string" || element === null ), 5308 options = { 5309 extra: shift ? keys : extra, 5310 keys: shift ? element : keys, 5311 element: shift ? this.element : element, 5312 add: add 5313 }; 5314 options.element.toggleClass( this._classes( options ), add ); 5315 return this; 5316 }, 5317 5318 _on: function( suppressDisabledCheck, element, handlers ) { 5319 var delegateElement; 5320 var instance = this; 5321 5322 // No suppressDisabledCheck flag, shuffle arguments 5323 if ( typeof suppressDisabledCheck !== "boolean" ) { 5324 handlers = element; 5325 element = suppressDisabledCheck; 5326 suppressDisabledCheck = false; 5327 } 5328 5329 // No element argument, shuffle and use this.element 5330 if ( !handlers ) { 5331 handlers = element; 5332 element = this.element; 5333 delegateElement = this.widget(); 5334 } else { 5335 element = delegateElement = $( element ); 5336 this.bindings = this.bindings.add( element ); 5337 } 5338 5339 $.each( handlers, function( event, handler ) { 5340 function handlerProxy() { 5341 5342 // Allow widgets to customize the disabled handling 5343 // - disabled as an array instead of boolean 5344 // - disabled class as method for disabling individual parts 5345 if ( !suppressDisabledCheck && 5346 ( instance.options.disabled === true || 5347 $( this ).hasClass( "ui-state-disabled" ) ) ) { 5348 return; 5349 } 5350 return ( typeof handler === "string" ? instance[ handler ] : handler ) 5351 .apply( instance, arguments ); 5352 } 5353 5354 // Copy the guid so direct unbinding works 5355 if ( typeof handler !== "string" ) { 5356 handlerProxy.guid = handler.guid = 5357 handler.guid || handlerProxy.guid || $.guid++; 5358 } 5359 5360 var match = event.match( /^([\w:-]*)\s*(.*)$/ ); 5361 var eventName = match[ 1 ] + instance.eventNamespace; 5362 var selector = match[ 2 ]; 5363 5364 if ( selector ) { 5365 delegateElement.on( eventName, selector, handlerProxy ); 5366 } else { 5367 element.on( eventName, handlerProxy ); 5368 } 5369 } ); 5370 }, 5371 5372 _off: function( element, eventName ) { 5373 eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + 5374 this.eventNamespace; 5375 element.off( eventName ).off( eventName ); 5376 5377 // Clear the stack to avoid memory leaks (#10056) 5378 this.bindings = $( this.bindings.not( element ).get() ); 5379 this.focusable = $( this.focusable.not( element ).get() ); 5380 this.hoverable = $( this.hoverable.not( element ).get() ); 5381 }, 5382 5383 _delay: function( handler, delay ) { 5384 function handlerProxy() { 5385 return ( typeof handler === "string" ? instance[ handler ] : handler ) 5386 .apply( instance, arguments ); 5387 } 5388 var instance = this; 5389 return setTimeout( handlerProxy, delay || 0 ); 5390 }, 5391 5392 _hoverable: function( element ) { 5393 this.hoverable = this.hoverable.add( element ); 5394 this._on( element, { 5395 mouseenter: function( event ) { 5396 this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); 5397 }, 5398 mouseleave: function( event ) { 5399 this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); 5400 } 5401 } ); 5402 }, 5403 5404 _focusable: function( element ) { 5405 this.focusable = this.focusable.add( element ); 5406 this._on( element, { 5407 focusin: function( event ) { 5408 this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); 5409 }, 5410 focusout: function( event ) { 5411 this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); 5412 } 5413 } ); 5414 }, 5415 5416 _trigger: function( type, event, data ) { 5417 var prop, orig; 5418 var callback = this.options[ type ]; 5419 5420 data = data || {}; 5421 event = $.Event( event ); 5422 event.type = ( type === this.widgetEventPrefix ? 5423 type : 5424 this.widgetEventPrefix + type ).toLowerCase(); 5425 5426 // The original event may come from any element 5427 // so we need to reset the target on the new event 5428 event.target = this.element[ 0 ]; 5429 5430 // Copy original event properties over to the new event 5431 orig = event.originalEvent; 5432 if ( orig ) { 5433 for ( prop in orig ) { 5434 if ( !( prop in event ) ) { 5435 event[ prop ] = orig[ prop ]; 5436 } 5437 } 5438 } 5439 5440 this.element.trigger( event, data ); 5441 return !( $.isFunction( callback ) && 5442 callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || 5443 event.isDefaultPrevented() ); 5444 } 5445 }; 5446 5447 $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { 5448 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { 5449 if ( typeof options === "string" ) { 5450 options = { effect: options }; 5451 } 5452 5453 var hasOptions; 5454 var effectName = !options ? 5455 method : 5456 options === true || typeof options === "number" ? 5457 defaultEffect : 5458 options.effect || defaultEffect; 5459 5460 options = options || {}; 5461 if ( typeof options === "number" ) { 5462 options = { duration: options }; 5463 } 5464 5465 hasOptions = !$.isEmptyObject( options ); 5466 options.complete = callback; 5467 5468 if ( options.delay ) { 5469 element.delay( options.delay ); 5470 } 5471 5472 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 5473 element[ method ]( options ); 5474 } else if ( effectName !== method && element[ effectName ] ) { 5475 element[ effectName ]( options.duration, options.easing, callback ); 5476 } else { 5477 element.queue( function( next ) { 5478 $( this )[ method ](); 5479 if ( callback ) { 5480 callback.call( element[ 0 ] ); 5481 } 5482 next(); 5483 } ); 5484 } 5485 }; 5486 } ); 5487 5488 return $.widget; 5489 5490 } ) ); 5491 5492 5493 /***/ }, 5494 /* 19 */ 5495 /***/ function(module, exports, __webpack_require__) { 5496 5497 // Standard YAML's Failsafe schema. 5498 // http://www.yaml.org/spec/1.2/spec.html#id2802346 5499 5500 5501 'use strict'; 5502 5503 5504 var Schema = __webpack_require__(8); 5505 5506 5507 module.exports = new Schema({ 5508 explicit: [ 5509 __webpack_require__(106), 5510 __webpack_require__(104), 5511 __webpack_require__(99) 5512 ] 5513 }); 5514 5515 5516 /***/ }, 5517 /* 20 */ 5518 /***/ function(module, exports) { 5519 5520 module.exports = function(obj){ 5521 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 5522 with(obj||{}){ 5523 __p+='<div class="sk-three-bounce">\n <div class="sk-child sk-bounce1"></div>\n <div class="sk-child sk-bounce2"></div>\n <div class="sk-child sk-bounce3"></div>\n</div>\n'; 5524 } 5525 return __p; 5526 }; 5527 5528 /***/ }, 5529 /* 21 */ 5530 /***/ function(module, exports, __webpack_require__) { 5531 5532 (function(){function o(n){var i=e;n&&(e[n]||(e[n]={}),i=e[n]);if(!i.define||!i.define.packaged)t.original=i.define,i.define=t,i.define.packaged=!0;if(!i.require||!i.require.packaged)r.original=i.require,i.require=r,i.require.packaged=!0}var ACE_NAMESPACE = "ace",e=function(){return this}();!e&&typeof window!="undefined"&&(e=window);if(!ACE_NAMESPACE&&typeof requirejs!="undefined")return;var t=function(e,n,r){if(typeof e!="string"){t.original?t.original.apply(this,arguments):(console.error("dropping module because define wasn't a string."),console.trace());return}arguments.length==2&&(r=n),t.modules[e]||(t.payloads[e]=r,t.modules[e]=null)};t.modules={},t.payloads={};var n=function(e,t,n){if(typeof t=="string"){var i=s(e,t);if(i!=undefined)return n&&n(),i}else if(Object.prototype.toString.call(t)==="[object Array]"){var o=[];for(var u=0,a=t.length;u<a;++u){var f=s(e,t[u]);if(f==undefined&&r.original)return;o.push(f)}return n&&n.apply(null,o)||!0}},r=function(e,t){var i=n("",e,t);return i==undefined&&r.original?r.original.apply(this,arguments):i},i=function(e,t){if(t.indexOf("!")!==-1){var n=t.split("!");return i(e,n[0])+"!"+i(e,n[1])}if(t.charAt(0)=="."){var r=e.split("/").slice(0,-1).join("/");t=r+"/"+t;while(t.indexOf(".")!==-1&&s!=t){var s=t;t=t.replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return t},s=function(e,r){r=i(e,r);var s=t.modules[r];if(!s){s=t.payloads[r];if(typeof s=="function"){var o={},u={id:r,uri:"",exports:o,packaged:!0},a=function(e,t){return n(r,e,t)},f=s(a,o,u);o=f||u.exports,t.modules[r]=o,delete t.payloads[r]}s=t.modules[r]=o||s}return s};o(ACE_NAMESPACE)})(),ace.define("ace/lib/regexp",["require","exports","module"],function(e,t,n){"use strict";function o(e){return(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.extended?"x":"")+(e.sticky?"y":"")}function u(e,t,n){if(Array.prototype.indexOf)return e.indexOf(t,n);for(var r=n||0;r<e.length;r++)if(e[r]===t)return r;return-1}var r={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},i=r.exec.call(/()??/,"")[1]===undefined,s=function(){var e=/^/g;return r.test.call(e,""),!e.lastIndex}();if(s&&i)return;RegExp.prototype.exec=function(e){var t=r.exec.apply(this,arguments),n,a;if(typeof e=="string"&&t){!i&&t.length>1&&u(t,"")>-1&&(a=RegExp(this.source,r.replace.call(o(this),"g","")),r.replace.call(e.slice(t.index),a,function(){for(var e=1;e<arguments.length-2;e++)arguments[e]===undefined&&(t[e]=undefined)}));if(this._xregexp&&this._xregexp.captureNames)for(var f=1;f<t.length;f++)n=this._xregexp.captureNames[f-1],n&&(t[n]=t[f]);!s&&this.global&&!t[0].length&&this.lastIndex>t.index&&this.lastIndex--}return t},s||(RegExp.prototype.test=function(e){var t=r.exec.call(this,e);return t&&this.global&&!t[0].length&&this.lastIndex>t.index&&this.lastIndex--,!!t})}),ace.define("ace/lib/es5-shim",["require","exports","module"],function(e,t,n){function r(){}function w(e){try{return Object.defineProperty(e,"sentinel",{}),"sentinel"in e}catch(t){}}function H(e){return e=+e,e!==e?e=0:e!==0&&e!==1/0&&e!==-1/0&&(e=(e>0||-1)*Math.floor(Math.abs(e))),e}function B(e){var t=typeof e;return e===null||t==="undefined"||t==="boolean"||t==="number"||t==="string"}function j(e){var t,n,r;if(B(e))return e;n=e.valueOf;if(typeof n=="function"){t=n.call(e);if(B(t))return t}r=e.toString;if(typeof r=="function"){t=r.call(e);if(B(t))return t}throw new TypeError}Function.prototype.bind||(Function.prototype.bind=function(t){var n=this;if(typeof n!="function")throw new TypeError("Function.prototype.bind called on incompatible "+n);var i=u.call(arguments,1),s=function(){if(this instanceof s){var e=n.apply(this,i.concat(u.call(arguments)));return Object(e)===e?e:this}return n.apply(t,i.concat(u.call(arguments)))};return n.prototype&&(r.prototype=n.prototype,s.prototype=new r,r.prototype=null),s});var i=Function.prototype.call,s=Array.prototype,o=Object.prototype,u=s.slice,a=i.bind(o.toString),f=i.bind(o.hasOwnProperty),l,c,h,p,d;if(d=f(o,"__defineGetter__"))l=i.bind(o.__defineGetter__),c=i.bind(o.__defineSetter__),h=i.bind(o.__lookupGetter__),p=i.bind(o.__lookupSetter__);if([1,2].splice(0).length!=2)if(!function(){function e(e){var t=new Array(e+2);return t[0]=t[1]=0,t}var t=[],n;t.splice.apply(t,e(20)),t.splice.apply(t,e(26)),n=t.length,t.splice(5,0,"XXX"),n+1==t.length;if(n+1==t.length)return!0}())Array.prototype.splice=function(e,t){var n=this.length;e>0?e>n&&(e=n):e==void 0?e=0:e<0&&(e=Math.max(n+e,0)),e+t<n||(t=n-e);var r=this.slice(e,e+t),i=u.call(arguments,2),s=i.length;if(e===n)s&&this.push.apply(this,i);else{var o=Math.min(t,n-e),a=e+o,f=a+s-o,l=n-a,c=n-o;if(f<a)for(var h=0;h<l;++h)this[f+h]=this[a+h];else if(f>a)for(h=l;h--;)this[f+h]=this[a+h];if(s&&e===c)this.length=c,this.push.apply(this,i);else{this.length=c+s;for(h=0;h<s;++h)this[e+h]=i[h]}}return r};else{var v=Array.prototype.splice;Array.prototype.splice=function(e,t){return arguments.length?v.apply(this,[e===void 0?0:e,t===void 0?this.length-e:t].concat(u.call(arguments,2))):[]}}Array.isArray||(Array.isArray=function(t){return a(t)=="[object Array]"});var m=Object("a"),g=m[0]!="a"||!(0 in m);Array.prototype.forEach||(Array.prototype.forEach=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=arguments[1],s=-1,o=r.length>>>0;if(a(t)!="[object Function]")throw new TypeError;while(++s<o)s in r&&t.call(i,r[s],s,n)}),Array.prototype.map||(Array.prototype.map=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=Array(i),o=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var u=0;u<i;u++)u in r&&(s[u]=t.call(o,r[u],u,n));return s}),Array.prototype.filter||(Array.prototype.filter=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=[],o,u=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var f=0;f<i;f++)f in r&&(o=r[f],t.call(u,o,f,n)&&s.push(o));return s}),Array.prototype.every||(Array.prototype.every=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o<i;o++)if(o in r&&!t.call(s,r[o],o,n))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o<i;o++)if(o in r&&t.call(s,r[o],o,n))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduce of empty array with no initial value");var s=0,o;if(arguments.length>=2)o=arguments[1];else do{if(s in r){o=r[s++];break}if(++s>=i)throw new TypeError("reduce of empty array with no initial value")}while(!0);for(;s<i;s++)s in r&&(o=t.call(void 0,o,r[s],s,n));return o}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");var s,o=i-1;if(arguments.length>=2)s=arguments[1];else do{if(o in r){s=r[o--];break}if(--o<0)throw new TypeError("reduceRight of empty array with no initial value")}while(!0);do o in this&&(s=t.call(void 0,s,r[o],o,n));while(o--);return s});if(!Array.prototype.indexOf||[0,1].indexOf(1,2)!=-1)Array.prototype.indexOf=function(t){var n=g&&a(this)=="[object String]"?this.split(""):F(this),r=n.length>>>0;if(!r)return-1;var i=0;arguments.length>1&&(i=H(arguments[1])),i=i>=0?i:Math.max(0,r+i);for(;i<r;i++)if(i in n&&n[i]===t)return i;return-1};if(!Array.prototype.lastIndexOf||[0,1].lastIndexOf(0,-3)!=-1)Array.prototype.lastIndexOf=function(t){var n=g&&a(this)=="[object String]"?this.split(""):F(this),r=n.length>>>0;if(!r)return-1;var i=r-1;arguments.length>1&&(i=Math.min(i,H(arguments[1]))),i=i>=0?i:r-Math.abs(i);for(;i>=0;i--)if(i in n&&t===n[i])return i;return-1};Object.getPrototypeOf||(Object.getPrototypeOf=function(t){return t.__proto__||(t.constructor?t.constructor.prototype:o)});if(!Object.getOwnPropertyDescriptor){var y="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function(t,n){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(y+t);if(!f(t,n))return;var r,i,s;r={enumerable:!0,configurable:!0};if(d){var u=t.__proto__;t.__proto__=o;var i=h(t,n),s=p(t,n);t.__proto__=u;if(i||s)return i&&(r.get=i),s&&(r.set=s),r}return r.value=t[n],r}}Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(t){return Object.keys(t)});if(!Object.create){var b;Object.prototype.__proto__===null?b=function(){return{__proto__:null}}:b=function(){var e={};for(var t in e)e[t]=null;return e.constructor=e.hasOwnProperty=e.propertyIsEnumerable=e.isPrototypeOf=e.toLocaleString=e.toString=e.valueOf=e.__proto__=null,e},Object.create=function(t,n){var r;if(t===null)r=b();else{if(typeof t!="object")throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var i=function(){};i.prototype=t,r=new i,r.__proto__=t}return n!==void 0&&Object.defineProperties(r,n),r}}if(Object.defineProperty){var E=w({}),S=typeof document=="undefined"||w(document.createElement("div"));if(!E||!S)var x=Object.defineProperty}if(!Object.defineProperty||x){var T="Property description must be an object: ",N="Object.defineProperty called on non-object: ",C="getters & setters can not be defined on this javascript engine";Object.defineProperty=function(t,n,r){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(N+t);if(typeof r!="object"&&typeof r!="function"||r===null)throw new TypeError(T+r);if(x)try{return x.call(Object,t,n,r)}catch(i){}if(f(r,"value"))if(d&&(h(t,n)||p(t,n))){var s=t.__proto__;t.__proto__=o,delete t[n],t[n]=r.value,t.__proto__=s}else t[n]=r.value;else{if(!d)throw new TypeError(C);f(r,"get")&&l(t,n,r.get),f(r,"set")&&c(t,n,r.set)}return t}}Object.defineProperties||(Object.defineProperties=function(t,n){for(var r in n)f(n,r)&&Object.defineProperty(t,r,n[r]);return t}),Object.seal||(Object.seal=function(t){return t}),Object.freeze||(Object.freeze=function(t){return t});try{Object.freeze(function(){})}catch(k){Object.freeze=function(t){return function(n){return typeof n=="function"?n:t(n)}}(Object.freeze)}Object.preventExtensions||(Object.preventExtensions=function(t){return t}),Object.isSealed||(Object.isSealed=function(t){return!1}),Object.isFrozen||(Object.isFrozen=function(t){return!1}),Object.isExtensible||(Object.isExtensible=function(t){if(Object(t)===t)throw new TypeError;var n="";while(f(t,n))n+="?";t[n]=!0;var r=f(t,n);return delete t[n],r});if(!Object.keys){var L=!0,A=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],O=A.length;for(var M in{toString:null})L=!1;Object.keys=function I(e){if(typeof e!="object"&&typeof e!="function"||e===null)throw new TypeError("Object.keys called on a non-object");var I=[];for(var t in e)f(e,t)&&I.push(t);if(L)for(var n=0,r=O;n<r;n++){var i=A[n];f(e,i)&&I.push(i)}return I}}Date.now||(Date.now=function(){return(new Date).getTime()});var _=" \n\f\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff";if(!String.prototype.trim||_.trim()){_="["+_+"]";var D=new RegExp("^"+_+_+"*"),P=new RegExp(_+_+"*$");String.prototype.trim=function(){return String(this).replace(D,"").replace(P,"")}}var F=function(e){if(e==null)throw new TypeError("can't convert "+e+" to object");return Object(e)}}),ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"],function(e,t,n){"use strict";e("./regexp"),e("./es5-shim")}),ace.define("ace/lib/dom",["require","exports","module"],function(e,t,n){"use strict";var r="http://www.w3.org/1999/xhtml";t.getDocumentHead=function(e){return e||(e=document),e.head||e.getElementsByTagName("head")[0]||e.documentElement},t.createElement=function(e,t){return document.createElementNS?document.createElementNS(t||r,e):document.createElement(e)},t.hasCssClass=function(e,t){var n=(e.className+"").split(/\s+/g);return n.indexOf(t)!==-1},t.addCssClass=function(e,n){t.hasCssClass(e,n)||(e.className+=" "+n)},t.removeCssClass=function(e,t){var n=e.className.split(/\s+/g);for(;;){var r=n.indexOf(t);if(r==-1)break;n.splice(r,1)}e.className=n.join(" ")},t.toggleCssClass=function(e,t){var n=e.className.split(/\s+/g),r=!0;for(;;){var i=n.indexOf(t);if(i==-1)break;r=!1,n.splice(i,1)}return r&&n.push(t),e.className=n.join(" "),r},t.setCssClass=function(e,n,r){r?t.addCssClass(e,n):t.removeCssClass(e,n)},t.hasCssString=function(e,t){var n=0,r;t=t||document;if(t.createStyleSheet&&(r=t.styleSheets)){while(n<r.length)if(r[n++].owningElement.id===e)return!0}else if(r=t.getElementsByTagName("style"))while(n<r.length)if(r[n++].id===e)return!0;return!1},t.importCssString=function(n,r,i){i=i||document;if(r&&t.hasCssString(r,i))return null;var s;r&&(n+="\n/*# sourceURL=ace/css/"+r+" */"),i.createStyleSheet?(s=i.createStyleSheet(),s.cssText=n,r&&(s.owningElement.id=r)):(s=t.createElement("style"),s.appendChild(i.createTextNode(n)),r&&(s.id=r),t.getDocumentHead(i).appendChild(s))},t.importCssStylsheet=function(e,n){if(n.createStyleSheet)n.createStyleSheet(e);else{var r=t.createElement("link");r.rel="stylesheet",r.href=e,t.getDocumentHead(n).appendChild(r)}},t.getInnerWidth=function(e){return parseInt(t.computedStyle(e,"paddingLeft"),10)+parseInt(t.computedStyle(e,"paddingRight"),10)+e.clientWidth},t.getInnerHeight=function(e){return parseInt(t.computedStyle(e,"paddingTop"),10)+parseInt(t.computedStyle(e,"paddingBottom"),10)+e.clientHeight},t.scrollbarWidth=function(e){var n=t.createElement("ace_inner");n.style.width="100%",n.style.minWidth="0px",n.style.height="200px",n.style.display="block";var r=t.createElement("ace_outer"),i=r.style;i.position="absolute",i.left="-10000px",i.overflow="hidden",i.width="200px",i.minWidth="0px",i.height="150px",i.display="block",r.appendChild(n);var s=e.documentElement;s.appendChild(r);var o=n.offsetWidth;i.overflow="scroll";var u=n.offsetWidth;return o==u&&(u=r.clientWidth),s.removeChild(r),o-u};if(typeof document=="undefined"){t.importCssString=function(){};return}window.pageYOffset!==undefined?(t.getPageScrollTop=function(){return window.pageYOffset},t.getPageScrollLeft=function(){return window.pageXOffset}):(t.getPageScrollTop=function(){return document.body.scrollTop},t.getPageScrollLeft=function(){return document.body.scrollLeft}),window.getComputedStyle?t.computedStyle=function(e,t){return t?(window.getComputedStyle(e,"")||{})[t]||"":window.getComputedStyle(e,"")||{}}:t.computedStyle=function(e,t){return t?e.currentStyle[t]:e.currentStyle},t.setInnerHtml=function(e,t){var n=e.cloneNode(!1);return n.innerHTML=t,e.parentNode.replaceChild(n,e),n},"textContent"in document.documentElement?(t.setInnerText=function(e,t){e.textContent=t},t.getInnerText=function(e){return e.textContent}):(t.setInnerText=function(e,t){e.innerText=t},t.getInnerText=function(e){return e.innerText}),t.getParentWindow=function(e){return e.defaultView||e.parentWindow}}),ace.define("ace/lib/oop",["require","exports","module"],function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}}),ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"],function(e,t,n){"use strict";e("./fixoldbrowsers");var r=e("./oop"),i=function(){var e={MODIFIER_KEYS:{16:"Shift",17:"Ctrl",18:"Alt",224:"Meta"},KEY_MODS:{ctrl:1,alt:2,option:2,shift:4,"super":8,meta:8,command:8,cmd:8},FUNCTION_KEYS:{8:"Backspace",9:"Tab",13:"Return",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9","-13":"NumpadEnter",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock"},PRINTABLE_KEYS:{32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",111:"/",106:"*"}},t,n;for(n in e.FUNCTION_KEYS)t=e.FUNCTION_KEYS[n].toLowerCase(),e[t]=parseInt(n,10);for(n in e.PRINTABLE_KEYS)t=e.PRINTABLE_KEYS[n].toLowerCase(),e[t]=parseInt(n,10);return r.mixin(e,e.MODIFIER_KEYS),r.mixin(e,e.PRINTABLE_KEYS),r.mixin(e,e.FUNCTION_KEYS),e.enter=e["return"],e.escape=e.esc,e.del=e["delete"],e[173]="-",function(){var t=["cmd","ctrl","alt","shift"];for(var n=Math.pow(2,t.length);n--;)e.KEY_MODS[n]=t.filter(function(t){return n&e.KEY_MODS[t]}).join("-")+"-"}(),e.KEY_MODS[0]="",e.KEY_MODS[-1]="input-",e}();r.mixin(t,i),t.keyCodeToString=function(e){var t=i[e];return typeof t!="string"&&(t=String.fromCharCode(e)),t.toLowerCase()}}),ace.define("ace/lib/useragent",["require","exports","module"],function(e,t,n){"use strict";t.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"},t.getOS=function(){return t.isMac?t.OS.MAC:t.isLinux?t.OS.LINUX:t.OS.WINDOWS};if(typeof navigator!="object")return;var r=(navigator.platform.match(/mac|win|linux/i)||["other"])[0].toLowerCase(),i=navigator.userAgent;t.isWin=r=="win",t.isMac=r=="mac",t.isLinux=r=="linux",t.isIE=navigator.appName=="Microsoft Internet Explorer"||navigator.appName.indexOf("MSAppHost")>=0?parseFloat((i.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]):parseFloat((i.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]),t.isOldIE=t.isIE&&t.isIE<9,t.isGecko=t.isMozilla=(window.Controllers||window.controllers)&&window.navigator.product==="Gecko",t.isOldGecko=t.isGecko&&parseInt((i.match(/rv:(\d+)/)||[])[1],10)<4,t.isOpera=window.opera&&Object.prototype.toString.call(window.opera)=="[object Opera]",t.isWebKit=parseFloat(i.split("WebKit/")[1])||undefined,t.isChrome=parseFloat(i.split(" Chrome/")[1])||undefined,t.isAIR=i.indexOf("AdobeAIR")>=0,t.isIPad=i.indexOf("iPad")>=0,t.isTouchPad=i.indexOf("TouchPad")>=0,t.isChromeOS=i.indexOf(" CrOS ")>=0}),ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function a(e,t,n){var a=u(t);if(!i.isMac&&s){t.getModifierState&&(t.getModifierState("OS")||t.getModifierState("Win"))&&(a|=8);if(s.altGr){if((3&a)==3)return;s.altGr=0}if(n===18||n===17){var f="location"in t?t.location:t.keyLocation;if(n===17&&f===1)s[n]==1&&(o=t.timeStamp);else if(n===18&&a===3&&f===2){var l=t.timeStamp-o;l<50&&(s.altGr=!0)}}}n in r.MODIFIER_KEYS&&(n=-1),a&8&&n>=91&&n<=93&&(n=-1);if(!a&&n===13){var f="location"in t?t.location:t.keyLocation;if(f===3){e(t,a,-n);if(t.defaultPrevented)return}}if(i.isChromeOS&&a&8){e(t,a,n);if(t.defaultPrevented)return;a&=-9}return!!a||n in r.FUNCTION_KEYS||n in r.PRINTABLE_KEYS?e(t,a,n):!1}function f(){s=Object.create(null)}var r=e("./keys"),i=e("./useragent"),s=null,o=0;t.addListener=function(e,t,n){if(e.addEventListener)return e.addEventListener(t,n,!1);if(e.attachEvent){var r=function(){n.call(e,window.event)};n._wrapper=r,e.attachEvent("on"+t,r)}},t.removeListener=function(e,t,n){if(e.removeEventListener)return e.removeEventListener(t,n,!1);e.detachEvent&&e.detachEvent("on"+t,n._wrapper||n)},t.stopEvent=function(e){return t.stopPropagation(e),t.preventDefault(e),!1},t.stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},t.preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},t.getButton=function(e){return e.type=="dblclick"?0:e.type=="contextmenu"||i.isMac&&e.ctrlKey&&!e.altKey&&!e.shiftKey?2:e.preventDefault?e.button:{1:0,2:2,4:1}[e.button]},t.capture=function(e,n,r){function i(e){n&&n(e),r&&r(e),t.removeListener(document,"mousemove",n,!0),t.removeListener(document,"mouseup",i,!0),t.removeListener(document,"dragstart",i,!0)}return t.addListener(document,"mousemove",n,!0),t.addListener(document,"mouseup",i,!0),t.addListener(document,"dragstart",i,!0),i},t.addTouchMoveListener=function(e,n){if("ontouchmove"in e){var r,i;t.addListener(e,"touchstart",function(e){var t=e.changedTouches[0];r=t.clientX,i=t.clientY}),t.addListener(e,"touchmove",function(e){var t=1,s=e.changedTouches[0];e.wheelX=-(s.clientX-r)/t,e.wheelY=-(s.clientY-i)/t,r=s.clientX,i=s.clientY,n(e)})}},t.addMouseWheelListener=function(e,n){"onmousewheel"in e?t.addListener(e,"mousewheel",function(e){var t=8;e.wheelDeltaX!==undefined?(e.wheelX=-e.wheelDeltaX/t,e.wheelY=-e.wheelDeltaY/t):(e.wheelX=0,e.wheelY=-e.wheelDelta/t),n(e)}):"onwheel"in e?t.addListener(e,"wheel",function(e){var t=.35;switch(e.deltaMode){case e.DOM_DELTA_PIXEL:e.wheelX=e.deltaX*t||0,e.wheelY=e.deltaY*t||0;break;case e.DOM_DELTA_LINE:case e.DOM_DELTA_PAGE:e.wheelX=(e.deltaX||0)*5,e.wheelY=(e.deltaY||0)*5}n(e)}):t.addListener(e,"DOMMouseScroll",function(e){e.axis&&e.axis==e.HORIZONTAL_AXIS?(e.wheelX=(e.detail||0)*5,e.wheelY=0):(e.wheelX=0,e.wheelY=(e.detail||0)*5),n(e)})},t.addMultiMouseDownListener=function(e,n,r,s){function c(e){t.getButton(e)!==0?o=0:e.detail>1?(o++,o>4&&(o=1)):o=1;if(i.isIE){var c=Math.abs(e.clientX-u)>5||Math.abs(e.clientY-a)>5;if(!f||c)o=1;f&&clearTimeout(f),f=setTimeout(function(){f=null},n[o-1]||600),o==1&&(u=e.clientX,a=e.clientY)}e._clicks=o,r[s]("mousedown",e);if(o>4)o=0;else if(o>1)return r[s](l[o],e)}function h(e){o=2,f&&clearTimeout(f),f=setTimeout(function(){f=null},n[o-1]||600),r[s]("mousedown",e),r[s](l[o],e)}var o=0,u,a,f,l={2:"dblclick",3:"tripleclick",4:"quadclick"};Array.isArray(e)||(e=[e]),e.forEach(function(e){t.addListener(e,"mousedown",c),i.isOldIE&&t.addListener(e,"dblclick",h)})};var u=!i.isMac||!i.isOpera||"KeyboardEvent"in window?function(e){return 0|(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0)}:function(e){return 0|(e.metaKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.ctrlKey?8:0)};t.getModifierString=function(e){return r.KEY_MODS[u(e)]},t.addCommandKeyListener=function(e,n){var r=t.addListener;if(i.isOldGecko||i.isOpera&&!("KeyboardEvent"in window)){var o=null;r(e,"keydown",function(e){o=e.keyCode}),r(e,"keypress",function(e){return a(n,e,o)})}else{var u=null;r(e,"keydown",function(e){s[e.keyCode]=(s[e.keyCode]||0)+1;var t=a(n,e,e.keyCode);return u=e.defaultPrevented,t}),r(e,"keypress",function(e){u&&(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)&&(t.stopEvent(e),u=null)}),r(e,"keyup",function(e){s[e.keyCode]=null}),s||(f(),r(window,"focus",f))}};if(typeof window=="object"&&window.postMessage&&!i.isOldIE){var l=1;t.nextTick=function(e,n){n=n||window;var r="zero-timeout-message-"+l;t.addListener(n,"message",function i(s){s.data==r&&(t.stopPropagation(s),t.removeListener(n,"message",i),e())}),n.postMessage(r,"*")}}t.nextFrame=typeof window=="object"&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame),t.nextFrame?t.nextFrame=t.nextFrame.bind(window):t.nextFrame=function(e){setTimeout(e,17)}}),ace.define("ace/lib/lang",["require","exports","module"],function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){var n="";while(t>0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n<r;n++)e[n]&&typeof e[n]=="object"?t[n]=this.copyObject(e[n]):t[n]=e[n];return t},t.deepCopy=function s(e){if(typeof e!="object"||!e)return e;var t;if(Array.isArray(e)){t=[];for(var n=0;n<e.length;n++)t[n]=s(e[n]);return t}if(Object.prototype.toString.call(e)!=="[object Object]")return e;t={};for(var n in e)t[n]=s(e[n]);return t},t.arrayToMap=function(e){var t={};for(var n=0;n<e.length;n++)t[e[n]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var n in e)t[n]=e[n];return t},t.arrayRemove=function(e,t){for(var n=0;n<=e.length;n++)t===e[n]&&e.splice(n,1)},t.escapeRegExp=function(e){return e.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},t.escapeHTML=function(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<")},t.getMatchOffsets=function(e,t){var n=[];return e.replace(t,function(e){n.push({offset:arguments[arguments.length-2],length:e.length})}),n},t.deferredCall=function(e){var t=null,n=function(){t=null,e()},r=function(e){return r.cancel(),t=setTimeout(n,e||0),r};return r.schedule=r,r.call=function(){return this.cancel(),e(),r},r.cancel=function(){return clearTimeout(t),t=null,r},r.isPending=function(){return t},r},t.delayedCall=function(e,t){var n=null,r=function(){n=null,e()},i=function(e){n==null&&(n=setTimeout(r,e||t))};return i.delay=function(e){n&&clearTimeout(n),n=setTimeout(r,e||t)},i.schedule=i,i.call=function(){this.cancel(),e()},i.cancel=function(){n&&clearTimeout(n),n=null},i.isPending=function(){return n},i}}),ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=e("../lib/dom"),o=e("../lib/lang"),u=i.isChrome<18,a=i.isIE,f=function(e,t){function b(e){if(h)return;h=!0;if(k)t=0,r=e?0:n.value.length-1;else var t=e?2:1,r=2;try{n.setSelectionRange(t,r)}catch(i){}h=!1}function w(){if(h)return;n.value=f,i.isWebKit&&y.schedule()}function R(){clearTimeout(q),q=setTimeout(function(){p&&(n.style.cssText=p,p=""),t.renderer.$keepTextAreaAtCursor==null&&(t.renderer.$keepTextAreaAtCursor=!0,t.renderer.$moveTextAreaToCursor())},i.isOldIE?200:0)}var n=s.createElement("textarea");n.className="ace_text-input",i.isTouchPad&&n.setAttribute("x-palm-disable-auto-cap",!0),n.setAttribute("wrap","off"),n.setAttribute("autocorrect","off"),n.setAttribute("autocapitalize","off"),n.setAttribute("spellcheck",!1),n.style.opacity="0",i.isOldIE&&(n.style.top="-1000px"),e.insertBefore(n,e.firstChild);var f="",l=!1,c=!1,h=!1,p="",d=!0;try{var v=document.activeElement===n}catch(m){}r.addListener(n,"blur",function(e){t.onBlur(e),v=!1}),r.addListener(n,"focus",function(e){v=!0,t.onFocus(e),b()}),this.focus=function(){if(p)return n.focus();var e=n.style.top;n.style.position="fixed",n.style.top="0px",n.focus(),setTimeout(function(){n.style.position="",n.style.top=="0px"&&(n.style.top=e)},0)},this.blur=function(){n.blur()},this.isFocused=function(){return v};var g=o.delayedCall(function(){v&&b(d)}),y=o.delayedCall(function(){h||(n.value=f,v&&b())});i.isWebKit||t.addEventListener("changeSelection",function(){t.selection.isEmpty()!=d&&(d=!d,g.schedule())}),w(),v&&t.onFocus();var E=function(e){return e.selectionStart===0&&e.selectionEnd===e.value.length};!n.setSelectionRange&&n.createTextRange&&(n.setSelectionRange=function(e,t){var n=this.createTextRange();n.collapse(!0),n.moveStart("character",e),n.moveEnd("character",t),n.select()},E=function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.text==e.value});if(i.isOldIE){var S=!1,x=function(e){if(S)return;var t=n.value;if(h||!t||t==f)return;if(e&&t==f[0])return T.schedule();A(t),S=!0,w(),S=!1},T=o.delayedCall(x);r.addListener(n,"propertychange",x);var N={13:1,27:1};r.addListener(n,"keyup",function(e){h&&(!n.value||N[e.keyCode])&&setTimeout(F,0);if((n.value.charCodeAt(0)||0)<129)return T.call();h?j():B()}),r.addListener(n,"keydown",function(e){T.schedule(50)})}var C=function(e){l?l=!1:E(n)?(t.selectAll(),b()):k&&b(t.selection.isEmpty())},k=null;this.setInputHandler=function(e){k=e},this.getInputHandler=function(){return k};var L=!1,A=function(e){k&&(e=k(e),k=null),c?(b(),e&&t.onPaste(e),c=!1):e==f.charAt(0)?L?t.execCommand("del",{source:"ace"}):t.execCommand("backspace",{source:"ace"}):(e.substring(0,2)==f?e=e.substr(2):e.charAt(0)==f.charAt(0)?e=e.substr(1):e.charAt(e.length-1)==f.charAt(0)&&(e=e.slice(0,-1)),e.charAt(e.length-1)==f.charAt(0)&&(e=e.slice(0,-1)),e&&t.onTextInput(e)),L&&(L=!1)},O=function(e){if(h)return;var t=n.value;A(t),w()},M=function(e,t,n){var r=e.clipboardData||window.clipboardData;if(!r||u)return;var i=a||n?"Text":"text/plain";try{return t?r.setData(i,t)!==!1:r.getData(i)}catch(e){if(!n)return M(e,t,!0)}},_=function(e,i){var s=t.getCopyText();if(!s)return r.preventDefault(e);M(e,s)?(i?t.onCut():t.onCopy(),r.preventDefault(e)):(l=!0,n.value=s,n.select(),setTimeout(function(){l=!1,w(),b(),i?t.onCut():t.onCopy()}))},D=function(e){_(e,!0)},P=function(e){_(e,!1)},H=function(e){var s=M(e);typeof s=="string"?(s&&t.onPaste(s,e),i.isIE&&setTimeout(b),r.preventDefault(e)):(n.value="",c=!0)};r.addCommandKeyListener(n,t.onCommandKey.bind(t)),r.addListener(n,"select",C),r.addListener(n,"input",O),r.addListener(n,"cut",D),r.addListener(n,"copy",P),r.addListener(n,"paste",H),(!("oncut"in n)||!("oncopy"in n)||!("onpaste"in n))&&r.addListener(e,"keydown",function(e){if(i.isMac&&!e.metaKey||!e.ctrlKey)return;switch(e.keyCode){case 67:P(e);break;case 86:H(e);break;case 88:D(e)}});var B=function(e){if(h||!t.onCompositionStart||t.$readOnly)return;h={},h.canUndo=t.session.$undoManager,t.onCompositionStart(),setTimeout(j,0),t.on("mousedown",F),h.canUndo&&!t.selection.isEmpty()&&(t.insert(""),t.session.markUndoGroup(),t.selection.clearSelection()),t.session.markUndoGroup()},j=function(){if(!h||!t.onCompositionUpdate||t.$readOnly)return;var e=n.value.replace(/\x01/g,"");if(h.lastValue===e)return;t.onCompositionUpdate(e),h.lastValue&&t.undo(),h.canUndo&&(h.lastValue=e);if(h.lastValue){var r=t.selection.getRange();t.insert(h.lastValue),t.session.markUndoGroup(),h.range=t.selection.getRange(),t.selection.setRange(r),t.selection.clearSelection()}},F=function(e){if(!t.onCompositionEnd||t.$readOnly)return;var r=h;h=!1;var i=setTimeout(function(){i=null;var e=n.value.replace(/\x01/g,"");if(h)return;e==r.lastValue?w():!r.lastValue&&e&&(w(),A(e))});k=function(n){return i&&clearTimeout(i),n=n.replace(/\x01/g,""),n==r.lastValue?"":(r.lastValue&&i&&t.undo(),n)},t.onCompositionEnd(),t.removeListener("mousedown",F),e.type=="compositionend"&&r.range&&t.selection.setRange(r.range)},I=o.delayedCall(j,50);r.addListener(n,"compositionstart",B),i.isGecko?r.addListener(n,"text",function(){I.schedule()}):(r.addListener(n,"keyup",function(){I.schedule()}),r.addListener(n,"keydown",function(){I.schedule()})),r.addListener(n,"compositionend",F),this.getElement=function(){return n},this.setReadOnly=function(e){n.readOnly=e},this.onContextMenu=function(e){L=!0,b(t.selection.isEmpty()),t._emit("nativecontextmenu",{target:t,domEvent:e}),this.moveToMouse(e,!0)},this.moveToMouse=function(e,o){if(!o&&i.isOldIE)return;p||(p=n.style.cssText),n.style.cssText=(o?"z-index:100000;":"")+"height:"+n.style.height+";"+(i.isIE?"opacity:0.1;":"");var u=t.container.getBoundingClientRect(),a=s.computedStyle(t.container),f=u.top+(parseInt(a.borderTopWidth)||0),l=u.left+(parseInt(u.borderLeftWidth)||0),c=u.bottom-f-n.clientHeight-2,h=function(e){n.style.left=e.clientX-l-2+"px",n.style.top=Math.min(e.clientY-f-2,c)+"px"};h(e);if(e.type!="mousedown")return;t.renderer.$keepTextAreaAtCursor&&(t.renderer.$keepTextAreaAtCursor=null),clearTimeout(q),i.isWin&&!i.isOldIE&&r.capture(t.container,h,R)},this.onContextMenuClose=R;var q,U=function(e){t.textInput.onContextMenu(e),R()};r.addListener(n,"mouseup",U),r.addListener(n,"mousedown",function(e){e.preventDefault(),R()}),r.addListener(t.renderer.scroller,"contextmenu",U),r.addListener(n,"contextmenu",U)};t.TextInput=f}),ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";function u(e){e.$clickSelection=null;var t=e.editor;t.setDefaultHandler("mousedown",this.onMouseDown.bind(e)),t.setDefaultHandler("dblclick",this.onDoubleClick.bind(e)),t.setDefaultHandler("tripleclick",this.onTripleClick.bind(e)),t.setDefaultHandler("quadclick",this.onQuadClick.bind(e)),t.setDefaultHandler("mousewheel",this.onMouseWheel.bind(e)),t.setDefaultHandler("touchmove",this.onTouchMove.bind(e));var n=["select","startSelect","selectEnd","selectAllEnd","selectByWordsEnd","selectByLinesEnd","dragWait","dragWaitEnd","focusWait"];n.forEach(function(t){e[t]=this[t]},this),e.selectByLines=this.extendSelectionBy.bind(e,"getLineRange"),e.selectByWords=this.extendSelectionBy.bind(e,"getWordRange")}function a(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}function f(e,t){if(e.start.row==e.end.row)var n=2*t.column-e.start.column-e.end.column;else if(e.start.row==e.end.row-1&&!e.start.column&&!e.end.column)var n=t.column-4;else var n=2*t.row-e.start.row-e.end.row;return n<0?{cursor:e.start,anchor:e.end}:{cursor:e.end,anchor:e.start}}var r=e("../lib/dom"),i=e("../lib/event"),s=e("../lib/useragent"),o=0;(function(){this.onMouseDown=function(e){var t=e.inSelection(),n=e.getDocumentPosition();this.mousedownEvent=e;var r=this.editor,i=e.getButton();if(i!==0){var s=r.getSelectionRange(),o=s.isEmpty();r.$blockScrolling++,(o||i==1)&&r.selection.moveToPosition(n),r.$blockScrolling--,i==2&&r.textInput.onContextMenu(e.domEvent);return}this.mousedownEvent.time=Date.now();if(t&&!r.isFocused()){r.focus();if(this.$focusTimout&&!this.$clickSelection&&!r.inMultiSelectMode){this.setState("focusWait"),this.captureMouse(e);return}}return this.captureMouse(e),this.startSelect(n,e.domEvent._clicks>1),e.preventDefault()},this.startSelect=function(e,t){e=e||this.editor.renderer.screenToTextCoordinates(this.x,this.y);var n=this.editor;n.$blockScrolling++,this.mousedownEvent.getShiftKey()?n.selection.selectToPosition(e):t||n.selection.moveToPosition(e),t||this.select(),n.renderer.scroller.setCapture&&n.renderer.scroller.setCapture(),n.setStyle("ace_selecting"),this.setState("select"),n.$blockScrolling--},this.select=function(){var e,t=this.editor,n=t.renderer.screenToTextCoordinates(this.x,this.y);t.$blockScrolling++;if(this.$clickSelection){var r=this.$clickSelection.comparePoint(n);if(r==-1)e=this.$clickSelection.end;else if(r==1)e=this.$clickSelection.start;else{var i=f(this.$clickSelection,n);n=i.cursor,e=i.anchor}t.selection.setSelectionAnchor(e.row,e.column)}t.selection.selectToPosition(n),t.$blockScrolling--,t.renderer.scrollCursorIntoView()},this.extendSelectionBy=function(e){var t,n=this.editor,r=n.renderer.screenToTextCoordinates(this.x,this.y),i=n.selection[e](r.row,r.column);n.$blockScrolling++;if(this.$clickSelection){var s=this.$clickSelection.comparePoint(i.start),o=this.$clickSelection.comparePoint(i.end);if(s==-1&&o<=0){t=this.$clickSelection.end;if(i.end.row!=r.row||i.end.column!=r.column)r=i.start}else if(o==1&&s>=0){t=this.$clickSelection.start;if(i.start.row!=r.row||i.start.column!=r.column)r=i.end}else if(s==-1&&o==1)r=i.end,t=i.start;else{var u=f(this.$clickSelection,r);r=u.cursor,t=u.anchor}n.selection.setSelectionAnchor(t.row,t.column)}n.selection.selectToPosition(r),n.$blockScrolling--,n.renderer.scrollCursorIntoView()},this.selectEnd=this.selectAllEnd=this.selectByWordsEnd=this.selectByLinesEnd=function(){this.$clickSelection=null,this.editor.unsetStyle("ace_selecting"),this.editor.renderer.scroller.releaseCapture&&this.editor.renderer.scroller.releaseCapture()},this.focusWait=function(){var e=a(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y),t=Date.now();(e>o||t-this.mousedownEvent.time>this.$focusTimout)&&this.startSelect(this.mousedownEvent.getDocumentPosition())},this.onDoubleClick=function(e){var t=e.getDocumentPosition(),n=this.editor,r=n.session,i=r.getBracketRange(t);i?(i.isEmpty()&&(i.start.column--,i.end.column++),this.setState("select")):(i=n.selection.getWordRange(t.row,t.column),this.setState("selectByWords")),this.$clickSelection=i,this.select()},this.onTripleClick=function(e){var t=e.getDocumentPosition(),n=this.editor;this.setState("selectByLines");var r=n.getSelectionRange();r.isMultiLine()&&r.contains(t.row,t.column)?(this.$clickSelection=n.selection.getLineRange(r.start.row),this.$clickSelection.end=n.selection.getLineRange(r.end.row).end):this.$clickSelection=n.selection.getLineRange(t.row),this.select()},this.onQuadClick=function(e){var t=this.editor;t.selectAll(),this.$clickSelection=t.getSelectionRange(),this.setState("selectAll")},this.onMouseWheel=function(e){if(e.getAccelKey())return;e.getShiftKey()&&e.wheelY&&!e.wheelX&&(e.wheelX=e.wheelY,e.wheelY=0);var t=e.domEvent.timeStamp,n=t-(this.$lastScrollTime||0),r=this.editor,i=r.renderer.isScrollableBy(e.wheelX*e.speed,e.wheelY*e.speed);if(i||n<200)return this.$lastScrollTime=t,r.renderer.scrollBy(e.wheelX*e.speed,e.wheelY*e.speed),e.stop()},this.onTouchMove=function(e){var t=e.domEvent.timeStamp,n=t-(this.$lastScrollTime||0),r=this.editor,i=r.renderer.isScrollableBy(e.wheelX*e.speed,e.wheelY*e.speed);if(i||n<200)return this.$lastScrollTime=t,r.renderer.scrollBy(e.wheelX*e.speed,e.wheelY*e.speed),e.stop()}}).call(u.prototype),t.DefaultHandlers=u}),ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"],function(e,t,n){"use strict";function s(e){this.isOpen=!1,this.$element=null,this.$parentNode=e}var r=e("./lib/oop"),i=e("./lib/dom");(function(){this.$init=function(){return this.$element=i.createElement("div"),this.$element.className="ace_tooltip",this.$element.style.display="none",this.$parentNode.appendChild(this.$element),this.$element},this.getElement=function(){return this.$element||this.$init()},this.setText=function(e){i.setInnerText(this.getElement(),e)},this.setHtml=function(e){this.getElement().innerHTML=e},this.setPosition=function(e,t){this.getElement().style.left=e+"px",this.getElement().style.top=t+"px"},this.setClassName=function(e){i.addCssClass(this.getElement(),e)},this.show=function(e,t,n){e!=null&&this.setText(e),t!=null&&n!=null&&this.setPosition(t,n),this.isOpen||(this.getElement().style.display="block",this.isOpen=!0)},this.hide=function(){this.isOpen&&(this.getElement().style.display="none",this.isOpen=!1)},this.getHeight=function(){return this.getElement().offsetHeight},this.getWidth=function(){return this.getElement().offsetWidth}}).call(s.prototype),t.Tooltip=s}),ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"],function(e,t,n){"use strict";function u(e){function l(){var r=u.getDocumentPosition().row,s=n.$annotations[r];if(!s)return c();var o=t.session.getLength();if(r==o){var a=t.renderer.pixelToScreenCoordinates(0,u.y).row,l=u.$pos;if(a>t.session.documentToScreenRow(l.row,l.column))return c()}if(f==s)return;f=s.text.join("<br/>"),i.setHtml(f),i.show(),t._signal("showGutterTooltip",i),t.on("mousewheel",c);if(e.$tooltipFollowsMouse)h(u);else{var p=u.domEvent.target,d=p.getBoundingClientRect(),v=i.getElement().style;v.left=d.right+"px",v.top=d.bottom+"px"}}function c(){o&&(o=clearTimeout(o)),f&&(i.hide(),f=null,t._signal("hideGutterTooltip",i),t.removeEventListener("mousewheel",c))}function h(e){i.setPosition(e.x,e.y)}var t=e.editor,n=t.renderer.$gutterLayer,i=new a(t.container);e.editor.setDefaultHandler("guttermousedown",function(r){if(!t.isFocused()||r.getButton()!=0)return;var i=n.getRegion(r);if(i=="foldWidgets")return;var s=r.getDocumentPosition().row,o=t.session.selection;if(r.getShiftKey())o.selectTo(s,0);else{if(r.domEvent.detail==2)return t.selectAll(),r.preventDefault();e.$clickSelection=t.selection.getLineRange(s)}return e.setState("selectByLines"),e.captureMouse(r),r.preventDefault()});var o,u,f;e.editor.setDefaultHandler("guttermousemove",function(t){var n=t.domEvent.target||t.domEvent.srcElement;if(r.hasCssClass(n,"ace_fold-widget"))return c();f&&e.$tooltipFollowsMouse&&h(t),u=t;if(o)return;o=setTimeout(function(){o=null,u&&!e.isMousePressed?l():c()},50)}),s.addListener(t.renderer.$gutter,"mouseout",function(e){u=null;if(!f||o)return;o=setTimeout(function(){o=null,c()},50)}),t.on("changeSession",c)}function a(e){o.call(this,e)}var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/event"),o=e("../tooltip").Tooltip;i.inherits(a,o),function(){this.setPosition=function(e,t){var n=window.innerWidth||document.documentElement.clientWidth,r=window.innerHeight||document.documentElement.clientHeight,i=this.getWidth(),s=this.getHeight();e+=15,t+=15,e+i>n&&(e-=e+i-n),t+s>r&&(t-=20+s),o.prototype.setPosition.call(this,e,t)}}.call(a.prototype),t.GutterHandler=u}),ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=t.MouseEvent=function(e,t){this.domEvent=e,this.editor=t,this.x=this.clientX=e.clientX,this.y=this.clientY=e.clientY,this.$pos=null,this.$inSelection=null,this.propagationStopped=!1,this.defaultPrevented=!1};(function(){this.stopPropagation=function(){r.stopPropagation(this.domEvent),this.propagationStopped=!0},this.preventDefault=function(){r.preventDefault(this.domEvent),this.defaultPrevented=!0},this.stop=function(){this.stopPropagation(),this.preventDefault()},this.getDocumentPosition=function(){return this.$pos?this.$pos:(this.$pos=this.editor.renderer.screenToTextCoordinates(this.clientX,this.clientY),this.$pos)},this.inSelection=function(){if(this.$inSelection!==null)return this.$inSelection;var e=this.editor,t=e.getSelectionRange();if(t.isEmpty())this.$inSelection=!1;else{var n=this.getDocumentPosition();this.$inSelection=t.contains(n.row,n.column)}return this.$inSelection},this.getButton=function(){return r.getButton(this.domEvent)},this.getShiftKey=function(){return this.domEvent.shiftKey},this.getAccelKey=i.isMac?function(){return this.domEvent.metaKey}:function(){return this.domEvent.ctrlKey}}).call(s.prototype)}),ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";function f(e){function T(e,n){var r=Date.now(),i=!n||e.row!=n.row,s=!n||e.column!=n.column;if(!S||i||s)t.$blockScrolling+=1,t.moveCursorToPosition(e),t.$blockScrolling-=1,S=r,x={x:p,y:d};else{var o=l(x.x,x.y,p,d);o>a?S=null:r-S>=u&&(t.renderer.scrollCursorIntoView(),S=null)}}function N(e,n){var r=Date.now(),i=t.renderer.layerConfig.lineHeight,s=t.renderer.layerConfig.characterWidth,u=t.renderer.scroller.getBoundingClientRect(),a={x:{left:p-u.left,right:u.right-p},y:{top:d-u.top,bottom:u.bottom-d}},f=Math.min(a.x.left,a.x.right),l=Math.min(a.y.top,a.y.bottom),c={row:e.row,column:e.column};f/s<=2&&(c.column+=a.x.left<a.x.right?-3:2),l/i<=1&&(c.row+=a.y.top<a.y.bottom?-1:1);var h=e.row!=c.row,v=e.column!=c.column,m=!n||e.row!=n.row;h||v&&!m?E?r-E>=o&&t.renderer.scrollCursorIntoView(c):E=r:E=null}function C(){var e=g;g=t.renderer.screenToTextCoordinates(p,d),T(g,e),N(g,e)}function k(){m=t.selection.toOrientedRange(),h=t.session.addMarker(m,"ace_selection",t.getSelectionStyle()),t.clearSelection(),t.isFocused()&&t.renderer.$cursorLayer.setBlinking(!1),clearInterval(v),C(),v=setInterval(C,20),y=0,i.addListener(document,"mousemove",O)}function L(){clearInterval(v),t.session.removeMarker(h),h=null,t.$blockScrolling+=1,t.selection.fromOrientedRange(m),t.$blockScrolling-=1,t.isFocused()&&!w&&t.renderer.$cursorLayer.setBlinking(!t.getReadOnly()),m=null,g=null,y=0,E=null,S=null,i.removeListener(document,"mousemove",O)}function O(){A==null&&(A=setTimeout(function(){A!=null&&h&&L()},20))}function M(e){var t=e.types;return!t||Array.prototype.some.call(t,function(e){return e=="text/plain"||e=="Text"})}function _(e){var t=["copy","copymove","all","uninitialized"],n=["move","copymove","linkmove","all","uninitialized"],r=s.isMac?e.altKey:e.ctrlKey,i="uninitialized";try{i=e.dataTransfer.effectAllowed.toLowerCase()}catch(e){}var o="none";return r&&t.indexOf(i)>=0?o="copy":n.indexOf(i)>=0?o="move":t.indexOf(i)>=0&&(o="copy"),o}var t=e.editor,n=r.createElement("img");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",s.isOpera&&(n.style.cssText="width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;");var f=["dragWait","dragWaitEnd","startDrag","dragReadyEnd","onMouseDrag"];f.forEach(function(t){e[t]=this[t]},this),t.addEventListener("mousedown",this.onMouseDown.bind(e));var c=t.container,h,p,d,v,m,g,y=0,b,w,E,S,x;this.onDragStart=function(e){if(this.cancelDrag||!c.draggable){var r=this;return setTimeout(function(){r.startSelect(),r.captureMouse(e)},0),e.preventDefault()}m=t.getSelectionRange();var i=e.dataTransfer;i.effectAllowed=t.getReadOnly()?"copy":"copyMove",s.isOpera&&(t.container.appendChild(n),n.scrollTop=0),i.setDragImage&&i.setDragImage(n,0,0),s.isOpera&&t.container.removeChild(n),i.clearData(),i.setData("Text",t.session.getTextRange()),w=!0,this.setState("drag")},this.onDragEnd=function(e){c.draggable=!1,w=!1,this.setState(null);if(!t.getReadOnly()){var n=e.dataTransfer.dropEffect;!b&&n=="move"&&t.session.remove(t.getSelectionRange()),t.renderer.$cursorLayer.setBlinking(!0)}this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle("")},this.onDragEnter=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||k(),y++,e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragOver=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||(k(),y++),A!==null&&(A=null),e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragLeave=function(e){y--;if(y<=0&&h)return L(),b=null,i.preventDefault(e)},this.onDrop=function(e){if(!g)return;var n=e.dataTransfer;if(w)switch(b){case"move":m.contains(g.row,g.column)?m={start:g,end:g}:m=t.moveText(m,g);break;case"copy":m=t.moveText(m,g,!0)}else{var r=n.getData("Text");m={start:g,end:t.session.insert(g,r)},t.focus(),b=null}return L(),i.preventDefault(e)},i.addListener(c,"dragstart",this.onDragStart.bind(e)),i.addListener(c,"dragend",this.onDragEnd.bind(e)),i.addListener(c,"dragenter",this.onDragEnter.bind(e)),i.addListener(c,"dragover",this.onDragOver.bind(e)),i.addListener(c,"dragleave",this.onDragLeave.bind(e)),i.addListener(c,"drop",this.onDrop.bind(e));var A=null}function l(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}var r=e("../lib/dom"),i=e("../lib/event"),s=e("../lib/useragent"),o=200,u=200,a=5;(function(){this.dragWait=function(){var e=Date.now()-this.mousedownEvent.time;e>this.editor.getDragDelay()&&this.startDrag()},this.dragWaitEnd=function(){var e=this.editor.container;e.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()),this.selectEnd()},this.dragReadyEnd=function(e){this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly()),this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle(""),this.dragWaitEnd()},this.startDrag=function(){this.cancelDrag=!1;var e=this.editor,t=e.container;t.draggable=!0,e.renderer.$cursorLayer.setBlinking(!1),e.setStyle("ace_dragging");var n=s.isWin?"default":"move";e.renderer.setCursorStyle(n),this.setState("dragReady")},this.onMouseDrag=function(e){var t=this.editor.container;if(s.isIE&&this.state=="dragReady"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>3&&t.dragDrop()}if(this.state==="dragWait"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>0&&(t.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()))}},this.onMouseDown=function(e){if(!this.$dragEnabled)return;this.mousedownEvent=e;var t=this.editor,n=e.inSelection(),r=e.getButton(),i=e.domEvent.detail||1;if(i===1&&r===0&&n){if(e.editor.inMultiSelectMode&&(e.getAccelKey()||e.getShiftKey()))return;this.mousedownEvent.time=Date.now();var o=e.domEvent.target||e.domEvent.srcElement;"unselectable"in o&&(o.unselectable="on");if(t.getDragDelay()){if(s.isWebKit){this.cancelDrag=!0;var u=t.container;u.draggable=!0}this.setState("dragWait")}else this.startDrag();this.captureMouse(e,this.onMouseDrag.bind(this)),e.defaultPrevented=!0}}}).call(f.prototype),t.DragdropHandler=f}),ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("./dom");t.get=function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.onreadystatechange=function(){n.readyState===4&&t(n.responseText)},n.send(null)},t.loadScript=function(e,t){var n=r.getDocumentHead(),i=document.createElement("script");i.src=e,n.appendChild(i),i.onload=i.onreadystatechange=function(e,n){if(n||!i.readyState||i.readyState=="loaded"||i.readyState=="complete")i=i.onload=i.onreadystatechange=null,n||t()}},t.qualifyURL=function(e){var t=document.createElement("a");return t.href=e,t.href}}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o<n.length;o++){n[o](t,this);if(t.propagationStopped)break}if(r&&!t.defaultPrevented)return r(t,this)},r._signal=function(e,t){var n=(this._eventRegistry||{})[e];if(!n)return;n=n.slice();for(var r=0;r<n.length;r++)n[r](t,this)},r.once=function(e,t){var n=this;t&&this.addEventListener(e,function r(){n.removeEventListener(e,r),t.apply(null,arguments)})},r.setDefaultHandler=function(e,t){var n=this._defaultHandlers;n||(n=this._defaultHandlers={_disabled_:{}});if(n[e]){var r=n[e],i=n._disabled_[e];i||(n._disabled_[e]=i=[]),i.push(r);var s=i.indexOf(t);s!=-1&&i.splice(s,1)}n[e]=t},r.removeDefaultHandler=function(e,t){var n=this._defaultHandlers;if(!n)return;var r=n._disabled_[e];if(n[e]==t){var i=n[e];r&&this.setDefaultHandler(e,r.pop())}else if(r){var s=r.indexOf(t);s!=-1&&r.splice(s,1)}},r.on=r.addEventListener=function(e,t,n){this._eventRegistry=this._eventRegistry||{};var r=this._eventRegistry[e];return r||(r=this._eventRegistry[e]=[]),r.indexOf(t)==-1&&r[n?"unshift":"push"](t),t},r.off=r.removeListener=r.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];if(!n)return;var r=n.indexOf(t);r!==-1&&n.splice(r,1)},r.removeAllListeners=function(e){this._eventRegistry&&(this._eventRegistry[e]=[])},t.EventEmitter=r}),ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"no use strict";function o(e){typeof console!="undefined"&&console.warn&&console.warn.apply(console,arguments)}function u(e,t){var n=new Error(e);n.data=t,typeof console=="object"&&console.error&&console.error(n),setTimeout(function(){throw n})}var r=e("./oop"),i=e("./event_emitter").EventEmitter,s={setOptions:function(e){Object.keys(e).forEach(function(t){this.setOption(t,e[t])},this)},getOptions:function(e){var t={};return e?Array.isArray(e)||(t=e,e=Object.keys(t)):e=Object.keys(this.$options),e.forEach(function(e){t[e]=this.getOption(e)},this),t},setOption:function(e,t){if(this["$"+e]===t)return;var n=this.$options[e];if(!n)return o('misspelled option "'+e+'"');if(n.forwardTo)return this[n.forwardTo]&&this[n.forwardTo].setOption(e,t);n.handlesSet||(this["$"+e]=t),n&&n.set&&n.set.call(this,t)},getOption:function(e){var t=this.$options[e];return t?t.forwardTo?this[t.forwardTo]&&this[t.forwardTo].getOption(e):t&&t.get?t.get.call(this):this["$"+e]:o('misspelled option "'+e+'"')}},a=function(){this.$defaultOptions={}};(function(){r.implement(this,i),this.defineOptions=function(e,t,n){return e.$options||(this.$defaultOptions[t]=e.$options={}),Object.keys(n).forEach(function(t){var r=n[t];typeof r=="string"&&(r={forwardTo:r}),r.name||(r.name=t),e.$options[r.name]=r,"initialValue"in r&&(e["$"+r.name]=r.initialValue)}),r.implement(e,s),this},this.resetOptions=function(e){Object.keys(e.$options).forEach(function(t){var n=e.$options[t];"value"in n&&e.setOption(t,n.value)})},this.setDefaultValue=function(e,t,n){var r=this.$defaultOptions[e]||(this.$defaultOptions[e]={});r[t]&&(r.forwardTo?this.setDefaultValue(r.forwardTo,t,n):r[t].value=n)},this.setDefaultValues=function(e,t){Object.keys(t).forEach(function(n){this.setDefaultValue(e,n,t[n])},this)},this.warn=o,this.reportError=u}).call(a.prototype),t.AppConfig=a}),ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"],function(e,t,n){"no use strict";function f(r){if(!u||!u.document)return;a.packaged=r||e.packaged||n.packaged||u.define&&__webpack_require__(31).packaged;var i={},s="",o=document.currentScript||document._currentScript,f=o&&o.ownerDocument||document,c=f.getElementsByTagName("script");for(var h=0;h<c.length;h++){var p=c[h],d=p.src||p.getAttribute("src");if(!d)continue;var v=p.attributes;for(var m=0,g=v.length;m<g;m++){var y=v[m];y.name.indexOf("data-ace-")===0&&(i[l(y.name.replace(/^data-ace-/,""))]=y.value)}var b=d.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);b&&(s=b[1])}s&&(i.base=i.base||s,i.packaged=!0),i.basePath=i.base,i.workerPath=i.workerPath||i.base,i.modePath=i.modePath||i.base,i.themePath=i.themePath||i.base,delete i.base;for(var w in i)typeof i[w]!="undefined"&&t.set(w,i[w])}function l(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})}var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./lib/net"),o=e("./lib/app_config").AppConfig;n.exports=t=new o;var u=function(){return this||typeof window!="undefined"&&window}(),a={packaged:!1,workerPath:null,modePath:null,themePath:null,basePath:"",suffix:".js",$moduleUrls:{}};t.get=function(e){if(!a.hasOwnProperty(e))throw new Error("Unknown config key: "+e);return a[e]},t.set=function(e,t){if(!a.hasOwnProperty(e))throw new Error("Unknown config key: "+e);a[e]=t},t.all=function(){return r.copyObject(a)},t.moduleUrl=function(e,t){if(a.$moduleUrls[e])return a.$moduleUrls[e];var n=e.split("/");t=t||n[n.length-2]||"";var r=t=="snippets"?"/":"-",i=n[n.length-1];if(t=="worker"&&r=="-"){var s=new RegExp("^"+t+"[\\-_]|[\\-_]"+t+"$","g");i=i.replace(s,"")}(!i||i==t)&&n.length>1&&(i=n[n.length-2]);var o=a[t+"Path"];return o==null?o=a.basePath:r=="/"&&(t=r=""),o&&o.slice(-1)!="/"&&(o+="/"),o+t+r+i+this.get("suffix")},t.setModuleUrl=function(e,t){return a.$moduleUrls[e]=t},t.$loading={},t.loadModule=function(n,r){var i,o;Array.isArray(n)&&(o=n[0],n=n[1]);try{i=e(n)}catch(u){}if(i&&!t.$loading[n])return r&&r(i);t.$loading[n]||(t.$loading[n]=[]),t.$loading[n].push(r);if(t.$loading[n].length>1)return;var a=function(){e([n],function(e){t._emit("load.module",{name:n,module:e});var r=t.$loading[n];t.$loading[n]=null,r.forEach(function(t){t&&t(e)})})};if(!t.get("packaged"))return a();s.loadScript(t.moduleUrl(n,o),a)},t.init=f}),ace.define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event","ace/mouse/dragdrop_handler","ace/config"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=e("./default_handlers").DefaultHandlers,o=e("./default_gutter_handler").GutterHandler,u=e("./mouse_event").MouseEvent,a=e("./dragdrop_handler").DragdropHandler,f=e("../config"),l=function(e){var t=this;this.editor=e,new s(this),new o(this),new a(this);var n=function(t){var n=!document.hasFocus||!document.hasFocus()||!e.isFocused()&&document.activeElement==(e.textInput&&e.textInput.getElement());n&&window.focus(),e.focus()},u=e.renderer.getMouseEventTarget();r.addListener(u,"click",this.onMouseEvent.bind(this,"click")),r.addListener(u,"mousemove",this.onMouseMove.bind(this,"mousemove")),r.addMultiMouseDownListener([u,e.renderer.scrollBarV&&e.renderer.scrollBarV.inner,e.renderer.scrollBarH&&e.renderer.scrollBarH.inner,e.textInput&&e.textInput.getElement()].filter(Boolean),[400,300,250],this,"onMouseEvent"),r.addMouseWheelListener(e.container,this.onMouseWheel.bind(this,"mousewheel")),r.addTouchMoveListener(e.container,this.onTouchMove.bind(this,"touchmove"));var f=e.renderer.$gutter;r.addListener(f,"mousedown",this.onMouseEvent.bind(this,"guttermousedown")),r.addListener(f,"click",this.onMouseEvent.bind(this,"gutterclick")),r.addListener(f,"dblclick",this.onMouseEvent.bind(this,"gutterdblclick")),r.addListener(f,"mousemove",this.onMouseEvent.bind(this,"guttermousemove")),r.addListener(u,"mousedown",n),r.addListener(f,"mousedown",n),i.isIE&&e.renderer.scrollBarV&&(r.addListener(e.renderer.scrollBarV.element,"mousedown",n),r.addListener(e.renderer.scrollBarH.element,"mousedown",n)),e.on("mousemove",function(n){if(t.state||t.$dragDelay||!t.$dragEnabled)return;var r=e.renderer.screenToTextCoordinates(n.x,n.y),i=e.session.selection.getRange(),s=e.renderer;!i.isEmpty()&&i.insideStart(r.row,r.column)?s.setCursorStyle("default"):s.setCursorStyle("")})};(function(){this.onMouseEvent=function(e,t){this.editor._emit(e,new u(t,this.editor))},this.onMouseMove=function(e,t){var n=this.editor._eventRegistry&&this.editor._eventRegistry.mousemove;if(!n||!n.length)return;this.editor._emit(e,new u(t,this.editor))},this.onMouseWheel=function(e,t){var n=new u(t,this.editor);n.speed=this.$scrollSpeed*2,n.wheelX=t.wheelX,n.wheelY=t.wheelY,this.editor._emit(e,n)},this.onTouchMove=function(e,t){var n=new u(t,this.editor);n.speed=1,n.wheelX=t.wheelX,n.wheelY=t.wheelY,this.editor._emit(e,n)},this.setState=function(e){this.state=e},this.captureMouse=function(e,t){this.x=e.x,this.y=e.y,this.isMousePressed=!0;var n=this.editor.renderer;n.$keepTextAreaAtCursor&&(n.$keepTextAreaAtCursor=null);var s=this,o=function(e){if(!e)return;if(i.isWebKit&&!e.which&&s.releaseMouse)return s.releaseMouse();s.x=e.clientX,s.y=e.clientY,t&&t(e),s.mouseEvent=new u(e,s.editor),s.$mouseMoved=!0},a=function(e){clearInterval(l),f(),s[s.state+"End"]&&s[s.state+"End"](e),s.state="",n.$keepTextAreaAtCursor==null&&(n.$keepTextAreaAtCursor=!0,n.$moveTextAreaToCursor()),s.isMousePressed=!1,s.$onCaptureMouseMove=s.releaseMouse=null,e&&s.onMouseEvent("mouseup",e)},f=function(){s[s.state]&&s[s.state](),s.$mouseMoved=!1};if(i.isOldIE&&e.domEvent.type=="dblclick")return setTimeout(function(){a(e)});s.$onCaptureMouseMove=o,s.releaseMouse=r.capture(this.editor.container,o,a);var l=setInterval(f,20)},this.releaseMouse=null,this.cancelContextMenu=function(){var e=function(t){if(t&&t.domEvent&&t.domEvent.type!="contextmenu")return;this.editor.off("nativecontextmenu",e),t&&t.domEvent&&r.stopEvent(t.domEvent)}.bind(this);setTimeout(e,10),this.editor.on("nativecontextmenu",e)}}).call(l.prototype),f.defineOptions(l.prototype,"mouseHandler",{scrollSpeed:{initialValue:2},dragDelay:{initialValue:i.isMac?150:0},dragEnabled:{initialValue:!0},focusTimout:{initialValue:0},tooltipFollowsMouse:{initialValue:!0}}),t.MouseHandler=l}),ace.define("ace/mouse/fold_handler",["require","exports","module"],function(e,t,n){"use strict";function r(e){e.on("click",function(t){var n=t.getDocumentPosition(),r=e.session,i=r.getFoldAt(n.row,n.column,1);i&&(t.getAccelKey()?r.removeFold(i):r.expandFold(i),t.stop())}),e.on("gutterclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session;i.foldWidgets&&i.foldWidgets[r]&&e.session.onFoldWidgetClick(r,t),e.isFocused()||e.focus(),t.stop()}}),e.on("gutterdblclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session,s=i.getParentFoldRangeData(r,!0),o=s.range||s.firstRange;if(o){r=o.start.row;var u=i.getFoldAt(r,i.getLine(r).length,1);u?i.removeFold(u):(i.addFold("...",o),e.renderer.scrollCursorIntoView({row:o.start.row,column:0}))}t.stop()}})}t.FoldHandler=r}),ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"],function(e,t,n){"use strict";var r=e("../lib/keys"),i=e("../lib/event"),s=function(e){this.$editor=e,this.$data={editor:e},this.$handlers=[],this.setDefaultHandler(e.commands)};(function(){this.setDefaultHandler=function(e){this.removeKeyboardHandler(this.$defaultHandler),this.$defaultHandler=e,this.addKeyboardHandler(e,0)},this.setKeyboardHandler=function(e){var t=this.$handlers;if(t[t.length-1]==e)return;while(t[t.length-1]&&t[t.length-1]!=this.$defaultHandler)this.removeKeyboardHandler(t[t.length-1]);this.addKeyboardHandler(e,1)},this.addKeyboardHandler=function(e,t){if(!e)return;typeof e=="function"&&!e.handleKeyboard&&(e.handleKeyboard=e);var n=this.$handlers.indexOf(e);n!=-1&&this.$handlers.splice(n,1),t==undefined?this.$handlers.push(e):this.$handlers.splice(t,0,e),n==-1&&e.attach&&e.attach(this.$editor)},this.removeKeyboardHandler=function(e){var t=this.$handlers.indexOf(e);return t==-1?!1:(this.$handlers.splice(t,1),e.detach&&e.detach(this.$editor),!0)},this.getKeyboardHandler=function(){return this.$handlers[this.$handlers.length-1]},this.getStatusText=function(){var e=this.$data,t=e.editor;return this.$handlers.map(function(n){return n.getStatusText&&n.getStatusText(t,e)||""}).filter(Boolean).join(" ")},this.$callKeyboardHandlers=function(e,t,n,r){var s,o=!1,u=this.$editor.commands;for(var a=this.$handlers.length;a--;){s=this.$handlers[a].handleKeyboard(this.$data,e,t,n,r);if(!s||!s.command)continue;s.command=="null"?o=!0:o=u.exec(s.command,this.$editor,s.args,r),o&&r&&e!=-1&&s.passEvent!=1&&s.command.passEvent!=1&&i.stopEvent(r);if(o)break}return!o&&e==-1&&(s={command:"insertstring"},o=u.exec("insertstring",this.$editor,t)),o&&this.$editor._signal&&this.$editor._signal("keyboardActivity",s),o},this.onCommandKey=function(e,t,n){var i=r.keyCodeToString(n);this.$callKeyboardHandlers(t,i,n,e)},this.onTextInput=function(e){this.$callKeyboardHandlers(-1,e)}}).call(s.prototype),t.KeyBinding=s}),ace.define("ace/range",["require","exports","module"],function(e,t,n){"use strict";var r=function(e,t){return e.row-t.row||e.column-t.column},i=function(e,t,n,r){this.start={row:e,column:t},this.end={row:n,column:r}};(function(){this.isEqual=function(e){return this.start.row===e.start.row&&this.end.row===e.end.row&&this.start.column===e.start.column&&this.end.column===e.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(e,t){return this.compare(e,t)==0},this.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},this.comparePoint=function(e){return this.compare(e.row,e.column)},this.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},this.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},this.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},this.isStart=function(e,t){return this.start.row==e&&this.start.column==t},this.setStart=function(e,t){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},this.setEnd=function(e,t){typeof e=="object"?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},this.inside=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},this.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},this.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},this.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?t<this.start.column?-1:t>this.end.column?1:0:e<this.start.row?-1:e>this.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0},this.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},this.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.clipRows=function(e,t){if(this.end.row>t)var n={row:t+1,column:0};else if(this.end.row<e)var n={row:e,column:0};if(this.start.row>t)var r={row:t+1,column:0};else if(this.start.row<e)var r={row:e,column:0};return i.fromPoints(r||this.start,n||this.end)},this.extend=function(e,t){var n=this.compare(e,t);if(n==0)return this;if(n==-1)var r={row:e,column:t};else var s={row:e,column:t};return i.fromPoints(r||this.start,s||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return i.fromPoints(this.start,this.end)},this.collapseRows=function(){return this.end.column==0?new i(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new i(this.start.row,0,this.end.row,0)},this.toScreenRange=function(e){var t=e.documentToScreenPosition(this.start),n=e.documentToScreenPosition(this.end);return new i(t.row,t.column,n.row,n.column)},this.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t}}).call(i.prototype),i.fromPoints=function(e,t){return new i(e.row,e.column,t.row,t.column)},i.comparePoints=r,i.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=i}),ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/lang"),s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=function(e){this.session=e,this.doc=e.getDocument(),this.clearSelection(),this.lead=this.selectionLead=this.doc.createAnchor(0,0),this.anchor=this.selectionAnchor=this.doc.createAnchor(0,0);var t=this;this.lead.on("change",function(e){t._emit("changeCursor"),t.$isEmpty||t._emit("changeSelection"),!t.$keepDesiredColumnOnChange&&e.old.column!=e.value.column&&(t.$desiredColumn=null)}),this.selectionAnchor.on("change",function(){t.$isEmpty||t._emit("changeSelection")})};(function(){r.implement(this,s),this.isEmpty=function(){return this.$isEmpty||this.anchor.row==this.lead.row&&this.anchor.column==this.lead.column},this.isMultiLine=function(){return this.isEmpty()?!1:this.getRange().isMultiLine()},this.getCursor=function(){return this.lead.getPosition()},this.setSelectionAnchor=function(e,t){this.anchor.setPosition(e,t),this.$isEmpty&&(this.$isEmpty=!1,this._emit("changeSelection"))},this.getSelectionAnchor=function(){return this.$isEmpty?this.getSelectionLead():this.anchor.getPosition()},this.getSelectionLead=function(){return this.lead.getPosition()},this.shiftSelection=function(e){if(this.$isEmpty){this.moveCursorTo(this.lead.row,this.lead.column+e);return}var t=this.getSelectionAnchor(),n=this.getSelectionLead(),r=this.isBackwards();(!r||t.column!==0)&&this.setSelectionAnchor(t.row,t.column+e),(r||n.column!==0)&&this.$moveSelection(function(){this.moveCursorTo(n.row,n.column+e)})},this.isBackwards=function(){var e=this.anchor,t=this.lead;return e.row>t.row||e.row==t.row&&e.column>t.column},this.getRange=function(){var e=this.anchor,t=this.lead;return this.isEmpty()?o.fromPoints(t,t):this.isBackwards()?o.fromPoints(t,e):o.fromPoints(e,t)},this.clearSelection=function(){this.$isEmpty||(this.$isEmpty=!0,this._emit("changeSelection"))},this.selectAll=function(){var e=this.doc.getLength()-1;this.setSelectionAnchor(0,0),this.moveCursorTo(e,this.doc.getLine(e).length)},this.setRange=this.setSelectionRange=function(e,t){t?(this.setSelectionAnchor(e.end.row,e.end.column),this.selectTo(e.start.row,e.start.column)):(this.setSelectionAnchor(e.start.row,e.start.column),this.selectTo(e.end.row,e.end.column)),this.getRange().isEmpty()&&(this.$isEmpty=!0),this.$desiredColumn=null},this.$moveSelection=function(e){var t=this.lead;this.$isEmpty&&this.setSelectionAnchor(t.row,t.column),e.call(this)},this.selectTo=function(e,t){this.$moveSelection(function(){this.moveCursorTo(e,t)})},this.selectToPosition=function(e){this.$moveSelection(function(){this.moveCursorToPosition(e)})},this.moveTo=function(e,t){this.clearSelection(),this.moveCursorTo(e,t)},this.moveToPosition=function(e){this.clearSelection(),this.moveCursorToPosition(e)},this.selectUp=function(){this.$moveSelection(this.moveCursorUp)},this.selectDown=function(){this.$moveSelection(this.moveCursorDown)},this.selectRight=function(){this.$moveSelection(this.moveCursorRight)},this.selectLeft=function(){this.$moveSelection(this.moveCursorLeft)},this.selectLineStart=function(){this.$moveSelection(this.moveCursorLineStart)},this.selectLineEnd=function(){this.$moveSelection(this.moveCursorLineEnd)},this.selectFileEnd=function(){this.$moveSelection(this.moveCursorFileEnd)},this.selectFileStart=function(){this.$moveSelection(this.moveCursorFileStart)},this.selectWordRight=function(){this.$moveSelection(this.moveCursorWordRight)},this.selectWordLeft=function(){this.$moveSelection(this.moveCursorWordLeft)},this.getWordRange=function(e,t){if(typeof t=="undefined"){var n=e||this.lead;e=n.row,t=n.column}return this.session.getWordRange(e,t)},this.selectWord=function(){this.setSelectionRange(this.getWordRange())},this.selectAWord=function(){var e=this.getCursor(),t=this.session.getAWordRange(e.row,e.column);this.setSelectionRange(t)},this.getLineRange=function(e,t){var n=typeof e=="number"?e:this.lead.row,r,i=this.session.getFoldLine(n);return i?(n=i.start.row,r=i.end.row):r=n,t===!0?new o(n,0,r,this.session.getLine(r).length):new o(n,0,r+1,0)},this.selectLine=function(){this.setSelectionRange(this.getLineRange())},this.moveCursorUp=function(){this.moveCursorBy(-1,0)},this.moveCursorDown=function(){this.moveCursorBy(1,0)},this.moveCursorLeft=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,-1))this.moveCursorTo(t.start.row,t.start.column);else if(e.column===0)e.row>0&&this.moveCursorTo(e.row-1,this.doc.getLine(e.row-1).length);else{var n=this.session.getTabSize();this.session.isTabStop(e)&&this.doc.getLine(e.row).slice(e.column-n,e.column).split(" ").length-1==n?this.moveCursorBy(0,-n):this.moveCursorBy(0,-1)}},this.moveCursorRight=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,1))this.moveCursorTo(t.end.row,t.end.column);else if(this.lead.column==this.doc.getLine(this.lead.row).length)this.lead.row<this.doc.getLength()-1&&this.moveCursorTo(this.lead.row+1,0);else{var n=this.session.getTabSize(),e=this.lead;this.session.isTabStop(e)&&this.doc.getLine(e.row).slice(e.column,e.column+n).split(" ").length-1==n?this.moveCursorBy(0,n):this.moveCursorBy(0,1)}},this.moveCursorLineStart=function(){var e=this.lead.row,t=this.lead.column,n=this.session.documentToScreenRow(e,t),r=this.session.screenToDocumentPosition(n,0),i=this.session.getDisplayLine(e,null,r.row,r.column),s=i.match(/^\s*/);s[0].length!=t&&!this.session.$useEmacsStyleLineStart&&(r.column+=s[0].length),this.moveCursorToPosition(r)},this.moveCursorLineEnd=function(){var e=this.lead,t=this.session.getDocumentLastRowColumnPosition(e.row,e.column);if(this.lead.column==t.column){var n=this.session.getLine(t.row);if(t.column==n.length){var r=n.search(/\s+$/);r>0&&(t.column=r)}}this.moveCursorTo(t.row,t.column)},this.moveCursorFileEnd=function(){var e=this.doc.getLength()-1,t=this.doc.getLine(e).length;this.moveCursorTo(e,t)},this.moveCursorFileStart=function(){this.moveCursorTo(0,0)},this.moveCursorLongWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t),i;this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;var s=this.session.getFoldAt(e,t,1);if(s){this.moveCursorTo(s.end.row,s.end.column);return}if(i=this.session.nonTokenRe.exec(r))t+=this.session.nonTokenRe.lastIndex,this.session.nonTokenRe.lastIndex=0,r=n.substring(t);if(t>=n.length){this.moveCursorTo(e,n.length),this.moveCursorRight(),e<this.doc.getLength()-1&&this.moveCursorWordRight();return}if(i=this.session.tokenRe.exec(r))t+=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0;this.moveCursorTo(e,t)},this.moveCursorLongWordLeft=function(){var e=this.lead.row,t=this.lead.column,n;if(n=this.session.getFoldAt(e,t,-1)){this.moveCursorTo(n.start.row,n.start.column);return}var r=this.session.getFoldStringAt(e,t,-1);r==null&&(r=this.doc.getLine(e).substring(0,t));var s=i.stringReverse(r),o;this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;if(o=this.session.nonTokenRe.exec(s))t-=this.session.nonTokenRe.lastIndex,s=s.slice(this.session.nonTokenRe.lastIndex),this.session.nonTokenRe.lastIndex=0;if(t<=0){this.moveCursorTo(e,0),this.moveCursorLeft(),e>0&&this.moveCursorWordLeft();return}if(o=this.session.tokenRe.exec(s))t-=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0;this.moveCursorTo(e,t)},this.$shortWordEndIndex=function(e){var t,n=0,r,i=/\s/,s=this.session.tokenRe;s.lastIndex=0;if(t=this.session.tokenRe.exec(e))n=this.session.tokenRe.lastIndex;else{while((r=e[n])&&i.test(r))n++;if(n<1){s.lastIndex=0;while((r=e[n])&&!s.test(r)){s.lastIndex=0,n++;if(i.test(r)){if(n>2){n--;break}while((r=e[n])&&i.test(r))n++;if(n>2)break}}}}return s.lastIndex=0,n},this.moveCursorShortWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t),i=this.session.getFoldAt(e,t,1);if(i)return this.moveCursorTo(i.end.row,i.end.column);if(t==n.length){var s=this.doc.getLength();do e++,r=this.doc.getLine(e);while(e<s&&/^\s*$/.test(r));/^\s+/.test(r)||(r=""),t=0}var o=this.$shortWordEndIndex(r);this.moveCursorTo(e,t+o)},this.moveCursorShortWordLeft=function(){var e=this.lead.row,t=this.lead.column,n;if(n=this.session.getFoldAt(e,t,-1))return this.moveCursorTo(n.start.row,n.start.column);var r=this.session.getLine(e).substring(0,t);if(t===0){do e--,r=this.doc.getLine(e);while(e>0&&/^\s*$/.test(r));t=r.length,/\s+$/.test(r)||(r="")}var s=i.stringReverse(r),o=this.$shortWordEndIndex(s);return this.moveCursorTo(e,t-o)},this.moveCursorWordRight=function(){this.session.$selectLongWords?this.moveCursorLongWordRight():this.moveCursorShortWordRight()},this.moveCursorWordLeft=function(){this.session.$selectLongWords?this.moveCursorLongWordLeft():this.moveCursorShortWordLeft()},this.moveCursorBy=function(e,t){var n=this.session.documentToScreenPosition(this.lead.row,this.lead.column);t===0&&(this.$desiredColumn?n.column=this.$desiredColumn:this.$desiredColumn=n.column);var r=this.session.screenToDocumentPosition(n.row+e,n.column);e!==0&&t===0&&r.row===this.lead.row&&r.column===this.lead.column&&this.session.lineWidgets&&this.session.lineWidgets[r.row]&&(r.row>0||e>0)&&r.row++,this.moveCursorTo(r.row,r.column+t,t===0)},this.moveCursorToPosition=function(e){this.moveCursorTo(e.row,e.column)},this.moveCursorTo=function(e,t,n){var r=this.session.getFoldAt(e,t,1);r&&(e=r.start.row,t=r.start.column),this.$keepDesiredColumnOnChange=!0,this.lead.setPosition(e,t),this.$keepDesiredColumnOnChange=!1,n||(this.$desiredColumn=null)},this.moveCursorToScreen=function(e,t,n){var r=this.session.screenToDocumentPosition(e,t);this.moveCursorTo(r.row,r.column,n)},this.detach=function(){this.lead.detach(),this.anchor.detach(),this.session=this.doc=null},this.fromOrientedRange=function(e){this.setSelectionRange(e,e.cursor==e.start),this.$desiredColumn=e.desiredColumn||this.$desiredColumn},this.toOrientedRange=function(e){var t=this.getRange();return e?(e.start.column=t.start.column,e.start.row=t.start.row,e.end.column=t.end.column,e.end.row=t.end.row):e=t,e.cursor=this.isBackwards()?e.start:e.end,e.desiredColumn=this.$desiredColumn,e},this.getRangeOfMovements=function(e){var t=this.getCursor();try{e(this);var n=this.getCursor();return o.fromPoints(t,n)}catch(r){return o.fromPoints(t,t)}finally{this.moveCursorToPosition(t)}},this.toJSON=function(){if(this.rangeCount)var e=this.ranges.map(function(e){var t=e.clone();return t.isBackwards=e.cursor==e.start,t});else{var e=this.getRange();e.isBackwards=this.isBackwards()}return e},this.fromJSON=function(e){if(e.start==undefined){if(this.rangeList){this.toSingleRange(e[0]);for(var t=e.length;t--;){var n=o.fromPoints(e[t].start,e[t].end);e[t].isBackwards&&(n.cursor=n.start),this.addRange(n,!0)}return}e=e[0]}this.rangeList&&this.toSingleRange(e),this.setSelectionRange(e,e.isBackwards)},this.isEqual=function(e){if((e.length||this.rangeCount)&&e.length!=this.rangeCount)return!1;if(!e.length||!this.ranges)return this.getRange().isEqual(e);for(var t=this.ranges.length;t--;)if(!this.ranges[t].isEqual(e[t]))return!1;return!0}}).call(u.prototype),t.Selection=u}),ace.define("ace/tokenizer",["require","exports","module","ace/config"],function(e,t,n){"use strict";var r=e("./config"),i=2e3,s=function(e){this.states=e,this.regExps={},this.matchMappings={};for(var t in this.states){var n=this.states[t],r=[],i=0,s=this.matchMappings[t]={defaultToken:"text"},o="g",u=[];for(var a=0;a<n.length;a++){var f=n[a];f.defaultToken&&(s.defaultToken=f.defaultToken),f.caseInsensitive&&(o="gi");if(f.regex==null)continue;f.regex instanceof RegExp&&(f.regex=f.regex.toString().slice(1,-1));var l=f.regex,c=(new RegExp("(?:("+l+")|(.))")).exec("a").length-2;Array.isArray(f.token)?f.token.length==1||c==1?f.token=f.token[0]:c-1!=f.token.length?(this.reportError("number of classes and regexp groups doesn't match",{rule:f,groupCount:c-1}),f.token=f.token[0]):(f.tokenArray=f.token,f.token=null,f.onMatch=this.$arrayTokens):typeof f.token=="function"&&!f.onMatch&&(c>1?f.onMatch=this.$applyToken:f.onMatch=f.token),c>1&&(/\\\d/.test(f.regex)?l=f.regex.replace(/\\([0-9]+)/g,function(e,t){return"\\"+(parseInt(t,10)+i+1)}):(c=1,l=this.removeCapturingGroups(f.regex)),!f.splitRegex&&typeof f.token!="string"&&u.push(f)),s[i]=a,i+=c,r.push(l),f.onMatch||(f.onMatch=null)}r.length||(s[0]=0,r.push("$")),u.forEach(function(e){e.splitRegex=this.createSplitterRegexp(e.regex,o)},this),this.regExps[t]=new RegExp("("+r.join(")|(")+")|($)",o)}};(function(){this.$setMaxTokenCount=function(e){i=e|0},this.$applyToken=function(e){var t=this.splitRegex.exec(e).slice(1),n=this.token.apply(this,t);if(typeof n=="string")return[{type:n,value:e}];var r=[];for(var i=0,s=n.length;i<s;i++)t[i]&&(r[r.length]={type:n[i],value:t[i]});return r},this.$arrayTokens=function(e){if(!e)return[];var t=this.splitRegex.exec(e);if(!t)return"text";var n=[],r=this.tokenArray;for(var i=0,s=r.length;i<s;i++)t[i+1]&&(n[n.length]={type:r[i],value:t[i+1]});return n},this.removeCapturingGroups=function(e){var t=e.replace(/\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,function(e,t){return t?"(?:":e});return t},this.createSplitterRegexp=function(e,t){if(e.indexOf("(?=")!=-1){var n=0,r=!1,i={};e.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g,function(e,t,s,o,u,a){return r?r=u!="]":u?r=!0:o?(n==i.stack&&(i.end=a+1,i.stack=-1),n--):s&&(n++,s.length!=1&&(i.stack=n,i.start=a)),e}),i.end!=null&&/^\)*$/.test(e.substr(i.end))&&(e=e.substring(0,i.start)+e.substr(i.end))}return e.charAt(0)!="^"&&(e="^"+e),e.charAt(e.length-1)!="$"&&(e+="$"),new RegExp(e,(t||"").replace("g",""))},this.getLineTokens=function(e,t){if(t&&typeof t!="string"){var n=t.slice(0);t=n[0],t==="#tmp"&&(n.shift(),t=n.shift())}else var n=[];var r=t||"start",s=this.states[r];s||(r="start",s=this.states[r]);var o=this.matchMappings[r],u=this.regExps[r];u.lastIndex=0;var a,f=[],l=0,c=0,h={type:null,value:""};while(a=u.exec(e)){var p=o.defaultToken,d=null,v=a[0],m=u.lastIndex;if(m-v.length>l){var g=e.substring(l,m-v.length);h.type==p?h.value+=g:(h.type&&f.push(h),h={type:p,value:g})}for(var y=0;y<a.length-2;y++){if(a[y+1]===undefined)continue;d=s[o[y]],d.onMatch?p=d.onMatch(v,r,n):p=d.token,d.next&&(typeof d.next=="string"?r=d.next:r=d.next(r,n),s=this.states[r],s||(this.reportError("state doesn't exist",r),r="start",s=this.states[r]),o=this.matchMappings[r],l=m,u=this.regExps[r],u.lastIndex=m);break}if(v)if(typeof p=="string")!!d&&d.merge===!1||h.type!==p?(h.type&&f.push(h),h={type:p,value:v}):h.value+=v;else if(p){h.type&&f.push(h),h={type:null,value:""};for(var y=0;y<p.length;y++)f.push(p[y])}if(l==e.length)break;l=m;if(c++>i){c>2*e.length&&this.reportError("infinite loop with in ace tokenizer",{startState:t,line:e});while(l<e.length)h.type&&f.push(h),h={value:e.substring(l,l+=2e3),type:"overflow"};r="start",n=[];break}}return h.type&&f.push(h),n.length>1&&n[0]!==r&&n.unshift("#tmp",r),{tokens:f,state:n.length?n:r}},this.reportError=r.reportError}).call(s.prototype),t.Tokenizer=s}),ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/lang"),i=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(e,t){if(!t){for(var n in e)this.$rules[n]=e[n];return}for(var n in e){var r=e[n];for(var i=0;i<r.length;i++){var s=r[i];if(s.next||s.onMatch)typeof s.next=="string"&&s.next.indexOf(t)!==0&&(s.next=t+s.next),s.nextState&&s.nextState.indexOf(t)!==0&&(s.nextState=t+s.nextState)}this.$rules[t+n]=r}},this.getRules=function(){return this.$rules},this.embedRules=function(e,t,n,i,s){var o=typeof e=="function"?(new e).getRules():e;if(i)for(var u=0;u<i.length;u++)i[u]=t+i[u];else{i=[];for(var a in o)i.push(t+a)}this.addRules(o,t);if(n){var f=Array.prototype[s?"push":"unshift"];for(var u=0;u<i.length;u++)f.apply(this.$rules[i[u]],r.deepCopy(n))}this.$embeds||(this.$embeds=[]),this.$embeds.push(t)},this.getEmbeds=function(){return this.$embeds};var e=function(e,t){return(e!="start"||t.length)&&t.unshift(this.nextState,e),this.nextState},t=function(e,t){return t.shift(),t.shift()||"start"};this.normalizeRules=function(){function i(s){var o=r[s];o.processed=!0;for(var u=0;u<o.length;u++){var a=o[u],f=null;Array.isArray(a)&&(f=a,a={}),!a.regex&&a.start&&(a.regex=a.start,a.next||(a.next=[]),a.next.push({defaultToken:a.token},{token:a.token+".end",regex:a.end||a.start,next:"pop"}),a.token=a.token+".start",a.push=!0);var l=a.next||a.push;if(l&&Array.isArray(l)){var c=a.stateName;c||(c=a.token,typeof c!="string"&&(c=c[0]||""),r[c]&&(c+=n++)),r[c]=l,a.next=c,i(c)}else l=="pop"&&(a.next=t);a.push&&(a.nextState=a.next||a.push,a.next=e,delete a.push);if(a.rules)for(var h in a.rules)r[h]?r[h].push&&r[h].push.apply(r[h],a.rules[h]):r[h]=a.rules[h];var p=typeof a=="string"?a:typeof a.include=="string"?a.include:"";p&&(f=r[p]);if(f){var d=[u,1].concat(f);a.noEscape&&(d=d.filter(function(e){return!e.next})),o.splice.apply(o,d),u--}a.keywordMap&&(a.token=this.createKeywordMapper(a.keywordMap,a.defaultToken||"text",a.caseInsensitive),delete a.defaultToken)}}var n=0,r=this.$rules;Object.keys(r).forEach(i,this)},this.createKeywordMapper=function(e,t,n,r){var i=Object.create(null);return Object.keys(e).forEach(function(t){var s=e[t];n&&(s=s.toLowerCase());var o=s.split(r||"|");for(var u=o.length;u--;)i[o[u]]=t}),Object.getPrototypeOf(i)&&(i.__proto__=null),this.$keywordList=Object.keys(i),e=null,n?function(e){return i[e.toLowerCase()]||t}:function(e){return i[e]||t}},this.getKeywords=function(){return this.$keywords}}).call(i.prototype),t.TextHighlightRules=i}),ace.define("ace/mode/behaviour",["require","exports","module"],function(e,t,n){"use strict";var r=function(){this.$behaviours={}};(function(){this.add=function(e,t,n){switch(undefined){case this.$behaviours:this.$behaviours={};case this.$behaviours[e]:this.$behaviours[e]={}}this.$behaviours[e][t]=n},this.addBehaviours=function(e){for(var t in e)for(var n in e[t])this.add(t,n,e[t][n])},this.remove=function(e){this.$behaviours&&this.$behaviours[e]&&delete this.$behaviours[e]},this.inherit=function(e,t){if(typeof e=="function")var n=(new e).getBehaviours(t);else var n=e.getBehaviours(t);this.addBehaviours(n)},this.getBehaviours=function(e){if(!e)return this.$behaviours;var t={};for(var n=0;n<e.length;n++)this.$behaviours[e[n]]&&(t[e[n]]=this.$behaviours[e[n]]);return t}}).call(r.prototype),t.Behaviour=r}),ace.define("ace/token_iterator",["require","exports","module"],function(e,t,n){"use strict";var r=function(e,t,n){this.$session=e,this.$row=t,this.$rowTokens=e.getTokens(t);var r=e.getTokenAt(t,n);this.$tokenIndex=r?r.index:-1};(function(){this.stepBackward=function(){this.$tokenIndex-=1;while(this.$tokenIndex<0){this.$row-=1;if(this.$row<0)return this.$row=0,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=this.$rowTokens.length-1}return this.$rowTokens[this.$tokenIndex]},this.stepForward=function(){this.$tokenIndex+=1;var e;while(this.$tokenIndex>=this.$rowTokens.length){this.$row+=1,e||(e=this.$session.getLength());if(this.$row>=e)return this.$row=e-1,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=0}return this.$rowTokens[this.$tokenIndex]},this.getCurrentToken=function(){return this.$rowTokens[this.$tokenIndex]},this.getCurrentTokenRow=function(){return this.$row},this.getCurrentTokenColumn=function(){var e=this.$rowTokens,t=this.$tokenIndex,n=e[t].start;if(n!==undefined)return n;n=0;while(t>0)t-=1,n+=e[t].value.length;return n},this.getCurrentTokenPosition=function(){return{row:this.$row,column:this.getCurrentTokenColumn()}}}).call(r.prototype),t.TokenIterator=r}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../behaviour").Behaviour,s=e("../../token_iterator").TokenIterator,o=e("../../lib/lang"),u=["text","paren.rparen","punctuation.operator"],a=["text","paren.rparen","punctuation.operator","comment"],f,l={},c=function(e){var t=-1;e.multiSelect&&(t=e.selection.index,l.rangeCount!=e.multiSelect.rangeCount&&(l={rangeCount:e.multiSelect.rangeCount}));if(l[t])return f=l[t];f=l[t]={autoInsertedBrackets:0,autoInsertedRow:-1,autoInsertedLineEnd:"",maybeInsertedBrackets:0,maybeInsertedRow:-1,maybeInsertedLineStart:"",maybeInsertedLineEnd:""}},h=function(e,t,n,r){var i=e.end.row-e.start.row;return{text:n+t+r,selection:[0,e.start.column+1,i,e.end.column+(i?0:1)]}},p=function(){this.add("braces","insertion",function(e,t,n,r,i){var s=n.getCursorPosition(),u=r.doc.getLine(s.row);if(i=="{"){c(n);var a=n.getSelectionRange(),l=r.doc.getTextRange(a);if(l!==""&&l!=="{"&&n.getWrapBehavioursEnabled())return h(a,l,"{","}");if(p.isSaneInsertion(n,r))return/[\]\}\)]/.test(u[s.column])||n.inMultiSelectMode?(p.recordAutoInsert(n,r,"}"),{text:"{}",selection:[1,1]}):(p.recordMaybeInsert(n,r,"{"),{text:"{",selection:[1,1]})}else if(i=="}"){c(n);var d=u.substring(s.column,s.column+1);if(d=="}"){var v=r.$findOpeningBracket("}",{column:s.column+1,row:s.row});if(v!==null&&p.isAutoInsertedClosing(s,u,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else{if(i=="\n"||i=="\r\n"){c(n);var m="";p.isMaybeInsertedClosing(s,u)&&(m=o.stringRepeat("}",f.maybeInsertedBrackets),p.clearMaybeInsertedClosing());var d=u.substring(s.column,s.column+1);if(d==="}"){var g=r.findMatchingBracket({row:s.row,column:s.column+1},"}");if(!g)return null;var y=this.$getIndent(r.getLine(g.row))}else{if(!m){p.clearMaybeInsertedClosing();return}var y=this.$getIndent(u)}var b=y+r.getTabString();return{text:"\n"+b+"\n"+y+m,selection:[1,b.length,1,b.length]}}p.clearMaybeInsertedClosing()}}),this.add("braces","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="{"){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.end.column,i.end.column+1);if(u=="}")return i.end.column++,i;f.maybeInsertedBrackets--}}),this.add("parens","insertion",function(e,t,n,r,i){if(i=="("){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return h(s,o,"(",")");if(p.isSaneInsertion(n,r))return p.recordAutoInsert(n,r,")"),{text:"()",selection:[1,1]}}else if(i==")"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f==")"){var l=r.$findOpeningBracket(")",{column:u.column+1,row:u.row});if(l!==null&&p.isAutoInsertedClosing(u,a,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="("){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==")")return i.end.column++,i}}),this.add("brackets","insertion",function(e,t,n,r,i){if(i=="["){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return h(s,o,"[","]");if(p.isSaneInsertion(n,r))return p.recordAutoInsert(n,r,"]"),{text:"[]",selection:[1,1]}}else if(i=="]"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f=="]"){var l=r.$findOpeningBracket("]",{column:u.column+1,row:u.row});if(l!==null&&p.isAutoInsertedClosing(u,a,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="["){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u=="]")return i.end.column++,i}}),this.add("string_dquotes","insertion",function(e,t,n,r,i){if(i=='"'||i=="'"){if(this.lineCommentStart&&this.lineCommentStart.indexOf(i)!=-1)return;c(n);var s=i,o=n.getSelectionRange(),u=r.doc.getTextRange(o);if(u!==""&&u!=="'"&&u!='"'&&n.getWrapBehavioursEnabled())return h(o,u,s,s);if(!u){var a=n.getCursorPosition(),f=r.doc.getLine(a.row),l=f.substring(a.column-1,a.column),p=f.substring(a.column,a.column+1),d=r.getTokenAt(a.row,a.column),v=r.getTokenAt(a.row,a.column+1);if(l=="\\"&&d&&/escape/.test(d.type))return null;var m=d&&/string|escape/.test(d.type),g=!v||/string|escape/.test(v.type),y;if(p==s)y=m!==g,y&&/string\.end/.test(v.type)&&(y=!1);else{if(m&&!g)return null;if(m&&g)return null;var b=r.$mode.tokenRe;b.lastIndex=0;var w=b.test(l);b.lastIndex=0;var E=b.test(l);if(w||E)return null;if(p&&!/[\s;,.})\]\\]/.test(p))return null;y=!0}return{text:y?s+s:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&(s=='"'||s=="'")){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==s)return i.end.column++,i}})};p.isSaneInsertion=function(e,t){var n=e.getCursorPosition(),r=new s(t,n.row,n.column);if(!this.$matchTokenType(r.getCurrentToken()||"text",u)){var i=new s(t,n.row,n.column+1);if(!this.$matchTokenType(i.getCurrentToken()||"text",u))return!1}return r.stepForward(),r.getCurrentTokenRow()!==n.row||this.$matchTokenType(r.getCurrentToken()||"text",a)},p.$matchTokenType=function(e,t){return t.indexOf(e.type||e)>-1},p.recordAutoInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isAutoInsertedClosing(r,i,f.autoInsertedLineEnd[0])||(f.autoInsertedBrackets=0),f.autoInsertedRow=r.row,f.autoInsertedLineEnd=n+i.substr(r.column),f.autoInsertedBrackets++},p.recordMaybeInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isMaybeInsertedClosing(r,i)||(f.maybeInsertedBrackets=0),f.maybeInsertedRow=r.row,f.maybeInsertedLineStart=i.substr(0,r.column)+n,f.maybeInsertedLineEnd=i.substr(r.column),f.maybeInsertedBrackets++},p.isAutoInsertedClosing=function(e,t,n){return f.autoInsertedBrackets>0&&e.row===f.autoInsertedRow&&n===f.autoInsertedLineEnd[0]&&t.substr(e.column)===f.autoInsertedLineEnd},p.isMaybeInsertedClosing=function(e,t){return f.maybeInsertedBrackets>0&&e.row===f.maybeInsertedRow&&t.substr(e.column)===f.maybeInsertedLineEnd&&t.substr(0,e.column)==f.maybeInsertedLineStart},p.popAutoInsertedClosing=function(){f.autoInsertedLineEnd=f.autoInsertedLineEnd.substr(1),f.autoInsertedBrackets--},p.clearMaybeInsertedClosing=function(){f&&(f.maybeInsertedBrackets=0,f.maybeInsertedRow=-1)},r.inherits(p,i),t.CstyleBehaviour=p}),ace.define("ace/unicode",["require","exports","module"],function(e,t,n){"use strict";function r(e){var n=/\w{4}/g;for(var r in e)t.packages[r]=e[r].replace(n,"\\u$&")}t.packages={},r({L:"0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",Ll:"0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",Lu:"0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",Lt:"01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",Lm:"02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",Lo:"01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",M:"0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",Mn:"0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",Mc:"0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",Me:"0488048906DE20DD-20E020E2-20E4A670-A672",N:"0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",Nd:"0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",Nl:"16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",No:"00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",P:"0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",Pd:"002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",Ps:"0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",Pe:"0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",Pi:"00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",Pf:"00BB2019201D203A2E032E052E0A2E0D2E1D2E21",Pc:"005F203F20402054FE33FE34FE4D-FE4FFF3F",Po:"0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",S:"0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",Sm:"002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",Sc:"002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",Sk:"005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",So:"00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",Z:"002000A01680180E2000-200A20282029202F205F3000",Zs:"002000A01680180E2000-200A202F205F3000",Zl:"2028",Zp:"2029",C:"0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",Cc:"0000-001F007F-009F",Cf:"00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",Co:"E000-F8FF",Cs:"D800-DFFF",Cn:"03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"})}),ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"],function(e,t,n){"use strict";var r=e("../tokenizer").Tokenizer,i=e("./text_highlight_rules").TextHighlightRules,s=e("./behaviour/cstyle").CstyleBehaviour,o=e("../unicode"),u=e("../lib/lang"),a=e("../token_iterator").TokenIterator,f=e("../range").Range,l=function(){this.HighlightRules=i};(function(){this.$behaviour=new s,this.tokenRe=new RegExp("^["+o.packages.L+o.packages.Mn+o.packages.Mc+o.packages.Nd+o.packages.Pc+"\\$_]+","g"),this.nonTokenRe=new RegExp("^(?:[^"+o.packages.L+o.packages.Mn+o.packages.Mc+o.packages.Nd+o.packages.Pc+"\\$_]|\\s])+","g"),this.getTokenizer=function(){return this.$tokenizer||(this.$highlightRules=this.$highlightRules||new this.HighlightRules(this.$highlightRuleConfig),this.$tokenizer=new r(this.$highlightRules.getRules())),this.$tokenizer},this.lineCommentStart="",this.blockComment="",this.toggleCommentLines=function(e,t,n,r){function w(e){for(var t=n;t<=r;t++)e(i.getLine(t),t)}var i=t.doc,s=!0,o=!0,a=Infinity,f=t.getTabSize(),l=!1;if(!this.lineCommentStart){if(!this.blockComment)return!1;var c=this.blockComment.start,h=this.blockComment.end,p=new RegExp("^(\\s*)(?:"+u.escapeRegExp(c)+")"),d=new RegExp("(?:"+u.escapeRegExp(h)+")\\s*$"),v=function(e,t){if(g(e,t))return;if(!s||/\S/.test(e))i.insertInLine({row:t,column:e.length},h),i.insertInLine({row:t,column:a},c)},m=function(e,t){var n;(n=e.match(d))&&i.removeInLine(t,e.length-n[0].length,e.length),(n=e.match(p))&&i.removeInLine(t,n[1].length,n[0].length)},g=function(e,n){if(p.test(e))return!0;var r=t.getTokens(n);for(var i=0;i<r.length;i++)if(r[i].type==="comment")return!0}}else{if(Array.isArray(this.lineCommentStart))var p=this.lineCommentStart.map(u.escapeRegExp).join("|"),c=this.lineCommentStart[0];else var p=u.escapeRegExp(this.lineCommentStart),c=this.lineCommentStart;p=new RegExp("^(\\s*)(?:"+p+") ?"),l=t.getUseSoftTabs();var m=function(e,t){var n=e.match(p);if(!n)return;var r=n[1].length,s=n[0].length;!b(e,r,s)&&n[0][s-1]==" "&&s--,i.removeInLine(t,r,s)},y=c+" ",v=function(e,t){if(!s||/\S/.test(e))b(e,a,a)?i.insertInLine({row:t,column:a},y):i.insertInLine({row:t,column:a},c)},g=function(e,t){return p.test(e)},b=function(e,t,n){var r=0;while(t--&&e.charAt(t)==" ")r++;if(r%f!=0)return!1;var r=0;while(e.charAt(n++)==" ")r++;return f>2?r%f!=f-1:r%f==0}}var E=Infinity;w(function(e,t){var n=e.search(/\S/);n!==-1?(n<a&&(a=n),o&&!g(e,t)&&(o=!1)):E>e.length&&(E=e.length)}),a==Infinity&&(a=E,s=!1,o=!1),l&&a%f!=0&&(a=Math.floor(a/f)*f),w(o?m:v)},this.toggleBlockComment=function(e,t,n,r){var i=this.blockComment;if(!i)return;!i.start&&i[0]&&(i=i[0]);var s=new a(t,r.row,r.column),o=s.getCurrentToken(),u=t.selection,l=t.selection.toOrientedRange(),c,h;if(o&&/comment/.test(o.type)){var p,d;while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.start);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;p=new f(m,g,m,g+i.start.length);break}o=s.stepBackward()}var s=new a(t,r.row,r.column),o=s.getCurrentToken();while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.end);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;d=new f(m,g,m,g+i.end.length);break}o=s.stepForward()}d&&t.remove(d),p&&(t.remove(p),c=p.start.row,h=-i.start.length)}else h=i.start.length,c=n.start.row,t.insert(n.end,i.end),t.insert(n.start,i.start);l.start.row==c&&(l.start.column+=h),l.end.row==c&&(l.end.column+=h),t.selection.fromOrientedRange(l)},this.getNextLineIndent=function(e,t,n){return this.$getIndent(t)},this.checkOutdent=function(e,t,n){return!1},this.autoOutdent=function(e,t,n){},this.$getIndent=function(e){return e.match(/^\s*/)[0]},this.createWorker=function(e){return null},this.createModeDelegates=function(e){this.$embeds=[],this.$modes={};for(var t in e)e[t]&&(this.$embeds.push(t),this.$modes[t]=new e[t]);var n=["toggleBlockComment","toggleCommentLines","getNextLineIndent","checkOutdent","autoOutdent","transformAction","getCompletions"];for(var t=0;t<n.length;t++)(function(e){var r=n[t],i=e[r];e[n[t]]=function(){return this.$delegator(r,arguments,i)}})(this)},this.$delegator=function(e,t,n){var r=t[0];typeof r!="string"&&(r=r[0]);for(var i=0;i<this.$embeds.length;i++){if(!this.$modes[this.$embeds[i]])continue;var s=r.split(this.$embeds[i]);if(!s[0]&&s[1]){t[0]=s[1];var o=this.$modes[this.$embeds[i]];return o[e].apply(o,t)}}var u=n.apply(this,t);return n?u:undefined},this.transformAction=function(e,t,n,r,i){if(this.$behaviour){var s=this.$behaviour.getBehaviours();for(var o in s)if(s[o][t]){var u=s[o][t].apply(this,arguments);if(u)return u}}},this.getKeywords=function(e){if(!this.completionKeywords){var t=this.$tokenizer.rules,n=[];for(var r in t){var i=t[r];for(var s=0,o=i.length;s<o;s++)if(typeof i[s].token=="string")/keyword|support|storage/.test(i[s].token)&&n.push(i[s].regex);else if(typeof i[s].token=="object")for(var u=0,a=i[s].token.length;u<a;u++)if(/keyword|support|storage/.test(i[s].token[u])){var r=i[s].regex.match(/\(.+?\)/g)[u];n.push(r.substr(1,r.length-2))}}this.completionKeywords=n}return e?n.concat(this.$keywordList||[]):this.$keywordList},this.$createKeywordList=function(){return this.$highlightRules||this.getTokenizer(),this.$keywordList=this.$highlightRules.$keywordList||[]},this.getCompletions=function(e,t,n,r){var i=this.$keywordList||this.$createKeywordList();return i.map(function(e){return{name:e,value:e,score:0,meta:"keyword"}})},this.$id="ace/mode/text"}).call(l.prototype),t.Mode=l}),ace.define("ace/apply_delta",["require","exports","module"],function(e,t,n){"use strict";function r(e,t){throw console.log("Invalid Delta:",e),"Invalid Delta: "+t}function i(e,t){return t.row>=0&&t.row<e.length&&t.column>=0&&t.column<=e[t.row].length}function s(e,t){t.action!="insert"&&t.action!="remove"&&r(t,"delta.action must be 'insert' or 'remove'"),t.lines instanceof Array||r(t,"delta.lines must be an Array"),(!t.start||!t.end)&&r(t,"delta.start/end must be an present");var n=t.start;i(e,t.start)||r(t,"delta.start must be contained in document");var s=t.end;t.action=="remove"&&!i(e,s)&&r(t,"delta.end must contained in document for 'remove' actions");var o=s.row-n.row,u=s.column-(o==0?n.column:0);(o!=t.lines.length-1||t.lines[o].length!=u)&&r(t,"delta.range must match delta lines")}t.applyDelta=function(e,t,n){var r=t.start.row,i=t.start.column,s=e[r]||"";switch(t.action){case"insert":var o=t.lines;if(o.length===1)e[r]=s.substring(0,i)+t.lines[0]+s.substring(i);else{var u=[r,1].concat(t.lines);e.splice.apply(e,u),e[r]=s.substring(0,i)+e[r],e[r+t.lines.length-1]+=s.substring(i)}break;case"remove":var a=t.end.column,f=t.end.row;r===f?e[r]=s.substring(0,i)+s.substring(a):e.splice(r,f-r+1,s.substring(0,i)+e[f].substring(a))}}}),ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=t.Anchor=function(e,t,n){this.$onChange=this.onChange.bind(this),this.attach(e),typeof n=="undefined"?this.setPosition(t.row,t.column):this.setPosition(t,n)};(function(){function e(e,t,n){var r=n?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&r}function t(t,n,r){var i=t.action=="insert",s=(i?1:-1)*(t.end.row-t.start.row),o=(i?1:-1)*(t.end.column-t.start.column),u=t.start,a=i?u:t.end;return e(n,u,r)?{row:n.row,column:n.column}:e(a,n,!r)?{row:n.row+s,column:n.column+(n.row==a.row?o:0)}:{row:u.row,column:u.column}}r.implement(this,i),this.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},this.getDocument=function(){return this.document},this.$insertRight=!1,this.onChange=function(e){if(e.start.row==e.end.row&&e.start.row!=this.row)return;if(e.start.row>this.row)return;var n=t(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(n.row,n.column,!0)},this.setPosition=function(e,t,n){var r;n?r={row:e,column:t}:r=this.$clipPositionToDocument(e,t);if(this.row==r.row&&this.column==r.column)return;var i={row:this.row,column:this.column};this.row=r.row,this.column=r.column,this._signal("change",{old:i,value:r})},this.detach=function(){this.document.removeEventListener("change",this.$onChange)},this.attach=function(e){this.document=e||this.document,this.document.on("change",this.$onChange)},this.$clipPositionToDocument=function(e,t){var n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n}}).call(s.prototype)}),ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./apply_delta").applyDelta,s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=e("./anchor").Anchor,a=function(e){this.$lines=[""],e.length===0?this.$lines=[""]:Array.isArray(e)?this.insertMergedLines({row:0,column:0},e):this.insert({row:0,column:0},e)};(function(){r.implement(this,s),this.setValue=function(e){var t=this.getLength()-1;this.remove(new o(0,0,t,this.getLine(t).length)),this.insert({row:0,column:0},e)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(e,t){return new u(this,e,t)},"aaa".split(/a/).length===0?this.$split=function(e){return e.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(e){return e.split(/\r\n|\r|\n/)},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(e){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},this.getLine=function(e){return this.$lines[e]||""},this.getLines=function(e,t){return this.$lines.slice(e,t+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(e){return this.getLinesForRange(e).join(this.getNewLineCharacter())},this.getLinesForRange=function(e){var t;if(e.start.row===e.end.row)t=[this.getLine(e.start.row).substring(e.start.column,e.end.column)];else{t=this.getLines(e.start.row,e.end.row),t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column))}return t},this.insertLines=function(e,t){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(e,t)},this.removeLines=function(e,t){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(e,t)},this.insertNewLine=function(e){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."),this.insertMergedLines(e,["",""])},this.insert=function(e,t){return this.getLength()<=1&&this.$detectNewLine(t),this.insertMergedLines(e,this.$split(t))},this.insertInLine=function(e,t){var n=this.clippedPos(e.row,e.column),r=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:r,action:"insert",lines:[t]},!0),this.clonePos(r)},this.clippedPos=function(e,t){var n=this.getLength();e===undefined?e=n:e<0?e=0:e>=n&&(e=n-1,t=undefined);var r=this.getLine(e);return t==undefined&&(t=r.length),t=Math.min(Math.max(t,0),r.length),{row:e,column:t}},this.clonePos=function(e){return{row:e.row,column:e.column}},this.pos=function(e,t){return{row:e,column:t}},this.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):(e.row=Math.max(0,e.row),e.column=Math.min(Math.max(e.column,0),this.getLine(e.row).length)),e},this.insertFullLines=function(e,t){e=Math.min(Math.max(e,0),this.getLength());var n=0;e<this.getLength()?(t=t.concat([""]),n=0):(t=[""].concat(t),e--,n=this.$lines[e].length),this.insertMergedLines({row:e,column:n},t)},this.insertMergedLines=function(e,t){var n=this.clippedPos(e.row,e.column),r={row:n.row+t.length-1,column:(t.length==1?n.column:0)+t[t.length-1].length};return this.applyDelta({start:n,end:r,action:"insert",lines:t}),this.clonePos(r)},this.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),n=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:n,action:"remove",lines:this.getLinesForRange({start:t,end:n})}),this.clonePos(t)},this.removeInLine=function(e,t,n){var r=this.clippedPos(e,t),i=this.clippedPos(e,n);return this.applyDelta({start:r,end:i,action:"remove",lines:this.getLinesForRange({start:r,end:i})},!0),this.clonePos(r)},this.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1),t=Math.min(Math.max(0,t),this.getLength()-1);var n=t==this.getLength()-1&&e>0,r=t<this.getLength()-1,i=n?e-1:e,s=n?this.getLine(i).length:0,u=r?t+1:t,a=r?0:this.getLine(u).length,f=new o(i,s,u,a),l=this.$lines.slice(e,t+1);return this.applyDelta({start:f.start,end:f.end,action:"remove",lines:this.getLinesForRange(f)}),l},this.removeNewLine=function(e){e<this.getLength()-1&&e>=0&&this.applyDelta({start:this.pos(e,this.getLine(e).length),end:this.pos(e+1,0),action:"remove",lines:["",""]})},this.replace=function(e,t){e instanceof o||(e=o.fromPoints(e.start,e.end));if(t.length===0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);var n;return t?n=this.insert(e.start,t):n=e.start,n},this.applyDeltas=function(e){for(var t=0;t<e.length;t++)this.applyDelta(e[t])},this.revertDeltas=function(e){for(var t=e.length-1;t>=0;t--)this.revertDelta(e[t])},this.applyDelta=function(e,t){var n=e.action=="insert";if(n?e.lines.length<=1&&!e.lines[0]:!o.comparePoints(e.start,e.end))return;n&&e.lines.length>2e4&&this.$splitAndapplyLargeDelta(e,2e4),i(this.$lines,e,t),this._signal("change",e)},this.$splitAndapplyLargeDelta=function(e,t){var n=e.lines,r=n.length,i=e.start.row,s=e.start.column,o=0,u=0;do{o=u,u+=t-1;var a=n.slice(o,u);if(u>r){e.lines=a,e.start.row=i+o,e.start.column=s;break}a.push(""),this.applyDelta({start:this.pos(i+o,s),end:this.pos(i+u,s=0),action:e.action,lines:a},!0)}while(!0)},this.revertDelta=function(e){this.applyDelta({start:this.clonePos(e.start),end:this.clonePos(e.end),action:e.action=="insert"?"remove":"insert",lines:e.lines.slice()})},this.indexToPosition=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length;for(var i=t||0,s=n.length;i<s;i++){e-=n[i].length+r;if(e<0)return{row:i,column:e+n[i].length+r}}return{row:s-1,column:n[s-1].length}},this.positionToIndex=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length,i=0,s=Math.min(e.row,n.length);for(var o=t||0;o<s;++o)i+=n[o].length+r;return i+e.column}}).call(a.prototype),t.Document=a}),ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=function(e,t){this.running=!1,this.lines=[],this.states=[],this.currentLine=0,this.tokenizer=e;var n=this;this.$worker=function(){if(!n.running)return;var e=new Date,t=n.currentLine,r=-1,i=n.doc,s=t;while(n.lines[t])t++;var o=i.getLength(),u=0;n.running=!1;while(t<o){n.$tokenizeRow(t),r=t;do t++;while(n.lines[t]);u++;if(u%5===0&&new Date-e>20){n.running=setTimeout(n.$worker,20);break}}n.currentLine=t,s<=r&&n.fireUpdateEvent(s,r)}};(function(){r.implement(this,i),this.setTokenizer=function(e){this.tokenizer=e,this.lines=[],this.states=[],this.start(0)},this.setDocument=function(e){this.doc=e,this.lines=[],this.states=[],this.stop()},this.fireUpdateEvent=function(e,t){var n={first:e,last:t};this._signal("update",{data:n})},this.start=function(e){this.currentLine=Math.min(e||0,this.currentLine,this.doc.getLength()),this.lines.splice(this.currentLine,this.lines.length),this.states.splice(this.currentLine,this.states.length),this.stop(),this.running=setTimeout(this.$worker,700)},this.scheduleStart=function(){this.running||(this.running=setTimeout(this.$worker,700))},this.$updateOnChange=function(e){var t=e.start.row,n=e.end.row-t;if(n===0)this.lines[t]=null;else if(e.action=="remove")this.lines.splice(t,n+1,null),this.states.splice(t,n+1,null);else{var r=Array(n+1);r.unshift(t,1),this.lines.splice.apply(this.lines,r),this.states.splice.apply(this.states,r)}this.currentLine=Math.min(t,this.currentLine,this.doc.getLength()),this.stop()},this.stop=function(){this.running&&clearTimeout(this.running),this.running=!1},this.getTokens=function(e){return this.lines[e]||this.$tokenizeRow(e)},this.getState=function(e){return this.currentLine==e&&this.$tokenizeRow(e),this.states[e]||"start"},this.$tokenizeRow=function(e){var t=this.doc.getLine(e),n=this.states[e-1],r=this.tokenizer.getLineTokens(t,n,e);return this.states[e]+""!=r.state+""?(this.states[e]=r.state,this.lines[e+1]=null,this.currentLine>e+1&&(this.currentLine=e+1)):this.currentLine==e&&(this.currentLine=e+1),this.lines[e]=r.tokens}}).call(s.prototype),t.BackgroundTokenizer=s}),ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(e,t,n){this.setRegexp(e),this.clazz=t,this.type=n||"text"};(function(){this.MAX_RANGES=500,this.setRegexp=function(e){if(this.regExp+""==e+"")return;this.regExp=e,this.cache=[]},this.update=function(e,t,n,i){if(!this.regExp)return;var o=i.firstRow,u=i.lastRow;for(var a=o;a<=u;a++){var f=this.cache[a];f==null&&(f=r.getMatchOffsets(n.getLine(a),this.regExp),f.length>this.MAX_RANGES&&(f=f.slice(0,this.MAX_RANGES)),f=f.map(function(e){return new s(a,e.offset,a,e.offset+e.length)}),this.cache[a]=f.length?f:"");for(var l=f.length;l--;)t.drawSingleLineMarker(e,f[l].toScreenRange(n),this.clazz,i)}}}).call(o.prototype),t.SearchHighlight=o}),ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"],function(e,t,n){"use strict";function i(e,t){this.foldData=e,Array.isArray(t)?this.folds=t:t=this.folds=[t];var n=t[t.length-1];this.range=new r(t[0].start.row,t[0].start.column,n.end.row,n.end.column),this.start=this.range.start,this.end=this.range.end,this.folds.forEach(function(e){e.setFoldLine(this)},this)}var r=e("../range").Range;(function(){this.shiftRow=function(e){this.start.row+=e,this.end.row+=e,this.folds.forEach(function(t){t.start.row+=e,t.end.row+=e})},this.addFold=function(e){if(e.sameRow){if(e.start.row<this.startRow||e.endRow>this.endRow)throw new Error("Can't add a fold to this FoldLine as it has no connection");this.folds.push(e),this.folds.sort(function(e,t){return-e.range.compareEnd(t.start.row,t.start.column)}),this.range.compareEnd(e.start.row,e.start.column)>0?(this.end.row=e.end.row,this.end.column=e.end.column):this.range.compareStart(e.end.row,e.end.column)<0&&(this.start.row=e.start.row,this.start.column=e.start.column)}else if(e.start.row==this.end.row)this.folds.push(e),this.end.row=e.end.row,this.end.column=e.end.column;else{if(e.end.row!=this.start.row)throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");this.folds.unshift(e),this.start.row=e.start.row,this.start.column=e.start.column}e.foldLine=this},this.containsRow=function(e){return e>=this.start.row&&e<=this.end.row},this.walk=function(e,t,n){var r=0,i=this.folds,s,o,u,a=!0;t==null&&(t=this.end.row,n=this.end.column);for(var f=0;f<i.length;f++){s=i[f],o=s.range.compareStart(t,n);if(o==-1){e(null,t,n,r,a);return}u=e(null,s.start.row,s.start.column,r,a),u=!u&&e(s.placeholder,s.start.row,s.start.column,r);if(u||o===0)return;a=!s.sameRow,r=s.end.column}e(null,t,n,r,a)},this.getNextFoldTo=function(e,t){var n,r;for(var i=0;i<this.folds.length;i++){n=this.folds[i],r=n.range.compareEnd(e,t);if(r==-1)return{fold:n,kind:"after"};if(r===0)return{fold:n,kind:"inside"}}return null},this.addRemoveChars=function(e,t,n){var r=this.getNextFoldTo(e,t),i,s;if(r){i=r.fold;if(r.kind=="inside"&&i.start.column!=t&&i.start.row!=e)window.console&&window.console.log(e,t,i);else if(i.start.row==e){s=this.folds;var o=s.indexOf(i);o===0&&(this.start.column+=n);for(o;o<s.length;o++){i=s[o],i.start.column+=n;if(!i.sameRow)return;i.end.column+=n}this.end.column+=n}}},this.split=function(e,t){var n=this.getNextFoldTo(e,t);if(!n||n.kind=="inside")return null;var r=n.fold,s=this.folds,o=this.foldData,u=s.indexOf(r),a=s[u-1];this.end.row=a.end.row,this.end.column=a.end.column,s=s.splice(u,s.length-u);var f=new i(o,s);return o.splice(o.indexOf(this)+1,0,f),f},this.merge=function(e){var t=e.folds;for(var n=0;n<t.length;n++)this.addFold(t[n]);var r=this.foldData;r.splice(r.indexOf(e),1)},this.toString=function(){var e=[this.range.toString()+": ["];return this.folds.forEach(function(t){e.push(" "+t.toString())}),e.push("]"),e.join("\n")},this.idxToPosition=function(e){var t=0;for(var n=0;n<this.folds.length;n++){var r=this.folds[n];e-=r.start.column-t;if(e<0)return{row:r.start.row,column:r.start.column+e};e-=r.placeholder.length;if(e<0)return r.start;t=r.end.column}return{row:this.end.row,column:this.end.column+e}}}).call(i.prototype),t.FoldLine=i}),ace.define("ace/range_list",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("./range").Range,i=r.comparePoints,s=function(){this.ranges=[]};(function(){this.comparePoints=i,this.pointIndex=function(e,t,n){var r=this.ranges;for(var s=n||0;s<r.length;s++){var o=r[s],u=i(e,o.end);if(u>0)continue;var a=i(e,o.start);return u===0?t&&a!==0?-s-2:s:a>0||a===0&&!t?s:-s-1}return-s-1},this.add=function(e){var t=!e.isEmpty(),n=this.pointIndex(e.start,t);n<0&&(n=-n-1);var r=this.pointIndex(e.end,t,n);return r<0?r=-r-1:r++,this.ranges.splice(n,r-n,e)},this.addList=function(e){var t=[];for(var n=e.length;n--;)t.push.apply(t,this.add(e[n]));return t},this.substractPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges.splice(t,1)},this.merge=function(){var e=[],t=this.ranges;t=t.sort(function(e,t){return i(e.start,t.start)});var n=t[0],r;for(var s=1;s<t.length;s++){r=n,n=t[s];var o=i(r.end,n.start);if(o<0)continue;if(o==0&&!r.isEmpty()&&!n.isEmpty())continue;i(r.end,n.end)<0&&(r.end.row=n.end.row,r.end.column=n.end.column),t.splice(s,1),e.push(n),n=r,s--}return this.ranges=t,e},this.contains=function(e,t){return this.pointIndex({row:e,column:t})>=0},this.containsPoint=function(e){return this.pointIndex(e)>=0},this.rangeAtPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges[t]},this.clipRows=function(e,t){var n=this.ranges;if(n[0].start.row>t||n[n.length-1].start.row<e)return[];var r=this.pointIndex({row:e,column:0});r<0&&(r=-r-1);var i=this.pointIndex({row:t,column:0},r);i<0&&(i=-i-1);var s=[];for(var o=r;o<i;o++)s.push(n[o]);return s},this.removeAll=function(){return this.ranges.splice(0,this.ranges.length)},this.attach=function(e){this.session&&this.detach(),this.session=e,this.onChange=this.$onChange.bind(this),this.session.on("change",this.onChange)},this.detach=function(){if(!this.session)return;this.session.removeListener("change",this.onChange),this.session=null},this.$onChange=function(e){if(e.action=="insert")var t=e.start,n=e.end;else var n=e.start,t=e.end;var r=t.row,i=n.row,s=i-r,o=-t.column+n.column,u=this.ranges;for(var a=0,f=u.length;a<f;a++){var l=u[a];if(l.end.row<r)continue;if(l.start.row>r)break;l.start.row==r&&l.start.column>=t.column&&(l.start.column!=t.column||!this.$insertRight)&&(l.start.column+=o,l.start.row+=s);if(l.end.row==r&&l.end.column>=t.column){if(l.end.column==t.column&&this.$insertRight)continue;l.end.column==t.column&&o>0&&a<f-1&&l.end.column>l.start.column&&l.end.column==u[a+1].start.column&&(l.end.column-=o),l.end.column+=o,l.end.row+=s}}if(s!=0&&a<f)for(;a<f;a++){var l=u[a];l.start.row+=s,l.end.row+=s}}}).call(s.prototype),t.RangeList=s}),ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"],function(e,t,n){"use strict";function u(e,t){e.row-=t.row,e.row==0&&(e.column-=t.column)}function a(e,t){u(e.start,t),u(e.end,t)}function f(e,t){e.row==0&&(e.column+=t.column),e.row+=t.row}function l(e,t){f(e.start,t),f(e.end,t)}var r=e("../range").Range,i=e("../range_list").RangeList,s=e("../lib/oop"),o=t.Fold=function(e,t){this.foldLine=null,this.placeholder=t,this.range=e,this.start=e.start,this.end=e.end,this.sameRow=e.start.row==e.end.row,this.subFolds=this.ranges=[]};s.inherits(o,i),function(){this.toString=function(){return'"'+this.placeholder+'" '+this.range.toString()},this.setFoldLine=function(e){this.foldLine=e,this.subFolds.forEach(function(t){t.setFoldLine(e)})},this.clone=function(){var e=this.range.clone(),t=new o(e,this.placeholder);return this.subFolds.forEach(function(e){t.subFolds.push(e.clone())}),t.collapseChildren=this.collapseChildren,t},this.addSubFold=function(e){if(this.range.isEqual(e))return;if(!this.range.containsRange(e))throw new Error("A fold can't intersect already existing fold"+e.range+this.range);a(e,this.start);var t=e.start.row,n=e.start.column;for(var r=0,i=-1;r<this.subFolds.length;r++){i=this.subFolds[r].range.compare(t,n);if(i!=1)break}var s=this.subFolds[r];if(i==0)return s.addSubFold(e);var t=e.range.end.row,n=e.range.end.column;for(var o=r,i=-1;o<this.subFolds.length;o++){i=this.subFolds[o].range.compare(t,n);if(i!=1)break}var u=this.subFolds[o];if(i==0)throw new Error("A fold can't intersect already existing fold"+e.range+this.range);var f=this.subFolds.splice(r,o-r,e);return e.setFoldLine(this.foldLine),e},this.restoreRange=function(e){return l(e,this.start)}}.call(o.prototype)}),ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"],function(e,t,n){"use strict";function u(){this.getFoldAt=function(e,t,n){var r=this.getFoldLine(e);if(!r)return null;var i=r.folds;for(var s=0;s<i.length;s++){var o=i[s];if(o.range.contains(e,t)){if(n==1&&o.range.isEnd(e,t))continue;if(n==-1&&o.range.isStart(e,t))continue;return o}}},this.getFoldsInRange=function(e){var t=e.start,n=e.end,r=this.$foldData,i=[];t.column+=1,n.column-=1;for(var s=0;s<r.length;s++){var o=r[s].range.compareRange(e);if(o==2)continue;if(o==-2)break;var u=r[s].folds;for(var a=0;a<u.length;a++){var f=u[a];o=f.range.compareRange(e);if(o==-2)break;if(o==2)continue;if(o==42)break;i.push(f)}}return t.column-=1,n.column+=1,i},this.getFoldsInRangeList=function(e){if(Array.isArray(e)){var t=[];e.forEach(function(e){t=t.concat(this.getFoldsInRange(e))},this)}else var t=this.getFoldsInRange(e);return t},this.getAllFolds=function(){var e=[],t=this.$foldData;for(var n=0;n<t.length;n++)for(var r=0;r<t[n].folds.length;r++)e.push(t[n].folds[r]);return e},this.getFoldStringAt=function(e,t,n,r){r=r||this.getFoldLine(e);if(!r)return null;var i={end:{column:0}},s,o;for(var u=0;u<r.folds.length;u++){o=r.folds[u];var a=o.range.compareEnd(e,t);if(a==-1){s=this.getLine(o.start.row).substring(i.end.column,o.start.column);break}if(a===0)return null;i=o}return s||(s=this.getLine(o.start.row).substring(i.end.column)),n==-1?s.substring(0,t-i.end.column):n==1?s.substring(t-i.end.column):s},this.getFoldLine=function(e,t){var n=this.$foldData,r=0;t&&(r=n.indexOf(t)),r==-1&&(r=0);for(r;r<n.length;r++){var i=n[r];if(i.start.row<=e&&i.end.row>=e)return i;if(i.end.row>e)return null}return null},this.getNextFoldLine=function(e,t){var n=this.$foldData,r=0;t&&(r=n.indexOf(t)),r==-1&&(r=0);for(r;r<n.length;r++){var i=n[r];if(i.end.row>=e)return i}return null},this.getFoldedRowCount=function(e,t){var n=this.$foldData,r=t-e+1;for(var i=0;i<n.length;i++){var s=n[i],o=s.end.row,u=s.start.row;if(o>=t){u<t&&(u>=e?r-=t-u:r=0);break}o>=e&&(u>=e?r-=o-u:r-=o-e+1)}return r},this.$addFoldLine=function(e){return this.$foldData.push(e),this.$foldData.sort(function(e,t){return e.start.row-t.start.row}),e},this.addFold=function(e,t){var n=this.$foldData,r=!1,o;e instanceof s?o=e:(o=new s(t,e),o.collapseChildren=t.collapseChildren),this.$clipRangeToDocument(o.range);var u=o.start.row,a=o.start.column,f=o.end.row,l=o.end.column;if(u<f||u==f&&a<=l-2){var c=this.getFoldAt(u,a,1),h=this.getFoldAt(f,l,-1);if(c&&h==c)return c.addSubFold(o);c&&!c.range.isStart(u,a)&&this.removeFold(c),h&&!h.range.isEnd(f,l)&&this.removeFold(h);var p=this.getFoldsInRange(o.range);p.length>0&&(this.removeFolds(p),p.forEach(function(e){o.addSubFold(e)}));for(var d=0;d<n.length;d++){var v=n[d];if(f==v.start.row){v.addFold(o),r=!0;break}if(u==v.end.row){v.addFold(o),r=!0;if(!o.sameRow){var m=n[d+1];if(m&&m.start.row==f){v.merge(m);break}}break}if(f<=v.start.row)break}return r||(v=this.$addFoldLine(new i(this.$foldData,o))),this.$useWrapMode?this.$updateWrapData(v.start.row,v.start.row):this.$updateRowLengthCache(v.start.row,v.start.row),this.$modified=!0,this._signal("changeFold",{data:o,action:"add"}),o}throw new Error("The range has to be at least 2 characters width")},this.addFolds=function(e){e.forEach(function(e){this.addFold(e)},this)},this.removeFold=function(e){var t=e.foldLine,n=t.start.row,r=t.end.row,i=this.$foldData,s=t.folds;if(s.length==1)i.splice(i.indexOf(t),1);else if(t.range.isEnd(e.end.row,e.end.column))s.pop(),t.end.row=s[s.length-1].end.row,t.end.column=s[s.length-1].end.column;else if(t.range.isStart(e.start.row,e.start.column))s.shift(),t.start.row=s[0].start.row,t.start.column=s[0].start.column;else if(e.sameRow)s.splice(s.indexOf(e),1);else{var o=t.split(e.start.row,e.start.column);s=o.folds,s.shift(),o.start.row=s[0].start.row,o.start.column=s[0].start.column}this.$updating||(this.$useWrapMode?this.$updateWrapData(n,r):this.$updateRowLengthCache(n,r)),this.$modified=!0,this._signal("changeFold",{data:e,action:"remove"})},this.removeFolds=function(e){var t=[];for(var n=0;n<e.length;n++)t.push(e[n]);t.forEach(function(e){this.removeFold(e)},this),this.$modified=!0},this.expandFold=function(e){this.removeFold(e),e.subFolds.forEach(function(t){e.restoreRange(t),this.addFold(t)},this),e.collapseChildren>0&&this.foldAll(e.start.row+1,e.end.row,e.collapseChildren-1),e.subFolds=[]},this.expandFolds=function(e){e.forEach(function(e){this.expandFold(e)},this)},this.unfold=function(e,t){var n,i;e==null?(n=new r(0,0,this.getLength(),0),t=!0):typeof e=="number"?n=new r(e,0,e,this.getLine(e).length):"row"in e?n=r.fromPoints(e,e):n=e,i=this.getFoldsInRangeList(n);if(t)this.removeFolds(i);else{var s=i;while(s.length)this.expandFolds(s),s=this.getFoldsInRangeList(n)}if(i.length)return i},this.isRowFolded=function(e,t){return!!this.getFoldLine(e,t)},this.getRowFoldEnd=function(e,t){var n=this.getFoldLine(e,t);return n?n.end.row:e},this.getRowFoldStart=function(e,t){var n=this.getFoldLine(e,t);return n?n.start.row:e},this.getFoldDisplayLine=function(e,t,n,r,i){r==null&&(r=e.start.row),i==null&&(i=0),t==null&&(t=e.end.row),n==null&&(n=this.getLine(t).length);var s=this.doc,o="";return e.walk(function(e,t,n,u){if(t<r)return;if(t==r){if(n<i)return;u=Math.max(i,u)}e!=null?o+=e:o+=s.getLine(t).substring(u,n)},t,n),o},this.getDisplayLine=function(e,t,n,r){var i=this.getFoldLine(e);if(!i){var s;return s=this.doc.getLine(e),s.substring(r||0,t||s.length)}return this.getFoldDisplayLine(i,e,t,n,r)},this.$cloneFoldData=function(){var e=[];return e=this.$foldData.map(function(t){var n=t.folds.map(function(e){return e.clone()});return new i(e,n)}),e},this.toggleFold=function(e){var t=this.selection,n=t.getRange(),r,i;if(n.isEmpty()){var s=n.start;r=this.getFoldAt(s.row,s.column);if(r){this.expandFold(r);return}(i=this.findMatchingBracket(s))?n.comparePoint(i)==1?n.end=i:(n.start=i,n.start.column++,n.end.column--):(i=this.findMatchingBracket({row:s.row,column:s.column+1}))?(n.comparePoint(i)==1?n.end=i:n.start=i,n.start.column++):n=this.getCommentFoldRange(s.row,s.column)||n}else{var o=this.getFoldsInRange(n);if(e&&o.length){this.expandFolds(o);return}o.length==1&&(r=o[0])}r||(r=this.getFoldAt(n.start.row,n.start.column));if(r&&r.range.toString()==n.toString()){this.expandFold(r);return}var u="...";if(!n.isMultiLine()){u=this.getTextRange(n);if(u.length<4)return;u=u.trim().substring(0,2)+".."}this.addFold(u,n)},this.getCommentFoldRange=function(e,t,n){var i=new o(this,e,t),s=i.getCurrentToken();if(s&&/^comment|string/.test(s.type)){var u=new r,a=new RegExp(s.type.replace(/\..*/,"\\."));if(n!=1){do s=i.stepBackward();while(s&&a.test(s.type));i.stepForward()}u.start.row=i.getCurrentTokenRow(),u.start.column=i.getCurrentTokenColumn()+2,i=new o(this,e,t);if(n!=-1){do s=i.stepForward();while(s&&a.test(s.type));s=i.stepBackward()}else s=i.getCurrentToken();return u.end.row=i.getCurrentTokenRow(),u.end.column=i.getCurrentTokenColumn()+s.value.length-2,u}},this.foldAll=function(e,t,n){n==undefined&&(n=1e5);var r=this.foldWidgets;if(!r)return;t=t||this.getLength(),e=e||0;for(var i=e;i<t;i++){r[i]==null&&(r[i]=this.getFoldWidget(i));if(r[i]!="start")continue;var s=this.getFoldWidgetRange(i);if(s&&s.isMultiLine()&&s.end.row<=t&&s.start.row>=e){i=s.end.row;try{var o=this.addFold("...",s);o&&(o.collapseChildren=n)}catch(u){}}}},this.$foldStyles={manual:1,markbegin:1,markbeginend:1},this.$foldStyle="markbegin",this.setFoldStyle=function(e){if(!this.$foldStyles[e])throw new Error("invalid fold style: "+e+"["+Object.keys(this.$foldStyles).join(", ")+"]");if(this.$foldStyle==e)return;this.$foldStyle=e,e=="manual"&&this.unfold();var t=this.$foldMode;this.$setFolding(null),this.$setFolding(t)},this.$setFolding=function(e){if(this.$foldMode==e)return;this.$foldMode=e,this.off("change",this.$updateFoldWidgets),this.off("tokenizerUpdate",this.$tokenizerUpdateFoldWidgets),this._signal("changeAnnotation");if(!e||this.$foldStyle=="manual"){this.foldWidgets=null;return}this.foldWidgets=[],this.getFoldWidget=e.getFoldWidget.bind(e,this,this.$foldStyle),this.getFoldWidgetRange=e.getFoldWidgetRange.bind(e,this,this.$foldStyle),this.$updateFoldWidgets=this.updateFoldWidgets.bind(this),this.$tokenizerUpdateFoldWidgets=this.tokenizerUpdateFoldWidgets.bind(this),this.on("change",this.$updateFoldWidgets),this.on("tokenizerUpdate",this.$tokenizerUpdateFoldWidgets)},this.getParentFoldRangeData=function(e,t){var n=this.foldWidgets;if(!n||t&&n[e])return{};var r=e-1,i;while(r>=0){var s=n[r];s==null&&(s=n[r]=this.getFoldWidget(r));if(s=="start"){var o=this.getFoldWidgetRange(r);i||(i=o);if(o&&o.end.row>=e)break}r--}return{range:r!==-1&&o,firstRange:i}},this.onFoldWidgetClick=function(e,t){t=t.domEvent;var n={children:t.shiftKey,all:t.ctrlKey||t.metaKey,siblings:t.altKey},r=this.$toggleFoldWidget(e,n);if(!r){var i=t.target||t.srcElement;i&&/ace_fold-widget/.test(i.className)&&(i.className+=" ace_invalid")}},this.$toggleFoldWidget=function(e,t){if(!this.getFoldWidget)return;var n=this.getFoldWidget(e),r=this.getLine(e),i=n==="end"?-1:1,s=this.getFoldAt(e,i===-1?0:r.length,i);if(s)return t.children||t.all?this.removeFold(s):this.expandFold(s),s;var o=this.getFoldWidgetRange(e,!0);if(o&&!o.isMultiLine()){s=this.getFoldAt(o.start.row,o.start.column,1);if(s&&o.isEqual(s.range))return this.removeFold(s),s}if(t.siblings){var u=this.getParentFoldRangeData(e);if(u.range)var a=u.range.start.row+1,f=u.range.end.row;this.foldAll(a,f,t.all?1e4:0)}else t.children?(f=o?o.end.row:this.getLength(),this.foldAll(e+1,f,t.all?1e4:0)):o&&(t.all&&(o.collapseChildren=1e4),this.addFold("...",o));return o},this.toggleFoldWidget=function(e){var t=this.selection.getCursor().row;t=this.getRowFoldStart(t);var n=this.$toggleFoldWidget(t,{});if(n)return;var r=this.getParentFoldRangeData(t,!0);n=r.range||r.firstRange;if(n){t=n.start.row;var i=this.getFoldAt(t,this.getLine(t).length,1);i?this.removeFold(i):this.addFold("...",n)}},this.updateFoldWidgets=function(e){var t=e.start.row,n=e.end.row-t;if(n===0)this.foldWidgets[t]=null;else if(e.action=="remove")this.foldWidgets.splice(t,n+1,null);else{var r=Array(n+1);r.unshift(t,1),this.foldWidgets.splice.apply(this.foldWidgets,r)}},this.tokenizerUpdateFoldWidgets=function(e){var t=e.data;t.first!=t.last&&this.foldWidgets.length>t.first&&this.foldWidgets.splice(t.first,this.foldWidgets.length)}}var r=e("../range").Range,i=e("./fold_line").FoldLine,s=e("./fold").Fold,o=e("../token_iterator").TokenIterator;t.Folding=u}),ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"],function(e,t,n){"use strict";function s(){this.findMatchingBracket=function(e,t){if(e.column==0)return null;var n=t||this.getLine(e.row).charAt(e.column-1);if(n=="")return null;var r=n.match(/([\(\[\{])|([\)\]\}])/);return r?r[1]?this.$findClosingBracket(r[1],e):this.$findOpeningBracket(r[2],e):null},this.getBracketRange=function(e){var t=this.getLine(e.row),n=!0,r,s=t.charAt(e.column-1),o=s&&s.match(/([\(\[\{])|([\)\]\}])/);o||(s=t.charAt(e.column),e={row:e.row,column:e.column+1},o=s&&s.match(/([\(\[\{])|([\)\]\}])/),n=!1);if(!o)return null;if(o[1]){var u=this.$findClosingBracket(o[1],e);if(!u)return null;r=i.fromPoints(e,u),n||(r.end.column++,r.start.column--),r.cursor=r.end}else{var u=this.$findOpeningBracket(o[2],e);if(!u)return null;r=i.fromPoints(u,e),n||(r.start.column++,r.end.column--),r.cursor=r.start}return r},this.$brackets={")":"(","(":")","]":"[","[":"]","{":"}","}":"{"},this.$findOpeningBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("rparen",".paren").replace(/\b(?:end)\b/,"(?:start|begin|end)")+")+"));var a=t.column-o.getCurrentTokenColumn()-2,f=u.value;for(;;){while(a>=0){var l=f.charAt(a);if(l==i){s-=1;if(s==0)return{row:o.getCurrentTokenRow(),column:a+o.getCurrentTokenColumn()}}else l==e&&(s+=1);a-=1}do u=o.stepBackward();while(u&&!n.test(u.type));if(u==null)break;f=u.value,a=f.length-1}return null},this.$findClosingBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("lparen",".paren").replace(/\b(?:start|begin)\b/,"(?:start|begin|end)")+")+"));var a=t.column-o.getCurrentTokenColumn();for(;;){var f=u.value,l=f.length;while(a<l){var c=f.charAt(a);if(c==i){s-=1;if(s==0)return{row:o.getCurrentTokenRow(),column:a+o.getCurrentTokenColumn()}}else c==e&&(s+=1);a+=1}do u=o.stepForward();while(u&&!n.test(u.type));if(u==null)break;a=0}return null}}var r=e("../token_iterator").TokenIterator,i=e("../range").Range;t.BracketMatch=s}),ace.define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/edit_session/folding","ace/edit_session/bracket_match"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/lang"),s=e("./config"),o=e("./lib/event_emitter").EventEmitter,u=e("./selection").Selection,a=e("./mode/text").Mode,f=e("./range").Range,l=e("./document").Document,c=e("./background_tokenizer").BackgroundTokenizer,h=e("./search_highlight").SearchHighlight,p=function(e,t){this.$breakpoints=[],this.$decorations=[],this.$frontMarkers={},this.$backMarkers={},this.$markerId=1,this.$undoSelect=!0,this.$foldData=[],this.id="session"+ ++p.$uid,this.$foldData.toString=function(){return this.join("\n")},this.on("changeFold",this.onChangeFold.bind(this)),this.$onChange=this.onChange.bind(this);if(typeof e!="object"||!e.getLine)e=new l(e);this.setDocument(e),this.selection=new u(this),s.resetOptions(this),this.setMode(t),s._signal("session",this)};(function(){function m(e){return e<4352?!1:e>=4352&&e<=4447||e>=4515&&e<=4519||e>=4602&&e<=4607||e>=9001&&e<=9002||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12283||e>=12288&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12589||e>=12593&&e<=12686||e>=12688&&e<=12730||e>=12736&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=13054||e>=13056&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=55216&&e<=55238||e>=55243&&e<=55291||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510}r.implement(this,o),this.setDocument=function(e){this.doc&&this.doc.removeListener("change",this.$onChange),this.doc=e,e.on("change",this.$onChange),this.bgTokenizer&&this.bgTokenizer.setDocument(this.getDocument()),this.resetCaches()},this.getDocument=function(){return this.doc},this.$resetRowCache=function(e){if(!e){this.$docRowCache=[],this.$screenRowCache=[];return}var t=this.$docRowCache.length,n=this.$getRowCacheIndex(this.$docRowCache,e)+1;t>n&&(this.$docRowCache.splice(n,t),this.$screenRowCache.splice(n,t))},this.$getRowCacheIndex=function(e,t){var n=0,r=e.length-1;while(n<=r){var i=n+r>>1,s=e[i];if(t>s)n=i+1;else{if(!(t<s))return i;r=i-1}}return n-1},this.resetCaches=function(){this.$modified=!0,this.$wrapData=[],this.$rowLengthCache=[],this.$resetRowCache(0),this.bgTokenizer&&this.bgTokenizer.start(0)},this.onChangeFold=function(e){var t=e.data;this.$resetRowCache(t.start.row)},this.onChange=function(e){this.$modified=!0,this.$resetRowCache(e.start.row);var t=this.$updateInternalDataOnChange(e);!this.$fromUndo&&this.$undoManager&&!e.ignore&&(this.$deltasDoc.push(e),t&&t.length!=0&&this.$deltasFold.push({action:"removeFolds",folds:t}),this.$informUndoManager.schedule()),this.bgTokenizer&&this.bgTokenizer.$updateOnChange(e),this._signal("change",e)},this.setValue=function(e){this.doc.setValue(e),this.selection.moveTo(0,0),this.$resetRowCache(0),this.$deltas=[],this.$deltasDoc=[],this.$deltasFold=[],this.setUndoManager(this.$undoManager),this.getUndoManager().reset()},this.getValue=this.toString=function(){return this.doc.getValue()},this.getSelection=function(){return this.selection},this.getState=function(e){return this.bgTokenizer.getState(e)},this.getTokens=function(e){return this.bgTokenizer.getTokens(e)},this.getTokenAt=function(e,t){var n=this.bgTokenizer.getTokens(e),r,i=0;if(t==null)s=n.length-1,i=this.getLine(e).length;else for(var s=0;s<n.length;s++){i+=n[s].value.length;if(i>=t)break}return r=n[s],r?(r.index=s,r.start=i-r.value.length,r):null},this.setUndoManager=function(e){this.$undoManager=e,this.$deltas=[],this.$deltasDoc=[],this.$deltasFold=[],this.$informUndoManager&&this.$informUndoManager.cancel();if(e){var t=this;this.$syncInformUndoManager=function(){t.$informUndoManager.cancel(),t.$deltasFold.length&&(t.$deltas.push({group:"fold",deltas:t.$deltasFold}),t.$deltasFold=[]),t.$deltasDoc.length&&(t.$deltas.push({group:"doc",deltas:t.$deltasDoc}),t.$deltasDoc=[]),t.$deltas.length>0&&e.execute({action:"aceupdate",args:[t.$deltas,t],merge:t.mergeUndoDeltas}),t.mergeUndoDeltas=!1,t.$deltas=[]},this.$informUndoManager=i.delayedCall(this.$syncInformUndoManager)}},this.markUndoGroup=function(){this.$syncInformUndoManager&&this.$syncInformUndoManager()},this.$defaultUndoManager={undo:function(){},redo:function(){},reset:function(){}},this.getUndoManager=function(){return this.$undoManager||this.$defaultUndoManager},this.getTabString=function(){return this.getUseSoftTabs()?i.stringRepeat(" ",this.getTabSize()):" "},this.setUseSoftTabs=function(e){this.setOption("useSoftTabs",e)},this.getUseSoftTabs=function(){return this.$useSoftTabs&&!this.$mode.$indentWithTabs},this.setTabSize=function(e){this.setOption("tabSize",e)},this.getTabSize=function(){return this.$tabSize},this.isTabStop=function(e){return this.$useSoftTabs&&e.column%this.$tabSize===0},this.$overwrite=!1,this.setOverwrite=function(e){this.setOption("overwrite",e)},this.getOverwrite=function(){return this.$overwrite},this.toggleOverwrite=function(){this.setOverwrite(!this.$overwrite)},this.addGutterDecoration=function(e,t){this.$decorations[e]||(this.$decorations[e]=""),this.$decorations[e]+=" "+t,this._signal("changeBreakpoint",{})},this.removeGutterDecoration=function(e,t){this.$decorations[e]=(this.$decorations[e]||"").replace(" "+t,""),this._signal("changeBreakpoint",{})},this.getBreakpoints=function(){return this.$breakpoints},this.setBreakpoints=function(e){this.$breakpoints=[];for(var t=0;t<e.length;t++)this.$breakpoints[e[t]]="ace_breakpoint";this._signal("changeBreakpoint",{})},this.clearBreakpoints=function(){this.$breakpoints=[],this._signal("changeBreakpoint",{})},this.setBreakpoint=function(e,t){t===undefined&&(t="ace_breakpoint"),t?this.$breakpoints[e]=t:delete this.$breakpoints[e],this._signal("changeBreakpoint",{})},this.clearBreakpoint=function(e){delete this.$breakpoints[e],this._signal("changeBreakpoint",{})},this.addMarker=function(e,t,n,r){var i=this.$markerId++,s={range:e,type:n||"line",renderer:typeof n=="function"?n:null,clazz:t,inFront:!!r,id:i};return r?(this.$frontMarkers[i]=s,this._signal("changeFrontMarker")):(this.$backMarkers[i]=s,this._signal("changeBackMarker")),i},this.addDynamicMarker=function(e,t){if(!e.update)return;var n=this.$markerId++;return e.id=n,e.inFront=!!t,t?(this.$frontMarkers[n]=e,this._signal("changeFrontMarker")):(this.$backMarkers[n]=e,this._signal("changeBackMarker")),e},this.removeMarker=function(e){var t=this.$frontMarkers[e]||this.$backMarkers[e];if(!t)return;var n=t.inFront?this.$frontMarkers:this.$backMarkers;t&&(delete n[e],this._signal(t.inFront?"changeFrontMarker":"changeBackMarker"))},this.getMarkers=function(e){return e?this.$frontMarkers:this.$backMarkers},this.highlight=function(e){if(!this.$searchHighlight){var t=new h(null,"ace_selected-word","text");this.$searchHighlight=this.addDynamicMarker(t)}this.$searchHighlight.setRegexp(e)},this.highlightLines=function(e,t,n,r){typeof t!="number"&&(n=t,t=e),n||(n="ace_step");var i=new f(e,0,t,Infinity);return i.id=this.addMarker(i,n,"fullLine",r),i},this.setAnnotations=function(e){this.$annotations=e,this._signal("changeAnnotation",{})},this.getAnnotations=function(){return this.$annotations||[]},this.clearAnnotations=function(){this.setAnnotations([])},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r?\n)/m);t?this.$autoNewLine=t[1]:this.$autoNewLine="\n"},this.getWordRange=function(e,t){var n=this.getLine(e),r=!1;t>0&&(r=!!n.charAt(t-1).match(this.tokenRe)),r||(r=!!n.charAt(t).match(this.tokenRe));if(r)var i=this.tokenRe;else if(/^\s+$/.test(n.slice(t-1,t+1)))var i=/\s/;else var i=this.nonTokenRe;var s=t;if(s>0){do s--;while(s>=0&&n.charAt(s).match(i));s++}var o=t;while(o<n.length&&n.charAt(o).match(i))o++;return new f(e,s,e,o)},this.getAWordRange=function(e,t){var n=this.getWordRange(e,t),r=this.getLine(n.end.row);while(r.charAt(n.end.column).match(/[ \t]/))n.end.column+=1;return n},this.setNewLineMode=function(e){this.doc.setNewLineMode(e)},this.getNewLineMode=function(){return this.doc.getNewLineMode()},this.setUseWorker=function(e){this.setOption("useWorker",e)},this.getUseWorker=function(){return this.$useWorker},this.onReloadTokenizer=function(e){var t=e.data;this.bgTokenizer.start(t.first),this._signal("tokenizerUpdate",e)},this.$modes={},this.$mode=null,this.$modeId=null,this.setMode=function(e,t){if(e&&typeof e=="object"){if(e.getTokenizer)return this.$onChangeMode(e);var n=e,r=n.path}else r=e||"ace/mode/text";this.$modes["ace/mode/text"]||(this.$modes["ace/mode/text"]=new a);if(this.$modes[r]&&!n){this.$onChangeMode(this.$modes[r]),t&&t();return}this.$modeId=r,s.loadModule(["mode",r],function(e){if(this.$modeId!==r)return t&&t();this.$modes[r]&&!n?this.$onChangeMode(this.$modes[r]):e&&e.Mode&&(e=new e.Mode(n),n||(this.$modes[r]=e,e.$id=r),this.$onChangeMode(e)),t&&t()}.bind(this)),this.$mode||this.$onChangeMode(this.$modes["ace/mode/text"],!0)},this.$onChangeMode=function(e,t){t||(this.$modeId=e.$id);if(this.$mode===e)return;this.$mode=e,this.$stopWorker(),this.$useWorker&&this.$startWorker();var n=e.getTokenizer();if(n.addEventListener!==undefined){var r=this.onReloadTokenizer.bind(this);n.addEventListener("update",r)}if(!this.bgTokenizer){this.bgTokenizer=new c(n);var i=this;this.bgTokenizer.addEventListener("update",function(e){i._signal("tokenizerUpdate",e)})}else this.bgTokenizer.setTokenizer(n);this.bgTokenizer.setDocument(this.getDocument()),this.tokenRe=e.tokenRe,this.nonTokenRe=e.nonTokenRe,t||(e.attachToSession&&e.attachToSession(this),this.$options.wrapMethod.set.call(this,this.$wrapMethod),this.$setFolding(e.foldingRules),this.bgTokenizer.start(0),this._emit("changeMode"))},this.$stopWorker=function(){this.$worker&&(this.$worker.terminate(),this.$worker=null)},this.$startWorker=function(){try{this.$worker=this.$mode.createWorker(this)}catch(e){s.warn("Could not load worker",e),this.$worker=null}},this.getMode=function(){return this.$mode},this.$scrollTop=0,this.setScrollTop=function(e){if(this.$scrollTop===e||isNaN(e))return;this.$scrollTop=e,this._signal("changeScrollTop",e)},this.getScrollTop=function(){return this.$scrollTop},this.$scrollLeft=0,this.setScrollLeft=function(e){if(this.$scrollLeft===e||isNaN(e))return;this.$scrollLeft=e,this._signal("changeScrollLeft",e)},this.getScrollLeft=function(){return this.$scrollLeft},this.getScreenWidth=function(){return this.$computeWidth(),this.lineWidgets?Math.max(this.getLineWidgetMaxWidth(),this.screenWidth):this.screenWidth},this.getLineWidgetMaxWidth=function(){if(this.lineWidgetsWidth!=null)return this.lineWidgetsWidth;var e=0;return this.lineWidgets.forEach(function(t){t&&t.screenWidth>e&&(e=t.screenWidth)}),this.lineWidgetWidth=e},this.$computeWidth=function(e){if(this.$modified||e){this.$modified=!1;if(this.$useWrapMode)return this.screenWidth=this.$wrapLimit;var t=this.doc.getAllLines(),n=this.$rowLengthCache,r=0,i=0,s=this.$foldData[i],o=s?s.start.row:Infinity,u=t.length;for(var a=0;a<u;a++){if(a>o){a=s.end.row+1;if(a>=u)break;s=this.$foldData[i++],o=s?s.start.row:Infinity}n[a]==null&&(n[a]=this.$getStringScreenWidth(t[a])[0]),n[a]>r&&(r=n[a])}this.screenWidth=r}},this.getLine=function(e){return this.doc.getLine(e)},this.getLines=function(e,t){return this.doc.getLines(e,t)},this.getLength=function(){return this.doc.getLength()},this.getTextRange=function(e){return this.doc.getTextRange(e||this.selection.getRange())},this.insert=function(e,t){return this.doc.insert(e,t)},this.remove=function(e){return this.doc.remove(e)},this.removeFullLines=function(e,t){return this.doc.removeFullLines(e,t)},this.undoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;var n=null;for(var r=e.length-1;r!=-1;r--){var i=e[r];i.group=="doc"?(this.doc.revertDeltas(i.deltas),n=this.$getUndoSelection(i.deltas,!0,n)):i.deltas.forEach(function(e){this.addFolds(e.folds)},this)}return this.$fromUndo=!1,n&&this.$undoSelect&&!t&&this.selection.setSelectionRange(n),n},this.redoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;var n=null;for(var r=0;r<e.length;r++){var i=e[r];i.group=="doc"&&(this.doc.applyDeltas(i.deltas),n=this.$getUndoSelection(i.deltas,!1,n))}return this.$fromUndo=!1,n&&this.$undoSelect&&!t&&this.selection.setSelectionRange(n),n},this.setUndoSelect=function(e){this.$undoSelect=e},this.$getUndoSelection=function(e,t,n){function r(e){return t?e.action!=="insert":e.action==="insert"}var i=e[0],s,o,u=!1;r(i)?(s=f.fromPoints(i.start,i.end),u=!0):(s=f.fromPoints(i.start,i.start),u=!1);for(var a=1;a<e.length;a++)i=e[a],r(i)?(o=i.start,s.compare(o.row,o.column)==-1&&s.setStart(o),o=i.end,s.compare(o.row,o.column)==1&&s.setEnd(o),u=!0):(o=i.start,s.compare(o.row,o.column)==-1&&(s=f.fromPoints(i.start,i.start)),u=!1);if(n!=null){f.comparePoints(n.start,s.start)===0&&(n.start.column+=s.end.column-s.start.column,n.end.column+=s.end.column-s.start.column);var l=n.compareRange(s);l==1?s.setStart(n.start):l==-1&&s.setEnd(n.end)}return s},this.replace=function(e,t){return this.doc.replace(e,t)},this.moveText=function(e,t,n){var r=this.getTextRange(e),i=this.getFoldsInRange(e),s=f.fromPoints(t,t);if(!n){this.remove(e);var o=e.start.row-e.end.row,u=o?-e.end.column:e.start.column-e.end.column;u&&(s.start.row==e.end.row&&s.start.column>e.end.column&&(s.start.column+=u),s.end.row==e.end.row&&s.end.column>e.end.column&&(s.end.column+=u)),o&&s.start.row>=e.end.row&&(s.start.row+=o,s.end.row+=o)}s.end=this.insert(s.start,r);if(i.length){var a=e.start,l=s.start,o=l.row-a.row,u=l.column-a.column;this.addFolds(i.map(function(e){return e=e.clone(),e.start.row==a.row&&(e.start.column+=u),e.end.row==a.row&&(e.end.column+=u),e.start.row+=o,e.end.row+=o,e}))}return s},this.indentRows=function(e,t,n){n=n.replace(/\t/g,this.getTabString());for(var r=e;r<=t;r++)this.doc.insertInLine({row:r,column:0},n)},this.outdentRows=function(e){var t=e.collapseRows(),n=new f(0,0,0,0),r=this.getTabSize();for(var i=t.start.row;i<=t.end.row;++i){var s=this.getLine(i);n.start.row=i,n.end.row=i;for(var o=0;o<r;++o)if(s.charAt(o)!=" ")break;o<r&&s.charAt(o)==" "?(n.start.column=o,n.end.column=o+1):(n.start.column=0,n.end.column=o),this.remove(n)}},this.$moveLines=function(e,t,n){e=this.getRowFoldStart(e),t=this.getRowFoldEnd(t);if(n<0){var r=this.getRowFoldStart(e+n);if(r<0)return 0;var i=r-e}else if(n>0){var r=this.getRowFoldEnd(t+n);if(r>this.doc.getLength()-1)return 0;var i=r-t}else{e=this.$clipRowToDocument(e),t=this.$clipRowToDocument(t);var i=t-e+1}var s=new f(e,0,t,Number.MAX_VALUE),o=this.getFoldsInRange(s).map(function(e){return e=e.clone(),e.start.row+=i,e.end.row+=i,e}),u=n==0?this.doc.getLines(e,t):this.doc.removeFullLines(e,t);return this.doc.insertFullLines(e+i,u),o.length&&this.addFolds(o),i},this.moveLinesUp=function(e,t){return this.$moveLines(e,t,-1)},this.moveLinesDown=function(e,t){return this.$moveLines(e,t,1)},this.duplicateLines=function(e,t){return this.$moveLines(e,t,0)},this.$clipRowToDocument=function(e){return Math.max(0,Math.min(e,this.doc.getLength()-1))},this.$clipColumnToRow=function(e,t){return t<0?0:Math.min(this.doc.getLine(e).length,t)},this.$clipPositionToDocument=function(e,t){t=Math.max(0,t);if(e<0)e=0,t=0;else{var n=this.doc.getLength();e>=n?(e=n-1,t=this.doc.getLine(n-1).length):t=Math.min(this.doc.getLine(e).length,t)}return{row:e,column:t}},this.$clipRangeToDocument=function(e){e.start.row<0?(e.start.row=0,e.start.column=0):e.start.column=this.$clipColumnToRow(e.start.row,e.start.column);var t=this.doc.getLength()-1;return e.end.row>t?(e.end.row=t,e.end.column=this.doc.getLine(t).length):e.end.column=this.$clipColumnToRow(e.end.row,e.end.column),e},this.$wrapLimit=80,this.$useWrapMode=!1,this.$wrapLimitRange={min:null,max:null},this.setUseWrapMode=function(e){if(e!=this.$useWrapMode){this.$useWrapMode=e,this.$modified=!0,this.$resetRowCache(0);if(e){var t=this.getLength();this.$wrapData=Array(t),this.$updateWrapData(0,t-1)}this._signal("changeWrapMode")}},this.getUseWrapMode=function(){return this.$useWrapMode},this.setWrapLimitRange=function(e,t){if(this.$wrapLimitRange.min!==e||this.$wrapLimitRange.max!==t)this.$wrapLimitRange={min:e,max:t},this.$modified=!0,this.$useWrapMode&&this._signal("changeWrapMode")},this.adjustWrapLimit=function(e,t){var n=this.$wrapLimitRange;n.max<0&&(n={min:t,max:t});var r=this.$constrainWrapLimit(e,n.min,n.max);return r!=this.$wrapLimit&&r>1?(this.$wrapLimit=r,this.$modified=!0,this.$useWrapMode&&(this.$updateWrapData(0,this.getLength()-1),this.$resetRowCache(0),this._signal("changeWrapLimit")),!0):!1},this.$constrainWrapLimit=function(e,t,n){return t&&(e=Math.max(t,e)),n&&(e=Math.min(n,e)),e},this.getWrapLimit=function(){return this.$wrapLimit},this.setWrapLimit=function(e){this.setWrapLimitRange(e,e)},this.getWrapLimitRange=function(){return{min:this.$wrapLimitRange.min,max:this.$wrapLimitRange.max}},this.$updateInternalDataOnChange=function(e){var t=this.$useWrapMode,n=e.action,r=e.start,i=e.end,s=r.row,o=i.row,u=o-s,a=null;this.$updating=!0;if(u!=0)if(n==="remove"){this[t?"$wrapData":"$rowLengthCache"].splice(s,u);var f=this.$foldData;a=this.getFoldsInRange(e),this.removeFolds(a);var l=this.getFoldLine(i.row),c=0;if(l){l.addRemoveChars(i.row,i.column,r.column-i.column),l.shiftRow(-u);var h=this.getFoldLine(s);h&&h!==l&&(h.merge(l),l=h),c=f.indexOf(l)+1}for(c;c<f.length;c++){var l=f[c];l.start.row>=i.row&&l.shiftRow(-u)}o=s}else{var p=Array(u);p.unshift(s,0);var d=t?this.$wrapData:this.$rowLengthCache;d.splice.apply(d,p);var f=this.$foldData,l=this.getFoldLine(s),c=0;if(l){var v=l.range.compareInside(r.row,r.column);v==0?(l=l.split(r.row,r.column),l&&(l.shiftRow(u),l.addRemoveChars(o,0,i.column-r.column))):v==-1&&(l.addRemoveChars(s,0,i.column-r.column),l.shiftRow(u)),c=f.indexOf(l)+1}for(c;c<f.length;c++){var l=f[c];l.start.row>=s&&l.shiftRow(u)}}else{u=Math.abs(e.start.column-e.end.column),n==="remove"&&(a=this.getFoldsInRange(e),this.removeFolds(a),u=-u);var l=this.getFoldLine(s);l&&l.addRemoveChars(s,r.column,u)}return t&&this.$wrapData.length!=this.doc.getLength()&&console.error("doc.getLength() and $wrapData.length have to be the same!"),this.$updating=!1,t?this.$updateWrapData(s,o):this.$updateRowLengthCache(s,o),a},this.$updateRowLengthCache=function(e,t,n){this.$rowLengthCache[e]=null,this.$rowLengthCache[t]=null},this.$updateWrapData=function(e,t){var r=this.doc.getAllLines(),i=this.getTabSize(),s=this.$wrapData,o=this.$wrapLimit,a,f,l=e;t=Math.min(t,r.length-1);while(l<=t)f=this.getFoldLine(l,f),f?(a=[],f.walk(function(e,t,i,s){var o;if(e!=null){o=this.$getDisplayTokens(e,a.length),o[0]=n;for(var f=1;f<o.length;f++)o[f]=u}else o=this.$getDisplayTokens(r[t].substring(s,i),a.length);a=a.concat(o)}.bind(this),f.end.row,r[f.end.row].length+1),s[f.start.row]=this.$computeWrapSplits(a,o,i),l=f.end.row+1):(a=this.$getDisplayTokens(r[l]),s[l]=this.$computeWrapSplits(a,o,i),l++)};var e=1,t=2,n=3,u=4,l=9,p=10,d=11,v=12;this.$computeWrapSplits=function(e,r,i){function g(){var t=0;if(m===0)return t;if(h)for(var n=0;n<e.length;n++){var r=e[n];if(r==p)t+=1;else{if(r!=d){if(r==v)continue;break}t+=i}}return c&&h!==!1&&(t+=i),Math.min(t,m)}function y(t){var n=e.slice(a,t),r=n.length;n.join("").replace(/12/g,function(){r-=1}).replace(/2/g,function(){r-=1}),s.length||(b=g(),s.indent=b),f+=r,s.push(f),a=t}if(e.length==0)return[];var s=[],o=e.length,a=0,f=0,c=this.$wrapAsCode,h=this.$indentedSoftWrap,m=r<=Math.max(2*i,8)||h===!1?0:Math.floor(r/2),b=0;while(o-a>r-b){var w=a+r-b;if(e[w-1]>=p&&e[w]>=p){y(w);continue}if(e[w]==n||e[w]==u){for(w;w!=a-1;w--)if(e[w]==n)break;if(w>a){y(w);continue}w=a+r;for(w;w<e.length;w++)if(e[w]!=u)break;if(w==e.length)break;y(w);continue}var E=Math.max(w-(r-(r>>2)),a-1);while(w>E&&e[w]<n)w--;if(c){while(w>E&&e[w]<n)w--;while(w>E&&e[w]==l)w--}else while(w>E&&e[w]<p)w--;if(w>E){y(++w);continue}w=a+r,e[w]==t&&w--,y(w-b)}return s},this.$getDisplayTokens=function(n,r){var i=[],s;r=r||0;for(var o=0;o<n.length;o++){var u=n.charCodeAt(o);if(u==9){s=this.getScreenTabSize(i.length+r),i.push(d);for(var a=1;a<s;a++)i.push(v)}else u==32?i.push(p):u>39&&u<48||u>57&&u<64?i.push(l):u>=4352&&m(u)?i.push(e,t):i.push(e)}return i},this.$getStringScreenWidth=function(e,t,n){if(t==0)return[0,0];t==null&&(t=Infinity),n=n||0;var r,i;for(i=0;i<e.length;i++){r=e.charCodeAt(i),r==9?n+=this.getScreenTabSize(n):r>=4352&&m(r)?n+=2:n+=1;if(n>t)break}return[n,i]},this.lineWidgets=null,this.getRowLength=function(e){if(this.lineWidgets)var t=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0;else t=0;return!this.$useWrapMode||!this.$wrapData[e]?1+t:this.$wrapData[e].length+1+t},this.getRowLineCount=function(e){return!this.$useWrapMode||!this.$wrapData[e]?1:this.$wrapData[e].length+1},this.getRowWrapIndent=function(e){if(this.$useWrapMode){var t=this.screenToDocumentPosition(e,Number.MAX_VALUE),n=this.$wrapData[t.row];return n.length&&n[0]<t.column?n.indent:0}return 0},this.getScreenLastRowColumn=function(e){var t=this.screenToDocumentPosition(e,Number.MAX_VALUE);return this.documentToScreenColumn(t.row,t.column)},this.getDocumentLastRowColumn=function(e,t){var n=this.documentToScreenRow(e,t);return this.getScreenLastRowColumn(n)},this.getDocumentLastRowColumnPosition=function(e,t){var n=this.documentToScreenRow(e,t);return this.screenToDocumentPosition(n,Number.MAX_VALUE/10)},this.getRowSplitData=function(e){return this.$useWrapMode?this.$wrapData[e]:undefined},this.getScreenTabSize=function(e){return this.$tabSize-e%this.$tabSize},this.screenToDocumentRow=function(e,t){return this.screenToDocumentPosition(e,t).row},this.screenToDocumentColumn=function(e,t){return this.screenToDocumentPosition(e,t).column},this.screenToDocumentPosition=function(e,t){if(e<0)return{row:0,column:0};var n,r=0,i=0,s,o=0,u=0,a=this.$screenRowCache,f=this.$getRowCacheIndex(a,e),l=a.length;if(l&&f>=0)var o=a[f],r=this.$docRowCache[f],c=e>a[l-1];else var c=!l;var h=this.getLength()-1,p=this.getNextFoldLine(r),d=p?p.start.row:Infinity;while(o<=e){u=this.getRowLength(r);if(o+u>e||r>=h)break;o+=u,r++,r>d&&(r=p.end.row+1,p=this.getNextFoldLine(r,p),d=p?p.start.row:Infinity),c&&(this.$docRowCache.push(r),this.$screenRowCache.push(o))}if(p&&p.start.row<=r)n=this.getFoldDisplayLine(p),r=p.start.row;else{if(o+u<=e||r>h)return{row:h,column:this.getLine(h).length};n=this.getLine(r),p=null}var v=0;if(this.$useWrapMode){var m=this.$wrapData[r];if(m){var g=Math.floor(e-o);s=m[g],g>0&&m.length&&(v=m.indent,i=m[g-1]||m[m.length-1],n=n.substring(i))}}return i+=this.$getStringScreenWidth(n,t-v)[1],this.$useWrapMode&&i>=s&&(i=s-1),p?p.idxToPosition(i):{row:r,column:i}},this.documentToScreenPosition=function(e,t){if(typeof t=="undefined")var n=this.$clipPositionToDocument(e.row,e.column);else n=this.$clipPositionToDocument(e,t);e=n.row,t=n.column;var r=0,i=null,s=null;s=this.getFoldAt(e,t,1),s&&(e=s.start.row,t=s.start.column);var o,u=0,a=this.$docRowCache,f=this.$getRowCacheIndex(a,e),l=a.length;if(l&&f>=0)var u=a[f],r=this.$screenRowCache[f],c=e>a[l-1];else var c=!l;var h=this.getNextFoldLine(u),p=h?h.start.row:Infinity;while(u<e){if(u>=p){o=h.end.row+1;if(o>e)break;h=this.getNextFoldLine(o,h),p=h?h.start.row:Infinity}else o=u+1;r+=this.getRowLength(u),u=o,c&&(this.$docRowCache.push(u),this.$screenRowCache.push(r))}var d="";h&&u>=p?(d=this.getFoldDisplayLine(h,e,t),i=h.start.row):(d=this.getLine(e).substring(0,t),i=e);var v=0;if(this.$useWrapMode){var m=this.$wrapData[i];if(m){var g=0;while(d.length>=m[g])r++,g++;d=d.substring(m[g-1]||0,d.length),v=g>0?m.indent:0}}return{row:r,column:v+this.$getStringScreenWidth(d)[0]}},this.documentToScreenColumn=function(e,t){return this.documentToScreenPosition(e,t).column},this.documentToScreenRow=function(e,t){return this.documentToScreenPosition(e,t).row},this.getScreenLength=function(){var e=0,t=null;if(!this.$useWrapMode){e=this.getLength();var n=this.$foldData;for(var r=0;r<n.length;r++)t=n[r],e-=t.end.row-t.start.row}else{var i=this.$wrapData.length,s=0,r=0,t=this.$foldData[r++],o=t?t.start.row:Infinity;while(s<i){var u=this.$wrapData[s];e+=u?u.length+1:1,s++,s>o&&(s=t.end.row+1,t=this.$foldData[r++],o=t?t.start.row:Infinity)}}return this.lineWidgets&&(e+=this.$getWidgetScreenLength()),e},this.$setFontMetrics=function(e){if(!this.$enableVarChar)return;this.$getStringScreenWidth=function(t,n,r){if(n===0)return[0,0];n||(n=Infinity),r=r||0;var i,s;for(s=0;s<t.length;s++){i=t.charAt(s),i===" "?r+=this.getScreenTabSize(r):r+=e.getCharacterWidth(i);if(r>n)break}return[r,s]}},this.destroy=function(){this.bgTokenizer&&(this.bgTokenizer.setDocument(null),this.bgTokenizer=null),this.$stopWorker()}}).call(p.prototype),e("./edit_session/folding").Folding.call(p.prototype),e("./edit_session/bracket_match").BracketMatch.call(p.prototype),s.defineOptions(p.prototype,"session",{wrap:{set:function(e){!e||e=="off"?e=!1:e=="free"?e=!0:e=="printMargin"?e=-1:typeof e=="string"&&(e=parseInt(e,10)||!1);if(this.$wrap==e)return;this.$wrap=e;if(!e)this.setUseWrapMode(!1);else{var t=typeof e=="number"?e:null;this.setWrapLimitRange(t,t),this.setUseWrapMode(!0)}},get:function(){return this.getUseWrapMode()?this.$wrap==-1?"printMargin":this.getWrapLimitRange().min?this.$wrap:"free":"off"},handlesSet:!0},wrapMethod:{set:function(e){e=e=="auto"?this.$mode.type!="text":e!="text",e!=this.$wrapAsCode&&(this.$wrapAsCode=e,this.$useWrapMode&&(this.$modified=!0,this.$resetRowCache(0),this.$updateWrapData(0,this.getLength()-1)))},initialValue:"auto"},indentedSoftWrap:{initialValue:!0},firstLineNumber:{set:function(){this._signal("changeBreakpoint")},initialValue:1},useWorker:{set:function(e){this.$useWorker=e,this.$stopWorker(),e&&this.$startWorker()},initialValue:!0},useSoftTabs:{initialValue:!0},tabSize:{set:function(e){if(isNaN(e)||this.$tabSize===e)return;this.$modified=!0,this.$rowLengthCache=[],this.$tabSize=e,this._signal("changeTabSize")},initialValue:4,handlesSet:!0},overwrite:{set:function(e){this._signal("changeOverwrite")},initialValue:!1},newLineMode:{set:function(e){this.doc.setNewLineMode(e)},get:function(){return this.doc.getNewLineMode()},handlesSet:!0},mode:{set:function(e){this.setMode(e)},get:function(){return this.$modeId}}}),t.EditSession=p}),ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(){this.$options={}};(function(){this.set=function(e){return i.mixin(this.$options,e),this},this.getOptions=function(){return r.copyObject(this.$options)},this.setOptions=function(e){this.$options=e},this.find=function(e){var t=this.$options,n=this.$matchIterator(e,t);if(!n)return!1;var r=null;return n.forEach(function(e,n,i){if(!e.start){var o=e.offset+(i||0);r=new s(n,o,n,o+e.length);if(!e.length&&t.start&&t.start.start&&t.skipCurrent!=0&&r.isEqual(t.start))return r=null,!1}else r=e;return!0}),r},this.findAll=function(e){var t=this.$options;if(!t.needle)return[];this.$assembleRegExp(t);var n=t.range,i=n?e.getLines(n.start.row,n.end.row):e.doc.getAllLines(),o=[],u=t.re;if(t.$isMultiLine){var a=u.length,f=i.length-a,l;e:for(var c=u.offset||0;c<=f;c++){for(var h=0;h<a;h++)if(i[c+h].search(u[h])==-1)continue e;var p=i[c],d=i[c+a-1],v=p.length-p.match(u[0])[0].length,m=d.match(u[a-1])[0].length;if(l&&l.end.row===c&&l.end.column>v)continue;o.push(l=new s(c,v,c+a-1,m)),a>2&&(c=c+a-2)}}else for(var g=0;g<i.length;g++){var y=r.getMatchOffsets(i[g],u);for(var h=0;h<y.length;h++){var b=y[h];o.push(new s(g,b.offset,g,b.offset+b.length))}}if(n){var w=n.start.column,E=n.start.column,g=0,h=o.length-1;while(g<h&&o[g].start.column<w&&o[g].start.row==n.start.row)g++;while(g<h&&o[h].end.column>E&&o[h].end.row==n.end.row)h--;o=o.slice(g,h+1);for(g=0,h=o.length;g<h;g++)o[g].start.row+=n.start.row,o[g].end.row+=n.start.row}return o},this.replace=function(e,t){var n=this.$options,r=this.$assembleRegExp(n);if(n.$isMultiLine)return t;if(!r)return;var i=r.exec(e);if(!i||i[0].length!=e.length)return null;t=e.replace(r,t);if(n.preserveCase){t=t.split("");for(var s=Math.min(e.length,e.length);s--;){var o=e[s];o&&o.toLowerCase()!=o?t[s]=t[s].toUpperCase():t[s]=t[s].toLowerCase()}t=t.join("")}return t},this.$matchIterator=function(e,t){var n=this.$assembleRegExp(t);if(!n)return!1;var i;if(t.$isMultiLine)var o=n.length,u=function(t,r,u){var a=t.search(n[0]);if(a==-1)return;for(var f=1;f<o;f++){t=e.getLine(r+f);if(t.search(n[f])==-1)return}var l=t.match(n[o-1])[0].length,c=new s(r,a,r+o-1,l);n.offset==1?(c.start.row--,c.start.column=Number.MAX_VALUE):u&&(c.start.column+=u);if(i(c))return!0};else if(t.backwards)var u=function(e,t,s){var o=r.getMatchOffsets(e,n);for(var u=o.length-1;u>=0;u--)if(i(o[u],t,s))return!0};else var u=function(e,t,s){var o=r.getMatchOffsets(e,n);for(var u=0;u<o.length;u++)if(i(o[u],t,s))return!0};var a=this.$lineIterator(e,t);return{forEach:function(e){i=e,a.forEach(u)}}},this.$assembleRegExp=function(e,t){if(e.needle instanceof RegExp)return e.re=e.needle;var n=e.needle;if(!e.needle)return e.re=!1;e.regExp||(n=r.escapeRegExp(n)),e.wholeWord&&(n="\\b"+n+"\\b");var i=e.caseSensitive?"gm":"gmi";e.$isMultiLine=!t&&/[\n\r]/.test(n);if(e.$isMultiLine)return e.re=this.$assembleMultilineRegExp(n,i);try{var s=new RegExp(n,i)}catch(o){s=!1}return e.re=s},this.$assembleMultilineRegExp=function(e,t){var n=e.replace(/\r\n|\r|\n/g,"$\n^").split("\n"),r=[];for(var i=0;i<n.length;i++)try{r.push(new RegExp(n[i],t))}catch(s){return!1}return n[0]==""?(r.shift(),r.offset=1):r.offset=0,r},this.$lineIterator=function(e,t){var n=t.backwards==1,r=t.skipCurrent!=0,i=t.range,s=t.start;s||(s=i?i[n?"end":"start"]:e.selection.getRange()),s.start&&(s=s[r!=n?"end":"start"]);var o=i?i.start.row:0,u=i?i.end.row:e.getLength()-1,a=n?function(n){var r=s.row,i=e.getLine(r).substring(0,s.column);if(n(i,r))return;for(r--;r>=o;r--)if(n(e.getLine(r),r))return;if(t.wrap==0)return;for(r=u,o=s.row;r>=o;r--)if(n(e.getLine(r),r))return}:function(n){var r=s.row,i=e.getLine(r).substr(s.column);if(n(i,r,s.column))return;for(r+=1;r<=u;r++)if(n(e.getLine(r),r))return;if(t.wrap==0)return;for(r=o,u=s.row;r<=u;r++)if(n(e.getLine(r),r))return};return{forEach:a}}}).call(o.prototype),t.Search=o}),ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function o(e,t){this.platform=t||(i.isMac?"mac":"win"),this.commands={},this.commandKeyBinding={},this.addCommands(e),this.$singleCommand=!0}function u(e,t){o.call(this,e,t),this.$singleCommand=!1}var r=e("../lib/keys"),i=e("../lib/useragent"),s=r.KEY_MODS;u.prototype=o.prototype,function(){function e(e){return typeof e=="object"&&e.bindKey&&e.bindKey.position||0}this.addCommand=function(e){this.commands[e.name]&&this.removeCommand(e),this.commands[e.name]=e,e.bindKey&&this._buildKeyHash(e)},this.removeCommand=function(e,t){var n=e&&(typeof e=="string"?e:e.name);e=this.commands[n],t||delete this.commands[n];var r=this.commandKeyBinding;for(var i in r){var s=r[i];if(s==e)delete r[i];else if(Array.isArray(s)){var o=s.indexOf(e);o!=-1&&(s.splice(o,1),s.length==1&&(r[i]=s[0]))}}},this.bindKey=function(e,t,n){typeof e=="object"&&e&&(n==undefined&&(n=e.position),e=e[this.platform]);if(!e)return;if(typeof t=="function")return this.addCommand({exec:t,bindKey:e,name:t.name||e});e.split("|").forEach(function(e){var r="";if(e.indexOf(" ")!=-1){var i=e.split(/\s+/);e=i.pop(),i.forEach(function(e){var t=this.parseKeys(e),n=s[t.hashId]+t.key;r+=(r?" ":"")+n,this._addCommandToBinding(r,"chainKeys")},this),r+=" "}var o=this.parseKeys(e),u=s[o.hashId]+o.key;this._addCommandToBinding(r+u,t,n)},this)},this._addCommandToBinding=function(t,n,r){var i=this.commandKeyBinding,s;if(!n)delete i[t];else if(!i[t]||this.$singleCommand)i[t]=n;else{Array.isArray(i[t])?(s=i[t].indexOf(n))!=-1&&i[t].splice(s,1):i[t]=[i[t]],typeof r!="number"&&(r||n.isDefault?r=-100:r=e(n));var o=i[t];for(s=0;s<o.length;s++){var u=o[s],a=e(u);if(a>r)break}o.splice(s,0,n)}},this.addCommands=function(e){e&&Object.keys(e).forEach(function(t){var n=e[t];if(!n)return;if(typeof n=="string")return this.bindKey(n,t);typeof n=="function"&&(n={exec:n});if(typeof n!="object")return;n.name||(n.name=t),this.addCommand(n)},this)},this.removeCommands=function(e){Object.keys(e).forEach(function(t){this.removeCommand(e[t])},this)},this.bindKeys=function(e){Object.keys(e).forEach(function(t){this.bindKey(t,e[t])},this)},this._buildKeyHash=function(e){this.bindKey(e.bindKey,e)},this.parseKeys=function(e){var t=e.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(e){return e}),n=t.pop(),i=r[n];if(r.FUNCTION_KEYS[i])n=r.FUNCTION_KEYS[i].toLowerCase();else{if(!t.length)return{key:n,hashId:-1};if(t.length==1&&t[0]=="shift")return{key:n.toUpperCase(),hashId:-1}}var s=0;for(var o=t.length;o--;){var u=r.KEY_MODS[t[o]];if(u==null)return typeof console!="undefined"&&console.error("invalid modifier "+t[o]+" in "+e),!1;s|=u}return{key:n,hashId:s}},this.findKeyCommand=function(t,n){var r=s[t]+n;return this.commandKeyBinding[r]},this.handleKeyboard=function(e,t,n,r){if(r<0)return;var i=s[t]+n,o=this.commandKeyBinding[i];e.$keyChain&&(e.$keyChain+=" "+i,o=this.commandKeyBinding[e.$keyChain]||o);if(o)if(o=="chainKeys"||o[o.length-1]=="chainKeys")return e.$keyChain=e.$keyChain||i,{command:"null"};if(e.$keyChain)if(!!t&&t!=4||n.length!=1){if(t==-1||r>0)e.$keyChain=""}else e.$keyChain=e.$keyChain.slice(0,-i.length-1);return{command:o}},this.getStatusText=function(e,t){return t.$keyChain||""}}.call(o.prototype),t.HashHandler=o,t.MultiHashHandler=u}),ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../keyboard/hash_handler").MultiHashHandler,s=e("../lib/event_emitter").EventEmitter,o=function(e,t){i.call(this,t,e),this.byName=this.commands,this.setDefaultHandler("exec",function(e){return e.command.exec(e.editor,e.args||{})})};r.inherits(o,i),function(){r.implement(this,s),this.exec=function(e,t,n){if(Array.isArray(e)){for(var r=e.length;r--;)if(this.exec(e[r],t,n))return!0;return!1}typeof e=="string"&&(e=this.commands[e]);if(!e)return!1;if(t&&t.$readOnly&&!e.readOnly)return!1;var i={editor:t,command:e,args:n};return i.returnValue=this._emit("exec",i),this._signal("afterExec",i),i.returnValue===!1?!1:!0},this.toggleRecording=function(e){if(this.$inReplay)return;return e&&e._emit("changeStatus"),this.recording?(this.macro.pop(),this.removeEventListener("exec",this.$addCommandToMacro),this.macro.length||(this.macro=this.oldMacro),this.recording=!1):(this.$addCommandToMacro||(this.$addCommandToMacro=function(e){this.macro.push([e.command,e.args])}.bind(this)),this.oldMacro=this.macro,this.macro=[],this.on("exec",this.$addCommandToMacro),this.recording=!0)},this.replay=function(e){if(this.$inReplay||!this.macro)return;if(this.recording)return this.toggleRecording(e);try{this.$inReplay=!0,this.macro.forEach(function(t){typeof t=="string"?this.exec(t,e):this.exec(t[0],e,t[1])},this)}finally{this.$inReplay=!1}},this.trimMacro=function(e){return e.map(function(e){return typeof e[0]!="string"&&(e[0]=e[0].name),e[1]||(e=e[0]),e})}}.call(o.prototype),t.CommandManager=o}),ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"],function(e,t,n){"use strict";function o(e,t){return{win:e,mac:t}}var r=e("../lib/lang"),i=e("../config"),s=e("../range").Range;t.commands=[{name:"showSettingsMenu",bindKey:o("Ctrl-,","Command-,"),exec:function(e){i.loadModule("ace/ext/settings_menu",function(t){t.init(e),e.showSettingsMenu()})},readOnly:!0},{name:"goToNextError",bindKey:o("Alt-E","Ctrl-E"),exec:function(e){i.loadModule("ace/ext/error_marker",function(t){t.showErrorMarker(e,1)})},scrollIntoView:"animate",readOnly:!0},{name:"goToPreviousError",bindKey:o("Alt-Shift-E","Ctrl-Shift-E"),exec:function(e){i.loadModule("ace/ext/error_marker",function(t){t.showErrorMarker(e,-1)})},scrollIntoView:"animate",readOnly:!0},{name:"selectall",bindKey:o("Ctrl-A","Command-A"),exec:function(e){e.selectAll()},readOnly:!0},{name:"centerselection",bindKey:o(null,"Ctrl-L"),exec:function(e){e.centerSelection()},readOnly:!0},{name:"gotoline",bindKey:o("Ctrl-L","Command-L"),exec:function(e){var t=parseInt(prompt("Enter line number:"),10);isNaN(t)||e.gotoLine(t)},readOnly:!0},{name:"fold",bindKey:o("Alt-L|Ctrl-F1","Command-Alt-L|Command-F1"),exec:function(e){e.session.toggleFold(!1)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"unfold",bindKey:o("Alt-Shift-L|Ctrl-Shift-F1","Command-Alt-Shift-L|Command-Shift-F1"),exec:function(e){e.session.toggleFold(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleFoldWidget",bindKey:o("F2","F2"),exec:function(e){e.session.toggleFoldWidget()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleParentFoldWidget",bindKey:o("Alt-F2","Alt-F2"),exec:function(e){e.session.toggleFoldWidget(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"foldall",bindKey:o(null,"Ctrl-Command-Option-0"),exec:function(e){e.session.foldAll()},scrollIntoView:"center",readOnly:!0},{name:"foldOther",bindKey:o("Alt-0","Command-Option-0"),exec:function(e){e.session.foldAll(),e.session.unfold(e.selection.getAllRanges())},scrollIntoView:"center",readOnly:!0},{name:"unfoldall",bindKey:o("Alt-Shift-0","Command-Option-Shift-0"),exec:function(e){e.session.unfold()},scrollIntoView:"center",readOnly:!0},{name:"findnext",bindKey:o("Ctrl-K","Command-G"),exec:function(e){e.findNext()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"findprevious",bindKey:o("Ctrl-Shift-K","Command-Shift-G"),exec:function(e){e.findPrevious()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"selectOrFindNext",bindKey:o("Alt-K","Ctrl-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findNext()},readOnly:!0},{name:"selectOrFindPrevious",bindKey:o("Alt-Shift-K","Ctrl-Shift-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findPrevious()},readOnly:!0},{name:"find",bindKey:o("Ctrl-F","Command-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e)})},readOnly:!0},{name:"overwrite",bindKey:"Insert",exec:function(e){e.toggleOverwrite()},readOnly:!0},{name:"selecttostart",bindKey:o("Ctrl-Shift-Home","Command-Shift-Up"),exec:function(e){e.getSelection().selectFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotostart",bindKey:o("Ctrl-Home","Command-Home|Command-Up"),exec:function(e){e.navigateFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectup",bindKey:o("Shift-Up","Shift-Up"),exec:function(e){e.getSelection().selectUp()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golineup",bindKey:o("Up","Up|Ctrl-P"),exec:function(e,t){e.navigateUp(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttoend",bindKey:o("Ctrl-Shift-End","Command-Shift-Down"),exec:function(e){e.getSelection().selectFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotoend",bindKey:o("Ctrl-End","Command-End|Command-Down"),exec:function(e){e.navigateFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectdown",bindKey:o("Shift-Down","Shift-Down"),exec:function(e){e.getSelection().selectDown()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golinedown",bindKey:o("Down","Down|Ctrl-N"),exec:function(e,t){e.navigateDown(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordleft",bindKey:o("Ctrl-Shift-Left","Option-Shift-Left"),exec:function(e){e.getSelection().selectWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordleft",bindKey:o("Ctrl-Left","Option-Left"),exec:function(e){e.navigateWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolinestart",bindKey:o("Alt-Shift-Left","Command-Shift-Left"),exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolinestart",bindKey:o("Alt-Left|Home","Command-Left|Home|Ctrl-A"),exec:function(e){e.navigateLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectleft",bindKey:o("Shift-Left","Shift-Left"),exec:function(e){e.getSelection().selectLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoleft",bindKey:o("Left","Left|Ctrl-B"),exec:function(e,t){e.navigateLeft(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordright",bindKey:o("Ctrl-Shift-Right","Option-Shift-Right"),exec:function(e){e.getSelection().selectWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordright",bindKey:o("Ctrl-Right","Option-Right"),exec:function(e){e.navigateWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolineend",bindKey:o("Alt-Shift-Right","Command-Shift-Right"),exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolineend",bindKey:o("Alt-Right|End","Command-Right|End|Ctrl-E"),exec:function(e){e.navigateLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectright",bindKey:o("Shift-Right","Shift-Right"),exec:function(e){e.getSelection().selectRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoright",bindKey:o("Right","Right|Ctrl-F"),exec:function(e,t){e.navigateRight(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectpagedown",bindKey:"Shift-PageDown",exec:function(e){e.selectPageDown()},readOnly:!0},{name:"pagedown",bindKey:o(null,"Option-PageDown"),exec:function(e){e.scrollPageDown()},readOnly:!0},{name:"gotopagedown",bindKey:o("PageDown","PageDown|Ctrl-V"),exec:function(e){e.gotoPageDown()},readOnly:!0},{name:"selectpageup",bindKey:"Shift-PageUp",exec:function(e){e.selectPageUp()},readOnly:!0},{name:"pageup",bindKey:o(null,"Option-PageUp"),exec:function(e){e.scrollPageUp()},readOnly:!0},{name:"gotopageup",bindKey:"PageUp",exec:function(e){e.gotoPageUp()},readOnly:!0},{name:"scrollup",bindKey:o("Ctrl-Up",null),exec:function(e){e.renderer.scrollBy(0,-2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"scrolldown",bindKey:o("Ctrl-Down",null),exec:function(e){e.renderer.scrollBy(0,2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"selectlinestart",bindKey:"Shift-Home",exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectlineend",bindKey:"Shift-End",exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"togglerecording",bindKey:o("Ctrl-Alt-E","Command-Option-E"),exec:function(e){e.commands.toggleRecording(e)},readOnly:!0},{name:"replaymacro",bindKey:o("Ctrl-Shift-E","Command-Shift-E"),exec:function(e){e.commands.replay(e)},readOnly:!0},{name:"jumptomatching",bindKey:o("Ctrl-P","Ctrl-P"),exec:function(e){e.jumpToMatching()},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"selecttomatching",bindKey:o("Ctrl-Shift-P","Ctrl-Shift-P"),exec:function(e){e.jumpToMatching(!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"expandToMatching",bindKey:o("Ctrl-Shift-M","Ctrl-Shift-M"),exec:function(e){e.jumpToMatching(!0,!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"passKeysToBrowser",bindKey:o(null,null),exec:function(){},passEvent:!0,readOnly:!0},{name:"copy",exec:function(e){},readOnly:!0},{name:"cut",exec:function(e){var t=e.getSelectionRange();e._emit("cut",t),e.selection.isEmpty()||(e.session.remove(t),e.clearSelection())},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"paste",exec:function(e,t){e.$handlePaste(t)},scrollIntoView:"cursor"},{name:"removeline",bindKey:o("Ctrl-D","Command-D"),exec:function(e){e.removeLines()},scrollIntoView:"cursor",multiSelectAction:"forEachLine"},{name:"duplicateSelection",bindKey:o("Ctrl-Shift-D","Command-Shift-D"),exec:function(e){e.duplicateSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"sortlines",bindKey:o("Ctrl-Alt-S","Command-Alt-S"),exec:function(e){e.sortLines()},scrollIntoView:"selection",multiSelectAction:"forEachLine"},{name:"togglecomment",bindKey:o("Ctrl-/","Command-/"),exec:function(e){e.toggleCommentLines()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"toggleBlockComment",bindKey:o("Ctrl-Shift-/","Command-Shift-/"),exec:function(e){e.toggleBlockComment()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"modifyNumberUp",bindKey:o("Ctrl-Shift-Up","Alt-Shift-Up"),exec:function(e){e.modifyNumber(1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"modifyNumberDown",bindKey:o("Ctrl-Shift-Down","Alt-Shift-Down"),exec:function(e){e.modifyNumber(-1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"replace",bindKey:o("Ctrl-H","Command-Option-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e,!0)})}},{name:"undo",bindKey:o("Ctrl-Z","Command-Z"),exec:function(e){e.undo()}},{name:"redo",bindKey:o("Ctrl-Shift-Z|Ctrl-Y","Command-Shift-Z|Command-Y"),exec:function(e){e.redo()}},{name:"copylinesup",bindKey:o("Alt-Shift-Up","Command-Option-Up"),exec:function(e){e.copyLinesUp()},scrollIntoView:"cursor"},{name:"movelinesup",bindKey:o("Alt-Up","Option-Up"),exec:function(e){e.moveLinesUp()},scrollIntoView:"cursor"},{name:"copylinesdown",bindKey:o("Alt-Shift-Down","Command-Option-Down"),exec:function(e){e.copyLinesDown()},scrollIntoView:"cursor"},{name:"movelinesdown",bindKey:o("Alt-Down","Option-Down"),exec:function(e){e.moveLinesDown()},scrollIntoView:"cursor"},{name:"del",bindKey:o("Delete","Delete|Ctrl-D|Shift-Delete"),exec:function(e){e.remove("right")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"backspace",bindKey:o("Shift-Backspace|Backspace","Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"),exec:function(e){e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"cut_or_delete",bindKey:o("Shift-Delete",null),exec:function(e){if(!e.selection.isEmpty())return!1;e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestart",bindKey:o("Alt-Backspace","Command-Backspace"),exec:function(e){e.removeToLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineend",bindKey:o("Alt-Delete","Ctrl-K"),exec:function(e){e.removeToLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordleft",bindKey:o("Ctrl-Backspace","Alt-Backspace|Ctrl-Alt-Backspace"),exec:function(e){e.removeWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordright",bindKey:o("Ctrl-Delete","Alt-Delete"),exec:function(e){e.removeWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"outdent",bindKey:o("Shift-Tab","Shift-Tab"),exec:function(e){e.blockOutdent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"indent",bindKey:o("Tab","Tab"),exec:function(e){e.indent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"blockoutdent",bindKey:o("Ctrl-[","Ctrl-["),exec:function(e){e.blockOutdent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"blockindent",bindKey:o("Ctrl-]","Ctrl-]"),exec:function(e){e.blockIndent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"insertstring",exec:function(e,t){e.insert(t)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"inserttext",exec:function(e,t){e.insert(r.stringRepeat(t.text||"",t.times||1))},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"splitline",bindKey:o(null,"Ctrl-O"),exec:function(e){e.splitLine()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"transposeletters",bindKey:o("Ctrl-T","Ctrl-T"),exec:function(e){e.transposeLetters()},multiSelectAction:function(e){e.transposeSelections(1)},scrollIntoView:"cursor"},{name:"touppercase",bindKey:o("Ctrl-U","Ctrl-U"),exec:function(e){e.toUpperCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"tolowercase",bindKey:o("Ctrl-Shift-U","Ctrl-Shift-U"),exec:function(e){e.toLowerCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"expandtoline",bindKey:o("Ctrl-Shift-L","Command-Shift-L"),exec:function(e){var t=e.selection.getRange();t.start.column=t.end.column=0,t.end.row++,e.selection.setRange(t,!1)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"joinlines",bindKey:o(null,null),exec:function(e){var t=e.selection.isBackwards(),n=t?e.selection.getSelectionLead():e.selection.getSelectionAnchor(),i=t?e.selection.getSelectionAnchor():e.selection.getSelectionLead(),o=e.session.doc.getLine(n.row).length,u=e.session.doc.getTextRange(e.selection.getRange()),a=u.replace(/\n\s*/," ").length,f=e.session.doc.getLine(n.row);for(var l=n.row+1;l<=i.row+1;l++){var c=r.stringTrimLeft(r.stringTrimRight(e.session.doc.getLine(l)));c.length!==0&&(c=" "+c),f+=c}i.row+1<e.session.doc.getLength()-1&&(f+=e.session.doc.getNewLineCharacter()),e.clearSelection(),e.session.doc.replace(new s(n.row,0,i.row+2,0),f),a>0?(e.selection.moveCursorTo(n.row,n.column),e.selection.selectTo(n.row,n.column+a)):(o=e.session.doc.getLine(n.row).length>o?o+1:o,e.selection.moveCursorTo(n.row,o))},multiSelectAction:"forEach",readOnly:!0},{name:"invertSelection",bindKey:o(null,null),exec:function(e){var t=e.session.doc.getLength()-1,n=e.session.doc.getLine(t).length,r=e.selection.rangeList.ranges,i=[];r.length<1&&(r=[e.selection.getRange()]);for(var o=0;o<r.length;o++)o==r.length-1&&(r[o].end.row!==t||r[o].end.column!==n)&&i.push(new s(r[o].end.row,r[o].end.column,t,n)),o===0?(r[o].start.row!==0||r[o].start.column!==0)&&i.push(new s(0,0,r[o].start.row,r[o].start.column)):i.push(new s(r[o-1].end.row,r[o-1].end.column,r[o].start.row,r[o].start.column));e.exitMultiSelectMode(),e.clearSelection();for(var o=0;o<i.length;o++)e.selection.addRange(i[o],!1)},readOnly:!0,scrollIntoView:"none"}]}),ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"],function(e,t,n){"use strict";e("./lib/fixoldbrowsers");var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./lib/lang"),o=e("./lib/useragent"),u=e("./keyboard/textinput").TextInput,a=e("./mouse/mouse_handler").MouseHandler,f=e("./mouse/fold_handler").FoldHandler,l=e("./keyboard/keybinding").KeyBinding,c=e("./edit_session").EditSession,h=e("./search").Search,p=e("./range").Range,d=e("./lib/event_emitter").EventEmitter,v=e("./commands/command_manager").CommandManager,m=e("./commands/default_commands").commands,g=e("./config"),y=e("./token_iterator").TokenIterator,b=function(e,t){var n=e.getContainerElement();this.container=n,this.renderer=e,this.commands=new v(o.isMac?"mac":"win",m),this.textInput=new u(e.getTextAreaContainer(),this),this.renderer.textarea=this.textInput.getElement(),this.keyBinding=new l(this),this.$mouseHandler=new a(this),new f(this),this.$blockScrolling=0,this.$search=(new h).set({wrap:!0}),this.$historyTracker=this.$historyTracker.bind(this),this.commands.on("exec",this.$historyTracker),this.$initOperationListeners(),this._$emitInputEvent=s.delayedCall(function(){this._signal("input",{}),this.session&&this.session.bgTokenizer&&this.session.bgTokenizer.scheduleStart()}.bind(this)),this.on("change",function(e,t){t._$emitInputEvent.schedule(31)}),this.setSession(t||new c("")),g.resetOptions(this),g._signal("editor",this)};(function(){r.implement(this,d),this.$initOperationListeners=function(){function e(e){return e[e.length-1]}this.selections=[],this.commands.on("exec",this.startOperation.bind(this),!0),this.commands.on("afterExec",this.endOperation.bind(this),!0),this.$opResetTimer=s.delayedCall(this.endOperation.bind(this)),this.on("change",function(){this.curOp||this.startOperation(),this.curOp.docChanged=!0}.bind(this),!0),this.on("changeSelection",function(){this.curOp||this.startOperation(),this.curOp.selectionChanged=!0}.bind(this),!0)},this.curOp=null,this.prevOp={},this.startOperation=function(e){if(this.curOp){if(!e||this.curOp.command)return;this.prevOp=this.curOp}e||(this.previousCommand=null,e={}),this.$opResetTimer.schedule(),this.curOp={command:e.command||{},args:e.args,scrollTop:this.renderer.scrollTop},this.curOp.command.name&&this.curOp.command.scrollIntoView!==undefined&&this.$blockScrolling++},this.endOperation=function(e){if(this.curOp){if(e&&e.returnValue===!1)return this.curOp=null;this._signal("beforeEndOperation");var t=this.curOp.command;t.name&&this.$blockScrolling>0&&this.$blockScrolling--;var n=t&&t.scrollIntoView;if(n){switch(n){case"center-animate":n="animate";case"center":this.renderer.scrollCursorIntoView(null,.5);break;case"animate":case"cursor":this.renderer.scrollCursorIntoView();break;case"selectionPart":var r=this.selection.getRange(),i=this.renderer.layerConfig;(r.start.row>=i.lastRow||r.end.row<=i.firstRow)&&this.renderer.scrollSelectionIntoView(this.selection.anchor,this.selection.lead);break;default:}n=="animate"&&this.renderer.animateScrolling(this.curOp.scrollTop)}this.prevOp=this.curOp,this.curOp=null}},this.$mergeableCommands=["backspace","del","insertstring"],this.$historyTracker=function(e){if(!this.$mergeUndoDeltas)return;var t=this.prevOp,n=this.$mergeableCommands,r=t.command&&e.command.name==t.command.name;if(e.command.name=="insertstring"){var i=e.args;this.mergeNextCommand===undefined&&(this.mergeNextCommand=!0),r=r&&this.mergeNextCommand&&(!/\s/.test(i)||/\s/.test(t.args)),this.mergeNextCommand=!0}else r=r&&n.indexOf(e.command.name)!==-1;this.$mergeUndoDeltas!="always"&&Date.now()-this.sequenceStartTime>2e3&&(r=!1),r?this.session.mergeUndoDeltas=!0:n.indexOf(e.command.name)!==-1&&(this.sequenceStartTime=Date.now())},this.setKeyboardHandler=function(e,t){if(e&&typeof e=="string"){this.$keybindingId=e;var n=this;g.loadModule(["keybinding",e],function(r){n.$keybindingId==e&&n.keyBinding.setKeyboardHandler(r&&r.handler),t&&t()})}else this.$keybindingId=null,this.keyBinding.setKeyboardHandler(e),t&&t()},this.getKeyboardHandler=function(){return this.keyBinding.getKeyboardHandler()},this.setSession=function(e){if(this.session==e)return;this.curOp&&this.endOperation(),this.curOp={};var t=this.session;if(t){this.session.off("change",this.$onDocumentChange),this.session.off("changeMode",this.$onChangeMode),this.session.off("tokenizerUpdate",this.$onTokenizerUpdate),this.session.off("changeTabSize",this.$onChangeTabSize),this.session.off("changeWrapLimit",this.$onChangeWrapLimit),this.session.off("changeWrapMode",this.$onChangeWrapMode),this.session.off("changeFold",this.$onChangeFold),this.session.off("changeFrontMarker",this.$onChangeFrontMarker),this.session.off("changeBackMarker",this.$onChangeBackMarker),this.session.off("changeBreakpoint",this.$onChangeBreakpoint),this.session.off("changeAnnotation",this.$onChangeAnnotation),this.session.off("changeOverwrite",this.$onCursorChange),this.session.off("changeScrollTop",this.$onScrollTopChange),this.session.off("changeScrollLeft",this.$onScrollLeftChange);var n=this.session.getSelection();n.off("changeCursor",this.$onCursorChange),n.off("changeSelection",this.$onSelectionChange)}this.session=e,e?(this.$onDocumentChange=this.onDocumentChange.bind(this),e.on("change",this.$onDocumentChange),this.renderer.setSession(e),this.$onChangeMode=this.onChangeMode.bind(this),e.on("changeMode",this.$onChangeMode),this.$onTokenizerUpdate=this.onTokenizerUpdate.bind(this),e.on("tokenizerUpdate",this.$onTokenizerUpdate),this.$onChangeTabSize=this.renderer.onChangeTabSize.bind(this.renderer),e.on("changeTabSize",this.$onChangeTabSize),this.$onChangeWrapLimit=this.onChangeWrapLimit.bind(this),e.on("changeWrapLimit",this.$onChangeWrapLimit),this.$onChangeWrapMode=this.onChangeWrapMode.bind(this),e.on("changeWrapMode",this.$onChangeWrapMode),this.$onChangeFold=this.onChangeFold.bind(this),e.on("changeFold",this.$onChangeFold),this.$onChangeFrontMarker=this.onChangeFrontMarker.bind(this),this.session.on("changeFrontMarker",this.$onChangeFrontMarker),this.$onChangeBackMarker=this.onChangeBackMarker.bind(this),this.session.on("changeBackMarker",this.$onChangeBackMarker),this.$onChangeBreakpoint=this.onChangeBreakpoint.bind(this),this.session.on("changeBreakpoint",this.$onChangeBreakpoint),this.$onChangeAnnotation=this.onChangeAnnotation.bind(this),this.session.on("changeAnnotation",this.$onChangeAnnotation),this.$onCursorChange=this.onCursorChange.bind(this),this.session.on("changeOverwrite",this.$onCursorChange),this.$onScrollTopChange=this.onScrollTopChange.bind(this),this.session.on("changeScrollTop",this.$onScrollTopChange),this.$onScrollLeftChange=this.onScrollLeftChange.bind(this),this.session.on("changeScrollLeft",this.$onScrollLeftChange),this.selection=e.getSelection(),this.selection.on("changeCursor",this.$onCursorChange),this.$onSelectionChange=this.onSelectionChange.bind(this),this.selection.on("changeSelection",this.$onSelectionChange),this.onChangeMode(),this.$blockScrolling+=1,this.onCursorChange(),this.$blockScrolling-=1,this.onScrollTopChange(),this.onScrollLeftChange(),this.onSelectionChange(),this.onChangeFrontMarker(),this.onChangeBackMarker(),this.onChangeBreakpoint(),this.onChangeAnnotation(),this.session.getUseWrapMode()&&this.renderer.adjustWrapLimit(),this.renderer.updateFull()):(this.selection=null,this.renderer.setSession(e)),this._signal("changeSession",{session:e,oldSession:t}),this.curOp=null,t&&t._signal("changeEditor",{oldEditor:this}),e&&e._signal("changeEditor",{editor:this})},this.getSession=function(){return this.session},this.setValue=function(e,t){return this.session.doc.setValue(e),t?t==1?this.navigateFileEnd():t==-1&&this.navigateFileStart():this.selectAll(),e},this.getValue=function(){return this.session.getValue()},this.getSelection=function(){return this.selection},this.resize=function(e){this.renderer.onResize(e)},this.setTheme=function(e,t){this.renderer.setTheme(e,t)},this.getTheme=function(){return this.renderer.getTheme()},this.setStyle=function(e){this.renderer.setStyle(e)},this.unsetStyle=function(e){this.renderer.unsetStyle(e)},this.getFontSize=function(){return this.getOption("fontSize")||i.computedStyle(this.container,"fontSize")},this.setFontSize=function(e){this.setOption("fontSize",e)},this.$highlightBrackets=function(){this.session.$bracketHighlight&&(this.session.removeMarker(this.session.$bracketHighlight),this.session.$bracketHighlight=null);if(this.$highlightPending)return;var e=this;this.$highlightPending=!0,setTimeout(function(){e.$highlightPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;var n=t.findMatchingBracket(e.getCursorPosition());if(n)var r=new p(n.row,n.column,n.row,n.column+1);else if(t.$mode.getMatching)var r=t.$mode.getMatching(e.session);r&&(t.$bracketHighlight=t.addMarker(r,"ace_bracket","text"))},50)},this.$highlightTags=function(){if(this.$highlightTagPending)return;var e=this;this.$highlightTagPending=!0,setTimeout(function(){e.$highlightTagPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;var n=e.getCursorPosition(),r=new y(e.session,n.row,n.column),i=r.getCurrentToken();if(!i||!/\b(?:tag-open|tag-name)/.test(i.type)){t.removeMarker(t.$tagHighlight),t.$tagHighlight=null;return}if(i.type.indexOf("tag-open")!=-1){i=r.stepForward();if(!i)return}var s=i.value,o=0,u=r.stepBackward();if(u.value=="<"){do u=i,i=r.stepForward(),i&&i.value===s&&i.type.indexOf("tag-name")!==-1&&(u.value==="<"?o++:u.value==="</"&&o--);while(i&&o>=0)}else{do i=u,u=r.stepBackward(),i&&i.value===s&&i.type.indexOf("tag-name")!==-1&&(u.value==="<"?o++:u.value==="</"&&o--);while(u&&o<=0);r.stepForward()}if(!i){t.removeMarker(t.$tagHighlight),t.$tagHighlight=null;return}var a=r.getCurrentTokenRow(),f=r.getCurrentTokenColumn(),l=new p(a,f,a,f+i.value.length);t.$tagHighlight&&l.compareRange(t.$backMarkers[t.$tagHighlight].range)!==0&&(t.removeMarker(t.$tagHighlight),t.$tagHighlight=null),l&&!t.$tagHighlight&&(t.$tagHighlight=t.addMarker(l,"ace_bracket","text"))},50)},this.focus=function(){var e=this;setTimeout(function(){e.textInput.focus()}),this.textInput.focus()},this.isFocused=function(){return this.textInput.isFocused()},this.blur=function(){this.textInput.blur()},this.onFocus=function(e){if(this.$isFocused)return;this.$isFocused=!0,this.renderer.showCursor(),this.renderer.visualizeFocus(),this._emit("focus",e)},this.onBlur=function(e){if(!this.$isFocused)return;this.$isFocused=!1,this.renderer.hideCursor(),this.renderer.visualizeBlur(),this._emit("blur",e)},this.$cursorChange=function(){this.renderer.updateCursor()},this.onDocumentChange=function(e){var t=this.session.$useWrapMode,n=e.start.row==e.end.row?e.end.row:Infinity;this.renderer.updateLines(e.start.row,n,t),this._signal("change",e),this.$cursorChange(),this.$updateHighlightActiveLine()},this.onTokenizerUpdate=function(e){var t=e.data;this.renderer.updateLines(t.first,t.last)},this.onScrollTopChange=function(){this.renderer.scrollToY(this.session.getScrollTop())},this.onScrollLeftChange=function(){this.renderer.scrollToX(this.session.getScrollLeft())},this.onCursorChange=function(){this.$cursorChange(),this.$blockScrolling||(g.warn("Automatically scrolling cursor into view after selection change","this will be disabled in the next version","set editor.$blockScrolling = Infinity to disable this message"),this.renderer.scrollCursorIntoView()),this.$highlightBrackets(),this.$highlightTags(),this.$updateHighlightActiveLine(),this._signal("changeSelection")},this.$updateHighlightActiveLine=function(){var e=this.getSession(),t;if(this.$highlightActiveLine){if(this.$selectionStyle!="line"||!this.selection.isMultiLine())t=this.getCursorPosition();this.renderer.$maxLines&&this.session.getLength()===1&&!(this.renderer.$minLines>1)&&(t=!1)}if(e.$highlightLineMarker&&!t)e.removeMarker(e.$highlightLineMarker.id),e.$highlightLineMarker=null;else if(!e.$highlightLineMarker&&t){var n=new p(t.row,t.column,t.row,Infinity);n.id=e.addMarker(n,"ace_active-line","screenLine"),e.$highlightLineMarker=n}else t&&(e.$highlightLineMarker.start.row=t.row,e.$highlightLineMarker.end.row=t.row,e.$highlightLineMarker.start.column=t.column,e._signal("changeBackMarker"))},this.onSelectionChange=function(e){var t=this.session;t.$selectionMarker&&t.removeMarker(t.$selectionMarker),t.$selectionMarker=null;if(!this.selection.isEmpty()){var n=this.selection.getRange(),r=this.getSelectionStyle();t.$selectionMarker=t.addMarker(n,"ace_selection",r)}else this.$updateHighlightActiveLine();var i=this.$highlightSelectedWord&&this.$getSelectionHighLightRegexp();this.session.highlight(i),this._signal("changeSelection")},this.$getSelectionHighLightRegexp=function(){var e=this.session,t=this.getSelectionRange();if(t.isEmpty()||t.isMultiLine())return;var n=t.start.column-1,r=t.end.column+1,i=e.getLine(t.start.row),s=i.length,o=i.substring(Math.max(n,0),Math.min(r,s));if(n>=0&&/^[\w\d]/.test(o)||r<=s&&/[\w\d]$/.test(o))return;o=i.substring(t.start.column,t.end.column);if(!/^[\w\d]+$/.test(o))return;var u=this.$search.$assembleRegExp({wholeWord:!0,caseSensitive:!0,needle:o});return u},this.onChangeFrontMarker=function(){this.renderer.updateFrontMarkers()},this.onChangeBackMarker=function(){this.renderer.updateBackMarkers()},this.onChangeBreakpoint=function(){this.renderer.updateBreakpoints()},this.onChangeAnnotation=function(){this.renderer.setAnnotations(this.session.getAnnotations())},this.onChangeMode=function(e){this.renderer.updateText(),this._emit("changeMode",e)},this.onChangeWrapLimit=function(){this.renderer.updateFull()},this.onChangeWrapMode=function(){this.renderer.onResize(!0)},this.onChangeFold=function(){this.$updateHighlightActiveLine(),this.renderer.updateFull()},this.getSelectedText=function(){return this.session.getTextRange(this.getSelectionRange())},this.getCopyText=function(){var e=this.getSelectedText();return this._signal("copy",e),e},this.onCopy=function(){this.commands.exec("copy",this)},this.onCut=function(){this.commands.exec("cut",this)},this.onPaste=function(e,t){var n={text:e,event:t};this.commands.exec("paste",this,n)},this.$handlePaste=function(e){typeof e=="string"&&(e={text:e}),this._signal("paste",e);var t=e.text;if(!this.inMultiSelectMode||this.inVirtualSelectionMode)this.insert(t);else{var n=t.split(/\r\n|\r|\n/),r=this.selection.rangeList.ranges;if(n.length>r.length||n.length<2||!n[1])return this.commands.exec("insertstring",this,t);for(var i=r.length;i--;){var s=r[i];s.isEmpty()||this.session.remove(s),this.session.insert(s.start,n[i])}}},this.execCommand=function(e,t){return this.commands.exec(e,this,t)},this.insert=function(e,t){var n=this.session,r=n.getMode(),i=this.getCursorPosition();if(this.getBehavioursEnabled()&&!t){var s=r.transformAction(n.getState(i.row),"insertion",this,n,e);s&&(e!==s.text&&(this.session.mergeUndoDeltas=!1,this.$mergeNextCommand=!1),e=s.text)}e==" "&&(e=this.session.getTabString());if(!this.selection.isEmpty()){var o=this.getSelectionRange();i=this.session.remove(o),this.clearSelection()}else if(this.session.getOverwrite()){var o=new p.fromPoints(i,i);o.end.column+=e.length,this.session.remove(o)}if(e=="\n"||e=="\r\n"){var u=n.getLine(i.row);if(i.column>u.search(/\S|$/)){var a=u.substr(i.column).search(/\S|$/);n.doc.removeInLine(i.row,i.column,i.column+a)}}this.clearSelection();var f=i.column,l=n.getState(i.row),u=n.getLine(i.row),c=r.checkOutdent(l,u,e),h=n.insert(i,e);s&&s.selection&&(s.selection.length==2?this.selection.setSelectionRange(new p(i.row,f+s.selection[0],i.row,f+s.selection[1])):this.selection.setSelectionRange(new p(i.row+s.selection[0],s.selection[1],i.row+s.selection[2],s.selection[3])));if(n.getDocument().isNewLine(e)){var d=r.getNextLineIndent(l,u.slice(0,i.column),n.getTabString());n.insert({row:i.row+1,column:0},d)}c&&r.autoOutdent(l,n,i.row)},this.onTextInput=function(e){this.keyBinding.onTextInput(e)},this.onCommandKey=function(e,t,n){this.keyBinding.onCommandKey(e,t,n)},this.setOverwrite=function(e){this.session.setOverwrite(e)},this.getOverwrite=function(){return this.session.getOverwrite()},this.toggleOverwrite=function(){this.session.toggleOverwrite()},this.setScrollSpeed=function(e){this.setOption("scrollSpeed",e)},this.getScrollSpeed=function(){return this.getOption("scrollSpeed")},this.setDragDelay=function(e){this.setOption("dragDelay",e)},this.getDragDelay=function(){return this.getOption("dragDelay")},this.setSelectionStyle=function(e){this.setOption("selectionStyle",e)},this.getSelectionStyle=function(){return this.getOption("selectionStyle")},this.setHighlightActiveLine=function(e){this.setOption("highlightActiveLine",e)},this.getHighlightActiveLine=function(){return this.getOption("highlightActiveLine")},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.setHighlightSelectedWord=function(e){this.setOption("highlightSelectedWord",e)},this.getHighlightSelectedWord=function(){return this.$highlightSelectedWord},this.setAnimatedScroll=function(e){this.renderer.setAnimatedScroll(e)},this.getAnimatedScroll=function(){return this.renderer.getAnimatedScroll()},this.setShowInvisibles=function(e){this.renderer.setShowInvisibles(e)},this.getShowInvisibles=function(){return this.renderer.getShowInvisibles()},this.setDisplayIndentGuides=function(e){this.renderer.setDisplayIndentGuides(e)},this.getDisplayIndentGuides=function(){return this.renderer.getDisplayIndentGuides()},this.setShowPrintMargin=function(e){this.renderer.setShowPrintMargin(e)},this.getShowPrintMargin=function(){return this.renderer.getShowPrintMargin()},this.setPrintMarginColumn=function(e){this.renderer.setPrintMarginColumn(e)},this.getPrintMarginColumn=function(){return this.renderer.getPrintMarginColumn()},this.setReadOnly=function(e){this.setOption("readOnly",e)},this.getReadOnly=function(){return this.getOption("readOnly")},this.setBehavioursEnabled=function(e){this.setOption("behavioursEnabled",e)},this.getBehavioursEnabled=function(){return this.getOption("behavioursEnabled")},this.setWrapBehavioursEnabled=function(e){this.setOption("wrapBehavioursEnabled",e)},this.getWrapBehavioursEnabled=function(){return this.getOption("wrapBehavioursEnabled")},this.setShowFoldWidgets=function(e){this.setOption("showFoldWidgets",e)},this.getShowFoldWidgets=function(){return this.getOption("showFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.remove=function(e){this.selection.isEmpty()&&(e=="left"?this.selection.selectLeft():this.selection.selectRight());var t=this.getSelectionRange();if(this.getBehavioursEnabled()){var n=this.session,r=n.getState(t.start.row),i=n.getMode().transformAction(r,"deletion",this,n,t);if(t.end.column===0){var s=n.getTextRange(t);if(s[s.length-1]=="\n"){var o=n.getLine(t.end.row);/^\s+$/.test(o)&&(t.end.column=o.length)}}i&&(t=i)}this.session.remove(t),this.clearSelection()},this.removeWordRight=function(){this.selection.isEmpty()&&this.selection.selectWordRight(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeWordLeft=function(){this.selection.isEmpty()&&this.selection.selectWordLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineStart=function(){this.selection.isEmpty()&&this.selection.selectLineStart(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineEnd=function(){this.selection.isEmpty()&&this.selection.selectLineEnd();var e=this.getSelectionRange();e.start.column==e.end.column&&e.start.row==e.end.row&&(e.end.column=0,e.end.row++),this.session.remove(e),this.clearSelection()},this.splitLine=function(){this.selection.isEmpty()||(this.session.remove(this.getSelectionRange()),this.clearSelection());var e=this.getCursorPosition();this.insert("\n"),this.moveCursorToPosition(e)},this.transposeLetters=function(){if(!this.selection.isEmpty())return;var e=this.getCursorPosition(),t=e.column;if(t===0)return;var n=this.session.getLine(e.row),r,i;t<n.length?(r=n.charAt(t)+n.charAt(t-1),i=new p(e.row,t-1,e.row,t+1)):(r=n.charAt(t-1)+n.charAt(t-2),i=new p(e.row,t-2,e.row,t)),this.session.replace(i,r)},this.toLowerCase=function(){var e=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var t=this.getSelectionRange(),n=this.session.getTextRange(t);this.session.replace(t,n.toLowerCase()),this.selection.setSelectionRange(e)},this.toUpperCase=function(){var e=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var t=this.getSelectionRange(),n=this.session.getTextRange(t);this.session.replace(t,n.toUpperCase()),this.selection.setSelectionRange(e)},this.indent=function(){var e=this.session,t=this.getSelectionRange();if(t.start.row<t.end.row){var n=this.$getSelectedRows();e.indentRows(n.first,n.last," ");return}if(t.start.column<t.end.column){var r=e.getTextRange(t);if(!/^\s+$/.test(r)){var n=this.$getSelectedRows();e.indentRows(n.first,n.last," ");return}}var i=e.getLine(t.start.row),o=t.start,u=e.getTabSize(),a=e.documentToScreenColumn(o.row,o.column);if(this.session.getUseSoftTabs())var f=u-a%u,l=s.stringRepeat(" ",f);else{var f=a%u;while(i[t.start.column-1]==" "&&f)t.start.column--,f--;this.selection.setSelectionRange(t),l=" "}return this.insert(l)},this.blockIndent=function(){var e=this.$getSelectedRows();this.session.indentRows(e.first,e.last," ")},this.blockOutdent=function(){var e=this.session.getSelection();this.session.outdentRows(e.getRange())},this.sortLines=function(){var e=this.$getSelectedRows(),t=this.session,n=[];for(i=e.first;i<=e.last;i++)n.push(t.getLine(i));n.sort(function(e,t){return e.toLowerCase()<t.toLowerCase()?-1:e.toLowerCase()>t.toLowerCase()?1:0});var r=new p(0,0,0,0);for(var i=e.first;i<=e.last;i++){var s=t.getLine(i);r.start.row=i,r.end.row=i,r.end.column=s.length,t.replace(r,n[i-e.first])}},this.toggleCommentLines=function(){var e=this.session.getState(this.getCursorPosition().row),t=this.$getSelectedRows();this.session.getMode().toggleCommentLines(e,this.session,t.first,t.last)},this.toggleBlockComment=function(){var e=this.getCursorPosition(),t=this.session.getState(e.row),n=this.getSelectionRange();this.session.getMode().toggleBlockComment(t,this.session,n,e)},this.getNumberAt=function(e,t){var n=/[\-]?[0-9]+(?:\.[0-9]+)?/g;n.lastIndex=0;var r=this.session.getLine(e);while(n.lastIndex<t){var i=n.exec(r);if(i.index<=t&&i.index+i[0].length>=t){var s={value:i[0],start:i.index,end:i.index+i[0].length};return s}}return null},this.modifyNumber=function(e){var t=this.selection.getCursor().row,n=this.selection.getCursor().column,r=new p(t,n-1,t,n),i=this.session.getTextRange(r);if(!isNaN(parseFloat(i))&&isFinite(i)){var s=this.getNumberAt(t,n);if(s){var o=s.value.indexOf(".")>=0?s.start+s.value.indexOf(".")+1:s.end,u=s.start+s.value.length-o,a=parseFloat(s.value);a*=Math.pow(10,u),o!==s.end&&n<o?e*=Math.pow(10,s.end-n-1):e*=Math.pow(10,s.end-n),a+=e,a/=Math.pow(10,u);var f=a.toFixed(u),l=new p(t,s.start,t,s.end);this.session.replace(l,f),this.moveCursorTo(t,Math.max(s.start+1,n+f.length-s.value.length))}}},this.removeLines=function(){var e=this.$getSelectedRows();this.session.removeFullLines(e.first,e.last),this.clearSelection()},this.duplicateSelection=function(){var e=this.selection,t=this.session,n=e.getRange(),r=e.isBackwards();if(n.isEmpty()){var i=n.start.row;t.duplicateLines(i,i)}else{var s=r?n.start:n.end,o=t.insert(s,t.getTextRange(n),!1);n.start=s,n.end=o,e.setSelectionRange(n,r)}},this.moveLinesDown=function(){this.$moveLines(1,!1)},this.moveLinesUp=function(){this.$moveLines(-1,!1)},this.moveText=function(e,t,n){return this.session.moveText(e,t,n)},this.copyLinesUp=function(){this.$moveLines(-1,!0)},this.copyLinesDown=function(){this.$moveLines(1,!0)},this.$moveLines=function(e,t){var n,r,i=this.selection;if(!i.inMultiSelectMode||this.inVirtualSelectionMode){var s=i.toOrientedRange();n=this.$getSelectedRows(s),r=this.session.$moveLines(n.first,n.last,t?0:e),t&&e==-1&&(r=0),s.moveBy(r,0),i.fromOrientedRange(s)}else{var o=i.rangeList.ranges;i.rangeList.detach(this.session),this.inVirtualSelectionMode=!0;var u=0,a=0,f=o.length;for(var l=0;l<f;l++){var c=l;o[l].moveBy(u,0),n=this.$getSelectedRows(o[l]);var h=n.first,p=n.last;while(++l<f){a&&o[l].moveBy(a,0);var d=this.$getSelectedRows(o[l]);if(t&&d.first!=p)break;if(!t&&d.first>p+1)break;p=d.last}l--,u=this.session.$moveLines(h,p,t?0:e),t&&e==-1&&(c=l+1);while(c<=l)o[c].moveBy(u,0),c++;t||(u=0),a+=u}i.fromOrientedRange(i.ranges[0]),i.rangeList.attach(this.session),this.inVirtualSelectionMode=!1}},this.$getSelectedRows=function(e){return e=(e||this.getSelectionRange()).collapseRows(),{first:this.session.getRowFoldStart(e.start.row),last:this.session.getRowFoldEnd(e.end.row)}},this.onCompositionStart=function(e){this.renderer.showComposition(this.getCursorPosition())},this.onCompositionUpdate=function(e){this.renderer.setCompositionText(e)},this.onCompositionEnd=function(){this.renderer.hideComposition()},this.getFirstVisibleRow=function(){return this.renderer.getFirstVisibleRow()},this.getLastVisibleRow=function(){return this.renderer.getLastVisibleRow()},this.isRowVisible=function(e){return e>=this.getFirstVisibleRow()&&e<=this.getLastVisibleRow()},this.isRowFullyVisible=function(e){return e>=this.renderer.getFirstFullyVisibleRow()&&e<=this.renderer.getLastFullyVisibleRow()},this.$getVisibleRowCount=function(){return this.renderer.getScrollBottomRow()-this.renderer.getScrollTopRow()+1},this.$moveByPage=function(e,t){var n=this.renderer,r=this.renderer.layerConfig,i=e*Math.floor(r.height/r.lineHeight);this.$blockScrolling++,t===!0?this.selection.$moveSelection(function(){this.moveCursorBy(i,0)}):t===!1&&(this.selection.moveCursorBy(i,0),this.selection.clearSelection()),this.$blockScrolling--;var s=n.scrollTop;n.scrollBy(0,i*r.lineHeight),t!=null&&n.scrollCursorIntoView(null,.5),n.animateScrolling(s)},this.selectPageDown=function(){this.$moveByPage(1,!0)},this.selectPageUp=function(){this.$moveByPage(-1,!0)},this.gotoPageDown=function(){this.$moveByPage(1,!1)},this.gotoPageUp=function(){this.$moveByPage(-1,!1)},this.scrollPageDown=function(){this.$moveByPage(1)},this.scrollPageUp=function(){this.$moveByPage(-1)},this.scrollToRow=function(e){this.renderer.scrollToRow(e)},this.scrollToLine=function(e,t,n,r){this.renderer.scrollToLine(e,t,n,r)},this.centerSelection=function(){var e=this.getSelectionRange(),t={row:Math.floor(e.start.row+(e.end.row-e.start.row)/2),column:Math.floor(e.start.column+(e.end.column-e.start.column)/2)};this.renderer.alignCursor(t,.5)},this.getCursorPosition=function(){return this.selection.getCursor()},this.getCursorPositionScreen=function(){return this.session.documentToScreenPosition(this.getCursorPosition())},this.getSelectionRange=function(){return this.selection.getRange()},this.selectAll=function(){this.$blockScrolling+=1,this.selection.selectAll(),this.$blockScrolling-=1},this.clearSelection=function(){this.selection.clearSelection()},this.moveCursorTo=function(e,t){this.selection.moveCursorTo(e,t)},this.moveCursorToPosition=function(e){this.selection.moveCursorToPosition(e)},this.jumpToMatching=function(e,t){var n=this.getCursorPosition(),r=new y(this.session,n.row,n.column),i=r.getCurrentToken(),s=i||r.stepForward();if(!s)return;var o,u=!1,a={},f=n.column-s.start,l,c={")":"(","(":"(","]":"[","[":"[","{":"{","}":"{"};do{if(s.value.match(/[{}()\[\]]/g))for(;f<s.value.length&&!u;f++){if(!c[s.value[f]])continue;l=c[s.value[f]]+"."+s.type.replace("rparen","lparen"),isNaN(a[l])&&(a[l]=0);switch(s.value[f]){case"(":case"[":case"{":a[l]++;break;case")":case"]":case"}":a[l]--,a[l]===-1&&(o="bracket",u=!0)}}else s&&s.type.indexOf("tag-name")!==-1&&(isNaN(a[s.value])&&(a[s.value]=0),i.value==="<"?a[s.value]++:i.value==="</"&&a[s.value]--,a[s.value]===-1&&(o="tag",u=!0));u||(i=s,s=r.stepForward(),f=0)}while(s&&!u);if(!o)return;var h,d;if(o==="bracket"){h=this.session.getBracketRange(n);if(!h){h=new p(r.getCurrentTokenRow(),r.getCurrentTokenColumn()+f-1,r.getCurrentTokenRow(),r.getCurrentTokenColumn()+f-1),d=h.start;if(t||d.row===n.row&&Math.abs(d.column-n.column)<2)h=this.session.getBracketRange(d)}}else if(o==="tag"){if(!s||s.type.indexOf("tag-name")===-1)return;var v=s.value;h=new p(r.getCurrentTokenRow(),r.getCurrentTokenColumn()-2,r.getCurrentTokenRow(),r.getCurrentTokenColumn()-2);if(h.compare(n.row,n.column)===0){u=!1;do s=i,i=r.stepBackward(),i&&(i.type.indexOf("tag-close")!==-1&&h.setEnd(r.getCurrentTokenRow(),r.getCurrentTokenColumn()+1),s.value===v&&s.type.indexOf("tag-name")!==-1&&(i.value==="<"?a[v]++:i.value==="</"&&a[v]--,a[v]===0&&(u=!0)));while(i&&!u)}s&&s.type.indexOf("tag-name")&&(d=h.start,d.row==n.row&&Math.abs(d.column-n.column)<2&&(d=h.end))}d=h&&h.cursor||d,d&&(e?h&&t?this.selection.setRange(h):h&&h.isEqual(this.getSelectionRange())?this.clearSelection():this.selection.selectTo(d.row,d.column):this.selection.moveTo(d.row,d.column))},this.gotoLine=function(e,t,n){this.selection.clearSelection(),this.session.unfold({row:e-1,column:t||0}),this.$blockScrolling+=1,this.exitMultiSelectMode&&this.exitMultiSelectMode(),this.moveCursorTo(e-1,t||0),this.$blockScrolling-=1,this.isRowFullyVisible(e-1)||this.scrollToLine(e-1,!0,n)},this.navigateTo=function(e,t){this.selection.moveTo(e,t)},this.navigateUp=function(e){if(this.selection.isMultiLine()&&!this.selection.isBackwards()){var t=this.selection.anchor.getPosition();return this.moveCursorToPosition(t)}this.selection.clearSelection(),this.selection.moveCursorBy(-e||-1,0)},this.navigateDown=function(e){if(this.selection.isMultiLine()&&this.selection.isBackwards()){var t=this.selection.anchor.getPosition();return this.moveCursorToPosition(t)}this.selection.clearSelection(),this.selection.moveCursorBy(e||1,0)},this.navigateLeft=function(e){if(!this.selection.isEmpty()){var t=this.getSelectionRange().start;this.moveCursorToPosition(t)}else{e=e||1;while(e--)this.selection.moveCursorLeft()}this.clearSelection()},this.navigateRight=function(e){if(!this.selection.isEmpty()){var t=this.getSelectionRange().end;this.moveCursorToPosition(t)}else{e=e||1;while(e--)this.selection.moveCursorRight()}this.clearSelection()},this.navigateLineStart=function(){this.selection.moveCursorLineStart(),this.clearSelection()},this.navigateLineEnd=function(){this.selection.moveCursorLineEnd(),this.clearSelection()},this.navigateFileEnd=function(){this.selection.moveCursorFileEnd(),this.clearSelection()},this.navigateFileStart=function(){this.selection.moveCursorFileStart(),this.clearSelection()},this.navigateWordRight=function(){this.selection.moveCursorWordRight(),this.clearSelection()},this.navigateWordLeft=function(){this.selection.moveCursorWordLeft(),this.clearSelection()},this.replace=function(e,t){t&&this.$search.set(t);var n=this.$search.find(this.session),r=0;return n?(this.$tryReplace(n,e)&&(r=1),n!==null&&(this.selection.setSelectionRange(n),this.renderer.scrollSelectionIntoView(n.start,n.end)),r):r},this.replaceAll=function(e,t){t&&this.$search.set(t);var n=this.$search.findAll(this.session),r=0;if(!n.length)return r;this.$blockScrolling+=1;var i=this.getSelectionRange();this.selection.moveTo(0,0);for(var s=n.length-1;s>=0;--s)this.$tryReplace(n[s],e)&&r++;return this.selection.setSelectionRange(i),this.$blockScrolling-=1,r},this.$tryReplace=function(e,t){var n=this.session.getTextRange(e);return t=this.$search.replace(n,t),t!==null?(e.end=this.session.replace(e,t),e):null},this.getLastSearchOptions=function(){return this.$search.getOptions()},this.find=function(e,t,n){t||(t={}),typeof e=="string"||e instanceof RegExp?t.needle=e:typeof e=="object"&&r.mixin(t,e);var i=this.selection.getRange();t.needle==null&&(e=this.session.getTextRange(i)||this.$search.$options.needle,e||(i=this.session.getWordRange(i.start.row,i.start.column),e=this.session.getTextRange(i)),this.$search.set({needle:e})),this.$search.set(t),t.start||this.$search.set({start:i});var s=this.$search.find(this.session);if(t.preventScroll)return s;if(s)return this.revealRange(s,n),s;t.backwards?i.start=i.end:i.end=i.start,this.selection.setRange(i)},this.findNext=function(e,t){this.find({skipCurrent:!0,backwards:!1},e,t)},this.findPrevious=function(e,t){this.find(e,{skipCurrent:!0,backwards:!0},t)},this.revealRange=function(e,t){this.$blockScrolling+=1,this.session.unfold(e),this.selection.setSelectionRange(e),this.$blockScrolling-=1;var n=this.renderer.scrollTop;this.renderer.scrollSelectionIntoView(e.start,e.end,.5),t!==!1&&this.renderer.animateScrolling(n)},this.undo=function(){this.$blockScrolling++,this.session.getUndoManager().undo(),this.$blockScrolling--,this.renderer.scrollCursorIntoView(null,.5)},this.redo=function(){this.$blockScrolling++,this.session.getUndoManager().redo(),this.$blockScrolling--,this.renderer.scrollCursorIntoView(null,.5)},this.destroy=function(){this.renderer.destroy(),this._signal("destroy",this),this.session&&this.session.destroy()},this.setAutoScrollEditorIntoView=function(e){if(!e)return;var t,n=this,r=!1;this.$scrollAnchor||(this.$scrollAnchor=document.createElement("div"));var i=this.$scrollAnchor;i.style.cssText="position:absolute",this.container.insertBefore(i,this.container.firstChild);var s=this.on("changeSelection",function(){r=!0}),o=this.renderer.on("beforeRender",function(){r&&(t=n.renderer.container.getBoundingClientRect())}),u=this.renderer.on("afterRender",function(){if(r&&t&&(n.isFocused()||n.searchBox&&n.searchBox.isFocused())){var e=n.renderer,s=e.$cursorLayer.$pixelPos,o=e.layerConfig,u=s.top-o.offset;s.top>=0&&u+t.top<0?r=!0:s.top<o.height&&s.top+t.top+o.lineHeight>window.innerHeight?r=!1:r=null,r!=null&&(i.style.top=u+"px",i.style.left=s.left+"px",i.style.height=o.lineHeight+"px",i.scrollIntoView(r)),r=t=null}});this.setAutoScrollEditorIntoView=function(e){if(e)return;delete this.setAutoScrollEditorIntoView,this.off("changeSelection",s),this.renderer.off("afterRender",u),this.renderer.off("beforeRender",o)}},this.$resetCursorStyle=function(){var e=this.$cursorStyle||"ace",t=this.renderer.$cursorLayer;if(!t)return;t.setSmoothBlinking(/smooth/.test(e)),t.isBlinking=!this.$readOnly&&e!="wide",i.setCssClass(t.element,"ace_slim-cursors",/slim/.test(e))}}).call(b.prototype),g.defineOptions(b.prototype,"editor",{selectionStyle:{set:function(e){this.onSelectionChange(),this._signal("changeSelectionStyle",{data:e})},initialValue:"line"},highlightActiveLine:{set:function(){this.$updateHighlightActiveLine()},initialValue:!0},highlightSelectedWord:{set:function(e){this.$onSelectionChange()},initialValue:!0},readOnly:{set:function(e){this.$resetCursorStyle()},initialValue:!1},cursorStyle:{set:function(e){this.$resetCursorStyle()},values:["ace","slim","smooth","wide"],initialValue:"ace"},mergeUndoDeltas:{values:[!1,!0,"always"],initialValue:!0},behavioursEnabled:{initialValue:!0},wrapBehavioursEnabled:{initialValue:!0},autoScrollEditorIntoView:{set:function(e){this.setAutoScrollEditorIntoView(e)}},keyboardHandler:{set:function(e){this.setKeyboardHandler(e)},get:function(){return this.keybindingId},handlesSet:!0},hScrollBarAlwaysVisible:"renderer",vScrollBarAlwaysVisible:"renderer",highlightGutterLine:"renderer",animatedScroll:"renderer",showInvisibles:"renderer",showPrintMargin:"renderer",printMarginColumn:"renderer",printMargin:"renderer",fadeFoldWidgets:"renderer",showFoldWidgets:"renderer",showLineNumbers:"renderer",showGutter:"renderer",displayIndentGuides:"renderer",fontSize:"renderer",fontFamily:"renderer",maxLines:"renderer",minLines:"renderer",scrollPastEnd:"renderer",fixedWidthGutter:"renderer",theme:"renderer",scrollSpeed:"$mouseHandler",dragDelay:"$mouseHandler",dragEnabled:"$mouseHandler",focusTimout:"$mouseHandler",tooltipFollowsMouse:"$mouseHandler",firstLineNumber:"session",overwrite:"session",newLineMode:"session",useWorker:"session",useSoftTabs:"session",tabSize:"session",wrap:"session",indentedSoftWrap:"session",foldStyle:"session",mode:"session"}),t.Editor=b}),ace.define("ace/undomanager",["require","exports","module"],function(e,t,n){"use strict";var r=function(){this.reset()};(function(){function e(e){return{action:e.action,start:e.start,end:e.end,lines:e.lines.length==1?null:e.lines,text:e.lines.length==1?e.lines[0]:null}}function t(e){return{action:e.action,start:e.start,end:e.end,lines:e.lines||[e.text]}}function n(e,t){var n=new Array(e.length);for(var r=0;r<e.length;r++){var i=e[r],s={group:i.group,deltas:new Array(i.length)};for(var o=0;o<i.deltas.length;o++){var u=i.deltas[o];s.deltas[o]=t(u)}n[r]=s}return n}this.execute=function(e){var t=e.args[0];this.$doc=e.args[1],e.merge&&this.hasUndo()&&(this.dirtyCounter--,t=this.$undoStack.pop().concat(t)),this.$undoStack.push(t),this.$redoStack=[],this.dirtyCounter<0&&(this.dirtyCounter=NaN),this.dirtyCounter++},this.undo=function(e){var t=this.$undoStack.pop(),n=null;return t&&(n=this.$doc.undoChanges(t,e),this.$redoStack.push(t),this.dirtyCounter--),n},this.redo=function(e){var t=this.$redoStack.pop(),n=null;return t&&(n=this.$doc.redoChanges(this.$deserializeDeltas(t),e),this.$undoStack.push(t),this.dirtyCounter++),n},this.reset=function(){this.$undoStack=[],this.$redoStack=[],this.dirtyCounter=0},this.hasUndo=function(){return this.$undoStack.length>0},this.hasRedo=function(){return this.$redoStack.length>0},this.markClean=function(){this.dirtyCounter=0},this.isClean=function(){return this.dirtyCounter===0},this.$serializeDeltas=function(t){return n(t,e)},this.$deserializeDeltas=function(e){return n(e,t)}}).call(r.prototype),t.UndoManager=r}),ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/lang"),o=e("../lib/event_emitter").EventEmitter,u=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_gutter-layer",e.appendChild(this.element),this.setShowFoldWidgets(this.$showFoldWidgets),this.gutterWidth=0,this.$annotations=[],this.$updateAnnotations=this.$updateAnnotations.bind(this),this.$cells=[]};(function(){i.implement(this,o),this.setSession=function(e){this.session&&this.session.removeEventListener("change",this.$updateAnnotations),this.session=e,e&&e.on("change",this.$updateAnnotations)},this.addGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.addGutterDecoration"),this.session.addGutterDecoration(e,t)},this.removeGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.removeGutterDecoration"),this.session.removeGutterDecoration(e,t)},this.setAnnotations=function(e){this.$annotations=[];for(var t=0;t<e.length;t++){var n=e[t],r=n.row,i=this.$annotations[r];i||(i=this.$annotations[r]={text:[]});var o=n.text;o=o?s.escapeHTML(o):n.html||"",i.text.indexOf(o)===-1&&i.text.push(o);var u=n.type;u=="error"?i.className=" ace_error":u=="warning"&&i.className!=" ace_error"?i.className=" ace_warning":u=="info"&&!i.className&&(i.className=" ace_info")}},this.$updateAnnotations=function(e){if(!this.$annotations.length)return;var t=e.start.row,n=e.end.row-t;if(n!==0)if(e.action=="remove")this.$annotations.splice(t,n+1,null);else{var r=new Array(n+1);r.unshift(t,1),this.$annotations.splice.apply(this.$annotations,r)}},this.update=function(e){var t=this.session,n=e.firstRow,i=Math.min(e.lastRow+e.gutterOffset,t.getLength()-1),s=t.getNextFoldLine(n),o=s?s.start.row:Infinity,u=this.$showFoldWidgets&&t.foldWidgets,a=t.$breakpoints,f=t.$decorations,l=t.$firstLineNumber,c=0,h=t.gutterRenderer||this.$renderer,p=null,d=-1,v=n;for(;;){v>o&&(v=s.end.row+1,s=t.getNextFoldLine(v,s),o=s?s.start.row:Infinity);if(v>i){while(this.$cells.length>d+1)p=this.$cells.pop(),this.element.removeChild(p.element);break}p=this.$cells[++d],p||(p={element:null,textNode:null,foldWidget:null},p.element=r.createElement("div"),p.textNode=document.createTextNode(""),p.element.appendChild(p.textNode),this.element.appendChild(p.element),this.$cells[d]=p);var m="ace_gutter-cell ";a[v]&&(m+=a[v]),f[v]&&(m+=f[v]),this.$annotations[v]&&(m+=this.$annotations[v].className),p.element.className!=m&&(p.element.className=m);var g=t.getRowLength(v)*e.lineHeight+"px";g!=p.element.style.height&&(p.element.style.height=g);if(u){var y=u[v];y==null&&(y=u[v]=t.getFoldWidget(v))}if(y){p.foldWidget||(p.foldWidget=r.createElement("span"),p.element.appendChild(p.foldWidget));var m="ace_fold-widget ace_"+y;y=="start"&&v==o&&v<s.end.row?m+=" ace_closed":m+=" ace_open",p.foldWidget.className!=m&&(p.foldWidget.className=m);var g=e.lineHeight+"px";p.foldWidget.style.height!=g&&(p.foldWidget.style.height=g)}else p.foldWidget&&(p.element.removeChild(p.foldWidget),p.foldWidget=null);var b=c=h?h.getText(t,v):v+l;b!=p.textNode.data&&(p.textNode.data=b),v++}this.element.style.height=e.minHeight+"px";if(this.$fixedWidth||t.$useWrapMode)c=t.getLength()+l;var w=h?h.getWidth(t,c,e):c.toString().length*e.characterWidth,E=this.$padding||this.$computePadding();w+=E.left+E.right,w!==this.gutterWidth&&!isNaN(w)&&(this.gutterWidth=w,this.element.style.width=Math.ceil(this.gutterWidth)+"px",this._emit("changeGutterWidth",w))},this.$fixedWidth=!1,this.$showLineNumbers=!0,this.$renderer="",this.setShowLineNumbers=function(e){this.$renderer=!e&&{getWidth:function(){return""},getText:function(){return""}}},this.getShowLineNumbers=function(){return this.$showLineNumbers},this.$showFoldWidgets=!0,this.setShowFoldWidgets=function(e){e?r.addCssClass(this.element,"ace_folding-enabled"):r.removeCssClass(this.element,"ace_folding-enabled"),this.$showFoldWidgets=e,this.$padding=null},this.getShowFoldWidgets=function(){return this.$showFoldWidgets},this.$computePadding=function(){if(!this.element.firstChild)return{left:0,right:0};var e=r.computedStyle(this.element.firstChild);return this.$padding={},this.$padding.left=parseInt(e.paddingLeft)+1||0,this.$padding.right=parseInt(e.paddingRight)||0,this.$padding},this.getRegion=function(e){var t=this.$padding||this.$computePadding(),n=this.element.getBoundingClientRect();if(e.x<t.left+n.left)return"markers";if(this.$showFoldWidgets&&e.x>n.right-t.right)return"foldWidgets"}}).call(u.prototype),t.Gutter=u}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../range").Range,i=e("../lib/dom"),s=function(e){this.element=i.createElement("div"),this.element.className="ace_layer ace_marker-layer",e.appendChild(this.element)};(function(){function e(e,t,n,r){return(e?1:0)|(t?2:0)|(n?4:0)|(r?8:0)}this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setMarkers=function(e){this.markers=e},this.update=function(e){var e=e||this.config;if(!e)return;this.config=e;var t=[];for(var n in this.markers){var r=this.markers[n];if(!r.range){r.update(t,this,this.session,e);continue}var i=r.range.clipRows(e.firstRow,e.lastRow);if(i.isEmpty())continue;i=i.toScreenRange(this.session);if(r.renderer){var s=this.$getTop(i.start.row,e),o=this.$padding+i.start.column*e.characterWidth;r.renderer(t,i,o,s,e)}else r.type=="fullLine"?this.drawFullLineMarker(t,i,r.clazz,e):r.type=="screenLine"?this.drawScreenLineMarker(t,i,r.clazz,e):i.isMultiLine()?r.type=="text"?this.drawTextMarker(t,i,r.clazz,e):this.drawMultiLineMarker(t,i,r.clazz,e):this.drawSingleLineMarker(t,i,r.clazz+" ace_start"+" ace_br15",e)}this.element.innerHTML=t.join("")},this.$getTop=function(e,t){return(e-t.firstRowScreen)*t.lineHeight},this.drawTextMarker=function(t,n,i,s,o){var u=this.session,a=n.start.row,f=n.end.row,l=a,c=0,h=0,p=u.getScreenLastRowColumn(l),d=new r(l,n.start.column,l,h);for(;l<=f;l++)d.start.row=d.end.row=l,d.start.column=l==a?n.start.column:u.getRowWrapIndent(l),d.end.column=p,c=h,h=p,p=l+1<f?u.getScreenLastRowColumn(l+1):l==f?0:n.end.column,this.drawSingleLineMarker(t,d,i+(l==a?" ace_start":"")+" ace_br"+e(l==a||l==a+1&&n.start.column,c<h,h>p,l==f),s,l==f?0:1,o)},this.drawMultiLineMarker=function(e,t,n,r,i){var s=this.$padding,o=r.lineHeight,u=this.$getTop(t.start.row,r),a=s+t.start.column*r.characterWidth;i=i||"",e.push("<div class='",n," ace_br1 ace_start' style='","height:",o,"px;","right:0;","top:",u,"px;","left:",a,"px;",i,"'></div>"),u=this.$getTop(t.end.row,r);var f=t.end.column*r.characterWidth;e.push("<div class='",n," ace_br12' style='","height:",o,"px;","width:",f,"px;","top:",u,"px;","left:",s,"px;",i,"'></div>"),o=(t.end.row-t.start.row-1)*r.lineHeight;if(o<=0)return;u=this.$getTop(t.start.row+1,r);var l=(t.start.column?1:0)|(t.end.column?0:8);e.push("<div class='",n,l?" ace_br"+l:"","' style='","height:",o,"px;","right:0;","top:",u,"px;","left:",s,"px;",i,"'></div>")},this.drawSingleLineMarker=function(e,t,n,r,i,s){var o=r.lineHeight,u=(t.end.column+(i||0)-t.start.column)*r.characterWidth,a=this.$getTop(t.start.row,r),f=this.$padding+t.start.column*r.characterWidth;e.push("<div class='",n,"' style='","height:",o,"px;","width:",u,"px;","top:",a,"px;","left:",f,"px;",s||"","'></div>")},this.drawFullLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;t.start.row!=t.end.row&&(o+=this.$getTop(t.end.row,r)-s),e.push("<div class='",n,"' style='","height:",o,"px;","top:",s,"px;","left:0;right:0;",i||"","'></div>")},this.drawScreenLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;e.push("<div class='",n,"' style='","height:",o,"px;","top:",s,"px;","left:0;right:0;",i||"","'></div>")}}).call(s.prototype),t.Marker=s}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("../lib/useragent"),u=e("../lib/event_emitter").EventEmitter,a=function(e){this.element=i.createElement("div"),this.element.className="ace_layer ace_text-layer",e.appendChild(this.element),this.$updateEolChar=this.$updateEolChar.bind(this)};(function(){r.implement(this,u),this.EOF_CHAR="\u00b6",this.EOL_CHAR_LF="\u00ac",this.EOL_CHAR_CRLF="\u00a4",this.EOL_CHAR=this.EOL_CHAR_LF,this.TAB_CHAR="\u2014",this.SPACE_CHAR="\u00b7",this.$padding=0,this.$updateEolChar=function(){var e=this.session.doc.getNewLineCharacter()=="\n"?this.EOL_CHAR_LF:this.EOL_CHAR_CRLF;if(this.EOL_CHAR!=e)return this.EOL_CHAR=e,!0},this.setPadding=function(e){this.$padding=e,this.element.style.padding="0 "+e+"px"},this.getLineHeight=function(){return this.$fontMetrics.$characterSize.height||0},this.getCharacterWidth=function(){return this.$fontMetrics.$characterSize.width||0},this.$setFontMetrics=function(e){this.$fontMetrics=e,this.$fontMetrics.on("changeCharacterSize",function(e){this._signal("changeCharacterSize",e)}.bind(this)),this.$pollSizeChanges()},this.checkForSizeChanges=function(){this.$fontMetrics.checkForSizeChanges()},this.$pollSizeChanges=function(){return this.$pollSizeChangesTimer=this.$fontMetrics.$pollSizeChanges()},this.setSession=function(e){this.session=e,e&&this.$computeTabString()},this.showInvisibles=!1,this.setShowInvisibles=function(e){return this.showInvisibles==e?!1:(this.showInvisibles=e,this.$computeTabString(),!0)},this.displayIndentGuides=!0,this.setDisplayIndentGuides=function(e){return this.displayIndentGuides==e?!1:(this.displayIndentGuides=e,this.$computeTabString(),!0)},this.$tabStrings=[],this.onChangeTabSize=this.$computeTabString=function(){var e=this.session.getTabSize();this.tabSize=e;var t=this.$tabStrings=[0];for(var n=1;n<e+1;n++)this.showInvisibles?t.push("<span class='ace_invisible ace_invisible_tab'>"+s.stringRepeat(this.TAB_CHAR,n)+"</span>"):t.push(s.stringRepeat(" ",n));if(this.displayIndentGuides){this.$indentGuideRe=/\s\S| \t|\t |\s$/;var r="ace_indent-guide",i="",o="";if(this.showInvisibles){r+=" ace_invisible",i=" ace_invisible_space",o=" ace_invisible_tab";var u=s.stringRepeat(this.SPACE_CHAR,this.tabSize),a=s.stringRepeat(this.TAB_CHAR,this.tabSize)}else var u=s.stringRepeat(" ",this.tabSize),a=u;this.$tabStrings[" "]="<span class='"+r+i+"'>"+u+"</span>",this.$tabStrings[" "]="<span class='"+r+o+"'>"+a+"</span>"}},this.updateLines=function(e,t,n){(this.config.lastRow!=e.lastRow||this.config.firstRow!=e.firstRow)&&this.scrollLines(e),this.config=e;var r=Math.max(t,e.firstRow),i=Math.min(n,e.lastRow),s=this.element.childNodes,o=0;for(var u=e.firstRow;u<r;u++){var a=this.session.getFoldLine(u);if(a){if(a.containsRow(r)){r=a.start.row;break}u=a.end.row}o++}var u=r,a=this.session.getNextFoldLine(u),f=a?a.start.row:Infinity;for(;;){u>f&&(u=a.end.row+1,a=this.session.getNextFoldLine(u,a),f=a?a.start.row:Infinity);if(u>i)break;var l=s[o++];if(l){var c=[];this.$renderLine(c,u,!this.$useLineGroups(),u==f?a:!1),l.style.height=e.lineHeight*this.session.getRowLength(u)+"px",l.innerHTML=c.join("")}u++}},this.scrollLines=function(e){var t=this.config;this.config=e;if(!t||t.lastRow<e.firstRow)return this.update(e);if(e.lastRow<t.firstRow)return this.update(e);var n=this.element;if(t.firstRow<e.firstRow)for(var r=this.session.getFoldedRowCount(t.firstRow,e.firstRow-1);r>0;r--)n.removeChild(n.firstChild);if(t.lastRow>e.lastRow)for(var r=this.session.getFoldedRowCount(e.lastRow+1,t.lastRow);r>0;r--)n.removeChild(n.lastChild);if(e.firstRow<t.firstRow){var i=this.$renderLinesFragment(e,e.firstRow,t.firstRow-1);n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i)}if(e.lastRow>t.lastRow){var i=this.$renderLinesFragment(e,t.lastRow+1,e.lastRow);n.appendChild(i)}},this.$renderLinesFragment=function(e,t,n){var r=this.element.ownerDocument.createDocumentFragment(),s=t,o=this.session.getNextFoldLine(s),u=o?o.start.row:Infinity;for(;;){s>u&&(s=o.end.row+1,o=this.session.getNextFoldLine(s,o),u=o?o.start.row:Infinity);if(s>n)break;var a=i.createElement("div"),f=[];this.$renderLine(f,s,!1,s==u?o:!1),a.innerHTML=f.join("");if(this.$useLineGroups())a.className="ace_line_group",r.appendChild(a),a.style.height=e.lineHeight*this.session.getRowLength(s)+"px";else while(a.firstChild)r.appendChild(a.firstChild);s++}return r},this.update=function(e){this.config=e;var t=[],n=e.firstRow,r=e.lastRow,i=n,s=this.session.getNextFoldLine(i),o=s?s.start.row:Infinity;for(;;){i>o&&(i=s.end.row+1,s=this.session.getNextFoldLine(i,s),o=s?s.start.row:Infinity);if(i>r)break;this.$useLineGroups()&&t.push("<div class='ace_line_group' style='height:",e.lineHeight*this.session.getRowLength(i),"px'>"),this.$renderLine(t,i,!1,i==o?s:!1),this.$useLineGroups()&&t.push("</div>"),i++}this.element.innerHTML=t.join("")},this.$textToken={text:!0,rparen:!0,lparen:!0},this.$renderToken=function(e,t,n,r){var i=this,o=/\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g,u=function(e,n,r,o,u){if(n)return i.showInvisibles?"<span class='ace_invisible ace_invisible_space'>"+s.stringRepeat(i.SPACE_CHAR,e.length)+"</span>":e;if(e=="&")return"&";if(e=="<")return"<";if(e==">")return">";if(e==" "){var a=i.session.getScreenTabSize(t+o);return t+=a-1,i.$tabStrings[a]}if(e=="\u3000"){var f=i.showInvisibles?"ace_cjk ace_invisible ace_invisible_space":"ace_cjk",l=i.showInvisibles?i.SPACE_CHAR:"";return t+=1,"<span class='"+f+"' style='width:"+i.config.characterWidth*2+"px'>"+l+"</span>"}return r?"<span class='ace_invisible ace_invisible_space ace_invalid'>"+i.SPACE_CHAR+"</span>":(t+=1,"<span class='ace_cjk' style='width:"+i.config.characterWidth*2+"px'>"+e+"</span>")},a=r.replace(o,u);if(!this.$textToken[n.type]){var f="ace_"+n.type.replace(/\./g," ace_"),l="";n.type=="fold"&&(l=" style='width:"+n.value.length*this.config.characterWidth+"px;' "),e.push("<span class='",f,"'",l,">",a,"</span>")}else e.push(a);return t+r.length},this.renderIndentGuide=function(e,t,n){var r=t.search(this.$indentGuideRe);return r<=0||r>=n?t:t[0]==" "?(r-=r%this.tabSize,e.push(s.stringRepeat(this.$tabStrings[" "],r/this.tabSize)),t.substr(r)):t[0]==" "?(e.push(s.stringRepeat(this.$tabStrings[" "],r)),t.substr(r)):t},this.$renderWrappedLine=function(e,t,n,r){var i=0,o=0,u=n[0],a=0;for(var f=0;f<t.length;f++){var l=t[f],c=l.value;if(f==0&&this.displayIndentGuides){i=c.length,c=this.renderIndentGuide(e,c,u);if(!c)continue;i-=c.length}if(i+c.length<u)a=this.$renderToken(e,a,l,c),i+=c.length;else{while(i+c.length>=u)a=this.$renderToken(e,a,l,c.substring(0,u-i)),c=c.substring(u-i),i=u,r||e.push("</div>","<div class='ace_line' style='height:",this.config.lineHeight,"px'>"),e.push(s.stringRepeat("\u00a0",n.indent)),o++,a=0,u=n[o]||Number.MAX_VALUE;c.length!=0&&(i+=c.length,a=this.$renderToken(e,a,l,c))}}},this.$renderSimpleLine=function(e,t){var n=0,r=t[0],i=r.value;this.displayIndentGuides&&(i=this.renderIndentGuide(e,i)),i&&(n=this.$renderToken(e,n,r,i));for(var s=1;s<t.length;s++)r=t[s],i=r.value,n=this.$renderToken(e,n,r,i)},this.$renderLine=function(e,t,n,r){!r&&r!=0&&(r=this.session.getFoldLine(t));if(r)var i=this.$getFoldLineTokens(t,r);else var i=this.session.getTokens(t);n||e.push("<div class='ace_line' style='height:",this.config.lineHeight*(this.$useLineGroups()?1:this.session.getRowLength(t)),"px'>");if(i.length){var s=this.session.getRowSplitData(t);s&&s.length?this.$renderWrappedLine(e,i,s,n):this.$renderSimpleLine(e,i)}this.showInvisibles&&(r&&(t=r.end.row),e.push("<span class='ace_invisible ace_invisible_eol'>",t==this.session.getLength()-1?this.EOF_CHAR:this.EOL_CHAR,"</span>")),n||e.push("</div>")},this.$getFoldLineTokens=function(e,t){function i(e,t,n){var i=0,s=0;while(s+e[i].value.length<t){s+=e[i].value.length,i++;if(i==e.length)return}if(s!=t){var o=e[i].value.substring(t-s);o.length>n-t&&(o=o.substring(0,n-t)),r.push({type:e[i].type,value:o}),s=t+o.length,i+=1}while(s<n&&i<e.length){var o=e[i].value;o.length+s>n?r.push({type:e[i].type,value:o.substring(0,n-s)}):r.push(e[i]),s+=o.length,i+=1}}var n=this.session,r=[],s=n.getTokens(e);return t.walk(function(e,t,o,u,a){e!=null?r.push({type:"fold",value:e}):(a&&(s=n.getTokens(t)),s.length&&i(s,u,o))},t.end.row,this.session.getLine(t.end.row).length),r},this.$useLineGroups=function(){return this.session.getUseWrapMode()},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$measureNode&&this.$measureNode.parentNode.removeChild(this.$measureNode),delete this.$measureNode}}).call(a.prototype),t.Text=a}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../lib/dom"),i,s=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_cursor-layer",e.appendChild(this.element),i===undefined&&(i=!("opacity"in this.element.style)),this.isVisible=!1,this.isBlinking=!0,this.blinkInterval=1e3,this.smoothBlinking=!1,this.cursors=[],this.cursor=this.addCursor(),r.addCssClass(this.element,"ace_hidden-cursors"),this.$updateCursors=(i?this.$updateVisibility:this.$updateOpacity).bind(this)};(function(){this.$updateVisibility=function(e){var t=this.cursors;for(var n=t.length;n--;)t[n].style.visibility=e?"":"hidden"},this.$updateOpacity=function(e){var t=this.cursors;for(var n=t.length;n--;)t[n].style.opacity=e?"":"0"},this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setBlinking=function(e){e!=this.isBlinking&&(this.isBlinking=e,this.restartTimer())},this.setBlinkInterval=function(e){e!=this.blinkInterval&&(this.blinkInterval=e,this.restartTimer())},this.setSmoothBlinking=function(e){e!=this.smoothBlinking&&!i&&(this.smoothBlinking=e,r.setCssClass(this.element,"ace_smooth-blinking",e),this.$updateCursors(!0),this.$updateCursors=this.$updateOpacity.bind(this),this.restartTimer())},this.addCursor=function(){var e=r.createElement("div");return e.className="ace_cursor",this.element.appendChild(e),this.cursors.push(e),e},this.removeCursor=function(){if(this.cursors.length>1){var e=this.cursors.pop();return e.parentNode.removeChild(e),e}},this.hideCursor=function(){this.isVisible=!1,r.addCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.showCursor=function(){this.isVisible=!0,r.removeCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.restartTimer=function(){var e=this.$updateCursors;clearInterval(this.intervalId),clearTimeout(this.timeoutId),this.smoothBlinking&&r.removeCssClass(this.element,"ace_smooth-blinking"),e(!0);if(!this.isBlinking||!this.blinkInterval||!this.isVisible)return;this.smoothBlinking&&setTimeout(function(){r.addCssClass(this.element,"ace_smooth-blinking")}.bind(this));var t=function(){this.timeoutId=setTimeout(function(){e(!1)},.6*this.blinkInterval)}.bind(this);this.intervalId=setInterval(function(){e(!0),t()},this.blinkInterval),t()},this.getPixelPosition=function(e,t){if(!this.config||!this.session)return{left:0,top:0};e||(e=this.session.selection.getCursor());var n=this.session.documentToScreenPosition(e),r=this.$padding+n.column*this.config.characterWidth,i=(n.row-(t?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:r,top:i}},this.update=function(e){this.config=e;var t=this.session.$selectionMarkers,n=0,r=0;if(t===undefined||t.length===0)t=[{cursor:null}];for(var n=0,i=t.length;n<i;n++){var s=this.getPixelPosition(t[n].cursor,!0);if((s.top>e.height+e.offset||s.top<0)&&n>1)continue;var o=(this.cursors[r++]||this.addCursor()).style;this.drawCursor?this.drawCursor(o,s,e,t[n],this.session):(o.left=s.left+"px",o.top=s.top+"px",o.width=e.characterWidth+"px",o.height=e.lineHeight+"px")}while(this.cursors.length>r)this.removeCursor();var u=this.session.getOverwrite();this.$setOverwrite(u),this.$pixelPos=s,this.restartTimer()},this.drawCursor=null,this.$setOverwrite=function(e){e!=this.overwrite&&(this.overwrite=e,e?r.addCssClass(this.element,"ace_overwrite-cursors"):r.removeCssClass(this.element,"ace_overwrite-cursors"))},this.destroy=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId)}}).call(s.prototype),t.Cursor=s}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./lib/event"),o=e("./lib/event_emitter").EventEmitter,u=32768,a=function(e){this.element=i.createElement("div"),this.element.className="ace_scrollbar ace_scrollbar"+this.classSuffix,this.inner=i.createElement("div"),this.inner.className="ace_scrollbar-inner",this.element.appendChild(this.inner),e.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,s.addListener(this.element,"scroll",this.onScroll.bind(this)),s.addListener(this.element,"mousedown",s.preventDefault)};(function(){r.implement(this,o),this.setVisible=function(e){this.element.style.display=e?"":"none",this.isVisible=e,this.coeff=1}}).call(a.prototype);var f=function(e,t){a.call(this,e),this.scrollTop=0,this.scrollHeight=0,t.$scrollbarWidth=this.width=i.scrollbarWidth(e.ownerDocument),this.inner.style.width=this.element.style.width=(this.width||15)+5+"px"};r.inherits(f,a),function(){this.classSuffix="-v",this.onScroll=function(){if(!this.skipEvent){this.scrollTop=this.element.scrollTop;if(this.coeff!=1){var e=this.element.clientHeight/this.scrollHeight;this.scrollTop=this.scrollTop*(1-e)/(this.coeff-e)}this._emit("scroll",{data:this.scrollTop})}this.skipEvent=!1},this.getWidth=function(){return this.isVisible?this.width:0},this.setHeight=function(e){this.element.style.height=e+"px"},this.setInnerHeight=this.setScrollHeight=function(e){this.scrollHeight=e,e>u?(this.coeff=u/e,e=u):this.coeff!=1&&(this.coeff=1),this.inner.style.height=e+"px"},this.setScrollTop=function(e){this.scrollTop!=e&&(this.skipEvent=!0,this.scrollTop=e,this.element.scrollTop=e*this.coeff)}}.call(f.prototype);var l=function(e,t){a.call(this,e),this.scrollLeft=0,this.height=t.$scrollbarWidth,this.inner.style.height=this.element.style.height=(this.height||15)+5+"px"};r.inherits(l,a),function(){this.classSuffix="-h",this.onScroll=function(){this.skipEvent||(this.scrollLeft=this.element.scrollLeft,this._emit("scroll",{data:this.scrollLeft})),this.skipEvent=!1},this.getHeight=function(){return this.isVisible?this.height:0},this.setWidth=function(e){this.element.style.width=e+"px"},this.setInnerWidth=function(e){this.inner.style.width=e+"px"},this.setScrollWidth=function(e){this.inner.style.width=e+"px"},this.setScrollLeft=function(e){this.scrollLeft!=e&&(this.skipEvent=!0,this.scrollLeft=this.element.scrollLeft=e)}}.call(l.prototype),t.ScrollBar=f,t.ScrollBarV=f,t.ScrollBarH=l,t.VScrollBar=f,t.HScrollBar=l}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(e,t,n){"use strict";var r=e("./lib/event"),i=function(e,t){this.onRender=e,this.pending=!1,this.changes=0,this.window=t||window};(function(){this.schedule=function(e){this.changes=this.changes|e;if(!this.pending&&this.changes){this.pending=!0;var t=this;r.nextFrame(function(){t.pending=!1;var e;while(e=t.changes)t.changes=0,t.onRender(e)},this.window)}}}).call(i.prototype),t.RenderLoop=i}),ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(e,t,n){var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("../lib/useragent"),u=e("../lib/event_emitter").EventEmitter,a=0,f=t.FontMetrics=function(e){this.el=i.createElement("div"),this.$setMeasureNodeStyles(this.el.style,!0),this.$main=i.createElement("div"),this.$setMeasureNodeStyles(this.$main.style),this.$measureNode=i.createElement("div"),this.$setMeasureNodeStyles(this.$measureNode.style),this.el.appendChild(this.$main),this.el.appendChild(this.$measureNode),e.appendChild(this.el),a||this.$testFractionalRect(),this.$measureNode.innerHTML=s.stringRepeat("X",a),this.$characterSize={width:0,height:0},this.checkForSizeChanges()};(function(){r.implement(this,u),this.$characterSize={width:0,height:0},this.$testFractionalRect=function(){var e=i.createElement("div");this.$setMeasureNodeStyles(e.style),e.style.width="0.2px",document.documentElement.appendChild(e);var t=e.getBoundingClientRect().width;t>0&&t<1?a=50:a=100,e.parentNode.removeChild(e)},this.$setMeasureNodeStyles=function(e,t){e.width=e.height="auto",e.left=e.top="0px",e.visibility="hidden",e.position="absolute",e.whiteSpace="pre",o.isIE<8?e["font-family"]="inherit":e.font="inherit",e.overflow=t?"hidden":"visible"},this.checkForSizeChanges=function(){var e=this.$measureSizes();if(e&&(this.$characterSize.width!==e.width||this.$characterSize.height!==e.height)){this.$measureNode.style.fontWeight="bold";var t=this.$measureSizes();this.$measureNode.style.fontWeight="",this.$characterSize=e,this.charSizes=Object.create(null),this.allowBoldFonts=t&&t.width===e.width&&t.height===e.height,this._emit("changeCharacterSize",{data:e})}},this.$pollSizeChanges=function(){if(this.$pollSizeChangesTimer)return this.$pollSizeChangesTimer;var e=this;return this.$pollSizeChangesTimer=setInterval(function(){e.checkForSizeChanges()},500)},this.setPolling=function(e){e?this.$pollSizeChanges():this.$pollSizeChangesTimer&&(clearInterval(this.$pollSizeChangesTimer),this.$pollSizeChangesTimer=0)},this.$measureSizes=function(){if(a===50){var e=null;try{e=this.$measureNode.getBoundingClientRect()}catch(t){e={width:0,height:0}}var n={height:e.height,width:e.width/a}}else var n={height:this.$measureNode.clientHeight,width:this.$measureNode.clientWidth/a};return n.width===0||n.height===0?null:n},this.$measureCharWidth=function(e){this.$main.innerHTML=s.stringRepeat(e,a);var t=this.$main.getBoundingClientRect();return t.width/a},this.getCharacterWidth=function(e){var t=this.charSizes[e];return t===undefined&&(t=this.charSizes[e]=this.$measureCharWidth(e)/this.$characterSize.width),t},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)}}).call(f.prototype)}),ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./config"),o=e("./lib/useragent"),u=e("./layer/gutter").Gutter,a=e("./layer/marker").Marker,f=e("./layer/text").Text,l=e("./layer/cursor").Cursor,c=e("./scrollbar").HScrollBar,h=e("./scrollbar").VScrollBar,p=e("./renderloop").RenderLoop,d=e("./layer/font_metrics").FontMetrics,v=e("./lib/event_emitter").EventEmitter,m='.ace_editor {position: relative;overflow: hidden;font: 12px/normal \'Monaco\', \'Menlo\', \'Ubuntu Mono\', \'Consolas\', \'source-code-pro\', monospace;direction: ltr;text-align: left;}.ace_scroller {position: absolute;overflow: hidden;top: 0;bottom: 0;background-color: inherit;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;cursor: text;}.ace_content {position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;min-width: 100%;}.ace_dragging .ace_scroller:before{position: absolute;top: 0;left: 0;right: 0;bottom: 0;content: \'\';background: rgba(250, 250, 250, 0.01);z-index: 1000;}.ace_dragging.ace_dark .ace_scroller:before{background: rgba(0, 0, 0, 0.01);}.ace_selecting, .ace_selecting * {cursor: text !important;}.ace_gutter {position: absolute;overflow : hidden;width: auto;top: 0;bottom: 0;left: 0;cursor: default;z-index: 4;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;}.ace_gutter-active-line {position: absolute;left: 0;right: 0;}.ace_scroller.ace_scroll-left {box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;}.ace_gutter-cell {padding-left: 19px;padding-right: 6px;background-repeat: no-repeat;}.ace_gutter-cell.ace_error {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: 2px center;}.ace_gutter-cell.ace_warning {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==");background-position: 2px center;}.ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=");background-position: 2px center;}.ace_dark .ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC");}.ace_scrollbar {position: absolute;right: 0;bottom: 0;z-index: 6;}.ace_scrollbar-inner {position: absolute;cursor: text;left: 0;top: 0;}.ace_scrollbar-v{overflow-x: hidden;overflow-y: scroll;top: 0;}.ace_scrollbar-h {overflow-x: scroll;overflow-y: hidden;left: 0;}.ace_print-margin {position: absolute;height: 100%;}.ace_text-input {position: absolute;z-index: 0;width: 0.5em;height: 1em;opacity: 0;background: transparent;-moz-appearance: none;appearance: none;border: none;resize: none;outline: none;overflow: hidden;font: inherit;padding: 0 1px;margin: 0 -1px;text-indent: -1em;-ms-user-select: text;-moz-user-select: text;-webkit-user-select: text;user-select: text;white-space: pre!important;}.ace_text-input.ace_composition {background: inherit;color: inherit;z-index: 1000;opacity: 1;text-indent: 0;}.ace_layer {z-index: 1;position: absolute;overflow: hidden;word-wrap: normal;white-space: pre;height: 100%;width: 100%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;pointer-events: none;}.ace_gutter-layer {position: relative;width: auto;text-align: right;pointer-events: auto;}.ace_text-layer {font: inherit !important;}.ace_cjk {display: inline-block;text-align: center;}.ace_cursor-layer {z-index: 4;}.ace_cursor {z-index: 4;position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;border-left: 2px solid;transform: translatez(0);}.ace_slim-cursors .ace_cursor {border-left-width: 1px;}.ace_overwrite-cursors .ace_cursor {border-left-width: 0;border-bottom: 1px solid;}.ace_hidden-cursors .ace_cursor {opacity: 0.2;}.ace_smooth-blinking .ace_cursor {-webkit-transition: opacity 0.18s;transition: opacity 0.18s;}.ace_editor.ace_multiselect .ace_cursor {border-left-width: 1px;}.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {position: absolute;z-index: 3;}.ace_marker-layer .ace_selection {position: absolute;z-index: 5;}.ace_marker-layer .ace_bracket {position: absolute;z-index: 6;}.ace_marker-layer .ace_active-line {position: absolute;z-index: 2;}.ace_marker-layer .ace_selected-word {position: absolute;z-index: 4;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;}.ace_line .ace_fold {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;display: inline-block;height: 11px;margin-top: -2px;vertical-align: middle;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=");background-repeat: no-repeat, repeat-x;background-position: center center, top left;color: transparent;border: 1px solid black;border-radius: 2px;cursor: pointer;pointer-events: auto;}.ace_dark .ace_fold {}.ace_fold:hover{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC");}.ace_tooltip {background-color: #FFF;background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));border: 1px solid gray;border-radius: 1px;box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);color: black;max-width: 100%;padding: 3px 4px;position: fixed;z-index: 999999;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: default;white-space: pre;word-wrap: break-word;line-height: normal;font-style: normal;font-weight: normal;letter-spacing: normal;pointer-events: none;}.ace_folding-enabled > .ace_gutter-cell {padding-right: 13px;}.ace_fold-widget {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0 -12px 0 1px;display: none;width: 11px;vertical-align: top;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: center;border-radius: 3px;border: 1px solid transparent;cursor: pointer;}.ace_folding-enabled .ace_fold-widget {display: inline-block; }.ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==");}.ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==");}.ace_fold-widget:hover {border: 1px solid rgba(0, 0, 0, 0.3);background-color: rgba(255, 255, 255, 0.2);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);}.ace_fold-widget:active {border: 1px solid rgba(0, 0, 0, 0.4);background-color: rgba(0, 0, 0, 0.05);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);}.ace_dark .ace_fold-widget {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");}.ace_dark .ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget:hover {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);background-color: rgba(255, 255, 255, 0.1);}.ace_dark .ace_fold-widget:active {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);}.ace_fold-widget.ace_invalid {background-color: #FFB4B4;border-color: #DE5555;}.ace_fade-fold-widgets .ace_fold-widget {-webkit-transition: opacity 0.4s ease 0.05s;transition: opacity 0.4s ease 0.05s;opacity: 0;}.ace_fade-fold-widgets:hover .ace_fold-widget {-webkit-transition: opacity 0.05s ease 0.05s;transition: opacity 0.05s ease 0.05s;opacity:1;}.ace_underline {text-decoration: underline;}.ace_bold {font-weight: bold;}.ace_nobold .ace_bold {font-weight: normal;}.ace_italic {font-style: italic;}.ace_error-marker {background-color: rgba(255, 0, 0,0.2);position: absolute;z-index: 9;}.ace_highlight-marker {background-color: rgba(255, 255, 0,0.2);position: absolute;z-index: 8;}.ace_br1 {border-top-left-radius : 3px;}.ace_br2 {border-top-right-radius : 3px;}.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}.ace_br4 {border-bottom-right-radius: 3px;}.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}.ace_br8 {border-bottom-left-radius : 3px;}.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}';i.importCssString(m,"ace_editor.css");var g=function(e,t){var n=this;this.container=e||i.createElement("div"),this.$keepTextAreaAtCursor=!o.isOldIE,i.addCssClass(this.container,"ace_editor"),this.setTheme(t),this.$gutter=i.createElement("div"),this.$gutter.className="ace_gutter",this.container.appendChild(this.$gutter),this.scroller=i.createElement("div"),this.scroller.className="ace_scroller",this.container.appendChild(this.scroller),this.content=i.createElement("div"),this.content.className="ace_content",this.scroller.appendChild(this.content),this.$gutterLayer=new u(this.$gutter),this.$gutterLayer.on("changeGutterWidth",this.onGutterResize.bind(this)),this.$markerBack=new a(this.content);var r=this.$textLayer=new f(this.content);this.canvas=r.element,this.$markerFront=new a(this.content),this.$cursorLayer=new l(this.content),this.$horizScroll=!1,this.$vScroll=!1,this.scrollBar=this.scrollBarV=new h(this.container,this),this.scrollBarH=new c(this.container,this),this.scrollBarV.addEventListener("scroll",function(e){n.$scrollAnimation||n.session.setScrollTop(e.data-n.scrollMargin.top)}),this.scrollBarH.addEventListener("scroll",function(e){n.$scrollAnimation||n.session.setScrollLeft(e.data-n.scrollMargin.left)}),this.scrollTop=0,this.scrollLeft=0,this.cursorPos={row:0,column:0},this.$fontMetrics=new d(this.container),this.$textLayer.$setFontMetrics(this.$fontMetrics),this.$textLayer.addEventListener("changeCharacterSize",function(e){n.updateCharacterSize(),n.onResize(!0,n.gutterWidth,n.$size.width,n.$size.height),n._signal("changeCharacterSize",e)}),this.$size={width:0,height:0,scrollerHeight:0,scrollerWidth:0,$dirty:!0},this.layerConfig={width:1,padding:0,firstRow:0,firstRowScreen:0,lastRow:0,lineHeight:0,characterWidth:0,minHeight:1,maxHeight:1,offset:0,height:1,gutterOffset:1},this.scrollMargin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.$loop=new p(this.$renderChanges.bind(this),this.container.ownerDocument.defaultView),this.$loop.schedule(this.CHANGE_FULL),this.updateCharacterSize(),this.setPadding(4),s.resetOptions(this),s._emit("renderer",this)};(function(){this.CHANGE_CURSOR=1,this.CHANGE_MARKER=2,this.CHANGE_GUTTER=4,this.CHANGE_SCROLL=8,this.CHANGE_LINES=16,this.CHANGE_TEXT=32,this.CHANGE_SIZE=64,this.CHANGE_MARKER_BACK=128,this.CHANGE_MARKER_FRONT=256,this.CHANGE_FULL=512,this.CHANGE_H_SCROLL=1024,r.implement(this,v),this.updateCharacterSize=function(){this.$textLayer.allowBoldFonts!=this.$allowBoldFonts&&(this.$allowBoldFonts=this.$textLayer.allowBoldFonts,this.setStyle("ace_nobold",!this.$allowBoldFonts)),this.layerConfig.characterWidth=this.characterWidth=this.$textLayer.getCharacterWidth(),this.layerConfig.lineHeight=this.lineHeight=this.$textLayer.getLineHeight(),this.$updatePrintMargin()},this.setSession=function(e){this.session&&this.session.doc.off("changeNewLineMode",this.onChangeNewLineMode),this.session=e,e&&this.scrollMargin.top&&e.getScrollTop()<=0&&e.setScrollTop(-this.scrollMargin.top),this.$cursorLayer.setSession(e),this.$markerBack.setSession(e),this.$markerFront.setSession(e),this.$gutterLayer.setSession(e),this.$textLayer.setSession(e);if(!e)return;this.$loop.schedule(this.CHANGE_FULL),this.session.$setFontMetrics(this.$fontMetrics),this.scrollBarV.scrollLeft=this.scrollBarV.scrollTop=null,this.onChangeNewLineMode=this.onChangeNewLineMode.bind(this),this.onChangeNewLineMode(),this.session.doc.on("changeNewLineMode",this.onChangeNewLineMode)},this.updateLines=function(e,t,n){t===undefined&&(t=Infinity),this.$changedLines?(this.$changedLines.firstRow>e&&(this.$changedLines.firstRow=e),this.$changedLines.lastRow<t&&(this.$changedLines.lastRow=t)):this.$changedLines={firstRow:e,lastRow:t};if(this.$changedLines.lastRow<this.layerConfig.firstRow){if(!n)return;this.$changedLines.lastRow=this.layerConfig.lastRow}if(this.$changedLines.firstRow>this.layerConfig.lastRow)return;this.$loop.schedule(this.CHANGE_LINES)},this.onChangeNewLineMode=function(){this.$loop.schedule(this.CHANGE_TEXT),this.$textLayer.$updateEolChar()},this.onChangeTabSize=function(){this.$loop.schedule(this.CHANGE_TEXT|this.CHANGE_MARKER),this.$textLayer.onChangeTabSize()},this.updateText=function(){this.$loop.schedule(this.CHANGE_TEXT)},this.updateFull=function(e){e?this.$renderChanges(this.CHANGE_FULL,!0):this.$loop.schedule(this.CHANGE_FULL)},this.updateFontSize=function(){this.$textLayer.checkForSizeChanges()},this.$changes=0,this.$updateSizeAsync=function(){this.$loop.pending?this.$size.$dirty=!0:this.onResize()},this.onResize=function(e,t,n,r){if(this.resizing>2)return;this.resizing>0?this.resizing++:this.resizing=e?1:0;var i=this.container;r||(r=i.clientHeight||i.scrollHeight),n||(n=i.clientWidth||i.scrollWidth);var s=this.$updateCachedSize(e,t,n,r);if(!this.$size.scrollerHeight||!n&&!r)return this.resizing=0;e&&(this.$gutterLayer.$padding=null),e?this.$renderChanges(s|this.$changes,!0):this.$loop.schedule(s|this.$changes),this.resizing&&(this.resizing=0),this.scrollBarV.scrollLeft=this.scrollBarV.scrollTop=null},this.$updateCachedSize=function(e,t,n,r){r-=this.$extraHeight||0;var i=0,s=this.$size,o={width:s.width,height:s.height,scrollerHeight:s.scrollerHeight,scrollerWidth:s.scrollerWidth};r&&(e||s.height!=r)&&(s.height=r,i|=this.CHANGE_SIZE,s.scrollerHeight=s.height,this.$horizScroll&&(s.scrollerHeight-=this.scrollBarH.getHeight()),this.scrollBarV.element.style.bottom=this.scrollBarH.getHeight()+"px",i|=this.CHANGE_SCROLL);if(n&&(e||s.width!=n)){i|=this.CHANGE_SIZE,s.width=n,t==null&&(t=this.$showGutter?this.$gutter.offsetWidth:0),this.gutterWidth=t,this.scrollBarH.element.style.left=this.scroller.style.left=t+"px",s.scrollerWidth=Math.max(0,n-t-this.scrollBarV.getWidth()),this.scrollBarH.element.style.right=this.scroller.style.right=this.scrollBarV.getWidth()+"px",this.scroller.style.bottom=this.scrollBarH.getHeight()+"px";if(this.session&&this.session.getUseWrapMode()&&this.adjustWrapLimit()||e)i|=this.CHANGE_FULL}return s.$dirty=!n||!r,i&&this._signal("resize",o),i},this.onGutterResize=function(){var e=this.$showGutter?this.$gutter.offsetWidth:0;e!=this.gutterWidth&&(this.$changes|=this.$updateCachedSize(!0,e,this.$size.width,this.$size.height)),this.session.getUseWrapMode()&&this.adjustWrapLimit()?this.$loop.schedule(this.CHANGE_FULL):this.$size.$dirty?this.$loop.schedule(this.CHANGE_FULL):(this.$computeLayerConfig(),this.$loop.schedule(this.CHANGE_MARKER))},this.adjustWrapLimit=function(){var e=this.$size.scrollerWidth-this.$padding*2,t=Math.floor(e/this.characterWidth);return this.session.adjustWrapLimit(t,this.$showPrintMargin&&this.$printMarginColumn)},this.setAnimatedScroll=function(e){this.setOption("animatedScroll",e)},this.getAnimatedScroll=function(){return this.$animatedScroll},this.setShowInvisibles=function(e){this.setOption("showInvisibles",e)},this.getShowInvisibles=function(){return this.getOption("showInvisibles")},this.getDisplayIndentGuides=function(){return this.getOption("displayIndentGuides")},this.setDisplayIndentGuides=function(e){this.setOption("displayIndentGuides",e)},this.setShowPrintMargin=function(e){this.setOption("showPrintMargin",e)},this.getShowPrintMargin=function(){return this.getOption("showPrintMargin")},this.setPrintMarginColumn=function(e){this.setOption("printMarginColumn",e)},this.getPrintMarginColumn=function(){return this.getOption("printMarginColumn")},this.getShowGutter=function(){return this.getOption("showGutter")},this.setShowGutter=function(e){return this.setOption("showGutter",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.$updateGutterLineHighlight=function(){var e=this.$cursorLayer.$pixelPos,t=this.layerConfig.lineHeight;if(this.session.getUseWrapMode()){var n=this.session.selection.getCursor();n.column=0,e=this.$cursorLayer.getPixelPosition(n,!0),t*=this.session.getRowLength(n.row)}this.$gutterLineHighlight.style.top=e.top-this.layerConfig.offset+"px",this.$gutterLineHighlight.style.height=t+"px"},this.$updatePrintMargin=function(){if(!this.$showPrintMargin&&!this.$printMarginEl)return;if(!this.$printMarginEl){var e=i.createElement("div");e.className="ace_layer ace_print-margin-layer",this.$printMarginEl=i.createElement("div"),this.$printMarginEl.className="ace_print-margin",e.appendChild(this.$printMarginEl),this.content.insertBefore(e,this.content.firstChild)}var t=this.$printMarginEl.style;t.left=this.characterWidth*this.$printMarginColumn+this.$padding+"px",t.visibility=this.$showPrintMargin?"visible":"hidden",this.session&&this.session.$wrap==-1&&this.adjustWrapLimit()},this.getContainerElement=function(){return this.container},this.getMouseEventTarget=function(){return this.scroller},this.getTextAreaContainer=function(){return this.container},this.$moveTextAreaToCursor=function(){if(!this.$keepTextAreaAtCursor)return;var e=this.layerConfig,t=this.$cursorLayer.$pixelPos.top,n=this.$cursorLayer.$pixelPos.left;t-=e.offset;var r=this.textarea.style,i=this.lineHeight;if(t<0||t>e.height-i){r.top=r.left="0";return}var s=this.characterWidth;if(this.$composition){var o=this.textarea.value.replace(/^\x01+/,"");s*=this.session.$getStringScreenWidth(o)[0]+2,i+=2}n-=this.scrollLeft,n>this.$size.scrollerWidth-s&&(n=this.$size.scrollerWidth-s),n+=this.gutterWidth,r.height=i+"px",r.width=s+"px",r.left=Math.min(n,this.$size.scrollerWidth-s)+"px",r.top=Math.min(t,this.$size.height-i)+"px"},this.getFirstVisibleRow=function(){return this.layerConfig.firstRow},this.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(this.layerConfig.offset===0?0:1)},this.getLastFullyVisibleRow=function(){var e=this.layerConfig,t=e.lastRow,n=this.session.documentToScreenRow(t,0)*e.lineHeight;return n-this.session.getScrollTop()>e.height-e.lineHeight?t-1:t},this.getLastVisibleRow=function(){return this.layerConfig.lastRow},this.$padding=null,this.setPadding=function(e){this.$padding=e,this.$textLayer.setPadding(e),this.$cursorLayer.setPadding(e),this.$markerFront.setPadding(e),this.$markerBack.setPadding(e),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},this.setScrollMargin=function(e,t,n,r){var i=this.scrollMargin;i.top=e|0,i.bottom=t|0,i.right=r|0,i.left=n|0,i.v=i.top+i.bottom,i.h=i.left+i.right,i.top&&this.scrollTop<=0&&this.session&&this.session.setScrollTop(-i.top),this.updateFull()},this.getHScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},this.setHScrollBarAlwaysVisible=function(e){this.setOption("hScrollBarAlwaysVisible",e)},this.getVScrollBarAlwaysVisible=function(){return this.$vScrollBarAlwaysVisible},this.setVScrollBarAlwaysVisible=function(e){this.setOption("vScrollBarAlwaysVisible",e)},this.$updateScrollBarV=function(){var e=this.layerConfig.maxHeight,t=this.$size.scrollerHeight;!this.$maxLines&&this.$scrollPastEnd&&(e-=(t-this.lineHeight)*this.$scrollPastEnd,this.scrollTop>e-t&&(e=this.scrollTop+t,this.scrollBarV.scrollTop=null)),this.scrollBarV.setScrollHeight(e+this.scrollMargin.v),this.scrollBarV.setScrollTop(this.scrollTop+this.scrollMargin.top)},this.$updateScrollBarH=function(){this.scrollBarH.setScrollWidth(this.layerConfig.width+2*this.$padding+this.scrollMargin.h),this.scrollBarH.setScrollLeft(this.scrollLeft+this.scrollMargin.left)},this.$frozen=!1,this.freeze=function(){this.$frozen=!0},this.unfreeze=function(){this.$frozen=!1},this.$renderChanges=function(e,t){this.$changes&&(e|=this.$changes,this.$changes=0);if(!this.session||!this.container.offsetWidth||this.$frozen||!e&&!t){this.$changes|=e;return}if(this.$size.$dirty)return this.$changes|=e,this.onResize(!0);this.lineHeight||this.$textLayer.checkForSizeChanges(),this._signal("beforeRender");var n=this.layerConfig;if(e&this.CHANGE_FULL||e&this.CHANGE_SIZE||e&this.CHANGE_TEXT||e&this.CHANGE_LINES||e&this.CHANGE_SCROLL||e&this.CHANGE_H_SCROLL){e|=this.$computeLayerConfig();if(n.firstRow!=this.layerConfig.firstRow&&n.firstRowScreen==this.layerConfig.firstRowScreen){var r=this.scrollTop+(n.firstRow-this.layerConfig.firstRow)*this.lineHeight;r>0&&(this.scrollTop=r,e|=this.CHANGE_SCROLL,e|=this.$computeLayerConfig())}n=this.layerConfig,this.$updateScrollBarV(),e&this.CHANGE_H_SCROLL&&this.$updateScrollBarH(),this.$gutterLayer.element.style.marginTop=-n.offset+"px",this.content.style.marginTop=-n.offset+"px",this.content.style.width=n.width+2*this.$padding+"px",this.content.style.height=n.minHeight+"px"}e&this.CHANGE_H_SCROLL&&(this.content.style.marginLeft=-this.scrollLeft+"px",this.scroller.className=this.scrollLeft<=0?"ace_scroller":"ace_scroller ace_scroll-left");if(e&this.CHANGE_FULL){this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this._signal("afterRender");return}if(e&this.CHANGE_SCROLL){e&this.CHANGE_TEXT||e&this.CHANGE_LINES?this.$textLayer.update(n):this.$textLayer.scrollLines(n),this.$showGutter&&this.$gutterLayer.update(n),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this.$moveTextAreaToCursor(),this._signal("afterRender");return}e&this.CHANGE_TEXT?(this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n)):e&this.CHANGE_LINES?(this.$updateLines()||e&this.CHANGE_GUTTER&&this.$showGutter)&&this.$gutterLayer.update(n):(e&this.CHANGE_TEXT||e&this.CHANGE_GUTTER)&&this.$showGutter&&this.$gutterLayer.update(n),e&this.CHANGE_CURSOR&&(this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight()),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(n),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(n),this._signal("afterRender")},this.$autosize=function(){var e=this.session.getScreenLength()*this.lineHeight,t=this.$maxLines*this.lineHeight,n=Math.min(t,Math.max((this.$minLines||1)*this.lineHeight,e))+this.scrollMargin.v+(this.$extraHeight||0);this.$horizScroll&&(n+=this.scrollBarH.getHeight()),this.$maxPixelHeight&&n>this.$maxPixelHeight&&(n=this.$maxPixelHeight);var r=e>t;if(n!=this.desiredHeight||this.$size.height!=this.desiredHeight||r!=this.$vScroll){r!=this.$vScroll&&(this.$vScroll=r,this.scrollBarV.setVisible(r));var i=this.container.clientWidth;this.container.style.height=n+"px",this.$updateCachedSize(!0,this.$gutterWidth,i,n),this.desiredHeight=n,this._signal("autosize")}},this.$computeLayerConfig=function(){var e=this.session,t=this.$size,n=t.height<=2*this.lineHeight,r=this.session.getScreenLength(),i=r*this.lineHeight,s=this.$getLongestLine(),o=!n&&(this.$hScrollBarAlwaysVisible||t.scrollerWidth-s-2*this.$padding<0),u=this.$horizScroll!==o;u&&(this.$horizScroll=o,this.scrollBarH.setVisible(o));var a=this.$vScroll;this.$maxLines&&this.lineHeight>1&&this.$autosize();var f=this.scrollTop%this.lineHeight,l=t.scrollerHeight+this.lineHeight,c=!this.$maxLines&&this.$scrollPastEnd?(t.scrollerHeight-this.lineHeight)*this.$scrollPastEnd:0;i+=c;var h=this.scrollMargin;this.session.setScrollTop(Math.max(-h.top,Math.min(this.scrollTop,i-t.scrollerHeight+h.bottom))),this.session.setScrollLeft(Math.max(-h.left,Math.min(this.scrollLeft,s+2*this.$padding-t.scrollerWidth+h.right)));var p=!n&&(this.$vScrollBarAlwaysVisible||t.scrollerHeight-i+c<0||this.scrollTop>h.top),d=a!==p;d&&(this.$vScroll=p,this.scrollBarV.setVisible(p));var v=Math.ceil(l/this.lineHeight)-1,m=Math.max(0,Math.round((this.scrollTop-f)/this.lineHeight)),g=m+v,y,b,w=this.lineHeight;m=e.screenToDocumentRow(m,0);var E=e.getFoldLine(m);E&&(m=E.start.row),y=e.documentToScreenRow(m,0),b=e.getRowLength(m)*w,g=Math.min(e.screenToDocumentRow(g,0),e.getLength()-1),l=t.scrollerHeight+e.getRowLength(g)*w+b,f=this.scrollTop-y*w;var S=0;this.layerConfig.width!=s&&(S=this.CHANGE_H_SCROLL);if(u||d)S=this.$updateCachedSize(!0,this.gutterWidth,t.width,t.height),this._signal("scrollbarVisibilityChanged"),d&&(s=this.$getLongestLine());return this.layerConfig={width:s,padding:this.$padding,firstRow:m,firstRowScreen:y,lastRow:g,lineHeight:w,characterWidth:this.characterWidth,minHeight:l,maxHeight:i,offset:f,gutterOffset:w?Math.max(0,Math.ceil((f+t.height-t.scrollerHeight)/w)):0,height:this.$size.scrollerHeight},S},this.$updateLines=function(){var e=this.$changedLines.firstRow,t=this.$changedLines.lastRow;this.$changedLines=null;var n=this.layerConfig;if(e>n.lastRow+1)return;if(t<n.firstRow)return;if(t===Infinity){this.$showGutter&&this.$gutterLayer.update(n),this.$textLayer.update(n);return}return this.$textLayer.updateLines(n,e,t),!0},this.$getLongestLine=function(){var e=this.session.getScreenWidth();return this.showInvisibles&&!this.session.$useWrapMode&&(e+=1),Math.max(this.$size.scrollerWidth-2*this.$padding,Math.round(e*this.characterWidth))},this.updateFrontMarkers=function(){this.$markerFront.setMarkers(this.session.getMarkers(!0)),this.$loop.schedule(this.CHANGE_MARKER_FRONT)},this.updateBackMarkers=function(){this.$markerBack.setMarkers(this.session.getMarkers()),this.$loop.schedule(this.CHANGE_MARKER_BACK)},this.addGutterDecoration=function(e,t){this.$gutterLayer.addGutterDecoration(e,t)},this.removeGutterDecoration=function(e,t){this.$gutterLayer.removeGutterDecoration(e,t)},this.updateBreakpoints=function(e){this.$loop.schedule(this.CHANGE_GUTTER)},this.setAnnotations=function(e){this.$gutterLayer.setAnnotations(e),this.$loop.schedule(this.CHANGE_GUTTER)},this.updateCursor=function(){this.$loop.schedule(this.CHANGE_CURSOR)},this.hideCursor=function(){this.$cursorLayer.hideCursor()},this.showCursor=function(){this.$cursorLayer.showCursor()},this.scrollSelectionIntoView=function(e,t,n){this.scrollCursorIntoView(e,n),this.scrollCursorIntoView(t,n)},this.scrollCursorIntoView=function(e,t,n){if(this.$size.scrollerHeight===0)return;var r=this.$cursorLayer.getPixelPosition(e),i=r.left,s=r.top,o=n&&n.top||0,u=n&&n.bottom||0,a=this.$scrollAnimation?this.session.getScrollTop():this.scrollTop;a+o>s?(t&&a+o>s+this.lineHeight&&(s-=t*this.$size.scrollerHeight),s===0&&(s=-this.scrollMargin.top),this.session.setScrollTop(s)):a+this.$size.scrollerHeight-u<s+this.lineHeight&&(t&&a+this.$size.scrollerHeight-u<s-this.lineHeight&&(s+=t*this.$size.scrollerHeight),this.session.setScrollTop(s+this.lineHeight-this.$size.scrollerHeight));var f=this.scrollLeft;f>i?(i<this.$padding+2*this.layerConfig.characterWidth&&(i=-this.scrollMargin.left),this.session.setScrollLeft(i)):f+this.$size.scrollerWidth<i+this.characterWidth?this.session.setScrollLeft(Math.round(i+this.characterWidth-this.$size.scrollerWidth)):f<=this.$padding&&i-f<this.characterWidth&&this.session.setScrollLeft(0)},this.getScrollTop=function(){return this.session.getScrollTop()},this.getScrollLeft=function(){return this.session.getScrollLeft()},this.getScrollTopRow=function(){return this.scrollTop/this.lineHeight},this.getScrollBottomRow=function(){return Math.max(0,Math.floor((this.scrollTop+this.$size.scrollerHeight)/this.lineHeight)-1)},this.scrollToRow=function(e){this.session.setScrollTop(e*this.lineHeight)},this.alignCursor=function(e,t){typeof e=="number"&&(e={row:e,column:0});var n=this.$cursorLayer.getPixelPosition(e),r=this.$size.scrollerHeight-this.lineHeight,i=n.top-r*(t||0);return this.session.setScrollTop(i),i},this.STEPS=8,this.$calcSteps=function(e,t){var n=0,r=this.STEPS,i=[],s=function(e,t,n){return n*(Math.pow(e-1,3)+1)+t};for(n=0;n<r;++n)i.push(s(n/this.STEPS,e,t-e));return i},this.scrollToLine=function(e,t,n,r){var i=this.$cursorLayer.getPixelPosition({row:e,column:0}),s=i.top;t&&(s-=this.$size.scrollerHeight/2);var o=this.scrollTop;this.session.setScrollTop(s),n!==!1&&this.animateScrolling(o,r)},this.animateScrolling=function(e,t){var n=this.scrollTop;if(!this.$animatedScroll)return;var r=this;if(e==n)return;if(this.$scrollAnimation){var i=this.$scrollAnimation.steps;if(i.length){e=i[0];if(e==n)return}}var s=r.$calcSteps(e,n);this.$scrollAnimation={from:e,to:n,steps:s},clearInterval(this.$timer),r.session.setScrollTop(s.shift()),r.session.$scrollTop=n,this.$timer=setInterval(function(){s.length?(r.session.setScrollTop(s.shift()),r.session.$scrollTop=n):n!=null?(r.session.$scrollTop=-1,r.session.setScrollTop(n),n=null):(r.$timer=clearInterval(r.$timer),r.$scrollAnimation=null,t&&t())},10)},this.scrollToY=function(e){this.scrollTop!==e&&(this.$loop.schedule(this.CHANGE_SCROLL),this.scrollTop=e)},this.scrollToX=function(e){this.scrollLeft!==e&&(this.scrollLeft=e),this.$loop.schedule(this.CHANGE_H_SCROLL)},this.scrollTo=function(e,t){this.session.setScrollTop(t),this.session.setScrollLeft(t)},this.scrollBy=function(e,t){t&&this.session.setScrollTop(this.session.getScrollTop()+t),e&&this.session.setScrollLeft(this.session.getScrollLeft()+e)},this.isScrollableBy=function(e,t){if(t<0&&this.session.getScrollTop()>=1-this.scrollMargin.top)return!0;if(t>0&&this.session.getScrollTop()+this.$size.scrollerHeight-this.layerConfig.maxHeight<-1+this.scrollMargin.bottom)return!0;if(e<0&&this.session.getScrollLeft()>=1-this.scrollMargin.left)return!0;if(e>0&&this.session.getScrollLeft()+this.$size.scrollerWidth-this.layerConfig.width<-1+this.scrollMargin.right)return!0},this.pixelToScreenCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=(e+this.scrollLeft-n.left-this.$padding)/this.characterWidth,i=Math.floor((t+this.scrollTop-n.top)/this.lineHeight),s=Math.round(r);return{row:i,column:s,side:r-s>0?1:-1}},this.screenToTextCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=Math.round((e+this.scrollLeft-n.left-this.$padding)/this.characterWidth),i=(t+this.scrollTop-n.top)/this.lineHeight;return this.session.screenToDocumentPosition(i,Math.max(r,0))},this.textToScreenCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=this.session.documentToScreenPosition(e,t),i=this.$padding+Math.round(r.column*this.characterWidth),s=r.row*this.lineHeight;return{pageX:n.left+i-this.scrollLeft,pageY:n.top+s-this.scrollTop}},this.visualizeFocus=function(){i.addCssClass(this.container,"ace_focus")},this.visualizeBlur=function(){i.removeCssClass(this.container,"ace_focus")},this.showComposition=function(e){this.$composition||(this.$composition={keepTextAreaAtCursor:this.$keepTextAreaAtCursor,cssText:this.textarea.style.cssText}),this.$keepTextAreaAtCursor=!0,i.addCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText="",this.$moveTextAreaToCursor()},this.setCompositionText=function(e){this.$moveTextAreaToCursor()},this.hideComposition=function(){if(!this.$composition)return;i.removeCssClass(this.textarea,"ace_composition"),this.$keepTextAreaAtCursor=this.$composition.keepTextAreaAtCursor,this.textarea.style.cssText=this.$composition.cssText,this.$composition=null},this.setTheme=function(e,t){function o(r){if(n.$themeId!=e)return t&&t();if(!r||!r.cssClass)throw new Error("couldn't load module "+e+" or it didn't call define");i.importCssString(r.cssText,r.cssClass,n.container.ownerDocument),n.theme&&i.removeCssClass(n.container,n.theme.cssClass);var s="padding"in r?r.padding:"padding"in(n.theme||{})?4:n.$padding;n.$padding&&s!=n.$padding&&n.setPadding(s),n.$theme=r.cssClass,n.theme=r,i.addCssClass(n.container,r.cssClass),i.setCssClass(n.container,"ace_dark",r.isDark),n.$size&&(n.$size.width=0,n.$updateSizeAsync()),n._dispatchEvent("themeLoaded",{theme:r}),t&&t()}var n=this;this.$themeId=e,n._dispatchEvent("themeChange",{theme:e});if(!e||typeof e=="string"){var r=e||this.$options.theme.initialValue;s.loadModule(["theme",r],o)}else o(e)},this.getTheme=function(){return this.$themeId},this.setStyle=function(e,t){i.setCssClass(this.container,e,t!==!1)},this.unsetStyle=function(e){i.removeCssClass(this.container,e)},this.setCursorStyle=function(e){this.scroller.style.cursor!=e&&(this.scroller.style.cursor=e)},this.setMouseCursor=function(e){this.scroller.style.cursor=e},this.destroy=function(){this.$textLayer.destroy(),this.$cursorLayer.destroy()}}).call(g.prototype),s.defineOptions(g.prototype,"renderer",{animatedScroll:{initialValue:!1},showInvisibles:{set:function(e){this.$textLayer.setShowInvisibles(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!1},showPrintMargin:{set:function(){this.$updatePrintMargin()},initialValue:!0},printMarginColumn:{set:function(){this.$updatePrintMargin()},initialValue:80},printMargin:{set:function(e){typeof e=="number"&&(this.$printMarginColumn=e),this.$showPrintMargin=!!e,this.$updatePrintMargin()},get:function(){return this.$showPrintMargin&&this.$printMarginColumn}},showGutter:{set:function(e){this.$gutter.style.display=e?"block":"none",this.$loop.schedule(this.CHANGE_FULL),this.onGutterResize()},initialValue:!0},fadeFoldWidgets:{set:function(e){i.setCssClass(this.$gutter,"ace_fade-fold-widgets",e)},initialValue:!1},showFoldWidgets:{set:function(e){this.$gutterLayer.setShowFoldWidgets(e)},initialValue:!0},showLineNumbers:{set:function(e){this.$gutterLayer.setShowLineNumbers(e),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},displayIndentGuides:{set:function(e){this.$textLayer.setDisplayIndentGuides(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!0},highlightGutterLine:{set:function(e){if(!this.$gutterLineHighlight){this.$gutterLineHighlight=i.createElement("div"),this.$gutterLineHighlight.className="ace_gutter-active-line",this.$gutter.appendChild(this.$gutterLineHighlight);return}this.$gutterLineHighlight.style.display=e?"":"none",this.$cursorLayer.$pixelPos&&this.$updateGutterLineHighlight()},initialValue:!1,value:!0},hScrollBarAlwaysVisible:{set:function(e){(!this.$hScrollBarAlwaysVisible||!this.$horizScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},vScrollBarAlwaysVisible:{set:function(e){(!this.$vScrollBarAlwaysVisible||!this.$vScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},fontSize:{set:function(e){typeof e=="number"&&(e+="px"),this.container.style.fontSize=e,this.updateFontSize()},initialValue:12},fontFamily:{set:function(e){this.container.style.fontFamily=e,this.updateFontSize()}},maxLines:{set:function(e){this.updateFull()}},minLines:{set:function(e){this.updateFull()}},maxPixelHeight:{set:function(e){this.updateFull()},initialValue:0},scrollPastEnd:{set:function(e){e=+e||0;if(this.$scrollPastEnd==e)return;this.$scrollPastEnd=e,this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:0,handlesSet:!0},fixedWidthGutter:{set:function(e){this.$gutterLayer.$fixedWidth=!!e,this.$loop.schedule(this.CHANGE_GUTTER)}},theme:{set:function(e){this.setTheme(e)},get:function(){return this.$themeId||this.theme},initialValue:"./theme/textmate",handlesSet:!0}}),t.VirtualRenderer=g}),ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/net"),s=e("../lib/event_emitter").EventEmitter,o=e("../config"),u=function(t,n,r,i){this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.onMessage=this.onMessage.bind(this),e.nameToUrl&&!e.toUrl&&(e.toUrl=e.nameToUrl);if(o.get("packaged")||!e.toUrl)i=i||o.moduleUrl(n,"worker");else{var s=this.$normalizePath;i=i||s(e.toUrl("ace/worker/worker.js",null,"_"));var u={};t.forEach(function(t){u[t]=s(e.toUrl(t,null,"_").replace(/(\.js)?(\?.*)?$/,""))})}try{this.$worker=new Worker(i)}catch(a){if(!(a instanceof window.DOMException))throw a;var f=this.$workerBlob(i),l=window.URL||window.webkitURL,c=l.createObjectURL(f);this.$worker=new Worker(c),l.revokeObjectURL(c)}this.$worker.postMessage({init:!0,tlns:u,module:n,classname:r}),this.callbackId=1,this.callbacks={},this.$worker.onmessage=this.onMessage};(function(){r.implement(this,s),this.onMessage=function(e){var t=e.data;switch(t.type){case"event":this._signal(t.name,{data:t.data});break;case"call":var n=this.callbacks[t.id];n&&(n(t.data),delete this.callbacks[t.id]);break;case"error":this.reportError(t.data);break;case"log":window.console&&console.log&&console.log.apply(console,t.data)}},this.reportError=function(e){window.console&&console.error&&console.error(e)},this.$normalizePath=function(e){return i.qualifyURL(e)},this.terminate=function(){this._signal("terminate",{}),this.deltaQueue=null,this.$worker.terminate(),this.$worker=null,this.$doc&&this.$doc.off("change",this.changeListener),this.$doc=null},this.send=function(e,t){this.$worker.postMessage({command:e,args:t})},this.call=function(e,t,n){if(n){var r=this.callbackId++;this.callbacks[r]=n,t.push(r)}this.send(e,t)},this.emit=function(e,t){try{this.$worker.postMessage({event:e,data:{data:t.data}})}catch(n){console.error(n.stack)}},this.attachToDocument=function(e){this.$doc&&this.terminate(),this.$doc=e,this.call("setValue",[e.getValue()]),e.on("change",this.changeListener)},this.changeListener=function(e){this.deltaQueue||(this.deltaQueue=[],setTimeout(this.$sendDeltaQueue,0)),e.action=="insert"?this.deltaQueue.push(e.start,e.lines):this.deltaQueue.push(e.start,e.end)},this.$sendDeltaQueue=function(){var e=this.deltaQueue;if(!e)return;this.deltaQueue=null,e.length>50&&e.length>this.$doc.getLength()>>1?this.call("setValue",[this.$doc.getValue()]):this.emit("change",{data:e})},this.$workerBlob=function(e){var t="importScripts('"+i.qualifyURL(e)+"');";try{return new Blob([t],{type:"application/javascript"})}catch(n){var r=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,s=new r;return s.append(t),s.getBlob("application/javascript")}}}).call(u.prototype);var a=function(e,t,n){this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.callbackId=1,this.callbacks={},this.messageBuffer=[];var r=null,i=!1,u=Object.create(s),a=this;this.$worker={},this.$worker.terminate=function(){},this.$worker.postMessage=function(e){a.messageBuffer.push(e),r&&(i?setTimeout(f):f())},this.setEmitSync=function(e){i=e};var f=function(){var e=a.messageBuffer.shift();e.command?r[e.command].apply(r,e.args):e.event&&u._signal(e.event,e.data)};u.postMessage=function(e){a.onMessage({data:e})},u.callback=function(e,t){this.postMessage({type:"call",id:t,data:e})},u.emit=function(e,t){this.postMessage({type:"event",name:e,data:t})},o.loadModule(["worker",t],function(e){r=new e[n](u);while(a.messageBuffer.length)f()})};a.prototype=u.prototype,t.UIWorkerClient=a,t.WorkerClient=u}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(e,t,n){"use strict";var r=e("./range").Range,i=e("./lib/event_emitter").EventEmitter,s=e("./lib/oop"),o=function(e,t,n,r,i,s){var o=this;this.length=t,this.session=e,this.doc=e.getDocument(),this.mainClass=i,this.othersClass=s,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate),this.$others=r,this.$onCursorChange=function(){setTimeout(function(){o.onCursorChange()})},this.$pos=n;var u=e.getUndoManager().$undoStack||e.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=u.length,this.setup(),e.selection.on("changeCursor",this.$onCursorChange)};(function(){s.implement(this,i),this.setup=function(){var e=this,t=this.doc,n=this.session;this.selectionBefore=n.selection.toJSON(),n.selection.inMultiSelectMode&&n.selection.toSingleRange(),this.pos=t.createAnchor(this.$pos.row,this.$pos.column);var i=this.pos;i.$insertRight=!0,i.detach(),i.markerId=n.addMarker(new r(i.row,i.column,i.row,i.column+this.length),this.mainClass,null,!1),this.others=[],this.$others.forEach(function(n){var r=t.createAnchor(n.row,n.column);r.$insertRight=!0,r.detach(),e.others.push(r)}),n.setUndoSelect(!1)},this.showOtherMarkers=function(){if(this.othersActive)return;var e=this.session,t=this;this.othersActive=!0,this.others.forEach(function(n){n.markerId=e.addMarker(new r(n.row,n.column,n.row,n.column+t.length),t.othersClass,null,!1)})},this.hideOtherMarkers=function(){if(!this.othersActive)return;this.othersActive=!1;for(var e=0;e<this.others.length;e++)this.session.removeMarker(this.others[e].markerId)},this.onUpdate=function(e){if(this.$updating)return this.updateAnchors(e);var t=e;if(t.start.row!==t.end.row)return;if(t.start.row!==this.pos.row)return;this.$updating=!0;var n=e.action==="insert"?t.end.column-t.start.column:t.start.column-t.end.column,i=t.start.column>=this.pos.column&&t.start.column<=this.pos.column+this.length+1,s=t.start.column-this.pos.column;this.updateAnchors(e),i&&(this.length+=n);if(i&&!this.session.$fromUndo)if(e.action==="insert")for(var o=this.others.length-1;o>=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};this.doc.insertMergedLines(a,e.lines)}else if(e.action==="remove")for(var o=this.others.length-1;o>=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};this.doc.remove(new r(a.row,a.column,a.row,a.column-n))}this.$updating=!1,this.updateMarkers()},this.updateAnchors=function(e){this.pos.onChange(e);for(var t=this.others.length;t--;)this.others[t].onChange(e);this.updateMarkers()},this.updateMarkers=function(){if(this.$updating)return;var e=this,t=this.session,n=function(n,i){t.removeMarker(n.markerId),n.markerId=t.addMarker(new r(n.row,n.column,n.row,n.column+e.length),i,null,!1)};n(this.pos,this.mainClass);for(var i=this.others.length;i--;)n(this.others[i],this.othersClass)},this.onCursorChange=function(e){if(this.$updating||!this.session)return;var t=this.session.selection.getCursor();t.row===this.pos.row&&t.column>=this.pos.column&&t.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",e)):(this.hideOtherMarkers(),this._emit("cursorLeave",e))},this.detach=function(){this.session.removeMarker(this.pos&&this.pos.markerId),this.hideOtherMarkers(),this.doc.removeEventListener("change",this.$onUpdate),this.session.selection.removeEventListener("changeCursor",this.$onCursorChange),this.session.setUndoSelect(!0),this.session=null},this.cancel=function(){if(this.$undoStackDepth===-1)return;var e=this.session.getUndoManager(),t=(e.$undoStack||e.$undostack).length-this.$undoStackDepth;for(var n=0;n<t;n++)e.undo(!0);this.selectionBefore&&this.session.selection.fromJSON(this.selectionBefore)}}).call(o.prototype),t.PlaceHolder=o}),ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(e,t,n){function s(e,t){return e.row==t.row&&e.column==t.column}function o(e){var t=e.domEvent,n=t.altKey,o=t.shiftKey,u=t.ctrlKey,a=e.getAccelKey(),f=e.getButton();u&&i.isMac&&(f=t.button);if(e.editor.inMultiSelectMode&&f==2){e.editor.textInput.onContextMenu(e.domEvent);return}if(!u&&!n&&!a){f===0&&e.editor.inMultiSelectMode&&e.editor.exitMultiSelectMode();return}if(f!==0)return;var l=e.editor,c=l.selection,h=l.inMultiSelectMode,p=e.getDocumentPosition(),d=c.getCursor(),v=e.inSelection()||c.isEmpty()&&s(p,d),m=e.x,g=e.y,y=function(e){m=e.clientX,g=e.clientY},b=l.session,w=l.renderer.pixelToScreenCoordinates(m,g),E=w,S;if(l.$mouseHandler.$enableJumpToDef)u&&n||a&&n?S=o?"block":"add":n&&l.$blockSelectEnabled&&(S="block");else if(a&&!n){S="add";if(!h&&o)return}else n&&l.$blockSelectEnabled&&(S="block");S&&i.isMac&&t.ctrlKey&&l.$mouseHandler.cancelContextMenu();if(S=="add"){if(!h&&v)return;if(!h){var x=c.toOrientedRange();l.addSelectionMarker(x)}var T=c.rangeList.rangeAtPoint(p);l.$blockScrolling++,l.inVirtualSelectionMode=!0,o&&(T=null,x=c.ranges[0]||x,l.removeSelectionMarker(x)),l.once("mouseup",function(){var e=c.toOrientedRange();T&&e.isEmpty()&&s(T.cursor,e.cursor)?c.substractPoint(e.cursor):(o?c.substractPoint(x.cursor):x&&(l.removeSelectionMarker(x),c.addRange(x)),c.addRange(e)),l.$blockScrolling--,l.inVirtualSelectionMode=!1})}else if(S=="block"){e.stop(),l.inVirtualSelectionMode=!0;var N,C=[],k=function(){var e=l.renderer.pixelToScreenCoordinates(m,g),t=b.screenToDocumentPosition(e.row,e.column);if(s(E,e)&&s(t,c.lead))return;E=e,l.$blockScrolling++,l.selection.moveToPosition(t),l.renderer.scrollCursorIntoView(),l.removeSelectionMarkers(C),C=c.rectangularRangeBlock(E,w),l.$mouseHandler.$clickSelection&&C.length==1&&C[0].isEmpty()&&(C[0]=l.$mouseHandler.$clickSelection.clone()),C.forEach(l.addSelectionMarker,l),l.updateSelectionMarkers(),l.$blockScrolling--};l.$blockScrolling++,h&&!a?c.toSingleRange():!h&&a&&(N=c.toOrientedRange(),l.addSelectionMarker(N)),o?w=b.documentToScreenPosition(c.lead):c.moveToPosition(p),l.$blockScrolling--,E={row:-1,column:-1};var L=function(e){clearInterval(O),l.removeSelectionMarkers(C),C.length||(C=[c.toOrientedRange()]),l.$blockScrolling++,N&&(l.removeSelectionMarker(N),c.toSingleRange(N));for(var t=0;t<C.length;t++)c.addRange(C[t]);l.inVirtualSelectionMode=!1,l.$mouseHandler.$clickSelection=null,l.$blockScrolling--},A=k;r.capture(l.container,y,L);var O=setInterval(function(){A()},20);return e.preventDefault()}}var r=e("../lib/event"),i=e("../lib/useragent");t.onMouseDown=o}),ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"],function(e,t,n){t.defaultCommands=[{name:"addCursorAbove",exec:function(e){e.selectMoreLines(-1)},bindKey:{win:"Ctrl-Alt-Up",mac:"Ctrl-Alt-Up"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorBelow",exec:function(e){e.selectMoreLines(1)},bindKey:{win:"Ctrl-Alt-Down",mac:"Ctrl-Alt-Down"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorAboveSkipCurrent",exec:function(e){e.selectMoreLines(-1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Up",mac:"Ctrl-Alt-Shift-Up"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorBelowSkipCurrent",exec:function(e){e.selectMoreLines(1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Down",mac:"Ctrl-Alt-Shift-Down"},scrollIntoView:"cursor",readOnly:!0},{name:"selectMoreBefore",exec:function(e){e.selectMore(-1)},bindKey:{win:"Ctrl-Alt-Left",mac:"Ctrl-Alt-Left"},scrollIntoView:"cursor",readOnly:!0},{name:"selectMoreAfter",exec:function(e){e.selectMore(1)},bindKey:{win:"Ctrl-Alt-Right",mac:"Ctrl-Alt-Right"},scrollIntoView:"cursor",readOnly:!0},{name:"selectNextBefore",exec:function(e){e.selectMore(-1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Left",mac:"Ctrl-Alt-Shift-Left"},scrollIntoView:"cursor",readOnly:!0},{name:"selectNextAfter",exec:function(e){e.selectMore(1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Right",mac:"Ctrl-Alt-Shift-Right"},scrollIntoView:"cursor",readOnly:!0},{name:"splitIntoLines",exec:function(e){e.multiSelect.splitIntoLines()},bindKey:{win:"Ctrl-Alt-L",mac:"Ctrl-Alt-L"},readOnly:!0},{name:"alignCursors",exec:function(e){e.alignCursors()},bindKey:{win:"Ctrl-Alt-A",mac:"Ctrl-Alt-A"},scrollIntoView:"cursor"},{name:"findAll",exec:function(e){e.findAll()},bindKey:{win:"Ctrl-Alt-K",mac:"Ctrl-Alt-G"},scrollIntoView:"cursor",readOnly:!0}],t.multiSelectCommands=[{name:"singleSelection",bindKey:"esc",exec:function(e){e.exitMultiSelectMode()},scrollIntoView:"cursor",readOnly:!0,isAvailable:function(e){return e&&e.inMultiSelectMode}}];var r=e("../keyboard/hash_handler").HashHandler;t.keyboardHandler=new r(t.multiSelectCommands)}),ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"],function(e,t,n){function h(e,t,n){return c.$options.wrap=!0,c.$options.needle=t,c.$options.backwards=n==-1,c.find(e)}function v(e,t){return e.row==t.row&&e.column==t.column}function m(e){if(e.$multiselectOnSessionChange)return;e.$onAddRange=e.$onAddRange.bind(e),e.$onRemoveRange=e.$onRemoveRange.bind(e),e.$onMultiSelect=e.$onMultiSelect.bind(e),e.$onSingleSelect=e.$onSingleSelect.bind(e),e.$multiselectOnSessionChange=t.onSessionChange.bind(e),e.$checkMultiselectChange=e.$checkMultiselectChange.bind(e),e.$multiselectOnSessionChange(e),e.on("changeSession",e.$multiselectOnSessionChange),e.on("mousedown",o),e.commands.addCommands(f.defaultCommands),g(e)}function g(e){function r(t){n&&(e.renderer.setMouseCursor(""),n=!1)}var t=e.textInput.getElement(),n=!1;u.addListener(t,"keydown",function(t){var i=t.keyCode==18&&!(t.ctrlKey||t.shiftKey||t.metaKey);e.$blockSelectEnabled&&i?n||(e.renderer.setMouseCursor("crosshair"),n=!0):n&&r()}),u.addListener(t,"keyup",r),u.addListener(t,"blur",r)}var r=e("./range_list").RangeList,i=e("./range").Range,s=e("./selection").Selection,o=e("./mouse/multi_select_handler").onMouseDown,u=e("./lib/event"),a=e("./lib/lang"),f=e("./commands/multi_select_commands");t.commands=f.defaultCommands.concat(f.multiSelectCommands);var l=e("./search").Search,c=new l,p=e("./edit_session").EditSession;(function(){this.getSelectionMarkers=function(){return this.$selectionMarkers}}).call(p.prototype),function(){this.ranges=null,this.rangeList=null,this.addRange=function(e,t){if(!e)return;if(!this.inMultiSelectMode&&this.rangeCount===0){var n=this.toOrientedRange();this.rangeList.add(n),this.rangeList.add(e);if(this.rangeList.ranges.length!=2)return this.rangeList.removeAll(),t||this.fromOrientedRange(e);this.rangeList.removeAll(),this.rangeList.add(n),this.$onAddRange(n)}e.cursor||(e.cursor=e.end);var r=this.rangeList.add(e);return this.$onAddRange(e),r.length&&this.$onRemoveRange(r),this.rangeCount>1&&!this.inMultiSelectMode&&(this._signal("multiSelect"),this.inMultiSelectMode=!0,this.session.$undoSelect=!1,this.rangeList.attach(this.session)),t||this.fromOrientedRange(e)},this.toSingleRange=function(e){e=e||this.ranges[0];var t=this.rangeList.removeAll();t.length&&this.$onRemoveRange(t),e&&this.fromOrientedRange(e)},this.substractPoint=function(e){var t=this.rangeList.substractPoint(e);if(t)return this.$onRemoveRange(t),t[0]},this.mergeOverlappingRanges=function(){var e=this.rangeList.merge();e.length?this.$onRemoveRange(e):this.ranges[0]&&this.fromOrientedRange(this.ranges[0])},this.$onAddRange=function(e){this.rangeCount=this.rangeList.ranges.length,this.ranges.unshift(e),this._signal("addRange",{range:e})},this.$onRemoveRange=function(e){this.rangeCount=this.rangeList.ranges.length;if(this.rangeCount==1&&this.inMultiSelectMode){var t=this.rangeList.ranges.pop();e.push(t),this.rangeCount=0}for(var n=e.length;n--;){var r=this.ranges.indexOf(e[n]);this.ranges.splice(r,1)}this._signal("removeRange",{ranges:e}),this.rangeCount===0&&this.inMultiSelectMode&&(this.inMultiSelectMode=!1,this._signal("singleSelect"),this.session.$undoSelect=!0,this.rangeList.detach(this.session)),t=t||this.ranges[0],t&&!t.isEqual(this.getRange())&&this.fromOrientedRange(t)},this.$initRangeList=function(){if(this.rangeList)return;this.rangeList=new r,this.ranges=[],this.rangeCount=0},this.getAllRanges=function(){return this.rangeCount?this.rangeList.ranges.concat():[this.getRange()]},this.splitIntoLines=function(){if(this.rangeCount>1){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)}else{var n=this.getRange(),r=this.isBackwards(),s=n.start.row,o=n.end.row;if(s==o){if(r)var u=n.end,a=n.start;else var u=n.start,a=n.end;this.addRange(i.fromPoints(a,a)),this.addRange(i.fromPoints(u,u));return}var f=[],l=this.getLineRange(s,!0);l.start.column=n.start.column,f.push(l);for(var c=s+1;c<o;c++)f.push(this.getLineRange(c,!0));l=this.getLineRange(o,!0),l.end.column=n.end.column,f.push(l),f.forEach(this.addRange,this)}},this.toggleBlockSelection=function(){if(this.rangeCount>1){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)}else{var r=this.session.documentToScreenPosition(this.selectionLead),s=this.session.documentToScreenPosition(this.selectionAnchor),o=this.rectangularRangeBlock(r,s);o.forEach(this.addRange,this)}},this.rectangularRangeBlock=function(e,t,n){var r=[],s=e.column<t.column;if(s)var o=e.column,u=t.column;else var o=t.column,u=e.column;var a=e.row<t.row;if(a)var f=e.row,l=t.row;else var f=t.row,l=e.row;o<0&&(o=0),f<0&&(f=0),f==l&&(n=!0);for(var c=f;c<=l;c++){var h=i.fromPoints(this.session.screenToDocumentPosition(c,o),this.session.screenToDocumentPosition(c,u));if(h.isEmpty()){if(p&&v(h.end,p))break;var p=h.end}h.cursor=s?h.start:h.end,r.push(h)}a&&r.reverse();if(!n){var d=r.length-1;while(r[d].isEmpty()&&d>0)d--;if(d>0){var m=0;while(r[m].isEmpty())m++}for(var g=d;g>=m;g--)r[g].isEmpty()&&r.splice(g,1)}return r}}.call(s.prototype);var d=e("./editor").Editor;(function(){this.updateSelectionMarkers=function(){this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.addSelectionMarker=function(e){e.cursor||(e.cursor=e.end);var t=this.getSelectionStyle();return e.marker=this.session.addMarker(e,"ace_selection",t),this.session.$selectionMarkers.push(e),this.session.selectionMarkerCount=this.session.$selectionMarkers.length,e},this.removeSelectionMarker=function(e){if(!e.marker)return;this.session.removeMarker(e.marker);var t=this.session.$selectionMarkers.indexOf(e);t!=-1&&this.session.$selectionMarkers.splice(t,1),this.session.selectionMarkerCount=this.session.$selectionMarkers.length},this.removeSelectionMarkers=function(e){var t=this.session.$selectionMarkers;for(var n=e.length;n--;){var r=e[n];if(!r.marker)continue;this.session.removeMarker(r.marker);var i=t.indexOf(r);i!=-1&&t.splice(i,1)}this.session.selectionMarkerCount=t.length},this.$onAddRange=function(e){this.addSelectionMarker(e.range),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onRemoveRange=function(e){this.removeSelectionMarkers(e.ranges),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onMultiSelect=function(e){if(this.inMultiSelectMode)return;this.inMultiSelectMode=!0,this.setStyle("ace_multiselect"),this.keyBinding.addKeyboardHandler(f.keyboardHandler),this.commands.setDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onSingleSelect=function(e){if(this.session.multiSelect.inVirtualMode)return;this.inMultiSelectMode=!1,this.unsetStyle("ace_multiselect"),this.keyBinding.removeKeyboardHandler(f.keyboardHandler),this.commands.removeDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers(),this._emit("changeSelection")},this.$onMultiSelectExec=function(e){var t=e.command,n=e.editor;if(!n.multiSelect)return;if(!t.multiSelectAction){var r=t.exec(n,e.args||{});n.multiSelect.addRange(n.multiSelect.toOrientedRange()),n.multiSelect.mergeOverlappingRanges()}else t.multiSelectAction=="forEach"?r=n.forEachSelection(t,e.args):t.multiSelectAction=="forEachLine"?r=n.forEachSelection(t,e.args,!0):t.multiSelectAction=="single"?(n.exitMultiSelectMode(),r=t.exec(n,e.args||{})):r=t.multiSelectAction(n,e.args||{});return r},this.forEachSelection=function(e,t,n){if(this.inVirtualSelectionMode)return;var r=n&&n.keepOrder,i=n==1||n&&n.$byLines,o=this.session,u=this.selection,a=u.rangeList,f=(r?u:a).ranges,l;if(!f.length)return e.exec?e.exec(this,t||{}):e(this,t||{});var c=u._eventRegistry;u._eventRegistry={};var h=new s(o);this.inVirtualSelectionMode=!0;for(var p=f.length;p--;){if(i)while(p>0&&f[p].start.row==f[p-1].end.row)p--;h.fromOrientedRange(f[p]),h.index=p,this.selection=o.selection=h;var d=e.exec?e.exec(this,t||{}):e(this,t||{});!l&&d!==undefined&&(l=d),h.toOrientedRange(f[p])}h.detach(),this.selection=o.selection=u,this.inVirtualSelectionMode=!1,u._eventRegistry=c,u.mergeOverlappingRanges();var v=this.renderer.$scrollAnimation;return this.onCursorChange(),this.onSelectionChange(),v&&v.from==v.to&&this.renderer.animateScrolling(v.from),l},this.exitMultiSelectMode=function(){if(!this.inMultiSelectMode||this.inVirtualSelectionMode)return;this.multiSelect.toSingleRange()},this.getSelectedText=function(){var e="";if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){var t=this.multiSelect.rangeList.ranges,n=[];for(var r=0;r<t.length;r++)n.push(this.session.getTextRange(t[r]));var i=this.session.getDocument().getNewLineCharacter();e=n.join(i),e.length==(n.length-1)*i.length&&(e="")}else this.selection.isEmpty()||(e=this.session.getTextRange(this.getSelectionRange()));return e},this.$checkMultiselectChange=function(e,t){if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){var n=this.multiSelect.ranges[0];if(this.multiSelect.isEmpty()&&t==this.multiSelect.anchor)return;var r=t==this.multiSelect.anchor?n.cursor==n.start?n.end:n.start:n.cursor;(r.row!=t.row||this.session.$clipPositionToDocument(r.row,r.column).column!=t.column)&&this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange())}},this.findAll=function(e,t,n){t=t||{},t.needle=e||t.needle;if(t.needle==undefined){var r=this.selection.isEmpty()?this.selection.getWordRange():this.selection.getRange();t.needle=this.session.getTextRange(r)}this.$search.set(t);var i=this.$search.findAll(this.session);if(!i.length)return 0;this.$blockScrolling+=1;var s=this.multiSelect;n||s.toSingleRange(i[0]);for(var o=i.length;o--;)s.addRange(i[o],!0);return r&&s.rangeList.rangeAtPoint(r.start)&&s.addRange(r,!0),this.$blockScrolling-=1,i.length},this.selectMoreLines=function(e,t){var n=this.selection.toOrientedRange(),r=n.cursor==n.end,s=this.session.documentToScreenPosition(n.cursor);this.selection.$desiredColumn&&(s.column=this.selection.$desiredColumn);var o=this.session.screenToDocumentPosition(s.row+e,s.column);if(!n.isEmpty())var u=this.session.documentToScreenPosition(r?n.end:n.start),a=this.session.screenToDocumentPosition(u.row+e,u.column);else var a=o;if(r){var f=i.fromPoints(o,a);f.cursor=f.start}else{var f=i.fromPoints(a,o);f.cursor=f.end}f.desiredColumn=s.column;if(!this.selection.inMultiSelectMode)this.selection.addRange(n);else if(t)var l=n.cursor;this.selection.addRange(f),l&&this.selection.substractPoint(l)},this.transposeSelections=function(e){var t=this.session,n=t.multiSelect,r=n.ranges;for(var i=r.length;i--;){var s=r[i];if(s.isEmpty()){var o=t.getWordRange(s.start.row,s.start.column);s.start.row=o.start.row,s.start.column=o.start.column,s.end.row=o.end.row,s.end.column=o.end.column}}n.mergeOverlappingRanges();var u=[];for(var i=r.length;i--;){var s=r[i];u.unshift(t.getTextRange(s))}e<0?u.unshift(u.pop()):u.push(u.shift());for(var i=r.length;i--;){var s=r[i],o=s.clone();t.replace(s,u[i]),s.start.row=o.start.row,s.start.column=o.start.column}},this.selectMore=function(e,t,n){var r=this.session,i=r.multiSelect,s=i.toOrientedRange();if(s.isEmpty()){s=r.getWordRange(s.start.row,s.start.column),s.cursor=e==-1?s.start:s.end,this.multiSelect.addRange(s);if(n)return}var o=r.getTextRange(s),u=h(r,o,e);u&&(u.cursor=e==-1?u.start:u.end,this.$blockScrolling+=1,this.session.unfold(u),this.multiSelect.addRange(u),this.$blockScrolling-=1,this.renderer.scrollCursorIntoView(null,.5)),t&&this.multiSelect.substractPoint(s.cursor)},this.alignCursors=function(){var e=this.session,t=e.multiSelect,n=t.ranges,r=-1,s=n.filter(function(e){if(e.cursor.row==r)return!0;r=e.cursor.row});if(!n.length||s.length==n.length-1){var o=this.selection.getRange(),u=o.start.row,f=o.end.row,l=u==f;if(l){var c=this.session.getLength(),h;do h=this.session.getLine(f);while(/[=:]/.test(h)&&++f<c);do h=this.session.getLine(u);while(/[=:]/.test(h)&&--u>0);u<0&&(u=0),f>=c&&(f=c-1)}var p=this.session.removeFullLines(u,f);p=this.$reAlignText(p,l),this.session.insert({row:u,column:0},p.join("\n")+"\n"),l||(o.start.column=0,o.end.column=p[p.length-1].length),this.selection.setRange(o)}else{s.forEach(function(e){t.substractPoint(e.cursor)});var d=0,v=Infinity,m=n.map(function(t){var n=t.cursor,r=e.getLine(n.row),i=r.substr(n.column).search(/\S/g);return i==-1&&(i=0),n.column>d&&(d=n.column),i<v&&(v=i),i});n.forEach(function(t,n){var r=t.cursor,s=d-r.column,o=m[n]-v;s>o?e.insert(r,a.stringRepeat(" ",s-o)):e.remove(new i(r.row,r.column,r.row,r.column-s+o)),t.start.column=t.end.column=d,t.start.row=t.end.row=r.row,t.cursor=t.end}),t.fromOrientedRange(n[0]),this.renderer.updateCursor(),this.renderer.updateBackMarkers()}},this.$reAlignText=function(e,t){function u(e){return a.stringRepeat(" ",e)}function f(e){return e[2]?u(i)+e[2]+u(s-e[2].length+o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function l(e){return e[2]?u(i+s-e[2].length)+e[2]+u(o," ")+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function c(e){return e[2]?u(i)+e[2]+u(o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}var n=!0,r=!0,i,s,o;return e.map(function(e){var t=e.match(/(\s*)(.*?)(\s*)([=:].*)/);return t?i==null?(i=t[1].length,s=t[2].length,o=t[3].length,t):(i+s+o!=t[1].length+t[2].length+t[3].length&&(r=!1),i!=t[1].length&&(n=!1),i>t[1].length&&(i=t[1].length),s<t[2].length&&(s=t[2].length),o>t[3].length&&(o=t[3].length),t):[e]}).map(t?f:n?r?l:f:c)}}).call(d.prototype),t.onSessionChange=function(e){var t=e.session;t&&!t.multiSelect&&(t.$selectionMarkers=[],t.selection.$initRangeList(),t.multiSelect=t.selection),this.multiSelect=t&&t.multiSelect;var n=e.oldSession;n&&(n.multiSelect.off("addRange",this.$onAddRange),n.multiSelect.off("removeRange",this.$onRemoveRange),n.multiSelect.off("multiSelect",this.$onMultiSelect),n.multiSelect.off("singleSelect",this.$onSingleSelect),n.multiSelect.lead.off("change",this.$checkMultiselectChange),n.multiSelect.anchor.off("change",this.$checkMultiselectChange)),t&&(t.multiSelect.on("addRange",this.$onAddRange),t.multiSelect.on("removeRange",this.$onRemoveRange),t.multiSelect.on("multiSelect",this.$onMultiSelect),t.multiSelect.on("singleSelect",this.$onSingleSelect),t.multiSelect.lead.on("change",this.$checkMultiselectChange),t.multiSelect.anchor.on("change",this.$checkMultiselectChange)),t&&this.inMultiSelectMode!=t.selection.inMultiSelectMode&&(t.selection.inMultiSelectMode?this.$onMultiSelect():this.$onSingleSelect())},t.MultiSelect=m,e("./config").defineOptions(d.prototype,"editor",{enableMultiselect:{set:function(e){m(this),e?(this.on("changeSession",this.$multiselectOnSessionChange),this.on("mousedown",o)):(this.off("changeSession",this.$multiselectOnSessionChange),this.off("mousedown",o))},value:!0},enableBlockSelect:{set:function(e){this.$blockSelectEnabled=e},value:!0}})}),ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../../range").Range,i=t.FoldMode=function(){};(function(){this.foldingStartMarker=null,this.foldingStopMarker=null,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);return this.foldingStartMarker.test(r)?"start":t=="markbeginend"&&this.foldingStopMarker&&this.foldingStopMarker.test(r)?"end":""},this.getFoldWidgetRange=function(e,t,n){return null},this.indentationBlock=function(e,t,n){var i=/\S/,s=e.getLine(t),o=s.search(i);if(o==-1)return;var u=n||s.length,a=e.getLength(),f=t,l=t;while(++t<a){var c=e.getLine(t).search(i);if(c==-1)continue;if(c<=o)break;l=t}if(l>f){var h=e.getLine(l).length;return new r(f,u,l,h)}},this.openingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i+1},u=e.$findClosingBracket(t,o,s);if(!u)return;var a=e.foldWidgets[u.row];return a==null&&(a=e.getFoldWidget(u.row)),a=="start"&&u.row>o.row&&(u.row--,u.column=e.getLine(u.row).length),r.fromPoints(o,u)},this.closingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i},u=e.$findOpeningBracket(t,o);if(!u)return;return u.column++,o.column--,r.fromPoints(u,o)}}).call(i.prototype)}),ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";t.isDark=!1,t.cssClass="ace-tm",t.cssText='.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;color: black;}.ace-tm .ace_cursor {color: black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}';var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}),ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"],function(e,t,n){"use strict";function o(e){this.session=e,this.session.widgetManager=this,this.session.getRowLength=this.getRowLength,this.session.$getWidgetScreenLength=this.$getWidgetScreenLength,this.updateOnChange=this.updateOnChange.bind(this),this.renderWidgets=this.renderWidgets.bind(this),this.measureWidgets=this.measureWidgets.bind(this),this.session._changedWidgets=[],this.$onChangeEditor=this.$onChangeEditor.bind(this),this.session.on("change",this.updateOnChange),this.session.on("changeFold",this.updateOnFold),this.session.on("changeEditor",this.$onChangeEditor)}var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./range").Range;(function(){this.getRowLength=function(e){var t;return this.lineWidgets?t=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0:t=0,!this.$useWrapMode||!this.$wrapData[e]?1+t:this.$wrapData[e].length+1+t},this.$getWidgetScreenLength=function(){var e=0;return this.lineWidgets.forEach(function(t){t&&t.rowCount&&!t.hidden&&(e+=t.rowCount)}),e},this.$onChangeEditor=function(e){this.attach(e.editor)},this.attach=function(e){e&&e.widgetManager&&e.widgetManager!=this&&e.widgetManager.detach();if(this.editor==e)return;this.detach(),this.editor=e,e&&(e.widgetManager=this,e.renderer.on("beforeRender",this.measureWidgets),e.renderer.on("afterRender",this.renderWidgets))},this.detach=function(e){var t=this.editor;if(!t)return;this.editor=null,t.widgetManager=null,t.renderer.off("beforeRender",this.measureWidgets),t.renderer.off("afterRender",this.renderWidgets);var n=this.session.lineWidgets;n&&n.forEach(function(e){e&&e.el&&e.el.parentNode&&(e._inDocument=!1,e.el.parentNode.removeChild(e.el))})},this.updateOnFold=function(e,t){var n=t.lineWidgets;if(!n||!e.action)return;var r=e.data,i=r.start.row,s=r.end.row,o=e.action=="add";for(var u=i+1;u<s;u++)n[u]&&(n[u].hidden=o);n[s]&&(o?n[i]?n[s].hidden=o:n[i]=n[s]:(n[i]==n[s]&&(n[i]=undefined),n[s].hidden=o))},this.updateOnChange=function(e){var t=this.session.lineWidgets;if(!t)return;var n=e.start.row,r=e.end.row-n;if(r!==0)if(e.action=="remove"){var i=t.splice(n+1,r);i.forEach(function(e){e&&this.removeLineWidget(e)},this),this.$updateRows()}else{var s=new Array(r);s.unshift(n,0),t.splice.apply(t,s),this.$updateRows()}},this.$updateRows=function(){var e=this.session.lineWidgets;if(!e)return;var t=!0;e.forEach(function(e,n){if(e){t=!1,e.row=n;while(e.$oldWidget)e.$oldWidget.row=n,e=e.$oldWidget}}),t&&(this.session.lineWidgets=null)},this.addLineWidget=function(e){this.session.lineWidgets||(this.session.lineWidgets=new Array(this.session.getLength()));var t=this.session.lineWidgets[e.row];t&&(e.$oldWidget=t,t.el&&t.el.parentNode&&(t.el.parentNode.removeChild(t.el),t._inDocument=!1)),this.session.lineWidgets[e.row]=e,e.session=this.session;var n=this.editor.renderer;e.html&&!e.el&&(e.el=i.createElement("div"),e.el.innerHTML=e.html),e.el&&(i.addCssClass(e.el,"ace_lineWidgetContainer"),e.el.style.position="absolute",e.el.style.zIndex=5,n.container.appendChild(e.el),e._inDocument=!0),e.coverGutter||(e.el.style.zIndex=3),e.pixelHeight==null&&(e.pixelHeight=e.el.offsetHeight),e.rowCount==null&&(e.rowCount=e.pixelHeight/n.layerConfig.lineHeight);var r=this.session.getFoldAt(e.row,0);e.$fold=r;if(r){var s=this.session.lineWidgets;e.row==r.end.row&&!s[r.start.row]?s[r.start.row]=e:e.hidden=!0}return this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows(),this.renderWidgets(null,n),this.onWidgetChanged(e),e},this.removeLineWidget=function(e){e._inDocument=!1,e.session=null,e.el&&e.el.parentNode&&e.el.parentNode.removeChild(e.el);if(e.editor&&e.editor.destroy)try{e.editor.destroy()}catch(t){}if(this.session.lineWidgets){var n=this.session.lineWidgets[e.row];if(n==e)this.session.lineWidgets[e.row]=e.$oldWidget,e.$oldWidget&&this.onWidgetChanged(e.$oldWidget);else while(n){if(n.$oldWidget==e){n.$oldWidget=e.$oldWidget;break}n=n.$oldWidget}}this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows()},this.getWidgetsAtRow=function(e){var t=this.session.lineWidgets,n=t&&t[e],r=[];while(n)r.push(n),n=n.$oldWidget;return r},this.onWidgetChanged=function(e){this.session._changedWidgets.push(e),this.editor&&this.editor.renderer.updateFull()},this.measureWidgets=function(e,t){var n=this.session._changedWidgets,r=t.layerConfig;if(!n||!n.length)return;var i=Infinity;for(var s=0;s<n.length;s++){var o=n[s];if(!o||!o.el)continue;if(o.session!=this.session)continue;if(!o._inDocument){if(this.session.lineWidgets[o.row]!=o)continue;o._inDocument=!0,t.container.appendChild(o.el)}o.h=o.el.offsetHeight,o.fixedWidth||(o.w=o.el.offsetWidth,o.screenWidth=Math.ceil(o.w/r.characterWidth));var u=o.h/r.lineHeight;o.coverLine&&(u-=this.session.getRowLineCount(o.row),u<0&&(u=0)),o.rowCount!=u&&(o.rowCount=u,o.row<i&&(i=o.row))}i!=Infinity&&(this.session._emit("changeFold",{data:{start:{row:i}}}),this.session.lineWidgetWidth=null),this.session._changedWidgets=[]},this.renderWidgets=function(e,t){var n=t.layerConfig,r=this.session.lineWidgets;if(!r)return;var i=Math.min(this.firstRow,n.firstRow),s=Math.max(this.lastRow,n.lastRow,r.length);while(i>0&&!r[i])i--;this.firstRow=n.firstRow,this.lastRow=n.lastRow,t.$cursorLayer.config=n;for(var o=i;o<=s;o++){var u=r[o];if(!u||!u.el)continue;if(u.hidden){u.el.style.top=-100-(u.pixelHeight||0)+"px";continue}u._inDocument||(u._inDocument=!0,t.container.appendChild(u.el));var a=t.$cursorLayer.getPixelPosition({row:o,column:0},!0).top;u.coverLine||(a+=n.lineHeight*this.session.getRowLineCount(u.row)),u.el.style.top=a-n.offset+"px";var f=u.coverGutter?0:t.gutterWidth;u.fixedWidth||(f-=t.scrollLeft),u.el.style.left=f+"px",u.fullWidth&&u.screenWidth&&(u.el.style.minWidth=n.width+2*n.padding+"px"),u.fixedWidth?u.el.style.right=t.scrollBar.getWidth()+"px":u.el.style.right=""}}}).call(o.prototype),t.LineWidgets=o}),ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"],function(e,t,n){"use strict";function o(e,t,n){var r=0,i=e.length-1;while(r<=i){var s=r+i>>1,o=n(t,e[s]);if(o>0)r=s+1;else{if(!(o<0))return s;i=s-1}}return-(r+1)}function u(e,t,n){var r=e.getAnnotations().sort(s.comparePoints);if(!r.length)return;var i=o(r,{row:t,column:-1},s.comparePoints);i<0&&(i=-i-1),i>=r.length?i=n>0?0:r.length-1:i===0&&n<0&&(i=r.length-1);var u=r[i];if(!u||!n)return;if(u.row===t){do u=r[i+=n];while(u&&u.row===t);if(!u)return r.slice()}var a=[];t=u.row;do a[n<0?"unshift":"push"](u),u=r[i+=n];while(u&&u.row==t);return a.length&&a}var r=e("../line_widgets").LineWidgets,i=e("../lib/dom"),s=e("../range").Range;t.showErrorMarker=function(e,t){var n=e.session;n.widgetManager||(n.widgetManager=new r(n),n.widgetManager.attach(e));var s=e.getCursorPosition(),o=s.row,a=n.widgetManager.getWidgetsAtRow(o).filter(function(e){return e.type=="errorMarker"})[0];a?a.destroy():o-=t;var f=u(n,o,t),l;if(f){var c=f[0];s.column=(c.pos&&typeof c.column!="number"?c.pos.sc:c.column)||0,s.row=c.row,l=e.renderer.$gutterLayer.$annotations[s.row]}else{if(a)return;l={text:["Looks good!"],className:"ace_ok"}}e.session.unfold(s.row),e.selection.moveToPosition(s);var h={row:s.row,fixedWidth:!0,coverGutter:!0,el:i.createElement("div"),type:"errorMarker"},p=h.el.appendChild(i.createElement("div")),d=h.el.appendChild(i.createElement("div"));d.className="error_widget_arrow "+l.className;var v=e.renderer.$cursorLayer.getPixelPosition(s).left;d.style.left=v+e.renderer.gutterWidth-5+"px",h.el.className="error_widget_wrapper",p.className="error_widget "+l.className,p.innerHTML=l.text.join("<br>"),p.appendChild(i.createElement("div"));var m=function(e,t,n){if(t===0&&(n==="esc"||n==="return"))return h.destroy(),{command:"null"}};h.destroy=function(){if(e.$mouseHandler.isMousePressed)return;e.keyBinding.removeKeyboardHandler(m),n.widgetManager.removeLineWidget(h),e.off("changeSelection",h.destroy),e.off("changeSession",h.destroy),e.off("mouseup",h.destroy),e.off("change",h.destroy)},e.keyBinding.addKeyboardHandler(m),e.on("changeSelection",h.destroy),e.on("changeSession",h.destroy),e.on("mouseup",h.destroy),e.on("change",h.destroy),e.session.widgetManager.addLineWidget(h),h.el.onmousedown=e.focus.bind(e),e.renderer.scrollCursorIntoView(null,.5,{bottom:h.el.offsetHeight})},i.importCssString(" .error_widget_wrapper { background: inherit; color: inherit; border:none } .error_widget { border-top: solid 2px; border-bottom: solid 2px; margin: 5px 0; padding: 10px 40px; white-space: pre-wrap; } .error_widget.ace_error, .error_widget_arrow.ace_error{ border-color: #ff5a5a } .error_widget.ace_warning, .error_widget_arrow.ace_warning{ border-color: #F1D817 } .error_widget.ace_info, .error_widget_arrow.ace_info{ border-color: #5a5a5a } .error_widget.ace_ok, .error_widget_arrow.ace_ok{ border-color: #5aaa5a } .error_widget_arrow { position: absolute; border: solid 5px; border-top-color: transparent!important; border-right-color: transparent!important; border-left-color: transparent!important; top: -5px; }","")}),ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"],function(e,t,n){"use strict";e("./lib/fixoldbrowsers");var r=e("./lib/dom"),i=e("./lib/event"),s=e("./editor").Editor,o=e("./edit_session").EditSession,u=e("./undomanager").UndoManager,a=e("./virtual_renderer").VirtualRenderer;e("./worker/worker_client"),e("./keyboard/hash_handler"),e("./placeholder"),e("./multi_select"),e("./mode/folding/fold_mode"),e("./theme/textmate"),e("./ext/error_marker"),t.config=e("./config"),t.require=e,"function"=="function"&&(t.define=__webpack_require__(31)),t.edit=function(e){if(typeof e=="string"){var n=e;e=document.getElementById(n);if(!e)throw new Error("ace.edit can't find div #"+n)}if(e&&e.env&&e.env.editor instanceof s)return e.env.editor;var o="";if(e&&/input|textarea/i.test(e.tagName)){var u=e;o=u.value,e=r.createElement("pre"),u.parentNode.replaceChild(e,u)}else e&&(o=r.getInnerText(e),e.innerHTML="");var f=t.createEditSession(o),l=new s(new a(e));l.setSession(f);var c={document:f,editor:l,onResize:l.resize.bind(l,null)};return u&&(c.textarea=u),i.addListener(window,"resize",c.onResize),l.on("destroy",function(){i.removeListener(window,"resize",c.onResize),c.editor.container.env=null}),l.container.env=l.env=c,l},t.createEditSession=function(e,t){var n=new o(e,t);return n.setUndoManager(new u),n},t.EditSession=o,t.UndoManager=u,t.version="1.2.5"}); 5533 (function() { 5534 ace.require(["ace/ace"], function(a) { 5535 if (a) { 5536 a.config.init(true); 5537 a.define = ace.define; 5538 } 5539 if (!window.ace) 5540 window.ace = a; 5541 for (var key in a) if (a.hasOwnProperty(key)) 5542 window.ace[key] = a[key]; 5543 }); 5544 })(); 5545 5546 5547 /***/ }, 5548 /* 22 */ 5549 /***/ function(module, exports) { 5550 5551 ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},s.getTagRule(),{defaultToken:"comment.doc",caseInsensitive:!0}]}};r.inherits(s,i),s.getTagRule=function(e){return{token:"comment.doc.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},s.getStartRule=function(e){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:e}},s.getEndRule=function(e){return{token:"comment.doc",regex:"\\*\\/",next:e}},t.DocCommentHighlightRules=s}),ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";function a(){var e=o.replace("\\d","\\d\\-"),t={onMatch:function(e,t,n){var r=e.charAt(1)=="/"?2:1;if(r==1)t!=this.nextState?n.unshift(this.next,this.nextState,0):n.unshift(this.next),n[2]++;else if(r==2&&t==this.nextState){n[1]--;if(!n[1]||n[1]<0)n.shift(),n.shift()}return[{type:"meta.tag.punctuation."+(r==1?"":"end-")+"tag-open.xml",value:e.slice(0,r)},{type:"meta.tag.tag-name.xml",value:e.substr(r)}]},regex:"</?"+e+"",next:"jsxAttributes",nextState:"jsx"};this.$rules.start.unshift(t);var n={regex:"{",token:"paren.quasi.start",push:"start"};this.$rules.jsx=[n,t,{include:"reference"},{defaultToken:"string"}],this.$rules.jsxAttributes=[{token:"meta.tag.punctuation.tag-close.xml",regex:"/?>",onMatch:function(e,t,n){return t==n[0]&&n.shift(),e.length==2&&(n[0]==this.nextState&&n[1]--,(!n[1]||n[1]<0)&&n.splice(0,2)),this.next=n[0]||"start",[{type:this.token,value:e}]},nextState:"jsx"},n,f("jsxAttributes"),{token:"entity.other.attribute-name.xml",regex:e},{token:"keyword.operator.attribute-equals.xml",regex:"="},{token:"text.tag-whitespace.xml",regex:"\\s+"},{token:"string.attribute-value.xml",regex:"'",stateName:"jsx_attr_q",push:[{token:"string.attribute-value.xml",regex:"'",next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},{token:"string.attribute-value.xml",regex:'"',stateName:"jsx_attr_qq",push:[{token:"string.attribute-value.xml",regex:'"',next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},t],this.$rules.reference=[{token:"constant.language.escape.reference.xml",regex:"(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"}]}function f(e){return[{token:"comment",regex:/\/\*/,next:[i.getTagRule(),{token:"comment",regex:"\\*\\/",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]},{token:"comment",regex:"\\/\\/",next:[i.getTagRule(),{token:"comment",regex:"$|^",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]}]}var r=e("../lib/oop"),i=e("./doc_comment_highlight_rules").DocCommentHighlightRules,s=e("./text_highlight_rules").TextHighlightRules,o="[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*",u=function(e){var t=this.createKeywordMapper({"variable.language":"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Namespace|QName|XML|XMLList|ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|JSON|Math|this|arguments|prototype|window|document",keyword:"const|yield|import|get|set|async|await|break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|__parent__|__count__|escape|unescape|with|__proto__|class|enum|extends|super|export|implements|private|public|interface|package|protected|static","storage.type":"const|let|var|function","constant.language":"null|Infinity|NaN|undefined","support.function":"alert","constant.language.boolean":"true|false"},"identifier"),n="case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void",r="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|u{[0-9a-fA-F]{1,6}}|[0-2][0-7]{0,2}|3[0-7][0-7]?|[4-7][0-7]?|.)";this.$rules={no_regex:[i.getStartRule("doc-start"),f("no_regex"),{token:"string",regex:"'(?=.)",next:"qstring"},{token:"string",regex:'"(?=.)',next:"qqstring"},{token:"constant.numeric",regex:/0(?:[xX][0-9a-fA-F]+|[bB][01]+)\b/},{token:"constant.numeric",regex:/[+-]?\d[\d_]*(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["storage.type","punctuation.operator","support.function","punctuation.operator","entity.name.function","text","keyword.operator"],regex:"("+o+")(\\.)(prototype)(\\.)("+o+")(\\s*)(=)",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","entity.name.function","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+o+")(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","punctuation.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["text","text","storage.type","text","paren.lparen"],regex:"(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:"keyword",regex:"(?:"+n+")\\b",next:"start"},{token:["support.constant"],regex:/that\b/},{token:["storage.type","punctuation.operator","support.function.firebug"],regex:/(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/},{token:t,regex:o},{token:"punctuation.operator",regex:/[.](?![.])/,next:"property"},{token:"keyword.operator",regex:/--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,next:"start"},{token:"punctuation.operator",regex:/[?:,;.]/,next:"start"},{token:"paren.lparen",regex:/[\[({]/,next:"start"},{token:"paren.rparen",regex:/[\])}]/},{token:"comment",regex:/^#!.*$/}],property:[{token:"text",regex:"\\s+"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","entity.name.function","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",next:"function_arguments"},{token:"punctuation.operator",regex:/[.](?![.])/},{token:"support.function",regex:/(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/},{token:"support.function.dom",regex:/(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/},{token:"support.constant",regex:/(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/},{token:"identifier",regex:o},{regex:"",token:"empty",next:"no_regex"}],start:[i.getStartRule("doc-start"),f("start"),{token:"string.regexp",regex:"\\/",next:"regex"},{token:"text",regex:"\\s+|^$",next:"start"},{token:"empty",regex:"",next:"no_regex"}],regex:[{token:"regexp.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"string.regexp",regex:"/[sxngimy]*",next:"no_regex"},{token:"invalid",regex:/\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/},{token:"constant.language.escape",regex:/\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/},{token:"constant.language.delimiter",regex:/\|/},{token:"constant.language.escape",regex:/\[\^?/,next:"regex_character_class"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp"}],regex_character_class:[{token:"regexp.charclass.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"constant.language.escape",regex:"]",next:"regex"},{token:"constant.language.escape",regex:"-"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp.charachterclass"}],function_arguments:[{token:"variable.parameter",regex:o},{token:"punctuation.operator",regex:"[, ]+"},{token:"punctuation.operator",regex:"$"},{token:"empty",regex:"",next:"no_regex"}],qqstring:[{token:"constant.language.escape",regex:r},{token:"string",regex:"\\\\$",next:"qqstring"},{token:"string",regex:'"|$',next:"no_regex"},{defaultToken:"string"}],qstring:[{token:"constant.language.escape",regex:r},{token:"string",regex:"\\\\$",next:"qstring"},{token:"string",regex:"'|$",next:"no_regex"},{defaultToken:"string"}]};if(!e||!e.noES6)this.$rules.no_regex.unshift({regex:"[{}]",onMatch:function(e,t,n){this.next=e=="{"?this.nextState:"";if(e=="{"&&n.length)n.unshift("start",t);else if(e=="}"&&n.length){n.shift(),this.next=n.shift();if(this.next.indexOf("string")!=-1||this.next.indexOf("jsx")!=-1)return"paren.quasi.end"}return e=="{"?"paren.lparen":"paren.rparen"},nextState:"start"},{token:"string.quasi.start",regex:/`/,push:[{token:"constant.language.escape",regex:r},{token:"paren.quasi.start",regex:/\${/,push:"start"},{token:"string.quasi.end",regex:/`/,next:"pop"},{defaultToken:"string.quasi"}]}),(!e||e.jsx!=0)&&a.call(this);this.embedRules(i,"doc-",[i.getEndRule("no_regex")]),this.normalizeRules()};r.inherits(u,s),t.JavaScriptHighlightRules=u}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++t<a){n=e.getLine(t);var f=n.search(/\S/);if(f===-1)continue;if(r>f)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++n<s){t=e.getLine(n);var f=u.exec(t);if(!f)continue;f[1]?a--:a++;if(!a)break}var l=n;if(l>o)return new i(o,r,l,t.length)}}.call(o.prototype)}),ace.define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./javascript_highlight_rules").JavaScriptHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"||e=="no_regex"){var u=t.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc-start"){if(o=="start"||o=="no_regex")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.createWorker=function(e){var t=new a(["ace"],"ace/mode/javascript_worker","JavaScriptWorker");return t.attachToDocument(e.getDocument()),t.on("annotate",function(t){e.setAnnotations(t.data)}),t.on("terminate",function(){e.clearAnnotations()}),t},this.$id="ace/mode/javascript"}.call(c.prototype),t.Mode=c}) 5552 5553 /***/ }, 5554 /* 23 */ 5555 /***/ function(module, exports) { 5556 5557 ace.define("ace/mode/yaml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment",regex:"#.*$"},{token:"list.markup",regex:/^(?:-{3}|\.{3})\s*(?=#|$)/},{token:"list.markup",regex:/^\s*[\-?](?:$|\s)/},{token:"constant",regex:"!![\\w//]+"},{token:"constant.language",regex:"[&\\*][a-zA-Z0-9-_]+"},{token:["meta.tag","keyword"],regex:/^(\s*\w.*?)(:(?:\s+|$))/},{token:["meta.tag","keyword"],regex:/(\w+?)(\s*:(?:\s+|$))/},{token:"keyword.operator",regex:"<<\\w*:\\w*"},{token:"keyword.operator",regex:"-\\s*(?=[{])"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:"[|>][-+\\d\\s]*$",next:"qqstring"},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"constant.numeric",regex:/(\b|[+\-\.])[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)/},{token:"constant.numeric",regex:/[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/},{token:"constant.language.boolean",regex:"\\b(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"},{token:"paren.lparen",regex:"[[({]"},{token:"paren.rparen",regex:"[\\])}]"}],qqstring:[{token:"string",regex:"(?=(?:(?:\\\\.)|(?:[^:]))*?:)",next:"start"},{token:"string",regex:".+"}]}};r.inherits(s,i),t.YamlHighlightRules=s}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("./fold_mode").FoldMode,s=e("../../range").Range,o=t.FoldMode=function(){};r.inherits(o,i),function(){this.getFoldWidgetRange=function(e,t,n){var r=this.indentationBlock(e,n);if(r)return r;var i=/\S/,o=e.getLine(n),u=o.search(i);if(u==-1||o[u]!="#")return;var a=o.length,f=e.getLength(),l=n,c=n;while(++n<f){o=e.getLine(n);var h=o.search(i);if(h==-1)continue;if(o[h]!="#")break;c=n}if(c>l){var p=e.getLine(c).length;return new s(l,a,c,p)}},this.getFoldWidget=function(e,t,n){var r=e.getLine(n),i=r.search(/\S/),s=e.getLine(n+1),o=e.getLine(n-1),u=o.search(/\S/),a=s.search(/\S/);if(i==-1)return e.foldWidgets[n-1]=u!=-1&&u<a?"start":"","";if(u==-1){if(i==a&&r[i]=="#"&&s[i]=="#")return e.foldWidgets[n-1]="",e.foldWidgets[n+1]="","start"}else if(u==i&&r[i]=="#"&&o[i]=="#"&&e.getLine(n-2).search(/\S/)==-1)return e.foldWidgets[n-1]="start",e.foldWidgets[n+1]="","";return u!=-1&&u<i?e.foldWidgets[n-1]="start":e.foldWidgets[n-1]="",i<a?"start":""}}.call(o.prototype)}),ace.define("ace/mode/yaml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/yaml_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./yaml_highlight_rules").YamlHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("./folding/coffee").FoldMode,a=function(){this.HighlightRules=s,this.$outdent=new o,this.foldingRules=new u};r.inherits(a,i),function(){this.lineCommentStart="#",this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t);if(e=="start"){var i=t.match(/^.*[\{\(\[]\s*$/);i&&(r+=n)}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/yaml"}.call(a.prototype),t.Mode=a}) 5558 5559 /***/ }, 5560 /* 24 */ 5561 /***/ function(module, exports) { 5562 5563 ace.define("ace/theme/monokai",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-monokai",t.cssText=".ace-monokai .ace_gutter {background: #2F3129;color: #8F908A}.ace-monokai .ace_print-margin {width: 1px;background: #555651}.ace-monokai {background-color: #272822;color: #F8F8F2}.ace-monokai .ace_cursor {color: #F8F8F0}.ace-monokai .ace_marker-layer .ace_selection {background: #49483E}.ace-monokai.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #272822;}.ace-monokai .ace_marker-layer .ace_step {background: rgb(102, 82, 0)}.ace-monokai .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #49483E}.ace-monokai .ace_marker-layer .ace_active-line {background: #202020}.ace-monokai .ace_gutter-active-line {background-color: #272727}.ace-monokai .ace_marker-layer .ace_selected-word {border: 1px solid #49483E}.ace-monokai .ace_invisible {color: #52524d}.ace-monokai .ace_entity.ace_name.ace_tag,.ace-monokai .ace_keyword,.ace-monokai .ace_meta.ace_tag,.ace-monokai .ace_storage {color: #F92672}.ace-monokai .ace_punctuation,.ace-monokai .ace_punctuation.ace_tag {color: #fff}.ace-monokai .ace_constant.ace_character,.ace-monokai .ace_constant.ace_language,.ace-monokai .ace_constant.ace_numeric,.ace-monokai .ace_constant.ace_other {color: #AE81FF}.ace-monokai .ace_invalid {color: #F8F8F0;background-color: #F92672}.ace-monokai .ace_invalid.ace_deprecated {color: #F8F8F0;background-color: #AE81FF}.ace-monokai .ace_support.ace_constant,.ace-monokai .ace_support.ace_function {color: #66D9EF}.ace-monokai .ace_fold {background-color: #A6E22E;border-color: #F8F8F2}.ace-monokai .ace_storage.ace_type,.ace-monokai .ace_support.ace_class,.ace-monokai .ace_support.ace_type {font-style: italic;color: #66D9EF}.ace-monokai .ace_entity.ace_name.ace_function,.ace-monokai .ace_entity.ace_other,.ace-monokai .ace_entity.ace_other.ace_attribute-name,.ace-monokai .ace_variable {color: #A6E22E}.ace-monokai .ace_variable.ace_parameter {font-style: italic;color: #FD971F}.ace-monokai .ace_string {color: #E6DB74}.ace-monokai .ace_comment {color: #75715E}.ace-monokai .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ0FD0ZXBzd/wPAAjVAoxeSgNeAAAAAElFTkSuQmCC) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}) 5564 5565 /***/ }, 5566 /* 25 */ 5567 /***/ function(module, exports, __webpack_require__) { 5568 5569 var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(jQuery, _, Backbone) {/** 5570 * Bootstrap Modal wrapper for use with Backbone. 5571 * 5572 * Takes care of instantiation, manages multiple modals, 5573 * adds several options and removes the element from the DOM when closed 5574 * 5575 * @author Charles Davison <charlie@powmedia.co.uk> 5576 * 5577 * Events: 5578 * shown: Fired when the modal has finished animating in 5579 * hidden: Fired when the modal has finished animating out 5580 * cancel: The user dismissed the modal 5581 * ok: The user clicked OK 5582 */ 5583 (function($, _, Backbone) { 5584 5585 //Set custom template settings 5586 var _interpolateBackup = _.templateSettings; 5587 _.templateSettings = { 5588 interpolate: /\{\{(.+?)\}\}/g, 5589 evaluate: /<%([\s\S]+?)%>/g 5590 } 5591 5592 var template = _.template('\ 5593 <% if (title) { %>\ 5594 <div class="modal-header">\ 5595 <% if (allowCancel) { %>\ 5596 <a class="close">×</a>\ 5597 <% } %>\ 5598 <h3>{{title}}</h3>\ 5599 </div>\ 5600 <% } %>\ 5601 <div class="modal-body">{{content}}</div>\ 5602 <div class="modal-footer">\ 5603 <% if (allowCancel) { %>\ 5604 <% if (cancelText) { %>\ 5605 <a href="#" class="btn cancel">{{cancelText}}</a>\ 5606 <% } %>\ 5607 <% } %>\ 5608 <a href="#" class="btn ok btn-primary">{{okText}}</a>\ 5609 </div>\ 5610 '); 5611 5612 //Reset to users' template settings 5613 _.templateSettings = _interpolateBackup; 5614 5615 5616 var Modal = Backbone.View.extend({ 5617 5618 className: 'modal', 5619 5620 events: { 5621 'click .close': function(event) { 5622 event.preventDefault(); 5623 5624 this.trigger('cancel'); 5625 }, 5626 'click .cancel': function(event) { 5627 event.preventDefault(); 5628 5629 this.trigger('cancel'); 5630 }, 5631 'click .ok': function(event) { 5632 event.preventDefault(); 5633 5634 this.trigger('ok'); 5635 this.close(); 5636 } 5637 }, 5638 5639 /** 5640 * Creates an instance of a Bootstrap Modal 5641 * 5642 * @see http://twitter.github.com/bootstrap/javascript.html#modals 5643 * 5644 * @param {Object} options 5645 * @param {String|View} [options.content] Modal content. Default: none 5646 * @param {String} [options.title] Title. Default: none 5647 * @param {String} [options.okText] Text for the OK button. Default: 'OK' 5648 * @param {String} [options.cancelText] Text for the cancel button. Default: 'Cancel'. If passed a falsey value, the button will be removed 5649 * @param {Boolean} [options.allowCancel Whether the modal can be closed, other than by pressing OK. Default: true 5650 * @param {Boolean} [options.escape] Whether the 'esc' key can dismiss the modal. Default: true, but false if options.cancellable is true 5651 * @param {Boolean} [options.animate] Whether to animate in/out. Default: false 5652 * @param {Function} [options.template] Compiled underscore template to override the default one 5653 */ 5654 initialize: function(options) { 5655 this.options = _.extend({ 5656 title: null, 5657 okText: 'OK', 5658 cancelText: 'Cancel', 5659 allowCancel: true, 5660 escape: true, 5661 animate: false, 5662 template: template 5663 }, options); 5664 }, 5665 5666 /** 5667 * Creates the DOM element 5668 * 5669 * @api private 5670 */ 5671 render: function() { 5672 var $el = this.$el, 5673 options = this.options, 5674 content = options.content; 5675 5676 //Create the modal container 5677 $el.html(options.template(options)); 5678 5679 var $content = this.$content = $el.find('.modal-body') 5680 5681 //Insert the main content if it's a view 5682 if (content.$el) { 5683 $el.find('.modal-body').html(content.render().$el); 5684 } 5685 5686 if (options.animate) $el.addClass('fade'); 5687 5688 this.isRendered = true; 5689 5690 return this; 5691 }, 5692 5693 /** 5694 * Renders and shows the modal 5695 * 5696 * @param {Function} [cb] Optional callback that runs only when OK is pressed. 5697 */ 5698 open: function(cb) { 5699 if (!this.isRendered) this.render(); 5700 5701 var self = this, 5702 $el = this.$el; 5703 5704 //Create it 5705 $el.modal({ 5706 keyboard: this.options.allowCancel, 5707 backdrop: this.options.allowCancel ? true : 'static' 5708 }); 5709 5710 //Focus OK button 5711 $el.one('shown', function() { 5712 $el.find('.btn.ok').focus(); 5713 5714 self.trigger('shown'); 5715 }); 5716 5717 //Adjust the modal and backdrop z-index; for dealing with multiple modals 5718 var numModals = Modal.count, 5719 $backdrop = $('.modal-backdrop:eq('+numModals+')'), 5720 backdropIndex = $backdrop.css('z-index'), 5721 elIndex = $backdrop.css('z-index'); 5722 5723 $backdrop.css('z-index', backdropIndex + numModals); 5724 this.$el.css('z-index', elIndex + numModals); 5725 5726 if (this.options.allowCancel) { 5727 $backdrop.one('click', function() { 5728 self.trigger('cancel'); 5729 }); 5730 5731 $(document).one('keyup.dismiss.modal', function (e) { 5732 e.which == 27 && self.trigger('cancel'); 5733 }); 5734 } 5735 5736 this.on('cancel', function() { 5737 self.close(); 5738 }); 5739 5740 Modal.count++; 5741 5742 //Run callback on OK if provided 5743 if (cb) { 5744 self.on('ok', cb); 5745 } 5746 5747 return this; 5748 }, 5749 5750 /** 5751 * Closes the modal 5752 */ 5753 close: function() { 5754 var self = this, 5755 $el = this.$el; 5756 5757 //Check if the modal should stay open 5758 if (this._preventClose) { 5759 this._preventClose = false; 5760 return; 5761 } 5762 5763 $el.modal('hide'); 5764 5765 $el.one('hidden', function() { 5766 self.remove(); 5767 5768 self.trigger('hidden'); 5769 }); 5770 5771 Modal.count--; 5772 }, 5773 5774 /** 5775 * Stop the modal from closing. 5776 * Can be called from within a 'close' or 'ok' event listener. 5777 */ 5778 preventClose: function() { 5779 this._preventClose = true; 5780 } 5781 }, { 5782 //STATICS 5783 5784 //The number of modals on display 5785 count: 0 5786 }); 5787 5788 5789 //EXPORTS 5790 //CommonJS 5791 if ("function" == 'function' && typeof module !== 'undefined' && exports) { 5792 module.exports = Modal; 5793 } 5794 5795 //AMD / RequireJS 5796 if (true) { 5797 return !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { 5798 Backbone.BootstrapModal = Modal; 5799 }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) 5800 } 5801 5802 //Regular; add to Backbone.Bootstrap.Modal 5803 else { 5804 Backbone.BootstrapModal = Modal; 5805 } 5806 5807 })(jQuery, _, Backbone); 5808 5809 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(4), __webpack_require__(32))) 5810 5811 /***/ }, 5812 /* 26 */ 5813 /***/ function(module, exports, __webpack_require__) { 5814 5815 /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*! 5816 * The buffer module from node.js, for the browser. 5817 * 5818 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> 5819 * @license MIT 5820 */ 5821 /* eslint-disable no-proto */ 5822 5823 'use strict' 5824 5825 var base64 = __webpack_require__(57) 5826 var ieee754 = __webpack_require__(81) 5827 var isArray = __webpack_require__(82) 5828 5829 exports.Buffer = Buffer 5830 exports.SlowBuffer = SlowBuffer 5831 exports.INSPECT_MAX_BYTES = 50 5832 5833 /** 5834 * If `Buffer.TYPED_ARRAY_SUPPORT`: 5835 * === true Use Uint8Array implementation (fastest) 5836 * === false Use Object implementation (most compatible, even IE6) 5837 * 5838 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 5839 * Opera 11.6+, iOS 4.2+. 5840 * 5841 * Due to various browser bugs, sometimes the Object implementation will be used even 5842 * when the browser supports typed arrays. 5843 * 5844 * Note: 5845 * 5846 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, 5847 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. 5848 * 5849 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. 5850 * 5851 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of 5852 * incorrect length in some situations. 5853 5854 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they 5855 * get the Object implementation, which is slower but behaves correctly. 5856 */ 5857 Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined 5858 ? global.TYPED_ARRAY_SUPPORT 5859 : typedArraySupport() 5860 5861 /* 5862 * Export kMaxLength after typed array support is determined. 5863 */ 5864 exports.kMaxLength = kMaxLength() 5865 5866 function typedArraySupport () { 5867 try { 5868 var arr = new Uint8Array(1) 5869 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} 5870 return arr.foo() === 42 && // typed array instances can be augmented 5871 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` 5872 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` 5873 } catch (e) { 5874 return false 5875 } 5876 } 5877 5878 function kMaxLength () { 5879 return Buffer.TYPED_ARRAY_SUPPORT 5880 ? 0x7fffffff 5881 : 0x3fffffff 5882 } 5883 5884 function createBuffer (that, length) { 5885 if (kMaxLength() < length) { 5886 throw new RangeError('Invalid typed array length') 5887 } 5888 if (Buffer.TYPED_ARRAY_SUPPORT) { 5889 // Return an augmented `Uint8Array` instance, for best performance 5890 that = new Uint8Array(length) 5891 that.__proto__ = Buffer.prototype 5892 } else { 5893 // Fallback: Return an object instance of the Buffer class 5894 if (that === null) { 5895 that = new Buffer(length) 5896 } 5897 that.length = length 5898 } 5899 5900 return that 5901 } 5902 5903 /** 5904 * The Buffer constructor returns instances of `Uint8Array` that have their 5905 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of 5906 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods 5907 * and the `Uint8Array` methods. Square bracket notation works as expected -- it 5908 * returns a single octet. 5909 * 5910 * The `Uint8Array` prototype remains unmodified. 5911 */ 5912 5913 function Buffer (arg, encodingOrOffset, length) { 5914 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { 5915 return new Buffer(arg, encodingOrOffset, length) 5916 } 5917 5918 // Common case. 5919 if (typeof arg === 'number') { 5920 if (typeof encodingOrOffset === 'string') { 5921 throw new Error( 5922 'If encoding is specified then the first argument must be a string' 5923 ) 5924 } 5925 return allocUnsafe(this, arg) 5926 } 5927 return from(this, arg, encodingOrOffset, length) 5928 } 5929 5930 Buffer.poolSize = 8192 // not used by this implementation 5931 5932 // TODO: Legacy, not needed anymore. Remove in next major version. 5933 Buffer._augment = function (arr) { 5934 arr.__proto__ = Buffer.prototype 5935 return arr 5936 } 5937 5938 function from (that, value, encodingOrOffset, length) { 5939 if (typeof value === 'number') { 5940 throw new TypeError('"value" argument must not be a number') 5941 } 5942 5943 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { 5944 return fromArrayBuffer(that, value, encodingOrOffset, length) 5945 } 5946 5947 if (typeof value === 'string') { 5948 return fromString(that, value, encodingOrOffset) 5949 } 5950 5951 return fromObject(that, value) 5952 } 5953 5954 /** 5955 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError 5956 * if value is a number. 5957 * Buffer.from(str[, encoding]) 5958 * Buffer.from(array) 5959 * Buffer.from(buffer) 5960 * Buffer.from(arrayBuffer[, byteOffset[, length]]) 5961 **/ 5962 Buffer.from = function (value, encodingOrOffset, length) { 5963 return from(null, value, encodingOrOffset, length) 5964 } 5965 5966 if (Buffer.TYPED_ARRAY_SUPPORT) { 5967 Buffer.prototype.__proto__ = Uint8Array.prototype 5968 Buffer.__proto__ = Uint8Array 5969 if (typeof Symbol !== 'undefined' && Symbol.species && 5970 Buffer[Symbol.species] === Buffer) { 5971 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 5972 Object.defineProperty(Buffer, Symbol.species, { 5973 value: null, 5974 configurable: true 5975 }) 5976 } 5977 } 5978 5979 function assertSize (size) { 5980 if (typeof size !== 'number') { 5981 throw new TypeError('"size" argument must be a number') 5982 } else if (size < 0) { 5983 throw new RangeError('"size" argument must not be negative') 5984 } 5985 } 5986 5987 function alloc (that, size, fill, encoding) { 5988 assertSize(size) 5989 if (size <= 0) { 5990 return createBuffer(that, size) 5991 } 5992 if (fill !== undefined) { 5993 // Only pay attention to encoding if it's a string. This 5994 // prevents accidentally sending in a number that would 5995 // be interpretted as a start offset. 5996 return typeof encoding === 'string' 5997 ? createBuffer(that, size).fill(fill, encoding) 5998 : createBuffer(that, size).fill(fill) 5999 } 6000 return createBuffer(that, size) 6001 } 6002 6003 /** 6004 * Creates a new filled Buffer instance. 6005 * alloc(size[, fill[, encoding]]) 6006 **/ 6007 Buffer.alloc = function (size, fill, encoding) { 6008 return alloc(null, size, fill, encoding) 6009 } 6010 6011 function allocUnsafe (that, size) { 6012 assertSize(size) 6013 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) 6014 if (!Buffer.TYPED_ARRAY_SUPPORT) { 6015 for (var i = 0; i < size; ++i) { 6016 that[i] = 0 6017 } 6018 } 6019 return that 6020 } 6021 6022 /** 6023 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. 6024 * */ 6025 Buffer.allocUnsafe = function (size) { 6026 return allocUnsafe(null, size) 6027 } 6028 /** 6029 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. 6030 */ 6031 Buffer.allocUnsafeSlow = function (size) { 6032 return allocUnsafe(null, size) 6033 } 6034 6035 function fromString (that, string, encoding) { 6036 if (typeof encoding !== 'string' || encoding === '') { 6037 encoding = 'utf8' 6038 } 6039 6040 if (!Buffer.isEncoding(encoding)) { 6041 throw new TypeError('"encoding" must be a valid string encoding') 6042 } 6043 6044 var length = byteLength(string, encoding) | 0 6045 that = createBuffer(that, length) 6046 6047 var actual = that.write(string, encoding) 6048 6049 if (actual !== length) { 6050 // Writing a hex string, for example, that contains invalid characters will 6051 // cause everything after the first invalid character to be ignored. (e.g. 6052 // 'abxxcd' will be treated as 'ab') 6053 that = that.slice(0, actual) 6054 } 6055 6056 return that 6057 } 6058 6059 function fromArrayLike (that, array) { 6060 var length = array.length < 0 ? 0 : checked(array.length) | 0 6061 that = createBuffer(that, length) 6062 for (var i = 0; i < length; i += 1) { 6063 that[i] = array[i] & 255 6064 } 6065 return that 6066 } 6067 6068 function fromArrayBuffer (that, array, byteOffset, length) { 6069 array.byteLength // this throws if `array` is not a valid ArrayBuffer 6070 6071 if (byteOffset < 0 || array.byteLength < byteOffset) { 6072 throw new RangeError('\'offset\' is out of bounds') 6073 } 6074 6075 if (array.byteLength < byteOffset + (length || 0)) { 6076 throw new RangeError('\'length\' is out of bounds') 6077 } 6078 6079 if (byteOffset === undefined && length === undefined) { 6080 array = new Uint8Array(array) 6081 } else if (length === undefined) { 6082 array = new Uint8Array(array, byteOffset) 6083 } else { 6084 array = new Uint8Array(array, byteOffset, length) 6085 } 6086 6087 if (Buffer.TYPED_ARRAY_SUPPORT) { 6088 // Return an augmented `Uint8Array` instance, for best performance 6089 that = array 6090 that.__proto__ = Buffer.prototype 6091 } else { 6092 // Fallback: Return an object instance of the Buffer class 6093 that = fromArrayLike(that, array) 6094 } 6095 return that 6096 } 6097 6098 function fromObject (that, obj) { 6099 if (Buffer.isBuffer(obj)) { 6100 var len = checked(obj.length) | 0 6101 that = createBuffer(that, len) 6102 6103 if (that.length === 0) { 6104 return that 6105 } 6106 6107 obj.copy(that, 0, 0, len) 6108 return that 6109 } 6110 6111 if (obj) { 6112 if ((typeof ArrayBuffer !== 'undefined' && 6113 obj.buffer instanceof ArrayBuffer) || 'length' in obj) { 6114 if (typeof obj.length !== 'number' || isnan(obj.length)) { 6115 return createBuffer(that, 0) 6116 } 6117 return fromArrayLike(that, obj) 6118 } 6119 6120 if (obj.type === 'Buffer' && isArray(obj.data)) { 6121 return fromArrayLike(that, obj.data) 6122 } 6123 } 6124 6125 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') 6126 } 6127 6128 function checked (length) { 6129 // Note: cannot use `length < kMaxLength()` here because that fails when 6130 // length is NaN (which is otherwise coerced to zero.) 6131 if (length >= kMaxLength()) { 6132 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 6133 'size: 0x' + kMaxLength().toString(16) + ' bytes') 6134 } 6135 return length | 0 6136 } 6137 6138 function SlowBuffer (length) { 6139 if (+length != length) { // eslint-disable-line eqeqeq 6140 length = 0 6141 } 6142 return Buffer.alloc(+length) 6143 } 6144 6145 Buffer.isBuffer = function isBuffer (b) { 6146 return !!(b != null && b._isBuffer) 6147 } 6148 6149 Buffer.compare = function compare (a, b) { 6150 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { 6151 throw new TypeError('Arguments must be Buffers') 6152 } 6153 6154 if (a === b) return 0 6155 6156 var x = a.length 6157 var y = b.length 6158 6159 for (var i = 0, len = Math.min(x, y); i < len; ++i) { 6160 if (a[i] !== b[i]) { 6161 x = a[i] 6162 y = b[i] 6163 break 6164 } 6165 } 6166 6167 if (x < y) return -1 6168 if (y < x) return 1 6169 return 0 6170 } 6171 6172 Buffer.isEncoding = function isEncoding (encoding) { 6173 switch (String(encoding).toLowerCase()) { 6174 case 'hex': 6175 case 'utf8': 6176 case 'utf-8': 6177 case 'ascii': 6178 case 'latin1': 6179 case 'binary': 6180 case 'base64': 6181 case 'ucs2': 6182 case 'ucs-2': 6183 case 'utf16le': 6184 case 'utf-16le': 6185 return true 6186 default: 6187 return false 6188 } 6189 } 6190 6191 Buffer.concat = function concat (list, length) { 6192 if (!isArray(list)) { 6193 throw new TypeError('"list" argument must be an Array of Buffers') 6194 } 6195 6196 if (list.length === 0) { 6197 return Buffer.alloc(0) 6198 } 6199 6200 var i 6201 if (length === undefined) { 6202 length = 0 6203 for (i = 0; i < list.length; ++i) { 6204 length += list[i].length 6205 } 6206 } 6207 6208 var buffer = Buffer.allocUnsafe(length) 6209 var pos = 0 6210 for (i = 0; i < list.length; ++i) { 6211 var buf = list[i] 6212 if (!Buffer.isBuffer(buf)) { 6213 throw new TypeError('"list" argument must be an Array of Buffers') 6214 } 6215 buf.copy(buffer, pos) 6216 pos += buf.length 6217 } 6218 return buffer 6219 } 6220 6221 function byteLength (string, encoding) { 6222 if (Buffer.isBuffer(string)) { 6223 return string.length 6224 } 6225 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && 6226 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { 6227 return string.byteLength 6228 } 6229 if (typeof string !== 'string') { 6230 string = '' + string 6231 } 6232 6233 var len = string.length 6234 if (len === 0) return 0 6235 6236 // Use a for loop to avoid recursion 6237 var loweredCase = false 6238 for (;;) { 6239 switch (encoding) { 6240 case 'ascii': 6241 case 'latin1': 6242 case 'binary': 6243 return len 6244 case 'utf8': 6245 case 'utf-8': 6246 case undefined: 6247 return utf8ToBytes(string).length 6248 case 'ucs2': 6249 case 'ucs-2': 6250 case 'utf16le': 6251 case 'utf-16le': 6252 return len * 2 6253 case 'hex': 6254 return len >>> 1 6255 case 'base64': 6256 return base64ToBytes(string).length 6257 default: 6258 if (loweredCase) return utf8ToBytes(string).length // assume utf8 6259 encoding = ('' + encoding).toLowerCase() 6260 loweredCase = true 6261 } 6262 } 6263 } 6264 Buffer.byteLength = byteLength 6265 6266 function slowToString (encoding, start, end) { 6267 var loweredCase = false 6268 6269 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only 6270 // property of a typed array. 6271 6272 // This behaves neither like String nor Uint8Array in that we set start/end 6273 // to their upper/lower bounds if the value passed is out of range. 6274 // undefined is handled specially as per ECMA-262 6th Edition, 6275 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. 6276 if (start === undefined || start < 0) { 6277 start = 0 6278 } 6279 // Return early if start > this.length. Done here to prevent potential uint32 6280 // coercion fail below. 6281 if (start > this.length) { 6282 return '' 6283 } 6284 6285 if (end === undefined || end > this.length) { 6286 end = this.length 6287 } 6288 6289 if (end <= 0) { 6290 return '' 6291 } 6292 6293 // Force coersion to uint32. This will also coerce falsey/NaN values to 0. 6294 end >>>= 0 6295 start >>>= 0 6296 6297 if (end <= start) { 6298 return '' 6299 } 6300 6301 if (!encoding) encoding = 'utf8' 6302 6303 while (true) { 6304 switch (encoding) { 6305 case 'hex': 6306 return hexSlice(this, start, end) 6307 6308 case 'utf8': 6309 case 'utf-8': 6310 return utf8Slice(this, start, end) 6311 6312 case 'ascii': 6313 return asciiSlice(this, start, end) 6314 6315 case 'latin1': 6316 case 'binary': 6317 return latin1Slice(this, start, end) 6318 6319 case 'base64': 6320 return base64Slice(this, start, end) 6321 6322 case 'ucs2': 6323 case 'ucs-2': 6324 case 'utf16le': 6325 case 'utf-16le': 6326 return utf16leSlice(this, start, end) 6327 6328 default: 6329 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 6330 encoding = (encoding + '').toLowerCase() 6331 loweredCase = true 6332 } 6333 } 6334 } 6335 6336 // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect 6337 // Buffer instances. 6338 Buffer.prototype._isBuffer = true 6339 6340 function swap (b, n, m) { 6341 var i = b[n] 6342 b[n] = b[m] 6343 b[m] = i 6344 } 6345 6346 Buffer.prototype.swap16 = function swap16 () { 6347 var len = this.length 6348 if (len % 2 !== 0) { 6349 throw new RangeError('Buffer size must be a multiple of 16-bits') 6350 } 6351 for (var i = 0; i < len; i += 2) { 6352 swap(this, i, i + 1) 6353 } 6354 return this 6355 } 6356 6357 Buffer.prototype.swap32 = function swap32 () { 6358 var len = this.length 6359 if (len % 4 !== 0) { 6360 throw new RangeError('Buffer size must be a multiple of 32-bits') 6361 } 6362 for (var i = 0; i < len; i += 4) { 6363 swap(this, i, i + 3) 6364 swap(this, i + 1, i + 2) 6365 } 6366 return this 6367 } 6368 6369 Buffer.prototype.swap64 = function swap64 () { 6370 var len = this.length 6371 if (len % 8 !== 0) { 6372 throw new RangeError('Buffer size must be a multiple of 64-bits') 6373 } 6374 for (var i = 0; i < len; i += 8) { 6375 swap(this, i, i + 7) 6376 swap(this, i + 1, i + 6) 6377 swap(this, i + 2, i + 5) 6378 swap(this, i + 3, i + 4) 6379 } 6380 return this 6381 } 6382 6383 Buffer.prototype.toString = function toString () { 6384 var length = this.length | 0 6385 if (length === 0) return '' 6386 if (arguments.length === 0) return utf8Slice(this, 0, length) 6387 return slowToString.apply(this, arguments) 6388 } 6389 6390 Buffer.prototype.equals = function equals (b) { 6391 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') 6392 if (this === b) return true 6393 return Buffer.compare(this, b) === 0 6394 } 6395 6396 Buffer.prototype.inspect = function inspect () { 6397 var str = '' 6398 var max = exports.INSPECT_MAX_BYTES 6399 if (this.length > 0) { 6400 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') 6401 if (this.length > max) str += ' ... ' 6402 } 6403 return '<Buffer ' + str + '>' 6404 } 6405 6406 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { 6407 if (!Buffer.isBuffer(target)) { 6408 throw new TypeError('Argument must be a Buffer') 6409 } 6410 6411 if (start === undefined) { 6412 start = 0 6413 } 6414 if (end === undefined) { 6415 end = target ? target.length : 0 6416 } 6417 if (thisStart === undefined) { 6418 thisStart = 0 6419 } 6420 if (thisEnd === undefined) { 6421 thisEnd = this.length 6422 } 6423 6424 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { 6425 throw new RangeError('out of range index') 6426 } 6427 6428 if (thisStart >= thisEnd && start >= end) { 6429 return 0 6430 } 6431 if (thisStart >= thisEnd) { 6432 return -1 6433 } 6434 if (start >= end) { 6435 return 1 6436 } 6437 6438 start >>>= 0 6439 end >>>= 0 6440 thisStart >>>= 0 6441 thisEnd >>>= 0 6442 6443 if (this === target) return 0 6444 6445 var x = thisEnd - thisStart 6446 var y = end - start 6447 var len = Math.min(x, y) 6448 6449 var thisCopy = this.slice(thisStart, thisEnd) 6450 var targetCopy = target.slice(start, end) 6451 6452 for (var i = 0; i < len; ++i) { 6453 if (thisCopy[i] !== targetCopy[i]) { 6454 x = thisCopy[i] 6455 y = targetCopy[i] 6456 break 6457 } 6458 } 6459 6460 if (x < y) return -1 6461 if (y < x) return 1 6462 return 0 6463 } 6464 6465 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, 6466 // OR the last index of `val` in `buffer` at offset <= `byteOffset`. 6467 // 6468 // Arguments: 6469 // - buffer - a Buffer to search 6470 // - val - a string, Buffer, or number 6471 // - byteOffset - an index into `buffer`; will be clamped to an int32 6472 // - encoding - an optional encoding, relevant is val is a string 6473 // - dir - true for indexOf, false for lastIndexOf 6474 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { 6475 // Empty buffer means no match 6476 if (buffer.length === 0) return -1 6477 6478 // Normalize byteOffset 6479 if (typeof byteOffset === 'string') { 6480 encoding = byteOffset 6481 byteOffset = 0 6482 } else if (byteOffset > 0x7fffffff) { 6483 byteOffset = 0x7fffffff 6484 } else if (byteOffset < -0x80000000) { 6485 byteOffset = -0x80000000 6486 } 6487 byteOffset = +byteOffset // Coerce to Number. 6488 if (isNaN(byteOffset)) { 6489 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer 6490 byteOffset = dir ? 0 : (buffer.length - 1) 6491 } 6492 6493 // Normalize byteOffset: negative offsets start from the end of the buffer 6494 if (byteOffset < 0) byteOffset = buffer.length + byteOffset 6495 if (byteOffset >= buffer.length) { 6496 if (dir) return -1 6497 else byteOffset = buffer.length - 1 6498 } else if (byteOffset < 0) { 6499 if (dir) byteOffset = 0 6500 else return -1 6501 } 6502 6503 // Normalize val 6504 if (typeof val === 'string') { 6505 val = Buffer.from(val, encoding) 6506 } 6507 6508 // Finally, search either indexOf (if dir is true) or lastIndexOf 6509 if (Buffer.isBuffer(val)) { 6510 // Special case: looking for empty string/buffer always fails 6511 if (val.length === 0) { 6512 return -1 6513 } 6514 return arrayIndexOf(buffer, val, byteOffset, encoding, dir) 6515 } else if (typeof val === 'number') { 6516 val = val & 0xFF // Search for a byte value [0-255] 6517 if (Buffer.TYPED_ARRAY_SUPPORT && 6518 typeof Uint8Array.prototype.indexOf === 'function') { 6519 if (dir) { 6520 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) 6521 } else { 6522 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) 6523 } 6524 } 6525 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) 6526 } 6527 6528 throw new TypeError('val must be string, number or Buffer') 6529 } 6530 6531 function arrayIndexOf (arr, val, byteOffset, encoding, dir) { 6532 var indexSize = 1 6533 var arrLength = arr.length 6534 var valLength = val.length 6535 6536 if (encoding !== undefined) { 6537 encoding = String(encoding).toLowerCase() 6538 if (encoding === 'ucs2' || encoding === 'ucs-2' || 6539 encoding === 'utf16le' || encoding === 'utf-16le') { 6540 if (arr.length < 2 || val.length < 2) { 6541 return -1 6542 } 6543 indexSize = 2 6544 arrLength /= 2 6545 valLength /= 2 6546 byteOffset /= 2 6547 } 6548 } 6549 6550 function read (buf, i) { 6551 if (indexSize === 1) { 6552 return buf[i] 6553 } else { 6554 return buf.readUInt16BE(i * indexSize) 6555 } 6556 } 6557 6558 var i 6559 if (dir) { 6560 var foundIndex = -1 6561 for (i = byteOffset; i < arrLength; i++) { 6562 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { 6563 if (foundIndex === -1) foundIndex = i 6564 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize 6565 } else { 6566 if (foundIndex !== -1) i -= i - foundIndex 6567 foundIndex = -1 6568 } 6569 } 6570 } else { 6571 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength 6572 for (i = byteOffset; i >= 0; i--) { 6573 var found = true 6574 for (var j = 0; j < valLength; j++) { 6575 if (read(arr, i + j) !== read(val, j)) { 6576 found = false 6577 break 6578 } 6579 } 6580 if (found) return i 6581 } 6582 } 6583 6584 return -1 6585 } 6586 6587 Buffer.prototype.includes = function includes (val, byteOffset, encoding) { 6588 return this.indexOf(val, byteOffset, encoding) !== -1 6589 } 6590 6591 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { 6592 return bidirectionalIndexOf(this, val, byteOffset, encoding, true) 6593 } 6594 6595 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { 6596 return bidirectionalIndexOf(this, val, byteOffset, encoding, false) 6597 } 6598 6599 function hexWrite (buf, string, offset, length) { 6600 offset = Number(offset) || 0 6601 var remaining = buf.length - offset 6602 if (!length) { 6603 length = remaining 6604 } else { 6605 length = Number(length) 6606 if (length > remaining) { 6607 length = remaining 6608 } 6609 } 6610 6611 // must be an even number of digits 6612 var strLen = string.length 6613 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') 6614 6615 if (length > strLen / 2) { 6616 length = strLen / 2 6617 } 6618 for (var i = 0; i < length; ++i) { 6619 var parsed = parseInt(string.substr(i * 2, 2), 16) 6620 if (isNaN(parsed)) return i 6621 buf[offset + i] = parsed 6622 } 6623 return i 6624 } 6625 6626 function utf8Write (buf, string, offset, length) { 6627 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) 6628 } 6629 6630 function asciiWrite (buf, string, offset, length) { 6631 return blitBuffer(asciiToBytes(string), buf, offset, length) 6632 } 6633 6634 function latin1Write (buf, string, offset, length) { 6635 return asciiWrite(buf, string, offset, length) 6636 } 6637 6638 function base64Write (buf, string, offset, length) { 6639 return blitBuffer(base64ToBytes(string), buf, offset, length) 6640 } 6641 6642 function ucs2Write (buf, string, offset, length) { 6643 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) 6644 } 6645 6646 Buffer.prototype.write = function write (string, offset, length, encoding) { 6647 // Buffer#write(string) 6648 if (offset === undefined) { 6649 encoding = 'utf8' 6650 length = this.length 6651 offset = 0 6652 // Buffer#write(string, encoding) 6653 } else if (length === undefined && typeof offset === 'string') { 6654 encoding = offset 6655 length = this.length 6656 offset = 0 6657 // Buffer#write(string, offset[, length][, encoding]) 6658 } else if (isFinite(offset)) { 6659 offset = offset | 0 6660 if (isFinite(length)) { 6661 length = length | 0 6662 if (encoding === undefined) encoding = 'utf8' 6663 } else { 6664 encoding = length 6665 length = undefined 6666 } 6667 // legacy write(string, encoding, offset, length) - remove in v0.13 6668 } else { 6669 throw new Error( 6670 'Buffer.write(string, encoding, offset[, length]) is no longer supported' 6671 ) 6672 } 6673 6674 var remaining = this.length - offset 6675 if (length === undefined || length > remaining) length = remaining 6676 6677 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { 6678 throw new RangeError('Attempt to write outside buffer bounds') 6679 } 6680 6681 if (!encoding) encoding = 'utf8' 6682 6683 var loweredCase = false 6684 for (;;) { 6685 switch (encoding) { 6686 case 'hex': 6687 return hexWrite(this, string, offset, length) 6688 6689 case 'utf8': 6690 case 'utf-8': 6691 return utf8Write(this, string, offset, length) 6692 6693 case 'ascii': 6694 return asciiWrite(this, string, offset, length) 6695 6696 case 'latin1': 6697 case 'binary': 6698 return latin1Write(this, string, offset, length) 6699 6700 case 'base64': 6701 // Warning: maxLength not taken into account in base64Write 6702 return base64Write(this, string, offset, length) 6703 6704 case 'ucs2': 6705 case 'ucs-2': 6706 case 'utf16le': 6707 case 'utf-16le': 6708 return ucs2Write(this, string, offset, length) 6709 6710 default: 6711 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 6712 encoding = ('' + encoding).toLowerCase() 6713 loweredCase = true 6714 } 6715 } 6716 } 6717 6718 Buffer.prototype.toJSON = function toJSON () { 6719 return { 6720 type: 'Buffer', 6721 data: Array.prototype.slice.call(this._arr || this, 0) 6722 } 6723 } 6724 6725 function base64Slice (buf, start, end) { 6726 if (start === 0 && end === buf.length) { 6727 return base64.fromByteArray(buf) 6728 } else { 6729 return base64.fromByteArray(buf.slice(start, end)) 6730 } 6731 } 6732 6733 function utf8Slice (buf, start, end) { 6734 end = Math.min(buf.length, end) 6735 var res = [] 6736 6737 var i = start 6738 while (i < end) { 6739 var firstByte = buf[i] 6740 var codePoint = null 6741 var bytesPerSequence = (firstByte > 0xEF) ? 4 6742 : (firstByte > 0xDF) ? 3 6743 : (firstByte > 0xBF) ? 2 6744 : 1 6745 6746 if (i + bytesPerSequence <= end) { 6747 var secondByte, thirdByte, fourthByte, tempCodePoint 6748 6749 switch (bytesPerSequence) { 6750 case 1: 6751 if (firstByte < 0x80) { 6752 codePoint = firstByte 6753 } 6754 break 6755 case 2: 6756 secondByte = buf[i + 1] 6757 if ((secondByte & 0xC0) === 0x80) { 6758 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) 6759 if (tempCodePoint > 0x7F) { 6760 codePoint = tempCodePoint 6761 } 6762 } 6763 break 6764 case 3: 6765 secondByte = buf[i + 1] 6766 thirdByte = buf[i + 2] 6767 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 6768 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) 6769 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 6770 codePoint = tempCodePoint 6771 } 6772 } 6773 break 6774 case 4: 6775 secondByte = buf[i + 1] 6776 thirdByte = buf[i + 2] 6777 fourthByte = buf[i + 3] 6778 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 6779 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) 6780 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 6781 codePoint = tempCodePoint 6782 } 6783 } 6784 } 6785 } 6786 6787 if (codePoint === null) { 6788 // we did not generate a valid codePoint so insert a 6789 // replacement char (U+FFFD) and advance only 1 byte 6790 codePoint = 0xFFFD 6791 bytesPerSequence = 1 6792 } else if (codePoint > 0xFFFF) { 6793 // encode to utf16 (surrogate pair dance) 6794 codePoint -= 0x10000 6795 res.push(codePoint >>> 10 & 0x3FF | 0xD800) 6796 codePoint = 0xDC00 | codePoint & 0x3FF 6797 } 6798 6799 res.push(codePoint) 6800 i += bytesPerSequence 6801 } 6802 6803 return decodeCodePointsArray(res) 6804 } 6805 6806 // Based on http://stackoverflow.com/a/22747272/680742, the browser with 6807 // the lowest limit is Chrome, with 0x10000 args. 6808 // We go 1 magnitude less, for safety 6809 var MAX_ARGUMENTS_LENGTH = 0x1000 6810 6811 function decodeCodePointsArray (codePoints) { 6812 var len = codePoints.length 6813 if (len <= MAX_ARGUMENTS_LENGTH) { 6814 return String.fromCharCode.apply(String, codePoints) // avoid extra slice() 6815 } 6816 6817 // Decode in chunks to avoid "call stack size exceeded". 6818 var res = '' 6819 var i = 0 6820 while (i < len) { 6821 res += String.fromCharCode.apply( 6822 String, 6823 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) 6824 ) 6825 } 6826 return res 6827 } 6828 6829 function asciiSlice (buf, start, end) { 6830 var ret = '' 6831 end = Math.min(buf.length, end) 6832 6833 for (var i = start; i < end; ++i) { 6834 ret += String.fromCharCode(buf[i] & 0x7F) 6835 } 6836 return ret 6837 } 6838 6839 function latin1Slice (buf, start, end) { 6840 var ret = '' 6841 end = Math.min(buf.length, end) 6842 6843 for (var i = start; i < end; ++i) { 6844 ret += String.fromCharCode(buf[i]) 6845 } 6846 return ret 6847 } 6848 6849 function hexSlice (buf, start, end) { 6850 var len = buf.length 6851 6852 if (!start || start < 0) start = 0 6853 if (!end || end < 0 || end > len) end = len 6854 6855 var out = '' 6856 for (var i = start; i < end; ++i) { 6857 out += toHex(buf[i]) 6858 } 6859 return out 6860 } 6861 6862 function utf16leSlice (buf, start, end) { 6863 var bytes = buf.slice(start, end) 6864 var res = '' 6865 for (var i = 0; i < bytes.length; i += 2) { 6866 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) 6867 } 6868 return res 6869 } 6870 6871 Buffer.prototype.slice = function slice (start, end) { 6872 var len = this.length 6873 start = ~~start 6874 end = end === undefined ? len : ~~end 6875 6876 if (start < 0) { 6877 start += len 6878 if (start < 0) start = 0 6879 } else if (start > len) { 6880 start = len 6881 } 6882 6883 if (end < 0) { 6884 end += len 6885 if (end < 0) end = 0 6886 } else if (end > len) { 6887 end = len 6888 } 6889 6890 if (end < start) end = start 6891 6892 var newBuf 6893 if (Buffer.TYPED_ARRAY_SUPPORT) { 6894 newBuf = this.subarray(start, end) 6895 newBuf.__proto__ = Buffer.prototype 6896 } else { 6897 var sliceLen = end - start 6898 newBuf = new Buffer(sliceLen, undefined) 6899 for (var i = 0; i < sliceLen; ++i) { 6900 newBuf[i] = this[i + start] 6901 } 6902 } 6903 6904 return newBuf 6905 } 6906 6907 /* 6908 * Need to make sure that buffer isn't trying to write out of bounds. 6909 */ 6910 function checkOffset (offset, ext, length) { 6911 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') 6912 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') 6913 } 6914 6915 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { 6916 offset = offset | 0 6917 byteLength = byteLength | 0 6918 if (!noAssert) checkOffset(offset, byteLength, this.length) 6919 6920 var val = this[offset] 6921 var mul = 1 6922 var i = 0 6923 while (++i < byteLength && (mul *= 0x100)) { 6924 val += this[offset + i] * mul 6925 } 6926 6927 return val 6928 } 6929 6930 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { 6931 offset = offset | 0 6932 byteLength = byteLength | 0 6933 if (!noAssert) { 6934 checkOffset(offset, byteLength, this.length) 6935 } 6936 6937 var val = this[offset + --byteLength] 6938 var mul = 1 6939 while (byteLength > 0 && (mul *= 0x100)) { 6940 val += this[offset + --byteLength] * mul 6941 } 6942 6943 return val 6944 } 6945 6946 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { 6947 if (!noAssert) checkOffset(offset, 1, this.length) 6948 return this[offset] 6949 } 6950 6951 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { 6952 if (!noAssert) checkOffset(offset, 2, this.length) 6953 return this[offset] | (this[offset + 1] << 8) 6954 } 6955 6956 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { 6957 if (!noAssert) checkOffset(offset, 2, this.length) 6958 return (this[offset] << 8) | this[offset + 1] 6959 } 6960 6961 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { 6962 if (!noAssert) checkOffset(offset, 4, this.length) 6963 6964 return ((this[offset]) | 6965 (this[offset + 1] << 8) | 6966 (this[offset + 2] << 16)) + 6967 (this[offset + 3] * 0x1000000) 6968 } 6969 6970 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { 6971 if (!noAssert) checkOffset(offset, 4, this.length) 6972 6973 return (this[offset] * 0x1000000) + 6974 ((this[offset + 1] << 16) | 6975 (this[offset + 2] << 8) | 6976 this[offset + 3]) 6977 } 6978 6979 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { 6980 offset = offset | 0 6981 byteLength = byteLength | 0 6982 if (!noAssert) checkOffset(offset, byteLength, this.length) 6983 6984 var val = this[offset] 6985 var mul = 1 6986 var i = 0 6987 while (++i < byteLength && (mul *= 0x100)) { 6988 val += this[offset + i] * mul 6989 } 6990 mul *= 0x80 6991 6992 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 6993 6994 return val 6995 } 6996 6997 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { 6998 offset = offset | 0 6999 byteLength = byteLength | 0 7000 if (!noAssert) checkOffset(offset, byteLength, this.length) 7001 7002 var i = byteLength 7003 var mul = 1 7004 var val = this[offset + --i] 7005 while (i > 0 && (mul *= 0x100)) { 7006 val += this[offset + --i] * mul 7007 } 7008 mul *= 0x80 7009 7010 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 7011 7012 return val 7013 } 7014 7015 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { 7016 if (!noAssert) checkOffset(offset, 1, this.length) 7017 if (!(this[offset] & 0x80)) return (this[offset]) 7018 return ((0xff - this[offset] + 1) * -1) 7019 } 7020 7021 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { 7022 if (!noAssert) checkOffset(offset, 2, this.length) 7023 var val = this[offset] | (this[offset + 1] << 8) 7024 return (val & 0x8000) ? val | 0xFFFF0000 : val 7025 } 7026 7027 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { 7028 if (!noAssert) checkOffset(offset, 2, this.length) 7029 var val = this[offset + 1] | (this[offset] << 8) 7030 return (val & 0x8000) ? val | 0xFFFF0000 : val 7031 } 7032 7033 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { 7034 if (!noAssert) checkOffset(offset, 4, this.length) 7035 7036 return (this[offset]) | 7037 (this[offset + 1] << 8) | 7038 (this[offset + 2] << 16) | 7039 (this[offset + 3] << 24) 7040 } 7041 7042 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { 7043 if (!noAssert) checkOffset(offset, 4, this.length) 7044 7045 return (this[offset] << 24) | 7046 (this[offset + 1] << 16) | 7047 (this[offset + 2] << 8) | 7048 (this[offset + 3]) 7049 } 7050 7051 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { 7052 if (!noAssert) checkOffset(offset, 4, this.length) 7053 return ieee754.read(this, offset, true, 23, 4) 7054 } 7055 7056 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { 7057 if (!noAssert) checkOffset(offset, 4, this.length) 7058 return ieee754.read(this, offset, false, 23, 4) 7059 } 7060 7061 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { 7062 if (!noAssert) checkOffset(offset, 8, this.length) 7063 return ieee754.read(this, offset, true, 52, 8) 7064 } 7065 7066 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { 7067 if (!noAssert) checkOffset(offset, 8, this.length) 7068 return ieee754.read(this, offset, false, 52, 8) 7069 } 7070 7071 function checkInt (buf, value, offset, ext, max, min) { 7072 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') 7073 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') 7074 if (offset + ext > buf.length) throw new RangeError('Index out of range') 7075 } 7076 7077 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { 7078 value = +value 7079 offset = offset | 0 7080 byteLength = byteLength | 0 7081 if (!noAssert) { 7082 var maxBytes = Math.pow(2, 8 * byteLength) - 1 7083 checkInt(this, value, offset, byteLength, maxBytes, 0) 7084 } 7085 7086 var mul = 1 7087 var i = 0 7088 this[offset] = value & 0xFF 7089 while (++i < byteLength && (mul *= 0x100)) { 7090 this[offset + i] = (value / mul) & 0xFF 7091 } 7092 7093 return offset + byteLength 7094 } 7095 7096 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { 7097 value = +value 7098 offset = offset | 0 7099 byteLength = byteLength | 0 7100 if (!noAssert) { 7101 var maxBytes = Math.pow(2, 8 * byteLength) - 1 7102 checkInt(this, value, offset, byteLength, maxBytes, 0) 7103 } 7104 7105 var i = byteLength - 1 7106 var mul = 1 7107 this[offset + i] = value & 0xFF 7108 while (--i >= 0 && (mul *= 0x100)) { 7109 this[offset + i] = (value / mul) & 0xFF 7110 } 7111 7112 return offset + byteLength 7113 } 7114 7115 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { 7116 value = +value 7117 offset = offset | 0 7118 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) 7119 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 7120 this[offset] = (value & 0xff) 7121 return offset + 1 7122 } 7123 7124 function objectWriteUInt16 (buf, value, offset, littleEndian) { 7125 if (value < 0) value = 0xffff + value + 1 7126 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { 7127 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> 7128 (littleEndian ? i : 1 - i) * 8 7129 } 7130 } 7131 7132 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { 7133 value = +value 7134 offset = offset | 0 7135 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 7136 if (Buffer.TYPED_ARRAY_SUPPORT) { 7137 this[offset] = (value & 0xff) 7138 this[offset + 1] = (value >>> 8) 7139 } else { 7140 objectWriteUInt16(this, value, offset, true) 7141 } 7142 return offset + 2 7143 } 7144 7145 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { 7146 value = +value 7147 offset = offset | 0 7148 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 7149 if (Buffer.TYPED_ARRAY_SUPPORT) { 7150 this[offset] = (value >>> 8) 7151 this[offset + 1] = (value & 0xff) 7152 } else { 7153 objectWriteUInt16(this, value, offset, false) 7154 } 7155 return offset + 2 7156 } 7157 7158 function objectWriteUInt32 (buf, value, offset, littleEndian) { 7159 if (value < 0) value = 0xffffffff + value + 1 7160 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { 7161 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff 7162 } 7163 } 7164 7165 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { 7166 value = +value 7167 offset = offset | 0 7168 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 7169 if (Buffer.TYPED_ARRAY_SUPPORT) { 7170 this[offset + 3] = (value >>> 24) 7171 this[offset + 2] = (value >>> 16) 7172 this[offset + 1] = (value >>> 8) 7173 this[offset] = (value & 0xff) 7174 } else { 7175 objectWriteUInt32(this, value, offset, true) 7176 } 7177 return offset + 4 7178 } 7179 7180 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { 7181 value = +value 7182 offset = offset | 0 7183 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 7184 if (Buffer.TYPED_ARRAY_SUPPORT) { 7185 this[offset] = (value >>> 24) 7186 this[offset + 1] = (value >>> 16) 7187 this[offset + 2] = (value >>> 8) 7188 this[offset + 3] = (value & 0xff) 7189 } else { 7190 objectWriteUInt32(this, value, offset, false) 7191 } 7192 return offset + 4 7193 } 7194 7195 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { 7196 value = +value 7197 offset = offset | 0 7198 if (!noAssert) { 7199 var limit = Math.pow(2, 8 * byteLength - 1) 7200 7201 checkInt(this, value, offset, byteLength, limit - 1, -limit) 7202 } 7203 7204 var i = 0 7205 var mul = 1 7206 var sub = 0 7207 this[offset] = value & 0xFF 7208 while (++i < byteLength && (mul *= 0x100)) { 7209 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { 7210 sub = 1 7211 } 7212 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 7213 } 7214 7215 return offset + byteLength 7216 } 7217 7218 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { 7219 value = +value 7220 offset = offset | 0 7221 if (!noAssert) { 7222 var limit = Math.pow(2, 8 * byteLength - 1) 7223 7224 checkInt(this, value, offset, byteLength, limit - 1, -limit) 7225 } 7226 7227 var i = byteLength - 1 7228 var mul = 1 7229 var sub = 0 7230 this[offset + i] = value & 0xFF 7231 while (--i >= 0 && (mul *= 0x100)) { 7232 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { 7233 sub = 1 7234 } 7235 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 7236 } 7237 7238 return offset + byteLength 7239 } 7240 7241 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { 7242 value = +value 7243 offset = offset | 0 7244 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) 7245 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 7246 if (value < 0) value = 0xff + value + 1 7247 this[offset] = (value & 0xff) 7248 return offset + 1 7249 } 7250 7251 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { 7252 value = +value 7253 offset = offset | 0 7254 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 7255 if (Buffer.TYPED_ARRAY_SUPPORT) { 7256 this[offset] = (value & 0xff) 7257 this[offset + 1] = (value >>> 8) 7258 } else { 7259 objectWriteUInt16(this, value, offset, true) 7260 } 7261 return offset + 2 7262 } 7263 7264 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { 7265 value = +value 7266 offset = offset | 0 7267 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 7268 if (Buffer.TYPED_ARRAY_SUPPORT) { 7269 this[offset] = (value >>> 8) 7270 this[offset + 1] = (value & 0xff) 7271 } else { 7272 objectWriteUInt16(this, value, offset, false) 7273 } 7274 return offset + 2 7275 } 7276 7277 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { 7278 value = +value 7279 offset = offset | 0 7280 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 7281 if (Buffer.TYPED_ARRAY_SUPPORT) { 7282 this[offset] = (value & 0xff) 7283 this[offset + 1] = (value >>> 8) 7284 this[offset + 2] = (value >>> 16) 7285 this[offset + 3] = (value >>> 24) 7286 } else { 7287 objectWriteUInt32(this, value, offset, true) 7288 } 7289 return offset + 4 7290 } 7291 7292 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { 7293 value = +value 7294 offset = offset | 0 7295 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 7296 if (value < 0) value = 0xffffffff + value + 1 7297 if (Buffer.TYPED_ARRAY_SUPPORT) { 7298 this[offset] = (value >>> 24) 7299 this[offset + 1] = (value >>> 16) 7300 this[offset + 2] = (value >>> 8) 7301 this[offset + 3] = (value & 0xff) 7302 } else { 7303 objectWriteUInt32(this, value, offset, false) 7304 } 7305 return offset + 4 7306 } 7307 7308 function checkIEEE754 (buf, value, offset, ext, max, min) { 7309 if (offset + ext > buf.length) throw new RangeError('Index out of range') 7310 if (offset < 0) throw new RangeError('Index out of range') 7311 } 7312 7313 function writeFloat (buf, value, offset, littleEndian, noAssert) { 7314 if (!noAssert) { 7315 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) 7316 } 7317 ieee754.write(buf, value, offset, littleEndian, 23, 4) 7318 return offset + 4 7319 } 7320 7321 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { 7322 return writeFloat(this, value, offset, true, noAssert) 7323 } 7324 7325 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { 7326 return writeFloat(this, value, offset, false, noAssert) 7327 } 7328 7329 function writeDouble (buf, value, offset, littleEndian, noAssert) { 7330 if (!noAssert) { 7331 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) 7332 } 7333 ieee754.write(buf, value, offset, littleEndian, 52, 8) 7334 return offset + 8 7335 } 7336 7337 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { 7338 return writeDouble(this, value, offset, true, noAssert) 7339 } 7340 7341 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { 7342 return writeDouble(this, value, offset, false, noAssert) 7343 } 7344 7345 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 7346 Buffer.prototype.copy = function copy (target, targetStart, start, end) { 7347 if (!start) start = 0 7348 if (!end && end !== 0) end = this.length 7349 if (targetStart >= target.length) targetStart = target.length 7350 if (!targetStart) targetStart = 0 7351 if (end > 0 && end < start) end = start 7352 7353 // Copy 0 bytes; we're done 7354 if (end === start) return 0 7355 if (target.length === 0 || this.length === 0) return 0 7356 7357 // Fatal error conditions 7358 if (targetStart < 0) { 7359 throw new RangeError('targetStart out of bounds') 7360 } 7361 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') 7362 if (end < 0) throw new RangeError('sourceEnd out of bounds') 7363 7364 // Are we oob? 7365 if (end > this.length) end = this.length 7366 if (target.length - targetStart < end - start) { 7367 end = target.length - targetStart + start 7368 } 7369 7370 var len = end - start 7371 var i 7372 7373 if (this === target && start < targetStart && targetStart < end) { 7374 // descending copy from end 7375 for (i = len - 1; i >= 0; --i) { 7376 target[i + targetStart] = this[i + start] 7377 } 7378 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { 7379 // ascending copy from start 7380 for (i = 0; i < len; ++i) { 7381 target[i + targetStart] = this[i + start] 7382 } 7383 } else { 7384 Uint8Array.prototype.set.call( 7385 target, 7386 this.subarray(start, start + len), 7387 targetStart 7388 ) 7389 } 7390 7391 return len 7392 } 7393 7394 // Usage: 7395 // buffer.fill(number[, offset[, end]]) 7396 // buffer.fill(buffer[, offset[, end]]) 7397 // buffer.fill(string[, offset[, end]][, encoding]) 7398 Buffer.prototype.fill = function fill (val, start, end, encoding) { 7399 // Handle string cases: 7400 if (typeof val === 'string') { 7401 if (typeof start === 'string') { 7402 encoding = start 7403 start = 0 7404 end = this.length 7405 } else if (typeof end === 'string') { 7406 encoding = end 7407 end = this.length 7408 } 7409 if (val.length === 1) { 7410 var code = val.charCodeAt(0) 7411 if (code < 256) { 7412 val = code 7413 } 7414 } 7415 if (encoding !== undefined && typeof encoding !== 'string') { 7416 throw new TypeError('encoding must be a string') 7417 } 7418 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { 7419 throw new TypeError('Unknown encoding: ' + encoding) 7420 } 7421 } else if (typeof val === 'number') { 7422 val = val & 255 7423 } 7424 7425 // Invalid ranges are not set to a default, so can range check early. 7426 if (start < 0 || this.length < start || this.length < end) { 7427 throw new RangeError('Out of range index') 7428 } 7429 7430 if (end <= start) { 7431 return this 7432 } 7433 7434 start = start >>> 0 7435 end = end === undefined ? this.length : end >>> 0 7436 7437 if (!val) val = 0 7438 7439 var i 7440 if (typeof val === 'number') { 7441 for (i = start; i < end; ++i) { 7442 this[i] = val 7443 } 7444 } else { 7445 var bytes = Buffer.isBuffer(val) 7446 ? val 7447 : utf8ToBytes(new Buffer(val, encoding).toString()) 7448 var len = bytes.length 7449 for (i = 0; i < end - start; ++i) { 7450 this[i + start] = bytes[i % len] 7451 } 7452 } 7453 7454 return this 7455 } 7456 7457 // HELPER FUNCTIONS 7458 // ================ 7459 7460 var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g 7461 7462 function base64clean (str) { 7463 // Node strips out invalid characters like \n and \t from the string, base64-js does not 7464 str = stringtrim(str).replace(INVALID_BASE64_RE, '') 7465 // Node converts strings with length < 2 to '' 7466 if (str.length < 2) return '' 7467 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 7468 while (str.length % 4 !== 0) { 7469 str = str + '=' 7470 } 7471 return str 7472 } 7473 7474 function stringtrim (str) { 7475 if (str.trim) return str.trim() 7476 return str.replace(/^\s+|\s+$/g, '') 7477 } 7478 7479 function toHex (n) { 7480 if (n < 16) return '0' + n.toString(16) 7481 return n.toString(16) 7482 } 7483 7484 function utf8ToBytes (string, units) { 7485 units = units || Infinity 7486 var codePoint 7487 var length = string.length 7488 var leadSurrogate = null 7489 var bytes = [] 7490 7491 for (var i = 0; i < length; ++i) { 7492 codePoint = string.charCodeAt(i) 7493 7494 // is surrogate component 7495 if (codePoint > 0xD7FF && codePoint < 0xE000) { 7496 // last char was a lead 7497 if (!leadSurrogate) { 7498 // no lead yet 7499 if (codePoint > 0xDBFF) { 7500 // unexpected trail 7501 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 7502 continue 7503 } else if (i + 1 === length) { 7504 // unpaired lead 7505 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 7506 continue 7507 } 7508 7509 // valid lead 7510 leadSurrogate = codePoint 7511 7512 continue 7513 } 7514 7515 // 2 leads in a row 7516 if (codePoint < 0xDC00) { 7517 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 7518 leadSurrogate = codePoint 7519 continue 7520 } 7521 7522 // valid surrogate pair 7523 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 7524 } else if (leadSurrogate) { 7525 // valid bmp char, but last char was a lead 7526 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 7527 } 7528 7529 leadSurrogate = null 7530 7531 // encode utf8 7532 if (codePoint < 0x80) { 7533 if ((units -= 1) < 0) break 7534 bytes.push(codePoint) 7535 } else if (codePoint < 0x800) { 7536 if ((units -= 2) < 0) break 7537 bytes.push( 7538 codePoint >> 0x6 | 0xC0, 7539 codePoint & 0x3F | 0x80 7540 ) 7541 } else if (codePoint < 0x10000) { 7542 if ((units -= 3) < 0) break 7543 bytes.push( 7544 codePoint >> 0xC | 0xE0, 7545 codePoint >> 0x6 & 0x3F | 0x80, 7546 codePoint & 0x3F | 0x80 7547 ) 7548 } else if (codePoint < 0x110000) { 7549 if ((units -= 4) < 0) break 7550 bytes.push( 7551 codePoint >> 0x12 | 0xF0, 7552 codePoint >> 0xC & 0x3F | 0x80, 7553 codePoint >> 0x6 & 0x3F | 0x80, 7554 codePoint & 0x3F | 0x80 7555 ) 7556 } else { 7557 throw new Error('Invalid code point') 7558 } 7559 } 7560 7561 return bytes 7562 } 7563 7564 function asciiToBytes (str) { 7565 var byteArray = [] 7566 for (var i = 0; i < str.length; ++i) { 7567 // Node's code seems to be doing this and not & 0x7F.. 7568 byteArray.push(str.charCodeAt(i) & 0xFF) 7569 } 7570 return byteArray 7571 } 7572 7573 function utf16leToBytes (str, units) { 7574 var c, hi, lo 7575 var byteArray = [] 7576 for (var i = 0; i < str.length; ++i) { 7577 if ((units -= 2) < 0) break 7578 7579 c = str.charCodeAt(i) 7580 hi = c >> 8 7581 lo = c % 256 7582 byteArray.push(lo) 7583 byteArray.push(hi) 7584 } 7585 7586 return byteArray 7587 } 7588 7589 function base64ToBytes (str) { 7590 return base64.toByteArray(base64clean(str)) 7591 } 7592 7593 function blitBuffer (src, dst, offset, length) { 7594 for (var i = 0; i < length; ++i) { 7595 if ((i + offset >= dst.length) || (i >= src.length)) break 7596 dst[i + offset] = src[i] 7597 } 7598 return i 7599 } 7600 7601 function isnan (val) { 7602 return val !== val // eslint-disable-line no-self-compare 7603 } 7604 7605 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(26).Buffer, (function() { return this; }()))) 7606 7607 /***/ }, 7608 /* 27 */ 7609 /***/ function(module, exports, __webpack_require__) { 7610 7611 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) { 7612 if ( true ) { 7613 7614 // AMD. Register as an anonymous module. 7615 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(1), __webpack_require__(6) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 7616 } else { 7617 7618 // Browser globals 7619 factory( jQuery ); 7620 } 7621 } ( function( $ ) { 7622 7623 // This file is deprecated 7624 return $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 7625 } ) ); 7626 7627 7628 /***/ }, 7629 /* 28 */ 7630 /***/ function(module, exports, __webpack_require__) { 7631 7632 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 7633 * jQuery UI Mouse 1.12.1 7634 * http://jqueryui.com 7635 * 7636 * Copyright jQuery Foundation and other contributors 7637 * Released under the MIT license. 7638 * http://jquery.org/license 7639 */ 7640 7641 //>>label: Mouse 7642 //>>group: Widgets 7643 //>>description: Abstracts mouse-based interactions to assist in creating certain widgets. 7644 //>>docs: http://api.jqueryui.com/mouse/ 7645 7646 ( function( factory ) { 7647 if ( true ) { 7648 7649 // AMD. Register as an anonymous module. 7650 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ 7651 __webpack_require__(1), 7652 __webpack_require__(27), 7653 __webpack_require__(6), 7654 __webpack_require__(18) 7655 ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 7656 } else { 7657 7658 // Browser globals 7659 factory( jQuery ); 7660 } 7661 }( function( $ ) { 7662 7663 var mouseHandled = false; 7664 $( document ).on( "mouseup", function() { 7665 mouseHandled = false; 7666 } ); 7667 7668 return $.widget( "ui.mouse", { 7669 version: "1.12.1", 7670 options: { 7671 cancel: "input, textarea, button, select, option", 7672 distance: 1, 7673 delay: 0 7674 }, 7675 _mouseInit: function() { 7676 var that = this; 7677 7678 this.element 7679 .on( "mousedown." + this.widgetName, function( event ) { 7680 return that._mouseDown( event ); 7681 } ) 7682 .on( "click." + this.widgetName, function( event ) { 7683 if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) { 7684 $.removeData( event.target, that.widgetName + ".preventClickEvent" ); 7685 event.stopImmediatePropagation(); 7686 return false; 7687 } 7688 } ); 7689 7690 this.started = false; 7691 }, 7692 7693 // TODO: make sure destroying one instance of mouse doesn't mess with 7694 // other instances of mouse 7695 _mouseDestroy: function() { 7696 this.element.off( "." + this.widgetName ); 7697 if ( this._mouseMoveDelegate ) { 7698 this.document 7699 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 7700 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 7701 } 7702 }, 7703 7704 _mouseDown: function( event ) { 7705 7706 // don't let more than one widget handle mouseStart 7707 if ( mouseHandled ) { 7708 return; 7709 } 7710 7711 this._mouseMoved = false; 7712 7713 // We may have missed mouseup (out of window) 7714 ( this._mouseStarted && this._mouseUp( event ) ); 7715 7716 this._mouseDownEvent = event; 7717 7718 var that = this, 7719 btnIsLeft = ( event.which === 1 ), 7720 7721 // event.target.nodeName works around a bug in IE 8 with 7722 // disabled inputs (#7620) 7723 elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? 7724 $( event.target ).closest( this.options.cancel ).length : false ); 7725 if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { 7726 return true; 7727 } 7728 7729 this.mouseDelayMet = !this.options.delay; 7730 if ( !this.mouseDelayMet ) { 7731 this._mouseDelayTimer = setTimeout( function() { 7732 that.mouseDelayMet = true; 7733 }, this.options.delay ); 7734 } 7735 7736 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 7737 this._mouseStarted = ( this._mouseStart( event ) !== false ); 7738 if ( !this._mouseStarted ) { 7739 event.preventDefault(); 7740 return true; 7741 } 7742 } 7743 7744 // Click event may never have fired (Gecko & Opera) 7745 if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) { 7746 $.removeData( event.target, this.widgetName + ".preventClickEvent" ); 7747 } 7748 7749 // These delegates are required to keep context 7750 this._mouseMoveDelegate = function( event ) { 7751 return that._mouseMove( event ); 7752 }; 7753 this._mouseUpDelegate = function( event ) { 7754 return that._mouseUp( event ); 7755 }; 7756 7757 this.document 7758 .on( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 7759 .on( "mouseup." + this.widgetName, this._mouseUpDelegate ); 7760 7761 event.preventDefault(); 7762 7763 mouseHandled = true; 7764 return true; 7765 }, 7766 7767 _mouseMove: function( event ) { 7768 7769 // Only check for mouseups outside the document if you've moved inside the document 7770 // at least once. This prevents the firing of mouseup in the case of IE<9, which will 7771 // fire a mousemove event if content is placed under the cursor. See #7778 7772 // Support: IE <9 7773 if ( this._mouseMoved ) { 7774 7775 // IE mouseup check - mouseup happened when mouse was out of window 7776 if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && 7777 !event.button ) { 7778 return this._mouseUp( event ); 7779 7780 // Iframe mouseup check - mouseup occurred in another document 7781 } else if ( !event.which ) { 7782 7783 // Support: Safari <=8 - 9 7784 // Safari sets which to 0 if you press any of the following keys 7785 // during a drag (#14461) 7786 if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || 7787 event.originalEvent.metaKey || event.originalEvent.shiftKey ) { 7788 this.ignoreMissingWhich = true; 7789 } else if ( !this.ignoreMissingWhich ) { 7790 return this._mouseUp( event ); 7791 } 7792 } 7793 } 7794 7795 if ( event.which || event.button ) { 7796 this._mouseMoved = true; 7797 } 7798 7799 if ( this._mouseStarted ) { 7800 this._mouseDrag( event ); 7801 return event.preventDefault(); 7802 } 7803 7804 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 7805 this._mouseStarted = 7806 ( this._mouseStart( this._mouseDownEvent, event ) !== false ); 7807 ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) ); 7808 } 7809 7810 return !this._mouseStarted; 7811 }, 7812 7813 _mouseUp: function( event ) { 7814 this.document 7815 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 7816 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 7817 7818 if ( this._mouseStarted ) { 7819 this._mouseStarted = false; 7820 7821 if ( event.target === this._mouseDownEvent.target ) { 7822 $.data( event.target, this.widgetName + ".preventClickEvent", true ); 7823 } 7824 7825 this._mouseStop( event ); 7826 } 7827 7828 if ( this._mouseDelayTimer ) { 7829 clearTimeout( this._mouseDelayTimer ); 7830 delete this._mouseDelayTimer; 7831 } 7832 7833 this.ignoreMissingWhich = false; 7834 mouseHandled = false; 7835 event.preventDefault(); 7836 }, 7837 7838 _mouseDistanceMet: function( event ) { 7839 return ( Math.max( 7840 Math.abs( this._mouseDownEvent.pageX - event.pageX ), 7841 Math.abs( this._mouseDownEvent.pageY - event.pageY ) 7842 ) >= this.options.distance 7843 ); 7844 }, 7845 7846 _mouseDelayMet: function( /* event */ ) { 7847 return this.mouseDelayMet; 7848 }, 7849 7850 // These are placeholder methods, to be overriden by extending plugin 7851 _mouseStart: function( /* event */ ) {}, 7852 _mouseDrag: function( /* event */ ) {}, 7853 _mouseStop: function( /* event */ ) {}, 7854 _mouseCapture: function( /* event */ ) { return true; } 7855 } ); 7856 7857 } ) ); 7858 7859 7860 /***/ }, 7861 /* 29 */ 7862 /***/ function(module, exports, __webpack_require__) { 7863 7864 // Standard YAML's Core schema. 7865 // http://www.yaml.org/spec/1.2/spec.html#id2804923 7866 // 7867 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. 7868 // So, Core schema has no distinctions from JSON schema is JS-YAML. 7869 7870 7871 'use strict'; 7872 7873 7874 var Schema = __webpack_require__(8); 7875 7876 7877 module.exports = new Schema({ 7878 include: [ 7879 __webpack_require__(30) 7880 ] 7881 }); 7882 7883 7884 /***/ }, 7885 /* 30 */ 7886 /***/ function(module, exports, __webpack_require__) { 7887 7888 // Standard YAML's JSON schema. 7889 // http://www.yaml.org/spec/1.2/spec.html#id2803231 7890 // 7891 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. 7892 // So, this schema is not such strict as defined in the YAML specification. 7893 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. 7894 7895 7896 'use strict'; 7897 7898 7899 var Schema = __webpack_require__(8); 7900 7901 7902 module.exports = new Schema({ 7903 include: [ 7904 __webpack_require__(19) 7905 ], 7906 implicit: [ 7907 __webpack_require__(101), 7908 __webpack_require__(93), 7909 __webpack_require__(95), 7910 __webpack_require__(94) 7911 ] 7912 }); 7913 7914 7915 /***/ }, 7916 /* 31 */ 7917 /***/ function(module, exports) { 7918 7919 module.exports = function() { throw new Error("define cannot be used indirect"); }; 7920 7921 7922 /***/ }, 7923 /* 32 */ 7924 /***/ function(module, exports, __webpack_require__) { 7925 7926 module.exports = __webpack_require__(56); 7927 7928 /***/ }, 7929 /* 33 */ 7930 /***/ function(module, exports, __webpack_require__) { 7931 7932 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 7933 7934 __webpack_require__(14); 7935 7936 __webpack_require__(13); 7937 7938 __webpack_require__(121); 7939 7940 __webpack_require__(75); 7941 7942 __webpack_require__(76); 7943 7944 __webpack_require__(79); 7945 7946 __webpack_require__(80); 7947 7948 var _backbone = __webpack_require__(2); 7949 7950 var _appView = __webpack_require__(39); 7951 7952 var _appView2 = _interopRequireDefault(_appView); 7953 7954 var _schemaView = __webpack_require__(52); 7955 7956 var _schemaView2 = _interopRequireDefault(_schemaView); 7957 7958 var _router = __webpack_require__(38); 7959 7960 var _router2 = _interopRequireDefault(_router); 7961 7962 var _configModel = __webpack_require__(34); 7963 7964 var _configModel2 = _interopRequireDefault(_configModel); 7965 7966 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7967 7968 /* global $, document */ 7969 // Import bootstraps. 7970 const config = new _configModel2.default({ url: 'config.json' }); 7971 7972 // Import JS. 7973 7974 7975 // Import css. 7976 7977 7978 config.fetch().then(() => { 7979 const rootView = new _appView2.default({ 7980 router: new _router2.default({ title: document.title }), 7981 config, 7982 viewClass: { 7983 schema: { 7984 table: _schemaView2.default 7985 } } 7986 }); 7987 7988 $('body').append(rootView.render().el); 7989 _backbone.history.start(); 7990 }, () => { 7991 $('body').append('Failed to load config.json'); 7992 }); 7993 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 7994 7995 /***/ }, 7996 /* 34 */ 7997 /***/ function(module, exports, __webpack_require__) { 7998 7999 'use strict'; 8000 8001 Object.defineProperty(exports, "__esModule", { 8002 value: true 8003 }); 8004 8005 var _backbone = __webpack_require__(2); 8006 8007 /** 8008 * Class contains logic of config in application. 8009 * @class ConfigModel 8010 * @extends Model 8011 */ 8012 class ConfigModel extends _backbone.Model { 8013 8014 /** 8015 * Constructs the object. 8016 * @constructor 8017 * @extends Model.constructor 8018 * @param options 8019 */ 8020 constructor(options) { 8021 super(options); 8022 8023 this.url = options.url; 8024 } 8025 8026 /** 8027 * Fetches data from server. 8028 * @extends Collection.fetch 8029 * @param {Object} [options] 8030 * @returns {Promise} 8031 */ 8032 fetch(options) { 8033 return new Promise((resolve, reject) => { 8034 super.fetch(Object.assign({ 8035 success: (...params) => { 8036 resolve(params); 8037 }, 8038 error: (...params) => { 8039 reject(params); 8040 } 8041 }, options)); 8042 }); 8043 } 8044 8045 /** 8046 * Parses data. 8047 * @override Model.parse 8048 * @param {Object} resp 8049 * @returns {Object} 8050 */ 8051 parse(resp) { 8052 if (resp.authUrl.indexOf('__HOST__') !== -1) { 8053 resp.authUrl = resp.authUrl.replace('__HOST__', location.hostname); 8054 } 8055 8056 if (resp.gohan.url.indexOf('__HOST__') !== -1) { 8057 resp.gohan.url = resp.gohan.url.replace('__HOST__', location.hostname); 8058 } 8059 return resp; 8060 } 8061 } 8062 exports.default = ConfigModel; /* global location */ 8063 8064 /***/ }, 8065 /* 35 */ 8066 /***/ function(module, exports, __webpack_require__) { 8067 8068 'use strict'; 8069 8070 Object.defineProperty(exports, "__esModule", { 8071 value: true 8072 }); 8073 8074 var _backbone = __webpack_require__(2); 8075 8076 var _schemaModel = __webpack_require__(36); 8077 8078 var _schemaModel2 = _interopRequireDefault(_schemaModel); 8079 8080 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8081 8082 /** 8083 * Class contains logic of router in application. 8084 * @class AppRouter 8085 * @extends Router 8086 */ 8087 class SchemaCollection extends _backbone.Collection { 8088 8089 /** 8090 * Constructs the object. 8091 * @constructor 8092 * @override Collection.constructor 8093 * @param options 8094 */ 8095 constructor(options) { 8096 super(options); 8097 8098 this.model = _schemaModel2.default; 8099 8100 this.baseUrl = options.baseUrl; 8101 this.url = options.url; 8102 this.userModel = options.userModel; 8103 this.additionalForms = options.additionalForms; 8104 this.addingRelationDialog = options.addingRelationDialog; 8105 this.pageLimit = options.pageLimit; 8106 } 8107 8108 /** 8109 * Parses data. 8110 * @override Collection.parse 8111 * @param {Object} resp 8112 * @returns {Object} 8113 */ 8114 parse(resp) { 8115 return resp.schemas; 8116 } 8117 8118 /** 8119 * Unsets auth data. 8120 */ 8121 unsetAuthData() { 8122 this.userModel.unsetAuthData(); 8123 } 8124 8125 /** 8126 * Fetches data from server. 8127 * @extends Collection.fetch 8128 * @param {Object} [options] 8129 * @returns {Promise} 8130 */ 8131 fetch(options) { 8132 return new Promise((resolve, reject) => { 8133 super.fetch(Object.assign({ 8134 success: (...params) => { 8135 resolve(params); 8136 }, 8137 error: (...params) => { 8138 reject(params); 8139 } 8140 }, options)); 8141 }); 8142 } 8143 8144 /** 8145 * Syncs model data. 8146 * @extends Collection.sync 8147 * @param {string} method 8148 * @param {Object} collection 8149 * @param {Object} options 8150 */ 8151 sync(method, collection, options = {}) { 8152 options.headers = { 8153 'X-Auth-Token': this.userModel.authToken(), 8154 'Content-Type': 'application/json' 8155 }; 8156 super.sync(method, collection, options); 8157 } 8158 } 8159 exports.default = SchemaCollection; 8160 8161 /***/ }, 8162 /* 36 */ 8163 /***/ function(module, exports, __webpack_require__) { 8164 8165 'use strict'; 8166 8167 Object.defineProperty(exports, "__esModule", { 8168 value: true 8169 }); 8170 8171 __webpack_require__(120); 8172 8173 var _jsYaml = __webpack_require__(10); 8174 8175 var _jsYaml2 = _interopRequireDefault(_jsYaml); 8176 8177 var _backbone = __webpack_require__(2); 8178 8179 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8180 8181 /** 8182 * Class contains logic of schema model in application. 8183 * @class SchemaModel 8184 * @extends Model 8185 */ 8186 class SchemaModel extends _backbone.Model { 8187 collections() { 8188 return []; 8189 } 8190 8191 /** 8192 * Returns API endpoint. 8193 * @returns {string} 8194 */ 8195 apiEndpoint() { 8196 return this.apiEndpointBase() + this.get('url'); 8197 } 8198 8199 /** 8200 * Returns base API endpoint. 8201 * @returns {string} 8202 */ 8203 apiEndpointBase() { 8204 return this.collection.baseUrl; 8205 } 8206 8207 /** 8208 * Returns detail path. 8209 * @returns {string} 8210 */ 8211 detailPath(id) { 8212 return this.get('prefix') + '/' + id; 8213 } 8214 8215 /** 8216 * Returns full url. 8217 * @returns {string} 8218 */ 8219 url() { 8220 if (!this.hasParent()) { 8221 return this.get('url'); 8222 } 8223 8224 const parentSchema = this.parent(); 8225 8226 return parentSchema.url() + '/:' + parentSchema.get('singular') + '/' + this.get('plural'); 8227 } 8228 8229 /** 8230 * Returns schema parent. 8231 * @returns {Model} 8232 */ 8233 parent() { 8234 return this.collection.get(this.get('parent')); 8235 } 8236 8237 /** 8238 * Returns parent property. 8239 * @returns {string} 8240 */ 8241 parentProperty() { 8242 return this.get('parent') + '_id'; 8243 } 8244 8245 /** 8246 * Returns true if schema has parent otherwise false. 8247 * @returns {boolean} 8248 */ 8249 hasParent() { 8250 return this.get('parent') !== undefined && this.get('parent') !== ''; 8251 } 8252 8253 /** 8254 * Returns new model class. 8255 * @param baseUrl 8256 * @returns {any} 8257 */ 8258 makeModel(baseUrl = this.apiEndpoint()) { 8259 const self = this; 8260 const userModel = this.collection.userModel; 8261 8262 return class DataModel extends _backbone.Model { 8263 8264 /** 8265 * Constructs the object. 8266 * @constructor 8267 * @extends Model.constructor 8268 * @param {Object} options 8269 */ 8270 constructor(options) { 8271 super(options); 8272 this.schema = self; 8273 this.baseUrl = baseUrl; 8274 this.url = this.baseUrl; 8275 this.longPolling = false; 8276 this.timeOutId = -1; 8277 this.intervalSeconds = 10; 8278 } 8279 8280 /** 8281 * Returns state of isNew, true when model is new otherwise false. 8282 * @returns {boolean} 8283 */ 8284 isNew() { 8285 return Boolean(this.get('isNew')); 8286 } 8287 8288 /** 8289 * Destroys object. 8290 * @extend Model.destroy 8291 * @param {Object} options 8292 * @returns {Promise} 8293 */ 8294 destroy(options = {}) { 8295 return new Promise((resolve, reject) => { 8296 super.destroy(Object.assign({ 8297 success: (...params) => { 8298 resolve(params); 8299 }, 8300 error: (...params) => { 8301 reject(params); 8302 } 8303 }, options)); 8304 }); 8305 } 8306 8307 /** 8308 * Saves model data. 8309 * @extend Model.save 8310 * @param {Model} model 8311 * @param {Object} options 8312 * @returns {Promise} 8313 */ 8314 save(model, options = {}) { 8315 return new Promise((resolve, reject) => { 8316 super.save(model, Object.assign({ 8317 success: (...params) => { 8318 resolve(params); 8319 }, 8320 error: (...params) => { 8321 reject(params); 8322 } 8323 }, options)); 8324 }); 8325 } 8326 8327 /** 8328 * Fetches data from server 8329 * @extend Model.fetch 8330 * @param {Object} options 8331 * @returns {Promise} 8332 */ 8333 fetch(options = {}) { 8334 return new Promise((resolve, reject) => { 8335 super.fetch(Object.assign({ 8336 success: (...params) => { 8337 resolve(params); 8338 }, 8339 error: (...params) => { 8340 reject(params); 8341 } 8342 }, options)); 8343 }); 8344 } 8345 8346 /** 8347 * Parses data from the server. 8348 * @override Model.parse 8349 * @param {Object} resp 8350 * @returns {Object} 8351 */ 8352 parse(resp) { 8353 if (resp.id === undefined) { 8354 return resp[self.get('singular')]; 8355 } 8356 return resp; 8357 } 8358 8359 /** 8360 * Syncs model data. 8361 * @extends Model.sync 8362 * @param method 8363 * @param model 8364 * @param options 8365 */ 8366 sync(method, model, options = {}) { 8367 if (!this.isNew()) { 8368 this.url = this.baseUrl + '/' + this.id; 8369 } 8370 8371 if (method === 'patch') { 8372 method = 'update'; 8373 } 8374 8375 options.headers = { 8376 'X-Auth-Token': userModel.authToken(), 8377 'Content-Type': 'application/json' 8378 }; 8379 this.unset('isNew'); 8380 8381 const data = {}; 8382 8383 const cloneOfModel = model.clone(); 8384 const modelJSON = {}; 8385 8386 if (method.toLowerCase() === 'read') { 8387 super.sync(method, model, options); 8388 return; 8389 } 8390 8391 this.schema.filterByAction(method).then(schemaForAction => { 8392 for (let key in schemaForAction.properties) { 8393 modelJSON[key] = cloneOfModel.get(key); 8394 } 8395 8396 data[this.schema.get('singular')] = modelJSON; 8397 options.data = JSON.stringify(data); 8398 super.sync(method, model, options); 8399 }); 8400 } 8401 8402 /** 8403 * Starts long polling. 8404 * @param {number} intervalSeconds 8405 */ 8406 startLongPolling(intervalSeconds) { 8407 this.longPolling = true; 8408 8409 if (intervalSeconds) { 8410 this.intervalSeconds = intervalSeconds; 8411 } 8412 this.executeLongPolling(); 8413 } 8414 8415 /** 8416 * Stops long polling. 8417 */ 8418 stopLongPolling() { 8419 this.longPolling = false; 8420 clearTimeout(this.timeOutId); 8421 this.timeOutId = -1; 8422 } 8423 8424 /** 8425 * Fetches data from server. 8426 */ 8427 executeLongPolling() { 8428 const fetchSuccess = () => { 8429 if (this.longPolling) { 8430 this.timeOutId = setTimeout(this.executeLongPolling.bind(this), 1000 * this.intervalSeconds); 8431 } 8432 }; 8433 8434 this.fetch().then(fetchSuccess); 8435 } 8436 8437 /** 8438 * Returns parent id of model. 8439 * @returns {string | undefined} 8440 */ 8441 parentId() { 8442 if (this.schema.hasParent()) { 8443 return this.get(this.schema.parentProperty()); 8444 } 8445 return undefined; 8446 } 8447 8448 /** 8449 * Returns path fragment. 8450 * @returns {string} 8451 */ 8452 fragment() { 8453 return this.schema.detailPath(this.id).substr(1); 8454 } 8455 8456 /** 8457 * Returns ancestors. 8458 * @param {function} callback 8459 * @param {Array} ancestors 8460 */ 8461 getAncestors(callback, ancestors = []) { 8462 if (!this.schema.hasParent()) { 8463 callback(ancestors); 8464 return; 8465 } 8466 8467 if (this.parentId() === undefined) { 8468 return; 8469 } 8470 8471 const parentModelClass = this.schema.parent().makeModel(); 8472 const parentModel = new parentModelClass({ id: this.parentId() }); 8473 8474 parentModel.fetch().then(() => { 8475 ancestors.push(parentModel); 8476 parentModel.getAncestors(callback, ancestors); 8477 }); 8478 } 8479 }; 8480 } 8481 8482 /** 8483 * Returns new collection of models. 8484 * @param {string} url 8485 * @param {object} options 8486 * @param {*} options.pageLimit 8487 * @param {string} options.sortKey 8488 * @param {string} options.sortOrder 8489 * @returns {CollectionClass} 8490 */ 8491 makeCollection(url = this.apiEndpoint(), options = { pageLimit: this.collection.pageLimit }) { 8492 if (typeof options !== 'object') { 8493 console.warn('2nd argument of makeCollection should be options object.'); 8494 options = Object.assign({}, { pageLimit: options }); 8495 } 8496 8497 if (this.collections[url]) { 8498 return this.collections[url]; 8499 } 8500 8501 const model = this.makeModel(url); 8502 const userModel = this.collection.userModel; 8503 const additionalForms = this.collection.additionalForms; 8504 const addingRelationDialog = this.collection.addingRelationDialog; 8505 const self = this; 8506 8507 if (additionalForms !== undefined && additionalForms[this.id] === undefined) { 8508 this.additionalForm = additionalForms[self.id]; 8509 } else { 8510 this.additionalForm = ['*']; 8511 } 8512 8513 if (addingRelationDialog) { 8514 this.addingRelationDialog = addingRelationDialog; 8515 } 8516 8517 class CollectionClass extends _backbone.Collection { 8518 8519 /** 8520 * Constructs the object. 8521 * @constructor 8522 * @extends Collection.constructor 8523 * @param {Object} options 8524 */ 8525 constructor(options = {}) { 8526 super(options); 8527 8528 this._pageLimit = ~~options.pageLimit; 8529 this.total = 0; 8530 this.offset = 0; 8531 this.sortKey = options.sortKey || 'id'; 8532 this.sortOrder = options.sortOrder || 'asc'; 8533 this.baseUrl = url; 8534 this.url = url; 8535 this.model = model; 8536 this.schema = self; 8537 this.filters = {}; 8538 this.longPolling = false; 8539 this.timeOutId = -1; 8540 this.intervalSeconds = 10; 8541 } 8542 8543 get pageLimit() { 8544 return this._pageLimit; 8545 } 8546 8547 set pageLimit(pageLimit) { 8548 this._pageLimit = pageLimit; 8549 } 8550 8551 /** 8552 * Updates collection url to filter, sort and paging. 8553 */ 8554 updateUrl() { 8555 if (this.sortKey !== undefined && !Object.keys(this.schema.get('schema').properties).includes(this.sortKey)) { 8556 console.warn('sortKey is invalid, as sortKey will be set "id" key.'); 8557 this.sortKey = 'id'; 8558 } 8559 8560 if (this.sortOrder !== undefined && !(this.sortOrder === 'asc' || this.sortOrder === 'desc')) { 8561 console.warn('sortOrder should be asc or desc, as sortOrder will be set "asc".'); 8562 this.sortOrder = 'asc'; 8563 } 8564 let filter = ''; 8565 let pagination = ''; 8566 let queryExtension = '?'; 8567 8568 for (let key in this.filters) { 8569 if (this.filters.hasOwnProperty(key)) { 8570 filter += '&' + key + '=' + this.filters[key]; 8571 } 8572 } 8573 8574 if (this.pageLimit !== 0) { 8575 pagination = '&limit=' + this.pageLimit + '&offset=' + this.offset; 8576 } 8577 if (this.baseUrl.includes('?')) { 8578 queryExtension = '&'; 8579 } 8580 8581 this.url = this.baseUrl + queryExtension + 'sort_key=' + this.sortKey + '&sort_order=' + this.sortOrder + pagination + filter; 8582 } 8583 8584 /** 8585 * Sorts by specified key and specified order (asc or desc). 8586 * @param {string} key 8587 * @param {string} order 8588 * @returns {Promise} 8589 */ 8590 sort(key = 'id', order = 'asc') { 8591 return new Promise((resolve, reject) => { 8592 this.sortKey = key; 8593 this.sortOrder = order; 8594 8595 this.fetch().then(resolve, reject); 8596 }); 8597 } 8598 8599 resetFilters() { 8600 this.filters = {}; 8601 } 8602 8603 filterByQuery(property, value) { 8604 return new Promise((resolve, reject) => { 8605 if (property === undefined) { 8606 this.filters = {}; 8607 } else if (value === undefined) { 8608 delete this.filters[property]; 8609 } else { 8610 this.filters[property] = value; 8611 } 8612 this.offset = 0; 8613 8614 this.fetch().then(resolve, reject); 8615 }); 8616 } 8617 8618 /** 8619 * Returns count of pages. 8620 * @returns {number} 8621 */ 8622 getPageCount() { 8623 return this.pageLimit === 0 ? this.pageLimit : Math.ceil(this.total / this.pageLimit); 8624 } 8625 8626 /** 8627 * Updates collection data to data from specified page. 8628 * @param {number} pageNo 8629 * @returns {Promise} 8630 */ 8631 getPage(pageNo = 0) { 8632 return new Promise((resolve, reject) => { 8633 const offset = this.pageLimit * pageNo; 8634 8635 if (this.total !== 0 && (offset > this.total || offset < 0)) { 8636 reject('Wrong page number!'); 8637 return; 8638 } 8639 8640 this.offset = offset; 8641 8642 this.fetch().then(resolve, reject); 8643 }); 8644 } 8645 8646 /** 8647 * Updated collection data to next page. 8648 * @returns {Promise} 8649 */ 8650 getNextPage() { 8651 return new Promise((resolve, reject) => { 8652 const offset = this.offset + this.pageLimit; 8653 if (offset >= this.total) { 8654 reject('This was last page!'); 8655 return; 8656 } 8657 8658 this.offset = offset; 8659 8660 this.fetch().then(resolve, reject); 8661 }); 8662 } 8663 8664 /** 8665 * Updated collection data to prev page. 8666 * @returns {Promise} 8667 */ 8668 getPrevPage() { 8669 return new Promise((resolve, reject) => { 8670 const offset = this.offset - this.pageLimit; 8671 if (offset < 0) { 8672 reject('This was first page!'); 8673 return; 8674 } 8675 8676 this.offset = offset; 8677 8678 this.fetch().then(resolve, reject); 8679 }); 8680 } 8681 8682 /** 8683 * Fetches data from server. 8684 * @extend Collection.fetch 8685 * @param {Object} options 8686 * @returns {Promise} 8687 */ 8688 fetch(options) { 8689 this.updateUrl(); 8690 8691 return new Promise((resolve, reject) => { 8692 super.fetch(Object.assign({ 8693 success: (...params) => { 8694 resolve(params); 8695 }, 8696 error: (...params) => { 8697 reject(params); 8698 } 8699 }, options)); 8700 }); 8701 } 8702 8703 /** 8704 * Removes data from server. 8705 * @extend Collection.remove 8706 * @param {Model} model 8707 * @param {Object} options 8708 * @returns {Promise} 8709 */ 8710 remove(model, options) { 8711 return new Promise((resolve, reject) => { 8712 super.remove(model, Object.assign({ 8713 success: (...params) => { 8714 resolve(params); 8715 }, 8716 error: (...params) => { 8717 reject(params); 8718 } 8719 }, options)); 8720 }); 8721 } 8722 8723 /** 8724 * Creates data from server. 8725 * @extend Collection.create 8726 * @param {Model} model 8727 * @param {Object} options 8728 * @returns {Promise} 8729 */ 8730 create(model, options) { 8731 return new Promise((resolve, reject) => { 8732 super.create(model, Object.assign({ 8733 success: (...params) => { 8734 resolve(params); 8735 }, 8736 error: (...params) => { 8737 reject(params); 8738 } 8739 }, options)); 8740 }); 8741 } 8742 8743 /** 8744 * Parses response from the server. 8745 * @override Collection.parse 8746 * @param {Object} resp 8747 * @param {Object} options 8748 * @returns {Object} 8749 */ 8750 parse(resp, options) { 8751 this.total = Number(options.xhr.getResponseHeader('X-Total-Count')); 8752 8753 return resp[self.get('plural')]; 8754 } 8755 8756 /** 8757 * Loges out user. 8758 */ 8759 unsetAuthData() { 8760 this.userModel.unsetAuthData(); 8761 } 8762 8763 /** 8764 * Starts long polling. 8765 * @param {number} intervalSeconds 8766 */ 8767 startLongPolling(intervalSeconds) { 8768 this.longPolling = true; 8769 8770 if (intervalSeconds) { 8771 this.intervalSeconds = intervalSeconds; 8772 } 8773 this.executeLongPolling(); 8774 } 8775 8776 /** 8777 * Stops long polling. 8778 */ 8779 stopLongPolling() { 8780 this.longPolling = false; 8781 clearTimeout(this.timeOutId); 8782 this.timeOutId = -1; 8783 } 8784 8785 /** 8786 * Fetches data from server. 8787 */ 8788 executeLongPolling() { 8789 const fetchSuccess = () => { 8790 if (this.longPolling) { 8791 this.timeOutId = setTimeout(this.executeLongPolling.bind(this), 1000 * this.intervalSeconds); 8792 } 8793 }; 8794 8795 this.fetch().then(fetchSuccess); 8796 } 8797 8798 /** 8799 * Syncs model data. 8800 * @extends Collection.sync 8801 * @param {string} method 8802 * @param {Object} collection 8803 * @param {Object} options 8804 */ 8805 sync(method, collection, options = {}) { 8806 options.headers = { 8807 'X-Auth-Token': userModel.authToken(), 8808 'Content-Type': 'application/json' 8809 }; 8810 super.sync(method, collection, options); 8811 } 8812 } 8813 8814 const collection = new CollectionClass(options); 8815 8816 self.collections[url] = collection; 8817 return collection; 8818 } 8819 toFormJSON(json) { 8820 const schema = {}; 8821 8822 for (let key in json.properties) { 8823 if (json.propertiesOrder !== undefined) { 8824 if (!json.propertiesOrder.includes(key)) { 8825 continue; 8826 } 8827 } 8828 8829 const value = json.properties[key]; 8830 8831 schema[key] = { 8832 title: value.title, 8833 type: 'Text', 8834 help: value.description, 8835 validators: [] 8836 }; 8837 8838 if (value.relation) { 8839 schema[key].relation = value.relation; 8840 } 8841 8842 if (value.type === 'string') { 8843 if (value.enum !== undefined) { 8844 schema[key].type = 'Select'; 8845 schema[key].options = []; 8846 8847 if (value.options !== undefined) { 8848 schema[key].options = value.options; 8849 } else { 8850 schema[key].options = value.enum; 8851 } 8852 } else if (value.format !== undefined && (value.format === 'yaml' || value.format === 'javascript')) { 8853 schema[key].format = value.format; 8854 schema[key].type = 'CodeEditor'; 8855 } else { 8856 schema[key].type = 'Text'; 8857 } 8858 } else if (value.type === 'integer' || value.type === 'number') { 8859 schema[key].type = 'Number'; 8860 } else if (value.type === 'array') { 8861 schema[key].type = 'List'; 8862 schema[key].default = this.defaultValue(value.items); 8863 if (value.items.type === 'object') { 8864 schema[key].itemType = 'Object'; 8865 schema[key].order = value.items.propertiesOrder; 8866 schema[key].subSchema = this.toFormJSON(value.items); 8867 } else if (value.items.type === 'boolean') { 8868 schema[key].itemType = 'Checkbox'; 8869 } else if (value.items.type === 'number' || value.items.type === 'integer') { 8870 schema[key].itemType = 'Number'; 8871 } else if (value.items.type === 'string') { 8872 if (value.items.enum !== undefined) { 8873 schema[key].itemType = 'Select'; 8874 schema[key].options = []; 8875 8876 if (value.items.options !== undefined) { 8877 schema[key].options = value.items.options; 8878 } else { 8879 schema[key].options = value.items.enum; 8880 } 8881 } else if (value.format !== undefined && (value.format === 'yaml' || value.format === 'javascript')) { 8882 schema[key].format = value.format; 8883 schema[key].itemType = 'CodeEditor'; 8884 } else { 8885 schema[key].itemType = 'Text'; 8886 } 8887 } 8888 } else if (value.type === 'object') { 8889 if (value.properties) { 8890 schema[key].type = 'Object'; 8891 schema[key].subSchema = this.toFormJSON(value); 8892 } else { 8893 schema[key].type = 'CodeEditor'; 8894 schema[key].format = value.format; 8895 } 8896 } else if (value.type === 'boolean') { 8897 schema[key].type = 'Checkbox'; 8898 } 8899 if (value.format !== undefined) { 8900 schema[key].validators.push(value.format); 8901 } 8902 if (json.required !== undefined && json.required.includes(key)) { 8903 schema[key].title += '<span class="form-asterisk">*</span>'; 8904 schema[key].validators.push('required'); 8905 } 8906 } 8907 return schema; 8908 } 8909 /** 8910 * Returns local schema for popup with content. 8911 * @param {Object} schema 8912 * @returns {Promise} 8913 */ 8914 toLocalSchema(schema) { 8915 // Convert dict in schema to array for form generation 8916 // In json schema, we can't type dict element, so gohan 8917 // extend json schema using items property for object. 8918 // If object type has items property, items is considered to 8919 // schema for object of dict. 8920 // We will transform schema here for jsonform lib. 8921 return new Promise((resolve, reject) => { 8922 const self = this; 8923 8924 if (Array.isArray(schema.type)) { 8925 schema.type = schema.type[0]; 8926 } 8927 8928 if (schema.relation !== undefined) { 8929 const enumValues = []; 8930 const options = {}; 8931 const headers = {}; 8932 const properties = []; 8933 8934 headers['X-Auth-Token'] = this.collection.userModel.authToken(); 8935 const relatedSchema = this.collection.get(schema.relation); 8936 8937 fetch(relatedSchema.apiEndpoint(), { headers }).then(response => response.json()).then(data => { 8938 for (let key in data) { 8939 for (let value of data[key]) { 8940 enumValues.push(value.id); 8941 options[value.id] = value.name; 8942 properties.push(value); 8943 } 8944 } 8945 schema.enum = enumValues; 8946 schema.options = options; 8947 schema.properties = properties; 8948 resolve(schema); 8949 }, error => { 8950 reject(error); 8951 }); 8952 return; 8953 } 8954 const result = Object.assign({}, schema); 8955 8956 if (schema.type === 'array') { 8957 const promise = this.toLocalSchema(result.items); 8958 8959 promise.then(data => { 8960 result.items = data; 8961 resolve(result); 8962 }); 8963 return; 8964 } 8965 8966 if (schema.type !== 'object') { 8967 resolve(schema); 8968 return; 8969 } 8970 8971 if (schema.properties !== undefined) { 8972 const promises = []; 8973 8974 for (let key in schema.properties) { 8975 const promise = self.toLocalSchema(schema.properties[key]); 8976 8977 promises.push(promise); 8978 promise.then(function onFulfilled(data) { 8979 result.properties[key] = data; 8980 }); 8981 } 8982 Promise.all(promises).then(() => { 8983 resolve(result); 8984 }, data => { 8985 reject(data); 8986 }); 8987 } else if (schema.items !== undefined) { 8988 result.type = 'array'; 8989 8990 this.toLocalSchema(result.items).then(items => { 8991 if (items.title === undefined) { 8992 items.title = 'value'; 8993 } 8994 result.items = { 8995 type: 'object', 8996 required: schema.required, 8997 properties: { 8998 id: { 8999 title: 'key', 9000 type: 'string' 9001 }, 9002 value: items 9003 } 9004 }; 9005 resolve(result); 9006 }, error => { 9007 reject(error); 9008 }); 9009 } else { 9010 result.type = schema.type; 9011 result.format = 'yaml'; 9012 result.originalType = 'object'; 9013 resolve(result); 9014 } 9015 }); 9016 } 9017 9018 /** 9019 * Returns default values in schema. 9020 * @param {Object} schema 9021 * @returns {*} 9022 */ 9023 defaultValue(schema) { 9024 if (schema.type === 'object') { 9025 if (schema.default === undefined && schema.properties !== undefined) { 9026 const result = {}; 9027 9028 for (let key in schema.properties) { 9029 result[key] = this.defaultValue(schema.properties[key]); 9030 } 9031 return result; 9032 } 9033 } else if (schema.type === 'array') { 9034 if (schema.items.properties !== undefined) { 9035 const result = {}; 9036 9037 for (let key in schema.items.properties) { 9038 result[key] = this.defaultValue(schema.items.properties[key]); 9039 } 9040 return [result]; 9041 } 9042 return undefined; 9043 } 9044 return schema.default; 9045 } 9046 9047 /** 9048 * Format data to local. 9049 * @param {Object} data 9050 * @returns {Object} 9051 */ 9052 toLocal(data) { 9053 const schema = this.get('schema'); 9054 const defaultValue = this.defaultValue(schema); 9055 9056 data = defaultValue === undefined ? undefined : Object.assign({}, defaultValue, data); 9057 return this.toLocalData(schema, data); 9058 } 9059 9060 /** 9061 * Format data to local. 9062 * @param {Object} schema 9063 * @param {Object} data 9064 * @returns {Object} 9065 */ 9066 toLocalData(schema, data) { 9067 if (schema.type !== 'object') { 9068 return data; 9069 } 9070 9071 if (data === undefined) { 9072 return undefined; 9073 } 9074 9075 if (schema.format === 'jsonschema') { 9076 return _jsYaml2.default.safeDump(data); 9077 } else if (schema.properties !== undefined) { 9078 if (data) { 9079 for (let key in schema.properties) { 9080 data[key] = this.toLocalData(schema.properties[key], data[key]); 9081 } 9082 } 9083 } else if (schema.items !== undefined) { 9084 const result = []; 9085 9086 if (schema.items.propertiesOrder === undefined) { 9087 for (let key in data) { 9088 result.push({ 9089 id: key, 9090 value: this.toLocalData(schema.items, data[key]) 9091 }); 9092 } 9093 } else { 9094 for (let key of schema.items.propertiesOrder) { 9095 const value = data[key]; 9096 9097 result.push({ 9098 id: key, 9099 value: this.toLocalData(schema.items, value) 9100 }); 9101 } 9102 } 9103 return result; 9104 } else { 9105 return _jsYaml2.default.safeDump(data); 9106 } 9107 return data; 9108 } 9109 9110 /** 9111 * Format data to server format. 9112 * @param {Object} data 9113 * @returns {Object} 9114 */ 9115 toServer(data) { 9116 return this.toServerData(this.get('schema'), data); 9117 } 9118 9119 /** 9120 * Format data to server format. 9121 * @param {Object} schema 9122 * @param {Object} data 9123 * @returns {Object} 9124 */ 9125 toServerData(schema, data) { 9126 const self = this; 9127 if (data === undefined || data === null || data === '') { 9128 return undefined; 9129 } 9130 9131 if (schema.type === 'array') { 9132 return data.map(item => this.toServerData(schema.items, item)); 9133 } 9134 9135 if (schema.type !== 'object' && schema.originalType !== 'object') { 9136 return data; 9137 } 9138 9139 if (schema.properties !== undefined) { 9140 const result = {}; 9141 for (let key in schema.properties) { 9142 if (key === 'id') { 9143 continue; 9144 } 9145 result[key] = self.toServerData(schema.properties[key], data[key]); 9146 } 9147 return result; 9148 } else if (schema.items !== undefined) { 9149 const result = {}; 9150 9151 for (let d of data) { 9152 result[d.id] = self.toServerData(schema.items, d.value); 9153 } 9154 return result; 9155 } 9156 return _jsYaml2.default.safeLoad(data); 9157 } 9158 9159 /** 9160 * Filters schema by action. 9161 * @param {string} action 9162 * @param {string} [parentProperty] 9163 * @returns {Promise} 9164 */ 9165 filterByAction(action, parentProperty) { 9166 return new Promise((resolve, reject) => { 9167 let result = {}; 9168 const schema = this.toJSON(); 9169 9170 this.toLocalSchema(schema.schema).then(localSchema => { 9171 for (let key in localSchema.properties) { 9172 const property = localSchema.properties[key]; 9173 9174 if (key === 'id' && property.format === 'uuid') { 9175 continue; 9176 } 9177 9178 if (key === parentProperty) { 9179 continue; 9180 } 9181 9182 if (property.permission === null || property.permission === undefined) { 9183 continue; 9184 } 9185 9186 const view = property.view; 9187 9188 if (view) { 9189 if (view.indexOf(action) < 0) { 9190 continue; 9191 } 9192 } 9193 9194 if (property.permission.indexOf(action) >= 0) { 9195 result[key] = property; 9196 } 9197 } 9198 let required = []; 9199 9200 if (schema.schema.required) { 9201 required = schema.schema.required.filter(property => { 9202 return result.hasOwnProperty(property); 9203 }); 9204 } 9205 9206 result = { 9207 type: 'object', 9208 properties: result, 9209 propertiesOrder: schema.schema.propertiesOrder, 9210 required 9211 }; 9212 9213 resolve(result); 9214 }, error => { 9215 reject(error); 9216 console.error(error); 9217 }); 9218 }); 9219 } 9220 9221 /** 9222 * Returns children of schema. 9223 * @returns {TModel[]} 9224 */ 9225 children() { 9226 return this.collection.filter(schema => { 9227 return schema.get('parent') === this.id; 9228 }); 9229 } 9230 } 9231 exports.default = SchemaModel; /* global fetch */ 9232 9233 /***/ }, 9234 /* 37 */ 9235 /***/ function(module, exports, __webpack_require__) { 9236 9237 'use strict'; 9238 9239 Object.defineProperty(exports, "__esModule", { 9240 value: true 9241 }); 9242 9243 var _backbone = __webpack_require__(2); 9244 9245 var _backbone2 = _interopRequireDefault(_backbone); 9246 9247 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9248 9249 /** 9250 * Class contains logic of user authority in application. 9251 * @class UserModel 9252 * @extends Model 9253 */ 9254 class UserModel extends _backbone.Model { 9255 defaults() { 9256 return { 9257 authData: undefined 9258 }; 9259 } 9260 9261 /** 9262 * Constructs the object. 9263 * @constructor 9264 * @extends Model.constructor 9265 * @param {Object} options 9266 */ 9267 constructor(options) { 9268 super(options); 9269 9270 this.url = options.url + '/tokens'; 9271 this.tenantURL = options.url + '/tenants'; 9272 this.config = options.config; 9273 9274 window.addEventListener('storage', this.sessionStorageTransfer.bind(this), false); 9275 9276 if (!sessionStorage.length) { 9277 localStorage.setItem('getSessionStorage', 'true'); 9278 setTimeout(() => { 9279 localStorage.removeItem('getSessionStorage'); 9280 }, 500); 9281 } 9282 } 9283 9284 sessionStorageTransfer(event) { 9285 if (!event.newValue) { 9286 return; 9287 } 9288 if (event.key === 'getSessionStorage') { 9289 localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage)); 9290 setTimeout(() => { 9291 localStorage.removeItem('sessionStorage'); 9292 localStorage.removeItem('getSessionStorage'); 9293 }, 0); 9294 } else if (event.key === 'sessionStorage' && !sessionStorage.length) { 9295 const data = JSON.parse(event.newValue); 9296 for (let key in data) { 9297 sessionStorage.setItem(key, data[key]); 9298 } 9299 if (data.unscopedToken) { 9300 this.set('authData', JSON.parse(data.unscopedToken)); 9301 } 9302 } else if (event.key === 'clearSessionStorage') { 9303 this.unsetAuthData(); 9304 } 9305 } 9306 9307 /** 9308 * Calls setAuthData function. 9309 * @override Model.parse 9310 * @param {Object} data 9311 */ 9312 parse(data) { 9313 this.saveScopedToken(data); 9314 } 9315 9316 /** 9317 * Syncs model data. 9318 * @extends Model.sync 9319 * @param {string} method 9320 * @param {Object} model 9321 * @param {Object} options 9322 */ 9323 sync(method, model, options = {}) { 9324 options.headers = { 9325 'Content-Type': 'application/json' 9326 }; 9327 super.sync(method, model, options); 9328 } 9329 9330 /** 9331 * Login to the server 9332 * @param {string} username 9333 * @param {string} password 9334 * @returns {Promise} 9335 */ 9336 login(username, password) { 9337 return new Promise((resolve, reject) => { 9338 const authData = { 9339 auth: { 9340 passwordCredentials: { 9341 username, 9342 password 9343 } 9344 } 9345 }; 9346 9347 const tenants = this.tenants(); 9348 if (tenants) { 9349 resolve(tenants); 9350 return; 9351 } 9352 _backbone2.default.ajax({ 9353 dataType: 'json', 9354 url: this.url, 9355 data: JSON.stringify(authData), 9356 method: 'POST', 9357 timeout: this.config.get('loginRequestTimeout'), 9358 headers: { 9359 'Content-Type': 'application/json' 9360 }, 9361 success: authToken => { 9362 this.saveUnscopedToken(authToken); 9363 this.fetchTenant(resolve, reject); 9364 }, 9365 error: (...params) => { 9366 reject(params); 9367 } 9368 }); 9369 }); 9370 } 9371 9372 /** 9373 * Fetch tenants from server 9374 */ 9375 fetchTenant(resolve, reject) { 9376 _backbone2.default.ajax({ 9377 method: 'GET', 9378 dataType: 'json', 9379 url: this.tenantURL, 9380 headers: { 9381 'Content-Type': 'application/json', 9382 'X-Auth-Token': this.unscopedToken() 9383 }, 9384 success: data => { 9385 const tenants = data.tenants; 9386 this.saveTenants(tenants); 9387 resolve(tenants); 9388 }, 9389 error: (...params) => { 9390 reject(params); 9391 } 9392 }); 9393 } 9394 9395 /** 9396 * Login to the server with tenant. 9397 * @param {String} tenant 9398 * @returns {Promise} 9399 */ 9400 loginTenant(tenant) { 9401 return new Promise((resolve, reject) => { 9402 const authData = { 9403 auth: { 9404 token: { 9405 id: this.unscopedToken() 9406 }, 9407 tenantName: tenant 9408 } 9409 }; 9410 this.saveTenant(tenant); 9411 this.save(authData, { 9412 data: JSON.stringify(authData), 9413 success: (...params) => { 9414 resolve(params); 9415 }, 9416 error: (...params) => { 9417 reject(params); 9418 } 9419 }); 9420 }); 9421 } 9422 9423 /** 9424 * Save item to sessionStorage 9425 * @param {Object} data 9426 */ 9427 setItem(key, value) { 9428 sessionStorage.setItem(key, JSON.stringify(value)); 9429 } 9430 9431 /** 9432 * Get item to from sessionStorage 9433 * @param {Object} data 9434 */ 9435 getItem(key) { 9436 const value = sessionStorage.getItem(key); 9437 if (value) { 9438 return JSON.parse(value); 9439 } 9440 } 9441 9442 /** 9443 * Save unscoped token 9444 * @param {Object} data 9445 */ 9446 saveUnscopedToken(data) { 9447 this.setItem('unscopedToken', data); 9448 } 9449 9450 /** 9451 * Save tenants 9452 * @param {Object} data 9453 */ 9454 saveTenants(data) { 9455 this.setItem('tenants', data); 9456 } 9457 9458 /** 9459 * Save tenant selection 9460 * @param {Object} data 9461 */ 9462 saveTenant(data) { 9463 this.setItem('tenant', data); 9464 } 9465 9466 /** 9467 * Save scoped token 9468 * @param {Object} data 9469 */ 9470 saveScopedToken(data) { 9471 const tenant = this.tenantName(); 9472 let scopedToken = this.getItem('scopedToken'); 9473 if (!scopedToken) { 9474 scopedToken = {}; 9475 } 9476 scopedToken[tenant] = data; 9477 this.setItem('scopedToken', scopedToken); 9478 this.set('authData', data); 9479 } 9480 9481 /** 9482 * Reset auth data 9483 */ 9484 unsetAuthData() { 9485 localStorage.setItem('clearSessionStorage', 'true'); 9486 setTimeout(() => { 9487 localStorage.removeItem('clearSessionStorage'); 9488 }, 0); 9489 sessionStorage.removeItem('scopedToken'); 9490 sessionStorage.removeItem('unscopedToken'); 9491 sessionStorage.removeItem('tenant'); 9492 sessionStorage.removeItem('tenants'); 9493 } 9494 9495 /** 9496 * Returns scoped token. 9497 * @returns {string} 9498 */ 9499 authToken() { 9500 const tenant = this.tenantName(); 9501 const scopedToken = this.getItem('scopedToken'); 9502 if (scopedToken) { 9503 const data = scopedToken[tenant]; 9504 if (data) { 9505 return data.access.token.id; 9506 } 9507 } 9508 } 9509 9510 /** 9511 * Returns scoped token expires date. 9512 * @returns {Date} 9513 */ 9514 expiresTokenDate() { 9515 const tenant = this.tenantName(); 9516 const scopedToken = this.getItem('scopedToken'); 9517 9518 if (scopedToken) { 9519 const data = scopedToken[tenant]; 9520 if (data) { 9521 return new Date(data.access.token.expires); 9522 } 9523 } 9524 } 9525 9526 /** 9527 * Returns unscoped token. 9528 * @returns {string} 9529 */ 9530 unscopedToken() { 9531 const unscopedToken = this.getItem('unscopedToken'); 9532 if (unscopedToken) { 9533 return unscopedToken.access.token.id; 9534 } 9535 } 9536 9537 /** 9538 * Returns tenant name. 9539 * @returns {string} 9540 */ 9541 tenantName() { 9542 return this.getItem('tenant'); 9543 } 9544 9545 /** 9546 * Returns tenants. 9547 * @returns {Object} 9548 */ 9549 tenants() { 9550 return this.getItem('tenants'); 9551 } 9552 9553 /** 9554 * Returns user name. 9555 * @returns {string} 9556 */ 9557 userName() { 9558 const tenant = this.tenantName(); 9559 const scopedToken = this.getItem('scopedToken'); 9560 if (scopedToken) { 9561 const data = scopedToken[tenant]; 9562 if (data) { 9563 return data.access.user.name; 9564 } 9565 } 9566 } 9567 } 9568 exports.default = UserModel; /* global window, sessionStorage, localStorage */ 9569 9570 /***/ }, 9571 /* 38 */ 9572 /***/ function(module, exports, __webpack_require__) { 9573 9574 'use strict'; 9575 9576 Object.defineProperty(exports, "__esModule", { 9577 value: true 9578 }); 9579 9580 var _backbone = __webpack_require__(2); 9581 9582 /** 9583 * Class contains logic of router in application. 9584 * @class AppRouter 9585 * @extends Router 9586 */ 9587 class AppRouter extends _backbone.Router { 9588 9589 /** 9590 * Constructs the object. 9591 * @constructor 9592 * @override 9593 * @param {Object} options={} 9594 */ 9595 constructor(options = {}) { 9596 super(options); 9597 9598 this.pageBaseTitle = options.title || ''; 9599 this.routes = []; 9600 } 9601 9602 /** 9603 * Adds route to router. 9604 * @override 9605 * @param {string} route 9606 * @param {string} name 9607 * @param {!*} rest 9608 */ 9609 route(route, name, ...rest) { 9610 this.routes.push({ 9611 path: route, 9612 name 9613 }); 9614 super.route(route, name, ...rest); 9615 } 9616 9617 /** 9618 * Changes title to specified value. 9619 * @param {string} name='' 9620 */ 9621 changeTitle(name = '') { 9622 if (name !== '') { 9623 document.title = name + ' | ' + this.pageBaseTitle; 9624 return; 9625 } 9626 document.title = this.pageBaseTitle; 9627 } 9628 9629 setQueryParams(params) { 9630 9631 let queryStrings = ''; 9632 9633 for (let x in params) { 9634 if (params.hasOwnProperty(x)) { 9635 if (queryStrings === '') { 9636 queryStrings += '?'; 9637 } else { 9638 queryStrings += '&'; 9639 } 9640 queryStrings += x + '=' + params[x]; 9641 } 9642 } 9643 window.history.replaceState({}, '', '/' + queryStrings + window.location.hash); 9644 } 9645 9646 getQueryParams() { 9647 const params = {}; 9648 const queryStrings = _backbone.history.location.search.substr(1); 9649 9650 if (queryStrings === '') { 9651 return params; 9652 } 9653 9654 queryStrings.split('&').map(query => { 9655 const keyvalue = query.split('='); 9656 9657 params[keyvalue[0].toString()] = keyvalue[1].toString(); 9658 }); 9659 9660 return params; 9661 } 9662 9663 /** 9664 * Returns status of path in router, 9665 * if is registered returns true, otherwise false. 9666 * @param param 9667 * @returns {boolean} 9668 */ 9669 pathIsRegistered(param) { 9670 return this.routes.map(({ path }) => path).includes(param); 9671 } 9672 } 9673 exports.default = AppRouter; /* global document, window */ 9674 9675 /***/ }, 9676 /* 39 */ 9677 /***/ function(module, exports, __webpack_require__) { 9678 9679 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 9680 9681 Object.defineProperty(exports, "__esModule", { 9682 value: true 9683 }); 9684 9685 var _backbone = __webpack_require__(2); 9686 9687 var _userModel = __webpack_require__(37); 9688 9689 var _userModel2 = _interopRequireDefault(_userModel); 9690 9691 var _schemaCollection = __webpack_require__(35); 9692 9693 var _schemaCollection2 = _interopRequireDefault(_schemaCollection); 9694 9695 var _sidebarView = __webpack_require__(54); 9696 9697 var _sidebarView2 = _interopRequireDefault(_sidebarView); 9698 9699 var _headerView = __webpack_require__(49); 9700 9701 var _headerView2 = _interopRequireDefault(_headerView); 9702 9703 var _tableView = __webpack_require__(17); 9704 9705 var _tableView2 = _interopRequireDefault(_tableView); 9706 9707 var _detailView = __webpack_require__(41); 9708 9709 var _detailView2 = _interopRequireDefault(_detailView); 9710 9711 var _loginView = __webpack_require__(50); 9712 9713 var _loginView2 = _interopRequireDefault(_loginView); 9714 9715 var _sampleView = __webpack_require__(51); 9716 9717 var _sampleView2 = _interopRequireDefault(_sampleView); 9718 9719 var _errorView = __webpack_require__(9); 9720 9721 var _errorView2 = _interopRequireDefault(_errorView); 9722 9723 var _breadCrumbView = __webpack_require__(40); 9724 9725 var _breadCrumbView2 = _interopRequireDefault(_breadCrumbView); 9726 9727 var _app = __webpack_require__(108); 9728 9729 var _app2 = _interopRequireDefault(_app); 9730 9731 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 9732 9733 /* global window, $ */ 9734 class AppView extends _backbone.View { 9735 9736 get className() { 9737 return 'appview'; 9738 } 9739 9740 constructor(options) { 9741 super(options); 9742 9743 this.template = options.template || _app2.default; 9744 this.router = options.router; 9745 this.config = options.config; 9746 this.viewClass = Object.assign({ 9747 table: _tableView2.default, 9748 detail: _detailView2.default, 9749 sampleview: _sampleView2.default 9750 }, options.viewClass); 9751 9752 this.menuCollection = new _backbone.Collection(); 9753 9754 this.userModel = options.userModel || new _userModel2.default({ 9755 config: this.config, 9756 url: this.config.get('authUrl') 9757 }); 9758 9759 this.schemas = options.schemas || new _schemaCollection2.default({ 9760 baseUrl: this.config.get('gohan').url, 9761 userModel: this.userModel, 9762 url: this.config.get('gohan').url + this.config.get('gohan').schema, 9763 additionalForms: this.config.get('additionalForms'), 9764 pageLimit: this.config.get('pageLimit'), 9765 addingRelationDialog: this.config.get('addingRelationDialog') 9766 }); 9767 9768 this.view = null; 9769 9770 const showTokenExpireError = () => { 9771 let message; 9772 if (this.config.get('errorMessages') && this.config.get('errorMessages')['tokenExpire']) { 9773 message = this.config.get('errorMessages')['tokenExpire']; 9774 } else { 9775 message = 'The token is expired. Please re-login. '; 9776 } 9777 this.errorView.render({ 9778 status: 1, 9779 readyState: 1, 9780 statusText: message + ' <a href="#" data-gohan="logout" class="alert-link">Logout</a>' 9781 }); 9782 this.userModel.unsetAuthData(); 9783 $('[data-gohan="logout"]', this.errorView.el).on('click', event => { 9784 event.preventDefault(); 9785 window.location.reload(); 9786 }); 9787 }; 9788 if (this.userModel.authToken()) { 9789 setTimeout(showTokenExpireError, this.userModel.expiresTokenDate() - new Date()); 9790 this.schemas.fetch().then(() => { 9791 this.buildUi(); 9792 }, error => { 9793 this.errorView.render(...error); 9794 }); 9795 } else { 9796 this.listenTo(this.userModel, 'change:authData', () => { 9797 setTimeout(showTokenExpireError, this.userModel.expiresTokenDate() - new Date()); 9798 this.$('#main_body').empty(); 9799 this.schemas.fetch().then(() => { 9800 this.buildUi(); 9801 }); 9802 this.render(); 9803 }); 9804 } 9805 this.SidebarClass = options.SidebarClass || _sidebarView2.default; 9806 this.HeaderClass = options.HeaderClass || _headerView2.default; 9807 this.BreadCrumbClass = options.BreadCrumbClass || _breadCrumbView2.default; 9808 this.LoginClass = options.LoginClass || _loginView2.default; 9809 this.ErrorClass = options.ErrorClass || _errorView2.default; 9810 9811 this.ErrorClass = options.ErrorClass || _errorView2.default; 9812 this.errorView = new this.ErrorClass(); 9813 $('[data-gohan="error"]').append(this.errorView.el); 9814 this.breadCrumb = new this.BreadCrumbClass(); 9815 this.sidebarView = new this.SidebarClass({ 9816 collection: this.menuCollection, 9817 config: this.config.toJSON(), 9818 app: this 9819 }); 9820 9821 this.headerView = new this.HeaderClass({ 9822 collection: this.menuCollection, 9823 config: this.config.toJSON(), 9824 model: this.userModel, 9825 app: this 9826 }); 9827 } 9828 9829 closeActivePage() { 9830 if (this.view) { 9831 if (this.view.close) { 9832 this.view.close(); 9833 } else { 9834 this.view.remove(); 9835 } 9836 } 9837 } 9838 9839 buildUi() { 9840 const params = this.router.getQueryParams(); 9841 9842 this.schemas.each(schema => { 9843 const metadata = schema.get('metadata'); 9844 const type = params.type || 'tenant'; 9845 9846 if (metadata && metadata.type !== undefined && metadata.type !== type) { 9847 return; 9848 } 9849 9850 const viewClass = Object.assign({}, this.viewClass, this.viewClass[schema.id]); 9851 const route = schema.url().substr(1); 9852 9853 if (!schema.hasParent() && this.config.get('sidebar') === undefined) { 9854 this.menuCollection.add({ 9855 path: schema.get('url'), 9856 title: schema.get('title') 9857 }); 9858 } 9859 const tableView = () => { 9860 let collection = {}; 9861 if (schema.hasParent()) { 9862 const endpoint = schema.apiEndpointBase() + '/' + _backbone.history.fragment; 9863 collection = schema.makeCollection(endpoint); 9864 } else { 9865 collection = schema.makeCollection(); 9866 } 9867 9868 $('#alerts').empty(); 9869 this.closeActivePage(); 9870 9871 this.view = new viewClass.table({ 9872 params: this.router.getQueryParams(), 9873 schema, 9874 collection, 9875 childview: schema.hasParent(), 9876 fragment: _backbone.history.fragment, 9877 app: this 9878 }); 9879 9880 this.$('#main_body').html(this.view.el); 9881 }; 9882 9883 const detailView = (...rest) => { 9884 const id = rest.length >= 2 ? rest[rest.length - 2] : ''; 9885 const collection = schema.makeCollection(); 9886 const model = collection.get(id) || new collection.model({ id }); 9887 9888 $('#alerts').empty(); 9889 this.closeActivePage(); 9890 this.view = new viewClass.detail({ 9891 schema, 9892 collection, 9893 model, 9894 fragment: _backbone.history.fragment, 9895 app: this, 9896 polling: this.config.get('polling'), 9897 params: this.router.getQueryParams() 9898 }); 9899 9900 this.$('#main_body').html(this.view.el); 9901 }; 9902 9903 this.router.route(route, 'table_view', tableView); 9904 this.router.route(route + '/:id', 'detail_view', detailView); 9905 }); 9906 9907 if (this.config.get('sidebar') !== undefined) { 9908 this.config.get('sidebar').forEach((item, key) => { 9909 this.sidebarView.collection.add({ 9910 path: item.path, 9911 title: item.title, 9912 cssClass: item.cssClass, 9913 order: key 9914 }); 9915 }); 9916 } 9917 9918 this.config.get('routes').forEach(route => { 9919 const customView = (...rest) => { 9920 const schema = this.schemas.get(route.name); 9921 this.closeActivePage(); 9922 if (schema === undefined) { 9923 this.view = new this.viewClass[route.viewClass]({ 9924 params: this.router.getQueryParams(), 9925 arguments: rest, 9926 fragment: _backbone.history.fragment, 9927 app: this 9928 }); 9929 this.$('#main_body').append(this.view.el); 9930 } else { 9931 const collection = schema.makeCollection(); 9932 if (rest) { 9933 const id = rest.length >= 2 ? rest[rest.length - 2] : ''; 9934 const model = collection.get(id) || new collection.model({ id }); 9935 9936 this.view = new this.viewClass[route.viewClass]({ 9937 arguments: rest, 9938 fragment: _backbone.history.fragment, 9939 app: this, 9940 schema, 9941 model, 9942 params: this.router.getQueryParams(), 9943 collection 9944 }); 9945 this.$('#main_body').append(this.view.el); 9946 } else { 9947 this.view = new this.viewClass[route.viewClass]({ 9948 arguments: rest, 9949 fragment: _backbone.history.fragment, 9950 app: this, 9951 schema, 9952 params: this.router.getQueryParams(), 9953 collection 9954 }); 9955 9956 this.$('#main_body').append(this.view.el); 9957 } 9958 } 9959 }; 9960 9961 this.router.route(route.path, route.name, customView); 9962 }); 9963 9964 _backbone.history.loadUrl(_backbone.history.fragment); 9965 } 9966 9967 /** 9968 * Shows login page. 9969 */ 9970 showLogin() { 9971 const loginView = new this.LoginClass({ 9972 model: this.userModel 9973 }); 9974 9975 this.$el.html(loginView.render().el); 9976 } 9977 9978 /** 9979 * Renders page content. 9980 * @override View.render 9981 * @returns {AppView} 9982 */ 9983 render() { 9984 if (!this.userModel.authToken()) { 9985 this.showLogin(); 9986 } else { 9987 this.$el.html(this.template()); 9988 this.$('#header').append(this.headerView.render().el); 9989 this.$('#sidebar').append(this.sidebarView.render().el); 9990 this.$('#bread-crumb').append(this.breadCrumb.render().el); 9991 } 9992 return this; 9993 } 9994 } 9995 exports.default = AppView; 9996 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 9997 9998 /***/ }, 9999 /* 40 */ 10000 /***/ function(module, exports, __webpack_require__) { 10001 10002 'use strict'; 10003 10004 Object.defineProperty(exports, "__esModule", { 10005 value: true 10006 }); 10007 10008 var _backbone = __webpack_require__(2); 10009 10010 var _breadcrumb = __webpack_require__(109); 10011 10012 var _breadcrumb2 = _interopRequireDefault(_breadcrumb); 10013 10014 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10015 10016 /** 10017 * Class contains logic of bread crumb view in application. 10018 * @class BreadCrumbView 10019 * @extends View 10020 */ 10021 class BreadCrumbView extends _backbone.View { 10022 get template() { 10023 return _breadcrumb2.default; 10024 } 10025 10026 /** 10027 * Updates bread crumb. 10028 * @param {Array} ancestors 10029 * @param {Object} childView 10030 */ 10031 update(parents) { 10032 this.$el.html(this.template({ parents })); 10033 } 10034 10035 /** 10036 * Renders component content. 10037 * @override View.render 10038 * @returns {BreadCrumbView} 10039 */ 10040 render() { 10041 this.$el.html(); 10042 return this; 10043 } 10044 } 10045 exports.default = BreadCrumbView; 10046 10047 /***/ }, 10048 /* 41 */ 10049 /***/ function(module, exports, __webpack_require__) { 10050 10051 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 10052 10053 Object.defineProperty(exports, "__esModule", { 10054 value: true 10055 }); 10056 10057 var _backbone = __webpack_require__(2); 10058 10059 var _underscore = __webpack_require__(4); 10060 10061 var _underscore2 = _interopRequireDefault(_underscore); 10062 10063 var _jsYaml = __webpack_require__(10); 10064 10065 var _jsYaml2 = _interopRequireDefault(_jsYaml); 10066 10067 var _bootstrapDialog = __webpack_require__(13); 10068 10069 var _bootstrapDialog2 = _interopRequireDefault(_bootstrapDialog); 10070 10071 var _dialogView = __webpack_require__(16); 10072 10073 var _dialogView2 = _interopRequireDefault(_dialogView); 10074 10075 var _errorView = __webpack_require__(9); 10076 10077 var _errorView2 = _interopRequireDefault(_errorView); 10078 10079 var _tableView = __webpack_require__(17); 10080 10081 var _tableView2 = _interopRequireDefault(_tableView); 10082 10083 var _loader = __webpack_require__(20); 10084 10085 var _loader2 = _interopRequireDefault(_loader); 10086 10087 var _detail = __webpack_require__(111); 10088 10089 var _detail2 = _interopRequireDefault(_detail); 10090 10091 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10092 10093 class DetailView extends _backbone.View { 10094 get tagName() { 10095 return 'div'; 10096 } 10097 10098 get className() { 10099 return 'detailview'; 10100 } 10101 10102 get events() { 10103 return { 10104 'click [data-gohan="update"]': 'update', 10105 'click [data-gohan="delete"]': 'delete' 10106 }; 10107 } 10108 constructor(options) { 10109 super(options); 10110 10111 this.app = options.app; 10112 this.errorView = this.app.ErrorClass ? new this.app.ErrorClass() : new _errorView2.default(); 10113 this.template = options.template || _detail2.default; 10114 this.loaderTemplate = options.loaderTemplate || _loader2.default; 10115 this.TableViewClass = options.TableViewClass || _tableView2.default; 10116 this.schema = options.schema; 10117 this.childview = options.childview; 10118 this.model = options.model; 10119 this.fragment = options.fragment; 10120 10121 this.$el.html(this.loaderTemplate()); 10122 this.model.fetch().then(() => this.render(), error => this.errorView.render(...error)); 10123 } 10124 dialogForm(action, formTitle, data, onsubmit, onhide) { 10125 this.schema.filterByAction(action, this.parentProperty).then(schema => { 10126 this.dialog = new _dialogView2.default({ 10127 app: this.app, 10128 formTitle, 10129 data, 10130 onsubmit, 10131 onhide, 10132 unformattedSchema: this.schema, 10133 schema: this.schema.toFormJSON(schema), 10134 fields: schema.propertiesOrder 10135 }); 10136 this.dialog.render(); 10137 }); 10138 } 10139 toLocal(data) { 10140 return this.schema.toLocal(data); 10141 } 10142 toServer(data) { 10143 return this.schema.toServer(data); 10144 } 10145 delete(event) { 10146 event.preventDefault(); 10147 10148 _bootstrapDialog2.default.confirm({ 10149 title: 'Delete', 10150 message: 'Are you sure to delete?', 10151 closable: true, 10152 btnOKLabel: 'Delete', 10153 callback: result => { 10154 if (result) { 10155 this.model.destroy().then(() => { 10156 history.back(); 10157 }, error => { 10158 this.errorView.render(...error); 10159 }); 10160 } 10161 } 10162 }); 10163 } 10164 update(event) { 10165 event.preventDefault(); 10166 event.currentTarget.disabled = true; 10167 10168 const model = this.model; 10169 const data = this.toLocal(model.toJSON()); 10170 const action = 'update'; 10171 const formTitle = '<h4>Update ' + this.schema.get('title') + '</h4>'; 10172 const onhide = () => { 10173 event.currentTarget.disabled = false; 10174 }; 10175 const onsubmit = values => { 10176 values = this.toServer(values); 10177 10178 model.save(values).then(() => { 10179 this.dialog.close(); 10180 this.render(); 10181 }, error => { 10182 this.dialog.errorView.render(...error); 10183 this.dialog.stopSpin(); 10184 }); 10185 }; 10186 10187 this.dialogForm(action, formTitle, data, onsubmit, onhide); 10188 } 10189 renderProperty(data, key) { 10190 let content; 10191 const property = this.schema.get('schema').properties[key]; 10192 const value = data[key]; 10193 10194 if (value === undefined) { 10195 return ''; 10196 } 10197 10198 if (property === undefined) { 10199 return ''; 10200 } 10201 10202 const relatedObject = data[property.relation_property]; // jscs:ignore requireCamelCaseOrUpperCaseIdentifiers 10203 10204 if (relatedObject !== undefined) { 10205 if (relatedObject.name !== undefined) { 10206 return relatedObject.name; 10207 } 10208 } 10209 10210 if (property.type === 'object' || property.originalType === 'object') { 10211 content = $('<pre style="width:500px;"></pre>').text(_jsYaml2.default.safeDump(value)).html(); 10212 return '<pre>' + _underscore2.default.escape(content) + '</pre>'; 10213 } 10214 10215 if (property.type === 'array') { 10216 return '<pre>' + _jsYaml2.default.safeDump(value) + '</pre>'; 10217 } 10218 if (property.type === 'string' && property.format === 'yaml') { 10219 return '<pre>' + _underscore2.default.escape(value) + '</pre>'; 10220 } 10221 return _underscore2.default.escape(value); 10222 } 10223 render() { 10224 const data = this.model.toJSON(); 10225 const result = Object.assign({}, data); 10226 10227 for (let key in data) { 10228 result[key] = this.renderProperty(data, key); 10229 } 10230 const children = this.schema.children().map(child => { 10231 const fragment = this.fragment + '/' + child.get('plural'); 10232 10233 return { 10234 id: child.id, 10235 title: child.get('title'), 10236 href: fragment 10237 }; 10238 }); 10239 10240 this.$el.html(this.template({ 10241 data: result, 10242 schema: this.schema.toJSON(), 10243 children 10244 })); 10245 $('[data-gohan="error"]', this.el).append(this.errorView.el); 10246 this.app.router.changeTitle(this.model.get('name') || this.model.get('id')); 10247 this.model.getAncestors(ancestors => { 10248 ancestors.unshift(this.model); 10249 const parents = ancestors.reduce((result, ancestor) => { 10250 const fragment = ancestor.schema.get('url'); 10251 let modelFragment; 10252 let schemaFragment; 10253 if (ancestor.schema.hasParent()) { 10254 modelFragment = ancestor.schema.parent().get('url') + '/' + ancestor.parentId() + '/' + ancestor.schema.get('plural') + '/' + ancestor.get('id'); 10255 schemaFragment = ancestor.schema.parent().get('url') + '/' + ancestor.parentId() + '/' + ancestor.schema.get('plural'); 10256 } else { 10257 modelFragment = ancestor.schema.get('url') + '/' + ancestor.get('id'); 10258 schemaFragment = fragment; 10259 } 10260 result.push({ 10261 title: ancestor.get('name'), 10262 url: modelFragment 10263 }, { 10264 title: ancestor.schema.get('title'), 10265 url: schemaFragment 10266 }); 10267 return result; 10268 }, []); 10269 parents.reverse(); 10270 this.app.breadCrumb.update(parents); 10271 }); 10272 10273 this.schema.children().forEach(child => { 10274 const fragment = this.fragment + '/' + child.get('plural'); 10275 const endpoint = this.schema.apiEndpointBase() + '/' + fragment; 10276 const collection = child.makeCollection(endpoint); 10277 const tableView = new this.TableViewClass({ 10278 schema: child, 10279 collection, 10280 childview: true, 10281 fragment: this.fragment + '/' + child.get('plural'), 10282 app: this.app 10283 }); 10284 10285 $('div#' + child.id + '_table', this.$el).html(tableView.render().el); 10286 return { 10287 title: child.get('title'), 10288 href: fragment, 10289 element: tableView.render().el 10290 }; 10291 }); 10292 10293 this.$('button[data-toggle=hover]').popover(); 10294 10295 return this; 10296 } 10297 } 10298 exports.default = DetailView; /* global $, history */ 10299 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 10300 10301 /***/ }, 10302 /* 42 */ 10303 /***/ function(module, exports, __webpack_require__) { 10304 10305 'use strict'; 10306 10307 var _backbone = __webpack_require__(2); 10308 10309 var _backbone2 = _interopRequireDefault(_backbone); 10310 10311 __webpack_require__(5); 10312 10313 __webpack_require__(21); 10314 10315 __webpack_require__(24); 10316 10317 __webpack_require__(23); 10318 10319 __webpack_require__(22); 10320 10321 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10322 10323 /* global window */ 10324 class CodeEditor extends _backbone2.default.Form.editors.Base { 10325 10326 constructor(options) { 10327 super(options); 10328 10329 this.format = options.schema.format; 10330 this.editor = window.ace.edit(this.el); 10331 this.$el.css('height', '300px'); 10332 this.editor.setTheme('ace/theme/monokai'); 10333 this.editor.getSession().setMode('ace/mode/' + this.format); 10334 this.editor.$blockScrolling = Infinity; 10335 } 10336 10337 render() { 10338 this.setValue(this.value); 10339 return this; 10340 } 10341 10342 getValue() { 10343 return this.editor.getValue(); 10344 } 10345 10346 setValue(value) { 10347 if (value) { 10348 this.editor.setValue(value); 10349 } 10350 } 10351 10352 focus() { 10353 if (this.hasFocus) { 10354 return; 10355 } 10356 10357 this.$el.focus(); 10358 } 10359 10360 blur() { 10361 if (!this.hasFocus) { 10362 return; 10363 } 10364 10365 this.$el.blur(); 10366 } 10367 } 10368 10369 _backbone2.default.Form.editors.CodeEditor = CodeEditor; 10370 10371 /***/ }, 10372 /* 43 */ 10373 /***/ function(module, exports, __webpack_require__) { 10374 10375 /* WEBPACK VAR INJECTION */(function(_, $) {'use strict'; 10376 10377 var _backbone = __webpack_require__(2); 10378 10379 var _backbone2 = _interopRequireDefault(_backbone); 10380 10381 __webpack_require__(5); 10382 10383 var _objectListEditor = __webpack_require__(45); 10384 10385 var _objectListEditor2 = _interopRequireDefault(_objectListEditor); 10386 10387 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10388 10389 _backbone2.default.Form.editors.List = class List extends _backbone2.default.Form.editors.Base { 10390 10391 get events() { 10392 return { 10393 'click [data-action="add"]': event => { 10394 event.stopPropagation(); 10395 event.preventDefault(); 10396 10397 this.addItem(this.schema.default, true); 10398 }, 10399 'click span.tab-delete': event => { 10400 event.stopPropagation(); 10401 event.preventDefault(); 10402 const item = _.findWhere(this.items, { cid: $(event.target).data('cid') }); 10403 if (item) { 10404 this.removeItem(item); 10405 } 10406 } 10407 }; 10408 } 10409 10410 static template() { 10411 return _.template('<div>' + ' <div data-items></div>' + ' <button type="button" data-action="add">Add</button>' + '</div>', _backbone2.default.Form.templateSettings)(); 10412 } 10413 10414 static objectTemplate() { 10415 return _.template('<div class="object-list-container">' + ' <a class="add-item" data-action="add"><span class="fa fa-plus-circle"></span> Add Item</a>' + ' <ul class="nav nav-tabs object-list-tabs" role="tablist" data-tabs></ul>' + ' <div class="tab-content" data-items></div>' + '</div>', _backbone2.default.Form.templateSettings)(); 10416 } 10417 10418 constructor(options) { 10419 super(options); 10420 10421 const editors = _backbone2.default.Form.editors; 10422 const type = this.schema.itemType; 10423 10424 if (!this.schema) { 10425 throw new Error('Missing required option \'schema\''); 10426 } 10427 10428 // Default to Text 10429 if (!type) { 10430 this.Editor = editors.Text; 10431 } else if (editors.List[type]) { 10432 this.Editor = editors.List[type]; 10433 } else { 10434 this.Editor = editors[type]; 10435 } 10436 10437 this.isObjectType = type === 'Object'; 10438 this.items = []; 10439 } 10440 10441 render() { 10442 const value = this.value || []; 10443 const $el = this.isObjectType ? $($.trim(List.objectTemplate())) : $($.trim(List.template())); 10444 10445 this.$list = $el.is('[data-items]') ? $el : $el.find('[data-items]'); 10446 10447 if (this.isObjectType) { 10448 this.$tab = $el.find('[data-tabs]'); 10449 } 10450 10451 if (value.length) { 10452 value.forEach(itemValue => { 10453 this.addItem(itemValue); 10454 }); 10455 } else if (!this.Editor.isAsync) { 10456 this.addItem(this.schema.default); 10457 } 10458 10459 if (this.isObjectType) { 10460 this.$tab.find('a[href="#tab-' + this.items[0].cid + '"]').tab('show'); 10461 this.items[0].$el.addClass('active in'); 10462 } 10463 10464 this.setElement($el); 10465 this.$el.attr('id', this.id); 10466 this.$el.attr('name', this.key); 10467 10468 if (this.hasFocus) this.trigger('blur', this); 10469 10470 return this; 10471 } 10472 10473 /** 10474 * Add a new item to the list 10475 * @param {Mixed} [value] Value for the new item editor 10476 * @param {Boolean} [userInitiated] If the item was added by the user clicking 'add' 10477 */ 10478 addItem(value, userInitiated) { 10479 10480 const editors = _backbone2.default.Form.editors; 10481 10482 // Create the item 10483 const item = new editors.List.Item({ 10484 list: this, 10485 form: this.form, 10486 schema: this.schema, 10487 value, 10488 Editor: this.Editor, 10489 key: this.key 10490 }).render(); 10491 10492 const tab = _.template('<li role="presentation" class="object-list-tab">' + ' <a href="#tab-<%= cid %>" class="tab-link" aria-controls="tab-<%= cid %>" role="tab" data-toggle="tab">' + ' <span class="tab-title">Item</span>' + ' <span class="tab-delete fa fa-times-circle" data-cid="<%= cid %>"></span>' + ' </a>' + '</li>', _backbone2.default.Form.templateSettings)({ cid: item.cid }); 10493 10494 const _addItem = () => { 10495 this.items.push(item); 10496 this.$list.append(item.el); 10497 if (this.isObjectType) { 10498 this.$tab.append(tab); 10499 this.$tab.find('a[href="#tab-' + item.cid + '"]').tab('show'); 10500 } 10501 10502 item.editor.on('all', event => { 10503 if (event === 'change') return; 10504 10505 // args = ["key:change", itemEditor, fieldEditor] 10506 var args = _.toArray(arguments); 10507 args[0] = 'item:' + event; 10508 args.splice(1, 0, this); 10509 // args = ["item:key:change", this=listEditor, itemEditor, fieldEditor] 10510 10511 editors.List.prototype.trigger.apply(this, args); 10512 }, this); 10513 10514 item.editor.on('change', function () { 10515 if (!item.addEventTriggered) { 10516 item.addEventTriggered = true; 10517 this.trigger('add', this, item.editor); 10518 } 10519 this.trigger('item:change', this, item.editor); 10520 this.trigger('change', this); 10521 }, this); 10522 10523 item.editor.on('focus', function () { 10524 if (this.hasFocus) return; 10525 this.trigger('focus', this); 10526 }, this); 10527 item.editor.on('blur', () => { 10528 if (!this.hasFocus) return; 10529 setTimeout(() => { 10530 if (_.find(this.items, item => { 10531 return item.editor.hasFocus; 10532 })) return; 10533 this.trigger('blur', this); 10534 }, 0); 10535 }, this); 10536 10537 if (userInitiated || value) { 10538 item.addEventTriggered = true; 10539 } 10540 10541 if (userInitiated) { 10542 this.trigger('add', this, item.editor); 10543 this.trigger('change', this); 10544 } 10545 }; 10546 10547 // Check if we need to wait for the item to complete before adding to the list 10548 if (this.Editor.isAsync) { 10549 item.editor.on('readyToAdd', _addItem, this); 10550 } else { 10551 // Most editors can be added automatically 10552 _addItem(); 10553 item.editor.focus(); 10554 } 10555 10556 return item; 10557 } 10558 10559 /** 10560 * Remove an item from the list 10561 * @param {List.Item} item 10562 */ 10563 removeItem(item) { 10564 // Confirm delete 10565 const confirmMsg = this.schema.confirmDelete; 10566 if (confirmMsg && !confirm(confirmMsg)) { 10567 // eslint-disable-line no-alert 10568 return; 10569 } 10570 10571 const index = _.indexOf(this.items, item); 10572 10573 this.items[index].remove(); 10574 this.items.splice(index, 1); 10575 if (this.isObjectType) { 10576 let prev = index - 1 < 0 ? 0 : index - 1; 10577 this.$tab.children().eq(index).remove(); 10578 if (this.items.length > 0) { 10579 this.$tab.find('a[href="#tab-' + this.items[prev].cid + '"]').tab('show'); 10580 } 10581 } 10582 10583 if (item.addEventTriggered) { 10584 this.trigger('remove', this, item.editor); 10585 this.trigger('change', this); 10586 } 10587 } 10588 10589 /** 10590 * Move an item in the list 10591 * @param {List.Item} item 10592 * @param {String} direction 10593 */ 10594 moveItem(item, direction) { 10595 const index = _.indexOf(this.items, item); 10596 const $currentPane = this.$list.children().eq(index); 10597 let moveIndex = index - 1; 10598 10599 if (direction === 'left') { 10600 $currentPane.insertBefore($currentPane.prev()); 10601 } else if (direction === 'right') { 10602 $currentPane.insertAfter($currentPane.next()); 10603 moveIndex++; 10604 } 10605 10606 if (this.isObjectType) { 10607 const $currentTab = this.$tab.children().eq(index); 10608 if (direction === 'left') { 10609 $currentTab.insertBefore($currentTab.prev()); 10610 } else if (direction === 'right') { 10611 $currentTab.insertAfter($currentTab.next()); 10612 } 10613 } 10614 10615 this.items.splice(moveIndex, 2, this.items[moveIndex + 1], this.items[moveIndex]); 10616 } 10617 10618 getValue() { 10619 const values = _.map(this.items, function (item) { 10620 return item.getValue(); 10621 }); 10622 10623 // Filter empty items 10624 return _.without(values, undefined, ''); 10625 } 10626 10627 setValue(value) { 10628 this.value = value; 10629 this.render(); 10630 } 10631 10632 focus() { 10633 if (this.hasFocus) return; 10634 10635 if (this.items[0]) this.items[0].editor.focus(); 10636 } 10637 10638 blur() { 10639 if (!this.hasFocus) return; 10640 10641 var focusedItem = _.find(this.items, function (item) { 10642 return item.editor.hasFocus; 10643 }); 10644 10645 if (focusedItem) focusedItem.editor.blur(); 10646 } 10647 10648 /** 10649 * Override default remove function in order to remove item views 10650 */ 10651 remove() { 10652 _.invoke(this.items, 'remove'); 10653 10654 _backbone2.default.Form.editors.Base.prototype.remove.call(this); 10655 } 10656 10657 /** 10658 * Run validation 10659 * 10660 * @return {Object|Null} 10661 */ 10662 validate() { 10663 if (!this.validators) return null; 10664 10665 // Collect errors 10666 const errors = _.map(this.items, function (item) { 10667 return item.validate(); 10668 }); 10669 10670 // Check if any item has errors 10671 const hasErrors = Boolean(_.compact(errors).length); 10672 if (!hasErrors) return null; 10673 10674 // If so create a shared error 10675 var fieldError = { 10676 type: 'list', 10677 message: 'Some of the items in the list failed validation', 10678 errors 10679 }; 10680 10681 return fieldError; 10682 } 10683 }; 10684 10685 /** 10686 * A single item in the list 10687 * 10688 * @param {editors.List} options.list The List editor instance this item belongs to 10689 * @param {Function} options.Editor Editor constructor function 10690 * @param {String} options.key Model key 10691 * @param {Mixed} options.value Value 10692 * @param {Object} options.schema Field schema 10693 */ 10694 /* global $ _ confirm*/ 10695 _backbone2.default.Form.editors.List.Item = class ListItem extends _backbone2.default.Form.editors.Base { 10696 10697 get events() { 10698 return { 10699 'click [data-action="remove"]': event => { 10700 event.stopPropagation(); 10701 event.preventDefault(); 10702 this.list.removeItem(this); 10703 }, 10704 'click [data-action="move-left"]': event => { 10705 event.stopPropagation(); 10706 event.preventDefault(); 10707 this.list.moveItem(this, 'left'); 10708 }, 10709 'click [data-action="move-right"]': event => { 10710 event.stopPropagation(); 10711 event.preventDefault(); 10712 this.list.moveItem(this, 'right'); 10713 }, 10714 'keydown input[type=text]': event => { 10715 if (event.keyCode !== 13) return; 10716 event.stopPropagation(); 10717 event.preventDefault(); 10718 this.list.addItem(); 10719 this.list.$list.find('> li:last input').focus(); 10720 } 10721 }; 10722 } 10723 10724 static template() { 10725 return _.template('<div style="margin-bottom: 5px">' + ' <span data-editor></span>' + ' <button type="button" data-action="move-left">∧ up</button>' + ' <button type="button" data-action="move-right">∨ down</button>' + ' <button type="button" data-action="remove">× delete</button>' + '</div>', _backbone2.default.Form.templateSettings)(); 10726 } 10727 10728 static objectTemplate(data) { 10729 return _.template('<div role="tabpanel" class="list-tab-pane tab-pane fade" id="tab-<%= cid %>">' + ' <div class="object-list-tab-pane">' + ' <div class="tab-pane-action">' + ' <a class="tab-pane-move-left" data-action="move-left">' + ' <span class="fa fa-angle-left"></span> Move Left' + ' </a>' + ' <a class="tab-pane-move-right" data-action="move-right">' + ' Move Right <span class="fa fa-angle-right"></span>' + ' </a>' + ' </div>' + ' <span data-editor></span>' + ' </div>' + '</div>', _backbone2.default.Form.templateSettings)(data); 10730 } 10731 10732 static errorClassName() { 10733 return 'error'; 10734 } 10735 10736 constructor(options) { 10737 super(options); 10738 10739 this.list = options.list; 10740 this.schema = options.schema || this.list.schema; 10741 this.value = options.value; 10742 this.Editor = options.Editor || _backbone2.default.Form.editors.Text; 10743 this.key = options.key; 10744 this.template = options.template || this.schema.itemTemplate || this.constructor.template; 10745 this.errorClassName = options.errorClassName || this.constructor.errorClassName; 10746 this.form = options.form; 10747 } 10748 10749 render() { 10750 // Create editor 10751 this.editor = new this.Editor({ 10752 key: this.key, 10753 schema: this.schema, 10754 value: this.value, 10755 list: this.list, 10756 item: this, 10757 form: this.form 10758 }).render(); 10759 10760 // Create main element 10761 const $el = this.list.isObjectType ? $($.trim(this.constructor.objectTemplate({ cid: this.cid }))) : $($.trim(this.template())); 10762 10763 $el.find('[data-editor]').append(this.editor.el); 10764 10765 // Replace the entire element so there isn't a wrapper tag 10766 this.setElement($el); 10767 10768 return this; 10769 } 10770 10771 getValue() { 10772 return this.editor.getValue(); 10773 } 10774 10775 setValue(value) { 10776 this.editor.setValue(value); 10777 } 10778 10779 focus() { 10780 this.editor.focus(); 10781 } 10782 10783 blur() { 10784 this.editor.blur(); 10785 } 10786 10787 remove() { 10788 this.editor.remove(); 10789 10790 _backbone2.default.View.prototype.remove.call(this); 10791 } 10792 10793 validate() { 10794 const value = this.getValue(); 10795 const formValues = this.list.form ? this.list.form.getValue() : {}; 10796 const validators = this.schema.validators; 10797 const getValidator = this.getValidator; 10798 10799 if (!validators) return null; 10800 10801 // Run through validators until an error is found 10802 let error = null; 10803 _.every(validators, function (validator) { 10804 error = getValidator(validator)(value, formValues); 10805 10806 return !error; 10807 }); 10808 10809 // Show/hide error 10810 if (error) { 10811 this.setError(error); 10812 } else { 10813 this.clearError(); 10814 } 10815 10816 // Return error to be aggregated by list 10817 return error ? error : null; 10818 } 10819 10820 /** 10821 * Show a validation error 10822 */ 10823 setError(err) { 10824 this.$el.addClass(this.errorClassName); 10825 this.$el.attr('title', err.message); 10826 } 10827 10828 /** 10829 * Hide validation errors 10830 */ 10831 clearError() { 10832 this.$el.removeClass(this.errorClassName); 10833 this.$el.attr('title', null); 10834 } 10835 }; 10836 10837 _backbone2.default.Form.editors.List.Object = _objectListEditor2.default; 10838 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(1))) 10839 10840 /***/ }, 10841 /* 44 */ 10842 /***/ function(module, exports, __webpack_require__) { 10843 10844 'use strict'; 10845 10846 var _backbone = __webpack_require__(2); 10847 10848 var _backbone2 = _interopRequireDefault(_backbone); 10849 10850 __webpack_require__(5); 10851 10852 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10853 10854 class NumberEditor extends _backbone2.default.Form.editors.Number { 10855 get defaultValue() { 10856 return ''; 10857 } 10858 10859 getValue() { 10860 const value = this.$el.val(); 10861 10862 return value === '' ? '' : parseFloat(value, 10); 10863 } 10864 } 10865 10866 _backbone2.default.Form.editors.Number = NumberEditor; 10867 10868 /***/ }, 10869 /* 45 */ 10870 /***/ function(module, exports, __webpack_require__) { 10871 10872 'use strict'; 10873 10874 Object.defineProperty(exports, "__esModule", { 10875 value: true 10876 }); 10877 10878 var _backbone = __webpack_require__(2); 10879 10880 var _backbone2 = _interopRequireDefault(_backbone); 10881 10882 __webpack_require__(5); 10883 10884 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10885 10886 class ObjectListEditor extends _backbone2.default.Form.editors.Base { 10887 get hasNestedForm() { 10888 return false; 10889 } 10890 10891 constructor(options, ...params) { 10892 super(options, ...params); 10893 10894 if (!this.form) throw new Error('Missing required option \'form"\''); 10895 if (!this.schema.subSchema) throw new Error('Missing required \'schema.subSchema\' option for Object editor'); 10896 } 10897 10898 render() { 10899 const NestedForm = this.form.constructor; 10900 this.nestedForm = new NestedForm({ 10901 schema: this.schema.subSchema, 10902 fields: this.schema.order || undefined, 10903 data: this.value, 10904 Field: NestedForm.NestedField 10905 }); 10906 10907 this.$el.html(this.nestedForm.render().el); 10908 10909 if (this.hasFocus) { 10910 this.trigger('blur', this); 10911 } 10912 10913 return this; 10914 } 10915 10916 getValue() { 10917 if (this.nestedForm) { 10918 return this.nestedForm.getValue(); 10919 } 10920 10921 return this.value; 10922 } 10923 10924 setValue(value) { 10925 this.value = value; 10926 10927 this.render(); 10928 } 10929 10930 focus() { 10931 if (this.hasFocus) { 10932 return; 10933 } 10934 10935 this.nestedForm.focus(); 10936 } 10937 10938 blur() { 10939 if (!this.hasFocus) { 10940 return; 10941 } 10942 10943 this.nestedForm.blur(); 10944 } 10945 10946 remove() { 10947 this.nestedForm.remove(); 10948 10949 super.remove(); 10950 } 10951 10952 validate() { 10953 return this.nestedForm.validate(); 10954 } 10955 } 10956 exports.default = ObjectListEditor; 10957 10958 /***/ }, 10959 /* 46 */ 10960 /***/ function(module, exports, __webpack_require__) { 10961 10962 'use strict'; 10963 10964 var _backbone = __webpack_require__(2); 10965 10966 var _backbone2 = _interopRequireDefault(_backbone); 10967 10968 __webpack_require__(5); 10969 10970 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 10971 10972 class SelectEditor extends _backbone2.default.Form.editors.Select { 10973 setValue(value) { 10974 if (value) { 10975 super.setValue(value); 10976 } 10977 } 10978 10979 render() { 10980 const searchThreshold = 6; 10981 const options = { 10982 container: 'body', 10983 width: '100%' 10984 }; 10985 const optionLength = Object.keys(this.schema.options).length; 10986 10987 if (this.schema.options instanceof Array) { 10988 this.setOptions(this.schema.options); 10989 } else { 10990 const sortedOptions = Object.keys(this.schema.options).sort((a, b) => this.schema.options[a] > this.schema.options[b]).reduce((acc, val) => { 10991 acc[val] = this.schema.options[val]; 10992 return acc; 10993 }, {}); 10994 10995 this.setOptions(sortedOptions); 10996 } 10997 10998 if (optionLength >= searchThreshold) { 10999 options.liveSearch = true; 11000 } 11001 this.$el.addClass('selectpicker'); 11002 setTimeout(() => { 11003 this.$el.selectpicker(options); 11004 }, 0); 11005 return this; 11006 } 11007 } 11008 11009 _backbone2.default.Form.editors.Select = SelectEditor; 11010 11011 /***/ }, 11012 /* 47 */ 11013 /***/ function(module, exports, __webpack_require__) { 11014 11015 'use strict'; 11016 11017 var _backbone = __webpack_require__(2); 11018 11019 var _backbone2 = _interopRequireDefault(_backbone); 11020 11021 var _underscore = __webpack_require__(4); 11022 11023 var _underscore2 = _interopRequireDefault(_underscore); 11024 11025 __webpack_require__(5); 11026 11027 __webpack_require__(25); 11028 11029 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11030 11031 const Form = _backbone2.default.Form; 11032 Form.template = _underscore2.default.template('<form class="gohan-form" role="form">' + ' <div class="required-description"><span class="form-asterisk">*</span> Indicates required field</div>' + ' <div data-fieldsets></div>' + '</form>'); 11033 11034 Form.Fieldset.template = _underscore2.default.template('<fieldset data-fields>' + ' <% if (legend) { %>' + ' <legend><%= legend %></legend>' + ' <% } %>' + '</fieldset>'); 11035 11036 Form.Field.template = _underscore2.default.template('<div class="nested-form-group field-<%= key %>">' + ' <label class="control-label" for="<%= editorId %>"><%= title %></label>' + ' <% if (help) { %>' + ' <span class="help-description"> <%= help %></span>' + ' <% } %>' + ' <div class="controls">' + ' <span data-editor></span>' + ' <div class="help-block"><span class="error" data-error></span></div>' + ' </div>' + '</div>'); 11037 11038 Form.NestedField = Form.Field.extend({ 11039 template: _underscore2.default.template('<div class="nested-form-group field-<%= key %>">' + ' <label class="control-label" for="<%= editorId %>"><%= title %></label>' + ' <% if (help) { %>' + ' <span class="help-description"> <%= help %></span>' + ' <% } %>' + ' <div class="controls">' + ' <span data-editor></span>' + ' <div class="help-block"><span class="error" data-error></span></div>' + ' </div>' + '</div>', null, Form.templateSettings) 11040 }); 11041 11042 Form.editors.Base.prototype.className = 'form-control'; 11043 Form.Field.errorClassName = 'has-error'; 11044 11045 if (Form.editors.List) { 11046 Form.editors.List.template = _underscore2.default.template('<div class="list-container">' + ' <ul class="list-sortable" data-items></ul>' + ' <a class="add-item" data-action="add"><span class="fa fa-plus-circle"></span> Add Item</a>' + '</div>'); 11047 11048 Form.editors.List.Item.template = _underscore2.default.template('<li class="list-item-container">' + ' <div class="list-action">' + ' <span class="fa fa-minus-circle" data-action="remove" title="Remove Item"></span>' + ' </div>' + ' <div class="list-counter"></div>' + ' <div class="list-body">' + ' <span data-editor></span>' + ' <div class="help-block"><span class="error" data-error></span></div>' + ' </div>' + ' <div class="list-sort up">' + ' <a class="" data-action="move-left"><span class="fa fa-chevron-circle-up"></span>Up</a>' + ' </div>' + ' <div class="list-sort down">' + ' <a class="" data-action="move-right"><span class="fa fa-chevron-circle-down"></span>Down</a>' + ' </div>' + '</li>'); 11049 } 11050 11051 /***/ }, 11052 /* 48 */ 11053 /***/ function(module, exports, __webpack_require__) { 11054 11055 'use strict'; 11056 11057 var _backbone = __webpack_require__(2); 11058 11059 var _backbone2 = _interopRequireDefault(_backbone); 11060 11061 __webpack_require__(5); 11062 11063 var _jsYaml = __webpack_require__(10); 11064 11065 var _jsYaml2 = _interopRequireDefault(_jsYaml); 11066 11067 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11068 11069 _backbone2.default.Form.validators.errMessages.ipv4 = 'The specified IP address has an invalid format.'; 11070 _backbone2.default.Form.validators.errMessages.ipv6 = 'The specified IP address has an invalid format.'; 11071 _backbone2.default.Form.validators.errMessages.ipv4mask = 'The specified IP mask has an invalid format.'; 11072 _backbone2.default.Form.validators.errMessages.cidr = 'The specified CIDR has an invalid format.'; 11073 _backbone2.default.Form.validators.errMessages.mac = 'The specified MAC address has an invalid format.'; 11074 _backbone2.default.Form.validators.errMessages.uuid = 'The specified UUID has an invalid format.'; 11075 _backbone2.default.Form.validators.errMessages.port = 'The specified port has an invalid format.'; 11076 _backbone2.default.Form.validators.errMessages.hostname = 'The specified hostname has an invalid format.'; 11077 _backbone2.default.Form.validators.errMessages.uri = 'The specified uri has an invalid format.'; 11078 _backbone2.default.Form.validators.errMessages['cidr-or-ipv4'] = 'The specified CIDR or IP has an invalid format.'; 11079 _backbone2.default.Form.validators.errMessages.yaml = 'The specified yaml has an invalid format.'; 11080 11081 _backbone2.default.Form.validators.ipv4 = function ipv4(options) { 11082 options = Object.assign({ 11083 type: 'ipv4', 11084 message: this.errMessages.ipv4 11085 }, options); 11086 11087 return value => { 11088 const validation = new RegExp('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$').test(value); 11089 11090 options.value = value; 11091 11092 if (!validation && value) { 11093 return { 11094 type: options.type, 11095 message: options.message 11096 }; 11097 } 11098 }; 11099 }; 11100 11101 _backbone2.default.Form.validators.ipv6 = function ipv6(options) { 11102 options = Object.assign({ 11103 type: 'ipv6', 11104 message: this.errMessages.ipv6 11105 }, options); 11106 11107 return value => { 11108 const validation = new RegExp('(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]' + '{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9' + 'a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4' + '}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a' + '-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))').test(value); 11109 11110 options.value = value; 11111 11112 if (!validation && value) { 11113 const error = { 11114 type: options.type, 11115 message: options.message 11116 }; 11117 11118 return error; 11119 } 11120 }; 11121 }; 11122 11123 _backbone2.default.Form.validators.ipv4mask = function ipv4mask(options) { 11124 options = Object.assign({ 11125 type: 'ipv4mask', 11126 message: this.errMessages.ipv4mask 11127 }, options); 11128 11129 return value => { 11130 const validation = new RegExp('^\\d+$').test(value) && value >= 1 && value <= 32; 11131 11132 options.value = value; 11133 11134 if (!validation && value) { 11135 const error = { 11136 type: options.type, 11137 message: options.message 11138 }; 11139 11140 return error; 11141 } 11142 }; 11143 }; 11144 11145 _backbone2.default.Form.validators.cidr = function cidr(options) { 11146 const ipv4Validator = _backbone2.default.Form.validators.ipv4(options); 11147 const ipv4MaskValidator = _backbone2.default.Form.validators.ipv4mask(options); 11148 11149 options = Object.assign({}, { 11150 type: 'cidr', 11151 message: this.errMessages.cidr 11152 }, options); 11153 11154 return value => { 11155 const parts = value.split('/'); 11156 const ip = parts[0]; 11157 const mask = parts[1]; 11158 const ipv4ValidatorError = ipv4Validator(ip); 11159 const ipv4MaskValidatorError = ipv4MaskValidator(mask); 11160 11161 options.value = value; 11162 11163 if (ipv4ValidatorError || ipv4MaskValidatorError) { 11164 const error = { 11165 type: options.type, 11166 message: options.message 11167 }; 11168 return error; 11169 } 11170 }; 11171 }; 11172 11173 _backbone2.default.Form.validators.mac = function mac(options) { 11174 options = Object.assign({ 11175 type: 'mac', 11176 message: this.errMessages.mac 11177 }, options); 11178 11179 return value => { 11180 const validation = new RegExp('^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$').test(value); 11181 11182 options.value = value; 11183 11184 if (!validation && value) { 11185 const error = { 11186 type: options.type, 11187 message: options.message 11188 }; 11189 11190 return error; 11191 } 11192 }; 11193 }; 11194 11195 _backbone2.default.Form.validators.uuid = function uuid(options) { 11196 options = Object.assign({ 11197 type: 'uuid', 11198 message: this.errMessages.uuid 11199 }, options); 11200 11201 return value => { 11202 const formats = [/^[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[1-5][A-Fa-f0-9]{3}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$/, /^[A-Fa-f0-9]{8}[A-Fa-f0-9]{4}[1-5][A-Fa-f0-9]{3}[A-Fa-f0-9]{4}[A-Fa-f0-9]{12}$/]; 11203 11204 const validation = formats.some(regexp => { 11205 return regexp.test(value); 11206 }); 11207 11208 options.value = value; 11209 11210 if (!validation && value) { 11211 const error = { 11212 type: options.type, 11213 message: options.message 11214 }; 11215 11216 return error; 11217 } 11218 }; 11219 }; 11220 11221 _backbone2.default.Form.validators.port = function port(options) { 11222 options = Object.assign({ 11223 type: 'port', 11224 message: this.errMessages.port 11225 }, options); 11226 11227 return value => { 11228 const validation = new RegExp('^\\d+$').test(value) && value >= 1 && value <= 65535; 11229 11230 options.value = value; 11231 11232 if (!validation && value) { 11233 const error = { 11234 type: options.type, 11235 message: options.message 11236 }; 11237 11238 return error; 11239 } 11240 }; 11241 }; 11242 11243 _backbone2.default.Form.validators.hostname = function hostname(options) { 11244 options = Object.assign({ 11245 type: 'hostname', 11246 message: this.errMessages.hostname 11247 }, options); 11248 11249 return value => { 11250 const validation = new RegExp('^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$').test(value); 11251 11252 options.value = value; 11253 11254 if (!validation && value) { 11255 const error = { 11256 type: options.type, 11257 message: options.message 11258 }; 11259 11260 return error; 11261 } 11262 }; 11263 }; 11264 11265 _backbone2.default.Form.validators.uri = function uri(options) { 11266 options = Object.assign({ 11267 type: 'uri', 11268 message: this.errMessages.uri 11269 }, options); 11270 11271 return value => { 11272 const validation = new RegExp('([A-Za-z][A-Za-z0-9+\\-.]*):(?:(//)(?:((?:[A-Za-z0-9\\-._~!$&\'()*+,;=:]|%[0-9A-Fa-f]{2})*)@)?((?:\\[(?:(?:(' + '?:(?:[0-9A-Fa-f]{1,4}:){6}|::(?:[0-9A-Fa-f]{1,4}:){5}|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}|(?:(?:' + '[0-9A-Fa-f]{1,4}:){0,1}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}|(?:(?:[0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]' + '{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}|(?:(?:[0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:|(?:(?:[' + '0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})?::)(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:25[0-5]|2[0-4][0-9]|[0' + '1]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|(?:(?:[0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4' + '})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})?::)|[Vv][0-9A-Fa-f]+\\.[A-Za-z0-9\\-._~' + '!$&\'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]' + '?)|(?:[A-Za-z0-9\\-._~!$&\'()*+,;=]|%[0-9A-Fa-f]{2})*))(?::([0-9]*))?((?:/(?:[A-Za-z0-9\\-._~!$&\'()*+,;=:@]' + '|%[0-9A-Fa-f]{2})*)*)|/((?:(?:[A-Za-z0-9\\-._~!$&\'()*+,;=:@]|%[0-9A-Fa-f]{2})+(?:/(?:[A-Za-z0-9\\-._~!$&\'(' + ')*+,;=:@]|%[0-9A-Fa-f]{2})*)*)?)|((?:[A-Za-z0-9\\-._~!$&\'()*+,;=:@]|%[0-9A-Fa-f]{2})+(?:/(?:[A-Za-z0-9\\-._' + '~!$&\'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*)|)(?:\\?((?:[A-Za-z0-9\\-._~!$&\'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*))?(?:\\' + '#((?:[A-Za-z0-9\\-._~!$&\'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*))?').test(value); 11273 11274 options.value = value; 11275 11276 if (!validation && value) { 11277 const error = { 11278 type: options.type, 11279 message: options.message 11280 }; 11281 11282 return error; 11283 } 11284 }; 11285 }; 11286 11287 _backbone2.default.Form.validators['cidr-or-ipv4'] = function cidrOrIpv4(options) { 11288 const ipv4Validator = _backbone2.default.Form.validators.ipv4(options); 11289 const ipv4MaskValidator = _backbone2.default.Form.validators.ipv4mask(options); 11290 11291 options = Object.assign({}, { 11292 type: 'cidr-or-ipv4', 11293 message: this.errMessages['cidr-or-ipv4'] 11294 }, options); 11295 11296 return value => { 11297 const parts = value.split('/'); 11298 const ip = parts[0]; 11299 const mask = parts[1]; 11300 const ipv4ValidatorError = ipv4Validator(ip); 11301 const ipv4MaskValidatorError = ipv4MaskValidator(mask); 11302 11303 options.value = value; 11304 11305 if (!ipv4ValidatorError && parts.length === 1) { 11306 return; 11307 } else if (!(ipv4ValidatorError || ipv4MaskValidatorError) && parts.length === 2) { 11308 return; 11309 } 11310 11311 const error = { 11312 type: options.type, 11313 message: options.message 11314 }; 11315 return error; 11316 }; 11317 }; 11318 11319 _backbone2.default.Form.validators.yaml = function uri(options) { 11320 options = Object.assign({ 11321 type: 'yaml', 11322 message: this.errMessages.yaml 11323 }, options); 11324 11325 return value => { 11326 let validation; 11327 11328 try { 11329 let object = _jsYaml2.default.load(value); 11330 11331 if ((typeof object).toLowerCase() === 'object') { 11332 throw Error(); 11333 } 11334 } catch (err) { 11335 validation = err; 11336 } 11337 11338 options.value = value; 11339 11340 if (!validation && value) { 11341 const error = { 11342 type: options.type, 11343 message: options.message 11344 }; 11345 11346 return error; 11347 } 11348 }; 11349 }; 11350 11351 /***/ }, 11352 /* 49 */ 11353 /***/ function(module, exports, __webpack_require__) { 11354 11355 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 11356 11357 Object.defineProperty(exports, "__esModule", { 11358 value: true 11359 }); 11360 11361 var _backbone = __webpack_require__(2); 11362 11363 var _header = __webpack_require__(113); 11364 11365 var _header2 = _interopRequireDefault(_header); 11366 11367 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11368 11369 /** 11370 * Class contains logic of header view in application. 11371 * @class HeaderView 11372 * @extends View 11373 */ 11374 /* global window, $ */ 11375 class HeaderView extends _backbone.View { 11376 get tagName() { 11377 return 'div'; 11378 } 11379 get events() { 11380 return { 11381 'click [data-gohan="logout"]': 'logout', 11382 'click [data-gohan="change-tenant"]': 'changeTenant' 11383 }; 11384 } 11385 11386 /** 11387 * Constructs the object. 11388 * @constructor 11389 * @override View.constructor 11390 * @param {Object} options 11391 */ 11392 constructor(options) { 11393 super(options); 11394 this.config = options.config; 11395 } 11396 11397 /** 11398 * Logs out user and reloads page. 11399 */ 11400 logout() { 11401 this.model.unsetAuthData(); 11402 window.location.reload(); 11403 } 11404 11405 /** 11406 * Change Tenant 11407 */ 11408 changeTenant(event) { 11409 const tenant = $(event.currentTarget).data('tenant'); 11410 this.model.loginTenant(tenant).then(() => { 11411 window.location.reload(); 11412 }); 11413 } 11414 11415 /** 11416 * Renders component content. 11417 * @override View.render 11418 * @returns {HeaderView} 11419 */ 11420 render() { 11421 this.$el.html((0, _header2.default)({ 11422 config: this.config, 11423 username: this.model.userName(), 11424 authToken: this.model.authToken(), 11425 tenantName: this.model.tenantName(), 11426 tenants: this.model.tenants() 11427 })); 11428 return this; 11429 } 11430 } 11431 exports.default = HeaderView; 11432 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 11433 11434 /***/ }, 11435 /* 50 */ 11436 /***/ function(module, exports, __webpack_require__) { 11437 11438 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 11439 11440 Object.defineProperty(exports, "__esModule", { 11441 value: true 11442 }); 11443 11444 var _backbone = __webpack_require__(2); 11445 11446 var _errorView = __webpack_require__(9); 11447 11448 var _errorView2 = _interopRequireDefault(_errorView); 11449 11450 var _login = __webpack_require__(114); 11451 11452 var _login2 = _interopRequireDefault(_login); 11453 11454 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11455 11456 class LoginView extends _backbone.View { 11457 get tagName() { 11458 return 'div'; 11459 } 11460 get events() { 11461 return { 11462 'click [data-gohan="login"]': 'login' 11463 }; 11464 } 11465 11466 /** 11467 * Constructs the object. 11468 * @constructor 11469 * @extends View.constructor 11470 * @param {Object} options 11471 */ 11472 constructor(options) { 11473 super(options); 11474 11475 this.template = options.template || _login2.default; 11476 this.model = options.model; 11477 this.errorView = new _errorView2.default(); 11478 this.listenTo(this.model, 'change:authData', this.reload); 11479 } 11480 11481 /** 11482 * Reloads window on current history fragment. 11483 */ 11484 reload() { 11485 _backbone.history.loadUrl(_backbone.history.fragment); 11486 } 11487 11488 /** 11489 * Renders template to html element. 11490 * @returns {LoginView} 11491 */ 11492 render() { 11493 this.el.innerHTML = this.template({}); 11494 $('[data-gohan="error"]', this.el).append(this.errorView.el); 11495 return this; 11496 } 11497 11498 /** 11499 * Handles of click event on login button. 11500 * @param {Event} event 11501 */ 11502 login(event) { 11503 event.preventDefault(); 11504 event.currentTarget.disabled = true; 11505 11506 const id = this.$('#id').val(); 11507 const password = this.$('#password').val(); 11508 $('#alerts').empty(); 11509 this.model.login(id, password).then(tenants => { 11510 const tenant = tenants[0].name; 11511 this.model.loginTenant(tenant).catch(error => { 11512 this.errorView.render(...error); 11513 }); 11514 }).catch(error => { 11515 this.errorView.render(...error); 11516 event.currentTarget.disabled = false; 11517 }); 11518 } 11519 } 11520 exports.default = LoginView; /* global $ */ 11521 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 11522 11523 /***/ }, 11524 /* 51 */ 11525 /***/ function(module, exports, __webpack_require__) { 11526 11527 'use strict'; 11528 11529 Object.defineProperty(exports, "__esModule", { 11530 value: true 11531 }); 11532 11533 var _backbone = __webpack_require__(2); 11534 11535 var _loader = __webpack_require__(20); 11536 11537 var _loader2 = _interopRequireDefault(_loader); 11538 11539 var _sample = __webpack_require__(116); 11540 11541 var _sample2 = _interopRequireDefault(_sample); 11542 11543 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11544 11545 /** 11546 * Class contains logic of sample page view in application. 11547 * @class SampleView 11548 * @extends View 11549 */ 11550 class SampleView extends _backbone.View { 11551 get tagName() { 11552 return 'div'; 11553 } 11554 get className() { 11555 return 'sampleview'; 11556 } 11557 11558 /** 11559 * Constructs the object. 11560 * @constructor 11561 * @override View.constructor 11562 * @param {Object} options 11563 */ 11564 constructor(options) { 11565 super(options); 11566 this.app = options.app; 11567 11568 this.$el.html((0, _loader2.default)()); 11569 setTimeout(() => this.render(), 2000); // this was added for showing loading. 11570 11571 if (this.app) { 11572 this.app.router.changeTitle('Home'); 11573 this.app.breadCrumb.update([]); 11574 } 11575 } 11576 11577 /** 11578 * Renders component content. 11579 * @override View.render 11580 * @returns {SampleView} 11581 */ 11582 render() { 11583 this.$el.html((0, _sample2.default)()); 11584 return this; 11585 } 11586 11587 /** 11588 * Removes page content. 11589 */ 11590 close() { 11591 this.remove(); 11592 } 11593 } 11594 exports.default = SampleView; /* global setTimeout */ 11595 11596 /***/ }, 11597 /* 52 */ 11598 /***/ function(module, exports, __webpack_require__) { 11599 11600 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 11601 11602 Object.defineProperty(exports, "__esModule", { 11603 value: true 11604 }); 11605 11606 var _bootstrapDialog = __webpack_require__(13); 11607 11608 var _bootstrapDialog2 = _interopRequireDefault(_bootstrapDialog); 11609 11610 var _dialogView = __webpack_require__(16); 11611 11612 var _dialogView2 = _interopRequireDefault(_dialogView); 11613 11614 var _underscore = __webpack_require__(4); 11615 11616 var _underscore2 = _interopRequireDefault(_underscore); 11617 11618 var _jsYaml = __webpack_require__(10); 11619 11620 var _jsYaml2 = _interopRequireDefault(_jsYaml); 11621 11622 __webpack_require__(83); 11623 11624 __webpack_require__(18); 11625 11626 __webpack_require__(28); 11627 11628 __webpack_require__(86); 11629 11630 __webpack_require__(21); 11631 11632 __webpack_require__(24); 11633 11634 __webpack_require__(23); 11635 11636 __webpack_require__(22); 11637 11638 var _tableView = __webpack_require__(17); 11639 11640 var _tableView2 = _interopRequireDefault(_tableView); 11641 11642 var _schemaForm = __webpack_require__(117); 11643 11644 var _schemaForm2 = _interopRequireDefault(_schemaForm); 11645 11646 var _propertyForm = __webpack_require__(115); 11647 11648 var _propertyForm2 = _interopRequireDefault(_propertyForm); 11649 11650 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11651 11652 class SchemaView extends _tableView2.default { 11653 toLocal(data) { 11654 return data; 11655 } 11656 toServer(data) { 11657 return data; 11658 } 11659 dialogForm(action, formTitle, data, onsubmit) { 11660 this.schema.filterByAction(action, this.parentProperty).then(schema => { 11661 const onSubmit = values => { 11662 const propertiesOrder = []; 11663 const required = []; 11664 const properties = {}; 11665 11666 $('#properties_table tbody tr').each(function iterator() { 11667 const property = $(this).data('property'); 11668 const id = property.id; 11669 11670 if (id === undefined) { 11671 return; 11672 } 11673 11674 if (properties[id]) { 11675 return; 11676 } 11677 11678 propertiesOrder.push(property.id); 11679 11680 if (property.required) { 11681 required.push(id); 11682 } 11683 11684 delete property.id; 11685 delete property.required; 11686 properties[id] = property; 11687 }); 11688 11689 values.schema = { 11690 type: 'object', 11691 propertiesOrder, 11692 required, 11693 properties 11694 }; 11695 11696 onsubmit(values); 11697 }; 11698 11699 schema.additionalForm = ['*']; 11700 schema.propertiesOrder = ['id', 'singular', 'plural', 'title', 'description', 'parent', 'namespace', 'prefix']; 11701 schema.required = []; 11702 11703 const propertyColumns = [{ 11704 id: 'title', 11705 type: 'string' 11706 }, { 11707 id: 'type', 11708 type: 'string', 11709 enum: ['string', 'boolean', 'integer', 'number', 'array', 'object'] 11710 }, { 11711 id: 'description', 11712 type: 'string' 11713 }, { 11714 id: 'required', 11715 type: 'checkbox' 11716 }]; 11717 const properties = []; 11718 11719 if (data.schema === undefined) { 11720 data.schema = { 11721 properties: { 11722 id: { 11723 title: 'ID', 11724 type: 'string', 11725 description: 'ID', 11726 permission: ['create'], 11727 view: ['detail'] 11728 }, 11729 name: { 11730 title: 'Name', 11731 type: 'string', 11732 description: 'Name', 11733 permission: ['create', 'update'] 11734 }, 11735 description: { 11736 title: 'Description', 11737 type: 'string', 11738 description: 'Description', 11739 permission: ['create', 'update'] 11740 }, 11741 tenant_id: { // eslint-disable-line camelcase 11742 title: 'Tenant ID', 11743 type: 'string', 11744 description: 'Tenant ID', 11745 permission: ['create'], 11746 view: ['detail'] 11747 } 11748 }, 11749 propertiesOrder: ['id', 'name', 'description', 'tenant_id'] 11750 }; 11751 } 11752 11753 this.dialog = new _dialogView2.default({ 11754 action, 11755 formTitle, 11756 data, 11757 fields: schema.propertiesOrder, 11758 onsubmit: onSubmit, 11759 unformattedSchema: this.schema, 11760 schema: this.schema.toFormJSON(schema) 11761 }); 11762 11763 this.dialog.render(); 11764 11765 this.dialog.form.$el.append($((0, _schemaForm2.default)({ 11766 propertyColumns 11767 }))); 11768 11769 $('#properties_table tbody', this.dialog.form.$el).sortable(); 11770 11771 const dataSchema = data.schema || {}; 11772 11773 for (let id of dataSchema.propertiesOrder) { 11774 const property = _underscore2.default.extend({}, dataSchema.properties[id]); 11775 11776 if (property === undefined) { 11777 return; 11778 } 11779 11780 let required = false; 11781 11782 if (dataSchema.required && dataSchema.required.indexOf(id) >= 0) { 11783 required = true; 11784 } 11785 11786 property.id = id; 11787 property.required = required; 11788 properties.push(property); 11789 } 11790 11791 const defaultProperty = { type: 'string' }; 11792 11793 properties.push(_underscore2.default.extend({}, defaultProperty)); 11794 11795 const addNewRow = property => { 11796 const $newRow = $((0, _propertyForm2.default)({ 11797 propertyColumns, 11798 property 11799 })); 11800 11801 $('.delete', $newRow).on('click', function onClick() { 11802 if (!window.confirm('Are you sure to delete?')) { 11803 // eslint-disable-line no-alert 11804 return; 11805 } 11806 $(this).off('click'); 11807 $(this).parent().parent().remove(); 11808 }); 11809 $('.id_form', $newRow).change(ensureNewRow); 11810 $('#properties_table tbody', this.dialog.form.$el).append($newRow); 11811 $('#id', $newRow).change(function onChange() { 11812 property.id = $(this).val(); 11813 }); 11814 $newRow.data('property', property); 11815 11816 for (let column of propertyColumns) { 11817 $('#' + column.id, $newRow).change(function onChange() { 11818 if (column.type === 'checkbox') { 11819 property[column.id] = $(this).is(':checked'); 11820 } else { 11821 property[column.id] = $(this).val(); 11822 } 11823 }); 11824 } 11825 $('button#detail', $newRow).click(() => { 11826 const $detailPane = $('<div style="width:500px;height:200px;"></div>'); 11827 const ace = window.ace; 11828 const editor = ace.edit($detailPane.get(0)); 11829 11830 editor.getSession().setNewLineMode('unix'); 11831 editor.setTheme('ace/theme/monokai'); 11832 editor.getSession().setMode('ace/mode/yaml'); 11833 editor.getSession().setTabSize(2); 11834 editor.$blockScrolling = 'Infinity'; 11835 11836 const yaml = _jsYaml2.default.safeDump(property); 11837 11838 editor.getSession().setValue(yaml); 11839 _bootstrapDialog2.default.show({ 11840 type: _bootstrapDialog2.default.TYPE_DEFAULT, 11841 title: 'Property Detail', 11842 closeByKeyboard: false, 11843 message: $detailPane, 11844 spinicon: 'glyphicon glyphicon-refresh', 11845 onshown: () => { 11846 $('.modal-body').css({ 11847 'max-height': $(window).height() - 200 + 'px' 11848 }); 11849 }, 11850 buttons: [{ 11851 id: 'submit', 11852 label: 'Submit', 11853 cssClass: 'btn-primary btn-raised btn-material-blue-600', 11854 action: function action(dialog) { 11855 const yaml = editor.getSession().getValue(); 11856 const data = _jsYaml2.default.safeLoad(yaml); 11857 const $propertiesTable = $($('#properties_table tbody tr').get(properties.indexOf(property))); 11858 11859 for (let key in property) { 11860 delete property[key]; 11861 } 11862 11863 for (let key in data) { 11864 property[key] = data[key]; 11865 } 11866 11867 for (let key in property) { 11868 let value = property[key]; 11869 11870 if (typeof value === 'boolean') { 11871 $propertiesTable.find('#' + key).prop('checked', value); 11872 } else { 11873 $propertiesTable.find('#' + key).val(value); 11874 } 11875 } 11876 dialog.close(); 11877 } 11878 }] 11879 }); 11880 }); 11881 }; 11882 const ensureNewRow = () => { 11883 let requireRow = true; 11884 11885 $('.id_form', this.dialog.form.$el).each(function iterator() { 11886 if ($(this).val() === '\'\'') { 11887 requireRow = false; 11888 } 11889 }); 11890 11891 if (requireRow) { 11892 addNewRow(Object.assign({}, defaultProperty)); 11893 } 11894 }; 11895 11896 for (let property of properties) { 11897 addNewRow(property); 11898 } 11899 }); 11900 } 11901 } 11902 exports.default = SchemaView; /* global window, $ */ 11903 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 11904 11905 /***/ }, 11906 /* 53 */ 11907 /***/ function(module, exports, __webpack_require__) { 11908 11909 'use strict'; 11910 11911 Object.defineProperty(exports, "__esModule", { 11912 value: true 11913 }); 11914 11915 var _backbone = __webpack_require__(2); 11916 11917 var _sideviewItem = __webpack_require__(118); 11918 11919 var _sideviewItem2 = _interopRequireDefault(_sideviewItem); 11920 11921 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11922 11923 /** 11924 * Class contains logic of sidebar item view in application. 11925 * @class SidebarItemView 11926 * @extends View 11927 */ 11928 class SidebarItemView extends _backbone.View { 11929 get tagName() { 11930 return 'li'; 11931 } 11932 11933 /** 11934 * Constructs the object. 11935 * @constructor 11936 * @override View.constructor 11937 * @param {Object} options 11938 */ 11939 constructor(options) { 11940 super(options); 11941 11942 this.listenTo(this.model, 'change', this.render); 11943 this.listenTo(this.model, 'remove', this.remove); 11944 this.$el.addClass('withripple'); 11945 this.$el.addClass(this.model.get('class')); 11946 } 11947 11948 /** 11949 * Renders component content. 11950 * @override View.render 11951 * @returns {SidebarItemView} 11952 */ 11953 render() { 11954 this.$el.html((0, _sideviewItem2.default)({ 11955 source: this.model.toJSON() 11956 })); 11957 return this; 11958 } 11959 } 11960 exports.default = SidebarItemView; 11961 11962 /***/ }, 11963 /* 54 */ 11964 /***/ function(module, exports, __webpack_require__) { 11965 11966 /* WEBPACK VAR INJECTION */(function($) {'use strict'; 11967 11968 Object.defineProperty(exports, "__esModule", { 11969 value: true 11970 }); 11971 11972 var _backbone = __webpack_require__(2); 11973 11974 var _sidebarItemView = __webpack_require__(53); 11975 11976 var _sidebarItemView2 = _interopRequireDefault(_sidebarItemView); 11977 11978 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11979 11980 /** 11981 * Class contains logic of sidebar view in application. 11982 * @class SidebarView 11983 * @extends View 11984 */ 11985 /* global $ */ 11986 class SidebarView extends _backbone.View { 11987 get tagName() { 11988 return 'ul'; 11989 } 11990 get className() { 11991 return 'nav nav-sidebar'; 11992 } 11993 11994 /** 11995 * Constructs the object. 11996 * @constructor 11997 * @override View.constructor 11998 * @param {Object} options 11999 */ 12000 constructor(options) { 12001 super(options); 12002 12003 this.schemas = options.schemas; 12004 this.router = options.app.router; 12005 this.listenTo(this.collection, 'add', this.append); 12006 this.router.on('route', this.onRoute.bind(this)); 12007 } 12008 12009 /** 12010 * Handles on route event. 12011 * Selects item in menu, by url fragment. 12012 */ 12013 onRoute() { 12014 const model = this.collection.where({ path: '/' + _backbone.history.getFragment() })[0]; 12015 12016 this.$('.active').removeClass('active'); 12017 12018 if (model === undefined) { 12019 return; 12020 } 12021 const index = this.collection.indexOf(model); 12022 12023 $(this.$el.children()[index]).addClass('active'); 12024 } 12025 12026 /** 12027 * Appends model and create sidebar item. 12028 * @param {Model} model 12029 */ 12030 append(model) { 12031 const itemView = new _sidebarItemView2.default({ 12032 model 12033 }).render(); 12034 const index = this.collection.indexOf(model); 12035 12036 if (index === 0) { 12037 this.$el.prepend(itemView.el); 12038 } else { 12039 itemView.$el.insertAfter(this.$el.children()[index - 1]); 12040 } 12041 } 12042 12043 /** 12044 * Renders component content. 12045 * @override View.render 12046 * @returns {SidebarView} 12047 */ 12048 render() { 12049 this.collection.each(function iterator(model) { 12050 this.append(model); 12051 }, this); 12052 return this; 12053 } 12054 } 12055 exports.default = SidebarView; 12056 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 12057 12058 /***/ }, 12059 /* 55 */ 12060 /***/ function(module, exports, __webpack_require__) { 12061 12062 /* WEBPACK VAR INJECTION */(function(global, $) {/** 12063 * Backbone Forms v0.14.1 12064 * 12065 * Copyright (c) 2014 Charles Davison, Pow Media Ltd 12066 * 12067 * License and more information at: 12068 * http://github.com/powmedia/backbone-forms 12069 */ 12070 ;(function(root) { 12071 12072 //DEPENDENCIES 12073 //CommonJS 12074 if (true) { 12075 var _ = root._ || __webpack_require__(4), 12076 Backbone = root.Backbone || __webpack_require__(32); 12077 } 12078 12079 //Browser 12080 else { 12081 var _ = root._, 12082 Backbone = root.Backbone; 12083 } 12084 12085 12086 //SOURCE 12087 //================================================================================================== 12088 //FORM 12089 //================================================================================================== 12090 12091 var Form = Backbone.View.extend({ 12092 12093 events: { 12094 'submit': function(event) { 12095 this.trigger('submit', event); 12096 } 12097 }, 12098 12099 /** 12100 * Constructor 12101 * 12102 * @param {Object} [options.schema] 12103 * @param {Backbone.Model} [options.model] 12104 * @param {Object} [options.data] 12105 * @param {String[]|Object[]} [options.fieldsets] 12106 * @param {String[]} [options.fields] 12107 * @param {String} [options.idPrefix] 12108 * @param {Form.Field} [options.Field] 12109 * @param {Form.Fieldset} [options.Fieldset] 12110 * @param {Function} [options.template] 12111 * @param {Boolean|String} [options.submitButton] 12112 */ 12113 initialize: function(options) { 12114 var self = this; 12115 12116 //Merge default options 12117 options = this.options = _.extend({ 12118 submitButton: false 12119 }, options); 12120 12121 //Find the schema to use 12122 var schema = this.schema = (function() { 12123 //Prefer schema from options 12124 if (options.schema) return _.result(options, 'schema'); 12125 12126 //Then schema on model 12127 var model = options.model; 12128 if (model && model.schema) return _.result(model, 'schema'); 12129 12130 //Then built-in schema 12131 if (self.schema) return _.result(self, 'schema'); 12132 12133 //Fallback to empty schema 12134 return {}; 12135 })(); 12136 12137 //Store important data 12138 _.extend(this, _.pick(options, 'model', 'data', 'idPrefix', 'templateData')); 12139 12140 //Override defaults 12141 var constructor = this.constructor; 12142 this.template = options.template || this.template || constructor.template; 12143 this.Fieldset = options.Fieldset || this.Fieldset || constructor.Fieldset; 12144 this.Field = options.Field || this.Field || constructor.Field; 12145 this.NestedField = options.NestedField || this.NestedField || constructor.NestedField; 12146 12147 //Check which fields will be included (defaults to all) 12148 var selectedFields = this.selectedFields = options.fields || _.keys(schema); 12149 12150 //Create fields 12151 var fields = this.fields = {}; 12152 12153 _.each(selectedFields, function(key) { 12154 var fieldSchema = schema[key]; 12155 fields[key] = this.createField(key, fieldSchema); 12156 }, this); 12157 12158 //Create fieldsets 12159 var fieldsetSchema = options.fieldsets || _.result(this, 'fieldsets') || [selectedFields], 12160 fieldsets = this.fieldsets = []; 12161 12162 _.each(fieldsetSchema, function(itemSchema) { 12163 this.fieldsets.push(this.createFieldset(itemSchema)); 12164 }, this); 12165 }, 12166 12167 /** 12168 * Creates a Fieldset instance 12169 * 12170 * @param {String[]|Object[]} schema Fieldset schema 12171 * 12172 * @return {Form.Fieldset} 12173 */ 12174 createFieldset: function(schema) { 12175 var options = { 12176 schema: schema, 12177 fields: this.fields 12178 }; 12179 12180 return new this.Fieldset(options); 12181 }, 12182 12183 /** 12184 * Creates a Field instance 12185 * 12186 * @param {String} key 12187 * @param {Object} schema Field schema 12188 * 12189 * @return {Form.Field} 12190 */ 12191 createField: function(key, schema) { 12192 var options = { 12193 form: this, 12194 key: key, 12195 schema: schema, 12196 idPrefix: this.idPrefix 12197 }; 12198 12199 if (this.model) { 12200 options.model = this.model; 12201 } else if (this.data) { 12202 options.value = this.data[key]; 12203 } else { 12204 options.value = null; 12205 } 12206 12207 var field = new this.Field(options); 12208 12209 this.listenTo(field.editor, 'all', this.handleEditorEvent); 12210 12211 return field; 12212 }, 12213 12214 /** 12215 * Callback for when an editor event is fired. 12216 * Re-triggers events on the form as key:event and triggers additional form-level events 12217 * 12218 * @param {String} event 12219 * @param {Editor} editor 12220 */ 12221 handleEditorEvent: function(event, editor) { 12222 //Re-trigger editor events on the form 12223 var formEvent = editor.key+':'+event; 12224 12225 this.trigger.call(this, formEvent, this, editor, Array.prototype.slice.call(arguments, 2)); 12226 12227 //Trigger additional events 12228 switch (event) { 12229 case 'change': 12230 this.trigger('change', this); 12231 break; 12232 12233 case 'focus': 12234 if (!this.hasFocus) this.trigger('focus', this); 12235 break; 12236 12237 case 'blur': 12238 if (this.hasFocus) { 12239 //TODO: Is the timeout etc needed? 12240 var self = this; 12241 setTimeout(function() { 12242 var focusedField = _.find(self.fields, function(field) { 12243 return field.editor.hasFocus; 12244 }); 12245 12246 if (!focusedField) self.trigger('blur', self); 12247 }, 0); 12248 } 12249 break; 12250 } 12251 }, 12252 12253 templateData: function() { 12254 var options = this.options; 12255 12256 return { 12257 submitButton: options.submitButton 12258 } 12259 }, 12260 12261 render: function() { 12262 var self = this, 12263 fields = this.fields, 12264 $ = Backbone.$; 12265 12266 //Render form 12267 var $form = $($.trim(this.template(_.result(this, 'templateData')))); 12268 12269 //Render standalone editors 12270 $form.find('[data-editors]').add($form).each(function(i, el) { 12271 var $container = $(el), 12272 selection = $container.attr('data-editors'); 12273 12274 if (_.isUndefined(selection)) return; 12275 12276 //Work out which fields to include 12277 var keys = (selection == '*') 12278 ? self.selectedFields || _.keys(fields) 12279 : selection.split(','); 12280 12281 //Add them 12282 _.each(keys, function(key) { 12283 var field = fields[key]; 12284 12285 $container.append(field.editor.render().el); 12286 }); 12287 }); 12288 12289 //Render standalone fields 12290 $form.find('[data-fields]').add($form).each(function(i, el) { 12291 var $container = $(el), 12292 selection = $container.attr('data-fields'); 12293 12294 if (_.isUndefined(selection)) return; 12295 12296 //Work out which fields to include 12297 var keys = (selection == '*') 12298 ? self.selectedFields || _.keys(fields) 12299 : selection.split(','); 12300 12301 //Add them 12302 _.each(keys, function(key) { 12303 var field = fields[key]; 12304 12305 $container.append(field.render().el); 12306 }); 12307 }); 12308 12309 //Render fieldsets 12310 $form.find('[data-fieldsets]').add($form).each(function(i, el) { 12311 var $container = $(el), 12312 selection = $container.attr('data-fieldsets'); 12313 12314 if (_.isUndefined(selection)) return; 12315 12316 _.each(self.fieldsets, function(fieldset) { 12317 $container.append(fieldset.render().el); 12318 }); 12319 }); 12320 12321 //Set the main element 12322 this.setElement($form); 12323 12324 //Set class 12325 $form.addClass(this.className); 12326 12327 return this; 12328 }, 12329 12330 /** 12331 * Validate the data 12332 * 12333 * @return {Object} Validation errors 12334 */ 12335 validate: function(options) { 12336 var self = this, 12337 fields = this.fields, 12338 model = this.model, 12339 errors = {}; 12340 12341 options = options || {}; 12342 12343 //Collect errors from schema validation 12344 _.each(fields, function(field) { 12345 var error = field.validate(); 12346 if (error) { 12347 errors[field.key] = error; 12348 } 12349 }); 12350 12351 //Get errors from default Backbone model validator 12352 if (!options.skipModelValidate && model && model.validate) { 12353 var modelErrors = model.validate(this.getValue()); 12354 12355 if (modelErrors) { 12356 var isDictionary = _.isObject(modelErrors) && !_.isArray(modelErrors); 12357 12358 //If errors are not in object form then just store on the error object 12359 if (!isDictionary) { 12360 errors._others = errors._others || []; 12361 errors._others.push(modelErrors); 12362 } 12363 12364 //Merge programmatic errors (requires model.validate() to return an object e.g. { fieldKey: 'error' }) 12365 if (isDictionary) { 12366 _.each(modelErrors, function(val, key) { 12367 //Set error on field if there isn't one already 12368 if (fields[key] && !errors[key]) { 12369 fields[key].setError(val); 12370 errors[key] = val; 12371 } 12372 12373 else { 12374 //Otherwise add to '_others' key 12375 errors._others = errors._others || []; 12376 var tmpErr = {}; 12377 tmpErr[key] = val; 12378 errors._others.push(tmpErr); 12379 } 12380 }); 12381 } 12382 } 12383 } 12384 12385 return _.isEmpty(errors) ? null : errors; 12386 }, 12387 12388 /** 12389 * Update the model with all latest values. 12390 * 12391 * @param {Object} [options] Options to pass to Model#set (e.g. { silent: true }) 12392 * 12393 * @return {Object} Validation errors 12394 */ 12395 commit: function(options) { 12396 //Validate 12397 options = options || {}; 12398 12399 var validateOptions = { 12400 skipModelValidate: !options.validate 12401 }; 12402 12403 var errors = this.validate(validateOptions); 12404 if (errors) return errors; 12405 12406 //Commit 12407 var modelError; 12408 12409 var setOptions = _.extend({ 12410 error: function(model, e) { 12411 modelError = e; 12412 } 12413 }, options); 12414 12415 this.model.set(this.getValue(), setOptions); 12416 12417 if (modelError) return modelError; 12418 }, 12419 12420 /** 12421 * Get all the field values as an object. 12422 * Use this method when passing data instead of objects 12423 * 12424 * @param {String} [key] Specific field value to get 12425 */ 12426 getValue: function(key) { 12427 //Return only given key if specified 12428 if (key) return this.fields[key].getValue(); 12429 12430 //Otherwise return entire form 12431 var values = {}; 12432 _.each(this.fields, function(field) { 12433 values[field.key] = field.getValue(); 12434 }); 12435 12436 return values; 12437 }, 12438 12439 /** 12440 * Update field values, referenced by key 12441 * 12442 * @param {Object|String} key New values to set, or property to set 12443 * @param val Value to set 12444 */ 12445 setValue: function(prop, val) { 12446 var data = {}; 12447 if (typeof prop === 'string') { 12448 data[prop] = val; 12449 } else { 12450 data = prop; 12451 } 12452 12453 var key; 12454 for (key in this.schema) { 12455 if (data[key] !== undefined) { 12456 this.fields[key].setValue(data[key]); 12457 } 12458 } 12459 }, 12460 12461 /** 12462 * Returns the editor for a given field key 12463 * 12464 * @param {String} key 12465 * 12466 * @return {Editor} 12467 */ 12468 getEditor: function(key) { 12469 var field = this.fields[key]; 12470 if (!field) throw new Error('Field not found: '+key); 12471 12472 return field.editor; 12473 }, 12474 12475 /** 12476 * Gives the first editor in the form focus 12477 */ 12478 focus: function() { 12479 if (this.hasFocus) return; 12480 12481 //Get the first field 12482 var fieldset = this.fieldsets[0], 12483 field = fieldset.getFieldAt(0); 12484 12485 if (!field) return; 12486 12487 //Set focus 12488 field.editor.focus(); 12489 }, 12490 12491 /** 12492 * Removes focus from the currently focused editor 12493 */ 12494 blur: function() { 12495 if (!this.hasFocus) return; 12496 12497 var focusedField = _.find(this.fields, function(field) { 12498 return field.editor.hasFocus; 12499 }); 12500 12501 if (focusedField) focusedField.editor.blur(); 12502 }, 12503 12504 /** 12505 * Manages the hasFocus property 12506 * 12507 * @param {String} event 12508 */ 12509 trigger: function(event) { 12510 if (event === 'focus') { 12511 this.hasFocus = true; 12512 } 12513 else if (event === 'blur') { 12514 this.hasFocus = false; 12515 } 12516 12517 return Backbone.View.prototype.trigger.apply(this, arguments); 12518 }, 12519 12520 /** 12521 * Override default remove function in order to remove embedded views 12522 * 12523 * TODO: If editors are included directly with data-editors="x", they need to be removed 12524 * May be best to use XView to manage adding/removing views 12525 */ 12526 remove: function() { 12527 _.each(this.fieldsets, function(fieldset) { 12528 fieldset.remove(); 12529 }); 12530 12531 _.each(this.fields, function(field) { 12532 field.remove(); 12533 }); 12534 12535 return Backbone.View.prototype.remove.apply(this, arguments); 12536 } 12537 12538 }, { 12539 12540 //STATICS 12541 template: _.template('\ 12542 <form>\ 12543 <div data-fieldsets></div>\ 12544 <% if (submitButton) { %>\ 12545 <button type="submit"><%= submitButton %></button>\ 12546 <% } %>\ 12547 </form>\ 12548 ', null, this.templateSettings), 12549 12550 templateSettings: { 12551 evaluate: /<%([\s\S]+?)%>/g, 12552 interpolate: /<%=([\s\S]+?)%>/g, 12553 escape: /<%-([\s\S]+?)%>/g 12554 }, 12555 12556 editors: {} 12557 12558 }); 12559 12560 12561 //================================================================================================== 12562 //VALIDATORS 12563 //================================================================================================== 12564 12565 Form.validators = (function() { 12566 12567 var validators = {}; 12568 12569 validators.errMessages = { 12570 required: 'Required', 12571 regexp: 'Invalid', 12572 number: 'Must be a number', 12573 email: 'Invalid email address', 12574 url: 'Invalid URL', 12575 match: _.template('Must match field "<%= field %>"', null, Form.templateSettings) 12576 }; 12577 12578 validators.required = function(options) { 12579 options = _.extend({ 12580 type: 'required', 12581 message: this.errMessages.required 12582 }, options); 12583 12584 return function required(value) { 12585 options.value = value; 12586 12587 var err = { 12588 type: options.type, 12589 message: _.isFunction(options.message) ? options.message(options) : options.message 12590 }; 12591 12592 if (value === null || value === undefined || value === false || value === '') return err; 12593 }; 12594 }; 12595 12596 validators.regexp = function(options) { 12597 if (!options.regexp) throw new Error('Missing required "regexp" option for "regexp" validator'); 12598 12599 options = _.extend({ 12600 type: 'regexp', 12601 match: true, 12602 message: this.errMessages.regexp 12603 }, options); 12604 12605 return function regexp(value) { 12606 options.value = value; 12607 12608 var err = { 12609 type: options.type, 12610 message: _.isFunction(options.message) ? options.message(options) : options.message 12611 }; 12612 12613 //Don't check empty values (add a 'required' validator for this) 12614 if (value === null || value === undefined || value === '') return; 12615 12616 //Create RegExp from string if it's valid 12617 if ('string' === typeof options.regexp) options.regexp = new RegExp(options.regexp, options.flags); 12618 12619 if ((options.match) ? !options.regexp.test(value) : options.regexp.test(value)) return err; 12620 }; 12621 }; 12622 12623 validators.number = function(options) { 12624 options = _.extend({ 12625 type: 'number', 12626 message: this.errMessages.number, 12627 regexp: /^[0-9]*\.?[0-9]*?$/ 12628 }, options); 12629 12630 return validators.regexp(options); 12631 }; 12632 12633 validators.email = function(options) { 12634 options = _.extend({ 12635 type: 'email', 12636 message: this.errMessages.email, 12637 regexp: /^[\w\-]{1,}([\w\-\+.]{1,1}[\w\-]{1,}){0,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/ 12638 }, options); 12639 12640 return validators.regexp(options); 12641 }; 12642 12643 validators.url = function(options) { 12644 options = _.extend({ 12645 type: 'url', 12646 message: this.errMessages.url, 12647 regexp: /^(http|https):\/\/(([A-Z0-9][A-Z0-9_\-]*)(\.[A-Z0-9][A-Z0-9_\-]*)+)(:(\d+))?\/?/i 12648 }, options); 12649 12650 return validators.regexp(options); 12651 }; 12652 12653 validators.match = function(options) { 12654 if (!options.field) throw new Error('Missing required "field" options for "match" validator'); 12655 12656 options = _.extend({ 12657 type: 'match', 12658 message: this.errMessages.match 12659 }, options); 12660 12661 return function match(value, attrs) { 12662 options.value = value; 12663 12664 var err = { 12665 type: options.type, 12666 message: _.isFunction(options.message) ? options.message(options) : options.message 12667 }; 12668 12669 //Don't check empty values (add a 'required' validator for this) 12670 if (value === null || value === undefined || value === '') return; 12671 12672 if (value !== attrs[options.field]) return err; 12673 }; 12674 }; 12675 12676 12677 return validators; 12678 12679 })(); 12680 12681 12682 //================================================================================================== 12683 //FIELDSET 12684 //================================================================================================== 12685 12686 Form.Fieldset = Backbone.View.extend({ 12687 12688 /** 12689 * Constructor 12690 * 12691 * Valid fieldset schemas: 12692 * ['field1', 'field2'] 12693 * { legend: 'Some Fieldset', fields: ['field1', 'field2'] } 12694 * 12695 * @param {String[]|Object[]} options.schema Fieldset schema 12696 * @param {Object} options.fields Form fields 12697 */ 12698 initialize: function(options) { 12699 options = options || {}; 12700 12701 //Create the full fieldset schema, merging defaults etc. 12702 var schema = this.schema = this.createSchema(options.schema); 12703 12704 //Store the fields for this fieldset 12705 this.fields = _.pick(options.fields, schema.fields); 12706 12707 //Override defaults 12708 this.template = options.template || schema.template || this.template || this.constructor.template; 12709 }, 12710 12711 /** 12712 * Creates the full fieldset schema, normalising, merging defaults etc. 12713 * 12714 * @param {String[]|Object[]} schema 12715 * 12716 * @return {Object} 12717 */ 12718 createSchema: function(schema) { 12719 //Normalise to object 12720 if (_.isArray(schema)) { 12721 schema = { fields: schema }; 12722 } 12723 12724 //Add null legend to prevent template error 12725 schema.legend = schema.legend || null; 12726 12727 return schema; 12728 }, 12729 12730 /** 12731 * Returns the field for a given index 12732 * 12733 * @param {Number} index 12734 * 12735 * @return {Field} 12736 */ 12737 getFieldAt: function(index) { 12738 var key = this.schema.fields[index]; 12739 12740 return this.fields[key]; 12741 }, 12742 12743 /** 12744 * Returns data to pass to template 12745 * 12746 * @return {Object} 12747 */ 12748 templateData: function() { 12749 return this.schema; 12750 }, 12751 12752 /** 12753 * Renders the fieldset and fields 12754 * 12755 * @return {Fieldset} this 12756 */ 12757 render: function() { 12758 var schema = this.schema, 12759 fields = this.fields, 12760 $ = Backbone.$; 12761 12762 //Render fieldset 12763 var $fieldset = $($.trim(this.template(_.result(this, 'templateData')))); 12764 12765 //Render fields 12766 $fieldset.find('[data-fields]').add($fieldset).each(function(i, el) { 12767 var $container = $(el), 12768 selection = $container.attr('data-fields'); 12769 12770 if (_.isUndefined(selection)) return; 12771 12772 _.each(fields, function(field) { 12773 $container.append(field.render().el); 12774 }); 12775 }); 12776 12777 this.setElement($fieldset); 12778 12779 return this; 12780 }, 12781 12782 /** 12783 * Remove embedded views then self 12784 */ 12785 remove: function() { 12786 _.each(this.fields, function(field) { 12787 field.remove(); 12788 }); 12789 12790 Backbone.View.prototype.remove.call(this); 12791 } 12792 12793 }, { 12794 //STATICS 12795 12796 template: _.template('\ 12797 <fieldset data-fields>\ 12798 <% if (legend) { %>\ 12799 <legend><%= legend %></legend>\ 12800 <% } %>\ 12801 </fieldset>\ 12802 ', null, Form.templateSettings) 12803 12804 }); 12805 12806 12807 //================================================================================================== 12808 //FIELD 12809 //================================================================================================== 12810 12811 Form.Field = Backbone.View.extend({ 12812 12813 /** 12814 * Constructor 12815 * 12816 * @param {Object} options.key 12817 * @param {Object} options.form 12818 * @param {Object} [options.schema] 12819 * @param {Function} [options.schema.template] 12820 * @param {Backbone.Model} [options.model] 12821 * @param {Object} [options.value] 12822 * @param {String} [options.idPrefix] 12823 * @param {Function} [options.template] 12824 * @param {Function} [options.errorClassName] 12825 */ 12826 initialize: function(options) { 12827 options = options || {}; 12828 12829 //Store important data 12830 _.extend(this, _.pick(options, 'form', 'key', 'model', 'value', 'idPrefix')); 12831 12832 //Create the full field schema, merging defaults etc. 12833 var schema = this.schema = this.createSchema(options.schema); 12834 12835 //Override defaults 12836 this.template = options.template || schema.template || this.template || this.constructor.template; 12837 this.errorClassName = options.errorClassName || this.errorClassName || this.constructor.errorClassName; 12838 12839 //Create editor 12840 this.editor = this.createEditor(); 12841 }, 12842 12843 /** 12844 * Creates the full field schema, merging defaults etc. 12845 * 12846 * @param {Object|String} schema 12847 * 12848 * @return {Object} 12849 */ 12850 createSchema: function(schema) { 12851 if (_.isString(schema)) schema = { type: schema }; 12852 12853 //Set defaults 12854 schema = _.extend({ 12855 type: 'Text', 12856 title: this.createTitle() 12857 }, schema); 12858 12859 //Get the real constructor function i.e. if type is a string such as 'Text' 12860 schema.type = (_.isString(schema.type)) ? Form.editors[schema.type] : schema.type; 12861 12862 return schema; 12863 }, 12864 12865 /** 12866 * Creates the editor specified in the schema; either an editor string name or 12867 * a constructor function 12868 * 12869 * @return {View} 12870 */ 12871 createEditor: function() { 12872 var options = _.extend( 12873 _.pick(this, 'schema', 'form', 'key', 'model', 'value'), 12874 { id: this.createEditorId() } 12875 ); 12876 12877 var constructorFn = this.schema.type; 12878 12879 return new constructorFn(options); 12880 }, 12881 12882 /** 12883 * Creates the ID that will be assigned to the editor 12884 * 12885 * @return {String} 12886 */ 12887 createEditorId: function() { 12888 var prefix = this.idPrefix, 12889 id = this.key; 12890 12891 //Replace periods with underscores (e.g. for when using paths) 12892 id = id.replace(/\./g, '_'); 12893 12894 //If a specific ID prefix is set, use it 12895 if (_.isString(prefix) || _.isNumber(prefix)) return prefix + id; 12896 if (_.isNull(prefix)) return id; 12897 12898 //Otherwise, if there is a model use it's CID to avoid conflicts when multiple forms are on the page 12899 if (this.model) return this.model.cid + '_' + id; 12900 12901 return id; 12902 }, 12903 12904 /** 12905 * Create the default field title (label text) from the key name. 12906 * (Converts 'camelCase' to 'Camel Case') 12907 * 12908 * @return {String} 12909 */ 12910 createTitle: function() { 12911 var str = this.key; 12912 12913 //Add spaces 12914 str = str.replace(/([A-Z])/g, ' $1'); 12915 12916 //Uppercase first character 12917 str = str.replace(/^./, function(str) { return str.toUpperCase(); }); 12918 12919 return str; 12920 }, 12921 12922 /** 12923 * Returns the data to be passed to the template 12924 * 12925 * @return {Object} 12926 */ 12927 templateData: function() { 12928 var schema = this.schema; 12929 12930 return { 12931 help: schema.help || '', 12932 title: schema.title, 12933 fieldAttrs: schema.fieldAttrs, 12934 editorAttrs: schema.editorAttrs, 12935 key: this.key, 12936 editorId: this.editor.id 12937 }; 12938 }, 12939 12940 /** 12941 * Render the field and editor 12942 * 12943 * @return {Field} self 12944 */ 12945 render: function() { 12946 var schema = this.schema, 12947 editor = this.editor, 12948 $ = Backbone.$; 12949 12950 //Only render the editor if Hidden 12951 if (schema.type == Form.editors.Hidden) { 12952 return this.setElement(editor.render().el); 12953 } 12954 12955 //Render field 12956 var $field = $($.trim(this.template(_.result(this, 'templateData')))); 12957 12958 if (schema.fieldClass) $field.addClass(schema.fieldClass); 12959 if (schema.fieldAttrs) $field.attr(schema.fieldAttrs); 12960 12961 //Render editor 12962 $field.find('[data-editor]').add($field).each(function(i, el) { 12963 var $container = $(el), 12964 selection = $container.attr('data-editor'); 12965 12966 if (_.isUndefined(selection)) return; 12967 12968 $container.append(editor.render().el); 12969 }); 12970 12971 this.setElement($field); 12972 12973 return this; 12974 }, 12975 12976 /** 12977 * Check the validity of the field 12978 * 12979 * @return {String} 12980 */ 12981 validate: function() { 12982 var error = this.editor.validate(); 12983 12984 if (error) { 12985 this.setError(error.message); 12986 } else { 12987 this.clearError(); 12988 } 12989 12990 return error; 12991 }, 12992 12993 /** 12994 * Set the field into an error state, adding the error class and setting the error message 12995 * 12996 * @param {String} msg Error message 12997 */ 12998 setError: function(msg) { 12999 //Nested form editors (e.g. Object) set their errors internally 13000 if (this.editor.hasNestedForm) return; 13001 13002 //Add error CSS class 13003 this.$el.addClass(this.errorClassName); 13004 13005 //Set error message 13006 this.$('[data-error]').html(msg); 13007 }, 13008 13009 /** 13010 * Clear the error state and reset the help message 13011 */ 13012 clearError: function() { 13013 //Remove error CSS class 13014 this.$el.removeClass(this.errorClassName); 13015 13016 //Clear error message 13017 this.$('[data-error]').empty(); 13018 }, 13019 13020 /** 13021 * Update the model with the new value from the editor 13022 * 13023 * @return {Mixed} 13024 */ 13025 commit: function() { 13026 return this.editor.commit(); 13027 }, 13028 13029 /** 13030 * Get the value from the editor 13031 * 13032 * @return {Mixed} 13033 */ 13034 getValue: function() { 13035 return this.editor.getValue(); 13036 }, 13037 13038 /** 13039 * Set/change the value of the editor 13040 * 13041 * @param {Mixed} value 13042 */ 13043 setValue: function(value) { 13044 this.editor.setValue(value); 13045 }, 13046 13047 /** 13048 * Give the editor focus 13049 */ 13050 focus: function() { 13051 this.editor.focus(); 13052 }, 13053 13054 /** 13055 * Remove focus from the editor 13056 */ 13057 blur: function() { 13058 this.editor.blur(); 13059 }, 13060 13061 /** 13062 * Remove the field and editor views 13063 */ 13064 remove: function() { 13065 this.editor.remove(); 13066 13067 Backbone.View.prototype.remove.call(this); 13068 } 13069 13070 }, { 13071 //STATICS 13072 13073 template: _.template('\ 13074 <div>\ 13075 <label for="<%= editorId %>"><%= title %></label>\ 13076 <div>\ 13077 <span data-editor></span>\ 13078 <div data-error></div>\ 13079 <div><%= help %></div>\ 13080 </div>\ 13081 </div>\ 13082 ', null, Form.templateSettings), 13083 13084 /** 13085 * CSS class name added to the field when there is a validation error 13086 */ 13087 errorClassName: 'error' 13088 13089 }); 13090 13091 13092 //================================================================================================== 13093 //NESTEDFIELD 13094 //================================================================================================== 13095 13096 Form.NestedField = Form.Field.extend({ 13097 13098 template: _.template('\ 13099 <div>\ 13100 <span data-editor></span>\ 13101 <% if (help) { %>\ 13102 <div><%= help %></div>\ 13103 <% } %>\ 13104 <div data-error></div>\ 13105 </div>\ 13106 ', null, Form.templateSettings) 13107 13108 }); 13109 13110 /** 13111 * Base editor (interface). To be extended, not used directly 13112 * 13113 * @param {Object} options 13114 * @param {String} [options.id] Editor ID 13115 * @param {Model} [options.model] Use instead of value, and use commit() 13116 * @param {String} [options.key] The model attribute key. Required when using 'model' 13117 * @param {Mixed} [options.value] When not using a model. If neither provided, defaultValue will be used 13118 * @param {Object} [options.schema] Field schema; may be required by some editors 13119 * @param {Object} [options.validators] Validators; falls back to those stored on schema 13120 * @param {Object} [options.form] The form 13121 */ 13122 Form.Editor = Form.editors.Base = Backbone.View.extend({ 13123 13124 defaultValue: null, 13125 13126 hasFocus: false, 13127 13128 initialize: function(options) { 13129 var options = options || {}; 13130 13131 //Set initial value 13132 if (options.model) { 13133 if (!options.key) throw new Error("Missing option: 'key'"); 13134 13135 this.model = options.model; 13136 13137 this.value = this.model.get(options.key); 13138 } 13139 else if (options.value !== undefined) { 13140 this.value = options.value; 13141 } 13142 13143 if (this.value === undefined) this.value = this.defaultValue; 13144 13145 //Store important data 13146 _.extend(this, _.pick(options, 'key', 'form')); 13147 13148 var schema = this.schema = options.schema || {}; 13149 13150 this.validators = options.validators || schema.validators; 13151 13152 //Main attributes 13153 this.$el.attr('id', this.id); 13154 this.$el.attr('name', this.getName()); 13155 if (schema.editorClass) this.$el.addClass(schema.editorClass); 13156 if (schema.editorAttrs) this.$el.attr(schema.editorAttrs); 13157 }, 13158 13159 /** 13160 * Get the value for the form input 'name' attribute 13161 * 13162 * @return {String} 13163 * 13164 * @api private 13165 */ 13166 getName: function() { 13167 var key = this.key || ''; 13168 13169 //Replace periods with underscores (e.g. for when using paths) 13170 return key.replace(/\./g, '_'); 13171 }, 13172 13173 /** 13174 * Get editor value 13175 * Extend and override this method to reflect changes in the DOM 13176 * 13177 * @return {Mixed} 13178 */ 13179 getValue: function() { 13180 return this.value; 13181 }, 13182 13183 /** 13184 * Set editor value 13185 * Extend and override this method to reflect changes in the DOM 13186 * 13187 * @param {Mixed} value 13188 */ 13189 setValue: function(value) { 13190 this.value = value; 13191 }, 13192 13193 /** 13194 * Give the editor focus 13195 * Extend and override this method 13196 */ 13197 focus: function() { 13198 throw new Error('Not implemented'); 13199 }, 13200 13201 /** 13202 * Remove focus from the editor 13203 * Extend and override this method 13204 */ 13205 blur: function() { 13206 throw new Error('Not implemented'); 13207 }, 13208 13209 /** 13210 * Update the model with the current value 13211 * 13212 * @param {Object} [options] Options to pass to model.set() 13213 * @param {Boolean} [options.validate] Set to true to trigger built-in model validation 13214 * 13215 * @return {Mixed} error 13216 */ 13217 commit: function(options) { 13218 var error = this.validate(); 13219 if (error) return error; 13220 13221 this.listenTo(this.model, 'invalid', function(model, e) { 13222 error = e; 13223 }); 13224 this.model.set(this.key, this.getValue(), options); 13225 13226 if (error) return error; 13227 }, 13228 13229 /** 13230 * Check validity 13231 * 13232 * @return {Object|Undefined} 13233 */ 13234 validate: function() { 13235 var $el = this.$el, 13236 error = null, 13237 value = this.getValue(), 13238 formValues = this.form ? this.form.getValue() : {}, 13239 validators = this.validators, 13240 getValidator = this.getValidator; 13241 13242 if (validators) { 13243 //Run through validators until an error is found 13244 _.every(validators, function(validator) { 13245 error = getValidator(validator)(value, formValues); 13246 13247 return error ? false : true; 13248 }); 13249 } 13250 13251 return error; 13252 }, 13253 13254 /** 13255 * Set this.hasFocus, or call parent trigger() 13256 * 13257 * @param {String} event 13258 */ 13259 trigger: function(event) { 13260 if (event === 'focus') { 13261 this.hasFocus = true; 13262 } 13263 else if (event === 'blur') { 13264 this.hasFocus = false; 13265 } 13266 13267 return Backbone.View.prototype.trigger.apply(this, arguments); 13268 }, 13269 13270 /** 13271 * Returns a validation function based on the type defined in the schema 13272 * 13273 * @param {RegExp|String|Function} validator 13274 * @return {Function} 13275 */ 13276 getValidator: function(validator) { 13277 var validators = Form.validators; 13278 13279 //Convert regular expressions to validators 13280 if (_.isRegExp(validator)) { 13281 return validators.regexp({ regexp: validator }); 13282 } 13283 13284 //Use a built-in validator if given a string 13285 if (_.isString(validator)) { 13286 if (!validators[validator]) throw new Error('Validator "'+validator+'" not found'); 13287 13288 return validators[validator](); 13289 } 13290 13291 //Functions can be used directly 13292 if (_.isFunction(validator)) return validator; 13293 13294 //Use a customised built-in validator if given an object 13295 if (_.isObject(validator) && validator.type) { 13296 var config = validator; 13297 13298 return validators[config.type](config); 13299 } 13300 13301 //Unkown validator type 13302 throw new Error('Invalid validator: ' + validator); 13303 } 13304 }); 13305 13306 /** 13307 * Text 13308 * 13309 * Text input with focus, blur and change events 13310 */ 13311 Form.editors.Text = Form.Editor.extend({ 13312 13313 tagName: 'input', 13314 13315 defaultValue: '', 13316 13317 previousValue: '', 13318 13319 events: { 13320 'keyup': 'determineChange', 13321 'keypress': function(event) { 13322 var self = this; 13323 setTimeout(function() { 13324 self.determineChange(); 13325 }, 0); 13326 }, 13327 'select': function(event) { 13328 this.trigger('select', this); 13329 }, 13330 'focus': function(event) { 13331 this.trigger('focus', this); 13332 }, 13333 'blur': function(event) { 13334 this.trigger('blur', this); 13335 } 13336 }, 13337 13338 initialize: function(options) { 13339 Form.editors.Base.prototype.initialize.call(this, options); 13340 13341 var schema = this.schema; 13342 13343 //Allow customising text type (email, phone etc.) for HTML5 browsers 13344 var type = 'text'; 13345 13346 if (schema && schema.editorAttrs && schema.editorAttrs.type) type = schema.editorAttrs.type; 13347 if (schema && schema.dataType) type = schema.dataType; 13348 13349 this.$el.attr('type', type); 13350 }, 13351 13352 /** 13353 * Adds the editor to the DOM 13354 */ 13355 render: function() { 13356 this.setValue(this.value); 13357 13358 return this; 13359 }, 13360 13361 determineChange: function(event) { 13362 var currentValue = this.$el.val(); 13363 var changed = (currentValue !== this.previousValue); 13364 13365 if (changed) { 13366 this.previousValue = currentValue; 13367 13368 this.trigger('change', this); 13369 } 13370 }, 13371 13372 /** 13373 * Returns the current editor value 13374 * @return {String} 13375 */ 13376 getValue: function() { 13377 return this.$el.val(); 13378 }, 13379 13380 /** 13381 * Sets the value of the form element 13382 * @param {String} 13383 */ 13384 setValue: function(value) { 13385 this.$el.val(value); 13386 }, 13387 13388 focus: function() { 13389 if (this.hasFocus) return; 13390 13391 this.$el.focus(); 13392 }, 13393 13394 blur: function() { 13395 if (!this.hasFocus) return; 13396 13397 this.$el.blur(); 13398 }, 13399 13400 select: function() { 13401 this.$el.select(); 13402 } 13403 13404 }); 13405 13406 /** 13407 * TextArea editor 13408 */ 13409 Form.editors.TextArea = Form.editors.Text.extend({ 13410 13411 tagName: 'textarea', 13412 13413 /** 13414 * Override Text constructor so type property isn't set (issue #261) 13415 */ 13416 initialize: function(options) { 13417 Form.editors.Base.prototype.initialize.call(this, options); 13418 } 13419 13420 }); 13421 13422 /** 13423 * Password editor 13424 */ 13425 Form.editors.Password = Form.editors.Text.extend({ 13426 13427 initialize: function(options) { 13428 Form.editors.Text.prototype.initialize.call(this, options); 13429 13430 this.$el.attr('type', 'password'); 13431 } 13432 13433 }); 13434 13435 /** 13436 * NUMBER 13437 * 13438 * Normal text input that only allows a number. Letters etc. are not entered. 13439 */ 13440 Form.editors.Number = Form.editors.Text.extend({ 13441 13442 defaultValue: 0, 13443 13444 events: _.extend({}, Form.editors.Text.prototype.events, { 13445 'keypress': 'onKeyPress', 13446 'change': 'onKeyPress' 13447 }), 13448 13449 initialize: function(options) { 13450 Form.editors.Text.prototype.initialize.call(this, options); 13451 13452 var schema = this.schema; 13453 13454 this.$el.attr('type', 'number'); 13455 13456 if (!schema || !schema.editorAttrs || !schema.editorAttrs.step) { 13457 // provide a default for `step` attr, 13458 // but don't overwrite if already specified 13459 this.$el.attr('step', 'any'); 13460 } 13461 }, 13462 13463 /** 13464 * Check value is numeric 13465 */ 13466 onKeyPress: function(event) { 13467 var self = this, 13468 delayedDetermineChange = function() { 13469 setTimeout(function() { 13470 self.determineChange(); 13471 }, 0); 13472 }; 13473 13474 //Allow backspace 13475 if (event.charCode === 0) { 13476 delayedDetermineChange(); 13477 return; 13478 } 13479 13480 //Get the whole new value so that we can prevent things like double decimals points etc. 13481 var newVal = this.$el.val() 13482 if( event.charCode != undefined ) { 13483 newVal = newVal + String.fromCharCode(event.charCode); 13484 } 13485 13486 var numeric = /^[0-9]*\.?[0-9]*?$/.test(newVal); 13487 13488 if (numeric) { 13489 delayedDetermineChange(); 13490 } 13491 else { 13492 event.preventDefault(); 13493 } 13494 }, 13495 13496 getValue: function() { 13497 var value = this.$el.val(); 13498 13499 return value === "" ? null : parseFloat(value, 10); 13500 }, 13501 13502 setValue: function(value) { 13503 value = (function() { 13504 if (_.isNumber(value)) return value; 13505 13506 if (_.isString(value) && value !== '') return parseFloat(value, 10); 13507 13508 return null; 13509 })(); 13510 13511 if (_.isNaN(value)) value = null; 13512 13513 Form.editors.Text.prototype.setValue.call(this, value); 13514 } 13515 13516 }); 13517 13518 /** 13519 * Hidden editor 13520 */ 13521 Form.editors.Hidden = Form.editors.Text.extend({ 13522 13523 defaultValue: '', 13524 13525 initialize: function(options) { 13526 Form.editors.Text.prototype.initialize.call(this, options); 13527 13528 this.$el.attr('type', 'hidden'); 13529 }, 13530 13531 focus: function() { 13532 13533 }, 13534 13535 blur: function() { 13536 13537 } 13538 13539 }); 13540 13541 /** 13542 * Checkbox editor 13543 * 13544 * Creates a single checkbox, i.e. boolean value 13545 */ 13546 Form.editors.Checkbox = Form.editors.Base.extend({ 13547 13548 defaultValue: false, 13549 13550 tagName: 'input', 13551 13552 events: { 13553 'click': function(event) { 13554 this.trigger('change', this); 13555 }, 13556 'focus': function(event) { 13557 this.trigger('focus', this); 13558 }, 13559 'blur': function(event) { 13560 this.trigger('blur', this); 13561 } 13562 }, 13563 13564 initialize: function(options) { 13565 Form.editors.Base.prototype.initialize.call(this, options); 13566 13567 this.$el.attr('type', 'checkbox'); 13568 }, 13569 13570 /** 13571 * Adds the editor to the DOM 13572 */ 13573 render: function() { 13574 this.setValue(this.value); 13575 13576 return this; 13577 }, 13578 13579 getValue: function() { 13580 return this.$el.prop('checked'); 13581 }, 13582 13583 setValue: function(value) { 13584 if (value) { 13585 this.$el.prop('checked', true); 13586 }else{ 13587 this.$el.prop('checked', false); 13588 } 13589 }, 13590 13591 focus: function() { 13592 if (this.hasFocus) return; 13593 13594 this.$el.focus(); 13595 }, 13596 13597 blur: function() { 13598 if (!this.hasFocus) return; 13599 13600 this.$el.blur(); 13601 } 13602 13603 }); 13604 13605 /** 13606 * Select editor 13607 * 13608 * Renders a <select> with given options 13609 * 13610 * Requires an 'options' value on the schema. 13611 * Can be an array of options, a function that calls back with the array of options, a string of HTML 13612 * or a Backbone collection. If a collection, the models must implement a toString() method 13613 */ 13614 Form.editors.Select = Form.editors.Base.extend({ 13615 13616 tagName: 'select', 13617 13618 previousValue: '', 13619 13620 events: { 13621 'keyup': 'determineChange', 13622 'keypress': function(event) { 13623 var self = this; 13624 setTimeout(function() { 13625 self.determineChange(); 13626 }, 0); 13627 }, 13628 'change': function(event) { 13629 this.trigger('change', this); 13630 }, 13631 'focus': function(event) { 13632 this.trigger('focus', this); 13633 }, 13634 'blur': function(event) { 13635 this.trigger('blur', this); 13636 } 13637 }, 13638 13639 initialize: function(options) { 13640 Form.editors.Base.prototype.initialize.call(this, options); 13641 13642 if (!this.schema || !this.schema.options) throw new Error("Missing required 'schema.options'"); 13643 }, 13644 13645 render: function() { 13646 this.setOptions(this.schema.options); 13647 13648 return this; 13649 }, 13650 13651 /** 13652 * Sets the options that populate the <select> 13653 * 13654 * @param {Mixed} options 13655 */ 13656 setOptions: function(options) { 13657 var self = this; 13658 13659 //If a collection was passed, check if it needs fetching 13660 if (options instanceof Backbone.Collection) { 13661 var collection = options; 13662 13663 //Don't do the fetch if it's already populated 13664 if (collection.length > 0) { 13665 this.renderOptions(options); 13666 } else { 13667 collection.fetch({ 13668 success: function(collection) { 13669 self.renderOptions(options); 13670 } 13671 }); 13672 } 13673 } 13674 13675 //If a function was passed, run it to get the options 13676 else if (_.isFunction(options)) { 13677 options(function(result) { 13678 self.renderOptions(result); 13679 }, self); 13680 } 13681 13682 //Otherwise, ready to go straight to renderOptions 13683 else { 13684 this.renderOptions(options); 13685 } 13686 }, 13687 13688 /** 13689 * Adds the <option> html to the DOM 13690 * @param {Mixed} Options as a simple array e.g. ['option1', 'option2'] 13691 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 13692 * or as a string of <option> HTML to insert into the <select> 13693 * or any object 13694 */ 13695 renderOptions: function(options) { 13696 var $select = this.$el, 13697 html; 13698 13699 html = this._getOptionsHtml(options); 13700 13701 //Insert options 13702 $select.html(html); 13703 13704 //Select correct option 13705 this.setValue(this.value); 13706 }, 13707 13708 _getOptionsHtml: function(options) { 13709 var html; 13710 //Accept string of HTML 13711 if (_.isString(options)) { 13712 html = options; 13713 } 13714 13715 //Or array 13716 else if (_.isArray(options)) { 13717 html = this._arrayToHtml(options); 13718 } 13719 13720 //Or Backbone collection 13721 else if (options instanceof Backbone.Collection) { 13722 html = this._collectionToHtml(options); 13723 } 13724 13725 else if (_.isFunction(options)) { 13726 var newOptions; 13727 13728 options(function(opts) { 13729 newOptions = opts; 13730 }, this); 13731 13732 html = this._getOptionsHtml(newOptions); 13733 //Or any object 13734 }else{ 13735 html=this._objectToHtml(options); 13736 } 13737 13738 return html; 13739 }, 13740 13741 determineChange: function(event) { 13742 var currentValue = this.getValue(); 13743 var changed = (currentValue !== this.previousValue); 13744 13745 if (changed) { 13746 this.previousValue = currentValue; 13747 13748 this.trigger('change', this); 13749 } 13750 }, 13751 13752 getValue: function() { 13753 return this.$el.val(); 13754 }, 13755 13756 setValue: function(value) { 13757 this.$el.val(value); 13758 }, 13759 13760 focus: function() { 13761 if (this.hasFocus) return; 13762 13763 this.$el.focus(); 13764 }, 13765 13766 blur: function() { 13767 if (!this.hasFocus) return; 13768 13769 this.$el.blur(); 13770 }, 13771 13772 /** 13773 * Transforms a collection into HTML ready to use in the renderOptions method 13774 * @param {Backbone.Collection} 13775 * @return {String} 13776 */ 13777 _collectionToHtml: function(collection) { 13778 //Convert collection to array first 13779 var array = []; 13780 collection.each(function(model) { 13781 array.push({ val: model.id, label: model.toString() }); 13782 }); 13783 13784 //Now convert to HTML 13785 var html = this._arrayToHtml(array); 13786 13787 return html; 13788 }, 13789 /** 13790 * Transforms an object into HTML ready to use in the renderOptions method 13791 * @param {Object} 13792 * @return {String} 13793 */ 13794 _objectToHtml: function(obj) { 13795 //Convert object to array first 13796 var array = []; 13797 for(var key in obj){ 13798 if( obj.hasOwnProperty( key ) ) { 13799 array.push({ val: key, label: obj[key] }); 13800 } 13801 } 13802 13803 //Now convert to HTML 13804 var html = this._arrayToHtml(array); 13805 13806 return html; 13807 }, 13808 13809 13810 13811 /** 13812 * Create the <option> HTML 13813 * @param {Array} Options as a simple array e.g. ['option1', 'option2'] 13814 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 13815 * @return {String} HTML 13816 */ 13817 _arrayToHtml: function(array) { 13818 var html = []; 13819 13820 //Generate HTML 13821 _.each(array, function(option) { 13822 if (_.isObject(option)) { 13823 if (option.group) { 13824 html.push('<optgroup label="'+option.group+'">'); 13825 html.push(this._getOptionsHtml(option.options)) 13826 html.push('</optgroup>'); 13827 } else { 13828 var val = (option.val || option.val === 0) ? option.val : ''; 13829 html.push('<option value="'+val+'">'+option.label+'</option>'); 13830 } 13831 } 13832 else { 13833 html.push('<option>'+option+'</option>'); 13834 } 13835 }, this); 13836 13837 return html.join(''); 13838 } 13839 13840 }); 13841 13842 /** 13843 * Radio editor 13844 * 13845 * Renders a <ul> with given options represented as <li> objects containing radio buttons 13846 * 13847 * Requires an 'options' value on the schema. 13848 * Can be an array of options, a function that calls back with the array of options, a string of HTML 13849 * or a Backbone collection. If a collection, the models must implement a toString() method 13850 */ 13851 Form.editors.Radio = Form.editors.Select.extend({ 13852 13853 tagName: 'ul', 13854 13855 events: { 13856 'change input[type=radio]': function() { 13857 this.trigger('change', this); 13858 }, 13859 'focus input[type=radio]': function() { 13860 if (this.hasFocus) return; 13861 this.trigger('focus', this); 13862 }, 13863 'blur input[type=radio]': function() { 13864 if (!this.hasFocus) return; 13865 var self = this; 13866 setTimeout(function() { 13867 if (self.$('input[type=radio]:focus')[0]) return; 13868 self.trigger('blur', self); 13869 }, 0); 13870 } 13871 }, 13872 13873 /** 13874 * Returns the template. Override for custom templates 13875 * 13876 * @return {Function} Compiled template 13877 */ 13878 getTemplate: function() { 13879 return this.schema.template || this.constructor.template; 13880 }, 13881 13882 getValue: function() { 13883 return this.$('input[type=radio]:checked').val(); 13884 }, 13885 13886 setValue: function(value) { 13887 this.$('input[type=radio]').val([value]); 13888 }, 13889 13890 focus: function() { 13891 if (this.hasFocus) return; 13892 13893 var checked = this.$('input[type=radio]:checked'); 13894 if (checked[0]) { 13895 checked.focus(); 13896 return; 13897 } 13898 13899 this.$('input[type=radio]').first().focus(); 13900 }, 13901 13902 blur: function() { 13903 if (!this.hasFocus) return; 13904 13905 this.$('input[type=radio]:focus').blur(); 13906 }, 13907 13908 /** 13909 * Create the radio list HTML 13910 * @param {Array} Options as a simple array e.g. ['option1', 'option2'] 13911 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 13912 * @return {String} HTML 13913 */ 13914 _arrayToHtml: function (array) { 13915 var self = this; 13916 13917 var template = this.getTemplate(), 13918 name = self.getName(), 13919 id = self.id; 13920 13921 var items = _.map(array, function(option, index) { 13922 var item = { 13923 name: name, 13924 id: id + '-' + index 13925 } 13926 13927 if (_.isObject(option)) { 13928 item.value = (option.val || option.val === 0) ? option.val : ''; 13929 item.label = option.label; 13930 } else { 13931 item.value = option; 13932 item.label = option; 13933 } 13934 13935 return item; 13936 }); 13937 13938 return template({ items: items }); 13939 } 13940 13941 }, { 13942 13943 //STATICS 13944 template: _.template('\ 13945 <% _.each(items, function(item) { %>\ 13946 <li>\ 13947 <input type="radio" name="<%= item.name %>" value="<%= item.value %>" id="<%= item.id %>" />\ 13948 <label for="<%= item.id %>"><%= item.label %></label>\ 13949 </li>\ 13950 <% }); %>\ 13951 ', null, Form.templateSettings) 13952 13953 }); 13954 13955 /** 13956 * Checkboxes editor 13957 * 13958 * Renders a <ul> with given options represented as <li> objects containing checkboxes 13959 * 13960 * Requires an 'options' value on the schema. 13961 * Can be an array of options, a function that calls back with the array of options, a string of HTML 13962 * or a Backbone collection. If a collection, the models must implement a toString() method 13963 */ 13964 Form.editors.Checkboxes = Form.editors.Select.extend({ 13965 13966 tagName: 'ul', 13967 13968 groupNumber: 0, 13969 13970 events: { 13971 'click input[type=checkbox]': function() { 13972 this.trigger('change', this); 13973 }, 13974 'focus input[type=checkbox]': function() { 13975 if (this.hasFocus) return; 13976 this.trigger('focus', this); 13977 }, 13978 'blur input[type=checkbox]': function() { 13979 if (!this.hasFocus) return; 13980 var self = this; 13981 setTimeout(function() { 13982 if (self.$('input[type=checkbox]:focus')[0]) return; 13983 self.trigger('blur', self); 13984 }, 0); 13985 } 13986 }, 13987 13988 getValue: function() { 13989 var values = []; 13990 this.$('input[type=checkbox]:checked').each(function() { 13991 values.push($(this).val()); 13992 }); 13993 return values; 13994 }, 13995 13996 setValue: function(values) { 13997 if (!_.isArray(values)) values = [values]; 13998 this.$('input[type=checkbox]').val(values); 13999 }, 14000 14001 focus: function() { 14002 if (this.hasFocus) return; 14003 14004 this.$('input[type=checkbox]').first().focus(); 14005 }, 14006 14007 blur: function() { 14008 if (!this.hasFocus) return; 14009 14010 this.$('input[type=checkbox]:focus').blur(); 14011 }, 14012 14013 /** 14014 * Create the checkbox list HTML 14015 * @param {Array} Options as a simple array e.g. ['option1', 'option2'] 14016 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 14017 * @return {String} HTML 14018 */ 14019 _arrayToHtml: function (array) { 14020 var html = []; 14021 var self = this; 14022 14023 _.each(array, function(option, index) { 14024 var itemHtml = '<li>'; 14025 var close = true; 14026 if (_.isObject(option)) { 14027 if (option.group) { 14028 var originalId = self.id; 14029 self.id += "-" + self.groupNumber++; 14030 itemHtml = ('<fieldset class="group"> <legend>'+option.group+'</legend>'); 14031 itemHtml += (self._arrayToHtml(option.options)); 14032 itemHtml += ('</fieldset>'); 14033 self.id = originalId; 14034 close = false; 14035 }else{ 14036 var val = (option.val || option.val === 0) ? option.val : ''; 14037 itemHtml += ('<input type="checkbox" name="'+self.getName()+'" value="'+val+'" id="'+self.id+'-'+index+'" />'); 14038 itemHtml += ('<label for="'+self.id+'-'+index+'">'+option.label+'</label>'); 14039 } 14040 } 14041 else { 14042 itemHtml += ('<input type="checkbox" name="'+self.getName()+'" value="'+option+'" id="'+self.id+'-'+index+'" />'); 14043 itemHtml += ('<label for="'+self.id+'-'+index+'">'+option+'</label>'); 14044 } 14045 if(close){ 14046 itemHtml += '</li>'; 14047 } 14048 html.push(itemHtml); 14049 }); 14050 14051 return html.join(''); 14052 } 14053 14054 }); 14055 14056 /** 14057 * Object editor 14058 * 14059 * Creates a child form. For editing Javascript objects 14060 * 14061 * @param {Object} options 14062 * @param {Form} options.form The form this editor belongs to; used to determine the constructor for the nested form 14063 * @param {Object} options.schema The schema for the object 14064 * @param {Object} options.schema.subSchema The schema for the nested form 14065 */ 14066 Form.editors.Object = Form.editors.Base.extend({ 14067 //Prevent error classes being set on the main control; they are internally on the individual fields 14068 hasNestedForm: true, 14069 14070 initialize: function(options) { 14071 //Set default value for the instance so it's not a shared object 14072 this.value = {}; 14073 14074 //Init 14075 Form.editors.Base.prototype.initialize.call(this, options); 14076 14077 //Check required options 14078 if (!this.form) throw new Error('Missing required option "form"'); 14079 if (!this.schema.subSchema) throw new Error("Missing required 'schema.subSchema' option for Object editor"); 14080 }, 14081 14082 render: function() { 14083 //Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form 14084 var NestedForm = this.form.constructor; 14085 14086 //Create the nested form 14087 this.nestedForm = new NestedForm({ 14088 schema: this.schema.subSchema, 14089 data: this.value, 14090 idPrefix: this.id + '_', 14091 Field: NestedForm.NestedField 14092 }); 14093 14094 this._observeFormEvents(); 14095 14096 this.$el.html(this.nestedForm.render().el); 14097 14098 if (this.hasFocus) this.trigger('blur', this); 14099 14100 return this; 14101 }, 14102 14103 getValue: function() { 14104 if (this.nestedForm) return this.nestedForm.getValue(); 14105 14106 return this.value; 14107 }, 14108 14109 setValue: function(value) { 14110 this.value = value; 14111 14112 this.render(); 14113 }, 14114 14115 focus: function() { 14116 if (this.hasFocus) return; 14117 14118 this.nestedForm.focus(); 14119 }, 14120 14121 blur: function() { 14122 if (!this.hasFocus) return; 14123 14124 this.nestedForm.blur(); 14125 }, 14126 14127 remove: function() { 14128 this.nestedForm.remove(); 14129 14130 Backbone.View.prototype.remove.call(this); 14131 }, 14132 14133 validate: function() { 14134 return this.nestedForm.validate(); 14135 }, 14136 14137 _observeFormEvents: function() { 14138 if (!this.nestedForm) return; 14139 14140 this.nestedForm.on('all', function() { 14141 // args = ["key:change", form, fieldEditor] 14142 var args = _.toArray(arguments); 14143 args[1] = this; 14144 // args = ["key:change", this=objectEditor, fieldEditor] 14145 14146 this.trigger.apply(this, args); 14147 }, this); 14148 } 14149 14150 }); 14151 14152 /** 14153 * NestedModel editor 14154 * 14155 * Creates a child form. For editing nested Backbone models 14156 * 14157 * Special options: 14158 * schema.model: Embedded model constructor 14159 */ 14160 Form.editors.NestedModel = Form.editors.Object.extend({ 14161 initialize: function(options) { 14162 Form.editors.Base.prototype.initialize.call(this, options); 14163 14164 if (!this.form) throw new Error('Missing required option "form"'); 14165 if (!options.schema.model) throw new Error('Missing required "schema.model" option for NestedModel editor'); 14166 }, 14167 14168 render: function() { 14169 //Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form 14170 var NestedForm = this.form.constructor; 14171 14172 var data = this.value || {}, 14173 key = this.key, 14174 nestedModel = this.schema.model; 14175 14176 //Wrap the data in a model if it isn't already a model instance 14177 var modelInstance = (data.constructor === nestedModel) ? data : new nestedModel(data); 14178 14179 this.nestedForm = new NestedForm({ 14180 model: modelInstance, 14181 idPrefix: this.id + '_', 14182 fieldTemplate: 'nestedField' 14183 }); 14184 14185 this._observeFormEvents(); 14186 14187 //Render form 14188 this.$el.html(this.nestedForm.render().el); 14189 14190 if (this.hasFocus) this.trigger('blur', this); 14191 14192 return this; 14193 }, 14194 14195 /** 14196 * Update the embedded model, checking for nested validation errors and pass them up 14197 * Then update the main model if all OK 14198 * 14199 * @return {Error|null} Validation error or null 14200 */ 14201 commit: function() { 14202 var error = this.nestedForm.commit(); 14203 if (error) { 14204 this.$el.addClass('error'); 14205 return error; 14206 } 14207 14208 return Form.editors.Object.prototype.commit.call(this); 14209 } 14210 14211 }); 14212 14213 /** 14214 * Date editor 14215 * 14216 * Schema options 14217 * @param {Number|String} [options.schema.yearStart] First year in list. Default: 100 years ago 14218 * @param {Number|String} [options.schema.yearEnd] Last year in list. Default: current year 14219 * 14220 * Config options (if not set, defaults to options stored on the main Date class) 14221 * @param {Boolean} [options.showMonthNames] Use month names instead of numbers. Default: true 14222 * @param {String[]} [options.monthNames] Month names. Default: Full English names 14223 */ 14224 Form.editors.Date = Form.editors.Base.extend({ 14225 14226 events: { 14227 'change select': function() { 14228 this.updateHidden(); 14229 this.trigger('change', this); 14230 }, 14231 'focus select': function() { 14232 if (this.hasFocus) return; 14233 this.trigger('focus', this); 14234 }, 14235 'blur select': function() { 14236 if (!this.hasFocus) return; 14237 var self = this; 14238 setTimeout(function() { 14239 if (self.$('select:focus')[0]) return; 14240 self.trigger('blur', self); 14241 }, 0); 14242 } 14243 }, 14244 14245 initialize: function(options) { 14246 options = options || {}; 14247 14248 Form.editors.Base.prototype.initialize.call(this, options); 14249 14250 var Self = Form.editors.Date, 14251 today = new Date(); 14252 14253 //Option defaults 14254 this.options = _.extend({ 14255 monthNames: Self.monthNames, 14256 showMonthNames: Self.showMonthNames 14257 }, options); 14258 14259 //Schema defaults 14260 this.schema = _.extend({ 14261 yearStart: today.getFullYear() - 100, 14262 yearEnd: today.getFullYear() 14263 }, options.schema || {}); 14264 14265 //Cast to Date 14266 if (this.value && !_.isDate(this.value)) { 14267 this.value = new Date(this.value); 14268 } 14269 14270 //Set default date 14271 if (!this.value) { 14272 var date = new Date(); 14273 date.setSeconds(0); 14274 date.setMilliseconds(0); 14275 14276 this.value = date; 14277 } 14278 14279 //Template 14280 this.template = options.template || this.constructor.template; 14281 }, 14282 14283 render: function() { 14284 var options = this.options, 14285 schema = this.schema, 14286 $ = Backbone.$; 14287 14288 var datesOptions = _.map(_.range(1, 32), function(date) { 14289 return '<option value="'+date+'">' + date + '</option>'; 14290 }); 14291 14292 var monthsOptions = _.map(_.range(0, 12), function(month) { 14293 var value = (options.showMonthNames) 14294 ? options.monthNames[month] 14295 : (month + 1); 14296 14297 return '<option value="'+month+'">' + value + '</option>'; 14298 }); 14299 14300 var yearRange = (schema.yearStart < schema.yearEnd) 14301 ? _.range(schema.yearStart, schema.yearEnd + 1) 14302 : _.range(schema.yearStart, schema.yearEnd - 1, -1); 14303 14304 var yearsOptions = _.map(yearRange, function(year) { 14305 return '<option value="'+year+'">' + year + '</option>'; 14306 }); 14307 14308 //Render the selects 14309 var $el = $($.trim(this.template({ 14310 dates: datesOptions.join(''), 14311 months: monthsOptions.join(''), 14312 years: yearsOptions.join('') 14313 }))); 14314 14315 //Store references to selects 14316 this.$date = $el.find('[data-type="date"]'); 14317 this.$month = $el.find('[data-type="month"]'); 14318 this.$year = $el.find('[data-type="year"]'); 14319 14320 //Create the hidden field to store values in case POSTed to server 14321 this.$hidden = $('<input type="hidden" name="'+this.key+'" />'); 14322 $el.append(this.$hidden); 14323 14324 //Set value on this and hidden field 14325 this.setValue(this.value); 14326 14327 //Remove the wrapper tag 14328 this.setElement($el); 14329 this.$el.attr('id', this.id); 14330 this.$el.attr('name', this.getName()); 14331 14332 if (this.hasFocus) this.trigger('blur', this); 14333 14334 return this; 14335 }, 14336 14337 /** 14338 * @return {Date} Selected date 14339 */ 14340 getValue: function() { 14341 var year = this.$year.val(), 14342 month = this.$month.val(), 14343 date = this.$date.val(); 14344 14345 if (!year || !month || !date) return null; 14346 14347 return new Date(year, month, date); 14348 }, 14349 14350 /** 14351 * @param {Date} date 14352 */ 14353 setValue: function(date) { 14354 this.$date.val(date.getDate()); 14355 this.$month.val(date.getMonth()); 14356 this.$year.val(date.getFullYear()); 14357 14358 this.updateHidden(); 14359 }, 14360 14361 focus: function() { 14362 if (this.hasFocus) return; 14363 14364 this.$('select').first().focus(); 14365 }, 14366 14367 blur: function() { 14368 if (!this.hasFocus) return; 14369 14370 this.$('select:focus').blur(); 14371 }, 14372 14373 /** 14374 * Update the hidden input which is maintained for when submitting a form 14375 * via a normal browser POST 14376 */ 14377 updateHidden: function() { 14378 var val = this.getValue(); 14379 14380 if (_.isDate(val)) val = val.toISOString(); 14381 14382 this.$hidden.val(val); 14383 } 14384 14385 }, { 14386 //STATICS 14387 template: _.template('\ 14388 <div>\ 14389 <select data-type="date"><%= dates %></select>\ 14390 <select data-type="month"><%= months %></select>\ 14391 <select data-type="year"><%= years %></select>\ 14392 </div>\ 14393 ', null, Form.templateSettings), 14394 14395 //Whether to show month names instead of numbers 14396 showMonthNames: true, 14397 14398 //Month names to use if showMonthNames is true 14399 //Replace for localisation, e.g. Form.editors.Date.monthNames = ['Janvier', 'Fevrier'...] 14400 monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] 14401 }); 14402 14403 /** 14404 * DateTime editor 14405 * 14406 * @param {Editor} [options.DateEditor] Date editor view to use (not definition) 14407 * @param {Number} [options.schema.minsInterval] Interval between minutes. Default: 15 14408 */ 14409 Form.editors.DateTime = Form.editors.Base.extend({ 14410 14411 events: { 14412 'change select': function() { 14413 this.updateHidden(); 14414 this.trigger('change', this); 14415 }, 14416 'focus select': function() { 14417 if (this.hasFocus) return; 14418 this.trigger('focus', this); 14419 }, 14420 'blur select': function() { 14421 if (!this.hasFocus) return; 14422 var self = this; 14423 setTimeout(function() { 14424 if (self.$('select:focus')[0]) return; 14425 self.trigger('blur', self); 14426 }, 0); 14427 } 14428 }, 14429 14430 initialize: function(options) { 14431 options = options || {}; 14432 14433 Form.editors.Base.prototype.initialize.call(this, options); 14434 14435 //Option defaults 14436 this.options = _.extend({ 14437 DateEditor: Form.editors.DateTime.DateEditor 14438 }, options); 14439 14440 //Schema defaults 14441 this.schema = _.extend({ 14442 minsInterval: 15 14443 }, options.schema || {}); 14444 14445 //Create embedded date editor 14446 this.dateEditor = new this.options.DateEditor(options); 14447 14448 this.value = this.dateEditor.value; 14449 14450 //Template 14451 this.template = options.template || this.constructor.template; 14452 }, 14453 14454 render: function() { 14455 function pad(n) { 14456 return n < 10 ? '0' + n : n; 14457 } 14458 14459 var schema = this.schema, 14460 $ = Backbone.$; 14461 14462 //Create options 14463 var hoursOptions = _.map(_.range(0, 24), function(hour) { 14464 return '<option value="'+hour+'">' + pad(hour) + '</option>'; 14465 }); 14466 14467 var minsOptions = _.map(_.range(0, 60, schema.minsInterval), function(min) { 14468 return '<option value="'+min+'">' + pad(min) + '</option>'; 14469 }); 14470 14471 //Render time selects 14472 var $el = $($.trim(this.template({ 14473 hours: hoursOptions.join(), 14474 mins: minsOptions.join() 14475 }))); 14476 14477 //Include the date editor 14478 $el.find('[data-date]').append(this.dateEditor.render().el); 14479 14480 //Store references to selects 14481 this.$hour = $el.find('select[data-type="hour"]'); 14482 this.$min = $el.find('select[data-type="min"]'); 14483 14484 //Get the hidden date field to store values in case POSTed to server 14485 this.$hidden = $el.find('input[type="hidden"]'); 14486 14487 //Set time 14488 this.setValue(this.value); 14489 14490 this.setElement($el); 14491 this.$el.attr('id', this.id); 14492 this.$el.attr('name', this.getName()); 14493 14494 if (this.hasFocus) this.trigger('blur', this); 14495 14496 return this; 14497 }, 14498 14499 /** 14500 * @return {Date} Selected datetime 14501 */ 14502 getValue: function() { 14503 var date = this.dateEditor.getValue(); 14504 14505 var hour = this.$hour.val(), 14506 min = this.$min.val(); 14507 14508 if (!date || !hour || !min) return null; 14509 14510 date.setHours(hour); 14511 date.setMinutes(min); 14512 14513 return date; 14514 }, 14515 14516 /** 14517 * @param {Date} 14518 */ 14519 setValue: function(date) { 14520 if (!_.isDate(date)) date = new Date(date); 14521 14522 this.dateEditor.setValue(date); 14523 14524 this.$hour.val(date.getHours()); 14525 this.$min.val(date.getMinutes()); 14526 14527 this.updateHidden(); 14528 }, 14529 14530 focus: function() { 14531 if (this.hasFocus) return; 14532 14533 this.$('select').first().focus(); 14534 }, 14535 14536 blur: function() { 14537 if (!this.hasFocus) return; 14538 14539 this.$('select:focus').blur(); 14540 }, 14541 14542 /** 14543 * Update the hidden input which is maintained for when submitting a form 14544 * via a normal browser POST 14545 */ 14546 updateHidden: function() { 14547 var val = this.getValue(); 14548 if (_.isDate(val)) val = val.toISOString(); 14549 14550 this.$hidden.val(val); 14551 }, 14552 14553 /** 14554 * Remove the Date editor before removing self 14555 */ 14556 remove: function() { 14557 this.dateEditor.remove(); 14558 14559 Form.editors.Base.prototype.remove.call(this); 14560 } 14561 14562 }, { 14563 //STATICS 14564 template: _.template('\ 14565 <div class="bbf-datetime">\ 14566 <div class="bbf-date-container" data-date></div>\ 14567 <select data-type="hour"><%= hours %></select>\ 14568 :\ 14569 <select data-type="min"><%= mins %></select>\ 14570 </div>\ 14571 ', null, Form.templateSettings), 14572 14573 //The date editor to use (constructor function, not instance) 14574 DateEditor: Form.editors.Date 14575 }); 14576 14577 14578 14579 //Metadata 14580 Form.VERSION = '0.14.1'; 14581 14582 14583 //Exports 14584 Backbone.Form = Form; 14585 if (true) module.exports = Form; 14586 14587 })(window || global || this); 14588 14589 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(1))) 14590 14591 /***/ }, 14592 /* 56 */ 14593 /***/ function(module, exports, __webpack_require__) { 14594 14595 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Backbone.js 1.1.2 14596 14597 // (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 14598 // Backbone may be freely distributed under the MIT license. 14599 // For all details and documentation: 14600 // http://backbonejs.org 14601 14602 (function(root, factory) { 14603 14604 // Set up Backbone appropriately for the environment. Start with AMD. 14605 if (true) { 14606 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4), __webpack_require__(1), exports], __WEBPACK_AMD_DEFINE_RESULT__ = function(_, $, exports) { 14607 // Export global even in AMD case in case this script is loaded with 14608 // others that may still expect a global Backbone. 14609 root.Backbone = factory(root, exports, _, $); 14610 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 14611 14612 // Next for Node.js or CommonJS. jQuery may not be needed as a module. 14613 } else if (typeof exports !== 'undefined') { 14614 var _ = require('underscore'); 14615 factory(root, exports, _); 14616 14617 // Finally, as a browser global. 14618 } else { 14619 root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$)); 14620 } 14621 14622 }(this, function(root, Backbone, _, $) { 14623 14624 // Initial Setup 14625 // ------------- 14626 14627 // Save the previous value of the `Backbone` variable, so that it can be 14628 // restored later on, if `noConflict` is used. 14629 var previousBackbone = root.Backbone; 14630 14631 // Create local references to array methods we'll want to use later. 14632 var array = []; 14633 var push = array.push; 14634 var slice = array.slice; 14635 var splice = array.splice; 14636 14637 // Current version of the library. Keep in sync with `package.json`. 14638 Backbone.VERSION = '1.1.2'; 14639 14640 // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns 14641 // the `$` variable. 14642 Backbone.$ = $; 14643 14644 // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable 14645 // to its previous owner. Returns a reference to this Backbone object. 14646 Backbone.noConflict = function() { 14647 root.Backbone = previousBackbone; 14648 return this; 14649 }; 14650 14651 // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option 14652 // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and 14653 // set a `X-Http-Method-Override` header. 14654 Backbone.emulateHTTP = false; 14655 14656 // Turn on `emulateJSON` to support legacy servers that can't deal with direct 14657 // `application/json` requests ... will encode the body as 14658 // `application/x-www-form-urlencoded` instead and will send the model in a 14659 // form param named `model`. 14660 Backbone.emulateJSON = false; 14661 14662 // Backbone.Events 14663 // --------------- 14664 14665 // A module that can be mixed in to *any object* in order to provide it with 14666 // custom events. You may bind with `on` or remove with `off` callback 14667 // functions to an event; `trigger`-ing an event fires all callbacks in 14668 // succession. 14669 // 14670 // var object = {}; 14671 // _.extend(object, Backbone.Events); 14672 // object.on('expand', function(){ alert('expanded'); }); 14673 // object.trigger('expand'); 14674 // 14675 var Events = Backbone.Events = { 14676 14677 // Bind an event to a `callback` function. Passing `"all"` will bind 14678 // the callback to all events fired. 14679 on: function(name, callback, context) { 14680 if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this; 14681 this._events || (this._events = {}); 14682 var events = this._events[name] || (this._events[name] = []); 14683 events.push({callback: callback, context: context, ctx: context || this}); 14684 return this; 14685 }, 14686 14687 // Bind an event to only be triggered a single time. After the first time 14688 // the callback is invoked, it will be removed. 14689 once: function(name, callback, context) { 14690 if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this; 14691 var self = this; 14692 var once = _.once(function() { 14693 self.off(name, once); 14694 callback.apply(this, arguments); 14695 }); 14696 once._callback = callback; 14697 return this.on(name, once, context); 14698 }, 14699 14700 // Remove one or many callbacks. If `context` is null, removes all 14701 // callbacks with that function. If `callback` is null, removes all 14702 // callbacks for the event. If `name` is null, removes all bound 14703 // callbacks for all events. 14704 off: function(name, callback, context) { 14705 var retain, ev, events, names, i, l, j, k; 14706 if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this; 14707 if (!name && !callback && !context) { 14708 this._events = void 0; 14709 return this; 14710 } 14711 names = name ? [name] : _.keys(this._events); 14712 for (i = 0, l = names.length; i < l; i++) { 14713 name = names[i]; 14714 if (events = this._events[name]) { 14715 this._events[name] = retain = []; 14716 if (callback || context) { 14717 for (j = 0, k = events.length; j < k; j++) { 14718 ev = events[j]; 14719 if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || 14720 (context && context !== ev.context)) { 14721 retain.push(ev); 14722 } 14723 } 14724 } 14725 if (!retain.length) delete this._events[name]; 14726 } 14727 } 14728 14729 return this; 14730 }, 14731 14732 // Trigger one or many events, firing all bound callbacks. Callbacks are 14733 // passed the same arguments as `trigger` is, apart from the event name 14734 // (unless you're listening on `"all"`, which will cause your callback to 14735 // receive the true name of the event as the first argument). 14736 trigger: function(name) { 14737 if (!this._events) return this; 14738 var args = slice.call(arguments, 1); 14739 if (!eventsApi(this, 'trigger', name, args)) return this; 14740 var events = this._events[name]; 14741 var allEvents = this._events.all; 14742 if (events) triggerEvents(events, args); 14743 if (allEvents) triggerEvents(allEvents, arguments); 14744 return this; 14745 }, 14746 14747 // Tell this object to stop listening to either specific events ... or 14748 // to every object it's currently listening to. 14749 stopListening: function(obj, name, callback) { 14750 var listeningTo = this._listeningTo; 14751 if (!listeningTo) return this; 14752 var remove = !name && !callback; 14753 if (!callback && typeof name === 'object') callback = this; 14754 if (obj) (listeningTo = {})[obj._listenId] = obj; 14755 for (var id in listeningTo) { 14756 obj = listeningTo[id]; 14757 obj.off(name, callback, this); 14758 if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id]; 14759 } 14760 return this; 14761 } 14762 14763 }; 14764 14765 // Regular expression used to split event strings. 14766 var eventSplitter = /\s+/; 14767 14768 // Implement fancy features of the Events API such as multiple event 14769 // names `"change blur"` and jQuery-style event maps `{change: action}` 14770 // in terms of the existing API. 14771 var eventsApi = function(obj, action, name, rest) { 14772 if (!name) return true; 14773 14774 // Handle event maps. 14775 if (typeof name === 'object') { 14776 for (var key in name) { 14777 obj[action].apply(obj, [key, name[key]].concat(rest)); 14778 } 14779 return false; 14780 } 14781 14782 // Handle space separated event names. 14783 if (eventSplitter.test(name)) { 14784 var names = name.split(eventSplitter); 14785 for (var i = 0, l = names.length; i < l; i++) { 14786 obj[action].apply(obj, [names[i]].concat(rest)); 14787 } 14788 return false; 14789 } 14790 14791 return true; 14792 }; 14793 14794 // A difficult-to-believe, but optimized internal dispatch function for 14795 // triggering events. Tries to keep the usual cases speedy (most internal 14796 // Backbone events have 3 arguments). 14797 var triggerEvents = function(events, args) { 14798 var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; 14799 switch (args.length) { 14800 case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; 14801 case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return; 14802 case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; 14803 case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; 14804 default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return; 14805 } 14806 }; 14807 14808 var listenMethods = {listenTo: 'on', listenToOnce: 'once'}; 14809 14810 // Inversion-of-control versions of `on` and `once`. Tell *this* object to 14811 // listen to an event in another object ... keeping track of what it's 14812 // listening to. 14813 _.each(listenMethods, function(implementation, method) { 14814 Events[method] = function(obj, name, callback) { 14815 var listeningTo = this._listeningTo || (this._listeningTo = {}); 14816 var id = obj._listenId || (obj._listenId = _.uniqueId('l')); 14817 listeningTo[id] = obj; 14818 if (!callback && typeof name === 'object') callback = this; 14819 obj[implementation](name, callback, this); 14820 return this; 14821 }; 14822 }); 14823 14824 // Aliases for backwards compatibility. 14825 Events.bind = Events.on; 14826 Events.unbind = Events.off; 14827 14828 // Allow the `Backbone` object to serve as a global event bus, for folks who 14829 // want global "pubsub" in a convenient place. 14830 _.extend(Backbone, Events); 14831 14832 // Backbone.Model 14833 // -------------- 14834 14835 // Backbone **Models** are the basic data object in the framework -- 14836 // frequently representing a row in a table in a database on your server. 14837 // A discrete chunk of data and a bunch of useful, related methods for 14838 // performing computations and transformations on that data. 14839 14840 // Create a new model with the specified attributes. A client id (`cid`) 14841 // is automatically generated and assigned for you. 14842 var Model = Backbone.Model = function(attributes, options) { 14843 var attrs = attributes || {}; 14844 options || (options = {}); 14845 this.cid = _.uniqueId('c'); 14846 this.attributes = {}; 14847 if (options.collection) this.collection = options.collection; 14848 if (options.parse) attrs = this.parse(attrs, options) || {}; 14849 attrs = _.defaults({}, attrs, _.result(this, 'defaults')); 14850 this.set(attrs, options); 14851 this.changed = {}; 14852 this.initialize.apply(this, arguments); 14853 }; 14854 14855 // Attach all inheritable methods to the Model prototype. 14856 _.extend(Model.prototype, Events, { 14857 14858 // A hash of attributes whose current and previous value differ. 14859 changed: null, 14860 14861 // The value returned during the last failed validation. 14862 validationError: null, 14863 14864 // The default name for the JSON `id` attribute is `"id"`. MongoDB and 14865 // CouchDB users may want to set this to `"_id"`. 14866 idAttribute: 'id', 14867 14868 // Initialize is an empty function by default. Override it with your own 14869 // initialization logic. 14870 initialize: function(){}, 14871 14872 // Return a copy of the model's `attributes` object. 14873 toJSON: function(options) { 14874 return _.clone(this.attributes); 14875 }, 14876 14877 // Proxy `Backbone.sync` by default -- but override this if you need 14878 // custom syncing semantics for *this* particular model. 14879 sync: function() { 14880 return Backbone.sync.apply(this, arguments); 14881 }, 14882 14883 // Get the value of an attribute. 14884 get: function(attr) { 14885 return this.attributes[attr]; 14886 }, 14887 14888 // Get the HTML-escaped value of an attribute. 14889 escape: function(attr) { 14890 return _.escape(this.get(attr)); 14891 }, 14892 14893 // Returns `true` if the attribute contains a value that is not null 14894 // or undefined. 14895 has: function(attr) { 14896 return this.get(attr) != null; 14897 }, 14898 14899 // Set a hash of model attributes on the object, firing `"change"`. This is 14900 // the core primitive operation of a model, updating the data and notifying 14901 // anyone who needs to know about the change in state. The heart of the beast. 14902 set: function(key, val, options) { 14903 var attr, attrs, unset, changes, silent, changing, prev, current; 14904 if (key == null) return this; 14905 14906 // Handle both `"key", value` and `{key: value}` -style arguments. 14907 if (typeof key === 'object') { 14908 attrs = key; 14909 options = val; 14910 } else { 14911 (attrs = {})[key] = val; 14912 } 14913 14914 options || (options = {}); 14915 14916 // Run validation. 14917 if (!this._validate(attrs, options)) return false; 14918 14919 // Extract attributes and options. 14920 unset = options.unset; 14921 silent = options.silent; 14922 changes = []; 14923 changing = this._changing; 14924 this._changing = true; 14925 14926 if (!changing) { 14927 this._previousAttributes = _.clone(this.attributes); 14928 this.changed = {}; 14929 } 14930 current = this.attributes, prev = this._previousAttributes; 14931 14932 // Check for changes of `id`. 14933 if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; 14934 14935 // For each `set` attribute, update or delete the current value. 14936 for (attr in attrs) { 14937 val = attrs[attr]; 14938 if (!_.isEqual(current[attr], val)) changes.push(attr); 14939 if (!_.isEqual(prev[attr], val)) { 14940 this.changed[attr] = val; 14941 } else { 14942 delete this.changed[attr]; 14943 } 14944 unset ? delete current[attr] : current[attr] = val; 14945 } 14946 14947 // Trigger all relevant attribute changes. 14948 if (!silent) { 14949 if (changes.length) this._pending = options; 14950 for (var i = 0, l = changes.length; i < l; i++) { 14951 this.trigger('change:' + changes[i], this, current[changes[i]], options); 14952 } 14953 } 14954 14955 // You might be wondering why there's a `while` loop here. Changes can 14956 // be recursively nested within `"change"` events. 14957 if (changing) return this; 14958 if (!silent) { 14959 while (this._pending) { 14960 options = this._pending; 14961 this._pending = false; 14962 this.trigger('change', this, options); 14963 } 14964 } 14965 this._pending = false; 14966 this._changing = false; 14967 return this; 14968 }, 14969 14970 // Remove an attribute from the model, firing `"change"`. `unset` is a noop 14971 // if the attribute doesn't exist. 14972 unset: function(attr, options) { 14973 return this.set(attr, void 0, _.extend({}, options, {unset: true})); 14974 }, 14975 14976 // Clear all attributes on the model, firing `"change"`. 14977 clear: function(options) { 14978 var attrs = {}; 14979 for (var key in this.attributes) attrs[key] = void 0; 14980 return this.set(attrs, _.extend({}, options, {unset: true})); 14981 }, 14982 14983 // Determine if the model has changed since the last `"change"` event. 14984 // If you specify an attribute name, determine if that attribute has changed. 14985 hasChanged: function(attr) { 14986 if (attr == null) return !_.isEmpty(this.changed); 14987 return _.has(this.changed, attr); 14988 }, 14989 14990 // Return an object containing all the attributes that have changed, or 14991 // false if there are no changed attributes. Useful for determining what 14992 // parts of a view need to be updated and/or what attributes need to be 14993 // persisted to the server. Unset attributes will be set to undefined. 14994 // You can also pass an attributes object to diff against the model, 14995 // determining if there *would be* a change. 14996 changedAttributes: function(diff) { 14997 if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; 14998 var val, changed = false; 14999 var old = this._changing ? this._previousAttributes : this.attributes; 15000 for (var attr in diff) { 15001 if (_.isEqual(old[attr], (val = diff[attr]))) continue; 15002 (changed || (changed = {}))[attr] = val; 15003 } 15004 return changed; 15005 }, 15006 15007 // Get the previous value of an attribute, recorded at the time the last 15008 // `"change"` event was fired. 15009 previous: function(attr) { 15010 if (attr == null || !this._previousAttributes) return null; 15011 return this._previousAttributes[attr]; 15012 }, 15013 15014 // Get all of the attributes of the model at the time of the previous 15015 // `"change"` event. 15016 previousAttributes: function() { 15017 return _.clone(this._previousAttributes); 15018 }, 15019 15020 // Fetch the model from the server. If the server's representation of the 15021 // model differs from its current attributes, they will be overridden, 15022 // triggering a `"change"` event. 15023 fetch: function(options) { 15024 options = options ? _.clone(options) : {}; 15025 if (options.parse === void 0) options.parse = true; 15026 var model = this; 15027 var success = options.success; 15028 options.success = function(resp) { 15029 if (!model.set(model.parse(resp, options), options)) return false; 15030 if (success) success(model, resp, options); 15031 model.trigger('sync', model, resp, options); 15032 }; 15033 wrapError(this, options); 15034 return this.sync('read', this, options); 15035 }, 15036 15037 // Set a hash of model attributes, and sync the model to the server. 15038 // If the server returns an attributes hash that differs, the model's 15039 // state will be `set` again. 15040 save: function(key, val, options) { 15041 var attrs, method, xhr, attributes = this.attributes; 15042 15043 // Handle both `"key", value` and `{key: value}` -style arguments. 15044 if (key == null || typeof key === 'object') { 15045 attrs = key; 15046 options = val; 15047 } else { 15048 (attrs = {})[key] = val; 15049 } 15050 15051 options = _.extend({validate: true}, options); 15052 15053 // If we're not waiting and attributes exist, save acts as 15054 // `set(attr).save(null, opts)` with validation. Otherwise, check if 15055 // the model will be valid when the attributes, if any, are set. 15056 if (attrs && !options.wait) { 15057 if (!this.set(attrs, options)) return false; 15058 } else { 15059 if (!this._validate(attrs, options)) return false; 15060 } 15061 15062 // Set temporary attributes if `{wait: true}`. 15063 if (attrs && options.wait) { 15064 this.attributes = _.extend({}, attributes, attrs); 15065 } 15066 15067 // After a successful server-side save, the client is (optionally) 15068 // updated with the server-side state. 15069 if (options.parse === void 0) options.parse = true; 15070 var model = this; 15071 var success = options.success; 15072 options.success = function(resp) { 15073 // Ensure attributes are restored during synchronous saves. 15074 model.attributes = attributes; 15075 var serverAttrs = model.parse(resp, options); 15076 if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); 15077 if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { 15078 return false; 15079 } 15080 if (success) success(model, resp, options); 15081 model.trigger('sync', model, resp, options); 15082 }; 15083 wrapError(this, options); 15084 15085 method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); 15086 if (method === 'patch') options.attrs = attrs; 15087 xhr = this.sync(method, this, options); 15088 15089 // Restore attributes. 15090 if (attrs && options.wait) this.attributes = attributes; 15091 15092 return xhr; 15093 }, 15094 15095 // Destroy this model on the server if it was already persisted. 15096 // Optimistically removes the model from its collection, if it has one. 15097 // If `wait: true` is passed, waits for the server to respond before removal. 15098 destroy: function(options) { 15099 options = options ? _.clone(options) : {}; 15100 var model = this; 15101 var success = options.success; 15102 15103 var destroy = function() { 15104 model.trigger('destroy', model, model.collection, options); 15105 }; 15106 15107 options.success = function(resp) { 15108 if (options.wait || model.isNew()) destroy(); 15109 if (success) success(model, resp, options); 15110 if (!model.isNew()) model.trigger('sync', model, resp, options); 15111 }; 15112 15113 if (this.isNew()) { 15114 options.success(); 15115 return false; 15116 } 15117 wrapError(this, options); 15118 15119 var xhr = this.sync('delete', this, options); 15120 if (!options.wait) destroy(); 15121 return xhr; 15122 }, 15123 15124 // Default URL for the model's representation on the server -- if you're 15125 // using Backbone's restful methods, override this to change the endpoint 15126 // that will be called. 15127 url: function() { 15128 var base = 15129 _.result(this, 'urlRoot') || 15130 _.result(this.collection, 'url') || 15131 urlError(); 15132 if (this.isNew()) return base; 15133 return base.replace(/([^\/])$/, '$1/') + encodeURIComponent(this.id); 15134 }, 15135 15136 // **parse** converts a response into the hash of attributes to be `set` on 15137 // the model. The default implementation is just to pass the response along. 15138 parse: function(resp, options) { 15139 return resp; 15140 }, 15141 15142 // Create a new model with identical attributes to this one. 15143 clone: function() { 15144 return new this.constructor(this.attributes); 15145 }, 15146 15147 // A model is new if it has never been saved to the server, and lacks an id. 15148 isNew: function() { 15149 return !this.has(this.idAttribute); 15150 }, 15151 15152 // Check if the model is currently in a valid state. 15153 isValid: function(options) { 15154 return this._validate({}, _.extend(options || {}, { validate: true })); 15155 }, 15156 15157 // Run validation against the next complete set of model attributes, 15158 // returning `true` if all is well. Otherwise, fire an `"invalid"` event. 15159 _validate: function(attrs, options) { 15160 if (!options.validate || !this.validate) return true; 15161 attrs = _.extend({}, this.attributes, attrs); 15162 var error = this.validationError = this.validate(attrs, options) || null; 15163 if (!error) return true; 15164 this.trigger('invalid', this, error, _.extend(options, {validationError: error})); 15165 return false; 15166 } 15167 15168 }); 15169 15170 // Underscore methods that we want to implement on the Model. 15171 var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit']; 15172 15173 // Mix in each Underscore method as a proxy to `Model#attributes`. 15174 _.each(modelMethods, function(method) { 15175 Model.prototype[method] = function() { 15176 var args = slice.call(arguments); 15177 args.unshift(this.attributes); 15178 return _[method].apply(_, args); 15179 }; 15180 }); 15181 15182 // Backbone.Collection 15183 // ------------------- 15184 15185 // If models tend to represent a single row of data, a Backbone Collection is 15186 // more analagous to a table full of data ... or a small slice or page of that 15187 // table, or a collection of rows that belong together for a particular reason 15188 // -- all of the messages in this particular folder, all of the documents 15189 // belonging to this particular author, and so on. Collections maintain 15190 // indexes of their models, both in order, and for lookup by `id`. 15191 15192 // Create a new **Collection**, perhaps to contain a specific type of `model`. 15193 // If a `comparator` is specified, the Collection will maintain 15194 // its models in sort order, as they're added and removed. 15195 var Collection = Backbone.Collection = function(models, options) { 15196 options || (options = {}); 15197 if (options.model) this.model = options.model; 15198 if (options.comparator !== void 0) this.comparator = options.comparator; 15199 this._reset(); 15200 this.initialize.apply(this, arguments); 15201 if (models) this.reset(models, _.extend({silent: true}, options)); 15202 }; 15203 15204 // Default options for `Collection#set`. 15205 var setOptions = {add: true, remove: true, merge: true}; 15206 var addOptions = {add: true, remove: false}; 15207 15208 // Define the Collection's inheritable methods. 15209 _.extend(Collection.prototype, Events, { 15210 15211 // The default model for a collection is just a **Backbone.Model**. 15212 // This should be overridden in most cases. 15213 model: Model, 15214 15215 // Initialize is an empty function by default. Override it with your own 15216 // initialization logic. 15217 initialize: function(){}, 15218 15219 // The JSON representation of a Collection is an array of the 15220 // models' attributes. 15221 toJSON: function(options) { 15222 return this.map(function(model){ return model.toJSON(options); }); 15223 }, 15224 15225 // Proxy `Backbone.sync` by default. 15226 sync: function() { 15227 return Backbone.sync.apply(this, arguments); 15228 }, 15229 15230 // Add a model, or list of models to the set. 15231 add: function(models, options) { 15232 return this.set(models, _.extend({merge: false}, options, addOptions)); 15233 }, 15234 15235 // Remove a model, or a list of models from the set. 15236 remove: function(models, options) { 15237 var singular = !_.isArray(models); 15238 models = singular ? [models] : _.clone(models); 15239 options || (options = {}); 15240 var i, l, index, model; 15241 for (i = 0, l = models.length; i < l; i++) { 15242 model = models[i] = this.get(models[i]); 15243 if (!model) continue; 15244 delete this._byId[model.id]; 15245 delete this._byId[model.cid]; 15246 index = this.indexOf(model); 15247 this.models.splice(index, 1); 15248 this.length--; 15249 if (!options.silent) { 15250 options.index = index; 15251 model.trigger('remove', model, this, options); 15252 } 15253 this._removeReference(model, options); 15254 } 15255 return singular ? models[0] : models; 15256 }, 15257 15258 // Update a collection by `set`-ing a new list of models, adding new ones, 15259 // removing models that are no longer present, and merging models that 15260 // already exist in the collection, as necessary. Similar to **Model#set**, 15261 // the core operation for updating the data contained by the collection. 15262 set: function(models, options) { 15263 options = _.defaults({}, options, setOptions); 15264 if (options.parse) models = this.parse(models, options); 15265 var singular = !_.isArray(models); 15266 models = singular ? (models ? [models] : []) : _.clone(models); 15267 var i, l, id, model, attrs, existing, sort; 15268 var at = options.at; 15269 var targetModel = this.model; 15270 var sortable = this.comparator && (at == null) && options.sort !== false; 15271 var sortAttr = _.isString(this.comparator) ? this.comparator : null; 15272 var toAdd = [], toRemove = [], modelMap = {}; 15273 var add = options.add, merge = options.merge, remove = options.remove; 15274 var order = !sortable && add && remove ? [] : false; 15275 15276 // Turn bare objects into model references, and prevent invalid models 15277 // from being added. 15278 for (i = 0, l = models.length; i < l; i++) { 15279 attrs = models[i] || {}; 15280 if (attrs instanceof Model) { 15281 id = model = attrs; 15282 } else { 15283 id = attrs[targetModel.prototype.idAttribute || 'id']; 15284 } 15285 15286 // If a duplicate is found, prevent it from being added and 15287 // optionally merge it into the existing model. 15288 if (existing = this.get(id)) { 15289 if (remove) modelMap[existing.cid] = true; 15290 if (merge) { 15291 attrs = attrs === model ? model.attributes : attrs; 15292 if (options.parse) attrs = existing.parse(attrs, options); 15293 existing.set(attrs, options); 15294 if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true; 15295 } 15296 models[i] = existing; 15297 15298 // If this is a new, valid model, push it to the `toAdd` list. 15299 } else if (add) { 15300 model = models[i] = this._prepareModel(attrs, options); 15301 if (!model) continue; 15302 toAdd.push(model); 15303 this._addReference(model, options); 15304 } 15305 15306 // Do not add multiple models with the same `id`. 15307 model = existing || model; 15308 if (order && (model.isNew() || !modelMap[model.id])) order.push(model); 15309 modelMap[model.id] = true; 15310 } 15311 15312 // Remove nonexistent models if appropriate. 15313 if (remove) { 15314 for (i = 0, l = this.length; i < l; ++i) { 15315 if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model); 15316 } 15317 if (toRemove.length) this.remove(toRemove, options); 15318 } 15319 15320 // See if sorting is needed, update `length` and splice in new models. 15321 if (toAdd.length || (order && order.length)) { 15322 if (sortable) sort = true; 15323 this.length += toAdd.length; 15324 if (at != null) { 15325 for (i = 0, l = toAdd.length; i < l; i++) { 15326 this.models.splice(at + i, 0, toAdd[i]); 15327 } 15328 } else { 15329 if (order) this.models.length = 0; 15330 var orderedModels = order || toAdd; 15331 for (i = 0, l = orderedModels.length; i < l; i++) { 15332 this.models.push(orderedModels[i]); 15333 } 15334 } 15335 } 15336 15337 // Silently sort the collection if appropriate. 15338 if (sort) this.sort({silent: true}); 15339 15340 // Unless silenced, it's time to fire all appropriate add/sort events. 15341 if (!options.silent) { 15342 for (i = 0, l = toAdd.length; i < l; i++) { 15343 (model = toAdd[i]).trigger('add', model, this, options); 15344 } 15345 if (sort || (order && order.length)) this.trigger('sort', this, options); 15346 } 15347 15348 // Return the added (or merged) model (or models). 15349 return singular ? models[0] : models; 15350 }, 15351 15352 // When you have more items than you want to add or remove individually, 15353 // you can reset the entire set with a new list of models, without firing 15354 // any granular `add` or `remove` events. Fires `reset` when finished. 15355 // Useful for bulk operations and optimizations. 15356 reset: function(models, options) { 15357 options || (options = {}); 15358 for (var i = 0, l = this.models.length; i < l; i++) { 15359 this._removeReference(this.models[i], options); 15360 } 15361 options.previousModels = this.models; 15362 this._reset(); 15363 models = this.add(models, _.extend({silent: true}, options)); 15364 if (!options.silent) this.trigger('reset', this, options); 15365 return models; 15366 }, 15367 15368 // Add a model to the end of the collection. 15369 push: function(model, options) { 15370 return this.add(model, _.extend({at: this.length}, options)); 15371 }, 15372 15373 // Remove a model from the end of the collection. 15374 pop: function(options) { 15375 var model = this.at(this.length - 1); 15376 this.remove(model, options); 15377 return model; 15378 }, 15379 15380 // Add a model to the beginning of the collection. 15381 unshift: function(model, options) { 15382 return this.add(model, _.extend({at: 0}, options)); 15383 }, 15384 15385 // Remove a model from the beginning of the collection. 15386 shift: function(options) { 15387 var model = this.at(0); 15388 this.remove(model, options); 15389 return model; 15390 }, 15391 15392 // Slice out a sub-array of models from the collection. 15393 slice: function() { 15394 return slice.apply(this.models, arguments); 15395 }, 15396 15397 // Get a model from the set by id. 15398 get: function(obj) { 15399 if (obj == null) return void 0; 15400 return this._byId[obj] || this._byId[obj.id] || this._byId[obj.cid]; 15401 }, 15402 15403 // Get the model at the given index. 15404 at: function(index) { 15405 return this.models[index]; 15406 }, 15407 15408 // Return models with matching attributes. Useful for simple cases of 15409 // `filter`. 15410 where: function(attrs, first) { 15411 if (_.isEmpty(attrs)) return first ? void 0 : []; 15412 return this[first ? 'find' : 'filter'](function(model) { 15413 for (var key in attrs) { 15414 if (attrs[key] !== model.get(key)) return false; 15415 } 15416 return true; 15417 }); 15418 }, 15419 15420 // Return the first model with matching attributes. Useful for simple cases 15421 // of `find`. 15422 findWhere: function(attrs) { 15423 return this.where(attrs, true); 15424 }, 15425 15426 // Force the collection to re-sort itself. You don't need to call this under 15427 // normal circumstances, as the set will maintain sort order as each item 15428 // is added. 15429 sort: function(options) { 15430 if (!this.comparator) throw new Error('Cannot sort a set without a comparator'); 15431 options || (options = {}); 15432 15433 // Run sort based on type of `comparator`. 15434 if (_.isString(this.comparator) || this.comparator.length === 1) { 15435 this.models = this.sortBy(this.comparator, this); 15436 } else { 15437 this.models.sort(_.bind(this.comparator, this)); 15438 } 15439 15440 if (!options.silent) this.trigger('sort', this, options); 15441 return this; 15442 }, 15443 15444 // Pluck an attribute from each model in the collection. 15445 pluck: function(attr) { 15446 return _.invoke(this.models, 'get', attr); 15447 }, 15448 15449 // Fetch the default set of models for this collection, resetting the 15450 // collection when they arrive. If `reset: true` is passed, the response 15451 // data will be passed through the `reset` method instead of `set`. 15452 fetch: function(options) { 15453 options = options ? _.clone(options) : {}; 15454 if (options.parse === void 0) options.parse = true; 15455 var success = options.success; 15456 var collection = this; 15457 options.success = function(resp) { 15458 var method = options.reset ? 'reset' : 'set'; 15459 collection[method](resp, options); 15460 if (success) success(collection, resp, options); 15461 collection.trigger('sync', collection, resp, options); 15462 }; 15463 wrapError(this, options); 15464 return this.sync('read', this, options); 15465 }, 15466 15467 // Create a new instance of a model in this collection. Add the model to the 15468 // collection immediately, unless `wait: true` is passed, in which case we 15469 // wait for the server to agree. 15470 create: function(model, options) { 15471 options = options ? _.clone(options) : {}; 15472 if (!(model = this._prepareModel(model, options))) return false; 15473 if (!options.wait) this.add(model, options); 15474 var collection = this; 15475 var success = options.success; 15476 options.success = function(model, resp) { 15477 if (options.wait) collection.add(model, options); 15478 if (success) success(model, resp, options); 15479 }; 15480 model.save(null, options); 15481 return model; 15482 }, 15483 15484 // **parse** converts a response into a list of models to be added to the 15485 // collection. The default implementation is just to pass it through. 15486 parse: function(resp, options) { 15487 return resp; 15488 }, 15489 15490 // Create a new collection with an identical list of models as this one. 15491 clone: function() { 15492 return new this.constructor(this.models); 15493 }, 15494 15495 // Private method to reset all internal state. Called when the collection 15496 // is first initialized or reset. 15497 _reset: function() { 15498 this.length = 0; 15499 this.models = []; 15500 this._byId = {}; 15501 }, 15502 15503 // Prepare a hash of attributes (or other model) to be added to this 15504 // collection. 15505 _prepareModel: function(attrs, options) { 15506 if (attrs instanceof Model) return attrs; 15507 options = options ? _.clone(options) : {}; 15508 options.collection = this; 15509 var model = new this.model(attrs, options); 15510 if (!model.validationError) return model; 15511 this.trigger('invalid', this, model.validationError, options); 15512 return false; 15513 }, 15514 15515 // Internal method to create a model's ties to a collection. 15516 _addReference: function(model, options) { 15517 this._byId[model.cid] = model; 15518 if (model.id != null) this._byId[model.id] = model; 15519 if (!model.collection) model.collection = this; 15520 model.on('all', this._onModelEvent, this); 15521 }, 15522 15523 // Internal method to sever a model's ties to a collection. 15524 _removeReference: function(model, options) { 15525 if (this === model.collection) delete model.collection; 15526 model.off('all', this._onModelEvent, this); 15527 }, 15528 15529 // Internal method called every time a model in the set fires an event. 15530 // Sets need to update their indexes when models change ids. All other 15531 // events simply proxy through. "add" and "remove" events that originate 15532 // in other collections are ignored. 15533 _onModelEvent: function(event, model, collection, options) { 15534 if ((event === 'add' || event === 'remove') && collection !== this) return; 15535 if (event === 'destroy') this.remove(model, options); 15536 if (model && event === 'change:' + model.idAttribute) { 15537 delete this._byId[model.previous(model.idAttribute)]; 15538 if (model.id != null) this._byId[model.id] = model; 15539 } 15540 this.trigger.apply(this, arguments); 15541 } 15542 15543 }); 15544 15545 // Underscore methods that we want to implement on the Collection. 15546 // 90% of the core usefulness of Backbone Collections is actually implemented 15547 // right here: 15548 var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl', 15549 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', 15550 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', 15551 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest', 15552 'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle', 15553 'lastIndexOf', 'isEmpty', 'chain', 'sample']; 15554 15555 // Mix in each Underscore method as a proxy to `Collection#models`. 15556 _.each(methods, function(method) { 15557 Collection.prototype[method] = function() { 15558 var args = slice.call(arguments); 15559 args.unshift(this.models); 15560 return _[method].apply(_, args); 15561 }; 15562 }); 15563 15564 // Underscore methods that take a property name as an argument. 15565 var attributeMethods = ['groupBy', 'countBy', 'sortBy', 'indexBy']; 15566 15567 // Use attributes instead of properties. 15568 _.each(attributeMethods, function(method) { 15569 Collection.prototype[method] = function(value, context) { 15570 var iterator = _.isFunction(value) ? value : function(model) { 15571 return model.get(value); 15572 }; 15573 return _[method](this.models, iterator, context); 15574 }; 15575 }); 15576 15577 // Backbone.View 15578 // ------------- 15579 15580 // Backbone Views are almost more convention than they are actual code. A View 15581 // is simply a JavaScript object that represents a logical chunk of UI in the 15582 // DOM. This might be a single item, an entire list, a sidebar or panel, or 15583 // even the surrounding frame which wraps your whole app. Defining a chunk of 15584 // UI as a **View** allows you to define your DOM events declaratively, without 15585 // having to worry about render order ... and makes it easy for the view to 15586 // react to specific changes in the state of your models. 15587 15588 // Creating a Backbone.View creates its initial element outside of the DOM, 15589 // if an existing element is not provided... 15590 var View = Backbone.View = function(options) { 15591 this.cid = _.uniqueId('view'); 15592 options || (options = {}); 15593 _.extend(this, _.pick(options, viewOptions)); 15594 this._ensureElement(); 15595 this.initialize.apply(this, arguments); 15596 this.delegateEvents(); 15597 }; 15598 15599 // Cached regex to split keys for `delegate`. 15600 var delegateEventSplitter = /^(\S+)\s*(.*)$/; 15601 15602 // List of view options to be merged as properties. 15603 var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; 15604 15605 // Set up all inheritable **Backbone.View** properties and methods. 15606 _.extend(View.prototype, Events, { 15607 15608 // The default `tagName` of a View's element is `"div"`. 15609 tagName: 'div', 15610 15611 // jQuery delegate for element lookup, scoped to DOM elements within the 15612 // current view. This should be preferred to global lookups where possible. 15613 $: function(selector) { 15614 return this.$el.find(selector); 15615 }, 15616 15617 // Initialize is an empty function by default. Override it with your own 15618 // initialization logic. 15619 initialize: function(){}, 15620 15621 // **render** is the core function that your view should override, in order 15622 // to populate its element (`this.el`), with the appropriate HTML. The 15623 // convention is for **render** to always return `this`. 15624 render: function() { 15625 return this; 15626 }, 15627 15628 // Remove this view by taking the element out of the DOM, and removing any 15629 // applicable Backbone.Events listeners. 15630 remove: function() { 15631 this.$el.remove(); 15632 this.stopListening(); 15633 return this; 15634 }, 15635 15636 // Change the view's element (`this.el` property), including event 15637 // re-delegation. 15638 setElement: function(element, delegate) { 15639 if (this.$el) this.undelegateEvents(); 15640 this.$el = element instanceof Backbone.$ ? element : Backbone.$(element); 15641 this.el = this.$el[0]; 15642 if (delegate !== false) this.delegateEvents(); 15643 return this; 15644 }, 15645 15646 // Set callbacks, where `this.events` is a hash of 15647 // 15648 // *{"event selector": "callback"}* 15649 // 15650 // { 15651 // 'mousedown .title': 'edit', 15652 // 'click .button': 'save', 15653 // 'click .open': function(e) { ... } 15654 // } 15655 // 15656 // pairs. Callbacks will be bound to the view, with `this` set properly. 15657 // Uses event delegation for efficiency. 15658 // Omitting the selector binds the event to `this.el`. 15659 // This only works for delegate-able events: not `focus`, `blur`, and 15660 // not `change`, `submit`, and `reset` in Internet Explorer. 15661 delegateEvents: function(events) { 15662 if (!(events || (events = _.result(this, 'events')))) return this; 15663 this.undelegateEvents(); 15664 for (var key in events) { 15665 var method = events[key]; 15666 if (!_.isFunction(method)) method = this[events[key]]; 15667 if (!method) continue; 15668 15669 var match = key.match(delegateEventSplitter); 15670 var eventName = match[1], selector = match[2]; 15671 method = _.bind(method, this); 15672 eventName += '.delegateEvents' + this.cid; 15673 if (selector === '') { 15674 this.$el.on(eventName, method); 15675 } else { 15676 this.$el.on(eventName, selector, method); 15677 } 15678 } 15679 return this; 15680 }, 15681 15682 // Clears all callbacks previously bound to the view with `delegateEvents`. 15683 // You usually don't need to use this, but may wish to if you have multiple 15684 // Backbone views attached to the same DOM element. 15685 undelegateEvents: function() { 15686 this.$el.off('.delegateEvents' + this.cid); 15687 return this; 15688 }, 15689 15690 // Ensure that the View has a DOM element to render into. 15691 // If `this.el` is a string, pass it through `$()`, take the first 15692 // matching element, and re-assign it to `el`. Otherwise, create 15693 // an element from the `id`, `className` and `tagName` properties. 15694 _ensureElement: function() { 15695 if (!this.el) { 15696 var attrs = _.extend({}, _.result(this, 'attributes')); 15697 if (this.id) attrs.id = _.result(this, 'id'); 15698 if (this.className) attrs['class'] = _.result(this, 'className'); 15699 var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs); 15700 this.setElement($el, false); 15701 } else { 15702 this.setElement(_.result(this, 'el'), false); 15703 } 15704 } 15705 15706 }); 15707 15708 // Backbone.sync 15709 // ------------- 15710 15711 // Override this function to change the manner in which Backbone persists 15712 // models to the server. You will be passed the type of request, and the 15713 // model in question. By default, makes a RESTful Ajax request 15714 // to the model's `url()`. Some possible customizations could be: 15715 // 15716 // * Use `setTimeout` to batch rapid-fire updates into a single request. 15717 // * Send up the models as XML instead of JSON. 15718 // * Persist models via WebSockets instead of Ajax. 15719 // 15720 // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests 15721 // as `POST`, with a `_method` parameter containing the true HTTP method, 15722 // as well as all requests with the body as `application/x-www-form-urlencoded` 15723 // instead of `application/json` with the model in a param named `model`. 15724 // Useful when interfacing with server-side languages like **PHP** that make 15725 // it difficult to read the body of `PUT` requests. 15726 Backbone.sync = function(method, model, options) { 15727 var type = methodMap[method]; 15728 15729 // Default options, unless specified. 15730 _.defaults(options || (options = {}), { 15731 emulateHTTP: Backbone.emulateHTTP, 15732 emulateJSON: Backbone.emulateJSON 15733 }); 15734 15735 // Default JSON-request options. 15736 var params = {type: type, dataType: 'json'}; 15737 15738 // Ensure that we have a URL. 15739 if (!options.url) { 15740 params.url = _.result(model, 'url') || urlError(); 15741 } 15742 15743 // Ensure that we have the appropriate request data. 15744 if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { 15745 params.contentType = 'application/json'; 15746 params.data = JSON.stringify(options.attrs || model.toJSON(options)); 15747 } 15748 15749 // For older servers, emulate JSON by encoding the request into an HTML-form. 15750 if (options.emulateJSON) { 15751 params.contentType = 'application/x-www-form-urlencoded'; 15752 params.data = params.data ? {model: params.data} : {}; 15753 } 15754 15755 // For older servers, emulate HTTP by mimicking the HTTP method with `_method` 15756 // And an `X-HTTP-Method-Override` header. 15757 if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { 15758 params.type = 'POST'; 15759 if (options.emulateJSON) params.data._method = type; 15760 var beforeSend = options.beforeSend; 15761 options.beforeSend = function(xhr) { 15762 xhr.setRequestHeader('X-HTTP-Method-Override', type); 15763 if (beforeSend) return beforeSend.apply(this, arguments); 15764 }; 15765 } 15766 15767 // Don't process data on a non-GET request. 15768 if (params.type !== 'GET' && !options.emulateJSON) { 15769 params.processData = false; 15770 } 15771 15772 // If we're sending a `PATCH` request, and we're in an old Internet Explorer 15773 // that still has ActiveX enabled by default, override jQuery to use that 15774 // for XHR instead. Remove this line when jQuery supports `PATCH` on IE8. 15775 if (params.type === 'PATCH' && noXhrPatch) { 15776 params.xhr = function() { 15777 return new ActiveXObject("Microsoft.XMLHTTP"); 15778 }; 15779 } 15780 15781 // Make the request, allowing the user to override any Ajax options. 15782 var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); 15783 model.trigger('request', model, xhr, options); 15784 return xhr; 15785 }; 15786 15787 var noXhrPatch = 15788 typeof window !== 'undefined' && !!window.ActiveXObject && 15789 !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent); 15790 15791 // Map from CRUD to HTTP for our default `Backbone.sync` implementation. 15792 var methodMap = { 15793 'create': 'POST', 15794 'update': 'PUT', 15795 'patch': 'PATCH', 15796 'delete': 'DELETE', 15797 'read': 'GET' 15798 }; 15799 15800 // Set the default implementation of `Backbone.ajax` to proxy through to `$`. 15801 // Override this if you'd like to use a different library. 15802 Backbone.ajax = function() { 15803 return Backbone.$.ajax.apply(Backbone.$, arguments); 15804 }; 15805 15806 // Backbone.Router 15807 // --------------- 15808 15809 // Routers map faux-URLs to actions, and fire events when routes are 15810 // matched. Creating a new one sets its `routes` hash, if not set statically. 15811 var Router = Backbone.Router = function(options) { 15812 options || (options = {}); 15813 if (options.routes) this.routes = options.routes; 15814 this._bindRoutes(); 15815 this.initialize.apply(this, arguments); 15816 }; 15817 15818 // Cached regular expressions for matching named param parts and splatted 15819 // parts of route strings. 15820 var optionalParam = /\((.*?)\)/g; 15821 var namedParam = /(\(\?)?:\w+/g; 15822 var splatParam = /\*\w+/g; 15823 var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; 15824 15825 // Set up all inheritable **Backbone.Router** properties and methods. 15826 _.extend(Router.prototype, Events, { 15827 15828 // Initialize is an empty function by default. Override it with your own 15829 // initialization logic. 15830 initialize: function(){}, 15831 15832 // Manually bind a single named route to a callback. For example: 15833 // 15834 // this.route('search/:query/p:num', 'search', function(query, num) { 15835 // ... 15836 // }); 15837 // 15838 route: function(route, name, callback) { 15839 if (!_.isRegExp(route)) route = this._routeToRegExp(route); 15840 if (_.isFunction(name)) { 15841 callback = name; 15842 name = ''; 15843 } 15844 if (!callback) callback = this[name]; 15845 var router = this; 15846 Backbone.history.route(route, function(fragment) { 15847 var args = router._extractParameters(route, fragment); 15848 router.execute(callback, args); 15849 router.trigger.apply(router, ['route:' + name].concat(args)); 15850 router.trigger('route', name, args); 15851 Backbone.history.trigger('route', router, name, args); 15852 }); 15853 return this; 15854 }, 15855 15856 // Execute a route handler with the provided parameters. This is an 15857 // excellent place to do pre-route setup or post-route cleanup. 15858 execute: function(callback, args) { 15859 if (callback) callback.apply(this, args); 15860 }, 15861 15862 // Simple proxy to `Backbone.history` to save a fragment into the history. 15863 navigate: function(fragment, options) { 15864 Backbone.history.navigate(fragment, options); 15865 return this; 15866 }, 15867 15868 // Bind all defined routes to `Backbone.history`. We have to reverse the 15869 // order of the routes here to support behavior where the most general 15870 // routes can be defined at the bottom of the route map. 15871 _bindRoutes: function() { 15872 if (!this.routes) return; 15873 this.routes = _.result(this, 'routes'); 15874 var route, routes = _.keys(this.routes); 15875 while ((route = routes.pop()) != null) { 15876 this.route(route, this.routes[route]); 15877 } 15878 }, 15879 15880 // Convert a route string into a regular expression, suitable for matching 15881 // against the current location hash. 15882 _routeToRegExp: function(route) { 15883 route = route.replace(escapeRegExp, '\\$&') 15884 .replace(optionalParam, '(?:$1)?') 15885 .replace(namedParam, function(match, optional) { 15886 return optional ? match : '([^/?]+)'; 15887 }) 15888 .replace(splatParam, '([^?]*?)'); 15889 return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$'); 15890 }, 15891 15892 // Given a route, and a URL fragment that it matches, return the array of 15893 // extracted decoded parameters. Empty or unmatched parameters will be 15894 // treated as `null` to normalize cross-browser behavior. 15895 _extractParameters: function(route, fragment) { 15896 var params = route.exec(fragment).slice(1); 15897 return _.map(params, function(param, i) { 15898 // Don't decode the search params. 15899 if (i === params.length - 1) return param || null; 15900 return param ? decodeURIComponent(param) : null; 15901 }); 15902 } 15903 15904 }); 15905 15906 // Backbone.History 15907 // ---------------- 15908 15909 // Handles cross-browser history management, based on either 15910 // [pushState](http://diveintohtml5.info/history.html) and real URLs, or 15911 // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange) 15912 // and URL fragments. If the browser supports neither (old IE, natch), 15913 // falls back to polling. 15914 var History = Backbone.History = function() { 15915 this.handlers = []; 15916 _.bindAll(this, 'checkUrl'); 15917 15918 // Ensure that `History` can be used outside of the browser. 15919 if (typeof window !== 'undefined') { 15920 this.location = window.location; 15921 this.history = window.history; 15922 } 15923 }; 15924 15925 // Cached regex for stripping a leading hash/slash and trailing space. 15926 var routeStripper = /^[#\/]|\s+$/g; 15927 15928 // Cached regex for stripping leading and trailing slashes. 15929 var rootStripper = /^\/+|\/+$/g; 15930 15931 // Cached regex for detecting MSIE. 15932 var isExplorer = /msie [\w.]+/; 15933 15934 // Cached regex for removing a trailing slash. 15935 var trailingSlash = /\/$/; 15936 15937 // Cached regex for stripping urls of hash. 15938 var pathStripper = /#.*$/; 15939 15940 // Has the history handling already been started? 15941 History.started = false; 15942 15943 // Set up all inheritable **Backbone.History** properties and methods. 15944 _.extend(History.prototype, Events, { 15945 15946 // The default interval to poll for hash changes, if necessary, is 15947 // twenty times a second. 15948 interval: 50, 15949 15950 // Are we at the app root? 15951 atRoot: function() { 15952 return this.location.pathname.replace(/[^\/]$/, '$&/') === this.root; 15953 }, 15954 15955 // Gets the true hash value. Cannot use location.hash directly due to bug 15956 // in Firefox where location.hash will always be decoded. 15957 getHash: function(window) { 15958 var match = (window || this).location.href.match(/#(.*)$/); 15959 return match ? match[1] : ''; 15960 }, 15961 15962 // Get the cross-browser normalized URL fragment, either from the URL, 15963 // the hash, or the override. 15964 getFragment: function(fragment, forcePushState) { 15965 if (fragment == null) { 15966 if (this._hasPushState || !this._wantsHashChange || forcePushState) { 15967 fragment = decodeURI(this.location.pathname + this.location.search); 15968 var root = this.root.replace(trailingSlash, ''); 15969 if (!fragment.indexOf(root)) fragment = fragment.slice(root.length); 15970 } else { 15971 fragment = this.getHash(); 15972 } 15973 } 15974 return fragment.replace(routeStripper, ''); 15975 }, 15976 15977 // Start the hash change handling, returning `true` if the current URL matches 15978 // an existing route, and `false` otherwise. 15979 start: function(options) { 15980 if (History.started) throw new Error("Backbone.history has already been started"); 15981 History.started = true; 15982 15983 // Figure out the initial configuration. Do we need an iframe? 15984 // Is pushState desired ... is it available? 15985 this.options = _.extend({root: '/'}, this.options, options); 15986 this.root = this.options.root; 15987 this._wantsHashChange = this.options.hashChange !== false; 15988 this._wantsPushState = !!this.options.pushState; 15989 this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState); 15990 var fragment = this.getFragment(); 15991 var docMode = document.documentMode; 15992 var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); 15993 15994 // Normalize root to always include a leading and trailing slash. 15995 this.root = ('/' + this.root + '/').replace(rootStripper, '/'); 15996 15997 if (oldIE && this._wantsHashChange) { 15998 var frame = Backbone.$('<iframe src="javascript:0" tabindex="-1">'); 15999 this.iframe = frame.hide().appendTo('body')[0].contentWindow; 16000 this.navigate(fragment); 16001 } 16002 16003 // Depending on whether we're using pushState or hashes, and whether 16004 // 'onhashchange' is supported, determine how we check the URL state. 16005 if (this._hasPushState) { 16006 Backbone.$(window).on('popstate', this.checkUrl); 16007 } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) { 16008 Backbone.$(window).on('hashchange', this.checkUrl); 16009 } else if (this._wantsHashChange) { 16010 this._checkUrlInterval = setInterval(this.checkUrl, this.interval); 16011 } 16012 16013 // Determine if we need to change the base url, for a pushState link 16014 // opened by a non-pushState browser. 16015 this.fragment = fragment; 16016 var loc = this.location; 16017 16018 // Transition from hashChange to pushState or vice versa if both are 16019 // requested. 16020 if (this._wantsHashChange && this._wantsPushState) { 16021 16022 // If we've started off with a route from a `pushState`-enabled 16023 // browser, but we're currently in a browser that doesn't support it... 16024 if (!this._hasPushState && !this.atRoot()) { 16025 this.fragment = this.getFragment(null, true); 16026 this.location.replace(this.root + '#' + this.fragment); 16027 // Return immediately as browser will do redirect to new url 16028 return true; 16029 16030 // Or if we've started out with a hash-based route, but we're currently 16031 // in a browser where it could be `pushState`-based instead... 16032 } else if (this._hasPushState && this.atRoot() && loc.hash) { 16033 this.fragment = this.getHash().replace(routeStripper, ''); 16034 this.history.replaceState({}, document.title, this.root + this.fragment); 16035 } 16036 16037 } 16038 16039 if (!this.options.silent) return this.loadUrl(); 16040 }, 16041 16042 // Disable Backbone.history, perhaps temporarily. Not useful in a real app, 16043 // but possibly useful for unit testing Routers. 16044 stop: function() { 16045 Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl); 16046 if (this._checkUrlInterval) clearInterval(this._checkUrlInterval); 16047 History.started = false; 16048 }, 16049 16050 // Add a route to be tested when the fragment changes. Routes added later 16051 // may override previous routes. 16052 route: function(route, callback) { 16053 this.handlers.unshift({route: route, callback: callback}); 16054 }, 16055 16056 // Checks the current URL to see if it has changed, and if it has, 16057 // calls `loadUrl`, normalizing across the hidden iframe. 16058 checkUrl: function(e) { 16059 var current = this.getFragment(); 16060 if (current === this.fragment && this.iframe) { 16061 current = this.getFragment(this.getHash(this.iframe)); 16062 } 16063 if (current === this.fragment) return false; 16064 if (this.iframe) this.navigate(current); 16065 this.loadUrl(); 16066 }, 16067 16068 // Attempt to load the current URL fragment. If a route succeeds with a 16069 // match, returns `true`. If no defined routes matches the fragment, 16070 // returns `false`. 16071 loadUrl: function(fragment) { 16072 fragment = this.fragment = this.getFragment(fragment); 16073 return _.any(this.handlers, function(handler) { 16074 if (handler.route.test(fragment)) { 16075 handler.callback(fragment); 16076 return true; 16077 } 16078 }); 16079 }, 16080 16081 // Save a fragment into the hash history, or replace the URL state if the 16082 // 'replace' option is passed. You are responsible for properly URL-encoding 16083 // the fragment in advance. 16084 // 16085 // The options object can contain `trigger: true` if you wish to have the 16086 // route callback be fired (not usually desirable), or `replace: true`, if 16087 // you wish to modify the current URL without adding an entry to the history. 16088 navigate: function(fragment, options) { 16089 if (!History.started) return false; 16090 if (!options || options === true) options = {trigger: !!options}; 16091 16092 var url = this.root + (fragment = this.getFragment(fragment || '')); 16093 16094 // Strip the hash for matching. 16095 fragment = fragment.replace(pathStripper, ''); 16096 16097 if (this.fragment === fragment) return; 16098 this.fragment = fragment; 16099 16100 // Don't include a trailing slash on the root. 16101 if (fragment === '' && url !== '/') url = url.slice(0, -1); 16102 16103 // If pushState is available, we use it to set the fragment as a real URL. 16104 if (this._hasPushState) { 16105 this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url); 16106 16107 // If hash changes haven't been explicitly disabled, update the hash 16108 // fragment to store history. 16109 } else if (this._wantsHashChange) { 16110 this._updateHash(this.location, fragment, options.replace); 16111 if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) { 16112 // Opening and closing the iframe tricks IE7 and earlier to push a 16113 // history entry on hash-tag change. When replace is true, we don't 16114 // want this. 16115 if(!options.replace) this.iframe.document.open().close(); 16116 this._updateHash(this.iframe.location, fragment, options.replace); 16117 } 16118 16119 // If you've told us that you explicitly don't want fallback hashchange- 16120 // based history, then `navigate` becomes a page refresh. 16121 } else { 16122 return this.location.assign(url); 16123 } 16124 if (options.trigger) return this.loadUrl(fragment); 16125 }, 16126 16127 // Update the hash location, either replacing the current entry, or adding 16128 // a new one to the browser history. 16129 _updateHash: function(location, fragment, replace) { 16130 if (replace) { 16131 var href = location.href.replace(/(javascript:|#).*$/, ''); 16132 location.replace(href + '#' + fragment); 16133 } else { 16134 // Some browsers require that `hash` contains a leading #. 16135 location.hash = '#' + fragment; 16136 } 16137 } 16138 16139 }); 16140 16141 // Create the default Backbone.history. 16142 Backbone.history = new History; 16143 16144 // Helpers 16145 // ------- 16146 16147 // Helper function to correctly set up the prototype chain, for subclasses. 16148 // Similar to `goog.inherits`, but uses a hash of prototype properties and 16149 // class properties to be extended. 16150 var extend = function(protoProps, staticProps) { 16151 var parent = this; 16152 var child; 16153 16154 // The constructor function for the new subclass is either defined by you 16155 // (the "constructor" property in your `extend` definition), or defaulted 16156 // by us to simply call the parent's constructor. 16157 if (protoProps && _.has(protoProps, 'constructor')) { 16158 child = protoProps.constructor; 16159 } else { 16160 child = function(){ return parent.apply(this, arguments); }; 16161 } 16162 16163 // Add static properties to the constructor function, if supplied. 16164 _.extend(child, parent, staticProps); 16165 16166 // Set the prototype chain to inherit from `parent`, without calling 16167 // `parent`'s constructor function. 16168 var Surrogate = function(){ this.constructor = child; }; 16169 Surrogate.prototype = parent.prototype; 16170 child.prototype = new Surrogate; 16171 16172 // Add prototype properties (instance properties) to the subclass, 16173 // if supplied. 16174 if (protoProps) _.extend(child.prototype, protoProps); 16175 16176 // Set a convenience property in case the parent's prototype is needed 16177 // later. 16178 child.__super__ = parent.prototype; 16179 16180 return child; 16181 }; 16182 16183 // Set up inheritance for the model, collection, router, view and history. 16184 Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend; 16185 16186 // Throw an error when a URL is needed, and none is supplied. 16187 var urlError = function() { 16188 throw new Error('A "url" property or function must be specified'); 16189 }; 16190 16191 // Wrap an optional error callback with a fallback error event. 16192 var wrapError = function(model, options) { 16193 var error = options.error; 16194 options.error = function(resp) { 16195 if (error) error(model, resp, options); 16196 model.trigger('error', model, resp, options); 16197 }; 16198 }; 16199 16200 return Backbone; 16201 16202 })); 16203 16204 16205 /***/ }, 16206 /* 57 */ 16207 /***/ function(module, exports) { 16208 16209 'use strict' 16210 16211 exports.byteLength = byteLength 16212 exports.toByteArray = toByteArray 16213 exports.fromByteArray = fromByteArray 16214 16215 var lookup = [] 16216 var revLookup = [] 16217 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array 16218 16219 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' 16220 for (var i = 0, len = code.length; i < len; ++i) { 16221 lookup[i] = code[i] 16222 revLookup[code.charCodeAt(i)] = i 16223 } 16224 16225 revLookup['-'.charCodeAt(0)] = 62 16226 revLookup['_'.charCodeAt(0)] = 63 16227 16228 function placeHoldersCount (b64) { 16229 var len = b64.length 16230 if (len % 4 > 0) { 16231 throw new Error('Invalid string. Length must be a multiple of 4') 16232 } 16233 16234 // the number of equal signs (place holders) 16235 // if there are two placeholders, than the two characters before it 16236 // represent one byte 16237 // if there is only one, then the three characters before it represent 2 bytes 16238 // this is just a cheap hack to not do indexOf twice 16239 return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 16240 } 16241 16242 function byteLength (b64) { 16243 // base64 is 4/3 + up to two characters of the original data 16244 return b64.length * 3 / 4 - placeHoldersCount(b64) 16245 } 16246 16247 function toByteArray (b64) { 16248 var i, j, l, tmp, placeHolders, arr 16249 var len = b64.length 16250 placeHolders = placeHoldersCount(b64) 16251 16252 arr = new Arr(len * 3 / 4 - placeHolders) 16253 16254 // if there are placeholders, only get up to the last complete 4 chars 16255 l = placeHolders > 0 ? len - 4 : len 16256 16257 var L = 0 16258 16259 for (i = 0, j = 0; i < l; i += 4, j += 3) { 16260 tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] 16261 arr[L++] = (tmp >> 16) & 0xFF 16262 arr[L++] = (tmp >> 8) & 0xFF 16263 arr[L++] = tmp & 0xFF 16264 } 16265 16266 if (placeHolders === 2) { 16267 tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) 16268 arr[L++] = tmp & 0xFF 16269 } else if (placeHolders === 1) { 16270 tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) 16271 arr[L++] = (tmp >> 8) & 0xFF 16272 arr[L++] = tmp & 0xFF 16273 } 16274 16275 return arr 16276 } 16277 16278 function tripletToBase64 (num) { 16279 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] 16280 } 16281 16282 function encodeChunk (uint8, start, end) { 16283 var tmp 16284 var output = [] 16285 for (var i = start; i < end; i += 3) { 16286 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) 16287 output.push(tripletToBase64(tmp)) 16288 } 16289 return output.join('') 16290 } 16291 16292 function fromByteArray (uint8) { 16293 var tmp 16294 var len = uint8.length 16295 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes 16296 var output = '' 16297 var parts = [] 16298 var maxChunkLength = 16383 // must be multiple of 3 16299 16300 // go through the array every three bytes, we'll deal with trailing stuff later 16301 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { 16302 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) 16303 } 16304 16305 // pad the end with zeros, but make sure to not forget the extra bytes 16306 if (extraBytes === 1) { 16307 tmp = uint8[len - 1] 16308 output += lookup[tmp >> 2] 16309 output += lookup[(tmp << 4) & 0x3F] 16310 output += '==' 16311 } else if (extraBytes === 2) { 16312 tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) 16313 output += lookup[tmp >> 10] 16314 output += lookup[(tmp >> 4) & 0x3F] 16315 output += lookup[(tmp << 2) & 0x3F] 16316 output += '=' 16317 } 16318 16319 parts.push(output) 16320 16321 return parts.join('') 16322 } 16323 16324 16325 /***/ }, 16326 /* 58 */ 16327 /***/ function(module, exports, __webpack_require__) { 16328 16329 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!function(t,e){"use strict";"undefined"!=typeof module&&module.exports?module.exports=e(__webpack_require__(1),__webpack_require__(14)): true?!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1),__webpack_require__(14)], __WEBPACK_AMD_DEFINE_RESULT__ = function(t){return e(t)}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):t.BootstrapDialog=e(t.jQuery)}(this,function(t){"use strict";var e=t.fn.modal.Constructor,n=function(t,n){e.call(this,t,n)};n.getModalVersion=function(){var e=null;return e="undefined"==typeof t.fn.modal.Constructor.VERSION?"v3.1":/3\.2\.\d+/.test(t.fn.modal.Constructor.VERSION)?"v3.2":/3\.3\.[1,2]/.test(t.fn.modal.Constructor.VERSION)?"v3.3":"v3.3.4"},n.ORIGINAL_BODY_PADDING=parseInt(t("body").css("padding-right")||0,10),n.METHODS_TO_OVERRIDE={},n.METHODS_TO_OVERRIDE["v3.1"]={},n.METHODS_TO_OVERRIDE["v3.2"]={hide:function(e){if(e&&e.preventDefault(),e=t.Event("hide.bs.modal"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()){this.isShown=!1;var n=this.getGlobalOpenedDialogs();0===n.length&&this.$body.removeClass("modal-open"),this.resetScrollbar(),this.escape(),t(document).off("focusin.bs.modal"),this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.bs.modal"),t.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",t.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal()}}},n.METHODS_TO_OVERRIDE["v3.3"]={setScrollbar:function(){var t=n.ORIGINAL_BODY_PADDING;this.bodyIsOverflowing&&this.$body.css("padding-right",t+this.scrollbarWidth)},resetScrollbar:function(){var t=this.getGlobalOpenedDialogs();0===t.length&&this.$body.css("padding-right",n.ORIGINAL_BODY_PADDING)},hideModal:function(){this.$element.hide(),this.backdrop(t.proxy(function(){var t=this.getGlobalOpenedDialogs();0===t.length&&this.$body.removeClass("modal-open"),this.resetAdjustments(),this.resetScrollbar(),this.$element.trigger("hidden.bs.modal")},this))}},n.METHODS_TO_OVERRIDE["v3.3.4"]=t.extend({},n.METHODS_TO_OVERRIDE["v3.3"]),n.prototype={constructor:n,getGlobalOpenedDialogs:function(){var e=[];return t.each(o.dialogs,function(t,n){n.isRealized()&&n.isOpened()&&e.push(n)}),e}},n.prototype=t.extend(n.prototype,e.prototype,n.METHODS_TO_OVERRIDE[n.getModalVersion()]);var o=function(e){this.defaultOptions=t.extend(!0,{id:o.newGuid(),buttons:[],data:{},onshow:null,onshown:null,onhide:null,onhidden:null},o.defaultOptions),this.indexedButtons={},this.registeredButtonHotkeys={},this.draggableData={isMouseDown:!1,mouseOffset:{}},this.realized=!1,this.opened=!1,this.initOptions(e),this.holdThisInstance()};return o.BootstrapDialogModal=n,o.NAMESPACE="bootstrap-dialog",o.TYPE_DEFAULT="type-default",o.TYPE_INFO="type-info",o.TYPE_PRIMARY="type-primary",o.TYPE_SUCCESS="type-success",o.TYPE_WARNING="type-warning",o.TYPE_DANGER="type-danger",o.DEFAULT_TEXTS={},o.DEFAULT_TEXTS[o.TYPE_DEFAULT]="Information",o.DEFAULT_TEXTS[o.TYPE_INFO]="Information",o.DEFAULT_TEXTS[o.TYPE_PRIMARY]="Information",o.DEFAULT_TEXTS[o.TYPE_SUCCESS]="Success",o.DEFAULT_TEXTS[o.TYPE_WARNING]="Warning",o.DEFAULT_TEXTS[o.TYPE_DANGER]="Danger",o.DEFAULT_TEXTS.OK="OK",o.DEFAULT_TEXTS.CANCEL="Cancel",o.DEFAULT_TEXTS.CONFIRM="Confirmation",o.SIZE_NORMAL="size-normal",o.SIZE_SMALL="size-small",o.SIZE_WIDE="size-wide",o.SIZE_LARGE="size-large",o.BUTTON_SIZES={},o.BUTTON_SIZES[o.SIZE_NORMAL]="",o.BUTTON_SIZES[o.SIZE_SMALL]="",o.BUTTON_SIZES[o.SIZE_WIDE]="",o.BUTTON_SIZES[o.SIZE_LARGE]="btn-lg",o.ICON_SPINNER="glyphicon glyphicon-asterisk",o.defaultOptions={type:o.TYPE_PRIMARY,size:o.SIZE_NORMAL,cssClass:"",title:null,message:null,nl2br:!0,closable:!0,closeByBackdrop:!0,closeByKeyboard:!0,spinicon:o.ICON_SPINNER,autodestroy:!0,draggable:!1,animate:!0,description:"",tabindex:-1},o.configDefaultOptions=function(e){o.defaultOptions=t.extend(!0,o.defaultOptions,e)},o.dialogs={},o.openAll=function(){t.each(o.dialogs,function(t,e){e.open()})},o.closeAll=function(){t.each(o.dialogs,function(t,e){e.close()})},o.moveFocus=function(){var e=null;t.each(o.dialogs,function(t,n){e=n}),null!==e&&e.isRealized()&&e.getModal().focus()},o.METHODS_TO_OVERRIDE={},o.METHODS_TO_OVERRIDE["v3.1"]={handleModalBackdropEvent:function(){return this.getModal().on("click",{dialog:this},function(t){t.target===this&&t.data.dialog.isClosable()&&t.data.dialog.canCloseByBackdrop()&&t.data.dialog.close()}),this},updateZIndex:function(){var e=1040,n=1050,i=0;t.each(o.dialogs,function(t,e){i++});var s=this.getModal(),a=s.data("bs.modal").$backdrop;return s.css("z-index",n+20*(i-1)),a.css("z-index",e+20*(i-1)),this},open:function(){return!this.isRealized()&&this.realize(),this.getModal().modal("show"),this.updateZIndex(),this}},o.METHODS_TO_OVERRIDE["v3.2"]={handleModalBackdropEvent:o.METHODS_TO_OVERRIDE["v3.1"].handleModalBackdropEvent,updateZIndex:o.METHODS_TO_OVERRIDE["v3.1"].updateZIndex,open:o.METHODS_TO_OVERRIDE["v3.1"].open},o.METHODS_TO_OVERRIDE["v3.3"]={},o.METHODS_TO_OVERRIDE["v3.3.4"]=t.extend({},o.METHODS_TO_OVERRIDE["v3.1"]),o.prototype={constructor:o,initOptions:function(e){return this.options=t.extend(!0,this.defaultOptions,e),this},holdThisInstance:function(){return o.dialogs[this.getId()]=this,this},initModalStuff:function(){return this.setModal(this.createModal()).setModalDialog(this.createModalDialog()).setModalContent(this.createModalContent()).setModalHeader(this.createModalHeader()).setModalBody(this.createModalBody()).setModalFooter(this.createModalFooter()),this.getModal().append(this.getModalDialog()),this.getModalDialog().append(this.getModalContent()),this.getModalContent().append(this.getModalHeader()).append(this.getModalBody()).append(this.getModalFooter()),this},createModal:function(){var e=t('<div class="modal" role="dialog" aria-hidden="true"></div>');return e.prop("id",this.getId()),e.attr("aria-labelledby",this.getId()+"_title"),e},getModal:function(){return this.$modal},setModal:function(t){return this.$modal=t,this},createModalDialog:function(){return t('<div class="modal-dialog"></div>')},getModalDialog:function(){return this.$modalDialog},setModalDialog:function(t){return this.$modalDialog=t,this},createModalContent:function(){return t('<div class="modal-content"></div>')},getModalContent:function(){return this.$modalContent},setModalContent:function(t){return this.$modalContent=t,this},createModalHeader:function(){return t('<div class="modal-header"></div>')},getModalHeader:function(){return this.$modalHeader},setModalHeader:function(t){return this.$modalHeader=t,this},createModalBody:function(){return t('<div class="modal-body"></div>')},getModalBody:function(){return this.$modalBody},setModalBody:function(t){return this.$modalBody=t,this},createModalFooter:function(){return t('<div class="modal-footer"></div>')},getModalFooter:function(){return this.$modalFooter},setModalFooter:function(t){return this.$modalFooter=t,this},createDynamicContent:function(t){var e=null;return e="function"==typeof t?t.call(t,this):t,"string"==typeof e&&(e=this.formatStringContent(e)),e},formatStringContent:function(t){return this.options.nl2br?t.replace(/\r\n/g,"<br />").replace(/[\r\n]/g,"<br />"):t},setData:function(t,e){return this.options.data[t]=e,this},getData:function(t){return this.options.data[t]},setId:function(t){return this.options.id=t,this},getId:function(){return this.options.id},getType:function(){return this.options.type},setType:function(t){return this.options.type=t,this.updateType(),this},updateType:function(){if(this.isRealized()){var t=[o.TYPE_DEFAULT,o.TYPE_INFO,o.TYPE_PRIMARY,o.TYPE_SUCCESS,o.TYPE_WARNING,o.TYPE_DANGER];this.getModal().removeClass(t.join(" ")).addClass(this.getType())}return this},getSize:function(){return this.options.size},setSize:function(t){return this.options.size=t,this.updateSize(),this},updateSize:function(){if(this.isRealized()){var e=this;this.getModal().removeClass(o.SIZE_NORMAL).removeClass(o.SIZE_SMALL).removeClass(o.SIZE_WIDE).removeClass(o.SIZE_LARGE),this.getModal().addClass(this.getSize()),this.getModalDialog().removeClass("modal-sm"),this.getSize()===o.SIZE_SMALL&&this.getModalDialog().addClass("modal-sm"),this.getModalDialog().removeClass("modal-lg"),this.getSize()===o.SIZE_WIDE&&this.getModalDialog().addClass("modal-lg"),t.each(this.options.buttons,function(n,o){var i=e.getButton(o.id),s=["btn-lg","btn-sm","btn-xs"],a=!1;if("string"==typeof o.cssClass){var d=o.cssClass.split(" ");t.each(d,function(e,n){-1!==t.inArray(n,s)&&(a=!0)})}a||(i.removeClass(s.join(" ")),i.addClass(e.getButtonSize()))})}return this},getCssClass:function(){return this.options.cssClass},setCssClass:function(t){return this.options.cssClass=t,this},getTitle:function(){return this.options.title},setTitle:function(t){return this.options.title=t,this.updateTitle(),this},updateTitle:function(){if(this.isRealized()){var t=null!==this.getTitle()?this.createDynamicContent(this.getTitle()):this.getDefaultText();this.getModalHeader().find("."+this.getNamespace("title")).html("").append(t).prop("id",this.getId()+"_title")}return this},getMessage:function(){return this.options.message},setMessage:function(t){return this.options.message=t,this.updateMessage(),this},updateMessage:function(){if(this.isRealized()){var t=this.createDynamicContent(this.getMessage());this.getModalBody().find("."+this.getNamespace("message")).html("").append(t)}return this},isClosable:function(){return this.options.closable},setClosable:function(t){return this.options.closable=t,this.updateClosable(),this},setCloseByBackdrop:function(t){return this.options.closeByBackdrop=t,this},canCloseByBackdrop:function(){return this.options.closeByBackdrop},setCloseByKeyboard:function(t){return this.options.closeByKeyboard=t,this},canCloseByKeyboard:function(){return this.options.closeByKeyboard},isAnimate:function(){return this.options.animate},setAnimate:function(t){return this.options.animate=t,this},updateAnimate:function(){return this.isRealized()&&this.getModal().toggleClass("fade",this.isAnimate()),this},getSpinicon:function(){return this.options.spinicon},setSpinicon:function(t){return this.options.spinicon=t,this},addButton:function(t){return this.options.buttons.push(t),this},addButtons:function(e){var n=this;return t.each(e,function(t,e){n.addButton(e)}),this},getButtons:function(){return this.options.buttons},setButtons:function(t){return this.options.buttons=t,this.updateButtons(),this},getButton:function(t){return"undefined"!=typeof this.indexedButtons[t]?this.indexedButtons[t]:null},getButtonSize:function(){return"undefined"!=typeof o.BUTTON_SIZES[this.getSize()]?o.BUTTON_SIZES[this.getSize()]:""},updateButtons:function(){return this.isRealized()&&(0===this.getButtons().length?this.getModalFooter().hide():this.getModalFooter().show().find("."+this.getNamespace("footer")).html("").append(this.createFooterButtons())),this},isAutodestroy:function(){return this.options.autodestroy},setAutodestroy:function(t){this.options.autodestroy=t},getDescription:function(){return this.options.description},setDescription:function(t){return this.options.description=t,this},setTabindex:function(t){return this.options.tabindex=t,this},getTabindex:function(){return this.options.tabindex},updateTabindex:function(){return this.isRealized()&&this.getModal().attr("tabindex",this.getTabindex()),this},getDefaultText:function(){return o.DEFAULT_TEXTS[this.getType()]},getNamespace:function(t){return o.NAMESPACE+"-"+t},createHeaderContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("header")),e.append(this.createTitleContent()),e.prepend(this.createCloseButton()),e},createTitleContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("title")),e},createCloseButton:function(){var e=t("<div></div>");e.addClass(this.getNamespace("close-button"));var n=t('<button class="close">×</button>');return e.append(n),e.on("click",{dialog:this},function(t){t.data.dialog.close()}),e},createBodyContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("body")),e.append(this.createMessageContent()),e},createMessageContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("message")),e},createFooterContent:function(){var e=t("<div></div>");return e.addClass(this.getNamespace("footer")),e},createFooterButtons:function(){var e=this,n=t("<div></div>");return n.addClass(this.getNamespace("footer-buttons")),this.indexedButtons={},t.each(this.options.buttons,function(t,i){i.id||(i.id=o.newGuid());var s=e.createButton(i);e.indexedButtons[i.id]=s,n.append(s)}),n},createButton:function(e){var n=t('<button class="btn"></button>');return n.prop("id",e.id),n.data("button",e),"undefined"!=typeof e.icon&&""!==t.trim(e.icon)&&n.append(this.createButtonIcon(e.icon)),"undefined"!=typeof e.label&&n.append(e.label),n.addClass("undefined"!=typeof e.cssClass&&""!==t.trim(e.cssClass)?e.cssClass:"btn-default"),"undefined"!=typeof e.hotkey&&(this.registeredButtonHotkeys[e.hotkey]=n),n.on("click",{dialog:this,$button:n,button:e},function(t){var e=t.data.dialog,n=t.data.$button,o=n.data("button");"function"==typeof o.action&&o.action.call(n,e,t),o.autospin&&n.toggleSpin(!0)}),this.enhanceButton(n),n},enhanceButton:function(t){return t.dialog=this,t.toggleEnable=function(t){var e=this;return"undefined"!=typeof t?e.prop("disabled",!t).toggleClass("disabled",!t):e.prop("disabled",!e.prop("disabled")),e},t.enable=function(){var t=this;return t.toggleEnable(!0),t},t.disable=function(){var t=this;return t.toggleEnable(!1),t},t.toggleSpin=function(e){var n=this,o=n.dialog,i=n.find("."+o.getNamespace("button-icon"));return"undefined"==typeof e&&(e=!(t.find(".icon-spin").length>0)),e?(i.hide(),t.prepend(o.createButtonIcon(o.getSpinicon()).addClass("icon-spin"))):(i.show(),t.find(".icon-spin").remove()),n},t.spin=function(){var t=this;return t.toggleSpin(!0),t},t.stopSpin=function(){var t=this;return t.toggleSpin(!1),t},this},createButtonIcon:function(e){var n=t("<span></span>");return n.addClass(this.getNamespace("button-icon")).addClass(e),n},enableButtons:function(e){return t.each(this.indexedButtons,function(t,n){n.toggleEnable(e)}),this},updateClosable:function(){return this.isRealized()&&this.getModalHeader().find("."+this.getNamespace("close-button")).toggle(this.isClosable()),this},onShow:function(t){return this.options.onshow=t,this},onShown:function(t){return this.options.onshown=t,this},onHide:function(t){return this.options.onhide=t,this},onHidden:function(t){return this.options.onhidden=t,this},isRealized:function(){return this.realized},setRealized:function(t){return this.realized=t,this},isOpened:function(){return this.opened},setOpened:function(t){return this.opened=t,this},handleModalEvents:function(){return this.getModal().on("show.bs.modal",{dialog:this},function(t){var e=t.data.dialog;if(e.setOpened(!0),e.isModalEvent(t)&&"function"==typeof e.options.onshow){var n=e.options.onshow(e);return n===!1&&e.setOpened(!1),n}}),this.getModal().on("shown.bs.modal",{dialog:this},function(t){var e=t.data.dialog;e.isModalEvent(t)&&"function"==typeof e.options.onshown&&e.options.onshown(e)}),this.getModal().on("hide.bs.modal",{dialog:this},function(t){var e=t.data.dialog;if(e.setOpened(!1),e.isModalEvent(t)&&"function"==typeof e.options.onhide){var n=e.options.onhide(e);return n===!1&&e.setOpened(!0),n}}),this.getModal().on("hidden.bs.modal",{dialog:this},function(e){var n=e.data.dialog;n.isModalEvent(e)&&"function"==typeof n.options.onhidden&&n.options.onhidden(n),n.isAutodestroy()&&(delete o.dialogs[n.getId()],t(this).remove()),o.moveFocus()}),this.handleModalBackdropEvent(),this.getModal().on("keyup",{dialog:this},function(t){27===t.which&&t.data.dialog.isClosable()&&t.data.dialog.canCloseByKeyboard()&&t.data.dialog.close()}),this.getModal().on("keyup",{dialog:this},function(e){var n=e.data.dialog;if("undefined"!=typeof n.registeredButtonHotkeys[e.which]){var o=t(n.registeredButtonHotkeys[e.which]);!o.prop("disabled")&&o.focus().trigger("click")}}),this},handleModalBackdropEvent:function(){return this.getModal().on("click",{dialog:this},function(e){t(e.target).hasClass("modal-backdrop")&&e.data.dialog.isClosable()&&e.data.dialog.canCloseByBackdrop()&&e.data.dialog.close()}),this},isModalEvent:function(t){return"undefined"!=typeof t.namespace&&"bs.modal"===t.namespace},makeModalDraggable:function(){return this.options.draggable&&(this.getModalHeader().addClass(this.getNamespace("draggable")).on("mousedown",{dialog:this},function(t){var e=t.data.dialog;e.draggableData.isMouseDown=!0;var n=e.getModalDialog().offset();e.draggableData.mouseOffset={top:t.clientY-n.top,left:t.clientX-n.left}}),this.getModal().on("mouseup mouseleave",{dialog:this},function(t){t.data.dialog.draggableData.isMouseDown=!1}),t("body").on("mousemove",{dialog:this},function(t){var e=t.data.dialog;e.draggableData.isMouseDown&&e.getModalDialog().offset({top:t.clientY-e.draggableData.mouseOffset.top,left:t.clientX-e.draggableData.mouseOffset.left})})),this},realize:function(){return this.initModalStuff(),this.getModal().addClass(o.NAMESPACE).addClass(this.getCssClass()),this.updateSize(),this.getDescription()&&this.getModal().attr("aria-describedby",this.getDescription()),this.getModalFooter().append(this.createFooterContent()),this.getModalHeader().append(this.createHeaderContent()),this.getModalBody().append(this.createBodyContent()),this.getModal().data("bs.modal",new n(this.getModal(),{backdrop:"static",keyboard:!1,show:!1})),this.makeModalDraggable(),this.handleModalEvents(),this.setRealized(!0),this.updateButtons(),this.updateType(),this.updateTitle(),this.updateMessage(),this.updateClosable(),this.updateAnimate(),this.updateSize(),this.updateTabindex(),this},open:function(){return!this.isRealized()&&this.realize(),this.getModal().modal("show"),this},close:function(){return this.getModal().modal("hide"),this}},o.prototype=t.extend(o.prototype,o.METHODS_TO_OVERRIDE[n.getModalVersion()]),o.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})},o.show=function(t){return new o(t).open()},o.alert=function(){var e={},n={type:o.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,buttonLabel:o.DEFAULT_TEXTS.OK,callback:null};return e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,n,arguments[0]):t.extend(!0,n,{message:arguments[0],callback:"undefined"!=typeof arguments[1]?arguments[1]:null}),new o({type:e.type,title:e.title,message:e.message,closable:e.closable,draggable:e.draggable,data:{callback:e.callback},onhide:function(t){!t.getData("btnClicked")&&t.isClosable()&&"function"==typeof t.getData("callback")&&t.getData("callback")(!1)},buttons:[{label:e.buttonLabel,action:function(t){t.setData("btnClicked",!0),"function"==typeof t.getData("callback")&&t.getData("callback")(!0),t.close()}}]}).open()},o.confirm=function(){var e={},n={type:o.TYPE_PRIMARY,title:null,message:null,closable:!1,draggable:!1,btnCancelLabel:o.DEFAULT_TEXTS.CANCEL,btnOKLabel:o.DEFAULT_TEXTS.OK,btnOKClass:null,callback:null};return e="object"==typeof arguments[0]&&arguments[0].constructor==={}.constructor?t.extend(!0,n,arguments[0]):t.extend(!0,n,{message:arguments[0],closable:!1,buttonLabel:o.DEFAULT_TEXTS.OK,callback:"undefined"!=typeof arguments[1]?arguments[1]:null}),null===e.btnOKClass&&(e.btnOKClass=["btn",e.type.split("-")[1]].join("-")),new o({type:e.type,title:e.title,message:e.message,closable:e.closable,draggable:e.draggable,data:{callback:e.callback},buttons:[{label:e.btnCancelLabel,action:function(t){"function"==typeof t.getData("callback")&&t.getData("callback")(!1),t.close()}},{label:e.btnOKLabel,cssClass:e.btnOKClass,action:function(t){"function"==typeof t.getData("callback")&&t.getData("callback")(!0),t.close()}}]}).open()},o.warning=function(t,e){return new o({type:o.TYPE_WARNING,message:t}).open()},o.danger=function(t,e){return new o({type:o.TYPE_DANGER,message:t}).open()},o.success=function(t,e){return new o({type:o.TYPE_SUCCESS,message:t}).open()},o}); 16330 16331 /***/ }, 16332 /* 59 */ 16333 /***/ function(module, exports, __webpack_require__) { 16334 16335 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 16336 * Bootstrap-select v1.11.2 (http://silviomoreto.github.io/bootstrap-select) 16337 * 16338 * Copyright 2013-2016 bootstrap-select 16339 * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE) 16340 */ 16341 16342 (function (root, factory) { 16343 if (true) { 16344 // AMD. Register as an anonymous module unless amdModuleId is set 16345 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1)], __WEBPACK_AMD_DEFINE_RESULT__ = function (a0) { 16346 return (factory(a0)); 16347 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 16348 } else if (typeof exports === 'object') { 16349 // Node. Does not work with strict CommonJS, but 16350 // only CommonJS-like environments that support module.exports, 16351 // like Node. 16352 module.exports = factory(require("jquery")); 16353 } else { 16354 factory(jQuery); 16355 } 16356 }(this, function (jQuery) { 16357 16358 (function ($) { 16359 'use strict'; 16360 16361 //<editor-fold desc="Shims"> 16362 if (!String.prototype.includes) { 16363 (function () { 16364 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` 16365 var toString = {}.toString; 16366 var defineProperty = (function () { 16367 // IE 8 only supports `Object.defineProperty` on DOM elements 16368 try { 16369 var object = {}; 16370 var $defineProperty = Object.defineProperty; 16371 var result = $defineProperty(object, object, object) && $defineProperty; 16372 } catch (error) { 16373 } 16374 return result; 16375 }()); 16376 var indexOf = ''.indexOf; 16377 var includes = function (search) { 16378 if (this == null) { 16379 throw new TypeError(); 16380 } 16381 var string = String(this); 16382 if (search && toString.call(search) == '[object RegExp]') { 16383 throw new TypeError(); 16384 } 16385 var stringLength = string.length; 16386 var searchString = String(search); 16387 var searchLength = searchString.length; 16388 var position = arguments.length > 1 ? arguments[1] : undefined; 16389 // `ToInteger` 16390 var pos = position ? Number(position) : 0; 16391 if (pos != pos) { // better `isNaN` 16392 pos = 0; 16393 } 16394 var start = Math.min(Math.max(pos, 0), stringLength); 16395 // Avoid the `indexOf` call if no match is possible 16396 if (searchLength + start > stringLength) { 16397 return false; 16398 } 16399 return indexOf.call(string, searchString, pos) != -1; 16400 }; 16401 if (defineProperty) { 16402 defineProperty(String.prototype, 'includes', { 16403 'value': includes, 16404 'configurable': true, 16405 'writable': true 16406 }); 16407 } else { 16408 String.prototype.includes = includes; 16409 } 16410 }()); 16411 } 16412 16413 if (!String.prototype.startsWith) { 16414 (function () { 16415 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` 16416 var defineProperty = (function () { 16417 // IE 8 only supports `Object.defineProperty` on DOM elements 16418 try { 16419 var object = {}; 16420 var $defineProperty = Object.defineProperty; 16421 var result = $defineProperty(object, object, object) && $defineProperty; 16422 } catch (error) { 16423 } 16424 return result; 16425 }()); 16426 var toString = {}.toString; 16427 var startsWith = function (search) { 16428 if (this == null) { 16429 throw new TypeError(); 16430 } 16431 var string = String(this); 16432 if (search && toString.call(search) == '[object RegExp]') { 16433 throw new TypeError(); 16434 } 16435 var stringLength = string.length; 16436 var searchString = String(search); 16437 var searchLength = searchString.length; 16438 var position = arguments.length > 1 ? arguments[1] : undefined; 16439 // `ToInteger` 16440 var pos = position ? Number(position) : 0; 16441 if (pos != pos) { // better `isNaN` 16442 pos = 0; 16443 } 16444 var start = Math.min(Math.max(pos, 0), stringLength); 16445 // Avoid the `indexOf` call if no match is possible 16446 if (searchLength + start > stringLength) { 16447 return false; 16448 } 16449 var index = -1; 16450 while (++index < searchLength) { 16451 if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) { 16452 return false; 16453 } 16454 } 16455 return true; 16456 }; 16457 if (defineProperty) { 16458 defineProperty(String.prototype, 'startsWith', { 16459 'value': startsWith, 16460 'configurable': true, 16461 'writable': true 16462 }); 16463 } else { 16464 String.prototype.startsWith = startsWith; 16465 } 16466 }()); 16467 } 16468 16469 if (!Object.keys) { 16470 Object.keys = function ( 16471 o, // object 16472 k, // key 16473 r // result array 16474 ){ 16475 // initialize object and result 16476 r=[]; 16477 // iterate over object keys 16478 for (k in o) 16479 // fill result array with non-prototypical keys 16480 r.hasOwnProperty.call(o, k) && r.push(k); 16481 // return result 16482 return r; 16483 }; 16484 } 16485 16486 // set data-selected on select element if the value has been programmatically selected 16487 // prior to initialization of bootstrap-select 16488 // * consider removing or replacing an alternative method * 16489 var valHooks = { 16490 useDefault: false, 16491 _set: $.valHooks.select.set 16492 }; 16493 16494 $.valHooks.select.set = function(elem, value) { 16495 if (value && !valHooks.useDefault) $(elem).data('selected', true); 16496 16497 return valHooks._set.apply(this, arguments); 16498 }; 16499 16500 var changed_arguments = null; 16501 $.fn.triggerNative = function (eventName) { 16502 var el = this[0], 16503 event; 16504 16505 if (el.dispatchEvent) { // for modern browsers & IE9+ 16506 if (typeof Event === 'function') { 16507 // For modern browsers 16508 event = new Event(eventName, { 16509 bubbles: true 16510 }); 16511 } else { 16512 // For IE since it doesn't support Event constructor 16513 event = document.createEvent('Event'); 16514 event.initEvent(eventName, true, false); 16515 } 16516 16517 el.dispatchEvent(event); 16518 } else if (el.fireEvent) { // for IE8 16519 event = document.createEventObject(); 16520 event.eventType = eventName; 16521 el.fireEvent('on' + eventName, event); 16522 } else { 16523 // fall back to jQuery.trigger 16524 this.trigger(eventName); 16525 } 16526 }; 16527 //</editor-fold> 16528 16529 // Case insensitive contains search 16530 $.expr.pseudos.icontains = function (obj, index, meta) { 16531 var $obj = $(obj); 16532 var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase(); 16533 return haystack.includes(meta[3].toUpperCase()); 16534 }; 16535 16536 // Case insensitive begins search 16537 $.expr.pseudos.ibegins = function (obj, index, meta) { 16538 var $obj = $(obj); 16539 var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase(); 16540 return haystack.startsWith(meta[3].toUpperCase()); 16541 }; 16542 16543 // Case and accent insensitive contains search 16544 $.expr.pseudos.aicontains = function (obj, index, meta) { 16545 var $obj = $(obj); 16546 var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase(); 16547 return haystack.includes(meta[3].toUpperCase()); 16548 }; 16549 16550 // Case and accent insensitive begins search 16551 $.expr.pseudos.aibegins = function (obj, index, meta) { 16552 var $obj = $(obj); 16553 var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase(); 16554 return haystack.startsWith(meta[3].toUpperCase()); 16555 }; 16556 16557 /** 16558 * Remove all diatrics from the given text. 16559 * @access private 16560 * @param {String} text 16561 * @returns {String} 16562 */ 16563 function normalizeToBase(text) { 16564 var rExps = [ 16565 {re: /[\xC0-\xC6]/g, ch: "A"}, 16566 {re: /[\xE0-\xE6]/g, ch: "a"}, 16567 {re: /[\xC8-\xCB]/g, ch: "E"}, 16568 {re: /[\xE8-\xEB]/g, ch: "e"}, 16569 {re: /[\xCC-\xCF]/g, ch: "I"}, 16570 {re: /[\xEC-\xEF]/g, ch: "i"}, 16571 {re: /[\xD2-\xD6]/g, ch: "O"}, 16572 {re: /[\xF2-\xF6]/g, ch: "o"}, 16573 {re: /[\xD9-\xDC]/g, ch: "U"}, 16574 {re: /[\xF9-\xFC]/g, ch: "u"}, 16575 {re: /[\xC7-\xE7]/g, ch: "c"}, 16576 {re: /[\xD1]/g, ch: "N"}, 16577 {re: /[\xF1]/g, ch: "n"} 16578 ]; 16579 $.each(rExps, function () { 16580 text = text.replace(this.re, this.ch); 16581 }); 16582 return text; 16583 } 16584 16585 16586 function htmlEscape(html) { 16587 var escapeMap = { 16588 '&': '&', 16589 '<': '<', 16590 '>': '>', 16591 '"': '"', 16592 "'": ''', 16593 '`': '`' 16594 }; 16595 var source = '(?:' + Object.keys(escapeMap).join('|') + ')', 16596 testRegexp = new RegExp(source), 16597 replaceRegexp = new RegExp(source, 'g'), 16598 string = html == null ? '' : '' + html; 16599 return testRegexp.test(string) ? string.replace(replaceRegexp, function (match) { 16600 return escapeMap[match]; 16601 }) : string; 16602 } 16603 16604 var Selectpicker = function (element, options, e) { 16605 // bootstrap-select has been initialized - revert valHooks.select.set back to its original function 16606 if (!valHooks.useDefault) { 16607 $.valHooks.select.set = valHooks._set; 16608 valHooks.useDefault = true; 16609 } 16610 16611 if (e) { 16612 e.stopPropagation(); 16613 e.preventDefault(); 16614 } 16615 16616 this.$element = $(element); 16617 this.$newElement = null; 16618 this.$button = null; 16619 this.$menu = null; 16620 this.$lis = null; 16621 this.options = options; 16622 16623 // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a 16624 // data-attribute) 16625 if (this.options.title === null) { 16626 this.options.title = this.$element.attr('title'); 16627 } 16628 16629 //Expose public methods 16630 this.val = Selectpicker.prototype.val; 16631 this.render = Selectpicker.prototype.render; 16632 this.refresh = Selectpicker.prototype.refresh; 16633 this.setStyle = Selectpicker.prototype.setStyle; 16634 this.selectAll = Selectpicker.prototype.selectAll; 16635 this.deselectAll = Selectpicker.prototype.deselectAll; 16636 this.destroy = Selectpicker.prototype.destroy; 16637 this.remove = Selectpicker.prototype.remove; 16638 this.show = Selectpicker.prototype.show; 16639 this.hide = Selectpicker.prototype.hide; 16640 16641 this.init(); 16642 }; 16643 16644 Selectpicker.VERSION = '1.11.2'; 16645 16646 // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both. 16647 Selectpicker.DEFAULTS = { 16648 noneSelectedText: 'Nothing selected', 16649 noneResultsText: 'No results matched {0}', 16650 countSelectedText: function (numSelected, numTotal) { 16651 return (numSelected == 1) ? "{0} item selected" : "{0} items selected"; 16652 }, 16653 maxOptionsText: function (numAll, numGroup) { 16654 return [ 16655 (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)', 16656 (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)' 16657 ]; 16658 }, 16659 selectAllText: 'Select All', 16660 deselectAllText: 'Deselect All', 16661 doneButton: false, 16662 doneButtonText: 'Close', 16663 multipleSeparator: ', ', 16664 styleBase: 'btn', 16665 style: 'btn-default', 16666 size: 'auto', 16667 title: null, 16668 selectedTextFormat: 'values', 16669 width: false, 16670 container: false, 16671 hideDisabled: false, 16672 showSubtext: false, 16673 showIcon: true, 16674 showContent: true, 16675 dropupAuto: true, 16676 header: false, 16677 liveSearch: false, 16678 liveSearchPlaceholder: null, 16679 liveSearchNormalize: false, 16680 liveSearchStyle: 'contains', 16681 actionsBox: false, 16682 iconBase: 'glyphicon', 16683 tickIcon: 'glyphicon-ok', 16684 showTick: false, 16685 template: { 16686 caret: '<span class="caret"></span>' 16687 }, 16688 maxOptions: false, 16689 mobile: false, 16690 selectOnTab: false, 16691 dropdownAlignRight: false 16692 }; 16693 16694 Selectpicker.prototype = { 16695 16696 constructor: Selectpicker, 16697 16698 init: function () { 16699 var that = this, 16700 id = this.$element.attr('id'); 16701 16702 this.$element.addClass('bs-select-hidden'); 16703 16704 // store originalIndex (key) and newIndex (value) in this.liObj for fast accessibility 16705 // allows us to do this.$lis.eq(that.liObj[index]) instead of this.$lis.filter('[data-original-index="' + index + '"]') 16706 this.liObj = {}; 16707 this.multiple = this.$element.prop('multiple'); 16708 this.autofocus = this.$element.prop('autofocus'); 16709 this.$newElement = this.createView(); 16710 this.$element 16711 .after(this.$newElement) 16712 .appendTo(this.$newElement); 16713 this.$button = this.$newElement.children('button'); 16714 this.$menu = this.$newElement.children('.dropdown-menu'); 16715 this.$menuInner = this.$menu.children('.inner'); 16716 this.$searchbox = this.$menu.find('input'); 16717 16718 this.$element.removeClass('bs-select-hidden'); 16719 16720 if (this.options.dropdownAlignRight === true) this.$menu.addClass('dropdown-menu-right'); 16721 16722 if (typeof id !== 'undefined') { 16723 this.$button.attr('data-id', id); 16724 $('label[for="' + id + '"]').click(function (e) { 16725 e.preventDefault(); 16726 that.$button.focus(); 16727 }); 16728 } 16729 16730 this.checkDisabled(); 16731 this.clickListener(); 16732 if (this.options.liveSearch) this.liveSearchListener(); 16733 this.render(); 16734 this.setStyle(); 16735 this.setWidth(); 16736 if (this.options.container) this.selectPosition(); 16737 this.$menu.data('this', this); 16738 this.$newElement.data('this', this); 16739 if (this.options.mobile) this.mobile(); 16740 16741 this.$newElement.on({ 16742 'hide.bs.dropdown': function (e) { 16743 that.$menuInner.attr('aria-expanded', false); 16744 that.$element.trigger('hide.bs.select', e); 16745 }, 16746 'hidden.bs.dropdown': function (e) { 16747 that.$element.trigger('hidden.bs.select', e); 16748 }, 16749 'show.bs.dropdown': function (e) { 16750 that.$menuInner.attr('aria-expanded', true); 16751 that.$element.trigger('show.bs.select', e); 16752 }, 16753 'shown.bs.dropdown': function (e) { 16754 that.$element.trigger('shown.bs.select', e); 16755 } 16756 }); 16757 16758 if (that.$element[0].hasAttribute('required')) { 16759 this.$element.on('invalid', function () { 16760 that.$button 16761 .addClass('bs-invalid') 16762 .focus(); 16763 16764 that.$element.on({ 16765 'focus.bs.select': function () { 16766 that.$button.focus(); 16767 that.$element.off('focus.bs.select'); 16768 }, 16769 'shown.bs.select': function () { 16770 that.$element 16771 .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened 16772 .off('shown.bs.select'); 16773 }, 16774 'rendered.bs.select': function () { 16775 // if select is no longer invalid, remove the bs-invalid class 16776 if (this.validity.valid) that.$button.removeClass('bs-invalid'); 16777 that.$element.off('rendered.bs.select'); 16778 } 16779 }); 16780 }); 16781 } 16782 16783 setTimeout(function () { 16784 that.$element.trigger('loaded.bs.select'); 16785 }); 16786 }, 16787 16788 createDropdown: function () { 16789 // Options 16790 // If we are multiple or showTick option is set, then add the show-tick class 16791 var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '', 16792 inputGroup = this.$element.parent().hasClass('input-group') ? ' input-group-btn' : '', 16793 autofocus = this.autofocus ? ' autofocus' : ''; 16794 // Elements 16795 var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">×</button>' + this.options.header + '</div>' : ''; 16796 var searchbox = this.options.liveSearch ? 16797 '<div class="bs-searchbox">' + 16798 '<input type="text" class="form-control" autocomplete="off"' + 16799 (null === this.options.liveSearchPlaceholder ? '' : ' placeholder="' + htmlEscape(this.options.liveSearchPlaceholder) + '"') + ' role="textbox" aria-label="Search">' + 16800 '</div>' 16801 : ''; 16802 var actionsbox = this.multiple && this.options.actionsBox ? 16803 '<div class="bs-actionsbox">' + 16804 '<div class="btn-group btn-group-sm btn-block">' + 16805 '<button type="button" class="actions-btn bs-select-all btn btn-default">' + 16806 this.options.selectAllText + 16807 '</button>' + 16808 '<button type="button" class="actions-btn bs-deselect-all btn btn-default">' + 16809 this.options.deselectAllText + 16810 '</button>' + 16811 '</div>' + 16812 '</div>' 16813 : ''; 16814 var donebutton = this.multiple && this.options.doneButton ? 16815 '<div class="bs-donebutton">' + 16816 '<div class="btn-group btn-block">' + 16817 '<button type="button" class="btn btn-sm btn-default">' + 16818 this.options.doneButtonText + 16819 '</button>' + 16820 '</div>' + 16821 '</div>' 16822 : ''; 16823 var drop = 16824 '<div class="btn-group bootstrap-select' + showTick + inputGroup + '">' + 16825 '<button type="button" class="' + this.options.styleBase + ' dropdown-toggle" data-toggle="dropdown"' + autofocus + ' role="button">' + 16826 '<span class="filter-option pull-left"></span> ' + 16827 '<span class="bs-caret">' + 16828 this.options.template.caret + 16829 '</span>' + 16830 '</button>' + 16831 '<div class="dropdown-menu open" role="combobox">' + 16832 header + 16833 searchbox + 16834 actionsbox + 16835 '<ul class="dropdown-menu inner" role="listbox" aria-expanded="false">' + 16836 '</ul>' + 16837 donebutton + 16838 '</div>' + 16839 '</div>'; 16840 16841 return $(drop); 16842 }, 16843 16844 createView: function () { 16845 var $drop = this.createDropdown(), 16846 li = this.createLi(); 16847 16848 $drop.find('ul')[0].innerHTML = li; 16849 return $drop; 16850 }, 16851 16852 reloadLi: function () { 16853 //Remove all children. 16854 this.destroyLi(); 16855 //Re build 16856 var li = this.createLi(); 16857 this.$menuInner[0].innerHTML = li; 16858 }, 16859 16860 destroyLi: function () { 16861 this.$menu.find('li').remove(); 16862 }, 16863 16864 createLi: function () { 16865 var that = this, 16866 _li = [], 16867 optID = 0, 16868 titleOption = document.createElement('option'), 16869 liIndex = -1; // increment liIndex whenever a new <li> element is created to ensure liObj is correct 16870 16871 // Helper functions 16872 /** 16873 * @param content 16874 * @param [index] 16875 * @param [classes] 16876 * @param [optgroup] 16877 * @returns {string} 16878 */ 16879 var generateLI = function (content, index, classes, optgroup) { 16880 return '<li' + 16881 ((typeof classes !== 'undefined' & '' !== classes) ? ' class="' + classes + '"' : '') + 16882 ((typeof index !== 'undefined' & null !== index) ? ' data-original-index="' + index + '"' : '') + 16883 ((typeof optgroup !== 'undefined' & null !== optgroup) ? 'data-optgroup="' + optgroup + '"' : '') + 16884 '>' + content + '</li>'; 16885 }; 16886 16887 /** 16888 * @param text 16889 * @param [classes] 16890 * @param [inline] 16891 * @param [tokens] 16892 * @returns {string} 16893 */ 16894 var generateA = function (text, classes, inline, tokens) { 16895 return '<a tabindex="0"' + 16896 (typeof classes !== 'undefined' ? ' class="' + classes + '"' : '') + 16897 (typeof inline !== 'undefined' ? ' style="' + inline + '"' : '') + 16898 (that.options.liveSearchNormalize ? ' data-normalized-text="' + normalizeToBase(htmlEscape(text)) + '"' : '') + 16899 (typeof tokens !== 'undefined' || tokens !== null ? ' data-tokens="' + tokens + '"' : '') + 16900 ' role="option">' + text + 16901 '<span class="' + that.options.iconBase + ' ' + that.options.tickIcon + ' check-mark"></span>' + 16902 '</a>'; 16903 }; 16904 16905 if (this.options.title && !this.multiple) { 16906 // this option doesn't create a new <li> element, but does add a new option, so liIndex is decreased 16907 // since liObj is recalculated on every refresh, liIndex needs to be decreased even if the titleOption is already appended 16908 liIndex--; 16909 16910 if (!this.$element.find('.bs-title-option').length) { 16911 // Use native JS to prepend option (faster) 16912 var element = this.$element[0]; 16913 titleOption.className = 'bs-title-option'; 16914 titleOption.appendChild(document.createTextNode(this.options.title)); 16915 titleOption.value = ''; 16916 element.insertBefore(titleOption, element.firstChild); 16917 // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option. 16918 // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs, 16919 // if so, the select will have the data-selected attribute 16920 var $opt = $(element.options[element.selectedIndex]); 16921 if ($opt.attr('selected') === undefined && this.$element.data('selected') === undefined) { 16922 titleOption.selected = true; 16923 } 16924 } 16925 } 16926 16927 this.$element.find('option').each(function (index) { 16928 var $this = $(this); 16929 16930 liIndex++; 16931 16932 if ($this.hasClass('bs-title-option')) return; 16933 16934 // Get the class and text for the option 16935 var optionClass = this.className || '', 16936 inline = this.style.cssText, 16937 text = $this.data('content') ? $this.data('content') : $this.html(), 16938 tokens = $this.data('tokens') ? $this.data('tokens') : null, 16939 subtext = typeof $this.data('subtext') !== 'undefined' ? '<small class="text-muted">' + $this.data('subtext') + '</small>' : '', 16940 icon = typeof $this.data('icon') !== 'undefined' ? '<span class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></span> ' : '', 16941 $parent = $this.parent(), 16942 isOptgroup = $parent[0].tagName === 'OPTGROUP', 16943 isOptgroupDisabled = isOptgroup && $parent[0].disabled, 16944 isDisabled = this.disabled || isOptgroupDisabled; 16945 16946 if (icon !== '' && isDisabled) { 16947 icon = '<span>' + icon + '</span>'; 16948 } 16949 16950 if (that.options.hideDisabled && (isDisabled && !isOptgroup || isOptgroupDisabled)) { 16951 liIndex--; 16952 return; 16953 } 16954 16955 if (!$this.data('content')) { 16956 // Prepend any icon and append any subtext to the main text. 16957 text = icon + '<span class="text">' + text + subtext + '</span>'; 16958 } 16959 16960 if (isOptgroup && $this.data('divider') !== true) { 16961 if (that.options.hideDisabled && isDisabled) { 16962 if ($parent.data('allOptionsDisabled') === undefined) { 16963 var $options = $parent.children(); 16964 $parent.data('allOptionsDisabled', $options.filter(':disabled').length === $options.length); 16965 } 16966 16967 if ($parent.data('allOptionsDisabled')) { 16968 liIndex--; 16969 return; 16970 } 16971 } 16972 16973 var optGroupClass = ' ' + $parent[0].className || ''; 16974 16975 if ($this.index() === 0) { // Is it the first option of the optgroup? 16976 optID += 1; 16977 16978 // Get the opt group label 16979 var label = $parent[0].label, 16980 labelSubtext = typeof $parent.data('subtext') !== 'undefined' ? '<small class="text-muted">' + $parent.data('subtext') + '</small>' : '', 16981 labelIcon = $parent.data('icon') ? '<span class="' + that.options.iconBase + ' ' + $parent.data('icon') + '"></span> ' : ''; 16982 16983 label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>'; 16984 16985 if (index !== 0 && _li.length > 0) { // Is it NOT the first option of the select && are there elements in the dropdown? 16986 liIndex++; 16987 _li.push(generateLI('', null, 'divider', optID + 'div')); 16988 } 16989 liIndex++; 16990 _li.push(generateLI(label, null, 'dropdown-header' + optGroupClass, optID)); 16991 } 16992 16993 if (that.options.hideDisabled && isDisabled) { 16994 liIndex--; 16995 return; 16996 } 16997 16998 _li.push(generateLI(generateA(text, 'opt ' + optionClass + optGroupClass, inline, tokens), index, '', optID)); 16999 } else if ($this.data('divider') === true) { 17000 _li.push(generateLI('', index, 'divider')); 17001 } else if ($this.data('hidden') === true) { 17002 _li.push(generateLI(generateA(text, optionClass, inline, tokens), index, 'hidden is-hidden')); 17003 } else { 17004 var showDivider = this.previousElementSibling && this.previousElementSibling.tagName === 'OPTGROUP'; 17005 17006 // if previous element is not an optgroup and hideDisabled is true 17007 if (!showDivider && that.options.hideDisabled) { 17008 // get previous elements 17009 var $prev = $(this).prevAll(); 17010 17011 for (var i = 0; i < $prev.length; i++) { 17012 // find the first element in the previous elements that is an optgroup 17013 if ($prev[i].tagName === 'OPTGROUP') { 17014 var optGroupDistance = 0; 17015 17016 // loop through the options in between the current option and the optgroup 17017 // and check if they are hidden or disabled 17018 for (var d = 0; d < i; d++) { 17019 var prevOption = $prev[d]; 17020 if (prevOption.disabled || $(prevOption).data('hidden') === true) optGroupDistance++; 17021 } 17022 17023 // if all of the options between the current option and the optgroup are hidden or disabled, show the divider 17024 if (optGroupDistance === i) showDivider = true; 17025 17026 break; 17027 } 17028 } 17029 } 17030 17031 if (showDivider) { 17032 liIndex++; 17033 _li.push(generateLI('', null, 'divider', optID + 'div')); 17034 } 17035 _li.push(generateLI(generateA(text, optionClass, inline, tokens), index)); 17036 } 17037 17038 that.liObj[index] = liIndex; 17039 }); 17040 17041 //If we are not multiple, we don't have a selected item, and we don't have a title, select the first element so something is set in the button 17042 if (!this.multiple && this.$element.find('option:selected').length === 0 && !this.options.title) { 17043 this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected'); 17044 } 17045 17046 return _li.join(''); 17047 }, 17048 17049 findLis: function () { 17050 if (this.$lis == null) this.$lis = this.$menu.find('li'); 17051 return this.$lis; 17052 }, 17053 17054 /** 17055 * @param [updateLi] defaults to true 17056 */ 17057 render: function (updateLi) { 17058 var that = this, 17059 notDisabled; 17060 17061 //Update the LI to match the SELECT 17062 if (updateLi !== false) { 17063 this.$element.find('option').each(function (index) { 17064 var $lis = that.findLis().eq(that.liObj[index]); 17065 17066 that.setDisabled(index, this.disabled || this.parentNode.tagName === 'OPTGROUP' && this.parentNode.disabled, $lis); 17067 that.setSelected(index, this.selected, $lis); 17068 }); 17069 } 17070 17071 this.togglePlaceholder(); 17072 17073 this.tabIndex(); 17074 17075 var selectedItems = this.$element.find('option').map(function () { 17076 if (this.selected) { 17077 if (that.options.hideDisabled && (this.disabled || this.parentNode.tagName === 'OPTGROUP' && this.parentNode.disabled)) return; 17078 17079 var $this = $(this), 17080 icon = $this.data('icon') && that.options.showIcon ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '', 17081 subtext; 17082 17083 if (that.options.showSubtext && $this.data('subtext') && !that.multiple) { 17084 subtext = ' <small class="text-muted">' + $this.data('subtext') + '</small>'; 17085 } else { 17086 subtext = ''; 17087 } 17088 if (typeof $this.attr('title') !== 'undefined') { 17089 return $this.attr('title'); 17090 } else if ($this.data('content') && that.options.showContent) { 17091 return $this.data('content'); 17092 } else { 17093 return icon + $this.html() + subtext; 17094 } 17095 } 17096 }).toArray(); 17097 17098 //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled 17099 //Convert all the values into a comma delimited string 17100 var title = !this.multiple ? selectedItems[0] : selectedItems.join(this.options.multipleSeparator); 17101 17102 //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc.. 17103 if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) { 17104 var max = this.options.selectedTextFormat.split('>'); 17105 if ((max.length > 1 && selectedItems.length > max[1]) || (max.length == 1 && selectedItems.length >= 2)) { 17106 notDisabled = this.options.hideDisabled ? ', [disabled]' : ''; 17107 var totalCount = this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length, 17108 tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedItems.length, totalCount) : this.options.countSelectedText; 17109 title = tr8nText.replace('{0}', selectedItems.length.toString()).replace('{1}', totalCount.toString()); 17110 } 17111 } 17112 17113 if (this.options.title == undefined) { 17114 this.options.title = this.$element.attr('title'); 17115 } 17116 17117 if (this.options.selectedTextFormat == 'static') { 17118 title = this.options.title; 17119 } 17120 17121 //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text 17122 if (!title) { 17123 title = typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText; 17124 } 17125 17126 //strip all html-tags and trim the result 17127 this.$button.attr('title', $.trim(title.replace(/<[^>]*>?/g, ''))); 17128 this.$button.children('.filter-option').html(title); 17129 17130 this.$element.trigger('rendered.bs.select'); 17131 }, 17132 17133 /** 17134 * @param [style] 17135 * @param [status] 17136 */ 17137 setStyle: function (style, status) { 17138 if (this.$element.attr('class')) { 17139 this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, '')); 17140 } 17141 17142 var buttonClass = style ? style : this.options.style; 17143 17144 if (status == 'add') { 17145 this.$button.addClass(buttonClass); 17146 } else if (status == 'remove') { 17147 this.$button.removeClass(buttonClass); 17148 } else { 17149 this.$button.removeClass(this.options.style); 17150 this.$button.addClass(buttonClass); 17151 } 17152 }, 17153 17154 liHeight: function (refresh) { 17155 if (!refresh && (this.options.size === false || this.sizeInfo)) return; 17156 17157 var newElement = document.createElement('div'), 17158 menu = document.createElement('div'), 17159 menuInner = document.createElement('ul'), 17160 divider = document.createElement('li'), 17161 li = document.createElement('li'), 17162 a = document.createElement('a'), 17163 text = document.createElement('span'), 17164 header = this.options.header && this.$menu.find('.popover-title').length > 0 ? this.$menu.find('.popover-title')[0].cloneNode(true) : null, 17165 search = this.options.liveSearch ? document.createElement('div') : null, 17166 actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null, 17167 doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null; 17168 17169 text.className = 'text'; 17170 newElement.className = this.$menu[0].parentNode.className + ' open'; 17171 menu.className = 'dropdown-menu open'; 17172 menuInner.className = 'dropdown-menu inner'; 17173 divider.className = 'divider'; 17174 17175 text.appendChild(document.createTextNode('Inner text')); 17176 a.appendChild(text); 17177 li.appendChild(a); 17178 menuInner.appendChild(li); 17179 menuInner.appendChild(divider); 17180 if (header) menu.appendChild(header); 17181 if (search) { 17182 // create a span instead of input as creating an input element is slower 17183 var input = document.createElement('span'); 17184 search.className = 'bs-searchbox'; 17185 input.className = 'form-control'; 17186 search.appendChild(input); 17187 menu.appendChild(search); 17188 } 17189 if (actions) menu.appendChild(actions); 17190 menu.appendChild(menuInner); 17191 if (doneButton) menu.appendChild(doneButton); 17192 newElement.appendChild(menu); 17193 17194 document.body.appendChild(newElement); 17195 17196 var liHeight = a.offsetHeight, 17197 headerHeight = header ? header.offsetHeight : 0, 17198 searchHeight = search ? search.offsetHeight : 0, 17199 actionsHeight = actions ? actions.offsetHeight : 0, 17200 doneButtonHeight = doneButton ? doneButton.offsetHeight : 0, 17201 dividerHeight = $(divider).outerHeight(true), 17202 // fall back to jQuery if getComputedStyle is not supported 17203 menuStyle = typeof getComputedStyle === 'function' ? getComputedStyle(menu) : false, 17204 $menu = menuStyle ? null : $(menu), 17205 menuPadding = { 17206 vert: parseInt(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) + 17207 parseInt(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) + 17208 parseInt(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) + 17209 parseInt(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')), 17210 horiz: parseInt(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) + 17211 parseInt(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) + 17212 parseInt(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) + 17213 parseInt(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth')) 17214 }, 17215 menuExtras = { 17216 vert: menuPadding.vert + 17217 parseInt(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) + 17218 parseInt(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2, 17219 horiz: menuPadding.horiz + 17220 parseInt(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) + 17221 parseInt(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2 17222 } 17223 17224 document.body.removeChild(newElement); 17225 17226 this.sizeInfo = { 17227 liHeight: liHeight, 17228 headerHeight: headerHeight, 17229 searchHeight: searchHeight, 17230 actionsHeight: actionsHeight, 17231 doneButtonHeight: doneButtonHeight, 17232 dividerHeight: dividerHeight, 17233 menuPadding: menuPadding, 17234 menuExtras: menuExtras 17235 }; 17236 }, 17237 17238 setSize: function () { 17239 this.findLis(); 17240 this.liHeight(); 17241 17242 if (this.options.header) this.$menu.css('padding-top', 0); 17243 if (this.options.size === false) return; 17244 17245 var that = this, 17246 $menu = this.$menu, 17247 $menuInner = this.$menuInner, 17248 $window = $(window), 17249 selectHeight = this.$newElement[0].offsetHeight, 17250 selectWidth = this.$newElement[0].offsetWidth, 17251 liHeight = this.sizeInfo['liHeight'], 17252 headerHeight = this.sizeInfo['headerHeight'], 17253 searchHeight = this.sizeInfo['searchHeight'], 17254 actionsHeight = this.sizeInfo['actionsHeight'], 17255 doneButtonHeight = this.sizeInfo['doneButtonHeight'], 17256 divHeight = this.sizeInfo['dividerHeight'], 17257 menuPadding = this.sizeInfo['menuPadding'], 17258 menuExtras = this.sizeInfo['menuExtras'], 17259 notDisabled = this.options.hideDisabled ? '.disabled' : '', 17260 menuHeight, 17261 menuWidth, 17262 getHeight, 17263 getWidth, 17264 selectOffsetTop, 17265 selectOffsetBot, 17266 selectOffsetLeft, 17267 selectOffsetRight, 17268 getPos = function() { 17269 var pos = that.$newElement.offset(), 17270 $container = $(that.options.container), 17271 containerPos; 17272 17273 if (that.options.container && !$container.is('body')) { 17274 containerPos = $container.offset(); 17275 containerPos.top += parseInt($container.css('borderTopWidth')); 17276 containerPos.left += parseInt($container.css('borderLeftWidth')); 17277 } else { 17278 containerPos = { top: 0, left: 0 }; 17279 } 17280 17281 selectOffsetTop = pos.top - containerPos.top - $window.scrollTop(); 17282 selectOffsetBot = $window.height() - selectOffsetTop - selectHeight - containerPos.top; 17283 selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft(); 17284 selectOffsetRight = $window.width() - selectOffsetLeft - selectWidth - containerPos.left; 17285 }; 17286 17287 getPos(); 17288 17289 if (this.options.size === 'auto') { 17290 var getSize = function () { 17291 var minHeight, 17292 hasClass = function (className, include) { 17293 return function (element) { 17294 if (include) { 17295 return (element.classList ? element.classList.contains(className) : $(element).hasClass(className)); 17296 } else { 17297 return !(element.classList ? element.classList.contains(className) : $(element).hasClass(className)); 17298 } 17299 }; 17300 }, 17301 lis = that.$menuInner[0].getElementsByTagName('li'), 17302 lisVisible = Array.prototype.filter ? Array.prototype.filter.call(lis, hasClass('hidden', false)) : that.$lis.not('.hidden'), 17303 optGroup = Array.prototype.filter ? Array.prototype.filter.call(lisVisible, hasClass('dropdown-header', true)) : lisVisible.filter('.dropdown-header'); 17304 17305 getPos(); 17306 menuHeight = selectOffsetBot - menuExtras.vert; 17307 menuWidth = selectOffsetRight - menuExtras.horiz; 17308 17309 if (that.options.container) { 17310 if (!$menu.data('height')) $menu.data('height', $menu.height()); 17311 getHeight = $menu.data('height'); 17312 17313 if (!$menu.data('width')) $menu.data('width', $menu.width()); 17314 getWidth = $menu.data('width'); 17315 } else { 17316 getHeight = $menu.height(); 17317 getWidth = $menu.width(); 17318 } 17319 17320 if (that.options.dropupAuto) { 17321 that.$newElement.toggleClass('dropup', selectOffsetTop > selectOffsetBot && (menuHeight - menuExtras.vert) < getHeight); 17322 } 17323 17324 if (that.$newElement.hasClass('dropup')) { 17325 menuHeight = selectOffsetTop - menuExtras.vert; 17326 } 17327 17328 if (that.options.dropdownAlignRight === 'auto') { 17329 $menu.toggleClass('dropdown-menu-right', selectOffsetLeft > selectOffsetRight && (menuWidth - menuExtras.horiz) < (getWidth - selectWidth)); 17330 } 17331 17332 if ((lisVisible.length + optGroup.length) > 3) { 17333 minHeight = liHeight * 3 + menuExtras.vert - 2; 17334 } else { 17335 minHeight = 0; 17336 } 17337 17338 $menu.css({ 17339 'max-height': menuHeight + 'px', 17340 'overflow': 'hidden', 17341 'min-height': minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight + 'px' 17342 }); 17343 $menuInner.css({ 17344 'max-height': menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert + 'px', 17345 'overflow-y': 'auto', 17346 'min-height': Math.max(minHeight - menuPadding.vert, 0) + 'px' 17347 }); 17348 }; 17349 getSize(); 17350 this.$searchbox.off('input.getSize propertychange.getSize').on('input.getSize propertychange.getSize', getSize); 17351 $window.off('resize.getSize scroll.getSize').on('resize.getSize scroll.getSize', getSize); 17352 } else if (this.options.size && this.options.size != 'auto' && this.$lis.not(notDisabled).length > this.options.size) { 17353 var optIndex = this.$lis.not('.divider').not(notDisabled).children().slice(0, this.options.size).last().parent().index(), 17354 divLength = this.$lis.slice(0, optIndex + 1).filter('.divider').length; 17355 menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert; 17356 17357 if (that.options.container) { 17358 if (!$menu.data('height')) $menu.data('height', $menu.height()); 17359 getHeight = $menu.data('height'); 17360 } else { 17361 getHeight = $menu.height(); 17362 } 17363 17364 if (that.options.dropupAuto) { 17365 //noinspection JSUnusedAssignment 17366 this.$newElement.toggleClass('dropup', selectOffsetTop > selectOffsetBot && (menuHeight - menuExtras.vert) < getHeight); 17367 } 17368 $menu.css({ 17369 'max-height': menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight + 'px', 17370 'overflow': 'hidden', 17371 'min-height': '' 17372 }); 17373 $menuInner.css({ 17374 'max-height': menuHeight - menuPadding.vert + 'px', 17375 'overflow-y': 'auto', 17376 'min-height': '' 17377 }); 17378 } 17379 }, 17380 17381 setWidth: function () { 17382 if (this.options.width === 'auto') { 17383 this.$menu.css('min-width', '0'); 17384 17385 // Get correct width if element is hidden 17386 var $selectClone = this.$menu.parent().clone().appendTo('body'), 17387 $selectClone2 = this.options.container ? this.$newElement.clone().appendTo('body') : $selectClone, 17388 ulWidth = $selectClone.children('.dropdown-menu').outerWidth(), 17389 btnWidth = $selectClone2.css('width', 'auto').children('button').outerWidth(); 17390 17391 $selectClone.remove(); 17392 $selectClone2.remove(); 17393 17394 // Set width to whatever's larger, button title or longest option 17395 this.$newElement.css('width', Math.max(ulWidth, btnWidth) + 'px'); 17396 } else if (this.options.width === 'fit') { 17397 // Remove inline min-width so width can be changed from 'auto' 17398 this.$menu.css('min-width', ''); 17399 this.$newElement.css('width', '').addClass('fit-width'); 17400 } else if (this.options.width) { 17401 // Remove inline min-width so width can be changed from 'auto' 17402 this.$menu.css('min-width', ''); 17403 this.$newElement.css('width', this.options.width); 17404 } else { 17405 // Remove inline min-width/width so width can be changed 17406 this.$menu.css('min-width', ''); 17407 this.$newElement.css('width', ''); 17408 } 17409 // Remove fit-width class if width is changed programmatically 17410 if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') { 17411 this.$newElement.removeClass('fit-width'); 17412 } 17413 }, 17414 17415 selectPosition: function () { 17416 this.$bsContainer = $('<div class="bs-container" />'); 17417 17418 var that = this, 17419 $container = $(this.options.container), 17420 pos, 17421 containerPos, 17422 actualHeight, 17423 getPlacement = function ($element) { 17424 that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass('dropup', $element.hasClass('dropup')); 17425 pos = $element.offset(); 17426 17427 if (!$container.is('body')) { 17428 containerPos = $container.offset(); 17429 containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop(); 17430 containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft(); 17431 } else { 17432 containerPos = { top: 0, left: 0 }; 17433 } 17434 17435 actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight; 17436 17437 that.$bsContainer.css({ 17438 'top': pos.top - containerPos.top + actualHeight, 17439 'left': pos.left - containerPos.left, 17440 'width': $element[0].offsetWidth 17441 }); 17442 }; 17443 17444 this.$button.on('click', function () { 17445 var $this = $(this); 17446 17447 if (that.isDisabled()) { 17448 return; 17449 } 17450 17451 getPlacement(that.$newElement); 17452 17453 that.$bsContainer 17454 .appendTo(that.options.container) 17455 .toggleClass('open', !$this.hasClass('open')) 17456 .append(that.$menu); 17457 }); 17458 17459 $(window).on('resize scroll', function () { 17460 getPlacement(that.$newElement); 17461 }); 17462 17463 this.$element.on('hide.bs.select', function () { 17464 that.$menu.data('height', that.$menu.height()); 17465 that.$bsContainer.detach(); 17466 }); 17467 }, 17468 17469 /** 17470 * @param {number} index - the index of the option that is being changed 17471 * @param {boolean} selected - true if the option is being selected, false if being deselected 17472 * @param {JQuery} $lis - the 'li' element that is being modified 17473 */ 17474 setSelected: function (index, selected, $lis) { 17475 if (!$lis) { 17476 this.togglePlaceholder(); // check if setSelected is being called by changing the value of the select 17477 $lis = this.findLis().eq(this.liObj[index]); 17478 } 17479 17480 $lis.toggleClass('selected', selected).find('a').attr('aria-selected', selected); 17481 }, 17482 17483 /** 17484 * @param {number} index - the index of the option that is being disabled 17485 * @param {boolean} disabled - true if the option is being disabled, false if being enabled 17486 * @param {JQuery} $lis - the 'li' element that is being modified 17487 */ 17488 setDisabled: function (index, disabled, $lis) { 17489 if (!$lis) { 17490 $lis = this.findLis().eq(this.liObj[index]); 17491 } 17492 17493 if (disabled) { 17494 $lis.addClass('disabled').children('a').attr('href', '#').attr('tabindex', -1).attr('aria-disabled', true); 17495 } else { 17496 $lis.removeClass('disabled').children('a').removeAttr('href').attr('tabindex', 0).attr('aria-disabled', false); 17497 } 17498 }, 17499 17500 isDisabled: function () { 17501 return this.$element[0].disabled; 17502 }, 17503 17504 checkDisabled: function () { 17505 var that = this; 17506 17507 if (this.isDisabled()) { 17508 this.$newElement.addClass('disabled'); 17509 this.$button.addClass('disabled').attr('tabindex', -1); 17510 } else { 17511 if (this.$button.hasClass('disabled')) { 17512 this.$newElement.removeClass('disabled'); 17513 this.$button.removeClass('disabled'); 17514 } 17515 17516 if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) { 17517 this.$button.removeAttr('tabindex'); 17518 } 17519 } 17520 17521 this.$button.click(function () { 17522 return !that.isDisabled(); 17523 }); 17524 }, 17525 17526 togglePlaceholder: function () { 17527 var value = this.$element.val(); 17528 this.$button.toggleClass('bs-placeholder', value === null || value === ''); 17529 }, 17530 17531 tabIndex: function () { 17532 if (this.$element.data('tabindex') !== this.$element.attr('tabindex') && 17533 (this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) { 17534 this.$element.data('tabindex', this.$element.attr('tabindex')); 17535 this.$button.attr('tabindex', this.$element.data('tabindex')); 17536 } 17537 17538 this.$element.attr('tabindex', -98); 17539 }, 17540 17541 clickListener: function () { 17542 var that = this, 17543 $document = $(document); 17544 17545 this.$newElement.on('touchstart.dropdown', '.dropdown-menu', function (e) { 17546 e.stopPropagation(); 17547 }); 17548 17549 $document.data('spaceSelect', false); 17550 17551 this.$button.on('keyup', function (e) { 17552 if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) { 17553 e.preventDefault(); 17554 $document.data('spaceSelect', false); 17555 } 17556 }); 17557 17558 this.$button.on('click', function () { 17559 that.setSize(); 17560 }); 17561 17562 this.$element.on('shown.bs.select', function () { 17563 if (!that.options.liveSearch && !that.multiple) { 17564 that.$menuInner.find('.selected a').focus(); 17565 } else if (!that.multiple) { 17566 var selectedIndex = that.liObj[that.$element[0].selectedIndex]; 17567 17568 if (typeof selectedIndex !== 'number' || that.options.size === false) return; 17569 17570 // scroll to selected option 17571 var offset = that.$lis.eq(selectedIndex)[0].offsetTop - that.$menuInner[0].offsetTop; 17572 offset = offset - that.$menuInner[0].offsetHeight/2 + that.sizeInfo.liHeight/2; 17573 that.$menuInner[0].scrollTop = offset; 17574 } 17575 }); 17576 17577 this.$menuInner.on('click', 'li a', function (e) { 17578 var $this = $(this), 17579 clickedIndex = $this.parent().data('originalIndex'), 17580 prevValue = that.$element.val(), 17581 prevIndex = that.$element.prop('selectedIndex'), 17582 triggerChange = true; 17583 17584 // Don't close on multi choice menu 17585 if (that.multiple && that.options.maxOptions !== 1) { 17586 e.stopPropagation(); 17587 } 17588 17589 e.preventDefault(); 17590 17591 //Don't run if we have been disabled 17592 if (!that.isDisabled() && !$this.parent().hasClass('disabled')) { 17593 var $options = that.$element.find('option'), 17594 $option = $options.eq(clickedIndex), 17595 state = $option.prop('selected'), 17596 $optgroup = $option.parent('optgroup'), 17597 maxOptions = that.options.maxOptions, 17598 maxOptionsGrp = $optgroup.data('maxOptions') || false; 17599 17600 if (!that.multiple) { // Deselect all others if not multi select box 17601 $options.prop('selected', false); 17602 $option.prop('selected', true); 17603 that.$menuInner.find('.selected').removeClass('selected').find('a').attr('aria-selected', false); 17604 that.setSelected(clickedIndex, true); 17605 } else { // Toggle the one we have chosen if we are multi select. 17606 $option.prop('selected', !state); 17607 that.setSelected(clickedIndex, !state); 17608 $this.blur(); 17609 17610 if (maxOptions !== false || maxOptionsGrp !== false) { 17611 var maxReached = maxOptions < $options.filter(':selected').length, 17612 maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length; 17613 17614 if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) { 17615 if (maxOptions && maxOptions == 1) { 17616 $options.prop('selected', false); 17617 $option.prop('selected', true); 17618 that.$menuInner.find('.selected').removeClass('selected'); 17619 that.setSelected(clickedIndex, true); 17620 } else if (maxOptionsGrp && maxOptionsGrp == 1) { 17621 $optgroup.find('option:selected').prop('selected', false); 17622 $option.prop('selected', true); 17623 var optgroupID = $this.parent().data('optgroup'); 17624 that.$menuInner.find('[data-optgroup="' + optgroupID + '"]').removeClass('selected'); 17625 that.setSelected(clickedIndex, true); 17626 } else { 17627 var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText, 17628 maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText, 17629 maxTxt = maxOptionsArr[0].replace('{n}', maxOptions), 17630 maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp), 17631 $notify = $('<div class="notify"></div>'); 17632 // If {var} is set in array, replace it 17633 /** @deprecated */ 17634 if (maxOptionsArr[2]) { 17635 maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]); 17636 maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]); 17637 } 17638 17639 $option.prop('selected', false); 17640 17641 that.$menu.append($notify); 17642 17643 if (maxOptions && maxReached) { 17644 $notify.append($('<div>' + maxTxt + '</div>')); 17645 triggerChange = false; 17646 that.$element.trigger('maxReached.bs.select'); 17647 } 17648 17649 if (maxOptionsGrp && maxReachedGrp) { 17650 $notify.append($('<div>' + maxTxtGrp + '</div>')); 17651 triggerChange = false; 17652 that.$element.trigger('maxReachedGrp.bs.select'); 17653 } 17654 17655 setTimeout(function () { 17656 that.setSelected(clickedIndex, false); 17657 }, 10); 17658 17659 $notify.delay(750).fadeOut(300, function () { 17660 $(this).remove(); 17661 }); 17662 } 17663 } 17664 } 17665 } 17666 17667 if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) { 17668 that.$button.focus(); 17669 } else if (that.options.liveSearch) { 17670 that.$searchbox.focus(); 17671 } 17672 17673 // Trigger select 'change' 17674 if (triggerChange) { 17675 if ((prevValue != that.$element.val() && that.multiple) || (prevIndex != that.$element.prop('selectedIndex') && !that.multiple)) { 17676 // $option.prop('selected') is current option state (selected/unselected). state is previous option state. 17677 changed_arguments = [clickedIndex, $option.prop('selected'), state]; 17678 that.$element 17679 .triggerNative('change'); 17680 } 17681 } 17682 } 17683 }); 17684 17685 this.$menu.on('click', 'li.disabled a, .popover-title, .popover-title :not(.close)', function (e) { 17686 if (e.currentTarget == this) { 17687 e.preventDefault(); 17688 e.stopPropagation(); 17689 if (that.options.liveSearch && !$(e.target).hasClass('close')) { 17690 that.$searchbox.focus(); 17691 } else { 17692 that.$button.focus(); 17693 } 17694 } 17695 }); 17696 17697 this.$menuInner.on('click', '.divider, .dropdown-header', function (e) { 17698 e.preventDefault(); 17699 e.stopPropagation(); 17700 if (that.options.liveSearch) { 17701 that.$searchbox.focus(); 17702 } else { 17703 that.$button.focus(); 17704 } 17705 }); 17706 17707 this.$menu.on('click', '.popover-title .close', function () { 17708 that.$button.click(); 17709 }); 17710 17711 this.$searchbox.on('click', function (e) { 17712 e.stopPropagation(); 17713 }); 17714 17715 this.$menu.on('click', '.actions-btn', function (e) { 17716 if (that.options.liveSearch) { 17717 that.$searchbox.focus(); 17718 } else { 17719 that.$button.focus(); 17720 } 17721 17722 e.preventDefault(); 17723 e.stopPropagation(); 17724 17725 if ($(this).hasClass('bs-select-all')) { 17726 that.selectAll(); 17727 } else { 17728 that.deselectAll(); 17729 } 17730 }); 17731 17732 this.$element.change(function () { 17733 that.render(false); 17734 that.$element.trigger('changed.bs.select', changed_arguments); 17735 changed_arguments = null; 17736 }); 17737 }, 17738 17739 liveSearchListener: function () { 17740 var that = this, 17741 $no_results = $('<li class="no-results"></li>'); 17742 17743 this.$button.on('click.dropdown.data-api touchstart.dropdown.data-api', function () { 17744 that.$menuInner.find('.active').removeClass('active'); 17745 if (!!that.$searchbox.val()) { 17746 that.$searchbox.val(''); 17747 that.$lis.not('.is-hidden').removeClass('hidden'); 17748 if (!!$no_results.parent().length) $no_results.remove(); 17749 } 17750 if (!that.multiple) that.$menuInner.find('.selected').addClass('active'); 17751 setTimeout(function () { 17752 that.$searchbox.focus(); 17753 }, 10); 17754 }); 17755 17756 this.$searchbox.on('click.dropdown.data-api focus.dropdown.data-api touchend.dropdown.data-api', function (e) { 17757 e.stopPropagation(); 17758 }); 17759 17760 this.$searchbox.on('input propertychange', function () { 17761 if (that.$searchbox.val()) { 17762 var $searchBase = that.$lis.not('.is-hidden').removeClass('hidden').children('a'); 17763 if (that.options.liveSearchNormalize) { 17764 $searchBase = $searchBase.not(':a' + that._searchStyle() + '("' + normalizeToBase(that.$searchbox.val()) + '")'); 17765 } else { 17766 $searchBase = $searchBase.not(':' + that._searchStyle() + '("' + that.$searchbox.val() + '")'); 17767 } 17768 $searchBase.parent().addClass('hidden'); 17769 17770 that.$lis.filter('.dropdown-header').each(function () { 17771 var $this = $(this), 17772 optgroup = $this.data('optgroup'); 17773 17774 if (that.$lis.filter('[data-optgroup=' + optgroup + ']').not($this).not('.hidden').length === 0) { 17775 $this.addClass('hidden'); 17776 that.$lis.filter('[data-optgroup=' + optgroup + 'div]').addClass('hidden'); 17777 } 17778 }); 17779 17780 var $lisVisible = that.$lis.not('.hidden'); 17781 17782 // hide divider if first or last visible, or if followed by another divider 17783 $lisVisible.each(function (index) { 17784 var $this = $(this); 17785 17786 if ($this.hasClass('divider') && ( 17787 $this.index() === $lisVisible.first().index() || 17788 $this.index() === $lisVisible.last().index() || 17789 $lisVisible.eq(index + 1).hasClass('divider'))) { 17790 $this.addClass('hidden'); 17791 } 17792 }); 17793 17794 if (!that.$lis.not('.hidden, .no-results').length) { 17795 if (!!$no_results.parent().length) { 17796 $no_results.remove(); 17797 } 17798 $no_results.html(that.options.noneResultsText.replace('{0}', '"' + htmlEscape(that.$searchbox.val()) + '"')).show(); 17799 that.$menuInner.append($no_results); 17800 } else if (!!$no_results.parent().length) { 17801 $no_results.remove(); 17802 } 17803 } else { 17804 that.$lis.not('.is-hidden').removeClass('hidden'); 17805 if (!!$no_results.parent().length) { 17806 $no_results.remove(); 17807 } 17808 } 17809 17810 that.$lis.filter('.active').removeClass('active'); 17811 if (that.$searchbox.val()) that.$lis.not('.hidden, .divider, .dropdown-header').eq(0).addClass('active').children('a').focus(); 17812 $(this).focus(); 17813 }); 17814 }, 17815 17816 _searchStyle: function () { 17817 var styles = { 17818 begins: 'ibegins', 17819 startsWith: 'ibegins' 17820 }; 17821 17822 return styles[this.options.liveSearchStyle] || 'icontains'; 17823 }, 17824 17825 val: function (value) { 17826 if (typeof value !== 'undefined') { 17827 this.$element.val(value); 17828 this.render(); 17829 17830 return this.$element; 17831 } else { 17832 return this.$element.val(); 17833 } 17834 }, 17835 17836 changeAll: function (status) { 17837 if (!this.multiple) return; 17838 if (typeof status === 'undefined') status = true; 17839 17840 this.findLis(); 17841 17842 var $options = this.$element.find('option'), 17843 $lisVisible = this.$lis.not('.divider, .dropdown-header, .disabled, .hidden'), 17844 lisVisLen = $lisVisible.length, 17845 selectedOptions = []; 17846 17847 if (status) { 17848 if ($lisVisible.filter('.selected').length === $lisVisible.length) return; 17849 } else { 17850 if ($lisVisible.filter('.selected').length === 0) return; 17851 } 17852 17853 $lisVisible.toggleClass('selected', status); 17854 17855 for (var i = 0; i < lisVisLen; i++) { 17856 var origIndex = $lisVisible[i].getAttribute('data-original-index'); 17857 selectedOptions[selectedOptions.length] = $options.eq(origIndex)[0]; 17858 } 17859 17860 $(selectedOptions).prop('selected', status); 17861 17862 this.render(false); 17863 17864 this.togglePlaceholder(); 17865 17866 this.$element 17867 .triggerNative('change'); 17868 }, 17869 17870 selectAll: function () { 17871 return this.changeAll(true); 17872 }, 17873 17874 deselectAll: function () { 17875 return this.changeAll(false); 17876 }, 17877 17878 toggle: function (e) { 17879 e = e || window.event; 17880 17881 if (e) e.stopPropagation(); 17882 17883 this.$button.trigger('click'); 17884 }, 17885 17886 keydown: function (e) { 17887 var $this = $(this), 17888 $parent = $this.is('input') ? $this.parent().parent() : $this.parent(), 17889 $items, 17890 that = $parent.data('this'), 17891 index, 17892 next, 17893 first, 17894 last, 17895 prev, 17896 nextPrev, 17897 prevIndex, 17898 isActive, 17899 selector = ':not(.disabled, .hidden, .dropdown-header, .divider)', 17900 keyCodeMap = { 17901 32: ' ', 17902 48: '0', 17903 49: '1', 17904 50: '2', 17905 51: '3', 17906 52: '4', 17907 53: '5', 17908 54: '6', 17909 55: '7', 17910 56: '8', 17911 57: '9', 17912 59: ';', 17913 65: 'a', 17914 66: 'b', 17915 67: 'c', 17916 68: 'd', 17917 69: 'e', 17918 70: 'f', 17919 71: 'g', 17920 72: 'h', 17921 73: 'i', 17922 74: 'j', 17923 75: 'k', 17924 76: 'l', 17925 77: 'm', 17926 78: 'n', 17927 79: 'o', 17928 80: 'p', 17929 81: 'q', 17930 82: 'r', 17931 83: 's', 17932 84: 't', 17933 85: 'u', 17934 86: 'v', 17935 87: 'w', 17936 88: 'x', 17937 89: 'y', 17938 90: 'z', 17939 96: '0', 17940 97: '1', 17941 98: '2', 17942 99: '3', 17943 100: '4', 17944 101: '5', 17945 102: '6', 17946 103: '7', 17947 104: '8', 17948 105: '9' 17949 }; 17950 17951 if (that.options.liveSearch) $parent = $this.parent().parent(); 17952 17953 if (that.options.container) $parent = that.$menu; 17954 17955 $items = $('[role="listbox"] li', $parent); 17956 17957 isActive = that.$newElement.hasClass('open'); 17958 17959 if (!isActive && (e.keyCode >= 48 && e.keyCode <= 57 || e.keyCode >= 96 && e.keyCode <= 105 || e.keyCode >= 65 && e.keyCode <= 90)) { 17960 if (!that.options.container) { 17961 that.setSize(); 17962 that.$menu.parent().addClass('open'); 17963 isActive = true; 17964 } else { 17965 that.$button.trigger('click'); 17966 } 17967 that.$searchbox.focus(); 17968 return; 17969 } 17970 17971 if (that.options.liveSearch) { 17972 if (/(^9$|27)/.test(e.keyCode.toString(10)) && isActive) { 17973 e.preventDefault(); 17974 e.stopPropagation(); 17975 that.$button.click().focus(); 17976 } 17977 // $items contains li elements when liveSearch is enabled 17978 $items = $('[role="listbox"] li' + selector, $parent); 17979 if (!$this.val() && !/(38|40)/.test(e.keyCode.toString(10))) { 17980 if ($items.filter('.active').length === 0) { 17981 $items = that.$menuInner.find('li'); 17982 if (that.options.liveSearchNormalize) { 17983 $items = $items.filter(':a' + that._searchStyle() + '(' + normalizeToBase(keyCodeMap[e.keyCode]) + ')'); 17984 } else { 17985 $items = $items.filter(':' + that._searchStyle() + '(' + keyCodeMap[e.keyCode] + ')'); 17986 } 17987 } 17988 } 17989 } 17990 17991 if (!$items.length) return; 17992 17993 if (/(38|40)/.test(e.keyCode.toString(10))) { 17994 index = $items.index($items.find('a').filter(':focus').parent()); 17995 first = $items.filter(selector).first().index(); 17996 last = $items.filter(selector).last().index(); 17997 next = $items.eq(index).nextAll(selector).eq(0).index(); 17998 prev = $items.eq(index).prevAll(selector).eq(0).index(); 17999 nextPrev = $items.eq(next).prevAll(selector).eq(0).index(); 18000 18001 if (that.options.liveSearch) { 18002 $items.each(function (i) { 18003 if (!$(this).hasClass('disabled')) { 18004 $(this).data('index', i); 18005 } 18006 }); 18007 index = $items.index($items.filter('.active')); 18008 first = $items.first().data('index'); 18009 last = $items.last().data('index'); 18010 next = $items.eq(index).nextAll().eq(0).data('index'); 18011 prev = $items.eq(index).prevAll().eq(0).data('index'); 18012 nextPrev = $items.eq(next).prevAll().eq(0).data('index'); 18013 } 18014 18015 prevIndex = $this.data('prevIndex'); 18016 18017 if (e.keyCode == 38) { 18018 if (that.options.liveSearch) index--; 18019 if (index != nextPrev && index > prev) index = prev; 18020 if (index < first) index = first; 18021 if (index == prevIndex) index = last; 18022 } else if (e.keyCode == 40) { 18023 if (that.options.liveSearch) index++; 18024 if (index == -1) index = 0; 18025 if (index != nextPrev && index < next) index = next; 18026 if (index > last) index = last; 18027 if (index == prevIndex) index = first; 18028 } 18029 18030 $this.data('prevIndex', index); 18031 18032 if (!that.options.liveSearch) { 18033 $items.eq(index).children('a').focus(); 18034 } else { 18035 e.preventDefault(); 18036 if (!$this.hasClass('dropdown-toggle')) { 18037 $items.removeClass('active').eq(index).addClass('active').children('a').focus(); 18038 $this.focus(); 18039 } 18040 } 18041 18042 } else if (!$this.is('input')) { 18043 var keyIndex = [], 18044 count, 18045 prevKey; 18046 18047 $items.each(function () { 18048 if (!$(this).hasClass('disabled')) { 18049 if ($.trim($(this).children('a').text().toLowerCase()).substring(0, 1) == keyCodeMap[e.keyCode]) { 18050 keyIndex.push($(this).index()); 18051 } 18052 } 18053 }); 18054 18055 count = $(document).data('keycount'); 18056 count++; 18057 $(document).data('keycount', count); 18058 18059 prevKey = $.trim($(':focus').text().toLowerCase()).substring(0, 1); 18060 18061 if (prevKey != keyCodeMap[e.keyCode]) { 18062 count = 1; 18063 $(document).data('keycount', count); 18064 } else if (count >= keyIndex.length) { 18065 $(document).data('keycount', 0); 18066 if (count > keyIndex.length) count = 1; 18067 } 18068 18069 $items.eq(keyIndex[count - 1]).children('a').focus(); 18070 } 18071 18072 // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu. 18073 if ((/(13|32)/.test(e.keyCode.toString(10)) || (/(^9$)/.test(e.keyCode.toString(10)) && that.options.selectOnTab)) && isActive) { 18074 if (!/(32)/.test(e.keyCode.toString(10))) e.preventDefault(); 18075 if (!that.options.liveSearch) { 18076 var elem = $(':focus'); 18077 elem.click(); 18078 // Bring back focus for multiselects 18079 elem.focus(); 18080 // Prevent screen from scrolling if the user hit the spacebar 18081 e.preventDefault(); 18082 // Fixes spacebar selection of dropdown items in FF & IE 18083 $(document).data('spaceSelect', true); 18084 } else if (!/(32)/.test(e.keyCode.toString(10))) { 18085 that.$menuInner.find('.active a').click(); 18086 $this.focus(); 18087 } 18088 $(document).data('keycount', 0); 18089 } 18090 18091 if ((/(^9$|27)/.test(e.keyCode.toString(10)) && isActive && (that.multiple || that.options.liveSearch)) || (/(27)/.test(e.keyCode.toString(10)) && !isActive)) { 18092 that.$menu.parent().removeClass('open'); 18093 if (that.options.container) that.$newElement.removeClass('open'); 18094 that.$button.focus(); 18095 } 18096 }, 18097 18098 mobile: function () { 18099 this.$element.addClass('mobile-device'); 18100 }, 18101 18102 refresh: function () { 18103 this.$lis = null; 18104 this.liObj = {}; 18105 this.reloadLi(); 18106 this.render(); 18107 this.checkDisabled(); 18108 this.liHeight(true); 18109 this.setStyle(); 18110 this.setWidth(); 18111 if (this.$lis) this.$searchbox.trigger('propertychange'); 18112 18113 this.$element.trigger('refreshed.bs.select'); 18114 }, 18115 18116 hide: function () { 18117 this.$newElement.hide(); 18118 }, 18119 18120 show: function () { 18121 this.$newElement.show(); 18122 }, 18123 18124 remove: function () { 18125 this.$newElement.remove(); 18126 this.$element.remove(); 18127 }, 18128 18129 destroy: function () { 18130 this.$newElement.before(this.$element).remove(); 18131 18132 if (this.$bsContainer) { 18133 this.$bsContainer.remove(); 18134 } else { 18135 this.$menu.remove(); 18136 } 18137 18138 this.$element 18139 .off('.bs.select') 18140 .removeData('selectpicker') 18141 .removeClass('bs-select-hidden selectpicker'); 18142 } 18143 }; 18144 18145 // SELECTPICKER PLUGIN DEFINITION 18146 // ============================== 18147 function Plugin(option, event) { 18148 // get the args of the outer function.. 18149 var args = arguments; 18150 // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them 18151 // to get lost/corrupted in android 2.3 and IE9 #715 #775 18152 var _option = option, 18153 _event = event; 18154 [].shift.apply(args); 18155 18156 var value; 18157 var chain = this.each(function () { 18158 var $this = $(this); 18159 if ($this.is('select')) { 18160 var data = $this.data('selectpicker'), 18161 options = typeof _option == 'object' && _option; 18162 18163 if (!data) { 18164 var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, $this.data(), options); 18165 config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), $this.data().template, options.template); 18166 $this.data('selectpicker', (data = new Selectpicker(this, config, _event))); 18167 } else if (options) { 18168 for (var i in options) { 18169 if (options.hasOwnProperty(i)) { 18170 data.options[i] = options[i]; 18171 } 18172 } 18173 } 18174 18175 if (typeof _option == 'string') { 18176 if (data[_option] instanceof Function) { 18177 value = data[_option].apply(data, args); 18178 } else { 18179 value = data.options[_option]; 18180 } 18181 } 18182 } 18183 }); 18184 18185 if (typeof value !== 'undefined') { 18186 //noinspection JSUnusedAssignment 18187 return value; 18188 } else { 18189 return chain; 18190 } 18191 } 18192 18193 var old = $.fn.selectpicker; 18194 $.fn.selectpicker = Plugin; 18195 $.fn.selectpicker.Constructor = Selectpicker; 18196 18197 // SELECTPICKER NO CONFLICT 18198 // ======================== 18199 $.fn.selectpicker.noConflict = function () { 18200 $.fn.selectpicker = old; 18201 return this; 18202 }; 18203 18204 $(document) 18205 .data('keycount', 0) 18206 .on('keydown.bs.select', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', Selectpicker.prototype.keydown) 18207 .on('focusin.modal', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', function (e) { 18208 e.stopPropagation(); 18209 }); 18210 18211 // SELECTPICKER DATA-API 18212 // ===================== 18213 $(window).on('load.bs.select.data-api', function () { 18214 $('.selectpicker').each(function () { 18215 var $selectpicker = $(this); 18216 Plugin.call($selectpicker, $selectpicker.data()); 18217 }) 18218 }); 18219 })(jQuery); 18220 18221 18222 })); 18223 18224 18225 /***/ }, 18226 /* 60 */ 18227 /***/ function(module, exports, __webpack_require__) { 18228 18229 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 18230 * Bootstrap: affix.js v3.3.7 18231 * http://getbootstrap.com/javascript/#affix 18232 * ======================================================================== 18233 * Copyright 2011-2016 Twitter, Inc. 18234 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 18235 * ======================================================================== */ 18236 18237 18238 +function ($) { 18239 'use strict'; 18240 18241 // AFFIX CLASS DEFINITION 18242 // ====================== 18243 18244 var Affix = function (element, options) { 18245 this.options = $.extend({}, Affix.DEFAULTS, options) 18246 18247 this.$target = $(this.options.target) 18248 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) 18249 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) 18250 18251 this.$element = $(element) 18252 this.affixed = null 18253 this.unpin = null 18254 this.pinnedOffset = null 18255 18256 this.checkPosition() 18257 } 18258 18259 Affix.VERSION = '3.3.7' 18260 18261 Affix.RESET = 'affix affix-top affix-bottom' 18262 18263 Affix.DEFAULTS = { 18264 offset: 0, 18265 target: window 18266 } 18267 18268 Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) { 18269 var scrollTop = this.$target.scrollTop() 18270 var position = this.$element.offset() 18271 var targetHeight = this.$target.height() 18272 18273 if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false 18274 18275 if (this.affixed == 'bottom') { 18276 if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom' 18277 return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom' 18278 } 18279 18280 var initializing = this.affixed == null 18281 var colliderTop = initializing ? scrollTop : position.top 18282 var colliderHeight = initializing ? targetHeight : height 18283 18284 if (offsetTop != null && scrollTop <= offsetTop) return 'top' 18285 if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom' 18286 18287 return false 18288 } 18289 18290 Affix.prototype.getPinnedOffset = function () { 18291 if (this.pinnedOffset) return this.pinnedOffset 18292 this.$element.removeClass(Affix.RESET).addClass('affix') 18293 var scrollTop = this.$target.scrollTop() 18294 var position = this.$element.offset() 18295 return (this.pinnedOffset = position.top - scrollTop) 18296 } 18297 18298 Affix.prototype.checkPositionWithEventLoop = function () { 18299 setTimeout($.proxy(this.checkPosition, this), 1) 18300 } 18301 18302 Affix.prototype.checkPosition = function () { 18303 if (!this.$element.is(':visible')) return 18304 18305 var height = this.$element.height() 18306 var offset = this.options.offset 18307 var offsetTop = offset.top 18308 var offsetBottom = offset.bottom 18309 var scrollHeight = Math.max($(document).height(), $(document.body).height()) 18310 18311 if (typeof offset != 'object') offsetBottom = offsetTop = offset 18312 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element) 18313 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element) 18314 18315 var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom) 18316 18317 if (this.affixed != affix) { 18318 if (this.unpin != null) this.$element.css('top', '') 18319 18320 var affixType = 'affix' + (affix ? '-' + affix : '') 18321 var e = $.Event(affixType + '.bs.affix') 18322 18323 this.$element.trigger(e) 18324 18325 if (e.isDefaultPrevented()) return 18326 18327 this.affixed = affix 18328 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null 18329 18330 this.$element 18331 .removeClass(Affix.RESET) 18332 .addClass(affixType) 18333 .trigger(affixType.replace('affix', 'affixed') + '.bs.affix') 18334 } 18335 18336 if (affix == 'bottom') { 18337 this.$element.offset({ 18338 top: scrollHeight - height - offsetBottom 18339 }) 18340 } 18341 } 18342 18343 18344 // AFFIX PLUGIN DEFINITION 18345 // ======================= 18346 18347 function Plugin(option) { 18348 return this.each(function () { 18349 var $this = $(this) 18350 var data = $this.data('bs.affix') 18351 var options = typeof option == 'object' && option 18352 18353 if (!data) $this.data('bs.affix', (data = new Affix(this, options))) 18354 if (typeof option == 'string') data[option]() 18355 }) 18356 } 18357 18358 var old = $.fn.affix 18359 18360 $.fn.affix = Plugin 18361 $.fn.affix.Constructor = Affix 18362 18363 18364 // AFFIX NO CONFLICT 18365 // ================= 18366 18367 $.fn.affix.noConflict = function () { 18368 $.fn.affix = old 18369 return this 18370 } 18371 18372 18373 // AFFIX DATA-API 18374 // ============== 18375 18376 $(window).on('load', function () { 18377 $('[data-spy="affix"]').each(function () { 18378 var $spy = $(this) 18379 var data = $spy.data() 18380 18381 data.offset = data.offset || {} 18382 18383 if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom 18384 if (data.offsetTop != null) data.offset.top = data.offsetTop 18385 18386 Plugin.call($spy, data) 18387 }) 18388 }) 18389 18390 }(jQuery); 18391 18392 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 18393 18394 /***/ }, 18395 /* 61 */ 18396 /***/ function(module, exports, __webpack_require__) { 18397 18398 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 18399 * Bootstrap: alert.js v3.3.7 18400 * http://getbootstrap.com/javascript/#alerts 18401 * ======================================================================== 18402 * Copyright 2011-2016 Twitter, Inc. 18403 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 18404 * ======================================================================== */ 18405 18406 18407 +function ($) { 18408 'use strict'; 18409 18410 // ALERT CLASS DEFINITION 18411 // ====================== 18412 18413 var dismiss = '[data-dismiss="alert"]' 18414 var Alert = function (el) { 18415 $(el).on('click', dismiss, this.close) 18416 } 18417 18418 Alert.VERSION = '3.3.7' 18419 18420 Alert.TRANSITION_DURATION = 150 18421 18422 Alert.prototype.close = function (e) { 18423 var $this = $(this) 18424 var selector = $this.attr('data-target') 18425 18426 if (!selector) { 18427 selector = $this.attr('href') 18428 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 18429 } 18430 18431 var $parent = $(selector === '#' ? [] : selector) 18432 18433 if (e) e.preventDefault() 18434 18435 if (!$parent.length) { 18436 $parent = $this.closest('.alert') 18437 } 18438 18439 $parent.trigger(e = $.Event('close.bs.alert')) 18440 18441 if (e.isDefaultPrevented()) return 18442 18443 $parent.removeClass('in') 18444 18445 function removeElement() { 18446 // detach from parent, fire event then clean up data 18447 $parent.detach().trigger('closed.bs.alert').remove() 18448 } 18449 18450 $.support.transition && $parent.hasClass('fade') ? 18451 $parent 18452 .one('bsTransitionEnd', removeElement) 18453 .emulateTransitionEnd(Alert.TRANSITION_DURATION) : 18454 removeElement() 18455 } 18456 18457 18458 // ALERT PLUGIN DEFINITION 18459 // ======================= 18460 18461 function Plugin(option) { 18462 return this.each(function () { 18463 var $this = $(this) 18464 var data = $this.data('bs.alert') 18465 18466 if (!data) $this.data('bs.alert', (data = new Alert(this))) 18467 if (typeof option == 'string') data[option].call($this) 18468 }) 18469 } 18470 18471 var old = $.fn.alert 18472 18473 $.fn.alert = Plugin 18474 $.fn.alert.Constructor = Alert 18475 18476 18477 // ALERT NO CONFLICT 18478 // ================= 18479 18480 $.fn.alert.noConflict = function () { 18481 $.fn.alert = old 18482 return this 18483 } 18484 18485 18486 // ALERT DATA-API 18487 // ============== 18488 18489 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) 18490 18491 }(jQuery); 18492 18493 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 18494 18495 /***/ }, 18496 /* 62 */ 18497 /***/ function(module, exports, __webpack_require__) { 18498 18499 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 18500 * Bootstrap: button.js v3.3.7 18501 * http://getbootstrap.com/javascript/#buttons 18502 * ======================================================================== 18503 * Copyright 2011-2016 Twitter, Inc. 18504 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 18505 * ======================================================================== */ 18506 18507 18508 +function ($) { 18509 'use strict'; 18510 18511 // BUTTON PUBLIC CLASS DEFINITION 18512 // ============================== 18513 18514 var Button = function (element, options) { 18515 this.$element = $(element) 18516 this.options = $.extend({}, Button.DEFAULTS, options) 18517 this.isLoading = false 18518 } 18519 18520 Button.VERSION = '3.3.7' 18521 18522 Button.DEFAULTS = { 18523 loadingText: 'loading...' 18524 } 18525 18526 Button.prototype.setState = function (state) { 18527 var d = 'disabled' 18528 var $el = this.$element 18529 var val = $el.is('input') ? 'val' : 'html' 18530 var data = $el.data() 18531 18532 state += 'Text' 18533 18534 if (data.resetText == null) $el.data('resetText', $el[val]()) 18535 18536 // push to event loop to allow forms to submit 18537 setTimeout($.proxy(function () { 18538 $el[val](data[state] == null ? this.options[state] : data[state]) 18539 18540 if (state == 'loadingText') { 18541 this.isLoading = true 18542 $el.addClass(d).attr(d, d).prop(d, true) 18543 } else if (this.isLoading) { 18544 this.isLoading = false 18545 $el.removeClass(d).removeAttr(d).prop(d, false) 18546 } 18547 }, this), 0) 18548 } 18549 18550 Button.prototype.toggle = function () { 18551 var changed = true 18552 var $parent = this.$element.closest('[data-toggle="buttons"]') 18553 18554 if ($parent.length) { 18555 var $input = this.$element.find('input') 18556 if ($input.prop('type') == 'radio') { 18557 if ($input.prop('checked')) changed = false 18558 $parent.find('.active').removeClass('active') 18559 this.$element.addClass('active') 18560 } else if ($input.prop('type') == 'checkbox') { 18561 if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false 18562 this.$element.toggleClass('active') 18563 } 18564 $input.prop('checked', this.$element.hasClass('active')) 18565 if (changed) $input.trigger('change') 18566 } else { 18567 this.$element.attr('aria-pressed', !this.$element.hasClass('active')) 18568 this.$element.toggleClass('active') 18569 } 18570 } 18571 18572 18573 // BUTTON PLUGIN DEFINITION 18574 // ======================== 18575 18576 function Plugin(option) { 18577 return this.each(function () { 18578 var $this = $(this) 18579 var data = $this.data('bs.button') 18580 var options = typeof option == 'object' && option 18581 18582 if (!data) $this.data('bs.button', (data = new Button(this, options))) 18583 18584 if (option == 'toggle') data.toggle() 18585 else if (option) data.setState(option) 18586 }) 18587 } 18588 18589 var old = $.fn.button 18590 18591 $.fn.button = Plugin 18592 $.fn.button.Constructor = Button 18593 18594 18595 // BUTTON NO CONFLICT 18596 // ================== 18597 18598 $.fn.button.noConflict = function () { 18599 $.fn.button = old 18600 return this 18601 } 18602 18603 18604 // BUTTON DATA-API 18605 // =============== 18606 18607 $(document) 18608 .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { 18609 var $btn = $(e.target).closest('.btn') 18610 Plugin.call($btn, 'toggle') 18611 if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) { 18612 // Prevent double click on radios, and the double selections (so cancellation) on checkboxes 18613 e.preventDefault() 18614 // The target component still receive the focus 18615 if ($btn.is('input,button')) $btn.trigger('focus') 18616 else $btn.find('input:visible,button:visible').first().trigger('focus') 18617 } 18618 }) 18619 .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { 18620 $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type)) 18621 }) 18622 18623 }(jQuery); 18624 18625 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 18626 18627 /***/ }, 18628 /* 63 */ 18629 /***/ function(module, exports, __webpack_require__) { 18630 18631 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 18632 * Bootstrap: carousel.js v3.3.7 18633 * http://getbootstrap.com/javascript/#carousel 18634 * ======================================================================== 18635 * Copyright 2011-2016 Twitter, Inc. 18636 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 18637 * ======================================================================== */ 18638 18639 18640 +function ($) { 18641 'use strict'; 18642 18643 // CAROUSEL CLASS DEFINITION 18644 // ========================= 18645 18646 var Carousel = function (element, options) { 18647 this.$element = $(element) 18648 this.$indicators = this.$element.find('.carousel-indicators') 18649 this.options = options 18650 this.paused = null 18651 this.sliding = null 18652 this.interval = null 18653 this.$active = null 18654 this.$items = null 18655 18656 this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this)) 18657 18658 this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element 18659 .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) 18660 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) 18661 } 18662 18663 Carousel.VERSION = '3.3.7' 18664 18665 Carousel.TRANSITION_DURATION = 600 18666 18667 Carousel.DEFAULTS = { 18668 interval: 5000, 18669 pause: 'hover', 18670 wrap: true, 18671 keyboard: true 18672 } 18673 18674 Carousel.prototype.keydown = function (e) { 18675 if (/input|textarea/i.test(e.target.tagName)) return 18676 switch (e.which) { 18677 case 37: this.prev(); break 18678 case 39: this.next(); break 18679 default: return 18680 } 18681 18682 e.preventDefault() 18683 } 18684 18685 Carousel.prototype.cycle = function (e) { 18686 e || (this.paused = false) 18687 18688 this.interval && clearInterval(this.interval) 18689 18690 this.options.interval 18691 && !this.paused 18692 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) 18693 18694 return this 18695 } 18696 18697 Carousel.prototype.getItemIndex = function (item) { 18698 this.$items = item.parent().children('.item') 18699 return this.$items.index(item || this.$active) 18700 } 18701 18702 Carousel.prototype.getItemForDirection = function (direction, active) { 18703 var activeIndex = this.getItemIndex(active) 18704 var willWrap = (direction == 'prev' && activeIndex === 0) 18705 || (direction == 'next' && activeIndex == (this.$items.length - 1)) 18706 if (willWrap && !this.options.wrap) return active 18707 var delta = direction == 'prev' ? -1 : 1 18708 var itemIndex = (activeIndex + delta) % this.$items.length 18709 return this.$items.eq(itemIndex) 18710 } 18711 18712 Carousel.prototype.to = function (pos) { 18713 var that = this 18714 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) 18715 18716 if (pos > (this.$items.length - 1) || pos < 0) return 18717 18718 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" 18719 if (activeIndex == pos) return this.pause().cycle() 18720 18721 return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos)) 18722 } 18723 18724 Carousel.prototype.pause = function (e) { 18725 e || (this.paused = true) 18726 18727 if (this.$element.find('.next, .prev').length && $.support.transition) { 18728 this.$element.trigger($.support.transition.end) 18729 this.cycle(true) 18730 } 18731 18732 this.interval = clearInterval(this.interval) 18733 18734 return this 18735 } 18736 18737 Carousel.prototype.next = function () { 18738 if (this.sliding) return 18739 return this.slide('next') 18740 } 18741 18742 Carousel.prototype.prev = function () { 18743 if (this.sliding) return 18744 return this.slide('prev') 18745 } 18746 18747 Carousel.prototype.slide = function (type, next) { 18748 var $active = this.$element.find('.item.active') 18749 var $next = next || this.getItemForDirection(type, $active) 18750 var isCycling = this.interval 18751 var direction = type == 'next' ? 'left' : 'right' 18752 var that = this 18753 18754 if ($next.hasClass('active')) return (this.sliding = false) 18755 18756 var relatedTarget = $next[0] 18757 var slideEvent = $.Event('slide.bs.carousel', { 18758 relatedTarget: relatedTarget, 18759 direction: direction 18760 }) 18761 this.$element.trigger(slideEvent) 18762 if (slideEvent.isDefaultPrevented()) return 18763 18764 this.sliding = true 18765 18766 isCycling && this.pause() 18767 18768 if (this.$indicators.length) { 18769 this.$indicators.find('.active').removeClass('active') 18770 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) 18771 $nextIndicator && $nextIndicator.addClass('active') 18772 } 18773 18774 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" 18775 if ($.support.transition && this.$element.hasClass('slide')) { 18776 $next.addClass(type) 18777 $next[0].offsetWidth // force reflow 18778 $active.addClass(direction) 18779 $next.addClass(direction) 18780 $active 18781 .one('bsTransitionEnd', function () { 18782 $next.removeClass([type, direction].join(' ')).addClass('active') 18783 $active.removeClass(['active', direction].join(' ')) 18784 that.sliding = false 18785 setTimeout(function () { 18786 that.$element.trigger(slidEvent) 18787 }, 0) 18788 }) 18789 .emulateTransitionEnd(Carousel.TRANSITION_DURATION) 18790 } else { 18791 $active.removeClass('active') 18792 $next.addClass('active') 18793 this.sliding = false 18794 this.$element.trigger(slidEvent) 18795 } 18796 18797 isCycling && this.cycle() 18798 18799 return this 18800 } 18801 18802 18803 // CAROUSEL PLUGIN DEFINITION 18804 // ========================== 18805 18806 function Plugin(option) { 18807 return this.each(function () { 18808 var $this = $(this) 18809 var data = $this.data('bs.carousel') 18810 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) 18811 var action = typeof option == 'string' ? option : options.slide 18812 18813 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) 18814 if (typeof option == 'number') data.to(option) 18815 else if (action) data[action]() 18816 else if (options.interval) data.pause().cycle() 18817 }) 18818 } 18819 18820 var old = $.fn.carousel 18821 18822 $.fn.carousel = Plugin 18823 $.fn.carousel.Constructor = Carousel 18824 18825 18826 // CAROUSEL NO CONFLICT 18827 // ==================== 18828 18829 $.fn.carousel.noConflict = function () { 18830 $.fn.carousel = old 18831 return this 18832 } 18833 18834 18835 // CAROUSEL DATA-API 18836 // ================= 18837 18838 var clickHandler = function (e) { 18839 var href 18840 var $this = $(this) 18841 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 18842 if (!$target.hasClass('carousel')) return 18843 var options = $.extend({}, $target.data(), $this.data()) 18844 var slideIndex = $this.attr('data-slide-to') 18845 if (slideIndex) options.interval = false 18846 18847 Plugin.call($target, options) 18848 18849 if (slideIndex) { 18850 $target.data('bs.carousel').to(slideIndex) 18851 } 18852 18853 e.preventDefault() 18854 } 18855 18856 $(document) 18857 .on('click.bs.carousel.data-api', '[data-slide]', clickHandler) 18858 .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler) 18859 18860 $(window).on('load', function () { 18861 $('[data-ride="carousel"]').each(function () { 18862 var $carousel = $(this) 18863 Plugin.call($carousel, $carousel.data()) 18864 }) 18865 }) 18866 18867 }(jQuery); 18868 18869 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 18870 18871 /***/ }, 18872 /* 64 */ 18873 /***/ function(module, exports, __webpack_require__) { 18874 18875 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 18876 * Bootstrap: collapse.js v3.3.7 18877 * http://getbootstrap.com/javascript/#collapse 18878 * ======================================================================== 18879 * Copyright 2011-2016 Twitter, Inc. 18880 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 18881 * ======================================================================== */ 18882 18883 /* jshint latedef: false */ 18884 18885 +function ($) { 18886 'use strict'; 18887 18888 // COLLAPSE PUBLIC CLASS DEFINITION 18889 // ================================ 18890 18891 var Collapse = function (element, options) { 18892 this.$element = $(element) 18893 this.options = $.extend({}, Collapse.DEFAULTS, options) 18894 this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' + 18895 '[data-toggle="collapse"][data-target="#' + element.id + '"]') 18896 this.transitioning = null 18897 18898 if (this.options.parent) { 18899 this.$parent = this.getParent() 18900 } else { 18901 this.addAriaAndCollapsedClass(this.$element, this.$trigger) 18902 } 18903 18904 if (this.options.toggle) this.toggle() 18905 } 18906 18907 Collapse.VERSION = '3.3.7' 18908 18909 Collapse.TRANSITION_DURATION = 350 18910 18911 Collapse.DEFAULTS = { 18912 toggle: true 18913 } 18914 18915 Collapse.prototype.dimension = function () { 18916 var hasWidth = this.$element.hasClass('width') 18917 return hasWidth ? 'width' : 'height' 18918 } 18919 18920 Collapse.prototype.show = function () { 18921 if (this.transitioning || this.$element.hasClass('in')) return 18922 18923 var activesData 18924 var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') 18925 18926 if (actives && actives.length) { 18927 activesData = actives.data('bs.collapse') 18928 if (activesData && activesData.transitioning) return 18929 } 18930 18931 var startEvent = $.Event('show.bs.collapse') 18932 this.$element.trigger(startEvent) 18933 if (startEvent.isDefaultPrevented()) return 18934 18935 if (actives && actives.length) { 18936 Plugin.call(actives, 'hide') 18937 activesData || actives.data('bs.collapse', null) 18938 } 18939 18940 var dimension = this.dimension() 18941 18942 this.$element 18943 .removeClass('collapse') 18944 .addClass('collapsing')[dimension](0) 18945 .attr('aria-expanded', true) 18946 18947 this.$trigger 18948 .removeClass('collapsed') 18949 .attr('aria-expanded', true) 18950 18951 this.transitioning = 1 18952 18953 var complete = function () { 18954 this.$element 18955 .removeClass('collapsing') 18956 .addClass('collapse in')[dimension]('') 18957 this.transitioning = 0 18958 this.$element 18959 .trigger('shown.bs.collapse') 18960 } 18961 18962 if (!$.support.transition) return complete.call(this) 18963 18964 var scrollSize = $.camelCase(['scroll', dimension].join('-')) 18965 18966 this.$element 18967 .one('bsTransitionEnd', $.proxy(complete, this)) 18968 .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) 18969 } 18970 18971 Collapse.prototype.hide = function () { 18972 if (this.transitioning || !this.$element.hasClass('in')) return 18973 18974 var startEvent = $.Event('hide.bs.collapse') 18975 this.$element.trigger(startEvent) 18976 if (startEvent.isDefaultPrevented()) return 18977 18978 var dimension = this.dimension() 18979 18980 this.$element[dimension](this.$element[dimension]())[0].offsetHeight 18981 18982 this.$element 18983 .addClass('collapsing') 18984 .removeClass('collapse in') 18985 .attr('aria-expanded', false) 18986 18987 this.$trigger 18988 .addClass('collapsed') 18989 .attr('aria-expanded', false) 18990 18991 this.transitioning = 1 18992 18993 var complete = function () { 18994 this.transitioning = 0 18995 this.$element 18996 .removeClass('collapsing') 18997 .addClass('collapse') 18998 .trigger('hidden.bs.collapse') 18999 } 19000 19001 if (!$.support.transition) return complete.call(this) 19002 19003 this.$element 19004 [dimension](0) 19005 .one('bsTransitionEnd', $.proxy(complete, this)) 19006 .emulateTransitionEnd(Collapse.TRANSITION_DURATION) 19007 } 19008 19009 Collapse.prototype.toggle = function () { 19010 this[this.$element.hasClass('in') ? 'hide' : 'show']() 19011 } 19012 19013 Collapse.prototype.getParent = function () { 19014 return $(this.options.parent) 19015 .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]') 19016 .each($.proxy(function (i, element) { 19017 var $element = $(element) 19018 this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element) 19019 }, this)) 19020 .end() 19021 } 19022 19023 Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) { 19024 var isOpen = $element.hasClass('in') 19025 19026 $element.attr('aria-expanded', isOpen) 19027 $trigger 19028 .toggleClass('collapsed', !isOpen) 19029 .attr('aria-expanded', isOpen) 19030 } 19031 19032 function getTargetFromTrigger($trigger) { 19033 var href 19034 var target = $trigger.attr('data-target') 19035 || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 19036 19037 return $(target) 19038 } 19039 19040 19041 // COLLAPSE PLUGIN DEFINITION 19042 // ========================== 19043 19044 function Plugin(option) { 19045 return this.each(function () { 19046 var $this = $(this) 19047 var data = $this.data('bs.collapse') 19048 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) 19049 19050 if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false 19051 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) 19052 if (typeof option == 'string') data[option]() 19053 }) 19054 } 19055 19056 var old = $.fn.collapse 19057 19058 $.fn.collapse = Plugin 19059 $.fn.collapse.Constructor = Collapse 19060 19061 19062 // COLLAPSE NO CONFLICT 19063 // ==================== 19064 19065 $.fn.collapse.noConflict = function () { 19066 $.fn.collapse = old 19067 return this 19068 } 19069 19070 19071 // COLLAPSE DATA-API 19072 // ================= 19073 19074 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { 19075 var $this = $(this) 19076 19077 if (!$this.attr('data-target')) e.preventDefault() 19078 19079 var $target = getTargetFromTrigger($this) 19080 var data = $target.data('bs.collapse') 19081 var option = data ? 'toggle' : $this.data() 19082 19083 Plugin.call($target, option) 19084 }) 19085 19086 }(jQuery); 19087 19088 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 19089 19090 /***/ }, 19091 /* 65 */ 19092 /***/ function(module, exports, __webpack_require__) { 19093 19094 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 19095 * Bootstrap: dropdown.js v3.3.7 19096 * http://getbootstrap.com/javascript/#dropdowns 19097 * ======================================================================== 19098 * Copyright 2011-2016 Twitter, Inc. 19099 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 19100 * ======================================================================== */ 19101 19102 19103 +function ($) { 19104 'use strict'; 19105 19106 // DROPDOWN CLASS DEFINITION 19107 // ========================= 19108 19109 var backdrop = '.dropdown-backdrop' 19110 var toggle = '[data-toggle="dropdown"]' 19111 var Dropdown = function (element) { 19112 $(element).on('click.bs.dropdown', this.toggle) 19113 } 19114 19115 Dropdown.VERSION = '3.3.7' 19116 19117 function getParent($this) { 19118 var selector = $this.attr('data-target') 19119 19120 if (!selector) { 19121 selector = $this.attr('href') 19122 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 19123 } 19124 19125 var $parent = selector && $(selector) 19126 19127 return $parent && $parent.length ? $parent : $this.parent() 19128 } 19129 19130 function clearMenus(e) { 19131 if (e && e.which === 3) return 19132 $(backdrop).remove() 19133 $(toggle).each(function () { 19134 var $this = $(this) 19135 var $parent = getParent($this) 19136 var relatedTarget = { relatedTarget: this } 19137 19138 if (!$parent.hasClass('open')) return 19139 19140 if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return 19141 19142 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) 19143 19144 if (e.isDefaultPrevented()) return 19145 19146 $this.attr('aria-expanded', 'false') 19147 $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget)) 19148 }) 19149 } 19150 19151 Dropdown.prototype.toggle = function (e) { 19152 var $this = $(this) 19153 19154 if ($this.is('.disabled, :disabled')) return 19155 19156 var $parent = getParent($this) 19157 var isActive = $parent.hasClass('open') 19158 19159 clearMenus() 19160 19161 if (!isActive) { 19162 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { 19163 // if mobile we use a backdrop because click events don't delegate 19164 $(document.createElement('div')) 19165 .addClass('dropdown-backdrop') 19166 .insertAfter($(this)) 19167 .on('click', clearMenus) 19168 } 19169 19170 var relatedTarget = { relatedTarget: this } 19171 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)) 19172 19173 if (e.isDefaultPrevented()) return 19174 19175 $this 19176 .trigger('focus') 19177 .attr('aria-expanded', 'true') 19178 19179 $parent 19180 .toggleClass('open') 19181 .trigger($.Event('shown.bs.dropdown', relatedTarget)) 19182 } 19183 19184 return false 19185 } 19186 19187 Dropdown.prototype.keydown = function (e) { 19188 if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return 19189 19190 var $this = $(this) 19191 19192 e.preventDefault() 19193 e.stopPropagation() 19194 19195 if ($this.is('.disabled, :disabled')) return 19196 19197 var $parent = getParent($this) 19198 var isActive = $parent.hasClass('open') 19199 19200 if (!isActive && e.which != 27 || isActive && e.which == 27) { 19201 if (e.which == 27) $parent.find(toggle).trigger('focus') 19202 return $this.trigger('click') 19203 } 19204 19205 var desc = ' li:not(.disabled):visible a' 19206 var $items = $parent.find('.dropdown-menu' + desc) 19207 19208 if (!$items.length) return 19209 19210 var index = $items.index(e.target) 19211 19212 if (e.which == 38 && index > 0) index-- // up 19213 if (e.which == 40 && index < $items.length - 1) index++ // down 19214 if (!~index) index = 0 19215 19216 $items.eq(index).trigger('focus') 19217 } 19218 19219 19220 // DROPDOWN PLUGIN DEFINITION 19221 // ========================== 19222 19223 function Plugin(option) { 19224 return this.each(function () { 19225 var $this = $(this) 19226 var data = $this.data('bs.dropdown') 19227 19228 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) 19229 if (typeof option == 'string') data[option].call($this) 19230 }) 19231 } 19232 19233 var old = $.fn.dropdown 19234 19235 $.fn.dropdown = Plugin 19236 $.fn.dropdown.Constructor = Dropdown 19237 19238 19239 // DROPDOWN NO CONFLICT 19240 // ==================== 19241 19242 $.fn.dropdown.noConflict = function () { 19243 $.fn.dropdown = old 19244 return this 19245 } 19246 19247 19248 // APPLY TO STANDARD DROPDOWN ELEMENTS 19249 // =================================== 19250 19251 $(document) 19252 .on('click.bs.dropdown.data-api', clearMenus) 19253 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) 19254 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) 19255 .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown) 19256 .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown) 19257 19258 }(jQuery); 19259 19260 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 19261 19262 /***/ }, 19263 /* 66 */ 19264 /***/ function(module, exports, __webpack_require__) { 19265 19266 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 19267 * Bootstrap: modal.js v3.3.7 19268 * http://getbootstrap.com/javascript/#modals 19269 * ======================================================================== 19270 * Copyright 2011-2016 Twitter, Inc. 19271 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 19272 * ======================================================================== */ 19273 19274 19275 +function ($) { 19276 'use strict'; 19277 19278 // MODAL CLASS DEFINITION 19279 // ====================== 19280 19281 var Modal = function (element, options) { 19282 this.options = options 19283 this.$body = $(document.body) 19284 this.$element = $(element) 19285 this.$dialog = this.$element.find('.modal-dialog') 19286 this.$backdrop = null 19287 this.isShown = null 19288 this.originalBodyPad = null 19289 this.scrollbarWidth = 0 19290 this.ignoreBackdropClick = false 19291 19292 if (this.options.remote) { 19293 this.$element 19294 .find('.modal-content') 19295 .load(this.options.remote, $.proxy(function () { 19296 this.$element.trigger('loaded.bs.modal') 19297 }, this)) 19298 } 19299 } 19300 19301 Modal.VERSION = '3.3.7' 19302 19303 Modal.TRANSITION_DURATION = 300 19304 Modal.BACKDROP_TRANSITION_DURATION = 150 19305 19306 Modal.DEFAULTS = { 19307 backdrop: true, 19308 keyboard: true, 19309 show: true 19310 } 19311 19312 Modal.prototype.toggle = function (_relatedTarget) { 19313 return this.isShown ? this.hide() : this.show(_relatedTarget) 19314 } 19315 19316 Modal.prototype.show = function (_relatedTarget) { 19317 var that = this 19318 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 19319 19320 this.$element.trigger(e) 19321 19322 if (this.isShown || e.isDefaultPrevented()) return 19323 19324 this.isShown = true 19325 19326 this.checkScrollbar() 19327 this.setScrollbar() 19328 this.$body.addClass('modal-open') 19329 19330 this.escape() 19331 this.resize() 19332 19333 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 19334 19335 this.$dialog.on('mousedown.dismiss.bs.modal', function () { 19336 that.$element.one('mouseup.dismiss.bs.modal', function (e) { 19337 if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true 19338 }) 19339 }) 19340 19341 this.backdrop(function () { 19342 var transition = $.support.transition && that.$element.hasClass('fade') 19343 19344 if (!that.$element.parent().length) { 19345 that.$element.appendTo(that.$body) // don't move modals dom position 19346 } 19347 19348 that.$element 19349 .show() 19350 .scrollTop(0) 19351 19352 that.adjustDialog() 19353 19354 if (transition) { 19355 that.$element[0].offsetWidth // force reflow 19356 } 19357 19358 that.$element.addClass('in') 19359 19360 that.enforceFocus() 19361 19362 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 19363 19364 transition ? 19365 that.$dialog // wait for modal to slide in 19366 .one('bsTransitionEnd', function () { 19367 that.$element.trigger('focus').trigger(e) 19368 }) 19369 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 19370 that.$element.trigger('focus').trigger(e) 19371 }) 19372 } 19373 19374 Modal.prototype.hide = function (e) { 19375 if (e) e.preventDefault() 19376 19377 e = $.Event('hide.bs.modal') 19378 19379 this.$element.trigger(e) 19380 19381 if (!this.isShown || e.isDefaultPrevented()) return 19382 19383 this.isShown = false 19384 19385 this.escape() 19386 this.resize() 19387 19388 $(document).off('focusin.bs.modal') 19389 19390 this.$element 19391 .removeClass('in') 19392 .off('click.dismiss.bs.modal') 19393 .off('mouseup.dismiss.bs.modal') 19394 19395 this.$dialog.off('mousedown.dismiss.bs.modal') 19396 19397 $.support.transition && this.$element.hasClass('fade') ? 19398 this.$element 19399 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 19400 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 19401 this.hideModal() 19402 } 19403 19404 Modal.prototype.enforceFocus = function () { 19405 $(document) 19406 .off('focusin.bs.modal') // guard against infinite focus loop 19407 .on('focusin.bs.modal', $.proxy(function (e) { 19408 if (document !== e.target && 19409 this.$element[0] !== e.target && 19410 !this.$element.has(e.target).length) { 19411 this.$element.trigger('focus') 19412 } 19413 }, this)) 19414 } 19415 19416 Modal.prototype.escape = function () { 19417 if (this.isShown && this.options.keyboard) { 19418 this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { 19419 e.which == 27 && this.hide() 19420 }, this)) 19421 } else if (!this.isShown) { 19422 this.$element.off('keydown.dismiss.bs.modal') 19423 } 19424 } 19425 19426 Modal.prototype.resize = function () { 19427 if (this.isShown) { 19428 $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) 19429 } else { 19430 $(window).off('resize.bs.modal') 19431 } 19432 } 19433 19434 Modal.prototype.hideModal = function () { 19435 var that = this 19436 this.$element.hide() 19437 this.backdrop(function () { 19438 that.$body.removeClass('modal-open') 19439 that.resetAdjustments() 19440 that.resetScrollbar() 19441 that.$element.trigger('hidden.bs.modal') 19442 }) 19443 } 19444 19445 Modal.prototype.removeBackdrop = function () { 19446 this.$backdrop && this.$backdrop.remove() 19447 this.$backdrop = null 19448 } 19449 19450 Modal.prototype.backdrop = function (callback) { 19451 var that = this 19452 var animate = this.$element.hasClass('fade') ? 'fade' : '' 19453 19454 if (this.isShown && this.options.backdrop) { 19455 var doAnimate = $.support.transition && animate 19456 19457 this.$backdrop = $(document.createElement('div')) 19458 .addClass('modal-backdrop ' + animate) 19459 .appendTo(this.$body) 19460 19461 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { 19462 if (this.ignoreBackdropClick) { 19463 this.ignoreBackdropClick = false 19464 return 19465 } 19466 if (e.target !== e.currentTarget) return 19467 this.options.backdrop == 'static' 19468 ? this.$element[0].focus() 19469 : this.hide() 19470 }, this)) 19471 19472 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 19473 19474 this.$backdrop.addClass('in') 19475 19476 if (!callback) return 19477 19478 doAnimate ? 19479 this.$backdrop 19480 .one('bsTransitionEnd', callback) 19481 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 19482 callback() 19483 19484 } else if (!this.isShown && this.$backdrop) { 19485 this.$backdrop.removeClass('in') 19486 19487 var callbackRemove = function () { 19488 that.removeBackdrop() 19489 callback && callback() 19490 } 19491 $.support.transition && this.$element.hasClass('fade') ? 19492 this.$backdrop 19493 .one('bsTransitionEnd', callbackRemove) 19494 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 19495 callbackRemove() 19496 19497 } else if (callback) { 19498 callback() 19499 } 19500 } 19501 19502 // these following methods are used to handle overflowing modals 19503 19504 Modal.prototype.handleUpdate = function () { 19505 this.adjustDialog() 19506 } 19507 19508 Modal.prototype.adjustDialog = function () { 19509 var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight 19510 19511 this.$element.css({ 19512 paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', 19513 paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' 19514 }) 19515 } 19516 19517 Modal.prototype.resetAdjustments = function () { 19518 this.$element.css({ 19519 paddingLeft: '', 19520 paddingRight: '' 19521 }) 19522 } 19523 19524 Modal.prototype.checkScrollbar = function () { 19525 var fullWindowWidth = window.innerWidth 19526 if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 19527 var documentElementRect = document.documentElement.getBoundingClientRect() 19528 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left) 19529 } 19530 this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth 19531 this.scrollbarWidth = this.measureScrollbar() 19532 } 19533 19534 Modal.prototype.setScrollbar = function () { 19535 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 19536 this.originalBodyPad = document.body.style.paddingRight || '' 19537 if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) 19538 } 19539 19540 Modal.prototype.resetScrollbar = function () { 19541 this.$body.css('padding-right', this.originalBodyPad) 19542 } 19543 19544 Modal.prototype.measureScrollbar = function () { // thx walsh 19545 var scrollDiv = document.createElement('div') 19546 scrollDiv.className = 'modal-scrollbar-measure' 19547 this.$body.append(scrollDiv) 19548 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 19549 this.$body[0].removeChild(scrollDiv) 19550 return scrollbarWidth 19551 } 19552 19553 19554 // MODAL PLUGIN DEFINITION 19555 // ======================= 19556 19557 function Plugin(option, _relatedTarget) { 19558 return this.each(function () { 19559 var $this = $(this) 19560 var data = $this.data('bs.modal') 19561 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 19562 19563 if (!data) $this.data('bs.modal', (data = new Modal(this, options))) 19564 if (typeof option == 'string') data[option](_relatedTarget) 19565 else if (options.show) data.show(_relatedTarget) 19566 }) 19567 } 19568 19569 var old = $.fn.modal 19570 19571 $.fn.modal = Plugin 19572 $.fn.modal.Constructor = Modal 19573 19574 19575 // MODAL NO CONFLICT 19576 // ================= 19577 19578 $.fn.modal.noConflict = function () { 19579 $.fn.modal = old 19580 return this 19581 } 19582 19583 19584 // MODAL DATA-API 19585 // ============== 19586 19587 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 19588 var $this = $(this) 19589 var href = $this.attr('href') 19590 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7 19591 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 19592 19593 if ($this.is('a')) e.preventDefault() 19594 19595 $target.one('show.bs.modal', function (showEvent) { 19596 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown 19597 $target.one('hidden.bs.modal', function () { 19598 $this.is(':visible') && $this.trigger('focus') 19599 }) 19600 }) 19601 Plugin.call($target, option, this) 19602 }) 19603 19604 }(jQuery); 19605 19606 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 19607 19608 /***/ }, 19609 /* 67 */ 19610 /***/ function(module, exports, __webpack_require__) { 19611 19612 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 19613 * Bootstrap: popover.js v3.3.7 19614 * http://getbootstrap.com/javascript/#popovers 19615 * ======================================================================== 19616 * Copyright 2011-2016 Twitter, Inc. 19617 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 19618 * ======================================================================== */ 19619 19620 19621 +function ($) { 19622 'use strict'; 19623 19624 // POPOVER PUBLIC CLASS DEFINITION 19625 // =============================== 19626 19627 var Popover = function (element, options) { 19628 this.init('popover', element, options) 19629 } 19630 19631 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js') 19632 19633 Popover.VERSION = '3.3.7' 19634 19635 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, { 19636 placement: 'right', 19637 trigger: 'click', 19638 content: '', 19639 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' 19640 }) 19641 19642 19643 // NOTE: POPOVER EXTENDS tooltip.js 19644 // ================================ 19645 19646 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype) 19647 19648 Popover.prototype.constructor = Popover 19649 19650 Popover.prototype.getDefaults = function () { 19651 return Popover.DEFAULTS 19652 } 19653 19654 Popover.prototype.setContent = function () { 19655 var $tip = this.tip() 19656 var title = this.getTitle() 19657 var content = this.getContent() 19658 19659 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) 19660 $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events 19661 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text' 19662 ](content) 19663 19664 $tip.removeClass('fade top bottom left right in') 19665 19666 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do 19667 // this manually by checking the contents. 19668 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide() 19669 } 19670 19671 Popover.prototype.hasContent = function () { 19672 return this.getTitle() || this.getContent() 19673 } 19674 19675 Popover.prototype.getContent = function () { 19676 var $e = this.$element 19677 var o = this.options 19678 19679 return $e.attr('data-content') 19680 || (typeof o.content == 'function' ? 19681 o.content.call($e[0]) : 19682 o.content) 19683 } 19684 19685 Popover.prototype.arrow = function () { 19686 return (this.$arrow = this.$arrow || this.tip().find('.arrow')) 19687 } 19688 19689 19690 // POPOVER PLUGIN DEFINITION 19691 // ========================= 19692 19693 function Plugin(option) { 19694 return this.each(function () { 19695 var $this = $(this) 19696 var data = $this.data('bs.popover') 19697 var options = typeof option == 'object' && option 19698 19699 if (!data && /destroy|hide/.test(option)) return 19700 if (!data) $this.data('bs.popover', (data = new Popover(this, options))) 19701 if (typeof option == 'string') data[option]() 19702 }) 19703 } 19704 19705 var old = $.fn.popover 19706 19707 $.fn.popover = Plugin 19708 $.fn.popover.Constructor = Popover 19709 19710 19711 // POPOVER NO CONFLICT 19712 // =================== 19713 19714 $.fn.popover.noConflict = function () { 19715 $.fn.popover = old 19716 return this 19717 } 19718 19719 }(jQuery); 19720 19721 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 19722 19723 /***/ }, 19724 /* 68 */ 19725 /***/ function(module, exports, __webpack_require__) { 19726 19727 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 19728 * Bootstrap: scrollspy.js v3.3.7 19729 * http://getbootstrap.com/javascript/#scrollspy 19730 * ======================================================================== 19731 * Copyright 2011-2016 Twitter, Inc. 19732 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 19733 * ======================================================================== */ 19734 19735 19736 +function ($) { 19737 'use strict'; 19738 19739 // SCROLLSPY CLASS DEFINITION 19740 // ========================== 19741 19742 function ScrollSpy(element, options) { 19743 this.$body = $(document.body) 19744 this.$scrollElement = $(element).is(document.body) ? $(window) : $(element) 19745 this.options = $.extend({}, ScrollSpy.DEFAULTS, options) 19746 this.selector = (this.options.target || '') + ' .nav li > a' 19747 this.offsets = [] 19748 this.targets = [] 19749 this.activeTarget = null 19750 this.scrollHeight = 0 19751 19752 this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this)) 19753 this.refresh() 19754 this.process() 19755 } 19756 19757 ScrollSpy.VERSION = '3.3.7' 19758 19759 ScrollSpy.DEFAULTS = { 19760 offset: 10 19761 } 19762 19763 ScrollSpy.prototype.getScrollHeight = function () { 19764 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight) 19765 } 19766 19767 ScrollSpy.prototype.refresh = function () { 19768 var that = this 19769 var offsetMethod = 'offset' 19770 var offsetBase = 0 19771 19772 this.offsets = [] 19773 this.targets = [] 19774 this.scrollHeight = this.getScrollHeight() 19775 19776 if (!$.isWindow(this.$scrollElement[0])) { 19777 offsetMethod = 'position' 19778 offsetBase = this.$scrollElement.scrollTop() 19779 } 19780 19781 this.$body 19782 .find(this.selector) 19783 .map(function () { 19784 var $el = $(this) 19785 var href = $el.data('target') || $el.attr('href') 19786 var $href = /^#./.test(href) && $(href) 19787 19788 return ($href 19789 && $href.length 19790 && $href.is(':visible') 19791 && [[$href[offsetMethod]().top + offsetBase, href]]) || null 19792 }) 19793 .sort(function (a, b) { return a[0] - b[0] }) 19794 .each(function () { 19795 that.offsets.push(this[0]) 19796 that.targets.push(this[1]) 19797 }) 19798 } 19799 19800 ScrollSpy.prototype.process = function () { 19801 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset 19802 var scrollHeight = this.getScrollHeight() 19803 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height() 19804 var offsets = this.offsets 19805 var targets = this.targets 19806 var activeTarget = this.activeTarget 19807 var i 19808 19809 if (this.scrollHeight != scrollHeight) { 19810 this.refresh() 19811 } 19812 19813 if (scrollTop >= maxScroll) { 19814 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i) 19815 } 19816 19817 if (activeTarget && scrollTop < offsets[0]) { 19818 this.activeTarget = null 19819 return this.clear() 19820 } 19821 19822 for (i = offsets.length; i--;) { 19823 activeTarget != targets[i] 19824 && scrollTop >= offsets[i] 19825 && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1]) 19826 && this.activate(targets[i]) 19827 } 19828 } 19829 19830 ScrollSpy.prototype.activate = function (target) { 19831 this.activeTarget = target 19832 19833 this.clear() 19834 19835 var selector = this.selector + 19836 '[data-target="' + target + '"],' + 19837 this.selector + '[href="' + target + '"]' 19838 19839 var active = $(selector) 19840 .parents('li') 19841 .addClass('active') 19842 19843 if (active.parent('.dropdown-menu').length) { 19844 active = active 19845 .closest('li.dropdown') 19846 .addClass('active') 19847 } 19848 19849 active.trigger('activate.bs.scrollspy') 19850 } 19851 19852 ScrollSpy.prototype.clear = function () { 19853 $(this.selector) 19854 .parentsUntil(this.options.target, '.active') 19855 .removeClass('active') 19856 } 19857 19858 19859 // SCROLLSPY PLUGIN DEFINITION 19860 // =========================== 19861 19862 function Plugin(option) { 19863 return this.each(function () { 19864 var $this = $(this) 19865 var data = $this.data('bs.scrollspy') 19866 var options = typeof option == 'object' && option 19867 19868 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options))) 19869 if (typeof option == 'string') data[option]() 19870 }) 19871 } 19872 19873 var old = $.fn.scrollspy 19874 19875 $.fn.scrollspy = Plugin 19876 $.fn.scrollspy.Constructor = ScrollSpy 19877 19878 19879 // SCROLLSPY NO CONFLICT 19880 // ===================== 19881 19882 $.fn.scrollspy.noConflict = function () { 19883 $.fn.scrollspy = old 19884 return this 19885 } 19886 19887 19888 // SCROLLSPY DATA-API 19889 // ================== 19890 19891 $(window).on('load.bs.scrollspy.data-api', function () { 19892 $('[data-spy="scroll"]').each(function () { 19893 var $spy = $(this) 19894 Plugin.call($spy, $spy.data()) 19895 }) 19896 }) 19897 19898 }(jQuery); 19899 19900 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 19901 19902 /***/ }, 19903 /* 69 */ 19904 /***/ function(module, exports, __webpack_require__) { 19905 19906 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 19907 * Bootstrap: tab.js v3.3.7 19908 * http://getbootstrap.com/javascript/#tabs 19909 * ======================================================================== 19910 * Copyright 2011-2016 Twitter, Inc. 19911 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 19912 * ======================================================================== */ 19913 19914 19915 +function ($) { 19916 'use strict'; 19917 19918 // TAB CLASS DEFINITION 19919 // ==================== 19920 19921 var Tab = function (element) { 19922 // jscs:disable requireDollarBeforejQueryAssignment 19923 this.element = $(element) 19924 // jscs:enable requireDollarBeforejQueryAssignment 19925 } 19926 19927 Tab.VERSION = '3.3.7' 19928 19929 Tab.TRANSITION_DURATION = 150 19930 19931 Tab.prototype.show = function () { 19932 var $this = this.element 19933 var $ul = $this.closest('ul:not(.dropdown-menu)') 19934 var selector = $this.data('target') 19935 19936 if (!selector) { 19937 selector = $this.attr('href') 19938 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 19939 } 19940 19941 if ($this.parent('li').hasClass('active')) return 19942 19943 var $previous = $ul.find('.active:last a') 19944 var hideEvent = $.Event('hide.bs.tab', { 19945 relatedTarget: $this[0] 19946 }) 19947 var showEvent = $.Event('show.bs.tab', { 19948 relatedTarget: $previous[0] 19949 }) 19950 19951 $previous.trigger(hideEvent) 19952 $this.trigger(showEvent) 19953 19954 if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return 19955 19956 var $target = $(selector) 19957 19958 this.activate($this.closest('li'), $ul) 19959 this.activate($target, $target.parent(), function () { 19960 $previous.trigger({ 19961 type: 'hidden.bs.tab', 19962 relatedTarget: $this[0] 19963 }) 19964 $this.trigger({ 19965 type: 'shown.bs.tab', 19966 relatedTarget: $previous[0] 19967 }) 19968 }) 19969 } 19970 19971 Tab.prototype.activate = function (element, container, callback) { 19972 var $active = container.find('> .active') 19973 var transition = callback 19974 && $.support.transition 19975 && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length) 19976 19977 function next() { 19978 $active 19979 .removeClass('active') 19980 .find('> .dropdown-menu > .active') 19981 .removeClass('active') 19982 .end() 19983 .find('[data-toggle="tab"]') 19984 .attr('aria-expanded', false) 19985 19986 element 19987 .addClass('active') 19988 .find('[data-toggle="tab"]') 19989 .attr('aria-expanded', true) 19990 19991 if (transition) { 19992 element[0].offsetWidth // reflow for transition 19993 element.addClass('in') 19994 } else { 19995 element.removeClass('fade') 19996 } 19997 19998 if (element.parent('.dropdown-menu').length) { 19999 element 20000 .closest('li.dropdown') 20001 .addClass('active') 20002 .end() 20003 .find('[data-toggle="tab"]') 20004 .attr('aria-expanded', true) 20005 } 20006 20007 callback && callback() 20008 } 20009 20010 $active.length && transition ? 20011 $active 20012 .one('bsTransitionEnd', next) 20013 .emulateTransitionEnd(Tab.TRANSITION_DURATION) : 20014 next() 20015 20016 $active.removeClass('in') 20017 } 20018 20019 20020 // TAB PLUGIN DEFINITION 20021 // ===================== 20022 20023 function Plugin(option) { 20024 return this.each(function () { 20025 var $this = $(this) 20026 var data = $this.data('bs.tab') 20027 20028 if (!data) $this.data('bs.tab', (data = new Tab(this))) 20029 if (typeof option == 'string') data[option]() 20030 }) 20031 } 20032 20033 var old = $.fn.tab 20034 20035 $.fn.tab = Plugin 20036 $.fn.tab.Constructor = Tab 20037 20038 20039 // TAB NO CONFLICT 20040 // =============== 20041 20042 $.fn.tab.noConflict = function () { 20043 $.fn.tab = old 20044 return this 20045 } 20046 20047 20048 // TAB DATA-API 20049 // ============ 20050 20051 var clickHandler = function (e) { 20052 e.preventDefault() 20053 Plugin.call($(this), 'show') 20054 } 20055 20056 $(document) 20057 .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler) 20058 .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler) 20059 20060 }(jQuery); 20061 20062 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 20063 20064 /***/ }, 20065 /* 70 */ 20066 /***/ function(module, exports, __webpack_require__) { 20067 20068 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 20069 * Bootstrap: tooltip.js v3.3.7 20070 * http://getbootstrap.com/javascript/#tooltip 20071 * Inspired by the original jQuery.tipsy by Jason Frame 20072 * ======================================================================== 20073 * Copyright 2011-2016 Twitter, Inc. 20074 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 20075 * ======================================================================== */ 20076 20077 20078 +function ($) { 20079 'use strict'; 20080 20081 // TOOLTIP PUBLIC CLASS DEFINITION 20082 // =============================== 20083 20084 var Tooltip = function (element, options) { 20085 this.type = null 20086 this.options = null 20087 this.enabled = null 20088 this.timeout = null 20089 this.hoverState = null 20090 this.$element = null 20091 this.inState = null 20092 20093 this.init('tooltip', element, options) 20094 } 20095 20096 Tooltip.VERSION = '3.3.7' 20097 20098 Tooltip.TRANSITION_DURATION = 150 20099 20100 Tooltip.DEFAULTS = { 20101 animation: true, 20102 placement: 'top', 20103 selector: false, 20104 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', 20105 trigger: 'hover focus', 20106 title: '', 20107 delay: 0, 20108 html: false, 20109 container: false, 20110 viewport: { 20111 selector: 'body', 20112 padding: 0 20113 } 20114 } 20115 20116 Tooltip.prototype.init = function (type, element, options) { 20117 this.enabled = true 20118 this.type = type 20119 this.$element = $(element) 20120 this.options = this.getOptions(options) 20121 this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport)) 20122 this.inState = { click: false, hover: false, focus: false } 20123 20124 if (this.$element[0] instanceof document.constructor && !this.options.selector) { 20125 throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!') 20126 } 20127 20128 var triggers = this.options.trigger.split(' ') 20129 20130 for (var i = triggers.length; i--;) { 20131 var trigger = triggers[i] 20132 20133 if (trigger == 'click') { 20134 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) 20135 } else if (trigger != 'manual') { 20136 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin' 20137 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout' 20138 20139 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) 20140 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) 20141 } 20142 } 20143 20144 this.options.selector ? 20145 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : 20146 this.fixTitle() 20147 } 20148 20149 Tooltip.prototype.getDefaults = function () { 20150 return Tooltip.DEFAULTS 20151 } 20152 20153 Tooltip.prototype.getOptions = function (options) { 20154 options = $.extend({}, this.getDefaults(), this.$element.data(), options) 20155 20156 if (options.delay && typeof options.delay == 'number') { 20157 options.delay = { 20158 show: options.delay, 20159 hide: options.delay 20160 } 20161 } 20162 20163 return options 20164 } 20165 20166 Tooltip.prototype.getDelegateOptions = function () { 20167 var options = {} 20168 var defaults = this.getDefaults() 20169 20170 this._options && $.each(this._options, function (key, value) { 20171 if (defaults[key] != value) options[key] = value 20172 }) 20173 20174 return options 20175 } 20176 20177 Tooltip.prototype.enter = function (obj) { 20178 var self = obj instanceof this.constructor ? 20179 obj : $(obj.currentTarget).data('bs.' + this.type) 20180 20181 if (!self) { 20182 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 20183 $(obj.currentTarget).data('bs.' + this.type, self) 20184 } 20185 20186 if (obj instanceof $.Event) { 20187 self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true 20188 } 20189 20190 if (self.tip().hasClass('in') || self.hoverState == 'in') { 20191 self.hoverState = 'in' 20192 return 20193 } 20194 20195 clearTimeout(self.timeout) 20196 20197 self.hoverState = 'in' 20198 20199 if (!self.options.delay || !self.options.delay.show) return self.show() 20200 20201 self.timeout = setTimeout(function () { 20202 if (self.hoverState == 'in') self.show() 20203 }, self.options.delay.show) 20204 } 20205 20206 Tooltip.prototype.isInStateTrue = function () { 20207 for (var key in this.inState) { 20208 if (this.inState[key]) return true 20209 } 20210 20211 return false 20212 } 20213 20214 Tooltip.prototype.leave = function (obj) { 20215 var self = obj instanceof this.constructor ? 20216 obj : $(obj.currentTarget).data('bs.' + this.type) 20217 20218 if (!self) { 20219 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 20220 $(obj.currentTarget).data('bs.' + this.type, self) 20221 } 20222 20223 if (obj instanceof $.Event) { 20224 self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false 20225 } 20226 20227 if (self.isInStateTrue()) return 20228 20229 clearTimeout(self.timeout) 20230 20231 self.hoverState = 'out' 20232 20233 if (!self.options.delay || !self.options.delay.hide) return self.hide() 20234 20235 self.timeout = setTimeout(function () { 20236 if (self.hoverState == 'out') self.hide() 20237 }, self.options.delay.hide) 20238 } 20239 20240 Tooltip.prototype.show = function () { 20241 var e = $.Event('show.bs.' + this.type) 20242 20243 if (this.hasContent() && this.enabled) { 20244 this.$element.trigger(e) 20245 20246 var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0]) 20247 if (e.isDefaultPrevented() || !inDom) return 20248 var that = this 20249 20250 var $tip = this.tip() 20251 20252 var tipId = this.getUID(this.type) 20253 20254 this.setContent() 20255 $tip.attr('id', tipId) 20256 this.$element.attr('aria-describedby', tipId) 20257 20258 if (this.options.animation) $tip.addClass('fade') 20259 20260 var placement = typeof this.options.placement == 'function' ? 20261 this.options.placement.call(this, $tip[0], this.$element[0]) : 20262 this.options.placement 20263 20264 var autoToken = /\s?auto?\s?/i 20265 var autoPlace = autoToken.test(placement) 20266 if (autoPlace) placement = placement.replace(autoToken, '') || 'top' 20267 20268 $tip 20269 .detach() 20270 .css({ top: 0, left: 0, display: 'block' }) 20271 .addClass(placement) 20272 .data('bs.' + this.type, this) 20273 20274 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) 20275 this.$element.trigger('inserted.bs.' + this.type) 20276 20277 var pos = this.getPosition() 20278 var actualWidth = $tip[0].offsetWidth 20279 var actualHeight = $tip[0].offsetHeight 20280 20281 if (autoPlace) { 20282 var orgPlacement = placement 20283 var viewportDim = this.getPosition(this.$viewport) 20284 20285 placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' : 20286 placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' : 20287 placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' : 20288 placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' : 20289 placement 20290 20291 $tip 20292 .removeClass(orgPlacement) 20293 .addClass(placement) 20294 } 20295 20296 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) 20297 20298 this.applyPlacement(calculatedOffset, placement) 20299 20300 var complete = function () { 20301 var prevHoverState = that.hoverState 20302 that.$element.trigger('shown.bs.' + that.type) 20303 that.hoverState = null 20304 20305 if (prevHoverState == 'out') that.leave(that) 20306 } 20307 20308 $.support.transition && this.$tip.hasClass('fade') ? 20309 $tip 20310 .one('bsTransitionEnd', complete) 20311 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : 20312 complete() 20313 } 20314 } 20315 20316 Tooltip.prototype.applyPlacement = function (offset, placement) { 20317 var $tip = this.tip() 20318 var width = $tip[0].offsetWidth 20319 var height = $tip[0].offsetHeight 20320 20321 // manually read margins because getBoundingClientRect includes difference 20322 var marginTop = parseInt($tip.css('margin-top'), 10) 20323 var marginLeft = parseInt($tip.css('margin-left'), 10) 20324 20325 // we must check for NaN for ie 8/9 20326 if (isNaN(marginTop)) marginTop = 0 20327 if (isNaN(marginLeft)) marginLeft = 0 20328 20329 offset.top += marginTop 20330 offset.left += marginLeft 20331 20332 // $.fn.offset doesn't round pixel values 20333 // so we use setOffset directly with our own function B-0 20334 $.offset.setOffset($tip[0], $.extend({ 20335 using: function (props) { 20336 $tip.css({ 20337 top: Math.round(props.top), 20338 left: Math.round(props.left) 20339 }) 20340 } 20341 }, offset), 0) 20342 20343 $tip.addClass('in') 20344 20345 // check to see if placing tip in new offset caused the tip to resize itself 20346 var actualWidth = $tip[0].offsetWidth 20347 var actualHeight = $tip[0].offsetHeight 20348 20349 if (placement == 'top' && actualHeight != height) { 20350 offset.top = offset.top + height - actualHeight 20351 } 20352 20353 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight) 20354 20355 if (delta.left) offset.left += delta.left 20356 else offset.top += delta.top 20357 20358 var isVertical = /top|bottom/.test(placement) 20359 var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight 20360 var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight' 20361 20362 $tip.offset(offset) 20363 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical) 20364 } 20365 20366 Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) { 20367 this.arrow() 20368 .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%') 20369 .css(isVertical ? 'top' : 'left', '') 20370 } 20371 20372 Tooltip.prototype.setContent = function () { 20373 var $tip = this.tip() 20374 var title = this.getTitle() 20375 20376 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) 20377 $tip.removeClass('fade in top bottom left right') 20378 } 20379 20380 Tooltip.prototype.hide = function (callback) { 20381 var that = this 20382 var $tip = $(this.$tip) 20383 var e = $.Event('hide.bs.' + this.type) 20384 20385 function complete() { 20386 if (that.hoverState != 'in') $tip.detach() 20387 if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary. 20388 that.$element 20389 .removeAttr('aria-describedby') 20390 .trigger('hidden.bs.' + that.type) 20391 } 20392 callback && callback() 20393 } 20394 20395 this.$element.trigger(e) 20396 20397 if (e.isDefaultPrevented()) return 20398 20399 $tip.removeClass('in') 20400 20401 $.support.transition && $tip.hasClass('fade') ? 20402 $tip 20403 .one('bsTransitionEnd', complete) 20404 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : 20405 complete() 20406 20407 this.hoverState = null 20408 20409 return this 20410 } 20411 20412 Tooltip.prototype.fixTitle = function () { 20413 var $e = this.$element 20414 if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') { 20415 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '') 20416 } 20417 } 20418 20419 Tooltip.prototype.hasContent = function () { 20420 return this.getTitle() 20421 } 20422 20423 Tooltip.prototype.getPosition = function ($element) { 20424 $element = $element || this.$element 20425 20426 var el = $element[0] 20427 var isBody = el.tagName == 'BODY' 20428 20429 var elRect = el.getBoundingClientRect() 20430 if (elRect.width == null) { 20431 // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093 20432 elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top }) 20433 } 20434 var isSvg = window.SVGElement && el instanceof window.SVGElement 20435 // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3. 20436 // See https://github.com/twbs/bootstrap/issues/20280 20437 var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset()) 20438 var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() } 20439 var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null 20440 20441 return $.extend({}, elRect, scroll, outerDims, elOffset) 20442 } 20443 20444 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { 20445 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : 20446 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : 20447 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : 20448 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } 20449 20450 } 20451 20452 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) { 20453 var delta = { top: 0, left: 0 } 20454 if (!this.$viewport) return delta 20455 20456 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0 20457 var viewportDimensions = this.getPosition(this.$viewport) 20458 20459 if (/right|left/.test(placement)) { 20460 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll 20461 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight 20462 if (topEdgeOffset < viewportDimensions.top) { // top overflow 20463 delta.top = viewportDimensions.top - topEdgeOffset 20464 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow 20465 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset 20466 } 20467 } else { 20468 var leftEdgeOffset = pos.left - viewportPadding 20469 var rightEdgeOffset = pos.left + viewportPadding + actualWidth 20470 if (leftEdgeOffset < viewportDimensions.left) { // left overflow 20471 delta.left = viewportDimensions.left - leftEdgeOffset 20472 } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow 20473 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset 20474 } 20475 } 20476 20477 return delta 20478 } 20479 20480 Tooltip.prototype.getTitle = function () { 20481 var title 20482 var $e = this.$element 20483 var o = this.options 20484 20485 title = $e.attr('data-original-title') 20486 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) 20487 20488 return title 20489 } 20490 20491 Tooltip.prototype.getUID = function (prefix) { 20492 do prefix += ~~(Math.random() * 1000000) 20493 while (document.getElementById(prefix)) 20494 return prefix 20495 } 20496 20497 Tooltip.prototype.tip = function () { 20498 if (!this.$tip) { 20499 this.$tip = $(this.options.template) 20500 if (this.$tip.length != 1) { 20501 throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!') 20502 } 20503 } 20504 return this.$tip 20505 } 20506 20507 Tooltip.prototype.arrow = function () { 20508 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')) 20509 } 20510 20511 Tooltip.prototype.enable = function () { 20512 this.enabled = true 20513 } 20514 20515 Tooltip.prototype.disable = function () { 20516 this.enabled = false 20517 } 20518 20519 Tooltip.prototype.toggleEnabled = function () { 20520 this.enabled = !this.enabled 20521 } 20522 20523 Tooltip.prototype.toggle = function (e) { 20524 var self = this 20525 if (e) { 20526 self = $(e.currentTarget).data('bs.' + this.type) 20527 if (!self) { 20528 self = new this.constructor(e.currentTarget, this.getDelegateOptions()) 20529 $(e.currentTarget).data('bs.' + this.type, self) 20530 } 20531 } 20532 20533 if (e) { 20534 self.inState.click = !self.inState.click 20535 if (self.isInStateTrue()) self.enter(self) 20536 else self.leave(self) 20537 } else { 20538 self.tip().hasClass('in') ? self.leave(self) : self.enter(self) 20539 } 20540 } 20541 20542 Tooltip.prototype.destroy = function () { 20543 var that = this 20544 clearTimeout(this.timeout) 20545 this.hide(function () { 20546 that.$element.off('.' + that.type).removeData('bs.' + that.type) 20547 if (that.$tip) { 20548 that.$tip.detach() 20549 } 20550 that.$tip = null 20551 that.$arrow = null 20552 that.$viewport = null 20553 that.$element = null 20554 }) 20555 } 20556 20557 20558 // TOOLTIP PLUGIN DEFINITION 20559 // ========================= 20560 20561 function Plugin(option) { 20562 return this.each(function () { 20563 var $this = $(this) 20564 var data = $this.data('bs.tooltip') 20565 var options = typeof option == 'object' && option 20566 20567 if (!data && /destroy|hide/.test(option)) return 20568 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options))) 20569 if (typeof option == 'string') data[option]() 20570 }) 20571 } 20572 20573 var old = $.fn.tooltip 20574 20575 $.fn.tooltip = Plugin 20576 $.fn.tooltip.Constructor = Tooltip 20577 20578 20579 // TOOLTIP NO CONFLICT 20580 // =================== 20581 20582 $.fn.tooltip.noConflict = function () { 20583 $.fn.tooltip = old 20584 return this 20585 } 20586 20587 }(jQuery); 20588 20589 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 20590 20591 /***/ }, 20592 /* 71 */ 20593 /***/ function(module, exports, __webpack_require__) { 20594 20595 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 20596 * Bootstrap: transition.js v3.3.7 20597 * http://getbootstrap.com/javascript/#transitions 20598 * ======================================================================== 20599 * Copyright 2011-2016 Twitter, Inc. 20600 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 20601 * ======================================================================== */ 20602 20603 20604 +function ($) { 20605 'use strict'; 20606 20607 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 20608 // ============================================================ 20609 20610 function transitionEnd() { 20611 var el = document.createElement('bootstrap') 20612 20613 var transEndEventNames = { 20614 WebkitTransition : 'webkitTransitionEnd', 20615 MozTransition : 'transitionend', 20616 OTransition : 'oTransitionEnd otransitionend', 20617 transition : 'transitionend' 20618 } 20619 20620 for (var name in transEndEventNames) { 20621 if (el.style[name] !== undefined) { 20622 return { end: transEndEventNames[name] } 20623 } 20624 } 20625 20626 return false // explicit for ie8 ( ._.) 20627 } 20628 20629 // http://blog.alexmaccaw.com/css-transitions 20630 $.fn.emulateTransitionEnd = function (duration) { 20631 var called = false 20632 var $el = this 20633 $(this).one('bsTransitionEnd', function () { called = true }) 20634 var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 20635 setTimeout(callback, duration) 20636 return this 20637 } 20638 20639 $(function () { 20640 $.support.transition = transitionEnd() 20641 20642 if (!$.support.transition) return 20643 20644 $.event.special.bsTransitionEnd = { 20645 bindType: $.support.transition.end, 20646 delegateType: $.support.transition.end, 20647 handle: function (e) { 20648 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) 20649 } 20650 } 20651 }) 20652 20653 }(jQuery); 20654 20655 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) 20656 20657 /***/ }, 20658 /* 72 */ 20659 /***/ function(module, exports, __webpack_require__) { 20660 20661 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* 20662 Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved. 20663 20664 Redistribution and use in source and binary forms, with or without 20665 modification, are permitted provided that the following conditions are met: 20666 20667 * Redistributions of source code must retain the above copyright 20668 notice, this list of conditions and the following disclaimer. 20669 * Redistributions in binary form must reproduce the above copyright 20670 notice, this list of conditions and the following disclaimer in the 20671 documentation and/or other materials provided with the distribution. 20672 20673 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20674 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20675 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20676 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 20677 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20678 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20679 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20680 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20681 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 20682 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20683 */ 20684 20685 (function (root, factory) { 20686 'use strict'; 20687 20688 // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, 20689 // Rhino, and plain browser loading. 20690 20691 /* istanbul ignore next */ 20692 if (true) { 20693 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 20694 } else if (typeof exports !== 'undefined') { 20695 factory(exports); 20696 } else { 20697 factory((root.esprima = {})); 20698 } 20699 }(this, function (exports) { 20700 'use strict'; 20701 20702 var Token, 20703 TokenName, 20704 FnExprTokens, 20705 Syntax, 20706 PlaceHolders, 20707 Messages, 20708 Regex, 20709 source, 20710 strict, 20711 index, 20712 lineNumber, 20713 lineStart, 20714 hasLineTerminator, 20715 lastIndex, 20716 lastLineNumber, 20717 lastLineStart, 20718 startIndex, 20719 startLineNumber, 20720 startLineStart, 20721 scanning, 20722 length, 20723 lookahead, 20724 state, 20725 extra, 20726 isBindingElement, 20727 isAssignmentTarget, 20728 firstCoverInitializedNameError; 20729 20730 Token = { 20731 BooleanLiteral: 1, 20732 EOF: 2, 20733 Identifier: 3, 20734 Keyword: 4, 20735 NullLiteral: 5, 20736 NumericLiteral: 6, 20737 Punctuator: 7, 20738 StringLiteral: 8, 20739 RegularExpression: 9, 20740 Template: 10 20741 }; 20742 20743 TokenName = {}; 20744 TokenName[Token.BooleanLiteral] = 'Boolean'; 20745 TokenName[Token.EOF] = '<end>'; 20746 TokenName[Token.Identifier] = 'Identifier'; 20747 TokenName[Token.Keyword] = 'Keyword'; 20748 TokenName[Token.NullLiteral] = 'Null'; 20749 TokenName[Token.NumericLiteral] = 'Numeric'; 20750 TokenName[Token.Punctuator] = 'Punctuator'; 20751 TokenName[Token.StringLiteral] = 'String'; 20752 TokenName[Token.RegularExpression] = 'RegularExpression'; 20753 TokenName[Token.Template] = 'Template'; 20754 20755 // A function following one of those tokens is an expression. 20756 FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', 20757 'return', 'case', 'delete', 'throw', 'void', 20758 // assignment operators 20759 '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', 20760 '&=', '|=', '^=', ',', 20761 // binary/unary operators 20762 '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', 20763 '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', 20764 '<=', '<', '>', '!=', '!==']; 20765 20766 Syntax = { 20767 AssignmentExpression: 'AssignmentExpression', 20768 AssignmentPattern: 'AssignmentPattern', 20769 ArrayExpression: 'ArrayExpression', 20770 ArrayPattern: 'ArrayPattern', 20771 ArrowFunctionExpression: 'ArrowFunctionExpression', 20772 BlockStatement: 'BlockStatement', 20773 BinaryExpression: 'BinaryExpression', 20774 BreakStatement: 'BreakStatement', 20775 CallExpression: 'CallExpression', 20776 CatchClause: 'CatchClause', 20777 ClassBody: 'ClassBody', 20778 ClassDeclaration: 'ClassDeclaration', 20779 ClassExpression: 'ClassExpression', 20780 ConditionalExpression: 'ConditionalExpression', 20781 ContinueStatement: 'ContinueStatement', 20782 DoWhileStatement: 'DoWhileStatement', 20783 DebuggerStatement: 'DebuggerStatement', 20784 EmptyStatement: 'EmptyStatement', 20785 ExportAllDeclaration: 'ExportAllDeclaration', 20786 ExportDefaultDeclaration: 'ExportDefaultDeclaration', 20787 ExportNamedDeclaration: 'ExportNamedDeclaration', 20788 ExportSpecifier: 'ExportSpecifier', 20789 ExpressionStatement: 'ExpressionStatement', 20790 ForStatement: 'ForStatement', 20791 ForOfStatement: 'ForOfStatement', 20792 ForInStatement: 'ForInStatement', 20793 FunctionDeclaration: 'FunctionDeclaration', 20794 FunctionExpression: 'FunctionExpression', 20795 Identifier: 'Identifier', 20796 IfStatement: 'IfStatement', 20797 ImportDeclaration: 'ImportDeclaration', 20798 ImportDefaultSpecifier: 'ImportDefaultSpecifier', 20799 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', 20800 ImportSpecifier: 'ImportSpecifier', 20801 Literal: 'Literal', 20802 LabeledStatement: 'LabeledStatement', 20803 LogicalExpression: 'LogicalExpression', 20804 MemberExpression: 'MemberExpression', 20805 MetaProperty: 'MetaProperty', 20806 MethodDefinition: 'MethodDefinition', 20807 NewExpression: 'NewExpression', 20808 ObjectExpression: 'ObjectExpression', 20809 ObjectPattern: 'ObjectPattern', 20810 Program: 'Program', 20811 Property: 'Property', 20812 RestElement: 'RestElement', 20813 ReturnStatement: 'ReturnStatement', 20814 SequenceExpression: 'SequenceExpression', 20815 SpreadElement: 'SpreadElement', 20816 Super: 'Super', 20817 SwitchCase: 'SwitchCase', 20818 SwitchStatement: 'SwitchStatement', 20819 TaggedTemplateExpression: 'TaggedTemplateExpression', 20820 TemplateElement: 'TemplateElement', 20821 TemplateLiteral: 'TemplateLiteral', 20822 ThisExpression: 'ThisExpression', 20823 ThrowStatement: 'ThrowStatement', 20824 TryStatement: 'TryStatement', 20825 UnaryExpression: 'UnaryExpression', 20826 UpdateExpression: 'UpdateExpression', 20827 VariableDeclaration: 'VariableDeclaration', 20828 VariableDeclarator: 'VariableDeclarator', 20829 WhileStatement: 'WhileStatement', 20830 WithStatement: 'WithStatement', 20831 YieldExpression: 'YieldExpression' 20832 }; 20833 20834 PlaceHolders = { 20835 ArrowParameterPlaceHolder: 'ArrowParameterPlaceHolder' 20836 }; 20837 20838 // Error messages should be identical to V8. 20839 Messages = { 20840 UnexpectedToken: 'Unexpected token %0', 20841 UnexpectedNumber: 'Unexpected number', 20842 UnexpectedString: 'Unexpected string', 20843 UnexpectedIdentifier: 'Unexpected identifier', 20844 UnexpectedReserved: 'Unexpected reserved word', 20845 UnexpectedTemplate: 'Unexpected quasi %0', 20846 UnexpectedEOS: 'Unexpected end of input', 20847 NewlineAfterThrow: 'Illegal newline after throw', 20848 InvalidRegExp: 'Invalid regular expression', 20849 UnterminatedRegExp: 'Invalid regular expression: missing /', 20850 InvalidLHSInAssignment: 'Invalid left-hand side in assignment', 20851 InvalidLHSInForIn: 'Invalid left-hand side in for-in', 20852 InvalidLHSInForLoop: 'Invalid left-hand side in for-loop', 20853 MultipleDefaultsInSwitch: 'More than one default clause in switch statement', 20854 NoCatchOrFinally: 'Missing catch or finally after try', 20855 UnknownLabel: 'Undefined label \'%0\'', 20856 Redeclaration: '%0 \'%1\' has already been declared', 20857 IllegalContinue: 'Illegal continue statement', 20858 IllegalBreak: 'Illegal break statement', 20859 IllegalReturn: 'Illegal return statement', 20860 StrictModeWith: 'Strict mode code may not include a with statement', 20861 StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', 20862 StrictVarName: 'Variable name may not be eval or arguments in strict mode', 20863 StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', 20864 StrictParamDupe: 'Strict mode function may not have duplicate parameter names', 20865 StrictFunctionName: 'Function name may not be eval or arguments in strict mode', 20866 StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', 20867 StrictDelete: 'Delete of an unqualified identifier in strict mode.', 20868 StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', 20869 StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', 20870 StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', 20871 StrictReservedWord: 'Use of future reserved word in strict mode', 20872 TemplateOctalLiteral: 'Octal literals are not allowed in template strings.', 20873 ParameterAfterRestParameter: 'Rest parameter must be last formal parameter', 20874 DefaultRestParameter: 'Unexpected token =', 20875 ObjectPatternAsRestParameter: 'Unexpected token {', 20876 DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals', 20877 ConstructorSpecialMethod: 'Class constructor may not be an accessor', 20878 DuplicateConstructor: 'A class may only have one constructor', 20879 StaticPrototype: 'Classes may not have static property named prototype', 20880 MissingFromClause: 'Unexpected token', 20881 NoAsAfterImportNamespace: 'Unexpected token', 20882 InvalidModuleSpecifier: 'Unexpected token', 20883 IllegalImportDeclaration: 'Unexpected token', 20884 IllegalExportDeclaration: 'Unexpected token', 20885 DuplicateBinding: 'Duplicate binding %0' 20886 }; 20887 20888 // See also tools/generate-unicode-regex.js. 20889 Regex = { 20890 // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart: 20891 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/, 20892 20893 // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart: 20894 NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ 20895 }; 20896 20897 // Ensure the condition is true, otherwise throw an error. 20898 // This is only to have a better contract semantic, i.e. another safety net 20899 // to catch a logic error. The condition shall be fulfilled in normal case. 20900 // Do NOT use this to enforce a certain condition on any user input. 20901 20902 function assert(condition, message) { 20903 /* istanbul ignore if */ 20904 if (!condition) { 20905 throw new Error('ASSERT: ' + message); 20906 } 20907 } 20908 20909 function isDecimalDigit(ch) { 20910 return (ch >= 0x30 && ch <= 0x39); // 0..9 20911 } 20912 20913 function isHexDigit(ch) { 20914 return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; 20915 } 20916 20917 function isOctalDigit(ch) { 20918 return '01234567'.indexOf(ch) >= 0; 20919 } 20920 20921 function octalToDecimal(ch) { 20922 // \0 is not octal escape sequence 20923 var octal = (ch !== '0'), code = '01234567'.indexOf(ch); 20924 20925 if (index < length && isOctalDigit(source[index])) { 20926 octal = true; 20927 code = code * 8 + '01234567'.indexOf(source[index++]); 20928 20929 // 3 digits are only allowed when string starts 20930 // with 0, 1, 2, 3 20931 if ('0123'.indexOf(ch) >= 0 && 20932 index < length && 20933 isOctalDigit(source[index])) { 20934 code = code * 8 + '01234567'.indexOf(source[index++]); 20935 } 20936 } 20937 20938 return { 20939 code: code, 20940 octal: octal 20941 }; 20942 } 20943 20944 // ECMA-262 11.2 White Space 20945 20946 function isWhiteSpace(ch) { 20947 return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || 20948 (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); 20949 } 20950 20951 // ECMA-262 11.3 Line Terminators 20952 20953 function isLineTerminator(ch) { 20954 return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); 20955 } 20956 20957 // ECMA-262 11.6 Identifier Names and Identifiers 20958 20959 function fromCodePoint(cp) { 20960 return (cp < 0x10000) ? String.fromCharCode(cp) : 20961 String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) + 20962 String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023)); 20963 } 20964 20965 function isIdentifierStart(ch) { 20966 return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) 20967 (ch >= 0x41 && ch <= 0x5A) || // A..Z 20968 (ch >= 0x61 && ch <= 0x7A) || // a..z 20969 (ch === 0x5C) || // \ (backslash) 20970 ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch))); 20971 } 20972 20973 function isIdentifierPart(ch) { 20974 return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) 20975 (ch >= 0x41 && ch <= 0x5A) || // A..Z 20976 (ch >= 0x61 && ch <= 0x7A) || // a..z 20977 (ch >= 0x30 && ch <= 0x39) || // 0..9 20978 (ch === 0x5C) || // \ (backslash) 20979 ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch))); 20980 } 20981 20982 // ECMA-262 11.6.2.2 Future Reserved Words 20983 20984 function isFutureReservedWord(id) { 20985 switch (id) { 20986 case 'enum': 20987 case 'export': 20988 case 'import': 20989 case 'super': 20990 return true; 20991 default: 20992 return false; 20993 } 20994 } 20995 20996 function isStrictModeReservedWord(id) { 20997 switch (id) { 20998 case 'implements': 20999 case 'interface': 21000 case 'package': 21001 case 'private': 21002 case 'protected': 21003 case 'public': 21004 case 'static': 21005 case 'yield': 21006 case 'let': 21007 return true; 21008 default: 21009 return false; 21010 } 21011 } 21012 21013 function isRestrictedWord(id) { 21014 return id === 'eval' || id === 'arguments'; 21015 } 21016 21017 // ECMA-262 11.6.2.1 Keywords 21018 21019 function isKeyword(id) { 21020 switch (id.length) { 21021 case 2: 21022 return (id === 'if') || (id === 'in') || (id === 'do'); 21023 case 3: 21024 return (id === 'var') || (id === 'for') || (id === 'new') || 21025 (id === 'try') || (id === 'let'); 21026 case 4: 21027 return (id === 'this') || (id === 'else') || (id === 'case') || 21028 (id === 'void') || (id === 'with') || (id === 'enum'); 21029 case 5: 21030 return (id === 'while') || (id === 'break') || (id === 'catch') || 21031 (id === 'throw') || (id === 'const') || (id === 'yield') || 21032 (id === 'class') || (id === 'super'); 21033 case 6: 21034 return (id === 'return') || (id === 'typeof') || (id === 'delete') || 21035 (id === 'switch') || (id === 'export') || (id === 'import'); 21036 case 7: 21037 return (id === 'default') || (id === 'finally') || (id === 'extends'); 21038 case 8: 21039 return (id === 'function') || (id === 'continue') || (id === 'debugger'); 21040 case 10: 21041 return (id === 'instanceof'); 21042 default: 21043 return false; 21044 } 21045 } 21046 21047 // ECMA-262 11.4 Comments 21048 21049 function addComment(type, value, start, end, loc) { 21050 var comment; 21051 21052 assert(typeof start === 'number', 'Comment must have valid position'); 21053 21054 state.lastCommentStart = start; 21055 21056 comment = { 21057 type: type, 21058 value: value 21059 }; 21060 if (extra.range) { 21061 comment.range = [start, end]; 21062 } 21063 if (extra.loc) { 21064 comment.loc = loc; 21065 } 21066 extra.comments.push(comment); 21067 if (extra.attachComment) { 21068 extra.leadingComments.push(comment); 21069 extra.trailingComments.push(comment); 21070 } 21071 if (extra.tokenize) { 21072 comment.type = comment.type + 'Comment'; 21073 if (extra.delegate) { 21074 comment = extra.delegate(comment); 21075 } 21076 extra.tokens.push(comment); 21077 } 21078 } 21079 21080 function skipSingleLineComment(offset) { 21081 var start, loc, ch, comment; 21082 21083 start = index - offset; 21084 loc = { 21085 start: { 21086 line: lineNumber, 21087 column: index - lineStart - offset 21088 } 21089 }; 21090 21091 while (index < length) { 21092 ch = source.charCodeAt(index); 21093 ++index; 21094 if (isLineTerminator(ch)) { 21095 hasLineTerminator = true; 21096 if (extra.comments) { 21097 comment = source.slice(start + offset, index - 1); 21098 loc.end = { 21099 line: lineNumber, 21100 column: index - lineStart - 1 21101 }; 21102 addComment('Line', comment, start, index - 1, loc); 21103 } 21104 if (ch === 13 && source.charCodeAt(index) === 10) { 21105 ++index; 21106 } 21107 ++lineNumber; 21108 lineStart = index; 21109 return; 21110 } 21111 } 21112 21113 if (extra.comments) { 21114 comment = source.slice(start + offset, index); 21115 loc.end = { 21116 line: lineNumber, 21117 column: index - lineStart 21118 }; 21119 addComment('Line', comment, start, index, loc); 21120 } 21121 } 21122 21123 function skipMultiLineComment() { 21124 var start, loc, ch, comment; 21125 21126 if (extra.comments) { 21127 start = index - 2; 21128 loc = { 21129 start: { 21130 line: lineNumber, 21131 column: index - lineStart - 2 21132 } 21133 }; 21134 } 21135 21136 while (index < length) { 21137 ch = source.charCodeAt(index); 21138 if (isLineTerminator(ch)) { 21139 if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) { 21140 ++index; 21141 } 21142 hasLineTerminator = true; 21143 ++lineNumber; 21144 ++index; 21145 lineStart = index; 21146 } else if (ch === 0x2A) { 21147 // Block comment ends with '*/'. 21148 if (source.charCodeAt(index + 1) === 0x2F) { 21149 ++index; 21150 ++index; 21151 if (extra.comments) { 21152 comment = source.slice(start + 2, index - 2); 21153 loc.end = { 21154 line: lineNumber, 21155 column: index - lineStart 21156 }; 21157 addComment('Block', comment, start, index, loc); 21158 } 21159 return; 21160 } 21161 ++index; 21162 } else { 21163 ++index; 21164 } 21165 } 21166 21167 // Ran off the end of the file - the whole thing is a comment 21168 if (extra.comments) { 21169 loc.end = { 21170 line: lineNumber, 21171 column: index - lineStart 21172 }; 21173 comment = source.slice(start + 2, index); 21174 addComment('Block', comment, start, index, loc); 21175 } 21176 tolerateUnexpectedToken(); 21177 } 21178 21179 function skipComment() { 21180 var ch, start; 21181 hasLineTerminator = false; 21182 21183 start = (index === 0); 21184 while (index < length) { 21185 ch = source.charCodeAt(index); 21186 21187 if (isWhiteSpace(ch)) { 21188 ++index; 21189 } else if (isLineTerminator(ch)) { 21190 hasLineTerminator = true; 21191 ++index; 21192 if (ch === 0x0D && source.charCodeAt(index) === 0x0A) { 21193 ++index; 21194 } 21195 ++lineNumber; 21196 lineStart = index; 21197 start = true; 21198 } else if (ch === 0x2F) { // U+002F is '/' 21199 ch = source.charCodeAt(index + 1); 21200 if (ch === 0x2F) { 21201 ++index; 21202 ++index; 21203 skipSingleLineComment(2); 21204 start = true; 21205 } else if (ch === 0x2A) { // U+002A is '*' 21206 ++index; 21207 ++index; 21208 skipMultiLineComment(); 21209 } else { 21210 break; 21211 } 21212 } else if (start && ch === 0x2D) { // U+002D is '-' 21213 // U+003E is '>' 21214 if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) { 21215 // '-->' is a single-line comment 21216 index += 3; 21217 skipSingleLineComment(3); 21218 } else { 21219 break; 21220 } 21221 } else if (ch === 0x3C) { // U+003C is '<' 21222 if (source.slice(index + 1, index + 4) === '!--') { 21223 ++index; // `<` 21224 ++index; // `!` 21225 ++index; // `-` 21226 ++index; // `-` 21227 skipSingleLineComment(4); 21228 } else { 21229 break; 21230 } 21231 } else { 21232 break; 21233 } 21234 } 21235 } 21236 21237 function scanHexEscape(prefix) { 21238 var i, len, ch, code = 0; 21239 21240 len = (prefix === 'u') ? 4 : 2; 21241 for (i = 0; i < len; ++i) { 21242 if (index < length && isHexDigit(source[index])) { 21243 ch = source[index++]; 21244 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); 21245 } else { 21246 return ''; 21247 } 21248 } 21249 return String.fromCharCode(code); 21250 } 21251 21252 function scanUnicodeCodePointEscape() { 21253 var ch, code; 21254 21255 ch = source[index]; 21256 code = 0; 21257 21258 // At least, one hex digit is required. 21259 if (ch === '}') { 21260 throwUnexpectedToken(); 21261 } 21262 21263 while (index < length) { 21264 ch = source[index++]; 21265 if (!isHexDigit(ch)) { 21266 break; 21267 } 21268 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); 21269 } 21270 21271 if (code > 0x10FFFF || ch !== '}') { 21272 throwUnexpectedToken(); 21273 } 21274 21275 return fromCodePoint(code); 21276 } 21277 21278 function codePointAt(i) { 21279 var cp, first, second; 21280 21281 cp = source.charCodeAt(i); 21282 if (cp >= 0xD800 && cp <= 0xDBFF) { 21283 second = source.charCodeAt(i + 1); 21284 if (second >= 0xDC00 && second <= 0xDFFF) { 21285 first = cp; 21286 cp = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; 21287 } 21288 } 21289 21290 return cp; 21291 } 21292 21293 function getComplexIdentifier() { 21294 var cp, ch, id; 21295 21296 cp = codePointAt(index); 21297 id = fromCodePoint(cp); 21298 index += id.length; 21299 21300 // '\u' (U+005C, U+0075) denotes an escaped character. 21301 if (cp === 0x5C) { 21302 if (source.charCodeAt(index) !== 0x75) { 21303 throwUnexpectedToken(); 21304 } 21305 ++index; 21306 if (source[index] === '{') { 21307 ++index; 21308 ch = scanUnicodeCodePointEscape(); 21309 } else { 21310 ch = scanHexEscape('u'); 21311 cp = ch.charCodeAt(0); 21312 if (!ch || ch === '\\' || !isIdentifierStart(cp)) { 21313 throwUnexpectedToken(); 21314 } 21315 } 21316 id = ch; 21317 } 21318 21319 while (index < length) { 21320 cp = codePointAt(index); 21321 if (!isIdentifierPart(cp)) { 21322 break; 21323 } 21324 ch = fromCodePoint(cp); 21325 id += ch; 21326 index += ch.length; 21327 21328 // '\u' (U+005C, U+0075) denotes an escaped character. 21329 if (cp === 0x5C) { 21330 id = id.substr(0, id.length - 1); 21331 if (source.charCodeAt(index) !== 0x75) { 21332 throwUnexpectedToken(); 21333 } 21334 ++index; 21335 if (source[index] === '{') { 21336 ++index; 21337 ch = scanUnicodeCodePointEscape(); 21338 } else { 21339 ch = scanHexEscape('u'); 21340 cp = ch.charCodeAt(0); 21341 if (!ch || ch === '\\' || !isIdentifierPart(cp)) { 21342 throwUnexpectedToken(); 21343 } 21344 } 21345 id += ch; 21346 } 21347 } 21348 21349 return id; 21350 } 21351 21352 function getIdentifier() { 21353 var start, ch; 21354 21355 start = index++; 21356 while (index < length) { 21357 ch = source.charCodeAt(index); 21358 if (ch === 0x5C) { 21359 // Blackslash (U+005C) marks Unicode escape sequence. 21360 index = start; 21361 return getComplexIdentifier(); 21362 } else if (ch >= 0xD800 && ch < 0xDFFF) { 21363 // Need to handle surrogate pairs. 21364 index = start; 21365 return getComplexIdentifier(); 21366 } 21367 if (isIdentifierPart(ch)) { 21368 ++index; 21369 } else { 21370 break; 21371 } 21372 } 21373 21374 return source.slice(start, index); 21375 } 21376 21377 function scanIdentifier() { 21378 var start, id, type; 21379 21380 start = index; 21381 21382 // Backslash (U+005C) starts an escaped character. 21383 id = (source.charCodeAt(index) === 0x5C) ? getComplexIdentifier() : getIdentifier(); 21384 21385 // There is no keyword or literal with only one character. 21386 // Thus, it must be an identifier. 21387 if (id.length === 1) { 21388 type = Token.Identifier; 21389 } else if (isKeyword(id)) { 21390 type = Token.Keyword; 21391 } else if (id === 'null') { 21392 type = Token.NullLiteral; 21393 } else if (id === 'true' || id === 'false') { 21394 type = Token.BooleanLiteral; 21395 } else { 21396 type = Token.Identifier; 21397 } 21398 21399 return { 21400 type: type, 21401 value: id, 21402 lineNumber: lineNumber, 21403 lineStart: lineStart, 21404 start: start, 21405 end: index 21406 }; 21407 } 21408 21409 21410 // ECMA-262 11.7 Punctuators 21411 21412 function scanPunctuator() { 21413 var token, str; 21414 21415 token = { 21416 type: Token.Punctuator, 21417 value: '', 21418 lineNumber: lineNumber, 21419 lineStart: lineStart, 21420 start: index, 21421 end: index 21422 }; 21423 21424 // Check for most common single-character punctuators. 21425 str = source[index]; 21426 switch (str) { 21427 21428 case '(': 21429 if (extra.tokenize) { 21430 extra.openParenToken = extra.tokenValues.length; 21431 } 21432 ++index; 21433 break; 21434 21435 case '{': 21436 if (extra.tokenize) { 21437 extra.openCurlyToken = extra.tokenValues.length; 21438 } 21439 state.curlyStack.push('{'); 21440 ++index; 21441 break; 21442 21443 case '.': 21444 ++index; 21445 if (source[index] === '.' && source[index + 1] === '.') { 21446 // Spread operator: ... 21447 index += 2; 21448 str = '...'; 21449 } 21450 break; 21451 21452 case '}': 21453 ++index; 21454 state.curlyStack.pop(); 21455 break; 21456 case ')': 21457 case ';': 21458 case ',': 21459 case '[': 21460 case ']': 21461 case ':': 21462 case '?': 21463 case '~': 21464 ++index; 21465 break; 21466 21467 default: 21468 // 4-character punctuator. 21469 str = source.substr(index, 4); 21470 if (str === '>>>=') { 21471 index += 4; 21472 } else { 21473 21474 // 3-character punctuators. 21475 str = str.substr(0, 3); 21476 if (str === '===' || str === '!==' || str === '>>>' || 21477 str === '<<=' || str === '>>=') { 21478 index += 3; 21479 } else { 21480 21481 // 2-character punctuators. 21482 str = str.substr(0, 2); 21483 if (str === '&&' || str === '||' || str === '==' || str === '!=' || 21484 str === '+=' || str === '-=' || str === '*=' || str === '/=' || 21485 str === '++' || str === '--' || str === '<<' || str === '>>' || 21486 str === '&=' || str === '|=' || str === '^=' || str === '%=' || 21487 str === '<=' || str === '>=' || str === '=>') { 21488 index += 2; 21489 } else { 21490 21491 // 1-character punctuators. 21492 str = source[index]; 21493 if ('<>=!+-*%&|^/'.indexOf(str) >= 0) { 21494 ++index; 21495 } 21496 } 21497 } 21498 } 21499 } 21500 21501 if (index === token.start) { 21502 throwUnexpectedToken(); 21503 } 21504 21505 token.end = index; 21506 token.value = str; 21507 return token; 21508 } 21509 21510 // ECMA-262 11.8.3 Numeric Literals 21511 21512 function scanHexLiteral(start) { 21513 var number = ''; 21514 21515 while (index < length) { 21516 if (!isHexDigit(source[index])) { 21517 break; 21518 } 21519 number += source[index++]; 21520 } 21521 21522 if (number.length === 0) { 21523 throwUnexpectedToken(); 21524 } 21525 21526 if (isIdentifierStart(source.charCodeAt(index))) { 21527 throwUnexpectedToken(); 21528 } 21529 21530 return { 21531 type: Token.NumericLiteral, 21532 value: parseInt('0x' + number, 16), 21533 lineNumber: lineNumber, 21534 lineStart: lineStart, 21535 start: start, 21536 end: index 21537 }; 21538 } 21539 21540 function scanBinaryLiteral(start) { 21541 var ch, number; 21542 21543 number = ''; 21544 21545 while (index < length) { 21546 ch = source[index]; 21547 if (ch !== '0' && ch !== '1') { 21548 break; 21549 } 21550 number += source[index++]; 21551 } 21552 21553 if (number.length === 0) { 21554 // only 0b or 0B 21555 throwUnexpectedToken(); 21556 } 21557 21558 if (index < length) { 21559 ch = source.charCodeAt(index); 21560 /* istanbul ignore else */ 21561 if (isIdentifierStart(ch) || isDecimalDigit(ch)) { 21562 throwUnexpectedToken(); 21563 } 21564 } 21565 21566 return { 21567 type: Token.NumericLiteral, 21568 value: parseInt(number, 2), 21569 lineNumber: lineNumber, 21570 lineStart: lineStart, 21571 start: start, 21572 end: index 21573 }; 21574 } 21575 21576 function scanOctalLiteral(prefix, start) { 21577 var number, octal; 21578 21579 if (isOctalDigit(prefix)) { 21580 octal = true; 21581 number = '0' + source[index++]; 21582 } else { 21583 octal = false; 21584 ++index; 21585 number = ''; 21586 } 21587 21588 while (index < length) { 21589 if (!isOctalDigit(source[index])) { 21590 break; 21591 } 21592 number += source[index++]; 21593 } 21594 21595 if (!octal && number.length === 0) { 21596 // only 0o or 0O 21597 throwUnexpectedToken(); 21598 } 21599 21600 if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { 21601 throwUnexpectedToken(); 21602 } 21603 21604 return { 21605 type: Token.NumericLiteral, 21606 value: parseInt(number, 8), 21607 octal: octal, 21608 lineNumber: lineNumber, 21609 lineStart: lineStart, 21610 start: start, 21611 end: index 21612 }; 21613 } 21614 21615 function isImplicitOctalLiteral() { 21616 var i, ch; 21617 21618 // Implicit octal, unless there is a non-octal digit. 21619 // (Annex B.1.1 on Numeric Literals) 21620 for (i = index + 1; i < length; ++i) { 21621 ch = source[i]; 21622 if (ch === '8' || ch === '9') { 21623 return false; 21624 } 21625 if (!isOctalDigit(ch)) { 21626 return true; 21627 } 21628 } 21629 21630 return true; 21631 } 21632 21633 function scanNumericLiteral() { 21634 var number, start, ch; 21635 21636 ch = source[index]; 21637 assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), 21638 'Numeric literal must start with a decimal digit or a decimal point'); 21639 21640 start = index; 21641 number = ''; 21642 if (ch !== '.') { 21643 number = source[index++]; 21644 ch = source[index]; 21645 21646 // Hex number starts with '0x'. 21647 // Octal number starts with '0'. 21648 // Octal number in ES6 starts with '0o'. 21649 // Binary number in ES6 starts with '0b'. 21650 if (number === '0') { 21651 if (ch === 'x' || ch === 'X') { 21652 ++index; 21653 return scanHexLiteral(start); 21654 } 21655 if (ch === 'b' || ch === 'B') { 21656 ++index; 21657 return scanBinaryLiteral(start); 21658 } 21659 if (ch === 'o' || ch === 'O') { 21660 return scanOctalLiteral(ch, start); 21661 } 21662 21663 if (isOctalDigit(ch)) { 21664 if (isImplicitOctalLiteral()) { 21665 return scanOctalLiteral(ch, start); 21666 } 21667 } 21668 } 21669 21670 while (isDecimalDigit(source.charCodeAt(index))) { 21671 number += source[index++]; 21672 } 21673 ch = source[index]; 21674 } 21675 21676 if (ch === '.') { 21677 number += source[index++]; 21678 while (isDecimalDigit(source.charCodeAt(index))) { 21679 number += source[index++]; 21680 } 21681 ch = source[index]; 21682 } 21683 21684 if (ch === 'e' || ch === 'E') { 21685 number += source[index++]; 21686 21687 ch = source[index]; 21688 if (ch === '+' || ch === '-') { 21689 number += source[index++]; 21690 } 21691 if (isDecimalDigit(source.charCodeAt(index))) { 21692 while (isDecimalDigit(source.charCodeAt(index))) { 21693 number += source[index++]; 21694 } 21695 } else { 21696 throwUnexpectedToken(); 21697 } 21698 } 21699 21700 if (isIdentifierStart(source.charCodeAt(index))) { 21701 throwUnexpectedToken(); 21702 } 21703 21704 return { 21705 type: Token.NumericLiteral, 21706 value: parseFloat(number), 21707 lineNumber: lineNumber, 21708 lineStart: lineStart, 21709 start: start, 21710 end: index 21711 }; 21712 } 21713 21714 // ECMA-262 11.8.4 String Literals 21715 21716 function scanStringLiteral() { 21717 var str = '', quote, start, ch, unescaped, octToDec, octal = false; 21718 21719 quote = source[index]; 21720 assert((quote === '\'' || quote === '"'), 21721 'String literal must starts with a quote'); 21722 21723 start = index; 21724 ++index; 21725 21726 while (index < length) { 21727 ch = source[index++]; 21728 21729 if (ch === quote) { 21730 quote = ''; 21731 break; 21732 } else if (ch === '\\') { 21733 ch = source[index++]; 21734 if (!ch || !isLineTerminator(ch.charCodeAt(0))) { 21735 switch (ch) { 21736 case 'u': 21737 case 'x': 21738 if (source[index] === '{') { 21739 ++index; 21740 str += scanUnicodeCodePointEscape(); 21741 } else { 21742 unescaped = scanHexEscape(ch); 21743 if (!unescaped) { 21744 throw throwUnexpectedToken(); 21745 } 21746 str += unescaped; 21747 } 21748 break; 21749 case 'n': 21750 str += '\n'; 21751 break; 21752 case 'r': 21753 str += '\r'; 21754 break; 21755 case 't': 21756 str += '\t'; 21757 break; 21758 case 'b': 21759 str += '\b'; 21760 break; 21761 case 'f': 21762 str += '\f'; 21763 break; 21764 case 'v': 21765 str += '\x0B'; 21766 break; 21767 case '8': 21768 case '9': 21769 str += ch; 21770 tolerateUnexpectedToken(); 21771 break; 21772 21773 default: 21774 if (isOctalDigit(ch)) { 21775 octToDec = octalToDecimal(ch); 21776 21777 octal = octToDec.octal || octal; 21778 str += String.fromCharCode(octToDec.code); 21779 } else { 21780 str += ch; 21781 } 21782 break; 21783 } 21784 } else { 21785 ++lineNumber; 21786 if (ch === '\r' && source[index] === '\n') { 21787 ++index; 21788 } 21789 lineStart = index; 21790 } 21791 } else if (isLineTerminator(ch.charCodeAt(0))) { 21792 break; 21793 } else { 21794 str += ch; 21795 } 21796 } 21797 21798 if (quote !== '') { 21799 index = start; 21800 throwUnexpectedToken(); 21801 } 21802 21803 return { 21804 type: Token.StringLiteral, 21805 value: str, 21806 octal: octal, 21807 lineNumber: startLineNumber, 21808 lineStart: startLineStart, 21809 start: start, 21810 end: index 21811 }; 21812 } 21813 21814 // ECMA-262 11.8.6 Template Literal Lexical Components 21815 21816 function scanTemplate() { 21817 var cooked = '', ch, start, rawOffset, terminated, head, tail, restore, unescaped; 21818 21819 terminated = false; 21820 tail = false; 21821 start = index; 21822 head = (source[index] === '`'); 21823 rawOffset = 2; 21824 21825 ++index; 21826 21827 while (index < length) { 21828 ch = source[index++]; 21829 if (ch === '`') { 21830 rawOffset = 1; 21831 tail = true; 21832 terminated = true; 21833 break; 21834 } else if (ch === '$') { 21835 if (source[index] === '{') { 21836 state.curlyStack.push('${'); 21837 ++index; 21838 terminated = true; 21839 break; 21840 } 21841 cooked += ch; 21842 } else if (ch === '\\') { 21843 ch = source[index++]; 21844 if (!isLineTerminator(ch.charCodeAt(0))) { 21845 switch (ch) { 21846 case 'n': 21847 cooked += '\n'; 21848 break; 21849 case 'r': 21850 cooked += '\r'; 21851 break; 21852 case 't': 21853 cooked += '\t'; 21854 break; 21855 case 'u': 21856 case 'x': 21857 if (source[index] === '{') { 21858 ++index; 21859 cooked += scanUnicodeCodePointEscape(); 21860 } else { 21861 restore = index; 21862 unescaped = scanHexEscape(ch); 21863 if (unescaped) { 21864 cooked += unescaped; 21865 } else { 21866 index = restore; 21867 cooked += ch; 21868 } 21869 } 21870 break; 21871 case 'b': 21872 cooked += '\b'; 21873 break; 21874 case 'f': 21875 cooked += '\f'; 21876 break; 21877 case 'v': 21878 cooked += '\v'; 21879 break; 21880 21881 default: 21882 if (ch === '0') { 21883 if (isDecimalDigit(source.charCodeAt(index))) { 21884 // Illegal: \01 \02 and so on 21885 throwError(Messages.TemplateOctalLiteral); 21886 } 21887 cooked += '\0'; 21888 } else if (isOctalDigit(ch)) { 21889 // Illegal: \1 \2 21890 throwError(Messages.TemplateOctalLiteral); 21891 } else { 21892 cooked += ch; 21893 } 21894 break; 21895 } 21896 } else { 21897 ++lineNumber; 21898 if (ch === '\r' && source[index] === '\n') { 21899 ++index; 21900 } 21901 lineStart = index; 21902 } 21903 } else if (isLineTerminator(ch.charCodeAt(0))) { 21904 ++lineNumber; 21905 if (ch === '\r' && source[index] === '\n') { 21906 ++index; 21907 } 21908 lineStart = index; 21909 cooked += '\n'; 21910 } else { 21911 cooked += ch; 21912 } 21913 } 21914 21915 if (!terminated) { 21916 throwUnexpectedToken(); 21917 } 21918 21919 if (!head) { 21920 state.curlyStack.pop(); 21921 } 21922 21923 return { 21924 type: Token.Template, 21925 value: { 21926 cooked: cooked, 21927 raw: source.slice(start + 1, index - rawOffset) 21928 }, 21929 head: head, 21930 tail: tail, 21931 lineNumber: lineNumber, 21932 lineStart: lineStart, 21933 start: start, 21934 end: index 21935 }; 21936 } 21937 21938 // ECMA-262 11.8.5 Regular Expression Literals 21939 21940 function testRegExp(pattern, flags) { 21941 // The BMP character to use as a replacement for astral symbols when 21942 // translating an ES6 "u"-flagged pattern to an ES5-compatible 21943 // approximation. 21944 // Note: replacing with '\uFFFF' enables false positives in unlikely 21945 // scenarios. For example, `[\u{1044f}-\u{10440}]` is an invalid 21946 // pattern that would not be detected by this substitution. 21947 var astralSubstitute = '\uFFFF', 21948 tmp = pattern; 21949 21950 if (flags.indexOf('u') >= 0) { 21951 tmp = tmp 21952 // Replace every Unicode escape sequence with the equivalent 21953 // BMP character or a constant ASCII code point in the case of 21954 // astral symbols. (See the above note on `astralSubstitute` 21955 // for more information.) 21956 .replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function ($0, $1, $2) { 21957 var codePoint = parseInt($1 || $2, 16); 21958 if (codePoint > 0x10FFFF) { 21959 throwUnexpectedToken(null, Messages.InvalidRegExp); 21960 } 21961 if (codePoint <= 0xFFFF) { 21962 return String.fromCharCode(codePoint); 21963 } 21964 return astralSubstitute; 21965 }) 21966 // Replace each paired surrogate with a single ASCII symbol to 21967 // avoid throwing on regular expressions that are only valid in 21968 // combination with the "u" flag. 21969 .replace( 21970 /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 21971 astralSubstitute 21972 ); 21973 } 21974 21975 // First, detect invalid regular expressions. 21976 try { 21977 RegExp(tmp); 21978 } catch (e) { 21979 throwUnexpectedToken(null, Messages.InvalidRegExp); 21980 } 21981 21982 // Return a regular expression object for this pattern-flag pair, or 21983 // `null` in case the current environment doesn't support the flags it 21984 // uses. 21985 try { 21986 return new RegExp(pattern, flags); 21987 } catch (exception) { 21988 /* istanbul ignore next */ 21989 return null; 21990 } 21991 } 21992 21993 function scanRegExpBody() { 21994 var ch, str, classMarker, terminated, body; 21995 21996 ch = source[index]; 21997 assert(ch === '/', 'Regular expression literal must start with a slash'); 21998 str = source[index++]; 21999 22000 classMarker = false; 22001 terminated = false; 22002 while (index < length) { 22003 ch = source[index++]; 22004 str += ch; 22005 if (ch === '\\') { 22006 ch = source[index++]; 22007 // ECMA-262 7.8.5 22008 if (isLineTerminator(ch.charCodeAt(0))) { 22009 throwUnexpectedToken(null, Messages.UnterminatedRegExp); 22010 } 22011 str += ch; 22012 } else if (isLineTerminator(ch.charCodeAt(0))) { 22013 throwUnexpectedToken(null, Messages.UnterminatedRegExp); 22014 } else if (classMarker) { 22015 if (ch === ']') { 22016 classMarker = false; 22017 } 22018 } else { 22019 if (ch === '/') { 22020 terminated = true; 22021 break; 22022 } else if (ch === '[') { 22023 classMarker = true; 22024 } 22025 } 22026 } 22027 22028 if (!terminated) { 22029 throwUnexpectedToken(null, Messages.UnterminatedRegExp); 22030 } 22031 22032 // Exclude leading and trailing slash. 22033 body = str.substr(1, str.length - 2); 22034 return { 22035 value: body, 22036 literal: str 22037 }; 22038 } 22039 22040 function scanRegExpFlags() { 22041 var ch, str, flags, restore; 22042 22043 str = ''; 22044 flags = ''; 22045 while (index < length) { 22046 ch = source[index]; 22047 if (!isIdentifierPart(ch.charCodeAt(0))) { 22048 break; 22049 } 22050 22051 ++index; 22052 if (ch === '\\' && index < length) { 22053 ch = source[index]; 22054 if (ch === 'u') { 22055 ++index; 22056 restore = index; 22057 ch = scanHexEscape('u'); 22058 if (ch) { 22059 flags += ch; 22060 for (str += '\\u'; restore < index; ++restore) { 22061 str += source[restore]; 22062 } 22063 } else { 22064 index = restore; 22065 flags += 'u'; 22066 str += '\\u'; 22067 } 22068 tolerateUnexpectedToken(); 22069 } else { 22070 str += '\\'; 22071 tolerateUnexpectedToken(); 22072 } 22073 } else { 22074 flags += ch; 22075 str += ch; 22076 } 22077 } 22078 22079 return { 22080 value: flags, 22081 literal: str 22082 }; 22083 } 22084 22085 function scanRegExp() { 22086 var start, body, flags, value; 22087 scanning = true; 22088 22089 lookahead = null; 22090 skipComment(); 22091 start = index; 22092 22093 body = scanRegExpBody(); 22094 flags = scanRegExpFlags(); 22095 value = testRegExp(body.value, flags.value); 22096 scanning = false; 22097 if (extra.tokenize) { 22098 return { 22099 type: Token.RegularExpression, 22100 value: value, 22101 regex: { 22102 pattern: body.value, 22103 flags: flags.value 22104 }, 22105 lineNumber: lineNumber, 22106 lineStart: lineStart, 22107 start: start, 22108 end: index 22109 }; 22110 } 22111 22112 return { 22113 literal: body.literal + flags.literal, 22114 value: value, 22115 regex: { 22116 pattern: body.value, 22117 flags: flags.value 22118 }, 22119 start: start, 22120 end: index 22121 }; 22122 } 22123 22124 function collectRegex() { 22125 var pos, loc, regex, token; 22126 22127 skipComment(); 22128 22129 pos = index; 22130 loc = { 22131 start: { 22132 line: lineNumber, 22133 column: index - lineStart 22134 } 22135 }; 22136 22137 regex = scanRegExp(); 22138 22139 loc.end = { 22140 line: lineNumber, 22141 column: index - lineStart 22142 }; 22143 22144 /* istanbul ignore next */ 22145 if (!extra.tokenize) { 22146 // Pop the previous token, which is likely '/' or '/=' 22147 if (extra.tokens.length > 0) { 22148 token = extra.tokens[extra.tokens.length - 1]; 22149 if (token.range[0] === pos && token.type === 'Punctuator') { 22150 if (token.value === '/' || token.value === '/=') { 22151 extra.tokens.pop(); 22152 } 22153 } 22154 } 22155 22156 extra.tokens.push({ 22157 type: 'RegularExpression', 22158 value: regex.literal, 22159 regex: regex.regex, 22160 range: [pos, index], 22161 loc: loc 22162 }); 22163 } 22164 22165 return regex; 22166 } 22167 22168 function isIdentifierName(token) { 22169 return token.type === Token.Identifier || 22170 token.type === Token.Keyword || 22171 token.type === Token.BooleanLiteral || 22172 token.type === Token.NullLiteral; 22173 } 22174 22175 // Using the following algorithm: 22176 // https://github.com/mozilla/sweet.js/wiki/design 22177 22178 function advanceSlash() { 22179 var regex, previous, check; 22180 22181 function testKeyword(value) { 22182 return value && (value.length > 1) && (value[0] >= 'a') && (value[0] <= 'z'); 22183 } 22184 22185 previous = extra.tokenValues[extra.tokenValues.length - 1]; 22186 regex = (previous !== null); 22187 22188 switch (previous) { 22189 case 'this': 22190 case ']': 22191 regex = false; 22192 break; 22193 22194 case ')': 22195 check = extra.tokenValues[extra.openParenToken - 1]; 22196 regex = (check === 'if' || check === 'while' || check === 'for' || check === 'with'); 22197 break; 22198 22199 case '}': 22200 // Dividing a function by anything makes little sense, 22201 // but we have to check for that. 22202 regex = false; 22203 if (testKeyword(extra.tokenValues[extra.openCurlyToken - 3])) { 22204 // Anonymous function, e.g. function(){} /42 22205 check = extra.tokenValues[extra.openCurlyToken - 4]; 22206 regex = check ? (FnExprTokens.indexOf(check) < 0) : false; 22207 } else if (testKeyword(extra.tokenValues[extra.openCurlyToken - 4])) { 22208 // Named function, e.g. function f(){} /42/ 22209 check = extra.tokenValues[extra.openCurlyToken - 5]; 22210 regex = check ? (FnExprTokens.indexOf(check) < 0) : true; 22211 } 22212 } 22213 22214 return regex ? collectRegex() : scanPunctuator(); 22215 } 22216 22217 function advance() { 22218 var cp, token; 22219 22220 if (index >= length) { 22221 return { 22222 type: Token.EOF, 22223 lineNumber: lineNumber, 22224 lineStart: lineStart, 22225 start: index, 22226 end: index 22227 }; 22228 } 22229 22230 cp = source.charCodeAt(index); 22231 22232 if (isIdentifierStart(cp)) { 22233 token = scanIdentifier(); 22234 if (strict && isStrictModeReservedWord(token.value)) { 22235 token.type = Token.Keyword; 22236 } 22237 return token; 22238 } 22239 22240 // Very common: ( and ) and ; 22241 if (cp === 0x28 || cp === 0x29 || cp === 0x3B) { 22242 return scanPunctuator(); 22243 } 22244 22245 // String literal starts with single quote (U+0027) or double quote (U+0022). 22246 if (cp === 0x27 || cp === 0x22) { 22247 return scanStringLiteral(); 22248 } 22249 22250 // Dot (.) U+002E can also start a floating-point number, hence the need 22251 // to check the next character. 22252 if (cp === 0x2E) { 22253 if (isDecimalDigit(source.charCodeAt(index + 1))) { 22254 return scanNumericLiteral(); 22255 } 22256 return scanPunctuator(); 22257 } 22258 22259 if (isDecimalDigit(cp)) { 22260 return scanNumericLiteral(); 22261 } 22262 22263 // Slash (/) U+002F can also start a regex. 22264 if (extra.tokenize && cp === 0x2F) { 22265 return advanceSlash(); 22266 } 22267 22268 // Template literals start with ` (U+0060) for template head 22269 // or } (U+007D) for template middle or template tail. 22270 if (cp === 0x60 || (cp === 0x7D && state.curlyStack[state.curlyStack.length - 1] === '${')) { 22271 return scanTemplate(); 22272 } 22273 22274 // Possible identifier start in a surrogate pair. 22275 if (cp >= 0xD800 && cp < 0xDFFF) { 22276 cp = codePointAt(index); 22277 if (isIdentifierStart(cp)) { 22278 return scanIdentifier(); 22279 } 22280 } 22281 22282 return scanPunctuator(); 22283 } 22284 22285 function collectToken() { 22286 var loc, token, value, entry; 22287 22288 loc = { 22289 start: { 22290 line: lineNumber, 22291 column: index - lineStart 22292 } 22293 }; 22294 22295 token = advance(); 22296 loc.end = { 22297 line: lineNumber, 22298 column: index - lineStart 22299 }; 22300 22301 if (token.type !== Token.EOF) { 22302 value = source.slice(token.start, token.end); 22303 entry = { 22304 type: TokenName[token.type], 22305 value: value, 22306 range: [token.start, token.end], 22307 loc: loc 22308 }; 22309 if (token.regex) { 22310 entry.regex = { 22311 pattern: token.regex.pattern, 22312 flags: token.regex.flags 22313 }; 22314 } 22315 if (extra.tokenValues) { 22316 extra.tokenValues.push((entry.type === 'Punctuator' || entry.type === 'Keyword') ? entry.value : null); 22317 } 22318 if (extra.tokenize) { 22319 if (!extra.range) { 22320 delete entry.range; 22321 } 22322 if (!extra.loc) { 22323 delete entry.loc; 22324 } 22325 if (extra.delegate) { 22326 entry = extra.delegate(entry); 22327 } 22328 } 22329 extra.tokens.push(entry); 22330 } 22331 22332 return token; 22333 } 22334 22335 function lex() { 22336 var token; 22337 scanning = true; 22338 22339 lastIndex = index; 22340 lastLineNumber = lineNumber; 22341 lastLineStart = lineStart; 22342 22343 skipComment(); 22344 22345 token = lookahead; 22346 22347 startIndex = index; 22348 startLineNumber = lineNumber; 22349 startLineStart = lineStart; 22350 22351 lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); 22352 scanning = false; 22353 return token; 22354 } 22355 22356 function peek() { 22357 scanning = true; 22358 22359 skipComment(); 22360 22361 lastIndex = index; 22362 lastLineNumber = lineNumber; 22363 lastLineStart = lineStart; 22364 22365 startIndex = index; 22366 startLineNumber = lineNumber; 22367 startLineStart = lineStart; 22368 22369 lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); 22370 scanning = false; 22371 } 22372 22373 function Position() { 22374 this.line = startLineNumber; 22375 this.column = startIndex - startLineStart; 22376 } 22377 22378 function SourceLocation() { 22379 this.start = new Position(); 22380 this.end = null; 22381 } 22382 22383 function WrappingSourceLocation(startToken) { 22384 this.start = { 22385 line: startToken.lineNumber, 22386 column: startToken.start - startToken.lineStart 22387 }; 22388 this.end = null; 22389 } 22390 22391 function Node() { 22392 if (extra.range) { 22393 this.range = [startIndex, 0]; 22394 } 22395 if (extra.loc) { 22396 this.loc = new SourceLocation(); 22397 } 22398 } 22399 22400 function WrappingNode(startToken) { 22401 if (extra.range) { 22402 this.range = [startToken.start, 0]; 22403 } 22404 if (extra.loc) { 22405 this.loc = new WrappingSourceLocation(startToken); 22406 } 22407 } 22408 22409 WrappingNode.prototype = Node.prototype = { 22410 22411 processComment: function () { 22412 var lastChild, 22413 innerComments, 22414 leadingComments, 22415 trailingComments, 22416 bottomRight = extra.bottomRightStack, 22417 i, 22418 comment, 22419 last = bottomRight[bottomRight.length - 1]; 22420 22421 if (this.type === Syntax.Program) { 22422 if (this.body.length > 0) { 22423 return; 22424 } 22425 } 22426 /** 22427 * patch innnerComments for properties empty block 22428 * `function a() {/** comments **\/}` 22429 */ 22430 22431 if (this.type === Syntax.BlockStatement && this.body.length === 0) { 22432 innerComments = []; 22433 for (i = extra.leadingComments.length - 1; i >= 0; --i) { 22434 comment = extra.leadingComments[i]; 22435 if (this.range[1] >= comment.range[1]) { 22436 innerComments.unshift(comment); 22437 extra.leadingComments.splice(i, 1); 22438 extra.trailingComments.splice(i, 1); 22439 } 22440 } 22441 if (innerComments.length) { 22442 this.innerComments = innerComments; 22443 //bottomRight.push(this); 22444 return; 22445 } 22446 } 22447 22448 if (extra.trailingComments.length > 0) { 22449 trailingComments = []; 22450 for (i = extra.trailingComments.length - 1; i >= 0; --i) { 22451 comment = extra.trailingComments[i]; 22452 if (comment.range[0] >= this.range[1]) { 22453 trailingComments.unshift(comment); 22454 extra.trailingComments.splice(i, 1); 22455 } 22456 } 22457 extra.trailingComments = []; 22458 } else { 22459 if (last && last.trailingComments && last.trailingComments[0].range[0] >= this.range[1]) { 22460 trailingComments = last.trailingComments; 22461 delete last.trailingComments; 22462 } 22463 } 22464 22465 // Eating the stack. 22466 while (last && last.range[0] >= this.range[0]) { 22467 lastChild = bottomRight.pop(); 22468 last = bottomRight[bottomRight.length - 1]; 22469 } 22470 22471 if (lastChild) { 22472 if (lastChild.leadingComments) { 22473 leadingComments = []; 22474 for (i = lastChild.leadingComments.length - 1; i >= 0; --i) { 22475 comment = lastChild.leadingComments[i]; 22476 if (comment.range[1] <= this.range[0]) { 22477 leadingComments.unshift(comment); 22478 lastChild.leadingComments.splice(i, 1); 22479 } 22480 } 22481 22482 if (!lastChild.leadingComments.length) { 22483 lastChild.leadingComments = undefined; 22484 } 22485 } 22486 } else if (extra.leadingComments.length > 0) { 22487 leadingComments = []; 22488 for (i = extra.leadingComments.length - 1; i >= 0; --i) { 22489 comment = extra.leadingComments[i]; 22490 if (comment.range[1] <= this.range[0]) { 22491 leadingComments.unshift(comment); 22492 extra.leadingComments.splice(i, 1); 22493 } 22494 } 22495 } 22496 22497 22498 if (leadingComments && leadingComments.length > 0) { 22499 this.leadingComments = leadingComments; 22500 } 22501 if (trailingComments && trailingComments.length > 0) { 22502 this.trailingComments = trailingComments; 22503 } 22504 22505 bottomRight.push(this); 22506 }, 22507 22508 finish: function () { 22509 if (extra.range) { 22510 this.range[1] = lastIndex; 22511 } 22512 if (extra.loc) { 22513 this.loc.end = { 22514 line: lastLineNumber, 22515 column: lastIndex - lastLineStart 22516 }; 22517 if (extra.source) { 22518 this.loc.source = extra.source; 22519 } 22520 } 22521 22522 if (extra.attachComment) { 22523 this.processComment(); 22524 } 22525 }, 22526 22527 finishArrayExpression: function (elements) { 22528 this.type = Syntax.ArrayExpression; 22529 this.elements = elements; 22530 this.finish(); 22531 return this; 22532 }, 22533 22534 finishArrayPattern: function (elements) { 22535 this.type = Syntax.ArrayPattern; 22536 this.elements = elements; 22537 this.finish(); 22538 return this; 22539 }, 22540 22541 finishArrowFunctionExpression: function (params, defaults, body, expression) { 22542 this.type = Syntax.ArrowFunctionExpression; 22543 this.id = null; 22544 this.params = params; 22545 this.defaults = defaults; 22546 this.body = body; 22547 this.generator = false; 22548 this.expression = expression; 22549 this.finish(); 22550 return this; 22551 }, 22552 22553 finishAssignmentExpression: function (operator, left, right) { 22554 this.type = Syntax.AssignmentExpression; 22555 this.operator = operator; 22556 this.left = left; 22557 this.right = right; 22558 this.finish(); 22559 return this; 22560 }, 22561 22562 finishAssignmentPattern: function (left, right) { 22563 this.type = Syntax.AssignmentPattern; 22564 this.left = left; 22565 this.right = right; 22566 this.finish(); 22567 return this; 22568 }, 22569 22570 finishBinaryExpression: function (operator, left, right) { 22571 this.type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : Syntax.BinaryExpression; 22572 this.operator = operator; 22573 this.left = left; 22574 this.right = right; 22575 this.finish(); 22576 return this; 22577 }, 22578 22579 finishBlockStatement: function (body) { 22580 this.type = Syntax.BlockStatement; 22581 this.body = body; 22582 this.finish(); 22583 return this; 22584 }, 22585 22586 finishBreakStatement: function (label) { 22587 this.type = Syntax.BreakStatement; 22588 this.label = label; 22589 this.finish(); 22590 return this; 22591 }, 22592 22593 finishCallExpression: function (callee, args) { 22594 this.type = Syntax.CallExpression; 22595 this.callee = callee; 22596 this.arguments = args; 22597 this.finish(); 22598 return this; 22599 }, 22600 22601 finishCatchClause: function (param, body) { 22602 this.type = Syntax.CatchClause; 22603 this.param = param; 22604 this.body = body; 22605 this.finish(); 22606 return this; 22607 }, 22608 22609 finishClassBody: function (body) { 22610 this.type = Syntax.ClassBody; 22611 this.body = body; 22612 this.finish(); 22613 return this; 22614 }, 22615 22616 finishClassDeclaration: function (id, superClass, body) { 22617 this.type = Syntax.ClassDeclaration; 22618 this.id = id; 22619 this.superClass = superClass; 22620 this.body = body; 22621 this.finish(); 22622 return this; 22623 }, 22624 22625 finishClassExpression: function (id, superClass, body) { 22626 this.type = Syntax.ClassExpression; 22627 this.id = id; 22628 this.superClass = superClass; 22629 this.body = body; 22630 this.finish(); 22631 return this; 22632 }, 22633 22634 finishConditionalExpression: function (test, consequent, alternate) { 22635 this.type = Syntax.ConditionalExpression; 22636 this.test = test; 22637 this.consequent = consequent; 22638 this.alternate = alternate; 22639 this.finish(); 22640 return this; 22641 }, 22642 22643 finishContinueStatement: function (label) { 22644 this.type = Syntax.ContinueStatement; 22645 this.label = label; 22646 this.finish(); 22647 return this; 22648 }, 22649 22650 finishDebuggerStatement: function () { 22651 this.type = Syntax.DebuggerStatement; 22652 this.finish(); 22653 return this; 22654 }, 22655 22656 finishDoWhileStatement: function (body, test) { 22657 this.type = Syntax.DoWhileStatement; 22658 this.body = body; 22659 this.test = test; 22660 this.finish(); 22661 return this; 22662 }, 22663 22664 finishEmptyStatement: function () { 22665 this.type = Syntax.EmptyStatement; 22666 this.finish(); 22667 return this; 22668 }, 22669 22670 finishExpressionStatement: function (expression) { 22671 this.type = Syntax.ExpressionStatement; 22672 this.expression = expression; 22673 this.finish(); 22674 return this; 22675 }, 22676 22677 finishForStatement: function (init, test, update, body) { 22678 this.type = Syntax.ForStatement; 22679 this.init = init; 22680 this.test = test; 22681 this.update = update; 22682 this.body = body; 22683 this.finish(); 22684 return this; 22685 }, 22686 22687 finishForOfStatement: function (left, right, body) { 22688 this.type = Syntax.ForOfStatement; 22689 this.left = left; 22690 this.right = right; 22691 this.body = body; 22692 this.finish(); 22693 return this; 22694 }, 22695 22696 finishForInStatement: function (left, right, body) { 22697 this.type = Syntax.ForInStatement; 22698 this.left = left; 22699 this.right = right; 22700 this.body = body; 22701 this.each = false; 22702 this.finish(); 22703 return this; 22704 }, 22705 22706 finishFunctionDeclaration: function (id, params, defaults, body, generator) { 22707 this.type = Syntax.FunctionDeclaration; 22708 this.id = id; 22709 this.params = params; 22710 this.defaults = defaults; 22711 this.body = body; 22712 this.generator = generator; 22713 this.expression = false; 22714 this.finish(); 22715 return this; 22716 }, 22717 22718 finishFunctionExpression: function (id, params, defaults, body, generator) { 22719 this.type = Syntax.FunctionExpression; 22720 this.id = id; 22721 this.params = params; 22722 this.defaults = defaults; 22723 this.body = body; 22724 this.generator = generator; 22725 this.expression = false; 22726 this.finish(); 22727 return this; 22728 }, 22729 22730 finishIdentifier: function (name) { 22731 this.type = Syntax.Identifier; 22732 this.name = name; 22733 this.finish(); 22734 return this; 22735 }, 22736 22737 finishIfStatement: function (test, consequent, alternate) { 22738 this.type = Syntax.IfStatement; 22739 this.test = test; 22740 this.consequent = consequent; 22741 this.alternate = alternate; 22742 this.finish(); 22743 return this; 22744 }, 22745 22746 finishLabeledStatement: function (label, body) { 22747 this.type = Syntax.LabeledStatement; 22748 this.label = label; 22749 this.body = body; 22750 this.finish(); 22751 return this; 22752 }, 22753 22754 finishLiteral: function (token) { 22755 this.type = Syntax.Literal; 22756 this.value = token.value; 22757 this.raw = source.slice(token.start, token.end); 22758 if (token.regex) { 22759 this.regex = token.regex; 22760 } 22761 this.finish(); 22762 return this; 22763 }, 22764 22765 finishMemberExpression: function (accessor, object, property) { 22766 this.type = Syntax.MemberExpression; 22767 this.computed = accessor === '['; 22768 this.object = object; 22769 this.property = property; 22770 this.finish(); 22771 return this; 22772 }, 22773 22774 finishMetaProperty: function (meta, property) { 22775 this.type = Syntax.MetaProperty; 22776 this.meta = meta; 22777 this.property = property; 22778 this.finish(); 22779 return this; 22780 }, 22781 22782 finishNewExpression: function (callee, args) { 22783 this.type = Syntax.NewExpression; 22784 this.callee = callee; 22785 this.arguments = args; 22786 this.finish(); 22787 return this; 22788 }, 22789 22790 finishObjectExpression: function (properties) { 22791 this.type = Syntax.ObjectExpression; 22792 this.properties = properties; 22793 this.finish(); 22794 return this; 22795 }, 22796 22797 finishObjectPattern: function (properties) { 22798 this.type = Syntax.ObjectPattern; 22799 this.properties = properties; 22800 this.finish(); 22801 return this; 22802 }, 22803 22804 finishPostfixExpression: function (operator, argument) { 22805 this.type = Syntax.UpdateExpression; 22806 this.operator = operator; 22807 this.argument = argument; 22808 this.prefix = false; 22809 this.finish(); 22810 return this; 22811 }, 22812 22813 finishProgram: function (body, sourceType) { 22814 this.type = Syntax.Program; 22815 this.body = body; 22816 this.sourceType = sourceType; 22817 this.finish(); 22818 return this; 22819 }, 22820 22821 finishProperty: function (kind, key, computed, value, method, shorthand) { 22822 this.type = Syntax.Property; 22823 this.key = key; 22824 this.computed = computed; 22825 this.value = value; 22826 this.kind = kind; 22827 this.method = method; 22828 this.shorthand = shorthand; 22829 this.finish(); 22830 return this; 22831 }, 22832 22833 finishRestElement: function (argument) { 22834 this.type = Syntax.RestElement; 22835 this.argument = argument; 22836 this.finish(); 22837 return this; 22838 }, 22839 22840 finishReturnStatement: function (argument) { 22841 this.type = Syntax.ReturnStatement; 22842 this.argument = argument; 22843 this.finish(); 22844 return this; 22845 }, 22846 22847 finishSequenceExpression: function (expressions) { 22848 this.type = Syntax.SequenceExpression; 22849 this.expressions = expressions; 22850 this.finish(); 22851 return this; 22852 }, 22853 22854 finishSpreadElement: function (argument) { 22855 this.type = Syntax.SpreadElement; 22856 this.argument = argument; 22857 this.finish(); 22858 return this; 22859 }, 22860 22861 finishSwitchCase: function (test, consequent) { 22862 this.type = Syntax.SwitchCase; 22863 this.test = test; 22864 this.consequent = consequent; 22865 this.finish(); 22866 return this; 22867 }, 22868 22869 finishSuper: function () { 22870 this.type = Syntax.Super; 22871 this.finish(); 22872 return this; 22873 }, 22874 22875 finishSwitchStatement: function (discriminant, cases) { 22876 this.type = Syntax.SwitchStatement; 22877 this.discriminant = discriminant; 22878 this.cases = cases; 22879 this.finish(); 22880 return this; 22881 }, 22882 22883 finishTaggedTemplateExpression: function (tag, quasi) { 22884 this.type = Syntax.TaggedTemplateExpression; 22885 this.tag = tag; 22886 this.quasi = quasi; 22887 this.finish(); 22888 return this; 22889 }, 22890 22891 finishTemplateElement: function (value, tail) { 22892 this.type = Syntax.TemplateElement; 22893 this.value = value; 22894 this.tail = tail; 22895 this.finish(); 22896 return this; 22897 }, 22898 22899 finishTemplateLiteral: function (quasis, expressions) { 22900 this.type = Syntax.TemplateLiteral; 22901 this.quasis = quasis; 22902 this.expressions = expressions; 22903 this.finish(); 22904 return this; 22905 }, 22906 22907 finishThisExpression: function () { 22908 this.type = Syntax.ThisExpression; 22909 this.finish(); 22910 return this; 22911 }, 22912 22913 finishThrowStatement: function (argument) { 22914 this.type = Syntax.ThrowStatement; 22915 this.argument = argument; 22916 this.finish(); 22917 return this; 22918 }, 22919 22920 finishTryStatement: function (block, handler, finalizer) { 22921 this.type = Syntax.TryStatement; 22922 this.block = block; 22923 this.guardedHandlers = []; 22924 this.handlers = handler ? [handler] : []; 22925 this.handler = handler; 22926 this.finalizer = finalizer; 22927 this.finish(); 22928 return this; 22929 }, 22930 22931 finishUnaryExpression: function (operator, argument) { 22932 this.type = (operator === '++' || operator === '--') ? Syntax.UpdateExpression : Syntax.UnaryExpression; 22933 this.operator = operator; 22934 this.argument = argument; 22935 this.prefix = true; 22936 this.finish(); 22937 return this; 22938 }, 22939 22940 finishVariableDeclaration: function (declarations) { 22941 this.type = Syntax.VariableDeclaration; 22942 this.declarations = declarations; 22943 this.kind = 'var'; 22944 this.finish(); 22945 return this; 22946 }, 22947 22948 finishLexicalDeclaration: function (declarations, kind) { 22949 this.type = Syntax.VariableDeclaration; 22950 this.declarations = declarations; 22951 this.kind = kind; 22952 this.finish(); 22953 return this; 22954 }, 22955 22956 finishVariableDeclarator: function (id, init) { 22957 this.type = Syntax.VariableDeclarator; 22958 this.id = id; 22959 this.init = init; 22960 this.finish(); 22961 return this; 22962 }, 22963 22964 finishWhileStatement: function (test, body) { 22965 this.type = Syntax.WhileStatement; 22966 this.test = test; 22967 this.body = body; 22968 this.finish(); 22969 return this; 22970 }, 22971 22972 finishWithStatement: function (object, body) { 22973 this.type = Syntax.WithStatement; 22974 this.object = object; 22975 this.body = body; 22976 this.finish(); 22977 return this; 22978 }, 22979 22980 finishExportSpecifier: function (local, exported) { 22981 this.type = Syntax.ExportSpecifier; 22982 this.exported = exported || local; 22983 this.local = local; 22984 this.finish(); 22985 return this; 22986 }, 22987 22988 finishImportDefaultSpecifier: function (local) { 22989 this.type = Syntax.ImportDefaultSpecifier; 22990 this.local = local; 22991 this.finish(); 22992 return this; 22993 }, 22994 22995 finishImportNamespaceSpecifier: function (local) { 22996 this.type = Syntax.ImportNamespaceSpecifier; 22997 this.local = local; 22998 this.finish(); 22999 return this; 23000 }, 23001 23002 finishExportNamedDeclaration: function (declaration, specifiers, src) { 23003 this.type = Syntax.ExportNamedDeclaration; 23004 this.declaration = declaration; 23005 this.specifiers = specifiers; 23006 this.source = src; 23007 this.finish(); 23008 return this; 23009 }, 23010 23011 finishExportDefaultDeclaration: function (declaration) { 23012 this.type = Syntax.ExportDefaultDeclaration; 23013 this.declaration = declaration; 23014 this.finish(); 23015 return this; 23016 }, 23017 23018 finishExportAllDeclaration: function (src) { 23019 this.type = Syntax.ExportAllDeclaration; 23020 this.source = src; 23021 this.finish(); 23022 return this; 23023 }, 23024 23025 finishImportSpecifier: function (local, imported) { 23026 this.type = Syntax.ImportSpecifier; 23027 this.local = local || imported; 23028 this.imported = imported; 23029 this.finish(); 23030 return this; 23031 }, 23032 23033 finishImportDeclaration: function (specifiers, src) { 23034 this.type = Syntax.ImportDeclaration; 23035 this.specifiers = specifiers; 23036 this.source = src; 23037 this.finish(); 23038 return this; 23039 }, 23040 23041 finishYieldExpression: function (argument, delegate) { 23042 this.type = Syntax.YieldExpression; 23043 this.argument = argument; 23044 this.delegate = delegate; 23045 this.finish(); 23046 return this; 23047 } 23048 }; 23049 23050 23051 function recordError(error) { 23052 var e, existing; 23053 23054 for (e = 0; e < extra.errors.length; e++) { 23055 existing = extra.errors[e]; 23056 // Prevent duplicated error. 23057 /* istanbul ignore next */ 23058 if (existing.index === error.index && existing.message === error.message) { 23059 return; 23060 } 23061 } 23062 23063 extra.errors.push(error); 23064 } 23065 23066 function constructError(msg, column) { 23067 var error = new Error(msg); 23068 try { 23069 throw error; 23070 } catch (base) { 23071 /* istanbul ignore else */ 23072 if (Object.create && Object.defineProperty) { 23073 error = Object.create(base); 23074 Object.defineProperty(error, 'column', { value: column }); 23075 } 23076 } finally { 23077 return error; 23078 } 23079 } 23080 23081 function createError(line, pos, description) { 23082 var msg, column, error; 23083 23084 msg = 'Line ' + line + ': ' + description; 23085 column = pos - (scanning ? lineStart : lastLineStart) + 1; 23086 error = constructError(msg, column); 23087 error.lineNumber = line; 23088 error.description = description; 23089 error.index = pos; 23090 return error; 23091 } 23092 23093 // Throw an exception 23094 23095 function throwError(messageFormat) { 23096 var args, msg; 23097 23098 args = Array.prototype.slice.call(arguments, 1); 23099 msg = messageFormat.replace(/%(\d)/g, 23100 function (whole, idx) { 23101 assert(idx < args.length, 'Message reference must be in range'); 23102 return args[idx]; 23103 } 23104 ); 23105 23106 throw createError(lastLineNumber, lastIndex, msg); 23107 } 23108 23109 function tolerateError(messageFormat) { 23110 var args, msg, error; 23111 23112 args = Array.prototype.slice.call(arguments, 1); 23113 /* istanbul ignore next */ 23114 msg = messageFormat.replace(/%(\d)/g, 23115 function (whole, idx) { 23116 assert(idx < args.length, 'Message reference must be in range'); 23117 return args[idx]; 23118 } 23119 ); 23120 23121 error = createError(lineNumber, lastIndex, msg); 23122 if (extra.errors) { 23123 recordError(error); 23124 } else { 23125 throw error; 23126 } 23127 } 23128 23129 // Throw an exception because of the token. 23130 23131 function unexpectedTokenError(token, message) { 23132 var value, msg = message || Messages.UnexpectedToken; 23133 23134 if (token) { 23135 if (!message) { 23136 msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS : 23137 (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier : 23138 (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber : 23139 (token.type === Token.StringLiteral) ? Messages.UnexpectedString : 23140 (token.type === Token.Template) ? Messages.UnexpectedTemplate : 23141 Messages.UnexpectedToken; 23142 23143 if (token.type === Token.Keyword) { 23144 if (isFutureReservedWord(token.value)) { 23145 msg = Messages.UnexpectedReserved; 23146 } else if (strict && isStrictModeReservedWord(token.value)) { 23147 msg = Messages.StrictReservedWord; 23148 } 23149 } 23150 } 23151 23152 value = (token.type === Token.Template) ? token.value.raw : token.value; 23153 } else { 23154 value = 'ILLEGAL'; 23155 } 23156 23157 msg = msg.replace('%0', value); 23158 23159 return (token && typeof token.lineNumber === 'number') ? 23160 createError(token.lineNumber, token.start, msg) : 23161 createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg); 23162 } 23163 23164 function throwUnexpectedToken(token, message) { 23165 throw unexpectedTokenError(token, message); 23166 } 23167 23168 function tolerateUnexpectedToken(token, message) { 23169 var error = unexpectedTokenError(token, message); 23170 if (extra.errors) { 23171 recordError(error); 23172 } else { 23173 throw error; 23174 } 23175 } 23176 23177 // Expect the next token to match the specified punctuator. 23178 // If not, an exception will be thrown. 23179 23180 function expect(value) { 23181 var token = lex(); 23182 if (token.type !== Token.Punctuator || token.value !== value) { 23183 throwUnexpectedToken(token); 23184 } 23185 } 23186 23187 /** 23188 * @name expectCommaSeparator 23189 * @description Quietly expect a comma when in tolerant mode, otherwise delegates 23190 * to <code>expect(value)</code> 23191 * @since 2.0 23192 */ 23193 function expectCommaSeparator() { 23194 var token; 23195 23196 if (extra.errors) { 23197 token = lookahead; 23198 if (token.type === Token.Punctuator && token.value === ',') { 23199 lex(); 23200 } else if (token.type === Token.Punctuator && token.value === ';') { 23201 lex(); 23202 tolerateUnexpectedToken(token); 23203 } else { 23204 tolerateUnexpectedToken(token, Messages.UnexpectedToken); 23205 } 23206 } else { 23207 expect(','); 23208 } 23209 } 23210 23211 // Expect the next token to match the specified keyword. 23212 // If not, an exception will be thrown. 23213 23214 function expectKeyword(keyword) { 23215 var token = lex(); 23216 if (token.type !== Token.Keyword || token.value !== keyword) { 23217 throwUnexpectedToken(token); 23218 } 23219 } 23220 23221 // Return true if the next token matches the specified punctuator. 23222 23223 function match(value) { 23224 return lookahead.type === Token.Punctuator && lookahead.value === value; 23225 } 23226 23227 // Return true if the next token matches the specified keyword 23228 23229 function matchKeyword(keyword) { 23230 return lookahead.type === Token.Keyword && lookahead.value === keyword; 23231 } 23232 23233 // Return true if the next token matches the specified contextual keyword 23234 // (where an identifier is sometimes a keyword depending on the context) 23235 23236 function matchContextualKeyword(keyword) { 23237 return lookahead.type === Token.Identifier && lookahead.value === keyword; 23238 } 23239 23240 // Return true if the next token is an assignment operator 23241 23242 function matchAssign() { 23243 var op; 23244 23245 if (lookahead.type !== Token.Punctuator) { 23246 return false; 23247 } 23248 op = lookahead.value; 23249 return op === '=' || 23250 op === '*=' || 23251 op === '/=' || 23252 op === '%=' || 23253 op === '+=' || 23254 op === '-=' || 23255 op === '<<=' || 23256 op === '>>=' || 23257 op === '>>>=' || 23258 op === '&=' || 23259 op === '^=' || 23260 op === '|='; 23261 } 23262 23263 function consumeSemicolon() { 23264 // Catch the very common case first: immediately a semicolon (U+003B). 23265 if (source.charCodeAt(startIndex) === 0x3B || match(';')) { 23266 lex(); 23267 return; 23268 } 23269 23270 if (hasLineTerminator) { 23271 return; 23272 } 23273 23274 // FIXME(ikarienator): this is seemingly an issue in the previous location info convention. 23275 lastIndex = startIndex; 23276 lastLineNumber = startLineNumber; 23277 lastLineStart = startLineStart; 23278 23279 if (lookahead.type !== Token.EOF && !match('}')) { 23280 throwUnexpectedToken(lookahead); 23281 } 23282 } 23283 23284 // Cover grammar support. 23285 // 23286 // When an assignment expression position starts with an left parenthesis, the determination of the type 23287 // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead) 23288 // or the first comma. This situation also defers the determination of all the expressions nested in the pair. 23289 // 23290 // There are three productions that can be parsed in a parentheses pair that needs to be determined 23291 // after the outermost pair is closed. They are: 23292 // 23293 // 1. AssignmentExpression 23294 // 2. BindingElements 23295 // 3. AssignmentTargets 23296 // 23297 // In order to avoid exponential backtracking, we use two flags to denote if the production can be 23298 // binding element or assignment target. 23299 // 23300 // The three productions have the relationship: 23301 // 23302 // BindingElements ⊆ AssignmentTargets ⊆ AssignmentExpression 23303 // 23304 // with a single exception that CoverInitializedName when used directly in an Expression, generates 23305 // an early error. Therefore, we need the third state, firstCoverInitializedNameError, to track the 23306 // first usage of CoverInitializedName and report it when we reached the end of the parentheses pair. 23307 // 23308 // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not 23309 // effect the current flags. This means the production the parser parses is only used as an expression. Therefore 23310 // the CoverInitializedName check is conducted. 23311 // 23312 // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates 23313 // the flags outside of the parser. This means the production the parser parses is used as a part of a potential 23314 // pattern. The CoverInitializedName check is deferred. 23315 function isolateCoverGrammar(parser) { 23316 var oldIsBindingElement = isBindingElement, 23317 oldIsAssignmentTarget = isAssignmentTarget, 23318 oldFirstCoverInitializedNameError = firstCoverInitializedNameError, 23319 result; 23320 isBindingElement = true; 23321 isAssignmentTarget = true; 23322 firstCoverInitializedNameError = null; 23323 result = parser(); 23324 if (firstCoverInitializedNameError !== null) { 23325 throwUnexpectedToken(firstCoverInitializedNameError); 23326 } 23327 isBindingElement = oldIsBindingElement; 23328 isAssignmentTarget = oldIsAssignmentTarget; 23329 firstCoverInitializedNameError = oldFirstCoverInitializedNameError; 23330 return result; 23331 } 23332 23333 function inheritCoverGrammar(parser) { 23334 var oldIsBindingElement = isBindingElement, 23335 oldIsAssignmentTarget = isAssignmentTarget, 23336 oldFirstCoverInitializedNameError = firstCoverInitializedNameError, 23337 result; 23338 isBindingElement = true; 23339 isAssignmentTarget = true; 23340 firstCoverInitializedNameError = null; 23341 result = parser(); 23342 isBindingElement = isBindingElement && oldIsBindingElement; 23343 isAssignmentTarget = isAssignmentTarget && oldIsAssignmentTarget; 23344 firstCoverInitializedNameError = oldFirstCoverInitializedNameError || firstCoverInitializedNameError; 23345 return result; 23346 } 23347 23348 // ECMA-262 13.3.3 Destructuring Binding Patterns 23349 23350 function parseArrayPattern(params, kind) { 23351 var node = new Node(), elements = [], rest, restNode; 23352 expect('['); 23353 23354 while (!match(']')) { 23355 if (match(',')) { 23356 lex(); 23357 elements.push(null); 23358 } else { 23359 if (match('...')) { 23360 restNode = new Node(); 23361 lex(); 23362 params.push(lookahead); 23363 rest = parseVariableIdentifier(kind); 23364 elements.push(restNode.finishRestElement(rest)); 23365 break; 23366 } else { 23367 elements.push(parsePatternWithDefault(params, kind)); 23368 } 23369 if (!match(']')) { 23370 expect(','); 23371 } 23372 } 23373 23374 } 23375 23376 expect(']'); 23377 23378 return node.finishArrayPattern(elements); 23379 } 23380 23381 function parsePropertyPattern(params, kind) { 23382 var node = new Node(), key, keyToken, computed = match('['), init; 23383 if (lookahead.type === Token.Identifier) { 23384 keyToken = lookahead; 23385 key = parseVariableIdentifier(); 23386 if (match('=')) { 23387 params.push(keyToken); 23388 lex(); 23389 init = parseAssignmentExpression(); 23390 23391 return node.finishProperty( 23392 'init', key, false, 23393 new WrappingNode(keyToken).finishAssignmentPattern(key, init), false, true); 23394 } else if (!match(':')) { 23395 params.push(keyToken); 23396 return node.finishProperty('init', key, false, key, false, true); 23397 } 23398 } else { 23399 key = parseObjectPropertyKey(); 23400 } 23401 expect(':'); 23402 init = parsePatternWithDefault(params, kind); 23403 return node.finishProperty('init', key, computed, init, false, false); 23404 } 23405 23406 function parseObjectPattern(params, kind) { 23407 var node = new Node(), properties = []; 23408 23409 expect('{'); 23410 23411 while (!match('}')) { 23412 properties.push(parsePropertyPattern(params, kind)); 23413 if (!match('}')) { 23414 expect(','); 23415 } 23416 } 23417 23418 lex(); 23419 23420 return node.finishObjectPattern(properties); 23421 } 23422 23423 function parsePattern(params, kind) { 23424 if (match('[')) { 23425 return parseArrayPattern(params, kind); 23426 } else if (match('{')) { 23427 return parseObjectPattern(params, kind); 23428 } else if (matchKeyword('let')) { 23429 if (kind === 'const' || kind === 'let') { 23430 tolerateUnexpectedToken(lookahead, Messages.UnexpectedToken); 23431 } 23432 } 23433 23434 params.push(lookahead); 23435 return parseVariableIdentifier(kind); 23436 } 23437 23438 function parsePatternWithDefault(params, kind) { 23439 var startToken = lookahead, pattern, previousAllowYield, right; 23440 pattern = parsePattern(params, kind); 23441 if (match('=')) { 23442 lex(); 23443 previousAllowYield = state.allowYield; 23444 state.allowYield = true; 23445 right = isolateCoverGrammar(parseAssignmentExpression); 23446 state.allowYield = previousAllowYield; 23447 pattern = new WrappingNode(startToken).finishAssignmentPattern(pattern, right); 23448 } 23449 return pattern; 23450 } 23451 23452 // ECMA-262 12.2.5 Array Initializer 23453 23454 function parseArrayInitializer() { 23455 var elements = [], node = new Node(), restSpread; 23456 23457 expect('['); 23458 23459 while (!match(']')) { 23460 if (match(',')) { 23461 lex(); 23462 elements.push(null); 23463 } else if (match('...')) { 23464 restSpread = new Node(); 23465 lex(); 23466 restSpread.finishSpreadElement(inheritCoverGrammar(parseAssignmentExpression)); 23467 23468 if (!match(']')) { 23469 isAssignmentTarget = isBindingElement = false; 23470 expect(','); 23471 } 23472 elements.push(restSpread); 23473 } else { 23474 elements.push(inheritCoverGrammar(parseAssignmentExpression)); 23475 23476 if (!match(']')) { 23477 expect(','); 23478 } 23479 } 23480 } 23481 23482 lex(); 23483 23484 return node.finishArrayExpression(elements); 23485 } 23486 23487 // ECMA-262 12.2.6 Object Initializer 23488 23489 function parsePropertyFunction(node, paramInfo, isGenerator) { 23490 var previousStrict, body; 23491 23492 isAssignmentTarget = isBindingElement = false; 23493 23494 previousStrict = strict; 23495 body = isolateCoverGrammar(parseFunctionSourceElements); 23496 23497 if (strict && paramInfo.firstRestricted) { 23498 tolerateUnexpectedToken(paramInfo.firstRestricted, paramInfo.message); 23499 } 23500 if (strict && paramInfo.stricted) { 23501 tolerateUnexpectedToken(paramInfo.stricted, paramInfo.message); 23502 } 23503 23504 strict = previousStrict; 23505 return node.finishFunctionExpression(null, paramInfo.params, paramInfo.defaults, body, isGenerator); 23506 } 23507 23508 function parsePropertyMethodFunction() { 23509 var params, method, node = new Node(), 23510 previousAllowYield = state.allowYield; 23511 23512 state.allowYield = false; 23513 params = parseParams(); 23514 state.allowYield = previousAllowYield; 23515 23516 state.allowYield = false; 23517 method = parsePropertyFunction(node, params, false); 23518 state.allowYield = previousAllowYield; 23519 23520 return method; 23521 } 23522 23523 function parseObjectPropertyKey() { 23524 var token, node = new Node(), expr; 23525 23526 token = lex(); 23527 23528 // Note: This function is called only from parseObjectProperty(), where 23529 // EOF and Punctuator tokens are already filtered out. 23530 23531 switch (token.type) { 23532 case Token.StringLiteral: 23533 case Token.NumericLiteral: 23534 if (strict && token.octal) { 23535 tolerateUnexpectedToken(token, Messages.StrictOctalLiteral); 23536 } 23537 return node.finishLiteral(token); 23538 case Token.Identifier: 23539 case Token.BooleanLiteral: 23540 case Token.NullLiteral: 23541 case Token.Keyword: 23542 return node.finishIdentifier(token.value); 23543 case Token.Punctuator: 23544 if (token.value === '[') { 23545 expr = isolateCoverGrammar(parseAssignmentExpression); 23546 expect(']'); 23547 return expr; 23548 } 23549 break; 23550 } 23551 throwUnexpectedToken(token); 23552 } 23553 23554 function lookaheadPropertyName() { 23555 switch (lookahead.type) { 23556 case Token.Identifier: 23557 case Token.StringLiteral: 23558 case Token.BooleanLiteral: 23559 case Token.NullLiteral: 23560 case Token.NumericLiteral: 23561 case Token.Keyword: 23562 return true; 23563 case Token.Punctuator: 23564 return lookahead.value === '['; 23565 } 23566 return false; 23567 } 23568 23569 // This function is to try to parse a MethodDefinition as defined in 14.3. But in the case of object literals, 23570 // it might be called at a position where there is in fact a short hand identifier pattern or a data property. 23571 // This can only be determined after we consumed up to the left parentheses. 23572 // 23573 // In order to avoid back tracking, it returns `null` if the position is not a MethodDefinition and the caller 23574 // is responsible to visit other options. 23575 function tryParseMethodDefinition(token, key, computed, node) { 23576 var value, options, methodNode, params, 23577 previousAllowYield = state.allowYield; 23578 23579 if (token.type === Token.Identifier) { 23580 // check for `get` and `set`; 23581 23582 if (token.value === 'get' && lookaheadPropertyName()) { 23583 computed = match('['); 23584 key = parseObjectPropertyKey(); 23585 methodNode = new Node(); 23586 expect('('); 23587 expect(')'); 23588 23589 state.allowYield = false; 23590 value = parsePropertyFunction(methodNode, { 23591 params: [], 23592 defaults: [], 23593 stricted: null, 23594 firstRestricted: null, 23595 message: null 23596 }, false); 23597 state.allowYield = previousAllowYield; 23598 23599 return node.finishProperty('get', key, computed, value, false, false); 23600 } else if (token.value === 'set' && lookaheadPropertyName()) { 23601 computed = match('['); 23602 key = parseObjectPropertyKey(); 23603 methodNode = new Node(); 23604 expect('('); 23605 23606 options = { 23607 params: [], 23608 defaultCount: 0, 23609 defaults: [], 23610 firstRestricted: null, 23611 paramSet: {} 23612 }; 23613 if (match(')')) { 23614 tolerateUnexpectedToken(lookahead); 23615 } else { 23616 state.allowYield = false; 23617 parseParam(options); 23618 state.allowYield = previousAllowYield; 23619 if (options.defaultCount === 0) { 23620 options.defaults = []; 23621 } 23622 } 23623 expect(')'); 23624 23625 state.allowYield = false; 23626 value = parsePropertyFunction(methodNode, options, false); 23627 state.allowYield = previousAllowYield; 23628 23629 return node.finishProperty('set', key, computed, value, false, false); 23630 } 23631 } else if (token.type === Token.Punctuator && token.value === '*' && lookaheadPropertyName()) { 23632 computed = match('['); 23633 key = parseObjectPropertyKey(); 23634 methodNode = new Node(); 23635 23636 state.allowYield = true; 23637 params = parseParams(); 23638 state.allowYield = previousAllowYield; 23639 23640 state.allowYield = false; 23641 value = parsePropertyFunction(methodNode, params, true); 23642 state.allowYield = previousAllowYield; 23643 23644 return node.finishProperty('init', key, computed, value, true, false); 23645 } 23646 23647 if (key && match('(')) { 23648 value = parsePropertyMethodFunction(); 23649 return node.finishProperty('init', key, computed, value, true, false); 23650 } 23651 23652 // Not a MethodDefinition. 23653 return null; 23654 } 23655 23656 function parseObjectProperty(hasProto) { 23657 var token = lookahead, node = new Node(), computed, key, maybeMethod, proto, value; 23658 23659 computed = match('['); 23660 if (match('*')) { 23661 lex(); 23662 } else { 23663 key = parseObjectPropertyKey(); 23664 } 23665 maybeMethod = tryParseMethodDefinition(token, key, computed, node); 23666 if (maybeMethod) { 23667 return maybeMethod; 23668 } 23669 23670 if (!key) { 23671 throwUnexpectedToken(lookahead); 23672 } 23673 23674 // Check for duplicated __proto__ 23675 if (!computed) { 23676 proto = (key.type === Syntax.Identifier && key.name === '__proto__') || 23677 (key.type === Syntax.Literal && key.value === '__proto__'); 23678 if (hasProto.value && proto) { 23679 tolerateError(Messages.DuplicateProtoProperty); 23680 } 23681 hasProto.value |= proto; 23682 } 23683 23684 if (match(':')) { 23685 lex(); 23686 value = inheritCoverGrammar(parseAssignmentExpression); 23687 return node.finishProperty('init', key, computed, value, false, false); 23688 } 23689 23690 if (token.type === Token.Identifier) { 23691 if (match('=')) { 23692 firstCoverInitializedNameError = lookahead; 23693 lex(); 23694 value = isolateCoverGrammar(parseAssignmentExpression); 23695 return node.finishProperty('init', key, computed, 23696 new WrappingNode(token).finishAssignmentPattern(key, value), false, true); 23697 } 23698 return node.finishProperty('init', key, computed, key, false, true); 23699 } 23700 23701 throwUnexpectedToken(lookahead); 23702 } 23703 23704 function parseObjectInitializer() { 23705 var properties = [], hasProto = {value: false}, node = new Node(); 23706 23707 expect('{'); 23708 23709 while (!match('}')) { 23710 properties.push(parseObjectProperty(hasProto)); 23711 23712 if (!match('}')) { 23713 expectCommaSeparator(); 23714 } 23715 } 23716 23717 expect('}'); 23718 23719 return node.finishObjectExpression(properties); 23720 } 23721 23722 function reinterpretExpressionAsPattern(expr) { 23723 var i; 23724 switch (expr.type) { 23725 case Syntax.Identifier: 23726 case Syntax.MemberExpression: 23727 case Syntax.RestElement: 23728 case Syntax.AssignmentPattern: 23729 break; 23730 case Syntax.SpreadElement: 23731 expr.type = Syntax.RestElement; 23732 reinterpretExpressionAsPattern(expr.argument); 23733 break; 23734 case Syntax.ArrayExpression: 23735 expr.type = Syntax.ArrayPattern; 23736 for (i = 0; i < expr.elements.length; i++) { 23737 if (expr.elements[i] !== null) { 23738 reinterpretExpressionAsPattern(expr.elements[i]); 23739 } 23740 } 23741 break; 23742 case Syntax.ObjectExpression: 23743 expr.type = Syntax.ObjectPattern; 23744 for (i = 0; i < expr.properties.length; i++) { 23745 reinterpretExpressionAsPattern(expr.properties[i].value); 23746 } 23747 break; 23748 case Syntax.AssignmentExpression: 23749 expr.type = Syntax.AssignmentPattern; 23750 reinterpretExpressionAsPattern(expr.left); 23751 break; 23752 default: 23753 // Allow other node type for tolerant parsing. 23754 break; 23755 } 23756 } 23757 23758 // ECMA-262 12.2.9 Template Literals 23759 23760 function parseTemplateElement(option) { 23761 var node, token; 23762 23763 if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) { 23764 throwUnexpectedToken(); 23765 } 23766 23767 node = new Node(); 23768 token = lex(); 23769 23770 return node.finishTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail); 23771 } 23772 23773 function parseTemplateLiteral() { 23774 var quasi, quasis, expressions, node = new Node(); 23775 23776 quasi = parseTemplateElement({ head: true }); 23777 quasis = [quasi]; 23778 expressions = []; 23779 23780 while (!quasi.tail) { 23781 expressions.push(parseExpression()); 23782 quasi = parseTemplateElement({ head: false }); 23783 quasis.push(quasi); 23784 } 23785 23786 return node.finishTemplateLiteral(quasis, expressions); 23787 } 23788 23789 // ECMA-262 12.2.10 The Grouping Operator 23790 23791 function parseGroupExpression() { 23792 var expr, expressions, startToken, i, params = []; 23793 23794 expect('('); 23795 23796 if (match(')')) { 23797 lex(); 23798 if (!match('=>')) { 23799 expect('=>'); 23800 } 23801 return { 23802 type: PlaceHolders.ArrowParameterPlaceHolder, 23803 params: [], 23804 rawParams: [] 23805 }; 23806 } 23807 23808 startToken = lookahead; 23809 if (match('...')) { 23810 expr = parseRestElement(params); 23811 expect(')'); 23812 if (!match('=>')) { 23813 expect('=>'); 23814 } 23815 return { 23816 type: PlaceHolders.ArrowParameterPlaceHolder, 23817 params: [expr] 23818 }; 23819 } 23820 23821 isBindingElement = true; 23822 expr = inheritCoverGrammar(parseAssignmentExpression); 23823 23824 if (match(',')) { 23825 isAssignmentTarget = false; 23826 expressions = [expr]; 23827 23828 while (startIndex < length) { 23829 if (!match(',')) { 23830 break; 23831 } 23832 lex(); 23833 23834 if (match('...')) { 23835 if (!isBindingElement) { 23836 throwUnexpectedToken(lookahead); 23837 } 23838 expressions.push(parseRestElement(params)); 23839 expect(')'); 23840 if (!match('=>')) { 23841 expect('=>'); 23842 } 23843 isBindingElement = false; 23844 for (i = 0; i < expressions.length; i++) { 23845 reinterpretExpressionAsPattern(expressions[i]); 23846 } 23847 return { 23848 type: PlaceHolders.ArrowParameterPlaceHolder, 23849 params: expressions 23850 }; 23851 } 23852 23853 expressions.push(inheritCoverGrammar(parseAssignmentExpression)); 23854 } 23855 23856 expr = new WrappingNode(startToken).finishSequenceExpression(expressions); 23857 } 23858 23859 23860 expect(')'); 23861 23862 if (match('=>')) { 23863 if (expr.type === Syntax.Identifier && expr.name === 'yield') { 23864 return { 23865 type: PlaceHolders.ArrowParameterPlaceHolder, 23866 params: [expr] 23867 }; 23868 } 23869 23870 if (!isBindingElement) { 23871 throwUnexpectedToken(lookahead); 23872 } 23873 23874 if (expr.type === Syntax.SequenceExpression) { 23875 for (i = 0; i < expr.expressions.length; i++) { 23876 reinterpretExpressionAsPattern(expr.expressions[i]); 23877 } 23878 } else { 23879 reinterpretExpressionAsPattern(expr); 23880 } 23881 23882 expr = { 23883 type: PlaceHolders.ArrowParameterPlaceHolder, 23884 params: expr.type === Syntax.SequenceExpression ? expr.expressions : [expr] 23885 }; 23886 } 23887 isBindingElement = false; 23888 return expr; 23889 } 23890 23891 23892 // ECMA-262 12.2 Primary Expressions 23893 23894 function parsePrimaryExpression() { 23895 var type, token, expr, node; 23896 23897 if (match('(')) { 23898 isBindingElement = false; 23899 return inheritCoverGrammar(parseGroupExpression); 23900 } 23901 23902 if (match('[')) { 23903 return inheritCoverGrammar(parseArrayInitializer); 23904 } 23905 23906 if (match('{')) { 23907 return inheritCoverGrammar(parseObjectInitializer); 23908 } 23909 23910 type = lookahead.type; 23911 node = new Node(); 23912 23913 if (type === Token.Identifier) { 23914 if (state.sourceType === 'module' && lookahead.value === 'await') { 23915 tolerateUnexpectedToken(lookahead); 23916 } 23917 expr = node.finishIdentifier(lex().value); 23918 } else if (type === Token.StringLiteral || type === Token.NumericLiteral) { 23919 isAssignmentTarget = isBindingElement = false; 23920 if (strict && lookahead.octal) { 23921 tolerateUnexpectedToken(lookahead, Messages.StrictOctalLiteral); 23922 } 23923 expr = node.finishLiteral(lex()); 23924 } else if (type === Token.Keyword) { 23925 if (!strict && state.allowYield && matchKeyword('yield')) { 23926 return parseNonComputedProperty(); 23927 } 23928 if (!strict && matchKeyword('let')) { 23929 return node.finishIdentifier(lex().value); 23930 } 23931 isAssignmentTarget = isBindingElement = false; 23932 if (matchKeyword('function')) { 23933 return parseFunctionExpression(); 23934 } 23935 if (matchKeyword('this')) { 23936 lex(); 23937 return node.finishThisExpression(); 23938 } 23939 if (matchKeyword('class')) { 23940 return parseClassExpression(); 23941 } 23942 throwUnexpectedToken(lex()); 23943 } else if (type === Token.BooleanLiteral) { 23944 isAssignmentTarget = isBindingElement = false; 23945 token = lex(); 23946 token.value = (token.value === 'true'); 23947 expr = node.finishLiteral(token); 23948 } else if (type === Token.NullLiteral) { 23949 isAssignmentTarget = isBindingElement = false; 23950 token = lex(); 23951 token.value = null; 23952 expr = node.finishLiteral(token); 23953 } else if (match('/') || match('/=')) { 23954 isAssignmentTarget = isBindingElement = false; 23955 index = startIndex; 23956 23957 if (typeof extra.tokens !== 'undefined') { 23958 token = collectRegex(); 23959 } else { 23960 token = scanRegExp(); 23961 } 23962 lex(); 23963 expr = node.finishLiteral(token); 23964 } else if (type === Token.Template) { 23965 expr = parseTemplateLiteral(); 23966 } else { 23967 throwUnexpectedToken(lex()); 23968 } 23969 23970 return expr; 23971 } 23972 23973 // ECMA-262 12.3 Left-Hand-Side Expressions 23974 23975 function parseArguments() { 23976 var args = [], expr; 23977 23978 expect('('); 23979 23980 if (!match(')')) { 23981 while (startIndex < length) { 23982 if (match('...')) { 23983 expr = new Node(); 23984 lex(); 23985 expr.finishSpreadElement(isolateCoverGrammar(parseAssignmentExpression)); 23986 } else { 23987 expr = isolateCoverGrammar(parseAssignmentExpression); 23988 } 23989 args.push(expr); 23990 if (match(')')) { 23991 break; 23992 } 23993 expectCommaSeparator(); 23994 } 23995 } 23996 23997 expect(')'); 23998 23999 return args; 24000 } 24001 24002 function parseNonComputedProperty() { 24003 var token, node = new Node(); 24004 24005 token = lex(); 24006 24007 if (!isIdentifierName(token)) { 24008 throwUnexpectedToken(token); 24009 } 24010 24011 return node.finishIdentifier(token.value); 24012 } 24013 24014 function parseNonComputedMember() { 24015 expect('.'); 24016 24017 return parseNonComputedProperty(); 24018 } 24019 24020 function parseComputedMember() { 24021 var expr; 24022 24023 expect('['); 24024 24025 expr = isolateCoverGrammar(parseExpression); 24026 24027 expect(']'); 24028 24029 return expr; 24030 } 24031 24032 // ECMA-262 12.3.3 The new Operator 24033 24034 function parseNewExpression() { 24035 var callee, args, node = new Node(); 24036 24037 expectKeyword('new'); 24038 24039 if (match('.')) { 24040 lex(); 24041 if (lookahead.type === Token.Identifier && lookahead.value === 'target') { 24042 if (state.inFunctionBody) { 24043 lex(); 24044 return node.finishMetaProperty('new', 'target'); 24045 } 24046 } 24047 throwUnexpectedToken(lookahead); 24048 } 24049 24050 callee = isolateCoverGrammar(parseLeftHandSideExpression); 24051 args = match('(') ? parseArguments() : []; 24052 24053 isAssignmentTarget = isBindingElement = false; 24054 24055 return node.finishNewExpression(callee, args); 24056 } 24057 24058 // ECMA-262 12.3.4 Function Calls 24059 24060 function parseLeftHandSideExpressionAllowCall() { 24061 var quasi, expr, args, property, startToken, previousAllowIn = state.allowIn; 24062 24063 startToken = lookahead; 24064 state.allowIn = true; 24065 24066 if (matchKeyword('super') && state.inFunctionBody) { 24067 expr = new Node(); 24068 lex(); 24069 expr = expr.finishSuper(); 24070 if (!match('(') && !match('.') && !match('[')) { 24071 throwUnexpectedToken(lookahead); 24072 } 24073 } else { 24074 expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression); 24075 } 24076 24077 for (;;) { 24078 if (match('.')) { 24079 isBindingElement = false; 24080 isAssignmentTarget = true; 24081 property = parseNonComputedMember(); 24082 expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property); 24083 } else if (match('(')) { 24084 isBindingElement = false; 24085 isAssignmentTarget = false; 24086 args = parseArguments(); 24087 expr = new WrappingNode(startToken).finishCallExpression(expr, args); 24088 } else if (match('[')) { 24089 isBindingElement = false; 24090 isAssignmentTarget = true; 24091 property = parseComputedMember(); 24092 expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property); 24093 } else if (lookahead.type === Token.Template && lookahead.head) { 24094 quasi = parseTemplateLiteral(); 24095 expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi); 24096 } else { 24097 break; 24098 } 24099 } 24100 state.allowIn = previousAllowIn; 24101 24102 return expr; 24103 } 24104 24105 // ECMA-262 12.3 Left-Hand-Side Expressions 24106 24107 function parseLeftHandSideExpression() { 24108 var quasi, expr, property, startToken; 24109 assert(state.allowIn, 'callee of new expression always allow in keyword.'); 24110 24111 startToken = lookahead; 24112 24113 if (matchKeyword('super') && state.inFunctionBody) { 24114 expr = new Node(); 24115 lex(); 24116 expr = expr.finishSuper(); 24117 if (!match('[') && !match('.')) { 24118 throwUnexpectedToken(lookahead); 24119 } 24120 } else { 24121 expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression); 24122 } 24123 24124 for (;;) { 24125 if (match('[')) { 24126 isBindingElement = false; 24127 isAssignmentTarget = true; 24128 property = parseComputedMember(); 24129 expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property); 24130 } else if (match('.')) { 24131 isBindingElement = false; 24132 isAssignmentTarget = true; 24133 property = parseNonComputedMember(); 24134 expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property); 24135 } else if (lookahead.type === Token.Template && lookahead.head) { 24136 quasi = parseTemplateLiteral(); 24137 expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi); 24138 } else { 24139 break; 24140 } 24141 } 24142 return expr; 24143 } 24144 24145 // ECMA-262 12.4 Postfix Expressions 24146 24147 function parsePostfixExpression() { 24148 var expr, token, startToken = lookahead; 24149 24150 expr = inheritCoverGrammar(parseLeftHandSideExpressionAllowCall); 24151 24152 if (!hasLineTerminator && lookahead.type === Token.Punctuator) { 24153 if (match('++') || match('--')) { 24154 // ECMA-262 11.3.1, 11.3.2 24155 if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { 24156 tolerateError(Messages.StrictLHSPostfix); 24157 } 24158 24159 if (!isAssignmentTarget) { 24160 tolerateError(Messages.InvalidLHSInAssignment); 24161 } 24162 24163 isAssignmentTarget = isBindingElement = false; 24164 24165 token = lex(); 24166 expr = new WrappingNode(startToken).finishPostfixExpression(token.value, expr); 24167 } 24168 } 24169 24170 return expr; 24171 } 24172 24173 // ECMA-262 12.5 Unary Operators 24174 24175 function parseUnaryExpression() { 24176 var token, expr, startToken; 24177 24178 if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { 24179 expr = parsePostfixExpression(); 24180 } else if (match('++') || match('--')) { 24181 startToken = lookahead; 24182 token = lex(); 24183 expr = inheritCoverGrammar(parseUnaryExpression); 24184 // ECMA-262 11.4.4, 11.4.5 24185 if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { 24186 tolerateError(Messages.StrictLHSPrefix); 24187 } 24188 24189 if (!isAssignmentTarget) { 24190 tolerateError(Messages.InvalidLHSInAssignment); 24191 } 24192 expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr); 24193 isAssignmentTarget = isBindingElement = false; 24194 } else if (match('+') || match('-') || match('~') || match('!')) { 24195 startToken = lookahead; 24196 token = lex(); 24197 expr = inheritCoverGrammar(parseUnaryExpression); 24198 expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr); 24199 isAssignmentTarget = isBindingElement = false; 24200 } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { 24201 startToken = lookahead; 24202 token = lex(); 24203 expr = inheritCoverGrammar(parseUnaryExpression); 24204 expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr); 24205 if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { 24206 tolerateError(Messages.StrictDelete); 24207 } 24208 isAssignmentTarget = isBindingElement = false; 24209 } else { 24210 expr = parsePostfixExpression(); 24211 } 24212 24213 return expr; 24214 } 24215 24216 function binaryPrecedence(token, allowIn) { 24217 var prec = 0; 24218 24219 if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { 24220 return 0; 24221 } 24222 24223 switch (token.value) { 24224 case '||': 24225 prec = 1; 24226 break; 24227 24228 case '&&': 24229 prec = 2; 24230 break; 24231 24232 case '|': 24233 prec = 3; 24234 break; 24235 24236 case '^': 24237 prec = 4; 24238 break; 24239 24240 case '&': 24241 prec = 5; 24242 break; 24243 24244 case '==': 24245 case '!=': 24246 case '===': 24247 case '!==': 24248 prec = 6; 24249 break; 24250 24251 case '<': 24252 case '>': 24253 case '<=': 24254 case '>=': 24255 case 'instanceof': 24256 prec = 7; 24257 break; 24258 24259 case 'in': 24260 prec = allowIn ? 7 : 0; 24261 break; 24262 24263 case '<<': 24264 case '>>': 24265 case '>>>': 24266 prec = 8; 24267 break; 24268 24269 case '+': 24270 case '-': 24271 prec = 9; 24272 break; 24273 24274 case '*': 24275 case '/': 24276 case '%': 24277 prec = 11; 24278 break; 24279 24280 default: 24281 break; 24282 } 24283 24284 return prec; 24285 } 24286 24287 // ECMA-262 12.6 Multiplicative Operators 24288 // ECMA-262 12.7 Additive Operators 24289 // ECMA-262 12.8 Bitwise Shift Operators 24290 // ECMA-262 12.9 Relational Operators 24291 // ECMA-262 12.10 Equality Operators 24292 // ECMA-262 12.11 Binary Bitwise Operators 24293 // ECMA-262 12.12 Binary Logical Operators 24294 24295 function parseBinaryExpression() { 24296 var marker, markers, expr, token, prec, stack, right, operator, left, i; 24297 24298 marker = lookahead; 24299 left = inheritCoverGrammar(parseUnaryExpression); 24300 24301 token = lookahead; 24302 prec = binaryPrecedence(token, state.allowIn); 24303 if (prec === 0) { 24304 return left; 24305 } 24306 isAssignmentTarget = isBindingElement = false; 24307 token.prec = prec; 24308 lex(); 24309 24310 markers = [marker, lookahead]; 24311 right = isolateCoverGrammar(parseUnaryExpression); 24312 24313 stack = [left, token, right]; 24314 24315 while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) { 24316 24317 // Reduce: make a binary expression from the three topmost entries. 24318 while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { 24319 right = stack.pop(); 24320 operator = stack.pop().value; 24321 left = stack.pop(); 24322 markers.pop(); 24323 expr = new WrappingNode(markers[markers.length - 1]).finishBinaryExpression(operator, left, right); 24324 stack.push(expr); 24325 } 24326 24327 // Shift. 24328 token = lex(); 24329 token.prec = prec; 24330 stack.push(token); 24331 markers.push(lookahead); 24332 expr = isolateCoverGrammar(parseUnaryExpression); 24333 stack.push(expr); 24334 } 24335 24336 // Final reduce to clean-up the stack. 24337 i = stack.length - 1; 24338 expr = stack[i]; 24339 markers.pop(); 24340 while (i > 1) { 24341 expr = new WrappingNode(markers.pop()).finishBinaryExpression(stack[i - 1].value, stack[i - 2], expr); 24342 i -= 2; 24343 } 24344 24345 return expr; 24346 } 24347 24348 24349 // ECMA-262 12.13 Conditional Operator 24350 24351 function parseConditionalExpression() { 24352 var expr, previousAllowIn, consequent, alternate, startToken; 24353 24354 startToken = lookahead; 24355 24356 expr = inheritCoverGrammar(parseBinaryExpression); 24357 if (match('?')) { 24358 lex(); 24359 previousAllowIn = state.allowIn; 24360 state.allowIn = true; 24361 consequent = isolateCoverGrammar(parseAssignmentExpression); 24362 state.allowIn = previousAllowIn; 24363 expect(':'); 24364 alternate = isolateCoverGrammar(parseAssignmentExpression); 24365 24366 expr = new WrappingNode(startToken).finishConditionalExpression(expr, consequent, alternate); 24367 isAssignmentTarget = isBindingElement = false; 24368 } 24369 24370 return expr; 24371 } 24372 24373 // ECMA-262 14.2 Arrow Function Definitions 24374 24375 function parseConciseBody() { 24376 if (match('{')) { 24377 return parseFunctionSourceElements(); 24378 } 24379 return isolateCoverGrammar(parseAssignmentExpression); 24380 } 24381 24382 function checkPatternParam(options, param) { 24383 var i; 24384 switch (param.type) { 24385 case Syntax.Identifier: 24386 validateParam(options, param, param.name); 24387 break; 24388 case Syntax.RestElement: 24389 checkPatternParam(options, param.argument); 24390 break; 24391 case Syntax.AssignmentPattern: 24392 checkPatternParam(options, param.left); 24393 break; 24394 case Syntax.ArrayPattern: 24395 for (i = 0; i < param.elements.length; i++) { 24396 if (param.elements[i] !== null) { 24397 checkPatternParam(options, param.elements[i]); 24398 } 24399 } 24400 break; 24401 case Syntax.YieldExpression: 24402 break; 24403 default: 24404 assert(param.type === Syntax.ObjectPattern, 'Invalid type'); 24405 for (i = 0; i < param.properties.length; i++) { 24406 checkPatternParam(options, param.properties[i].value); 24407 } 24408 break; 24409 } 24410 } 24411 function reinterpretAsCoverFormalsList(expr) { 24412 var i, len, param, params, defaults, defaultCount, options, token; 24413 24414 defaults = []; 24415 defaultCount = 0; 24416 params = [expr]; 24417 24418 switch (expr.type) { 24419 case Syntax.Identifier: 24420 break; 24421 case PlaceHolders.ArrowParameterPlaceHolder: 24422 params = expr.params; 24423 break; 24424 default: 24425 return null; 24426 } 24427 24428 options = { 24429 paramSet: {} 24430 }; 24431 24432 for (i = 0, len = params.length; i < len; i += 1) { 24433 param = params[i]; 24434 switch (param.type) { 24435 case Syntax.AssignmentPattern: 24436 params[i] = param.left; 24437 if (param.right.type === Syntax.YieldExpression) { 24438 if (param.right.argument) { 24439 throwUnexpectedToken(lookahead); 24440 } 24441 param.right.type = Syntax.Identifier; 24442 param.right.name = 'yield'; 24443 delete param.right.argument; 24444 delete param.right.delegate; 24445 } 24446 defaults.push(param.right); 24447 ++defaultCount; 24448 checkPatternParam(options, param.left); 24449 break; 24450 default: 24451 checkPatternParam(options, param); 24452 params[i] = param; 24453 defaults.push(null); 24454 break; 24455 } 24456 } 24457 24458 if (strict || !state.allowYield) { 24459 for (i = 0, len = params.length; i < len; i += 1) { 24460 param = params[i]; 24461 if (param.type === Syntax.YieldExpression) { 24462 throwUnexpectedToken(lookahead); 24463 } 24464 } 24465 } 24466 24467 if (options.message === Messages.StrictParamDupe) { 24468 token = strict ? options.stricted : options.firstRestricted; 24469 throwUnexpectedToken(token, options.message); 24470 } 24471 24472 if (defaultCount === 0) { 24473 defaults = []; 24474 } 24475 24476 return { 24477 params: params, 24478 defaults: defaults, 24479 stricted: options.stricted, 24480 firstRestricted: options.firstRestricted, 24481 message: options.message 24482 }; 24483 } 24484 24485 function parseArrowFunctionExpression(options, node) { 24486 var previousStrict, previousAllowYield, body; 24487 24488 if (hasLineTerminator) { 24489 tolerateUnexpectedToken(lookahead); 24490 } 24491 expect('=>'); 24492 24493 previousStrict = strict; 24494 previousAllowYield = state.allowYield; 24495 state.allowYield = true; 24496 24497 body = parseConciseBody(); 24498 24499 if (strict && options.firstRestricted) { 24500 throwUnexpectedToken(options.firstRestricted, options.message); 24501 } 24502 if (strict && options.stricted) { 24503 tolerateUnexpectedToken(options.stricted, options.message); 24504 } 24505 24506 strict = previousStrict; 24507 state.allowYield = previousAllowYield; 24508 24509 return node.finishArrowFunctionExpression(options.params, options.defaults, body, body.type !== Syntax.BlockStatement); 24510 } 24511 24512 // ECMA-262 14.4 Yield expression 24513 24514 function parseYieldExpression() { 24515 var argument, expr, delegate, previousAllowYield; 24516 24517 argument = null; 24518 expr = new Node(); 24519 delegate = false; 24520 24521 expectKeyword('yield'); 24522 24523 if (!hasLineTerminator) { 24524 previousAllowYield = state.allowYield; 24525 state.allowYield = false; 24526 delegate = match('*'); 24527 if (delegate) { 24528 lex(); 24529 argument = parseAssignmentExpression(); 24530 } else { 24531 if (!match(';') && !match('}') && !match(')') && lookahead.type !== Token.EOF) { 24532 argument = parseAssignmentExpression(); 24533 } 24534 } 24535 state.allowYield = previousAllowYield; 24536 } 24537 24538 return expr.finishYieldExpression(argument, delegate); 24539 } 24540 24541 // ECMA-262 12.14 Assignment Operators 24542 24543 function parseAssignmentExpression() { 24544 var token, expr, right, list, startToken; 24545 24546 startToken = lookahead; 24547 token = lookahead; 24548 24549 if (!state.allowYield && matchKeyword('yield')) { 24550 return parseYieldExpression(); 24551 } 24552 24553 expr = parseConditionalExpression(); 24554 24555 if (expr.type === PlaceHolders.ArrowParameterPlaceHolder || match('=>')) { 24556 isAssignmentTarget = isBindingElement = false; 24557 list = reinterpretAsCoverFormalsList(expr); 24558 24559 if (list) { 24560 firstCoverInitializedNameError = null; 24561 return parseArrowFunctionExpression(list, new WrappingNode(startToken)); 24562 } 24563 24564 return expr; 24565 } 24566 24567 if (matchAssign()) { 24568 if (!isAssignmentTarget) { 24569 tolerateError(Messages.InvalidLHSInAssignment); 24570 } 24571 24572 // ECMA-262 12.1.1 24573 if (strict && expr.type === Syntax.Identifier) { 24574 if (isRestrictedWord(expr.name)) { 24575 tolerateUnexpectedToken(token, Messages.StrictLHSAssignment); 24576 } 24577 if (isStrictModeReservedWord(expr.name)) { 24578 tolerateUnexpectedToken(token, Messages.StrictReservedWord); 24579 } 24580 } 24581 24582 if (!match('=')) { 24583 isAssignmentTarget = isBindingElement = false; 24584 } else { 24585 reinterpretExpressionAsPattern(expr); 24586 } 24587 24588 token = lex(); 24589 right = isolateCoverGrammar(parseAssignmentExpression); 24590 expr = new WrappingNode(startToken).finishAssignmentExpression(token.value, expr, right); 24591 firstCoverInitializedNameError = null; 24592 } 24593 24594 return expr; 24595 } 24596 24597 // ECMA-262 12.15 Comma Operator 24598 24599 function parseExpression() { 24600 var expr, startToken = lookahead, expressions; 24601 24602 expr = isolateCoverGrammar(parseAssignmentExpression); 24603 24604 if (match(',')) { 24605 expressions = [expr]; 24606 24607 while (startIndex < length) { 24608 if (!match(',')) { 24609 break; 24610 } 24611 lex(); 24612 expressions.push(isolateCoverGrammar(parseAssignmentExpression)); 24613 } 24614 24615 expr = new WrappingNode(startToken).finishSequenceExpression(expressions); 24616 } 24617 24618 return expr; 24619 } 24620 24621 // ECMA-262 13.2 Block 24622 24623 function parseStatementListItem() { 24624 if (lookahead.type === Token.Keyword) { 24625 switch (lookahead.value) { 24626 case 'export': 24627 if (state.sourceType !== 'module') { 24628 tolerateUnexpectedToken(lookahead, Messages.IllegalExportDeclaration); 24629 } 24630 return parseExportDeclaration(); 24631 case 'import': 24632 if (state.sourceType !== 'module') { 24633 tolerateUnexpectedToken(lookahead, Messages.IllegalImportDeclaration); 24634 } 24635 return parseImportDeclaration(); 24636 case 'const': 24637 return parseLexicalDeclaration({inFor: false}); 24638 case 'function': 24639 return parseFunctionDeclaration(new Node()); 24640 case 'class': 24641 return parseClassDeclaration(); 24642 } 24643 } 24644 24645 if (matchKeyword('let') && isLexicalDeclaration()) { 24646 return parseLexicalDeclaration({inFor: false}); 24647 } 24648 24649 return parseStatement(); 24650 } 24651 24652 function parseStatementList() { 24653 var list = []; 24654 while (startIndex < length) { 24655 if (match('}')) { 24656 break; 24657 } 24658 list.push(parseStatementListItem()); 24659 } 24660 24661 return list; 24662 } 24663 24664 function parseBlock() { 24665 var block, node = new Node(); 24666 24667 expect('{'); 24668 24669 block = parseStatementList(); 24670 24671 expect('}'); 24672 24673 return node.finishBlockStatement(block); 24674 } 24675 24676 // ECMA-262 13.3.2 Variable Statement 24677 24678 function parseVariableIdentifier(kind) { 24679 var token, node = new Node(); 24680 24681 token = lex(); 24682 24683 if (token.type === Token.Keyword && token.value === 'yield') { 24684 if (strict) { 24685 tolerateUnexpectedToken(token, Messages.StrictReservedWord); 24686 } if (!state.allowYield) { 24687 throwUnexpectedToken(token); 24688 } 24689 } else if (token.type !== Token.Identifier) { 24690 if (strict && token.type === Token.Keyword && isStrictModeReservedWord(token.value)) { 24691 tolerateUnexpectedToken(token, Messages.StrictReservedWord); 24692 } else { 24693 if (strict || token.value !== 'let' || kind !== 'var') { 24694 throwUnexpectedToken(token); 24695 } 24696 } 24697 } else if (state.sourceType === 'module' && token.type === Token.Identifier && token.value === 'await') { 24698 tolerateUnexpectedToken(token); 24699 } 24700 24701 return node.finishIdentifier(token.value); 24702 } 24703 24704 function parseVariableDeclaration(options) { 24705 var init = null, id, node = new Node(), params = []; 24706 24707 id = parsePattern(params, 'var'); 24708 24709 // ECMA-262 12.2.1 24710 if (strict && isRestrictedWord(id.name)) { 24711 tolerateError(Messages.StrictVarName); 24712 } 24713 24714 if (match('=')) { 24715 lex(); 24716 init = isolateCoverGrammar(parseAssignmentExpression); 24717 } else if (id.type !== Syntax.Identifier && !options.inFor) { 24718 expect('='); 24719 } 24720 24721 return node.finishVariableDeclarator(id, init); 24722 } 24723 24724 function parseVariableDeclarationList(options) { 24725 var opt, list; 24726 24727 opt = { inFor: options.inFor }; 24728 list = [parseVariableDeclaration(opt)]; 24729 24730 while (match(',')) { 24731 lex(); 24732 list.push(parseVariableDeclaration(opt)); 24733 } 24734 24735 return list; 24736 } 24737 24738 function parseVariableStatement(node) { 24739 var declarations; 24740 24741 expectKeyword('var'); 24742 24743 declarations = parseVariableDeclarationList({ inFor: false }); 24744 24745 consumeSemicolon(); 24746 24747 return node.finishVariableDeclaration(declarations); 24748 } 24749 24750 // ECMA-262 13.3.1 Let and Const Declarations 24751 24752 function parseLexicalBinding(kind, options) { 24753 var init = null, id, node = new Node(), params = []; 24754 24755 id = parsePattern(params, kind); 24756 24757 // ECMA-262 12.2.1 24758 if (strict && id.type === Syntax.Identifier && isRestrictedWord(id.name)) { 24759 tolerateError(Messages.StrictVarName); 24760 } 24761 24762 if (kind === 'const') { 24763 if (!matchKeyword('in') && !matchContextualKeyword('of')) { 24764 expect('='); 24765 init = isolateCoverGrammar(parseAssignmentExpression); 24766 } 24767 } else if ((!options.inFor && id.type !== Syntax.Identifier) || match('=')) { 24768 expect('='); 24769 init = isolateCoverGrammar(parseAssignmentExpression); 24770 } 24771 24772 return node.finishVariableDeclarator(id, init); 24773 } 24774 24775 function parseBindingList(kind, options) { 24776 var list = [parseLexicalBinding(kind, options)]; 24777 24778 while (match(',')) { 24779 lex(); 24780 list.push(parseLexicalBinding(kind, options)); 24781 } 24782 24783 return list; 24784 } 24785 24786 24787 function tokenizerState() { 24788 return { 24789 index: index, 24790 lineNumber: lineNumber, 24791 lineStart: lineStart, 24792 hasLineTerminator: hasLineTerminator, 24793 lastIndex: lastIndex, 24794 lastLineNumber: lastLineNumber, 24795 lastLineStart: lastLineStart, 24796 startIndex: startIndex, 24797 startLineNumber: startLineNumber, 24798 startLineStart: startLineStart, 24799 lookahead: lookahead, 24800 tokenCount: extra.tokens ? extra.tokens.length : 0 24801 }; 24802 } 24803 24804 function resetTokenizerState(ts) { 24805 index = ts.index; 24806 lineNumber = ts.lineNumber; 24807 lineStart = ts.lineStart; 24808 hasLineTerminator = ts.hasLineTerminator; 24809 lastIndex = ts.lastIndex; 24810 lastLineNumber = ts.lastLineNumber; 24811 lastLineStart = ts.lastLineStart; 24812 startIndex = ts.startIndex; 24813 startLineNumber = ts.startLineNumber; 24814 startLineStart = ts.startLineStart; 24815 lookahead = ts.lookahead; 24816 if (extra.tokens) { 24817 extra.tokens.splice(ts.tokenCount, extra.tokens.length); 24818 } 24819 } 24820 24821 function isLexicalDeclaration() { 24822 var lexical, ts; 24823 24824 ts = tokenizerState(); 24825 24826 lex(); 24827 lexical = (lookahead.type === Token.Identifier) || match('[') || match('{') || 24828 matchKeyword('let') || matchKeyword('yield'); 24829 24830 resetTokenizerState(ts); 24831 24832 return lexical; 24833 } 24834 24835 function parseLexicalDeclaration(options) { 24836 var kind, declarations, node = new Node(); 24837 24838 kind = lex().value; 24839 assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const'); 24840 24841 declarations = parseBindingList(kind, options); 24842 24843 consumeSemicolon(); 24844 24845 return node.finishLexicalDeclaration(declarations, kind); 24846 } 24847 24848 function parseRestElement(params) { 24849 var param, node = new Node(); 24850 24851 lex(); 24852 24853 if (match('{')) { 24854 throwError(Messages.ObjectPatternAsRestParameter); 24855 } 24856 24857 params.push(lookahead); 24858 24859 param = parseVariableIdentifier(); 24860 24861 if (match('=')) { 24862 throwError(Messages.DefaultRestParameter); 24863 } 24864 24865 if (!match(')')) { 24866 throwError(Messages.ParameterAfterRestParameter); 24867 } 24868 24869 return node.finishRestElement(param); 24870 } 24871 24872 // ECMA-262 13.4 Empty Statement 24873 24874 function parseEmptyStatement(node) { 24875 expect(';'); 24876 return node.finishEmptyStatement(); 24877 } 24878 24879 // ECMA-262 12.4 Expression Statement 24880 24881 function parseExpressionStatement(node) { 24882 var expr = parseExpression(); 24883 consumeSemicolon(); 24884 return node.finishExpressionStatement(expr); 24885 } 24886 24887 // ECMA-262 13.6 If statement 24888 24889 function parseIfStatement(node) { 24890 var test, consequent, alternate; 24891 24892 expectKeyword('if'); 24893 24894 expect('('); 24895 24896 test = parseExpression(); 24897 24898 expect(')'); 24899 24900 consequent = parseStatement(); 24901 24902 if (matchKeyword('else')) { 24903 lex(); 24904 alternate = parseStatement(); 24905 } else { 24906 alternate = null; 24907 } 24908 24909 return node.finishIfStatement(test, consequent, alternate); 24910 } 24911 24912 // ECMA-262 13.7 Iteration Statements 24913 24914 function parseDoWhileStatement(node) { 24915 var body, test, oldInIteration; 24916 24917 expectKeyword('do'); 24918 24919 oldInIteration = state.inIteration; 24920 state.inIteration = true; 24921 24922 body = parseStatement(); 24923 24924 state.inIteration = oldInIteration; 24925 24926 expectKeyword('while'); 24927 24928 expect('('); 24929 24930 test = parseExpression(); 24931 24932 expect(')'); 24933 24934 if (match(';')) { 24935 lex(); 24936 } 24937 24938 return node.finishDoWhileStatement(body, test); 24939 } 24940 24941 function parseWhileStatement(node) { 24942 var test, body, oldInIteration; 24943 24944 expectKeyword('while'); 24945 24946 expect('('); 24947 24948 test = parseExpression(); 24949 24950 expect(')'); 24951 24952 oldInIteration = state.inIteration; 24953 state.inIteration = true; 24954 24955 body = parseStatement(); 24956 24957 state.inIteration = oldInIteration; 24958 24959 return node.finishWhileStatement(test, body); 24960 } 24961 24962 function parseForStatement(node) { 24963 var init, forIn, initSeq, initStartToken, test, update, left, right, kind, declarations, 24964 body, oldInIteration, previousAllowIn = state.allowIn; 24965 24966 init = test = update = null; 24967 forIn = true; 24968 24969 expectKeyword('for'); 24970 24971 expect('('); 24972 24973 if (match(';')) { 24974 lex(); 24975 } else { 24976 if (matchKeyword('var')) { 24977 init = new Node(); 24978 lex(); 24979 24980 state.allowIn = false; 24981 declarations = parseVariableDeclarationList({ inFor: true }); 24982 state.allowIn = previousAllowIn; 24983 24984 if (declarations.length === 1 && matchKeyword('in')) { 24985 init = init.finishVariableDeclaration(declarations); 24986 lex(); 24987 left = init; 24988 right = parseExpression(); 24989 init = null; 24990 } else if (declarations.length === 1 && declarations[0].init === null && matchContextualKeyword('of')) { 24991 init = init.finishVariableDeclaration(declarations); 24992 lex(); 24993 left = init; 24994 right = parseAssignmentExpression(); 24995 init = null; 24996 forIn = false; 24997 } else { 24998 init = init.finishVariableDeclaration(declarations); 24999 expect(';'); 25000 } 25001 } else if (matchKeyword('const') || matchKeyword('let')) { 25002 init = new Node(); 25003 kind = lex().value; 25004 25005 if (!strict && lookahead.value === 'in') { 25006 init = init.finishIdentifier(kind); 25007 lex(); 25008 left = init; 25009 right = parseExpression(); 25010 init = null; 25011 } else { 25012 state.allowIn = false; 25013 declarations = parseBindingList(kind, {inFor: true}); 25014 state.allowIn = previousAllowIn; 25015 25016 if (declarations.length === 1 && declarations[0].init === null && matchKeyword('in')) { 25017 init = init.finishLexicalDeclaration(declarations, kind); 25018 lex(); 25019 left = init; 25020 right = parseExpression(); 25021 init = null; 25022 } else if (declarations.length === 1 && declarations[0].init === null && matchContextualKeyword('of')) { 25023 init = init.finishLexicalDeclaration(declarations, kind); 25024 lex(); 25025 left = init; 25026 right = parseAssignmentExpression(); 25027 init = null; 25028 forIn = false; 25029 } else { 25030 consumeSemicolon(); 25031 init = init.finishLexicalDeclaration(declarations, kind); 25032 } 25033 } 25034 } else { 25035 initStartToken = lookahead; 25036 state.allowIn = false; 25037 init = inheritCoverGrammar(parseAssignmentExpression); 25038 state.allowIn = previousAllowIn; 25039 25040 if (matchKeyword('in')) { 25041 if (!isAssignmentTarget) { 25042 tolerateError(Messages.InvalidLHSInForIn); 25043 } 25044 25045 lex(); 25046 reinterpretExpressionAsPattern(init); 25047 left = init; 25048 right = parseExpression(); 25049 init = null; 25050 } else if (matchContextualKeyword('of')) { 25051 if (!isAssignmentTarget) { 25052 tolerateError(Messages.InvalidLHSInForLoop); 25053 } 25054 25055 lex(); 25056 reinterpretExpressionAsPattern(init); 25057 left = init; 25058 right = parseAssignmentExpression(); 25059 init = null; 25060 forIn = false; 25061 } else { 25062 if (match(',')) { 25063 initSeq = [init]; 25064 while (match(',')) { 25065 lex(); 25066 initSeq.push(isolateCoverGrammar(parseAssignmentExpression)); 25067 } 25068 init = new WrappingNode(initStartToken).finishSequenceExpression(initSeq); 25069 } 25070 expect(';'); 25071 } 25072 } 25073 } 25074 25075 if (typeof left === 'undefined') { 25076 25077 if (!match(';')) { 25078 test = parseExpression(); 25079 } 25080 expect(';'); 25081 25082 if (!match(')')) { 25083 update = parseExpression(); 25084 } 25085 } 25086 25087 expect(')'); 25088 25089 oldInIteration = state.inIteration; 25090 state.inIteration = true; 25091 25092 body = isolateCoverGrammar(parseStatement); 25093 25094 state.inIteration = oldInIteration; 25095 25096 return (typeof left === 'undefined') ? 25097 node.finishForStatement(init, test, update, body) : 25098 forIn ? node.finishForInStatement(left, right, body) : 25099 node.finishForOfStatement(left, right, body); 25100 } 25101 25102 // ECMA-262 13.8 The continue statement 25103 25104 function parseContinueStatement(node) { 25105 var label = null, key; 25106 25107 expectKeyword('continue'); 25108 25109 // Optimize the most common form: 'continue;'. 25110 if (source.charCodeAt(startIndex) === 0x3B) { 25111 lex(); 25112 25113 if (!state.inIteration) { 25114 throwError(Messages.IllegalContinue); 25115 } 25116 25117 return node.finishContinueStatement(null); 25118 } 25119 25120 if (hasLineTerminator) { 25121 if (!state.inIteration) { 25122 throwError(Messages.IllegalContinue); 25123 } 25124 25125 return node.finishContinueStatement(null); 25126 } 25127 25128 if (lookahead.type === Token.Identifier) { 25129 label = parseVariableIdentifier(); 25130 25131 key = '$' + label.name; 25132 if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { 25133 throwError(Messages.UnknownLabel, label.name); 25134 } 25135 } 25136 25137 consumeSemicolon(); 25138 25139 if (label === null && !state.inIteration) { 25140 throwError(Messages.IllegalContinue); 25141 } 25142 25143 return node.finishContinueStatement(label); 25144 } 25145 25146 // ECMA-262 13.9 The break statement 25147 25148 function parseBreakStatement(node) { 25149 var label = null, key; 25150 25151 expectKeyword('break'); 25152 25153 // Catch the very common case first: immediately a semicolon (U+003B). 25154 if (source.charCodeAt(lastIndex) === 0x3B) { 25155 lex(); 25156 25157 if (!(state.inIteration || state.inSwitch)) { 25158 throwError(Messages.IllegalBreak); 25159 } 25160 25161 return node.finishBreakStatement(null); 25162 } 25163 25164 if (hasLineTerminator) { 25165 if (!(state.inIteration || state.inSwitch)) { 25166 throwError(Messages.IllegalBreak); 25167 } 25168 } else if (lookahead.type === Token.Identifier) { 25169 label = parseVariableIdentifier(); 25170 25171 key = '$' + label.name; 25172 if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { 25173 throwError(Messages.UnknownLabel, label.name); 25174 } 25175 } 25176 25177 consumeSemicolon(); 25178 25179 if (label === null && !(state.inIteration || state.inSwitch)) { 25180 throwError(Messages.IllegalBreak); 25181 } 25182 25183 return node.finishBreakStatement(label); 25184 } 25185 25186 // ECMA-262 13.10 The return statement 25187 25188 function parseReturnStatement(node) { 25189 var argument = null; 25190 25191 expectKeyword('return'); 25192 25193 if (!state.inFunctionBody) { 25194 tolerateError(Messages.IllegalReturn); 25195 } 25196 25197 // 'return' followed by a space and an identifier is very common. 25198 if (source.charCodeAt(lastIndex) === 0x20) { 25199 if (isIdentifierStart(source.charCodeAt(lastIndex + 1))) { 25200 argument = parseExpression(); 25201 consumeSemicolon(); 25202 return node.finishReturnStatement(argument); 25203 } 25204 } 25205 25206 if (hasLineTerminator) { 25207 // HACK 25208 return node.finishReturnStatement(null); 25209 } 25210 25211 if (!match(';')) { 25212 if (!match('}') && lookahead.type !== Token.EOF) { 25213 argument = parseExpression(); 25214 } 25215 } 25216 25217 consumeSemicolon(); 25218 25219 return node.finishReturnStatement(argument); 25220 } 25221 25222 // ECMA-262 13.11 The with statement 25223 25224 function parseWithStatement(node) { 25225 var object, body; 25226 25227 if (strict) { 25228 tolerateError(Messages.StrictModeWith); 25229 } 25230 25231 expectKeyword('with'); 25232 25233 expect('('); 25234 25235 object = parseExpression(); 25236 25237 expect(')'); 25238 25239 body = parseStatement(); 25240 25241 return node.finishWithStatement(object, body); 25242 } 25243 25244 // ECMA-262 13.12 The switch statement 25245 25246 function parseSwitchCase() { 25247 var test, consequent = [], statement, node = new Node(); 25248 25249 if (matchKeyword('default')) { 25250 lex(); 25251 test = null; 25252 } else { 25253 expectKeyword('case'); 25254 test = parseExpression(); 25255 } 25256 expect(':'); 25257 25258 while (startIndex < length) { 25259 if (match('}') || matchKeyword('default') || matchKeyword('case')) { 25260 break; 25261 } 25262 statement = parseStatementListItem(); 25263 consequent.push(statement); 25264 } 25265 25266 return node.finishSwitchCase(test, consequent); 25267 } 25268 25269 function parseSwitchStatement(node) { 25270 var discriminant, cases, clause, oldInSwitch, defaultFound; 25271 25272 expectKeyword('switch'); 25273 25274 expect('('); 25275 25276 discriminant = parseExpression(); 25277 25278 expect(')'); 25279 25280 expect('{'); 25281 25282 cases = []; 25283 25284 if (match('}')) { 25285 lex(); 25286 return node.finishSwitchStatement(discriminant, cases); 25287 } 25288 25289 oldInSwitch = state.inSwitch; 25290 state.inSwitch = true; 25291 defaultFound = false; 25292 25293 while (startIndex < length) { 25294 if (match('}')) { 25295 break; 25296 } 25297 clause = parseSwitchCase(); 25298 if (clause.test === null) { 25299 if (defaultFound) { 25300 throwError(Messages.MultipleDefaultsInSwitch); 25301 } 25302 defaultFound = true; 25303 } 25304 cases.push(clause); 25305 } 25306 25307 state.inSwitch = oldInSwitch; 25308 25309 expect('}'); 25310 25311 return node.finishSwitchStatement(discriminant, cases); 25312 } 25313 25314 // ECMA-262 13.14 The throw statement 25315 25316 function parseThrowStatement(node) { 25317 var argument; 25318 25319 expectKeyword('throw'); 25320 25321 if (hasLineTerminator) { 25322 throwError(Messages.NewlineAfterThrow); 25323 } 25324 25325 argument = parseExpression(); 25326 25327 consumeSemicolon(); 25328 25329 return node.finishThrowStatement(argument); 25330 } 25331 25332 // ECMA-262 13.15 The try statement 25333 25334 function parseCatchClause() { 25335 var param, params = [], paramMap = {}, key, i, body, node = new Node(); 25336 25337 expectKeyword('catch'); 25338 25339 expect('('); 25340 if (match(')')) { 25341 throwUnexpectedToken(lookahead); 25342 } 25343 25344 param = parsePattern(params); 25345 for (i = 0; i < params.length; i++) { 25346 key = '$' + params[i].value; 25347 if (Object.prototype.hasOwnProperty.call(paramMap, key)) { 25348 tolerateError(Messages.DuplicateBinding, params[i].value); 25349 } 25350 paramMap[key] = true; 25351 } 25352 25353 // ECMA-262 12.14.1 25354 if (strict && isRestrictedWord(param.name)) { 25355 tolerateError(Messages.StrictCatchVariable); 25356 } 25357 25358 expect(')'); 25359 body = parseBlock(); 25360 return node.finishCatchClause(param, body); 25361 } 25362 25363 function parseTryStatement(node) { 25364 var block, handler = null, finalizer = null; 25365 25366 expectKeyword('try'); 25367 25368 block = parseBlock(); 25369 25370 if (matchKeyword('catch')) { 25371 handler = parseCatchClause(); 25372 } 25373 25374 if (matchKeyword('finally')) { 25375 lex(); 25376 finalizer = parseBlock(); 25377 } 25378 25379 if (!handler && !finalizer) { 25380 throwError(Messages.NoCatchOrFinally); 25381 } 25382 25383 return node.finishTryStatement(block, handler, finalizer); 25384 } 25385 25386 // ECMA-262 13.16 The debugger statement 25387 25388 function parseDebuggerStatement(node) { 25389 expectKeyword('debugger'); 25390 25391 consumeSemicolon(); 25392 25393 return node.finishDebuggerStatement(); 25394 } 25395 25396 // 13 Statements 25397 25398 function parseStatement() { 25399 var type = lookahead.type, 25400 expr, 25401 labeledBody, 25402 key, 25403 node; 25404 25405 if (type === Token.EOF) { 25406 throwUnexpectedToken(lookahead); 25407 } 25408 25409 if (type === Token.Punctuator && lookahead.value === '{') { 25410 return parseBlock(); 25411 } 25412 isAssignmentTarget = isBindingElement = true; 25413 node = new Node(); 25414 25415 if (type === Token.Punctuator) { 25416 switch (lookahead.value) { 25417 case ';': 25418 return parseEmptyStatement(node); 25419 case '(': 25420 return parseExpressionStatement(node); 25421 default: 25422 break; 25423 } 25424 } else if (type === Token.Keyword) { 25425 switch (lookahead.value) { 25426 case 'break': 25427 return parseBreakStatement(node); 25428 case 'continue': 25429 return parseContinueStatement(node); 25430 case 'debugger': 25431 return parseDebuggerStatement(node); 25432 case 'do': 25433 return parseDoWhileStatement(node); 25434 case 'for': 25435 return parseForStatement(node); 25436 case 'function': 25437 return parseFunctionDeclaration(node); 25438 case 'if': 25439 return parseIfStatement(node); 25440 case 'return': 25441 return parseReturnStatement(node); 25442 case 'switch': 25443 return parseSwitchStatement(node); 25444 case 'throw': 25445 return parseThrowStatement(node); 25446 case 'try': 25447 return parseTryStatement(node); 25448 case 'var': 25449 return parseVariableStatement(node); 25450 case 'while': 25451 return parseWhileStatement(node); 25452 case 'with': 25453 return parseWithStatement(node); 25454 default: 25455 break; 25456 } 25457 } 25458 25459 expr = parseExpression(); 25460 25461 // ECMA-262 12.12 Labelled Statements 25462 if ((expr.type === Syntax.Identifier) && match(':')) { 25463 lex(); 25464 25465 key = '$' + expr.name; 25466 if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) { 25467 throwError(Messages.Redeclaration, 'Label', expr.name); 25468 } 25469 25470 state.labelSet[key] = true; 25471 labeledBody = parseStatement(); 25472 delete state.labelSet[key]; 25473 return node.finishLabeledStatement(expr, labeledBody); 25474 } 25475 25476 consumeSemicolon(); 25477 25478 return node.finishExpressionStatement(expr); 25479 } 25480 25481 // ECMA-262 14.1 Function Definition 25482 25483 function parseFunctionSourceElements() { 25484 var statement, body = [], token, directive, firstRestricted, 25485 oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, 25486 node = new Node(); 25487 25488 expect('{'); 25489 25490 while (startIndex < length) { 25491 if (lookahead.type !== Token.StringLiteral) { 25492 break; 25493 } 25494 token = lookahead; 25495 25496 statement = parseStatementListItem(); 25497 body.push(statement); 25498 if (statement.expression.type !== Syntax.Literal) { 25499 // this is not directive 25500 break; 25501 } 25502 directive = source.slice(token.start + 1, token.end - 1); 25503 if (directive === 'use strict') { 25504 strict = true; 25505 if (firstRestricted) { 25506 tolerateUnexpectedToken(firstRestricted, Messages.StrictOctalLiteral); 25507 } 25508 } else { 25509 if (!firstRestricted && token.octal) { 25510 firstRestricted = token; 25511 } 25512 } 25513 } 25514 25515 oldLabelSet = state.labelSet; 25516 oldInIteration = state.inIteration; 25517 oldInSwitch = state.inSwitch; 25518 oldInFunctionBody = state.inFunctionBody; 25519 25520 state.labelSet = {}; 25521 state.inIteration = false; 25522 state.inSwitch = false; 25523 state.inFunctionBody = true; 25524 25525 while (startIndex < length) { 25526 if (match('}')) { 25527 break; 25528 } 25529 body.push(parseStatementListItem()); 25530 } 25531 25532 expect('}'); 25533 25534 state.labelSet = oldLabelSet; 25535 state.inIteration = oldInIteration; 25536 state.inSwitch = oldInSwitch; 25537 state.inFunctionBody = oldInFunctionBody; 25538 25539 return node.finishBlockStatement(body); 25540 } 25541 25542 function validateParam(options, param, name) { 25543 var key = '$' + name; 25544 if (strict) { 25545 if (isRestrictedWord(name)) { 25546 options.stricted = param; 25547 options.message = Messages.StrictParamName; 25548 } 25549 if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) { 25550 options.stricted = param; 25551 options.message = Messages.StrictParamDupe; 25552 } 25553 } else if (!options.firstRestricted) { 25554 if (isRestrictedWord(name)) { 25555 options.firstRestricted = param; 25556 options.message = Messages.StrictParamName; 25557 } else if (isStrictModeReservedWord(name)) { 25558 options.firstRestricted = param; 25559 options.message = Messages.StrictReservedWord; 25560 } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) { 25561 options.stricted = param; 25562 options.message = Messages.StrictParamDupe; 25563 } 25564 } 25565 options.paramSet[key] = true; 25566 } 25567 25568 function parseParam(options) { 25569 var token, param, params = [], i, def; 25570 25571 token = lookahead; 25572 if (token.value === '...') { 25573 param = parseRestElement(params); 25574 validateParam(options, param.argument, param.argument.name); 25575 options.params.push(param); 25576 options.defaults.push(null); 25577 return false; 25578 } 25579 25580 param = parsePatternWithDefault(params); 25581 for (i = 0; i < params.length; i++) { 25582 validateParam(options, params[i], params[i].value); 25583 } 25584 25585 if (param.type === Syntax.AssignmentPattern) { 25586 def = param.right; 25587 param = param.left; 25588 ++options.defaultCount; 25589 } 25590 25591 options.params.push(param); 25592 options.defaults.push(def); 25593 25594 return !match(')'); 25595 } 25596 25597 function parseParams(firstRestricted) { 25598 var options; 25599 25600 options = { 25601 params: [], 25602 defaultCount: 0, 25603 defaults: [], 25604 firstRestricted: firstRestricted 25605 }; 25606 25607 expect('('); 25608 25609 if (!match(')')) { 25610 options.paramSet = {}; 25611 while (startIndex < length) { 25612 if (!parseParam(options)) { 25613 break; 25614 } 25615 expect(','); 25616 } 25617 } 25618 25619 expect(')'); 25620 25621 if (options.defaultCount === 0) { 25622 options.defaults = []; 25623 } 25624 25625 return { 25626 params: options.params, 25627 defaults: options.defaults, 25628 stricted: options.stricted, 25629 firstRestricted: options.firstRestricted, 25630 message: options.message 25631 }; 25632 } 25633 25634 function parseFunctionDeclaration(node, identifierIsOptional) { 25635 var id = null, params = [], defaults = [], body, token, stricted, tmp, firstRestricted, message, previousStrict, 25636 isGenerator, previousAllowYield; 25637 25638 previousAllowYield = state.allowYield; 25639 25640 expectKeyword('function'); 25641 25642 isGenerator = match('*'); 25643 if (isGenerator) { 25644 lex(); 25645 } 25646 25647 if (!identifierIsOptional || !match('(')) { 25648 token = lookahead; 25649 id = parseVariableIdentifier(); 25650 if (strict) { 25651 if (isRestrictedWord(token.value)) { 25652 tolerateUnexpectedToken(token, Messages.StrictFunctionName); 25653 } 25654 } else { 25655 if (isRestrictedWord(token.value)) { 25656 firstRestricted = token; 25657 message = Messages.StrictFunctionName; 25658 } else if (isStrictModeReservedWord(token.value)) { 25659 firstRestricted = token; 25660 message = Messages.StrictReservedWord; 25661 } 25662 } 25663 } 25664 25665 state.allowYield = !isGenerator; 25666 tmp = parseParams(firstRestricted); 25667 params = tmp.params; 25668 defaults = tmp.defaults; 25669 stricted = tmp.stricted; 25670 firstRestricted = tmp.firstRestricted; 25671 if (tmp.message) { 25672 message = tmp.message; 25673 } 25674 25675 25676 previousStrict = strict; 25677 body = parseFunctionSourceElements(); 25678 if (strict && firstRestricted) { 25679 throwUnexpectedToken(firstRestricted, message); 25680 } 25681 if (strict && stricted) { 25682 tolerateUnexpectedToken(stricted, message); 25683 } 25684 25685 strict = previousStrict; 25686 state.allowYield = previousAllowYield; 25687 25688 return node.finishFunctionDeclaration(id, params, defaults, body, isGenerator); 25689 } 25690 25691 function parseFunctionExpression() { 25692 var token, id = null, stricted, firstRestricted, message, tmp, 25693 params = [], defaults = [], body, previousStrict, node = new Node(), 25694 isGenerator, previousAllowYield; 25695 25696 previousAllowYield = state.allowYield; 25697 25698 expectKeyword('function'); 25699 25700 isGenerator = match('*'); 25701 if (isGenerator) { 25702 lex(); 25703 } 25704 25705 state.allowYield = !isGenerator; 25706 if (!match('(')) { 25707 token = lookahead; 25708 id = (!strict && !isGenerator && matchKeyword('yield')) ? parseNonComputedProperty() : parseVariableIdentifier(); 25709 if (strict) { 25710 if (isRestrictedWord(token.value)) { 25711 tolerateUnexpectedToken(token, Messages.StrictFunctionName); 25712 } 25713 } else { 25714 if (isRestrictedWord(token.value)) { 25715 firstRestricted = token; 25716 message = Messages.StrictFunctionName; 25717 } else if (isStrictModeReservedWord(token.value)) { 25718 firstRestricted = token; 25719 message = Messages.StrictReservedWord; 25720 } 25721 } 25722 } 25723 25724 tmp = parseParams(firstRestricted); 25725 params = tmp.params; 25726 defaults = tmp.defaults; 25727 stricted = tmp.stricted; 25728 firstRestricted = tmp.firstRestricted; 25729 if (tmp.message) { 25730 message = tmp.message; 25731 } 25732 25733 previousStrict = strict; 25734 body = parseFunctionSourceElements(); 25735 if (strict && firstRestricted) { 25736 throwUnexpectedToken(firstRestricted, message); 25737 } 25738 if (strict && stricted) { 25739 tolerateUnexpectedToken(stricted, message); 25740 } 25741 strict = previousStrict; 25742 state.allowYield = previousAllowYield; 25743 25744 return node.finishFunctionExpression(id, params, defaults, body, isGenerator); 25745 } 25746 25747 // ECMA-262 14.5 Class Definitions 25748 25749 function parseClassBody() { 25750 var classBody, token, isStatic, hasConstructor = false, body, method, computed, key; 25751 25752 classBody = new Node(); 25753 25754 expect('{'); 25755 body = []; 25756 while (!match('}')) { 25757 if (match(';')) { 25758 lex(); 25759 } else { 25760 method = new Node(); 25761 token = lookahead; 25762 isStatic = false; 25763 computed = match('['); 25764 if (match('*')) { 25765 lex(); 25766 } else { 25767 key = parseObjectPropertyKey(); 25768 if (key.name === 'static' && (lookaheadPropertyName() || match('*'))) { 25769 token = lookahead; 25770 isStatic = true; 25771 computed = match('['); 25772 if (match('*')) { 25773 lex(); 25774 } else { 25775 key = parseObjectPropertyKey(); 25776 } 25777 } 25778 } 25779 method = tryParseMethodDefinition(token, key, computed, method); 25780 if (method) { 25781 method['static'] = isStatic; // jscs:ignore requireDotNotation 25782 if (method.kind === 'init') { 25783 method.kind = 'method'; 25784 } 25785 if (!isStatic) { 25786 if (!method.computed && (method.key.name || method.key.value.toString()) === 'constructor') { 25787 if (method.kind !== 'method' || !method.method || method.value.generator) { 25788 throwUnexpectedToken(token, Messages.ConstructorSpecialMethod); 25789 } 25790 if (hasConstructor) { 25791 throwUnexpectedToken(token, Messages.DuplicateConstructor); 25792 } else { 25793 hasConstructor = true; 25794 } 25795 method.kind = 'constructor'; 25796 } 25797 } else { 25798 if (!method.computed && (method.key.name || method.key.value.toString()) === 'prototype') { 25799 throwUnexpectedToken(token, Messages.StaticPrototype); 25800 } 25801 } 25802 method.type = Syntax.MethodDefinition; 25803 delete method.method; 25804 delete method.shorthand; 25805 body.push(method); 25806 } else { 25807 throwUnexpectedToken(lookahead); 25808 } 25809 } 25810 } 25811 lex(); 25812 return classBody.finishClassBody(body); 25813 } 25814 25815 function parseClassDeclaration(identifierIsOptional) { 25816 var id = null, superClass = null, classNode = new Node(), classBody, previousStrict = strict; 25817 strict = true; 25818 25819 expectKeyword('class'); 25820 25821 if (!identifierIsOptional || lookahead.type === Token.Identifier) { 25822 id = parseVariableIdentifier(); 25823 } 25824 25825 if (matchKeyword('extends')) { 25826 lex(); 25827 superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall); 25828 } 25829 classBody = parseClassBody(); 25830 strict = previousStrict; 25831 25832 return classNode.finishClassDeclaration(id, superClass, classBody); 25833 } 25834 25835 function parseClassExpression() { 25836 var id = null, superClass = null, classNode = new Node(), classBody, previousStrict = strict; 25837 strict = true; 25838 25839 expectKeyword('class'); 25840 25841 if (lookahead.type === Token.Identifier) { 25842 id = parseVariableIdentifier(); 25843 } 25844 25845 if (matchKeyword('extends')) { 25846 lex(); 25847 superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall); 25848 } 25849 classBody = parseClassBody(); 25850 strict = previousStrict; 25851 25852 return classNode.finishClassExpression(id, superClass, classBody); 25853 } 25854 25855 // ECMA-262 15.2 Modules 25856 25857 function parseModuleSpecifier() { 25858 var node = new Node(); 25859 25860 if (lookahead.type !== Token.StringLiteral) { 25861 throwError(Messages.InvalidModuleSpecifier); 25862 } 25863 return node.finishLiteral(lex()); 25864 } 25865 25866 // ECMA-262 15.2.3 Exports 25867 25868 function parseExportSpecifier() { 25869 var exported, local, node = new Node(), def; 25870 if (matchKeyword('default')) { 25871 // export {default} from 'something'; 25872 def = new Node(); 25873 lex(); 25874 local = def.finishIdentifier('default'); 25875 } else { 25876 local = parseVariableIdentifier(); 25877 } 25878 if (matchContextualKeyword('as')) { 25879 lex(); 25880 exported = parseNonComputedProperty(); 25881 } 25882 return node.finishExportSpecifier(local, exported); 25883 } 25884 25885 function parseExportNamedDeclaration(node) { 25886 var declaration = null, 25887 isExportFromIdentifier, 25888 src = null, specifiers = []; 25889 25890 // non-default export 25891 if (lookahead.type === Token.Keyword) { 25892 // covers: 25893 // export var f = 1; 25894 switch (lookahead.value) { 25895 case 'let': 25896 case 'const': 25897 declaration = parseLexicalDeclaration({inFor: false}); 25898 return node.finishExportNamedDeclaration(declaration, specifiers, null); 25899 case 'var': 25900 case 'class': 25901 case 'function': 25902 declaration = parseStatementListItem(); 25903 return node.finishExportNamedDeclaration(declaration, specifiers, null); 25904 } 25905 } 25906 25907 expect('{'); 25908 while (!match('}')) { 25909 isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default'); 25910 specifiers.push(parseExportSpecifier()); 25911 if (!match('}')) { 25912 expect(','); 25913 if (match('}')) { 25914 break; 25915 } 25916 } 25917 } 25918 expect('}'); 25919 25920 if (matchContextualKeyword('from')) { 25921 // covering: 25922 // export {default} from 'foo'; 25923 // export {foo} from 'foo'; 25924 lex(); 25925 src = parseModuleSpecifier(); 25926 consumeSemicolon(); 25927 } else if (isExportFromIdentifier) { 25928 // covering: 25929 // export {default}; // missing fromClause 25930 throwError(lookahead.value ? 25931 Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); 25932 } else { 25933 // cover 25934 // export {foo}; 25935 consumeSemicolon(); 25936 } 25937 return node.finishExportNamedDeclaration(declaration, specifiers, src); 25938 } 25939 25940 function parseExportDefaultDeclaration(node) { 25941 var declaration = null, 25942 expression = null; 25943 25944 // covers: 25945 // export default ... 25946 expectKeyword('default'); 25947 25948 if (matchKeyword('function')) { 25949 // covers: 25950 // export default function foo () {} 25951 // export default function () {} 25952 declaration = parseFunctionDeclaration(new Node(), true); 25953 return node.finishExportDefaultDeclaration(declaration); 25954 } 25955 if (matchKeyword('class')) { 25956 declaration = parseClassDeclaration(true); 25957 return node.finishExportDefaultDeclaration(declaration); 25958 } 25959 25960 if (matchContextualKeyword('from')) { 25961 throwError(Messages.UnexpectedToken, lookahead.value); 25962 } 25963 25964 // covers: 25965 // export default {}; 25966 // export default []; 25967 // export default (1 + 2); 25968 if (match('{')) { 25969 expression = parseObjectInitializer(); 25970 } else if (match('[')) { 25971 expression = parseArrayInitializer(); 25972 } else { 25973 expression = parseAssignmentExpression(); 25974 } 25975 consumeSemicolon(); 25976 return node.finishExportDefaultDeclaration(expression); 25977 } 25978 25979 function parseExportAllDeclaration(node) { 25980 var src; 25981 25982 // covers: 25983 // export * from 'foo'; 25984 expect('*'); 25985 if (!matchContextualKeyword('from')) { 25986 throwError(lookahead.value ? 25987 Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); 25988 } 25989 lex(); 25990 src = parseModuleSpecifier(); 25991 consumeSemicolon(); 25992 25993 return node.finishExportAllDeclaration(src); 25994 } 25995 25996 function parseExportDeclaration() { 25997 var node = new Node(); 25998 if (state.inFunctionBody) { 25999 throwError(Messages.IllegalExportDeclaration); 26000 } 26001 26002 expectKeyword('export'); 26003 26004 if (matchKeyword('default')) { 26005 return parseExportDefaultDeclaration(node); 26006 } 26007 if (match('*')) { 26008 return parseExportAllDeclaration(node); 26009 } 26010 return parseExportNamedDeclaration(node); 26011 } 26012 26013 // ECMA-262 15.2.2 Imports 26014 26015 function parseImportSpecifier() { 26016 // import {<foo as bar>} ...; 26017 var local, imported, node = new Node(); 26018 26019 imported = parseNonComputedProperty(); 26020 if (matchContextualKeyword('as')) { 26021 lex(); 26022 local = parseVariableIdentifier(); 26023 } 26024 26025 return node.finishImportSpecifier(local, imported); 26026 } 26027 26028 function parseNamedImports() { 26029 var specifiers = []; 26030 // {foo, bar as bas} 26031 expect('{'); 26032 while (!match('}')) { 26033 specifiers.push(parseImportSpecifier()); 26034 if (!match('}')) { 26035 expect(','); 26036 if (match('}')) { 26037 break; 26038 } 26039 } 26040 } 26041 expect('}'); 26042 return specifiers; 26043 } 26044 26045 function parseImportDefaultSpecifier() { 26046 // import <foo> ...; 26047 var local, node = new Node(); 26048 26049 local = parseNonComputedProperty(); 26050 26051 return node.finishImportDefaultSpecifier(local); 26052 } 26053 26054 function parseImportNamespaceSpecifier() { 26055 // import <* as foo> ...; 26056 var local, node = new Node(); 26057 26058 expect('*'); 26059 if (!matchContextualKeyword('as')) { 26060 throwError(Messages.NoAsAfterImportNamespace); 26061 } 26062 lex(); 26063 local = parseNonComputedProperty(); 26064 26065 return node.finishImportNamespaceSpecifier(local); 26066 } 26067 26068 function parseImportDeclaration() { 26069 var specifiers = [], src, node = new Node(); 26070 26071 if (state.inFunctionBody) { 26072 throwError(Messages.IllegalImportDeclaration); 26073 } 26074 26075 expectKeyword('import'); 26076 26077 if (lookahead.type === Token.StringLiteral) { 26078 // import 'foo'; 26079 src = parseModuleSpecifier(); 26080 } else { 26081 26082 if (match('{')) { 26083 // import {bar} 26084 specifiers = specifiers.concat(parseNamedImports()); 26085 } else if (match('*')) { 26086 // import * as foo 26087 specifiers.push(parseImportNamespaceSpecifier()); 26088 } else if (isIdentifierName(lookahead) && !matchKeyword('default')) { 26089 // import foo 26090 specifiers.push(parseImportDefaultSpecifier()); 26091 if (match(',')) { 26092 lex(); 26093 if (match('*')) { 26094 // import foo, * as foo 26095 specifiers.push(parseImportNamespaceSpecifier()); 26096 } else if (match('{')) { 26097 // import foo, {bar} 26098 specifiers = specifiers.concat(parseNamedImports()); 26099 } else { 26100 throwUnexpectedToken(lookahead); 26101 } 26102 } 26103 } else { 26104 throwUnexpectedToken(lex()); 26105 } 26106 26107 if (!matchContextualKeyword('from')) { 26108 throwError(lookahead.value ? 26109 Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); 26110 } 26111 lex(); 26112 src = parseModuleSpecifier(); 26113 } 26114 26115 consumeSemicolon(); 26116 return node.finishImportDeclaration(specifiers, src); 26117 } 26118 26119 // ECMA-262 15.1 Scripts 26120 26121 function parseScriptBody() { 26122 var statement, body = [], token, directive, firstRestricted; 26123 26124 while (startIndex < length) { 26125 token = lookahead; 26126 if (token.type !== Token.StringLiteral) { 26127 break; 26128 } 26129 26130 statement = parseStatementListItem(); 26131 body.push(statement); 26132 if (statement.expression.type !== Syntax.Literal) { 26133 // this is not directive 26134 break; 26135 } 26136 directive = source.slice(token.start + 1, token.end - 1); 26137 if (directive === 'use strict') { 26138 strict = true; 26139 if (firstRestricted) { 26140 tolerateUnexpectedToken(firstRestricted, Messages.StrictOctalLiteral); 26141 } 26142 } else { 26143 if (!firstRestricted && token.octal) { 26144 firstRestricted = token; 26145 } 26146 } 26147 } 26148 26149 while (startIndex < length) { 26150 statement = parseStatementListItem(); 26151 /* istanbul ignore if */ 26152 if (typeof statement === 'undefined') { 26153 break; 26154 } 26155 body.push(statement); 26156 } 26157 return body; 26158 } 26159 26160 function parseProgram() { 26161 var body, node; 26162 26163 peek(); 26164 node = new Node(); 26165 26166 body = parseScriptBody(); 26167 return node.finishProgram(body, state.sourceType); 26168 } 26169 26170 function filterTokenLocation() { 26171 var i, entry, token, tokens = []; 26172 26173 for (i = 0; i < extra.tokens.length; ++i) { 26174 entry = extra.tokens[i]; 26175 token = { 26176 type: entry.type, 26177 value: entry.value 26178 }; 26179 if (entry.regex) { 26180 token.regex = { 26181 pattern: entry.regex.pattern, 26182 flags: entry.regex.flags 26183 }; 26184 } 26185 if (extra.range) { 26186 token.range = entry.range; 26187 } 26188 if (extra.loc) { 26189 token.loc = entry.loc; 26190 } 26191 tokens.push(token); 26192 } 26193 26194 extra.tokens = tokens; 26195 } 26196 26197 function tokenize(code, options, delegate) { 26198 var toString, 26199 tokens; 26200 26201 toString = String; 26202 if (typeof code !== 'string' && !(code instanceof String)) { 26203 code = toString(code); 26204 } 26205 26206 source = code; 26207 index = 0; 26208 lineNumber = (source.length > 0) ? 1 : 0; 26209 lineStart = 0; 26210 startIndex = index; 26211 startLineNumber = lineNumber; 26212 startLineStart = lineStart; 26213 length = source.length; 26214 lookahead = null; 26215 state = { 26216 allowIn: true, 26217 allowYield: true, 26218 labelSet: {}, 26219 inFunctionBody: false, 26220 inIteration: false, 26221 inSwitch: false, 26222 lastCommentStart: -1, 26223 curlyStack: [] 26224 }; 26225 26226 extra = {}; 26227 26228 // Options matching. 26229 options = options || {}; 26230 26231 // Of course we collect tokens here. 26232 options.tokens = true; 26233 extra.tokens = []; 26234 extra.tokenValues = []; 26235 extra.tokenize = true; 26236 extra.delegate = delegate; 26237 26238 // The following two fields are necessary to compute the Regex tokens. 26239 extra.openParenToken = -1; 26240 extra.openCurlyToken = -1; 26241 26242 extra.range = (typeof options.range === 'boolean') && options.range; 26243 extra.loc = (typeof options.loc === 'boolean') && options.loc; 26244 26245 if (typeof options.comment === 'boolean' && options.comment) { 26246 extra.comments = []; 26247 } 26248 if (typeof options.tolerant === 'boolean' && options.tolerant) { 26249 extra.errors = []; 26250 } 26251 26252 try { 26253 peek(); 26254 if (lookahead.type === Token.EOF) { 26255 return extra.tokens; 26256 } 26257 26258 lex(); 26259 while (lookahead.type !== Token.EOF) { 26260 try { 26261 lex(); 26262 } catch (lexError) { 26263 if (extra.errors) { 26264 recordError(lexError); 26265 // We have to break on the first error 26266 // to avoid infinite loops. 26267 break; 26268 } else { 26269 throw lexError; 26270 } 26271 } 26272 } 26273 26274 tokens = extra.tokens; 26275 if (typeof extra.errors !== 'undefined') { 26276 tokens.errors = extra.errors; 26277 } 26278 } catch (e) { 26279 throw e; 26280 } finally { 26281 extra = {}; 26282 } 26283 return tokens; 26284 } 26285 26286 function parse(code, options) { 26287 var program, toString; 26288 26289 toString = String; 26290 if (typeof code !== 'string' && !(code instanceof String)) { 26291 code = toString(code); 26292 } 26293 26294 source = code; 26295 index = 0; 26296 lineNumber = (source.length > 0) ? 1 : 0; 26297 lineStart = 0; 26298 startIndex = index; 26299 startLineNumber = lineNumber; 26300 startLineStart = lineStart; 26301 length = source.length; 26302 lookahead = null; 26303 state = { 26304 allowIn: true, 26305 allowYield: true, 26306 labelSet: {}, 26307 inFunctionBody: false, 26308 inIteration: false, 26309 inSwitch: false, 26310 lastCommentStart: -1, 26311 curlyStack: [], 26312 sourceType: 'script' 26313 }; 26314 strict = false; 26315 26316 extra = {}; 26317 if (typeof options !== 'undefined') { 26318 extra.range = (typeof options.range === 'boolean') && options.range; 26319 extra.loc = (typeof options.loc === 'boolean') && options.loc; 26320 extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; 26321 26322 if (extra.loc && options.source !== null && options.source !== undefined) { 26323 extra.source = toString(options.source); 26324 } 26325 26326 if (typeof options.tokens === 'boolean' && options.tokens) { 26327 extra.tokens = []; 26328 } 26329 if (typeof options.comment === 'boolean' && options.comment) { 26330 extra.comments = []; 26331 } 26332 if (typeof options.tolerant === 'boolean' && options.tolerant) { 26333 extra.errors = []; 26334 } 26335 if (extra.attachComment) { 26336 extra.range = true; 26337 extra.comments = []; 26338 extra.bottomRightStack = []; 26339 extra.trailingComments = []; 26340 extra.leadingComments = []; 26341 } 26342 if (options.sourceType === 'module') { 26343 // very restrictive condition for now 26344 state.sourceType = options.sourceType; 26345 strict = true; 26346 } 26347 } 26348 26349 try { 26350 program = parseProgram(); 26351 if (typeof extra.comments !== 'undefined') { 26352 program.comments = extra.comments; 26353 } 26354 if (typeof extra.tokens !== 'undefined') { 26355 filterTokenLocation(); 26356 program.tokens = extra.tokens; 26357 } 26358 if (typeof extra.errors !== 'undefined') { 26359 program.errors = extra.errors; 26360 } 26361 } catch (e) { 26362 throw e; 26363 } finally { 26364 extra = {}; 26365 } 26366 26367 return program; 26368 } 26369 26370 // Sync with *.json manifests. 26371 exports.version = '2.7.3'; 26372 26373 exports.tokenize = tokenize; 26374 26375 exports.parse = parse; 26376 26377 // Deep copy. 26378 /* istanbul ignore next */ 26379 exports.Syntax = (function () { 26380 var name, types = {}; 26381 26382 if (typeof Object.create === 'function') { 26383 types = Object.create(null); 26384 } 26385 26386 for (name in Syntax) { 26387 if (Syntax.hasOwnProperty(name)) { 26388 types[name] = Syntax[name]; 26389 } 26390 } 26391 26392 if (typeof Object.freeze === 'function') { 26393 Object.freeze(types); 26394 } 26395 26396 return types; 26397 }()); 26398 26399 })); 26400 /* vim: set sw=4 ts=4 et tw=80 : */ 26401 26402 26403 /***/ }, 26404 /* 73 */ 26405 /***/ function(module, exports) { 26406 26407 // removed by extract-text-webpack-plugin 26408 26409 /***/ }, 26410 /* 74 */ 26411 /***/ function(module, exports) { 26412 26413 // removed by extract-text-webpack-plugin 26414 26415 /***/ }, 26416 /* 75 */ 26417 /***/ function(module, exports) { 26418 26419 // removed by extract-text-webpack-plugin 26420 26421 /***/ }, 26422 /* 76 */ 26423 /***/ function(module, exports) { 26424 26425 // removed by extract-text-webpack-plugin 26426 26427 /***/ }, 26428 /* 77 */ 26429 /***/ function(module, exports) { 26430 26431 // removed by extract-text-webpack-plugin 26432 26433 /***/ }, 26434 /* 78 */ 26435 /***/ function(module, exports) { 26436 26437 // removed by extract-text-webpack-plugin 26438 26439 /***/ }, 26440 /* 79 */ 26441 /***/ function(module, exports) { 26442 26443 // removed by extract-text-webpack-plugin 26444 26445 /***/ }, 26446 /* 80 */ 26447 /***/ function(module, exports) { 26448 26449 // removed by extract-text-webpack-plugin 26450 26451 /***/ }, 26452 /* 81 */ 26453 /***/ function(module, exports) { 26454 26455 exports.read = function (buffer, offset, isLE, mLen, nBytes) { 26456 var e, m 26457 var eLen = nBytes * 8 - mLen - 1 26458 var eMax = (1 << eLen) - 1 26459 var eBias = eMax >> 1 26460 var nBits = -7 26461 var i = isLE ? (nBytes - 1) : 0 26462 var d = isLE ? -1 : 1 26463 var s = buffer[offset + i] 26464 26465 i += d 26466 26467 e = s & ((1 << (-nBits)) - 1) 26468 s >>= (-nBits) 26469 nBits += eLen 26470 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} 26471 26472 m = e & ((1 << (-nBits)) - 1) 26473 e >>= (-nBits) 26474 nBits += mLen 26475 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} 26476 26477 if (e === 0) { 26478 e = 1 - eBias 26479 } else if (e === eMax) { 26480 return m ? NaN : ((s ? -1 : 1) * Infinity) 26481 } else { 26482 m = m + Math.pow(2, mLen) 26483 e = e - eBias 26484 } 26485 return (s ? -1 : 1) * m * Math.pow(2, e - mLen) 26486 } 26487 26488 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { 26489 var e, m, c 26490 var eLen = nBytes * 8 - mLen - 1 26491 var eMax = (1 << eLen) - 1 26492 var eBias = eMax >> 1 26493 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) 26494 var i = isLE ? 0 : (nBytes - 1) 26495 var d = isLE ? 1 : -1 26496 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 26497 26498 value = Math.abs(value) 26499 26500 if (isNaN(value) || value === Infinity) { 26501 m = isNaN(value) ? 1 : 0 26502 e = eMax 26503 } else { 26504 e = Math.floor(Math.log(value) / Math.LN2) 26505 if (value * (c = Math.pow(2, -e)) < 1) { 26506 e-- 26507 c *= 2 26508 } 26509 if (e + eBias >= 1) { 26510 value += rt / c 26511 } else { 26512 value += rt * Math.pow(2, 1 - eBias) 26513 } 26514 if (value * c >= 2) { 26515 e++ 26516 c /= 2 26517 } 26518 26519 if (e + eBias >= eMax) { 26520 m = 0 26521 e = eMax 26522 } else if (e + eBias >= 1) { 26523 m = (value * c - 1) * Math.pow(2, mLen) 26524 e = e + eBias 26525 } else { 26526 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) 26527 e = 0 26528 } 26529 } 26530 26531 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} 26532 26533 e = (e << mLen) | m 26534 eLen += mLen 26535 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} 26536 26537 buffer[offset + i - d] |= s * 128 26538 } 26539 26540 26541 /***/ }, 26542 /* 82 */ 26543 /***/ function(module, exports) { 26544 26545 var toString = {}.toString; 26546 26547 module.exports = Array.isArray || function (arr) { 26548 return toString.call(arr) == '[object Array]'; 26549 }; 26550 26551 26552 /***/ }, 26553 /* 83 */ 26554 /***/ function(module, exports, __webpack_require__) { 26555 26556 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;// This file is deprecated in 1.12.0 to be removed in 1.13 26557 ( function() { 26558 !(__WEBPACK_AMD_DEFINE_FACTORY__ = ([ 26559 "jquery", 26560 "./data", 26561 "./disable-selection", 26562 "./focusable", 26563 "./form", 26564 "./ie", 26565 "./keycode", 26566 "./labels", 26567 "./jquery-1-7", 26568 "./plugin", 26569 "./safe-active-element", 26570 "./safe-blur", 26571 "./scroll-parent", 26572 "./tabbable", 26573 "./unique-id", 26574 "./version" 26575 ]), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 26576 } )(); 26577 26578 26579 /***/ }, 26580 /* 84 */ 26581 /***/ function(module, exports, __webpack_require__) { 26582 26583 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 26584 * jQuery UI :data 1.12.1 26585 * http://jqueryui.com 26586 * 26587 * Copyright jQuery Foundation and other contributors 26588 * Released under the MIT license. 26589 * http://jquery.org/license 26590 */ 26591 26592 //>>label: :data Selector 26593 //>>group: Core 26594 //>>description: Selects elements which have data stored under the specified key. 26595 //>>docs: http://api.jqueryui.com/data-selector/ 26596 26597 ( function( factory ) { 26598 if ( true ) { 26599 26600 // AMD. Register as an anonymous module. 26601 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(1), __webpack_require__(6) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 26602 } else { 26603 26604 // Browser globals 26605 factory( jQuery ); 26606 } 26607 } ( function( $ ) { 26608 return $.extend( $.expr[ ":" ], { 26609 data: $.expr.createPseudo ? 26610 $.expr.createPseudo( function( dataName ) { 26611 return function( elem ) { 26612 return !!$.data( elem, dataName ); 26613 }; 26614 } ) : 26615 26616 // Support: jQuery <1.8 26617 function( elem, i, match ) { 26618 return !!$.data( elem, match[ 3 ] ); 26619 } 26620 } ); 26621 } ) ); 26622 26623 26624 /***/ }, 26625 /* 85 */ 26626 /***/ function(module, exports, __webpack_require__) { 26627 26628 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 26629 * jQuery UI Scroll Parent 1.12.1 26630 * http://jqueryui.com 26631 * 26632 * Copyright jQuery Foundation and other contributors 26633 * Released under the MIT license. 26634 * http://jquery.org/license 26635 */ 26636 26637 //>>label: scrollParent 26638 //>>group: Core 26639 //>>description: Get the closest ancestor element that is scrollable. 26640 //>>docs: http://api.jqueryui.com/scrollParent/ 26641 26642 ( function( factory ) { 26643 if ( true ) { 26644 26645 // AMD. Register as an anonymous module. 26646 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(1), __webpack_require__(6) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 26647 } else { 26648 26649 // Browser globals 26650 factory( jQuery ); 26651 } 26652 } ( function( $ ) { 26653 26654 return $.fn.scrollParent = function( includeHidden ) { 26655 var position = this.css( "position" ), 26656 excludeStaticParent = position === "absolute", 26657 overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, 26658 scrollParent = this.parents().filter( function() { 26659 var parent = $( this ); 26660 if ( excludeStaticParent && parent.css( "position" ) === "static" ) { 26661 return false; 26662 } 26663 return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + 26664 parent.css( "overflow-x" ) ); 26665 } ).eq( 0 ); 26666 26667 return position === "fixed" || !scrollParent.length ? 26668 $( this[ 0 ].ownerDocument || document ) : 26669 scrollParent; 26670 }; 26671 26672 } ) ); 26673 26674 26675 /***/ }, 26676 /* 86 */ 26677 /***/ function(module, exports, __webpack_require__) { 26678 26679 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 26680 * jQuery UI Sortable 1.12.1 26681 * http://jqueryui.com 26682 * 26683 * Copyright jQuery Foundation and other contributors 26684 * Released under the MIT license. 26685 * http://jquery.org/license 26686 */ 26687 26688 //>>label: Sortable 26689 //>>group: Interactions 26690 //>>description: Enables items in a list to be sorted using the mouse. 26691 //>>docs: http://api.jqueryui.com/sortable/ 26692 //>>demos: http://jqueryui.com/sortable/ 26693 //>>css.structure: ../../themes/base/sortable.css 26694 26695 ( function( factory ) { 26696 if ( true ) { 26697 26698 // AMD. Register as an anonymous module. 26699 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ 26700 __webpack_require__(1), 26701 __webpack_require__(28), 26702 __webpack_require__(84), 26703 __webpack_require__(27), 26704 __webpack_require__(85), 26705 __webpack_require__(6), 26706 __webpack_require__(18) 26707 ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 26708 } else { 26709 26710 // Browser globals 26711 factory( jQuery ); 26712 } 26713 }( function( $ ) { 26714 26715 return $.widget( "ui.sortable", $.ui.mouse, { 26716 version: "1.12.1", 26717 widgetEventPrefix: "sort", 26718 ready: false, 26719 options: { 26720 appendTo: "parent", 26721 axis: false, 26722 connectWith: false, 26723 containment: false, 26724 cursor: "auto", 26725 cursorAt: false, 26726 dropOnEmpty: true, 26727 forcePlaceholderSize: false, 26728 forceHelperSize: false, 26729 grid: false, 26730 handle: false, 26731 helper: "original", 26732 items: "> *", 26733 opacity: false, 26734 placeholder: false, 26735 revert: false, 26736 scroll: true, 26737 scrollSensitivity: 20, 26738 scrollSpeed: 20, 26739 scope: "default", 26740 tolerance: "intersect", 26741 zIndex: 1000, 26742 26743 // Callbacks 26744 activate: null, 26745 beforeStop: null, 26746 change: null, 26747 deactivate: null, 26748 out: null, 26749 over: null, 26750 receive: null, 26751 remove: null, 26752 sort: null, 26753 start: null, 26754 stop: null, 26755 update: null 26756 }, 26757 26758 _isOverAxis: function( x, reference, size ) { 26759 return ( x >= reference ) && ( x < ( reference + size ) ); 26760 }, 26761 26762 _isFloating: function( item ) { 26763 return ( /left|right/ ).test( item.css( "float" ) ) || 26764 ( /inline|table-cell/ ).test( item.css( "display" ) ); 26765 }, 26766 26767 _create: function() { 26768 this.containerCache = {}; 26769 this._addClass( "ui-sortable" ); 26770 26771 //Get the items 26772 this.refresh(); 26773 26774 //Let's determine the parent's offset 26775 this.offset = this.element.offset(); 26776 26777 //Initialize mouse events for interaction 26778 this._mouseInit(); 26779 26780 this._setHandleClassName(); 26781 26782 //We're ready to go 26783 this.ready = true; 26784 26785 }, 26786 26787 _setOption: function( key, value ) { 26788 this._super( key, value ); 26789 26790 if ( key === "handle" ) { 26791 this._setHandleClassName(); 26792 } 26793 }, 26794 26795 _setHandleClassName: function() { 26796 var that = this; 26797 this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" ); 26798 $.each( this.items, function() { 26799 that._addClass( 26800 this.instance.options.handle ? 26801 this.item.find( this.instance.options.handle ) : 26802 this.item, 26803 "ui-sortable-handle" 26804 ); 26805 } ); 26806 }, 26807 26808 _destroy: function() { 26809 this._mouseDestroy(); 26810 26811 for ( var i = this.items.length - 1; i >= 0; i-- ) { 26812 this.items[ i ].item.removeData( this.widgetName + "-item" ); 26813 } 26814 26815 return this; 26816 }, 26817 26818 _mouseCapture: function( event, overrideHandle ) { 26819 var currentItem = null, 26820 validHandle = false, 26821 that = this; 26822 26823 if ( this.reverting ) { 26824 return false; 26825 } 26826 26827 if ( this.options.disabled || this.options.type === "static" ) { 26828 return false; 26829 } 26830 26831 //We have to refresh the items data once first 26832 this._refreshItems( event ); 26833 26834 //Find out if the clicked node (or one of its parents) is a actual item in this.items 26835 $( event.target ).parents().each( function() { 26836 if ( $.data( this, that.widgetName + "-item" ) === that ) { 26837 currentItem = $( this ); 26838 return false; 26839 } 26840 } ); 26841 if ( $.data( event.target, that.widgetName + "-item" ) === that ) { 26842 currentItem = $( event.target ); 26843 } 26844 26845 if ( !currentItem ) { 26846 return false; 26847 } 26848 if ( this.options.handle && !overrideHandle ) { 26849 $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() { 26850 if ( this === event.target ) { 26851 validHandle = true; 26852 } 26853 } ); 26854 if ( !validHandle ) { 26855 return false; 26856 } 26857 } 26858 26859 this.currentItem = currentItem; 26860 this._removeCurrentsFromItems(); 26861 return true; 26862 26863 }, 26864 26865 _mouseStart: function( event, overrideHandle, noActivation ) { 26866 26867 var i, body, 26868 o = this.options; 26869 26870 this.currentContainer = this; 26871 26872 //We only need to call refreshPositions, because the refreshItems call has been moved to 26873 // mouseCapture 26874 this.refreshPositions(); 26875 26876 //Create and append the visible helper 26877 this.helper = this._createHelper( event ); 26878 26879 //Cache the helper size 26880 this._cacheHelperProportions(); 26881 26882 /* 26883 * - Position generation - 26884 * This block generates everything position related - it's the core of draggables. 26885 */ 26886 26887 //Cache the margins of the original element 26888 this._cacheMargins(); 26889 26890 //Get the next scrolling parent 26891 this.scrollParent = this.helper.scrollParent(); 26892 26893 //The element's absolute position on the page minus margins 26894 this.offset = this.currentItem.offset(); 26895 this.offset = { 26896 top: this.offset.top - this.margins.top, 26897 left: this.offset.left - this.margins.left 26898 }; 26899 26900 $.extend( this.offset, { 26901 click: { //Where the click happened, relative to the element 26902 left: event.pageX - this.offset.left, 26903 top: event.pageY - this.offset.top 26904 }, 26905 parent: this._getParentOffset(), 26906 26907 // This is a relative to absolute position minus the actual position calculation - 26908 // only used for relative positioned helper 26909 relative: this._getRelativeOffset() 26910 } ); 26911 26912 // Only after we got the offset, we can change the helper's position to absolute 26913 // TODO: Still need to figure out a way to make relative sorting possible 26914 this.helper.css( "position", "absolute" ); 26915 this.cssPosition = this.helper.css( "position" ); 26916 26917 //Generate the original position 26918 this.originalPosition = this._generatePosition( event ); 26919 this.originalPageX = event.pageX; 26920 this.originalPageY = event.pageY; 26921 26922 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 26923 ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); 26924 26925 //Cache the former DOM position 26926 this.domPosition = { 26927 prev: this.currentItem.prev()[ 0 ], 26928 parent: this.currentItem.parent()[ 0 ] 26929 }; 26930 26931 // If the helper is not the original, hide the original so it's not playing any role during 26932 // the drag, won't cause anything bad this way 26933 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { 26934 this.currentItem.hide(); 26935 } 26936 26937 //Create the placeholder 26938 this._createPlaceholder(); 26939 26940 //Set a containment if given in the options 26941 if ( o.containment ) { 26942 this._setContainment(); 26943 } 26944 26945 if ( o.cursor && o.cursor !== "auto" ) { // cursor option 26946 body = this.document.find( "body" ); 26947 26948 // Support: IE 26949 this.storedCursor = body.css( "cursor" ); 26950 body.css( "cursor", o.cursor ); 26951 26952 this.storedStylesheet = 26953 $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body ); 26954 } 26955 26956 if ( o.opacity ) { // opacity option 26957 if ( this.helper.css( "opacity" ) ) { 26958 this._storedOpacity = this.helper.css( "opacity" ); 26959 } 26960 this.helper.css( "opacity", o.opacity ); 26961 } 26962 26963 if ( o.zIndex ) { // zIndex option 26964 if ( this.helper.css( "zIndex" ) ) { 26965 this._storedZIndex = this.helper.css( "zIndex" ); 26966 } 26967 this.helper.css( "zIndex", o.zIndex ); 26968 } 26969 26970 //Prepare scrolling 26971 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 26972 this.scrollParent[ 0 ].tagName !== "HTML" ) { 26973 this.overflowOffset = this.scrollParent.offset(); 26974 } 26975 26976 //Call callbacks 26977 this._trigger( "start", event, this._uiHash() ); 26978 26979 //Recache the helper size 26980 if ( !this._preserveHelperProportions ) { 26981 this._cacheHelperProportions(); 26982 } 26983 26984 //Post "activate" events to possible containers 26985 if ( !noActivation ) { 26986 for ( i = this.containers.length - 1; i >= 0; i-- ) { 26987 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); 26988 } 26989 } 26990 26991 //Prepare possible droppables 26992 if ( $.ui.ddmanager ) { 26993 $.ui.ddmanager.current = this; 26994 } 26995 26996 if ( $.ui.ddmanager && !o.dropBehaviour ) { 26997 $.ui.ddmanager.prepareOffsets( this, event ); 26998 } 26999 27000 this.dragging = true; 27001 27002 this._addClass( this.helper, "ui-sortable-helper" ); 27003 27004 // Execute the drag once - this causes the helper not to be visiblebefore getting its 27005 // correct position 27006 this._mouseDrag( event ); 27007 return true; 27008 27009 }, 27010 27011 _mouseDrag: function( event ) { 27012 var i, item, itemElement, intersection, 27013 o = this.options, 27014 scrolled = false; 27015 27016 //Compute the helpers position 27017 this.position = this._generatePosition( event ); 27018 this.positionAbs = this._convertPositionTo( "absolute" ); 27019 27020 if ( !this.lastPositionAbs ) { 27021 this.lastPositionAbs = this.positionAbs; 27022 } 27023 27024 //Do scrolling 27025 if ( this.options.scroll ) { 27026 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 27027 this.scrollParent[ 0 ].tagName !== "HTML" ) { 27028 27029 if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - 27030 event.pageY < o.scrollSensitivity ) { 27031 this.scrollParent[ 0 ].scrollTop = 27032 scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed; 27033 } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) { 27034 this.scrollParent[ 0 ].scrollTop = 27035 scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed; 27036 } 27037 27038 if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - 27039 event.pageX < o.scrollSensitivity ) { 27040 this.scrollParent[ 0 ].scrollLeft = scrolled = 27041 this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed; 27042 } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) { 27043 this.scrollParent[ 0 ].scrollLeft = scrolled = 27044 this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed; 27045 } 27046 27047 } else { 27048 27049 if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) { 27050 scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed ); 27051 } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < 27052 o.scrollSensitivity ) { 27053 scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed ); 27054 } 27055 27056 if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) { 27057 scrolled = this.document.scrollLeft( 27058 this.document.scrollLeft() - o.scrollSpeed 27059 ); 27060 } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < 27061 o.scrollSensitivity ) { 27062 scrolled = this.document.scrollLeft( 27063 this.document.scrollLeft() + o.scrollSpeed 27064 ); 27065 } 27066 27067 } 27068 27069 if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { 27070 $.ui.ddmanager.prepareOffsets( this, event ); 27071 } 27072 } 27073 27074 //Regenerate the absolute position used for position checks 27075 this.positionAbs = this._convertPositionTo( "absolute" ); 27076 27077 //Set the helper position 27078 if ( !this.options.axis || this.options.axis !== "y" ) { 27079 this.helper[ 0 ].style.left = this.position.left + "px"; 27080 } 27081 if ( !this.options.axis || this.options.axis !== "x" ) { 27082 this.helper[ 0 ].style.top = this.position.top + "px"; 27083 } 27084 27085 //Rearrange 27086 for ( i = this.items.length - 1; i >= 0; i-- ) { 27087 27088 //Cache variables and intersection, continue if no intersection 27089 item = this.items[ i ]; 27090 itemElement = item.item[ 0 ]; 27091 intersection = this._intersectsWithPointer( item ); 27092 if ( !intersection ) { 27093 continue; 27094 } 27095 27096 // Only put the placeholder inside the current Container, skip all 27097 // items from other containers. This works because when moving 27098 // an item from one container to another the 27099 // currentContainer is switched before the placeholder is moved. 27100 // 27101 // Without this, moving items in "sub-sortables" can cause 27102 // the placeholder to jitter between the outer and inner container. 27103 if ( item.instance !== this.currentContainer ) { 27104 continue; 27105 } 27106 27107 // Cannot intersect with itself 27108 // no useless actions that have been done before 27109 // no action if the item moved is the parent of the item checked 27110 if ( itemElement !== this.currentItem[ 0 ] && 27111 this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement && 27112 !$.contains( this.placeholder[ 0 ], itemElement ) && 27113 ( this.options.type === "semi-dynamic" ? 27114 !$.contains( this.element[ 0 ], itemElement ) : 27115 true 27116 ) 27117 ) { 27118 27119 this.direction = intersection === 1 ? "down" : "up"; 27120 27121 if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) { 27122 this._rearrange( event, item ); 27123 } else { 27124 break; 27125 } 27126 27127 this._trigger( "change", event, this._uiHash() ); 27128 break; 27129 } 27130 } 27131 27132 //Post events to containers 27133 this._contactContainers( event ); 27134 27135 //Interconnect with droppables 27136 if ( $.ui.ddmanager ) { 27137 $.ui.ddmanager.drag( this, event ); 27138 } 27139 27140 //Call callbacks 27141 this._trigger( "sort", event, this._uiHash() ); 27142 27143 this.lastPositionAbs = this.positionAbs; 27144 return false; 27145 27146 }, 27147 27148 _mouseStop: function( event, noPropagation ) { 27149 27150 if ( !event ) { 27151 return; 27152 } 27153 27154 //If we are using droppables, inform the manager about the drop 27155 if ( $.ui.ddmanager && !this.options.dropBehaviour ) { 27156 $.ui.ddmanager.drop( this, event ); 27157 } 27158 27159 if ( this.options.revert ) { 27160 var that = this, 27161 cur = this.placeholder.offset(), 27162 axis = this.options.axis, 27163 animation = {}; 27164 27165 if ( !axis || axis === "x" ) { 27166 animation.left = cur.left - this.offset.parent.left - this.margins.left + 27167 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 27168 0 : 27169 this.offsetParent[ 0 ].scrollLeft 27170 ); 27171 } 27172 if ( !axis || axis === "y" ) { 27173 animation.top = cur.top - this.offset.parent.top - this.margins.top + 27174 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 27175 0 : 27176 this.offsetParent[ 0 ].scrollTop 27177 ); 27178 } 27179 this.reverting = true; 27180 $( this.helper ).animate( 27181 animation, 27182 parseInt( this.options.revert, 10 ) || 500, 27183 function() { 27184 that._clear( event ); 27185 } 27186 ); 27187 } else { 27188 this._clear( event, noPropagation ); 27189 } 27190 27191 return false; 27192 27193 }, 27194 27195 cancel: function() { 27196 27197 if ( this.dragging ) { 27198 27199 this._mouseUp( new $.Event( "mouseup", { target: null } ) ); 27200 27201 if ( this.options.helper === "original" ) { 27202 this.currentItem.css( this._storedCSS ); 27203 this._removeClass( this.currentItem, "ui-sortable-helper" ); 27204 } else { 27205 this.currentItem.show(); 27206 } 27207 27208 //Post deactivating events to containers 27209 for ( var i = this.containers.length - 1; i >= 0; i-- ) { 27210 this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) ); 27211 if ( this.containers[ i ].containerCache.over ) { 27212 this.containers[ i ]._trigger( "out", null, this._uiHash( this ) ); 27213 this.containers[ i ].containerCache.over = 0; 27214 } 27215 } 27216 27217 } 27218 27219 if ( this.placeholder ) { 27220 27221 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 27222 // it unbinds ALL events from the original node! 27223 if ( this.placeholder[ 0 ].parentNode ) { 27224 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 27225 } 27226 if ( this.options.helper !== "original" && this.helper && 27227 this.helper[ 0 ].parentNode ) { 27228 this.helper.remove(); 27229 } 27230 27231 $.extend( this, { 27232 helper: null, 27233 dragging: false, 27234 reverting: false, 27235 _noFinalSort: null 27236 } ); 27237 27238 if ( this.domPosition.prev ) { 27239 $( this.domPosition.prev ).after( this.currentItem ); 27240 } else { 27241 $( this.domPosition.parent ).prepend( this.currentItem ); 27242 } 27243 } 27244 27245 return this; 27246 27247 }, 27248 27249 serialize: function( o ) { 27250 27251 var items = this._getItemsAsjQuery( o && o.connected ), 27252 str = []; 27253 o = o || {}; 27254 27255 $( items ).each( function() { 27256 var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ) 27257 .match( o.expression || ( /(.+)[\-=_](.+)/ ) ); 27258 if ( res ) { 27259 str.push( 27260 ( o.key || res[ 1 ] + "[]" ) + 27261 "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) ); 27262 } 27263 } ); 27264 27265 if ( !str.length && o.key ) { 27266 str.push( o.key + "=" ); 27267 } 27268 27269 return str.join( "&" ); 27270 27271 }, 27272 27273 toArray: function( o ) { 27274 27275 var items = this._getItemsAsjQuery( o && o.connected ), 27276 ret = []; 27277 27278 o = o || {}; 27279 27280 items.each( function() { 27281 ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); 27282 } ); 27283 return ret; 27284 27285 }, 27286 27287 /* Be careful with the following core functions */ 27288 _intersectsWith: function( item ) { 27289 27290 var x1 = this.positionAbs.left, 27291 x2 = x1 + this.helperProportions.width, 27292 y1 = this.positionAbs.top, 27293 y2 = y1 + this.helperProportions.height, 27294 l = item.left, 27295 r = l + item.width, 27296 t = item.top, 27297 b = t + item.height, 27298 dyClick = this.offset.click.top, 27299 dxClick = this.offset.click.left, 27300 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && 27301 ( y1 + dyClick ) < b ), 27302 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && 27303 ( x1 + dxClick ) < r ), 27304 isOverElement = isOverElementHeight && isOverElementWidth; 27305 27306 if ( this.options.tolerance === "pointer" || 27307 this.options.forcePointerForContainers || 27308 ( this.options.tolerance !== "pointer" && 27309 this.helperProportions[ this.floating ? "width" : "height" ] > 27310 item[ this.floating ? "width" : "height" ] ) 27311 ) { 27312 return isOverElement; 27313 } else { 27314 27315 return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half 27316 x2 - ( this.helperProportions.width / 2 ) < r && // Left Half 27317 t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half 27318 y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half 27319 27320 } 27321 }, 27322 27323 _intersectsWithPointer: function( item ) { 27324 var verticalDirection, horizontalDirection, 27325 isOverElementHeight = ( this.options.axis === "x" ) || 27326 this._isOverAxis( 27327 this.positionAbs.top + this.offset.click.top, item.top, item.height ), 27328 isOverElementWidth = ( this.options.axis === "y" ) || 27329 this._isOverAxis( 27330 this.positionAbs.left + this.offset.click.left, item.left, item.width ), 27331 isOverElement = isOverElementHeight && isOverElementWidth; 27332 27333 if ( !isOverElement ) { 27334 return false; 27335 } 27336 27337 verticalDirection = this._getDragVerticalDirection(); 27338 horizontalDirection = this._getDragHorizontalDirection(); 27339 27340 return this.floating ? 27341 ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) 27342 : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) ); 27343 27344 }, 27345 27346 _intersectsWithSides: function( item ) { 27347 27348 var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + 27349 this.offset.click.top, item.top + ( item.height / 2 ), item.height ), 27350 isOverRightHalf = this._isOverAxis( this.positionAbs.left + 27351 this.offset.click.left, item.left + ( item.width / 2 ), item.width ), 27352 verticalDirection = this._getDragVerticalDirection(), 27353 horizontalDirection = this._getDragHorizontalDirection(); 27354 27355 if ( this.floating && horizontalDirection ) { 27356 return ( ( horizontalDirection === "right" && isOverRightHalf ) || 27357 ( horizontalDirection === "left" && !isOverRightHalf ) ); 27358 } else { 27359 return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || 27360 ( verticalDirection === "up" && !isOverBottomHalf ) ); 27361 } 27362 27363 }, 27364 27365 _getDragVerticalDirection: function() { 27366 var delta = this.positionAbs.top - this.lastPositionAbs.top; 27367 return delta !== 0 && ( delta > 0 ? "down" : "up" ); 27368 }, 27369 27370 _getDragHorizontalDirection: function() { 27371 var delta = this.positionAbs.left - this.lastPositionAbs.left; 27372 return delta !== 0 && ( delta > 0 ? "right" : "left" ); 27373 }, 27374 27375 refresh: function( event ) { 27376 this._refreshItems( event ); 27377 this._setHandleClassName(); 27378 this.refreshPositions(); 27379 return this; 27380 }, 27381 27382 _connectWith: function() { 27383 var options = this.options; 27384 return options.connectWith.constructor === String ? 27385 [ options.connectWith ] : 27386 options.connectWith; 27387 }, 27388 27389 _getItemsAsjQuery: function( connected ) { 27390 27391 var i, j, cur, inst, 27392 items = [], 27393 queries = [], 27394 connectWith = this._connectWith(); 27395 27396 if ( connectWith && connected ) { 27397 for ( i = connectWith.length - 1; i >= 0; i-- ) { 27398 cur = $( connectWith[ i ], this.document[ 0 ] ); 27399 for ( j = cur.length - 1; j >= 0; j-- ) { 27400 inst = $.data( cur[ j ], this.widgetFullName ); 27401 if ( inst && inst !== this && !inst.options.disabled ) { 27402 queries.push( [ $.isFunction( inst.options.items ) ? 27403 inst.options.items.call( inst.element ) : 27404 $( inst.options.items, inst.element ) 27405 .not( ".ui-sortable-helper" ) 27406 .not( ".ui-sortable-placeholder" ), inst ] ); 27407 } 27408 } 27409 } 27410 } 27411 27412 queries.push( [ $.isFunction( this.options.items ) ? 27413 this.options.items 27414 .call( this.element, null, { options: this.options, item: this.currentItem } ) : 27415 $( this.options.items, this.element ) 27416 .not( ".ui-sortable-helper" ) 27417 .not( ".ui-sortable-placeholder" ), this ] ); 27418 27419 function addItems() { 27420 items.push( this ); 27421 } 27422 for ( i = queries.length - 1; i >= 0; i-- ) { 27423 queries[ i ][ 0 ].each( addItems ); 27424 } 27425 27426 return $( items ); 27427 27428 }, 27429 27430 _removeCurrentsFromItems: function() { 27431 27432 var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" ); 27433 27434 this.items = $.grep( this.items, function( item ) { 27435 for ( var j = 0; j < list.length; j++ ) { 27436 if ( list[ j ] === item.item[ 0 ] ) { 27437 return false; 27438 } 27439 } 27440 return true; 27441 } ); 27442 27443 }, 27444 27445 _refreshItems: function( event ) { 27446 27447 this.items = []; 27448 this.containers = [ this ]; 27449 27450 var i, j, cur, inst, targetData, _queries, item, queriesLength, 27451 items = this.items, 27452 queries = [ [ $.isFunction( this.options.items ) ? 27453 this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : 27454 $( this.options.items, this.element ), this ] ], 27455 connectWith = this._connectWith(); 27456 27457 //Shouldn't be run the first time through due to massive slow-down 27458 if ( connectWith && this.ready ) { 27459 for ( i = connectWith.length - 1; i >= 0; i-- ) { 27460 cur = $( connectWith[ i ], this.document[ 0 ] ); 27461 for ( j = cur.length - 1; j >= 0; j-- ) { 27462 inst = $.data( cur[ j ], this.widgetFullName ); 27463 if ( inst && inst !== this && !inst.options.disabled ) { 27464 queries.push( [ $.isFunction( inst.options.items ) ? 27465 inst.options.items 27466 .call( inst.element[ 0 ], event, { item: this.currentItem } ) : 27467 $( inst.options.items, inst.element ), inst ] ); 27468 this.containers.push( inst ); 27469 } 27470 } 27471 } 27472 } 27473 27474 for ( i = queries.length - 1; i >= 0; i-- ) { 27475 targetData = queries[ i ][ 1 ]; 27476 _queries = queries[ i ][ 0 ]; 27477 27478 for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) { 27479 item = $( _queries[ j ] ); 27480 27481 // Data for target checking (mouse manager) 27482 item.data( this.widgetName + "-item", targetData ); 27483 27484 items.push( { 27485 item: item, 27486 instance: targetData, 27487 width: 0, height: 0, 27488 left: 0, top: 0 27489 } ); 27490 } 27491 } 27492 27493 }, 27494 27495 refreshPositions: function( fast ) { 27496 27497 // Determine whether items are being displayed horizontally 27498 this.floating = this.items.length ? 27499 this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : 27500 false; 27501 27502 //This has to be redone because due to the item being moved out/into the offsetParent, 27503 // the offsetParent's position will change 27504 if ( this.offsetParent && this.helper ) { 27505 this.offset.parent = this._getParentOffset(); 27506 } 27507 27508 var i, item, t, p; 27509 27510 for ( i = this.items.length - 1; i >= 0; i-- ) { 27511 item = this.items[ i ]; 27512 27513 //We ignore calculating positions of all connected containers when we're not over them 27514 if ( item.instance !== this.currentContainer && this.currentContainer && 27515 item.item[ 0 ] !== this.currentItem[ 0 ] ) { 27516 continue; 27517 } 27518 27519 t = this.options.toleranceElement ? 27520 $( this.options.toleranceElement, item.item ) : 27521 item.item; 27522 27523 if ( !fast ) { 27524 item.width = t.outerWidth(); 27525 item.height = t.outerHeight(); 27526 } 27527 27528 p = t.offset(); 27529 item.left = p.left; 27530 item.top = p.top; 27531 } 27532 27533 if ( this.options.custom && this.options.custom.refreshContainers ) { 27534 this.options.custom.refreshContainers.call( this ); 27535 } else { 27536 for ( i = this.containers.length - 1; i >= 0; i-- ) { 27537 p = this.containers[ i ].element.offset(); 27538 this.containers[ i ].containerCache.left = p.left; 27539 this.containers[ i ].containerCache.top = p.top; 27540 this.containers[ i ].containerCache.width = 27541 this.containers[ i ].element.outerWidth(); 27542 this.containers[ i ].containerCache.height = 27543 this.containers[ i ].element.outerHeight(); 27544 } 27545 } 27546 27547 return this; 27548 }, 27549 27550 _createPlaceholder: function( that ) { 27551 that = that || this; 27552 var className, 27553 o = that.options; 27554 27555 if ( !o.placeholder || o.placeholder.constructor === String ) { 27556 className = o.placeholder; 27557 o.placeholder = { 27558 element: function() { 27559 27560 var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(), 27561 element = $( "<" + nodeName + ">", that.document[ 0 ] ); 27562 27563 that._addClass( element, "ui-sortable-placeholder", 27564 className || that.currentItem[ 0 ].className ) 27565 ._removeClass( element, "ui-sortable-helper" ); 27566 27567 if ( nodeName === "tbody" ) { 27568 that._createTrPlaceholder( 27569 that.currentItem.find( "tr" ).eq( 0 ), 27570 $( "<tr>", that.document[ 0 ] ).appendTo( element ) 27571 ); 27572 } else if ( nodeName === "tr" ) { 27573 that._createTrPlaceholder( that.currentItem, element ); 27574 } else if ( nodeName === "img" ) { 27575 element.attr( "src", that.currentItem.attr( "src" ) ); 27576 } 27577 27578 if ( !className ) { 27579 element.css( "visibility", "hidden" ); 27580 } 27581 27582 return element; 27583 }, 27584 update: function( container, p ) { 27585 27586 // 1. If a className is set as 'placeholder option, we don't force sizes - 27587 // the class is responsible for that 27588 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a 27589 // class name is specified 27590 if ( className && !o.forcePlaceholderSize ) { 27591 return; 27592 } 27593 27594 //If the element doesn't have a actual height by itself (without styles coming 27595 // from a stylesheet), it receives the inline height from the dragged item 27596 if ( !p.height() ) { 27597 p.height( 27598 that.currentItem.innerHeight() - 27599 parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) - 27600 parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) ); 27601 } 27602 if ( !p.width() ) { 27603 p.width( 27604 that.currentItem.innerWidth() - 27605 parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) - 27606 parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) ); 27607 } 27608 } 27609 }; 27610 } 27611 27612 //Create the placeholder 27613 that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) ); 27614 27615 //Append it after the actual current item 27616 that.currentItem.after( that.placeholder ); 27617 27618 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) 27619 o.placeholder.update( that, that.placeholder ); 27620 27621 }, 27622 27623 _createTrPlaceholder: function( sourceTr, targetTr ) { 27624 var that = this; 27625 27626 sourceTr.children().each( function() { 27627 $( "<td> </td>", that.document[ 0 ] ) 27628 .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) 27629 .appendTo( targetTr ); 27630 } ); 27631 }, 27632 27633 _contactContainers: function( event ) { 27634 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, 27635 floating, axis, 27636 innermostContainer = null, 27637 innermostIndex = null; 27638 27639 // Get innermost container that intersects with item 27640 for ( i = this.containers.length - 1; i >= 0; i-- ) { 27641 27642 // Never consider a container that's located within the item itself 27643 if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) { 27644 continue; 27645 } 27646 27647 if ( this._intersectsWith( this.containers[ i ].containerCache ) ) { 27648 27649 // If we've already found a container and it's more "inner" than this, then continue 27650 if ( innermostContainer && 27651 $.contains( 27652 this.containers[ i ].element[ 0 ], 27653 innermostContainer.element[ 0 ] ) ) { 27654 continue; 27655 } 27656 27657 innermostContainer = this.containers[ i ]; 27658 innermostIndex = i; 27659 27660 } else { 27661 27662 // container doesn't intersect. trigger "out" event if necessary 27663 if ( this.containers[ i ].containerCache.over ) { 27664 this.containers[ i ]._trigger( "out", event, this._uiHash( this ) ); 27665 this.containers[ i ].containerCache.over = 0; 27666 } 27667 } 27668 27669 } 27670 27671 // If no intersecting containers found, return 27672 if ( !innermostContainer ) { 27673 return; 27674 } 27675 27676 // Move the item into the container if it's not there already 27677 if ( this.containers.length === 1 ) { 27678 if ( !this.containers[ innermostIndex ].containerCache.over ) { 27679 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 27680 this.containers[ innermostIndex ].containerCache.over = 1; 27681 } 27682 } else { 27683 27684 // When entering a new container, we will find the item with the least distance and 27685 // append our item near it 27686 dist = 10000; 27687 itemWithLeastDistance = null; 27688 floating = innermostContainer.floating || this._isFloating( this.currentItem ); 27689 posProperty = floating ? "left" : "top"; 27690 sizeProperty = floating ? "width" : "height"; 27691 axis = floating ? "pageX" : "pageY"; 27692 27693 for ( j = this.items.length - 1; j >= 0; j-- ) { 27694 if ( !$.contains( 27695 this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) 27696 ) { 27697 continue; 27698 } 27699 if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) { 27700 continue; 27701 } 27702 27703 cur = this.items[ j ].item.offset()[ posProperty ]; 27704 nearBottom = false; 27705 if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { 27706 nearBottom = true; 27707 } 27708 27709 if ( Math.abs( event[ axis ] - cur ) < dist ) { 27710 dist = Math.abs( event[ axis ] - cur ); 27711 itemWithLeastDistance = this.items[ j ]; 27712 this.direction = nearBottom ? "up" : "down"; 27713 } 27714 } 27715 27716 //Check if dropOnEmpty is enabled 27717 if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) { 27718 return; 27719 } 27720 27721 if ( this.currentContainer === this.containers[ innermostIndex ] ) { 27722 if ( !this.currentContainer.containerCache.over ) { 27723 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() ); 27724 this.currentContainer.containerCache.over = 1; 27725 } 27726 return; 27727 } 27728 27729 itemWithLeastDistance ? 27730 this._rearrange( event, itemWithLeastDistance, null, true ) : 27731 this._rearrange( event, null, this.containers[ innermostIndex ].element, true ); 27732 this._trigger( "change", event, this._uiHash() ); 27733 this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) ); 27734 this.currentContainer = this.containers[ innermostIndex ]; 27735 27736 //Update the placeholder 27737 this.options.placeholder.update( this.currentContainer, this.placeholder ); 27738 27739 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 27740 this.containers[ innermostIndex ].containerCache.over = 1; 27741 } 27742 27743 }, 27744 27745 _createHelper: function( event ) { 27746 27747 var o = this.options, 27748 helper = $.isFunction( o.helper ) ? 27749 $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : 27750 ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); 27751 27752 //Add the helper to the DOM if that didn't happen already 27753 if ( !helper.parents( "body" ).length ) { 27754 $( o.appendTo !== "parent" ? 27755 o.appendTo : 27756 this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] ); 27757 } 27758 27759 if ( helper[ 0 ] === this.currentItem[ 0 ] ) { 27760 this._storedCSS = { 27761 width: this.currentItem[ 0 ].style.width, 27762 height: this.currentItem[ 0 ].style.height, 27763 position: this.currentItem.css( "position" ), 27764 top: this.currentItem.css( "top" ), 27765 left: this.currentItem.css( "left" ) 27766 }; 27767 } 27768 27769 if ( !helper[ 0 ].style.width || o.forceHelperSize ) { 27770 helper.width( this.currentItem.width() ); 27771 } 27772 if ( !helper[ 0 ].style.height || o.forceHelperSize ) { 27773 helper.height( this.currentItem.height() ); 27774 } 27775 27776 return helper; 27777 27778 }, 27779 27780 _adjustOffsetFromHelper: function( obj ) { 27781 if ( typeof obj === "string" ) { 27782 obj = obj.split( " " ); 27783 } 27784 if ( $.isArray( obj ) ) { 27785 obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; 27786 } 27787 if ( "left" in obj ) { 27788 this.offset.click.left = obj.left + this.margins.left; 27789 } 27790 if ( "right" in obj ) { 27791 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 27792 } 27793 if ( "top" in obj ) { 27794 this.offset.click.top = obj.top + this.margins.top; 27795 } 27796 if ( "bottom" in obj ) { 27797 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 27798 } 27799 }, 27800 27801 _getParentOffset: function() { 27802 27803 //Get the offsetParent and cache its position 27804 this.offsetParent = this.helper.offsetParent(); 27805 var po = this.offsetParent.offset(); 27806 27807 // This is a special case where we need to modify a offset calculated on start, since the 27808 // following happened: 27809 // 1. The position of the helper is absolute, so it's position is calculated based on the 27810 // next positioned parent 27811 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't 27812 // the document, which means that the scroll is included in the initial calculation of the 27813 // offset of the parent, and never recalculated upon drag 27814 if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && 27815 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { 27816 po.left += this.scrollParent.scrollLeft(); 27817 po.top += this.scrollParent.scrollTop(); 27818 } 27819 27820 // This needs to be actually done for all browsers, since pageX/pageY includes this 27821 // information with an ugly IE fix 27822 if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || 27823 ( this.offsetParent[ 0 ].tagName && 27824 this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { 27825 po = { top: 0, left: 0 }; 27826 } 27827 27828 return { 27829 top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), 27830 left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) 27831 }; 27832 27833 }, 27834 27835 _getRelativeOffset: function() { 27836 27837 if ( this.cssPosition === "relative" ) { 27838 var p = this.currentItem.position(); 27839 return { 27840 top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + 27841 this.scrollParent.scrollTop(), 27842 left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + 27843 this.scrollParent.scrollLeft() 27844 }; 27845 } else { 27846 return { top: 0, left: 0 }; 27847 } 27848 27849 }, 27850 27851 _cacheMargins: function() { 27852 this.margins = { 27853 left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ), 27854 top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 ) 27855 }; 27856 }, 27857 27858 _cacheHelperProportions: function() { 27859 this.helperProportions = { 27860 width: this.helper.outerWidth(), 27861 height: this.helper.outerHeight() 27862 }; 27863 }, 27864 27865 _setContainment: function() { 27866 27867 var ce, co, over, 27868 o = this.options; 27869 if ( o.containment === "parent" ) { 27870 o.containment = this.helper[ 0 ].parentNode; 27871 } 27872 if ( o.containment === "document" || o.containment === "window" ) { 27873 this.containment = [ 27874 0 - this.offset.relative.left - this.offset.parent.left, 27875 0 - this.offset.relative.top - this.offset.parent.top, 27876 o.containment === "document" ? 27877 this.document.width() : 27878 this.window.width() - this.helperProportions.width - this.margins.left, 27879 ( o.containment === "document" ? 27880 ( this.document.height() || document.body.parentNode.scrollHeight ) : 27881 this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight 27882 ) - this.helperProportions.height - this.margins.top 27883 ]; 27884 } 27885 27886 if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) { 27887 ce = $( o.containment )[ 0 ]; 27888 co = $( o.containment ).offset(); 27889 over = ( $( ce ).css( "overflow" ) !== "hidden" ); 27890 27891 this.containment = [ 27892 co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + 27893 ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left, 27894 co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + 27895 ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top, 27896 co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - 27897 ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - 27898 ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - 27899 this.helperProportions.width - this.margins.left, 27900 co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - 27901 ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - 27902 ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - 27903 this.helperProportions.height - this.margins.top 27904 ]; 27905 } 27906 27907 }, 27908 27909 _convertPositionTo: function( d, pos ) { 27910 27911 if ( !pos ) { 27912 pos = this.position; 27913 } 27914 var mod = d === "absolute" ? 1 : -1, 27915 scroll = this.cssPosition === "absolute" && 27916 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 27917 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 27918 this.offsetParent : 27919 this.scrollParent, 27920 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 27921 27922 return { 27923 top: ( 27924 27925 // The absolute mouse position 27926 pos.top + 27927 27928 // Only for relative positioned nodes: Relative offset from element to offset parent 27929 this.offset.relative.top * mod + 27930 27931 // The offsetParent's offset without borders (offset + border) 27932 this.offset.parent.top * mod - 27933 ( ( this.cssPosition === "fixed" ? 27934 -this.scrollParent.scrollTop() : 27935 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod ) 27936 ), 27937 left: ( 27938 27939 // The absolute mouse position 27940 pos.left + 27941 27942 // Only for relative positioned nodes: Relative offset from element to offset parent 27943 this.offset.relative.left * mod + 27944 27945 // The offsetParent's offset without borders (offset + border) 27946 this.offset.parent.left * mod - 27947 ( ( this.cssPosition === "fixed" ? 27948 -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : 27949 scroll.scrollLeft() ) * mod ) 27950 ) 27951 }; 27952 27953 }, 27954 27955 _generatePosition: function( event ) { 27956 27957 var top, left, 27958 o = this.options, 27959 pageX = event.pageX, 27960 pageY = event.pageY, 27961 scroll = this.cssPosition === "absolute" && 27962 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 27963 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 27964 this.offsetParent : 27965 this.scrollParent, 27966 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 27967 27968 // This is another very weird special case that only happens for relative elements: 27969 // 1. If the css position is relative 27970 // 2. and the scroll parent is the document or similar to the offset parent 27971 // we have to refresh the relative offset during the scroll so there are no jumps 27972 if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 27973 this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) { 27974 this.offset.relative = this._getRelativeOffset(); 27975 } 27976 27977 /* 27978 * - Position constraining - 27979 * Constrain the position to a mix of grid, containment. 27980 */ 27981 27982 if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options 27983 27984 if ( this.containment ) { 27985 if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) { 27986 pageX = this.containment[ 0 ] + this.offset.click.left; 27987 } 27988 if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) { 27989 pageY = this.containment[ 1 ] + this.offset.click.top; 27990 } 27991 if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) { 27992 pageX = this.containment[ 2 ] + this.offset.click.left; 27993 } 27994 if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) { 27995 pageY = this.containment[ 3 ] + this.offset.click.top; 27996 } 27997 } 27998 27999 if ( o.grid ) { 28000 top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / 28001 o.grid[ 1 ] ) * o.grid[ 1 ]; 28002 pageY = this.containment ? 28003 ( ( top - this.offset.click.top >= this.containment[ 1 ] && 28004 top - this.offset.click.top <= this.containment[ 3 ] ) ? 28005 top : 28006 ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? 28007 top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : 28008 top; 28009 28010 left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / 28011 o.grid[ 0 ] ) * o.grid[ 0 ]; 28012 pageX = this.containment ? 28013 ( ( left - this.offset.click.left >= this.containment[ 0 ] && 28014 left - this.offset.click.left <= this.containment[ 2 ] ) ? 28015 left : 28016 ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? 28017 left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : 28018 left; 28019 } 28020 28021 } 28022 28023 return { 28024 top: ( 28025 28026 // The absolute mouse position 28027 pageY - 28028 28029 // Click offset (relative to the element) 28030 this.offset.click.top - 28031 28032 // Only for relative positioned nodes: Relative offset from element to offset parent 28033 this.offset.relative.top - 28034 28035 // The offsetParent's offset without borders (offset + border) 28036 this.offset.parent.top + 28037 ( ( this.cssPosition === "fixed" ? 28038 -this.scrollParent.scrollTop() : 28039 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) ) 28040 ), 28041 left: ( 28042 28043 // The absolute mouse position 28044 pageX - 28045 28046 // Click offset (relative to the element) 28047 this.offset.click.left - 28048 28049 // Only for relative positioned nodes: Relative offset from element to offset parent 28050 this.offset.relative.left - 28051 28052 // The offsetParent's offset without borders (offset + border) 28053 this.offset.parent.left + 28054 ( ( this.cssPosition === "fixed" ? 28055 -this.scrollParent.scrollLeft() : 28056 scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) 28057 ) 28058 }; 28059 28060 }, 28061 28062 _rearrange: function( event, i, a, hardRefresh ) { 28063 28064 a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : 28065 i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], 28066 ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) ); 28067 28068 //Various things done here to improve the performance: 28069 // 1. we create a setTimeout, that calls refreshPositions 28070 // 2. on the instance, we have a counter variable, that get's higher after every append 28071 // 3. on the local scope, we copy the counter variable, and check in the timeout, 28072 // if it's still the same 28073 // 4. this lets only the last addition to the timeout stack through 28074 this.counter = this.counter ? ++this.counter : 1; 28075 var counter = this.counter; 28076 28077 this._delay( function() { 28078 if ( counter === this.counter ) { 28079 28080 //Precompute after each DOM insertion, NOT on mousemove 28081 this.refreshPositions( !hardRefresh ); 28082 } 28083 } ); 28084 28085 }, 28086 28087 _clear: function( event, noPropagation ) { 28088 28089 this.reverting = false; 28090 28091 // We delay all events that have to be triggered to after the point where the placeholder 28092 // has been removed and everything else normalized again 28093 var i, 28094 delayedTriggers = []; 28095 28096 // We first have to update the dom position of the actual currentItem 28097 // Note: don't do it if the current item is already removed (by a user), or it gets 28098 // reappended (see #4088) 28099 if ( !this._noFinalSort && this.currentItem.parent().length ) { 28100 this.placeholder.before( this.currentItem ); 28101 } 28102 this._noFinalSort = null; 28103 28104 if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) { 28105 for ( i in this._storedCSS ) { 28106 if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) { 28107 this._storedCSS[ i ] = ""; 28108 } 28109 } 28110 this.currentItem.css( this._storedCSS ); 28111 this._removeClass( this.currentItem, "ui-sortable-helper" ); 28112 } else { 28113 this.currentItem.show(); 28114 } 28115 28116 if ( this.fromOutside && !noPropagation ) { 28117 delayedTriggers.push( function( event ) { 28118 this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); 28119 } ); 28120 } 28121 if ( ( this.fromOutside || 28122 this.domPosition.prev !== 28123 this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || 28124 this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) { 28125 28126 // Trigger update callback if the DOM position has changed 28127 delayedTriggers.push( function( event ) { 28128 this._trigger( "update", event, this._uiHash() ); 28129 } ); 28130 } 28131 28132 // Check if the items Container has Changed and trigger appropriate 28133 // events. 28134 if ( this !== this.currentContainer ) { 28135 if ( !noPropagation ) { 28136 delayedTriggers.push( function( event ) { 28137 this._trigger( "remove", event, this._uiHash() ); 28138 } ); 28139 delayedTriggers.push( ( function( c ) { 28140 return function( event ) { 28141 c._trigger( "receive", event, this._uiHash( this ) ); 28142 }; 28143 } ).call( this, this.currentContainer ) ); 28144 delayedTriggers.push( ( function( c ) { 28145 return function( event ) { 28146 c._trigger( "update", event, this._uiHash( this ) ); 28147 }; 28148 } ).call( this, this.currentContainer ) ); 28149 } 28150 } 28151 28152 //Post events to containers 28153 function delayEvent( type, instance, container ) { 28154 return function( event ) { 28155 container._trigger( type, event, instance._uiHash( instance ) ); 28156 }; 28157 } 28158 for ( i = this.containers.length - 1; i >= 0; i-- ) { 28159 if ( !noPropagation ) { 28160 delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); 28161 } 28162 if ( this.containers[ i ].containerCache.over ) { 28163 delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); 28164 this.containers[ i ].containerCache.over = 0; 28165 } 28166 } 28167 28168 //Do what was originally in plugins 28169 if ( this.storedCursor ) { 28170 this.document.find( "body" ).css( "cursor", this.storedCursor ); 28171 this.storedStylesheet.remove(); 28172 } 28173 if ( this._storedOpacity ) { 28174 this.helper.css( "opacity", this._storedOpacity ); 28175 } 28176 if ( this._storedZIndex ) { 28177 this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex ); 28178 } 28179 28180 this.dragging = false; 28181 28182 if ( !noPropagation ) { 28183 this._trigger( "beforeStop", event, this._uiHash() ); 28184 } 28185 28186 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 28187 // it unbinds ALL events from the original node! 28188 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 28189 28190 if ( !this.cancelHelperRemoval ) { 28191 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { 28192 this.helper.remove(); 28193 } 28194 this.helper = null; 28195 } 28196 28197 if ( !noPropagation ) { 28198 for ( i = 0; i < delayedTriggers.length; i++ ) { 28199 28200 // Trigger all delayed events 28201 delayedTriggers[ i ].call( this, event ); 28202 } 28203 this._trigger( "stop", event, this._uiHash() ); 28204 } 28205 28206 this.fromOutside = false; 28207 return !this.cancelHelperRemoval; 28208 28209 }, 28210 28211 _trigger: function() { 28212 if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) { 28213 this.cancel(); 28214 } 28215 }, 28216 28217 _uiHash: function( _inst ) { 28218 var inst = _inst || this; 28219 return { 28220 helper: inst.helper, 28221 placeholder: inst.placeholder || $( [] ), 28222 position: inst.position, 28223 originalPosition: inst.originalPosition, 28224 offset: inst.positionAbs, 28225 item: inst.currentItem, 28226 sender: _inst ? _inst.element : null 28227 }; 28228 } 28229 28230 } ); 28231 28232 } ) ); 28233 28234 28235 /***/ }, 28236 /* 87 */ 28237 /***/ function(module, exports, __webpack_require__) { 28238 28239 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 28240 * jQuery JavaScript Library v2.2.4 28241 * http://jquery.com/ 28242 * 28243 * Includes Sizzle.js 28244 * http://sizzlejs.com/ 28245 * 28246 * Copyright jQuery Foundation and other contributors 28247 * Released under the MIT license 28248 * http://jquery.org/license 28249 * 28250 * Date: 2016-05-20T17:23Z 28251 */ 28252 28253 (function( global, factory ) { 28254 28255 if ( typeof module === "object" && typeof module.exports === "object" ) { 28256 // For CommonJS and CommonJS-like environments where a proper `window` 28257 // is present, execute the factory and get jQuery. 28258 // For environments that do not have a `window` with a `document` 28259 // (such as Node.js), expose a factory as module.exports. 28260 // This accentuates the need for the creation of a real `window`. 28261 // e.g. var jQuery = require("jquery")(window); 28262 // See ticket #14549 for more info. 28263 module.exports = global.document ? 28264 factory( global, true ) : 28265 function( w ) { 28266 if ( !w.document ) { 28267 throw new Error( "jQuery requires a window with a document" ); 28268 } 28269 return factory( w ); 28270 }; 28271 } else { 28272 factory( global ); 28273 } 28274 28275 // Pass this if window is not defined yet 28276 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 28277 28278 // Support: Firefox 18+ 28279 // Can't be in strict mode, several libs including ASP.NET trace 28280 // the stack via arguments.caller.callee and Firefox dies if 28281 // you try to trace through "use strict" call chains. (#13335) 28282 //"use strict"; 28283 var arr = []; 28284 28285 var document = window.document; 28286 28287 var slice = arr.slice; 28288 28289 var concat = arr.concat; 28290 28291 var push = arr.push; 28292 28293 var indexOf = arr.indexOf; 28294 28295 var class2type = {}; 28296 28297 var toString = class2type.toString; 28298 28299 var hasOwn = class2type.hasOwnProperty; 28300 28301 var support = {}; 28302 28303 28304 28305 var 28306 version = "2.2.4", 28307 28308 // Define a local copy of jQuery 28309 jQuery = function( selector, context ) { 28310 28311 // The jQuery object is actually just the init constructor 'enhanced' 28312 // Need init if jQuery is called (just allow error to be thrown if not included) 28313 return new jQuery.fn.init( selector, context ); 28314 }, 28315 28316 // Support: Android<4.1 28317 // Make sure we trim BOM and NBSP 28318 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, 28319 28320 // Matches dashed string for camelizing 28321 rmsPrefix = /^-ms-/, 28322 rdashAlpha = /-([\da-z])/gi, 28323 28324 // Used by jQuery.camelCase as callback to replace() 28325 fcamelCase = function( all, letter ) { 28326 return letter.toUpperCase(); 28327 }; 28328 28329 jQuery.fn = jQuery.prototype = { 28330 28331 // The current version of jQuery being used 28332 jquery: version, 28333 28334 constructor: jQuery, 28335 28336 // Start with an empty selector 28337 selector: "", 28338 28339 // The default length of a jQuery object is 0 28340 length: 0, 28341 28342 toArray: function() { 28343 return slice.call( this ); 28344 }, 28345 28346 // Get the Nth element in the matched element set OR 28347 // Get the whole matched element set as a clean array 28348 get: function( num ) { 28349 return num != null ? 28350 28351 // Return just the one element from the set 28352 ( num < 0 ? this[ num + this.length ] : this[ num ] ) : 28353 28354 // Return all the elements in a clean array 28355 slice.call( this ); 28356 }, 28357 28358 // Take an array of elements and push it onto the stack 28359 // (returning the new matched element set) 28360 pushStack: function( elems ) { 28361 28362 // Build a new jQuery matched element set 28363 var ret = jQuery.merge( this.constructor(), elems ); 28364 28365 // Add the old object onto the stack (as a reference) 28366 ret.prevObject = this; 28367 ret.context = this.context; 28368 28369 // Return the newly-formed element set 28370 return ret; 28371 }, 28372 28373 // Execute a callback for every element in the matched set. 28374 each: function( callback ) { 28375 return jQuery.each( this, callback ); 28376 }, 28377 28378 map: function( callback ) { 28379 return this.pushStack( jQuery.map( this, function( elem, i ) { 28380 return callback.call( elem, i, elem ); 28381 } ) ); 28382 }, 28383 28384 slice: function() { 28385 return this.pushStack( slice.apply( this, arguments ) ); 28386 }, 28387 28388 first: function() { 28389 return this.eq( 0 ); 28390 }, 28391 28392 last: function() { 28393 return this.eq( -1 ); 28394 }, 28395 28396 eq: function( i ) { 28397 var len = this.length, 28398 j = +i + ( i < 0 ? len : 0 ); 28399 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 28400 }, 28401 28402 end: function() { 28403 return this.prevObject || this.constructor(); 28404 }, 28405 28406 // For internal use only. 28407 // Behaves like an Array's method, not like a jQuery method. 28408 push: push, 28409 sort: arr.sort, 28410 splice: arr.splice 28411 }; 28412 28413 jQuery.extend = jQuery.fn.extend = function() { 28414 var options, name, src, copy, copyIsArray, clone, 28415 target = arguments[ 0 ] || {}, 28416 i = 1, 28417 length = arguments.length, 28418 deep = false; 28419 28420 // Handle a deep copy situation 28421 if ( typeof target === "boolean" ) { 28422 deep = target; 28423 28424 // Skip the boolean and the target 28425 target = arguments[ i ] || {}; 28426 i++; 28427 } 28428 28429 // Handle case when target is a string or something (possible in deep copy) 28430 if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { 28431 target = {}; 28432 } 28433 28434 // Extend jQuery itself if only one argument is passed 28435 if ( i === length ) { 28436 target = this; 28437 i--; 28438 } 28439 28440 for ( ; i < length; i++ ) { 28441 28442 // Only deal with non-null/undefined values 28443 if ( ( options = arguments[ i ] ) != null ) { 28444 28445 // Extend the base object 28446 for ( name in options ) { 28447 src = target[ name ]; 28448 copy = options[ name ]; 28449 28450 // Prevent never-ending loop 28451 if ( target === copy ) { 28452 continue; 28453 } 28454 28455 // Recurse if we're merging plain objects or arrays 28456 if ( deep && copy && ( jQuery.isPlainObject( copy ) || 28457 ( copyIsArray = jQuery.isArray( copy ) ) ) ) { 28458 28459 if ( copyIsArray ) { 28460 copyIsArray = false; 28461 clone = src && jQuery.isArray( src ) ? src : []; 28462 28463 } else { 28464 clone = src && jQuery.isPlainObject( src ) ? src : {}; 28465 } 28466 28467 // Never move original objects, clone them 28468 target[ name ] = jQuery.extend( deep, clone, copy ); 28469 28470 // Don't bring in undefined values 28471 } else if ( copy !== undefined ) { 28472 target[ name ] = copy; 28473 } 28474 } 28475 } 28476 } 28477 28478 // Return the modified object 28479 return target; 28480 }; 28481 28482 jQuery.extend( { 28483 28484 // Unique for each copy of jQuery on the page 28485 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 28486 28487 // Assume jQuery is ready without the ready module 28488 isReady: true, 28489 28490 error: function( msg ) { 28491 throw new Error( msg ); 28492 }, 28493 28494 noop: function() {}, 28495 28496 isFunction: function( obj ) { 28497 return jQuery.type( obj ) === "function"; 28498 }, 28499 28500 isArray: Array.isArray, 28501 28502 isWindow: function( obj ) { 28503 return obj != null && obj === obj.window; 28504 }, 28505 28506 isNumeric: function( obj ) { 28507 28508 // parseFloat NaNs numeric-cast false positives (null|true|false|"") 28509 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 28510 // subtraction forces infinities to NaN 28511 // adding 1 corrects loss of precision from parseFloat (#15100) 28512 var realStringObj = obj && obj.toString(); 28513 return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; 28514 }, 28515 28516 isPlainObject: function( obj ) { 28517 var key; 28518 28519 // Not plain objects: 28520 // - Any object or value whose internal [[Class]] property is not "[object Object]" 28521 // - DOM nodes 28522 // - window 28523 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { 28524 return false; 28525 } 28526 28527 // Not own constructor property must be Object 28528 if ( obj.constructor && 28529 !hasOwn.call( obj, "constructor" ) && 28530 !hasOwn.call( obj.constructor.prototype || {}, "isPrototypeOf" ) ) { 28531 return false; 28532 } 28533 28534 // Own properties are enumerated firstly, so to speed up, 28535 // if last one is own, then all properties are own 28536 for ( key in obj ) {} 28537 28538 return key === undefined || hasOwn.call( obj, key ); 28539 }, 28540 28541 isEmptyObject: function( obj ) { 28542 var name; 28543 for ( name in obj ) { 28544 return false; 28545 } 28546 return true; 28547 }, 28548 28549 type: function( obj ) { 28550 if ( obj == null ) { 28551 return obj + ""; 28552 } 28553 28554 // Support: Android<4.0, iOS<6 (functionish RegExp) 28555 return typeof obj === "object" || typeof obj === "function" ? 28556 class2type[ toString.call( obj ) ] || "object" : 28557 typeof obj; 28558 }, 28559 28560 // Evaluates a script in a global context 28561 globalEval: function( code ) { 28562 var script, 28563 indirect = eval; 28564 28565 code = jQuery.trim( code ); 28566 28567 if ( code ) { 28568 28569 // If the code includes a valid, prologue position 28570 // strict mode pragma, execute code by injecting a 28571 // script tag into the document. 28572 if ( code.indexOf( "use strict" ) === 1 ) { 28573 script = document.createElement( "script" ); 28574 script.text = code; 28575 document.head.appendChild( script ).parentNode.removeChild( script ); 28576 } else { 28577 28578 // Otherwise, avoid the DOM node creation, insertion 28579 // and removal by using an indirect global eval 28580 28581 indirect( code ); 28582 } 28583 } 28584 }, 28585 28586 // Convert dashed to camelCase; used by the css and data modules 28587 // Support: IE9-11+ 28588 // Microsoft forgot to hump their vendor prefix (#9572) 28589 camelCase: function( string ) { 28590 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 28591 }, 28592 28593 nodeName: function( elem, name ) { 28594 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 28595 }, 28596 28597 each: function( obj, callback ) { 28598 var length, i = 0; 28599 28600 if ( isArrayLike( obj ) ) { 28601 length = obj.length; 28602 for ( ; i < length; i++ ) { 28603 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 28604 break; 28605 } 28606 } 28607 } else { 28608 for ( i in obj ) { 28609 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 28610 break; 28611 } 28612 } 28613 } 28614 28615 return obj; 28616 }, 28617 28618 // Support: Android<4.1 28619 trim: function( text ) { 28620 return text == null ? 28621 "" : 28622 ( text + "" ).replace( rtrim, "" ); 28623 }, 28624 28625 // results is for internal usage only 28626 makeArray: function( arr, results ) { 28627 var ret = results || []; 28628 28629 if ( arr != null ) { 28630 if ( isArrayLike( Object( arr ) ) ) { 28631 jQuery.merge( ret, 28632 typeof arr === "string" ? 28633 [ arr ] : arr 28634 ); 28635 } else { 28636 push.call( ret, arr ); 28637 } 28638 } 28639 28640 return ret; 28641 }, 28642 28643 inArray: function( elem, arr, i ) { 28644 return arr == null ? -1 : indexOf.call( arr, elem, i ); 28645 }, 28646 28647 merge: function( first, second ) { 28648 var len = +second.length, 28649 j = 0, 28650 i = first.length; 28651 28652 for ( ; j < len; j++ ) { 28653 first[ i++ ] = second[ j ]; 28654 } 28655 28656 first.length = i; 28657 28658 return first; 28659 }, 28660 28661 grep: function( elems, callback, invert ) { 28662 var callbackInverse, 28663 matches = [], 28664 i = 0, 28665 length = elems.length, 28666 callbackExpect = !invert; 28667 28668 // Go through the array, only saving the items 28669 // that pass the validator function 28670 for ( ; i < length; i++ ) { 28671 callbackInverse = !callback( elems[ i ], i ); 28672 if ( callbackInverse !== callbackExpect ) { 28673 matches.push( elems[ i ] ); 28674 } 28675 } 28676 28677 return matches; 28678 }, 28679 28680 // arg is for internal usage only 28681 map: function( elems, callback, arg ) { 28682 var length, value, 28683 i = 0, 28684 ret = []; 28685 28686 // Go through the array, translating each of the items to their new values 28687 if ( isArrayLike( elems ) ) { 28688 length = elems.length; 28689 for ( ; i < length; i++ ) { 28690 value = callback( elems[ i ], i, arg ); 28691 28692 if ( value != null ) { 28693 ret.push( value ); 28694 } 28695 } 28696 28697 // Go through every key on the object, 28698 } else { 28699 for ( i in elems ) { 28700 value = callback( elems[ i ], i, arg ); 28701 28702 if ( value != null ) { 28703 ret.push( value ); 28704 } 28705 } 28706 } 28707 28708 // Flatten any nested arrays 28709 return concat.apply( [], ret ); 28710 }, 28711 28712 // A global GUID counter for objects 28713 guid: 1, 28714 28715 // Bind a function to a context, optionally partially applying any 28716 // arguments. 28717 proxy: function( fn, context ) { 28718 var tmp, args, proxy; 28719 28720 if ( typeof context === "string" ) { 28721 tmp = fn[ context ]; 28722 context = fn; 28723 fn = tmp; 28724 } 28725 28726 // Quick check to determine if target is callable, in the spec 28727 // this throws a TypeError, but we will just return undefined. 28728 if ( !jQuery.isFunction( fn ) ) { 28729 return undefined; 28730 } 28731 28732 // Simulated bind 28733 args = slice.call( arguments, 2 ); 28734 proxy = function() { 28735 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 28736 }; 28737 28738 // Set the guid of unique handler to the same of original handler, so it can be removed 28739 proxy.guid = fn.guid = fn.guid || jQuery.guid++; 28740 28741 return proxy; 28742 }, 28743 28744 now: Date.now, 28745 28746 // jQuery.support is not used in Core but other projects attach their 28747 // properties to it so it needs to exist. 28748 support: support 28749 } ); 28750 28751 // JSHint would error on this code due to the Symbol not being defined in ES5. 28752 // Defining this global in .jshintrc would create a danger of using the global 28753 // unguarded in another place, it seems safer to just disable JSHint for these 28754 // three lines. 28755 /* jshint ignore: start */ 28756 if ( typeof Symbol === "function" ) { 28757 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; 28758 } 28759 /* jshint ignore: end */ 28760 28761 // Populate the class2type map 28762 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 28763 function( i, name ) { 28764 class2type[ "[object " + name + "]" ] = name.toLowerCase(); 28765 } ); 28766 28767 function isArrayLike( obj ) { 28768 28769 // Support: iOS 8.2 (not reproducible in simulator) 28770 // `in` check used to prevent JIT error (gh-2145) 28771 // hasOwn isn't used here due to false negatives 28772 // regarding Nodelist length in IE 28773 var length = !!obj && "length" in obj && obj.length, 28774 type = jQuery.type( obj ); 28775 28776 if ( type === "function" || jQuery.isWindow( obj ) ) { 28777 return false; 28778 } 28779 28780 return type === "array" || length === 0 || 28781 typeof length === "number" && length > 0 && ( length - 1 ) in obj; 28782 } 28783 var Sizzle = 28784 /*! 28785 * Sizzle CSS Selector Engine v2.2.1 28786 * http://sizzlejs.com/ 28787 * 28788 * Copyright jQuery Foundation and other contributors 28789 * Released under the MIT license 28790 * http://jquery.org/license 28791 * 28792 * Date: 2015-10-17 28793 */ 28794 (function( window ) { 28795 28796 var i, 28797 support, 28798 Expr, 28799 getText, 28800 isXML, 28801 tokenize, 28802 compile, 28803 select, 28804 outermostContext, 28805 sortInput, 28806 hasDuplicate, 28807 28808 // Local document vars 28809 setDocument, 28810 document, 28811 docElem, 28812 documentIsHTML, 28813 rbuggyQSA, 28814 rbuggyMatches, 28815 matches, 28816 contains, 28817 28818 // Instance-specific data 28819 expando = "sizzle" + 1 * new Date(), 28820 preferredDoc = window.document, 28821 dirruns = 0, 28822 done = 0, 28823 classCache = createCache(), 28824 tokenCache = createCache(), 28825 compilerCache = createCache(), 28826 sortOrder = function( a, b ) { 28827 if ( a === b ) { 28828 hasDuplicate = true; 28829 } 28830 return 0; 28831 }, 28832 28833 // General-purpose constants 28834 MAX_NEGATIVE = 1 << 31, 28835 28836 // Instance methods 28837 hasOwn = ({}).hasOwnProperty, 28838 arr = [], 28839 pop = arr.pop, 28840 push_native = arr.push, 28841 push = arr.push, 28842 slice = arr.slice, 28843 // Use a stripped-down indexOf as it's faster than native 28844 // http://jsperf.com/thor-indexof-vs-for/5 28845 indexOf = function( list, elem ) { 28846 var i = 0, 28847 len = list.length; 28848 for ( ; i < len; i++ ) { 28849 if ( list[i] === elem ) { 28850 return i; 28851 } 28852 } 28853 return -1; 28854 }, 28855 28856 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", 28857 28858 // Regular expressions 28859 28860 // http://www.w3.org/TR/css3-selectors/#whitespace 28861 whitespace = "[\\x20\\t\\r\\n\\f]", 28862 28863 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier 28864 identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", 28865 28866 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors 28867 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 28868 // Operator (capture 2) 28869 "*([*^$|!~]?=)" + whitespace + 28870 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" 28871 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + 28872 "*\\]", 28873 28874 pseudos = ":(" + identifier + ")(?:\\((" + 28875 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 28876 // 1. quoted (capture 3; capture 4 or capture 5) 28877 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 28878 // 2. simple (capture 6) 28879 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 28880 // 3. anything else (capture 2) 28881 ".*" + 28882 ")\\)|)", 28883 28884 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 28885 rwhitespace = new RegExp( whitespace + "+", "g" ), 28886 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), 28887 28888 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 28889 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), 28890 28891 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), 28892 28893 rpseudo = new RegExp( pseudos ), 28894 ridentifier = new RegExp( "^" + identifier + "$" ), 28895 28896 matchExpr = { 28897 "ID": new RegExp( "^#(" + identifier + ")" ), 28898 "CLASS": new RegExp( "^\\.(" + identifier + ")" ), 28899 "TAG": new RegExp( "^(" + identifier + "|[*])" ), 28900 "ATTR": new RegExp( "^" + attributes ), 28901 "PSEUDO": new RegExp( "^" + pseudos ), 28902 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + 28903 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + 28904 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 28905 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), 28906 // For use in libraries implementing .is() 28907 // We use this for POS matching in `select` 28908 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + 28909 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 28910 }, 28911 28912 rinputs = /^(?:input|select|textarea|button)$/i, 28913 rheader = /^h\d$/i, 28914 28915 rnative = /^[^{]+\{\s*\[native \w/, 28916 28917 // Easily-parseable/retrievable ID or TAG or CLASS selectors 28918 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 28919 28920 rsibling = /[+~]/, 28921 rescape = /'|\\/g, 28922 28923 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters 28924 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), 28925 funescape = function( _, escaped, escapedWhitespace ) { 28926 var high = "0x" + escaped - 0x10000; 28927 // NaN means non-codepoint 28928 // Support: Firefox<24 28929 // Workaround erroneous numeric interpretation of +"0x" 28930 return high !== high || escapedWhitespace ? 28931 escaped : 28932 high < 0 ? 28933 // BMP codepoint 28934 String.fromCharCode( high + 0x10000 ) : 28935 // Supplemental Plane codepoint (surrogate pair) 28936 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 28937 }, 28938 28939 // Used for iframes 28940 // See setDocument() 28941 // Removing the function wrapper causes a "Permission Denied" 28942 // error in IE 28943 unloadHandler = function() { 28944 setDocument(); 28945 }; 28946 28947 // Optimize for push.apply( _, NodeList ) 28948 try { 28949 push.apply( 28950 (arr = slice.call( preferredDoc.childNodes )), 28951 preferredDoc.childNodes 28952 ); 28953 // Support: Android<4.0 28954 // Detect silently failing push.apply 28955 arr[ preferredDoc.childNodes.length ].nodeType; 28956 } catch ( e ) { 28957 push = { apply: arr.length ? 28958 28959 // Leverage slice if possible 28960 function( target, els ) { 28961 push_native.apply( target, slice.call(els) ); 28962 } : 28963 28964 // Support: IE<9 28965 // Otherwise append directly 28966 function( target, els ) { 28967 var j = target.length, 28968 i = 0; 28969 // Can't trust NodeList.length 28970 while ( (target[j++] = els[i++]) ) {} 28971 target.length = j - 1; 28972 } 28973 }; 28974 } 28975 28976 function Sizzle( selector, context, results, seed ) { 28977 var m, i, elem, nid, nidselect, match, groups, newSelector, 28978 newContext = context && context.ownerDocument, 28979 28980 // nodeType defaults to 9, since context defaults to document 28981 nodeType = context ? context.nodeType : 9; 28982 28983 results = results || []; 28984 28985 // Return early from calls with invalid selector or context 28986 if ( typeof selector !== "string" || !selector || 28987 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 28988 28989 return results; 28990 } 28991 28992 // Try to shortcut find operations (as opposed to filters) in HTML documents 28993 if ( !seed ) { 28994 28995 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { 28996 setDocument( context ); 28997 } 28998 context = context || document; 28999 29000 if ( documentIsHTML ) { 29001 29002 // If the selector is sufficiently simple, try using a "get*By*" DOM method 29003 // (excepting DocumentFragment context, where the methods don't exist) 29004 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { 29005 29006 // ID selector 29007 if ( (m = match[1]) ) { 29008 29009 // Document context 29010 if ( nodeType === 9 ) { 29011 if ( (elem = context.getElementById( m )) ) { 29012 29013 // Support: IE, Opera, Webkit 29014 // TODO: identify versions 29015 // getElementById can match elements by name instead of ID 29016 if ( elem.id === m ) { 29017 results.push( elem ); 29018 return results; 29019 } 29020 } else { 29021 return results; 29022 } 29023 29024 // Element context 29025 } else { 29026 29027 // Support: IE, Opera, Webkit 29028 // TODO: identify versions 29029 // getElementById can match elements by name instead of ID 29030 if ( newContext && (elem = newContext.getElementById( m )) && 29031 contains( context, elem ) && 29032 elem.id === m ) { 29033 29034 results.push( elem ); 29035 return results; 29036 } 29037 } 29038 29039 // Type selector 29040 } else if ( match[2] ) { 29041 push.apply( results, context.getElementsByTagName( selector ) ); 29042 return results; 29043 29044 // Class selector 29045 } else if ( (m = match[3]) && support.getElementsByClassName && 29046 context.getElementsByClassName ) { 29047 29048 push.apply( results, context.getElementsByClassName( m ) ); 29049 return results; 29050 } 29051 } 29052 29053 // Take advantage of querySelectorAll 29054 if ( support.qsa && 29055 !compilerCache[ selector + " " ] && 29056 (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { 29057 29058 if ( nodeType !== 1 ) { 29059 newContext = context; 29060 newSelector = selector; 29061 29062 // qSA looks outside Element context, which is not what we want 29063 // Thanks to Andrew Dupont for this workaround technique 29064 // Support: IE <=8 29065 // Exclude object elements 29066 } else if ( context.nodeName.toLowerCase() !== "object" ) { 29067 29068 // Capture the context ID, setting it first if necessary 29069 if ( (nid = context.getAttribute( "id" )) ) { 29070 nid = nid.replace( rescape, "\\$&" ); 29071 } else { 29072 context.setAttribute( "id", (nid = expando) ); 29073 } 29074 29075 // Prefix every selector in the list 29076 groups = tokenize( selector ); 29077 i = groups.length; 29078 nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; 29079 while ( i-- ) { 29080 groups[i] = nidselect + " " + toSelector( groups[i] ); 29081 } 29082 newSelector = groups.join( "," ); 29083 29084 // Expand context for sibling selectors 29085 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 29086 context; 29087 } 29088 29089 if ( newSelector ) { 29090 try { 29091 push.apply( results, 29092 newContext.querySelectorAll( newSelector ) 29093 ); 29094 return results; 29095 } catch ( qsaError ) { 29096 } finally { 29097 if ( nid === expando ) { 29098 context.removeAttribute( "id" ); 29099 } 29100 } 29101 } 29102 } 29103 } 29104 } 29105 29106 // All others 29107 return select( selector.replace( rtrim, "$1" ), context, results, seed ); 29108 } 29109 29110 /** 29111 * Create key-value caches of limited size 29112 * @returns {function(string, object)} Returns the Object data after storing it on itself with 29113 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 29114 * deleting the oldest entry 29115 */ 29116 function createCache() { 29117 var keys = []; 29118 29119 function cache( key, value ) { 29120 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) 29121 if ( keys.push( key + " " ) > Expr.cacheLength ) { 29122 // Only keep the most recent entries 29123 delete cache[ keys.shift() ]; 29124 } 29125 return (cache[ key + " " ] = value); 29126 } 29127 return cache; 29128 } 29129 29130 /** 29131 * Mark a function for special use by Sizzle 29132 * @param {Function} fn The function to mark 29133 */ 29134 function markFunction( fn ) { 29135 fn[ expando ] = true; 29136 return fn; 29137 } 29138 29139 /** 29140 * Support testing using an element 29141 * @param {Function} fn Passed the created div and expects a boolean result 29142 */ 29143 function assert( fn ) { 29144 var div = document.createElement("div"); 29145 29146 try { 29147 return !!fn( div ); 29148 } catch (e) { 29149 return false; 29150 } finally { 29151 // Remove from its parent by default 29152 if ( div.parentNode ) { 29153 div.parentNode.removeChild( div ); 29154 } 29155 // release memory in IE 29156 div = null; 29157 } 29158 } 29159 29160 /** 29161 * Adds the same handler for all of the specified attrs 29162 * @param {String} attrs Pipe-separated list of attributes 29163 * @param {Function} handler The method that will be applied 29164 */ 29165 function addHandle( attrs, handler ) { 29166 var arr = attrs.split("|"), 29167 i = arr.length; 29168 29169 while ( i-- ) { 29170 Expr.attrHandle[ arr[i] ] = handler; 29171 } 29172 } 29173 29174 /** 29175 * Checks document order of two siblings 29176 * @param {Element} a 29177 * @param {Element} b 29178 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b 29179 */ 29180 function siblingCheck( a, b ) { 29181 var cur = b && a, 29182 diff = cur && a.nodeType === 1 && b.nodeType === 1 && 29183 ( ~b.sourceIndex || MAX_NEGATIVE ) - 29184 ( ~a.sourceIndex || MAX_NEGATIVE ); 29185 29186 // Use IE sourceIndex if available on both nodes 29187 if ( diff ) { 29188 return diff; 29189 } 29190 29191 // Check if b follows a 29192 if ( cur ) { 29193 while ( (cur = cur.nextSibling) ) { 29194 if ( cur === b ) { 29195 return -1; 29196 } 29197 } 29198 } 29199 29200 return a ? 1 : -1; 29201 } 29202 29203 /** 29204 * Returns a function to use in pseudos for input types 29205 * @param {String} type 29206 */ 29207 function createInputPseudo( type ) { 29208 return function( elem ) { 29209 var name = elem.nodeName.toLowerCase(); 29210 return name === "input" && elem.type === type; 29211 }; 29212 } 29213 29214 /** 29215 * Returns a function to use in pseudos for buttons 29216 * @param {String} type 29217 */ 29218 function createButtonPseudo( type ) { 29219 return function( elem ) { 29220 var name = elem.nodeName.toLowerCase(); 29221 return (name === "input" || name === "button") && elem.type === type; 29222 }; 29223 } 29224 29225 /** 29226 * Returns a function to use in pseudos for positionals 29227 * @param {Function} fn 29228 */ 29229 function createPositionalPseudo( fn ) { 29230 return markFunction(function( argument ) { 29231 argument = +argument; 29232 return markFunction(function( seed, matches ) { 29233 var j, 29234 matchIndexes = fn( [], seed.length, argument ), 29235 i = matchIndexes.length; 29236 29237 // Match elements found at the specified indexes 29238 while ( i-- ) { 29239 if ( seed[ (j = matchIndexes[i]) ] ) { 29240 seed[j] = !(matches[j] = seed[j]); 29241 } 29242 } 29243 }); 29244 }); 29245 } 29246 29247 /** 29248 * Checks a node for validity as a Sizzle context 29249 * @param {Element|Object=} context 29250 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 29251 */ 29252 function testContext( context ) { 29253 return context && typeof context.getElementsByTagName !== "undefined" && context; 29254 } 29255 29256 // Expose support vars for convenience 29257 support = Sizzle.support = {}; 29258 29259 /** 29260 * Detects XML nodes 29261 * @param {Element|Object} elem An element or a document 29262 * @returns {Boolean} True iff elem is a non-HTML XML node 29263 */ 29264 isXML = Sizzle.isXML = function( elem ) { 29265 // documentElement is verified for cases where it doesn't yet exist 29266 // (such as loading iframes in IE - #4833) 29267 var documentElement = elem && (elem.ownerDocument || elem).documentElement; 29268 return documentElement ? documentElement.nodeName !== "HTML" : false; 29269 }; 29270 29271 /** 29272 * Sets document-related variables once based on the current document 29273 * @param {Element|Object} [doc] An element or document object to use to set the document 29274 * @returns {Object} Returns the current document 29275 */ 29276 setDocument = Sizzle.setDocument = function( node ) { 29277 var hasCompare, parent, 29278 doc = node ? node.ownerDocument || node : preferredDoc; 29279 29280 // Return early if doc is invalid or already selected 29281 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { 29282 return document; 29283 } 29284 29285 // Update global variables 29286 document = doc; 29287 docElem = document.documentElement; 29288 documentIsHTML = !isXML( document ); 29289 29290 // Support: IE 9-11, Edge 29291 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) 29292 if ( (parent = document.defaultView) && parent.top !== parent ) { 29293 // Support: IE 11 29294 if ( parent.addEventListener ) { 29295 parent.addEventListener( "unload", unloadHandler, false ); 29296 29297 // Support: IE 9 - 10 only 29298 } else if ( parent.attachEvent ) { 29299 parent.attachEvent( "onunload", unloadHandler ); 29300 } 29301 } 29302 29303 /* Attributes 29304 ---------------------------------------------------------------------- */ 29305 29306 // Support: IE<8 29307 // Verify that getAttribute really returns attributes and not properties 29308 // (excepting IE8 booleans) 29309 support.attributes = assert(function( div ) { 29310 div.className = "i"; 29311 return !div.getAttribute("className"); 29312 }); 29313 29314 /* getElement(s)By* 29315 ---------------------------------------------------------------------- */ 29316 29317 // Check if getElementsByTagName("*") returns only elements 29318 support.getElementsByTagName = assert(function( div ) { 29319 div.appendChild( document.createComment("") ); 29320 return !div.getElementsByTagName("*").length; 29321 }); 29322 29323 // Support: IE<9 29324 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); 29325 29326 // Support: IE<10 29327 // Check if getElementById returns elements by name 29328 // The broken getElementById methods don't pick up programatically-set names, 29329 // so use a roundabout getElementsByName test 29330 support.getById = assert(function( div ) { 29331 docElem.appendChild( div ).id = expando; 29332 return !document.getElementsByName || !document.getElementsByName( expando ).length; 29333 }); 29334 29335 // ID find and filter 29336 if ( support.getById ) { 29337 Expr.find["ID"] = function( id, context ) { 29338 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 29339 var m = context.getElementById( id ); 29340 return m ? [ m ] : []; 29341 } 29342 }; 29343 Expr.filter["ID"] = function( id ) { 29344 var attrId = id.replace( runescape, funescape ); 29345 return function( elem ) { 29346 return elem.getAttribute("id") === attrId; 29347 }; 29348 }; 29349 } else { 29350 // Support: IE6/7 29351 // getElementById is not reliable as a find shortcut 29352 delete Expr.find["ID"]; 29353 29354 Expr.filter["ID"] = function( id ) { 29355 var attrId = id.replace( runescape, funescape ); 29356 return function( elem ) { 29357 var node = typeof elem.getAttributeNode !== "undefined" && 29358 elem.getAttributeNode("id"); 29359 return node && node.value === attrId; 29360 }; 29361 }; 29362 } 29363 29364 // Tag 29365 Expr.find["TAG"] = support.getElementsByTagName ? 29366 function( tag, context ) { 29367 if ( typeof context.getElementsByTagName !== "undefined" ) { 29368 return context.getElementsByTagName( tag ); 29369 29370 // DocumentFragment nodes don't have gEBTN 29371 } else if ( support.qsa ) { 29372 return context.querySelectorAll( tag ); 29373 } 29374 } : 29375 29376 function( tag, context ) { 29377 var elem, 29378 tmp = [], 29379 i = 0, 29380 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too 29381 results = context.getElementsByTagName( tag ); 29382 29383 // Filter out possible comments 29384 if ( tag === "*" ) { 29385 while ( (elem = results[i++]) ) { 29386 if ( elem.nodeType === 1 ) { 29387 tmp.push( elem ); 29388 } 29389 } 29390 29391 return tmp; 29392 } 29393 return results; 29394 }; 29395 29396 // Class 29397 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { 29398 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 29399 return context.getElementsByClassName( className ); 29400 } 29401 }; 29402 29403 /* QSA/matchesSelector 29404 ---------------------------------------------------------------------- */ 29405 29406 // QSA and matchesSelector support 29407 29408 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) 29409 rbuggyMatches = []; 29410 29411 // qSa(:focus) reports false when true (Chrome 21) 29412 // We allow this because of a bug in IE8/9 that throws an error 29413 // whenever `document.activeElement` is accessed on an iframe 29414 // So, we allow :focus to pass through QSA all the time to avoid the IE error 29415 // See http://bugs.jquery.com/ticket/13378 29416 rbuggyQSA = []; 29417 29418 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { 29419 // Build QSA regex 29420 // Regex strategy adopted from Diego Perini 29421 assert(function( div ) { 29422 // Select is set to empty string on purpose 29423 // This is to test IE's treatment of not explicitly 29424 // setting a boolean content attribute, 29425 // since its presence should be enough 29426 // http://bugs.jquery.com/ticket/12359 29427 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + 29428 "<select id='" + expando + "-\r\\' msallowcapture=''>" + 29429 "<option selected=''></option></select>"; 29430 29431 // Support: IE8, Opera 11-12.16 29432 // Nothing should be selected when empty strings follow ^= or $= or *= 29433 // The test attribute must be unknown in Opera but "safe" for WinRT 29434 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section 29435 if ( div.querySelectorAll("[msallowcapture^='']").length ) { 29436 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); 29437 } 29438 29439 // Support: IE8 29440 // Boolean attributes and "value" are not treated correctly 29441 if ( !div.querySelectorAll("[selected]").length ) { 29442 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 29443 } 29444 29445 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ 29446 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 29447 rbuggyQSA.push("~="); 29448 } 29449 29450 // Webkit/Opera - :checked should return selected option elements 29451 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 29452 // IE8 throws error here and will not see later tests 29453 if ( !div.querySelectorAll(":checked").length ) { 29454 rbuggyQSA.push(":checked"); 29455 } 29456 29457 // Support: Safari 8+, iOS 8+ 29458 // https://bugs.webkit.org/show_bug.cgi?id=136851 29459 // In-page `selector#id sibing-combinator selector` fails 29460 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { 29461 rbuggyQSA.push(".#.+[+~]"); 29462 } 29463 }); 29464 29465 assert(function( div ) { 29466 // Support: Windows 8 Native Apps 29467 // The type and name attributes are restricted during .innerHTML assignment 29468 var input = document.createElement("input"); 29469 input.setAttribute( "type", "hidden" ); 29470 div.appendChild( input ).setAttribute( "name", "D" ); 29471 29472 // Support: IE8 29473 // Enforce case-sensitivity of name attribute 29474 if ( div.querySelectorAll("[name=d]").length ) { 29475 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); 29476 } 29477 29478 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) 29479 // IE8 throws error here and will not see later tests 29480 if ( !div.querySelectorAll(":enabled").length ) { 29481 rbuggyQSA.push( ":enabled", ":disabled" ); 29482 } 29483 29484 // Opera 10-11 does not throw on post-comma invalid pseudos 29485 div.querySelectorAll("*,:x"); 29486 rbuggyQSA.push(",.*:"); 29487 }); 29488 } 29489 29490 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || 29491 docElem.webkitMatchesSelector || 29492 docElem.mozMatchesSelector || 29493 docElem.oMatchesSelector || 29494 docElem.msMatchesSelector) )) ) { 29495 29496 assert(function( div ) { 29497 // Check to see if it's possible to do matchesSelector 29498 // on a disconnected node (IE 9) 29499 support.disconnectedMatch = matches.call( div, "div" ); 29500 29501 // This should fail with an exception 29502 // Gecko does not error, returns false instead 29503 matches.call( div, "[s!='']:x" ); 29504 rbuggyMatches.push( "!=", pseudos ); 29505 }); 29506 } 29507 29508 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); 29509 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); 29510 29511 /* Contains 29512 ---------------------------------------------------------------------- */ 29513 hasCompare = rnative.test( docElem.compareDocumentPosition ); 29514 29515 // Element contains another 29516 // Purposefully self-exclusive 29517 // As in, an element does not contain itself 29518 contains = hasCompare || rnative.test( docElem.contains ) ? 29519 function( a, b ) { 29520 var adown = a.nodeType === 9 ? a.documentElement : a, 29521 bup = b && b.parentNode; 29522 return a === bup || !!( bup && bup.nodeType === 1 && ( 29523 adown.contains ? 29524 adown.contains( bup ) : 29525 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 29526 )); 29527 } : 29528 function( a, b ) { 29529 if ( b ) { 29530 while ( (b = b.parentNode) ) { 29531 if ( b === a ) { 29532 return true; 29533 } 29534 } 29535 } 29536 return false; 29537 }; 29538 29539 /* Sorting 29540 ---------------------------------------------------------------------- */ 29541 29542 // Document order sorting 29543 sortOrder = hasCompare ? 29544 function( a, b ) { 29545 29546 // Flag for duplicate removal 29547 if ( a === b ) { 29548 hasDuplicate = true; 29549 return 0; 29550 } 29551 29552 // Sort on method existence if only one input has compareDocumentPosition 29553 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 29554 if ( compare ) { 29555 return compare; 29556 } 29557 29558 // Calculate position if both inputs belong to the same document 29559 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? 29560 a.compareDocumentPosition( b ) : 29561 29562 // Otherwise we know they are disconnected 29563 1; 29564 29565 // Disconnected nodes 29566 if ( compare & 1 || 29567 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { 29568 29569 // Choose the first element that is related to our preferred document 29570 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { 29571 return -1; 29572 } 29573 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { 29574 return 1; 29575 } 29576 29577 // Maintain original order 29578 return sortInput ? 29579 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 29580 0; 29581 } 29582 29583 return compare & 4 ? -1 : 1; 29584 } : 29585 function( a, b ) { 29586 // Exit early if the nodes are identical 29587 if ( a === b ) { 29588 hasDuplicate = true; 29589 return 0; 29590 } 29591 29592 var cur, 29593 i = 0, 29594 aup = a.parentNode, 29595 bup = b.parentNode, 29596 ap = [ a ], 29597 bp = [ b ]; 29598 29599 // Parentless nodes are either documents or disconnected 29600 if ( !aup || !bup ) { 29601 return a === document ? -1 : 29602 b === document ? 1 : 29603 aup ? -1 : 29604 bup ? 1 : 29605 sortInput ? 29606 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 29607 0; 29608 29609 // If the nodes are siblings, we can do a quick check 29610 } else if ( aup === bup ) { 29611 return siblingCheck( a, b ); 29612 } 29613 29614 // Otherwise we need full lists of their ancestors for comparison 29615 cur = a; 29616 while ( (cur = cur.parentNode) ) { 29617 ap.unshift( cur ); 29618 } 29619 cur = b; 29620 while ( (cur = cur.parentNode) ) { 29621 bp.unshift( cur ); 29622 } 29623 29624 // Walk down the tree looking for a discrepancy 29625 while ( ap[i] === bp[i] ) { 29626 i++; 29627 } 29628 29629 return i ? 29630 // Do a sibling check if the nodes have a common ancestor 29631 siblingCheck( ap[i], bp[i] ) : 29632 29633 // Otherwise nodes in our document sort first 29634 ap[i] === preferredDoc ? -1 : 29635 bp[i] === preferredDoc ? 1 : 29636 0; 29637 }; 29638 29639 return document; 29640 }; 29641 29642 Sizzle.matches = function( expr, elements ) { 29643 return Sizzle( expr, null, null, elements ); 29644 }; 29645 29646 Sizzle.matchesSelector = function( elem, expr ) { 29647 // Set document vars if needed 29648 if ( ( elem.ownerDocument || elem ) !== document ) { 29649 setDocument( elem ); 29650 } 29651 29652 // Make sure that attribute selectors are quoted 29653 expr = expr.replace( rattributeQuotes, "='$1']" ); 29654 29655 if ( support.matchesSelector && documentIsHTML && 29656 !compilerCache[ expr + " " ] && 29657 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && 29658 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 29659 29660 try { 29661 var ret = matches.call( elem, expr ); 29662 29663 // IE 9's matchesSelector returns false on disconnected nodes 29664 if ( ret || support.disconnectedMatch || 29665 // As well, disconnected nodes are said to be in a document 29666 // fragment in IE 9 29667 elem.document && elem.document.nodeType !== 11 ) { 29668 return ret; 29669 } 29670 } catch (e) {} 29671 } 29672 29673 return Sizzle( expr, document, null, [ elem ] ).length > 0; 29674 }; 29675 29676 Sizzle.contains = function( context, elem ) { 29677 // Set document vars if needed 29678 if ( ( context.ownerDocument || context ) !== document ) { 29679 setDocument( context ); 29680 } 29681 return contains( context, elem ); 29682 }; 29683 29684 Sizzle.attr = function( elem, name ) { 29685 // Set document vars if needed 29686 if ( ( elem.ownerDocument || elem ) !== document ) { 29687 setDocument( elem ); 29688 } 29689 29690 var fn = Expr.attrHandle[ name.toLowerCase() ], 29691 // Don't get fooled by Object.prototype properties (jQuery #13807) 29692 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 29693 fn( elem, name, !documentIsHTML ) : 29694 undefined; 29695 29696 return val !== undefined ? 29697 val : 29698 support.attributes || !documentIsHTML ? 29699 elem.getAttribute( name ) : 29700 (val = elem.getAttributeNode(name)) && val.specified ? 29701 val.value : 29702 null; 29703 }; 29704 29705 Sizzle.error = function( msg ) { 29706 throw new Error( "Syntax error, unrecognized expression: " + msg ); 29707 }; 29708 29709 /** 29710 * Document sorting and removing duplicates 29711 * @param {ArrayLike} results 29712 */ 29713 Sizzle.uniqueSort = function( results ) { 29714 var elem, 29715 duplicates = [], 29716 j = 0, 29717 i = 0; 29718 29719 // Unless we *know* we can detect duplicates, assume their presence 29720 hasDuplicate = !support.detectDuplicates; 29721 sortInput = !support.sortStable && results.slice( 0 ); 29722 results.sort( sortOrder ); 29723 29724 if ( hasDuplicate ) { 29725 while ( (elem = results[i++]) ) { 29726 if ( elem === results[ i ] ) { 29727 j = duplicates.push( i ); 29728 } 29729 } 29730 while ( j-- ) { 29731 results.splice( duplicates[ j ], 1 ); 29732 } 29733 } 29734 29735 // Clear input after sorting to release objects 29736 // See https://github.com/jquery/sizzle/pull/225 29737 sortInput = null; 29738 29739 return results; 29740 }; 29741 29742 /** 29743 * Utility function for retrieving the text value of an array of DOM nodes 29744 * @param {Array|Element} elem 29745 */ 29746 getText = Sizzle.getText = function( elem ) { 29747 var node, 29748 ret = "", 29749 i = 0, 29750 nodeType = elem.nodeType; 29751 29752 if ( !nodeType ) { 29753 // If no nodeType, this is expected to be an array 29754 while ( (node = elem[i++]) ) { 29755 // Do not traverse comment nodes 29756 ret += getText( node ); 29757 } 29758 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 29759 // Use textContent for elements 29760 // innerText usage removed for consistency of new lines (jQuery #11153) 29761 if ( typeof elem.textContent === "string" ) { 29762 return elem.textContent; 29763 } else { 29764 // Traverse its children 29765 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 29766 ret += getText( elem ); 29767 } 29768 } 29769 } else if ( nodeType === 3 || nodeType === 4 ) { 29770 return elem.nodeValue; 29771 } 29772 // Do not include comment or processing instruction nodes 29773 29774 return ret; 29775 }; 29776 29777 Expr = Sizzle.selectors = { 29778 29779 // Can be adjusted by the user 29780 cacheLength: 50, 29781 29782 createPseudo: markFunction, 29783 29784 match: matchExpr, 29785 29786 attrHandle: {}, 29787 29788 find: {}, 29789 29790 relative: { 29791 ">": { dir: "parentNode", first: true }, 29792 " ": { dir: "parentNode" }, 29793 "+": { dir: "previousSibling", first: true }, 29794 "~": { dir: "previousSibling" } 29795 }, 29796 29797 preFilter: { 29798 "ATTR": function( match ) { 29799 match[1] = match[1].replace( runescape, funescape ); 29800 29801 // Move the given value to match[3] whether quoted or unquoted 29802 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); 29803 29804 if ( match[2] === "~=" ) { 29805 match[3] = " " + match[3] + " "; 29806 } 29807 29808 return match.slice( 0, 4 ); 29809 }, 29810 29811 "CHILD": function( match ) { 29812 /* matches from matchExpr["CHILD"] 29813 1 type (only|nth|...) 29814 2 what (child|of-type) 29815 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 29816 4 xn-component of xn+y argument ([+-]?\d*n|) 29817 5 sign of xn-component 29818 6 x of xn-component 29819 7 sign of y-component 29820 8 y of y-component 29821 */ 29822 match[1] = match[1].toLowerCase(); 29823 29824 if ( match[1].slice( 0, 3 ) === "nth" ) { 29825 // nth-* requires argument 29826 if ( !match[3] ) { 29827 Sizzle.error( match[0] ); 29828 } 29829 29830 // numeric x and y parameters for Expr.filter.CHILD 29831 // remember that false/true cast respectively to 0/1 29832 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); 29833 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); 29834 29835 // other types prohibit arguments 29836 } else if ( match[3] ) { 29837 Sizzle.error( match[0] ); 29838 } 29839 29840 return match; 29841 }, 29842 29843 "PSEUDO": function( match ) { 29844 var excess, 29845 unquoted = !match[6] && match[2]; 29846 29847 if ( matchExpr["CHILD"].test( match[0] ) ) { 29848 return null; 29849 } 29850 29851 // Accept quoted arguments as-is 29852 if ( match[3] ) { 29853 match[2] = match[4] || match[5] || ""; 29854 29855 // Strip excess characters from unquoted arguments 29856 } else if ( unquoted && rpseudo.test( unquoted ) && 29857 // Get excess from tokenize (recursively) 29858 (excess = tokenize( unquoted, true )) && 29859 // advance to the next closing parenthesis 29860 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { 29861 29862 // excess is a negative index 29863 match[0] = match[0].slice( 0, excess ); 29864 match[2] = unquoted.slice( 0, excess ); 29865 } 29866 29867 // Return only captures needed by the pseudo filter method (type and argument) 29868 return match.slice( 0, 3 ); 29869 } 29870 }, 29871 29872 filter: { 29873 29874 "TAG": function( nodeNameSelector ) { 29875 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 29876 return nodeNameSelector === "*" ? 29877 function() { return true; } : 29878 function( elem ) { 29879 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; 29880 }; 29881 }, 29882 29883 "CLASS": function( className ) { 29884 var pattern = classCache[ className + " " ]; 29885 29886 return pattern || 29887 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && 29888 classCache( className, function( elem ) { 29889 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); 29890 }); 29891 }, 29892 29893 "ATTR": function( name, operator, check ) { 29894 return function( elem ) { 29895 var result = Sizzle.attr( elem, name ); 29896 29897 if ( result == null ) { 29898 return operator === "!="; 29899 } 29900 if ( !operator ) { 29901 return true; 29902 } 29903 29904 result += ""; 29905 29906 return operator === "=" ? result === check : 29907 operator === "!=" ? result !== check : 29908 operator === "^=" ? check && result.indexOf( check ) === 0 : 29909 operator === "*=" ? check && result.indexOf( check ) > -1 : 29910 operator === "$=" ? check && result.slice( -check.length ) === check : 29911 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : 29912 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : 29913 false; 29914 }; 29915 }, 29916 29917 "CHILD": function( type, what, argument, first, last ) { 29918 var simple = type.slice( 0, 3 ) !== "nth", 29919 forward = type.slice( -4 ) !== "last", 29920 ofType = what === "of-type"; 29921 29922 return first === 1 && last === 0 ? 29923 29924 // Shortcut for :nth-*(n) 29925 function( elem ) { 29926 return !!elem.parentNode; 29927 } : 29928 29929 function( elem, context, xml ) { 29930 var cache, uniqueCache, outerCache, node, nodeIndex, start, 29931 dir = simple !== forward ? "nextSibling" : "previousSibling", 29932 parent = elem.parentNode, 29933 name = ofType && elem.nodeName.toLowerCase(), 29934 useCache = !xml && !ofType, 29935 diff = false; 29936 29937 if ( parent ) { 29938 29939 // :(first|last|only)-(child|of-type) 29940 if ( simple ) { 29941 while ( dir ) { 29942 node = elem; 29943 while ( (node = node[ dir ]) ) { 29944 if ( ofType ? 29945 node.nodeName.toLowerCase() === name : 29946 node.nodeType === 1 ) { 29947 29948 return false; 29949 } 29950 } 29951 // Reverse direction for :only-* (if we haven't yet done so) 29952 start = dir = type === "only" && !start && "nextSibling"; 29953 } 29954 return true; 29955 } 29956 29957 start = [ forward ? parent.firstChild : parent.lastChild ]; 29958 29959 // non-xml :nth-child(...) stores cache data on `parent` 29960 if ( forward && useCache ) { 29961 29962 // Seek `elem` from a previously-cached index 29963 29964 // ...in a gzip-friendly way 29965 node = parent; 29966 outerCache = node[ expando ] || (node[ expando ] = {}); 29967 29968 // Support: IE <9 only 29969 // Defend against cloned attroperties (jQuery gh-1709) 29970 uniqueCache = outerCache[ node.uniqueID ] || 29971 (outerCache[ node.uniqueID ] = {}); 29972 29973 cache = uniqueCache[ type ] || []; 29974 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 29975 diff = nodeIndex && cache[ 2 ]; 29976 node = nodeIndex && parent.childNodes[ nodeIndex ]; 29977 29978 while ( (node = ++nodeIndex && node && node[ dir ] || 29979 29980 // Fallback to seeking `elem` from the start 29981 (diff = nodeIndex = 0) || start.pop()) ) { 29982 29983 // When found, cache indexes on `parent` and break 29984 if ( node.nodeType === 1 && ++diff && node === elem ) { 29985 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; 29986 break; 29987 } 29988 } 29989 29990 } else { 29991 // Use previously-cached element index if available 29992 if ( useCache ) { 29993 // ...in a gzip-friendly way 29994 node = elem; 29995 outerCache = node[ expando ] || (node[ expando ] = {}); 29996 29997 // Support: IE <9 only 29998 // Defend against cloned attroperties (jQuery gh-1709) 29999 uniqueCache = outerCache[ node.uniqueID ] || 30000 (outerCache[ node.uniqueID ] = {}); 30001 30002 cache = uniqueCache[ type ] || []; 30003 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 30004 diff = nodeIndex; 30005 } 30006 30007 // xml :nth-child(...) 30008 // or :nth-last-child(...) or :nth(-last)?-of-type(...) 30009 if ( diff === false ) { 30010 // Use the same loop as above to seek `elem` from the start 30011 while ( (node = ++nodeIndex && node && node[ dir ] || 30012 (diff = nodeIndex = 0) || start.pop()) ) { 30013 30014 if ( ( ofType ? 30015 node.nodeName.toLowerCase() === name : 30016 node.nodeType === 1 ) && 30017 ++diff ) { 30018 30019 // Cache the index of each encountered element 30020 if ( useCache ) { 30021 outerCache = node[ expando ] || (node[ expando ] = {}); 30022 30023 // Support: IE <9 only 30024 // Defend against cloned attroperties (jQuery gh-1709) 30025 uniqueCache = outerCache[ node.uniqueID ] || 30026 (outerCache[ node.uniqueID ] = {}); 30027 30028 uniqueCache[ type ] = [ dirruns, diff ]; 30029 } 30030 30031 if ( node === elem ) { 30032 break; 30033 } 30034 } 30035 } 30036 } 30037 } 30038 30039 // Incorporate the offset, then check against cycle size 30040 diff -= last; 30041 return diff === first || ( diff % first === 0 && diff / first >= 0 ); 30042 } 30043 }; 30044 }, 30045 30046 "PSEUDO": function( pseudo, argument ) { 30047 // pseudo-class names are case-insensitive 30048 // http://www.w3.org/TR/selectors/#pseudo-classes 30049 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 30050 // Remember that setFilters inherits from pseudos 30051 var args, 30052 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 30053 Sizzle.error( "unsupported pseudo: " + pseudo ); 30054 30055 // The user may use createPseudo to indicate that 30056 // arguments are needed to create the filter function 30057 // just as Sizzle does 30058 if ( fn[ expando ] ) { 30059 return fn( argument ); 30060 } 30061 30062 // But maintain support for old signatures 30063 if ( fn.length > 1 ) { 30064 args = [ pseudo, pseudo, "", argument ]; 30065 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 30066 markFunction(function( seed, matches ) { 30067 var idx, 30068 matched = fn( seed, argument ), 30069 i = matched.length; 30070 while ( i-- ) { 30071 idx = indexOf( seed, matched[i] ); 30072 seed[ idx ] = !( matches[ idx ] = matched[i] ); 30073 } 30074 }) : 30075 function( elem ) { 30076 return fn( elem, 0, args ); 30077 }; 30078 } 30079 30080 return fn; 30081 } 30082 }, 30083 30084 pseudos: { 30085 // Potentially complex pseudos 30086 "not": markFunction(function( selector ) { 30087 // Trim the selector passed to compile 30088 // to avoid treating leading and trailing 30089 // spaces as combinators 30090 var input = [], 30091 results = [], 30092 matcher = compile( selector.replace( rtrim, "$1" ) ); 30093 30094 return matcher[ expando ] ? 30095 markFunction(function( seed, matches, context, xml ) { 30096 var elem, 30097 unmatched = matcher( seed, null, xml, [] ), 30098 i = seed.length; 30099 30100 // Match elements unmatched by `matcher` 30101 while ( i-- ) { 30102 if ( (elem = unmatched[i]) ) { 30103 seed[i] = !(matches[i] = elem); 30104 } 30105 } 30106 }) : 30107 function( elem, context, xml ) { 30108 input[0] = elem; 30109 matcher( input, null, xml, results ); 30110 // Don't keep the element (issue #299) 30111 input[0] = null; 30112 return !results.pop(); 30113 }; 30114 }), 30115 30116 "has": markFunction(function( selector ) { 30117 return function( elem ) { 30118 return Sizzle( selector, elem ).length > 0; 30119 }; 30120 }), 30121 30122 "contains": markFunction(function( text ) { 30123 text = text.replace( runescape, funescape ); 30124 return function( elem ) { 30125 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; 30126 }; 30127 }), 30128 30129 // "Whether an element is represented by a :lang() selector 30130 // is based solely on the element's language value 30131 // being equal to the identifier C, 30132 // or beginning with the identifier C immediately followed by "-". 30133 // The matching of C against the element's language value is performed case-insensitively. 30134 // The identifier C does not have to be a valid language name." 30135 // http://www.w3.org/TR/selectors/#lang-pseudo 30136 "lang": markFunction( function( lang ) { 30137 // lang value must be a valid identifier 30138 if ( !ridentifier.test(lang || "") ) { 30139 Sizzle.error( "unsupported lang: " + lang ); 30140 } 30141 lang = lang.replace( runescape, funescape ).toLowerCase(); 30142 return function( elem ) { 30143 var elemLang; 30144 do { 30145 if ( (elemLang = documentIsHTML ? 30146 elem.lang : 30147 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { 30148 30149 elemLang = elemLang.toLowerCase(); 30150 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 30151 } 30152 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); 30153 return false; 30154 }; 30155 }), 30156 30157 // Miscellaneous 30158 "target": function( elem ) { 30159 var hash = window.location && window.location.hash; 30160 return hash && hash.slice( 1 ) === elem.id; 30161 }, 30162 30163 "root": function( elem ) { 30164 return elem === docElem; 30165 }, 30166 30167 "focus": function( elem ) { 30168 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); 30169 }, 30170 30171 // Boolean properties 30172 "enabled": function( elem ) { 30173 return elem.disabled === false; 30174 }, 30175 30176 "disabled": function( elem ) { 30177 return elem.disabled === true; 30178 }, 30179 30180 "checked": function( elem ) { 30181 // In CSS3, :checked should return both checked and selected elements 30182 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 30183 var nodeName = elem.nodeName.toLowerCase(); 30184 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); 30185 }, 30186 30187 "selected": function( elem ) { 30188 // Accessing this property makes selected-by-default 30189 // options in Safari work properly 30190 if ( elem.parentNode ) { 30191 elem.parentNode.selectedIndex; 30192 } 30193 30194 return elem.selected === true; 30195 }, 30196 30197 // Contents 30198 "empty": function( elem ) { 30199 // http://www.w3.org/TR/selectors/#empty-pseudo 30200 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 30201 // but not by others (comment: 8; processing instruction: 7; etc.) 30202 // nodeType < 6 works because attributes (2) do not appear as children 30203 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 30204 if ( elem.nodeType < 6 ) { 30205 return false; 30206 } 30207 } 30208 return true; 30209 }, 30210 30211 "parent": function( elem ) { 30212 return !Expr.pseudos["empty"]( elem ); 30213 }, 30214 30215 // Element/input types 30216 "header": function( elem ) { 30217 return rheader.test( elem.nodeName ); 30218 }, 30219 30220 "input": function( elem ) { 30221 return rinputs.test( elem.nodeName ); 30222 }, 30223 30224 "button": function( elem ) { 30225 var name = elem.nodeName.toLowerCase(); 30226 return name === "input" && elem.type === "button" || name === "button"; 30227 }, 30228 30229 "text": function( elem ) { 30230 var attr; 30231 return elem.nodeName.toLowerCase() === "input" && 30232 elem.type === "text" && 30233 30234 // Support: IE<8 30235 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" 30236 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); 30237 }, 30238 30239 // Position-in-collection 30240 "first": createPositionalPseudo(function() { 30241 return [ 0 ]; 30242 }), 30243 30244 "last": createPositionalPseudo(function( matchIndexes, length ) { 30245 return [ length - 1 ]; 30246 }), 30247 30248 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { 30249 return [ argument < 0 ? argument + length : argument ]; 30250 }), 30251 30252 "even": createPositionalPseudo(function( matchIndexes, length ) { 30253 var i = 0; 30254 for ( ; i < length; i += 2 ) { 30255 matchIndexes.push( i ); 30256 } 30257 return matchIndexes; 30258 }), 30259 30260 "odd": createPositionalPseudo(function( matchIndexes, length ) { 30261 var i = 1; 30262 for ( ; i < length; i += 2 ) { 30263 matchIndexes.push( i ); 30264 } 30265 return matchIndexes; 30266 }), 30267 30268 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { 30269 var i = argument < 0 ? argument + length : argument; 30270 for ( ; --i >= 0; ) { 30271 matchIndexes.push( i ); 30272 } 30273 return matchIndexes; 30274 }), 30275 30276 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { 30277 var i = argument < 0 ? argument + length : argument; 30278 for ( ; ++i < length; ) { 30279 matchIndexes.push( i ); 30280 } 30281 return matchIndexes; 30282 }) 30283 } 30284 }; 30285 30286 Expr.pseudos["nth"] = Expr.pseudos["eq"]; 30287 30288 // Add button/input type pseudos 30289 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 30290 Expr.pseudos[ i ] = createInputPseudo( i ); 30291 } 30292 for ( i in { submit: true, reset: true } ) { 30293 Expr.pseudos[ i ] = createButtonPseudo( i ); 30294 } 30295 30296 // Easy API for creating new setFilters 30297 function setFilters() {} 30298 setFilters.prototype = Expr.filters = Expr.pseudos; 30299 Expr.setFilters = new setFilters(); 30300 30301 tokenize = Sizzle.tokenize = function( selector, parseOnly ) { 30302 var matched, match, tokens, type, 30303 soFar, groups, preFilters, 30304 cached = tokenCache[ selector + " " ]; 30305 30306 if ( cached ) { 30307 return parseOnly ? 0 : cached.slice( 0 ); 30308 } 30309 30310 soFar = selector; 30311 groups = []; 30312 preFilters = Expr.preFilter; 30313 30314 while ( soFar ) { 30315 30316 // Comma and first run 30317 if ( !matched || (match = rcomma.exec( soFar )) ) { 30318 if ( match ) { 30319 // Don't consume trailing commas as valid 30320 soFar = soFar.slice( match[0].length ) || soFar; 30321 } 30322 groups.push( (tokens = []) ); 30323 } 30324 30325 matched = false; 30326 30327 // Combinators 30328 if ( (match = rcombinators.exec( soFar )) ) { 30329 matched = match.shift(); 30330 tokens.push({ 30331 value: matched, 30332 // Cast descendant combinators to space 30333 type: match[0].replace( rtrim, " " ) 30334 }); 30335 soFar = soFar.slice( matched.length ); 30336 } 30337 30338 // Filters 30339 for ( type in Expr.filter ) { 30340 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || 30341 (match = preFilters[ type ]( match ))) ) { 30342 matched = match.shift(); 30343 tokens.push({ 30344 value: matched, 30345 type: type, 30346 matches: match 30347 }); 30348 soFar = soFar.slice( matched.length ); 30349 } 30350 } 30351 30352 if ( !matched ) { 30353 break; 30354 } 30355 } 30356 30357 // Return the length of the invalid excess 30358 // if we're just parsing 30359 // Otherwise, throw an error or return tokens 30360 return parseOnly ? 30361 soFar.length : 30362 soFar ? 30363 Sizzle.error( selector ) : 30364 // Cache the tokens 30365 tokenCache( selector, groups ).slice( 0 ); 30366 }; 30367 30368 function toSelector( tokens ) { 30369 var i = 0, 30370 len = tokens.length, 30371 selector = ""; 30372 for ( ; i < len; i++ ) { 30373 selector += tokens[i].value; 30374 } 30375 return selector; 30376 } 30377 30378 function addCombinator( matcher, combinator, base ) { 30379 var dir = combinator.dir, 30380 checkNonElements = base && dir === "parentNode", 30381 doneName = done++; 30382 30383 return combinator.first ? 30384 // Check against closest ancestor/preceding element 30385 function( elem, context, xml ) { 30386 while ( (elem = elem[ dir ]) ) { 30387 if ( elem.nodeType === 1 || checkNonElements ) { 30388 return matcher( elem, context, xml ); 30389 } 30390 } 30391 } : 30392 30393 // Check against all ancestor/preceding elements 30394 function( elem, context, xml ) { 30395 var oldCache, uniqueCache, outerCache, 30396 newCache = [ dirruns, doneName ]; 30397 30398 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 30399 if ( xml ) { 30400 while ( (elem = elem[ dir ]) ) { 30401 if ( elem.nodeType === 1 || checkNonElements ) { 30402 if ( matcher( elem, context, xml ) ) { 30403 return true; 30404 } 30405 } 30406 } 30407 } else { 30408 while ( (elem = elem[ dir ]) ) { 30409 if ( elem.nodeType === 1 || checkNonElements ) { 30410 outerCache = elem[ expando ] || (elem[ expando ] = {}); 30411 30412 // Support: IE <9 only 30413 // Defend against cloned attroperties (jQuery gh-1709) 30414 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); 30415 30416 if ( (oldCache = uniqueCache[ dir ]) && 30417 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 30418 30419 // Assign to newCache so results back-propagate to previous elements 30420 return (newCache[ 2 ] = oldCache[ 2 ]); 30421 } else { 30422 // Reuse newcache so results back-propagate to previous elements 30423 uniqueCache[ dir ] = newCache; 30424 30425 // A match means we're done; a fail means we have to keep checking 30426 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { 30427 return true; 30428 } 30429 } 30430 } 30431 } 30432 } 30433 }; 30434 } 30435 30436 function elementMatcher( matchers ) { 30437 return matchers.length > 1 ? 30438 function( elem, context, xml ) { 30439 var i = matchers.length; 30440 while ( i-- ) { 30441 if ( !matchers[i]( elem, context, xml ) ) { 30442 return false; 30443 } 30444 } 30445 return true; 30446 } : 30447 matchers[0]; 30448 } 30449 30450 function multipleContexts( selector, contexts, results ) { 30451 var i = 0, 30452 len = contexts.length; 30453 for ( ; i < len; i++ ) { 30454 Sizzle( selector, contexts[i], results ); 30455 } 30456 return results; 30457 } 30458 30459 function condense( unmatched, map, filter, context, xml ) { 30460 var elem, 30461 newUnmatched = [], 30462 i = 0, 30463 len = unmatched.length, 30464 mapped = map != null; 30465 30466 for ( ; i < len; i++ ) { 30467 if ( (elem = unmatched[i]) ) { 30468 if ( !filter || filter( elem, context, xml ) ) { 30469 newUnmatched.push( elem ); 30470 if ( mapped ) { 30471 map.push( i ); 30472 } 30473 } 30474 } 30475 } 30476 30477 return newUnmatched; 30478 } 30479 30480 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 30481 if ( postFilter && !postFilter[ expando ] ) { 30482 postFilter = setMatcher( postFilter ); 30483 } 30484 if ( postFinder && !postFinder[ expando ] ) { 30485 postFinder = setMatcher( postFinder, postSelector ); 30486 } 30487 return markFunction(function( seed, results, context, xml ) { 30488 var temp, i, elem, 30489 preMap = [], 30490 postMap = [], 30491 preexisting = results.length, 30492 30493 // Get initial elements from seed or context 30494 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), 30495 30496 // Prefilter to get matcher input, preserving a map for seed-results synchronization 30497 matcherIn = preFilter && ( seed || !selector ) ? 30498 condense( elems, preMap, preFilter, context, xml ) : 30499 elems, 30500 30501 matcherOut = matcher ? 30502 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, 30503 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 30504 30505 // ...intermediate processing is necessary 30506 [] : 30507 30508 // ...otherwise use results directly 30509 results : 30510 matcherIn; 30511 30512 // Find primary matches 30513 if ( matcher ) { 30514 matcher( matcherIn, matcherOut, context, xml ); 30515 } 30516 30517 // Apply postFilter 30518 if ( postFilter ) { 30519 temp = condense( matcherOut, postMap ); 30520 postFilter( temp, [], context, xml ); 30521 30522 // Un-match failing elements by moving them back to matcherIn 30523 i = temp.length; 30524 while ( i-- ) { 30525 if ( (elem = temp[i]) ) { 30526 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); 30527 } 30528 } 30529 } 30530 30531 if ( seed ) { 30532 if ( postFinder || preFilter ) { 30533 if ( postFinder ) { 30534 // Get the final matcherOut by condensing this intermediate into postFinder contexts 30535 temp = []; 30536 i = matcherOut.length; 30537 while ( i-- ) { 30538 if ( (elem = matcherOut[i]) ) { 30539 // Restore matcherIn since elem is not yet a final match 30540 temp.push( (matcherIn[i] = elem) ); 30541 } 30542 } 30543 postFinder( null, (matcherOut = []), temp, xml ); 30544 } 30545 30546 // Move matched elements from seed to results to keep them synchronized 30547 i = matcherOut.length; 30548 while ( i-- ) { 30549 if ( (elem = matcherOut[i]) && 30550 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { 30551 30552 seed[temp] = !(results[temp] = elem); 30553 } 30554 } 30555 } 30556 30557 // Add elements to results, through postFinder if defined 30558 } else { 30559 matcherOut = condense( 30560 matcherOut === results ? 30561 matcherOut.splice( preexisting, matcherOut.length ) : 30562 matcherOut 30563 ); 30564 if ( postFinder ) { 30565 postFinder( null, results, matcherOut, xml ); 30566 } else { 30567 push.apply( results, matcherOut ); 30568 } 30569 } 30570 }); 30571 } 30572 30573 function matcherFromTokens( tokens ) { 30574 var checkContext, matcher, j, 30575 len = tokens.length, 30576 leadingRelative = Expr.relative[ tokens[0].type ], 30577 implicitRelative = leadingRelative || Expr.relative[" "], 30578 i = leadingRelative ? 1 : 0, 30579 30580 // The foundational matcher ensures that elements are reachable from top-level context(s) 30581 matchContext = addCombinator( function( elem ) { 30582 return elem === checkContext; 30583 }, implicitRelative, true ), 30584 matchAnyContext = addCombinator( function( elem ) { 30585 return indexOf( checkContext, elem ) > -1; 30586 }, implicitRelative, true ), 30587 matchers = [ function( elem, context, xml ) { 30588 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( 30589 (checkContext = context).nodeType ? 30590 matchContext( elem, context, xml ) : 30591 matchAnyContext( elem, context, xml ) ); 30592 // Avoid hanging onto element (issue #299) 30593 checkContext = null; 30594 return ret; 30595 } ]; 30596 30597 for ( ; i < len; i++ ) { 30598 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { 30599 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; 30600 } else { 30601 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); 30602 30603 // Return special upon seeing a positional matcher 30604 if ( matcher[ expando ] ) { 30605 // Find the next relative operator (if any) for proper handling 30606 j = ++i; 30607 for ( ; j < len; j++ ) { 30608 if ( Expr.relative[ tokens[j].type ] ) { 30609 break; 30610 } 30611 } 30612 return setMatcher( 30613 i > 1 && elementMatcher( matchers ), 30614 i > 1 && toSelector( 30615 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 30616 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) 30617 ).replace( rtrim, "$1" ), 30618 matcher, 30619 i < j && matcherFromTokens( tokens.slice( i, j ) ), 30620 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), 30621 j < len && toSelector( tokens ) 30622 ); 30623 } 30624 matchers.push( matcher ); 30625 } 30626 } 30627 30628 return elementMatcher( matchers ); 30629 } 30630 30631 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { 30632 var bySet = setMatchers.length > 0, 30633 byElement = elementMatchers.length > 0, 30634 superMatcher = function( seed, context, xml, results, outermost ) { 30635 var elem, j, matcher, 30636 matchedCount = 0, 30637 i = "0", 30638 unmatched = seed && [], 30639 setMatched = [], 30640 contextBackup = outermostContext, 30641 // We must always have either seed elements or outermost context 30642 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), 30643 // Use integer dirruns iff this is the outermost matcher 30644 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), 30645 len = elems.length; 30646 30647 if ( outermost ) { 30648 outermostContext = context === document || context || outermost; 30649 } 30650 30651 // Add elements passing elementMatchers directly to results 30652 // Support: IE<9, Safari 30653 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id 30654 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { 30655 if ( byElement && elem ) { 30656 j = 0; 30657 if ( !context && elem.ownerDocument !== document ) { 30658 setDocument( elem ); 30659 xml = !documentIsHTML; 30660 } 30661 while ( (matcher = elementMatchers[j++]) ) { 30662 if ( matcher( elem, context || document, xml) ) { 30663 results.push( elem ); 30664 break; 30665 } 30666 } 30667 if ( outermost ) { 30668 dirruns = dirrunsUnique; 30669 } 30670 } 30671 30672 // Track unmatched elements for set filters 30673 if ( bySet ) { 30674 // They will have gone through all possible matchers 30675 if ( (elem = !matcher && elem) ) { 30676 matchedCount--; 30677 } 30678 30679 // Lengthen the array for every element, matched or not 30680 if ( seed ) { 30681 unmatched.push( elem ); 30682 } 30683 } 30684 } 30685 30686 // `i` is now the count of elements visited above, and adding it to `matchedCount` 30687 // makes the latter nonnegative. 30688 matchedCount += i; 30689 30690 // Apply set filters to unmatched elements 30691 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 30692 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 30693 // no element matchers and no seed. 30694 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 30695 // case, which will result in a "00" `matchedCount` that differs from `i` but is also 30696 // numerically zero. 30697 if ( bySet && i !== matchedCount ) { 30698 j = 0; 30699 while ( (matcher = setMatchers[j++]) ) { 30700 matcher( unmatched, setMatched, context, xml ); 30701 } 30702 30703 if ( seed ) { 30704 // Reintegrate element matches to eliminate the need for sorting 30705 if ( matchedCount > 0 ) { 30706 while ( i-- ) { 30707 if ( !(unmatched[i] || setMatched[i]) ) { 30708 setMatched[i] = pop.call( results ); 30709 } 30710 } 30711 } 30712 30713 // Discard index placeholder values to get only actual matches 30714 setMatched = condense( setMatched ); 30715 } 30716 30717 // Add matches to results 30718 push.apply( results, setMatched ); 30719 30720 // Seedless set matches succeeding multiple successful matchers stipulate sorting 30721 if ( outermost && !seed && setMatched.length > 0 && 30722 ( matchedCount + setMatchers.length ) > 1 ) { 30723 30724 Sizzle.uniqueSort( results ); 30725 } 30726 } 30727 30728 // Override manipulation of globals by nested matchers 30729 if ( outermost ) { 30730 dirruns = dirrunsUnique; 30731 outermostContext = contextBackup; 30732 } 30733 30734 return unmatched; 30735 }; 30736 30737 return bySet ? 30738 markFunction( superMatcher ) : 30739 superMatcher; 30740 } 30741 30742 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { 30743 var i, 30744 setMatchers = [], 30745 elementMatchers = [], 30746 cached = compilerCache[ selector + " " ]; 30747 30748 if ( !cached ) { 30749 // Generate a function of recursive functions that can be used to check each element 30750 if ( !match ) { 30751 match = tokenize( selector ); 30752 } 30753 i = match.length; 30754 while ( i-- ) { 30755 cached = matcherFromTokens( match[i] ); 30756 if ( cached[ expando ] ) { 30757 setMatchers.push( cached ); 30758 } else { 30759 elementMatchers.push( cached ); 30760 } 30761 } 30762 30763 // Cache the compiled function 30764 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); 30765 30766 // Save selector and tokenization 30767 cached.selector = selector; 30768 } 30769 return cached; 30770 }; 30771 30772 /** 30773 * A low-level selection function that works with Sizzle's compiled 30774 * selector functions 30775 * @param {String|Function} selector A selector or a pre-compiled 30776 * selector function built with Sizzle.compile 30777 * @param {Element} context 30778 * @param {Array} [results] 30779 * @param {Array} [seed] A set of elements to match against 30780 */ 30781 select = Sizzle.select = function( selector, context, results, seed ) { 30782 var i, tokens, token, type, find, 30783 compiled = typeof selector === "function" && selector, 30784 match = !seed && tokenize( (selector = compiled.selector || selector) ); 30785 30786 results = results || []; 30787 30788 // Try to minimize operations if there is only one selector in the list and no seed 30789 // (the latter of which guarantees us context) 30790 if ( match.length === 1 ) { 30791 30792 // Reduce context if the leading compound selector is an ID 30793 tokens = match[0] = match[0].slice( 0 ); 30794 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && 30795 support.getById && context.nodeType === 9 && documentIsHTML && 30796 Expr.relative[ tokens[1].type ] ) { 30797 30798 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; 30799 if ( !context ) { 30800 return results; 30801 30802 // Precompiled matchers will still verify ancestry, so step up a level 30803 } else if ( compiled ) { 30804 context = context.parentNode; 30805 } 30806 30807 selector = selector.slice( tokens.shift().value.length ); 30808 } 30809 30810 // Fetch a seed set for right-to-left matching 30811 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; 30812 while ( i-- ) { 30813 token = tokens[i]; 30814 30815 // Abort if we hit a combinator 30816 if ( Expr.relative[ (type = token.type) ] ) { 30817 break; 30818 } 30819 if ( (find = Expr.find[ type ]) ) { 30820 // Search, expanding context for leading sibling combinators 30821 if ( (seed = find( 30822 token.matches[0].replace( runescape, funescape ), 30823 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context 30824 )) ) { 30825 30826 // If seed is empty or no tokens remain, we can return early 30827 tokens.splice( i, 1 ); 30828 selector = seed.length && toSelector( tokens ); 30829 if ( !selector ) { 30830 push.apply( results, seed ); 30831 return results; 30832 } 30833 30834 break; 30835 } 30836 } 30837 } 30838 } 30839 30840 // Compile and execute a filtering function if one is not provided 30841 // Provide `match` to avoid retokenization if we modified the selector above 30842 ( compiled || compile( selector, match ) )( 30843 seed, 30844 context, 30845 !documentIsHTML, 30846 results, 30847 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 30848 ); 30849 return results; 30850 }; 30851 30852 // One-time assignments 30853 30854 // Sort stability 30855 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; 30856 30857 // Support: Chrome 14-35+ 30858 // Always assume duplicates if they aren't passed to the comparison function 30859 support.detectDuplicates = !!hasDuplicate; 30860 30861 // Initialize against the default document 30862 setDocument(); 30863 30864 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) 30865 // Detached nodes confoundingly follow *each other* 30866 support.sortDetached = assert(function( div1 ) { 30867 // Should return 1, but returns 4 (following) 30868 return div1.compareDocumentPosition( document.createElement("div") ) & 1; 30869 }); 30870 30871 // Support: IE<8 30872 // Prevent attribute/property "interpolation" 30873 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 30874 if ( !assert(function( div ) { 30875 div.innerHTML = "<a href='#'></a>"; 30876 return div.firstChild.getAttribute("href") === "#" ; 30877 }) ) { 30878 addHandle( "type|href|height|width", function( elem, name, isXML ) { 30879 if ( !isXML ) { 30880 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); 30881 } 30882 }); 30883 } 30884 30885 // Support: IE<9 30886 // Use defaultValue in place of getAttribute("value") 30887 if ( !support.attributes || !assert(function( div ) { 30888 div.innerHTML = "<input/>"; 30889 div.firstChild.setAttribute( "value", "" ); 30890 return div.firstChild.getAttribute( "value" ) === ""; 30891 }) ) { 30892 addHandle( "value", function( elem, name, isXML ) { 30893 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { 30894 return elem.defaultValue; 30895 } 30896 }); 30897 } 30898 30899 // Support: IE<9 30900 // Use getAttributeNode to fetch booleans when getAttribute lies 30901 if ( !assert(function( div ) { 30902 return div.getAttribute("disabled") == null; 30903 }) ) { 30904 addHandle( booleans, function( elem, name, isXML ) { 30905 var val; 30906 if ( !isXML ) { 30907 return elem[ name ] === true ? name.toLowerCase() : 30908 (val = elem.getAttributeNode( name )) && val.specified ? 30909 val.value : 30910 null; 30911 } 30912 }); 30913 } 30914 30915 return Sizzle; 30916 30917 })( window ); 30918 30919 30920 30921 jQuery.find = Sizzle; 30922 jQuery.expr = Sizzle.selectors; 30923 jQuery.expr[ ":" ] = jQuery.expr.pseudos; 30924 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; 30925 jQuery.text = Sizzle.getText; 30926 jQuery.isXMLDoc = Sizzle.isXML; 30927 jQuery.contains = Sizzle.contains; 30928 30929 30930 30931 var dir = function( elem, dir, until ) { 30932 var matched = [], 30933 truncate = until !== undefined; 30934 30935 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 30936 if ( elem.nodeType === 1 ) { 30937 if ( truncate && jQuery( elem ).is( until ) ) { 30938 break; 30939 } 30940 matched.push( elem ); 30941 } 30942 } 30943 return matched; 30944 }; 30945 30946 30947 var siblings = function( n, elem ) { 30948 var matched = []; 30949 30950 for ( ; n; n = n.nextSibling ) { 30951 if ( n.nodeType === 1 && n !== elem ) { 30952 matched.push( n ); 30953 } 30954 } 30955 30956 return matched; 30957 }; 30958 30959 30960 var rneedsContext = jQuery.expr.match.needsContext; 30961 30962 var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); 30963 30964 30965 30966 var risSimple = /^.[^:#\[\.,]*$/; 30967 30968 // Implement the identical functionality for filter and not 30969 function winnow( elements, qualifier, not ) { 30970 if ( jQuery.isFunction( qualifier ) ) { 30971 return jQuery.grep( elements, function( elem, i ) { 30972 /* jshint -W018 */ 30973 return !!qualifier.call( elem, i, elem ) !== not; 30974 } ); 30975 30976 } 30977 30978 if ( qualifier.nodeType ) { 30979 return jQuery.grep( elements, function( elem ) { 30980 return ( elem === qualifier ) !== not; 30981 } ); 30982 30983 } 30984 30985 if ( typeof qualifier === "string" ) { 30986 if ( risSimple.test( qualifier ) ) { 30987 return jQuery.filter( qualifier, elements, not ); 30988 } 30989 30990 qualifier = jQuery.filter( qualifier, elements ); 30991 } 30992 30993 return jQuery.grep( elements, function( elem ) { 30994 return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 30995 } ); 30996 } 30997 30998 jQuery.filter = function( expr, elems, not ) { 30999 var elem = elems[ 0 ]; 31000 31001 if ( not ) { 31002 expr = ":not(" + expr + ")"; 31003 } 31004 31005 return elems.length === 1 && elem.nodeType === 1 ? 31006 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : 31007 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 31008 return elem.nodeType === 1; 31009 } ) ); 31010 }; 31011 31012 jQuery.fn.extend( { 31013 find: function( selector ) { 31014 var i, 31015 len = this.length, 31016 ret = [], 31017 self = this; 31018 31019 if ( typeof selector !== "string" ) { 31020 return this.pushStack( jQuery( selector ).filter( function() { 31021 for ( i = 0; i < len; i++ ) { 31022 if ( jQuery.contains( self[ i ], this ) ) { 31023 return true; 31024 } 31025 } 31026 } ) ); 31027 } 31028 31029 for ( i = 0; i < len; i++ ) { 31030 jQuery.find( selector, self[ i ], ret ); 31031 } 31032 31033 // Needed because $( selector, context ) becomes $( context ).find( selector ) 31034 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); 31035 ret.selector = this.selector ? this.selector + " " + selector : selector; 31036 return ret; 31037 }, 31038 filter: function( selector ) { 31039 return this.pushStack( winnow( this, selector || [], false ) ); 31040 }, 31041 not: function( selector ) { 31042 return this.pushStack( winnow( this, selector || [], true ) ); 31043 }, 31044 is: function( selector ) { 31045 return !!winnow( 31046 this, 31047 31048 // If this is a positional/relative selector, check membership in the returned set 31049 // so $("p:first").is("p:last") won't return true for a doc with two "p". 31050 typeof selector === "string" && rneedsContext.test( selector ) ? 31051 jQuery( selector ) : 31052 selector || [], 31053 false 31054 ).length; 31055 } 31056 } ); 31057 31058 31059 // Initialize a jQuery object 31060 31061 31062 // A central reference to the root jQuery(document) 31063 var rootjQuery, 31064 31065 // A simple way to check for HTML strings 31066 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) 31067 // Strict HTML recognition (#11290: must start with <) 31068 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, 31069 31070 init = jQuery.fn.init = function( selector, context, root ) { 31071 var match, elem; 31072 31073 // HANDLE: $(""), $(null), $(undefined), $(false) 31074 if ( !selector ) { 31075 return this; 31076 } 31077 31078 // Method init() accepts an alternate rootjQuery 31079 // so migrate can support jQuery.sub (gh-2101) 31080 root = root || rootjQuery; 31081 31082 // Handle HTML strings 31083 if ( typeof selector === "string" ) { 31084 if ( selector[ 0 ] === "<" && 31085 selector[ selector.length - 1 ] === ">" && 31086 selector.length >= 3 ) { 31087 31088 // Assume that strings that start and end with <> are HTML and skip the regex check 31089 match = [ null, selector, null ]; 31090 31091 } else { 31092 match = rquickExpr.exec( selector ); 31093 } 31094 31095 // Match html or make sure no context is specified for #id 31096 if ( match && ( match[ 1 ] || !context ) ) { 31097 31098 // HANDLE: $(html) -> $(array) 31099 if ( match[ 1 ] ) { 31100 context = context instanceof jQuery ? context[ 0 ] : context; 31101 31102 // Option to run scripts is true for back-compat 31103 // Intentionally let the error be thrown if parseHTML is not present 31104 jQuery.merge( this, jQuery.parseHTML( 31105 match[ 1 ], 31106 context && context.nodeType ? context.ownerDocument || context : document, 31107 true 31108 ) ); 31109 31110 // HANDLE: $(html, props) 31111 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 31112 for ( match in context ) { 31113 31114 // Properties of context are called as methods if possible 31115 if ( jQuery.isFunction( this[ match ] ) ) { 31116 this[ match ]( context[ match ] ); 31117 31118 // ...and otherwise set as attributes 31119 } else { 31120 this.attr( match, context[ match ] ); 31121 } 31122 } 31123 } 31124 31125 return this; 31126 31127 // HANDLE: $(#id) 31128 } else { 31129 elem = document.getElementById( match[ 2 ] ); 31130 31131 // Support: Blackberry 4.6 31132 // gEBID returns nodes no longer in the document (#6963) 31133 if ( elem && elem.parentNode ) { 31134 31135 // Inject the element directly into the jQuery object 31136 this.length = 1; 31137 this[ 0 ] = elem; 31138 } 31139 31140 this.context = document; 31141 this.selector = selector; 31142 return this; 31143 } 31144 31145 // HANDLE: $(expr, $(...)) 31146 } else if ( !context || context.jquery ) { 31147 return ( context || root ).find( selector ); 31148 31149 // HANDLE: $(expr, context) 31150 // (which is just equivalent to: $(context).find(expr) 31151 } else { 31152 return this.constructor( context ).find( selector ); 31153 } 31154 31155 // HANDLE: $(DOMElement) 31156 } else if ( selector.nodeType ) { 31157 this.context = this[ 0 ] = selector; 31158 this.length = 1; 31159 return this; 31160 31161 // HANDLE: $(function) 31162 // Shortcut for document ready 31163 } else if ( jQuery.isFunction( selector ) ) { 31164 return root.ready !== undefined ? 31165 root.ready( selector ) : 31166 31167 // Execute immediately if ready is not present 31168 selector( jQuery ); 31169 } 31170 31171 if ( selector.selector !== undefined ) { 31172 this.selector = selector.selector; 31173 this.context = selector.context; 31174 } 31175 31176 return jQuery.makeArray( selector, this ); 31177 }; 31178 31179 // Give the init function the jQuery prototype for later instantiation 31180 init.prototype = jQuery.fn; 31181 31182 // Initialize central reference 31183 rootjQuery = jQuery( document ); 31184 31185 31186 var rparentsprev = /^(?:parents|prev(?:Until|All))/, 31187 31188 // Methods guaranteed to produce a unique set when starting from a unique set 31189 guaranteedUnique = { 31190 children: true, 31191 contents: true, 31192 next: true, 31193 prev: true 31194 }; 31195 31196 jQuery.fn.extend( { 31197 has: function( target ) { 31198 var targets = jQuery( target, this ), 31199 l = targets.length; 31200 31201 return this.filter( function() { 31202 var i = 0; 31203 for ( ; i < l; i++ ) { 31204 if ( jQuery.contains( this, targets[ i ] ) ) { 31205 return true; 31206 } 31207 } 31208 } ); 31209 }, 31210 31211 closest: function( selectors, context ) { 31212 var cur, 31213 i = 0, 31214 l = this.length, 31215 matched = [], 31216 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? 31217 jQuery( selectors, context || this.context ) : 31218 0; 31219 31220 for ( ; i < l; i++ ) { 31221 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 31222 31223 // Always skip document fragments 31224 if ( cur.nodeType < 11 && ( pos ? 31225 pos.index( cur ) > -1 : 31226 31227 // Don't pass non-elements to Sizzle 31228 cur.nodeType === 1 && 31229 jQuery.find.matchesSelector( cur, selectors ) ) ) { 31230 31231 matched.push( cur ); 31232 break; 31233 } 31234 } 31235 } 31236 31237 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 31238 }, 31239 31240 // Determine the position of an element within the set 31241 index: function( elem ) { 31242 31243 // No argument, return index in parent 31244 if ( !elem ) { 31245 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 31246 } 31247 31248 // Index in selector 31249 if ( typeof elem === "string" ) { 31250 return indexOf.call( jQuery( elem ), this[ 0 ] ); 31251 } 31252 31253 // Locate the position of the desired element 31254 return indexOf.call( this, 31255 31256 // If it receives a jQuery object, the first element is used 31257 elem.jquery ? elem[ 0 ] : elem 31258 ); 31259 }, 31260 31261 add: function( selector, context ) { 31262 return this.pushStack( 31263 jQuery.uniqueSort( 31264 jQuery.merge( this.get(), jQuery( selector, context ) ) 31265 ) 31266 ); 31267 }, 31268 31269 addBack: function( selector ) { 31270 return this.add( selector == null ? 31271 this.prevObject : this.prevObject.filter( selector ) 31272 ); 31273 } 31274 } ); 31275 31276 function sibling( cur, dir ) { 31277 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 31278 return cur; 31279 } 31280 31281 jQuery.each( { 31282 parent: function( elem ) { 31283 var parent = elem.parentNode; 31284 return parent && parent.nodeType !== 11 ? parent : null; 31285 }, 31286 parents: function( elem ) { 31287 return dir( elem, "parentNode" ); 31288 }, 31289 parentsUntil: function( elem, i, until ) { 31290 return dir( elem, "parentNode", until ); 31291 }, 31292 next: function( elem ) { 31293 return sibling( elem, "nextSibling" ); 31294 }, 31295 prev: function( elem ) { 31296 return sibling( elem, "previousSibling" ); 31297 }, 31298 nextAll: function( elem ) { 31299 return dir( elem, "nextSibling" ); 31300 }, 31301 prevAll: function( elem ) { 31302 return dir( elem, "previousSibling" ); 31303 }, 31304 nextUntil: function( elem, i, until ) { 31305 return dir( elem, "nextSibling", until ); 31306 }, 31307 prevUntil: function( elem, i, until ) { 31308 return dir( elem, "previousSibling", until ); 31309 }, 31310 siblings: function( elem ) { 31311 return siblings( ( elem.parentNode || {} ).firstChild, elem ); 31312 }, 31313 children: function( elem ) { 31314 return siblings( elem.firstChild ); 31315 }, 31316 contents: function( elem ) { 31317 return elem.contentDocument || jQuery.merge( [], elem.childNodes ); 31318 } 31319 }, function( name, fn ) { 31320 jQuery.fn[ name ] = function( until, selector ) { 31321 var matched = jQuery.map( this, fn, until ); 31322 31323 if ( name.slice( -5 ) !== "Until" ) { 31324 selector = until; 31325 } 31326 31327 if ( selector && typeof selector === "string" ) { 31328 matched = jQuery.filter( selector, matched ); 31329 } 31330 31331 if ( this.length > 1 ) { 31332 31333 // Remove duplicates 31334 if ( !guaranteedUnique[ name ] ) { 31335 jQuery.uniqueSort( matched ); 31336 } 31337 31338 // Reverse order for parents* and prev-derivatives 31339 if ( rparentsprev.test( name ) ) { 31340 matched.reverse(); 31341 } 31342 } 31343 31344 return this.pushStack( matched ); 31345 }; 31346 } ); 31347 var rnotwhite = ( /\S+/g ); 31348 31349 31350 31351 // Convert String-formatted options into Object-formatted ones 31352 function createOptions( options ) { 31353 var object = {}; 31354 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { 31355 object[ flag ] = true; 31356 } ); 31357 return object; 31358 } 31359 31360 /* 31361 * Create a callback list using the following parameters: 31362 * 31363 * options: an optional list of space-separated options that will change how 31364 * the callback list behaves or a more traditional option object 31365 * 31366 * By default a callback list will act like an event callback list and can be 31367 * "fired" multiple times. 31368 * 31369 * Possible options: 31370 * 31371 * once: will ensure the callback list can only be fired once (like a Deferred) 31372 * 31373 * memory: will keep track of previous values and will call any callback added 31374 * after the list has been fired right away with the latest "memorized" 31375 * values (like a Deferred) 31376 * 31377 * unique: will ensure a callback can only be added once (no duplicate in the list) 31378 * 31379 * stopOnFalse: interrupt callings when a callback returns false 31380 * 31381 */ 31382 jQuery.Callbacks = function( options ) { 31383 31384 // Convert options from String-formatted to Object-formatted if needed 31385 // (we check in cache first) 31386 options = typeof options === "string" ? 31387 createOptions( options ) : 31388 jQuery.extend( {}, options ); 31389 31390 var // Flag to know if list is currently firing 31391 firing, 31392 31393 // Last fire value for non-forgettable lists 31394 memory, 31395 31396 // Flag to know if list was already fired 31397 fired, 31398 31399 // Flag to prevent firing 31400 locked, 31401 31402 // Actual callback list 31403 list = [], 31404 31405 // Queue of execution data for repeatable lists 31406 queue = [], 31407 31408 // Index of currently firing callback (modified by add/remove as needed) 31409 firingIndex = -1, 31410 31411 // Fire callbacks 31412 fire = function() { 31413 31414 // Enforce single-firing 31415 locked = options.once; 31416 31417 // Execute callbacks for all pending executions, 31418 // respecting firingIndex overrides and runtime changes 31419 fired = firing = true; 31420 for ( ; queue.length; firingIndex = -1 ) { 31421 memory = queue.shift(); 31422 while ( ++firingIndex < list.length ) { 31423 31424 // Run callback and check for early termination 31425 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 31426 options.stopOnFalse ) { 31427 31428 // Jump to end and forget the data so .add doesn't re-fire 31429 firingIndex = list.length; 31430 memory = false; 31431 } 31432 } 31433 } 31434 31435 // Forget the data if we're done with it 31436 if ( !options.memory ) { 31437 memory = false; 31438 } 31439 31440 firing = false; 31441 31442 // Clean up if we're done firing for good 31443 if ( locked ) { 31444 31445 // Keep an empty list if we have data for future add calls 31446 if ( memory ) { 31447 list = []; 31448 31449 // Otherwise, this object is spent 31450 } else { 31451 list = ""; 31452 } 31453 } 31454 }, 31455 31456 // Actual Callbacks object 31457 self = { 31458 31459 // Add a callback or a collection of callbacks to the list 31460 add: function() { 31461 if ( list ) { 31462 31463 // If we have memory from a past run, we should fire after adding 31464 if ( memory && !firing ) { 31465 firingIndex = list.length - 1; 31466 queue.push( memory ); 31467 } 31468 31469 ( function add( args ) { 31470 jQuery.each( args, function( _, arg ) { 31471 if ( jQuery.isFunction( arg ) ) { 31472 if ( !options.unique || !self.has( arg ) ) { 31473 list.push( arg ); 31474 } 31475 } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { 31476 31477 // Inspect recursively 31478 add( arg ); 31479 } 31480 } ); 31481 } )( arguments ); 31482 31483 if ( memory && !firing ) { 31484 fire(); 31485 } 31486 } 31487 return this; 31488 }, 31489 31490 // Remove a callback from the list 31491 remove: function() { 31492 jQuery.each( arguments, function( _, arg ) { 31493 var index; 31494 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 31495 list.splice( index, 1 ); 31496 31497 // Handle firing indexes 31498 if ( index <= firingIndex ) { 31499 firingIndex--; 31500 } 31501 } 31502 } ); 31503 return this; 31504 }, 31505 31506 // Check if a given callback is in the list. 31507 // If no argument is given, return whether or not list has callbacks attached. 31508 has: function( fn ) { 31509 return fn ? 31510 jQuery.inArray( fn, list ) > -1 : 31511 list.length > 0; 31512 }, 31513 31514 // Remove all callbacks from the list 31515 empty: function() { 31516 if ( list ) { 31517 list = []; 31518 } 31519 return this; 31520 }, 31521 31522 // Disable .fire and .add 31523 // Abort any current/pending executions 31524 // Clear all callbacks and values 31525 disable: function() { 31526 locked = queue = []; 31527 list = memory = ""; 31528 return this; 31529 }, 31530 disabled: function() { 31531 return !list; 31532 }, 31533 31534 // Disable .fire 31535 // Also disable .add unless we have memory (since it would have no effect) 31536 // Abort any pending executions 31537 lock: function() { 31538 locked = queue = []; 31539 if ( !memory ) { 31540 list = memory = ""; 31541 } 31542 return this; 31543 }, 31544 locked: function() { 31545 return !!locked; 31546 }, 31547 31548 // Call all callbacks with the given context and arguments 31549 fireWith: function( context, args ) { 31550 if ( !locked ) { 31551 args = args || []; 31552 args = [ context, args.slice ? args.slice() : args ]; 31553 queue.push( args ); 31554 if ( !firing ) { 31555 fire(); 31556 } 31557 } 31558 return this; 31559 }, 31560 31561 // Call all the callbacks with the given arguments 31562 fire: function() { 31563 self.fireWith( this, arguments ); 31564 return this; 31565 }, 31566 31567 // To know if the callbacks have already been called at least once 31568 fired: function() { 31569 return !!fired; 31570 } 31571 }; 31572 31573 return self; 31574 }; 31575 31576 31577 jQuery.extend( { 31578 31579 Deferred: function( func ) { 31580 var tuples = [ 31581 31582 // action, add listener, listener list, final state 31583 [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], 31584 [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], 31585 [ "notify", "progress", jQuery.Callbacks( "memory" ) ] 31586 ], 31587 state = "pending", 31588 promise = { 31589 state: function() { 31590 return state; 31591 }, 31592 always: function() { 31593 deferred.done( arguments ).fail( arguments ); 31594 return this; 31595 }, 31596 then: function( /* fnDone, fnFail, fnProgress */ ) { 31597 var fns = arguments; 31598 return jQuery.Deferred( function( newDefer ) { 31599 jQuery.each( tuples, function( i, tuple ) { 31600 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; 31601 31602 // deferred[ done | fail | progress ] for forwarding actions to newDefer 31603 deferred[ tuple[ 1 ] ]( function() { 31604 var returned = fn && fn.apply( this, arguments ); 31605 if ( returned && jQuery.isFunction( returned.promise ) ) { 31606 returned.promise() 31607 .progress( newDefer.notify ) 31608 .done( newDefer.resolve ) 31609 .fail( newDefer.reject ); 31610 } else { 31611 newDefer[ tuple[ 0 ] + "With" ]( 31612 this === promise ? newDefer.promise() : this, 31613 fn ? [ returned ] : arguments 31614 ); 31615 } 31616 } ); 31617 } ); 31618 fns = null; 31619 } ).promise(); 31620 }, 31621 31622 // Get a promise for this deferred 31623 // If obj is provided, the promise aspect is added to the object 31624 promise: function( obj ) { 31625 return obj != null ? jQuery.extend( obj, promise ) : promise; 31626 } 31627 }, 31628 deferred = {}; 31629 31630 // Keep pipe for back-compat 31631 promise.pipe = promise.then; 31632 31633 // Add list-specific methods 31634 jQuery.each( tuples, function( i, tuple ) { 31635 var list = tuple[ 2 ], 31636 stateString = tuple[ 3 ]; 31637 31638 // promise[ done | fail | progress ] = list.add 31639 promise[ tuple[ 1 ] ] = list.add; 31640 31641 // Handle state 31642 if ( stateString ) { 31643 list.add( function() { 31644 31645 // state = [ resolved | rejected ] 31646 state = stateString; 31647 31648 // [ reject_list | resolve_list ].disable; progress_list.lock 31649 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); 31650 } 31651 31652 // deferred[ resolve | reject | notify ] 31653 deferred[ tuple[ 0 ] ] = function() { 31654 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); 31655 return this; 31656 }; 31657 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 31658 } ); 31659 31660 // Make the deferred a promise 31661 promise.promise( deferred ); 31662 31663 // Call given func if any 31664 if ( func ) { 31665 func.call( deferred, deferred ); 31666 } 31667 31668 // All done! 31669 return deferred; 31670 }, 31671 31672 // Deferred helper 31673 when: function( subordinate /* , ..., subordinateN */ ) { 31674 var i = 0, 31675 resolveValues = slice.call( arguments ), 31676 length = resolveValues.length, 31677 31678 // the count of uncompleted subordinates 31679 remaining = length !== 1 || 31680 ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, 31681 31682 // the master Deferred. 31683 // If resolveValues consist of only a single Deferred, just use that. 31684 deferred = remaining === 1 ? subordinate : jQuery.Deferred(), 31685 31686 // Update function for both resolve and progress values 31687 updateFunc = function( i, contexts, values ) { 31688 return function( value ) { 31689 contexts[ i ] = this; 31690 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 31691 if ( values === progressValues ) { 31692 deferred.notifyWith( contexts, values ); 31693 } else if ( !( --remaining ) ) { 31694 deferred.resolveWith( contexts, values ); 31695 } 31696 }; 31697 }, 31698 31699 progressValues, progressContexts, resolveContexts; 31700 31701 // Add listeners to Deferred subordinates; treat others as resolved 31702 if ( length > 1 ) { 31703 progressValues = new Array( length ); 31704 progressContexts = new Array( length ); 31705 resolveContexts = new Array( length ); 31706 for ( ; i < length; i++ ) { 31707 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { 31708 resolveValues[ i ].promise() 31709 .progress( updateFunc( i, progressContexts, progressValues ) ) 31710 .done( updateFunc( i, resolveContexts, resolveValues ) ) 31711 .fail( deferred.reject ); 31712 } else { 31713 --remaining; 31714 } 31715 } 31716 } 31717 31718 // If we're not waiting on anything, resolve the master 31719 if ( !remaining ) { 31720 deferred.resolveWith( resolveContexts, resolveValues ); 31721 } 31722 31723 return deferred.promise(); 31724 } 31725 } ); 31726 31727 31728 // The deferred used on DOM ready 31729 var readyList; 31730 31731 jQuery.fn.ready = function( fn ) { 31732 31733 // Add the callback 31734 jQuery.ready.promise().done( fn ); 31735 31736 return this; 31737 }; 31738 31739 jQuery.extend( { 31740 31741 // Is the DOM ready to be used? Set to true once it occurs. 31742 isReady: false, 31743 31744 // A counter to track how many items to wait for before 31745 // the ready event fires. See #6781 31746 readyWait: 1, 31747 31748 // Hold (or release) the ready event 31749 holdReady: function( hold ) { 31750 if ( hold ) { 31751 jQuery.readyWait++; 31752 } else { 31753 jQuery.ready( true ); 31754 } 31755 }, 31756 31757 // Handle when the DOM is ready 31758 ready: function( wait ) { 31759 31760 // Abort if there are pending holds or we're already ready 31761 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 31762 return; 31763 } 31764 31765 // Remember that the DOM is ready 31766 jQuery.isReady = true; 31767 31768 // If a normal DOM Ready event fired, decrement, and wait if need be 31769 if ( wait !== true && --jQuery.readyWait > 0 ) { 31770 return; 31771 } 31772 31773 // If there are functions bound, to execute 31774 readyList.resolveWith( document, [ jQuery ] ); 31775 31776 // Trigger any bound ready events 31777 if ( jQuery.fn.triggerHandler ) { 31778 jQuery( document ).triggerHandler( "ready" ); 31779 jQuery( document ).off( "ready" ); 31780 } 31781 } 31782 } ); 31783 31784 /** 31785 * The ready event handler and self cleanup method 31786 */ 31787 function completed() { 31788 document.removeEventListener( "DOMContentLoaded", completed ); 31789 window.removeEventListener( "load", completed ); 31790 jQuery.ready(); 31791 } 31792 31793 jQuery.ready.promise = function( obj ) { 31794 if ( !readyList ) { 31795 31796 readyList = jQuery.Deferred(); 31797 31798 // Catch cases where $(document).ready() is called 31799 // after the browser event has already occurred. 31800 // Support: IE9-10 only 31801 // Older IE sometimes signals "interactive" too soon 31802 if ( document.readyState === "complete" || 31803 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 31804 31805 // Handle it asynchronously to allow scripts the opportunity to delay ready 31806 window.setTimeout( jQuery.ready ); 31807 31808 } else { 31809 31810 // Use the handy event callback 31811 document.addEventListener( "DOMContentLoaded", completed ); 31812 31813 // A fallback to window.onload, that will always work 31814 window.addEventListener( "load", completed ); 31815 } 31816 } 31817 return readyList.promise( obj ); 31818 }; 31819 31820 // Kick off the DOM ready check even if the user does not 31821 jQuery.ready.promise(); 31822 31823 31824 31825 31826 // Multifunctional method to get and set values of a collection 31827 // The value/s can optionally be executed if it's a function 31828 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 31829 var i = 0, 31830 len = elems.length, 31831 bulk = key == null; 31832 31833 // Sets many values 31834 if ( jQuery.type( key ) === "object" ) { 31835 chainable = true; 31836 for ( i in key ) { 31837 access( elems, fn, i, key[ i ], true, emptyGet, raw ); 31838 } 31839 31840 // Sets one value 31841 } else if ( value !== undefined ) { 31842 chainable = true; 31843 31844 if ( !jQuery.isFunction( value ) ) { 31845 raw = true; 31846 } 31847 31848 if ( bulk ) { 31849 31850 // Bulk operations run against the entire set 31851 if ( raw ) { 31852 fn.call( elems, value ); 31853 fn = null; 31854 31855 // ...except when executing function values 31856 } else { 31857 bulk = fn; 31858 fn = function( elem, key, value ) { 31859 return bulk.call( jQuery( elem ), value ); 31860 }; 31861 } 31862 } 31863 31864 if ( fn ) { 31865 for ( ; i < len; i++ ) { 31866 fn( 31867 elems[ i ], key, raw ? 31868 value : 31869 value.call( elems[ i ], i, fn( elems[ i ], key ) ) 31870 ); 31871 } 31872 } 31873 } 31874 31875 return chainable ? 31876 elems : 31877 31878 // Gets 31879 bulk ? 31880 fn.call( elems ) : 31881 len ? fn( elems[ 0 ], key ) : emptyGet; 31882 }; 31883 var acceptData = function( owner ) { 31884 31885 // Accepts only: 31886 // - Node 31887 // - Node.ELEMENT_NODE 31888 // - Node.DOCUMENT_NODE 31889 // - Object 31890 // - Any 31891 /* jshint -W018 */ 31892 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 31893 }; 31894 31895 31896 31897 31898 function Data() { 31899 this.expando = jQuery.expando + Data.uid++; 31900 } 31901 31902 Data.uid = 1; 31903 31904 Data.prototype = { 31905 31906 register: function( owner, initial ) { 31907 var value = initial || {}; 31908 31909 // If it is a node unlikely to be stringify-ed or looped over 31910 // use plain assignment 31911 if ( owner.nodeType ) { 31912 owner[ this.expando ] = value; 31913 31914 // Otherwise secure it in a non-enumerable, non-writable property 31915 // configurability must be true to allow the property to be 31916 // deleted with the delete operator 31917 } else { 31918 Object.defineProperty( owner, this.expando, { 31919 value: value, 31920 writable: true, 31921 configurable: true 31922 } ); 31923 } 31924 return owner[ this.expando ]; 31925 }, 31926 cache: function( owner ) { 31927 31928 // We can accept data for non-element nodes in modern browsers, 31929 // but we should not, see #8335. 31930 // Always return an empty object. 31931 if ( !acceptData( owner ) ) { 31932 return {}; 31933 } 31934 31935 // Check if the owner object already has a cache 31936 var value = owner[ this.expando ]; 31937 31938 // If not, create one 31939 if ( !value ) { 31940 value = {}; 31941 31942 // We can accept data for non-element nodes in modern browsers, 31943 // but we should not, see #8335. 31944 // Always return an empty object. 31945 if ( acceptData( owner ) ) { 31946 31947 // If it is a node unlikely to be stringify-ed or looped over 31948 // use plain assignment 31949 if ( owner.nodeType ) { 31950 owner[ this.expando ] = value; 31951 31952 // Otherwise secure it in a non-enumerable property 31953 // configurable must be true to allow the property to be 31954 // deleted when data is removed 31955 } else { 31956 Object.defineProperty( owner, this.expando, { 31957 value: value, 31958 configurable: true 31959 } ); 31960 } 31961 } 31962 } 31963 31964 return value; 31965 }, 31966 set: function( owner, data, value ) { 31967 var prop, 31968 cache = this.cache( owner ); 31969 31970 // Handle: [ owner, key, value ] args 31971 if ( typeof data === "string" ) { 31972 cache[ data ] = value; 31973 31974 // Handle: [ owner, { properties } ] args 31975 } else { 31976 31977 // Copy the properties one-by-one to the cache object 31978 for ( prop in data ) { 31979 cache[ prop ] = data[ prop ]; 31980 } 31981 } 31982 return cache; 31983 }, 31984 get: function( owner, key ) { 31985 return key === undefined ? 31986 this.cache( owner ) : 31987 owner[ this.expando ] && owner[ this.expando ][ key ]; 31988 }, 31989 access: function( owner, key, value ) { 31990 var stored; 31991 31992 // In cases where either: 31993 // 31994 // 1. No key was specified 31995 // 2. A string key was specified, but no value provided 31996 // 31997 // Take the "read" path and allow the get method to determine 31998 // which value to return, respectively either: 31999 // 32000 // 1. The entire cache object 32001 // 2. The data stored at the key 32002 // 32003 if ( key === undefined || 32004 ( ( key && typeof key === "string" ) && value === undefined ) ) { 32005 32006 stored = this.get( owner, key ); 32007 32008 return stored !== undefined ? 32009 stored : this.get( owner, jQuery.camelCase( key ) ); 32010 } 32011 32012 // When the key is not a string, or both a key and value 32013 // are specified, set or extend (existing objects) with either: 32014 // 32015 // 1. An object of properties 32016 // 2. A key and value 32017 // 32018 this.set( owner, key, value ); 32019 32020 // Since the "set" path can have two possible entry points 32021 // return the expected data based on which path was taken[*] 32022 return value !== undefined ? value : key; 32023 }, 32024 remove: function( owner, key ) { 32025 var i, name, camel, 32026 cache = owner[ this.expando ]; 32027 32028 if ( cache === undefined ) { 32029 return; 32030 } 32031 32032 if ( key === undefined ) { 32033 this.register( owner ); 32034 32035 } else { 32036 32037 // Support array or space separated string of keys 32038 if ( jQuery.isArray( key ) ) { 32039 32040 // If "name" is an array of keys... 32041 // When data is initially created, via ("key", "val") signature, 32042 // keys will be converted to camelCase. 32043 // Since there is no way to tell _how_ a key was added, remove 32044 // both plain key and camelCase key. #12786 32045 // This will only penalize the array argument path. 32046 name = key.concat( key.map( jQuery.camelCase ) ); 32047 } else { 32048 camel = jQuery.camelCase( key ); 32049 32050 // Try the string as a key before any manipulation 32051 if ( key in cache ) { 32052 name = [ key, camel ]; 32053 } else { 32054 32055 // If a key with the spaces exists, use it. 32056 // Otherwise, create an array by matching non-whitespace 32057 name = camel; 32058 name = name in cache ? 32059 [ name ] : ( name.match( rnotwhite ) || [] ); 32060 } 32061 } 32062 32063 i = name.length; 32064 32065 while ( i-- ) { 32066 delete cache[ name[ i ] ]; 32067 } 32068 } 32069 32070 // Remove the expando if there's no more data 32071 if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 32072 32073 // Support: Chrome <= 35-45+ 32074 // Webkit & Blink performance suffers when deleting properties 32075 // from DOM nodes, so set to undefined instead 32076 // https://code.google.com/p/chromium/issues/detail?id=378607 32077 if ( owner.nodeType ) { 32078 owner[ this.expando ] = undefined; 32079 } else { 32080 delete owner[ this.expando ]; 32081 } 32082 } 32083 }, 32084 hasData: function( owner ) { 32085 var cache = owner[ this.expando ]; 32086 return cache !== undefined && !jQuery.isEmptyObject( cache ); 32087 } 32088 }; 32089 var dataPriv = new Data(); 32090 32091 var dataUser = new Data(); 32092 32093 32094 32095 // Implementation Summary 32096 // 32097 // 1. Enforce API surface and semantic compatibility with 1.9.x branch 32098 // 2. Improve the module's maintainability by reducing the storage 32099 // paths to a single mechanism. 32100 // 3. Use the same single mechanism to support "private" and "user" data. 32101 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 32102 // 5. Avoid exposing implementation details on user objects (eg. expando properties) 32103 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 32104 32105 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 32106 rmultiDash = /[A-Z]/g; 32107 32108 function dataAttr( elem, key, data ) { 32109 var name; 32110 32111 // If nothing was found internally, try to fetch any 32112 // data from the HTML5 data-* attribute 32113 if ( data === undefined && elem.nodeType === 1 ) { 32114 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 32115 data = elem.getAttribute( name ); 32116 32117 if ( typeof data === "string" ) { 32118 try { 32119 data = data === "true" ? true : 32120 data === "false" ? false : 32121 data === "null" ? null : 32122 32123 // Only convert to a number if it doesn't change the string 32124 +data + "" === data ? +data : 32125 rbrace.test( data ) ? jQuery.parseJSON( data ) : 32126 data; 32127 } catch ( e ) {} 32128 32129 // Make sure we set the data so it isn't changed later 32130 dataUser.set( elem, key, data ); 32131 } else { 32132 data = undefined; 32133 } 32134 } 32135 return data; 32136 } 32137 32138 jQuery.extend( { 32139 hasData: function( elem ) { 32140 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 32141 }, 32142 32143 data: function( elem, name, data ) { 32144 return dataUser.access( elem, name, data ); 32145 }, 32146 32147 removeData: function( elem, name ) { 32148 dataUser.remove( elem, name ); 32149 }, 32150 32151 // TODO: Now that all calls to _data and _removeData have been replaced 32152 // with direct calls to dataPriv methods, these can be deprecated. 32153 _data: function( elem, name, data ) { 32154 return dataPriv.access( elem, name, data ); 32155 }, 32156 32157 _removeData: function( elem, name ) { 32158 dataPriv.remove( elem, name ); 32159 } 32160 } ); 32161 32162 jQuery.fn.extend( { 32163 data: function( key, value ) { 32164 var i, name, data, 32165 elem = this[ 0 ], 32166 attrs = elem && elem.attributes; 32167 32168 // Gets all values 32169 if ( key === undefined ) { 32170 if ( this.length ) { 32171 data = dataUser.get( elem ); 32172 32173 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 32174 i = attrs.length; 32175 while ( i-- ) { 32176 32177 // Support: IE11+ 32178 // The attrs elements can be null (#14894) 32179 if ( attrs[ i ] ) { 32180 name = attrs[ i ].name; 32181 if ( name.indexOf( "data-" ) === 0 ) { 32182 name = jQuery.camelCase( name.slice( 5 ) ); 32183 dataAttr( elem, name, data[ name ] ); 32184 } 32185 } 32186 } 32187 dataPriv.set( elem, "hasDataAttrs", true ); 32188 } 32189 } 32190 32191 return data; 32192 } 32193 32194 // Sets multiple values 32195 if ( typeof key === "object" ) { 32196 return this.each( function() { 32197 dataUser.set( this, key ); 32198 } ); 32199 } 32200 32201 return access( this, function( value ) { 32202 var data, camelKey; 32203 32204 // The calling jQuery object (element matches) is not empty 32205 // (and therefore has an element appears at this[ 0 ]) and the 32206 // `value` parameter was not undefined. An empty jQuery object 32207 // will result in `undefined` for elem = this[ 0 ] which will 32208 // throw an exception if an attempt to read a data cache is made. 32209 if ( elem && value === undefined ) { 32210 32211 // Attempt to get data from the cache 32212 // with the key as-is 32213 data = dataUser.get( elem, key ) || 32214 32215 // Try to find dashed key if it exists (gh-2779) 32216 // This is for 2.2.x only 32217 dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() ); 32218 32219 if ( data !== undefined ) { 32220 return data; 32221 } 32222 32223 camelKey = jQuery.camelCase( key ); 32224 32225 // Attempt to get data from the cache 32226 // with the key camelized 32227 data = dataUser.get( elem, camelKey ); 32228 if ( data !== undefined ) { 32229 return data; 32230 } 32231 32232 // Attempt to "discover" the data in 32233 // HTML5 custom data-* attrs 32234 data = dataAttr( elem, camelKey, undefined ); 32235 if ( data !== undefined ) { 32236 return data; 32237 } 32238 32239 // We tried really hard, but the data doesn't exist. 32240 return; 32241 } 32242 32243 // Set the data... 32244 camelKey = jQuery.camelCase( key ); 32245 this.each( function() { 32246 32247 // First, attempt to store a copy or reference of any 32248 // data that might've been store with a camelCased key. 32249 var data = dataUser.get( this, camelKey ); 32250 32251 // For HTML5 data-* attribute interop, we have to 32252 // store property names with dashes in a camelCase form. 32253 // This might not apply to all properties...* 32254 dataUser.set( this, camelKey, value ); 32255 32256 // *... In the case of properties that might _actually_ 32257 // have dashes, we need to also store a copy of that 32258 // unchanged property. 32259 if ( key.indexOf( "-" ) > -1 && data !== undefined ) { 32260 dataUser.set( this, key, value ); 32261 } 32262 } ); 32263 }, null, value, arguments.length > 1, null, true ); 32264 }, 32265 32266 removeData: function( key ) { 32267 return this.each( function() { 32268 dataUser.remove( this, key ); 32269 } ); 32270 } 32271 } ); 32272 32273 32274 jQuery.extend( { 32275 queue: function( elem, type, data ) { 32276 var queue; 32277 32278 if ( elem ) { 32279 type = ( type || "fx" ) + "queue"; 32280 queue = dataPriv.get( elem, type ); 32281 32282 // Speed up dequeue by getting out quickly if this is just a lookup 32283 if ( data ) { 32284 if ( !queue || jQuery.isArray( data ) ) { 32285 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 32286 } else { 32287 queue.push( data ); 32288 } 32289 } 32290 return queue || []; 32291 } 32292 }, 32293 32294 dequeue: function( elem, type ) { 32295 type = type || "fx"; 32296 32297 var queue = jQuery.queue( elem, type ), 32298 startLength = queue.length, 32299 fn = queue.shift(), 32300 hooks = jQuery._queueHooks( elem, type ), 32301 next = function() { 32302 jQuery.dequeue( elem, type ); 32303 }; 32304 32305 // If the fx queue is dequeued, always remove the progress sentinel 32306 if ( fn === "inprogress" ) { 32307 fn = queue.shift(); 32308 startLength--; 32309 } 32310 32311 if ( fn ) { 32312 32313 // Add a progress sentinel to prevent the fx queue from being 32314 // automatically dequeued 32315 if ( type === "fx" ) { 32316 queue.unshift( "inprogress" ); 32317 } 32318 32319 // Clear up the last queue stop function 32320 delete hooks.stop; 32321 fn.call( elem, next, hooks ); 32322 } 32323 32324 if ( !startLength && hooks ) { 32325 hooks.empty.fire(); 32326 } 32327 }, 32328 32329 // Not public - generate a queueHooks object, or return the current one 32330 _queueHooks: function( elem, type ) { 32331 var key = type + "queueHooks"; 32332 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 32333 empty: jQuery.Callbacks( "once memory" ).add( function() { 32334 dataPriv.remove( elem, [ type + "queue", key ] ); 32335 } ) 32336 } ); 32337 } 32338 } ); 32339 32340 jQuery.fn.extend( { 32341 queue: function( type, data ) { 32342 var setter = 2; 32343 32344 if ( typeof type !== "string" ) { 32345 data = type; 32346 type = "fx"; 32347 setter--; 32348 } 32349 32350 if ( arguments.length < setter ) { 32351 return jQuery.queue( this[ 0 ], type ); 32352 } 32353 32354 return data === undefined ? 32355 this : 32356 this.each( function() { 32357 var queue = jQuery.queue( this, type, data ); 32358 32359 // Ensure a hooks for this queue 32360 jQuery._queueHooks( this, type ); 32361 32362 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 32363 jQuery.dequeue( this, type ); 32364 } 32365 } ); 32366 }, 32367 dequeue: function( type ) { 32368 return this.each( function() { 32369 jQuery.dequeue( this, type ); 32370 } ); 32371 }, 32372 clearQueue: function( type ) { 32373 return this.queue( type || "fx", [] ); 32374 }, 32375 32376 // Get a promise resolved when queues of a certain type 32377 // are emptied (fx is the type by default) 32378 promise: function( type, obj ) { 32379 var tmp, 32380 count = 1, 32381 defer = jQuery.Deferred(), 32382 elements = this, 32383 i = this.length, 32384 resolve = function() { 32385 if ( !( --count ) ) { 32386 defer.resolveWith( elements, [ elements ] ); 32387 } 32388 }; 32389 32390 if ( typeof type !== "string" ) { 32391 obj = type; 32392 type = undefined; 32393 } 32394 type = type || "fx"; 32395 32396 while ( i-- ) { 32397 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 32398 if ( tmp && tmp.empty ) { 32399 count++; 32400 tmp.empty.add( resolve ); 32401 } 32402 } 32403 resolve(); 32404 return defer.promise( obj ); 32405 } 32406 } ); 32407 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 32408 32409 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 32410 32411 32412 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 32413 32414 var isHidden = function( elem, el ) { 32415 32416 // isHidden might be called from jQuery#filter function; 32417 // in that case, element will be second argument 32418 elem = el || elem; 32419 return jQuery.css( elem, "display" ) === "none" || 32420 !jQuery.contains( elem.ownerDocument, elem ); 32421 }; 32422 32423 32424 32425 function adjustCSS( elem, prop, valueParts, tween ) { 32426 var adjusted, 32427 scale = 1, 32428 maxIterations = 20, 32429 currentValue = tween ? 32430 function() { return tween.cur(); } : 32431 function() { return jQuery.css( elem, prop, "" ); }, 32432 initial = currentValue(), 32433 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 32434 32435 // Starting value computation is required for potential unit mismatches 32436 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 32437 rcssNum.exec( jQuery.css( elem, prop ) ); 32438 32439 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 32440 32441 // Trust units reported by jQuery.css 32442 unit = unit || initialInUnit[ 3 ]; 32443 32444 // Make sure we update the tween properties later on 32445 valueParts = valueParts || []; 32446 32447 // Iteratively approximate from a nonzero starting point 32448 initialInUnit = +initial || 1; 32449 32450 do { 32451 32452 // If previous iteration zeroed out, double until we get *something*. 32453 // Use string for doubling so we don't accidentally see scale as unchanged below 32454 scale = scale || ".5"; 32455 32456 // Adjust and apply 32457 initialInUnit = initialInUnit / scale; 32458 jQuery.style( elem, prop, initialInUnit + unit ); 32459 32460 // Update scale, tolerating zero or NaN from tween.cur() 32461 // Break the loop if scale is unchanged or perfect, or if we've just had enough. 32462 } while ( 32463 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations 32464 ); 32465 } 32466 32467 if ( valueParts ) { 32468 initialInUnit = +initialInUnit || +initial || 0; 32469 32470 // Apply relative offset (+=/-=) if specified 32471 adjusted = valueParts[ 1 ] ? 32472 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 32473 +valueParts[ 2 ]; 32474 if ( tween ) { 32475 tween.unit = unit; 32476 tween.start = initialInUnit; 32477 tween.end = adjusted; 32478 } 32479 } 32480 return adjusted; 32481 } 32482 var rcheckableType = ( /^(?:checkbox|radio)$/i ); 32483 32484 var rtagName = ( /<([\w:-]+)/ ); 32485 32486 var rscriptType = ( /^$|\/(?:java|ecma)script/i ); 32487 32488 32489 32490 // We have to close these tags to support XHTML (#13200) 32491 var wrapMap = { 32492 32493 // Support: IE9 32494 option: [ 1, "<select multiple='multiple'>", "</select>" ], 32495 32496 // XHTML parsers do not magically insert elements in the 32497 // same way that tag soup parsers do. So we cannot shorten 32498 // this by omitting <tbody> or other required elements. 32499 thead: [ 1, "<table>", "</table>" ], 32500 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], 32501 tr: [ 2, "<table><tbody>", "</tbody></table>" ], 32502 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 32503 32504 _default: [ 0, "", "" ] 32505 }; 32506 32507 // Support: IE9 32508 wrapMap.optgroup = wrapMap.option; 32509 32510 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 32511 wrapMap.th = wrapMap.td; 32512 32513 32514 function getAll( context, tag ) { 32515 32516 // Support: IE9-11+ 32517 // Use typeof to avoid zero-argument method invocation on host objects (#15151) 32518 var ret = typeof context.getElementsByTagName !== "undefined" ? 32519 context.getElementsByTagName( tag || "*" ) : 32520 typeof context.querySelectorAll !== "undefined" ? 32521 context.querySelectorAll( tag || "*" ) : 32522 []; 32523 32524 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? 32525 jQuery.merge( [ context ], ret ) : 32526 ret; 32527 } 32528 32529 32530 // Mark scripts as having already been evaluated 32531 function setGlobalEval( elems, refElements ) { 32532 var i = 0, 32533 l = elems.length; 32534 32535 for ( ; i < l; i++ ) { 32536 dataPriv.set( 32537 elems[ i ], 32538 "globalEval", 32539 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 32540 ); 32541 } 32542 } 32543 32544 32545 var rhtml = /<|&#?\w+;/; 32546 32547 function buildFragment( elems, context, scripts, selection, ignored ) { 32548 var elem, tmp, tag, wrap, contains, j, 32549 fragment = context.createDocumentFragment(), 32550 nodes = [], 32551 i = 0, 32552 l = elems.length; 32553 32554 for ( ; i < l; i++ ) { 32555 elem = elems[ i ]; 32556 32557 if ( elem || elem === 0 ) { 32558 32559 // Add nodes directly 32560 if ( jQuery.type( elem ) === "object" ) { 32561 32562 // Support: Android<4.1, PhantomJS<2 32563 // push.apply(_, arraylike) throws on ancient WebKit 32564 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 32565 32566 // Convert non-html into a text node 32567 } else if ( !rhtml.test( elem ) ) { 32568 nodes.push( context.createTextNode( elem ) ); 32569 32570 // Convert html into DOM nodes 32571 } else { 32572 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 32573 32574 // Deserialize a standard representation 32575 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 32576 wrap = wrapMap[ tag ] || wrapMap._default; 32577 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 32578 32579 // Descend through wrappers to the right content 32580 j = wrap[ 0 ]; 32581 while ( j-- ) { 32582 tmp = tmp.lastChild; 32583 } 32584 32585 // Support: Android<4.1, PhantomJS<2 32586 // push.apply(_, arraylike) throws on ancient WebKit 32587 jQuery.merge( nodes, tmp.childNodes ); 32588 32589 // Remember the top-level container 32590 tmp = fragment.firstChild; 32591 32592 // Ensure the created nodes are orphaned (#12392) 32593 tmp.textContent = ""; 32594 } 32595 } 32596 } 32597 32598 // Remove wrapper from fragment 32599 fragment.textContent = ""; 32600 32601 i = 0; 32602 while ( ( elem = nodes[ i++ ] ) ) { 32603 32604 // Skip elements already in the context collection (trac-4087) 32605 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 32606 if ( ignored ) { 32607 ignored.push( elem ); 32608 } 32609 continue; 32610 } 32611 32612 contains = jQuery.contains( elem.ownerDocument, elem ); 32613 32614 // Append to fragment 32615 tmp = getAll( fragment.appendChild( elem ), "script" ); 32616 32617 // Preserve script evaluation history 32618 if ( contains ) { 32619 setGlobalEval( tmp ); 32620 } 32621 32622 // Capture executables 32623 if ( scripts ) { 32624 j = 0; 32625 while ( ( elem = tmp[ j++ ] ) ) { 32626 if ( rscriptType.test( elem.type || "" ) ) { 32627 scripts.push( elem ); 32628 } 32629 } 32630 } 32631 } 32632 32633 return fragment; 32634 } 32635 32636 32637 ( function() { 32638 var fragment = document.createDocumentFragment(), 32639 div = fragment.appendChild( document.createElement( "div" ) ), 32640 input = document.createElement( "input" ); 32641 32642 // Support: Android 4.0-4.3, Safari<=5.1 32643 // Check state lost if the name is set (#11217) 32644 // Support: Windows Web Apps (WWA) 32645 // `name` and `type` must use .setAttribute for WWA (#14901) 32646 input.setAttribute( "type", "radio" ); 32647 input.setAttribute( "checked", "checked" ); 32648 input.setAttribute( "name", "t" ); 32649 32650 div.appendChild( input ); 32651 32652 // Support: Safari<=5.1, Android<4.2 32653 // Older WebKit doesn't clone checked state correctly in fragments 32654 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 32655 32656 // Support: IE<=11+ 32657 // Make sure textarea (and checkbox) defaultValue is properly cloned 32658 div.innerHTML = "<textarea>x</textarea>"; 32659 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 32660 } )(); 32661 32662 32663 var 32664 rkeyEvent = /^key/, 32665 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, 32666 rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 32667 32668 function returnTrue() { 32669 return true; 32670 } 32671 32672 function returnFalse() { 32673 return false; 32674 } 32675 32676 // Support: IE9 32677 // See #13393 for more info 32678 function safeActiveElement() { 32679 try { 32680 return document.activeElement; 32681 } catch ( err ) { } 32682 } 32683 32684 function on( elem, types, selector, data, fn, one ) { 32685 var origFn, type; 32686 32687 // Types can be a map of types/handlers 32688 if ( typeof types === "object" ) { 32689 32690 // ( types-Object, selector, data ) 32691 if ( typeof selector !== "string" ) { 32692 32693 // ( types-Object, data ) 32694 data = data || selector; 32695 selector = undefined; 32696 } 32697 for ( type in types ) { 32698 on( elem, type, selector, data, types[ type ], one ); 32699 } 32700 return elem; 32701 } 32702 32703 if ( data == null && fn == null ) { 32704 32705 // ( types, fn ) 32706 fn = selector; 32707 data = selector = undefined; 32708 } else if ( fn == null ) { 32709 if ( typeof selector === "string" ) { 32710 32711 // ( types, selector, fn ) 32712 fn = data; 32713 data = undefined; 32714 } else { 32715 32716 // ( types, data, fn ) 32717 fn = data; 32718 data = selector; 32719 selector = undefined; 32720 } 32721 } 32722 if ( fn === false ) { 32723 fn = returnFalse; 32724 } else if ( !fn ) { 32725 return elem; 32726 } 32727 32728 if ( one === 1 ) { 32729 origFn = fn; 32730 fn = function( event ) { 32731 32732 // Can use an empty set, since event contains the info 32733 jQuery().off( event ); 32734 return origFn.apply( this, arguments ); 32735 }; 32736 32737 // Use same guid so caller can remove using origFn 32738 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 32739 } 32740 return elem.each( function() { 32741 jQuery.event.add( this, types, fn, data, selector ); 32742 } ); 32743 } 32744 32745 /* 32746 * Helper functions for managing events -- not part of the public interface. 32747 * Props to Dean Edwards' addEvent library for many of the ideas. 32748 */ 32749 jQuery.event = { 32750 32751 global: {}, 32752 32753 add: function( elem, types, handler, data, selector ) { 32754 32755 var handleObjIn, eventHandle, tmp, 32756 events, t, handleObj, 32757 special, handlers, type, namespaces, origType, 32758 elemData = dataPriv.get( elem ); 32759 32760 // Don't attach events to noData or text/comment nodes (but allow plain objects) 32761 if ( !elemData ) { 32762 return; 32763 } 32764 32765 // Caller can pass in an object of custom data in lieu of the handler 32766 if ( handler.handler ) { 32767 handleObjIn = handler; 32768 handler = handleObjIn.handler; 32769 selector = handleObjIn.selector; 32770 } 32771 32772 // Make sure that the handler has a unique ID, used to find/remove it later 32773 if ( !handler.guid ) { 32774 handler.guid = jQuery.guid++; 32775 } 32776 32777 // Init the element's event structure and main handler, if this is the first 32778 if ( !( events = elemData.events ) ) { 32779 events = elemData.events = {}; 32780 } 32781 if ( !( eventHandle = elemData.handle ) ) { 32782 eventHandle = elemData.handle = function( e ) { 32783 32784 // Discard the second event of a jQuery.event.trigger() and 32785 // when an event is called after a page has unloaded 32786 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? 32787 jQuery.event.dispatch.apply( elem, arguments ) : undefined; 32788 }; 32789 } 32790 32791 // Handle multiple events separated by a space 32792 types = ( types || "" ).match( rnotwhite ) || [ "" ]; 32793 t = types.length; 32794 while ( t-- ) { 32795 tmp = rtypenamespace.exec( types[ t ] ) || []; 32796 type = origType = tmp[ 1 ]; 32797 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 32798 32799 // There *must* be a type, no attaching namespace-only handlers 32800 if ( !type ) { 32801 continue; 32802 } 32803 32804 // If event changes its type, use the special event handlers for the changed type 32805 special = jQuery.event.special[ type ] || {}; 32806 32807 // If selector defined, determine special event api type, otherwise given type 32808 type = ( selector ? special.delegateType : special.bindType ) || type; 32809 32810 // Update special based on newly reset type 32811 special = jQuery.event.special[ type ] || {}; 32812 32813 // handleObj is passed to all event handlers 32814 handleObj = jQuery.extend( { 32815 type: type, 32816 origType: origType, 32817 data: data, 32818 handler: handler, 32819 guid: handler.guid, 32820 selector: selector, 32821 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 32822 namespace: namespaces.join( "." ) 32823 }, handleObjIn ); 32824 32825 // Init the event handler queue if we're the first 32826 if ( !( handlers = events[ type ] ) ) { 32827 handlers = events[ type ] = []; 32828 handlers.delegateCount = 0; 32829 32830 // Only use addEventListener if the special events handler returns false 32831 if ( !special.setup || 32832 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 32833 32834 if ( elem.addEventListener ) { 32835 elem.addEventListener( type, eventHandle ); 32836 } 32837 } 32838 } 32839 32840 if ( special.add ) { 32841 special.add.call( elem, handleObj ); 32842 32843 if ( !handleObj.handler.guid ) { 32844 handleObj.handler.guid = handler.guid; 32845 } 32846 } 32847 32848 // Add to the element's handler list, delegates in front 32849 if ( selector ) { 32850 handlers.splice( handlers.delegateCount++, 0, handleObj ); 32851 } else { 32852 handlers.push( handleObj ); 32853 } 32854 32855 // Keep track of which events have ever been used, for event optimization 32856 jQuery.event.global[ type ] = true; 32857 } 32858 32859 }, 32860 32861 // Detach an event or set of events from an element 32862 remove: function( elem, types, handler, selector, mappedTypes ) { 32863 32864 var j, origCount, tmp, 32865 events, t, handleObj, 32866 special, handlers, type, namespaces, origType, 32867 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); 32868 32869 if ( !elemData || !( events = elemData.events ) ) { 32870 return; 32871 } 32872 32873 // Once for each type.namespace in types; type may be omitted 32874 types = ( types || "" ).match( rnotwhite ) || [ "" ]; 32875 t = types.length; 32876 while ( t-- ) { 32877 tmp = rtypenamespace.exec( types[ t ] ) || []; 32878 type = origType = tmp[ 1 ]; 32879 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 32880 32881 // Unbind all events (on this namespace, if provided) for the element 32882 if ( !type ) { 32883 for ( type in events ) { 32884 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 32885 } 32886 continue; 32887 } 32888 32889 special = jQuery.event.special[ type ] || {}; 32890 type = ( selector ? special.delegateType : special.bindType ) || type; 32891 handlers = events[ type ] || []; 32892 tmp = tmp[ 2 ] && 32893 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 32894 32895 // Remove matching events 32896 origCount = j = handlers.length; 32897 while ( j-- ) { 32898 handleObj = handlers[ j ]; 32899 32900 if ( ( mappedTypes || origType === handleObj.origType ) && 32901 ( !handler || handler.guid === handleObj.guid ) && 32902 ( !tmp || tmp.test( handleObj.namespace ) ) && 32903 ( !selector || selector === handleObj.selector || 32904 selector === "**" && handleObj.selector ) ) { 32905 handlers.splice( j, 1 ); 32906 32907 if ( handleObj.selector ) { 32908 handlers.delegateCount--; 32909 } 32910 if ( special.remove ) { 32911 special.remove.call( elem, handleObj ); 32912 } 32913 } 32914 } 32915 32916 // Remove generic event handler if we removed something and no more handlers exist 32917 // (avoids potential for endless recursion during removal of special event handlers) 32918 if ( origCount && !handlers.length ) { 32919 if ( !special.teardown || 32920 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 32921 32922 jQuery.removeEvent( elem, type, elemData.handle ); 32923 } 32924 32925 delete events[ type ]; 32926 } 32927 } 32928 32929 // Remove data and the expando if it's no longer used 32930 if ( jQuery.isEmptyObject( events ) ) { 32931 dataPriv.remove( elem, "handle events" ); 32932 } 32933 }, 32934 32935 dispatch: function( event ) { 32936 32937 // Make a writable jQuery.Event from the native event object 32938 event = jQuery.event.fix( event ); 32939 32940 var i, j, ret, matched, handleObj, 32941 handlerQueue = [], 32942 args = slice.call( arguments ), 32943 handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], 32944 special = jQuery.event.special[ event.type ] || {}; 32945 32946 // Use the fix-ed jQuery.Event rather than the (read-only) native event 32947 args[ 0 ] = event; 32948 event.delegateTarget = this; 32949 32950 // Call the preDispatch hook for the mapped type, and let it bail if desired 32951 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 32952 return; 32953 } 32954 32955 // Determine handlers 32956 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 32957 32958 // Run delegates first; they may want to stop propagation beneath us 32959 i = 0; 32960 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 32961 event.currentTarget = matched.elem; 32962 32963 j = 0; 32964 while ( ( handleObj = matched.handlers[ j++ ] ) && 32965 !event.isImmediatePropagationStopped() ) { 32966 32967 // Triggered event must either 1) have no namespace, or 2) have namespace(s) 32968 // a subset or equal to those in the bound event (both can have no namespace). 32969 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { 32970 32971 event.handleObj = handleObj; 32972 event.data = handleObj.data; 32973 32974 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 32975 handleObj.handler ).apply( matched.elem, args ); 32976 32977 if ( ret !== undefined ) { 32978 if ( ( event.result = ret ) === false ) { 32979 event.preventDefault(); 32980 event.stopPropagation(); 32981 } 32982 } 32983 } 32984 } 32985 } 32986 32987 // Call the postDispatch hook for the mapped type 32988 if ( special.postDispatch ) { 32989 special.postDispatch.call( this, event ); 32990 } 32991 32992 return event.result; 32993 }, 32994 32995 handlers: function( event, handlers ) { 32996 var i, matches, sel, handleObj, 32997 handlerQueue = [], 32998 delegateCount = handlers.delegateCount, 32999 cur = event.target; 33000 33001 // Support (at least): Chrome, IE9 33002 // Find delegate handlers 33003 // Black-hole SVG <use> instance trees (#13180) 33004 // 33005 // Support: Firefox<=42+ 33006 // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) 33007 if ( delegateCount && cur.nodeType && 33008 ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { 33009 33010 for ( ; cur !== this; cur = cur.parentNode || this ) { 33011 33012 // Don't check non-elements (#13208) 33013 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) 33014 if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) { 33015 matches = []; 33016 for ( i = 0; i < delegateCount; i++ ) { 33017 handleObj = handlers[ i ]; 33018 33019 // Don't conflict with Object.prototype properties (#13203) 33020 sel = handleObj.selector + " "; 33021 33022 if ( matches[ sel ] === undefined ) { 33023 matches[ sel ] = handleObj.needsContext ? 33024 jQuery( sel, this ).index( cur ) > -1 : 33025 jQuery.find( sel, this, null, [ cur ] ).length; 33026 } 33027 if ( matches[ sel ] ) { 33028 matches.push( handleObj ); 33029 } 33030 } 33031 if ( matches.length ) { 33032 handlerQueue.push( { elem: cur, handlers: matches } ); 33033 } 33034 } 33035 } 33036 } 33037 33038 // Add the remaining (directly-bound) handlers 33039 if ( delegateCount < handlers.length ) { 33040 handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } ); 33041 } 33042 33043 return handlerQueue; 33044 }, 33045 33046 // Includes some event props shared by KeyEvent and MouseEvent 33047 props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + 33048 "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), 33049 33050 fixHooks: {}, 33051 33052 keyHooks: { 33053 props: "char charCode key keyCode".split( " " ), 33054 filter: function( event, original ) { 33055 33056 // Add which for key events 33057 if ( event.which == null ) { 33058 event.which = original.charCode != null ? original.charCode : original.keyCode; 33059 } 33060 33061 return event; 33062 } 33063 }, 33064 33065 mouseHooks: { 33066 props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " + 33067 "screenX screenY toElement" ).split( " " ), 33068 filter: function( event, original ) { 33069 var eventDoc, doc, body, 33070 button = original.button; 33071 33072 // Calculate pageX/Y if missing and clientX/Y available 33073 if ( event.pageX == null && original.clientX != null ) { 33074 eventDoc = event.target.ownerDocument || document; 33075 doc = eventDoc.documentElement; 33076 body = eventDoc.body; 33077 33078 event.pageX = original.clientX + 33079 ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - 33080 ( doc && doc.clientLeft || body && body.clientLeft || 0 ); 33081 event.pageY = original.clientY + 33082 ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - 33083 ( doc && doc.clientTop || body && body.clientTop || 0 ); 33084 } 33085 33086 // Add which for click: 1 === left; 2 === middle; 3 === right 33087 // Note: button is not normalized, so don't use it 33088 if ( !event.which && button !== undefined ) { 33089 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); 33090 } 33091 33092 return event; 33093 } 33094 }, 33095 33096 fix: function( event ) { 33097 if ( event[ jQuery.expando ] ) { 33098 return event; 33099 } 33100 33101 // Create a writable copy of the event object and normalize some properties 33102 var i, prop, copy, 33103 type = event.type, 33104 originalEvent = event, 33105 fixHook = this.fixHooks[ type ]; 33106 33107 if ( !fixHook ) { 33108 this.fixHooks[ type ] = fixHook = 33109 rmouseEvent.test( type ) ? this.mouseHooks : 33110 rkeyEvent.test( type ) ? this.keyHooks : 33111 {}; 33112 } 33113 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; 33114 33115 event = new jQuery.Event( originalEvent ); 33116 33117 i = copy.length; 33118 while ( i-- ) { 33119 prop = copy[ i ]; 33120 event[ prop ] = originalEvent[ prop ]; 33121 } 33122 33123 // Support: Cordova 2.5 (WebKit) (#13255) 33124 // All events should have a target; Cordova deviceready doesn't 33125 if ( !event.target ) { 33126 event.target = document; 33127 } 33128 33129 // Support: Safari 6.0+, Chrome<28 33130 // Target should not be a text node (#504, #13143) 33131 if ( event.target.nodeType === 3 ) { 33132 event.target = event.target.parentNode; 33133 } 33134 33135 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; 33136 }, 33137 33138 special: { 33139 load: { 33140 33141 // Prevent triggered image.load events from bubbling to window.load 33142 noBubble: true 33143 }, 33144 focus: { 33145 33146 // Fire native event if possible so blur/focus sequence is correct 33147 trigger: function() { 33148 if ( this !== safeActiveElement() && this.focus ) { 33149 this.focus(); 33150 return false; 33151 } 33152 }, 33153 delegateType: "focusin" 33154 }, 33155 blur: { 33156 trigger: function() { 33157 if ( this === safeActiveElement() && this.blur ) { 33158 this.blur(); 33159 return false; 33160 } 33161 }, 33162 delegateType: "focusout" 33163 }, 33164 click: { 33165 33166 // For checkbox, fire native event so checked state will be right 33167 trigger: function() { 33168 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { 33169 this.click(); 33170 return false; 33171 } 33172 }, 33173 33174 // For cross-browser consistency, don't fire native .click() on links 33175 _default: function( event ) { 33176 return jQuery.nodeName( event.target, "a" ); 33177 } 33178 }, 33179 33180 beforeunload: { 33181 postDispatch: function( event ) { 33182 33183 // Support: Firefox 20+ 33184 // Firefox doesn't alert if the returnValue field is not set. 33185 if ( event.result !== undefined && event.originalEvent ) { 33186 event.originalEvent.returnValue = event.result; 33187 } 33188 } 33189 } 33190 } 33191 }; 33192 33193 jQuery.removeEvent = function( elem, type, handle ) { 33194 33195 // This "if" is needed for plain objects 33196 if ( elem.removeEventListener ) { 33197 elem.removeEventListener( type, handle ); 33198 } 33199 }; 33200 33201 jQuery.Event = function( src, props ) { 33202 33203 // Allow instantiation without the 'new' keyword 33204 if ( !( this instanceof jQuery.Event ) ) { 33205 return new jQuery.Event( src, props ); 33206 } 33207 33208 // Event object 33209 if ( src && src.type ) { 33210 this.originalEvent = src; 33211 this.type = src.type; 33212 33213 // Events bubbling up the document may have been marked as prevented 33214 // by a handler lower down the tree; reflect the correct value. 33215 this.isDefaultPrevented = src.defaultPrevented || 33216 src.defaultPrevented === undefined && 33217 33218 // Support: Android<4.0 33219 src.returnValue === false ? 33220 returnTrue : 33221 returnFalse; 33222 33223 // Event type 33224 } else { 33225 this.type = src; 33226 } 33227 33228 // Put explicitly provided properties onto the event object 33229 if ( props ) { 33230 jQuery.extend( this, props ); 33231 } 33232 33233 // Create a timestamp if incoming event doesn't have one 33234 this.timeStamp = src && src.timeStamp || jQuery.now(); 33235 33236 // Mark it as fixed 33237 this[ jQuery.expando ] = true; 33238 }; 33239 33240 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 33241 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 33242 jQuery.Event.prototype = { 33243 constructor: jQuery.Event, 33244 isDefaultPrevented: returnFalse, 33245 isPropagationStopped: returnFalse, 33246 isImmediatePropagationStopped: returnFalse, 33247 isSimulated: false, 33248 33249 preventDefault: function() { 33250 var e = this.originalEvent; 33251 33252 this.isDefaultPrevented = returnTrue; 33253 33254 if ( e && !this.isSimulated ) { 33255 e.preventDefault(); 33256 } 33257 }, 33258 stopPropagation: function() { 33259 var e = this.originalEvent; 33260 33261 this.isPropagationStopped = returnTrue; 33262 33263 if ( e && !this.isSimulated ) { 33264 e.stopPropagation(); 33265 } 33266 }, 33267 stopImmediatePropagation: function() { 33268 var e = this.originalEvent; 33269 33270 this.isImmediatePropagationStopped = returnTrue; 33271 33272 if ( e && !this.isSimulated ) { 33273 e.stopImmediatePropagation(); 33274 } 33275 33276 this.stopPropagation(); 33277 } 33278 }; 33279 33280 // Create mouseenter/leave events using mouseover/out and event-time checks 33281 // so that event delegation works in jQuery. 33282 // Do the same for pointerenter/pointerleave and pointerover/pointerout 33283 // 33284 // Support: Safari 7 only 33285 // Safari sends mouseenter too often; see: 33286 // https://code.google.com/p/chromium/issues/detail?id=470258 33287 // for the description of the bug (it existed in older Chrome versions as well). 33288 jQuery.each( { 33289 mouseenter: "mouseover", 33290 mouseleave: "mouseout", 33291 pointerenter: "pointerover", 33292 pointerleave: "pointerout" 33293 }, function( orig, fix ) { 33294 jQuery.event.special[ orig ] = { 33295 delegateType: fix, 33296 bindType: fix, 33297 33298 handle: function( event ) { 33299 var ret, 33300 target = this, 33301 related = event.relatedTarget, 33302 handleObj = event.handleObj; 33303 33304 // For mouseenter/leave call the handler if related is outside the target. 33305 // NB: No relatedTarget if the mouse left/entered the browser window 33306 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 33307 event.type = handleObj.origType; 33308 ret = handleObj.handler.apply( this, arguments ); 33309 event.type = fix; 33310 } 33311 return ret; 33312 } 33313 }; 33314 } ); 33315 33316 jQuery.fn.extend( { 33317 on: function( types, selector, data, fn ) { 33318 return on( this, types, selector, data, fn ); 33319 }, 33320 one: function( types, selector, data, fn ) { 33321 return on( this, types, selector, data, fn, 1 ); 33322 }, 33323 off: function( types, selector, fn ) { 33324 var handleObj, type; 33325 if ( types && types.preventDefault && types.handleObj ) { 33326 33327 // ( event ) dispatched jQuery.Event 33328 handleObj = types.handleObj; 33329 jQuery( types.delegateTarget ).off( 33330 handleObj.namespace ? 33331 handleObj.origType + "." + handleObj.namespace : 33332 handleObj.origType, 33333 handleObj.selector, 33334 handleObj.handler 33335 ); 33336 return this; 33337 } 33338 if ( typeof types === "object" ) { 33339 33340 // ( types-object [, selector] ) 33341 for ( type in types ) { 33342 this.off( type, selector, types[ type ] ); 33343 } 33344 return this; 33345 } 33346 if ( selector === false || typeof selector === "function" ) { 33347 33348 // ( types [, fn] ) 33349 fn = selector; 33350 selector = undefined; 33351 } 33352 if ( fn === false ) { 33353 fn = returnFalse; 33354 } 33355 return this.each( function() { 33356 jQuery.event.remove( this, types, fn, selector ); 33357 } ); 33358 } 33359 } ); 33360 33361 33362 var 33363 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, 33364 33365 // Support: IE 10-11, Edge 10240+ 33366 // In IE/Edge using regex groups here causes severe slowdowns. 33367 // See https://connect.microsoft.com/IE/feedback/details/1736512/ 33368 rnoInnerhtml = /<script|<style|<link/i, 33369 33370 // checked="checked" or checked 33371 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 33372 rscriptTypeMasked = /^true\/(.*)/, 33373 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; 33374 33375 // Manipulating tables requires a tbody 33376 function manipulationTarget( elem, content ) { 33377 return jQuery.nodeName( elem, "table" ) && 33378 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? 33379 33380 elem.getElementsByTagName( "tbody" )[ 0 ] || 33381 elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) : 33382 elem; 33383 } 33384 33385 // Replace/restore the type attribute of script elements for safe DOM manipulation 33386 function disableScript( elem ) { 33387 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; 33388 return elem; 33389 } 33390 function restoreScript( elem ) { 33391 var match = rscriptTypeMasked.exec( elem.type ); 33392 33393 if ( match ) { 33394 elem.type = match[ 1 ]; 33395 } else { 33396 elem.removeAttribute( "type" ); 33397 } 33398 33399 return elem; 33400 } 33401 33402 function cloneCopyEvent( src, dest ) { 33403 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; 33404 33405 if ( dest.nodeType !== 1 ) { 33406 return; 33407 } 33408 33409 // 1. Copy private data: events, handlers, etc. 33410 if ( dataPriv.hasData( src ) ) { 33411 pdataOld = dataPriv.access( src ); 33412 pdataCur = dataPriv.set( dest, pdataOld ); 33413 events = pdataOld.events; 33414 33415 if ( events ) { 33416 delete pdataCur.handle; 33417 pdataCur.events = {}; 33418 33419 for ( type in events ) { 33420 for ( i = 0, l = events[ type ].length; i < l; i++ ) { 33421 jQuery.event.add( dest, type, events[ type ][ i ] ); 33422 } 33423 } 33424 } 33425 } 33426 33427 // 2. Copy user data 33428 if ( dataUser.hasData( src ) ) { 33429 udataOld = dataUser.access( src ); 33430 udataCur = jQuery.extend( {}, udataOld ); 33431 33432 dataUser.set( dest, udataCur ); 33433 } 33434 } 33435 33436 // Fix IE bugs, see support tests 33437 function fixInput( src, dest ) { 33438 var nodeName = dest.nodeName.toLowerCase(); 33439 33440 // Fails to persist the checked state of a cloned checkbox or radio button. 33441 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 33442 dest.checked = src.checked; 33443 33444 // Fails to return the selected option to the default selected state when cloning options 33445 } else if ( nodeName === "input" || nodeName === "textarea" ) { 33446 dest.defaultValue = src.defaultValue; 33447 } 33448 } 33449 33450 function domManip( collection, args, callback, ignored ) { 33451 33452 // Flatten any nested arrays 33453 args = concat.apply( [], args ); 33454 33455 var fragment, first, scripts, hasScripts, node, doc, 33456 i = 0, 33457 l = collection.length, 33458 iNoClone = l - 1, 33459 value = args[ 0 ], 33460 isFunction = jQuery.isFunction( value ); 33461 33462 // We can't cloneNode fragments that contain checked, in WebKit 33463 if ( isFunction || 33464 ( l > 1 && typeof value === "string" && 33465 !support.checkClone && rchecked.test( value ) ) ) { 33466 return collection.each( function( index ) { 33467 var self = collection.eq( index ); 33468 if ( isFunction ) { 33469 args[ 0 ] = value.call( this, index, self.html() ); 33470 } 33471 domManip( self, args, callback, ignored ); 33472 } ); 33473 } 33474 33475 if ( l ) { 33476 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 33477 first = fragment.firstChild; 33478 33479 if ( fragment.childNodes.length === 1 ) { 33480 fragment = first; 33481 } 33482 33483 // Require either new content or an interest in ignored elements to invoke the callback 33484 if ( first || ignored ) { 33485 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 33486 hasScripts = scripts.length; 33487 33488 // Use the original fragment for the last item 33489 // instead of the first because it can end up 33490 // being emptied incorrectly in certain situations (#8070). 33491 for ( ; i < l; i++ ) { 33492 node = fragment; 33493 33494 if ( i !== iNoClone ) { 33495 node = jQuery.clone( node, true, true ); 33496 33497 // Keep references to cloned scripts for later restoration 33498 if ( hasScripts ) { 33499 33500 // Support: Android<4.1, PhantomJS<2 33501 // push.apply(_, arraylike) throws on ancient WebKit 33502 jQuery.merge( scripts, getAll( node, "script" ) ); 33503 } 33504 } 33505 33506 callback.call( collection[ i ], node, i ); 33507 } 33508 33509 if ( hasScripts ) { 33510 doc = scripts[ scripts.length - 1 ].ownerDocument; 33511 33512 // Reenable scripts 33513 jQuery.map( scripts, restoreScript ); 33514 33515 // Evaluate executable scripts on first document insertion 33516 for ( i = 0; i < hasScripts; i++ ) { 33517 node = scripts[ i ]; 33518 if ( rscriptType.test( node.type || "" ) && 33519 !dataPriv.access( node, "globalEval" ) && 33520 jQuery.contains( doc, node ) ) { 33521 33522 if ( node.src ) { 33523 33524 // Optional AJAX dependency, but won't run scripts if not present 33525 if ( jQuery._evalUrl ) { 33526 jQuery._evalUrl( node.src ); 33527 } 33528 } else { 33529 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); 33530 } 33531 } 33532 } 33533 } 33534 } 33535 } 33536 33537 return collection; 33538 } 33539 33540 function remove( elem, selector, keepData ) { 33541 var node, 33542 nodes = selector ? jQuery.filter( selector, elem ) : elem, 33543 i = 0; 33544 33545 for ( ; ( node = nodes[ i ] ) != null; i++ ) { 33546 if ( !keepData && node.nodeType === 1 ) { 33547 jQuery.cleanData( getAll( node ) ); 33548 } 33549 33550 if ( node.parentNode ) { 33551 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { 33552 setGlobalEval( getAll( node, "script" ) ); 33553 } 33554 node.parentNode.removeChild( node ); 33555 } 33556 } 33557 33558 return elem; 33559 } 33560 33561 jQuery.extend( { 33562 htmlPrefilter: function( html ) { 33563 return html.replace( rxhtmlTag, "<$1></$2>" ); 33564 }, 33565 33566 clone: function( elem, dataAndEvents, deepDataAndEvents ) { 33567 var i, l, srcElements, destElements, 33568 clone = elem.cloneNode( true ), 33569 inPage = jQuery.contains( elem.ownerDocument, elem ); 33570 33571 // Fix IE cloning issues 33572 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && 33573 !jQuery.isXMLDoc( elem ) ) { 33574 33575 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 33576 destElements = getAll( clone ); 33577 srcElements = getAll( elem ); 33578 33579 for ( i = 0, l = srcElements.length; i < l; i++ ) { 33580 fixInput( srcElements[ i ], destElements[ i ] ); 33581 } 33582 } 33583 33584 // Copy the events from the original to the clone 33585 if ( dataAndEvents ) { 33586 if ( deepDataAndEvents ) { 33587 srcElements = srcElements || getAll( elem ); 33588 destElements = destElements || getAll( clone ); 33589 33590 for ( i = 0, l = srcElements.length; i < l; i++ ) { 33591 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); 33592 } 33593 } else { 33594 cloneCopyEvent( elem, clone ); 33595 } 33596 } 33597 33598 // Preserve script evaluation history 33599 destElements = getAll( clone, "script" ); 33600 if ( destElements.length > 0 ) { 33601 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 33602 } 33603 33604 // Return the cloned set 33605 return clone; 33606 }, 33607 33608 cleanData: function( elems ) { 33609 var data, elem, type, 33610 special = jQuery.event.special, 33611 i = 0; 33612 33613 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { 33614 if ( acceptData( elem ) ) { 33615 if ( ( data = elem[ dataPriv.expando ] ) ) { 33616 if ( data.events ) { 33617 for ( type in data.events ) { 33618 if ( special[ type ] ) { 33619 jQuery.event.remove( elem, type ); 33620 33621 // This is a shortcut to avoid jQuery.event.remove's overhead 33622 } else { 33623 jQuery.removeEvent( elem, type, data.handle ); 33624 } 33625 } 33626 } 33627 33628 // Support: Chrome <= 35-45+ 33629 // Assign undefined instead of using delete, see Data#remove 33630 elem[ dataPriv.expando ] = undefined; 33631 } 33632 if ( elem[ dataUser.expando ] ) { 33633 33634 // Support: Chrome <= 35-45+ 33635 // Assign undefined instead of using delete, see Data#remove 33636 elem[ dataUser.expando ] = undefined; 33637 } 33638 } 33639 } 33640 } 33641 } ); 33642 33643 jQuery.fn.extend( { 33644 33645 // Keep domManip exposed until 3.0 (gh-2225) 33646 domManip: domManip, 33647 33648 detach: function( selector ) { 33649 return remove( this, selector, true ); 33650 }, 33651 33652 remove: function( selector ) { 33653 return remove( this, selector ); 33654 }, 33655 33656 text: function( value ) { 33657 return access( this, function( value ) { 33658 return value === undefined ? 33659 jQuery.text( this ) : 33660 this.empty().each( function() { 33661 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 33662 this.textContent = value; 33663 } 33664 } ); 33665 }, null, value, arguments.length ); 33666 }, 33667 33668 append: function() { 33669 return domManip( this, arguments, function( elem ) { 33670 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 33671 var target = manipulationTarget( this, elem ); 33672 target.appendChild( elem ); 33673 } 33674 } ); 33675 }, 33676 33677 prepend: function() { 33678 return domManip( this, arguments, function( elem ) { 33679 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 33680 var target = manipulationTarget( this, elem ); 33681 target.insertBefore( elem, target.firstChild ); 33682 } 33683 } ); 33684 }, 33685 33686 before: function() { 33687 return domManip( this, arguments, function( elem ) { 33688 if ( this.parentNode ) { 33689 this.parentNode.insertBefore( elem, this ); 33690 } 33691 } ); 33692 }, 33693 33694 after: function() { 33695 return domManip( this, arguments, function( elem ) { 33696 if ( this.parentNode ) { 33697 this.parentNode.insertBefore( elem, this.nextSibling ); 33698 } 33699 } ); 33700 }, 33701 33702 empty: function() { 33703 var elem, 33704 i = 0; 33705 33706 for ( ; ( elem = this[ i ] ) != null; i++ ) { 33707 if ( elem.nodeType === 1 ) { 33708 33709 // Prevent memory leaks 33710 jQuery.cleanData( getAll( elem, false ) ); 33711 33712 // Remove any remaining nodes 33713 elem.textContent = ""; 33714 } 33715 } 33716 33717 return this; 33718 }, 33719 33720 clone: function( dataAndEvents, deepDataAndEvents ) { 33721 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 33722 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 33723 33724 return this.map( function() { 33725 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 33726 } ); 33727 }, 33728 33729 html: function( value ) { 33730 return access( this, function( value ) { 33731 var elem = this[ 0 ] || {}, 33732 i = 0, 33733 l = this.length; 33734 33735 if ( value === undefined && elem.nodeType === 1 ) { 33736 return elem.innerHTML; 33737 } 33738 33739 // See if we can take a shortcut and just use innerHTML 33740 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 33741 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 33742 33743 value = jQuery.htmlPrefilter( value ); 33744 33745 try { 33746 for ( ; i < l; i++ ) { 33747 elem = this[ i ] || {}; 33748 33749 // Remove element nodes and prevent memory leaks 33750 if ( elem.nodeType === 1 ) { 33751 jQuery.cleanData( getAll( elem, false ) ); 33752 elem.innerHTML = value; 33753 } 33754 } 33755 33756 elem = 0; 33757 33758 // If using innerHTML throws an exception, use the fallback method 33759 } catch ( e ) {} 33760 } 33761 33762 if ( elem ) { 33763 this.empty().append( value ); 33764 } 33765 }, null, value, arguments.length ); 33766 }, 33767 33768 replaceWith: function() { 33769 var ignored = []; 33770 33771 // Make the changes, replacing each non-ignored context element with the new content 33772 return domManip( this, arguments, function( elem ) { 33773 var parent = this.parentNode; 33774 33775 if ( jQuery.inArray( this, ignored ) < 0 ) { 33776 jQuery.cleanData( getAll( this ) ); 33777 if ( parent ) { 33778 parent.replaceChild( elem, this ); 33779 } 33780 } 33781 33782 // Force callback invocation 33783 }, ignored ); 33784 } 33785 } ); 33786 33787 jQuery.each( { 33788 appendTo: "append", 33789 prependTo: "prepend", 33790 insertBefore: "before", 33791 insertAfter: "after", 33792 replaceAll: "replaceWith" 33793 }, function( name, original ) { 33794 jQuery.fn[ name ] = function( selector ) { 33795 var elems, 33796 ret = [], 33797 insert = jQuery( selector ), 33798 last = insert.length - 1, 33799 i = 0; 33800 33801 for ( ; i <= last; i++ ) { 33802 elems = i === last ? this : this.clone( true ); 33803 jQuery( insert[ i ] )[ original ]( elems ); 33804 33805 // Support: QtWebKit 33806 // .get() because push.apply(_, arraylike) throws 33807 push.apply( ret, elems.get() ); 33808 } 33809 33810 return this.pushStack( ret ); 33811 }; 33812 } ); 33813 33814 33815 var iframe, 33816 elemdisplay = { 33817 33818 // Support: Firefox 33819 // We have to pre-define these values for FF (#10227) 33820 HTML: "block", 33821 BODY: "block" 33822 }; 33823 33824 /** 33825 * Retrieve the actual display of a element 33826 * @param {String} name nodeName of the element 33827 * @param {Object} doc Document object 33828 */ 33829 33830 // Called only from within defaultDisplay 33831 function actualDisplay( name, doc ) { 33832 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), 33833 33834 display = jQuery.css( elem[ 0 ], "display" ); 33835 33836 // We don't have any data stored on the element, 33837 // so use "detach" method as fast way to get rid of the element 33838 elem.detach(); 33839 33840 return display; 33841 } 33842 33843 /** 33844 * Try to determine the default display value of an element 33845 * @param {String} nodeName 33846 */ 33847 function defaultDisplay( nodeName ) { 33848 var doc = document, 33849 display = elemdisplay[ nodeName ]; 33850 33851 if ( !display ) { 33852 display = actualDisplay( nodeName, doc ); 33853 33854 // If the simple way fails, read from inside an iframe 33855 if ( display === "none" || !display ) { 33856 33857 // Use the already-created iframe if possible 33858 iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) ) 33859 .appendTo( doc.documentElement ); 33860 33861 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse 33862 doc = iframe[ 0 ].contentDocument; 33863 33864 // Support: IE 33865 doc.write(); 33866 doc.close(); 33867 33868 display = actualDisplay( nodeName, doc ); 33869 iframe.detach(); 33870 } 33871 33872 // Store the correct default display 33873 elemdisplay[ nodeName ] = display; 33874 } 33875 33876 return display; 33877 } 33878 var rmargin = ( /^margin/ ); 33879 33880 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 33881 33882 var getStyles = function( elem ) { 33883 33884 // Support: IE<=11+, Firefox<=30+ (#15098, #14150) 33885 // IE throws on elements created in popups 33886 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 33887 var view = elem.ownerDocument.defaultView; 33888 33889 if ( !view || !view.opener ) { 33890 view = window; 33891 } 33892 33893 return view.getComputedStyle( elem ); 33894 }; 33895 33896 var swap = function( elem, options, callback, args ) { 33897 var ret, name, 33898 old = {}; 33899 33900 // Remember the old values, and insert the new ones 33901 for ( name in options ) { 33902 old[ name ] = elem.style[ name ]; 33903 elem.style[ name ] = options[ name ]; 33904 } 33905 33906 ret = callback.apply( elem, args || [] ); 33907 33908 // Revert the old values 33909 for ( name in options ) { 33910 elem.style[ name ] = old[ name ]; 33911 } 33912 33913 return ret; 33914 }; 33915 33916 33917 var documentElement = document.documentElement; 33918 33919 33920 33921 ( function() { 33922 var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, 33923 container = document.createElement( "div" ), 33924 div = document.createElement( "div" ); 33925 33926 // Finish early in limited (non-browser) environments 33927 if ( !div.style ) { 33928 return; 33929 } 33930 33931 // Support: IE9-11+ 33932 // Style of cloned element affects source element cloned (#8908) 33933 div.style.backgroundClip = "content-box"; 33934 div.cloneNode( true ).style.backgroundClip = ""; 33935 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 33936 33937 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + 33938 "padding:0;margin-top:1px;position:absolute"; 33939 container.appendChild( div ); 33940 33941 // Executing both pixelPosition & boxSizingReliable tests require only one layout 33942 // so they're executed at the same time to save the second computation. 33943 function computeStyleTests() { 33944 div.style.cssText = 33945 33946 // Support: Firefox<29, Android 2.3 33947 // Vendor-prefix box-sizing 33948 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" + 33949 "position:relative;display:block;" + 33950 "margin:auto;border:1px;padding:1px;" + 33951 "top:1%;width:50%"; 33952 div.innerHTML = ""; 33953 documentElement.appendChild( container ); 33954 33955 var divStyle = window.getComputedStyle( div ); 33956 pixelPositionVal = divStyle.top !== "1%"; 33957 reliableMarginLeftVal = divStyle.marginLeft === "2px"; 33958 boxSizingReliableVal = divStyle.width === "4px"; 33959 33960 // Support: Android 4.0 - 4.3 only 33961 // Some styles come back with percentage values, even though they shouldn't 33962 div.style.marginRight = "50%"; 33963 pixelMarginRightVal = divStyle.marginRight === "4px"; 33964 33965 documentElement.removeChild( container ); 33966 } 33967 33968 jQuery.extend( support, { 33969 pixelPosition: function() { 33970 33971 // This test is executed only once but we still do memoizing 33972 // since we can use the boxSizingReliable pre-computing. 33973 // No need to check if the test was already performed, though. 33974 computeStyleTests(); 33975 return pixelPositionVal; 33976 }, 33977 boxSizingReliable: function() { 33978 if ( boxSizingReliableVal == null ) { 33979 computeStyleTests(); 33980 } 33981 return boxSizingReliableVal; 33982 }, 33983 pixelMarginRight: function() { 33984 33985 // Support: Android 4.0-4.3 33986 // We're checking for boxSizingReliableVal here instead of pixelMarginRightVal 33987 // since that compresses better and they're computed together anyway. 33988 if ( boxSizingReliableVal == null ) { 33989 computeStyleTests(); 33990 } 33991 return pixelMarginRightVal; 33992 }, 33993 reliableMarginLeft: function() { 33994 33995 // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37 33996 if ( boxSizingReliableVal == null ) { 33997 computeStyleTests(); 33998 } 33999 return reliableMarginLeftVal; 34000 }, 34001 reliableMarginRight: function() { 34002 34003 // Support: Android 2.3 34004 // Check if div with explicit width and no margin-right incorrectly 34005 // gets computed margin-right based on width of container. (#3333) 34006 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right 34007 // This support function is only executed once so no memoizing is needed. 34008 var ret, 34009 marginDiv = div.appendChild( document.createElement( "div" ) ); 34010 34011 // Reset CSS: box-sizing; display; margin; border; padding 34012 marginDiv.style.cssText = div.style.cssText = 34013 34014 // Support: Android 2.3 34015 // Vendor-prefix box-sizing 34016 "-webkit-box-sizing:content-box;box-sizing:content-box;" + 34017 "display:block;margin:0;border:0;padding:0"; 34018 marginDiv.style.marginRight = marginDiv.style.width = "0"; 34019 div.style.width = "1px"; 34020 documentElement.appendChild( container ); 34021 34022 ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight ); 34023 34024 documentElement.removeChild( container ); 34025 div.removeChild( marginDiv ); 34026 34027 return ret; 34028 } 34029 } ); 34030 } )(); 34031 34032 34033 function curCSS( elem, name, computed ) { 34034 var width, minWidth, maxWidth, ret, 34035 style = elem.style; 34036 34037 computed = computed || getStyles( elem ); 34038 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; 34039 34040 // Support: Opera 12.1x only 34041 // Fall back to style even without computed 34042 // computed is undefined for elems on document fragments 34043 if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) { 34044 ret = jQuery.style( elem, name ); 34045 } 34046 34047 // Support: IE9 34048 // getPropertyValue is only needed for .css('filter') (#12537) 34049 if ( computed ) { 34050 34051 // A tribute to the "awesome hack by Dean Edwards" 34052 // Android Browser returns percentage for some values, 34053 // but width seems to be reliably pixels. 34054 // This is against the CSSOM draft spec: 34055 // http://dev.w3.org/csswg/cssom/#resolved-values 34056 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { 34057 34058 // Remember the original values 34059 width = style.width; 34060 minWidth = style.minWidth; 34061 maxWidth = style.maxWidth; 34062 34063 // Put in the new values to get a computed value out 34064 style.minWidth = style.maxWidth = style.width = ret; 34065 ret = computed.width; 34066 34067 // Revert the changed values 34068 style.width = width; 34069 style.minWidth = minWidth; 34070 style.maxWidth = maxWidth; 34071 } 34072 } 34073 34074 return ret !== undefined ? 34075 34076 // Support: IE9-11+ 34077 // IE returns zIndex value as an integer. 34078 ret + "" : 34079 ret; 34080 } 34081 34082 34083 function addGetHookIf( conditionFn, hookFn ) { 34084 34085 // Define the hook, we'll check on the first run if it's really needed. 34086 return { 34087 get: function() { 34088 if ( conditionFn() ) { 34089 34090 // Hook not needed (or it's not possible to use it due 34091 // to missing dependency), remove it. 34092 delete this.get; 34093 return; 34094 } 34095 34096 // Hook needed; redefine it so that the support test is not executed again. 34097 return ( this.get = hookFn ).apply( this, arguments ); 34098 } 34099 }; 34100 } 34101 34102 34103 var 34104 34105 // Swappable if display is none or starts with table 34106 // except "table", "table-cell", or "table-caption" 34107 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display 34108 rdisplayswap = /^(none|table(?!-c[ea]).+)/, 34109 34110 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 34111 cssNormalTransform = { 34112 letterSpacing: "0", 34113 fontWeight: "400" 34114 }, 34115 34116 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], 34117 emptyStyle = document.createElement( "div" ).style; 34118 34119 // Return a css property mapped to a potentially vendor prefixed property 34120 function vendorPropName( name ) { 34121 34122 // Shortcut for names that are not vendor prefixed 34123 if ( name in emptyStyle ) { 34124 return name; 34125 } 34126 34127 // Check for vendor prefixed names 34128 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 34129 i = cssPrefixes.length; 34130 34131 while ( i-- ) { 34132 name = cssPrefixes[ i ] + capName; 34133 if ( name in emptyStyle ) { 34134 return name; 34135 } 34136 } 34137 } 34138 34139 function setPositiveNumber( elem, value, subtract ) { 34140 34141 // Any relative (+/-) values have already been 34142 // normalized at this point 34143 var matches = rcssNum.exec( value ); 34144 return matches ? 34145 34146 // Guard against undefined "subtract", e.g., when used as in cssHooks 34147 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : 34148 value; 34149 } 34150 34151 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { 34152 var i = extra === ( isBorderBox ? "border" : "content" ) ? 34153 34154 // If we already have the right measurement, avoid augmentation 34155 4 : 34156 34157 // Otherwise initialize for horizontal or vertical properties 34158 name === "width" ? 1 : 0, 34159 34160 val = 0; 34161 34162 for ( ; i < 4; i += 2 ) { 34163 34164 // Both box models exclude margin, so add it if we want it 34165 if ( extra === "margin" ) { 34166 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); 34167 } 34168 34169 if ( isBorderBox ) { 34170 34171 // border-box includes padding, so remove it if we want content 34172 if ( extra === "content" ) { 34173 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 34174 } 34175 34176 // At this point, extra isn't border nor margin, so remove border 34177 if ( extra !== "margin" ) { 34178 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 34179 } 34180 } else { 34181 34182 // At this point, extra isn't content, so add padding 34183 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 34184 34185 // At this point, extra isn't content nor padding, so add border 34186 if ( extra !== "padding" ) { 34187 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 34188 } 34189 } 34190 } 34191 34192 return val; 34193 } 34194 34195 function getWidthOrHeight( elem, name, extra ) { 34196 34197 // Start with offset property, which is equivalent to the border-box value 34198 var valueIsBorderBox = true, 34199 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, 34200 styles = getStyles( elem ), 34201 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; 34202 34203 // Some non-html elements return undefined for offsetWidth, so check for null/undefined 34204 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 34205 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 34206 if ( val <= 0 || val == null ) { 34207 34208 // Fall back to computed then uncomputed css if necessary 34209 val = curCSS( elem, name, styles ); 34210 if ( val < 0 || val == null ) { 34211 val = elem.style[ name ]; 34212 } 34213 34214 // Computed unit is not pixels. Stop here and return. 34215 if ( rnumnonpx.test( val ) ) { 34216 return val; 34217 } 34218 34219 // Check for style in case a browser which returns unreliable values 34220 // for getComputedStyle silently falls back to the reliable elem.style 34221 valueIsBorderBox = isBorderBox && 34222 ( support.boxSizingReliable() || val === elem.style[ name ] ); 34223 34224 // Normalize "", auto, and prepare for extra 34225 val = parseFloat( val ) || 0; 34226 } 34227 34228 // Use the active box-sizing model to add/subtract irrelevant styles 34229 return ( val + 34230 augmentWidthOrHeight( 34231 elem, 34232 name, 34233 extra || ( isBorderBox ? "border" : "content" ), 34234 valueIsBorderBox, 34235 styles 34236 ) 34237 ) + "px"; 34238 } 34239 34240 function showHide( elements, show ) { 34241 var display, elem, hidden, 34242 values = [], 34243 index = 0, 34244 length = elements.length; 34245 34246 for ( ; index < length; index++ ) { 34247 elem = elements[ index ]; 34248 if ( !elem.style ) { 34249 continue; 34250 } 34251 34252 values[ index ] = dataPriv.get( elem, "olddisplay" ); 34253 display = elem.style.display; 34254 if ( show ) { 34255 34256 // Reset the inline display of this element to learn if it is 34257 // being hidden by cascaded rules or not 34258 if ( !values[ index ] && display === "none" ) { 34259 elem.style.display = ""; 34260 } 34261 34262 // Set elements which have been overridden with display: none 34263 // in a stylesheet to whatever the default browser style is 34264 // for such an element 34265 if ( elem.style.display === "" && isHidden( elem ) ) { 34266 values[ index ] = dataPriv.access( 34267 elem, 34268 "olddisplay", 34269 defaultDisplay( elem.nodeName ) 34270 ); 34271 } 34272 } else { 34273 hidden = isHidden( elem ); 34274 34275 if ( display !== "none" || !hidden ) { 34276 dataPriv.set( 34277 elem, 34278 "olddisplay", 34279 hidden ? display : jQuery.css( elem, "display" ) 34280 ); 34281 } 34282 } 34283 } 34284 34285 // Set the display of most of the elements in a second loop 34286 // to avoid the constant reflow 34287 for ( index = 0; index < length; index++ ) { 34288 elem = elements[ index ]; 34289 if ( !elem.style ) { 34290 continue; 34291 } 34292 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { 34293 elem.style.display = show ? values[ index ] || "" : "none"; 34294 } 34295 } 34296 34297 return elements; 34298 } 34299 34300 jQuery.extend( { 34301 34302 // Add in style property hooks for overriding the default 34303 // behavior of getting and setting a style property 34304 cssHooks: { 34305 opacity: { 34306 get: function( elem, computed ) { 34307 if ( computed ) { 34308 34309 // We should always get a number back from opacity 34310 var ret = curCSS( elem, "opacity" ); 34311 return ret === "" ? "1" : ret; 34312 } 34313 } 34314 } 34315 }, 34316 34317 // Don't automatically add "px" to these possibly-unitless properties 34318 cssNumber: { 34319 "animationIterationCount": true, 34320 "columnCount": true, 34321 "fillOpacity": true, 34322 "flexGrow": true, 34323 "flexShrink": true, 34324 "fontWeight": true, 34325 "lineHeight": true, 34326 "opacity": true, 34327 "order": true, 34328 "orphans": true, 34329 "widows": true, 34330 "zIndex": true, 34331 "zoom": true 34332 }, 34333 34334 // Add in properties whose names you wish to fix before 34335 // setting or getting the value 34336 cssProps: { 34337 "float": "cssFloat" 34338 }, 34339 34340 // Get and set the style property on a DOM Node 34341 style: function( elem, name, value, extra ) { 34342 34343 // Don't set styles on text and comment nodes 34344 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 34345 return; 34346 } 34347 34348 // Make sure that we're working with the right name 34349 var ret, type, hooks, 34350 origName = jQuery.camelCase( name ), 34351 style = elem.style; 34352 34353 name = jQuery.cssProps[ origName ] || 34354 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); 34355 34356 // Gets hook for the prefixed version, then unprefixed version 34357 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 34358 34359 // Check if we're setting a value 34360 if ( value !== undefined ) { 34361 type = typeof value; 34362 34363 // Convert "+=" or "-=" to relative numbers (#7345) 34364 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 34365 value = adjustCSS( elem, name, ret ); 34366 34367 // Fixes bug #9237 34368 type = "number"; 34369 } 34370 34371 // Make sure that null and NaN values aren't set (#7116) 34372 if ( value == null || value !== value ) { 34373 return; 34374 } 34375 34376 // If a number was passed in, add the unit (except for certain CSS properties) 34377 if ( type === "number" ) { 34378 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 34379 } 34380 34381 // Support: IE9-11+ 34382 // background-* props affect original clone's values 34383 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 34384 style[ name ] = "inherit"; 34385 } 34386 34387 // If a hook was provided, use that value, otherwise just set the specified value 34388 if ( !hooks || !( "set" in hooks ) || 34389 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 34390 34391 style[ name ] = value; 34392 } 34393 34394 } else { 34395 34396 // If a hook was provided get the non-computed value from there 34397 if ( hooks && "get" in hooks && 34398 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 34399 34400 return ret; 34401 } 34402 34403 // Otherwise just get the value from the style object 34404 return style[ name ]; 34405 } 34406 }, 34407 34408 css: function( elem, name, extra, styles ) { 34409 var val, num, hooks, 34410 origName = jQuery.camelCase( name ); 34411 34412 // Make sure that we're working with the right name 34413 name = jQuery.cssProps[ origName ] || 34414 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); 34415 34416 // Try prefixed name followed by the unprefixed name 34417 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 34418 34419 // If a hook was provided get the computed value from there 34420 if ( hooks && "get" in hooks ) { 34421 val = hooks.get( elem, true, extra ); 34422 } 34423 34424 // Otherwise, if a way to get the computed value exists, use that 34425 if ( val === undefined ) { 34426 val = curCSS( elem, name, styles ); 34427 } 34428 34429 // Convert "normal" to computed value 34430 if ( val === "normal" && name in cssNormalTransform ) { 34431 val = cssNormalTransform[ name ]; 34432 } 34433 34434 // Make numeric if forced or a qualifier was provided and val looks numeric 34435 if ( extra === "" || extra ) { 34436 num = parseFloat( val ); 34437 return extra === true || isFinite( num ) ? num || 0 : val; 34438 } 34439 return val; 34440 } 34441 } ); 34442 34443 jQuery.each( [ "height", "width" ], function( i, name ) { 34444 jQuery.cssHooks[ name ] = { 34445 get: function( elem, computed, extra ) { 34446 if ( computed ) { 34447 34448 // Certain elements can have dimension info if we invisibly show them 34449 // but it must have a current display style that would benefit 34450 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 34451 elem.offsetWidth === 0 ? 34452 swap( elem, cssShow, function() { 34453 return getWidthOrHeight( elem, name, extra ); 34454 } ) : 34455 getWidthOrHeight( elem, name, extra ); 34456 } 34457 }, 34458 34459 set: function( elem, value, extra ) { 34460 var matches, 34461 styles = extra && getStyles( elem ), 34462 subtract = extra && augmentWidthOrHeight( 34463 elem, 34464 name, 34465 extra, 34466 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 34467 styles 34468 ); 34469 34470 // Convert to pixels if value adjustment is needed 34471 if ( subtract && ( matches = rcssNum.exec( value ) ) && 34472 ( matches[ 3 ] || "px" ) !== "px" ) { 34473 34474 elem.style[ name ] = value; 34475 value = jQuery.css( elem, name ); 34476 } 34477 34478 return setPositiveNumber( elem, value, subtract ); 34479 } 34480 }; 34481 } ); 34482 34483 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 34484 function( elem, computed ) { 34485 if ( computed ) { 34486 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || 34487 elem.getBoundingClientRect().left - 34488 swap( elem, { marginLeft: 0 }, function() { 34489 return elem.getBoundingClientRect().left; 34490 } ) 34491 ) + "px"; 34492 } 34493 } 34494 ); 34495 34496 // Support: Android 2.3 34497 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, 34498 function( elem, computed ) { 34499 if ( computed ) { 34500 return swap( elem, { "display": "inline-block" }, 34501 curCSS, [ elem, "marginRight" ] ); 34502 } 34503 } 34504 ); 34505 34506 // These hooks are used by animate to expand properties 34507 jQuery.each( { 34508 margin: "", 34509 padding: "", 34510 border: "Width" 34511 }, function( prefix, suffix ) { 34512 jQuery.cssHooks[ prefix + suffix ] = { 34513 expand: function( value ) { 34514 var i = 0, 34515 expanded = {}, 34516 34517 // Assumes a single number if not a string 34518 parts = typeof value === "string" ? value.split( " " ) : [ value ]; 34519 34520 for ( ; i < 4; i++ ) { 34521 expanded[ prefix + cssExpand[ i ] + suffix ] = 34522 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 34523 } 34524 34525 return expanded; 34526 } 34527 }; 34528 34529 if ( !rmargin.test( prefix ) ) { 34530 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 34531 } 34532 } ); 34533 34534 jQuery.fn.extend( { 34535 css: function( name, value ) { 34536 return access( this, function( elem, name, value ) { 34537 var styles, len, 34538 map = {}, 34539 i = 0; 34540 34541 if ( jQuery.isArray( name ) ) { 34542 styles = getStyles( elem ); 34543 len = name.length; 34544 34545 for ( ; i < len; i++ ) { 34546 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 34547 } 34548 34549 return map; 34550 } 34551 34552 return value !== undefined ? 34553 jQuery.style( elem, name, value ) : 34554 jQuery.css( elem, name ); 34555 }, name, value, arguments.length > 1 ); 34556 }, 34557 show: function() { 34558 return showHide( this, true ); 34559 }, 34560 hide: function() { 34561 return showHide( this ); 34562 }, 34563 toggle: function( state ) { 34564 if ( typeof state === "boolean" ) { 34565 return state ? this.show() : this.hide(); 34566 } 34567 34568 return this.each( function() { 34569 if ( isHidden( this ) ) { 34570 jQuery( this ).show(); 34571 } else { 34572 jQuery( this ).hide(); 34573 } 34574 } ); 34575 } 34576 } ); 34577 34578 34579 function Tween( elem, options, prop, end, easing ) { 34580 return new Tween.prototype.init( elem, options, prop, end, easing ); 34581 } 34582 jQuery.Tween = Tween; 34583 34584 Tween.prototype = { 34585 constructor: Tween, 34586 init: function( elem, options, prop, end, easing, unit ) { 34587 this.elem = elem; 34588 this.prop = prop; 34589 this.easing = easing || jQuery.easing._default; 34590 this.options = options; 34591 this.start = this.now = this.cur(); 34592 this.end = end; 34593 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 34594 }, 34595 cur: function() { 34596 var hooks = Tween.propHooks[ this.prop ]; 34597 34598 return hooks && hooks.get ? 34599 hooks.get( this ) : 34600 Tween.propHooks._default.get( this ); 34601 }, 34602 run: function( percent ) { 34603 var eased, 34604 hooks = Tween.propHooks[ this.prop ]; 34605 34606 if ( this.options.duration ) { 34607 this.pos = eased = jQuery.easing[ this.easing ]( 34608 percent, this.options.duration * percent, 0, 1, this.options.duration 34609 ); 34610 } else { 34611 this.pos = eased = percent; 34612 } 34613 this.now = ( this.end - this.start ) * eased + this.start; 34614 34615 if ( this.options.step ) { 34616 this.options.step.call( this.elem, this.now, this ); 34617 } 34618 34619 if ( hooks && hooks.set ) { 34620 hooks.set( this ); 34621 } else { 34622 Tween.propHooks._default.set( this ); 34623 } 34624 return this; 34625 } 34626 }; 34627 34628 Tween.prototype.init.prototype = Tween.prototype; 34629 34630 Tween.propHooks = { 34631 _default: { 34632 get: function( tween ) { 34633 var result; 34634 34635 // Use a property on the element directly when it is not a DOM element, 34636 // or when there is no matching style property that exists. 34637 if ( tween.elem.nodeType !== 1 || 34638 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 34639 return tween.elem[ tween.prop ]; 34640 } 34641 34642 // Passing an empty string as a 3rd parameter to .css will automatically 34643 // attempt a parseFloat and fallback to a string if the parse fails. 34644 // Simple values such as "10px" are parsed to Float; 34645 // complex values such as "rotate(1rad)" are returned as-is. 34646 result = jQuery.css( tween.elem, tween.prop, "" ); 34647 34648 // Empty strings, null, undefined and "auto" are converted to 0. 34649 return !result || result === "auto" ? 0 : result; 34650 }, 34651 set: function( tween ) { 34652 34653 // Use step hook for back compat. 34654 // Use cssHook if its there. 34655 // Use .style if available and use plain properties where available. 34656 if ( jQuery.fx.step[ tween.prop ] ) { 34657 jQuery.fx.step[ tween.prop ]( tween ); 34658 } else if ( tween.elem.nodeType === 1 && 34659 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || 34660 jQuery.cssHooks[ tween.prop ] ) ) { 34661 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 34662 } else { 34663 tween.elem[ tween.prop ] = tween.now; 34664 } 34665 } 34666 } 34667 }; 34668 34669 // Support: IE9 34670 // Panic based approach to setting things on disconnected nodes 34671 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 34672 set: function( tween ) { 34673 if ( tween.elem.nodeType && tween.elem.parentNode ) { 34674 tween.elem[ tween.prop ] = tween.now; 34675 } 34676 } 34677 }; 34678 34679 jQuery.easing = { 34680 linear: function( p ) { 34681 return p; 34682 }, 34683 swing: function( p ) { 34684 return 0.5 - Math.cos( p * Math.PI ) / 2; 34685 }, 34686 _default: "swing" 34687 }; 34688 34689 jQuery.fx = Tween.prototype.init; 34690 34691 // Back Compat <1.8 extension point 34692 jQuery.fx.step = {}; 34693 34694 34695 34696 34697 var 34698 fxNow, timerId, 34699 rfxtypes = /^(?:toggle|show|hide)$/, 34700 rrun = /queueHooks$/; 34701 34702 // Animations created synchronously will run synchronously 34703 function createFxNow() { 34704 window.setTimeout( function() { 34705 fxNow = undefined; 34706 } ); 34707 return ( fxNow = jQuery.now() ); 34708 } 34709 34710 // Generate parameters to create a standard animation 34711 function genFx( type, includeWidth ) { 34712 var which, 34713 i = 0, 34714 attrs = { height: type }; 34715 34716 // If we include width, step value is 1 to do all cssExpand values, 34717 // otherwise step value is 2 to skip over Left and Right 34718 includeWidth = includeWidth ? 1 : 0; 34719 for ( ; i < 4 ; i += 2 - includeWidth ) { 34720 which = cssExpand[ i ]; 34721 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 34722 } 34723 34724 if ( includeWidth ) { 34725 attrs.opacity = attrs.width = type; 34726 } 34727 34728 return attrs; 34729 } 34730 34731 function createTween( value, prop, animation ) { 34732 var tween, 34733 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 34734 index = 0, 34735 length = collection.length; 34736 for ( ; index < length; index++ ) { 34737 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 34738 34739 // We're done with this property 34740 return tween; 34741 } 34742 } 34743 } 34744 34745 function defaultPrefilter( elem, props, opts ) { 34746 /* jshint validthis: true */ 34747 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, 34748 anim = this, 34749 orig = {}, 34750 style = elem.style, 34751 hidden = elem.nodeType && isHidden( elem ), 34752 dataShow = dataPriv.get( elem, "fxshow" ); 34753 34754 // Handle queue: false promises 34755 if ( !opts.queue ) { 34756 hooks = jQuery._queueHooks( elem, "fx" ); 34757 if ( hooks.unqueued == null ) { 34758 hooks.unqueued = 0; 34759 oldfire = hooks.empty.fire; 34760 hooks.empty.fire = function() { 34761 if ( !hooks.unqueued ) { 34762 oldfire(); 34763 } 34764 }; 34765 } 34766 hooks.unqueued++; 34767 34768 anim.always( function() { 34769 34770 // Ensure the complete handler is called before this completes 34771 anim.always( function() { 34772 hooks.unqueued--; 34773 if ( !jQuery.queue( elem, "fx" ).length ) { 34774 hooks.empty.fire(); 34775 } 34776 } ); 34777 } ); 34778 } 34779 34780 // Height/width overflow pass 34781 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { 34782 34783 // Make sure that nothing sneaks out 34784 // Record all 3 overflow attributes because IE9-10 do not 34785 // change the overflow attribute when overflowX and 34786 // overflowY are set to the same value 34787 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 34788 34789 // Set display property to inline-block for height/width 34790 // animations on inline elements that are having width/height animated 34791 display = jQuery.css( elem, "display" ); 34792 34793 // Test default display if display is currently "none" 34794 checkDisplay = display === "none" ? 34795 dataPriv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; 34796 34797 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { 34798 style.display = "inline-block"; 34799 } 34800 } 34801 34802 if ( opts.overflow ) { 34803 style.overflow = "hidden"; 34804 anim.always( function() { 34805 style.overflow = opts.overflow[ 0 ]; 34806 style.overflowX = opts.overflow[ 1 ]; 34807 style.overflowY = opts.overflow[ 2 ]; 34808 } ); 34809 } 34810 34811 // show/hide pass 34812 for ( prop in props ) { 34813 value = props[ prop ]; 34814 if ( rfxtypes.exec( value ) ) { 34815 delete props[ prop ]; 34816 toggle = toggle || value === "toggle"; 34817 if ( value === ( hidden ? "hide" : "show" ) ) { 34818 34819 // If there is dataShow left over from a stopped hide or show 34820 // and we are going to proceed with show, we should pretend to be hidden 34821 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 34822 hidden = true; 34823 } else { 34824 continue; 34825 } 34826 } 34827 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 34828 34829 // Any non-fx value stops us from restoring the original display value 34830 } else { 34831 display = undefined; 34832 } 34833 } 34834 34835 if ( !jQuery.isEmptyObject( orig ) ) { 34836 if ( dataShow ) { 34837 if ( "hidden" in dataShow ) { 34838 hidden = dataShow.hidden; 34839 } 34840 } else { 34841 dataShow = dataPriv.access( elem, "fxshow", {} ); 34842 } 34843 34844 // Store state if its toggle - enables .stop().toggle() to "reverse" 34845 if ( toggle ) { 34846 dataShow.hidden = !hidden; 34847 } 34848 if ( hidden ) { 34849 jQuery( elem ).show(); 34850 } else { 34851 anim.done( function() { 34852 jQuery( elem ).hide(); 34853 } ); 34854 } 34855 anim.done( function() { 34856 var prop; 34857 34858 dataPriv.remove( elem, "fxshow" ); 34859 for ( prop in orig ) { 34860 jQuery.style( elem, prop, orig[ prop ] ); 34861 } 34862 } ); 34863 for ( prop in orig ) { 34864 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 34865 34866 if ( !( prop in dataShow ) ) { 34867 dataShow[ prop ] = tween.start; 34868 if ( hidden ) { 34869 tween.end = tween.start; 34870 tween.start = prop === "width" || prop === "height" ? 1 : 0; 34871 } 34872 } 34873 } 34874 34875 // If this is a noop like .hide().hide(), restore an overwritten display value 34876 } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) { 34877 style.display = display; 34878 } 34879 } 34880 34881 function propFilter( props, specialEasing ) { 34882 var index, name, easing, value, hooks; 34883 34884 // camelCase, specialEasing and expand cssHook pass 34885 for ( index in props ) { 34886 name = jQuery.camelCase( index ); 34887 easing = specialEasing[ name ]; 34888 value = props[ index ]; 34889 if ( jQuery.isArray( value ) ) { 34890 easing = value[ 1 ]; 34891 value = props[ index ] = value[ 0 ]; 34892 } 34893 34894 if ( index !== name ) { 34895 props[ name ] = value; 34896 delete props[ index ]; 34897 } 34898 34899 hooks = jQuery.cssHooks[ name ]; 34900 if ( hooks && "expand" in hooks ) { 34901 value = hooks.expand( value ); 34902 delete props[ name ]; 34903 34904 // Not quite $.extend, this won't overwrite existing keys. 34905 // Reusing 'index' because we have the correct "name" 34906 for ( index in value ) { 34907 if ( !( index in props ) ) { 34908 props[ index ] = value[ index ]; 34909 specialEasing[ index ] = easing; 34910 } 34911 } 34912 } else { 34913 specialEasing[ name ] = easing; 34914 } 34915 } 34916 } 34917 34918 function Animation( elem, properties, options ) { 34919 var result, 34920 stopped, 34921 index = 0, 34922 length = Animation.prefilters.length, 34923 deferred = jQuery.Deferred().always( function() { 34924 34925 // Don't match elem in the :animated selector 34926 delete tick.elem; 34927 } ), 34928 tick = function() { 34929 if ( stopped ) { 34930 return false; 34931 } 34932 var currentTime = fxNow || createFxNow(), 34933 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 34934 34935 // Support: Android 2.3 34936 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) 34937 temp = remaining / animation.duration || 0, 34938 percent = 1 - temp, 34939 index = 0, 34940 length = animation.tweens.length; 34941 34942 for ( ; index < length ; index++ ) { 34943 animation.tweens[ index ].run( percent ); 34944 } 34945 34946 deferred.notifyWith( elem, [ animation, percent, remaining ] ); 34947 34948 if ( percent < 1 && length ) { 34949 return remaining; 34950 } else { 34951 deferred.resolveWith( elem, [ animation ] ); 34952 return false; 34953 } 34954 }, 34955 animation = deferred.promise( { 34956 elem: elem, 34957 props: jQuery.extend( {}, properties ), 34958 opts: jQuery.extend( true, { 34959 specialEasing: {}, 34960 easing: jQuery.easing._default 34961 }, options ), 34962 originalProperties: properties, 34963 originalOptions: options, 34964 startTime: fxNow || createFxNow(), 34965 duration: options.duration, 34966 tweens: [], 34967 createTween: function( prop, end ) { 34968 var tween = jQuery.Tween( elem, animation.opts, prop, end, 34969 animation.opts.specialEasing[ prop ] || animation.opts.easing ); 34970 animation.tweens.push( tween ); 34971 return tween; 34972 }, 34973 stop: function( gotoEnd ) { 34974 var index = 0, 34975 34976 // If we are going to the end, we want to run all the tweens 34977 // otherwise we skip this part 34978 length = gotoEnd ? animation.tweens.length : 0; 34979 if ( stopped ) { 34980 return this; 34981 } 34982 stopped = true; 34983 for ( ; index < length ; index++ ) { 34984 animation.tweens[ index ].run( 1 ); 34985 } 34986 34987 // Resolve when we played the last frame; otherwise, reject 34988 if ( gotoEnd ) { 34989 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 34990 deferred.resolveWith( elem, [ animation, gotoEnd ] ); 34991 } else { 34992 deferred.rejectWith( elem, [ animation, gotoEnd ] ); 34993 } 34994 return this; 34995 } 34996 } ), 34997 props = animation.props; 34998 34999 propFilter( props, animation.opts.specialEasing ); 35000 35001 for ( ; index < length ; index++ ) { 35002 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 35003 if ( result ) { 35004 if ( jQuery.isFunction( result.stop ) ) { 35005 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 35006 jQuery.proxy( result.stop, result ); 35007 } 35008 return result; 35009 } 35010 } 35011 35012 jQuery.map( props, createTween, animation ); 35013 35014 if ( jQuery.isFunction( animation.opts.start ) ) { 35015 animation.opts.start.call( elem, animation ); 35016 } 35017 35018 jQuery.fx.timer( 35019 jQuery.extend( tick, { 35020 elem: elem, 35021 anim: animation, 35022 queue: animation.opts.queue 35023 } ) 35024 ); 35025 35026 // attach callbacks from options 35027 return animation.progress( animation.opts.progress ) 35028 .done( animation.opts.done, animation.opts.complete ) 35029 .fail( animation.opts.fail ) 35030 .always( animation.opts.always ); 35031 } 35032 35033 jQuery.Animation = jQuery.extend( Animation, { 35034 tweeners: { 35035 "*": [ function( prop, value ) { 35036 var tween = this.createTween( prop, value ); 35037 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 35038 return tween; 35039 } ] 35040 }, 35041 35042 tweener: function( props, callback ) { 35043 if ( jQuery.isFunction( props ) ) { 35044 callback = props; 35045 props = [ "*" ]; 35046 } else { 35047 props = props.match( rnotwhite ); 35048 } 35049 35050 var prop, 35051 index = 0, 35052 length = props.length; 35053 35054 for ( ; index < length ; index++ ) { 35055 prop = props[ index ]; 35056 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 35057 Animation.tweeners[ prop ].unshift( callback ); 35058 } 35059 }, 35060 35061 prefilters: [ defaultPrefilter ], 35062 35063 prefilter: function( callback, prepend ) { 35064 if ( prepend ) { 35065 Animation.prefilters.unshift( callback ); 35066 } else { 35067 Animation.prefilters.push( callback ); 35068 } 35069 } 35070 } ); 35071 35072 jQuery.speed = function( speed, easing, fn ) { 35073 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 35074 complete: fn || !fn && easing || 35075 jQuery.isFunction( speed ) && speed, 35076 duration: speed, 35077 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing 35078 }; 35079 35080 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? 35081 opt.duration : opt.duration in jQuery.fx.speeds ? 35082 jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; 35083 35084 // Normalize opt.queue - true/undefined/null -> "fx" 35085 if ( opt.queue == null || opt.queue === true ) { 35086 opt.queue = "fx"; 35087 } 35088 35089 // Queueing 35090 opt.old = opt.complete; 35091 35092 opt.complete = function() { 35093 if ( jQuery.isFunction( opt.old ) ) { 35094 opt.old.call( this ); 35095 } 35096 35097 if ( opt.queue ) { 35098 jQuery.dequeue( this, opt.queue ); 35099 } 35100 }; 35101 35102 return opt; 35103 }; 35104 35105 jQuery.fn.extend( { 35106 fadeTo: function( speed, to, easing, callback ) { 35107 35108 // Show any hidden elements after setting opacity to 0 35109 return this.filter( isHidden ).css( "opacity", 0 ).show() 35110 35111 // Animate to the value specified 35112 .end().animate( { opacity: to }, speed, easing, callback ); 35113 }, 35114 animate: function( prop, speed, easing, callback ) { 35115 var empty = jQuery.isEmptyObject( prop ), 35116 optall = jQuery.speed( speed, easing, callback ), 35117 doAnimation = function() { 35118 35119 // Operate on a copy of prop so per-property easing won't be lost 35120 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 35121 35122 // Empty animations, or finishing resolves immediately 35123 if ( empty || dataPriv.get( this, "finish" ) ) { 35124 anim.stop( true ); 35125 } 35126 }; 35127 doAnimation.finish = doAnimation; 35128 35129 return empty || optall.queue === false ? 35130 this.each( doAnimation ) : 35131 this.queue( optall.queue, doAnimation ); 35132 }, 35133 stop: function( type, clearQueue, gotoEnd ) { 35134 var stopQueue = function( hooks ) { 35135 var stop = hooks.stop; 35136 delete hooks.stop; 35137 stop( gotoEnd ); 35138 }; 35139 35140 if ( typeof type !== "string" ) { 35141 gotoEnd = clearQueue; 35142 clearQueue = type; 35143 type = undefined; 35144 } 35145 if ( clearQueue && type !== false ) { 35146 this.queue( type || "fx", [] ); 35147 } 35148 35149 return this.each( function() { 35150 var dequeue = true, 35151 index = type != null && type + "queueHooks", 35152 timers = jQuery.timers, 35153 data = dataPriv.get( this ); 35154 35155 if ( index ) { 35156 if ( data[ index ] && data[ index ].stop ) { 35157 stopQueue( data[ index ] ); 35158 } 35159 } else { 35160 for ( index in data ) { 35161 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 35162 stopQueue( data[ index ] ); 35163 } 35164 } 35165 } 35166 35167 for ( index = timers.length; index--; ) { 35168 if ( timers[ index ].elem === this && 35169 ( type == null || timers[ index ].queue === type ) ) { 35170 35171 timers[ index ].anim.stop( gotoEnd ); 35172 dequeue = false; 35173 timers.splice( index, 1 ); 35174 } 35175 } 35176 35177 // Start the next in the queue if the last step wasn't forced. 35178 // Timers currently will call their complete callbacks, which 35179 // will dequeue but only if they were gotoEnd. 35180 if ( dequeue || !gotoEnd ) { 35181 jQuery.dequeue( this, type ); 35182 } 35183 } ); 35184 }, 35185 finish: function( type ) { 35186 if ( type !== false ) { 35187 type = type || "fx"; 35188 } 35189 return this.each( function() { 35190 var index, 35191 data = dataPriv.get( this ), 35192 queue = data[ type + "queue" ], 35193 hooks = data[ type + "queueHooks" ], 35194 timers = jQuery.timers, 35195 length = queue ? queue.length : 0; 35196 35197 // Enable finishing flag on private data 35198 data.finish = true; 35199 35200 // Empty the queue first 35201 jQuery.queue( this, type, [] ); 35202 35203 if ( hooks && hooks.stop ) { 35204 hooks.stop.call( this, true ); 35205 } 35206 35207 // Look for any active animations, and finish them 35208 for ( index = timers.length; index--; ) { 35209 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 35210 timers[ index ].anim.stop( true ); 35211 timers.splice( index, 1 ); 35212 } 35213 } 35214 35215 // Look for any animations in the old queue and finish them 35216 for ( index = 0; index < length; index++ ) { 35217 if ( queue[ index ] && queue[ index ].finish ) { 35218 queue[ index ].finish.call( this ); 35219 } 35220 } 35221 35222 // Turn off finishing flag 35223 delete data.finish; 35224 } ); 35225 } 35226 } ); 35227 35228 jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { 35229 var cssFn = jQuery.fn[ name ]; 35230 jQuery.fn[ name ] = function( speed, easing, callback ) { 35231 return speed == null || typeof speed === "boolean" ? 35232 cssFn.apply( this, arguments ) : 35233 this.animate( genFx( name, true ), speed, easing, callback ); 35234 }; 35235 } ); 35236 35237 // Generate shortcuts for custom animations 35238 jQuery.each( { 35239 slideDown: genFx( "show" ), 35240 slideUp: genFx( "hide" ), 35241 slideToggle: genFx( "toggle" ), 35242 fadeIn: { opacity: "show" }, 35243 fadeOut: { opacity: "hide" }, 35244 fadeToggle: { opacity: "toggle" } 35245 }, function( name, props ) { 35246 jQuery.fn[ name ] = function( speed, easing, callback ) { 35247 return this.animate( props, speed, easing, callback ); 35248 }; 35249 } ); 35250 35251 jQuery.timers = []; 35252 jQuery.fx.tick = function() { 35253 var timer, 35254 i = 0, 35255 timers = jQuery.timers; 35256 35257 fxNow = jQuery.now(); 35258 35259 for ( ; i < timers.length; i++ ) { 35260 timer = timers[ i ]; 35261 35262 // Checks the timer has not already been removed 35263 if ( !timer() && timers[ i ] === timer ) { 35264 timers.splice( i--, 1 ); 35265 } 35266 } 35267 35268 if ( !timers.length ) { 35269 jQuery.fx.stop(); 35270 } 35271 fxNow = undefined; 35272 }; 35273 35274 jQuery.fx.timer = function( timer ) { 35275 jQuery.timers.push( timer ); 35276 if ( timer() ) { 35277 jQuery.fx.start(); 35278 } else { 35279 jQuery.timers.pop(); 35280 } 35281 }; 35282 35283 jQuery.fx.interval = 13; 35284 jQuery.fx.start = function() { 35285 if ( !timerId ) { 35286 timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); 35287 } 35288 }; 35289 35290 jQuery.fx.stop = function() { 35291 window.clearInterval( timerId ); 35292 35293 timerId = null; 35294 }; 35295 35296 jQuery.fx.speeds = { 35297 slow: 600, 35298 fast: 200, 35299 35300 // Default speed 35301 _default: 400 35302 }; 35303 35304 35305 // Based off of the plugin by Clint Helfers, with permission. 35306 // http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ 35307 jQuery.fn.delay = function( time, type ) { 35308 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 35309 type = type || "fx"; 35310 35311 return this.queue( type, function( next, hooks ) { 35312 var timeout = window.setTimeout( next, time ); 35313 hooks.stop = function() { 35314 window.clearTimeout( timeout ); 35315 }; 35316 } ); 35317 }; 35318 35319 35320 ( function() { 35321 var input = document.createElement( "input" ), 35322 select = document.createElement( "select" ), 35323 opt = select.appendChild( document.createElement( "option" ) ); 35324 35325 input.type = "checkbox"; 35326 35327 // Support: iOS<=5.1, Android<=4.2+ 35328 // Default value for a checkbox should be "on" 35329 support.checkOn = input.value !== ""; 35330 35331 // Support: IE<=11+ 35332 // Must access selectedIndex to make default options select 35333 support.optSelected = opt.selected; 35334 35335 // Support: Android<=2.3 35336 // Options inside disabled selects are incorrectly marked as disabled 35337 select.disabled = true; 35338 support.optDisabled = !opt.disabled; 35339 35340 // Support: IE<=11+ 35341 // An input loses its value after becoming a radio 35342 input = document.createElement( "input" ); 35343 input.value = "t"; 35344 input.type = "radio"; 35345 support.radioValue = input.value === "t"; 35346 } )(); 35347 35348 35349 var boolHook, 35350 attrHandle = jQuery.expr.attrHandle; 35351 35352 jQuery.fn.extend( { 35353 attr: function( name, value ) { 35354 return access( this, jQuery.attr, name, value, arguments.length > 1 ); 35355 }, 35356 35357 removeAttr: function( name ) { 35358 return this.each( function() { 35359 jQuery.removeAttr( this, name ); 35360 } ); 35361 } 35362 } ); 35363 35364 jQuery.extend( { 35365 attr: function( elem, name, value ) { 35366 var ret, hooks, 35367 nType = elem.nodeType; 35368 35369 // Don't get/set attributes on text, comment and attribute nodes 35370 if ( nType === 3 || nType === 8 || nType === 2 ) { 35371 return; 35372 } 35373 35374 // Fallback to prop when attributes are not supported 35375 if ( typeof elem.getAttribute === "undefined" ) { 35376 return jQuery.prop( elem, name, value ); 35377 } 35378 35379 // All attributes are lowercase 35380 // Grab necessary hook if one is defined 35381 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 35382 name = name.toLowerCase(); 35383 hooks = jQuery.attrHooks[ name ] || 35384 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 35385 } 35386 35387 if ( value !== undefined ) { 35388 if ( value === null ) { 35389 jQuery.removeAttr( elem, name ); 35390 return; 35391 } 35392 35393 if ( hooks && "set" in hooks && 35394 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 35395 return ret; 35396 } 35397 35398 elem.setAttribute( name, value + "" ); 35399 return value; 35400 } 35401 35402 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 35403 return ret; 35404 } 35405 35406 ret = jQuery.find.attr( elem, name ); 35407 35408 // Non-existent attributes return null, we normalize to undefined 35409 return ret == null ? undefined : ret; 35410 }, 35411 35412 attrHooks: { 35413 type: { 35414 set: function( elem, value ) { 35415 if ( !support.radioValue && value === "radio" && 35416 jQuery.nodeName( elem, "input" ) ) { 35417 var val = elem.value; 35418 elem.setAttribute( "type", value ); 35419 if ( val ) { 35420 elem.value = val; 35421 } 35422 return value; 35423 } 35424 } 35425 } 35426 }, 35427 35428 removeAttr: function( elem, value ) { 35429 var name, propName, 35430 i = 0, 35431 attrNames = value && value.match( rnotwhite ); 35432 35433 if ( attrNames && elem.nodeType === 1 ) { 35434 while ( ( name = attrNames[ i++ ] ) ) { 35435 propName = jQuery.propFix[ name ] || name; 35436 35437 // Boolean attributes get special treatment (#10870) 35438 if ( jQuery.expr.match.bool.test( name ) ) { 35439 35440 // Set corresponding property to false 35441 elem[ propName ] = false; 35442 } 35443 35444 elem.removeAttribute( name ); 35445 } 35446 } 35447 } 35448 } ); 35449 35450 // Hooks for boolean attributes 35451 boolHook = { 35452 set: function( elem, value, name ) { 35453 if ( value === false ) { 35454 35455 // Remove boolean attributes when set to false 35456 jQuery.removeAttr( elem, name ); 35457 } else { 35458 elem.setAttribute( name, name ); 35459 } 35460 return name; 35461 } 35462 }; 35463 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { 35464 var getter = attrHandle[ name ] || jQuery.find.attr; 35465 35466 attrHandle[ name ] = function( elem, name, isXML ) { 35467 var ret, handle; 35468 if ( !isXML ) { 35469 35470 // Avoid an infinite loop by temporarily removing this function from the getter 35471 handle = attrHandle[ name ]; 35472 attrHandle[ name ] = ret; 35473 ret = getter( elem, name, isXML ) != null ? 35474 name.toLowerCase() : 35475 null; 35476 attrHandle[ name ] = handle; 35477 } 35478 return ret; 35479 }; 35480 } ); 35481 35482 35483 35484 35485 var rfocusable = /^(?:input|select|textarea|button)$/i, 35486 rclickable = /^(?:a|area)$/i; 35487 35488 jQuery.fn.extend( { 35489 prop: function( name, value ) { 35490 return access( this, jQuery.prop, name, value, arguments.length > 1 ); 35491 }, 35492 35493 removeProp: function( name ) { 35494 return this.each( function() { 35495 delete this[ jQuery.propFix[ name ] || name ]; 35496 } ); 35497 } 35498 } ); 35499 35500 jQuery.extend( { 35501 prop: function( elem, name, value ) { 35502 var ret, hooks, 35503 nType = elem.nodeType; 35504 35505 // Don't get/set properties on text, comment and attribute nodes 35506 if ( nType === 3 || nType === 8 || nType === 2 ) { 35507 return; 35508 } 35509 35510 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 35511 35512 // Fix name and attach hooks 35513 name = jQuery.propFix[ name ] || name; 35514 hooks = jQuery.propHooks[ name ]; 35515 } 35516 35517 if ( value !== undefined ) { 35518 if ( hooks && "set" in hooks && 35519 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 35520 return ret; 35521 } 35522 35523 return ( elem[ name ] = value ); 35524 } 35525 35526 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 35527 return ret; 35528 } 35529 35530 return elem[ name ]; 35531 }, 35532 35533 propHooks: { 35534 tabIndex: { 35535 get: function( elem ) { 35536 35537 // elem.tabIndex doesn't always return the 35538 // correct value when it hasn't been explicitly set 35539 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 35540 // Use proper attribute retrieval(#12072) 35541 var tabindex = jQuery.find.attr( elem, "tabindex" ); 35542 35543 return tabindex ? 35544 parseInt( tabindex, 10 ) : 35545 rfocusable.test( elem.nodeName ) || 35546 rclickable.test( elem.nodeName ) && elem.href ? 35547 0 : 35548 -1; 35549 } 35550 } 35551 }, 35552 35553 propFix: { 35554 "for": "htmlFor", 35555 "class": "className" 35556 } 35557 } ); 35558 35559 // Support: IE <=11 only 35560 // Accessing the selectedIndex property 35561 // forces the browser to respect setting selected 35562 // on the option 35563 // The getter ensures a default option is selected 35564 // when in an optgroup 35565 if ( !support.optSelected ) { 35566 jQuery.propHooks.selected = { 35567 get: function( elem ) { 35568 var parent = elem.parentNode; 35569 if ( parent && parent.parentNode ) { 35570 parent.parentNode.selectedIndex; 35571 } 35572 return null; 35573 }, 35574 set: function( elem ) { 35575 var parent = elem.parentNode; 35576 if ( parent ) { 35577 parent.selectedIndex; 35578 35579 if ( parent.parentNode ) { 35580 parent.parentNode.selectedIndex; 35581 } 35582 } 35583 } 35584 }; 35585 } 35586 35587 jQuery.each( [ 35588 "tabIndex", 35589 "readOnly", 35590 "maxLength", 35591 "cellSpacing", 35592 "cellPadding", 35593 "rowSpan", 35594 "colSpan", 35595 "useMap", 35596 "frameBorder", 35597 "contentEditable" 35598 ], function() { 35599 jQuery.propFix[ this.toLowerCase() ] = this; 35600 } ); 35601 35602 35603 35604 35605 var rclass = /[\t\r\n\f]/g; 35606 35607 function getClass( elem ) { 35608 return elem.getAttribute && elem.getAttribute( "class" ) || ""; 35609 } 35610 35611 jQuery.fn.extend( { 35612 addClass: function( value ) { 35613 var classes, elem, cur, curValue, clazz, j, finalValue, 35614 i = 0; 35615 35616 if ( jQuery.isFunction( value ) ) { 35617 return this.each( function( j ) { 35618 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 35619 } ); 35620 } 35621 35622 if ( typeof value === "string" && value ) { 35623 classes = value.match( rnotwhite ) || []; 35624 35625 while ( ( elem = this[ i++ ] ) ) { 35626 curValue = getClass( elem ); 35627 cur = elem.nodeType === 1 && 35628 ( " " + curValue + " " ).replace( rclass, " " ); 35629 35630 if ( cur ) { 35631 j = 0; 35632 while ( ( clazz = classes[ j++ ] ) ) { 35633 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 35634 cur += clazz + " "; 35635 } 35636 } 35637 35638 // Only assign if different to avoid unneeded rendering. 35639 finalValue = jQuery.trim( cur ); 35640 if ( curValue !== finalValue ) { 35641 elem.setAttribute( "class", finalValue ); 35642 } 35643 } 35644 } 35645 } 35646 35647 return this; 35648 }, 35649 35650 removeClass: function( value ) { 35651 var classes, elem, cur, curValue, clazz, j, finalValue, 35652 i = 0; 35653 35654 if ( jQuery.isFunction( value ) ) { 35655 return this.each( function( j ) { 35656 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 35657 } ); 35658 } 35659 35660 if ( !arguments.length ) { 35661 return this.attr( "class", "" ); 35662 } 35663 35664 if ( typeof value === "string" && value ) { 35665 classes = value.match( rnotwhite ) || []; 35666 35667 while ( ( elem = this[ i++ ] ) ) { 35668 curValue = getClass( elem ); 35669 35670 // This expression is here for better compressibility (see addClass) 35671 cur = elem.nodeType === 1 && 35672 ( " " + curValue + " " ).replace( rclass, " " ); 35673 35674 if ( cur ) { 35675 j = 0; 35676 while ( ( clazz = classes[ j++ ] ) ) { 35677 35678 // Remove *all* instances 35679 while ( cur.indexOf( " " + clazz + " " ) > -1 ) { 35680 cur = cur.replace( " " + clazz + " ", " " ); 35681 } 35682 } 35683 35684 // Only assign if different to avoid unneeded rendering. 35685 finalValue = jQuery.trim( cur ); 35686 if ( curValue !== finalValue ) { 35687 elem.setAttribute( "class", finalValue ); 35688 } 35689 } 35690 } 35691 } 35692 35693 return this; 35694 }, 35695 35696 toggleClass: function( value, stateVal ) { 35697 var type = typeof value; 35698 35699 if ( typeof stateVal === "boolean" && type === "string" ) { 35700 return stateVal ? this.addClass( value ) : this.removeClass( value ); 35701 } 35702 35703 if ( jQuery.isFunction( value ) ) { 35704 return this.each( function( i ) { 35705 jQuery( this ).toggleClass( 35706 value.call( this, i, getClass( this ), stateVal ), 35707 stateVal 35708 ); 35709 } ); 35710 } 35711 35712 return this.each( function() { 35713 var className, i, self, classNames; 35714 35715 if ( type === "string" ) { 35716 35717 // Toggle individual class names 35718 i = 0; 35719 self = jQuery( this ); 35720 classNames = value.match( rnotwhite ) || []; 35721 35722 while ( ( className = classNames[ i++ ] ) ) { 35723 35724 // Check each className given, space separated list 35725 if ( self.hasClass( className ) ) { 35726 self.removeClass( className ); 35727 } else { 35728 self.addClass( className ); 35729 } 35730 } 35731 35732 // Toggle whole class name 35733 } else if ( value === undefined || type === "boolean" ) { 35734 className = getClass( this ); 35735 if ( className ) { 35736 35737 // Store className if set 35738 dataPriv.set( this, "__className__", className ); 35739 } 35740 35741 // If the element has a class name or if we're passed `false`, 35742 // then remove the whole classname (if there was one, the above saved it). 35743 // Otherwise bring back whatever was previously saved (if anything), 35744 // falling back to the empty string if nothing was stored. 35745 if ( this.setAttribute ) { 35746 this.setAttribute( "class", 35747 className || value === false ? 35748 "" : 35749 dataPriv.get( this, "__className__" ) || "" 35750 ); 35751 } 35752 } 35753 } ); 35754 }, 35755 35756 hasClass: function( selector ) { 35757 var className, elem, 35758 i = 0; 35759 35760 className = " " + selector + " "; 35761 while ( ( elem = this[ i++ ] ) ) { 35762 if ( elem.nodeType === 1 && 35763 ( " " + getClass( elem ) + " " ).replace( rclass, " " ) 35764 .indexOf( className ) > -1 35765 ) { 35766 return true; 35767 } 35768 } 35769 35770 return false; 35771 } 35772 } ); 35773 35774 35775 35776 35777 var rreturn = /\r/g, 35778 rspaces = /[\x20\t\r\n\f]+/g; 35779 35780 jQuery.fn.extend( { 35781 val: function( value ) { 35782 var hooks, ret, isFunction, 35783 elem = this[ 0 ]; 35784 35785 if ( !arguments.length ) { 35786 if ( elem ) { 35787 hooks = jQuery.valHooks[ elem.type ] || 35788 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 35789 35790 if ( hooks && 35791 "get" in hooks && 35792 ( ret = hooks.get( elem, "value" ) ) !== undefined 35793 ) { 35794 return ret; 35795 } 35796 35797 ret = elem.value; 35798 35799 return typeof ret === "string" ? 35800 35801 // Handle most common string cases 35802 ret.replace( rreturn, "" ) : 35803 35804 // Handle cases where value is null/undef or number 35805 ret == null ? "" : ret; 35806 } 35807 35808 return; 35809 } 35810 35811 isFunction = jQuery.isFunction( value ); 35812 35813 return this.each( function( i ) { 35814 var val; 35815 35816 if ( this.nodeType !== 1 ) { 35817 return; 35818 } 35819 35820 if ( isFunction ) { 35821 val = value.call( this, i, jQuery( this ).val() ); 35822 } else { 35823 val = value; 35824 } 35825 35826 // Treat null/undefined as ""; convert numbers to string 35827 if ( val == null ) { 35828 val = ""; 35829 35830 } else if ( typeof val === "number" ) { 35831 val += ""; 35832 35833 } else if ( jQuery.isArray( val ) ) { 35834 val = jQuery.map( val, function( value ) { 35835 return value == null ? "" : value + ""; 35836 } ); 35837 } 35838 35839 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 35840 35841 // If set returns undefined, fall back to normal setting 35842 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 35843 this.value = val; 35844 } 35845 } ); 35846 } 35847 } ); 35848 35849 jQuery.extend( { 35850 valHooks: { 35851 option: { 35852 get: function( elem ) { 35853 35854 var val = jQuery.find.attr( elem, "value" ); 35855 return val != null ? 35856 val : 35857 35858 // Support: IE10-11+ 35859 // option.text throws exceptions (#14686, #14858) 35860 // Strip and collapse whitespace 35861 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 35862 jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " ); 35863 } 35864 }, 35865 select: { 35866 get: function( elem ) { 35867 var value, option, 35868 options = elem.options, 35869 index = elem.selectedIndex, 35870 one = elem.type === "select-one" || index < 0, 35871 values = one ? null : [], 35872 max = one ? index + 1 : options.length, 35873 i = index < 0 ? 35874 max : 35875 one ? index : 0; 35876 35877 // Loop through all the selected options 35878 for ( ; i < max; i++ ) { 35879 option = options[ i ]; 35880 35881 // IE8-9 doesn't update selected after form reset (#2551) 35882 if ( ( option.selected || i === index ) && 35883 35884 // Don't return options that are disabled or in a disabled optgroup 35885 ( support.optDisabled ? 35886 !option.disabled : option.getAttribute( "disabled" ) === null ) && 35887 ( !option.parentNode.disabled || 35888 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { 35889 35890 // Get the specific value for the option 35891 value = jQuery( option ).val(); 35892 35893 // We don't need an array for one selects 35894 if ( one ) { 35895 return value; 35896 } 35897 35898 // Multi-Selects return an array 35899 values.push( value ); 35900 } 35901 } 35902 35903 return values; 35904 }, 35905 35906 set: function( elem, value ) { 35907 var optionSet, option, 35908 options = elem.options, 35909 values = jQuery.makeArray( value ), 35910 i = options.length; 35911 35912 while ( i-- ) { 35913 option = options[ i ]; 35914 if ( option.selected = 35915 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 35916 ) { 35917 optionSet = true; 35918 } 35919 } 35920 35921 // Force browsers to behave consistently when non-matching value is set 35922 if ( !optionSet ) { 35923 elem.selectedIndex = -1; 35924 } 35925 return values; 35926 } 35927 } 35928 } 35929 } ); 35930 35931 // Radios and checkboxes getter/setter 35932 jQuery.each( [ "radio", "checkbox" ], function() { 35933 jQuery.valHooks[ this ] = { 35934 set: function( elem, value ) { 35935 if ( jQuery.isArray( value ) ) { 35936 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 35937 } 35938 } 35939 }; 35940 if ( !support.checkOn ) { 35941 jQuery.valHooks[ this ].get = function( elem ) { 35942 return elem.getAttribute( "value" ) === null ? "on" : elem.value; 35943 }; 35944 } 35945 } ); 35946 35947 35948 35949 35950 // Return jQuery for attributes-only inclusion 35951 35952 35953 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; 35954 35955 jQuery.extend( jQuery.event, { 35956 35957 trigger: function( event, data, elem, onlyHandlers ) { 35958 35959 var i, cur, tmp, bubbleType, ontype, handle, special, 35960 eventPath = [ elem || document ], 35961 type = hasOwn.call( event, "type" ) ? event.type : event, 35962 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 35963 35964 cur = tmp = elem = elem || document; 35965 35966 // Don't do events on text and comment nodes 35967 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 35968 return; 35969 } 35970 35971 // focus/blur morphs to focusin/out; ensure we're not firing them right now 35972 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 35973 return; 35974 } 35975 35976 if ( type.indexOf( "." ) > -1 ) { 35977 35978 // Namespaced trigger; create a regexp to match event type in handle() 35979 namespaces = type.split( "." ); 35980 type = namespaces.shift(); 35981 namespaces.sort(); 35982 } 35983 ontype = type.indexOf( ":" ) < 0 && "on" + type; 35984 35985 // Caller can pass in a jQuery.Event object, Object, or just an event type string 35986 event = event[ jQuery.expando ] ? 35987 event : 35988 new jQuery.Event( type, typeof event === "object" && event ); 35989 35990 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 35991 event.isTrigger = onlyHandlers ? 2 : 3; 35992 event.namespace = namespaces.join( "." ); 35993 event.rnamespace = event.namespace ? 35994 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 35995 null; 35996 35997 // Clean up the event in case it is being reused 35998 event.result = undefined; 35999 if ( !event.target ) { 36000 event.target = elem; 36001 } 36002 36003 // Clone any incoming data and prepend the event, creating the handler arg list 36004 data = data == null ? 36005 [ event ] : 36006 jQuery.makeArray( data, [ event ] ); 36007 36008 // Allow special events to draw outside the lines 36009 special = jQuery.event.special[ type ] || {}; 36010 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 36011 return; 36012 } 36013 36014 // Determine event propagation path in advance, per W3C events spec (#9951) 36015 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) 36016 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { 36017 36018 bubbleType = special.delegateType || type; 36019 if ( !rfocusMorph.test( bubbleType + type ) ) { 36020 cur = cur.parentNode; 36021 } 36022 for ( ; cur; cur = cur.parentNode ) { 36023 eventPath.push( cur ); 36024 tmp = cur; 36025 } 36026 36027 // Only add window if we got to document (e.g., not plain obj or detached DOM) 36028 if ( tmp === ( elem.ownerDocument || document ) ) { 36029 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 36030 } 36031 } 36032 36033 // Fire handlers on the event path 36034 i = 0; 36035 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 36036 36037 event.type = i > 1 ? 36038 bubbleType : 36039 special.bindType || type; 36040 36041 // jQuery handler 36042 handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && 36043 dataPriv.get( cur, "handle" ); 36044 if ( handle ) { 36045 handle.apply( cur, data ); 36046 } 36047 36048 // Native handler 36049 handle = ontype && cur[ ontype ]; 36050 if ( handle && handle.apply && acceptData( cur ) ) { 36051 event.result = handle.apply( cur, data ); 36052 if ( event.result === false ) { 36053 event.preventDefault(); 36054 } 36055 } 36056 } 36057 event.type = type; 36058 36059 // If nobody prevented the default action, do it now 36060 if ( !onlyHandlers && !event.isDefaultPrevented() ) { 36061 36062 if ( ( !special._default || 36063 special._default.apply( eventPath.pop(), data ) === false ) && 36064 acceptData( elem ) ) { 36065 36066 // Call a native DOM method on the target with the same name name as the event. 36067 // Don't do default actions on window, that's where global variables be (#6170) 36068 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { 36069 36070 // Don't re-trigger an onFOO event when we call its FOO() method 36071 tmp = elem[ ontype ]; 36072 36073 if ( tmp ) { 36074 elem[ ontype ] = null; 36075 } 36076 36077 // Prevent re-triggering of the same event, since we already bubbled it above 36078 jQuery.event.triggered = type; 36079 elem[ type ](); 36080 jQuery.event.triggered = undefined; 36081 36082 if ( tmp ) { 36083 elem[ ontype ] = tmp; 36084 } 36085 } 36086 } 36087 } 36088 36089 return event.result; 36090 }, 36091 36092 // Piggyback on a donor event to simulate a different one 36093 // Used only for `focus(in | out)` events 36094 simulate: function( type, elem, event ) { 36095 var e = jQuery.extend( 36096 new jQuery.Event(), 36097 event, 36098 { 36099 type: type, 36100 isSimulated: true 36101 } 36102 ); 36103 36104 jQuery.event.trigger( e, null, elem ); 36105 } 36106 36107 } ); 36108 36109 jQuery.fn.extend( { 36110 36111 trigger: function( type, data ) { 36112 return this.each( function() { 36113 jQuery.event.trigger( type, data, this ); 36114 } ); 36115 }, 36116 triggerHandler: function( type, data ) { 36117 var elem = this[ 0 ]; 36118 if ( elem ) { 36119 return jQuery.event.trigger( type, data, elem, true ); 36120 } 36121 } 36122 } ); 36123 36124 36125 jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " + 36126 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 36127 "change select submit keydown keypress keyup error contextmenu" ).split( " " ), 36128 function( i, name ) { 36129 36130 // Handle event binding 36131 jQuery.fn[ name ] = function( data, fn ) { 36132 return arguments.length > 0 ? 36133 this.on( name, null, data, fn ) : 36134 this.trigger( name ); 36135 }; 36136 } ); 36137 36138 jQuery.fn.extend( { 36139 hover: function( fnOver, fnOut ) { 36140 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 36141 } 36142 } ); 36143 36144 36145 36146 36147 support.focusin = "onfocusin" in window; 36148 36149 36150 // Support: Firefox 36151 // Firefox doesn't have focus(in | out) events 36152 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 36153 // 36154 // Support: Chrome, Safari 36155 // focus(in | out) events fire after focus & blur events, 36156 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 36157 // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857 36158 if ( !support.focusin ) { 36159 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { 36160 36161 // Attach a single capturing handler on the document while someone wants focusin/focusout 36162 var handler = function( event ) { 36163 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); 36164 }; 36165 36166 jQuery.event.special[ fix ] = { 36167 setup: function() { 36168 var doc = this.ownerDocument || this, 36169 attaches = dataPriv.access( doc, fix ); 36170 36171 if ( !attaches ) { 36172 doc.addEventListener( orig, handler, true ); 36173 } 36174 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); 36175 }, 36176 teardown: function() { 36177 var doc = this.ownerDocument || this, 36178 attaches = dataPriv.access( doc, fix ) - 1; 36179 36180 if ( !attaches ) { 36181 doc.removeEventListener( orig, handler, true ); 36182 dataPriv.remove( doc, fix ); 36183 36184 } else { 36185 dataPriv.access( doc, fix, attaches ); 36186 } 36187 } 36188 }; 36189 } ); 36190 } 36191 var location = window.location; 36192 36193 var nonce = jQuery.now(); 36194 36195 var rquery = ( /\?/ ); 36196 36197 36198 36199 // Support: Android 2.3 36200 // Workaround failure to string-cast null input 36201 jQuery.parseJSON = function( data ) { 36202 return JSON.parse( data + "" ); 36203 }; 36204 36205 36206 // Cross-browser xml parsing 36207 jQuery.parseXML = function( data ) { 36208 var xml; 36209 if ( !data || typeof data !== "string" ) { 36210 return null; 36211 } 36212 36213 // Support: IE9 36214 try { 36215 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 36216 } catch ( e ) { 36217 xml = undefined; 36218 } 36219 36220 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 36221 jQuery.error( "Invalid XML: " + data ); 36222 } 36223 return xml; 36224 }; 36225 36226 36227 var 36228 rhash = /#.*$/, 36229 rts = /([?&])_=[^&]*/, 36230 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, 36231 36232 // #7653, #8125, #8152: local protocol detection 36233 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 36234 rnoContent = /^(?:GET|HEAD)$/, 36235 rprotocol = /^\/\//, 36236 36237 /* Prefilters 36238 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 36239 * 2) These are called: 36240 * - BEFORE asking for a transport 36241 * - AFTER param serialization (s.data is a string if s.processData is true) 36242 * 3) key is the dataType 36243 * 4) the catchall symbol "*" can be used 36244 * 5) execution will start with transport dataType and THEN continue down to "*" if needed 36245 */ 36246 prefilters = {}, 36247 36248 /* Transports bindings 36249 * 1) key is the dataType 36250 * 2) the catchall symbol "*" can be used 36251 * 3) selection will start with transport dataType and THEN go to "*" if needed 36252 */ 36253 transports = {}, 36254 36255 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression 36256 allTypes = "*/".concat( "*" ), 36257 36258 // Anchor tag for parsing the document origin 36259 originAnchor = document.createElement( "a" ); 36260 originAnchor.href = location.href; 36261 36262 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 36263 function addToPrefiltersOrTransports( structure ) { 36264 36265 // dataTypeExpression is optional and defaults to "*" 36266 return function( dataTypeExpression, func ) { 36267 36268 if ( typeof dataTypeExpression !== "string" ) { 36269 func = dataTypeExpression; 36270 dataTypeExpression = "*"; 36271 } 36272 36273 var dataType, 36274 i = 0, 36275 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; 36276 36277 if ( jQuery.isFunction( func ) ) { 36278 36279 // For each dataType in the dataTypeExpression 36280 while ( ( dataType = dataTypes[ i++ ] ) ) { 36281 36282 // Prepend if requested 36283 if ( dataType[ 0 ] === "+" ) { 36284 dataType = dataType.slice( 1 ) || "*"; 36285 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 36286 36287 // Otherwise append 36288 } else { 36289 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 36290 } 36291 } 36292 } 36293 }; 36294 } 36295 36296 // Base inspection function for prefilters and transports 36297 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 36298 36299 var inspected = {}, 36300 seekingTransport = ( structure === transports ); 36301 36302 function inspect( dataType ) { 36303 var selected; 36304 inspected[ dataType ] = true; 36305 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 36306 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 36307 if ( typeof dataTypeOrTransport === "string" && 36308 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 36309 36310 options.dataTypes.unshift( dataTypeOrTransport ); 36311 inspect( dataTypeOrTransport ); 36312 return false; 36313 } else if ( seekingTransport ) { 36314 return !( selected = dataTypeOrTransport ); 36315 } 36316 } ); 36317 return selected; 36318 } 36319 36320 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 36321 } 36322 36323 // A special extend for ajax options 36324 // that takes "flat" options (not to be deep extended) 36325 // Fixes #9887 36326 function ajaxExtend( target, src ) { 36327 var key, deep, 36328 flatOptions = jQuery.ajaxSettings.flatOptions || {}; 36329 36330 for ( key in src ) { 36331 if ( src[ key ] !== undefined ) { 36332 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 36333 } 36334 } 36335 if ( deep ) { 36336 jQuery.extend( true, target, deep ); 36337 } 36338 36339 return target; 36340 } 36341 36342 /* Handles responses to an ajax request: 36343 * - finds the right dataType (mediates between content-type and expected dataType) 36344 * - returns the corresponding response 36345 */ 36346 function ajaxHandleResponses( s, jqXHR, responses ) { 36347 36348 var ct, type, finalDataType, firstDataType, 36349 contents = s.contents, 36350 dataTypes = s.dataTypes; 36351 36352 // Remove auto dataType and get content-type in the process 36353 while ( dataTypes[ 0 ] === "*" ) { 36354 dataTypes.shift(); 36355 if ( ct === undefined ) { 36356 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 36357 } 36358 } 36359 36360 // Check if we're dealing with a known content-type 36361 if ( ct ) { 36362 for ( type in contents ) { 36363 if ( contents[ type ] && contents[ type ].test( ct ) ) { 36364 dataTypes.unshift( type ); 36365 break; 36366 } 36367 } 36368 } 36369 36370 // Check to see if we have a response for the expected dataType 36371 if ( dataTypes[ 0 ] in responses ) { 36372 finalDataType = dataTypes[ 0 ]; 36373 } else { 36374 36375 // Try convertible dataTypes 36376 for ( type in responses ) { 36377 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 36378 finalDataType = type; 36379 break; 36380 } 36381 if ( !firstDataType ) { 36382 firstDataType = type; 36383 } 36384 } 36385 36386 // Or just use first one 36387 finalDataType = finalDataType || firstDataType; 36388 } 36389 36390 // If we found a dataType 36391 // We add the dataType to the list if needed 36392 // and return the corresponding response 36393 if ( finalDataType ) { 36394 if ( finalDataType !== dataTypes[ 0 ] ) { 36395 dataTypes.unshift( finalDataType ); 36396 } 36397 return responses[ finalDataType ]; 36398 } 36399 } 36400 36401 /* Chain conversions given the request and the original response 36402 * Also sets the responseXXX fields on the jqXHR instance 36403 */ 36404 function ajaxConvert( s, response, jqXHR, isSuccess ) { 36405 var conv2, current, conv, tmp, prev, 36406 converters = {}, 36407 36408 // Work with a copy of dataTypes in case we need to modify it for conversion 36409 dataTypes = s.dataTypes.slice(); 36410 36411 // Create converters map with lowercased keys 36412 if ( dataTypes[ 1 ] ) { 36413 for ( conv in s.converters ) { 36414 converters[ conv.toLowerCase() ] = s.converters[ conv ]; 36415 } 36416 } 36417 36418 current = dataTypes.shift(); 36419 36420 // Convert to each sequential dataType 36421 while ( current ) { 36422 36423 if ( s.responseFields[ current ] ) { 36424 jqXHR[ s.responseFields[ current ] ] = response; 36425 } 36426 36427 // Apply the dataFilter if provided 36428 if ( !prev && isSuccess && s.dataFilter ) { 36429 response = s.dataFilter( response, s.dataType ); 36430 } 36431 36432 prev = current; 36433 current = dataTypes.shift(); 36434 36435 if ( current ) { 36436 36437 // There's only work to do if current dataType is non-auto 36438 if ( current === "*" ) { 36439 36440 current = prev; 36441 36442 // Convert response if prev dataType is non-auto and differs from current 36443 } else if ( prev !== "*" && prev !== current ) { 36444 36445 // Seek a direct converter 36446 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 36447 36448 // If none found, seek a pair 36449 if ( !conv ) { 36450 for ( conv2 in converters ) { 36451 36452 // If conv2 outputs current 36453 tmp = conv2.split( " " ); 36454 if ( tmp[ 1 ] === current ) { 36455 36456 // If prev can be converted to accepted input 36457 conv = converters[ prev + " " + tmp[ 0 ] ] || 36458 converters[ "* " + tmp[ 0 ] ]; 36459 if ( conv ) { 36460 36461 // Condense equivalence converters 36462 if ( conv === true ) { 36463 conv = converters[ conv2 ]; 36464 36465 // Otherwise, insert the intermediate dataType 36466 } else if ( converters[ conv2 ] !== true ) { 36467 current = tmp[ 0 ]; 36468 dataTypes.unshift( tmp[ 1 ] ); 36469 } 36470 break; 36471 } 36472 } 36473 } 36474 } 36475 36476 // Apply converter (if not an equivalence) 36477 if ( conv !== true ) { 36478 36479 // Unless errors are allowed to bubble, catch and return them 36480 if ( conv && s.throws ) { 36481 response = conv( response ); 36482 } else { 36483 try { 36484 response = conv( response ); 36485 } catch ( e ) { 36486 return { 36487 state: "parsererror", 36488 error: conv ? e : "No conversion from " + prev + " to " + current 36489 }; 36490 } 36491 } 36492 } 36493 } 36494 } 36495 } 36496 36497 return { state: "success", data: response }; 36498 } 36499 36500 jQuery.extend( { 36501 36502 // Counter for holding the number of active queries 36503 active: 0, 36504 36505 // Last-Modified header cache for next request 36506 lastModified: {}, 36507 etag: {}, 36508 36509 ajaxSettings: { 36510 url: location.href, 36511 type: "GET", 36512 isLocal: rlocalProtocol.test( location.protocol ), 36513 global: true, 36514 processData: true, 36515 async: true, 36516 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 36517 /* 36518 timeout: 0, 36519 data: null, 36520 dataType: null, 36521 username: null, 36522 password: null, 36523 cache: null, 36524 throws: false, 36525 traditional: false, 36526 headers: {}, 36527 */ 36528 36529 accepts: { 36530 "*": allTypes, 36531 text: "text/plain", 36532 html: "text/html", 36533 xml: "application/xml, text/xml", 36534 json: "application/json, text/javascript" 36535 }, 36536 36537 contents: { 36538 xml: /\bxml\b/, 36539 html: /\bhtml/, 36540 json: /\bjson\b/ 36541 }, 36542 36543 responseFields: { 36544 xml: "responseXML", 36545 text: "responseText", 36546 json: "responseJSON" 36547 }, 36548 36549 // Data converters 36550 // Keys separate source (or catchall "*") and destination types with a single space 36551 converters: { 36552 36553 // Convert anything to text 36554 "* text": String, 36555 36556 // Text to html (true = no transformation) 36557 "text html": true, 36558 36559 // Evaluate text as a json expression 36560 "text json": jQuery.parseJSON, 36561 36562 // Parse text as xml 36563 "text xml": jQuery.parseXML 36564 }, 36565 36566 // For options that shouldn't be deep extended: 36567 // you can add your own custom options here if 36568 // and when you create one that shouldn't be 36569 // deep extended (see ajaxExtend) 36570 flatOptions: { 36571 url: true, 36572 context: true 36573 } 36574 }, 36575 36576 // Creates a full fledged settings object into target 36577 // with both ajaxSettings and settings fields. 36578 // If target is omitted, writes into ajaxSettings. 36579 ajaxSetup: function( target, settings ) { 36580 return settings ? 36581 36582 // Building a settings object 36583 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 36584 36585 // Extending ajaxSettings 36586 ajaxExtend( jQuery.ajaxSettings, target ); 36587 }, 36588 36589 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 36590 ajaxTransport: addToPrefiltersOrTransports( transports ), 36591 36592 // Main method 36593 ajax: function( url, options ) { 36594 36595 // If url is an object, simulate pre-1.5 signature 36596 if ( typeof url === "object" ) { 36597 options = url; 36598 url = undefined; 36599 } 36600 36601 // Force options to be an object 36602 options = options || {}; 36603 36604 var transport, 36605 36606 // URL without anti-cache param 36607 cacheURL, 36608 36609 // Response headers 36610 responseHeadersString, 36611 responseHeaders, 36612 36613 // timeout handle 36614 timeoutTimer, 36615 36616 // Url cleanup var 36617 urlAnchor, 36618 36619 // To know if global events are to be dispatched 36620 fireGlobals, 36621 36622 // Loop variable 36623 i, 36624 36625 // Create the final options object 36626 s = jQuery.ajaxSetup( {}, options ), 36627 36628 // Callbacks context 36629 callbackContext = s.context || s, 36630 36631 // Context for global events is callbackContext if it is a DOM node or jQuery collection 36632 globalEventContext = s.context && 36633 ( callbackContext.nodeType || callbackContext.jquery ) ? 36634 jQuery( callbackContext ) : 36635 jQuery.event, 36636 36637 // Deferreds 36638 deferred = jQuery.Deferred(), 36639 completeDeferred = jQuery.Callbacks( "once memory" ), 36640 36641 // Status-dependent callbacks 36642 statusCode = s.statusCode || {}, 36643 36644 // Headers (they are sent all at once) 36645 requestHeaders = {}, 36646 requestHeadersNames = {}, 36647 36648 // The jqXHR state 36649 state = 0, 36650 36651 // Default abort message 36652 strAbort = "canceled", 36653 36654 // Fake xhr 36655 jqXHR = { 36656 readyState: 0, 36657 36658 // Builds headers hashtable if needed 36659 getResponseHeader: function( key ) { 36660 var match; 36661 if ( state === 2 ) { 36662 if ( !responseHeaders ) { 36663 responseHeaders = {}; 36664 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 36665 responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; 36666 } 36667 } 36668 match = responseHeaders[ key.toLowerCase() ]; 36669 } 36670 return match == null ? null : match; 36671 }, 36672 36673 // Raw string 36674 getAllResponseHeaders: function() { 36675 return state === 2 ? responseHeadersString : null; 36676 }, 36677 36678 // Caches the header 36679 setRequestHeader: function( name, value ) { 36680 var lname = name.toLowerCase(); 36681 if ( !state ) { 36682 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; 36683 requestHeaders[ name ] = value; 36684 } 36685 return this; 36686 }, 36687 36688 // Overrides response content-type header 36689 overrideMimeType: function( type ) { 36690 if ( !state ) { 36691 s.mimeType = type; 36692 } 36693 return this; 36694 }, 36695 36696 // Status-dependent callbacks 36697 statusCode: function( map ) { 36698 var code; 36699 if ( map ) { 36700 if ( state < 2 ) { 36701 for ( code in map ) { 36702 36703 // Lazy-add the new callback in a way that preserves old ones 36704 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 36705 } 36706 } else { 36707 36708 // Execute the appropriate callbacks 36709 jqXHR.always( map[ jqXHR.status ] ); 36710 } 36711 } 36712 return this; 36713 }, 36714 36715 // Cancel the request 36716 abort: function( statusText ) { 36717 var finalText = statusText || strAbort; 36718 if ( transport ) { 36719 transport.abort( finalText ); 36720 } 36721 done( 0, finalText ); 36722 return this; 36723 } 36724 }; 36725 36726 // Attach deferreds 36727 deferred.promise( jqXHR ).complete = completeDeferred.add; 36728 jqXHR.success = jqXHR.done; 36729 jqXHR.error = jqXHR.fail; 36730 36731 // Remove hash character (#7531: and string promotion) 36732 // Add protocol if not provided (prefilters might expect it) 36733 // Handle falsy url in the settings object (#10093: consistency with old signature) 36734 // We also use the url parameter if available 36735 s.url = ( ( url || s.url || location.href ) + "" ).replace( rhash, "" ) 36736 .replace( rprotocol, location.protocol + "//" ); 36737 36738 // Alias method option to type as per ticket #12004 36739 s.type = options.method || options.type || s.method || s.type; 36740 36741 // Extract dataTypes list 36742 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; 36743 36744 // A cross-domain request is in order when the origin doesn't match the current origin. 36745 if ( s.crossDomain == null ) { 36746 urlAnchor = document.createElement( "a" ); 36747 36748 // Support: IE8-11+ 36749 // IE throws exception if url is malformed, e.g. http://example.com:80x/ 36750 try { 36751 urlAnchor.href = s.url; 36752 36753 // Support: IE8-11+ 36754 // Anchor's host property isn't correctly set when s.url is relative 36755 urlAnchor.href = urlAnchor.href; 36756 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== 36757 urlAnchor.protocol + "//" + urlAnchor.host; 36758 } catch ( e ) { 36759 36760 // If there is an error parsing the URL, assume it is crossDomain, 36761 // it can be rejected by the transport if it is invalid 36762 s.crossDomain = true; 36763 } 36764 } 36765 36766 // Convert data if not already a string 36767 if ( s.data && s.processData && typeof s.data !== "string" ) { 36768 s.data = jQuery.param( s.data, s.traditional ); 36769 } 36770 36771 // Apply prefilters 36772 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 36773 36774 // If request was aborted inside a prefilter, stop there 36775 if ( state === 2 ) { 36776 return jqXHR; 36777 } 36778 36779 // We can fire global events as of now if asked to 36780 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) 36781 fireGlobals = jQuery.event && s.global; 36782 36783 // Watch for a new set of requests 36784 if ( fireGlobals && jQuery.active++ === 0 ) { 36785 jQuery.event.trigger( "ajaxStart" ); 36786 } 36787 36788 // Uppercase the type 36789 s.type = s.type.toUpperCase(); 36790 36791 // Determine if request has content 36792 s.hasContent = !rnoContent.test( s.type ); 36793 36794 // Save the URL in case we're toying with the If-Modified-Since 36795 // and/or If-None-Match header later on 36796 cacheURL = s.url; 36797 36798 // More options handling for requests with no content 36799 if ( !s.hasContent ) { 36800 36801 // If data is available, append data to url 36802 if ( s.data ) { 36803 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); 36804 36805 // #9682: remove data so that it's not used in an eventual retry 36806 delete s.data; 36807 } 36808 36809 // Add anti-cache in url if needed 36810 if ( s.cache === false ) { 36811 s.url = rts.test( cacheURL ) ? 36812 36813 // If there is already a '_' parameter, set its value 36814 cacheURL.replace( rts, "$1_=" + nonce++ ) : 36815 36816 // Otherwise add one to the end 36817 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; 36818 } 36819 } 36820 36821 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 36822 if ( s.ifModified ) { 36823 if ( jQuery.lastModified[ cacheURL ] ) { 36824 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 36825 } 36826 if ( jQuery.etag[ cacheURL ] ) { 36827 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 36828 } 36829 } 36830 36831 // Set the correct header, if data is being sent 36832 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 36833 jqXHR.setRequestHeader( "Content-Type", s.contentType ); 36834 } 36835 36836 // Set the Accepts header for the server, depending on the dataType 36837 jqXHR.setRequestHeader( 36838 "Accept", 36839 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 36840 s.accepts[ s.dataTypes[ 0 ] ] + 36841 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 36842 s.accepts[ "*" ] 36843 ); 36844 36845 // Check for headers option 36846 for ( i in s.headers ) { 36847 jqXHR.setRequestHeader( i, s.headers[ i ] ); 36848 } 36849 36850 // Allow custom headers/mimetypes and early abort 36851 if ( s.beforeSend && 36852 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { 36853 36854 // Abort if not done already and return 36855 return jqXHR.abort(); 36856 } 36857 36858 // Aborting is no longer a cancellation 36859 strAbort = "abort"; 36860 36861 // Install callbacks on deferreds 36862 for ( i in { success: 1, error: 1, complete: 1 } ) { 36863 jqXHR[ i ]( s[ i ] ); 36864 } 36865 36866 // Get transport 36867 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 36868 36869 // If no transport, we auto-abort 36870 if ( !transport ) { 36871 done( -1, "No Transport" ); 36872 } else { 36873 jqXHR.readyState = 1; 36874 36875 // Send global event 36876 if ( fireGlobals ) { 36877 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 36878 } 36879 36880 // If request was aborted inside ajaxSend, stop there 36881 if ( state === 2 ) { 36882 return jqXHR; 36883 } 36884 36885 // Timeout 36886 if ( s.async && s.timeout > 0 ) { 36887 timeoutTimer = window.setTimeout( function() { 36888 jqXHR.abort( "timeout" ); 36889 }, s.timeout ); 36890 } 36891 36892 try { 36893 state = 1; 36894 transport.send( requestHeaders, done ); 36895 } catch ( e ) { 36896 36897 // Propagate exception as error if not done 36898 if ( state < 2 ) { 36899 done( -1, e ); 36900 36901 // Simply rethrow otherwise 36902 } else { 36903 throw e; 36904 } 36905 } 36906 } 36907 36908 // Callback for when everything is done 36909 function done( status, nativeStatusText, responses, headers ) { 36910 var isSuccess, success, error, response, modified, 36911 statusText = nativeStatusText; 36912 36913 // Called once 36914 if ( state === 2 ) { 36915 return; 36916 } 36917 36918 // State is "done" now 36919 state = 2; 36920 36921 // Clear timeout if it exists 36922 if ( timeoutTimer ) { 36923 window.clearTimeout( timeoutTimer ); 36924 } 36925 36926 // Dereference transport for early garbage collection 36927 // (no matter how long the jqXHR object will be used) 36928 transport = undefined; 36929 36930 // Cache response headers 36931 responseHeadersString = headers || ""; 36932 36933 // Set readyState 36934 jqXHR.readyState = status > 0 ? 4 : 0; 36935 36936 // Determine if successful 36937 isSuccess = status >= 200 && status < 300 || status === 304; 36938 36939 // Get response data 36940 if ( responses ) { 36941 response = ajaxHandleResponses( s, jqXHR, responses ); 36942 } 36943 36944 // Convert no matter what (that way responseXXX fields are always set) 36945 response = ajaxConvert( s, response, jqXHR, isSuccess ); 36946 36947 // If successful, handle type chaining 36948 if ( isSuccess ) { 36949 36950 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 36951 if ( s.ifModified ) { 36952 modified = jqXHR.getResponseHeader( "Last-Modified" ); 36953 if ( modified ) { 36954 jQuery.lastModified[ cacheURL ] = modified; 36955 } 36956 modified = jqXHR.getResponseHeader( "etag" ); 36957 if ( modified ) { 36958 jQuery.etag[ cacheURL ] = modified; 36959 } 36960 } 36961 36962 // if no content 36963 if ( status === 204 || s.type === "HEAD" ) { 36964 statusText = "nocontent"; 36965 36966 // if not modified 36967 } else if ( status === 304 ) { 36968 statusText = "notmodified"; 36969 36970 // If we have data, let's convert it 36971 } else { 36972 statusText = response.state; 36973 success = response.data; 36974 error = response.error; 36975 isSuccess = !error; 36976 } 36977 } else { 36978 36979 // Extract error from statusText and normalize for non-aborts 36980 error = statusText; 36981 if ( status || !statusText ) { 36982 statusText = "error"; 36983 if ( status < 0 ) { 36984 status = 0; 36985 } 36986 } 36987 } 36988 36989 // Set data for the fake xhr object 36990 jqXHR.status = status; 36991 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 36992 36993 // Success/Error 36994 if ( isSuccess ) { 36995 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 36996 } else { 36997 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 36998 } 36999 37000 // Status-dependent callbacks 37001 jqXHR.statusCode( statusCode ); 37002 statusCode = undefined; 37003 37004 if ( fireGlobals ) { 37005 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 37006 [ jqXHR, s, isSuccess ? success : error ] ); 37007 } 37008 37009 // Complete 37010 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 37011 37012 if ( fireGlobals ) { 37013 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 37014 37015 // Handle the global AJAX counter 37016 if ( !( --jQuery.active ) ) { 37017 jQuery.event.trigger( "ajaxStop" ); 37018 } 37019 } 37020 } 37021 37022 return jqXHR; 37023 }, 37024 37025 getJSON: function( url, data, callback ) { 37026 return jQuery.get( url, data, callback, "json" ); 37027 }, 37028 37029 getScript: function( url, callback ) { 37030 return jQuery.get( url, undefined, callback, "script" ); 37031 } 37032 } ); 37033 37034 jQuery.each( [ "get", "post" ], function( i, method ) { 37035 jQuery[ method ] = function( url, data, callback, type ) { 37036 37037 // Shift arguments if data argument was omitted 37038 if ( jQuery.isFunction( data ) ) { 37039 type = type || callback; 37040 callback = data; 37041 data = undefined; 37042 } 37043 37044 // The url can be an options object (which then must have .url) 37045 return jQuery.ajax( jQuery.extend( { 37046 url: url, 37047 type: method, 37048 dataType: type, 37049 data: data, 37050 success: callback 37051 }, jQuery.isPlainObject( url ) && url ) ); 37052 }; 37053 } ); 37054 37055 37056 jQuery._evalUrl = function( url ) { 37057 return jQuery.ajax( { 37058 url: url, 37059 37060 // Make this explicit, since user can override this through ajaxSetup (#11264) 37061 type: "GET", 37062 dataType: "script", 37063 async: false, 37064 global: false, 37065 "throws": true 37066 } ); 37067 }; 37068 37069 37070 jQuery.fn.extend( { 37071 wrapAll: function( html ) { 37072 var wrap; 37073 37074 if ( jQuery.isFunction( html ) ) { 37075 return this.each( function( i ) { 37076 jQuery( this ).wrapAll( html.call( this, i ) ); 37077 } ); 37078 } 37079 37080 if ( this[ 0 ] ) { 37081 37082 // The elements to wrap the target around 37083 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 37084 37085 if ( this[ 0 ].parentNode ) { 37086 wrap.insertBefore( this[ 0 ] ); 37087 } 37088 37089 wrap.map( function() { 37090 var elem = this; 37091 37092 while ( elem.firstElementChild ) { 37093 elem = elem.firstElementChild; 37094 } 37095 37096 return elem; 37097 } ).append( this ); 37098 } 37099 37100 return this; 37101 }, 37102 37103 wrapInner: function( html ) { 37104 if ( jQuery.isFunction( html ) ) { 37105 return this.each( function( i ) { 37106 jQuery( this ).wrapInner( html.call( this, i ) ); 37107 } ); 37108 } 37109 37110 return this.each( function() { 37111 var self = jQuery( this ), 37112 contents = self.contents(); 37113 37114 if ( contents.length ) { 37115 contents.wrapAll( html ); 37116 37117 } else { 37118 self.append( html ); 37119 } 37120 } ); 37121 }, 37122 37123 wrap: function( html ) { 37124 var isFunction = jQuery.isFunction( html ); 37125 37126 return this.each( function( i ) { 37127 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html ); 37128 } ); 37129 }, 37130 37131 unwrap: function() { 37132 return this.parent().each( function() { 37133 if ( !jQuery.nodeName( this, "body" ) ) { 37134 jQuery( this ).replaceWith( this.childNodes ); 37135 } 37136 } ).end(); 37137 } 37138 } ); 37139 37140 37141 jQuery.expr.filters.hidden = function( elem ) { 37142 return !jQuery.expr.filters.visible( elem ); 37143 }; 37144 jQuery.expr.filters.visible = function( elem ) { 37145 37146 // Support: Opera <= 12.12 37147 // Opera reports offsetWidths and offsetHeights less than zero on some elements 37148 // Use OR instead of AND as the element is not visible if either is true 37149 // See tickets #10406 and #13132 37150 return elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0; 37151 }; 37152 37153 37154 37155 37156 var r20 = /%20/g, 37157 rbracket = /\[\]$/, 37158 rCRLF = /\r?\n/g, 37159 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 37160 rsubmittable = /^(?:input|select|textarea|keygen)/i; 37161 37162 function buildParams( prefix, obj, traditional, add ) { 37163 var name; 37164 37165 if ( jQuery.isArray( obj ) ) { 37166 37167 // Serialize array item. 37168 jQuery.each( obj, function( i, v ) { 37169 if ( traditional || rbracket.test( prefix ) ) { 37170 37171 // Treat each array item as a scalar. 37172 add( prefix, v ); 37173 37174 } else { 37175 37176 // Item is non-scalar (array or object), encode its numeric index. 37177 buildParams( 37178 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 37179 v, 37180 traditional, 37181 add 37182 ); 37183 } 37184 } ); 37185 37186 } else if ( !traditional && jQuery.type( obj ) === "object" ) { 37187 37188 // Serialize object item. 37189 for ( name in obj ) { 37190 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 37191 } 37192 37193 } else { 37194 37195 // Serialize scalar item. 37196 add( prefix, obj ); 37197 } 37198 } 37199 37200 // Serialize an array of form elements or a set of 37201 // key/values into a query string 37202 jQuery.param = function( a, traditional ) { 37203 var prefix, 37204 s = [], 37205 add = function( key, value ) { 37206 37207 // If value is a function, invoke it and return its value 37208 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); 37209 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); 37210 }; 37211 37212 // Set traditional to true for jQuery <= 1.3.2 behavior. 37213 if ( traditional === undefined ) { 37214 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; 37215 } 37216 37217 // If an array was passed in, assume that it is an array of form elements. 37218 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 37219 37220 // Serialize the form elements 37221 jQuery.each( a, function() { 37222 add( this.name, this.value ); 37223 } ); 37224 37225 } else { 37226 37227 // If traditional, encode the "old" way (the way 1.3.2 or older 37228 // did it), otherwise encode params recursively. 37229 for ( prefix in a ) { 37230 buildParams( prefix, a[ prefix ], traditional, add ); 37231 } 37232 } 37233 37234 // Return the resulting serialization 37235 return s.join( "&" ).replace( r20, "+" ); 37236 }; 37237 37238 jQuery.fn.extend( { 37239 serialize: function() { 37240 return jQuery.param( this.serializeArray() ); 37241 }, 37242 serializeArray: function() { 37243 return this.map( function() { 37244 37245 // Can add propHook for "elements" to filter or add form elements 37246 var elements = jQuery.prop( this, "elements" ); 37247 return elements ? jQuery.makeArray( elements ) : this; 37248 } ) 37249 .filter( function() { 37250 var type = this.type; 37251 37252 // Use .is( ":disabled" ) so that fieldset[disabled] works 37253 return this.name && !jQuery( this ).is( ":disabled" ) && 37254 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 37255 ( this.checked || !rcheckableType.test( type ) ); 37256 } ) 37257 .map( function( i, elem ) { 37258 var val = jQuery( this ).val(); 37259 37260 return val == null ? 37261 null : 37262 jQuery.isArray( val ) ? 37263 jQuery.map( val, function( val ) { 37264 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 37265 } ) : 37266 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 37267 } ).get(); 37268 } 37269 } ); 37270 37271 37272 jQuery.ajaxSettings.xhr = function() { 37273 try { 37274 return new window.XMLHttpRequest(); 37275 } catch ( e ) {} 37276 }; 37277 37278 var xhrSuccessStatus = { 37279 37280 // File protocol always yields status code 0, assume 200 37281 0: 200, 37282 37283 // Support: IE9 37284 // #1450: sometimes IE returns 1223 when it should be 204 37285 1223: 204 37286 }, 37287 xhrSupported = jQuery.ajaxSettings.xhr(); 37288 37289 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 37290 support.ajax = xhrSupported = !!xhrSupported; 37291 37292 jQuery.ajaxTransport( function( options ) { 37293 var callback, errorCallback; 37294 37295 // Cross domain only allowed if supported through XMLHttpRequest 37296 if ( support.cors || xhrSupported && !options.crossDomain ) { 37297 return { 37298 send: function( headers, complete ) { 37299 var i, 37300 xhr = options.xhr(); 37301 37302 xhr.open( 37303 options.type, 37304 options.url, 37305 options.async, 37306 options.username, 37307 options.password 37308 ); 37309 37310 // Apply custom fields if provided 37311 if ( options.xhrFields ) { 37312 for ( i in options.xhrFields ) { 37313 xhr[ i ] = options.xhrFields[ i ]; 37314 } 37315 } 37316 37317 // Override mime type if needed 37318 if ( options.mimeType && xhr.overrideMimeType ) { 37319 xhr.overrideMimeType( options.mimeType ); 37320 } 37321 37322 // X-Requested-With header 37323 // For cross-domain requests, seeing as conditions for a preflight are 37324 // akin to a jigsaw puzzle, we simply never set it to be sure. 37325 // (it can always be set on a per-request basis or even using ajaxSetup) 37326 // For same-domain requests, won't change header if already provided. 37327 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 37328 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 37329 } 37330 37331 // Set headers 37332 for ( i in headers ) { 37333 xhr.setRequestHeader( i, headers[ i ] ); 37334 } 37335 37336 // Callback 37337 callback = function( type ) { 37338 return function() { 37339 if ( callback ) { 37340 callback = errorCallback = xhr.onload = 37341 xhr.onerror = xhr.onabort = xhr.onreadystatechange = null; 37342 37343 if ( type === "abort" ) { 37344 xhr.abort(); 37345 } else if ( type === "error" ) { 37346 37347 // Support: IE9 37348 // On a manual native abort, IE9 throws 37349 // errors on any property access that is not readyState 37350 if ( typeof xhr.status !== "number" ) { 37351 complete( 0, "error" ); 37352 } else { 37353 complete( 37354 37355 // File: protocol always yields status 0; see #8605, #14207 37356 xhr.status, 37357 xhr.statusText 37358 ); 37359 } 37360 } else { 37361 complete( 37362 xhrSuccessStatus[ xhr.status ] || xhr.status, 37363 xhr.statusText, 37364 37365 // Support: IE9 only 37366 // IE9 has no XHR2 but throws on binary (trac-11426) 37367 // For XHR2 non-text, let the caller handle it (gh-2498) 37368 ( xhr.responseType || "text" ) !== "text" || 37369 typeof xhr.responseText !== "string" ? 37370 { binary: xhr.response } : 37371 { text: xhr.responseText }, 37372 xhr.getAllResponseHeaders() 37373 ); 37374 } 37375 } 37376 }; 37377 }; 37378 37379 // Listen to events 37380 xhr.onload = callback(); 37381 errorCallback = xhr.onerror = callback( "error" ); 37382 37383 // Support: IE9 37384 // Use onreadystatechange to replace onabort 37385 // to handle uncaught aborts 37386 if ( xhr.onabort !== undefined ) { 37387 xhr.onabort = errorCallback; 37388 } else { 37389 xhr.onreadystatechange = function() { 37390 37391 // Check readyState before timeout as it changes 37392 if ( xhr.readyState === 4 ) { 37393 37394 // Allow onerror to be called first, 37395 // but that will not handle a native abort 37396 // Also, save errorCallback to a variable 37397 // as xhr.onerror cannot be accessed 37398 window.setTimeout( function() { 37399 if ( callback ) { 37400 errorCallback(); 37401 } 37402 } ); 37403 } 37404 }; 37405 } 37406 37407 // Create the abort callback 37408 callback = callback( "abort" ); 37409 37410 try { 37411 37412 // Do send the request (this may raise an exception) 37413 xhr.send( options.hasContent && options.data || null ); 37414 } catch ( e ) { 37415 37416 // #14683: Only rethrow if this hasn't been notified as an error yet 37417 if ( callback ) { 37418 throw e; 37419 } 37420 } 37421 }, 37422 37423 abort: function() { 37424 if ( callback ) { 37425 callback(); 37426 } 37427 } 37428 }; 37429 } 37430 } ); 37431 37432 37433 37434 37435 // Install script dataType 37436 jQuery.ajaxSetup( { 37437 accepts: { 37438 script: "text/javascript, application/javascript, " + 37439 "application/ecmascript, application/x-ecmascript" 37440 }, 37441 contents: { 37442 script: /\b(?:java|ecma)script\b/ 37443 }, 37444 converters: { 37445 "text script": function( text ) { 37446 jQuery.globalEval( text ); 37447 return text; 37448 } 37449 } 37450 } ); 37451 37452 // Handle cache's special case and crossDomain 37453 jQuery.ajaxPrefilter( "script", function( s ) { 37454 if ( s.cache === undefined ) { 37455 s.cache = false; 37456 } 37457 if ( s.crossDomain ) { 37458 s.type = "GET"; 37459 } 37460 } ); 37461 37462 // Bind script tag hack transport 37463 jQuery.ajaxTransport( "script", function( s ) { 37464 37465 // This transport only deals with cross domain requests 37466 if ( s.crossDomain ) { 37467 var script, callback; 37468 return { 37469 send: function( _, complete ) { 37470 script = jQuery( "<script>" ).prop( { 37471 charset: s.scriptCharset, 37472 src: s.url 37473 } ).on( 37474 "load error", 37475 callback = function( evt ) { 37476 script.remove(); 37477 callback = null; 37478 if ( evt ) { 37479 complete( evt.type === "error" ? 404 : 200, evt.type ); 37480 } 37481 } 37482 ); 37483 37484 // Use native DOM manipulation to avoid our domManip AJAX trickery 37485 document.head.appendChild( script[ 0 ] ); 37486 }, 37487 abort: function() { 37488 if ( callback ) { 37489 callback(); 37490 } 37491 } 37492 }; 37493 } 37494 } ); 37495 37496 37497 37498 37499 var oldCallbacks = [], 37500 rjsonp = /(=)\?(?=&|$)|\?\?/; 37501 37502 // Default jsonp settings 37503 jQuery.ajaxSetup( { 37504 jsonp: "callback", 37505 jsonpCallback: function() { 37506 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 37507 this[ callback ] = true; 37508 return callback; 37509 } 37510 } ); 37511 37512 // Detect, normalize options and install callbacks for jsonp requests 37513 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 37514 37515 var callbackName, overwritten, responseContainer, 37516 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 37517 "url" : 37518 typeof s.data === "string" && 37519 ( s.contentType || "" ) 37520 .indexOf( "application/x-www-form-urlencoded" ) === 0 && 37521 rjsonp.test( s.data ) && "data" 37522 ); 37523 37524 // Handle iff the expected data type is "jsonp" or we have a parameter to set 37525 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 37526 37527 // Get callback name, remembering preexisting value associated with it 37528 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? 37529 s.jsonpCallback() : 37530 s.jsonpCallback; 37531 37532 // Insert callback into url or form data 37533 if ( jsonProp ) { 37534 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 37535 } else if ( s.jsonp !== false ) { 37536 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 37537 } 37538 37539 // Use data converter to retrieve json after script execution 37540 s.converters[ "script json" ] = function() { 37541 if ( !responseContainer ) { 37542 jQuery.error( callbackName + " was not called" ); 37543 } 37544 return responseContainer[ 0 ]; 37545 }; 37546 37547 // Force json dataType 37548 s.dataTypes[ 0 ] = "json"; 37549 37550 // Install callback 37551 overwritten = window[ callbackName ]; 37552 window[ callbackName ] = function() { 37553 responseContainer = arguments; 37554 }; 37555 37556 // Clean-up function (fires after converters) 37557 jqXHR.always( function() { 37558 37559 // If previous value didn't exist - remove it 37560 if ( overwritten === undefined ) { 37561 jQuery( window ).removeProp( callbackName ); 37562 37563 // Otherwise restore preexisting value 37564 } else { 37565 window[ callbackName ] = overwritten; 37566 } 37567 37568 // Save back as free 37569 if ( s[ callbackName ] ) { 37570 37571 // Make sure that re-using the options doesn't screw things around 37572 s.jsonpCallback = originalSettings.jsonpCallback; 37573 37574 // Save the callback name for future use 37575 oldCallbacks.push( callbackName ); 37576 } 37577 37578 // Call if it was a function and we have a response 37579 if ( responseContainer && jQuery.isFunction( overwritten ) ) { 37580 overwritten( responseContainer[ 0 ] ); 37581 } 37582 37583 responseContainer = overwritten = undefined; 37584 } ); 37585 37586 // Delegate to script 37587 return "script"; 37588 } 37589 } ); 37590 37591 37592 37593 37594 // Argument "data" should be string of html 37595 // context (optional): If specified, the fragment will be created in this context, 37596 // defaults to document 37597 // keepScripts (optional): If true, will include scripts passed in the html string 37598 jQuery.parseHTML = function( data, context, keepScripts ) { 37599 if ( !data || typeof data !== "string" ) { 37600 return null; 37601 } 37602 if ( typeof context === "boolean" ) { 37603 keepScripts = context; 37604 context = false; 37605 } 37606 context = context || document; 37607 37608 var parsed = rsingleTag.exec( data ), 37609 scripts = !keepScripts && []; 37610 37611 // Single tag 37612 if ( parsed ) { 37613 return [ context.createElement( parsed[ 1 ] ) ]; 37614 } 37615 37616 parsed = buildFragment( [ data ], context, scripts ); 37617 37618 if ( scripts && scripts.length ) { 37619 jQuery( scripts ).remove(); 37620 } 37621 37622 return jQuery.merge( [], parsed.childNodes ); 37623 }; 37624 37625 37626 // Keep a copy of the old load method 37627 var _load = jQuery.fn.load; 37628 37629 /** 37630 * Load a url into a page 37631 */ 37632 jQuery.fn.load = function( url, params, callback ) { 37633 if ( typeof url !== "string" && _load ) { 37634 return _load.apply( this, arguments ); 37635 } 37636 37637 var selector, type, response, 37638 self = this, 37639 off = url.indexOf( " " ); 37640 37641 if ( off > -1 ) { 37642 selector = jQuery.trim( url.slice( off ) ); 37643 url = url.slice( 0, off ); 37644 } 37645 37646 // If it's a function 37647 if ( jQuery.isFunction( params ) ) { 37648 37649 // We assume that it's the callback 37650 callback = params; 37651 params = undefined; 37652 37653 // Otherwise, build a param string 37654 } else if ( params && typeof params === "object" ) { 37655 type = "POST"; 37656 } 37657 37658 // If we have elements to modify, make the request 37659 if ( self.length > 0 ) { 37660 jQuery.ajax( { 37661 url: url, 37662 37663 // If "type" variable is undefined, then "GET" method will be used. 37664 // Make value of this field explicit since 37665 // user can override it through ajaxSetup method 37666 type: type || "GET", 37667 dataType: "html", 37668 data: params 37669 } ).done( function( responseText ) { 37670 37671 // Save response for use in complete callback 37672 response = arguments; 37673 37674 self.html( selector ? 37675 37676 // If a selector was specified, locate the right elements in a dummy div 37677 // Exclude scripts to avoid IE 'Permission Denied' errors 37678 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 37679 37680 // Otherwise use the full result 37681 responseText ); 37682 37683 // If the request succeeds, this function gets "data", "status", "jqXHR" 37684 // but they are ignored because response was set above. 37685 // If it fails, this function gets "jqXHR", "status", "error" 37686 } ).always( callback && function( jqXHR, status ) { 37687 self.each( function() { 37688 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 37689 } ); 37690 } ); 37691 } 37692 37693 return this; 37694 }; 37695 37696 37697 37698 37699 // Attach a bunch of functions for handling common AJAX events 37700 jQuery.each( [ 37701 "ajaxStart", 37702 "ajaxStop", 37703 "ajaxComplete", 37704 "ajaxError", 37705 "ajaxSuccess", 37706 "ajaxSend" 37707 ], function( i, type ) { 37708 jQuery.fn[ type ] = function( fn ) { 37709 return this.on( type, fn ); 37710 }; 37711 } ); 37712 37713 37714 37715 37716 jQuery.expr.filters.animated = function( elem ) { 37717 return jQuery.grep( jQuery.timers, function( fn ) { 37718 return elem === fn.elem; 37719 } ).length; 37720 }; 37721 37722 37723 37724 37725 /** 37726 * Gets a window from an element 37727 */ 37728 function getWindow( elem ) { 37729 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; 37730 } 37731 37732 jQuery.offset = { 37733 setOffset: function( elem, options, i ) { 37734 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 37735 position = jQuery.css( elem, "position" ), 37736 curElem = jQuery( elem ), 37737 props = {}; 37738 37739 // Set position first, in-case top/left are set even on static elem 37740 if ( position === "static" ) { 37741 elem.style.position = "relative"; 37742 } 37743 37744 curOffset = curElem.offset(); 37745 curCSSTop = jQuery.css( elem, "top" ); 37746 curCSSLeft = jQuery.css( elem, "left" ); 37747 calculatePosition = ( position === "absolute" || position === "fixed" ) && 37748 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; 37749 37750 // Need to be able to calculate position if either 37751 // top or left is auto and position is either absolute or fixed 37752 if ( calculatePosition ) { 37753 curPosition = curElem.position(); 37754 curTop = curPosition.top; 37755 curLeft = curPosition.left; 37756 37757 } else { 37758 curTop = parseFloat( curCSSTop ) || 0; 37759 curLeft = parseFloat( curCSSLeft ) || 0; 37760 } 37761 37762 if ( jQuery.isFunction( options ) ) { 37763 37764 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 37765 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 37766 } 37767 37768 if ( options.top != null ) { 37769 props.top = ( options.top - curOffset.top ) + curTop; 37770 } 37771 if ( options.left != null ) { 37772 props.left = ( options.left - curOffset.left ) + curLeft; 37773 } 37774 37775 if ( "using" in options ) { 37776 options.using.call( elem, props ); 37777 37778 } else { 37779 curElem.css( props ); 37780 } 37781 } 37782 }; 37783 37784 jQuery.fn.extend( { 37785 offset: function( options ) { 37786 if ( arguments.length ) { 37787 return options === undefined ? 37788 this : 37789 this.each( function( i ) { 37790 jQuery.offset.setOffset( this, options, i ); 37791 } ); 37792 } 37793 37794 var docElem, win, 37795 elem = this[ 0 ], 37796 box = { top: 0, left: 0 }, 37797 doc = elem && elem.ownerDocument; 37798 37799 if ( !doc ) { 37800 return; 37801 } 37802 37803 docElem = doc.documentElement; 37804 37805 // Make sure it's not a disconnected DOM node 37806 if ( !jQuery.contains( docElem, elem ) ) { 37807 return box; 37808 } 37809 37810 box = elem.getBoundingClientRect(); 37811 win = getWindow( doc ); 37812 return { 37813 top: box.top + win.pageYOffset - docElem.clientTop, 37814 left: box.left + win.pageXOffset - docElem.clientLeft 37815 }; 37816 }, 37817 37818 position: function() { 37819 if ( !this[ 0 ] ) { 37820 return; 37821 } 37822 37823 var offsetParent, offset, 37824 elem = this[ 0 ], 37825 parentOffset = { top: 0, left: 0 }; 37826 37827 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, 37828 // because it is its only offset parent 37829 if ( jQuery.css( elem, "position" ) === "fixed" ) { 37830 37831 // Assume getBoundingClientRect is there when computed position is fixed 37832 offset = elem.getBoundingClientRect(); 37833 37834 } else { 37835 37836 // Get *real* offsetParent 37837 offsetParent = this.offsetParent(); 37838 37839 // Get correct offsets 37840 offset = this.offset(); 37841 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { 37842 parentOffset = offsetParent.offset(); 37843 } 37844 37845 // Add offsetParent borders 37846 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); 37847 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); 37848 } 37849 37850 // Subtract parent offsets and element margins 37851 return { 37852 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 37853 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 37854 }; 37855 }, 37856 37857 // This method will return documentElement in the following cases: 37858 // 1) For the element inside the iframe without offsetParent, this method will return 37859 // documentElement of the parent window 37860 // 2) For the hidden or detached element 37861 // 3) For body or html element, i.e. in case of the html node - it will return itself 37862 // 37863 // but those exceptions were never presented as a real life use-cases 37864 // and might be considered as more preferable results. 37865 // 37866 // This logic, however, is not guaranteed and can change at any point in the future 37867 offsetParent: function() { 37868 return this.map( function() { 37869 var offsetParent = this.offsetParent; 37870 37871 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { 37872 offsetParent = offsetParent.offsetParent; 37873 } 37874 37875 return offsetParent || documentElement; 37876 } ); 37877 } 37878 } ); 37879 37880 // Create scrollLeft and scrollTop methods 37881 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 37882 var top = "pageYOffset" === prop; 37883 37884 jQuery.fn[ method ] = function( val ) { 37885 return access( this, function( elem, method, val ) { 37886 var win = getWindow( elem ); 37887 37888 if ( val === undefined ) { 37889 return win ? win[ prop ] : elem[ method ]; 37890 } 37891 37892 if ( win ) { 37893 win.scrollTo( 37894 !top ? val : win.pageXOffset, 37895 top ? val : win.pageYOffset 37896 ); 37897 37898 } else { 37899 elem[ method ] = val; 37900 } 37901 }, method, val, arguments.length ); 37902 }; 37903 } ); 37904 37905 // Support: Safari<7-8+, Chrome<37-44+ 37906 // Add the top/left cssHooks using jQuery.fn.position 37907 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 37908 // Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280 37909 // getComputedStyle returns percent when specified for top/left/bottom/right; 37910 // rather than make the css module depend on the offset module, just check for it here 37911 jQuery.each( [ "top", "left" ], function( i, prop ) { 37912 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 37913 function( elem, computed ) { 37914 if ( computed ) { 37915 computed = curCSS( elem, prop ); 37916 37917 // If curCSS returns percentage, fallback to offset 37918 return rnumnonpx.test( computed ) ? 37919 jQuery( elem ).position()[ prop ] + "px" : 37920 computed; 37921 } 37922 } 37923 ); 37924 } ); 37925 37926 37927 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 37928 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 37929 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, 37930 function( defaultExtra, funcName ) { 37931 37932 // Margin is only for outerHeight, outerWidth 37933 jQuery.fn[ funcName ] = function( margin, value ) { 37934 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 37935 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 37936 37937 return access( this, function( elem, type, value ) { 37938 var doc; 37939 37940 if ( jQuery.isWindow( elem ) ) { 37941 37942 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there 37943 // isn't a whole lot we can do. See pull request at this URL for discussion: 37944 // https://github.com/jquery/jquery/pull/764 37945 return elem.document.documentElement[ "client" + name ]; 37946 } 37947 37948 // Get document width or height 37949 if ( elem.nodeType === 9 ) { 37950 doc = elem.documentElement; 37951 37952 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 37953 // whichever is greatest 37954 return Math.max( 37955 elem.body[ "scroll" + name ], doc[ "scroll" + name ], 37956 elem.body[ "offset" + name ], doc[ "offset" + name ], 37957 doc[ "client" + name ] 37958 ); 37959 } 37960 37961 return value === undefined ? 37962 37963 // Get width or height on the element, requesting but not forcing parseFloat 37964 jQuery.css( elem, type, extra ) : 37965 37966 // Set width or height on the element 37967 jQuery.style( elem, type, value, extra ); 37968 }, type, chainable ? margin : undefined, chainable, null ); 37969 }; 37970 } ); 37971 } ); 37972 37973 37974 jQuery.fn.extend( { 37975 37976 bind: function( types, data, fn ) { 37977 return this.on( types, null, data, fn ); 37978 }, 37979 unbind: function( types, fn ) { 37980 return this.off( types, null, fn ); 37981 }, 37982 37983 delegate: function( selector, types, data, fn ) { 37984 return this.on( types, selector, data, fn ); 37985 }, 37986 undelegate: function( selector, types, fn ) { 37987 37988 // ( namespace ) or ( selector, types [, fn] ) 37989 return arguments.length === 1 ? 37990 this.off( selector, "**" ) : 37991 this.off( types, selector || "**", fn ); 37992 }, 37993 size: function() { 37994 return this.length; 37995 } 37996 } ); 37997 37998 jQuery.fn.andSelf = jQuery.fn.addBack; 37999 38000 38001 38002 38003 // Register as a named AMD module, since jQuery can be concatenated with other 38004 // files that may use define, but not via a proper concatenation script that 38005 // understands anonymous AMD modules. A named AMD is safest and most robust 38006 // way to register. Lowercase jquery is used because AMD module names are 38007 // derived from file names, and jQuery is normally delivered in a lowercase 38008 // file name. Do this after creating the global so that if an AMD module wants 38009 // to call noConflict to hide this version of jQuery, it will work. 38010 38011 // Note that for maximum portability, libraries that are not jQuery should 38012 // declare themselves as anonymous modules, and avoid setting a global if an 38013 // AMD loader is present. jQuery is a special case. For more information, see 38014 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 38015 38016 if ( true ) { 38017 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { 38018 return jQuery; 38019 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 38020 } 38021 38022 38023 38024 var 38025 38026 // Map over jQuery in case of overwrite 38027 _jQuery = window.jQuery, 38028 38029 // Map over the $ in case of overwrite 38030 _$ = window.$; 38031 38032 jQuery.noConflict = function( deep ) { 38033 if ( window.$ === jQuery ) { 38034 window.$ = _$; 38035 } 38036 38037 if ( deep && window.jQuery === jQuery ) { 38038 window.jQuery = _jQuery; 38039 } 38040 38041 return jQuery; 38042 }; 38043 38044 // Expose jQuery and $ identifiers, even in AMD 38045 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 38046 // and CommonJS for browser emulators (#13566) 38047 if ( !noGlobal ) { 38048 window.jQuery = window.$ = jQuery; 38049 } 38050 38051 return jQuery; 38052 })); 38053 38054 38055 /***/ }, 38056 /* 88 */ 38057 /***/ function(module, exports, __webpack_require__) { 38058 38059 'use strict'; 38060 38061 38062 var loader = __webpack_require__(90); 38063 var dumper = __webpack_require__(89); 38064 38065 38066 function deprecated(name) { 38067 return function () { 38068 throw new Error('Function ' + name + ' is deprecated and cannot be used.'); 38069 }; 38070 } 38071 38072 38073 module.exports.Type = __webpack_require__(3); 38074 module.exports.Schema = __webpack_require__(8); 38075 module.exports.FAILSAFE_SCHEMA = __webpack_require__(19); 38076 module.exports.JSON_SCHEMA = __webpack_require__(30); 38077 module.exports.CORE_SCHEMA = __webpack_require__(29); 38078 module.exports.DEFAULT_SAFE_SCHEMA = __webpack_require__(12); 38079 module.exports.DEFAULT_FULL_SCHEMA = __webpack_require__(15); 38080 module.exports.load = loader.load; 38081 module.exports.loadAll = loader.loadAll; 38082 module.exports.safeLoad = loader.safeLoad; 38083 module.exports.safeLoadAll = loader.safeLoadAll; 38084 module.exports.dump = dumper.dump; 38085 module.exports.safeDump = dumper.safeDump; 38086 module.exports.YAMLException = __webpack_require__(11); 38087 38088 // Deprecated schema names from JS-YAML 2.0.x 38089 module.exports.MINIMAL_SCHEMA = __webpack_require__(19); 38090 module.exports.SAFE_SCHEMA = __webpack_require__(12); 38091 module.exports.DEFAULT_SCHEMA = __webpack_require__(15); 38092 38093 // Deprecated functions from JS-YAML 1.x.x 38094 module.exports.scan = deprecated('scan'); 38095 module.exports.parse = deprecated('parse'); 38096 module.exports.compose = deprecated('compose'); 38097 module.exports.addConstructor = deprecated('addConstructor'); 38098 38099 38100 /***/ }, 38101 /* 89 */ 38102 /***/ function(module, exports, __webpack_require__) { 38103 38104 'use strict'; 38105 38106 /*eslint-disable no-use-before-define*/ 38107 38108 var common = __webpack_require__(7); 38109 var YAMLException = __webpack_require__(11); 38110 var DEFAULT_FULL_SCHEMA = __webpack_require__(15); 38111 var DEFAULT_SAFE_SCHEMA = __webpack_require__(12); 38112 38113 var _toString = Object.prototype.toString; 38114 var _hasOwnProperty = Object.prototype.hasOwnProperty; 38115 38116 var CHAR_TAB = 0x09; /* Tab */ 38117 var CHAR_LINE_FEED = 0x0A; /* LF */ 38118 var CHAR_SPACE = 0x20; /* Space */ 38119 var CHAR_EXCLAMATION = 0x21; /* ! */ 38120 var CHAR_DOUBLE_QUOTE = 0x22; /* " */ 38121 var CHAR_SHARP = 0x23; /* # */ 38122 var CHAR_PERCENT = 0x25; /* % */ 38123 var CHAR_AMPERSAND = 0x26; /* & */ 38124 var CHAR_SINGLE_QUOTE = 0x27; /* ' */ 38125 var CHAR_ASTERISK = 0x2A; /* * */ 38126 var CHAR_COMMA = 0x2C; /* , */ 38127 var CHAR_MINUS = 0x2D; /* - */ 38128 var CHAR_COLON = 0x3A; /* : */ 38129 var CHAR_GREATER_THAN = 0x3E; /* > */ 38130 var CHAR_QUESTION = 0x3F; /* ? */ 38131 var CHAR_COMMERCIAL_AT = 0x40; /* @ */ 38132 var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ 38133 var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ 38134 var CHAR_GRAVE_ACCENT = 0x60; /* ` */ 38135 var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ 38136 var CHAR_VERTICAL_LINE = 0x7C; /* | */ 38137 var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ 38138 38139 var ESCAPE_SEQUENCES = {}; 38140 38141 ESCAPE_SEQUENCES[0x00] = '\\0'; 38142 ESCAPE_SEQUENCES[0x07] = '\\a'; 38143 ESCAPE_SEQUENCES[0x08] = '\\b'; 38144 ESCAPE_SEQUENCES[0x09] = '\\t'; 38145 ESCAPE_SEQUENCES[0x0A] = '\\n'; 38146 ESCAPE_SEQUENCES[0x0B] = '\\v'; 38147 ESCAPE_SEQUENCES[0x0C] = '\\f'; 38148 ESCAPE_SEQUENCES[0x0D] = '\\r'; 38149 ESCAPE_SEQUENCES[0x1B] = '\\e'; 38150 ESCAPE_SEQUENCES[0x22] = '\\"'; 38151 ESCAPE_SEQUENCES[0x5C] = '\\\\'; 38152 ESCAPE_SEQUENCES[0x85] = '\\N'; 38153 ESCAPE_SEQUENCES[0xA0] = '\\_'; 38154 ESCAPE_SEQUENCES[0x2028] = '\\L'; 38155 ESCAPE_SEQUENCES[0x2029] = '\\P'; 38156 38157 var DEPRECATED_BOOLEANS_SYNTAX = [ 38158 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 38159 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' 38160 ]; 38161 38162 function compileStyleMap(schema, map) { 38163 var result, keys, index, length, tag, style, type; 38164 38165 if (map === null) return {}; 38166 38167 result = {}; 38168 keys = Object.keys(map); 38169 38170 for (index = 0, length = keys.length; index < length; index += 1) { 38171 tag = keys[index]; 38172 style = String(map[tag]); 38173 38174 if (tag.slice(0, 2) === '!!') { 38175 tag = 'tag:yaml.org,2002:' + tag.slice(2); 38176 } 38177 38178 type = schema.compiledTypeMap[tag]; 38179 38180 if (type && _hasOwnProperty.call(type.styleAliases, style)) { 38181 style = type.styleAliases[style]; 38182 } 38183 38184 result[tag] = style; 38185 } 38186 38187 return result; 38188 } 38189 38190 function encodeHex(character) { 38191 var string, handle, length; 38192 38193 string = character.toString(16).toUpperCase(); 38194 38195 if (character <= 0xFF) { 38196 handle = 'x'; 38197 length = 2; 38198 } else if (character <= 0xFFFF) { 38199 handle = 'u'; 38200 length = 4; 38201 } else if (character <= 0xFFFFFFFF) { 38202 handle = 'U'; 38203 length = 8; 38204 } else { 38205 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); 38206 } 38207 38208 return '\\' + handle + common.repeat('0', length - string.length) + string; 38209 } 38210 38211 function State(options) { 38212 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; 38213 this.indent = Math.max(1, (options['indent'] || 2)); 38214 this.skipInvalid = options['skipInvalid'] || false; 38215 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); 38216 this.styleMap = compileStyleMap(this.schema, options['styles'] || null); 38217 this.sortKeys = options['sortKeys'] || false; 38218 this.lineWidth = options['lineWidth'] || 80; 38219 this.noRefs = options['noRefs'] || false; 38220 this.noCompatMode = options['noCompatMode'] || false; 38221 38222 this.implicitTypes = this.schema.compiledImplicit; 38223 this.explicitTypes = this.schema.compiledExplicit; 38224 38225 this.tag = null; 38226 this.result = ''; 38227 38228 this.duplicates = []; 38229 this.usedDuplicates = null; 38230 } 38231 38232 // Indents every line in a string. Empty lines (\n only) are not indented. 38233 function indentString(string, spaces) { 38234 var ind = common.repeat(' ', spaces), 38235 position = 0, 38236 next = -1, 38237 result = '', 38238 line, 38239 length = string.length; 38240 38241 while (position < length) { 38242 next = string.indexOf('\n', position); 38243 if (next === -1) { 38244 line = string.slice(position); 38245 position = length; 38246 } else { 38247 line = string.slice(position, next + 1); 38248 position = next + 1; 38249 } 38250 38251 if (line.length && line !== '\n') result += ind; 38252 38253 result += line; 38254 } 38255 38256 return result; 38257 } 38258 38259 function generateNextLine(state, level) { 38260 return '\n' + common.repeat(' ', state.indent * level); 38261 } 38262 38263 function testImplicitResolving(state, str) { 38264 var index, length, type; 38265 38266 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { 38267 type = state.implicitTypes[index]; 38268 38269 if (type.resolve(str)) { 38270 return true; 38271 } 38272 } 38273 38274 return false; 38275 } 38276 38277 // [33] s-white ::= s-space | s-tab 38278 function isWhitespace(c) { 38279 return c === CHAR_SPACE || c === CHAR_TAB; 38280 } 38281 38282 // Returns true if the character can be printed without escaping. 38283 // From YAML 1.2: "any allowed characters known to be non-printable 38284 // should also be escaped. [However,] This isn’t mandatory" 38285 // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. 38286 function isPrintable(c) { 38287 return (0x00020 <= c && c <= 0x00007E) 38288 || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) 38289 || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */) 38290 || (0x10000 <= c && c <= 0x10FFFF); 38291 } 38292 38293 // Simplified test for values allowed after the first character in plain style. 38294 function isPlainSafe(c) { 38295 // Uses a subset of nb-char - c-flow-indicator - ":" - "#" 38296 // where nb-char ::= c-printable - b-char - c-byte-order-mark. 38297 return isPrintable(c) && c !== 0xFEFF 38298 // - c-flow-indicator 38299 && c !== CHAR_COMMA 38300 && c !== CHAR_LEFT_SQUARE_BRACKET 38301 && c !== CHAR_RIGHT_SQUARE_BRACKET 38302 && c !== CHAR_LEFT_CURLY_BRACKET 38303 && c !== CHAR_RIGHT_CURLY_BRACKET 38304 // - ":" - "#" 38305 && c !== CHAR_COLON 38306 && c !== CHAR_SHARP; 38307 } 38308 38309 // Simplified test for values allowed as the first character in plain style. 38310 function isPlainSafeFirst(c) { 38311 // Uses a subset of ns-char - c-indicator 38312 // where ns-char = nb-char - s-white. 38313 return isPrintable(c) && c !== 0xFEFF 38314 && !isWhitespace(c) // - s-white 38315 // - (c-indicator ::= 38316 // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” 38317 && c !== CHAR_MINUS 38318 && c !== CHAR_QUESTION 38319 && c !== CHAR_COLON 38320 && c !== CHAR_COMMA 38321 && c !== CHAR_LEFT_SQUARE_BRACKET 38322 && c !== CHAR_RIGHT_SQUARE_BRACKET 38323 && c !== CHAR_LEFT_CURLY_BRACKET 38324 && c !== CHAR_RIGHT_CURLY_BRACKET 38325 // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"” 38326 && c !== CHAR_SHARP 38327 && c !== CHAR_AMPERSAND 38328 && c !== CHAR_ASTERISK 38329 && c !== CHAR_EXCLAMATION 38330 && c !== CHAR_VERTICAL_LINE 38331 && c !== CHAR_GREATER_THAN 38332 && c !== CHAR_SINGLE_QUOTE 38333 && c !== CHAR_DOUBLE_QUOTE 38334 // | “%” | “@” | “`”) 38335 && c !== CHAR_PERCENT 38336 && c !== CHAR_COMMERCIAL_AT 38337 && c !== CHAR_GRAVE_ACCENT; 38338 } 38339 38340 var STYLE_PLAIN = 1, 38341 STYLE_SINGLE = 2, 38342 STYLE_LITERAL = 3, 38343 STYLE_FOLDED = 4, 38344 STYLE_DOUBLE = 5; 38345 38346 // Determines which scalar styles are possible and returns the preferred style. 38347 // lineWidth = -1 => no limit. 38348 // Pre-conditions: str.length > 0. 38349 // Post-conditions: 38350 // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. 38351 // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). 38352 // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). 38353 function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { 38354 var i; 38355 var char; 38356 var hasLineBreak = false; 38357 var hasFoldableLine = false; // only checked if shouldTrackWidth 38358 var shouldTrackWidth = lineWidth !== -1; 38359 var previousLineBreak = -1; // count the first line correctly 38360 var plain = isPlainSafeFirst(string.charCodeAt(0)) 38361 && !isWhitespace(string.charCodeAt(string.length - 1)); 38362 38363 if (singleLineOnly) { 38364 // Case: no block styles. 38365 // Check for disallowed characters to rule out plain and single. 38366 for (i = 0; i < string.length; i++) { 38367 char = string.charCodeAt(i); 38368 if (!isPrintable(char)) { 38369 return STYLE_DOUBLE; 38370 } 38371 plain = plain && isPlainSafe(char); 38372 } 38373 } else { 38374 // Case: block styles permitted. 38375 for (i = 0; i < string.length; i++) { 38376 char = string.charCodeAt(i); 38377 if (char === CHAR_LINE_FEED) { 38378 hasLineBreak = true; 38379 // Check if any line can be folded. 38380 if (shouldTrackWidth) { 38381 hasFoldableLine = hasFoldableLine || 38382 // Foldable line = too long, and not more-indented. 38383 (i - previousLineBreak - 1 > lineWidth && 38384 string[previousLineBreak + 1] !== ' '); 38385 previousLineBreak = i; 38386 } 38387 } else if (!isPrintable(char)) { 38388 return STYLE_DOUBLE; 38389 } 38390 plain = plain && isPlainSafe(char); 38391 } 38392 // in case the end is missing a \n 38393 hasFoldableLine = hasFoldableLine || (shouldTrackWidth && 38394 (i - previousLineBreak - 1 > lineWidth && 38395 string[previousLineBreak + 1] !== ' ')); 38396 } 38397 // Although every style can represent \n without escaping, prefer block styles 38398 // for multiline, since they're more readable and they don't add empty lines. 38399 // Also prefer folding a super-long line. 38400 if (!hasLineBreak && !hasFoldableLine) { 38401 // Strings interpretable as another type have to be quoted; 38402 // e.g. the string 'true' vs. the boolean true. 38403 return plain && !testAmbiguousType(string) 38404 ? STYLE_PLAIN : STYLE_SINGLE; 38405 } 38406 // Edge case: block indentation indicator can only have one digit. 38407 if (string[0] === ' ' && indentPerLevel > 9) { 38408 return STYLE_DOUBLE; 38409 } 38410 // At this point we know block styles are valid. 38411 // Prefer literal style unless we want to fold. 38412 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; 38413 } 38414 38415 // Note: line breaking/folding is implemented for only the folded style. 38416 // NB. We drop the last trailing newline (if any) of a returned block scalar 38417 // since the dumper adds its own newline. This always works: 38418 // • No ending newline => unaffected; already using strip "-" chomping. 38419 // • Ending newline => removed then restored. 38420 // Importantly, this keeps the "+" chomp indicator from gaining an extra line. 38421 function writeScalar(state, string, level, iskey) { 38422 state.dump = (function () { 38423 if (string.length === 0) { 38424 return "''"; 38425 } 38426 if (!state.noCompatMode && 38427 DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) { 38428 return "'" + string + "'"; 38429 } 38430 38431 var indent = state.indent * Math.max(1, level); // no 0-indent scalars 38432 // As indentation gets deeper, let the width decrease monotonically 38433 // to the lower bound min(state.lineWidth, 40). 38434 // Note that this implies 38435 // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. 38436 // state.lineWidth > 40 + state.indent: width decreases until the lower bound. 38437 // This behaves better than a constant minimum width which disallows narrower options, 38438 // or an indent threshold which causes the width to suddenly increase. 38439 var lineWidth = state.lineWidth === -1 38440 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); 38441 38442 // Without knowing if keys are implicit/explicit, assume implicit for safety. 38443 var singleLineOnly = iskey 38444 // No block styles in flow mode. 38445 || (state.flowLevel > -1 && level >= state.flowLevel); 38446 function testAmbiguity(string) { 38447 return testImplicitResolving(state, string); 38448 } 38449 38450 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) { 38451 case STYLE_PLAIN: 38452 return string; 38453 case STYLE_SINGLE: 38454 return "'" + string.replace(/'/g, "''") + "'"; 38455 case STYLE_LITERAL: 38456 return '|' + blockHeader(string, state.indent) 38457 + dropEndingNewline(indentString(string, indent)); 38458 case STYLE_FOLDED: 38459 return '>' + blockHeader(string, state.indent) 38460 + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); 38461 case STYLE_DOUBLE: 38462 return '"' + escapeString(string, lineWidth) + '"'; 38463 default: 38464 throw new YAMLException('impossible error: invalid scalar style'); 38465 } 38466 }()); 38467 } 38468 38469 // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. 38470 function blockHeader(string, indentPerLevel) { 38471 var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : ''; 38472 38473 // note the special case: the string '\n' counts as a "trailing" empty line. 38474 var clip = string[string.length - 1] === '\n'; 38475 var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); 38476 var chomp = keep ? '+' : (clip ? '' : '-'); 38477 38478 return indentIndicator + chomp + '\n'; 38479 } 38480 38481 // (See the note for writeScalar.) 38482 function dropEndingNewline(string) { 38483 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; 38484 } 38485 38486 // Note: a long line without a suitable break point will exceed the width limit. 38487 // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. 38488 function foldString(string, width) { 38489 // In folded style, $k$ consecutive newlines output as $k+1$ newlines— 38490 // unless they're before or after a more-indented line, or at the very 38491 // beginning or end, in which case $k$ maps to $k$. 38492 // Therefore, parse each chunk as newline(s) followed by a content line. 38493 var lineRe = /(\n+)([^\n]*)/g; 38494 38495 // first line (possibly an empty line) 38496 var result = (function () { 38497 var nextLF = string.indexOf('\n'); 38498 nextLF = nextLF !== -1 ? nextLF : string.length; 38499 lineRe.lastIndex = nextLF; 38500 return foldLine(string.slice(0, nextLF), width); 38501 }()); 38502 // If we haven't reached the first content line yet, don't add an extra \n. 38503 var prevMoreIndented = string[0] === '\n' || string[0] === ' '; 38504 var moreIndented; 38505 38506 // rest of the lines 38507 var match; 38508 while ((match = lineRe.exec(string))) { 38509 var prefix = match[1], line = match[2]; 38510 moreIndented = (line[0] === ' '); 38511 result += prefix 38512 + (!prevMoreIndented && !moreIndented && line !== '' 38513 ? '\n' : '') 38514 + foldLine(line, width); 38515 prevMoreIndented = moreIndented; 38516 } 38517 38518 return result; 38519 } 38520 38521 // Greedy line breaking. 38522 // Picks the longest line under the limit each time, 38523 // otherwise settles for the shortest line over the limit. 38524 // NB. More-indented lines *cannot* be folded, as that would add an extra \n. 38525 function foldLine(line, width) { 38526 if (line === '' || line[0] === ' ') return line; 38527 38528 // Since a more-indented line adds a \n, breaks can't be followed by a space. 38529 var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. 38530 var match; 38531 // start is an inclusive index. end, curr, and next are exclusive. 38532 var start = 0, end, curr = 0, next = 0; 38533 var result = ''; 38534 38535 // Invariants: 0 <= start <= length-1. 38536 // 0 <= curr <= next <= max(0, length-2). curr - start <= width. 38537 // Inside the loop: 38538 // A match implies length >= 2, so curr and next are <= length-2. 38539 while ((match = breakRe.exec(line))) { 38540 next = match.index; 38541 // maintain invariant: curr - start <= width 38542 if (next - start > width) { 38543 end = (curr > start) ? curr : next; // derive end <= length-2 38544 result += '\n' + line.slice(start, end); 38545 // skip the space that was output as \n 38546 start = end + 1; // derive start <= length-1 38547 } 38548 curr = next; 38549 } 38550 38551 // By the invariants, start <= length-1, so there is something left over. 38552 // It is either the whole string or a part starting from non-whitespace. 38553 result += '\n'; 38554 // Insert a break if the remainder is too long and there is a break available. 38555 if (line.length - start > width && curr > start) { 38556 result += line.slice(start, curr) + '\n' + line.slice(curr + 1); 38557 } else { 38558 result += line.slice(start); 38559 } 38560 38561 return result.slice(1); // drop extra \n joiner 38562 } 38563 38564 // Escapes a double-quoted string. 38565 function escapeString(string) { 38566 var result = ''; 38567 var char; 38568 var escapeSeq; 38569 38570 for (var i = 0; i < string.length; i++) { 38571 char = string.charCodeAt(i); 38572 escapeSeq = ESCAPE_SEQUENCES[char]; 38573 result += !escapeSeq && isPrintable(char) 38574 ? string[i] 38575 : escapeSeq || encodeHex(char); 38576 } 38577 38578 return result; 38579 } 38580 38581 function writeFlowSequence(state, level, object) { 38582 var _result = '', 38583 _tag = state.tag, 38584 index, 38585 length; 38586 38587 for (index = 0, length = object.length; index < length; index += 1) { 38588 // Write only valid elements. 38589 if (writeNode(state, level, object[index], false, false)) { 38590 if (index !== 0) _result += ', '; 38591 _result += state.dump; 38592 } 38593 } 38594 38595 state.tag = _tag; 38596 state.dump = '[' + _result + ']'; 38597 } 38598 38599 function writeBlockSequence(state, level, object, compact) { 38600 var _result = '', 38601 _tag = state.tag, 38602 index, 38603 length; 38604 38605 for (index = 0, length = object.length; index < length; index += 1) { 38606 // Write only valid elements. 38607 if (writeNode(state, level + 1, object[index], true, true)) { 38608 if (!compact || index !== 0) { 38609 _result += generateNextLine(state, level); 38610 } 38611 _result += '- ' + state.dump; 38612 } 38613 } 38614 38615 state.tag = _tag; 38616 state.dump = _result || '[]'; // Empty sequence if no valid values. 38617 } 38618 38619 function writeFlowMapping(state, level, object) { 38620 var _result = '', 38621 _tag = state.tag, 38622 objectKeyList = Object.keys(object), 38623 index, 38624 length, 38625 objectKey, 38626 objectValue, 38627 pairBuffer; 38628 38629 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 38630 pairBuffer = ''; 38631 38632 if (index !== 0) pairBuffer += ', '; 38633 38634 objectKey = objectKeyList[index]; 38635 objectValue = object[objectKey]; 38636 38637 if (!writeNode(state, level, objectKey, false, false)) { 38638 continue; // Skip this pair because of invalid key; 38639 } 38640 38641 if (state.dump.length > 1024) pairBuffer += '? '; 38642 38643 pairBuffer += state.dump + ': '; 38644 38645 if (!writeNode(state, level, objectValue, false, false)) { 38646 continue; // Skip this pair because of invalid value. 38647 } 38648 38649 pairBuffer += state.dump; 38650 38651 // Both key and value are valid. 38652 _result += pairBuffer; 38653 } 38654 38655 state.tag = _tag; 38656 state.dump = '{' + _result + '}'; 38657 } 38658 38659 function writeBlockMapping(state, level, object, compact) { 38660 var _result = '', 38661 _tag = state.tag, 38662 objectKeyList = Object.keys(object), 38663 index, 38664 length, 38665 objectKey, 38666 objectValue, 38667 explicitPair, 38668 pairBuffer; 38669 38670 // Allow sorting keys so that the output file is deterministic 38671 if (state.sortKeys === true) { 38672 // Default sorting 38673 objectKeyList.sort(); 38674 } else if (typeof state.sortKeys === 'function') { 38675 // Custom sort function 38676 objectKeyList.sort(state.sortKeys); 38677 } else if (state.sortKeys) { 38678 // Something is wrong 38679 throw new YAMLException('sortKeys must be a boolean or a function'); 38680 } 38681 38682 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 38683 pairBuffer = ''; 38684 38685 if (!compact || index !== 0) { 38686 pairBuffer += generateNextLine(state, level); 38687 } 38688 38689 objectKey = objectKeyList[index]; 38690 objectValue = object[objectKey]; 38691 38692 if (!writeNode(state, level + 1, objectKey, true, true, true)) { 38693 continue; // Skip this pair because of invalid key. 38694 } 38695 38696 explicitPair = (state.tag !== null && state.tag !== '?') || 38697 (state.dump && state.dump.length > 1024); 38698 38699 if (explicitPair) { 38700 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 38701 pairBuffer += '?'; 38702 } else { 38703 pairBuffer += '? '; 38704 } 38705 } 38706 38707 pairBuffer += state.dump; 38708 38709 if (explicitPair) { 38710 pairBuffer += generateNextLine(state, level); 38711 } 38712 38713 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { 38714 continue; // Skip this pair because of invalid value. 38715 } 38716 38717 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 38718 pairBuffer += ':'; 38719 } else { 38720 pairBuffer += ': '; 38721 } 38722 38723 pairBuffer += state.dump; 38724 38725 // Both key and value are valid. 38726 _result += pairBuffer; 38727 } 38728 38729 state.tag = _tag; 38730 state.dump = _result || '{}'; // Empty mapping if no valid pairs. 38731 } 38732 38733 function detectType(state, object, explicit) { 38734 var _result, typeList, index, length, type, style; 38735 38736 typeList = explicit ? state.explicitTypes : state.implicitTypes; 38737 38738 for (index = 0, length = typeList.length; index < length; index += 1) { 38739 type = typeList[index]; 38740 38741 if ((type.instanceOf || type.predicate) && 38742 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && 38743 (!type.predicate || type.predicate(object))) { 38744 38745 state.tag = explicit ? type.tag : '?'; 38746 38747 if (type.represent) { 38748 style = state.styleMap[type.tag] || type.defaultStyle; 38749 38750 if (_toString.call(type.represent) === '[object Function]') { 38751 _result = type.represent(object, style); 38752 } else if (_hasOwnProperty.call(type.represent, style)) { 38753 _result = type.represent[style](object, style); 38754 } else { 38755 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); 38756 } 38757 38758 state.dump = _result; 38759 } 38760 38761 return true; 38762 } 38763 } 38764 38765 return false; 38766 } 38767 38768 // Serializes `object` and writes it to global `result`. 38769 // Returns true on success, or false on invalid object. 38770 // 38771 function writeNode(state, level, object, block, compact, iskey) { 38772 state.tag = null; 38773 state.dump = object; 38774 38775 if (!detectType(state, object, false)) { 38776 detectType(state, object, true); 38777 } 38778 38779 var type = _toString.call(state.dump); 38780 38781 if (block) { 38782 block = (state.flowLevel < 0 || state.flowLevel > level); 38783 } 38784 38785 var objectOrArray = type === '[object Object]' || type === '[object Array]', 38786 duplicateIndex, 38787 duplicate; 38788 38789 if (objectOrArray) { 38790 duplicateIndex = state.duplicates.indexOf(object); 38791 duplicate = duplicateIndex !== -1; 38792 } 38793 38794 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { 38795 compact = false; 38796 } 38797 38798 if (duplicate && state.usedDuplicates[duplicateIndex]) { 38799 state.dump = '*ref_' + duplicateIndex; 38800 } else { 38801 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { 38802 state.usedDuplicates[duplicateIndex] = true; 38803 } 38804 if (type === '[object Object]') { 38805 if (block && (Object.keys(state.dump).length !== 0)) { 38806 writeBlockMapping(state, level, state.dump, compact); 38807 if (duplicate) { 38808 state.dump = '&ref_' + duplicateIndex + state.dump; 38809 } 38810 } else { 38811 writeFlowMapping(state, level, state.dump); 38812 if (duplicate) { 38813 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; 38814 } 38815 } 38816 } else if (type === '[object Array]') { 38817 if (block && (state.dump.length !== 0)) { 38818 writeBlockSequence(state, level, state.dump, compact); 38819 if (duplicate) { 38820 state.dump = '&ref_' + duplicateIndex + state.dump; 38821 } 38822 } else { 38823 writeFlowSequence(state, level, state.dump); 38824 if (duplicate) { 38825 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; 38826 } 38827 } 38828 } else if (type === '[object String]') { 38829 if (state.tag !== '?') { 38830 writeScalar(state, state.dump, level, iskey); 38831 } 38832 } else { 38833 if (state.skipInvalid) return false; 38834 throw new YAMLException('unacceptable kind of an object to dump ' + type); 38835 } 38836 38837 if (state.tag !== null && state.tag !== '?') { 38838 state.dump = '!<' + state.tag + '> ' + state.dump; 38839 } 38840 } 38841 38842 return true; 38843 } 38844 38845 function getDuplicateReferences(object, state) { 38846 var objects = [], 38847 duplicatesIndexes = [], 38848 index, 38849 length; 38850 38851 inspectNode(object, objects, duplicatesIndexes); 38852 38853 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { 38854 state.duplicates.push(objects[duplicatesIndexes[index]]); 38855 } 38856 state.usedDuplicates = new Array(length); 38857 } 38858 38859 function inspectNode(object, objects, duplicatesIndexes) { 38860 var objectKeyList, 38861 index, 38862 length; 38863 38864 if (object !== null && typeof object === 'object') { 38865 index = objects.indexOf(object); 38866 if (index !== -1) { 38867 if (duplicatesIndexes.indexOf(index) === -1) { 38868 duplicatesIndexes.push(index); 38869 } 38870 } else { 38871 objects.push(object); 38872 38873 if (Array.isArray(object)) { 38874 for (index = 0, length = object.length; index < length; index += 1) { 38875 inspectNode(object[index], objects, duplicatesIndexes); 38876 } 38877 } else { 38878 objectKeyList = Object.keys(object); 38879 38880 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 38881 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); 38882 } 38883 } 38884 } 38885 } 38886 } 38887 38888 function dump(input, options) { 38889 options = options || {}; 38890 38891 var state = new State(options); 38892 38893 if (!state.noRefs) getDuplicateReferences(input, state); 38894 38895 if (writeNode(state, 0, input, true, true)) return state.dump + '\n'; 38896 38897 return ''; 38898 } 38899 38900 function safeDump(input, options) { 38901 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); 38902 } 38903 38904 module.exports.dump = dump; 38905 module.exports.safeDump = safeDump; 38906 38907 38908 /***/ }, 38909 /* 90 */ 38910 /***/ function(module, exports, __webpack_require__) { 38911 38912 'use strict'; 38913 38914 /*eslint-disable max-len,no-use-before-define*/ 38915 38916 var common = __webpack_require__(7); 38917 var YAMLException = __webpack_require__(11); 38918 var Mark = __webpack_require__(91); 38919 var DEFAULT_SAFE_SCHEMA = __webpack_require__(12); 38920 var DEFAULT_FULL_SCHEMA = __webpack_require__(15); 38921 38922 38923 var _hasOwnProperty = Object.prototype.hasOwnProperty; 38924 38925 38926 var CONTEXT_FLOW_IN = 1; 38927 var CONTEXT_FLOW_OUT = 2; 38928 var CONTEXT_BLOCK_IN = 3; 38929 var CONTEXT_BLOCK_OUT = 4; 38930 38931 38932 var CHOMPING_CLIP = 1; 38933 var CHOMPING_STRIP = 2; 38934 var CHOMPING_KEEP = 3; 38935 38936 38937 var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; 38938 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; 38939 var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; 38940 var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; 38941 var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; 38942 38943 38944 function is_EOL(c) { 38945 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); 38946 } 38947 38948 function is_WHITE_SPACE(c) { 38949 return (c === 0x09/* Tab */) || (c === 0x20/* Space */); 38950 } 38951 38952 function is_WS_OR_EOL(c) { 38953 return (c === 0x09/* Tab */) || 38954 (c === 0x20/* Space */) || 38955 (c === 0x0A/* LF */) || 38956 (c === 0x0D/* CR */); 38957 } 38958 38959 function is_FLOW_INDICATOR(c) { 38960 return c === 0x2C/* , */ || 38961 c === 0x5B/* [ */ || 38962 c === 0x5D/* ] */ || 38963 c === 0x7B/* { */ || 38964 c === 0x7D/* } */; 38965 } 38966 38967 function fromHexCode(c) { 38968 var lc; 38969 38970 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { 38971 return c - 0x30; 38972 } 38973 38974 /*eslint-disable no-bitwise*/ 38975 lc = c | 0x20; 38976 38977 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { 38978 return lc - 0x61 + 10; 38979 } 38980 38981 return -1; 38982 } 38983 38984 function escapedHexLen(c) { 38985 if (c === 0x78/* x */) { return 2; } 38986 if (c === 0x75/* u */) { return 4; } 38987 if (c === 0x55/* U */) { return 8; } 38988 return 0; 38989 } 38990 38991 function fromDecimalCode(c) { 38992 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { 38993 return c - 0x30; 38994 } 38995 38996 return -1; 38997 } 38998 38999 function simpleEscapeSequence(c) { 39000 return (c === 0x30/* 0 */) ? '\x00' : 39001 (c === 0x61/* a */) ? '\x07' : 39002 (c === 0x62/* b */) ? '\x08' : 39003 (c === 0x74/* t */) ? '\x09' : 39004 (c === 0x09/* Tab */) ? '\x09' : 39005 (c === 0x6E/* n */) ? '\x0A' : 39006 (c === 0x76/* v */) ? '\x0B' : 39007 (c === 0x66/* f */) ? '\x0C' : 39008 (c === 0x72/* r */) ? '\x0D' : 39009 (c === 0x65/* e */) ? '\x1B' : 39010 (c === 0x20/* Space */) ? ' ' : 39011 (c === 0x22/* " */) ? '\x22' : 39012 (c === 0x2F/* / */) ? '/' : 39013 (c === 0x5C/* \ */) ? '\x5C' : 39014 (c === 0x4E/* N */) ? '\x85' : 39015 (c === 0x5F/* _ */) ? '\xA0' : 39016 (c === 0x4C/* L */) ? '\u2028' : 39017 (c === 0x50/* P */) ? '\u2029' : ''; 39018 } 39019 39020 function charFromCodepoint(c) { 39021 if (c <= 0xFFFF) { 39022 return String.fromCharCode(c); 39023 } 39024 // Encode UTF-16 surrogate pair 39025 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF 39026 return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800, 39027 ((c - 0x010000) & 0x03FF) + 0xDC00); 39028 } 39029 39030 var simpleEscapeCheck = new Array(256); // integer, for fast access 39031 var simpleEscapeMap = new Array(256); 39032 for (var i = 0; i < 256; i++) { 39033 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; 39034 simpleEscapeMap[i] = simpleEscapeSequence(i); 39035 } 39036 39037 39038 function State(input, options) { 39039 this.input = input; 39040 39041 this.filename = options['filename'] || null; 39042 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; 39043 this.onWarning = options['onWarning'] || null; 39044 this.legacy = options['legacy'] || false; 39045 this.json = options['json'] || false; 39046 this.listener = options['listener'] || null; 39047 39048 this.implicitTypes = this.schema.compiledImplicit; 39049 this.typeMap = this.schema.compiledTypeMap; 39050 39051 this.length = input.length; 39052 this.position = 0; 39053 this.line = 0; 39054 this.lineStart = 0; 39055 this.lineIndent = 0; 39056 39057 this.documents = []; 39058 39059 /* 39060 this.version; 39061 this.checkLineBreaks; 39062 this.tagMap; 39063 this.anchorMap; 39064 this.tag; 39065 this.anchor; 39066 this.kind; 39067 this.result;*/ 39068 39069 } 39070 39071 39072 function generateError(state, message) { 39073 return new YAMLException( 39074 message, 39075 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); 39076 } 39077 39078 function throwError(state, message) { 39079 throw generateError(state, message); 39080 } 39081 39082 function throwWarning(state, message) { 39083 if (state.onWarning) { 39084 state.onWarning.call(null, generateError(state, message)); 39085 } 39086 } 39087 39088 39089 var directiveHandlers = { 39090 39091 YAML: function handleYamlDirective(state, name, args) { 39092 39093 var match, major, minor; 39094 39095 if (state.version !== null) { 39096 throwError(state, 'duplication of %YAML directive'); 39097 } 39098 39099 if (args.length !== 1) { 39100 throwError(state, 'YAML directive accepts exactly one argument'); 39101 } 39102 39103 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); 39104 39105 if (match === null) { 39106 throwError(state, 'ill-formed argument of the YAML directive'); 39107 } 39108 39109 major = parseInt(match[1], 10); 39110 minor = parseInt(match[2], 10); 39111 39112 if (major !== 1) { 39113 throwError(state, 'unacceptable YAML version of the document'); 39114 } 39115 39116 state.version = args[0]; 39117 state.checkLineBreaks = (minor < 2); 39118 39119 if (minor !== 1 && minor !== 2) { 39120 throwWarning(state, 'unsupported YAML version of the document'); 39121 } 39122 }, 39123 39124 TAG: function handleTagDirective(state, name, args) { 39125 39126 var handle, prefix; 39127 39128 if (args.length !== 2) { 39129 throwError(state, 'TAG directive accepts exactly two arguments'); 39130 } 39131 39132 handle = args[0]; 39133 prefix = args[1]; 39134 39135 if (!PATTERN_TAG_HANDLE.test(handle)) { 39136 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); 39137 } 39138 39139 if (_hasOwnProperty.call(state.tagMap, handle)) { 39140 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); 39141 } 39142 39143 if (!PATTERN_TAG_URI.test(prefix)) { 39144 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); 39145 } 39146 39147 state.tagMap[handle] = prefix; 39148 } 39149 }; 39150 39151 39152 function captureSegment(state, start, end, checkJson) { 39153 var _position, _length, _character, _result; 39154 39155 if (start < end) { 39156 _result = state.input.slice(start, end); 39157 39158 if (checkJson) { 39159 for (_position = 0, _length = _result.length; 39160 _position < _length; 39161 _position += 1) { 39162 _character = _result.charCodeAt(_position); 39163 if (!(_character === 0x09 || 39164 (0x20 <= _character && _character <= 0x10FFFF))) { 39165 throwError(state, 'expected valid JSON character'); 39166 } 39167 } 39168 } else if (PATTERN_NON_PRINTABLE.test(_result)) { 39169 throwError(state, 'the stream contains non-printable characters'); 39170 } 39171 39172 state.result += _result; 39173 } 39174 } 39175 39176 function mergeMappings(state, destination, source, overridableKeys) { 39177 var sourceKeys, key, index, quantity; 39178 39179 if (!common.isObject(source)) { 39180 throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); 39181 } 39182 39183 sourceKeys = Object.keys(source); 39184 39185 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { 39186 key = sourceKeys[index]; 39187 39188 if (!_hasOwnProperty.call(destination, key)) { 39189 destination[key] = source[key]; 39190 overridableKeys[key] = true; 39191 } 39192 } 39193 } 39194 39195 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) { 39196 var index, quantity; 39197 39198 keyNode = String(keyNode); 39199 39200 if (_result === null) { 39201 _result = {}; 39202 } 39203 39204 if (keyTag === 'tag:yaml.org,2002:merge') { 39205 if (Array.isArray(valueNode)) { 39206 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { 39207 mergeMappings(state, _result, valueNode[index], overridableKeys); 39208 } 39209 } else { 39210 mergeMappings(state, _result, valueNode, overridableKeys); 39211 } 39212 } else { 39213 if (!state.json && 39214 !_hasOwnProperty.call(overridableKeys, keyNode) && 39215 _hasOwnProperty.call(_result, keyNode)) { 39216 throwError(state, 'duplicated mapping key'); 39217 } 39218 _result[keyNode] = valueNode; 39219 delete overridableKeys[keyNode]; 39220 } 39221 39222 return _result; 39223 } 39224 39225 function readLineBreak(state) { 39226 var ch; 39227 39228 ch = state.input.charCodeAt(state.position); 39229 39230 if (ch === 0x0A/* LF */) { 39231 state.position++; 39232 } else if (ch === 0x0D/* CR */) { 39233 state.position++; 39234 if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { 39235 state.position++; 39236 } 39237 } else { 39238 throwError(state, 'a line break is expected'); 39239 } 39240 39241 state.line += 1; 39242 state.lineStart = state.position; 39243 } 39244 39245 function skipSeparationSpace(state, allowComments, checkIndent) { 39246 var lineBreaks = 0, 39247 ch = state.input.charCodeAt(state.position); 39248 39249 while (ch !== 0) { 39250 while (is_WHITE_SPACE(ch)) { 39251 ch = state.input.charCodeAt(++state.position); 39252 } 39253 39254 if (allowComments && ch === 0x23/* # */) { 39255 do { 39256 ch = state.input.charCodeAt(++state.position); 39257 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); 39258 } 39259 39260 if (is_EOL(ch)) { 39261 readLineBreak(state); 39262 39263 ch = state.input.charCodeAt(state.position); 39264 lineBreaks++; 39265 state.lineIndent = 0; 39266 39267 while (ch === 0x20/* Space */) { 39268 state.lineIndent++; 39269 ch = state.input.charCodeAt(++state.position); 39270 } 39271 } else { 39272 break; 39273 } 39274 } 39275 39276 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { 39277 throwWarning(state, 'deficient indentation'); 39278 } 39279 39280 return lineBreaks; 39281 } 39282 39283 function testDocumentSeparator(state) { 39284 var _position = state.position, 39285 ch; 39286 39287 ch = state.input.charCodeAt(_position); 39288 39289 // Condition state.position === state.lineStart is tested 39290 // in parent on each call, for efficiency. No needs to test here again. 39291 if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && 39292 ch === state.input.charCodeAt(_position + 1) && 39293 ch === state.input.charCodeAt(_position + 2)) { 39294 39295 _position += 3; 39296 39297 ch = state.input.charCodeAt(_position); 39298 39299 if (ch === 0 || is_WS_OR_EOL(ch)) { 39300 return true; 39301 } 39302 } 39303 39304 return false; 39305 } 39306 39307 function writeFoldedLines(state, count) { 39308 if (count === 1) { 39309 state.result += ' '; 39310 } else if (count > 1) { 39311 state.result += common.repeat('\n', count - 1); 39312 } 39313 } 39314 39315 39316 function readPlainScalar(state, nodeIndent, withinFlowCollection) { 39317 var preceding, 39318 following, 39319 captureStart, 39320 captureEnd, 39321 hasPendingContent, 39322 _line, 39323 _lineStart, 39324 _lineIndent, 39325 _kind = state.kind, 39326 _result = state.result, 39327 ch; 39328 39329 ch = state.input.charCodeAt(state.position); 39330 39331 if (is_WS_OR_EOL(ch) || 39332 is_FLOW_INDICATOR(ch) || 39333 ch === 0x23/* # */ || 39334 ch === 0x26/* & */ || 39335 ch === 0x2A/* * */ || 39336 ch === 0x21/* ! */ || 39337 ch === 0x7C/* | */ || 39338 ch === 0x3E/* > */ || 39339 ch === 0x27/* ' */ || 39340 ch === 0x22/* " */ || 39341 ch === 0x25/* % */ || 39342 ch === 0x40/* @ */ || 39343 ch === 0x60/* ` */) { 39344 return false; 39345 } 39346 39347 if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { 39348 following = state.input.charCodeAt(state.position + 1); 39349 39350 if (is_WS_OR_EOL(following) || 39351 withinFlowCollection && is_FLOW_INDICATOR(following)) { 39352 return false; 39353 } 39354 } 39355 39356 state.kind = 'scalar'; 39357 state.result = ''; 39358 captureStart = captureEnd = state.position; 39359 hasPendingContent = false; 39360 39361 while (ch !== 0) { 39362 if (ch === 0x3A/* : */) { 39363 following = state.input.charCodeAt(state.position + 1); 39364 39365 if (is_WS_OR_EOL(following) || 39366 withinFlowCollection && is_FLOW_INDICATOR(following)) { 39367 break; 39368 } 39369 39370 } else if (ch === 0x23/* # */) { 39371 preceding = state.input.charCodeAt(state.position - 1); 39372 39373 if (is_WS_OR_EOL(preceding)) { 39374 break; 39375 } 39376 39377 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || 39378 withinFlowCollection && is_FLOW_INDICATOR(ch)) { 39379 break; 39380 39381 } else if (is_EOL(ch)) { 39382 _line = state.line; 39383 _lineStart = state.lineStart; 39384 _lineIndent = state.lineIndent; 39385 skipSeparationSpace(state, false, -1); 39386 39387 if (state.lineIndent >= nodeIndent) { 39388 hasPendingContent = true; 39389 ch = state.input.charCodeAt(state.position); 39390 continue; 39391 } else { 39392 state.position = captureEnd; 39393 state.line = _line; 39394 state.lineStart = _lineStart; 39395 state.lineIndent = _lineIndent; 39396 break; 39397 } 39398 } 39399 39400 if (hasPendingContent) { 39401 captureSegment(state, captureStart, captureEnd, false); 39402 writeFoldedLines(state, state.line - _line); 39403 captureStart = captureEnd = state.position; 39404 hasPendingContent = false; 39405 } 39406 39407 if (!is_WHITE_SPACE(ch)) { 39408 captureEnd = state.position + 1; 39409 } 39410 39411 ch = state.input.charCodeAt(++state.position); 39412 } 39413 39414 captureSegment(state, captureStart, captureEnd, false); 39415 39416 if (state.result) { 39417 return true; 39418 } 39419 39420 state.kind = _kind; 39421 state.result = _result; 39422 return false; 39423 } 39424 39425 function readSingleQuotedScalar(state, nodeIndent) { 39426 var ch, 39427 captureStart, captureEnd; 39428 39429 ch = state.input.charCodeAt(state.position); 39430 39431 if (ch !== 0x27/* ' */) { 39432 return false; 39433 } 39434 39435 state.kind = 'scalar'; 39436 state.result = ''; 39437 state.position++; 39438 captureStart = captureEnd = state.position; 39439 39440 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 39441 if (ch === 0x27/* ' */) { 39442 captureSegment(state, captureStart, state.position, true); 39443 ch = state.input.charCodeAt(++state.position); 39444 39445 if (ch === 0x27/* ' */) { 39446 captureStart = captureEnd = state.position; 39447 state.position++; 39448 } else { 39449 return true; 39450 } 39451 39452 } else if (is_EOL(ch)) { 39453 captureSegment(state, captureStart, captureEnd, true); 39454 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 39455 captureStart = captureEnd = state.position; 39456 39457 } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 39458 throwError(state, 'unexpected end of the document within a single quoted scalar'); 39459 39460 } else { 39461 state.position++; 39462 captureEnd = state.position; 39463 } 39464 } 39465 39466 throwError(state, 'unexpected end of the stream within a single quoted scalar'); 39467 } 39468 39469 function readDoubleQuotedScalar(state, nodeIndent) { 39470 var captureStart, 39471 captureEnd, 39472 hexLength, 39473 hexResult, 39474 tmp, 39475 ch; 39476 39477 ch = state.input.charCodeAt(state.position); 39478 39479 if (ch !== 0x22/* " */) { 39480 return false; 39481 } 39482 39483 state.kind = 'scalar'; 39484 state.result = ''; 39485 state.position++; 39486 captureStart = captureEnd = state.position; 39487 39488 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 39489 if (ch === 0x22/* " */) { 39490 captureSegment(state, captureStart, state.position, true); 39491 state.position++; 39492 return true; 39493 39494 } else if (ch === 0x5C/* \ */) { 39495 captureSegment(state, captureStart, state.position, true); 39496 ch = state.input.charCodeAt(++state.position); 39497 39498 if (is_EOL(ch)) { 39499 skipSeparationSpace(state, false, nodeIndent); 39500 39501 // TODO: rework to inline fn with no type cast? 39502 } else if (ch < 256 && simpleEscapeCheck[ch]) { 39503 state.result += simpleEscapeMap[ch]; 39504 state.position++; 39505 39506 } else if ((tmp = escapedHexLen(ch)) > 0) { 39507 hexLength = tmp; 39508 hexResult = 0; 39509 39510 for (; hexLength > 0; hexLength--) { 39511 ch = state.input.charCodeAt(++state.position); 39512 39513 if ((tmp = fromHexCode(ch)) >= 0) { 39514 hexResult = (hexResult << 4) + tmp; 39515 39516 } else { 39517 throwError(state, 'expected hexadecimal character'); 39518 } 39519 } 39520 39521 state.result += charFromCodepoint(hexResult); 39522 39523 state.position++; 39524 39525 } else { 39526 throwError(state, 'unknown escape sequence'); 39527 } 39528 39529 captureStart = captureEnd = state.position; 39530 39531 } else if (is_EOL(ch)) { 39532 captureSegment(state, captureStart, captureEnd, true); 39533 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 39534 captureStart = captureEnd = state.position; 39535 39536 } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 39537 throwError(state, 'unexpected end of the document within a double quoted scalar'); 39538 39539 } else { 39540 state.position++; 39541 captureEnd = state.position; 39542 } 39543 } 39544 39545 throwError(state, 'unexpected end of the stream within a double quoted scalar'); 39546 } 39547 39548 function readFlowCollection(state, nodeIndent) { 39549 var readNext = true, 39550 _line, 39551 _tag = state.tag, 39552 _result, 39553 _anchor = state.anchor, 39554 following, 39555 terminator, 39556 isPair, 39557 isExplicitPair, 39558 isMapping, 39559 overridableKeys = {}, 39560 keyNode, 39561 keyTag, 39562 valueNode, 39563 ch; 39564 39565 ch = state.input.charCodeAt(state.position); 39566 39567 if (ch === 0x5B/* [ */) { 39568 terminator = 0x5D;/* ] */ 39569 isMapping = false; 39570 _result = []; 39571 } else if (ch === 0x7B/* { */) { 39572 terminator = 0x7D;/* } */ 39573 isMapping = true; 39574 _result = {}; 39575 } else { 39576 return false; 39577 } 39578 39579 if (state.anchor !== null) { 39580 state.anchorMap[state.anchor] = _result; 39581 } 39582 39583 ch = state.input.charCodeAt(++state.position); 39584 39585 while (ch !== 0) { 39586 skipSeparationSpace(state, true, nodeIndent); 39587 39588 ch = state.input.charCodeAt(state.position); 39589 39590 if (ch === terminator) { 39591 state.position++; 39592 state.tag = _tag; 39593 state.anchor = _anchor; 39594 state.kind = isMapping ? 'mapping' : 'sequence'; 39595 state.result = _result; 39596 return true; 39597 } else if (!readNext) { 39598 throwError(state, 'missed comma between flow collection entries'); 39599 } 39600 39601 keyTag = keyNode = valueNode = null; 39602 isPair = isExplicitPair = false; 39603 39604 if (ch === 0x3F/* ? */) { 39605 following = state.input.charCodeAt(state.position + 1); 39606 39607 if (is_WS_OR_EOL(following)) { 39608 isPair = isExplicitPair = true; 39609 state.position++; 39610 skipSeparationSpace(state, true, nodeIndent); 39611 } 39612 } 39613 39614 _line = state.line; 39615 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 39616 keyTag = state.tag; 39617 keyNode = state.result; 39618 skipSeparationSpace(state, true, nodeIndent); 39619 39620 ch = state.input.charCodeAt(state.position); 39621 39622 if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { 39623 isPair = true; 39624 ch = state.input.charCodeAt(++state.position); 39625 skipSeparationSpace(state, true, nodeIndent); 39626 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 39627 valueNode = state.result; 39628 } 39629 39630 if (isMapping) { 39631 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); 39632 } else if (isPair) { 39633 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode)); 39634 } else { 39635 _result.push(keyNode); 39636 } 39637 39638 skipSeparationSpace(state, true, nodeIndent); 39639 39640 ch = state.input.charCodeAt(state.position); 39641 39642 if (ch === 0x2C/* , */) { 39643 readNext = true; 39644 ch = state.input.charCodeAt(++state.position); 39645 } else { 39646 readNext = false; 39647 } 39648 } 39649 39650 throwError(state, 'unexpected end of the stream within a flow collection'); 39651 } 39652 39653 function readBlockScalar(state, nodeIndent) { 39654 var captureStart, 39655 folding, 39656 chomping = CHOMPING_CLIP, 39657 didReadContent = false, 39658 detectedIndent = false, 39659 textIndent = nodeIndent, 39660 emptyLines = 0, 39661 atMoreIndented = false, 39662 tmp, 39663 ch; 39664 39665 ch = state.input.charCodeAt(state.position); 39666 39667 if (ch === 0x7C/* | */) { 39668 folding = false; 39669 } else if (ch === 0x3E/* > */) { 39670 folding = true; 39671 } else { 39672 return false; 39673 } 39674 39675 state.kind = 'scalar'; 39676 state.result = ''; 39677 39678 while (ch !== 0) { 39679 ch = state.input.charCodeAt(++state.position); 39680 39681 if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { 39682 if (CHOMPING_CLIP === chomping) { 39683 chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; 39684 } else { 39685 throwError(state, 'repeat of a chomping mode identifier'); 39686 } 39687 39688 } else if ((tmp = fromDecimalCode(ch)) >= 0) { 39689 if (tmp === 0) { 39690 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); 39691 } else if (!detectedIndent) { 39692 textIndent = nodeIndent + tmp - 1; 39693 detectedIndent = true; 39694 } else { 39695 throwError(state, 'repeat of an indentation width identifier'); 39696 } 39697 39698 } else { 39699 break; 39700 } 39701 } 39702 39703 if (is_WHITE_SPACE(ch)) { 39704 do { ch = state.input.charCodeAt(++state.position); } 39705 while (is_WHITE_SPACE(ch)); 39706 39707 if (ch === 0x23/* # */) { 39708 do { ch = state.input.charCodeAt(++state.position); } 39709 while (!is_EOL(ch) && (ch !== 0)); 39710 } 39711 } 39712 39713 while (ch !== 0) { 39714 readLineBreak(state); 39715 state.lineIndent = 0; 39716 39717 ch = state.input.charCodeAt(state.position); 39718 39719 while ((!detectedIndent || state.lineIndent < textIndent) && 39720 (ch === 0x20/* Space */)) { 39721 state.lineIndent++; 39722 ch = state.input.charCodeAt(++state.position); 39723 } 39724 39725 if (!detectedIndent && state.lineIndent > textIndent) { 39726 textIndent = state.lineIndent; 39727 } 39728 39729 if (is_EOL(ch)) { 39730 emptyLines++; 39731 continue; 39732 } 39733 39734 // End of the scalar. 39735 if (state.lineIndent < textIndent) { 39736 39737 // Perform the chomping. 39738 if (chomping === CHOMPING_KEEP) { 39739 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 39740 } else if (chomping === CHOMPING_CLIP) { 39741 if (didReadContent) { // i.e. only if the scalar is not empty. 39742 state.result += '\n'; 39743 } 39744 } 39745 39746 // Break this `while` cycle and go to the funciton's epilogue. 39747 break; 39748 } 39749 39750 // Folded style: use fancy rules to handle line breaks. 39751 if (folding) { 39752 39753 // Lines starting with white space characters (more-indented lines) are not folded. 39754 if (is_WHITE_SPACE(ch)) { 39755 atMoreIndented = true; 39756 // except for the first content line (cf. Example 8.1) 39757 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 39758 39759 // End of more-indented block. 39760 } else if (atMoreIndented) { 39761 atMoreIndented = false; 39762 state.result += common.repeat('\n', emptyLines + 1); 39763 39764 // Just one line break - perceive as the same line. 39765 } else if (emptyLines === 0) { 39766 if (didReadContent) { // i.e. only if we have already read some scalar content. 39767 state.result += ' '; 39768 } 39769 39770 // Several line breaks - perceive as different lines. 39771 } else { 39772 state.result += common.repeat('\n', emptyLines); 39773 } 39774 39775 // Literal style: just add exact number of line breaks between content lines. 39776 } else { 39777 // Keep all line breaks except the header line break. 39778 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 39779 } 39780 39781 didReadContent = true; 39782 detectedIndent = true; 39783 emptyLines = 0; 39784 captureStart = state.position; 39785 39786 while (!is_EOL(ch) && (ch !== 0)) { 39787 ch = state.input.charCodeAt(++state.position); 39788 } 39789 39790 captureSegment(state, captureStart, state.position, false); 39791 } 39792 39793 return true; 39794 } 39795 39796 function readBlockSequence(state, nodeIndent) { 39797 var _line, 39798 _tag = state.tag, 39799 _anchor = state.anchor, 39800 _result = [], 39801 following, 39802 detected = false, 39803 ch; 39804 39805 if (state.anchor !== null) { 39806 state.anchorMap[state.anchor] = _result; 39807 } 39808 39809 ch = state.input.charCodeAt(state.position); 39810 39811 while (ch !== 0) { 39812 39813 if (ch !== 0x2D/* - */) { 39814 break; 39815 } 39816 39817 following = state.input.charCodeAt(state.position + 1); 39818 39819 if (!is_WS_OR_EOL(following)) { 39820 break; 39821 } 39822 39823 detected = true; 39824 state.position++; 39825 39826 if (skipSeparationSpace(state, true, -1)) { 39827 if (state.lineIndent <= nodeIndent) { 39828 _result.push(null); 39829 ch = state.input.charCodeAt(state.position); 39830 continue; 39831 } 39832 } 39833 39834 _line = state.line; 39835 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); 39836 _result.push(state.result); 39837 skipSeparationSpace(state, true, -1); 39838 39839 ch = state.input.charCodeAt(state.position); 39840 39841 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { 39842 throwError(state, 'bad indentation of a sequence entry'); 39843 } else if (state.lineIndent < nodeIndent) { 39844 break; 39845 } 39846 } 39847 39848 if (detected) { 39849 state.tag = _tag; 39850 state.anchor = _anchor; 39851 state.kind = 'sequence'; 39852 state.result = _result; 39853 return true; 39854 } 39855 return false; 39856 } 39857 39858 function readBlockMapping(state, nodeIndent, flowIndent) { 39859 var following, 39860 allowCompact, 39861 _line, 39862 _tag = state.tag, 39863 _anchor = state.anchor, 39864 _result = {}, 39865 overridableKeys = {}, 39866 keyTag = null, 39867 keyNode = null, 39868 valueNode = null, 39869 atExplicitKey = false, 39870 detected = false, 39871 ch; 39872 39873 if (state.anchor !== null) { 39874 state.anchorMap[state.anchor] = _result; 39875 } 39876 39877 ch = state.input.charCodeAt(state.position); 39878 39879 while (ch !== 0) { 39880 following = state.input.charCodeAt(state.position + 1); 39881 _line = state.line; // Save the current line. 39882 39883 // 39884 // Explicit notation case. There are two separate blocks: 39885 // first for the key (denoted by "?") and second for the value (denoted by ":") 39886 // 39887 if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { 39888 39889 if (ch === 0x3F/* ? */) { 39890 if (atExplicitKey) { 39891 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); 39892 keyTag = keyNode = valueNode = null; 39893 } 39894 39895 detected = true; 39896 atExplicitKey = true; 39897 allowCompact = true; 39898 39899 } else if (atExplicitKey) { 39900 // i.e. 0x3A/* : */ === character after the explicit key. 39901 atExplicitKey = false; 39902 allowCompact = true; 39903 39904 } else { 39905 throwError(state, 'incomplete explicit mapping pair; a key node is missed'); 39906 } 39907 39908 state.position += 1; 39909 ch = following; 39910 39911 // 39912 // Implicit notation case. Flow-style node as the key first, then ":", and the value. 39913 // 39914 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { 39915 39916 if (state.line === _line) { 39917 ch = state.input.charCodeAt(state.position); 39918 39919 while (is_WHITE_SPACE(ch)) { 39920 ch = state.input.charCodeAt(++state.position); 39921 } 39922 39923 if (ch === 0x3A/* : */) { 39924 ch = state.input.charCodeAt(++state.position); 39925 39926 if (!is_WS_OR_EOL(ch)) { 39927 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); 39928 } 39929 39930 if (atExplicitKey) { 39931 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); 39932 keyTag = keyNode = valueNode = null; 39933 } 39934 39935 detected = true; 39936 atExplicitKey = false; 39937 allowCompact = false; 39938 keyTag = state.tag; 39939 keyNode = state.result; 39940 39941 } else if (detected) { 39942 throwError(state, 'can not read an implicit mapping pair; a colon is missed'); 39943 39944 } else { 39945 state.tag = _tag; 39946 state.anchor = _anchor; 39947 return true; // Keep the result of `composeNode`. 39948 } 39949 39950 } else if (detected) { 39951 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); 39952 39953 } else { 39954 state.tag = _tag; 39955 state.anchor = _anchor; 39956 return true; // Keep the result of `composeNode`. 39957 } 39958 39959 } else { 39960 break; // Reading is done. Go to the epilogue. 39961 } 39962 39963 // 39964 // Common reading code for both explicit and implicit notations. 39965 // 39966 if (state.line === _line || state.lineIndent > nodeIndent) { 39967 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { 39968 if (atExplicitKey) { 39969 keyNode = state.result; 39970 } else { 39971 valueNode = state.result; 39972 } 39973 } 39974 39975 if (!atExplicitKey) { 39976 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); 39977 keyTag = keyNode = valueNode = null; 39978 } 39979 39980 skipSeparationSpace(state, true, -1); 39981 ch = state.input.charCodeAt(state.position); 39982 } 39983 39984 if (state.lineIndent > nodeIndent && (ch !== 0)) { 39985 throwError(state, 'bad indentation of a mapping entry'); 39986 } else if (state.lineIndent < nodeIndent) { 39987 break; 39988 } 39989 } 39990 39991 // 39992 // Epilogue. 39993 // 39994 39995 // Special case: last mapping's node contains only the key in explicit notation. 39996 if (atExplicitKey) { 39997 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); 39998 } 39999 40000 // Expose the resulting mapping. 40001 if (detected) { 40002 state.tag = _tag; 40003 state.anchor = _anchor; 40004 state.kind = 'mapping'; 40005 state.result = _result; 40006 } 40007 40008 return detected; 40009 } 40010 40011 function readTagProperty(state) { 40012 var _position, 40013 isVerbatim = false, 40014 isNamed = false, 40015 tagHandle, 40016 tagName, 40017 ch; 40018 40019 ch = state.input.charCodeAt(state.position); 40020 40021 if (ch !== 0x21/* ! */) return false; 40022 40023 if (state.tag !== null) { 40024 throwError(state, 'duplication of a tag property'); 40025 } 40026 40027 ch = state.input.charCodeAt(++state.position); 40028 40029 if (ch === 0x3C/* < */) { 40030 isVerbatim = true; 40031 ch = state.input.charCodeAt(++state.position); 40032 40033 } else if (ch === 0x21/* ! */) { 40034 isNamed = true; 40035 tagHandle = '!!'; 40036 ch = state.input.charCodeAt(++state.position); 40037 40038 } else { 40039 tagHandle = '!'; 40040 } 40041 40042 _position = state.position; 40043 40044 if (isVerbatim) { 40045 do { ch = state.input.charCodeAt(++state.position); } 40046 while (ch !== 0 && ch !== 0x3E/* > */); 40047 40048 if (state.position < state.length) { 40049 tagName = state.input.slice(_position, state.position); 40050 ch = state.input.charCodeAt(++state.position); 40051 } else { 40052 throwError(state, 'unexpected end of the stream within a verbatim tag'); 40053 } 40054 } else { 40055 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 40056 40057 if (ch === 0x21/* ! */) { 40058 if (!isNamed) { 40059 tagHandle = state.input.slice(_position - 1, state.position + 1); 40060 40061 if (!PATTERN_TAG_HANDLE.test(tagHandle)) { 40062 throwError(state, 'named tag handle cannot contain such characters'); 40063 } 40064 40065 isNamed = true; 40066 _position = state.position + 1; 40067 } else { 40068 throwError(state, 'tag suffix cannot contain exclamation marks'); 40069 } 40070 } 40071 40072 ch = state.input.charCodeAt(++state.position); 40073 } 40074 40075 tagName = state.input.slice(_position, state.position); 40076 40077 if (PATTERN_FLOW_INDICATORS.test(tagName)) { 40078 throwError(state, 'tag suffix cannot contain flow indicator characters'); 40079 } 40080 } 40081 40082 if (tagName && !PATTERN_TAG_URI.test(tagName)) { 40083 throwError(state, 'tag name cannot contain such characters: ' + tagName); 40084 } 40085 40086 if (isVerbatim) { 40087 state.tag = tagName; 40088 40089 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { 40090 state.tag = state.tagMap[tagHandle] + tagName; 40091 40092 } else if (tagHandle === '!') { 40093 state.tag = '!' + tagName; 40094 40095 } else if (tagHandle === '!!') { 40096 state.tag = 'tag:yaml.org,2002:' + tagName; 40097 40098 } else { 40099 throwError(state, 'undeclared tag handle "' + tagHandle + '"'); 40100 } 40101 40102 return true; 40103 } 40104 40105 function readAnchorProperty(state) { 40106 var _position, 40107 ch; 40108 40109 ch = state.input.charCodeAt(state.position); 40110 40111 if (ch !== 0x26/* & */) return false; 40112 40113 if (state.anchor !== null) { 40114 throwError(state, 'duplication of an anchor property'); 40115 } 40116 40117 ch = state.input.charCodeAt(++state.position); 40118 _position = state.position; 40119 40120 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 40121 ch = state.input.charCodeAt(++state.position); 40122 } 40123 40124 if (state.position === _position) { 40125 throwError(state, 'name of an anchor node must contain at least one character'); 40126 } 40127 40128 state.anchor = state.input.slice(_position, state.position); 40129 return true; 40130 } 40131 40132 function readAlias(state) { 40133 var _position, alias, 40134 ch; 40135 40136 ch = state.input.charCodeAt(state.position); 40137 40138 if (ch !== 0x2A/* * */) return false; 40139 40140 ch = state.input.charCodeAt(++state.position); 40141 _position = state.position; 40142 40143 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 40144 ch = state.input.charCodeAt(++state.position); 40145 } 40146 40147 if (state.position === _position) { 40148 throwError(state, 'name of an alias node must contain at least one character'); 40149 } 40150 40151 alias = state.input.slice(_position, state.position); 40152 40153 if (!state.anchorMap.hasOwnProperty(alias)) { 40154 throwError(state, 'unidentified alias "' + alias + '"'); 40155 } 40156 40157 state.result = state.anchorMap[alias]; 40158 skipSeparationSpace(state, true, -1); 40159 return true; 40160 } 40161 40162 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { 40163 var allowBlockStyles, 40164 allowBlockScalars, 40165 allowBlockCollections, 40166 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent 40167 atNewLine = false, 40168 hasContent = false, 40169 typeIndex, 40170 typeQuantity, 40171 type, 40172 flowIndent, 40173 blockIndent; 40174 40175 if (state.listener !== null) { 40176 state.listener('open', state); 40177 } 40178 40179 state.tag = null; 40180 state.anchor = null; 40181 state.kind = null; 40182 state.result = null; 40183 40184 allowBlockStyles = allowBlockScalars = allowBlockCollections = 40185 CONTEXT_BLOCK_OUT === nodeContext || 40186 CONTEXT_BLOCK_IN === nodeContext; 40187 40188 if (allowToSeek) { 40189 if (skipSeparationSpace(state, true, -1)) { 40190 atNewLine = true; 40191 40192 if (state.lineIndent > parentIndent) { 40193 indentStatus = 1; 40194 } else if (state.lineIndent === parentIndent) { 40195 indentStatus = 0; 40196 } else if (state.lineIndent < parentIndent) { 40197 indentStatus = -1; 40198 } 40199 } 40200 } 40201 40202 if (indentStatus === 1) { 40203 while (readTagProperty(state) || readAnchorProperty(state)) { 40204 if (skipSeparationSpace(state, true, -1)) { 40205 atNewLine = true; 40206 allowBlockCollections = allowBlockStyles; 40207 40208 if (state.lineIndent > parentIndent) { 40209 indentStatus = 1; 40210 } else if (state.lineIndent === parentIndent) { 40211 indentStatus = 0; 40212 } else if (state.lineIndent < parentIndent) { 40213 indentStatus = -1; 40214 } 40215 } else { 40216 allowBlockCollections = false; 40217 } 40218 } 40219 } 40220 40221 if (allowBlockCollections) { 40222 allowBlockCollections = atNewLine || allowCompact; 40223 } 40224 40225 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { 40226 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { 40227 flowIndent = parentIndent; 40228 } else { 40229 flowIndent = parentIndent + 1; 40230 } 40231 40232 blockIndent = state.position - state.lineStart; 40233 40234 if (indentStatus === 1) { 40235 if (allowBlockCollections && 40236 (readBlockSequence(state, blockIndent) || 40237 readBlockMapping(state, blockIndent, flowIndent)) || 40238 readFlowCollection(state, flowIndent)) { 40239 hasContent = true; 40240 } else { 40241 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || 40242 readSingleQuotedScalar(state, flowIndent) || 40243 readDoubleQuotedScalar(state, flowIndent)) { 40244 hasContent = true; 40245 40246 } else if (readAlias(state)) { 40247 hasContent = true; 40248 40249 if (state.tag !== null || state.anchor !== null) { 40250 throwError(state, 'alias node should not have any properties'); 40251 } 40252 40253 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { 40254 hasContent = true; 40255 40256 if (state.tag === null) { 40257 state.tag = '?'; 40258 } 40259 } 40260 40261 if (state.anchor !== null) { 40262 state.anchorMap[state.anchor] = state.result; 40263 } 40264 } 40265 } else if (indentStatus === 0) { 40266 // Special case: block sequences are allowed to have same indentation level as the parent. 40267 // http://www.yaml.org/spec/1.2/spec.html#id2799784 40268 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); 40269 } 40270 } 40271 40272 if (state.tag !== null && state.tag !== '!') { 40273 if (state.tag === '?') { 40274 for (typeIndex = 0, typeQuantity = state.implicitTypes.length; 40275 typeIndex < typeQuantity; 40276 typeIndex += 1) { 40277 type = state.implicitTypes[typeIndex]; 40278 40279 // Implicit resolving is not allowed for non-scalar types, and '?' 40280 // non-specific tag is only assigned to plain scalars. So, it isn't 40281 // needed to check for 'kind' conformity. 40282 40283 if (type.resolve(state.result)) { // `state.result` updated in resolver if matched 40284 state.result = type.construct(state.result); 40285 state.tag = type.tag; 40286 if (state.anchor !== null) { 40287 state.anchorMap[state.anchor] = state.result; 40288 } 40289 break; 40290 } 40291 } 40292 } else if (_hasOwnProperty.call(state.typeMap, state.tag)) { 40293 type = state.typeMap[state.tag]; 40294 40295 if (state.result !== null && type.kind !== state.kind) { 40296 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); 40297 } 40298 40299 if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched 40300 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); 40301 } else { 40302 state.result = type.construct(state.result); 40303 if (state.anchor !== null) { 40304 state.anchorMap[state.anchor] = state.result; 40305 } 40306 } 40307 } else { 40308 throwError(state, 'unknown tag !<' + state.tag + '>'); 40309 } 40310 } 40311 40312 if (state.listener !== null) { 40313 state.listener('close', state); 40314 } 40315 return state.tag !== null || state.anchor !== null || hasContent; 40316 } 40317 40318 function readDocument(state) { 40319 var documentStart = state.position, 40320 _position, 40321 directiveName, 40322 directiveArgs, 40323 hasDirectives = false, 40324 ch; 40325 40326 state.version = null; 40327 state.checkLineBreaks = state.legacy; 40328 state.tagMap = {}; 40329 state.anchorMap = {}; 40330 40331 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 40332 skipSeparationSpace(state, true, -1); 40333 40334 ch = state.input.charCodeAt(state.position); 40335 40336 if (state.lineIndent > 0 || ch !== 0x25/* % */) { 40337 break; 40338 } 40339 40340 hasDirectives = true; 40341 ch = state.input.charCodeAt(++state.position); 40342 _position = state.position; 40343 40344 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 40345 ch = state.input.charCodeAt(++state.position); 40346 } 40347 40348 directiveName = state.input.slice(_position, state.position); 40349 directiveArgs = []; 40350 40351 if (directiveName.length < 1) { 40352 throwError(state, 'directive name must not be less than one character in length'); 40353 } 40354 40355 while (ch !== 0) { 40356 while (is_WHITE_SPACE(ch)) { 40357 ch = state.input.charCodeAt(++state.position); 40358 } 40359 40360 if (ch === 0x23/* # */) { 40361 do { ch = state.input.charCodeAt(++state.position); } 40362 while (ch !== 0 && !is_EOL(ch)); 40363 break; 40364 } 40365 40366 if (is_EOL(ch)) break; 40367 40368 _position = state.position; 40369 40370 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 40371 ch = state.input.charCodeAt(++state.position); 40372 } 40373 40374 directiveArgs.push(state.input.slice(_position, state.position)); 40375 } 40376 40377 if (ch !== 0) readLineBreak(state); 40378 40379 if (_hasOwnProperty.call(directiveHandlers, directiveName)) { 40380 directiveHandlers[directiveName](state, directiveName, directiveArgs); 40381 } else { 40382 throwWarning(state, 'unknown document directive "' + directiveName + '"'); 40383 } 40384 } 40385 40386 skipSeparationSpace(state, true, -1); 40387 40388 if (state.lineIndent === 0 && 40389 state.input.charCodeAt(state.position) === 0x2D/* - */ && 40390 state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && 40391 state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { 40392 state.position += 3; 40393 skipSeparationSpace(state, true, -1); 40394 40395 } else if (hasDirectives) { 40396 throwError(state, 'directives end mark is expected'); 40397 } 40398 40399 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); 40400 skipSeparationSpace(state, true, -1); 40401 40402 if (state.checkLineBreaks && 40403 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { 40404 throwWarning(state, 'non-ASCII line breaks are interpreted as content'); 40405 } 40406 40407 state.documents.push(state.result); 40408 40409 if (state.position === state.lineStart && testDocumentSeparator(state)) { 40410 40411 if (state.input.charCodeAt(state.position) === 0x2E/* . */) { 40412 state.position += 3; 40413 skipSeparationSpace(state, true, -1); 40414 } 40415 return; 40416 } 40417 40418 if (state.position < (state.length - 1)) { 40419 throwError(state, 'end of the stream or a document separator is expected'); 40420 } else { 40421 return; 40422 } 40423 } 40424 40425 40426 function loadDocuments(input, options) { 40427 input = String(input); 40428 options = options || {}; 40429 40430 if (input.length !== 0) { 40431 40432 // Add tailing `\n` if not exists 40433 if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && 40434 input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { 40435 input += '\n'; 40436 } 40437 40438 // Strip BOM 40439 if (input.charCodeAt(0) === 0xFEFF) { 40440 input = input.slice(1); 40441 } 40442 } 40443 40444 var state = new State(input, options); 40445 40446 // Use 0 as string terminator. That significantly simplifies bounds check. 40447 state.input += '\0'; 40448 40449 while (state.input.charCodeAt(state.position) === 0x20/* Space */) { 40450 state.lineIndent += 1; 40451 state.position += 1; 40452 } 40453 40454 while (state.position < (state.length - 1)) { 40455 readDocument(state); 40456 } 40457 40458 return state.documents; 40459 } 40460 40461 40462 function loadAll(input, iterator, options) { 40463 var documents = loadDocuments(input, options), index, length; 40464 40465 for (index = 0, length = documents.length; index < length; index += 1) { 40466 iterator(documents[index]); 40467 } 40468 } 40469 40470 40471 function load(input, options) { 40472 var documents = loadDocuments(input, options); 40473 40474 if (documents.length === 0) { 40475 /*eslint-disable no-undefined*/ 40476 return undefined; 40477 } else if (documents.length === 1) { 40478 return documents[0]; 40479 } 40480 throw new YAMLException('expected a single document in the stream, but found more'); 40481 } 40482 40483 40484 function safeLoadAll(input, output, options) { 40485 loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); 40486 } 40487 40488 40489 function safeLoad(input, options) { 40490 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); 40491 } 40492 40493 40494 module.exports.loadAll = loadAll; 40495 module.exports.load = load; 40496 module.exports.safeLoadAll = safeLoadAll; 40497 module.exports.safeLoad = safeLoad; 40498 40499 40500 /***/ }, 40501 /* 91 */ 40502 /***/ function(module, exports, __webpack_require__) { 40503 40504 'use strict'; 40505 40506 40507 var common = __webpack_require__(7); 40508 40509 40510 function Mark(name, buffer, position, line, column) { 40511 this.name = name; 40512 this.buffer = buffer; 40513 this.position = position; 40514 this.line = line; 40515 this.column = column; 40516 } 40517 40518 40519 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) { 40520 var head, start, tail, end, snippet; 40521 40522 if (!this.buffer) return null; 40523 40524 indent = indent || 4; 40525 maxLength = maxLength || 75; 40526 40527 head = ''; 40528 start = this.position; 40529 40530 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) { 40531 start -= 1; 40532 if (this.position - start > (maxLength / 2 - 1)) { 40533 head = ' ... '; 40534 start += 5; 40535 break; 40536 } 40537 } 40538 40539 tail = ''; 40540 end = this.position; 40541 40542 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) { 40543 end += 1; 40544 if (end - this.position > (maxLength / 2 - 1)) { 40545 tail = ' ... '; 40546 end -= 5; 40547 break; 40548 } 40549 } 40550 40551 snippet = this.buffer.slice(start, end); 40552 40553 return common.repeat(' ', indent) + head + snippet + tail + '\n' + 40554 common.repeat(' ', indent + this.position - start + head.length) + '^'; 40555 }; 40556 40557 40558 Mark.prototype.toString = function toString(compact) { 40559 var snippet, where = ''; 40560 40561 if (this.name) { 40562 where += 'in "' + this.name + '" '; 40563 } 40564 40565 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1); 40566 40567 if (!compact) { 40568 snippet = this.getSnippet(); 40569 40570 if (snippet) { 40571 where += ':\n' + snippet; 40572 } 40573 } 40574 40575 return where; 40576 }; 40577 40578 40579 module.exports = Mark; 40580 40581 40582 /***/ }, 40583 /* 92 */ 40584 /***/ function(module, exports, __webpack_require__) { 40585 40586 var require;'use strict'; 40587 40588 /*eslint-disable no-bitwise*/ 40589 40590 var NodeBuffer; 40591 40592 try { 40593 // A trick for browserified version, to not include `Buffer` shim 40594 var _require = require; 40595 NodeBuffer = __webpack_require__(26).Buffer; 40596 } catch (__) {} 40597 40598 var Type = __webpack_require__(3); 40599 40600 40601 // [ 64, 65, 66 ] -> [ padding, CR, LF ] 40602 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; 40603 40604 40605 function resolveYamlBinary(data) { 40606 if (data === null) return false; 40607 40608 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; 40609 40610 // Convert one by one. 40611 for (idx = 0; idx < max; idx++) { 40612 code = map.indexOf(data.charAt(idx)); 40613 40614 // Skip CR/LF 40615 if (code > 64) continue; 40616 40617 // Fail on illegal characters 40618 if (code < 0) return false; 40619 40620 bitlen += 6; 40621 } 40622 40623 // If there are any bits left, source was corrupted 40624 return (bitlen % 8) === 0; 40625 } 40626 40627 function constructYamlBinary(data) { 40628 var idx, tailbits, 40629 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan 40630 max = input.length, 40631 map = BASE64_MAP, 40632 bits = 0, 40633 result = []; 40634 40635 // Collect by 6*4 bits (3 bytes) 40636 40637 for (idx = 0; idx < max; idx++) { 40638 if ((idx % 4 === 0) && idx) { 40639 result.push((bits >> 16) & 0xFF); 40640 result.push((bits >> 8) & 0xFF); 40641 result.push(bits & 0xFF); 40642 } 40643 40644 bits = (bits << 6) | map.indexOf(input.charAt(idx)); 40645 } 40646 40647 // Dump tail 40648 40649 tailbits = (max % 4) * 6; 40650 40651 if (tailbits === 0) { 40652 result.push((bits >> 16) & 0xFF); 40653 result.push((bits >> 8) & 0xFF); 40654 result.push(bits & 0xFF); 40655 } else if (tailbits === 18) { 40656 result.push((bits >> 10) & 0xFF); 40657 result.push((bits >> 2) & 0xFF); 40658 } else if (tailbits === 12) { 40659 result.push((bits >> 4) & 0xFF); 40660 } 40661 40662 // Wrap into Buffer for NodeJS and leave Array for browser 40663 if (NodeBuffer) return new NodeBuffer(result); 40664 40665 return result; 40666 } 40667 40668 function representYamlBinary(object /*, style*/) { 40669 var result = '', bits = 0, idx, tail, 40670 max = object.length, 40671 map = BASE64_MAP; 40672 40673 // Convert every three bytes to 4 ASCII characters. 40674 40675 for (idx = 0; idx < max; idx++) { 40676 if ((idx % 3 === 0) && idx) { 40677 result += map[(bits >> 18) & 0x3F]; 40678 result += map[(bits >> 12) & 0x3F]; 40679 result += map[(bits >> 6) & 0x3F]; 40680 result += map[bits & 0x3F]; 40681 } 40682 40683 bits = (bits << 8) + object[idx]; 40684 } 40685 40686 // Dump tail 40687 40688 tail = max % 3; 40689 40690 if (tail === 0) { 40691 result += map[(bits >> 18) & 0x3F]; 40692 result += map[(bits >> 12) & 0x3F]; 40693 result += map[(bits >> 6) & 0x3F]; 40694 result += map[bits & 0x3F]; 40695 } else if (tail === 2) { 40696 result += map[(bits >> 10) & 0x3F]; 40697 result += map[(bits >> 4) & 0x3F]; 40698 result += map[(bits << 2) & 0x3F]; 40699 result += map[64]; 40700 } else if (tail === 1) { 40701 result += map[(bits >> 2) & 0x3F]; 40702 result += map[(bits << 4) & 0x3F]; 40703 result += map[64]; 40704 result += map[64]; 40705 } 40706 40707 return result; 40708 } 40709 40710 function isBinary(object) { 40711 return NodeBuffer && NodeBuffer.isBuffer(object); 40712 } 40713 40714 module.exports = new Type('tag:yaml.org,2002:binary', { 40715 kind: 'scalar', 40716 resolve: resolveYamlBinary, 40717 construct: constructYamlBinary, 40718 predicate: isBinary, 40719 represent: representYamlBinary 40720 }); 40721 40722 40723 /***/ }, 40724 /* 93 */ 40725 /***/ function(module, exports, __webpack_require__) { 40726 40727 'use strict'; 40728 40729 var Type = __webpack_require__(3); 40730 40731 function resolveYamlBoolean(data) { 40732 if (data === null) return false; 40733 40734 var max = data.length; 40735 40736 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || 40737 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); 40738 } 40739 40740 function constructYamlBoolean(data) { 40741 return data === 'true' || 40742 data === 'True' || 40743 data === 'TRUE'; 40744 } 40745 40746 function isBoolean(object) { 40747 return Object.prototype.toString.call(object) === '[object Boolean]'; 40748 } 40749 40750 module.exports = new Type('tag:yaml.org,2002:bool', { 40751 kind: 'scalar', 40752 resolve: resolveYamlBoolean, 40753 construct: constructYamlBoolean, 40754 predicate: isBoolean, 40755 represent: { 40756 lowercase: function (object) { return object ? 'true' : 'false'; }, 40757 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, 40758 camelcase: function (object) { return object ? 'True' : 'False'; } 40759 }, 40760 defaultStyle: 'lowercase' 40761 }); 40762 40763 40764 /***/ }, 40765 /* 94 */ 40766 /***/ function(module, exports, __webpack_require__) { 40767 40768 'use strict'; 40769 40770 var common = __webpack_require__(7); 40771 var Type = __webpack_require__(3); 40772 40773 var YAML_FLOAT_PATTERN = new RegExp( 40774 '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' + 40775 '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' + 40776 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + 40777 '|[-+]?\\.(?:inf|Inf|INF)' + 40778 '|\\.(?:nan|NaN|NAN))$'); 40779 40780 function resolveYamlFloat(data) { 40781 if (data === null) return false; 40782 40783 if (!YAML_FLOAT_PATTERN.test(data)) return false; 40784 40785 return true; 40786 } 40787 40788 function constructYamlFloat(data) { 40789 var value, sign, base, digits; 40790 40791 value = data.replace(/_/g, '').toLowerCase(); 40792 sign = value[0] === '-' ? -1 : 1; 40793 digits = []; 40794 40795 if ('+-'.indexOf(value[0]) >= 0) { 40796 value = value.slice(1); 40797 } 40798 40799 if (value === '.inf') { 40800 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; 40801 40802 } else if (value === '.nan') { 40803 return NaN; 40804 40805 } else if (value.indexOf(':') >= 0) { 40806 value.split(':').forEach(function (v) { 40807 digits.unshift(parseFloat(v, 10)); 40808 }); 40809 40810 value = 0.0; 40811 base = 1; 40812 40813 digits.forEach(function (d) { 40814 value += d * base; 40815 base *= 60; 40816 }); 40817 40818 return sign * value; 40819 40820 } 40821 return sign * parseFloat(value, 10); 40822 } 40823 40824 40825 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; 40826 40827 function representYamlFloat(object, style) { 40828 var res; 40829 40830 if (isNaN(object)) { 40831 switch (style) { 40832 case 'lowercase': return '.nan'; 40833 case 'uppercase': return '.NAN'; 40834 case 'camelcase': return '.NaN'; 40835 } 40836 } else if (Number.POSITIVE_INFINITY === object) { 40837 switch (style) { 40838 case 'lowercase': return '.inf'; 40839 case 'uppercase': return '.INF'; 40840 case 'camelcase': return '.Inf'; 40841 } 40842 } else if (Number.NEGATIVE_INFINITY === object) { 40843 switch (style) { 40844 case 'lowercase': return '-.inf'; 40845 case 'uppercase': return '-.INF'; 40846 case 'camelcase': return '-.Inf'; 40847 } 40848 } else if (common.isNegativeZero(object)) { 40849 return '-0.0'; 40850 } 40851 40852 res = object.toString(10); 40853 40854 // JS stringifier can build scientific format without dots: 5e-100, 40855 // while YAML requres dot: 5.e-100. Fix it with simple hack 40856 40857 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; 40858 } 40859 40860 function isFloat(object) { 40861 return (Object.prototype.toString.call(object) === '[object Number]') && 40862 (object % 1 !== 0 || common.isNegativeZero(object)); 40863 } 40864 40865 module.exports = new Type('tag:yaml.org,2002:float', { 40866 kind: 'scalar', 40867 resolve: resolveYamlFloat, 40868 construct: constructYamlFloat, 40869 predicate: isFloat, 40870 represent: representYamlFloat, 40871 defaultStyle: 'lowercase' 40872 }); 40873 40874 40875 /***/ }, 40876 /* 95 */ 40877 /***/ function(module, exports, __webpack_require__) { 40878 40879 'use strict'; 40880 40881 var common = __webpack_require__(7); 40882 var Type = __webpack_require__(3); 40883 40884 function isHexCode(c) { 40885 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || 40886 ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || 40887 ((0x61/* a */ <= c) && (c <= 0x66/* f */)); 40888 } 40889 40890 function isOctCode(c) { 40891 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); 40892 } 40893 40894 function isDecCode(c) { 40895 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); 40896 } 40897 40898 function resolveYamlInteger(data) { 40899 if (data === null) return false; 40900 40901 var max = data.length, 40902 index = 0, 40903 hasDigits = false, 40904 ch; 40905 40906 if (!max) return false; 40907 40908 ch = data[index]; 40909 40910 // sign 40911 if (ch === '-' || ch === '+') { 40912 ch = data[++index]; 40913 } 40914 40915 if (ch === '0') { 40916 // 0 40917 if (index + 1 === max) return true; 40918 ch = data[++index]; 40919 40920 // base 2, base 8, base 16 40921 40922 if (ch === 'b') { 40923 // base 2 40924 index++; 40925 40926 for (; index < max; index++) { 40927 ch = data[index]; 40928 if (ch === '_') continue; 40929 if (ch !== '0' && ch !== '1') return false; 40930 hasDigits = true; 40931 } 40932 return hasDigits; 40933 } 40934 40935 40936 if (ch === 'x') { 40937 // base 16 40938 index++; 40939 40940 for (; index < max; index++) { 40941 ch = data[index]; 40942 if (ch === '_') continue; 40943 if (!isHexCode(data.charCodeAt(index))) return false; 40944 hasDigits = true; 40945 } 40946 return hasDigits; 40947 } 40948 40949 // base 8 40950 for (; index < max; index++) { 40951 ch = data[index]; 40952 if (ch === '_') continue; 40953 if (!isOctCode(data.charCodeAt(index))) return false; 40954 hasDigits = true; 40955 } 40956 return hasDigits; 40957 } 40958 40959 // base 10 (except 0) or base 60 40960 40961 for (; index < max; index++) { 40962 ch = data[index]; 40963 if (ch === '_') continue; 40964 if (ch === ':') break; 40965 if (!isDecCode(data.charCodeAt(index))) { 40966 return false; 40967 } 40968 hasDigits = true; 40969 } 40970 40971 if (!hasDigits) return false; 40972 40973 // if !base60 - done; 40974 if (ch !== ':') return true; 40975 40976 // base60 almost not used, no needs to optimize 40977 return /^(:[0-5]?[0-9])+$/.test(data.slice(index)); 40978 } 40979 40980 function constructYamlInteger(data) { 40981 var value = data, sign = 1, ch, base, digits = []; 40982 40983 if (value.indexOf('_') !== -1) { 40984 value = value.replace(/_/g, ''); 40985 } 40986 40987 ch = value[0]; 40988 40989 if (ch === '-' || ch === '+') { 40990 if (ch === '-') sign = -1; 40991 value = value.slice(1); 40992 ch = value[0]; 40993 } 40994 40995 if (value === '0') return 0; 40996 40997 if (ch === '0') { 40998 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); 40999 if (value[1] === 'x') return sign * parseInt(value, 16); 41000 return sign * parseInt(value, 8); 41001 } 41002 41003 if (value.indexOf(':') !== -1) { 41004 value.split(':').forEach(function (v) { 41005 digits.unshift(parseInt(v, 10)); 41006 }); 41007 41008 value = 0; 41009 base = 1; 41010 41011 digits.forEach(function (d) { 41012 value += (d * base); 41013 base *= 60; 41014 }); 41015 41016 return sign * value; 41017 41018 } 41019 41020 return sign * parseInt(value, 10); 41021 } 41022 41023 function isInteger(object) { 41024 return (Object.prototype.toString.call(object)) === '[object Number]' && 41025 (object % 1 === 0 && !common.isNegativeZero(object)); 41026 } 41027 41028 module.exports = new Type('tag:yaml.org,2002:int', { 41029 kind: 'scalar', 41030 resolve: resolveYamlInteger, 41031 construct: constructYamlInteger, 41032 predicate: isInteger, 41033 represent: { 41034 binary: function (object) { return '0b' + object.toString(2); }, 41035 octal: function (object) { return '0' + object.toString(8); }, 41036 decimal: function (object) { return object.toString(10); }, 41037 hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); } 41038 }, 41039 defaultStyle: 'decimal', 41040 styleAliases: { 41041 binary: [ 2, 'bin' ], 41042 octal: [ 8, 'oct' ], 41043 decimal: [ 10, 'dec' ], 41044 hexadecimal: [ 16, 'hex' ] 41045 } 41046 }); 41047 41048 41049 /***/ }, 41050 /* 96 */ 41051 /***/ function(module, exports, __webpack_require__) { 41052 41053 var require;'use strict'; 41054 41055 var esprima; 41056 41057 // Browserified version does not have esprima 41058 // 41059 // 1. For node.js just require module as deps 41060 // 2. For browser try to require mudule via external AMD system. 41061 // If not found - try to fallback to window.esprima. If not 41062 // found too - then fail to parse. 41063 // 41064 try { 41065 // workaround to exclude package from browserify list. 41066 var _require = require; 41067 esprima = __webpack_require__(72); 41068 } catch (_) { 41069 /*global window */ 41070 if (typeof window !== 'undefined') esprima = window.esprima; 41071 } 41072 41073 var Type = __webpack_require__(3); 41074 41075 function resolveJavascriptFunction(data) { 41076 if (data === null) return false; 41077 41078 try { 41079 var source = '(' + data + ')', 41080 ast = esprima.parse(source, { range: true }); 41081 41082 if (ast.type !== 'Program' || 41083 ast.body.length !== 1 || 41084 ast.body[0].type !== 'ExpressionStatement' || 41085 ast.body[0].expression.type !== 'FunctionExpression') { 41086 return false; 41087 } 41088 41089 return true; 41090 } catch (err) { 41091 return false; 41092 } 41093 } 41094 41095 function constructJavascriptFunction(data) { 41096 /*jslint evil:true*/ 41097 41098 var source = '(' + data + ')', 41099 ast = esprima.parse(source, { range: true }), 41100 params = [], 41101 body; 41102 41103 if (ast.type !== 'Program' || 41104 ast.body.length !== 1 || 41105 ast.body[0].type !== 'ExpressionStatement' || 41106 ast.body[0].expression.type !== 'FunctionExpression') { 41107 throw new Error('Failed to resolve function'); 41108 } 41109 41110 ast.body[0].expression.params.forEach(function (param) { 41111 params.push(param.name); 41112 }); 41113 41114 body = ast.body[0].expression.body.range; 41115 41116 // Esprima's ranges include the first '{' and the last '}' characters on 41117 // function expressions. So cut them out. 41118 /*eslint-disable no-new-func*/ 41119 return new Function(params, source.slice(body[0] + 1, body[1] - 1)); 41120 } 41121 41122 function representJavascriptFunction(object /*, style*/) { 41123 return object.toString(); 41124 } 41125 41126 function isFunction(object) { 41127 return Object.prototype.toString.call(object) === '[object Function]'; 41128 } 41129 41130 module.exports = new Type('tag:yaml.org,2002:js/function', { 41131 kind: 'scalar', 41132 resolve: resolveJavascriptFunction, 41133 construct: constructJavascriptFunction, 41134 predicate: isFunction, 41135 represent: representJavascriptFunction 41136 }); 41137 41138 41139 /***/ }, 41140 /* 97 */ 41141 /***/ function(module, exports, __webpack_require__) { 41142 41143 'use strict'; 41144 41145 var Type = __webpack_require__(3); 41146 41147 function resolveJavascriptRegExp(data) { 41148 if (data === null) return false; 41149 if (data.length === 0) return false; 41150 41151 var regexp = data, 41152 tail = /\/([gim]*)$/.exec(data), 41153 modifiers = ''; 41154 41155 // if regexp starts with '/' it can have modifiers and must be properly closed 41156 // `/foo/gim` - modifiers tail can be maximum 3 chars 41157 if (regexp[0] === '/') { 41158 if (tail) modifiers = tail[1]; 41159 41160 if (modifiers.length > 3) return false; 41161 // if expression starts with /, is should be properly terminated 41162 if (regexp[regexp.length - modifiers.length - 1] !== '/') return false; 41163 } 41164 41165 return true; 41166 } 41167 41168 function constructJavascriptRegExp(data) { 41169 var regexp = data, 41170 tail = /\/([gim]*)$/.exec(data), 41171 modifiers = ''; 41172 41173 // `/foo/gim` - tail can be maximum 4 chars 41174 if (regexp[0] === '/') { 41175 if (tail) modifiers = tail[1]; 41176 regexp = regexp.slice(1, regexp.length - modifiers.length - 1); 41177 } 41178 41179 return new RegExp(regexp, modifiers); 41180 } 41181 41182 function representJavascriptRegExp(object /*, style*/) { 41183 var result = '/' + object.source + '/'; 41184 41185 if (object.global) result += 'g'; 41186 if (object.multiline) result += 'm'; 41187 if (object.ignoreCase) result += 'i'; 41188 41189 return result; 41190 } 41191 41192 function isRegExp(object) { 41193 return Object.prototype.toString.call(object) === '[object RegExp]'; 41194 } 41195 41196 module.exports = new Type('tag:yaml.org,2002:js/regexp', { 41197 kind: 'scalar', 41198 resolve: resolveJavascriptRegExp, 41199 construct: constructJavascriptRegExp, 41200 predicate: isRegExp, 41201 represent: representJavascriptRegExp 41202 }); 41203 41204 41205 /***/ }, 41206 /* 98 */ 41207 /***/ function(module, exports, __webpack_require__) { 41208 41209 'use strict'; 41210 41211 var Type = __webpack_require__(3); 41212 41213 function resolveJavascriptUndefined() { 41214 return true; 41215 } 41216 41217 function constructJavascriptUndefined() { 41218 /*eslint-disable no-undefined*/ 41219 return undefined; 41220 } 41221 41222 function representJavascriptUndefined() { 41223 return ''; 41224 } 41225 41226 function isUndefined(object) { 41227 return typeof object === 'undefined'; 41228 } 41229 41230 module.exports = new Type('tag:yaml.org,2002:js/undefined', { 41231 kind: 'scalar', 41232 resolve: resolveJavascriptUndefined, 41233 construct: constructJavascriptUndefined, 41234 predicate: isUndefined, 41235 represent: representJavascriptUndefined 41236 }); 41237 41238 41239 /***/ }, 41240 /* 99 */ 41241 /***/ function(module, exports, __webpack_require__) { 41242 41243 'use strict'; 41244 41245 var Type = __webpack_require__(3); 41246 41247 module.exports = new Type('tag:yaml.org,2002:map', { 41248 kind: 'mapping', 41249 construct: function (data) { return data !== null ? data : {}; } 41250 }); 41251 41252 41253 /***/ }, 41254 /* 100 */ 41255 /***/ function(module, exports, __webpack_require__) { 41256 41257 'use strict'; 41258 41259 var Type = __webpack_require__(3); 41260 41261 function resolveYamlMerge(data) { 41262 return data === '<<' || data === null; 41263 } 41264 41265 module.exports = new Type('tag:yaml.org,2002:merge', { 41266 kind: 'scalar', 41267 resolve: resolveYamlMerge 41268 }); 41269 41270 41271 /***/ }, 41272 /* 101 */ 41273 /***/ function(module, exports, __webpack_require__) { 41274 41275 'use strict'; 41276 41277 var Type = __webpack_require__(3); 41278 41279 function resolveYamlNull(data) { 41280 if (data === null) return true; 41281 41282 var max = data.length; 41283 41284 return (max === 1 && data === '~') || 41285 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); 41286 } 41287 41288 function constructYamlNull() { 41289 return null; 41290 } 41291 41292 function isNull(object) { 41293 return object === null; 41294 } 41295 41296 module.exports = new Type('tag:yaml.org,2002:null', { 41297 kind: 'scalar', 41298 resolve: resolveYamlNull, 41299 construct: constructYamlNull, 41300 predicate: isNull, 41301 represent: { 41302 canonical: function () { return '~'; }, 41303 lowercase: function () { return 'null'; }, 41304 uppercase: function () { return 'NULL'; }, 41305 camelcase: function () { return 'Null'; } 41306 }, 41307 defaultStyle: 'lowercase' 41308 }); 41309 41310 41311 /***/ }, 41312 /* 102 */ 41313 /***/ function(module, exports, __webpack_require__) { 41314 41315 'use strict'; 41316 41317 var Type = __webpack_require__(3); 41318 41319 var _hasOwnProperty = Object.prototype.hasOwnProperty; 41320 var _toString = Object.prototype.toString; 41321 41322 function resolveYamlOmap(data) { 41323 if (data === null) return true; 41324 41325 var objectKeys = [], index, length, pair, pairKey, pairHasKey, 41326 object = data; 41327 41328 for (index = 0, length = object.length; index < length; index += 1) { 41329 pair = object[index]; 41330 pairHasKey = false; 41331 41332 if (_toString.call(pair) !== '[object Object]') return false; 41333 41334 for (pairKey in pair) { 41335 if (_hasOwnProperty.call(pair, pairKey)) { 41336 if (!pairHasKey) pairHasKey = true; 41337 else return false; 41338 } 41339 } 41340 41341 if (!pairHasKey) return false; 41342 41343 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); 41344 else return false; 41345 } 41346 41347 return true; 41348 } 41349 41350 function constructYamlOmap(data) { 41351 return data !== null ? data : []; 41352 } 41353 41354 module.exports = new Type('tag:yaml.org,2002:omap', { 41355 kind: 'sequence', 41356 resolve: resolveYamlOmap, 41357 construct: constructYamlOmap 41358 }); 41359 41360 41361 /***/ }, 41362 /* 103 */ 41363 /***/ function(module, exports, __webpack_require__) { 41364 41365 'use strict'; 41366 41367 var Type = __webpack_require__(3); 41368 41369 var _toString = Object.prototype.toString; 41370 41371 function resolveYamlPairs(data) { 41372 if (data === null) return true; 41373 41374 var index, length, pair, keys, result, 41375 object = data; 41376 41377 result = new Array(object.length); 41378 41379 for (index = 0, length = object.length; index < length; index += 1) { 41380 pair = object[index]; 41381 41382 if (_toString.call(pair) !== '[object Object]') return false; 41383 41384 keys = Object.keys(pair); 41385 41386 if (keys.length !== 1) return false; 41387 41388 result[index] = [ keys[0], pair[keys[0]] ]; 41389 } 41390 41391 return true; 41392 } 41393 41394 function constructYamlPairs(data) { 41395 if (data === null) return []; 41396 41397 var index, length, pair, keys, result, 41398 object = data; 41399 41400 result = new Array(object.length); 41401 41402 for (index = 0, length = object.length; index < length; index += 1) { 41403 pair = object[index]; 41404 41405 keys = Object.keys(pair); 41406 41407 result[index] = [ keys[0], pair[keys[0]] ]; 41408 } 41409 41410 return result; 41411 } 41412 41413 module.exports = new Type('tag:yaml.org,2002:pairs', { 41414 kind: 'sequence', 41415 resolve: resolveYamlPairs, 41416 construct: constructYamlPairs 41417 }); 41418 41419 41420 /***/ }, 41421 /* 104 */ 41422 /***/ function(module, exports, __webpack_require__) { 41423 41424 'use strict'; 41425 41426 var Type = __webpack_require__(3); 41427 41428 module.exports = new Type('tag:yaml.org,2002:seq', { 41429 kind: 'sequence', 41430 construct: function (data) { return data !== null ? data : []; } 41431 }); 41432 41433 41434 /***/ }, 41435 /* 105 */ 41436 /***/ function(module, exports, __webpack_require__) { 41437 41438 'use strict'; 41439 41440 var Type = __webpack_require__(3); 41441 41442 var _hasOwnProperty = Object.prototype.hasOwnProperty; 41443 41444 function resolveYamlSet(data) { 41445 if (data === null) return true; 41446 41447 var key, object = data; 41448 41449 for (key in object) { 41450 if (_hasOwnProperty.call(object, key)) { 41451 if (object[key] !== null) return false; 41452 } 41453 } 41454 41455 return true; 41456 } 41457 41458 function constructYamlSet(data) { 41459 return data !== null ? data : {}; 41460 } 41461 41462 module.exports = new Type('tag:yaml.org,2002:set', { 41463 kind: 'mapping', 41464 resolve: resolveYamlSet, 41465 construct: constructYamlSet 41466 }); 41467 41468 41469 /***/ }, 41470 /* 106 */ 41471 /***/ function(module, exports, __webpack_require__) { 41472 41473 'use strict'; 41474 41475 var Type = __webpack_require__(3); 41476 41477 module.exports = new Type('tag:yaml.org,2002:str', { 41478 kind: 'scalar', 41479 construct: function (data) { return data !== null ? data : ''; } 41480 }); 41481 41482 41483 /***/ }, 41484 /* 107 */ 41485 /***/ function(module, exports, __webpack_require__) { 41486 41487 'use strict'; 41488 41489 var Type = __webpack_require__(3); 41490 41491 var YAML_DATE_REGEXP = new RegExp( 41492 '^([0-9][0-9][0-9][0-9])' + // [1] year 41493 '-([0-9][0-9])' + // [2] month 41494 '-([0-9][0-9])$'); // [3] day 41495 41496 var YAML_TIMESTAMP_REGEXP = new RegExp( 41497 '^([0-9][0-9][0-9][0-9])' + // [1] year 41498 '-([0-9][0-9]?)' + // [2] month 41499 '-([0-9][0-9]?)' + // [3] day 41500 '(?:[Tt]|[ \\t]+)' + // ... 41501 '([0-9][0-9]?)' + // [4] hour 41502 ':([0-9][0-9])' + // [5] minute 41503 ':([0-9][0-9])' + // [6] second 41504 '(?:\\.([0-9]*))?' + // [7] fraction 41505 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour 41506 '(?::([0-9][0-9]))?))?$'); // [11] tz_minute 41507 41508 function resolveYamlTimestamp(data) { 41509 if (data === null) return false; 41510 if (YAML_DATE_REGEXP.exec(data) !== null) return true; 41511 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; 41512 return false; 41513 } 41514 41515 function constructYamlTimestamp(data) { 41516 var match, year, month, day, hour, minute, second, fraction = 0, 41517 delta = null, tz_hour, tz_minute, date; 41518 41519 match = YAML_DATE_REGEXP.exec(data); 41520 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); 41521 41522 if (match === null) throw new Error('Date resolve error'); 41523 41524 // match: [1] year [2] month [3] day 41525 41526 year = +(match[1]); 41527 month = +(match[2]) - 1; // JS month starts with 0 41528 day = +(match[3]); 41529 41530 if (!match[4]) { // no hour 41531 return new Date(Date.UTC(year, month, day)); 41532 } 41533 41534 // match: [4] hour [5] minute [6] second [7] fraction 41535 41536 hour = +(match[4]); 41537 minute = +(match[5]); 41538 second = +(match[6]); 41539 41540 if (match[7]) { 41541 fraction = match[7].slice(0, 3); 41542 while (fraction.length < 3) { // milli-seconds 41543 fraction += '0'; 41544 } 41545 fraction = +fraction; 41546 } 41547 41548 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute 41549 41550 if (match[9]) { 41551 tz_hour = +(match[10]); 41552 tz_minute = +(match[11] || 0); 41553 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds 41554 if (match[9] === '-') delta = -delta; 41555 } 41556 41557 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); 41558 41559 if (delta) date.setTime(date.getTime() - delta); 41560 41561 return date; 41562 } 41563 41564 function representYamlTimestamp(object /*, style*/) { 41565 return object.toISOString(); 41566 } 41567 41568 module.exports = new Type('tag:yaml.org,2002:timestamp', { 41569 kind: 'scalar', 41570 resolve: resolveYamlTimestamp, 41571 construct: constructYamlTimestamp, 41572 instanceOf: Date, 41573 represent: representYamlTimestamp 41574 }); 41575 41576 41577 /***/ }, 41578 /* 108 */ 41579 /***/ function(module, exports) { 41580 41581 module.exports = function(obj){ 41582 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41583 with(obj||{}){ 41584 __p+='<div class="container-fluid">\n <div class="row">\n <div class="col-sm-3 col-md-2 sidebar">\n <div class="user_menu" id="header">\n </div>\n <div id="sidebar">\n </div>\n </div>\n <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">\n <div class="gohan_header" id="bread-crumb"></div>\n <div id="main_body">\n </div>\n </div>\n </div>\n</div>\n'; 41585 } 41586 return __p; 41587 }; 41588 41589 /***/ }, 41590 /* 109 */ 41591 /***/ function(module, exports, __webpack_require__) { 41592 41593 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 41594 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41595 with(obj||{}){ 41596 __p+='<div class="container-fluid">\n <div class="row">\n <div class="col-sm-8 title"><span class="fa fa-navicon"></span><h1><ol>\n '; 41597 _.each(parents, function iterator(parent, key) { 41598 __p+='<li>\n <a href="#'+ 41599 ((__t=( parent.url ))==null?'':_.escape(__t))+ 41600 '">'+ 41601 ((__t=( parent.title ))==null?'':_.escape(__t))+ 41602 '</a></li>\n '; 41603 }) 41604 __p+='\n </ol></h1></div>\n <div class="col-sm-4 edit"></div>\n </div>\n</div>\n'; 41605 } 41606 return __p; 41607 }; 41608 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) 41609 41610 /***/ }, 41611 /* 110 */ 41612 /***/ function(module, exports) { 41613 41614 module.exports = function(obj){ 41615 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41616 with(obj||{}){ 41617 __p+='<a class=\'btn btn-default btn-sm\'\n tabindex="0"\n role="button"\n data-placement=\'auto\'\n data-trigger=\'click\'\n data-toggle=\'popover\'\n data-html=\'true\'\n data-content=\''+ 41618 ((__t=( content ))==null?'':__t)+ 41619 '\'>view</a>\n'; 41620 } 41621 return __p; 41622 }; 41623 41624 /***/ }, 41625 /* 111 */ 41626 /***/ function(module, exports, __webpack_require__) { 41627 41628 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 41629 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41630 with(obj||{}){ 41631 __p+='<div data-gohan="error"></div>\n<div class="detail_info_container card">\n <div class="container-fluid">\n <div class="row">\n <div class="col-xs-6 resource_name"><h2>'+ 41632 ((__t=( schema.title ))==null?'':_.escape(__t))+ 41633 '</h2></div>\n <div class="col-xs-6 func">\n <a class="edit" data-gohan="update" href="#">Edit</a>\n <a class="edit" data-gohan="delete" href="#">Delete</a>\n </div>\n </div>\n\n '; 41634 _.each(schema.schema.propertiesOrder, function(key){ 41635 var property = schema.schema.properties[key]; 41636 var view = property['view']; 41637 if(view){ 41638 if(view.indexOf("detail") < 0){ 41639 return 41640 } 41641 } 41642 41643 __p+='\n <div class="row_property">\n <div class="property_title">'+ 41644 ((__t=( property.title ))==null?'':_.escape(__t))+ 41645 '</div>\n <div class="property_detail">'+ 41646 ((__t=( data[key] ))==null?'':__t)+ 41647 '</div>\n </div>\n '; 41648 }); 41649 __p+='\n </div>\n</div>\n\n\n'; 41650 if ( children.length > 0 ) { 41651 __p+='\n<div class="container-fluid">\n <div class="row">\n '; 41652 _.each(children, function(child){ 41653 __p+='\n <div class="child_resource">\n <div id="'+ 41654 ((__t=( child.id ))==null?'':_.escape(__t))+ 41655 '_table"></div>\n </div>\n '; 41656 }); 41657 __p+='\n </div>\n</div>\n'; 41658 } 41659 __p+='\n'; 41660 } 41661 return __p; 41662 }; 41663 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) 41664 41665 /***/ }, 41666 /* 112 */ 41667 /***/ function(module, exports) { 41668 41669 module.exports = function(obj){ 41670 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41671 with(obj||{}){ 41672 __p+='<div class="alert alert-warning fade in out" role="alert">\n <a data-gohan="close" class="close" data-dismiss="alert" aria-label="close">×</a>\n <strong>'+ 41673 ((__t=( message ))==null?'':__t)+ 41674 ': </strong>\n <span>'+ 41675 ((__t=( messageDetail ))==null?'':__t)+ 41676 '</span>\n</div>\n'; 41677 } 41678 return __p; 41679 }; 41680 41681 /***/ }, 41682 /* 113 */ 41683 /***/ function(module, exports, __webpack_require__) { 41684 41685 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 41686 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41687 with(obj||{}){ 41688 __p+='<div class="title">\n <a href="/#"><h2>Gohan</h2></a>\n</div>\n'; 41689 if (authToken) { 41690 __p+='\n<div class="dropdown">\n <a data-target="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">\n <span class="fa fa-user"></span>\n '+ 41691 ((__t=( username ))==null?'':__t)+ 41692 '\n <span class="caret"></span>\n </a>\n <ul id="menu1" class="dropdown-menu" aria-labelledby="dLabel">\n <li>\n <a href="#" data-gohan="logout">Log Out</a>\n </li>\n </ul>\n</div>\n'; 41693 if(tenants.length > 1){ 41694 __p+='\n<div class="dropdown">\n <a data-target="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">\n <span class="fa fa-users"></span>\n '+ 41695 ((__t=( tenantName ))==null?'':__t)+ 41696 '\n <span class="caret"></span>\n </a>\n\n <ul id="menu2" class="dropdown-menu" aria-labelledby="dLabel">\n'; 41697 _.each(tenants, function(tenant){ 41698 __p+='\n <li>\n <a data-gohan="change-tenant" data-tenant="'+ 41699 ((__t=( tenant.name ))==null?'':__t)+ 41700 '">'+ 41701 ((__t=( tenant.name ))==null?'':__t)+ 41702 '</a>\n </li>\n'; 41703 }); 41704 __p+='\n </ul>\n</div>\n'; 41705 } 41706 __p+='\n'; 41707 } 41708 __p+='\n\n\n\n'; 41709 } 41710 return __p; 41711 }; 41712 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) 41713 41714 /***/ }, 41715 /* 114 */ 41716 /***/ function(module, exports) { 41717 41718 module.exports = function(obj){ 41719 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41720 with(obj||{}){ 41721 __p+='<div class="login_container" id="main">\n <div class="login_panel">\n <div class="panel panel-default card">\n <div class="panel-heading">\n <h3 class="panel-title">Please sign in</h3>\n </div>\n <div class="panel-body">\n <div id="alerts"></div>\n <div data-gohan="error"></div>\n <form accept-charset="UTF-8" method="" action="" role="form" id="login">\n <fieldset>\n <div class="form-group">\n <input class="form-control" placeholder="ID" name="id" type="text" id="id"></div>\n <div class="form-group">\n <input class="form-control" placeholder="Password" name="password" id="password" type="password" value=""></div>\n <input class="btn btn-primary btn-block" data-gohan="login" type="submit" value="Login"></fieldset>\n </form>\n </div>\n </div>\n </div>\n</div>\n'; 41722 } 41723 return __p; 41724 }; 41725 41726 /***/ }, 41727 /* 115 */ 41728 /***/ function(module, exports, __webpack_require__) { 41729 41730 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 41731 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41732 with(obj||{}){ 41733 __p+='<tr>\n<td class="handle">\n <span class="fa fa-reorder" aria-hidden="true"></span>\n</td>\n<td>\n <input id="id" value="'+ 41734 ((__t=( property["id"] ))==null?'':_.escape(__t))+ 41735 '" class="form-control id_form"/>\n</td>\n'; 41736 _.each(propertyColumns, function(column){ 41737 var id = column.id; 41738 __p+='\n <td>\n '; 41739 if (column.enum){ 41740 __p+='\n <select class="form-control" id="\''+ 41741 ((__t=( id ))==null?'':_.escape(__t))+ 41742 '">\n '; 41743 _.each(column.enum, function(key){ 41744 __p+='\n <option value="'+ 41745 ((__t=( key ))==null?'':_.escape(__t))+ 41746 '"\n '; 41747 if(key == property[column.id] ){ 41748 __p+=' selected '; 41749 } 41750 __p+='> '+ 41751 ((__t=( key ))==null?'':_.escape(__t))+ 41752 '\n </option>\n '; 41753 }); 41754 __p+='\n </select>\n '; 41755 } else if (column.type == "string"){ 41756 __p+='\n <input id="'+ 41757 ((__t=( id ))==null?'':_.escape(__t))+ 41758 '" value="'+ 41759 ((__t=( property[column.id] ))==null?'':_.escape(__t))+ 41760 '" class="form-control"/>\n '; 41761 }else if(column.type == "checkbox") { 41762 __p+='\n <input type="checkbox" class="form-control" id="'+ 41763 ((__t=( id ))==null?'':_.escape(__t))+ 41764 '"\n '; 41765 if(property[column.id]){; 41766 __p+=' checked '; 41767 } 41768 __p+=' />\n '; 41769 } 41770 __p+='\n </td>\n'; 41771 }); 41772 __p+='\n<td class="action">\n <button type="button" class="btn btn-default" aria-label="Detail" id="detail" > Detail </button>\n <a class="delete" aria-label="Delete"><span class="fa fa-remove"></span></a>\n</td>\n</tr>\n'; 41773 } 41774 return __p; 41775 }; 41776 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) 41777 41778 /***/ }, 41779 /* 116 */ 41780 /***/ function(module, exports) { 41781 41782 module.exports = function(obj){ 41783 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41784 with(obj||{}){ 41785 __p+='<div class="card gohan_home">\n <h2>Welcome to Gohan UI</h2>\n <ul>\n <li><a href="http://gohan.cloudwan.io/" target="_blank">Gohan</a></li>\n <li><a href="https://github.com/cloudwan/gohan/" target="_blank">Github</a></li>\n <li><a href="http://gohan.cloudwan.io/gohan/" target="_blank">Gohan Docs</a></li>\n </ul>\n</div>\n'; 41786 } 41787 return __p; 41788 }; 41789 41790 /***/ }, 41791 /* 117 */ 41792 /***/ function(module, exports, __webpack_require__) { 41793 41794 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 41795 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41796 with(obj||{}){ 41797 __p+='<table class="table table-striped" id="properties_table">\n<thead>\n<tr><th></th><th>ID</th>'; 41798 41799 _.each(propertyColumns, function(column){ 41800 __p+='\n <th>'+ 41801 ((__t=( column.id ))==null?'':__t)+ 41802 '</th>\n'; 41803 41804 }); 41805 41806 __p+='\n<th></th></tr></thead>\n<tbody></tbody></table>\n\n'; 41807 } 41808 return __p; 41809 }; 41810 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) 41811 41812 /***/ }, 41813 /* 118 */ 41814 /***/ function(module, exports) { 41815 41816 module.exports = function(obj){ 41817 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41818 with(obj||{}){ 41819 __p+='<a href="#'+ 41820 ((__t=( source.path ))==null?'':__t)+ 41821 '">\n '+ 41822 ((__t=( source.title ))==null?'':__t)+ 41823 '\n</a>\n'; 41824 } 41825 return __p; 41826 }; 41827 41828 /***/ }, 41829 /* 119 */ 41830 /***/ function(module, exports, __webpack_require__) { 41831 41832 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 41833 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 41834 with(obj||{}){ 41835 __p+='\n<div class="container-fluid table_search">\n <div class="row">\n <div class="col-xs-6 resource_name">\n <h2>'+ 41836 ((__t=( schema.title ))==null?'':_.escape(__t))+ 41837 '</h2>\n </div>\n <div class="col-xs-6 func">\n <form class="form-inline">\n <div class="form-group" data-gohan="search">\n <span>Filter by:</span>\n <select class="form-control" placeholder="Filter By">\n '; 41838 schema.schema.propertiesOrder.forEach( function(key){ 41839 var property = schema.schema.properties[key]; 41840 var view = property['view'] 41841 41842 if(view && !view.includes('list') || key === parentProperty){ 41843 return; 41844 } 41845 41846 __p+='\n <option value="'+ 41847 ((__t=( key ))==null?'':__t)+ 41848 '">'+ 41849 ((__t=( property.title ))==null?'':__t)+ 41850 '</option>\n '; 41851 41852 } 41853 ); 41854 41855 __p+='\n </select>\n <input type="text" class="form-control" placeholder="Search" value="'+ 41856 ((__t=( searchQuery.sortKey ))==null?'':__t)+ 41857 '">\n </div>\n </form>\n <a class="btn btn-primary gohan_create" data-gohan="create">\n <strong>+</strong> New\n </a>\n </div>\n </div>\n</div>\n<div data-gohan="error"></div>\n<div class="card">\n <table class="table table-hover gohan-table">\n <thead>\n <tr>\n '; 41858 schema.schema.propertiesOrder.forEach( function(key){ 41859 var property = schema.schema.properties[key]; 41860 var view = property['view'] 41861 41862 if(view && !view.includes('list') || key === parentProperty){ 41863 return; 41864 } 41865 41866 __p+='\n <th>\n <a href="#/'+ 41867 ((__t=( schema.url.substring(1) ))==null?'':__t)+ 41868 '" data-id="'+ 41869 ((__t=( key ))==null?'':__t)+ 41870 '" class="title" data-gohan="sort-title">'+ 41871 ((__t=( property.title ))==null?'':__t)+ 41872 '\n '; 41873 if(sort.by === key) { 41874 if(sort.reverse) { 41875 __p+='\n <div class="glyphicon glyphicon-sort-by-alphabet-alt"></div>\n '; 41876 } else { 41877 __p+='\n <div class="glyphicon glyphicon-sort-by-alphabet"></div>\n '; 41878 } 41879 } 41880 __p+='\n </a>\n </th>\n '; 41881 }); 41882 __p+='\n <th></th>\n </tr>\n </thead>\n <tbody id="page'+ 41883 ((__t=( key + 1 ))==null?'':__t)+ 41884 '" >\n '; 41885 _.each(data, function(d){ 41886 __p+='\n <tr>\n '; 41887 schema.schema.propertiesOrder.forEach( function(key){ 41888 var property = schema.schema.properties[key]; 41889 var view = property['view'] 41890 41891 if (view) { 41892 if (view.indexOf("list") < 0) { 41893 return 41894 } 41895 } 41896 if (key === parentProperty){ 41897 return 41898 } 41899 const title = property.title.toLowerCase(); 41900 41901 var urlPattern = /^((http|https):\/\/)/; 41902 if (property['format'] === 'uri' && urlPattern.test(d[key])) { 41903 __p+='\n <td><a href="'+ 41904 ((__t=( d[key] ))==null?'':_.escape(__t))+ 41905 '"> link </a></td>\n '; 41906 }else if(title === 'name' || title === 'title'){ 41907 __p+='\n <td><a data-id="'+ 41908 ((__t=( d[key] ))==null?'':__t)+ 41909 '" href="#/'+ 41910 ((__t=( fragment ))==null?'':__t)+ 41911 '/'+ 41912 ((__t=( d.id ))==null?'':__t)+ 41913 '">'+ 41914 ((__t=( _.escape(d[key]) ))==null?'':__t)+ 41915 '</a></td>\n '; 41916 } else { 41917 __p+='\n <td>'+ 41918 ((__t=( d[key] ))==null?'':__t)+ 41919 '</td>\n '; 41920 } 41921 __p+='\n '; 41922 }); 41923 __p+='\n <td class="action_column">\n <div class="btn-group ">\n <a class="btn btn-default btn-sm btn-raised btn-material-blue-600" data-id="'+ 41924 ((__t=( d['id']))==null?'':_.escape(__t))+ 41925 '" data-gohan="update">Edit</a>\n <button type="button" class="btn btn-default btn-sm dropdown-toggle"\n data-toggle="dropdown" aria-expanded="true" data-container="body">\n <span class="caret"></span>\n <span class="sr-only">Toggle Dropdown</span>\n </button>\n <ul class="dropdown-menu pull-right" role="menu" >\n <li><a data-id="'+ 41926 ((__t=( d['id']))==null?'':_.escape(__t))+ 41927 '" data-gohan="delete">Delete</a></li>\n </ul>\n </div>\n </td>\n </tr>\n '; 41928 }); 41929 __p+='\n </tbody>\n </table>\n</div>\n\n'; 41930 if (pageCount > 1) { 41931 __p+='\n<nav data-gohan="pagination">\n <ul class="pagination pagination-sm">\n <li '; 41932 if (activePage === 1) { 41933 __p+=' class="disabled" '; 41934 } 41935 __p+='>\n <a data-id="prev" aria-label="Previous">\n <span aria-hidden="true">«</span>\n </a>\n </li>\n '; 41936 if(pagination.start !== 1) { 41937 __p+='\n <li><a data-id="'+ 41938 ((__t=( pagination.start - 1 ))==null?'':__t)+ 41939 '" data-more="'+ 41940 ((__t=( 'left' ))==null?'':__t)+ 41941 '">'+ 41942 ((__t=((pagination.start - pagination.limit + 1) +'...' + (pagination.start - 1) ))==null?'':__t)+ 41943 '</a></li>\n '; 41944 } 41945 __p+='\n '; 41946 for (var key = pagination.start; key <= pagination.start + pagination.limit - 1 && key <= pageCount; key++) { 41947 if(key === pagination.start + pagination.limit - 1) { 41948 41949 __p+='\n <li ><a data-id="'+ 41950 ((__t=( key ))==null?'':__t)+ 41951 '" data-more="right">'+ 41952 ((__t=( key + '...' + pageCount ))==null?'':__t)+ 41953 '</a></li>\n '; 41954 } else { 41955 41956 __p+='\n <li '; 41957 if (key === activePage) { 41958 __p+=' class="active" '; 41959 } 41960 __p+='><a data-id="'+ 41961 ((__t=( key ))==null?'':__t)+ 41962 '">'+ 41963 ((__t=( key ))==null?'':__t)+ 41964 '</a></li>\n '; 41965 41966 } 41967 } 41968 __p+='\n <li '; 41969 if (activePage === pageCount) { 41970 __p+=' class="disabled" '; 41971 } 41972 __p+='>\n <a data-id="next" aria-label="Next">\n <span aria-hidden="true">»</span>\n </a>\n </li>\n </ul>\n</nav>\n'; 41973 } 41974 __p+='\n\n\n'; 41975 } 41976 return __p; 41977 }; 41978 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4))) 41979 41980 /***/ }, 41981 /* 120 */ 41982 /***/ function(module, exports) { 41983 41984 (function(self) { 41985 'use strict'; 41986 41987 if (self.fetch) { 41988 return 41989 } 41990 41991 var support = { 41992 searchParams: 'URLSearchParams' in self, 41993 iterable: 'Symbol' in self && 'iterator' in Symbol, 41994 blob: 'FileReader' in self && 'Blob' in self && (function() { 41995 try { 41996 new Blob() 41997 return true 41998 } catch(e) { 41999 return false 42000 } 42001 })(), 42002 formData: 'FormData' in self, 42003 arrayBuffer: 'ArrayBuffer' in self 42004 } 42005 42006 function normalizeName(name) { 42007 if (typeof name !== 'string') { 42008 name = String(name) 42009 } 42010 if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { 42011 throw new TypeError('Invalid character in header field name') 42012 } 42013 return name.toLowerCase() 42014 } 42015 42016 function normalizeValue(value) { 42017 if (typeof value !== 'string') { 42018 value = String(value) 42019 } 42020 return value 42021 } 42022 42023 // Build a destructive iterator for the value list 42024 function iteratorFor(items) { 42025 var iterator = { 42026 next: function() { 42027 var value = items.shift() 42028 return {done: value === undefined, value: value} 42029 } 42030 } 42031 42032 if (support.iterable) { 42033 iterator[Symbol.iterator] = function() { 42034 return iterator 42035 } 42036 } 42037 42038 return iterator 42039 } 42040 42041 function Headers(headers) { 42042 this.map = {} 42043 42044 if (headers instanceof Headers) { 42045 headers.forEach(function(value, name) { 42046 this.append(name, value) 42047 }, this) 42048 42049 } else if (headers) { 42050 Object.getOwnPropertyNames(headers).forEach(function(name) { 42051 this.append(name, headers[name]) 42052 }, this) 42053 } 42054 } 42055 42056 Headers.prototype.append = function(name, value) { 42057 name = normalizeName(name) 42058 value = normalizeValue(value) 42059 var list = this.map[name] 42060 if (!list) { 42061 list = [] 42062 this.map[name] = list 42063 } 42064 list.push(value) 42065 } 42066 42067 Headers.prototype['delete'] = function(name) { 42068 delete this.map[normalizeName(name)] 42069 } 42070 42071 Headers.prototype.get = function(name) { 42072 var values = this.map[normalizeName(name)] 42073 return values ? values[0] : null 42074 } 42075 42076 Headers.prototype.getAll = function(name) { 42077 return this.map[normalizeName(name)] || [] 42078 } 42079 42080 Headers.prototype.has = function(name) { 42081 return this.map.hasOwnProperty(normalizeName(name)) 42082 } 42083 42084 Headers.prototype.set = function(name, value) { 42085 this.map[normalizeName(name)] = [normalizeValue(value)] 42086 } 42087 42088 Headers.prototype.forEach = function(callback, thisArg) { 42089 Object.getOwnPropertyNames(this.map).forEach(function(name) { 42090 this.map[name].forEach(function(value) { 42091 callback.call(thisArg, value, name, this) 42092 }, this) 42093 }, this) 42094 } 42095 42096 Headers.prototype.keys = function() { 42097 var items = [] 42098 this.forEach(function(value, name) { items.push(name) }) 42099 return iteratorFor(items) 42100 } 42101 42102 Headers.prototype.values = function() { 42103 var items = [] 42104 this.forEach(function(value) { items.push(value) }) 42105 return iteratorFor(items) 42106 } 42107 42108 Headers.prototype.entries = function() { 42109 var items = [] 42110 this.forEach(function(value, name) { items.push([name, value]) }) 42111 return iteratorFor(items) 42112 } 42113 42114 if (support.iterable) { 42115 Headers.prototype[Symbol.iterator] = Headers.prototype.entries 42116 } 42117 42118 function consumed(body) { 42119 if (body.bodyUsed) { 42120 return Promise.reject(new TypeError('Already read')) 42121 } 42122 body.bodyUsed = true 42123 } 42124 42125 function fileReaderReady(reader) { 42126 return new Promise(function(resolve, reject) { 42127 reader.onload = function() { 42128 resolve(reader.result) 42129 } 42130 reader.onerror = function() { 42131 reject(reader.error) 42132 } 42133 }) 42134 } 42135 42136 function readBlobAsArrayBuffer(blob) { 42137 var reader = new FileReader() 42138 reader.readAsArrayBuffer(blob) 42139 return fileReaderReady(reader) 42140 } 42141 42142 function readBlobAsText(blob) { 42143 var reader = new FileReader() 42144 reader.readAsText(blob) 42145 return fileReaderReady(reader) 42146 } 42147 42148 function Body() { 42149 this.bodyUsed = false 42150 42151 this._initBody = function(body) { 42152 this._bodyInit = body 42153 if (typeof body === 'string') { 42154 this._bodyText = body 42155 } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { 42156 this._bodyBlob = body 42157 } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { 42158 this._bodyFormData = body 42159 } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 42160 this._bodyText = body.toString() 42161 } else if (!body) { 42162 this._bodyText = '' 42163 } else if (support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) { 42164 // Only support ArrayBuffers for POST method. 42165 // Receiving ArrayBuffers happens via Blobs, instead. 42166 } else { 42167 throw new Error('unsupported BodyInit type') 42168 } 42169 42170 if (!this.headers.get('content-type')) { 42171 if (typeof body === 'string') { 42172 this.headers.set('content-type', 'text/plain;charset=UTF-8') 42173 } else if (this._bodyBlob && this._bodyBlob.type) { 42174 this.headers.set('content-type', this._bodyBlob.type) 42175 } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 42176 this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') 42177 } 42178 } 42179 } 42180 42181 if (support.blob) { 42182 this.blob = function() { 42183 var rejected = consumed(this) 42184 if (rejected) { 42185 return rejected 42186 } 42187 42188 if (this._bodyBlob) { 42189 return Promise.resolve(this._bodyBlob) 42190 } else if (this._bodyFormData) { 42191 throw new Error('could not read FormData body as blob') 42192 } else { 42193 return Promise.resolve(new Blob([this._bodyText])) 42194 } 42195 } 42196 42197 this.arrayBuffer = function() { 42198 return this.blob().then(readBlobAsArrayBuffer) 42199 } 42200 42201 this.text = function() { 42202 var rejected = consumed(this) 42203 if (rejected) { 42204 return rejected 42205 } 42206 42207 if (this._bodyBlob) { 42208 return readBlobAsText(this._bodyBlob) 42209 } else if (this._bodyFormData) { 42210 throw new Error('could not read FormData body as text') 42211 } else { 42212 return Promise.resolve(this._bodyText) 42213 } 42214 } 42215 } else { 42216 this.text = function() { 42217 var rejected = consumed(this) 42218 return rejected ? rejected : Promise.resolve(this._bodyText) 42219 } 42220 } 42221 42222 if (support.formData) { 42223 this.formData = function() { 42224 return this.text().then(decode) 42225 } 42226 } 42227 42228 this.json = function() { 42229 return this.text().then(JSON.parse) 42230 } 42231 42232 return this 42233 } 42234 42235 // HTTP methods whose capitalization should be normalized 42236 var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'] 42237 42238 function normalizeMethod(method) { 42239 var upcased = method.toUpperCase() 42240 return (methods.indexOf(upcased) > -1) ? upcased : method 42241 } 42242 42243 function Request(input, options) { 42244 options = options || {} 42245 var body = options.body 42246 if (Request.prototype.isPrototypeOf(input)) { 42247 if (input.bodyUsed) { 42248 throw new TypeError('Already read') 42249 } 42250 this.url = input.url 42251 this.credentials = input.credentials 42252 if (!options.headers) { 42253 this.headers = new Headers(input.headers) 42254 } 42255 this.method = input.method 42256 this.mode = input.mode 42257 if (!body) { 42258 body = input._bodyInit 42259 input.bodyUsed = true 42260 } 42261 } else { 42262 this.url = input 42263 } 42264 42265 this.credentials = options.credentials || this.credentials || 'omit' 42266 if (options.headers || !this.headers) { 42267 this.headers = new Headers(options.headers) 42268 } 42269 this.method = normalizeMethod(options.method || this.method || 'GET') 42270 this.mode = options.mode || this.mode || null 42271 this.referrer = null 42272 42273 if ((this.method === 'GET' || this.method === 'HEAD') && body) { 42274 throw new TypeError('Body not allowed for GET or HEAD requests') 42275 } 42276 this._initBody(body) 42277 } 42278 42279 Request.prototype.clone = function() { 42280 return new Request(this) 42281 } 42282 42283 function decode(body) { 42284 var form = new FormData() 42285 body.trim().split('&').forEach(function(bytes) { 42286 if (bytes) { 42287 var split = bytes.split('=') 42288 var name = split.shift().replace(/\+/g, ' ') 42289 var value = split.join('=').replace(/\+/g, ' ') 42290 form.append(decodeURIComponent(name), decodeURIComponent(value)) 42291 } 42292 }) 42293 return form 42294 } 42295 42296 function headers(xhr) { 42297 var head = new Headers() 42298 var pairs = (xhr.getAllResponseHeaders() || '').trim().split('\n') 42299 pairs.forEach(function(header) { 42300 var split = header.trim().split(':') 42301 var key = split.shift().trim() 42302 var value = split.join(':').trim() 42303 head.append(key, value) 42304 }) 42305 return head 42306 } 42307 42308 Body.call(Request.prototype) 42309 42310 function Response(bodyInit, options) { 42311 if (!options) { 42312 options = {} 42313 } 42314 42315 this.type = 'default' 42316 this.status = options.status 42317 this.ok = this.status >= 200 && this.status < 300 42318 this.statusText = options.statusText 42319 this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers) 42320 this.url = options.url || '' 42321 this._initBody(bodyInit) 42322 } 42323 42324 Body.call(Response.prototype) 42325 42326 Response.prototype.clone = function() { 42327 return new Response(this._bodyInit, { 42328 status: this.status, 42329 statusText: this.statusText, 42330 headers: new Headers(this.headers), 42331 url: this.url 42332 }) 42333 } 42334 42335 Response.error = function() { 42336 var response = new Response(null, {status: 0, statusText: ''}) 42337 response.type = 'error' 42338 return response 42339 } 42340 42341 var redirectStatuses = [301, 302, 303, 307, 308] 42342 42343 Response.redirect = function(url, status) { 42344 if (redirectStatuses.indexOf(status) === -1) { 42345 throw new RangeError('Invalid status code') 42346 } 42347 42348 return new Response(null, {status: status, headers: {location: url}}) 42349 } 42350 42351 self.Headers = Headers 42352 self.Request = Request 42353 self.Response = Response 42354 42355 self.fetch = function(input, init) { 42356 return new Promise(function(resolve, reject) { 42357 var request 42358 if (Request.prototype.isPrototypeOf(input) && !init) { 42359 request = input 42360 } else { 42361 request = new Request(input, init) 42362 } 42363 42364 var xhr = new XMLHttpRequest() 42365 42366 function responseURL() { 42367 if ('responseURL' in xhr) { 42368 return xhr.responseURL 42369 } 42370 42371 // Avoid security warnings on getResponseHeader when not allowed by CORS 42372 if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) { 42373 return xhr.getResponseHeader('X-Request-URL') 42374 } 42375 42376 return 42377 } 42378 42379 xhr.onload = function() { 42380 var options = { 42381 status: xhr.status, 42382 statusText: xhr.statusText, 42383 headers: headers(xhr), 42384 url: responseURL() 42385 } 42386 var body = 'response' in xhr ? xhr.response : xhr.responseText 42387 resolve(new Response(body, options)) 42388 } 42389 42390 xhr.onerror = function() { 42391 reject(new TypeError('Network request failed')) 42392 } 42393 42394 xhr.ontimeout = function() { 42395 reject(new TypeError('Network request failed')) 42396 } 42397 42398 xhr.open(request.method, request.url, true) 42399 42400 if (request.credentials === 'include') { 42401 xhr.withCredentials = true 42402 } 42403 42404 if ('responseType' in xhr && support.blob) { 42405 xhr.responseType = 'blob' 42406 } 42407 42408 request.headers.forEach(function(value, name) { 42409 xhr.setRequestHeader(name, value) 42410 }) 42411 42412 xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit) 42413 }) 42414 } 42415 self.fetch.polyfill = true 42416 })(typeof self !== 'undefined' ? self : this); 42417 42418 42419 /***/ }, 42420 /* 121 */ 42421 /***/ function(module, exports, __webpack_require__) { 42422 42423 __webpack_require__(78); 42424 __webpack_require__(74); 42425 module.exports = __webpack_require__(59); 42426 42427 /***/ } 42428 /******/ ]);