define(["modules/forms/module","lodash"],function(a,b){"use strict";return a.registerDirective("smartWizard",function(){return{restrict:"A",scope:{smartWizardCallback:"&"},link:function(a,c){function d(a){f=a,$("[data-smart-wizard-pane="+a+"]",c).addClass("active").siblings("[data-smart-wizard-pane]").removeClass("active"),$("[data-smart-wizard-tab="+a+"]",c).addClass("active").siblings("[data-smart-wizard-tab]").removeClass("active"),i.toggleClass("disabled",1==a)}var e=$("[data-smart-wizard-tab]").length,f=1,g=[],h=c.closest("form"),i=$("[data-smart-wizard-prev]",c),j=$("[data-smart-wizard-next]",c);c.on("click","[data-smart-wizard-tab]",function(a){d(parseInt($(this).data("smartWizardTab"))),a.preventDefault()}),j.on("click",function(i){if(h.data("validator")){if(!h.valid())return g=b.without(g,f),h.data("validator").focusInvalid(),!1;g=b.without(g,f),g.push(f),c.find("[data-smart-wizard-tab="+f+"]").addClass("complete").find(".step").html('<i class="fa fa-check"></i>')}if(e>f)d(f+1);else if(g.length<e){var j=b.range(1,e+1);b(j).forEach(function(a){return-1==g.indexOf(a)?(console.log(a),d(a),!1):void 0})}else{var k={};b.each(h.serializeArray(),function(a){k[a.name]=a.value}),"function"==typeof a.smartWizardCallback()&&a.smartWizardCallback()(k)}i.preventDefault()}),i.on("click",function(a){!i.hasClass("disabled")&&f>0&&d(f-1),a.preventDefault()}),d(f)}}})});