define(["require","exports","tslib","react","./common","./constants","./FormElementOuter","./utils","./assets/stock"],function(e,t,l,h,b,g,y,k,E){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),h=l.__importDefault(h),y=l.__importDefault(y),t.renderFilePicker=function(n,r){var t,s=(u=n.props).host,l=u.name,e=r.size,i=r.value,c=5;"number"==typeof e&&(c=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),u=n.enabled,f=[];if(void 0!==i)for(var u=n.enabled&&i.files.length<c,o=0,d=i.files;o<d.length;o++){var m=d[o],p=f.length;f.push(h.default.createElement("div",{className:"file",key:"$"+p},h.default.createElement("div",null,h.default.createElement("label",null,m.name),h.default.createElement("button",{"aria-label":s.renderText("@file-picker-remove-item-label"),className:"delete",disabled:!n.enabled,ref:function(e){return b.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 f.push(h.default.createElement("div",{className:"add-file",key:"footer"},h.default.createElement("button",{className:"add",disabled:!u,title:a,ref:function(e){b.renderFocus(e,l,s),v(e)},onClick:function(){t.value=null,t.click()}},E.renderCrossAdd(),h.default.createElement("div",{className:"inline",dangerouslySetInnerHTML:{__html:s.renderHtml(r.prompt)}})))),e=[r.type,k.makeSafeClassName(l)],u=1!==c,h.default.createElement(y.default,{className:e.join(" "),component:n,element:r,errorClassName:g.CssClasses.ERROR},h.default.createElement("div",{className:"items"},f),h.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!==c;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:u,accept:r.fileTypes,ref:function(e){t=e}}))}});