@databrainhq/plugin 0.16.27 → 0.16.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -594,7 +594,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
594
594
|
FETCH NEXT ${O} ROWS ONLY`;r||s||C?e=X$2({sqlQuery:e,existingOffset:d,existingLimit:y,outputQuery:k,isRemove:a}):e=JW(e,`limit ${y}`,a?"":`limit ${O} ${l!=="0"?`OFFSET ${l}`:""}`)}else r||s||C?!(/fetch/i.test(e)||/offset/i.test(e))&&!a?e+=` ${f||s||C?"":" ORDER BY(SELECT NULL) "} ${`offset ${l||0} rows`} fetch next ${y||u} rows only`:(/fetch/i.test(e)||/offset/i.test(e))&&(e=_$2({sql:e,newLimit:u,newOffset:l,isRemove:a})):a||(e+=` limit ${u} ${l!=="0"?`OFFSET ${l}`:""}`);return e},hy=(t,n)=>(t==null?void 0:t.label)||n||(t==null?void 0:t.tableName)||"",$$2=(t=[])=>t.flatMap(n=>n.conditions.map(i=>({a:i.firstOperand.parentAlias,b:i.secondOperand.parentAlias}))),e20=(t=[])=>t.map(n=>({a:n.childTableName,b:n.parentTableName})),dS=(t,n)=>t===n||t.endsWith(n)||n.endsWith(t),t20=(t,n)=>{const i=dS(t.a,n.a)&&dS(t.b,n.b),o=dS(t.a,n.b)&&dS(t.b,n.a);return i||o},r20=(t=[],n=[])=>t.length?t.every(i=>n.some(o=>t20(i,o))):!0,n20=(t=[],n=[])=>{const i=$$2(t),o=e20(n);return r20(i,o)},gS=({onSubmit:t,defaultValues:n,onCancel:i,error:o,isCreatingMetric:a})=>{var f;const{register:s,handleSubmit:r,setValue:C,formState:{errors:l},watch:e}=Vb(),u=e("name"),A=e("metricId");return P0.useEffect(()=>{!n||a||(C("name",n.name),C("description",n.description),C("metricId",n.metricId))},[n]),P0.useEffect(()=>{var d;!n&&((d=u==null?void 0:u.trim())==null?void 0:d.length)>=4&&!A&&C("metricId",`${u}_${dm(10)}`)},[n,u]),h.jsxs("form",{onSubmit:r(d=>t(d,!1)),children:[h.jsxs("div",{className:I12.container,children:[h.jsx(K9,{name:"name",type:"text",placeholder:"What is the name of the metric?",label:"Metric Name",register:s("name",{required:{value:!0,message:"Metric name is required"}}),error:(f=l.name)==null?void 0:f.message,defaultValue:n==null?void 0:n.name,isImportant:!0}),h.jsx(zC0,{className:I12.field,id:"desc",placeholder:"What is the name of the metric?",label:"Description",rows:5,register:s("description"),defaultValue:n==null?void 0:n.description})]}),!!o&&h.jsx(_7,{variant:"body-text-2",color:"alert",children:o}),a&&h.jsx("div",{className:"dbn-absolute dbn-w-full dbn-h-full dbn-top-0 dbn-bg-black/[0.1]",children:h.jsx(gA,{})}),h.jsxs(Ed,{children:[h.jsx(e8,{type:"reset",variant:"tab",onClick:i,children:"Cancel"}),h.jsx(e8,{type:"submit",variant:"primary",isDisabled:a,children:"Save"})]})]})},yl={wrapper:"_wrapper_1g0lw_1",valueWrapper:"_valueWrapper_1g0lw_5",value:"_value_1g0lw_5",error:"_error_1g0lw_16",noOptions:"_noOptions_1g0lw_20",floatingLabel:"_floatingLabel_1g0lw_24",badge:"_badge_1g0lw_28",badgeColor:"_badgeColor_1g0lw_32",badgeFull:"_badgeFull_1g0lw_36",dropdown:"_dropdown_1g0lw_74",options:"_options_1g0lw_78",optionsWrapper:"_optionsWrapper_1g0lw_82",checkedOption:"_checkedOption_1g0lw_86",option:"_option_1g0lw_78",searchDiv:"_searchDiv_1g0lw_150",placeholderWrapper:"_placeholderWrapper_1g0lw_158",optionLabel:"_optionLabel_1g0lw_166"};function qW(t,n){return qW=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},qW(t,n)}function Em(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,qW(t,n)}var i20=function(n,i){return n===void 0&&(n=[]),i===void 0&&(i=[]),n.length!==i.length||n.some(function(o,a){return!Object.is(o,i[a])})},GC2={error:null},o20=function(t){Em(n,t);function n(){for(var o,a=arguments.length,s=new Array(a),r=0;r<a;r++)s[r]=arguments[r];return o=t.call.apply(t,[this].concat(s))||this,o.state=GC2,o.resetErrorBoundary=function(){for(var C,l=arguments.length,e=new Array(l),u=0;u<l;u++)e[u]=arguments[u];o.props.onReset==null||(C=o.props).onReset.apply(C,e),o.reset()},o}n.getDerivedStateFromError=function(a){return{error:a}};var i=n.prototype;return i.reset=function(){this.setState(GC2)},i.componentDidCatch=function(a,s){var r,C;(r=(C=this.props).onError)==null||r.call(C,a,s)},i.componentDidUpdate=function(a,s){var r=this.state.error,C=this.props.resetKeys;if(r!==null&&s.error!==null&&i20(a.resetKeys,C)){var l,e;(l=(e=this.props).onResetKeysChange)==null||l.call(e,a.resetKeys,C),this.reset()}},i.render=function(){var a=this.state.error,s=this.props,r=s.fallbackRender,C=s.FallbackComponent,l=s.fallback;if(a!==null){var e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(P0.isValidElement(l))return l;if(typeof r=="function")return r(e);if(C)return P0.createElement(C,e);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(P0.Component),Ey=function(){function t(){this.listeners=[]}var n=t.prototype;return n.subscribe=function(o){var a=this,s=o||function(){};return this.listeners.push(s),this.onSubscribe(),function(){a.listeners=a.listeners.filter(function(r){return r!==s}),a.onUnsubscribe()}},n.hasListeners=function(){return this.listeners.length>0},n.onSubscribe=function(){},n.onUnsubscribe=function(){},t}();function oC(){return oC=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var o in i)({}).hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},oC.apply(null,arguments)}var hS=typeof window>"u";function lA(){}function a20(t,n){return typeof t=="function"?t(n):t}function $W(t){return typeof t=="number"&&t>=0&&t!==1/0}function ES(t){return Array.isArray(t)?t:[t]}function YC2(t,n){return Math.max(t+(n||0)-Date.now(),0)}function pS(t,n,i){return HM(t)?typeof n=="function"?oC({},i,{queryKey:t,queryFn:n}):oC({},n,{queryKey:t}):t}function s20(t,n,i){return HM(t)?typeof n=="function"?oC({},i,{mutationKey:t,mutationFn:n}):oC({},n,{mutationKey:t}):typeof t=="function"?oC({},n,{mutationFn:t}):oC({},t)}function Wp(t,n,i){return HM(t)?[oC({},n,{queryKey:t}),i]:[t||{},n]}function C20(t,n){if(t===!0&&n===!0||t==null&&n==null)return"all";if(t===!1&&n===!1)return"none";var i=t??!n;return i?"active":"inactive"}function WC2(t,n){var i=t.active,o=t.exact,a=t.fetching,s=t.inactive,r=t.predicate,C=t.queryKey,l=t.stale;if(HM(C)){if(o){if(n.queryHash!==e_(C,n.options))return!1}else if(!vS(n.queryKey,C))return!1}var e=C20(i,s);if(e==="none")return!1;if(e!=="all"){var u=n.isActive();if(e==="active"&&!u||e==="inactive"&&u)return!1}return!(typeof l=="boolean"&&n.isStale()!==l||typeof a=="boolean"&&n.isFetching()!==a||r&&!r(n))}function _C2(t,n){var i=t.exact,o=t.fetching,a=t.predicate,s=t.mutationKey;if(HM(s)){if(!n.options.mutationKey)return!1;if(i){if(pm(n.options.mutationKey)!==pm(s))return!1}else if(!vS(n.options.mutationKey,s))return!1}return!(typeof o=="boolean"&&n.state.status==="loading"!==o||a&&!a(n))}function e_(t,n){var i=(n==null?void 0:n.queryKeyHashFn)||pm;return i(t)}function pm(t){var n=ES(t);return l20(n)}function l20(t){return JSON.stringify(t,function(n,i){return t_(i)?Object.keys(i).sort().reduce(function(o,a){return o[a]=i[a],o},{}):i})}function vS(t,n){return XC2(ES(t),ES(n))}function XC2(t,n){return t===n?!0:typeof t!=typeof n?!1:t&&n&&typeof t=="object"&&typeof n=="object"?!Object.keys(n).some(function(i){return!XC2(t[i],n[i])}):!1}function IS(t,n){if(t===n)return t;var i=Array.isArray(t)&&Array.isArray(n);if(i||t_(t)&&t_(n)){for(var o=i?t.length:Object.keys(t).length,a=i?n:Object.keys(n),s=a.length,r=i?[]:{},C=0,l=0;l<s;l++){var e=i?l:a[l];r[e]=IS(t[e],n[e]),r[e]===t[e]&&C++}return o===s&&C===o?t:r}return n}function u20(t,n){if(t&&!n||n&&!t)return!1;for(var i in t)if(t[i]!==n[i])return!1;return!0}function t_(t){if(!KC2(t))return!1;var n=t.constructor;if(typeof n>"u")return!0;var i=n.prototype;return!(!KC2(i)||!i.hasOwnProperty("isPrototypeOf"))}function KC2(t){return Object.prototype.toString.call(t)==="[object Object]"}function HM(t){return typeof t=="string"||Array.isArray(t)}function A20(t){return new Promise(function(n){setTimeout(n,t)})}function JC2(t){Promise.resolve().then(t).catch(function(n){return setTimeout(function(){throw n})})}function qC2(){if(typeof AbortController=="function")return new AbortController}var c20=function(t){Em(n,t);function n(){var o;return o=t.call(this)||this,o.setup=function(a){var s;if(!hS&&((s=window)!=null&&s.addEventListener)){var r=function(){return a()};return window.addEventListener("visibilitychange",r,!1),window.addEventListener("focus",r,!1),function(){window.removeEventListener("visibilitychange",r),window.removeEventListener("focus",r)}}},o}var i=n.prototype;return i.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},i.onUnsubscribe=function(){if(!this.hasListeners()){var a;(a=this.cleanup)==null||a.call(this),this.cleanup=void 0}},i.setEventListener=function(a){var s,r=this;this.setup=a,(s=this.cleanup)==null||s.call(this),this.cleanup=a(function(C){typeof C=="boolean"?r.setFocused(C):r.onFocus()})},i.setFocused=function(a){this.focused=a,a&&this.onFocus()},i.onFocus=function(){this.listeners.forEach(function(a){a()})},i.isFocused=function(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)},n}(Ey),DM=new c20,f20=function(t){Em(n,t);function n(){var o;return o=t.call(this)||this,o.setup=function(a){var s;if(!hS&&((s=window)!=null&&s.addEventListener)){var r=function(){return a()};return window.addEventListener("online",r,!1),window.addEventListener("offline",r,!1),function(){window.removeEventListener("online",r),window.removeEventListener("offline",r)}}},o}var i=n.prototype;return i.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},i.onUnsubscribe=function(){if(!this.hasListeners()){var a;(a=this.cleanup)==null||a.call(this),this.cleanup=void 0}},i.setEventListener=function(a){var s,r=this;this.setup=a,(s=this.cleanup)==null||s.call(this),this.cleanup=a(function(C){typeof C=="boolean"?r.setOnline(C):r.onOnline()})},i.setOnline=function(a){this.online=a,a&&this.onOnline()},i.onOnline=function(){this.listeners.forEach(function(a){a()})},i.isOnline=function(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine},n}(Ey),mS=new f20;function d20(t){return Math.min(1e3*Math.pow(2,t),3e4)}function bS(t){return typeof(t==null?void 0:t.cancel)=="function"}var $C2=function(n){this.revert=n==null?void 0:n.revert,this.silent=n==null?void 0:n.silent};function BS(t){return t instanceof $C2}var el2=function(n){var i=this,o=!1,a,s,r,C;this.abort=n.abort,this.cancel=function(f){return a==null?void 0:a(f)},this.cancelRetry=function(){o=!0},this.continueRetry=function(){o=!1},this.continue=function(){return s==null?void 0:s()},this.failureCount=0,this.isPaused=!1,this.isResolved=!1,this.isTransportCancelable=!1,this.promise=new Promise(function(f,d){r=f,C=d});var l=function(d){i.isResolved||(i.isResolved=!0,n.onSuccess==null||n.onSuccess(d),s==null||s(),r(d))},e=function(d){i.isResolved||(i.isResolved=!0,n.onError==null||n.onError(d),s==null||s(),C(d))},u=function(){return new Promise(function(d){s=d,i.isPaused=!0,n.onPause==null||n.onPause()}).then(function(){s=void 0,i.isPaused=!1,n.onContinue==null||n.onContinue()})},A=function f(){if(!i.isResolved){var d;try{d=n.fn()}catch(g){d=Promise.reject(g)}a=function(E){if(!i.isResolved&&(e(new $C2(E)),i.abort==null||i.abort(),bS(d)))try{d.cancel()}catch{}},i.isTransportCancelable=bS(d),Promise.resolve(d).then(l).catch(function(g){var E,y;if(!i.isResolved){var Q=(E=n.retry)!=null?E:3,R=(y=n.retryDelay)!=null?y:d20,D=typeof R=="function"?R(i.failureCount,g):R,O=Q===!0||typeof Q=="number"&&i.failureCount<Q||typeof Q=="function"&&Q(i.failureCount,g);if(o||!O){e(g);return}i.failureCount++,n.onFail==null||n.onFail(i.failureCount,g),A20(D).then(function(){if(!DM.isFocused()||!mS.isOnline())return u()}).then(function(){o?e(g):f()})}})}};A()},g20=function(){function t(){this.queue=[],this.transactions=0,this.notifyFn=function(i){i()},this.batchNotifyFn=function(i){i()}}var n=t.prototype;return n.batch=function(o){var a;this.transactions++;try{a=o()}finally{this.transactions--,this.transactions||this.flush()}return a},n.schedule=function(o){var a=this;this.transactions?this.queue.push(o):JC2(function(){a.notifyFn(o)})},n.batchCalls=function(o){var a=this;return function(){for(var s=arguments.length,r=new Array(s),C=0;C<s;C++)r[C]=arguments[C];a.schedule(function(){o.apply(void 0,r)})}},n.flush=function(){var o=this,a=this.queue;this.queue=[],a.length&&JC2(function(){o.batchNotifyFn(function(){a.forEach(function(s){o.notifyFn(s)})})})},n.setNotifyFunction=function(o){this.notifyFn=o},n.setBatchNotifyFunction=function(o){this.batchNotifyFn=o},t}(),Nl=new g20,tl2=console;function yS(){return tl2}function h20(t){tl2=t}var E20=function(){function t(i){this.abortSignalConsumed=!1,this.hadObservers=!1,this.defaultOptions=i.defaultOptions,this.setOptions(i.options),this.observers=[],this.cache=i.cache,this.queryKey=i.queryKey,this.queryHash=i.queryHash,this.initialState=i.state||this.getDefaultState(this.options),this.state=this.initialState,this.meta=i.meta,this.scheduleGc()}var n=t.prototype;return n.setOptions=function(o){var a;this.options=oC({},this.defaultOptions,o),this.meta=o==null?void 0:o.meta,this.cacheTime=Math.max(this.cacheTime||0,(a=this.options.cacheTime)!=null?a:5*60*1e3)},n.setDefaultOptions=function(o){this.defaultOptions=o},n.scheduleGc=function(){var o=this;this.clearGcTimeout(),$W(this.cacheTime)&&(this.gcTimeout=setTimeout(function(){o.optionalRemove()},this.cacheTime))},n.clearGcTimeout=function(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)},n.optionalRemove=function(){this.observers.length||(this.state.isFetching?this.hadObservers&&this.scheduleGc():this.cache.remove(this))},n.setData=function(o,a){var s,r,C=this.state.data,l=a20(o,C);return(s=(r=this.options).isDataEqual)!=null&&s.call(r,C,l)?l=C:this.options.structuralSharing!==!1&&(l=IS(C,l)),this.dispatch({data:l,type:"success",dataUpdatedAt:a==null?void 0:a.updatedAt}),l},n.setState=function(o,a){this.dispatch({type:"setState",state:o,setStateOptions:a})},n.cancel=function(o){var a,s=this.promise;return(a=this.retryer)==null||a.cancel(o),s?s.then(lA).catch(lA):Promise.resolve()},n.destroy=function(){this.clearGcTimeout(),this.cancel({silent:!0})},n.reset=function(){this.destroy(),this.setState(this.initialState)},n.isActive=function(){return this.observers.some(function(o){return o.options.enabled!==!1})},n.isFetching=function(){return this.state.isFetching},n.isStale=function(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(function(o){return o.getCurrentResult().isStale})},n.isStaleByTime=function(o){return o===void 0&&(o=0),this.state.isInvalidated||!this.state.dataUpdatedAt||!YC2(this.state.dataUpdatedAt,o)},n.onFocus=function(){var o,a=this.observers.find(function(s){return s.shouldFetchOnWindowFocus()});a&&a.refetch(),(o=this.retryer)==null||o.continue()},n.onOnline=function(){var o,a=this.observers.find(function(s){return s.shouldFetchOnReconnect()});a&&a.refetch(),(o=this.retryer)==null||o.continue()},n.addObserver=function(o){this.observers.indexOf(o)===-1&&(this.observers.push(o),this.hadObservers=!0,this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:o}))},n.removeObserver=function(o){this.observers.indexOf(o)!==-1&&(this.observers=this.observers.filter(function(a){return a!==o}),this.observers.length||(this.retryer&&(this.retryer.isTransportCancelable||this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.cacheTime?this.scheduleGc():this.cache.remove(this)),this.cache.notify({type:"observerRemoved",query:this,observer:o}))},n.getObserversCount=function(){return this.observers.length},n.invalidate=function(){this.state.isInvalidated||this.dispatch({type:"invalidate"})},n.fetch=function(o,a){var s=this,r,C,l;if(this.state.isFetching){if(this.state.dataUpdatedAt&&(a!=null&&a.cancelRefetch))this.cancel({silent:!0});else if(this.promise){var e;return(e=this.retryer)==null||e.continueRetry(),this.promise}}if(o&&this.setOptions(o),!this.options.queryFn){var u=this.observers.find(function(R){return R.options.queryFn});u&&this.setOptions(u.options)}var A=ES(this.queryKey),f=qC2(),d={queryKey:A,pageParam:void 0,meta:this.meta};Object.defineProperty(d,"signal",{enumerable:!0,get:function(){if(f)return s.abortSignalConsumed=!0,f.signal}});var g=function(){return s.options.queryFn?(s.abortSignalConsumed=!1,s.options.queryFn(d)):Promise.reject("Missing queryFn")},E={fetchOptions:a,options:this.options,queryKey:A,state:this.state,fetchFn:g,meta:this.meta};if((r=this.options.behavior)!=null&&r.onFetch){var y;(y=this.options.behavior)==null||y.onFetch(E)}if(this.revertState=this.state,!this.state.isFetching||this.state.fetchMeta!==((C=E.fetchOptions)==null?void 0:C.meta)){var Q;this.dispatch({type:"fetch",meta:(Q=E.fetchOptions)==null?void 0:Q.meta})}return this.retryer=new el2({fn:E.fetchFn,abort:f==null||(l=f.abort)==null?void 0:l.bind(f),onSuccess:function(D){s.setData(D),s.cache.config.onSuccess==null||s.cache.config.onSuccess(D,s),s.cacheTime===0&&s.optionalRemove()},onError:function(D){BS(D)&&D.silent||s.dispatch({type:"error",error:D}),BS(D)||(s.cache.config.onError==null||s.cache.config.onError(D,s),yS().error(D)),s.cacheTime===0&&s.optionalRemove()},onFail:function(){s.dispatch({type:"failed"})},onPause:function(){s.dispatch({type:"pause"})},onContinue:function(){s.dispatch({type:"continue"})},retry:E.options.retry,retryDelay:E.options.retryDelay}),this.promise=this.retryer.promise,this.promise},n.dispatch=function(o){var a=this;this.state=this.reducer(this.state,o),Nl.batch(function(){a.observers.forEach(function(s){s.onQueryUpdate(o)}),a.cache.notify({query:a,type:"queryUpdated",action:o})})},n.getDefaultState=function(o){var a=typeof o.initialData=="function"?o.initialData():o.initialData,s=typeof o.initialData<"u",r=s?typeof o.initialDataUpdatedAt=="function"?o.initialDataUpdatedAt():o.initialDataUpdatedAt:0,C=typeof a<"u";return{data:a,dataUpdateCount:0,dataUpdatedAt:C?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchMeta:null,isFetching:!1,isInvalidated:!1,isPaused:!1,status:C?"success":"idle"}},n.reducer=function(o,a){var s,r;switch(a.type){case"failed":return oC({},o,{fetchFailureCount:o.fetchFailureCount+1});case"pause":return oC({},o,{isPaused:!0});case"continue":return oC({},o,{isPaused:!1});case"fetch":return oC({},o,{fetchFailureCount:0,fetchMeta:(s=a.meta)!=null?s:null,isFetching:!0,isPaused:!1},!o.dataUpdatedAt&&{error:null,status:"loading"});case"success":return oC({},o,{data:a.data,dataUpdateCount:o.dataUpdateCount+1,dataUpdatedAt:(r=a.dataUpdatedAt)!=null?r:Date.now(),error:null,fetchFailureCount:0,isFetching:!1,isInvalidated:!1,isPaused:!1,status:"success"});case"error":var C=a.error;return BS(C)&&C.revert&&this.revertState?oC({},this.revertState):oC({},o,{error:C,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,isFetching:!1,isPaused:!1,status:"error"});case"invalidate":return oC({},o,{isInvalidated:!0});case"setState":return oC({},o,a.state);default:return o}},t}(),p20=function(t){Em(n,t);function n(o){var a;return a=t.call(this)||this,a.config=o||{},a.queries=[],a.queriesMap={},a}var i=n.prototype;return i.build=function(a,s,r){var C,l=s.queryKey,e=(C=s.queryHash)!=null?C:e_(l,s),u=this.get(e);return u||(u=new E20({cache:this,queryKey:l,queryHash:e,options:a.defaultQueryOptions(s),state:r,defaultOptions:a.getQueryDefaults(l),meta:s.meta}),this.add(u)),u},i.add=function(a){this.queriesMap[a.queryHash]||(this.queriesMap[a.queryHash]=a,this.queries.push(a),this.notify({type:"queryAdded",query:a}))},i.remove=function(a){var s=this.queriesMap[a.queryHash];s&&(a.destroy(),this.queries=this.queries.filter(function(r){return r!==a}),s===a&&delete this.queriesMap[a.queryHash],this.notify({type:"queryRemoved",query:a}))},i.clear=function(){var a=this;Nl.batch(function(){a.queries.forEach(function(s){a.remove(s)})})},i.get=function(a){return this.queriesMap[a]},i.getAll=function(){return this.queries},i.find=function(a,s){var r=Wp(a,s),C=r[0];return typeof C.exact>"u"&&(C.exact=!0),this.queries.find(function(l){return WC2(C,l)})},i.findAll=function(a,s){var r=Wp(a,s),C=r[0];return Object.keys(C).length>0?this.queries.filter(function(l){return WC2(C,l)}):this.queries},i.notify=function(a){var s=this;Nl.batch(function(){s.listeners.forEach(function(r){r(a)})})},i.onFocus=function(){var a=this;Nl.batch(function(){a.queries.forEach(function(s){s.onFocus()})})},i.onOnline=function(){var a=this;Nl.batch(function(){a.queries.forEach(function(s){s.onOnline()})})},n}(Ey),v20=function(){function t(i){this.options=oC({},i.defaultOptions,i.options),this.mutationId=i.mutationId,this.mutationCache=i.mutationCache,this.observers=[],this.state=i.state||rl2(),this.meta=i.meta}var n=t.prototype;return n.setState=function(o){this.dispatch({type:"setState",state:o})},n.addObserver=function(o){this.observers.indexOf(o)===-1&&this.observers.push(o)},n.removeObserver=function(o){this.observers=this.observers.filter(function(a){return a!==o})},n.cancel=function(){return this.retryer?(this.retryer.cancel(),this.retryer.promise.then(lA).catch(lA)):Promise.resolve()},n.continue=function(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()},n.execute=function(){var o=this,a,s=this.state.status==="loading",r=Promise.resolve();return s||(this.dispatch({type:"loading",variables:this.options.variables}),r=r.then(function(){o.mutationCache.config.onMutate==null||o.mutationCache.config.onMutate(o.state.variables,o)}).then(function(){return o.options.onMutate==null?void 0:o.options.onMutate(o.state.variables)}).then(function(C){C!==o.state.context&&o.dispatch({type:"loading",context:C,variables:o.state.variables})})),r.then(function(){return o.executeMutation()}).then(function(C){a=C,o.mutationCache.config.onSuccess==null||o.mutationCache.config.onSuccess(a,o.state.variables,o.state.context,o)}).then(function(){return o.options.onSuccess==null?void 0:o.options.onSuccess(a,o.state.variables,o.state.context)}).then(function(){return o.options.onSettled==null?void 0:o.options.onSettled(a,null,o.state.variables,o.state.context)}).then(function(){return o.dispatch({type:"success",data:a}),a}).catch(function(C){return o.mutationCache.config.onError==null||o.mutationCache.config.onError(C,o.state.variables,o.state.context,o),yS().error(C),Promise.resolve().then(function(){return o.options.onError==null?void 0:o.options.onError(C,o.state.variables,o.state.context)}).then(function(){return o.options.onSettled==null?void 0:o.options.onSettled(void 0,C,o.state.variables,o.state.context)}).then(function(){throw o.dispatch({type:"error",error:C}),C})})},n.executeMutation=function(){var o=this,a;return this.retryer=new el2({fn:function(){return o.options.mutationFn?o.options.mutationFn(o.state.variables):Promise.reject("No mutationFn found")},onFail:function(){o.dispatch({type:"failed"})},onPause:function(){o.dispatch({type:"pause"})},onContinue:function(){o.dispatch({type:"continue"})},retry:(a=this.options.retry)!=null?a:0,retryDelay:this.options.retryDelay}),this.retryer.promise},n.dispatch=function(o){var a=this;this.state=I20(this.state,o),Nl.batch(function(){a.observers.forEach(function(s){s.onMutationUpdate(o)}),a.mutationCache.notify(a)})},t}();function rl2(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}function I20(t,n){switch(n.type){case"failed":return oC({},t,{failureCount:t.failureCount+1});case"pause":return oC({},t,{isPaused:!0});case"continue":return oC({},t,{isPaused:!1});case"loading":return oC({},t,{context:n.context,data:void 0,error:null,isPaused:!1,status:"loading",variables:n.variables});case"success":return oC({},t,{data:n.data,error:null,status:"success",isPaused:!1});case"error":return oC({},t,{data:void 0,error:n.error,failureCount:t.failureCount+1,isPaused:!1,status:"error"});case"setState":return oC({},t,n.state);default:return t}}var m20=function(t){Em(n,t);function n(o){var a;return a=t.call(this)||this,a.config=o||{},a.mutations=[],a.mutationId=0,a}var i=n.prototype;return i.build=function(a,s,r){var C=new v20({mutationCache:this,mutationId:++this.mutationId,options:a.defaultMutationOptions(s),state:r,defaultOptions:s.mutationKey?a.getMutationDefaults(s.mutationKey):void 0,meta:s.meta});return this.add(C),C},i.add=function(a){this.mutations.push(a),this.notify(a)},i.remove=function(a){this.mutations=this.mutations.filter(function(s){return s!==a}),a.cancel(),this.notify(a)},i.clear=function(){var a=this;Nl.batch(function(){a.mutations.forEach(function(s){a.remove(s)})})},i.getAll=function(){return this.mutations},i.find=function(a){return typeof a.exact>"u"&&(a.exact=!0),this.mutations.find(function(s){return _C2(a,s)})},i.findAll=function(a){return this.mutations.filter(function(s){return _C2(a,s)})},i.notify=function(a){var s=this;Nl.batch(function(){s.listeners.forEach(function(r){r(a)})})},i.onFocus=function(){this.resumePausedMutations()},i.onOnline=function(){this.resumePausedMutations()},i.resumePausedMutations=function(){var a=this.mutations.filter(function(s){return s.state.isPaused});return Nl.batch(function(){return a.reduce(function(s,r){return s.then(function(){return r.continue().catch(lA)})},Promise.resolve())})},n}(Ey);function b20(){return{onFetch:function(n){n.fetchFn=function(){var i,o,a,s,r,C,l=(i=n.fetchOptions)==null||(o=i.meta)==null?void 0:o.refetchPage,e=(a=n.fetchOptions)==null||(s=a.meta)==null?void 0:s.fetchMore,u=e==null?void 0:e.pageParam,A=(e==null?void 0:e.direction)==="forward",f=(e==null?void 0:e.direction)==="backward",d=((r=n.state.data)==null?void 0:r.pages)||[],g=((C=n.state.data)==null?void 0:C.pageParams)||[],E=qC2(),y=E==null?void 0:E.signal,Q=g,R=!1,D=n.options.queryFn||function(){return Promise.reject("Missing queryFn")},O=function(M2,Z2,Y2,f0){return Q=f0?[Z2].concat(Q):[].concat(Q,[Z2]),f0?[Y2].concat(M2):[].concat(M2,[Y2])},k=function(M2,Z2,Y2,f0){if(R)return Promise.reject("Cancelled");if(typeof Y2>"u"&&!Z2&&M2.length)return Promise.resolve(M2);var E0={queryKey:n.queryKey,signal:y,pageParam:Y2,meta:n.meta},M0=D(E0),x0=Promise.resolve(M0).then(function(t1){return O(M2,Y2,t1,f0)});if(bS(M0)){var z2=x0;z2.cancel=M0.cancel}return x0},J;if(!d.length)J=k([]);else if(A){var e2=typeof u<"u",p2=e2?u:nl2(n.options,d);J=k(d,e2,p2)}else if(f){var D2=typeof u<"u",Q2=D2?u:B20(n.options,d);J=k(d,D2,Q2,!0)}else(function(){Q=[];var R2=typeof n.options.getNextPageParam>"u",M2=l&&d[0]?l(d[0],0,d):!0;J=M2?k([],R2,g[0]):Promise.resolve(O([],g[0],d[0]));for(var Z2=function(E0){J=J.then(function(M0){var x0=l&&d[E0]?l(d[E0],E0,d):!0;if(x0){var z2=R2?g[E0]:nl2(n.options,M0);return k(M0,R2,z2)}return Promise.resolve(O(M0,g[E0],d[E0]))})},Y2=1;Y2<d.length;Y2++)Z2(Y2)})();var i2=J.then(function(R2){return{pages:R2,pageParams:Q}}),N2=i2;return N2.cancel=function(){R=!0,E==null||E.abort(),bS(J)&&J.cancel()},i2}}}}function nl2(t,n){return t.getNextPageParam==null?void 0:t.getNextPageParam(n[n.length-1],n)}function B20(t,n){return t.getPreviousPageParam==null?void 0:t.getPreviousPageParam(n[0],n)}var y20=function(){function t(i){i===void 0&&(i={}),this.queryCache=i.queryCache||new p20,this.mutationCache=i.mutationCache||new m20,this.defaultOptions=i.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}var n=t.prototype;return n.mount=function(){var o=this;this.unsubscribeFocus=DM.subscribe(function(){DM.isFocused()&&mS.isOnline()&&(o.mutationCache.onFocus(),o.queryCache.onFocus())}),this.unsubscribeOnline=mS.subscribe(function(){DM.isFocused()&&mS.isOnline()&&(o.mutationCache.onOnline(),o.queryCache.onOnline())})},n.unmount=function(){var o,a;(o=this.unsubscribeFocus)==null||o.call(this),(a=this.unsubscribeOnline)==null||a.call(this)},n.isFetching=function(o,a){var s=Wp(o,a),r=s[0];return r.fetching=!0,this.queryCache.findAll(r).length},n.isMutating=function(o){return this.mutationCache.findAll(oC({},o,{fetching:!0})).length},n.getQueryData=function(o,a){var s;return(s=this.queryCache.find(o,a))==null?void 0:s.state.data},n.getQueriesData=function(o){return this.getQueryCache().findAll(o).map(function(a){var s=a.queryKey,r=a.state,C=r.data;return[s,C]})},n.setQueryData=function(o,a,s){var r=pS(o),C=this.defaultQueryOptions(r);return this.queryCache.build(this,C).setData(a,s)},n.setQueriesData=function(o,a,s){var r=this;return Nl.batch(function(){return r.getQueryCache().findAll(o).map(function(C){var l=C.queryKey;return[l,r.setQueryData(l,a,s)]})})},n.getQueryState=function(o,a){var s;return(s=this.queryCache.find(o,a))==null?void 0:s.state},n.removeQueries=function(o,a){var s=Wp(o,a),r=s[0],C=this.queryCache;Nl.batch(function(){C.findAll(r).forEach(function(l){C.remove(l)})})},n.resetQueries=function(o,a,s){var r=this,C=Wp(o,a,s),l=C[0],e=C[1],u=this.queryCache,A=oC({},l,{active:!0});return Nl.batch(function(){return u.findAll(l).forEach(function(f){f.reset()}),r.refetchQueries(A,e)})},n.cancelQueries=function(o,a,s){var r=this,C=Wp(o,a,s),l=C[0],e=C[1],u=e===void 0?{}:e;typeof u.revert>"u"&&(u.revert=!0);var A=Nl.batch(function(){return r.queryCache.findAll(l).map(function(f){return f.cancel(u)})});return Promise.all(A).then(lA).catch(lA)},n.invalidateQueries=function(o,a,s){var r,C,l,e=this,u=Wp(o,a,s),A=u[0],f=u[1],d=oC({},A,{active:(r=(C=A.refetchActive)!=null?C:A.active)!=null?r:!0,inactive:(l=A.refetchInactive)!=null?l:!1});return Nl.batch(function(){return e.queryCache.findAll(A).forEach(function(g){g.invalidate()}),e.refetchQueries(d,f)})},n.refetchQueries=function(o,a,s){var r=this,C=Wp(o,a,s),l=C[0],e=C[1],u=Nl.batch(function(){return r.queryCache.findAll(l).map(function(f){return f.fetch(void 0,oC({},e,{meta:{refetchPage:l==null?void 0:l.refetchPage}}))})}),A=Promise.all(u).then(lA);return e!=null&&e.throwOnError||(A=A.catch(lA)),A},n.fetchQuery=function(o,a,s){var r=pS(o,a,s),C=this.defaultQueryOptions(r);typeof C.retry>"u"&&(C.retry=!1);var l=this.queryCache.build(this,C);return l.isStaleByTime(C.staleTime)?l.fetch(C):Promise.resolve(l.state.data)},n.prefetchQuery=function(o,a,s){return this.fetchQuery(o,a,s).then(lA).catch(lA)},n.fetchInfiniteQuery=function(o,a,s){var r=pS(o,a,s);return r.behavior=b20(),this.fetchQuery(r)},n.prefetchInfiniteQuery=function(o,a,s){return this.fetchInfiniteQuery(o,a,s).then(lA).catch(lA)},n.cancelMutations=function(){var o=this,a=Nl.batch(function(){return o.mutationCache.getAll().map(function(s){return s.cancel()})});return Promise.all(a).then(lA).catch(lA)},n.resumePausedMutations=function(){return this.getMutationCache().resumePausedMutations()},n.executeMutation=function(o){return this.mutationCache.build(this,o).execute()},n.getQueryCache=function(){return this.queryCache},n.getMutationCache=function(){return this.mutationCache},n.getDefaultOptions=function(){return this.defaultOptions},n.setDefaultOptions=function(o){this.defaultOptions=o},n.setQueryDefaults=function(o,a){var s=this.queryDefaults.find(function(r){return pm(o)===pm(r.queryKey)});s?s.defaultOptions=a:this.queryDefaults.push({queryKey:o,defaultOptions:a})},n.getQueryDefaults=function(o){var a;return o?(a=this.queryDefaults.find(function(s){return vS(o,s.queryKey)}))==null?void 0:a.defaultOptions:void 0},n.setMutationDefaults=function(o,a){var s=this.mutationDefaults.find(function(r){return pm(o)===pm(r.mutationKey)});s?s.defaultOptions=a:this.mutationDefaults.push({mutationKey:o,defaultOptions:a})},n.getMutationDefaults=function(o){var a;return o?(a=this.mutationDefaults.find(function(s){return vS(o,s.mutationKey)}))==null?void 0:a.defaultOptions:void 0},n.defaultQueryOptions=function(o){if(o!=null&&o._defaulted)return o;var a=oC({},this.defaultOptions.queries,this.getQueryDefaults(o==null?void 0:o.queryKey),o,{_defaulted:!0});return!a.queryHash&&a.queryKey&&(a.queryHash=e_(a.queryKey,a)),a},n.defaultQueryObserverOptions=function(o){return this.defaultQueryOptions(o)},n.defaultMutationOptions=function(o){return o!=null&&o._defaulted?o:oC({},this.defaultOptions.mutations,this.getMutationDefaults(o==null?void 0:o.mutationKey),o,{_defaulted:!0})},n.clear=function(){this.queryCache.clear(),this.mutationCache.clear()},t}(),L20=function(t){Em(n,t);function n(o,a){var s;return s=t.call(this)||this,s.client=o,s.options=a,s.trackedProps=[],s.selectError=null,s.bindMethods(),s.setOptions(a),s}var i=n.prototype;return i.bindMethods=function(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)},i.onSubscribe=function(){this.listeners.length===1&&(this.currentQuery.addObserver(this),il2(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},i.onUnsubscribe=function(){this.listeners.length||this.destroy()},i.shouldFetchOnReconnect=function(){return r_(this.currentQuery,this.options,this.options.refetchOnReconnect)},i.shouldFetchOnWindowFocus=function(){return r_(this.currentQuery,this.options,this.options.refetchOnWindowFocus)},i.destroy=function(){this.listeners=[],this.clearTimers(),this.currentQuery.removeObserver(this)},i.setOptions=function(a,s){var r=this.options,C=this.currentQuery;if(this.options=this.client.defaultQueryObserverOptions(a),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),this.updateQuery();var l=this.hasListeners();l&&ol2(this.currentQuery,C,this.options,r)&&this.executeFetch(),this.updateResult(s),l&&(this.currentQuery!==C||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&this.updateStaleTimeout();var e=this.computeRefetchInterval();l&&(this.currentQuery!==C||this.options.enabled!==r.enabled||e!==this.currentRefetchInterval)&&this.updateRefetchInterval(e)},i.getOptimisticResult=function(a){var s=this.client.defaultQueryObserverOptions(a),r=this.client.getQueryCache().build(this.client,s);return this.createResult(r,s)},i.getCurrentResult=function(){return this.currentResult},i.trackResult=function(a,s){var r=this,C={},l=function(u){r.trackedProps.includes(u)||r.trackedProps.push(u)};return Object.keys(a).forEach(function(e){Object.defineProperty(C,e,{configurable:!1,enumerable:!0,get:function(){return l(e),a[e]}})}),(s.useErrorBoundary||s.suspense)&&l("error"),C},i.getNextResult=function(a){var s=this;return new Promise(function(r,C){var l=s.subscribe(function(e){e.isFetching||(l(),e.isError&&(a!=null&&a.throwOnError)?C(e.error):r(e))})})},i.getCurrentQuery=function(){return this.currentQuery},i.remove=function(){this.client.getQueryCache().remove(this.currentQuery)},i.refetch=function(a){return this.fetch(oC({},a,{meta:{refetchPage:a==null?void 0:a.refetchPage}}))},i.fetchOptimistic=function(a){var s=this,r=this.client.defaultQueryObserverOptions(a),C=this.client.getQueryCache().build(this.client,r);return C.fetch().then(function(){return s.createResult(C,r)})},i.fetch=function(a){var s=this;return this.executeFetch(a).then(function(){return s.updateResult(),s.currentResult})},i.executeFetch=function(a){this.updateQuery();var s=this.currentQuery.fetch(this.options,a);return a!=null&&a.throwOnError||(s=s.catch(lA)),s},i.updateStaleTimeout=function(){var a=this;if(this.clearStaleTimeout(),!(hS||this.currentResult.isStale||!$W(this.options.staleTime))){var s=YC2(this.currentResult.dataUpdatedAt,this.options.staleTime),r=s+1;this.staleTimeoutId=setTimeout(function(){a.currentResult.isStale||a.updateResult()},r)}},i.computeRefetchInterval=function(){var a;return typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.currentResult.data,this.currentQuery):(a=this.options.refetchInterval)!=null?a:!1},i.updateRefetchInterval=function(a){var s=this;this.clearRefetchInterval(),this.currentRefetchInterval=a,!(hS||this.options.enabled===!1||!$W(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(function(){(s.options.refetchIntervalInBackground||DM.isFocused())&&s.executeFetch()},this.currentRefetchInterval))},i.updateTimers=function(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())},i.clearTimers=function(){this.clearStaleTimeout(),this.clearRefetchInterval()},i.clearStaleTimeout=function(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)},i.clearRefetchInterval=function(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)},i.createResult=function(a,s){var r=this.currentQuery,C=this.options,l=this.currentResult,e=this.currentResultState,u=this.currentResultOptions,A=a!==r,f=A?a.state:this.currentQueryInitialState,d=A?this.currentResult:this.previousQueryResult,g=a.state,E=g.dataUpdatedAt,y=g.error,Q=g.errorUpdatedAt,R=g.isFetching,D=g.status,O=!1,k=!1,J;if(s.optimisticResults){var e2=this.hasListeners(),p2=!e2&&il2(a,s),D2=e2&&ol2(a,r,s,C);(p2||D2)&&(R=!0,E||(D="loading"))}if(s.keepPreviousData&&!g.dataUpdateCount&&(d!=null&&d.isSuccess)&&D!=="error")J=d.data,E=d.dataUpdatedAt,D=d.status,O=!0;else if(s.select&&typeof g.data<"u")if(l&&g.data===(e==null?void 0:e.data)&&s.select===this.selectFn)J=this.selectResult;else try{this.selectFn=s.select,J=s.select(g.data),s.structuralSharing!==!1&&(J=IS(l==null?void 0:l.data,J)),this.selectResult=J,this.selectError=null}catch(N2){yS().error(N2),this.selectError=N2}else J=g.data;if(typeof s.placeholderData<"u"&&typeof J>"u"&&(D==="loading"||D==="idle")){var Q2;if(l!=null&&l.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData))Q2=l.data;else if(Q2=typeof s.placeholderData=="function"?s.placeholderData():s.placeholderData,s.select&&typeof Q2<"u")try{Q2=s.select(Q2),s.structuralSharing!==!1&&(Q2=IS(l==null?void 0:l.data,Q2)),this.selectError=null}catch(N2){yS().error(N2),this.selectError=N2}typeof Q2<"u"&&(D="success",J=Q2,k=!0)}this.selectError&&(y=this.selectError,J=this.selectResult,Q=Date.now(),D="error");var i2={status:D,isLoading:D==="loading",isSuccess:D==="success",isError:D==="error",isIdle:D==="idle",data:J,dataUpdatedAt:E,error:y,errorUpdatedAt:Q,failureCount:g.fetchFailureCount,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>f.dataUpdateCount||g.errorUpdateCount>f.errorUpdateCount,isFetching:R,isRefetching:R&&D!=="loading",isLoadingError:D==="error"&&g.dataUpdatedAt===0,isPlaceholderData:k,isPreviousData:O,isRefetchError:D==="error"&&g.dataUpdatedAt!==0,isStale:n_(a,s),refetch:this.refetch,remove:this.remove};return i2},i.shouldNotifyListeners=function(a,s){if(!s)return!0;var r=this.options,C=r.notifyOnChangeProps,l=r.notifyOnChangePropsExclusions;if(!C&&!l||C==="tracked"&&!this.trackedProps.length)return!0;var e=C==="tracked"?this.trackedProps:C;return Object.keys(a).some(function(u){var A=u,f=a[A]!==s[A],d=e==null?void 0:e.some(function(E){return E===u}),g=l==null?void 0:l.some(function(E){return E===u});return f&&!g&&(!e||d)})},i.updateResult=function(a){var s=this.currentResult;if(this.currentResult=this.createResult(this.currentQuery,this.options),this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,!u20(this.currentResult,s)){var r={cache:!0};(a==null?void 0:a.listeners)!==!1&&this.shouldNotifyListeners(this.currentResult,s)&&(r.listeners=!0),this.notify(oC({},r,a))}},i.updateQuery=function(){var a=this.client.getQueryCache().build(this.client,this.options);if(a!==this.currentQuery){var s=this.currentQuery;this.currentQuery=a,this.currentQueryInitialState=a.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(s==null||s.removeObserver(this),a.addObserver(this))}},i.onQueryUpdate=function(a){var s={};a.type==="success"?s.onSuccess=!0:a.type==="error"&&!BS(a.error)&&(s.onError=!0),this.updateResult(s),this.hasListeners()&&this.updateTimers()},i.notify=function(a){var s=this;Nl.batch(function(){a.onSuccess?(s.options.onSuccess==null||s.options.onSuccess(s.currentResult.data),s.options.onSettled==null||s.options.onSettled(s.currentResult.data,null)):a.onError&&(s.options.onError==null||s.options.onError(s.currentResult.error),s.options.onSettled==null||s.options.onSettled(void 0,s.currentResult.error)),a.listeners&&s.listeners.forEach(function(r){r(s.currentResult)}),a.cache&&s.client.getQueryCache().notify({query:s.currentQuery,type:"observerResultsUpdated"})})},n}(Ey);function w20(t,n){return n.enabled!==!1&&!t.state.dataUpdatedAt&&!(t.state.status==="error"&&n.retryOnMount===!1)}function il2(t,n){return w20(t,n)||t.state.dataUpdatedAt>0&&r_(t,n,n.refetchOnMount)}function r_(t,n,i){if(n.enabled!==!1){var o=typeof i=="function"?i(t):i;return o==="always"||o!==!1&&n_(t,n)}return!1}function ol2(t,n,i,o){return i.enabled!==!1&&(t!==n||o.enabled===!1)&&(!i.suspense||t.state.status!=="error")&&n_(t,i)}function n_(t,n){return t.isStaleByTime(n.staleTime)}var Q20=function(t){Em(n,t);function n(o,a){var s;return s=t.call(this)||this,s.client=o,s.setOptions(a),s.bindMethods(),s.updateResult(),s}var i=n.prototype;return i.bindMethods=function(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)},i.setOptions=function(a){this.options=this.client.defaultMutationOptions(a)},i.onUnsubscribe=function(){if(!this.listeners.length){var a;(a=this.currentMutation)==null||a.removeObserver(this)}},i.onMutationUpdate=function(a){this.updateResult();var s={listeners:!0};a.type==="success"?s.onSuccess=!0:a.type==="error"&&(s.onError=!0),this.notify(s)},i.getCurrentResult=function(){return this.currentResult},i.reset=function(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})},i.mutate=function(a,s){return this.mutateOptions=s,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,oC({},this.options,{variables:typeof a<"u"?a:this.options.variables})),this.currentMutation.addObserver(this),this.currentMutation.execute()},i.updateResult=function(){var a=this.currentMutation?this.currentMutation.state:rl2(),s=oC({},a,{isLoading:a.status==="loading",isSuccess:a.status==="success",isError:a.status==="error",isIdle:a.status==="idle",mutate:this.mutate,reset:this.reset});this.currentResult=s},i.notify=function(a){var s=this;Nl.batch(function(){s.mutateOptions&&(a.onSuccess?(s.mutateOptions.onSuccess==null||s.mutateOptions.onSuccess(s.currentResult.data,s.currentResult.variables,s.currentResult.context),s.mutateOptions.onSettled==null||s.mutateOptions.onSettled(s.currentResult.data,null,s.currentResult.variables,s.currentResult.context)):a.onError&&(s.mutateOptions.onError==null||s.mutateOptions.onError(s.currentResult.error,s.currentResult.variables,s.currentResult.context),s.mutateOptions.onSettled==null||s.mutateOptions.onSettled(void 0,s.currentResult.error,s.currentResult.variables,s.currentResult.context))),a.listeners&&s.listeners.forEach(function(r){r(s.currentResult)})})},n}(Ey),M20=EP.unstable_batchedUpdates;Nl.setBatchNotifyFunction(M20);var T20=console;h20(T20);var al2=T9.createContext(void 0),sl2=T9.createContext(!1);function Cl2(t){return t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=al2),window.ReactQueryClientContext):al2}var i_=function(){var n=T9.useContext(Cl2(T9.useContext(sl2)));if(!n)throw new Error("No QueryClient set, use QueryClientProvider to set one");return n},x20=function(n){var i=n.client,o=n.contextSharing,a=o===void 0?!1:o,s=n.children;T9.useEffect(function(){return i.mount(),function(){i.unmount()}},[i]);var r=Cl2(a);return T9.createElement(sl2.Provider,{value:a},T9.createElement(r.Provider,{value:i},s))};function R20(){var t=!1;return{clearReset:function(){t=!1},reset:function(){t=!0},isReset:function(){return t}}}var H20=T9.createContext(R20()),D20=function(){return T9.useContext(H20)};function ll2(t,n,i){return typeof n=="function"?n.apply(void 0,i):typeof n=="boolean"?n:!!t}function Wl(t,n,i){var o=T9.useRef(!1),a=T9.useState(0),s=a[1],r=s20(t,n,i),C=i_(),l=T9.useRef();l.current?l.current.setOptions(r):l.current=new Q20(C,r);var e=l.current.getCurrentResult();T9.useEffect(function(){o.current=!0;var A=l.current.subscribe(Nl.batchCalls(function(){o.current&&s(function(f){return f+1})}));return function(){o.current=!1,A()}},[]);var u=T9.useCallback(function(A,f){l.current.mutate(A,f).catch(lA)},[]);if(e.error&&ll2(void 0,l.current.options.useErrorBoundary,[e.error]))throw e.error;return oC({},e,{mutate:u,mutateAsync:e.mutate})}function N20(t,n){var i=T9.useRef(!1),o=T9.useState(0),a=o[1],s=i_(),r=D20(),C=s.defaultQueryObserverOptions(t);C.optimisticResults=!0,C.onError&&(C.onError=Nl.batchCalls(C.onError)),C.onSuccess&&(C.onSuccess=Nl.batchCalls(C.onSuccess)),C.onSettled&&(C.onSettled=Nl.batchCalls(C.onSettled)),C.suspense&&(typeof C.staleTime!="number"&&(C.staleTime=1e3),C.cacheTime===0&&(C.cacheTime=1)),(C.suspense||C.useErrorBoundary)&&(r.isReset()||(C.retryOnMount=!1));var l=T9.useState(function(){return new n(s,C)}),e=l[0],u=e.getOptimisticResult(C);if(T9.useEffect(function(){i.current=!0,r.clearReset();var A=e.subscribe(Nl.batchCalls(function(){i.current&&a(function(f){return f+1})}));return e.updateResult(),function(){i.current=!1,A()}},[r,e]),T9.useEffect(function(){e.setOptions(C,{listeners:!1})},[C,e]),C.suspense&&u.isLoading)throw e.fetchOptimistic(C).then(function(A){var f=A.data;C.onSuccess==null||C.onSuccess(f),C.onSettled==null||C.onSettled(f,null)}).catch(function(A){r.clearReset(),C.onError==null||C.onError(A),C.onSettled==null||C.onSettled(void 0,A)});if(u.isError&&!r.isReset()&&!u.isFetching&&ll2(C.suspense,C.useErrorBoundary,[u.error,e.getCurrentQuery()]))throw u.error;return C.notifyOnChangeProps==="tracked"&&(u=e.trackResult(u,C)),u}function _p(t,n,i){var o=pS(t,n,i);return N20(o,L20)}var tg,p4=typeof window<"u"?window:void 0,Gc=typeof globalThis<"u"?globalThis:p4,ul2=Array.prototype,Al2=ul2.forEach,cl2=ul2.indexOf,Bf=Gc==null?void 0:Gc.navigator,Fn=Gc==null?void 0:Gc.document,cd=Gc==null?void 0:Gc.location,o_=Gc==null?void 0:Gc.fetch,a_=Gc!=null&&Gc.XMLHttpRequest&&"withCredentials"in new Gc.XMLHttpRequest?Gc.XMLHttpRequest:void 0,fl2=Gc==null?void 0:Gc.AbortController,vu=Bf==null?void 0:Bf.userAgent,zs=p4??{},pE={DEBUG:!1,LIB_VERSION:"1.234.1"},s_="$copy_autocapture",S20=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];(function(t){t.GZipJS="gzip-js",t.Base64="base64"})(tg||(tg={}));var V20=["fatal","error","warning","log","info","debug"];function lC(t,n){return t.indexOf(n)!==-1}var LS=function(t){return t.trim()},C_=function(t){return t.replace(/^\$/,"")},k20=Array.isArray,dl2=Object.prototype,gl2=dl2.hasOwnProperty,wS=dl2.toString,_l=k20||function(t){return wS.call(t)==="[object Array]"},rg=t=>typeof t=="function",Xl=t=>t===Object(t)&&!_l(t),py=t=>{if(Xl(t)){for(var n in t)if(gl2.call(t,n))return!1;return!0}return!1},Mr=t=>t===void 0,Iu=t=>wS.call(t)=="[object String]",l_=t=>Iu(t)&&t.trim().length===0,Xp=t=>t===null,ll=t=>Mr(t)||Xp(t),Ac=t=>wS.call(t)=="[object Number]",Kp=t=>wS.call(t)==="[object Boolean]",O20=t=>t instanceof FormData,P20=t=>lC(S20,t),hl2=t=>{var n={_log:function(i){if(p4&&(pE.DEBUG||zs.POSTHOG_DEBUG)&&!Mr(p4.console)&&p4.console){for(var o=("__rrweb_original__"in p4.console[i])?p4.console[i].__rrweb_original__:p4.console[i],a=arguments.length,s=new Array(a>1?a-1:0),r=1;r<a;r++)s[r-1]=arguments[r];o(t,...s)}},info:function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];n._log("log",...o)},warn:function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];n._log("warn",...o)},error:function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];n._log("error",...o)},critical:function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];console.error(t,...o)},uninitializedWarning:i=>{n.error("You must initialize PostHog before calling ".concat(i))},createLogger:i=>hl2("".concat(t," ").concat(i))};return n},Wi=hl2("[PostHog.js]"),PA=Wi.createLogger,Z20=PA("[ExternalScriptsLoader]"),El2=(t,n,i)=>{if(t.config.disable_external_dependency_loading)return Z20.warn("".concat(n," was requested but loading of external scripts is disabled.")),i("Loading of external scripts is disabled");var o=Fn==null?void 0:Fn.querySelectorAll("script");if(o){for(var a=0;a<o.length;a++)if(o[a].src===n)return i()}var s=()=>{if(!Fn)return i("document not found");var r=Fn.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=n,r.onload=e=>i(void 0,e),r.onerror=e=>i(e),t.config.prepare_external_dependency_script&&(r=t.config.prepare_external_dependency_script(r)),!r)return i("prepare_external_dependency_script returned null");var C,l=Fn.querySelectorAll("body > script");l.length>0?(C=l[0].parentNode)===null||C===void 0||C.insertBefore(r,l[0]):Fn.body.appendChild(r)};Fn!=null&&Fn.body?s():Fn==null||Fn.addEventListener("DOMContentLoaded",s)};function pl2(t,n){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),i.push.apply(i,o)}return i}function S4(t){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?pl2(Object(i),!0).forEach(function(o){St(t,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):pl2(Object(i)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(i,o))})}return t}function St(t,n,i){return n in t?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,t}function vl2(t,n){if(t==null)return{};var i,o,a=function(r,C){if(r==null)return{};var l,e,u={},A=Object.keys(r);for(e=0;e<A.length;e++)l=A[e],C.indexOf(l)>=0||(u[l]=r[l]);return u}(t,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)i=s[o],n.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(a[i]=t[i])}return a}zs.__PosthogExtensions__=zs.__PosthogExtensions__||{},zs.__PosthogExtensions__.loadExternalDependency=(t,n,i)=>{var o="/static/".concat(n,".js")+"?v=".concat(t.version);if(n==="remote-config"&&(o="/array/".concat(t.config.token,"/config.js")),n==="toolbar"){var a=3e5,s=Math.floor(Date.now()/a)*a;o="".concat(o,"&t=").concat(s)}var r=t.requestRouter.endpointFor("assets",o);El2(t,r,i)},zs.__PosthogExtensions__.loadSiteApp=(t,n,i)=>{var o=t.requestRouter.endpointFor("api",n);El2(t,o,i)};var QS={};function Jp(t,n,i){if(_l(t)){if(Al2&&t.forEach===Al2)t.forEach(n,i);else if("length"in t&&t.length===+t.length){for(var o=0,a=t.length;o<a;o++)if(o in t&&n.call(i,t[o],o)===QS)return}}}function cl(t,n,i){if(!ll(t)){if(_l(t))return Jp(t,n,i);if(O20(t)){for(var o of t.entries())if(n.call(i,o[1],o[0])===QS)return}else for(var a in t)if(gl2.call(t,a)&&n.call(i,t[a],a)===QS)return}}var mu=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return Jp(i,function(a){for(var s in a)a[s]!==void 0&&(t[s]=a[s])}),t},MS=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return Jp(i,function(a){Jp(a,function(s){t.push(s)})}),t};function TS(t){for(var n=Object.keys(t),i=n.length,o=new Array(i);i--;)o[i]=[n[i],t[n[i]]];return o}var Il2=function(t){try{return t()}catch{return}},F20=function(t){return function(){try{for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return t.apply(this,i)}catch(a){Wi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Wi.critical(a)}}},NM=function(t){var n={};return cl(t,function(i,o){Iu(i)&&i.length>0&&(n[o]=i)}),n};function U20(t,n){return i=t,o=s=>Iu(s)&&!Xp(n)?s.slice(0,n):s,a=new Set,function s(r,C){return r!==Object(r)?o?o(r,C):r:a.has(r)?void 0:(a.add(r),_l(r)?(l=[],Jp(r,e=>{l.push(s(e))})):(l={},cl(r,(e,u)=>{a.has(e)||(l[u]=s(e,u))})),l);var l}(i);var i,o,a}var j20=["herokuapp.com","vercel.app","netlify.app"];function z20(t){var n=t==null?void 0:t.hostname;if(!Iu(n))return!1;var i=n.split(".").slice(-2).join(".");for(var o of j20)if(i===o)return!1;return!0}function ml2(t,n){for(var i=0;i<t.length;i++)if(n(t[i]))return t[i]}function su(t,n,i,o){var{capture:a=!1,passive:s=!0}=o??{};t==null||t.addEventListener(n,i,{capture:a,passive:s})}var bl2="$people_distinct_id",SM="__alias",VM="__timers",Bl2="$autocapture_disabled_server_side",u_="$heatmaps_enabled_server_side",yl2="$exception_capture_enabled_server_side",Ll2="$web_vitals_enabled_server_side",wl2="$dead_clicks_enabled_server_side",Ql2="$web_vitals_allowed_metrics",A_="$session_recording_enabled_server_side",Ml2="$console_log_recording_enabled_server_side",Tl2="$session_recording_network_payload_capture",xl2="$session_recording_masking",Rl2="$session_recording_canvas_recording",Hl2="$replay_sample_rate",Dl2="$replay_minimum_duration",Nl2="$replay_script_config",xS="$sesid",kM="$session_is_sampled",c_="$session_recording_url_trigger_activated_session",f_="$session_recording_event_trigger_activated_session",vy="$enabled_feature_flags",RS="$early_access_features",d_="$feature_flag_details",OM="$stored_person_properties",vm="$stored_group_properties",g_="$surveys",HS="$surveys_activated",DS="$flag_call_reported",vE="$user_state",h_="$client_session_props",E_="$capture_rate_limit",p_="$initial_campaign_params",v_="$initial_referrer_info",I_="$initial_person_info",NS="$epp",Sl2="__POSTHOG_TOOLBAR__",Vl2="$posthog_cookieless",G20=[bl2,SM,"__cmpns",VM,A_,u_,xS,vy,vE,RS,d_,vm,OM,g_,DS,h_,E_,p_,v_,NS];function kl2(t){var n;return t instanceof Element&&(t.id===Sl2||!((n=t.closest)===null||n===void 0||!n.call(t,".toolbar-global-fade-container")))}function SS(t){return!!t&&t.nodeType===1}function qp(t,n){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===n.toLowerCase()}function Ol2(t){return!!t&&t.nodeType===3}function Pl2(t){return!!t&&t.nodeType===11}function m_(t){return t?LS(t).split(/\s+/):[]}function Zl2(t){var n=p4==null?void 0:p4.location.href;return!!(n&&t&&t.some(i=>n.match(i)))}function VS(t){var n="";switch(typeof t.className){case"string":n=t.className;break;case"object":n=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:n=""}return m_(n)}function Fl2(t){return ll(t)?null:LS(t).split(/(\s+)/).filter(n=>Iy(n)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function kS(t){var n="";return B_(t)&&!zl2(t)&&t.childNodes&&t.childNodes.length&&cl(t.childNodes,function(i){var o;Ol2(i)&&i.textContent&&(n+=(o=Fl2(i.textContent))!==null&&o!==void 0?o:"")}),LS(n)}function Ul2(t){return Mr(t.target)?t.srcElement||null:(n=t.target)!==null&&n!==void 0&&n.shadowRoot?t.composedPath()[0]||null:t.target||null;var n}var b_=["a","button","form","input","select","textarea","label"];function jl2(t){var n=t.parentNode;return!(!n||!SS(n))&&n}function Y20(t,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(!p4||!t||qp(t,"html")||!SS(t)||i!=null&&i.url_allowlist&&!Zl2(i.url_allowlist)||i!=null&&i.url_ignorelist&&Zl2(i.url_ignorelist))return!1;if(i!=null&&i.dom_event_allowlist){var s=i.dom_event_allowlist;if(s&&!s.some(d=>n.type===d))return!1}for(var r=!1,C=[t],l=!0,e=t;e.parentNode&&!qp(e,"body");)if(Pl2(e.parentNode))C.push(e.parentNode.host),e=e.parentNode.host;else{if(!(l=jl2(e)))break;if(o||b_.indexOf(l.tagName.toLowerCase())>-1)r=!0;else{var u=p4.getComputedStyle(l);u&&u.getPropertyValue("cursor")==="pointer"&&(r=!0)}C.push(l),e=l}if(!function(d,g){var E=g==null?void 0:g.element_allowlist;if(Mr(E))return!0;var y=function(D){if(E.some(O=>D.tagName.toLowerCase()===O))return{v:!0}};for(var Q of d){var R=y(Q);if(typeof R=="object")return R.v}return!1}(C,i)||!function(d,g){var E=g==null?void 0:g.css_selector_allowlist;if(Mr(E))return!0;var y=function(D){if(E.some(O=>D.matches(O)))return{v:!0}};for(var Q of d){var R=y(Q);if(typeof R=="object")return R.v}return!1}(C,i))return!1;var A=p4.getComputedStyle(t);if(A&&A.getPropertyValue("cursor")==="pointer"&&n.type==="click")return!0;var f=t.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(a||["submit"]).indexOf(n.type)>=0;case"input":case"select":case"textarea":return(a||["change","click"]).indexOf(n.type)>=0;default:return r?(a||["click"]).indexOf(n.type)>=0:(a||["click"]).indexOf(n.type)>=0&&(b_.indexOf(f)>-1||t.getAttribute("contenteditable")==="true")}}function B_(t){for(var n=t;n.parentNode&&!qp(n,"body");n=n.parentNode){var i=VS(n);if(lC(i,"ph-sensitive")||lC(i,"ph-no-capture"))return!1}if(lC(VS(t),"ph-include"))return!0;var o=t.type||"";if(Iu(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!(Iu(a)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,"")))}function zl2(t){return!!(qp(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||qp(t,"select")||qp(t,"textarea")||t.getAttribute("contenteditable")==="true")}var Gl2="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",W20=new RegExp("^(?:".concat(Gl2,")$")),_20=new RegExp(Gl2),Yl2="\\d{3}-?\\d{2}-?\\d{4}",X20=new RegExp("^(".concat(Yl2,")$")),K20=new RegExp("(".concat(Yl2,")"));function Iy(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(ll(t)||Iu(t)&&(t=LS(t),(n?W20:_20).test((t||"").replace(/[- ]/g,""))||(n?X20:K20).test(t)))}function Wl2(t){var n=kS(t);return Iy(n="".concat(n," ").concat(_l2(t)).trim())?n:""}function _l2(t){var n="";return t&&t.childNodes&&t.childNodes.length&&cl(t.childNodes,function(i){var o;if(i&&((o=i.tagName)===null||o===void 0?void 0:o.toLowerCase())==="span")try{var a=kS(i);n="".concat(n," ").concat(a).trim(),i.childNodes&&i.childNodes.length&&(n="".concat(n," ").concat(_l2(i)).trim())}catch(s){Wi.error("[AutoCapture]",s)}}),n}function J20(t){return function(n){var i=n.map(o=>{var a,s,r="";if(o.tag_name&&(r+=o.tag_name),o.attr_class)for(var C of(o.attr_class.sort(),o.attr_class))r+=".".concat(C.replace(/"/g,""));var l=S4(S4(S4(S4({},o.text?{text:o.text}:{}),{},{"nth-child":(a=o.nth_child)!==null&&a!==void 0?a:0,"nth-of-type":(s=o.nth_of_type)!==null&&s!==void 0?s:0},o.href?{href:o.href}:{}),o.attr_id?{attr_id:o.attr_id}:{}),o.attributes),e={};return TS(l).sort((u,A)=>{var[f]=u,[d]=A;return f.localeCompare(d)}).forEach(u=>{var[A,f]=u;return e[Xl2(A.toString())]=Xl2(f.toString())}),r+=":",r+=TS(l).map(u=>{var[A,f]=u;return"".concat(A,'="').concat(f,'"')}).join("")});return i.join(";")}(function(n){return n.map(i=>{var o,a,s={text:(o=i.$el_text)===null||o===void 0?void 0:o.slice(0,400),tag_name:i.tag_name,href:(a=i.attr__href)===null||a===void 0?void 0:a.slice(0,2048),attr_class:q20(i),attr_id:i.attr__id,nth_child:i.nth_child,nth_of_type:i.nth_of_type,attributes:{}};return TS(i).filter(r=>{var[C]=r;return C.indexOf("attr__")===0}).forEach(r=>{var[C,l]=r;return s.attributes[C]=l}),s})}(t))}function Xl2(t){return t.replace(/"|\\"/g,'\\"')}function q20(t){var n=t.attr__class;return n?_l(n)?n:m_(n):void 0}class Kl2{constructor(){this.clicks=[]}isRageClick(n,i,o){var a=this.clicks[this.clicks.length-1];if(a&&Math.abs(n-a.x)+Math.abs(i-a.y)<30&&o-a.timestamp<1e3){if(this.clicks.push({x:n,y:i,timestamp:o}),this.clicks.length===3)return!0}else this.clicks=[{x:n,y:i,timestamp:o}];return!1}}var $20=["localhost","127.0.0.1"],my=t=>{var n=Fn==null?void 0:Fn.createElement("a");return Mr(n)?null:(n.href=t,n)},e00=function(t){var n,i,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",a=[];return cl(t,function(s,r){Mr(s)||Mr(r)||r==="undefined"||(n=encodeURIComponent((C=>C instanceof File)(s)?s.name:s.toString()),i=encodeURIComponent(r),a[a.length]=i+"="+n)}),a.join(o)},OS=function(t,n){for(var i,o=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),a=0;a<o.length;a++){var s=o[a].split("=");if(s[0]===n){i=s;break}}if(!_l(i)||i.length<2)return"";var r=i[1];try{r=decodeURIComponent(r)}catch{Wi.error("Skipping decoding for malformed query param: "+r)}return r.replace(/\+/g," ")},y_=function(t,n,i){if(!t||!n||!n.length)return t;for(var o=t.split("#"),a=o[0]||"",s=o[1],r=a.split("?"),C=r[1],l=r[0],e=(C||"").split("&"),u=[],A=0;A<e.length;A++){var f=e[A].split("=");_l(f)&&(n.includes(f[0])?u.push(f[0]+"="+i):u.push(e[A]))}var d=l;return C!=null&&(d+="?"+u.join("&")),s!=null&&(d+="#"+s),d},PS=function(t,n){var i=t.match(new RegExp(n+"=([^&]*)"));return i?i[1]:null},Jl2=PA("[AutoCapture]");function L_(t,n){return n.length>t?n.slice(0,t)+"...":n}function t00(t){if(t.previousElementSibling)return t.previousElementSibling;var n=t;do n=n.previousSibling;while(n&&!SS(n));return n}function r00(t,n,i,o){var a=t.tagName.toLowerCase(),s={tag_name:a};b_.indexOf(a)>-1&&!i&&(a.toLowerCase()==="a"||a.toLowerCase()==="button"?s.$el_text=L_(1024,Wl2(t)):s.$el_text=L_(1024,kS(t)));var r=VS(t);r.length>0&&(s.classes=r.filter(function(u){return u!==""})),cl(t.attributes,function(u){var A;if((!zl2(t)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(o==null||!o.includes(u.name))&&!n&&Iy(u.value)&&(A=u.name,!Iu(A)||A.substring(0,10)!=="_ngcontent"&&A.substring(0,7)!=="_nghost")){var f=u.value;u.name==="class"&&(f=m_(f).join(" ")),s["attr__"+u.name]=L_(1024,f)}});for(var C=1,l=1,e=t;e=t00(e);)C++,e.tagName===t.tagName&&l++;return s.nth_child=C,s.nth_of_type=l,s}function n00(t,n){for(var i,o,{e:a,maskAllElementAttributes:s,maskAllText:r,elementAttributeIgnoreList:C,elementsChainAsString:l}=n,e=[t],u=t;u.parentNode&&!qp(u,"body");)Pl2(u.parentNode)?(e.push(u.parentNode.host),u=u.parentNode.host):(e.push(u.parentNode),u=u.parentNode);var A,f=[],d={},g=!1,E=!1;if(cl(e,O=>{var k=B_(O);O.tagName.toLowerCase()==="a"&&(g=O.getAttribute("href"),g=k&&g&&Iy(g)&&g),lC(VS(O),"ph-no-capture")&&(E=!0),f.push(r00(O,s,r,C));var J=function(e2){if(!B_(e2))return{};var p2={};return cl(e2.attributes,function(D2){if(D2.name&&D2.name.indexOf("data-ph-capture-attribute")===0){var Q2=D2.name.replace("data-ph-capture-attribute-",""),i2=D2.value;Q2&&i2&&Iy(i2)&&(p2[Q2]=i2)}}),p2}(O);mu(d,J)}),E)return{props:{},explicitNoCapture:E};if(r||(t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?f[0].$el_text=Wl2(t):f[0].$el_text=kS(t)),g){var y,Q;f[0].attr__href=g;var R=(y=my(g))===null||y===void 0?void 0:y.host,D=p4==null||(Q=p4.location)===null||Q===void 0?void 0:Q.host;R&&D&&R!==D&&(A=g)}return{props:mu({$event_type:a.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:J20(f)},(i=f[0])!==null&&i!==void 0&&i.$el_text?{$el_text:(o=f[0])===null||o===void 0?void 0:o.$el_text}:{},A&&a.type==="click"?{$external_click_url:A}:{},d)}}class i00{constructor(n){St(this,"_initialized",!1),St(this,"_isDisabledServerSide",null),St(this,"rageclicks",new Kl2),St(this,"_elementsChainAsString",!1),this.instance=n,this._elementSelectors=null}get config(){var n,i,o=Xl(this.instance.config.autocapture)?this.instance.config.autocapture:{};return o.url_allowlist=(n=o.url_allowlist)===null||n===void 0?void 0:n.map(a=>new RegExp(a)),o.url_ignorelist=(i=o.url_ignorelist)===null||i===void 0?void 0:i.map(a=>new RegExp(a)),o}_addDomEventHandlers(){if(this.isBrowserSupported()){if(p4&&Fn){var n=o=>{o=o||(p4==null?void 0:p4.event);try{this._captureEvent(o)}catch(a){Jl2.error("Failed to capture event",a)}};if(su(Fn,"submit",n,{capture:!0}),su(Fn,"change",n,{capture:!0}),su(Fn,"click",n,{capture:!0}),this.config.capture_copied_text){var i=o=>{o=o||(p4==null?void 0:p4.event),this._captureEvent(o,s_)};su(Fn,"copy",i,{capture:!0}),su(Fn,"cut",i,{capture:!0})}}}else Jl2.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(n){n.elementsChainAsString&&(this._elementsChainAsString=n.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Bl2]:!!n.autocapture_opt_out}),this._isDisabledServerSide=!!n.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(n){this._elementSelectors=n}getElementSelectors(n){var i,o=[];return(i=this._elementSelectors)===null||i===void 0||i.forEach(a=>{var s=Fn==null?void 0:Fn.querySelectorAll(a);s==null||s.forEach(r=>{n===r&&o.push(a)})}),o}get isEnabled(){var n,i,o=(n=this.instance.persistence)===null||n===void 0?void 0:n.props[Bl2],a=this._isDisabledServerSide;if(Xp(a)&&!Kp(o)&&!this.instance.config.advanced_disable_decide)return!1;var s=(i=this._isDisabledServerSide)!==null&&i!==void 0?i:!!o;return!!this.instance.config.autocapture&&!s}_captureEvent(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var o,a=Ul2(n);Ol2(a)&&(a=a.parentNode||null),i==="$autocapture"&&n.type==="click"&&n instanceof MouseEvent&&this.instance.config.rageclick&&(o=this.rageclicks)!==null&&o!==void 0&&o.isRageClick(n.clientX,n.clientY,new Date().getTime())&&this._captureEvent(n,"$rageclick");var s=i===s_;if(a&&Y20(a,n,this.config,s,s?["copy","cut"]:void 0)){var{props:r,explicitNoCapture:C}=n00(a,{e:n,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(C)return!1;var l=this.getElementSelectors(a);if(l&&l.length>0&&(r.$element_selectors=l),i===s_){var e,u=Fl2(p4==null||(e=p4.getSelection())===null||e===void 0?void 0:e.toString()),A=n.type||"clipboard";if(!u)return!1;r.$selected_content=u,r.$copy_type=A}return this.instance.capture(i,r),!0}}}isBrowserSupported(){return rg(Fn==null?void 0:Fn.querySelectorAll)}}Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Ac(t)&&isFinite(t)&&Math.floor(t)===t});var ql2="0123456789abcdef";class ZS{constructor(n){if(this.bytes=n,n.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(n,i,o,a){if(!Number.isInteger(n)||!Number.isInteger(i)||!Number.isInteger(o)||!Number.isInteger(a)||n<0||i<0||o<0||a<0||n>0xffffffffffff||i>4095||o>1073741823||a>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=n/Math.pow(2,40),s[1]=n/Math.pow(2,32),s[2]=n/Math.pow(2,24),s[3]=n/Math.pow(2,16),s[4]=n/Math.pow(2,8),s[5]=n,s[6]=112|i>>>8,s[7]=i,s[8]=128|o>>>24,s[9]=o>>>16,s[10]=o>>>8,s[11]=o,s[12]=a>>>24,s[13]=a>>>16,s[14]=a>>>8,s[15]=a,new ZS(s)}toString(){for(var n="",i=0;i<this.bytes.length;i++)n=n+ql2.charAt(this.bytes[i]>>>4)+ql2.charAt(15&this.bytes[i]),i!==3&&i!==5&&i!==7&&i!==9||(n+="-");if(n.length!==36)throw new Error("Invalid UUIDv7 was generated");return n}clone(){return new ZS(this.bytes.slice(0))}equals(n){return this.compareTo(n)===0}compareTo(n){for(var i=0;i<16;i++){var o=this.bytes[i]-n.bytes[i];if(o!==0)return Math.sign(o)}return 0}}class o00{constructor(){St(this,"timestamp",0),St(this,"counter",0),St(this,"random",new a00)}generate(){var n=this.generateOrAbort();if(Mr(n)){this.timestamp=0;var i=this.generateOrAbort();if(Mr(i))throw new Error("Could not generate UUID after timestamp reset");return i}return n}generateOrAbort(){var n=Date.now();if(n>this.timestamp)this.timestamp=n,this.resetCounter();else{if(!(n+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return ZS.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}var $l2,eu2=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var n=0;n<t.length;n++)t[n]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};p4&&!Mr(p4.crypto)&&crypto.getRandomValues&&(eu2=t=>crypto.getRandomValues(t));class a00{constructor(){St(this,"buffer",new Uint32Array(8)),St(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(eu2(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var $p=()=>s00().toString(),s00=()=>($l2||($l2=new o00)).generate(),C00="Thu, 01 Jan 1970 00:00:00 GMT",PM="",l00=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function u00(t,n){if(n){var i=function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fn;if(PM)return PM;if(!s||["localhost","127.0.0.1"].includes(a))return"";for(var r=a.split("."),C=Math.min(r.length,8),l="dmn_chk_"+$p(),e=new RegExp("(^|;)\\s*"+l+"=1");!PM&&C--;){var u=r.slice(C).join("."),A=l+"=1;domain=."+u;s.cookie=A,e.test(s.cookie)&&(s.cookie=A+";expires="+C00,PM=u)}return PM}(t);if(!i){var o=(a=>{var s=a.match(l00);return s?s[0]:""})(t);o!==i&&Wi.info("Warning: cookie subdomain discovery mismatch",o,i),i=o}return i?"; domain=."+i:""}return""}var ev,IE={is_supported:()=>!!Fn,error:function(t){Wi.error("cookieStore error: "+t)},get:function(t){if(Fn){try{for(var n=t+"=",i=Fn.cookie.split(";").filter(s=>s.length),o=0;o<i.length;o++){for(var a=i[o];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(n)===0)return decodeURIComponent(a.substring(n.length,a.length))}}catch{}return null}},parse:function(t){var n;try{n=JSON.parse(IE.get(t))||{}}catch{}return n},set:function(t,n,i,o,a){if(Fn)try{var s="",r="",C=u00(Fn.location.hostname,o);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),s="; expires="+l.toUTCString()}a&&(r="; secure");var e=t+"="+encodeURIComponent(JSON.stringify(n))+s+"; SameSite=Lax; path=/"+C+r;return e.length>3686.4&&Wi.warn("cookieStore warning: large cookie, len="+e.length),Fn.cookie=e,e}catch{return}},remove:function(t,n){try{IE.set(t,"",-1,n)}catch{return}}},w_=null,Du={is_supported:function(){if(!Xp(w_))return w_;var t=!0;if(Mr(p4))t=!1;else try{var n="__mplssupport__";Du.set(n,"xyz"),Du.get(n)!=='"xyz"'&&(t=!1),Du.remove(n)}catch{t=!1}return t||Wi.error("localStorage unsupported; falling back to cookie store"),w_=t,t},error:function(t){Wi.error("localStorage error: "+t)},get:function(t){try{return p4==null?void 0:p4.localStorage.getItem(t)}catch(n){Du.error(n)}return null},parse:function(t){try{return JSON.parse(Du.get(t))||{}}catch{}return null},set:function(t,n){try{p4==null||p4.localStorage.setItem(t,JSON.stringify(n))}catch(i){Du.error(i)}},remove:function(t){try{p4==null||p4.localStorage.removeItem(t)}catch(n){Du.error(n)}}},A00=["distinct_id",xS,kM,NS,I_],FS=S4(S4({},Du),{},{parse:function(t){try{var n={};try{n=IE.parse(t)||{}}catch{}var i=mu(n,JSON.parse(Du.get(t)||"{}"));return Du.set(t,i),i}catch{}return null},set:function(t,n,i,o,a,s){try{Du.set(t,n,void 0,void 0,s);var r={};A00.forEach(C=>{n[C]&&(r[C]=n[C])}),Object.keys(r).length&&IE.set(t,r,i,o,a,s)}catch(C){Du.error(C)}},remove:function(t,n){try{p4==null||p4.localStorage.removeItem(t),IE.remove(t,n)}catch(i){Du.error(i)}}}),US={},c00={is_supported:function(){return!0},error:function(t){Wi.error("memoryStorage error: "+t)},get:function(t){return US[t]||null},parse:function(t){return US[t]||null},set:function(t,n){US[t]=n},remove:function(t){delete US[t]}},Im=null,uA={is_supported:function(){if(!Xp(Im))return Im;if(Im=!0,Mr(p4))Im=!1;else try{var t="__support__";uA.set(t,"xyz"),uA.get(t)!=='"xyz"'&&(Im=!1),uA.remove(t)}catch{Im=!1}return Im},error:function(t){Wi.error("sessionStorage error: ",t)},get:function(t){try{return p4==null?void 0:p4.sessionStorage.getItem(t)}catch(n){uA.error(n)}return null},parse:function(t){try{return JSON.parse(uA.get(t))||null}catch{}return null},set:function(t,n){try{p4==null||p4.sessionStorage.setItem(t,JSON.stringify(n))}catch(i){uA.error(i)}},remove:function(t){try{p4==null||p4.sessionStorage.removeItem(t)}catch(n){uA.error(n)}}};(function(t){t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED"})(ev||(ev={}));class f00{constructor(n){this.instance=n}get config(){return this.instance.config}get consent(){return this.getDnt()?ev.DENIED:this.storedConsent}isOptedOut(){return this.consent===ev.DENIED||this.consent===ev.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(n){this.storage.set(this.storageKey,n?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:n,opt_out_capturing_cookie_prefix:i}=this.instance.config;return(i||"__ph_opt_in_out_")+n}get storedConsent(){var n=this.storage.get(this.storageKey);return n==="1"?ev.GRANTED:n==="0"?ev.DENIED:ev.PENDING}get storage(){if(!this._storage){var n=this.config.opt_out_capturing_persistence_type;this._storage=n==="localStorage"?Du:IE;var i=n==="localStorage"?IE:Du;i.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(i.get(this.storageKey)==="1"),i.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!ml2([Bf==null?void 0:Bf.doNotTrack,Bf==null?void 0:Bf.msDoNotTrack,zs.doNotTrack],n=>lC([!0,1,"1","yes"],n))}}var jS=PA("[Dead Clicks]"),d00=()=>!0,g00=t=>{var n,i=!((n=t.instance.persistence)===null||n===void 0||!n.get_property(wl2)),o=t.instance.config.capture_dead_clicks;return Kp(o)?o:i};class tu2{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(n,i,o){this.instance=n,this.isEnabled=i,this.onCapture=o,this.startIfEnabled()}onRemoteConfig(n){this.instance.persistence&&this.instance.persistence.register({[wl2]:n==null?void 0:n.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(n){var i,o,a;(i=zs.__PosthogExtensions__)!==null&&i!==void 0&&i.initDeadClicksAutocapture&&n(),(o=zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"dead-clicks-autocapture",s=>{s?jS.error("failed to load script",s):n()})}start(){var n;if(Fn){if(!this._lazyLoadedDeadClicksAutocapture&&(n=zs.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture){var i=Xl(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};i.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=zs.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this._lazyLoadedDeadClicksAutocapture.start(Fn),jS.info("starting...")}}else jS.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,jS.info("stopping..."))}}var zS=PA("[ExceptionAutocapture]");class h00{constructor(n){var i;St(this,"startCapturing",()=>{var o,a,s,r,C,l;if(p4&&this.isEnabled){var e=(o=zs.__PosthogExtensions__)===null||o===void 0||(a=o.errorWrappingFunctions)===null||a===void 0?void 0:a.wrapOnError,u=(s=zs.__PosthogExtensions__)===null||s===void 0||(r=s.errorWrappingFunctions)===null||r===void 0?void 0:r.wrapUnhandledRejection,A=(C=zs.__PosthogExtensions__)===null||C===void 0||(l=C.errorWrappingFunctions)===null||l===void 0?void 0:l.wrapConsoleError;if(e&&u&&A)try{this.unwrapOnError||(this.unwrapOnError=e(this.captureException.bind(this))),this.unwrapUnhandledRejection||(this.unwrapUnhandledRejection=u(this.captureException.bind(this))),this.unwrapConsoleError||(this.unwrapConsoleError=A(this.captureException.bind(this)))}catch(f){zS.error("failed to start",f),this.stopCapturing()}else zS.error("failed to load error wrapping functions - cannot start")}}),this.instance=n,this.remoteEnabled=!((i=this.instance.persistence)===null||i===void 0||!i.props[yl2]),this.config=this.requiredConfig(),this.startIfEnabled()}requiredConfig(){var n=this.instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Xl(n)?i=S4(S4({},i),n):(Mr(n)?this.remoteEnabled:n)&&(i=S4(S4({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}get hasHandlers(){return!Mr(this.unwrapOnError)&&!Mr(this.unwrapUnhandledRejection)&&!Mr(this.unwrapConsoleError)}startIfEnabled(){this.isEnabled&&!this.hasHandlers&&(zS.info("enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(n){var i,o;this.hasHandlers&&n(),(i=zs.__PosthogExtensions__)===null||i===void 0||(o=i.loadExternalDependency)===null||o===void 0||o.call(i,this.instance,"exception-autocapture",a=>{if(a)return zS.error("failed to load script",a);n()})}stopCapturing(){var n,i,o;(n=this.unwrapOnError)===null||n===void 0||n.call(this),this.unwrapOnError=void 0,(i=this.unwrapUnhandledRejection)===null||i===void 0||i.call(this),this.unwrapUnhandledRejection=void 0,(o=this.unwrapConsoleError)===null||o===void 0||o.call(this),this.unwrapConsoleError=void 0}onRemoteConfig(n){var i=n.autocaptureExceptions;this.remoteEnabled=!!i||!1,this.config=this.requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[yl2]:this.remoteEnabled}),this.startIfEnabled()}captureException(n){var i=this.instance.requestRouter.endpointFor("ui");n.$exception_personURL="".concat(i,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(n)}}function ru2(t){return!Mr(Event)&&nu2(t,Event)}function nu2(t,n){try{return t instanceof n}catch{return!1}}function GS(t,n){return Object.prototype.toString.call(t)==="[object ".concat(n,"]")}function Q_(t){return GS(t,"DOMError")}var iu2=/\(error: (.*)\)/,ou2=50,by="?";function M_(t,n,i,o){var a={platform:"web:javascript",filename:t,function:n==="<anonymous>"?by:n,in_app:!0};return Mr(i)||(a.lineno=i),Mr(o)||(a.colno=o),a}var E00=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,p00=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,v00=/\((\S*)(?::(\d+))(?::(\d+))\)/,I00=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,m00=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,b00=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var o=n.sort((a,s)=>a[0]-s[0]).map(a=>a[1]);return function(a){for(var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=[],C=a.split(`
|
|
595
595
|
`),l=s;l<C.length;l++){var e=C[l];if(!(e.length>1024)){var u=iu2.test(e)?e.replace(iu2,"$1"):e;if(!u.match(/\S*Error: /)){for(var A of o){var f=A(u);if(f){r.push(f);break}}if(r.length>=ou2)break}}}return function(d){if(!d.length)return[];var g=Array.from(d);return g.reverse(),g.slice(0,ou2).map(E=>S4(S4({},E),{},{filename:E.filename||B00(g).filename,function:E.function||by}))}(r)}}([30,t=>{var n=E00.exec(t);if(n){var[,i,o,a]=n;return M_(i,by,+o,+a)}var s=p00.exec(t);if(s){if(s[2]&&s[2].indexOf("eval")===0){var r=v00.exec(s[2]);r&&(s[2]=r[1],s[3]=r[2],s[4]=r[3])}var[C,l]=su2(s[1]||by,s[2]);return M_(l,C,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,t=>{var n=I00.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var i=m00.exec(n[3]);i&&(n[1]=n[1]||"eval",n[3]=i[1],n[4]=i[2],n[5]="")}var o=n[3],a=n[1]||by;return[a,o]=su2(a,o),M_(o,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}]);function B00(t){return t[t.length-1]||{}}var YS,au2,T_,su2=(t,n)=>{var i=t.indexOf("safari-extension")!==-1,o=t.indexOf("safari-web-extension")!==-1;return i||o?[t.indexOf("@")!==-1?t.split("@")[0]:by,i?"safari-extension:".concat(n):"safari-web-extension:".concat(n)]:[t,n]},y00=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function x_(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=t.stacktrace||t.stack||"",o=function(r){return r&&L00.test(r.message)?1:0}(t);try{var a=b00,s=function(r,C){var l=function(e){var u=globalThis._posthogChunkIds;if(!u)return{};var A=Object.keys(u);return T_&&A.length===au2||(au2=A.length,T_=A.reduce((f,d)=>{YS||(YS={});var g=YS[d];if(g)f[g[0]]=g[1];else for(var E=e(d),y=E.length-1;y>=0;y--){var Q=E[y],R=Q==null?void 0:Q.filename,D=u[d];if(R&&D){f[R]=D,YS[d]=[R,D];break}}return f},{})),T_}(C);return r.forEach(e=>{e.filename&&(e.chunk_id=l[e.filename])}),r}(a(i,o),a);return s.slice(0,s.length-n)}catch{}return[]}var L00=/Minified React error #\d+;/i;function R_(t,n){var i,o,a=x_(t),s=(i=n==null?void 0:n.handled)===null||i===void 0||i,r=(o=n==null?void 0:n.synthetic)!==null&&o!==void 0&&o;return{$exception_list:[{type:n!=null&&n.overrideExceptionType?n.overrideExceptionType:t.name,value:n!=null&&n.overrideExceptionMessage?n.overrideExceptionMessage:function(C){var l=C.message;return l.error&&typeof l.error.message=="string"?l.error.message:l}(t),stacktrace:{frames:a,type:"raw"},mechanism:{handled:s,synthetic:r}}],$exception_level:"error"}}function H_(t,n){var i,o,a,s=(i=n==null?void 0:n.handled)===null||i===void 0||i,r=(o=n==null?void 0:n.synthetic)===null||o===void 0||o,C={type:n!=null&&n.overrideExceptionType?n.overrideExceptionType:(a=n==null?void 0:n.defaultExceptionType)!==null&&a!==void 0?a:"Error",value:n!=null&&n.overrideExceptionMessage?n.overrideExceptionMessage:t||(n==null?void 0:n.defaultExceptionMessage),mechanism:{handled:s,synthetic:r}};if(n!=null&&n.syntheticException){var l=x_(n.syntheticException,1);l.length&&(C.stacktrace={frames:l,type:"raw"})}return{$exception_list:[C],$exception_level:"error"}}function w00(t){return Iu(t)&&!l_(t)&&V20.indexOf(t)>=0}function Q00(t,n){var i,o,a=(i=n==null?void 0:n.handled)===null||i===void 0||i,s=(o=n==null?void 0:n.synthetic)===null||o===void 0||o,r=n!=null&&n.overrideExceptionType?n.overrideExceptionType:ru2(t)?t.constructor.name:"Error",C=n!=null&&n.overrideExceptionMessage?n.overrideExceptionMessage:"Non-Error ".concat("exception"," captured with keys: ",function(u){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:40,f=Object.keys(u);if(f.sort(),!f.length)return"[object has no keys]";for(var d=f.length;d>0;d--){var g=f.slice(0,d).join(", ");if(!(g.length>A))return d===f.length||g.length<=A?g:"".concat(g.slice(0,A),"...")}return""}(t)),l={type:r,value:C,mechanism:{handled:a,synthetic:s}};if(n!=null&&n.syntheticException){var e=x_(n==null?void 0:n.syntheticException,1);e.length&&(l.stacktrace={frames:e,type:"raw"})}return{$exception_list:[l],$exception_level:w00(t.level)?t.level:"error"}}function M00(t,n){var{error:i,event:o}=t,a={$exception_list:[]},s=i||o;if(Q_(s)||function(d){return GS(d,"DOMException")}(s)){var r=s;if(function(d){return"stack"in d}(s))a=R_(s,n);else{var C=r.name||(Q_(r)?"DOMError":"DOMException"),l=r.message?"".concat(C,": ").concat(r.message):C,e=Q_(r)?"DOMError":"DOMException";a=H_(l,S4(S4({},n),{},{overrideExceptionType:e,defaultExceptionMessage:l}))}return"code"in r&&(a.$exception_DOMException_code="".concat(r.code)),a}if(function(d){return GS(d,"ErrorEvent")}(s)&&s.error)return R_(s.error,n);if(function(d){switch(Object.prototype.toString.call(d)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return nu2(d,Error)}}(s))return R_(s,n);if(function(d){return GS(d,"Object")}(s)||ru2(s))return Q00(s,n);if(Mr(i)&&Iu(o)){var u="Error",A=o,f=o.match(y00);return f&&(u=f[1],A=f[2]),H_(A,S4(S4({},n),{},{overrideExceptionType:u,defaultExceptionMessage:A}))}return H_(s,n)}function WS(t){var n,i;return((n=JSON.stringify(t,(i=[],function(o,a){if(Xl(a)){for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(a)?"[Circular]":(i.push(a),a)}return a})))===null||n===void 0?void 0:n.length)||0}function D_(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(t.size>=n&&t.data.length>1){var i=Math.floor(t.data.length/2),o=t.data.slice(0,i),a=t.data.slice(i);return[D_({size:WS(o),data:o,sessionId:t.sessionId,windowId:t.windowId}),D_({size:WS(a),data:a,sessionId:t.sessionId,windowId:t.windowId})].flatMap(s=>s)}return[t]}var mE=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(mE||{}),ng=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(ng||{}),N_="[SessionRecording]",S_="redacted",_S={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:t=>t,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com"]},T00=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],x00=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],R00=["/s/","/e/","/i/"];function Cu2(t,n,i,o){if(ll(t))return t;var a=(n==null?void 0:n["content-length"])||function(s){return new Blob([s]).size}(t);return Iu(a)&&(a=parseInt(a)),a>i?N_+" ".concat(o," body too large to record (").concat(a," bytes)"):t}function lu2(t,n){if(ll(t))return t;var i=t;return Iy(i,!1)||(i=N_+" "+n+" body "+S_),cl(x00,o=>{var a,s;(a=i)!==null&&a!==void 0&&a.length&&((s=i)===null||s===void 0?void 0:s.indexOf(o))!==-1&&(i=N_+" "+n+" body "+S_+" as might contain: "+o)}),i}var H00=(t,n)=>{var i,o,a,s={payloadSizeLimitBytes:_S.payloadSizeLimitBytes,performanceEntryTypeToObserve:[..._S.performanceEntryTypeToObserve],payloadHostDenyList:[...n.payloadHostDenyList||[],..._S.payloadHostDenyList]},r=t.session_recording.recordHeaders!==!1&&n.recordHeaders,C=t.session_recording.recordBody!==!1&&n.recordBody,l=t.capture_performance!==!1&&n.recordPerformance,e=(i=s,a=Math.min(1e6,(o=i.payloadSizeLimitBytes)!==null&&o!==void 0?o:1e6),f=>(f!=null&&f.requestBody&&(f.requestBody=Cu2(f.requestBody,f.requestHeaders,a,"Request")),f!=null&&f.responseBody&&(f.responseBody=Cu2(f.responseBody,f.responseHeaders,a,"Response")),f)),u=f=>{return e(((E,y)=>{var Q,R=my(E.name),D=y.indexOf("http")===0?(Q=my(y))===null||Q===void 0?void 0:Q.pathname:y;D==="/"&&(D="");var O=R==null?void 0:R.pathname.replace(D||"","");if(!(R&&O&&R00.some(k=>O.indexOf(k)===0)))return E})((g=(d=f).requestHeaders,ll(g)||cl(Object.keys(g??{}),E=>{T00.includes(E.toLowerCase())&&(g[E]=S_)}),d),t.api_host));var d,g},A=rg(t.session_recording.maskNetworkRequestFn);return A&&rg(t.session_recording.maskCapturedNetworkRequestFn)&&Wi.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),A&&(t.session_recording.maskCapturedNetworkRequestFn=f=>{var d=t.session_recording.maskNetworkRequestFn({url:f.name});return S4(S4({},f),{},{name:d==null?void 0:d.url})}),s.maskRequestFn=rg(t.session_recording.maskCapturedNetworkRequestFn)?f=>{var d,g,E,y=u(f);return y&&(d=(g=(E=t.session_recording).maskCapturedNetworkRequestFn)===null||g===void 0?void 0:g.call(E,y))!==null&&d!==void 0?d:void 0}:f=>function(d){if(!Mr(d))return d.requestBody=lu2(d.requestBody,"Request"),d.responseBody=lu2(d.responseBody,"Response"),d}(u(f)),S4(S4(S4({},_S),s),{},{recordHeaders:r,recordBody:C,recordPerformance:l,recordInitialRequests:l})};function fd(t,n,i,o,a){return n>i&&(Wi.warn("min cannot be greater than max."),n=i),Ac(t)?t>i?(o&&Wi.warn(o+" cannot be greater than max: "+i+". Using max value instead."),i):t<n?(o&&Wi.warn(o+" cannot be less than min: "+n+". Using min value instead."),n):t:(o&&Wi.warn(o+" must be a number. using max or fallback. max: "+i+", fallback: "+a),fd(a||i,n,i,o))}class D00{constructor(n){var i,o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};St(this,"bucketSize",100),St(this,"refillRate",10),St(this,"mutationBuckets",{}),St(this,"loggedTracker",{}),St(this,"refillBuckets",()=>{Object.keys(this.mutationBuckets).forEach(s=>{this.mutationBuckets[s]=this.mutationBuckets[s]+this.refillRate,this.mutationBuckets[s]>=this.bucketSize&&delete this.mutationBuckets[s]})}),St(this,"getNodeOrRelevantParent",s=>{var r=this.rrweb.mirror.getNode(s);if((r==null?void 0:r.nodeName)!=="svg"&&r instanceof Element){var C=r.closest("svg");if(C)return[this.rrweb.mirror.getId(C),C]}return[s,r]}),St(this,"numberOfChanges",s=>{var r,C,l,e,u,A,f,d;return((r=(C=s.removes)===null||C===void 0?void 0:C.length)!==null&&r!==void 0?r:0)+((l=(e=s.attributes)===null||e===void 0?void 0:e.length)!==null&&l!==void 0?l:0)+((u=(A=s.texts)===null||A===void 0?void 0:A.length)!==null&&u!==void 0?u:0)+((f=(d=s.adds)===null||d===void 0?void 0:d.length)!==null&&f!==void 0?f:0)}),St(this,"throttleMutations",s=>{if(s.type!==3||s.data.source!==0)return s;var r=s.data,C=this.numberOfChanges(r);r.attributes&&(r.attributes=r.attributes.filter(e=>{var u,A,f,[d,g]=this.getNodeOrRelevantParent(e.id);return this.mutationBuckets[d]===0?!1:(this.mutationBuckets[d]=(u=this.mutationBuckets[d])!==null&&u!==void 0?u:this.bucketSize,this.mutationBuckets[d]=Math.max(this.mutationBuckets[d]-1,0),this.mutationBuckets[d]===0&&(this.loggedTracker[d]||(this.loggedTracker[d]=!0,(A=(f=this.options).onBlockedNode)===null||A===void 0||A.call(f,d,g))),e)}));var l=this.numberOfChanges(r);return l!==0||C===l?s:void 0}),this.rrweb=n,this.options=a,this.refillRate=fd((i=this.options.refillRate)!==null&&i!==void 0?i:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=fd((o=this.options.bucketSize)!==null&&o!==void 0?o:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}}var dd=Uint8Array,Yc=Uint16Array,By=Uint32Array,V_=new dd([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),k_=new dd([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),uu2=new dd([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Au2=function(t,n){for(var i=new Yc(31),o=0;o<31;++o)i[o]=n+=1<<t[o-1];var a=new By(i[30]);for(o=1;o<30;++o)for(var s=i[o];s<i[o+1];++s)a[s]=s-i[o]<<5|o;return[i,a]},cu2=Au2(V_,2),N00=cu2[0],O_=cu2[1];N00[28]=258,O_[258]=28;for(var fu2=Au2(k_,0)[1],du2=new Yc(32768),Ll=0;Ll<32768;++Ll){var mm=(43690&Ll)>>>1|(21845&Ll)<<1;mm=(61680&(mm=(52428&mm)>>>2|(13107&mm)<<2))>>>4|(3855&mm)<<4,du2[Ll]=((65280&mm)>>>8|(255&mm)<<8)>>>1}var ZM=function(t,n,i){for(var o=t.length,a=0,s=new Yc(n);a<o;++a)++s[t[a]-1];var r,C=new Yc(n);for(a=0;a<n;++a)C[a]=C[a-1]+s[a-1]<<1;for(r=new Yc(o),a=0;a<o;++a)r[a]=du2[C[t[a]-1]++]>>>15-t[a];return r},bm=new dd(288);for(Ll=0;Ll<144;++Ll)bm[Ll]=8;for(Ll=144;Ll<256;++Ll)bm[Ll]=9;for(Ll=256;Ll<280;++Ll)bm[Ll]=7;for(Ll=280;Ll<288;++Ll)bm[Ll]=8;var XS=new dd(32);for(Ll=0;Ll<32;++Ll)XS[Ll]=5;var S00=ZM(bm,9),V00=ZM(XS,5),gu2=function(t){return(t/8>>0)+(7&t&&1)},hu2=function(t,n,i){(i==null||i>t.length)&&(i=t.length);var o=new(t instanceof Yc?Yc:t instanceof By?By:dd)(i-n);return o.set(t.subarray(n,i)),o},bE=function(t,n,i){i<<=7&n;var o=n/8>>0;t[o]|=i,t[o+1]|=i>>>8},FM=function(t,n,i){i<<=7&n;var o=n/8>>0;t[o]|=i,t[o+1]|=i>>>8,t[o+2]|=i>>>16},P_=function(t,n){for(var i=[],o=0;o<t.length;++o)t[o]&&i.push({s:o,f:t[o]});var a=i.length,s=i.slice();if(!a)return[new dd(0),0];if(a==1){var r=new dd(i[0].s+1);return r[i[0].s]=1,[r,1]}i.sort(function(k,J){return k.f-J.f}),i.push({s:-1,f:25001});var C=i[0],l=i[1],e=0,u=1,A=2;for(i[0]={s:-1,f:C.f+l.f,l:C,r:l};u!=a-1;)C=i[i[e].f<i[A].f?e++:A++],l=i[e!=u&&i[e].f<i[A].f?e++:A++],i[u++]={s:-1,f:C.f+l.f,l:C,r:l};var f=s[0].s;for(o=1;o<a;++o)s[o].s>f&&(f=s[o].s);var d=new Yc(f+1),g=Z_(i[u-1],d,0);if(g>n){o=0;var E=0,y=g-n,Q=1<<y;for(s.sort(function(k,J){return d[J.s]-d[k.s]||k.f-J.f});o<a;++o){var R=s[o].s;if(!(d[R]>n))break;E+=Q-(1<<g-d[R]),d[R]=n}for(E>>>=y;E>0;){var D=s[o].s;d[D]<n?E-=1<<n-d[D]++-1:++o}for(;o>=0&&E;--o){var O=s[o].s;d[O]==n&&(--d[O],++E)}g=n}return[new dd(d),g]},Z_=function(t,n,i){return t.s==-1?Math.max(Z_(t.l,n,i+1),Z_(t.r,n,i+1)):n[t.s]=i},Eu2=function(t){for(var n=t.length;n&&!t[--n];);for(var i=new Yc(++n),o=0,a=t[0],s=1,r=function(l){i[o++]=l},C=1;C<=n;++C)if(t[C]==a&&C!=n)++s;else{if(!a&&s>2){for(;s>138;s-=138)r(32754);s>2&&(r(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(r(a),--s;s>6;s-=6)r(8304);s>2&&(r(s-3<<5|8208),s=0)}for(;s--;)r(a);s=1,a=t[C]}return[i.subarray(0,o),n]},UM=function(t,n){for(var i=0,o=0;o<n.length;++o)i+=t[o]*n[o];return i},F_=function(t,n,i){var o=i.length,a=gu2(n+2);t[a]=255&o,t[a+1]=o>>>8,t[a+2]=255^t[a],t[a+3]=255^t[a+1];for(var s=0;s<o;++s)t[a+s+4]=i[s];return 8*(a+4+o)},pu2=function(t,n,i,o,a,s,r,C,l,e,u){bE(n,u++,i),++a[256];for(var A=P_(a,15),f=A[0],d=A[1],g=P_(s,15),E=g[0],y=g[1],Q=Eu2(f),R=Q[0],D=Q[1],O=Eu2(E),k=O[0],J=O[1],e2=new Yc(19),p2=0;p2<R.length;++p2)e2[31&R[p2]]++;for(p2=0;p2<k.length;++p2)e2[31&k[p2]]++;for(var D2=P_(e2,7),Q2=D2[0],i2=D2[1],N2=19;N2>4&&!Q2[uu2[N2-1]];--N2);var R2,M2,Z2,Y2,f0=e+5<<3,E0=UM(a,bm)+UM(s,XS)+r,M0=UM(a,f)+UM(s,E)+r+14+3*N2+UM(e2,Q2)+(2*e2[16]+3*e2[17]+7*e2[18]);if(f0<=E0&&f0<=M0)return F_(n,u,t.subarray(l,l+e));if(bE(n,u,1+(M0<E0)),u+=2,M0<E0){R2=ZM(f,d),M2=f,Z2=ZM(E,y),Y2=E;var x0=ZM(Q2,i2);for(bE(n,u,D-257),bE(n,u+5,J-1),bE(n,u+10,N2-4),u+=14,p2=0;p2<N2;++p2)bE(n,u+3*p2,Q2[uu2[p2]]);u+=3*N2;for(var z2=[R,k],t1=0;t1<2;++t1){var p0=z2[t1];for(p2=0;p2<p0.length;++p2){var U0=31&p0[p2];bE(n,u,x0[U0]),u+=Q2[U0],U0>15&&(bE(n,u,p0[p2]>>>5&127),u+=p0[p2]>>>12)}}}else R2=S00,M2=bm,Z2=V00,Y2=XS;for(p2=0;p2<C;++p2)if(o[p2]>255){U0=o[p2]>>>18&31,FM(n,u,R2[U0+257]),u+=M2[U0+257],U0>7&&(bE(n,u,o[p2]>>>23&31),u+=V_[U0]);var G0=31&o[p2];FM(n,u,Z2[G0]),u+=Y2[G0],G0>3&&(FM(n,u,o[p2]>>>5&8191),u+=k_[G0])}else FM(n,u,R2[o[p2]]),u+=M2[o[p2]];return FM(n,u,R2[256]),u+M2[256]},k00=new By([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),O00=function(){for(var t=new By(256),n=0;n<256;++n){for(var i=n,o=9;--o;)i=(1&i&&3988292384)^i>>>1;t[n]=i}return t}(),P00=function(){var t=4294967295;return{p:function(n){for(var i=t,o=0;o<n.length;++o)i=O00[255&i^n[o]]^i>>>8;t=i},d:function(){return 4294967295^t}}},Z00=function(t,n,i,o,a){return function(s,r,C,l,e,u){var A=s.length,f=new dd(l+A+5*(1+Math.floor(A/7e3))+e),d=f.subarray(l,f.length-e),g=0;if(!r||A<8)for(var E=0;E<=A;E+=65535){var y=E+65535;y<A?g=F_(d,g,s.subarray(E,y)):(d[E]=u,g=F_(d,g,s.subarray(E,A)))}else{for(var Q=k00[r-1],R=Q>>>13,D=8191&Q,O=(1<<C)-1,k=new Yc(32768),J=new Yc(O+1),e2=Math.ceil(C/3),p2=2*e2,D2=function(k6){return(s[k6]^s[k6+1]<<e2^s[k6+2]<<p2)&O},Q2=new By(25e3),i2=new Yc(288),N2=new Yc(32),R2=0,M2=0,Z2=(E=0,0),Y2=0,f0=0;E<A;++E){var E0=D2(E),M0=32767&E,x0=J[E0];if(k[M0]=x0,J[E0]=M0,Y2<=E){var z2=A-E;if((R2>7e3||Z2>24576)&&z2>423){g=pu2(s,d,0,Q2,i2,N2,M2,Z2,f0,E-f0,g),Z2=R2=M2=0,f0=E;for(var t1=0;t1<286;++t1)i2[t1]=0;for(t1=0;t1<30;++t1)N2[t1]=0}var p0=2,U0=0,G0=D,X2=M0-x0&32767;if(z2>2&&E0==D2(E-X2))for(var L3=Math.min(R,z2)-1,O1=Math.min(32767,E),C3=Math.min(258,z2);X2<=O1&&--G0&&M0!=x0;){if(s[E+p0]==s[E+p0-X2]){for(var W3=0;W3<C3&&s[E+W3]==s[E+W3-X2];++W3);if(W3>p0){if(p0=W3,U0=X2,W3>L3)break;var d7=Math.min(X2,W3-2),y7=0;for(t1=0;t1<d7;++t1){var Y7=E-X2+t1+32768&32767,I6=Y7-k[Y7]+32768&32767;I6>y7&&(y7=I6,x0=Y7)}}}X2+=(M0=x0)-(x0=k[M0])+32768&32767}if(U0){Q2[Z2++]=268435456|O_[p0]<<18|fu2[U0];var z7=31&O_[p0],X6=31&fu2[U0];M2+=V_[z7]+k_[X6],++i2[257+z7],++N2[X6],Y2=E+p0,++R2}else Q2[Z2++]=s[E],++i2[s[E]]}}g=pu2(s,d,u,Q2,i2,N2,M2,Z2,f0,E-f0,g)}return hu2(f,0,l+gu2(g)+e)}(t,n.level==null?6:n.level,n.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+n.mem,i,o,!0)},U_=function(t,n,i){for(;i;++n)t[n]=i,i>>>=8},F00=function(t,n){var i=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:n.level==9?2:0,t[9]=3,n.mtime!=0&&U_(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),i){t[3]=8;for(var o=0;o<=i.length;++o)t[o+10]=i.charCodeAt(o)}},U00=function(t){return 10+(t.filename&&t.filename.length+1||0)};function vu2(t,n){n===void 0&&(n={});var i=P00(),o=t.length;i.p(t);var a=Z00(t,n,U00(n),8),s=a.length;return F00(a,n),U_(a,s-8,i.d()),U_(a,s-4,o),a}function Iu2(t,n){var i=t.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var o=new dd(t.length+(t.length>>>1)),a=0,s=function(e){o[a++]=e},r=0;r<i;++r){if(a+5>o.length){var C=new dd(a+8+(i-r<<1));C.set(o),o=C}var l=t.charCodeAt(r);l<128||n?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++r))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return hu2(o,0,a)}function j00(t,n){return function(i){for(var o=0,a=0;a<i.length;a++)o=(o<<5)-o+i.charCodeAt(a),o|=0;return Math.abs(o)}(t)%100<fd(100*n,0,100)}var jM="[SessionRecording]",ZA=PA(jM);function KS(){var t,n;return zs==null||(t=zs.__PosthogExtensions__)===null||t===void 0||(n=t.rrweb)===null||n===void 0?void 0:n.record}var z00=3e5,G00=[ng.MouseMove,ng.MouseInteraction,ng.Scroll,ng.ViewportResize,ng.Input,ng.TouchMove,ng.MediaInteraction,ng.Drag],mu2=t=>({rrwebMethod:t,enqueuedAt:Date.now(),attempt:1});function Bm(t){return function(n,i){for(var o="",a=0;a<n.length;){var s=n[a++];o+=String.fromCharCode(s)}return o}(vu2(Iu2(JSON.stringify(t))))}function bu2(t){return t.type===mE.Custom&&t.data.tag==="sessionIdle"}function Bu2(t,n){return n.some(i=>i.matching==="regex"&&new RegExp(i.url).test(t))}class Y00{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(jM+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var n,i;return this.triggerStatus==="trigger_pending"?6e4:(n=(i=this.instance.config.session_recording)===null||i===void 0?void 0:i.full_snapshot_interval_millis)!==null&&n!==void 0?n:z00}get isSampled(){var n=this.instance.get_property(kM);return Kp(n)?n:null}get sessionDuration(){var n,i,o=(n=this.buffer)===null||n===void 0?void 0:n.data[((i=this.buffer)===null||i===void 0?void 0:i.data.length)-1],{sessionStartTimestamp:a}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return o?o.timestamp-a:null}get isRecordingEnabled(){var n=!!this.instance.get_property(A_),i=!this.instance.config.disable_session_recording;return p4&&n&&i}get isConsoleLogCaptureEnabled(){var n=!!this.instance.get_property(Ml2),i=this.instance.config.enable_recording_console_log;return i??n}get canvasRecording(){var n,i,o,a,s,r,C=this.instance.config.session_recording.captureCanvas,l=this.instance.get_property(Rl2),e=(n=(i=C==null?void 0:C.recordCanvas)!==null&&i!==void 0?i:l==null?void 0:l.enabled)!==null&&n!==void 0&&n,u=(o=(a=C==null?void 0:C.canvasFps)!==null&&a!==void 0?a:l==null?void 0:l.fps)!==null&&o!==void 0?o:4,A=(s=(r=C==null?void 0:C.canvasQuality)!==null&&r!==void 0?r:l==null?void 0:l.quality)!==null&&s!==void 0?s:.4;if(typeof A=="string"){var f=parseFloat(A);A=isNaN(f)?.4:f}return{enabled:e,fps:fd(u,0,12,"canvas recording fps",4),quality:fd(A,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var n,i,o=this.instance.get_property(Tl2),a={recordHeaders:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.recordHeaders,recordBody:(i=this.instance.config.session_recording)===null||i===void 0?void 0:i.recordBody},s=(a==null?void 0:a.recordHeaders)||(o==null?void 0:o.recordHeaders),r=(a==null?void 0:a.recordBody)||(o==null?void 0:o.recordBody),C=Xl(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(Kp(C)?C:o!=null&&o.capturePerformance);return s||r||l?{recordHeaders:s,recordBody:r,recordPerformance:l}:void 0}get masking(){var n,i,o,a,s,r,C=this.instance.get_property(xl2),l={maskAllInputs:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.maskAllInputs,maskTextSelector:(i=this.instance.config.session_recording)===null||i===void 0?void 0:i.maskTextSelector,blockSelector:(o=this.instance.config.session_recording)===null||o===void 0?void 0:o.blockSelector},e=(a=l==null?void 0:l.maskAllInputs)!==null&&a!==void 0?a:C==null?void 0:C.maskAllInputs,u=(s=l==null?void 0:l.maskTextSelector)!==null&&s!==void 0?s:C==null?void 0:C.maskTextSelector,A=(r=l==null?void 0:l.blockSelector)!==null&&r!==void 0?r:C==null?void 0:C.blockSelector;return Mr(e)&&Mr(u)&&Mr(A)?void 0:{maskAllInputs:e==null||e,maskTextSelector:u,blockSelector:A}}get sampleRate(){var n=this.instance.get_property(Hl2);return Ac(n)?n:null}get minimumDuration(){var n=this.instance.get_property(Dl2);return Ac(n)?n:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":ll(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":Kp(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var n;return this._urlTriggers.length===0?"trigger_disabled":((n=this.instance)===null||n===void 0?void 0:n.get_property(c_))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var n;return this._eventTriggers.length===0?"trigger_disabled":((n=this.instance)===null||n===void 0?void 0:n.get_property(f_))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var n=this.eventTriggerStatus==="trigger_activated"||this.urlTriggerStatus==="trigger_activated",i=this.eventTriggerStatus==="trigger_pending"||this.urlTriggerStatus==="trigger_pending";return n?"trigger_activated":i?"trigger_pending":"trigger_disabled"}constructor(n){if(St(this,"queuedRRWebEvents",[]),St(this,"isIdle","unknown"),St(this,"_linkedFlagSeen",!1),St(this,"_lastActivityTimestamp",Date.now()),St(this,"_linkedFlag",null),St(this,"_removePageViewCaptureHook",void 0),St(this,"_onSessionIdListener",void 0),St(this,"_persistDecideOnSessionListener",void 0),St(this,"_samplingSessionListener",void 0),St(this,"_urlTriggers",[]),St(this,"_urlBlocklist",[]),St(this,"_urlBlocked",!1),St(this,"_eventTriggers",[]),St(this,"_removeEventTriggerCaptureHook",void 0),St(this,"_forceAllowLocalhostNetworkCapture",!1),St(this,"_onBeforeUnload",()=>{this._flushBuffer()}),St(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),St(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),St(this,"_onVisibilityChange",()=>{if(Fn!=null&&Fn.visibilityState){var a="window "+Fn.visibilityState;this._tryAddCustomEvent(a,{})}}),this.instance=n,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw ZA.error("started without valid sessionManager"),new Error(jM+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(jM+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:i,windowId:o}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=i,this.windowId=o,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&ZA.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(n){this.isRecordingEnabled?(this._startCapture(n),su(p4,"beforeunload",this._onBeforeUnload),su(p4,"offline",this._onOffline),su(p4,"online",this._onOnline),su(p4,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),ll(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",i=>{try{if(i.event==="$pageview"){var o=i!=null&&i.properties.$current_url?this._maskUrl(i==null?void 0:i.properties.$current_url):"";if(!o)return;this._tryAddCustomEvent("$pageview",{href:o})}}catch(a){ZA.error("Could not add $pageview to rrweb session",a)}})),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId((i,o,a)=>{var s,r,C,l;a&&(this._tryAddCustomEvent("$session_id_change",{sessionId:i,windowId:o,changeReason:a}),(s=this.instance)===null||s===void 0||(r=s.persistence)===null||r===void 0||r.unregister(f_),(C=this.instance)===null||C===void 0||(l=C.persistence)===null||l===void 0||l.unregister(c_))}))):this.stopRecording()}stopRecording(){var n,i,o,a;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,p4==null||p4.removeEventListener("beforeunload",this._onBeforeUnload),p4==null||p4.removeEventListener("offline",this._onOffline),p4==null||p4.removeEventListener("online",this._onOnline),p4==null||p4.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),(n=this._removePageViewCaptureHook)===null||n===void 0||n.call(this),this._removePageViewCaptureHook=void 0,(i=this._removeEventTriggerCaptureHook)===null||i===void 0||i.call(this),this._removeEventTriggerCaptureHook=void 0,(o=this._onSessionIdListener)===null||o===void 0||o.call(this),this._onSessionIdListener=void 0,(a=this._samplingSessionListener)===null||a===void 0||a.call(this),this._samplingSessionListener=void 0,ZA.info("stopped"))}makeSamplingDecision(n){var i,o=this.sessionId!==n,a=this.sampleRate;if(Ac(a)){var s=this.isSampled,r=o||!Kp(s),C=r?j00(n,a):s;r&&(C?this._reportStarted("sampled"):ZA.warn("Sample rate (".concat(a,") has determined that this sessionId (").concat(n,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:a,isSampled:C})),(i=this.instance.persistence)===null||i===void 0||i.register({[kM]:C})}else{var l;(l=this.instance.persistence)===null||l===void 0||l.register({[kM]:null})}}onRemoteConfig(n){var i,o,a,s,r,C;if(this._tryAddCustomEvent("$remote_config_received",n),this._persistRemoteConfig(n),this._linkedFlag=((i=n.sessionRecording)===null||i===void 0?void 0:i.linkedFlag)||null,(o=n.sessionRecording)!==null&&o!==void 0&&o.endpoint&&(this._endpoint=(C=n.sessionRecording)===null||C===void 0?void 0:C.endpoint),this._setupSampling(),!ll(this._linkedFlag)&&!this._linkedFlagSeen){var l=Iu(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,e=Iu(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((u,A)=>{var f=Xl(A)&&l in A,d=e?A[l]===e:f;d&&this._reportStarted("linked_flag_matched",{linkedFlag:l,linkedVariant:e}),this._linkedFlagSeen=d})}(a=n.sessionRecording)!==null&&a!==void 0&&a.urlTriggers&&(this._urlTriggers=n.sessionRecording.urlTriggers),(s=n.sessionRecording)!==null&&s!==void 0&&s.urlBlocklist&&(this._urlBlocklist=n.sessionRecording.urlBlocklist),(r=n.sessionRecording)!==null&&r!==void 0&&r.eventTriggers&&(this._eventTriggers=n.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){Ac(this.sampleRate)&&ll(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId(n=>{this.makeSamplingDecision(n)}))}_persistRemoteConfig(n){if(this.instance.persistence){var i,o=this.instance.persistence,a=()=>{var s,r,C,l,e,u,A,f,d,g=(s=n.sessionRecording)===null||s===void 0?void 0:s.sampleRate,E=ll(g)?null:parseFloat(g),y=(r=n.sessionRecording)===null||r===void 0?void 0:r.minimumDurationMilliseconds;o.register({[A_]:!!n.sessionRecording,[Ml2]:(C=n.sessionRecording)===null||C===void 0?void 0:C.consoleLogRecordingEnabled,[Tl2]:S4({capturePerformance:n.capturePerformance},(l=n.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[xl2]:(e=n.sessionRecording)===null||e===void 0?void 0:e.masking,[Rl2]:{enabled:(u=n.sessionRecording)===null||u===void 0?void 0:u.recordCanvas,fps:(A=n.sessionRecording)===null||A===void 0?void 0:A.canvasFps,quality:(f=n.sessionRecording)===null||f===void 0?void 0:f.canvasQuality},[Hl2]:E,[Dl2]:Mr(y)?null:y,[Nl2]:(d=n.sessionRecording)===null||d===void 0?void 0:d.scriptConfig})};a(),(i=this._persistDecideOnSessionListener)===null||i===void 0||i.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(a)}}log(n){var i,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(i=this.instance.sessionRecording)===null||i===void 0||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:o,trace:[],payload:[JSON.stringify(n)]}},timestamp:Date.now()})}_startCapture(n){if(!Mr(Object.assign)&&!Mr(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var i,o;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),KS()?this._onScriptLoaded():(i=zs.__PosthogExtensions__)===null||i===void 0||(o=i.loadExternalDependency)===null||o===void 0||o.call(i,this.instance,this.scriptName,a=>{if(a)return ZA.error("could not load recorder",a);this._onScriptLoaded()}),ZA.info("starting"),this.status==="active"&&this._reportStarted(n||"recording_initialized")}}get scriptName(){var n,i,o;return((n=this.instance)===null||n===void 0||(i=n.persistence)===null||i===void 0||(o=i.get_property(Nl2))===null||o===void 0?void 0:o.script)||"recorder"}isInteractiveEvent(n){var i;return n.type===3&&G00.indexOf((i=n.data)===null||i===void 0?void 0:i.source)!==-1}_updateWindowAndSessionIds(n){var i=this.isInteractiveEvent(n);i||this.isIdle||n.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:n.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var o=!1;if(i&&(this._lastActivityTimestamp=n.timestamp,this.isIdle)){var a=this.isIdle==="unknown";this.isIdle=!1,a||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:n.type}),o=!0)}if(!this.isIdle){var{windowId:s,sessionId:r}=this.sessionManager.checkAndGetSessionAndWindowId(!i,n.timestamp),C=this.sessionId!==r,l=this.windowId!==s;this.windowId=s,this.sessionId=r,C||l?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):o&&this._scheduleFullSnapshot()}}_tryRRWebMethod(n){try{return n.rrwebMethod(),!0}catch(i){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:n.enqueuedAt||Date.now(),attempt:n.attempt++,rrwebMethod:n.rrwebMethod}):ZA.warn("could not emit queued rrweb event.",i,n),!1}}_tryAddCustomEvent(n,i){return this._tryRRWebMethod(mu2(()=>KS().addCustomEvent(n,i)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(mu2(()=>KS().takeFullSnapshot()))}_onScriptLoaded(){var n,i,o,a,s={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},r=this.instance.config.session_recording;for(var[C,l]of Object.entries(r||{}))C in s&&(C==="maskInputOptions"?s.maskInputOptions=S4({password:!0},l):s[C]=l);this.canvasRecording&&this.canvasRecording.enabled&&(s.recordCanvas=!0,s.sampling={canvas:this.canvasRecording.fps},s.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking&&(s.maskAllInputs=(i=this.masking.maskAllInputs)===null||i===void 0||i,s.maskTextSelector=(o=this.masking.maskTextSelector)!==null&&o!==void 0?o:void 0,s.blockSelector=(a=this.masking.blockSelector)!==null&&a!==void 0?a:void 0);var e=KS();if(e){this.mutationRateLimiter=(n=this.mutationRateLimiter)!==null&&n!==void 0?n:new D00(e,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(A,f)=>{var d="Too many mutations on node '".concat(A,"'. Rate limiting. This could be due to SVG animations or something similar");ZA.info(d,{node:f}),this.log(jM+" "+d,"warn")}});var u=this._gatherRRWebPlugins();this.stopRrweb=e(S4({emit:A=>{this.onRRwebEmit(A)},plugins:u},s)),this._lastActivityTimestamp=Date.now(),this.isIdle=Kp(this.isIdle)?this.isIdle:"unknown",this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:s,activePlugins:u.map(A=>A==null?void 0:A.name)}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else ZA.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle!==!0){var n=this.fullSnapshotIntervalMillis;n&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},n))}}_gatherRRWebPlugins(){var n,i,o,a,s=[],r=(n=zs.__PosthogExtensions__)===null||n===void 0||(i=n.rrwebPlugins)===null||i===void 0?void 0:i.getRecordConsolePlugin;r&&this.isConsoleLogCaptureEnabled&&s.push(r());var C=(o=zs.__PosthogExtensions__)===null||o===void 0||(a=o.rrwebPlugins)===null||a===void 0?void 0:a.getRecordNetworkPlugin;return this.networkPayloadCapture&&rg(C)&&(!$20.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?s.push(C(H00(this.instance.config,this.networkPayloadCapture))):ZA.info("NetworkCapture not started because we are on localhost.")),s}onRRwebEmit(n){var i;if(this._processQueuedEvents(),n&&Xl(n)){if(n.type===mE.Meta){var o=this._maskUrl(n.data.href);if(this._lastHref=o,!o)return;n.data.href=o}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(A){return A.type===mE.Custom&&A.data.tag==="recording paused"}(n)){n.type===mE.FullSnapshot&&this._scheduleFullSnapshot(),n.type===mE.FullSnapshot&&this.triggerStatus==="trigger_pending"&&this.clearBuffer();var a=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(n):n;if(a){var s=function(A){var f=A;if(f&&Xl(f)&&f.type===6&&Xl(f.data)&&f.data.plugin==="rrweb/console@1"){f.data.payload.payload.length>10&&(f.data.payload.payload=f.data.payload.payload.slice(0,10),f.data.payload.payload.push("...[truncated]"));for(var d=[],g=0;g<f.data.payload.payload.length;g++)f.data.payload.payload[g]&&f.data.payload.payload[g].length>2e3?d.push(f.data.payload.payload[g].slice(0,2e3)+"...[truncated]"):d.push(f.data.payload.payload[g]);return f.data.payload.payload=d,A}return A}(a);if(this._updateWindowAndSessionIds(s),this.isIdle!==!0||bu2(s)){if(bu2(s)){var r=s.data.payload;if(r){var C=r.lastActivityTimestamp,l=r.threshold;s.timestamp=C+l}}var e=(i=this.instance.config.session_recording.compress_events)===null||i===void 0||i?function(A){if(WS(A)<1024)return A;try{if(A.type===mE.FullSnapshot)return S4(S4({},A),{},{data:Bm(A.data),cv:"2024-10"});if(A.type===mE.IncrementalSnapshot&&A.data.source===ng.Mutation)return S4(S4({},A),{},{cv:"2024-10",data:S4(S4({},A.data),{},{texts:Bm(A.data.texts),attributes:Bm(A.data.attributes),removes:Bm(A.data.removes),adds:Bm(A.data.adds)})});if(A.type===mE.IncrementalSnapshot&&A.data.source===ng.StyleSheetRule)return S4(S4({},A),{},{cv:"2024-10",data:S4(S4({},A.data),{},{adds:A.data.adds?Bm(A.data.adds):void 0,removes:A.data.removes?Bm(A.data.removes):void 0})})}catch(f){ZA.error("could not compress event - will use uncompressed event",f)}return A}(s):s,u={$snapshot_bytes:WS(e),$snapshot_data:e,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(u):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&p4){var n=this._maskUrl(p4.location.href);this._lastHref!==n&&(this._tryAddCustomEvent("$url_changed",{href:n}),this._lastHref=n)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var n=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],n.forEach(i=>{Date.now()-i.enqueuedAt<=2e3&&this._tryRRWebMethod(i)})}}_maskUrl(n){var i=this.instance.config.session_recording;if(i.maskNetworkRequestFn){var o,a={url:n};return(o=a=i.maskNetworkRequestFn(a))===null||o===void 0?void 0:o.url}return n}clearBuffer(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}_flushBuffer(){this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var n=this.minimumDuration,i=this.sessionDuration,o=Ac(i)&&i>=0,a=Ac(n)&&o&&i<n;return this.status==="buffering"||this.status==="paused"||this.status==="disabled"||a?(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3),this.buffer):(this.buffer.data.length>0&&D_(this.buffer).forEach(s=>{this._captureSnapshot({$snapshot_bytes:s.size,$snapshot_data:s.data,$session_id:s.sessionId,$window_id:s.windowId,$lib:"web",$lib_version:pE.LIB_VERSION})}),this.clearBuffer())}_captureSnapshotBuffered(n){var i,o=2+(((i=this.buffer)===null||i===void 0?void 0:i.data.length)||0);!this.isIdle&&(this.buffer.size+n.$snapshot_bytes+o>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=n.$snapshot_bytes,this.buffer.data.push(n.$snapshot_data),this.flushBufferTimer||this.isIdle||(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_captureSnapshot(n){this.instance.capture("$snapshot",n,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_checkUrlTriggerConditions(){if(p4!==void 0&&p4.location.href){var n=p4.location.href,i=this._urlBlocked,o=Bu2(n,this._urlBlocklist);o&&!i?this._pauseRecording():!o&&i&&this._resumeRecording(),Bu2(n,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(n){var i,o;this.triggerStatus==="trigger_pending"&&((i=this.instance)===null||i===void 0||(o=i.persistence)===null||o===void 0||o.register({[n==="url"?c_:f_]:this.sessionId}),this._flushBuffer(),this._reportStarted(n+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),ZA.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlBlocked&&(this._urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),ZA.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&ll(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",n=>{try{this._eventTriggers.includes(n.event)&&this._activateTrigger("event")}catch(i){ZA.error("Could not activate event trigger",i)}}))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var n;(n=this.instance.persistence)===null||n===void 0||n.register({[kM]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(n){this._activateTrigger(n)}_reportStarted(n,i){this.instance.register_for_session({$session_recording_start_reason:n}),ZA.info(n.replace("_"," "),i),lC(["recording_initialized","session_id_changed"],n)||this._tryAddCustomEvent(n,i)}}var j_=PA("[SegmentIntegration]");function W00(t,n){var i=t.config.segment;if(!i)return n();(function(o,a){var s=o.config.segment;if(!s)return a();var r=l=>{var e=()=>l.anonymousId()||$p();o.config.get_device_id=e,l.id()&&(o.register({distinct_id:l.id(),$device_id:e()}),o.persistence.set_property(vE,"identified")),a()},C=s.user();"then"in C&&rg(C.then)?C.then(l=>r(l)):r(C)})(t,()=>{i.register((o=>{Promise&&Promise.resolve||j_.warn("This browser does not have Promise support, and can not use the segment integration");var a=(s,r)=>{var C;if(!r)return s;s.event.userId||s.event.anonymousId===o.get_distinct_id()||(j_.info("No userId set, resetting PostHog"),o.reset()),s.event.userId&&s.event.userId!==o.get_distinct_id()&&(j_.info("UserId set, identifying with PostHog"),o.identify(s.event.userId));var l=o._calculate_event_properties(r,(C=s.event.properties)!==null&&C!==void 0?C:{},new Date);return s.event.properties=Object.assign({},l,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>a(s,s.event.event),page:s=>a(s,"$pageview"),identify:s=>a(s,"$identify"),screen:s=>a(s,"$screen")}})(t)).then(()=>{n()})})}var yu2="posthog-js";function Lu2(t){var{organization:n,projectId:i,prefix:o,severityAllowList:a=["error"]}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return s=>{var r,C,l,e,u;if(!(a==="*"||a.includes(s.level))||!t.__loaded)return s;s.tags||(s.tags={});var A=t.requestRouter.endpointFor("ui","/project/".concat(t.config.token,"/person/").concat(t.get_distinct_id()));s.tags["PostHog Person URL"]=A,t.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var f=((r=s.exception)===null||r===void 0?void 0:r.values)||[],d=f.map(E=>S4(S4({},E),{},{stacktrace:E.stacktrace?S4(S4({},E.stacktrace),{},{type:"raw",frames:(E.stacktrace.frames||[]).map(y=>S4(S4({},y),{},{platform:"web:javascript"}))}):void 0})),g={$exception_message:((C=f[0])===null||C===void 0?void 0:C.value)||s.message,$exception_type:(l=f[0])===null||l===void 0?void 0:l.type,$exception_personURL:A,$exception_level:s.level,$exception_list:d,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:((e=f[0])===null||e===void 0?void 0:e.value)||s.message,$sentry_exception_type:(u=f[0])===null||u===void 0?void 0:u.type,$sentry_tags:s.tags};return n&&i&&(g.$sentry_url=(o||"https://sentry.io/organizations/")+n+"/issues/?project="+i+"&query="+s.event_id),t.exceptions.sendExceptionEvent(g),s}}class _00{constructor(n,i,o,a,s){this.name=yu2,this.setupOnce=function(r){r(Lu2(n,{organization:i,projectId:o,prefix:a,severityAllowList:s}))}}}var BE,X00=p4!=null&&p4.location?PS(p4.location.hash,"__posthog")||PS(location.hash,"state"):null,wu2="_postHogToolbarParams",Qu2=PA("[Toolbar]");(function(t){t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED"})(BE||(BE={}));class K00{constructor(n){this.instance=n}setToolbarState(n){zs.ph_toolbar_state=n}getToolbarState(){var n;return(n=zs.ph_toolbar_state)!==null&&n!==void 0?n:BE.UNINITIALIZED}maybeLoadToolbar(){var n,i,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!p4||!Fn)return!1;o=(n=o)!==null&&n!==void 0?n:p4.location,s=(i=s)!==null&&i!==void 0?i:p4.history;try{if(!a){try{p4.localStorage.setItem("test","test"),p4.localStorage.removeItem("test")}catch{return!1}a=p4==null?void 0:p4.localStorage}var r,C=X00||PS(o.hash,"__posthog")||PS(o.hash,"state"),l=C?Il2(()=>JSON.parse(atob(decodeURIComponent(C))))||Il2(()=>JSON.parse(decodeURIComponent(C))):null;return l&&l.action==="ph_authorize"?((r=l).source="url",r&&Object.keys(r).length>0&&(l.desiredHash?o.hash=l.desiredHash:s?s.replaceState(s.state,"",o.pathname+o.search):o.hash="")):((r=JSON.parse(a.getItem(wu2)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token)&&(this.loadToolbar(r),!0)}catch{return!1}}_callLoadToolbar(n){var i=zs.ph_load_toolbar||zs.ph_load_editor;!ll(i)&&rg(i)?i(n,this.instance):Qu2.warn("No toolbar load function found")}loadToolbar(n){var i=!(Fn==null||!Fn.getElementById(Sl2));if(!p4||i)return!1;var o=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,a=S4(S4({token:this.instance.config.token},n),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},o?{instrument:!1}:{});if(p4.localStorage.setItem(wu2,JSON.stringify(S4(S4({},a),{},{source:void 0}))),this.getToolbarState()===BE.LOADED)this._callLoadToolbar(a);else if(this.getToolbarState()===BE.UNINITIALIZED){var s,r;this.setToolbarState(BE.LOADING),(s=zs.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"toolbar",C=>{if(C)return Qu2.error("[Toolbar] Failed to load",C),void this.setToolbarState(BE.UNINITIALIZED);this.setToolbarState(BE.LOADED),this._callLoadToolbar(a)}),su(p4,"turbolinks:load",()=>{this.setToolbarState(BE.UNINITIALIZED),this.loadToolbar(a)})}return!0}_loadEditor(n){return this.loadToolbar(n)}maybeLoadEditor(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(n,i,o)}}var J00=PA("[TracingHeaders]");class q00{constructor(n){St(this,"_restoreXHRPatch",void 0),St(this,"_restoreFetchPatch",void 0),St(this,"_startCapturing",()=>{var i,o,a,s;Mr(this._restoreXHRPatch)&&((i=zs.__PosthogExtensions__)===null||i===void 0||(o=i.tracingHeadersPatchFns)===null||o===void 0||o._patchXHR(this.instance.sessionManager)),Mr(this._restoreFetchPatch)&&((a=zs.__PosthogExtensions__)===null||a===void 0||(s=a.tracingHeadersPatchFns)===null||s===void 0||s._patchFetch(this.instance.sessionManager))}),this.instance=n}_loadScript(n){var i,o,a;(i=zs.__PosthogExtensions__)!==null&&i!==void 0&&i.tracingHeadersPatchFns&&n(),(o=zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"tracing-headers",s=>{if(s)return J00.error("failed to load script",s);n()})}startIfEnabledOrStop(){var n,i;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((n=this._restoreXHRPatch)===null||n===void 0||n.call(this),(i=this._restoreFetchPatch)===null||i===void 0||i.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var ym=PA("[Web Vitals]"),Mu2=9e5;class $00{constructor(n){var i;St(this,"_enabledServerSide",!1),St(this,"_initialized",!1),St(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),St(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((o,a)=>S4(S4({},o),{},{["$web_vitals_".concat(a.name,"_event")]:S4({},a),["$web_vitals_".concat(a.name,"_value")]:a.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),St(this,"_addToBuffer",o=>{var a,s=(a=this.instance.sessionManager)===null||a===void 0?void 0:a.checkAndGetSessionAndWindowId(!0);if(Mr(s))ym.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();Mr(r)||(ll(o==null?void 0:o.name)||ll(o==null?void 0:o.value)?ym.error("Invalid metric received",o):this._maxAllowedValue&&o.value>=this._maxAllowedValue?ym.error("Ignoring metric with value >= "+this._maxAllowedValue,o):(this.buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Mr(this.buffer.url)&&(this.buffer.url=r),this.buffer.firstMetricTimestamp=Mr(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,o.attribution&&o.attribution.interactionTargetElement&&(o.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(S4(S4({},o),{},{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),St(this,"_startCapturing",()=>{var o,a,s,r,C=zs.__PosthogExtensions__;Mr(C)||Mr(C.postHogWebVitalsCallbacks)||({onLCP:o,onCLS:a,onFCP:s,onINP:r}=C.postHogWebVitalsCallbacks),o&&a&&s&&r?(this.allowedMetrics.indexOf("LCP")>-1&&o(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&a(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this)),this._initialized=!0):ym.error("web vitals callbacks not loaded - not starting")}),this.instance=n,this._enabledServerSide=!((i=this.instance.persistence)===null||i===void 0||!i.props[Ll2]),this.startIfEnabled()}get allowedMetrics(){var n,i,o=Xl(this.instance.config.capture_performance)?(n=this.instance.config.capture_performance)===null||n===void 0?void 0:n.web_vitals_allowed_metrics:void 0;return Mr(o)?((i=this.instance.persistence)===null||i===void 0?void 0:i.props[Ql2])||["CLS","FCP","INP","LCP"]:o}get flushToCaptureTimeoutMs(){return(Xl(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var n=Xl(this.instance.config.capture_performance)&&Ac(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Mu2;return 0<n&&n<=6e4?Mu2:n}get isEnabled(){var n=Xl(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return Kp(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(ym.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(n){var i=Xl(n.capturePerformance)&&!!n.capturePerformance.web_vitals,o=Xl(n.capturePerformance)?n.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[Ll2]:i}),this.instance.persistence.register({[Ql2]:o})),this._enabledServerSide=i,this.startIfEnabled()}loadScript(n){var i,o,a;(i=zs.__PosthogExtensions__)!==null&&i!==void 0&&i.postHogWebVitalsCallbacks&&n(),(o=zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"web-vitals",s=>{s?ym.error("failed to load script",s):n()})}_currentURL(){var n=p4?p4.location.href:void 0;return n||ym.error("Could not determine current URL"),n}}var e10=PA("[Heatmaps]");function Tu2(t){return Xl(t)&&"clientX"in t&&"clientY"in t&&Ac(t.clientX)&&Ac(t.clientY)}class t10{constructor(n){var i;St(this,"rageclicks",new Kl2),St(this,"_enabledServerSide",!1),St(this,"_initialized",!1),St(this,"_flushInterval",null),this.instance=n,this._enabledServerSide=!((i=this.instance.persistence)===null||i===void 0||!i.props[u_])}get flushIntervalMilliseconds(){var n=5e3;return Xl(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(n=this.instance.config.capture_heatmaps.flush_interval_milliseconds),n}get isEnabled(){return Mr(this.instance.config.capture_heatmaps)?Mr(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;e10.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var n,i;clearInterval((n=this._flushInterval)!==null&&n!==void 0?n:void 0),(i=this.deadClicksCapture)===null||i===void 0||i.stop(),this.getAndClearBuffer()}}onRemoteConfig(n){var i=!!n.heatmaps;this.instance.persistence&&this.instance.persistence.register({[u_]:i}),this._enabledServerSide=i,this.startIfEnabled()}getAndClearBuffer(){var n=this.buffer;return this.buffer=void 0,n}_onDeadClick(n){this._onClick(n.originalEvent,"deadclick")}_setupListeners(){p4&&Fn&&(su(p4,"beforeunload",this.flush.bind(this)),su(Fn,"click",n=>this._onClick(n||(p4==null?void 0:p4.event)),{capture:!0}),su(Fn,"mousemove",n=>this._onMouseMove(n||(p4==null?void 0:p4.event)),{capture:!0}),this.deadClicksCapture=new tu2(this.instance,d00,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(n,i){var o=this.instance.scrollManager.scrollY(),a=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),r=function(C,l,e){for(var u=C;u&&SS(u)&&!qp(u,"body");){if(u===e)return!1;if(lC(l,p4==null?void 0:p4.getComputedStyle(u).position))return!0;u=jl2(u)}return!1}(Ul2(n),["fixed","sticky"],s);return{x:n.clientX+(r?0:a),y:n.clientY+(r?0:o),target_fixed:r,type:i}}_onClick(n){var i,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"click";if(!kl2(n.target)&&Tu2(n)){var a=this._getProperties(n,o);(i=this.rageclicks)!==null&&i!==void 0&&i.isRageClick(n.clientX,n.clientY,new Date().getTime())&&this._capture(S4(S4({},a),{},{type:"rageclick"})),this._capture(a)}}_onMouseMove(n){!kl2(n.target)&&Tu2(n)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(n,"mousemove"))},500))}_capture(n){if(p4){var i=p4.location.href;this.buffer=this.buffer||{},this.buffer[i]||(this.buffer[i]=[]),this.buffer[i].push(n)}}flush(){this.buffer&&!py(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class r10{constructor(n){this._instance=n}doPageView(n,i){var o,a=this._previousPageViewProperties(n,i);return this._currentPageview={pathname:(o=p4==null?void 0:p4.location.pathname)!==null&&o!==void 0?o:"",pageViewId:i,timestamp:n},this._instance.scrollManager.resetContext(),a}doPageLeave(n){var i;return this._previousPageViewProperties(n,(i=this._currentPageview)===null||i===void 0?void 0:i.pageViewId)}doEvent(){var n;return{$pageview_id:(n=this._currentPageview)===null||n===void 0?void 0:n.pageViewId}}_previousPageViewProperties(n,i){var o=this._currentPageview;if(!o)return{$pageview_id:i};var a={$pageview_id:i,$prev_pageview_id:o.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:r,lastScrollY:C,maxScrollY:l,maxContentHeight:e,lastContentY:u,maxContentY:A}=s;if(!(Mr(r)||Mr(C)||Mr(l)||Mr(e)||Mr(u)||Mr(A))){r=Math.ceil(r),C=Math.ceil(C),l=Math.ceil(l),e=Math.ceil(e),u=Math.ceil(u),A=Math.ceil(A);var f=r<=1?1:fd(C/r,0,1),d=r<=1?1:fd(l/r,0,1),g=e<=1?1:fd(u/e,0,1),E=e<=1?1:fd(A/e,0,1);a=mu(a,{$prev_pageview_last_scroll:C,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:A,$prev_pageview_max_content_percentage:E})}}return o.pathname&&(a.$prev_pageview_pathname=o.pathname),o.timestamp&&(a.$prev_pageview_duration=(n.getTime()-o.timestamp.getTime())/1e3),a}}class n10{constructor(n){this.instance=n}sendExceptionEvent(n){this.instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var gd="Mobile",JS="iOS",rh="Android",zM="Tablet",xu2=rh+" "+zM,Ru2="iPad",Hu2="Apple",Du2=Hu2+" Watch",GM="Safari",yy="BlackBerry",Nu2="Samsung",Su2=Nu2+"Browser",Vu2=Nu2+" Internet",Lm="Chrome",i10=Lm+" OS",ku2=Lm+" "+JS,z_="Internet Explorer",Ou2=z_+" "+gd,G_="Opera",o10=G_+" Mini",Y_="Edge",Pu2="Microsoft "+Y_,Ly="Firefox",Zu2=Ly+" "+JS,YM="Nintendo",WM="PlayStation",wy="Xbox",Fu2=rh+" "+gd,Uu2=gd+" "+GM,_M="Windows",W_=_M+" Phone",ju2="Nokia",__="Ouya",zu2="Generic",a10=zu2+" "+gd.toLowerCase(),Gu2=zu2+" "+zM.toLowerCase(),X_="Konqueror",cc="(\\d+(\\.\\d+)?)",K_=new RegExp("Version/"+cc),s10=new RegExp(wy,"i"),C10=new RegExp(WM+" \\w+","i"),l10=new RegExp(YM+" \\w+","i"),J_=new RegExp(yy+"|PlayBook|BB10","i"),u10={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},q_,A10=(t,n)=>n&&lC(n,Hu2)||function(i){return lC(i,GM)&&!lC(i,Lm)&&!lC(i,rh)}(t),Yu2=function(t,n){return n=n||"",lC(t," OPR/")&&lC(t,"Mini")?o10:lC(t," OPR/")?G_:J_.test(t)?yy:lC(t,"IE"+gd)||lC(t,"WPDesktop")?Ou2:lC(t,Su2)?Vu2:lC(t,Y_)||lC(t,"Edg/")?Pu2:lC(t,"FBIOS")?"Facebook "+gd:lC(t,"UCWEB")||lC(t,"UCBrowser")?"UC Browser":lC(t,"CriOS")?ku2:lC(t,"CrMo")||lC(t,Lm)?Lm:lC(t,rh)&&lC(t,GM)?Fu2:lC(t,"FxiOS")?Zu2:lC(t.toLowerCase(),X_.toLowerCase())?X_:A10(t,n)?lC(t,gd)?Uu2:GM:lC(t,Ly)?Ly:lC(t,"MSIE")||lC(t,"Trident/")?z_:lC(t,"Gecko")?Ly:""},c10={[Ou2]:[new RegExp("rv:"+cc)],[Pu2]:[new RegExp(Y_+"?\\/"+cc)],[Lm]:[new RegExp("("+Lm+"|CrMo)\\/"+cc)],[ku2]:[new RegExp("CriOS\\/"+cc)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+cc)],[GM]:[K_],[Uu2]:[K_],[G_]:[new RegExp("(Opera|OPR)\\/"+cc)],[Ly]:[new RegExp(Ly+"\\/"+cc)],[Zu2]:[new RegExp("FxiOS\\/"+cc)],[X_]:[new RegExp("Konqueror[:/]?"+cc,"i")],[yy]:[new RegExp(yy+" "+cc),K_],[Fu2]:[new RegExp("android\\s"+cc,"i")],[Vu2]:[new RegExp(Su2+"\\/"+cc)],[z_]:[new RegExp("(rv:|MSIE )"+cc)],Mozilla:[new RegExp("rv:"+cc)]},Wu2=[[new RegExp(wy+"; "+wy+" (.*?)[);]","i"),t=>[wy,t&&t[1]||""]],[new RegExp(YM,"i"),[YM,""]],[new RegExp(WM,"i"),[WM,""]],[J_,[yy,""]],[new RegExp(_M,"i"),(t,n)=>{if(/Phone/.test(n)||/WPDesktop/.test(n))return[W_,""];if(new RegExp(gd).test(n)&&!/IEMobile\b/.test(n))return[_M+" "+gd,""];var i=/Windows NT ([0-9.]+)/i.exec(n);if(i&&i[1]){var o=i[1],a=u10[o]||"";return/arm/i.test(n)&&(a="RT"),[_M,a]}return[_M,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var n=[t[3],t[4],t[5]||"0"];return[JS,n.join(".")]}return[JS,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var n="";return t&&t.length>=3&&(n=Mr(t[2])?t[3]:t[2]),["watchOS",n]}],[new RegExp("("+rh+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+rh+")","i"),t=>{if(t&&t[2]){var n=[t[2],t[3],t[4]||"0"];return[rh,n.join(".")]}return[rh,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var n=["Mac OS X",""];if(t&&t[1]){var i=[t[1],t[2],t[3]||"0"];n[1]=i.join(".")}return n}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[i10,""]],[/Linux|debian/i,["Linux",""]]],_u2=function(t){return l10.test(t)?YM:C10.test(t)?WM:s10.test(t)?wy:new RegExp(__,"i").test(t)?__:new RegExp("("+W_+"|WPDesktop)","i").test(t)?W_:/iPad/.test(t)?Ru2:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Du2:J_.test(t)?yy:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(ju2,"i").test(t)?ju2:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?!new RegExp(gd).test(t)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)?/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?rh:xu2:rh:new RegExp("(pda|"+gd+")","i").test(t)?a10:new RegExp(zM,"i").test(t)&&!new RegExp(zM+" pc","i").test(t)?Gu2:""},qS="https?://(.*)",$S=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],f10=MS(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],$S),$_="<masked>",Sl={campaignParams:function(){var{customTrackedParams:t,maskPersonalDataProperties:n,customPersonalDataProperties:i}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!Fn)return{};var o=n?MS([],$S,i||[]):[];return this._campaignParamsFromUrl(y_(Fn.URL,o,$_),t)},_campaignParamsFromUrl:function(t,n){var i=f10.concat(n||[]),o={};return cl(i,function(a){var s=OS(t,a);o[a]=s||null}),o},_searchEngine:function(t){return t?t.search(qS+"google.([^/?]*)")===0?"google":t.search(qS+"bing.com")===0?"bing":t.search(qS+"yahoo.com")===0?"yahoo":t.search(qS+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(t){var n=Sl._searchEngine(t),i=n!="yahoo"?"q":"p",o={};if(!Xp(n)){o.$search_engine=n;var a=Fn?OS(Fn.referrer,i):"";a.length&&(o.ph_keyword=a)}return o},searchInfo:function(){var t=Fn==null?void 0:Fn.referrer;return t?this._searchInfoFromReferrer(t):{}},browser:Yu2,browserVersion:function(t,n){var i=Yu2(t,n),o=c10[i];if(Mr(o))return null;for(var a=0;a<o.length;a++){var s=o[a],r=t.match(s);if(r)return parseFloat(r[r.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var t=this.browserLanguage();return typeof t=="string"?t.split("-")[0]:void 0},os:function(t){for(var n=0;n<Wu2.length;n++){var[i,o]=Wu2[n],a=i.exec(t),s=a&&(rg(o)?o(a,t):o);if(s)return s}return["",""]},device:_u2,deviceType:function(t){var n=_u2(t);return n===Ru2||n===xu2||n==="Kobo"||n==="Kindle Fire"||n===Gu2?zM:n===YM||n===wy||n===WM||n===__?"Console":n===Du2?"Wearable":n?gd:"Desktop"},referrer:function(){return(Fn==null?void 0:Fn.referrer)||"$direct"},referringDomain:function(){var t;return Fn!=null&&Fn.referrer&&((t=my(Fn.referrer))===null||t===void 0?void 0:t.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=t?MS([],$S,n||[]):[],o=cd==null?void 0:cd.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:o?y_(o,i,$_):void 0}},personPropsFromInfo:function(t){var n,{r:i,u:o}=t,a={$referrer:i,$referring_domain:i==null?void 0:i=="$direct"?"$direct":(n=my(i))===null||n===void 0?void 0:n.host};if(o){a.$current_url=o;var s=my(o);a.$host=s==null?void 0:s.host,a.$pathname=s==null?void 0:s.pathname;var r=this._campaignParamsFromUrl(o);mu(a,r)}if(i){var C=this._searchInfoFromReferrer(i);mu(a,C)}return a},initialPersonPropsFromInfo:function(t){var n=this.personPropsFromInfo(t),i={};return cl(n,function(o,a){i["$initial_".concat(C_(a))]=o}),i},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}},timezoneOffset:function(){try{return new Date().getTimezoneOffset()}catch{return}},properties:function(){var{maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!vu)return{};var i=t?MS([],$S,n||[]):[],[o,a]=Sl.os(vu);return mu(NM({$os:o,$os_version:a,$browser:Sl.browser(vu,navigator.vendor),$device:Sl.device(vu),$device_type:Sl.deviceType(vu),$timezone:Sl.timezone(),$timezone_offset:Sl.timezoneOffset()}),{$current_url:y_(cd==null?void 0:cd.href,i,$_),$host:cd==null?void 0:cd.host,$pathname:cd==null?void 0:cd.pathname,$raw_user_agent:vu.length>1e3?vu.substring(0,997)+"...":vu,$browser_version:Sl.browserVersion(vu,navigator.vendor),$browser_language:Sl.browserLanguage(),$browser_language_prefix:Sl.browserLanguagePrefix(),$screen_height:p4==null?void 0:p4.screen.height,$screen_width:p4==null?void 0:p4.screen.width,$viewport_height:p4==null?void 0:p4.innerHeight,$viewport_width:p4==null?void 0:p4.innerWidth,$lib:"web",$lib_version:pE.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!vu)return{};var[t,n]=Sl.os(vu);return mu(NM({$os:t,$os_version:n,$browser:Sl.browser(vu,navigator.vendor)}),{$browser_version:Sl.browserVersion(vu,navigator.vendor)})}},nh=PA("[FeatureFlags]"),eX="$active_feature_flags",Qy="$override_feature_flags",Xu2="$feature_flag_payloads",XM="$override_feature_flag_payloads",Ku2="$feature_flag_request_id",Ju2=t=>{var n={};for(var[i,o]of TS(t||{}))o&&(n[i]=o);return n},d10=t=>{var n=t.flags;return n?(t.featureFlags=Object.fromEntries(Object.keys(n).map(i=>{var o;return[i,(o=n[i].variant)!==null&&o!==void 0?o:n[i].enabled]})),t.featureFlagPayloads=Object.fromEntries(Object.keys(n).filter(i=>n[i].enabled).filter(i=>{var o;return(o=n[i].metadata)===null||o===void 0?void 0:o.payload}).map(i=>{var o;return[i,(o=n[i].metadata)===null||o===void 0?void 0:o.payload]}))):nh.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t};(function(t){t.FeatureFlags="feature_flags",t.Recordings="recordings"})(q_||(q_={}));class g10{constructor(n){St(this,"_override_warning",!1),St(this,"_hasLoadedFlags",!1),St(this,"_requestInFlight",!1),St(this,"_reloadingDisabled",!1),St(this,"_additionalReloadRequested",!1),St(this,"_decideCalled",!1),St(this,"_flagsLoadedFromRemote",!1),this.instance=n,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var n=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:n})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var n=this.instance.get_property(d_),i=this.instance.get_property(Qy),o=this.instance.get_property(XM);if(!o&&!i)return n||{};var a=mu({},n||{}),s=[...new Set([...Object.keys(o||{}),...Object.keys(i||{})])];for(var r of s){var C,l,e=a[r],u=i==null?void 0:i[r],A=Mr(u)?(C=e==null?void 0:e.enabled)!==null&&C!==void 0&&C:!!u,f=Mr(u)?e.variant:typeof u=="string"?u:void 0,d=o==null?void 0:o[r],g=S4(S4({},e),{},{enabled:A,variant:A?f??(e==null?void 0:e.variant):void 0});A!==(e==null?void 0:e.enabled)&&(g.original_enabled=e==null?void 0:e.enabled),f!==(e==null?void 0:e.variant)&&(g.original_variant=e==null?void 0:e.variant),d&&(g.metadata=S4(S4({},e==null?void 0:e.metadata),{},{payload:d,original_payload:e==null||(l=e.metadata)===null||l===void 0?void 0:l.payload})),a[r]=g}return this._override_warning||(nh.warn(" Overriding feature flag details!",{flagDetails:n,overriddenPayloads:o,finalDetails:a}),this._override_warning=!0),a}getFlagVariants(){var n=this.instance.get_property(vy),i=this.instance.get_property(Qy);if(!i)return n||{};for(var o=mu({},n),a=Object.keys(i),s=0;s<a.length;s++)o[a[s]]=i[a[s]];return this._override_warning||(nh.warn(" Overriding feature flags!",{enabledFlags:n,overriddenFlags:i,finalFlags:o}),this._override_warning=!0),o}getFlagPayloads(){var n=this.instance.get_property(Xu2),i=this.instance.get_property(XM);if(!i)return n||{};for(var o=mu({},n||{}),a=Object.keys(i),s=0;s<a.length;s++)o[a[s]]=i[a[s]];return this._override_warning||(nh.warn(" Overriding feature flag payloads!",{flagPayloads:n,overriddenPayloads:i,finalPayloads:o}),this._override_warning=!0),o}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout(()=>{this._callDecideEndpoint()},5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(n){this.$anon_distinct_id=n}setReloadingPaused(n){this._reloadingDisabled=n}_callDecideEndpoint(n){var i;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var o={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:S4(S4({},((i=this.instance.persistence)===null||i===void 0?void 0:i.get_initial_props())||{}),this.instance.get_property(OM)||{}),group_properties:this.instance.get_property(vm)};(n!=null&&n.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(o.disable_flags=!0);var a=this.instance.config.__preview_flags_v2&&this.instance.config.__preview_remote_config;a&&(o.timezone=Sl.timezone()),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api",a?"/flags/?v=2":"/decide/?v=4"),data:o,compression:this.instance.config.disable_compression?void 0:tg.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:s=>{var r,C,l,e=!0;s.statusCode===200&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),e=!1),this._requestInFlight=!1,this._decideCalled||(this._decideCalled=!0,this.instance._onRemoteConfig((l=s.json)!==null&&l!==void 0?l:{})),o.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!e,s.json&&(r=s.json.quotaLimited)!==null&&r!==void 0&&r.includes(q_.FeatureFlags)?nh.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(this.receivedFeatureFlags((C=s.json)!==null&&C!==void 0?C:{},e),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint())))}})}}getFeatureFlag(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var o=this.getFlagVariants()[n],a="".concat(o),s=this.instance.get_property(Ku2)||void 0,r=this.instance.get_property(DS)||{};if((i.send_event||!("send_event"in i))&&(!(n in r)||!r[n].includes(a))){var C,l,e,u,A,f,d,g,E,y,Q;_l(r[n])?r[n].push(a):r[n]=[a],(C=this.instance.persistence)===null||C===void 0||C.register({[DS]:r});var R=this.getFeatureFlagDetails(n),D={$feature_flag:n,$feature_flag_response:o,$feature_flag_payload:this.getFeatureFlagPayload(n)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:((l=this.instance.config.bootstrap)===null||l===void 0||(e=l.featureFlags)===null||e===void 0?void 0:e[n])||null,$feature_flag_bootstrapped_payload:((u=this.instance.config.bootstrap)===null||u===void 0||(A=u.featureFlagPayloads)===null||A===void 0?void 0:A[n])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};Mr(R==null||(f=R.metadata)===null||f===void 0?void 0:f.version)||(D.$feature_flag_version=R.metadata.version);var O,k=(d=R==null||(g=R.reason)===null||g===void 0?void 0:g.description)!==null&&d!==void 0?d:R==null||(E=R.reason)===null||E===void 0?void 0:E.code;k&&(D.$feature_flag_reason=k),R!=null&&(y=R.metadata)!==null&&y!==void 0&&y.id&&(D.$feature_flag_id=R.metadata.id),Mr(R==null?void 0:R.original_variant)&&Mr(R==null?void 0:R.original_enabled)||(D.$feature_flag_original_response=Mr(R.original_variant)?R.original_enabled:R.original_variant),R!=null&&(Q=R.metadata)!==null&&Q!==void 0&&Q.original_payload&&(D.$feature_flag_original_payload=R==null||(O=R.metadata)===null||O===void 0?void 0:O.original_payload),this.instance.capture("$feature_flag_called",D)}return o}nh.warn('getFeatureFlag for key "'+n+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(n){return this.getFlagsWithDetails()[n]}getFeatureFlagPayload(n){return this.getFlagPayloads()[n]}getRemoteConfigPayload(n,i){var o=this.instance.config.token;this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=4"),data:{distinct_id:this.instance.get_distinct_id(),token:o},compression:this.instance.config.disable_compression?void 0:tg.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:a=>{var s,r=(s=a.json)===null||s===void 0?void 0:s.featureFlagPayloads;i((r==null?void 0:r[n])||void 0)}})}isFeatureEnabled(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(n,i);nh.warn('isFeatureEnabled for key "'+n+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(n){this.featureFlagEventHandlers.push(n)}removeFeatureFlagsHandler(n){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==n)}receivedFeatureFlags(n,i){if(this.instance.persistence){this._hasLoadedFlags=!0;var o=this.getFlagVariants(),a=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(r,C){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},e=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},u=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},A=d10(r),f=A.flags,d=A.featureFlags,g=A.featureFlagPayloads;if(d){var E=r.requestId;if(_l(d)){nh.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(d)for(var Q=0;Q<d.length;Q++)y[d[Q]]=!0;C&&C.register({[eX]:d,[vy]:y})}else{var R=d,D=g,O=f;r.errorsWhileComputingFlags&&(R=S4(S4({},l),R),D=S4(S4({},e),D),O=S4(S4({},u),O)),C&&C.register(S4({[eX]:Object.keys(Ju2(R)),[vy]:R||{},[Xu2]:D||{},[d_]:O||{}},E?{[Ku2]:E}:{}))}}})(n,this.instance.persistence,o,a,s),this._fireFeatureFlagsCallbacks(i)}}override(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];nh.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:n,suppressWarning:i})}overrideFeatureFlags(n){if(!this.instance.__loaded||!this.instance.persistence)return nh.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(n===!1)return this.instance.persistence.unregister(Qy),this.instance.persistence.unregister(XM),void this._fireFeatureFlagsCallbacks();if(n&&typeof n=="object"&&("flags"in n||"payloads"in n)){var i,o=n;if(this._override_warning=!!((i=o.suppressWarning)!==null&&i!==void 0&&i),"flags"in o){if(o.flags===!1)this.instance.persistence.unregister(Qy);else if(o.flags)if(_l(o.flags)){for(var a={},s=0;s<o.flags.length;s++)a[o.flags[s]]=!0;this.instance.persistence.register({[Qy]:a})}else this.instance.persistence.register({[Qy]:o.flags})}return"payloads"in o&&(o.payloads===!1?this.instance.persistence.unregister(XM):o.payloads&&this.instance.persistence.register({[XM]:o.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(n){if(this.addFeatureFlagsHandler(n),this._hasLoadedFlags){var{flags:i,flagVariants:o}=this._prepareFeatureFlagsForCallbacks();n(i,o)}return()=>this.removeFeatureFlagsHandler(n)}updateEarlyAccessFeatureEnrollment(n,i){var o,a=(this.instance.get_property(RS)||[]).find(l=>l.flagKey===n),s={["$feature_enrollment/".concat(n)]:i},r={$feature_flag:n,$feature_enrollment:i,$set:s};a&&(r.$early_access_feature_name=a.name),this.instance.capture("$feature_enrollment_update",r),this.setPersonPropertiesForFlags(s,!1);var C=S4(S4({},this.getFlagVariants()),{},{[n]:i});(o=this.instance.persistence)===null||o===void 0||o.register({[eX]:Object.keys(Ju2(C)),[vy]:C}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],o=arguments.length>2?arguments[2]:void 0,a=this.instance.get_property(RS),s=o?"&".concat(o.map(r=>"stage=".concat(r)).join("&")):"";if(a&&!i)return n(a);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token).concat(s)),method:"GET",callback:r=>{var C;if(r.json){var l=r.json.earlyAccessFeatures;return(C=this.instance.persistence)===null||C===void 0||C.register({[RS]:l}),n(l)}}})}_prepareFeatureFlagsForCallbacks(){var n=this.getFlags(),i=this.getFlagVariants();return{flags:n.filter(o=>i[o]),flagVariants:Object.keys(i).filter(o=>i[o]).reduce((o,a)=>(o[a]=i[a],o),{})}}_fireFeatureFlagsCallbacks(n){var{flags:i,flagVariants:o}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach(a=>a(i,o,{errorsLoading:n}))}setPersonPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],o=this.instance.get_property(OM)||{};this.instance.register({[OM]:S4(S4({},o),n)}),i&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(OM)}setGroupPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],o=this.instance.get_property(vm)||{};Object.keys(o).length!==0&&Object.keys(o).forEach(a=>{o[a]=S4(S4({},o[a]),n[a]),delete n[a]}),this.instance.register({[vm]:S4(S4({},o),n)}),i&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(n){if(n){var i=this.instance.get_property(vm)||{};this.instance.register({[vm]:S4(S4({},i),{},{[n]:{}})})}else this.instance.unregister(vm)}}var h10=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class tX{constructor(n){this.config=n,this.props={},this.campaign_params_saved=!1,this.name=(i=>{var o="";return i.token&&(o=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+o+"_posthog"})(n),this.storage=this.buildStorage(n),this.load(),n.debug&&Wi.info("Persistence loaded",n.persistence,S4({},this.props)),this.update_config(n,n),this.save()}buildStorage(n){h10.indexOf(n.persistence.toLowerCase())===-1&&(Wi.critical("Unknown persistence type "+n.persistence+"; falling back to localStorage+cookie"),n.persistence="localStorage+cookie");var i=n.persistence.toLowerCase();return i==="localstorage"&&Du.is_supported()?Du:i==="localstorage+cookie"&&FS.is_supported()?FS:i==="sessionstorage"&&uA.is_supported()?uA:i==="memory"?c00:i==="cookie"?IE:FS.is_supported()?FS:IE}properties(){var n={};return cl(this.props,function(i,o){if(o===vy&&Xl(i))for(var a=Object.keys(i),s=0;s<a.length;s++)n["$feature/".concat(a[s])]=i[a[s]];else C=o,l=!1,(Xp(r=G20)?l:cl2&&r.indexOf===cl2?r.indexOf(C)!=-1:(cl(r,function(e){if(l||(l=e===C))return QS}),l))||(n[o]=i);var r,C,l}),n}load(){if(!this.disabled){var n=this.storage.parse(this.name);n&&(this.props=mu({},n))}}save(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}remove(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}clear(){this.remove(),this.props={}}register_once(n,i,o){if(Xl(n)){Mr(i)&&(i="None"),this.expire_days=Mr(o)?this.default_expiry:o;var a=!1;if(cl(n,(s,r)=>{this.props.hasOwnProperty(r)&&this.props[r]!==i||(this.props[r]=s,a=!0)}),a)return this.save(),!0}return!1}register(n,i){if(Xl(n)){this.expire_days=Mr(i)?this.default_expiry:i;var o=!1;if(cl(n,(a,s)=>{n.hasOwnProperty(s)&&this.props[s]!==a&&(this.props[s]=a,o=!0)}),o)return this.save(),!0}return!1}unregister(n){n in this.props&&(delete this.props[n],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var n=Sl.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});py(NM(n))||this.register(n),this.campaign_params_saved=!0}}update_search_keyword(){this.register(Sl.searchInfo())}update_referrer_info(){this.register_once(Sl.referrerInfo(),void 0)}set_initial_person_info(){this.props[p_]||this.props[v_]||this.register_once({[I_]:Sl.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return NM({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var n={};cl([v_,p_],a=>{var s=this.props[a];s&&cl(s,function(r,C){n["$initial_"+C_(C)]=r})});var i=this.props[I_];if(i){var o=Sl.initialPersonPropsFromInfo(i);mu(n,o)}return n}safe_merge(n){return cl(this.props,function(i,o){o in n||(n[o]=i)}),n}update_config(n,i){if(this.default_expiry=this.expire_days=n.cookie_expiration,this.set_disabled(n.disable_persistence),this.set_cross_subdomain(n.cross_subdomain_cookie),this.set_secure(n.secure_cookie),n.persistence!==i.persistence){var o=this.buildStorage(n),a=this.props;this.clear(),this.storage=o,this.props=a,this.save()}}set_disabled(n){this.disabled=n,this.disabled?this.remove():this.save()}set_cross_subdomain(n){n!==this.cross_subdomain&&(this.cross_subdomain=n,this.remove(),this.save())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(n){n!==this.secure&&(this.secure=n,this.remove(),this.save())}set_event_timer(n,i){var o=this.props[VM]||{};o[n]=i,this.props[VM]=o,this.save()}remove_event_timer(n){var i=(this.props[VM]||{})[n];return Mr(i)||(delete this.props[VM][n],this.save()),i}get_property(n){return this.props[n]}set_property(n,i){this.props[n]=i,this.save()}}var qu2,Kl,$u2,wm,eA2,tA2,rX,rA2,nA2,iA2,oA2,aA2,nX={},sA2=[],E10=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,iX=Array.isArray;function tv(t,n){for(var i in n)t[i]=n[i];return t}function CA2(t){var n=t.parentNode;n&&n.removeChild(t)}function oX(t,n,i,o,a){var s={type:t,props:n,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:a??++$u2,__i:-1,__u:0};return a==null&&Kl.vnode!=null&&Kl.vnode(s),s}function aX(t){return t.children}function eV(t,n){this.props=t,this.context=n}function My(t,n){if(n==null)return t.__?My(t.__,t.__i+1):null;for(var i;n<t.__k.length;n++)if((i=t.__k[n])!=null&&i.__e!=null)return i.__e;return typeof t.type=="function"?My(t):null}function lA2(t){var n,i;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,n=0;n<t.__k.length;n++)if((i=t.__k[n])!=null&&i.__e!=null){t.__e=t.__c.base=i.__e;break}return lA2(t)}}function sX(t){(!t.__d&&(t.__d=!0)&&wm.push(t)&&!tV.__r++||eA2!==Kl.debounceRendering)&&((eA2=Kl.debounceRendering)||tA2)(tV)}function tV(){var t,n,i,o,a,s,r,C,l;for(wm.sort(rX);t=wm.shift();)t.__d&&(n=wm.length,o=void 0,s=(a=(i=t).__v).__e,C=[],l=[],(r=i.__P)&&((o=tv({},a)).__v=a.__v+1,Kl.vnode&&Kl.vnode(o),gA2(r,o,a,i.__n,r.ownerSVGElement!==void 0,32&a.__u?[s]:null,C,s??My(a),!!(32&a.__u),l),o.__.__k[o.__i]=o,I10(C,o,l),o.__e!=s&&lA2(o)),wm.length>n&&wm.sort(rX));tV.__r=0}function uA2(t,n,i,o,a,s,r,C,l,e,u){var A,f,d,g,E,y=o&&o.__k||sA2,Q=n.length;for(i.__d=l,p10(i,n,y),l=i.__d,A=0;A<Q;A++)(d=i.__k[A])!=null&&typeof d!="boolean"&&typeof d!="function"&&(f=d.__i===-1?nX:y[d.__i]||nX,d.__i=A,gA2(t,d,f,a,s,r,C,l,e,u),g=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&CX(f.ref,null,d),u.push(d.ref,d.__c||g,d)),E==null&&g!=null&&(E=g),65536&d.__u||f.__k===d.__k?l=AA2(d,l,t):typeof d.type=="function"&&d.__d!==void 0?l=d.__d:g&&(l=g.nextSibling),d.__d=void 0,d.__u&=-196609);i.__d=l,i.__e=E}function p10(t,n,i){var o,a,s,r,C,l=n.length,e=i.length,u=e,A=0;for(t.__k=[],o=0;o<l;o++)(a=t.__k[o]=(a=n[o])==null||typeof a=="boolean"||typeof a=="function"?null:typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?oX(null,a,null,null,a):iX(a)?oX(aX,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?oX(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a)!=null?(a.__=t,a.__b=t.__b+1,C=v10(a,i,r=o+A,u),a.__i=C,s=null,C!==-1&&(u--,(s=i[C])&&(s.__u|=131072)),s==null||s.__v===null?(C==-1&&A--,typeof a.type!="function"&&(a.__u|=65536)):C!==r&&(C===r+1?A++:C>r?u>l-r?A+=C-r:A--:A=C<r&&C==r-1?C-r:0,C!==o+A&&(a.__u|=65536))):(s=i[o])&&s.key==null&&s.__e&&(s.__e==t.__d&&(t.__d=My(s)),lX(s,s,!1),i[o]=null,u--);if(u)for(o=0;o<e;o++)(s=i[o])!=null&&!(131072&s.__u)&&(s.__e==t.__d&&(t.__d=My(s)),lX(s,s))}function AA2(t,n,i){var o,a;if(typeof t.type=="function"){for(o=t.__k,a=0;o&&a<o.length;a++)o[a]&&(o[a].__=t,n=AA2(o[a],n,i));return n}return t.__e!=n&&(i.insertBefore(t.__e,n||null),n=t.__e),n&&n.nextSibling}function v10(t,n,i,o){var a=t.key,s=t.type,r=i-1,C=i+1,l=n[i];if(l===null||l&&a==l.key&&s===l.type)return i;if(o>(l!=null&&!(131072&l.__u)?1:0))for(;r>=0||C<n.length;){if(r>=0){if((l=n[r])&&!(131072&l.__u)&&a==l.key&&s===l.type)return r;r--}if(C<n.length){if((l=n[C])&&!(131072&l.__u)&&a==l.key&&s===l.type)return C;C++}}return-1}function cA2(t,n,i){n[0]==="-"?t.setProperty(n,i??""):t[n]=i==null?"":typeof i!="number"||E10.test(n)?i:i+"px"}function rV(t,n,i,o,a){var s;e:if(n==="style")if(typeof i=="string")t.style.cssText=i;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(n in o)i&&n in i||cA2(t.style,n,"");if(i)for(n in i)o&&i[n]===o[n]||cA2(t.style,n,i[n])}else if(n[0]==="o"&&n[1]==="n")s=n!==(n=n.replace(/(PointerCapture)$|Capture$/,"$1")),n=n.toLowerCase()in t?n.toLowerCase().slice(2):n.slice(2),t.l||(t.l={}),t.l[n+s]=i,i?o?i.u=o.u:(i.u=Date.now(),t.addEventListener(n,s?dA2:fA2,s)):t.removeEventListener(n,s?dA2:fA2,s);else{if(a)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!=="width"&&n!=="height"&&n!=="href"&&n!=="list"&&n!=="form"&&n!=="tabIndex"&&n!=="download"&&n!=="rowSpan"&&n!=="colSpan"&&n!=="role"&&n in t)try{t[n]=i??"";break e}catch{}typeof i=="function"||(i==null||i===!1&&n[4]!=="-"?t.removeAttribute(n):t.setAttribute(n,i))}}function fA2(t){var n=this.l[t.type+!1];if(t.t){if(t.t<=n.u)return}else t.t=Date.now();return n(Kl.event?Kl.event(t):t)}function dA2(t){return this.l[t.type+!0](Kl.event?Kl.event(t):t)}function gA2(t,n,i,o,a,s,r,C,l,e){var u,A,f,d,g,E,y,Q,R,D,O,k,J,e2,p2,D2=n.type;if(n.constructor!==void 0)return null;128&i.__u&&(l=!!(32&i.__u),s=[C=n.__e=i.__e]),(u=Kl.__b)&&u(n);e:if(typeof D2=="function")try{if(Q=n.props,R=(u=D2.contextType)&&o[u.__c],D=u?R?R.props.value:u.__:o,i.__c?y=(A=n.__c=i.__c).__=A.__E:("prototype"in D2&&D2.prototype.render?n.__c=A=new D2(Q,D):(n.__c=A=new eV(Q,D),A.constructor=D2,A.render=b10),R&&R.sub(A),A.props=Q,A.state||(A.state={}),A.context=D,A.__n=o,f=A.__d=!0,A.__h=[],A._sb=[]),A.__s==null&&(A.__s=A.state),D2.getDerivedStateFromProps!=null&&(A.__s==A.state&&(A.__s=tv({},A.__s)),tv(A.__s,D2.getDerivedStateFromProps(Q,A.__s))),d=A.props,g=A.state,A.__v=n,f)D2.getDerivedStateFromProps==null&&A.componentWillMount!=null&&A.componentWillMount(),A.componentDidMount!=null&&A.__h.push(A.componentDidMount);else{if(D2.getDerivedStateFromProps==null&&Q!==d&&A.componentWillReceiveProps!=null&&A.componentWillReceiveProps(Q,D),!A.__e&&(A.shouldComponentUpdate!=null&&A.shouldComponentUpdate(Q,A.__s,D)===!1||n.__v===i.__v)){for(n.__v!==i.__v&&(A.props=Q,A.state=A.__s,A.__d=!1),n.__e=i.__e,n.__k=i.__k,n.__k.forEach(function(Q2){Q2&&(Q2.__=n)}),O=0;O<A._sb.length;O++)A.__h.push(A._sb[O]);A._sb=[],A.__h.length&&r.push(A);break e}A.componentWillUpdate!=null&&A.componentWillUpdate(Q,A.__s,D),A.componentDidUpdate!=null&&A.__h.push(function(){A.componentDidUpdate(d,g,E)})}if(A.context=D,A.props=Q,A.__P=t,A.__e=!1,k=Kl.__r,J=0,"prototype"in D2&&D2.prototype.render){for(A.state=A.__s,A.__d=!1,k&&k(n),u=A.render(A.props,A.state,A.context),e2=0;e2<A._sb.length;e2++)A.__h.push(A._sb[e2]);A._sb=[]}else do A.__d=!1,k&&k(n),u=A.render(A.props,A.state,A.context),A.state=A.__s;while(A.__d&&++J<25);A.state=A.__s,A.getChildContext!=null&&(o=tv(tv({},o),A.getChildContext())),f||A.getSnapshotBeforeUpdate==null||(E=A.getSnapshotBeforeUpdate(d,g)),uA2(t,iX(p2=u!=null&&u.type===aX&&u.key==null?u.props.children:u)?p2:[p2],n,i,o,a,s,r,C,l,e),A.base=n.__e,n.__u&=-161,A.__h.length&&r.push(A),y&&(A.__E=A.__=null)}catch(Q2){n.__v=null,l||s!=null?(n.__e=C,n.__u|=l?160:32,s[s.indexOf(C)]=null):(n.__e=i.__e,n.__k=i.__k),Kl.__e(Q2,n,i)}else s==null&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=m10(i.__e,n,i,o,a,s,r,l,e);(u=Kl.diffed)&&u(n)}function I10(t,n,i){n.__d=void 0;for(var o=0;o<i.length;o++)CX(i[o],i[++o],i[++o]);Kl.__c&&Kl.__c(n,t),t.some(function(a){try{t=a.__h,a.__h=[],t.some(function(s){s.call(a)})}catch(s){Kl.__e(s,a.__v)}})}function m10(t,n,i,o,a,s,r,C,l){var e,u,A,f,d,g,E,y=i.props,Q=n.props,R=n.type;if(R==="svg"&&(a=!0),s!=null){for(e=0;e<s.length;e++)if((d=s[e])&&"setAttribute"in d==!!R&&(R?d.localName===R:d.nodeType===3)){t=d,s[e]=null;break}}if(t==null){if(R===null)return document.createTextNode(Q);t=a?document.createElementNS("http://www.w3.org/2000/svg",R):document.createElement(R,Q.is&&Q),s=null,C=!1}if(R===null)y===Q||C&&t.data===Q||(t.data=Q);else{if(s=s&&qu2.call(t.childNodes),y=i.props||nX,!C&&s!=null)for(y={},e=0;e<t.attributes.length;e++)y[(d=t.attributes[e]).name]=d.value;for(e in y)d=y[e],e=="children"||(e=="dangerouslySetInnerHTML"?A=d:e==="key"||e in Q||rV(t,e,null,d,a));for(e in Q)d=Q[e],e=="children"?f=d:e=="dangerouslySetInnerHTML"?u=d:e=="value"?g=d:e=="checked"?E=d:e==="key"||C&&typeof d!="function"||y[e]===d||rV(t,e,d,y[e],a);if(u)C||A&&(u.__html===A.__html||u.__html===t.innerHTML)||(t.innerHTML=u.__html),n.__k=[];else if(A&&(t.innerHTML=""),uA2(t,iX(f)?f:[f],n,i,o,a&&R!=="foreignObject",s,r,s?s[0]:i.__k&&My(i,0),C,l),s!=null)for(e=s.length;e--;)s[e]!=null&&CA2(s[e]);C||(e="value",g!==void 0&&(g!==t[e]||R==="progress"&&!g||R==="option"&&g!==y[e])&&rV(t,e,g,y[e],!1),e="checked",E!==void 0&&E!==t[e]&&rV(t,e,E,y[e],!1))}return t}function CX(t,n,i){try{typeof t=="function"?t(n):t.current=n}catch(o){Kl.__e(o,i)}}function lX(t,n,i){var o,a;if(Kl.unmount&&Kl.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||CX(o,null,n)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){Kl.__e(s,n)}o.base=o.__P=null,t.__c=void 0}if(o=t.__k)for(a=0;a<o.length;a++)o[a]&&lX(o[a],n,i||typeof t.type!="function");i||t.__e==null||CA2(t.__e),t.__=t.__e=t.__d=void 0}function b10(t,n,i){return this.constructor(t,i)}qu2=sA2.slice,Kl={__e:function(t,n,i,o){for(var a,s,r;n=n.__;)if((a=n.__c)&&!a.__)try{if((s=a.constructor)&&s.getDerivedStateFromError!=null&&(a.setState(s.getDerivedStateFromError(t)),r=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(t,o||{}),r=a.__d),r)return a.__E=a}catch(C){t=C}throw t}},$u2=0,eV.prototype.setState=function(t,n){var i;i=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=tv({},this.state),typeof t=="function"&&(t=t(tv({},i),this.props)),t&&tv(i,t),t!=null&&this.__v&&(n&&this._sb.push(n),sX(this))},eV.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),sX(this))},eV.prototype.render=aX,wm=[],tA2=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,rX=function(t,n){return t.__v.__b-n.__v.__b},tV.__r=0,rA2=0,function(t){t.Popover="popover",t.API="api",t.Widget="widget"}(nA2||(nA2={})),function(t){t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link"}(iA2||(iA2={})),function(t){t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question"}(oA2||(oA2={})),function(t){t.Once="once",t.Recurring="recurring",t.Always="always"}(aA2||(aA2={})),function(t,n){var i={__c:n="__cC"+rA2++,__:t,Consumer:function(o,a){return o.children(a)},Provider:function(o){var a,s;return this.getChildContext||(a=[],(s={})[n]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(r){this.props.value!==r.value&&a.some(function(C){C.__e=!0,sX(C)})},this.sub=function(r){a.push(r);var C=r.componentWillUnmount;r.componentWillUnmount=function(){a.splice(a.indexOf(r),1),C&&C.call(r)}}),o.children}};i.Provider.__=i.Consumer.contextType=i}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed:()=>{},isPopup:!0,onPreviewSubmit:()=>{}});var Ty=function(t,n){if(!function(i){try{new RegExp(i)}catch{return!1}return!0}(n))return!1;try{return new RegExp(n).test(t)}catch{return!1}};class hA2{constructor(){St(this,"events",{}),this.events={}}on(n,i){return this.events[n]||(this.events[n]=[]),this.events[n].push(i),()=>{this.events[n]=this.events[n].filter(o=>o!==i)}}emit(n,i){for(var o of this.events[n]||[])o(i);for(var a of this.events["*"]||[])a(n,i)}}class Qm{constructor(n){St(this,"_debugEventEmitter",new hA2),St(this,"checkStep",(i,o)=>this.checkStepEvent(i,o)&&this.checkStepUrl(i,o)&&this.checkStepElement(i,o)),St(this,"checkStepEvent",(i,o)=>o==null||!o.event||(i==null?void 0:i.event)===(o==null?void 0:o.event)),this.instance=n,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var n;if(!Mr((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)){var i;(i=this.instance)===null||i===void 0||i._addCaptureHook((o,a)=>{this.on(o,a)})}}register(n){var i,o;if(!Mr((i=this.instance)===null||i===void 0?void 0:i._addCaptureHook)&&(n.forEach(r=>{var C,l;(C=this.actionRegistry)===null||C===void 0||C.add(r),(l=r.steps)===null||l===void 0||l.forEach(e=>{var u;(u=this.actionEvents)===null||u===void 0||u.add((e==null?void 0:e.event)||"")})}),(o=this.instance)!==null&&o!==void 0&&o.autocapture)){var a,s=new Set;n.forEach(r=>{var C;(C=r.steps)===null||C===void 0||C.forEach(l=>{l!=null&&l.selector&&s.add(l==null?void 0:l.selector)})}),(a=this.instance)===null||a===void 0||a.autocapture.setElementSelectors(s)}}on(n,i){var o;i!=null&&n.length!=0&&(this.actionEvents.has(n)||this.actionEvents.has(i==null?void 0:i.event))&&this.actionRegistry&&((o=this.actionRegistry)===null||o===void 0?void 0:o.size)>0&&this.actionRegistry.forEach(a=>{this.checkAction(i,a)&&this._debugEventEmitter.emit("actionCaptured",a.name)})}_addActionHook(n){this.onAction("actionCaptured",i=>n(i))}checkAction(n,i){if((i==null?void 0:i.steps)==null)return!1;for(var o of i.steps)if(this.checkStep(n,o))return!0;return!1}onAction(n,i){return this._debugEventEmitter.on(n,i)}checkStepUrl(n,i){if(i!=null&&i.url){var o,a=n==null||(o=n.properties)===null||o===void 0?void 0:o.$current_url;if(!a||typeof a!="string"||!Qm.matchString(a,i==null?void 0:i.url,(i==null?void 0:i.url_matching)||"contains"))return!1}return!0}static matchString(n,i,o){switch(o){case"regex":return!!p4&&Ty(n,i);case"exact":return i===n;case"contains":var a=Qm.escapeStringRegexp(i).replace(/_/g,".").replace(/%/g,".*");return Ty(n,a);default:return!1}}static escapeStringRegexp(n){return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(n,i){if((i!=null&&i.href||i!=null&&i.tag_name||i!=null&&i.text)&&!this.getElementsList(n).some(s=>!(i!=null&&i.href&&!Qm.matchString(s.href||"",i==null?void 0:i.href,(i==null?void 0:i.href_matching)||"exact"))&&(i==null||!i.tag_name||s.tag_name===(i==null?void 0:i.tag_name))&&!(i!=null&&i.text&&!Qm.matchString(s.text||"",i==null?void 0:i.text,(i==null?void 0:i.text_matching)||"exact")&&!Qm.matchString(s.$el_text||"",i==null?void 0:i.text,(i==null?void 0:i.text_matching)||"exact"))))return!1;if(i!=null&&i.selector){var o,a=n==null||(o=n.properties)===null||o===void 0?void 0:o.$element_selectors;if(!a||!a.includes(i==null?void 0:i.selector))return!1}return!0}getElementsList(n){return(n==null?void 0:n.properties.$elements)==null?[]:n==null?void 0:n.properties.$elements}}class KM{constructor(n){this.instance=n,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(n){var i;Mr((i=this.instance)===null||i===void 0?void 0:i._addCaptureHook)||(this.setupEventBasedSurveys(n),this.setupActionBasedSurveys(n))}setupActionBasedSurveys(n){var i=n.filter(o=>{var a,s,r,C;return((a=o.conditions)===null||a===void 0?void 0:a.actions)&&((s=o.conditions)===null||s===void 0||(r=s.actions)===null||r===void 0||(C=r.values)===null||C===void 0?void 0:C.length)>0});i.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new Qm(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(o=>{this.onAction(o)})),i.forEach(o=>{var a,s,r,C,l,e,u,A,f,d;o.conditions&&(a=o.conditions)!==null&&a!==void 0&&a.actions&&(s=o.conditions)!==null&&s!==void 0&&(r=s.actions)!==null&&r!==void 0&&r.values&&((C=o.conditions)===null||C===void 0||(l=C.actions)===null||l===void 0||(e=l.values)===null||e===void 0?void 0:e.length)>0&&((u=this.actionMatcher)===null||u===void 0||u.register(o.conditions.actions.values),(A=o.conditions)===null||A===void 0||(f=A.actions)===null||f===void 0||(d=f.values)===null||d===void 0||d.forEach(g=>{if(g&&g.name){var E=this.actionToSurveys.get(g.name);E&&E.push(o.id),this.actionToSurveys.set(g.name,E||[o.id])}}))}))}setupEventBasedSurveys(n){var i;n.filter(o=>{var a,s,r,C;return((a=o.conditions)===null||a===void 0?void 0:a.events)&&((s=o.conditions)===null||s===void 0||(r=s.events)===null||r===void 0||(C=r.values)===null||C===void 0?void 0:C.length)>0}).length!==0&&((i=this.instance)===null||i===void 0||i._addCaptureHook((o,a)=>{this.onEvent(o,a)}),n.forEach(o=>{var a,s,r;(a=o.conditions)===null||a===void 0||(s=a.events)===null||s===void 0||(r=s.values)===null||r===void 0||r.forEach(C=>{if(C&&C.name){var l=this.eventToSurveys.get(C.name);l&&l.push(o.id),this.eventToSurveys.set(C.name,l||[o.id])}})}))}onEvent(n,i){var o,a,s=((o=this.instance)===null||o===void 0||(a=o.persistence)===null||a===void 0?void 0:a.props[HS])||[];if(KM.SURVEY_SHOWN_EVENT_NAME==n&&i&&s.length>0){var r,C=i==null||(r=i.properties)===null||r===void 0?void 0:r.$survey_id;if(C){var l=s.indexOf(C);l>=0&&(s.splice(l,1),this._updateActivatedSurveys(s))}}else this.eventToSurveys.has(n)&&this._updateActivatedSurveys(s.concat(this.eventToSurveys.get(n)||[]))}onAction(n){var i,o,a=((i=this.instance)===null||i===void 0||(o=i.persistence)===null||o===void 0?void 0:o.props[HS])||[];this.actionToSurveys.has(n)&&this._updateActivatedSurveys(a.concat(this.actionToSurveys.get(n)||[]))}_updateActivatedSurveys(n){var i,o;(i=this.instance)===null||i===void 0||(o=i.persistence)===null||o===void 0||o.register({[HS]:[...new Set(n)]})}getSurveys(){var n,i,o=(n=this.instance)===null||n===void 0||(i=n.persistence)===null||i===void 0?void 0:i.props[HS];return o||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}St(KM,"SURVEY_SHOWN_EVENT_NAME","survey shown");var AA=PA("[Surveys]"),EA2={icontains:(t,n)=>t.some(i=>n.toLowerCase().includes(i.toLowerCase())),not_icontains:(t,n)=>t.every(i=>!n.toLowerCase().includes(i.toLowerCase())),regex:(t,n)=>t.some(i=>Ty(n,i)),not_regex:(t,n)=>t.every(i=>!Ty(n,i)),exact:(t,n)=>t.some(i=>n===i),is_not:(t,n)=>t.every(i=>n!==i)};function pA2(t){return t??"icontains"}class B10{constructor(n){St(this,"_isFetchingSurveys",!1),St(this,"_isInitializingSurveys",!1),St(this,"_surveyCallbacks",[]),this.instance=n,this._surveyEventReceiver=null}onRemoteConfig(n){var i=n.surveys;if(ll(i))return AA.warn("Decide not loaded yet. Not loading surveys.");var o=_l(i);this._hasSurveys=o?i.length>0:i,AA.info("decide response received, hasSurveys: ".concat(this._hasSurveys)),this._hasSurveys&&this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var n=(()=>{for(var i=[],o=0;o<localStorage.length;o++){var a=localStorage.key(o);a!=null&&a.startsWith("seenSurvey_")&&i.push(a)}return i})();n.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)AA.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)AA.info("Disabled. Not loading surveys.");else{var n=zs==null?void 0:zs.__PosthogExtensions__;if(n)if(this._hasSurveys){this._isInitializingSurveys=!0;try{var i=n.generateSurveys;if(i)this._surveyManager=i(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new KM(this.instance),AA.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0});else{var o=n.loadExternalDependency;if(o)o(this.instance,"surveys",s=>{if(s||!n.generateSurveys)return AA.error("Could not load surveys script",s),void(this._isInitializingSurveys=!1);this._surveyManager=n.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new KM(this.instance),AA.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var a="PostHog loadExternalDependency extension not found. Cannot load remote config.";AA.error(a),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:a})}}}catch(s){throw AA.error("Error initializing surveys",s),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),s}}else AA.info("No surveys to load.");else AA.error("PostHog Extensions not found.")}}onSurveysLoaded(n){return this._surveyCallbacks.push(n),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(i=>i!==n)}}getSurveys(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return AA.info("Disabled. Not loading surveys."),n([]);var o=this.instance.get_property(g_);if(o&&!i)return n(o,{isLoaded:!0});if(this._isFetchingSurveys)return n([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",timeout:this.instance.config.surveys_request_timeout_ms,callback:a=>{var s;this._isFetchingSurveys=!1;var r=a.statusCode;if(r!==200||!a.json){var C="Surveys API could not be loaded, status: ".concat(r);return AA.error(C),n([],{isLoaded:!1,error:C})}var l,e=a.json.surveys||[],u=e.filter(A=>{var f,d,g,E,y,Q,R,D,O,k,J,e2;return((f=A.conditions)===null||f===void 0?void 0:f.events)&&((d=A.conditions)===null||d===void 0||(g=d.events)===null||g===void 0?void 0:g.values)&&((E=A.conditions)===null||E===void 0||(y=E.events)===null||y===void 0||(Q=y.values)===null||Q===void 0?void 0:Q.length)>0||((R=A.conditions)===null||R===void 0?void 0:R.actions)&&((D=A.conditions)===null||D===void 0||(O=D.actions)===null||O===void 0?void 0:O.values)&&((k=A.conditions)===null||k===void 0||(J=k.actions)===null||J===void 0||(e2=J.values)===null||e2===void 0?void 0:e2.length)>0});return u.length>0&&((l=this._surveyEventReceiver)===null||l===void 0||l.register(u)),(s=this.instance.persistence)===null||s===void 0||s.register({[g_]:e}),n(e,{isLoaded:!0})}})}catch(a){throw this._isFetchingSurveys=!1,a}}_notifySurveyCallbacks(n){for(var i of this._surveyCallbacks)try{n.isLoaded?this.getSurveys(i):i([],n)}catch(o){AA.error("Error in survey callback",o)}}isSurveyFeatureFlagEnabled(n){return!n||this.instance.featureFlags.isFeatureEnabled(n)}getActiveMatchingSurveys(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(o=>{var a,s=o.filter(l=>!(!l.start_date||l.end_date)).filter(l=>{var e;if(!l.conditions)return!0;var u=function(d){var g,E,y;if((g=d.conditions)===null||g===void 0||!g.url)return!0;var Q=p4==null||(E=p4.location)===null||E===void 0?void 0:E.href;if(!Q)return!1;var R=[d.conditions.url];return EA2[pA2((y=d.conditions)===null||y===void 0?void 0:y.urlMatchType)](R,Q)}(l),A=(e=l.conditions)===null||e===void 0||!e.selector||(Fn==null?void 0:Fn.querySelector(l.conditions.selector)),f=function(d){var g,E,y;if((g=d.conditions)===null||g===void 0||!g.deviceTypes||((E=d.conditions)===null||E===void 0?void 0:E.deviceTypes.length)===0)return!0;if(!vu)return!1;var Q=Sl.deviceType(vu);return EA2[pA2((y=d.conditions)===null||y===void 0?void 0:y.deviceTypesMatchType)](d.conditions.deviceTypes,Q)}(l);return u&&A&&f}),r=(a=this._surveyEventReceiver)===null||a===void 0?void 0:a.getSurveys(),C=s.filter(l=>{var e,u,A,f,d,g,E,y,Q;if(!(l.linked_flag_key||l.targeting_flag_key||l.internal_targeting_flag_key||(e=l.feature_flag_keys)!==null&&e!==void 0&&e.length))return!0;var R=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),D=this.isSurveyFeatureFlagEnabled(l.targeting_flag_key),O=((u=(A=l.conditions)===null||A===void 0||(f=A.events)===null||f===void 0||(d=f.values)===null||d===void 0?void 0:d.length)!==null&&u!==void 0?u:0)>0,k=((g=(E=l.conditions)===null||E===void 0||(y=E.actions)===null||y===void 0||(Q=y.values)===null||Q===void 0?void 0:Q.length)!==null&&g!==void 0?g:0)>0,J=!O&&!k||(r==null?void 0:r.includes(l.id)),e2=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),p2=this.checkFlags(l);return R&&D&&e2&&J&&p2});return n(C)},i)}checkFlags(n){var i;return(i=n.feature_flag_keys)===null||i===void 0||!i.length||n.feature_flag_keys.every(o=>{var{key:a,value:s}=o;return!a||!s||this.instance.featureFlags.isFeatureEnabled(s)})}_canActivateRepeatedly(n){var i;return ll((i=zs.__PosthogExtensions__)===null||i===void 0?void 0:i.canActivateRepeatedly)?(AA.warn("init was not called"),!1):zs.__PosthogExtensions__.canActivateRepeatedly(n)}canRenderSurvey(n){ll(this._surveyManager)?AA.warn("init was not called"):this.getSurveys(i=>{var o=i.filter(a=>a.id===n)[0];this._surveyManager.canRenderSurvey(o)})}renderSurvey(n,i){ll(this._surveyManager)?AA.warn("init was not called"):this.getSurveys(o=>{var a=o.filter(s=>s.id===n)[0];this._surveyManager.renderSurvey(a,Fn==null?void 0:Fn.querySelector(i))})}}var vA2=PA("[RateLimiter]");class y10{constructor(n){var i,o;St(this,"serverLimits",{}),St(this,"lastEventRateLimited",!1),St(this,"checkForLimiting",a=>{var s=a.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(r=>{vA2.info("".concat(r||"events"," is quota limited.")),this.serverLimits[r]=new Date().getTime()+6e4})}catch(r){return void vA2.warn('could not rate limit - continuing. Error: "'.concat(r==null?void 0:r.message,'"'),{text:s})}}),this.instance=n,this.captureEventsPerSecond=((i=n.config.rate_limiting)===null||i===void 0?void 0:i.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((o=n.config.rate_limiting)===null||o===void 0?void 0:o.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var n,i,o,a=arguments.length>0&&arguments[0]!==void 0&&arguments[0],s=new Date().getTime(),r=(n=(i=this.instance.persistence)===null||i===void 0?void 0:i.get_property(E_))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:s};r.tokens+=(s-r.last)/1e3*this.captureEventsPerSecond,r.last=s,r.tokens>this.captureEventsBurstLimit&&(r.tokens=this.captureEventsBurstLimit);var C=r.tokens<1;return C||a||(r.tokens=Math.max(0,r.tokens-1)),!C||this.lastEventRateLimited||a||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=C,(o=this.instance.persistence)===null||o===void 0||o.set_property(E_,r),{isRateLimited:C,remainingTokens:r.tokens}}isServerRateLimited(n){var i=this.serverLimits[n||"events"]||!1;return i!==!1&&new Date().getTime()<i}}var Mm=PA("[RemoteConfig]");class L10{constructor(n){this.instance=n}get remoteConfig(){var n,i;return(n=zs._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(i=n[this.instance.config.token])===null||i===void 0?void 0:i.config}_loadRemoteConfigJs(n){var i,o,a;(i=zs.__PosthogExtensions__)!==null&&i!==void 0&&i.loadExternalDependency?(o=zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"remote-config",()=>n(this.remoteConfig)):(Mm.error("PostHog Extensions not found. Cannot load remote config."),n())}_loadRemoteConfigJSON(n){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:i=>{n(i.json)}})}load(){try{if(this.remoteConfig)return Mm.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void Mm.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(n=>{if(!n)return Mm.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(i=>{this.onRemoteConfig(i)});this.onRemoteConfig(n)})}catch(n){Mm.error("Error loading remote config",n)}}onRemoteConfig(n){n?this.instance.config.__preview_remote_config?(this.instance._onRemoteConfig(n),n.hasFeatureFlags!==!1&&this.instance.featureFlags.ensureFlagsLoaded()):Mm.info("__preview_remote_config is disabled. Logging config instead",n):Mm.error("Failed to fetch remote config from PostHog.")}}var w10=function(t){var n,i,o,a,s="";for(n=i=0,o=(t=(t+"").replace(/\r\n/g,`
|
|
596
596
|
`).replace(/\r/g,`
|
|
597
|
-
`)).length,a=0;a<o;a++){var r=t.charCodeAt(a),C=null;r<128?i++:C=r>127&&r<2048?String.fromCharCode(r>>6|192,63&r|128):String.fromCharCode(r>>12|224,r>>6&63|128,63&r|128),Xp(C)||(i>n&&(s+=t.substring(n,i)),s+=C,n=i=a+1)}return i>n&&(s+=t.substring(n,t.length)),s},Q10=!!a_||!!o_,IA2="text/plain",nV=(t,n)=>{var[i,o]=t.split("?"),a=S4({},n);o==null||o.split("&").forEach(r=>{var[C]=r.split("=");delete a[C]});var s=e00(a);return s=s?(o?o+"&":"")+s:o,"".concat(i,"?").concat(s)},JM=(t,n)=>JSON.stringify(t,(i,o)=>typeof o=="bigint"?o.toString():o,n),uX=t=>{var{data:n,compression:i}=t;if(n){if(i===tg.GZipJS){var o=vu2(Iu2(JM(n)),{mtime:0}),a=new Blob([o],{type:IA2});return{contentType:IA2,body:a,estimatedSize:a.size}}if(i===tg.Base64){var s=function(l){var e,u,A,f,d,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",E=0,y=0,Q="",R=[];if(!l)return l;l=w10(l);do e=(d=l.charCodeAt(E++)<<16|l.charCodeAt(E++)<<8|l.charCodeAt(E++))>>18&63,u=d>>12&63,A=d>>6&63,f=63&d,R[y++]=g.charAt(e)+g.charAt(u)+g.charAt(A)+g.charAt(f);while(E<l.length);switch(Q=R.join(""),l.length%3){case 1:Q=Q.slice(0,-2)+"==";break;case 2:Q=Q.slice(0,-1)+"="}return Q}(JM(n)),r=(l=>"data="+encodeURIComponent(typeof l=="string"?l:JM(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var C=JM(n);return{contentType:"application/json",body:C,estimatedSize:new Blob([C]).size}}},qM=[];o_&&qM.push({transport:"fetch",method:t=>{var n,i,{contentType:o,body:a,estimatedSize:s}=(n=uX(t))!==null&&n!==void 0?n:{},r=new Headers;cl(t.headers,function(u,A){r.append(A,u)}),o&&r.append("Content-Type",o);var C=t.url,l=null;if(fl2){var e=new fl2;l={signal:e.signal,timeout:setTimeout(()=>e.abort(),t.timeout)}}o_(C,S4({method:(t==null?void 0:t.method)||"GET",headers:r,keepalive:t.method==="POST"&&(s||0)<52428.8,body:a,signal:(i=l)===null||i===void 0?void 0:i.signal},t.fetchOptions)).then(u=>u.text().then(A=>{var f,d={statusCode:u.status,text:A};if(u.status===200)try{d.json=JSON.parse(A)}catch(g){Wi.error(g)}(f=t.callback)===null||f===void 0||f.call(t,d)})).catch(u=>{var A;Wi.error(u),(A=t.callback)===null||A===void 0||A.call(t,{statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),a_&&qM.push({transport:"XHR",method:t=>{var n,i=new a_;i.open(t.method||"GET",t.url,!0);var{contentType:o,body:a}=(n=uX(t))!==null&&n!==void 0?n:{};cl(t.headers,function(s,r){i.setRequestHeader(r,s)}),o&&i.setRequestHeader("Content-Type",o),t.timeout&&(i.timeout=t.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(i.readyState===4){var s,r={statusCode:i.status,text:i.responseText};if(i.status===200)try{r.json=JSON.parse(i.responseText)}catch{}(s=t.callback)===null||s===void 0||s.call(t,r)}},i.send(a)}}),Bf!=null&&Bf.sendBeacon&&qM.push({transport:"sendBeacon",method:t=>{var n=nV(t.url,{beacon:"1"});try{var i,{contentType:o,body:a}=(i=uX(t))!==null&&i!==void 0?i:{},s=typeof a=="string"?new Blob([a],{type:o}):a;Bf.sendBeacon(n,s)}catch{}}});var AX=3e3;class M10{constructor(n,i){St(this,"isPaused",!0),St(this,"queue",[]),this.flushTimeoutMs=fd((i==null?void 0:i.flush_interval_ms)||AX,250,5e3,"flush interval",AX),this.sendRequest=n}enqueue(n){this.queue.push(n),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var n=this.queue.length>0?this.formatQueue():{},i=Object.values(n),o=[...i.filter(a=>a.url.indexOf("/e")===0),...i.filter(a=>a.url.indexOf("/e")!==0)];o.map(a=>{this.sendRequest(S4(S4({},a),{},{transport:"sendBeacon"}))})}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var n=this;this.isPaused||(this.flushTimeout=setTimeout(()=>{if(this.clearFlushTimeout(),this.queue.length>0){var i=this.formatQueue(),o=function(s){var r=i[s],C=new Date().getTime();r.data&&_l(r.data)&&cl(r.data,l=>{l.offset=Math.abs(l.timestamp-C),delete l.timestamp}),n.sendRequest(r)};for(var a in i)o(a)}},this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var n={};return cl(this.queue,i=>{var o,a=i,s=(a?a.batchKey:null)||a.url;Mr(n[s])&&(n[s]=S4(S4({},a),{},{data:[]})),(o=n[s].data)===null||o===void 0||o.push(a.data)}),this.queue=[],n}}var T10=["retriesPerformedSoFar"];class x10{constructor(n){St(this,"isPolling",!1),St(this,"pollIntervalMs",3e3),St(this,"queue",[]),this.instance=n,this.queue=[],this.areWeOnline=!0,!Mr(p4)&&"onLine"in p4.navigator&&(this.areWeOnline=p4.navigator.onLine,su(p4,"online",()=>{this.areWeOnline=!0,this.flush()}),su(p4,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(n){var{retriesPerformedSoFar:i}=n,o=vl2(n,T10);Ac(i)&&i>0&&(o.url=nV(o.url,{retry_count:i})),this.instance._send_request(S4(S4({},o),{},{callback:a=>{var s;a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(i??0)<10?this.enqueue(S4({retriesPerformedSoFar:i},o)):(s=o.callback)===null||s===void 0||s.call(o,a)}}))}enqueue(n){var i=n.retriesPerformedSoFar||0;n.retriesPerformedSoFar=i+1;var o=function(r){var C=3e3*Math.pow(2,r),l=C/2,e=Math.min(18e5,C),u=(Math.random()-.5)*(e-l);return Math.ceil(e+u)}(i),a=Date.now()+o;this.queue.push({retryAt:a,requestOptions:n});var s="Enqueued failed request for retry in ".concat(o);navigator.onLine||(s+=" (Browser is offline)"),Wi.warn(s),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout(()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()},this.pollIntervalMs)}flush(){var n=Date.now(),i=[],o=this.queue.filter(s=>s.retryAt<n||(i.push(s),!1));if(this.queue=i,o.length>0)for(var{requestOptions:a}of o)this.retriableRequest(a)}unload(){for(var{requestOptions:n}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(S4(S4({},n),{},{transport:"sendBeacon"}))}catch(i){Wi.error(i)}this.queue=[]}}class R10{constructor(n){St(this,"_updateScrollData",()=>{var i,o,a,s;this.context||(this.context={});var r=this.scrollElement(),C=this.scrollY(),l=r?Math.max(0,r.scrollHeight-r.clientHeight):0,e=C+((r==null?void 0:r.clientHeight)||0),u=(r==null?void 0:r.scrollHeight)||0;this.context.lastScrollY=Math.ceil(C),this.context.maxScrollY=Math.max(C,(i=this.context.maxScrollY)!==null&&i!==void 0?i:0),this.context.maxScrollHeight=Math.max(l,(o=this.context.maxScrollHeight)!==null&&o!==void 0?o:0),this.context.lastContentY=e,this.context.maxContentY=Math.max(e,(a=this.context.maxContentY)!==null&&a!==void 0?a:0),this.context.maxContentHeight=Math.max(u,(s=this.context.maxContentHeight)!==null&&s!==void 0?s:0)}),this.instance=n}getContext(){return this.context}resetContext(){var n=this.context;return setTimeout(this._updateScrollData,0),n}startMeasuringScrollPosition(){su(p4,"scroll",this._updateScrollData,{capture:!0}),su(p4,"scrollend",this._updateScrollData,{capture:!0}),su(p4,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return p4==null?void 0:p4.document.documentElement;var n=_l(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var i of n){var o=p4==null?void 0:p4.document.querySelector(i);if(o)return o}}scrollY(){if(this.instance.config.scroll_root_selector){var n=this.scrollElement();return n&&n.scrollTop||0}return p4&&(p4.scrollY||p4.pageYOffset||p4.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var n=this.scrollElement();return n&&n.scrollLeft||0}return p4&&(p4.scrollX||p4.pageXOffset||p4.document.documentElement.scrollLeft)||0}}var H10=t=>Sl.personInfo({maskPersonalDataProperties:t==null?void 0:t.config.mask_personal_data_properties,customPersonalDataProperties:t==null?void 0:t.config.custom_personal_data_properties});class D10{constructor(n,i,o,a){St(this,"_onSessionIdCallback",s=>{var r=this._getStored();if(!r||r.sessionId!==s){var C={sessionId:s,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[h_]:C})}}),this.instance=n,this._sessionIdManager=i,this._persistence=o,this._sessionSourceParamGenerator=a||H10,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[h_]}getSetOnceProps(){var n,i=(n=this._getStored())===null||n===void 0?void 0:n.props;return i?"r"in i?Sl.personPropsFromInfo(i):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var n={};return cl(NM(this.getSetOnceProps()),(i,o)=>{o==="$current_url"&&(o="url"),n["$session_entry_".concat(C_(o))]=i}),n}}var mA2=PA("[SessionId]");class N10{constructor(n,i,o){var a;if(St(this,"_sessionIdChangedHandlers",[]),!n.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(n.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.config=n.config,this.persistence=n.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=i||$p,this._windowIdGenerator=o||$p;var s=this.config.persistence_name||this.config.token,r=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*fd(r,60,36e3,"session_idle_timeout_seconds",1800),n.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var C=uA.parse(this._window_id_storage_key),l=uA.parse(this._primary_window_exists_storage_key);C&&!l?this._windowId=C:uA.remove(this._window_id_storage_key),uA.set(this._primary_window_exists_storage_key,!0)}if((a=this.config.bootstrap)!==null&&a!==void 0&&a.sessionID)try{var e=(u=>{var A=u.replace(/-/g,"");if(A.length!==32)throw new Error("Not a valid UUID");if(A[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(A.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,new Date().getTime(),e)}catch(u){mA2.error("Invalid sessionID in bootstrap",u)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(n){return Mr(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(n),this._sessionId&&n(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(i=>i!==n)}}_canUseSessionStorage(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&uA.is_supported()}_setWindowId(n){n!==this._windowId&&(this._windowId=n,this._canUseSessionStorage()&&uA.set(this._window_id_storage_key,n))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?uA.parse(this._window_id_storage_key):null}_setSessionId(n,i,o){n===this._sessionId&&i===this._sessionActivityTimestamp&&o===this._sessionStartTimestamp||(this._sessionStartTimestamp=o,this._sessionActivityTimestamp=i,this._sessionId=n,this.persistence.register({[xS]:[i,n,o]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var n=this.persistence.props[xS];return _l(n)&&n.length===2&&n.push(n[0]),n||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){su(p4,"beforeunload",()=>{this._canUseSessionStorage()&&uA.remove(this._primary_window_exists_storage_key)},{capture:!1})}checkAndGetSessionAndWindowId(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.config.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var o=i||new Date().getTime(),[a,s,r]=this._getSessionId(),C=this._getWindowId(),l=Ac(r)&&r>0&&Math.abs(o-r)>864e5,e=!1,u=!s,A=!n&&Math.abs(o-a)>this.sessionTimeoutMs;u||A||l?(s=this._sessionIdGenerator(),C=this._windowIdGenerator(),mA2.info("new session ID generated",{sessionId:s,windowId:C,changeReason:{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}}),r=o,e=!0):C||(C=this._windowIdGenerator(),e=!0);var f=a===0||!n||l?o:a,d=r===0?new Date().getTime():r;return this._setWindowId(C),this._setSessionId(s,f,d),n||this.resetIdleTimer(),e&&this._sessionIdChangedHandlers.forEach(g=>g(s,C,e?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0)),{sessionId:s,windowId:C,sessionStartTimestamp:d,changeReason:e?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:a}}resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{this.resetSessionId()},1.1*this.sessionTimeoutMs)}}var S10=["$set_once","$set"],rv=PA("[SiteApps]");class V10{constructor(n){this.instance=n,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(n,i){if(i){var o=this.globalsForEvent(i);this.bufferedInvocations.push(o),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var n,i;return(n=zs._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(i=n[this.instance.config.token])===null||i===void 0?void 0:i.siteApps}init(){if(this.isEnabled){var n=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{n(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(n){var i,o,a,s,r,C,l;if(!n)throw new Error("Event payload is required");var e={},u=this.instance.get_property("$groups")||[],A=this.instance.get_property("$stored_group_properties")||{};for(var[f,d]of Object.entries(A))e[f]={id:u[f],type:f,properties:d};var{$set_once:g,$set:E}=n;return{event:S4(S4({},vl2(n,S10)),{},{properties:S4(S4(S4({},n.properties),E?{$set:S4(S4({},(i=(o=n.properties)===null||o===void 0?void 0:o.$set)!==null&&i!==void 0?i:{}),E)}:{}),g?{$set_once:S4(S4({},(a=(s=n.properties)===null||s===void 0?void 0:s.$set_once)!==null&&a!==void 0?a:{}),g)}:{}),elements_chain:(r=(C=n.properties)===null||C===void 0?void 0:C.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(l=n.properties)===null||l===void 0?void 0:l.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:e}}setupSiteApp(n){var i=this.apps[n.id],o=()=>{var C;!i.errored&&this.bufferedInvocations.length&&(rv.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(n.id)),this.bufferedInvocations.forEach(l=>{var e;return(e=i.processEvent)===null||e===void 0?void 0:e.call(i,l)}),i.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((C=this.stopBuffering)===null||C===void 0||C.call(this))},a=!1,s=C=>{i.errored=!C,i.loaded=!0,rv.info("Site app with id ".concat(n.id," ").concat(C?"loaded":"errored")),a&&o()};try{var{processEvent:r}=n.init({posthog:this.instance,callback:C=>{s(C)}});r&&(i.processEvent=r),a=!0}catch(C){rv.error("Error while initializing PostHog app with config id ".concat(n.id),C),s(!1)}if(a&&i.loaded)try{o()}catch(C){rv.error("Error while processing buffered events PostHog app with config id ".concat(n.id),C),i.errored=!0}}setupSiteApps(){var n=this.siteAppLoaders||[];for(var i of n)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var o of n)this.setupSiteApp(o)}onCapturedEvent(n){if(Object.keys(this.apps).length!==0){var i=this.globalsForEvent(n);for(var o of Object.values(this.apps))try{var a;(a=o.processEvent)===null||a===void 0||a.call(o,i)}catch(s){rv.error("Error while processing event ".concat(n.event," for site app ").concat(o.id),s)}}}onRemoteConfig(n){var i,o,a,s=this;if((i=this.siteAppLoaders)!==null&&i!==void 0&&i.length)return this.isEnabled?(this.setupSiteApps(),void this.instance.on("eventCaptured",e=>this.onCapturedEvent(e))):void rv.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((o=this.stopBuffering)===null||o===void 0||o.call(this),(a=n.siteApps)!==null&&a!==void 0&&a.length)if(this.isEnabled){var r=function(e,u){var A,f;zs["__$$ph_site_app_".concat(e)]=s.instance,(A=zs.__PosthogExtensions__)===null||A===void 0||(f=A.loadSiteApp)===null||f===void 0||f.call(A,s.instance,u,d=>{if(d)return rv.error("Error while initializing PostHog app with config id ".concat(e),d)})};for(var{id:C,url:l}of n.siteApps)r(C,l)}else rv.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var Tm,k10=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","bytespider"],bA2=function(t,n){if(!t)return!1;var i=t.toLowerCase();return k10.concat(n||[]).some(o=>{var a=o.toLowerCase();return i.indexOf(a)!==-1})},BA2=function(t,n){if(!t)return!1;var i=t.userAgent;if(i&&bA2(i,n))return!0;try{var o=t==null?void 0:t.userAgentData;if(o!=null&&o.brands&&o.brands.some(a=>bA2(a==null?void 0:a.brand,n)))return!0}catch{}return!!t.webdriver};function cX(t,n,i){return JM({distinct_id:t,userPropertiesToSet:n,userPropertiesToSetOnce:i})}(function(t){t.US="us",t.EU="eu",t.CUSTOM="custom"})(Tm||(Tm={}));var yA2="i.posthog.com";class O10{constructor(n){St(this,"_regionCache",{}),this.instance=n}get apiHost(){var n=this.instance.config.api_host.trim().replace(/\/$/,"");return n==="https://app.posthog.com"?"https://us.i.posthog.com":n}get uiHost(){var n,i=(n=this.instance.config.ui_host)===null||n===void 0?void 0:n.replace(/\/$/,"");return i||(i=this.apiHost.replace(".".concat(yA2),".posthog.com")),i==="https://app.posthog.com"?"https://us.posthog.com":i}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=Tm.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=Tm.EU:this._regionCache[this.apiHost]=Tm.CUSTOM),this._regionCache[this.apiHost]}endpointFor(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(i&&(i=i[0]==="/"?i:"/".concat(i)),n==="ui")return this.uiHost+i;if(this.region===Tm.CUSTOM)return this.apiHost+i;var o=yA2+i;switch(n){case"assets":return"https://".concat(this.region,"-assets.").concat(o);case"api":return"https://".concat(this.region,".").concat(o)}}}var P10={icontains:(t,n)=>!!p4&&n.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,n)=>!!p4&&n.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,n)=>!!p4&&Ty(n.href,t),not_regex:(t,n)=>!!p4&&!Ty(n.href,t),exact:(t,n)=>n.href===t,is_not:(t,n)=>n.href!==t};class FA{constructor(n){var i=this;St(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var o=arguments.length>0&&arguments[0]!==void 0&&arguments[0];i.getWebExperiments(a=>{FA.logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,a.forEach(s=>{if(s.feature_flag_key){var r;i._flagToExperiments&&(FA.logInfo("setting flag key ",s.feature_flag_key," to web experiment ",s),(r=i._flagToExperiments)===null||r===void 0||r.set(s.feature_flag_key,s));var C=i.instance.getFeatureFlag(s.feature_flag_key);Iu(C)&&s.variants[C]&&i.applyTransforms(s.name,C,s.variants[C].transforms)}else if(s.variants)for(var l in s.variants){var e=s.variants[l];FA.matchesTestVariant(e)&&i.applyTransforms(s.name,l,e.transforms)}})},o)}),this.instance=n,this.instance.onFeatureFlags(o=>{this.onFeatureFlags(o)})}onFeatureFlags(n){if(this._is_bot())FA.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(ll(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();FA.logInfo("applying feature flags",n),n.forEach(i=>{var o;if(this._flagToExperiments&&(o=this._flagToExperiments)!==null&&o!==void 0&&o.has(i)){var a,s=this.instance.getFeatureFlag(i),r=(a=this._flagToExperiments)===null||a===void 0?void 0:a.get(i);s&&r!=null&&r.variants[s]&&this.applyTransforms(r.name,s,r.variants[s].transforms)}})}}previewWebExperiment(){var n=FA.getWindowLocation();if(n!=null&&n.search){var i=OS(n==null?void 0:n.search,"__experiment_id"),o=OS(n==null?void 0:n.search,"__experiment_variant");i&&o&&(FA.logInfo("previewing web experiments ".concat(i," && ").concat(o)),this.getWebExperiments(a=>{this.showPreviewWebExperiment(parseInt(i),o,a)},!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(n,i,o){if(this.instance.config.disable_web_experiments&&!o)return n([]);var a=this.instance.get_property("$web_experiments");if(a&&!i)return n(a);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return n([]);var r=s.json.experiments||[];return n(r)}})}showPreviewWebExperiment(n,i,o){var a=o.filter(s=>s.id===n);a&&a.length>0&&(FA.logInfo("Previewing web experiment [".concat(a[0].name,"] with variant [").concat(i,"]")),this.applyTransforms(a[0].name,i,a[0].variants[i].transforms))}static matchesTestVariant(n){return!ll(n.conditions)&&FA.matchUrlConditions(n)&&FA.matchUTMConditions(n)}static matchUrlConditions(n){var i;if(ll(n.conditions)||ll((i=n.conditions)===null||i===void 0?void 0:i.url))return!0;var o,a,s,r=FA.getWindowLocation();return!!r&&((o=n.conditions)===null||o===void 0||!o.url||P10[(a=(s=n.conditions)===null||s===void 0?void 0:s.urlMatchType)!==null&&a!==void 0?a:"icontains"](n.conditions.url,r))}static getWindowLocation(){return p4==null?void 0:p4.location}static matchUTMConditions(n){var i;if(ll(n.conditions)||ll((i=n.conditions)===null||i===void 0?void 0:i.utm))return!0;var o=Sl.campaignParams();if(o.utm_source){var a,s,r,C,l,e,u,A,f,d,g,E,y,Q,R,D,O=(a=n.conditions)===null||a===void 0||(s=a.utm)===null||s===void 0||!s.utm_campaign||((r=n.conditions)===null||r===void 0||(C=r.utm)===null||C===void 0?void 0:C.utm_campaign)==o.utm_campaign,k=(l=n.conditions)===null||l===void 0||(e=l.utm)===null||e===void 0||!e.utm_source||((u=n.conditions)===null||u===void 0||(A=u.utm)===null||A===void 0?void 0:A.utm_source)==o.utm_source,J=(f=n.conditions)===null||f===void 0||(d=f.utm)===null||d===void 0||!d.utm_medium||((g=n.conditions)===null||g===void 0||(E=g.utm)===null||E===void 0?void 0:E.utm_medium)==o.utm_medium,e2=(y=n.conditions)===null||y===void 0||(Q=y.utm)===null||Q===void 0||!Q.utm_term||((R=n.conditions)===null||R===void 0||(D=R.utm)===null||D===void 0?void 0:D.utm_term)==o.utm_term;return O&&J&&e2&&k}return!1}static logInfo(n){for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];Wi.info("[WebExperiments] ".concat(n),o)}applyTransforms(n,i,o){this._is_bot()?FA.logInfo("Refusing to render web experiment since the viewer is a likely bot"):i!=="control"?o.forEach(a=>{if(a.selector){var s;FA.logInfo("applying transform of variant ".concat(i," for experiment ").concat(n," "),a);var r=(s=document)===null||s===void 0?void 0:s.querySelectorAll(a.selector);r==null||r.forEach(C=>{var l=C;a.html&&(l.innerHTML=a.html),a.css&&l.setAttribute("style",a.css)})}}):FA.logInfo("Control variants leave the page unmodified.")}_is_bot(){return Bf&&this.instance?BA2(Bf,this.instance.config.custom_blocked_useragents):void 0}}var $M={},fX=()=>{},xy="posthog",LA2=!Q10&&(vu==null?void 0:vu.indexOf("MSIE"))===-1&&(vu==null?void 0:vu.indexOf("Mozilla"))===-1,wA2=()=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:z20(Fn==null?void 0:Fn.location),persistence:"localStorage+cookie",persistence_name:"",loaded:fX,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:cd&&Iu(cd==null?void 0:cd.search)&&cd.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(p4==null||(t=p4.location)===null||t===void 0?void 0:t.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var i="Bad HTTP status: "+n.statusCode+" "+n.text;Wi.error(i)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:AX},_onCapture:fX}},QA2=t=>{var n={};Mr(t.process_person)||(n.person_profiles=t.process_person),Mr(t.xhr_headers)||(n.request_headers=t.xhr_headers),Mr(t.cookie_name)||(n.persistence_name=t.cookie_name),Mr(t.disable_cookie)||(n.disable_persistence=t.disable_cookie),Mr(t.store_google)||(n.save_campaign_params=t.store_google),Mr(t.verbose)||(n.debug=t.verbose);var i=mu({},n,t);return _l(t.property_blacklist)&&(Mr(t.property_denylist)?i.property_denylist=t.property_blacklist:_l(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:Wi.error("Invalid value for property_denylist config: "+t.property_denylist)),i};class Z10{constructor(){St(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(n){Wi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=n}}class iV{get decideEndpointWasHit(){var n,i;return(n=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&n!==void 0&&n}constructor(){St(this,"webPerformance",new Z10),St(this,"_personProcessingSetOncePropertiesSent",!1),St(this,"version",pE.LIB_VERSION),St(this,"_internalEventEmitter",new hA2),this.config=wA2(),this.SentryIntegration=_00,this.sentryIntegration=n=>function(i,o){var a=Lu2(i,o);return{name:yu2,processEvent:s=>a(s)}}(this,n),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this._cachedIdentify=null,this.featureFlags=new g10(this),this.toolbar=new K00(this),this.scrollManager=new R10(this),this.pageViewManager=new r10(this),this.surveys=new B10(this),this.experiments=new FA(this),this.exceptions=new n10(this),this.rateLimiter=new y10(this),this.requestRouter=new O10(this),this.consent=new f00(this),this.people={set:(n,i,o)=>{var a=Iu(n)?{[n]:i}:n;this.setPersonProperties(a),o==null||o({})},set_once:(n,i,o)=>{var a=Iu(n)?{[n]:i}:n;this.setPersonProperties(void 0,a),o==null||o({})}},this.on("eventCaptured",n=>Wi.info('send "'.concat(n==null?void 0:n.event,'"'),n))}init(n,i,o){if(o&&o!==xy){var a,s=(a=$M[o])!==null&&a!==void 0?a:new iV;return s._init(n,i,o),$M[o]=s,$M[xy][o]=s,s}return this._init(n,i,o)}_init(n){var i,o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(Mr(n)||l_(n))return Wi.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return Wi.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],a.person_profiles&&(this._initialPersonProfilesConfig=a.person_profiles),this.set_config(mu({},wA2(),QA2(a),{name:s,token:n})),this.config.on_xhr_error&&Wi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=a.disable_compression?void 0:tg.GZipJS,this.persistence=new tX(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tX(S4(S4({},this.config),{},{persistence:"sessionStorage"}));var r=S4({},this.persistence.props),C=S4({},this.sessionPersistence.props);if(this._requestQueue=new M10(Q=>this._send_retriable_request(Q),this.config.request_queue_config),this._retryQueue=new x10(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new N10(this),this.sessionPropsManager=new D10(this,this.sessionManager,this.persistence)),new q00(this).startIfEnabledOrStop(),this.siteApps=new V10(this),(i=this.siteApps)===null||i===void 0||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new Y00(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new i00(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new t10(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new $00(this),this.exceptionObserver=new h00(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new tu2(this,g00),this.deadClicksAutocapture.startIfEnabled(),pE.DEBUG=pE.DEBUG||this.config.debug,pE.DEBUG&&Wi.info("Starting in debug mode",{this:this,config:a,thisC:S4({},this.config),p:r,s:C}),this._sync_opt_out_with_persistence(),((o=a.bootstrap)===null||o===void 0?void 0:o.distinctID)!==void 0){var l,e,u=this.config.get_device_id($p()),A=(l=a.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?u:a.bootstrap.distinctID;this.persistence.set_property(vE,(e=a.bootstrap)!==null&&e!==void 0&&e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:a.bootstrap.distinctID,$device_id:A})}if(this._hasBootstrappedFeatureFlags()){var f,d,g=Object.keys(((f=a.bootstrap)===null||f===void 0?void 0:f.featureFlags)||{}).filter(Q=>{var R,D;return!((R=a.bootstrap)===null||R===void 0||(D=R.featureFlags)===null||D===void 0||!D[Q])}).reduce((Q,R)=>{var D,O;return Q[R]=((D=a.bootstrap)===null||D===void 0||(O=D.featureFlags)===null||O===void 0?void 0:O[R])||!1,Q},{}),E=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlagPayloads)||{}).filter(Q=>g[Q]).reduce((Q,R)=>{var D,O,k,J;return(D=a.bootstrap)!==null&&D!==void 0&&(O=D.featureFlagPayloads)!==null&&O!==void 0&&O[R]&&(Q[R]=(k=a.bootstrap)===null||k===void 0||(J=k.featureFlagPayloads)===null||J===void 0?void 0:J[R]),Q},{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:E})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Vl2,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id($p());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(vE,"anonymous")}return su(p4,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),a.segment?W00(this,()=>this._loaded()):this._loaded(),rg(this.config._onCapture)&&this.config._onCapture!==fX&&(Wi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",Q=>this.config._onCapture(Q.event,Q))),this}_onRemoteConfig(n){var i,o,a,s,r,C,l,e;if(!Fn||!Fn.body)return Wi.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(n)},500);this.compression=void 0,n.supportedCompression&&!this.config.disable_compression&&(this.compression=lC(n.supportedCompression,tg.GZipJS)?tg.GZipJS:lC(n.supportedCompression,tg.Base64)?tg.Base64:void 0),(i=n.analytics)!==null&&i!==void 0&&i.endpoint&&(this.analyticsDefaultEndpoint=n.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),(o=this.siteApps)===null||o===void 0||o.onRemoteConfig(n),(a=this.sessionRecording)===null||a===void 0||a.onRemoteConfig(n),(s=this.autocapture)===null||s===void 0||s.onRemoteConfig(n),(r=this.heatmaps)===null||r===void 0||r.onRemoteConfig(n),this.surveys.onRemoteConfig(n),(C=this.webVitalsAutocapture)===null||C===void 0||C.onRemoteConfig(n),(l=this.exceptionObserver)===null||l===void 0||l.onRemoteConfig(n),(e=this.deadClicksAutocapture)===null||e===void 0||e.onRemoteConfig(n)}_loaded(){try{this.config.loaded(this)}catch(n){Wi.critical("`loaded` function failed",n)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new L10(this).load(),this.featureFlags.decide()}_start_queue_if_opted_in(){var n;this.has_opted_out_capturing()||this.config.request_batching&&((n=this._requestQueue)===null||n===void 0||n.enable())}_dom_loaded(){this.has_opted_out_capturing()||Jp(this.__request_queue,n=>this._send_retriable_request(n)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var n,i;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),(n=this._requestQueue)===null||n===void 0||n.unload(),(i=this._retryQueue)===null||i===void 0||i.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(n){this.__loaded&&(LA2?this.__request_queue.push(n):this.rateLimiter.isServerRateLimited(n.batchKey)||(n.transport=n.transport||this.config.api_transport,n.url=nV(n.url,{ip:this.config.ip?1:0}),n.headers=S4({},this.config.request_headers),n.compression=n.compression==="best-available"?this.compression:n.compression,n.fetchOptions=n.fetchOptions||this.config.fetch_options,(i=>{var o,a,s,r=S4({},i);r.timeout=r.timeout||6e4,r.url=nV(r.url,{_:new Date().getTime().toString(),ver:pE.LIB_VERSION,compression:r.compression});var C=(o=r.transport)!==null&&o!==void 0?o:"fetch",l=(a=(s=ml2(qM,e=>e.transport===C))===null||s===void 0?void 0:s.method)!==null&&a!==void 0?a:qM[0].method;if(!l)throw new Error("No available transport method");l(r)})(S4(S4({},n),{},{callback:i=>{var o,a,s;this.rateLimiter.checkForLimiting(i),i.statusCode>=400&&((a=(s=this.config).on_request_error)===null||a===void 0||a.call(s,i)),(o=n.callback)===null||o===void 0||o.call(n,i)}}))))}_send_retriable_request(n){this._retryQueue?this._retryQueue.retriableRequest(n):this._send_request(n)}_execute_array(n){var i,o=[],a=[],s=[];Jp(n,C=>{C&&(i=C[0],_l(i)?s.push(C):rg(C)?C.call(this):_l(C)&&i==="alias"?o.push(C):_l(C)&&i.indexOf("capture")!==-1&&rg(this[i])?s.push(C):a.push(C))});var r=function(C,l){Jp(C,function(e){if(_l(e[0])){var u=l;cl(e,function(A){u=u[A[0]].apply(u,A.slice(1))})}else this[e[0]].apply(this,e.slice(1))},l)};r(o,this),r(a,this),r(s,this)}_hasBootstrappedFeatureFlags(){var n,i;return((n=this.config.bootstrap)===null||n===void 0?void 0:n.featureFlags)&&Object.keys((i=this.config.bootstrap)===null||i===void 0?void 0:i.featureFlags).length>0||!1}push(n){this._execute_array([n])}capture(n,i,o){var a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!Mr(n)&&Iu(n)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var s=o!=null&&o.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){i!=null&&i.$current_url&&!Iu(i==null?void 0:i.$current_url)&&(Wi.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),i==null||delete i.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var r=new Date,C=(o==null?void 0:o.timestamp)||r,l=$p(),e={uuid:l,event:n,properties:this._calculate_event_properties(n,i||{},C,l)};s&&(e.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),o!=null&&o.$set&&(e.$set=o==null?void 0:o.$set);var u=this._calculate_set_once_properties(o==null?void 0:o.$set_once);u&&(e.$set_once=u),(e=U20(e,o!=null&&o._noTruncate?null:this.config.properties_string_max_length)).timestamp=C,Mr(o==null?void 0:o.timestamp)||(e.properties.$event_time_override_provided=!0,e.properties.$event_time_override_system_time=r);var A=S4(S4({},e.properties.$set),e.$set);if(py(A)||this.setPersonPropertiesForFlags(A),!ll(this.config.before_send)){var f=this._runBeforeSend(e);if(!f)return;e=f}this._internalEventEmitter.emit("eventCaptured",e);var d={method:"POST",url:(a=o==null?void 0:o._url)!==null&&a!==void 0?a:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:e,compression:"best-available",batchKey:o==null?void 0:o._batchKey};return!this.config.request_batching||o&&(o==null||!o._batchKey)||o!=null&&o.send_instantly?this._send_retriable_request(d):this._requestQueue.enqueue(d),e}Wi.critical("This capture call is ignored due to client rate limiting.")}}else Wi.error("No event name provided to posthog.capture")}else Wi.uninitializedWarning("posthog.capture")}_addCaptureHook(n){return this.on("eventCaptured",i=>n(i.event,i))}_calculate_event_properties(n,i,o,a){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return i;var s=this.persistence.remove_event_timer(n),r=S4({},i);if(r.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(r.$cookieless_mode=!0),n==="$snapshot"){var C=S4(S4({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=C.distinct_id,(!Iu(r.distinct_id)&&!Ac(r.distinct_id)||l_(r.distinct_id))&&Wi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var l,e=Sl.properties({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});if(this.sessionManager){var{sessionId:u,windowId:A}=this.sessionManager.checkAndGetSessionAndWindowId();r.$session_id=u,r.$window_id=A}this.sessionPropsManager&&mu(r,this.sessionPropsManager.getSessionProps());try{var f,d;this.sessionRecording&&(r.$recording_status=this.sessionRecording.status,r.$sdk_debug_replay_internal_buffer_length=this.sessionRecording.buffer.data.length,r.$sdk_debug_replay_internal_buffer_size=this.sessionRecording.buffer.size),r.$sdk_debug_retry_queue_size=(f=this._retryQueue)===null||f===void 0||(d=f.queue)===null||d===void 0?void 0:d.length}catch(Q){r.$sdk_debug_error_capturing_properties=String(Q)}if(this.requestRouter.region===Tm.CUSTOM&&(r.$lib_custom_api_host=this.config.api_host),l=n==="$pageview"?this.pageViewManager.doPageView(o,a):n==="$pageleave"?this.pageViewManager.doPageLeave(o):this.pageViewManager.doEvent(),r=mu(r,l),n==="$pageview"&&Fn&&(r.title=Fn.title),!Mr(s)){var g=o.getTime()-s;r.$duration=parseFloat((g/1e3).toFixed(3))}vu&&this.config.opt_out_useragent_filter&&(r.$browser_type=this._is_bot()?"bot":"browser"),(r=mu({},e,this.persistence.properties(),this.sessionPersistence.properties(),r)).$is_identified=this._isIdentified(),_l(this.config.property_denylist)?cl(this.config.property_denylist,function(Q){delete r[Q]}):Wi.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var E=this.config.sanitize_properties;E&&(Wi.error("sanitize_properties is deprecated. Use before_send instead"),r=E(r,n));var y=this._hasPersonProcessing();return r.$process_person_profile=y,y&&this._requirePersonProcessing("_calculate_event_properties"),r}_calculate_set_once_properties(n){var i;if(!this.persistence||!this._hasPersonProcessing()||this._personProcessingSetOncePropertiesSent)return n;var o=this.persistence.get_initial_props(),a=(i=this.sessionPropsManager)===null||i===void 0?void 0:i.getSetOnceProps(),s=mu({},o,a||{},n||{}),r=this.config.sanitize_properties;return r&&(Wi.error("sanitize_properties is deprecated. Use before_send instead"),s=r(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,py(s)?void 0:s}register(n,i){var o;(o=this.persistence)===null||o===void 0||o.register(n,i)}register_once(n,i,o){var a;(a=this.persistence)===null||a===void 0||a.register_once(n,i,o)}register_for_session(n){var i;(i=this.sessionPersistence)===null||i===void 0||i.register(n)}unregister(n){var i;(i=this.persistence)===null||i===void 0||i.unregister(n)}unregister_for_session(n){var i;(i=this.sessionPersistence)===null||i===void 0||i.unregister(n)}_register_single(n,i){this.register({[n]:i})}getFeatureFlag(n,i){return this.featureFlags.getFeatureFlag(n,i)}getFeatureFlagPayload(n){var i=this.featureFlags.getFeatureFlagPayload(n);try{return JSON.parse(i)}catch{return i}}isFeatureEnabled(n,i){return this.featureFlags.isFeatureEnabled(n,i)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(n,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(n,i)}getEarlyAccessFeatures(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],o=arguments.length>2?arguments[2]:void 0;return this.featureFlags.getEarlyAccessFeatures(n,i,o)}on(n,i){return this._internalEventEmitter.on(n,i)}onFeatureFlags(n){return this.featureFlags.onFeatureFlags(n)}onSurveysLoaded(n){return this.surveys.onSurveysLoaded(n)}onSessionId(n){var i,o;return(i=(o=this.sessionManager)===null||o===void 0?void 0:o.onSessionId(n))!==null&&i!==void 0?i:()=>{}}getSurveys(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(n,i)}getActiveMatchingSurveys(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(n,i)}renderSurvey(n,i){this.surveys.renderSurvey(n,i)}canRenderSurvey(n){this.surveys.canRenderSurvey(n)}identify(n,i,o){if(!this.__loaded||!this.persistence)return Wi.uninitializedWarning("posthog.identify");if(Ac(n)&&(n=n.toString(),Wi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),n){if(["distinct_id","distinctid"].includes(n.toLowerCase()))Wi.critical('The string "'.concat(n,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var a=this.get_distinct_id();if(this.register({$user_id:n}),!this.get_property("$device_id")){var s=a;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}n!==a&&n!==this.get_property(SM)&&(this.unregister(SM),this.register({distinct_id:n}));var r=(this.persistence.get_property(vE)||"anonymous")==="anonymous";n!==a&&r?(this.persistence.set_property(vE,"identified"),this.setPersonPropertiesForFlags(S4(S4({},o||{}),i||{}),!1),this.capture("$identify",{distinct_id:n,$anon_distinct_id:a},{$set:i||{},$set_once:o||{}}),this.featureFlags.setAnonymousDistinctId(a),this._cachedIdentify=cX(n,i,o)):(i||o)&&(this._cachedIdentify!==cX(n,i,o)?(this.setPersonProperties(i,o),this._cachedIdentify=cX(n,i,o)):Wi.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),n!==a&&(this.reloadFeatureFlags(),this.unregister(DS))}}else Wi.error("Unique user id has not been set in posthog.identify")}setPersonProperties(n,i){(n||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(S4(S4({},i||{}),n||{})),this.capture("$set",{$set:n||{},$set_once:i||{}}))}group(n,i,o){if(n&&i){if(this._requirePersonProcessing("posthog.group")){var a=this.getGroups();a[n]!==i&&this.resetGroupPropertiesForFlags(n),this.register({$groups:S4(S4({},a),{},{[n]:i})}),o&&(this.capture("$groupidentify",{$group_type:n,$group_key:i,$group_set:o}),this.setGroupPropertiesForFlags({[n]:o})),a[n]===i||o||this.reloadFeatureFlags()}}else Wi.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setPersonPropertiesForFlags(n,i)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(n,i)}resetGroupPropertiesForFlags(n){this.featureFlags.resetGroupPropertiesForFlags(n)}reset(n){var i,o,a,s;if(Wi.info("reset"),!this.__loaded)return Wi.uninitializedWarning("posthog.reset");var r=this.get_property("$device_id");if(this.consent.reset(),(i=this.persistence)===null||i===void 0||i.clear(),(o=this.sessionPersistence)===null||o===void 0||o.clear(),this.surveys.reset(),(a=this.persistence)===null||a===void 0||a.set_property(vE,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Vl2,$device_id:null},"");else{var C=this.config.get_device_id($p());this.register_once({distinct_id:C,$device_id:n?C:r},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var n,i;return(n=(i=this.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&n!==void 0?n:""}get_session_replay_url(n){if(!this.sessionManager)return"";var{sessionId:i,sessionStartTimestamp:o}=this.sessionManager.checkAndGetSessionAndWindowId(!0),a=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(i));if(n!=null&&n.withTimestamp&&o){var s,r=(s=n.timestampLookBack)!==null&&s!==void 0?s:10;if(!o)return a;var C=Math.max(Math.floor((new Date().getTime()-o)/1e3)-r,0);a+="?t=".concat(C)}return a}alias(n,i){return n===this.get_property(bl2)?(Wi.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Mr(i)&&(i=this.get_distinct_id()),n!==i?(this._register_single(SM,n),this.capture("$create_alias",{alias:n,distinct_id:i})):(Wi.warn("alias matches current distinct_id - skipping api call."),this.identify(n),-1)):void 0}set_config(n){var i,o,a,s,r=S4({},this.config);Xl(n)&&(mu(this.config,QA2(n)),(i=this.persistence)===null||i===void 0||i.update_config(this.config,r),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tX(S4(S4({},this.config),{},{persistence:"sessionStorage"})),Du.is_supported()&&Du.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(pE.DEBUG=!0,Wi.info("set_config",JSON.stringify({config:n,oldConfig:r,newConfig:S4({},this.config)},null,2))),(o=this.sessionRecording)===null||o===void 0||o.startIfEnabledOrStop(),(a=this.autocapture)===null||a===void 0||a.startIfEnabled(),(s=this.heatmaps)===null||s===void 0||s.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(n){var i=n===!0,o={sampling:i||!(n==null||!n.sampling),linked_flag:i||!(n==null||!n.linked_flag),url_trigger:i||!(n==null||!n.url_trigger),event_trigger:i||!(n==null||!n.event_trigger)};if(Object.values(o).some(Boolean)){var a,s,r,C,l;(a=this.sessionManager)===null||a===void 0||a.checkAndGetSessionAndWindowId(),o.sampling&&((s=this.sessionRecording)===null||s===void 0||s.overrideSampling()),o.linked_flag&&((r=this.sessionRecording)===null||r===void 0||r.overrideLinkedFlag()),o.url_trigger&&((C=this.sessionRecording)===null||C===void 0||C.overrideTrigger("url")),o.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var n;return!((n=this.sessionRecording)===null||n===void 0||!n.started)}captureException(n,i){var o=new Error("PostHog syntheticException");this.exceptions.sendExceptionEvent(S4(S4({},M00((a=>a instanceof Error)(n)?{error:n,event:n.message}:{event:n},{syntheticException:o})),i))}loadToolbar(n){return this.toolbar.loadToolbar(n)}get_property(n){var i;return(i=this.persistence)===null||i===void 0?void 0:i.props[n]}getSessionProperty(n){var i;return(i=this.sessionPersistence)===null||i===void 0?void 0:i.props[n]}toString(){var n,i=(n=this.config.name)!==null&&n!==void 0?n:xy;return i!==xy&&(i=xy+"."+i),i}_isIdentified(){var n,i;return((n=this.persistence)===null||n===void 0?void 0:n.get_property(vE))==="identified"||((i=this.sessionPersistence)===null||i===void 0?void 0:i.get_property(vE))==="identified"}_hasPersonProcessing(){var n,i,o,a;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&py(this.getGroups())&&((n=this.persistence)===null||n===void 0||(i=n.props)===null||i===void 0||!i[SM])&&((o=this.persistence)===null||o===void 0||(a=o.props)===null||a===void 0||!a[NS]))}_shouldCapturePageleave(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(n){return this.config.person_profiles==="never"?(Wi.error(n+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(NS,!0),!0)}_sync_opt_out_with_persistence(){var n,i,o,a,s=this.consent.isOptedOut(),r=this.config.opt_out_persistence_by_default,C=this.config.disable_persistence||s&&!!r;((n=this.persistence)===null||n===void 0?void 0:n.disabled)!==C&&((o=this.persistence)===null||o===void 0||o.set_disabled(C)),((i=this.sessionPersistence)===null||i===void 0?void 0:i.disabled)!==C&&((a=this.sessionPersistence)===null||a===void 0||a.set_disabled(C))}opt_in_capturing(n){var i;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),(Mr(n==null?void 0:n.captureEventName)||n!=null&&n.captureEventName)&&this.capture((i=n==null?void 0:n.captureEventName)!==null&&i!==void 0?i:"$opt_in",n==null?void 0:n.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return Bf?BA2(Bf,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Fn&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:Fn.title},{send_instantly:!0}))}debug(n){n===!1?(p4==null||p4.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(p4==null||p4.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_runBeforeSend(n){if(ll(this.config.before_send))return n;var i=_l(this.config.before_send)?this.config.before_send:[this.config.before_send],o=n;for(var a of i){if(o=a(o),ll(o)){var s="Event '".concat(n.event,"' was rejected in beforeSend function");return P20(n.event)?Wi.warn("".concat(s,". This can cause unexpected behavior.")):Wi.info(s),null}o.properties&&!py(o.properties)||Wi.warn("Event '".concat(n.event,"' has no properties after beforeSend function, this is likely an error."))}return o}getPageViewId(){var n;return(n=this.pageViewManager._currentPageview)===null||n===void 0?void 0:n.pageViewId}captureTraceFeedback(n,i){this.capture("$ai_feedback",{$ai_trace_id:String(n),$ai_feedback_text:i})}captureTraceMetric(n,i,o){this.capture("$ai_metric",{$ai_trace_id:String(n),$ai_metric_name:i,$ai_metric_value:String(o)})}}(function(t,n){for(var i=0;i<n.length;i++)t.prototype[n[i]]=F20(t.prototype[n[i]])})(iV,["identify"]);var MA2,F10=(MA2=$M[xy]=new iV,function(){function t(){t.done||(t.done=!0,LA2=!1,cl($M,function(n){n._dom_loaded()}))}Fn!=null&&Fn.addEventListener?Fn.readyState==="complete"?t():su(Fn,"DOMContentLoaded",t,{capture:!1}):p4&&Wi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),MA2);const U10=new y20({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),TA2=({children:t,theme:n})=>{P0.useEffect(()=>{!n||!Object.keys(n).length||Ly2(n)},[n]);const i=(o,a)=>{F10.capture("sth_went_wrong",{message:o.message,stack:o.stack,componentStack:a.componentStack})};return h.jsx(o20,{FallbackComponent:PB2,onError:i,children:h.jsx(x20,{client:U10,children:t})})},Ry={metric:"_metric_d9kl6_1",loader:"_loader_d9kl6_7","alt-container":"_alt-container_d9kl6_13","MetricList-wrapper":"_MetricList-wrapper_d9kl6_21",flexDisplay:"_flexDisplay_d9kl6_45",mergedCard:"_mergedCard_d9kl6_53"},xA2=P0.createContext({isLoading:void 0,data:void 0,token:void 0,refetch:void 0}),eT=()=>P0.useContext(xA2),oV="http://localhost:3000",Ju="/api/v2/dashboard",Hy="/api/v2/metric",ih="/api/v3/metric",j10="dashboardData",z10=`${Ju}/embeddedMetric`,G10="embeddedMetric",Y10=`${Hy}/layout`,RA2="dashboardLayout",W10=`${Ju}/scheduledReportV2`,_10="dashboardScheduledReportV2",X10=`${Hy}/saveLayout`,K10="saveLayout",J10=`${Ju}/saveScheduleReport`,q10="saveScheduleReport",$10=`${Ju}/deleteScheduleReport`,e30="deleteScheduleReport",t30=`${Ju}/createMetric`,r30="createMetric",n30=`${Ju}/updateMetric`,i30="updateMetric",o30=`${Ju}/updateAdminMetric`,a30="updateAdminMetric",s30=`${Ju}/generateMetric`,C30="generateMetric",l30=`${Ju}/datasetMetricCreation`,u30="datasetMetricCreation",A30=`${Ju}/previewTable`,c30="previewTable",f30=`${Ju}/generatetMetricData`,d30="/generatetMetricData",g30=`${Ju}/getOpenaiChatResponse`,h30="getOpenaiChatResponse",E30=`${Ju}/getDashboardScreenshot`,p30=`${Ju}/createDashboardFilterView`,v30="createDashboardFilterView",I30=`${Ju}/getDashboardFilterView`,m30="getDashboardFilterView",b30=`${Ju}/getTheme`,B30="getTheme",y30=`${ih}/query`,L30="query",w30=`${ih}/datasetMetricCreation`,Q30="newDatasetMetricCreation",M30=`${ih}/generateDataReport`,T30="generateDataReport",x30=`${ih}/chatQuery`,R30="chatQuery",H30=`${Hy}/rawDownloadSettings`,D30="rawDownloadSettings",N30=`${Hy}/column`,S30="column",V30=`${Hy}/underlyingData`,k30="underlyingData",O30=`${Hy}/invokeShareCsv`,P30="invokeShareCsv",Z30=`${ih}/markArchived`,F30="markArchived",U30=`${ih}/publishMetrics`,j30="publishMetrics",z30=`${ih}/download-csv`,G30=`${ih}/downloadDashboardMetrics`,Y30="IS_LOADING",W30="DATA_LOADED",_30=`${ih}/summarizeMetric`,X30="summarizeMetric",K30=`${ih}/createGuestTokenUsageLog`,J30="createGuestTokenUsageLog",HA2="ENTER_FULL_SCREEN_MODE",DA2="EXIT_FULL_SCREEN_MODE",q30="ENTER_SCHEDULED_REPORT_MODE",$30="SAVE_SCHEDULED_REPORT",NA2="EXIT_SCHEDULED_REPORT_MODE",e70="ENTER_CUSTOMIZE_LAYOUT_MODE",SA2="EXIT_CUSTOMIZE_LAYOUT_MODE",VA2="SAVE_LAYOUT",t70="ENTER_MANAGE_METRICS_MODE",kA2="EXIT_MANAGE_METRICS_MODE",r70="SAVE_MANAGE_METRICS",n70="ARCHIVE_METRIC",OA2="DOWNLOAD_METRIC",PA2="DOWNLOAD_METRIC_WITHOUT_FILTERS",i70="SAVE_METRIC_PNG",o70="METRIC_FILTER_APPLIED",a70="DASHBOARD_FILTER_APPLIED",s70="CREATE_METRIC",ZA2="UPDATE_METRIC",dX=()=>localStorage.getItem(mB2),aV=()=>{var o,a,s;const t=((o=window==null?void 0:window.dbn)==null?void 0:o.proxyAuthUrl)||"",n=((a=window==null?void 0:window.dbn)==null?void 0:a.proxyAuthKey)||"";return((s=window==null?void 0:window.dbn)==null?void 0:s.isEnableProxyAuth)||!1?{"X-Proxy-Auth-key":n,"X-Proxy-Auth-Url":t,"X-Authorization":n}:null},zC=async(t,n={method:"GET"})=>{var r,C,l,e,u,A,f;const i=((r=window==null?void 0:window.dbn)==null?void 0:r.isEnableProxyAuth)||!1,o={method:n.method,headers:{"Content-Type":"application/json",...i?{}:{"X-Plugin-Token":n.token||""},"X-Plugin-Origin":window.location.host,...n.isFrontend?{"X-Dbn-Secret":n.clientId}:{},...n.isFrontend?{"X-Dbn-token":dX()||""}:{},...aV()||{}}};n.data&&(o.body=JSON.stringify(n.data));const s=await(await fetch(`${((C=window.dbn)==null?void 0:C.proxyAuthUrl)||((l=window.dbn)==null?void 0:l.baseUrl)||oV}${t}`,o)).json();if(s.error){const{message:d}=s.error;throw new Error(d)}if(["E1005","E1007"].includes(((u=(e=s==null?void 0:s.data)==null?void 0:e.error)==null?void 0:u.code)||""))throw new Error(((f=(A=s==null?void 0:s.data)==null?void 0:A.error)==null?void 0:f.message)||"An error occurred");return s.data},C70=()=>Wl(K10,t=>zC(X10,{method:"POST",data:t})),l70=()=>Wl(q10,t=>zC(J10,{method:"POST",data:t.data,token:t.token})),FA2=()=>Wl(e30,t=>zC($10,{method:"POST",data:t,token:t.token})),u70=()=>Wl(r30,({data:t,token:n})=>zC(t30,{method:"POST",data:t,token:n})),A70=()=>Wl(i30,({data:t,token:n})=>zC(n30,{method:"POST",data:t,token:n})),c70=()=>Wl(a30,({data:t,token:n})=>zC(o30,{method:"POST",data:t,token:n})),f70=()=>Wl(C30,({data:t,token:n})=>zC(s30,{method:"POST",data:t,token:n})),UA2=()=>Wl(u30,({data:t,token:n})=>zC(l30,{method:"POST",data:t,token:n})),d70=()=>Wl(c30,({data:t,token:n})=>zC(A30,{method:"POST",data:t,token:n})),g70=()=>Wl(d30,({data:t,token:n})=>zC(f30,{method:"POST",data:t,token:n})),h70=()=>Wl(h30,({data:t,token:n})=>zC(g30,{method:"POST",data:t,token:n})),E70=()=>Wl(v30,({data:t,token:n})=>zC(p30,{method:"POST",data:t,token:n})),gX=()=>Wl(S30,t=>zC(N30,{method:"POST",data:t})),p70=()=>Wl(k30,t=>zC(V30,{method:"POST",data:t})),v70=()=>Wl(P30,t=>zC(O30,{method:"POST",data:t})),I70=()=>Wl(F30,({data:t,token:n})=>zC(Z30,{method:"POST",data:t,token:n})),m70=()=>Wl(j30,({data:t,token:n})=>zC(U30,{method:"POST",data:t,token:n})),b70=()=>Wl(Q30,({data:t,token:n,clientId:i,isFrontendApp:o})=>zC(w30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),jA2=()=>Wl(T30,({data:t,token:n,clientId:i,isFrontendApp:o})=>zC(M30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),B70=()=>Wl(R30,({data:t,token:n,clientId:i,isFrontendApp:o})=>zC(x30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),y70=()=>Wl(X30,({data:t,isFrontendApp:n,clientId:i,token:o})=>zC(_30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),L70=()=>Wl(J30,({data:t,isFrontendApp:n,clientId:i,token:o})=>zC(K30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),hX=()=>{const{mutateAsync:t}=L70();return{saveLogsAsync:async i=>{t(i)}}},tT=({onSuccess:t,companyIntegrationId:n,selectedColumns:i,query:o,metricQuery:a,integrationName:s,outputColumns:r,chartSettings:C,clientId:l,companyId:e,isLiveMode:u,timeGrain:A,dashboardIds:f,isEnableGroupBy:d,groupBy:g,selectedGroupBy:E,metric:y,datasetMetricSettings:Q,drillDownSettings:R,onServerEvent:D,limit:O})=>{var X2,L3,O1;const{token:k,data:J}=eT(),[e2,p2]=P0.useState(""),{mutate:D2,isLoading:Q2}=u70(),{mutate:i2}=d70(),{saveLogsAsync:N2}=hX(),{register:R2,setValue:M2,watch:Z2,handleSubmit:Y2,control:f0,reset:E0}=Vb(),M0=C3=>{p2(""),C==null||C.chartType,m0.singleValue,D2({data:{companyId:e,companyIntegrationId:n,description:C3.description,inputFields:i,metricId:C3.metricId,name:C3.name,query:o,metricQuery:a,integrationName:s,outputColumns:r,createdBy:l||"external user",isLive:u||!1,chartOptions:C,datasetMetricSettings:Q,clientId:l||null,isCreatedByClient:!!l,timeGrain:A||null,externalDashboardIds:f==null?void 0:f.map(W3=>({externalDashboardId:W3})),isEnableGroupBy:d,groupBy:g??{},selectedGroupBy:E,drillDownSettings:R,limit:O},token:k},{onSuccess:async W3=>{var d7,y7,Y7;(d7=W3==null?void 0:W3.insert_externalMetrics_one)!=null&&d7.id?(await N2({clientId:l,data:{companyId:e,feature:"CREATE_METRIC",metricId:(y7=W3==null?void 0:W3.insert_externalMetrics_one)==null?void 0:y7.metricId},isFrontendApp:!1,token:k}),await(t==null?void 0:t((Y7=W3==null?void 0:W3.insert_externalMetrics_one)==null?void 0:Y7.id)),D==null||D(s70)):p2("Metric Id already exists")},onError:()=>{p2&&p2("Metric Id already exists")}})},{mutateAsync:x0,isLoading:z2}=c70(),{mutateAsync:t1,isLoading:p0}=A70(),U0=P0.useCallback((C3,W3)=>{var y7,Y7,I6;p2("");let d7={};if(W3&&(d7={isDisableCardAppearance:C3.isDisableCardAppearance,titleAlignment:C3.titleAlignment,descAlignment:C3.descAlignment,...C3.text?{textBox:{text:C3.text,fontWeight:C3.fontWeight||"400",fontColor:C3.fontColor||"",fontSize:C3.fontSize||"14px",alignment:C3.textAlignment||"left",link:C3.textLink,isOpenInNewTab:C3.isOpenInNewTab,targetWord:C3.targetWord}}:null}),!(y!=null&&y.isCreatedByClient))x0({data:{externalMetricId:y==null?void 0:y.id,clientId:l,object:{clientId:l,companyId:e,companyIntegrationId:n||(y==null?void 0:y.companyIntegrationId),description:C3.description,inputFields:i,metricId:C3.metricId===(y==null?void 0:y.metricId)?`update_${C3.metricId}_by_${l}_${Date.now()}`:C3.metricId,name:W3?(y7=C3==null?void 0:C3.elementTitle)==null?void 0:y7.trim():(Y7=C3==null?void 0:C3.name)==null?void 0:Y7.trim(),query:o,metricQuery:a,datasetMetricSettings:Q,integrationName:s,outputColumns:r,createdBy:l||"external user",isCreatedByClient:!!l,isLive:u||C3.isLive,chartOptions:C,limit:O,drillDownSettings:R,elementSettings:d7,isMetric:!W3,...W3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}},externalDashboardMetrics:{data:f==null?void 0:f.map(z7=>({externalDashboardId:z7}))}}},token:k},{onSuccess:async z7=>{var X6;!(z7!=null&&z7.insert_clientDeletedMetrics_one)||!(z7!=null&&z7.insert_externalMetrics_one)||(p2(""),await N2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(X6=z7==null?void 0:z7.insert_externalMetrics_one)==null?void 0:X6.metricId},isFrontendApp:!1,token:k}),await(t==null?void 0:t()),D==null||D(ZA2))},onError:()=>{p2("Something went wrong! Please try again later.")}});else{const z7={chartOptions:C,datasetMetricSettings:Q,limit:O,description:C3.description,query:o,metricQuery:a,drillDownSettings:R,elementSettings:d7,isMetric:!W3,...W3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}}};C3.description&&(z7.description=C3.description),C3.metricId&&(z7.metricId=C3.metricId),C3.name&&!W3&&(z7.name=C3.name),C3.elementTitle&&W3&&(z7.name=C3==null?void 0:C3.elementTitle),(I6=Object.keys(d7))!=null&&I6.length&&(z7.elementSettings=d7),t1({data:{externalMetricId:y==null?void 0:y.id,set:z7},token:k},{onSuccess:async X6=>{var k6,z3;(k6=X6==null?void 0:X6.update_externalMetrics_by_pk)!=null&&k6.id&&(p2(""),await N2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(z3=X6==null?void 0:X6.update_externalMetrics_by_pk)==null?void 0:z3.metricId},isFrontendApp:!1,token:k}),await(t==null?void 0:t()),D==null||D(ZA2))},onError:()=>{p2("Something went wrong! Please try again later.")}})}},[C,y,t1,x0,l,e,n,s,u,f,o,i,r,a,Q,O]),G0=P0.useCallback(C3=>{p2("");const W3={isPublished:!(C3!=null&&C3.isPublished)};t1({data:{externalMetricId:C3==null?void 0:C3.id,set:W3},token:k},{onSuccess:async d7=>{var y7,Y7;(y7=d7==null?void 0:d7.update_externalMetrics_by_pk)!=null&&y7.id&&(p2(""),await N2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(Y7=d7==null?void 0:d7.update_externalMetrics_by_pk)==null?void 0:Y7.metricId},isFrontendApp:!1,token:k}),t==null||t())},onError:()=>{p2("Something went wrong! Please try again later.")}})},[y]);return{createExternalMetric:M0,updateExternalMetric:U0,error:e2,isLoading:Q2||z2||p0,clientSubsetData:J==null?void 0:J.clientSubsetData,previewTable:i2,token:k,workspaceId:(X2=J==null?void 0:J.workspace)==null?void 0:X2.id,dashboardOptions:[{value:(L3=J==null?void 0:J.externalDashboard)==null?void 0:L3.id,label:((O1=J==null?void 0:J.externalDashboard)==null?void 0:O1.name)||"Dashboard"}],isDatabaseTenancy:(J==null?void 0:J.companyTenancyType)===YL,register:R2,setValue:M2,watch:Z2,handleSubmit:Y2,control:f0,reset:E0,onPublishMetric:G0}},zA2=()=>{const{mutate:t,isLoading:n,error:i}=f70(),{mutate:o,mutateAsync:a}=gX();return{generateDatasetMetric:t,isGeneratingDataset:n,generateError:i,fetchColumnValues:o,fetchColumnValuesAsync:a}};let w70=0;function Q70(t,n){const i=`atom${++w70}`,o={toString:()=>i};return typeof t=="function"?o.read=t:(o.init=t,o.read=a=>a(o),o.write=(a,s,r)=>s(o,typeof r=="function"?r(a(o)):r)),o}const hd={},nv=Symbol(),EX=t=>!!t[nv],sV=t=>!t[nv].c,rT=t=>{var n;const{b:i,c:o}=t[nv];o&&(o(),(n=T70.get(i))==null||n())},CV=(t,n)=>{const i=t[nv].o,o=n[nv].o;return i===o||t===o||EX(i)&&CV(i,n)},pX=(t,n)=>{const i={b:t,o:n,c:null},o=new Promise(a=>{i.c=()=>{i.c=null,a()},n.finally(i.c)});return o[nv]=i,o},M70=t=>pX(t[nv].b,t[nv].o),T70=new WeakMap,vX=t=>"init"in t,IX="r",mX="w",lV="c",bX="s",GA2="h",x70="n",R70="l",H70="a",D70="m",N70=t=>{const n=new WeakMap,i=new WeakMap,o=new Map;let a,s;(hd&&"production")!=="production"&&(a=new Set,s=new Set);const r=new WeakMap,C=(x0,z2,t1)=>{let p0=r.get(z2);p0||(p0=new Map,r.set(z2,p0)),t1.then(()=>{p0.get(x0)===t1&&(p0.delete(x0),p0.size||r.delete(z2))}),p0.set(x0,t1)},l=x0=>{const z2=new Set,t1=r.get(x0);return t1&&(r.delete(x0),t1.forEach((p0,U0)=>{rT(p0),z2.add(U0)})),z2},e=new WeakMap,u=x0=>{let z2=e.get(x0);return z2||(z2=new Map,e.set(x0,z2)),z2},A=(x0,z2)=>{if(x0){const t1=u(x0);let p0=t1.get(z2);return p0||(p0=A(x0.p,z2),p0&&"p"in p0&&sV(p0.p)&&(p0=void 0),p0&&t1.set(z2,p0)),p0}return n.get(z2)},f=(x0,z2,t1)=>{if((hd&&"production")!=="production"&&Object.freeze(t1),x0)u(x0).set(z2,t1);else{const p0=n.get(z2);n.set(z2,t1),o.has(z2)||o.set(z2,p0)}},d=(x0,z2=new Map,t1)=>{if(!t1)return z2;const p0=new Map;let U0=!1;return t1.forEach(G0=>{var X2;const L3=((X2=A(x0,G0))==null?void 0:X2.r)||0;p0.set(G0,L3),z2.get(G0)!==L3&&(U0=!0)}),z2.size===p0.size&&!U0?z2:p0},g=(x0,z2,t1,p0,U0)=>{const G0=A(x0,z2);if(G0){if(U0&&(!("p"in G0)||!CV(G0.p,U0)))return G0;"p"in G0&&rT(G0.p)}const X2={v:t1,r:(G0==null?void 0:G0.r)||0,y:!0,d:d(x0,G0==null?void 0:G0.d,p0)};let L3=!(G0!=null&&G0.y);return!G0||!("v"in G0)||!Object.is(G0.v,t1)?(L3=!0,++X2.r,X2.d.has(z2)&&(X2.d=new Map(X2.d).set(z2,X2.r))):X2.d!==G0.d&&(X2.d.size!==G0.d.size||!Array.from(X2.d.keys()).every(O1=>G0.d.has(O1)))&&(L3=!0,Promise.resolve().then(()=>{Z2(x0)})),G0&&!L3?G0:(f(x0,z2,X2),X2)},E=(x0,z2,t1,p0,U0)=>{const G0=A(x0,z2);if(G0){if(U0&&(!("p"in G0)||!CV(G0.p,U0)))return G0;"p"in G0&&rT(G0.p)}const X2={e:t1,r:((G0==null?void 0:G0.r)||0)+1,y:!0,d:d(x0,G0==null?void 0:G0.d,p0)};return f(x0,z2,X2),X2},y=(x0,z2,t1,p0)=>{const U0=A(x0,z2);if(U0&&"p"in U0){if(CV(U0.p,t1)&&!sV(U0.p))return U0.y?U0:{...U0,y:!0};rT(U0.p)}C(x0,z2,t1);const G0={p:t1,r:((U0==null?void 0:U0.r)||0)+1,y:!0,d:d(x0,U0==null?void 0:U0.d,p0)};return f(x0,z2,G0),G0},Q=(x0,z2,t1,p0)=>{if(t1 instanceof Promise){const U0=pX(t1,t1.then(G0=>{g(x0,z2,G0,p0,U0)}).catch(G0=>{if(G0 instanceof Promise)return EX(G0)?G0.then(()=>{D(x0,z2,!0)}):G0;E(x0,z2,G0,p0,U0)}));return y(x0,z2,U0,p0)}return g(x0,z2,t1,p0)},R=(x0,z2)=>{const t1=A(x0,z2);if(t1){const p0={...t1,y:!1};f(x0,z2,p0)}else(hd&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",z2)},D=(x0,z2,t1)=>{if(!t1){const U0=A(x0,z2);if(U0){if(U0.y&&"p"in U0&&!sV(U0.p))return U0;if(U0.d.forEach((G0,X2)=>{if(X2!==z2)if(!i.has(X2))D(x0,X2);else{const L3=A(x0,X2);L3&&!L3.y&&D(x0,X2)}}),Array.from(U0.d).every(([G0,X2])=>{const L3=A(x0,G0);return L3&&!("p"in L3)&&L3.r===X2}))return U0.y?U0:{...U0,y:!0}}}const p0=new Set;try{const U0=z2.read(G0=>{p0.add(G0);const X2=G0===z2?A(x0,G0):D(x0,G0);if(X2){if("e"in X2)throw X2.e;if("p"in X2)throw X2.p;return X2.v}if(vX(G0))return G0.init;throw new Error("no atom init")});return Q(x0,z2,U0,p0)}catch(U0){if(U0 instanceof Promise){const G0=EX(U0)&&sV(U0)?M70(U0):pX(U0,U0);return y(x0,z2,G0,p0)}return E(x0,z2,U0,p0)}},O=(x0,z2)=>D(z2,x0),k=(x0,z2)=>{let t1=i.get(z2);return t1||(t1=N2(x0,z2)),t1},J=(x0,z2)=>!z2.l.size&&(!z2.t.size||z2.t.size===1&&z2.t.has(x0)),e2=(x0,z2)=>{const t1=i.get(z2);t1&&J(z2,t1)&&R2(x0,z2)},p2=(x0,z2)=>{const t1=i.get(z2);t1==null||t1.t.forEach(p0=>{p0!==z2&&(R(x0,p0),p2(x0,p0))})},D2=(x0,z2,t1)=>{let p0=!0;const U0=(L3,O1)=>{const C3=D(x0,L3);if("e"in C3)throw C3.e;if("p"in C3){if(O1!=null&&O1.unstable_promise)return C3.p.then(()=>{const W3=A(x0,L3);return W3&&"p"in W3&&W3.p===C3.p?new Promise(d7=>setTimeout(d7)).then(()=>U0(L3,O1)):U0(L3,O1)});throw(hd&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",L3),C3.p}if("v"in C3)return C3.v;throw(hd&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",L3),new Error("no value found")},G0=(L3,O1)=>{let C3;if(L3===z2){if(!vX(L3))throw new Error("atom not writable");l(L3).forEach(Y7=>{Y7!==x0&&Q(Y7,L3,O1)});const d7=A(x0,L3),y7=Q(x0,L3,O1);d7!==y7&&p2(x0,L3)}else C3=D2(x0,L3,O1);return p0||Z2(x0),C3},X2=z2.write(U0,G0,t1);return p0=!1,X2},Q2=(x0,z2,t1)=>{const p0=D2(t1,x0,z2);return Z2(t1),p0},i2=x0=>!!x0.write,N2=(x0,z2,t1)=>{const p0={t:new Set(t1&&[t1]),l:new Set};if(i.set(z2,p0),(hd&&"production")!=="production"&&s.add(z2),D(void 0,z2).d.forEach((G0,X2)=>{const L3=i.get(X2);L3?L3.t.add(z2):X2!==z2&&N2(x0,X2,z2)}),i2(z2)&&z2.onMount){const G0=L3=>Q2(z2,L3,x0),X2=z2.onMount(G0);x0=void 0,X2&&(p0.u=X2)}return p0},R2=(x0,z2)=>{var t1;const p0=(t1=i.get(z2))==null?void 0:t1.u;p0&&p0(),i.delete(z2),(hd&&"production")!=="production"&&s.delete(z2);const U0=A(x0,z2);U0?("p"in U0&&rT(U0.p),U0.d.forEach((G0,X2)=>{if(X2!==z2){const L3=i.get(X2);L3&&(L3.t.delete(z2),J(X2,L3)&&R2(x0,X2))}})):(hd&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",z2)},M2=(x0,z2,t1,p0)=>{const U0=new Set(t1.d.keys());p0==null||p0.forEach((G0,X2)=>{if(U0.has(X2)){U0.delete(X2);return}const L3=i.get(X2);L3&&(L3.t.delete(z2),J(X2,L3)&&R2(x0,X2))}),U0.forEach(G0=>{const X2=i.get(G0);X2?X2.t.add(z2):i.has(z2)&&N2(x0,G0,z2)})},Z2=x0=>{if(x0){u(x0).forEach((t1,p0)=>{const U0=n.get(p0);if(t1!==U0){const G0=i.get(p0);G0==null||G0.l.forEach(X2=>X2(x0))}});return}for(;o.size;){const z2=Array.from(o);o.clear(),z2.forEach(([t1,p0])=>{const U0=A(void 0,t1);if(U0&&U0.d!==(p0==null?void 0:p0.d)&&M2(void 0,t1,U0,p0==null?void 0:p0.d),p0&&!p0.y&&(U0!=null&&U0.y))return;const G0=i.get(t1);G0==null||G0.l.forEach(X2=>X2())})}(hd&&"production")!=="production"&&a.forEach(z2=>z2())},Y2=x0=>{u(x0).forEach((t1,p0)=>{const U0=n.get(p0);(!U0||t1.r>U0.r||t1.y!==U0.y||t1.r===U0.r&&t1.d!==U0.d)&&(n.set(p0,t1),t1.d!==(U0==null?void 0:U0.d)&&M2(x0,p0,t1,U0==null?void 0:U0.d))})},f0=(x0,z2)=>{z2&&Y2(z2),Z2(void 0)},E0=(x0,z2,t1)=>{const U0=k(t1,x0).l;return U0.add(z2),()=>{U0.delete(z2),e2(t1,x0)}},M0=(x0,z2)=>{for(const[t1,p0]of x0)vX(t1)&&(Q(z2,t1,p0),p2(z2,t1));Z2(z2)};return(hd&&"production")!=="production"?{[IX]:O,[mX]:Q2,[lV]:f0,[bX]:E0,[GA2]:M0,[x70]:x0=>(a.add(x0),()=>{a.delete(x0)}),[R70]:()=>s.values(),[H70]:x0=>n.get(x0),[D70]:x0=>i.get(x0)}:{[IX]:O,[mX]:Q2,[lV]:f0,[bX]:E0,[GA2]:M0}},S70=(t,n)=>({s:n?n(t).SECRET_INTERNAL_store:N70()}),BX=new Map,YA2=t=>(BX.has(t)||BX.set(t,P0.createContext(S70())),BX.get(t));function WA2(t,n){return Q70(t)}function V70(t,n){const i=YA2(n),o=P0.useContext(i),{s:a,v:s}=o,r=f=>{const d=a[IX](t,f);if((hd&&"production")!=="production"&&!d.y)throw new Error("should not be invalidated");if("e"in d)throw d.e;if("p"in d)throw d.p;if("v"in d)return d.v;throw new Error("no atom value")},[[C,l,e],u]=P0.useReducer((f,d)=>{const g=r(d);return Object.is(f[1],g)&&f[2]===t?f:[d,g,t]},s,f=>{const d=r(f);return[f,d,t]});let A=l;return e!==t&&(u(C),A=r(C)),P0.useEffect(()=>{const{v:f}=o;f&&a[lV](t,f);const d=a[bX](t,u,f);return u(f),d},[a,t,o]),P0.useEffect(()=>{a[lV](t,C)}),P0.useDebugValue(A),A}function k70(t,n){const i=YA2(n),{s:o,w:a}=P0.useContext(i);return P0.useCallback(r=>{if((hd&&"production")!=="production"&&!("write"in t))throw new Error("not writable atom");const C=l=>o[mX](t,r,l);return a?a(C):C()},[o,a,t])}function yX(t,n){return"scope"in t&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),n=t.scope),[V70(t,n),k70(t,n)]}const uV=({onOutsideClick:t,wrapRef:n,portalRef:i})=>{P0.useEffect(()=>{const o=a=>{const s=n.current&&!n.current.contains("composedPath"in a?a.composedPath()[0]:a.target),r=i&&!i.contains("composedPath"in a?a.composedPath()[0]:a.target);i?s&&r&&t():s&&t()};return document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}},[n,t,i])},O70=({wrapRef:t,portalRef:n,autoCloseParent:i=!1})=>{const[o]=yX(Gc2);P0.useEffect(()=>{const a=s=>{o==null||o.forEach(r=>{var l,e,u,A,f,d,g,E;const C=((l=r.popperElement)==null?void 0:l.contains("composedPath"in s?s.composedPath()[0]:s.target))||((e=r.referenceElement)==null?void 0:e.contains("composedPath"in s?s.composedPath()[0]:s.target));if(!C){const y=o.find(Q=>{var D,O;const R=((D=r.popperElement)==null?void 0:D.contains(Q.referenceElement))&&(Q.isOpen===!0||Q.isMenuOpen===!0);return i?R&&((O=Q.popperElement)==null?void 0:O.contains("composedPath"in s?s.composedPath()[0]:s.target)):R});y?((u=y==null?void 0:y.setOpen)==null||u.call(y,!0),(A=y==null?void 0:y.setMenuOpen)==null||A.call(y,!0)):((f=r.setOpen)==null||f.call(r,!1),(d=r.setMenuOpen)==null||d.call(r,!1))}!C&&(r!=null&&r.disableCloseOnClickOutside)&&((g=r.setOpen)==null||g.call(r,!0),(E=r.setMenuOpen)==null||E.call(r,!0))})};return document.addEventListener("click",a,!0),()=>{document.removeEventListener("click",a,!0)}},[t,n,o])},P70=({token:t,dashboardId:n,configId:i,isEn:o})=>{var a;return _p([j10,{dashboardId:n,configId:i,token:t,isEn:o}],()=>{const s=n?`${Ju}?dashboardId=${n}${i?`&configId=${i}`:""}${`&isEn=${o}`}`:Ju;return zC(s,{method:"GET",token:t})},{enabled:!!t||!!((a=window==null?void 0:window.dbn)!=null&&a.isEnableProxyAuth)})},Z70=(t,n)=>_p([RA2,{dashboardId:t,clientId:n}],()=>zC(`${Y10}?id=${t}&clientId=${n}`,{method:"GET"}),{enabled:!!t&&!!n}),F70=(t,n,i)=>_p(_10,()=>zC(`${W10}?externalDashboardId=${n}${i?`&embedId=${i}`:""}`,{method:"GET",token:t}),{enabled:!!t&&!!n}),U70=(t,n)=>{var i;return _p([G10,{id:n}],()=>zC(`${z10}?metricId=${n}`,{method:"GET",token:t}),{enabled:!!t||!!((i=window==null?void 0:window.dbn)!=null&&i.isEnableProxyAuth)})},_A2=({token:t,name:n,companyId:i})=>_p([B30,{name:n}],()=>zC(b30,{method:"POST",token:t,data:{name:n,companyId:i}}),{enabled:!!(n&&t&&i)}),j70=({token:t,dashboardId:n})=>_p([m30,{dashboardId:n}],()=>zC(I30,{method:"POST",token:t,data:{dashboardId:n}}),{enabled:!!(t&&n)}),z70=({externalDashboardId:t,clientId:n})=>{const i=i_(),{data:o,isLoading:a}=Z70(t,n),[s,r,C,l]=P0.useMemo(()=>{const f=o;return[(f==null?void 0:f.layout)||[],(f==null?void 0:f.dashboardFiltersLayout)||[],!1,(f==null?void 0:f.gridMargin)||{}]},[o]),{mutateAsync:e,isLoading:u}=C70();return{saveLayout:P0.useCallback(async f=>{await e({clientId:n,externalDashboardId:t,layout:f.newLayout.length?f.newLayout:s,isLocked:!!f.isChangedByClient,dashboardFiltersLayout:f.filtersLayout.length?f.filtersLayout:r,gridMargin:f.gridMargin||null},{onSuccess:d=>{if(!d)return;const g=d;i.setQueryData([RA2,{dashboardId:t,clientId:n}],E=>({...E,...g}))}})},[e,n,t]),layout:s,dashboardFiltersLayout:r,gridMargin:l,isLayoutLocked:C,isLoadingLayout:a||u}},G70=({query:t,limit:n,offset:i,dbName:o})=>{const a=Of===(o==null?void 0:o.toLowerCase()),s=Yu===(o==null?void 0:o.toLowerCase()),r=LA===(o==null?void 0:o.toLowerCase());let C=t.replace(/;(^;]*)$/,"");const e=(C==null?void 0:C.toLowerCase()).includes("order"),u=parseInt(n,10);if(C!=null&&C.toLowerCase().includes("limit")){const A=parseInt(C==null?void 0:C.toLowerCase().split("limit")[1].trim(),10),f=i?n:Math.min(A,u);s||a||r?(C=C.replace(`limit ${A}`,`${e||a||r?"":"order by(select null)"} ${`offset ${i||0} rows`} fetch next ${f} rows only`),C=C.replace(`LIMIT ${A}`,`${e||a||r?"":" ORDER BY(SELECT NULL) "} OFFSET ${i||0} ROWS FETCH NEXT ${f} ROWS ONLY`)):(C=C.replace(`limit ${A}`,`limit ${f} ${i?`OFFSET ${i}`:""}`),C=C.replace(`LIMIT ${A}`,`LIMIT ${f} ${i?`OFFSET ${i}`:""}`))}else C!=null&&C.toLowerCase().includes("fetch")||C!=null&&C.toLowerCase().includes("limit")||((o==null?void 0:o.toLowerCase())==Yu||(o==null?void 0:o.toLowerCase())==Of||r?C+=` ${e||a||r?"":" ORDER BY(SELECT NULL) "} ${`offset ${i||0} rows`} fetch next ${u} rows only`:C+=` limit ${u} ${i?`OFFSET ${i}`:""}`);return C},Y70=({datasourceId:t,clientName:n,dbName:i,tenancyType:o,values:a,query:s,companyId:r,workspaceId:C,metricId:l,globalFilters:e,isAllClient:u,rlsConditions:A,dataMartRelationships:f,customSql:d,isEnableCustomSQL:g})=>{const{mutate:E}=p70();return{getUnderlyingData:({columnName:Q,value:R,setData:D,setLoading:O,isSingleValueChart:k,clientColumnType:J})=>{const e2=o==="MULTI_DATABASE"&&n||"",p2=g&&d?d:G70({query:s,limit:"5000",dbName:i}),D2=Ob({clientColumnType:J,query:p2||"",dbName:i,rlsConditions:A,tenancyLevel:o||"TABLE",clientId:n,globalFilters:e,values:a,isAllClient:u,dataMartRelationships:f});D([]),O(!0),E({columnName:k?void 0:Q,companyId:r,query:bf(D2,r),value:k?void 0:R.toString().replace(/'/g,"''"),workspaceId:C,metricId:l,isCustomSql:g&&!!d,databaseName:e2,datasourceId:t},{onSuccess(Q2){const i2=Q2==null?void 0:Q2.data;i2&&Array.isArray(i2)&&i2.length?(D(i2),O(!1)):(D([]),O(!1))},onError(){D([]),O(!1)}})}}},W70=({clientId:t,data:n,token:i,isFrontendApp:o,isFullScreen:a=""},s)=>_p([L30,n,t,o,i,a],()=>{var r,C,l;return zC(y30,{method:"POST",data:{...n||{},...!o&&i?{...(r=n==null?void 0:n.rlsConditions)!=null&&r.length?{rlsConditions:gy(n==null?void 0:n.rlsConditions,i)}:{},...(l=(C=n==null?void 0:n.globalFilters)==null?void 0:C.filters)!=null&&l.length?{globalFilters:gy(n==null?void 0:n.globalFilters,i)}:{}}:{}},isFrontend:o,clientId:t,token:i})},{enabled:!!n.id,onSuccess:s==null?void 0:s.onSuccess,retry:2}),_70=t=>_p([D30,t],()=>zC(`${H30}?id=${t}`,{method:"GET"}),{enabled:!!t}),AV={timeSeriesSettingsContainer:"_timeSeriesSettingsContainer_icvr7_1",timeSeriesSettingsType:"_timeSeriesSettingsType_icvr7_5",featToggle:"_featToggle_icvr7_9",dynamicFormat:"_dynamicFormat_icvr7_17"},X70=[{value:"line",label:"line"},{value:"bar",label:"bar"},{value:"area",label:"area"},{value:"stack",label:"stack"},{value:"combo",label:"combo"}],vC=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"},{value:"Quarterly",label:"Quarterly"},{value:"Yearly",label:"Yearly"}],K70=({onChange:t,settings:{groupBySettings:n,seriesType:i},yAxisList:o,onChangeTimeseriesFormat:a,globalFilterOptions:s})=>{var C,l,e,u,A,f;const r=(d,g)=>{if(n.options[d].split("____").length){const E=`${n.options[d].split("____")[0]}____${g}`,y=`${n.options[d].split("____")[0]}`;t(Q=>{var R,D,O,k;return{...Q,groupBySettings:{...Q.groupBySettings,options:(R=Q.groupBySettings.options)==null?void 0:R.map((J,e2)=>e2===d?E:J),value:((D=Q.groupBySettings.options)==null?void 0:D.find((J,e2)=>e2===d))===((O=Q==null?void 0:Q.groupBySettings)==null?void 0:O.value)?y:(k=Q==null?void 0:Q.groupBySettings)==null?void 0:k.value}}})}else{const E=`${n.options[d]}____${g}`,y=`${n.options[d]}`;t(Q=>{var R,D,O,k;return{...Q,groupBySettings:{...Q.groupBySettings,options:(R=Q.groupBySettings.options)==null?void 0:R.map((J,e2)=>e2===d?E:J),value:((D=Q.groupBySettings.options)==null?void 0:D.find((J,e2)=>e2===d))===((O=Q==null?void 0:Q.groupBySettings)==null?void 0:O.value)?y:(k=Q==null?void 0:Q.groupBySettings)==null?void 0:k.value}}})}};return h.jsxs("div",{className:AV.timeSeriesSettingsContainer,children:[h.jsx(_7,{variant:"heading-5",children:"Time Series Settings"}),h.jsx(K4,{label:"Series Type",options:X70,selectedOption:{value:((C=i==null?void 0:i[0])==null?void 0:C.type)||"bar",label:((l=i==null?void 0:i[0])==null?void 0:l.type)||"bar"},onChange:d=>{t(g=>({...g,seriesType:o==null?void 0:o.map(E=>({column:E,type:d.value}))}))},menuWidth:"100%",buttonWidth:"100%"}),h.jsx(_7,{variant:"body-text-2",children:"Group format"}),h.jsxs("div",{className:AV.timeSeriesSettingsType,children:[h.jsx(pc,{"data-testid":"group-default",id:"group-default",type:"radio",labelClass:"dbn-text-sm dbn-font-normal",onChange:({target:{checked:d}})=>{d&&(t(g=>({...g,groupBySettings:{...g.groupBySettings,value:"monthly",isDynamic:!1,options:vC==null?void 0:vC.map(E=>E.value),isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(vC==null?void 0:vC[2]))},name:"isDynamic",label:"Default",defaultChecked:!n.isDynamic&&!n.isGlobalFilter,checked:!n.isDynamic&&!n.isGlobalFilter}),h.jsx(pc,{"data-testid":"group-dynamic",id:"group-dynamic",type:"radio",labelClass:"dbn-text-sm dbn-font-normal",name:"isDynamic",label:"Dynamic",checked:n.isDynamic,defaultChecked:n.isDynamic,onChange:({target:{checked:d}})=>{d&&(t(g=>({...g,groupBySettings:{...g.groupBySettings,value:"monthly",isDynamic:!0,options:vC==null?void 0:vC.map(E=>E.value),fillXAxis:!1,isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(vC==null?void 0:vC[2]))}}),h.jsx(pc,{"data-testid":"group-global-filters",id:"group-global-filters",type:"radio",labelClass:"dbn-text-sm dbn-font-normal",name:"isGlobalFilter",label:"Filter",checked:n.isGlobalFilter,defaultChecked:n.isGlobalFilter,onChange:({target:{checked:d}})=>{d&&(t(g=>({...g,groupBySettings:{...g.groupBySettings,value:"daily",isDynamic:!1,options:vC==null?void 0:vC.map(E=>E.value),fillXAxis:!1,isGlobalFilter:!0,globalFilterOption:{label:"",value:""}}})),a==null||a(vC==null?void 0:vC[0]))}})]}),n.isDynamic?h.jsxs("div",{className:AV.dynamicFormat,children:[h.jsx(bs,{buttonWidth:"100%",menuWidth:"100%",options:vC,selectedOption:(A=n.options)==null?void 0:A.map(d=>d.split("____").length?{value:d.split("____")[0],label:d.split("____")[0]}:{value:d,label:d}),label:"Dynamic options",onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:Array.isArray(d)&&d.length?d[0].value:"monthly",options:(d==null?void 0:d.map(E=>E.value))||["monthly"],fillXAxis:[uf.daily,uf.weekly,uf.yearly].includes(Array.isArray(d)&&d.length?d[0].value:"monthly")?!1:g.groupBySettings.fillXAxis}})),a==null||a((d==null?void 0:d[0])||(vC==null?void 0:vC[2]))},isShowSelectedOptions:!0}),(f=n.options)==null?void 0:f.map((d,g)=>h.jsx(K9,{label:d.split("____").length>1?d.split("____")[0]:d,type:"text",value:d.split("____").length>1?d.split("____")[1]:d,placeholder:"Save as",onChange:E=>{r(g,E.target.value)}}))]}):h.jsxs(h.Fragment,{children:[(n==null?void 0:n.isGlobalFilter)&&h.jsxs(h.Fragment,{children:[h.jsx(K4,{label:"Dashboard Filter",menuWidth:"100%",buttonWidth:"100%",options:s,selectedOption:n.globalFilterOption||{value:"",label:""},onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,globalFilterOption:d,formatWithValue:[]}}))}}),!!((u=(e=n==null?void 0:n.globalFilterOption)==null?void 0:e.presetDateOptions)!=null&&u.length)&&h.jsx(os,{direction:"col",className:"dbn-gap-3",children:vC==null?void 0:vC.map(d=>{var g,E,y,Q,R,D,O;return h.jsxs(os,{className:"dbn-w-full dbn-gap-2",alignItems:"center",justify:"between",children:[h.jsx(wf,{checked:!!((g=n==null?void 0:n.formatWithValue)!=null&&g.find(k=>k.format===d.value&&k.isEnable)),onChange:({target:{checked:k}})=>{t(J=>{var e2,p2,D2,Q2,i2;return{...J,groupBySettings:{...J.groupBySettings,formatWithValue:[...((p2=(e2=J==null?void 0:J.groupBySettings)==null?void 0:e2.formatWithValue)==null?void 0:p2.filter(N2=>N2.format!==d.value))||[],{format:d.value,isEnable:k,value:((i2=(Q2=(D2=J==null?void 0:J.groupBySettings)==null?void 0:D2.formatWithValue)==null?void 0:Q2.find(N2=>N2.format===d.value))==null?void 0:i2.value)||""}]}}})},label:d.value}),h.jsx("div",{className:"dbn-w-full",children:h.jsx(K4,{placeholder:"Select a Filter Value",menuWidth:"100%",buttonWidth:"100%",options:((E=n==null?void 0:n.globalFilterOption)==null?void 0:E.presetDateOptions)||[],selectedOption:{value:((Q=(y=n==null?void 0:n.formatWithValue)==null?void 0:y.find(k=>k.format===d.value))==null?void 0:Q.value)||"",label:((D=(R=n==null?void 0:n.formatWithValue)==null?void 0:R.find(k=>k.format===d.value))==null?void 0:D.value)||""},isDisabled:!((O=n==null?void 0:n.formatWithValue)!=null&&O.find(k=>k.format===d.value&&k.isEnable)),onChange:k=>{t(J=>{var e2,p2,D2,Q2,i2;return{...J,groupBySettings:{...J.groupBySettings,formatWithValue:[...((p2=(e2=J==null?void 0:J.groupBySettings)==null?void 0:e2.formatWithValue)==null?void 0:p2.filter(N2=>N2.format!==d.value))||[],{format:d.value,isEnable:!!((i2=(Q2=(D2=J==null?void 0:J.groupBySettings)==null?void 0:D2.formatWithValue)==null?void 0:Q2.find(N2=>N2.format===d.value))!=null&&i2.isEnable),value:(k==null?void 0:k.value)||""}]}}})}})})]})})})]}),h.jsx(K4,{label:"Format Type",menuWidth:"100%",buttonWidth:"100%",options:vC,selectedOption:(vC==null?void 0:vC.find(d=>{var g,E;return((g=d.value)==null?void 0:g.toLowerCase())===((E=n==null?void 0:n.value)==null?void 0:E.toLowerCase())}))||(vC==null?void 0:vC[2]),onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:d.value}})),a==null||a(d)}}),[uf.month,uf.quarter].includes(n.value.toLowerCase())&&h.jsxs("div",{className:AV.featToggle,children:[h.jsx(_5,{name:"fill axis",enabled:n.fillXAxis,onChange:()=>t(d=>({...d,groupBySettings:{...d.groupBySettings,fillXAxis:!d.groupBySettings.fillXAxis}}))}),h.jsxs("span",{className:"dbn-flex dbn-gap-2 dbn-items-center",children:[h.jsx(_7,{variant:"body-text-2",children:"Fill X-axis"}),h.jsx(yf,{position:"top",iconConfig:{size:"xs",color:"primary"},text:"Enable to fill missing months or dates.",tooltipClass:"dbn-w-[300px]"})]})]})]})]})},fc=t=>{const n=new Set;return t.filter(i=>{var a;const o=JSON.stringify((a=i==null?void 0:i.measures)==null?void 0:a.sort());return n.has(o)?!1:(n.add(o),!0)})},Wc=t=>{const n=new Date(t);return n instanceof Date&&!Number.isNaN(n.getTime())?n:null},LX=({metric:t,globalFilters:n={tableName:"",filters:[]},rlsFilters:i,clientId:o,tenancyLevel:a,isInternalApp:s,appFilters:r,setCrossDashboardFilters:C,crossDashboardFilters:l,metricFilterOptions:e,isAllClient:u,isFrontendApp:A,guestToken:f,encryptedClientId:d,workspaceId:g,metricStore:E,setMetricStore:y,onServerEvent:Q,clientColumnType:R,datasourceId:D,appliedCardMetricFilters:O,language:k,translationDictionary:J,calendarType:e2,setLoadedCardMetadata:p2,isFullScreen:D2,setMetricMetadata:Q2,viewMetricData:i2,generatingPdf:N2,dataMartTables:R2})=>{var x5,M5,Y5,r4,n4,y4,m4,ce,N4,je,J4,ne,l1,z1,Z3,H3,X7,i3,Q1,y3,T7,V6,r8,V8,i9,S9,D3,E6,O7,h6,Z6,F8,E8,_8,R9,Z8,r5,t5,c5,s4,q4,ie,Be,fe,it,Bt,jr,Cn,xn,di,ii,oi,Ri,Ni,dn,Xr,gi,_i,ai,hi,si,Sr,en,ur,tn;const[M2,Z2]=P0.useState(!1),[Y2,f0]=P0.useState(!0),E0=y70(),[M0,x0]=P0.useState(""),[z2,t1]=P0.useState(""),[p0,U0]=P0.useState(!1),G0=P0.useRef(null),[X2,L3]=P0.useState({limit:10,offset:0}),[O1,C3]=P0.useState(0),[W3,d7]=P0.useState(0),[y7,Y7]=P0.useState((t==null?void 0:t.rlsConditions)||[]),[I6,z7]=P0.useState([]),[X6,k6]=P0.useState(!1),[z3,t0]=P0.useState(),[j3,K7]=P0.useState([]),[G7,c6]=P0.useState(""),[u6,L6]=P0.useState([]),[v1,A3]=P0.useState({isOpen:!1,report:"",isLoading:!1}),[c7,X3]=P0.useState(!1),[Y3,n7]=P0.useState([]),[V7,P7]=P0.useState([]),[D7,_6]=P0.useState({isEnableGroupBy:!1,isEnableCrossFilter:!1,drillType:""}),[c8,x8]=P0.useState([]),[C8,K8]=P0.useState(!1),[l8,I9]=P0.useState(!1),[M8,d9]=P0.useState([]),[b8,g5]=P0.useState({}),[N5,h5]=P0.useState(!1),[d4,b5]=P0.useState(null),[M1,o9]=P0.useState(t==null?void 0:t.chartOptions),[O9,s5]=P0.useState({data:[],error:"",isLoading:!1,currentValue:""}),u5=P0.useMemo(()=>{var K6,T6;return!!((T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)!=null&&T6.isPythonMode)},[(M5=(x5=t==null?void 0:t.datasetMetricSettings)==null?void 0:x5.newDatasetSettings)==null?void 0:M5.isPythonMode]),B5=P0.useMemo(()=>{var K6,T6,r9,I8,B9;return((B9=(I8=(r9=(T6=(K6=t==null?void 0:t.externalDashboardMetrics)==null?void 0:K6[0])==null?void 0:T6.externalDashboard)==null?void 0:r9.companyWorkspace)==null?void 0:I8.datamart)==null?void 0:B9.datamartRelationships)||[]},[t]),U9=P0.useMemo(()=>{const K6={};if(i!=null&&i.values)for(const T6 in i.values){const r9=`${T6}_variable`;K6[r9]=i.values[T6]}return K6},[i==null?void 0:i.values]),c3=P0.useMemo(()=>{var r9,I8,B9;const K6=(I8=(r9=t==null?void 0:t.datasetMetricSettings)==null?void 0:r9.newDatasetSettings)==null?void 0:I8.selectedMainTable,T6=R2==null?void 0:R2.find(D8=>D8.tableName===(K6==null?void 0:K6.tableName));return((B9=T6==null?void 0:T6.customColumnFields)==null?void 0:B9.map(D8=>{var n5,y5,V5,f4,R5,R6;return{value:D8==null?void 0:D8.columnName,label:D8==null?void 0:D8.columnName,isCustomField:!0,column:{uniqueId:dm(10),alias:D8==null?void 0:D8.columnName,configType:"DIMENSION",datatype:D8==null?void 0:D8.datatype,dropType:"DIMENSION",index:1e3,name:D8==null?void 0:D8.columnName,parentAlias:`${fm(K6==null?void 0:K6.schemaName,((n5=t==null?void 0:t.companyIntegration)==null?void 0:n5.name)||"")}_${(y5=K6==null?void 0:K6.tableName)==null?void 0:y5.replaceAll(" ","_")}`,table:(f4=(V5=t==null?void 0:t.datasetMetricSettings)==null?void 0:V5.newDatasetSettings)==null?void 0:f4.selectedMainTable,type:"DEFAULT",draggableItemData:{column:{name:D8==null?void 0:D8.columnName,dataType:D8==null?void 0:D8.datatype,as:D8==null?void 0:D8.datatype},table:(R6=(R5=t==null?void 0:t.datasetMetricSettings)==null?void 0:R5.newDatasetSettings)==null?void 0:R6.selectedMainTable},label:"",sql:""}}}))||[]},[(r4=(Y5=t==null?void 0:t.datasetMetricSettings)==null?void 0:Y5.newDatasetSettings)==null?void 0:r4.selectedMainTable,(n4=t==null?void 0:t.companyIntegration)==null?void 0:n4.name,R2]),W8=P0.useMemo(()=>{var K6,T6,r9,I8,B9,D8,n5,y5,V5,f4,R5,R6,k8,J9;return{isAllClient:u,id:t==null?void 0:t.id,tenancyLevel:a,rlsConditions:[...M8||[],...(K6=M1==null?void 0:M1.tableSettings)!=null&&K6.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?(T6=I6==null?void 0:I6.map(A5=>A5.condition))==null?void 0:T6.filter(A5=>vR(A5)):[]],globalFilters:u5?void 0:{...n,filters:(r9=n==null?void 0:n.filters)==null?void 0:r9.filter(A5=>{var Qe;return Array.isArray(A5==null?void 0:A5.value)?(Qe=A5==null?void 0:A5.value)==null?void 0:Qe.length:A5})},filterValues:u5?void 0:U9,limit:(I8=M1==null?void 0:M1.tableSettings)!=null&&I8.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?Math.min(X2.limit,1e3):void 0,offset:(B9=M1==null?void 0:M1.tableSettings)!=null&&B9.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?X2.offset:void 0,disableStringify:!0,pivotHeaders:((D8=M1==null?void 0:M1.pivotTableSettings2)==null?void 0:D8.headers)||[],timeseriesSettings:u5?void 0:{format:((V5=(y5=(n5=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:n5.groupBySettings)==null?void 0:y5.value)==null?void 0:V5.toLowerCase())||"monthly",seriesField:(M1==null?void 0:M1.seriesField)||"",isFiscal:e2==="ind"},chartSeriesField:(M1==null?void 0:M1.seriesField)!=="ungrouped"&&(M1!=null&&M1.seriesField)&&(M1!=null&&M1.isDynamicSeries)?M1==null?void 0:M1.seriesField:void 0,comparisonCount:W3,dynamicXAxis:{isEnable:!!((f4=M1==null?void 0:M1.dynamicXAxis)!=null&&f4.isEnabled||(R5=M1==null?void 0:M1.enduserMeasureAndDimensions)!=null&&R5.isEnabled)&&Uh.includes((M1==null?void 0:M1.chartType)||""),xaxis:(M1==null?void 0:M1.xAxis)||"",customField:(k8=(R6=M1==null?void 0:M1.dynamicXAxis)==null?void 0:R6.selectedOption)==null?void 0:k8.column},dbId:D,elementSettings:(J9=t==null?void 0:t.elementSettings)==null?void 0:J9.metricExpression,drillConfig:D7==null?void 0:D7.configV2,isEncrypted:!!(!A&&f)}},[M1,u,t,M8,u5,U9,V7,a,n,X2,W3,Uh,D,e2,D7==null?void 0:D7.configV2,f,A,JSON.stringify(I6)]),{data:e7,isLoading:Q6,error:P6,refetch:f6}=W70({data:W8,clientId:A?d||"":o,token:f,isFrontendApp:A,isFullScreen:D2},{onSuccess:K6=>{var r9;const T6=Iy2(K6);p2&&((r9=T6==null?void 0:T6.error)==null?void 0:r9.code)!=="E1001"&&(p2==null||p2(I8=>{var B9;return[...(I8==null?void 0:I8.filter(D8=>(D8==null?void 0:D8.id)!==(W8==null?void 0:W8.id)))||[],{id:W8==null?void 0:W8.id,isDataFound:!!(T6!=null&&T6.length)&&((M1==null?void 0:M1.chartType)!==m0.singleValue||((B9=T6==null?void 0:T6[0])==null?void 0:B9[(M1==null?void 0:M1.singleValue)||""])!==null)}]}))}}),{mutate:x7}=b70(),{mutateAsync:s7}=jA2();P0.useEffect(()=>{var T6;const K6=((T6=t==null?void 0:t.rlsConditions)==null?void 0:T6.map(r9=>{var V5,f4,R5,R6,k8,J9,A5,Qe,xe,ge,Ct,ye,j4,ze,Qt;let I8=r9;if(e){const re=by2(I8,e);re&&(I8={...I8,filterType:"manual",value:re.value?I8.datatype==="string"&&((V5=I8==null?void 0:I8.filterVariant)==null?void 0:V5.value)===fu?[re.value]:re.value:I8.value,options:I8.datatype==="date"?(f4=re.options)==null?void 0:f4.map(Le=>({...Le,startDate:Wc(Le.fromDate)??Le.startDate,endDate:Wc(Le.toDate)??Le.endDate,minDate:Wc(Le.minDate)??void 0,maxDate:Wc(Le.maxDate)??void 0,fromDate:Wc(Le.fromDate)??void 0,toDate:Wc(Le.toDate)??void 0})):re.options,variableOptions:I8.datatype==="date"?(R5=re.options)==null?void 0:R5.map(Le=>({range:Le.range,startDate:Wc(Le.fromDate)??Le.startDate,endDate:Wc(Le.toDate)??Le.endDate,minDate:Wc(Le.minDate)??void 0,maxDate:Wc(Le.maxDate)??void 0,fromDate:Wc(Le.fromDate)??void 0,toDate:Wc(Le.toDate)??void 0,value:Le.name,label:Le.name})):(R6=re.options)==null?void 0:R6.map(Le=>({value:Le,label:Le})),selectedVariableValue:re.value?I8.datatype==="string"?{value:re.value,label:re.value}:{startDate:Wc((J9=(k8=re.options)==null?void 0:k8.find(Le=>Le.name===re.value))==null?void 0:J9.fromDate),endDate:Wc((Qe=(A5=re.options)==null?void 0:A5.find(Le=>Le.name===re.value))==null?void 0:Qe.toDate),value:re.value,label:re.value}:I8.selectedVariableValue})}const D8=[...((Ct=(ge=(xe=i2==null?void 0:i2.metricViewFilters)==null?void 0:xe.find(re=>re.id===(t==null?void 0:t.id)))==null?void 0:ge.filters)==null?void 0:Ct.filter(re=>!(O!=null&&O.find(Le=>(re==null?void 0:re.name)===(Le==null?void 0:Le.name)))))||[],...O||[]].find(re=>I8.name===re.name);if(D8!=null&&D8.value&&(I8={...I8,...D8!=null&&D8.value?{value:D8==null?void 0:D8.value}:{},...D8!=null&&D8.selectedDropdownValue?{selectedDropdownValue:D8==null?void 0:D8.selectedDropdownValue}:{},...D8!=null&&D8.selectedVariableValue?{selectedVariableValue:D8==null?void 0:D8.selectedVariableValue}:{}}),(I8==null?void 0:I8.datatype)==="date"&&((ye=I8==null?void 0:I8.options)==null?void 0:ye.find(re=>re.range==="Custom Date"))&&(I8==null?void 0:I8.isEnableDynamicDate)&&((j4=I8==null?void 0:I8.dynamicDate)==null?void 0:j4.value)){const re=$s2(((ze=Tb==null?void 0:Tb.find(Kn=>{var le;return Kn.value===((le=I8==null?void 0:I8.dynamicDate)==null?void 0:le.value)}))==null?void 0:ze.count)||0),Le=qc(re),Ci=qc(re);I8={...I8,options:(Qt=I8==null?void 0:I8.options)==null?void 0:Qt.map(Kn=>Kn.range==="Custom Date"?{...Kn,startDate:re,endDate:re,timeGrainValue:`${Le} - ${Ci}`}:Kn)}}return a==="DATABASE"?{...I8,tableName:`${o}.${r9.tableName.split(".").slice(1).join(".")}`}:I8}))||[];Y7(K6||[])},[t==null?void 0:t.rlsConditions,e,a,o,O,i2]),P0.useEffect(()=>{let K6;return Q6?f0(!0):K6=setTimeout(()=>{f0(!1)},300),()=>clearTimeout(K6)},[Q6]),P0.useEffect(()=>{t!=null&&t.id&&Q2&&!u5&&(t!=null&&t.isMetric)&&(Q2==null||Q2(K6=>{var T6,r9,I8,B9,D8,n5,y5,V5,f4,R5,R6;return[...(K6==null?void 0:K6.filter(k8=>k8.id!==(t==null?void 0:t.id)))||[],{filters:[...M8||[],...(T6=M1==null?void 0:M1.tableSettings)!=null&&T6.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?(r9=I6==null?void 0:I6.map(k8=>k8.condition))==null?void 0:r9.filter(k8=>vR(k8)):[]],xAxisSettings:{isEnable:!!((I8=M1==null?void 0:M1.dynamicXAxis)!=null&&I8.isEnabled||(B9=M1==null?void 0:M1.enduserMeasureAndDimensions)!=null&&B9.isEnabled)&&Uh.includes((M1==null?void 0:M1.chartType)||""),xaxis:(M1==null?void 0:M1.xAxis)||""},yAxisSettings:{isEnable:!!(!((D8=M1==null?void 0:M1.dynamicYAxis)!=null&&D8.isEnabled)||!((n5=M1==null?void 0:M1.dynamicYAxis)!=null&&n5.selectedOption)||Array.isArray((y5=M1==null?void 0:M1.dynamicYAxis)==null?void 0:y5.selectedOption)),yAxis:((V5=M1==null?void 0:M1.dynamicYAxis)==null?void 0:V5.selectedOption)||""},id:t==null?void 0:t.id,metricRequestData:{isAllClient:u,timeseriesSettings:u5?void 0:{format:((R6=(R5=(f4=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:f4.groupBySettings)==null?void 0:R5.value)==null?void 0:R6.toLowerCase())||"monthly",seriesField:(M1==null?void 0:M1.seriesField)||"",isFiscal:e2==="ind"}}}]}))},[t==null?void 0:t.id,t==null?void 0:t.isMetric,M8,M1==null?void 0:M1.timeSeriesSettings,M1==null?void 0:M1.seriesField,u5,e2,u,I6,(y4=M1==null?void 0:M1.tableSettings)==null?void 0:y4.isServerSidePagination,M1==null?void 0:M1.chartType,M1==null?void 0:M1.dynamicYAxis,M1==null?void 0:M1.dynamicXAxis]),P0.useEffect(()=>{var K6,T6,r9,I8,B9,D8;if((K6=t==null?void 0:t.drillDownSettings)!=null&&K6.isEnableGroupBy){const n5=t==null?void 0:t.datasetMetricSettings;!((T6=t==null?void 0:t.drillDownSettings)!=null&&T6.configV2)&&!(D7!=null&&D7.configV2)&&((I8=(r9=n5==null?void 0:n5.newDatasetSettings)==null?void 0:r9.selectedMetrics)!=null&&I8.length)&&((D8=(B9=n5==null?void 0:n5.newDatasetSettings)==null?void 0:B9.selectedDims)!=null&&D8.length)?_6(y5=>{var V5,f4,R5;return{...(t==null?void 0:t.drillDownSettings)||{},configV2:{isEnable:!!((V5=t==null?void 0:t.drillDownSettings)!=null&&V5.isEnableGroupBy),levels:(R5=(f4=n5==null?void 0:n5.newDatasetSettings)==null?void 0:f4.selectedDims)==null?void 0:R5.map((R6,k8)=>{var A5,Qe,xe,ge;const J9=(xe=(Qe=(A5=t==null?void 0:t.drillDownSettings)==null?void 0:A5.drilldownChartSettings)==null?void 0:Qe.find(Ct=>(Ct==null?void 0:Ct.name)===(R6==null?void 0:R6.alias)))==null?void 0:xe.chartSettings;return{name:`Drill Level ${k8+1}`,chartSettings:J9||M1,index:dm(4),isEnable:k8===0,dimensions:[R6],measures:((ge=n5==null?void 0:n5.newDatasetSettings)==null?void 0:ge.selectedMetrics)||[]}})}}}):D7!=null&&D7.isEnableGroupBy||_6(t==null?void 0:t.drillDownSettings)}},[(m4=t==null?void 0:t.drillDownSettings)==null?void 0:m4.isEnableGroupBy,(ce=t==null?void 0:t.drillDownSettings)==null?void 0:ce.configV2,t==null?void 0:t.datasetMetricSettings,M1]);const{mutateAsync:k3}=gX(),E3=P0.useMemo(()=>{var r9,I8,B9,D8,n5,y5,V5,f4,R5,R6,k8,J9,A5,Qe,xe,ge;const K6=((r9=t==null?void 0:t.datasetMetricSettings)==null?void 0:r9.metricVariables)||[];if(!K6||!Array.isArray(K6)||!(K6!=null&&K6.length))return[];const T6=[];for(let Ct=0;Ct<(K6==null?void 0:K6.length);Ct++){const ye=K6[Ct],j4=ye.type.value==="custom"&&ye.customQuery&&ye.customColumnName,ze=j4?{query:Ob({query:(ye==null?void 0:ye.customQuery)||"",tenancyLevel:a,clientId:o,isAllClient:u,clientColumnType:R||"STRING",dbName:(I8=t==null?void 0:t.companyIntegration)==null?void 0:I8.name,rlsConditions:M8==null?void 0:M8.filter(le=>le.isVariableFilter),globalFilters:{...n,filters:(B9=n==null?void 0:n.filters)==null?void 0:B9.filter(le=>{var qt;return(le==null?void 0:le.isVariableFilter)&&!!(Array.isArray(le==null?void 0:le.value)?(qt=le==null?void 0:le.value)!=null&&qt.length:le)})}}),alias:DP}:void 0,Qt=(D8=ye.dependOnOptions)!=null&&D8.length?M8==null?void 0:M8.filter(le=>ye.dependOnOptions.some(qt=>{var br;return qt.type==="metric"&&((br=qt.filter)==null?void 0:br.value)===le.name&&qt.column})):[],re=(n5=ye.dependOnOptions)!=null&&n5.length?(y5=n==null?void 0:n.filters)==null?void 0:y5.filter(le=>{var qt;return Array.isArray(le==null?void 0:le.value)?(qt=le==null?void 0:le.value)==null?void 0:qt.length:le&&ye.dependOnOptions.some(br=>{var Ar;return br.type==="dashboard"&&((Ar=br.filter)==null?void 0:Ar.value)===le.label&&br.column})}):[],Le=Qt==null?void 0:Qt.map(le=>{var qt;return{columnName:((qt=ye.dependOnOptions.find(br=>{var Ar;return le.name===((Ar=br.filter)==null?void 0:Ar.value)}))==null?void 0:qt.column)||"",value:le.value,as:"string"}}),Ci=re==null?void 0:re.map(le=>{var qt;return{columnName:((qt=ye.dependOnOptions.find(br=>{var Ar;return le.label===((Ar=br.filter)==null?void 0:Ar.value)}))==null?void 0:qt.column)||"",value:kb(le==null?void 0:le.value),as:"string"}});ye.isClientScoped&&o&&R&&!u&&a==="TABLE"&&((f4=(V5=ye.clientColumn)==null?void 0:V5.name)!=null&&f4.value)&&((R6=(R5=ye.clientColumn)==null?void 0:R5.datatype)!=null&&R6.value)&&Le.push({columnName:(J9=(k8=ye.clientColumn)==null?void 0:k8.name)==null?void 0:J9.value,value:o,as:(Qe=(A5=ye.clientColumn)==null?void 0:A5.datatype)==null?void 0:Qe.value});const Kn=[...Le,...Ci];T6.push({object:{wId:g,tableName:j4?"":(xe=ye==null?void 0:ye.table)==null?void 0:xe.value,columnName:j4?(ye==null?void 0:ye.customColumnName)||"":((ge=ye==null?void 0:ye.column)==null?void 0:ge.value)||"",filter:Kn,customTable:ze,limit:"1",datasourceId:D,databaseName:a==="MULTI_DATABASE"&&o||""},element:ye})}return T6},[(N4=t==null?void 0:t.datasetMetricSettings)==null?void 0:N4.metricVariables,JSON.stringify(n==null?void 0:n.filters),M8,R,g,a,o,u,D]),Q7=async K6=>{var r9,I8,B9,D8,n5;Z2(!0);const T6={};K6==null||K6.forEach(y5=>{var V5,f4;T6[(V5=y5==null?void 0:y5.element)==null?void 0:V5.name]=((f4=y5==null?void 0:y5.element)==null?void 0:f4.defaultValue)||""}),g5(T6);for(let y5=0;y5<(K6==null?void 0:K6.length);y5++){const V5=K6[y5];if(T6[V5.element.name]=V5.element.defaultValue||"",Z2(!0),V5.object.wId&&(!((I8=(r9=V5==null?void 0:V5.object)==null?void 0:r9.customTable)!=null&&I8.query)||!((n5=(D8=(B9=V5==null?void 0:V5.object)==null?void 0:B9.customTable)==null?void 0:D8.query)!=null&&n5.includes("{{")))){const f4=await k3(V5.object);f4!=null&&f4.data&&Array.isArray(f4.data)&&g5(R5=>{var R6,k8;return{...R5,[V5.element.name]:((k8=(R6=f4==null?void 0:f4.data)==null?void 0:R6[0])==null?void 0:k8.value)||V5.element.defaultValue||""}})}}setTimeout(()=>{Z2(!1)},200)};P0.useEffect(()=>{E3!=null&&E3.length&&Q7(E3)},[JSON.stringify(E3)]);const E7=P0.useMemo(()=>{var K6,T6,r9,I8;return(I8=(r9=(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)==null?void 0:T6.selectedDims)==null?void 0:r9[0])==null?void 0:I8.name},[t]);P0.useMemo(()=>{var K6,T6,r9,I8;return Gs2(((I8=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.selectedDimensions)==null?void 0:I8[V7.length<((r9=(T6=t==null?void 0:t.datasetMetricSettings)==null?void 0:T6.selectedDimensions)==null?void 0:r9.length)?V7.length:0])||"")},[t==null?void 0:t.datasetMetricSettings,V7]),P0.useEffect(()=>{var r9,I8,B9;const T6=((r9=t==null?void 0:t.drillDownSettings)==null?void 0:r9.isEnableGroupBy)?y7||[]:[...y7!=null&&y7.length?y7:[],...l||[]];(I8=T6==null?void 0:T6.filter(D8=>D8.isAddOnMetrics))!=null&&I8.length?d9((B9=T6.filter(D8=>D8.isAddOnMetrics))==null?void 0:B9.map(D8=>{var n5,y5,V5,f4,R5;return s?{...D8,dimensionColumn:(M1==null?void 0:M1.xAxis)||"",measureColumn:((n5=M1==null?void 0:M1.yAxisList)==null?void 0:n5[0])||"",options:D8.datatype!==nA?[]:D8.options,variableOptions:D8.datatype!==nA?[]:D8.variableOptions}:{...D8,dimensionColumn:(M1==null?void 0:M1.xAxis)||"",measureColumn:((y5=M1==null?void 0:M1.yAxisList)==null?void 0:y5[0])||"",value:D8.isAppFilter?D8.datatype==="date"?(V5=D8==null?void 0:D8.options)==null?void 0:V5.find(R6=>{var k8;return R6.name===((k8=r==null?void 0:r.values)==null?void 0:k8[D8.name])||D8.value}):((f4=r==null?void 0:r.values)==null?void 0:f4[D8.name])||D8.value:D8.value,options:D8.datatype!==nA?[]:(R5=D8==null?void 0:D8.options)==null?void 0:R5.map(R6=>e2==="ind"&&D8.datatype===nA?{...R6,isFiscal:!0}:R6),variableOptions:D8.datatype!==nA?[]:D8.variableOptions}}).filter(D8=>vR(D8))):d9([])},[y7,r,l,(je=t==null?void 0:t.drillDownSettings)==null?void 0:je.isEnableGroupBy,a,s,o,e2]);const w6=P0.useMemo(()=>{var K6,T6,r9;return(M1==null?void 0:M1.chartType)===m0.singleValue&&!!((K6=M1==null?void 0:M1.customSettings)!=null&&K6.comparisonValueShow)&&!!((T6=M1==null?void 0:M1.customSettings)!=null&&T6.comparisonTimeGrain)&&!!((r9=M1==null?void 0:M1.customSettings)!=null&&r9.comparisonTimePeriod)&&!!(M1!=null&&M1.singleValue)},[M1]);P0.useEffect(()=>{var B9,D8,n5,y5,V5;const K6=e7;let T6=K6!=null&&K6.data&&typeof K6.data=="string"?JSON.parse(K6.data):K6!=null&&K6.data&&Array.isArray(K6==null?void 0:K6.data)?K6==null?void 0:K6.data:[];s5({data:[],error:"",isLoading:!1,currentValue:""}),(M1==null?void 0:M1.chartType)===m0.table&&C3((K6==null?void 0:K6.totalRecords)||0),T6=Js2(T6||[],((D8=(B9=t==null?void 0:t.datasetMetricSettings)==null?void 0:B9.newDatasetSettings)==null?void 0:D8.selectedDims)||[],((y5=(n5=t==null?void 0:t.datasetMetricSettings)==null?void 0:n5.newDatasetSettings)==null?void 0:y5.selectedMetrics)||[]);const r9=(()=>{var f4,R5,R6,k8;if(!Array.isArray(T6))return[];if(((R5=(f4=t==null?void 0:t.companyIntegration)==null?void 0:f4.name)==null?void 0:R5.toLowerCase())===Lg&&!u5){const J9=(R6=t==null?void 0:t.datasetMetricSettings)==null?void 0:R6.newDatasetSettings,A5=(J9==null?void 0:J9.selectedMetrics)||[],Qe=((k8=J9==null?void 0:J9.selectedDims)==null?void 0:k8.filter(ge=>{var Ct,ye;return!((ye=(Ct=ge==null?void 0:ge.alias)==null?void 0:Ct.toLowerCase())!=null&&ye.match(/monthly|quarterly|weekly|yearly|daily/))}))||[],xe=[...Qe==null?void 0:Qe.map(ge=>ge.alias),...A5==null?void 0:A5.map(ge=>ge.alias)];return Ks2(xe,T6)}return T6})();if(K7(r9),(V5=t==null?void 0:t.datasetMetricSettings)!=null&&V5.isUseRawSQL){const f4=Object.keys((r9==null?void 0:r9[0])||{})||[];o9(R5=>({...R5,yAxisList:f4||(R5==null?void 0:R5.yAxisList)||[]}))}const I8=K6==null?void 0:K6.metaData;x8(CW(I8==null?void 0:I8.groupbyColumnList)),A3(f4=>({...f4,report:"",isLoading:f4==null?void 0:f4.isLoading,isOpen:f4==null?void 0:f4.isOpen}))},[e7,t==null?void 0:t.datasetMetricSettings,u5]),P0.useEffect(()=>{var K6,T6;(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.createdSorts)!=null&&T6.length?h5(!0):h5(!1)},[(ne=(J4=t==null?void 0:t.datasetMetricSettings)==null?void 0:J4.createdSorts)==null?void 0:ne.length]),P0.useEffect(()=>{var K6,T6;(M1==null?void 0:M1.chartType)===m0.timeSeries&&((T6=(K6=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:K6.groupBySettings)!=null&&T6.value)&&!u5&&o9(r9=>{var I8,B9,D8;return{...r9,xAxis:`${(D8=(B9=(I8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:I8.groupBySettings)==null?void 0:B9.value)==null?void 0:D8.toLowerCase()} of ${E7}`}})},[j3,M1==null?void 0:M1.chartType,M1==null?void 0:M1.timeSeriesSettings,u5]),P0.useEffect(()=>{var K6;if(M1!=null&&M1.isEnableComparisonFilter&&[m0.line].includes(M1==null?void 0:M1.chartType)){const T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings,r9=(T6==null?void 0:T6.selectedMetrics)||[],I8=Object==null?void 0:Object.keys((j3==null?void 0:j3[0])||{});o9(B9=>({...B9,yAxisList:[...I8.filter(D8=>r9==null?void 0:r9.some(n5=>D8.startsWith(n5.alias)))]}))}},[j3,M1==null?void 0:M1.isEnableComparisonFilter,W3,M1==null?void 0:M1.chartType]);const n6=P0.useCallback((K6,T6,r9,I8,B9,D8)=>{Q==null||Q(o70,t==null?void 0:t.id),Y7(I8?n5=>n5==null?void 0:n5.map(y5=>{var V5,f4;return y5.name===K6?{...y5,value:T6,options:(V5=y5.options)==null?void 0:V5.map(R5=>T6===R5.name?{...R5,...I8,timeGrainValue:D8}:R5),variableOptions:(f4=y5.variableOptions)==null?void 0:f4.map(R5=>R5.value===T6?{...R5,...I8,timeGrainValue:D8}:R5),selectedVariableValue:{value:T6,label:T6,endDate:I8.endDate,startDate:I8.startDate,timeGrainValue:D8}}:y5}):B9?n5=>n5==null?void 0:n5.map(y5=>y5.name===K6?{...y5,value:B9!=null&&B9.length?B9==null?void 0:B9.map(V5=>V5.value):void 0,selectedDropdownValue:B9!=null&&B9.length?B9:void 0}:y5):n5=>n5==null?void 0:n5.map(y5=>y5.name===K6?{...y5,value:T6,selectedVariableValue:{value:T6,label:T6},selectedDropdownValue:{value:T6,label:r9||T6}}:y5))},[]),o6=P0.useCallback(K6=>{var T6,r9;K6!=null&&K6.event&&((r9=(T6=K6==null?void 0:K6.event)==null?void 0:T6.event)==null||r9.preventDefault()),t0(K6)},[y7]),{getUnderlyingData:g8}=Y70({clientName:o,dbName:(l1=t==null?void 0:t.companyIntegration)==null?void 0:l1.name,tenancyType:a,values:U9,companyId:t==null?void 0:t.companyId,query:eg(t==null?void 0:t.query,t==null?void 0:t.companyId),workspaceId:g,metricId:t==null?void 0:t.id,rlsConditions:M8,globalFilters:n,isAllClient:!!u,dataMartRelationships:B5,customSql:(Z3=(z1=t==null?void 0:t.clickActions)==null?void 0:z1.underlyingData)==null?void 0:Z3.sql,isEnableCustomSQL:(M1==null?void 0:M1.chartType)===m0.singleValue&&((X7=(H3=t==null?void 0:t.clickActions)==null?void 0:H3.underlyingData)==null?void 0:X7.isEnable)&&((Q1=(i3=t==null?void 0:t.clickActions)==null?void 0:i3.underlyingData)==null?void 0:Q1.sql),datasourceId:D}),J3=P0.useMemo(()=>Array.isArray(j3)&&j3.length&&(z3!=null&&z3.name)?j3==null?void 0:j3.map(K6=>{const T6=Object.entries(K6).find(([,r9])=>(typeof r9=="number"&&typeof(z3==null?void 0:z3.name)=="string"?r9==null?void 0:r9.toString():r9)===z3.name);return T6==null?void 0:T6[0]}).filter(K6=>K6)[0]:"",[j3,z3==null?void 0:z3.name]),A8=async(K6,T6,r9,I8)=>{var ze,Qt,re,Le,Ci,Kn,le,qt,br,Ar,gn,hn,Tr,Rn,Eo,Jn,Un,Xi,Ki,Oi,Oo,Vr,Hi,po,aa,Ea,Yo;const B9=t==null?void 0:t.datasetMetricSettings;if(!(D7!=null&&D7.configV2)||!((ze=B9==null?void 0:B9.newDatasetSettings)!=null&&ze.configuration)||!((Qt=t==null?void 0:t.companyIntegration)!=null&&Qt.name)||!K6)return;let D8=K6;const n5=(D8==null?void 0:D8.levels)||[],y5=n5==null?void 0:n5.find(ve=>r9?ve.index===r9:ve==null?void 0:ve.isEnable),V5=n5==null?void 0:n5.findIndex(ve=>r9?ve.index===r9:ve==null?void 0:ve.isEnable),f4=V5>=0&&V5<(n5==null?void 0:n5.length)-1,R5=f4?n5==null?void 0:n5[V5+1]:n5==null?void 0:n5[0],R6=T6==null?void 0:T6.name,k8=(T6==null?void 0:T6.rowFilters)||[],J9=(Le=(re=y5==null?void 0:y5.dimensions)==null?void 0:re[0])==null?void 0:Le.alias;!y5||I8?D8={...D8||{},levels:((Ci=D8==null?void 0:D8.levels)==null?void 0:Ci.map((ve,xr)=>xr==0?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:r9&&y5?D8={...D8||{},levels:((Kn=D8==null?void 0:D8.levels)==null?void 0:Kn.map((ve,xr)=>ve.index===(y5==null?void 0:y5.index)?{...ve,filters:[...(y5==null?void 0:y5.filters)||[]],isEnable:!0}:{...ve,filters:xr>V5?[]:ve==null?void 0:ve.filters,isEnable:!1}))||[]}:(R6&&J9||k8!=null&&k8.length)&&y5?D8={...D8||{},levels:((le=D8==null?void 0:D8.levels)==null?void 0:le.map(ve=>ve.index===(R5==null?void 0:R5.index)?{...ve,filters:f4?[...(y5==null?void 0:y5.filters)||[],...k8!=null&&k8.length?k8:[{columnName:J9,value:R6}]]:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:D8={...D8||{},levels:((qt=D8==null?void 0:D8.levels)==null?void 0:qt.map(ve=>ve.index===(y5==null?void 0:y5.index)?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]},D8={...D8||{},levels:((br=D8==null?void 0:D8.levels)==null?void 0:br.map(ve=>{var xr,Pi;return{...ve,dimensions:((xr=ve==null?void 0:ve.dimensions)==null?void 0:xr.filter(rr=>{var nr,ln;return(ln=(nr=B9==null?void 0:B9.newDatasetSettings)==null?void 0:nr.selectedDims)==null?void 0:ln.some(Hn=>Hn.alias===(rr==null?void 0:rr.alias))}))||[],measures:((Pi=ve==null?void 0:ve.measures)==null?void 0:Pi.filter(rr=>{var nr,ln;return(ln=(nr=B9==null?void 0:B9.newDatasetSettings)==null?void 0:nr.selectedMetrics)==null?void 0:ln.some(Hn=>Hn.alias===(rr==null?void 0:rr.alias))}))||[]}}))||[]};const A5=(Ar=D8==null?void 0:D8.levels)==null?void 0:Ar.find(ve=>ve==null?void 0:ve.isEnable),Qe=!!((Tr=(hn=D8==null?void 0:D8.levels)==null?void 0:hn[((gn=D8==null?void 0:D8.levels)==null?void 0:gn.length)-1])!=null&&Tr.isEnable);(Eo=(Rn=D8==null?void 0:D8.levels)==null?void 0:Rn[0])==null||Eo.isEnable;const xe=(A5==null?void 0:A5.chartSettings)||M1,ge=(xe==null?void 0:xe.chartType)===m0.table,Ct=[...((Jn=A5==null?void 0:A5.dimensions)==null?void 0:Jn.map(ve=>ve.alias))||[],...((Un=A5==null?void 0:A5.measures)==null?void 0:Un.map(ve=>ve.alias))||[]],ye={...xe,xAxis:((Ki=(Xi=A5==null?void 0:A5.dimensions)==null?void 0:Xi[0])==null?void 0:Ki.alias)||"",yAxisList:Qe&&!(xe!=null&&xe.chartType)||ge?Ct:((Oi=A5==null?void 0:A5.measures)==null?void 0:Oi.map(ve=>ve.alias))||[],chartType:Qe&&!(xe!=null&&xe.chartType)?m0.table:xe==null?void 0:xe.chartType},j4=`${(Hi=(Vr=(Oo=A5==null?void 0:A5.dimensions)==null?void 0:Oo[0])==null?void 0:Vr.table)==null?void 0:Hi.schemaName}.${(Ea=(aa=(po=A5==null?void 0:A5.dimensions)==null?void 0:po[0])==null?void 0:aa.table)==null?void 0:Ea.tableName}`;if(_6(ve=>{var xr;return{...ve,configV2:{...D8||{},levels:((xr=D8==null?void 0:D8.levels)==null?void 0:xr.map(Pi=>Pi.index===(A5==null?void 0:A5.index)?{...Pi,chartSettings:ye}:Pi))||[]}}}),o9(ve=>ye),(Yo=t==null?void 0:t.drillDownSettings)!=null&&Yo.isEnableCrossFilter){const ve=(()=>{var xr;if(I8||r9)return[];if((R6&&J9||k8!=null&&k8.length)&&y5){if(k8!=null&&k8.length){const Pi=(xr=k8==null?void 0:k8.map(rr=>{var Hn,c9,K5,b4;const nr=(c9=(Hn=B9==null?void 0:B9.newDatasetSettings)==null?void 0:Hn.selectedDims)==null?void 0:c9.find(Pe=>(Pe==null?void 0:Pe.alias)===(rr==null?void 0:rr.columnName)),ln=`${(K5=nr==null?void 0:nr.table)==null?void 0:K5.schemaName}.${(b4=nr==null?void 0:nr.table)==null?void 0:b4.tableName}`;if(nr)return{columnName:rr==null?void 0:rr.columnName,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[rr==null?void 0:rr.value],tableName:a==="DATABASE"?`${o}.${ln==null?void 0:ln.split(".").slice(1).join(".")}`:ln,value:[rr==null?void 0:rr.value]}}))==null?void 0:xr.filter(rr=>rr);return[...l||[],...Pi]}if(J9&&R6)return[...l||[],{columnName:J9,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[R6],tableName:a==="DATABASE"?`${o}.${j4==null?void 0:j4.split(".").slice(1).join(".")}`:j4,value:[R6]}]}return[]})();C==null||C(ve)}},J8=async(K6,T6)=>{await A8(D7==null?void 0:D7.configV2,K6)},t8=({filters:K6,nextLevel:T6,currentValue:r9})=>{var Ct,ye;const I8=(Ct=t==null?void 0:t.datasetMetricSettings)==null?void 0:Ct.newDatasetSettings,B9=I8==null?void 0:I8.configuration,D8=(I8==null?void 0:I8.selectedDims)||[],n5=(I8==null?void 0:I8.selectedMetrics)||[],y5=((ye=t==null?void 0:t.datasetMetricSettings)==null?void 0:ye.createdSorts)||[],{headerColumns:V5,nonHeaderColumns:f4}=D8.reduce((j4,ze)=>{var Qt,re;return(re=(Qt=M1==null?void 0:M1.pivotTableSettings2)==null?void 0:Qt.headers)!=null&&re.includes(ze.alias)?j4.headerColumns.push(ze):j4.nonHeaderColumns.push(ze),j4},{headerColumns:[],nonHeaderColumns:[]}),R5=K6==null?void 0:K6.map(j4=>`${j4.columnName};;${j4.value}`).join(";;");s5(j4=>({...j4,data:j4.data.filter(ze=>ze.key!==R5),error:"",isLoading:!0,currentValue:r9}));const R6=f4.slice(0,T6),k8=K6==null?void 0:K6.map(j4=>{const ze=D8.find(Qt=>Qt.alias===j4.columnName);if(ze)return{alias:ze.alias||"",columnName:ze.name,dataType:ze.datatype,method:"=",parentAlias:ze.parentAlias,type:"dimension",value:j4.value,relationOperator:"AND"}}).filter(j4=>j4),J9=[...R6,...n5,...V5],{aggregates:A5,dimensions:Qe}=Hu(J9),xe=Yq2(y5),ge={...B9,dimensions:Qe,aggregates:A5,filters:[...B9.filters,...k8],orders:(xe==null?void 0:xe.filter(j4=>(j4==null?void 0:j4.type)==="selected_column"?J9==null?void 0:J9.some(ze=>(ze==null?void 0:ze.alias)===(j4==null?void 0:j4.name)):!0))||[],isApplyGlobalFilter:!0,isApplyMetricFilter:!0,globalFilters:n,rlsConditions:M8};x7({data:{configuration:ge,id:g,datasourceId:D,dashboardId:"",isCreateMetric:!0},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(j4){const ze=j4==null?void 0:j4.error,Qt=j4==null?void 0:j4.data;ze!=null&&ze.message?s5(re=>({...re,error:ze==null?void 0:ze.message,isLoading:!1,currentValue:""})):(s5(re=>({data:[...re.data,{key:R5,data:Array.isArray(Qt)?Qt:[]}],error:"",isLoading:!1,currentValue:""})),o9(re=>{var Le,Ci;return{...re,pivotTableSettings2:{...M1==null?void 0:M1.pivotTableSettings2,dimensions:fy(R6,((Le=t==null?void 0:t.companyIntegration)==null?void 0:Le.name)||""),headers:fy(V5,((Ci=t==null?void 0:t.companyIntegration)==null?void 0:Ci.name)||"")}}}))}})},a9=P0.useCallback(async(K6,T6)=>{await A8(D7==null?void 0:D7.configV2,void 0,K6,T6)},[D7==null?void 0:D7.configV2]),u8=P0.useCallback(K6=>{var T6;if(K6)Y7(r9=>[...r9==null?void 0:r9.filter(I8=>I8.group!==`${W3}`)]),d7(r9=>r9-1);else{const r9=(T6=y7.filter(I8=>!(I8!=null&&I8.group)))==null?void 0:T6.map(I8=>{var B9,D8,n5,y5;return{...I8,name:`${I8==null?void 0:I8.name}_${W3+1}`,group:`${W3+1}`,dependOn:I8.dependOn?{value:`${(B9=I8.dependOn)==null?void 0:B9.value}_${W3+1}`,label:`${(D8=I8.dependOn)==null?void 0:D8.label}_${W3+1}`,customColumnName:(n5=I8.dependOn)==null?void 0:n5.customColumnName}:void 0,dependOns:((y5=I8==null?void 0:I8.dependOns)==null?void 0:y5.map(V5=>({value:`${V5==null?void 0:V5.value}_${W3+1}`,label:`${V5==null?void 0:V5.label}_${W3+1}`,customColumnName:V5==null?void 0:V5.customColumnName})))||[]}});r9.length&&(Y7(I8=>[...I8,...r9]),d7(I8=>I8+1))}},[y7]),k9=P0.useCallback(async()=>{v1.report?A3(K6=>({...K6,isOpen:!0})):(A3({report:"",isLoading:!0,isOpen:!0}),await s7({data:{data:j3,wId:g},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(K6){const T6=K6==null?void 0:K6.content;A3(r9=>({...r9,report:T6||"",isLoading:!1}))},onError(){A3(K6=>({...K6,report:"",isLoading:!1}))}}))},[j3,o,A,f,d,o,v1]),P5=P0.useMemo(()=>{var V5,f4,R5,R6,k8,J9;const K6=(V5=t==null?void 0:t.datasetMetricSettings)==null?void 0:V5.newDatasetSettings,T6=K6==null?void 0:K6.configuration,r9=IR(j3||[]);let I8=r9;const B9=((f4=K6==null?void 0:K6.selectedDims)==null?void 0:f4.some(A5=>{var Qe,xe,ge;return El.includes(((xe=(Qe=A5==null?void 0:A5.cast)==null?void 0:Qe.value)==null?void 0:xe.toLowerCase())||((ge=A5==null?void 0:A5.datatype)==null?void 0:ge.toLowerCase())||"")}))||Fq2((j3==null?void 0:j3[0])||""),D8=((R5=K6==null?void 0:K6.selectedDims)==null?void 0:R5.length)>1&&((R6=K6==null?void 0:K6.selectedMetrics)==null?void 0:R6.length)>0,n5=[m0.pivot,m0.pivotV2,m0.pivotV3,m0.timeSeries,m0.treeMap,m0.indianMap,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap],y5=!!((k8=T6==null?void 0:T6.aggregates)!=null&&k8.length)&&!!((J9=T6==null?void 0:T6.dimensions)!=null&&J9.length);return y5&&B9&&(I8=[...r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5))),...n5]),y5&&!B9&&(I8=[...r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5))),...n5==null?void 0:n5.filter(A5=>A5!==m0.timeSeries)]),!y5&&B9&&(I8=[...r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5))),m0.timeSeries]),!y5&&!B9&&(I8=r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5)))),D7!=null&&D7.isEnableGroupBy&&(D7!=null&&D7.configV2)&&(I8=I8==null?void 0:I8.filter(A5=>Mb==null?void 0:Mb.includes(A5))),D8||(I8=I8==null?void 0:I8.filter(A5=>A5!==m0.bubbleV2)),I8},[j3,M1==null?void 0:M1.xAxis,D7==null?void 0:D7.isEnableGroupBy,D7==null?void 0:D7.configV2,(V6=(T7=(y3=t==null?void 0:t.datasetMetricSettings)==null?void 0:y3.newDatasetSettings)==null?void 0:T7.configuration)==null?void 0:V6.aggregates,(i9=(V8=(r8=t==null?void 0:t.datasetMetricSettings)==null?void 0:r8.newDatasetSettings)==null?void 0:V8.configuration)==null?void 0:i9.dimensions]),s9=K6=>{var y5,V5,f4;const T6=(y5=t==null?void 0:t.datasetMetricSettings)==null?void 0:y5.newDatasetSettings,r9=T6==null?void 0:T6.configuration,I8=(T6==null?void 0:T6.selectedDims)||[],B9=(T6==null?void 0:T6.selectedMetrics)||[],D8=(V5=t==null?void 0:t.companyIntegration)==null?void 0:V5.name,n5=(f4=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:f4.isEnabled;Uq2({chartAggregateColumns:lW(fy((B9==null?void 0:B9.filter(R5=>{var R6,k8;return R5.configType==="AGGREGATE"&&n5?(k8=(R6=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:R6.measures)==null?void 0:k8.some(J9=>J9.value===R5.alias):!0}))||[],D8),j3||[]),chartDimensions:lW(fy((I8==null?void 0:I8.filter(R5=>{var R6,k8;return n5?(k8=(R6=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:R6.dimensions)==null?void 0:k8.some(J9=>J9.value===R5.alias):!0}))||[],D8),j3||[]),chartMetrics:lW(fy((B9==null?void 0:B9.filter(R5=>{var R6,k8;return n5?(k8=(R6=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:R6.measures)==null?void 0:k8.some(J9=>J9.value===R5.alias):!0}))||[],D8),j3||[]),chartSettings:M1,chartTimeColumns:fy(I8==null?void 0:I8.filter(R5=>{var R6;return El.includes((R6=R5.datatype)==null?void 0:R6.toLowerCase())}),D8),chartType:K6,configAggregates:r9==null?void 0:r9.aggregates,configuration:T6==null?void 0:T6.configuration,pivotHeaderColumns:[],resultData:j3||[],setChartSettings:o9})},X5=P0.useMemo(()=>GP(y7.filter(K6=>K6.group&&K6.isAddOnMetrics&&!K6.isAppFilter),"group"),[y7]),U5=P0.useMemo(()=>{var r9,I8;return((r9=M1==null?void 0:M1.customSettings)==null?void 0:r9.comparisonValueShow)&&(M1==null?void 0:M1.chartType)===m0.singleValue?(I8=n==null?void 0:n.filters)==null?void 0:I8.find(B9=>(B9==null?void 0:B9.as)==="date"):void 0},[(S9=M1==null?void 0:M1.customSettings)==null?void 0:S9.comparisonValueShow,M1==null?void 0:M1.chartType,(D3=n==null?void 0:n.filters)==null?void 0:D3.find(K6=>(K6==null?void 0:K6.as)==="date")]);P0.useEffect(()=>{j3!=null&&j3.length&&c8.length?K8(!0):K8(!1)},[j3,c8.length,t==null?void 0:t.integrationName,t==null?void 0:t.query]);const z5=P0.useMemo(()=>{var K6,T6,r9,I8,B9,D8;return(r9=(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)==null?void 0:T6.selectedMetrics)!=null&&r9.some(n5=>n5.configType==="AGGREGATE")?((D8=(B9=(I8=t==null?void 0:t.datasetMetricSettings)==null?void 0:I8.newDatasetSettings)==null?void 0:B9.selectedDims)==null?void 0:D8.map(n5=>({value:n5.alias,label:n5.alias})))||[]:[]},[(E6=t==null?void 0:t.datasetMetricSettings)==null?void 0:E6.newDatasetSettings]),G5=P0.useMemo(()=>{var K6,T6,r9;return((r9=(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)==null?void 0:T6.selectedMetrics)==null?void 0:r9.map(I8=>({value:(I8==null?void 0:I8.alias)||(I8==null?void 0:I8.name),label:(I8==null?void 0:I8.alias)||(I8==null?void 0:I8.name)})))||[]},[(h6=(O7=t==null?void 0:t.datasetMetricSettings)==null?void 0:O7.newDatasetSettings)==null?void 0:h6.selectedMetrics]),{metricFilters:Z4,leftPositionedMetricFilters:T5,rightPositionedMetricFilters:d8}=P0.useMemo(()=>{const K6=y7.filter(B9=>!B9.isAppFilter);let T6=K6.filter(B9=>B9.isAddOnMetrics);N2&&(T6=T6.filter(B9=>vR(B9,!0)));const r9=[],I8=[];return T6.forEach(B9=>{B9.position==="top-right"?I8.push(B9):r9.push(B9)}),{metricFilters:K6,leftPositionedMetricFilters:r9,rightPositionedMetricFilters:I8}},[y7]),n9=[m0.pie,m0.doughnut,m0.rose,m0.funnel,m0.singleValue,m0.table,m0.pivot,m0.horizontalStackTable,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.sankey,m0.timeSeries,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap,m0.boxplot,m0.timeSeries,m0.gantt].includes(M1==null?void 0:M1.chartType)||((M1==null?void 0:M1.isMultiDimension)||(M1==null?void 0:M1.isDynamicSeries))&&(M1==null?void 0:M1.seriesField)!=="ungrouped",i8=P0.useMemo(()=>{var T6;const K6=((T6=t==null?void 0:t.dataSecuritySettings)==null?void 0:T6.csvColumns)||[];return j3!=null&&j3.length?j3==null?void 0:j3.map(r9=>{const I8={};for(const B9 in r9)K6!=null&&K6.includes(B9)||(I8[B9]=r9[B9]);return I8}):[]},[j3,t==null?void 0:t.dataSecuritySettings]);P0.useEffect(()=>{var K6,T6;M1||(o9(t==null?void 0:t.chartOptions),L3({limit:parseInt(((T6=(K6=t==null?void 0:t.chartOptions)==null?void 0:K6.tableSettings)==null?void 0:T6.defaultRowSize)||"100",10),offset:0}))},[t==null?void 0:t.chartOptions,M1]),P0.useEffect(()=>{var K6,T6,r9,I8,B9,D8,n5,y5,V5,f4;if((M1==null?void 0:M1.chartType)===m0.timeSeries&&((T6=(K6=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:K6.groupBySettings)!=null&&T6.isGlobalFilter)&&E7){const R5=(I8=(r9=n==null?void 0:n.filters)==null?void 0:r9.find(R6=>{var k8,J9,A5;return R6.label===((A5=(J9=(k8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:k8.groupBySettings)==null?void 0:J9.globalFilterOption)==null?void 0:A5.value)}))==null?void 0:I8.value;if((typeof R5=="string"||typeof R5=="object"&&(R5!=null&&R5.value))&&R5){const R6=typeof R5=="string"?(B9=kb(R5))==null?void 0:B9.toLowerCase():((f4=(V5=(y5=(n5=(D8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:D8.groupBySettings)==null?void 0:n5.formatWithValue)==null?void 0:y5.find(k8=>k8.value===kb(R5==null?void 0:R5.value)))==null?void 0:V5.format)==null?void 0:f4.toLowerCase())||"";vC!=null&&vC.find(k8=>{var J9;return((J9=k8==null?void 0:k8.value)==null?void 0:J9.toLowerCase())===R6})&&o9(k8=>{var J9;return{...k8,timeSeriesSettings:{...k8==null?void 0:k8.timeSeriesSettings,groupBySettings:{...(J9=k8==null?void 0:k8.timeSeriesSettings)==null?void 0:J9.groupBySettings,value:R6}},xAxis:u5?k8.xAxis:`${R6} of ${E7}`}})}}},[n,M1==null?void 0:M1.chartType,(F8=(Z6=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:Z6.groupBySettings)==null?void 0:F8.isGlobalFilter,(_8=(E8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:E8.groupBySettings)==null?void 0:_8.globalFilterOption,E7]),P0.useEffect(()=>{var K6,T6,r9,I8;M1!=null&&M1.isDynamicSeries&&((K6=M1==null?void 0:M1.seriesOptions)!=null&&K6.includes("ungrouped")?M1!=null&&M1.ungroupedAlias?b5((T6=M1==null?void 0:M1.seriesOptions)==null?void 0:T6.map(B9=>B9==="ungrouped"?{value:B9,label:M1==null?void 0:M1.ungroupedAlias}:{value:B9,label:B9})):b5((r9=M1==null?void 0:M1.seriesOptions)==null?void 0:r9.map(B9=>({value:B9,label:B9}))):b5([...((I8=M1==null?void 0:M1.seriesOptions)==null?void 0:I8.map(B9=>({value:B9,label:B9})))??[]]))},[M1==null?void 0:M1.seriesOptions,M1==null?void 0:M1.isDynamicSeries,M1==null?void 0:M1.ungroupedAlias]);const[B6,e5]=P0.useState(!1),E9=K6=>{K6.key==="Control"&&e5(!0)},A9=K6=>{K6.key==="Control"&&e5(!1)};P0.useEffect(()=>{j3!=null&&j3.length&&L6(Object.keys((j3==null?void 0:j3[0])||{}))},[j3==null?void 0:j3.length]),P0.useEffect(()=>{var K6,T6;return(T6=(K6=M1==null?void 0:M1.customSettings)==null?void 0:K6.chartZoom)!=null&&T6.isZoomEnabled&&(window.addEventListener("keydown",E9),window.addEventListener("keyup",A9)),()=>{window.removeEventListener("keydown",E9),window.removeEventListener("keyup",A9)}},[]);const p9=P0.useMemo(()=>{let K6=!1;if(j3!=null&&j3.length){const T6=M1==null?void 0:M1.singleValue;K6=j3[0][T6]===null&&(M1==null?void 0:M1.chartType)==="singleValue"}return K6},[j3==null?void 0:j3.length,M1==null?void 0:M1.singleValue,(M1==null?void 0:M1.chartType)==="singleValue"]),d5=P0.useMemo(()=>ud({chartOptions:M1,data:j3||[]}),[j3,M1==null?void 0:M1.xAxis,M1==null?void 0:M1.yAxisList,(R9=M1==null?void 0:M1.dynamicXAxis)==null?void 0:R9.isEnabled,M1==null?void 0:M1.chartType,M1==null?void 0:M1.seriesField,(Z8=M1==null?void 0:M1.customSettings)==null?void 0:Z8.cumulativeBar,M1==null?void 0:M1.isGroupXAxis,(r5=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:r5.seriesType[0],(c5=(t5=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:t5.groupBySettings)==null?void 0:c5.fillXAxis]),C5=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.name)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.name,b8,J,k]),W6=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.longDescription)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.longDescription,b8,k,J]),e9=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.description)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.description,b8,k,J]),Y9=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.footNote)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.footNote,b8,k,J]),P9=P0.useMemo(()=>{var K6;return`${((K6=j3==null?void 0:j3[0])==null?void 0:K6.dbn_metric_expression_data)||"No Data Found"}`},[j3]),C9=P0.useMemo(()=>{var K6;return(K6=t==null?void 0:t.rlsConditions)==null?void 0:K6.map(T6=>{var I8,B9,D8,n5;if((T6==null?void 0:T6.datatype)==="date"&&((I8=T6==null?void 0:T6.options)==null?void 0:I8.find(y5=>y5.range==="Custom Date"))&&(T6==null?void 0:T6.isEnableDynamicDate)&&((B9=T6==null?void 0:T6.dynamicDate)==null?void 0:B9.value)){const y5=$s2(((D8=Tb==null?void 0:Tb.find(R5=>{var R6;return R5.value===((R6=T6==null?void 0:T6.dynamicDate)==null?void 0:R6.value)}))==null?void 0:D8.count)||0),V5=qc(y5),f4=qc(y5);return{...T6,options:(n5=T6==null?void 0:T6.options)==null?void 0:n5.map(R5=>R5.range==="Custom Date"?{...R5,startDate:y5,endDate:y5,timeGrainValue:`${V5} - ${f4}`}:R5)}}return T6})},[t==null?void 0:t.rlsConditions]);P0.useLayoutEffect(()=>{Q6&&(y==null||y(K6=>{const T6=new Map(K6);return T6.set(t==null?void 0:t.id,{data:{data:[],name:"",description:""},isLoading:Q6,key:""}),T6})),e7!=null&&e7.data&&E&&(y==null||y(K6=>{const T6=new Map(K6);return T6.set(t==null?void 0:t.id,{data:{data:e7==null?void 0:e7.data,name:(t==null?void 0:t.name)||"",description:(t==null?void 0:t.description)||""},isLoading:Q6,key:JSON.stringify(W8)}),T6}))},[e7==null?void 0:e7.data,Q6]);const I4=()=>{var T6,r9,I8;return(((I8=(r9=(T6=t==null?void 0:t.elementSettings)==null?void 0:T6.summary)==null?void 0:r9.metricList)==null?void 0:I8.map(B9=>{var D8;return(D8=E==null?void 0:E.get(B9==null?void 0:B9.value))==null?void 0:D8.isLoading}))||[]).some(B9=>B9===!0)};P0.useLayoutEffect(()=>{var K6,T6,r9,I8,B9,D8,n5,y5,V5,f4,R5;if((T6=(K6=t==null?void 0:t.elementSettings)==null?void 0:K6.summary)!=null&&T6.metricList&&(E!=null&&E.get(t==null?void 0:t.id))&&!p0&&!I4()){const R6=((B9=(I8=(r9=t==null?void 0:t.elementSettings)==null?void 0:r9.summary)==null?void 0:I8.metricList)==null?void 0:B9.map(k8=>{var J9,A5,Qe,xe,ge,Ct,ye,j4,ze;return{data:(Qe=(A5=(J9=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:J9.data)==null?void 0:A5.data)!=null&&Qe.length?(ge=(xe=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:xe.data)==null?void 0:ge.data:{},metricName:(ye=(Ct=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:Ct.data)==null?void 0:ye.name,metricDescription:(ze=(j4=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:j4.data)==null?void 0:ze.description}}))||[];x0(""),t1(""),!R6.some(k8=>Object.keys(k8.data).length===0)&&!p0&&(U0(()=>!0),E0.mutate({data:{metricData:R6,summaryPrompt:(n5=(D8=t==null?void 0:t.elementSettings)==null?void 0:D8.summary)==null?void 0:n5.summaryPrompt,id:t==null?void 0:t.id,filters:`${(R5=(f4=(V5=(y5=t==null?void 0:t.elementSettings)==null?void 0:y5.summary)==null?void 0:V5.metricList)==null?void 0:f4.map(k8=>{var J9;return(J9=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:J9.key}))==null?void 0:R5.join("###")}`,name:t==null?void 0:t.name,description:t==null?void 0:t.description,workspaceId:g},token:f||"",clientId:A?d||"":o,isFrontendApp:A},{onSuccess:k8=>{k8.summary?(x0(k8.summary),t1("")):(t1(H02),x0("")),U0(()=>!1)},onSettled:()=>{U0(()=>!1)},onError:k8=>{U0(()=>!1),t1(k8.message),x0("")}}))}},[t==null?void 0:t.elementSettings,E]),P0.useEffect(()=>{var I8,B9,D8,n5,y5,V5,f4,R5,R6,k8,J9,A5,Qe,xe,ge,Ct,ye,j4,ze,Qt,re,Le,Ci,Kn;const K6=fc(((I8=M1==null?void 0:M1.customSettings)==null?void 0:I8.comboAxisSettings)||[]),T6=(B9=K6==null?void 0:K6.map(le=>le==null?void 0:le.measures))==null?void 0:B9.flat(),r9=(D8=M1==null?void 0:M1.yAxisList)==null?void 0:D8.every(le=>T6==null?void 0:T6.includes(le));if((n5=M1==null?void 0:M1.yAxisList)!=null&&n5.length&&((y5=M1==null?void 0:M1.yAxisList)==null?void 0:y5.length)!==(T6==null?void 0:T6.length)&&!(T6!=null&&T6.length)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((M1==null?void 0:M1.chartType)||"")){const le=(f4=(V5=M1==null?void 0:M1.yAxisList)==null?void 0:V5.filter(hn=>{var Tr;return!((Tr=M1==null?void 0:M1.comboBarList)!=null&&Tr.includes(hn))}))==null?void 0:f4.filter(hn=>!(T6!=null&&T6.includes(hn))),qt=((R6=(R5=M1==null?void 0:M1.customSettings)==null?void 0:R5.comboStackAxisSymbols)==null?void 0:R6.name)||"",br=(A5=(J9=(k8=M1==null?void 0:M1.customSettings)==null?void 0:k8.comboLabelFormatter)==null?void 0:J9.find(hn=>hn.axis===(qt||"stack")))==null?void 0:A5.formatter,Ar=(Qe=M1==null?void 0:M1.comboBarList)==null?void 0:Qe.join(" and "),gn=(Ct=(ge=(xe=M1==null?void 0:M1.customSettings)==null?void 0:xe.comboLabelFormatter)==null?void 0:ge.find(hn=>hn.axis===Ar))==null?void 0:Ct.formatter;o9(hn=>{var Tr,Rn,Eo,Jn,Un,Xi,Ki,Oi,Oo,Vr,Hi,po,aa,Ea,Yo,ve,xr,Pi,rr;return{...hn,customSettings:{...hn.customSettings,comboAxisSettings:fc([...((Tr=hn.customSettings)==null?void 0:Tr.comboAxisSettings)||[],...le==null?void 0:le.map(nr=>{var c9,K5,b4,Pe,Br,at;const ln=(b4=(K5=(c9=M1==null?void 0:M1.customSettings)==null?void 0:c9.comboLabelFormatter)==null?void 0:K5.find(ft=>ft.axis===nr))==null?void 0:b4.formatter,Hn=(Br=(Pe=M1==null?void 0:M1.customSettings)==null?void 0:Pe.comboAxisSymbols)==null?void 0:Br.find(ft=>ft.name===nr);return{axis:nr,measures:[nr],chartTypes:[{axis:nr,type:"line"}],numberFormatter:(at=M1==null?void 0:M1.customSettings)==null?void 0:at.numberFormatter,labelFormatter:ln,prefix:(Hn==null?void 0:Hn.prefix)||"",suffix:(Hn==null?void 0:Hn.suffix)||"",isEnableLabelFormatter:!!(ln!=null&&ln.length)}}),...(Rn=M1==null?void 0:M1.comboBarList)!=null&&Rn.length&&((Eo=M1==null?void 0:M1.customSettings)!=null&&Eo.isCombineBarAxis||(Jn=M1==null?void 0:M1.customSettings)!=null&&Jn.isStackBar)?[{axis:(Un=M1==null?void 0:M1.customSettings)!=null&&Un.isStackBar&&qt||Ar,measures:M1==null?void 0:M1.comboBarList,chartTypes:(Xi=M1==null?void 0:M1.comboBarList)==null?void 0:Xi.map(nr=>({axis:nr,type:"bar"})),isEnableStackBar:(Ki=M1==null?void 0:M1.customSettings)==null?void 0:Ki.isStackBar,numberFormatter:(Oi=M1==null?void 0:M1.customSettings)==null?void 0:Oi.numberFormatter,...(Oo=M1==null?void 0:M1.customSettings)!=null&&Oo.isStackBar?{prefix:((Hi=(Vr=M1==null?void 0:M1.customSettings)==null?void 0:Vr.comboStackAxisSymbols)==null?void 0:Hi.prefix)||"",suffix:((aa=(po=M1==null?void 0:M1.customSettings)==null?void 0:po.comboStackAxisSymbols)==null?void 0:aa.suffix)||"",labelFormatter:br,isEnableLabelFormatter:!!(br!=null&&br.length)}:{prefix:((Ea=M1==null?void 0:M1.customSettings)==null?void 0:Ea.combinedAxisPrefix)||"",suffix:((Yo=M1==null?void 0:M1.customSettings)==null?void 0:Yo.combinedAxisSuffix)||"",labelFormatter:gn,isEnableLabelFormatter:!!(gn!=null&&gn.length)}}]:[],...(ve=M1==null?void 0:M1.comboBarList)!=null&&ve.length&&!((xr=M1==null?void 0:M1.customSettings)!=null&&xr.isCombineBarAxis)&&!((Pi=M1==null?void 0:M1.customSettings)!=null&&Pi.isStackBar)?(rr=M1==null?void 0:M1.comboBarList)==null?void 0:rr.map(nr=>{var c9,K5,b4,Pe,Br,at;const ln=(b4=(K5=(c9=M1==null?void 0:M1.customSettings)==null?void 0:c9.comboLabelFormatter)==null?void 0:K5.find(ft=>ft.axis===nr))==null?void 0:b4.formatter,Hn=(Br=(Pe=M1==null?void 0:M1.customSettings)==null?void 0:Pe.comboAxisSymbols)==null?void 0:Br.find(ft=>ft.name===nr);return{axis:nr,measures:[nr],chartTypes:[{axis:nr,type:"bar"}],numberFormatter:(at=M1==null?void 0:M1.customSettings)==null?void 0:at.numberFormatter,labelFormatter:ln,prefix:(Hn==null?void 0:Hn.prefix)||"",suffix:(Hn==null?void 0:Hn.suffix)||"",isEnableLabelFormatter:!!(ln!=null&&ln.length)}}):[]].filter(nr=>{var ln;return(ln=nr==null?void 0:nr.measures)==null?void 0:ln.length})),comboAxisSymbols:[],combinedAxisPrefix:"",combinedAxisSuffix:"",comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}})}if(T6!=null&&T6.length&&((ye=M1==null?void 0:M1.yAxisList)!=null&&ye.length)&&(((j4=M1==null?void 0:M1.yAxisList)==null?void 0:j4.length)!==(T6==null?void 0:T6.length)||((ze=M1==null?void 0:M1.yAxisList)==null?void 0:ze.length)===(T6==null?void 0:T6.length)&&!r9)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((M1==null?void 0:M1.chartType)||"")){const le=(Qt=M1==null?void 0:M1.yAxisList)==null?void 0:Qt.filter(br=>!(T6!=null&&T6.includes(br))),qt=T6==null?void 0:T6.filter(br=>{var Ar;return!((Ar=M1==null?void 0:M1.yAxisList)!=null&&Ar.includes(br))});qt==null||qt.forEach(br=>{var Tr,Rn,Eo;const Ar=(Rn=(Tr=M1==null?void 0:M1.customSettings)==null?void 0:Tr.comboAxisSettings)==null?void 0:Rn.find(Jn=>{var Un;return(Un=Jn.measures)==null?void 0:Un.includes(br)}),gn=Ar==null?void 0:Ar.axis,hn=(((Eo=Ar==null?void 0:Ar.measures)==null?void 0:Eo.length)||0)>1;o9(Jn=>{var Un,Xi,Ki,Oi,Oo;return{...Jn,customSettings:{...Jn.customSettings,comboAxisSettings:fc(hn?((Ki=(Xi=(Un=Jn.customSettings)==null?void 0:Un.comboAxisSettings)==null?void 0:Xi.map(Vr=>{var Hi;return Vr.axis===gn?{...Vr,measures:(Hi=Vr==null?void 0:Vr.measures)==null?void 0:Hi.filter(po=>po!==br)}:Vr}))==null?void 0:Ki.filter(Vr=>{var Hi;return(Hi=Vr==null?void 0:Vr.measures)==null?void 0:Hi.length}))||[]:((Oo=(Oi=Jn.customSettings)==null?void 0:Oi.comboAxisSettings)==null?void 0:Oo.filter(Vr=>{var Hi;return Vr.axis!==gn&&((Hi=Vr==null?void 0:Vr.measures)==null?void 0:Hi.length)}))||[])}}})}),le!=null&&le.length&&o9(br=>{var Ar;return{...br,customSettings:{...br.customSettings,comboAxisSettings:fc([...((Ar=br.customSettings)==null?void 0:Ar.comboAxisSettings)||[],...le==null?void 0:le.map(gn=>({axis:gn,measures:[gn],chartTypes:[{axis:gn,type:"line"}]}))].filter(gn=>{var hn;return(hn=gn==null?void 0:gn.measures)==null?void 0:hn.length})||[])}}})}T6!=null&&T6.length&&((re=M1==null?void 0:M1.yAxisList)!=null&&re.length)&&((Le=M1==null?void 0:M1.yAxisList)==null?void 0:Le.length)===(T6==null?void 0:T6.length)&&r9&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((M1==null?void 0:M1.chartType)||"")&&((Kn=(Ci=M1==null?void 0:M1.customSettings)==null?void 0:Ci.comboAxisSettings)==null?void 0:Kn.length)!==(K6==null?void 0:K6.length)&&o9(le=>({...le,customSettings:{...le==null?void 0:le.customSettings,comboAxisSettings:K6}}))},[M1==null?void 0:M1.yAxisList,(s4=M1==null?void 0:M1.customSettings)==null?void 0:s4.comboAxisSettings,M1==null?void 0:M1.comboBarList,(q4=M1==null?void 0:M1.customSettings)==null?void 0:q4.isCombineBarAxis,(ie=M1==null?void 0:M1.customSettings)==null?void 0:ie.isStackBar,(fe=(Be=M1==null?void 0:M1.customSettings)==null?void 0:Be.comboStackAxisSymbols)==null?void 0:fe.name,(Bt=(it=M1==null?void 0:M1.customSettings)==null?void 0:it.comboStackAxisSymbols)==null?void 0:Bt.prefix,(Cn=(jr=M1==null?void 0:M1.customSettings)==null?void 0:jr.comboStackAxisSymbols)==null?void 0:Cn.suffix,(xn=M1==null?void 0:M1.customSettings)==null?void 0:xn.comboLabelFormatter,(di=M1==null?void 0:M1.customSettings)==null?void 0:di.comboAxisSymbols,(ii=M1==null?void 0:M1.customSettings)==null?void 0:ii.numberFormatter,(oi=M1==null?void 0:M1.customSettings)==null?void 0:oi.combinedAxisPrefix,(Ri=M1==null?void 0:M1.customSettings)==null?void 0:Ri.combinedAxisSuffix,M1==null?void 0:M1.chartType]),P0.useEffect(()=>{var K6,T6,r9;(K6=M1==null?void 0:M1.yAxisList)!=null&&K6.length&&((T6=M1==null?void 0:M1.yAxisList)==null?void 0:T6.length)<5&&(M1==null?void 0:M1.chartType)===m0.boxplot&&o9(I8=>({...I8,chartType:m0.line})),!((r9=M1==null?void 0:M1.yAxisList)!=null&&r9.length)&&(M1==null?void 0:M1.chartType)===m0.funnelV2&&o9(I8=>({...I8,chartType:m0.singleValue}))},[M1==null?void 0:M1.chartType,(Ni=M1==null?void 0:M1.yAxisList)==null?void 0:Ni.length]);const v4=({columnAlias:K6,value:T6,isClear:r9=!1})=>{const I8=t==null?void 0:t.datasetMetricSettings;I8&&Gq2({columnAlias:K6,datasetSettings:I8,setTableColumnFilters:z7,value:T6,isClear:r9})};return P0.useEffect(()=>{var T6,r9,I8,B9;if(!((T6=M1==null?void 0:M1.dynamicYAxis)!=null&&T6.isEnabled)||!((r9=M1==null?void 0:M1.dynamicYAxis)!=null&&r9.selectedOption)||Array.isArray((I8=M1==null?void 0:M1.dynamicYAxis)==null?void 0:I8.selectedOption))return;const K6=(B9=M1==null?void 0:M1.dynamicYAxis)==null?void 0:B9.selectedOption;o9(D8=>({...D8,dynamicYAxis:{...D8==null?void 0:D8.dynamicYAxis,selectedOption:[K6]},yAxisList:[K6==null?void 0:K6.value]}))},[(dn=M1==null?void 0:M1.dynamicYAxis)==null?void 0:dn.selectedOption,(Xr=M1==null?void 0:M1.dynamicYAxis)==null?void 0:Xr.isEnabled]),P0.useEffect(()=>{var I8,B9,D8,n5,y5,V5,f4,R5;const K6=(I8=i2==null?void 0:i2.yAxisSettings)==null?void 0:I8.find(R6=>{var k8,J9,A5,Qe,xe;return((k8=R6==null?void 0:R6.yAxisSettings)==null?void 0:k8.isEnable)&&(R6==null?void 0:R6.id)===(t==null?void 0:t.id)&&((J9=R6==null?void 0:R6.yAxisSettings)==null?void 0:J9.yAxis)&&Array.isArray((A5=R6==null?void 0:R6.yAxisSettings)==null?void 0:A5.yAxis)&&((xe=(Qe=R6==null?void 0:R6.yAxisSettings)==null?void 0:Qe.yAxis)==null?void 0:xe.length)>0}),T6=(B9=i2==null?void 0:i2.xAxisSettings)==null?void 0:B9.find(R6=>{var k8,J9;return((k8=R6==null?void 0:R6.xAxisSettings)==null?void 0:k8.isEnable)&&(R6==null?void 0:R6.id)===(t==null?void 0:t.id)&&((J9=R6==null?void 0:R6.xAxisSettings)==null?void 0:J9.xaxis)});if(!((D8=M1==null?void 0:M1.dynamicYAxis)!=null&&D8.isEnabled)&&!((n5=M1==null?void 0:M1.dynamicXAxis)!=null&&n5.isEnabled)&&!((y5=D7==null?void 0:D7.configV2)!=null&&y5.isEnable)||!K6&&!T6&&!((V5=D7==null?void 0:D7.configV2)!=null&&V5.isEnable)){o9(R6=>(t==null?void 0:t.chartOptions)||R6);return}const r9=(R5=(f4=K6==null?void 0:K6.yAxisSettings)==null?void 0:f4.yAxis)==null?void 0:R5[0];o9(R6=>{var k8,J9,A5,Qe,xe,ge,Ct;return{...R6,dynamicYAxis:{...R6==null?void 0:R6.dynamicYAxis,selectedOption:r9?[r9]:((k8=R6==null?void 0:R6.dynamicYAxis)==null?void 0:k8.selectedOption)||[]},dynamicXAxis:{...R6==null?void 0:R6.dynamicXAxis,selectedOption:(J9=T6==null?void 0:T6.xAxisSettings)!=null&&J9.xaxis?{value:(A5=T6==null?void 0:T6.xAxisSettings)==null?void 0:A5.xaxis,label:(Qe=T6==null?void 0:T6.xAxisSettings)==null?void 0:Qe.xaxis}:((xe=R6==null?void 0:R6.dynamicXAxis)==null?void 0:xe.selectedOption)||[]},yAxisList:r9!=null&&r9.value?[r9==null?void 0:r9.value]:(R6==null?void 0:R6.yAxisList)||[],xAxis:(ge=T6==null?void 0:T6.xAxisSettings)!=null&&ge.xaxis?(Ct=T6==null?void 0:T6.xAxisSettings)==null?void 0:Ct.xaxis:(R6==null?void 0:R6.xAxis)||""}})},[i2==null?void 0:i2.yAxisSettings,t==null?void 0:t.id,i2==null?void 0:i2.xAxisSettings,(gi=M1==null?void 0:M1.dynamicYAxis)==null?void 0:gi.isEnabled,(_i=M1==null?void 0:M1.dynamicXAxis)==null?void 0:_i.isEnabled,(ai=D7==null?void 0:D7.configV2)==null?void 0:ai.isEnable]),P0.useEffect(()=>{var K6,T6,r9;(K6=M1==null?void 0:M1.customSettings)!=null&&K6.isShowDuration&&(M1==null?void 0:M1.chartType)===m0.gantt&&!((r9=(T6=M1==null?void 0:M1.customSettings)==null?void 0:T6.ganttTooltipKeys)!=null&&r9.includes("Duration"))&&o9(I8=>{var B9;return{...I8,customSettings:{...I8==null?void 0:I8.customSettings,ganttTooltipKeys:[...((B9=I8==null?void 0:I8.customSettings)==null?void 0:B9.ganttTooltipKeys)||[],"Duration"]}}})},[(hi=M1==null?void 0:M1.customSettings)==null?void 0:hi.isShowDuration,M1==null?void 0:M1.chartType,(si=M1==null?void 0:M1.customSettings)==null?void 0:si.ganttTooltipKeys]),{elementSummary:M0,elementSummaryError:z2,isLoadingSummary:p0,isMetricListLoading:I4,onDrillLevelClick:a9,onDrillDown:J8,handleChartClick:o6,dataDb:j3,getUnderlyingData:g8,onChangeFilterValue:n6,isShowChartPopup:X6,setShowChartPopup:k6,columnName:J3,chartParams:z3,isQueryLoading:Q6||M2||Y2,isSingleValueNull:p9,dynamicOptions:d4,chartSettings:M1,setChartSettings:o9,isEnableZoom:B6,filterValues:U9,containerRef:G0,drilledLevel:V7.length,dimensions:((en=(Sr=t==null?void 0:t.datasetMetricSettings)==null?void 0:Sr.selectedDimensions)==null?void 0:en.map(K6=>Gs2(K6||"none")))||[],rlsConditions:y7,setRlsConditions:Y7,setTableLimit:L3,isEnableNextBtn:O1>(X2==null?void 0:X2.limit)+(X2==null?void 0:X2.offset),isEnablePrevBtn:(X2==null?void 0:X2.offset)!==0,paginationInfo:{limit:X2==null?void 0:X2.limit,offset:X2==null?void 0:X2.offset,totalRecords:O1},onChangePage:(K6,T6,r9)=>{L3(T6?{limit:T6,offset:0}:I8=>{let B9;return r9||r9===0?B9=r9:K6?B9=I8.offset>I8.limit?I8.offset-I8.limit:0:B9=I8.offset+I8.limit,{limit:I8.limit,offset:B9}})},isExternalChart:((ur=M1==null?void 0:M1.tableSettings)==null?void 0:ur.isServerSidePagination)&&(M1==null?void 0:M1.chartType)===m0.table,isEnablePivotTable:C8,groupByList:c8,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:K6=>{Y7(T6=>T6==null?void 0:T6.map(r9=>r9.name===K6.name&&r9.datatype===K6.datatype&&r9.tableName===K6.tableName&&r9.columnName===K6.columnName?{...r9,isAddOnMetrics:!r9.isAddOnMetrics}:r9))},metricFilters:Z4,leftPositionedMetricFilters:T5,rightPositionedMetricFilters:d8,drillFilters:V7,drillType:(tn=t==null?void 0:t.drillDownSettings)==null?void 0:tn.drillType,tableResultsDownloadData:i8,appliedMetricFilters:M8,pivotHeaderOptions:z5,pivotDrillState:O9,onDrillPivotTable:t8,legendData:d5,timeseriesDimension:E7,isPythonMode:u5,sortOrder:G7,setSortOrder:c6,isNotFirstRender:c7,setNotFirstRender:X3,isSorted:N5,isInavlidForSort:n9,onAddComparison:u8,groupedRlsConditions:X5,onGenerateMetricSummary:k9,summary:v1,setSummary:A3,dataMartRelationships:B5,onChartChange:s9,isCompareValue:w6,isShowChartPropertyPanel:l8,setShowChartPropertyPanel:I9,columnList:u6,variables:b8,metricName:C5,longDescription:W6,footNote:Y9,description:e9,drilldownCols:Y3,switchMeasureOptions:G5,metricExpressionResult:P9,dateFilter:U5,drillDownSettings:D7,enabledCharts:P5,tableColumnFilters:I6,onChangePaginationColumnFilters:v4,queryError:P6||(e7==null?void 0:e7.error),refetchMetricData:f6,customSwitchXAxis:c3,savedMetricFilters:C9||[]}},J70=({metricId:t,onSuccess:n,token:i})=>{const{mutateAsync:o,isLoading:a}=I70();return{handleArchiveMetric:P0.useCallback(async()=>{!t||!i||await o({data:{id:t},token:i},{onSuccess:async r=>{r!=null&&r.error||await n()}})},[o,t]),isLoading:a}},XA2=({token:t,metricId:n})=>{var R2;const[i,o]=P0.useState(!0),{data:a,isLoading:s}=U70(t,n),{externalMetric:r,sharingSettingsId:C,adminTheme:l,params:e,companyId:u,clientId:A,errorMsg:f,clientColumnType:d,isEnableMetricSummary:g,isAllClient:E,isShowUnderlyingData:y,appFilters:Q,mergedMetricsId:R,datasourceId:D,mergedMetricLayout:O,mergedDashboardFilters:k,dashboardAppFilterValues:J,filterLayout:e2,nestedMetric:p2,guestToken:D2}=P0.useMemo(()=>{var Z2,Y2;const M2=a;return{externalMetric:M2==null?void 0:M2.externalMetric,adminTheme:M2==null?void 0:M2.adminTheme,sharingSettingsId:M2==null?void 0:M2.sharingSettingsId,errorMsg:(Z2=M2==null?void 0:M2.error)==null?void 0:Z2.message,params:M2==null?void 0:M2.params,companyId:M2==null?void 0:M2.companyId,clientId:M2==null?void 0:M2.clientId,clientColumnType:M2==null?void 0:M2.cType,isEnableMetricSummary:M2==null?void 0:M2.isEnableMetricSummary,isAllClient:!!(M2!=null&&M2.isAllClient),isShowUnderlyingData:(M2==null?void 0:M2.isShowUnderlyingData)||!1,appFilters:M2==null?void 0:M2.appFilters,mergedMetricsId:M2==null?void 0:M2.mergedMetricsId,datasourceId:(M2==null?void 0:M2.datasourceId)||"",mergedMetricLayout:(M2==null?void 0:M2.mergedMetricLayout)||[],mergedDashboardFilters:(M2==null?void 0:M2.mergedDashboardFilters)||[],dashboardAppFilterValues:M2==null?void 0:M2.dashboardAppFilterValues,filterLayout:(M2==null?void 0:M2.filterLayout)||[],nestedMetric:M2==null?void 0:M2.nestedMetric,guestToken:(Y2=window==null?void 0:window.dbn)!=null&&Y2.isEnableProxyAuth?eg(M2==null?void 0:M2.token,M2==null?void 0:M2.companyId):M2==null?void 0:M2.token}},[a,(R2=window==null?void 0:window.dbn)==null?void 0:R2.isEnableProxyAuth]),{rlsSettings:Q2,tenancyLevel:i2,workspaceId:N2}=P0.useMemo(()=>{var Z2,Y2;if(!e)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const M2=JSON.parse(e);return{rlsSettings:(Z2=M2.rlsSettings)==null?void 0:Z2.find(f0=>f0.metricId===n),tenancyLevel:M2.companyTenancyType||"TABLE",workspaceId:((Y2=M2==null?void 0:M2.workspace)==null?void 0:Y2.id)||""}},[e,n]);return P0.useEffect(()=>{s&&o(!0),(r||f||!s)&&o(!1)},[s,r,f]),{externalMetric:r,sharingSettingsId:C,companyId:u,clientId:A,rlsSettings:Q2,tenancyLevel:i2,isLoading:i,errorMsg:f,adminTheme:l,workspaceId:N2,clientColumnType:d,isEnableMetricSummary:g,isAllClient:E,isShowUnderlyingData:y,appFilters:Q,mergedMetricsId:R,datasourceId:D,mergedMetricLayout:O,mergedDashboardFilters:k,dashboardAppFilterValues:J,filterLayout:e2,nestedMetric:p2,token:D2}},q70=WA2({active:null,over:null,DragPreviewCreateRoot:null,draggables:[],droppables:[]}),KA2=()=>{const[t,n]=yX(q70);return{dndState:t,setActive:r=>{n(C=>({...C,active:r}))},setOver:r=>{n(C=>({...C,over:r}))},setDraggables:r=>{n(C=>{var u;const l=(u=C.draggables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,draggables:[...C.draggables,r]};const e=[...C.draggables];return e[l]=r,{...C,draggables:e}})},setDropables:r=>{n(C=>{var u;const l=(u=C.droppables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,droppables:[...C.droppables,r]};const e=[...C.droppables];return e[l]=r,{...C,droppables:e}})},setDndState:n}},$70=({identifier:t,data:n,modifiers:i,events:o,CustomDragPreview:a,disabled:s=!1,dropText:r})=>{const{dndState:C,setActive:l,setDndState:e,setDraggables:u}=KA2(),[A,f]=P0.useState(!1),[d,g]=P0.useState(!0),[E,y]=P0.useState(null),Q=P0.useRef(null),R=P0.useRef(null),D={"data-type":t.type||t.id,id:`draggable-${t.id}`,role:"button",tabindex:"0",draggable:d?"true":"false","aria-grabbed":"false"},O=J=>{Object.entries(D).forEach(([e2,p2])=>{J.setAttribute(e2,p2)})},k=()=>{var J;R.current&&((J=C.DragPreviewCreateRoot)==null||J.render(a))};return P0.useEffect(()=>{if(a&&(R.current=document.getElementById("CustomDragPreviewContainer"),R.current===null)){R.current=document.createElement("div"),R.current.setAttribute("id","CustomDragPreviewContainer"),document.body.appendChild(R.current);const J=UL.createRoot(R.current);e(e2=>({...e2,DragPreviewCreateRoot:J}))}},[]),P0.useEffect(()=>{if(Q.current){const J=Q.current.getBoundingClientRect();y(J),u({identifier:t,data:n,modifiers:i,DragNodeRef:Q,rect:E,events:o,isDragging:A,isEnableDrag:d})}},[Q.current,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i),JSON.stringify(o),JSON.stringify(A)]),P0.useEffect(()=>{const J=Q.current;if(!J)return;O(J);const e2=D2=>{var Q2,i2,N2,R2;if(f(!0),l({identifier:t,data:n,modifiers:i,DragNodeRef:Q,rect:E,events:o,isDragging:A,isEnableDrag:d}),J.setAttribute("aria-grabbed","true"),r?(Q2=D2.dataTransfer)==null||Q2.setData("text/plain",r):(i2=D2.dataTransfer)==null||i2.setData("text/plain",JSON.stringify({data:n})),(N2=o==null?void 0:o.onDragStart)==null||N2.call(o,D2,C),R.current){const M2=R.current.getBoundingClientRect();(R2=D2.dataTransfer)==null||R2.setDragImage(R.current,M2.width/2,M2.height/2)}},p2=D2=>{var Q2;J.setAttribute("aria-grabbed","false"),f(!1),l(null),(Q2=o==null?void 0:o.onDragEnd)==null||Q2.call(o,D2,C)};return J.addEventListener("mousedown",()=>{a&&k()}),J.addEventListener("dragstart",e2),J.addEventListener("dragend",p2),()=>{J.removeEventListener("dragstart",e2),J.removeEventListener("dragend",p2)}},[Q.current,JSON.stringify(t),JSON.stringify(n),C.DragPreviewCreateRoot]),P0.useEffect(()=>{const J=Q.current;J&&J.setAttribute("draggable",d?"true":"false")},[d]),P0.useEffect(()=>{var e2,p2,D2,Q2;let J=[];return A&&(l({identifier:t,data:n,modifiers:i,DragNodeRef:Q,rect:E,events:o,isDragging:A,isEnableDrag:d}),(e2=i==null?void 0:i.highlightDrop)!=null&&e2.onDrag&&(J=((D2=(p2=C.droppables)==null?void 0:p2.filter(i2=>((i2==null?void 0:i2.identifier.accepts)??[]).includes(t.type??"")&&(i2==null?void 0:i2.isEnableDrop)))==null?void 0:D2.map(i2=>i2==null?void 0:i2.setDropNodeRef.current))??[],(Q2=i==null?void 0:i.highlightDrop)!=null&&Q2.onDrag&&J.forEach(i2=>{var N2;i2==null||i2.classList.add(((N2=i==null?void 0:i.highlightDrop)==null?void 0:N2.highlightClass)||"dnd-droppable-highlight")}))),()=>{J.forEach(i2=>{var N2;i2==null||i2.classList.remove(((N2=i==null?void 0:i.highlightDrop)==null?void 0:N2.highlightClass)||"dnd-droppable-highlight")})}},[A]),P0.useEffect(()=>{g(!s)},[s]),{isDragging:A,isEnableDrag:d,setIsEnableDrag:g,DragNodeRef:Q}},JA2=({identifier:t,events:n,modifiers:i})=>{var O;const{dndState:o,setOver:a,setDropables:s}=KA2(),[r,C]=P0.useState(null),[l,e]=P0.useState({isDragOver:!1,isDrop:!1}),[u,A]=P0.useState({before:-1,after:-1}),[f,d]=P0.useState(!0),g=P0.useRef(null),E={"data-type":((O=t.accepts)==null?void 0:O.join("-"))??"",id:`droppable-${t.id}`,droppable:f?"true":"false"},y=k=>{Object.entries(E).forEach(([J,e2])=>{k.setAttribute(J,e2)})},Q=(k,J,e2)=>{const p2=[...e2];k=k===-1?p2.length-1:k;const[D2]=p2.splice(k,1);return J===-1?p2.push(D2):p2.splice(J,0,D2),p2},R=(k,J,e2)=>[...k.querySelectorAll('[draggable="true"]:not([aria-grabbed="true"])')].reduce((Q2,i2,N2)=>{const R2=i2.getBoundingClientRect(),M2=J-R2[e2==="horizontal"?"left":"top"]-R2[e2==="horizontal"?"width":"height"]/2;return M2<0&&M2>Q2.offset?{offset:M2,element:i2,index:N2}:Q2},{offset:Number.NEGATIVE_INFINITY,element:null,index:-1}),D=(k,J,e2)=>{const p2=[...k.querySelectorAll('[draggable="true"]')],D2=k.querySelector('[aria-grabbed="true"]'),{width:Q2,height:i2}=e2,N2=(M2,Z2,Y2)=>{const f0=M2.x-Z2/2,E0=M2.y-Y2/2;return[{x:f0,y:E0},{x:f0+Z2,y:E0},{x:f0,y:E0+Y2},{x:f0+Z2,y:E0+Y2}]};return p2.reduce((M2,Z2,Y2)=>{const f0=Z2.getBoundingClientRect(),E0=[{x:f0.left,y:f0.top},{x:f0.left+f0.width,y:f0.top},{x:f0.left,y:f0.top+f0.height},{x:f0.left+f0.width,y:f0.top+f0.height}],M0=N2(J,Q2,i2);let x0=Number.POSITIVE_INFINITY,z2=Y2,t1=Number.POSITIVE_INFINITY,p0=Number.POSITIVE_INFINITY;return E0.forEach((U0,G0)=>{M0.forEach(X2=>{let L3=Number.POSITIVE_INFINITY;t1=Math.sqrt((U0.x-X2.x)**2+(U0.y-X2.y)**2),p0=Math.sqrt((U0.x-J.x)**2+(U0.y-J.y)**2),L3=Math.min(t1,p0),L3<x0&&(x0=L3,G0===1||G0===3?D2!==Z2&&(z2=Y2+1):z2=Y2)})}),x0<M2.minDistance?{minDistance:x0,element:Z2,index:z2,closestBasedOnCorner:t1,closestBasedonCursor:p0}:M2},{minDistance:Number.POSITIVE_INFINITY,element:null,index:-1,closestBasedOnCorner:0,closestBasedonCursor:0})};return P0.useEffect(()=>{const k=g.current;if(!k)return;const J=k.getBoundingClientRect();C(J),s({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l})},[g.current,f,l.isDragOver,l.isDrop,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i)]),P0.useEffect(()=>{var i2,N2;const k=g.current;if(y(k),!k||!f||(i2=t.accepts)!=null&&i2.length&&!t.accepts.includes(((N2=o.active)==null?void 0:N2.identifier.type)??""))return;const{sorting:J}=i||{},e2=R2=>{var M2;R2.preventDefault(),a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),(M2=n==null?void 0:n.onDragEnter)==null||M2.call(n,R2,o)},p2=R2=>{var M2,Z2,Y2,f0,E0,M0,x0,z2,t1,p0,U0,G0;if(R2.preventDefault(),(Y2=(Z2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:Z2.highlightDrop)!=null&&Y2.onDragOver&&g.current.classList.add(((M0=(E0=(f0=o.active)==null?void 0:f0.modifiers)==null?void 0:E0.highlightDrop)==null?void 0:M0.highlightClass)||"dnd-droppable-highlight"),l.isDragOver||e(X2=>({...X2,isDragOver:!0})),o.over===null&&a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),J!=null&&J.isEnabled&&((x0=J.list)!=null&&x0.length)){const X2=(p0=(t1=(z2=o.active)==null?void 0:z2.DragNodeRef)==null?void 0:t1.current)==null?void 0:p0.getAttribute("data-dbn-sorting-index");let L3=null;if((J.sortingType==="vertical"||J.sortingType==="horizontal")&&(L3=R(k,(J==null?void 0:J.sortingType)==="horizontal"?R2.clientX:R2.clientY,J==null?void 0:J.sortingType)),J.sortingType==="both-axis"){const C3=(U0=document.getElementById("CustomDragPreviewContainer"))==null?void 0:U0.getBoundingClientRect();L3=D(k,{x:R2.clientX,y:R2.clientY},{width:(C3==null?void 0:C3.width)??0,height:(C3==null?void 0:C3.height)??0})}const O1={before:parseInt(X2??-1,10),after:L3==null?void 0:L3.index};(O1.before!==u.before||O1.after!==u.after)&&A(O1)}(G0=n==null?void 0:n.onDragOver)==null||G0.call(n,R2,o)},D2=R2=>{var M2,Z2,Y2,f0,E0,M0,x0;R2.preventDefault(),(Y2=(Z2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:Z2.highlightDrop)!=null&&Y2.onDragOver&&g.current.classList.remove(((M0=(E0=(f0=o.active)==null?void 0:f0.modifiers)==null?void 0:E0.highlightDrop)==null?void 0:M0.highlightClass)||"dnd-droppable-highlight"),e(z2=>({...z2,isDragOver:!1})),(x0=n==null?void 0:n.onDragLeave)==null||x0.call(n,R2,o),a(null)},Q2=R2=>{var E0,M0,x0,z2,t1,p0,U0,G0,X2,L3;R2.preventDefault();const M2=g.current.contains((M0=(E0=o.active)==null?void 0:E0.DragNodeRef)==null?void 0:M0.current);let Z2={...o};(t1=(z2=(x0=o.active)==null?void 0:x0.modifiers)==null?void 0:z2.highlightDrop)!=null&&t1.onDragOver&&g.current.classList.remove(((G0=(U0=(p0=o.active)==null?void 0:p0.modifiers)==null?void 0:U0.highlightDrop)==null?void 0:G0.highlightClass)||"dnd-droppable-highlight");let{before:Y2,after:f0}=u;if(J!=null&&J.isEnabled&&((X2=J.list)!=null&&X2.length)){let O1=[...J.list];M2?O1=Q(Y2,f0,O1):Y2=-1,Z2={...o,sorting:{sortedList:O1,isSelfDrop:M2,ArrayElementSwap:Q,sortingIndexes:{before:Y2,after:f0}}},J.isEnabledAutoSort&&M2&&J.setList(O1)}e(O1=>({...O1,isDrop:!0})),(L3=n==null?void 0:n.onDrop)==null||L3.call(n,R2,Z2),a(null)};return k.addEventListener("dragenter",e2),k.addEventListener("dragover",p2),k.addEventListener("dragleave",D2),k.addEventListener("drop",Q2),()=>{k.removeEventListener("dragenter",e2),k.removeEventListener("dragover",p2),k.removeEventListener("dragleave",D2),k.removeEventListener("drop",Q2)}},[g.current,t,f,i,n,u]),P0.useEffect(()=>{const k=g.current;k&&k.setAttribute("droppable",f?"true":"false")},[f]),{dragStatus:l,isEnableDrop:f,setIsEnableDrop:d,setDropNodeRef:g}},e60=(t,n,i)=>({autoCompleteDropdownOptions:P0.useMemo(()=>{if(!n.length)return[];const a=[];return n.forEach(s=>{s.columnsWithDataType.forEach(r=>{var g;const C=a$2(((g=r==null?void 0:r.dataType)==null?void 0:g.toLowerCase())||""),l=s$2(C,i),e=new Set,u=new Set,A=new Set;switch(r.columnTypeConfig&&typeof r.columnTypeConfig=="string"?e.add(r.columnTypeConfig):r.columnTypeConfig&&typeof r.columnTypeConfig=="object"&&Object.entries(r.columnTypeConfig).forEach(([E,y])=>{e.add(E),y&&u.add(y)}),C){case"DATE":rR.forEach(E=>E.synonyms.forEach(A.add,A));break;case"NUMBER":KE.forEach(E=>E.synonymns.forEach(A.add,A));break;case"STRING":Oh.forEach(E=>E.synonyms.forEach(A.add,A)),RB2.forEach(E=>E.synonyms.forEach(A.add,A));break}$L.forEach(E=>E.synonymns.forEach(A.add,A));const f=l.flatMap(E=>(xb==null?void 0:xb[E.value])||[]),d={alias:`${s.tableName}.${r.alias||r.name}`,datatype:r.dataType,name:r.name,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],functionsSynonyms:f,distinctValues:[...e],filtersSynonyms:[...A],distinctValueSynonyms:[...u],type:"COLUMN"};a.push(d),e.forEach(E=>{a.push({alias:E,datatype:r.dataType,name:E,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],distinctValueSynonyms:[...u],type:"VALUE"})})})}),a},[n,i,t])}),t60=(t="download.pdf",n)=>({toPDF:async o=>{var C,l,e;const a=((C=window==null?void 0:window.dbn)==null?void 0:C.isEnableProxyAuth)||!1,s=await fetch(`${((l=window.dbn)==null?void 0:l.proxyAuthUrl)||((e=window.dbn)==null?void 0:e.baseUrl)||oV}${E30}`,{method:"POST",body:JSON.stringify({fileName:t,dashboardId:n}),headers:{"Content-Type":"application/json",...a?{}:{"X-Plugin-Token":o||""},...aV()||{},"X-Plugin-Origin":window.location.host}});if(!s.ok)throw new Error("Network response was not ok");const r=await s.blob();try{if(r.type==="application/pdf"){const u=URL.createObjectURL(r),A=document.createElement("a");A.href=u,A.download=`${t}.pdf`,A.click(),URL.revokeObjectURL(u)}else console.error("Unexpected file type:",r.type)}catch{console.error("Unexpected file type:",r.type)}}}),r60=()=>{const[t,n]=P0.useState({isLoading:!1,downloadProgress:!1});return{onDownloadMetrics:async({dashboardName:o,externalDashboardId:a,token:s,isFrontend:r,clientId:C,datasourceId:l,globalFilters:e,metricData:u,workspaceId:A})=>{var d,g,E;const f=((d=window==null?void 0:window.dbn)==null?void 0:d.isEnableProxyAuth)||!1;try{n({downloadProgress:!0,isLoading:!0});const y=await fetch(`${((g=window.dbn)==null?void 0:g.proxyAuthUrl)||((E=window.dbn)==null?void 0:E.baseUrl)||oV}${G30}`,{method:"POST",body:JSON.stringify({externalDashboardId:a,globalFilters:e,metricData:u,datasourceId:l,workspaceId:A}),headers:{"Content-Type":"application/json",...f?{}:{"X-Plugin-Token":s||""},...aV()||{},"X-Plugin-Origin":window.location.host,...r?{"X-Dbn-Secret":C}:{},...r?{"X-Dbn-token":dX()||""}:{}}});if(!y.ok)throw new Error("Network response was not ok");const Q=await y.blob(),R=URL.createObjectURL(Q),D=document.createElement("a");D.href=R,D.download=`${o}.zip`,D.style.display="none",document.body.appendChild(D),n({downloadProgress:!1,isLoading:!1}),BP&&(document!=null&&document.createEvent)||D.click(),URL.revokeObjectURL(R),document.body.removeChild(D)}catch{n({downloadProgress:!1,isLoading:!1}),alert("Error downloading the file. Please try later.")}},downloadState:t}},n60=({dashboardId:t,fileName:n,token:i})=>{const[o,a]=P0.useState(""),[s,r]=P0.useState(!1),[C,l]=P0.useState({isGettingPdf:!1}),{toPDF:e}=t60(n,t);return{toPDF:async()=>{if(l({isGettingPdf:!0}),a(""),r(!1),!i){a(zu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1});return}try{await e(i),r(!0),setTimeout(()=>{r(!1)},2e3),l({isGettingPdf:!1})}catch{a(zu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1})}},isGettingPdf:C==null?void 0:C.isGettingPdf,error:o,isPdfExported:s}},cV={downloadCsv:"_downloadCsv_z5r12_1",downloadCsvWrapper:"_downloadCsvWrapper_z5r12_9",downloadCsvNote:"_downloadCsvNote_z5r12_45",downloadCsvNoteText:"_downloadCsvNoteText_z5r12_59"},UA={label:"_label_lpfkf_1","inputField-container":"_inputField-container_lpfkf_25",upperContainer:"_upperContainer_lpfkf_31",input:"_input_lpfkf_25",supportText:"_supportText_lpfkf_49",error:"_error_lpfkf_55",inputVal:"_inputVal_lpfkf_61",inputContainer:"_inputContainer_lpfkf_67",floatingLabel:"_floatingLabel_lpfkf_81",suffixContainer:"_suffixContainer_lpfkf_89",prefixContainer:"_prefixContainer_lpfkf_95",inlineLabelContainer:"_inlineLabelContainer_lpfkf_101",important:"_important_lpfkf_109"},K9=({type:t="text",register:n,label:i,isDisabled:o,id:a,elementRef:s,error:r,supportingText:C,leftIcon:l,rightIcon:e,addSuffix:u,addPrefix:A,inlineLabel:f,labelVariant:d="static",value:g,isImportant:E,containerClassName:y="",containerStyle:Q,customClassName:R="",isFilter:D,isApplyDashboardColor:O,...k})=>{var J,e2,p2,D2;return h.jsxs("div",{className:`${UA["inputField-container"]} ${R}`,children:[h.jsxs("div",{className:UA.upperContainer,id:`${(e2=(J=i??a)==null?void 0:J.replaceAll(" ","-"))==null?void 0:e2.toLowerCase()}-input`,"data-testid":`${(D2=(p2=i??a)==null?void 0:p2.replaceAll(" ","-"))==null?void 0:D2.toLowerCase()}-input`,children:[i?h.jsxs(h.Fragment,{children:[d==="floating"&&h.jsxs("label",{htmlFor:a,className:`${UA.floatingLabel} ${D?"dbn-selectBox-text":""} ${D&&O?"dbn-selectBox":""}`,children:[i,E?h.jsx("span",{className:UA.important,children:"*"}):null]}),d==="static"&&h.jsx("label",{htmlFor:a,className:`${UA.label} ${D?"dbn-selectBox-text":""} ${D&&O?"dbn-selectBox":""}`,children:h.jsxs(_7,{variant:"input-label",color:"primary",children:[i,E?h.jsx("span",{className:UA.important,children:"*"}):null]})})]}):null,h.jsxs("div",{className:`${UA.inputContainer} ${D&&O?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""} ${y} `,style:Q,children:[f&&h.jsx("div",{className:UA.inlineLabelContainer,children:h.jsx(_7,{variant:"heading-6",children:f})}),A&&h.jsx("div",{className:`${UA.prefixContainer} ${UA.supportText}`,children:A}),l&&h.jsx("div",{className:"dbn-p-2",children:l}),h.jsx("input",{...k,value:g,ref:s,id:a,type:t,className:`${UA.input} ${k.className||""} ${r?UA.error:""} ${g?UA.inputVal:""} ${D&&O?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""}`,...n,disabled:o}),e&&h.jsx("div",{className:"dbn-p-2",children:e}),u&&h.jsx("div",{className:`${UA.suffixContainer} ${UA.supportText}`,children:u})]})]}),C&&h.jsx("div",{className:UA.supportText,children:C}),r&&h.jsx(_7,{variant:"body-text-2",color:"alert",children:r})]})},ig={modal:"_modal_19z4t_1","popup-sm":"_popup-sm_19z4t_9","popup-md":"_popup-md_19z4t_17","popup-lg":"_popup-lg_19z4t_25","popup-xl":"_popup-xl_19z4t_33","popup-xxl":"_popup-xxl_19z4t_41",popup:"_popup_19z4t_9",header:"_header_19z4t_57",subHeadingTitle:"_subHeadingTitle_19z4t_65",headerTitle:"_headerTitle_19z4t_73",content:"_content_19z4t_81",footer:"_footer_19z4t_89"},qu=({children:t,isOpen:n,onClose:i,headerTitle:o,subHeadingTitle:a,customHeader:s,enableFullScreenButton:r,icon:C,zIndex:l,size:e,isRemoveHeader:u,isMobileModal:A,keepMounted:f})=>{const d=P0.useRef(),[g,E]=P0.useState(!1),[y,Q]=P0.useState(!1),[R,D]=P0.useState(!1),O=J=>{J.target.classList.contains(ig.modal)?Q(!0):Q(!1)},k=J=>{J.target.classList.contains(ig.modal)?D(!0):D(!1)};return P0.useEffect(()=>{R&&y&&(D(!1),Q(!1))},[R,y]),h.jsx(kE,{children:n||f?h.jsx("div",{className:`${ig.modal} ${A?"dbn-items-end dbn-py-0":""}`,onMouseDown:k,onMouseUp:O,ref:d,style:{...l?{zIndex:l}:{},...f?{display:n?void 0:"none"}:{}},children:h.jsxs("div",{className:`${ig.popup} ${g?ig.popupFullScreen:""} ${e?ig[`popup-${e}`]:""} ${A?"dbn-my-0 dbn-rounded-b-none dbn-rounded-t-3xl":""}`,onClick:J=>{J.stopPropagation()},children:[u?null:h.jsx("section",{className:ig.header,children:s||h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-items-start dbn-gap-1.5",children:[h.jsxs("div",{className:ig.headerTitle,children:[C,h.jsx(_7,{variant:"heading-3",color:"primary",children:o})]}),a&&h.jsx("div",{className:ig.subHeadingTitle,children:h.jsx(_7,{variant:"body-text-3",color:"sec-text",children:a})})]}),h.jsx(e8,{"data-testid":"close-modal",variant:"tertiary",type:"button",onClick:i,leftIcon:h.jsx(h8,{name:"cross",size:"small"}),style:{padding:"0",height:"20px"},className:"dbn-p-1.5"})]})}),h.jsx("section",{className:ig.content,children:t})]})}):null})},Ed=({children:t,className:n})=>h.jsx("section",{className:`${ig.footer} ${n}`,children:t}),i60=t=>{if(!t.length)return!1;const n=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;return t.every(i=>n.test(i))},wX=({onCloseModal:t,sharingSettingsId:n,metricItem:i,workspaceId:o})=>{const{data:a}=_70(o),[s,r]=P0.useState(!1),[C,l]=P0.useState(""),{mutate:e}=v70(),{handleSubmit:u,register:A,setValue:f,control:d,formState:{errors:g}}=Vb(),E=P0.useMemo(()=>{const Q=a;return{expireTimeInMin:(Q==null?void 0:Q.expireTimeInMin)||30,isEnable:Q==null?void 0:Q.isEnable}},[a]);return{onSumbitSendCsvUrl:({values:Q,query:R})=>{r(!0),l("");const D=E.expireTimeInMin||30,O=new Date(Date.now()+D*60*1e3),k=R,J=Q.emails;if(!i60(J)){r(!1),l("please enter valid email");return}if(!n){r(!1),l("no sharing settings are found");return}e({configurations:{externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,name:i==null?void 0:i.name},emails:J,expireCsvFileAt:O,expireUrlIn:D*60,externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,query:k,sharingSettingsId:n,subject:Q.subject},{onSuccess(e2){e2?(r(!1),l(""),t==null||t(!1)):(r(!1),l(zu))},onError(){r(!1),l(zu)}})},isDisableDownloadSettings:!n||!E.isEnable,downloadCsvError:C,handleSubmit:u,isLoading:s,register:A,control:d,setValue:f,errors:g}},Dy={required:"Required"};({...Dy},{...Dy}),{...Dy};const fV={"tag-text":"_tag-text_m1urh_4",inputFieldContainer:"_inputFieldContainer_m1urh_11","tag-container":"_tag-container_m1urh_15",important:"_important_m1urh_23"},QX=({id:t,control:n,placeholder:i,name:o,label:a,onChangeTags:s,onChange:r,defaultTagValue:C,isImportant:l,isDisabled:e,width:u="300px",regexStr:A,tagType:f,tagError:d,setTagError:g,register:E,error:y})=>{const[Q,R]=P0.useState(),[D,O]=P0.useState(""),k=Q2=>{R(Q==null?void 0:Q.filter(i2=>i2!==Q2)),s==null||s(Q==null?void 0:Q.filter(i2=>i2!==Q2))},J=()=>{const Q2=D.split(",").map(R2=>R2.trim()).filter(Boolean),i2=new Set;for(const R2 of Q2){if(i2.has(R2)){g==null||g(`Duplicate ${(f==null?void 0:f.toLocaleLowerCase())||"value"} in input: "${R2}"`);return}if(Q!=null&&Q.includes(R2)){g==null||g(`"${R2}" already added`);return}if(A&&!A.test(R2)){g==null||g(`Invalid ${(f==null?void 0:f.toLocaleLowerCase())||"input"}: "${R2}"`);return}i2.add(R2)}const N2=[...Q||[],...Q2];R(N2),s==null||s(N2),O(""),g==null||g("")},e2=Q2=>{if(Q2.key==="Enter"||Q2.key==="Tab")Q2.preventDefault(),J();else if(Q2.key==="Backspace"&&(D==null?void 0:D.length)===0){R(N2=>(N2==null||N2.pop(),[...N2||[]])),Q==null||Q.pop();const i2=[...Q||[]];s==null||s(i2)}},p2=()=>{J()};P0.useEffect(()=>{C&&Array.isArray(C)?R(C):R([])},[C]);const D2=Q2=>{const i2=Q2.target.parentElement;i2.scrollLeft=i2.scrollWidth,O(Q2.target.value),r==null||r(Q2.target.value)};return P0.useEffect(()=>{g==null||g("")},[D]),h.jsx(JE,{name:o||"tags",control:n,defaultValue:"",render:({field:Q2})=>{var R2,M2,Z2,Y2;const{ref:i2,...N2}=Q2;return h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[a?h.jsxs(_7,{variant:"input-label",color:"primary",children:[a,l?h.jsx("span",{className:fV.important,children:"*"}):null]}):null,h.jsxs("div",{className:fV.inputFieldContainer,style:{width:u},id:`${(M2=(R2=a??t)==null?void 0:R2.replaceAll(" ","-"))==null?void 0:M2.toLowerCase()}-input`,"data-testid":`${(Y2=(Z2=a??t)==null?void 0:Z2.replaceAll(" ","-"))==null?void 0:Y2.toLowerCase()}-input`,children:[Q!=null&&Q.length?h.jsx("div",{className:fV["tag-container"],children:Q==null?void 0:Q.map(f0=>h.jsx(e8,{variant:"popover",type:"button",onClick:()=>k(f0),className:"dbn-flex dbn-font-semibold dbn-gap-2 dbn-px-2 dbn-py-1 dbn-bg-gray dbn-rounded",rightIcon:h.jsx(h8,{name:"cross",size:"xxs"}),children:h.jsx("span",{className:fV["tag-text"],children:f0})},f0))}):null,h.jsx("input",{...N2,type:"text",value:D,onChange:D2,onKeyDown:e2,placeholder:Q!=null&&Q.length?"":i,disabled:e,className:`dbn-outline-none dbn-border-none dbn-text-sm ${Q!=null&&Q.length?"dbn-max-w-[400px]":"dbn-w-full"} ${{...E}}`,onBlur:p2})]})]}),d&&h.jsx(Tl,{text:d,variant:"error"}),!d&&y&&h.jsx(_7,{variant:"body-text-2",color:"alert",children:y})]})}})};T9.memo(QX);const dc={container:"_container_10845_1",tooltip:"_tooltip_10845_9",subTooltip:"_subTooltip_10845_17",textPadding:"_textPadding_10845_25",subPadding:"_subPadding_10845_33",heading:"_heading_10845_41",tooltipMetric:"_tooltipMetric_10845_87",active:"_active_10845_115",top:"_top_10845_125",bottom:"_bottom_10845_143",left:"_left_10845_161",right:"_right_10845_179","left-top-end":"_left-top-end_10845_197","right-top-end":"_right-top-end_10845_215","left-bottom-end":"_left-bottom-end_10845_233","right-bottom-end":"_right-bottom-end_10845_251","top-left":"_top-left_10845_269","top-right":"_top-right_10845_287","bottom-left":"_bottom-left_10845_305","bottom-right":"_bottom-right_10845_323","left-top":"_left-top_10845_197","left-bottom":"_left-bottom_10845_233","right-top":"_right-top_10845_215","right-bottom":"_right-bottom_10845_251",addedLink:"_addedLink_10845_413",subText:"_subText_10845_421"};/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */const{entries:qA2,setPrototypeOf:$A2,isFrozen:o60,getPrototypeOf:a60,getOwnPropertyDescriptor:s60}=Object;let{freeze:gc,seal:pd,create:ec2}=Object,{apply:MX,construct:TX}=typeof Reflect<"u"&&Reflect;gc||(gc=function(n){return n}),pd||(pd=function(n){return n}),MX||(MX=function(n,i,o){return n.apply(i,o)}),TX||(TX=function(n,i){return new n(...i)});const dV=Ec(Array.prototype.forEach),C60=Ec(Array.prototype.lastIndexOf),tc2=Ec(Array.prototype.pop),nT=Ec(Array.prototype.push),l60=Ec(Array.prototype.splice),gV=Ec(String.prototype.toLowerCase),xX=Ec(String.prototype.toString),rc2=Ec(String.prototype.match),iT=Ec(String.prototype.replace),u60=Ec(String.prototype.indexOf),A60=Ec(String.prototype.trim),og=Ec(Object.prototype.hasOwnProperty),hc=Ec(RegExp.prototype.test),oT=c60(TypeError);function Ec(t){return function(n){for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return MX(t,n,o)}}function c60(t){return function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return TX(t,i)}}function uC(t,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gV;$A2&&$A2(t,null);let o=n.length;for(;o--;){let a=n[o];if(typeof a=="string"){const s=i(a);s!==a&&(o60(n)||(n[o]=s),a=s)}t[a]=!0}return t}function f60(t){for(let n=0;n<t.length;n++)og(t,n)||(t[n]=null);return t}function xm(t){const n=ec2(null);for(const[i,o]of qA2(t))og(t,i)&&(Array.isArray(o)?n[i]=f60(o):o&&typeof o=="object"&&o.constructor===Object?n[i]=xm(o):n[i]=o);return n}function aT(t,n){for(;t!==null;){const o=s60(t,n);if(o){if(o.get)return Ec(o.get);if(typeof o.value=="function")return Ec(o.value)}t=a60(t)}function i(){return null}return i}const nc2=gc(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),RX=gc(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),HX=gc(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),d60=gc(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),DX=gc(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),g60=gc(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ic2=gc(["#text"]),oc2=gc(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),NX=gc(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ac2=gc(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),hV=gc(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),h60=pd(/\{\{[\w\W]*|[\w\W]*\}\}/gm),E60=pd(/<%[\w\W]*|[\w\W]*%>/gm),p60=pd(/\$\{[\w\W]*/gm),v60=pd(/^data-[\-\w.\u00B7-\uFFFF]+$/),I60=pd(/^aria-[\-\w]+$/),sc2=pd(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),m60=pd(/^(?:\w+script|data):/i),b60=pd(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cc2=pd(/^html$/i),B60=pd(/^[a-z][.\w]*(-[.\w]+)+$/i);var lc2=Object.freeze({__proto__:null,ARIA_ATTR:I60,ATTR_WHITESPACE:b60,CUSTOM_ELEMENT:B60,DATA_ATTR:v60,DOCTYPE_NAME:Cc2,ERB_EXPR:E60,IS_ALLOWED_URI:sc2,IS_SCRIPT_OR_DATA:m60,MUSTACHE_EXPR:h60,TMPLIT_EXPR:p60});const sT={element:1,text:3,progressingInstruction:7,comment:8,document:9},y60=function(){return typeof window>"u"?null:window},L60=function(n,i){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let o=null;const a="data-tt-policy-suffix";i&&i.hasAttribute(a)&&(o=i.getAttribute(a));const s="dompurify"+(o?"#"+o:"");try{return n.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},uc2=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ac2(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y60();const n=k3=>Ac2(k3);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==sT.document||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,a=o.currentScript,{DocumentFragment:s,HTMLTemplateElement:r,Node:C,Element:l,NodeFilter:e,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:A,DOMParser:f,trustedTypes:d}=t,g=l.prototype,E=aT(g,"cloneNode"),y=aT(g,"remove"),Q=aT(g,"nextSibling"),R=aT(g,"childNodes"),D=aT(g,"parentNode");if(typeof r=="function"){const k3=i.createElement("template");k3.content&&k3.content.ownerDocument&&(i=k3.content.ownerDocument)}let O,k="";const{implementation:J,createNodeIterator:e2,createDocumentFragment:p2,getElementsByTagName:D2}=i,{importNode:Q2}=o;let i2=uc2();n.isSupported=typeof qA2=="function"&&typeof D=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:N2,ERB_EXPR:R2,TMPLIT_EXPR:M2,DATA_ATTR:Z2,ARIA_ATTR:Y2,IS_SCRIPT_OR_DATA:f0,ATTR_WHITESPACE:E0,CUSTOM_ELEMENT:M0}=lc2;let{IS_ALLOWED_URI:x0}=lc2,z2=null;const t1=uC({},[...nc2,...RX,...HX,...DX,...ic2]);let p0=null;const U0=uC({},[...oc2,...NX,...ac2,...hV]);let G0=Object.seal(ec2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),X2=null,L3=null,O1=!0,C3=!0,W3=!1,d7=!0,y7=!1,Y7=!0,I6=!1,z7=!1,X6=!1,k6=!1,z3=!1,t0=!1,j3=!0,K7=!1;const G7="user-content-";let c6=!0,u6=!1,L6={},v1=null;const A3=uC({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let c7=null;const X3=uC({},["audio","video","img","source","image","track"]);let Y3=null;const n7=uC({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),V7="http://www.w3.org/1998/Math/MathML",P7="http://www.w3.org/2000/svg",D7="http://www.w3.org/1999/xhtml";let _6=D7,c8=!1,x8=null;const C8=uC({},[V7,P7,D7],xX);let K8=uC({},["mi","mo","mn","ms","mtext"]),l8=uC({},["annotation-xml"]);const I9=uC({},["title","style","font","a","script"]);let M8=null;const d9=["application/xhtml+xml","text/html"],b8="text/html";let g5=null,N5=null;const h5=i.createElement("form"),d4=function(E3){return E3 instanceof RegExp||E3 instanceof Function},b5=function(){let E3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(N5&&N5===E3)){if((!E3||typeof E3!="object")&&(E3={}),E3=xm(E3),M8=d9.indexOf(E3.PARSER_MEDIA_TYPE)===-1?b8:E3.PARSER_MEDIA_TYPE,g5=M8==="application/xhtml+xml"?xX:gV,z2=og(E3,"ALLOWED_TAGS")?uC({},E3.ALLOWED_TAGS,g5):t1,p0=og(E3,"ALLOWED_ATTR")?uC({},E3.ALLOWED_ATTR,g5):U0,x8=og(E3,"ALLOWED_NAMESPACES")?uC({},E3.ALLOWED_NAMESPACES,xX):C8,Y3=og(E3,"ADD_URI_SAFE_ATTR")?uC(xm(n7),E3.ADD_URI_SAFE_ATTR,g5):n7,c7=og(E3,"ADD_DATA_URI_TAGS")?uC(xm(X3),E3.ADD_DATA_URI_TAGS,g5):X3,v1=og(E3,"FORBID_CONTENTS")?uC({},E3.FORBID_CONTENTS,g5):A3,X2=og(E3,"FORBID_TAGS")?uC({},E3.FORBID_TAGS,g5):{},L3=og(E3,"FORBID_ATTR")?uC({},E3.FORBID_ATTR,g5):{},L6=og(E3,"USE_PROFILES")?E3.USE_PROFILES:!1,O1=E3.ALLOW_ARIA_ATTR!==!1,C3=E3.ALLOW_DATA_ATTR!==!1,W3=E3.ALLOW_UNKNOWN_PROTOCOLS||!1,d7=E3.ALLOW_SELF_CLOSE_IN_ATTR!==!1,y7=E3.SAFE_FOR_TEMPLATES||!1,Y7=E3.SAFE_FOR_XML!==!1,I6=E3.WHOLE_DOCUMENT||!1,k6=E3.RETURN_DOM||!1,z3=E3.RETURN_DOM_FRAGMENT||!1,t0=E3.RETURN_TRUSTED_TYPE||!1,X6=E3.FORCE_BODY||!1,j3=E3.SANITIZE_DOM!==!1,K7=E3.SANITIZE_NAMED_PROPS||!1,c6=E3.KEEP_CONTENT!==!1,u6=E3.IN_PLACE||!1,x0=E3.ALLOWED_URI_REGEXP||sc2,_6=E3.NAMESPACE||D7,K8=E3.MATHML_TEXT_INTEGRATION_POINTS||K8,l8=E3.HTML_INTEGRATION_POINTS||l8,G0=E3.CUSTOM_ELEMENT_HANDLING||{},E3.CUSTOM_ELEMENT_HANDLING&&d4(E3.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(G0.tagNameCheck=E3.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E3.CUSTOM_ELEMENT_HANDLING&&d4(E3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(G0.attributeNameCheck=E3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E3.CUSTOM_ELEMENT_HANDLING&&typeof E3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(G0.allowCustomizedBuiltInElements=E3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),y7&&(C3=!1),z3&&(k6=!0),L6&&(z2=uC({},ic2),p0=[],L6.html===!0&&(uC(z2,nc2),uC(p0,oc2)),L6.svg===!0&&(uC(z2,RX),uC(p0,NX),uC(p0,hV)),L6.svgFilters===!0&&(uC(z2,HX),uC(p0,NX),uC(p0,hV)),L6.mathMl===!0&&(uC(z2,DX),uC(p0,ac2),uC(p0,hV))),E3.ADD_TAGS&&(z2===t1&&(z2=xm(z2)),uC(z2,E3.ADD_TAGS,g5)),E3.ADD_ATTR&&(p0===U0&&(p0=xm(p0)),uC(p0,E3.ADD_ATTR,g5)),E3.ADD_URI_SAFE_ATTR&&uC(Y3,E3.ADD_URI_SAFE_ATTR,g5),E3.FORBID_CONTENTS&&(v1===A3&&(v1=xm(v1)),uC(v1,E3.FORBID_CONTENTS,g5)),c6&&(z2["#text"]=!0),I6&&uC(z2,["html","head","body"]),z2.table&&(uC(z2,["tbody"]),delete X2.tbody),E3.TRUSTED_TYPES_POLICY){if(typeof E3.TRUSTED_TYPES_POLICY.createHTML!="function")throw oT('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E3.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw oT('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');O=E3.TRUSTED_TYPES_POLICY,k=O.createHTML("")}else O===void 0&&(O=L60(d,a)),O!==null&&typeof k=="string"&&(k=O.createHTML(""));gc&&gc(E3),N5=E3}},M1=uC({},[...RX,...HX,...d60]),o9=uC({},[...DX,...g60]),O9=function(E3){let Q7=D(E3);(!Q7||!Q7.tagName)&&(Q7={namespaceURI:_6,tagName:"template"});const E7=gV(E3.tagName),w6=gV(Q7.tagName);return x8[E3.namespaceURI]?E3.namespaceURI===P7?Q7.namespaceURI===D7?E7==="svg":Q7.namespaceURI===V7?E7==="svg"&&(w6==="annotation-xml"||K8[w6]):!!M1[E7]:E3.namespaceURI===V7?Q7.namespaceURI===D7?E7==="math":Q7.namespaceURI===P7?E7==="math"&&l8[w6]:!!o9[E7]:E3.namespaceURI===D7?Q7.namespaceURI===P7&&!l8[w6]||Q7.namespaceURI===V7&&!K8[w6]?!1:!o9[E7]&&(I9[E7]||!M1[E7]):!!(M8==="application/xhtml+xml"&&x8[E3.namespaceURI]):!1},s5=function(E3){nT(n.removed,{element:E3});try{D(E3).removeChild(E3)}catch{y(E3)}},u5=function(E3,Q7){try{nT(n.removed,{attribute:Q7.getAttributeNode(E3),from:Q7})}catch{nT(n.removed,{attribute:null,from:Q7})}if(Q7.removeAttribute(E3),E3==="is")if(k6||z3)try{s5(Q7)}catch{}else try{Q7.setAttribute(E3,"")}catch{}},B5=function(E3){let Q7=null,E7=null;if(X6)E3="<remove></remove>"+E3;else{const o6=rc2(E3,/^[\r\n\t ]+/);E7=o6&&o6[0]}M8==="application/xhtml+xml"&&_6===D7&&(E3='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E3+"</body></html>");const w6=O?O.createHTML(E3):E3;if(_6===D7)try{Q7=new f().parseFromString(w6,M8)}catch{}if(!Q7||!Q7.documentElement){Q7=J.createDocument(_6,"template",null);try{Q7.documentElement.innerHTML=c8?k:w6}catch{}}const n6=Q7.body||Q7.documentElement;return E3&&E7&&n6.insertBefore(i.createTextNode(E7),n6.childNodes[0]||null),_6===D7?D2.call(Q7,I6?"html":"body")[0]:I6?Q7.documentElement:n6},U9=function(E3){return e2.call(E3.ownerDocument||E3,E3,e.SHOW_ELEMENT|e.SHOW_COMMENT|e.SHOW_TEXT|e.SHOW_PROCESSING_INSTRUCTION|e.SHOW_CDATA_SECTION,null)},c3=function(E3){return E3 instanceof A&&(typeof E3.nodeName!="string"||typeof E3.textContent!="string"||typeof E3.removeChild!="function"||!(E3.attributes instanceof u)||typeof E3.removeAttribute!="function"||typeof E3.setAttribute!="function"||typeof E3.namespaceURI!="string"||typeof E3.insertBefore!="function"||typeof E3.hasChildNodes!="function")},W8=function(E3){return typeof C=="function"&&E3 instanceof C};function e7(k3,E3,Q7){dV(k3,E7=>{E7.call(n,E3,Q7,N5)})}const Q6=function(E3){let Q7=null;if(e7(i2.beforeSanitizeElements,E3,null),c3(E3))return s5(E3),!0;const E7=g5(E3.nodeName);if(e7(i2.uponSanitizeElement,E3,{tagName:E7,allowedTags:z2}),E3.hasChildNodes()&&!W8(E3.firstElementChild)&&hc(/<[/\w]/g,E3.innerHTML)&&hc(/<[/\w]/g,E3.textContent)||E3.nodeType===sT.progressingInstruction||Y7&&E3.nodeType===sT.comment&&hc(/<[/\w]/g,E3.data))return s5(E3),!0;if(!z2[E7]||X2[E7]){if(!X2[E7]&&f6(E7)&&(G0.tagNameCheck instanceof RegExp&&hc(G0.tagNameCheck,E7)||G0.tagNameCheck instanceof Function&&G0.tagNameCheck(E7)))return!1;if(c6&&!v1[E7]){const w6=D(E3)||E3.parentNode,n6=R(E3)||E3.childNodes;if(n6&&w6){const o6=n6.length;for(let g8=o6-1;g8>=0;--g8){const J3=E(n6[g8],!0);J3.__removalCount=(E3.__removalCount||0)+1,w6.insertBefore(J3,Q(E3))}}}return s5(E3),!0}return E3 instanceof l&&!O9(E3)||(E7==="noscript"||E7==="noembed"||E7==="noframes")&&hc(/<\/no(script|embed|frames)/i,E3.innerHTML)?(s5(E3),!0):(y7&&E3.nodeType===sT.text&&(Q7=E3.textContent,dV([N2,R2,M2],w6=>{Q7=iT(Q7,w6," ")}),E3.textContent!==Q7&&(nT(n.removed,{element:E3.cloneNode()}),E3.textContent=Q7)),e7(i2.afterSanitizeElements,E3,null),!1)},P6=function(E3,Q7,E7){if(j3&&(Q7==="id"||Q7==="name")&&(E7 in i||E7 in h5))return!1;if(!(C3&&!L3[Q7]&&hc(Z2,Q7))){if(!(O1&&hc(Y2,Q7))){if(!p0[Q7]||L3[Q7]){if(!(f6(E3)&&(G0.tagNameCheck instanceof RegExp&&hc(G0.tagNameCheck,E3)||G0.tagNameCheck instanceof Function&&G0.tagNameCheck(E3))&&(G0.attributeNameCheck instanceof RegExp&&hc(G0.attributeNameCheck,Q7)||G0.attributeNameCheck instanceof Function&&G0.attributeNameCheck(Q7))||Q7==="is"&&G0.allowCustomizedBuiltInElements&&(G0.tagNameCheck instanceof RegExp&&hc(G0.tagNameCheck,E7)||G0.tagNameCheck instanceof Function&&G0.tagNameCheck(E7))))return!1}else if(!Y3[Q7]){if(!hc(x0,iT(E7,E0,""))){if(!((Q7==="src"||Q7==="xlink:href"||Q7==="href")&&E3!=="script"&&u60(E7,"data:")===0&&c7[E3])){if(!(W3&&!hc(f0,iT(E7,E0,"")))){if(E7)return!1}}}}}}return!0},f6=function(E3){return E3!=="annotation-xml"&&rc2(E3,M0)},x7=function(E3){e7(i2.beforeSanitizeAttributes,E3,null);const{attributes:Q7}=E3;if(!Q7||c3(E3))return;const E7={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:p0,forceKeepAttr:void 0};let w6=Q7.length;for(;w6--;){const n6=Q7[w6],{name:o6,namespaceURI:g8,value:J3}=n6,A8=g5(o6);let J8=o6==="value"?J3:A60(J3);if(E7.attrName=A8,E7.attrValue=J8,E7.keepAttr=!0,E7.forceKeepAttr=void 0,e7(i2.uponSanitizeAttribute,E3,E7),J8=E7.attrValue,K7&&(A8==="id"||A8==="name")&&(u5(o6,E3),J8=G7+J8),Y7&&hc(/((--!?|])>)|<\/(style|title)/i,J8)){u5(o6,E3);continue}if(E7.forceKeepAttr||(u5(o6,E3),!E7.keepAttr))continue;if(!d7&&hc(/\/>/i,J8)){u5(o6,E3);continue}y7&&dV([N2,R2,M2],a9=>{J8=iT(J8,a9," ")});const t8=g5(E3.nodeName);if(P6(t8,A8,J8)){if(O&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!g8)switch(d.getAttributeType(t8,A8)){case"TrustedHTML":{J8=O.createHTML(J8);break}case"TrustedScriptURL":{J8=O.createScriptURL(J8);break}}try{g8?E3.setAttributeNS(g8,o6,J8):E3.setAttribute(o6,J8),c3(E3)?s5(E3):tc2(n.removed)}catch{}}}e7(i2.afterSanitizeAttributes,E3,null)},s7=function k3(E3){let Q7=null;const E7=U9(E3);for(e7(i2.beforeSanitizeShadowDOM,E3,null);Q7=E7.nextNode();)e7(i2.uponSanitizeShadowNode,Q7,null),Q6(Q7),x7(Q7),Q7.content instanceof s&&k3(Q7.content);e7(i2.afterSanitizeShadowDOM,E3,null)};return n.sanitize=function(k3){let E3=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Q7=null,E7=null,w6=null,n6=null;if(c8=!k3,c8&&(k3="<!-->"),typeof k3!="string"&&!W8(k3))if(typeof k3.toString=="function"){if(k3=k3.toString(),typeof k3!="string")throw oT("dirty is not a string, aborting")}else throw oT("toString is not a function");if(!n.isSupported)return k3;if(z7||b5(E3),n.removed=[],typeof k3=="string"&&(u6=!1),u6){if(k3.nodeName){const J3=g5(k3.nodeName);if(!z2[J3]||X2[J3])throw oT("root node is forbidden and cannot be sanitized in-place")}}else if(k3 instanceof C)Q7=B5("<!---->"),E7=Q7.ownerDocument.importNode(k3,!0),E7.nodeType===sT.element&&E7.nodeName==="BODY"||E7.nodeName==="HTML"?Q7=E7:Q7.appendChild(E7);else{if(!k6&&!y7&&!I6&&k3.indexOf("<")===-1)return O&&t0?O.createHTML(k3):k3;if(Q7=B5(k3),!Q7)return k6?null:t0?k:""}Q7&&X6&&s5(Q7.firstChild);const o6=U9(u6?k3:Q7);for(;w6=o6.nextNode();)Q6(w6),x7(w6),w6.content instanceof s&&s7(w6.content);if(u6)return k3;if(k6){if(z3)for(n6=p2.call(Q7.ownerDocument);Q7.firstChild;)n6.appendChild(Q7.firstChild);else n6=Q7;return(p0.shadowroot||p0.shadowrootmode)&&(n6=Q2.call(o,n6,!0)),n6}let g8=I6?Q7.outerHTML:Q7.innerHTML;return I6&&z2["!doctype"]&&Q7.ownerDocument&&Q7.ownerDocument.doctype&&Q7.ownerDocument.doctype.name&&hc(Cc2,Q7.ownerDocument.doctype.name)&&(g8="<!DOCTYPE "+Q7.ownerDocument.doctype.name+`>
|
|
597
|
+
`)).length,a=0;a<o;a++){var r=t.charCodeAt(a),C=null;r<128?i++:C=r>127&&r<2048?String.fromCharCode(r>>6|192,63&r|128):String.fromCharCode(r>>12|224,r>>6&63|128,63&r|128),Xp(C)||(i>n&&(s+=t.substring(n,i)),s+=C,n=i=a+1)}return i>n&&(s+=t.substring(n,t.length)),s},Q10=!!a_||!!o_,IA2="text/plain",nV=(t,n)=>{var[i,o]=t.split("?"),a=S4({},n);o==null||o.split("&").forEach(r=>{var[C]=r.split("=");delete a[C]});var s=e00(a);return s=s?(o?o+"&":"")+s:o,"".concat(i,"?").concat(s)},JM=(t,n)=>JSON.stringify(t,(i,o)=>typeof o=="bigint"?o.toString():o,n),uX=t=>{var{data:n,compression:i}=t;if(n){if(i===tg.GZipJS){var o=vu2(Iu2(JM(n)),{mtime:0}),a=new Blob([o],{type:IA2});return{contentType:IA2,body:a,estimatedSize:a.size}}if(i===tg.Base64){var s=function(l){var e,u,A,f,d,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",E=0,y=0,Q="",R=[];if(!l)return l;l=w10(l);do e=(d=l.charCodeAt(E++)<<16|l.charCodeAt(E++)<<8|l.charCodeAt(E++))>>18&63,u=d>>12&63,A=d>>6&63,f=63&d,R[y++]=g.charAt(e)+g.charAt(u)+g.charAt(A)+g.charAt(f);while(E<l.length);switch(Q=R.join(""),l.length%3){case 1:Q=Q.slice(0,-2)+"==";break;case 2:Q=Q.slice(0,-1)+"="}return Q}(JM(n)),r=(l=>"data="+encodeURIComponent(typeof l=="string"?l:JM(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var C=JM(n);return{contentType:"application/json",body:C,estimatedSize:new Blob([C]).size}}},qM=[];o_&&qM.push({transport:"fetch",method:t=>{var n,i,{contentType:o,body:a,estimatedSize:s}=(n=uX(t))!==null&&n!==void 0?n:{},r=new Headers;cl(t.headers,function(u,A){r.append(A,u)}),o&&r.append("Content-Type",o);var C=t.url,l=null;if(fl2){var e=new fl2;l={signal:e.signal,timeout:setTimeout(()=>e.abort(),t.timeout)}}o_(C,S4({method:(t==null?void 0:t.method)||"GET",headers:r,keepalive:t.method==="POST"&&(s||0)<52428.8,body:a,signal:(i=l)===null||i===void 0?void 0:i.signal},t.fetchOptions)).then(u=>u.text().then(A=>{var f,d={statusCode:u.status,text:A};if(u.status===200)try{d.json=JSON.parse(A)}catch(g){Wi.error(g)}(f=t.callback)===null||f===void 0||f.call(t,d)})).catch(u=>{var A;Wi.error(u),(A=t.callback)===null||A===void 0||A.call(t,{statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),a_&&qM.push({transport:"XHR",method:t=>{var n,i=new a_;i.open(t.method||"GET",t.url,!0);var{contentType:o,body:a}=(n=uX(t))!==null&&n!==void 0?n:{};cl(t.headers,function(s,r){i.setRequestHeader(r,s)}),o&&i.setRequestHeader("Content-Type",o),t.timeout&&(i.timeout=t.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(i.readyState===4){var s,r={statusCode:i.status,text:i.responseText};if(i.status===200)try{r.json=JSON.parse(i.responseText)}catch{}(s=t.callback)===null||s===void 0||s.call(t,r)}},i.send(a)}}),Bf!=null&&Bf.sendBeacon&&qM.push({transport:"sendBeacon",method:t=>{var n=nV(t.url,{beacon:"1"});try{var i,{contentType:o,body:a}=(i=uX(t))!==null&&i!==void 0?i:{},s=typeof a=="string"?new Blob([a],{type:o}):a;Bf.sendBeacon(n,s)}catch{}}});var AX=3e3;class M10{constructor(n,i){St(this,"isPaused",!0),St(this,"queue",[]),this.flushTimeoutMs=fd((i==null?void 0:i.flush_interval_ms)||AX,250,5e3,"flush interval",AX),this.sendRequest=n}enqueue(n){this.queue.push(n),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var n=this.queue.length>0?this.formatQueue():{},i=Object.values(n),o=[...i.filter(a=>a.url.indexOf("/e")===0),...i.filter(a=>a.url.indexOf("/e")!==0)];o.map(a=>{this.sendRequest(S4(S4({},a),{},{transport:"sendBeacon"}))})}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var n=this;this.isPaused||(this.flushTimeout=setTimeout(()=>{if(this.clearFlushTimeout(),this.queue.length>0){var i=this.formatQueue(),o=function(s){var r=i[s],C=new Date().getTime();r.data&&_l(r.data)&&cl(r.data,l=>{l.offset=Math.abs(l.timestamp-C),delete l.timestamp}),n.sendRequest(r)};for(var a in i)o(a)}},this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var n={};return cl(this.queue,i=>{var o,a=i,s=(a?a.batchKey:null)||a.url;Mr(n[s])&&(n[s]=S4(S4({},a),{},{data:[]})),(o=n[s].data)===null||o===void 0||o.push(a.data)}),this.queue=[],n}}var T10=["retriesPerformedSoFar"];class x10{constructor(n){St(this,"isPolling",!1),St(this,"pollIntervalMs",3e3),St(this,"queue",[]),this.instance=n,this.queue=[],this.areWeOnline=!0,!Mr(p4)&&"onLine"in p4.navigator&&(this.areWeOnline=p4.navigator.onLine,su(p4,"online",()=>{this.areWeOnline=!0,this.flush()}),su(p4,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(n){var{retriesPerformedSoFar:i}=n,o=vl2(n,T10);Ac(i)&&i>0&&(o.url=nV(o.url,{retry_count:i})),this.instance._send_request(S4(S4({},o),{},{callback:a=>{var s;a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(i??0)<10?this.enqueue(S4({retriesPerformedSoFar:i},o)):(s=o.callback)===null||s===void 0||s.call(o,a)}}))}enqueue(n){var i=n.retriesPerformedSoFar||0;n.retriesPerformedSoFar=i+1;var o=function(r){var C=3e3*Math.pow(2,r),l=C/2,e=Math.min(18e5,C),u=(Math.random()-.5)*(e-l);return Math.ceil(e+u)}(i),a=Date.now()+o;this.queue.push({retryAt:a,requestOptions:n});var s="Enqueued failed request for retry in ".concat(o);navigator.onLine||(s+=" (Browser is offline)"),Wi.warn(s),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout(()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()},this.pollIntervalMs)}flush(){var n=Date.now(),i=[],o=this.queue.filter(s=>s.retryAt<n||(i.push(s),!1));if(this.queue=i,o.length>0)for(var{requestOptions:a}of o)this.retriableRequest(a)}unload(){for(var{requestOptions:n}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(S4(S4({},n),{},{transport:"sendBeacon"}))}catch(i){Wi.error(i)}this.queue=[]}}class R10{constructor(n){St(this,"_updateScrollData",()=>{var i,o,a,s;this.context||(this.context={});var r=this.scrollElement(),C=this.scrollY(),l=r?Math.max(0,r.scrollHeight-r.clientHeight):0,e=C+((r==null?void 0:r.clientHeight)||0),u=(r==null?void 0:r.scrollHeight)||0;this.context.lastScrollY=Math.ceil(C),this.context.maxScrollY=Math.max(C,(i=this.context.maxScrollY)!==null&&i!==void 0?i:0),this.context.maxScrollHeight=Math.max(l,(o=this.context.maxScrollHeight)!==null&&o!==void 0?o:0),this.context.lastContentY=e,this.context.maxContentY=Math.max(e,(a=this.context.maxContentY)!==null&&a!==void 0?a:0),this.context.maxContentHeight=Math.max(u,(s=this.context.maxContentHeight)!==null&&s!==void 0?s:0)}),this.instance=n}getContext(){return this.context}resetContext(){var n=this.context;return setTimeout(this._updateScrollData,0),n}startMeasuringScrollPosition(){su(p4,"scroll",this._updateScrollData,{capture:!0}),su(p4,"scrollend",this._updateScrollData,{capture:!0}),su(p4,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return p4==null?void 0:p4.document.documentElement;var n=_l(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var i of n){var o=p4==null?void 0:p4.document.querySelector(i);if(o)return o}}scrollY(){if(this.instance.config.scroll_root_selector){var n=this.scrollElement();return n&&n.scrollTop||0}return p4&&(p4.scrollY||p4.pageYOffset||p4.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var n=this.scrollElement();return n&&n.scrollLeft||0}return p4&&(p4.scrollX||p4.pageXOffset||p4.document.documentElement.scrollLeft)||0}}var H10=t=>Sl.personInfo({maskPersonalDataProperties:t==null?void 0:t.config.mask_personal_data_properties,customPersonalDataProperties:t==null?void 0:t.config.custom_personal_data_properties});class D10{constructor(n,i,o,a){St(this,"_onSessionIdCallback",s=>{var r=this._getStored();if(!r||r.sessionId!==s){var C={sessionId:s,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[h_]:C})}}),this.instance=n,this._sessionIdManager=i,this._persistence=o,this._sessionSourceParamGenerator=a||H10,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[h_]}getSetOnceProps(){var n,i=(n=this._getStored())===null||n===void 0?void 0:n.props;return i?"r"in i?Sl.personPropsFromInfo(i):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var n={};return cl(NM(this.getSetOnceProps()),(i,o)=>{o==="$current_url"&&(o="url"),n["$session_entry_".concat(C_(o))]=i}),n}}var mA2=PA("[SessionId]");class N10{constructor(n,i,o){var a;if(St(this,"_sessionIdChangedHandlers",[]),!n.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(n.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.config=n.config,this.persistence=n.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=i||$p,this._windowIdGenerator=o||$p;var s=this.config.persistence_name||this.config.token,r=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*fd(r,60,36e3,"session_idle_timeout_seconds",1800),n.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var C=uA.parse(this._window_id_storage_key),l=uA.parse(this._primary_window_exists_storage_key);C&&!l?this._windowId=C:uA.remove(this._window_id_storage_key),uA.set(this._primary_window_exists_storage_key,!0)}if((a=this.config.bootstrap)!==null&&a!==void 0&&a.sessionID)try{var e=(u=>{var A=u.replace(/-/g,"");if(A.length!==32)throw new Error("Not a valid UUID");if(A[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(A.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,new Date().getTime(),e)}catch(u){mA2.error("Invalid sessionID in bootstrap",u)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(n){return Mr(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(n),this._sessionId&&n(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(i=>i!==n)}}_canUseSessionStorage(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&uA.is_supported()}_setWindowId(n){n!==this._windowId&&(this._windowId=n,this._canUseSessionStorage()&&uA.set(this._window_id_storage_key,n))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?uA.parse(this._window_id_storage_key):null}_setSessionId(n,i,o){n===this._sessionId&&i===this._sessionActivityTimestamp&&o===this._sessionStartTimestamp||(this._sessionStartTimestamp=o,this._sessionActivityTimestamp=i,this._sessionId=n,this.persistence.register({[xS]:[i,n,o]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var n=this.persistence.props[xS];return _l(n)&&n.length===2&&n.push(n[0]),n||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){su(p4,"beforeunload",()=>{this._canUseSessionStorage()&&uA.remove(this._primary_window_exists_storage_key)},{capture:!1})}checkAndGetSessionAndWindowId(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.config.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var o=i||new Date().getTime(),[a,s,r]=this._getSessionId(),C=this._getWindowId(),l=Ac(r)&&r>0&&Math.abs(o-r)>864e5,e=!1,u=!s,A=!n&&Math.abs(o-a)>this.sessionTimeoutMs;u||A||l?(s=this._sessionIdGenerator(),C=this._windowIdGenerator(),mA2.info("new session ID generated",{sessionId:s,windowId:C,changeReason:{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}}),r=o,e=!0):C||(C=this._windowIdGenerator(),e=!0);var f=a===0||!n||l?o:a,d=r===0?new Date().getTime():r;return this._setWindowId(C),this._setSessionId(s,f,d),n||this.resetIdleTimer(),e&&this._sessionIdChangedHandlers.forEach(g=>g(s,C,e?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0)),{sessionId:s,windowId:C,sessionStartTimestamp:d,changeReason:e?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:a}}resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{this.resetSessionId()},1.1*this.sessionTimeoutMs)}}var S10=["$set_once","$set"],rv=PA("[SiteApps]");class V10{constructor(n){this.instance=n,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(n,i){if(i){var o=this.globalsForEvent(i);this.bufferedInvocations.push(o),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var n,i;return(n=zs._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(i=n[this.instance.config.token])===null||i===void 0?void 0:i.siteApps}init(){if(this.isEnabled){var n=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{n(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(n){var i,o,a,s,r,C,l;if(!n)throw new Error("Event payload is required");var e={},u=this.instance.get_property("$groups")||[],A=this.instance.get_property("$stored_group_properties")||{};for(var[f,d]of Object.entries(A))e[f]={id:u[f],type:f,properties:d};var{$set_once:g,$set:E}=n;return{event:S4(S4({},vl2(n,S10)),{},{properties:S4(S4(S4({},n.properties),E?{$set:S4(S4({},(i=(o=n.properties)===null||o===void 0?void 0:o.$set)!==null&&i!==void 0?i:{}),E)}:{}),g?{$set_once:S4(S4({},(a=(s=n.properties)===null||s===void 0?void 0:s.$set_once)!==null&&a!==void 0?a:{}),g)}:{}),elements_chain:(r=(C=n.properties)===null||C===void 0?void 0:C.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(l=n.properties)===null||l===void 0?void 0:l.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:e}}setupSiteApp(n){var i=this.apps[n.id],o=()=>{var C;!i.errored&&this.bufferedInvocations.length&&(rv.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(n.id)),this.bufferedInvocations.forEach(l=>{var e;return(e=i.processEvent)===null||e===void 0?void 0:e.call(i,l)}),i.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((C=this.stopBuffering)===null||C===void 0||C.call(this))},a=!1,s=C=>{i.errored=!C,i.loaded=!0,rv.info("Site app with id ".concat(n.id," ").concat(C?"loaded":"errored")),a&&o()};try{var{processEvent:r}=n.init({posthog:this.instance,callback:C=>{s(C)}});r&&(i.processEvent=r),a=!0}catch(C){rv.error("Error while initializing PostHog app with config id ".concat(n.id),C),s(!1)}if(a&&i.loaded)try{o()}catch(C){rv.error("Error while processing buffered events PostHog app with config id ".concat(n.id),C),i.errored=!0}}setupSiteApps(){var n=this.siteAppLoaders||[];for(var i of n)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var o of n)this.setupSiteApp(o)}onCapturedEvent(n){if(Object.keys(this.apps).length!==0){var i=this.globalsForEvent(n);for(var o of Object.values(this.apps))try{var a;(a=o.processEvent)===null||a===void 0||a.call(o,i)}catch(s){rv.error("Error while processing event ".concat(n.event," for site app ").concat(o.id),s)}}}onRemoteConfig(n){var i,o,a,s=this;if((i=this.siteAppLoaders)!==null&&i!==void 0&&i.length)return this.isEnabled?(this.setupSiteApps(),void this.instance.on("eventCaptured",e=>this.onCapturedEvent(e))):void rv.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((o=this.stopBuffering)===null||o===void 0||o.call(this),(a=n.siteApps)!==null&&a!==void 0&&a.length)if(this.isEnabled){var r=function(e,u){var A,f;zs["__$$ph_site_app_".concat(e)]=s.instance,(A=zs.__PosthogExtensions__)===null||A===void 0||(f=A.loadSiteApp)===null||f===void 0||f.call(A,s.instance,u,d=>{if(d)return rv.error("Error while initializing PostHog app with config id ".concat(e),d)})};for(var{id:C,url:l}of n.siteApps)r(C,l)}else rv.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var Tm,k10=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","bytespider"],bA2=function(t,n){if(!t)return!1;var i=t.toLowerCase();return k10.concat(n||[]).some(o=>{var a=o.toLowerCase();return i.indexOf(a)!==-1})},BA2=function(t,n){if(!t)return!1;var i=t.userAgent;if(i&&bA2(i,n))return!0;try{var o=t==null?void 0:t.userAgentData;if(o!=null&&o.brands&&o.brands.some(a=>bA2(a==null?void 0:a.brand,n)))return!0}catch{}return!!t.webdriver};function cX(t,n,i){return JM({distinct_id:t,userPropertiesToSet:n,userPropertiesToSetOnce:i})}(function(t){t.US="us",t.EU="eu",t.CUSTOM="custom"})(Tm||(Tm={}));var yA2="i.posthog.com";class O10{constructor(n){St(this,"_regionCache",{}),this.instance=n}get apiHost(){var n=this.instance.config.api_host.trim().replace(/\/$/,"");return n==="https://app.posthog.com"?"https://us.i.posthog.com":n}get uiHost(){var n,i=(n=this.instance.config.ui_host)===null||n===void 0?void 0:n.replace(/\/$/,"");return i||(i=this.apiHost.replace(".".concat(yA2),".posthog.com")),i==="https://app.posthog.com"?"https://us.posthog.com":i}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=Tm.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=Tm.EU:this._regionCache[this.apiHost]=Tm.CUSTOM),this._regionCache[this.apiHost]}endpointFor(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(i&&(i=i[0]==="/"?i:"/".concat(i)),n==="ui")return this.uiHost+i;if(this.region===Tm.CUSTOM)return this.apiHost+i;var o=yA2+i;switch(n){case"assets":return"https://".concat(this.region,"-assets.").concat(o);case"api":return"https://".concat(this.region,".").concat(o)}}}var P10={icontains:(t,n)=>!!p4&&n.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,n)=>!!p4&&n.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,n)=>!!p4&&Ty(n.href,t),not_regex:(t,n)=>!!p4&&!Ty(n.href,t),exact:(t,n)=>n.href===t,is_not:(t,n)=>n.href!==t};class FA{constructor(n){var i=this;St(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var o=arguments.length>0&&arguments[0]!==void 0&&arguments[0];i.getWebExperiments(a=>{FA.logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,a.forEach(s=>{if(s.feature_flag_key){var r;i._flagToExperiments&&(FA.logInfo("setting flag key ",s.feature_flag_key," to web experiment ",s),(r=i._flagToExperiments)===null||r===void 0||r.set(s.feature_flag_key,s));var C=i.instance.getFeatureFlag(s.feature_flag_key);Iu(C)&&s.variants[C]&&i.applyTransforms(s.name,C,s.variants[C].transforms)}else if(s.variants)for(var l in s.variants){var e=s.variants[l];FA.matchesTestVariant(e)&&i.applyTransforms(s.name,l,e.transforms)}})},o)}),this.instance=n,this.instance.onFeatureFlags(o=>{this.onFeatureFlags(o)})}onFeatureFlags(n){if(this._is_bot())FA.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(ll(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();FA.logInfo("applying feature flags",n),n.forEach(i=>{var o;if(this._flagToExperiments&&(o=this._flagToExperiments)!==null&&o!==void 0&&o.has(i)){var a,s=this.instance.getFeatureFlag(i),r=(a=this._flagToExperiments)===null||a===void 0?void 0:a.get(i);s&&r!=null&&r.variants[s]&&this.applyTransforms(r.name,s,r.variants[s].transforms)}})}}previewWebExperiment(){var n=FA.getWindowLocation();if(n!=null&&n.search){var i=OS(n==null?void 0:n.search,"__experiment_id"),o=OS(n==null?void 0:n.search,"__experiment_variant");i&&o&&(FA.logInfo("previewing web experiments ".concat(i," && ").concat(o)),this.getWebExperiments(a=>{this.showPreviewWebExperiment(parseInt(i),o,a)},!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(n,i,o){if(this.instance.config.disable_web_experiments&&!o)return n([]);var a=this.instance.get_property("$web_experiments");if(a&&!i)return n(a);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return n([]);var r=s.json.experiments||[];return n(r)}})}showPreviewWebExperiment(n,i,o){var a=o.filter(s=>s.id===n);a&&a.length>0&&(FA.logInfo("Previewing web experiment [".concat(a[0].name,"] with variant [").concat(i,"]")),this.applyTransforms(a[0].name,i,a[0].variants[i].transforms))}static matchesTestVariant(n){return!ll(n.conditions)&&FA.matchUrlConditions(n)&&FA.matchUTMConditions(n)}static matchUrlConditions(n){var i;if(ll(n.conditions)||ll((i=n.conditions)===null||i===void 0?void 0:i.url))return!0;var o,a,s,r=FA.getWindowLocation();return!!r&&((o=n.conditions)===null||o===void 0||!o.url||P10[(a=(s=n.conditions)===null||s===void 0?void 0:s.urlMatchType)!==null&&a!==void 0?a:"icontains"](n.conditions.url,r))}static getWindowLocation(){return p4==null?void 0:p4.location}static matchUTMConditions(n){var i;if(ll(n.conditions)||ll((i=n.conditions)===null||i===void 0?void 0:i.utm))return!0;var o=Sl.campaignParams();if(o.utm_source){var a,s,r,C,l,e,u,A,f,d,g,E,y,Q,R,D,O=(a=n.conditions)===null||a===void 0||(s=a.utm)===null||s===void 0||!s.utm_campaign||((r=n.conditions)===null||r===void 0||(C=r.utm)===null||C===void 0?void 0:C.utm_campaign)==o.utm_campaign,k=(l=n.conditions)===null||l===void 0||(e=l.utm)===null||e===void 0||!e.utm_source||((u=n.conditions)===null||u===void 0||(A=u.utm)===null||A===void 0?void 0:A.utm_source)==o.utm_source,J=(f=n.conditions)===null||f===void 0||(d=f.utm)===null||d===void 0||!d.utm_medium||((g=n.conditions)===null||g===void 0||(E=g.utm)===null||E===void 0?void 0:E.utm_medium)==o.utm_medium,e2=(y=n.conditions)===null||y===void 0||(Q=y.utm)===null||Q===void 0||!Q.utm_term||((R=n.conditions)===null||R===void 0||(D=R.utm)===null||D===void 0?void 0:D.utm_term)==o.utm_term;return O&&J&&e2&&k}return!1}static logInfo(n){for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];Wi.info("[WebExperiments] ".concat(n),o)}applyTransforms(n,i,o){this._is_bot()?FA.logInfo("Refusing to render web experiment since the viewer is a likely bot"):i!=="control"?o.forEach(a=>{if(a.selector){var s;FA.logInfo("applying transform of variant ".concat(i," for experiment ").concat(n," "),a);var r=(s=document)===null||s===void 0?void 0:s.querySelectorAll(a.selector);r==null||r.forEach(C=>{var l=C;a.html&&(l.innerHTML=a.html),a.css&&l.setAttribute("style",a.css)})}}):FA.logInfo("Control variants leave the page unmodified.")}_is_bot(){return Bf&&this.instance?BA2(Bf,this.instance.config.custom_blocked_useragents):void 0}}var $M={},fX=()=>{},xy="posthog",LA2=!Q10&&(vu==null?void 0:vu.indexOf("MSIE"))===-1&&(vu==null?void 0:vu.indexOf("Mozilla"))===-1,wA2=()=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:z20(Fn==null?void 0:Fn.location),persistence:"localStorage+cookie",persistence_name:"",loaded:fX,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:cd&&Iu(cd==null?void 0:cd.search)&&cd.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(p4==null||(t=p4.location)===null||t===void 0?void 0:t.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var i="Bad HTTP status: "+n.statusCode+" "+n.text;Wi.error(i)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:AX},_onCapture:fX}},QA2=t=>{var n={};Mr(t.process_person)||(n.person_profiles=t.process_person),Mr(t.xhr_headers)||(n.request_headers=t.xhr_headers),Mr(t.cookie_name)||(n.persistence_name=t.cookie_name),Mr(t.disable_cookie)||(n.disable_persistence=t.disable_cookie),Mr(t.store_google)||(n.save_campaign_params=t.store_google),Mr(t.verbose)||(n.debug=t.verbose);var i=mu({},n,t);return _l(t.property_blacklist)&&(Mr(t.property_denylist)?i.property_denylist=t.property_blacklist:_l(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:Wi.error("Invalid value for property_denylist config: "+t.property_denylist)),i};class Z10{constructor(){St(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(n){Wi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=n}}class iV{get decideEndpointWasHit(){var n,i;return(n=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&n!==void 0&&n}constructor(){St(this,"webPerformance",new Z10),St(this,"_personProcessingSetOncePropertiesSent",!1),St(this,"version",pE.LIB_VERSION),St(this,"_internalEventEmitter",new hA2),this.config=wA2(),this.SentryIntegration=_00,this.sentryIntegration=n=>function(i,o){var a=Lu2(i,o);return{name:yu2,processEvent:s=>a(s)}}(this,n),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this._cachedIdentify=null,this.featureFlags=new g10(this),this.toolbar=new K00(this),this.scrollManager=new R10(this),this.pageViewManager=new r10(this),this.surveys=new B10(this),this.experiments=new FA(this),this.exceptions=new n10(this),this.rateLimiter=new y10(this),this.requestRouter=new O10(this),this.consent=new f00(this),this.people={set:(n,i,o)=>{var a=Iu(n)?{[n]:i}:n;this.setPersonProperties(a),o==null||o({})},set_once:(n,i,o)=>{var a=Iu(n)?{[n]:i}:n;this.setPersonProperties(void 0,a),o==null||o({})}},this.on("eventCaptured",n=>Wi.info('send "'.concat(n==null?void 0:n.event,'"'),n))}init(n,i,o){if(o&&o!==xy){var a,s=(a=$M[o])!==null&&a!==void 0?a:new iV;return s._init(n,i,o),$M[o]=s,$M[xy][o]=s,s}return this._init(n,i,o)}_init(n){var i,o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(Mr(n)||l_(n))return Wi.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return Wi.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],a.person_profiles&&(this._initialPersonProfilesConfig=a.person_profiles),this.set_config(mu({},wA2(),QA2(a),{name:s,token:n})),this.config.on_xhr_error&&Wi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=a.disable_compression?void 0:tg.GZipJS,this.persistence=new tX(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tX(S4(S4({},this.config),{},{persistence:"sessionStorage"}));var r=S4({},this.persistence.props),C=S4({},this.sessionPersistence.props);if(this._requestQueue=new M10(Q=>this._send_retriable_request(Q),this.config.request_queue_config),this._retryQueue=new x10(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new N10(this),this.sessionPropsManager=new D10(this,this.sessionManager,this.persistence)),new q00(this).startIfEnabledOrStop(),this.siteApps=new V10(this),(i=this.siteApps)===null||i===void 0||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new Y00(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new i00(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new t10(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new $00(this),this.exceptionObserver=new h00(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new tu2(this,g00),this.deadClicksAutocapture.startIfEnabled(),pE.DEBUG=pE.DEBUG||this.config.debug,pE.DEBUG&&Wi.info("Starting in debug mode",{this:this,config:a,thisC:S4({},this.config),p:r,s:C}),this._sync_opt_out_with_persistence(),((o=a.bootstrap)===null||o===void 0?void 0:o.distinctID)!==void 0){var l,e,u=this.config.get_device_id($p()),A=(l=a.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?u:a.bootstrap.distinctID;this.persistence.set_property(vE,(e=a.bootstrap)!==null&&e!==void 0&&e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:a.bootstrap.distinctID,$device_id:A})}if(this._hasBootstrappedFeatureFlags()){var f,d,g=Object.keys(((f=a.bootstrap)===null||f===void 0?void 0:f.featureFlags)||{}).filter(Q=>{var R,D;return!((R=a.bootstrap)===null||R===void 0||(D=R.featureFlags)===null||D===void 0||!D[Q])}).reduce((Q,R)=>{var D,O;return Q[R]=((D=a.bootstrap)===null||D===void 0||(O=D.featureFlags)===null||O===void 0?void 0:O[R])||!1,Q},{}),E=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlagPayloads)||{}).filter(Q=>g[Q]).reduce((Q,R)=>{var D,O,k,J;return(D=a.bootstrap)!==null&&D!==void 0&&(O=D.featureFlagPayloads)!==null&&O!==void 0&&O[R]&&(Q[R]=(k=a.bootstrap)===null||k===void 0||(J=k.featureFlagPayloads)===null||J===void 0?void 0:J[R]),Q},{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:E})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Vl2,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id($p());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(vE,"anonymous")}return su(p4,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),a.segment?W00(this,()=>this._loaded()):this._loaded(),rg(this.config._onCapture)&&this.config._onCapture!==fX&&(Wi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",Q=>this.config._onCapture(Q.event,Q))),this}_onRemoteConfig(n){var i,o,a,s,r,C,l,e;if(!Fn||!Fn.body)return Wi.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(n)},500);this.compression=void 0,n.supportedCompression&&!this.config.disable_compression&&(this.compression=lC(n.supportedCompression,tg.GZipJS)?tg.GZipJS:lC(n.supportedCompression,tg.Base64)?tg.Base64:void 0),(i=n.analytics)!==null&&i!==void 0&&i.endpoint&&(this.analyticsDefaultEndpoint=n.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),(o=this.siteApps)===null||o===void 0||o.onRemoteConfig(n),(a=this.sessionRecording)===null||a===void 0||a.onRemoteConfig(n),(s=this.autocapture)===null||s===void 0||s.onRemoteConfig(n),(r=this.heatmaps)===null||r===void 0||r.onRemoteConfig(n),this.surveys.onRemoteConfig(n),(C=this.webVitalsAutocapture)===null||C===void 0||C.onRemoteConfig(n),(l=this.exceptionObserver)===null||l===void 0||l.onRemoteConfig(n),(e=this.deadClicksAutocapture)===null||e===void 0||e.onRemoteConfig(n)}_loaded(){try{this.config.loaded(this)}catch(n){Wi.critical("`loaded` function failed",n)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new L10(this).load(),this.featureFlags.decide()}_start_queue_if_opted_in(){var n;this.has_opted_out_capturing()||this.config.request_batching&&((n=this._requestQueue)===null||n===void 0||n.enable())}_dom_loaded(){this.has_opted_out_capturing()||Jp(this.__request_queue,n=>this._send_retriable_request(n)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var n,i;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),(n=this._requestQueue)===null||n===void 0||n.unload(),(i=this._retryQueue)===null||i===void 0||i.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(n){this.__loaded&&(LA2?this.__request_queue.push(n):this.rateLimiter.isServerRateLimited(n.batchKey)||(n.transport=n.transport||this.config.api_transport,n.url=nV(n.url,{ip:this.config.ip?1:0}),n.headers=S4({},this.config.request_headers),n.compression=n.compression==="best-available"?this.compression:n.compression,n.fetchOptions=n.fetchOptions||this.config.fetch_options,(i=>{var o,a,s,r=S4({},i);r.timeout=r.timeout||6e4,r.url=nV(r.url,{_:new Date().getTime().toString(),ver:pE.LIB_VERSION,compression:r.compression});var C=(o=r.transport)!==null&&o!==void 0?o:"fetch",l=(a=(s=ml2(qM,e=>e.transport===C))===null||s===void 0?void 0:s.method)!==null&&a!==void 0?a:qM[0].method;if(!l)throw new Error("No available transport method");l(r)})(S4(S4({},n),{},{callback:i=>{var o,a,s;this.rateLimiter.checkForLimiting(i),i.statusCode>=400&&((a=(s=this.config).on_request_error)===null||a===void 0||a.call(s,i)),(o=n.callback)===null||o===void 0||o.call(n,i)}}))))}_send_retriable_request(n){this._retryQueue?this._retryQueue.retriableRequest(n):this._send_request(n)}_execute_array(n){var i,o=[],a=[],s=[];Jp(n,C=>{C&&(i=C[0],_l(i)?s.push(C):rg(C)?C.call(this):_l(C)&&i==="alias"?o.push(C):_l(C)&&i.indexOf("capture")!==-1&&rg(this[i])?s.push(C):a.push(C))});var r=function(C,l){Jp(C,function(e){if(_l(e[0])){var u=l;cl(e,function(A){u=u[A[0]].apply(u,A.slice(1))})}else this[e[0]].apply(this,e.slice(1))},l)};r(o,this),r(a,this),r(s,this)}_hasBootstrappedFeatureFlags(){var n,i;return((n=this.config.bootstrap)===null||n===void 0?void 0:n.featureFlags)&&Object.keys((i=this.config.bootstrap)===null||i===void 0?void 0:i.featureFlags).length>0||!1}push(n){this._execute_array([n])}capture(n,i,o){var a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!Mr(n)&&Iu(n)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var s=o!=null&&o.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){i!=null&&i.$current_url&&!Iu(i==null?void 0:i.$current_url)&&(Wi.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),i==null||delete i.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var r=new Date,C=(o==null?void 0:o.timestamp)||r,l=$p(),e={uuid:l,event:n,properties:this._calculate_event_properties(n,i||{},C,l)};s&&(e.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),o!=null&&o.$set&&(e.$set=o==null?void 0:o.$set);var u=this._calculate_set_once_properties(o==null?void 0:o.$set_once);u&&(e.$set_once=u),(e=U20(e,o!=null&&o._noTruncate?null:this.config.properties_string_max_length)).timestamp=C,Mr(o==null?void 0:o.timestamp)||(e.properties.$event_time_override_provided=!0,e.properties.$event_time_override_system_time=r);var A=S4(S4({},e.properties.$set),e.$set);if(py(A)||this.setPersonPropertiesForFlags(A),!ll(this.config.before_send)){var f=this._runBeforeSend(e);if(!f)return;e=f}this._internalEventEmitter.emit("eventCaptured",e);var d={method:"POST",url:(a=o==null?void 0:o._url)!==null&&a!==void 0?a:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:e,compression:"best-available",batchKey:o==null?void 0:o._batchKey};return!this.config.request_batching||o&&(o==null||!o._batchKey)||o!=null&&o.send_instantly?this._send_retriable_request(d):this._requestQueue.enqueue(d),e}Wi.critical("This capture call is ignored due to client rate limiting.")}}else Wi.error("No event name provided to posthog.capture")}else Wi.uninitializedWarning("posthog.capture")}_addCaptureHook(n){return this.on("eventCaptured",i=>n(i.event,i))}_calculate_event_properties(n,i,o,a){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return i;var s=this.persistence.remove_event_timer(n),r=S4({},i);if(r.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(r.$cookieless_mode=!0),n==="$snapshot"){var C=S4(S4({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=C.distinct_id,(!Iu(r.distinct_id)&&!Ac(r.distinct_id)||l_(r.distinct_id))&&Wi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var l,e=Sl.properties({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});if(this.sessionManager){var{sessionId:u,windowId:A}=this.sessionManager.checkAndGetSessionAndWindowId();r.$session_id=u,r.$window_id=A}this.sessionPropsManager&&mu(r,this.sessionPropsManager.getSessionProps());try{var f,d;this.sessionRecording&&(r.$recording_status=this.sessionRecording.status,r.$sdk_debug_replay_internal_buffer_length=this.sessionRecording.buffer.data.length,r.$sdk_debug_replay_internal_buffer_size=this.sessionRecording.buffer.size),r.$sdk_debug_retry_queue_size=(f=this._retryQueue)===null||f===void 0||(d=f.queue)===null||d===void 0?void 0:d.length}catch(Q){r.$sdk_debug_error_capturing_properties=String(Q)}if(this.requestRouter.region===Tm.CUSTOM&&(r.$lib_custom_api_host=this.config.api_host),l=n==="$pageview"?this.pageViewManager.doPageView(o,a):n==="$pageleave"?this.pageViewManager.doPageLeave(o):this.pageViewManager.doEvent(),r=mu(r,l),n==="$pageview"&&Fn&&(r.title=Fn.title),!Mr(s)){var g=o.getTime()-s;r.$duration=parseFloat((g/1e3).toFixed(3))}vu&&this.config.opt_out_useragent_filter&&(r.$browser_type=this._is_bot()?"bot":"browser"),(r=mu({},e,this.persistence.properties(),this.sessionPersistence.properties(),r)).$is_identified=this._isIdentified(),_l(this.config.property_denylist)?cl(this.config.property_denylist,function(Q){delete r[Q]}):Wi.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var E=this.config.sanitize_properties;E&&(Wi.error("sanitize_properties is deprecated. Use before_send instead"),r=E(r,n));var y=this._hasPersonProcessing();return r.$process_person_profile=y,y&&this._requirePersonProcessing("_calculate_event_properties"),r}_calculate_set_once_properties(n){var i;if(!this.persistence||!this._hasPersonProcessing()||this._personProcessingSetOncePropertiesSent)return n;var o=this.persistence.get_initial_props(),a=(i=this.sessionPropsManager)===null||i===void 0?void 0:i.getSetOnceProps(),s=mu({},o,a||{},n||{}),r=this.config.sanitize_properties;return r&&(Wi.error("sanitize_properties is deprecated. Use before_send instead"),s=r(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,py(s)?void 0:s}register(n,i){var o;(o=this.persistence)===null||o===void 0||o.register(n,i)}register_once(n,i,o){var a;(a=this.persistence)===null||a===void 0||a.register_once(n,i,o)}register_for_session(n){var i;(i=this.sessionPersistence)===null||i===void 0||i.register(n)}unregister(n){var i;(i=this.persistence)===null||i===void 0||i.unregister(n)}unregister_for_session(n){var i;(i=this.sessionPersistence)===null||i===void 0||i.unregister(n)}_register_single(n,i){this.register({[n]:i})}getFeatureFlag(n,i){return this.featureFlags.getFeatureFlag(n,i)}getFeatureFlagPayload(n){var i=this.featureFlags.getFeatureFlagPayload(n);try{return JSON.parse(i)}catch{return i}}isFeatureEnabled(n,i){return this.featureFlags.isFeatureEnabled(n,i)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(n,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(n,i)}getEarlyAccessFeatures(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],o=arguments.length>2?arguments[2]:void 0;return this.featureFlags.getEarlyAccessFeatures(n,i,o)}on(n,i){return this._internalEventEmitter.on(n,i)}onFeatureFlags(n){return this.featureFlags.onFeatureFlags(n)}onSurveysLoaded(n){return this.surveys.onSurveysLoaded(n)}onSessionId(n){var i,o;return(i=(o=this.sessionManager)===null||o===void 0?void 0:o.onSessionId(n))!==null&&i!==void 0?i:()=>{}}getSurveys(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(n,i)}getActiveMatchingSurveys(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(n,i)}renderSurvey(n,i){this.surveys.renderSurvey(n,i)}canRenderSurvey(n){this.surveys.canRenderSurvey(n)}identify(n,i,o){if(!this.__loaded||!this.persistence)return Wi.uninitializedWarning("posthog.identify");if(Ac(n)&&(n=n.toString(),Wi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),n){if(["distinct_id","distinctid"].includes(n.toLowerCase()))Wi.critical('The string "'.concat(n,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var a=this.get_distinct_id();if(this.register({$user_id:n}),!this.get_property("$device_id")){var s=a;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}n!==a&&n!==this.get_property(SM)&&(this.unregister(SM),this.register({distinct_id:n}));var r=(this.persistence.get_property(vE)||"anonymous")==="anonymous";n!==a&&r?(this.persistence.set_property(vE,"identified"),this.setPersonPropertiesForFlags(S4(S4({},o||{}),i||{}),!1),this.capture("$identify",{distinct_id:n,$anon_distinct_id:a},{$set:i||{},$set_once:o||{}}),this.featureFlags.setAnonymousDistinctId(a),this._cachedIdentify=cX(n,i,o)):(i||o)&&(this._cachedIdentify!==cX(n,i,o)?(this.setPersonProperties(i,o),this._cachedIdentify=cX(n,i,o)):Wi.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),n!==a&&(this.reloadFeatureFlags(),this.unregister(DS))}}else Wi.error("Unique user id has not been set in posthog.identify")}setPersonProperties(n,i){(n||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(S4(S4({},i||{}),n||{})),this.capture("$set",{$set:n||{},$set_once:i||{}}))}group(n,i,o){if(n&&i){if(this._requirePersonProcessing("posthog.group")){var a=this.getGroups();a[n]!==i&&this.resetGroupPropertiesForFlags(n),this.register({$groups:S4(S4({},a),{},{[n]:i})}),o&&(this.capture("$groupidentify",{$group_type:n,$group_key:i,$group_set:o}),this.setGroupPropertiesForFlags({[n]:o})),a[n]===i||o||this.reloadFeatureFlags()}}else Wi.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setPersonPropertiesForFlags(n,i)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(n,i)}resetGroupPropertiesForFlags(n){this.featureFlags.resetGroupPropertiesForFlags(n)}reset(n){var i,o,a,s;if(Wi.info("reset"),!this.__loaded)return Wi.uninitializedWarning("posthog.reset");var r=this.get_property("$device_id");if(this.consent.reset(),(i=this.persistence)===null||i===void 0||i.clear(),(o=this.sessionPersistence)===null||o===void 0||o.clear(),this.surveys.reset(),(a=this.persistence)===null||a===void 0||a.set_property(vE,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Vl2,$device_id:null},"");else{var C=this.config.get_device_id($p());this.register_once({distinct_id:C,$device_id:n?C:r},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var n,i;return(n=(i=this.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&n!==void 0?n:""}get_session_replay_url(n){if(!this.sessionManager)return"";var{sessionId:i,sessionStartTimestamp:o}=this.sessionManager.checkAndGetSessionAndWindowId(!0),a=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(i));if(n!=null&&n.withTimestamp&&o){var s,r=(s=n.timestampLookBack)!==null&&s!==void 0?s:10;if(!o)return a;var C=Math.max(Math.floor((new Date().getTime()-o)/1e3)-r,0);a+="?t=".concat(C)}return a}alias(n,i){return n===this.get_property(bl2)?(Wi.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Mr(i)&&(i=this.get_distinct_id()),n!==i?(this._register_single(SM,n),this.capture("$create_alias",{alias:n,distinct_id:i})):(Wi.warn("alias matches current distinct_id - skipping api call."),this.identify(n),-1)):void 0}set_config(n){var i,o,a,s,r=S4({},this.config);Xl(n)&&(mu(this.config,QA2(n)),(i=this.persistence)===null||i===void 0||i.update_config(this.config,r),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tX(S4(S4({},this.config),{},{persistence:"sessionStorage"})),Du.is_supported()&&Du.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(pE.DEBUG=!0,Wi.info("set_config",JSON.stringify({config:n,oldConfig:r,newConfig:S4({},this.config)},null,2))),(o=this.sessionRecording)===null||o===void 0||o.startIfEnabledOrStop(),(a=this.autocapture)===null||a===void 0||a.startIfEnabled(),(s=this.heatmaps)===null||s===void 0||s.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(n){var i=n===!0,o={sampling:i||!(n==null||!n.sampling),linked_flag:i||!(n==null||!n.linked_flag),url_trigger:i||!(n==null||!n.url_trigger),event_trigger:i||!(n==null||!n.event_trigger)};if(Object.values(o).some(Boolean)){var a,s,r,C,l;(a=this.sessionManager)===null||a===void 0||a.checkAndGetSessionAndWindowId(),o.sampling&&((s=this.sessionRecording)===null||s===void 0||s.overrideSampling()),o.linked_flag&&((r=this.sessionRecording)===null||r===void 0||r.overrideLinkedFlag()),o.url_trigger&&((C=this.sessionRecording)===null||C===void 0||C.overrideTrigger("url")),o.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var n;return!((n=this.sessionRecording)===null||n===void 0||!n.started)}captureException(n,i){var o=new Error("PostHog syntheticException");this.exceptions.sendExceptionEvent(S4(S4({},M00((a=>a instanceof Error)(n)?{error:n,event:n.message}:{event:n},{syntheticException:o})),i))}loadToolbar(n){return this.toolbar.loadToolbar(n)}get_property(n){var i;return(i=this.persistence)===null||i===void 0?void 0:i.props[n]}getSessionProperty(n){var i;return(i=this.sessionPersistence)===null||i===void 0?void 0:i.props[n]}toString(){var n,i=(n=this.config.name)!==null&&n!==void 0?n:xy;return i!==xy&&(i=xy+"."+i),i}_isIdentified(){var n,i;return((n=this.persistence)===null||n===void 0?void 0:n.get_property(vE))==="identified"||((i=this.sessionPersistence)===null||i===void 0?void 0:i.get_property(vE))==="identified"}_hasPersonProcessing(){var n,i,o,a;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&py(this.getGroups())&&((n=this.persistence)===null||n===void 0||(i=n.props)===null||i===void 0||!i[SM])&&((o=this.persistence)===null||o===void 0||(a=o.props)===null||a===void 0||!a[NS]))}_shouldCapturePageleave(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(n){return this.config.person_profiles==="never"?(Wi.error(n+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(NS,!0),!0)}_sync_opt_out_with_persistence(){var n,i,o,a,s=this.consent.isOptedOut(),r=this.config.opt_out_persistence_by_default,C=this.config.disable_persistence||s&&!!r;((n=this.persistence)===null||n===void 0?void 0:n.disabled)!==C&&((o=this.persistence)===null||o===void 0||o.set_disabled(C)),((i=this.sessionPersistence)===null||i===void 0?void 0:i.disabled)!==C&&((a=this.sessionPersistence)===null||a===void 0||a.set_disabled(C))}opt_in_capturing(n){var i;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),(Mr(n==null?void 0:n.captureEventName)||n!=null&&n.captureEventName)&&this.capture((i=n==null?void 0:n.captureEventName)!==null&&i!==void 0?i:"$opt_in",n==null?void 0:n.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return Bf?BA2(Bf,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Fn&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:Fn.title},{send_instantly:!0}))}debug(n){n===!1?(p4==null||p4.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(p4==null||p4.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_runBeforeSend(n){if(ll(this.config.before_send))return n;var i=_l(this.config.before_send)?this.config.before_send:[this.config.before_send],o=n;for(var a of i){if(o=a(o),ll(o)){var s="Event '".concat(n.event,"' was rejected in beforeSend function");return P20(n.event)?Wi.warn("".concat(s,". This can cause unexpected behavior.")):Wi.info(s),null}o.properties&&!py(o.properties)||Wi.warn("Event '".concat(n.event,"' has no properties after beforeSend function, this is likely an error."))}return o}getPageViewId(){var n;return(n=this.pageViewManager._currentPageview)===null||n===void 0?void 0:n.pageViewId}captureTraceFeedback(n,i){this.capture("$ai_feedback",{$ai_trace_id:String(n),$ai_feedback_text:i})}captureTraceMetric(n,i,o){this.capture("$ai_metric",{$ai_trace_id:String(n),$ai_metric_name:i,$ai_metric_value:String(o)})}}(function(t,n){for(var i=0;i<n.length;i++)t.prototype[n[i]]=F20(t.prototype[n[i]])})(iV,["identify"]);var MA2,F10=(MA2=$M[xy]=new iV,function(){function t(){t.done||(t.done=!0,LA2=!1,cl($M,function(n){n._dom_loaded()}))}Fn!=null&&Fn.addEventListener?Fn.readyState==="complete"?t():su(Fn,"DOMContentLoaded",t,{capture:!1}):p4&&Wi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),MA2);const U10=new y20({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),TA2=({children:t,theme:n})=>{P0.useEffect(()=>{!n||!Object.keys(n).length||Ly2(n)},[n]);const i=(o,a)=>{F10.capture("sth_went_wrong",{message:o.message,stack:o.stack,componentStack:a.componentStack})};return h.jsx(o20,{FallbackComponent:PB2,onError:i,children:h.jsx(x20,{client:U10,children:t})})},Ry={metric:"_metric_d9kl6_1",loader:"_loader_d9kl6_7","alt-container":"_alt-container_d9kl6_13","MetricList-wrapper":"_MetricList-wrapper_d9kl6_21",flexDisplay:"_flexDisplay_d9kl6_45",mergedCard:"_mergedCard_d9kl6_53"},xA2=P0.createContext({isLoading:void 0,data:void 0,token:void 0,refetch:void 0}),eT=()=>P0.useContext(xA2),oV="https://api.usedatabrain.com",Ju="/api/v2/dashboard",Hy="/api/v2/metric",ih="/api/v3/metric",j10="dashboardData",z10=`${Ju}/embeddedMetric`,G10="embeddedMetric",Y10=`${Hy}/layout`,RA2="dashboardLayout",W10=`${Ju}/scheduledReportV2`,_10="dashboardScheduledReportV2",X10=`${Hy}/saveLayout`,K10="saveLayout",J10=`${Ju}/saveScheduleReport`,q10="saveScheduleReport",$10=`${Ju}/deleteScheduleReport`,e30="deleteScheduleReport",t30=`${Ju}/createMetric`,r30="createMetric",n30=`${Ju}/updateMetric`,i30="updateMetric",o30=`${Ju}/updateAdminMetric`,a30="updateAdminMetric",s30=`${Ju}/generateMetric`,C30="generateMetric",l30=`${Ju}/datasetMetricCreation`,u30="datasetMetricCreation",A30=`${Ju}/previewTable`,c30="previewTable",f30=`${Ju}/generatetMetricData`,d30="/generatetMetricData",g30=`${Ju}/getOpenaiChatResponse`,h30="getOpenaiChatResponse",E30=`${Ju}/getDashboardScreenshot`,p30=`${Ju}/createDashboardFilterView`,v30="createDashboardFilterView",I30=`${Ju}/getDashboardFilterView`,m30="getDashboardFilterView",b30=`${Ju}/getTheme`,B30="getTheme",y30=`${ih}/query`,L30="query",w30=`${ih}/datasetMetricCreation`,Q30="newDatasetMetricCreation",M30=`${ih}/generateDataReport`,T30="generateDataReport",x30=`${ih}/chatQuery`,R30="chatQuery",H30=`${Hy}/rawDownloadSettings`,D30="rawDownloadSettings",N30=`${Hy}/column`,S30="column",V30=`${Hy}/underlyingData`,k30="underlyingData",O30=`${Hy}/invokeShareCsv`,P30="invokeShareCsv",Z30=`${ih}/markArchived`,F30="markArchived",U30=`${ih}/publishMetrics`,j30="publishMetrics",z30=`${ih}/download-csv`,G30=`${ih}/downloadDashboardMetrics`,Y30="IS_LOADING",W30="DATA_LOADED",_30=`${ih}/summarizeMetric`,X30="summarizeMetric",K30=`${ih}/createGuestTokenUsageLog`,J30="createGuestTokenUsageLog",HA2="ENTER_FULL_SCREEN_MODE",DA2="EXIT_FULL_SCREEN_MODE",q30="ENTER_SCHEDULED_REPORT_MODE",$30="SAVE_SCHEDULED_REPORT",NA2="EXIT_SCHEDULED_REPORT_MODE",e70="ENTER_CUSTOMIZE_LAYOUT_MODE",SA2="EXIT_CUSTOMIZE_LAYOUT_MODE",VA2="SAVE_LAYOUT",t70="ENTER_MANAGE_METRICS_MODE",kA2="EXIT_MANAGE_METRICS_MODE",r70="SAVE_MANAGE_METRICS",n70="ARCHIVE_METRIC",OA2="DOWNLOAD_METRIC",PA2="DOWNLOAD_METRIC_WITHOUT_FILTERS",i70="SAVE_METRIC_PNG",o70="METRIC_FILTER_APPLIED",a70="DASHBOARD_FILTER_APPLIED",s70="CREATE_METRIC",ZA2="UPDATE_METRIC",dX=()=>localStorage.getItem(mB2),aV=()=>{var o,a,s;const t=((o=window==null?void 0:window.dbn)==null?void 0:o.proxyAuthUrl)||"",n=((a=window==null?void 0:window.dbn)==null?void 0:a.proxyAuthKey)||"";return((s=window==null?void 0:window.dbn)==null?void 0:s.isEnableProxyAuth)||!1?{"X-Proxy-Auth-key":n,"X-Proxy-Auth-Url":t,"X-Authorization":n}:null},zC=async(t,n={method:"GET"})=>{var r,C,l,e,u,A,f;const i=((r=window==null?void 0:window.dbn)==null?void 0:r.isEnableProxyAuth)||!1,o={method:n.method,headers:{"Content-Type":"application/json",...i?{}:{"X-Plugin-Token":n.token||""},"X-Plugin-Origin":window.location.host,...n.isFrontend?{"X-Dbn-Secret":n.clientId}:{},...n.isFrontend?{"X-Dbn-token":dX()||""}:{},...aV()||{}}};n.data&&(o.body=JSON.stringify(n.data));const s=await(await fetch(`${((C=window.dbn)==null?void 0:C.proxyAuthUrl)||((l=window.dbn)==null?void 0:l.baseUrl)||oV}${t}`,o)).json();if(s.error){const{message:d}=s.error;throw new Error(d)}if(["E1005","E1007"].includes(((u=(e=s==null?void 0:s.data)==null?void 0:e.error)==null?void 0:u.code)||""))throw new Error(((f=(A=s==null?void 0:s.data)==null?void 0:A.error)==null?void 0:f.message)||"An error occurred");return s.data},C70=()=>Wl(K10,t=>zC(X10,{method:"POST",data:t})),l70=()=>Wl(q10,t=>zC(J10,{method:"POST",data:t.data,token:t.token})),FA2=()=>Wl(e30,t=>zC($10,{method:"POST",data:t,token:t.token})),u70=()=>Wl(r30,({data:t,token:n})=>zC(t30,{method:"POST",data:t,token:n})),A70=()=>Wl(i30,({data:t,token:n})=>zC(n30,{method:"POST",data:t,token:n})),c70=()=>Wl(a30,({data:t,token:n})=>zC(o30,{method:"POST",data:t,token:n})),f70=()=>Wl(C30,({data:t,token:n})=>zC(s30,{method:"POST",data:t,token:n})),UA2=()=>Wl(u30,({data:t,token:n})=>zC(l30,{method:"POST",data:t,token:n})),d70=()=>Wl(c30,({data:t,token:n})=>zC(A30,{method:"POST",data:t,token:n})),g70=()=>Wl(d30,({data:t,token:n})=>zC(f30,{method:"POST",data:t,token:n})),h70=()=>Wl(h30,({data:t,token:n})=>zC(g30,{method:"POST",data:t,token:n})),E70=()=>Wl(v30,({data:t,token:n})=>zC(p30,{method:"POST",data:t,token:n})),gX=()=>Wl(S30,t=>zC(N30,{method:"POST",data:t})),p70=()=>Wl(k30,t=>zC(V30,{method:"POST",data:t})),v70=()=>Wl(P30,t=>zC(O30,{method:"POST",data:t})),I70=()=>Wl(F30,({data:t,token:n})=>zC(Z30,{method:"POST",data:t,token:n})),m70=()=>Wl(j30,({data:t,token:n})=>zC(U30,{method:"POST",data:t,token:n})),b70=()=>Wl(Q30,({data:t,token:n,clientId:i,isFrontendApp:o})=>zC(w30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),jA2=()=>Wl(T30,({data:t,token:n,clientId:i,isFrontendApp:o})=>zC(M30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),B70=()=>Wl(R30,({data:t,token:n,clientId:i,isFrontendApp:o})=>zC(x30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),y70=()=>Wl(X30,({data:t,isFrontendApp:n,clientId:i,token:o})=>zC(_30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),L70=()=>Wl(J30,({data:t,isFrontendApp:n,clientId:i,token:o})=>zC(K30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),hX=()=>{const{mutateAsync:t}=L70();return{saveLogsAsync:async i=>{t(i)}}},tT=({onSuccess:t,companyIntegrationId:n,selectedColumns:i,query:o,metricQuery:a,integrationName:s,outputColumns:r,chartSettings:C,clientId:l,companyId:e,isLiveMode:u,timeGrain:A,dashboardIds:f,isEnableGroupBy:d,groupBy:g,selectedGroupBy:E,metric:y,datasetMetricSettings:Q,drillDownSettings:R,onServerEvent:D,limit:O})=>{var X2,L3,O1;const{token:k,data:J}=eT(),[e2,p2]=P0.useState(""),{mutate:D2,isLoading:Q2}=u70(),{mutate:i2}=d70(),{saveLogsAsync:N2}=hX(),{register:R2,setValue:M2,watch:Z2,handleSubmit:Y2,control:f0,reset:E0}=Vb(),M0=C3=>{p2(""),C==null||C.chartType,m0.singleValue,D2({data:{companyId:e,companyIntegrationId:n,description:C3.description,inputFields:i,metricId:C3.metricId,name:C3.name,query:o,metricQuery:a,integrationName:s,outputColumns:r,createdBy:l||"external user",isLive:u||!1,chartOptions:C,datasetMetricSettings:Q,clientId:l||null,isCreatedByClient:!!l,timeGrain:A||null,externalDashboardIds:f==null?void 0:f.map(W3=>({externalDashboardId:W3})),isEnableGroupBy:d,groupBy:g??{},selectedGroupBy:E,drillDownSettings:R,limit:O},token:k},{onSuccess:async W3=>{var d7,y7,Y7;(d7=W3==null?void 0:W3.insert_externalMetrics_one)!=null&&d7.id?(await N2({clientId:l,data:{companyId:e,feature:"CREATE_METRIC",metricId:(y7=W3==null?void 0:W3.insert_externalMetrics_one)==null?void 0:y7.metricId},isFrontendApp:!1,token:k}),await(t==null?void 0:t((Y7=W3==null?void 0:W3.insert_externalMetrics_one)==null?void 0:Y7.id)),D==null||D(s70)):p2("Metric Id already exists")},onError:()=>{p2&&p2("Metric Id already exists")}})},{mutateAsync:x0,isLoading:z2}=c70(),{mutateAsync:t1,isLoading:p0}=A70(),U0=P0.useCallback((C3,W3)=>{var y7,Y7,I6;p2("");let d7={};if(W3&&(d7={isDisableCardAppearance:C3.isDisableCardAppearance,titleAlignment:C3.titleAlignment,descAlignment:C3.descAlignment,...C3.text?{textBox:{text:C3.text,fontWeight:C3.fontWeight||"400",fontColor:C3.fontColor||"",fontSize:C3.fontSize||"14px",alignment:C3.textAlignment||"left",link:C3.textLink,isOpenInNewTab:C3.isOpenInNewTab,targetWord:C3.targetWord}}:null}),!(y!=null&&y.isCreatedByClient))x0({data:{externalMetricId:y==null?void 0:y.id,clientId:l,object:{clientId:l,companyId:e,companyIntegrationId:n||(y==null?void 0:y.companyIntegrationId),description:C3.description,inputFields:i,metricId:C3.metricId===(y==null?void 0:y.metricId)?`update_${C3.metricId}_by_${l}_${Date.now()}`:C3.metricId,name:W3?(y7=C3==null?void 0:C3.elementTitle)==null?void 0:y7.trim():(Y7=C3==null?void 0:C3.name)==null?void 0:Y7.trim(),query:o,metricQuery:a,datasetMetricSettings:Q,integrationName:s,outputColumns:r,createdBy:l||"external user",isCreatedByClient:!!l,isLive:u||C3.isLive,chartOptions:C,limit:O,drillDownSettings:R,elementSettings:d7,isMetric:!W3,...W3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}},externalDashboardMetrics:{data:f==null?void 0:f.map(z7=>({externalDashboardId:z7}))}}},token:k},{onSuccess:async z7=>{var X6;!(z7!=null&&z7.insert_clientDeletedMetrics_one)||!(z7!=null&&z7.insert_externalMetrics_one)||(p2(""),await N2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(X6=z7==null?void 0:z7.insert_externalMetrics_one)==null?void 0:X6.metricId},isFrontendApp:!1,token:k}),await(t==null?void 0:t()),D==null||D(ZA2))},onError:()=>{p2("Something went wrong! Please try again later.")}});else{const z7={chartOptions:C,datasetMetricSettings:Q,limit:O,description:C3.description,query:o,metricQuery:a,drillDownSettings:R,elementSettings:d7,isMetric:!W3,...W3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}}};C3.description&&(z7.description=C3.description),C3.metricId&&(z7.metricId=C3.metricId),C3.name&&!W3&&(z7.name=C3.name),C3.elementTitle&&W3&&(z7.name=C3==null?void 0:C3.elementTitle),(I6=Object.keys(d7))!=null&&I6.length&&(z7.elementSettings=d7),t1({data:{externalMetricId:y==null?void 0:y.id,set:z7},token:k},{onSuccess:async X6=>{var k6,z3;(k6=X6==null?void 0:X6.update_externalMetrics_by_pk)!=null&&k6.id&&(p2(""),await N2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(z3=X6==null?void 0:X6.update_externalMetrics_by_pk)==null?void 0:z3.metricId},isFrontendApp:!1,token:k}),await(t==null?void 0:t()),D==null||D(ZA2))},onError:()=>{p2("Something went wrong! Please try again later.")}})}},[C,y,t1,x0,l,e,n,s,u,f,o,i,r,a,Q,O]),G0=P0.useCallback(C3=>{p2("");const W3={isPublished:!(C3!=null&&C3.isPublished)};t1({data:{externalMetricId:C3==null?void 0:C3.id,set:W3},token:k},{onSuccess:async d7=>{var y7,Y7;(y7=d7==null?void 0:d7.update_externalMetrics_by_pk)!=null&&y7.id&&(p2(""),await N2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(Y7=d7==null?void 0:d7.update_externalMetrics_by_pk)==null?void 0:Y7.metricId},isFrontendApp:!1,token:k}),t==null||t())},onError:()=>{p2("Something went wrong! Please try again later.")}})},[y]);return{createExternalMetric:M0,updateExternalMetric:U0,error:e2,isLoading:Q2||z2||p0,clientSubsetData:J==null?void 0:J.clientSubsetData,previewTable:i2,token:k,workspaceId:(X2=J==null?void 0:J.workspace)==null?void 0:X2.id,dashboardOptions:[{value:(L3=J==null?void 0:J.externalDashboard)==null?void 0:L3.id,label:((O1=J==null?void 0:J.externalDashboard)==null?void 0:O1.name)||"Dashboard"}],isDatabaseTenancy:(J==null?void 0:J.companyTenancyType)===YL,register:R2,setValue:M2,watch:Z2,handleSubmit:Y2,control:f0,reset:E0,onPublishMetric:G0}},zA2=()=>{const{mutate:t,isLoading:n,error:i}=f70(),{mutate:o,mutateAsync:a}=gX();return{generateDatasetMetric:t,isGeneratingDataset:n,generateError:i,fetchColumnValues:o,fetchColumnValuesAsync:a}};let w70=0;function Q70(t,n){const i=`atom${++w70}`,o={toString:()=>i};return typeof t=="function"?o.read=t:(o.init=t,o.read=a=>a(o),o.write=(a,s,r)=>s(o,typeof r=="function"?r(a(o)):r)),o}const hd={},nv=Symbol(),EX=t=>!!t[nv],sV=t=>!t[nv].c,rT=t=>{var n;const{b:i,c:o}=t[nv];o&&(o(),(n=T70.get(i))==null||n())},CV=(t,n)=>{const i=t[nv].o,o=n[nv].o;return i===o||t===o||EX(i)&&CV(i,n)},pX=(t,n)=>{const i={b:t,o:n,c:null},o=new Promise(a=>{i.c=()=>{i.c=null,a()},n.finally(i.c)});return o[nv]=i,o},M70=t=>pX(t[nv].b,t[nv].o),T70=new WeakMap,vX=t=>"init"in t,IX="r",mX="w",lV="c",bX="s",GA2="h",x70="n",R70="l",H70="a",D70="m",N70=t=>{const n=new WeakMap,i=new WeakMap,o=new Map;let a,s;(hd&&"production")!=="production"&&(a=new Set,s=new Set);const r=new WeakMap,C=(x0,z2,t1)=>{let p0=r.get(z2);p0||(p0=new Map,r.set(z2,p0)),t1.then(()=>{p0.get(x0)===t1&&(p0.delete(x0),p0.size||r.delete(z2))}),p0.set(x0,t1)},l=x0=>{const z2=new Set,t1=r.get(x0);return t1&&(r.delete(x0),t1.forEach((p0,U0)=>{rT(p0),z2.add(U0)})),z2},e=new WeakMap,u=x0=>{let z2=e.get(x0);return z2||(z2=new Map,e.set(x0,z2)),z2},A=(x0,z2)=>{if(x0){const t1=u(x0);let p0=t1.get(z2);return p0||(p0=A(x0.p,z2),p0&&"p"in p0&&sV(p0.p)&&(p0=void 0),p0&&t1.set(z2,p0)),p0}return n.get(z2)},f=(x0,z2,t1)=>{if((hd&&"production")!=="production"&&Object.freeze(t1),x0)u(x0).set(z2,t1);else{const p0=n.get(z2);n.set(z2,t1),o.has(z2)||o.set(z2,p0)}},d=(x0,z2=new Map,t1)=>{if(!t1)return z2;const p0=new Map;let U0=!1;return t1.forEach(G0=>{var X2;const L3=((X2=A(x0,G0))==null?void 0:X2.r)||0;p0.set(G0,L3),z2.get(G0)!==L3&&(U0=!0)}),z2.size===p0.size&&!U0?z2:p0},g=(x0,z2,t1,p0,U0)=>{const G0=A(x0,z2);if(G0){if(U0&&(!("p"in G0)||!CV(G0.p,U0)))return G0;"p"in G0&&rT(G0.p)}const X2={v:t1,r:(G0==null?void 0:G0.r)||0,y:!0,d:d(x0,G0==null?void 0:G0.d,p0)};let L3=!(G0!=null&&G0.y);return!G0||!("v"in G0)||!Object.is(G0.v,t1)?(L3=!0,++X2.r,X2.d.has(z2)&&(X2.d=new Map(X2.d).set(z2,X2.r))):X2.d!==G0.d&&(X2.d.size!==G0.d.size||!Array.from(X2.d.keys()).every(O1=>G0.d.has(O1)))&&(L3=!0,Promise.resolve().then(()=>{Z2(x0)})),G0&&!L3?G0:(f(x0,z2,X2),X2)},E=(x0,z2,t1,p0,U0)=>{const G0=A(x0,z2);if(G0){if(U0&&(!("p"in G0)||!CV(G0.p,U0)))return G0;"p"in G0&&rT(G0.p)}const X2={e:t1,r:((G0==null?void 0:G0.r)||0)+1,y:!0,d:d(x0,G0==null?void 0:G0.d,p0)};return f(x0,z2,X2),X2},y=(x0,z2,t1,p0)=>{const U0=A(x0,z2);if(U0&&"p"in U0){if(CV(U0.p,t1)&&!sV(U0.p))return U0.y?U0:{...U0,y:!0};rT(U0.p)}C(x0,z2,t1);const G0={p:t1,r:((U0==null?void 0:U0.r)||0)+1,y:!0,d:d(x0,U0==null?void 0:U0.d,p0)};return f(x0,z2,G0),G0},Q=(x0,z2,t1,p0)=>{if(t1 instanceof Promise){const U0=pX(t1,t1.then(G0=>{g(x0,z2,G0,p0,U0)}).catch(G0=>{if(G0 instanceof Promise)return EX(G0)?G0.then(()=>{D(x0,z2,!0)}):G0;E(x0,z2,G0,p0,U0)}));return y(x0,z2,U0,p0)}return g(x0,z2,t1,p0)},R=(x0,z2)=>{const t1=A(x0,z2);if(t1){const p0={...t1,y:!1};f(x0,z2,p0)}else(hd&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",z2)},D=(x0,z2,t1)=>{if(!t1){const U0=A(x0,z2);if(U0){if(U0.y&&"p"in U0&&!sV(U0.p))return U0;if(U0.d.forEach((G0,X2)=>{if(X2!==z2)if(!i.has(X2))D(x0,X2);else{const L3=A(x0,X2);L3&&!L3.y&&D(x0,X2)}}),Array.from(U0.d).every(([G0,X2])=>{const L3=A(x0,G0);return L3&&!("p"in L3)&&L3.r===X2}))return U0.y?U0:{...U0,y:!0}}}const p0=new Set;try{const U0=z2.read(G0=>{p0.add(G0);const X2=G0===z2?A(x0,G0):D(x0,G0);if(X2){if("e"in X2)throw X2.e;if("p"in X2)throw X2.p;return X2.v}if(vX(G0))return G0.init;throw new Error("no atom init")});return Q(x0,z2,U0,p0)}catch(U0){if(U0 instanceof Promise){const G0=EX(U0)&&sV(U0)?M70(U0):pX(U0,U0);return y(x0,z2,G0,p0)}return E(x0,z2,U0,p0)}},O=(x0,z2)=>D(z2,x0),k=(x0,z2)=>{let t1=i.get(z2);return t1||(t1=N2(x0,z2)),t1},J=(x0,z2)=>!z2.l.size&&(!z2.t.size||z2.t.size===1&&z2.t.has(x0)),e2=(x0,z2)=>{const t1=i.get(z2);t1&&J(z2,t1)&&R2(x0,z2)},p2=(x0,z2)=>{const t1=i.get(z2);t1==null||t1.t.forEach(p0=>{p0!==z2&&(R(x0,p0),p2(x0,p0))})},D2=(x0,z2,t1)=>{let p0=!0;const U0=(L3,O1)=>{const C3=D(x0,L3);if("e"in C3)throw C3.e;if("p"in C3){if(O1!=null&&O1.unstable_promise)return C3.p.then(()=>{const W3=A(x0,L3);return W3&&"p"in W3&&W3.p===C3.p?new Promise(d7=>setTimeout(d7)).then(()=>U0(L3,O1)):U0(L3,O1)});throw(hd&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",L3),C3.p}if("v"in C3)return C3.v;throw(hd&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",L3),new Error("no value found")},G0=(L3,O1)=>{let C3;if(L3===z2){if(!vX(L3))throw new Error("atom not writable");l(L3).forEach(Y7=>{Y7!==x0&&Q(Y7,L3,O1)});const d7=A(x0,L3),y7=Q(x0,L3,O1);d7!==y7&&p2(x0,L3)}else C3=D2(x0,L3,O1);return p0||Z2(x0),C3},X2=z2.write(U0,G0,t1);return p0=!1,X2},Q2=(x0,z2,t1)=>{const p0=D2(t1,x0,z2);return Z2(t1),p0},i2=x0=>!!x0.write,N2=(x0,z2,t1)=>{const p0={t:new Set(t1&&[t1]),l:new Set};if(i.set(z2,p0),(hd&&"production")!=="production"&&s.add(z2),D(void 0,z2).d.forEach((G0,X2)=>{const L3=i.get(X2);L3?L3.t.add(z2):X2!==z2&&N2(x0,X2,z2)}),i2(z2)&&z2.onMount){const G0=L3=>Q2(z2,L3,x0),X2=z2.onMount(G0);x0=void 0,X2&&(p0.u=X2)}return p0},R2=(x0,z2)=>{var t1;const p0=(t1=i.get(z2))==null?void 0:t1.u;p0&&p0(),i.delete(z2),(hd&&"production")!=="production"&&s.delete(z2);const U0=A(x0,z2);U0?("p"in U0&&rT(U0.p),U0.d.forEach((G0,X2)=>{if(X2!==z2){const L3=i.get(X2);L3&&(L3.t.delete(z2),J(X2,L3)&&R2(x0,X2))}})):(hd&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",z2)},M2=(x0,z2,t1,p0)=>{const U0=new Set(t1.d.keys());p0==null||p0.forEach((G0,X2)=>{if(U0.has(X2)){U0.delete(X2);return}const L3=i.get(X2);L3&&(L3.t.delete(z2),J(X2,L3)&&R2(x0,X2))}),U0.forEach(G0=>{const X2=i.get(G0);X2?X2.t.add(z2):i.has(z2)&&N2(x0,G0,z2)})},Z2=x0=>{if(x0){u(x0).forEach((t1,p0)=>{const U0=n.get(p0);if(t1!==U0){const G0=i.get(p0);G0==null||G0.l.forEach(X2=>X2(x0))}});return}for(;o.size;){const z2=Array.from(o);o.clear(),z2.forEach(([t1,p0])=>{const U0=A(void 0,t1);if(U0&&U0.d!==(p0==null?void 0:p0.d)&&M2(void 0,t1,U0,p0==null?void 0:p0.d),p0&&!p0.y&&(U0!=null&&U0.y))return;const G0=i.get(t1);G0==null||G0.l.forEach(X2=>X2())})}(hd&&"production")!=="production"&&a.forEach(z2=>z2())},Y2=x0=>{u(x0).forEach((t1,p0)=>{const U0=n.get(p0);(!U0||t1.r>U0.r||t1.y!==U0.y||t1.r===U0.r&&t1.d!==U0.d)&&(n.set(p0,t1),t1.d!==(U0==null?void 0:U0.d)&&M2(x0,p0,t1,U0==null?void 0:U0.d))})},f0=(x0,z2)=>{z2&&Y2(z2),Z2(void 0)},E0=(x0,z2,t1)=>{const U0=k(t1,x0).l;return U0.add(z2),()=>{U0.delete(z2),e2(t1,x0)}},M0=(x0,z2)=>{for(const[t1,p0]of x0)vX(t1)&&(Q(z2,t1,p0),p2(z2,t1));Z2(z2)};return(hd&&"production")!=="production"?{[IX]:O,[mX]:Q2,[lV]:f0,[bX]:E0,[GA2]:M0,[x70]:x0=>(a.add(x0),()=>{a.delete(x0)}),[R70]:()=>s.values(),[H70]:x0=>n.get(x0),[D70]:x0=>i.get(x0)}:{[IX]:O,[mX]:Q2,[lV]:f0,[bX]:E0,[GA2]:M0}},S70=(t,n)=>({s:n?n(t).SECRET_INTERNAL_store:N70()}),BX=new Map,YA2=t=>(BX.has(t)||BX.set(t,P0.createContext(S70())),BX.get(t));function WA2(t,n){return Q70(t)}function V70(t,n){const i=YA2(n),o=P0.useContext(i),{s:a,v:s}=o,r=f=>{const d=a[IX](t,f);if((hd&&"production")!=="production"&&!d.y)throw new Error("should not be invalidated");if("e"in d)throw d.e;if("p"in d)throw d.p;if("v"in d)return d.v;throw new Error("no atom value")},[[C,l,e],u]=P0.useReducer((f,d)=>{const g=r(d);return Object.is(f[1],g)&&f[2]===t?f:[d,g,t]},s,f=>{const d=r(f);return[f,d,t]});let A=l;return e!==t&&(u(C),A=r(C)),P0.useEffect(()=>{const{v:f}=o;f&&a[lV](t,f);const d=a[bX](t,u,f);return u(f),d},[a,t,o]),P0.useEffect(()=>{a[lV](t,C)}),P0.useDebugValue(A),A}function k70(t,n){const i=YA2(n),{s:o,w:a}=P0.useContext(i);return P0.useCallback(r=>{if((hd&&"production")!=="production"&&!("write"in t))throw new Error("not writable atom");const C=l=>o[mX](t,r,l);return a?a(C):C()},[o,a,t])}function yX(t,n){return"scope"in t&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),n=t.scope),[V70(t,n),k70(t,n)]}const uV=({onOutsideClick:t,wrapRef:n,portalRef:i})=>{P0.useEffect(()=>{const o=a=>{const s=n.current&&!n.current.contains("composedPath"in a?a.composedPath()[0]:a.target),r=i&&!i.contains("composedPath"in a?a.composedPath()[0]:a.target);i?s&&r&&t():s&&t()};return document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}},[n,t,i])},O70=({wrapRef:t,portalRef:n,autoCloseParent:i=!1})=>{const[o]=yX(Gc2);P0.useEffect(()=>{const a=s=>{o==null||o.forEach(r=>{var l,e,u,A,f,d,g,E;const C=((l=r.popperElement)==null?void 0:l.contains("composedPath"in s?s.composedPath()[0]:s.target))||((e=r.referenceElement)==null?void 0:e.contains("composedPath"in s?s.composedPath()[0]:s.target));if(!C){const y=o.find(Q=>{var D,O;const R=((D=r.popperElement)==null?void 0:D.contains(Q.referenceElement))&&(Q.isOpen===!0||Q.isMenuOpen===!0);return i?R&&((O=Q.popperElement)==null?void 0:O.contains("composedPath"in s?s.composedPath()[0]:s.target)):R});y?((u=y==null?void 0:y.setOpen)==null||u.call(y,!0),(A=y==null?void 0:y.setMenuOpen)==null||A.call(y,!0)):((f=r.setOpen)==null||f.call(r,!1),(d=r.setMenuOpen)==null||d.call(r,!1))}!C&&(r!=null&&r.disableCloseOnClickOutside)&&((g=r.setOpen)==null||g.call(r,!0),(E=r.setMenuOpen)==null||E.call(r,!0))})};return document.addEventListener("click",a,!0),()=>{document.removeEventListener("click",a,!0)}},[t,n,o])},P70=({token:t,dashboardId:n,configId:i,isEn:o})=>{var a;return _p([j10,{dashboardId:n,configId:i,token:t,isEn:o}],()=>{const s=n?`${Ju}?dashboardId=${n}${i?`&configId=${i}`:""}${`&isEn=${o}`}`:Ju;return zC(s,{method:"GET",token:t})},{enabled:!!t||!!((a=window==null?void 0:window.dbn)!=null&&a.isEnableProxyAuth)})},Z70=(t,n)=>_p([RA2,{dashboardId:t,clientId:n}],()=>zC(`${Y10}?id=${t}&clientId=${n}`,{method:"GET"}),{enabled:!!t&&!!n}),F70=(t,n,i)=>_p(_10,()=>zC(`${W10}?externalDashboardId=${n}${i?`&embedId=${i}`:""}`,{method:"GET",token:t}),{enabled:!!t&&!!n}),U70=(t,n)=>{var i;return _p([G10,{id:n}],()=>zC(`${z10}?metricId=${n}`,{method:"GET",token:t}),{enabled:!!t||!!((i=window==null?void 0:window.dbn)!=null&&i.isEnableProxyAuth)})},_A2=({token:t,name:n,companyId:i})=>_p([B30,{name:n}],()=>zC(b30,{method:"POST",token:t,data:{name:n,companyId:i}}),{enabled:!!(n&&t&&i)}),j70=({token:t,dashboardId:n})=>_p([m30,{dashboardId:n}],()=>zC(I30,{method:"POST",token:t,data:{dashboardId:n}}),{enabled:!!(t&&n)}),z70=({externalDashboardId:t,clientId:n})=>{const i=i_(),{data:o,isLoading:a}=Z70(t,n),[s,r,C,l]=P0.useMemo(()=>{const f=o;return[(f==null?void 0:f.layout)||[],(f==null?void 0:f.dashboardFiltersLayout)||[],!1,(f==null?void 0:f.gridMargin)||{}]},[o]),{mutateAsync:e,isLoading:u}=C70();return{saveLayout:P0.useCallback(async f=>{await e({clientId:n,externalDashboardId:t,layout:f.newLayout.length?f.newLayout:s,isLocked:!!f.isChangedByClient,dashboardFiltersLayout:f.filtersLayout.length?f.filtersLayout:r,gridMargin:f.gridMargin||null},{onSuccess:d=>{if(!d)return;const g=d;i.setQueryData([RA2,{dashboardId:t,clientId:n}],E=>({...E,...g}))}})},[e,n,t]),layout:s,dashboardFiltersLayout:r,gridMargin:l,isLayoutLocked:C,isLoadingLayout:a||u}},G70=({query:t,limit:n,offset:i,dbName:o})=>{const a=Of===(o==null?void 0:o.toLowerCase()),s=Yu===(o==null?void 0:o.toLowerCase()),r=LA===(o==null?void 0:o.toLowerCase());let C=t.replace(/;(^;]*)$/,"");const e=(C==null?void 0:C.toLowerCase()).includes("order"),u=parseInt(n,10);if(C!=null&&C.toLowerCase().includes("limit")){const A=parseInt(C==null?void 0:C.toLowerCase().split("limit")[1].trim(),10),f=i?n:Math.min(A,u);s||a||r?(C=C.replace(`limit ${A}`,`${e||a||r?"":"order by(select null)"} ${`offset ${i||0} rows`} fetch next ${f} rows only`),C=C.replace(`LIMIT ${A}`,`${e||a||r?"":" ORDER BY(SELECT NULL) "} OFFSET ${i||0} ROWS FETCH NEXT ${f} ROWS ONLY`)):(C=C.replace(`limit ${A}`,`limit ${f} ${i?`OFFSET ${i}`:""}`),C=C.replace(`LIMIT ${A}`,`LIMIT ${f} ${i?`OFFSET ${i}`:""}`))}else C!=null&&C.toLowerCase().includes("fetch")||C!=null&&C.toLowerCase().includes("limit")||((o==null?void 0:o.toLowerCase())==Yu||(o==null?void 0:o.toLowerCase())==Of||r?C+=` ${e||a||r?"":" ORDER BY(SELECT NULL) "} ${`offset ${i||0} rows`} fetch next ${u} rows only`:C+=` limit ${u} ${i?`OFFSET ${i}`:""}`);return C},Y70=({datasourceId:t,clientName:n,dbName:i,tenancyType:o,values:a,query:s,companyId:r,workspaceId:C,metricId:l,globalFilters:e,isAllClient:u,rlsConditions:A,dataMartRelationships:f,customSql:d,isEnableCustomSQL:g})=>{const{mutate:E}=p70();return{getUnderlyingData:({columnName:Q,value:R,setData:D,setLoading:O,isSingleValueChart:k,clientColumnType:J})=>{const e2=o==="MULTI_DATABASE"&&n||"",p2=g&&d?d:G70({query:s,limit:"5000",dbName:i}),D2=Ob({clientColumnType:J,query:p2||"",dbName:i,rlsConditions:A,tenancyLevel:o||"TABLE",clientId:n,globalFilters:e,values:a,isAllClient:u,dataMartRelationships:f});D([]),O(!0),E({columnName:k?void 0:Q,companyId:r,query:bf(D2,r),value:k?void 0:R.toString().replace(/'/g,"''"),workspaceId:C,metricId:l,isCustomSql:g&&!!d,databaseName:e2,datasourceId:t},{onSuccess(Q2){const i2=Q2==null?void 0:Q2.data;i2&&Array.isArray(i2)&&i2.length?(D(i2),O(!1)):(D([]),O(!1))},onError(){D([]),O(!1)}})}}},W70=({clientId:t,data:n,token:i,isFrontendApp:o,isFullScreen:a=""},s)=>_p([L30,n,t,o,i,a],()=>{var r,C,l;return zC(y30,{method:"POST",data:{...n||{},...!o&&i?{...(r=n==null?void 0:n.rlsConditions)!=null&&r.length?{rlsConditions:gy(n==null?void 0:n.rlsConditions,i)}:{},...(l=(C=n==null?void 0:n.globalFilters)==null?void 0:C.filters)!=null&&l.length?{globalFilters:gy(n==null?void 0:n.globalFilters,i)}:{}}:{}},isFrontend:o,clientId:t,token:i})},{enabled:!!n.id,onSuccess:s==null?void 0:s.onSuccess,retry:2}),_70=t=>_p([D30,t],()=>zC(`${H30}?id=${t}`,{method:"GET"}),{enabled:!!t}),AV={timeSeriesSettingsContainer:"_timeSeriesSettingsContainer_icvr7_1",timeSeriesSettingsType:"_timeSeriesSettingsType_icvr7_5",featToggle:"_featToggle_icvr7_9",dynamicFormat:"_dynamicFormat_icvr7_17"},X70=[{value:"line",label:"line"},{value:"bar",label:"bar"},{value:"area",label:"area"},{value:"stack",label:"stack"},{value:"combo",label:"combo"}],vC=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"},{value:"Quarterly",label:"Quarterly"},{value:"Yearly",label:"Yearly"}],K70=({onChange:t,settings:{groupBySettings:n,seriesType:i},yAxisList:o,onChangeTimeseriesFormat:a,globalFilterOptions:s})=>{var C,l,e,u,A,f;const r=(d,g)=>{if(n.options[d].split("____").length){const E=`${n.options[d].split("____")[0]}____${g}`,y=`${n.options[d].split("____")[0]}`;t(Q=>{var R,D,O,k;return{...Q,groupBySettings:{...Q.groupBySettings,options:(R=Q.groupBySettings.options)==null?void 0:R.map((J,e2)=>e2===d?E:J),value:((D=Q.groupBySettings.options)==null?void 0:D.find((J,e2)=>e2===d))===((O=Q==null?void 0:Q.groupBySettings)==null?void 0:O.value)?y:(k=Q==null?void 0:Q.groupBySettings)==null?void 0:k.value}}})}else{const E=`${n.options[d]}____${g}`,y=`${n.options[d]}`;t(Q=>{var R,D,O,k;return{...Q,groupBySettings:{...Q.groupBySettings,options:(R=Q.groupBySettings.options)==null?void 0:R.map((J,e2)=>e2===d?E:J),value:((D=Q.groupBySettings.options)==null?void 0:D.find((J,e2)=>e2===d))===((O=Q==null?void 0:Q.groupBySettings)==null?void 0:O.value)?y:(k=Q==null?void 0:Q.groupBySettings)==null?void 0:k.value}}})}};return h.jsxs("div",{className:AV.timeSeriesSettingsContainer,children:[h.jsx(_7,{variant:"heading-5",children:"Time Series Settings"}),h.jsx(K4,{label:"Series Type",options:X70,selectedOption:{value:((C=i==null?void 0:i[0])==null?void 0:C.type)||"bar",label:((l=i==null?void 0:i[0])==null?void 0:l.type)||"bar"},onChange:d=>{t(g=>({...g,seriesType:o==null?void 0:o.map(E=>({column:E,type:d.value}))}))},menuWidth:"100%",buttonWidth:"100%"}),h.jsx(_7,{variant:"body-text-2",children:"Group format"}),h.jsxs("div",{className:AV.timeSeriesSettingsType,children:[h.jsx(pc,{"data-testid":"group-default",id:"group-default",type:"radio",labelClass:"dbn-text-sm dbn-font-normal",onChange:({target:{checked:d}})=>{d&&(t(g=>({...g,groupBySettings:{...g.groupBySettings,value:"monthly",isDynamic:!1,options:vC==null?void 0:vC.map(E=>E.value),isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(vC==null?void 0:vC[2]))},name:"isDynamic",label:"Default",defaultChecked:!n.isDynamic&&!n.isGlobalFilter,checked:!n.isDynamic&&!n.isGlobalFilter}),h.jsx(pc,{"data-testid":"group-dynamic",id:"group-dynamic",type:"radio",labelClass:"dbn-text-sm dbn-font-normal",name:"isDynamic",label:"Dynamic",checked:n.isDynamic,defaultChecked:n.isDynamic,onChange:({target:{checked:d}})=>{d&&(t(g=>({...g,groupBySettings:{...g.groupBySettings,value:"monthly",isDynamic:!0,options:vC==null?void 0:vC.map(E=>E.value),fillXAxis:!1,isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(vC==null?void 0:vC[2]))}}),h.jsx(pc,{"data-testid":"group-global-filters",id:"group-global-filters",type:"radio",labelClass:"dbn-text-sm dbn-font-normal",name:"isGlobalFilter",label:"Filter",checked:n.isGlobalFilter,defaultChecked:n.isGlobalFilter,onChange:({target:{checked:d}})=>{d&&(t(g=>({...g,groupBySettings:{...g.groupBySettings,value:"daily",isDynamic:!1,options:vC==null?void 0:vC.map(E=>E.value),fillXAxis:!1,isGlobalFilter:!0,globalFilterOption:{label:"",value:""}}})),a==null||a(vC==null?void 0:vC[0]))}})]}),n.isDynamic?h.jsxs("div",{className:AV.dynamicFormat,children:[h.jsx(bs,{buttonWidth:"100%",menuWidth:"100%",options:vC,selectedOption:(A=n.options)==null?void 0:A.map(d=>d.split("____").length?{value:d.split("____")[0],label:d.split("____")[0]}:{value:d,label:d}),label:"Dynamic options",onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:Array.isArray(d)&&d.length?d[0].value:"monthly",options:(d==null?void 0:d.map(E=>E.value))||["monthly"],fillXAxis:[uf.daily,uf.weekly,uf.yearly].includes(Array.isArray(d)&&d.length?d[0].value:"monthly")?!1:g.groupBySettings.fillXAxis}})),a==null||a((d==null?void 0:d[0])||(vC==null?void 0:vC[2]))},isShowSelectedOptions:!0}),(f=n.options)==null?void 0:f.map((d,g)=>h.jsx(K9,{label:d.split("____").length>1?d.split("____")[0]:d,type:"text",value:d.split("____").length>1?d.split("____")[1]:d,placeholder:"Save as",onChange:E=>{r(g,E.target.value)}}))]}):h.jsxs(h.Fragment,{children:[(n==null?void 0:n.isGlobalFilter)&&h.jsxs(h.Fragment,{children:[h.jsx(K4,{label:"Dashboard Filter",menuWidth:"100%",buttonWidth:"100%",options:s,selectedOption:n.globalFilterOption||{value:"",label:""},onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,globalFilterOption:d,formatWithValue:[]}}))}}),!!((u=(e=n==null?void 0:n.globalFilterOption)==null?void 0:e.presetDateOptions)!=null&&u.length)&&h.jsx(os,{direction:"col",className:"dbn-gap-3",children:vC==null?void 0:vC.map(d=>{var g,E,y,Q,R,D,O;return h.jsxs(os,{className:"dbn-w-full dbn-gap-2",alignItems:"center",justify:"between",children:[h.jsx(wf,{checked:!!((g=n==null?void 0:n.formatWithValue)!=null&&g.find(k=>k.format===d.value&&k.isEnable)),onChange:({target:{checked:k}})=>{t(J=>{var e2,p2,D2,Q2,i2;return{...J,groupBySettings:{...J.groupBySettings,formatWithValue:[...((p2=(e2=J==null?void 0:J.groupBySettings)==null?void 0:e2.formatWithValue)==null?void 0:p2.filter(N2=>N2.format!==d.value))||[],{format:d.value,isEnable:k,value:((i2=(Q2=(D2=J==null?void 0:J.groupBySettings)==null?void 0:D2.formatWithValue)==null?void 0:Q2.find(N2=>N2.format===d.value))==null?void 0:i2.value)||""}]}}})},label:d.value}),h.jsx("div",{className:"dbn-w-full",children:h.jsx(K4,{placeholder:"Select a Filter Value",menuWidth:"100%",buttonWidth:"100%",options:((E=n==null?void 0:n.globalFilterOption)==null?void 0:E.presetDateOptions)||[],selectedOption:{value:((Q=(y=n==null?void 0:n.formatWithValue)==null?void 0:y.find(k=>k.format===d.value))==null?void 0:Q.value)||"",label:((D=(R=n==null?void 0:n.formatWithValue)==null?void 0:R.find(k=>k.format===d.value))==null?void 0:D.value)||""},isDisabled:!((O=n==null?void 0:n.formatWithValue)!=null&&O.find(k=>k.format===d.value&&k.isEnable)),onChange:k=>{t(J=>{var e2,p2,D2,Q2,i2;return{...J,groupBySettings:{...J.groupBySettings,formatWithValue:[...((p2=(e2=J==null?void 0:J.groupBySettings)==null?void 0:e2.formatWithValue)==null?void 0:p2.filter(N2=>N2.format!==d.value))||[],{format:d.value,isEnable:!!((i2=(Q2=(D2=J==null?void 0:J.groupBySettings)==null?void 0:D2.formatWithValue)==null?void 0:Q2.find(N2=>N2.format===d.value))!=null&&i2.isEnable),value:(k==null?void 0:k.value)||""}]}}})}})})]})})})]}),h.jsx(K4,{label:"Format Type",menuWidth:"100%",buttonWidth:"100%",options:vC,selectedOption:(vC==null?void 0:vC.find(d=>{var g,E;return((g=d.value)==null?void 0:g.toLowerCase())===((E=n==null?void 0:n.value)==null?void 0:E.toLowerCase())}))||(vC==null?void 0:vC[2]),onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:d.value}})),a==null||a(d)}}),[uf.month,uf.quarter].includes(n.value.toLowerCase())&&h.jsxs("div",{className:AV.featToggle,children:[h.jsx(_5,{name:"fill axis",enabled:n.fillXAxis,onChange:()=>t(d=>({...d,groupBySettings:{...d.groupBySettings,fillXAxis:!d.groupBySettings.fillXAxis}}))}),h.jsxs("span",{className:"dbn-flex dbn-gap-2 dbn-items-center",children:[h.jsx(_7,{variant:"body-text-2",children:"Fill X-axis"}),h.jsx(yf,{position:"top",iconConfig:{size:"xs",color:"primary"},text:"Enable to fill missing months or dates.",tooltipClass:"dbn-w-[300px]"})]})]})]})]})},fc=t=>{const n=new Set;return t.filter(i=>{var a;const o=JSON.stringify((a=i==null?void 0:i.measures)==null?void 0:a.sort());return n.has(o)?!1:(n.add(o),!0)})},Wc=t=>{const n=new Date(t);return n instanceof Date&&!Number.isNaN(n.getTime())?n:null},LX=({metric:t,globalFilters:n={tableName:"",filters:[]},rlsFilters:i,clientId:o,tenancyLevel:a,isInternalApp:s,appFilters:r,setCrossDashboardFilters:C,crossDashboardFilters:l,metricFilterOptions:e,isAllClient:u,isFrontendApp:A,guestToken:f,encryptedClientId:d,workspaceId:g,metricStore:E,setMetricStore:y,onServerEvent:Q,clientColumnType:R,datasourceId:D,appliedCardMetricFilters:O,language:k,translationDictionary:J,calendarType:e2,setLoadedCardMetadata:p2,isFullScreen:D2,setMetricMetadata:Q2,viewMetricData:i2,generatingPdf:N2,dataMartTables:R2})=>{var x5,M5,Y5,r4,n4,y4,m4,ce,N4,je,J4,ne,l1,z1,Z3,H3,X7,i3,Q1,y3,T7,V6,r8,V8,i9,S9,D3,E6,O7,h6,Z6,F8,E8,_8,R9,Z8,r5,t5,c5,s4,q4,ie,Be,fe,it,Bt,jr,Cn,xn,di,ii,oi,Ri,Ni,dn,Xr,gi,_i,ai,hi,si,Sr,en,ur,tn;const[M2,Z2]=P0.useState(!1),[Y2,f0]=P0.useState(!0),E0=y70(),[M0,x0]=P0.useState(""),[z2,t1]=P0.useState(""),[p0,U0]=P0.useState(!1),G0=P0.useRef(null),[X2,L3]=P0.useState({limit:10,offset:0}),[O1,C3]=P0.useState(0),[W3,d7]=P0.useState(0),[y7,Y7]=P0.useState((t==null?void 0:t.rlsConditions)||[]),[I6,z7]=P0.useState([]),[X6,k6]=P0.useState(!1),[z3,t0]=P0.useState(),[j3,K7]=P0.useState([]),[G7,c6]=P0.useState(""),[u6,L6]=P0.useState([]),[v1,A3]=P0.useState({isOpen:!1,report:"",isLoading:!1}),[c7,X3]=P0.useState(!1),[Y3,n7]=P0.useState([]),[V7,P7]=P0.useState([]),[D7,_6]=P0.useState({isEnableGroupBy:!1,isEnableCrossFilter:!1,drillType:""}),[c8,x8]=P0.useState([]),[C8,K8]=P0.useState(!1),[l8,I9]=P0.useState(!1),[M8,d9]=P0.useState([]),[b8,g5]=P0.useState({}),[N5,h5]=P0.useState(!1),[d4,b5]=P0.useState(null),[M1,o9]=P0.useState(t==null?void 0:t.chartOptions),[O9,s5]=P0.useState({data:[],error:"",isLoading:!1,currentValue:""}),u5=P0.useMemo(()=>{var K6,T6;return!!((T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)!=null&&T6.isPythonMode)},[(M5=(x5=t==null?void 0:t.datasetMetricSettings)==null?void 0:x5.newDatasetSettings)==null?void 0:M5.isPythonMode]),B5=P0.useMemo(()=>{var K6,T6,r9,I8,B9;return((B9=(I8=(r9=(T6=(K6=t==null?void 0:t.externalDashboardMetrics)==null?void 0:K6[0])==null?void 0:T6.externalDashboard)==null?void 0:r9.companyWorkspace)==null?void 0:I8.datamart)==null?void 0:B9.datamartRelationships)||[]},[t]),U9=P0.useMemo(()=>{const K6={};if(i!=null&&i.values)for(const T6 in i.values){const r9=`${T6}_variable`;K6[r9]=i.values[T6]}return K6},[i==null?void 0:i.values]),c3=P0.useMemo(()=>{var r9,I8,B9;const K6=(I8=(r9=t==null?void 0:t.datasetMetricSettings)==null?void 0:r9.newDatasetSettings)==null?void 0:I8.selectedMainTable,T6=R2==null?void 0:R2.find(D8=>D8.tableName===(K6==null?void 0:K6.tableName));return((B9=T6==null?void 0:T6.customColumnFields)==null?void 0:B9.map(D8=>{var n5,y5,V5,f4,R5,R6;return{value:D8==null?void 0:D8.columnName,label:D8==null?void 0:D8.columnName,isCustomField:!0,column:{uniqueId:dm(10),alias:D8==null?void 0:D8.columnName,configType:"DIMENSION",datatype:D8==null?void 0:D8.datatype,dropType:"DIMENSION",index:1e3,name:D8==null?void 0:D8.columnName,parentAlias:`${fm(K6==null?void 0:K6.schemaName,((n5=t==null?void 0:t.companyIntegration)==null?void 0:n5.name)||"")}_${(y5=K6==null?void 0:K6.tableName)==null?void 0:y5.replaceAll(" ","_")}`,table:(f4=(V5=t==null?void 0:t.datasetMetricSettings)==null?void 0:V5.newDatasetSettings)==null?void 0:f4.selectedMainTable,type:"DEFAULT",draggableItemData:{column:{name:D8==null?void 0:D8.columnName,dataType:D8==null?void 0:D8.datatype,as:D8==null?void 0:D8.datatype},table:(R6=(R5=t==null?void 0:t.datasetMetricSettings)==null?void 0:R5.newDatasetSettings)==null?void 0:R6.selectedMainTable},label:"",sql:""}}}))||[]},[(r4=(Y5=t==null?void 0:t.datasetMetricSettings)==null?void 0:Y5.newDatasetSettings)==null?void 0:r4.selectedMainTable,(n4=t==null?void 0:t.companyIntegration)==null?void 0:n4.name,R2]),W8=P0.useMemo(()=>{var K6,T6,r9,I8,B9,D8,n5,y5,V5,f4,R5,R6,k8,J9;return{isAllClient:u,id:t==null?void 0:t.id,tenancyLevel:a,rlsConditions:[...M8||[],...(K6=M1==null?void 0:M1.tableSettings)!=null&&K6.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?(T6=I6==null?void 0:I6.map(A5=>A5.condition))==null?void 0:T6.filter(A5=>vR(A5)):[]],globalFilters:u5?void 0:{...n,filters:(r9=n==null?void 0:n.filters)==null?void 0:r9.filter(A5=>{var Qe;return Array.isArray(A5==null?void 0:A5.value)?(Qe=A5==null?void 0:A5.value)==null?void 0:Qe.length:A5})},filterValues:u5?void 0:U9,limit:(I8=M1==null?void 0:M1.tableSettings)!=null&&I8.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?Math.min(X2.limit,1e3):void 0,offset:(B9=M1==null?void 0:M1.tableSettings)!=null&&B9.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?X2.offset:void 0,disableStringify:!0,pivotHeaders:((D8=M1==null?void 0:M1.pivotTableSettings2)==null?void 0:D8.headers)||[],timeseriesSettings:u5?void 0:{format:((V5=(y5=(n5=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:n5.groupBySettings)==null?void 0:y5.value)==null?void 0:V5.toLowerCase())||"monthly",seriesField:(M1==null?void 0:M1.seriesField)||"",isFiscal:e2==="ind"},chartSeriesField:(M1==null?void 0:M1.seriesField)!=="ungrouped"&&(M1!=null&&M1.seriesField)&&(M1!=null&&M1.isDynamicSeries)?M1==null?void 0:M1.seriesField:void 0,comparisonCount:W3,dynamicXAxis:{isEnable:!!((f4=M1==null?void 0:M1.dynamicXAxis)!=null&&f4.isEnabled||(R5=M1==null?void 0:M1.enduserMeasureAndDimensions)!=null&&R5.isEnabled)&&Uh.includes((M1==null?void 0:M1.chartType)||""),xaxis:(M1==null?void 0:M1.xAxis)||"",customField:(k8=(R6=M1==null?void 0:M1.dynamicXAxis)==null?void 0:R6.selectedOption)==null?void 0:k8.column},dbId:D,elementSettings:(J9=t==null?void 0:t.elementSettings)==null?void 0:J9.metricExpression,drillConfig:D7==null?void 0:D7.configV2,isEncrypted:!!(!A&&f)}},[M1,u,t,M8,u5,U9,V7,a,n,X2,W3,Uh,D,e2,D7==null?void 0:D7.configV2,f,A,JSON.stringify(I6)]),{data:e7,isLoading:Q6,error:P6,refetch:f6}=W70({data:W8,clientId:A?d||"":o,token:f,isFrontendApp:A,isFullScreen:D2},{onSuccess:K6=>{var r9;const T6=Iy2(K6);p2&&((r9=T6==null?void 0:T6.error)==null?void 0:r9.code)!=="E1001"&&(p2==null||p2(I8=>{var B9;return[...(I8==null?void 0:I8.filter(D8=>(D8==null?void 0:D8.id)!==(W8==null?void 0:W8.id)))||[],{id:W8==null?void 0:W8.id,isDataFound:!!(T6!=null&&T6.length)&&((M1==null?void 0:M1.chartType)!==m0.singleValue||((B9=T6==null?void 0:T6[0])==null?void 0:B9[(M1==null?void 0:M1.singleValue)||""])!==null)}]}))}}),{mutate:x7}=b70(),{mutateAsync:s7}=jA2();P0.useEffect(()=>{var T6;const K6=((T6=t==null?void 0:t.rlsConditions)==null?void 0:T6.map(r9=>{var V5,f4,R5,R6,k8,J9,A5,Qe,xe,ge,Ct,ye,j4,ze,Qt;let I8=r9;if(e){const re=by2(I8,e);re&&(I8={...I8,filterType:"manual",value:re.value?I8.datatype==="string"&&((V5=I8==null?void 0:I8.filterVariant)==null?void 0:V5.value)===fu?[re.value]:re.value:I8.value,options:I8.datatype==="date"?(f4=re.options)==null?void 0:f4.map(Le=>({...Le,startDate:Wc(Le.fromDate)??Le.startDate,endDate:Wc(Le.toDate)??Le.endDate,minDate:Wc(Le.minDate)??void 0,maxDate:Wc(Le.maxDate)??void 0,fromDate:Wc(Le.fromDate)??void 0,toDate:Wc(Le.toDate)??void 0})):re.options,variableOptions:I8.datatype==="date"?(R5=re.options)==null?void 0:R5.map(Le=>({range:Le.range,startDate:Wc(Le.fromDate)??Le.startDate,endDate:Wc(Le.toDate)??Le.endDate,minDate:Wc(Le.minDate)??void 0,maxDate:Wc(Le.maxDate)??void 0,fromDate:Wc(Le.fromDate)??void 0,toDate:Wc(Le.toDate)??void 0,value:Le.name,label:Le.name})):(R6=re.options)==null?void 0:R6.map(Le=>({value:Le,label:Le})),selectedVariableValue:re.value?I8.datatype==="string"?{value:re.value,label:re.value}:{startDate:Wc((J9=(k8=re.options)==null?void 0:k8.find(Le=>Le.name===re.value))==null?void 0:J9.fromDate),endDate:Wc((Qe=(A5=re.options)==null?void 0:A5.find(Le=>Le.name===re.value))==null?void 0:Qe.toDate),value:re.value,label:re.value}:I8.selectedVariableValue})}const D8=[...((Ct=(ge=(xe=i2==null?void 0:i2.metricViewFilters)==null?void 0:xe.find(re=>re.id===(t==null?void 0:t.id)))==null?void 0:ge.filters)==null?void 0:Ct.filter(re=>!(O!=null&&O.find(Le=>(re==null?void 0:re.name)===(Le==null?void 0:Le.name)))))||[],...O||[]].find(re=>I8.name===re.name);if(D8!=null&&D8.value&&(I8={...I8,...D8!=null&&D8.value?{value:D8==null?void 0:D8.value}:{},...D8!=null&&D8.selectedDropdownValue?{selectedDropdownValue:D8==null?void 0:D8.selectedDropdownValue}:{},...D8!=null&&D8.selectedVariableValue?{selectedVariableValue:D8==null?void 0:D8.selectedVariableValue}:{}}),(I8==null?void 0:I8.datatype)==="date"&&((ye=I8==null?void 0:I8.options)==null?void 0:ye.find(re=>re.range==="Custom Date"))&&(I8==null?void 0:I8.isEnableDynamicDate)&&((j4=I8==null?void 0:I8.dynamicDate)==null?void 0:j4.value)){const re=$s2(((ze=Tb==null?void 0:Tb.find(Kn=>{var le;return Kn.value===((le=I8==null?void 0:I8.dynamicDate)==null?void 0:le.value)}))==null?void 0:ze.count)||0),Le=qc(re),Ci=qc(re);I8={...I8,options:(Qt=I8==null?void 0:I8.options)==null?void 0:Qt.map(Kn=>Kn.range==="Custom Date"?{...Kn,startDate:re,endDate:re,timeGrainValue:`${Le} - ${Ci}`}:Kn)}}return a==="DATABASE"?{...I8,tableName:`${o}.${r9.tableName.split(".").slice(1).join(".")}`}:I8}))||[];Y7(K6||[])},[t==null?void 0:t.rlsConditions,e,a,o,O,i2]),P0.useEffect(()=>{let K6;return Q6?f0(!0):K6=setTimeout(()=>{f0(!1)},300),()=>clearTimeout(K6)},[Q6]),P0.useEffect(()=>{t!=null&&t.id&&Q2&&!u5&&(t!=null&&t.isMetric)&&(Q2==null||Q2(K6=>{var T6,r9,I8,B9,D8,n5,y5,V5,f4,R5,R6;return[...(K6==null?void 0:K6.filter(k8=>k8.id!==(t==null?void 0:t.id)))||[],{filters:[...M8||[],...(T6=M1==null?void 0:M1.tableSettings)!=null&&T6.isServerSidePagination&&(M1==null?void 0:M1.chartType)===m0.table?(r9=I6==null?void 0:I6.map(k8=>k8.condition))==null?void 0:r9.filter(k8=>vR(k8)):[]],xAxisSettings:{isEnable:!!((I8=M1==null?void 0:M1.dynamicXAxis)!=null&&I8.isEnabled||(B9=M1==null?void 0:M1.enduserMeasureAndDimensions)!=null&&B9.isEnabled)&&Uh.includes((M1==null?void 0:M1.chartType)||""),xaxis:(M1==null?void 0:M1.xAxis)||""},yAxisSettings:{isEnable:!!(!((D8=M1==null?void 0:M1.dynamicYAxis)!=null&&D8.isEnabled)||!((n5=M1==null?void 0:M1.dynamicYAxis)!=null&&n5.selectedOption)||Array.isArray((y5=M1==null?void 0:M1.dynamicYAxis)==null?void 0:y5.selectedOption)),yAxis:((V5=M1==null?void 0:M1.dynamicYAxis)==null?void 0:V5.selectedOption)||""},id:t==null?void 0:t.id,metricRequestData:{isAllClient:u,timeseriesSettings:u5?void 0:{format:((R6=(R5=(f4=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:f4.groupBySettings)==null?void 0:R5.value)==null?void 0:R6.toLowerCase())||"monthly",seriesField:(M1==null?void 0:M1.seriesField)||"",isFiscal:e2==="ind"}}}]}))},[t==null?void 0:t.id,t==null?void 0:t.isMetric,M8,M1==null?void 0:M1.timeSeriesSettings,M1==null?void 0:M1.seriesField,u5,e2,u,I6,(y4=M1==null?void 0:M1.tableSettings)==null?void 0:y4.isServerSidePagination,M1==null?void 0:M1.chartType,M1==null?void 0:M1.dynamicYAxis,M1==null?void 0:M1.dynamicXAxis]),P0.useEffect(()=>{var K6,T6,r9,I8,B9,D8;if((K6=t==null?void 0:t.drillDownSettings)!=null&&K6.isEnableGroupBy){const n5=t==null?void 0:t.datasetMetricSettings;!((T6=t==null?void 0:t.drillDownSettings)!=null&&T6.configV2)&&!(D7!=null&&D7.configV2)&&((I8=(r9=n5==null?void 0:n5.newDatasetSettings)==null?void 0:r9.selectedMetrics)!=null&&I8.length)&&((D8=(B9=n5==null?void 0:n5.newDatasetSettings)==null?void 0:B9.selectedDims)!=null&&D8.length)?_6(y5=>{var V5,f4,R5;return{...(t==null?void 0:t.drillDownSettings)||{},configV2:{isEnable:!!((V5=t==null?void 0:t.drillDownSettings)!=null&&V5.isEnableGroupBy),levels:(R5=(f4=n5==null?void 0:n5.newDatasetSettings)==null?void 0:f4.selectedDims)==null?void 0:R5.map((R6,k8)=>{var A5,Qe,xe,ge;const J9=(xe=(Qe=(A5=t==null?void 0:t.drillDownSettings)==null?void 0:A5.drilldownChartSettings)==null?void 0:Qe.find(Ct=>(Ct==null?void 0:Ct.name)===(R6==null?void 0:R6.alias)))==null?void 0:xe.chartSettings;return{name:`Drill Level ${k8+1}`,chartSettings:J9||M1,index:dm(4),isEnable:k8===0,dimensions:[R6],measures:((ge=n5==null?void 0:n5.newDatasetSettings)==null?void 0:ge.selectedMetrics)||[]}})}}}):D7!=null&&D7.isEnableGroupBy||_6(t==null?void 0:t.drillDownSettings)}},[(m4=t==null?void 0:t.drillDownSettings)==null?void 0:m4.isEnableGroupBy,(ce=t==null?void 0:t.drillDownSettings)==null?void 0:ce.configV2,t==null?void 0:t.datasetMetricSettings,M1]);const{mutateAsync:k3}=gX(),E3=P0.useMemo(()=>{var r9,I8,B9,D8,n5,y5,V5,f4,R5,R6,k8,J9,A5,Qe,xe,ge;const K6=((r9=t==null?void 0:t.datasetMetricSettings)==null?void 0:r9.metricVariables)||[];if(!K6||!Array.isArray(K6)||!(K6!=null&&K6.length))return[];const T6=[];for(let Ct=0;Ct<(K6==null?void 0:K6.length);Ct++){const ye=K6[Ct],j4=ye.type.value==="custom"&&ye.customQuery&&ye.customColumnName,ze=j4?{query:Ob({query:(ye==null?void 0:ye.customQuery)||"",tenancyLevel:a,clientId:o,isAllClient:u,clientColumnType:R||"STRING",dbName:(I8=t==null?void 0:t.companyIntegration)==null?void 0:I8.name,rlsConditions:M8==null?void 0:M8.filter(le=>le.isVariableFilter),globalFilters:{...n,filters:(B9=n==null?void 0:n.filters)==null?void 0:B9.filter(le=>{var qt;return(le==null?void 0:le.isVariableFilter)&&!!(Array.isArray(le==null?void 0:le.value)?(qt=le==null?void 0:le.value)!=null&&qt.length:le)})}}),alias:DP}:void 0,Qt=(D8=ye.dependOnOptions)!=null&&D8.length?M8==null?void 0:M8.filter(le=>ye.dependOnOptions.some(qt=>{var br;return qt.type==="metric"&&((br=qt.filter)==null?void 0:br.value)===le.name&&qt.column})):[],re=(n5=ye.dependOnOptions)!=null&&n5.length?(y5=n==null?void 0:n.filters)==null?void 0:y5.filter(le=>{var qt;return Array.isArray(le==null?void 0:le.value)?(qt=le==null?void 0:le.value)==null?void 0:qt.length:le&&ye.dependOnOptions.some(br=>{var Ar;return br.type==="dashboard"&&((Ar=br.filter)==null?void 0:Ar.value)===le.label&&br.column})}):[],Le=Qt==null?void 0:Qt.map(le=>{var qt;return{columnName:((qt=ye.dependOnOptions.find(br=>{var Ar;return le.name===((Ar=br.filter)==null?void 0:Ar.value)}))==null?void 0:qt.column)||"",value:le.value,as:"string"}}),Ci=re==null?void 0:re.map(le=>{var qt;return{columnName:((qt=ye.dependOnOptions.find(br=>{var Ar;return le.label===((Ar=br.filter)==null?void 0:Ar.value)}))==null?void 0:qt.column)||"",value:kb(le==null?void 0:le.value),as:"string"}});ye.isClientScoped&&o&&R&&!u&&a==="TABLE"&&((f4=(V5=ye.clientColumn)==null?void 0:V5.name)!=null&&f4.value)&&((R6=(R5=ye.clientColumn)==null?void 0:R5.datatype)!=null&&R6.value)&&Le.push({columnName:(J9=(k8=ye.clientColumn)==null?void 0:k8.name)==null?void 0:J9.value,value:o,as:(Qe=(A5=ye.clientColumn)==null?void 0:A5.datatype)==null?void 0:Qe.value});const Kn=[...Le,...Ci];T6.push({object:{wId:g,tableName:j4?"":(xe=ye==null?void 0:ye.table)==null?void 0:xe.value,columnName:j4?(ye==null?void 0:ye.customColumnName)||"":((ge=ye==null?void 0:ye.column)==null?void 0:ge.value)||"",filter:Kn,customTable:ze,limit:"1",datasourceId:D,databaseName:a==="MULTI_DATABASE"&&o||""},element:ye})}return T6},[(N4=t==null?void 0:t.datasetMetricSettings)==null?void 0:N4.metricVariables,JSON.stringify(n==null?void 0:n.filters),M8,R,g,a,o,u,D]),Q7=async K6=>{var r9,I8,B9,D8,n5;Z2(!0);const T6={};K6==null||K6.forEach(y5=>{var V5,f4;T6[(V5=y5==null?void 0:y5.element)==null?void 0:V5.name]=((f4=y5==null?void 0:y5.element)==null?void 0:f4.defaultValue)||""}),g5(T6);for(let y5=0;y5<(K6==null?void 0:K6.length);y5++){const V5=K6[y5];if(T6[V5.element.name]=V5.element.defaultValue||"",Z2(!0),V5.object.wId&&(!((I8=(r9=V5==null?void 0:V5.object)==null?void 0:r9.customTable)!=null&&I8.query)||!((n5=(D8=(B9=V5==null?void 0:V5.object)==null?void 0:B9.customTable)==null?void 0:D8.query)!=null&&n5.includes("{{")))){const f4=await k3(V5.object);f4!=null&&f4.data&&Array.isArray(f4.data)&&g5(R5=>{var R6,k8;return{...R5,[V5.element.name]:((k8=(R6=f4==null?void 0:f4.data)==null?void 0:R6[0])==null?void 0:k8.value)||V5.element.defaultValue||""}})}}setTimeout(()=>{Z2(!1)},200)};P0.useEffect(()=>{E3!=null&&E3.length&&Q7(E3)},[JSON.stringify(E3)]);const E7=P0.useMemo(()=>{var K6,T6,r9,I8;return(I8=(r9=(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)==null?void 0:T6.selectedDims)==null?void 0:r9[0])==null?void 0:I8.name},[t]);P0.useMemo(()=>{var K6,T6,r9,I8;return Gs2(((I8=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.selectedDimensions)==null?void 0:I8[V7.length<((r9=(T6=t==null?void 0:t.datasetMetricSettings)==null?void 0:T6.selectedDimensions)==null?void 0:r9.length)?V7.length:0])||"")},[t==null?void 0:t.datasetMetricSettings,V7]),P0.useEffect(()=>{var r9,I8,B9;const T6=((r9=t==null?void 0:t.drillDownSettings)==null?void 0:r9.isEnableGroupBy)?y7||[]:[...y7!=null&&y7.length?y7:[],...l||[]];(I8=T6==null?void 0:T6.filter(D8=>D8.isAddOnMetrics))!=null&&I8.length?d9((B9=T6.filter(D8=>D8.isAddOnMetrics))==null?void 0:B9.map(D8=>{var n5,y5,V5,f4,R5;return s?{...D8,dimensionColumn:(M1==null?void 0:M1.xAxis)||"",measureColumn:((n5=M1==null?void 0:M1.yAxisList)==null?void 0:n5[0])||"",options:D8.datatype!==nA?[]:D8.options,variableOptions:D8.datatype!==nA?[]:D8.variableOptions}:{...D8,dimensionColumn:(M1==null?void 0:M1.xAxis)||"",measureColumn:((y5=M1==null?void 0:M1.yAxisList)==null?void 0:y5[0])||"",value:D8.isAppFilter?D8.datatype==="date"?(V5=D8==null?void 0:D8.options)==null?void 0:V5.find(R6=>{var k8;return R6.name===((k8=r==null?void 0:r.values)==null?void 0:k8[D8.name])||D8.value}):((f4=r==null?void 0:r.values)==null?void 0:f4[D8.name])||D8.value:D8.value,options:D8.datatype!==nA?[]:(R5=D8==null?void 0:D8.options)==null?void 0:R5.map(R6=>e2==="ind"&&D8.datatype===nA?{...R6,isFiscal:!0}:R6),variableOptions:D8.datatype!==nA?[]:D8.variableOptions}}).filter(D8=>vR(D8))):d9([])},[y7,r,l,(je=t==null?void 0:t.drillDownSettings)==null?void 0:je.isEnableGroupBy,a,s,o,e2]);const w6=P0.useMemo(()=>{var K6,T6,r9;return(M1==null?void 0:M1.chartType)===m0.singleValue&&!!((K6=M1==null?void 0:M1.customSettings)!=null&&K6.comparisonValueShow)&&!!((T6=M1==null?void 0:M1.customSettings)!=null&&T6.comparisonTimeGrain)&&!!((r9=M1==null?void 0:M1.customSettings)!=null&&r9.comparisonTimePeriod)&&!!(M1!=null&&M1.singleValue)},[M1]);P0.useEffect(()=>{var B9,D8,n5,y5,V5;const K6=e7;let T6=K6!=null&&K6.data&&typeof K6.data=="string"?JSON.parse(K6.data):K6!=null&&K6.data&&Array.isArray(K6==null?void 0:K6.data)?K6==null?void 0:K6.data:[];s5({data:[],error:"",isLoading:!1,currentValue:""}),(M1==null?void 0:M1.chartType)===m0.table&&C3((K6==null?void 0:K6.totalRecords)||0),T6=Js2(T6||[],((D8=(B9=t==null?void 0:t.datasetMetricSettings)==null?void 0:B9.newDatasetSettings)==null?void 0:D8.selectedDims)||[],((y5=(n5=t==null?void 0:t.datasetMetricSettings)==null?void 0:n5.newDatasetSettings)==null?void 0:y5.selectedMetrics)||[]);const r9=(()=>{var f4,R5,R6,k8;if(!Array.isArray(T6))return[];if(((R5=(f4=t==null?void 0:t.companyIntegration)==null?void 0:f4.name)==null?void 0:R5.toLowerCase())===Lg&&!u5){const J9=(R6=t==null?void 0:t.datasetMetricSettings)==null?void 0:R6.newDatasetSettings,A5=(J9==null?void 0:J9.selectedMetrics)||[],Qe=((k8=J9==null?void 0:J9.selectedDims)==null?void 0:k8.filter(ge=>{var Ct,ye;return!((ye=(Ct=ge==null?void 0:ge.alias)==null?void 0:Ct.toLowerCase())!=null&&ye.match(/monthly|quarterly|weekly|yearly|daily/))}))||[],xe=[...Qe==null?void 0:Qe.map(ge=>ge.alias),...A5==null?void 0:A5.map(ge=>ge.alias)];return Ks2(xe,T6)}return T6})();if(K7(r9),(V5=t==null?void 0:t.datasetMetricSettings)!=null&&V5.isUseRawSQL){const f4=Object.keys((r9==null?void 0:r9[0])||{})||[];o9(R5=>({...R5,yAxisList:f4||(R5==null?void 0:R5.yAxisList)||[]}))}const I8=K6==null?void 0:K6.metaData;x8(CW(I8==null?void 0:I8.groupbyColumnList)),A3(f4=>({...f4,report:"",isLoading:f4==null?void 0:f4.isLoading,isOpen:f4==null?void 0:f4.isOpen}))},[e7,t==null?void 0:t.datasetMetricSettings,u5]),P0.useEffect(()=>{var K6,T6;(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.createdSorts)!=null&&T6.length?h5(!0):h5(!1)},[(ne=(J4=t==null?void 0:t.datasetMetricSettings)==null?void 0:J4.createdSorts)==null?void 0:ne.length]),P0.useEffect(()=>{var K6,T6;(M1==null?void 0:M1.chartType)===m0.timeSeries&&((T6=(K6=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:K6.groupBySettings)!=null&&T6.value)&&!u5&&o9(r9=>{var I8,B9,D8;return{...r9,xAxis:`${(D8=(B9=(I8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:I8.groupBySettings)==null?void 0:B9.value)==null?void 0:D8.toLowerCase()} of ${E7}`}})},[j3,M1==null?void 0:M1.chartType,M1==null?void 0:M1.timeSeriesSettings,u5]),P0.useEffect(()=>{var K6;if(M1!=null&&M1.isEnableComparisonFilter&&[m0.line].includes(M1==null?void 0:M1.chartType)){const T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings,r9=(T6==null?void 0:T6.selectedMetrics)||[],I8=Object==null?void 0:Object.keys((j3==null?void 0:j3[0])||{});o9(B9=>({...B9,yAxisList:[...I8.filter(D8=>r9==null?void 0:r9.some(n5=>D8.startsWith(n5.alias)))]}))}},[j3,M1==null?void 0:M1.isEnableComparisonFilter,W3,M1==null?void 0:M1.chartType]);const n6=P0.useCallback((K6,T6,r9,I8,B9,D8)=>{Q==null||Q(o70,t==null?void 0:t.id),Y7(I8?n5=>n5==null?void 0:n5.map(y5=>{var V5,f4;return y5.name===K6?{...y5,value:T6,options:(V5=y5.options)==null?void 0:V5.map(R5=>T6===R5.name?{...R5,...I8,timeGrainValue:D8}:R5),variableOptions:(f4=y5.variableOptions)==null?void 0:f4.map(R5=>R5.value===T6?{...R5,...I8,timeGrainValue:D8}:R5),selectedVariableValue:{value:T6,label:T6,endDate:I8.endDate,startDate:I8.startDate,timeGrainValue:D8}}:y5}):B9?n5=>n5==null?void 0:n5.map(y5=>y5.name===K6?{...y5,value:B9!=null&&B9.length?B9==null?void 0:B9.map(V5=>V5.value):void 0,selectedDropdownValue:B9!=null&&B9.length?B9:void 0}:y5):n5=>n5==null?void 0:n5.map(y5=>y5.name===K6?{...y5,value:T6,selectedVariableValue:{value:T6,label:T6},selectedDropdownValue:{value:T6,label:r9||T6}}:y5))},[]),o6=P0.useCallback(K6=>{var T6,r9;K6!=null&&K6.event&&((r9=(T6=K6==null?void 0:K6.event)==null?void 0:T6.event)==null||r9.preventDefault()),t0(K6)},[y7]),{getUnderlyingData:g8}=Y70({clientName:o,dbName:(l1=t==null?void 0:t.companyIntegration)==null?void 0:l1.name,tenancyType:a,values:U9,companyId:t==null?void 0:t.companyId,query:eg(t==null?void 0:t.query,t==null?void 0:t.companyId),workspaceId:g,metricId:t==null?void 0:t.id,rlsConditions:M8,globalFilters:n,isAllClient:!!u,dataMartRelationships:B5,customSql:(Z3=(z1=t==null?void 0:t.clickActions)==null?void 0:z1.underlyingData)==null?void 0:Z3.sql,isEnableCustomSQL:(M1==null?void 0:M1.chartType)===m0.singleValue&&((X7=(H3=t==null?void 0:t.clickActions)==null?void 0:H3.underlyingData)==null?void 0:X7.isEnable)&&((Q1=(i3=t==null?void 0:t.clickActions)==null?void 0:i3.underlyingData)==null?void 0:Q1.sql),datasourceId:D}),J3=P0.useMemo(()=>Array.isArray(j3)&&j3.length&&(z3!=null&&z3.name)?j3==null?void 0:j3.map(K6=>{const T6=Object.entries(K6).find(([,r9])=>(typeof r9=="number"&&typeof(z3==null?void 0:z3.name)=="string"?r9==null?void 0:r9.toString():r9)===z3.name);return T6==null?void 0:T6[0]}).filter(K6=>K6)[0]:"",[j3,z3==null?void 0:z3.name]),A8=async(K6,T6,r9,I8)=>{var ze,Qt,re,Le,Ci,Kn,le,qt,br,Ar,gn,hn,Tr,Rn,Eo,Jn,Un,Xi,Ki,Oi,Oo,Vr,Hi,po,aa,Ea,Yo;const B9=t==null?void 0:t.datasetMetricSettings;if(!(D7!=null&&D7.configV2)||!((ze=B9==null?void 0:B9.newDatasetSettings)!=null&&ze.configuration)||!((Qt=t==null?void 0:t.companyIntegration)!=null&&Qt.name)||!K6)return;let D8=K6;const n5=(D8==null?void 0:D8.levels)||[],y5=n5==null?void 0:n5.find(ve=>r9?ve.index===r9:ve==null?void 0:ve.isEnable),V5=n5==null?void 0:n5.findIndex(ve=>r9?ve.index===r9:ve==null?void 0:ve.isEnable),f4=V5>=0&&V5<(n5==null?void 0:n5.length)-1,R5=f4?n5==null?void 0:n5[V5+1]:n5==null?void 0:n5[0],R6=T6==null?void 0:T6.name,k8=(T6==null?void 0:T6.rowFilters)||[],J9=(Le=(re=y5==null?void 0:y5.dimensions)==null?void 0:re[0])==null?void 0:Le.alias;!y5||I8?D8={...D8||{},levels:((Ci=D8==null?void 0:D8.levels)==null?void 0:Ci.map((ve,xr)=>xr==0?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:r9&&y5?D8={...D8||{},levels:((Kn=D8==null?void 0:D8.levels)==null?void 0:Kn.map((ve,xr)=>ve.index===(y5==null?void 0:y5.index)?{...ve,filters:[...(y5==null?void 0:y5.filters)||[]],isEnable:!0}:{...ve,filters:xr>V5?[]:ve==null?void 0:ve.filters,isEnable:!1}))||[]}:(R6&&J9||k8!=null&&k8.length)&&y5?D8={...D8||{},levels:((le=D8==null?void 0:D8.levels)==null?void 0:le.map(ve=>ve.index===(R5==null?void 0:R5.index)?{...ve,filters:f4?[...(y5==null?void 0:y5.filters)||[],...k8!=null&&k8.length?k8:[{columnName:J9,value:R6}]]:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:D8={...D8||{},levels:((qt=D8==null?void 0:D8.levels)==null?void 0:qt.map(ve=>ve.index===(y5==null?void 0:y5.index)?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]},D8={...D8||{},levels:((br=D8==null?void 0:D8.levels)==null?void 0:br.map(ve=>{var xr,Pi;return{...ve,dimensions:((xr=ve==null?void 0:ve.dimensions)==null?void 0:xr.filter(rr=>{var nr,ln;return(ln=(nr=B9==null?void 0:B9.newDatasetSettings)==null?void 0:nr.selectedDims)==null?void 0:ln.some(Hn=>Hn.alias===(rr==null?void 0:rr.alias))}))||[],measures:((Pi=ve==null?void 0:ve.measures)==null?void 0:Pi.filter(rr=>{var nr,ln;return(ln=(nr=B9==null?void 0:B9.newDatasetSettings)==null?void 0:nr.selectedMetrics)==null?void 0:ln.some(Hn=>Hn.alias===(rr==null?void 0:rr.alias))}))||[]}}))||[]};const A5=(Ar=D8==null?void 0:D8.levels)==null?void 0:Ar.find(ve=>ve==null?void 0:ve.isEnable),Qe=!!((Tr=(hn=D8==null?void 0:D8.levels)==null?void 0:hn[((gn=D8==null?void 0:D8.levels)==null?void 0:gn.length)-1])!=null&&Tr.isEnable);(Eo=(Rn=D8==null?void 0:D8.levels)==null?void 0:Rn[0])==null||Eo.isEnable;const xe=(A5==null?void 0:A5.chartSettings)||M1,ge=(xe==null?void 0:xe.chartType)===m0.table,Ct=[...((Jn=A5==null?void 0:A5.dimensions)==null?void 0:Jn.map(ve=>ve.alias))||[],...((Un=A5==null?void 0:A5.measures)==null?void 0:Un.map(ve=>ve.alias))||[]],ye={...xe,xAxis:((Ki=(Xi=A5==null?void 0:A5.dimensions)==null?void 0:Xi[0])==null?void 0:Ki.alias)||"",yAxisList:Qe&&!(xe!=null&&xe.chartType)||ge?Ct:((Oi=A5==null?void 0:A5.measures)==null?void 0:Oi.map(ve=>ve.alias))||[],chartType:Qe&&!(xe!=null&&xe.chartType)?m0.table:xe==null?void 0:xe.chartType},j4=`${(Hi=(Vr=(Oo=A5==null?void 0:A5.dimensions)==null?void 0:Oo[0])==null?void 0:Vr.table)==null?void 0:Hi.schemaName}.${(Ea=(aa=(po=A5==null?void 0:A5.dimensions)==null?void 0:po[0])==null?void 0:aa.table)==null?void 0:Ea.tableName}`;if(_6(ve=>{var xr;return{...ve,configV2:{...D8||{},levels:((xr=D8==null?void 0:D8.levels)==null?void 0:xr.map(Pi=>Pi.index===(A5==null?void 0:A5.index)?{...Pi,chartSettings:ye}:Pi))||[]}}}),o9(ve=>ye),(Yo=t==null?void 0:t.drillDownSettings)!=null&&Yo.isEnableCrossFilter){const ve=(()=>{var xr;if(I8||r9)return[];if((R6&&J9||k8!=null&&k8.length)&&y5){if(k8!=null&&k8.length){const Pi=(xr=k8==null?void 0:k8.map(rr=>{var Hn,c9,K5,b4;const nr=(c9=(Hn=B9==null?void 0:B9.newDatasetSettings)==null?void 0:Hn.selectedDims)==null?void 0:c9.find(Pe=>(Pe==null?void 0:Pe.alias)===(rr==null?void 0:rr.columnName)),ln=`${(K5=nr==null?void 0:nr.table)==null?void 0:K5.schemaName}.${(b4=nr==null?void 0:nr.table)==null?void 0:b4.tableName}`;if(nr)return{columnName:rr==null?void 0:rr.columnName,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[rr==null?void 0:rr.value],tableName:a==="DATABASE"?`${o}.${ln==null?void 0:ln.split(".").slice(1).join(".")}`:ln,value:[rr==null?void 0:rr.value]}}))==null?void 0:xr.filter(rr=>rr);return[...l||[],...Pi]}if(J9&&R6)return[...l||[],{columnName:J9,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[R6],tableName:a==="DATABASE"?`${o}.${j4==null?void 0:j4.split(".").slice(1).join(".")}`:j4,value:[R6]}]}return[]})();C==null||C(ve)}},J8=async(K6,T6)=>{await A8(D7==null?void 0:D7.configV2,K6)},t8=({filters:K6,nextLevel:T6,currentValue:r9})=>{var Ct,ye;const I8=(Ct=t==null?void 0:t.datasetMetricSettings)==null?void 0:Ct.newDatasetSettings,B9=I8==null?void 0:I8.configuration,D8=(I8==null?void 0:I8.selectedDims)||[],n5=(I8==null?void 0:I8.selectedMetrics)||[],y5=((ye=t==null?void 0:t.datasetMetricSettings)==null?void 0:ye.createdSorts)||[],{headerColumns:V5,nonHeaderColumns:f4}=D8.reduce((j4,ze)=>{var Qt,re;return(re=(Qt=M1==null?void 0:M1.pivotTableSettings2)==null?void 0:Qt.headers)!=null&&re.includes(ze.alias)?j4.headerColumns.push(ze):j4.nonHeaderColumns.push(ze),j4},{headerColumns:[],nonHeaderColumns:[]}),R5=K6==null?void 0:K6.map(j4=>`${j4.columnName};;${j4.value}`).join(";;");s5(j4=>({...j4,data:j4.data.filter(ze=>ze.key!==R5),error:"",isLoading:!0,currentValue:r9}));const R6=f4.slice(0,T6),k8=K6==null?void 0:K6.map(j4=>{const ze=D8.find(Qt=>Qt.alias===j4.columnName);if(ze)return{alias:ze.alias||"",columnName:ze.name,dataType:ze.datatype,method:"=",parentAlias:ze.parentAlias,type:"dimension",value:j4.value,relationOperator:"AND"}}).filter(j4=>j4),J9=[...R6,...n5,...V5],{aggregates:A5,dimensions:Qe}=Hu(J9),xe=Yq2(y5),ge={...B9,dimensions:Qe,aggregates:A5,filters:[...B9.filters,...k8],orders:(xe==null?void 0:xe.filter(j4=>(j4==null?void 0:j4.type)==="selected_column"?J9==null?void 0:J9.some(ze=>(ze==null?void 0:ze.alias)===(j4==null?void 0:j4.name)):!0))||[],isApplyGlobalFilter:!0,isApplyMetricFilter:!0,globalFilters:n,rlsConditions:M8};x7({data:{configuration:ge,id:g,datasourceId:D,dashboardId:"",isCreateMetric:!0},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(j4){const ze=j4==null?void 0:j4.error,Qt=j4==null?void 0:j4.data;ze!=null&&ze.message?s5(re=>({...re,error:ze==null?void 0:ze.message,isLoading:!1,currentValue:""})):(s5(re=>({data:[...re.data,{key:R5,data:Array.isArray(Qt)?Qt:[]}],error:"",isLoading:!1,currentValue:""})),o9(re=>{var Le,Ci;return{...re,pivotTableSettings2:{...M1==null?void 0:M1.pivotTableSettings2,dimensions:fy(R6,((Le=t==null?void 0:t.companyIntegration)==null?void 0:Le.name)||""),headers:fy(V5,((Ci=t==null?void 0:t.companyIntegration)==null?void 0:Ci.name)||"")}}}))}})},a9=P0.useCallback(async(K6,T6)=>{await A8(D7==null?void 0:D7.configV2,void 0,K6,T6)},[D7==null?void 0:D7.configV2]),u8=P0.useCallback(K6=>{var T6;if(K6)Y7(r9=>[...r9==null?void 0:r9.filter(I8=>I8.group!==`${W3}`)]),d7(r9=>r9-1);else{const r9=(T6=y7.filter(I8=>!(I8!=null&&I8.group)))==null?void 0:T6.map(I8=>{var B9,D8,n5,y5;return{...I8,name:`${I8==null?void 0:I8.name}_${W3+1}`,group:`${W3+1}`,dependOn:I8.dependOn?{value:`${(B9=I8.dependOn)==null?void 0:B9.value}_${W3+1}`,label:`${(D8=I8.dependOn)==null?void 0:D8.label}_${W3+1}`,customColumnName:(n5=I8.dependOn)==null?void 0:n5.customColumnName}:void 0,dependOns:((y5=I8==null?void 0:I8.dependOns)==null?void 0:y5.map(V5=>({value:`${V5==null?void 0:V5.value}_${W3+1}`,label:`${V5==null?void 0:V5.label}_${W3+1}`,customColumnName:V5==null?void 0:V5.customColumnName})))||[]}});r9.length&&(Y7(I8=>[...I8,...r9]),d7(I8=>I8+1))}},[y7]),k9=P0.useCallback(async()=>{v1.report?A3(K6=>({...K6,isOpen:!0})):(A3({report:"",isLoading:!0,isOpen:!0}),await s7({data:{data:j3,wId:g},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(K6){const T6=K6==null?void 0:K6.content;A3(r9=>({...r9,report:T6||"",isLoading:!1}))},onError(){A3(K6=>({...K6,report:"",isLoading:!1}))}}))},[j3,o,A,f,d,o,v1]),P5=P0.useMemo(()=>{var V5,f4,R5,R6,k8,J9;const K6=(V5=t==null?void 0:t.datasetMetricSettings)==null?void 0:V5.newDatasetSettings,T6=K6==null?void 0:K6.configuration,r9=IR(j3||[]);let I8=r9;const B9=((f4=K6==null?void 0:K6.selectedDims)==null?void 0:f4.some(A5=>{var Qe,xe,ge;return El.includes(((xe=(Qe=A5==null?void 0:A5.cast)==null?void 0:Qe.value)==null?void 0:xe.toLowerCase())||((ge=A5==null?void 0:A5.datatype)==null?void 0:ge.toLowerCase())||"")}))||Fq2((j3==null?void 0:j3[0])||""),D8=((R5=K6==null?void 0:K6.selectedDims)==null?void 0:R5.length)>1&&((R6=K6==null?void 0:K6.selectedMetrics)==null?void 0:R6.length)>0,n5=[m0.pivot,m0.pivotV2,m0.pivotV3,m0.timeSeries,m0.treeMap,m0.indianMap,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap],y5=!!((k8=T6==null?void 0:T6.aggregates)!=null&&k8.length)&&!!((J9=T6==null?void 0:T6.dimensions)!=null&&J9.length);return y5&&B9&&(I8=[...r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5))),...n5]),y5&&!B9&&(I8=[...r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5))),...n5==null?void 0:n5.filter(A5=>A5!==m0.timeSeries)]),!y5&&B9&&(I8=[...r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5))),m0.timeSeries]),!y5&&!B9&&(I8=r9==null?void 0:r9.filter(A5=>!(n5!=null&&n5.includes(A5)))),D7!=null&&D7.isEnableGroupBy&&(D7!=null&&D7.configV2)&&(I8=I8==null?void 0:I8.filter(A5=>Mb==null?void 0:Mb.includes(A5))),D8||(I8=I8==null?void 0:I8.filter(A5=>A5!==m0.bubbleV2)),I8},[j3,M1==null?void 0:M1.xAxis,D7==null?void 0:D7.isEnableGroupBy,D7==null?void 0:D7.configV2,(V6=(T7=(y3=t==null?void 0:t.datasetMetricSettings)==null?void 0:y3.newDatasetSettings)==null?void 0:T7.configuration)==null?void 0:V6.aggregates,(i9=(V8=(r8=t==null?void 0:t.datasetMetricSettings)==null?void 0:r8.newDatasetSettings)==null?void 0:V8.configuration)==null?void 0:i9.dimensions]),s9=K6=>{var y5,V5,f4;const T6=(y5=t==null?void 0:t.datasetMetricSettings)==null?void 0:y5.newDatasetSettings,r9=T6==null?void 0:T6.configuration,I8=(T6==null?void 0:T6.selectedDims)||[],B9=(T6==null?void 0:T6.selectedMetrics)||[],D8=(V5=t==null?void 0:t.companyIntegration)==null?void 0:V5.name,n5=(f4=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:f4.isEnabled;Uq2({chartAggregateColumns:lW(fy((B9==null?void 0:B9.filter(R5=>{var R6,k8;return R5.configType==="AGGREGATE"&&n5?(k8=(R6=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:R6.measures)==null?void 0:k8.some(J9=>J9.value===R5.alias):!0}))||[],D8),j3||[]),chartDimensions:lW(fy((I8==null?void 0:I8.filter(R5=>{var R6,k8;return n5?(k8=(R6=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:R6.dimensions)==null?void 0:k8.some(J9=>J9.value===R5.alias):!0}))||[],D8),j3||[]),chartMetrics:lW(fy((B9==null?void 0:B9.filter(R5=>{var R6,k8;return n5?(k8=(R6=M1==null?void 0:M1.enduserMeasureAndDimensions)==null?void 0:R6.measures)==null?void 0:k8.some(J9=>J9.value===R5.alias):!0}))||[],D8),j3||[]),chartSettings:M1,chartTimeColumns:fy(I8==null?void 0:I8.filter(R5=>{var R6;return El.includes((R6=R5.datatype)==null?void 0:R6.toLowerCase())}),D8),chartType:K6,configAggregates:r9==null?void 0:r9.aggregates,configuration:T6==null?void 0:T6.configuration,pivotHeaderColumns:[],resultData:j3||[],setChartSettings:o9})},X5=P0.useMemo(()=>GP(y7.filter(K6=>K6.group&&K6.isAddOnMetrics&&!K6.isAppFilter),"group"),[y7]),U5=P0.useMemo(()=>{var r9,I8;return((r9=M1==null?void 0:M1.customSettings)==null?void 0:r9.comparisonValueShow)&&(M1==null?void 0:M1.chartType)===m0.singleValue?(I8=n==null?void 0:n.filters)==null?void 0:I8.find(B9=>(B9==null?void 0:B9.as)==="date"):void 0},[(S9=M1==null?void 0:M1.customSettings)==null?void 0:S9.comparisonValueShow,M1==null?void 0:M1.chartType,(D3=n==null?void 0:n.filters)==null?void 0:D3.find(K6=>(K6==null?void 0:K6.as)==="date")]);P0.useEffect(()=>{j3!=null&&j3.length&&c8.length?K8(!0):K8(!1)},[j3,c8.length,t==null?void 0:t.integrationName,t==null?void 0:t.query]);const z5=P0.useMemo(()=>{var K6,T6,r9,I8,B9,D8;return(r9=(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)==null?void 0:T6.selectedMetrics)!=null&&r9.some(n5=>n5.configType==="AGGREGATE")?((D8=(B9=(I8=t==null?void 0:t.datasetMetricSettings)==null?void 0:I8.newDatasetSettings)==null?void 0:B9.selectedDims)==null?void 0:D8.map(n5=>({value:n5.alias,label:n5.alias})))||[]:[]},[(E6=t==null?void 0:t.datasetMetricSettings)==null?void 0:E6.newDatasetSettings]),G5=P0.useMemo(()=>{var K6,T6,r9;return((r9=(T6=(K6=t==null?void 0:t.datasetMetricSettings)==null?void 0:K6.newDatasetSettings)==null?void 0:T6.selectedMetrics)==null?void 0:r9.map(I8=>({value:(I8==null?void 0:I8.alias)||(I8==null?void 0:I8.name),label:(I8==null?void 0:I8.alias)||(I8==null?void 0:I8.name)})))||[]},[(h6=(O7=t==null?void 0:t.datasetMetricSettings)==null?void 0:O7.newDatasetSettings)==null?void 0:h6.selectedMetrics]),{metricFilters:Z4,leftPositionedMetricFilters:T5,rightPositionedMetricFilters:d8}=P0.useMemo(()=>{const K6=y7.filter(B9=>!B9.isAppFilter);let T6=K6.filter(B9=>B9.isAddOnMetrics);N2&&(T6=T6.filter(B9=>vR(B9,!0)));const r9=[],I8=[];return T6.forEach(B9=>{B9.position==="top-right"?I8.push(B9):r9.push(B9)}),{metricFilters:K6,leftPositionedMetricFilters:r9,rightPositionedMetricFilters:I8}},[y7]),n9=[m0.pie,m0.doughnut,m0.rose,m0.funnel,m0.singleValue,m0.table,m0.pivot,m0.horizontalStackTable,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.sankey,m0.timeSeries,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap,m0.boxplot,m0.timeSeries,m0.gantt].includes(M1==null?void 0:M1.chartType)||((M1==null?void 0:M1.isMultiDimension)||(M1==null?void 0:M1.isDynamicSeries))&&(M1==null?void 0:M1.seriesField)!=="ungrouped",i8=P0.useMemo(()=>{var T6;const K6=((T6=t==null?void 0:t.dataSecuritySettings)==null?void 0:T6.csvColumns)||[];return j3!=null&&j3.length?j3==null?void 0:j3.map(r9=>{const I8={};for(const B9 in r9)K6!=null&&K6.includes(B9)||(I8[B9]=r9[B9]);return I8}):[]},[j3,t==null?void 0:t.dataSecuritySettings]);P0.useEffect(()=>{var K6,T6;M1||(o9(t==null?void 0:t.chartOptions),L3({limit:parseInt(((T6=(K6=t==null?void 0:t.chartOptions)==null?void 0:K6.tableSettings)==null?void 0:T6.defaultRowSize)||"100",10),offset:0}))},[t==null?void 0:t.chartOptions,M1]),P0.useEffect(()=>{var K6,T6,r9,I8,B9,D8,n5,y5,V5,f4;if((M1==null?void 0:M1.chartType)===m0.timeSeries&&((T6=(K6=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:K6.groupBySettings)!=null&&T6.isGlobalFilter)&&E7){const R5=(I8=(r9=n==null?void 0:n.filters)==null?void 0:r9.find(R6=>{var k8,J9,A5;return R6.label===((A5=(J9=(k8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:k8.groupBySettings)==null?void 0:J9.globalFilterOption)==null?void 0:A5.value)}))==null?void 0:I8.value;if((typeof R5=="string"||typeof R5=="object"&&(R5!=null&&R5.value))&&R5){const R6=typeof R5=="string"?(B9=kb(R5))==null?void 0:B9.toLowerCase():((f4=(V5=(y5=(n5=(D8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:D8.groupBySettings)==null?void 0:n5.formatWithValue)==null?void 0:y5.find(k8=>k8.value===kb(R5==null?void 0:R5.value)))==null?void 0:V5.format)==null?void 0:f4.toLowerCase())||"";vC!=null&&vC.find(k8=>{var J9;return((J9=k8==null?void 0:k8.value)==null?void 0:J9.toLowerCase())===R6})&&o9(k8=>{var J9;return{...k8,timeSeriesSettings:{...k8==null?void 0:k8.timeSeriesSettings,groupBySettings:{...(J9=k8==null?void 0:k8.timeSeriesSettings)==null?void 0:J9.groupBySettings,value:R6}},xAxis:u5?k8.xAxis:`${R6} of ${E7}`}})}}},[n,M1==null?void 0:M1.chartType,(F8=(Z6=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:Z6.groupBySettings)==null?void 0:F8.isGlobalFilter,(_8=(E8=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:E8.groupBySettings)==null?void 0:_8.globalFilterOption,E7]),P0.useEffect(()=>{var K6,T6,r9,I8;M1!=null&&M1.isDynamicSeries&&((K6=M1==null?void 0:M1.seriesOptions)!=null&&K6.includes("ungrouped")?M1!=null&&M1.ungroupedAlias?b5((T6=M1==null?void 0:M1.seriesOptions)==null?void 0:T6.map(B9=>B9==="ungrouped"?{value:B9,label:M1==null?void 0:M1.ungroupedAlias}:{value:B9,label:B9})):b5((r9=M1==null?void 0:M1.seriesOptions)==null?void 0:r9.map(B9=>({value:B9,label:B9}))):b5([...((I8=M1==null?void 0:M1.seriesOptions)==null?void 0:I8.map(B9=>({value:B9,label:B9})))??[]]))},[M1==null?void 0:M1.seriesOptions,M1==null?void 0:M1.isDynamicSeries,M1==null?void 0:M1.ungroupedAlias]);const[B6,e5]=P0.useState(!1),E9=K6=>{K6.key==="Control"&&e5(!0)},A9=K6=>{K6.key==="Control"&&e5(!1)};P0.useEffect(()=>{j3!=null&&j3.length&&L6(Object.keys((j3==null?void 0:j3[0])||{}))},[j3==null?void 0:j3.length]),P0.useEffect(()=>{var K6,T6;return(T6=(K6=M1==null?void 0:M1.customSettings)==null?void 0:K6.chartZoom)!=null&&T6.isZoomEnabled&&(window.addEventListener("keydown",E9),window.addEventListener("keyup",A9)),()=>{window.removeEventListener("keydown",E9),window.removeEventListener("keyup",A9)}},[]);const p9=P0.useMemo(()=>{let K6=!1;if(j3!=null&&j3.length){const T6=M1==null?void 0:M1.singleValue;K6=j3[0][T6]===null&&(M1==null?void 0:M1.chartType)==="singleValue"}return K6},[j3==null?void 0:j3.length,M1==null?void 0:M1.singleValue,(M1==null?void 0:M1.chartType)==="singleValue"]),d5=P0.useMemo(()=>ud({chartOptions:M1,data:j3||[]}),[j3,M1==null?void 0:M1.xAxis,M1==null?void 0:M1.yAxisList,(R9=M1==null?void 0:M1.dynamicXAxis)==null?void 0:R9.isEnabled,M1==null?void 0:M1.chartType,M1==null?void 0:M1.seriesField,(Z8=M1==null?void 0:M1.customSettings)==null?void 0:Z8.cumulativeBar,M1==null?void 0:M1.isGroupXAxis,(r5=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:r5.seriesType[0],(c5=(t5=M1==null?void 0:M1.timeSeriesSettings)==null?void 0:t5.groupBySettings)==null?void 0:c5.fillXAxis]),C5=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.name)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.name,b8,J,k]),W6=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.longDescription)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.longDescription,b8,k,J]),e9=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.description)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.description,b8,k,J]),Y9=P0.useMemo(()=>PC({text:xC((t==null?void 0:t.footNote)||"",b8)||"",selectedLanguage:k,translationDictionary:J}),[t==null?void 0:t.footNote,b8,k,J]),P9=P0.useMemo(()=>{var K6;return`${((K6=j3==null?void 0:j3[0])==null?void 0:K6.dbn_metric_expression_data)||"No Data Found"}`},[j3]),C9=P0.useMemo(()=>{var K6;return(K6=t==null?void 0:t.rlsConditions)==null?void 0:K6.map(T6=>{var I8,B9,D8,n5;if((T6==null?void 0:T6.datatype)==="date"&&((I8=T6==null?void 0:T6.options)==null?void 0:I8.find(y5=>y5.range==="Custom Date"))&&(T6==null?void 0:T6.isEnableDynamicDate)&&((B9=T6==null?void 0:T6.dynamicDate)==null?void 0:B9.value)){const y5=$s2(((D8=Tb==null?void 0:Tb.find(R5=>{var R6;return R5.value===((R6=T6==null?void 0:T6.dynamicDate)==null?void 0:R6.value)}))==null?void 0:D8.count)||0),V5=qc(y5),f4=qc(y5);return{...T6,options:(n5=T6==null?void 0:T6.options)==null?void 0:n5.map(R5=>R5.range==="Custom Date"?{...R5,startDate:y5,endDate:y5,timeGrainValue:`${V5} - ${f4}`}:R5)}}return T6})},[t==null?void 0:t.rlsConditions]);P0.useLayoutEffect(()=>{Q6&&(y==null||y(K6=>{const T6=new Map(K6);return T6.set(t==null?void 0:t.id,{data:{data:[],name:"",description:""},isLoading:Q6,key:""}),T6})),e7!=null&&e7.data&&E&&(y==null||y(K6=>{const T6=new Map(K6);return T6.set(t==null?void 0:t.id,{data:{data:e7==null?void 0:e7.data,name:(t==null?void 0:t.name)||"",description:(t==null?void 0:t.description)||""},isLoading:Q6,key:JSON.stringify(W8)}),T6}))},[e7==null?void 0:e7.data,Q6]);const I4=()=>{var T6,r9,I8;return(((I8=(r9=(T6=t==null?void 0:t.elementSettings)==null?void 0:T6.summary)==null?void 0:r9.metricList)==null?void 0:I8.map(B9=>{var D8;return(D8=E==null?void 0:E.get(B9==null?void 0:B9.value))==null?void 0:D8.isLoading}))||[]).some(B9=>B9===!0)};P0.useLayoutEffect(()=>{var K6,T6,r9,I8,B9,D8,n5,y5,V5,f4,R5;if((T6=(K6=t==null?void 0:t.elementSettings)==null?void 0:K6.summary)!=null&&T6.metricList&&(E!=null&&E.get(t==null?void 0:t.id))&&!p0&&!I4()){const R6=((B9=(I8=(r9=t==null?void 0:t.elementSettings)==null?void 0:r9.summary)==null?void 0:I8.metricList)==null?void 0:B9.map(k8=>{var J9,A5,Qe,xe,ge,Ct,ye,j4,ze;return{data:(Qe=(A5=(J9=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:J9.data)==null?void 0:A5.data)!=null&&Qe.length?(ge=(xe=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:xe.data)==null?void 0:ge.data:{},metricName:(ye=(Ct=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:Ct.data)==null?void 0:ye.name,metricDescription:(ze=(j4=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:j4.data)==null?void 0:ze.description}}))||[];x0(""),t1(""),!R6.some(k8=>Object.keys(k8.data).length===0)&&!p0&&(U0(()=>!0),E0.mutate({data:{metricData:R6,summaryPrompt:(n5=(D8=t==null?void 0:t.elementSettings)==null?void 0:D8.summary)==null?void 0:n5.summaryPrompt,id:t==null?void 0:t.id,filters:`${(R5=(f4=(V5=(y5=t==null?void 0:t.elementSettings)==null?void 0:y5.summary)==null?void 0:V5.metricList)==null?void 0:f4.map(k8=>{var J9;return(J9=E==null?void 0:E.get(k8==null?void 0:k8.value))==null?void 0:J9.key}))==null?void 0:R5.join("###")}`,name:t==null?void 0:t.name,description:t==null?void 0:t.description,workspaceId:g},token:f||"",clientId:A?d||"":o,isFrontendApp:A},{onSuccess:k8=>{k8.summary?(x0(k8.summary),t1("")):(t1(H02),x0("")),U0(()=>!1)},onSettled:()=>{U0(()=>!1)},onError:k8=>{U0(()=>!1),t1(k8.message),x0("")}}))}},[t==null?void 0:t.elementSettings,E]),P0.useEffect(()=>{var I8,B9,D8,n5,y5,V5,f4,R5,R6,k8,J9,A5,Qe,xe,ge,Ct,ye,j4,ze,Qt,re,Le,Ci,Kn;const K6=fc(((I8=M1==null?void 0:M1.customSettings)==null?void 0:I8.comboAxisSettings)||[]),T6=(B9=K6==null?void 0:K6.map(le=>le==null?void 0:le.measures))==null?void 0:B9.flat(),r9=(D8=M1==null?void 0:M1.yAxisList)==null?void 0:D8.every(le=>T6==null?void 0:T6.includes(le));if((n5=M1==null?void 0:M1.yAxisList)!=null&&n5.length&&((y5=M1==null?void 0:M1.yAxisList)==null?void 0:y5.length)!==(T6==null?void 0:T6.length)&&!(T6!=null&&T6.length)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((M1==null?void 0:M1.chartType)||"")){const le=(f4=(V5=M1==null?void 0:M1.yAxisList)==null?void 0:V5.filter(hn=>{var Tr;return!((Tr=M1==null?void 0:M1.comboBarList)!=null&&Tr.includes(hn))}))==null?void 0:f4.filter(hn=>!(T6!=null&&T6.includes(hn))),qt=((R6=(R5=M1==null?void 0:M1.customSettings)==null?void 0:R5.comboStackAxisSymbols)==null?void 0:R6.name)||"",br=(A5=(J9=(k8=M1==null?void 0:M1.customSettings)==null?void 0:k8.comboLabelFormatter)==null?void 0:J9.find(hn=>hn.axis===(qt||"stack")))==null?void 0:A5.formatter,Ar=(Qe=M1==null?void 0:M1.comboBarList)==null?void 0:Qe.join(" and "),gn=(Ct=(ge=(xe=M1==null?void 0:M1.customSettings)==null?void 0:xe.comboLabelFormatter)==null?void 0:ge.find(hn=>hn.axis===Ar))==null?void 0:Ct.formatter;o9(hn=>{var Tr,Rn,Eo,Jn,Un,Xi,Ki,Oi,Oo,Vr,Hi,po,aa,Ea,Yo,ve,xr,Pi,rr;return{...hn,customSettings:{...hn.customSettings,comboAxisSettings:fc([...((Tr=hn.customSettings)==null?void 0:Tr.comboAxisSettings)||[],...le==null?void 0:le.map(nr=>{var c9,K5,b4,Pe,Br,at;const ln=(b4=(K5=(c9=M1==null?void 0:M1.customSettings)==null?void 0:c9.comboLabelFormatter)==null?void 0:K5.find(ft=>ft.axis===nr))==null?void 0:b4.formatter,Hn=(Br=(Pe=M1==null?void 0:M1.customSettings)==null?void 0:Pe.comboAxisSymbols)==null?void 0:Br.find(ft=>ft.name===nr);return{axis:nr,measures:[nr],chartTypes:[{axis:nr,type:"line"}],numberFormatter:(at=M1==null?void 0:M1.customSettings)==null?void 0:at.numberFormatter,labelFormatter:ln,prefix:(Hn==null?void 0:Hn.prefix)||"",suffix:(Hn==null?void 0:Hn.suffix)||"",isEnableLabelFormatter:!!(ln!=null&&ln.length)}}),...(Rn=M1==null?void 0:M1.comboBarList)!=null&&Rn.length&&((Eo=M1==null?void 0:M1.customSettings)!=null&&Eo.isCombineBarAxis||(Jn=M1==null?void 0:M1.customSettings)!=null&&Jn.isStackBar)?[{axis:(Un=M1==null?void 0:M1.customSettings)!=null&&Un.isStackBar&&qt||Ar,measures:M1==null?void 0:M1.comboBarList,chartTypes:(Xi=M1==null?void 0:M1.comboBarList)==null?void 0:Xi.map(nr=>({axis:nr,type:"bar"})),isEnableStackBar:(Ki=M1==null?void 0:M1.customSettings)==null?void 0:Ki.isStackBar,numberFormatter:(Oi=M1==null?void 0:M1.customSettings)==null?void 0:Oi.numberFormatter,...(Oo=M1==null?void 0:M1.customSettings)!=null&&Oo.isStackBar?{prefix:((Hi=(Vr=M1==null?void 0:M1.customSettings)==null?void 0:Vr.comboStackAxisSymbols)==null?void 0:Hi.prefix)||"",suffix:((aa=(po=M1==null?void 0:M1.customSettings)==null?void 0:po.comboStackAxisSymbols)==null?void 0:aa.suffix)||"",labelFormatter:br,isEnableLabelFormatter:!!(br!=null&&br.length)}:{prefix:((Ea=M1==null?void 0:M1.customSettings)==null?void 0:Ea.combinedAxisPrefix)||"",suffix:((Yo=M1==null?void 0:M1.customSettings)==null?void 0:Yo.combinedAxisSuffix)||"",labelFormatter:gn,isEnableLabelFormatter:!!(gn!=null&&gn.length)}}]:[],...(ve=M1==null?void 0:M1.comboBarList)!=null&&ve.length&&!((xr=M1==null?void 0:M1.customSettings)!=null&&xr.isCombineBarAxis)&&!((Pi=M1==null?void 0:M1.customSettings)!=null&&Pi.isStackBar)?(rr=M1==null?void 0:M1.comboBarList)==null?void 0:rr.map(nr=>{var c9,K5,b4,Pe,Br,at;const ln=(b4=(K5=(c9=M1==null?void 0:M1.customSettings)==null?void 0:c9.comboLabelFormatter)==null?void 0:K5.find(ft=>ft.axis===nr))==null?void 0:b4.formatter,Hn=(Br=(Pe=M1==null?void 0:M1.customSettings)==null?void 0:Pe.comboAxisSymbols)==null?void 0:Br.find(ft=>ft.name===nr);return{axis:nr,measures:[nr],chartTypes:[{axis:nr,type:"bar"}],numberFormatter:(at=M1==null?void 0:M1.customSettings)==null?void 0:at.numberFormatter,labelFormatter:ln,prefix:(Hn==null?void 0:Hn.prefix)||"",suffix:(Hn==null?void 0:Hn.suffix)||"",isEnableLabelFormatter:!!(ln!=null&&ln.length)}}):[]].filter(nr=>{var ln;return(ln=nr==null?void 0:nr.measures)==null?void 0:ln.length})),comboAxisSymbols:[],combinedAxisPrefix:"",combinedAxisSuffix:"",comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}})}if(T6!=null&&T6.length&&((ye=M1==null?void 0:M1.yAxisList)!=null&&ye.length)&&(((j4=M1==null?void 0:M1.yAxisList)==null?void 0:j4.length)!==(T6==null?void 0:T6.length)||((ze=M1==null?void 0:M1.yAxisList)==null?void 0:ze.length)===(T6==null?void 0:T6.length)&&!r9)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((M1==null?void 0:M1.chartType)||"")){const le=(Qt=M1==null?void 0:M1.yAxisList)==null?void 0:Qt.filter(br=>!(T6!=null&&T6.includes(br))),qt=T6==null?void 0:T6.filter(br=>{var Ar;return!((Ar=M1==null?void 0:M1.yAxisList)!=null&&Ar.includes(br))});qt==null||qt.forEach(br=>{var Tr,Rn,Eo;const Ar=(Rn=(Tr=M1==null?void 0:M1.customSettings)==null?void 0:Tr.comboAxisSettings)==null?void 0:Rn.find(Jn=>{var Un;return(Un=Jn.measures)==null?void 0:Un.includes(br)}),gn=Ar==null?void 0:Ar.axis,hn=(((Eo=Ar==null?void 0:Ar.measures)==null?void 0:Eo.length)||0)>1;o9(Jn=>{var Un,Xi,Ki,Oi,Oo;return{...Jn,customSettings:{...Jn.customSettings,comboAxisSettings:fc(hn?((Ki=(Xi=(Un=Jn.customSettings)==null?void 0:Un.comboAxisSettings)==null?void 0:Xi.map(Vr=>{var Hi;return Vr.axis===gn?{...Vr,measures:(Hi=Vr==null?void 0:Vr.measures)==null?void 0:Hi.filter(po=>po!==br)}:Vr}))==null?void 0:Ki.filter(Vr=>{var Hi;return(Hi=Vr==null?void 0:Vr.measures)==null?void 0:Hi.length}))||[]:((Oo=(Oi=Jn.customSettings)==null?void 0:Oi.comboAxisSettings)==null?void 0:Oo.filter(Vr=>{var Hi;return Vr.axis!==gn&&((Hi=Vr==null?void 0:Vr.measures)==null?void 0:Hi.length)}))||[])}}})}),le!=null&&le.length&&o9(br=>{var Ar;return{...br,customSettings:{...br.customSettings,comboAxisSettings:fc([...((Ar=br.customSettings)==null?void 0:Ar.comboAxisSettings)||[],...le==null?void 0:le.map(gn=>({axis:gn,measures:[gn],chartTypes:[{axis:gn,type:"line"}]}))].filter(gn=>{var hn;return(hn=gn==null?void 0:gn.measures)==null?void 0:hn.length})||[])}}})}T6!=null&&T6.length&&((re=M1==null?void 0:M1.yAxisList)!=null&&re.length)&&((Le=M1==null?void 0:M1.yAxisList)==null?void 0:Le.length)===(T6==null?void 0:T6.length)&&r9&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((M1==null?void 0:M1.chartType)||"")&&((Kn=(Ci=M1==null?void 0:M1.customSettings)==null?void 0:Ci.comboAxisSettings)==null?void 0:Kn.length)!==(K6==null?void 0:K6.length)&&o9(le=>({...le,customSettings:{...le==null?void 0:le.customSettings,comboAxisSettings:K6}}))},[M1==null?void 0:M1.yAxisList,(s4=M1==null?void 0:M1.customSettings)==null?void 0:s4.comboAxisSettings,M1==null?void 0:M1.comboBarList,(q4=M1==null?void 0:M1.customSettings)==null?void 0:q4.isCombineBarAxis,(ie=M1==null?void 0:M1.customSettings)==null?void 0:ie.isStackBar,(fe=(Be=M1==null?void 0:M1.customSettings)==null?void 0:Be.comboStackAxisSymbols)==null?void 0:fe.name,(Bt=(it=M1==null?void 0:M1.customSettings)==null?void 0:it.comboStackAxisSymbols)==null?void 0:Bt.prefix,(Cn=(jr=M1==null?void 0:M1.customSettings)==null?void 0:jr.comboStackAxisSymbols)==null?void 0:Cn.suffix,(xn=M1==null?void 0:M1.customSettings)==null?void 0:xn.comboLabelFormatter,(di=M1==null?void 0:M1.customSettings)==null?void 0:di.comboAxisSymbols,(ii=M1==null?void 0:M1.customSettings)==null?void 0:ii.numberFormatter,(oi=M1==null?void 0:M1.customSettings)==null?void 0:oi.combinedAxisPrefix,(Ri=M1==null?void 0:M1.customSettings)==null?void 0:Ri.combinedAxisSuffix,M1==null?void 0:M1.chartType]),P0.useEffect(()=>{var K6,T6,r9;(K6=M1==null?void 0:M1.yAxisList)!=null&&K6.length&&((T6=M1==null?void 0:M1.yAxisList)==null?void 0:T6.length)<5&&(M1==null?void 0:M1.chartType)===m0.boxplot&&o9(I8=>({...I8,chartType:m0.line})),!((r9=M1==null?void 0:M1.yAxisList)!=null&&r9.length)&&(M1==null?void 0:M1.chartType)===m0.funnelV2&&o9(I8=>({...I8,chartType:m0.singleValue}))},[M1==null?void 0:M1.chartType,(Ni=M1==null?void 0:M1.yAxisList)==null?void 0:Ni.length]);const v4=({columnAlias:K6,value:T6,isClear:r9=!1})=>{const I8=t==null?void 0:t.datasetMetricSettings;I8&&Gq2({columnAlias:K6,datasetSettings:I8,setTableColumnFilters:z7,value:T6,isClear:r9})};return P0.useEffect(()=>{var T6,r9,I8,B9;if(!((T6=M1==null?void 0:M1.dynamicYAxis)!=null&&T6.isEnabled)||!((r9=M1==null?void 0:M1.dynamicYAxis)!=null&&r9.selectedOption)||Array.isArray((I8=M1==null?void 0:M1.dynamicYAxis)==null?void 0:I8.selectedOption))return;const K6=(B9=M1==null?void 0:M1.dynamicYAxis)==null?void 0:B9.selectedOption;o9(D8=>({...D8,dynamicYAxis:{...D8==null?void 0:D8.dynamicYAxis,selectedOption:[K6]},yAxisList:[K6==null?void 0:K6.value]}))},[(dn=M1==null?void 0:M1.dynamicYAxis)==null?void 0:dn.selectedOption,(Xr=M1==null?void 0:M1.dynamicYAxis)==null?void 0:Xr.isEnabled]),P0.useEffect(()=>{var I8,B9,D8,n5,y5,V5,f4,R5;const K6=(I8=i2==null?void 0:i2.yAxisSettings)==null?void 0:I8.find(R6=>{var k8,J9,A5,Qe,xe;return((k8=R6==null?void 0:R6.yAxisSettings)==null?void 0:k8.isEnable)&&(R6==null?void 0:R6.id)===(t==null?void 0:t.id)&&((J9=R6==null?void 0:R6.yAxisSettings)==null?void 0:J9.yAxis)&&Array.isArray((A5=R6==null?void 0:R6.yAxisSettings)==null?void 0:A5.yAxis)&&((xe=(Qe=R6==null?void 0:R6.yAxisSettings)==null?void 0:Qe.yAxis)==null?void 0:xe.length)>0}),T6=(B9=i2==null?void 0:i2.xAxisSettings)==null?void 0:B9.find(R6=>{var k8,J9;return((k8=R6==null?void 0:R6.xAxisSettings)==null?void 0:k8.isEnable)&&(R6==null?void 0:R6.id)===(t==null?void 0:t.id)&&((J9=R6==null?void 0:R6.xAxisSettings)==null?void 0:J9.xaxis)});if(!((D8=M1==null?void 0:M1.dynamicYAxis)!=null&&D8.isEnabled)&&!((n5=M1==null?void 0:M1.dynamicXAxis)!=null&&n5.isEnabled)&&!((y5=D7==null?void 0:D7.configV2)!=null&&y5.isEnable)||!K6&&!T6&&!((V5=D7==null?void 0:D7.configV2)!=null&&V5.isEnable)){o9(R6=>(t==null?void 0:t.chartOptions)||R6);return}const r9=(R5=(f4=K6==null?void 0:K6.yAxisSettings)==null?void 0:f4.yAxis)==null?void 0:R5[0];o9(R6=>{var k8,J9,A5,Qe,xe,ge,Ct;return{...R6,dynamicYAxis:{...R6==null?void 0:R6.dynamicYAxis,selectedOption:r9?[r9]:((k8=R6==null?void 0:R6.dynamicYAxis)==null?void 0:k8.selectedOption)||[]},dynamicXAxis:{...R6==null?void 0:R6.dynamicXAxis,selectedOption:(J9=T6==null?void 0:T6.xAxisSettings)!=null&&J9.xaxis?{value:(A5=T6==null?void 0:T6.xAxisSettings)==null?void 0:A5.xaxis,label:(Qe=T6==null?void 0:T6.xAxisSettings)==null?void 0:Qe.xaxis}:((xe=R6==null?void 0:R6.dynamicXAxis)==null?void 0:xe.selectedOption)||[]},yAxisList:r9!=null&&r9.value?[r9==null?void 0:r9.value]:(R6==null?void 0:R6.yAxisList)||[],xAxis:(ge=T6==null?void 0:T6.xAxisSettings)!=null&&ge.xaxis?(Ct=T6==null?void 0:T6.xAxisSettings)==null?void 0:Ct.xaxis:(R6==null?void 0:R6.xAxis)||""}})},[i2==null?void 0:i2.yAxisSettings,t==null?void 0:t.id,i2==null?void 0:i2.xAxisSettings,(gi=M1==null?void 0:M1.dynamicYAxis)==null?void 0:gi.isEnabled,(_i=M1==null?void 0:M1.dynamicXAxis)==null?void 0:_i.isEnabled,(ai=D7==null?void 0:D7.configV2)==null?void 0:ai.isEnable]),P0.useEffect(()=>{var K6,T6,r9;(K6=M1==null?void 0:M1.customSettings)!=null&&K6.isShowDuration&&(M1==null?void 0:M1.chartType)===m0.gantt&&!((r9=(T6=M1==null?void 0:M1.customSettings)==null?void 0:T6.ganttTooltipKeys)!=null&&r9.includes("Duration"))&&o9(I8=>{var B9;return{...I8,customSettings:{...I8==null?void 0:I8.customSettings,ganttTooltipKeys:[...((B9=I8==null?void 0:I8.customSettings)==null?void 0:B9.ganttTooltipKeys)||[],"Duration"]}}})},[(hi=M1==null?void 0:M1.customSettings)==null?void 0:hi.isShowDuration,M1==null?void 0:M1.chartType,(si=M1==null?void 0:M1.customSettings)==null?void 0:si.ganttTooltipKeys]),{elementSummary:M0,elementSummaryError:z2,isLoadingSummary:p0,isMetricListLoading:I4,onDrillLevelClick:a9,onDrillDown:J8,handleChartClick:o6,dataDb:j3,getUnderlyingData:g8,onChangeFilterValue:n6,isShowChartPopup:X6,setShowChartPopup:k6,columnName:J3,chartParams:z3,isQueryLoading:Q6||M2||Y2,isSingleValueNull:p9,dynamicOptions:d4,chartSettings:M1,setChartSettings:o9,isEnableZoom:B6,filterValues:U9,containerRef:G0,drilledLevel:V7.length,dimensions:((en=(Sr=t==null?void 0:t.datasetMetricSettings)==null?void 0:Sr.selectedDimensions)==null?void 0:en.map(K6=>Gs2(K6||"none")))||[],rlsConditions:y7,setRlsConditions:Y7,setTableLimit:L3,isEnableNextBtn:O1>(X2==null?void 0:X2.limit)+(X2==null?void 0:X2.offset),isEnablePrevBtn:(X2==null?void 0:X2.offset)!==0,paginationInfo:{limit:X2==null?void 0:X2.limit,offset:X2==null?void 0:X2.offset,totalRecords:O1},onChangePage:(K6,T6,r9)=>{L3(T6?{limit:T6,offset:0}:I8=>{let B9;return r9||r9===0?B9=r9:K6?B9=I8.offset>I8.limit?I8.offset-I8.limit:0:B9=I8.offset+I8.limit,{limit:I8.limit,offset:B9}})},isExternalChart:((ur=M1==null?void 0:M1.tableSettings)==null?void 0:ur.isServerSidePagination)&&(M1==null?void 0:M1.chartType)===m0.table,isEnablePivotTable:C8,groupByList:c8,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:K6=>{Y7(T6=>T6==null?void 0:T6.map(r9=>r9.name===K6.name&&r9.datatype===K6.datatype&&r9.tableName===K6.tableName&&r9.columnName===K6.columnName?{...r9,isAddOnMetrics:!r9.isAddOnMetrics}:r9))},metricFilters:Z4,leftPositionedMetricFilters:T5,rightPositionedMetricFilters:d8,drillFilters:V7,drillType:(tn=t==null?void 0:t.drillDownSettings)==null?void 0:tn.drillType,tableResultsDownloadData:i8,appliedMetricFilters:M8,pivotHeaderOptions:z5,pivotDrillState:O9,onDrillPivotTable:t8,legendData:d5,timeseriesDimension:E7,isPythonMode:u5,sortOrder:G7,setSortOrder:c6,isNotFirstRender:c7,setNotFirstRender:X3,isSorted:N5,isInavlidForSort:n9,onAddComparison:u8,groupedRlsConditions:X5,onGenerateMetricSummary:k9,summary:v1,setSummary:A3,dataMartRelationships:B5,onChartChange:s9,isCompareValue:w6,isShowChartPropertyPanel:l8,setShowChartPropertyPanel:I9,columnList:u6,variables:b8,metricName:C5,longDescription:W6,footNote:Y9,description:e9,drilldownCols:Y3,switchMeasureOptions:G5,metricExpressionResult:P9,dateFilter:U5,drillDownSettings:D7,enabledCharts:P5,tableColumnFilters:I6,onChangePaginationColumnFilters:v4,queryError:P6||(e7==null?void 0:e7.error),refetchMetricData:f6,customSwitchXAxis:c3,savedMetricFilters:C9||[]}},J70=({metricId:t,onSuccess:n,token:i})=>{const{mutateAsync:o,isLoading:a}=I70();return{handleArchiveMetric:P0.useCallback(async()=>{!t||!i||await o({data:{id:t},token:i},{onSuccess:async r=>{r!=null&&r.error||await n()}})},[o,t]),isLoading:a}},XA2=({token:t,metricId:n})=>{var R2;const[i,o]=P0.useState(!0),{data:a,isLoading:s}=U70(t,n),{externalMetric:r,sharingSettingsId:C,adminTheme:l,params:e,companyId:u,clientId:A,errorMsg:f,clientColumnType:d,isEnableMetricSummary:g,isAllClient:E,isShowUnderlyingData:y,appFilters:Q,mergedMetricsId:R,datasourceId:D,mergedMetricLayout:O,mergedDashboardFilters:k,dashboardAppFilterValues:J,filterLayout:e2,nestedMetric:p2,guestToken:D2}=P0.useMemo(()=>{var Z2,Y2;const M2=a;return{externalMetric:M2==null?void 0:M2.externalMetric,adminTheme:M2==null?void 0:M2.adminTheme,sharingSettingsId:M2==null?void 0:M2.sharingSettingsId,errorMsg:(Z2=M2==null?void 0:M2.error)==null?void 0:Z2.message,params:M2==null?void 0:M2.params,companyId:M2==null?void 0:M2.companyId,clientId:M2==null?void 0:M2.clientId,clientColumnType:M2==null?void 0:M2.cType,isEnableMetricSummary:M2==null?void 0:M2.isEnableMetricSummary,isAllClient:!!(M2!=null&&M2.isAllClient),isShowUnderlyingData:(M2==null?void 0:M2.isShowUnderlyingData)||!1,appFilters:M2==null?void 0:M2.appFilters,mergedMetricsId:M2==null?void 0:M2.mergedMetricsId,datasourceId:(M2==null?void 0:M2.datasourceId)||"",mergedMetricLayout:(M2==null?void 0:M2.mergedMetricLayout)||[],mergedDashboardFilters:(M2==null?void 0:M2.mergedDashboardFilters)||[],dashboardAppFilterValues:M2==null?void 0:M2.dashboardAppFilterValues,filterLayout:(M2==null?void 0:M2.filterLayout)||[],nestedMetric:M2==null?void 0:M2.nestedMetric,guestToken:(Y2=window==null?void 0:window.dbn)!=null&&Y2.isEnableProxyAuth?eg(M2==null?void 0:M2.token,M2==null?void 0:M2.companyId):M2==null?void 0:M2.token}},[a,(R2=window==null?void 0:window.dbn)==null?void 0:R2.isEnableProxyAuth]),{rlsSettings:Q2,tenancyLevel:i2,workspaceId:N2}=P0.useMemo(()=>{var Z2,Y2;if(!e)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const M2=JSON.parse(e);return{rlsSettings:(Z2=M2.rlsSettings)==null?void 0:Z2.find(f0=>f0.metricId===n),tenancyLevel:M2.companyTenancyType||"TABLE",workspaceId:((Y2=M2==null?void 0:M2.workspace)==null?void 0:Y2.id)||""}},[e,n]);return P0.useEffect(()=>{s&&o(!0),(r||f||!s)&&o(!1)},[s,r,f]),{externalMetric:r,sharingSettingsId:C,companyId:u,clientId:A,rlsSettings:Q2,tenancyLevel:i2,isLoading:i,errorMsg:f,adminTheme:l,workspaceId:N2,clientColumnType:d,isEnableMetricSummary:g,isAllClient:E,isShowUnderlyingData:y,appFilters:Q,mergedMetricsId:R,datasourceId:D,mergedMetricLayout:O,mergedDashboardFilters:k,dashboardAppFilterValues:J,filterLayout:e2,nestedMetric:p2,token:D2}},q70=WA2({active:null,over:null,DragPreviewCreateRoot:null,draggables:[],droppables:[]}),KA2=()=>{const[t,n]=yX(q70);return{dndState:t,setActive:r=>{n(C=>({...C,active:r}))},setOver:r=>{n(C=>({...C,over:r}))},setDraggables:r=>{n(C=>{var u;const l=(u=C.draggables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,draggables:[...C.draggables,r]};const e=[...C.draggables];return e[l]=r,{...C,draggables:e}})},setDropables:r=>{n(C=>{var u;const l=(u=C.droppables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,droppables:[...C.droppables,r]};const e=[...C.droppables];return e[l]=r,{...C,droppables:e}})},setDndState:n}},$70=({identifier:t,data:n,modifiers:i,events:o,CustomDragPreview:a,disabled:s=!1,dropText:r})=>{const{dndState:C,setActive:l,setDndState:e,setDraggables:u}=KA2(),[A,f]=P0.useState(!1),[d,g]=P0.useState(!0),[E,y]=P0.useState(null),Q=P0.useRef(null),R=P0.useRef(null),D={"data-type":t.type||t.id,id:`draggable-${t.id}`,role:"button",tabindex:"0",draggable:d?"true":"false","aria-grabbed":"false"},O=J=>{Object.entries(D).forEach(([e2,p2])=>{J.setAttribute(e2,p2)})},k=()=>{var J;R.current&&((J=C.DragPreviewCreateRoot)==null||J.render(a))};return P0.useEffect(()=>{if(a&&(R.current=document.getElementById("CustomDragPreviewContainer"),R.current===null)){R.current=document.createElement("div"),R.current.setAttribute("id","CustomDragPreviewContainer"),document.body.appendChild(R.current);const J=UL.createRoot(R.current);e(e2=>({...e2,DragPreviewCreateRoot:J}))}},[]),P0.useEffect(()=>{if(Q.current){const J=Q.current.getBoundingClientRect();y(J),u({identifier:t,data:n,modifiers:i,DragNodeRef:Q,rect:E,events:o,isDragging:A,isEnableDrag:d})}},[Q.current,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i),JSON.stringify(o),JSON.stringify(A)]),P0.useEffect(()=>{const J=Q.current;if(!J)return;O(J);const e2=D2=>{var Q2,i2,N2,R2;if(f(!0),l({identifier:t,data:n,modifiers:i,DragNodeRef:Q,rect:E,events:o,isDragging:A,isEnableDrag:d}),J.setAttribute("aria-grabbed","true"),r?(Q2=D2.dataTransfer)==null||Q2.setData("text/plain",r):(i2=D2.dataTransfer)==null||i2.setData("text/plain",JSON.stringify({data:n})),(N2=o==null?void 0:o.onDragStart)==null||N2.call(o,D2,C),R.current){const M2=R.current.getBoundingClientRect();(R2=D2.dataTransfer)==null||R2.setDragImage(R.current,M2.width/2,M2.height/2)}},p2=D2=>{var Q2;J.setAttribute("aria-grabbed","false"),f(!1),l(null),(Q2=o==null?void 0:o.onDragEnd)==null||Q2.call(o,D2,C)};return J.addEventListener("mousedown",()=>{a&&k()}),J.addEventListener("dragstart",e2),J.addEventListener("dragend",p2),()=>{J.removeEventListener("dragstart",e2),J.removeEventListener("dragend",p2)}},[Q.current,JSON.stringify(t),JSON.stringify(n),C.DragPreviewCreateRoot]),P0.useEffect(()=>{const J=Q.current;J&&J.setAttribute("draggable",d?"true":"false")},[d]),P0.useEffect(()=>{var e2,p2,D2,Q2;let J=[];return A&&(l({identifier:t,data:n,modifiers:i,DragNodeRef:Q,rect:E,events:o,isDragging:A,isEnableDrag:d}),(e2=i==null?void 0:i.highlightDrop)!=null&&e2.onDrag&&(J=((D2=(p2=C.droppables)==null?void 0:p2.filter(i2=>((i2==null?void 0:i2.identifier.accepts)??[]).includes(t.type??"")&&(i2==null?void 0:i2.isEnableDrop)))==null?void 0:D2.map(i2=>i2==null?void 0:i2.setDropNodeRef.current))??[],(Q2=i==null?void 0:i.highlightDrop)!=null&&Q2.onDrag&&J.forEach(i2=>{var N2;i2==null||i2.classList.add(((N2=i==null?void 0:i.highlightDrop)==null?void 0:N2.highlightClass)||"dnd-droppable-highlight")}))),()=>{J.forEach(i2=>{var N2;i2==null||i2.classList.remove(((N2=i==null?void 0:i.highlightDrop)==null?void 0:N2.highlightClass)||"dnd-droppable-highlight")})}},[A]),P0.useEffect(()=>{g(!s)},[s]),{isDragging:A,isEnableDrag:d,setIsEnableDrag:g,DragNodeRef:Q}},JA2=({identifier:t,events:n,modifiers:i})=>{var O;const{dndState:o,setOver:a,setDropables:s}=KA2(),[r,C]=P0.useState(null),[l,e]=P0.useState({isDragOver:!1,isDrop:!1}),[u,A]=P0.useState({before:-1,after:-1}),[f,d]=P0.useState(!0),g=P0.useRef(null),E={"data-type":((O=t.accepts)==null?void 0:O.join("-"))??"",id:`droppable-${t.id}`,droppable:f?"true":"false"},y=k=>{Object.entries(E).forEach(([J,e2])=>{k.setAttribute(J,e2)})},Q=(k,J,e2)=>{const p2=[...e2];k=k===-1?p2.length-1:k;const[D2]=p2.splice(k,1);return J===-1?p2.push(D2):p2.splice(J,0,D2),p2},R=(k,J,e2)=>[...k.querySelectorAll('[draggable="true"]:not([aria-grabbed="true"])')].reduce((Q2,i2,N2)=>{const R2=i2.getBoundingClientRect(),M2=J-R2[e2==="horizontal"?"left":"top"]-R2[e2==="horizontal"?"width":"height"]/2;return M2<0&&M2>Q2.offset?{offset:M2,element:i2,index:N2}:Q2},{offset:Number.NEGATIVE_INFINITY,element:null,index:-1}),D=(k,J,e2)=>{const p2=[...k.querySelectorAll('[draggable="true"]')],D2=k.querySelector('[aria-grabbed="true"]'),{width:Q2,height:i2}=e2,N2=(M2,Z2,Y2)=>{const f0=M2.x-Z2/2,E0=M2.y-Y2/2;return[{x:f0,y:E0},{x:f0+Z2,y:E0},{x:f0,y:E0+Y2},{x:f0+Z2,y:E0+Y2}]};return p2.reduce((M2,Z2,Y2)=>{const f0=Z2.getBoundingClientRect(),E0=[{x:f0.left,y:f0.top},{x:f0.left+f0.width,y:f0.top},{x:f0.left,y:f0.top+f0.height},{x:f0.left+f0.width,y:f0.top+f0.height}],M0=N2(J,Q2,i2);let x0=Number.POSITIVE_INFINITY,z2=Y2,t1=Number.POSITIVE_INFINITY,p0=Number.POSITIVE_INFINITY;return E0.forEach((U0,G0)=>{M0.forEach(X2=>{let L3=Number.POSITIVE_INFINITY;t1=Math.sqrt((U0.x-X2.x)**2+(U0.y-X2.y)**2),p0=Math.sqrt((U0.x-J.x)**2+(U0.y-J.y)**2),L3=Math.min(t1,p0),L3<x0&&(x0=L3,G0===1||G0===3?D2!==Z2&&(z2=Y2+1):z2=Y2)})}),x0<M2.minDistance?{minDistance:x0,element:Z2,index:z2,closestBasedOnCorner:t1,closestBasedonCursor:p0}:M2},{minDistance:Number.POSITIVE_INFINITY,element:null,index:-1,closestBasedOnCorner:0,closestBasedonCursor:0})};return P0.useEffect(()=>{const k=g.current;if(!k)return;const J=k.getBoundingClientRect();C(J),s({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l})},[g.current,f,l.isDragOver,l.isDrop,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i)]),P0.useEffect(()=>{var i2,N2;const k=g.current;if(y(k),!k||!f||(i2=t.accepts)!=null&&i2.length&&!t.accepts.includes(((N2=o.active)==null?void 0:N2.identifier.type)??""))return;const{sorting:J}=i||{},e2=R2=>{var M2;R2.preventDefault(),a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),(M2=n==null?void 0:n.onDragEnter)==null||M2.call(n,R2,o)},p2=R2=>{var M2,Z2,Y2,f0,E0,M0,x0,z2,t1,p0,U0,G0;if(R2.preventDefault(),(Y2=(Z2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:Z2.highlightDrop)!=null&&Y2.onDragOver&&g.current.classList.add(((M0=(E0=(f0=o.active)==null?void 0:f0.modifiers)==null?void 0:E0.highlightDrop)==null?void 0:M0.highlightClass)||"dnd-droppable-highlight"),l.isDragOver||e(X2=>({...X2,isDragOver:!0})),o.over===null&&a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),J!=null&&J.isEnabled&&((x0=J.list)!=null&&x0.length)){const X2=(p0=(t1=(z2=o.active)==null?void 0:z2.DragNodeRef)==null?void 0:t1.current)==null?void 0:p0.getAttribute("data-dbn-sorting-index");let L3=null;if((J.sortingType==="vertical"||J.sortingType==="horizontal")&&(L3=R(k,(J==null?void 0:J.sortingType)==="horizontal"?R2.clientX:R2.clientY,J==null?void 0:J.sortingType)),J.sortingType==="both-axis"){const C3=(U0=document.getElementById("CustomDragPreviewContainer"))==null?void 0:U0.getBoundingClientRect();L3=D(k,{x:R2.clientX,y:R2.clientY},{width:(C3==null?void 0:C3.width)??0,height:(C3==null?void 0:C3.height)??0})}const O1={before:parseInt(X2??-1,10),after:L3==null?void 0:L3.index};(O1.before!==u.before||O1.after!==u.after)&&A(O1)}(G0=n==null?void 0:n.onDragOver)==null||G0.call(n,R2,o)},D2=R2=>{var M2,Z2,Y2,f0,E0,M0,x0;R2.preventDefault(),(Y2=(Z2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:Z2.highlightDrop)!=null&&Y2.onDragOver&&g.current.classList.remove(((M0=(E0=(f0=o.active)==null?void 0:f0.modifiers)==null?void 0:E0.highlightDrop)==null?void 0:M0.highlightClass)||"dnd-droppable-highlight"),e(z2=>({...z2,isDragOver:!1})),(x0=n==null?void 0:n.onDragLeave)==null||x0.call(n,R2,o),a(null)},Q2=R2=>{var E0,M0,x0,z2,t1,p0,U0,G0,X2,L3;R2.preventDefault();const M2=g.current.contains((M0=(E0=o.active)==null?void 0:E0.DragNodeRef)==null?void 0:M0.current);let Z2={...o};(t1=(z2=(x0=o.active)==null?void 0:x0.modifiers)==null?void 0:z2.highlightDrop)!=null&&t1.onDragOver&&g.current.classList.remove(((G0=(U0=(p0=o.active)==null?void 0:p0.modifiers)==null?void 0:U0.highlightDrop)==null?void 0:G0.highlightClass)||"dnd-droppable-highlight");let{before:Y2,after:f0}=u;if(J!=null&&J.isEnabled&&((X2=J.list)!=null&&X2.length)){let O1=[...J.list];M2?O1=Q(Y2,f0,O1):Y2=-1,Z2={...o,sorting:{sortedList:O1,isSelfDrop:M2,ArrayElementSwap:Q,sortingIndexes:{before:Y2,after:f0}}},J.isEnabledAutoSort&&M2&&J.setList(O1)}e(O1=>({...O1,isDrop:!0})),(L3=n==null?void 0:n.onDrop)==null||L3.call(n,R2,Z2),a(null)};return k.addEventListener("dragenter",e2),k.addEventListener("dragover",p2),k.addEventListener("dragleave",D2),k.addEventListener("drop",Q2),()=>{k.removeEventListener("dragenter",e2),k.removeEventListener("dragover",p2),k.removeEventListener("dragleave",D2),k.removeEventListener("drop",Q2)}},[g.current,t,f,i,n,u]),P0.useEffect(()=>{const k=g.current;k&&k.setAttribute("droppable",f?"true":"false")},[f]),{dragStatus:l,isEnableDrop:f,setIsEnableDrop:d,setDropNodeRef:g}},e60=(t,n,i)=>({autoCompleteDropdownOptions:P0.useMemo(()=>{if(!n.length)return[];const a=[];return n.forEach(s=>{s.columnsWithDataType.forEach(r=>{var g;const C=a$2(((g=r==null?void 0:r.dataType)==null?void 0:g.toLowerCase())||""),l=s$2(C,i),e=new Set,u=new Set,A=new Set;switch(r.columnTypeConfig&&typeof r.columnTypeConfig=="string"?e.add(r.columnTypeConfig):r.columnTypeConfig&&typeof r.columnTypeConfig=="object"&&Object.entries(r.columnTypeConfig).forEach(([E,y])=>{e.add(E),y&&u.add(y)}),C){case"DATE":rR.forEach(E=>E.synonyms.forEach(A.add,A));break;case"NUMBER":KE.forEach(E=>E.synonymns.forEach(A.add,A));break;case"STRING":Oh.forEach(E=>E.synonyms.forEach(A.add,A)),RB2.forEach(E=>E.synonyms.forEach(A.add,A));break}$L.forEach(E=>E.synonymns.forEach(A.add,A));const f=l.flatMap(E=>(xb==null?void 0:xb[E.value])||[]),d={alias:`${s.tableName}.${r.alias||r.name}`,datatype:r.dataType,name:r.name,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],functionsSynonyms:f,distinctValues:[...e],filtersSynonyms:[...A],distinctValueSynonyms:[...u],type:"COLUMN"};a.push(d),e.forEach(E=>{a.push({alias:E,datatype:r.dataType,name:E,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],distinctValueSynonyms:[...u],type:"VALUE"})})})}),a},[n,i,t])}),t60=(t="download.pdf",n)=>({toPDF:async o=>{var C,l,e;const a=((C=window==null?void 0:window.dbn)==null?void 0:C.isEnableProxyAuth)||!1,s=await fetch(`${((l=window.dbn)==null?void 0:l.proxyAuthUrl)||((e=window.dbn)==null?void 0:e.baseUrl)||oV}${E30}`,{method:"POST",body:JSON.stringify({fileName:t,dashboardId:n}),headers:{"Content-Type":"application/json",...a?{}:{"X-Plugin-Token":o||""},...aV()||{},"X-Plugin-Origin":window.location.host}});if(!s.ok)throw new Error("Network response was not ok");const r=await s.blob();try{if(r.type==="application/pdf"){const u=URL.createObjectURL(r),A=document.createElement("a");A.href=u,A.download=`${t}.pdf`,A.click(),URL.revokeObjectURL(u)}else console.error("Unexpected file type:",r.type)}catch{console.error("Unexpected file type:",r.type)}}}),r60=()=>{const[t,n]=P0.useState({isLoading:!1,downloadProgress:!1});return{onDownloadMetrics:async({dashboardName:o,externalDashboardId:a,token:s,isFrontend:r,clientId:C,datasourceId:l,globalFilters:e,metricData:u,workspaceId:A})=>{var d,g,E;const f=((d=window==null?void 0:window.dbn)==null?void 0:d.isEnableProxyAuth)||!1;try{n({downloadProgress:!0,isLoading:!0});const y=await fetch(`${((g=window.dbn)==null?void 0:g.proxyAuthUrl)||((E=window.dbn)==null?void 0:E.baseUrl)||oV}${G30}`,{method:"POST",body:JSON.stringify({externalDashboardId:a,globalFilters:e,metricData:u,datasourceId:l,workspaceId:A}),headers:{"Content-Type":"application/json",...f?{}:{"X-Plugin-Token":s||""},...aV()||{},"X-Plugin-Origin":window.location.host,...r?{"X-Dbn-Secret":C}:{},...r?{"X-Dbn-token":dX()||""}:{}}});if(!y.ok)throw new Error("Network response was not ok");const Q=await y.blob(),R=URL.createObjectURL(Q),D=document.createElement("a");D.href=R,D.download=`${o}.zip`,D.style.display="none",document.body.appendChild(D),n({downloadProgress:!1,isLoading:!1}),BP&&(document!=null&&document.createEvent)||D.click(),URL.revokeObjectURL(R),document.body.removeChild(D)}catch{n({downloadProgress:!1,isLoading:!1}),alert("Error downloading the file. Please try later.")}},downloadState:t}},n60=({dashboardId:t,fileName:n,token:i})=>{const[o,a]=P0.useState(""),[s,r]=P0.useState(!1),[C,l]=P0.useState({isGettingPdf:!1}),{toPDF:e}=t60(n,t);return{toPDF:async()=>{if(l({isGettingPdf:!0}),a(""),r(!1),!i){a(zu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1});return}try{await e(i),r(!0),setTimeout(()=>{r(!1)},2e3),l({isGettingPdf:!1})}catch{a(zu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1})}},isGettingPdf:C==null?void 0:C.isGettingPdf,error:o,isPdfExported:s}},cV={downloadCsv:"_downloadCsv_z5r12_1",downloadCsvWrapper:"_downloadCsvWrapper_z5r12_9",downloadCsvNote:"_downloadCsvNote_z5r12_45",downloadCsvNoteText:"_downloadCsvNoteText_z5r12_59"},UA={label:"_label_lpfkf_1","inputField-container":"_inputField-container_lpfkf_25",upperContainer:"_upperContainer_lpfkf_31",input:"_input_lpfkf_25",supportText:"_supportText_lpfkf_49",error:"_error_lpfkf_55",inputVal:"_inputVal_lpfkf_61",inputContainer:"_inputContainer_lpfkf_67",floatingLabel:"_floatingLabel_lpfkf_81",suffixContainer:"_suffixContainer_lpfkf_89",prefixContainer:"_prefixContainer_lpfkf_95",inlineLabelContainer:"_inlineLabelContainer_lpfkf_101",important:"_important_lpfkf_109"},K9=({type:t="text",register:n,label:i,isDisabled:o,id:a,elementRef:s,error:r,supportingText:C,leftIcon:l,rightIcon:e,addSuffix:u,addPrefix:A,inlineLabel:f,labelVariant:d="static",value:g,isImportant:E,containerClassName:y="",containerStyle:Q,customClassName:R="",isFilter:D,isApplyDashboardColor:O,...k})=>{var J,e2,p2,D2;return h.jsxs("div",{className:`${UA["inputField-container"]} ${R}`,children:[h.jsxs("div",{className:UA.upperContainer,id:`${(e2=(J=i??a)==null?void 0:J.replaceAll(" ","-"))==null?void 0:e2.toLowerCase()}-input`,"data-testid":`${(D2=(p2=i??a)==null?void 0:p2.replaceAll(" ","-"))==null?void 0:D2.toLowerCase()}-input`,children:[i?h.jsxs(h.Fragment,{children:[d==="floating"&&h.jsxs("label",{htmlFor:a,className:`${UA.floatingLabel} ${D?"dbn-selectBox-text":""} ${D&&O?"dbn-selectBox":""}`,children:[i,E?h.jsx("span",{className:UA.important,children:"*"}):null]}),d==="static"&&h.jsx("label",{htmlFor:a,className:`${UA.label} ${D?"dbn-selectBox-text":""} ${D&&O?"dbn-selectBox":""}`,children:h.jsxs(_7,{variant:"input-label",color:"primary",children:[i,E?h.jsx("span",{className:UA.important,children:"*"}):null]})})]}):null,h.jsxs("div",{className:`${UA.inputContainer} ${D&&O?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""} ${y} `,style:Q,children:[f&&h.jsx("div",{className:UA.inlineLabelContainer,children:h.jsx(_7,{variant:"heading-6",children:f})}),A&&h.jsx("div",{className:`${UA.prefixContainer} ${UA.supportText}`,children:A}),l&&h.jsx("div",{className:"dbn-p-2",children:l}),h.jsx("input",{...k,value:g,ref:s,id:a,type:t,className:`${UA.input} ${k.className||""} ${r?UA.error:""} ${g?UA.inputVal:""} ${D&&O?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""}`,...n,disabled:o}),e&&h.jsx("div",{className:"dbn-p-2",children:e}),u&&h.jsx("div",{className:`${UA.suffixContainer} ${UA.supportText}`,children:u})]})]}),C&&h.jsx("div",{className:UA.supportText,children:C}),r&&h.jsx(_7,{variant:"body-text-2",color:"alert",children:r})]})},ig={modal:"_modal_19z4t_1","popup-sm":"_popup-sm_19z4t_9","popup-md":"_popup-md_19z4t_17","popup-lg":"_popup-lg_19z4t_25","popup-xl":"_popup-xl_19z4t_33","popup-xxl":"_popup-xxl_19z4t_41",popup:"_popup_19z4t_9",header:"_header_19z4t_57",subHeadingTitle:"_subHeadingTitle_19z4t_65",headerTitle:"_headerTitle_19z4t_73",content:"_content_19z4t_81",footer:"_footer_19z4t_89"},qu=({children:t,isOpen:n,onClose:i,headerTitle:o,subHeadingTitle:a,customHeader:s,enableFullScreenButton:r,icon:C,zIndex:l,size:e,isRemoveHeader:u,isMobileModal:A,keepMounted:f})=>{const d=P0.useRef(),[g,E]=P0.useState(!1),[y,Q]=P0.useState(!1),[R,D]=P0.useState(!1),O=J=>{J.target.classList.contains(ig.modal)?Q(!0):Q(!1)},k=J=>{J.target.classList.contains(ig.modal)?D(!0):D(!1)};return P0.useEffect(()=>{R&&y&&(D(!1),Q(!1))},[R,y]),h.jsx(kE,{children:n||f?h.jsx("div",{className:`${ig.modal} ${A?"dbn-items-end dbn-py-0":""}`,onMouseDown:k,onMouseUp:O,ref:d,style:{...l?{zIndex:l}:{},...f?{display:n?void 0:"none"}:{}},children:h.jsxs("div",{className:`${ig.popup} ${g?ig.popupFullScreen:""} ${e?ig[`popup-${e}`]:""} ${A?"dbn-my-0 dbn-rounded-b-none dbn-rounded-t-3xl":""}`,onClick:J=>{J.stopPropagation()},children:[u?null:h.jsx("section",{className:ig.header,children:s||h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-items-start dbn-gap-1.5",children:[h.jsxs("div",{className:ig.headerTitle,children:[C,h.jsx(_7,{variant:"heading-3",color:"primary",children:o})]}),a&&h.jsx("div",{className:ig.subHeadingTitle,children:h.jsx(_7,{variant:"body-text-3",color:"sec-text",children:a})})]}),h.jsx(e8,{"data-testid":"close-modal",variant:"tertiary",type:"button",onClick:i,leftIcon:h.jsx(h8,{name:"cross",size:"small"}),style:{padding:"0",height:"20px"},className:"dbn-p-1.5"})]})}),h.jsx("section",{className:ig.content,children:t})]})}):null})},Ed=({children:t,className:n})=>h.jsx("section",{className:`${ig.footer} ${n}`,children:t}),i60=t=>{if(!t.length)return!1;const n=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;return t.every(i=>n.test(i))},wX=({onCloseModal:t,sharingSettingsId:n,metricItem:i,workspaceId:o})=>{const{data:a}=_70(o),[s,r]=P0.useState(!1),[C,l]=P0.useState(""),{mutate:e}=v70(),{handleSubmit:u,register:A,setValue:f,control:d,formState:{errors:g}}=Vb(),E=P0.useMemo(()=>{const Q=a;return{expireTimeInMin:(Q==null?void 0:Q.expireTimeInMin)||30,isEnable:Q==null?void 0:Q.isEnable}},[a]);return{onSumbitSendCsvUrl:({values:Q,query:R})=>{r(!0),l("");const D=E.expireTimeInMin||30,O=new Date(Date.now()+D*60*1e3),k=R,J=Q.emails;if(!i60(J)){r(!1),l("please enter valid email");return}if(!n){r(!1),l("no sharing settings are found");return}e({configurations:{externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,name:i==null?void 0:i.name},emails:J,expireCsvFileAt:O,expireUrlIn:D*60,externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,query:k,sharingSettingsId:n,subject:Q.subject},{onSuccess(e2){e2?(r(!1),l(""),t==null||t(!1)):(r(!1),l(zu))},onError(){r(!1),l(zu)}})},isDisableDownloadSettings:!n||!E.isEnable,downloadCsvError:C,handleSubmit:u,isLoading:s,register:A,control:d,setValue:f,errors:g}},Dy={required:"Required"};({...Dy},{...Dy}),{...Dy};const fV={"tag-text":"_tag-text_m1urh_4",inputFieldContainer:"_inputFieldContainer_m1urh_11","tag-container":"_tag-container_m1urh_15",important:"_important_m1urh_23"},QX=({id:t,control:n,placeholder:i,name:o,label:a,onChangeTags:s,onChange:r,defaultTagValue:C,isImportant:l,isDisabled:e,width:u="300px",regexStr:A,tagType:f,tagError:d,setTagError:g,register:E,error:y})=>{const[Q,R]=P0.useState(),[D,O]=P0.useState(""),k=Q2=>{R(Q==null?void 0:Q.filter(i2=>i2!==Q2)),s==null||s(Q==null?void 0:Q.filter(i2=>i2!==Q2))},J=()=>{const Q2=D.split(",").map(R2=>R2.trim()).filter(Boolean),i2=new Set;for(const R2 of Q2){if(i2.has(R2)){g==null||g(`Duplicate ${(f==null?void 0:f.toLocaleLowerCase())||"value"} in input: "${R2}"`);return}if(Q!=null&&Q.includes(R2)){g==null||g(`"${R2}" already added`);return}if(A&&!A.test(R2)){g==null||g(`Invalid ${(f==null?void 0:f.toLocaleLowerCase())||"input"}: "${R2}"`);return}i2.add(R2)}const N2=[...Q||[],...Q2];R(N2),s==null||s(N2),O(""),g==null||g("")},e2=Q2=>{if(Q2.key==="Enter"||Q2.key==="Tab")Q2.preventDefault(),J();else if(Q2.key==="Backspace"&&(D==null?void 0:D.length)===0){R(N2=>(N2==null||N2.pop(),[...N2||[]])),Q==null||Q.pop();const i2=[...Q||[]];s==null||s(i2)}},p2=()=>{J()};P0.useEffect(()=>{C&&Array.isArray(C)?R(C):R([])},[C]);const D2=Q2=>{const i2=Q2.target.parentElement;i2.scrollLeft=i2.scrollWidth,O(Q2.target.value),r==null||r(Q2.target.value)};return P0.useEffect(()=>{g==null||g("")},[D]),h.jsx(JE,{name:o||"tags",control:n,defaultValue:"",render:({field:Q2})=>{var R2,M2,Z2,Y2;const{ref:i2,...N2}=Q2;return h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[a?h.jsxs(_7,{variant:"input-label",color:"primary",children:[a,l?h.jsx("span",{className:fV.important,children:"*"}):null]}):null,h.jsxs("div",{className:fV.inputFieldContainer,style:{width:u},id:`${(M2=(R2=a??t)==null?void 0:R2.replaceAll(" ","-"))==null?void 0:M2.toLowerCase()}-input`,"data-testid":`${(Y2=(Z2=a??t)==null?void 0:Z2.replaceAll(" ","-"))==null?void 0:Y2.toLowerCase()}-input`,children:[Q!=null&&Q.length?h.jsx("div",{className:fV["tag-container"],children:Q==null?void 0:Q.map(f0=>h.jsx(e8,{variant:"popover",type:"button",onClick:()=>k(f0),className:"dbn-flex dbn-font-semibold dbn-gap-2 dbn-px-2 dbn-py-1 dbn-bg-gray dbn-rounded",rightIcon:h.jsx(h8,{name:"cross",size:"xxs"}),children:h.jsx("span",{className:fV["tag-text"],children:f0})},f0))}):null,h.jsx("input",{...N2,type:"text",value:D,onChange:D2,onKeyDown:e2,placeholder:Q!=null&&Q.length?"":i,disabled:e,className:`dbn-outline-none dbn-border-none dbn-text-sm ${Q!=null&&Q.length?"dbn-max-w-[400px]":"dbn-w-full"} ${{...E}}`,onBlur:p2})]})]}),d&&h.jsx(Tl,{text:d,variant:"error"}),!d&&y&&h.jsx(_7,{variant:"body-text-2",color:"alert",children:y})]})}})};T9.memo(QX);const dc={container:"_container_10845_1",tooltip:"_tooltip_10845_9",subTooltip:"_subTooltip_10845_17",textPadding:"_textPadding_10845_25",subPadding:"_subPadding_10845_33",heading:"_heading_10845_41",tooltipMetric:"_tooltipMetric_10845_87",active:"_active_10845_115",top:"_top_10845_125",bottom:"_bottom_10845_143",left:"_left_10845_161",right:"_right_10845_179","left-top-end":"_left-top-end_10845_197","right-top-end":"_right-top-end_10845_215","left-bottom-end":"_left-bottom-end_10845_233","right-bottom-end":"_right-bottom-end_10845_251","top-left":"_top-left_10845_269","top-right":"_top-right_10845_287","bottom-left":"_bottom-left_10845_305","bottom-right":"_bottom-right_10845_323","left-top":"_left-top_10845_197","left-bottom":"_left-bottom_10845_233","right-top":"_right-top_10845_215","right-bottom":"_right-bottom_10845_251",addedLink:"_addedLink_10845_413",subText:"_subText_10845_421"};/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */const{entries:qA2,setPrototypeOf:$A2,isFrozen:o60,getPrototypeOf:a60,getOwnPropertyDescriptor:s60}=Object;let{freeze:gc,seal:pd,create:ec2}=Object,{apply:MX,construct:TX}=typeof Reflect<"u"&&Reflect;gc||(gc=function(n){return n}),pd||(pd=function(n){return n}),MX||(MX=function(n,i,o){return n.apply(i,o)}),TX||(TX=function(n,i){return new n(...i)});const dV=Ec(Array.prototype.forEach),C60=Ec(Array.prototype.lastIndexOf),tc2=Ec(Array.prototype.pop),nT=Ec(Array.prototype.push),l60=Ec(Array.prototype.splice),gV=Ec(String.prototype.toLowerCase),xX=Ec(String.prototype.toString),rc2=Ec(String.prototype.match),iT=Ec(String.prototype.replace),u60=Ec(String.prototype.indexOf),A60=Ec(String.prototype.trim),og=Ec(Object.prototype.hasOwnProperty),hc=Ec(RegExp.prototype.test),oT=c60(TypeError);function Ec(t){return function(n){for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return MX(t,n,o)}}function c60(t){return function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return TX(t,i)}}function uC(t,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gV;$A2&&$A2(t,null);let o=n.length;for(;o--;){let a=n[o];if(typeof a=="string"){const s=i(a);s!==a&&(o60(n)||(n[o]=s),a=s)}t[a]=!0}return t}function f60(t){for(let n=0;n<t.length;n++)og(t,n)||(t[n]=null);return t}function xm(t){const n=ec2(null);for(const[i,o]of qA2(t))og(t,i)&&(Array.isArray(o)?n[i]=f60(o):o&&typeof o=="object"&&o.constructor===Object?n[i]=xm(o):n[i]=o);return n}function aT(t,n){for(;t!==null;){const o=s60(t,n);if(o){if(o.get)return Ec(o.get);if(typeof o.value=="function")return Ec(o.value)}t=a60(t)}function i(){return null}return i}const nc2=gc(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),RX=gc(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),HX=gc(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),d60=gc(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),DX=gc(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),g60=gc(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ic2=gc(["#text"]),oc2=gc(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),NX=gc(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ac2=gc(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),hV=gc(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),h60=pd(/\{\{[\w\W]*|[\w\W]*\}\}/gm),E60=pd(/<%[\w\W]*|[\w\W]*%>/gm),p60=pd(/\$\{[\w\W]*/gm),v60=pd(/^data-[\-\w.\u00B7-\uFFFF]+$/),I60=pd(/^aria-[\-\w]+$/),sc2=pd(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),m60=pd(/^(?:\w+script|data):/i),b60=pd(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cc2=pd(/^html$/i),B60=pd(/^[a-z][.\w]*(-[.\w]+)+$/i);var lc2=Object.freeze({__proto__:null,ARIA_ATTR:I60,ATTR_WHITESPACE:b60,CUSTOM_ELEMENT:B60,DATA_ATTR:v60,DOCTYPE_NAME:Cc2,ERB_EXPR:E60,IS_ALLOWED_URI:sc2,IS_SCRIPT_OR_DATA:m60,MUSTACHE_EXPR:h60,TMPLIT_EXPR:p60});const sT={element:1,text:3,progressingInstruction:7,comment:8,document:9},y60=function(){return typeof window>"u"?null:window},L60=function(n,i){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let o=null;const a="data-tt-policy-suffix";i&&i.hasAttribute(a)&&(o=i.getAttribute(a));const s="dompurify"+(o?"#"+o:"");try{return n.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},uc2=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ac2(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y60();const n=k3=>Ac2(k3);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==sT.document||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,a=o.currentScript,{DocumentFragment:s,HTMLTemplateElement:r,Node:C,Element:l,NodeFilter:e,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:A,DOMParser:f,trustedTypes:d}=t,g=l.prototype,E=aT(g,"cloneNode"),y=aT(g,"remove"),Q=aT(g,"nextSibling"),R=aT(g,"childNodes"),D=aT(g,"parentNode");if(typeof r=="function"){const k3=i.createElement("template");k3.content&&k3.content.ownerDocument&&(i=k3.content.ownerDocument)}let O,k="";const{implementation:J,createNodeIterator:e2,createDocumentFragment:p2,getElementsByTagName:D2}=i,{importNode:Q2}=o;let i2=uc2();n.isSupported=typeof qA2=="function"&&typeof D=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:N2,ERB_EXPR:R2,TMPLIT_EXPR:M2,DATA_ATTR:Z2,ARIA_ATTR:Y2,IS_SCRIPT_OR_DATA:f0,ATTR_WHITESPACE:E0,CUSTOM_ELEMENT:M0}=lc2;let{IS_ALLOWED_URI:x0}=lc2,z2=null;const t1=uC({},[...nc2,...RX,...HX,...DX,...ic2]);let p0=null;const U0=uC({},[...oc2,...NX,...ac2,...hV]);let G0=Object.seal(ec2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),X2=null,L3=null,O1=!0,C3=!0,W3=!1,d7=!0,y7=!1,Y7=!0,I6=!1,z7=!1,X6=!1,k6=!1,z3=!1,t0=!1,j3=!0,K7=!1;const G7="user-content-";let c6=!0,u6=!1,L6={},v1=null;const A3=uC({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let c7=null;const X3=uC({},["audio","video","img","source","image","track"]);let Y3=null;const n7=uC({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),V7="http://www.w3.org/1998/Math/MathML",P7="http://www.w3.org/2000/svg",D7="http://www.w3.org/1999/xhtml";let _6=D7,c8=!1,x8=null;const C8=uC({},[V7,P7,D7],xX);let K8=uC({},["mi","mo","mn","ms","mtext"]),l8=uC({},["annotation-xml"]);const I9=uC({},["title","style","font","a","script"]);let M8=null;const d9=["application/xhtml+xml","text/html"],b8="text/html";let g5=null,N5=null;const h5=i.createElement("form"),d4=function(E3){return E3 instanceof RegExp||E3 instanceof Function},b5=function(){let E3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(N5&&N5===E3)){if((!E3||typeof E3!="object")&&(E3={}),E3=xm(E3),M8=d9.indexOf(E3.PARSER_MEDIA_TYPE)===-1?b8:E3.PARSER_MEDIA_TYPE,g5=M8==="application/xhtml+xml"?xX:gV,z2=og(E3,"ALLOWED_TAGS")?uC({},E3.ALLOWED_TAGS,g5):t1,p0=og(E3,"ALLOWED_ATTR")?uC({},E3.ALLOWED_ATTR,g5):U0,x8=og(E3,"ALLOWED_NAMESPACES")?uC({},E3.ALLOWED_NAMESPACES,xX):C8,Y3=og(E3,"ADD_URI_SAFE_ATTR")?uC(xm(n7),E3.ADD_URI_SAFE_ATTR,g5):n7,c7=og(E3,"ADD_DATA_URI_TAGS")?uC(xm(X3),E3.ADD_DATA_URI_TAGS,g5):X3,v1=og(E3,"FORBID_CONTENTS")?uC({},E3.FORBID_CONTENTS,g5):A3,X2=og(E3,"FORBID_TAGS")?uC({},E3.FORBID_TAGS,g5):{},L3=og(E3,"FORBID_ATTR")?uC({},E3.FORBID_ATTR,g5):{},L6=og(E3,"USE_PROFILES")?E3.USE_PROFILES:!1,O1=E3.ALLOW_ARIA_ATTR!==!1,C3=E3.ALLOW_DATA_ATTR!==!1,W3=E3.ALLOW_UNKNOWN_PROTOCOLS||!1,d7=E3.ALLOW_SELF_CLOSE_IN_ATTR!==!1,y7=E3.SAFE_FOR_TEMPLATES||!1,Y7=E3.SAFE_FOR_XML!==!1,I6=E3.WHOLE_DOCUMENT||!1,k6=E3.RETURN_DOM||!1,z3=E3.RETURN_DOM_FRAGMENT||!1,t0=E3.RETURN_TRUSTED_TYPE||!1,X6=E3.FORCE_BODY||!1,j3=E3.SANITIZE_DOM!==!1,K7=E3.SANITIZE_NAMED_PROPS||!1,c6=E3.KEEP_CONTENT!==!1,u6=E3.IN_PLACE||!1,x0=E3.ALLOWED_URI_REGEXP||sc2,_6=E3.NAMESPACE||D7,K8=E3.MATHML_TEXT_INTEGRATION_POINTS||K8,l8=E3.HTML_INTEGRATION_POINTS||l8,G0=E3.CUSTOM_ELEMENT_HANDLING||{},E3.CUSTOM_ELEMENT_HANDLING&&d4(E3.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(G0.tagNameCheck=E3.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E3.CUSTOM_ELEMENT_HANDLING&&d4(E3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(G0.attributeNameCheck=E3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E3.CUSTOM_ELEMENT_HANDLING&&typeof E3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(G0.allowCustomizedBuiltInElements=E3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),y7&&(C3=!1),z3&&(k6=!0),L6&&(z2=uC({},ic2),p0=[],L6.html===!0&&(uC(z2,nc2),uC(p0,oc2)),L6.svg===!0&&(uC(z2,RX),uC(p0,NX),uC(p0,hV)),L6.svgFilters===!0&&(uC(z2,HX),uC(p0,NX),uC(p0,hV)),L6.mathMl===!0&&(uC(z2,DX),uC(p0,ac2),uC(p0,hV))),E3.ADD_TAGS&&(z2===t1&&(z2=xm(z2)),uC(z2,E3.ADD_TAGS,g5)),E3.ADD_ATTR&&(p0===U0&&(p0=xm(p0)),uC(p0,E3.ADD_ATTR,g5)),E3.ADD_URI_SAFE_ATTR&&uC(Y3,E3.ADD_URI_SAFE_ATTR,g5),E3.FORBID_CONTENTS&&(v1===A3&&(v1=xm(v1)),uC(v1,E3.FORBID_CONTENTS,g5)),c6&&(z2["#text"]=!0),I6&&uC(z2,["html","head","body"]),z2.table&&(uC(z2,["tbody"]),delete X2.tbody),E3.TRUSTED_TYPES_POLICY){if(typeof E3.TRUSTED_TYPES_POLICY.createHTML!="function")throw oT('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E3.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw oT('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');O=E3.TRUSTED_TYPES_POLICY,k=O.createHTML("")}else O===void 0&&(O=L60(d,a)),O!==null&&typeof k=="string"&&(k=O.createHTML(""));gc&&gc(E3),N5=E3}},M1=uC({},[...RX,...HX,...d60]),o9=uC({},[...DX,...g60]),O9=function(E3){let Q7=D(E3);(!Q7||!Q7.tagName)&&(Q7={namespaceURI:_6,tagName:"template"});const E7=gV(E3.tagName),w6=gV(Q7.tagName);return x8[E3.namespaceURI]?E3.namespaceURI===P7?Q7.namespaceURI===D7?E7==="svg":Q7.namespaceURI===V7?E7==="svg"&&(w6==="annotation-xml"||K8[w6]):!!M1[E7]:E3.namespaceURI===V7?Q7.namespaceURI===D7?E7==="math":Q7.namespaceURI===P7?E7==="math"&&l8[w6]:!!o9[E7]:E3.namespaceURI===D7?Q7.namespaceURI===P7&&!l8[w6]||Q7.namespaceURI===V7&&!K8[w6]?!1:!o9[E7]&&(I9[E7]||!M1[E7]):!!(M8==="application/xhtml+xml"&&x8[E3.namespaceURI]):!1},s5=function(E3){nT(n.removed,{element:E3});try{D(E3).removeChild(E3)}catch{y(E3)}},u5=function(E3,Q7){try{nT(n.removed,{attribute:Q7.getAttributeNode(E3),from:Q7})}catch{nT(n.removed,{attribute:null,from:Q7})}if(Q7.removeAttribute(E3),E3==="is")if(k6||z3)try{s5(Q7)}catch{}else try{Q7.setAttribute(E3,"")}catch{}},B5=function(E3){let Q7=null,E7=null;if(X6)E3="<remove></remove>"+E3;else{const o6=rc2(E3,/^[\r\n\t ]+/);E7=o6&&o6[0]}M8==="application/xhtml+xml"&&_6===D7&&(E3='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E3+"</body></html>");const w6=O?O.createHTML(E3):E3;if(_6===D7)try{Q7=new f().parseFromString(w6,M8)}catch{}if(!Q7||!Q7.documentElement){Q7=J.createDocument(_6,"template",null);try{Q7.documentElement.innerHTML=c8?k:w6}catch{}}const n6=Q7.body||Q7.documentElement;return E3&&E7&&n6.insertBefore(i.createTextNode(E7),n6.childNodes[0]||null),_6===D7?D2.call(Q7,I6?"html":"body")[0]:I6?Q7.documentElement:n6},U9=function(E3){return e2.call(E3.ownerDocument||E3,E3,e.SHOW_ELEMENT|e.SHOW_COMMENT|e.SHOW_TEXT|e.SHOW_PROCESSING_INSTRUCTION|e.SHOW_CDATA_SECTION,null)},c3=function(E3){return E3 instanceof A&&(typeof E3.nodeName!="string"||typeof E3.textContent!="string"||typeof E3.removeChild!="function"||!(E3.attributes instanceof u)||typeof E3.removeAttribute!="function"||typeof E3.setAttribute!="function"||typeof E3.namespaceURI!="string"||typeof E3.insertBefore!="function"||typeof E3.hasChildNodes!="function")},W8=function(E3){return typeof C=="function"&&E3 instanceof C};function e7(k3,E3,Q7){dV(k3,E7=>{E7.call(n,E3,Q7,N5)})}const Q6=function(E3){let Q7=null;if(e7(i2.beforeSanitizeElements,E3,null),c3(E3))return s5(E3),!0;const E7=g5(E3.nodeName);if(e7(i2.uponSanitizeElement,E3,{tagName:E7,allowedTags:z2}),E3.hasChildNodes()&&!W8(E3.firstElementChild)&&hc(/<[/\w]/g,E3.innerHTML)&&hc(/<[/\w]/g,E3.textContent)||E3.nodeType===sT.progressingInstruction||Y7&&E3.nodeType===sT.comment&&hc(/<[/\w]/g,E3.data))return s5(E3),!0;if(!z2[E7]||X2[E7]){if(!X2[E7]&&f6(E7)&&(G0.tagNameCheck instanceof RegExp&&hc(G0.tagNameCheck,E7)||G0.tagNameCheck instanceof Function&&G0.tagNameCheck(E7)))return!1;if(c6&&!v1[E7]){const w6=D(E3)||E3.parentNode,n6=R(E3)||E3.childNodes;if(n6&&w6){const o6=n6.length;for(let g8=o6-1;g8>=0;--g8){const J3=E(n6[g8],!0);J3.__removalCount=(E3.__removalCount||0)+1,w6.insertBefore(J3,Q(E3))}}}return s5(E3),!0}return E3 instanceof l&&!O9(E3)||(E7==="noscript"||E7==="noembed"||E7==="noframes")&&hc(/<\/no(script|embed|frames)/i,E3.innerHTML)?(s5(E3),!0):(y7&&E3.nodeType===sT.text&&(Q7=E3.textContent,dV([N2,R2,M2],w6=>{Q7=iT(Q7,w6," ")}),E3.textContent!==Q7&&(nT(n.removed,{element:E3.cloneNode()}),E3.textContent=Q7)),e7(i2.afterSanitizeElements,E3,null),!1)},P6=function(E3,Q7,E7){if(j3&&(Q7==="id"||Q7==="name")&&(E7 in i||E7 in h5))return!1;if(!(C3&&!L3[Q7]&&hc(Z2,Q7))){if(!(O1&&hc(Y2,Q7))){if(!p0[Q7]||L3[Q7]){if(!(f6(E3)&&(G0.tagNameCheck instanceof RegExp&&hc(G0.tagNameCheck,E3)||G0.tagNameCheck instanceof Function&&G0.tagNameCheck(E3))&&(G0.attributeNameCheck instanceof RegExp&&hc(G0.attributeNameCheck,Q7)||G0.attributeNameCheck instanceof Function&&G0.attributeNameCheck(Q7))||Q7==="is"&&G0.allowCustomizedBuiltInElements&&(G0.tagNameCheck instanceof RegExp&&hc(G0.tagNameCheck,E7)||G0.tagNameCheck instanceof Function&&G0.tagNameCheck(E7))))return!1}else if(!Y3[Q7]){if(!hc(x0,iT(E7,E0,""))){if(!((Q7==="src"||Q7==="xlink:href"||Q7==="href")&&E3!=="script"&&u60(E7,"data:")===0&&c7[E3])){if(!(W3&&!hc(f0,iT(E7,E0,"")))){if(E7)return!1}}}}}}return!0},f6=function(E3){return E3!=="annotation-xml"&&rc2(E3,M0)},x7=function(E3){e7(i2.beforeSanitizeAttributes,E3,null);const{attributes:Q7}=E3;if(!Q7||c3(E3))return;const E7={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:p0,forceKeepAttr:void 0};let w6=Q7.length;for(;w6--;){const n6=Q7[w6],{name:o6,namespaceURI:g8,value:J3}=n6,A8=g5(o6);let J8=o6==="value"?J3:A60(J3);if(E7.attrName=A8,E7.attrValue=J8,E7.keepAttr=!0,E7.forceKeepAttr=void 0,e7(i2.uponSanitizeAttribute,E3,E7),J8=E7.attrValue,K7&&(A8==="id"||A8==="name")&&(u5(o6,E3),J8=G7+J8),Y7&&hc(/((--!?|])>)|<\/(style|title)/i,J8)){u5(o6,E3);continue}if(E7.forceKeepAttr||(u5(o6,E3),!E7.keepAttr))continue;if(!d7&&hc(/\/>/i,J8)){u5(o6,E3);continue}y7&&dV([N2,R2,M2],a9=>{J8=iT(J8,a9," ")});const t8=g5(E3.nodeName);if(P6(t8,A8,J8)){if(O&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!g8)switch(d.getAttributeType(t8,A8)){case"TrustedHTML":{J8=O.createHTML(J8);break}case"TrustedScriptURL":{J8=O.createScriptURL(J8);break}}try{g8?E3.setAttributeNS(g8,o6,J8):E3.setAttribute(o6,J8),c3(E3)?s5(E3):tc2(n.removed)}catch{}}}e7(i2.afterSanitizeAttributes,E3,null)},s7=function k3(E3){let Q7=null;const E7=U9(E3);for(e7(i2.beforeSanitizeShadowDOM,E3,null);Q7=E7.nextNode();)e7(i2.uponSanitizeShadowNode,Q7,null),Q6(Q7),x7(Q7),Q7.content instanceof s&&k3(Q7.content);e7(i2.afterSanitizeShadowDOM,E3,null)};return n.sanitize=function(k3){let E3=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Q7=null,E7=null,w6=null,n6=null;if(c8=!k3,c8&&(k3="<!-->"),typeof k3!="string"&&!W8(k3))if(typeof k3.toString=="function"){if(k3=k3.toString(),typeof k3!="string")throw oT("dirty is not a string, aborting")}else throw oT("toString is not a function");if(!n.isSupported)return k3;if(z7||b5(E3),n.removed=[],typeof k3=="string"&&(u6=!1),u6){if(k3.nodeName){const J3=g5(k3.nodeName);if(!z2[J3]||X2[J3])throw oT("root node is forbidden and cannot be sanitized in-place")}}else if(k3 instanceof C)Q7=B5("<!---->"),E7=Q7.ownerDocument.importNode(k3,!0),E7.nodeType===sT.element&&E7.nodeName==="BODY"||E7.nodeName==="HTML"?Q7=E7:Q7.appendChild(E7);else{if(!k6&&!y7&&!I6&&k3.indexOf("<")===-1)return O&&t0?O.createHTML(k3):k3;if(Q7=B5(k3),!Q7)return k6?null:t0?k:""}Q7&&X6&&s5(Q7.firstChild);const o6=U9(u6?k3:Q7);for(;w6=o6.nextNode();)Q6(w6),x7(w6),w6.content instanceof s&&s7(w6.content);if(u6)return k3;if(k6){if(z3)for(n6=p2.call(Q7.ownerDocument);Q7.firstChild;)n6.appendChild(Q7.firstChild);else n6=Q7;return(p0.shadowroot||p0.shadowrootmode)&&(n6=Q2.call(o,n6,!0)),n6}let g8=I6?Q7.outerHTML:Q7.innerHTML;return I6&&z2["!doctype"]&&Q7.ownerDocument&&Q7.ownerDocument.doctype&&Q7.ownerDocument.doctype.name&&hc(Cc2,Q7.ownerDocument.doctype.name)&&(g8="<!DOCTYPE "+Q7.ownerDocument.doctype.name+`>
|
|
598
598
|
`+g8),y7&&dV([N2,R2,M2],J3=>{g8=iT(g8,J3," ")}),O&&t0?O.createHTML(g8):g8},n.setConfig=function(){let k3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b5(k3),z7=!0},n.clearConfig=function(){N5=null,z7=!1},n.isValidAttribute=function(k3,E3,Q7){N5||b5({});const E7=g5(k3),w6=g5(E3);return P6(E7,w6,Q7)},n.addHook=function(k3,E3){typeof E3=="function"&&nT(i2[k3],E3)},n.removeHook=function(k3,E3){if(E3!==void 0){const Q7=C60(i2[k3],E3);return Q7===-1?void 0:l60(i2[k3],Q7,1)[0]}return tc2(i2[k3])},n.removeHooks=function(k3){i2[k3]=[]},n.removeAllHooks=function(){i2=uc2()},n}var cc2=Ac2();const EV=t=>cc2.sanitize(t,{ALLOWED_TAGS:["p","div","span","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","img","b","i"],ALLOWED_ATTR:["class","id","src","alt"],ADD_ATTR:["target"],FORBID_ATTR:["on*"],FORBID_TAGS:["script","iframe","form","object","embed"],ALLOW_DATA_ATTR:!1,ADD_URI_SAFE_ATTR:["src"],ALLOW_UNKNOWN_PROTOCOLS:!1,RETURN_DOM_FRAGMENT:!1,RETURN_TRUSTED_TYPE:!0,USE_PROFILES:{html:!0}}),ha=({children:t,text:n,bulletText:i,className:o="",position:a="bottom",tooltipClass:s="",isSingleLineTxt:r=!0,showTooltip:C=!0,isAllowPosChange:l=!1})=>{const e=P0.useRef(null),[u,A]=P0.useState(a),f=312,d=40,g=P0.useCallback(()=>{if(!e.current||!l)return;const y=e.current.getBoundingClientRect(),Q=window.innerWidth,R=window.innerHeight,D=f/2;let O=y.right+f>Q,k=y.left-f<0;(a.startsWith("top")||a.startsWith("bottom"))&&(O=y.left+D>Q,k=y.right-D<0);const J=y.top-d<0,e2=y.bottom+d>R,D2={top:J?"bottom":O?"top-right":k?"top-left":"top",bottom:e2?"top":O?"bottom-right":k?"bottom-left":"bottom",left:k?"right":"left",right:O?"left":"right","top-left":J&&k?"bottom-right":J?"bottom-left":k?"top-right":"top-left","top-right":J&&O?"bottom-left":J?"bottom-right":O?"top-left":"top-right","bottom-left":e2&&k?"top-right":e2?"top-left":k?"bottom-right":"bottom-left","bottom-right":e2&&O?"top-left":e2?"top-right":O?"bottom-left":"bottom-right","left-top-end":k&&J?"right-bottom-end":k?"right-top-end":J?"left-bottom-end":"left-top-end","left-bottom-end":k&&e2?"right-top-end":k?"right-bottom-end":e2?"left-top-end":"left-bottom-end","right-top-end":O&&J?"left-bottom-end":O?"left-top-end":J?"right-bottom-end":"right-top-end","right-bottom-end":O&&e2?"left-top-end":O?"left-bottom-end":e2?"right-top-end":"right-bottom-end"}[a]||a;D2!==u&&A(D2)},[a,u,l]);P0.useEffect(()=>{if(!C||!l)return;g(),window.addEventListener("resize",g),window.addEventListener("scroll",g);const y=e.current;return y&&y.addEventListener("mouseenter",g),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g),y&&y.removeEventListener("mouseenter",g)}},[C,l,g]);const E=(n||i)&&C;return h.jsxs("div",{ref:e,className:`${dc.container} ${o}`,children:[t,E&&h.jsxs("span",{className:`${dc.tooltip} ${s} ${dc[u]} ${r?"dbn-p-3":"dbn-p-4"} dbn-w-max`,style:{maxWidth:`${f}px`},children:[n&&h.jsx(_7,{variant:"body-text-2",color:"white",children:n}),i&&h.jsx("ul",{className:"dbn-w-full",children:i.map((y,Q)=>h.jsxs("li",{className:"dbn-flex dbn-gap-2",children:[h.jsx(_7,{variant:"body-text-2",color:"white",children:"•"}),h.jsx(_7,{variant:"body-text-2",color:"white",children:y})]},Q))})]})]})},fc2=({children:t,text:n,subText:i,className:o,position:a="bottom",tooltipClass:s="",headingIcon:r})=>h.jsx(h.Fragment,{children:h.jsxs("div",{className:`${dc.container} ${o}`,children:[t,!n&&!i?null:h.jsx("span",{className:`${dc.subTooltip} ${s} ${dc[a]} ${i?dc.subPadding:dc.textPadding}`,style:{maxWidth:"246px"},children:h.jsxs("span",{className:"dbn-flex dbn-flex-col dbn-gap-2 ",children:[n?h.jsxs("span",{className:dc.heading,children:[r?h.jsx(h8,{name:r,color:"white"}):null," ",h.jsx(_7,{variant:"sec-heading-4",color:"white",children:n})]},n):null,i?h.jsx("span",{className:dc.subText,children:i},i):null]})})]})}),yf=({children:t,className:n,iconConfig:i,position:o,tooltipClass:a,text:s,isSingleLineTxt:r})=>h.jsx(ha,{className:n,position:o,tooltipClass:`${a} dbn-w-max`,text:s,isSingleLineTxt:r,children:h.jsx(h8,{name:"info",size:i==null?void 0:i.size,color:i==null?void 0:i.color})}),dc2=({title:t,html:n,className:i,position:o="right-top",setHoverLongDesc:a})=>{const[s,r]=P0.useState(!1),C=P0.useRef(null);return P0.useEffect(()=>{const l=e=>{C.current&&!C.current.contains(e.target)&&(r(!1),a==null||a(!1))};return s&&document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[s,a]),h.jsxs("div",{ref:C,"data-testid":`longDesc-${t==null?void 0:t.toLowerCase().replaceAll(" ","-")}`,className:`${dc.container} ${s?dc.active:""}`,onMouseOver:()=>!s&&(a==null?void 0:a(!0)),onMouseOut:()=>!s&&(a==null?void 0:a(!1)),onClick:l=>{l.stopPropagation(),r(!0),a==null||a(!0)},children:[h.jsx(h8,{name:"info",size:"xs"}),h.jsx("div",{className:`${dc.tooltipMetric} ${dc[o]} ${i} dbn-longDesc`,children:h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[h.jsx("div",{className:"dbn-mx-1 dbn-text-sm dbn-text-left",children:h.jsx(_7,{variant:"sec-heading-4",color:"white",children:t})}),h.jsx("div",{className:`${dc.addedLink} dbn-p-1`,dangerouslySetInnerHTML:{__html:EV(n||"")}})]})})]})},pV=({onCloseModal:t,isShowRawCsvModal:n,metricItem:i,query:o,sharingSettingsId:a,workspaceId:s})=>{const{downloadCsvError:r,handleSubmit:C,isLoading:l,onSumbitSendCsvUrl:e,register:u,control:A,setValue:f,isDisableDownloadSettings:d,errors:g}=wX({onCloseModal:t,metricItem:i,sharingSettingsId:a,workspaceId:s}),E=()=>{var y;return h.jsx(h.Fragment,{children:h.jsxs("form",{onSubmit:C(Q=>e({values:Q,query:o})),children:[h.jsxs("div",{className:cV.downloadCsvWrapper,children:[h.jsx(K9,{type:"subject",label:"Subject",placeholder:"enter a subject",register:u("subject",Dy),defaultValue:i==null?void 0:i.name,error:(y=g.subject)==null?void 0:y.message,isImportant:!0}),h.jsxs("div",{className:"dbn-w-full dbn-flex dbn-gap-1 dbn-flex-col",children:[h.jsxs("div",{className:"dbn-w-full dbn-flex dbn-gap-2",children:[h.jsxs(_7,{variant:"input-label",children:["Send to ",h.jsx("span",{className:"dbn-text-alert",children:"*"})]}),h.jsx(yf,{text:"Enter multiple email addresses separated by enter",iconConfig:{size:"xs",color:"primary-dark"},isSingleLineTxt:!1})]}),h.jsx(QX,{control:A,type:"text",label:"",placeholder:"Enter email addresses",onChangeTags:Q=>f("emails",Q),width:"100%",onChange:Q=>f("emails",[Q.trim()])})]}),r&&h.jsx(aR,{message:r}),h.jsx("div",{className:cV.downloadCsvNote,children:h.jsx("div",{className:cV.downloadCsvNoteText,children:h.jsxs(_7,{variant:"body-text-2",children:[h.jsx("b",{children:"Note:"})," You will shortly receive a mail with CSV download URL to the above email id(s), once you click on Submit"]})})})]}),h.jsxs(Ed,{children:[h.jsx(e8,{variant:"tab",type:"button",onClick:()=>t(!1),isDisabled:l,children:"Cancel"}),h.jsx(e8,{variant:"primary",type:"submit",isDisabled:l||d,children:"Submit"})]})]})})};return h.jsx(qu,{isOpen:n,onClose:()=>t(!1),headerTitle:"Download Raw CSV",zIndex:99999999999,children:h.jsx("div",{className:cV.downloadCsv,children:h.jsx(E,{})})})},w60=T9.memo(pV),Q60=({token:t,metricId:n,disableMetricCardBorder:i,noDataImg:o,hideMetricCardShadow:a,isEnableUnderlyingData:s,chartAppearance:r,hideDatePickerOptions:C,appearanceOptions:l,dropdownTheme:e,underlyingTheme:u,adminColors:A,chartColors:f,optionsIcon:d,disableFullscreen:g,chartRendererType:E,metricFilterOptions:y,enableDownloadCsv:Q,enableMultiMetricFilters:R,metricFilterPosition:D,enableEmailCsv:O,isDisableCardTitle:k,disableDownloadPng:J,onMinimize:e2,isHideChartSettings:p2,isHideTablePreview:D2,dataMartRelationships:Q2,isEnableCumulative:i2,isEnableDynamic:N2,isEnableStack:R2,metricCardColor:M2,language:Z2,translationDictionary:Y2,globalFilters:f0,calendarType:E0,isDisableClick:M0,disableDownloadDataNoFilters:x0=!1,disableDownloadUnderlyingDataNoFilters:z2=!1})=>{var j3;const[t1,p0]=P0.useState([]),[U0,G0]=P0.useState({isShow:!1}),[X2,L3]=P0.useState({show:!1,filterValues:void 0}),{externalMetric:O1,rlsSettings:C3,sharingSettingsId:W3,companyId:d7,clientId:y7,tenancyLevel:Y7,workspaceId:I6,clientColumnType:z7,isEnableMetricSummary:X6,isAllClient:k6,appFilters:z3,datasourceId:t0}=XA2({token:t,metricId:n});return h.jsxs(h.Fragment,{children:[h.jsx(Wk,{disableDownloadDataNoFilters:x0,disableDownloadUnderlyingDataNoFilters:z2,calendarType:E0,disableFullscreen:!!g,language:Z2,translationDictionary:Y2,datasourceId:t0,isAllClient:k6,disableBorder:i,noDataImg:o,isShadowDisableOnHover:a||!1,isAllowedToSeeUnderlyingData:s,clientColumnType:z7,isEnableCumulative:i2,isDisableClick:M0,isEnableDynamic:N2,isEnableStack:R2,chartAppearance:r,hideDatePickerOptions:C,metricCardColor:M2,workspaceId:I6,guestToken:t,isFrontendApp:!1,downloadMetrics:t1,appearanceOptions:l,onDownload:(K7,G7)=>{p0(G7?c6=>[...c6,{id:K7,isInProgress:G7}]:c6=>c6.filter(u6=>u6.id!==K7))},metricItem:O1,client:y7,dropdownTheme:e,underlyingTheme:u,colors:A||f,optionsIcon:d,onMaximize:g?void 0:({rlsFilters:K7,appliedMetricFilters:G7})=>G0({isShow:!0,rlsFilters:K7,appliedMetricFilters:G7}),companyTenancyType:Y7,chartRendererType:E,param:C3,metricFilterOptions:y,enableDownloadCsv:Q,enableMultiMetricFilters:R,metricFilterPosition:D,onDownloadRawCsv:O?K7=>L3({show:!0,filterValues:K7}):void 0,isDisableCardTitle:k,appFilters:z3,isMergedMetric:!0,globalFilters:f0}),h.jsx(kE,{children:!g&&U0.isShow?h.jsx($k,{disableDownloadDataNoFilters:x0,disableDownloadUnderlyingDataNoFilters:z2,calendarType:E0,language:Z2,translationDictionary:Y2,appliedMetricFilters:(U0==null?void 0:U0.appliedMetricFilters)||[],datasourceId:t0,appFilters:z3,isAllClient:k6,isEnableMetricSummary:X6,hideDatePickerOptions:C,disableDownloadPng:J,chartAppearance:r,clientColumnType:z7,workspaceId:I6,guestToken:t,isFrontendApp:!1,downloadMetrics:t1,onDownload:(K7,G7)=>{p0(G7?c6=>[...c6,{id:K7,isInProgress:G7}]:c6=>c6.filter(u6=>u6.id!==K7))},metric:O1,clientId:y7,colors:A||f,onMinimize:()=>{G0({isShow:!1}),e2==null||e2()},companyId:d7,tenancyLevel:Y7,rlsFilters:U0.rlsFilters,sharingSettingsId:W3,externalDashboardId:"",userProvidedDashboardId:"",isShowChartConfigTab:!1,isHideChartSettings:p2,isHideTablePreview:D2,metricFilterOptions:y,globalFilters:f0}):null}),O&&h.jsx(w60,{workspaceId:I6,metricItem:O1,isShowRawCsvModal:X2.show,onCloseModal:()=>L3({show:!1,filterValues:void 0}),sharingSettingsId:W3,query:Ob({query:eg((O1==null?void 0:O1.query)||"",d7||""),dbName:(O1==null?void 0:O1.integrationName)||"",rlsConditions:((j3=O1==null?void 0:O1.rlsConditions)==null?void 0:j3.filter(K7=>K7.isAddOnMetrics))||[],tenancyLevel:Y7,clientId:y7,values:X2.filterValues,isAllClient:!1,clientColumnType:z7,dataMartRelationships:Q2})})]})},vV="data:image/svg+xml,%3csvg%20width='56'%20height='46'%20viewBox='0%200%2056%2046'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3crect%20width='56'%20height='46'%20fill='url(%23pattern0)'/%3e%3cdefs%3e%3cpattern%20id='pattern0'%20patternContentUnits='objectBoundingBox'%20width='1'%20height='1'%3e%3cuse%20xlink:href='%23image0_65_43'%20transform='matrix(0.00543478%200%200%200.00661626%200%20-0.00283554)'/%3e%3c/pattern%3e%3cimage%20id='image0_65_43'%20width='184'%20height='152'%20xlink:href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALgAAACYCAYAAABXnyPxAAAR0UlEQVR4Xu1dC3hNVxYO8n7IQ4Q8rnhEkFSiFSk1RBitkKlXGOo5ZbTjU/WV1lTT+RhFNaKtR0tJJl6l1BhUmpJQ7yBoNCFeIURCEkmJPG8wa6fiu9JE9j73nnP32XedfvfTJGvvvda//rvO2mvvs08jM7wQAQUQ8Pf3d+z2SsjwV3r0CGuj8fBx9/D0cnRu5lp76IKCu3dzc7KvX7l04dzhI8f2bNu6ebs+6jXSpzG2RQSeh4CbWwvHiNFj3x4aPnBIR/+AQJC1kYCY9sD+pITdu3ZuA7JvYG2PBGdFDOUbRGDAgAGvvzF24pTQvv0GgrDBOFZWXlG+Y/vW9TFrv4m6dDHjSoOKGHJwmsFQRmwE2rbz0axetfp7iNbBclu64/stsdOnvzOpoXEaNySAf0cEaBCY+u7MDw4ePn5FCXITfYZGjHrz+Jn067179w55nn4Gu33QgIAy4iHg7uHhHBO7Pr5zQGB3Y1m3Li52ZeSc2dPqGh8JbiyvCDAupCRe23f8cMTVtZm3sc2BiejO8WNHDamtB6YoxvaMSseHCok9kPsoD+QmEMKEdvCyZcvjkOAqJRRvaset37QXyN2KJ70gL58wadKkqbo6YQTnyUMq0SUyMnI+5Nw9eFR37vxPl8Cikn+NbpiD8+gljnUC7nSKT9if1rhJY26DY0b6uZT+/ft1IzByqyTHPjZp1WZ/+PFnPJObOAdKlUFDhgwbjQQ3aaqyGw9Vk9YwmQtjb6l8i8mTJ72DBFced1WPOHjI0DFgQBM1GBH4UvBLUOmxwBRFDd7iRMf+/V8bzIkqNGpYhYWFjUaC00CFMtUI+Pt3ftEYUFiYNzGztGC/cfi9ENDL3BgK45jqQ8C3Q8cOMLlk5outjZVZaVlFnQZ7uf9hO7hZdm7BM7KODrZmDva2T3+XV1BkVql9SAVg584BfTGCU0GFQhBFLVlRIFHXxcnBjJBcykXa65Kb9OHm6kzdVSuNV1skODVcpi0Ie7FLAYHHLCjUkJGQXMplYy3ti1EzlqWNPdbBpQBvim2ys29eYyE4SS10r9o/02CoraJLRerr697d3HsYwWmQRhmzyoqKRxDF606m68CndmpBfiaTRZaL5O7l5ZXPNCn8rZi6iwsXryYzTxqoe0dB4RBIPnYkCRZ6wmkMqz1ZrKsNjUxB0f2nFZTHkCCxRPUbN7LSMYLTeAtlqhE4eGDfHmNAQaom5MNCbtCzcn/Svp242coYHlPpmPD0jtvJlNQboL5+sz8F7IfjJ268GNDRGyO4AmCLMkRuTk4ePOy7UQ32rIlZs5roiRFcDd7iSEeI4s2TT5y9BYs+Fhyp9YwqEL1zIXp7kF9iBOfVS5zqBVE8/4svlszlVL1qtRZ+Mu/DGv0wgvPsKY51i09IPG7MJ+nrg2bDhrhVc2a//w8kOMfkUYNqQUHBQTt27TnJU5r7Y0LC7ilvjntdFz9MUdTAJg519Pf368wTueHYiL21yY05OIfEUYtK/foP4GVv+ONvN21YDWeivFYXdiaRg5Pbqa2tNdkcUddmIaYNREYmoD661via/NsoKyvrOnxITZv5srSyskq7cDUfNkNJ20XFPGLdDWDrQMmCeZEz1q2LW1tfl0Iv1U+YMHHM8hUrV1uYm9sZCFOhuklLO5caERExEIiew2LYwLBBfwFyP7ubiqUD/WUrIN/+4dMF82ZnXr1y9XndCZuDjxg5OmLVqtVxSO763f/CCwGBe+J/SmLlW9++oSQd+AN3oP6ctzT6szmRH74/Oft2XjZrvxTyj389l3p66OuD/gT5dkRD5Cb9CZuiXMrMzta4N/ekAM3kReZERv7z8+ioxbRApKVnFMHbGZxAXgufRzDBS/x2Y9zqBKhi6PYBRzeMGBYxcgxs0HoVfi/l8HvSXRX54uz9KX7Xtu+2/Ccl5SSp3FBfQhLc29vbMyPj0k2Rv8DUHqYQTEpK/Dk8fFAohWi1yLFjx1Js7F0069fFfLll86Y1ZPGnobZwR30jqFu3V9y9fXw6d/TtAse+kefVyF1Al4OPgMxF8AqTq7+knj159vSZE6dPnzoKkZrsRZd0CUlwcvpSSsqZtCcASgLGlBodOXIkGU6CUvwoNlj2b+Hi7OxqY2Nnm59/JxfmAgZPa0SdZJJqgz4VB1PiN7H1kTEMhsh/h3zkHFvUSSaSm401Qt7JCQQiExxJzkZyIaVFJbiQzkKj2BEQNQdnRkJbVcX6SBTzGEo1IA/3Qv1fqeG4HgdRAPfcKy4Rhtw1bCOH7djqea4I18ylVM7kUxSRIreuz7XaKkoKVIsJO18xeYKzsEBNsoxPoKvJNCZdkeBMcKGw2hBAgqvNY/Loi3VweXDFXhEBeREQOYILG5XkpYRYvYtMcLE8hdZIQgAJLgk2bKQWBEQmOKYoamGhjHqKTHAZYROua2GDARJcOK6iQboIIMGRD0IjgAQX2r1onKgErz7cBt2LCIhKcPQsIlCNABIciSA0Akhwod1LbZyw6RwSnJoDKKhGBJDgavQa6kyNABKcGioUVCMCSHA1eg11pkZAZIILO3Gi9i4KYpkQOSA2AiJHcLE9h9ZRIYAEp4IJhdSKABJcrZ5DvakQEJngVKc1iXqGn6VFEyoCiC6EZxOChx0dbMU7mxDPJaz+7opKcKYSIYniokZyygjNhBdln1yImXyKwoUXUAnZEBCZ4LKBhh2rBwEkuHp8hZpKQAAJLgE0AZtgDq4yp+IzmSpzmFzqYgSXC1l19YsRXF3+wifqVeYv2dQVNYJTrWLKhqr6OhYWL5EJLqzTDP39sbODV7IJegm5kunnH9AV/MX05S0trxDGxazvydS0bt9BGONrGSIcwb29vTVvvTvr3ywOM/X3ZMLGLKuF0ctWz5k5/S0W3NQgyxTleDfI0sqqyfyo5d/b2Vh70eqK78n8Hang7j3/OvHvU9+jxU0tckIRfO7CqI0enp7BAL4lrQNMfJOVLkyOYydOiuzdu3c/WuzUICcMwae+O3MBRKFRUkAn22VFukgO7uhgJ8Uk538t+nxL23Y+7aU05rGNEAX+AQMGRMz6eMFmALh6TgEpilmXTj484s2lTvcflJj9eunaU91ybt1KnzxuRFBlRUU5lwozKKX6CO7boWMgkHtNDbkZbEfRehCANM9/xddrE0UASNUEd3Nr4bUwesUucISTCM7gyYa2Hfx6fvDRvFU86SRFF9USHCom1p98umSHk7NzKymGY5uGEXh1YPjEESNHq7p0qFqCz5g15yuIMkENuwkl9EDACtYUFvn7+7+kRx9GbapKgk+YMPF9iC5/MypypjO487zFX26HdNBdjSarjuBBQcF9x015h2mlUo2O4UlnSANbQzq4laSFPOlFo4uqyoSwDN8hemXMQQC8xfOMYy0TktXM0jJx9qI0Aq82taevg9cuE9aH7cnko9thOT+Chli8yKiG4CR6rN2wLR1KWG0bAo+V4AVF9xvqUnV/Jwf/0JKcluAAwuONcTEfxa35apFaAFFNigLL8NtoyM0KPIneIl6V2odymNUIlvPnwHL+a3J0LkefqiA4LMNHwTJ8uBwAiLoXxVa+Ld72sJy/HpbzfeXwh6H75H67LCzDjxo28o0ZhjZctz+yF6UM9oM/FuQRCQsLczNbeY9uc5u7aOlmWM7vDsv5Wjl9o2/fXOfgZBn+q9hNh8FIBxZDWXNwlr5FlGXIwXXNr8q8eP7AlDfHvcozJtymKFB39XyyDM9Ebp7BFkw3c1ho6wHL+Ut4totLgkPFxArqrhtxGZ5n6lTrZgkLbmOGDBkmaZuyEtZxmaIsjlq6bujwkeP1AaCpPd0eb5Kvsj7DqI9eSrUlz5hWQYWIZl6hrXpYPQfR4yrybevlokd72ZpyOcl0btbcw0bPSRJxGs1VI0dITioPaq+qEGJLWbTSE28HuOs2hgnnIxrMlZThMkUBABQvThOi3ysuVRJ7g48lldwGUIRUUrisQfFKcANgLq0LUlFQ6yUlchvI1iYQvZHgDGAabW4g0wogg+nSRI28IsvtC4EwgkvjE3etaOcc3Ckus0JI8DoANnI0lNnlsnTPZXpCLOWV4EZLUQgoaoyGWq3i83LdbwoSXJa4IVOnRiYLs1UcnM7FXXmwBkReIzizkw3ZgERwtVRTCLk5KG9iBDckAZXoi1RTfj+U06i3/ueaygm5iY7cEpzLlUwlCEwzhu7iD1np5OlS4zzBGPghwSlRR0JRAsWZGObgnDkE1TEsAkhww+KJvXGGAJcEL3/wWxFnOKE6z0eA20kmlwS/lnXjKjIKETAEAlwS3BCGYR+IAEGAV4IbdakeqcGMALf+4pXgzAhjA0SgLgSQ4MgLQyCAEdwQKGIf3CKABGd0DbeAMdphKuLcZgLcKmYqzBDETm4DEhJcEIYZ2QxuecStYkZ2GA7PhgC3POJWMTZ8URoRqBsBXgnObU6HRFIXArwSnNtn/NTlXtSWV4LzqhcyRmUIcJMKkNdyh4WFjezatWtIrz79w11dmyHJVUSm1DMnTyUnHz967Hjy/v1Jibt5Ud2oBCfngPcNDR02cOCg8UFBXUMBFCsCTFNHFzNH52a8YIR6UCBw8/plcnKpJXzMS0rK8uMTEtbtTYjflJ6e/gtFc9lEFCc4kNqy+8sv94M3dYWHhIQOt7Oz+cM7L5Hgsvlbto6B4HX1XX4l88aFgwf2fZeYmPjfrKysOoVkUwo6VpTg8M7zoGnTps0PDAzsB2Nb1GcYElxOl8vTdz0E1x2sfNv2HctXrlj2MZxEq9dp+ywWKEJw8r6d6TPeW9y3T69hoJxNQwoiwRtCiL+/UxC8WmlIX4q+WbP2o21bN3+thBWyExzI7REbG3vIxcW5Ha1BFhYWZi09W9OKo5yRESCvPym4fYNJC4jm0Z9HR81iaiRBWPZKxYyZsxaykJvYoNVqzR49xFK4BH8apUll2QPmcUcMHzozKCj4z8wNGRvITvA+vXoOZNSpWrz4Pj5YLwU3pduQQFRWWixp2F4hIYMlNWRoJDvBDx9N3sugz1PR+/cK9X3zl5RhsQ0jAiQQkTuulOv0qRM/SmnH0kZ2gkdHLX6vsLDoIotSNbIkr9Pz9XZShsU2FAiQyH2v6K4ZCURSrvj4+K8PHToUL6UtSxvZJ5lEGW9v73bzFyz+1qdtq2AW5WpkSVXF0sbeTM9X3UkZGtvUQoAQm0RtkpZIjNyVMTEx/4LPYiXAVYTgNYZMmDDxg7Fjx82GxR0XJYzDMfhCABZ9Li77YunbKSknf1ZKM0UJTowiNfEx48bP7BfaZwRUVzzhV4rroBS4OE41AqWpqak/79y5MzYhIWG70pgYlVxQJgolM+knZCdL9nwdwq20N8QZj5D6SHLyiR/hWpeXd8doJTGjElzXn74dOnbp0b17f7KbEDZe9Ya/OYjjb+EteQiFhNuwm3BHSkpKEkTq//FiMTcErw0IRPc+gYGdewYGdgnp1MmvK+TtjhjhuaANWYGrBEIXAqF3p6WdTz579vQ+2Eh1iwvtainBLcFrgwURPsCvk19Qm3bt/Hx92nbRaFp1hByeTFbJFlvZy508Ok8BnUiBuwwmh5ezb928cPVSRurly5d/zci4eArSDmn1QQWU1h1CNQSvDxfYoeiv0Wg6eXp6tmvTzreLW0uP9m00Hr4Q8W0x4lOxibxlq4pE5MzMzFQ4uvp8YUH+rWvXMs9DVD4Hn1yqXjgVUj3B68MV9p1bt/fxCWjR0t1b4+XVWqPxagMVHI2TS3MPFycHV4j+rtCWbNklE1tR7gAkfSCH0ZMP+f+H5AM7+GCDanlpTl7hzYL821n5eXm3sm9mX7tz+9Z1IHAGfDI55afeaglLcBpkgPAt7R0cnCDTcbW1tbY3t7CE/8ytrK1tbR0dmzqZmzexaOrk4mRnY2UPsu7W9k6OHm4ureC74wB3COsnY9T3dgOCbc0Xh/xLfq7Bm5CvNhlJP7r+eKZfiLB3C38rzi8pLioouv+gsLT43oPc3NzsqqqH2tKyijItbLIuLy8tKS0ln/KSsrKSB4VFRXdyc3Ju02AhqoxJE1xJp8IcwgFeRVj9pYA3tlVcuphxX8nxTXWs/wN+NfPn5SsFWwAAAABJRU5ErkJggg=='/%3e%3c/defs%3e%3c/svg%3e",BC={container:"_container_1xd5b_1",form:"_form_1xd5b_7",mobileForm:"_mobileForm_1xd5b_23",filterHeader:"_filterHeader_1xd5b_31",titleContent:"_titleContent_1xd5b_37",buttons:"_buttons_1xd5b_49",filterFieldsContainer:"_filterFieldsContainer_1xd5b_75",filterFields:"_filterFields_1xd5b_75",mobileFilterFields:"_mobileFilterFields_1xd5b_99",filterContainer:"_filterContainer_1xd5b_107",layoutFilterContainer:"_layoutFilterContainer_1xd5b_113",mobileFilterContainer:"_mobileFilterContainer_1xd5b_119",AddFilter:"_AddFilter_1xd5b_127",filterDropdown:"_filterDropdown_1xd5b_133",filterDropdowns:"_filterDropdowns_1xd5b_141",numberField:"_numberField_1xd5b_233",numberFieldWrapper:"_numberFieldWrapper_1xd5b_249",numberFieldLabel:"_numberFieldLabel_1xd5b_257",selectedLabel:"_selectedLabel_1xd5b_265",numberFieldLabelText:"_numberFieldLabelText_1xd5b_273",numberFieldFooter:"_numberFieldFooter_1xd5b_321",addFilterMenu:"_addFilterMenu_1xd5b_345",addFilterOption:"_addFilterOption_1xd5b_351",addFilterCheckedOption:"_addFilterCheckedOption_1xd5b_357",addFilterOptionLabel:"_addFilterOptionLabel_1xd5b_363",filterButton:"_filterButton_1xd5b_395",filterLength:"_filterLength_1xd5b_411",viewBorder:"_viewBorder_1xd5b_435",searchFilter:"_searchFilter_1xd5b_443",rangeValue:"_rangeValue_1xd5b_451"},SX=({setAppliedFilters:t,column:n,defaultValues:i,className:o="",onChange:a,label:s,variant:r="static",buttonWidth:C="auto",radius:l,isFilter:e,isDisabled:u})=>{var J,e2;const[A,f]=P0.useState(i||{min:null,max:null}),d=(i==null?void 0:i.min)===null||(i==null?void 0:i.max)===null,g=P0.useRef(null),[E,y]=P0.useState(""),[Q,R]=P0.useState(""),D=()=>{var p2;f({min:null,max:null}),y(""),R(""),(p2=g.current)==null||p2.click(),n&&t?t(D2=>D2==null?void 0:D2.filter(Q2=>Q2.label!==(n==null?void 0:n.label))):a&&(a==null||a(void 0))},O=()=>{var p2;if(A.min===null||A.max===null){R("Invalid value");return}n&&t?t(D2=>{const Q2={column:n.name,operator:Qb,value:`${A.min} AND ${A.max}`,as:n.as,defaultValues:A,filterType:n.isShowHorizontal?"horizontal":"global",isFilterApplied:!!n.isShowHorizontal,applyOnTables:n.applyOnTables,isVariableFilter:n.isVariableFilter,variableStrings:n.variableStrings||[],label:n.label||n.name,restrictedMetrics:n.restrictedMetrics||[]},i2=D2.findIndex(R2=>R2.label===n.label);if(i2===-1)return[...D2,Q2];const N2=[...D2];return N2[i2]=Q2,N2}):a&&(a==null||a({min:A.min,max:A.max})),y(`Between ${A.min} to ${A.max}`),R(""),(p2=g.current)==null||p2.click()};P0.useEffect(()=>{f(i&&!d?i:{min:null,max:null}),y(i&&!d?`Between ${i.min} to ${i.max}`:"")},[i==null?void 0:i.max,i==null?void 0:i.min,d]);const k=window.CSS&&CSS.supports("width","clamp(1px, 1px, 1px)");return h.jsx(h.Fragment,{children:h.jsx(fl,{position:"bottom-start",buttonWidth:k&&e?`clamp(100px, 13cqw, ${C})`:C,tabMenu:!0,menuWidth:"200px",isDisabled:u,buttonContent:h.jsxs(h.Fragment,{children:[r==="static"&&h.jsx("span",{className:`dbn-inline-block dbn-text-xs dbn-leading-6 dbn-font-medium dbn-font-sans ${e?"dbn-selectBox":""}`,children:s||(n==null?void 0:n.label)||(n==null?void 0:n.name)}),h.jsxs("div",{className:BC.numberField,style:{borderRadius:l||"4px",containerType:"inline-size",opacity:u?.6:1},ref:g,"data-testid":(J=(n==null?void 0:n.label)||(n==null?void 0:n.name))==null?void 0:J.toLowerCase().replaceAll(" ","-").concat("-dropdown"),children:[h.jsxs("div",{className:BC.numberFieldLabelText,children:[r==="floating"&&h.jsx("span",{className:`${[BC.numberFieldLabel,BC.selectedLabel].join(" ")} ${e?"dbn-selectBox":""}`,children:s||(n==null?void 0:n.label)||(n==null?void 0:n.name)}),h.jsx("span",{className:`${BC.rangeValue} ${e?"dbn-selectBox":""}`,style:k&&e?{fontSize:"clamp(8px, 9cqw, 14px)"}:{fontSize:"14px"},children:E||"Select a value"})]}),h.jsx("span",{className:"dbn-interactive-element",children:h.jsx(h8,{name:"chevron-down",color:"gray"})})]})]}),children:h.jsxs("div",{className:BC.numberFieldWrapper,"data-testid":(e2=(n==null?void 0:n.label)||(n==null?void 0:n.name))==null?void 0:e2.toLowerCase().replaceAll(" ","-").concat("-menu"),children:[h.jsx(K9,{label:"minimum",type:"number",defaultValue:A.min,onChange:({target:{value:p2}})=>{f(D2=>({...D2,min:p2===""?null:Number(p2)}))}}),h.jsx(K9,{label:"maximum",type:"number",defaultValue:A.max,onChange:({target:{value:p2}})=>{f(D2=>({...D2,max:p2===""?null:Number(p2)}))}}),h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[Q&&h.jsx(_7,{variant:"body-text-2",color:"alert",children:Q}),h.jsxs("div",{className:BC.numberFieldFooter,children:[h.jsx(e8,{type:"button",variant:"tertiary",onClick:D,children:"Clear"}),h.jsx(e8,{variant:"primary",type:"button",onClick:O,children:"Save"})]})]})]})})})},VX=({column:t,onClickSearch:n,selectedValue:i,isDisabled:o,buttonWidth:a="200px",isFilter:s,isApplyDashboardColor:r,labelVariant:C="static",isImportant:l,radius:e})=>{const[u,A]=P0.useState(""),f=window.CSS&&CSS.supports("width","clamp(1px, 1px, 1px)");P0.useEffect(()=>{A((i==null?void 0:i.value)||"")},[i]);const d=P0.useMemo(()=>{if(a){if(a==="100%")return"100%";const E=`${parseInt(a,10)-44}px`;return f&&s?`clamp(100px, 13cqw, ${E})`:E}return"200px"},[a,s,f]);return h.jsxs("div",{className:a==="100%"?"dbn-w-full":"",children:[(t.label||t.name)&&C==="static"?h.jsx(h.Fragment,{children:s&&r?h.jsxs("span",{className:"dbn-text-xs dbn-leading-6 dbn-font-normal dbn-inline-block dbn-font-sans dbn-selectBox",children:[t.label||t.name,l?h.jsx("span",{className:BC.important,children:"*"}):null]}):h.jsxs(_7,{variant:"input-label",color:"primary-title",children:[t.label||t.name,l?h.jsx("span",{className:BC.important,children:"*"}):null]})}):null,h.jsxs("div",{className:BC.searchFilter,style:{borderRadius:e||"6px",opacity:o?.6:1,pointerEvents:o?"none":"auto"},children:[h.jsx(K9,{id:`${t.label||t.name}-search`,label:C==="static"?"":t.label||t.name,labelVariant:"floating",isFilter:s,isApplyDashboardColor:r,value:u,onChange:({target:{value:g}})=>A(g),style:{...d?{width:d}:{},borderTopLeftRadius:e||"6px",borderBottomLeftRadius:e||"6px"},className:"dbn-truncate",containerStyle:{borderTopLeftRadius:e||"6px",borderBottomLeftRadius:e||"6px"},isDisabled:o}),h.jsx(e8,{id:"search","data-testid":"search-btn",variant:"primary",className:"dbn-rounded-l-none",style:{borderRadius:e||"6px"},onClick:()=>{n(u!=null&&u.length?u:void 0)},isDisabled:o,children:h.jsx(h8,{name:"magnifying-glass",color:"white"})})]})]})},kX=({appliedfilters:t,setAppliedFilters:n,filters:i,internal:o,clientId:a,isAllClient:s,theme:r,addGlobalFilter:C,filterOptions:l,tenancyLevel:e,clientColumnType:u,layout:A,isEditLayoutEnabled:f,hideDatePickerOptions:d,isEndUserApp:g,datasourceId:E,parentAppliedFilter:y,isDisableClick:Q,isMobileView:R})=>{var Q2;const D=P0.useMemo(()=>e==="MULTI_DATABASE"&&a||"",[e,a]),O=P0.useCallback((i2,N2)=>{var Y2,f0;const R2=((Y2=t.find(E0=>E0.label===i2))==null?void 0:Y2.value)||"",M2=(f0=t.find(E0=>E0.label===i2))==null?void 0:f0.selectedDropdownValue;let Z2="";return M2&&!Array.isArray(M2)&&(Z2=M2.label||""),N2==="string"?Array.isArray(R2)&&(R2!=null&&R2.length)?R2==null?void 0:R2.map(E0=>typeof E0=="object"?E0:{value:E0,label:E0}):[]:N2==="string"?Array.isArray(M2)?M2:[]:{label:Z2||R2,value:R2}},[t]),k=P0.useCallback(i2=>{var M2;const N2=((M2=i2.dependOn)==null?void 0:M2.map(Z2=>{const Y2=[...t||[],...y||[]].find(f0=>Z2.label===f0.label||Z2.value===f0.column);if(Y2){const f0=IV({operator:Y2.operator,value:Y2.value});return{as:"string",columnName:Z2.customColumnName||Y2.column,value:kb(f0)}}return null}))||[],R2=N2==null?void 0:N2.filter(Z2=>Z2);return i2.clientColumn&&i2.isClientScoped&&i2.clientColumnType&&!s?[{columnName:i2.clientColumn,value:a,as:i2.clientColumnType},...R2]:R2},[t,a,s,y]),J=P0.useCallback(i2=>{var R2;const N2=(R2=A==null?void 0:A.clientLayout)!=null&&R2.length?A==null?void 0:A.clientLayout:A==null?void 0:A.adminLayout;return N2!=null&&N2.includes(i2.label)?N2==null?void 0:N2.indexOf(i2.label):N2!=null&&N2.includes(i2.name)?N2==null?void 0:N2.indexOf(i2.name):N2==null?void 0:N2.length},[A==null?void 0:A.adminLayout,A==null?void 0:A.clientLayout]),e2=P0.useMemo(()=>{var i2,N2;return(N2=(i2=i==null?void 0:i[0])==null?void 0:i2.columns)==null?void 0:N2.filter(R2=>R2.isShowHorizontal).sort((R2,M2)=>J(R2)-J(M2))},[i,J]),p2=P0.useMemo(()=>{let i2=-2,N2=0;return(e2==null?void 0:e2.map(M2=>{let Z2;return i2+2>=12?(i2=0,N2+=3,Z2=0):(Z2=i2+2,i2+=2),{i:M2.label||M2.name,w:2,h:3,x:Z2,y:N2,minW:2,minH:1,maxH:3}}))||[]},[e2,f]),D2=P0.useCallback(i2=>{var R2,M2;return((M2=(R2=t.find(Z2=>Z2.label===i2))==null?void 0:R2.value)==null?void 0:M2.presetDateOption)||""},[t]);return h.jsx(h.Fragment,{children:f?h.jsx(eO,{layouts:{lg:p2},rowHeight:3,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:12,sm:12,xs:4,xxs:2},margin:[10,10],containerPadding:[0,0],onResizeStop:A.isLocked?void 0:A.onChange,onDragStop:A.isLocked?void 0:A.onChange,isDraggable:!A.isLocked,isResizable:!1,isDroppable:!A.isLocked,compactType:"horizontal",children:e2==null?void 0:e2.map(i2=>{var N2,R2,M2,Z2,Y2,f0,E0,M0,x0,z2,t1,p0,U0,G0,X2,L3,O1,C3,W3,d7,y7,Y7,I6,z7,X6,k6,z3,t0,j3,K7,G7,c6,u6,L6,v1,A3,c7,X3,Y3,n7;return h.jsxs("div",{className:BC.filterDropdown,style:{borderRadius:r.radius},id:i2.label||i2.name,tabIndex:0,role:"button",children:[!i2.isCustomFieldFilter&&(l==null?void 0:l(i2.label||i2.name||""))," ",i2.as==="date"&&h.jsx(h.Fragment,{children:h.jsx(fA,{datePickerFormat:r==null?void 0:r.datePickerFormat,label:i2.label||i2.name,hideDatePickerOptions:d,isFilter:!0,variant:r.variant==="static"?"static":"floatingLabel",buttonWidth:r.width,radius:r.radius,defaultValues:(N2=t.find(V7=>V7.label===i2.label))==null?void 0:N2.defaultValues,isDateReset:!t.filter(V7=>V7.as==="date").length,onChange:V7=>Ws({column:i2,operator:Qb,setAppliedFilters:n,type:KL,value:V7!=null&&V7.startDate&&(V7!=null&&V7.endDate)?V7:void 0}),isDisabled:f})}),i2.as==="number"&&h.jsx(SX,{variant:r.variant,isFilter:!0,buttonWidth:r.width,radius:r.radius,setAppliedFilters:n,column:i2,defaultValues:(R2=t.find(V7=>V7.label===i2.label))==null?void 0:R2.defaultValues,isDisabled:f}),i2.as==="string"&&!i2.isVariableFilter&&!((M2=i2.filterVariant)!=null&&M2.value)&&(o!=null&&o.isInternal&&!i2.isManualOptions?h.jsx(oh,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((Z2=i2.autoSelectType)==null?void 0:Z2.value)==="last",autoSelectCount:["last","first"].includes(((Y2=i2.autoSelectType)==null?void 0:Y2.value)||"")?i2.autoSelectCount:1,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,filter:{columnName:i2.filterType===du&&((f0=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:f0.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((E0=i==null?void 0:i[0])==null?void 0:E0.tableName):(M0=i==null?void 0:i[0])==null?void 0:M0.tableName},isDisabled:f,customTable:i2.filterType===du&&((x0=i2==null?void 0:i2.selectedCustomColumn)!=null&&x0.columnName)&&((z2=i2==null?void 0:i2.selectedCustomColumn)!=null&&z2.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,buttonWidth:r.width,isFilter:!0,isApplyDashboardColor:!0,menuWidth:r.width,radius:r.radius,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,selectedOption:O(i2.label||i2.name,"string")||[],autoSelected:!1,onChange:V7=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:V7!=null&&V7.length?V7:void 0})},isSearchEnabled:!0,label:i2.label||i2.name,filterClause:k(i2),isClearEnabled:i2.isEnableClearSelection}):h.jsx(bs,{isAutoSelectFromLast:((t1=i2.autoSelectType)==null?void 0:t1.value)==="last",autoSelectCount:["last","first"].includes(((p0=i2.autoSelectType)==null?void 0:p0.value)||"")?i2.autoSelectCount:1,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Ad(i2),labelVariant:r.variant,radius:r.radius,selectedOption:O(i2.label||i2.name,"string")||[],onChange:V7=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:V7!=null&&V7.length?V7:void 0})},isSearchEnabled:!0,label:i2.label||i2.name})),i2.as==="default"||i2.as==="boolean"||["default","boolean","string"].includes(i2.as||"")&&i2.isVariableFilter&&!((U0=i2.filterVariant)!=null&&U0.value)?o!=null&&o.isInternal&&!i2.isManualOptions?h.jsx(yE,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((G0=i2.autoSelectType)==null?void 0:G0.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:i2.filterType===du&&((X2=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:X2.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((L3=i==null?void 0:i[0])==null?void 0:L3.tableName):(O1=i==null?void 0:i[0])==null?void 0:O1.tableName},customTable:i2.filterType===du&&((C3=i2==null?void 0:i2.selectedCustomColumn)!=null&&C3.columnName)&&((W3=i2==null?void 0:i2.selectedCustomColumn)!=null&&W3.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,radius:r.radius,autoSelected:!1,selectedOption:O(i2.label||i2.name,"boolean"),onChange:V7=>{Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:V7!=null&&V7.value?V7:void 0})},isSearchEnabled:!0,label:i2.label||i2.name,filterClause:k(i2),isClearEnabled:i2.isEnableClearSelection}):h.jsx(K4,{isAutoSelectFromLast:((d7=i2.autoSelectType)==null?void 0:d7.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Ad(i2),labelVariant:r.variant,radius:r.radius,selectedOption:O(i2.label||i2.name,"boolean"),onChange:V7=>{Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:V7!=null&&V7.value?V7:void 0})},isClearEnabled:i2.isEnableClearSelection,isSearchEnabled:!0,label:i2.label||i2.name}):null,!!(i2.as==="string"&&((y7=i2.filterVariant)!=null&&y7.value))&&h.jsxs(h.Fragment,{children:[((Y7=i2.filterVariant)==null?void 0:Y7.value)==="like"&&h.jsx(VX,{column:i2,isDisabled:f,buttonWidth:(r==null?void 0:r.width)||"200px",isFilter:!0,isApplyDashboardColor:!0,selectedValue:O(i2.label||i2.name,"boolean"),onClickSearch:V7=>Ws({column:i2,operator:$A,setAppliedFilters:n,type:XL,value:V7}),labelVariant:(r==null?void 0:r.variant)||"floating",radius:r==null?void 0:r.radius}),((I6=i2.filterVariant)==null?void 0:I6.value)==="IN"&&(!i2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(oh,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((z7=i2.autoSelectType)==null?void 0:z7.value)==="last",autoSelectCount:["last","first"].includes(((X6=i2.autoSelectType)==null?void 0:X6.value)||"")?i2.autoSelectCount:1,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,labelVariant:r.variant,radius:r.radius,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:i2.filterType===du&&((k6=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:k6.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((z3=i==null?void 0:i[0])==null?void 0:z3.tableName):(t0=i==null?void 0:i[0])==null?void 0:t0.tableName,labelColumnName:i2.filterType===du?i2.customLabelColumn||"":i2.labelColumnName||""},customTable:i2.filterType===du&&((j3=i2==null?void 0:i2.selectedCustomColumn)!=null&&j3.columnName)&&((K7=i2==null?void 0:i2.selectedCustomColumn)!=null&&K7.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,selectedOption:O(i2.label||i2.name,"string")||[],onChange:V7=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:V7!=null&&V7.length?V7:void 0})},isSearchEnabled:!0,label:i2.label||i2.name,filterClause:k(i2),isClearEnabled:i2.isEnableClearSelection}):h.jsx(bs,{isAutoSelectFromLast:((G7=i2.autoSelectType)==null?void 0:G7.value)==="last",autoSelectCount:["last","first"].includes(((c6=i2.autoSelectType)==null?void 0:c6.value)||"")?i2.autoSelectCount:1,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,radius:r.radius,options:Ad(i2),labelVariant:r.variant,selectedOption:O(i2.label||i2.name,"string")||[],onChange:V7=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:V7!=null&&V7.length?V7:void 0})},isSearchEnabled:!0,label:i2.label||i2.name})),((u6=i2.filterVariant)==null?void 0:u6.value)==="="&&(!i2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(yE,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((L6=i2.autoSelectType)==null?void 0:L6.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,radius:r.radius,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:i2.filterType===du&&((v1=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:v1.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((A3=i==null?void 0:i[0])==null?void 0:A3.tableName):(c7=i==null?void 0:i[0])==null?void 0:c7.tableName,labelColumnName:i2.filterType===du?i2.customLabelColumn||"":i2.labelColumnName||""},customTable:i2.filterType===du&&((X3=i2==null?void 0:i2.selectedCustomColumn)!=null&&X3.columnName)&&((Y3=i2==null?void 0:i2.selectedCustomColumn)!=null&&Y3.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,autoSelected:!1,selectedOption:O(i2.label||i2.name,"boolean"),onChange:V7=>Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:V7!=null&&V7.value?V7:void 0}),isSearchEnabled:!0,isClearEnabled:i2.isEnableClearSelection,label:i2.label||i2.name,filterClause:k(i2)}):h.jsx(K4,{isAutoSelectFromLast:((n7=i2.autoSelectType)==null?void 0:n7.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,radius:r.radius,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Ad(i2),labelVariant:r.variant,selectedOption:O(i2.label||i2.name,"boolean"),onChange:V7=>Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:V7!=null&&V7.value?V7:void 0}),isSearchEnabled:!0,isClearEnabled:i2.isEnableClearSelection,label:i2.label||i2.name}))]})]},i2.label||i2.name)})},f?"reset":"default"):h.jsxs(h.Fragment,{children:[(Q2=e2==null?void 0:e2.filter(i2=>g?!i2.isAppFilter:!0))==null?void 0:Q2.map(i2=>{var N2,R2,M2,Z2,Y2,f0,E0,M0,x0,z2,t1,p0,U0,G0,X2,L3,O1,C3,W3,d7,y7,Y7,I6,z7,X6,k6,z3,t0,j3,K7,G7,c6,u6,L6,v1,A3,c7,X3,Y3,n7,V7,P7,D7,_6,c8,x8,C8,K8,l8,I9,M8,d9,b8,g5,N5,h5,d4,b5,M1,o9,O9,s5,u5,B5,U9,c3,W8,e7,Q6,P6,f6,x7,s7,k3,E3,Q7,E7,w6;return h.jsxs("div",{className:R?"dbn-w-full":BC.filterDropdown,style:{borderRadius:r.radius,pointerEvents:Q?"none":void 0},"data-testid":(N2=i2.label||i2.name)==null?void 0:N2.toLowerCase().replaceAll(" ","-").concat("-filter"),children:[!i2.isCustomFieldFilter&&(l==null?void 0:l(i2.label||i2.name||"")),i2.as==="date"&&h.jsx(h.Fragment,{children:((R2=i2.dateVariant)==null?void 0:R2.value)==="preset"?h.jsx(K4,{isAutoSelectFromLast:((M2=i2.autoSelectType)==null?void 0:M2.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,isFilter:!R,isApplyDashboardColor:!R,options:((Z2=i2==null?void 0:i2.datePresetOptions)==null?void 0:Z2.map(n6=>({value:n6.label,label:n6.label,presetDateOption:n6})))||[],labelVariant:r.variant,radius:r.radius,defaultOption:(Y2=i2==null?void 0:i2.defaultValue)!=null&&Y2.value?{value:(f0=i2==null?void 0:i2.defaultValue)==null?void 0:f0.value,label:(E0=i2==null?void 0:i2.defaultValue)==null?void 0:E0.label,presetDateOption:(M0=i2==null?void 0:i2.defaultValue)==null?void 0:M0.presetDateOption}:{value:"",label:""},selectedOption:(z2=(x0=t.find(n6=>n6.label===i2.label))==null?void 0:x0.value)!=null&&z2.value?(t1=t.find(n6=>n6.label===i2.label))==null?void 0:t1.value:{value:"",label:""},onChange:n6=>{Ws({column:i2,operator:ml,setAppliedFilters:n,type:JL,value:n6!=null&&n6.value?n6:void 0})},isClearEnabled:i2.isEnableClearSelection,isSearchEnabled:!0,label:i2.label||i2.name,disableAutoClose:!0,children:((U0=(p0=D2(i2.label))==null?void 0:p0.type)==null?void 0:U0.value)==="custom"?h.jsx("div",{className:"dbn-p-1",children:h.jsx(fA,{datePickerFormat:r==null?void 0:r.datePickerFormat,isEnableSingleDate:((X2=(G0=D2(i2.label))==null?void 0:G0.customType)==null?void 0:X2.value)==="singleDate",label:((O1=(L3=D2(i2.label))==null?void 0:L3.customType)==null?void 0:O1.value)==="singleDate"?qx:$x,hideDatePickerOptions:d,onChange:n6=>{var o6;Ws({column:i2,operator:ml,setAppliedFilters:n,type:JL,value:{...(o6=t.find(g8=>g8.label===i2.label))==null?void 0:o6.value,presetDateOption:{...D2(i2.label),customDate:n6}}})},minDate:(C3=D2(i2.label))!=null&&C3.isDateRestricted&&((W3=D2(i2.label))!=null&&W3.restrictionDateFrom)?Yl((d7=D2(i2.label))==null?void 0:d7.restrictionDateFrom,!0):void 0,maxDate:(y7=D2(i2.label))!=null&&y7.isDateRestricted&&((Y7=D2(i2.label))!=null&&Y7.restrictionDateTo)?Yl((I6=D2(i2.label))==null?void 0:I6.restrictionDateTo):void 0,defaultValues:(X6=(z7=D2(i2.label))==null?void 0:z7.customDate)!=null&&X6.startDate&&((z3=(k6=D2(i2.label))==null?void 0:k6.customDate)!=null&&z3.endDate)?{startDate:new Date((j3=(t0=D2(i2.label))==null?void 0:t0.customDate)==null?void 0:j3.startDate),endDate:new Date((G7=(K7=D2(i2.label))==null?void 0:K7.customDate)==null?void 0:G7.endDate),timeGrainValue:((u6=(c6=D2(i2.label))==null?void 0:c6.customDate)==null?void 0:u6.timeGrainValue)||""}:void 0})}):null}):h.jsx(fA,{datePickerFormat:r==null?void 0:r.datePickerFormat,minDate:i2.isEnableDateRestriction&&((L6=i2==null?void 0:i2.dateRestrictionRange)!=null&&L6.from)?Yl((v1=i2==null?void 0:i2.dateRestrictionRange)==null?void 0:v1.from,!0):void 0,maxDate:i2.isEnableDateRestriction&&((A3=i2==null?void 0:i2.dateRestrictionRange)!=null&&A3.to)?Yl((c7=i2==null?void 0:i2.dateRestrictionRange)==null?void 0:c7.to):void 0,label:i2.label||i2.name,hideDatePickerOptions:d,isEnableSingleDate:((X3=i2.dateSelectionType)==null?void 0:X3.value)==="singleDate",buttonWidth:R?"100%":r.width,isFilter:!R,variant:r.variant==="static"?"static":"floatingLabel",radius:r.radius,defaultValues:(Y3=t.find(n6=>n6.label===i2.label))==null?void 0:Y3.defaultValues,defaultOption:eC2(i2),isDateReset:!t.filter(n6=>n6.as==="date").length,onChange:n6=>Ws({column:i2,operator:Qb,setAppliedFilters:n,type:KL,value:n6!=null&&n6.startDate&&(n6!=null&&n6.endDate)?n6:void 0})})}),i2.as==="number"&&h.jsx(SX,{variant:r.variant,buttonWidth:R?"100%":r.width,isFilter:!R,radius:r.radius,setAppliedFilters:n,column:i2,defaultValues:(n7=t.find(n6=>n6.label===i2.label))==null?void 0:n7.defaultValues}),i2.as==="string"&&!i2.isVariableFilter&&!((V7=i2.filterVariant)!=null&&V7.value)&&(o!=null&&o.isInternal&&!i2.isManualOptions?h.jsx(oh,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((P7=i2.autoSelectType)==null?void 0:P7.value)==="last",autoSelectCount:["last","first"].includes(((D7=i2.autoSelectType)==null?void 0:D7.value)||"")?i2.autoSelectCount:1,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,filter:{columnName:i2.filterType===du&&((_6=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:_6.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((c8=i==null?void 0:i[0])==null?void 0:c8.tableName):(x8=i==null?void 0:i[0])==null?void 0:x8.tableName},customTable:i2.filterType===du&&((C8=i2==null?void 0:i2.selectedCustomColumn)!=null&&C8.columnName)&&((K8=i2==null?void 0:i2.selectedCustomColumn)!=null&&K8.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,isFilter:!R,isApplyDashboardColor:!R,radius:r.radius,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,selectedOption:O(i2.label||i2.name,"string")||[],autoSelected:!1,onChange:n6=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:n6!=null&&n6.length?n6:void 0})},isSearchEnabled:!0,label:i2.label||i2.name,filterClause:k(i2),isClearEnabled:i2.isEnableClearSelection}):h.jsx(bs,{isAutoSelectFromLast:((l8=i2.autoSelectType)==null?void 0:l8.value)==="last",isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,autoSelectCount:["last","first"].includes(((I9=i2.autoSelectType)==null?void 0:I9.value)||"")?i2.autoSelectCount:1,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,isFilter:!R,isApplyDashboardColor:!R,options:Ad(i2),labelVariant:r.variant,radius:r.radius,selectedOption:O(i2.label||i2.name,"string")||[],onChange:n6=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:n6!=null&&n6.length?n6:void 0})},isSearchEnabled:!0,label:i2.label||i2.name})),i2.as==="default"||i2.as==="boolean"||["default","boolean","string"].includes(i2.as||"")&&i2.isVariableFilter&&!((M8=i2.filterVariant)!=null&&M8.value)?o!=null&&o.isInternal&&!i2.isManualOptions?h.jsx(yE,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((d9=i2.autoSelectType)==null?void 0:d9.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,isFilter:!R,isApplyDashboardColor:!R,filter:{columnName:i2.filterType===du&&((b8=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:b8.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((g5=i==null?void 0:i[0])==null?void 0:g5.tableName):(N5=i==null?void 0:i[0])==null?void 0:N5.tableName},customTable:i2.filterType===du&&((h5=i2==null?void 0:i2.selectedCustomColumn)!=null&&h5.columnName)&&((d4=i2==null?void 0:i2.selectedCustomColumn)!=null&&d4.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,radius:r.radius,autoSelected:!1,selectedOption:O(i2.label||i2.name,"boolean"),onChange:n6=>{Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:n6!=null&&n6.value?n6:void 0})},isSearchEnabled:!0,label:i2.label||i2.name,filterClause:k(i2),isClearEnabled:i2.isEnableClearSelection}):h.jsx(K4,{isAutoSelectFromLast:((b5=i2.autoSelectType)==null?void 0:b5.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,isFilter:!R,isApplyDashboardColor:!R,options:Ad(i2),labelVariant:r.variant,radius:r.radius,selectedOption:O(i2.label||i2.name,"boolean"),onChange:n6=>{Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:n6!=null&&n6.value?n6:void 0})},isClearEnabled:i2.isEnableClearSelection,isSearchEnabled:!0,label:i2.label||i2.name}):null,!!(i2.as==="string"&&((M1=i2.filterVariant)!=null&&M1.value))&&h.jsxs(h.Fragment,{children:[((o9=i2.filterVariant)==null?void 0:o9.value)==="like"&&h.jsx(VX,{column:i2,buttonWidth:R?"100%":r==null?void 0:r.width,isFilter:!R,isApplyDashboardColor:!R,selectedValue:O(i2.label||i2.name,"boolean"),onClickSearch:n6=>Ws({column:i2,operator:$A,setAppliedFilters:n,type:XL,value:n6}),labelVariant:(r==null?void 0:r.variant)||"floating",radius:r==null?void 0:r.radius}),((O9=i2.filterVariant)==null?void 0:O9.value)==="IN"&&(!i2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(oh,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((s5=i2.autoSelectType)==null?void 0:s5.value)==="last",autoSelectCount:["last","first"].includes(((u5=i2.autoSelectType)==null?void 0:u5.value)||"")?i2.autoSelectCount:1,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,labelVariant:r.variant,radius:r.radius,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,isFilter:!R,isApplyDashboardColor:!R,filter:{columnName:i2.filterType===du&&((B5=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:B5.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((U9=i==null?void 0:i[0])==null?void 0:U9.tableName):(c3=i==null?void 0:i[0])==null?void 0:c3.tableName,labelColumnName:i2.filterType===du?i2.customLabelColumn||"":i2.labelColumnName||""},customTable:i2.filterType===du&&((W8=i2==null?void 0:i2.selectedCustomColumn)!=null&&W8.columnName)&&((e7=i2==null?void 0:i2.selectedCustomColumn)!=null&&e7.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,selectedOption:O(i2.label||i2.name,"string")||[],onChange:n6=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:n6!=null&&n6.length?n6:void 0})},isSearchEnabled:!0,label:i2.label||i2.name,filterClause:k(i2),isClearEnabled:i2.isEnableClearSelection}):h.jsx(bs,{isAutoSelectFromLast:((Q6=i2.autoSelectType)==null?void 0:Q6.value)==="last",autoSelectCount:["last","first"].includes(((P6=i2.autoSelectType)==null?void 0:P6.value)||"")?i2.autoSelectCount:1,isAutoSelectAll:i2==null?void 0:i2.isSelectAllMultiSelectOptions,isSelectAllEnabled:i2==null?void 0:i2.isSelectAllMultiSelect,isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,isFilter:!R,isApplyDashboardColor:!R,radius:r.radius,options:Ad(i2),labelVariant:r.variant,selectedOption:O(i2.label||i2.name,"string")||[],onChange:n6=>{Ws({column:i2,operator:fu,setAppliedFilters:n,type:ec,value:n6!=null&&n6.length?n6:void 0})},isSearchEnabled:!0,label:i2.label||i2.name,isClearEnabled:i2.isEnableClearSelection})),((f6=i2.filterVariant)==null?void 0:f6.value)==="="&&(!i2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(yE,{databaseName:D,datasourceId:E,isAutoSelectFromLast:((x7=i2.autoSelectType)==null?void 0:x7.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,radius:r.radius,isFilter:!R,isApplyDashboardColor:!R,filter:{columnName:i2.filterType===du&&((s7=i2==null?void 0:i2.selectedCustomColumn)==null?void 0:s7.columnName)||i2.name,tableName:i2.filterType==="auto"?i2.selectedTable||((k3=i==null?void 0:i[0])==null?void 0:k3.tableName):(E3=i==null?void 0:i[0])==null?void 0:E3.tableName,labelColumnName:i2.filterType===du?i2.customLabelColumn||"":i2.labelColumnName||""},customTable:i2.filterType===du&&((Q7=i2==null?void 0:i2.selectedCustomColumn)!=null&&Q7.columnName)&&((E7=i2==null?void 0:i2.selectedCustomColumn)!=null&&E7.query)?{alias:"custom_dbn_table",query:Sc({query:i2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,autoSelected:!1,selectedOption:O(i2.label||i2.name,"boolean"),onChange:n6=>Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:n6!=null&&n6.value?n6:void 0}),isSearchEnabled:!0,isClearEnabled:i2.isEnableClearSelection,label:i2.label||i2.name,filterClause:k(i2)}):h.jsx(K4,{isAutoSelectFromLast:((w6=i2.autoSelectType)==null?void 0:w6.value)==="last",isAutoSelectOption:i2.isAutoSelectFilterValue,buttonWidth:R?"100%":r.width,menuWidth:R?"100%":r.width,radius:r.radius,isFilter:!R,isApplyDashboardColor:!R,options:Ad(i2),labelVariant:r.variant,selectedOption:O(i2.label||i2.name,"boolean"),onChange:n6=>Ws({column:i2,operator:ml,setAppliedFilters:n,type:tc,value:n6!=null&&n6.value?n6:void 0}),isSearchEnabled:!0,isClearEnabled:i2.isEnableClearSelection,label:i2.label||i2.name}))]})]},i2.label||i2.name)}),C]})})},M60=T9.memo(({token:t,chartColors:n,metricId:i,chartRendererType:o="canvas",variant:a="card",onMinimize:s,isHideChartSettings:r,isHideTablePreview:C,enableDownloadCsv:l,enableEmailCsv:e,metricFilterOptions:u,enableMultiMetricFilters:A,metricFilterPosition:f="outside",disableFullscreen:d,optionsIcon:g,customMessages:E,themeName:y,setAdminTheme:Q,appearanceOptions:R,isDisableCardTitle:D,hideDatePickerOptions:O,chartAppearance:k,hideMetricCardShadow:J,disableUnderlyingData:e2,noDataImg:p2,disableDownloadPng:D2,disableMetricCardBorder:Q2,isMergedCard:i2,chartColumns:N2,language:R2,translationDictionary:M2,globalFilterOptions:Z2,calendarType:Y2="default",disableDownloadDataNoFilters:f0=!1,disableDownloadUnderlyingDataNoFilters:E0=!1})=>{var o9,O9,s5,u5,B5,U9,c3,W8,e7,Q6,P6,f6,x7,s7,k3,E3,Q7,E7,w6,n6,o6,g8,J3,A8,J8,t8,a9,u8,k9,P5,s9,X5,U5,z5,G5,Z4;const[M0,x0]=P0.useState([]),[z2,t1]=P0.useState({isShow:a==="fullscreen"}),[p0,U0]=P0.useState(!1),[G0,X2]=P0.useState(!1),[L3,O1]=P0.useState(!1),[C3,W3]=P0.useState(!1),[d7,y7]=P0.useState({show:!1,filterValues:void 0}),[Y7,I6]=P0.useState([]),[z7,X6]=P0.useState({width:"200px",variant:"floating",radius:"6px",datePickerFormat:""}),[k6,z3]=P0.useState({header:{fontColor:"",bgColor:"",fontWeight:""},content:{fontColor:"",lineGap:"",fontWeight:""}}),{externalMetric:t0,rlsSettings:j3,sharingSettingsId:K7,companyId:G7,clientId:c6,tenancyLevel:u6,isLoading:L6,errorMsg:v1,adminTheme:A3,workspaceId:c7,clientColumnType:X3,isEnableMetricSummary:Y3,isAllClient:n7,isShowUnderlyingData:V7,appFilters:P7,mergedMetricsId:D7,datasourceId:_6,mergedMetricLayout:c8,mergedDashboardFilters:x8,dashboardAppFilterValues:C8,nestedMetric:K8,token:l8}=XA2({token:t,metricId:i}),I9=(o9=window==null?void 0:window.dbn)!=null&&o9.isEnableProxyAuth?l8:t,M8=P0.useMemo(()=>{var T5,d8,n9,i8,B6;return((B6=(i8=(n9=(d8=(T5=t0==null?void 0:t0.externalDashboardMetrics)==null?void 0:T5[0])==null?void 0:d8.externalDashboard)==null?void 0:n9.companyWorkspace)==null?void 0:i8.datamart)==null?void 0:B6.datamartRelationships)||[]},[t0]),{data:d9}=_A2({token:I9,name:y||"",companyId:G7}),b8=P0.useMemo(()=>(d9==null?void 0:d9.theme)||A3,[A3,d9]),g5=P0.useMemo(()=>e2!=null&&e2.toString()?!e2:V7,[e2,V7]),N5=P0.useMemo(()=>c8==null?void 0:c8.map(d8=>{const n9=d8.i,i8=d8.layout;return{i:n9,w:(i8==null?void 0:i8.w)??d8.resizeAttributes.width??5,h:(i8==null?void 0:i8.h)??d8.resizeAttributes.height??10,x:(i8==null?void 0:i8.x)??d8.resizeAttributes.xAxis??0,y:(i8==null?void 0:i8.y)??d8.resizeAttributes.yAxis??0,minW:d8.isMetric?[m0.singleValue,m0.pivot,m0.pivotV2,m0.pivotV3,m0.progressBar,m0.linearGauge].includes(d8==null?void 0:d8.chartType)?2:3:1,minH:d8.isMetric?[m0.singleValue,m0.pivot,m0.pivotV2,m0.pivotV3].includes(d8==null?void 0:d8.chartType)?2:[m0.progressBar,m0.linearGauge].includes(d8==null?void 0:d8.chartType)?3:8:d8.description?2:1,maxH:(d8==null?void 0:d8.chartType)==="table"?1/0:15}}),[c8]),h5=P0.useMemo(()=>N5.sort((T5,d8)=>T5.y!==d8.y?T5.y-d8.y:T5.x-d8.x),[N5]),d4=P0.useMemo(()=>{var d8,n9,i8;return n??((i8=(n9=(d8=b8==null?void 0:b8.chart)==null?void 0:d8.palettes)==null?void 0:n9.find(B6=>{var e5,E9;return B6.name===((E9=(e5=(d9==null?void 0:d9.theme)||A3)==null?void 0:e5.chart)==null?void 0:E9.selected)}))==null?void 0:i8.colors)},[b8,n]);P0.useEffect(()=>{var T5,d8,n9,i8,B6,e5,E9,A9,p9,d5,C5,W6,e9,Y9,P9,C9,I4,v4,x5,M5,Y5,r4,n4,y4,m4,ce;if(b8!=null&&b8.dashboard.selectBoxSize)switch(b8==null?void 0:b8.dashboard.selectBoxSize){case"small":X6(N4=>({...N4,width:"130px"}));break;case"medium":X6(N4=>({...N4,width:"180px"}));break;case"large":X6(N4=>({...N4,width:"250px"}));break;default:X6(N4=>({...N4,width:"200px"}))}b8!=null&&b8.dashboard.selectBoxVariant&&X6(N4=>({...N4,variant:b8.dashboard.selectBoxVariant})),b8!=null&&b8.dashboard.selectBoxBorderRadius&&X6(N4=>({...N4,radius:b8.dashboard.selectBoxBorderRadius})),(T5=b8==null?void 0:b8.general)!=null&&T5.datePickerFormat&&X6(N4=>{var je;return{...N4,datePickerFormat:(je=b8==null?void 0:b8.general)==null?void 0:je.datePickerFormat}}),(d8=b8==null?void 0:b8.dashboard)!=null&&d8.underlyingData&&z3({header:{fontColor:((B6=(i8=(n9=b8==null?void 0:b8.dashboard)==null?void 0:n9.underlyingData)==null?void 0:i8.header)==null?void 0:B6.fontColor)||"#0D0D0D",bgColor:((A9=(E9=(e5=b8==null?void 0:b8.dashboard)==null?void 0:e5.underlyingData)==null?void 0:E9.header)==null?void 0:A9.bgColor)||"#f9fafb",fontWeight:((C5=(d5=(p9=b8==null?void 0:b8.dashboard)==null?void 0:p9.underlyingData)==null?void 0:d5.header)==null?void 0:C5.fontWeight)||"boldfont",fontSize:(Y9=(e9=(W6=b8==null?void 0:b8.dashboard)==null?void 0:W6.underlyingData)==null?void 0:e9.header)==null?void 0:Y9.fontSize},content:{fontColor:((I4=(C9=(P9=b8==null?void 0:b8.dashboard)==null?void 0:P9.underlyingData)==null?void 0:C9.content)==null?void 0:I4.fontColor)||"#222c3a",lineGap:((M5=(x5=(v4=b8==null?void 0:b8.dashboard)==null?void 0:v4.underlyingData)==null?void 0:x5.content)==null?void 0:M5.lineGap)||"24px",fontWeight:((n4=(r4=(Y5=b8==null?void 0:b8.dashboard)==null?void 0:Y5.underlyingData)==null?void 0:r4.content)==null?void 0:n4.fontWeight)||"500",fontSize:(ce=(m4=(y4=b8==null?void 0:b8.dashboard)==null?void 0:y4.underlyingData)==null?void 0:m4.content)==null?void 0:ce.fontSize}})},[b8]),P0.useEffect(()=>{Q(b8)},[b8]);const b5=P0.useMemo(()=>!!(D7!=null&&D7.length)||!!(x8!=null&&x8.length),[D7,x8]),M1=P0.useMemo(()=>x8!=null&&x8.length?(x8==null?void 0:x8.map(T5=>{var d8,n9,i8;return{...T5,...u6==="DATABASE"?{tableName:`${c6}.${(n9=(d8=T5==null?void 0:T5.tableName)==null?void 0:d8.split(/\.(?=[^.]*$)/))==null?void 0:n9[1]}`}:{},columns:((i8=T5==null?void 0:T5.columns)==null?void 0:i8.map(B6=>{var e5,E9;return{...B6,defaultValue:Xs2(B6,C8,Z2),isManualOptions:!!((e5=Z2==null?void 0:Z2[B6==null?void 0:B6.label])!=null&&e5.options)||!!(B6!=null&&B6.isManualOptions),manualOptions:((E9=Z2==null?void 0:Z2[B6==null?void 0:B6.label])==null?void 0:E9.options)||(B6==null?void 0:B6.manualOptions)||[]}}))||[]}}))||[]:[],[x8,u6,c6,C8,Z2]);return P0.useEffect(()=>{setTimeout(()=>{W3(!!localStorage.getItem("isDisableClick")||!1)},1e3)},[]),h.jsxs(h.Fragment,{children:[L6&&(I9||(O9=window==null?void 0:window.dbn)!=null&&O9.isEnableProxyAuth)?h.jsx("div",{className:Ry.loader,children:h.jsx(gA,{})}):null,(v1==="TOKEN_EXPIRED"&&(I9||(s5=window==null?void 0:window.dbn)!=null&&s5.isEnableProxyAuth)?(E==null?void 0:E.tokenExpiry)||"Expired Token!":v1)||null,!I9&&!((u5=window==null?void 0:window.dbn)!=null&&u5.isEnableProxyAuth)&&!L6?h.jsxs("div",{className:Ry["alt-container"],children:[E!=null&&E.tokenAbsent?null:h.jsx("img",{src:vV,alt:"no data",width:100,height:100}),(E==null?void 0:E.tokenAbsent)||"INVALID_TOKEN"]}):null,t0&&!L6?h.jsxs(h.Fragment,{children:[a==="card"?h.jsxs("div",{className:"dbn-w-full dbn-h-full",children:[(B5=Object.keys(R||{}))!=null&&B5.length&&[y02,aB2].includes((R==null?void 0:R.appearanceOptionsPosition)||"")?h.jsxs("div",{className:`dbn-w-full dbn-flex dbn-flex-wrap dbn-gap-4 dbn-pb-2 ${(R==null?void 0:R.appearanceOptionsPosition)===y02?"dbn-justify-start":"dbn-justify-end"}`,style:C3?{pointerEvents:"none"}:{},children:[(U9=R==null?void 0:R.cumulativeBar)!=null&&U9.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(ha,{position:"bottom",text:"It demonstrates the accumulated values, providing insights into the overall trend or pattern in the data",isSingleLineTxt:!1,children:h.jsx(_5,{enabled:p0,name:"cumulative",onChange:()=>U0(!p0),placeholder:((c3=R==null?void 0:R.cumulativeBar)==null?void 0:c3.label)||"Cumulative"})})}):null,(W8=R==null?void 0:R.dynamicBehaviour)!=null&&W8.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(ha,{position:"bottom",text:"It allows you to observe trends, fluctuations, or updates as they occur in a responsive visual representation",isSingleLineTxt:!1,children:h.jsx(_5,{enabled:G0,name:"dynamic",onChange:()=>X2(!G0),placeholder:((e7=R==null?void 0:R.dynamicBehaviour)==null?void 0:e7.label)||"Dynamic"})})}):null,(Q6=R==null?void 0:R.stackedBars)!=null&&Q6.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(ha,{position:"bottom",text:"It represents the percentage distribution of individual components relative to the whole.",isSingleLineTxt:!1,children:h.jsx(_5,{name:"full stacked",enabled:L3,onChange:()=>O1(!L3),placeholder:((P6=R==null?void 0:R.stackedBars)==null?void 0:P6.label)||"100% stacked bars"})})}):null]}):null,h.jsx("div",{className:`${Ry["MetricList-wrapper"]} dbn-metric-chart
|
|
599
599
|
${b5&&i2?`dbn-metric-card dbn-metric-card-container ${Ry.mergedCard}`:Ry.flexDisplay}
|
|
600
600
|
${Q2?"dbn-border-0":""}`,style:{background:b5&&i2&&((f6=b8==null?void 0:b8.dashboard)!=null&&f6.metricCardColor)?(x7=b8==null?void 0:b8.dashboard)==null?void 0:x7.metricCardColor:b5&&i2&&!((s7=b8==null?void 0:b8.dashboard)!=null&&s7.metricCardColor)?"dbn-bg-white":""},children:i2&&b5?h.jsxs(h.Fragment,{children:[!!((E3=(k3=M1==null?void 0:M1[0])==null?void 0:k3.columns)!=null&&E3.length)&&h.jsx("div",{className:"dbn-w-full dbn-flex dbn-gap-2 dbn-p-2 dbn-items-end dbn-z-[19] dbn-justify-start",children:h.jsx(kX,{isEditLayoutEnabled:!1,clientColumnType:X3,hideDatePickerOptions:[],appliedfilters:M0,setAppliedFilters:x0,isDisableClick:C3,filters:M1,internal:{isInternal:!0,workspaceId:c7||""},clientId:c6,isAllClient:n7,theme:z7,tenancyLevel:u6,layout:{adminLayout:((Q7=t0==null?void 0:t0.chartOptions)==null?void 0:Q7.filterLayout)||[],clientLayout:[],isLocked:!0,onChange:()=>{}},datasourceId:_6})}),h.jsx(eO,{layouts:{lg:h5},rowHeight:30,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:12,sm:12,xs:4,xxs:2},margin:[10,10],containerPadding:[0,0],draggableHandle:"metric-sub-card",isDraggable:!1,isDroppable:!1,isResizable:!1,children:[t0==null?void 0:t0.metricId,...D7].map(T5=>{var d8,n9,i8,B6,e5,E9,A9;return h.jsx("div",{id:((n9=(d8=c8==null?void 0:c8.find(p9=>(p9==null?void 0:p9.metricId)===T5))==null?void 0:d8.layout)==null?void 0:n9.i)||T5,children:h.jsx(Q60,{disableDownloadDataNoFilters:f0,disableDownloadUnderlyingDataNoFilters:E0,calendarType:Y2,globalFilters:{tableName:(M1==null?void 0:M1.tableName)||"",filters:(i8=M0==null?void 0:M0.filter(p9=>p9==null?void 0:p9.value))==null?void 0:i8.map(p9=>Ws2(p9))},language:R2,translationDictionary:M2,dropdownTheme:z7,underlyingTheme:k6,isDisableClick:C3,metricId:T5,token:I9,adminColors:d4,appearanceOptions:R,metricCardColor:((B6=b8==null?void 0:b8.dashboard)==null?void 0:B6.metricCardColor)||"",chartAppearance:k,chartColors:n,chartRendererType:o,dataMartRelationships:M8,isEnableCumulative:p0,isEnableDynamic:G0,isEnableStack:L3,disableDownloadPng:D2,disableFullscreen:d,disableMetricCardBorder:Q2,enableDownloadCsv:l,enableEmailCsv:e,enableMultiMetricFilters:A,hideDatePickerOptions:O,hideMetricCardShadow:J??((e5=b8==null?void 0:b8.cardCustomization)==null?void 0:e5.disableShadowOnHover)??!1,isDisableCardTitle:D,isEnableUnderlyingData:g5,isHideChartSettings:r,isHideTablePreview:C,metricFilterOptions:u,metricFilterPosition:f,noDataImg:p2,onMinimize:s,optionsIcon:g},T5)},((A9=(E9=c8==null?void 0:c8.find(p9=>(p9==null?void 0:p9.metricId)===T5))==null?void 0:E9.layout)==null?void 0:A9.i)||T5)})},"default")]}):h.jsx(Wk,{disableDownloadDataNoFilters:f0,disableDownloadUnderlyingDataNoFilters:E0,disableFullscreen:!!d,language:R2,translationDictionary:M2,isDisableClick:C3,isEmbeddedMetric:!i2,datasourceId:_6,isAllClient:n7,disableBorder:Q2,metricCardColor:((E7=b8==null?void 0:b8.dashboard)==null?void 0:E7.metricCardColor)||"",isEnableCumulative:p0,isEnableDynamic:G0,isEnableStack:L3,isMergedMetric:b5&&i2,noDataImg:p2,isShadowDisableOnHover:J??((w6=b8==null?void 0:b8.cardCustomization)==null?void 0:w6.disableShadowOnHover)??!1,isAllowedToSeeUnderlyingData:g5,clientColumnType:X3,chartAppearance:k,hideDatePickerOptions:O,workspaceId:c7,guestToken:I9,isFrontendApp:!1,downloadMetrics:Y7,appearanceOptions:R,onDownload:(T5,d8)=>{I6(d8?n9=>[...n9,{id:T5,isInProgress:d8}]:n9=>n9.filter(i8=>i8.id!==T5))},metricItem:N2!=null&&N2.isEnabled?{...t0,chartOptions:{...t0==null?void 0:t0.chartOptions,yAxisList:(N2==null?void 0:N2.measures)||[],xAxis:((n6=N2==null?void 0:N2.dimensions)==null?void 0:n6[0])||"",enduserMeasureAndDimensions:{isEnabled:N2==null?void 0:N2.isEnabled,dimensions:((o6=N2==null?void 0:N2.dimensions)==null?void 0:o6.map(T5=>({value:T5,label:T5})))||[],measures:((g8=N2==null?void 0:N2.measures)==null?void 0:g8.map(T5=>({value:T5,label:T5})))||[]}}}:t0,client:c6,dropdownTheme:z7,underlyingTheme:k6,colors:d4||n,optionsIcon:g,onMaximize:d&&!((A8=(J3=t0==null?void 0:t0.clickActions)==null?void 0:J3.chartWithMetric)!=null&&A8.isEnable)?void 0:({rlsFilters:T5,appliedMetricFilters:d8,isClickOnChart:n9})=>t1({isShow:!0,rlsFilters:T5,appliedMetricFilters:d8,isClickOnChart:n9}),companyTenancyType:u6,chartRendererType:o,param:j3,metricFilterOptions:u,enableDownloadCsv:l,enableMultiMetricFilters:A,metricFilterPosition:f,onDownloadRawCsv:e?T5=>y7({show:!0,filterValues:T5}):void 0,isDisableCardTitle:D,appFilters:P7,calendarType:Y2})}),(J8=Object.keys(R||{}))!=null&&J8.length&&[L02,w02].includes((R==null?void 0:R.appearanceOptionsPosition)||"")?h.jsxs("div",{className:`dbn-w-full dbn-flex dbn-flex-wrap dbn-gap-4 dbn-pt-2 ${(R==null?void 0:R.appearanceOptionsPosition)===L02?"dbn-justify-start":"dbn-justify-end"}`,style:C3?{pointerEvents:"none"}:{},children:[(t8=R==null?void 0:R.cumulativeBar)!=null&&t8.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(ha,{position:"bottom",text:"It demonstrates the accumulated values, providing insights into the overall trend or pattern in the data",isSingleLineTxt:!1,children:h.jsx(_5,{enabled:p0,name:"cumulative",onChange:()=>U0(!p0),placeholder:((a9=R==null?void 0:R.cumulativeBar)==null?void 0:a9.label)||"Cumulative"})})}):null,(u8=R==null?void 0:R.dynamicBehaviour)!=null&&u8.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(ha,{position:"bottom",text:"It allows you to observe trends, fluctuations, or updates as they occur in a responsive visual representation",isSingleLineTxt:!1,children:h.jsx(_5,{enabled:G0,name:"dynamic",onChange:()=>X2(!G0),placeholder:((k9=R==null?void 0:R.dynamicBehaviour)==null?void 0:k9.label)||"Dynamic"})})}):null,(P5=R==null?void 0:R.stackedBars)!=null&&P5.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(ha,{position:"bottom",text:"It represents the percentage distribution of individual components relative to the whole.",isSingleLineTxt:!1,children:h.jsx(_5,{name:"full stacked",enabled:L3,onChange:()=>O1(!L3),placeholder:((s9=R==null?void 0:R.stackedBars)==null?void 0:s9.label)||"100% stacked bars"})})}):null]}):null]}):null,(!d||z2!=null&&z2.isClickOnChart)&&z2.isShow||a==="fullscreen"?h.jsx(kE,{children:h.jsx($k,{refetchDashboardData:()=>{},onServerEvent:()=>{},disableDownloadDataNoFilters:f0,disableDownloadUnderlyingDataNoFilters:E0,calendarType:Y2,language:R2,translationDictionary:M2,appliedMetricFilters:(z2==null?void 0:z2.appliedMetricFilters)||[],datasourceId:_6,appFilters:P7,isAllClient:n7,isEnableMetricSummary:Y3,hideDatePickerOptions:O,disableDownloadPng:D2,chartAppearance:k,clientColumnType:X3,workspaceId:c7,guestToken:I9,isFrontendApp:!1,downloadMetrics:Y7,onDownload:(T5,d8)=>{I6(d8?n9=>[...n9,{id:T5,isInProgress:d8}]:n9=>n9.filter(i8=>i8.id!==T5))},metric:N2!=null&&N2.isEnabled?{...z2!=null&&z2.isClickOnChart&&K8?K8:t0,chartOptions:{...(X5=z2!=null&&z2.isClickOnChart&&K8?K8:t0)==null?void 0:X5.chartOptions,yAxisList:(N2==null?void 0:N2.measures)||[],xAxis:((U5=N2==null?void 0:N2.dimensions)==null?void 0:U5[0])||"",enduserMeasureAndDimensions:{isEnabled:N2==null?void 0:N2.isEnabled,dimensions:((z5=N2==null?void 0:N2.dimensions)==null?void 0:z5.map(T5=>({value:T5,label:T5})))||[],measures:((G5=N2==null?void 0:N2.measures)==null?void 0:G5.map(T5=>({value:T5,label:T5})))||[]}}}:z2!=null&&z2.isClickOnChart&&K8?K8:t0,clientId:c6,colors:d4||n,onMinimize:()=>{t1({isShow:!1,isClickOnChart:!1}),s==null||s()},companyId:G7,tenancyLevel:u6,rlsFilters:z2.rlsFilters,sharingSettingsId:K7,externalDashboardId:"",userProvidedDashboardId:"",isShowChartConfigTab:!1,isHideChartSettings:r,isHideTablePreview:C,metricFilterOptions:u})}):null,e?h.jsx(pV,{workspaceId:c7,metricItem:t0,isShowRawCsvModal:d7.show,onCloseModal:()=>y7({show:!1,filterValues:void 0}),sharingSettingsId:K7,query:Ob({query:eg((t0==null?void 0:t0.query)||"",G7||""),dbName:(t0==null?void 0:t0.integrationName)||"",rlsConditions:((Z4=t0==null?void 0:t0.rlsConditions)==null?void 0:Z4.filter(T5=>T5.isAddOnMetrics))||[],tenancyLevel:u6,clientId:c6,values:d7.filterValues,isAllClient:!1,clientColumnType:X3,dataMartRelationships:M8})}):null]}):null]})}),gc2=({componentName:t,adminTheme:n,isDisableCardShadow:i,theme:o,longDescriptionConfig:a,isDisableStrokeOpt:s})=>{var d,g,E;const C=new URLSearchParams(window.location.search).get("isDbn"),[l,e]=P0.useState(""),[u,A]=P0.useState(""),f=P0.useId();return P0.useEffect(()=>{const y=document.querySelector("#dbn-styles");y&&A(y.innerHTML)},[]),P0.useEffect(()=>{var Q,R,D,O,k,J,e2,p2,D2,Q2,i2,N2,R2,M2,Z2,Y2,f0,E0,M0,x0,z2,t1,p0,U0,G0,X2,L3,O1,C3,W3,d7,y7;if(!n)return e("");let y="";(Q=n.general.fontFamily)!=null&&Q.trim()&&(y=`
|