define(["require","exports","tslib","react","./constants","./FormElementOuter","./keyboard","./utils","./assets/stock","./common"],function(e,t,S,F,M,x,A,L,R,O){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),F=S.__importDefault(F),x=S.__importDefault(x);var n,T=(n=F.default.Component,S.__extends(r,n),r.prototype.render=function(){var t=this;return F.default.createElement("div",S.__assign({ref:function(e){return t.root=e}},this.props))},r);function r(){return null!==n&&n.apply(this,arguments)||this}t.renderGeometryPicker=function(t,n){var r,l=(_=t.props).name,o=_.host,e=5;"number"==typeof(E=n.size)&&(e=1<E?Math.ceil(E):1);var a,s="✎",u=n.value=L.sanitizeGeometryRef(n.value);void 0!==u&&(a=u.geometry,N=n.itemLabel,Array.isArray(N)?r=N:(r=[],L.text.isMarkdown(N)?N.markdown&&(s=N):L.text.isStatus(N)?N.status&&(s=N.status):N&&(s=N)));var c=n.state;function d(e){var t=c[e];return null==t&&(c.length<=e&&(c.length=e,c.push({})),t=c[e]),t}null==c&&(c=n.state=[]);var i=t.enabled;function f(t,n){var r;function a(){var e=d(t);e.checked=i&&r.checked,e.focused=i&&r.focused,e.pending=i&&r.pending,n&&o.renderState(l,"geometry",c),L.setClass(r.root,"checked",e.checked),L.setClass(r.root,"focus",e.focused),L.setClass(r.root,"hover",e.pending)}return void 0===n&&(n=!0),{ref:function(e){null!==(r=e)&&a()},onChangeCapture:function(e){r&&(r.checked=null!==e.currentTarget.querySelector("input:checked"),a())},onFocusCapture:function(e){r&&(r.focused=!0,a())},onBlurCapture:function(){r&&(r.focused=!1,a())},onMouseOver:function(){r&&(r.pending=!0,a())},onMouseOut:function(){r&&(r.pending=!1,a())},onKeyDownCapture:function(e){i&&"delete"===A.getKeyString(e)&&void 0!==d(t).content&&m(t)()}}}function m(e){return function(){1<a.length?(a.splice(e,1),c.splice(e,1),e<r.length&&r.splice(e,1)):(n.value=void 0,n.state=void 0),t.forceUpdate(),o.post("changed",{name:l,value:u})}}var p=t.enabled,v=[];if(void 0!==u)for(var p=t.enabled&&u.geometry.length<e,h=0,g=u.geometry;h<g.length;h++){var y=g[h],b=v.length;d(b).content=y;y={__html:o.renderHtml(r[b]||s)};v.push(F.default.createElement(T,S.__assign({className:"shape",key:"$"+b},f(b)),F.default.createElement("div",null,F.default.createElement("label",null,F.default.createElement("input",{type:"checkbox",disabled:!t.enabled,ref:function(t){return function(e){null!==e&&(e.disabled||o.renderFocus(e,l),e.checked=d(t).checked)}}(b)}),F.default.createElement("div",{className:"inline",dangerouslySetInnerHTML:y})),F.default.createElement("button",{className:"delete",disabled:!t.enabled,ref:function(e){return O.renderFocus(e,l,o)},onClick:m(b)},R.renderRemove()))))}function k(){o.post("clicked",{name:l,value:u})}void 0!==u&&u.format;var C={__html:o.renderHtml(n.prompt)},_=o.renderText(n.tooltip),E=v.length,N=t.enabled&&void 0!==u;return v.push(F.default.createElement(T,S.__assign({className:"add-shape",key:"footer"},f(E,!1)),F.default.createElement("button",{className:"add",disabled:!p,title:_,ref:function(e){return O.renderFocus(e,l,o)},onClick:k},R.renderCrossAdd(),F.default.createElement("div",{className:"inline",dangerouslySetInnerHTML:C})),F.default.createElement("button",{className:"clear",disabled:!N,ref:function(e){return O.renderFocus(e,l,o)},onClick:function(){u=n.value=void 0,t.forceUpdate(),o.post("changed",{name:l,value:u})}},R.renderArrowRollup()))),N=[n.type,L.makeSafeClassName(l)],1===e&&N.push(M.CssClasses.SINGLE),void 0!==u&&u.geometry.length>=e&&N.push(M.CssClasses.FULL),t.enabled&&n.autoActivate&&(p&&setTimeout(k),delete n.autoActivate),F.default.createElement(x.default,{className:N.join(" "),component:t,element:n,errorClassName:M.CssClasses.ERROR,ref:function(e){null===e&&o.renderState(l,"geometry")}},F.default.createElement("div",{className:"items"},v))}});