fileinput.min.js 72.6 KB
Newer Older
sistem17user committed
1 2 3 4 5 6 7 8 9 10 11 12
/*!
 * bootstrap-fileinput v4.3.7
 * http://plugins.krajee.com/file-input
 *
 * Author: Kartik Visweswaran
 * Copyright: 2014 - 2017, Kartik Visweswaran, Krajee.com
 *
 * Licensed under the BSD 3-Clause
 * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md
 */!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(window.jQuery)}(function(e){"use strict";e.fn.fileinputLocales={},e.fn.fileinputThemes={};var i,t,a,n,r,o,l,s,d,c,p,u,f,m,g,v,h,w,b,_,C,x,y,T,F,k,E,S,$,I,P,z,D,A,U,j,L,Z,B,O,R,M,N,H,q,W,K,V,G,X,Y,J,Q,ee,ie,te,ae,ne,re,oe,le,se,de,ce,pe,ue,fe,me,ge;i=".fileinput",t="kvFileinputModal",a=".file-preview-frame:visible",n='style="width:{width};height:{height};"',r='<param name="controller" value="true" />\n<param name="allowFullScreen" value="true" />\n<param name="allowScriptAccess" value="always" />\n<param name="autoPlay" value="false" />\n<param name="autoStart" value="false" />\n<param name="quality" value="high" />\n',o='<div class="file-preview-other">\n<span class="{previewFileIconClass}">{previewFileIcon}</span>\n</div>',l=window.URL||window.webkitURL,s=function(e,i,t){return void 0!==e&&(t?e===i:e.match(i))},d=function(e){if("Microsoft Internet Explorer"!==navigator.appName)return!1;if(10===e)return new RegExp("msie\\s"+e,"i").test(navigator.userAgent);var i,t=document.createElement("div");return t.innerHTML="<!--[if IE "+e+"]> <i></i> <![endif]-->",i=t.getElementsByTagName("i").length,document.body.appendChild(t),t.parentNode.removeChild(t),i},c=function(e,t,a,n){var r=n?t:t.split(" ").join(i+" ")+i;e.off(r).on(r,a)},p={data:{},init:function(e){var i=e.initialPreview,t=e.id;i.length>0&&!re(i)&&(i=i.split(e.initialPreviewDelimiter)),p.data[t]={content:i,config:e.initialPreviewConfig,tags:e.initialPreviewThumbTags,delimiter:e.initialPreviewDelimiter,previewFileType:e.initialPreviewFileType,previewAsData:e.initialPreviewAsData,template:e.previewGenericTemplate,showZoom:e.fileActionSettings.showZoom,showDrag:e.fileActionSettings.showDrag,getSize:function(i){return e._getSize(i)},parseTemplate:function(i,t,a,n,r,o,l,s){var d=" file-preview-initial";return e._generatePreviewTemplate(i,t,a,n,r,!1,null,d,o,l,s)},msg:function(i){return e._getMsgSelected(i)},initId:e.previewInitId,footer:e._getLayoutTemplate("footer").replace(/\{progress}/g,e._renderThumbProgress()),isDelete:e.initialPreviewShowDelete,caption:e.initialCaption,actions:function(i,t,a,n,r,o,l){return e._renderFileActions(i,t,a,n,r,o,l,!0)}}},fetch:function(e){return p.data[e].content.filter(function(e){return null!==e})},count:function(e,i){return p.data[e]&&p.data[e].content?i?p.data[e].content.length:p.fetch(e).length:0},get:function(i,t,a){var n,r,o,l,s,d,c="init_"+t,u=p.data[i],f=u.config[t],m=u.content[t],g=u.initId+"-"+c,v=oe("previewAsData",f,u.previewAsData);return a=void 0===a?!0:a,m?(o=oe("type",f,u.previewFileType||"generic"),s=oe("filename",f,oe("caption",f)),d=oe("filetype",f,o),l=p.footer(i,t,a,f&&f.size||null),n=v?u.parseTemplate(o,m,s,d,g,l,c):u.parseTemplate("generic",m,s,d,g,l,c,o).replace(/\{content}/g,u.content[t]),u.tags.length&&u.tags[t]&&(n=de(n,u.tags[t])),ne(f)||ne(f.frameAttr)||(r=e(document.createElement("div")).html(n),r.find(".file-preview-initial").attr(f.frameAttr),n=r.html(),r.remove()),n):""},add:function(i,t,a,n,r){var o,l=e.extend(!0,{},p.data[i]);return re(t)||(t=t.split(l.delimiter)),r?(o=l.content.push(t)-1,l.config[o]=a,l.tags[o]=n):(o=t.length-1,l.content=t,l.config=a,l.tags=n),p.data[i]=l,o},set:function(i,t,a,n,r){var o,l,s=e.extend(!0,{},p.data[i]);if(t&&t.length&&(re(t)||(t=t.split(s.delimiter)),l=t.filter(function(e){return null!==e}),l.length)){if(void 0===s.content&&(s.content=[]),void 0===s.config&&(s.config=[]),void 0===s.tags&&(s.tags=[]),r){for(o=0;o<t.length;o++)t[o]&&s.content.push(t[o]);for(o=0;o<a.length;o++)a[o]&&s.config.push(a[o]);for(o=0;o<n.length;o++)n[o]&&s.tags.push(n[o])}else s.content=t,s.config=a,s.tags=n;p.data[i]=s}},unset:function(e,i){var t=p.count(e.id);if(t){if(1===t)return p.data[e.id].content=[],p.data[e.id].config=[],p.data[e.id].tags=[],e.initialPreview=[],e.initialPreviewConfig=[],void(e.initialPreviewThumbTags=[]);p.data[e.id].content[i]=null,p.data[e.id].config[i]=null,p.data[e.id].tags[i]=null}},out:function(e){var i,t="",a=p.data[e],n=p.count(e,!0);if(0===n)return{content:"",caption:""};for(var r=0;n>r;r++)t+=p.get(e,r);return i=a.msg(p.count(e)),{content:'<div class="file-initial-thumbs">'+t+"</div>",caption:i}},footer:function(e,i,t,a){var n=p.data[e];if(t=void 0===t?!0:t,!n||!n.config||0===n.config.length||ne(n.config[i]))return"";var r=n.config[i],o=oe("caption",r),l=oe("width",r,"auto"),s=oe("url",r,!1),d=oe("key",r,null),c=oe("showDelete",r,!0),u=oe("showZoom",r,n.showZoom),f=oe("showDrag",r,n.showDrag),m=s===!1&&t,g=n.isDelete?n.actions(!1,c,u,f,m,s,d):"",v=n.footer.replace(/\{actions}/g,g);return v.replace(/\{caption}/g,o).replace(/\{size}/g,n.getSize(a)).replace(/\{width}/g,l).replace(/\{indicator}/g,"").replace(/\{indicatorTitle}/g,"")}},u=function(e,i){return i=i||0,"number"==typeof e?e:("string"==typeof e&&(e=parseFloat(e)),isNaN(e)?i:e)},f=function(){return!(!window.File||!window.FileReader)},m=function(){var e=document.createElement("div");return!d(9)&&(void 0!==e.draggable||void 0!==e.ondragstart&&void 0!==e.ondrop)},g=function(){return f()&&window.FormData},v=function(e,i){e.removeClass(i).addClass(i)},X={showRemove:!0,showUpload:!0,showZoom:!0,showDrag:!0,removeIcon:'<i class="glyphicon glyphicon-trash text-danger"></i>',removeClass:"btn btn-xs btn-default",removeTitle:"Remove file",uploadIcon:'<i class="glyphicon glyphicon-upload text-info"></i>',uploadClass:"btn btn-xs btn-default",uploadTitle:"Upload file",zoomIcon:'<i class="glyphicon glyphicon-zoom-in"></i>',zoomClass:"btn btn-xs btn-default",zoomTitle:"View Details",dragIcon:'<i class="glyphicon glyphicon-menu-hamburger"></i>',dragClass:"text-info",dragTitle:"Move / Rearrange",dragSettings:{},indicatorNew:'<i class="glyphicon glyphicon-hand-down text-warning"></i>',indicatorSuccess:'<i class="glyphicon glyphicon-ok-sign text-success"></i>',indicatorError:'<i class="glyphicon glyphicon-exclamation-sign text-danger"></i>',indicatorLoading:'<i class="glyphicon glyphicon-hand-up text-muted"></i>',indicatorNewTitle:"Not uploaded yet",indicatorSuccessTitle:"Uploaded",indicatorErrorTitle:"Upload Error",indicatorLoadingTitle:"Uploading ..."},h='{preview}\n<div class="kv-upload-progress hide"></div>\n<div class="input-group {class}">\n   {caption}\n   <div class="input-group-btn">\n       {remove}\n       {cancel}\n       {upload}\n       {browse}\n   </div>\n</div>',w='{preview}\n<div class="kv-upload-progress hide"></div>\n{remove}\n{cancel}\n{upload}\n{browse}\n',b='<div class="file-preview {class}">\n    {close}    <div class="{dropClass}">\n    <div class="file-preview-thumbnails">\n    </div>\n    <div class="clearfix"></div>    <div class="file-preview-status text-center text-success"></div>\n    <div class="kv-fileinput-error"></div>\n    </div>\n</div>',C='<div class="close fileinput-remove">&times;</div>\n',_='<i class="glyphicon glyphicon-file kv-caption-icon"></i>',x='<div tabindex="500" class="form-control file-caption {class}">\n   <div class="file-caption-name"></div>\n</div>\n',y='<button type="{type}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</button>',T='<a href="{href}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</a>',F='<div tabindex="500" class="{css}" {status}>{icon} {label}</div>',k='<div id="'+t+'" class="file-zoom-dialog modal fade" tabindex="-1" aria-labelledby="'+t+'Label"></div>',E='<div class="modal-dialog modal-lg" role="document">\n  <div class="modal-content">\n    <div class="modal-header">\n      <div class="kv-zoom-actions pull-right">{toggleheader}{fullscreen}{borderless}{close}</div>\n      <h3 class="modal-title">{heading} <small><span class="kv-zoom-title"></span></small></h3>\n    </div>\n    <div class="modal-body">\n      <div class="floating-buttons"></div>\n      <div class="kv-zoom-body file-zoom-content"></div>\n{prev} {next}\n    </div>\n  </div>\n</div>\n',S='<div class="progress">\n    <div class="{class}" role="progressbar" aria-valuenow="{percent}" aria-valuemin="0" aria-valuemax="100" style="width:{percent}%;">\n        {percent}%\n     </div>\n</div>',$=" <br><samp>({sizeText})</samp>",I='<div class="file-thumbnail-footer">\n    <div class="file-footer-caption" title="{caption}">{caption}{size}</div>\n    {progress} {actions}\n</div>',P='<div class="file-actions">\n    <div class="file-footer-buttons">\n        {upload} {delete} {zoom} {other}    </div>\n    {drag}\n    <div class="file-upload-indicator" title="{indicatorTitle}">{indicator}</div>\n    <div class="clearfix"></div>\n</div>',z='<button type="button" class="kv-file-remove {removeClass}" title="{removeTitle}" {dataUrl}{dataKey}>{removeIcon}</button>\n',D='<button type="button" class="kv-file-upload {uploadClass}" title="{uploadTitle}">{uploadIcon}</button>',A='<button type="button" class="kv-file-zoom {zoomClass}" title="{zoomTitle}">{zoomIcon}</button>',U='<span class="file-drag-handle {dragClass}" title="{dragTitle}">{dragIcon}</span>',j='<div class="file-preview-frame{frameClass}" id="{previewId}" data-fileindex="{fileindex}" data-template="{template}"',L=j+'><div class="kv-file-content">\n',Z=j+' title="{caption}" '+n+'><div class="kv-file-content">\n',B="</div>{footer}\n</div>\n",O="{content}\n",R='<div class="kv-preview-data file-preview-html" title="{caption}" '+n+">{data}</div>\n",M='<img src="{data}" class="kv-preview-data file-preview-image" title="{caption}" alt="{caption}" '+n+">\n",N='<textarea class="kv-preview-data file-preview-text" title="{caption}" readonly '+n+">{data}</textarea>\n",H='<video class="kv-preview-data" width="{width}" height="{height}" controls>\n<source src="{data}" type="{type}">\n'+o+"\n</video>\n",q='<audio class="kv-preview-data" controls>\n<source src="{data}" type="{type}">\n'+o+"\n</audio>\n",W='<object class="kv-preview-data file-object" type="application/x-shockwave-flash" width="{width}" height="{height}" data="{data}">\n'+r+" "+o+"\n</object>\n",K='<object class="kv-preview-data file-object" data="{data}" type="{type}" width="{width}" height="{height}">\n<param name="movie" value="{caption}" />\n'+r+" "+o+"\n</object>\n",V='<embed class="kv-preview-data" src="{data}" width="{width}" height="{height}" type="application/pdf">\n',G='<div class="kv-preview-data file-preview-other-frame">\n'+o+"\n</div>\n",Y={main1:h,main2:w,preview:b,close:C,fileIcon:_,caption:x,modalMain:k,modal:E,progress:S,size:$,footer:I,actions:P,actionDelete:z,actionUpload:D,actionZoom:A,actionDrag:U,btnDefault:y,btnLink:T,btnBrowse:F},J={generic:L+O+B,html:L+R+B,image:L+M+B,text:L+N+B,video:Z+H+B,audio:Z+q+B,flash:Z+W+B,object:Z+K+B,pdf:Z+V+B,other:Z+G+B},ee=["image","html","text","video","audio","flash","pdf","object"],te={image:{width:"auto",height:"160px"},html:{width:"213px",height:"160px"},text:{width:"213px",height:"160px"},video:{width:"213px",height:"160px"},audio:{width:"213px",height:"80px"},flash:{width:"213px",height:"160px"},object:{width:"160px",height:"160px"},pdf:{width:"160px",height:"160px"},other:{width:"160px",height:"160px"}},Q={image:{width:"auto",height:"auto","max-width":"100%","max-height":"100%"},html:{width:"100%",height:"100%","min-height":"480px"},text:{width:"100%",height:"100%","min-height":"480px"},video:{width:"auto",height:"100%","max-width":"100%"},audio:{width:"100%",height:"30px"},flash:{width:"auto",height:"480px"},object:{width:"auto",height:"100%","min-height":"480px"},pdf:{width:"100%",height:"100%","min-height":"480px"},other:{width:"auto",height:"100%","min-height":"480px"}},ae={image:function(e,i){return s(e,"image.*")||s(i,/\.(gif|png|jpe?g)$/i)},html:function(e,i){return s(e,"text/html")||s(i,/\.(htm|html)$/i)},text:function(e,i){return s(e,"text.*")||s(i,/\.(xml|javascript)$/i)||s(i,/\.(txt|md|csv|nfo|ini|json|php|js|css)$/i)},video:function(e,i){return s(e,"video.*")&&(s(e,/(ogg|mp4|mp?g|mov|webm|3gp)$/i)||s(i,/\.(og?|mp4|webm|mp?g|mov|3gp)$/i))},audio:function(e,i){return s(e,"audio.*")&&(s(i,/(ogg|mp3|mp?g|wav)$/i)||s(i,/\.(og?|mp3|mp?g|wav)$/i))},flash:function(e,i){return s(e,"application/x-shockwave-flash",!0)||s(i,/\.(swf)$/i)},pdf:function(e,i){return s(e,"application/pdf",!0)||s(i,/\.(pdf)$/i)},object:function(){return!0},other:function(){return!0}},ne=function(i,t){return void 0===i||null===i||0===i.length||t&&""===e.trim(i)},re=function(e){return Array.isArray(e)||"[object Array]"===Object.prototype.toString.call(e)},oe=function(e,i,t){return t=t||"",i&&"object"==typeof i&&e in i?i[e]:t},ie=function(i,t,a){return ne(i)||ne(i[t])?a:e(i[t])},le=function(){return Math.round((new Date).getTime()+100*Math.random())},se=function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},de=function(i,t){var a=i;return t?(e.each(t,function(e,i){"function"==typeof i&&(i=i()),a=a.split(e).join(i)}),a):a},ce=function(e){var i=e.is("img")?e.attr("src"):e.find("source").attr("src");l.revokeObjectURL(i)},pe=function(e){var i=e.lastIndexOf("/");return-1===i&&(i=e.lastIndexOf("\\")),e.split(e.substring(i,i+1)).pop()},ue=function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement},fe=function(e){var i=document,t=i.documentElement;t&&e&&!ue()?t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):i.exitFullscreen?i.exitFullscreen():i.msExitFullscreen?i.msExitFullscreen():i.mozCancelFullScreen?i.mozCancelFullScreen():i.webkitExitFullscreen&&i.webkitExitFullscreen()},me=function(e,i,t){if(t>=e.length)for(var a=t-e.length;a--+1;)e.push(void 0);return e.splice(t,0,e.splice(i,1)[0]),e},ge=function(i,t){var a=this;a.$element=e(i),a._validate()&&(a.isPreviewable=f(),a.isIE9=d(9),a.isIE10=d(10),a.isPreviewable||a.isIE9?(a._init(t),a._listen()):a.$element.removeClass("file-loading"))},ge.prototype={constructor:ge,_init:function(i){var t,a=this,n=a.$element;e.each(i,function(e,i){switch(e){case"minFileCount":case"maxFileCount":case"maxFileSize":a[e]=u(i);break;default:a[e]=i}}),a.fileInputCleared=!1,a.fileBatchCompleted=!0,a.isPreviewable||(a.showPreview=!1),a.uploadFileAttr=ne(n.attr("name"))?"file_data":n.attr("name"),a.reader=null,a.formdata={},a.clearStack(),a.uploadCount=0,a.uploadStatus={},a.uploadLog=[],a.uploadAsyncCount=0,a.loadedImages=[],a.totalImagesCount=0,a.ajaxRequests=[],a.isError=!1,a.ajaxAborted=!1,a.cancelling=!1,t=a._getLayoutTemplate("progress"),a.progressTemplate=t.replace("{class}",a.progressClass),a.progressCompleteTemplate=t.replace("{class}",a.progressCompleteClass),a.progressErrorTemplate=t.replace("{class}",a.progressErrorClass),a.dropZoneEnabled=m()&&a.dropZoneEnabled,a.isDisabled=a.$element.attr("disabled")||a.$element.attr("readonly"),a.isUploadable=g()&&!ne(a.uploadUrl),a.isClickable=a.browseOnZoneClick&&a.showPreview&&(a.isUploadable&&a.dropZoneEnabled||!ne(a.defaultPreviewContent)),a.slug="function"==typeof i.slugCallback?i.slugCallback:a._slugDefault,a.mainTemplate=a.showCaption?a._getLayoutTemplate("main1"):a._getLayoutTemplate("main2"),a.captionTemplate=a._getLayoutTemplate("caption"),a.previewGenericTemplate=a._getPreviewTemplate("generic"),a.resizeImage&&(a.maxImageWidth||a.maxImageHeight)&&(a.imageCanvas=document.createElement("canvas"),a.imageCanvasContext=a.imageCanvas.getContext("2d")),ne(a.$element.attr("id"))&&a.$element.attr("id",le()),void 0===a.$container?a.$container=a._createContainer():a._refreshContainer(),a.$dropZone=a.$container.find(".file-drop-zone"),a.$progress=a.$container.find(".kv-upload-progress"),a.$btnUpload=a.$container.find(".fileinput-upload"),a.$captionContainer=ie(i,"elCaptionContainer",a.$container.find(".file-caption")),a.$caption=ie(i,"elCaptionText",a.$container.find(".file-caption-name")),a.$previewContainer=ie(i,"elPreviewContainer",a.$container.find(".file-preview")),a.$preview=ie(i,"elPreviewImage",a.$container.find(".file-preview-thumbnails")),a.$previewStatus=ie(i,"elPreviewStatus",a.$container.find(".file-preview-status")),a.$errorContainer=ie(i,"elErrorContainer",a.$previewContainer.find(".kv-fileinput-error")),ne(a.msgErrorClass)||v(a.$errorContainer,a.msgErrorClass),a.$errorContainer.hide(),a.fileActionSettings=e.extend(!0,X,i.fileActionSettings),a.previewInitId="preview-"+le(),a.id=a.$element.attr("id"),p.init(a),a._initPreview(!0),a._initPreviewActions(),a.options=i,a._setFileDropZoneTitle(),a.$element.removeClass("file-loading"),a.$element.attr("disabled")&&a.disable(),a._initZoom()},_log:function(e){var i=this,t=i.$element.attr("id");t&&(e='"'+t+'": '+e),"undefined"!=typeof window.console.log?window.console.log(e):window.alert(e)},_validate:function(){var e=this,i="file"===e.$element.attr("type");return i||e._log('The input "type" must be set to "file" for initializing the "bootstrap-fileinput" plugin.'),i},_errorsExist:function(){var i,t=this;return t.$errorContainer.find("li").length?!0:(i=e(document.createElement("div")).html(t.$errorContainer.html()),i.find("span.kv-error-close").remove(),i.find("ul").remove(),!!e.trim(i.text()).length)},_errorHandler:function(e,i){var t=this,a=e.target.error;a.code===a.NOT_FOUND_ERR?t._showError(t.msgFileNotFound.replace("{name}",i)):a.code===a.SECURITY_ERR?t._showError(t.msgFileSecured.replace("{name}",i)):a.code===a.NOT_READABLE_ERR?t._showError(t.msgFileNotReadable.replace("{name}",i)):a.code===a.ABORT_ERR?t._showError(t.msgFilePreviewAborted.replace("{name}",i)):t._showError(t.msgFilePreviewError.replace("{name}",i))},_addError:function(e){var i=this,t=i.$errorContainer;e&&t.length&&(t.html(i.errorCloseButton+e),c(t.find(".kv-error-close"),"click",function(){t.fadeOut("slow")}))},_resetErrors:function(e){var i=this,t=i.$errorContainer;i.isError=!1,i.$container.removeClass("has-error"),t.html(""),e?t.fadeOut("slow"):t.hide()},_showFolderError:function(e){var i,t=this,a=t.$errorContainer;e&&(i=t.msgFoldersNotAllowed.replace(/\{n}/g,e),t._addError(i),v(t.$container,"has-error"),a.fadeIn(800),t._raise("filefoldererror",[e,i]))},_showUploadError:function(e,i,t){var a=this,n=a.$errorContainer,r=t||"fileuploaderror",o=i&&i.id?'<li data-file-id="'+i.id+'">'+e+"</li>":"<li>"+e+"</li>";return 0===n.find("ul").length?a._addError("<ul>"+o+"</ul>"):n.find("ul").append(o),n.fadeIn(800),a._raise(r,[i,e]),a.$container.removeClass("file-input-new"),v(a.$container,"has-error"),!0},_showError:function(e,i,t){var a=this,n=a.$errorContainer,r=t||"fileerror";return i=i||{},i.reader=a.reader,a._addError(e),n.fadeIn(800),a._raise(r,[i,e]),a.isUploadable||a._clearFileInput(),a.$container.removeClass("file-input-new"),v(a.$container,"has-error"),a.$btnUpload.attr("disabled",!0),!0},_noFilesError:function(e){var i=this,t=i.minFileCount>1?i.filePlural:i.fileSingle,a=i.msgFilesTooLess.replace("{n}",i.minFileCount).replace("{files}",t),n=i.$errorContainer;i._addError(a),i.isError=!0,i._updateFileDetails(0),n.fadeIn(800),i._raise("fileerror",[e,a]),i._clearFileInput(),v(i.$container,"has-error")},_parseError:function(i,t,a){var n=this,r=e.trim(t+""),o="."===r.slice(-1)?"":".",l=void 0!==i.responseJSON&&void 0!==i.responseJSON.error?i.responseJSON.error:i.responseText;return n.cancelling&&n.msgUploadAborted&&(r=n.msgUploadAborted),n.showAjaxErrorDetails&&l?(l=e.trim(l.replace(/\n\s*\n/g,"\n")),l=l.length>0?"<pre>"+l+"</pre>":"",r+=o+l):r+=o,n.cancelling=!1,a?"<b>"+a+": </b>"+r:r},_parseFileType:function(e){var i,t,a,n,r=this;for(n=0;n<ee.length;n+=1)if(a=ee[n],i=oe(a,r.fileTypeSettings,ae[a]),t=i(e.type,e.name)?a:"",!ne(t))return t;return"other"},_getPreviewIcon:function(i){var t,a=this,n=null;return i&&i.indexOf(".")>-1&&(t=i.split(".").pop(),a.previewFileIconSettings&&a.previewFileIconSettings[t]&&(n=a.previewFileIconSettings[t]),a.previewFileExtSettings&&e.each(a.previewFileExtSettings,function(e,i){return a.previewFileIconSettings[e]&&i(t)?void(n=a.previewFileIconSettings[e]):void 0})),n},_parseFilePreviewIcon:function(e,i){var t=this,a=t._getPreviewIcon(i)||t.previewFileIcon;return e.indexOf("{previewFileIcon}")>-1&&(e=e.replace(/\{previewFileIconClass}/g,t.previewFileIconClass).replace(/\{previewFileIcon}/g,a)),e},_raise:function(i,t){var a=this,n=e.Event(i);if(void 0!==t?a.$element.trigger(n,t):a.$element.trigger(n),n.isDefaultPrevented())return!1;if(!n.result)return n.result;switch(i){case"filebatchuploadcomplete":case"filebatchuploadsuccess":case"fileuploaded":case"fileclear":case"filecleared":case"filereset":case"fileerror":case"filefoldererror":case"fileuploaderror":case"filebatchuploaderror":case"filedeleteerror":case"filecustomerror":case"filesuccessremove":break;default:a.ajaxAborted=n.result}return!0},_listenFullScreen:function(e){var i,t,a=this,n=a.$modal;n&&n.length&&(i=n&&n.find(".btn-fullscreen"),t=n&&n.find(".btn-borderless"),i.length&&t.length&&(i.removeClass("active").attr("aria-pressed","false"),t.removeClass("active").attr("aria-pressed","false"),e?i.addClass("active").attr("aria-pressed","true"):t.addClass("active").attr("aria-pressed","true"),n.hasClass("file-zoom-fullscreen")?a._maximizeZoomDialog():e?a._maximizeZoomDialog():t.removeClass("active").attr("aria-pressed","false")))},_listen:function(){var i=this,t=i.$element,a=t.closest("form"),n=i.$container;c(t,"change",e.proxy(i._change,i)),i.showBrowse&&c(i.$btnFile,"click",e.proxy(i._browse,i)),c(a,"reset",e.proxy(i.reset,i)),c(n.find(".fileinput-remove:not([disabled])"),"click",e.proxy(i.clear,i)),c(n.find(".fileinput-cancel"),"click",e.proxy(i.cancel,i)),i._initDragDrop(),i.isUploadable||c(a,"submit",e.proxy(i._submitForm,i)),c(i.$container.find(".fileinput-upload"),"click",e.proxy(i._uploadClick,i)),c(e(window),"resize",function(){i._listenFullScreen(screen.width===window.innerWidth&&screen.height===window.innerHeight)}),c(e(document),"webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange",function(){i._listenFullScreen(ue())}),i._initClickable()},_initClickable:function(){var i,t=this;t.isClickable&&(i=t.isUploadable?t.$dropZone:t.$preview.find(".file-default-preview"),v(i,"clickable"),i.attr("tabindex",-1),c(i,"click",function(a){var n=e(a.target);n.parents(".file-preview-thumbnails").length&&!n.parents(".file-default-preview").length||(t.$element.trigger("click"),i.blur())}))},_initDragDrop:function(){var i=this,t=i.$dropZone;i.isUploadable&&i.dropZoneEnabled&&i.showPreview&&(c(t,"dragenter dragover",e.proxy(i._zoneDragEnter,i)),c(t,"dragleave",e.proxy(i._zoneDragLeave,i)),c(t,"drop",e.proxy(i._zoneDrop,i)),c(e(document),"dragenter dragover drop",i._zoneDragDropInit))},_zoneDragDropInit:function(e){e.stopPropagation(),e.preventDefault()},_zoneDragEnter:function(i){var t=this,a=e.inArray("Files",i.originalEvent.dataTransfer.types)>-1;return t._zoneDragDropInit(i),t.isDisabled||!a?(i.originalEvent.dataTransfer.effectAllowed="none",void(i.originalEvent.dataTransfer.dropEffect="none")):void v(t.$dropZone,"file-highlighted")},_zoneDragLeave:function(e){var i=this;i._zoneDragDropInit(e),i.isDisabled||i.$dropZone.removeClass("file-highlighted")},_zoneDrop:function(e){var i=this;e.preventDefault(),i.isDisabled||ne(e.originalEvent.dataTransfer.files)||(i._change(e,"dragdrop"),i.$dropZone.removeClass("file-highlighted"))},_uploadClick:function(e){var i,t=this,a=t.$container.find(".fileinput-upload"),n=!a.hasClass("disabled")&&ne(a.attr("disabled"));if(!e||!e.isDefaultPrevented()){if(!t.isUploadable)return void(n&&"submit"!==a.attr("type")&&(i=a.closest("form"),i.length&&i.trigger("submit"),e.preventDefault()));e.preventDefault(),n&&t.upload()}},_submitForm:function(){var e=this,i=e.$element,t=i.get(0).files;return t&&e.minFileCount>0&&e._getFileCount(t.length)<e.minFileCount?(e._noFilesError({}),!1):!e._abort({})},_clearPreview:function(){var e=this,i=e.showUploadedThumbs?e.$preview.find(a+":not(.file-preview-success)"):e.$preview.find(a);i.remove(),e.$preview.find(a).length&&e.showPreview||e._resetUpload(),e._validateDefaultPreview()},_initSortable:function(){var i,t,n=this,r=n.$preview;window.KvSortable&&(i=r.find(".file-initial-thumbs"),t={handle:".drag-handle-init",dataIdAttr:"data-preview-id",draggable:".file-preview-initial",onSort:function(i){var t,r,o=i.oldIndex,l=i.newIndex;n.initialPreview=me(n.initialPreview,o,l),n.initialPreviewConfig=me(n.initialPreviewConfig,o,l),p.init(n);for(var s=0;s<n.initialPreviewConfig.length;s++)null!==n.initialPreviewConfig[s]&&(t=n.initialPreviewConfig[s].key,r=e(".kv-file-remove[data-key='"+t+"']").closest(a),r.attr("data-fileindex","init_"+s).data("fileindex","init_"+s));n._raise("filesorted",{previewId:e(i.item).attr("id"),oldIndex:o,newIndex:l,stack:n.initialPreviewConfig})}},i.data("kvsortable")&&i.kvsortable("destroy"),e.extend(!0,t,n.fileActionSettings.dragSettings),i.kvsortable(t))},_initPreview:function(e){var i,t=this,a=t.initialCaption||"";return p.count(t.id)?(i=p.out(t.id),a=e&&t.initialCaption?t.initialCaption:i.caption,t.$preview.html(i.content),t._setCaption(a),t._initSortable(),void(ne(i.content)||t.$container.removeClass("file-input-new"))):(t._clearPreview(),void(e?t._setCaption(a):t._initCaption()))},_getZoomButton:function(e){var i=this,t=i.previewZoomButtonIcons[e],a=i.previewZoomButtonClasses[e],n=' title="'+(i.previewZoomButtonTitles[e]||"")+'" ',r=n+("close"===e?' data-dismiss="modal" aria-hidden="true"':"");return"fullscreen"!==e&&"borderless"!==e&&"toggleheader"!==e||(r+=' data-toggle="button" aria-pressed="false" autocomplete="off"'),'<button type="button" class="'+a+" btn-"+e+'"'+r+">"+t+"</button>"},_getModalContent:function(){var e=this;return e._getLayoutTemplate("modal").replace(/\{heading}/g,e.msgZoomModalHeading).replace(/\{prev}/g,e._getZoomButton("prev")).replace(/\{next}/g,e._getZoomButton("next")).replace(/\{toggleheader}/g,e._getZoomButton("toggleheader")).replace(/\{fullscreen}/g,e._getZoomButton("fullscreen")).replace(/\{borderless}/g,e._getZoomButton("borderless")).replace(/\{close}/g,e._getZoomButton("close"))},_listenModalEvent:function(e){var i=this,t=i.$modal,a=function(e){return{sourceEvent:e,previewId:t.data("previewId"),modal:t}};t.on(e+".bs.modal",function(n){var r=t.find(".btn-fullscreen"),o=t.find(".btn-borderless");i._raise("filezoom"+e,a(n)),"shown"===e&&(o.removeClass("active").attr("aria-pressed","false"),r.removeClass("active").attr("aria-pressed","false"),t.hasClass("file-zoom-fullscreen")&&(i._maximizeZoomDialog(),ue()?r.addClass("active").attr("aria-pressed","true"):o.addClass("active").attr("aria-pressed","true")))})},_initZoom:function(){var i,a=this,n=a._getLayoutTemplate("modalMain"),r="#"+t;a.$modal=e(r),a.$modal&&a.$modal.length||(i=e(document.createElement("div")).html(n).insertAfter(a.$container),a.$modal=e("#"+t).insertBefore(i),i.remove()),a.$modal.html(a._getModalContent()),a._listenModalEvent("show"),a._listenModalEvent("shown"),a._listenModalEvent("hide"),a._listenModalEvent("hidden"),a._listenModalEvent("loaded")},_initZoomButtons:function(){var i,t,n=this,r=n.$modal.data("previewId")||"",o=n.$preview.find(a).toArray(),l=o.length,s=n.$modal.find(".btn-prev"),d=n.$modal.find(".btn-next");l&&(i=e(o[0]),t=e(o[l-1]),s.removeAttr("disabled"),d.removeAttr("disabled"),i.length&&i.attr("id")===r&&s.attr("disabled",!0),t.length&&t.attr("id")===r&&d.attr("disabled",!0))},_maximizeZoomDialog:function(){var i=this,t=i.$modal,a=t.find(".modal-header:visible"),n=t.find(".modal-footer:visible"),r=t.find(".modal-body"),o=e(window).height(),l=0;t.addClass("file-zoom-fullscreen"),a&&a.length&&(o-=a.outerHeight(!0)),n&&n.length&&(o-=n.outerHeight(!0)),r&&r.length&&(l=r.outerHeight(!0)-r.height(),o-=l),t.find(".kv-zoom-body").height(o)},_resizeZoomDialog:function(e){var i=this,t=i.$modal,a=t.find(".btn-fullscreen"),n=t.find(".btn-borderless");if(t.hasClass("file-zoom-fullscreen"))fe(!1),e?a.hasClass("active")||(t.removeClass("file-zoom-fullscreen"),i._resizeZoomDialog(!0),n.hasClass("active")&&n.removeClass("active").attr("aria-pressed","false")):a.hasClass("active")?a.removeClass("active").attr("aria-pressed","false"):(t.removeClass("file-zoom-fullscreen"),i.$modal.find(".kv-zoom-body").css("height",i.zoomModalHeight));else{if(!e)return void i._maximizeZoomDialog();fe(!0)}t.focus()},_setZoomContent:function(i,t){var a,n,r,o,l,s,d,p,u=this,f=i.attr("id"),m=u.$modal,g=m.find(".btn-prev"),h=m.find(".btn-next"),w=m.find(".btn-fullscreen"),b=m.find(".btn-borderless"),_=m.find(".btn-toggleheader"),C=u.$preview.find("#zoom-"+f);n=C.attr("data-template")||"generic",a=C.find(".kv-file-content"),r=a.length?a.html():"",o=C.find(".file-footer-caption").text()||"",m.find(".kv-zoom-title").html(o),l=m.find(".kv-zoom-body"),t?(p=l.clone().insertAfter(l),l.html(r).hide(),p.fadeOut("fast",function(){l.fadeIn("fast"),p.remove()})):l.html(r),d=u.previewZoomSettings[n],d&&(s=l.find(".kv-preview-data"),v(s,"file-zoom-detail"),e.each(d,function(e,i){s.css(e,i),(s.attr("width")&&"width"===e||s.attr("height")&&"height"===e)&&s.removeAttr(e)})),m.data("previewId",f),c(g,"click",function(){u._zoomSlideShow("prev",f)}),c(h,"click",function(){u._zoomSlideShow("next",f)}),c(w,"click",function(){u._resizeZoomDialog(!0)}),c(b,"click",function(){u._resizeZoomDialog(!1)}),c(_,"click",function(){var e,i=m.find(".modal-header"),t=m.find(".modal-body .floating-buttons"),a=i.find(".kv-zoom-actions"),n=function(e){var t=u.$modal.find(".kv-zoom-body"),a=u.zoomModalHeight;m.hasClass("file-zoom-fullscreen")&&(a=t.outerHeight(!0),e||(a-=i.outerHeight(!0))),t.css("height",e?a+e:a)};i.is(":visible")?(e=i.outerHeight(!0),i.slideUp("slow",function(){a.find(".btn").appendTo(t),n(e)})):(t.find(".btn").appendTo(a),i.slideDown("slow",function(){n()})),m.focus()}),c(m,"keydown",function(e){var i=e.which||e.keyCode;37!==i||g.attr("disabled")||u._zoomSlideShow("prev",f),39!==i||h.attr("disabled")||u._zoomSlideShow("next",f)})},_zoomPreview:function(e){var i,t=this;if(!e.length)throw"Cannot zoom to detailed preview!";t.$modal.html(t._getModalContent()),i=e.closest(a),t._setZoomContent(i),t.$modal.modal("show"),t._initZoomButtons()},_zoomSlideShow:function(i,t){var n,r,o,l=this,s=l.$modal.find(".kv-zoom-actions .btn-"+i),d=l.$preview.find(a).toArray(),c=d.length;if(!s.attr("disabled")){for(r=0;c>r;r++)if(e(d[r]).attr("id")===t){o="prev"===i?r-1:r+1;break}0>o||o>=c||!d[o]||(n=e(d[o]),n.length&&l._setZoomContent(n,!0),l._initZoomButtons(),l._raise("filezoom"+i,{previewId:t,modal:l.$modal}))}},_initZoomButton:function(){var i=this;i.$preview.find(".kv-file-zoom").each(function(){var t=e(this);c(t,"click",function(){i._zoomPreview(t)})})},_initPreviewActions:function(){var i=this,t=i.$preview,n=i.deleteExtraData||{},r=function(){var e=i.isUploadable?p.count(i.id):i.$element.get(0).files.length;0!==t.find(".kv-file-remove:visible").length||e||(i.reset(),i.initialCaption="")};i._initZoomButton(),t.find(".kv-file-remove:visible").each(function(){var o=e(this),l=o.data("url")||i.deleteUrl,s=o.data("key");if(!ne(l)&&void 0!==s){var d,u,f,m,g=o.closest(a),h=p.data[i.id],w=g.data("fileindex");w=parseInt(w.replace("init_","")),f=ne(h.config)&&ne(h.config[w])?null:h.config[w],m=ne(f)||ne(f.extra)?n:f.extra,"function"==typeof m&&(m=m()),u={id:o.attr("id"),key:s,extra:m},d=e.extend(!0,{},{url:l,type:"POST",dataType:"json",data:e.extend(!0,{},{key:s},m),beforeSend:function(e){i.ajaxAborted=!1,i._raise("filepredelete",[s,e,m]),i.ajaxAborted?e.abort():(v(g,"file-uploading"),v(o,"disabled"))},success:function(e,a,n){var l,d;return ne(e)||ne(e.error)?(p.init(i),w=parseInt(g.data("fileindex").replace("init_","")),p.unset(i,w),l=p.count(i.id),d=l>0?i._getMsgSelected(l):"",i._raise("filedeleted",[s,n,m]),i._setCaption(d),g.removeClass("file-uploading").addClass("file-deleted"),void g.fadeOut("slow",function(){var e=t.find("#zoom-"+g.attr("id"));e.length&&e.closest(".kv-zoom-cache").remove(),i._clearObjects(g),g.remove(),r(),l||0!==i.getFileStack().length||(i._setCaption(""),i.reset())})):(u.jqXHR=n,
    u.response=e,i._showError(e.error,u,"filedeleteerror"),g.removeClass("file-uploading"),o.removeClass("disabled"),void r())},error:function(e,t,a){var n=i._parseError(e,a);u.jqXHR=e,u.response={},i._showError(n,u,"filedeleteerror"),g.removeClass("file-uploading"),r()}},i.ajaxDeleteSettings),c(o,"click",function(){return i._validateMinCount()?void e.ajax(d):!1})}})},_clearObjects:function(i){i.find("video audio").each(function(){this.pause(),e(this).remove()}),i.find("img object div").each(function(){e(this).remove()})},_clearFileInput:function(){var i,t,a,n=this,r=n.$element;n.fileInputCleared=!0,ne(r.val())||(n.isIE9||n.isIE10?(i=r.closest("form"),t=e(document.createElement("form")),a=e(document.createElement("div")),r.before(a),i.length?i.after(t):a.after(t),t.append(r).trigger("reset"),a.before(r).remove(),t.remove()):r.val(""))},_resetUpload:function(){var e=this;e.uploadCache={content:[],config:[],tags:[],append:!0},e.uploadCount=0,e.uploadStatus={},e.uploadLog=[],e.uploadAsyncCount=0,e.loadedImages=[],e.totalImagesCount=0,e.$btnUpload.removeAttr("disabled"),e._setProgress(0),v(e.$progress,"hide"),e._resetErrors(!1),e.ajaxAborted=!1,e.ajaxRequests=[],e._resetCanvas()},_resetCanvas:function(){var e=this;e.canvas&&e.imageCanvasContext&&e.imageCanvasContext.clearRect(0,0,e.canvas.width,e.canvas.height)},_hasInitialPreview:function(){var e=this;return!e.overwriteInitial&&p.count(e.id)},_resetPreview:function(){var e,i,t=this;p.count(t.id)?(e=p.out(t.id),t.$preview.html(e.content),i=t.initialCaption?t.initialCaption:e.caption,t._setCaption(i)):(t._clearPreview(),t._initCaption()),t.showPreview&&(t._initZoom(),t._initSortable())},_clearDefaultPreview:function(){var e=this;e.$preview.find(".file-default-preview").remove()},_validateDefaultPreview:function(){var e=this;e.showPreview&&!ne(e.defaultPreviewContent)&&(e.$preview.html('<div class="file-default-preview">'+e.defaultPreviewContent+"</div>"),e.$container.removeClass("file-input-new"),e._initClickable())},_resetPreviewThumbs:function(e){var i,t=this;return e?(t._clearPreview(),void t.clearStack()):void(t._hasInitialPreview()?(i=p.out(t.id),t.$preview.html(i.content),t._setCaption(i.caption),t._initPreviewActions()):t._clearPreview())},_getLayoutTemplate:function(e){var i=this,t=oe(e,i.layoutTemplates,Y[e]);return ne(i.customLayoutTags)?t:de(t,i.customLayoutTags)},_getPreviewTemplate:function(e){var i=this,t=oe(e,i.previewTemplates,J[e]);return ne(i.customPreviewTags)?t:de(t,i.customPreviewTags)},_getOutData:function(e,i,t){var a=this;return e=e||{},i=i||{},t=t||a.filestack.slice(0)||{},{form:a.formdata,files:t,filenames:a.filenames,filescount:a.getFilesCount(),extra:a._getExtraData(),response:i,reader:a.reader,jqXHR:e}},_getMsgSelected:function(e){var i=this,t=1===e?i.fileSingle:i.filePlural;return e>0?i.msgSelected.replace("{n}",e).replace("{files}",t):i.msgNoFilesSelected},_getThumbs:function(e){return e=e||"",this.$preview.find(a+":not(.file-preview-initial)"+e)},_getExtraData:function(e,i){var t=this,a=t.uploadExtraData;return"function"==typeof t.uploadExtraData&&(a=t.uploadExtraData(e,i)),a},_initXhr:function(e,i,t){var a=this;return e.upload&&e.upload.addEventListener("progress",function(e){var n=0,r=e.total,o=e.loaded||e.position;e.lengthComputable&&(n=Math.floor(o/r*100)),i?a._setAsyncUploadStatus(i,n,t):a._setProgress(n)},!1),e},_ajaxSubmit:function(i,t,a,n,r,o){var l,s=this;s._raise("filepreajax",[r,o]),s._uploadExtra(r,o),l=e.extend(!0,{},{xhr:function(){var i=e.ajaxSettings.xhr();return s._initXhr(i,r,s.getFileStack().length)},url:s.uploadUrl,type:"POST",dataType:"json",data:s.formdata,cache:!1,processData:!1,contentType:!1,beforeSend:i,success:t,complete:a,error:n},s.ajaxSettings),s.ajaxRequests.push(e.ajax(l))},_initUploadSuccess:function(i,t,a){var n,r,o,l,s,d,c,u,f,m,g=this,h=function(e,i){g[e]instanceof Array||(g[e]=[]),i&&i.length&&(g[e]=g[e].concat(i))};g.showPreview&&"object"==typeof i&&!e.isEmptyObject(i)&&void 0!==i.initialPreview&&i.initialPreview.length>0&&(g.hasInitData=!0,d=i.initialPreview||[],c=i.initialPreviewConfig||[],u=i.initialPreviewThumbTags||[],n=!(void 0!==i.append&&!i.append),d.length>0&&!re(d)&&(d=d.split(g.initialPreviewDelimiter)),g.overwriteInitial=!1,h("initialPreview",d),h("initialPreviewConfig",c),h("initialPreviewThumbTags",u),void 0!==t?a?(f=t.attr("data-fileindex"),g.uploadCache.content[f]=d[0],g.uploadCache.config[f]=c[0]||[],g.uploadCache.tags[f]=u[0]||[],g.uploadCache.append=n):(o=p.add(g.id,d,c[0],u[0],n),r=p.get(g.id,o,!1),l=e(document.createElement("div")).html(r).hide().insertAfter(t),s=l.find(".kv-zoom-cache"),s&&s.length&&s.insertAfter(t),m=g.$preview.find(".file-live-thumbs"),m.length&&v(m,"file-initial-thumbs"),t.fadeOut("slow",function(){var e=l.find(".file-preview-frame"),i=g.$preview.find("#zoom-"+t.attr("id")).closest(".kv-zoom-cache");e&&e.length&&e.insertBefore(t).fadeIn("slow").css("display:inline-block"),g._initPreviewActions(),g._clearFileInput(),i&&i.length&&i.remove(),t.remove(),l.remove(),g._initSortable()})):(p.set(g.id,d,c,u,n),g._initPreview(),g._initPreviewActions()))},_initSuccessThumbs:function(){var i=this;i.showPreview&&i._getThumbs(".file-preview-success:visible").each(function(){var t=e(this),n=i.$preview,r=t.find(".kv-file-remove");r.removeAttr("disabled"),c(r,"click",function(){var e=t.attr("id"),r=i._raise("filesuccessremove",[e,t.data("fileindex")]);ce(t),r!==!1&&t.fadeOut("slow",function(){var r=n.find("#zoom-"+e);r.length&&r.closest(".kv-zoom-cache").remove(),t.remove(),n.find(a).length||i.reset()})})})},_checkAsyncComplete:function(){var i,t,a=this;for(t=0;t<a.filestack.length;t++)if(a.filestack[t]&&(i=a.previewInitId+"-"+t,-1===e.inArray(i,a.uploadLog)))return!1;return a.uploadAsyncCount===a.uploadLog.length},_uploadExtra:function(i,t){var a=this,n=a._getExtraData(i,t);0!==n.length&&e.each(n,function(e,i){a.formdata.append(e,i)})},_uploadSingle:function(i,t,a){var n,r,o,l,s,d,c,u,f,m,g=this,h=g.getFileStack().length,w=new FormData,b=g.previewInitId+"-"+i,_=g.filestack.length>0||!e.isEmptyObject(g.uploadExtraData),C={id:b,index:i};g.formdata=w,g.showPreview&&(r=e("#"+b+":not(.file-preview-initial)"),l=r.find(".kv-file-upload"),s=r.find(".kv-file-remove"),e("#"+b).find(".file-thumb-progress").removeClass("hide")),0===h||!_||l&&l.hasClass("disabled")||g._abort(C)||(m=function(e,i){g.updateStack(e,void 0),g.uploadLog.push(i),g._checkAsyncComplete()&&(g.fileBatchCompleted=!0)},o=function(){var e=g.uploadCache;g.fileBatchCompleted&&setTimeout(function(){g.showPreview&&(p.set(g.id,e.content,e.config,e.tags,e.append),g.hasInitData&&(g._initPreview(),g._initPreviewActions())),g.unlock(),g._clearFileInput(),g._raise("filebatchuploadcomplete",[g.filestack,g._getExtraData()]),g.uploadCount=0,g.uploadStatus={},g.uploadLog=[],g._setProgress(101)},100)},d=function(t){n=g._getOutData(t),g.fileBatchCompleted=!1,g.showPreview&&(r.hasClass("file-preview-success")||(g._setThumbStatus(r,"Loading"),v(r,"file-uploading")),l.attr("disabled",!0),s.attr("disabled",!0)),a||g.lock(),g._raise("filepreupload",[n,b,i]),e.extend(!0,C,n),g._abort(C)&&(t.abort(),g._setProgressCancelled())},c=function(t,o,s){var d=g.showPreview&&r.attr("id")?r.attr("id"):b;n=g._getOutData(s,t),e.extend(!0,C,n),setTimeout(function(){ne(t)||ne(t.error)?(g.showPreview&&(g._setThumbStatus(r,"Success"),l.hide(),g._initUploadSuccess(t,r,a)),g._raise("fileuploaded",[n,d,i]),a?m(i,d):g.updateStack(i,void 0)):(g._showUploadError(t.error,C),g._setPreviewError(r,i),a&&m(i,d))},100)},u=function(){setTimeout(function(){g.showPreview&&(l.removeAttr("disabled"),s.removeAttr("disabled"),r.removeClass("file-uploading"),g._setProgress(101,e("#"+b).find(".file-thumb-progress"))),a?o():(g.unlock(!1),g._clearFileInput()),g._initSuccessThumbs()},100)},f=function(n,o,l){var s=g._parseError(n,l,a?t[i].name:null);setTimeout(function(){a&&m(i,b),g.uploadStatus[b]=100,g._setPreviewError(r,i),e.extend(!0,C,g._getOutData(n)),g._showUploadError(s,C)},100)},w.append(g.uploadFileAttr,t[i],g.filenames[i]),w.append("file_id",i),g._ajaxSubmit(d,c,u,f,b,i))},_uploadBatch:function(){var i,t,a,n,r,o=this,l=o.filestack,s=l.length,d={},c=o.filestack.length>0||!e.isEmptyObject(o.uploadExtraData);o.formdata=new FormData,0!==s&&c&&!o._abort(d)&&(r=function(){e.each(l,function(e){o.updateStack(e,void 0)}),o._clearFileInput()},i=function(i){o.lock();var t=o._getOutData(i);o.showPreview&&o._getThumbs().each(function(){var i=e(this),t=i.find(".kv-file-upload"),a=i.find(".kv-file-remove");i.hasClass("file-preview-success")||(o._setThumbStatus(i,"Loading"),v(i,"file-uploading")),t.attr("disabled",!0),a.attr("disabled",!0)}),o._raise("filebatchpreupload",[t]),o._abort(t)&&(i.abort(),o._setProgressCancelled())},t=function(i,t,a){var n=o._getOutData(a,i),l=o._getThumbs(":not(.file-preview-error)"),s=0,d=ne(i)||ne(i.errorkeys)?[]:i.errorkeys;ne(i)||ne(i.error)?(o._raise("filebatchuploadsuccess",[n]),r(),o.showPreview?(l.each(function(){var i=e(this),t=i.find(".kv-file-upload");i.find(".kv-file-upload").hide(),o._setThumbStatus(i,"Success"),i.removeClass("file-uploading"),t.removeAttr("disabled")}),o._initUploadSuccess(i)):o.reset()):(o.showPreview&&(l.each(function(){var i=e(this),t=i.find(".kv-file-remove"),a=i.find(".kv-file-upload");return i.removeClass("file-uploading"),a.removeAttr("disabled"),t.removeAttr("disabled"),0===d.length?void o._setPreviewError(i):(-1!==e.inArray(s,d)?o._setPreviewError(i):(i.find(".kv-file-upload").hide(),o._setThumbStatus(i,"Success"),o.updateStack(s,void 0)),void s++)}),o._initUploadSuccess(i)),o._showUploadError(i.error,n,"filebatchuploaderror"))},n=function(){o._setProgress(101),o.unlock(),o._initSuccessThumbs(),o._clearFileInput(),o._raise("filebatchuploadcomplete",[o.filestack,o._getExtraData()])},a=function(i,t,a){var n=o._getOutData(i),r=o._parseError(i,a);o._showUploadError(r,n,"filebatchuploaderror"),o.uploadFileCount=s-1,o.showPreview&&(o._getThumbs().each(function(){var i=e(this),t=i.attr("data-fileindex");i.removeClass("file-uploading"),void 0!==o.filestack[t]&&o._setPreviewError(i)}),o._getThumbs().removeClass("file-uploading"),o._getThumbs(" .kv-file-upload").removeAttr("disabled"),o._getThumbs(" .kv-file-delete").removeAttr("disabled"))},e.each(l,function(e,i){ne(l[e])||o.formdata.append(o.uploadFileAttr,i,o.filenames[e])}),o._ajaxSubmit(i,t,n,a))},_uploadExtraOnly:function(){var e,i,t,a,n=this,r={};n.formdata=new FormData,n._abort(r)||(e=function(e){n.lock();var i=n._getOutData(e);n._raise("filebatchpreupload",[i]),n._setProgress(50),r.data=i,r.xhr=e,n._abort(r)&&(e.abort(),n._setProgressCancelled())},i=function(e,i,t){var a=n._getOutData(t,e);ne(e)||ne(e.error)?(n._raise("filebatchuploadsuccess",[a]),n._clearFileInput(),n._initUploadSuccess(e)):n._showUploadError(e.error,a,"filebatchuploaderror")},t=function(){n._setProgress(101),n.unlock(),n._clearFileInput(),n._raise("filebatchuploadcomplete",[n.filestack,n._getExtraData()])},a=function(e,i,t){var a=n._getOutData(e),o=n._parseError(e,t);r.data=a,n._showUploadError(o,a,"filebatchuploaderror")},n._ajaxSubmit(e,i,t,a))},_initFileActions:function(){var i=this,t=i.$preview;i.showPreview&&(i._initZoomButton(),t.find(".kv-file-remove:visible").each(function(){var n,r,o,l,s=e(this),d=s.closest(a),u=d.attr("id"),f=d.attr("data-fileindex");c(s,"click",function(){return l=i._raise("filepreremove",[u,f]),l!==!1&&i._validateMinCount()?(n=d.hasClass("file-preview-error"),ce(d),void d.fadeOut("slow",function(){var l=t.find("#zoom-"+u);l.length&&l.closest(".kv-zoom-cache").remove(),i.updateStack(f,void 0),i._clearObjects(d),d.remove(),u&&n&&i.$errorContainer.find('li[data-file-id="'+u+'"]').fadeOut("fast",function(){e(this).remove(),i._errorsExist()||i._resetErrors()}),i._clearFileInput();var s=i.getFileStack(!0),c=p.count(i.id),m=s.length,g=i.showPreview&&t.find(a).length;0!==m||0!==c||g?(r=c+m,o=r>1?i._getMsgSelected(r):s[0]?i._getFileNames()[0]:"",i._setCaption(o)):i.reset(),i._raise("fileremoved",[u,f])})):!1})}),i.$preview.find(".kv-file-upload:visible").each(function(){var t=e(this);c(t,"click",function(){var e=t.closest(a),n=e.attr("data-fileindex");e.hasClass("file-preview-error")||i._uploadSingle(n,i.filestack,!1)})}))},_hideFileIcon:function(){this.overwriteInitial&&this.$captionContainer.find(".kv-caption-icon").hide()},_showFileIcon:function(){this.$captionContainer.find(".kv-caption-icon").show()},_getSize:function(e){var i=this,t=parseFloat(e);if(!e||!t||isNaN(e)||isNaN(t))return i._getLayoutTemplate("size").replace("{sizeText}","0.00 KB");var a,n,r,o=i.fileSizeGetter;return"function"==typeof o?r=o(e):(a=Math.floor(Math.log(t)/Math.log(1024)),n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=1*(t/Math.pow(1024,a)).toFixed(2)+" "+n[a]),i._getLayoutTemplate("size").replace("{sizeText}",r)},_generatePreviewTemplate:function(e,i,t,a,n,r,o,l,s,d,c){var p,u=this,f=l||"",m=u.slug(t),g=oe(e,u.previewSettings,te[e]),v="",h=s||u._renderFileFooter(m,o,g.width,r),w=u._getPreviewIcon(t),b=w&&u.preferIconicPreview,_=w&&u.preferIconicZoomPreview,C=function(i,r,o){var l=o?"zoom-"+n:n,s=u._getPreviewTemplate(i);return s=u._parseFilePreviewIcon(s,t),"text"===i&&(r=se(r)),s.replace(/\{previewId}/g,l).replace(/\{caption}/g,m).replace(/\{frameClass}/g,f).replace(/\{type}/g,a).replace(/\{fileindex}/g,d).replace(/\{width}/g,g.width).replace(/\{height}/g,g.height).replace(/\{footer}/g,h).replace(/\{data}/g,r).replace(/\{template}/g,c||e)};return d=d||n.slice(n.lastIndexOf("-")+1),u.fileActionSettings.showZoom&&(v=C(_?"other":e,i,!0)),v='\n<div class="kv-zoom-cache" style="display:none">\n'+v+"\n</div>\n",p=C(b?"other":e,i),p+v},_previewDefault:function(i,t,a){var n=this,r=n.$preview,o=r.find(".file-live-thumbs");if(n.showPreview){var s,d=i?i.name:"",c=i?i.type:"",p=a===!0&&!n.isUploadable,u=l.createObjectURL(i);n._clearDefaultPreview(),s=n._generatePreviewTemplate("other",u,d,c,t,p,i.size),o.length||(o=e(document.createElement("div")).addClass("file-live-thumbs").appendTo(r)),o.append("\n"+s),a===!0&&n.isUploadable&&n._setThumbStatus(e("#"+t),"Error")}},_previewFile:function(i,t,a,n,r){if(this.showPreview){var o,l=this,s=l._parseFileType(t),d=t?t.name:"",c=l.slug(d),p=l.allowedPreviewTypes,u=l.allowedPreviewMimeTypes,f=l.$preview,m=p&&p.indexOf(s)>=0,g=f.find(".file-live-thumbs"),v="text"===s||"html"===s||"image"===s?a.target.result:r,h=u&&-1!==u.indexOf(t.type);g.length||(g=e(document.createElement("div")).addClass("file-live-thumbs").appendTo(f)),"html"===s&&l.purifyHtml&&window.DOMPurify&&(v=window.DOMPurify.sanitize(v)),m||h?(o=l._generatePreviewTemplate(s,v,d,t.type,n,!1,t.size),l._clearDefaultPreview(),g.append("\n"+o),l._validateImage(n,c,t.type)):l._previewDefault(t,n),l._initSortable()}},_slugDefault:function(e){return ne(e)?"":String(e).replace(/[\-\[\]\/\{}:;#%=\(\)\*\+\?\\\^\$\|<>&"']/g,"_")},_readFiles:function(i){this.reader=new FileReader;var t,a=this,n=a.$element,r=a.$preview,o=a.reader,d=a.$previewContainer,c=a.$previewStatus,p=a.msgLoading,f=a.msgProgress,m=a.previewInitId,g=i.length,v=a.fileTypeSettings,h=a.filestack.length,w=a.maxFilePreviewSize&&parseFloat(a.maxFilePreviewSize),b=r.length&&(!w||isNaN(w)),_=function(n,r,o,l){var s=e.extend(!0,{},a._getOutData({},{},i),{id:o,index:l}),d={id:o,index:l,file:r,files:i};return a._previewDefault(r,o,!0),a.isUploadable&&(a.addToStack(void 0),setTimeout(function(){t(l+1)},100)),a._initFileActions(),a.removeFromPreviewOnError&&e("#"+o).remove(),a.isUploadable?a._showUploadError(n,s):a._showError(n,d)};a.loadedImages=[],a.totalImagesCount=0,e.each(i,function(e,i){var t=a.fileTypeSettings.image||ae.image;t&&t(i.type)&&a.totalImagesCount++}),t=function(e){if(ne(n.attr("multiple"))&&(g=1),e>=g)return a.isUploadable&&a.filestack.length>0?a._raise("filebatchselected",[a.getFileStack()]):a._raise("filebatchselected",[i]),d.removeClass("file-thumb-loading"),void c.html("");var C,x,y,T,F,k,E,S,$,I,P=h+e,z=m+"-"+P,D=i[e],A=D.name?a.slug(D.name):"",U=(D.size||0)/1e3,j="",L=l.createObjectURL(D),Z=0,B=a.allowedFileTypes,O="",R=B?B.length:0,M=a.allowedFileExtensions,N=ne(M)?"":M.join(", ");if(R>0)for(F=0;R>F;F++)$=B[F],I=a.msgFileTypes[$]||$,O+=0===F?I:", "+I;if(A===!1)return void t(e+1);if(0===A.length)return k=a.msgInvalidFileName.replace("{name}",se(D.name)),void(a.isError=_(k,D,z,e));if(ne(M)||(j=new RegExp("\\.("+M.join("|")+")$","i")),y=U.toFixed(2),a.maxFileSize>0&&U>a.maxFileSize)return k=a.msgSizeTooLarge.replace("{name}",A).replace("{size}",y).replace("{maxSize}",a.maxFileSize),void(a.isError=_(k,D,z,e));if(null!==a.minFileSize&&U<=u(a.minFileSize))return k=a.msgSizeTooSmall.replace("{name}",A).replace("{size}",y).replace("{minSize}",a.minFileSize),void(a.isError=_(k,D,z,e));if(!ne(B)&&re(B)){for(F=0;F<B.length;F+=1)E=B[F],T=v[E],S=void 0!==T&&T(D.type,A),Z+=ne(S)?0:S.length;if(0===Z)return k=a.msgInvalidFileType.replace("{name}",A).replace("{types}",O),void(a.isError=_(k,D,z,e))}return 0!==Z||ne(M)||!re(M)||ne(j)||(S=s(A,j),Z+=ne(S)?0:S.length,0!==Z)?a.showPreview?!b&&U>w?(a.addToStack(D),d.addClass("file-thumb-loading"),a._previewDefault(D,z),a._initFileActions(),a._updateFileDetails(g),void t(e+1)):(r.length&&void 0!==FileReader?(c.html(p.replace("{index}",e+1).replace("{files}",g)),d.addClass("file-thumb-loading"),o.onerror=function(e){a._errorHandler(e,A)},o.onload=function(i){a._previewFile(e,D,i,z,L),a._initFileActions()},o.onloadend=function(){k=f.replace("{index}",e+1).replace("{files}",g).replace("{percent}",50).replace("{name}",A),setTimeout(function(){c.html(k),a._updateFileDetails(g),t(e+1)},100),a._raise("fileloaded",[D,z,e,o])},o.onprogress=function(i){if(i.lengthComputable){var t=i.loaded/i.total*100,a=Math.ceil(t);k=f.replace("{index}",e+1).replace("{files}",g).replace("{percent}",a).replace("{name}",A),setTimeout(function(){c.html(k)},100)}},C=oe("text",v,ae.text),x=oe("image",v,ae.image),C(D.type,A)?o.readAsText(D,a.textEncoding):x(D.type,A)?o.readAsDataURL(D):o.readAsArrayBuffer(D)):(a._previewDefault(D,z),setTimeout(function(){t(e+1),a._updateFileDetails(g)},100),a._raise("fileloaded",[D,z,e,o])),void a.addToStack(D)):(a.addToStack(D),setTimeout(function(){t(e+1)},100),void a._raise("fileloaded",[D,z,e,o])):(k=a.msgInvalidFileExtension.replace("{name}",A).replace("{extensions}",N),void(a.isError=_(k,D,z,e)))},t(0),a._updateFileDetails(g,!1)},_updateFileDetails:function(e){var i=this,t=i.$element,a=i.getFileStack(),n=d(9)&&pe(t.val())||t[0].files[0]&&t[0].files[0].name||a.length&&a[0].name||"",r=i.slug(n),o=i.isUploadable?a.length:e,l=p.count(i.id)+o,s=o>1?i._getMsgSelected(l):r;i.isError?(i.$previewContainer.removeClass("file-thumb-loading"),i.$previewStatus.html(""),i.$captionContainer.find(".kv-caption-icon").hide()):i._showFileIcon(),i._setCaption(s,i.isError),i.$container.removeClass("file-input-new file-input-ajax-new"),1===arguments.length&&i._raise("fileselect",[e,r]),p.count(i.id)&&i._initPreviewActions()},_setThumbStatus:function(e,i){var t=this;if(t.showPreview){var a="indicator"+i,n=a+"Title",r="file-preview-"+i.toLowerCase(),o=e.find(".file-upload-indicator"),l=t.fileActionSettings;e.removeClass("file-preview-success file-preview-error file-preview-loading"),"Error"===i&&e.find(".kv-file-upload").attr("disabled",!0),"Success"===i&&(e.find(".file-drag-handle").remove(),o.css("margin-left",0)),o.html(l[a]),o.attr("title",l[n]),e.addClass(r)}},_setProgressCancelled:function(){var e=this;e._setProgress(101,e.$progress,e.msgCancelled)},_setProgress:function(e,i,t){var a=this,n=Math.min(e,100),r=100>n?a.progressTemplate:t?a.progressErrorTemplate:100>=e?a.progressTemplate:a.progressCompleteTemplate,o=a.progressUploadThreshold;if(i=i||a.$progress,!ne(r)){if(o&&n>o&&100>=e){var l=r.replace("{percent}",o).replace("{percent}",o).replace("{percent}%",a.msgUploadThreshold);i.html(l)}else i.html(r.replace(/\{percent}/g,n));t&&i.find('[role="progressbar"]').html(t)}},_setFileDropZoneTitle:function(){var e,i=this,t=i.$container.find(".file-drop-zone"),n=i.dropZoneTitle;i.isClickable&&(e=ne(i.$element.attr("multiple"))?i.fileSingle:i.filePlural,n+=i.dropZoneClickTitle.replace("{files}",e)),t.find("."+i.dropZoneTitleClass).remove(),i.isUploadable&&i.showPreview&&0!==t.length&&!(i.getFileStack().length>0)&&i.dropZoneEnabled&&(0===t.find(a).length&&ne(i.defaultPreviewContent)&&t.prepend('<div class="'+i.dropZoneTitleClass+'">'+n+"</div>"),i.$container.removeClass("file-input-new"),v(i.$container,"file-input-ajax-new"))},_setAsyncUploadStatus:function(i,t,a){var n=this,r=0;n._setProgress(t,e("#"+i).find(".file-thumb-progress")),n.uploadStatus[i]=t,e.each(n.uploadStatus,function(e,i){r+=i}),n._setProgress(Math.floor(r/a))},_validateMinCount:function(){var e=this,i=e.isUploadable?e.getFileStack().length:e.$element.get(0).files.length;return e.validateInitialCount&&e.minFileCount>0&&e._getFileCount(i-1)<e.minFileCount?(e._noFilesError({}),!1):!0},_getFileCount:function(e){var i=this,t=0;return i.validateInitialCount&&!i.overwriteInitial&&(t=p.count(i.id),e+=t),e},_getFileName:function(e){return e&&e.name?this.slug(e.name):void 0},_getFileNames:function(e){var i=this;return i.filenames.filter(function(i){return e?void 0!==i:void 0!==i&&null!==i})},_setPreviewError:function(e,i,t){var a=this;void 0!==i&&a.updateStack(i,t),a.removeFromPreviewOnError?e.remove():a._setThumbStatus(e,"Error")},_checkDimensions:function(e,i,t,a,n,r,o){var l,s,d,c,p=this,u="Small"===i?"min":"max",f=p[u+"Image"+r];!ne(f)&&t.length&&(d=t[0],s="Width"===r?d.naturalWidth||d.width:d.naturalHeight||d.height,c="Small"===i?s>=f:f>=s,c||(l=p["msgImage"+r+i].replace("{name}",n).replace("{size}",f),p._showUploadError(l,o),p._setPreviewError(a,e,null)))},_validateImage:function(e,i,t){var a,n,r,o=this,l=o.$preview,s=l.find("#"+e),d=s.attr("data-fileindex"),p=s.find("img");i=i||"Untitled",p.length&&c(p,"load",function(){n=s.width(),r=l.width(),n>r&&(p.css("width","100%"),s.css("width","97%")),a={ind:d,id:e},o._checkDimensions(d,"Small",p,s,i,"Width",a),o._checkDimensions(d,"Small",p,s,i,"Height",a),o.resizeImage||(o._checkDimensions(d,"Large",p,s,i,"Width",a),o._checkDimensions(d,"Large",p,s,i,"Height",a)),o._raise("fileimageloaded",[e]),o.loadedImages.push({ind:d,img:p,thumb:s,pid:e,typ:t}),o._validateAllImages()})},_validateAllImages:function(){var e,i,t,a,n,r,o=this,l={val:0};if(o.loadedImages.length===o.totalImagesCount&&(o._raise("fileimagesloaded"),o.resizeImage))for(r=o.isUploadable?o._showUploadError:o._showError,e=0;e<o.loadedImages.length;e++)i=o.loadedImages[e],t=i.img,a=i.pid,n=i.ind,o._getResizedImage(t[0],i.typ,a,n,l,o.loadedImages.length)||(r(o.msgImageResizeError,{id:a,index:n},"fileimageresizeerror"),o._setPreviewError(i.thumb,n))},_getResizedImage:function(e,i,t,a,n,r){var o,l,s=this,d=e.naturalWidth,c=e.naturalHeight,p=1,u=s.maxImageWidth||d,f=s.maxImageHeight||c,m=!(!d||!c),g=s.imageCanvas,v=s.imageCanvasContext;if(d===u&&c===f||!s.filestack[a]||!m)return m&&s.filestack[a]&&s._raise("fileimageresized",[t,a]),n.val++,n.val===r&&s._raise("fileimagesresized"),m;i=i||s.resizeDefaultImageType,o=d>u,l=c>f,p="width"===s.resizePreference?o?u/d:l?f/c:1:l?f/c:o?u/d:1,s._resetCanvas(),d*=p,c*=p,g.width=d,g.height=c;try{return v.drawImage(e,0,0,d,c),g.toBlob(function(e){s.filestack[a]=e,s._raise("fileimageresized",[t,a]),n.val++,n.val===r&&s._raise("fileimagesresized",[void 0,void 0])},i,s.resizeQuality),!0}catch(h){return n.val++,n.val===r&&s._raise("fileimagesresized",[void 0,void 0]),!1}},_initBrowse:function(e){var i=this;i.showBrowse?(i.$btnFile=e.find(".btn-file"),i.$btnFile.append(i.$element)):i.$element.hide()},_initCaption:function(){var e=this,i=e.initialCaption||"";return e.overwriteInitial||ne(i)?(e.$caption.html(""),!1):(e._setCaption(i),!0)},_setCaption:function(i,t){var a,n,r,o,l=this,s=l.getFileStack();if(l.$caption.length){if(t)a=e("<div>"+l.msgValidationError+"</div>").text(),r=s.length,o=r?1===r&&s[0]?l._getFileNames()[0]:l._getMsgSelected(r):l._getMsgSelected(l.msgNo),n='<span class="'+l.msgValidationErrorClass+'">'+l.msgValidationErrorIcon+(ne(i)?o:i)+"</span>";else{if(ne(i))return;a=e("<div>"+i+"</div>").text(),n=l._getLayoutTemplate("fileIcon")+a}l.$caption.html(n),l.$caption.attr("title",a),l.$captionContainer.find(".file-caption-ellipsis").attr("title",a)}},_createContainer:function(){var i=this,t=e(document.createElement("div")).attr({"class":"file-input file-input-new"}).html(i._renderMain());return i.$element.before(t),i._initBrowse(t),i.theme&&t.addClass("theme-"+i.theme),t},_refreshContainer:function(){var e=this,i=e.$container;i.before(e.$element),i.html(e._renderMain()),e._initBrowse(i)},_renderMain:function(){var e=this,i=e.isUploadable&&e.dropZoneEnabled?" file-drop-zone":"file-drop-disabled",t=e.showClose?e._getLayoutTemplate("close"):"",a=e.showPreview?e._getLayoutTemplate("preview").replace(/\{class}/g,e.previewClass).replace(/\{dropClass}/g,i):"",n=e.isDisabled?e.captionClass+" file-caption-disabled":e.captionClass,r=e.captionTemplate.replace(/\{class}/g,n+" kv-fileinput-caption");return e.mainTemplate.replace(/\{class}/g,e.mainClass+(!e.showBrowse&&e.showCaption?" no-browse":"")).replace(/\{preview}/g,a).replace(/\{close}/g,t).replace(/\{caption}/g,r).replace(/\{upload}/g,e._renderButton("upload")).replace(/\{remove}/g,e._renderButton("remove")).replace(/\{cancel}/g,e._renderButton("cancel")).replace(/\{browse}/g,e._renderButton("browse"))},_renderButton:function(e){var i=this,t=i._getLayoutTemplate("btnDefault"),a=i[e+"Class"],n=i[e+"Title"],r=i[e+"Icon"],o=i[e+"Label"],l=i.isDisabled?" disabled":"",s="button";switch(e){case"remove":if(!i.showRemove)return"";break;case"cancel":if(!i.showCancel)return"";a+=" hide";break;case"upload":if(!i.showUpload)return"";i.isUploadable&&!i.isDisabled?t=i._getLayoutTemplate("btnLink").replace("{href}",i.uploadUrl):s="submit";break;case"browse":if(!i.showBrowse)return"";t=i._getLayoutTemplate("btnBrowse");break;default:return""}return a+="browse"===e?" btn-file":" fileinput-"+e+" fileinput-"+e+"-button",ne(o)||(o=' <span class="'+i.buttonLabelClass+'">'+o+"</span>"),t.replace("{type}",s).replace("{css}",a).replace("{title}",n).replace("{status}",l).replace("{icon}",r).replace("{label}",o)},_renderThumbProgress:function(){return'<div class="file-thumb-progress hide">'+this.progressTemplate.replace(/\{percent}/g,"0")+"</div>"},_renderFileFooter:function(e,i,t,a){var n,r=this,o=r.fileActionSettings,l=o.showRemove,s=o.showDrag,d=o.showUpload,c=o.showZoom,p=r._getLayoutTemplate("footer"),u=a?o.indicatorError:o.indicatorNew,f=a?o.indicatorErrorTitle:o.indicatorNewTitle;return i=r._getSize(i),n=r.isUploadable?p.replace(/\{actions}/g,r._renderFileActions(d,l,c,s,!1,!1,!1)).replace(/\{caption}/g,e).replace(/\{size}/g,i).replace(/\{width}/g,t).replace(/\{progress}/g,r._renderThumbProgress()).replace(/\{indicator}/g,u).replace(/\{indicatorTitle}/g,f):p.replace(/\{actions}/g,r._renderFileActions(!1,!1,c,s,!1,!1,!1)).replace(/\{caption}/g,e).replace(/\{size}/g,i).replace(/\{width}/g,t).replace(/\{progress}/g,"").replace(/\{indicator}/g,u).replace(/\{indicatorTitle}/g,f),n=de(n,r.previewThumbTags)},_renderFileActions:function(e,i,t,a,n,r,o,l){if(!(e||i||t||a))return"";var s,d=this,c=r===!1?"":' data-url="'+r+'"',p=o===!1?"":' data-key="'+o+'"',u="",f="",m="",g="",v=d._getLayoutTemplate("actions"),h=d.fileActionSettings,w=d.otherActionButtons.replace(/\{dataKey}/g,p),b=n?h.removeClass+" disabled":h.removeClass;return i&&(u=d._getLayoutTemplate("actionDelete").replace(/\{removeClass}/g,b).replace(/\{removeIcon}/g,h.removeIcon).replace(/\{removeTitle}/g,h.removeTitle).replace(/\{dataUrl}/g,c).replace(/\{dataKey}/g,p)),e&&(f=d._getLayoutTemplate("actionUpload").replace(/\{uploadClass}/g,h.uploadClass).replace(/\{uploadIcon}/g,h.uploadIcon).replace(/\{uploadTitle}/g,h.uploadTitle)),t&&(m=d._getLayoutTemplate("actionZoom").replace(/\{zoomClass}/g,h.zoomClass).replace(/\{zoomIcon}/g,h.zoomIcon).replace(/\{zoomTitle}/g,h.zoomTitle)),a&&l&&(s="drag-handle-init "+h.dragClass,g=d._getLayoutTemplate("actionDrag").replace(/\{dragClass}/g,s).replace(/\{dragTitle}/g,h.dragTitle).replace(/\{dragIcon}/g,h.dragIcon)),v.replace(/\{delete}/g,u).replace(/\{upload}/g,f).replace(/\{zoom}/g,m).replace(/\{drag}/g,g).replace(/\{other}/g,w)},_browse:function(e){var i=this;i._raise("filebrowse"),e&&e.isDefaultPrevented()||(i.isError&&!i.isUploadable&&i.clear(),i.$captionContainer.focus())},_change:function(i){var t=this,a=t.$element;if(!t.isUploadable&&ne(a.val())&&t.fileInputCleared)return void(t.fileInputCleared=!1);t.fileInputCleared=!1;var n,r,o,l,s,d,c=arguments.length>1,u=t.isUploadable,f=0,m=c?i.originalEvent.dataTransfer.files:a.get(0).files,g=t.filestack.length,v=ne(a.attr("multiple")),h=v&&g>0,w=0,b=function(i,a,n,r){var o=e.extend(!0,{},t._getOutData({},{},m),{id:n,index:r}),l={id:n,index:r,file:a,files:m};return t.isUploadable?t._showUploadError(i,o):t._showError(i,l)};if(t.reader=null,t._resetUpload(),t._hideFileIcon(),t.isUploadable&&t.$container.find(".file-drop-zone ."+t.dropZoneTitleClass).remove(),c)for(n=[];m[f];)l=m[f],l.type||l.size%4096!==0?n.push(l):w++,f++;else n=void 0===i.target.files?i.target&&i.target.value?[{name:i.target.value.replace(/^.+\\/,"")}]:[]:i.target.files;if(ne(n)||0===n.length)return u||t.clear(),t._showFolderError(w),void t._raise("fileselectnone");if(t._resetErrors(),d=n.length,o=t._getFileCount(t.isUploadable?t.getFileStack().length+d:d),t.maxFileCount>0&&o>t.maxFileCount){if(!t.autoReplace||d>t.maxFileCount)return s=t.autoReplace&&d>t.maxFileCount?d:o,r=t.msgFilesTooMany.replace("{m}",t.maxFileCount).replace("{n}",s),t.isError=b(r,null,null,null),t.$captionContainer.find(".kv-caption-icon").hide(),t._setCaption("",!0),void t.$container.removeClass("file-input-new file-input-ajax-new");o>t.maxFileCount&&t._resetPreviewThumbs(u)}else!u||h?(t._resetPreviewThumbs(!1),h&&t.clearStack()):!u||0!==g||p.count(t.id)&&!t.overwriteInitial||t._resetPreviewThumbs(!0);t.isPreviewable?t._readFiles(n):t._updateFileDetails(1),t._showFolderError(w)},_abort:function(i){var t,a=this;return a.ajaxAborted&&"object"==typeof a.ajaxAborted&&void 0!==a.ajaxAborted.message?(t=e.extend(!0,{},a._getOutData(),i),t.abortData=a.ajaxAborted.data||{},t.abortMessage=a.ajaxAborted.message,a.cancel(),a._setProgress(101,a.$progress,a.msgCancelled),a._showUploadError(a.ajaxAborted.message,t,"filecustomerror"),!0):!1},_resetFileStack:function(){var i=this,t=0,a=[],n=[];i._getThumbs().each(function(){var r=e(this),o=r.attr("data-fileindex"),l=i.filestack[o];-1!==o&&(void 0!==l?(a[t]=l,n[t]=i._getFileName(l),r.attr({id:i.previewInitId+"-"+t,"data-fileindex":t}),t++):r.attr({id:"uploaded-"+le(),"data-fileindex":"-1"}))}),i.filestack=a,i.filenames=n},clearStack:function(){var e=this;return e.filestack=[],e.filenames=[],e.$element},updateStack:function(e,i){var t=this;return t.filestack[e]=i,t.filenames[e]=t._getFileName(i),t.$element},addToStack:function(e){var i=this;return i.filestack.push(e),i.filenames.push(i._getFileName(e)),i.$element},getFileStack:function(e){var i=this;return i.filestack.filter(function(i){return e?void 0!==i:void 0!==i&&null!==i})},getFilesCount:function(){var e=this,i=e.isUploadable?e.getFileStack().length:e.$element.get(0).files.length;return e._getFileCount(i)},lock:function(){var e=this;return e._resetErrors(),e.disable(),e.showRemove&&v(e.$container.find(".fileinput-remove"),"hide"),e.showCancel&&e.$container.find(".fileinput-cancel").removeClass("hide"),e._raise("filelock",[e.filestack,e._getExtraData()]),e.$element},unlock:function(e){var i=this;return void 0===e&&(e=!0),i.enable(),i.showCancel&&v(i.$container.find(".fileinput-cancel"),"hide"),i.showRemove&&i.$container.find(".fileinput-remove").removeClass("hide"),e&&i._resetFileStack(),i._raise("fileunlock",[i.filestack,i._getExtraData()]),i.$element},cancel:function(){var i,t=this,a=t.ajaxRequests,n=a.length;if(n>0)for(i=0;n>i;i+=1)t.cancelling=!0,a[i].abort();return t._setProgressCancelled(),t._getThumbs().each(function(){var i=e(this),a=i.attr("data-fileindex");i.removeClass("file-uploading"),void 0!==t.filestack[a]&&(i.find(".kv-file-upload").removeClass("disabled").removeAttr("disabled"),
    i.find(".kv-file-remove").removeClass("disabled").removeAttr("disabled")),t.unlock()}),t.$element},clear:function(){var i,t=this;return t.$btnUpload.removeAttr("disabled"),t._getThumbs().find("video,audio,img").each(function(){ce(e(this))}),t._resetUpload(),t.clearStack(),t._clearFileInput(),t._resetErrors(!0),t._raise("fileclear"),t._hasInitialPreview()?(t._showFileIcon(),t._resetPreview(),t._initPreviewActions(),t.$container.removeClass("file-input-new")):(t._getThumbs().each(function(){t._clearObjects(e(this))}),t.isUploadable&&(p.data[t.id]={}),t.$preview.html(""),i=!t.overwriteInitial&&t.initialCaption.length>0?t.initialCaption:"",t.$caption.html(i),t.$caption.attr("title",""),v(t.$container,"file-input-new"),t._validateDefaultPreview()),0===t.$container.find(a).length&&(t._initCaption()||t.$captionContainer.find(".kv-caption-icon").hide()),t._hideFileIcon(),t._raise("filecleared"),t.$captionContainer.focus(),t._setFileDropZoneTitle(),t.$element},reset:function(){var e=this;return e._resetPreview(),e.$container.find(".fileinput-filename").text(""),e._raise("filereset"),v(e.$container,"file-input-new"),(e.$preview.find(a).length||e.isUploadable&&e.dropZoneEnabled)&&e.$container.removeClass("file-input-new"),e._setFileDropZoneTitle(),e.clearStack(),e.formdata={},e.$element},disable:function(){var e=this;return e.isDisabled=!0,e._raise("filedisabled"),e.$element.attr("disabled","disabled"),e.$container.find(".kv-fileinput-caption").addClass("file-caption-disabled"),e.$container.find(".btn-file, .fileinput-remove, .fileinput-upload, .file-preview-frame button").attr("disabled",!0),e._initDragDrop(),e.$element},enable:function(){var e=this;return e.isDisabled=!1,e._raise("fileenabled"),e.$element.removeAttr("disabled"),e.$container.find(".kv-fileinput-caption").removeClass("file-caption-disabled"),e.$container.find(".btn-file, .fileinput-remove, .fileinput-upload, .file-preview-frame button").removeAttr("disabled"),e._initDragDrop(),e.$element},upload:function(){var i,t,a,n=this,r=n.getFileStack().length,o={},l=!e.isEmptyObject(n._getExtraData());if(n.isUploadable&&!n.isDisabled){if(n.minFileCount>0&&n._getFileCount(r)<n.minFileCount)return void n._noFilesError(o);if(0===r&&!l)return n._resetUpload(),void n._showUploadError(n.msgUploadEmpty);if(n._resetUpload(),n.$progress.removeClass("hide"),n.uploadCount=0,n.uploadStatus={},n.uploadLog=[],n.lock(),n._setProgress(2),0===r&&l)return void n._uploadExtraOnly();if(a=n.filestack.length,n.hasInitData=!1,!n.uploadAsync)return n._uploadBatch(),n.$element;for(t=n._getOutData(),n._raise("filebatchpreupload",[t]),n.fileBatchCompleted=!1,n.uploadCache={content:[],config:[],tags:[],append:!0},n.uploadAsyncCount=n.getFileStack().length,i=0;a>i;i++)n.uploadCache.content[i]=null,n.uploadCache.config[i]=null,n.uploadCache.tags[i]=null;for(i=0;a>i;i++)void 0!==n.filestack[i]&&n._uploadSingle(i,n.filestack,!0)}},destroy:function(){var e=this,t=e.$container;return t.find(".file-drop-zone").off(),e.$element.insertBefore(t).off(i).removeData(),t.off().remove(),e.$element},refresh:function(i){var t=this,a=t.$element;return i=i?e.extend(!0,{},t.options,i):t.options,t.destroy(),a.fileinput(i),a.val()&&a.trigger("change.fileinput"),a}},e.fn.fileinput=function(i){if(f()||d(9)){var t=Array.apply(null,arguments),a=[];switch(t.shift(),this.each(function(){var n,r=e(this),o=r.data("fileinput"),l="object"==typeof i&&i,s=l.theme||r.data("theme"),d={},c={},p=l.language||r.data("language")||e.fn.fileinput.defaults.language||"en";o||(s&&(c=e.fn.fileinputThemes[s]||{}),"en"===p||ne(e.fn.fileinputLocales[p])||(d=e.fn.fileinputLocales[p]||{}),n=e.extend(!0,{},e.fn.fileinput.defaults,c,e.fn.fileinputLocales.en,d,l,r.data()),o=new ge(this,n),r.data("fileinput",o)),"string"==typeof i&&a.push(o[i].apply(o,t))}),a.length){case 0:return this;case 1:return a[0];default:return a}}},e.fn.fileinput.defaults={language:"en",showCaption:!0,showBrowse:!0,showPreview:!0,showRemove:!0,showUpload:!0,showCancel:!0,showClose:!0,showUploadedThumbs:!0,browseOnZoneClick:!1,autoReplace:!1,previewClass:"",captionClass:"",mainClass:"file-caption-main",mainTemplate:null,purifyHtml:!0,fileSizeGetter:null,initialCaption:"",initialPreview:[],initialPreviewDelimiter:"*$$*",initialPreviewAsData:!1,initialPreviewFileType:"image",initialPreviewConfig:[],initialPreviewThumbTags:[],previewThumbTags:{},initialPreviewShowDelete:!0,removeFromPreviewOnError:!1,deleteUrl:"",deleteExtraData:{},overwriteInitial:!0,layoutTemplates:Y,previewTemplates:J,previewZoomSettings:Q,previewZoomButtonIcons:{prev:'<i class="glyphicon glyphicon-triangle-left"></i>',next:'<i class="glyphicon glyphicon-triangle-right"></i>',toggleheader:'<i class="glyphicon glyphicon-resize-vertical"></i>',fullscreen:'<i class="glyphicon glyphicon-fullscreen"></i>',borderless:'<i class="glyphicon glyphicon-resize-full"></i>',close:'<i class="glyphicon glyphicon-remove"></i>'},previewZoomButtonClasses:{prev:"btn btn-navigate",next:"btn btn-navigate",toggleheader:"btn btn-default btn-header-toggle",fullscreen:"btn btn-default",borderless:"btn btn-default",close:"btn btn-default"},preferIconicPreview:!1,preferIconicZoomPreview:!1,allowedPreviewTypes:ee,allowedPreviewMimeTypes:null,allowedFileTypes:null,allowedFileExtensions:null,defaultPreviewContent:null,customLayoutTags:{},customPreviewTags:{},previewSettings:te,fileTypeSettings:ae,previewFileIcon:'<i class="glyphicon glyphicon-file"></i>',previewFileIconClass:"file-other-icon",previewFileIconSettings:{},previewFileExtSettings:{},buttonLabelClass:"hidden-xs",browseIcon:'<i class="glyphicon glyphicon-folder-open"></i>&nbsp;',browseClass:"btn btn-primary",removeIcon:'<i class="glyphicon glyphicon-trash"></i>',removeClass:"btn btn-default",cancelIcon:'<i class="glyphicon glyphicon-ban-circle"></i>',cancelClass:"btn btn-default",uploadIcon:'<i class="glyphicon glyphicon-upload"></i>',uploadClass:"btn btn-default",uploadUrl:null,uploadAsync:!0,uploadExtraData:{},zoomModalHeight:480,minImageWidth:null,minImageHeight:null,maxImageWidth:null,maxImageHeight:null,resizeImage:!1,resizePreference:"width",resizeQuality:.92,resizeDefaultImageType:"image/jpeg",minFileSize:0,maxFileSize:0,maxFilePreviewSize:25600,minFileCount:0,maxFileCount:0,validateInitialCount:!1,msgValidationErrorClass:"text-danger",msgValidationErrorIcon:'<i class="glyphicon glyphicon-exclamation-sign"></i> ',msgErrorClass:"file-error-message",progressThumbClass:"progress-bar progress-bar-success progress-bar-striped active",progressClass:"progress-bar progress-bar-success progress-bar-striped active",progressCompleteClass:"progress-bar progress-bar-success",progressErrorClass:"progress-bar progress-bar-danger",progressUploadThreshold:99,previewFileType:"image",elCaptionContainer:null,elCaptionText:null,elPreviewContainer:null,elPreviewImage:null,elPreviewStatus:null,elErrorContainer:null,errorCloseButton:'<span class="close kv-error-close">&times;</span>',slugCallback:null,dropZoneEnabled:!0,dropZoneTitleClass:"file-drop-zone-title",fileActionSettings:{},otherActionButtons:"",textEncoding:"UTF-8",ajaxSettings:{},ajaxDeleteSettings:{},showAjaxErrorDetails:!0},e.fn.fileinputLocales.en={fileSingle:"file",filePlural:"files",browseLabel:"Browse &hellip;",removeLabel:"Remove",removeTitle:"Clear selected files",cancelLabel:"Cancel",cancelTitle:"Abort ongoing upload",uploadLabel:"Upload",uploadTitle:"Upload selected files",msgNo:"No",msgNoFilesSelected:"No files selected",msgCancelled:"Cancelled",msgZoomModalHeading:"Detailed Preview",msgSizeTooSmall:'File "{name}" (<b>{size} KB</b>) is too small and must be larger than <b>{minSize} KB</b>.',msgSizeTooLarge:'File "{name}" (<b>{size} KB</b>) exceeds maximum allowed upload size of <b>{maxSize} KB</b>.',msgFilesTooLess:"You must select at least <b>{n}</b> {files} to upload.",msgFilesTooMany:"Number of files selected for upload <b>({n})</b> exceeds maximum allowed limit of <b>{m}</b>.",msgFileNotFound:'File "{name}" not found!',msgFileSecured:'Security restrictions prevent reading the file "{name}".',msgFileNotReadable:'File "{name}" is not readable.',msgFilePreviewAborted:'File preview aborted for "{name}".',msgFilePreviewError:'An error occurred while reading the file "{name}".',msgInvalidFileName:'Invalid or unsupported characters in file name "{name}".',msgInvalidFileType:'Invalid type for file "{name}". Only "{types}" files are supported.',msgInvalidFileExtension:'Invalid extension for file "{name}". Only "{extensions}" files are supported.',msgFileTypes:{image:"image",html:"HTML",text:"text",video:"video",audio:"audio",flash:"flash",pdf:"PDF",object:"object"},msgUploadAborted:"The file upload was aborted",msgUploadThreshold:"Processing...",msgUploadEmpty:"No valid data available for upload.",msgValidationError:"Validation Error",msgLoading:"Loading file {index} of {files} &hellip;",msgProgress:"Loading file {index} of {files} - {name} - {percent}% completed.",msgSelected:"{n} {files} selected",msgFoldersNotAllowed:"Drag & drop files only! {n} folder(s) dropped were skipped.",msgImageWidthSmall:'Width of image file "{name}" must be at least {size} px.',msgImageHeightSmall:'Height of image file "{name}" must be at least {size} px.',msgImageWidthLarge:'Width of image file "{name}" cannot exceed {size} px.',msgImageHeightLarge:'Height of image file "{name}" cannot exceed {size} px.',msgImageResizeError:"Could not get the image dimensions to resize.",msgImageResizeException:"Error while resizing the image.<pre>{errors}</pre>",dropZoneTitle:"Drag & drop files here &hellip;",dropZoneClickTitle:"<br>(or click to select {files})",previewZoomButtonTitles:{prev:"View previous file",next:"View next file",toggleheader:"Toggle header",fullscreen:"Toggle full screen",borderless:"Toggle borderless mode",close:"Close detailed preview"}},e.fn.fileinput.Constructor=ge,e(document).ready(function(){var i=e("input.file[type=file]");i.length&&i.fileinput()})});