multi-source-select
Version:
Multi-source select control
28 lines (24 loc) • 38.9 kB
JavaScript
var pr=require("./MultiSelect.css");Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const he=require("react");function It(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const w=It(he);var He={exports:{}},Ye={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ot;function At(){if(ot)return Ye;ot=1;var t=he,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,f=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,y={key:!0,ref:!0,__self:!0,__source:!0};function p(d,m,_){var R,C={},B=null,N=null;_!==void 0&&(B=""+_),m.key!==void 0&&(B=""+m.key),m.ref!==void 0&&(N=m.ref);for(R in m)i.call(m,R)&&!y.hasOwnProperty(R)&&(C[R]=m[R]);if(d&&d.defaultProps)for(R in m=d.defaultProps,m)C[R]===void 0&&(C[R]=m[R]);return{$$typeof:n,type:d,key:B,ref:N,props:C,_owner:f.current}}return Ye.Fragment=r,Ye.jsx=p,Ye.jsxs=p,Ye}var Be={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var at;function $t(){return at||(at=1,process.env.NODE_ENV!=="production"&&function(){var t=he,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),p=Symbol.for("react.provider"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),N=Symbol.for("react.offscreen"),J=Symbol.iterator,L="@@iterator";function z(e){if(e===null||typeof e!="object")return null;var a=J&&e[J]||e[L];return typeof a=="function"?a:null}var g=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function s(e){{for(var a=arguments.length,u=new Array(a>1?a-1:0),b=1;b<a;b++)u[b-1]=arguments[b];k("error",e,u)}}function k(e,a,u){{var b=g.ReactDebugCurrentFrame,A=b.getStackAddendum();A!==""&&(a+="%s",u=u.concat([A]));var $=u.map(function(F){return String(F)});$.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,$)}}var U=!1,P=!1,te=!1,oe=!1,X=!1,re;re=Symbol.for("react.module.reference");function ce(e){return!!(typeof e=="string"||typeof e=="function"||e===i||e===y||X||e===f||e===_||e===R||oe||e===N||U||P||te||typeof e=="object"&&e!==null&&(e.$$typeof===B||e.$$typeof===C||e.$$typeof===p||e.$$typeof===d||e.$$typeof===m||e.$$typeof===re||e.getModuleId!==void 0))}function ae(e,a,u){var b=e.displayName;if(b)return b;var A=a.displayName||a.name||"";return A!==""?u+"("+A+")":u}function Q(e){return e.displayName||"Context"}function x(e){if(e==null)return null;if(typeof e.tag=="number"&&s("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case i:return"Fragment";case r:return"Portal";case y:return"Profiler";case f:return"StrictMode";case _:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case d:var a=e;return Q(a)+".Consumer";case p:var u=e;return Q(u._context)+".Provider";case m:return ae(e,e.render,"ForwardRef");case C:var b=e.displayName||null;return b!==null?b:x(e.type)||"Memo";case B:{var A=e,$=A._payload,F=A._init;try{return x(F($))}catch{return null}}}return null}var D=Object.assign,h=0,E,V,ie,se,ke,I,ne;function K(){}K.__reactDisabledLog=!0;function _e(){{if(h===0){E=console.log,V=console.info,ie=console.warn,se=console.error,ke=console.group,I=console.groupCollapsed,ne=console.groupEnd;var e={configurable:!0,enumerable:!0,value:K,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}h++}}function ue(){{if(h--,h===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:E}),info:D({},e,{value:V}),warn:D({},e,{value:ie}),error:D({},e,{value:se}),group:D({},e,{value:ke}),groupCollapsed:D({},e,{value:I}),groupEnd:D({},e,{value:ne})})}h<0&&s("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ee=g.ReactCurrentDispatcher,Re;function ve(e,a,u){{if(Re===void 0)try{throw Error()}catch(A){var b=A.stack.trim().match(/\n( *(at )?)/);Re=b&&b[1]||""}return`
`+Re+e}}var je=!1,Ce;{var fe=typeof WeakMap=="function"?WeakMap:Map;Ce=new fe}function Te(e,a){if(!e||je)return"";{var u=Ce.get(e);if(u!==void 0)return u}var b;je=!0;var A=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $;$=Ee.current,Ee.current=null,_e();try{if(a){var F=function(){throw Error()};if(Object.defineProperty(F.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(F,[])}catch(xe){b=xe}Reflect.construct(e,[],F)}else{try{F.call()}catch(xe){b=xe}e.call(F.prototype)}}else{try{throw Error()}catch(xe){b=xe}e()}}catch(xe){if(xe&&b&&typeof xe.stack=="string"){for(var T=xe.stack.split(`
`),ee=b.stack.split(`
`),G=T.length-1,H=ee.length-1;G>=1&&H>=0&&T[G]!==ee[H];)H--;for(;G>=1&&H>=0;G--,H--)if(T[G]!==ee[H]){if(G!==1||H!==1)do if(G--,H--,H<0||T[G]!==ee[H]){var le=`
`+T[G].replace(" at new "," at ");return e.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",e.displayName)),typeof e=="function"&&Ce.set(e,le),le}while(G>=1&&H>=0);break}}}finally{je=!1,Ee.current=$,ue(),Error.prepareStackTrace=A}var Ne=e?e.displayName||e.name:"",nt=Ne?ve(Ne):"";return typeof e=="function"&&Ce.set(e,nt),nt}function Me(e,a,u){return Te(e,!1)}function Fe(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function me(e,a,u){if(e==null)return"";if(typeof e=="function")return Te(e,Fe(e));if(typeof e=="string")return ve(e);switch(e){case _:return ve("Suspense");case R:return ve("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case m:return Me(e.render);case C:return me(e.type,a,u);case B:{var b=e,A=b._payload,$=b._init;try{return me($(A),a,u)}catch{}}}return""}var ye=Object.prototype.hasOwnProperty,Pe={},Ie=g.ReactDebugCurrentFrame;function Se(e){if(e){var a=e._owner,u=me(e.type,e._source,a?a.type:null);Ie.setExtraStackFrame(u)}else Ie.setExtraStackFrame(null)}function De(e,a,u,b,A){{var $=Function.call.bind(ye);for(var F in e)if($(e,F)){var T=void 0;try{if(typeof e[F]!="function"){var ee=Error((b||"React class")+": "+u+" type `"+F+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[F]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ee.name="Invariant Violation",ee}T=e[F](a,F,b,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(G){T=G}T&&!(T instanceof Error)&&(Se(A),s("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",u,F,typeof T),Se(null)),T instanceof Error&&!(T.message in Pe)&&(Pe[T.message]=!0,Se(A),s("Failed %s type: %s",u,T.message),Se(null))}}}var Le=Array.isArray;function we(e){return Le(e)}function Ve(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,u=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function Ue(e){try{return Ae(e),!1}catch{return!0}}function Ae(e){return""+e}function $e(e){if(Ue(e))return s("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ve(e)),Ae(e)}var be=g.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0},S,M,W;W={};function q(e){if(ye.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function o(e){if(ye.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function c(e,a){if(typeof e.ref=="string"&&be.current&&a&&be.current.stateNode!==a){var u=x(be.current.type);W[u]||(s('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',x(be.current.type),e.ref),W[u]=!0)}}function v(e,a){{var u=function(){S||(S=!0,s("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function j(e,a){{var u=function(){M||(M=!0,s("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var Y=function(e,a,u,b,A,$,F){var T={$$typeof:n,type:e,key:a,ref:u,props:F,_owner:$};return T._store={},Object.defineProperty(T._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(T,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(T,"_source",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.freeze&&(Object.freeze(T.props),Object.freeze(T)),T};function Z(e,a,u,b,A){{var $,F={},T=null,ee=null;u!==void 0&&($e(u),T=""+u),o(a)&&($e(a.key),T=""+a.key),q(a)&&(ee=a.ref,c(a,A));for($ in a)ye.call(a,$)&&!l.hasOwnProperty($)&&(F[$]=a[$]);if(e&&e.defaultProps){var G=e.defaultProps;for($ in G)F[$]===void 0&&(F[$]=G[$])}if(T||ee){var H=typeof e=="function"?e.displayName||e.name||"Unknown":e;T&&v(F,H),ee&&j(F,H)}return Y(e,T,ee,A,b,be.current,F)}}var pe=g.ReactCurrentOwner,We=g.ReactDebugCurrentFrame;function de(e){if(e){var a=e._owner,u=me(e.type,e._source,a?a.type:null);We.setExtraStackFrame(u)}else We.setExtraStackFrame(null)}var ze;ze=!1;function Ke(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function Ze(){{if(pe.current){var e=x(pe.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function _t(e){{if(e!==void 0){var a=e.fileName.replace(/^.*[\\\/]/,""),u=e.lineNumber;return`
Check your code at `+a+":"+u+"."}return""}}var Qe={};function Rt(e){{var a=Ze();if(!a){var u=typeof e=="string"?e:e.displayName||e.name;u&&(a=`
Check the top-level render call using <`+u+">.")}return a}}function et(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=Rt(a);if(Qe[u])return;Qe[u]=!0;var b="";e&&e._owner&&e._owner!==pe.current&&(b=" It was passed a child from "+x(e._owner.type)+"."),de(e),s('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,b),de(null)}}function tt(e,a){{if(typeof e!="object")return;if(we(e))for(var u=0;u<e.length;u++){var b=e[u];Ke(b)&&et(b,a)}else if(Ke(e))e._store&&(e._store.validated=!0);else if(e){var A=z(e);if(typeof A=="function"&&A!==e.entries)for(var $=A.call(e),F;!(F=$.next()).done;)Ke(F.value)&&et(F.value,a)}}}function jt(e){{var a=e.type;if(a==null||typeof a=="string")return;var u;if(typeof a=="function")u=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===m||a.$$typeof===C))u=a.propTypes;else return;if(u){var b=x(a);De(u,e.props,"prop",b,e)}else if(a.PropTypes!==void 0&&!ze){ze=!0;var A=x(a);s("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",A||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&s("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tt(e){{for(var a=Object.keys(e.props),u=0;u<a.length;u++){var b=a[u];if(b!=="children"&&b!=="key"){de(e),s("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),de(null);break}}e.ref!==null&&(de(e),s("Invalid attribute `ref` supplied to `React.Fragment`."),de(null))}}function rt(e,a,u,b,A,$){{var F=ce(e);if(!F){var T="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ee=_t(A);ee?T+=ee:T+=Ze();var G;e===null?G="null":we(e)?G="array":e!==void 0&&e.$$typeof===n?(G="<"+(x(e.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):G=typeof e,s("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",G,T)}var H=Z(e,a,u,A,$);if(H==null)return H;if(F){var le=a.children;if(le!==void 0)if(b)if(we(le)){for(var Ne=0;Ne<le.length;Ne++)tt(le[Ne],e);Object.freeze&&Object.freeze(le)}else s("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else tt(le,e)}return e===i?Tt(H):jt(H),H}}function Pt(e,a,u){return rt(e,a,u,!0)}function Dt(e,a,u){return rt(e,a,u,!1)}var Mt=Dt,Ft=Pt;Be.Fragment=i,Be.jsx=Mt,Be.jsxs=Ft}()),Be}process.env.NODE_ENV==="production"?He.exports=At():He.exports=$t();var O=He.exports;const Nt=["=","!"],Lt=["=","!","*","!*","<*",">*"],Vt=["=",">","<",">=","<=","!"],it="~~func~~",ge=()=>{const t=n=>{const r=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);let i="",f=0;for(n=n||1;f<n;)i+=r(),f++;return i};return`${t(2)}-${t()}-${t()}-${t()}-${t(3)}`},qe=(t,n,r)=>r.indexOf(t)===n,gt=(t,n)=>n.valueGetter&&typeof t=="object"?n.valueGetter(t):t.toString(),ht=(t,n)=>n.textGetter&&typeof t=="object"?n.textGetter(t):t.toString(),vt=10,mt=w.createContext(!1),Je=w.createContext({dataSources:[],defaultComparison:"=",and:"&",or:"|",comparisons:[],comparisonDescriptions:[],operators:"Complex",defaultItemLimit:vt}),yt=w.createContext({matchers:[],activeFunction:null});var bt={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},st=he.createContext&&he.createContext(bt),Oe=globalThis&&globalThis.__assign||function(){return Oe=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var f in n)Object.prototype.hasOwnProperty.call(n,f)&&(t[f]=n[f])}return t},Oe.apply(this,arguments)},Ut=globalThis&&globalThis.__rest||function(t,n){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var f=0,i=Object.getOwnPropertySymbols(t);f<i.length;f++)n.indexOf(i[f])<0&&Object.prototype.propertyIsEnumerable.call(t,i[f])&&(r[i[f]]=t[i[f]]);return r};function xt(t){return t&&t.map(function(n,r){return he.createElement(n.tag,Oe({key:r},n.attr),xt(n.child))})}function Ge(t){return function(n){return he.createElement(Wt,Oe({attr:Oe({},t.attr)},n),xt(t.child))}}function Wt(t){var n=function(r){var i=t.attr,f=t.size,y=t.title,p=Ut(t,["attr","size","title"]),d=f||r.size||"1em",m;return r.className&&(m=r.className),t.className&&(m=(m?m+" ":"")+t.className),he.createElement("svg",Oe({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,p,{className:m,style:Oe(Oe({color:t.color||r.color},r.style),t.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),y&&he.createElement("title",null,y),t.children)};return st!==void 0?he.createElement(st.Consumer,null,function(r){return n(r)}):n(bt)}function Yt(t){return Ge({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"}}]})(t)}const Bt=({options:t,activeOption:n,onSelectOption:r,onSelectActiveOption:i,onSelectOperator:f,onSelectComparison:y,onSelectText:p,styles:d})=>{const[m,_]=w.useState(null),R=w.useRef(null),C=w.useContext(Je);w.useEffect(()=>{R.current&&R.current.scrollIntoView&&R.current.scrollIntoView({block:"end",behavior:"smooth"})},[n]);const B=(z,g)=>{r(g),z.stopPropagation()},N=()=>{let z=0;return t.map(g=>{const[s,k]=g;return O.jsxs("ul",{children:[O.jsx("li",{className:"optionListCategory",style:d==null?void 0:d.optionCategory,children:s}),k.map(U=>{const P=z++;return O.jsx("li",{ref:P===n?R:void 0,className:P===n?"optionListOption optionListActiveOption":"optionListOption",style:P===n?d==null?void 0:d.activeOption:d==null?void 0:d.option,onMouseEnter:()=>i(P),onClick:te=>B(te,U),children:U.text},U.value.toString())})]},s)})},J=z=>{const g=[];return C.operators!=="Simple"&&(g.push({header:"Operators"}),g.push({text:"And",value:"and",type:"operator"}),g.push({text:"Or",value:"or",type:"operator"}),C.operators==="Complex"&&(g.push({text:"( Open bracket",value:"(",type:"operator"}),g.push({text:") Close bracket",value:")",type:"operator"}))),C.operators!=="Simple"&&(g.push({header:"Comparison"}),g.push(...C.comparisonDescriptions.map(s=>({text:s.description===""?s.symbol:s.description,value:s.symbol,type:"comparison"})))),C.dataSources.forEach(s=>{let k=null;s.definitions.forEach(U=>{s.hideOnShortcut||("source"in U&&U.source?typeof U.source!="function"?k!==s.title&&(g.push({header:s.title}),g.push(...U.source.map(P=>({text:ht(P,U),value:gt(P,U),type:s.name})))):k!==s.title&&g.push({header:s.title,type:"Lookup"}):k!==s.title&&g.push({header:s.title,type:"Expression"}),k=s.title)})}),O.jsx("div",{style:{maxHeight:C.maxDropDownHeight??310},children:O.jsx("div",{className:"optionStaticList",style:{minHeight:C.minStaticListHeight,maxHeight:C.maxStaticListHeight??300},children:g.map(s=>"header"in s?"items"in s?O.jsxs("div",{className:"optionStaticHeaderMenu",onMouseEnter:()=>_(s.header),onMouseLeave:()=>_(null),children:[s.header,O.jsx(Yt,{}),O.jsx("div",{children:z===s.header&&O.jsx("div",{className:"subItemsList",children:s.items.map(k=>O.jsx("div",{children:k.text},s.header+"-"+k.text))})})]},s.header):"type"in s?O.jsxs("div",{className:"optionStaticHeader",children:[s.header," - ",s.type]},s.header):O.jsx("div",{className:"optionStaticHeader",children:s.header},s.header):O.jsx("div",{className:"optionStaticItem",onClick:()=>{s.type==="comparison"?y(typeof s.value=="string"?s.value:s.value.toString()):s.type==="operator"?f(typeof s.value=="string"?s.value:s.value.toString()):p({text:s.text,value:s.value,source:s.type})},children:s.text},s.text+"-"+s.type))})})},L={...d==null?void 0:d.optionsList,...C.maxDropDownHeight?{maxHeight:C.maxDropDownHeight}:{}};return O.jsx("div",{id:"option_list",className:"optionListMain",style:L,children:t.length>0?N():J(m)})};function Et(t){return Ge({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}}]})(t)}const Gt=({errorMessage:t,onErrorAcknowledged:n,style:r})=>O.jsxs("div",{id:"editError",className:"errorMessageMain",style:r,children:[O.jsx(Et,{className:"errorMessageIcon",onClick:n}),t]}),Ct="Functions",St=(t,n,r)=>n.length>(t.itemLimit??r)?n.slice(0,t.itemLimit??r):n,zt=(t,n,r)=>{if(n.precedence){const i=n.precedence;return t.findIndex(f=>{if(f[0]===Ct)return!1;const y=r.find(p=>p.title===f[0]);return i>((y==null?void 0:y.precedence)??0)})}return-1},Kt=(t,n,r)=>t.map(i=>({source:n,value:gt(i,r),text:ht(i,r)})),lt=(t,n,r,i,f,y)=>{let p=Kt(t,n.name,r);return p.length>0&&(p=St(r,p,f),qt(i,n,r,p,f,y)),p.length},Ht=(t,n,r,i)=>St(t,n.concat(r).filter((f,y,p)=>p.findIndex(d=>d.value===f.value)===y),i),qt=(t,n,r,i,f,y)=>{const p=t.find(d=>d[0]===n.title);if(p){p[1]=Ht(r,p[1],i,f);return}wt(t,n,i,y)},wt=(t,n,r,i)=>{const f=zt(t,n,i);f!==-1?t.splice(f,0,[n.title,r]):t.push([n.title,r])},Jt=(t,n,r)=>{const i=n.textGetter&&typeof t=="object"?n.textGetter(t):t.toString();return n.ignoreCase?i.toUpperCase().includes(r.toUpperCase()):i.includes(r)},Xt=(t,n)=>t===0?0:n.slice(0,t).map(r=>r[1].length).reduce((r,i)=>r+i),ut=(t,n,r=!0)=>{let i=0;const f=n.findIndex(y=>{const[,p]=y,d=t>=i&&t<i+p.length;return i+=p.length,d});return Xt(r?f<n.length-1?f+1:0:f>0?f-1:n.length-1,n)};const Xe=w.forwardRef((t,n)=>{const{matcher:r,onMatcherChanged:i,onValidate:f,onFocus:y,onCancel:p,onEditPrevious:d,onEditNext:m,onInsertMatcher:_,first:R,allowFunctions:C,allowFreeText:B,styles:N,onChanging:J,onSetActiveFunction:L,onDeleteActiveFunction:z}=t,g=w.useContext(Je),s=w.useRef(null),[k,U]=w.useState(r?`${!R&&g.operators!=="Simple"?r.operator+" ":""}${r.comparison}${r.text}`:""),[P,te]=w.useState((r==null?void 0:r.comparison)??null),[oe,X]=w.useState((r==null?void 0:r.operator)??null),[re,ce]=w.useState(null),ae=w.useRef(""),[Q,x]=w.useState([]),[D,h]=w.useState(0),[E,V]=w.useState(null),[ie,se]=w.useState(null),[ke,I]=w.useState(!1),ne=w.useContext(mt),K=w.useContext(yt),_e=(o=null,c=null,v=null)=>{let j="";o==="("||o===")"?W(o):((o||oe)&&(j=`${o??oe} `),(c||P)&&(j=`${j}${c??P} `),v?W(v):(j=`${j}${re??""}`,Te(j)))};w.useEffect(()=>{s.current&&ne&&s.current.focus()},[ne]),w.useEffect(()=>{se(null)},[R]),w.useEffect(()=>{k.length===0&&V(null)},[k]);const ue=()=>{U(""),X(null),te(null),ce(null),x([]),h(0),V(null)},Ee=(o,c)=>{if(o.length>2&&o.substring(0,3)==="and")return X("and"),c.op="and",o.substring(3).trim();if(o.length>1&&o.substring(0,2)==="or")return X("or"),c.op="or",o.substring(2).trim();const v=o[0];return v===g.and||v===g.or?(X(v),c.op=v===g.and?"and":"or",o.substring(1).trim()):o},Re=o=>{if(o.length>1){const v=o.substring(0,2);if(g.comparisons.includes(v))return te(v),o.substring(2).trim()}const c=o[0];if(g.operators==="Complex"&&(!K.activeFunction||!K.activeFunction.noBrackets)&&(c==="("||c===")")){if(r&&_&&r.operator!==c){const v={key:ge(),operator:c,comparison:c,source:"",value:"",text:""};_(v)}else W(c);return null}return g.comparisons.includes(c)?(te(c),o.substring(1).trim()):o},ve=(o,c,v)=>{if(o.length>0){let j=o.trim();if(j.length>0&&j[0]!=='"'&&(g.operators!=="Simple"&&(!K.activeFunction||!K.activeFunction.noAndOr)&&(j=Ee(j,v)),j=Re(j),ce(j),j!==null&&j.length>0)){const Y=j;Y.length>=(g.searchStartLength??0)&&(C&&g.functions&&je(Y,g.functions,v),g.dataSources.forEach(Z=>{var pe,We;(!K.activeFunction&&!Z.functional||K.activeFunction&&((pe=K.activeFunction.requiredDataSources)!=null&&pe.includes(Z.name)||(We=K.activeFunction.optionalDataSources)!=null&&We.includes(Z.name)))&&Z.definitions.forEach(de=>{"source"in de?Ce(Y,Z,de,c,v):fe(Y,Z,de,c,v)})}))}}},je=(o,c,v)=>{const j=c.filter(Y=>Y.name.toUpperCase().includes(o.toUpperCase())).map(Y=>({source:it,text:Y.name,value:Y.name}));j.length>0&&(v.allOptions.push([Ct,j]),v.totalCount+=j.length)},Ce=(o,c,v,j,Y)=>{if(o.length>=(v.searchStartLength??0)){if(typeof v.source=="function"){const Z=v.source;setTimeout(()=>{j===ae.current&&Z(o,Y.op,K.matchers).then(pe=>{j===ae.current&&(Y.totalCount+=lt(pe,c,v,Y.allOptions,g.defaultItemLimit,g.dataSources),Me(Y))})},g.promiseDelay??1)}else if(j===ae.current){const Z=v.source.filter(pe=>Jt(pe,v,o));Z.length>0&&(Y.totalCount+=lt(Z,c,v,Y.allOptions,g.defaultItemLimit,g.dataSources))}}},fe=(o,c,v,j,Y)=>{if((v.match instanceof RegExp&&o.match(v.match)||typeof v.match=="function"&&v.match(o))&&j===ae.current){const Z=v.value(o);wt(Y.allOptions,c,[{source:c.name,value:Z,text:Z.toString()}],g.dataSources),Y.totalCount+=1}},Te=o=>{X(null),te(null),ce(null),!ke&&r&&(I(!0),J&&J());const c=ge();ae.current=c;const v={allOptions:[],totalCount:0,op:null};ve(o,c,v),U(o),Me(v)},Me=o=>{const{allOptions:c,totalCount:v}=o;x(c),h(v),v>0&&(E===null?V(0):E>=v&&V(v-1))},Fe=o=>d&&!o.shiftKey&&!o.ctrlKey?(R&&z?z():d(!0),!0):p?(W(),!0):!1,me=()=>(p&&p(),!0),ye=()=>(W(),!0),Pe=o=>{var v;const c=Q.flatMap(j=>j[1]);if(E!==null&&c.length>E){if(c[E].source===it){const j=(v=g.functions)==null?void 0:v.find(Y=>Y.name===c[E].text);j&&L&&(L(j),ue())}else o.shiftKey?M(c[E]):W(c[E]);return!0}return!1},Ie=()=>{if(B){const o={key:ge(),operator:"",comparison:'"',source:"Free Text",value:k.substring(1),text:k.substring(1)};return i(o),ue(),!0}return!1},Se=()=>D>0?(V(D-1),!0):!1,De=()=>D>0?(V(0),!0):!1,Le=()=>D>0?(V(ut(E??D-1,Q)),!0):!1,we=()=>D>0?(V(ut(E??0,Q,!1)),!0):!1,Ve=()=>(E===null?V(0):E<D-1?V(E+1):V(0),!0),Ue=()=>(E===null?V(D-1):E>0?V(E-1):V(D-1),!0),Ae=o=>s.current&&!o.ctrlKey&&!o.shiftKey&&o.currentTarget.selectionStart===o.currentTarget.value.length&&m?(m(),!0):!1,$e=o=>s.current&&!o.ctrlKey&&!o.shiftKey&&o.currentTarget.selectionStart===0?(d(!1),!0):!1,be=o=>{let c=!1;switch(se(null),o.code){case"ArrowLeft":c=$e(o);break;case"ArrowRight":c=Ae(o);break;case"ArrowUp":c=Ue();break;case"ArrowDown":c=Ve();break;case"PageUp":c=we();break;case"PageDown":c=Le();break;case"Home":c=De();break;case"End":c=Se();break;case"Enter":case"Tab":k.length>0&&k[0]==='"'?c=Ie():Q.length>0&&E!==null?c=Pe(o):k.length===0&&r?c=ye():r&&p&&(c=me());break;case"Backspace":k.length===0&&(c=Fe(o));break}c&&(o.preventDefault(),o.stopPropagation())},l=o=>{const c=g.dataSources.find(v=>v.name===o.source);if(c&&P!==null&&!c.comparisons.includes(P)){const v=k.indexOf(P);return v!==-1&&s.current&&(s.current.selectionStart=v,s.current.selectionEnd=v+1),`Compairson (${P}) isn't valid for ${c.name}.`}return null},S=o=>{if(o!=="("&&o!==")"&&o){const v=l(o);if(v)return se(v),!1}const c=o?{key:(r==null?void 0:r.key)??ge(),operator:o===")"?"":oe??"and",comparison:o==="("||o===")"?o:P??g.defaultComparison,source:typeof o=="object"?o.source:"",value:typeof o=="object"?o.value:"",text:typeof o=="object"?o.text:""}:null;if(c&&f){const v=f(c);if(v)return se(v),!1}return c},M=o=>{const c=S(o);c!==!1&&c!==null&&_&&_(c)},W=o=>{const c=S(o);c!==!1&&(i(c),ue())},q=()=>{y&&y()};return O.jsxs("div",{className:"matcherEditMain",style:N==null?void 0:N.matcherEdit,children:[ie&&O.jsx(Gt,{errorMessage:ie,onErrorAcknowledged:()=>se(null),style:N==null?void 0:N.errorMessage}),O.jsx("input",{id:((r==null?void 0:r.key)??"edit")+"_input",style:N==null?void 0:N.input,ref:o=>{s.current=o,typeof n=="function"?n(o):n&&(n.current=o)},value:k,onChange:o=>Te(o.target.value),onFocus:q,onKeyDown:be,autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",spellCheck:"false",type:"text",placeholder:"..."}),ne&&(!r||Q.length>0)&&O.jsx(Bt,{options:Q,activeOption:E,onSelectActiveOption:V,onSelectOption:W,styles:N,onSelectComparison:o=>_e(null,o),onSelectOperator:o=>_e(o),onSelectText:o=>_e(null,null,o)})]})});Xe.displayName="MatcherEdit";function Zt(t){return Ge({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18 11h-12c-1.104 0-2 .896-2 2s.896 2 2 2h12c1.104 0 2-.896 2-2s-.896-2-2-2z"}}]})(t)}const Qt=(t,n,r,i)=>`${n||r||t.operator===""||t.comparison===")"?"":(t.operator==="&"||t.operator==="and"?"and":"or")+" "}${i==="left"?t.source+" ":""}${t.comparison!=='"'?t.comparison+" ":""}${t.text}`,er=t=>`${t.source}: ${t.text}${t.value!==t.text?"("+t.value+")":""}`,ct="multi-select/matcher/",ft=({matcher:t,onMatcherChanged:n,onValidate:r,onDelete:i,onSelect:f,onCancel:y,onSwapMatcher:p,onEditPrevious:d,onEditNext:m,onChanging:_,onInsertMatcher:R,selected:C,first:B,hideOperators:N,showWarning:J,showCategory:L,categoryPosition:z,hideToolTip:g,allowFreeText:s,styles:k})=>{var h;const U=w.useRef(null),[P,te]=w.useState(!1),[oe,X]=w.useState(!1);w.useEffect(()=>{C&&P&&te(!1)},[C,P]),w.useEffect(()=>{C&&oe&&X(!1)},[C,oe]);const re=E=>{E?i():d&&d()},ce=E=>{i(),E.stopPropagation()},ae=E=>{E?n&&n(E):i()},Q=E=>{"key"in t&&(E.dataTransfer.setData(`${ct}${t.key}`,JSON.stringify(t)),E.dataTransfer.effectAllowed="move")},x=E=>{"key"in t&&(E.dataTransfer.types.find(V=>V.includes(t.key))||(E.dataTransfer.dropEffect="move",E.preventDefault()))},D=E=>{if("key"in t){const V=E.dataTransfer.types.find(ie=>ie.includes(ct));if(V){const ie=E.dataTransfer.getData(V);if(ie&&p){const se=JSON.parse(ie);p(t,se)}}}};return O.jsxs("div",{id:"key"in t?t.key+"_view":"function_view",className:"matcherViewMain",style:{...C?k==null?void 0:k.matcherViewSelected:k==null?void 0:k.matcherView,flexGrow:C?1:0},onClick:f,draggable:!0,onDragStart:Q,onDragOver:x,onDrop:D,onMouseEnter:()=>X(!0),onMouseLeave:()=>X(!1),children:[oe&&!C&&O.jsx(Zt,{className:"deleteIcon",onClick:ce}),C&&"key"in t?O.jsx(Xe,{matcher:t,onMatcherChanged:ae,onValidate:r,onCancel:y,first:B??!1,styles:k,onEditNext:m,onEditPrevious:re,onChanging:_,onInsertMatcher:R,allowFreeText:s}):O.jsxs(O.Fragment,{children:[!g&&P&&"key"in t&&O.jsx("div",{id:t.key+"_tool_tip",className:"matcherViewToolTip",style:{top:(((h=U.current)==null?void 0:h.clientHeight)??10)*-1-4,...k==null?void 0:k.matcherToolTip},children:er(t)}),O.jsxs("div",{onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),className:"matcherViewContainer",style:"key"in t&&t.source!==""?{}:{alignSelf:"end"},children:[L&&"key"in t&&z!=="left"&&O.jsx("div",{className:"matchViewCategory",children:t.source}),O.jsx("div",{ref:U,id:"key"in t?t.key+"_label":"function_label",className:J?"matcherViewWarning":"",children:"key"in t?Qt(t,B??!1,N??!1,z):t.name})]})]})]})},pt=(t,n,r)=>{const i=r?"(":")",f=r?")":"(",y=[];for(let p=r?t.length-1:0;!r&&p<t.length||r&&p>=0;r?p--:p++)if(t[p]===i){let d=!1;for(let m=r?p+1:p-1;r&&m<t.length||!r&&m>=0;r?m++:m--)if(t[m]===f&&!y.includes(m)){y.push(m),d=!0;break}d||n.push(p)}},dt=(t,n,r,i,f,y)=>{if(r.comparison==="("||r.comparison===")")return null;if(f==="AgGrid"&&(r.operator==="or"||r.operator===y)){const d=i?i>0?t[i-1]:null:t.length>0?t[t.length-1]:null;if(d&&d.source!==r.source)return"When using AgGrid style operators, or can only be used for the same field"}const p=n.find(d=>d.name===r.source);return p!=null&&p.selectionLimit&&t.filter(m=>r.key!==m.key&&r.source===m.source).length>=p.selectionLimit?`Datasource (${p.name}) is limited to ${p.selectionLimit} items.`:null},tr=(t,n,r,i,f="Individual",y=500)=>new Promise(p=>{const d=(r==null?void 0:r.pasteFreeTextAction)??f,m=t.includes('"')?ir(t):t.split(" "),_=m,R=[];let C="and",B="=";m.forEach((L,z)=>{const g=L.trim();g===i.and||g==="and"?C="and":g===i.or||g==="or"?C="or":i.comparisons.includes(g)?B=g:g!==""&&n.forEach(s=>{var k,U;(r&&((k=r.optionalDataSources)!=null&&k.includes(s.name)||(U=r.requiredDataSources)!=null&&U.includes(s.name))||!r&&!s.functional)&&s.definitions.forEach(P=>{"source"in P?(!P.searchStartLength||g.length>=P.searchStartLength)&&(typeof P.source=="function"?typeof P.matchOnPaste=="function"&&or(s,P,P.matchOnPaste,g,z,R,_,C,B):nr(s,P,P.source,g,z,_,C,B)):rr(s,P,g,z,_,C,B)})})});const N=()=>{p(d==="Original"?[{key:ge(),operator:"",comparison:"",source:"Free Text",value:t,text:t},..._.filter(L=>typeof L!="string")]:d==="Combined"?[ar(_,i),..._.filter(L=>typeof L!="string")]:_.filter(L=>typeof L!="string"||Ot(L,i)).map(L=>typeof L=="string"?{key:ge(),operator:"",comparison:"",source:"Free Text",value:L,text:L}:L))};let J="running";Promise.all(R).then(()=>{J!=="cancel"&&(J="done",N())}),setTimeout(()=>{J!=="done"&&(J="cancel",N())},y)}),rr=(t,n,r,i,f,y,p)=>{if(n.matchOnPaste&&(n.match instanceof RegExp&&r.match(n.match)||typeof n.match=="function"&&n.match(r))){const d=n.value(r);d&&(f[i]=f[i]={key:ge(),operator:y,comparison:p,source:t.name,value:d,text:typeof d=="string"?d:d.toString()})}},nr=(t,n,r,i,f,y,p,d)=>{if(n.matchOnPaste){const m=r.find(_=>{const R=n.textGetter&&typeof _=="object"?n.textGetter(_):_.toString();return n.ignoreCase?R.toUpperCase()===i.toUpperCase():R===i});if(m){const _=kt(m,n,t);_&&(y[f]={key:ge(),operator:p,comparison:d,..._})}}},or=(t,n,r,i,f,y,p,d,m)=>{y.push(r(i).then(_=>{if(_){const R=kt(_,n,t);R&&(p[f]={key:ge(),operator:d,comparison:m,...R})}return!0}))},Ot=(t,n)=>t!=="and"&&t!=="or"&&t!==n.and&&t!==n.or&&!n.comparisons.includes(t),ar=(t,n)=>{const r=t.filter(i=>typeof i=="string"&&Ot(i,n)).join(" ");return{key:ge(),operator:"",comparison:"",source:"Free Text",value:r,text:r}},kt=(t,n,r)=>typeof t=="object"?n.valueGetter&&n.textGetter?{source:r.name,value:n.valueGetter(t),text:n.textGetter(t)}:void 0:{source:r.name,value:t,text:t},ir=t=>t.split('"').map((n,r)=>r%2===1?n.replaceAll(" ","^¬|"):n).join('"').split(" ").map(n=>n.replaceAll("^¬|"," ").replaceAll('"',""));function sr(t){return Ge({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M443.5 420.2L336.7 312.4c20.9-26.2 33.5-59.4 33.5-95.5 0-84.5-68.5-153-153.1-153S64 132.5 64 217s68.5 153 153.1 153c36.6 0 70.1-12.8 96.5-34.2l106.1 107.1c3.2 3.4 7.6 5.1 11.9 5.1 4.1 0 8.2-1.5 11.3-4.5 6.6-6.3 6.8-16.7.6-23.3zm-226.4-83.1c-32.1 0-62.3-12.5-85-35.2-22.7-22.7-35.2-52.9-35.2-84.9 0-32.1 12.5-62.3 35.2-84.9 22.7-22.7 52.9-35.2 85-35.2s62.3 12.5 85 35.2c22.7 22.7 35.2 52.9 35.2 84.9 0 32.1-12.5 62.3-35.2 84.9-22.7 22.7-52.9 35.2-85 35.2z"}}]})(t)}const lr=(t,n)=>{w.useEffect(()=>{const r=i=>{t&&i.target&&(t.contains(i.target)||n())};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,n])};const ur=t=>t.flatMap(n=>n.comparisons).filter(qe),cr=t=>t.flatMap(n=>n.comparisons).filter(qe).map(n=>({symbol:n,description:""})),fr=({matchers:t,defaultComparison:n,comparisonDescriptons:r,and:i,or:f,dataSources:y,functions:p,defaultItemLimit:d,operators:m,onMatchersChanged:_,onComplete:R,onCompleteError:C,clearIcon:B,maxDropDownHeight:N,minStaticListHeight:J,maxStaticListHeight:L,searchStartLength:z,showCategories:g,categoryPosition:s,hideToolTip:k,allowFreeText:U,pasteFreeTextAction:P,pasteMatchTimeout:te,promiseDelay:oe,styles:X})=>{const re=w.useRef(null),ce=w.useRef(null),[ae,Q]=w.useState(!1),[x,D]=w.useState(null),[h,E]=w.useState(t??[]),[V,ie]=w.useState([]),[se,ke]=w.useState(!1),[I,ne]=w.useState(null),K=w.useMemo(()=>({dataSources:y,functions:p,defaultComparison:n??"=",and:i??"&",or:f??"|",comparisons:ur(y),comparisonDescriptions:r??cr(y),defaultItemLimit:d??vt,operators:m??"Complex",maxDropDownHeight:N,minStaticListHeight:J,maxStaticListHeight:L,searchStartLength:z,promiseDelay:oe}),[y,p,n,r,i,f,d,m,N,J,L,z,oe]);w.useEffect(()=>{se?ke(!1):E(t??[])},[t]);const _e=w.useCallback(()=>{Q(!1),D(null)},[]);lr(ce.current,_e);const ue=()=>{var l;D(null),(l=re.current)==null||l.focus()},Ee=()=>{ne(null)},Re=()=>{ue(),Q(!0)},ve=l=>{_&&_(l)},je=()=>{if(I!=null&&I.requiredDataSources){const l=I.requiredDataSources.filter(S=>!h.find(M=>M.source===S));if(l.length>0)return C&&C(I.name,`mandatory fields are missing (${l.join("")})`,l),!1}if(I!=null&&I.validate){const l=I.validate(h);if(l)return C&&C(I.name,l),!1}return!0},Ce=l=>{const S=[],M=l.map(W=>W.comparison);pt(M,S,!0),pt(M,S,!1),ie(S)},fe=l=>{E(l),ve(l),Ce(l)},Te=l=>{const S=h.map(M=>M.key===l.key?l:M);fe(S),ue()},Me=()=>{h.length>0?Pe(h[h.length-1]):I!=null&&ne(null)},Fe=()=>{fe([]),ue(),ne(null)},me=()=>{h.length>0&&(x===null?D(h.length-1):x>0&&D(x-1))},ye=()=>{h.length>0&&x!==null&&x<h.length-1&&D(x+1)},Pe=(l,S=!1)=>{const M=h.filter(W=>W.key!==l.key);fe(M),x!==null&&(S||x>h.length-1)&&ue()},Ie=l=>{if(l){const S=[...h,l];fe(S)}},Se=l=>{ae||Q(!0),D(l)},De=(l,S)=>{const M=h.findIndex(q=>q.key===l.key),W=h.findIndex(q=>q.key===S.key);if(M!==-1&&W!==-1){const q=h.map(o=>o.key===l.key?S:o.key===S.key?l:o);fe(q)}},Le=l=>{ke(!0),ve(h.map(S=>S.key===l.key?{...l,changing:!0}:S))},we=(l,S)=>{if(S){const M=h.findIndex(W=>W.key===S.key);h.splice(M,0,l),E([...h]),x!=null&&M<=x&&D(x+1)}else E([...h,l])},Ve=l=>{var S;switch(l.code){case"ArrowLeft":if(l.shiftKey)D(x===null?h.length-1:x>0?x-1:null),l.preventDefault();else if(l.ctrlKey&&x!==null&&h.length>1){const M=x>0?x-1:h.length-1;De(h[x],h[M]),D(M)}break;case"ArrowRight":if(l.shiftKey)D(x===null?0:x<h.length-1?x+1:null),l.preventDefault();else if(l.ctrlKey&&x!==null&&h.length>1){const M=x<h.length-1?x+1:0;De(h[x],h[M]),D(M)}break;case"Backspace":l.shiftKey?(h.length===0&&ne(null),Me(),l.preventDefault()):l.ctrlKey&&(Fe(),l.preventDefault());break;case"Enter":R&&je()&&setTimeout(()=>{R(h,I==null?void 0:I.name),E([]),D(null),ne(null),re.current&&re.current.blur()},10),l.preventDefault();break;case"Home":h.length>0&&(D(0),l.preventDefault(),l.stopPropagation());break;case"End":h.length>0&&(D(null),(S=re.current)==null||S.focus(),l.preventDefault(),l.stopPropagation());break}},Ue=l=>{var M;const S=(M=l.clipboardData)==null?void 0:M.getData("text");S&&tr(S,y,I,K,P,te).then(W=>fe([...h,...W])),l.stopPropagation(),l.preventDefault()},Ae=l=>{var W;const S=q=>`${q.operator!=="and"&&q.operator!==K.and?`${q.operator} `:""}${q.comparison!=="="?`${q.comparison} `:""}${q.text.includes(" ")?`"${q.text}"`:q.text}`,M=I?`${I.name} ${h.map(S).join(" ")}`:h.map(S).join(" ");(W=l.clipboardData)==null||W.setData("text",M),l.stopPropagation(),l.preventDefault()},$e={matchers:h,activeFunction:I},be=()=>{var l;x===null&&((l=re.current)==null||l.focus())};return O.jsx(mt.Provider,{value:ae,children:O.jsx(Je.Provider,{value:K,children:O.jsx(yt.Provider,{value:$e,children:O.jsxs("div",{id:"MultiSelect",style:X==null?void 0:X.mutliSelect,className:"multiSelectMain",ref:ce,onKeyDown:Ve,onPaste:Ue,onCopy:Ae,onClick:be,children:[(h.length>0||I!==null)&&O.jsx("div",{className:"multiSelectClearIcon",onClick:()=>Fe(),children:B||O.jsx(Et,{})}),O.jsxs("div",{className:"multiSelectFlow",children:[I&&O.jsx(ft,{matcher:I,onDelete:Ee},"function"),h==null?void 0:h.map((l,S)=>O.jsx(ft,{matcher:l,onMatcherChanged:Te,onValidate:M=>dt(h,y,M,x,K.operators,K.or),onDelete:()=>Pe(l,!0),onSelect:()=>Se(S),onCancel:()=>ue(),onSwapMatcher:De,onEditPrevious:me,onEditNext:ye,onChanging:()=>Le(l),onInsertMatcher:M=>we(M,l),selected:S===x,first:S===0||h[S-1].comparison==="(",hideOperators:m==="Simple",showWarning:V.includes(S),showCategory:g,categoryPosition:s,hideToolTip:k,allowFreeText:U||I!==null&&I.allowFreeText,styles:X},l.key)),x===null&&O.jsx("div",{className:"defaultMatcherEdit",style:{paddingLeft:h.length===0&&I===null?4:0},children:O.jsx(Xe,{ref:re,onMatcherChanged:Ie,onValidate:l=>dt(h,y,l,x,K.operators,K.or),onFocus:Re,first:h.length===0,allowFunctions:h.length===0&&I===null,allowFreeText:U||I!==null&&I.allowFreeText,onEditPrevious:me,onEditNext:ye,onInsertMatcher:l=>we(l,null),onSetActiveFunction:l=>ne(l),onDeleteActiveFunction:Ee,styles:X})})]}),O.jsx(sr,{className:"multiSelectSearchIcon"})]})})})})};exports.default=fr;exports.defaultComparison=Nt;exports.isUnique=qe;exports.numberComparisons=Vt;exports.stringComparisons=Lt;