bwdefine("groupwheel",["lodash"],function(e){"use strict";function t(e){e=e.trim();var t=0,l=/(\-+)(.*)/g,r=l.exec(e);r&&(t=r[1].length,e=r[2].trim()),l=/^image:(.+)/g,r=l.exec(e);var n="text";return r&&(e=r[1],n="image"),{level:t,text:e,kind:n}}function l(l,r){var n=[],o=[r.getFirstWheel()],i=[0],a={0:{}},u=0,h=[0],v={};e.forEach(l.images,function(e){v[e.alias]=e.image}),e.forEach(l.group_slots,function(e,l){for(var s=t(e);o.length<s.level+1;){var g=r.createWheelElement();o.push(g),i.push(0)}"text"===s.kind?n.push(r.addTextSlotToWheel(o[s.level],s.text)):s.text in v?r.addImageSlotToWheel(o[s.level],v[s.text]):(r.reportConfigurationError("Widget configuration error: unknown image '"+s.text+"'"),n.push(r.addTextSlotToWheel(o[s.level],"image:"+s.text))),s.level in a||(a[s.level]={});for(;s.level+1>h.length;)h.push(-1);var f=h[s.level];a[s.level][f]||(a[s.level][f]=[]),a[s.level][f].push(i[s.level]),s.level>u+1&&r.reportConfigurationError("Widget configuration error: skipping wheels is not allowed. Line: "+s.text),u=s.level,h[s.level+1]=i[s.level]++});for(var s=1;s<o.length;++s)r.addTextSlotToWheel(o[s],"");r.adjustFontSizes(n);var g=e.map(o,function(e,t){return function(e,r){if(0===t&&"yes"===l.sequentialFirstWheel)return(r+1)%a[0][0].length;var n=a[t][e];if(n){var o=Math.floor(Math.random()*n.length);return n[o]}return i[t]}}),f=Array.apply(null,Array(o.length)).map(Number.prototype.valueOf,-1);return e.forEach(o,function(e,t){var l=r.finalizeWheel(e,i[t]);r.pushFinalizedWheel(l),l.setRandomize(function(){var e=g[t];return f[t]=e(t>0?f[t-1]:0,f[t]),f[t]})}),{numWheels:o.length,validIndicesPerLevel:a,nextValueFunctions:g}}return{processGroupWheelConfig:l,processGroupSlot:t}});