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AqB,iBAAiB,SAAS,SAAS,GACvD,EAAG,iBACH,EAAG,kBACH,EAAmB,EAAG,OAAO,WAC9B,IAGA,EAAqB,iBAAiB,WAAW,SAAS,GACzD,IAAI,EAAkB,EAAG,OAAO,WAEhC,OAAQ,EAAG,SACV,KAAK,EAEJ,EAAmB,GACnB,MACD,KAAK,EACL,KAAK,EAEG,EAAgB,UAAU,SAAS,SAKpC,EAAG,UAAY,EAEa,IAA3B,IACJ,GAAkD,GAI9C,EAAyB,IAC7B,GAAkD,GAGpD,EAAmB,SAAQ,SAAS,EAAQ,GACtC,IAAU,EACd,EAAO,UAAU,IAAI,eAErB,EAAO,UAAU,OAAO,cAE1B,KApBA,EAAmB,GAsBpB,EAAG,iBACH,EAAG,kBACH,MAED,KAAK,EACJ,IAAI,EAAoB,EAAqB,WAAW,iBAAiB,cAAc,GACtF,EAAW,EAAkB,QAAQ,MACrC,EAAW,EAAkB,YAE9B,EAAoB,EAAU,GAC9B,EAAG,iBACH,EAAG,kBAGN,IAGA,EAAM,QAAQ,iBAAiB,SAAS,SAAS,IAhO/B,SAAS,EAAS,EAAU,GAC9C,IAAI,EAAS,EAAQ,WACrB,GAAK,GAAe,EAAQ,QAAQ,GACnC,OAAO,EAIR,KAAQ,GAAU,EAAO,UAAgC,IAApB,EAAO,UAAiB,CAC5D,GAAK,EAAO,QAAQ,GACnB,OAAO,EAER,EAAS,EAAO,UACjB,CACA,OAAO,CACR,EAoNS,CAAa,EAAG,OAAQ,iBAAiB,IAC/C,GAEF,GAED,CAGD","file":"/npm/@szelep/styleselect@1.0.4/js/styleselect.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@szelep/styleselect@1.0.4/js/styleselect.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// UMD module from From https://github.com/umdjs/umd/blob/master/returnExports.js\r\n// From 'if the module has no dependencies' example.\r\n(function (root, factory) {\r\n    if (typeof define === 'function' && define.amd) {\r\n        // AMD. Register as an anonymous module.\r\n        define([], factory);\r\n    } else if (typeof exports === 'object') {\r\n        // Node. Does not work with strict CommonJS, but\r\n        // only CommonJS-like environments that support module.exports,\r\n        // like Node.\r\n        module.exports = factory();\r\n    } else {\r\n        // Browser globals (root is window)\r\n        root.styleSelect  = factory();\r\n  }\r\n}(this, function () {\r\n// End of UMD module\r\n\r\n\t// Quick aliases and polyfills if needed\r\n\tvar query = document.querySelector.bind(document);\r\n\tvar queryAll = document.querySelectorAll.bind(document);\r\n\r\n\tvar KEYCODES = {\r\n\t\tSPACE: 32,\r\n\t\tUP: 38,\r\n\t\tDOWN: 40,\r\n\t\tENTER: 13\r\n\t};\r\n\r\n\tif ( ! NodeList.prototype.forEach ) {\r\n\t\tNodeList.prototype.forEach = Array.prototype.forEach;\r\n\t}\r\n\tif ( ! HTMLCollection.prototype.forEach ) {\r\n\t\tHTMLCollection.prototype.forEach = Array.prototype.forEach;\r\n\t}\r\n\tif ( ! Element.prototype.matches ) {\r\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/Element.matches\r\n\t\tElement.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector\r\n\t}\r\n\r\n\t// IE 9-11 CustomEvent polyfill\r\n\t// From https://developer.mozilla.org/en/docs/Web/API/CustomEvent\r\n\tvar CustomEvent = function( eventName, params ) {\r\n\t\tparams = params || { bubbles: false, cancelable: false, detail: undefined };\r\n\t\tvar event = document.createEvent( 'CustomEvent' );\r\n\t\tevent.initCustomEvent( eventName, params.bubbles, params.cancelable, params.detail );\r\n\t\treturn event;\r\n\t};\r\n\tCustomEvent.prototype = window.Event.prototype;\r\n\twindow.CustomEvent = CustomEvent;\r\n\r\n\t// IE10 dataset polyfill\r\n\t// From https://gist.githubusercontent.com/brettz9/4093766/raw/ba31a05e7ce21af67c6cafee9b3f439c86e95b01/html5-dataset.js\r\n\tif (!document.documentElement.dataset &&\r\n\t\t\t // FF is empty while IE gives empty object\r\n\t\t\t(!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset')  ||\r\n\t\t\t!Object.getOwnPropertyDescriptor(Element.prototype, 'dataset').get)\r\n\t\t) {\r\n\t\tvar propDescriptor = {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function () {\r\n\t\t\t\t'use strict';\r\n\t\t\t\tvar i,\r\n\t\t\t\t\tthat = this,\r\n\t\t\t\t\tHTML5_DOMStringMap,\r\n\t\t\t\t\tattrVal, attrName, propName,\r\n\t\t\t\t\tattribute,\r\n\t\t\t\t\tattributes = this.attributes,\r\n\t\t\t\t\tattsLength = attributes.length,\r\n\t\t\t\t\ttoUpperCase = function (n0) {\r\n\t\t\t\t\t\treturn n0.charAt(1).toUpperCase();\r\n\t\t\t\t\t},\r\n\t\t\t\t\tgetter = function () {\r\n\t\t\t\t\t\treturn this;\r\n\t\t\t\t\t},\r\n\t\t\t\t\tsetter = function (attrName, value) {\r\n\t\t\t\t\t\treturn (typeof value !== 'undefined') ?\r\n\t\t\t\t\t\t\tthis.setAttribute(attrName, value) :\r\n\t\t\t\t\t\t\tthis.removeAttribute(attrName);\r\n\t\t\t\t\t};\r\n\t\t\t\ttry { // Simulate DOMStringMap w/accessor support\r\n\t\t\t\t\t// Test setting accessor on normal object\r\n\t\t\t\t\t({}).__defineGetter__('test', function () {});\r\n\t\t\t\t\tHTML5_DOMStringMap = {};\r\n\t\t\t\t}\r\n\t\t\t\tcatch (e1) { // Use a DOM object for IE8\r\n\t\t\t\t\tHTML5_DOMStringMap = document.createElement('div');\r\n\t\t\t\t}\r\n\t\t\t\tfor (i = 0; i < attsLength; i++) {\r\n\t\t\t\t\tattribute = attributes[i];\r\n\t\t\t\t\t// Fix: This test really should allow any XML Name without\r\n\t\t\t\t\t//         colons (and non-uppercase for XHTML)\r\n\t\t\t\t\tif (attribute && attribute.name &&\r\n\t\t\t\t\t\t(/^data-\\w[\\w\\-]*$/).test(attribute.name)) {\r\n\t\t\t\t\t\tattrVal = attribute.value;\r\n\t\t\t\t\t\tattrName = attribute.name;\r\n\t\t\t\t\t\t// Change to CamelCase\r\n\t\t\t\t\t\tpropName = attrName.substr(5).replace(/-./g, toUpperCase);\r\n\t\t\t\t\t\ttry {\r\n\t\t\t\t\t\t\tObject.defineProperty(HTML5_DOMStringMap, propName, {\r\n\t\t\t\t\t\t\t\tenumerable: this.enumerable,\r\n\t\t\t\t\t\t\t\tget: getter.bind(attrVal || ''),\r\n\t\t\t\t\t\t\t\tset: setter.bind(that, attrName)\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcatch (e2) { // if accessors are not working\r\n\t\t\t\t\t\t\tHTML5_DOMStringMap[propName] = attrVal;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn HTML5_DOMStringMap;\r\n\t\t\t}\r\n\t\t};\r\n\t\ttry {\r\n\t\t\t// FF enumerates over element's dataset, but not\r\n\t\t\t//   Element.prototype.dataset; IE9 iterates over both\r\n\t\t\tObject.defineProperty(Element.prototype, 'dataset', propDescriptor);\r\n\t\t} catch (e) {\r\n\t\t\tpropDescriptor.enumerable = false; // IE8 does not allow setting to true\r\n\t\t\tObject.defineProperty(Element.prototype, 'dataset', propDescriptor);\r\n\t\t}\r\n\t}\r\n\r\n\t// Return true if any ancestor matches selector\r\n\t// Borrowed from ancestorMatches() from agave.js (MIT)\r\n\tvar isAncestorOf = function(element, selector, includeSelf) {\r\n\t\tvar parent = element.parentNode;\r\n\t\tif ( includeSelf && element.matches(selector) ) {\r\n\t\t\treturn true\r\n\t\t}\r\n\t\t// While parents are 'element' type nodes\r\n\t\t// See https://developer.mozilla.org/en-US/docs/DOM/Node.nodeType\r\n\t\twhile ( parent && parent.nodeType && parent.nodeType === 1 ) {\r\n\t\t\tif ( parent.matches(selector) ) {\r\n\t\t\t\treturn true\r\n\t\t\t}\r\n\t\t\tparent = parent.parentNode;\r\n\t\t}\r\n\t\treturn false;\r\n\t};\r\n\r\n\r\n\t// Used to match select boxes to their style select partners\r\n\tvar makeUUID = function(){\r\n\t\treturn 'ss-xxxx-xxxx-xxxx-xxxx-xxxx'.replace(/x/g, function (c) {\r\n\t\t\tvar r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;\r\n\t\t\treturn v.toString(16);\r\n\t\t})\r\n\t};\r\n\r\n\r\n\t// The 'styleSelect' main function\r\n\t// selector:String - CSS selector for the select box to style\r\n\treturn function(selector) {\r\n\t\t// Use native selects (which pop up large native UIs to go through the options ) on iOS/Android\r\n\t/*\tif ( navigator.userAgent.match( /iPad|iPhone|Android/i ) ) {\r\n\t\t\treturn\r\n\t\t}\r\n\t*/\r\n\t\tvar realSelect = typeof selector == 'object' ? selector : query(selector),\r\n\t\t\trealOptions = realSelect.children,\r\n\t\t\tselectedIndex = realSelect.selectedIndex,\r\n\t\t\tuuid = makeUUID(),\r\n\t\t\tstyleSelectHTML = '<div class=\"style-select\" aria-hidden=\"true\" data-ss-uuid=\"' + uuid + '\">';\r\n\r\n\t\t// The index of the item that's being highlighted by the mouse or keyboard\r\n\t\tvar highlightedOptionIndex;\r\n\t\tvar highlightedOptionIndexMax = realOptions.length - 1;\r\n\r\n\t\trealSelect.setAttribute('data-ss-uuid', uuid);\r\n\t\t// Even though the element is display: none, a11y users should still see it.\r\n\t\t// According to http://www.w3.org/TR/wai-aria/states_and_properties#aria-hidden\r\n\t\t// some browsers may have bugs with this but future implementation may improve\r\n\t\trealSelect.setAttribute('aria-hidden', \"false\");\r\n\r\n\t\t// Build styled clones of all the real options\r\n\t\tvar selectedOptionHTML;\r\n\t\tvar optionsHTML = '<div class=\"ss-dropdown\">';\r\n\t\trealOptions.forEach(function(realOption, index){\r\n\t\t\tvar text = realOption.textContent,\r\n\t\t\t\tvalue = realOption.getAttribute('value') || '',\r\n                cssClass = 'ss-option';\r\n\r\n\t\t\tif (index === selectedIndex) {\r\n\t\t\t\t// Mark first item as selected-option - this is where we store state for the styled select box\r\n\t\t\t\t// aria-hidden=true so screen readers ignore the styles selext box in favor of the real one (which is visible by default)\r\n\t\t\t\tselectedOptionHTML = '<div class=\"ss-selected-option\" tabindex=\"0\" data-value=\"' + value + '\">' + text + '</div>'\r\n\t\t\t}\r\n\r\n            if (realOption.disabled) {\r\n                cssClass += ' disabled';\r\n            }\r\n\r\n            // Continue building optionsHTML\r\n\t\t\toptionsHTML += '<div class=\"' + cssClass + '\" data-value=\"' + value + '\">' + text + '</div>';\r\n\t\t});\r\n\t\toptionsHTML += '</div>';\r\n\t\tstyleSelectHTML += selectedOptionHTML += optionsHTML += '</div>';\r\n\t\t// And add out styled select just after the real select\r\n\t\trealSelect.insertAdjacentHTML('afterend', styleSelectHTML);\r\n\r\n\t\tvar styledSelect = query('.style-select[data-ss-uuid=\"'+uuid+'\"]');\r\n\t\tvar styleSelectOptions = styledSelect.querySelectorAll('.ss-option');\r\n\t\tvar selectedOption = styledSelect.querySelector('.ss-selected-option');\r\n\r\n\t\tvar changeRealSelectBox = function(newValue, newLabel) {\r\n\t\t\t// Close styledSelect\r\n\t\t\tstyledSelect.classList.remove('open');\r\n\r\n\t\t\t// Update styled value\r\n\t\t\tselectedOption.textContent = newLabel;\r\n\t\t\tselectedOption.dataset.value = newValue;\r\n\r\n\t\t\t// Update the 'tick' that shows the option with the current value\r\n\t\t\tstyleSelectOptions.forEach(function(styleSelectOption){\r\n\t\t\t\tif ( styleSelectOption.dataset.value === newValue) {\r\n\t\t\t\t\tstyleSelectOption.classList.add('ticked')\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstyleSelectOption.classList.remove('ticked')\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Update real select box\r\n\t\t\trealSelect.value = newValue;\r\n\r\n\t\t\t// Send 'change' event to real select - to trigger any change event listeners\r\n\t\t\tvar changeEvent = new CustomEvent('change');\r\n\t\t\trealSelect.dispatchEvent(changeEvent);\r\n\t\t};\r\n\r\n\t\t// Change real select box when a styled option is clicked\r\n\t\tstyleSelectOptions.forEach(function(unused, index){\r\n\t\t\tvar styleSelectOption = styleSelectOptions.item(index);\r\n\r\n            if (styleSelectOption.className.match(/\\bdisabled\\b/)) {\r\n                return;\r\n            }\r\n\r\n            styleSelectOption.addEventListener('click', function(ev) {\r\n\t\t\t\tvar target = ev.target,\r\n\t\t\t\t\tstyledSelectBox = target.parentNode.parentNode,\r\n\t\t\t\t\tuuid = styledSelectBox.getAttribute('data-ss-uuid'),\r\n\t\t\t\t\tnewValue = target.getAttribute('data-value'),\r\n\t\t\t\t\tnewLabel = target.textContent;\r\n\r\n\t\t\t\tchangeRealSelectBox(newValue, newLabel)\r\n\r\n\t\t\t});\r\n\r\n\t\t\t// Tick and highlight the option that's currently in use\r\n\t\t\tif ( styleSelectOption.dataset.value === realSelect.value ) {\r\n\t\t\t\thighlightedOptionIndex = index;\r\n\t\t\t\tstyleSelectOption.classList.add('ticked');\r\n\t\t\t\tstyleSelectOption.classList.add('highlighted')\r\n\t\t\t}\r\n\r\n\t\t\t// Important: we can't use ':hover' as the keyboard and default value can also set the highlight\r\n\t\t\tstyleSelectOption.addEventListener('mouseover', function(ev){\r\n\t\t\t\tstyleSelectOption.parentNode.childNodes.forEach(function(sibling, index){\r\n\t\t\t\t\tif ( sibling === ev.target ) {\r\n\t\t\t\t\t\tsibling.classList.add('highlighted');\r\n\t\t\t\t\t\thighlightedOptionIndex = index;\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tsibling.classList.remove('highlighted')\r\n\t\t\t\t\t}\r\n\t\t\t\t})\r\n\t\t\t})\r\n\t\t});\r\n\r\n\r\n\r\n\t\tvar closeAllStyleSelects = function(exception){\r\n\t\t\tqueryAll('.style-select').forEach(function(styleSelectEl) {\r\n\t\t\t\tif ( styleSelectEl !== exception ) {\r\n\t\t\t\t\tstyleSelectEl.classList.remove('open');\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t};\r\n\r\n\t\tvar toggleStyledSelect = function(styledSelectBox){\r\n\t\t\tif ( ! styledSelectBox.classList.contains('open') ) {\r\n\t\t\t\t// If we're closed and about to open, close other style selects on the page\r\n\t\t\t\tcloseAllStyleSelects(styledSelectBox);\r\n\t\t\t}\r\n\t\t\t// Then toggle open/close\r\n\t\t\tstyledSelectBox.classList.toggle('open');\r\n\t\t};\r\n\r\n\t\t// When a styled select box is clicked\r\n\t\tvar styledSelectedOption = query('.style-select[data-ss-uuid=\"' + uuid + '\"] .ss-selected-option');\r\n\t\tstyledSelectedOption.addEventListener('click', function(ev) {\r\n\t\t\tev.preventDefault();\r\n\t\t\tev.stopPropagation();\r\n\t\t\ttoggleStyledSelect(ev.target.parentNode);\r\n\t\t});\r\n\r\n\t\t// Keyboard handling\r\n\t\tstyledSelectedOption.addEventListener('keydown', function(ev) {\r\n\t\t\tvar styledSelectBox = ev.target.parentNode;\r\n\r\n\t\t\tswitch (ev.keyCode) {\r\n\t\t\t\tcase KEYCODES.SPACE:\r\n\t\t\t\t\t// Space shows and hides styles select boxes\r\n\t\t\t\t\ttoggleStyledSelect(styledSelectBox);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase KEYCODES.DOWN:\r\n\t\t\t\tcase KEYCODES.UP:\r\n\t\t\t\t\t// Move the highlight up and down\r\n\t\t\t\t\tif ( ! styledSelectBox.classList.contains('open') ) {\r\n\t\t\t\t\t\t// If style select is not open, up/down should open it.\r\n\t\t\t\t\t\ttoggleStyledSelect(styledSelectBox);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// If style select is already open, these should change what the highlighted option is\r\n\t\t\t\t\t\tif ( ev.keyCode === KEYCODES.UP ) {\r\n\t\t\t\t\t\t\t// Up arrow moves earlier in list\r\n\t\t\t\t\t\t\tif ( highlightedOptionIndex !== 0 ) {\r\n\t\t\t\t\t\t\t\thighlightedOptionIndex = highlightedOptionIndex - 1\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t// Down arrow moves later in list\r\n\t\t\t\t\t\t\tif ( highlightedOptionIndex < highlightedOptionIndexMax ) {\r\n\t\t\t\t\t\t\t\thighlightedOptionIndex = highlightedOptionIndex + 1\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tstyleSelectOptions.forEach(function(option, index){\r\n\t\t\t\t\t\t\tif ( index === highlightedOptionIndex ) {\r\n\t\t\t\t\t\t\t\toption.classList.add('highlighted')\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\toption.classList.remove('highlighted')\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t}\r\n\t\t\t\t\tev.preventDefault();\r\n\t\t\t\t\tev.stopPropagation();\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t// User has picked an item from the keyboard\r\n\t\t\t\tcase KEYCODES.ENTER:\r\n\t\t\t\t\tvar highlightedOption = styledSelectedOption.parentNode.querySelectorAll('.ss-option')[highlightedOptionIndex],\r\n\t\t\t\t\t\tnewValue = highlightedOption.dataset.value,\r\n\t\t\t\t\t\tnewLabel = highlightedOption.textContent;\r\n\r\n\t\t\t\t\tchangeRealSelectBox(newValue, newLabel);\r\n\t\t\t\t\tev.preventDefault();\r\n\t\t\t\t\tev.stopPropagation();\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Clicking outside of the styled select box closes any open styled select boxes\r\n\t\tquery('body').addEventListener('click', function(ev){\r\n\r\n\t\t\tif ( ! isAncestorOf(ev.target, '.style-select', true) ) {\r\n\t\t\t\tcloseAllStyleSelects();\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t};\r\n\r\n// Close UMD module\r\n}));\r\n\r\n"]}