!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require,exports):"function"==typeof define&&define.amd&&define(["require","exports","tslib","react","./common","./constants","./FormElementOuter","./utils","./assets/stock"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l=e("tslib"),b=l.__importDefault(e("react")),h=e("./common"),g=e("./constants"),y=l.__importDefault(e("./FormElementOuter")),k=e("./utils"),E=e("./assets/stock");t.renderFilePicker=function(n,r){var t,s=(c=n.props).host,l=c.name,e=r.size,i=r.value,o=5;"number"==typeof e&&(o=1<e?Math.ceil(e):1),i&&(k.isFilesRef(i)&&Array.isArray(i.files)||(r.value=i=void 0));var a=s.renderText(r.tooltip),c=n.enabled,u=[];if(void 0!==i)for(var c=n.enabled&&i.files.length<o,f=0,d=i.files;f<d.length;f++){var m=d[f],p=u.length;u.push(b.default.createElement("div",{className:"file",key:"$"+p},b.default.createElement("div",null,b.default.createElement("label",null,m.name),b.default.createElement("button",{"aria-label":s.renderText("@file-picker-remove-item-label"),className:"delete",disabled:!n.enabled,ref:function(e){return h.renderFocus(e,l,s)},onClick:function(e){return function(){1<i.files.length?i.files.splice(e,1):r.value=void 0,n.forceUpdate(),s.post("changed",{name:l,value:r.value})}}(p)},E.renderRemove()))))}var v=function(e){if(e){var t=e.getAttribute("class");if(/\bneedsclick\b/.test(t)||e.setAttribute("class",t?t+" needsclick":"needsclick"),"svg"!==e.tagName)for(var l=e.children,a=0;a<l.length;a++)v(l[a])}};return u.push(b.default.createElement("div",{className:"add-file",key:"footer"},b.default.createElement("button",{className:"add",disabled:!c,title:a,ref:function(e){h.renderFocus(e,l,s),v(e)},onClick:function(){t.value=null,t.click()}},E.renderCrossAdd(),b.default.createElement("div",{className:"inline",dangerouslySetInnerHTML:{__html:s.renderHtml(r.prompt)}})))),e=[r.type,k.makeSafeClassName(l)],c=1!==o,b.default.createElement(y.default,{className:e.join(" "),component:n,element:r,errorClassName:g.CssClasses.ERROR},b.default.createElement("div",{className:"items"},u),b.default.createElement("input",{type:"file",style:{display:"none"},title:a,onChange:function(e){return function(e){var t=e.files;if(t&&t.length){for(var l=i&&i.files||[],a=0;a<t.length&&l.length!==o;a++)l.push(t[a]);e={refValueType:"files",files:l};r.value=e,n.forceUpdate(),s.post("changed",{name:n.props.name,value:e})}}(e.target)},multiple:c,accept:r.fileTypes,ref:function(e){t=e}}))}});