true
+ *
+ * _.eq(object, other);
+ * // => false
+ *
+ * _.eq('a', 'a');
+ * // => true
+ *
+ * _.eq('a', Object('a'));
+ * // => false
+ *
+ * _.eq(NaN, NaN);
+ * // => true
+ */
+function eq(value,other){return value===other||value!==value&&other!==other}module.exports=eq},{}],232:[function(require,module,exports){var arrayFilter=require("./_arrayFilter"),baseFilter=require("./_baseFilter"),baseIteratee=require("./_baseIteratee"),isArray=require("./isArray");
+/**
+ * Iterates over elements of `collection`, returning an array of all elements
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * **Note:** Unlike `_.remove`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ * @see _.reject
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * _.filter(users, function(o) { return !o.active; });
+ * // => objects for ['fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.filter(users, { 'age': 36, 'active': true });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.filter(users, ['active', false]);
+ * // => objects for ['fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.filter(users, 'active');
+ * // => objects for ['barney']
+ */function filter(collection,predicate){var func=isArray(collection)?arrayFilter:baseFilter;return func(collection,baseIteratee(predicate,3))}module.exports=filter},{"./_arrayFilter":65,"./_baseFilter":84,"./_baseIteratee":105,"./isArray":243}],233:[function(require,module,exports){var createFind=require("./_createFind"),findIndex=require("./findIndex");
+/**
+ * Iterates over elements of `collection`, returning the first element
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {*} Returns the matched element, else `undefined`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false },
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
+ * ];
+ *
+ * _.find(users, function(o) { return o.age < 40; });
+ * // => object for 'barney'
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.find(users, { 'age': 1, 'active': true });
+ * // => object for 'pebbles'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.find(users, ['active', false]);
+ * // => object for 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.find(users, 'active');
+ * // => object for 'barney'
+ */var find=createFind(findIndex);module.exports=find},{"./_createFind":150,"./findIndex":234}],234:[function(require,module,exports){var baseFindIndex=require("./_baseFindIndex"),baseIteratee=require("./_baseIteratee"),toInteger=require("./toInteger");
+/* Built-in method references for those with the same name as other `lodash` methods. */var nativeMax=Math.max;
+/**
+ * This method is like `_.find` except that it returns the index of the first
+ * element `predicate` returns truthy for instead of the element itself.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the found element, else `-1`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.findIndex(users, function(o) { return o.user == 'barney'; });
+ * // => 0
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findIndex(users, { 'user': 'fred', 'active': false });
+ * // => 1
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findIndex(users, ['active', false]);
+ * // => 0
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findIndex(users, 'active');
+ * // => 2
+ */function findIndex(array,predicate,fromIndex){var length=array==null?0:array.length;if(!length){return-1}var index=fromIndex==null?0:toInteger(fromIndex);if(index<0){index=nativeMax(length+index,0)}return baseFindIndex(array,baseIteratee(predicate,3),index)}module.exports=findIndex},{"./_baseFindIndex":85,"./_baseIteratee":105,"./toInteger":280}],235:[function(require,module,exports){var baseFlatten=require("./_baseFlatten");
+/**
+ * Flattens `array` a single level deep.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * _.flatten([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, [3, [4]], 5]
+ */function flatten(array){var length=array==null?0:array.length;return length?baseFlatten(array,1):[]}module.exports=flatten},{"./_baseFlatten":86}],236:[function(require,module,exports){var arrayEach=require("./_arrayEach"),baseEach=require("./_baseEach"),castFunction=require("./_castFunction"),isArray=require("./isArray");
+/**
+ * Iterates over elements of `collection` and invokes `iteratee` for each element.
+ * The iteratee is invoked with three arguments: (value, index|key, collection).
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * **Note:** As with other "Collections" methods, objects with a "length"
+ * property are iterated like arrays. To avoid this behavior use `_.forIn`
+ * or `_.forOwn` for object iteration.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @alias each
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ * @see _.forEachRight
+ * @example
+ *
+ * _.forEach([1, 2], function(value) {
+ * console.log(value);
+ * });
+ * // => Logs `1` then `2`.
+ *
+ * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
+ */function forEach(collection,iteratee){var func=isArray(collection)?arrayEach:baseEach;return func(collection,castFunction(iteratee))}module.exports=forEach},{"./_arrayEach":64,"./_baseEach":82,"./_castFunction":132,"./isArray":243}],237:[function(require,module,exports){var baseFor=require("./_baseFor"),castFunction=require("./_castFunction"),keysIn=require("./keysIn");
+/**
+ * Iterates over own and inherited enumerable string keyed properties of an
+ * object and invokes `iteratee` for each property. The iteratee is invoked
+ * with three arguments: (value, key, object). Iteratee functions may exit
+ * iteration early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forInRight
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forIn(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
+ */function forIn(object,iteratee){return object==null?object:baseFor(object,castFunction(iteratee),keysIn)}module.exports=forIn},{"./_baseFor":87,"./_castFunction":132,"./keysIn":260}],238:[function(require,module,exports){var baseGet=require("./_baseGet");
+/**
+ * Gets the value at `path` of `object`. If the resolved value is
+ * `undefined`, the `defaultValue` is returned in its place.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.get(object, 'a[0].b.c');
+ * // => 3
+ *
+ * _.get(object, ['a', '0', 'b', 'c']);
+ * // => 3
+ *
+ * _.get(object, 'a.b.c', 'default');
+ * // => 'default'
+ */function get(object,path,defaultValue){var result=object==null?undefined:baseGet(object,path);return result===undefined?defaultValue:result}module.exports=get},{"./_baseGet":89}],239:[function(require,module,exports){var baseHas=require("./_baseHas"),hasPath=require("./_hasPath");
+/**
+ * Checks if `path` is a direct property of `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = { 'a': { 'b': 2 } };
+ * var other = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.has(object, 'a');
+ * // => true
+ *
+ * _.has(object, 'a.b');
+ * // => true
+ *
+ * _.has(object, ['a', 'b']);
+ * // => true
+ *
+ * _.has(other, 'a');
+ * // => false
+ */function has(object,path){return object!=null&&hasPath(object,path,baseHas)}module.exports=has},{"./_baseHas":93,"./_hasPath":170}],240:[function(require,module,exports){var baseHasIn=require("./_baseHasIn"),hasPath=require("./_hasPath");
+/**
+ * Checks if `path` is a direct or inherited property of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.hasIn(object, 'a');
+ * // => true
+ *
+ * _.hasIn(object, 'a.b');
+ * // => true
+ *
+ * _.hasIn(object, ['a', 'b']);
+ * // => true
+ *
+ * _.hasIn(object, 'b');
+ * // => false
+ */function hasIn(object,path){return object!=null&&hasPath(object,path,baseHasIn)}module.exports=hasIn},{"./_baseHasIn":94,"./_hasPath":170}],241:[function(require,module,exports){
+/**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+function identity(value){return value}module.exports=identity},{}],242:[function(require,module,exports){var baseIsArguments=require("./_baseIsArguments"),isObjectLike=require("./isObjectLike");
+/** Used for built-in method references. */var objectProto=Object.prototype;
+/** Used to check objects for own properties. */var hasOwnProperty=objectProto.hasOwnProperty;
+/** Built-in value references. */var propertyIsEnumerable=objectProto.propertyIsEnumerable;
+/**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */var isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(value){return isObjectLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")};module.exports=isArguments},{"./_baseIsArguments":96,"./isObjectLike":252}],243:[function(require,module,exports){
+/**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+var isArray=Array.isArray;module.exports=isArray},{}],244:[function(require,module,exports){var isFunction=require("./isFunction"),isLength=require("./isLength");
+/**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */function isArrayLike(value){return value!=null&&isLength(value.length)&&!isFunction(value)}module.exports=isArrayLike},{"./isFunction":248,"./isLength":249}],245:[function(require,module,exports){var isArrayLike=require("./isArrayLike"),isObjectLike=require("./isObjectLike");
+/**
+ * This method is like `_.isArrayLike` except that it also checks if `value`
+ * is an object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
+ * else `false`.
+ * @example
+ *
+ * _.isArrayLikeObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLikeObject(document.body.children);
+ * // => true
+ *
+ * _.isArrayLikeObject('abc');
+ * // => false
+ *
+ * _.isArrayLikeObject(_.noop);
+ * // => false
+ */function isArrayLikeObject(value){return isObjectLike(value)&&isArrayLike(value)}module.exports=isArrayLikeObject},{"./isArrayLike":244,"./isObjectLike":252}],246:[function(require,module,exports){var root=require("./_root"),stubFalse=require("./stubFalse");
+/** Detect free variable `exports`. */var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports;
+/** Detect free variable `module`. */var freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module;
+/** Detect the popular CommonJS extension `module.exports`. */var moduleExports=freeModule&&freeModule.exports===freeExports;
+/** Built-in value references. */var Buffer=moduleExports?root.Buffer:undefined;
+/* Built-in method references for those with the same name as other `lodash` methods. */var nativeIsBuffer=Buffer?Buffer.isBuffer:undefined;
+/**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */var isBuffer=nativeIsBuffer||stubFalse;module.exports=isBuffer},{"./_root":208,"./stubFalse":278}],247:[function(require,module,exports){var baseKeys=require("./_baseKeys"),getTag=require("./_getTag"),isArguments=require("./isArguments"),isArray=require("./isArray"),isArrayLike=require("./isArrayLike"),isBuffer=require("./isBuffer"),isPrototype=require("./_isPrototype"),isTypedArray=require("./isTypedArray");
+/** `Object#toString` result references. */var mapTag="[object Map]",setTag="[object Set]";
+/** Used for built-in method references. */var objectProto=Object.prototype;
+/** Used to check objects for own properties. */var hasOwnProperty=objectProto.hasOwnProperty;
+/**
+ * Checks if `value` is an empty object, collection, map, or set.
+ *
+ * Objects are considered empty if they have no own enumerable string keyed
+ * properties.
+ *
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
+ * @example
+ *
+ * _.isEmpty(null);
+ * // => true
+ *
+ * _.isEmpty(true);
+ * // => true
+ *
+ * _.isEmpty(1);
+ * // => true
+ *
+ * _.isEmpty([1, 2, 3]);
+ * // => false
+ *
+ * _.isEmpty({ 'a': 1 });
+ * // => false
+ */function isEmpty(value){if(value==null){return true}if(isArrayLike(value)&&(isArray(value)||typeof value=="string"||typeof value.splice=="function"||isBuffer(value)||isTypedArray(value)||isArguments(value))){return!value.length}var tag=getTag(value);if(tag==mapTag||tag==setTag){return!value.size}if(isPrototype(value)){return!baseKeys(value).length}for(var key in value){if(hasOwnProperty.call(value,key)){return false}}return true}module.exports=isEmpty},{"./_baseKeys":106,"./_getTag":168,"./_isPrototype":186,"./isArguments":242,"./isArray":243,"./isArrayLike":244,"./isBuffer":246,"./isTypedArray":257}],248:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),isObject=require("./isObject");
+/** `Object#toString` result references. */var asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";
+/**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */function isFunction(value){if(!isObject(value)){return false}
+// The use of `Object#toString` avoids issues with the `typeof` operator
+// in Safari 9 which returns 'object' for typed arrays and other constructors.
+var tag=baseGetTag(value);return tag==funcTag||tag==genTag||tag==asyncTag||tag==proxyTag}module.exports=isFunction},{"./_baseGetTag":91,"./isObject":251}],249:[function(require,module,exports){
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER=9007199254740991;
+/**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}module.exports=isLength},{}],250:[function(require,module,exports){var baseIsMap=require("./_baseIsMap"),baseUnary=require("./_baseUnary"),nodeUtil=require("./_nodeUtil");
+/* Node.js helper references. */var nodeIsMap=nodeUtil&&nodeUtil.isMap;
+/**
+ * Checks if `value` is classified as a `Map` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
+ * @example
+ *
+ * _.isMap(new Map);
+ * // => true
+ *
+ * _.isMap(new WeakMap);
+ * // => false
+ */var isMap=nodeIsMap?baseUnary(nodeIsMap):baseIsMap;module.exports=isMap},{"./_baseIsMap":99,"./_baseUnary":127,"./_nodeUtil":204}],251:[function(require,module,exports){
+/**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+function isObject(value){var type=typeof value;return value!=null&&(type=="object"||type=="function")}module.exports=isObject},{}],252:[function(require,module,exports){
+/**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+function isObjectLike(value){return value!=null&&typeof value=="object"}module.exports=isObjectLike},{}],253:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),getPrototype=require("./_getPrototype"),isObjectLike=require("./isObjectLike");
+/** `Object#toString` result references. */var objectTag="[object Object]";
+/** Used for built-in method references. */var funcProto=Function.prototype,objectProto=Object.prototype;
+/** Used to resolve the decompiled source of functions. */var funcToString=funcProto.toString;
+/** Used to check objects for own properties. */var hasOwnProperty=objectProto.hasOwnProperty;
+/** Used to infer the `Object` constructor. */var objectCtorString=funcToString.call(Object);
+/**
+ * Checks if `value` is a plain object, that is, an object created by the
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.8.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * _.isPlainObject(new Foo);
+ * // => false
+ *
+ * _.isPlainObject([1, 2, 3]);
+ * // => false
+ *
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
+ * // => true
+ *
+ * _.isPlainObject(Object.create(null));
+ * // => true
+ */function isPlainObject(value){if(!isObjectLike(value)||baseGetTag(value)!=objectTag){return false}var proto=getPrototype(value);if(proto===null){return true}var Ctor=hasOwnProperty.call(proto,"constructor")&&proto.constructor;return typeof Ctor=="function"&&Ctor instanceof Ctor&&funcToString.call(Ctor)==objectCtorString}module.exports=isPlainObject},{"./_baseGetTag":91,"./_getPrototype":164,"./isObjectLike":252}],254:[function(require,module,exports){var baseIsSet=require("./_baseIsSet"),baseUnary=require("./_baseUnary"),nodeUtil=require("./_nodeUtil");
+/* Node.js helper references. */var nodeIsSet=nodeUtil&&nodeUtil.isSet;
+/**
+ * Checks if `value` is classified as a `Set` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
+ * @example
+ *
+ * _.isSet(new Set);
+ * // => true
+ *
+ * _.isSet(new WeakSet);
+ * // => false
+ */var isSet=nodeIsSet?baseUnary(nodeIsSet):baseIsSet;module.exports=isSet},{"./_baseIsSet":103,"./_baseUnary":127,"./_nodeUtil":204}],255:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),isArray=require("./isArray"),isObjectLike=require("./isObjectLike");
+/** `Object#toString` result references. */var stringTag="[object String]";
+/**
+ * Checks if `value` is classified as a `String` primitive or object.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a string, else `false`.
+ * @example
+ *
+ * _.isString('abc');
+ * // => true
+ *
+ * _.isString(1);
+ * // => false
+ */function isString(value){return typeof value=="string"||!isArray(value)&&isObjectLike(value)&&baseGetTag(value)==stringTag}module.exports=isString},{"./_baseGetTag":91,"./isArray":243,"./isObjectLike":252}],256:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),isObjectLike=require("./isObjectLike");
+/** `Object#toString` result references. */var symbolTag="[object Symbol]";
+/**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */function isSymbol(value){return typeof value=="symbol"||isObjectLike(value)&&baseGetTag(value)==symbolTag}module.exports=isSymbol},{"./_baseGetTag":91,"./isObjectLike":252}],257:[function(require,module,exports){var baseIsTypedArray=require("./_baseIsTypedArray"),baseUnary=require("./_baseUnary"),nodeUtil=require("./_nodeUtil");
+/* Node.js helper references. */var nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray;
+/**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */var isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;module.exports=isTypedArray},{"./_baseIsTypedArray":104,"./_baseUnary":127,"./_nodeUtil":204}],258:[function(require,module,exports){
+/**
+ * Checks if `value` is `undefined`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
+ * @example
+ *
+ * _.isUndefined(void 0);
+ * // => true
+ *
+ * _.isUndefined(null);
+ * // => false
+ */
+function isUndefined(value){return value===undefined}module.exports=isUndefined},{}],259:[function(require,module,exports){var arrayLikeKeys=require("./_arrayLikeKeys"),baseKeys=require("./_baseKeys"),isArrayLike=require("./isArrayLike");
+/**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */function keys(object){return isArrayLike(object)?arrayLikeKeys(object):baseKeys(object)}module.exports=keys},{"./_arrayLikeKeys":68,"./_baseKeys":106,"./isArrayLike":244}],260:[function(require,module,exports){var arrayLikeKeys=require("./_arrayLikeKeys"),baseKeysIn=require("./_baseKeysIn"),isArrayLike=require("./isArrayLike");
+/**
+ * Creates an array of the own and inherited enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keysIn(new Foo);
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
+ */function keysIn(object){return isArrayLike(object)?arrayLikeKeys(object,true):baseKeysIn(object)}module.exports=keysIn},{"./_arrayLikeKeys":68,"./_baseKeysIn":107,"./isArrayLike":244}],261:[function(require,module,exports){
+/**
+ * Gets the last element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {*} Returns the last element of `array`.
+ * @example
+ *
+ * _.last([1, 2, 3]);
+ * // => 3
+ */
+function last(array){var length=array==null?0:array.length;return length?array[length-1]:undefined}module.exports=last},{}],262:[function(require,module,exports){var arrayMap=require("./_arrayMap"),baseIteratee=require("./_baseIteratee"),baseMap=require("./_baseMap"),isArray=require("./isArray");
+/**
+ * Creates an array of values by running each element in `collection` thru
+ * `iteratee`. The iteratee is invoked with three arguments:
+ * (value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
+ *
+ * The guarded methods are:
+ * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
+ * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * _.map([4, 8], square);
+ * // => [16, 64]
+ *
+ * _.map({ 'a': 4, 'b': 8 }, square);
+ * // => [16, 64] (iteration order is not guaranteed)
+ *
+ * var users = [
+ * { 'user': 'barney' },
+ * { 'user': 'fred' }
+ * ];
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.map(users, 'user');
+ * // => ['barney', 'fred']
+ */function map(collection,iteratee){var func=isArray(collection)?arrayMap:baseMap;return func(collection,baseIteratee(iteratee,3))}module.exports=map},{"./_arrayMap":69,"./_baseIteratee":105,"./_baseMap":109,"./isArray":243}],263:[function(require,module,exports){var baseAssignValue=require("./_baseAssignValue"),baseForOwn=require("./_baseForOwn"),baseIteratee=require("./_baseIteratee");
+/**
+ * Creates an object with the same keys as `object` and values generated
+ * by running each own enumerable string keyed property of `object` thru
+ * `iteratee`. The iteratee is invoked with three arguments:
+ * (value, key, object).
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns the new mapped object.
+ * @see _.mapKeys
+ * @example
+ *
+ * var users = {
+ * 'fred': { 'user': 'fred', 'age': 40 },
+ * 'pebbles': { 'user': 'pebbles', 'age': 1 }
+ * };
+ *
+ * _.mapValues(users, function(o) { return o.age; });
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.mapValues(users, 'age');
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
+ */function mapValues(object,iteratee){var result={};iteratee=baseIteratee(iteratee,3);baseForOwn(object,function(value,key,object){baseAssignValue(result,key,iteratee(value,key,object))});return result}module.exports=mapValues},{"./_baseAssignValue":79,"./_baseForOwn":88,"./_baseIteratee":105}],264:[function(require,module,exports){var baseExtremum=require("./_baseExtremum"),baseGt=require("./_baseGt"),identity=require("./identity");
+/**
+ * Computes the maximum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the maximum value.
+ * @example
+ *
+ * _.max([4, 2, 8, 6]);
+ * // => 8
+ *
+ * _.max([]);
+ * // => undefined
+ */function max(array){return array&&array.length?baseExtremum(array,identity,baseGt):undefined}module.exports=max},{"./_baseExtremum":83,"./_baseGt":92,"./identity":241}],265:[function(require,module,exports){var MapCache=require("./_MapCache");
+/** Error message constants. */var FUNC_ERROR_TEXT="Expected a function";
+/**
+ * Creates a function that memoizes the result of `func`. If `resolver` is
+ * provided, it determines the cache key for storing the result based on the
+ * arguments provided to the memoized function. By default, the first argument
+ * provided to the memoized function is used as the map cache key. The `func`
+ * is invoked with the `this` binding of the memoized function.
+ *
+ * **Note:** The cache is exposed as the `cache` property on the memoized
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
+ * constructor with one whose instances implement the
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to have its output memoized.
+ * @param {Function} [resolver] The function to resolve the cache key.
+ * @returns {Function} Returns the new memoized function.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ * var other = { 'c': 3, 'd': 4 };
+ *
+ * var values = _.memoize(_.values);
+ * values(object);
+ * // => [1, 2]
+ *
+ * values(other);
+ * // => [3, 4]
+ *
+ * object.a = 2;
+ * values(object);
+ * // => [1, 2]
+ *
+ * // Modify the result cache.
+ * values.cache.set(object, ['a', 'b']);
+ * values(object);
+ * // => ['a', 'b']
+ *
+ * // Replace `_.memoize.Cache`.
+ * _.memoize.Cache = WeakMap;
+ */function memoize(func,resolver){if(typeof func!="function"||resolver!=null&&typeof resolver!="function"){throw new TypeError(FUNC_ERROR_TEXT)}var memoized=function(){var args=arguments,key=resolver?resolver.apply(this,args):args[0],cache=memoized.cache;if(cache.has(key)){return cache.get(key)}var result=func.apply(this,args);memoized.cache=cache.set(key,result)||cache;return result};memoized.cache=new(memoize.Cache||MapCache);return memoized}
+// Expose `MapCache`.
+memoize.Cache=MapCache;module.exports=memoize},{"./_MapCache":55}],266:[function(require,module,exports){var baseMerge=require("./_baseMerge"),createAssigner=require("./_createAssigner");
+/**
+ * This method is like `_.assign` except that it recursively merges own and
+ * inherited enumerable string keyed properties of source objects into the
+ * destination object. Source properties that resolve to `undefined` are
+ * skipped if a destination value exists. Array and plain object properties
+ * are merged recursively. Other objects and value types are overridden by
+ * assignment. Source objects are applied from left to right. Subsequent
+ * sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
+ * };
+ *
+ * var other = {
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
+ * };
+ *
+ * _.merge(object, other);
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
+ */var merge=createAssigner(function(object,source,srcIndex){baseMerge(object,source,srcIndex)});module.exports=merge},{"./_baseMerge":112,"./_createAssigner":147}],267:[function(require,module,exports){var baseExtremum=require("./_baseExtremum"),baseLt=require("./_baseLt"),identity=require("./identity");
+/**
+ * Computes the minimum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the minimum value.
+ * @example
+ *
+ * _.min([4, 2, 8, 6]);
+ * // => 2
+ *
+ * _.min([]);
+ * // => undefined
+ */function min(array){return array&&array.length?baseExtremum(array,identity,baseLt):undefined}module.exports=min},{"./_baseExtremum":83,"./_baseLt":108,"./identity":241}],268:[function(require,module,exports){var baseExtremum=require("./_baseExtremum"),baseIteratee=require("./_baseIteratee"),baseLt=require("./_baseLt");
+/**
+ * This method is like `_.min` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * the value is ranked. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {*} Returns the minimum value.
+ * @example
+ *
+ * var objects = [{ 'n': 1 }, { 'n': 2 }];
+ *
+ * _.minBy(objects, function(o) { return o.n; });
+ * // => { 'n': 1 }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.minBy(objects, 'n');
+ * // => { 'n': 1 }
+ */function minBy(array,iteratee){return array&&array.length?baseExtremum(array,baseIteratee(iteratee,2),baseLt):undefined}module.exports=minBy},{"./_baseExtremum":83,"./_baseIteratee":105,"./_baseLt":108}],269:[function(require,module,exports){
+/**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+function noop(){
+// No operation performed.
+}module.exports=noop},{}],270:[function(require,module,exports){var root=require("./_root");
+/**
+ * Gets the timestamp of the number of milliseconds that have elapsed since
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Date
+ * @returns {number} Returns the timestamp.
+ * @example
+ *
+ * _.defer(function(stamp) {
+ * console.log(_.now() - stamp);
+ * }, _.now());
+ * // => Logs the number of milliseconds it took for the deferred invocation.
+ */var now=function(){return root.Date.now()};module.exports=now},{"./_root":208}],271:[function(require,module,exports){var basePick=require("./_basePick"),flatRest=require("./_flatRest");
+/**
+ * Creates an object composed of the picked `object` properties.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.pick(object, ['a', 'c']);
+ * // => { 'a': 1, 'c': 3 }
+ */var pick=flatRest(function(object,paths){return object==null?{}:basePick(object,paths)});module.exports=pick},{"./_basePick":115,"./_flatRest":157}],272:[function(require,module,exports){var baseProperty=require("./_baseProperty"),basePropertyDeep=require("./_basePropertyDeep"),isKey=require("./_isKey"),toKey=require("./_toKey");
+/**
+ * Creates a function that returns the value at `path` of a given object.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {Array|string} path The path of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': { 'b': 2 } },
+ * { 'a': { 'b': 1 } }
+ * ];
+ *
+ * _.map(objects, _.property('a.b'));
+ * // => [2, 1]
+ *
+ * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
+ * // => [1, 2]
+ */function property(path){return isKey(path)?baseProperty(toKey(path)):basePropertyDeep(path)}module.exports=property},{"./_baseProperty":117,"./_basePropertyDeep":118,"./_isKey":183,"./_toKey":223}],273:[function(require,module,exports){var createRange=require("./_createRange");
+/**
+ * Creates an array of numbers (positive and/or negative) progressing from
+ * `start` up to, but not including, `end`. A step of `-1` is used if a negative
+ * `start` is specified without an `end` or `step`. If `end` is not specified,
+ * it's set to `start` with `start` then set to `0`.
+ *
+ * **Note:** JavaScript follows the IEEE-754 standard for resolving
+ * floating-point values which can produce unexpected results.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} [step=1] The value to increment or decrement by.
+ * @returns {Array} Returns the range of numbers.
+ * @see _.inRange, _.rangeRight
+ * @example
+ *
+ * _.range(4);
+ * // => [0, 1, 2, 3]
+ *
+ * _.range(-4);
+ * // => [0, -1, -2, -3]
+ *
+ * _.range(1, 5);
+ * // => [1, 2, 3, 4]
+ *
+ * _.range(0, 20, 5);
+ * // => [0, 5, 10, 15]
+ *
+ * _.range(0, -4, -1);
+ * // => [0, -1, -2, -3]
+ *
+ * _.range(1, 4, 0);
+ * // => [1, 1, 1]
+ *
+ * _.range(0);
+ * // => []
+ */var range=createRange();module.exports=range},{"./_createRange":151}],274:[function(require,module,exports){var arrayReduce=require("./_arrayReduce"),baseEach=require("./_baseEach"),baseIteratee=require("./_baseIteratee"),baseReduce=require("./_baseReduce"),isArray=require("./isArray");
+/**
+ * Reduces `collection` to a value which is the accumulated result of running
+ * each element in `collection` thru `iteratee`, where each successive
+ * invocation is supplied the return value of the previous. If `accumulator`
+ * is not given, the first element of `collection` is used as the initial
+ * value. The iteratee is invoked with four arguments:
+ * (accumulator, value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.reduce`, `_.reduceRight`, and `_.transform`.
+ *
+ * The guarded methods are:
+ * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
+ * and `sortBy`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @returns {*} Returns the accumulated value.
+ * @see _.reduceRight
+ * @example
+ *
+ * _.reduce([1, 2], function(sum, n) {
+ * return sum + n;
+ * }, 0);
+ * // => 3
+ *
+ * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
+ * (result[value] || (result[value] = [])).push(key);
+ * return result;
+ * }, {});
+ * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
+ */function reduce(collection,iteratee,accumulator){var func=isArray(collection)?arrayReduce:baseReduce,initAccum=arguments.length<3;return func(collection,baseIteratee(iteratee,4),accumulator,initAccum,baseEach)}module.exports=reduce},{"./_arrayReduce":71,"./_baseEach":82,"./_baseIteratee":105,"./_baseReduce":120,"./isArray":243}],275:[function(require,module,exports){var baseKeys=require("./_baseKeys"),getTag=require("./_getTag"),isArrayLike=require("./isArrayLike"),isString=require("./isString"),stringSize=require("./_stringSize");
+/** `Object#toString` result references. */var mapTag="[object Map]",setTag="[object Set]";
+/**
+ * Gets the size of `collection` by returning its length for array-like
+ * values or the number of own enumerable string keyed properties for objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object|string} collection The collection to inspect.
+ * @returns {number} Returns the collection size.
+ * @example
+ *
+ * _.size([1, 2, 3]);
+ * // => 3
+ *
+ * _.size({ 'a': 1, 'b': 2 });
+ * // => 2
+ *
+ * _.size('pebbles');
+ * // => 7
+ */function size(collection){if(collection==null){return 0}if(isArrayLike(collection)){return isString(collection)?stringSize(collection):collection.length}var tag=getTag(collection);if(tag==mapTag||tag==setTag){return collection.size}return baseKeys(collection).length}module.exports=size},{"./_baseKeys":106,"./_getTag":168,"./_stringSize":221,"./isArrayLike":244,"./isString":255}],276:[function(require,module,exports){var baseFlatten=require("./_baseFlatten"),baseOrderBy=require("./_baseOrderBy"),baseRest=require("./_baseRest"),isIterateeCall=require("./_isIterateeCall");
+/**
+ * Creates an array of elements, sorted in ascending order by the results of
+ * running each element in a collection thru each iteratee. This method
+ * performs a stable sort, that is, it preserves the original sort order of
+ * equal elements. The iteratees are invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to sort by.
+ * @returns {Array} Returns the new sorted array.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'fred', 'age': 48 },
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 34 }
+ * ];
+ *
+ * _.sortBy(users, [function(o) { return o.user; }]);
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
+ *
+ * _.sortBy(users, ['user', 'age']);
+ * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
+ */var sortBy=baseRest(function(collection,iteratees){if(collection==null){return[]}var length=iteratees.length;if(length>1&&isIterateeCall(collection,iteratees[0],iteratees[1])){iteratees=[]}else if(length>2&&isIterateeCall(iteratees[0],iteratees[1],iteratees[2])){iteratees=[iteratees[0]]}return baseOrderBy(collection,baseFlatten(iteratees,1),[])});module.exports=sortBy},{"./_baseFlatten":86,"./_baseOrderBy":114,"./_baseRest":121,"./_isIterateeCall":182}],277:[function(require,module,exports){
+/**
+ * This method returns a new empty array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {Array} Returns the new empty array.
+ * @example
+ *
+ * var arrays = _.times(2, _.stubArray);
+ *
+ * console.log(arrays);
+ * // => [[], []]
+ *
+ * console.log(arrays[0] === arrays[1]);
+ * // => false
+ */
+function stubArray(){return[]}module.exports=stubArray},{}],278:[function(require,module,exports){
+/**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+function stubFalse(){return false}module.exports=stubFalse},{}],279:[function(require,module,exports){var toNumber=require("./toNumber");
+/** Used as references for various `Number` constants. */var INFINITY=1/0,MAX_INTEGER=17976931348623157e292;
+/**
+ * Converts `value` to a finite number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.12.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted number.
+ * @example
+ *
+ * _.toFinite(3.2);
+ * // => 3.2
+ *
+ * _.toFinite(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toFinite(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toFinite('3.2');
+ * // => 3.2
+ */function toFinite(value){if(!value){return value===0?value:0}value=toNumber(value);if(value===INFINITY||value===-INFINITY){var sign=value<0?-1:1;return sign*MAX_INTEGER}return value===value?value:0}module.exports=toFinite},{"./toNumber":281}],280:[function(require,module,exports){var toFinite=require("./toFinite");
+/**
+ * Converts `value` to an integer.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toInteger(3.2);
+ * // => 3
+ *
+ * _.toInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toInteger(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toInteger('3.2');
+ * // => 3
+ */function toInteger(value){var result=toFinite(value),remainder=result%1;return result===result?remainder?result-remainder:result:0}module.exports=toInteger},{"./toFinite":279}],281:[function(require,module,exports){var isObject=require("./isObject"),isSymbol=require("./isSymbol");
+/** Used as references for various `Number` constants. */var NAN=0/0;
+/** Used to match leading and trailing whitespace. */var reTrim=/^\s+|\s+$/g;
+/** Used to detect bad signed hexadecimal string values. */var reIsBadHex=/^[-+]0x[0-9a-f]+$/i;
+/** Used to detect binary string values. */var reIsBinary=/^0b[01]+$/i;
+/** Used to detect octal string values. */var reIsOctal=/^0o[0-7]+$/i;
+/** Built-in method references without a dependency on `root`. */var freeParseInt=parseInt;
+/**
+ * Converts `value` to a number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ * @example
+ *
+ * _.toNumber(3.2);
+ * // => 3.2
+ *
+ * _.toNumber(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toNumber(Infinity);
+ * // => Infinity
+ *
+ * _.toNumber('3.2');
+ * // => 3.2
+ */function toNumber(value){if(typeof value=="number"){return value}if(isSymbol(value)){return NAN}if(isObject(value)){var other=typeof value.valueOf=="function"?value.valueOf():value;value=isObject(other)?other+"":other}if(typeof value!="string"){return value===0?value:+value}value=value.replace(reTrim,"");var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NAN:+value}module.exports=toNumber},{"./isObject":251,"./isSymbol":256}],282:[function(require,module,exports){var copyObject=require("./_copyObject"),keysIn=require("./keysIn");
+/**
+ * Converts `value` to a plain object flattening inherited enumerable string
+ * keyed properties of `value` to own properties of the plain object.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {Object} Returns the converted plain object.
+ * @example
+ *
+ * function Foo() {
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.assign({ 'a': 1 }, new Foo);
+ * // => { 'a': 1, 'b': 2 }
+ *
+ * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
+ * // => { 'a': 1, 'b': 2, 'c': 3 }
+ */function toPlainObject(value){return copyObject(value,keysIn(value))}module.exports=toPlainObject},{"./_copyObject":143,"./keysIn":260}],283:[function(require,module,exports){var baseToString=require("./_baseToString");
+/**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */function toString(value){return value==null?"":baseToString(value)}module.exports=toString},{"./_baseToString":126}],284:[function(require,module,exports){var arrayEach=require("./_arrayEach"),baseCreate=require("./_baseCreate"),baseForOwn=require("./_baseForOwn"),baseIteratee=require("./_baseIteratee"),getPrototype=require("./_getPrototype"),isArray=require("./isArray"),isBuffer=require("./isBuffer"),isFunction=require("./isFunction"),isObject=require("./isObject"),isTypedArray=require("./isTypedArray");
+/**
+ * An alternative to `_.reduce`; this method transforms `object` to a new
+ * `accumulator` object which is the result of running each of its own
+ * enumerable string keyed properties thru `iteratee`, with each invocation
+ * potentially mutating the `accumulator` object. If `accumulator` is not
+ * provided, a new object with the same `[[Prototype]]` will be used. The
+ * iteratee is invoked with four arguments: (accumulator, value, key, object).
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The custom accumulator value.
+ * @returns {*} Returns the accumulated value.
+ * @example
+ *
+ * _.transform([2, 3, 4], function(result, n) {
+ * result.push(n *= n);
+ * return n % 2 == 0;
+ * }, []);
+ * // => [4, 9]
+ *
+ * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
+ * (result[value] || (result[value] = [])).push(key);
+ * }, {});
+ * // => { '1': ['a', 'c'], '2': ['b'] }
+ */function transform(object,iteratee,accumulator){var isArr=isArray(object),isArrLike=isArr||isBuffer(object)||isTypedArray(object);iteratee=baseIteratee(iteratee,4);if(accumulator==null){var Ctor=object&&object.constructor;if(isArrLike){accumulator=isArr?new Ctor:[]}else if(isObject(object)){accumulator=isFunction(Ctor)?baseCreate(getPrototype(object)):{}}else{accumulator={}}}(isArrLike?arrayEach:baseForOwn)(object,function(value,index,object){return iteratee(accumulator,value,index,object)});return accumulator}module.exports=transform},{"./_arrayEach":64,"./_baseCreate":81,"./_baseForOwn":88,"./_baseIteratee":105,"./_getPrototype":164,"./isArray":243,"./isBuffer":246,"./isFunction":248,"./isObject":251,"./isTypedArray":257}],285:[function(require,module,exports){var baseFlatten=require("./_baseFlatten"),baseRest=require("./_baseRest"),baseUniq=require("./_baseUniq"),isArrayLikeObject=require("./isArrayLikeObject");
+/**
+ * Creates an array of unique values, in order, from all given arrays using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @returns {Array} Returns the new array of combined values.
+ * @example
+ *
+ * _.union([2], [1, 2]);
+ * // => [2, 1]
+ */var union=baseRest(function(arrays){return baseUniq(baseFlatten(arrays,1,isArrayLikeObject,true))});module.exports=union},{"./_baseFlatten":86,"./_baseRest":121,"./_baseUniq":128,"./isArrayLikeObject":245}],286:[function(require,module,exports){var toString=require("./toString");
+/** Used to generate unique IDs. */var idCounter=0;
+/**
+ * Generates a unique ID. If `prefix` is given, the ID is appended to it.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {string} [prefix=''] The value to prefix the ID with.
+ * @returns {string} Returns the unique ID.
+ * @example
+ *
+ * _.uniqueId('contact_');
+ * // => 'contact_104'
+ *
+ * _.uniqueId();
+ * // => '105'
+ */function uniqueId(prefix){var id=++idCounter;return toString(prefix)+id}module.exports=uniqueId},{"./toString":283}],287:[function(require,module,exports){var baseValues=require("./_baseValues"),keys=require("./keys");
+/**
+ * Creates an array of the own enumerable string keyed property values of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property values.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.values(new Foo);
+ * // => [1, 2] (iteration order is not guaranteed)
+ *
+ * _.values('hi');
+ * // => ['h', 'i']
+ */function values(object){return object==null?[]:baseValues(object,keys(object))}module.exports=values},{"./_baseValues":129,"./keys":259}],288:[function(require,module,exports){var assignValue=require("./_assignValue"),baseZipObject=require("./_baseZipObject");
+/**
+ * This method is like `_.fromPairs` except that it accepts two arrays,
+ * one of property identifiers and one of corresponding values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.4.0
+ * @category Array
+ * @param {Array} [props=[]] The property identifiers.
+ * @param {Array} [values=[]] The property values.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * _.zipObject(['a', 'b'], [1, 2]);
+ * // => { 'a': 1, 'b': 2 }
+ */function zipObject(props,values){return baseZipObject(props||[],values||[],assignValue)}module.exports=zipObject},{"./_assignValue":75,"./_baseZipObject":130}]},{},[1])(1)});
diff --git a/src/assets/viewer-app.js b/src/assets/viewer-app.js
new file mode 100644
index 0000000..0e6eab6
--- /dev/null
+++ b/src/assets/viewer-app.js
@@ -0,0 +1,402 @@
+/* SocratiCode interactive graph viewer — app logic
+ * Loaded after Cytoscape + Dagre + cytoscape-dagre are on window.
+ * Reads embedded graph data from window.__SOCRATICODE_DATA__.
+ *
+ * All DOM rendering uses createElement + textContent for XSS safety — no
+ * innerHTML is used anywhere, so data fields with HTML-looking content
+ * (rare but possible in symbol names) cannot escape into markup.
+ */
+(function () {
+ "use strict";
+
+ const DATA = window.__SOCRATICODE_DATA__;
+ if (!DATA) throw new Error("Missing __SOCRATICODE_DATA__");
+
+ // Language → colour palette (kept in sync with Mermaid generator)
+ const LANG_COLORS = {
+ typescript: "#3178C6", javascript: "#F7DF1E", python: "#3776AB",
+ java: "#ED8B00", kotlin: "#7F52FF", go: "#00ADD8",
+ rust: "#CE422B", ruby: "#CC342D", php: "#777BB4",
+ swift: "#FA7343", c: "#A8B9CC", cpp: "#00599C",
+ csharp: "#239120", scala: "#DC322F", dart: "#0175C2",
+ lua: "#2C2D72", shell: "#4EAA25", html: "#E34F26",
+ css: "#1572B6", json: "#808080",
+ };
+ const FALLBACK_COLOR = "#607D8B";
+ const colourFor = (lang) => LANG_COLORS[lang] || FALLBACK_COLOR;
+
+ // Symbol-kind → colour
+ const KIND_COLORS = {
+ function: "#3b82f6", class: "#a855f7", method: "#06b6d4",
+ constructor: "#0891b2", interface: "#f59e0b", trait: "#f59e0b",
+ enum: "#ec4899", module: "#6b7280", struct: "#a855f7", variable: "#84cc16",
+ };
+
+ // ── Tiny DOM builder (XSS-safe — all text via textContent) ───────
+ function h(tag, attrs, ...children) {
+ const el = document.createElement(tag);
+ if (attrs) {
+ for (const [k, v] of Object.entries(attrs)) {
+ if (v == null || v === false) continue;
+ if (k === "class") el.className = v;
+ else if (k === "style") el.setAttribute("style", v);
+ else if (k.startsWith("data-")) el.setAttribute(k, String(v));
+ else if (k === "title") el.title = String(v);
+ else if (k === "disabled") el.disabled = true;
+ else el[k] = v;
+ }
+ }
+ for (const c of children) {
+ if (c == null || c === false) continue;
+ el.appendChild(typeof c === "string" || typeof c === "number" ? document.createTextNode(String(c)) : c);
+ }
+ return el;
+ }
+
+ // ── Register layouts ──────────────────────────────────────────────
+ if (window.cytoscapeDagre) window.cytoscapeDagre(cytoscape);
+
+ // ── Build Cytoscape elements from data ───────────────────────────
+ const FILE_NODES = DATA.files.map((f) => ({
+ group: "nodes",
+ data: {
+ id: `f::${f.id}`,
+ label: f.label,
+ nodeType: "file",
+ file: f.id,
+ language: f.language,
+ deps: f.deps,
+ dependents: f.dependents,
+ symbolCount: f.symbolCount || 0,
+ },
+ }));
+ const FILE_EDGES = DATA.fileEdges.map((e, i) => ({
+ group: "edges",
+ data: {
+ id: `fe${i}`,
+ source: `f::${e.source}`,
+ target: `f::${e.target}`,
+ edgeType: e.type,
+ cyclic: e.cyclic,
+ scope: "file",
+ },
+ classes: `${e.cyclic ? "cyclic" : ""} ${e.type === "dynamic-import" ? "dynamic" : ""}`.trim(),
+ }));
+
+ const SYMBOL_NODES = (DATA.symbols || []).map((s) => ({
+ group: "nodes",
+ data: {
+ id: `s::${s.id}`,
+ label: s.name,
+ nodeType: "symbol",
+ qualifiedName: s.qualifiedName,
+ kind: s.kind,
+ file: s.file,
+ line: s.line,
+ },
+ }));
+ const SYMBOL_EDGES = (DATA.symbolEdges || []).map((e, i) => ({
+ group: "edges",
+ data: {
+ id: `se${i}`,
+ source: `s::${e.source}`,
+ target: `s::${e.target}`,
+ confidence: e.confidence,
+ scope: "symbol",
+ },
+ classes: `conf-${e.confidence}`,
+ }));
+
+ // ── Cytoscape style ──────────────────────────────────────────────
+ const STYLE = [
+ {
+ selector: 'node[nodeType = "file"]',
+ style: {
+ "background-color": (ele) => colourFor(ele.data("language")),
+ "label": "data(label)",
+ "font-size": 10, "color": "#1f2937", "text-valign": "bottom",
+ "text-margin-y": 4, "text-background-color": "#fff",
+ "text-background-opacity": 0.8, "text-background-padding": 2,
+ "width": (ele) => 14 + Math.min(30, (ele.data("dependents") || 0) * 2),
+ "height": (ele) => 14 + Math.min(30, (ele.data("dependents") || 0) * 2),
+ "border-width": 1, "border-color": "#0f172a",
+ },
+ },
+ {
+ selector: 'node[nodeType = "symbol"]',
+ style: {
+ "background-color": (ele) => KIND_COLORS[ele.data("kind")] || "#64748b",
+ "label": "data(label)",
+ "font-size": 10, "color": "#1f2937", "text-valign": "bottom",
+ "text-margin-y": 4, "shape": "round-rectangle",
+ "width": 40, "height": 18,
+ "border-width": 1, "border-color": "#0f172a",
+ },
+ },
+ {
+ selector: "edge",
+ style: {
+ "width": 1.5, "line-color": "#cbd5e1",
+ "target-arrow-color": "#cbd5e1", "target-arrow-shape": "triangle",
+ "curve-style": "bezier", "arrow-scale": 0.8,
+ },
+ },
+ { selector: "edge.dynamic", style: { "line-style": "dashed" } },
+ { selector: "edge.cyclic", style: { "line-color": "#dc2626", "target-arrow-color": "#dc2626", "width": 2.5, "line-style": "dashed" } },
+ { selector: "edge.conf-multiple-candidates", style: { "line-style": "dashed", "line-color": "#a78bfa", "target-arrow-color": "#a78bfa" } },
+ { selector: "edge.conf-unresolved", style: { "line-style": "dotted", "line-color": "#94a3b8", "target-arrow-color": "#94a3b8" } },
+ { selector: ".faded", style: { "opacity": 0.15, "text-opacity": 0.1 } },
+ {
+ selector: ".highlight",
+ style: {
+ "background-color": "#ef4444", "border-color": "#991b1b",
+ "border-width": 2, "z-index": 999,
+ },
+ },
+ {
+ selector: ".highlight-flow",
+ style: {
+ "background-color": "#3b82f6", "border-color": "#1e40af",
+ "border-width": 2, "z-index": 999,
+ },
+ },
+ { selector: "edge.highlight-edge", style: { "line-color": "#ef4444", "target-arrow-color": "#ef4444", "width": 3, "z-index": 999 } },
+ { selector: "edge.highlight-flow-edge", style: { "line-color": "#3b82f6", "target-arrow-color": "#3b82f6", "width": 3, "z-index": 999 } },
+ ];
+
+ // ── Instantiate Cytoscape ────────────────────────────────────────
+ const cy = cytoscape({
+ container: document.getElementById("cy"),
+ elements: [...FILE_NODES, ...FILE_EDGES],
+ style: STYLE,
+ wheelSensitivity: 0.2,
+ minZoom: 0.1,
+ maxZoom: 3,
+ });
+
+ // ── Layout runner ────────────────────────────────────────────────
+ let currentView = "files";
+ let currentLayout = DATA.files.length > 200 ? "dagre" : "cose";
+
+ function runLayout(name) {
+ currentLayout = name;
+ const opts = { name, animate: true, animationDuration: 300, fit: true, padding: 30 };
+ if (name === "dagre") { opts.rankDir = "LR"; opts.nodeSep = 20; opts.rankSep = 60; }
+ if (name === "cose") { opts.nodeRepulsion = 8000; opts.idealEdgeLength = 80; }
+ cy.layout(opts).run();
+ }
+
+ // ── View toggle ──────────────────────────────────────────────────
+ function switchView(next) {
+ if (next === currentView) return;
+ currentView = next;
+ clearHighlights();
+ closeSidebar();
+
+ cy.elements().remove();
+ if (next === "files") cy.add([...FILE_NODES, ...FILE_EDGES]);
+ else cy.add([...SYMBOL_NODES, ...SYMBOL_EDGES]);
+
+ document.querySelectorAll(".view-toggle button").forEach((b) => b.classList.toggle("active", b.dataset.view === next));
+ runLayout(currentLayout);
+ }
+
+ // ── Highlighting ─────────────────────────────────────────────────
+ function clearHighlights() { cy.elements().removeClass("faded highlight highlight-flow highlight-edge highlight-flow-edge"); }
+
+ function bfsHighlight(rootId, direction) {
+ clearHighlights();
+ const root = cy.getElementById(rootId);
+ if (root.empty()) return;
+ const visited = new Set([rootId]);
+ const queue = [rootId];
+ const edges = [];
+ while (queue.length) {
+ const id = queue.shift();
+ const neighbours = direction === "reverse" ? cy.getElementById(id).incomers() : cy.getElementById(id).outgoers();
+ neighbours.edges().forEach((e) => edges.push(e.id()));
+ neighbours.nodes().forEach((n) => { if (!visited.has(n.id())) { visited.add(n.id()); queue.push(n.id()); } });
+ }
+ cy.elements().addClass("faded");
+ const nodeClass = direction === "reverse" ? "highlight" : "highlight-flow";
+ const edgeClass = direction === "reverse" ? "highlight-edge" : "highlight-flow-edge";
+ visited.forEach((id) => cy.getElementById(id).removeClass("faded").addClass(nodeClass));
+ edges.forEach((id) => cy.getElementById(id).removeClass("faded").addClass(edgeClass));
+ }
+ const highlightImpact = (id) => bfsHighlight(id, "reverse");
+ const highlightFlow = (id) => bfsHighlight(id, "forward");
+
+ // ── Sidebar (safe DOM builders — no innerHTML) ───────────────────
+ const sidebar = document.getElementById("sidebar");
+
+ function clearSidebar() { while (sidebar.firstChild) sidebar.removeChild(sidebar.firstChild); }
+
+ function closeSidebar() {
+ clearSidebar();
+ sidebar.className = "empty";
+ sidebar.appendChild(document.createTextNode("Click a node to see details"));
+ }
+
+ function actionBar(nodeId) {
+ return h("div", { class: "actions" },
+ h("button", { "data-action": "impact", "data-id": nodeId }, "Blast radius"),
+ h("button", { class: "flow", "data-action": "flow", "data-id": nodeId }, "Call flow"),
+ h("button", { class: "reset", "data-action": "reset" }, "Clear"),
+ );
+ }
+
+ function metaRow(label, value) {
+ return h("div", { class: "meta" }, h("strong", null, `${label}: `), String(value));
+ }
+
+ function openFile(id) {
+ const file = DATA.files.find((f) => f.id === id);
+ if (!file) return closeSidebar();
+ const color = colourFor(file.language);
+ const syms = (DATA.symbolsByFile && DATA.symbolsByFile[id]) || [];
+ const preview = syms.slice(0, 30);
+
+ clearSidebar();
+ sidebar.className = "";
+ sidebar.appendChild(h("h2", null, file.label));
+ sidebar.appendChild(h("div", { style: "font-size:11px;color:#6b7280;margin-bottom:8px;word-break:break-all;" }, file.id));
+ sidebar.appendChild(h("span", { class: "lang-badge", style: `background:${color}` }, file.language));
+
+ const connections = h("div", { class: "section" },
+ h("h3", null, "Connections"),
+ h("div", { class: "meta" },
+ "imports: ", h("strong", null, String(file.deps)),
+ " · imported by: ", h("strong", null, String(file.dependents)),
+ " · symbols: ", h("strong", null, String(file.symbolCount || 0)),
+ ),
+ );
+ sidebar.appendChild(connections);
+
+ if (syms.length > 0) {
+ const section = h("div", { class: "section" },
+ h("h3", null, `Symbols (${syms.length})`),
+ );
+ const ul = h("ul", null);
+ for (const s of preview) {
+ const li = h("li", { "data-symbol-id": s.id, title: `${s.qualifiedName}:${s.line}` },
+ h("span", { style: `color:${KIND_COLORS[s.kind] || "#64748b"};font-weight:600;` }, s.kind),
+ " ",
+ s.name,
+ h("span", { style: "color:#94a3b8" }, `:${s.line}`),
+ );
+ ul.appendChild(li);
+ }
+ section.appendChild(ul);
+ if (syms.length > preview.length) {
+ section.appendChild(h("div", { style: "color:#9ca3af;font-size:11px;margin-top:4px" },
+ `+ ${syms.length - preview.length} more — use codebase_symbols to list all`));
+ }
+ sidebar.appendChild(section);
+ }
+
+ sidebar.appendChild(actionBar(`f::${file.id}`));
+ }
+
+ function openSymbol(id) {
+ const sym = (DATA.symbols || []).find((s) => s.id === id);
+ if (!sym) return closeSidebar();
+ clearSidebar();
+ sidebar.className = "";
+ sidebar.appendChild(h("h2", null, sym.name));
+ sidebar.appendChild(h("span", { class: "kind-badge" }, sym.kind));
+ sidebar.appendChild(metaRow("Qualified", sym.qualifiedName));
+ sidebar.appendChild(h("div", { class: "meta" }, h("strong", null, "File: "), h("code", null, sym.file)));
+ sidebar.appendChild(metaRow("Line", sym.line));
+ sidebar.appendChild(actionBar(`s::${sym.id}`));
+ }
+
+ // ── Event wiring ─────────────────────────────────────────────────
+ cy.on("tap", "node", (evt) => {
+ const n = evt.target;
+ if (n.data("nodeType") === "file") openFile(n.data("file"));
+ else openSymbol(n.id().slice(3));
+ });
+ cy.on("tap", (evt) => { if (evt.target === cy) { closeSidebar(); clearHighlights(); } });
+
+ sidebar.addEventListener("click", (evt) => {
+ const btn = evt.target.closest("button[data-action]");
+ if (btn) {
+ const action = btn.dataset.action;
+ if (action === "impact") highlightImpact(btn.dataset.id);
+ else if (action === "flow") highlightFlow(btn.dataset.id);
+ else if (action === "reset") clearHighlights();
+ return;
+ }
+ const li = evt.target.closest("li[data-symbol-id]");
+ if (li && currentView === "symbols") {
+ const cyNode = cy.getElementById(`s::${li.dataset.symbolId}`);
+ if (!cyNode.empty()) cy.animate({ center: { eles: cyNode }, zoom: 1.3 }, { duration: 300 });
+ }
+ });
+
+ // ── Toolbar wiring ───────────────────────────────────────────────
+ document.getElementById("layout").addEventListener("change", (e) => runLayout(e.target.value));
+ document.querySelectorAll(".view-toggle button").forEach((b) => b.addEventListener("click", () => switchView(b.dataset.view)));
+ document.getElementById("fit").addEventListener("click", () => cy.fit(undefined, 30));
+ document.getElementById("reset").addEventListener("click", () => { clearHighlights(); closeSidebar(); cy.fit(undefined, 30); });
+ document.getElementById("export").addEventListener("click", () => {
+ const png = cy.png({ full: true, scale: 2, bg: "#f8fafc" });
+ const a = document.createElement("a");
+ // Sanitise the project name for cross-platform filesystem safety:
+ // strip characters forbidden on Windows (<>:"/\\|?*), control chars,
+ // collapse whitespace, cap length, and fall back to "graph" if empty.
+ const rawName = String(DATA.project.name || "graph");
+ const safeName = rawName.replace(/[<>:"/\\|?*\x00-\x1f]/g, "_").trim().slice(0, 120) || "graph";
+ a.href = png; a.download = `${safeName}.png`; a.click();
+ });
+
+ // ── Live search ──────────────────────────────────────────────────
+ document.getElementById("search").addEventListener("input", (e) => {
+ const q = e.target.value.trim().toLowerCase();
+ clearHighlights();
+ if (!q) return;
+ const matches = cy.nodes().filter((n) => {
+ const label = (n.data("label") || "").toLowerCase();
+ const file = (n.data("file") || "").toLowerCase();
+ const qn = (n.data("qualifiedName") || "").toLowerCase();
+ return label.includes(q) || file.includes(q) || qn.includes(q);
+ });
+ if (matches.length === 0) return;
+ cy.elements().addClass("faded");
+ matches.removeClass("faded").addClass("highlight");
+ if (matches.length <= 20) cy.animate({ fit: { eles: matches, padding: 80 } }, { duration: 300 });
+ });
+
+ // ── Tooltip on hover ─────────────────────────────────────────────
+ const tooltip = document.getElementById("tooltip");
+ cy.on("mouseover", "node", (evt) => {
+ const n = evt.target;
+ const pos = evt.renderedPosition || n.renderedPosition();
+ tooltip.textContent = n.data("nodeType") === "file"
+ ? `${n.data("file")} — ${n.data("language")}`
+ : `${n.data("qualifiedName")} — ${n.data("kind")} @ ${n.data("file")}:${n.data("line")}`;
+ tooltip.style.left = `${pos.x + 14}px`;
+ tooltip.style.top = `${pos.y + 14}px`;
+ tooltip.style.opacity = "1";
+ });
+ cy.on("mouseout", "node", () => { tooltip.style.opacity = "0"; });
+
+ // Right-click node → blast radius
+ cy.on("cxttap", "node", (evt) => highlightImpact(evt.target.id()));
+
+ // ── Symbols-unavailable banner ───────────────────────────────────
+ const banner = document.getElementById("banner");
+ if (DATA.symbolMode !== "full") {
+ banner.classList.add("visible");
+ banner.textContent = DATA.symbolMode === "omitted"
+ ? `Symbol view disabled: ${DATA.symbolOmitReason || "no symbol graph available"}. Run codebase_graph_build first.`
+ : `Symbol view partial (${DATA.symbolOmitReason}). Use codebase_symbols / codebase_impact for full detail.`;
+ if (DATA.symbolMode === "omitted") {
+ document.querySelectorAll('.view-toggle button[data-view="symbols"]').forEach((b) => { b.disabled = true; b.title = "No symbol graph available"; });
+ }
+ }
+
+ // ── Initial layout + sidebar ─────────────────────────────────────
+ runLayout(currentLayout);
+ closeSidebar();
+})();
diff --git a/src/assets/viewer-styles.css b/src/assets/viewer-styles.css
new file mode 100644
index 0000000..dff0677
--- /dev/null
+++ b/src/assets/viewer-styles.css
@@ -0,0 +1,91 @@
+/* SocratiCode interactive graph viewer — styles */
+* { box-sizing: border-box; margin: 0; padding: 0; }
+html, body { height: 100%; width: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #1f2937; overflow: hidden; }
+body { display: flex; flex-direction: column; }
+
+/* ── top bar ─────────────────────────────────────────────────────── */
+header {
+ display: flex; align-items: center; gap: 12px;
+ padding: 10px 16px; background: #0f172a; color: #e2e8f0;
+ border-bottom: 1px solid #1e293b; flex-shrink: 0;
+}
+header h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
+header h1 .proj { color: #fbbf24; }
+header .stats { font-size: 12px; color: #94a3b8; margin-left: 4px; }
+header .sep { width: 1px; height: 18px; background: #334155; }
+header .spacer { flex: 1; }
+
+.toolbar { display: flex; gap: 6px; align-items: center; }
+.toolbar label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
+.toolbar select, .toolbar input, .toolbar button {
+ background: #1e293b; color: #e2e8f0; border: 1px solid #334155;
+ padding: 5px 10px; border-radius: 4px; font-size: 12px; font-family: inherit;
+ outline: none;
+}
+.toolbar select:hover, .toolbar button:hover { background: #334155; cursor: pointer; }
+.toolbar select:focus, .toolbar input:focus { border-color: #60a5fa; }
+.toolbar input { width: 200px; }
+.toolbar button.primary { background: #2563eb; border-color: #2563eb; }
+.toolbar button.primary:hover { background: #1d4ed8; }
+.toolbar button:disabled { opacity: 0.4; cursor: not-allowed; }
+
+.view-toggle { display: inline-flex; border: 1px solid #334155; border-radius: 4px; overflow: hidden; }
+.view-toggle button { border: none; border-radius: 0; padding: 5px 10px; }
+.view-toggle button.active { background: #2563eb; color: #fff; }
+
+/* ── main area ───────────────────────────────────────────────────── */
+main { flex: 1; display: flex; min-height: 0; position: relative; }
+#cy { flex: 1; background: #f8fafc; min-width: 0; }
+
+#sidebar {
+ width: 340px; background: #fff; border-left: 1px solid #e5e7eb;
+ padding: 16px; overflow-y: auto; flex-shrink: 0;
+ font-size: 13px; line-height: 1.5;
+}
+#sidebar.empty { color: #94a3b8; font-style: italic; text-align: center; padding-top: 80px; }
+#sidebar h2 { font-size: 14px; font-weight: 600; margin-bottom: 4px; word-break: break-all; }
+#sidebar .kind-badge {
+ display: inline-block; padding: 2px 8px; border-radius: 10px;
+ font-size: 11px; font-weight: 500; margin-bottom: 8px;
+ background: #e0e7ff; color: #3730a3;
+}
+#sidebar .lang-badge {
+ display: inline-block; padding: 2px 8px; border-radius: 10px;
+ font-size: 11px; font-weight: 500; margin-bottom: 8px; color: #fff;
+}
+#sidebar .meta { color: #6b7280; font-size: 12px; margin-bottom: 12px; }
+#sidebar .meta strong { color: #1f2937; }
+#sidebar .section { margin-top: 14px; }
+#sidebar .section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; margin-bottom: 6px; }
+#sidebar ul { list-style: none; }
+#sidebar li { padding: 4px 8px; border-radius: 3px; cursor: pointer; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; color: #334155; }
+#sidebar li:hover { background: #f1f5f9; color: #0f172a; }
+#sidebar .actions { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
+#sidebar .actions button {
+ background: #fee2e2; color: #991b1b; border: 1px solid #fecaca;
+ padding: 5px 10px; border-radius: 4px; font-size: 12px; font-family: inherit; cursor: pointer;
+}
+#sidebar .actions button:hover { background: #fecaca; }
+#sidebar .actions button.flow { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
+#sidebar .actions button.flow:hover { background: #bfdbfe; }
+#sidebar .actions button.reset { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }
+#sidebar .actions button.reset:hover { background: #e5e7eb; }
+#sidebar .actions button.truncated-note { background: transparent; border: none; color: #9ca3af; font-size: 11px; cursor: default; padding: 5px 0; }
+
+/* ── banner (symbol-mode not available) ─────────────────────────── */
+#banner {
+ position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
+ background: #fef3c7; color: #92400e; border: 1px solid #fde68a;
+ padding: 8px 14px; border-radius: 6px; font-size: 12px;
+ box-shadow: 0 4px 12px rgba(0,0,0,0.08); z-index: 10;
+ display: none;
+}
+#banner.visible { display: block; }
+
+/* ── hover tooltip ──────────────────────────────────────────────── */
+#tooltip {
+ position: absolute; background: #1f2937; color: #f9fafb;
+ padding: 6px 10px; border-radius: 4px; font-size: 12px;
+ pointer-events: none; opacity: 0; transition: opacity 0.1s;
+ max-width: 300px; word-break: break-all; z-index: 20;
+}
diff --git a/src/assets/viewer-template.html b/src/assets/viewer-template.html
new file mode 100644
index 0000000..2a2c243
--- /dev/null
+++ b/src/assets/viewer-template.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+{{TITLE}}
+
+
+
+
+ SocratiCode {{PROJECT_NAME}} {{STATS}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/index.ts b/src/index.ts
index 8d40b23..ebfdb90 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -232,12 +232,24 @@ server.tool(
server.tool(
"codebase_graph_visualize",
- "Generate a visual Mermaid diagram of the code dependency graph, color-coded by language with circular dependencies highlighted.",
+ [
+ "Visualise the code dependency graph. Two modes:",
+ " • mode=\"mermaid\" (default) — returns a Mermaid diagram (text) colour-coded by language, circular deps highlighted. Best for inline rendering inside chat, GitHub, or editors that render Mermaid.",
+ " • mode=\"interactive\" — writes a self-contained HTML page (vendored Cytoscape.js + Dagre, works offline) and opens it in the user's default browser. Shows the file graph and, when a symbol graph is available and fits, a Symbols toggle with the symbol-level call graph. Interactions: click node for sidebar with imports/dependents/symbols list; right-click node to highlight its blast radius (reverse-transitive closure); live search; layout switcher (Dagre / force / concentric / breadth-first / grid / circle); PNG export. Use this when the user asks for a visual/interactive view, wants to explore visually, or needs a shareable diagram.",
+ ].join("\n"),
{
projectPath: z
.string()
.describe("Absolute path to the project directory.")
.optional(),
+ mode: z
+ .enum(["mermaid", "interactive"])
+ .describe("\"mermaid\" (default — text diagram) or \"interactive\" (browser-based explorer).")
+ .optional(),
+ open: z
+ .boolean()
+ .describe("In interactive mode, whether to auto-open the browser. Default true. Set false to just get the file path (useful in headless environments).")
+ .optional(),
},
async (args) => ({
content: [{ type: "text", text: await handleGraphTool("codebase_graph_visualize", args) }],
diff --git a/src/services/graph-visualize-browser.ts b/src/services/graph-visualize-browser.ts
new file mode 100644
index 0000000..041a0fb
--- /dev/null
+++ b/src/services/graph-visualize-browser.ts
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
+
+/**
+ * Cross-platform helpers for the interactive graph viewer:
+ * 1. Write a generated HTML document to a stable path inside the OS
+ * temp directory (one file per project, deterministic by projectId).
+ * 2. Open that path in the user's default browser using the `open`
+ * package — handles macOS (`open`), Linux (`xdg-open`), and
+ * Windows (`start`) with zero external deps.
+ *
+ * `open` is called with `wait: false` so the call returns immediately;
+ * on headless Linux systems where no browser is registered the function
+ * swallows the error and lets the caller surface the path instead.
+ */
+
+import fs from "node:fs/promises";
+import os from "node:os";
+import path from "node:path";
+import open from "open";
+import { logger } from "./logger.js";
+
+/** Write HTML to a deterministic file under the OS temp dir. */
+export async function writeInteractiveGraphFile(
+ projectId: string,
+ html: string,
+): Promise {
+ const dir = path.join(os.tmpdir(), "socraticode-graph");
+ await fs.mkdir(dir, { recursive: true });
+ const file = path.join(dir, `${projectId}.html`);
+ await fs.writeFile(file, html, "utf-8");
+ logger.info("Wrote interactive graph HTML", { file, bytes: html.length });
+ return file;
+}
+
+/** Open the given file path in the user's default browser (best-effort). */
+export async function openInBrowser(filePath: string): Promise<{ opened: boolean; error?: string }> {
+ try {
+ await open(filePath, { wait: false });
+ return { opened: true };
+ } catch (err) {
+ const message = err instanceof Error ? err.message : String(err);
+ logger.warn("Failed to open browser — user can open manually", { filePath, error: message });
+ return { opened: false, error: message };
+ }
+}
diff --git a/src/services/graph-visualize-html.ts b/src/services/graph-visualize-html.ts
new file mode 100644
index 0000000..6356c79
--- /dev/null
+++ b/src/services/graph-visualize-html.ts
@@ -0,0 +1,315 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
+
+/**
+ * Interactive HTML graph visualiser.
+ *
+ * Builds a single self-contained HTML file that renders the project's
+ * file-import graph (and, when available, the symbol-level call graph)
+ * using a vendored Cytoscape.js + Dagre layout, so the file works offline
+ * without any CDN access.
+ *
+ * The generated page contains:
+ * - The file-import graph as the primary view (always available).
+ * - A "Symbols" toggle that switches to the symbol-level call graph,
+ * available when the symbol graph fits within the embed caps.
+ * - Per-file symbol lists in the sidebar (names, kinds, line numbers).
+ * - Blast-radius and call-flow overlays (click or right-click a node).
+ * - Live search across files and symbols, six layouts, PNG export.
+ *
+ * Scale caps (to keep the HTML payload bounded for gigantic repos):
+ * - Symbol graph embedded only if `symbolCount <= MAX_SYMBOLS` and
+ * `edgeCount <= MAX_EDGES`. Above either cap the symbol toggle is
+ * disabled and a banner explains why; the file view still works.
+ * - Per-file symbol list always embedded (capped at `MAX_SYMS_PER_FILE`
+ * per file — the sidebar shows the first N and a "use codebase_symbols
+ * for full list" note).
+ */
+
+import fs from "node:fs/promises";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import { getLanguageFromExtension } from "../constants.js";
+import type { CodeGraph } from "../types.js";
+import { findCircularDependencies } from "./graph-analysis.js";
+import { logger } from "./logger.js";
+import { loadFilePayload, loadSymbolGraphMeta } from "./symbol-graph-store.js";
+
+// ── Assets locator ────────────────────────────────────────────────────
+// Works in dev (tsx, src/) and prod (node, dist/): assets sit alongside
+// the services directory in both layouts thanks to `scripts/copy-assets.mjs`.
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const ASSETS_DIR = path.join(__dirname, "..", "assets");
+
+// ── Caps ──────────────────────────────────────────────────────────────
+const MAX_SYMBOLS = 20_000; // total symbols embedded in the Symbols view
+const MAX_EDGES = 60_000; // total call edges embedded in the Symbols view
+const MAX_SYMS_PER_FILE = 200; // per-file list shown in the sidebar
+const PARALLEL_LOAD_BATCH = 20; // Qdrant payload fetches in parallel
+
+// ── Data contract (matches viewer-app.js) ─────────────────────────────
+export interface VizFile {
+ id: string; // relative path
+ label: string; // basename
+ language: string;
+ deps: number;
+ dependents: number;
+ symbolCount: number; // full count, even if list was truncated
+}
+
+export interface VizFileEdge {
+ source: string;
+ target: string;
+ type: "import" | "re-export" | "dynamic-import";
+ cyclic: boolean;
+}
+
+export interface VizSymbol {
+ id: string;
+ file: string;
+ name: string;
+ qualifiedName: string;
+ kind: string;
+ line: number;
+}
+
+export interface VizSymbolEdge {
+ source: string; // symbol id
+ target: string; // symbol id (first candidate)
+ confidence: "unique" | "multiple-candidates" | "local" | "unresolved";
+}
+
+export interface VizData {
+ project: { name: string; files: number; edges: number; symbols: number | null; callEdges: number | null; builtAt: string | null };
+ files: VizFile[];
+ fileEdges: VizFileEdge[];
+ symbols: VizSymbol[];
+ symbolEdges: VizSymbolEdge[];
+ /** Per-file symbol list for the sidebar; capped to MAX_SYMS_PER_FILE */
+ symbolsByFile: Record;
+ symbolMode: "full" | "omitted" | "capped";
+ symbolOmitReason?: string;
+}
+
+// ── Cached assets (read once per process) ─────────────────────────────
+let _assetCache: { cytoscape: string; dagre: string; cytoscapeDagre: string; styles: string; app: string; template: string } | null = null;
+
+async function loadAssets(): Promise> {
+ if (_assetCache) return _assetCache;
+ const [cytoscape, dagre, cytoscapeDagre, styles, app, template] = await Promise.all([
+ fs.readFile(path.join(ASSETS_DIR, "cytoscape.min.js"), "utf-8"),
+ fs.readFile(path.join(ASSETS_DIR, "dagre.min.js"), "utf-8"),
+ fs.readFile(path.join(ASSETS_DIR, "cytoscape-dagre.js"), "utf-8"),
+ fs.readFile(path.join(ASSETS_DIR, "viewer-styles.css"), "utf-8"),
+ fs.readFile(path.join(ASSETS_DIR, "viewer-app.js"), "utf-8"),
+ fs.readFile(path.join(ASSETS_DIR, "viewer-template.html"), "utf-8"),
+ ]);
+ _assetCache = { cytoscape, dagre, cytoscapeDagre, styles, app, template };
+ return _assetCache;
+}
+
+/** Reset the asset cache (for tests / hot-reload). */
+export function resetVisualizeAssetCache(): void {
+ _assetCache = null;
+}
+
+// ── Symbol-data loader ────────────────────────────────────────────────
+interface SymbolLoadResult {
+ mode: "full" | "omitted" | "capped";
+ reason?: string;
+ symbols: VizSymbol[];
+ symbolEdges: VizSymbolEdge[];
+ symbolsByFile: Record;
+ perFileCount: Record;
+ symbolCount: number | null;
+ edgeCount: number | null;
+ builtAt: number | null;
+}
+
+async function loadSymbolDataForViz(
+ projectId: string,
+ fileGraph: CodeGraph,
+): Promise {
+ const meta = await loadSymbolGraphMeta(projectId).catch(() => null);
+ if (!meta) {
+ return { mode: "omitted", reason: "no symbol graph meta", symbols: [], symbolEdges: [], symbolsByFile: {}, perFileCount: {}, symbolCount: null, edgeCount: null, builtAt: null };
+ }
+
+ const exceedsSymbols = meta.symbolCount > MAX_SYMBOLS;
+ const exceedsEdges = meta.edgeCount > MAX_EDGES;
+
+ const symbols: VizSymbol[] = [];
+ const symbolEdges: VizSymbolEdge[] = [];
+ const symbolsByFile: Record = {};
+ const perFileCount: Record = {};
+
+ // Load per-file payloads in bounded parallel batches.
+ for (let i = 0; i < fileGraph.nodes.length; i += PARALLEL_LOAD_BATCH) {
+ const batch = fileGraph.nodes.slice(i, i + PARALLEL_LOAD_BATCH);
+ const payloads = await Promise.all(
+ batch.map((n) => loadFilePayload(projectId, n.relativePath).catch(() => null)),
+ );
+ for (const payload of payloads) {
+ if (!payload) continue;
+ perFileCount[payload.file] = payload.symbols.length;
+
+ const vizSymbols = payload.symbols.slice(0, MAX_SYMS_PER_FILE).map((s) => ({
+ id: s.id, file: payload.file, name: s.name, qualifiedName: s.qualifiedName, kind: s.kind, line: s.line,
+ }));
+ symbolsByFile[payload.file] = vizSymbols;
+
+ if (!exceedsSymbols) {
+ // Embed all symbols from the file into the top-level list (no cap there)
+ for (const s of payload.symbols) {
+ symbols.push({ id: s.id, file: payload.file, name: s.name, qualifiedName: s.qualifiedName, kind: s.kind, line: s.line });
+ }
+ }
+ if (!exceedsEdges) {
+ for (const e of payload.outgoingCalls) {
+ const target = e.calleeCandidates[0];
+ if (!target) continue;
+ symbolEdges.push({ source: e.callerId, target, confidence: e.confidence });
+ }
+ }
+ }
+ }
+
+ if (exceedsSymbols || exceedsEdges) {
+ const parts: string[] = [];
+ if (exceedsSymbols) parts.push(`${meta.symbolCount.toLocaleString()} symbols > ${MAX_SYMBOLS.toLocaleString()} cap`);
+ if (exceedsEdges) parts.push(`${meta.edgeCount.toLocaleString()} call edges > ${MAX_EDGES.toLocaleString()} cap`);
+ return {
+ mode: "capped",
+ reason: parts.join(", "),
+ symbols: [], symbolEdges: [], symbolsByFile, perFileCount,
+ symbolCount: meta.symbolCount, edgeCount: meta.edgeCount, builtAt: meta.builtAt,
+ };
+ }
+
+ return {
+ mode: "full",
+ symbols, symbolEdges, symbolsByFile, perFileCount,
+ symbolCount: meta.symbolCount, edgeCount: meta.edgeCount, builtAt: meta.builtAt,
+ };
+}
+
+// ── File-graph → viz data ─────────────────────────────────────────────
+function buildFileVizData(graph: CodeGraph): { files: VizFile[]; fileEdges: VizFileEdge[] } {
+ // Circular-dependency edge set for highlighting
+ const cyclicEdgeKeys = new Set();
+ const cycles = findCircularDependencies(graph);
+ for (const cycle of cycles) {
+ for (let i = 0; i < cycle.length - 1; i++) cyclicEdgeKeys.add(`${cycle[i]}->${cycle[i + 1]}`);
+ }
+
+ const files: VizFile[] = graph.nodes.map((n) => ({
+ id: n.relativePath,
+ label: path.basename(n.relativePath),
+ language: getLanguageFromExtension(path.extname(n.relativePath).toLowerCase()),
+ deps: n.dependencies.length,
+ dependents: n.dependents.length,
+ symbolCount: 0,
+ }));
+
+ // Dedupe edges (graph edges may repeat on multi-import files)
+ const seen = new Set();
+ const fileEdges: VizFileEdge[] = [];
+ for (const e of graph.edges) {
+ const key = `${e.source}->${e.target}`;
+ if (seen.has(key)) continue;
+ seen.add(key);
+ fileEdges.push({ source: e.source, target: e.target, type: e.type, cyclic: cyclicEdgeKeys.has(key) });
+ }
+ return { files, fileEdges };
+}
+
+// ── HTML escapers ─────────────────────────────────────────────────────
+/** Escape text for safe interpolation into HTML text content / attrs. */
+function escapeHtml(s: string): string {
+ return s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c] as string);
+}
+
+/**
+ * Serialize data for embedding inside a ` anywhere inside the payload.
+ */
+function toEmbeddedJson(data: unknown): string {
+ return JSON.stringify(data).replace(/