(function(k){LIModules.exports("WeightedQueue",function(b){function f(a,b){return a.weight-b.weight}function c(){d&&(a=a.sort(b.sort),d=!1)}var g=/LI_JS_DEBUG/.test(window.location.hash),h=!!window.LI_JS_TEST,a=[],d=!1;b=b||{};b.weight=b.weight||0;b.sort="function"===typeof b.sort?b.sort:f;this.length=function(){return a.length};this.enqueue=function(c,e){a.push({weight:isNaN(e)?b.weight:e,item:c});d=!0};this.dequeue=function(){c();return a.length?a.pop().item:void 0};this.peek=function(){c();return a.length?
a[a.length-1].item:void 0};this.publicInterface={length:this.length,enqueue:this.enqueue,dequeue:this.dequeue,peek:this.peek};g&&(this.publicInterface._debug={queue:a});h&&(this.publicInterface._test={queue:a});return this.publicInterface})})();