"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/api");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var o=u(e),c=r(n);function i(e){if(Array.isArray(e))return e}function a(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,u,o,c,i=[],a=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;a=!1}else for(;!(a=(r=o.call(n)).done)&&(i.push(r.value),i.length!==t);a=!0);}catch(e){l=!0,u=e}finally{try{if(!a&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(l)throw u}}return i}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n0&&void 0!==arguments[0]?arguments[0]:{},n=e.target;t.ObjectUtils.isNotEmpty(n)&&(g(),(e.when||l)&&(s.current=t.DomHandler.getTargetElement(n))),!f.current&&s.current&&(f.current=function(e){return c&&c(e)},s.current.addEventListener(u,f.current,i))},g=function(){f.current&&(s.current.removeEventListener(u,f.current,i),f.current=null)},h=function(){g(),d=null,y=null},b=o.useCallback((function(){l?s.current=t.DomHandler.getTargetElement(r):(g(),s.current=null)}),[r,l]);return o.useEffect((function(){b()}),[b]),o.useEffect((function(){var e="".concat(d)!=="".concat(c),t=f.current;t&&(e||y!==i)?(g(),l&&m()):t||h()}),[c,i,l]),v((function(){h()})),[m,g]},m={},g={ico:"image/x-icon",png:"image/png",svg:"image/svg+xml",gif:"image/gif"};function h(e){if(Array.isArray(e))return l(e)}function b(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function w(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function E(e){return h(e)||b(e)||s(e)||w()}var O={escKeyListeners:new Map,onGlobalKeyDown:function(e){if("Escape"===e.code){var t=O.escKeyListeners,n=Math.max.apply(Math,E(t.keys())),r=t.get(n),u=Math.max.apply(Math,E(r.keys()));r.get(u)(e)}},refreshGlobalKeyDownListener:function(){var e=t.DomHandler.getTargetElement("document");this.escKeyListeners.size>0?e.addEventListener("keydown",this.onGlobalKeyDown):e.removeEventListener("keydown",this.onGlobalKeyDown)},addListener:function(e,t){var n=this,r=d(t,2),u=r[0],o=r[1],c=this.escKeyListeners;c.has(u)||c.set(u,new Map);var i=c.get(u);if(i.has(o))throw new Error("Unexpected: global esc key listener with priority [".concat(u,", ").concat(o,"] already exists."));return i.set(o,e),this.refreshGlobalKeyDownListener(),function(){i.delete(o),0===i.size&&c.delete(u),n.refreshGlobalKeyDownListener()}}},S=function(e){var t=o.useRef(!1);return o.useEffect((function(){if(!t.current)return t.current=!0,e&&e()}),[])};function x(e){return x="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},x(e)}function D(e,t){if("object"!=x(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=x(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function j(e){var t=D(e,"string");return"symbol"==x(t)?t:t+""}function P(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function R(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};if(t.ObjectUtils.isNotEmpty(e.target)&&(b(),(e.when||l)&&(f.current=t.DomHandler.getTargetElement(e.target))),!d.current&&f.current){var n=s?s.hideOverlaysOnDocumentScrolling:c.default.hideOverlaysOnDocumentScrolling,r=y.current=t.DomHandler.getScrollableParents(f.current);r.some((function(e){return e===document.body||e===window}))||r.push(n?window:document.body),d.current=function(e){return u&&u(e)},r.forEach((function(e){return e.addEventListener("scroll",d.current,i)}))}},b=function(){d.current&&(y.current.forEach((function(e){return e.removeEventListener("scroll",d.current,i)})),d.current=null)},w=function(){b(),y.current=null,m=null,g=null},E=o.useCallback((function(){l?f.current=t.DomHandler.getTargetElement(r):(b(),f.current=null)}),[r,l]);return o.useEffect((function(){E()}),[E]),o.useEffect((function(){var e="".concat(m)!=="".concat(u),t=d.current;t&&(e||g!==i)?(b(),l&&h()):t||w()}),[u,i,l]),v((function(){w()})),[h,b]},T=function(e){var t=e.when;return y({target:"window",type:"resize",listener:e.listener,when:void 0===t||t})},M=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"local",r="undefined"!=typeof window,u=d(y({target:"window",type:"storage",listener:function(e){var r="local"===n?window.localStorage:window.sessionStorage;if(e.storageArea===r&&e.key===t){var u=e.newValue?JSON.parse(e.newValue):void 0;s(u)}}}),2),c=u[0],i=u[1],a=d(o.useState(e),2),l=a[0],s=a[1];return o.useEffect((function(){r||s(e);try{var u="local"===n?window.localStorage.getItem(t):window.sessionStorage.getItem(t);s(u?JSON.parse(u):e)}catch(t){s(e)}return c(),function(){return i()}}),[]),[l,function(e){try{var u=e instanceof Function?e(l):e;if(s(u),r){var o=JSON.stringify(u);"local"===n?window.localStorage.setItem(t,o):window.sessionStorage.setItem(t,o)}}catch(e){throw new Error("PrimeReact useStorage: Failed to serialize the value at key: ".concat(t))}}]},k=0;exports.ESC_KEY_HANDLING_PRIORITIES={SIDEBAR:100,SLIDE_MENU:200,DIALOG:300,IMAGE:400,MENU:500,OVERLAY_PANEL:600,PASSWORD:700,CASCADE_SELECT:800,SPLIT_BUTTON:900,SPEED_DIAL:1e3,TOOLTIP:1200},exports.useClickOutside=function(e,t){var n=function(n){e.current&&!e.current.contains(n.target)&&t(n)},r=d(y({type:"mousedown",listener:n}),2),u=r[0],c=r[1],i=d(y({type:"touchstart",listener:n}),2),a=i[0],l=i[1];return o.useEffect((function(){if(e.current)return u(),a(),function(){c(),l()}})),[e,t]},exports.useCounter=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{step:1},t=d(o.useState(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0),2),n=t[0],r=t[1];return{count:n,increment:function(){e.max&&n>=e.max||r(n+e.step)},decrement:function(){if(e.min||0===e.min&&n<=e.min)return null;r(n-e.step)},reset:function(){r(0)}}},exports.useDebounce=function(e,t){var n=d(o.useState(e),2),r=n[0],u=n[1],c=d(o.useState(e),2),i=c[0],a=c[1],l=o.useRef(!1),s=o.useRef(null),f=function(){return window.clearTimeout(s.current)};return S((function(){l.current=!0})),v((function(){f()})),o.useEffect((function(){l.current&&(f(),s.current=window.setTimeout((function(){a(r)}),t))}),[r,t]),[r,i,u]},exports.useDisplayOrder=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=d(o.useState((function(){return t.UniqueComponentId()})),1)[0],u=d(o.useState(0),2),c=u[0],i=u[1];return o.useEffect((function(){if(n){m[e]||(m[e]=[]);var u=m[e].push(r);return i(u),function(){delete m[e][u-1];var n=m[e].length-1,r=t.ObjectUtils.findLastIndex(m[e],(function(e){return void 0!==e}));r!==n&&m[e].splice(r+1),i(void 0)}}}),[e,r,n]),c},exports.useEventListener=y,exports.useFavicon=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"shortcut icon";o.useLayoutEffect((function(){if(e){document.querySelectorAll("link[rel*='icon']").forEach((function(e){document.head.removeChild(e)}));var n=document.createElement("link");n.setAttribute("type",g[e.split(".").pop()]),n.setAttribute("rel",t),n.setAttribute("href",e),document.head.appendChild(n)}}),[e,t])},exports.useGlobalOnEscapeKey=function(t){var n=t.callback,r=t.when,u=t.priority;e.useEffect((function(){if(r)return O.addListener(n,u)}),[n,r,u])},exports.useIntersectionObserver=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=d(o.useState(!1),2),r=n[0],u=n[1];return o.useEffect((function(){if(e.current){var n=new IntersectionObserver((function(e){var t=d(e,1);u(t[0].isIntersecting)}),t);return n.observe(e.current),function(){n.disconnect()}}}),[t,e]),r},exports.useInterval=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=o.useRef(null),u=o.useRef(null),c=o.useCallback((function(){return clearInterval(r.current)}),[r.current]);return o.useEffect((function(){u.current=e})),o.useEffect((function(){if(n)return r.current=setInterval((function(){u.current()}),t),c;c()}),[t,n]),v((function(){c()})),[c]},exports.useLocalStorage=function(e,t){return M(e,t,"local")},exports.useMatchMedia=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=d(o.useState(!1),2),r=n[0],u=n[1],c=o.useRef(null),i=function(e){return u(e.matches)},a=function(){return c.current&&c.current.removeEventListener("change",i)&&(c.current=null)};return o.useEffect((function(){return t&&(c.current=window.matchMedia(e),u(c.current.matches),c.current&&c.current.addEventListener("change",i)),a}),[e,t]),r},exports.useMergeProps=function(){var r=e.useContext(n.PrimeReactContext);return function(){for(var e=arguments.length,n=new Array(e),u=0;u1&&void 0!==arguments[1]?arguments[1]:{},o=d(e.useState(!1),2),i=o[0],a=o[1],l=e.useRef(null),s=e.useContext(n.PrimeReactContext),f=t.DomHandler.isClient()?window.document:void 0,p=u.document,v=void 0===p?f:p,y=u.manual,m=void 0!==y&&y,g=u.name,h=void 0===g?"style_".concat(++k):g,b=u.id,w=void 0===b?void 0:b,E=u.media,O=void 0===E?void 0:E,S=function(e){var t=e.querySelector('style[data-primereact-style-id="'.concat(h,'"]'));if(t)return t;if(void 0!==w){var n=v.getElementById(w);if(n)return n}return v.createElement("style")},x=function(){if(v&&!i){var e=(null==s?void 0:s.styleContainer)||v.head;l.current=S(e),l.current.isConnected||(l.current.type="text/css",w&&(l.current.id=w),O&&(l.current.media=O),t.DomHandler.addNonce(l.current,s&&s.nonce||c.default.nonce),e.appendChild(l.current),h&&l.current.setAttribute("data-primereact-style-id",h)),l.current.textContent=r,a(!0)}};return e.useEffect((function(){m||x()}),[m]),{id:w,name:h,update:function(e){i&&r!==e&&(l.current.textContent=e)},unload:function(){v&&l.current&&(t.DomHandler.removeInlineStyle(l.current),a(!1))},load:x,isLoaded:i}},exports.useTimeout=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=o.useRef(null),u=o.useRef(null),c=o.useCallback((function(){return clearTimeout(r.current)}),[r.current]);return o.useEffect((function(){u.current=e})),o.useEffect((function(){if(n)return r.current=setTimeout((function(){u.current()}),t),c;c()}),[t,n]),v((function(){c()})),[c]},exports.useUnmountEffect=v,exports.useUpdateEffect=function(e,t){var n=o.useRef(!1);return o.useEffect((function(){if(n.current)return e&&e();n.current=!0}),t)};