/**
 * Tagify (v3.21.0) - tags input component
 * By Yair Even-Or
 * Don't sell this code. (c)
 * https://github.com/yairEO/tagify
 */

!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.React.tagify=t()}(this,function(){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.MixedTags=void 0;var e,G=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==i(e)&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var u=r?Object.getOwnPropertyDescriptor(e,o):null;u&&(u.get||u.set)?Object.defineProperty(n,o,u):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(require("react")),H=require("react-dom/server"),t=require("prop-types"),L=(e=require("./tagify.min.js"))&&e.__esModule?e:{default:e};function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(r=0;r<u.length;r++)n=u[r],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Q(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function U(e){return e}function n(e){function t(e){J.current=e}var n=e.name,r=e.value,o=void 0===r?"":r,u=e.loading,i=void 0!==u&&u,a=e.onInput,c=void 0===a?U:a,l=e.onAdd,f=void 0===l?U:l,s=e.onRemove,d=void 0===s?U:s,p=e.onEdit,y=void 0===p?U:p,g=e.onInvalid,v=void 0===g?U:g,m=e.onClick,b=void 0===m?U:m,h=e.onKeydown,O=void 0===h?U:h,w=e.onFocus,j=void 0===w?U:w,E=e.onBlur,x=void 0===E?U:E,M=e.onChange,S=void 0===M?U:M,P=e.readOnly,T=e.children,R=e.settings,k=void 0===R?{}:R,I=e.InputMode,A=void 0===I?"input":I,C=e.autoFocus,N=e.className,_=e.whitelist,F=e.tagifyRef,q=e.placeholder,D=void 0===q?"":q,V=e.defaultValue,W=e.showDropdown,B=(0,G.useRef)(),J=(0,G.useRef)(),K=(0,G.useRef)(),z=(0,G.useMemo)(function(){return{ref:t,name:n,value:T||("string"==typeof o?o:JSON.stringify(o)),className:N,readOnly:P,onChange:S,autoFocus:C,placeholder:D,defaultValue:V}},[]);return(0,G.useEffect)(function(){!function(e){if(e)for(var n in e){String(e[n]).includes(".createElement")&&function(){var t=e[n];e[n]=function(e){return(0,H.renderToStaticMarkup)(G.default.createElement(t,e))}}()}}(k.templates),"textarea"==A&&(k.mode="mix"),_&&_.length&&(k.whitelist=_);var e=new L.default(J.current,k);return c&&e.on("input",c),f&&e.on("add",f),d&&e.on("remove",d),y&&e.on("edit",y),v&&e.on("invalid",v),O&&e.on("keydown",O),j&&e.on("focus",j),x&&e.on("blur",x),b&&e.on("click",b),F&&(F.current=e),K.current=e,function(){e.destroy()}},[]),(0,G.useEffect)(function(){var e;B.current&&(K.current.settings.whitelist.length=0,_&&_.length&&(e=K.current.settings.whitelist).push.apply(e,Q(_)))},[_]),(0,G.useEffect)(function(){B.current&&K.current.loadOriginalValues(o)},[o]),(0,G.useEffect)(function(){B.current&&K.current.toggleClass(N)},[N]),(0,G.useEffect)(function(){B.current&&K.current.loading(i)},[i]),(0,G.useEffect)(function(){B.current&&K.current.setReadonly(P)},[P]),(0,G.useEffect)(function(){var e=K.current;B.current&&(W?(e.dropdown.show.call(e,W),e.toggleFocusClass(!0)):e.dropdown.hide.call(e))},[W]),(0,G.useEffect)(function(){B.current=!0},[]),G.default.createElement("div",{className:"tags-input"},G.default.createElement(A,z))}n.propTypes={name:t.string,value:(0,t.oneOfType)([t.string,t.array]),loading:t.bool,children:t.element,onChange:t.func,readOnly:t.bool,settings:t.object,InputMode:t.string,autoFocus:t.bool,className:t.string,tagifyRef:t.object,whitelist:t.array,placeholder:t.string,defaultValue:(0,t.oneOfType)([t.string,t.array]),showDropdown:(0,t.oneOfType)([t.string,t.bool])};var u=G.default.memo(n);u.displayName="Tags";exports.MixedTags=function(e){var t=e.children,n=o(e,["children"]);return G.default.createElement(u,r({InputMode:"textarea"},n),t)};var c=u;return exports.default=c,u});