module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
            },
            app: {
                src: ["build/image-picker.js"],
                dest: "build/image-picker.min.js"
            }
        },
        ngAnnotate: {
            app: {
                src: ["AngularMediaModal/app/app.js", "AngularMediaModal/app/**/*.js"],
                dest: "build/image-picker.js"
            }
        },
        ngtemplates: {
            app: {
                options: {
                    module: "mediaModalTemplates",
                    standalone: true
                },
                cwd: "AngularMediaModal/app/views/",
                src: ["**/*.html"],
                dest: "build/templates.js"
            }
        },
        concat: {
            app: {
                src: ["build/templates.js", "build/image-picker.js"],
                dest: "build/image-picker.js"
            },
            dist: {
               src: [
                'AngularMediaModal/assets/fileupload/js/s/vendor/jquery.ui.widget.js',
                'AngularMediaModal/assets/fileupload/js/s/vendor/canvas-to-blob.min.js',
                'AngularMediaModal/assets/fileupload/js/s/vendor/load-image.all.min.js',
                'AngularMediaModal/assets/fileupload/js/jquery.iframe-transport.js',
                'AngularMediaModal/assets/fileupload/js/jquery.fileupload.js',
                'AngularMediaModal/assets/fileupload/js/jquery.fileupload-process.js',
                'AngularMediaModal/assets/fileupload/js/jquery.fileupload-image.js',
                'AngularMediaModal/assets/fileupload/js/jquery.fileupload-audio.js',
                'AngularMediaModal/assets/fileupload/js/jquery.fileupload-video.js',
                'AngularMediaModal/assets/fileupload/js/jquery.fileupload-validate.js',
                'AngularMediaModal/assets/fileupload/js/jquery.fileupload-angular.js',
                'build/image-picker.min.js',

                ],
               dest: 'image-picker.min.js'
            }
        },
        copy: {
            css: {
                src: ["AngularMediaModal/app/styles/media-modal.css"],
                dest: "build/media-modal.css"
            }
        },
        watch: {
            js: {
                files: ["AngularMediaModal/app/**/*.js"],
                tasks: ["ngAnnotate", "concat"]
            },
            templates: {
                files: ["AngularMediaModal/app/views/**/*.html"],
                tasks: ["ngtemplates", "ngAnnotate", "concat"]
            },
            css: {
                files: ["AngularMediaModal/app/styles/**/*.css"],
                tasks: ["copy:css"]
            }
        }
    });

    require('load-grunt-tasks')(grunt);

    grunt.registerTask('default', ["ngtemplates", "ngAnnotate", "concat", "copy", "uglify"]);
    grunt.registerTask('dev', ["ngtemplates", "ngAnnotate", "concat", "copy", "watch"]);

};