',a=a.firstChild,c.body.appendChild(a),b=d.width=a.offsetWidth-a.clientWidth,c.body.removeChild(a)),b},e=function(){var e,f,g,h,i,j,k;if(k=a("[data-group]",c.$dropdown_content),f=k.length,f&&c.$dropdown_content.width()){if(b.equalizeHeight){for(g=0,e=0;e1&&(i=j-h*(f-1),k.eq(f-1).css({width:i})))}};(b.equalizeHeight||b.equalizeWidth)&&(B.after(this,"positionDropdown",e),B.after(this,"refreshOptions",e))}),M.define("remove_button",function(b){b=a.extend({label:"×",title:"Remove",className:"remove",append:!0},b);var c=function(b,c){c.className="remove-single";var d=b,e=''+c.label+"",f=function(a,b){return a+b};b.setup=function(){var g=d.setup;return function(){if(c.append){var h=a(d.$input.context).attr("id"),i=(a("#"+h),d.settings.render.item);d.settings.render.item=function(a){return f(i.apply(b,arguments),e)}}g.apply(b,arguments),b.$control.on("click","."+c.className,function(a){a.preventDefault(),d.isLocked||d.clear()})}}()},d=function(b,c){var d=b,e=''+c.label+"",f=function(a,b){var c=a.search(/(<\/[^>]+>\s*)$/);return a.substring(0,c)+b+a.substring(c)};b.setup=function(){var g=d.setup;return function(){if(c.append){var h=d.settings.render.item;d.settings.render.item=function(a){return f(h.apply(b,arguments),e)}}g.apply(b,arguments),b.$control.on("click","."+c.className,function(b){if(b.preventDefault(),!d.isLocked){var c=a(b.currentTarget).parent();d.setActiveItem(c),d.deleteSelection()&&d.setCaret(d.items.length)}})}}()};return"single"===this.settings.mode?void c(this,b):void d(this,b)}),M.define("restore_on_backspace",function(a){var b=this;a.text=a.text||function(a){return a[this.settings.labelField]},this.onKeyDown=function(){var c=b.onKeyDown;return function(b){var d,e;return b.keyCode===p&&""===this.$control_input.val()&&!this.$activeItems.length&&(d=this.caretPos-1,d>=0&&d\": \">\",\n '\"': \""\",\n \"'\": \"'\",\n \"/\": \"/\"\n };\n\n return str.replace(/[&<>'\"\\/]/g, function(m) {\n return escaped[m];\n });\n}\n\nfunction randomId() {\n return Math.floor(0x100000000 + (Math.random() * 0xF00000000)).toString(16);\n}\n\nfunction strToBool(str) {\n if (!str || !str.toLowerCase)\n return undefined;\n\n switch(str.toLowerCase()) {\n case 'true':\n return true;\n case 'false':\n return false;\n default:\n return undefined;\n }\n}\n\n// A wrapper for getComputedStyle that is compatible with older browsers.\n// This is significantly faster than jQuery's .css() function.\nfunction getStyle(el, styleProp) {\n var x;\n if (el.currentStyle)\n x = el.currentStyle[styleProp];\n else if (window.getComputedStyle) {\n // getComputedStyle can return null when we're inside a hidden iframe on\n // Firefox; don't attempt to retrieve style props in this case.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=548397\n var style = document.defaultView.getComputedStyle(el, null);\n if (style)\n x = style.getPropertyValue(styleProp);\n }\n return x;\n}\n\n// Convert a number to a string with leading zeros\nfunction padZeros(n, digits) {\n var str = n.toString();\n while (str.length < digits)\n str = \"0\" + str;\n return str;\n}\n\n// Round to a specified number of significant digits.\nfunction roundSignif(x, digits = 1) {\n if (digits < 1)\n throw \"Significant digits must be at least 1.\";\n\n // This converts to a string and back to a number, which is inelegant, but\n // is less prone to FP rounding error than an alternate method which used\n // Math.round().\n return parseFloat(x.toPrecision(digits));\n}\n\n// Take a string with format \"YYYY-MM-DD\" and return a Date object.\n// IE8 and QTWebKit don't support YYYY-MM-DD, but they support YYYY/MM/DD\nfunction parseDate(dateString) {\n var date = new Date(dateString);\n if (isNaN(date))\n date = new Date(dateString.replace(/-/g, \"/\"));\n return date;\n}\n\n// Given a Date object, return a string in yyyy-mm-dd format, using the\n// UTC date. This may be a day off from the date in the local time zone.\nfunction formatDateUTC(date) {\n if (date instanceof Date) {\n return date.getUTCFullYear() + '-' +\n padZeros(date.getUTCMonth()+1, 2) + '-' +\n padZeros(date.getUTCDate(), 2);\n\n } else {\n return null;\n }\n}\n\n\n// Given an element and a function(width, height), returns a function(). When\n// the output function is called, it calls the input function with the offset\n// width and height of the input element--but only if the size of the element\n// is non-zero and the size is different than the last time the output\n// function was called.\n//\n// Basically we are trying to filter out extraneous calls to func, so that\n// when the window size changes or whatever, we don't run resize logic for\n// elements that haven't actually changed size or aren't visible anyway.\nfunction makeResizeFilter(el, func) {\n var lastSize = {};\n return function() {\n var size = { w: el.offsetWidth, h: el.offsetHeight };\n if (size.w === 0 && size.h === 0)\n return;\n if (size.w === lastSize.w && size.h === lastSize.h)\n return;\n lastSize = size;\n func(size.w, size.h);\n };\n}\n\nvar _BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder ||\n window.MozBlobBuilder || window.MSBlobBuilder;\n\nfunction makeBlob(parts) {\n\n // Browser compatibility is a mess right now. The code as written works in\n // a variety of modern browsers, but sadly gives a deprecation warning\n // message on the console in current versions (as of this writing) of\n // Chrome.\n\n // Safari 6.0 (8536.25) on Mac OS X 10.8.1:\n // Has Blob constructor but it doesn't work with ArrayBufferView args\n\n // Google Chrome 21.0.1180.81 on Xubuntu 12.04:\n // Has Blob constructor, accepts ArrayBufferView args, accepts ArrayBuffer\n // but with a deprecation warning message\n\n // Firefox 15.0 on Xubuntu 12.04:\n // Has Blob constructor, accepts both ArrayBuffer and ArrayBufferView args\n\n // Chromium 18.0.1025.168 (Developer Build 134367 Linux) on Xubuntu 12.04:\n // No Blob constructor. Has WebKitBlobBuilder.\n\n try {\n return new Blob(parts);\n }\n catch (e) {\n var blobBuilder = new _BlobBuilder();\n $.each(parts, function(i, part) {\n blobBuilder.append(part);\n });\n return blobBuilder.getBlob();\n }\n}\n\nfunction pixelRatio() {\n if (window.devicePixelRatio) {\n return window.devicePixelRatio;\n } else {\n return 1;\n }\n}\n\n// Takes a string expression and returns a function that takes an argument.\n//\n// When the function is executed, it will evaluate that expression using\n// \"with\" on the argument value, and return the result.\nfunction scopeExprToFunc(expr) {\n /*jshint evil: true */\n var expr_escaped = expr\n .replace(/[\\\\\"']/g, '\\\\$&')\n .replace(/\\u0000/g, '\\\\0')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n // \\b has a special meaning; need [\\b] to match backspace char.\n .replace(/[\\b]/g, '\\\\b');\n\n try {\n var func = new Function(\n `with (this) {\n try {\n return (${expr});\n } catch (e) {\n console.error('Error evaluating expression: ${expr_escaped}');\n throw e;\n }\n }`\n );\n } catch (e) {\n console.error(\"Error parsing expression: \" + expr);\n throw e;\n }\n\n\n return function(scope) {\n return func.call(scope);\n };\n}\n\nfunction asArray(value) {\n if (value === null || value === undefined)\n return [];\n if ($.isArray(value))\n return value;\n return [value];\n}\n\n// We need a stable sorting algorithm for ordering\n// bindings by priority and insertion order.\nfunction mergeSort(list, sortfunc) {\n function merge(sortfunc, a, b) {\n var ia = 0;\n var ib = 0;\n var sorted = [];\n while (ia < a.length && ib < b.length) {\n if (sortfunc(a[ia], b[ib]) <= 0) {\n sorted.push(a[ia++]);\n }\n else {\n sorted.push(b[ib++]);\n }\n }\n while (ia < a.length)\n sorted.push(a[ia++]);\n while (ib < b.length)\n sorted.push(b[ib++]);\n return sorted;\n }\n\n // Don't mutate list argument\n list = list.slice(0);\n\n for (var chunkSize = 1; chunkSize < list.length; chunkSize *= 2) {\n for (var i = 0; i < list.length; i += chunkSize * 2) {\n var listA = list.slice(i, i + chunkSize);\n var listB = list.slice(i + chunkSize, i + chunkSize * 2);\n var merged = merge(sortfunc, listA, listB);\n var args = [i, merged.length];\n Array.prototype.push.apply(args, merged);\n Array.prototype.splice.apply(list, args);\n }\n }\n\n return list;\n}\n\n// Escape jQuery selector metacharacters: !\"#$%&'()*+,./:;<=>?@[\\]^`{|}~\nvar $escape = exports.$escape = function(val) {\n return val.replace(/([!\"#$%&'()*+,.\\/:;<=>?@\\[\\\\\\]^`{|}~])/g, '\\\\$1');\n};\n\n// Maps a function over an object, preserving keys. Like the mapValues\n// function from lodash.\nfunction mapValues(obj, f) {\n const newObj = {};\n for (let key in obj) {\n if (obj.hasOwnProperty(key))\n newObj[key] = f(obj[key], key, obj);\n }\n return newObj;\n}\n\n// This is does the same as Number.isNaN, but that function unfortunately does\n// not exist in any version of IE.\nfunction isnan(x) {\n return typeof(x) === 'number' && isNaN(x);\n}\n\n// Binary equality function used by the equal function.\nfunction _equal(x, y) {\n if ($.type(x) === \"object\" && $.type(y) === \"object\") {\n if (Object.keys(x).length !== Object.keys(y).length) return false;\n for (let prop in x)\n if (!y.hasOwnProperty(prop) || !_equal(x[prop], y[prop]))\n return false;\n return true;\n } else if ($.type(x) === \"array\" && $.type(y) === \"array\") {\n if (x.length !== y.length) return false;\n for (let i = 0; i < x.length; i++)\n if (!_equal(x[i], y[i])) return false;\n return true;\n } else {\n return (x === y);\n }\n}\n\n// Structural or \"deep\" equality predicate. Tests two or more arguments for\n// equality, traversing arrays and objects (as determined by $.type) as\n// necessary.\n//\n// Objects other than objects and arrays are tested for equality using ===.\nfunction equal(...args) {\n if (args.length < 2) throw new Error(\"equal requires at least two arguments.\");\n for (let i = 0; i < args.length-1; i++) {\n if (!_equal(args[i], args[i+1]))\n return false;\n }\n return true;\n};\n\n// Compare version strings like \"1.0.1\", \"1.4-2\". `op` must be a string like\n// \"==\" or \"<\".\nexports.compareVersion = function(a, op, b) {\n function versionParts(ver) {\n return (ver + \"\")\n .replace(/-/, \".\")\n .replace(/(\\.0)+[^\\.]*$/, \"\")\n .split(\".\");\n }\n\n function cmpVersion(a, b) {\n a = versionParts(a);\n b = versionParts(b);\n var len = Math.min(a.length, b.length);\n var cmp;\n\n for(var i=0; i=\") return (diff >= 0);\n else if (op === \">\") return (diff > 0);\n else if (op === \"<=\") return (diff <= 0);\n else if (op === \"<\") return (diff < 0);\n else throw `Unknown operator: ${op}`;\n};\n\n\n// multimethod: Creates functions — \"multimethods\" — that are polymorphic on one\n// or more of their arguments.\n//\n// Multimethods can take any number of arguments. Arguments are passed to an\n// applicable function or \"method\", returning its result. By default, if no\n// method was applicable, an exception is thrown.\n//\n// Methods are searched in the order that they were added, and the first\n// applicable method found is the one used.\n//\n// A method is applicable when the \"dispatch value\" associated with it\n// corresponds to the value returned by the dispatch function. The dispatch\n// function defaults to the value of the first argument passed to the\n// multimethod.\n//\n// The correspondence between the value returned by the dispatch function and\n// any method's dispatch value is determined by the test function, which is\n// user-definable and defaults to `equal` or deep equality.\n//\n// # Chainable Functions\n//\n// The function returned by `multimethod()` exposes functions as properties.\n// These functions generally return the multimethod, and so can be chained.\n//\n// - dispatch([function newDispatch]): Sets the dispatch function. The dispatch\n// function can take any number of arguments, but must return a dispatch\n// value. The default dispatch function returns the first argument passed to\n// the multimethod.\n//\n// - test([function newTest]): Sets the test function. The test function takes\n// two arguments: the dispatch value produced by the dispatch function, and\n// the dispatch value associated with some method. It must return a boolean\n// indicating whether or not to select the method. The default test function\n// is `equal`.\n//\n// - when(object dispatchVal, function method): Adds a new dispatch value/method\n// combination.\n//\n// - whenAny(array