conjur-asset-ui-api 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.git-hooks/pre_commit/ensure_livescript_compiled.rb +31 -0
  3. data/.git-hooks/pre_commit/trailing_whitespace.rb +26 -0
  4. data/.gitignore +20 -0
  5. data/.overcommit.yml +5 -0
  6. data/.project +18 -0
  7. data/Gemfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +41 -0
  10. data/Rakefile +1 -0
  11. data/compile_ls +2 -0
  12. data/conjur-asset-ui.gemspec +36 -0
  13. data/lib/conjur-asset-ui-version.rb +7 -0
  14. data/lib/conjur-asset-ui.rb +7 -0
  15. data/lib/conjur/audit/follower.rb +63 -0
  16. data/lib/conjur/audit/humanizer.rb +53 -0
  17. data/lib/conjur/audit/tableizer.rb +55 -0
  18. data/lib/conjur/command/ui.rb +38 -0
  19. data/lib/conjur/webserver/api_proxy.rb +94 -0
  20. data/lib/conjur/webserver/audit_stream.rb +92 -0
  21. data/lib/conjur/webserver/authorize.rb +28 -0
  22. data/lib/conjur/webserver/conjur_info.rb +33 -0
  23. data/lib/conjur/webserver/home.rb +36 -0
  24. data/lib/conjur/webserver/login.rb +50 -0
  25. data/lib/conjur/webserver/server.rb +111 -0
  26. data/livescript/views/audit.ls +124 -0
  27. data/public/css/bootstrap.css +7 -0
  28. data/public/css/styles.less +400 -0
  29. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  30. data/public/fonts/glyphicons-halflings-regular.svg +229 -0
  31. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  32. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  33. data/public/images/conjur-logo.svg +26 -0
  34. data/public/images/icon-client-pc.svg +12 -0
  35. data/public/images/icon-environment.png +0 -0
  36. data/public/images/icon-person.svg +12 -0
  37. data/public/images/icon-service-dots.svg +13 -0
  38. data/public/images/icon-variable.png +0 -0
  39. data/public/index.html +121 -0
  40. data/public/js/lib/JSXTransformer.js +10862 -0
  41. data/public/js/lib/async.js +958 -0
  42. data/public/js/lib/backbone.js +2 -0
  43. data/public/js/lib/bootstrap.js +6 -0
  44. data/public/js/lib/date.extensions.js +141 -0
  45. data/public/js/lib/less.js +16 -0
  46. data/public/js/lib/moment.js +7768 -0
  47. data/public/js/lib/pace.js +2 -0
  48. data/public/js/lib/prelude-browser-min.js +1 -0
  49. data/public/js/lib/react-with-addons.js +15505 -0
  50. data/public/js/lib/react.js +14469 -0
  51. data/public/js/lib/sorted-set.no-require.js +1170 -0
  52. data/public/js/lib/sorted-set.no-require.js.txt +6 -0
  53. data/public/js/lib/underscore-min.js +6 -0
  54. data/public/js/lib/underscore.string.min.js +1 -0
  55. data/public/js/main.js +353 -0
  56. data/public/js/models/namespace.js +6 -0
  57. data/public/js/models/policyList.js +10 -0
  58. data/public/js/models/record.js +26 -0
  59. data/public/js/models/resourceList.js +61 -0
  60. data/public/js/models/userList.js +16 -0
  61. data/public/js/models/variableList.js +12 -0
  62. data/public/js/views/audit.js +191 -0
  63. data/public/js/views/dashboard.js +35 -0
  64. data/public/js/views/generic.js +42 -0
  65. data/public/js/views/group.js +32 -0
  66. data/public/js/views/groups.js +18 -0
  67. data/public/js/views/host.js +40 -0
  68. data/public/js/views/hosts.js +18 -0
  69. data/public/js/views/layer.js +63 -0
  70. data/public/js/views/layers.js +18 -0
  71. data/public/js/views/mixins/search.js +9 -0
  72. data/public/js/views/namespaces.js +40 -0
  73. data/public/js/views/navSearch.js +16 -0
  74. data/public/js/views/permissions.js +91 -0
  75. data/public/js/views/policies.js +17 -0
  76. data/public/js/views/policy.js +23 -0
  77. data/public/js/views/resource.js +23 -0
  78. data/public/js/views/role.js +18 -0
  79. data/public/js/views/searchResults.js +146 -0
  80. data/public/js/views/time.js +14 -0
  81. data/public/js/views/user.js +22 -0
  82. data/public/js/views/users.js +18 -0
  83. data/public/js/views/variable.js +41 -0
  84. data/public/js/views/variables.js +18 -0
  85. data/vendor/prelude-ls/.gitignore +2 -0
  86. data/vendor/prelude-ls/.travis.yml +3 -0
  87. data/vendor/prelude-ls/CHANGELOG.md +81 -0
  88. data/vendor/prelude-ls/LICENSE +22 -0
  89. data/vendor/prelude-ls/Makefile +50 -0
  90. data/vendor/prelude-ls/README.md +15 -0
  91. data/vendor/prelude-ls/browser/prelude-browser-min.js +1 -0
  92. data/vendor/prelude-ls/browser/prelude-browser.js +1172 -0
  93. data/vendor/prelude-ls/lib/Func.js +40 -0
  94. data/vendor/prelude-ls/lib/List.js +602 -0
  95. data/vendor/prelude-ls/lib/Num.js +129 -0
  96. data/vendor/prelude-ls/lib/Obj.js +153 -0
  97. data/vendor/prelude-ls/lib/Str.js +68 -0
  98. data/vendor/prelude-ls/lib/index.js +164 -0
  99. data/vendor/prelude-ls/package.json +50 -0
  100. data/vendor/prelude-ls/package.ls +46 -0
  101. data/vendor/prelude-ls/src/Func.ls +17 -0
  102. data/vendor/prelude-ls/src/List.ls +299 -0
  103. data/vendor/prelude-ls/src/Num.ls +83 -0
  104. data/vendor/prelude-ls/src/Obj.ls +61 -0
  105. data/vendor/prelude-ls/src/Str.ls +32 -0
  106. data/vendor/prelude-ls/src/index.ls +56 -0
  107. data/vendor/prelude-ls/test/Func.ls +36 -0
  108. data/vendor/prelude-ls/test/List.ls +751 -0
  109. data/vendor/prelude-ls/test/Num.ls +258 -0
  110. data/vendor/prelude-ls/test/Obj.ls +145 -0
  111. data/vendor/prelude-ls/test/Prelude.ls +49 -0
  112. data/vendor/prelude-ls/test/Str.ls +208 -0
  113. data/vendor/prelude-ls/test/browser.html +5 -0
  114. metadata +328 -0
@@ -0,0 +1,1170 @@
1
+ (function () {
2
+ /**
3
+ * almond 0.2.5 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.
4
+ * Available via the MIT or new BSD license.
5
+ * see: http://github.com/jrburke/almond for details
6
+ */
7
+ //Going sloppy to avoid 'use strict' string cost, but strict practices should
8
+ //be followed.
9
+ /*jslint sloppy: true */
10
+ /*global setTimeout: false */
11
+
12
+ var requirejs, require, define;
13
+ (function (undef) {
14
+ var main, req, makeMap, handlers,
15
+ defined = {},
16
+ waiting = {},
17
+ config = {},
18
+ defining = {},
19
+ hasOwn = Object.prototype.hasOwnProperty,
20
+ aps = [].slice;
21
+
22
+ function hasProp(obj, prop) {
23
+ return hasOwn.call(obj, prop);
24
+ }
25
+
26
+ /**
27
+ * Given a relative module name, like ./something, normalize it to
28
+ * a real name that can be mapped to a path.
29
+ * @param {String} name the relative name
30
+ * @param {String} baseName a real name that the name arg is relative
31
+ * to.
32
+ * @returns {String} normalized name
33
+ */
34
+ function normalize(name, baseName) {
35
+ var nameParts, nameSegment, mapValue, foundMap,
36
+ foundI, foundStarMap, starI, i, j, part,
37
+ baseParts = baseName && baseName.split("/"),
38
+ map = config.map,
39
+ starMap = (map && map['*']) || {};
40
+
41
+ //Adjust any relative paths.
42
+ if (name && name.charAt(0) === ".") {
43
+ //If have a base name, try to normalize against it,
44
+ //otherwise, assume it is a top-level require that will
45
+ //be relative to baseUrl in the end.
46
+ if (baseName) {
47
+ //Convert baseName to array, and lop off the last part,
48
+ //so that . matches that "directory" and not name of the baseName's
49
+ //module. For instance, baseName of "one/two/three", maps to
50
+ //"one/two/three.js", but we want the directory, "one/two" for
51
+ //this normalization.
52
+ baseParts = baseParts.slice(0, baseParts.length - 1);
53
+
54
+ name = baseParts.concat(name.split("/"));
55
+
56
+ //start trimDots
57
+ for (i = 0; i < name.length; i += 1) {
58
+ part = name[i];
59
+ if (part === ".") {
60
+ name.splice(i, 1);
61
+ i -= 1;
62
+ } else if (part === "..") {
63
+ if (i === 1 && (name[2] === '..' || name[0] === '..')) {
64
+ //End of the line. Keep at least one non-dot
65
+ //path segment at the front so it can be mapped
66
+ //correctly to disk. Otherwise, there is likely
67
+ //no path mapping for a path starting with '..'.
68
+ //This can still fail, but catches the most reasonable
69
+ //uses of ..
70
+ break;
71
+ } else if (i > 0) {
72
+ name.splice(i - 1, 2);
73
+ i -= 2;
74
+ }
75
+ }
76
+ }
77
+ //end trimDots
78
+
79
+ name = name.join("/");
80
+ } else if (name.indexOf('./') === 0) {
81
+ // No baseName, so this is ID is resolved relative
82
+ // to baseUrl, pull off the leading dot.
83
+ name = name.substring(2);
84
+ }
85
+ }
86
+
87
+ //Apply map config if available.
88
+ if ((baseParts || starMap) && map) {
89
+ nameParts = name.split('/');
90
+
91
+ for (i = nameParts.length; i > 0; i -= 1) {
92
+ nameSegment = nameParts.slice(0, i).join("/");
93
+
94
+ if (baseParts) {
95
+ //Find the longest baseName segment match in the config.
96
+ //So, do joins on the biggest to smallest lengths of baseParts.
97
+ for (j = baseParts.length; j > 0; j -= 1) {
98
+ mapValue = map[baseParts.slice(0, j).join('/')];
99
+
100
+ //baseName segment has config, find if it has one for
101
+ //this name.
102
+ if (mapValue) {
103
+ mapValue = mapValue[nameSegment];
104
+ if (mapValue) {
105
+ //Match, update name to the new value.
106
+ foundMap = mapValue;
107
+ foundI = i;
108
+ break;
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ if (foundMap) {
115
+ break;
116
+ }
117
+
118
+ //Check for a star map match, but just hold on to it,
119
+ //if there is a shorter segment match later in a matching
120
+ //config, then favor over this star map.
121
+ if (!foundStarMap && starMap && starMap[nameSegment]) {
122
+ foundStarMap = starMap[nameSegment];
123
+ starI = i;
124
+ }
125
+ }
126
+
127
+ if (!foundMap && foundStarMap) {
128
+ foundMap = foundStarMap;
129
+ foundI = starI;
130
+ }
131
+
132
+ if (foundMap) {
133
+ nameParts.splice(0, foundI, foundMap);
134
+ name = nameParts.join('/');
135
+ }
136
+ }
137
+
138
+ return name;
139
+ }
140
+
141
+ function makeRequire(relName, forceSync) {
142
+ return function () {
143
+ //A version of a require function that passes a moduleName
144
+ //value for items that may need to
145
+ //look up paths relative to the moduleName
146
+ return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));
147
+ };
148
+ }
149
+
150
+ function makeNormalize(relName) {
151
+ return function (name) {
152
+ return normalize(name, relName);
153
+ };
154
+ }
155
+
156
+ function makeLoad(depName) {
157
+ return function (value) {
158
+ defined[depName] = value;
159
+ };
160
+ }
161
+
162
+ function callDep(name) {
163
+ if (hasProp(waiting, name)) {
164
+ var args = waiting[name];
165
+ delete waiting[name];
166
+ defining[name] = true;
167
+ main.apply(undef, args);
168
+ }
169
+
170
+ if (!hasProp(defined, name) && !hasProp(defining, name)) {
171
+ throw new Error('No ' + name);
172
+ }
173
+ return defined[name];
174
+ }
175
+
176
+ //Turns a plugin!resource to [plugin, resource]
177
+ //with the plugin being undefined if the name
178
+ //did not have a plugin prefix.
179
+ function splitPrefix(name) {
180
+ var prefix,
181
+ index = name ? name.indexOf('!') : -1;
182
+ if (index > -1) {
183
+ prefix = name.substring(0, index);
184
+ name = name.substring(index + 1, name.length);
185
+ }
186
+ return [prefix, name];
187
+ }
188
+
189
+ /**
190
+ * Makes a name map, normalizing the name, and using a plugin
191
+ * for normalization if necessary. Grabs a ref to plugin
192
+ * too, as an optimization.
193
+ */
194
+ makeMap = function (name, relName) {
195
+ var plugin,
196
+ parts = splitPrefix(name),
197
+ prefix = parts[0];
198
+
199
+ name = parts[1];
200
+
201
+ if (prefix) {
202
+ prefix = normalize(prefix, relName);
203
+ plugin = callDep(prefix);
204
+ }
205
+
206
+ //Normalize according
207
+ if (prefix) {
208
+ if (plugin && plugin.normalize) {
209
+ name = plugin.normalize(name, makeNormalize(relName));
210
+ } else {
211
+ name = normalize(name, relName);
212
+ }
213
+ } else {
214
+ name = normalize(name, relName);
215
+ parts = splitPrefix(name);
216
+ prefix = parts[0];
217
+ name = parts[1];
218
+ if (prefix) {
219
+ plugin = callDep(prefix);
220
+ }
221
+ }
222
+
223
+ //Using ridiculous property names for space reasons
224
+ return {
225
+ f: prefix ? prefix + '!' + name : name, //fullName
226
+ n: name,
227
+ pr: prefix,
228
+ p: plugin
229
+ };
230
+ };
231
+
232
+ function makeConfig(name) {
233
+ return function () {
234
+ return (config && config.config && config.config[name]) || {};
235
+ };
236
+ }
237
+
238
+ handlers = {
239
+ require: function (name) {
240
+ return makeRequire(name);
241
+ },
242
+ exports: function (name) {
243
+ var e = defined[name];
244
+ if (typeof e !== 'undefined') {
245
+ return e;
246
+ } else {
247
+ return (defined[name] = {});
248
+ }
249
+ },
250
+ module: function (name) {
251
+ return {
252
+ id: name,
253
+ uri: '',
254
+ exports: defined[name],
255
+ config: makeConfig(name)
256
+ };
257
+ }
258
+ };
259
+
260
+ main = function (name, deps, callback, relName) {
261
+ var cjsModule, depName, ret, map, i,
262
+ args = [],
263
+ usingExports;
264
+
265
+ //Use name if no relName
266
+ relName = relName || name;
267
+
268
+ //Call the callback to define the module, if necessary.
269
+ if (typeof callback === 'function') {
270
+
271
+ //Pull out the defined dependencies and pass the ordered
272
+ //values to the callback.
273
+ //Default to [require, exports, module] if no deps
274
+ deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
275
+ for (i = 0; i < deps.length; i += 1) {
276
+ map = makeMap(deps[i], relName);
277
+ depName = map.f;
278
+
279
+ //Fast path CommonJS standard dependencies.
280
+ if (depName === "require") {
281
+ args[i] = handlers.require(name);
282
+ } else if (depName === "exports") {
283
+ //CommonJS module spec 1.1
284
+ args[i] = handlers.exports(name);
285
+ usingExports = true;
286
+ } else if (depName === "module") {
287
+ //CommonJS module spec 1.1
288
+ cjsModule = args[i] = handlers.module(name);
289
+ } else if (hasProp(defined, depName) ||
290
+ hasProp(waiting, depName) ||
291
+ hasProp(defining, depName)) {
292
+ args[i] = callDep(depName);
293
+ } else if (map.p) {
294
+ map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
295
+ args[i] = defined[depName];
296
+ } else {
297
+ throw new Error(name + ' missing ' + depName);
298
+ }
299
+ }
300
+
301
+ ret = callback.apply(defined[name], args);
302
+
303
+ if (name) {
304
+ //If setting exports via "module" is in play,
305
+ //favor that over return value and exports. After that,
306
+ //favor a non-undefined return value over exports use.
307
+ if (cjsModule && cjsModule.exports !== undef &&
308
+ cjsModule.exports !== defined[name]) {
309
+ defined[name] = cjsModule.exports;
310
+ } else if (ret !== undef || !usingExports) {
311
+ //Use the return value from the function.
312
+ defined[name] = ret;
313
+ }
314
+ }
315
+ } else if (name) {
316
+ //May just be an object definition for the module. Only
317
+ //worry about defining if have a module name.
318
+ defined[name] = callback;
319
+ }
320
+ };
321
+
322
+ requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
323
+ if (typeof deps === "string") {
324
+ if (handlers[deps]) {
325
+ //callback in this case is really relName
326
+ return handlers[deps](callback);
327
+ }
328
+ //Just return the module wanted. In this scenario, the
329
+ //deps arg is the module name, and second arg (if passed)
330
+ //is just the relName.
331
+ //Normalize module name, if it contains . or ..
332
+ return callDep(makeMap(deps, callback).f);
333
+ } else if (!deps.splice) {
334
+ //deps is a config object, not an array.
335
+ config = deps;
336
+ if (callback.splice) {
337
+ //callback is an array, which means it is a dependency list.
338
+ //Adjust args if there are dependencies
339
+ deps = callback;
340
+ callback = relName;
341
+ relName = null;
342
+ } else {
343
+ deps = undef;
344
+ }
345
+ }
346
+
347
+ //Support require(['a'])
348
+ callback = callback || function () {};
349
+
350
+ //If relName is a function, it is an errback handler,
351
+ //so remove it.
352
+ if (typeof relName === 'function') {
353
+ relName = forceSync;
354
+ forceSync = alt;
355
+ }
356
+
357
+ //Simulate async callback;
358
+ if (forceSync) {
359
+ main(undef, deps, callback, relName);
360
+ } else {
361
+ //Using a non-zero value because of concern for what old browsers
362
+ //do, and latest browsers "upgrade" to 4 if lower value is used:
363
+ //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
364
+ //If want a value immediately, use require('id') instead -- something
365
+ //that works in almond on the global level, but not guaranteed and
366
+ //unlikely to work in other AMD implementations.
367
+ setTimeout(function () {
368
+ main(undef, deps, callback, relName);
369
+ }, 4);
370
+ }
371
+
372
+ return req;
373
+ };
374
+
375
+ /**
376
+ * Just drops the config on the floor, but returns req in case
377
+ * the config return value is used.
378
+ */
379
+ req.config = function (cfg) {
380
+ config = cfg;
381
+ if (config.deps) {
382
+ req(config.deps, config.callback);
383
+ }
384
+ return req;
385
+ };
386
+
387
+ define = function (name, deps, callback) {
388
+
389
+ //This module may not have dependencies
390
+ if (!deps.splice) {
391
+ //deps is not an array, so probably means
392
+ //an object literal or factory function for
393
+ //the value. Adjust args.
394
+ callback = deps;
395
+ deps = [];
396
+ }
397
+
398
+ if (!hasProp(defined, name) && !hasProp(waiting, name)) {
399
+ waiting[name] = [name, deps, callback];
400
+ }
401
+ };
402
+
403
+ define.amd = {
404
+ jQuery: true
405
+ };
406
+ }());
407
+
408
+ define("almond", function(){});
409
+
410
+ (function() {
411
+ define('SortedSet/AbstractSortedSet',[],function() {
412
+ var AbstractSortedSet;
413
+ return AbstractSortedSet = (function() {
414
+ function AbstractSortedSet(options) {
415
+ if ((options != null ? options.strategy : void 0) == null) {
416
+ throw 'Must pass options.strategy, a strategy';
417
+ }
418
+ if ((options != null ? options.comparator : void 0) == null) {
419
+ throw 'Must pass options.comparator, a comparator';
420
+ }
421
+ this.priv = new options.strategy(options);
422
+ }
423
+
424
+ AbstractSortedSet.prototype.insert = function(value) {
425
+ this.priv.insert(value);
426
+ return this;
427
+ };
428
+
429
+ AbstractSortedSet.prototype.remove = function(value) {
430
+ this.priv.remove(value);
431
+ return this;
432
+ };
433
+
434
+ AbstractSortedSet.prototype.contains = function(value) {
435
+ return this.priv.contains(value);
436
+ };
437
+
438
+ AbstractSortedSet.prototype.toArray = function() {
439
+ return this.priv.toArray();
440
+ };
441
+
442
+ AbstractSortedSet.prototype.forEach = function(callback, thisArg) {
443
+ this.priv.forEachImpl(callback, this, thisArg);
444
+ return this;
445
+ };
446
+
447
+ AbstractSortedSet.prototype.map = function(callback, thisArg) {
448
+ var ret;
449
+ ret = [];
450
+ this.forEach(function(value, index, self) {
451
+ return ret.push(callback.call(thisArg, value, index, self));
452
+ });
453
+ return ret;
454
+ };
455
+
456
+ AbstractSortedSet.prototype.filter = function(callback, thisArg) {
457
+ var ret;
458
+ ret = [];
459
+ this.forEach(function(value, index, self) {
460
+ if (callback.call(thisArg, value, index, self)) {
461
+ return ret.push(value);
462
+ }
463
+ });
464
+ return ret;
465
+ };
466
+
467
+ AbstractSortedSet.prototype.every = function(callback, thisArg) {
468
+ var ret;
469
+ ret = true;
470
+ this.forEach(function(value, index, self) {
471
+ if (ret && !callback.call(thisArg, value, index, self)) {
472
+ return ret = false;
473
+ }
474
+ });
475
+ return ret;
476
+ };
477
+
478
+ AbstractSortedSet.prototype.some = function(callback, thisArg) {
479
+ var ret;
480
+ ret = false;
481
+ this.forEach(function(value, index, self) {
482
+ if (!ret && callback.call(thisArg, value, index, self)) {
483
+ return ret = true;
484
+ }
485
+ });
486
+ return ret;
487
+ };
488
+
489
+ AbstractSortedSet.prototype.findIterator = function(value) {
490
+ return this.priv.findIterator(value);
491
+ };
492
+
493
+ AbstractSortedSet.prototype.beginIterator = function() {
494
+ return this.priv.beginIterator();
495
+ };
496
+
497
+ AbstractSortedSet.prototype.endIterator = function() {
498
+ return this.priv.endIterator();
499
+ };
500
+
501
+ return AbstractSortedSet;
502
+
503
+ })();
504
+ });
505
+
506
+ }).call(this);
507
+
508
+ /*
509
+ //@ sourceMappingURL=AbstractSortedSet.js.map
510
+ */;
511
+ (function() {
512
+ define('SortedSet/ArrayStrategy',[],function() {
513
+ var ArrayStrategy, Iterator, binarySearchForIndex;
514
+ Iterator = function(priv, index) {
515
+ var data;
516
+ data = priv.data;
517
+ return {
518
+ hasNext: function() {
519
+ return index < data.length;
520
+ },
521
+ hasPrevious: function() {
522
+ return index > 0;
523
+ },
524
+ value: function() {
525
+ if (index < data.length) {
526
+ return data[index];
527
+ } else {
528
+ return null;
529
+ }
530
+ },
531
+ setValue: function(value) {
532
+ if (!priv.options.allowSetValue) {
533
+ throw 'Must set options.allowSetValue';
534
+ }
535
+ if (!this.hasNext()) {
536
+ throw 'Cannot set value at end of set';
537
+ }
538
+ return data[index] = value;
539
+ },
540
+ next: function() {
541
+ if (index >= data.length) {
542
+ return null;
543
+ } else {
544
+ return new Iterator(priv, index + 1);
545
+ }
546
+ },
547
+ previous: function() {
548
+ if (index <= 0) {
549
+ return null;
550
+ } else {
551
+ return new Iterator(priv, index - 1);
552
+ }
553
+ }
554
+ };
555
+ };
556
+ binarySearchForIndex = function(array, value, comparator) {
557
+ var high, low, mid;
558
+ low = 0;
559
+ high = array.length;
560
+ while (low < high) {
561
+ mid = (low + high) >>> 1;
562
+ if (comparator(array[mid], value) < 0) {
563
+ low = mid + 1;
564
+ } else {
565
+ high = mid;
566
+ }
567
+ }
568
+ return low;
569
+ };
570
+ return ArrayStrategy = (function() {
571
+ function ArrayStrategy(options) {
572
+ this.options = options;
573
+ this.comparator = this.options.comparator;
574
+ this.data = [];
575
+ }
576
+
577
+ ArrayStrategy.prototype.toArray = function() {
578
+ return this.data;
579
+ };
580
+
581
+ ArrayStrategy.prototype.insert = function(value) {
582
+ var index;
583
+ index = binarySearchForIndex(this.data, value, this.comparator);
584
+ if (this.data[index] === value) {
585
+ throw 'Value already in set';
586
+ }
587
+ return this.data.splice(index, 0, value);
588
+ };
589
+
590
+ ArrayStrategy.prototype.remove = function(value) {
591
+ var index;
592
+ index = binarySearchForIndex(this.data, value, this.comparator);
593
+ if (this.data[index] !== value) {
594
+ throw 'Value not in set';
595
+ }
596
+ return this.data.splice(index, 1);
597
+ };
598
+
599
+ ArrayStrategy.prototype.contains = function(value) {
600
+ return this.data.indexOf(value) !== -1;
601
+ };
602
+
603
+ ArrayStrategy.prototype.forEachImpl = function(callback, sortedSet, thisArg) {
604
+ var index, value, _i, _len, _ref;
605
+ _ref = this.data;
606
+ for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
607
+ value = _ref[index];
608
+ callback.call(thisArg, value, index, sortedSet);
609
+ }
610
+ return void 0;
611
+ };
612
+
613
+ ArrayStrategy.prototype.findIterator = function(value) {
614
+ var index;
615
+ index = binarySearchForIndex(this.data, value, this.comparator);
616
+ return new Iterator(this, index);
617
+ };
618
+
619
+ ArrayStrategy.prototype.beginIterator = function() {
620
+ return new Iterator(this, 0);
621
+ };
622
+
623
+ ArrayStrategy.prototype.endIterator = function() {
624
+ return new Iterator(this, this.data.length);
625
+ };
626
+
627
+ return ArrayStrategy;
628
+
629
+ })();
630
+ });
631
+
632
+ }).call(this);
633
+
634
+ /*
635
+ //@ sourceMappingURL=ArrayStrategy.js.map
636
+ */;
637
+ (function() {
638
+ define('SortedSet/BinaryTreeIterator',[], function() {
639
+ var BinaryTreeIterator, descendAllTheWay, moveCursor;
640
+ descendAllTheWay = function(leftOrRight, node) {
641
+ var parent;
642
+ while (node[leftOrRight] !== null) {
643
+ parent = node;
644
+ node = node[leftOrRight];
645
+ node._iteratorParentNode = parent;
646
+ }
647
+ return node;
648
+ };
649
+ moveCursor = function(leftOrRight, node) {
650
+ var parent, rightOrLeft;
651
+ if (node[leftOrRight] !== null) {
652
+ parent = node;
653
+ node = node[leftOrRight];
654
+ node._iteratorParentNode = parent;
655
+ rightOrLeft = leftOrRight === 'left' ? 'right' : 'left';
656
+ node = descendAllTheWay(rightOrLeft, node);
657
+ } else {
658
+ while ((parent = node._iteratorParentNode) !== null && parent[leftOrRight] === node) {
659
+ node = parent;
660
+ }
661
+ node = parent;
662
+ }
663
+ return node;
664
+ };
665
+ BinaryTreeIterator = (function() {
666
+ function BinaryTreeIterator(tree, node) {
667
+ this.tree = tree;
668
+ this.node = node;
669
+ }
670
+
671
+ BinaryTreeIterator.prototype.next = function() {
672
+ var node;
673
+ if (this.node === null) {
674
+ return null;
675
+ } else {
676
+ node = moveCursor('right', this.node);
677
+ return new BinaryTreeIterator(this.tree, node);
678
+ }
679
+ };
680
+
681
+ BinaryTreeIterator.prototype.previous = function() {
682
+ var node;
683
+ if (this.node === null) {
684
+ if (this.tree.root === null) {
685
+ return null;
686
+ } else {
687
+ this.tree.root._iteratorParentNode = null;
688
+ node = descendAllTheWay('right', this.tree.root);
689
+ return new BinaryTreeIterator(this.tree, node);
690
+ }
691
+ } else {
692
+ node = moveCursor('left', this.node);
693
+ if (node === null) {
694
+ return null;
695
+ } else {
696
+ return new BinaryTreeIterator(this.tree, node);
697
+ }
698
+ }
699
+ };
700
+
701
+ BinaryTreeIterator.prototype.hasNext = function() {
702
+ return this.node !== null;
703
+ };
704
+
705
+ BinaryTreeIterator.prototype.hasPrevious = function() {
706
+ return this.previous() !== null;
707
+ };
708
+
709
+ BinaryTreeIterator.prototype.value = function() {
710
+ if (this.node === null) {
711
+ return null;
712
+ } else {
713
+ return this.node.value;
714
+ }
715
+ };
716
+
717
+ BinaryTreeIterator.prototype.setValue = function(value) {
718
+ if (!this.tree.options.allowSetValue) {
719
+ throw 'Must set options.allowSetValue';
720
+ }
721
+ if (!this.hasNext()) {
722
+ throw 'Cannot set value at end of set';
723
+ }
724
+ return this.node.value = value;
725
+ };
726
+
727
+ return BinaryTreeIterator;
728
+
729
+ })();
730
+ BinaryTreeIterator.find = function(tree, value, comparator) {
731
+ var cmp, nextNode, node, root;
732
+ root = tree.root;
733
+ if (root != null) {
734
+ root._iteratorParentNode = null;
735
+ }
736
+ node = root;
737
+ nextNode = null;
738
+ while (node !== null) {
739
+ cmp = comparator(value, node.value);
740
+ if (cmp === 0) {
741
+ break;
742
+ } else if (cmp < 0) {
743
+ if (node.left === null) {
744
+ break;
745
+ }
746
+ nextNode = node;
747
+ node.left._iteratorParentNode = node;
748
+ node = node.left;
749
+ } else {
750
+ if (node.right !== null) {
751
+ node.right._iteratorParentNode = node;
752
+ node = node.right;
753
+ } else {
754
+ node = nextNode;
755
+ break;
756
+ }
757
+ }
758
+ }
759
+ return new BinaryTreeIterator(tree, node);
760
+ };
761
+ BinaryTreeIterator.left = function(tree) {
762
+ var node;
763
+ if (tree.root === null) {
764
+ return new BinaryTreeIterator(tree, null);
765
+ } else {
766
+ tree.root._iteratorParentNode = null;
767
+ node = descendAllTheWay('left', tree.root);
768
+ return new BinaryTreeIterator(tree, node);
769
+ }
770
+ };
771
+ BinaryTreeIterator.right = function(tree) {
772
+ return new BinaryTreeIterator(tree, null);
773
+ };
774
+ return BinaryTreeIterator;
775
+ });
776
+
777
+ }).call(this);
778
+
779
+ /*
780
+ //@ sourceMappingURL=BinaryTreeIterator.js.map
781
+ */;
782
+ (function() {
783
+ define('SortedSet/AbstractBinaryTreeStrategy',['./BinaryTreeIterator'], function(BinaryTreeIterator) {
784
+ var AbstractBinaryTree, binaryTreeTraverse;
785
+ binaryTreeTraverse = function(node, callback) {
786
+ if (node !== null) {
787
+ binaryTreeTraverse(node.left, callback);
788
+ callback(node.value);
789
+ binaryTreeTraverse(node.right, callback);
790
+ }
791
+ return void 0;
792
+ };
793
+ return AbstractBinaryTree = (function() {
794
+ function AbstractBinaryTree() {}
795
+
796
+ AbstractBinaryTree.prototype.toArray = function() {
797
+ var ret;
798
+ ret = [];
799
+ binaryTreeTraverse(this.root, function(value) {
800
+ return ret.push(value);
801
+ });
802
+ return ret;
803
+ };
804
+
805
+ AbstractBinaryTree.prototype.forEachImpl = function(callback, sortedSet, thisArg) {
806
+ var i;
807
+ i = 0;
808
+ binaryTreeTraverse(this.root, function(value) {
809
+ callback.call(thisArg, value, i, sortedSet);
810
+ return i += 1;
811
+ });
812
+ return void 0;
813
+ };
814
+
815
+ AbstractBinaryTree.prototype.contains = function(value) {
816
+ var cmp, comparator, node;
817
+ comparator = this.comparator;
818
+ node = this.root;
819
+ while (node !== null) {
820
+ cmp = comparator(value, node.value);
821
+ if (cmp === 0) {
822
+ break;
823
+ } else if (cmp < 0) {
824
+ node = node.left;
825
+ } else {
826
+ node = node.right;
827
+ }
828
+ }
829
+ return node !== null && node.value === value;
830
+ };
831
+
832
+ AbstractBinaryTree.prototype.findIterator = function(value) {
833
+ return BinaryTreeIterator.find(this, value, this.comparator);
834
+ };
835
+
836
+ AbstractBinaryTree.prototype.beginIterator = function() {
837
+ return BinaryTreeIterator.left(this);
838
+ };
839
+
840
+ AbstractBinaryTree.prototype.endIterator = function() {
841
+ return BinaryTreeIterator.right(this);
842
+ };
843
+
844
+ return AbstractBinaryTree;
845
+
846
+ })();
847
+ });
848
+
849
+ }).call(this);
850
+
851
+ /*
852
+ //@ sourceMappingURL=AbstractBinaryTreeStrategy.js.map
853
+ */;
854
+ (function() {
855
+ var __hasProp = {}.hasOwnProperty,
856
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
857
+
858
+ define('SortedSet/BinaryTreeStrategy',['./AbstractBinaryTreeStrategy'], function(AbstractBinaryTreeStrategy) {
859
+ var BinaryTreeStrategy, Node, binaryTreeDelete, nodeAllTheWay;
860
+ Node = (function() {
861
+ function Node(value) {
862
+ this.value = value;
863
+ this.left = null;
864
+ this.right = null;
865
+ }
866
+
867
+ return Node;
868
+
869
+ })();
870
+ nodeAllTheWay = function(node, leftOrRight) {
871
+ while (node[leftOrRight] !== null) {
872
+ node = node[leftOrRight];
873
+ }
874
+ return node;
875
+ };
876
+ binaryTreeDelete = function(node, value, comparator) {
877
+ var cmp, nextNode;
878
+ if (node === null) {
879
+ throw 'Value not in set';
880
+ }
881
+ cmp = comparator(value, node.value);
882
+ if (cmp < 0) {
883
+ node.left = binaryTreeDelete(node.left, value, comparator);
884
+ } else if (cmp > 0) {
885
+ node.right = binaryTreeDelete(node.right, value, comparator);
886
+ } else {
887
+ if (node.left === null && node.right === null) {
888
+ node = null;
889
+ } else if (node.right === null) {
890
+ node = node.left;
891
+ } else if (node.left === null) {
892
+ node = node.right;
893
+ } else {
894
+ nextNode = nodeAllTheWay(node.right, 'left');
895
+ node.value = nextNode.value;
896
+ node.right = binaryTreeDelete(node.right, nextNode.value, comparator);
897
+ }
898
+ }
899
+ return node;
900
+ };
901
+ return BinaryTreeStrategy = (function(_super) {
902
+ __extends(BinaryTreeStrategy, _super);
903
+
904
+ function BinaryTreeStrategy(options) {
905
+ this.options = options;
906
+ this.comparator = this.options.comparator;
907
+ this.root = null;
908
+ }
909
+
910
+ BinaryTreeStrategy.prototype.insert = function(value) {
911
+ var cmp, compare, leftOrRight, parent;
912
+ compare = this.comparator;
913
+ if (this.root != null) {
914
+ parent = this.root;
915
+ while (true) {
916
+ cmp = compare(value, parent.value);
917
+ if (cmp === 0) {
918
+ throw 'Value already in set';
919
+ }
920
+ leftOrRight = cmp < 0 ? 'left' : 'right';
921
+ if (parent[leftOrRight] === null) {
922
+ break;
923
+ }
924
+ parent = parent[leftOrRight];
925
+ }
926
+ return parent[leftOrRight] = new Node(value);
927
+ } else {
928
+ return this.root = new Node(value);
929
+ }
930
+ };
931
+
932
+ BinaryTreeStrategy.prototype.remove = function(value) {
933
+ return this.root = binaryTreeDelete(this.root, value, this.comparator);
934
+ };
935
+
936
+ return BinaryTreeStrategy;
937
+
938
+ })(AbstractBinaryTreeStrategy);
939
+ });
940
+
941
+ }).call(this);
942
+
943
+ /*
944
+ //@ sourceMappingURL=BinaryTreeStrategy.js.map
945
+ */;
946
+ (function() {
947
+ var __hasProp = {}.hasOwnProperty,
948
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
949
+
950
+ define('SortedSet/RedBlackTreeStrategy',['./AbstractBinaryTreeStrategy'], function(AbstractBinaryTreeStrategy) {
951
+ var Node, RedBlackTreeStrategy, colorFlip, findMinNode, fixUp, insertInNode, moveRedLeft, moveRedRight, removeFromNode, removeMinNode, rotateLeft, rotateRight;
952
+ Node = (function() {
953
+ function Node(value) {
954
+ this.value = value;
955
+ this.left = null;
956
+ this.right = null;
957
+ this.isRed = true;
958
+ }
959
+
960
+ return Node;
961
+
962
+ })();
963
+ rotateLeft = function(h) {
964
+ var x;
965
+ x = h.right;
966
+ h.right = x.left;
967
+ x.left = h;
968
+ x.isRed = h.isRed;
969
+ h.isRed = true;
970
+ return x;
971
+ };
972
+ rotateRight = function(h) {
973
+ var x;
974
+ x = h.left;
975
+ h.left = x.right;
976
+ x.right = h;
977
+ x.isRed = h.isRed;
978
+ h.isRed = true;
979
+ return x;
980
+ };
981
+ colorFlip = function(h) {
982
+ h.isRed = !h.isRed;
983
+ h.left.isRed = !h.left.isRed;
984
+ h.right.isRed = !h.right.isRed;
985
+ return void 0;
986
+ };
987
+ moveRedLeft = function(h) {
988
+ colorFlip(h);
989
+ if (h.right !== null && h.right.left !== null && h.right.left.isRed) {
990
+ h.right = rotateRight(h.right);
991
+ h = rotateLeft(h);
992
+ colorFlip(h);
993
+ }
994
+ return h;
995
+ };
996
+ moveRedRight = function(h) {
997
+ colorFlip(h);
998
+ if (h.left !== null && h.left.left !== null && h.left.left.isRed) {
999
+ h = rotateRight(h);
1000
+ colorFlip(h);
1001
+ }
1002
+ return h;
1003
+ };
1004
+ insertInNode = function(h, value, compare) {
1005
+ if (h === null) {
1006
+ return new Node(value);
1007
+ }
1008
+ if (h.value === value) {
1009
+ throw 'Value already in set';
1010
+ } else {
1011
+ if (compare(value, h.value) < 0) {
1012
+ h.left = insertInNode(h.left, value, compare);
1013
+ } else {
1014
+ h.right = insertInNode(h.right, value, compare);
1015
+ }
1016
+ }
1017
+ if (h.right !== null && h.right.isRed && !(h.left !== null && h.left.isRed)) {
1018
+ h = rotateLeft(h);
1019
+ }
1020
+ if (h.left !== null && h.left.isRed && h.left.left !== null && h.left.left.isRed) {
1021
+ h = rotateRight(h);
1022
+ }
1023
+ if (h.left !== null && h.left.isRed && h.right !== null && h.right.isRed) {
1024
+ colorFlip(h);
1025
+ }
1026
+ return h;
1027
+ };
1028
+ findMinNode = function(h) {
1029
+ while (h.left !== null) {
1030
+ h = h.left;
1031
+ }
1032
+ return h;
1033
+ };
1034
+ fixUp = function(h) {
1035
+ if (h.right !== null && h.right.isRed) {
1036
+ h = rotateLeft(h);
1037
+ }
1038
+ if (h.left !== null && h.left.isRed && h.left.left !== null && h.left.left.isRed) {
1039
+ h = rotateRight(h);
1040
+ }
1041
+ if (h.left !== null && h.left.isRed && h.right !== null && h.right.isRed) {
1042
+ colorFlip(h);
1043
+ }
1044
+ return h;
1045
+ };
1046
+ removeMinNode = function(h) {
1047
+ if (h.left === null) {
1048
+ return null;
1049
+ }
1050
+ if (!h.left.isRed && !(h.left.left !== null && h.left.left.isRed)) {
1051
+ h = moveRedLeft(h);
1052
+ }
1053
+ h.left = removeMinNode(h.left);
1054
+ return fixUp(h);
1055
+ };
1056
+ removeFromNode = function(h, value, compare) {
1057
+ if (h === null) {
1058
+ throw 'Value not in set';
1059
+ }
1060
+ if (h.value !== value && compare(value, h.value) < 0) {
1061
+ if (h.left === null) {
1062
+ throw 'Value not in set';
1063
+ }
1064
+ if (!h.left.isRed && !(h.left.left !== null && h.left.left.isRed)) {
1065
+ h = moveRedLeft(h);
1066
+ }
1067
+ h.left = removeFromNode(h.left, value, compare);
1068
+ } else {
1069
+ if (h.left !== null && h.left.isRed) {
1070
+ h = rotateRight(h);
1071
+ }
1072
+ if (h.right === null) {
1073
+ if (value === h.value) {
1074
+ return null;
1075
+ } else {
1076
+ throw 'Value not in set';
1077
+ }
1078
+ }
1079
+ if (!h.right.isRed && !(h.right.left !== null && h.right.left.isRed)) {
1080
+ h = moveRedRight(h);
1081
+ }
1082
+ if (value === h.value) {
1083
+ h.value = findMinNode(h.right).value;
1084
+ h.right = removeMinNode(h.right);
1085
+ } else {
1086
+ h.right = removeFromNode(h.right, value, compare);
1087
+ }
1088
+ }
1089
+ if (h !== null) {
1090
+ h = fixUp(h);
1091
+ }
1092
+ return h;
1093
+ };
1094
+ return RedBlackTreeStrategy = (function(_super) {
1095
+ __extends(RedBlackTreeStrategy, _super);
1096
+
1097
+ function RedBlackTreeStrategy(options) {
1098
+ this.options = options;
1099
+ this.comparator = this.options.comparator;
1100
+ this.root = null;
1101
+ }
1102
+
1103
+ RedBlackTreeStrategy.prototype.insert = function(value) {
1104
+ this.root = insertInNode(this.root, value, this.comparator);
1105
+ this.root.isRed = false;
1106
+ return void 0;
1107
+ };
1108
+
1109
+ RedBlackTreeStrategy.prototype.remove = function(value) {
1110
+ this.root = removeFromNode(this.root, value, this.comparator);
1111
+ if (this.root !== null) {
1112
+ this.root.isRed = false;
1113
+ }
1114
+ return void 0;
1115
+ };
1116
+
1117
+ return RedBlackTreeStrategy;
1118
+
1119
+ })(AbstractBinaryTreeStrategy);
1120
+ });
1121
+
1122
+ }).call(this);
1123
+
1124
+ /*
1125
+ //@ sourceMappingURL=RedBlackTreeStrategy.js.map
1126
+ */;
1127
+ (function() {
1128
+ var __hasProp = {}.hasOwnProperty,
1129
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
1130
+
1131
+ define('SortedSet',['./SortedSet/AbstractSortedSet', './SortedSet/ArrayStrategy', './SortedSet/BinaryTreeStrategy', './SortedSet/RedBlackTreeStrategy'], function(AbstractSortedSet, ArrayStrategy, BinaryTreeStrategy, RedBlackTreeStrategy) {
1132
+ var SortedSet;
1133
+ SortedSet = (function(_super) {
1134
+ __extends(SortedSet, _super);
1135
+
1136
+ function SortedSet(options) {
1137
+ options || (options = {});
1138
+ options.strategy || (options.strategy = RedBlackTreeStrategy);
1139
+ options.comparator || (options.comparator = function(a, b) {
1140
+ return (a || 0) - (b || 0);
1141
+ });
1142
+ SortedSet.__super__.constructor.call(this, options);
1143
+ }
1144
+
1145
+ return SortedSet;
1146
+
1147
+ })(AbstractSortedSet);
1148
+ SortedSet.ArrayStrategy = ArrayStrategy;
1149
+ SortedSet.BinaryTreeStrategy = BinaryTreeStrategy;
1150
+ SortedSet.RedBlackTreeStrategy = RedBlackTreeStrategy;
1151
+ return SortedSet;
1152
+ });
1153
+
1154
+ }).call(this);
1155
+
1156
+ /*
1157
+ //@ sourceMappingURL=SortedSet.js.map
1158
+ */;
1159
+ (function() {
1160
+ require(['./SortedSet'], function(SortedSet) {
1161
+ return window.SortedSet = SortedSet;
1162
+ });
1163
+
1164
+ }).call(this);
1165
+
1166
+ /*
1167
+ //@ sourceMappingURL=index.js.map
1168
+ */;
1169
+ define("index", function(){});
1170
+ }());