@databrainhq/plugin 0.16.17 → 0.16.18

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.
@@ -584,7 +584,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
584
584
  FETCH NEXT ${N} ROWS ONLY`;r||s||C?e=f$2({sqlQuery:e,existingOffset:d,existingLimit:m,outputQuery:O,isRemove:a}):e=$Y(e,`limit ${m}`,a?"":`limit ${N} ${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 ${m||u} rows only`:(/fetch/i.test(e)||/offset/i.test(e))&&(e=c$2({sql:e,newLimit:u,newOffset:l,isRemove:a})):a||(e+=` limit ${u} ${l!=="0"?`OFFSET ${l}`:""}`);return e},hN=({onSubmit:t,defaultValues:n,onCancel:i,error:o,isCreatingMetric:a})=>{var f;const{register:s,handleSubmit:r,setValue:C,formState:{errors:l},watch:e}=sb(),u=e("name"),A=e("metricId");return z0.useEffect(()=>{!n||a||(C("name",n.name),C("description",n.description),C("metricId",n.metricId))},[n]),z0.useEffect(()=>{var d;!n&&((d=u==null?void 0:u.trim())==null?void 0:d.length)>=4&&!A&&C("metricId",`${u}_${PB(10)}`)},[n,u]),E.jsxs("form",{onSubmit:r(d=>t(d,!1)),children:[E.jsxs("div",{className:i02.container,children:[E.jsx(g5,{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}),E.jsx(Wn0,{className:i02.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&&E.jsx(q7,{variant:"body-text-2",color:"alert",children:o}),a&&E.jsx("div",{className:"dbn-absolute dbn-w-full dbn-h-full dbn-top-0 dbn-bg-black/[0.1]",children:E.jsx(oA,{})}),E.jsxs($f,{children:[E.jsx(C8,{type:"reset",variant:"tab",onClick:i,children:"Cancel"}),E.jsx(C8,{type:"submit",variant:"primary",isDisabled:a,children:"Save"})]})]})},hl={wrapper:"_wrapper_iw07e_1",valueWrapper:"_valueWrapper_iw07e_9",value:"_value_iw07e_9",error:"_error_iw07e_31",noOptions:"_noOptions_iw07e_39",floatingLabel:"_floatingLabel_iw07e_47",badge:"_badge_iw07e_55",badgeColor:"_badgeColor_iw07e_63",badgeFull:"_badgeFull_iw07e_71",dropdown:"_dropdown_iw07e_147",options:"_options_iw07e_155",optionsWrapper:"_optionsWrapper_iw07e_163",checkedOption:"_checkedOption_iw07e_171",option:"_option_iw07e_155",searchDiv:"_searchDiv_iw07e_299",placeholderWrapper:"_placeholderWrapper_iw07e_315",optionLabel:"_optionLabel_iw07e_331"};function eW(t,n){return eW=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},eW(t,n)}function qI(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,eW(t,n)}var E$2=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])})},ws2={error:null},p$2=function(t){qI(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=ws2,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(ws2)},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&&E$2(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(z0.isValidElement(l))return l;if(typeof r=="function")return r(e);if(C)return z0.createElement(C,e);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(z0.Component),UB=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 $s(){return $s=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},$s.apply(null,arguments)}var EN=typeof window>"u";function tA(){}function v$2(t,n){return typeof t=="function"?t(n):t}function tW(t){return typeof t=="number"&&t>=0&&t!==1/0}function pN(t){return Array.isArray(t)?t:[t]}function Qs2(t,n){return Math.max(t+(n||0)-Date.now(),0)}function vN(t,n,i){return zQ(t)?typeof n=="function"?$s({},i,{queryKey:t,queryFn:n}):$s({},n,{queryKey:t}):t}function I$2(t,n,i){return zQ(t)?typeof n=="function"?$s({},i,{mutationKey:t,mutationFn:n}):$s({},n,{mutationKey:t}):typeof t=="function"?$s({},n,{mutationFn:t}):$s({},t)}function wp(t,n,i){return zQ(t)?[$s({},n,{queryKey:t}),i]:[t||{},n]}function m$2(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 Ms2(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(zQ(C)){if(o){if(n.queryHash!==rW(C,n.options))return!1}else if(!IN(n.queryKey,C))return!1}var e=m$2(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 Ts2(t,n){var i=t.exact,o=t.fetching,a=t.predicate,s=t.mutationKey;if(zQ(s)){if(!n.options.mutationKey)return!1;if(i){if($I(n.options.mutationKey)!==$I(s))return!1}else if(!IN(n.options.mutationKey,s))return!1}return!(typeof o=="boolean"&&n.state.status==="loading"!==o||a&&!a(n))}function rW(t,n){var i=(n==null?void 0:n.queryKeyHashFn)||$I;return i(t)}function $I(t){var n=pN(t);return b$2(n)}function b$2(t){return JSON.stringify(t,function(n,i){return nW(i)?Object.keys(i).sort().reduce(function(o,a){return o[a]=i[a],o},{}):i})}function IN(t,n){return xs2(pN(t),pN(n))}function xs2(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!xs2(t[i],n[i])}):!1}function mN(t,n){if(t===n)return t;var i=Array.isArray(t)&&Array.isArray(n);if(i||nW(t)&&nW(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]=mN(t[e],n[e]),r[e]===t[e]&&C++}return o===s&&C===o?t:r}return n}function B$2(t,n){if(t&&!n||n&&!t)return!1;for(var i in t)if(t[i]!==n[i])return!1;return!0}function nW(t){if(!Rs2(t))return!1;var n=t.constructor;if(typeof n>"u")return!0;var i=n.prototype;return!(!Rs2(i)||!i.hasOwnProperty("isPrototypeOf"))}function Rs2(t){return Object.prototype.toString.call(t)==="[object Object]"}function zQ(t){return typeof t=="string"||Array.isArray(t)}function y$2(t){return new Promise(function(n){setTimeout(n,t)})}function Hs2(t){Promise.resolve().then(t).catch(function(n){return setTimeout(function(){throw n})})}function Ds2(){if(typeof AbortController=="function")return new AbortController}var L$2=function(t){qI(n,t);function n(){var o;return o=t.call(this)||this,o.setup=function(a){var s;if(!EN&&((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}(UB),GQ=new L$2,w$2=function(t){qI(n,t);function n(){var o;return o=t.call(this)||this,o.setup=function(a){var s;if(!EN&&((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}(UB),bN=new w$2;function Q$2(t){return Math.min(1e3*Math.pow(2,t),3e4)}function BN(t){return typeof(t==null?void 0:t.cancel)=="function"}var Ss2=function(n){this.revert=n==null?void 0:n.revert,this.silent=n==null?void 0:n.silent};function yN(t){return t instanceof Ss2}var Ns2=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(h){if(!i.isResolved&&(e(new Ss2(h)),i.abort==null||i.abort(),BN(d)))try{d.cancel()}catch{}},i.isTransportCancelable=BN(d),Promise.resolve(d).then(l).catch(function(g){var h,m;if(!i.isResolved){var w=(h=n.retry)!=null?h:3,Q=(m=n.retryDelay)!=null?m:Q$2,R=typeof Q=="function"?Q(i.failureCount,g):Q,N=w===!0||typeof w=="number"&&i.failureCount<w||typeof w=="function"&&w(i.failureCount,g);if(o||!N){e(g);return}i.failureCount++,n.onFail==null||n.onFail(i.failureCount,g),y$2(R).then(function(){if(!GQ.isFocused()||!bN.isOnline())return u()}).then(function(){o?e(g):f()})}})}};A()},M$2=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):Hs2(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&&Hs2(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}(),wl=new M$2,Vs2=console;function LN(){return Vs2}function T$2(t){Vs2=t}var x$2=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=$s({},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(),tW(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=v$2(o,C);return(s=(r=this.options).isDataEqual)!=null&&s.call(r,C,l)?l=C:this.options.structuralSharing!==!1&&(l=mN(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(tA).catch(tA):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||!Qs2(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(Q){return Q.options.queryFn});u&&this.setOptions(u.options)}var A=pN(this.queryKey),f=Ds2(),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")},h={fetchOptions:a,options:this.options,queryKey:A,state:this.state,fetchFn:g,meta:this.meta};if((r=this.options.behavior)!=null&&r.onFetch){var m;(m=this.options.behavior)==null||m.onFetch(h)}if(this.revertState=this.state,!this.state.isFetching||this.state.fetchMeta!==((C=h.fetchOptions)==null?void 0:C.meta)){var w;this.dispatch({type:"fetch",meta:(w=h.fetchOptions)==null?void 0:w.meta})}return this.retryer=new Ns2({fn:h.fetchFn,abort:f==null||(l=f.abort)==null?void 0:l.bind(f),onSuccess:function(R){s.setData(R),s.cache.config.onSuccess==null||s.cache.config.onSuccess(R,s),s.cacheTime===0&&s.optionalRemove()},onError:function(R){yN(R)&&R.silent||s.dispatch({type:"error",error:R}),yN(R)||(s.cache.config.onError==null||s.cache.config.onError(R,s),LN().error(R)),s.cacheTime===0&&s.optionalRemove()},onFail:function(){s.dispatch({type:"failed"})},onPause:function(){s.dispatch({type:"pause"})},onContinue:function(){s.dispatch({type:"continue"})},retry:h.options.retry,retryDelay:h.options.retryDelay}),this.promise=this.retryer.promise,this.promise},n.dispatch=function(o){var a=this;this.state=this.reducer(this.state,o),wl.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 $s({},o,{fetchFailureCount:o.fetchFailureCount+1});case"pause":return $s({},o,{isPaused:!0});case"continue":return $s({},o,{isPaused:!1});case"fetch":return $s({},o,{fetchFailureCount:0,fetchMeta:(s=a.meta)!=null?s:null,isFetching:!0,isPaused:!1},!o.dataUpdatedAt&&{error:null,status:"loading"});case"success":return $s({},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 yN(C)&&C.revert&&this.revertState?$s({},this.revertState):$s({},o,{error:C,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,isFetching:!1,isPaused:!1,status:"error"});case"invalidate":return $s({},o,{isInvalidated:!0});case"setState":return $s({},o,a.state);default:return o}},t}(),R$2=function(t){qI(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:rW(l,s),u=this.get(e);return u||(u=new x$2({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;wl.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 Ms2(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 Ms2(C,l)}):this.queries},i.notify=function(a){var s=this;wl.batch(function(){s.listeners.forEach(function(r){r(a)})})},i.onFocus=function(){var a=this;wl.batch(function(){a.queries.forEach(function(s){s.onFocus()})})},i.onOnline=function(){var a=this;wl.batch(function(){a.queries.forEach(function(s){s.onOnline()})})},n}(UB),H$2=function(){function t(i){this.options=$s({},i.defaultOptions,i.options),this.mutationId=i.mutationId,this.mutationCache=i.mutationCache,this.observers=[],this.state=i.state||ks2(),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(tA).catch(tA)):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),LN().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 Ns2({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=D$2(this.state,o),wl.batch(function(){a.observers.forEach(function(s){s.onMutationUpdate(o)}),a.mutationCache.notify(a)})},t}();function ks2(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}function D$2(t,n){switch(n.type){case"failed":return $s({},t,{failureCount:t.failureCount+1});case"pause":return $s({},t,{isPaused:!0});case"continue":return $s({},t,{isPaused:!1});case"loading":return $s({},t,{context:n.context,data:void 0,error:null,isPaused:!1,status:"loading",variables:n.variables});case"success":return $s({},t,{data:n.data,error:null,status:"success",isPaused:!1});case"error":return $s({},t,{data:void 0,error:n.error,failureCount:t.failureCount+1,isPaused:!1,status:"error"});case"setState":return $s({},t,n.state);default:return t}}var S$2=function(t){qI(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 H$2({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;wl.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 Ts2(a,s)})},i.findAll=function(a){return this.mutations.filter(function(s){return Ts2(a,s)})},i.notify=function(a){var s=this;wl.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 wl.batch(function(){return a.reduce(function(s,r){return s.then(function(){return r.continue().catch(tA)})},Promise.resolve())})},n}(UB);function N$2(){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)||[],h=Ds2(),m=h==null?void 0:h.signal,w=g,Q=!1,R=n.options.queryFn||function(){return Promise.reject("Missing queryFn")},N=function(M2,P2,G2,C0){return w=C0?[P2].concat(w):[].concat(w,[P2]),C0?[G2].concat(M2):[].concat(M2,[G2])},O=function(M2,P2,G2,C0){if(Q)return Promise.reject("Cancelled");if(typeof G2>"u"&&!P2&&M2.length)return Promise.resolve(M2);var m0={queryKey:n.queryKey,signal:m,pageParam:G2,meta:n.meta},H0=R(m0),v0=Promise.resolve(H0).then(function(U0){return N(M2,G2,U0,C0)});if(BN(H0)){var J2=v0;J2.cancel=H0.cancel}return v0},X;if(!d.length)X=O([]);else if(A){var K=typeof u<"u",f2=K?u:Os2(n.options,d);X=O(d,K,f2)}else if(f){var A2=typeof u<"u",b2=A2?u:V$2(n.options,d);X=O(d,A2,b2,!0)}else(function(){w=[];var R2=typeof n.options.getNextPageParam>"u",M2=l&&d[0]?l(d[0],0,d):!0;X=M2?O([],R2,g[0]):Promise.resolve(N([],g[0],d[0]));for(var P2=function(m0){X=X.then(function(H0){var v0=l&&d[m0]?l(d[m0],m0,d):!0;if(v0){var J2=R2?g[m0]:Os2(n.options,H0);return O(H0,R2,J2)}return Promise.resolve(N(H0,g[m0],d[m0]))})},G2=1;G2<d.length;G2++)P2(G2)})();var g2=X.then(function(R2){return{pages:R2,pageParams:w}}),j2=g2;return j2.cancel=function(){Q=!0,h==null||h.abort(),BN(X)&&X.cancel()},g2}}}}function Os2(t,n){return t.getNextPageParam==null?void 0:t.getNextPageParam(n[n.length-1],n)}function V$2(t,n){return t.getPreviousPageParam==null?void 0:t.getPreviousPageParam(n[0],n)}var k$2=function(){function t(i){i===void 0&&(i={}),this.queryCache=i.queryCache||new R$2,this.mutationCache=i.mutationCache||new S$2,this.defaultOptions=i.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}var n=t.prototype;return n.mount=function(){var o=this;this.unsubscribeFocus=GQ.subscribe(function(){GQ.isFocused()&&bN.isOnline()&&(o.mutationCache.onFocus(),o.queryCache.onFocus())}),this.unsubscribeOnline=bN.subscribe(function(){GQ.isFocused()&&bN.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($s({},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=vN(o),C=this.defaultQueryOptions(r);return this.queryCache.build(this,C).setData(a,s)},n.setQueriesData=function(o,a,s){var r=this;return wl.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;wl.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=$s({},l,{active:!0});return wl.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=wl.batch(function(){return r.queryCache.findAll(l).map(function(f){return f.cancel(u)})});return Promise.all(A).then(tA).catch(tA)},n.invalidateQueries=function(o,a,s){var r,C,l,e=this,u=wp(o,a,s),A=u[0],f=u[1],d=$s({},A,{active:(r=(C=A.refetchActive)!=null?C:A.active)!=null?r:!0,inactive:(l=A.refetchInactive)!=null?l:!1});return wl.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=wl.batch(function(){return r.queryCache.findAll(l).map(function(f){return f.fetch(void 0,$s({},e,{meta:{refetchPage:l==null?void 0:l.refetchPage}}))})}),A=Promise.all(u).then(tA);return e!=null&&e.throwOnError||(A=A.catch(tA)),A},n.fetchQuery=function(o,a,s){var r=vN(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(tA).catch(tA)},n.fetchInfiniteQuery=function(o,a,s){var r=vN(o,a,s);return r.behavior=N$2(),this.fetchQuery(r)},n.prefetchInfiniteQuery=function(o,a,s){return this.fetchInfiniteQuery(o,a,s).then(tA).catch(tA)},n.cancelMutations=function(){var o=this,a=wl.batch(function(){return o.mutationCache.getAll().map(function(s){return s.cancel()})});return Promise.all(a).then(tA).catch(tA)},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 $I(o)===$I(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 IN(o,s.queryKey)}))==null?void 0:a.defaultOptions:void 0},n.setMutationDefaults=function(o,a){var s=this.mutationDefaults.find(function(r){return $I(o)===$I(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 IN(o,s.mutationKey)}))==null?void 0:a.defaultOptions:void 0},n.defaultQueryOptions=function(o){if(o!=null&&o._defaulted)return o;var a=$s({},this.defaultOptions.queries,this.getQueryDefaults(o==null?void 0:o.queryKey),o,{_defaulted:!0});return!a.queryHash&&a.queryKey&&(a.queryHash=rW(a.queryKey,a)),a},n.defaultQueryObserverOptions=function(o){return this.defaultQueryOptions(o)},n.defaultMutationOptions=function(o){return o!=null&&o._defaulted?o:$s({},this.defaultOptions.mutations,this.getMutationDefaults(o==null?void 0:o.mutationKey),o,{_defaulted:!0})},n.clear=function(){this.queryCache.clear(),this.mutationCache.clear()},t}(),O$2=function(t){qI(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),Ps2(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},i.onUnsubscribe=function(){this.listeners.length||this.destroy()},i.shouldFetchOnReconnect=function(){return iW(this.currentQuery,this.options,this.options.refetchOnReconnect)},i.shouldFetchOnWindowFocus=function(){return iW(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&&Zs2(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($s({},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(tA)),s},i.updateStaleTimeout=function(){var a=this;if(this.clearStaleTimeout(),!(EN||this.currentResult.isStale||!tW(this.options.staleTime))){var s=Qs2(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,!(EN||this.options.enabled===!1||!tW(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(function(){(s.options.refetchIntervalInBackground||GQ.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,h=g.dataUpdatedAt,m=g.error,w=g.errorUpdatedAt,Q=g.isFetching,R=g.status,N=!1,O=!1,X;if(s.optimisticResults){var K=this.hasListeners(),f2=!K&&Ps2(a,s),A2=K&&Zs2(a,r,s,C);(f2||A2)&&(Q=!0,h||(R="loading"))}if(s.keepPreviousData&&!g.dataUpdateCount&&(d!=null&&d.isSuccess)&&R!=="error")X=d.data,h=d.dataUpdatedAt,R=d.status,N=!0;else if(s.select&&typeof g.data<"u")if(l&&g.data===(e==null?void 0:e.data)&&s.select===this.selectFn)X=this.selectResult;else try{this.selectFn=s.select,X=s.select(g.data),s.structuralSharing!==!1&&(X=mN(l==null?void 0:l.data,X)),this.selectResult=X,this.selectError=null}catch(j2){LN().error(j2),this.selectError=j2}else X=g.data;if(typeof s.placeholderData<"u"&&typeof X>"u"&&(R==="loading"||R==="idle")){var b2;if(l!=null&&l.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData))b2=l.data;else if(b2=typeof s.placeholderData=="function"?s.placeholderData():s.placeholderData,s.select&&typeof b2<"u")try{b2=s.select(b2),s.structuralSharing!==!1&&(b2=mN(l==null?void 0:l.data,b2)),this.selectError=null}catch(j2){LN().error(j2),this.selectError=j2}typeof b2<"u"&&(R="success",X=b2,O=!0)}this.selectError&&(m=this.selectError,X=this.selectResult,w=Date.now(),R="error");var g2={status:R,isLoading:R==="loading",isSuccess:R==="success",isError:R==="error",isIdle:R==="idle",data:X,dataUpdatedAt:h,error:m,errorUpdatedAt:w,failureCount:g.fetchFailureCount,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>f.dataUpdateCount||g.errorUpdateCount>f.errorUpdateCount,isFetching:Q,isRefetching:Q&&R!=="loading",isLoadingError:R==="error"&&g.dataUpdatedAt===0,isPlaceholderData:O,isPreviousData:N,isRefetchError:R==="error"&&g.dataUpdatedAt!==0,isStale:oW(a,s),refetch:this.refetch,remove:this.remove};return g2},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(h){return h===u}),g=l==null?void 0:l.some(function(h){return h===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,!B$2(this.currentResult,s)){var r={cache:!0};(a==null?void 0:a.listeners)!==!1&&this.shouldNotifyListeners(this.currentResult,s)&&(r.listeners=!0),this.notify($s({},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"&&!yN(a.error)&&(s.onError=!0),this.updateResult(s),this.hasListeners()&&this.updateTimers()},i.notify=function(a){var s=this;wl.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}(UB);function P$2(t,n){return n.enabled!==!1&&!t.state.dataUpdatedAt&&!(t.state.status==="error"&&n.retryOnMount===!1)}function Ps2(t,n){return P$2(t,n)||t.state.dataUpdatedAt>0&&iW(t,n,n.refetchOnMount)}function iW(t,n,i){if(n.enabled!==!1){var o=typeof i=="function"?i(t):i;return o==="always"||o!==!1&&oW(t,n)}return!1}function Zs2(t,n,i,o){return i.enabled!==!1&&(t!==n||o.enabled===!1)&&(!i.suspense||t.state.status!=="error")&&oW(t,i)}function oW(t,n){return t.isStaleByTime(n.staleTime)}var Z$2=function(t){qI(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,$s({},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:ks2(),s=$s({},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;wl.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}(UB),aW=ox();const sW=gA(aW);var F$2=sW.unstable_batchedUpdates;wl.setBatchNotifyFunction(F$2);var U$2=console;T$2(U$2);var Fs2=k9.createContext(void 0),Us2=k9.createContext(!1);function js2(t){return t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=Fs2),window.ReactQueryClientContext):Fs2}var CW=function(){var n=k9.useContext(js2(k9.useContext(Us2)));if(!n)throw new Error("No QueryClient set, use QueryClientProvider to set one");return n},j$2=function(n){var i=n.client,o=n.contextSharing,a=o===void 0?!1:o,s=n.children;k9.useEffect(function(){return i.mount(),function(){i.unmount()}},[i]);var r=js2(a);return k9.createElement(Us2.Provider,{value:a},k9.createElement(r.Provider,{value:i},s))};function z$2(){var t=!1;return{clearReset:function(){t=!1},reset:function(){t=!0},isReset:function(){return t}}}var G$2=k9.createContext(z$2()),Y$2=function(){return k9.useContext(G$2)};function zs2(t,n,i){return typeof n=="function"?n.apply(void 0,i):typeof n=="boolean"?n:!!t}function Zl(t,n,i){var o=k9.useRef(!1),a=k9.useState(0),s=a[1],r=I$2(t,n,i),C=CW(),l=k9.useRef();l.current?l.current.setOptions(r):l.current=new Z$2(C,r);var e=l.current.getCurrentResult();k9.useEffect(function(){o.current=!0;var A=l.current.subscribe(wl.batchCalls(function(){o.current&&s(function(f){return f+1})}));return function(){o.current=!1,A()}},[]);var u=k9.useCallback(function(A,f){l.current.mutate(A,f).catch(tA)},[]);if(e.error&&zs2(void 0,l.current.options.useErrorBoundary,[e.error]))throw e.error;return $s({},e,{mutate:u,mutateAsync:e.mutate})}function W$2(t,n){var i=k9.useRef(!1),o=k9.useState(0),a=o[1],s=CW(),r=Y$2(),C=s.defaultQueryObserverOptions(t);C.optimisticResults=!0,C.onError&&(C.onError=wl.batchCalls(C.onError)),C.onSuccess&&(C.onSuccess=wl.batchCalls(C.onSuccess)),C.onSettled&&(C.onSettled=wl.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=k9.useState(function(){return new n(s,C)}),e=l[0],u=e.getOptimisticResult(C);if(k9.useEffect(function(){i.current=!0,r.clearReset();var A=e.subscribe(wl.batchCalls(function(){i.current&&a(function(f){return f+1})}));return e.updateResult(),function(){i.current=!1,A()}},[r,e]),k9.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&&zs2(C.suspense,C.useErrorBoundary,[u.error,e.getCurrentQuery()]))throw u.error;return C.notifyOnChangeProps==="tracked"&&(u=e.trackResult(u,C)),u}function Qp(t,n,i){var o=vN(t,n,i);return W$2(o,O$2)}var Pd,p4=typeof window<"u"?window:void 0,Dc=typeof globalThis<"u"?globalThis:p4,Gs2=Array.prototype,Ys2=Gs2.forEach,Ws2=Gs2.indexOf,af=Dc==null?void 0:Dc.navigator,Un=Dc==null?void 0:Dc.document,_f=Dc==null?void 0:Dc.location,lW=Dc==null?void 0:Dc.fetch,uW=Dc!=null&&Dc.XMLHttpRequest&&"withCredentials"in new Dc.XMLHttpRequest?Dc.XMLHttpRequest:void 0,_s2=Dc==null?void 0:Dc.AbortController,cu=af==null?void 0:af.userAgent,Ps=p4??{},Kh={DEBUG:!1,LIB_VERSION:"1.234.1"},AW="$copy_autocapture",_$2=["$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"})(Pd||(Pd={}));var X$2=["fatal","error","warning","log","info","debug"];function rC(t,n){return t.indexOf(n)!==-1}var wN=function(t){return t.trim()},cW=function(t){return t.replace(/^\$/,"")},K$2=Array.isArray,Xs2=Object.prototype,Ks2=Xs2.hasOwnProperty,QN=Xs2.toString,Fl=K$2||function(t){return QN.call(t)==="[object Array]"},Zd=t=>typeof t=="function",Ul=t=>t===Object(t)&&!Fl(t),jB=t=>{if(Ul(t)){for(var n in t)if(Ks2.call(t,n))return!1;return!0}return!1},Qr=t=>t===void 0,fu=t=>QN.call(t)=="[object String]",fW=t=>fu(t)&&t.trim().length===0,Mp=t=>t===null,el=t=>Qr(t)||Mp(t),tc=t=>QN.call(t)=="[object Number]",Tp=t=>QN.call(t)==="[object Boolean]",J$2=t=>t instanceof FormData,q$2=t=>rC(_$2,t),Js2=t=>{var n={_log:function(i){if(p4&&(Kh.DEBUG||Ps.POSTHOG_DEBUG)&&!Qr(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=>Js2("".concat(t," ").concat(i))};return n},Ki=Js2("[PostHog.js]"),xA=Ki.createLogger,$$2=xA("[ExternalScriptsLoader]"),qs2=(t,n,i)=>{if(t.config.disable_external_dependency_loading)return $$2.warn("".concat(n," was requested but loading of external scripts is disabled.")),i("Loading of external scripts is disabled");var o=Un==null?void 0:Un.querySelectorAll("script");if(o){for(var a=0;a<o.length;a++)if(o[a].src===n)return i()}var s=()=>{if(!Un)return i("document not found");var r=Un.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=Un.querySelectorAll("body > script");l.length>0?(C=l[0].parentNode)===null||C===void 0||C.insertBefore(r,l[0]):Un.body.appendChild(r)};Un!=null&&Un.body?s():Un==null||Un.addEventListener("DOMContentLoaded",s)};function $s2(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 P4(t){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?$s2(Object(i),!0).forEach(function(o){Pt(t,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):$s2(Object(i)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(i,o))})}return t}function Pt(t,n,i){return n in t?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,t}function eC2(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}Ps.__PosthogExtensions__=Ps.__PosthogExtensions__||{},Ps.__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);qs2(t,r,i)},Ps.__PosthogExtensions__.loadSiteApp=(t,n,i)=>{var o=t.requestRouter.endpointFor("api",n);qs2(t,o,i)};var MN={};function xp(t,n,i){if(Fl(t)){if(Ys2&&t.forEach===Ys2)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)===MN)return}}}function il(t,n,i){if(!el(t)){if(Fl(t))return xp(t,n,i);if(J$2(t)){for(var o of t.entries())if(n.call(i,o[1],o[0])===MN)return}else for(var a in t)if(Ks2.call(t,a)&&n.call(i,t[a],a)===MN)return}}var du=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 xp(i,function(a){for(var s in a)a[s]!==void 0&&(t[s]=a[s])}),t},TN=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 xp(i,function(a){xp(a,function(s){t.push(s)})}),t};function xN(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 tC2=function(t){try{return t()}catch{return}},e20=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){Ki.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ki.critical(a)}}},YQ=function(t){var n={};return il(t,function(i,o){fu(i)&&i.length>0&&(n[o]=i)}),n};function t20(t,n){return i=t,o=s=>fu(s)&&!Mp(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),Fl(r)?(l=[],xp(r,e=>{l.push(s(e))})):(l={},il(r,(e,u)=>{a.has(e)||(l[u]=s(e,u))})),l);var l}(i);var i,o,a}var r20=["herokuapp.com","vercel.app","netlify.app"];function n20(t){var n=t==null?void 0:t.hostname;if(!fu(n))return!1;var i=n.split(".").slice(-2).join(".");for(var o of r20)if(i===o)return!1;return!0}function rC2(t,n){for(var i=0;i<t.length;i++)if(n(t[i]))return t[i]}function $l(t,n,i,o){var{capture:a=!1,passive:s=!0}=o??{};t==null||t.addEventListener(n,i,{capture:a,passive:s})}var nC2="$people_distinct_id",WQ="__alias",_Q="__timers",iC2="$autocapture_disabled_server_side",dW="$heatmaps_enabled_server_side",oC2="$exception_capture_enabled_server_side",aC2="$web_vitals_enabled_server_side",sC2="$dead_clicks_enabled_server_side",CC2="$web_vitals_allowed_metrics",gW="$session_recording_enabled_server_side",lC2="$console_log_recording_enabled_server_side",uC2="$session_recording_network_payload_capture",AC2="$session_recording_masking",cC2="$session_recording_canvas_recording",fC2="$replay_sample_rate",dC2="$replay_minimum_duration",gC2="$replay_script_config",RN="$sesid",XQ="$session_is_sampled",hW="$session_recording_url_trigger_activated_session",EW="$session_recording_event_trigger_activated_session",zB="$enabled_feature_flags",HN="$early_access_features",pW="$feature_flag_details",KQ="$stored_person_properties",em="$stored_group_properties",vW="$surveys",DN="$surveys_activated",SN="$flag_call_reported",Jh="$user_state",IW="$client_session_props",mW="$capture_rate_limit",bW="$initial_campaign_params",BW="$initial_referrer_info",yW="$initial_person_info",NN="$epp",hC2="__POSTHOG_TOOLBAR__",EC2="$posthog_cookieless",i20=[nC2,WQ,"__cmpns",_Q,gW,dW,RN,zB,Jh,HN,pW,em,KQ,vW,SN,IW,mW,bW,BW,NN];function pC2(t){var n;return t instanceof Element&&(t.id===hC2||!((n=t.closest)===null||n===void 0||!n.call(t,".toolbar-global-fade-container")))}function VN(t){return!!t&&t.nodeType===1}function Rp(t,n){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===n.toLowerCase()}function vC2(t){return!!t&&t.nodeType===3}function IC2(t){return!!t&&t.nodeType===11}function LW(t){return t?wN(t).split(/\s+/):[]}function mC2(t){var n=p4==null?void 0:p4.location.href;return!!(n&&t&&t.some(i=>n.match(i)))}function kN(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 LW(n)}function bC2(t){return el(t)?null:wN(t).split(/(\s+)/).filter(n=>GB(n)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ON(t){var n="";return QW(t)&&!LC2(t)&&t.childNodes&&t.childNodes.length&&il(t.childNodes,function(i){var o;vC2(i)&&i.textContent&&(n+=(o=bC2(i.textContent))!==null&&o!==void 0?o:"")}),wN(n)}function BC2(t){return Qr(t.target)?t.srcElement||null:(n=t.target)!==null&&n!==void 0&&n.shadowRoot?t.composedPath()[0]||null:t.target||null;var n}var wW=["a","button","form","input","select","textarea","label"];function yC2(t){var n=t.parentNode;return!(!n||!VN(n))&&n}function o20(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||Rp(t,"html")||!VN(t)||i!=null&&i.url_allowlist&&!mC2(i.url_allowlist)||i!=null&&i.url_ignorelist&&mC2(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&&!Rp(e,"body");)if(IC2(e.parentNode))C.push(e.parentNode.host),e=e.parentNode.host;else{if(!(l=yC2(e)))break;if(o||wW.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 h=g==null?void 0:g.element_allowlist;if(Qr(h))return!0;var m=function(R){if(h.some(N=>R.tagName.toLowerCase()===N))return{v:!0}};for(var w of d){var Q=m(w);if(typeof Q=="object")return Q.v}return!1}(C,i)||!function(d,g){var h=g==null?void 0:g.css_selector_allowlist;if(Qr(h))return!0;var m=function(R){if(h.some(N=>R.matches(N)))return{v:!0}};for(var w of d){var Q=m(w);if(typeof Q=="object")return Q.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&&(wW.indexOf(f)>-1||t.getAttribute("contenteditable")==="true")}}function QW(t){for(var n=t;n.parentNode&&!Rp(n,"body");n=n.parentNode){var i=kN(n);if(rC(i,"ph-sensitive")||rC(i,"ph-no-capture"))return!1}if(rC(kN(t),"ph-include"))return!0;var o=t.type||"";if(fu(o))switch(o.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!(fu(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 LC2(t){return!!(Rp(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Rp(t,"select")||Rp(t,"textarea")||t.getAttribute("contenteditable")==="true")}var wC2="(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})",a20=new RegExp("^(?:".concat(wC2,")$")),s20=new RegExp(wC2),QC2="\\d{3}-?\\d{2}-?\\d{4}",C20=new RegExp("^(".concat(QC2,")$")),l20=new RegExp("(".concat(QC2,")"));function GB(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(el(t)||fu(t)&&(t=wN(t),(n?a20:s20).test((t||"").replace(/[- ]/g,""))||(n?C20:l20).test(t)))}function MC2(t){var n=ON(t);return GB(n="".concat(n," ").concat(TC2(t)).trim())?n:""}function TC2(t){var n="";return t&&t.childNodes&&t.childNodes.length&&il(t.childNodes,function(i){var o;if(i&&((o=i.tagName)===null||o===void 0?void 0:o.toLowerCase())==="span")try{var a=ON(i);n="".concat(n," ").concat(a).trim(),i.childNodes&&i.childNodes.length&&(n="".concat(n," ").concat(TC2(i)).trim())}catch(s){Ki.error("[AutoCapture]",s)}}),n}function u20(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=P4(P4(P4(P4({},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 xN(l).sort((u,A)=>{var[f]=u,[d]=A;return f.localeCompare(d)}).forEach(u=>{var[A,f]=u;return e[xC2(A.toString())]=xC2(f.toString())}),r+=":",r+=xN(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:A20(i),attr_id:i.attr__id,nth_child:i.nth_child,nth_of_type:i.nth_of_type,attributes:{}};return xN(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 xC2(t){return t.replace(/"|\\"/g,'\\"')}function A20(t){var n=t.attr__class;return n?Fl(n)?n:LW(n):void 0}class RC2{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 c20=["localhost","127.0.0.1"],YB=t=>{var n=Un==null?void 0:Un.createElement("a");return Qr(n)?null:(n.href=t,n)},f20=function(t){var n,i,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",a=[];return il(t,function(s,r){Qr(s)||Qr(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)},PN=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(!Fl(i)||i.length<2)return"";var r=i[1];try{r=decodeURIComponent(r)}catch{Ki.error("Skipping decoding for malformed query param: "+r)}return r.replace(/\+/g," ")},MW=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("=");Fl(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},ZN=function(t,n){var i=t.match(new RegExp(n+"=([^&]*)"));return i?i[1]:null},HC2=xA("[AutoCapture]");function TW(t,n){return n.length>t?n.slice(0,t)+"...":n}function d20(t){if(t.previousElementSibling)return t.previousElementSibling;var n=t;do n=n.previousSibling;while(n&&!VN(n));return n}function g20(t,n,i,o){var a=t.tagName.toLowerCase(),s={tag_name:a};wW.indexOf(a)>-1&&!i&&(a.toLowerCase()==="a"||a.toLowerCase()==="button"?s.$el_text=TW(1024,MC2(t)):s.$el_text=TW(1024,ON(t)));var r=kN(t);r.length>0&&(s.classes=r.filter(function(u){return u!==""})),il(t.attributes,function(u){var A;if((!LC2(t)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(o==null||!o.includes(u.name))&&!n&&GB(u.value)&&(A=u.name,!fu(A)||A.substring(0,10)!=="_ngcontent"&&A.substring(0,7)!=="_nghost")){var f=u.value;u.name==="class"&&(f=LW(f).join(" ")),s["attr__"+u.name]=TW(1024,f)}});for(var C=1,l=1,e=t;e=d20(e);)C++,e.tagName===t.tagName&&l++;return s.nth_child=C,s.nth_of_type=l,s}function h20(t,n){for(var i,o,{e:a,maskAllElementAttributes:s,maskAllText:r,elementAttributeIgnoreList:C,elementsChainAsString:l}=n,e=[t],u=t;u.parentNode&&!Rp(u,"body");)IC2(u.parentNode)?(e.push(u.parentNode.host),u=u.parentNode.host):(e.push(u.parentNode),u=u.parentNode);var A,f=[],d={},g=!1,h=!1;if(il(e,N=>{var O=QW(N);N.tagName.toLowerCase()==="a"&&(g=N.getAttribute("href"),g=O&&g&&GB(g)&&g),rC(kN(N),"ph-no-capture")&&(h=!0),f.push(g20(N,s,r,C));var X=function(K){if(!QW(K))return{};var f2={};return il(K.attributes,function(A2){if(A2.name&&A2.name.indexOf("data-ph-capture-attribute")===0){var b2=A2.name.replace("data-ph-capture-attribute-",""),g2=A2.value;b2&&g2&&GB(g2)&&(f2[b2]=g2)}}),f2}(N);du(d,X)}),h)return{props:{},explicitNoCapture:h};if(r||(t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?f[0].$el_text=MC2(t):f[0].$el_text=ON(t)),g){var m,w;f[0].attr__href=g;var Q=(m=YB(g))===null||m===void 0?void 0:m.host,R=p4==null||(w=p4.location)===null||w===void 0?void 0:w.host;Q&&R&&Q!==R&&(A=g)}return{props:du({$event_type:a.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:u20(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 E20{constructor(n){Pt(this,"_initialized",!1),Pt(this,"_isDisabledServerSide",null),Pt(this,"rageclicks",new RC2),Pt(this,"_elementsChainAsString",!1),this.instance=n,this._elementSelectors=null}get config(){var n,i,o=Ul(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&&Un){var n=o=>{o=o||(p4==null?void 0:p4.event);try{this._captureEvent(o)}catch(a){HC2.error("Failed to capture event",a)}};if($l(Un,"submit",n,{capture:!0}),$l(Un,"change",n,{capture:!0}),$l(Un,"click",n,{capture:!0}),this.config.capture_copied_text){var i=o=>{o=o||(p4==null?void 0:p4.event),this._captureEvent(o,AW)};$l(Un,"copy",i,{capture:!0}),$l(Un,"cut",i,{capture:!0})}}}else HC2.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({[iC2]:!!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=Un==null?void 0:Un.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[iC2],a=this._isDisabledServerSide;if(Mp(a)&&!Tp(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=BC2(n);vC2(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===AW;if(a&&o20(a,n,this.config,s,s?["copy","cut"]:void 0)){var{props:r,explicitNoCapture:C}=h20(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===AW){var e,u=bC2(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 Zd(Un==null?void 0:Un.querySelectorAll)}}Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return tc(t)&&isFinite(t)&&Math.floor(t)===t});var DC2="0123456789abcdef";class FN{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 FN(s)}toString(){for(var n="",i=0;i<this.bytes.length;i++)n=n+DC2.charAt(this.bytes[i]>>>4)+DC2.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 FN(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 p20{constructor(){Pt(this,"timestamp",0),Pt(this,"counter",0),Pt(this,"random",new v20)}generate(){var n=this.generateOrAbort();if(Qr(n)){this.timestamp=0;var i=this.generateOrAbort();if(Qr(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 FN.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 SC2,NC2=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&&!Qr(p4.crypto)&&crypto.getRandomValues&&(NC2=t=>crypto.getRandomValues(t));class v20{constructor(){Pt(this,"buffer",new Uint32Array(8)),Pt(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(NC2(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var Hp=()=>I20().toString(),I20=()=>(SC2||(SC2=new p20)).generate(),m20="Thu, 01 Jan 1970 00:00:00 GMT",JQ="",b20=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function B20(t,n){if(n){var i=function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Un;if(JQ)return JQ;if(!s||["localhost","127.0.0.1"].includes(a))return"";for(var r=a.split("."),C=Math.min(r.length,8),l="dmn_chk_"+Hp(),e=new RegExp("(^|;)\\s*"+l+"=1");!JQ&&C--;){var u=r.slice(C).join("."),A=l+"=1;domain=."+u;s.cookie=A,e.test(s.cookie)&&(s.cookie=A+";expires="+m20,JQ=u)}return JQ}(t);if(!i){var o=(a=>{var s=a.match(b20);return s?s[0]:""})(t);o!==i&&Ki.info("Warning: cookie subdomain discovery mismatch",o,i),i=o}return i?"; domain=."+i:""}return""}var Dp,qh={is_supported:()=>!!Un,error:function(t){Ki.error("cookieStore error: "+t)},get:function(t){if(Un){try{for(var n=t+"=",i=Un.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(qh.get(t))||{}}catch{}return n},set:function(t,n,i,o,a){if(Un)try{var s="",r="",C=B20(Un.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&&Ki.warn("cookieStore warning: large cookie, len="+e.length),Un.cookie=e,e}catch{return}},remove:function(t,n){try{qh.set(t,"",-1,n)}catch{return}}},xW=null,Lu={is_supported:function(){if(!Mp(xW))return xW;var t=!0;if(Qr(p4))t=!1;else try{var n="__mplssupport__";Lu.set(n,"xyz"),Lu.get(n)!=='"xyz"'&&(t=!1),Lu.remove(n)}catch{t=!1}return t||Ki.error("localStorage unsupported; falling back to cookie store"),xW=t,t},error:function(t){Ki.error("localStorage error: "+t)},get:function(t){try{return p4==null?void 0:p4.localStorage.getItem(t)}catch(n){Lu.error(n)}return null},parse:function(t){try{return JSON.parse(Lu.get(t))||{}}catch{}return null},set:function(t,n){try{p4==null||p4.localStorage.setItem(t,JSON.stringify(n))}catch(i){Lu.error(i)}},remove:function(t){try{p4==null||p4.localStorage.removeItem(t)}catch(n){Lu.error(n)}}},y20=["distinct_id",RN,XQ,NN,yW],UN=P4(P4({},Lu),{},{parse:function(t){try{var n={};try{n=qh.parse(t)||{}}catch{}var i=du(n,JSON.parse(Lu.get(t)||"{}"));return Lu.set(t,i),i}catch{}return null},set:function(t,n,i,o,a,s){try{Lu.set(t,n,void 0,void 0,s);var r={};y20.forEach(C=>{n[C]&&(r[C]=n[C])}),Object.keys(r).length&&qh.set(t,r,i,o,a,s)}catch(C){Lu.error(C)}},remove:function(t,n){try{p4==null||p4.localStorage.removeItem(t),qh.remove(t,n)}catch(i){Lu.error(i)}}}),jN={},L20={is_supported:function(){return!0},error:function(t){Ki.error("memoryStorage error: "+t)},get:function(t){return jN[t]||null},parse:function(t){return jN[t]||null},set:function(t,n){jN[t]=n},remove:function(t){delete jN[t]}},tm=null,rA={is_supported:function(){if(!Mp(tm))return tm;if(tm=!0,Qr(p4))tm=!1;else try{var t="__support__";rA.set(t,"xyz"),rA.get(t)!=='"xyz"'&&(tm=!1),rA.remove(t)}catch{tm=!1}return tm},error:function(t){Ki.error("sessionStorage error: ",t)},get:function(t){try{return p4==null?void 0:p4.sessionStorage.getItem(t)}catch(n){rA.error(n)}return null},parse:function(t){try{return JSON.parse(rA.get(t))||null}catch{}return null},set:function(t,n){try{p4==null||p4.sessionStorage.setItem(t,JSON.stringify(n))}catch(i){rA.error(i)}},remove:function(t){try{p4==null||p4.sessionStorage.removeItem(t)}catch(n){rA.error(n)}}};(function(t){t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED"})(Dp||(Dp={}));class w20{constructor(n){this.instance=n}get config(){return this.instance.config}get consent(){return this.getDnt()?Dp.DENIED:this.storedConsent}isOptedOut(){return this.consent===Dp.DENIED||this.consent===Dp.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"?Dp.GRANTED:n==="0"?Dp.DENIED:Dp.PENDING}get storage(){if(!this._storage){var n=this.config.opt_out_capturing_persistence_type;this._storage=n==="localStorage"?Lu:qh;var i=n==="localStorage"?qh:Lu;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&&!!rC2([af==null?void 0:af.doNotTrack,af==null?void 0:af.msDoNotTrack,Ps.doNotTrack],n=>rC([!0,1,"1","yes"],n))}}var zN=xA("[Dead Clicks]"),Q20=()=>!0,M20=t=>{var n,i=!((n=t.instance.persistence)===null||n===void 0||!n.get_property(sC2)),o=t.instance.config.capture_dead_clicks;return Tp(o)?o:i};class VC2{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({[sC2]:n==null?void 0:n.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(n){var i,o,a;(i=Ps.__PosthogExtensions__)!==null&&i!==void 0&&i.initDeadClicksAutocapture&&n(),(o=Ps.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"dead-clicks-autocapture",s=>{s?zN.error("failed to load script",s):n()})}start(){var n;if(Un){if(!this._lazyLoadedDeadClicksAutocapture&&(n=Ps.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture){var i=Ul(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};i.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Ps.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this._lazyLoadedDeadClicksAutocapture.start(Un),zN.info("starting...")}}else zN.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,zN.info("stopping..."))}}var GN=xA("[ExceptionAutocapture]");class T20{constructor(n){var i;Pt(this,"startCapturing",()=>{var o,a,s,r,C,l;if(p4&&this.isEnabled){var e=(o=Ps.__PosthogExtensions__)===null||o===void 0||(a=o.errorWrappingFunctions)===null||a===void 0?void 0:a.wrapOnError,u=(s=Ps.__PosthogExtensions__)===null||s===void 0||(r=s.errorWrappingFunctions)===null||r===void 0?void 0:r.wrapUnhandledRejection,A=(C=Ps.__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){GN.error("failed to start",f),this.stopCapturing()}else GN.error("failed to load error wrapping functions - cannot start")}}),this.instance=n,this.remoteEnabled=!((i=this.instance.persistence)===null||i===void 0||!i.props[oC2]),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 Ul(n)?i=P4(P4({},i),n):(Qr(n)?this.remoteEnabled:n)&&(i=P4(P4({},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!Qr(this.unwrapOnError)&&!Qr(this.unwrapUnhandledRejection)&&!Qr(this.unwrapConsoleError)}startIfEnabled(){this.isEnabled&&!this.hasHandlers&&(GN.info("enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(n){var i,o;this.hasHandlers&&n(),(i=Ps.__PosthogExtensions__)===null||i===void 0||(o=i.loadExternalDependency)===null||o===void 0||o.call(i,this.instance,"exception-autocapture",a=>{if(a)return GN.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({[oC2]: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 kC2(t){return!Qr(Event)&&OC2(t,Event)}function OC2(t,n){try{return t instanceof n}catch{return!1}}function YN(t,n){return Object.prototype.toString.call(t)==="[object ".concat(n,"]")}function RW(t){return YN(t,"DOMError")}var PC2=/\(error: (.*)\)/,ZC2=50,WB="?";function HW(t,n,i,o){var a={platform:"web:javascript",filename:t,function:n==="<anonymous>"?WB:n,in_app:!0};return Qr(i)||(a.lineno=i),Qr(o)||(a.colno=o),a}var x20=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,R20=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,H20=/\((\S*)(?::(\d+))(?::(\d+))\)/,D20=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,S20=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,N20=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(`
585
585
  `),l=s;l<C.length;l++){var e=C[l];if(!(e.length>1024)){var u=PC2.test(e)?e.replace(PC2,"$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>=ZC2)break}}}return function(d){if(!d.length)return[];var g=Array.from(d);return g.reverse(),g.slice(0,ZC2).map(h=>P4(P4({},h),{},{filename:h.filename||V20(g).filename,function:h.function||WB}))}(r)}}([30,t=>{var n=x20.exec(t);if(n){var[,i,o,a]=n;return HW(i,WB,+o,+a)}var s=R20.exec(t);if(s){if(s[2]&&s[2].indexOf("eval")===0){var r=H20.exec(s[2]);r&&(s[2]=r[1],s[3]=r[2],s[4]=r[3])}var[C,l]=UC2(s[1]||WB,s[2]);return HW(l,C,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,t=>{var n=D20.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var i=S20.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]||WB;return[a,o]=UC2(a,o),HW(o,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}]);function V20(t){return t[t.length-1]||{}}var WN,FC2,DW,UC2=(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]:WB,i?"safari-extension:".concat(n):"safari-web-extension:".concat(n)]:[t,n]},k20=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function SW(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=t.stacktrace||t.stack||"",o=function(r){return r&&O20.test(r.message)?1:0}(t);try{var a=N20,s=function(r,C){var l=function(e){var u=globalThis._posthogChunkIds;if(!u)return{};var A=Object.keys(u);return DW&&A.length===FC2||(FC2=A.length,DW=A.reduce((f,d)=>{WN||(WN={});var g=WN[d];if(g)f[g[0]]=g[1];else for(var h=e(d),m=h.length-1;m>=0;m--){var w=h[m],Q=w==null?void 0:w.filename,R=u[d];if(Q&&R){f[Q]=R,WN[d]=[Q,R];break}}return f},{})),DW}(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 O20=/Minified React error #\d+;/i;function NW(t,n){var i,o,a=SW(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 VW(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=SW(n.syntheticException,1);l.length&&(C.stacktrace={frames:l,type:"raw"})}return{$exception_list:[C],$exception_level:"error"}}function P20(t){return fu(t)&&!fW(t)&&X$2.indexOf(t)>=0}function Z20(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:kC2(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=SW(n==null?void 0:n.syntheticException,1);e.length&&(l.stacktrace={frames:e,type:"raw"})}return{$exception_list:[l],$exception_level:P20(t.level)?t.level:"error"}}function F20(t,n){var{error:i,event:o}=t,a={$exception_list:[]},s=i||o;if(RW(s)||function(d){return YN(d,"DOMException")}(s)){var r=s;if(function(d){return"stack"in d}(s))a=NW(s,n);else{var C=r.name||(RW(r)?"DOMError":"DOMException"),l=r.message?"".concat(C,": ").concat(r.message):C,e=RW(r)?"DOMError":"DOMException";a=VW(l,P4(P4({},n),{},{overrideExceptionType:e,defaultExceptionMessage:l}))}return"code"in r&&(a.$exception_DOMException_code="".concat(r.code)),a}if(function(d){return YN(d,"ErrorEvent")}(s)&&s.error)return NW(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 OC2(d,Error)}}(s))return NW(s,n);if(function(d){return YN(d,"Object")}(s)||kC2(s))return Z20(s,n);if(Qr(i)&&fu(o)){var u="Error",A=o,f=o.match(k20);return f&&(u=f[1],A=f[2]),VW(A,P4(P4({},n),{},{overrideExceptionType:u,defaultExceptionMessage:A}))}return VW(s,n)}function _N(t){var n,i;return((n=JSON.stringify(t,(i=[],function(o,a){if(Ul(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 kW(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[kW({size:_N(o),data:o,sessionId:t.sessionId,windowId:t.windowId}),kW({size:_N(a),data:a,sessionId:t.sessionId,windowId:t.windowId})].flatMap(s=>s)}return[t]}var $h=(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))($h||{}),Fd=(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))(Fd||{}),OW="[SessionRecording]",PW="redacted",XN={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"]},U20=["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"],j20=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],z20=["/s/","/e/","/i/"];function jC2(t,n,i,o){if(el(t))return t;var a=(n==null?void 0:n["content-length"])||function(s){return new Blob([s]).size}(t);return fu(a)&&(a=parseInt(a)),a>i?OW+" ".concat(o," body too large to record (").concat(a," bytes)"):t}function zC2(t,n){if(el(t))return t;var i=t;return GB(i,!1)||(i=OW+" "+n+" body "+PW),il(j20,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=OW+" "+n+" body "+PW+" as might contain: "+o)}),i}var G20=(t,n)=>{var i,o,a,s={payloadSizeLimitBytes:XN.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...XN.performanceEntryTypeToObserve],payloadHostDenyList:[...n.payloadHostDenyList||[],...XN.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=jC2(f.requestBody,f.requestHeaders,a,"Request")),f!=null&&f.responseBody&&(f.responseBody=jC2(f.responseBody,f.responseHeaders,a,"Response")),f)),u=f=>{return e(((h,m)=>{var w,Q=YB(h.name),R=m.indexOf("http")===0?(w=YB(m))===null||w===void 0?void 0:w.pathname:m;R==="/"&&(R="");var N=Q==null?void 0:Q.pathname.replace(R||"","");if(!(Q&&N&&z20.some(O=>N.indexOf(O)===0)))return h})((g=(d=f).requestHeaders,el(g)||il(Object.keys(g??{}),h=>{U20.includes(h.toLowerCase())&&(g[h]=PW)}),d),t.api_host));var d,g},A=Zd(t.session_recording.maskNetworkRequestFn);return A&&Zd(t.session_recording.maskCapturedNetworkRequestFn)&&Ki.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 P4(P4({},f),{},{name:d==null?void 0:d.url})}),s.maskRequestFn=Zd(t.session_recording.maskCapturedNetworkRequestFn)?f=>{var d,g,h,m=u(f);return m&&(d=(g=(h=t.session_recording).maskCapturedNetworkRequestFn)===null||g===void 0?void 0:g.call(h,m))!==null&&d!==void 0?d:void 0}:f=>function(d){if(!Qr(d))return d.requestBody=zC2(d.requestBody,"Request"),d.responseBody=zC2(d.responseBody,"Response"),d}(u(f)),P4(P4(P4({},XN),s),{},{recordHeaders:r,recordBody:C,recordPerformance:l,recordInitialRequests:l})};function Xf(t,n,i,o,a){return n>i&&(Ki.warn("min cannot be greater than max."),n=i),tc(t)?t>i?(o&&Ki.warn(o+" cannot be greater than max: "+i+". Using max value instead."),i):t<n?(o&&Ki.warn(o+" cannot be less than min: "+n+". Using min value instead."),n):t:(o&&Ki.warn(o+" must be a number. using max or fallback. max: "+i+", fallback: "+a),Xf(a||i,n,i,o))}class Y20{constructor(n){var i,o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Pt(this,"bucketSize",100),Pt(this,"refillRate",10),Pt(this,"mutationBuckets",{}),Pt(this,"loggedTracker",{}),Pt(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]})}),Pt(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]}),Pt(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)}),Pt(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=Xf((i=this.options.refillRate)!==null&&i!==void 0?i:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=Xf((o=this.options.bucketSize)!==null&&o!==void 0?o:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}}var Kf=Uint8Array,Sc=Uint16Array,_B=Uint32Array,ZW=new Kf([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]),FW=new Kf([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]),GC2=new Kf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),YC2=function(t,n){for(var i=new Sc(31),o=0;o<31;++o)i[o]=n+=1<<t[o-1];var a=new _B(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]},WC2=YC2(ZW,2),W20=WC2[0],UW=WC2[1];W20[28]=258,UW[258]=28;for(var _C2=YC2(FW,0)[1],XC2=new Sc(32768),El=0;El<32768;++El){var rm=(43690&El)>>>1|(21845&El)<<1;rm=(61680&(rm=(52428&rm)>>>2|(13107&rm)<<2))>>>4|(3855&rm)<<4,XC2[El]=((65280&rm)>>>8|(255&rm)<<8)>>>1}var qQ=function(t,n,i){for(var o=t.length,a=0,s=new Sc(n);a<o;++a)++s[t[a]-1];var r,C=new Sc(n);for(a=0;a<n;++a)C[a]=C[a-1]+s[a-1]<<1;for(r=new Sc(o),a=0;a<o;++a)r[a]=XC2[C[t[a]-1]++]>>>15-t[a];return r},nm=new Kf(288);for(El=0;El<144;++El)nm[El]=8;for(El=144;El<256;++El)nm[El]=9;for(El=256;El<280;++El)nm[El]=7;for(El=280;El<288;++El)nm[El]=8;var KN=new Kf(32);for(El=0;El<32;++El)KN[El]=5;var _20=qQ(nm,9),X20=qQ(KN,5),KC2=function(t){return(t/8>>0)+(7&t&&1)},JC2=function(t,n,i){(i==null||i>t.length)&&(i=t.length);var o=new(t instanceof Sc?Sc:t instanceof _B?_B:Kf)(i-n);return o.set(t.subarray(n,i)),o},eE=function(t,n,i){i<<=7&n;var o=n/8>>0;t[o]|=i,t[o+1]|=i>>>8},$Q=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},jW=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 Kf(0),0];if(a==1){var r=new Kf(i[0].s+1);return r[i[0].s]=1,[r,1]}i.sort(function(O,X){return O.f-X.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 Sc(f+1),g=zW(i[u-1],d,0);if(g>n){o=0;var h=0,m=g-n,w=1<<m;for(s.sort(function(O,X){return d[X.s]-d[O.s]||O.f-X.f});o<a;++o){var Q=s[o].s;if(!(d[Q]>n))break;h+=w-(1<<g-d[Q]),d[Q]=n}for(h>>>=m;h>0;){var R=s[o].s;d[R]<n?h-=1<<n-d[R]++-1:++o}for(;o>=0&&h;--o){var N=s[o].s;d[N]==n&&(--d[N],++h)}g=n}return[new Kf(d),g]},zW=function(t,n,i){return t.s==-1?Math.max(zW(t.l,n,i+1),zW(t.r,n,i+1)):n[t.s]=i},qC2=function(t){for(var n=t.length;n&&!t[--n];);for(var i=new Sc(++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]},eM=function(t,n){for(var i=0,o=0;o<n.length;++o)i+=t[o]*n[o];return i},GW=function(t,n,i){var o=i.length,a=KC2(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)},$C2=function(t,n,i,o,a,s,r,C,l,e,u){eE(n,u++,i),++a[256];for(var A=jW(a,15),f=A[0],d=A[1],g=jW(s,15),h=g[0],m=g[1],w=qC2(f),Q=w[0],R=w[1],N=qC2(h),O=N[0],X=N[1],K=new Sc(19),f2=0;f2<Q.length;++f2)K[31&Q[f2]]++;for(f2=0;f2<O.length;++f2)K[31&O[f2]]++;for(var A2=jW(K,7),b2=A2[0],g2=A2[1],j2=19;j2>4&&!b2[GC2[j2-1]];--j2);var R2,M2,P2,G2,C0=e+5<<3,m0=eM(a,nm)+eM(s,KN)+r,H0=eM(a,f)+eM(s,h)+r+14+3*j2+eM(K,b2)+(2*K[16]+3*K[17]+7*K[18]);if(C0<=m0&&C0<=H0)return GW(n,u,t.subarray(l,l+e));if(eE(n,u,1+(H0<m0)),u+=2,H0<m0){R2=qQ(f,d),M2=f,P2=qQ(h,m),G2=h;var v0=qQ(b2,g2);for(eE(n,u,R-257),eE(n,u+5,X-1),eE(n,u+10,j2-4),u+=14,f2=0;f2<j2;++f2)eE(n,u+3*f2,b2[GC2[f2]]);u+=3*j2;for(var J2=[Q,O],U0=0;U0<2;++U0){var b0=J2[U0];for(f2=0;f2<b0.length;++f2){var k0=31&b0[f2];eE(n,u,v0[k0]),u+=b2[k0],k0>15&&(eE(n,u,b0[f2]>>>5&127),u+=b0[f2]>>>12)}}}else R2=_20,M2=nm,P2=X20,G2=KN;for(f2=0;f2<C;++f2)if(o[f2]>255){k0=o[f2]>>>18&31,$Q(n,u,R2[k0+257]),u+=M2[k0+257],k0>7&&(eE(n,u,o[f2]>>>23&31),u+=ZW[k0]);var J0=31&o[f2];$Q(n,u,P2[J0]),u+=G2[J0],J0>3&&($Q(n,u,o[f2]>>>5&8191),u+=FW[J0])}else $Q(n,u,R2[o[f2]]),u+=M2[o[f2]];return $Q(n,u,R2[256]),u+M2[256]},K20=new _B([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),J20=function(){for(var t=new _B(256),n=0;n<256;++n){for(var i=n,o=9;--o;)i=(1&i&&3988292384)^i>>>1;t[n]=i}return t}(),q20=function(){var t=4294967295;return{p:function(n){for(var i=t,o=0;o<n.length;++o)i=J20[255&i^n[o]]^i>>>8;t=i},d:function(){return 4294967295^t}}},$20=function(t,n,i,o,a){return function(s,r,C,l,e,u){var A=s.length,f=new Kf(l+A+5*(1+Math.floor(A/7e3))+e),d=f.subarray(l,f.length-e),g=0;if(!r||A<8)for(var h=0;h<=A;h+=65535){var m=h+65535;m<A?g=GW(d,g,s.subarray(h,m)):(d[h]=u,g=GW(d,g,s.subarray(h,A)))}else{for(var w=K20[r-1],Q=w>>>13,R=8191&w,N=(1<<C)-1,O=new Sc(32768),X=new Sc(N+1),K=Math.ceil(C/3),f2=2*K,A2=function(C6){return(s[C6]^s[C6+1]<<K^s[C6+2]<<f2)&N},b2=new _B(25e3),g2=new Sc(288),j2=new Sc(32),R2=0,M2=0,P2=(h=0,0),G2=0,C0=0;h<A;++h){var m0=A2(h),H0=32767&h,v0=X[m0];if(O[H0]=v0,X[m0]=H0,G2<=h){var J2=A-h;if((R2>7e3||P2>24576)&&J2>423){g=$C2(s,d,0,b2,g2,j2,M2,P2,C0,h-C0,g),P2=R2=M2=0,C0=h;for(var U0=0;U0<286;++U0)g2[U0]=0;for(U0=0;U0<30;++U0)j2[U0]=0}var b0=2,k0=0,J0=R,Y2=H0-v0&32767;if(J2>2&&m0==A2(h-Y2))for(var L3=Math.min(Q,J2)-1,M1=Math.min(32767,h),B3=Math.min(258,J2);Y2<=M1&&--J0&&H0!=v0;){if(s[h+b0]==s[h+b0-Y2]){for(var j3=0;j3<B3&&s[h+j3]==s[h+j3-Y2];++j3);if(j3>b0){if(b0=j3,k0=Y2,j3>L3)break;var w7=Math.min(Y2,j3-2),l3=0;for(U0=0;U0<w7;++U0){var c7=h-Y2+U0+32768&32767,T3=c7-O[c7]+32768&32767;T3>l3&&(l3=T3,v0=c7)}}}Y2+=(H0=v0)-(v0=O[H0])+32768&32767}if(k0){b2[P2++]=268435456|UW[b0]<<18|_C2[k0];var y6=31&UW[b0],t6=31&_C2[k0];M2+=ZW[y6]+FW[t6],++g2[257+y6],++j2[t6],G2=h+b0,++R2}else b2[P2++]=s[h],++g2[s[h]]}}g=$C2(s,d,u,b2,g2,j2,M2,P2,C0,h-C0,g)}return JC2(f,0,l+KC2(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)},YW=function(t,n,i){for(;i;++n)t[n]=i,i>>>=8},e00=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&&YW(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)}},t00=function(t){return 10+(t.filename&&t.filename.length+1||0)};function el2(t,n){n===void 0&&(n={});var i=q20(),o=t.length;i.p(t);var a=$20(t,n,t00(n),8),s=a.length;return e00(a,n),YW(a,s-8,i.d()),YW(a,s-4,o),a}function tl2(t,n){var i=t.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var o=new Kf(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 Kf(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 JC2(o,0,a)}function r00(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<Xf(100*n,0,100)}var tM="[SessionRecording]",RA=xA(tM);function JN(){var t,n;return Ps==null||(t=Ps.__PosthogExtensions__)===null||t===void 0||(n=t.rrweb)===null||n===void 0?void 0:n.record}var n00=3e5,i00=[Fd.MouseMove,Fd.MouseInteraction,Fd.Scroll,Fd.ViewportResize,Fd.Input,Fd.TouchMove,Fd.MediaInteraction,Fd.Drag],rl2=t=>({rrwebMethod:t,enqueuedAt:Date.now(),attempt:1});function im(t){return function(n,i){for(var o="",a=0;a<n.length;){var s=n[a++];o+=String.fromCharCode(s)}return o}(el2(tl2(JSON.stringify(t))))}function nl2(t){return t.type===$h.Custom&&t.data.tag==="sessionIdle"}function il2(t,n){return n.some(i=>i.matching==="regex"&&new RegExp(i.url).test(t))}class o00{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(tM+" 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:n00}get isSampled(){var n=this.instance.get_property(XQ);return Tp(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(gW),i=!this.instance.config.disable_session_recording;return p4&&n&&i}get isConsoleLogCaptureEnabled(){var n=!!this.instance.get_property(lC2),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(cC2),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:Xf(u,0,12,"canvas recording fps",4),quality:Xf(A,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var n,i,o=this.instance.get_property(uC2),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=Ul(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(Tp(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(AC2),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 Qr(e)&&Qr(u)&&Qr(A)?void 0:{maskAllInputs:e==null||e,maskTextSelector:u,blockSelector:A}}get sampleRate(){var n=this.instance.get_property(fC2);return tc(n)?n:null}get minimumDuration(){var n=this.instance.get_property(dC2);return tc(n)?n:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":el(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":Tp(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(hW))===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(EW))===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(Pt(this,"queuedRRWebEvents",[]),Pt(this,"isIdle","unknown"),Pt(this,"_linkedFlagSeen",!1),Pt(this,"_lastActivityTimestamp",Date.now()),Pt(this,"_linkedFlag",null),Pt(this,"_removePageViewCaptureHook",void 0),Pt(this,"_onSessionIdListener",void 0),Pt(this,"_persistDecideOnSessionListener",void 0),Pt(this,"_samplingSessionListener",void 0),Pt(this,"_urlTriggers",[]),Pt(this,"_urlBlocklist",[]),Pt(this,"_urlBlocked",!1),Pt(this,"_eventTriggers",[]),Pt(this,"_removeEventTriggerCaptureHook",void 0),Pt(this,"_forceAllowLocalhostNetworkCapture",!1),Pt(this,"_onBeforeUnload",()=>{this._flushBuffer()}),Pt(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),Pt(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),Pt(this,"_onVisibilityChange",()=>{if(Un!=null&&Un.visibilityState){var a="window "+Un.visibilityState;this._tryAddCustomEvent(a,{})}}),this.instance=n,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw RA.error("started without valid sessionManager"),new Error(tM+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(tM+" 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&&RA.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),$l(p4,"beforeunload",this._onBeforeUnload),$l(p4,"offline",this._onOffline),$l(p4,"online",this._onOnline),$l(p4,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),el(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){RA.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(EW),(C=this.instance)===null||C===void 0||(l=C.persistence)===null||l===void 0||l.unregister(hW))}))):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,RA.info("stopped"))}makeSamplingDecision(n){var i,o=this.sessionId!==n,a=this.sampleRate;if(tc(a)){var s=this.isSampled,r=o||!Tp(s),C=r?r00(n,a):s;r&&(C?this._reportStarted("sampled"):RA.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({[XQ]:C})}else{var l;(l=this.instance.persistence)===null||l===void 0||l.register({[XQ]: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(),!el(this._linkedFlag)&&!this._linkedFlagSeen){var l=fu(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,e=fu(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((u,A)=>{var f=Ul(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(){tc(this.sampleRate)&&el(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,h=el(g)?null:parseFloat(g),m=(r=n.sessionRecording)===null||r===void 0?void 0:r.minimumDurationMilliseconds;o.register({[gW]:!!n.sessionRecording,[lC2]:(C=n.sessionRecording)===null||C===void 0?void 0:C.consoleLogRecordingEnabled,[uC2]:P4({capturePerformance:n.capturePerformance},(l=n.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[AC2]:(e=n.sessionRecording)===null||e===void 0?void 0:e.masking,[cC2]:{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},[fC2]:h,[dC2]:Qr(m)?null:m,[gC2]:(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(!Qr(Object.assign)&&!Qr(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var i,o;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),JN()?this._onScriptLoaded():(i=Ps.__PosthogExtensions__)===null||i===void 0||(o=i.loadExternalDependency)===null||o===void 0||o.call(i,this.instance,this.scriptName,a=>{if(a)return RA.error("could not load recorder",a);this._onScriptLoaded()}),RA.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(gC2))===null||o===void 0?void 0:o.script)||"recorder"}isInteractiveEvent(n){var i;return n.type===3&&i00.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}):RA.warn("could not emit queued rrweb event.",i,n),!1}}_tryAddCustomEvent(n,i){return this._tryRRWebMethod(rl2(()=>JN().addCustomEvent(n,i)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(rl2(()=>JN().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=P4({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=JN();if(e){this.mutationRateLimiter=(n=this.mutationRateLimiter)!==null&&n!==void 0?n:new Y20(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");RA.info(d,{node:f}),this.log(tM+" "+d,"warn")}});var u=this._gatherRRWebPlugins();this.stopRrweb=e(P4({emit:A=>{this.onRRwebEmit(A)},plugins:u},s)),this._lastActivityTimestamp=Date.now(),this.isIdle=Tp(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 RA.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=Ps.__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=Ps.__PosthogExtensions__)===null||o===void 0||(a=o.rrwebPlugins)===null||a===void 0?void 0:a.getRecordNetworkPlugin;return this.networkPayloadCapture&&Zd(C)&&(!c20.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?s.push(C(G20(this.instance.config,this.networkPayloadCapture))):RA.info("NetworkCapture not started because we are on localhost.")),s}onRRwebEmit(n){var i;if(this._processQueuedEvents(),n&&Ul(n)){if(n.type===$h.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===$h.Custom&&A.data.tag==="recording paused"}(n)){n.type===$h.FullSnapshot&&this._scheduleFullSnapshot(),n.type===$h.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&&Ul(f)&&f.type===6&&Ul(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||nl2(s)){if(nl2(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(_N(A)<1024)return A;try{if(A.type===$h.FullSnapshot)return P4(P4({},A),{},{data:im(A.data),cv:"2024-10"});if(A.type===$h.IncrementalSnapshot&&A.data.source===Fd.Mutation)return P4(P4({},A),{},{cv:"2024-10",data:P4(P4({},A.data),{},{texts:im(A.data.texts),attributes:im(A.data.attributes),removes:im(A.data.removes),adds:im(A.data.adds)})});if(A.type===$h.IncrementalSnapshot&&A.data.source===Fd.StyleSheetRule)return P4(P4({},A),{},{cv:"2024-10",data:P4(P4({},A.data),{},{adds:A.data.adds?im(A.data.adds):void 0,removes:A.data.removes?im(A.data.removes):void 0})})}catch(f){RA.error("could not compress event - will use uncompressed event",f)}return A}(s):s,u={$snapshot_bytes:_N(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=tc(i)&&i>=0,a=tc(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&&kW(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:Kh.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=il2(n,this._urlBlocklist);o&&!i?this._pauseRecording():!o&&i&&this._resumeRecording(),il2(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"?hW:EW]:this.sessionId}),this._flushBuffer(),this._reportStarted(n+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),RA.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"}),RA.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&el(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",n=>{try{this._eventTriggers.includes(n.event)&&this._activateTrigger("event")}catch(i){RA.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({[XQ]:!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}),RA.info(n.replace("_"," "),i),rC(["recording_initialized","session_id_changed"],n)||this._tryAddCustomEvent(n,i)}}var WW=xA("[SegmentIntegration]");function a00(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()||Hp();o.config.get_device_id=e,l.id()&&(o.register({distinct_id:l.id(),$device_id:e()}),o.persistence.set_property(Jh,"identified")),a()},C=s.user();"then"in C&&Zd(C.then)?C.then(l=>r(l)):r(C)})(t,()=>{i.register((o=>{Promise&&Promise.resolve||WW.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()||(WW.info("No userId set, resetting PostHog"),o.reset()),s.event.userId&&s.event.userId!==o.get_distinct_id()&&(WW.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 ol2="posthog-js";function al2(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(h=>P4(P4({},h),{},{stacktrace:h.stacktrace?P4(P4({},h.stacktrace),{},{type:"raw",frames:(h.stacktrace.frames||[]).map(m=>P4(P4({},m),{},{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 s00{constructor(n,i,o,a,s){this.name=ol2,this.setupOnce=function(r){r(al2(n,{organization:i,projectId:o,prefix:a,severityAllowList:s}))}}}var tE,C00=p4!=null&&p4.location?ZN(p4.location.hash,"__posthog")||ZN(location.hash,"state"):null,sl2="_postHogToolbarParams",Cl2=xA("[Toolbar]");(function(t){t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED"})(tE||(tE={}));class l00{constructor(n){this.instance=n}setToolbarState(n){Ps.ph_toolbar_state=n}getToolbarState(){var n;return(n=Ps.ph_toolbar_state)!==null&&n!==void 0?n:tE.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||!Un)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=C00||ZN(o.hash,"__posthog")||ZN(o.hash,"state"),l=C?tC2(()=>JSON.parse(atob(decodeURIComponent(C))))||tC2(()=>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(sl2)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token)&&(this.loadToolbar(r),!0)}catch{return!1}}_callLoadToolbar(n){var i=Ps.ph_load_toolbar||Ps.ph_load_editor;!el(i)&&Zd(i)?i(n,this.instance):Cl2.warn("No toolbar load function found")}loadToolbar(n){var i=!(Un==null||!Un.getElementById(hC2));if(!p4||i)return!1;var o=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,a=P4(P4({token:this.instance.config.token},n),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},o?{instrument:!1}:{});if(p4.localStorage.setItem(sl2,JSON.stringify(P4(P4({},a),{},{source:void 0}))),this.getToolbarState()===tE.LOADED)this._callLoadToolbar(a);else if(this.getToolbarState()===tE.UNINITIALIZED){var s,r;this.setToolbarState(tE.LOADING),(s=Ps.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"toolbar",C=>{if(C)return Cl2.error("[Toolbar] Failed to load",C),void this.setToolbarState(tE.UNINITIALIZED);this.setToolbarState(tE.LOADED),this._callLoadToolbar(a)}),$l(p4,"turbolinks:load",()=>{this.setToolbarState(tE.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 u00=xA("[TracingHeaders]");class A00{constructor(n){Pt(this,"_restoreXHRPatch",void 0),Pt(this,"_restoreFetchPatch",void 0),Pt(this,"_startCapturing",()=>{var i,o,a,s;Qr(this._restoreXHRPatch)&&((i=Ps.__PosthogExtensions__)===null||i===void 0||(o=i.tracingHeadersPatchFns)===null||o===void 0||o._patchXHR(this.instance.sessionManager)),Qr(this._restoreFetchPatch)&&((a=Ps.__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=Ps.__PosthogExtensions__)!==null&&i!==void 0&&i.tracingHeadersPatchFns&&n(),(o=Ps.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"tracing-headers",s=>{if(s)return u00.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 om=xA("[Web Vitals]"),ll2=9e5;class c00{constructor(n){var i;Pt(this,"_enabledServerSide",!1),Pt(this,"_initialized",!1),Pt(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),Pt(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((o,a)=>P4(P4({},o),{},{["$web_vitals_".concat(a.name,"_event")]:P4({},a),["$web_vitals_".concat(a.name,"_value")]:a.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),Pt(this,"_addToBuffer",o=>{var a,s=(a=this.instance.sessionManager)===null||a===void 0?void 0:a.checkAndGetSessionAndWindowId(!0);if(Qr(s))om.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();Qr(r)||(el(o==null?void 0:o.name)||el(o==null?void 0:o.value)?om.error("Invalid metric received",o):this._maxAllowedValue&&o.value>=this._maxAllowedValue?om.error("Ignoring metric with value >= "+this._maxAllowedValue,o):(this.buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Qr(this.buffer.url)&&(this.buffer.url=r),this.buffer.firstMetricTimestamp=Qr(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,o.attribution&&o.attribution.interactionTargetElement&&(o.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(P4(P4({},o),{},{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),Pt(this,"_startCapturing",()=>{var o,a,s,r,C=Ps.__PosthogExtensions__;Qr(C)||Qr(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):om.error("web vitals callbacks not loaded - not starting")}),this.instance=n,this._enabledServerSide=!((i=this.instance.persistence)===null||i===void 0||!i.props[aC2]),this.startIfEnabled()}get allowedMetrics(){var n,i,o=Ul(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 Qr(o)?((i=this.instance.persistence)===null||i===void 0?void 0:i.props[CC2])||["CLS","FCP","INP","LCP"]:o}get flushToCaptureTimeoutMs(){return(Ul(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var n=Ul(this.instance.config.capture_performance)&&tc(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:ll2;return 0<n&&n<=6e4?ll2:n}get isEnabled(){var n=Ul(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return Tp(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(om.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(n){var i=Ul(n.capturePerformance)&&!!n.capturePerformance.web_vitals,o=Ul(n.capturePerformance)?n.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[aC2]:i}),this.instance.persistence.register({[CC2]:o})),this._enabledServerSide=i,this.startIfEnabled()}loadScript(n){var i,o,a;(i=Ps.__PosthogExtensions__)!==null&&i!==void 0&&i.postHogWebVitalsCallbacks&&n(),(o=Ps.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"web-vitals",s=>{s?om.error("failed to load script",s):n()})}_currentURL(){var n=p4?p4.location.href:void 0;return n||om.error("Could not determine current URL"),n}}var f00=xA("[Heatmaps]");function ul2(t){return Ul(t)&&"clientX"in t&&"clientY"in t&&tc(t.clientX)&&tc(t.clientY)}class d00{constructor(n){var i;Pt(this,"rageclicks",new RC2),Pt(this,"_enabledServerSide",!1),Pt(this,"_initialized",!1),Pt(this,"_flushInterval",null),this.instance=n,this._enabledServerSide=!((i=this.instance.persistence)===null||i===void 0||!i.props[dW])}get flushIntervalMilliseconds(){var n=5e3;return Ul(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 Qr(this.instance.config.capture_heatmaps)?Qr(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;f00.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({[dW]: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&&Un&&($l(p4,"beforeunload",this.flush.bind(this)),$l(Un,"click",n=>this._onClick(n||(p4==null?void 0:p4.event)),{capture:!0}),$l(Un,"mousemove",n=>this._onMouseMove(n||(p4==null?void 0:p4.event)),{capture:!0}),this.deadClicksCapture=new VC2(this.instance,Q20,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&&VN(u)&&!Rp(u,"body");){if(u===e)return!1;if(rC(l,p4==null?void 0:p4.getComputedStyle(u).position))return!0;u=yC2(u)}return!1}(BC2(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(!pC2(n.target)&&ul2(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(P4(P4({},a),{},{type:"rageclick"})),this._capture(a)}}_onMouseMove(n){!pC2(n.target)&&ul2(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&&!jB(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class g00{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(!(Qr(r)||Qr(C)||Qr(l)||Qr(e)||Qr(u)||Qr(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:Xf(C/r,0,1),d=r<=1?1:Xf(l/r,0,1),g=e<=1?1:Xf(u/e,0,1),h=e<=1?1:Xf(A/e,0,1);a=du(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:h})}}return o.pathname&&(a.$prev_pageview_pathname=o.pathname),o.timestamp&&(a.$prev_pageview_duration=(n.getTime()-o.timestamp.getTime())/1e3),a}}class h00{constructor(n){this.instance=n}sendExceptionEvent(n){this.instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var Jf="Mobile",qN="iOS",Pg="Android",rM="Tablet",Al2=Pg+" "+rM,cl2="iPad",fl2="Apple",dl2=fl2+" Watch",nM="Safari",XB="BlackBerry",gl2="Samsung",hl2=gl2+"Browser",El2=gl2+" Internet",am="Chrome",E00=am+" OS",pl2=am+" "+qN,_W="Internet Explorer",vl2=_W+" "+Jf,XW="Opera",p00=XW+" Mini",KW="Edge",Il2="Microsoft "+KW,KB="Firefox",ml2=KB+" "+qN,iM="Nintendo",oM="PlayStation",JB="Xbox",bl2=Pg+" "+Jf,Bl2=Jf+" "+nM,aM="Windows",JW=aM+" Phone",yl2="Nokia",qW="Ouya",Ll2="Generic",v00=Ll2+" "+Jf.toLowerCase(),wl2=Ll2+" "+rM.toLowerCase(),$W="Konqueror",rc="(\\d+(\\.\\d+)?)",e_=new RegExp("Version/"+rc),I00=new RegExp(JB,"i"),m00=new RegExp(oM+" \\w+","i"),b00=new RegExp(iM+" \\w+","i"),t_=new RegExp(XB+"|PlayBook|BB10","i"),B00={"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"},r_,y00=(t,n)=>n&&rC(n,fl2)||function(i){return rC(i,nM)&&!rC(i,am)&&!rC(i,Pg)}(t),Ql2=function(t,n){return n=n||"",rC(t," OPR/")&&rC(t,"Mini")?p00:rC(t," OPR/")?XW:t_.test(t)?XB:rC(t,"IE"+Jf)||rC(t,"WPDesktop")?vl2:rC(t,hl2)?El2:rC(t,KW)||rC(t,"Edg/")?Il2:rC(t,"FBIOS")?"Facebook "+Jf:rC(t,"UCWEB")||rC(t,"UCBrowser")?"UC Browser":rC(t,"CriOS")?pl2:rC(t,"CrMo")||rC(t,am)?am:rC(t,Pg)&&rC(t,nM)?bl2:rC(t,"FxiOS")?ml2:rC(t.toLowerCase(),$W.toLowerCase())?$W:y00(t,n)?rC(t,Jf)?Bl2:nM:rC(t,KB)?KB:rC(t,"MSIE")||rC(t,"Trident/")?_W:rC(t,"Gecko")?KB:""},L00={[vl2]:[new RegExp("rv:"+rc)],[Il2]:[new RegExp(KW+"?\\/"+rc)],[am]:[new RegExp("("+am+"|CrMo)\\/"+rc)],[pl2]:[new RegExp("CriOS\\/"+rc)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+rc)],[nM]:[e_],[Bl2]:[e_],[XW]:[new RegExp("(Opera|OPR)\\/"+rc)],[KB]:[new RegExp(KB+"\\/"+rc)],[ml2]:[new RegExp("FxiOS\\/"+rc)],[$W]:[new RegExp("Konqueror[:/]?"+rc,"i")],[XB]:[new RegExp(XB+" "+rc),e_],[bl2]:[new RegExp("android\\s"+rc,"i")],[El2]:[new RegExp(hl2+"\\/"+rc)],[_W]:[new RegExp("(rv:|MSIE )"+rc)],Mozilla:[new RegExp("rv:"+rc)]},Ml2=[[new RegExp(JB+"; "+JB+" (.*?)[);]","i"),t=>[JB,t&&t[1]||""]],[new RegExp(iM,"i"),[iM,""]],[new RegExp(oM,"i"),[oM,""]],[t_,[XB,""]],[new RegExp(aM,"i"),(t,n)=>{if(/Phone/.test(n)||/WPDesktop/.test(n))return[JW,""];if(new RegExp(Jf).test(n)&&!/IEMobile\b/.test(n))return[aM+" "+Jf,""];var i=/Windows NT ([0-9.]+)/i.exec(n);if(i&&i[1]){var o=i[1],a=B00[o]||"";return/arm/i.test(n)&&(a="RT"),[aM,a]}return[aM,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var n=[t[3],t[4],t[5]||"0"];return[qN,n.join(".")]}return[qN,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var n="";return t&&t.length>=3&&(n=Qr(t[2])?t[3]:t[2]),["watchOS",n]}],[new RegExp("("+Pg+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Pg+")","i"),t=>{if(t&&t[2]){var n=[t[2],t[3],t[4]||"0"];return[Pg,n.join(".")]}return[Pg,""]}],[/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/,[E00,""]],[/Linux|debian/i,["Linux",""]]],Tl2=function(t){return b00.test(t)?iM:m00.test(t)?oM:I00.test(t)?JB:new RegExp(qW,"i").test(t)?qW:new RegExp("("+JW+"|WPDesktop)","i").test(t)?JW:/iPad/.test(t)?cl2:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?dl2:t_.test(t)?XB:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(yl2,"i").test(t)?yl2:/(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(Jf).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)?Pg:Al2:Pg:new RegExp("(pda|"+Jf+")","i").test(t)?v00:new RegExp(rM,"i").test(t)&&!new RegExp(rM+" pc","i").test(t)?wl2:""},$N="https?://(.*)",eV=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],w00=TN(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],eV),n_="<masked>",Ql={campaignParams:function(){var{customTrackedParams:t,maskPersonalDataProperties:n,customPersonalDataProperties:i}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!Un)return{};var o=n?TN([],eV,i||[]):[];return this._campaignParamsFromUrl(MW(Un.URL,o,n_),t)},_campaignParamsFromUrl:function(t,n){var i=w00.concat(n||[]),o={};return il(i,function(a){var s=PN(t,a);o[a]=s||null}),o},_searchEngine:function(t){return t?t.search($N+"google.([^/?]*)")===0?"google":t.search($N+"bing.com")===0?"bing":t.search($N+"yahoo.com")===0?"yahoo":t.search($N+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(t){var n=Ql._searchEngine(t),i=n!="yahoo"?"q":"p",o={};if(!Mp(n)){o.$search_engine=n;var a=Un?PN(Un.referrer,i):"";a.length&&(o.ph_keyword=a)}return o},searchInfo:function(){var t=Un==null?void 0:Un.referrer;return t?this._searchInfoFromReferrer(t):{}},browser:Ql2,browserVersion:function(t,n){var i=Ql2(t,n),o=L00[i];if(Qr(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<Ml2.length;n++){var[i,o]=Ml2[n],a=i.exec(t),s=a&&(Zd(o)?o(a,t):o);if(s)return s}return["",""]},device:Tl2,deviceType:function(t){var n=Tl2(t);return n===cl2||n===Al2||n==="Kobo"||n==="Kindle Fire"||n===wl2?rM:n===iM||n===JB||n===oM||n===qW?"Console":n===dl2?"Wearable":n?Jf:"Desktop"},referrer:function(){return(Un==null?void 0:Un.referrer)||"$direct"},referringDomain:function(){var t;return Un!=null&&Un.referrer&&((t=YB(Un.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?TN([],eV,n||[]):[],o=_f==null?void 0:_f.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:o?MW(o,i,n_):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=YB(i))===null||n===void 0?void 0:n.host};if(o){a.$current_url=o;var s=YB(o);a.$host=s==null?void 0:s.host,a.$pathname=s==null?void 0:s.pathname;var r=this._campaignParamsFromUrl(o);du(a,r)}if(i){var C=this._searchInfoFromReferrer(i);du(a,C)}return a},initialPersonPropsFromInfo:function(t){var n=this.personPropsFromInfo(t),i={};return il(n,function(o,a){i["$initial_".concat(cW(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(!cu)return{};var i=t?TN([],eV,n||[]):[],[o,a]=Ql.os(cu);return du(YQ({$os:o,$os_version:a,$browser:Ql.browser(cu,navigator.vendor),$device:Ql.device(cu),$device_type:Ql.deviceType(cu),$timezone:Ql.timezone(),$timezone_offset:Ql.timezoneOffset()}),{$current_url:MW(_f==null?void 0:_f.href,i,n_),$host:_f==null?void 0:_f.host,$pathname:_f==null?void 0:_f.pathname,$raw_user_agent:cu.length>1e3?cu.substring(0,997)+"...":cu,$browser_version:Ql.browserVersion(cu,navigator.vendor),$browser_language:Ql.browserLanguage(),$browser_language_prefix:Ql.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:Kh.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(!cu)return{};var[t,n]=Ql.os(cu);return du(YQ({$os:t,$os_version:n,$browser:Ql.browser(cu,navigator.vendor)}),{$browser_version:Ql.browserVersion(cu,navigator.vendor)})}},Zg=xA("[FeatureFlags]"),i_="$active_feature_flags",qB="$override_feature_flags",xl2="$feature_flag_payloads",sM="$override_feature_flag_payloads",Rl2="$feature_flag_request_id",Hl2=t=>{var n={};for(var[i,o]of xN(t||{}))o&&(n[i]=o);return n},Q00=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]}))):Zg.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"})(r_||(r_={}));class M00{constructor(n){Pt(this,"_override_warning",!1),Pt(this,"_hasLoadedFlags",!1),Pt(this,"_requestInFlight",!1),Pt(this,"_reloadingDisabled",!1),Pt(this,"_additionalReloadRequested",!1),Pt(this,"_decideCalled",!1),Pt(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(pW),i=this.instance.get_property(qB),o=this.instance.get_property(sM);if(!o&&!i)return n||{};var a=du({},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=Qr(u)?(C=e==null?void 0:e.enabled)!==null&&C!==void 0&&C:!!u,f=Qr(u)?e.variant:typeof u=="string"?u:void 0,d=o==null?void 0:o[r],g=P4(P4({},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=P4(P4({},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||(Zg.warn(" Overriding feature flag details!",{flagDetails:n,overriddenPayloads:o,finalDetails:a}),this._override_warning=!0),a}getFlagVariants(){var n=this.instance.get_property(zB),i=this.instance.get_property(qB);if(!i)return n||{};for(var o=du({},n),a=Object.keys(i),s=0;s<a.length;s++)o[a[s]]=i[a[s]];return this._override_warning||(Zg.warn(" Overriding feature flags!",{enabledFlags:n,overriddenFlags:i,finalFlags:o}),this._override_warning=!0),o}getFlagPayloads(){var n=this.instance.get_property(xl2),i=this.instance.get_property(sM);if(!i)return n||{};for(var o=du({},n||{}),a=Object.keys(i),s=0;s<a.length;s++)o[a[s]]=i[a[s]];return this._override_warning||(Zg.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:P4(P4({},((i=this.instance.persistence)===null||i===void 0?void 0:i.get_initial_props())||{}),this.instance.get_property(KQ)||{}),group_properties:this.instance.get_property(em)};(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=Ql.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:Pd.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(r_.FeatureFlags)?Zg.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(Rl2)||void 0,r=this.instance.get_property(SN)||{};if((i.send_event||!("send_event"in i))&&(!(n in r)||!r[n].includes(a))){var C,l,e,u,A,f,d,g,h,m,w;Fl(r[n])?r[n].push(a):r[n]=[a],(C=this.instance.persistence)===null||C===void 0||C.register({[SN]:r});var Q=this.getFeatureFlagDetails(n),R={$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};Qr(Q==null||(f=Q.metadata)===null||f===void 0?void 0:f.version)||(R.$feature_flag_version=Q.metadata.version);var N,O=(d=Q==null||(g=Q.reason)===null||g===void 0?void 0:g.description)!==null&&d!==void 0?d:Q==null||(h=Q.reason)===null||h===void 0?void 0:h.code;O&&(R.$feature_flag_reason=O),Q!=null&&(m=Q.metadata)!==null&&m!==void 0&&m.id&&(R.$feature_flag_id=Q.metadata.id),Qr(Q==null?void 0:Q.original_variant)&&Qr(Q==null?void 0:Q.original_enabled)||(R.$feature_flag_original_response=Qr(Q.original_variant)?Q.original_enabled:Q.original_variant),Q!=null&&(w=Q.metadata)!==null&&w!==void 0&&w.original_payload&&(R.$feature_flag_original_payload=Q==null||(N=Q.metadata)===null||N===void 0?void 0:N.original_payload),this.instance.capture("$feature_flag_called",R)}return o}Zg.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:Pd.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);Zg.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=Q00(r),f=A.flags,d=A.featureFlags,g=A.featureFlagPayloads;if(d){var h=r.requestId;if(Fl(d)){Zg.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(d)for(var w=0;w<d.length;w++)m[d[w]]=!0;C&&C.register({[i_]:d,[zB]:m})}else{var Q=d,R=g,N=f;r.errorsWhileComputingFlags&&(Q=P4(P4({},l),Q),R=P4(P4({},e),R),N=P4(P4({},u),N)),C&&C.register(P4({[i_]:Object.keys(Hl2(Q)),[zB]:Q||{},[xl2]:R||{},[pW]:N||{}},h?{[Rl2]:h}:{}))}}})(n,this.instance.persistence,o,a,s),this._fireFeatureFlagsCallbacks(i)}}override(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];Zg.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:n,suppressWarning:i})}overrideFeatureFlags(n){if(!this.instance.__loaded||!this.instance.persistence)return Zg.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(n===!1)return this.instance.persistence.unregister(qB),this.instance.persistence.unregister(sM),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(qB);else if(o.flags)if(Fl(o.flags)){for(var a={},s=0;s<o.flags.length;s++)a[o.flags[s]]=!0;this.instance.persistence.register({[qB]:a})}else this.instance.persistence.register({[qB]:o.flags})}return"payloads"in o&&(o.payloads===!1?this.instance.persistence.unregister(sM):o.payloads&&this.instance.persistence.register({[sM]: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(HN)||[]).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=P4(P4({},this.getFlagVariants()),{},{[n]:i});(o=this.instance.persistence)===null||o===void 0||o.register({[i_]:Object.keys(Hl2(C)),[zB]: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(HN),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({[HN]: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(KQ)||{};this.instance.register({[KQ]:P4(P4({},o),n)}),i&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(KQ)}setGroupPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],o=this.instance.get_property(em)||{};Object.keys(o).length!==0&&Object.keys(o).forEach(a=>{o[a]=P4(P4({},o[a]),n[a]),delete n[a]}),this.instance.register({[em]:P4(P4({},o),n)}),i&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(n){if(n){var i=this.instance.get_property(em)||{};this.instance.register({[em]:P4(P4({},i),{},{[n]:{}})})}else this.instance.unregister(em)}}var T00=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class o_{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&&Ki.info("Persistence loaded",n.persistence,P4({},this.props)),this.update_config(n,n),this.save()}buildStorage(n){T00.indexOf(n.persistence.toLowerCase())===-1&&(Ki.critical("Unknown persistence type "+n.persistence+"; falling back to localStorage+cookie"),n.persistence="localStorage+cookie");var i=n.persistence.toLowerCase();return i==="localstorage"&&Lu.is_supported()?Lu:i==="localstorage+cookie"&&UN.is_supported()?UN:i==="sessionstorage"&&rA.is_supported()?rA:i==="memory"?L20:i==="cookie"?qh:UN.is_supported()?UN:qh}properties(){var n={};return il(this.props,function(i,o){if(o===zB&&Ul(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,(Mp(r=i20)?l:Ws2&&r.indexOf===Ws2?r.indexOf(C)!=-1:(il(r,function(e){if(l||(l=e===C))return MN}),l))||(n[o]=i);var r,C,l}),n}load(){if(!this.disabled){var n=this.storage.parse(this.name);n&&(this.props=du({},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(Ul(n)){Qr(i)&&(i="None"),this.expire_days=Qr(o)?this.default_expiry:o;var a=!1;if(il(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(Ul(n)){this.expire_days=Qr(i)?this.default_expiry:i;var o=!1;if(il(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=Ql.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});jB(YQ(n))||this.register(n),this.campaign_params_saved=!0}}update_search_keyword(){this.register(Ql.searchInfo())}update_referrer_info(){this.register_once(Ql.referrerInfo(),void 0)}set_initial_person_info(){this.props[bW]||this.props[BW]||this.register_once({[yW]:Ql.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return YQ({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var n={};il([BW,bW],a=>{var s=this.props[a];s&&il(s,function(r,C){n["$initial_"+cW(C)]=r})});var i=this.props[yW];if(i){var o=Ql.initialPersonPropsFromInfo(i);du(n,o)}return n}safe_merge(n){return il(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[_Q]||{};o[n]=i,this.props[_Q]=o,this.save()}remove_event_timer(n){var i=(this.props[_Q]||{})[n];return Qr(i)||(delete this.props[_Q][n],this.save()),i}get_property(n){return this.props[n]}set_property(n,i){this.props[n]=i,this.save()}}var Dl2,jl,Sl2,sm,Nl2,Vl2,a_,kl2,Ol2,Pl2,Zl2,Fl2,s_={},Ul2=[],x00=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,C_=Array.isArray;function Sp(t,n){for(var i in n)t[i]=n[i];return t}function jl2(t){var n=t.parentNode;n&&n.removeChild(t)}function l_(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??++Sl2,__i:-1,__u:0};return a==null&&jl.vnode!=null&&jl.vnode(s),s}function u_(t){return t.children}function tV(t,n){this.props=t,this.context=n}function $B(t,n){if(n==null)return t.__?$B(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"?$B(t):null}function zl2(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 zl2(t)}}function A_(t){(!t.__d&&(t.__d=!0)&&sm.push(t)&&!rV.__r++||Nl2!==jl.debounceRendering)&&((Nl2=jl.debounceRendering)||Vl2)(rV)}function rV(){var t,n,i,o,a,s,r,C,l;for(sm.sort(a_);t=sm.shift();)t.__d&&(n=sm.length,o=void 0,s=(a=(i=t).__v).__e,C=[],l=[],(r=i.__P)&&((o=Sp({},a)).__v=a.__v+1,jl.vnode&&jl.vnode(o),Kl2(r,o,a,i.__n,r.ownerSVGElement!==void 0,32&a.__u?[s]:null,C,s??$B(a),!!(32&a.__u),l),o.__.__k[o.__i]=o,D00(C,o,l),o.__e!=s&&zl2(o)),sm.length>n&&sm.sort(a_));rV.__r=0}function Gl2(t,n,i,o,a,s,r,C,l,e,u){var A,f,d,g,h,m=o&&o.__k||Ul2,w=n.length;for(i.__d=l,R00(i,n,m),l=i.__d,A=0;A<w;A++)(d=i.__k[A])!=null&&typeof d!="boolean"&&typeof d!="function"&&(f=d.__i===-1?s_:m[d.__i]||s_,d.__i=A,Kl2(t,d,f,a,s,r,C,l,e,u),g=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&c_(f.ref,null,d),u.push(d.ref,d.__c||g,d)),h==null&&g!=null&&(h=g),65536&d.__u||f.__k===d.__k?l=Yl2(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=h}function R00(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?l_(null,a,null,null,a):C_(a)?l_(u_,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?l_(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a)!=null?(a.__=t,a.__b=t.__b+1,C=H00(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=$B(s)),f_(s,s,!1),i[o]=null,u--);if(u)for(o=0;o<e;o++)(s=i[o])!=null&&(131072&s.__u)==0&&(s.__e==t.__d&&(t.__d=$B(s)),f_(s,s))}function Yl2(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=Yl2(o[a],n,i));return n}return t.__e!=n&&(i.insertBefore(t.__e,n||null),n=t.__e),n&&n.nextSibling}function H00(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)==0?1:0))for(;r>=0||C<n.length;){if(r>=0){if((l=n[r])&&(131072&l.__u)==0&&a==l.key&&s===l.type)return r;r--}if(C<n.length){if((l=n[C])&&(131072&l.__u)==0&&a==l.key&&s===l.type)return C;C++}}return-1}function Wl2(t,n,i){n[0]==="-"?t.setProperty(n,i??""):t[n]=i==null?"":typeof i!="number"||x00.test(n)?i:i+"px"}function nV(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||Wl2(t.style,n,"");if(i)for(n in i)o&&i[n]===o[n]||Wl2(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?Xl2:_l2,s)):t.removeEventListener(n,s?Xl2:_l2,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 _l2(t){var n=this.l[t.type+!1];if(t.t){if(t.t<=n.u)return}else t.t=Date.now();return n(jl.event?jl.event(t):t)}function Xl2(t){return this.l[t.type+!0](jl.event?jl.event(t):t)}function Kl2(t,n,i,o,a,s,r,C,l,e){var u,A,f,d,g,h,m,w,Q,R,N,O,X,K,f2,A2=n.type;if(n.constructor!==void 0)return null;128&i.__u&&(l=!!(32&i.__u),s=[C=n.__e=i.__e]),(u=jl.__b)&&u(n);e:if(typeof A2=="function")try{if(w=n.props,Q=(u=A2.contextType)&&o[u.__c],R=u?Q?Q.props.value:u.__:o,i.__c?m=(A=n.__c=i.__c).__=A.__E:("prototype"in A2&&A2.prototype.render?n.__c=A=new A2(w,R):(n.__c=A=new tV(w,R),A.constructor=A2,A.render=N00),Q&&Q.sub(A),A.props=w,A.state||(A.state={}),A.context=R,A.__n=o,f=A.__d=!0,A.__h=[],A._sb=[]),A.__s==null&&(A.__s=A.state),A2.getDerivedStateFromProps!=null&&(A.__s==A.state&&(A.__s=Sp({},A.__s)),Sp(A.__s,A2.getDerivedStateFromProps(w,A.__s))),d=A.props,g=A.state,A.__v=n,f)A2.getDerivedStateFromProps==null&&A.componentWillMount!=null&&A.componentWillMount(),A.componentDidMount!=null&&A.__h.push(A.componentDidMount);else{if(A2.getDerivedStateFromProps==null&&w!==d&&A.componentWillReceiveProps!=null&&A.componentWillReceiveProps(w,R),!A.__e&&(A.shouldComponentUpdate!=null&&A.shouldComponentUpdate(w,A.__s,R)===!1||n.__v===i.__v)){for(n.__v!==i.__v&&(A.props=w,A.state=A.__s,A.__d=!1),n.__e=i.__e,n.__k=i.__k,n.__k.forEach(function(b2){b2&&(b2.__=n)}),N=0;N<A._sb.length;N++)A.__h.push(A._sb[N]);A._sb=[],A.__h.length&&r.push(A);break e}A.componentWillUpdate!=null&&A.componentWillUpdate(w,A.__s,R),A.componentDidUpdate!=null&&A.__h.push(function(){A.componentDidUpdate(d,g,h)})}if(A.context=R,A.props=w,A.__P=t,A.__e=!1,O=jl.__r,X=0,"prototype"in A2&&A2.prototype.render){for(A.state=A.__s,A.__d=!1,O&&O(n),u=A.render(A.props,A.state,A.context),K=0;K<A._sb.length;K++)A.__h.push(A._sb[K]);A._sb=[]}else do A.__d=!1,O&&O(n),u=A.render(A.props,A.state,A.context),A.state=A.__s;while(A.__d&&++X<25);A.state=A.__s,A.getChildContext!=null&&(o=Sp(Sp({},o),A.getChildContext())),f||A.getSnapshotBeforeUpdate==null||(h=A.getSnapshotBeforeUpdate(d,g)),Gl2(t,C_(f2=u!=null&&u.type===u_&&u.key==null?u.props.children:u)?f2:[f2],n,i,o,a,s,r,C,l,e),A.base=n.__e,n.__u&=-161,A.__h.length&&r.push(A),m&&(A.__E=A.__=null)}catch(b2){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),jl.__e(b2,n,i)}else s==null&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=S00(i.__e,n,i,o,a,s,r,l,e);(u=jl.diffed)&&u(n)}function D00(t,n,i){n.__d=void 0;for(var o=0;o<i.length;o++)c_(i[o],i[++o],i[++o]);jl.__c&&jl.__c(n,t),t.some(function(a){try{t=a.__h,a.__h=[],t.some(function(s){s.call(a)})}catch(s){jl.__e(s,a.__v)}})}function S00(t,n,i,o,a,s,r,C,l){var e,u,A,f,d,g,h,m=i.props,w=n.props,Q=n.type;if(Q==="svg"&&(a=!0),s!=null){for(e=0;e<s.length;e++)if((d=s[e])&&"setAttribute"in d==!!Q&&(Q?d.localName===Q:d.nodeType===3)){t=d,s[e]=null;break}}if(t==null){if(Q===null)return document.createTextNode(w);t=a?document.createElementNS("http://www.w3.org/2000/svg",Q):document.createElement(Q,w.is&&w),s=null,C=!1}if(Q===null)m===w||C&&t.data===w||(t.data=w);else{if(s=s&&Dl2.call(t.childNodes),m=i.props||s_,!C&&s!=null)for(m={},e=0;e<t.attributes.length;e++)m[(d=t.attributes[e]).name]=d.value;for(e in m)d=m[e],e=="children"||(e=="dangerouslySetInnerHTML"?A=d:e==="key"||e in w||nV(t,e,null,d,a));for(e in w)d=w[e],e=="children"?f=d:e=="dangerouslySetInnerHTML"?u=d:e=="value"?g=d:e=="checked"?h=d:e==="key"||C&&typeof d!="function"||m[e]===d||nV(t,e,d,m[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=""),Gl2(t,C_(f)?f:[f],n,i,o,a&&Q!=="foreignObject",s,r,s?s[0]:i.__k&&$B(i,0),C,l),s!=null)for(e=s.length;e--;)s[e]!=null&&jl2(s[e]);C||(e="value",g!==void 0&&(g!==t[e]||Q==="progress"&&!g||Q==="option"&&g!==m[e])&&nV(t,e,g,m[e],!1),e="checked",h!==void 0&&h!==t[e]&&nV(t,e,h,m[e],!1))}return t}function c_(t,n,i){try{typeof t=="function"?t(n):t.current=n}catch(o){jl.__e(o,i)}}function f_(t,n,i){var o,a;if(jl.unmount&&jl.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||c_(o,null,n)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){jl.__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]&&f_(o[a],n,i||typeof t.type!="function");i||t.__e==null||jl2(t.__e),t.__=t.__e=t.__d=void 0}function N00(t,n,i){return this.constructor(t,i)}Dl2=Ul2.slice,jl={__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}},Sl2=0,tV.prototype.setState=function(t,n){var i;i=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Sp({},this.state),typeof t=="function"&&(t=t(Sp({},i),this.props)),t&&Sp(i,t),t!=null&&this.__v&&(n&&this._sb.push(n),A_(this))},tV.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),A_(this))},tV.prototype.render=u_,sm=[],Vl2=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,a_=function(t,n){return t.__v.__b-n.__v.__b},rV.__r=0,kl2=0,function(t){t.Popover="popover",t.API="api",t.Widget="widget"}(Ol2||(Ol2={})),function(t){t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link"}(Pl2||(Pl2={})),function(t){t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question"}(Zl2||(Zl2={})),function(t){t.Once="once",t.Recurring="recurring",t.Always="always"}(Fl2||(Fl2={})),function(t,n){var i={__c:n="__cC"+kl2++,__: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,A_(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 ey=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 Jl2{constructor(){Pt(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 Cm{constructor(n){Pt(this,"_debugEventEmitter",new Jl2),Pt(this,"checkStep",(i,o)=>this.checkStepEvent(i,o)&&this.checkStepUrl(i,o)&&this.checkStepElement(i,o)),Pt(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(!Qr((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(!Qr((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"||!Cm.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&&ey(n,i);case"exact":return i===n;case"contains":var a=Cm.escapeStringRegexp(i).replace(/_/g,".").replace(/%/g,".*");return ey(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&&!Cm.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&&!Cm.matchString(s.text||"",i==null?void 0:i.text,(i==null?void 0:i.text_matching)||"exact")&&!Cm.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 CM{constructor(n){this.instance=n,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(n){var i;Qr((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 Cm(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 h=this.actionToSurveys.get(g.name);h&&h.push(o.id),this.actionToSurveys.set(g.name,h||[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[DN])||[];if(CM.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[DN])||[];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({[DN]:[...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[DN];return o||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}Pt(CM,"SURVEY_SHOWN_EVENT_NAME","survey shown");var nA=xA("[Surveys]"),ql2={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=>ey(n,i)),not_regex:(t,n)=>t.every(i=>!ey(n,i)),exact:(t,n)=>t.some(i=>n===i),is_not:(t,n)=>t.every(i=>n!==i)};function $l2(t){return t??"icontains"}class V00{constructor(n){Pt(this,"_isFetchingSurveys",!1),Pt(this,"_isInitializingSurveys",!1),Pt(this,"_surveyCallbacks",[]),this.instance=n,this._surveyEventReceiver=null}onRemoteConfig(n){var i=n.surveys;if(el(i))return nA.warn("Decide not loaded yet. Not loading surveys.");var o=Fl(i);this._hasSurveys=o?i.length>0:i,nA.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)nA.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)nA.info("Disabled. Not loading surveys.");else{var n=Ps==null?void 0:Ps.__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 CM(this.instance),nA.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 nA.error("Could not load surveys script",s),void(this._isInitializingSurveys=!1);this._surveyManager=n.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new CM(this.instance),nA.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var a="PostHog loadExternalDependency extension not found. Cannot load remote config.";nA.error(a),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:a})}}}catch(s){throw nA.error("Error initializing surveys",s),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),s}}else nA.info("No surveys to load.");else nA.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 nA.info("Disabled. Not loading surveys."),n([]);var o=this.instance.get_property(vW);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 nA.error(C),n([],{isLoaded:!1,error:C})}var l,e=a.json.surveys||[],u=e.filter(A=>{var f,d,g,h,m,w,Q,R,N,O,X,K;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)&&((h=A.conditions)===null||h===void 0||(m=h.events)===null||m===void 0||(w=m.values)===null||w===void 0?void 0:w.length)>0||((Q=A.conditions)===null||Q===void 0?void 0:Q.actions)&&((R=A.conditions)===null||R===void 0||(N=R.actions)===null||N===void 0?void 0:N.values)&&((O=A.conditions)===null||O===void 0||(X=O.actions)===null||X===void 0||(K=X.values)===null||K===void 0?void 0:K.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({[vW]: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){nA.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,h,m;if((g=d.conditions)===null||g===void 0||!g.url)return!0;var w=p4==null||(h=p4.location)===null||h===void 0?void 0:h.href;if(!w)return!1;var Q=[d.conditions.url];return ql2[$l2((m=d.conditions)===null||m===void 0?void 0:m.urlMatchType)](Q,w)}(l),A=(e=l.conditions)===null||e===void 0||!e.selector||(Un==null?void 0:Un.querySelector(l.conditions.selector)),f=function(d){var g,h,m;if((g=d.conditions)===null||g===void 0||!g.deviceTypes||((h=d.conditions)===null||h===void 0?void 0:h.deviceTypes.length)===0)return!0;if(!cu)return!1;var w=Ql.deviceType(cu);return ql2[$l2((m=d.conditions)===null||m===void 0?void 0:m.deviceTypesMatchType)](d.conditions.deviceTypes,w)}(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,h,m,w;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 Q=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),R=this.isSurveyFeatureFlagEnabled(l.targeting_flag_key),N=((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,O=((g=(h=l.conditions)===null||h===void 0||(m=h.actions)===null||m===void 0||(w=m.values)===null||w===void 0?void 0:w.length)!==null&&g!==void 0?g:0)>0,X=!N&&!O||(r==null?void 0:r.includes(l.id)),K=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),f2=this.checkFlags(l);return Q&&R&&K&&X&&f2});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 el((i=Ps.__PosthogExtensions__)===null||i===void 0?void 0:i.canActivateRepeatedly)?(nA.warn("init was not called"),!1):Ps.__PosthogExtensions__.canActivateRepeatedly(n)}canRenderSurvey(n){el(this._surveyManager)?nA.warn("init was not called"):this.getSurveys(i=>{var o=i.filter(a=>a.id===n)[0];this._surveyManager.canRenderSurvey(o)})}renderSurvey(n,i){el(this._surveyManager)?nA.warn("init was not called"):this.getSurveys(o=>{var a=o.filter(s=>s.id===n)[0];this._surveyManager.renderSurvey(a,Un==null?void 0:Un.querySelector(i))})}}var eu2=xA("[RateLimiter]");class k00{constructor(n){var i,o;Pt(this,"serverLimits",{}),Pt(this,"lastEventRateLimited",!1),Pt(this,"checkForLimiting",a=>{var s=a.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(r=>{eu2.info("".concat(r||"events"," is quota limited.")),this.serverLimits[r]=new Date().getTime()+6e4})}catch(r){return void eu2.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(mW))!==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(mW,r),{isRateLimited:C,remainingTokens:r.tokens}}isServerRateLimited(n){var i=this.serverLimits[n||"events"]||!1;return i!==!1&&new Date().getTime()<i}}var lm=xA("[RemoteConfig]");class O00{constructor(n){this.instance=n}get remoteConfig(){var n,i;return(n=Ps._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=Ps.__PosthogExtensions__)!==null&&i!==void 0&&i.loadExternalDependency?(o=Ps.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"remote-config",()=>n(this.remoteConfig)):(lm.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 lm.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void lm.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(n=>{if(!n)return lm.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){lm.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()):lm.info("__preview_remote_config is disabled. Logging config instead",n):lm.error("Failed to fetch remote config from PostHog.")}}var P00=function(t){var n,i,o,a,s="";for(n=i=0,o=(t=(t+"").replace(/\r\n/g,`
586
586
  `).replace(/\r/g,`
587
- `)).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),Mp(C)||(i>n&&(s+=t.substring(n,i)),s+=C,n=i=a+1)}return i>n&&(s+=t.substring(n,t.length)),s},Z00=!!uW||!!lW,tu2="text/plain",iV=(t,n)=>{var[i,o]=t.split("?"),a=P4({},n);o==null||o.split("&").forEach(r=>{var[C]=r.split("=");delete a[C]});var s=f20(a);return s=s?(o?o+"&":"")+s:o,"".concat(i,"?").concat(s)},lM=(t,n)=>JSON.stringify(t,(i,o)=>typeof o=="bigint"?o.toString():o,n),d_=t=>{var{data:n,compression:i}=t;if(n){if(i===Pd.GZipJS){var o=el2(tl2(lM(n)),{mtime:0}),a=new Blob([o],{type:tu2});return{contentType:tu2,body:a,estimatedSize:a.size}}if(i===Pd.Base64){var s=function(l){var e,u,A,f,d,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=0,m=0,w="",Q=[];if(!l)return l;l=P00(l);do e=(d=l.charCodeAt(h++)<<16|l.charCodeAt(h++)<<8|l.charCodeAt(h++))>>18&63,u=d>>12&63,A=d>>6&63,f=63&d,Q[m++]=g.charAt(e)+g.charAt(u)+g.charAt(A)+g.charAt(f);while(h<l.length);switch(w=Q.join(""),l.length%3){case 1:w=w.slice(0,-2)+"==";break;case 2:w=w.slice(0,-1)+"="}return w}(lM(n)),r=(l=>"data="+encodeURIComponent(typeof l=="string"?l:lM(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var C=lM(n);return{contentType:"application/json",body:C,estimatedSize:new Blob([C]).size}}},uM=[];lW&&uM.push({transport:"fetch",method:t=>{var n,i,{contentType:o,body:a,estimatedSize:s}=(n=d_(t))!==null&&n!==void 0?n:{},r=new Headers;il(t.headers,function(u,A){r.append(A,u)}),o&&r.append("Content-Type",o);var C=t.url,l=null;if(_s2){var e=new _s2;l={signal:e.signal,timeout:setTimeout(()=>e.abort(),t.timeout)}}lW(C,P4({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){Ki.error(g)}(f=t.callback)===null||f===void 0||f.call(t,d)})).catch(u=>{var A;Ki.error(u),(A=t.callback)===null||A===void 0||A.call(t,{statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),uW&&uM.push({transport:"XHR",method:t=>{var n,i=new uW;i.open(t.method||"GET",t.url,!0);var{contentType:o,body:a}=(n=d_(t))!==null&&n!==void 0?n:{};il(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)}}),af!=null&&af.sendBeacon&&uM.push({transport:"sendBeacon",method:t=>{var n=iV(t.url,{beacon:"1"});try{var i,{contentType:o,body:a}=(i=d_(t))!==null&&i!==void 0?i:{},s=typeof a=="string"?new Blob([a],{type:o}):a;af.sendBeacon(n,s)}catch{}}});var g_=3e3;class F00{constructor(n,i){Pt(this,"isPaused",!0),Pt(this,"queue",[]),this.flushTimeoutMs=Xf((i==null?void 0:i.flush_interval_ms)||g_,250,5e3,"flush interval",g_),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(P4(P4({},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&&Fl(r.data)&&il(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 il(this.queue,i=>{var o,a=i,s=(a?a.batchKey:null)||a.url;Qr(n[s])&&(n[s]=P4(P4({},a),{},{data:[]})),(o=n[s].data)===null||o===void 0||o.push(a.data)}),this.queue=[],n}}var U00=["retriesPerformedSoFar"];class j00{constructor(n){Pt(this,"isPolling",!1),Pt(this,"pollIntervalMs",3e3),Pt(this,"queue",[]),this.instance=n,this.queue=[],this.areWeOnline=!0,!Qr(p4)&&"onLine"in p4.navigator&&(this.areWeOnline=p4.navigator.onLine,$l(p4,"online",()=>{this.areWeOnline=!0,this.flush()}),$l(p4,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(n){var{retriesPerformedSoFar:i}=n,o=eC2(n,U00);tc(i)&&i>0&&(o.url=iV(o.url,{retry_count:i})),this.instance._send_request(P4(P4({},o),{},{callback:a=>{var s;a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(i??0)<10?this.enqueue(P4({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)"),Ki.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(P4(P4({},n),{},{transport:"sendBeacon"}))}catch(i){Ki.error(i)}this.queue=[]}}class z00{constructor(n){Pt(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(){$l(p4,"scroll",this._updateScrollData,{capture:!0}),$l(p4,"scrollend",this._updateScrollData,{capture:!0}),$l(p4,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return p4==null?void 0:p4.document.documentElement;var n=Fl(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 G00=t=>Ql.personInfo({maskPersonalDataProperties:t==null?void 0:t.config.mask_personal_data_properties,customPersonalDataProperties:t==null?void 0:t.config.custom_personal_data_properties});class Y00{constructor(n,i,o,a){Pt(this,"_onSessionIdCallback",s=>{var r=this._getStored();if(!r||r.sessionId!==s){var C={sessionId:s,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[IW]:C})}}),this.instance=n,this._sessionIdManager=i,this._persistence=o,this._sessionSourceParamGenerator=a||G00,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[IW]}getSetOnceProps(){var n,i=(n=this._getStored())===null||n===void 0?void 0:n.props;return i?"r"in i?Ql.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 il(YQ(this.getSetOnceProps()),(i,o)=>{o==="$current_url"&&(o="url"),n["$session_entry_".concat(cW(o))]=i}),n}}var ru2=xA("[SessionId]");class W00{constructor(n,i,o){var a;if(Pt(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||Hp,this._windowIdGenerator=o||Hp;var s=this.config.persistence_name||this.config.token,r=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Xf(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=rA.parse(this._window_id_storage_key),l=rA.parse(this._primary_window_exists_storage_key);C&&!l?this._windowId=C:rA.remove(this._window_id_storage_key),rA.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){ru2.error("Invalid sessionID in bootstrap",u)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(n){return Qr(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&&rA.is_supported()}_setWindowId(n){n!==this._windowId&&(this._windowId=n,this._canUseSessionStorage()&&rA.set(this._window_id_storage_key,n))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?rA.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({[RN]:[i,n,o]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var n=this.persistence.props[RN];return Fl(n)&&n.length===2&&n.push(n[0]),n||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){$l(p4,"beforeunload",()=>{this._canUseSessionStorage()&&rA.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=tc(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(),ru2.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 _00=["$set_once","$set"],Np=xA("[SiteApps]");class X00{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=Ps._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:h}=n;return{event:P4(P4({},eC2(n,_00)),{},{properties:P4(P4(P4({},n.properties),h?{$set:P4(P4({},(i=(o=n.properties)===null||o===void 0?void 0:o.$set)!==null&&i!==void 0?i:{}),h)}:{}),g?{$set_once:P4(P4({},(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&&(Np.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,Np.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){Np.error("Error while initializing PostHog app with config id ".concat(n.id),C),s(!1)}if(a&&i.loaded)try{o()}catch(C){Np.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){Np.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 Np.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;Ps["__$$ph_site_app_".concat(e)]=s.instance,(A=Ps.__PosthogExtensions__)===null||A===void 0||(f=A.loadSiteApp)===null||f===void 0||f.call(A,s.instance,u,d=>{if(d)return Np.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 Np.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var um,K00=["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"],nu2=function(t,n){if(!t)return!1;var i=t.toLowerCase();return K00.concat(n||[]).some(o=>{var a=o.toLowerCase();return i.indexOf(a)!==-1})},iu2=function(t,n){if(!t)return!1;var i=t.userAgent;if(i&&nu2(i,n))return!0;try{var o=t==null?void 0:t.userAgentData;if(o!=null&&o.brands&&o.brands.some(a=>nu2(a==null?void 0:a.brand,n)))return!0}catch{}return!!t.webdriver};function h_(t,n,i){return lM({distinct_id:t,userPropertiesToSet:n,userPropertiesToSetOnce:i})}(function(t){t.US="us",t.EU="eu",t.CUSTOM="custom"})(um||(um={}));var ou2="i.posthog.com";class J00{constructor(n){Pt(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(ou2),".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]=um.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=um.EU:this._regionCache[this.apiHost]=um.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===um.CUSTOM)return this.apiHost+i;var o=ou2+i;switch(n){case"assets":return"https://".concat(this.region,"-assets.").concat(o);case"api":return"https://".concat(this.region,".").concat(o)}}}var q00={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&&ey(n.href,t),not_regex:(t,n)=>!!p4&&!ey(n.href,t),exact:(t,n)=>n.href===t,is_not:(t,n)=>n.href!==t};class HA{constructor(n){var i=this;Pt(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var o=arguments.length>0&&arguments[0]!==void 0&&arguments[0];i.getWebExperiments(a=>{HA.logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,a.forEach(s=>{if(s.feature_flag_key){var r;i._flagToExperiments&&(HA.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);fu(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];HA.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())HA.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(el(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();HA.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=HA.getWindowLocation();if(n!=null&&n.search){var i=PN(n==null?void 0:n.search,"__experiment_id"),o=PN(n==null?void 0:n.search,"__experiment_variant");i&&o&&(HA.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&&(HA.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!el(n.conditions)&&HA.matchUrlConditions(n)&&HA.matchUTMConditions(n)}static matchUrlConditions(n){var i;if(el(n.conditions)||el((i=n.conditions)===null||i===void 0?void 0:i.url))return!0;var o,a,s,r=HA.getWindowLocation();return!!r&&((o=n.conditions)===null||o===void 0||!o.url||q00[(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(el(n.conditions)||el((i=n.conditions)===null||i===void 0?void 0:i.utm))return!0;var o=Ql.campaignParams();if(o.utm_source){var a,s,r,C,l,e,u,A,f,d,g,h,m,w,Q,R,N=(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,O=(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,X=(f=n.conditions)===null||f===void 0||(d=f.utm)===null||d===void 0||!d.utm_medium||((g=n.conditions)===null||g===void 0||(h=g.utm)===null||h===void 0?void 0:h.utm_medium)==o.utm_medium,K=(m=n.conditions)===null||m===void 0||(w=m.utm)===null||w===void 0||!w.utm_term||((Q=n.conditions)===null||Q===void 0||(R=Q.utm)===null||R===void 0?void 0:R.utm_term)==o.utm_term;return N&&X&&K&&O}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];Ki.info("[WebExperiments] ".concat(n),o)}applyTransforms(n,i,o){this._is_bot()?HA.logInfo("Refusing to render web experiment since the viewer is a likely bot"):i!=="control"?o.forEach(a=>{if(a.selector){var s;HA.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)})}}):HA.logInfo("Control variants leave the page unmodified.")}_is_bot(){return af&&this.instance?iu2(af,this.instance.config.custom_blocked_useragents):void 0}}var AM={},E_=()=>{},ty="posthog",au2=!Z00&&(cu==null?void 0:cu.indexOf("MSIE"))===-1&&(cu==null?void 0:cu.indexOf("Mozilla"))===-1,su2=()=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:n20(Un==null?void 0:Un.location),persistence:"localStorage+cookie",persistence_name:"",loaded:E_,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:_f&&fu(_f==null?void 0:_f.search)&&_f.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;Ki.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:g_},_onCapture:E_}},Cu2=t=>{var n={};Qr(t.process_person)||(n.person_profiles=t.process_person),Qr(t.xhr_headers)||(n.request_headers=t.xhr_headers),Qr(t.cookie_name)||(n.persistence_name=t.cookie_name),Qr(t.disable_cookie)||(n.disable_persistence=t.disable_cookie),Qr(t.store_google)||(n.save_campaign_params=t.store_google),Qr(t.verbose)||(n.debug=t.verbose);var i=du({},n,t);return Fl(t.property_blacklist)&&(Qr(t.property_denylist)?i.property_denylist=t.property_blacklist:Fl(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:Ki.error("Invalid value for property_denylist config: "+t.property_denylist)),i};class $00{constructor(){Pt(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(n){Ki.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=n}}class oV{get decideEndpointWasHit(){var n,i;return(n=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&n!==void 0&&n}constructor(){Pt(this,"webPerformance",new $00),Pt(this,"_personProcessingSetOncePropertiesSent",!1),Pt(this,"version",Kh.LIB_VERSION),Pt(this,"_internalEventEmitter",new Jl2),this.config=su2(),this.SentryIntegration=s00,this.sentryIntegration=n=>function(i,o){var a=al2(i,o);return{name:ol2,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 M00(this),this.toolbar=new l00(this),this.scrollManager=new z00(this),this.pageViewManager=new g00(this),this.surveys=new V00(this),this.experiments=new HA(this),this.exceptions=new h00(this),this.rateLimiter=new k00(this),this.requestRouter=new J00(this),this.consent=new w20(this),this.people={set:(n,i,o)=>{var a=fu(n)?{[n]:i}:n;this.setPersonProperties(a),o==null||o({})},set_once:(n,i,o)=>{var a=fu(n)?{[n]:i}:n;this.setPersonProperties(void 0,a),o==null||o({})}},this.on("eventCaptured",n=>Ki.info('send "'.concat(n==null?void 0:n.event,'"'),n))}init(n,i,o){if(o&&o!==ty){var a,s=(a=AM[o])!==null&&a!==void 0?a:new oV;return s._init(n,i,o),AM[o]=s,AM[ty][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(Qr(n)||fW(n))return Ki.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 Ki.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(du({},su2(),Cu2(a),{name:s,token:n})),this.config.on_xhr_error&&Ki.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=a.disable_compression?void 0:Pd.GZipJS,this.persistence=new o_(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new o_(P4(P4({},this.config),{},{persistence:"sessionStorage"}));var r=P4({},this.persistence.props),C=P4({},this.sessionPersistence.props);if(this._requestQueue=new F00(w=>this._send_retriable_request(w),this.config.request_queue_config),this._retryQueue=new j00(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new W00(this),this.sessionPropsManager=new Y00(this,this.sessionManager,this.persistence)),new A00(this).startIfEnabledOrStop(),this.siteApps=new X00(this),(i=this.siteApps)===null||i===void 0||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new o00(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new E20(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new d00(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new c00(this),this.exceptionObserver=new T20(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new VC2(this,M20),this.deadClicksAutocapture.startIfEnabled(),Kh.DEBUG=Kh.DEBUG||this.config.debug,Kh.DEBUG&&Ki.info("Starting in debug mode",{this:this,config:a,thisC:P4({},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(Hp()),A=(l=a.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?u:a.bootstrap.distinctID;this.persistence.set_property(Jh,(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(w=>{var Q,R;return!((Q=a.bootstrap)===null||Q===void 0||(R=Q.featureFlags)===null||R===void 0||!R[w])}).reduce((w,Q)=>{var R,N;return w[Q]=((R=a.bootstrap)===null||R===void 0||(N=R.featureFlags)===null||N===void 0?void 0:N[Q])||!1,w},{}),h=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlagPayloads)||{}).filter(w=>g[w]).reduce((w,Q)=>{var R,N,O,X;return(R=a.bootstrap)!==null&&R!==void 0&&(N=R.featureFlagPayloads)!==null&&N!==void 0&&N[Q]&&(w[Q]=(O=a.bootstrap)===null||O===void 0||(X=O.featureFlagPayloads)===null||X===void 0?void 0:X[Q]),w},{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:h})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:EC2,$device_id:null},"");else if(!this.get_distinct_id()){var m=this.config.get_device_id(Hp());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(Jh,"anonymous")}return $l(p4,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),a.segment?a00(this,()=>this._loaded()):this._loaded(),Zd(this.config._onCapture)&&this.config._onCapture!==E_&&(Ki.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",w=>this.config._onCapture(w.event,w))),this}_onRemoteConfig(n){var i,o,a,s,r,C,l,e;if(!Un||!Un.body)return Ki.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=rC(n.supportedCompression,Pd.GZipJS)?Pd.GZipJS:rC(n.supportedCompression,Pd.Base64)?Pd.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){Ki.critical("`loaded` function failed",n)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new O00(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()||xp(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&&(au2?this.__request_queue.push(n):this.rateLimiter.isServerRateLimited(n.batchKey)||(n.transport=n.transport||this.config.api_transport,n.url=iV(n.url,{ip:this.config.ip?1:0}),n.headers=P4({},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=P4({},i);r.timeout=r.timeout||6e4,r.url=iV(r.url,{_:new Date().getTime().toString(),ver:Kh.LIB_VERSION,compression:r.compression});var C=(o=r.transport)!==null&&o!==void 0?o:"fetch",l=(a=(s=rC2(uM,e=>e.transport===C))===null||s===void 0?void 0:s.method)!==null&&a!==void 0?a:uM[0].method;if(!l)throw new Error("No available transport method");l(r)})(P4(P4({},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=[];xp(n,C=>{C&&(i=C[0],Fl(i)?s.push(C):Zd(C)?C.call(this):Fl(C)&&i==="alias"?o.push(C):Fl(C)&&i.indexOf("capture")!==-1&&Zd(this[i])?s.push(C):a.push(C))});var r=function(C,l){xp(C,function(e){if(Fl(e[0])){var u=l;il(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(!Qr(n)&&fu(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&&!fu(i==null?void 0:i.$current_url)&&(Ki.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=Hp(),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=t20(e,o!=null&&o._noTruncate?null:this.config.properties_string_max_length)).timestamp=C,Qr(o==null?void 0:o.timestamp)||(e.properties.$event_time_override_provided=!0,e.properties.$event_time_override_system_time=r);var A=P4(P4({},e.properties.$set),e.$set);if(jB(A)||this.setPersonPropertiesForFlags(A),!el(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}Ki.critical("This capture call is ignored due to client rate limiting.")}}else Ki.error("No event name provided to posthog.capture")}else Ki.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=P4({},i);if(r.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(r.$cookieless_mode=!0),n==="$snapshot"){var C=P4(P4({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=C.distinct_id,(!fu(r.distinct_id)&&!tc(r.distinct_id)||fW(r.distinct_id))&&Ki.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var l,e=Ql.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&&du(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(w){r.$sdk_debug_error_capturing_properties=String(w)}if(this.requestRouter.region===um.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=du(r,l),n==="$pageview"&&Un&&(r.title=Un.title),!Qr(s)){var g=o.getTime()-s;r.$duration=parseFloat((g/1e3).toFixed(3))}cu&&this.config.opt_out_useragent_filter&&(r.$browser_type=this._is_bot()?"bot":"browser"),(r=du({},e,this.persistence.properties(),this.sessionPersistence.properties(),r)).$is_identified=this._isIdentified(),Fl(this.config.property_denylist)?il(this.config.property_denylist,function(w){delete r[w]}):Ki.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var h=this.config.sanitize_properties;h&&(Ki.error("sanitize_properties is deprecated. Use before_send instead"),r=h(r,n));var m=this._hasPersonProcessing();return r.$process_person_profile=m,m&&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=du({},o,a||{},n||{}),r=this.config.sanitize_properties;return r&&(Ki.error("sanitize_properties is deprecated. Use before_send instead"),s=r(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,jB(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 Ki.uninitializedWarning("posthog.identify");if(tc(n)&&(n=n.toString(),Ki.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()))Ki.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(WQ)&&(this.unregister(WQ),this.register({distinct_id:n}));var r=(this.persistence.get_property(Jh)||"anonymous")==="anonymous";n!==a&&r?(this.persistence.set_property(Jh,"identified"),this.setPersonPropertiesForFlags(P4(P4({},o||{}),i||{}),!1),this.capture("$identify",{distinct_id:n,$anon_distinct_id:a},{$set:i||{},$set_once:o||{}}),this.featureFlags.setAnonymousDistinctId(a),this._cachedIdentify=h_(n,i,o)):(i||o)&&(this._cachedIdentify!==h_(n,i,o)?(this.setPersonProperties(i,o),this._cachedIdentify=h_(n,i,o)):Ki.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),n!==a&&(this.reloadFeatureFlags(),this.unregister(SN))}}else Ki.error("Unique user id has not been set in posthog.identify")}setPersonProperties(n,i){(n||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(P4(P4({},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:P4(P4({},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 Ki.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(Ki.info("reset"),!this.__loaded)return Ki.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(Jh,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:EC2,$device_id:null},"");else{var C=this.config.get_device_id(Hp());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(nC2)?(Ki.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Qr(i)&&(i=this.get_distinct_id()),n!==i?(this._register_single(WQ,n),this.capture("$create_alias",{alias:n,distinct_id:i})):(Ki.warn("alias matches current distinct_id - skipping api call."),this.identify(n),-1)):void 0}set_config(n){var i,o,a,s,r=P4({},this.config);Ul(n)&&(du(this.config,Cu2(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 o_(P4(P4({},this.config),{},{persistence:"sessionStorage"})),Lu.is_supported()&&Lu.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(Kh.DEBUG=!0,Ki.info("set_config",JSON.stringify({config:n,oldConfig:r,newConfig:P4({},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(P4(P4({},F20((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:ty;return i!==ty&&(i=ty+"."+i),i}_isIdentified(){var n,i;return((n=this.persistence)===null||n===void 0?void 0:n.get_property(Jh))==="identified"||((i=this.sessionPersistence)===null||i===void 0?void 0:i.get_property(Jh))==="identified"}_hasPersonProcessing(){var n,i,o,a;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&jB(this.getGroups())&&((n=this.persistence)===null||n===void 0||(i=n.props)===null||i===void 0||!i[WQ])&&((o=this.persistence)===null||o===void 0||(a=o.props)===null||a===void 0||!a[NN]))}_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"?(Ki.error(n+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(NN,!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(),(Qr(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 af?iu2(af,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Un&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:Un.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(el(this.config.before_send))return n;var i=Fl(this.config.before_send)?this.config.before_send:[this.config.before_send],o=n;for(var a of i){if(o=a(o),el(o)){var s="Event '".concat(n.event,"' was rejected in beforeSend function");return q$2(n.event)?Ki.warn("".concat(s,". This can cause unexpected behavior.")):Ki.info(s),null}o.properties&&!jB(o.properties)||Ki.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]]=e20(t.prototype[n[i]])})(oV,["identify"]);var lu2,e10=(lu2=AM[ty]=new oV,function(){function t(){t.done||(t.done=!0,au2=!1,il(AM,function(n){n._dom_loaded()}))}Un!=null&&Un.addEventListener?Un.readyState==="complete"?t():$l(Un,"DOMContentLoaded",t,{capture:!1}):p4&&Ki.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),lu2);const t10=new k$2({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),uu2=({children:t,theme:n})=>{z0.useEffect(()=>{!n||!Object.keys(n).length||nB2(n)},[n]);const i=(o,a)=>{e10.capture("sth_went_wrong",{message:o.message,stack:o.stack,componentStack:a.componentStack})};return E.jsx(p$2,{FallbackComponent:Eb2,onError:i,children:E.jsx(j$2,{client:t10,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"},Au2=z0.createContext({isLoading:void 0,data:void 0,token:void 0,refetch:void 0}),aV=()=>z0.useContext(Au2),sV="http://localhost:3000",ju="/api/v2/dashboard",ny="/api/v2/metric",Fg="/api/v3/metric",r10="dashboardData",n10=`${ju}/embeddedMetric`,i10="embeddedMetric",o10=`${ny}/layout`,cu2="dashboardLayout",a10=`${ju}/scheduledReportV2`,s10="dashboardScheduledReportV2",C10=`${ny}/saveLayout`,l10="saveLayout",u10=`${ju}/saveScheduleReport`,A10="saveScheduleReport",c10=`${ju}/deleteScheduleReport`,f10="deleteScheduleReport",d10=`${ju}/createMetric`,g10="createMetric",h10=`${ju}/updateMetric`,E10="updateMetric",p10=`${ju}/updateAdminMetric`,v10="updateAdminMetric",I10=`${ju}/generateMetric`,m10="generateMetric",b10=`${ju}/datasetMetricCreation`,B10="datasetMetricCreation",y10=`${ju}/previewTable`,L10="previewTable",w10=`${ju}/generatetMetricData`,Q10="/generatetMetricData",M10=`${ju}/getOpenaiChatResponse`,T10="getOpenaiChatResponse",x10=`${ju}/getDashboardScreenshot`,R10=`${ju}/createDashboardFilterView`,H10="createDashboardFilterView",D10=`${ju}/getDashboardFilterView`,S10="getDashboardFilterView",N10=`${ju}/getTheme`,V10="getTheme",k10=`${Fg}/query`,O10="query",P10=`${Fg}/datasetMetricCreation`,Z10="newDatasetMetricCreation",F10=`${Fg}/generateDataReport`,U10="generateDataReport",j10=`${Fg}/chatQuery`,z10="chatQuery",G10=`${ny}/rawDownloadSettings`,Y10="rawDownloadSettings",W10=`${ny}/column`,_10="column",X10=`${ny}/underlyingData`,K10="underlyingData",J10=`${ny}/invokeShareCsv`,q10="invokeShareCsv",$10=`${Fg}/markArchived`,e30="markArchived",t30=`${Fg}/publishMetrics`,r30="publishMetrics",n30=`${Fg}/download-csv`,i30=`${Fg}/downloadDashboardMetrics`,o30="IS_LOADING",a30="DATA_LOADED",s30=`${Fg}/summarizeMetric`,C30="summarizeMetric",l30=`${Fg}/createGuestTokenUsageLog`,u30="createGuestTokenUsageLog",A30="ENTER_FULL_SCREEN_MODE",fu2="EXIT_FULL_SCREEN_MODE",c30="ENTER_SCHEDULED_REPORT_MODE",f30="SAVE_SCHEDULED_REPORT",du2="EXIT_SCHEDULED_REPORT_MODE",d30="ENTER_CUSTOMIZE_LAYOUT_MODE",gu2="EXIT_CUSTOMIZE_LAYOUT_MODE",hu2="SAVE_LAYOUT",g30="ENTER_MANAGE_METRICS_MODE",Eu2="EXIT_MANAGE_METRICS_MODE",h30="SAVE_MANAGE_METRICS",E30="ARCHIVE_METRIC",pu2="DOWNLOAD_METRIC",vu2="DOWNLOAD_METRIC_WITHOUT_FILTERS",p30="SAVE_METRIC_PNG",v30="METRIC_FILTER_APPLIED",I30="DASHBOARD_FILTER_APPLIED",m30="CREATE_METRIC",Iu2="UPDATE_METRIC",p_=()=>localStorage.getItem(eb2),CV=()=>{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}:null},kC=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":p_()||""}:{},...CV()||{}}};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)||sV}${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},b30=()=>Zl(l10,t=>kC(C10,{method:"POST",data:t})),B30=()=>Zl(A10,t=>kC(u10,{method:"POST",data:t.data,token:t.token})),mu2=()=>Zl(f10,t=>kC(c10,{method:"POST",data:t,token:t.token})),y30=()=>Zl(g10,({data:t,token:n})=>kC(d10,{method:"POST",data:t,token:n})),L30=()=>Zl(E10,({data:t,token:n})=>kC(h10,{method:"POST",data:t,token:n})),w30=()=>Zl(v10,({data:t,token:n})=>kC(p10,{method:"POST",data:t,token:n})),Q30=()=>Zl(m10,({data:t,token:n})=>kC(I10,{method:"POST",data:t,token:n})),bu2=()=>Zl(B10,({data:t,token:n})=>kC(b10,{method:"POST",data:t,token:n})),M30=()=>Zl(L10,({data:t,token:n})=>kC(y10,{method:"POST",data:t,token:n})),T30=()=>Zl(Q10,({data:t,token:n})=>kC(w10,{method:"POST",data:t,token:n})),x30=()=>Zl(T10,({data:t,token:n})=>kC(M10,{method:"POST",data:t,token:n})),R30=()=>Zl(H10,({data:t,token:n})=>kC(R10,{method:"POST",data:t,token:n})),v_=()=>Zl(_10,t=>kC(W10,{method:"POST",data:t})),H30=()=>Zl(K10,t=>kC(X10,{method:"POST",data:t})),D30=()=>Zl(q10,t=>kC(J10,{method:"POST",data:t})),S30=()=>Zl(e30,({data:t,token:n})=>kC($10,{method:"POST",data:t,token:n})),N30=()=>Zl(r30,({data:t,token:n})=>kC(t30,{method:"POST",data:t,token:n})),V30=()=>Zl(Z10,({data:t,token:n,clientId:i,isFrontendApp:o})=>kC(P10,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),Bu2=()=>Zl(U10,({data:t,token:n,clientId:i,isFrontendApp:o})=>kC(F10,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),k30=()=>Zl(z10,({data:t,token:n,clientId:i,isFrontendApp:o})=>kC(j10,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),O30=()=>Zl(C30,({data:t,isFrontendApp:n,clientId:i,token:o})=>kC(s30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),P30=()=>Zl(u30,({data:t,isFrontendApp:n,clientId:i,token:o})=>kC(l30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),I_=()=>{const{mutateAsync:t}=P30();return{saveLogsAsync:async i=>{t(i)}}},cM=({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:h,metric:m,datasetMetricSettings:w,drillDownSettings:Q,onServerEvent:R})=>{var J0,Y2,L3;const{token:N,data:O}=aV(),[X,K]=z0.useState(""),{mutate:f2,isLoading:A2}=y30(),{mutate:b2}=M30(),{saveLogsAsync:g2}=I_(),{register:j2,setValue:R2,watch:M2,handleSubmit:P2,control:G2,reset:C0}=sb(),m0=M1=>{K(""),C==null||C.chartType,L0.singleValue,f2({data:{companyId:e,companyIntegrationId:n,description:M1.description,inputFields:i,metricId:M1.metricId,name:M1.name,query:o,metricQuery:a,integrationName:s,outputColumns:r,createdBy:l||"external user",isLive:u||!1,chartOptions:C,datasetMetricSettings:w,clientId:l||null,isCreatedByClient:!!l,timeGrain:A||null,externalDashboardIds:f==null?void 0:f.map(B3=>({externalDashboardId:B3})),isEnableGroupBy:d,groupBy:g??{},selectedGroupBy:h,drillDownSettings:Q},token:N},{onSuccess:async B3=>{var j3,w7,l3;(j3=B3==null?void 0:B3.insert_externalMetrics_one)!=null&&j3.id?(await g2({clientId:l,data:{companyId:e,feature:"CREATE_METRIC",metricId:(w7=B3==null?void 0:B3.insert_externalMetrics_one)==null?void 0:w7.metricId},isFrontendApp:!1,token:N}),await(t==null?void 0:t((l3=B3==null?void 0:B3.insert_externalMetrics_one)==null?void 0:l3.id)),R==null||R(m30)):K("Metric Id already exists")},onError:()=>{K&&K("Metric Id already exists")}})},{mutateAsync:H0,isLoading:v0}=w30(),{mutateAsync:J2,isLoading:U0}=L30(),b0=z0.useCallback((M1,B3)=>{var w7,l3,c7;K("");let j3={};if(B3&&(j3={isDisableCardAppearance:M1.isDisableCardAppearance,titleAlignment:M1.titleAlignment,descAlignment:M1.descAlignment,...M1.text?{textBox:{text:M1.text,fontWeight:M1.fontWeight||"400",fontColor:M1.fontColor||"",fontSize:M1.fontSize||"14px",alignment:M1.textAlignment||"left",link:M1.textLink,isOpenInNewTab:M1.isOpenInNewTab,targetWord:M1.targetWord}}:null}),!(m!=null&&m.isCreatedByClient))H0({data:{externalMetricId:m==null?void 0:m.id,clientId:l,object:{clientId:l,companyId:e,companyIntegrationId:n||(m==null?void 0:m.companyIntegrationId),description:M1.description,inputFields:i,metricId:M1.metricId===(m==null?void 0:m.metricId)?`update_${M1.metricId}_by_${l}_${Date.now()}`:M1.metricId,name:B3?(w7=M1==null?void 0:M1.elementTitle)==null?void 0:w7.trim():(l3=M1==null?void 0:M1.name)==null?void 0:l3.trim(),query:o,metricQuery:a,datasetMetricSettings:w,integrationName:s,outputColumns:r,createdBy:l||"external user",isCreatedByClient:!!l,isLive:u||M1.isLive,chartOptions:C,drillDownSettings:Q,elementSettings:j3,isMetric:!B3,...B3?{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(T3=>({externalDashboardId:T3}))}}},token:N},{onSuccess:async T3=>{var y6;!(T3!=null&&T3.insert_clientDeletedMetrics_one)||!(T3!=null&&T3.insert_externalMetrics_one)||(K(""),await g2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(y6=T3==null?void 0:T3.insert_externalMetrics_one)==null?void 0:y6.metricId},isFrontendApp:!1,token:N}),await(t==null?void 0:t()),R==null||R(Iu2))},onError:()=>{K("Something went wrong! Please try again later.")}});else{const T3={chartOptions:C,datasetMetricSettings:w,description:M1.description,query:o,metricQuery:a,drillDownSettings:Q,elementSettings:j3,isMetric:!B3,...B3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}}};M1.description&&(T3.description=M1.description),M1.metricId&&(T3.metricId=M1.metricId),M1.name&&!B3&&(T3.name=M1.name),M1.elementTitle&&B3&&(T3.name=M1==null?void 0:M1.elementTitle),(c7=Object.keys(j3))!=null&&c7.length&&(T3.elementSettings=j3),J2({data:{externalMetricId:m==null?void 0:m.id,set:T3},token:N},{onSuccess:async y6=>{var t6,C6;(t6=y6==null?void 0:y6.update_externalMetrics_by_pk)!=null&&t6.id&&(K(""),await g2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(C6=y6==null?void 0:y6.update_externalMetrics_by_pk)==null?void 0:C6.metricId},isFrontendApp:!1,token:N}),await(t==null?void 0:t()),R==null||R(Iu2))},onError:()=>{K("Something went wrong! Please try again later.")}})}},[C,m,J2,H0,l,e,n,s,u,f,o,i,r,a,w]),k0=z0.useCallback(M1=>{K("");const B3={isPublished:!(M1!=null&&M1.isPublished)};J2({data:{externalMetricId:M1==null?void 0:M1.id,set:B3},token:N},{onSuccess:async j3=>{var w7,l3;(w7=j3==null?void 0:j3.update_externalMetrics_by_pk)!=null&&w7.id&&(K(""),await g2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(l3=j3==null?void 0:j3.update_externalMetrics_by_pk)==null?void 0:l3.metricId},isFrontendApp:!1,token:N}),t==null||t())},onError:()=>{K("Something went wrong! Please try again later.")}})},[m]);return{createExternalMetric:m0,updateExternalMetric:b0,error:X,isLoading:A2||v0||U0,clientSubsetData:O==null?void 0:O.clientSubsetData,previewTable:b2,token:N,workspaceId:(J0=O==null?void 0:O.workspace)==null?void 0:J0.id,dashboardOptions:[{value:(Y2=O==null?void 0:O.externalDashboard)==null?void 0:Y2.id,label:((L3=O==null?void 0:O.externalDashboard)==null?void 0:L3.name)||"Dashboard"}],isDatabaseTenancy:(O==null?void 0:O.companyTenancyType)===sL,register:j2,setValue:R2,watch:M2,handleSubmit:P2,control:G2,reset:C0,onPublishMetric:k0}},yu2=()=>{const{mutate:t,isLoading:n,error:i}=Q30(),{mutate:o,mutateAsync:a}=v_();return{generateDatasetMetric:t,isGeneratingDataset:n,generateError:i,fetchColumnValues:o,fetchColumnValuesAsync:a}};let Z30=0;function F30(t,n){const i=`atom${++Z30}`,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 qf={},Vp=Symbol(),m_=t=>!!t[Vp],lV=t=>!t[Vp].c,fM=t=>{var n;const{b:i,c:o}=t[Vp];o&&(o(),(n=j30.get(i))==null||n())},uV=(t,n)=>{const i=t[Vp].o,o=n[Vp].o;return i===o||t===o||m_(i)&&uV(i,n)},b_=(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[Vp]=i,o},U30=t=>b_(t[Vp].b,t[Vp].o),j30=new WeakMap,B_=t=>"init"in t,y_="r",L_="w",AV="c",w_="s",Lu2="h",z30="n",G30="l",Y30="a",W30="m",_30=t=>{const n=new WeakMap,i=new WeakMap,o=new Map;let a,s;(qf&&"production")!=="production"&&(a=new Set,s=new Set);const r=new WeakMap,C=(v0,J2,U0)=>{let b0=r.get(J2);b0||(b0=new Map,r.set(J2,b0)),U0.then(()=>{b0.get(v0)===U0&&(b0.delete(v0),b0.size||r.delete(J2))}),b0.set(v0,U0)},l=v0=>{const J2=new Set,U0=r.get(v0);return U0&&(r.delete(v0),U0.forEach((b0,k0)=>{fM(b0),J2.add(k0)})),J2},e=new WeakMap,u=v0=>{let J2=e.get(v0);return J2||(J2=new Map,e.set(v0,J2)),J2},A=(v0,J2)=>{if(v0){const U0=u(v0);let b0=U0.get(J2);return b0||(b0=A(v0.p,J2),b0&&"p"in b0&&lV(b0.p)&&(b0=void 0),b0&&U0.set(J2,b0)),b0}return n.get(J2)},f=(v0,J2,U0)=>{if((qf&&"production")!=="production"&&Object.freeze(U0),v0)u(v0).set(J2,U0);else{const b0=n.get(J2);n.set(J2,U0),o.has(J2)||o.set(J2,b0)}},d=(v0,J2=new Map,U0)=>{if(!U0)return J2;const b0=new Map;let k0=!1;return U0.forEach(J0=>{var Y2;const L3=((Y2=A(v0,J0))==null?void 0:Y2.r)||0;b0.set(J0,L3),J2.get(J0)!==L3&&(k0=!0)}),J2.size===b0.size&&!k0?J2:b0},g=(v0,J2,U0,b0,k0)=>{const J0=A(v0,J2);if(J0){if(k0&&(!("p"in J0)||!uV(J0.p,k0)))return J0;"p"in J0&&fM(J0.p)}const Y2={v:U0,r:(J0==null?void 0:J0.r)||0,y:!0,d:d(v0,J0==null?void 0:J0.d,b0)};let L3=!(J0!=null&&J0.y);return!J0||!("v"in J0)||!Object.is(J0.v,U0)?(L3=!0,++Y2.r,Y2.d.has(J2)&&(Y2.d=new Map(Y2.d).set(J2,Y2.r))):Y2.d!==J0.d&&(Y2.d.size!==J0.d.size||!Array.from(Y2.d.keys()).every(M1=>J0.d.has(M1)))&&(L3=!0,Promise.resolve().then(()=>{P2(v0)})),J0&&!L3?J0:(f(v0,J2,Y2),Y2)},h=(v0,J2,U0,b0,k0)=>{const J0=A(v0,J2);if(J0){if(k0&&(!("p"in J0)||!uV(J0.p,k0)))return J0;"p"in J0&&fM(J0.p)}const Y2={e:U0,r:((J0==null?void 0:J0.r)||0)+1,y:!0,d:d(v0,J0==null?void 0:J0.d,b0)};return f(v0,J2,Y2),Y2},m=(v0,J2,U0,b0)=>{const k0=A(v0,J2);if(k0&&"p"in k0){if(uV(k0.p,U0)&&!lV(k0.p))return k0.y?k0:{...k0,y:!0};fM(k0.p)}C(v0,J2,U0);const J0={p:U0,r:((k0==null?void 0:k0.r)||0)+1,y:!0,d:d(v0,k0==null?void 0:k0.d,b0)};return f(v0,J2,J0),J0},w=(v0,J2,U0,b0)=>{if(U0 instanceof Promise){const k0=b_(U0,U0.then(J0=>{g(v0,J2,J0,b0,k0)}).catch(J0=>{if(J0 instanceof Promise)return m_(J0)?J0.then(()=>{R(v0,J2,!0)}):J0;h(v0,J2,J0,b0,k0)}));return m(v0,J2,k0,b0)}return g(v0,J2,U0,b0)},Q=(v0,J2)=>{const U0=A(v0,J2);if(U0){const b0={...U0,y:!1};f(v0,J2,b0)}else(qf&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",J2)},R=(v0,J2,U0)=>{if(!U0){const k0=A(v0,J2);if(k0){if(k0.y&&"p"in k0&&!lV(k0.p))return k0;if(k0.d.forEach((J0,Y2)=>{if(Y2!==J2)if(!i.has(Y2))R(v0,Y2);else{const L3=A(v0,Y2);L3&&!L3.y&&R(v0,Y2)}}),Array.from(k0.d).every(([J0,Y2])=>{const L3=A(v0,J0);return L3&&!("p"in L3)&&L3.r===Y2}))return k0.y?k0:{...k0,y:!0}}}const b0=new Set;try{const k0=J2.read(J0=>{b0.add(J0);const Y2=J0===J2?A(v0,J0):R(v0,J0);if(Y2){if("e"in Y2)throw Y2.e;if("p"in Y2)throw Y2.p;return Y2.v}if(B_(J0))return J0.init;throw new Error("no atom init")});return w(v0,J2,k0,b0)}catch(k0){if(k0 instanceof Promise){const J0=m_(k0)&&lV(k0)?U30(k0):b_(k0,k0);return m(v0,J2,J0,b0)}return h(v0,J2,k0,b0)}},N=(v0,J2)=>R(J2,v0),O=(v0,J2)=>{let U0=i.get(J2);return U0||(U0=j2(v0,J2)),U0},X=(v0,J2)=>!J2.l.size&&(!J2.t.size||J2.t.size===1&&J2.t.has(v0)),K=(v0,J2)=>{const U0=i.get(J2);U0&&X(J2,U0)&&R2(v0,J2)},f2=(v0,J2)=>{const U0=i.get(J2);U0==null||U0.t.forEach(b0=>{b0!==J2&&(Q(v0,b0),f2(v0,b0))})},A2=(v0,J2,U0)=>{let b0=!0;const k0=(L3,M1)=>{const B3=R(v0,L3);if("e"in B3)throw B3.e;if("p"in B3){if(M1!=null&&M1.unstable_promise)return B3.p.then(()=>{const j3=A(v0,L3);return j3&&"p"in j3&&j3.p===B3.p?new Promise(w7=>setTimeout(w7)).then(()=>k0(L3,M1)):k0(L3,M1)});throw(qf&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",L3),B3.p}if("v"in B3)return B3.v;throw(qf&&"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")},J0=(L3,M1)=>{let B3;if(L3===J2){if(!B_(L3))throw new Error("atom not writable");l(L3).forEach(c7=>{c7!==v0&&w(c7,L3,M1)});const w7=A(v0,L3),l3=w(v0,L3,M1);w7!==l3&&f2(v0,L3)}else B3=A2(v0,L3,M1);return b0||P2(v0),B3},Y2=J2.write(k0,J0,U0);return b0=!1,Y2},b2=(v0,J2,U0)=>{const b0=A2(U0,v0,J2);return P2(U0),b0},g2=v0=>!!v0.write,j2=(v0,J2,U0)=>{const b0={t:new Set(U0&&[U0]),l:new Set};if(i.set(J2,b0),(qf&&"production")!=="production"&&s.add(J2),R(void 0,J2).d.forEach((J0,Y2)=>{const L3=i.get(Y2);L3?L3.t.add(J2):Y2!==J2&&j2(v0,Y2,J2)}),g2(J2)&&J2.onMount){const J0=L3=>b2(J2,L3,v0),Y2=J2.onMount(J0);v0=void 0,Y2&&(b0.u=Y2)}return b0},R2=(v0,J2)=>{var U0;const b0=(U0=i.get(J2))==null?void 0:U0.u;b0&&b0(),i.delete(J2),(qf&&"production")!=="production"&&s.delete(J2);const k0=A(v0,J2);k0?("p"in k0&&fM(k0.p),k0.d.forEach((J0,Y2)=>{if(Y2!==J2){const L3=i.get(Y2);L3&&(L3.t.delete(J2),X(Y2,L3)&&R2(v0,Y2))}})):(qf&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",J2)},M2=(v0,J2,U0,b0)=>{const k0=new Set(U0.d.keys());b0==null||b0.forEach((J0,Y2)=>{if(k0.has(Y2)){k0.delete(Y2);return}const L3=i.get(Y2);L3&&(L3.t.delete(J2),X(Y2,L3)&&R2(v0,Y2))}),k0.forEach(J0=>{const Y2=i.get(J0);Y2?Y2.t.add(J2):i.has(J2)&&j2(v0,J0,J2)})},P2=v0=>{if(v0){u(v0).forEach((U0,b0)=>{const k0=n.get(b0);if(U0!==k0){const J0=i.get(b0);J0==null||J0.l.forEach(Y2=>Y2(v0))}});return}for(;o.size;){const J2=Array.from(o);o.clear(),J2.forEach(([U0,b0])=>{const k0=A(void 0,U0);if(k0&&k0.d!==(b0==null?void 0:b0.d)&&M2(void 0,U0,k0,b0==null?void 0:b0.d),b0&&!b0.y&&(k0!=null&&k0.y))return;const J0=i.get(U0);J0==null||J0.l.forEach(Y2=>Y2())})}(qf&&"production")!=="production"&&a.forEach(J2=>J2())},G2=v0=>{u(v0).forEach((U0,b0)=>{const k0=n.get(b0);(!k0||U0.r>k0.r||U0.y!==k0.y||U0.r===k0.r&&U0.d!==k0.d)&&(n.set(b0,U0),U0.d!==(k0==null?void 0:k0.d)&&M2(v0,b0,U0,k0==null?void 0:k0.d))})},C0=(v0,J2)=>{J2&&G2(J2),P2(void 0)},m0=(v0,J2,U0)=>{const k0=O(U0,v0).l;return k0.add(J2),()=>{k0.delete(J2),K(U0,v0)}},H0=(v0,J2)=>{for(const[U0,b0]of v0)B_(U0)&&(w(J2,U0,b0),f2(J2,U0));P2(J2)};return(qf&&"production")!=="production"?{[y_]:N,[L_]:b2,[AV]:C0,[w_]:m0,[Lu2]:H0,[z30]:v0=>(a.add(v0),()=>{a.delete(v0)}),[G30]:()=>s.values(),[Y30]:v0=>n.get(v0),[W30]:v0=>i.get(v0)}:{[y_]:N,[L_]:b2,[AV]:C0,[w_]:m0,[Lu2]:H0}},X30=(t,n)=>({s:n?n(t).SECRET_INTERNAL_store:_30()}),Q_=new Map,wu2=t=>(Q_.has(t)||Q_.set(t,z0.createContext(X30())),Q_.get(t));function Qu2(t,n){return F30(t)}function K30(t,n){const i=wu2(n),o=z0.useContext(i),{s:a,v:s}=o,r=f=>{const d=a[y_](t,f);if((qf&&"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]=z0.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)),z0.useEffect(()=>{const{v:f}=o;f&&a[AV](t,f);const d=a[w_](t,u,f);return u(f),d},[a,t,o]),z0.useEffect(()=>{a[AV](t,C)}),z0.useDebugValue(A),A}function J30(t,n){const i=wu2(n),{s:o,w:a}=z0.useContext(i);return z0.useCallback(r=>{if((qf&&"production")!=="production"&&!("write"in t))throw new Error("not writable atom");const C=l=>o[L_](t,r,l);return a?a(C):C()},[o,a,t])}function M_(t,n){return"scope"in t&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),n=t.scope),[K30(t,n),J30(t,n)]}const cV=({onOutsideClick:t,wrapRef:n,portalRef:i})=>{z0.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])},q30=({wrapRef:t,portalRef:n,autoCloseParent:i=!1})=>{const[o]=M_(LA2);z0.useEffect(()=>{const a=s=>{o==null||o.forEach(r=>{var l,e,u,A,f,d,g,h;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 m=o.find(w=>{var R,N;const Q=((R=r.popperElement)==null?void 0:R.contains(w.referenceElement))&&(w.isOpen===!0||w.isMenuOpen===!0);return i?Q&&((N=w.popperElement)==null?void 0:N.contains("composedPath"in s?s.composedPath()[0]:s.target)):Q});m?((u=m==null?void 0:m.setOpen)==null||u.call(m,!0),(A=m==null?void 0:m.setMenuOpen)==null||A.call(m,!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),(h=r.setMenuOpen)==null||h.call(r,!0))})};return document.addEventListener("click",a,!0),()=>{document.removeEventListener("click",a,!0)}},[t,n,o])},$30=({token:t,dashboardId:n,configId:i,isEn:o})=>{var a;return Qp([r10,{dashboardId:n,configId:i,token:t,isEn:o}],()=>{const s=n?`${ju}?dashboardId=${n}${i?`&configId=${i}`:""}${`&isEn=${o}`}`:ju;return kC(s,{method:"GET",token:t})},{enabled:!!t||!!((a=window==null?void 0:window.dbn)!=null&&a.isEnableProxyAuth)})},e70=(t,n)=>Qp([cu2,{dashboardId:t,clientId:n}],()=>kC(`${o10}?id=${t}&clientId=${n}`,{method:"GET"}),{enabled:!!t&&!!n}),t70=(t,n,i)=>Qp(s10,()=>kC(`${a10}?externalDashboardId=${n}${i?`&embedId=${i}`:""}`,{method:"GET",token:t}),{enabled:!!t&&!!n}),r70=(t,n)=>{var i;return Qp([i10,{id:n}],()=>kC(`${n10}?metricId=${n}`,{method:"GET",token:t}),{enabled:!!t||!!((i=window==null?void 0:window.dbn)!=null&&i.isEnableProxyAuth)})},Mu2=({token:t,name:n,companyId:i})=>Qp([V10,{name:n}],()=>kC(N10,{method:"POST",token:t,data:{name:n,companyId:i}}),{enabled:!!(n&&t&&i)}),n70=({token:t,dashboardId:n})=>Qp([S10,{dashboardId:n}],()=>kC(D10,{method:"POST",token:t,data:{dashboardId:n}}),{enabled:!!(t&&n)}),i70=({externalDashboardId:t,clientId:n})=>{const i=CW(),{data:o,isLoading:a}=e70(t,n),[s,r,C,l]=z0.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}=b30();return{saveLayout:z0.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([cu2,{dashboardId:t,clientId:n}],h=>({...h,...g}))}})},[e,n,t]),layout:s,dashboardFiltersLayout:r,gridMargin:l,isLayoutLocked:C,isLoadingLayout:a||u}},o70=({query:t,limit:n,offset:i,dbName:o})=>{const a=If===(o==null?void 0:o.toLowerCase()),s=ku===(o==null?void 0:o.toLowerCase()),r=hA===(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())==ku||(o==null?void 0:o.toLowerCase())==If||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},a70=({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:h}=H30();return{getUnderlyingData:({columnName:w,value:Q,setData:R,setLoading:N,isSingleValueChart:O,clientColumnType:X})=>{const K=o==="MULTI_DATABASE"&&n||"",f2=g&&d?d:o70({query:s,limit:"5000",dbName:i}),A2=lb({clientColumnType:X,query:f2||"",dbName:i,rlsConditions:A,tenancyLevel:o||"TABLE",clientId:n,globalFilters:e,values:a,isAllClient:u,dataMartRelationships:f});R([]),N(!0),h({columnName:O?void 0:w,companyId:r,query:of(A2,r),value:O?void 0:Q.toString().replace(/'/g,"''"),workspaceId:C,metricId:l,isCustomSql:g&&!!d,databaseName:K,datasourceId:t},{onSuccess(b2){const g2=b2==null?void 0:b2.data;g2&&Array.isArray(g2)&&g2.length?(R(g2),N(!1)):(R([]),N(!1))},onError(){R([]),N(!1)}})}}},s70=({clientId:t,data:n,token:i,isFrontendApp:o,isFullScreen:a=""},s)=>Qp([O10,n,t,o,i,a],()=>{var r,C,l;return kC(k10,{method:"POST",data:{...n||{},...!o&&i?{...(r=n==null?void 0:n.rlsConditions)!=null&&r.length?{rlsConditions:FB(n==null?void 0:n.rlsConditions,i)}:{},...(l=(C=n==null?void 0:n.globalFilters)==null?void 0:C.filters)!=null&&l.length?{globalFilters:FB(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}),C70=t=>Qp([Y10,t],()=>kC(`${G10}?id=${t}`,{method:"GET"}),{enabled:!!t}),fV={timeSeriesSettingsContainer:"_timeSeriesSettingsContainer_3qyzb_1",timeSeriesSettingsType:"_timeSeriesSettingsType_3qyzb_9",featToggle:"_featToggle_3qyzb_17",dynamicFormat:"_dynamicFormat_3qyzb_33"},l70=[{value:"line",label:"line"},{value:"bar",label:"bar"},{value:"area",label:"area"},{value:"stack",label:"stack"},{value:"combo",label:"combo"}],cC=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"},{value:"Quarterly",label:"Quarterly"},{value:"Yearly",label:"Yearly"}],u70=({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 h=`${n.options[d].split("____")[0]}____${g}`,m=`${n.options[d].split("____")[0]}`;t(w=>{var Q,R,N,O;return{...w,groupBySettings:{...w.groupBySettings,options:(Q=w.groupBySettings.options)==null?void 0:Q.map((X,K)=>K===d?h:X),value:((R=w.groupBySettings.options)==null?void 0:R.find((X,K)=>K===d))===((N=w==null?void 0:w.groupBySettings)==null?void 0:N.value)?m:(O=w==null?void 0:w.groupBySettings)==null?void 0:O.value}}})}else{const h=`${n.options[d]}____${g}`,m=`${n.options[d]}`;t(w=>{var Q,R,N,O;return{...w,groupBySettings:{...w.groupBySettings,options:(Q=w.groupBySettings.options)==null?void 0:Q.map((X,K)=>K===d?h:X),value:((R=w.groupBySettings.options)==null?void 0:R.find((X,K)=>K===d))===((N=w==null?void 0:w.groupBySettings)==null?void 0:N.value)?m:(O=w==null?void 0:w.groupBySettings)==null?void 0:O.value}}})}};return E.jsxs("div",{className:fV.timeSeriesSettingsContainer,children:[E.jsx(q7,{variant:"heading-5",children:"Time Series Settings"}),E.jsx(oe,{label:"Series Type",options:l70,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(h=>({column:h,type:d.value}))}))},menuWidth:"100%",buttonWidth:"100%"}),E.jsx(q7,{variant:"body-text-2",children:"Group format"}),E.jsxs("div",{className:fV.timeSeriesSettingsType,children:[E.jsx(uf,{"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:cC==null?void 0:cC.map(h=>h.value),isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[2]))},name:"isDynamic",label:"Default",defaultChecked:!n.isDynamic&&!n.isGlobalFilter,checked:!n.isDynamic&&!n.isGlobalFilter}),E.jsx(uf,{"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:cC==null?void 0:cC.map(h=>h.value),fillXAxis:!1,isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[2]))}}),E.jsx(uf,{"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:cC==null?void 0:cC.map(h=>h.value),fillXAxis:!1,isGlobalFilter:!0,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[0]))}})]}),n.isDynamic?E.jsxs("div",{className:fV.dynamicFormat,children:[E.jsx(_a,{buttonWidth:"100%",menuWidth:"100%",options:cC,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(h=>h.value))||["monthly"],fillXAxis:[Wc.daily,Wc.weekly,Wc.yearly].includes(Array.isArray(d)&&d.length?d[0].value:"monthly")?!1:g.groupBySettings.fillXAxis}})),a==null||a((d==null?void 0:d[0])||(cC==null?void 0:cC[2]))},isShowSelectedOptions:!0}),(f=n.options)==null?void 0:f.map((d,g)=>E.jsx(g5,{label:d.split("____").length>1?d.split("____")[0]:d,type:"text",value:d.split("____").length>1?d.split("____")[1]:d,placeholder:"Save as",onChange:h=>{r(g,h.target.value)}}))]}):E.jsxs(E.Fragment,{children:[(n==null?void 0:n.isGlobalFilter)&&E.jsxs(E.Fragment,{children:[E.jsx(oe,{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)&&E.jsx(js,{direction:"col",className:"dbn-gap-3",children:cC==null?void 0:cC.map(d=>{var g,h,m,w,Q,R,N;return E.jsxs(js,{className:"dbn-w-full dbn-gap-2",alignItems:"center",justify:"between",children:[E.jsx(lf,{checked:!!((g=n==null?void 0:n.formatWithValue)!=null&&g.find(O=>O.format===d.value&&O.isEnable)),onChange:({target:{checked:O}})=>{t(X=>{var K,f2,A2,b2,g2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(K=X==null?void 0:X.groupBySettings)==null?void 0:K.formatWithValue)==null?void 0:f2.filter(j2=>j2.format!==d.value))||[],{format:d.value,isEnable:O,value:((g2=(b2=(A2=X==null?void 0:X.groupBySettings)==null?void 0:A2.formatWithValue)==null?void 0:b2.find(j2=>j2.format===d.value))==null?void 0:g2.value)||""}]}}})},label:d.value}),E.jsx("div",{className:"dbn-w-full",children:E.jsx(oe,{placeholder:"Select a Filter Value",menuWidth:"100%",buttonWidth:"100%",options:((h=n==null?void 0:n.globalFilterOption)==null?void 0:h.presetDateOptions)||[],selectedOption:{value:((w=(m=n==null?void 0:n.formatWithValue)==null?void 0:m.find(O=>O.format===d.value))==null?void 0:w.value)||"",label:((R=(Q=n==null?void 0:n.formatWithValue)==null?void 0:Q.find(O=>O.format===d.value))==null?void 0:R.value)||""},isDisabled:!((N=n==null?void 0:n.formatWithValue)!=null&&N.find(O=>O.format===d.value&&O.isEnable)),onChange:O=>{t(X=>{var K,f2,A2,b2,g2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(K=X==null?void 0:X.groupBySettings)==null?void 0:K.formatWithValue)==null?void 0:f2.filter(j2=>j2.format!==d.value))||[],{format:d.value,isEnable:!!((g2=(b2=(A2=X==null?void 0:X.groupBySettings)==null?void 0:A2.formatWithValue)==null?void 0:b2.find(j2=>j2.format===d.value))!=null&&g2.isEnable),value:(O==null?void 0:O.value)||""}]}}})}})})]})})})]}),E.jsx(oe,{label:"Format Type",menuWidth:"100%",buttonWidth:"100%",options:cC,selectedOption:(cC==null?void 0:cC.find(d=>{var g,h;return((g=d.value)==null?void 0:g.toLowerCase())===((h=n==null?void 0:n.value)==null?void 0:h.toLowerCase())}))||(cC==null?void 0:cC[2]),onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:d.value}})),a==null||a(d)}}),[Wc.month,Wc.quarter].includes(n.value.toLowerCase())&&E.jsxs("div",{className:fV.featToggle,children:[E.jsx(a4,{name:"fill axis",enabled:n.fillXAxis,onChange:()=>t(d=>({...d,groupBySettings:{...d.groupBySettings,fillXAxis:!d.groupBySettings.fillXAxis}}))}),E.jsxs("span",{className:"dbn-flex dbn-gap-2 dbn-items-center",children:[E.jsx(q7,{variant:"body-text-2",children:"Fill X-axis"}),E.jsx(sf,{position:"top",iconConfig:{size:"xs",color:"primary"},text:"Enable to fill missing months or dates.",tooltipClass:"dbn-w-[300px]"})]})]})]})]})},nc=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)})},Nc=t=>{const n=new Date(t);return n instanceof Date&&!Number.isNaN(n.getTime())?n:null},T_=({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:h,setMetricStore:m,onServerEvent:w,clientColumnType:Q,datasourceId:R,appliedCardMetricFilters:N,language:O,translationDictionary:X,calendarType:K,setLoadedCardMetadata:f2,isFullScreen:A2,setMetricMetadata:b2,viewMetricData:g2,generatingPdf:j2,dataMartTables:R2})=>{var N4,r5,i4,D4,b4,z4,Ce,N9,K5,s4,le,B4,O4,i1,C3,W3,x3,_7,s3,t7,B6,U6,e9,r7,F7,s8,Y7,G1,E7,h6,H6,j6,n9,y8,q8,C9,V9,N5,l4,j5,u4,y4,re,_e,bt,Cr,Bt,jn,qn,Vi,Ji,qi,ki,$i,go,yo,fn,Zr,Xe,Ln,wn,$n,Ci,wi,pr;const[M2,P2]=z0.useState(!1),[G2,C0]=z0.useState(!0),m0=O30(),[H0,v0]=z0.useState(""),[J2,U0]=z0.useState(""),[b0,k0]=z0.useState(!1),J0=z0.useRef(null),[Y2,L3]=z0.useState({limit:10,offset:0}),[M1,B3]=z0.useState(0),[j3,w7]=z0.useState(0),[l3,c7]=z0.useState((t==null?void 0:t.rlsConditions)||[]),[T3,y6]=z0.useState([]),[t6,C6]=z0.useState(!1),[n3,t0]=z0.useState(),[V3,Z7]=z0.useState([]),[e6,l7]=z0.useState(""),[A6,w6]=z0.useState([]),[v1,h3]=z0.useState({isOpen:!1,report:"",isLoading:!1}),[o7,m7]=z0.useState(!1),[G3,J3]=z0.useState([]),[k7,W7]=z0.useState([]),[J7,e8]=z0.useState({isEnableGroupBy:!1,isEnableCrossFilter:!1,drillType:""}),[z7,x6]=z0.useState([]),[c8,h9]=z0.useState(!1),[U8,$9]=z0.useState(!1),[o9,M9]=z0.useState([]),[j8,y5]=z0.useState({}),[H5,_5]=z0.useState(!1),[T5,S8]=z0.useState(null),[W1,W9]=z0.useState(t==null?void 0:t.chartOptions),[I6,l8]=z0.useState({data:[],error:"",isLoading:!1,currentValue:""}),h8=z0.useMemo(()=>{var i8,r8;return!!((r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)!=null&&r8.isPythonMode)},[(r5=(N4=t==null?void 0:t.datasetMetricSettings)==null?void 0:N4.newDatasetSettings)==null?void 0:r5.isPythonMode]),Y6=z0.useMemo(()=>{var i8,r8,s9,B8,L9;return((L9=(B8=(s9=(r8=(i8=t==null?void 0:t.externalDashboardMetrics)==null?void 0:i8[0])==null?void 0:r8.externalDashboard)==null?void 0:s9.companyWorkspace)==null?void 0:B8.datamart)==null?void 0:L9.datamartRelationships)||[]},[t]),Q8=z0.useMemo(()=>{const i8={};if(i!=null&&i.values)for(const r8 in i.values){const s9=`${r8}_variable`;i8[s9]=i.values[r8]}return i8},[i==null?void 0:i.values]),x1=z0.useMemo(()=>{var s9,B8,L9;const i8=(B8=(s9=t==null?void 0:t.datasetMetricSettings)==null?void 0:s9.newDatasetSettings)==null?void 0:B8.selectedMainTable,r8=R2==null?void 0:R2.find(N8=>N8.tableName===(i8==null?void 0:i8.tableName));return((L9=r8==null?void 0:r8.customColumnFields)==null?void 0:L9.map(N8=>{var e5,B5,O5,f8,I9,l9;return{value:N8==null?void 0:N8.columnName,label:N8==null?void 0:N8.columnName,isCustomField:!0,column:{uniqueId:PB(10),alias:N8==null?void 0:N8.columnName,configType:"DIMENSION",datatype:N8==null?void 0:N8.datatype,dropType:"DIMENSION",index:1e3,name:N8==null?void 0:N8.columnName,parentAlias:`${TS(i8==null?void 0:i8.schemaName,((e5=t==null?void 0:t.companyIntegration)==null?void 0:e5.name)||"")}_${(B5=i8==null?void 0:i8.tableName)==null?void 0:B5.replaceAll(" ","_")}`,table:(f8=(O5=t==null?void 0:t.datasetMetricSettings)==null?void 0:O5.newDatasetSettings)==null?void 0:f8.selectedMainTable,type:"DEFAULT",draggableItemData:{column:{name:N8==null?void 0:N8.columnName,dataType:N8==null?void 0:N8.datatype,as:N8==null?void 0:N8.datatype},table:(l9=(I9=t==null?void 0:t.datasetMetricSettings)==null?void 0:I9.newDatasetSettings)==null?void 0:l9.selectedMainTable},label:"",sql:""}}}))||[]},[(D4=(i4=t==null?void 0:t.datasetMetricSettings)==null?void 0:i4.newDatasetSettings)==null?void 0:D4.selectedMainTable,(b4=t==null?void 0:t.companyIntegration)==null?void 0:b4.name,R2]),L7=z0.useMemo(()=>{var i8,r8,s9,B8,L9,N8,e5,B5,O5,f8,I9,l9,O9,m4;return{isAllClient:u,id:t==null?void 0:t.id,tenancyLevel:a,rlsConditions:[...o9||[],...(i8=W1==null?void 0:W1.tableSettings)!=null&&i8.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?(r8=T3==null?void 0:T3.map($5=>$5.condition))==null?void 0:r8.filter($5=>Px($5)):[]],globalFilters:h8?void 0:{...n,filters:(s9=n==null?void 0:n.filters)==null?void 0:s9.filter($5=>{var Ke;return Array.isArray($5==null?void 0:$5.value)?(Ke=$5==null?void 0:$5.value)==null?void 0:Ke.length:$5})},filterValues:h8?void 0:Q8,limit:(B8=W1==null?void 0:W1.tableSettings)!=null&&B8.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?Math.min(Y2.limit,1e3):void 0,offset:(L9=W1==null?void 0:W1.tableSettings)!=null&&L9.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?Y2.offset:void 0,disableStringify:!0,pivotHeaders:((N8=W1==null?void 0:W1.pivotTableSettings2)==null?void 0:N8.headers)||[],timeseriesSettings:h8?void 0:{format:((O5=(B5=(e5=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:e5.groupBySettings)==null?void 0:B5.value)==null?void 0:O5.toLowerCase())||"monthly",seriesField:(W1==null?void 0:W1.seriesField)||"",isFiscal:K==="ind"},chartSeriesField:(W1==null?void 0:W1.seriesField)!=="ungrouped"&&(W1!=null&&W1.seriesField)&&(W1!=null&&W1.isDynamicSeries)?W1==null?void 0:W1.seriesField:void 0,comparisonCount:j3,dynamicXAxis:{isEnable:!!((f8=W1==null?void 0:W1.dynamicXAxis)!=null&&f8.isEnabled||(I9=W1==null?void 0:W1.enduserMeasureAndDimensions)!=null&&I9.isEnabled)&&Ih.includes((W1==null?void 0:W1.chartType)||""),xaxis:(W1==null?void 0:W1.xAxis)||"",customField:(O9=(l9=W1==null?void 0:W1.dynamicXAxis)==null?void 0:l9.selectedOption)==null?void 0:O9.column},dbId:R,elementSettings:(m4=t==null?void 0:t.elementSettings)==null?void 0:m4.metricExpression,drillConfig:J7==null?void 0:J7.configV2,isEncrypted:!!(!A&&f)}},[W1,u,t,o9,h8,Q8,k7,a,n,Y2,j3,Ih,R,K,J7==null?void 0:J7.configV2,f,A,JSON.stringify(T3)]),{data:O6,isLoading:x7,error:a7,refetch:K6}=s70({data:L7,clientId:A?d||"":o,token:f,isFrontendApp:A,isFullScreen:A2},{onSuccess:i8=>{var s9;const r8=qb2(i8);f2&&((s9=r8==null?void 0:r8.error)==null?void 0:s9.code)!=="E1001"&&(f2==null||f2(B8=>{var L9;return[...(B8==null?void 0:B8.filter(N8=>(N8==null?void 0:N8.id)!==(L7==null?void 0:L7.id)))||[],{id:L7==null?void 0:L7.id,isDataFound:!!(r8!=null&&r8.length)&&((W1==null?void 0:W1.chartType)!==L0.singleValue||((L9=r8==null?void 0:r8[0])==null?void 0:L9[(W1==null?void 0:W1.singleValue)||""])!==null)}]}))}}),{mutate:o6}=V30(),{mutateAsync:N7}=Bu2();z0.useEffect(()=>{var r8;const i8=((r8=t==null?void 0:t.rlsConditions)==null?void 0:r8.map(s9=>{var O5,f8,I9,l9,O9,m4,$5,Ke,Ze,pt,De,ne,ye,Ne;let B8=s9;if(e){const Le=eB2(B8,e);Le&&(B8={...B8,filterType:"manual",value:Le.value?B8.datatype==="string"&&((O5=B8==null?void 0:B8.filterVariant)==null?void 0:O5.value)===au?[Le.value]:Le.value:B8.value,options:B8.datatype==="date"?(f8=Le.options)==null?void 0:f8.map(Ie=>({...Ie,startDate:Nc(Ie.fromDate)??Ie.startDate,endDate:Nc(Ie.toDate)??Ie.endDate,minDate:Nc(Ie.minDate)??void 0,maxDate:Nc(Ie.maxDate)??void 0,fromDate:Nc(Ie.fromDate)??void 0,toDate:Nc(Ie.toDate)??void 0})):Le.options,variableOptions:B8.datatype==="date"?(I9=Le.options)==null?void 0:I9.map(Ie=>({range:Ie.range,startDate:Nc(Ie.fromDate)??Ie.startDate,endDate:Nc(Ie.toDate)??Ie.endDate,minDate:Nc(Ie.minDate)??void 0,maxDate:Nc(Ie.maxDate)??void 0,fromDate:Nc(Ie.fromDate)??void 0,toDate:Nc(Ie.toDate)??void 0,value:Ie.name,label:Ie.name})):(l9=Le.options)==null?void 0:l9.map(Ie=>({value:Ie,label:Ie})),selectedVariableValue:Le.value?B8.datatype==="string"?{value:Le.value,label:Le.value}:{startDate:Nc((m4=(O9=Le.options)==null?void 0:O9.find(Ie=>Ie.name===Le.value))==null?void 0:m4.fromDate),endDate:Nc((Ke=($5=Le.options)==null?void 0:$5.find(Ie=>Ie.name===Le.value))==null?void 0:Ke.toDate),value:Le.value,label:Le.value}:B8.selectedVariableValue})}const N8=[...((De=(pt=(Ze=g2==null?void 0:g2.metricViewFilters)==null?void 0:Ze.find(Le=>Le.id===(t==null?void 0:t.id)))==null?void 0:pt.filters)==null?void 0:De.filter(Le=>!(N!=null&&N.find(Ie=>(Le==null?void 0:Le.name)===(Ie==null?void 0:Ie.name)))))||[],...N||[]].find(Le=>B8.name===Le.name);return N8!=null&&N8.value&&(B8={...B8,...N8!=null&&N8.value?{value:N8==null?void 0:N8.value}:{},...N8!=null&&N8.selectedDropdownValue?{selectedDropdownValue:N8==null?void 0:N8.selectedDropdownValue}:{},...N8!=null&&N8.selectedVariableValue?{selectedVariableValue:N8==null?void 0:N8.selectedVariableValue}:{}}),(B8==null?void 0:B8.datatype)==="date"&&((ne=B8==null?void 0:B8.options)==null?void 0:ne.find(Le=>Le.range==="Custom Date"))&&(B8==null?void 0:B8.isEnableDynamicDate)&&((ye=B8==null?void 0:B8.dynamicDate)==null?void 0:ye.value)&&(B8={...B8,options:(Ne=B8==null?void 0:B8.options)==null?void 0:Ne.map(Le=>{var Ie,Qn;return Le.range==="Custom Date"?{...Le,startDate:Na2(((Ie=eb==null?void 0:eb.find(ei=>{var ti;return ei.value===((ti=B8==null?void 0:B8.dynamicDate)==null?void 0:ti.value)}))==null?void 0:Ie.count)||0),endDate:Na2(((Qn=eb==null?void 0:eb.find(ei=>{var ti;return ei.value===((ti=B8==null?void 0:B8.dynamicDate)==null?void 0:ti.value)}))==null?void 0:Qn.count)||0)}:Le})}),a==="DATABASE"?{...B8,tableName:`${o}.${s9.tableName.split(".").slice(1).join(".")}`}:B8}))||[];c7(i8||[])},[t==null?void 0:t.rlsConditions,e,a,o,N,g2]),z0.useEffect(()=>{let i8;return x7?C0(!0):i8=setTimeout(()=>{C0(!1)},300),()=>clearTimeout(i8)},[x7]),z0.useEffect(()=>{t!=null&&t.id&&b2&&!h8&&(t!=null&&t.isMetric)&&(b2==null||b2(i8=>{var r8,s9,B8,L9,N8,e5,B5,O5,f8,I9,l9;return[...(i8==null?void 0:i8.filter(O9=>O9.id!==(t==null?void 0:t.id)))||[],{filters:[...o9||[],...(r8=W1==null?void 0:W1.tableSettings)!=null&&r8.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?(s9=T3==null?void 0:T3.map(O9=>O9.condition))==null?void 0:s9.filter(O9=>Px(O9)):[]],xAxisSettings:{isEnable:!!((B8=W1==null?void 0:W1.dynamicXAxis)!=null&&B8.isEnabled||(L9=W1==null?void 0:W1.enduserMeasureAndDimensions)!=null&&L9.isEnabled)&&Ih.includes((W1==null?void 0:W1.chartType)||""),xaxis:(W1==null?void 0:W1.xAxis)||""},yAxisSettings:{isEnable:!!(!((N8=W1==null?void 0:W1.dynamicYAxis)!=null&&N8.isEnabled)||!((e5=W1==null?void 0:W1.dynamicYAxis)!=null&&e5.selectedOption)||Array.isArray((B5=W1==null?void 0:W1.dynamicYAxis)==null?void 0:B5.selectedOption)),yAxis:((O5=W1==null?void 0:W1.dynamicYAxis)==null?void 0:O5.selectedOption)||""},id:t==null?void 0:t.id,metricRequestData:{isAllClient:u,timeseriesSettings:h8?void 0:{format:((l9=(I9=(f8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:f8.groupBySettings)==null?void 0:I9.value)==null?void 0:l9.toLowerCase())||"monthly",seriesField:(W1==null?void 0:W1.seriesField)||"",isFiscal:K==="ind"}}}]}))},[t==null?void 0:t.id,t==null?void 0:t.isMetric,o9,W1==null?void 0:W1.timeSeriesSettings,W1==null?void 0:W1.seriesField,h8,K,u,T3,(z4=W1==null?void 0:W1.tableSettings)==null?void 0:z4.isServerSidePagination,W1==null?void 0:W1.chartType,W1==null?void 0:W1.dynamicYAxis,W1==null?void 0:W1.dynamicXAxis]),z0.useEffect(()=>{var i8,r8,s9,B8,L9,N8;if((i8=t==null?void 0:t.drillDownSettings)!=null&&i8.isEnableGroupBy){const e5=t==null?void 0:t.datasetMetricSettings;!((r8=t==null?void 0:t.drillDownSettings)!=null&&r8.configV2)&&!(J7!=null&&J7.configV2)&&((B8=(s9=e5==null?void 0:e5.newDatasetSettings)==null?void 0:s9.selectedMetrics)!=null&&B8.length)&&((N8=(L9=e5==null?void 0:e5.newDatasetSettings)==null?void 0:L9.selectedDims)!=null&&N8.length)?e8(B5=>{var O5,f8,I9;return{...(t==null?void 0:t.drillDownSettings)||{},configV2:{isEnable:!!((O5=t==null?void 0:t.drillDownSettings)!=null&&O5.isEnableGroupBy),levels:(I9=(f8=e5==null?void 0:e5.newDatasetSettings)==null?void 0:f8.selectedDims)==null?void 0:I9.map((l9,O9)=>{var $5,Ke,Ze,pt;const m4=(Ze=(Ke=($5=t==null?void 0:t.drillDownSettings)==null?void 0:$5.drilldownChartSettings)==null?void 0:Ke.find(De=>(De==null?void 0:De.name)===(l9==null?void 0:l9.alias)))==null?void 0:Ze.chartSettings;return{name:`Drill Level ${O9+1}`,chartSettings:m4||W1,index:PB(4),isEnable:O9===0,dimensions:[l9],measures:((pt=e5==null?void 0:e5.newDatasetSettings)==null?void 0:pt.selectedMetrics)||[]}})}}}):J7!=null&&J7.isEnableGroupBy||e8(t==null?void 0:t.drillDownSettings)}},[(Ce=t==null?void 0:t.drillDownSettings)==null?void 0:Ce.isEnableGroupBy,(N9=t==null?void 0:t.drillDownSettings)==null?void 0:N9.configV2,t==null?void 0:t.datasetMetricSettings,W1]);const{mutateAsync:r6}=v_(),q3=z0.useMemo(()=>{var s9,B8,L9,N8,e5,B5,O5,f8,I9,l9,O9,m4,$5,Ke,Ze,pt;const i8=((s9=t==null?void 0:t.datasetMetricSettings)==null?void 0:s9.metricVariables)||[];if(!i8||!Array.isArray(i8)||!(i8!=null&&i8.length))return[];const r8=[];for(let De=0;De<(i8==null?void 0:i8.length);De++){const ne=i8[De],ye=ne.type.value==="custom"&&ne.customQuery&&ne.customColumnName,Ne=ye?{query:lb({query:(ne==null?void 0:ne.customQuery)||"",tenancyLevel:a,clientId:o,isAllClient:u,clientColumnType:Q||"STRING",dbName:(B8=t==null?void 0:t.companyIntegration)==null?void 0:B8.name,rlsConditions:o9==null?void 0:o9.filter(xe=>xe.isVariableFilter),globalFilters:{...n,filters:(L9=n==null?void 0:n.filters)==null?void 0:L9.filter(xe=>{var Wr;return(xe==null?void 0:xe.isVariableFilter)&&!!(Array.isArray(xe==null?void 0:xe.value)?(Wr=xe==null?void 0:xe.value)!=null&&Wr.length:xe)})}}),alias:fP}:void 0,Le=(N8=ne.dependOnOptions)!=null&&N8.length?o9==null?void 0:o9.filter(xe=>ne.dependOnOptions.some(Wr=>{var Xt;return Wr.type==="metric"&&((Xt=Wr.filter)==null?void 0:Xt.value)===xe.name&&Wr.column})):[],Ie=(e5=ne.dependOnOptions)!=null&&e5.length?(B5=n==null?void 0:n.filters)==null?void 0:B5.filter(xe=>{var Wr;return Array.isArray(xe==null?void 0:xe.value)?(Wr=xe==null?void 0:xe.value)==null?void 0:Wr.length:xe&&ne.dependOnOptions.some(Xt=>{var Mr;return Xt.type==="dashboard"&&((Mr=Xt.filter)==null?void 0:Mr.value)===xe.label&&Xt.column})}):[],Qn=Le==null?void 0:Le.map(xe=>{var Wr;return{columnName:((Wr=ne.dependOnOptions.find(Xt=>{var Mr;return xe.name===((Mr=Xt.filter)==null?void 0:Mr.value)}))==null?void 0:Wr.column)||"",value:xe.value,as:"string"}}),ei=Ie==null?void 0:Ie.map(xe=>{var Wr;return{columnName:((Wr=ne.dependOnOptions.find(Xt=>{var Mr;return xe.label===((Mr=Xt.filter)==null?void 0:Mr.value)}))==null?void 0:Wr.column)||"",value:Cb(xe==null?void 0:xe.value),as:"string"}});ne.isClientScoped&&o&&Q&&!u&&a==="TABLE"&&((f8=(O5=ne.clientColumn)==null?void 0:O5.name)!=null&&f8.value)&&((l9=(I9=ne.clientColumn)==null?void 0:I9.datatype)!=null&&l9.value)&&Qn.push({columnName:(m4=(O9=ne.clientColumn)==null?void 0:O9.name)==null?void 0:m4.value,value:o,as:(Ke=($5=ne.clientColumn)==null?void 0:$5.datatype)==null?void 0:Ke.value});const ti=[...Qn,...ei];r8.push({object:{wId:g,tableName:ye?"":(Ze=ne==null?void 0:ne.table)==null?void 0:Ze.value,columnName:ye?(ne==null?void 0:ne.customColumnName)||"":((pt=ne==null?void 0:ne.column)==null?void 0:pt.value)||"",filter:ti,customTable:Ne,limit:"1",datasourceId:R,databaseName:a==="MULTI_DATABASE"&&o||""},element:ne})}return r8},[(K5=t==null?void 0:t.datasetMetricSettings)==null?void 0:K5.metricVariables,JSON.stringify(n==null?void 0:n.filters),o9,Q,g,a,o,u,R]),Z6=async i8=>{var s9,B8,L9,N8,e5;P2(!0);const r8={};i8==null||i8.forEach(B5=>{var O5,f8;r8[(O5=B5==null?void 0:B5.element)==null?void 0:O5.name]=((f8=B5==null?void 0:B5.element)==null?void 0:f8.defaultValue)||""}),y5(r8);for(let B5=0;B5<(i8==null?void 0:i8.length);B5++){const O5=i8[B5];if(r8[O5.element.name]=O5.element.defaultValue||"",P2(!0),O5.object.wId&&(!((B8=(s9=O5==null?void 0:O5.object)==null?void 0:s9.customTable)!=null&&B8.query)||!((e5=(N8=(L9=O5==null?void 0:O5.object)==null?void 0:L9.customTable)==null?void 0:N8.query)!=null&&e5.includes("{{")))){const f8=await r6(O5.object);f8!=null&&f8.data&&Array.isArray(f8.data)&&y5(I9=>{var l9,O9;return{...I9,[O5.element.name]:((O9=(l9=f8==null?void 0:f8.data)==null?void 0:l9[0])==null?void 0:O9.value)||O5.element.defaultValue||""}})}}setTimeout(()=>{P2(!1)},200)};z0.useEffect(()=>{q3!=null&&q3.length&&Z6(q3)},[JSON.stringify(q3)]);const o8=z0.useMemo(()=>{var i8,r8,s9,B8;return(B8=(s9=(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)==null?void 0:r8.selectedDims)==null?void 0:s9[0])==null?void 0:B8.name},[t]);z0.useMemo(()=>{var i8,r8,s9,B8;return Qa2(((B8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.selectedDimensions)==null?void 0:B8[k7.length<((s9=(r8=t==null?void 0:t.datasetMetricSettings)==null?void 0:r8.selectedDimensions)==null?void 0:s9.length)?k7.length:0])||"")},[t==null?void 0:t.datasetMetricSettings,k7]),z0.useEffect(()=>{var s9,B8,L9;const r8=((s9=t==null?void 0:t.drillDownSettings)==null?void 0:s9.isEnableGroupBy)?l3||[]:[...l3!=null&&l3.length?l3:[],...l||[]];(B8=r8==null?void 0:r8.filter(N8=>N8.isAddOnMetrics))!=null&&B8.length?M9((L9=r8.filter(N8=>N8.isAddOnMetrics))==null?void 0:L9.map(N8=>{var e5,B5,O5,f8,I9;return s?{...N8,dimensionColumn:(W1==null?void 0:W1.xAxis)||"",measureColumn:((e5=W1==null?void 0:W1.yAxisList)==null?void 0:e5[0])||"",options:N8.datatype!==Xu?[]:N8.options,variableOptions:N8.datatype!==Xu?[]:N8.variableOptions}:{...N8,dimensionColumn:(W1==null?void 0:W1.xAxis)||"",measureColumn:((B5=W1==null?void 0:W1.yAxisList)==null?void 0:B5[0])||"",value:N8.isAppFilter?N8.datatype==="date"?(O5=N8==null?void 0:N8.options)==null?void 0:O5.find(l9=>{var O9;return l9.name===((O9=r==null?void 0:r.values)==null?void 0:O9[N8.name])||N8.value}):((f8=r==null?void 0:r.values)==null?void 0:f8[N8.name])||N8.value:N8.value,options:N8.datatype!==Xu?[]:(I9=N8==null?void 0:N8.options)==null?void 0:I9.map(l9=>K==="ind"&&N8.datatype===Xu?{...l9,isFiscal:!0}:l9),variableOptions:N8.datatype!==Xu?[]:N8.variableOptions}}).filter(N8=>Px(N8))):M9([])},[l3,r,l,(s4=t==null?void 0:t.drillDownSettings)==null?void 0:s4.isEnableGroupBy,a,s,o,K]);const D8=z0.useMemo(()=>{var i8,r8,s9;return(W1==null?void 0:W1.chartType)===L0.singleValue&&!!((i8=W1==null?void 0:W1.customSettings)!=null&&i8.comparisonValueShow)&&!!((r8=W1==null?void 0:W1.customSettings)!=null&&r8.comparisonTimeGrain)&&!!((s9=W1==null?void 0:W1.customSettings)!=null&&s9.comparisonTimePeriod)&&!!(W1!=null&&W1.singleValue)},[W1]);z0.useEffect(()=>{var L9,N8,e5,B5,O5;const i8=O6;let r8=i8!=null&&i8.data&&typeof i8.data=="string"?JSON.parse(i8.data):i8!=null&&i8.data&&Array.isArray(i8==null?void 0:i8.data)?i8==null?void 0:i8.data:[];l8({data:[],error:"",isLoading:!1,currentValue:""}),(W1==null?void 0:W1.chartType)===L0.table&&B3((i8==null?void 0:i8.totalRecords)||0),r8=Da2(r8||[],((N8=(L9=t==null?void 0:t.datasetMetricSettings)==null?void 0:L9.newDatasetSettings)==null?void 0:N8.selectedDims)||[],((B5=(e5=t==null?void 0:t.datasetMetricSettings)==null?void 0:e5.newDatasetSettings)==null?void 0:B5.selectedMetrics)||[]);const s9=(()=>{var f8,I9,l9,O9;if(!Array.isArray(r8))return[];if(((I9=(f8=t==null?void 0:t.companyIntegration)==null?void 0:f8.name)==null?void 0:I9.toLowerCase())===Cg&&!h8){const m4=(l9=t==null?void 0:t.datasetMetricSettings)==null?void 0:l9.newDatasetSettings,$5=(m4==null?void 0:m4.selectedMetrics)||[],Ke=((O9=m4==null?void 0:m4.selectedDims)==null?void 0:O9.filter(pt=>{var De,ne;return!((ne=(De=pt==null?void 0:pt.alias)==null?void 0:De.toLowerCase())!=null&&ne.match(/monthly|quarterly|weekly|yearly|daily/))}))||[],Ze=[...Ke==null?void 0:Ke.map(pt=>pt.alias),...$5==null?void 0:$5.map(pt=>pt.alias)];return Ha2(Ze,r8)}return r8})();if(Z7(s9),(O5=t==null?void 0:t.datasetMetricSettings)!=null&&O5.isUseRawSQL){const f8=Object.keys((s9==null?void 0:s9[0])||{})||[];W9(I9=>({...I9,yAxisList:f8||(I9==null?void 0:I9.yAxisList)||[]}))}const B8=i8==null?void 0:i8.metaData;x6(zY(B8==null?void 0:B8.groupbyColumnList)),h3(f8=>({...f8,report:"",isLoading:f8==null?void 0:f8.isLoading,isOpen:f8==null?void 0:f8.isOpen}))},[O6,t==null?void 0:t.datasetMetricSettings,h8]),z0.useEffect(()=>{var i8,r8;(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.createdSorts)!=null&&r8.length?_5(!0):_5(!1)},[(B4=(le=t==null?void 0:t.datasetMetricSettings)==null?void 0:le.createdSorts)==null?void 0:B4.length]),z0.useEffect(()=>{var i8,r8;(W1==null?void 0:W1.chartType)===L0.timeSeries&&((r8=(i8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:i8.groupBySettings)!=null&&r8.value)&&!h8&&W9(s9=>{var B8,L9,N8;return{...s9,xAxis:`${(N8=(L9=(B8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:B8.groupBySettings)==null?void 0:L9.value)==null?void 0:N8.toLowerCase()} of ${o8}`}})},[V3,W1==null?void 0:W1.chartType,W1==null?void 0:W1.timeSeriesSettings,h8]),z0.useEffect(()=>{var i8;if(W1!=null&&W1.isEnableComparisonFilter&&[L0.line].includes(W1==null?void 0:W1.chartType)){const r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings,s9=(r8==null?void 0:r8.selectedMetrics)||[],B8=Object==null?void 0:Object.keys((V3==null?void 0:V3[0])||{});W9(L9=>({...L9,yAxisList:[...B8.filter(N8=>s9==null?void 0:s9.some(e5=>N8.startsWith(e5.alias)))]}))}},[V3,W1==null?void 0:W1.isEnableComparisonFilter,j3,W1==null?void 0:W1.chartType]);const z8=z0.useCallback((i8,r8,s9,B8,L9,N8)=>{w==null||w(v30,t==null?void 0:t.id),c7(B8?e5=>e5==null?void 0:e5.map(B5=>{var O5,f8;return B5.name===i8?{...B5,value:r8,options:(O5=B5.options)==null?void 0:O5.map(I9=>r8===I9.name?{...I9,...B8,timeGrainValue:N8}:I9),variableOptions:(f8=B5.variableOptions)==null?void 0:f8.map(I9=>I9.value===r8?{...I9,...B8,timeGrainValue:N8}:I9),selectedVariableValue:{value:r8,label:r8,endDate:B8.endDate,startDate:B8.startDate,timeGrainValue:N8}}:B5}):L9?e5=>e5==null?void 0:e5.map(B5=>B5.name===i8?{...B5,value:L9!=null&&L9.length?L9==null?void 0:L9.map(O5=>O5.value):void 0,selectedDropdownValue:L9!=null&&L9.length?L9:void 0}:B5):e5=>e5==null?void 0:e5.map(B5=>B5.name===i8?{...B5,value:r8,selectedVariableValue:{value:r8,label:r8},selectedDropdownValue:{value:r8,label:s9||r8}}:B5))},[]),k8=z0.useCallback(i8=>{var r8,s9;i8!=null&&i8.event&&((s9=(r8=i8==null?void 0:i8.event)==null?void 0:r8.event)==null||s9.preventDefault()),t0(i8)},[l3]),{getUnderlyingData:k3}=a70({clientName:o,dbName:(O4=t==null?void 0:t.companyIntegration)==null?void 0:O4.name,tenancyType:a,values:Q8,companyId:t==null?void 0:t.companyId,query:Od(t==null?void 0:t.query,t==null?void 0:t.companyId),workspaceId:g,metricId:t==null?void 0:t.id,rlsConditions:o9,globalFilters:n,isAllClient:!!u,dataMartRelationships:Y6,customSql:(C3=(i1=t==null?void 0:t.clickActions)==null?void 0:i1.underlyingData)==null?void 0:C3.sql,isEnableCustomSQL:(W1==null?void 0:W1.chartType)===L0.singleValue&&((x3=(W3=t==null?void 0:t.clickActions)==null?void 0:W3.underlyingData)==null?void 0:x3.isEnable)&&((s3=(_7=t==null?void 0:t.clickActions)==null?void 0:_7.underlyingData)==null?void 0:s3.sql),datasourceId:R}),h5=z0.useMemo(()=>Array.isArray(V3)&&V3.length&&(n3!=null&&n3.name)?V3==null?void 0:V3.map(i8=>{const r8=Object.entries(i8).find(([,s9])=>(typeof s9=="number"&&typeof(n3==null?void 0:n3.name)=="string"?s9==null?void 0:s9.toString():s9)===n3.name);return r8==null?void 0:r8[0]}).filter(i8=>i8)[0]:"",[V3,n3==null?void 0:n3.name]),I8=async(i8,r8,s9,B8)=>{var Ne,Le,Ie,Qn,ei,ti,xe,Wr,Xt,Mr,Mn,sn,Oi,_r,Tn,Fi,li,Ei,eo,to,Gi,kn,On,ko,Oo,na,ca;const L9=t==null?void 0:t.datasetMetricSettings;if(!(J7!=null&&J7.configV2)||!((Ne=L9==null?void 0:L9.newDatasetSettings)!=null&&Ne.configuration)||!((Le=t==null?void 0:t.companyIntegration)!=null&&Le.name)||!i8)return;let N8=i8;const e5=(N8==null?void 0:N8.levels)||[],B5=e5==null?void 0:e5.find(Pe=>s9?Pe.index===s9:Pe==null?void 0:Pe.isEnable),O5=e5==null?void 0:e5.findIndex(Pe=>s9?Pe.index===s9:Pe==null?void 0:Pe.isEnable),f8=O5>=0&&O5<(e5==null?void 0:e5.length)-1,I9=f8?e5==null?void 0:e5[O5+1]:e5==null?void 0:e5[0],l9=r8==null?void 0:r8.name,O9=(r8==null?void 0:r8.rowFilters)||[],m4=(Qn=(Ie=B5==null?void 0:B5.dimensions)==null?void 0:Ie[0])==null?void 0:Qn.alias;!B5||B8?N8={...N8||{},levels:((ei=N8==null?void 0:N8.levels)==null?void 0:ei.map((Pe,Pn)=>Pn==0?{...Pe,filters:[],isEnable:!0}:{...Pe,isEnable:!1}))||[]}:s9&&B5?N8={...N8||{},levels:((ti=N8==null?void 0:N8.levels)==null?void 0:ti.map((Pe,Pn)=>Pe.index===(B5==null?void 0:B5.index)?{...Pe,filters:[...(B5==null?void 0:B5.filters)||[]],isEnable:!0}:{...Pe,filters:Pn>O5?[]:Pe==null?void 0:Pe.filters,isEnable:!1}))||[]}:(l9&&m4||O9!=null&&O9.length)&&B5?N8={...N8||{},levels:((xe=N8==null?void 0:N8.levels)==null?void 0:xe.map(Pe=>Pe.index===(I9==null?void 0:I9.index)?{...Pe,filters:f8?[...(B5==null?void 0:B5.filters)||[],...O9!=null&&O9.length?O9:[{columnName:m4,value:l9}]]:[],isEnable:!0}:{...Pe,isEnable:!1}))||[]}:N8={...N8||{},levels:((Wr=N8==null?void 0:N8.levels)==null?void 0:Wr.map(Pe=>Pe.index===(B5==null?void 0:B5.index)?{...Pe,filters:[],isEnable:!0}:{...Pe,isEnable:!1}))||[]},N8={...N8||{},levels:((Xt=N8==null?void 0:N8.levels)==null?void 0:Xt.map(Pe=>{var Pn,en;return{...Pe,dimensions:((Pn=Pe==null?void 0:Pe.dimensions)==null?void 0:Pn.filter(i9=>{var o5,I4;return(I4=(o5=L9==null?void 0:L9.newDatasetSettings)==null?void 0:o5.selectedDims)==null?void 0:I4.some(Ge=>Ge.alias===(i9==null?void 0:i9.alias))}))||[],measures:((en=Pe==null?void 0:Pe.measures)==null?void 0:en.filter(i9=>{var o5,I4;return(I4=(o5=L9==null?void 0:L9.newDatasetSettings)==null?void 0:o5.selectedMetrics)==null?void 0:I4.some(Ge=>Ge.alias===(i9==null?void 0:i9.alias))}))||[]}}))||[]};const $5=(Mr=N8==null?void 0:N8.levels)==null?void 0:Mr.find(Pe=>Pe==null?void 0:Pe.isEnable),Ke=!!((Oi=(sn=N8==null?void 0:N8.levels)==null?void 0:sn[((Mn=N8==null?void 0:N8.levels)==null?void 0:Mn.length)-1])!=null&&Oi.isEnable);(Tn=(_r=N8==null?void 0:N8.levels)==null?void 0:_r[0])==null||Tn.isEnable;const Ze=($5==null?void 0:$5.chartSettings)||W1,pt=(Ze==null?void 0:Ze.chartType)===L0.table,De=[...((Fi=$5==null?void 0:$5.dimensions)==null?void 0:Fi.map(Pe=>Pe.alias))||[],...((li=$5==null?void 0:$5.measures)==null?void 0:li.map(Pe=>Pe.alias))||[]],ne={...Ze,xAxis:((eo=(Ei=$5==null?void 0:$5.dimensions)==null?void 0:Ei[0])==null?void 0:eo.alias)||"",yAxisList:Ke&&!(Ze!=null&&Ze.chartType)||pt?De:((to=$5==null?void 0:$5.measures)==null?void 0:to.map(Pe=>Pe.alias))||[],chartType:Ke&&!(Ze!=null&&Ze.chartType)?L0.table:Ze==null?void 0:Ze.chartType},ye=`${(On=(kn=(Gi=$5==null?void 0:$5.dimensions)==null?void 0:Gi[0])==null?void 0:kn.table)==null?void 0:On.schemaName}.${(na=(Oo=(ko=$5==null?void 0:$5.dimensions)==null?void 0:ko[0])==null?void 0:Oo.table)==null?void 0:na.tableName}`;if(e8(Pe=>{var Pn;return{...Pe,configV2:{...N8||{},levels:((Pn=N8==null?void 0:N8.levels)==null?void 0:Pn.map(en=>en.index===($5==null?void 0:$5.index)?{...en,chartSettings:ne}:en))||[]}}}),W9(Pe=>ne),(ca=t==null?void 0:t.drillDownSettings)!=null&&ca.isEnableCrossFilter){const Pe=(()=>{var Pn;if(B8||s9)return[];if((l9&&m4||O9!=null&&O9.length)&&B5){if(O9!=null&&O9.length){const en=(Pn=O9==null?void 0:O9.map(i9=>{var Ge,Cn,zn,Zn;const o5=(Cn=(Ge=L9==null?void 0:L9.newDatasetSettings)==null?void 0:Ge.selectedDims)==null?void 0:Cn.find(dn=>(dn==null?void 0:dn.alias)===(i9==null?void 0:i9.columnName)),I4=`${(zn=o5==null?void 0:o5.table)==null?void 0:zn.schemaName}.${(Zn=o5==null?void 0:o5.table)==null?void 0:Zn.tableName}`;if(o5)return{columnName:i9==null?void 0:i9.columnName,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[i9==null?void 0:i9.value],tableName:a==="DATABASE"?`${o}.${I4==null?void 0:I4.split(".").slice(1).join(".")}`:I4,value:[i9==null?void 0:i9.value]}}))==null?void 0:Pn.filter(i9=>i9);return[...l||[],...en]}if(m4&&l9)return[...l||[],{columnName:m4,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[l9],tableName:a==="DATABASE"?`${o}.${ye==null?void 0:ye.split(".").slice(1).join(".")}`:ye,value:[l9]}]}return[]})();C==null||C(Pe)}},D9=async(i8,r8)=>{await I8(J7==null?void 0:J7.configV2,i8)},E8=({filters:i8,nextLevel:r8,currentValue:s9})=>{var De,ne;const B8=(De=t==null?void 0:t.datasetMetricSettings)==null?void 0:De.newDatasetSettings,L9=B8==null?void 0:B8.configuration,N8=(B8==null?void 0:B8.selectedDims)||[],e5=(B8==null?void 0:B8.selectedMetrics)||[],B5=((ne=t==null?void 0:t.datasetMetricSettings)==null?void 0:ne.createdSorts)||[],{headerColumns:O5,nonHeaderColumns:f8}=N8.reduce((ye,Ne)=>{var Le,Ie;return(Ie=(Le=W1==null?void 0:W1.pivotTableSettings2)==null?void 0:Le.headers)!=null&&Ie.includes(Ne.alias)?ye.headerColumns.push(Ne):ye.nonHeaderColumns.push(Ne),ye},{headerColumns:[],nonHeaderColumns:[]}),I9=i8==null?void 0:i8.map(ye=>`${ye.columnName};;${ye.value}`).join(";;");l8(ye=>({...ye,data:ye.data.filter(Ne=>Ne.key!==I9),error:"",isLoading:!0,currentValue:s9}));const l9=f8.slice(0,r8),O9=i8==null?void 0:i8.map(ye=>{const Ne=N8.find(Le=>Le.alias===ye.columnName);if(Ne)return{alias:Ne.alias||"",columnName:Ne.name,dataType:Ne.datatype,method:"=",parentAlias:Ne.parentAlias,type:"dimension",value:ye.value,relationOperator:"AND"}}).filter(ye=>ye),m4=[...l9,...e5,...O5],{aggregates:$5,dimensions:Ke}=Fu(m4),Ze=LJ2(B5),pt={...L9,dimensions:Ke,aggregates:$5,filters:[...L9.filters,...O9],orders:(Ze==null?void 0:Ze.filter(ye=>(ye==null?void 0:ye.type)==="selected_column"?m4==null?void 0:m4.some(Ne=>(Ne==null?void 0:Ne.alias)===(ye==null?void 0:ye.name)):!0))||[],isApplyGlobalFilter:!0,isApplyMetricFilter:!0,globalFilters:n,rlsConditions:o9};o6({data:{configuration:pt,id:g,datasourceId:R,dashboardId:"",isCreateMetric:!0},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(ye){const Ne=ye==null?void 0:ye.error,Le=ye==null?void 0:ye.data;Ne!=null&&Ne.message?l8(Ie=>({...Ie,error:Ne==null?void 0:Ne.message,isLoading:!1,currentValue:""})):(l8(Ie=>({data:[...Ie.data,{key:I9,data:Array.isArray(Le)?Le:[]}],error:"",isLoading:!1,currentValue:""})),W9(Ie=>{var Qn,ei;return{...Ie,pivotTableSettings2:{...W1==null?void 0:W1.pivotTableSettings2,dimensions:OB(l9,((Qn=t==null?void 0:t.companyIntegration)==null?void 0:Qn.name)||""),headers:OB(O5,((ei=t==null?void 0:t.companyIntegration)==null?void 0:ei.name)||"")}}}))}})},A5=z0.useCallback(async(i8,r8)=>{await I8(J7==null?void 0:J7.configV2,void 0,i8,r8)},[J7==null?void 0:J7.configV2]),y9=z0.useCallback(i8=>{var r8;if(i8)c7(s9=>[...s9==null?void 0:s9.filter(B8=>B8.group!==`${j3}`)]),w7(s9=>s9-1);else{const s9=(r8=l3.filter(B8=>!(B8!=null&&B8.group)))==null?void 0:r8.map(B8=>{var L9,N8,e5,B5;return{...B8,name:`${B8==null?void 0:B8.name}_${j3+1}`,group:`${j3+1}`,dependOn:B8.dependOn?{value:`${(L9=B8.dependOn)==null?void 0:L9.value}_${j3+1}`,label:`${(N8=B8.dependOn)==null?void 0:N8.label}_${j3+1}`,customColumnName:(e5=B8.dependOn)==null?void 0:e5.customColumnName}:void 0,dependOns:((B5=B8==null?void 0:B8.dependOns)==null?void 0:B5.map(O5=>({value:`${O5==null?void 0:O5.value}_${j3+1}`,label:`${O5==null?void 0:O5.label}_${j3+1}`,customColumnName:O5==null?void 0:O5.customColumnName})))||[]}});s9.length&&(c7(B8=>[...B8,...s9]),w7(B8=>B8+1))}},[l3]),p5=z0.useCallback(async()=>{v1.report?h3(i8=>({...i8,isOpen:!0})):(h3({report:"",isLoading:!0,isOpen:!0}),await N7({data:{data:V3,wId:g},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(i8){const r8=i8==null?void 0:i8.content;h3(s9=>({...s9,report:r8||"",isLoading:!1}))},onError(){h3(i8=>({...i8,report:"",isLoading:!1}))}}))},[V3,o,A,f,d,o,v1]),T4=z0.useMemo(()=>{var O5,f8,I9,l9,O9,m4;const i8=(O5=t==null?void 0:t.datasetMetricSettings)==null?void 0:O5.newDatasetSettings,r8=i8==null?void 0:i8.configuration,s9=Zx(V3||[]);let B8=s9;const L9=((f8=i8==null?void 0:i8.selectedDims)==null?void 0:f8.some($5=>{var Ke,Ze,pt;return Bl.includes(((Ze=(Ke=$5==null?void 0:$5.cast)==null?void 0:Ke.value)==null?void 0:Ze.toLowerCase())||((pt=$5==null?void 0:$5.datatype)==null?void 0:pt.toLowerCase())||"")}))||mJ2((V3==null?void 0:V3[0])||""),N8=((I9=i8==null?void 0:i8.selectedDims)==null?void 0:I9.length)>1&&((l9=i8==null?void 0:i8.selectedMetrics)==null?void 0:l9.length)>0,e5=[L0.pivot,L0.pivotV2,L0.pivotV3,L0.timeSeries,L0.treeMap,L0.indianMap,L0.geoBarMap,L0.geoMap,L0.geoScatterMap,L0.worldMap],B5=!!((O9=r8==null?void 0:r8.aggregates)!=null&&O9.length)&&!!((m4=r8==null?void 0:r8.dimensions)!=null&&m4.length);return B5&&L9&&(B8=[...s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5))),...e5]),B5&&!L9&&(B8=[...s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5))),...e5==null?void 0:e5.filter($5=>$5!==L0.timeSeries)]),!B5&&L9&&(B8=[...s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5))),L0.timeSeries]),!B5&&!L9&&(B8=s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5)))),J7!=null&&J7.isEnableGroupBy&&(J7!=null&&J7.configV2)&&(B8=B8==null?void 0:B8.filter($5=>$m==null?void 0:$m.includes($5))),N8||(B8=B8==null?void 0:B8.filter($5=>$5!==L0.bubbleV2)),B8},[V3,W1==null?void 0:W1.xAxis,J7==null?void 0:J7.isEnableGroupBy,J7==null?void 0:J7.configV2,(U6=(B6=(t7=t==null?void 0:t.datasetMetricSettings)==null?void 0:t7.newDatasetSettings)==null?void 0:B6.configuration)==null?void 0:U6.aggregates,(F7=(r7=(e9=t==null?void 0:t.datasetMetricSettings)==null?void 0:e9.newDatasetSettings)==null?void 0:r7.configuration)==null?void 0:F7.dimensions]),k4=i8=>{var B5,O5,f8;const r8=(B5=t==null?void 0:t.datasetMetricSettings)==null?void 0:B5.newDatasetSettings,s9=r8==null?void 0:r8.configuration,B8=(r8==null?void 0:r8.selectedDims)||[],L9=(r8==null?void 0:r8.selectedMetrics)||[],N8=(O5=t==null?void 0:t.companyIntegration)==null?void 0:O5.name,e5=(f8=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:f8.isEnabled;bJ2({chartAggregateColumns:GY(OB((L9==null?void 0:L9.filter(I9=>{var l9,O9;return I9.configType==="AGGREGATE"&&e5?(O9=(l9=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:l9.measures)==null?void 0:O9.some(m4=>m4.value===I9.alias):!0}))||[],N8),V3||[]),chartDimensions:GY(OB((B8==null?void 0:B8.filter(I9=>{var l9,O9;return e5?(O9=(l9=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:l9.dimensions)==null?void 0:O9.some(m4=>m4.value===I9.alias):!0}))||[],N8),V3||[]),chartMetrics:GY(OB((L9==null?void 0:L9.filter(I9=>{var l9,O9;return e5?(O9=(l9=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:l9.measures)==null?void 0:O9.some(m4=>m4.value===I9.alias):!0}))||[],N8),V3||[]),chartSettings:W1,chartTimeColumns:OB(B8==null?void 0:B8.filter(I9=>{var l9;return Bl.includes((l9=I9.datatype)==null?void 0:l9.toLowerCase())}),N8),chartType:i8,configAggregates:s9==null?void 0:s9.aggregates,configuration:r8==null?void 0:r8.configuration,pivotHeaderColumns:[],resultData:V3||[],setChartSettings:W9})},Te=z0.useMemo(()=>LP(l3.filter(i8=>i8.group&&i8.isAddOnMetrics&&!i8.isAppFilter),"group"),[l3]),X5=z0.useMemo(()=>{var s9,B8;return((s9=W1==null?void 0:W1.customSettings)==null?void 0:s9.comparisonValueShow)&&(W1==null?void 0:W1.chartType)===L0.singleValue?(B8=n==null?void 0:n.filters)==null?void 0:B8.find(L9=>(L9==null?void 0:L9.as)==="date"):void 0},[(s8=W1==null?void 0:W1.customSettings)==null?void 0:s8.comparisonValueShow,W1==null?void 0:W1.chartType,(Y7=n==null?void 0:n.filters)==null?void 0:Y7.find(i8=>(i8==null?void 0:i8.as)==="date")]);z0.useEffect(()=>{V3!=null&&V3.length&&z7.length?h9(!0):h9(!1)},[V3,z7.length,t==null?void 0:t.integrationName,t==null?void 0:t.query]);const te=z0.useMemo(()=>{var i8,r8,s9,B8,L9,N8;return(s9=(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)==null?void 0:r8.selectedMetrics)!=null&&s9.some(e5=>e5.configType==="AGGREGATE")?((N8=(L9=(B8=t==null?void 0:t.datasetMetricSettings)==null?void 0:B8.newDatasetSettings)==null?void 0:L9.selectedDims)==null?void 0:N8.map(e5=>({value:e5.alias,label:e5.alias})))||[]:[]},[(G1=t==null?void 0:t.datasetMetricSettings)==null?void 0:G1.newDatasetSettings]),V4=z0.useMemo(()=>{var i8,r8,s9;return((s9=(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)==null?void 0:r8.selectedMetrics)==null?void 0:s9.map(B8=>({value:(B8==null?void 0:B8.alias)||(B8==null?void 0:B8.name),label:(B8==null?void 0:B8.alias)||(B8==null?void 0:B8.name)})))||[]},[(h6=(E7=t==null?void 0:t.datasetMetricSettings)==null?void 0:E7.newDatasetSettings)==null?void 0:h6.selectedMetrics]),{metricFilters:fe,leftPositionedMetricFilters:Y5,rightPositionedMetricFilters:Q6}=z0.useMemo(()=>{const i8=l3.filter(L9=>!L9.isAppFilter);let r8=i8.filter(L9=>L9.isAddOnMetrics);j2&&(r8=r8.filter(L9=>Px(L9,!0)));const s9=[],B8=[];return r8.forEach(L9=>{L9.position==="top-right"?B8.push(L9):s9.push(L9)}),{metricFilters:i8,leftPositionedMetricFilters:s9,rightPositionedMetricFilters:B8}},[l3]),_8=[L0.pie,L0.doughnut,L0.rose,L0.funnel,L0.singleValue,L0.table,L0.pivot,L0.horizontalStackTable,L0.geoBarMap,L0.geoMap,L0.geoScatterMap,L0.sankey,L0.timeSeries,L0.geoBarMap,L0.geoMap,L0.geoScatterMap,L0.worldMap,L0.boxplot,L0.timeSeries,L0.gantt].includes(W1==null?void 0:W1.chartType)||((W1==null?void 0:W1.isMultiDimension)||(W1==null?void 0:W1.isDynamicSeries))&&(W1==null?void 0:W1.seriesField)!=="ungrouped",k6=z0.useMemo(()=>{var r8;const i8=((r8=t==null?void 0:t.dataSecuritySettings)==null?void 0:r8.csvColumns)||[];return V3!=null&&V3.length?V3==null?void 0:V3.map(s9=>{const B8={};for(const L9 in s9)i8!=null&&i8.includes(L9)||(B8[L9]=s9[L9]);return B8}):[]},[V3,t==null?void 0:t.dataSecuritySettings]);z0.useEffect(()=>{var i8,r8;W1||(W9(t==null?void 0:t.chartOptions),L3({limit:parseInt(((r8=(i8=t==null?void 0:t.chartOptions)==null?void 0:i8.tableSettings)==null?void 0:r8.defaultRowSize)||"100",10),offset:0}))},[t==null?void 0:t.chartOptions,W1]),z0.useEffect(()=>{var i8,r8,s9,B8,L9,N8,e5,B5,O5,f8;if((W1==null?void 0:W1.chartType)===L0.timeSeries&&((r8=(i8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:i8.groupBySettings)!=null&&r8.isGlobalFilter)&&o8){const I9=(B8=(s9=n==null?void 0:n.filters)==null?void 0:s9.find(l9=>{var O9,m4,$5;return l9.label===(($5=(m4=(O9=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:O9.groupBySettings)==null?void 0:m4.globalFilterOption)==null?void 0:$5.value)}))==null?void 0:B8.value;if((typeof I9=="string"||typeof I9=="object"&&(I9!=null&&I9.value))&&I9){const l9=typeof I9=="string"?(L9=Cb(I9))==null?void 0:L9.toLowerCase():((f8=(O5=(B5=(e5=(N8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:N8.groupBySettings)==null?void 0:e5.formatWithValue)==null?void 0:B5.find(O9=>O9.value===Cb(I9==null?void 0:I9.value)))==null?void 0:O5.format)==null?void 0:f8.toLowerCase())||"";cC!=null&&cC.find(O9=>{var m4;return((m4=O9==null?void 0:O9.value)==null?void 0:m4.toLowerCase())===l9})&&W9(O9=>{var m4;return{...O9,timeSeriesSettings:{...O9==null?void 0:O9.timeSeriesSettings,groupBySettings:{...(m4=O9==null?void 0:O9.timeSeriesSettings)==null?void 0:m4.groupBySettings,value:l9}},xAxis:h8?O9.xAxis:`${l9} of ${o8}`}})}}},[n,W1==null?void 0:W1.chartType,(j6=(H6=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:H6.groupBySettings)==null?void 0:j6.isGlobalFilter,(y8=(n9=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:n9.groupBySettings)==null?void 0:y8.globalFilterOption,o8]),z0.useEffect(()=>{var i8,r8,s9,B8;W1!=null&&W1.isDynamicSeries&&((i8=W1==null?void 0:W1.seriesOptions)!=null&&i8.includes("ungrouped")?W1!=null&&W1.ungroupedAlias?S8((r8=W1==null?void 0:W1.seriesOptions)==null?void 0:r8.map(L9=>L9==="ungrouped"?{value:L9,label:W1==null?void 0:W1.ungroupedAlias}:{value:L9,label:L9})):S8((s9=W1==null?void 0:W1.seriesOptions)==null?void 0:s9.map(L9=>({value:L9,label:L9}))):S8([...((B8=W1==null?void 0:W1.seriesOptions)==null?void 0:B8.map(L9=>({value:L9,label:L9})))??[]]))},[W1==null?void 0:W1.seriesOptions,W1==null?void 0:W1.isDynamicSeries,W1==null?void 0:W1.ungroupedAlias]);const[x8,d9]=z0.useState(!1),j9=i8=>{i8.key==="Control"&&d9(!0)},t9=i8=>{i8.key==="Control"&&d9(!1)};z0.useEffect(()=>{V3!=null&&V3.length&&w6(Object.keys((V3==null?void 0:V3[0])||{}))},[V3==null?void 0:V3.length]),z0.useEffect(()=>{var i8,r8;return(r8=(i8=W1==null?void 0:W1.customSettings)==null?void 0:i8.chartZoom)!=null&&r8.isZoomEnabled&&(window.addEventListener("keydown",j9),window.addEventListener("keyup",t9)),()=>{window.removeEventListener("keydown",j9),window.removeEventListener("keyup",t9)}},[]);const t8=z0.useMemo(()=>{let i8=!1;if(V3!=null&&V3.length){const r8=W1==null?void 0:W1.singleValue;i8=V3[0][r8]===null&&(W1==null?void 0:W1.chartType)==="singleValue"}return i8},[V3==null?void 0:V3.length,W1==null?void 0:W1.singleValue,(W1==null?void 0:W1.chartType)==="singleValue"]),z9=z0.useMemo(()=>Yf({chartOptions:W1,data:V3||[]}),[V3,W1==null?void 0:W1.xAxis,W1==null?void 0:W1.yAxisList,(q8=W1==null?void 0:W1.dynamicXAxis)==null?void 0:q8.isEnabled,W1==null?void 0:W1.chartType,W1==null?void 0:W1.seriesField,(C9=W1==null?void 0:W1.customSettings)==null?void 0:C9.cumulativeBar,W1==null?void 0:W1.isGroupXAxis,(V9=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:V9.seriesType[0],(l4=(N5=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:N5.groupBySettings)==null?void 0:l4.fillXAxis]),B9=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.name)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.name,j8,X,O]),S9=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.longDescription)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.longDescription,j8,O,X]),c9=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.description)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.description,j8,O,X]),L5=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.footNote)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.footNote,j8,O,X]),x5=z0.useMemo(()=>{var i8;return`${((i8=V3==null?void 0:V3[0])==null?void 0:i8.dbn_metric_expression_data)||"No Data Found"}`},[V3]);z0.useLayoutEffect(()=>{x7&&(m==null||m(i8=>{const r8=new Map(i8);return r8.set(t==null?void 0:t.id,{data:{data:[],name:"",description:""},isLoading:x7,key:""}),r8})),O6!=null&&O6.data&&h&&(m==null||m(i8=>{const r8=new Map(i8);return r8.set(t==null?void 0:t.id,{data:{data:O6==null?void 0:O6.data,name:(t==null?void 0:t.name)||"",description:(t==null?void 0:t.description)||""},isLoading:x7,key:JSON.stringify(L7)}),r8}))},[O6==null?void 0:O6.data,x7]);const c5=()=>{var r8,s9,B8;return(((B8=(s9=(r8=t==null?void 0:t.elementSettings)==null?void 0:r8.summary)==null?void 0:s9.metricList)==null?void 0:B8.map(L9=>{var N8;return(N8=h==null?void 0:h.get(L9==null?void 0:L9.value))==null?void 0:N8.isLoading}))||[]).some(L9=>L9===!0)};z0.useLayoutEffect(()=>{var i8,r8,s9,B8,L9,N8,e5,B5,O5,f8,I9;if((r8=(i8=t==null?void 0:t.elementSettings)==null?void 0:i8.summary)!=null&&r8.metricList&&(h!=null&&h.get(t==null?void 0:t.id))&&!b0&&!c5()){const l9=((L9=(B8=(s9=t==null?void 0:t.elementSettings)==null?void 0:s9.summary)==null?void 0:B8.metricList)==null?void 0:L9.map(O9=>{var m4,$5,Ke,Ze,pt,De,ne,ye,Ne;return{data:(Ke=($5=(m4=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:m4.data)==null?void 0:$5.data)!=null&&Ke.length?(pt=(Ze=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:Ze.data)==null?void 0:pt.data:{},metricName:(ne=(De=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:De.data)==null?void 0:ne.name,metricDescription:(Ne=(ye=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:ye.data)==null?void 0:Ne.description}}))||[];v0(""),U0(""),!l9.some(O9=>Object.keys(O9.data).length===0)&&!b0&&(k0(()=>!0),m0.mutate({data:{metricData:l9,summaryPrompt:(e5=(N8=t==null?void 0:t.elementSettings)==null?void 0:N8.summary)==null?void 0:e5.summaryPrompt,id:t==null?void 0:t.id,filters:`${(I9=(f8=(O5=(B5=t==null?void 0:t.elementSettings)==null?void 0:B5.summary)==null?void 0:O5.metricList)==null?void 0:f8.map(O9=>{var m4;return(m4=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:m4.key}))==null?void 0:I9.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:O9=>{O9.summary?(v0(O9.summary),U0("")):(U0(g22),v0("")),k0(()=>!1)},onSettled:()=>{k0(()=>!1)},onError:O9=>{k0(()=>!1),U0(O9.message),v0("")}}))}},[t==null?void 0:t.elementSettings,h]),z0.useEffect(()=>{var B8,L9,N8,e5,B5,O5,f8,I9,l9,O9,m4,$5,Ke,Ze,pt,De,ne,ye,Ne,Le,Ie,Qn,ei,ti;const i8=nc(((B8=W1==null?void 0:W1.customSettings)==null?void 0:B8.comboAxisSettings)||[]),r8=(L9=i8==null?void 0:i8.map(xe=>xe==null?void 0:xe.measures))==null?void 0:L9.flat(),s9=(N8=W1==null?void 0:W1.yAxisList)==null?void 0:N8.every(xe=>r8==null?void 0:r8.includes(xe));if((e5=W1==null?void 0:W1.yAxisList)!=null&&e5.length&&((B5=W1==null?void 0:W1.yAxisList)==null?void 0:B5.length)!==(r8==null?void 0:r8.length)&&!(r8!=null&&r8.length)&&[L0.combo,L0.timeSeries,L0.horizontalCombo].includes((W1==null?void 0:W1.chartType)||"")){const xe=(f8=(O5=W1==null?void 0:W1.yAxisList)==null?void 0:O5.filter(sn=>{var Oi;return!((Oi=W1==null?void 0:W1.comboBarList)!=null&&Oi.includes(sn))}))==null?void 0:f8.filter(sn=>!(r8!=null&&r8.includes(sn))),Wr=((l9=(I9=W1==null?void 0:W1.customSettings)==null?void 0:I9.comboStackAxisSymbols)==null?void 0:l9.name)||"",Xt=($5=(m4=(O9=W1==null?void 0:W1.customSettings)==null?void 0:O9.comboLabelFormatter)==null?void 0:m4.find(sn=>sn.axis===(Wr||"stack")))==null?void 0:$5.formatter,Mr=(Ke=W1==null?void 0:W1.comboBarList)==null?void 0:Ke.join(" and "),Mn=(De=(pt=(Ze=W1==null?void 0:W1.customSettings)==null?void 0:Ze.comboLabelFormatter)==null?void 0:pt.find(sn=>sn.axis===Mr))==null?void 0:De.formatter;W9(sn=>{var Oi,_r,Tn,Fi,li,Ei,eo,to,Gi,kn,On,ko,Oo,na,ca,Pe,Pn,en,i9;return{...sn,customSettings:{...sn.customSettings,comboAxisSettings:nc([...((Oi=sn.customSettings)==null?void 0:Oi.comboAxisSettings)||[],...xe==null?void 0:xe.map(o5=>{var Cn,zn,Zn,dn,ln,pi;const I4=(Zn=(zn=(Cn=W1==null?void 0:W1.customSettings)==null?void 0:Cn.comboLabelFormatter)==null?void 0:zn.find(St=>St.axis===o5))==null?void 0:Zn.formatter,Ge=(ln=(dn=W1==null?void 0:W1.customSettings)==null?void 0:dn.comboAxisSymbols)==null?void 0:ln.find(St=>St.name===o5);return{axis:o5,measures:[o5],chartTypes:[{axis:o5,type:"line"}],numberFormatter:(pi=W1==null?void 0:W1.customSettings)==null?void 0:pi.numberFormatter,labelFormatter:I4,prefix:(Ge==null?void 0:Ge.prefix)||"",suffix:(Ge==null?void 0:Ge.suffix)||"",isEnableLabelFormatter:!!(I4!=null&&I4.length)}}),...(_r=W1==null?void 0:W1.comboBarList)!=null&&_r.length&&((Tn=W1==null?void 0:W1.customSettings)!=null&&Tn.isCombineBarAxis||(Fi=W1==null?void 0:W1.customSettings)!=null&&Fi.isStackBar)?[{axis:(li=W1==null?void 0:W1.customSettings)!=null&&li.isStackBar&&Wr||Mr,measures:W1==null?void 0:W1.comboBarList,chartTypes:(Ei=W1==null?void 0:W1.comboBarList)==null?void 0:Ei.map(o5=>({axis:o5,type:"bar"})),isEnableStackBar:(eo=W1==null?void 0:W1.customSettings)==null?void 0:eo.isStackBar,numberFormatter:(to=W1==null?void 0:W1.customSettings)==null?void 0:to.numberFormatter,...(Gi=W1==null?void 0:W1.customSettings)!=null&&Gi.isStackBar?{prefix:((On=(kn=W1==null?void 0:W1.customSettings)==null?void 0:kn.comboStackAxisSymbols)==null?void 0:On.prefix)||"",suffix:((Oo=(ko=W1==null?void 0:W1.customSettings)==null?void 0:ko.comboStackAxisSymbols)==null?void 0:Oo.suffix)||"",labelFormatter:Xt,isEnableLabelFormatter:!!(Xt!=null&&Xt.length)}:{prefix:((na=W1==null?void 0:W1.customSettings)==null?void 0:na.combinedAxisPrefix)||"",suffix:((ca=W1==null?void 0:W1.customSettings)==null?void 0:ca.combinedAxisSuffix)||"",labelFormatter:Mn,isEnableLabelFormatter:!!(Mn!=null&&Mn.length)}}]:[],...(Pe=W1==null?void 0:W1.comboBarList)!=null&&Pe.length&&!((Pn=W1==null?void 0:W1.customSettings)!=null&&Pn.isCombineBarAxis)&&!((en=W1==null?void 0:W1.customSettings)!=null&&en.isStackBar)?(i9=W1==null?void 0:W1.comboBarList)==null?void 0:i9.map(o5=>{var Cn,zn,Zn,dn,ln,pi;const I4=(Zn=(zn=(Cn=W1==null?void 0:W1.customSettings)==null?void 0:Cn.comboLabelFormatter)==null?void 0:zn.find(St=>St.axis===o5))==null?void 0:Zn.formatter,Ge=(ln=(dn=W1==null?void 0:W1.customSettings)==null?void 0:dn.comboAxisSymbols)==null?void 0:ln.find(St=>St.name===o5);return{axis:o5,measures:[o5],chartTypes:[{axis:o5,type:"bar"}],numberFormatter:(pi=W1==null?void 0:W1.customSettings)==null?void 0:pi.numberFormatter,labelFormatter:I4,prefix:(Ge==null?void 0:Ge.prefix)||"",suffix:(Ge==null?void 0:Ge.suffix)||"",isEnableLabelFormatter:!!(I4!=null&&I4.length)}}):[]].filter(o5=>{var I4;return(I4=o5==null?void 0:o5.measures)==null?void 0:I4.length})),comboAxisSymbols:[],combinedAxisPrefix:"",combinedAxisSuffix:"",comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}})}if(r8!=null&&r8.length&&((ne=W1==null?void 0:W1.yAxisList)!=null&&ne.length)&&(((ye=W1==null?void 0:W1.yAxisList)==null?void 0:ye.length)!==(r8==null?void 0:r8.length)||((Ne=W1==null?void 0:W1.yAxisList)==null?void 0:Ne.length)===(r8==null?void 0:r8.length)&&!s9)&&[L0.combo,L0.timeSeries,L0.horizontalCombo].includes((W1==null?void 0:W1.chartType)||"")){const xe=(Le=W1==null?void 0:W1.yAxisList)==null?void 0:Le.filter(Xt=>!(r8!=null&&r8.includes(Xt))),Wr=r8==null?void 0:r8.filter(Xt=>{var Mr;return!((Mr=W1==null?void 0:W1.yAxisList)!=null&&Mr.includes(Xt))});Wr==null||Wr.forEach(Xt=>{var Oi,_r,Tn;const Mr=(_r=(Oi=W1==null?void 0:W1.customSettings)==null?void 0:Oi.comboAxisSettings)==null?void 0:_r.find(Fi=>{var li;return(li=Fi.measures)==null?void 0:li.includes(Xt)}),Mn=Mr==null?void 0:Mr.axis,sn=(((Tn=Mr==null?void 0:Mr.measures)==null?void 0:Tn.length)||0)>1;W9(Fi=>{var li,Ei,eo,to,Gi;return{...Fi,customSettings:{...Fi.customSettings,comboAxisSettings:nc(sn?((eo=(Ei=(li=Fi.customSettings)==null?void 0:li.comboAxisSettings)==null?void 0:Ei.map(kn=>{var On;return kn.axis===Mn?{...kn,measures:(On=kn==null?void 0:kn.measures)==null?void 0:On.filter(ko=>ko!==Xt)}:kn}))==null?void 0:eo.filter(kn=>{var On;return(On=kn==null?void 0:kn.measures)==null?void 0:On.length}))||[]:((Gi=(to=Fi.customSettings)==null?void 0:to.comboAxisSettings)==null?void 0:Gi.filter(kn=>{var On;return kn.axis!==Mn&&((On=kn==null?void 0:kn.measures)==null?void 0:On.length)}))||[])}}})}),xe!=null&&xe.length&&W9(Xt=>{var Mr;return{...Xt,customSettings:{...Xt.customSettings,comboAxisSettings:nc([...((Mr=Xt.customSettings)==null?void 0:Mr.comboAxisSettings)||[],...xe==null?void 0:xe.map(Mn=>({axis:Mn,measures:[Mn],chartTypes:[{axis:Mn,type:"line"}]}))].filter(Mn=>{var sn;return(sn=Mn==null?void 0:Mn.measures)==null?void 0:sn.length})||[])}}})}r8!=null&&r8.length&&((Ie=W1==null?void 0:W1.yAxisList)!=null&&Ie.length)&&((Qn=W1==null?void 0:W1.yAxisList)==null?void 0:Qn.length)===(r8==null?void 0:r8.length)&&s9&&[L0.combo,L0.timeSeries,L0.horizontalCombo].includes((W1==null?void 0:W1.chartType)||"")&&((ti=(ei=W1==null?void 0:W1.customSettings)==null?void 0:ei.comboAxisSettings)==null?void 0:ti.length)!==(i8==null?void 0:i8.length)&&W9(xe=>({...xe,customSettings:{...xe==null?void 0:xe.customSettings,comboAxisSettings:i8}}))},[W1==null?void 0:W1.yAxisList,(j5=W1==null?void 0:W1.customSettings)==null?void 0:j5.comboAxisSettings,W1==null?void 0:W1.comboBarList,(u4=W1==null?void 0:W1.customSettings)==null?void 0:u4.isCombineBarAxis,(y4=W1==null?void 0:W1.customSettings)==null?void 0:y4.isStackBar,(_e=(re=W1==null?void 0:W1.customSettings)==null?void 0:re.comboStackAxisSymbols)==null?void 0:_e.name,(Cr=(bt=W1==null?void 0:W1.customSettings)==null?void 0:bt.comboStackAxisSymbols)==null?void 0:Cr.prefix,(jn=(Bt=W1==null?void 0:W1.customSettings)==null?void 0:Bt.comboStackAxisSymbols)==null?void 0:jn.suffix,(qn=W1==null?void 0:W1.customSettings)==null?void 0:qn.comboLabelFormatter,(Vi=W1==null?void 0:W1.customSettings)==null?void 0:Vi.comboAxisSymbols,(Ji=W1==null?void 0:W1.customSettings)==null?void 0:Ji.numberFormatter,(qi=W1==null?void 0:W1.customSettings)==null?void 0:qi.combinedAxisPrefix,(ki=W1==null?void 0:W1.customSettings)==null?void 0:ki.combinedAxisSuffix,W1==null?void 0:W1.chartType]),z0.useEffect(()=>{var i8,r8,s9;(i8=W1==null?void 0:W1.yAxisList)!=null&&i8.length&&((r8=W1==null?void 0:W1.yAxisList)==null?void 0:r8.length)<5&&(W1==null?void 0:W1.chartType)===L0.boxplot&&W9(B8=>({...B8,chartType:L0.line})),!((s9=W1==null?void 0:W1.yAxisList)!=null&&s9.length)&&(W1==null?void 0:W1.chartType)===L0.funnelV2&&W9(B8=>({...B8,chartType:L0.singleValue}))},[W1==null?void 0:W1.chartType,($i=W1==null?void 0:W1.yAxisList)==null?void 0:$i.length]);const d4=({columnAlias:i8,value:r8,isClear:s9=!1})=>{const B8=t==null?void 0:t.datasetMetricSettings;B8&&yJ2({columnAlias:i8,datasetSettings:B8,setTableColumnFilters:y6,value:r8,isClear:s9})};return z0.useEffect(()=>{var r8,s9,B8,L9;if(!((r8=W1==null?void 0:W1.dynamicYAxis)!=null&&r8.isEnabled)||!((s9=W1==null?void 0:W1.dynamicYAxis)!=null&&s9.selectedOption)||Array.isArray((B8=W1==null?void 0:W1.dynamicYAxis)==null?void 0:B8.selectedOption))return;const i8=(L9=W1==null?void 0:W1.dynamicYAxis)==null?void 0:L9.selectedOption;W9(N8=>({...N8,dynamicYAxis:{...N8==null?void 0:N8.dynamicYAxis,selectedOption:[i8]},yAxisList:[i8==null?void 0:i8.value]}))},[(go=W1==null?void 0:W1.dynamicYAxis)==null?void 0:go.selectedOption,(yo=W1==null?void 0:W1.dynamicYAxis)==null?void 0:yo.isEnabled]),z0.useEffect(()=>{var B8,L9,N8,e5,B5,O5,f8,I9;const i8=(B8=g2==null?void 0:g2.yAxisSettings)==null?void 0:B8.find(l9=>{var O9,m4,$5,Ke,Ze;return((O9=l9==null?void 0:l9.yAxisSettings)==null?void 0:O9.isEnable)&&(l9==null?void 0:l9.id)===(t==null?void 0:t.id)&&((m4=l9==null?void 0:l9.yAxisSettings)==null?void 0:m4.yAxis)&&Array.isArray(($5=l9==null?void 0:l9.yAxisSettings)==null?void 0:$5.yAxis)&&((Ze=(Ke=l9==null?void 0:l9.yAxisSettings)==null?void 0:Ke.yAxis)==null?void 0:Ze.length)>0}),r8=(L9=g2==null?void 0:g2.xAxisSettings)==null?void 0:L9.find(l9=>{var O9,m4;return((O9=l9==null?void 0:l9.xAxisSettings)==null?void 0:O9.isEnable)&&(l9==null?void 0:l9.id)===(t==null?void 0:t.id)&&((m4=l9==null?void 0:l9.xAxisSettings)==null?void 0:m4.xaxis)});if(!((N8=W1==null?void 0:W1.dynamicYAxis)!=null&&N8.isEnabled)&&!((e5=W1==null?void 0:W1.dynamicXAxis)!=null&&e5.isEnabled)&&!((B5=J7==null?void 0:J7.configV2)!=null&&B5.isEnable)||!i8&&!r8&&!((O5=J7==null?void 0:J7.configV2)!=null&&O5.isEnable)){W9(l9=>(t==null?void 0:t.chartOptions)||l9);return}const s9=(I9=(f8=i8==null?void 0:i8.yAxisSettings)==null?void 0:f8.yAxis)==null?void 0:I9[0];W9(l9=>{var O9,m4,$5,Ke,Ze,pt,De;return{...l9,dynamicYAxis:{...l9==null?void 0:l9.dynamicYAxis,selectedOption:s9?[s9]:((O9=l9==null?void 0:l9.dynamicYAxis)==null?void 0:O9.selectedOption)||[]},dynamicXAxis:{...l9==null?void 0:l9.dynamicXAxis,selectedOption:(m4=r8==null?void 0:r8.xAxisSettings)!=null&&m4.xaxis?{value:($5=r8==null?void 0:r8.xAxisSettings)==null?void 0:$5.xaxis,label:(Ke=r8==null?void 0:r8.xAxisSettings)==null?void 0:Ke.xaxis}:((Ze=l9==null?void 0:l9.dynamicXAxis)==null?void 0:Ze.selectedOption)||[]},yAxisList:s9!=null&&s9.value?[s9==null?void 0:s9.value]:(l9==null?void 0:l9.yAxisList)||[],xAxis:(pt=r8==null?void 0:r8.xAxisSettings)!=null&&pt.xaxis?(De=r8==null?void 0:r8.xAxisSettings)==null?void 0:De.xaxis:(l9==null?void 0:l9.xAxis)||""}})},[g2==null?void 0:g2.yAxisSettings,t==null?void 0:t.id,g2==null?void 0:g2.xAxisSettings,(fn=W1==null?void 0:W1.dynamicYAxis)==null?void 0:fn.isEnabled,(Zr=W1==null?void 0:W1.dynamicXAxis)==null?void 0:Zr.isEnabled,(Xe=J7==null?void 0:J7.configV2)==null?void 0:Xe.isEnable]),z0.useEffect(()=>{var i8,r8,s9;(i8=W1==null?void 0:W1.customSettings)!=null&&i8.isShowDuration&&(W1==null?void 0:W1.chartType)===L0.gantt&&!((s9=(r8=W1==null?void 0:W1.customSettings)==null?void 0:r8.ganttTooltipKeys)!=null&&s9.includes("Duration"))&&W9(B8=>{var L9;return{...B8,customSettings:{...B8==null?void 0:B8.customSettings,ganttTooltipKeys:[...((L9=B8==null?void 0:B8.customSettings)==null?void 0:L9.ganttTooltipKeys)||[],"Duration"]}}})},[(Ln=W1==null?void 0:W1.customSettings)==null?void 0:Ln.isShowDuration,W1==null?void 0:W1.chartType,(wn=W1==null?void 0:W1.customSettings)==null?void 0:wn.ganttTooltipKeys]),{elementSummary:H0,elementSummaryError:J2,isLoadingSummary:b0,isMetricListLoading:c5,onDrillLevelClick:A5,onDrillDown:D9,handleChartClick:k8,dataDb:V3,getUnderlyingData:k3,onChangeFilterValue:z8,isShowChartPopup:t6,setShowChartPopup:C6,columnName:h5,chartParams:n3,isQueryLoading:x7||M2||G2,isSingleValueNull:t8,dynamicOptions:T5,chartSettings:W1,setChartSettings:W9,isEnableZoom:x8,filterValues:Q8,containerRef:J0,drilledLevel:k7.length,dimensions:((Ci=($n=t==null?void 0:t.datasetMetricSettings)==null?void 0:$n.selectedDimensions)==null?void 0:Ci.map(i8=>Qa2(i8||"none")))||[],rlsConditions:l3,setRlsConditions:c7,setTableLimit:L3,isEnableNextBtn:M1>(Y2==null?void 0:Y2.limit)+(Y2==null?void 0:Y2.offset),isEnablePrevBtn:(Y2==null?void 0:Y2.offset)!==0,paginationInfo:{limit:Y2==null?void 0:Y2.limit,offset:Y2==null?void 0:Y2.offset,totalRecords:M1},onChangePage:(i8,r8,s9)=>{L3(r8?{limit:r8,offset:0}:B8=>{let L9;return s9||s9===0?L9=s9:i8?L9=B8.offset>B8.limit?B8.offset-B8.limit:0:L9=B8.offset+B8.limit,{limit:B8.limit,offset:L9}})},isExternalChart:((wi=W1==null?void 0:W1.tableSettings)==null?void 0:wi.isServerSidePagination)&&(W1==null?void 0:W1.chartType)===L0.table,isEnablePivotTable:c8,groupByList:z7,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:i8=>{c7(r8=>r8==null?void 0:r8.map(s9=>s9.name===i8.name&&s9.datatype===i8.datatype&&s9.tableName===i8.tableName&&s9.columnName===i8.columnName?{...s9,isAddOnMetrics:!s9.isAddOnMetrics}:s9))},metricFilters:fe,leftPositionedMetricFilters:Y5,rightPositionedMetricFilters:Q6,drillFilters:k7,drillType:(pr=t==null?void 0:t.drillDownSettings)==null?void 0:pr.drillType,tableResultsDownloadData:k6,appliedMetricFilters:o9,pivotHeaderOptions:te,pivotDrillState:I6,onDrillPivotTable:E8,legendData:z9,timeseriesDimension:o8,isPythonMode:h8,sortOrder:e6,setSortOrder:l7,isNotFirstRender:o7,setNotFirstRender:m7,isSorted:H5,isInavlidForSort:_8,onAddComparison:y9,groupedRlsConditions:Te,onGenerateMetricSummary:p5,summary:v1,setSummary:h3,dataMartRelationships:Y6,onChartChange:k4,isCompareValue:D8,isShowChartPropertyPanel:U8,setShowChartPropertyPanel:$9,columnList:A6,variables:j8,metricName:B9,longDescription:S9,footNote:L5,description:c9,drilldownCols:G3,switchMeasureOptions:V4,metricExpressionResult:x5,dateFilter:X5,drillDownSettings:J7,enabledCharts:T4,tableColumnFilters:T3,onChangePaginationColumnFilters:d4,queryError:a7||(O6==null?void 0:O6.error),refetchMetricData:K6,customSwitchXAxis:x1}},A70=({metricId:t,onSuccess:n,token:i})=>{const{mutateAsync:o,isLoading:a}=S30();return{handleArchiveMetric:z0.useCallback(async()=>{!t||!i||await o({data:{id:t},token:i},{onSuccess:async r=>{r!=null&&r.error||await n()}})},[o,t]),isLoading:a}},Tu2=({token:t,metricId:n})=>{var R2;const[i,o]=z0.useState(!0),{data:a,isLoading:s}=r70(t,n),{externalMetric:r,sharingSettingsId:C,adminTheme:l,params:e,companyId:u,clientId:A,errorMsg:f,clientColumnType:d,isEnableMetricSummary:g,isAllClient:h,isShowUnderlyingData:m,appFilters:w,mergedMetricsId:Q,datasourceId:R,mergedMetricLayout:N,mergedDashboardFilters:O,dashboardAppFilterValues:X,filterLayout:K,nestedMetric:f2,guestToken:A2}=z0.useMemo(()=>{var P2,G2;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:(P2=M2==null?void 0:M2.error)==null?void 0:P2.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:(G2=window==null?void 0:window.dbn)!=null&&G2.isEnableProxyAuth?Od(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:b2,tenancyLevel:g2,workspaceId:j2}=z0.useMemo(()=>{var P2,G2;if(!e)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const M2=JSON.parse(e);return{rlsSettings:(P2=M2.rlsSettings)==null?void 0:P2.find(C0=>C0.metricId===n),tenancyLevel:M2.companyTenancyType||"TABLE",workspaceId:((G2=M2==null?void 0:M2.workspace)==null?void 0:G2.id)||""}},[e,n]);return z0.useEffect(()=>{s&&o(!0),(r||f||!s)&&o(!1)},[s,r,f]),{externalMetric:r,sharingSettingsId:C,companyId:u,clientId:A,rlsSettings:b2,tenancyLevel:g2,isLoading:i,errorMsg:f,adminTheme:l,workspaceId:j2,clientColumnType:d,isEnableMetricSummary:g,isAllClient:h,isShowUnderlyingData:m,appFilters:w,mergedMetricsId:Q,datasourceId:R,mergedMetricLayout:N,mergedDashboardFilters:O,dashboardAppFilterValues:X,filterLayout:K,nestedMetric:f2,token:A2}},c70=Qu2({active:null,over:null,DragPreviewCreateRoot:null,draggables:[],droppables:[]}),xu2=()=>{const[t,n]=M_(c70);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}},f70=({identifier:t,data:n,modifiers:i,events:o,CustomDragPreview:a,disabled:s=!1,dropText:r})=>{const{dndState:C,setActive:l,setDndState:e,setDraggables:u}=xu2(),[A,f]=z0.useState(!1),[d,g]=z0.useState(!0),[h,m]=z0.useState(null),w=z0.useRef(null),Q=z0.useRef(null),R={"data-type":t.type||t.id,id:`draggable-${t.id}`,role:"button",tabindex:"0",draggable:d?"true":"false","aria-grabbed":"false"},N=X=>{Object.entries(R).forEach(([K,f2])=>{X.setAttribute(K,f2)})},O=()=>{var X;Q.current&&((X=C.DragPreviewCreateRoot)==null||X.render(a))};return z0.useEffect(()=>{if(a&&(Q.current=document.getElementById("CustomDragPreviewContainer"),Q.current===null)){Q.current=document.createElement("div"),Q.current.setAttribute("id","CustomDragPreviewContainer"),document.body.appendChild(Q.current);const X=Uv2.createRoot(Q.current);e(K=>({...K,DragPreviewCreateRoot:X}))}},[]),z0.useEffect(()=>{if(w.current){const X=w.current.getBoundingClientRect();m(X),u({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:h,events:o,isDragging:A,isEnableDrag:d})}},[w.current,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i),JSON.stringify(o),JSON.stringify(A)]),z0.useEffect(()=>{const X=w.current;if(!X)return;N(X);const K=A2=>{var b2,g2,j2,R2;if(f(!0),l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:h,events:o,isDragging:A,isEnableDrag:d}),X.setAttribute("aria-grabbed","true"),r?(b2=A2.dataTransfer)==null||b2.setData("text/plain",r):(g2=A2.dataTransfer)==null||g2.setData("text/plain",JSON.stringify({data:n})),(j2=o==null?void 0:o.onDragStart)==null||j2.call(o,A2,C),Q.current){const M2=Q.current.getBoundingClientRect();(R2=A2.dataTransfer)==null||R2.setDragImage(Q.current,M2.width/2,M2.height/2)}},f2=A2=>{var b2;X.setAttribute("aria-grabbed","false"),f(!1),l(null),(b2=o==null?void 0:o.onDragEnd)==null||b2.call(o,A2,C)};return X.addEventListener("mousedown",()=>{a&&O()}),X.addEventListener("dragstart",K),X.addEventListener("dragend",f2),()=>{X.removeEventListener("dragstart",K),X.removeEventListener("dragend",f2)}},[w.current,JSON.stringify(t),JSON.stringify(n),C.DragPreviewCreateRoot]),z0.useEffect(()=>{const X=w.current;X&&X.setAttribute("draggable",d?"true":"false")},[d]),z0.useEffect(()=>{var K,f2,A2,b2;let X=[];return A&&(l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:h,events:o,isDragging:A,isEnableDrag:d}),(K=i==null?void 0:i.highlightDrop)!=null&&K.onDrag&&(X=((A2=(f2=C.droppables)==null?void 0:f2.filter(g2=>((g2==null?void 0:g2.identifier.accepts)??[]).includes(t.type??"")&&(g2==null?void 0:g2.isEnableDrop)))==null?void 0:A2.map(g2=>g2==null?void 0:g2.setDropNodeRef.current))??[],(b2=i==null?void 0:i.highlightDrop)!=null&&b2.onDrag&&X.forEach(g2=>{var j2;g2==null||g2.classList.add(((j2=i==null?void 0:i.highlightDrop)==null?void 0:j2.highlightClass)||"dnd-droppable-highlight")}))),()=>{X.forEach(g2=>{var j2;g2==null||g2.classList.remove(((j2=i==null?void 0:i.highlightDrop)==null?void 0:j2.highlightClass)||"dnd-droppable-highlight")})}},[A]),z0.useEffect(()=>{g(!s)},[s]),{isDragging:A,isEnableDrag:d,setIsEnableDrag:g,DragNodeRef:w}},Ru2=({identifier:t,events:n,modifiers:i})=>{var N;const{dndState:o,setOver:a,setDropables:s}=xu2(),[r,C]=z0.useState(null),[l,e]=z0.useState({isDragOver:!1,isDrop:!1}),[u,A]=z0.useState({before:-1,after:-1}),[f,d]=z0.useState(!0),g=z0.useRef(null),h={"data-type":((N=t.accepts)==null?void 0:N.join("-"))??"",id:`droppable-${t.id}`,droppable:f?"true":"false"},m=O=>{Object.entries(h).forEach(([X,K])=>{O.setAttribute(X,K)})},w=(O,X,K)=>{const f2=[...K];O=O===-1?f2.length-1:O;const[A2]=f2.splice(O,1);return X===-1?f2.push(A2):f2.splice(X,0,A2),f2},Q=(O,X,K)=>[...O.querySelectorAll('[draggable="true"]:not([aria-grabbed="true"])')].reduce((b2,g2,j2)=>{const R2=g2.getBoundingClientRect(),M2=X-R2[K==="horizontal"?"left":"top"]-R2[K==="horizontal"?"width":"height"]/2;return M2<0&&M2>b2.offset?{offset:M2,element:g2,index:j2}:b2},{offset:Number.NEGATIVE_INFINITY,element:null,index:-1}),R=(O,X,K)=>{const f2=[...O.querySelectorAll('[draggable="true"]')],A2=O.querySelector('[aria-grabbed="true"]'),{width:b2,height:g2}=K,j2=(M2,P2,G2)=>{const C0=M2.x-P2/2,m0=M2.y-G2/2;return[{x:C0,y:m0},{x:C0+P2,y:m0},{x:C0,y:m0+G2},{x:C0+P2,y:m0+G2}]};return f2.reduce((M2,P2,G2)=>{const C0=P2.getBoundingClientRect(),m0=[{x:C0.left,y:C0.top},{x:C0.left+C0.width,y:C0.top},{x:C0.left,y:C0.top+C0.height},{x:C0.left+C0.width,y:C0.top+C0.height}],H0=j2(X,b2,g2);let v0=Number.POSITIVE_INFINITY,J2=G2,U0=Number.POSITIVE_INFINITY,b0=Number.POSITIVE_INFINITY;return m0.forEach((k0,J0)=>{H0.forEach(Y2=>{let L3=Number.POSITIVE_INFINITY;U0=Math.sqrt((k0.x-Y2.x)**2+(k0.y-Y2.y)**2),b0=Math.sqrt((k0.x-X.x)**2+(k0.y-X.y)**2),L3=Math.min(U0,b0),L3<v0&&(v0=L3,J0===1||J0===3?A2!==P2&&(J2=G2+1):J2=G2)})}),v0<M2.minDistance?{minDistance:v0,element:P2,index:J2,closestBasedOnCorner:U0,closestBasedonCursor:b0}:M2},{minDistance:Number.POSITIVE_INFINITY,element:null,index:-1,closestBasedOnCorner:0,closestBasedonCursor:0})};return z0.useEffect(()=>{const O=g.current;if(!O)return;const X=O.getBoundingClientRect();C(X),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)]),z0.useEffect(()=>{var g2,j2;const O=g.current;if(m(O),!O||!f||(g2=t.accepts)!=null&&g2.length&&!t.accepts.includes(((j2=o.active)==null?void 0:j2.identifier.type)??""))return;const{sorting:X}=i||{},K=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)},f2=R2=>{var M2,P2,G2,C0,m0,H0,v0,J2,U0,b0,k0,J0;if(R2.preventDefault(),(G2=(P2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:P2.highlightDrop)!=null&&G2.onDragOver&&g.current.classList.add(((H0=(m0=(C0=o.active)==null?void 0:C0.modifiers)==null?void 0:m0.highlightDrop)==null?void 0:H0.highlightClass)||"dnd-droppable-highlight"),l.isDragOver||e(Y2=>({...Y2,isDragOver:!0})),o.over===null&&a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),X!=null&&X.isEnabled&&((v0=X.list)!=null&&v0.length)){const Y2=(b0=(U0=(J2=o.active)==null?void 0:J2.DragNodeRef)==null?void 0:U0.current)==null?void 0:b0.getAttribute("data-dbn-sorting-index");let L3=null;if((X.sortingType==="vertical"||X.sortingType==="horizontal")&&(L3=Q(O,(X==null?void 0:X.sortingType)==="horizontal"?R2.clientX:R2.clientY,X==null?void 0:X.sortingType)),X.sortingType==="both-axis"){const B3=(k0=document.getElementById("CustomDragPreviewContainer"))==null?void 0:k0.getBoundingClientRect();L3=R(O,{x:R2.clientX,y:R2.clientY},{width:(B3==null?void 0:B3.width)??0,height:(B3==null?void 0:B3.height)??0})}const M1={before:parseInt(Y2??-1,10),after:L3==null?void 0:L3.index};(M1.before!==u.before||M1.after!==u.after)&&A(M1)}(J0=n==null?void 0:n.onDragOver)==null||J0.call(n,R2,o)},A2=R2=>{var M2,P2,G2,C0,m0,H0,v0;R2.preventDefault(),(G2=(P2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:P2.highlightDrop)!=null&&G2.onDragOver&&g.current.classList.remove(((H0=(m0=(C0=o.active)==null?void 0:C0.modifiers)==null?void 0:m0.highlightDrop)==null?void 0:H0.highlightClass)||"dnd-droppable-highlight"),e(J2=>({...J2,isDragOver:!1})),(v0=n==null?void 0:n.onDragLeave)==null||v0.call(n,R2,o),a(null)},b2=R2=>{var m0,H0,v0,J2,U0,b0,k0,J0,Y2,L3;R2.preventDefault();const M2=g.current.contains((H0=(m0=o.active)==null?void 0:m0.DragNodeRef)==null?void 0:H0.current);let P2={...o};(U0=(J2=(v0=o.active)==null?void 0:v0.modifiers)==null?void 0:J2.highlightDrop)!=null&&U0.onDragOver&&g.current.classList.remove(((J0=(k0=(b0=o.active)==null?void 0:b0.modifiers)==null?void 0:k0.highlightDrop)==null?void 0:J0.highlightClass)||"dnd-droppable-highlight");let{before:G2,after:C0}=u;if(X!=null&&X.isEnabled&&((Y2=X.list)!=null&&Y2.length)){let M1=[...X.list];M2?M1=w(G2,C0,M1):G2=-1,P2={...o,sorting:{sortedList:M1,isSelfDrop:M2,ArrayElementSwap:w,sortingIndexes:{before:G2,after:C0}}},X.isEnabledAutoSort&&M2&&X.setList(M1)}e(M1=>({...M1,isDrop:!0})),(L3=n==null?void 0:n.onDrop)==null||L3.call(n,R2,P2),a(null)};return O.addEventListener("dragenter",K),O.addEventListener("dragover",f2),O.addEventListener("dragleave",A2),O.addEventListener("drop",b2),()=>{O.removeEventListener("dragenter",K),O.removeEventListener("dragover",f2),O.removeEventListener("dragleave",A2),O.removeEventListener("drop",b2)}},[g.current,t,f,i,n,u]),z0.useEffect(()=>{const O=g.current;O&&O.setAttribute("droppable",f?"true":"false")},[f]),{dragStatus:l,isEnableDrop:f,setIsEnableDrop:d,setDropNodeRef:g}},d70=(t,n,i)=>({autoCompleteDropdownOptions:z0.useMemo(()=>{if(!n.length)return[];const a=[];return n.forEach(s=>{s.columnsWithDataType.forEach(r=>{var g;const C=PJ2(((g=r==null?void 0:r.dataType)==null?void 0:g.toLowerCase())||""),l=ZJ2(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(([h,m])=>{e.add(h),m&&u.add(m)}),C){case"DATE":Ix.forEach(h=>h.synonyms.forEach(A.add,A));break;case"NUMBER":TE.forEach(h=>h.synonymns.forEach(A.add,A));break;case"STRING":Eh.forEach(h=>h.synonyms.forEach(A.add,A)),lb2.forEach(h=>h.synonyms.forEach(A.add,A));break}fL.forEach(h=>h.synonymns.forEach(A.add,A));const f=l.flatMap(h=>(tb==null?void 0:tb[h.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(h=>{a.push({alias:h,datatype:r.dataType,name:h,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],distinctValueSynonyms:[...u],type:"VALUE"})})})}),a},[n,i,t])}),g70=(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)||sV}${x10}`,{method:"POST",body:JSON.stringify({fileName:t,dashboardId:n}),headers:{"Content-Type":"application/json",...a?{}:{"X-Plugin-Token":o||""},...CV()||{},"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)}}}),h70=()=>{const[t,n]=z0.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,h;const f=((d=window==null?void 0:window.dbn)==null?void 0:d.isEnableProxyAuth)||!1;try{n({downloadProgress:!0,isLoading:!0});const m=await fetch(`${((g=window.dbn)==null?void 0:g.proxyAuthUrl)||((h=window.dbn)==null?void 0:h.baseUrl)||sV}${i30}`,{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||""},...CV()||{},"X-Plugin-Origin":window.location.host,...r?{"X-Dbn-Secret":C}:{},...r?{"X-Dbn-token":p_()||""}:{}}});if(!m.ok)throw new Error("Network response was not ok");const w=await m.blob(),Q=URL.createObjectURL(w),R=document.createElement("a");R.href=Q,R.download=`${o}.zip`,R.style.display="none",document.body.appendChild(R),n({downloadProgress:!1,isLoading:!1}),rP&&(document!=null&&document.createEvent)||R.click(),URL.revokeObjectURL(Q),document.body.removeChild(R)}catch{n({downloadProgress:!1,isLoading:!1}),alert("Error downloading the file. Please try later.")}},downloadState:t}},E70=({dashboardId:t,fileName:n,token:i})=>{const[o,a]=z0.useState(""),[s,r]=z0.useState(!1),[C,l]=z0.useState({isGettingPdf:!1}),{toPDF:e}=g70(n,t);return{toPDF:async()=>{if(l({isGettingPdf:!0}),a(""),r(!1),!i){a(Nu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1});return}try{await e(i),r(!0),setTimeout(()=>{r(!1)},2e3),l({isGettingPdf:!1})}catch{a(Nu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1})}},isGettingPdf:C==null?void 0:C.isGettingPdf,error:o,isPdfExported:s}},dV={downloadCsv:"_downloadCsv_z5r12_1",downloadCsvWrapper:"_downloadCsvWrapper_z5r12_9",downloadCsvNote:"_downloadCsvNote_z5r12_45",downloadCsvNoteText:"_downloadCsvNoteText_z5r12_59"},DA={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"},g5=({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:h,containerClassName:m="",containerStyle:w,customClassName:Q="",isFilter:R,isApplyDashboardColor:N,...O})=>{var X,K,f2,A2;return E.jsxs("div",{className:`${DA["inputField-container"]} ${Q}`,children:[E.jsxs("div",{className:DA.upperContainer,id:`${(K=(X=i??a)==null?void 0:X.replaceAll(" ","-"))==null?void 0:K.toLowerCase()}-input`,"data-testid":`${(A2=(f2=i??a)==null?void 0:f2.replaceAll(" ","-"))==null?void 0:A2.toLowerCase()}-input`,children:[i?E.jsxs(E.Fragment,{children:[d==="floating"&&E.jsxs("label",{htmlFor:a,className:`${DA.floatingLabel} ${R?"dbn-selectBox-text":""} ${R&&N?"dbn-selectBox":""}`,children:[i,h?E.jsx("span",{className:DA.important,children:"*"}):null]}),d==="static"&&E.jsx("label",{htmlFor:a,className:`${DA.label} ${R?"dbn-selectBox-text":""} ${R&&N?"dbn-selectBox":""}`,children:E.jsxs(q7,{variant:"input-label",color:"primary",children:[i,h?E.jsx("span",{className:DA.important,children:"*"}):null]})})]}):null,E.jsxs("div",{className:`${DA.inputContainer} ${R&&N?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""} ${m} `,style:w,children:[f&&E.jsx("div",{className:DA.inlineLabelContainer,children:E.jsx(q7,{variant:"heading-6",children:f})}),A&&E.jsx("div",{className:`${DA.prefixContainer} ${DA.supportText}`,children:A}),l&&E.jsx("div",{className:"dbn-p-2",children:l}),E.jsx("input",{...O,value:g,ref:s,id:a,type:t,className:`${DA.input} ${O.className||""} ${r?DA.error:""} ${g?DA.inputVal:""} ${R&&N?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""}`,...n,disabled:o}),e&&E.jsx("div",{className:"dbn-p-2",children:e}),u&&E.jsx("div",{className:`${DA.suffixContainer} ${DA.supportText}`,children:u})]})]}),C&&E.jsx("div",{className:DA.supportText,children:C}),r&&E.jsx(q7,{variant:"body-text-2",color:"alert",children:r})]})},Ud={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"},zu=({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=z0.useRef(),[g,h]=z0.useState(!1),[m,w]=z0.useState(!1),[Q,R]=z0.useState(!1),N=X=>{X.target.classList.contains(Ud.modal)?w(!0):w(!1)},O=X=>{X.target.classList.contains(Ud.modal)?R(!0):R(!1)};return z0.useEffect(()=>{Q&&m&&(R(!1),w(!1))},[Q,m]),E.jsx(pE,{children:n||f?E.jsx("div",{className:`${Ud.modal} ${A?"dbn-items-end dbn-py-0":""}`,onMouseDown:O,onMouseUp:N,ref:d,style:{...l?{zIndex:l}:{},...f?{display:n?void 0:"none"}:{}},children:E.jsxs("div",{className:`${Ud.popup} ${g?Ud.popupFullScreen:""} ${e?Ud[`popup-${e}`]:""} ${A?"dbn-my-0 dbn-rounded-b-none dbn-rounded-t-3xl":""}`,onClick:X=>{X.stopPropagation()},children:[u?null:E.jsx("section",{className:Ud.header,children:s||E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-items-start dbn-gap-1.5",children:[E.jsxs("div",{className:Ud.headerTitle,children:[C,E.jsx(q7,{variant:"heading-3",color:"primary",children:o})]}),a&&E.jsx("div",{className:Ud.subHeadingTitle,children:E.jsx(q7,{variant:"body-text-3",color:"sec-text",children:a})})]}),E.jsx(C8,{"data-testid":"close-modal",variant:"tertiary",type:"button",onClick:i,leftIcon:E.jsx(m8,{name:"cross",size:"small"}),style:{padding:"0",height:"20px"},className:"dbn-p-1.5"})]})}),E.jsx("section",{className:Ud.content,children:t})]})}):null})},$f=({children:t,className:n})=>E.jsx("section",{className:`${Ud.footer} ${n}`,children:t}),p70=t=>{if(!t.length)return!1;const n=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;return t.every(i=>n.test(i))},x_=({onCloseModal:t,sharingSettingsId:n,metricItem:i,workspaceId:o})=>{const{data:a}=C70(o),[s,r]=z0.useState(!1),[C,l]=z0.useState(""),{mutate:e}=D30(),{handleSubmit:u,register:A,setValue:f,control:d,formState:{errors:g}}=sb(),h=z0.useMemo(()=>{const w=a;return{expireTimeInMin:(w==null?void 0:w.expireTimeInMin)||30,isEnable:w==null?void 0:w.isEnable}},[a]);return{onSumbitSendCsvUrl:({values:w,query:Q})=>{r(!0),l("");const R=h.expireTimeInMin||30,N=new Date(Date.now()+R*60*1e3),O=Q,X=w.emails;if(!p70(X)){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:X,expireCsvFileAt:N,expireUrlIn:R*60,externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,query:O,sharingSettingsId:n,subject:w.subject},{onSuccess(K){K?(r(!1),l(""),t==null||t(!1)):(r(!1),l(Nu))},onError(){r(!1),l(Nu)}})},isDisableDownloadSettings:!n||!h.isEnable,downloadCsvError:C,handleSubmit:u,isLoading:s,register:A,control:d,setValue:f,errors:g}},iy={required:"Required"};({...iy},{...iy}),{...iy};const gV={"tag-text":"_tag-text_677jk_7",inputFieldContainer:"_inputFieldContainer_677jk_21","tag-container":"_tag-container_677jk_29",important:"_important_677jk_45"},R_=({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:h,error:m})=>{const[w,Q]=z0.useState(),[R,N]=z0.useState(""),O=b2=>{Q(w==null?void 0:w.filter(g2=>g2!==b2)),s==null||s(w==null?void 0:w.filter(g2=>g2!==b2))},X=()=>{const b2=R.split(",").map(R2=>R2.trim()).filter(Boolean),g2=new Set;for(const R2 of b2){if(g2.has(R2)){g==null||g(`Duplicate ${(f==null?void 0:f.toLocaleLowerCase())||"value"} in input: "${R2}"`);return}if(w!=null&&w.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}g2.add(R2)}const j2=[...w||[],...b2];Q(j2),s==null||s(j2),N(""),g==null||g("")},K=b2=>{if(b2.key==="Enter"||b2.key==="Tab")b2.preventDefault(),X();else if(b2.key==="Backspace"&&(R==null?void 0:R.length)===0){Q(j2=>(j2==null||j2.pop(),[...j2||[]])),w==null||w.pop();const g2=[...w||[]];s==null||s(g2)}},f2=()=>{X()};z0.useEffect(()=>{C&&Array.isArray(C)?Q(C):Q([])},[C]);const A2=b2=>{const g2=b2.target.parentElement;g2.scrollLeft=g2.scrollWidth,N(b2.target.value),r==null||r(b2.target.value)};return z0.useEffect(()=>{g==null||g("")},[R]),E.jsx(RE,{name:o||"tags",control:n,defaultValue:"",render:({field:b2})=>{var R2,M2,P2,G2;const{ref:g2,...j2}=b2;return E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[a?E.jsxs(q7,{variant:"input-label",color:"primary",children:[a,l?E.jsx("span",{className:gV.important,children:"*"}):null]}):null,E.jsxs("div",{className:gV.inputFieldContainer,style:{width:u},id:`${(M2=(R2=a??t)==null?void 0:R2.replaceAll(" ","-"))==null?void 0:M2.toLowerCase()}-input`,"data-testid":`${(G2=(P2=a??t)==null?void 0:P2.replaceAll(" ","-"))==null?void 0:G2.toLowerCase()}-input`,children:[w!=null&&w.length?E.jsx("div",{className:gV["tag-container"],children:w==null?void 0:w.map(C0=>E.jsx(C8,{variant:"popover",type:"button",onClick:()=>O(C0),className:"dbn-flex dbn-font-semibold dbn-gap-2 dbn-px-2 dbn-py-1 dbn-bg-gray dbn-rounded",rightIcon:E.jsx(m8,{name:"cross",size:"xxs"}),children:E.jsx("span",{className:gV["tag-text"],children:C0})},C0))}):null,E.jsx("input",{...j2,type:"text",value:R,onChange:A2,onKeyDown:K,placeholder:w!=null&&w.length?"":i,disabled:e,className:`dbn-outline-none dbn-border-none dbn-text-sm ${w!=null&&w.length?"dbn-max-w-[400px]":"dbn-w-full"} ${{...h}}`,onBlur:f2})]})]}),d&&E.jsx(Il,{text:d,variant:"error"}),!d&&m&&E.jsx(q7,{variant:"body-text-2",color:"alert",children:m})]})}})};k9.memo(R_);const ic={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:Hu2,setPrototypeOf:Du2,isFrozen:v70,getPrototypeOf:I70,getOwnPropertyDescriptor:m70}=Object;let{freeze:oc,seal:ed,create:Su2}=Object,{apply:H_,construct:D_}=typeof Reflect<"u"&&Reflect;oc||(oc=function(n){return n}),ed||(ed=function(n){return n}),H_||(H_=function(n,i,o){return n.apply(i,o)}),D_||(D_=function(n,i){return new n(...i)});const hV=sc(Array.prototype.forEach),b70=sc(Array.prototype.lastIndexOf),Nu2=sc(Array.prototype.pop),dM=sc(Array.prototype.push),B70=sc(Array.prototype.splice),EV=sc(String.prototype.toLowerCase),S_=sc(String.prototype.toString),Vu2=sc(String.prototype.match),gM=sc(String.prototype.replace),y70=sc(String.prototype.indexOf),L70=sc(String.prototype.trim),jd=sc(Object.prototype.hasOwnProperty),ac=sc(RegExp.prototype.test),hM=w70(TypeError);function sc(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 H_(t,n,o)}}function w70(t){return function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return D_(t,i)}}function nC(t,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:EV;Du2&&Du2(t,null);let o=n.length;for(;o--;){let a=n[o];if(typeof a=="string"){const s=i(a);s!==a&&(v70(n)||(n[o]=s),a=s)}t[a]=!0}return t}function Q70(t){for(let n=0;n<t.length;n++)jd(t,n)||(t[n]=null);return t}function Am(t){const n=Su2(null);for(const[i,o]of Hu2(t))jd(t,i)&&(Array.isArray(o)?n[i]=Q70(o):o&&typeof o=="object"&&o.constructor===Object?n[i]=Am(o):n[i]=o);return n}function EM(t,n){for(;t!==null;){const o=m70(t,n);if(o){if(o.get)return sc(o.get);if(typeof o.value=="function")return sc(o.value)}t=I70(t)}function i(){return null}return i}const ku2=oc(["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"]),N_=oc(["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"]),V_=oc(["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"]),M70=oc(["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"]),k_=oc(["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"]),T70=oc(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ou2=oc(["#text"]),Pu2=oc(["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"]),O_=oc(["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"]),Zu2=oc(["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"]),pV=oc(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),x70=ed(/\{\{[\w\W]*|[\w\W]*\}\}/gm),R70=ed(/<%[\w\W]*|[\w\W]*%>/gm),H70=ed(/\$\{[\w\W]*/gm),D70=ed(/^data-[\-\w.\u00B7-\uFFFF]+$/),S70=ed(/^aria-[\-\w]+$/),Fu2=ed(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),N70=ed(/^(?:\w+script|data):/i),V70=ed(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Uu2=ed(/^html$/i),k70=ed(/^[a-z][.\w]*(-[.\w]+)+$/i);var ju2=Object.freeze({__proto__:null,ARIA_ATTR:S70,ATTR_WHITESPACE:V70,CUSTOM_ELEMENT:k70,DATA_ATTR:D70,DOCTYPE_NAME:Uu2,ERB_EXPR:R70,IS_ALLOWED_URI:Fu2,IS_SCRIPT_OR_DATA:N70,MUSTACHE_EXPR:x70,TMPLIT_EXPR:H70});const pM={element:1,text:3,progressingInstruction:7,comment:8,document:9},O70=function(){return typeof window>"u"?null:window},P70=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}},zu2=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Gu2(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:O70();const n=r6=>Gu2(r6);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==pM.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,h=EM(g,"cloneNode"),m=EM(g,"remove"),w=EM(g,"nextSibling"),Q=EM(g,"childNodes"),R=EM(g,"parentNode");if(typeof r=="function"){const r6=i.createElement("template");r6.content&&r6.content.ownerDocument&&(i=r6.content.ownerDocument)}let N,O="";const{implementation:X,createNodeIterator:K,createDocumentFragment:f2,getElementsByTagName:A2}=i,{importNode:b2}=o;let g2=zu2();n.isSupported=typeof Hu2=="function"&&typeof R=="function"&&X&&X.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:j2,ERB_EXPR:R2,TMPLIT_EXPR:M2,DATA_ATTR:P2,ARIA_ATTR:G2,IS_SCRIPT_OR_DATA:C0,ATTR_WHITESPACE:m0,CUSTOM_ELEMENT:H0}=ju2;let{IS_ALLOWED_URI:v0}=ju2,J2=null;const U0=nC({},[...ku2,...N_,...V_,...k_,...Ou2]);let b0=null;const k0=nC({},[...Pu2,...O_,...Zu2,...pV]);let J0=Object.seal(Su2(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}})),Y2=null,L3=null,M1=!0,B3=!0,j3=!1,w7=!0,l3=!1,c7=!0,T3=!1,y6=!1,t6=!1,C6=!1,n3=!1,t0=!1,V3=!0,Z7=!1;const e6="user-content-";let l7=!0,A6=!1,w6={},v1=null;const h3=nC({},["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 o7=null;const m7=nC({},["audio","video","img","source","image","track"]);let G3=null;const J3=nC({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),k7="http://www.w3.org/1998/Math/MathML",W7="http://www.w3.org/2000/svg",J7="http://www.w3.org/1999/xhtml";let e8=J7,z7=!1,x6=null;const c8=nC({},[k7,W7,J7],S_);let h9=nC({},["mi","mo","mn","ms","mtext"]),U8=nC({},["annotation-xml"]);const $9=nC({},["title","style","font","a","script"]);let o9=null;const M9=["application/xhtml+xml","text/html"],j8="text/html";let y5=null,H5=null;const _5=i.createElement("form"),T5=function(q3){return q3 instanceof RegExp||q3 instanceof Function},S8=function(){let q3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(H5&&H5===q3)){if((!q3||typeof q3!="object")&&(q3={}),q3=Am(q3),o9=M9.indexOf(q3.PARSER_MEDIA_TYPE)===-1?j8:q3.PARSER_MEDIA_TYPE,y5=o9==="application/xhtml+xml"?S_:EV,J2=jd(q3,"ALLOWED_TAGS")?nC({},q3.ALLOWED_TAGS,y5):U0,b0=jd(q3,"ALLOWED_ATTR")?nC({},q3.ALLOWED_ATTR,y5):k0,x6=jd(q3,"ALLOWED_NAMESPACES")?nC({},q3.ALLOWED_NAMESPACES,S_):c8,G3=jd(q3,"ADD_URI_SAFE_ATTR")?nC(Am(J3),q3.ADD_URI_SAFE_ATTR,y5):J3,o7=jd(q3,"ADD_DATA_URI_TAGS")?nC(Am(m7),q3.ADD_DATA_URI_TAGS,y5):m7,v1=jd(q3,"FORBID_CONTENTS")?nC({},q3.FORBID_CONTENTS,y5):h3,Y2=jd(q3,"FORBID_TAGS")?nC({},q3.FORBID_TAGS,y5):{},L3=jd(q3,"FORBID_ATTR")?nC({},q3.FORBID_ATTR,y5):{},w6=jd(q3,"USE_PROFILES")?q3.USE_PROFILES:!1,M1=q3.ALLOW_ARIA_ATTR!==!1,B3=q3.ALLOW_DATA_ATTR!==!1,j3=q3.ALLOW_UNKNOWN_PROTOCOLS||!1,w7=q3.ALLOW_SELF_CLOSE_IN_ATTR!==!1,l3=q3.SAFE_FOR_TEMPLATES||!1,c7=q3.SAFE_FOR_XML!==!1,T3=q3.WHOLE_DOCUMENT||!1,C6=q3.RETURN_DOM||!1,n3=q3.RETURN_DOM_FRAGMENT||!1,t0=q3.RETURN_TRUSTED_TYPE||!1,t6=q3.FORCE_BODY||!1,V3=q3.SANITIZE_DOM!==!1,Z7=q3.SANITIZE_NAMED_PROPS||!1,l7=q3.KEEP_CONTENT!==!1,A6=q3.IN_PLACE||!1,v0=q3.ALLOWED_URI_REGEXP||Fu2,e8=q3.NAMESPACE||J7,h9=q3.MATHML_TEXT_INTEGRATION_POINTS||h9,U8=q3.HTML_INTEGRATION_POINTS||U8,J0=q3.CUSTOM_ELEMENT_HANDLING||{},q3.CUSTOM_ELEMENT_HANDLING&&T5(q3.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(J0.tagNameCheck=q3.CUSTOM_ELEMENT_HANDLING.tagNameCheck),q3.CUSTOM_ELEMENT_HANDLING&&T5(q3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(J0.attributeNameCheck=q3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),q3.CUSTOM_ELEMENT_HANDLING&&typeof q3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(J0.allowCustomizedBuiltInElements=q3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),l3&&(B3=!1),n3&&(C6=!0),w6&&(J2=nC({},Ou2),b0=[],w6.html===!0&&(nC(J2,ku2),nC(b0,Pu2)),w6.svg===!0&&(nC(J2,N_),nC(b0,O_),nC(b0,pV)),w6.svgFilters===!0&&(nC(J2,V_),nC(b0,O_),nC(b0,pV)),w6.mathMl===!0&&(nC(J2,k_),nC(b0,Zu2),nC(b0,pV))),q3.ADD_TAGS&&(J2===U0&&(J2=Am(J2)),nC(J2,q3.ADD_TAGS,y5)),q3.ADD_ATTR&&(b0===k0&&(b0=Am(b0)),nC(b0,q3.ADD_ATTR,y5)),q3.ADD_URI_SAFE_ATTR&&nC(G3,q3.ADD_URI_SAFE_ATTR,y5),q3.FORBID_CONTENTS&&(v1===h3&&(v1=Am(v1)),nC(v1,q3.FORBID_CONTENTS,y5)),l7&&(J2["#text"]=!0),T3&&nC(J2,["html","head","body"]),J2.table&&(nC(J2,["tbody"]),delete Y2.tbody),q3.TRUSTED_TYPES_POLICY){if(typeof q3.TRUSTED_TYPES_POLICY.createHTML!="function")throw hM('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof q3.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hM('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=q3.TRUSTED_TYPES_POLICY,O=N.createHTML("")}else N===void 0&&(N=P70(d,a)),N!==null&&typeof O=="string"&&(O=N.createHTML(""));oc&&oc(q3),H5=q3}},W1=nC({},[...N_,...V_,...M70]),W9=nC({},[...k_,...T70]),I6=function(q3){let Z6=R(q3);(!Z6||!Z6.tagName)&&(Z6={namespaceURI:e8,tagName:"template"});const o8=EV(q3.tagName),D8=EV(Z6.tagName);return x6[q3.namespaceURI]?q3.namespaceURI===W7?Z6.namespaceURI===J7?o8==="svg":Z6.namespaceURI===k7?o8==="svg"&&(D8==="annotation-xml"||h9[D8]):!!W1[o8]:q3.namespaceURI===k7?Z6.namespaceURI===J7?o8==="math":Z6.namespaceURI===W7?o8==="math"&&U8[D8]:!!W9[o8]:q3.namespaceURI===J7?Z6.namespaceURI===W7&&!U8[D8]||Z6.namespaceURI===k7&&!h9[D8]?!1:!W9[o8]&&($9[o8]||!W1[o8]):!!(o9==="application/xhtml+xml"&&x6[q3.namespaceURI]):!1},l8=function(q3){dM(n.removed,{element:q3});try{R(q3).removeChild(q3)}catch{m(q3)}},h8=function(q3,Z6){try{dM(n.removed,{attribute:Z6.getAttributeNode(q3),from:Z6})}catch{dM(n.removed,{attribute:null,from:Z6})}if(Z6.removeAttribute(q3),q3==="is")if(C6||n3)try{l8(Z6)}catch{}else try{Z6.setAttribute(q3,"")}catch{}},Y6=function(q3){let Z6=null,o8=null;if(t6)q3="<remove></remove>"+q3;else{const k8=Vu2(q3,/^[\r\n\t ]+/);o8=k8&&k8[0]}o9==="application/xhtml+xml"&&e8===J7&&(q3='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+q3+"</body></html>");const D8=N?N.createHTML(q3):q3;if(e8===J7)try{Z6=new f().parseFromString(D8,o9)}catch{}if(!Z6||!Z6.documentElement){Z6=X.createDocument(e8,"template",null);try{Z6.documentElement.innerHTML=z7?O:D8}catch{}}const z8=Z6.body||Z6.documentElement;return q3&&o8&&z8.insertBefore(i.createTextNode(o8),z8.childNodes[0]||null),e8===J7?A2.call(Z6,T3?"html":"body")[0]:T3?Z6.documentElement:z8},Q8=function(q3){return K.call(q3.ownerDocument||q3,q3,e.SHOW_ELEMENT|e.SHOW_COMMENT|e.SHOW_TEXT|e.SHOW_PROCESSING_INSTRUCTION|e.SHOW_CDATA_SECTION,null)},x1=function(q3){return q3 instanceof A&&(typeof q3.nodeName!="string"||typeof q3.textContent!="string"||typeof q3.removeChild!="function"||!(q3.attributes instanceof u)||typeof q3.removeAttribute!="function"||typeof q3.setAttribute!="function"||typeof q3.namespaceURI!="string"||typeof q3.insertBefore!="function"||typeof q3.hasChildNodes!="function")},L7=function(q3){return typeof C=="function"&&q3 instanceof C};function O6(r6,q3,Z6){hV(r6,o8=>{o8.call(n,q3,Z6,H5)})}const x7=function(q3){let Z6=null;if(O6(g2.beforeSanitizeElements,q3,null),x1(q3))return l8(q3),!0;const o8=y5(q3.nodeName);if(O6(g2.uponSanitizeElement,q3,{tagName:o8,allowedTags:J2}),q3.hasChildNodes()&&!L7(q3.firstElementChild)&&ac(/<[/\w]/g,q3.innerHTML)&&ac(/<[/\w]/g,q3.textContent)||q3.nodeType===pM.progressingInstruction||c7&&q3.nodeType===pM.comment&&ac(/<[/\w]/g,q3.data))return l8(q3),!0;if(!J2[o8]||Y2[o8]){if(!Y2[o8]&&K6(o8)&&(J0.tagNameCheck instanceof RegExp&&ac(J0.tagNameCheck,o8)||J0.tagNameCheck instanceof Function&&J0.tagNameCheck(o8)))return!1;if(l7&&!v1[o8]){const D8=R(q3)||q3.parentNode,z8=Q(q3)||q3.childNodes;if(z8&&D8){const k8=z8.length;for(let k3=k8-1;k3>=0;--k3){const h5=h(z8[k3],!0);h5.__removalCount=(q3.__removalCount||0)+1,D8.insertBefore(h5,w(q3))}}}return l8(q3),!0}return q3 instanceof l&&!I6(q3)||(o8==="noscript"||o8==="noembed"||o8==="noframes")&&ac(/<\/no(script|embed|frames)/i,q3.innerHTML)?(l8(q3),!0):(l3&&q3.nodeType===pM.text&&(Z6=q3.textContent,hV([j2,R2,M2],D8=>{Z6=gM(Z6,D8," ")}),q3.textContent!==Z6&&(dM(n.removed,{element:q3.cloneNode()}),q3.textContent=Z6)),O6(g2.afterSanitizeElements,q3,null),!1)},a7=function(q3,Z6,o8){if(V3&&(Z6==="id"||Z6==="name")&&(o8 in i||o8 in _5))return!1;if(!(B3&&!L3[Z6]&&ac(P2,Z6))){if(!(M1&&ac(G2,Z6))){if(!b0[Z6]||L3[Z6]){if(!(K6(q3)&&(J0.tagNameCheck instanceof RegExp&&ac(J0.tagNameCheck,q3)||J0.tagNameCheck instanceof Function&&J0.tagNameCheck(q3))&&(J0.attributeNameCheck instanceof RegExp&&ac(J0.attributeNameCheck,Z6)||J0.attributeNameCheck instanceof Function&&J0.attributeNameCheck(Z6))||Z6==="is"&&J0.allowCustomizedBuiltInElements&&(J0.tagNameCheck instanceof RegExp&&ac(J0.tagNameCheck,o8)||J0.tagNameCheck instanceof Function&&J0.tagNameCheck(o8))))return!1}else if(!G3[Z6]){if(!ac(v0,gM(o8,m0,""))){if(!((Z6==="src"||Z6==="xlink:href"||Z6==="href")&&q3!=="script"&&y70(o8,"data:")===0&&o7[q3])){if(!(j3&&!ac(C0,gM(o8,m0,"")))){if(o8)return!1}}}}}}return!0},K6=function(q3){return q3!=="annotation-xml"&&Vu2(q3,H0)},o6=function(q3){O6(g2.beforeSanitizeAttributes,q3,null);const{attributes:Z6}=q3;if(!Z6||x1(q3))return;const o8={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:b0,forceKeepAttr:void 0};let D8=Z6.length;for(;D8--;){const z8=Z6[D8],{name:k8,namespaceURI:k3,value:h5}=z8,I8=y5(k8);let D9=k8==="value"?h5:L70(h5);if(o8.attrName=I8,o8.attrValue=D9,o8.keepAttr=!0,o8.forceKeepAttr=void 0,O6(g2.uponSanitizeAttribute,q3,o8),D9=o8.attrValue,Z7&&(I8==="id"||I8==="name")&&(h8(k8,q3),D9=e6+D9),c7&&ac(/((--!?|])>)|<\/(style|title)/i,D9)){h8(k8,q3);continue}if(o8.forceKeepAttr||(h8(k8,q3),!o8.keepAttr))continue;if(!w7&&ac(/\/>/i,D9)){h8(k8,q3);continue}l3&&hV([j2,R2,M2],A5=>{D9=gM(D9,A5," ")});const E8=y5(q3.nodeName);if(a7(E8,I8,D9)){if(N&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!k3)switch(d.getAttributeType(E8,I8)){case"TrustedHTML":{D9=N.createHTML(D9);break}case"TrustedScriptURL":{D9=N.createScriptURL(D9);break}}try{k3?q3.setAttributeNS(k3,k8,D9):q3.setAttribute(k8,D9),x1(q3)?l8(q3):Nu2(n.removed)}catch{}}}O6(g2.afterSanitizeAttributes,q3,null)},N7=function r6(q3){let Z6=null;const o8=Q8(q3);for(O6(g2.beforeSanitizeShadowDOM,q3,null);Z6=o8.nextNode();)O6(g2.uponSanitizeShadowNode,Z6,null),x7(Z6),o6(Z6),Z6.content instanceof s&&r6(Z6.content);O6(g2.afterSanitizeShadowDOM,q3,null)};return n.sanitize=function(r6){let q3=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Z6=null,o8=null,D8=null,z8=null;if(z7=!r6,z7&&(r6="<!-->"),typeof r6!="string"&&!L7(r6))if(typeof r6.toString=="function"){if(r6=r6.toString(),typeof r6!="string")throw hM("dirty is not a string, aborting")}else throw hM("toString is not a function");if(!n.isSupported)return r6;if(y6||S8(q3),n.removed=[],typeof r6=="string"&&(A6=!1),A6){if(r6.nodeName){const h5=y5(r6.nodeName);if(!J2[h5]||Y2[h5])throw hM("root node is forbidden and cannot be sanitized in-place")}}else if(r6 instanceof C)Z6=Y6("<!---->"),o8=Z6.ownerDocument.importNode(r6,!0),o8.nodeType===pM.element&&o8.nodeName==="BODY"||o8.nodeName==="HTML"?Z6=o8:Z6.appendChild(o8);else{if(!C6&&!l3&&!T3&&r6.indexOf("<")===-1)return N&&t0?N.createHTML(r6):r6;if(Z6=Y6(r6),!Z6)return C6?null:t0?O:""}Z6&&t6&&l8(Z6.firstChild);const k8=Q8(A6?r6:Z6);for(;D8=k8.nextNode();)x7(D8),o6(D8),D8.content instanceof s&&N7(D8.content);if(A6)return r6;if(C6){if(n3)for(z8=f2.call(Z6.ownerDocument);Z6.firstChild;)z8.appendChild(Z6.firstChild);else z8=Z6;return(b0.shadowroot||b0.shadowrootmode)&&(z8=b2.call(o,z8,!0)),z8}let k3=T3?Z6.outerHTML:Z6.innerHTML;return T3&&J2["!doctype"]&&Z6.ownerDocument&&Z6.ownerDocument.doctype&&Z6.ownerDocument.doctype.name&&ac(Uu2,Z6.ownerDocument.doctype.name)&&(k3="<!DOCTYPE "+Z6.ownerDocument.doctype.name+`>
587
+ `)).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),Mp(C)||(i>n&&(s+=t.substring(n,i)),s+=C,n=i=a+1)}return i>n&&(s+=t.substring(n,t.length)),s},Z00=!!uW||!!lW,tu2="text/plain",iV=(t,n)=>{var[i,o]=t.split("?"),a=P4({},n);o==null||o.split("&").forEach(r=>{var[C]=r.split("=");delete a[C]});var s=f20(a);return s=s?(o?o+"&":"")+s:o,"".concat(i,"?").concat(s)},lM=(t,n)=>JSON.stringify(t,(i,o)=>typeof o=="bigint"?o.toString():o,n),d_=t=>{var{data:n,compression:i}=t;if(n){if(i===Pd.GZipJS){var o=el2(tl2(lM(n)),{mtime:0}),a=new Blob([o],{type:tu2});return{contentType:tu2,body:a,estimatedSize:a.size}}if(i===Pd.Base64){var s=function(l){var e,u,A,f,d,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=0,m=0,w="",Q=[];if(!l)return l;l=P00(l);do e=(d=l.charCodeAt(h++)<<16|l.charCodeAt(h++)<<8|l.charCodeAt(h++))>>18&63,u=d>>12&63,A=d>>6&63,f=63&d,Q[m++]=g.charAt(e)+g.charAt(u)+g.charAt(A)+g.charAt(f);while(h<l.length);switch(w=Q.join(""),l.length%3){case 1:w=w.slice(0,-2)+"==";break;case 2:w=w.slice(0,-1)+"="}return w}(lM(n)),r=(l=>"data="+encodeURIComponent(typeof l=="string"?l:lM(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var C=lM(n);return{contentType:"application/json",body:C,estimatedSize:new Blob([C]).size}}},uM=[];lW&&uM.push({transport:"fetch",method:t=>{var n,i,{contentType:o,body:a,estimatedSize:s}=(n=d_(t))!==null&&n!==void 0?n:{},r=new Headers;il(t.headers,function(u,A){r.append(A,u)}),o&&r.append("Content-Type",o);var C=t.url,l=null;if(_s2){var e=new _s2;l={signal:e.signal,timeout:setTimeout(()=>e.abort(),t.timeout)}}lW(C,P4({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){Ki.error(g)}(f=t.callback)===null||f===void 0||f.call(t,d)})).catch(u=>{var A;Ki.error(u),(A=t.callback)===null||A===void 0||A.call(t,{statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),uW&&uM.push({transport:"XHR",method:t=>{var n,i=new uW;i.open(t.method||"GET",t.url,!0);var{contentType:o,body:a}=(n=d_(t))!==null&&n!==void 0?n:{};il(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)}}),af!=null&&af.sendBeacon&&uM.push({transport:"sendBeacon",method:t=>{var n=iV(t.url,{beacon:"1"});try{var i,{contentType:o,body:a}=(i=d_(t))!==null&&i!==void 0?i:{},s=typeof a=="string"?new Blob([a],{type:o}):a;af.sendBeacon(n,s)}catch{}}});var g_=3e3;class F00{constructor(n,i){Pt(this,"isPaused",!0),Pt(this,"queue",[]),this.flushTimeoutMs=Xf((i==null?void 0:i.flush_interval_ms)||g_,250,5e3,"flush interval",g_),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(P4(P4({},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&&Fl(r.data)&&il(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 il(this.queue,i=>{var o,a=i,s=(a?a.batchKey:null)||a.url;Qr(n[s])&&(n[s]=P4(P4({},a),{},{data:[]})),(o=n[s].data)===null||o===void 0||o.push(a.data)}),this.queue=[],n}}var U00=["retriesPerformedSoFar"];class j00{constructor(n){Pt(this,"isPolling",!1),Pt(this,"pollIntervalMs",3e3),Pt(this,"queue",[]),this.instance=n,this.queue=[],this.areWeOnline=!0,!Qr(p4)&&"onLine"in p4.navigator&&(this.areWeOnline=p4.navigator.onLine,$l(p4,"online",()=>{this.areWeOnline=!0,this.flush()}),$l(p4,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(n){var{retriesPerformedSoFar:i}=n,o=eC2(n,U00);tc(i)&&i>0&&(o.url=iV(o.url,{retry_count:i})),this.instance._send_request(P4(P4({},o),{},{callback:a=>{var s;a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(i??0)<10?this.enqueue(P4({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)"),Ki.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(P4(P4({},n),{},{transport:"sendBeacon"}))}catch(i){Ki.error(i)}this.queue=[]}}class z00{constructor(n){Pt(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(){$l(p4,"scroll",this._updateScrollData,{capture:!0}),$l(p4,"scrollend",this._updateScrollData,{capture:!0}),$l(p4,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return p4==null?void 0:p4.document.documentElement;var n=Fl(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 G00=t=>Ql.personInfo({maskPersonalDataProperties:t==null?void 0:t.config.mask_personal_data_properties,customPersonalDataProperties:t==null?void 0:t.config.custom_personal_data_properties});class Y00{constructor(n,i,o,a){Pt(this,"_onSessionIdCallback",s=>{var r=this._getStored();if(!r||r.sessionId!==s){var C={sessionId:s,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[IW]:C})}}),this.instance=n,this._sessionIdManager=i,this._persistence=o,this._sessionSourceParamGenerator=a||G00,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[IW]}getSetOnceProps(){var n,i=(n=this._getStored())===null||n===void 0?void 0:n.props;return i?"r"in i?Ql.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 il(YQ(this.getSetOnceProps()),(i,o)=>{o==="$current_url"&&(o="url"),n["$session_entry_".concat(cW(o))]=i}),n}}var ru2=xA("[SessionId]");class W00{constructor(n,i,o){var a;if(Pt(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||Hp,this._windowIdGenerator=o||Hp;var s=this.config.persistence_name||this.config.token,r=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Xf(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=rA.parse(this._window_id_storage_key),l=rA.parse(this._primary_window_exists_storage_key);C&&!l?this._windowId=C:rA.remove(this._window_id_storage_key),rA.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){ru2.error("Invalid sessionID in bootstrap",u)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(n){return Qr(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&&rA.is_supported()}_setWindowId(n){n!==this._windowId&&(this._windowId=n,this._canUseSessionStorage()&&rA.set(this._window_id_storage_key,n))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?rA.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({[RN]:[i,n,o]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var n=this.persistence.props[RN];return Fl(n)&&n.length===2&&n.push(n[0]),n||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){$l(p4,"beforeunload",()=>{this._canUseSessionStorage()&&rA.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=tc(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(),ru2.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 _00=["$set_once","$set"],Np=xA("[SiteApps]");class X00{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=Ps._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:h}=n;return{event:P4(P4({},eC2(n,_00)),{},{properties:P4(P4(P4({},n.properties),h?{$set:P4(P4({},(i=(o=n.properties)===null||o===void 0?void 0:o.$set)!==null&&i!==void 0?i:{}),h)}:{}),g?{$set_once:P4(P4({},(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&&(Np.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,Np.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){Np.error("Error while initializing PostHog app with config id ".concat(n.id),C),s(!1)}if(a&&i.loaded)try{o()}catch(C){Np.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){Np.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 Np.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;Ps["__$$ph_site_app_".concat(e)]=s.instance,(A=Ps.__PosthogExtensions__)===null||A===void 0||(f=A.loadSiteApp)===null||f===void 0||f.call(A,s.instance,u,d=>{if(d)return Np.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 Np.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var um,K00=["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"],nu2=function(t,n){if(!t)return!1;var i=t.toLowerCase();return K00.concat(n||[]).some(o=>{var a=o.toLowerCase();return i.indexOf(a)!==-1})},iu2=function(t,n){if(!t)return!1;var i=t.userAgent;if(i&&nu2(i,n))return!0;try{var o=t==null?void 0:t.userAgentData;if(o!=null&&o.brands&&o.brands.some(a=>nu2(a==null?void 0:a.brand,n)))return!0}catch{}return!!t.webdriver};function h_(t,n,i){return lM({distinct_id:t,userPropertiesToSet:n,userPropertiesToSetOnce:i})}(function(t){t.US="us",t.EU="eu",t.CUSTOM="custom"})(um||(um={}));var ou2="i.posthog.com";class J00{constructor(n){Pt(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(ou2),".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]=um.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=um.EU:this._regionCache[this.apiHost]=um.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===um.CUSTOM)return this.apiHost+i;var o=ou2+i;switch(n){case"assets":return"https://".concat(this.region,"-assets.").concat(o);case"api":return"https://".concat(this.region,".").concat(o)}}}var q00={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&&ey(n.href,t),not_regex:(t,n)=>!!p4&&!ey(n.href,t),exact:(t,n)=>n.href===t,is_not:(t,n)=>n.href!==t};class HA{constructor(n){var i=this;Pt(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var o=arguments.length>0&&arguments[0]!==void 0&&arguments[0];i.getWebExperiments(a=>{HA.logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,a.forEach(s=>{if(s.feature_flag_key){var r;i._flagToExperiments&&(HA.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);fu(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];HA.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())HA.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(el(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();HA.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=HA.getWindowLocation();if(n!=null&&n.search){var i=PN(n==null?void 0:n.search,"__experiment_id"),o=PN(n==null?void 0:n.search,"__experiment_variant");i&&o&&(HA.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&&(HA.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!el(n.conditions)&&HA.matchUrlConditions(n)&&HA.matchUTMConditions(n)}static matchUrlConditions(n){var i;if(el(n.conditions)||el((i=n.conditions)===null||i===void 0?void 0:i.url))return!0;var o,a,s,r=HA.getWindowLocation();return!!r&&((o=n.conditions)===null||o===void 0||!o.url||q00[(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(el(n.conditions)||el((i=n.conditions)===null||i===void 0?void 0:i.utm))return!0;var o=Ql.campaignParams();if(o.utm_source){var a,s,r,C,l,e,u,A,f,d,g,h,m,w,Q,R,N=(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,O=(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,X=(f=n.conditions)===null||f===void 0||(d=f.utm)===null||d===void 0||!d.utm_medium||((g=n.conditions)===null||g===void 0||(h=g.utm)===null||h===void 0?void 0:h.utm_medium)==o.utm_medium,K=(m=n.conditions)===null||m===void 0||(w=m.utm)===null||w===void 0||!w.utm_term||((Q=n.conditions)===null||Q===void 0||(R=Q.utm)===null||R===void 0?void 0:R.utm_term)==o.utm_term;return N&&X&&K&&O}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];Ki.info("[WebExperiments] ".concat(n),o)}applyTransforms(n,i,o){this._is_bot()?HA.logInfo("Refusing to render web experiment since the viewer is a likely bot"):i!=="control"?o.forEach(a=>{if(a.selector){var s;HA.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)})}}):HA.logInfo("Control variants leave the page unmodified.")}_is_bot(){return af&&this.instance?iu2(af,this.instance.config.custom_blocked_useragents):void 0}}var AM={},E_=()=>{},ty="posthog",au2=!Z00&&(cu==null?void 0:cu.indexOf("MSIE"))===-1&&(cu==null?void 0:cu.indexOf("Mozilla"))===-1,su2=()=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:n20(Un==null?void 0:Un.location),persistence:"localStorage+cookie",persistence_name:"",loaded:E_,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:_f&&fu(_f==null?void 0:_f.search)&&_f.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;Ki.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:g_},_onCapture:E_}},Cu2=t=>{var n={};Qr(t.process_person)||(n.person_profiles=t.process_person),Qr(t.xhr_headers)||(n.request_headers=t.xhr_headers),Qr(t.cookie_name)||(n.persistence_name=t.cookie_name),Qr(t.disable_cookie)||(n.disable_persistence=t.disable_cookie),Qr(t.store_google)||(n.save_campaign_params=t.store_google),Qr(t.verbose)||(n.debug=t.verbose);var i=du({},n,t);return Fl(t.property_blacklist)&&(Qr(t.property_denylist)?i.property_denylist=t.property_blacklist:Fl(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:Ki.error("Invalid value for property_denylist config: "+t.property_denylist)),i};class $00{constructor(){Pt(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(n){Ki.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=n}}class oV{get decideEndpointWasHit(){var n,i;return(n=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&n!==void 0&&n}constructor(){Pt(this,"webPerformance",new $00),Pt(this,"_personProcessingSetOncePropertiesSent",!1),Pt(this,"version",Kh.LIB_VERSION),Pt(this,"_internalEventEmitter",new Jl2),this.config=su2(),this.SentryIntegration=s00,this.sentryIntegration=n=>function(i,o){var a=al2(i,o);return{name:ol2,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 M00(this),this.toolbar=new l00(this),this.scrollManager=new z00(this),this.pageViewManager=new g00(this),this.surveys=new V00(this),this.experiments=new HA(this),this.exceptions=new h00(this),this.rateLimiter=new k00(this),this.requestRouter=new J00(this),this.consent=new w20(this),this.people={set:(n,i,o)=>{var a=fu(n)?{[n]:i}:n;this.setPersonProperties(a),o==null||o({})},set_once:(n,i,o)=>{var a=fu(n)?{[n]:i}:n;this.setPersonProperties(void 0,a),o==null||o({})}},this.on("eventCaptured",n=>Ki.info('send "'.concat(n==null?void 0:n.event,'"'),n))}init(n,i,o){if(o&&o!==ty){var a,s=(a=AM[o])!==null&&a!==void 0?a:new oV;return s._init(n,i,o),AM[o]=s,AM[ty][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(Qr(n)||fW(n))return Ki.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 Ki.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(du({},su2(),Cu2(a),{name:s,token:n})),this.config.on_xhr_error&&Ki.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=a.disable_compression?void 0:Pd.GZipJS,this.persistence=new o_(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new o_(P4(P4({},this.config),{},{persistence:"sessionStorage"}));var r=P4({},this.persistence.props),C=P4({},this.sessionPersistence.props);if(this._requestQueue=new F00(w=>this._send_retriable_request(w),this.config.request_queue_config),this._retryQueue=new j00(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new W00(this),this.sessionPropsManager=new Y00(this,this.sessionManager,this.persistence)),new A00(this).startIfEnabledOrStop(),this.siteApps=new X00(this),(i=this.siteApps)===null||i===void 0||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new o00(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new E20(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new d00(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new c00(this),this.exceptionObserver=new T20(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new VC2(this,M20),this.deadClicksAutocapture.startIfEnabled(),Kh.DEBUG=Kh.DEBUG||this.config.debug,Kh.DEBUG&&Ki.info("Starting in debug mode",{this:this,config:a,thisC:P4({},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(Hp()),A=(l=a.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?u:a.bootstrap.distinctID;this.persistence.set_property(Jh,(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(w=>{var Q,R;return!((Q=a.bootstrap)===null||Q===void 0||(R=Q.featureFlags)===null||R===void 0||!R[w])}).reduce((w,Q)=>{var R,N;return w[Q]=((R=a.bootstrap)===null||R===void 0||(N=R.featureFlags)===null||N===void 0?void 0:N[Q])||!1,w},{}),h=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlagPayloads)||{}).filter(w=>g[w]).reduce((w,Q)=>{var R,N,O,X;return(R=a.bootstrap)!==null&&R!==void 0&&(N=R.featureFlagPayloads)!==null&&N!==void 0&&N[Q]&&(w[Q]=(O=a.bootstrap)===null||O===void 0||(X=O.featureFlagPayloads)===null||X===void 0?void 0:X[Q]),w},{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:h})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:EC2,$device_id:null},"");else if(!this.get_distinct_id()){var m=this.config.get_device_id(Hp());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(Jh,"anonymous")}return $l(p4,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),a.segment?a00(this,()=>this._loaded()):this._loaded(),Zd(this.config._onCapture)&&this.config._onCapture!==E_&&(Ki.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",w=>this.config._onCapture(w.event,w))),this}_onRemoteConfig(n){var i,o,a,s,r,C,l,e;if(!Un||!Un.body)return Ki.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=rC(n.supportedCompression,Pd.GZipJS)?Pd.GZipJS:rC(n.supportedCompression,Pd.Base64)?Pd.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){Ki.critical("`loaded` function failed",n)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new O00(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()||xp(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&&(au2?this.__request_queue.push(n):this.rateLimiter.isServerRateLimited(n.batchKey)||(n.transport=n.transport||this.config.api_transport,n.url=iV(n.url,{ip:this.config.ip?1:0}),n.headers=P4({},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=P4({},i);r.timeout=r.timeout||6e4,r.url=iV(r.url,{_:new Date().getTime().toString(),ver:Kh.LIB_VERSION,compression:r.compression});var C=(o=r.transport)!==null&&o!==void 0?o:"fetch",l=(a=(s=rC2(uM,e=>e.transport===C))===null||s===void 0?void 0:s.method)!==null&&a!==void 0?a:uM[0].method;if(!l)throw new Error("No available transport method");l(r)})(P4(P4({},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=[];xp(n,C=>{C&&(i=C[0],Fl(i)?s.push(C):Zd(C)?C.call(this):Fl(C)&&i==="alias"?o.push(C):Fl(C)&&i.indexOf("capture")!==-1&&Zd(this[i])?s.push(C):a.push(C))});var r=function(C,l){xp(C,function(e){if(Fl(e[0])){var u=l;il(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(!Qr(n)&&fu(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&&!fu(i==null?void 0:i.$current_url)&&(Ki.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=Hp(),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=t20(e,o!=null&&o._noTruncate?null:this.config.properties_string_max_length)).timestamp=C,Qr(o==null?void 0:o.timestamp)||(e.properties.$event_time_override_provided=!0,e.properties.$event_time_override_system_time=r);var A=P4(P4({},e.properties.$set),e.$set);if(jB(A)||this.setPersonPropertiesForFlags(A),!el(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}Ki.critical("This capture call is ignored due to client rate limiting.")}}else Ki.error("No event name provided to posthog.capture")}else Ki.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=P4({},i);if(r.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(r.$cookieless_mode=!0),n==="$snapshot"){var C=P4(P4({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=C.distinct_id,(!fu(r.distinct_id)&&!tc(r.distinct_id)||fW(r.distinct_id))&&Ki.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var l,e=Ql.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&&du(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(w){r.$sdk_debug_error_capturing_properties=String(w)}if(this.requestRouter.region===um.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=du(r,l),n==="$pageview"&&Un&&(r.title=Un.title),!Qr(s)){var g=o.getTime()-s;r.$duration=parseFloat((g/1e3).toFixed(3))}cu&&this.config.opt_out_useragent_filter&&(r.$browser_type=this._is_bot()?"bot":"browser"),(r=du({},e,this.persistence.properties(),this.sessionPersistence.properties(),r)).$is_identified=this._isIdentified(),Fl(this.config.property_denylist)?il(this.config.property_denylist,function(w){delete r[w]}):Ki.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var h=this.config.sanitize_properties;h&&(Ki.error("sanitize_properties is deprecated. Use before_send instead"),r=h(r,n));var m=this._hasPersonProcessing();return r.$process_person_profile=m,m&&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=du({},o,a||{},n||{}),r=this.config.sanitize_properties;return r&&(Ki.error("sanitize_properties is deprecated. Use before_send instead"),s=r(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,jB(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 Ki.uninitializedWarning("posthog.identify");if(tc(n)&&(n=n.toString(),Ki.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()))Ki.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(WQ)&&(this.unregister(WQ),this.register({distinct_id:n}));var r=(this.persistence.get_property(Jh)||"anonymous")==="anonymous";n!==a&&r?(this.persistence.set_property(Jh,"identified"),this.setPersonPropertiesForFlags(P4(P4({},o||{}),i||{}),!1),this.capture("$identify",{distinct_id:n,$anon_distinct_id:a},{$set:i||{},$set_once:o||{}}),this.featureFlags.setAnonymousDistinctId(a),this._cachedIdentify=h_(n,i,o)):(i||o)&&(this._cachedIdentify!==h_(n,i,o)?(this.setPersonProperties(i,o),this._cachedIdentify=h_(n,i,o)):Ki.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),n!==a&&(this.reloadFeatureFlags(),this.unregister(SN))}}else Ki.error("Unique user id has not been set in posthog.identify")}setPersonProperties(n,i){(n||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(P4(P4({},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:P4(P4({},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 Ki.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(Ki.info("reset"),!this.__loaded)return Ki.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(Jh,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:EC2,$device_id:null},"");else{var C=this.config.get_device_id(Hp());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(nC2)?(Ki.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Qr(i)&&(i=this.get_distinct_id()),n!==i?(this._register_single(WQ,n),this.capture("$create_alias",{alias:n,distinct_id:i})):(Ki.warn("alias matches current distinct_id - skipping api call."),this.identify(n),-1)):void 0}set_config(n){var i,o,a,s,r=P4({},this.config);Ul(n)&&(du(this.config,Cu2(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 o_(P4(P4({},this.config),{},{persistence:"sessionStorage"})),Lu.is_supported()&&Lu.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(Kh.DEBUG=!0,Ki.info("set_config",JSON.stringify({config:n,oldConfig:r,newConfig:P4({},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(P4(P4({},F20((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:ty;return i!==ty&&(i=ty+"."+i),i}_isIdentified(){var n,i;return((n=this.persistence)===null||n===void 0?void 0:n.get_property(Jh))==="identified"||((i=this.sessionPersistence)===null||i===void 0?void 0:i.get_property(Jh))==="identified"}_hasPersonProcessing(){var n,i,o,a;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&jB(this.getGroups())&&((n=this.persistence)===null||n===void 0||(i=n.props)===null||i===void 0||!i[WQ])&&((o=this.persistence)===null||o===void 0||(a=o.props)===null||a===void 0||!a[NN]))}_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"?(Ki.error(n+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(NN,!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(),(Qr(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 af?iu2(af,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Un&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:Un.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(el(this.config.before_send))return n;var i=Fl(this.config.before_send)?this.config.before_send:[this.config.before_send],o=n;for(var a of i){if(o=a(o),el(o)){var s="Event '".concat(n.event,"' was rejected in beforeSend function");return q$2(n.event)?Ki.warn("".concat(s,". This can cause unexpected behavior.")):Ki.info(s),null}o.properties&&!jB(o.properties)||Ki.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]]=e20(t.prototype[n[i]])})(oV,["identify"]);var lu2,e10=(lu2=AM[ty]=new oV,function(){function t(){t.done||(t.done=!0,au2=!1,il(AM,function(n){n._dom_loaded()}))}Un!=null&&Un.addEventListener?Un.readyState==="complete"?t():$l(Un,"DOMContentLoaded",t,{capture:!1}):p4&&Ki.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),lu2);const t10=new k$2({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),uu2=({children:t,theme:n})=>{z0.useEffect(()=>{!n||!Object.keys(n).length||nB2(n)},[n]);const i=(o,a)=>{e10.capture("sth_went_wrong",{message:o.message,stack:o.stack,componentStack:a.componentStack})};return E.jsx(p$2,{FallbackComponent:Eb2,onError:i,children:E.jsx(j$2,{client:t10,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"},Au2=z0.createContext({isLoading:void 0,data:void 0,token:void 0,refetch:void 0}),aV=()=>z0.useContext(Au2),sV="https://api.usedatabrain.com",ju="/api/v2/dashboard",ny="/api/v2/metric",Fg="/api/v3/metric",r10="dashboardData",n10=`${ju}/embeddedMetric`,i10="embeddedMetric",o10=`${ny}/layout`,cu2="dashboardLayout",a10=`${ju}/scheduledReportV2`,s10="dashboardScheduledReportV2",C10=`${ny}/saveLayout`,l10="saveLayout",u10=`${ju}/saveScheduleReport`,A10="saveScheduleReport",c10=`${ju}/deleteScheduleReport`,f10="deleteScheduleReport",d10=`${ju}/createMetric`,g10="createMetric",h10=`${ju}/updateMetric`,E10="updateMetric",p10=`${ju}/updateAdminMetric`,v10="updateAdminMetric",I10=`${ju}/generateMetric`,m10="generateMetric",b10=`${ju}/datasetMetricCreation`,B10="datasetMetricCreation",y10=`${ju}/previewTable`,L10="previewTable",w10=`${ju}/generatetMetricData`,Q10="/generatetMetricData",M10=`${ju}/getOpenaiChatResponse`,T10="getOpenaiChatResponse",x10=`${ju}/getDashboardScreenshot`,R10=`${ju}/createDashboardFilterView`,H10="createDashboardFilterView",D10=`${ju}/getDashboardFilterView`,S10="getDashboardFilterView",N10=`${ju}/getTheme`,V10="getTheme",k10=`${Fg}/query`,O10="query",P10=`${Fg}/datasetMetricCreation`,Z10="newDatasetMetricCreation",F10=`${Fg}/generateDataReport`,U10="generateDataReport",j10=`${Fg}/chatQuery`,z10="chatQuery",G10=`${ny}/rawDownloadSettings`,Y10="rawDownloadSettings",W10=`${ny}/column`,_10="column",X10=`${ny}/underlyingData`,K10="underlyingData",J10=`${ny}/invokeShareCsv`,q10="invokeShareCsv",$10=`${Fg}/markArchived`,e30="markArchived",t30=`${Fg}/publishMetrics`,r30="publishMetrics",n30=`${Fg}/download-csv`,i30=`${Fg}/downloadDashboardMetrics`,o30="IS_LOADING",a30="DATA_LOADED",s30=`${Fg}/summarizeMetric`,C30="summarizeMetric",l30=`${Fg}/createGuestTokenUsageLog`,u30="createGuestTokenUsageLog",A30="ENTER_FULL_SCREEN_MODE",fu2="EXIT_FULL_SCREEN_MODE",c30="ENTER_SCHEDULED_REPORT_MODE",f30="SAVE_SCHEDULED_REPORT",du2="EXIT_SCHEDULED_REPORT_MODE",d30="ENTER_CUSTOMIZE_LAYOUT_MODE",gu2="EXIT_CUSTOMIZE_LAYOUT_MODE",hu2="SAVE_LAYOUT",g30="ENTER_MANAGE_METRICS_MODE",Eu2="EXIT_MANAGE_METRICS_MODE",h30="SAVE_MANAGE_METRICS",E30="ARCHIVE_METRIC",pu2="DOWNLOAD_METRIC",vu2="DOWNLOAD_METRIC_WITHOUT_FILTERS",p30="SAVE_METRIC_PNG",v30="METRIC_FILTER_APPLIED",I30="DASHBOARD_FILTER_APPLIED",m30="CREATE_METRIC",Iu2="UPDATE_METRIC",p_=()=>localStorage.getItem(eb2),CV=()=>{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}:null},kC=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":p_()||""}:{},...CV()||{}}};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)||sV}${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},b30=()=>Zl(l10,t=>kC(C10,{method:"POST",data:t})),B30=()=>Zl(A10,t=>kC(u10,{method:"POST",data:t.data,token:t.token})),mu2=()=>Zl(f10,t=>kC(c10,{method:"POST",data:t,token:t.token})),y30=()=>Zl(g10,({data:t,token:n})=>kC(d10,{method:"POST",data:t,token:n})),L30=()=>Zl(E10,({data:t,token:n})=>kC(h10,{method:"POST",data:t,token:n})),w30=()=>Zl(v10,({data:t,token:n})=>kC(p10,{method:"POST",data:t,token:n})),Q30=()=>Zl(m10,({data:t,token:n})=>kC(I10,{method:"POST",data:t,token:n})),bu2=()=>Zl(B10,({data:t,token:n})=>kC(b10,{method:"POST",data:t,token:n})),M30=()=>Zl(L10,({data:t,token:n})=>kC(y10,{method:"POST",data:t,token:n})),T30=()=>Zl(Q10,({data:t,token:n})=>kC(w10,{method:"POST",data:t,token:n})),x30=()=>Zl(T10,({data:t,token:n})=>kC(M10,{method:"POST",data:t,token:n})),R30=()=>Zl(H10,({data:t,token:n})=>kC(R10,{method:"POST",data:t,token:n})),v_=()=>Zl(_10,t=>kC(W10,{method:"POST",data:t})),H30=()=>Zl(K10,t=>kC(X10,{method:"POST",data:t})),D30=()=>Zl(q10,t=>kC(J10,{method:"POST",data:t})),S30=()=>Zl(e30,({data:t,token:n})=>kC($10,{method:"POST",data:t,token:n})),N30=()=>Zl(r30,({data:t,token:n})=>kC(t30,{method:"POST",data:t,token:n})),V30=()=>Zl(Z10,({data:t,token:n,clientId:i,isFrontendApp:o})=>kC(P10,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),Bu2=()=>Zl(U10,({data:t,token:n,clientId:i,isFrontendApp:o})=>kC(F10,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),k30=()=>Zl(z10,({data:t,token:n,clientId:i,isFrontendApp:o})=>kC(j10,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),O30=()=>Zl(C30,({data:t,isFrontendApp:n,clientId:i,token:o})=>kC(s30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),P30=()=>Zl(u30,({data:t,isFrontendApp:n,clientId:i,token:o})=>kC(l30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),I_=()=>{const{mutateAsync:t}=P30();return{saveLogsAsync:async i=>{t(i)}}},cM=({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:h,metric:m,datasetMetricSettings:w,drillDownSettings:Q,onServerEvent:R})=>{var J0,Y2,L3;const{token:N,data:O}=aV(),[X,K]=z0.useState(""),{mutate:f2,isLoading:A2}=y30(),{mutate:b2}=M30(),{saveLogsAsync:g2}=I_(),{register:j2,setValue:R2,watch:M2,handleSubmit:P2,control:G2,reset:C0}=sb(),m0=M1=>{K(""),C==null||C.chartType,L0.singleValue,f2({data:{companyId:e,companyIntegrationId:n,description:M1.description,inputFields:i,metricId:M1.metricId,name:M1.name,query:o,metricQuery:a,integrationName:s,outputColumns:r,createdBy:l||"external user",isLive:u||!1,chartOptions:C,datasetMetricSettings:w,clientId:l||null,isCreatedByClient:!!l,timeGrain:A||null,externalDashboardIds:f==null?void 0:f.map(B3=>({externalDashboardId:B3})),isEnableGroupBy:d,groupBy:g??{},selectedGroupBy:h,drillDownSettings:Q},token:N},{onSuccess:async B3=>{var j3,w7,l3;(j3=B3==null?void 0:B3.insert_externalMetrics_one)!=null&&j3.id?(await g2({clientId:l,data:{companyId:e,feature:"CREATE_METRIC",metricId:(w7=B3==null?void 0:B3.insert_externalMetrics_one)==null?void 0:w7.metricId},isFrontendApp:!1,token:N}),await(t==null?void 0:t((l3=B3==null?void 0:B3.insert_externalMetrics_one)==null?void 0:l3.id)),R==null||R(m30)):K("Metric Id already exists")},onError:()=>{K&&K("Metric Id already exists")}})},{mutateAsync:H0,isLoading:v0}=w30(),{mutateAsync:J2,isLoading:U0}=L30(),b0=z0.useCallback((M1,B3)=>{var w7,l3,c7;K("");let j3={};if(B3&&(j3={isDisableCardAppearance:M1.isDisableCardAppearance,titleAlignment:M1.titleAlignment,descAlignment:M1.descAlignment,...M1.text?{textBox:{text:M1.text,fontWeight:M1.fontWeight||"400",fontColor:M1.fontColor||"",fontSize:M1.fontSize||"14px",alignment:M1.textAlignment||"left",link:M1.textLink,isOpenInNewTab:M1.isOpenInNewTab,targetWord:M1.targetWord}}:null}),!(m!=null&&m.isCreatedByClient))H0({data:{externalMetricId:m==null?void 0:m.id,clientId:l,object:{clientId:l,companyId:e,companyIntegrationId:n||(m==null?void 0:m.companyIntegrationId),description:M1.description,inputFields:i,metricId:M1.metricId===(m==null?void 0:m.metricId)?`update_${M1.metricId}_by_${l}_${Date.now()}`:M1.metricId,name:B3?(w7=M1==null?void 0:M1.elementTitle)==null?void 0:w7.trim():(l3=M1==null?void 0:M1.name)==null?void 0:l3.trim(),query:o,metricQuery:a,datasetMetricSettings:w,integrationName:s,outputColumns:r,createdBy:l||"external user",isCreatedByClient:!!l,isLive:u||M1.isLive,chartOptions:C,drillDownSettings:Q,elementSettings:j3,isMetric:!B3,...B3?{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(T3=>({externalDashboardId:T3}))}}},token:N},{onSuccess:async T3=>{var y6;!(T3!=null&&T3.insert_clientDeletedMetrics_one)||!(T3!=null&&T3.insert_externalMetrics_one)||(K(""),await g2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(y6=T3==null?void 0:T3.insert_externalMetrics_one)==null?void 0:y6.metricId},isFrontendApp:!1,token:N}),await(t==null?void 0:t()),R==null||R(Iu2))},onError:()=>{K("Something went wrong! Please try again later.")}});else{const T3={chartOptions:C,datasetMetricSettings:w,description:M1.description,query:o,metricQuery:a,drillDownSettings:Q,elementSettings:j3,isMetric:!B3,...B3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}}};M1.description&&(T3.description=M1.description),M1.metricId&&(T3.metricId=M1.metricId),M1.name&&!B3&&(T3.name=M1.name),M1.elementTitle&&B3&&(T3.name=M1==null?void 0:M1.elementTitle),(c7=Object.keys(j3))!=null&&c7.length&&(T3.elementSettings=j3),J2({data:{externalMetricId:m==null?void 0:m.id,set:T3},token:N},{onSuccess:async y6=>{var t6,C6;(t6=y6==null?void 0:y6.update_externalMetrics_by_pk)!=null&&t6.id&&(K(""),await g2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(C6=y6==null?void 0:y6.update_externalMetrics_by_pk)==null?void 0:C6.metricId},isFrontendApp:!1,token:N}),await(t==null?void 0:t()),R==null||R(Iu2))},onError:()=>{K("Something went wrong! Please try again later.")}})}},[C,m,J2,H0,l,e,n,s,u,f,o,i,r,a,w]),k0=z0.useCallback(M1=>{K("");const B3={isPublished:!(M1!=null&&M1.isPublished)};J2({data:{externalMetricId:M1==null?void 0:M1.id,set:B3},token:N},{onSuccess:async j3=>{var w7,l3;(w7=j3==null?void 0:j3.update_externalMetrics_by_pk)!=null&&w7.id&&(K(""),await g2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(l3=j3==null?void 0:j3.update_externalMetrics_by_pk)==null?void 0:l3.metricId},isFrontendApp:!1,token:N}),t==null||t())},onError:()=>{K("Something went wrong! Please try again later.")}})},[m]);return{createExternalMetric:m0,updateExternalMetric:b0,error:X,isLoading:A2||v0||U0,clientSubsetData:O==null?void 0:O.clientSubsetData,previewTable:b2,token:N,workspaceId:(J0=O==null?void 0:O.workspace)==null?void 0:J0.id,dashboardOptions:[{value:(Y2=O==null?void 0:O.externalDashboard)==null?void 0:Y2.id,label:((L3=O==null?void 0:O.externalDashboard)==null?void 0:L3.name)||"Dashboard"}],isDatabaseTenancy:(O==null?void 0:O.companyTenancyType)===sL,register:j2,setValue:R2,watch:M2,handleSubmit:P2,control:G2,reset:C0,onPublishMetric:k0}},yu2=()=>{const{mutate:t,isLoading:n,error:i}=Q30(),{mutate:o,mutateAsync:a}=v_();return{generateDatasetMetric:t,isGeneratingDataset:n,generateError:i,fetchColumnValues:o,fetchColumnValuesAsync:a}};let Z30=0;function F30(t,n){const i=`atom${++Z30}`,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 qf={},Vp=Symbol(),m_=t=>!!t[Vp],lV=t=>!t[Vp].c,fM=t=>{var n;const{b:i,c:o}=t[Vp];o&&(o(),(n=j30.get(i))==null||n())},uV=(t,n)=>{const i=t[Vp].o,o=n[Vp].o;return i===o||t===o||m_(i)&&uV(i,n)},b_=(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[Vp]=i,o},U30=t=>b_(t[Vp].b,t[Vp].o),j30=new WeakMap,B_=t=>"init"in t,y_="r",L_="w",AV="c",w_="s",Lu2="h",z30="n",G30="l",Y30="a",W30="m",_30=t=>{const n=new WeakMap,i=new WeakMap,o=new Map;let a,s;(qf&&"production")!=="production"&&(a=new Set,s=new Set);const r=new WeakMap,C=(v0,J2,U0)=>{let b0=r.get(J2);b0||(b0=new Map,r.set(J2,b0)),U0.then(()=>{b0.get(v0)===U0&&(b0.delete(v0),b0.size||r.delete(J2))}),b0.set(v0,U0)},l=v0=>{const J2=new Set,U0=r.get(v0);return U0&&(r.delete(v0),U0.forEach((b0,k0)=>{fM(b0),J2.add(k0)})),J2},e=new WeakMap,u=v0=>{let J2=e.get(v0);return J2||(J2=new Map,e.set(v0,J2)),J2},A=(v0,J2)=>{if(v0){const U0=u(v0);let b0=U0.get(J2);return b0||(b0=A(v0.p,J2),b0&&"p"in b0&&lV(b0.p)&&(b0=void 0),b0&&U0.set(J2,b0)),b0}return n.get(J2)},f=(v0,J2,U0)=>{if((qf&&"production")!=="production"&&Object.freeze(U0),v0)u(v0).set(J2,U0);else{const b0=n.get(J2);n.set(J2,U0),o.has(J2)||o.set(J2,b0)}},d=(v0,J2=new Map,U0)=>{if(!U0)return J2;const b0=new Map;let k0=!1;return U0.forEach(J0=>{var Y2;const L3=((Y2=A(v0,J0))==null?void 0:Y2.r)||0;b0.set(J0,L3),J2.get(J0)!==L3&&(k0=!0)}),J2.size===b0.size&&!k0?J2:b0},g=(v0,J2,U0,b0,k0)=>{const J0=A(v0,J2);if(J0){if(k0&&(!("p"in J0)||!uV(J0.p,k0)))return J0;"p"in J0&&fM(J0.p)}const Y2={v:U0,r:(J0==null?void 0:J0.r)||0,y:!0,d:d(v0,J0==null?void 0:J0.d,b0)};let L3=!(J0!=null&&J0.y);return!J0||!("v"in J0)||!Object.is(J0.v,U0)?(L3=!0,++Y2.r,Y2.d.has(J2)&&(Y2.d=new Map(Y2.d).set(J2,Y2.r))):Y2.d!==J0.d&&(Y2.d.size!==J0.d.size||!Array.from(Y2.d.keys()).every(M1=>J0.d.has(M1)))&&(L3=!0,Promise.resolve().then(()=>{P2(v0)})),J0&&!L3?J0:(f(v0,J2,Y2),Y2)},h=(v0,J2,U0,b0,k0)=>{const J0=A(v0,J2);if(J0){if(k0&&(!("p"in J0)||!uV(J0.p,k0)))return J0;"p"in J0&&fM(J0.p)}const Y2={e:U0,r:((J0==null?void 0:J0.r)||0)+1,y:!0,d:d(v0,J0==null?void 0:J0.d,b0)};return f(v0,J2,Y2),Y2},m=(v0,J2,U0,b0)=>{const k0=A(v0,J2);if(k0&&"p"in k0){if(uV(k0.p,U0)&&!lV(k0.p))return k0.y?k0:{...k0,y:!0};fM(k0.p)}C(v0,J2,U0);const J0={p:U0,r:((k0==null?void 0:k0.r)||0)+1,y:!0,d:d(v0,k0==null?void 0:k0.d,b0)};return f(v0,J2,J0),J0},w=(v0,J2,U0,b0)=>{if(U0 instanceof Promise){const k0=b_(U0,U0.then(J0=>{g(v0,J2,J0,b0,k0)}).catch(J0=>{if(J0 instanceof Promise)return m_(J0)?J0.then(()=>{R(v0,J2,!0)}):J0;h(v0,J2,J0,b0,k0)}));return m(v0,J2,k0,b0)}return g(v0,J2,U0,b0)},Q=(v0,J2)=>{const U0=A(v0,J2);if(U0){const b0={...U0,y:!1};f(v0,J2,b0)}else(qf&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",J2)},R=(v0,J2,U0)=>{if(!U0){const k0=A(v0,J2);if(k0){if(k0.y&&"p"in k0&&!lV(k0.p))return k0;if(k0.d.forEach((J0,Y2)=>{if(Y2!==J2)if(!i.has(Y2))R(v0,Y2);else{const L3=A(v0,Y2);L3&&!L3.y&&R(v0,Y2)}}),Array.from(k0.d).every(([J0,Y2])=>{const L3=A(v0,J0);return L3&&!("p"in L3)&&L3.r===Y2}))return k0.y?k0:{...k0,y:!0}}}const b0=new Set;try{const k0=J2.read(J0=>{b0.add(J0);const Y2=J0===J2?A(v0,J0):R(v0,J0);if(Y2){if("e"in Y2)throw Y2.e;if("p"in Y2)throw Y2.p;return Y2.v}if(B_(J0))return J0.init;throw new Error("no atom init")});return w(v0,J2,k0,b0)}catch(k0){if(k0 instanceof Promise){const J0=m_(k0)&&lV(k0)?U30(k0):b_(k0,k0);return m(v0,J2,J0,b0)}return h(v0,J2,k0,b0)}},N=(v0,J2)=>R(J2,v0),O=(v0,J2)=>{let U0=i.get(J2);return U0||(U0=j2(v0,J2)),U0},X=(v0,J2)=>!J2.l.size&&(!J2.t.size||J2.t.size===1&&J2.t.has(v0)),K=(v0,J2)=>{const U0=i.get(J2);U0&&X(J2,U0)&&R2(v0,J2)},f2=(v0,J2)=>{const U0=i.get(J2);U0==null||U0.t.forEach(b0=>{b0!==J2&&(Q(v0,b0),f2(v0,b0))})},A2=(v0,J2,U0)=>{let b0=!0;const k0=(L3,M1)=>{const B3=R(v0,L3);if("e"in B3)throw B3.e;if("p"in B3){if(M1!=null&&M1.unstable_promise)return B3.p.then(()=>{const j3=A(v0,L3);return j3&&"p"in j3&&j3.p===B3.p?new Promise(w7=>setTimeout(w7)).then(()=>k0(L3,M1)):k0(L3,M1)});throw(qf&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",L3),B3.p}if("v"in B3)return B3.v;throw(qf&&"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")},J0=(L3,M1)=>{let B3;if(L3===J2){if(!B_(L3))throw new Error("atom not writable");l(L3).forEach(c7=>{c7!==v0&&w(c7,L3,M1)});const w7=A(v0,L3),l3=w(v0,L3,M1);w7!==l3&&f2(v0,L3)}else B3=A2(v0,L3,M1);return b0||P2(v0),B3},Y2=J2.write(k0,J0,U0);return b0=!1,Y2},b2=(v0,J2,U0)=>{const b0=A2(U0,v0,J2);return P2(U0),b0},g2=v0=>!!v0.write,j2=(v0,J2,U0)=>{const b0={t:new Set(U0&&[U0]),l:new Set};if(i.set(J2,b0),(qf&&"production")!=="production"&&s.add(J2),R(void 0,J2).d.forEach((J0,Y2)=>{const L3=i.get(Y2);L3?L3.t.add(J2):Y2!==J2&&j2(v0,Y2,J2)}),g2(J2)&&J2.onMount){const J0=L3=>b2(J2,L3,v0),Y2=J2.onMount(J0);v0=void 0,Y2&&(b0.u=Y2)}return b0},R2=(v0,J2)=>{var U0;const b0=(U0=i.get(J2))==null?void 0:U0.u;b0&&b0(),i.delete(J2),(qf&&"production")!=="production"&&s.delete(J2);const k0=A(v0,J2);k0?("p"in k0&&fM(k0.p),k0.d.forEach((J0,Y2)=>{if(Y2!==J2){const L3=i.get(Y2);L3&&(L3.t.delete(J2),X(Y2,L3)&&R2(v0,Y2))}})):(qf&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",J2)},M2=(v0,J2,U0,b0)=>{const k0=new Set(U0.d.keys());b0==null||b0.forEach((J0,Y2)=>{if(k0.has(Y2)){k0.delete(Y2);return}const L3=i.get(Y2);L3&&(L3.t.delete(J2),X(Y2,L3)&&R2(v0,Y2))}),k0.forEach(J0=>{const Y2=i.get(J0);Y2?Y2.t.add(J2):i.has(J2)&&j2(v0,J0,J2)})},P2=v0=>{if(v0){u(v0).forEach((U0,b0)=>{const k0=n.get(b0);if(U0!==k0){const J0=i.get(b0);J0==null||J0.l.forEach(Y2=>Y2(v0))}});return}for(;o.size;){const J2=Array.from(o);o.clear(),J2.forEach(([U0,b0])=>{const k0=A(void 0,U0);if(k0&&k0.d!==(b0==null?void 0:b0.d)&&M2(void 0,U0,k0,b0==null?void 0:b0.d),b0&&!b0.y&&(k0!=null&&k0.y))return;const J0=i.get(U0);J0==null||J0.l.forEach(Y2=>Y2())})}(qf&&"production")!=="production"&&a.forEach(J2=>J2())},G2=v0=>{u(v0).forEach((U0,b0)=>{const k0=n.get(b0);(!k0||U0.r>k0.r||U0.y!==k0.y||U0.r===k0.r&&U0.d!==k0.d)&&(n.set(b0,U0),U0.d!==(k0==null?void 0:k0.d)&&M2(v0,b0,U0,k0==null?void 0:k0.d))})},C0=(v0,J2)=>{J2&&G2(J2),P2(void 0)},m0=(v0,J2,U0)=>{const k0=O(U0,v0).l;return k0.add(J2),()=>{k0.delete(J2),K(U0,v0)}},H0=(v0,J2)=>{for(const[U0,b0]of v0)B_(U0)&&(w(J2,U0,b0),f2(J2,U0));P2(J2)};return(qf&&"production")!=="production"?{[y_]:N,[L_]:b2,[AV]:C0,[w_]:m0,[Lu2]:H0,[z30]:v0=>(a.add(v0),()=>{a.delete(v0)}),[G30]:()=>s.values(),[Y30]:v0=>n.get(v0),[W30]:v0=>i.get(v0)}:{[y_]:N,[L_]:b2,[AV]:C0,[w_]:m0,[Lu2]:H0}},X30=(t,n)=>({s:n?n(t).SECRET_INTERNAL_store:_30()}),Q_=new Map,wu2=t=>(Q_.has(t)||Q_.set(t,z0.createContext(X30())),Q_.get(t));function Qu2(t,n){return F30(t)}function K30(t,n){const i=wu2(n),o=z0.useContext(i),{s:a,v:s}=o,r=f=>{const d=a[y_](t,f);if((qf&&"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]=z0.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)),z0.useEffect(()=>{const{v:f}=o;f&&a[AV](t,f);const d=a[w_](t,u,f);return u(f),d},[a,t,o]),z0.useEffect(()=>{a[AV](t,C)}),z0.useDebugValue(A),A}function J30(t,n){const i=wu2(n),{s:o,w:a}=z0.useContext(i);return z0.useCallback(r=>{if((qf&&"production")!=="production"&&!("write"in t))throw new Error("not writable atom");const C=l=>o[L_](t,r,l);return a?a(C):C()},[o,a,t])}function M_(t,n){return"scope"in t&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),n=t.scope),[K30(t,n),J30(t,n)]}const cV=({onOutsideClick:t,wrapRef:n,portalRef:i})=>{z0.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])},q30=({wrapRef:t,portalRef:n,autoCloseParent:i=!1})=>{const[o]=M_(LA2);z0.useEffect(()=>{const a=s=>{o==null||o.forEach(r=>{var l,e,u,A,f,d,g,h;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 m=o.find(w=>{var R,N;const Q=((R=r.popperElement)==null?void 0:R.contains(w.referenceElement))&&(w.isOpen===!0||w.isMenuOpen===!0);return i?Q&&((N=w.popperElement)==null?void 0:N.contains("composedPath"in s?s.composedPath()[0]:s.target)):Q});m?((u=m==null?void 0:m.setOpen)==null||u.call(m,!0),(A=m==null?void 0:m.setMenuOpen)==null||A.call(m,!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),(h=r.setMenuOpen)==null||h.call(r,!0))})};return document.addEventListener("click",a,!0),()=>{document.removeEventListener("click",a,!0)}},[t,n,o])},$30=({token:t,dashboardId:n,configId:i,isEn:o})=>{var a;return Qp([r10,{dashboardId:n,configId:i,token:t,isEn:o}],()=>{const s=n?`${ju}?dashboardId=${n}${i?`&configId=${i}`:""}${`&isEn=${o}`}`:ju;return kC(s,{method:"GET",token:t})},{enabled:!!t||!!((a=window==null?void 0:window.dbn)!=null&&a.isEnableProxyAuth)})},e70=(t,n)=>Qp([cu2,{dashboardId:t,clientId:n}],()=>kC(`${o10}?id=${t}&clientId=${n}`,{method:"GET"}),{enabled:!!t&&!!n}),t70=(t,n,i)=>Qp(s10,()=>kC(`${a10}?externalDashboardId=${n}${i?`&embedId=${i}`:""}`,{method:"GET",token:t}),{enabled:!!t&&!!n}),r70=(t,n)=>{var i;return Qp([i10,{id:n}],()=>kC(`${n10}?metricId=${n}`,{method:"GET",token:t}),{enabled:!!t||!!((i=window==null?void 0:window.dbn)!=null&&i.isEnableProxyAuth)})},Mu2=({token:t,name:n,companyId:i})=>Qp([V10,{name:n}],()=>kC(N10,{method:"POST",token:t,data:{name:n,companyId:i}}),{enabled:!!(n&&t&&i)}),n70=({token:t,dashboardId:n})=>Qp([S10,{dashboardId:n}],()=>kC(D10,{method:"POST",token:t,data:{dashboardId:n}}),{enabled:!!(t&&n)}),i70=({externalDashboardId:t,clientId:n})=>{const i=CW(),{data:o,isLoading:a}=e70(t,n),[s,r,C,l]=z0.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}=b30();return{saveLayout:z0.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([cu2,{dashboardId:t,clientId:n}],h=>({...h,...g}))}})},[e,n,t]),layout:s,dashboardFiltersLayout:r,gridMargin:l,isLayoutLocked:C,isLoadingLayout:a||u}},o70=({query:t,limit:n,offset:i,dbName:o})=>{const a=If===(o==null?void 0:o.toLowerCase()),s=ku===(o==null?void 0:o.toLowerCase()),r=hA===(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())==ku||(o==null?void 0:o.toLowerCase())==If||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},a70=({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:h}=H30();return{getUnderlyingData:({columnName:w,value:Q,setData:R,setLoading:N,isSingleValueChart:O,clientColumnType:X})=>{const K=o==="MULTI_DATABASE"&&n||"",f2=g&&d?d:o70({query:s,limit:"5000",dbName:i}),A2=lb({clientColumnType:X,query:f2||"",dbName:i,rlsConditions:A,tenancyLevel:o||"TABLE",clientId:n,globalFilters:e,values:a,isAllClient:u,dataMartRelationships:f});R([]),N(!0),h({columnName:O?void 0:w,companyId:r,query:of(A2,r),value:O?void 0:Q.toString().replace(/'/g,"''"),workspaceId:C,metricId:l,isCustomSql:g&&!!d,databaseName:K,datasourceId:t},{onSuccess(b2){const g2=b2==null?void 0:b2.data;g2&&Array.isArray(g2)&&g2.length?(R(g2),N(!1)):(R([]),N(!1))},onError(){R([]),N(!1)}})}}},s70=({clientId:t,data:n,token:i,isFrontendApp:o,isFullScreen:a=""},s)=>Qp([O10,n,t,o,i,a],()=>{var r,C,l;return kC(k10,{method:"POST",data:{...n||{},...!o&&i?{...(r=n==null?void 0:n.rlsConditions)!=null&&r.length?{rlsConditions:FB(n==null?void 0:n.rlsConditions,i)}:{},...(l=(C=n==null?void 0:n.globalFilters)==null?void 0:C.filters)!=null&&l.length?{globalFilters:FB(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}),C70=t=>Qp([Y10,t],()=>kC(`${G10}?id=${t}`,{method:"GET"}),{enabled:!!t}),fV={timeSeriesSettingsContainer:"_timeSeriesSettingsContainer_3qyzb_1",timeSeriesSettingsType:"_timeSeriesSettingsType_3qyzb_9",featToggle:"_featToggle_3qyzb_17",dynamicFormat:"_dynamicFormat_3qyzb_33"},l70=[{value:"line",label:"line"},{value:"bar",label:"bar"},{value:"area",label:"area"},{value:"stack",label:"stack"},{value:"combo",label:"combo"}],cC=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"},{value:"Quarterly",label:"Quarterly"},{value:"Yearly",label:"Yearly"}],u70=({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 h=`${n.options[d].split("____")[0]}____${g}`,m=`${n.options[d].split("____")[0]}`;t(w=>{var Q,R,N,O;return{...w,groupBySettings:{...w.groupBySettings,options:(Q=w.groupBySettings.options)==null?void 0:Q.map((X,K)=>K===d?h:X),value:((R=w.groupBySettings.options)==null?void 0:R.find((X,K)=>K===d))===((N=w==null?void 0:w.groupBySettings)==null?void 0:N.value)?m:(O=w==null?void 0:w.groupBySettings)==null?void 0:O.value}}})}else{const h=`${n.options[d]}____${g}`,m=`${n.options[d]}`;t(w=>{var Q,R,N,O;return{...w,groupBySettings:{...w.groupBySettings,options:(Q=w.groupBySettings.options)==null?void 0:Q.map((X,K)=>K===d?h:X),value:((R=w.groupBySettings.options)==null?void 0:R.find((X,K)=>K===d))===((N=w==null?void 0:w.groupBySettings)==null?void 0:N.value)?m:(O=w==null?void 0:w.groupBySettings)==null?void 0:O.value}}})}};return E.jsxs("div",{className:fV.timeSeriesSettingsContainer,children:[E.jsx(q7,{variant:"heading-5",children:"Time Series Settings"}),E.jsx(oe,{label:"Series Type",options:l70,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(h=>({column:h,type:d.value}))}))},menuWidth:"100%",buttonWidth:"100%"}),E.jsx(q7,{variant:"body-text-2",children:"Group format"}),E.jsxs("div",{className:fV.timeSeriesSettingsType,children:[E.jsx(uf,{"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:cC==null?void 0:cC.map(h=>h.value),isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[2]))},name:"isDynamic",label:"Default",defaultChecked:!n.isDynamic&&!n.isGlobalFilter,checked:!n.isDynamic&&!n.isGlobalFilter}),E.jsx(uf,{"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:cC==null?void 0:cC.map(h=>h.value),fillXAxis:!1,isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[2]))}}),E.jsx(uf,{"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:cC==null?void 0:cC.map(h=>h.value),fillXAxis:!1,isGlobalFilter:!0,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[0]))}})]}),n.isDynamic?E.jsxs("div",{className:fV.dynamicFormat,children:[E.jsx(_a,{buttonWidth:"100%",menuWidth:"100%",options:cC,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(h=>h.value))||["monthly"],fillXAxis:[Wc.daily,Wc.weekly,Wc.yearly].includes(Array.isArray(d)&&d.length?d[0].value:"monthly")?!1:g.groupBySettings.fillXAxis}})),a==null||a((d==null?void 0:d[0])||(cC==null?void 0:cC[2]))},isShowSelectedOptions:!0}),(f=n.options)==null?void 0:f.map((d,g)=>E.jsx(g5,{label:d.split("____").length>1?d.split("____")[0]:d,type:"text",value:d.split("____").length>1?d.split("____")[1]:d,placeholder:"Save as",onChange:h=>{r(g,h.target.value)}}))]}):E.jsxs(E.Fragment,{children:[(n==null?void 0:n.isGlobalFilter)&&E.jsxs(E.Fragment,{children:[E.jsx(oe,{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)&&E.jsx(js,{direction:"col",className:"dbn-gap-3",children:cC==null?void 0:cC.map(d=>{var g,h,m,w,Q,R,N;return E.jsxs(js,{className:"dbn-w-full dbn-gap-2",alignItems:"center",justify:"between",children:[E.jsx(lf,{checked:!!((g=n==null?void 0:n.formatWithValue)!=null&&g.find(O=>O.format===d.value&&O.isEnable)),onChange:({target:{checked:O}})=>{t(X=>{var K,f2,A2,b2,g2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(K=X==null?void 0:X.groupBySettings)==null?void 0:K.formatWithValue)==null?void 0:f2.filter(j2=>j2.format!==d.value))||[],{format:d.value,isEnable:O,value:((g2=(b2=(A2=X==null?void 0:X.groupBySettings)==null?void 0:A2.formatWithValue)==null?void 0:b2.find(j2=>j2.format===d.value))==null?void 0:g2.value)||""}]}}})},label:d.value}),E.jsx("div",{className:"dbn-w-full",children:E.jsx(oe,{placeholder:"Select a Filter Value",menuWidth:"100%",buttonWidth:"100%",options:((h=n==null?void 0:n.globalFilterOption)==null?void 0:h.presetDateOptions)||[],selectedOption:{value:((w=(m=n==null?void 0:n.formatWithValue)==null?void 0:m.find(O=>O.format===d.value))==null?void 0:w.value)||"",label:((R=(Q=n==null?void 0:n.formatWithValue)==null?void 0:Q.find(O=>O.format===d.value))==null?void 0:R.value)||""},isDisabled:!((N=n==null?void 0:n.formatWithValue)!=null&&N.find(O=>O.format===d.value&&O.isEnable)),onChange:O=>{t(X=>{var K,f2,A2,b2,g2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(K=X==null?void 0:X.groupBySettings)==null?void 0:K.formatWithValue)==null?void 0:f2.filter(j2=>j2.format!==d.value))||[],{format:d.value,isEnable:!!((g2=(b2=(A2=X==null?void 0:X.groupBySettings)==null?void 0:A2.formatWithValue)==null?void 0:b2.find(j2=>j2.format===d.value))!=null&&g2.isEnable),value:(O==null?void 0:O.value)||""}]}}})}})})]})})})]}),E.jsx(oe,{label:"Format Type",menuWidth:"100%",buttonWidth:"100%",options:cC,selectedOption:(cC==null?void 0:cC.find(d=>{var g,h;return((g=d.value)==null?void 0:g.toLowerCase())===((h=n==null?void 0:n.value)==null?void 0:h.toLowerCase())}))||(cC==null?void 0:cC[2]),onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:d.value}})),a==null||a(d)}}),[Wc.month,Wc.quarter].includes(n.value.toLowerCase())&&E.jsxs("div",{className:fV.featToggle,children:[E.jsx(a4,{name:"fill axis",enabled:n.fillXAxis,onChange:()=>t(d=>({...d,groupBySettings:{...d.groupBySettings,fillXAxis:!d.groupBySettings.fillXAxis}}))}),E.jsxs("span",{className:"dbn-flex dbn-gap-2 dbn-items-center",children:[E.jsx(q7,{variant:"body-text-2",children:"Fill X-axis"}),E.jsx(sf,{position:"top",iconConfig:{size:"xs",color:"primary"},text:"Enable to fill missing months or dates.",tooltipClass:"dbn-w-[300px]"})]})]})]})]})},nc=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)})},Nc=t=>{const n=new Date(t);return n instanceof Date&&!Number.isNaN(n.getTime())?n:null},T_=({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:h,setMetricStore:m,onServerEvent:w,clientColumnType:Q,datasourceId:R,appliedCardMetricFilters:N,language:O,translationDictionary:X,calendarType:K,setLoadedCardMetadata:f2,isFullScreen:A2,setMetricMetadata:b2,viewMetricData:g2,generatingPdf:j2,dataMartTables:R2})=>{var N4,r5,i4,D4,b4,z4,Ce,N9,K5,s4,le,B4,O4,i1,C3,W3,x3,_7,s3,t7,B6,U6,e9,r7,F7,s8,Y7,G1,E7,h6,H6,j6,n9,y8,q8,C9,V9,N5,l4,j5,u4,y4,re,_e,bt,Cr,Bt,jn,qn,Vi,Ji,qi,ki,$i,go,yo,fn,Zr,Xe,Ln,wn,$n,Ci,wi,pr;const[M2,P2]=z0.useState(!1),[G2,C0]=z0.useState(!0),m0=O30(),[H0,v0]=z0.useState(""),[J2,U0]=z0.useState(""),[b0,k0]=z0.useState(!1),J0=z0.useRef(null),[Y2,L3]=z0.useState({limit:10,offset:0}),[M1,B3]=z0.useState(0),[j3,w7]=z0.useState(0),[l3,c7]=z0.useState((t==null?void 0:t.rlsConditions)||[]),[T3,y6]=z0.useState([]),[t6,C6]=z0.useState(!1),[n3,t0]=z0.useState(),[V3,Z7]=z0.useState([]),[e6,l7]=z0.useState(""),[A6,w6]=z0.useState([]),[v1,h3]=z0.useState({isOpen:!1,report:"",isLoading:!1}),[o7,m7]=z0.useState(!1),[G3,J3]=z0.useState([]),[k7,W7]=z0.useState([]),[J7,e8]=z0.useState({isEnableGroupBy:!1,isEnableCrossFilter:!1,drillType:""}),[z7,x6]=z0.useState([]),[c8,h9]=z0.useState(!1),[U8,$9]=z0.useState(!1),[o9,M9]=z0.useState([]),[j8,y5]=z0.useState({}),[H5,_5]=z0.useState(!1),[T5,S8]=z0.useState(null),[W1,W9]=z0.useState(t==null?void 0:t.chartOptions),[I6,l8]=z0.useState({data:[],error:"",isLoading:!1,currentValue:""}),h8=z0.useMemo(()=>{var i8,r8;return!!((r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)!=null&&r8.isPythonMode)},[(r5=(N4=t==null?void 0:t.datasetMetricSettings)==null?void 0:N4.newDatasetSettings)==null?void 0:r5.isPythonMode]),Y6=z0.useMemo(()=>{var i8,r8,s9,B8,L9;return((L9=(B8=(s9=(r8=(i8=t==null?void 0:t.externalDashboardMetrics)==null?void 0:i8[0])==null?void 0:r8.externalDashboard)==null?void 0:s9.companyWorkspace)==null?void 0:B8.datamart)==null?void 0:L9.datamartRelationships)||[]},[t]),Q8=z0.useMemo(()=>{const i8={};if(i!=null&&i.values)for(const r8 in i.values){const s9=`${r8}_variable`;i8[s9]=i.values[r8]}return i8},[i==null?void 0:i.values]),x1=z0.useMemo(()=>{var s9,B8,L9;const i8=(B8=(s9=t==null?void 0:t.datasetMetricSettings)==null?void 0:s9.newDatasetSettings)==null?void 0:B8.selectedMainTable,r8=R2==null?void 0:R2.find(N8=>N8.tableName===(i8==null?void 0:i8.tableName));return((L9=r8==null?void 0:r8.customColumnFields)==null?void 0:L9.map(N8=>{var e5,B5,O5,f8,I9,l9;return{value:N8==null?void 0:N8.columnName,label:N8==null?void 0:N8.columnName,isCustomField:!0,column:{uniqueId:PB(10),alias:N8==null?void 0:N8.columnName,configType:"DIMENSION",datatype:N8==null?void 0:N8.datatype,dropType:"DIMENSION",index:1e3,name:N8==null?void 0:N8.columnName,parentAlias:`${TS(i8==null?void 0:i8.schemaName,((e5=t==null?void 0:t.companyIntegration)==null?void 0:e5.name)||"")}_${(B5=i8==null?void 0:i8.tableName)==null?void 0:B5.replaceAll(" ","_")}`,table:(f8=(O5=t==null?void 0:t.datasetMetricSettings)==null?void 0:O5.newDatasetSettings)==null?void 0:f8.selectedMainTable,type:"DEFAULT",draggableItemData:{column:{name:N8==null?void 0:N8.columnName,dataType:N8==null?void 0:N8.datatype,as:N8==null?void 0:N8.datatype},table:(l9=(I9=t==null?void 0:t.datasetMetricSettings)==null?void 0:I9.newDatasetSettings)==null?void 0:l9.selectedMainTable},label:"",sql:""}}}))||[]},[(D4=(i4=t==null?void 0:t.datasetMetricSettings)==null?void 0:i4.newDatasetSettings)==null?void 0:D4.selectedMainTable,(b4=t==null?void 0:t.companyIntegration)==null?void 0:b4.name,R2]),L7=z0.useMemo(()=>{var i8,r8,s9,B8,L9,N8,e5,B5,O5,f8,I9,l9,O9,m4;return{isAllClient:u,id:t==null?void 0:t.id,tenancyLevel:a,rlsConditions:[...o9||[],...(i8=W1==null?void 0:W1.tableSettings)!=null&&i8.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?(r8=T3==null?void 0:T3.map($5=>$5.condition))==null?void 0:r8.filter($5=>Px($5)):[]],globalFilters:h8?void 0:{...n,filters:(s9=n==null?void 0:n.filters)==null?void 0:s9.filter($5=>{var Ke;return Array.isArray($5==null?void 0:$5.value)?(Ke=$5==null?void 0:$5.value)==null?void 0:Ke.length:$5})},filterValues:h8?void 0:Q8,limit:(B8=W1==null?void 0:W1.tableSettings)!=null&&B8.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?Math.min(Y2.limit,1e3):void 0,offset:(L9=W1==null?void 0:W1.tableSettings)!=null&&L9.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?Y2.offset:void 0,disableStringify:!0,pivotHeaders:((N8=W1==null?void 0:W1.pivotTableSettings2)==null?void 0:N8.headers)||[],timeseriesSettings:h8?void 0:{format:((O5=(B5=(e5=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:e5.groupBySettings)==null?void 0:B5.value)==null?void 0:O5.toLowerCase())||"monthly",seriesField:(W1==null?void 0:W1.seriesField)||"",isFiscal:K==="ind"},chartSeriesField:(W1==null?void 0:W1.seriesField)!=="ungrouped"&&(W1!=null&&W1.seriesField)&&(W1!=null&&W1.isDynamicSeries)?W1==null?void 0:W1.seriesField:void 0,comparisonCount:j3,dynamicXAxis:{isEnable:!!((f8=W1==null?void 0:W1.dynamicXAxis)!=null&&f8.isEnabled||(I9=W1==null?void 0:W1.enduserMeasureAndDimensions)!=null&&I9.isEnabled)&&Ih.includes((W1==null?void 0:W1.chartType)||""),xaxis:(W1==null?void 0:W1.xAxis)||"",customField:(O9=(l9=W1==null?void 0:W1.dynamicXAxis)==null?void 0:l9.selectedOption)==null?void 0:O9.column},dbId:R,elementSettings:(m4=t==null?void 0:t.elementSettings)==null?void 0:m4.metricExpression,drillConfig:J7==null?void 0:J7.configV2,isEncrypted:!!(!A&&f)}},[W1,u,t,o9,h8,Q8,k7,a,n,Y2,j3,Ih,R,K,J7==null?void 0:J7.configV2,f,A,JSON.stringify(T3)]),{data:O6,isLoading:x7,error:a7,refetch:K6}=s70({data:L7,clientId:A?d||"":o,token:f,isFrontendApp:A,isFullScreen:A2},{onSuccess:i8=>{var s9;const r8=qb2(i8);f2&&((s9=r8==null?void 0:r8.error)==null?void 0:s9.code)!=="E1001"&&(f2==null||f2(B8=>{var L9;return[...(B8==null?void 0:B8.filter(N8=>(N8==null?void 0:N8.id)!==(L7==null?void 0:L7.id)))||[],{id:L7==null?void 0:L7.id,isDataFound:!!(r8!=null&&r8.length)&&((W1==null?void 0:W1.chartType)!==L0.singleValue||((L9=r8==null?void 0:r8[0])==null?void 0:L9[(W1==null?void 0:W1.singleValue)||""])!==null)}]}))}}),{mutate:o6}=V30(),{mutateAsync:N7}=Bu2();z0.useEffect(()=>{var r8;const i8=((r8=t==null?void 0:t.rlsConditions)==null?void 0:r8.map(s9=>{var O5,f8,I9,l9,O9,m4,$5,Ke,Ze,pt,De,ne,ye,Ne;let B8=s9;if(e){const Le=eB2(B8,e);Le&&(B8={...B8,filterType:"manual",value:Le.value?B8.datatype==="string"&&((O5=B8==null?void 0:B8.filterVariant)==null?void 0:O5.value)===au?[Le.value]:Le.value:B8.value,options:B8.datatype==="date"?(f8=Le.options)==null?void 0:f8.map(Ie=>({...Ie,startDate:Nc(Ie.fromDate)??Ie.startDate,endDate:Nc(Ie.toDate)??Ie.endDate,minDate:Nc(Ie.minDate)??void 0,maxDate:Nc(Ie.maxDate)??void 0,fromDate:Nc(Ie.fromDate)??void 0,toDate:Nc(Ie.toDate)??void 0})):Le.options,variableOptions:B8.datatype==="date"?(I9=Le.options)==null?void 0:I9.map(Ie=>({range:Ie.range,startDate:Nc(Ie.fromDate)??Ie.startDate,endDate:Nc(Ie.toDate)??Ie.endDate,minDate:Nc(Ie.minDate)??void 0,maxDate:Nc(Ie.maxDate)??void 0,fromDate:Nc(Ie.fromDate)??void 0,toDate:Nc(Ie.toDate)??void 0,value:Ie.name,label:Ie.name})):(l9=Le.options)==null?void 0:l9.map(Ie=>({value:Ie,label:Ie})),selectedVariableValue:Le.value?B8.datatype==="string"?{value:Le.value,label:Le.value}:{startDate:Nc((m4=(O9=Le.options)==null?void 0:O9.find(Ie=>Ie.name===Le.value))==null?void 0:m4.fromDate),endDate:Nc((Ke=($5=Le.options)==null?void 0:$5.find(Ie=>Ie.name===Le.value))==null?void 0:Ke.toDate),value:Le.value,label:Le.value}:B8.selectedVariableValue})}const N8=[...((De=(pt=(Ze=g2==null?void 0:g2.metricViewFilters)==null?void 0:Ze.find(Le=>Le.id===(t==null?void 0:t.id)))==null?void 0:pt.filters)==null?void 0:De.filter(Le=>!(N!=null&&N.find(Ie=>(Le==null?void 0:Le.name)===(Ie==null?void 0:Ie.name)))))||[],...N||[]].find(Le=>B8.name===Le.name);return N8!=null&&N8.value&&(B8={...B8,...N8!=null&&N8.value?{value:N8==null?void 0:N8.value}:{},...N8!=null&&N8.selectedDropdownValue?{selectedDropdownValue:N8==null?void 0:N8.selectedDropdownValue}:{},...N8!=null&&N8.selectedVariableValue?{selectedVariableValue:N8==null?void 0:N8.selectedVariableValue}:{}}),(B8==null?void 0:B8.datatype)==="date"&&((ne=B8==null?void 0:B8.options)==null?void 0:ne.find(Le=>Le.range==="Custom Date"))&&(B8==null?void 0:B8.isEnableDynamicDate)&&((ye=B8==null?void 0:B8.dynamicDate)==null?void 0:ye.value)&&(B8={...B8,options:(Ne=B8==null?void 0:B8.options)==null?void 0:Ne.map(Le=>{var Ie,Qn;return Le.range==="Custom Date"?{...Le,startDate:Na2(((Ie=eb==null?void 0:eb.find(ei=>{var ti;return ei.value===((ti=B8==null?void 0:B8.dynamicDate)==null?void 0:ti.value)}))==null?void 0:Ie.count)||0),endDate:Na2(((Qn=eb==null?void 0:eb.find(ei=>{var ti;return ei.value===((ti=B8==null?void 0:B8.dynamicDate)==null?void 0:ti.value)}))==null?void 0:Qn.count)||0)}:Le})}),a==="DATABASE"?{...B8,tableName:`${o}.${s9.tableName.split(".").slice(1).join(".")}`}:B8}))||[];c7(i8||[])},[t==null?void 0:t.rlsConditions,e,a,o,N,g2]),z0.useEffect(()=>{let i8;return x7?C0(!0):i8=setTimeout(()=>{C0(!1)},300),()=>clearTimeout(i8)},[x7]),z0.useEffect(()=>{t!=null&&t.id&&b2&&!h8&&(t!=null&&t.isMetric)&&(b2==null||b2(i8=>{var r8,s9,B8,L9,N8,e5,B5,O5,f8,I9,l9;return[...(i8==null?void 0:i8.filter(O9=>O9.id!==(t==null?void 0:t.id)))||[],{filters:[...o9||[],...(r8=W1==null?void 0:W1.tableSettings)!=null&&r8.isServerSidePagination&&(W1==null?void 0:W1.chartType)===L0.table?(s9=T3==null?void 0:T3.map(O9=>O9.condition))==null?void 0:s9.filter(O9=>Px(O9)):[]],xAxisSettings:{isEnable:!!((B8=W1==null?void 0:W1.dynamicXAxis)!=null&&B8.isEnabled||(L9=W1==null?void 0:W1.enduserMeasureAndDimensions)!=null&&L9.isEnabled)&&Ih.includes((W1==null?void 0:W1.chartType)||""),xaxis:(W1==null?void 0:W1.xAxis)||""},yAxisSettings:{isEnable:!!(!((N8=W1==null?void 0:W1.dynamicYAxis)!=null&&N8.isEnabled)||!((e5=W1==null?void 0:W1.dynamicYAxis)!=null&&e5.selectedOption)||Array.isArray((B5=W1==null?void 0:W1.dynamicYAxis)==null?void 0:B5.selectedOption)),yAxis:((O5=W1==null?void 0:W1.dynamicYAxis)==null?void 0:O5.selectedOption)||""},id:t==null?void 0:t.id,metricRequestData:{isAllClient:u,timeseriesSettings:h8?void 0:{format:((l9=(I9=(f8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:f8.groupBySettings)==null?void 0:I9.value)==null?void 0:l9.toLowerCase())||"monthly",seriesField:(W1==null?void 0:W1.seriesField)||"",isFiscal:K==="ind"}}}]}))},[t==null?void 0:t.id,t==null?void 0:t.isMetric,o9,W1==null?void 0:W1.timeSeriesSettings,W1==null?void 0:W1.seriesField,h8,K,u,T3,(z4=W1==null?void 0:W1.tableSettings)==null?void 0:z4.isServerSidePagination,W1==null?void 0:W1.chartType,W1==null?void 0:W1.dynamicYAxis,W1==null?void 0:W1.dynamicXAxis]),z0.useEffect(()=>{var i8,r8,s9,B8,L9,N8;if((i8=t==null?void 0:t.drillDownSettings)!=null&&i8.isEnableGroupBy){const e5=t==null?void 0:t.datasetMetricSettings;!((r8=t==null?void 0:t.drillDownSettings)!=null&&r8.configV2)&&!(J7!=null&&J7.configV2)&&((B8=(s9=e5==null?void 0:e5.newDatasetSettings)==null?void 0:s9.selectedMetrics)!=null&&B8.length)&&((N8=(L9=e5==null?void 0:e5.newDatasetSettings)==null?void 0:L9.selectedDims)!=null&&N8.length)?e8(B5=>{var O5,f8,I9;return{...(t==null?void 0:t.drillDownSettings)||{},configV2:{isEnable:!!((O5=t==null?void 0:t.drillDownSettings)!=null&&O5.isEnableGroupBy),levels:(I9=(f8=e5==null?void 0:e5.newDatasetSettings)==null?void 0:f8.selectedDims)==null?void 0:I9.map((l9,O9)=>{var $5,Ke,Ze,pt;const m4=(Ze=(Ke=($5=t==null?void 0:t.drillDownSettings)==null?void 0:$5.drilldownChartSettings)==null?void 0:Ke.find(De=>(De==null?void 0:De.name)===(l9==null?void 0:l9.alias)))==null?void 0:Ze.chartSettings;return{name:`Drill Level ${O9+1}`,chartSettings:m4||W1,index:PB(4),isEnable:O9===0,dimensions:[l9],measures:((pt=e5==null?void 0:e5.newDatasetSettings)==null?void 0:pt.selectedMetrics)||[]}})}}}):J7!=null&&J7.isEnableGroupBy||e8(t==null?void 0:t.drillDownSettings)}},[(Ce=t==null?void 0:t.drillDownSettings)==null?void 0:Ce.isEnableGroupBy,(N9=t==null?void 0:t.drillDownSettings)==null?void 0:N9.configV2,t==null?void 0:t.datasetMetricSettings,W1]);const{mutateAsync:r6}=v_(),q3=z0.useMemo(()=>{var s9,B8,L9,N8,e5,B5,O5,f8,I9,l9,O9,m4,$5,Ke,Ze,pt;const i8=((s9=t==null?void 0:t.datasetMetricSettings)==null?void 0:s9.metricVariables)||[];if(!i8||!Array.isArray(i8)||!(i8!=null&&i8.length))return[];const r8=[];for(let De=0;De<(i8==null?void 0:i8.length);De++){const ne=i8[De],ye=ne.type.value==="custom"&&ne.customQuery&&ne.customColumnName,Ne=ye?{query:lb({query:(ne==null?void 0:ne.customQuery)||"",tenancyLevel:a,clientId:o,isAllClient:u,clientColumnType:Q||"STRING",dbName:(B8=t==null?void 0:t.companyIntegration)==null?void 0:B8.name,rlsConditions:o9==null?void 0:o9.filter(xe=>xe.isVariableFilter),globalFilters:{...n,filters:(L9=n==null?void 0:n.filters)==null?void 0:L9.filter(xe=>{var Wr;return(xe==null?void 0:xe.isVariableFilter)&&!!(Array.isArray(xe==null?void 0:xe.value)?(Wr=xe==null?void 0:xe.value)!=null&&Wr.length:xe)})}}),alias:fP}:void 0,Le=(N8=ne.dependOnOptions)!=null&&N8.length?o9==null?void 0:o9.filter(xe=>ne.dependOnOptions.some(Wr=>{var Xt;return Wr.type==="metric"&&((Xt=Wr.filter)==null?void 0:Xt.value)===xe.name&&Wr.column})):[],Ie=(e5=ne.dependOnOptions)!=null&&e5.length?(B5=n==null?void 0:n.filters)==null?void 0:B5.filter(xe=>{var Wr;return Array.isArray(xe==null?void 0:xe.value)?(Wr=xe==null?void 0:xe.value)==null?void 0:Wr.length:xe&&ne.dependOnOptions.some(Xt=>{var Mr;return Xt.type==="dashboard"&&((Mr=Xt.filter)==null?void 0:Mr.value)===xe.label&&Xt.column})}):[],Qn=Le==null?void 0:Le.map(xe=>{var Wr;return{columnName:((Wr=ne.dependOnOptions.find(Xt=>{var Mr;return xe.name===((Mr=Xt.filter)==null?void 0:Mr.value)}))==null?void 0:Wr.column)||"",value:xe.value,as:"string"}}),ei=Ie==null?void 0:Ie.map(xe=>{var Wr;return{columnName:((Wr=ne.dependOnOptions.find(Xt=>{var Mr;return xe.label===((Mr=Xt.filter)==null?void 0:Mr.value)}))==null?void 0:Wr.column)||"",value:Cb(xe==null?void 0:xe.value),as:"string"}});ne.isClientScoped&&o&&Q&&!u&&a==="TABLE"&&((f8=(O5=ne.clientColumn)==null?void 0:O5.name)!=null&&f8.value)&&((l9=(I9=ne.clientColumn)==null?void 0:I9.datatype)!=null&&l9.value)&&Qn.push({columnName:(m4=(O9=ne.clientColumn)==null?void 0:O9.name)==null?void 0:m4.value,value:o,as:(Ke=($5=ne.clientColumn)==null?void 0:$5.datatype)==null?void 0:Ke.value});const ti=[...Qn,...ei];r8.push({object:{wId:g,tableName:ye?"":(Ze=ne==null?void 0:ne.table)==null?void 0:Ze.value,columnName:ye?(ne==null?void 0:ne.customColumnName)||"":((pt=ne==null?void 0:ne.column)==null?void 0:pt.value)||"",filter:ti,customTable:Ne,limit:"1",datasourceId:R,databaseName:a==="MULTI_DATABASE"&&o||""},element:ne})}return r8},[(K5=t==null?void 0:t.datasetMetricSettings)==null?void 0:K5.metricVariables,JSON.stringify(n==null?void 0:n.filters),o9,Q,g,a,o,u,R]),Z6=async i8=>{var s9,B8,L9,N8,e5;P2(!0);const r8={};i8==null||i8.forEach(B5=>{var O5,f8;r8[(O5=B5==null?void 0:B5.element)==null?void 0:O5.name]=((f8=B5==null?void 0:B5.element)==null?void 0:f8.defaultValue)||""}),y5(r8);for(let B5=0;B5<(i8==null?void 0:i8.length);B5++){const O5=i8[B5];if(r8[O5.element.name]=O5.element.defaultValue||"",P2(!0),O5.object.wId&&(!((B8=(s9=O5==null?void 0:O5.object)==null?void 0:s9.customTable)!=null&&B8.query)||!((e5=(N8=(L9=O5==null?void 0:O5.object)==null?void 0:L9.customTable)==null?void 0:N8.query)!=null&&e5.includes("{{")))){const f8=await r6(O5.object);f8!=null&&f8.data&&Array.isArray(f8.data)&&y5(I9=>{var l9,O9;return{...I9,[O5.element.name]:((O9=(l9=f8==null?void 0:f8.data)==null?void 0:l9[0])==null?void 0:O9.value)||O5.element.defaultValue||""}})}}setTimeout(()=>{P2(!1)},200)};z0.useEffect(()=>{q3!=null&&q3.length&&Z6(q3)},[JSON.stringify(q3)]);const o8=z0.useMemo(()=>{var i8,r8,s9,B8;return(B8=(s9=(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)==null?void 0:r8.selectedDims)==null?void 0:s9[0])==null?void 0:B8.name},[t]);z0.useMemo(()=>{var i8,r8,s9,B8;return Qa2(((B8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.selectedDimensions)==null?void 0:B8[k7.length<((s9=(r8=t==null?void 0:t.datasetMetricSettings)==null?void 0:r8.selectedDimensions)==null?void 0:s9.length)?k7.length:0])||"")},[t==null?void 0:t.datasetMetricSettings,k7]),z0.useEffect(()=>{var s9,B8,L9;const r8=((s9=t==null?void 0:t.drillDownSettings)==null?void 0:s9.isEnableGroupBy)?l3||[]:[...l3!=null&&l3.length?l3:[],...l||[]];(B8=r8==null?void 0:r8.filter(N8=>N8.isAddOnMetrics))!=null&&B8.length?M9((L9=r8.filter(N8=>N8.isAddOnMetrics))==null?void 0:L9.map(N8=>{var e5,B5,O5,f8,I9;return s?{...N8,dimensionColumn:(W1==null?void 0:W1.xAxis)||"",measureColumn:((e5=W1==null?void 0:W1.yAxisList)==null?void 0:e5[0])||"",options:N8.datatype!==Xu?[]:N8.options,variableOptions:N8.datatype!==Xu?[]:N8.variableOptions}:{...N8,dimensionColumn:(W1==null?void 0:W1.xAxis)||"",measureColumn:((B5=W1==null?void 0:W1.yAxisList)==null?void 0:B5[0])||"",value:N8.isAppFilter?N8.datatype==="date"?(O5=N8==null?void 0:N8.options)==null?void 0:O5.find(l9=>{var O9;return l9.name===((O9=r==null?void 0:r.values)==null?void 0:O9[N8.name])||N8.value}):((f8=r==null?void 0:r.values)==null?void 0:f8[N8.name])||N8.value:N8.value,options:N8.datatype!==Xu?[]:(I9=N8==null?void 0:N8.options)==null?void 0:I9.map(l9=>K==="ind"&&N8.datatype===Xu?{...l9,isFiscal:!0}:l9),variableOptions:N8.datatype!==Xu?[]:N8.variableOptions}}).filter(N8=>Px(N8))):M9([])},[l3,r,l,(s4=t==null?void 0:t.drillDownSettings)==null?void 0:s4.isEnableGroupBy,a,s,o,K]);const D8=z0.useMemo(()=>{var i8,r8,s9;return(W1==null?void 0:W1.chartType)===L0.singleValue&&!!((i8=W1==null?void 0:W1.customSettings)!=null&&i8.comparisonValueShow)&&!!((r8=W1==null?void 0:W1.customSettings)!=null&&r8.comparisonTimeGrain)&&!!((s9=W1==null?void 0:W1.customSettings)!=null&&s9.comparisonTimePeriod)&&!!(W1!=null&&W1.singleValue)},[W1]);z0.useEffect(()=>{var L9,N8,e5,B5,O5;const i8=O6;let r8=i8!=null&&i8.data&&typeof i8.data=="string"?JSON.parse(i8.data):i8!=null&&i8.data&&Array.isArray(i8==null?void 0:i8.data)?i8==null?void 0:i8.data:[];l8({data:[],error:"",isLoading:!1,currentValue:""}),(W1==null?void 0:W1.chartType)===L0.table&&B3((i8==null?void 0:i8.totalRecords)||0),r8=Da2(r8||[],((N8=(L9=t==null?void 0:t.datasetMetricSettings)==null?void 0:L9.newDatasetSettings)==null?void 0:N8.selectedDims)||[],((B5=(e5=t==null?void 0:t.datasetMetricSettings)==null?void 0:e5.newDatasetSettings)==null?void 0:B5.selectedMetrics)||[]);const s9=(()=>{var f8,I9,l9,O9;if(!Array.isArray(r8))return[];if(((I9=(f8=t==null?void 0:t.companyIntegration)==null?void 0:f8.name)==null?void 0:I9.toLowerCase())===Cg&&!h8){const m4=(l9=t==null?void 0:t.datasetMetricSettings)==null?void 0:l9.newDatasetSettings,$5=(m4==null?void 0:m4.selectedMetrics)||[],Ke=((O9=m4==null?void 0:m4.selectedDims)==null?void 0:O9.filter(pt=>{var De,ne;return!((ne=(De=pt==null?void 0:pt.alias)==null?void 0:De.toLowerCase())!=null&&ne.match(/monthly|quarterly|weekly|yearly|daily/))}))||[],Ze=[...Ke==null?void 0:Ke.map(pt=>pt.alias),...$5==null?void 0:$5.map(pt=>pt.alias)];return Ha2(Ze,r8)}return r8})();if(Z7(s9),(O5=t==null?void 0:t.datasetMetricSettings)!=null&&O5.isUseRawSQL){const f8=Object.keys((s9==null?void 0:s9[0])||{})||[];W9(I9=>({...I9,yAxisList:f8||(I9==null?void 0:I9.yAxisList)||[]}))}const B8=i8==null?void 0:i8.metaData;x6(zY(B8==null?void 0:B8.groupbyColumnList)),h3(f8=>({...f8,report:"",isLoading:f8==null?void 0:f8.isLoading,isOpen:f8==null?void 0:f8.isOpen}))},[O6,t==null?void 0:t.datasetMetricSettings,h8]),z0.useEffect(()=>{var i8,r8;(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.createdSorts)!=null&&r8.length?_5(!0):_5(!1)},[(B4=(le=t==null?void 0:t.datasetMetricSettings)==null?void 0:le.createdSorts)==null?void 0:B4.length]),z0.useEffect(()=>{var i8,r8;(W1==null?void 0:W1.chartType)===L0.timeSeries&&((r8=(i8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:i8.groupBySettings)!=null&&r8.value)&&!h8&&W9(s9=>{var B8,L9,N8;return{...s9,xAxis:`${(N8=(L9=(B8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:B8.groupBySettings)==null?void 0:L9.value)==null?void 0:N8.toLowerCase()} of ${o8}`}})},[V3,W1==null?void 0:W1.chartType,W1==null?void 0:W1.timeSeriesSettings,h8]),z0.useEffect(()=>{var i8;if(W1!=null&&W1.isEnableComparisonFilter&&[L0.line].includes(W1==null?void 0:W1.chartType)){const r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings,s9=(r8==null?void 0:r8.selectedMetrics)||[],B8=Object==null?void 0:Object.keys((V3==null?void 0:V3[0])||{});W9(L9=>({...L9,yAxisList:[...B8.filter(N8=>s9==null?void 0:s9.some(e5=>N8.startsWith(e5.alias)))]}))}},[V3,W1==null?void 0:W1.isEnableComparisonFilter,j3,W1==null?void 0:W1.chartType]);const z8=z0.useCallback((i8,r8,s9,B8,L9,N8)=>{w==null||w(v30,t==null?void 0:t.id),c7(B8?e5=>e5==null?void 0:e5.map(B5=>{var O5,f8;return B5.name===i8?{...B5,value:r8,options:(O5=B5.options)==null?void 0:O5.map(I9=>r8===I9.name?{...I9,...B8,timeGrainValue:N8}:I9),variableOptions:(f8=B5.variableOptions)==null?void 0:f8.map(I9=>I9.value===r8?{...I9,...B8,timeGrainValue:N8}:I9),selectedVariableValue:{value:r8,label:r8,endDate:B8.endDate,startDate:B8.startDate,timeGrainValue:N8}}:B5}):L9?e5=>e5==null?void 0:e5.map(B5=>B5.name===i8?{...B5,value:L9!=null&&L9.length?L9==null?void 0:L9.map(O5=>O5.value):void 0,selectedDropdownValue:L9!=null&&L9.length?L9:void 0}:B5):e5=>e5==null?void 0:e5.map(B5=>B5.name===i8?{...B5,value:r8,selectedVariableValue:{value:r8,label:r8},selectedDropdownValue:{value:r8,label:s9||r8}}:B5))},[]),k8=z0.useCallback(i8=>{var r8,s9;i8!=null&&i8.event&&((s9=(r8=i8==null?void 0:i8.event)==null?void 0:r8.event)==null||s9.preventDefault()),t0(i8)},[l3]),{getUnderlyingData:k3}=a70({clientName:o,dbName:(O4=t==null?void 0:t.companyIntegration)==null?void 0:O4.name,tenancyType:a,values:Q8,companyId:t==null?void 0:t.companyId,query:Od(t==null?void 0:t.query,t==null?void 0:t.companyId),workspaceId:g,metricId:t==null?void 0:t.id,rlsConditions:o9,globalFilters:n,isAllClient:!!u,dataMartRelationships:Y6,customSql:(C3=(i1=t==null?void 0:t.clickActions)==null?void 0:i1.underlyingData)==null?void 0:C3.sql,isEnableCustomSQL:(W1==null?void 0:W1.chartType)===L0.singleValue&&((x3=(W3=t==null?void 0:t.clickActions)==null?void 0:W3.underlyingData)==null?void 0:x3.isEnable)&&((s3=(_7=t==null?void 0:t.clickActions)==null?void 0:_7.underlyingData)==null?void 0:s3.sql),datasourceId:R}),h5=z0.useMemo(()=>Array.isArray(V3)&&V3.length&&(n3!=null&&n3.name)?V3==null?void 0:V3.map(i8=>{const r8=Object.entries(i8).find(([,s9])=>(typeof s9=="number"&&typeof(n3==null?void 0:n3.name)=="string"?s9==null?void 0:s9.toString():s9)===n3.name);return r8==null?void 0:r8[0]}).filter(i8=>i8)[0]:"",[V3,n3==null?void 0:n3.name]),I8=async(i8,r8,s9,B8)=>{var Ne,Le,Ie,Qn,ei,ti,xe,Wr,Xt,Mr,Mn,sn,Oi,_r,Tn,Fi,li,Ei,eo,to,Gi,kn,On,ko,Oo,na,ca;const L9=t==null?void 0:t.datasetMetricSettings;if(!(J7!=null&&J7.configV2)||!((Ne=L9==null?void 0:L9.newDatasetSettings)!=null&&Ne.configuration)||!((Le=t==null?void 0:t.companyIntegration)!=null&&Le.name)||!i8)return;let N8=i8;const e5=(N8==null?void 0:N8.levels)||[],B5=e5==null?void 0:e5.find(Pe=>s9?Pe.index===s9:Pe==null?void 0:Pe.isEnable),O5=e5==null?void 0:e5.findIndex(Pe=>s9?Pe.index===s9:Pe==null?void 0:Pe.isEnable),f8=O5>=0&&O5<(e5==null?void 0:e5.length)-1,I9=f8?e5==null?void 0:e5[O5+1]:e5==null?void 0:e5[0],l9=r8==null?void 0:r8.name,O9=(r8==null?void 0:r8.rowFilters)||[],m4=(Qn=(Ie=B5==null?void 0:B5.dimensions)==null?void 0:Ie[0])==null?void 0:Qn.alias;!B5||B8?N8={...N8||{},levels:((ei=N8==null?void 0:N8.levels)==null?void 0:ei.map((Pe,Pn)=>Pn==0?{...Pe,filters:[],isEnable:!0}:{...Pe,isEnable:!1}))||[]}:s9&&B5?N8={...N8||{},levels:((ti=N8==null?void 0:N8.levels)==null?void 0:ti.map((Pe,Pn)=>Pe.index===(B5==null?void 0:B5.index)?{...Pe,filters:[...(B5==null?void 0:B5.filters)||[]],isEnable:!0}:{...Pe,filters:Pn>O5?[]:Pe==null?void 0:Pe.filters,isEnable:!1}))||[]}:(l9&&m4||O9!=null&&O9.length)&&B5?N8={...N8||{},levels:((xe=N8==null?void 0:N8.levels)==null?void 0:xe.map(Pe=>Pe.index===(I9==null?void 0:I9.index)?{...Pe,filters:f8?[...(B5==null?void 0:B5.filters)||[],...O9!=null&&O9.length?O9:[{columnName:m4,value:l9}]]:[],isEnable:!0}:{...Pe,isEnable:!1}))||[]}:N8={...N8||{},levels:((Wr=N8==null?void 0:N8.levels)==null?void 0:Wr.map(Pe=>Pe.index===(B5==null?void 0:B5.index)?{...Pe,filters:[],isEnable:!0}:{...Pe,isEnable:!1}))||[]},N8={...N8||{},levels:((Xt=N8==null?void 0:N8.levels)==null?void 0:Xt.map(Pe=>{var Pn,en;return{...Pe,dimensions:((Pn=Pe==null?void 0:Pe.dimensions)==null?void 0:Pn.filter(i9=>{var o5,I4;return(I4=(o5=L9==null?void 0:L9.newDatasetSettings)==null?void 0:o5.selectedDims)==null?void 0:I4.some(Ge=>Ge.alias===(i9==null?void 0:i9.alias))}))||[],measures:((en=Pe==null?void 0:Pe.measures)==null?void 0:en.filter(i9=>{var o5,I4;return(I4=(o5=L9==null?void 0:L9.newDatasetSettings)==null?void 0:o5.selectedMetrics)==null?void 0:I4.some(Ge=>Ge.alias===(i9==null?void 0:i9.alias))}))||[]}}))||[]};const $5=(Mr=N8==null?void 0:N8.levels)==null?void 0:Mr.find(Pe=>Pe==null?void 0:Pe.isEnable),Ke=!!((Oi=(sn=N8==null?void 0:N8.levels)==null?void 0:sn[((Mn=N8==null?void 0:N8.levels)==null?void 0:Mn.length)-1])!=null&&Oi.isEnable);(Tn=(_r=N8==null?void 0:N8.levels)==null?void 0:_r[0])==null||Tn.isEnable;const Ze=($5==null?void 0:$5.chartSettings)||W1,pt=(Ze==null?void 0:Ze.chartType)===L0.table,De=[...((Fi=$5==null?void 0:$5.dimensions)==null?void 0:Fi.map(Pe=>Pe.alias))||[],...((li=$5==null?void 0:$5.measures)==null?void 0:li.map(Pe=>Pe.alias))||[]],ne={...Ze,xAxis:((eo=(Ei=$5==null?void 0:$5.dimensions)==null?void 0:Ei[0])==null?void 0:eo.alias)||"",yAxisList:Ke&&!(Ze!=null&&Ze.chartType)||pt?De:((to=$5==null?void 0:$5.measures)==null?void 0:to.map(Pe=>Pe.alias))||[],chartType:Ke&&!(Ze!=null&&Ze.chartType)?L0.table:Ze==null?void 0:Ze.chartType},ye=`${(On=(kn=(Gi=$5==null?void 0:$5.dimensions)==null?void 0:Gi[0])==null?void 0:kn.table)==null?void 0:On.schemaName}.${(na=(Oo=(ko=$5==null?void 0:$5.dimensions)==null?void 0:ko[0])==null?void 0:Oo.table)==null?void 0:na.tableName}`;if(e8(Pe=>{var Pn;return{...Pe,configV2:{...N8||{},levels:((Pn=N8==null?void 0:N8.levels)==null?void 0:Pn.map(en=>en.index===($5==null?void 0:$5.index)?{...en,chartSettings:ne}:en))||[]}}}),W9(Pe=>ne),(ca=t==null?void 0:t.drillDownSettings)!=null&&ca.isEnableCrossFilter){const Pe=(()=>{var Pn;if(B8||s9)return[];if((l9&&m4||O9!=null&&O9.length)&&B5){if(O9!=null&&O9.length){const en=(Pn=O9==null?void 0:O9.map(i9=>{var Ge,Cn,zn,Zn;const o5=(Cn=(Ge=L9==null?void 0:L9.newDatasetSettings)==null?void 0:Ge.selectedDims)==null?void 0:Cn.find(dn=>(dn==null?void 0:dn.alias)===(i9==null?void 0:i9.columnName)),I4=`${(zn=o5==null?void 0:o5.table)==null?void 0:zn.schemaName}.${(Zn=o5==null?void 0:o5.table)==null?void 0:Zn.tableName}`;if(o5)return{columnName:i9==null?void 0:i9.columnName,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[i9==null?void 0:i9.value],tableName:a==="DATABASE"?`${o}.${I4==null?void 0:I4.split(".").slice(1).join(".")}`:I4,value:[i9==null?void 0:i9.value]}}))==null?void 0:Pn.filter(i9=>i9);return[...l||[],...en]}if(m4&&l9)return[...l||[],{columnName:m4,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[l9],tableName:a==="DATABASE"?`${o}.${ye==null?void 0:ye.split(".").slice(1).join(".")}`:ye,value:[l9]}]}return[]})();C==null||C(Pe)}},D9=async(i8,r8)=>{await I8(J7==null?void 0:J7.configV2,i8)},E8=({filters:i8,nextLevel:r8,currentValue:s9})=>{var De,ne;const B8=(De=t==null?void 0:t.datasetMetricSettings)==null?void 0:De.newDatasetSettings,L9=B8==null?void 0:B8.configuration,N8=(B8==null?void 0:B8.selectedDims)||[],e5=(B8==null?void 0:B8.selectedMetrics)||[],B5=((ne=t==null?void 0:t.datasetMetricSettings)==null?void 0:ne.createdSorts)||[],{headerColumns:O5,nonHeaderColumns:f8}=N8.reduce((ye,Ne)=>{var Le,Ie;return(Ie=(Le=W1==null?void 0:W1.pivotTableSettings2)==null?void 0:Le.headers)!=null&&Ie.includes(Ne.alias)?ye.headerColumns.push(Ne):ye.nonHeaderColumns.push(Ne),ye},{headerColumns:[],nonHeaderColumns:[]}),I9=i8==null?void 0:i8.map(ye=>`${ye.columnName};;${ye.value}`).join(";;");l8(ye=>({...ye,data:ye.data.filter(Ne=>Ne.key!==I9),error:"",isLoading:!0,currentValue:s9}));const l9=f8.slice(0,r8),O9=i8==null?void 0:i8.map(ye=>{const Ne=N8.find(Le=>Le.alias===ye.columnName);if(Ne)return{alias:Ne.alias||"",columnName:Ne.name,dataType:Ne.datatype,method:"=",parentAlias:Ne.parentAlias,type:"dimension",value:ye.value,relationOperator:"AND"}}).filter(ye=>ye),m4=[...l9,...e5,...O5],{aggregates:$5,dimensions:Ke}=Fu(m4),Ze=LJ2(B5),pt={...L9,dimensions:Ke,aggregates:$5,filters:[...L9.filters,...O9],orders:(Ze==null?void 0:Ze.filter(ye=>(ye==null?void 0:ye.type)==="selected_column"?m4==null?void 0:m4.some(Ne=>(Ne==null?void 0:Ne.alias)===(ye==null?void 0:ye.name)):!0))||[],isApplyGlobalFilter:!0,isApplyMetricFilter:!0,globalFilters:n,rlsConditions:o9};o6({data:{configuration:pt,id:g,datasourceId:R,dashboardId:"",isCreateMetric:!0},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(ye){const Ne=ye==null?void 0:ye.error,Le=ye==null?void 0:ye.data;Ne!=null&&Ne.message?l8(Ie=>({...Ie,error:Ne==null?void 0:Ne.message,isLoading:!1,currentValue:""})):(l8(Ie=>({data:[...Ie.data,{key:I9,data:Array.isArray(Le)?Le:[]}],error:"",isLoading:!1,currentValue:""})),W9(Ie=>{var Qn,ei;return{...Ie,pivotTableSettings2:{...W1==null?void 0:W1.pivotTableSettings2,dimensions:OB(l9,((Qn=t==null?void 0:t.companyIntegration)==null?void 0:Qn.name)||""),headers:OB(O5,((ei=t==null?void 0:t.companyIntegration)==null?void 0:ei.name)||"")}}}))}})},A5=z0.useCallback(async(i8,r8)=>{await I8(J7==null?void 0:J7.configV2,void 0,i8,r8)},[J7==null?void 0:J7.configV2]),y9=z0.useCallback(i8=>{var r8;if(i8)c7(s9=>[...s9==null?void 0:s9.filter(B8=>B8.group!==`${j3}`)]),w7(s9=>s9-1);else{const s9=(r8=l3.filter(B8=>!(B8!=null&&B8.group)))==null?void 0:r8.map(B8=>{var L9,N8,e5,B5;return{...B8,name:`${B8==null?void 0:B8.name}_${j3+1}`,group:`${j3+1}`,dependOn:B8.dependOn?{value:`${(L9=B8.dependOn)==null?void 0:L9.value}_${j3+1}`,label:`${(N8=B8.dependOn)==null?void 0:N8.label}_${j3+1}`,customColumnName:(e5=B8.dependOn)==null?void 0:e5.customColumnName}:void 0,dependOns:((B5=B8==null?void 0:B8.dependOns)==null?void 0:B5.map(O5=>({value:`${O5==null?void 0:O5.value}_${j3+1}`,label:`${O5==null?void 0:O5.label}_${j3+1}`,customColumnName:O5==null?void 0:O5.customColumnName})))||[]}});s9.length&&(c7(B8=>[...B8,...s9]),w7(B8=>B8+1))}},[l3]),p5=z0.useCallback(async()=>{v1.report?h3(i8=>({...i8,isOpen:!0})):(h3({report:"",isLoading:!0,isOpen:!0}),await N7({data:{data:V3,wId:g},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(i8){const r8=i8==null?void 0:i8.content;h3(s9=>({...s9,report:r8||"",isLoading:!1}))},onError(){h3(i8=>({...i8,report:"",isLoading:!1}))}}))},[V3,o,A,f,d,o,v1]),T4=z0.useMemo(()=>{var O5,f8,I9,l9,O9,m4;const i8=(O5=t==null?void 0:t.datasetMetricSettings)==null?void 0:O5.newDatasetSettings,r8=i8==null?void 0:i8.configuration,s9=Zx(V3||[]);let B8=s9;const L9=((f8=i8==null?void 0:i8.selectedDims)==null?void 0:f8.some($5=>{var Ke,Ze,pt;return Bl.includes(((Ze=(Ke=$5==null?void 0:$5.cast)==null?void 0:Ke.value)==null?void 0:Ze.toLowerCase())||((pt=$5==null?void 0:$5.datatype)==null?void 0:pt.toLowerCase())||"")}))||mJ2((V3==null?void 0:V3[0])||""),N8=((I9=i8==null?void 0:i8.selectedDims)==null?void 0:I9.length)>1&&((l9=i8==null?void 0:i8.selectedMetrics)==null?void 0:l9.length)>0,e5=[L0.pivot,L0.pivotV2,L0.pivotV3,L0.timeSeries,L0.treeMap,L0.indianMap,L0.geoBarMap,L0.geoMap,L0.geoScatterMap,L0.worldMap],B5=!!((O9=r8==null?void 0:r8.aggregates)!=null&&O9.length)&&!!((m4=r8==null?void 0:r8.dimensions)!=null&&m4.length);return B5&&L9&&(B8=[...s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5))),...e5]),B5&&!L9&&(B8=[...s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5))),...e5==null?void 0:e5.filter($5=>$5!==L0.timeSeries)]),!B5&&L9&&(B8=[...s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5))),L0.timeSeries]),!B5&&!L9&&(B8=s9==null?void 0:s9.filter($5=>!(e5!=null&&e5.includes($5)))),J7!=null&&J7.isEnableGroupBy&&(J7!=null&&J7.configV2)&&(B8=B8==null?void 0:B8.filter($5=>$m==null?void 0:$m.includes($5))),N8||(B8=B8==null?void 0:B8.filter($5=>$5!==L0.bubbleV2)),B8},[V3,W1==null?void 0:W1.xAxis,J7==null?void 0:J7.isEnableGroupBy,J7==null?void 0:J7.configV2,(U6=(B6=(t7=t==null?void 0:t.datasetMetricSettings)==null?void 0:t7.newDatasetSettings)==null?void 0:B6.configuration)==null?void 0:U6.aggregates,(F7=(r7=(e9=t==null?void 0:t.datasetMetricSettings)==null?void 0:e9.newDatasetSettings)==null?void 0:r7.configuration)==null?void 0:F7.dimensions]),k4=i8=>{var B5,O5,f8;const r8=(B5=t==null?void 0:t.datasetMetricSettings)==null?void 0:B5.newDatasetSettings,s9=r8==null?void 0:r8.configuration,B8=(r8==null?void 0:r8.selectedDims)||[],L9=(r8==null?void 0:r8.selectedMetrics)||[],N8=(O5=t==null?void 0:t.companyIntegration)==null?void 0:O5.name,e5=(f8=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:f8.isEnabled;bJ2({chartAggregateColumns:GY(OB((L9==null?void 0:L9.filter(I9=>{var l9,O9;return I9.configType==="AGGREGATE"&&e5?(O9=(l9=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:l9.measures)==null?void 0:O9.some(m4=>m4.value===I9.alias):!0}))||[],N8),V3||[]),chartDimensions:GY(OB((B8==null?void 0:B8.filter(I9=>{var l9,O9;return e5?(O9=(l9=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:l9.dimensions)==null?void 0:O9.some(m4=>m4.value===I9.alias):!0}))||[],N8),V3||[]),chartMetrics:GY(OB((L9==null?void 0:L9.filter(I9=>{var l9,O9;return e5?(O9=(l9=W1==null?void 0:W1.enduserMeasureAndDimensions)==null?void 0:l9.measures)==null?void 0:O9.some(m4=>m4.value===I9.alias):!0}))||[],N8),V3||[]),chartSettings:W1,chartTimeColumns:OB(B8==null?void 0:B8.filter(I9=>{var l9;return Bl.includes((l9=I9.datatype)==null?void 0:l9.toLowerCase())}),N8),chartType:i8,configAggregates:s9==null?void 0:s9.aggregates,configuration:r8==null?void 0:r8.configuration,pivotHeaderColumns:[],resultData:V3||[],setChartSettings:W9})},Te=z0.useMemo(()=>LP(l3.filter(i8=>i8.group&&i8.isAddOnMetrics&&!i8.isAppFilter),"group"),[l3]),X5=z0.useMemo(()=>{var s9,B8;return((s9=W1==null?void 0:W1.customSettings)==null?void 0:s9.comparisonValueShow)&&(W1==null?void 0:W1.chartType)===L0.singleValue?(B8=n==null?void 0:n.filters)==null?void 0:B8.find(L9=>(L9==null?void 0:L9.as)==="date"):void 0},[(s8=W1==null?void 0:W1.customSettings)==null?void 0:s8.comparisonValueShow,W1==null?void 0:W1.chartType,(Y7=n==null?void 0:n.filters)==null?void 0:Y7.find(i8=>(i8==null?void 0:i8.as)==="date")]);z0.useEffect(()=>{V3!=null&&V3.length&&z7.length?h9(!0):h9(!1)},[V3,z7.length,t==null?void 0:t.integrationName,t==null?void 0:t.query]);const te=z0.useMemo(()=>{var i8,r8,s9,B8,L9,N8;return(s9=(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)==null?void 0:r8.selectedMetrics)!=null&&s9.some(e5=>e5.configType==="AGGREGATE")?((N8=(L9=(B8=t==null?void 0:t.datasetMetricSettings)==null?void 0:B8.newDatasetSettings)==null?void 0:L9.selectedDims)==null?void 0:N8.map(e5=>({value:e5.alias,label:e5.alias})))||[]:[]},[(G1=t==null?void 0:t.datasetMetricSettings)==null?void 0:G1.newDatasetSettings]),V4=z0.useMemo(()=>{var i8,r8,s9;return((s9=(r8=(i8=t==null?void 0:t.datasetMetricSettings)==null?void 0:i8.newDatasetSettings)==null?void 0:r8.selectedMetrics)==null?void 0:s9.map(B8=>({value:(B8==null?void 0:B8.alias)||(B8==null?void 0:B8.name),label:(B8==null?void 0:B8.alias)||(B8==null?void 0:B8.name)})))||[]},[(h6=(E7=t==null?void 0:t.datasetMetricSettings)==null?void 0:E7.newDatasetSettings)==null?void 0:h6.selectedMetrics]),{metricFilters:fe,leftPositionedMetricFilters:Y5,rightPositionedMetricFilters:Q6}=z0.useMemo(()=>{const i8=l3.filter(L9=>!L9.isAppFilter);let r8=i8.filter(L9=>L9.isAddOnMetrics);j2&&(r8=r8.filter(L9=>Px(L9,!0)));const s9=[],B8=[];return r8.forEach(L9=>{L9.position==="top-right"?B8.push(L9):s9.push(L9)}),{metricFilters:i8,leftPositionedMetricFilters:s9,rightPositionedMetricFilters:B8}},[l3]),_8=[L0.pie,L0.doughnut,L0.rose,L0.funnel,L0.singleValue,L0.table,L0.pivot,L0.horizontalStackTable,L0.geoBarMap,L0.geoMap,L0.geoScatterMap,L0.sankey,L0.timeSeries,L0.geoBarMap,L0.geoMap,L0.geoScatterMap,L0.worldMap,L0.boxplot,L0.timeSeries,L0.gantt].includes(W1==null?void 0:W1.chartType)||((W1==null?void 0:W1.isMultiDimension)||(W1==null?void 0:W1.isDynamicSeries))&&(W1==null?void 0:W1.seriesField)!=="ungrouped",k6=z0.useMemo(()=>{var r8;const i8=((r8=t==null?void 0:t.dataSecuritySettings)==null?void 0:r8.csvColumns)||[];return V3!=null&&V3.length?V3==null?void 0:V3.map(s9=>{const B8={};for(const L9 in s9)i8!=null&&i8.includes(L9)||(B8[L9]=s9[L9]);return B8}):[]},[V3,t==null?void 0:t.dataSecuritySettings]);z0.useEffect(()=>{var i8,r8;W1||(W9(t==null?void 0:t.chartOptions),L3({limit:parseInt(((r8=(i8=t==null?void 0:t.chartOptions)==null?void 0:i8.tableSettings)==null?void 0:r8.defaultRowSize)||"100",10),offset:0}))},[t==null?void 0:t.chartOptions,W1]),z0.useEffect(()=>{var i8,r8,s9,B8,L9,N8,e5,B5,O5,f8;if((W1==null?void 0:W1.chartType)===L0.timeSeries&&((r8=(i8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:i8.groupBySettings)!=null&&r8.isGlobalFilter)&&o8){const I9=(B8=(s9=n==null?void 0:n.filters)==null?void 0:s9.find(l9=>{var O9,m4,$5;return l9.label===(($5=(m4=(O9=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:O9.groupBySettings)==null?void 0:m4.globalFilterOption)==null?void 0:$5.value)}))==null?void 0:B8.value;if((typeof I9=="string"||typeof I9=="object"&&(I9!=null&&I9.value))&&I9){const l9=typeof I9=="string"?(L9=Cb(I9))==null?void 0:L9.toLowerCase():((f8=(O5=(B5=(e5=(N8=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:N8.groupBySettings)==null?void 0:e5.formatWithValue)==null?void 0:B5.find(O9=>O9.value===Cb(I9==null?void 0:I9.value)))==null?void 0:O5.format)==null?void 0:f8.toLowerCase())||"";cC!=null&&cC.find(O9=>{var m4;return((m4=O9==null?void 0:O9.value)==null?void 0:m4.toLowerCase())===l9})&&W9(O9=>{var m4;return{...O9,timeSeriesSettings:{...O9==null?void 0:O9.timeSeriesSettings,groupBySettings:{...(m4=O9==null?void 0:O9.timeSeriesSettings)==null?void 0:m4.groupBySettings,value:l9}},xAxis:h8?O9.xAxis:`${l9} of ${o8}`}})}}},[n,W1==null?void 0:W1.chartType,(j6=(H6=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:H6.groupBySettings)==null?void 0:j6.isGlobalFilter,(y8=(n9=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:n9.groupBySettings)==null?void 0:y8.globalFilterOption,o8]),z0.useEffect(()=>{var i8,r8,s9,B8;W1!=null&&W1.isDynamicSeries&&((i8=W1==null?void 0:W1.seriesOptions)!=null&&i8.includes("ungrouped")?W1!=null&&W1.ungroupedAlias?S8((r8=W1==null?void 0:W1.seriesOptions)==null?void 0:r8.map(L9=>L9==="ungrouped"?{value:L9,label:W1==null?void 0:W1.ungroupedAlias}:{value:L9,label:L9})):S8((s9=W1==null?void 0:W1.seriesOptions)==null?void 0:s9.map(L9=>({value:L9,label:L9}))):S8([...((B8=W1==null?void 0:W1.seriesOptions)==null?void 0:B8.map(L9=>({value:L9,label:L9})))??[]]))},[W1==null?void 0:W1.seriesOptions,W1==null?void 0:W1.isDynamicSeries,W1==null?void 0:W1.ungroupedAlias]);const[x8,d9]=z0.useState(!1),j9=i8=>{i8.key==="Control"&&d9(!0)},t9=i8=>{i8.key==="Control"&&d9(!1)};z0.useEffect(()=>{V3!=null&&V3.length&&w6(Object.keys((V3==null?void 0:V3[0])||{}))},[V3==null?void 0:V3.length]),z0.useEffect(()=>{var i8,r8;return(r8=(i8=W1==null?void 0:W1.customSettings)==null?void 0:i8.chartZoom)!=null&&r8.isZoomEnabled&&(window.addEventListener("keydown",j9),window.addEventListener("keyup",t9)),()=>{window.removeEventListener("keydown",j9),window.removeEventListener("keyup",t9)}},[]);const t8=z0.useMemo(()=>{let i8=!1;if(V3!=null&&V3.length){const r8=W1==null?void 0:W1.singleValue;i8=V3[0][r8]===null&&(W1==null?void 0:W1.chartType)==="singleValue"}return i8},[V3==null?void 0:V3.length,W1==null?void 0:W1.singleValue,(W1==null?void 0:W1.chartType)==="singleValue"]),z9=z0.useMemo(()=>Yf({chartOptions:W1,data:V3||[]}),[V3,W1==null?void 0:W1.xAxis,W1==null?void 0:W1.yAxisList,(q8=W1==null?void 0:W1.dynamicXAxis)==null?void 0:q8.isEnabled,W1==null?void 0:W1.chartType,W1==null?void 0:W1.seriesField,(C9=W1==null?void 0:W1.customSettings)==null?void 0:C9.cumulativeBar,W1==null?void 0:W1.isGroupXAxis,(V9=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:V9.seriesType[0],(l4=(N5=W1==null?void 0:W1.timeSeriesSettings)==null?void 0:N5.groupBySettings)==null?void 0:l4.fillXAxis]),B9=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.name)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.name,j8,X,O]),S9=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.longDescription)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.longDescription,j8,O,X]),c9=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.description)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.description,j8,O,X]),L5=z0.useMemo(()=>DC({text:nl((t==null?void 0:t.footNote)||"",j8)||"",selectedLanguage:O,translationDictionary:X}),[t==null?void 0:t.footNote,j8,O,X]),x5=z0.useMemo(()=>{var i8;return`${((i8=V3==null?void 0:V3[0])==null?void 0:i8.dbn_metric_expression_data)||"No Data Found"}`},[V3]);z0.useLayoutEffect(()=>{x7&&(m==null||m(i8=>{const r8=new Map(i8);return r8.set(t==null?void 0:t.id,{data:{data:[],name:"",description:""},isLoading:x7,key:""}),r8})),O6!=null&&O6.data&&h&&(m==null||m(i8=>{const r8=new Map(i8);return r8.set(t==null?void 0:t.id,{data:{data:O6==null?void 0:O6.data,name:(t==null?void 0:t.name)||"",description:(t==null?void 0:t.description)||""},isLoading:x7,key:JSON.stringify(L7)}),r8}))},[O6==null?void 0:O6.data,x7]);const c5=()=>{var r8,s9,B8;return(((B8=(s9=(r8=t==null?void 0:t.elementSettings)==null?void 0:r8.summary)==null?void 0:s9.metricList)==null?void 0:B8.map(L9=>{var N8;return(N8=h==null?void 0:h.get(L9==null?void 0:L9.value))==null?void 0:N8.isLoading}))||[]).some(L9=>L9===!0)};z0.useLayoutEffect(()=>{var i8,r8,s9,B8,L9,N8,e5,B5,O5,f8,I9;if((r8=(i8=t==null?void 0:t.elementSettings)==null?void 0:i8.summary)!=null&&r8.metricList&&(h!=null&&h.get(t==null?void 0:t.id))&&!b0&&!c5()){const l9=((L9=(B8=(s9=t==null?void 0:t.elementSettings)==null?void 0:s9.summary)==null?void 0:B8.metricList)==null?void 0:L9.map(O9=>{var m4,$5,Ke,Ze,pt,De,ne,ye,Ne;return{data:(Ke=($5=(m4=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:m4.data)==null?void 0:$5.data)!=null&&Ke.length?(pt=(Ze=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:Ze.data)==null?void 0:pt.data:{},metricName:(ne=(De=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:De.data)==null?void 0:ne.name,metricDescription:(Ne=(ye=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:ye.data)==null?void 0:Ne.description}}))||[];v0(""),U0(""),!l9.some(O9=>Object.keys(O9.data).length===0)&&!b0&&(k0(()=>!0),m0.mutate({data:{metricData:l9,summaryPrompt:(e5=(N8=t==null?void 0:t.elementSettings)==null?void 0:N8.summary)==null?void 0:e5.summaryPrompt,id:t==null?void 0:t.id,filters:`${(I9=(f8=(O5=(B5=t==null?void 0:t.elementSettings)==null?void 0:B5.summary)==null?void 0:O5.metricList)==null?void 0:f8.map(O9=>{var m4;return(m4=h==null?void 0:h.get(O9==null?void 0:O9.value))==null?void 0:m4.key}))==null?void 0:I9.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:O9=>{O9.summary?(v0(O9.summary),U0("")):(U0(g22),v0("")),k0(()=>!1)},onSettled:()=>{k0(()=>!1)},onError:O9=>{k0(()=>!1),U0(O9.message),v0("")}}))}},[t==null?void 0:t.elementSettings,h]),z0.useEffect(()=>{var B8,L9,N8,e5,B5,O5,f8,I9,l9,O9,m4,$5,Ke,Ze,pt,De,ne,ye,Ne,Le,Ie,Qn,ei,ti;const i8=nc(((B8=W1==null?void 0:W1.customSettings)==null?void 0:B8.comboAxisSettings)||[]),r8=(L9=i8==null?void 0:i8.map(xe=>xe==null?void 0:xe.measures))==null?void 0:L9.flat(),s9=(N8=W1==null?void 0:W1.yAxisList)==null?void 0:N8.every(xe=>r8==null?void 0:r8.includes(xe));if((e5=W1==null?void 0:W1.yAxisList)!=null&&e5.length&&((B5=W1==null?void 0:W1.yAxisList)==null?void 0:B5.length)!==(r8==null?void 0:r8.length)&&!(r8!=null&&r8.length)&&[L0.combo,L0.timeSeries,L0.horizontalCombo].includes((W1==null?void 0:W1.chartType)||"")){const xe=(f8=(O5=W1==null?void 0:W1.yAxisList)==null?void 0:O5.filter(sn=>{var Oi;return!((Oi=W1==null?void 0:W1.comboBarList)!=null&&Oi.includes(sn))}))==null?void 0:f8.filter(sn=>!(r8!=null&&r8.includes(sn))),Wr=((l9=(I9=W1==null?void 0:W1.customSettings)==null?void 0:I9.comboStackAxisSymbols)==null?void 0:l9.name)||"",Xt=($5=(m4=(O9=W1==null?void 0:W1.customSettings)==null?void 0:O9.comboLabelFormatter)==null?void 0:m4.find(sn=>sn.axis===(Wr||"stack")))==null?void 0:$5.formatter,Mr=(Ke=W1==null?void 0:W1.comboBarList)==null?void 0:Ke.join(" and "),Mn=(De=(pt=(Ze=W1==null?void 0:W1.customSettings)==null?void 0:Ze.comboLabelFormatter)==null?void 0:pt.find(sn=>sn.axis===Mr))==null?void 0:De.formatter;W9(sn=>{var Oi,_r,Tn,Fi,li,Ei,eo,to,Gi,kn,On,ko,Oo,na,ca,Pe,Pn,en,i9;return{...sn,customSettings:{...sn.customSettings,comboAxisSettings:nc([...((Oi=sn.customSettings)==null?void 0:Oi.comboAxisSettings)||[],...xe==null?void 0:xe.map(o5=>{var Cn,zn,Zn,dn,ln,pi;const I4=(Zn=(zn=(Cn=W1==null?void 0:W1.customSettings)==null?void 0:Cn.comboLabelFormatter)==null?void 0:zn.find(St=>St.axis===o5))==null?void 0:Zn.formatter,Ge=(ln=(dn=W1==null?void 0:W1.customSettings)==null?void 0:dn.comboAxisSymbols)==null?void 0:ln.find(St=>St.name===o5);return{axis:o5,measures:[o5],chartTypes:[{axis:o5,type:"line"}],numberFormatter:(pi=W1==null?void 0:W1.customSettings)==null?void 0:pi.numberFormatter,labelFormatter:I4,prefix:(Ge==null?void 0:Ge.prefix)||"",suffix:(Ge==null?void 0:Ge.suffix)||"",isEnableLabelFormatter:!!(I4!=null&&I4.length)}}),...(_r=W1==null?void 0:W1.comboBarList)!=null&&_r.length&&((Tn=W1==null?void 0:W1.customSettings)!=null&&Tn.isCombineBarAxis||(Fi=W1==null?void 0:W1.customSettings)!=null&&Fi.isStackBar)?[{axis:(li=W1==null?void 0:W1.customSettings)!=null&&li.isStackBar&&Wr||Mr,measures:W1==null?void 0:W1.comboBarList,chartTypes:(Ei=W1==null?void 0:W1.comboBarList)==null?void 0:Ei.map(o5=>({axis:o5,type:"bar"})),isEnableStackBar:(eo=W1==null?void 0:W1.customSettings)==null?void 0:eo.isStackBar,numberFormatter:(to=W1==null?void 0:W1.customSettings)==null?void 0:to.numberFormatter,...(Gi=W1==null?void 0:W1.customSettings)!=null&&Gi.isStackBar?{prefix:((On=(kn=W1==null?void 0:W1.customSettings)==null?void 0:kn.comboStackAxisSymbols)==null?void 0:On.prefix)||"",suffix:((Oo=(ko=W1==null?void 0:W1.customSettings)==null?void 0:ko.comboStackAxisSymbols)==null?void 0:Oo.suffix)||"",labelFormatter:Xt,isEnableLabelFormatter:!!(Xt!=null&&Xt.length)}:{prefix:((na=W1==null?void 0:W1.customSettings)==null?void 0:na.combinedAxisPrefix)||"",suffix:((ca=W1==null?void 0:W1.customSettings)==null?void 0:ca.combinedAxisSuffix)||"",labelFormatter:Mn,isEnableLabelFormatter:!!(Mn!=null&&Mn.length)}}]:[],...(Pe=W1==null?void 0:W1.comboBarList)!=null&&Pe.length&&!((Pn=W1==null?void 0:W1.customSettings)!=null&&Pn.isCombineBarAxis)&&!((en=W1==null?void 0:W1.customSettings)!=null&&en.isStackBar)?(i9=W1==null?void 0:W1.comboBarList)==null?void 0:i9.map(o5=>{var Cn,zn,Zn,dn,ln,pi;const I4=(Zn=(zn=(Cn=W1==null?void 0:W1.customSettings)==null?void 0:Cn.comboLabelFormatter)==null?void 0:zn.find(St=>St.axis===o5))==null?void 0:Zn.formatter,Ge=(ln=(dn=W1==null?void 0:W1.customSettings)==null?void 0:dn.comboAxisSymbols)==null?void 0:ln.find(St=>St.name===o5);return{axis:o5,measures:[o5],chartTypes:[{axis:o5,type:"bar"}],numberFormatter:(pi=W1==null?void 0:W1.customSettings)==null?void 0:pi.numberFormatter,labelFormatter:I4,prefix:(Ge==null?void 0:Ge.prefix)||"",suffix:(Ge==null?void 0:Ge.suffix)||"",isEnableLabelFormatter:!!(I4!=null&&I4.length)}}):[]].filter(o5=>{var I4;return(I4=o5==null?void 0:o5.measures)==null?void 0:I4.length})),comboAxisSymbols:[],combinedAxisPrefix:"",combinedAxisSuffix:"",comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}})}if(r8!=null&&r8.length&&((ne=W1==null?void 0:W1.yAxisList)!=null&&ne.length)&&(((ye=W1==null?void 0:W1.yAxisList)==null?void 0:ye.length)!==(r8==null?void 0:r8.length)||((Ne=W1==null?void 0:W1.yAxisList)==null?void 0:Ne.length)===(r8==null?void 0:r8.length)&&!s9)&&[L0.combo,L0.timeSeries,L0.horizontalCombo].includes((W1==null?void 0:W1.chartType)||"")){const xe=(Le=W1==null?void 0:W1.yAxisList)==null?void 0:Le.filter(Xt=>!(r8!=null&&r8.includes(Xt))),Wr=r8==null?void 0:r8.filter(Xt=>{var Mr;return!((Mr=W1==null?void 0:W1.yAxisList)!=null&&Mr.includes(Xt))});Wr==null||Wr.forEach(Xt=>{var Oi,_r,Tn;const Mr=(_r=(Oi=W1==null?void 0:W1.customSettings)==null?void 0:Oi.comboAxisSettings)==null?void 0:_r.find(Fi=>{var li;return(li=Fi.measures)==null?void 0:li.includes(Xt)}),Mn=Mr==null?void 0:Mr.axis,sn=(((Tn=Mr==null?void 0:Mr.measures)==null?void 0:Tn.length)||0)>1;W9(Fi=>{var li,Ei,eo,to,Gi;return{...Fi,customSettings:{...Fi.customSettings,comboAxisSettings:nc(sn?((eo=(Ei=(li=Fi.customSettings)==null?void 0:li.comboAxisSettings)==null?void 0:Ei.map(kn=>{var On;return kn.axis===Mn?{...kn,measures:(On=kn==null?void 0:kn.measures)==null?void 0:On.filter(ko=>ko!==Xt)}:kn}))==null?void 0:eo.filter(kn=>{var On;return(On=kn==null?void 0:kn.measures)==null?void 0:On.length}))||[]:((Gi=(to=Fi.customSettings)==null?void 0:to.comboAxisSettings)==null?void 0:Gi.filter(kn=>{var On;return kn.axis!==Mn&&((On=kn==null?void 0:kn.measures)==null?void 0:On.length)}))||[])}}})}),xe!=null&&xe.length&&W9(Xt=>{var Mr;return{...Xt,customSettings:{...Xt.customSettings,comboAxisSettings:nc([...((Mr=Xt.customSettings)==null?void 0:Mr.comboAxisSettings)||[],...xe==null?void 0:xe.map(Mn=>({axis:Mn,measures:[Mn],chartTypes:[{axis:Mn,type:"line"}]}))].filter(Mn=>{var sn;return(sn=Mn==null?void 0:Mn.measures)==null?void 0:sn.length})||[])}}})}r8!=null&&r8.length&&((Ie=W1==null?void 0:W1.yAxisList)!=null&&Ie.length)&&((Qn=W1==null?void 0:W1.yAxisList)==null?void 0:Qn.length)===(r8==null?void 0:r8.length)&&s9&&[L0.combo,L0.timeSeries,L0.horizontalCombo].includes((W1==null?void 0:W1.chartType)||"")&&((ti=(ei=W1==null?void 0:W1.customSettings)==null?void 0:ei.comboAxisSettings)==null?void 0:ti.length)!==(i8==null?void 0:i8.length)&&W9(xe=>({...xe,customSettings:{...xe==null?void 0:xe.customSettings,comboAxisSettings:i8}}))},[W1==null?void 0:W1.yAxisList,(j5=W1==null?void 0:W1.customSettings)==null?void 0:j5.comboAxisSettings,W1==null?void 0:W1.comboBarList,(u4=W1==null?void 0:W1.customSettings)==null?void 0:u4.isCombineBarAxis,(y4=W1==null?void 0:W1.customSettings)==null?void 0:y4.isStackBar,(_e=(re=W1==null?void 0:W1.customSettings)==null?void 0:re.comboStackAxisSymbols)==null?void 0:_e.name,(Cr=(bt=W1==null?void 0:W1.customSettings)==null?void 0:bt.comboStackAxisSymbols)==null?void 0:Cr.prefix,(jn=(Bt=W1==null?void 0:W1.customSettings)==null?void 0:Bt.comboStackAxisSymbols)==null?void 0:jn.suffix,(qn=W1==null?void 0:W1.customSettings)==null?void 0:qn.comboLabelFormatter,(Vi=W1==null?void 0:W1.customSettings)==null?void 0:Vi.comboAxisSymbols,(Ji=W1==null?void 0:W1.customSettings)==null?void 0:Ji.numberFormatter,(qi=W1==null?void 0:W1.customSettings)==null?void 0:qi.combinedAxisPrefix,(ki=W1==null?void 0:W1.customSettings)==null?void 0:ki.combinedAxisSuffix,W1==null?void 0:W1.chartType]),z0.useEffect(()=>{var i8,r8,s9;(i8=W1==null?void 0:W1.yAxisList)!=null&&i8.length&&((r8=W1==null?void 0:W1.yAxisList)==null?void 0:r8.length)<5&&(W1==null?void 0:W1.chartType)===L0.boxplot&&W9(B8=>({...B8,chartType:L0.line})),!((s9=W1==null?void 0:W1.yAxisList)!=null&&s9.length)&&(W1==null?void 0:W1.chartType)===L0.funnelV2&&W9(B8=>({...B8,chartType:L0.singleValue}))},[W1==null?void 0:W1.chartType,($i=W1==null?void 0:W1.yAxisList)==null?void 0:$i.length]);const d4=({columnAlias:i8,value:r8,isClear:s9=!1})=>{const B8=t==null?void 0:t.datasetMetricSettings;B8&&yJ2({columnAlias:i8,datasetSettings:B8,setTableColumnFilters:y6,value:r8,isClear:s9})};return z0.useEffect(()=>{var r8,s9,B8,L9;if(!((r8=W1==null?void 0:W1.dynamicYAxis)!=null&&r8.isEnabled)||!((s9=W1==null?void 0:W1.dynamicYAxis)!=null&&s9.selectedOption)||Array.isArray((B8=W1==null?void 0:W1.dynamicYAxis)==null?void 0:B8.selectedOption))return;const i8=(L9=W1==null?void 0:W1.dynamicYAxis)==null?void 0:L9.selectedOption;W9(N8=>({...N8,dynamicYAxis:{...N8==null?void 0:N8.dynamicYAxis,selectedOption:[i8]},yAxisList:[i8==null?void 0:i8.value]}))},[(go=W1==null?void 0:W1.dynamicYAxis)==null?void 0:go.selectedOption,(yo=W1==null?void 0:W1.dynamicYAxis)==null?void 0:yo.isEnabled]),z0.useEffect(()=>{var B8,L9,N8,e5,B5,O5,f8,I9;const i8=(B8=g2==null?void 0:g2.yAxisSettings)==null?void 0:B8.find(l9=>{var O9,m4,$5,Ke,Ze;return((O9=l9==null?void 0:l9.yAxisSettings)==null?void 0:O9.isEnable)&&(l9==null?void 0:l9.id)===(t==null?void 0:t.id)&&((m4=l9==null?void 0:l9.yAxisSettings)==null?void 0:m4.yAxis)&&Array.isArray(($5=l9==null?void 0:l9.yAxisSettings)==null?void 0:$5.yAxis)&&((Ze=(Ke=l9==null?void 0:l9.yAxisSettings)==null?void 0:Ke.yAxis)==null?void 0:Ze.length)>0}),r8=(L9=g2==null?void 0:g2.xAxisSettings)==null?void 0:L9.find(l9=>{var O9,m4;return((O9=l9==null?void 0:l9.xAxisSettings)==null?void 0:O9.isEnable)&&(l9==null?void 0:l9.id)===(t==null?void 0:t.id)&&((m4=l9==null?void 0:l9.xAxisSettings)==null?void 0:m4.xaxis)});if(!((N8=W1==null?void 0:W1.dynamicYAxis)!=null&&N8.isEnabled)&&!((e5=W1==null?void 0:W1.dynamicXAxis)!=null&&e5.isEnabled)&&!((B5=J7==null?void 0:J7.configV2)!=null&&B5.isEnable)||!i8&&!r8&&!((O5=J7==null?void 0:J7.configV2)!=null&&O5.isEnable)){W9(l9=>(t==null?void 0:t.chartOptions)||l9);return}const s9=(I9=(f8=i8==null?void 0:i8.yAxisSettings)==null?void 0:f8.yAxis)==null?void 0:I9[0];W9(l9=>{var O9,m4,$5,Ke,Ze,pt,De;return{...l9,dynamicYAxis:{...l9==null?void 0:l9.dynamicYAxis,selectedOption:s9?[s9]:((O9=l9==null?void 0:l9.dynamicYAxis)==null?void 0:O9.selectedOption)||[]},dynamicXAxis:{...l9==null?void 0:l9.dynamicXAxis,selectedOption:(m4=r8==null?void 0:r8.xAxisSettings)!=null&&m4.xaxis?{value:($5=r8==null?void 0:r8.xAxisSettings)==null?void 0:$5.xaxis,label:(Ke=r8==null?void 0:r8.xAxisSettings)==null?void 0:Ke.xaxis}:((Ze=l9==null?void 0:l9.dynamicXAxis)==null?void 0:Ze.selectedOption)||[]},yAxisList:s9!=null&&s9.value?[s9==null?void 0:s9.value]:(l9==null?void 0:l9.yAxisList)||[],xAxis:(pt=r8==null?void 0:r8.xAxisSettings)!=null&&pt.xaxis?(De=r8==null?void 0:r8.xAxisSettings)==null?void 0:De.xaxis:(l9==null?void 0:l9.xAxis)||""}})},[g2==null?void 0:g2.yAxisSettings,t==null?void 0:t.id,g2==null?void 0:g2.xAxisSettings,(fn=W1==null?void 0:W1.dynamicYAxis)==null?void 0:fn.isEnabled,(Zr=W1==null?void 0:W1.dynamicXAxis)==null?void 0:Zr.isEnabled,(Xe=J7==null?void 0:J7.configV2)==null?void 0:Xe.isEnable]),z0.useEffect(()=>{var i8,r8,s9;(i8=W1==null?void 0:W1.customSettings)!=null&&i8.isShowDuration&&(W1==null?void 0:W1.chartType)===L0.gantt&&!((s9=(r8=W1==null?void 0:W1.customSettings)==null?void 0:r8.ganttTooltipKeys)!=null&&s9.includes("Duration"))&&W9(B8=>{var L9;return{...B8,customSettings:{...B8==null?void 0:B8.customSettings,ganttTooltipKeys:[...((L9=B8==null?void 0:B8.customSettings)==null?void 0:L9.ganttTooltipKeys)||[],"Duration"]}}})},[(Ln=W1==null?void 0:W1.customSettings)==null?void 0:Ln.isShowDuration,W1==null?void 0:W1.chartType,(wn=W1==null?void 0:W1.customSettings)==null?void 0:wn.ganttTooltipKeys]),{elementSummary:H0,elementSummaryError:J2,isLoadingSummary:b0,isMetricListLoading:c5,onDrillLevelClick:A5,onDrillDown:D9,handleChartClick:k8,dataDb:V3,getUnderlyingData:k3,onChangeFilterValue:z8,isShowChartPopup:t6,setShowChartPopup:C6,columnName:h5,chartParams:n3,isQueryLoading:x7||M2||G2,isSingleValueNull:t8,dynamicOptions:T5,chartSettings:W1,setChartSettings:W9,isEnableZoom:x8,filterValues:Q8,containerRef:J0,drilledLevel:k7.length,dimensions:((Ci=($n=t==null?void 0:t.datasetMetricSettings)==null?void 0:$n.selectedDimensions)==null?void 0:Ci.map(i8=>Qa2(i8||"none")))||[],rlsConditions:l3,setRlsConditions:c7,setTableLimit:L3,isEnableNextBtn:M1>(Y2==null?void 0:Y2.limit)+(Y2==null?void 0:Y2.offset),isEnablePrevBtn:(Y2==null?void 0:Y2.offset)!==0,paginationInfo:{limit:Y2==null?void 0:Y2.limit,offset:Y2==null?void 0:Y2.offset,totalRecords:M1},onChangePage:(i8,r8,s9)=>{L3(r8?{limit:r8,offset:0}:B8=>{let L9;return s9||s9===0?L9=s9:i8?L9=B8.offset>B8.limit?B8.offset-B8.limit:0:L9=B8.offset+B8.limit,{limit:B8.limit,offset:L9}})},isExternalChart:((wi=W1==null?void 0:W1.tableSettings)==null?void 0:wi.isServerSidePagination)&&(W1==null?void 0:W1.chartType)===L0.table,isEnablePivotTable:c8,groupByList:z7,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:i8=>{c7(r8=>r8==null?void 0:r8.map(s9=>s9.name===i8.name&&s9.datatype===i8.datatype&&s9.tableName===i8.tableName&&s9.columnName===i8.columnName?{...s9,isAddOnMetrics:!s9.isAddOnMetrics}:s9))},metricFilters:fe,leftPositionedMetricFilters:Y5,rightPositionedMetricFilters:Q6,drillFilters:k7,drillType:(pr=t==null?void 0:t.drillDownSettings)==null?void 0:pr.drillType,tableResultsDownloadData:k6,appliedMetricFilters:o9,pivotHeaderOptions:te,pivotDrillState:I6,onDrillPivotTable:E8,legendData:z9,timeseriesDimension:o8,isPythonMode:h8,sortOrder:e6,setSortOrder:l7,isNotFirstRender:o7,setNotFirstRender:m7,isSorted:H5,isInavlidForSort:_8,onAddComparison:y9,groupedRlsConditions:Te,onGenerateMetricSummary:p5,summary:v1,setSummary:h3,dataMartRelationships:Y6,onChartChange:k4,isCompareValue:D8,isShowChartPropertyPanel:U8,setShowChartPropertyPanel:$9,columnList:A6,variables:j8,metricName:B9,longDescription:S9,footNote:L5,description:c9,drilldownCols:G3,switchMeasureOptions:V4,metricExpressionResult:x5,dateFilter:X5,drillDownSettings:J7,enabledCharts:T4,tableColumnFilters:T3,onChangePaginationColumnFilters:d4,queryError:a7||(O6==null?void 0:O6.error),refetchMetricData:K6,customSwitchXAxis:x1}},A70=({metricId:t,onSuccess:n,token:i})=>{const{mutateAsync:o,isLoading:a}=S30();return{handleArchiveMetric:z0.useCallback(async()=>{!t||!i||await o({data:{id:t},token:i},{onSuccess:async r=>{r!=null&&r.error||await n()}})},[o,t]),isLoading:a}},Tu2=({token:t,metricId:n})=>{var R2;const[i,o]=z0.useState(!0),{data:a,isLoading:s}=r70(t,n),{externalMetric:r,sharingSettingsId:C,adminTheme:l,params:e,companyId:u,clientId:A,errorMsg:f,clientColumnType:d,isEnableMetricSummary:g,isAllClient:h,isShowUnderlyingData:m,appFilters:w,mergedMetricsId:Q,datasourceId:R,mergedMetricLayout:N,mergedDashboardFilters:O,dashboardAppFilterValues:X,filterLayout:K,nestedMetric:f2,guestToken:A2}=z0.useMemo(()=>{var P2,G2;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:(P2=M2==null?void 0:M2.error)==null?void 0:P2.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:(G2=window==null?void 0:window.dbn)!=null&&G2.isEnableProxyAuth?Od(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:b2,tenancyLevel:g2,workspaceId:j2}=z0.useMemo(()=>{var P2,G2;if(!e)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const M2=JSON.parse(e);return{rlsSettings:(P2=M2.rlsSettings)==null?void 0:P2.find(C0=>C0.metricId===n),tenancyLevel:M2.companyTenancyType||"TABLE",workspaceId:((G2=M2==null?void 0:M2.workspace)==null?void 0:G2.id)||""}},[e,n]);return z0.useEffect(()=>{s&&o(!0),(r||f||!s)&&o(!1)},[s,r,f]),{externalMetric:r,sharingSettingsId:C,companyId:u,clientId:A,rlsSettings:b2,tenancyLevel:g2,isLoading:i,errorMsg:f,adminTheme:l,workspaceId:j2,clientColumnType:d,isEnableMetricSummary:g,isAllClient:h,isShowUnderlyingData:m,appFilters:w,mergedMetricsId:Q,datasourceId:R,mergedMetricLayout:N,mergedDashboardFilters:O,dashboardAppFilterValues:X,filterLayout:K,nestedMetric:f2,token:A2}},c70=Qu2({active:null,over:null,DragPreviewCreateRoot:null,draggables:[],droppables:[]}),xu2=()=>{const[t,n]=M_(c70);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}},f70=({identifier:t,data:n,modifiers:i,events:o,CustomDragPreview:a,disabled:s=!1,dropText:r})=>{const{dndState:C,setActive:l,setDndState:e,setDraggables:u}=xu2(),[A,f]=z0.useState(!1),[d,g]=z0.useState(!0),[h,m]=z0.useState(null),w=z0.useRef(null),Q=z0.useRef(null),R={"data-type":t.type||t.id,id:`draggable-${t.id}`,role:"button",tabindex:"0",draggable:d?"true":"false","aria-grabbed":"false"},N=X=>{Object.entries(R).forEach(([K,f2])=>{X.setAttribute(K,f2)})},O=()=>{var X;Q.current&&((X=C.DragPreviewCreateRoot)==null||X.render(a))};return z0.useEffect(()=>{if(a&&(Q.current=document.getElementById("CustomDragPreviewContainer"),Q.current===null)){Q.current=document.createElement("div"),Q.current.setAttribute("id","CustomDragPreviewContainer"),document.body.appendChild(Q.current);const X=Uv2.createRoot(Q.current);e(K=>({...K,DragPreviewCreateRoot:X}))}},[]),z0.useEffect(()=>{if(w.current){const X=w.current.getBoundingClientRect();m(X),u({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:h,events:o,isDragging:A,isEnableDrag:d})}},[w.current,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i),JSON.stringify(o),JSON.stringify(A)]),z0.useEffect(()=>{const X=w.current;if(!X)return;N(X);const K=A2=>{var b2,g2,j2,R2;if(f(!0),l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:h,events:o,isDragging:A,isEnableDrag:d}),X.setAttribute("aria-grabbed","true"),r?(b2=A2.dataTransfer)==null||b2.setData("text/plain",r):(g2=A2.dataTransfer)==null||g2.setData("text/plain",JSON.stringify({data:n})),(j2=o==null?void 0:o.onDragStart)==null||j2.call(o,A2,C),Q.current){const M2=Q.current.getBoundingClientRect();(R2=A2.dataTransfer)==null||R2.setDragImage(Q.current,M2.width/2,M2.height/2)}},f2=A2=>{var b2;X.setAttribute("aria-grabbed","false"),f(!1),l(null),(b2=o==null?void 0:o.onDragEnd)==null||b2.call(o,A2,C)};return X.addEventListener("mousedown",()=>{a&&O()}),X.addEventListener("dragstart",K),X.addEventListener("dragend",f2),()=>{X.removeEventListener("dragstart",K),X.removeEventListener("dragend",f2)}},[w.current,JSON.stringify(t),JSON.stringify(n),C.DragPreviewCreateRoot]),z0.useEffect(()=>{const X=w.current;X&&X.setAttribute("draggable",d?"true":"false")},[d]),z0.useEffect(()=>{var K,f2,A2,b2;let X=[];return A&&(l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:h,events:o,isDragging:A,isEnableDrag:d}),(K=i==null?void 0:i.highlightDrop)!=null&&K.onDrag&&(X=((A2=(f2=C.droppables)==null?void 0:f2.filter(g2=>((g2==null?void 0:g2.identifier.accepts)??[]).includes(t.type??"")&&(g2==null?void 0:g2.isEnableDrop)))==null?void 0:A2.map(g2=>g2==null?void 0:g2.setDropNodeRef.current))??[],(b2=i==null?void 0:i.highlightDrop)!=null&&b2.onDrag&&X.forEach(g2=>{var j2;g2==null||g2.classList.add(((j2=i==null?void 0:i.highlightDrop)==null?void 0:j2.highlightClass)||"dnd-droppable-highlight")}))),()=>{X.forEach(g2=>{var j2;g2==null||g2.classList.remove(((j2=i==null?void 0:i.highlightDrop)==null?void 0:j2.highlightClass)||"dnd-droppable-highlight")})}},[A]),z0.useEffect(()=>{g(!s)},[s]),{isDragging:A,isEnableDrag:d,setIsEnableDrag:g,DragNodeRef:w}},Ru2=({identifier:t,events:n,modifiers:i})=>{var N;const{dndState:o,setOver:a,setDropables:s}=xu2(),[r,C]=z0.useState(null),[l,e]=z0.useState({isDragOver:!1,isDrop:!1}),[u,A]=z0.useState({before:-1,after:-1}),[f,d]=z0.useState(!0),g=z0.useRef(null),h={"data-type":((N=t.accepts)==null?void 0:N.join("-"))??"",id:`droppable-${t.id}`,droppable:f?"true":"false"},m=O=>{Object.entries(h).forEach(([X,K])=>{O.setAttribute(X,K)})},w=(O,X,K)=>{const f2=[...K];O=O===-1?f2.length-1:O;const[A2]=f2.splice(O,1);return X===-1?f2.push(A2):f2.splice(X,0,A2),f2},Q=(O,X,K)=>[...O.querySelectorAll('[draggable="true"]:not([aria-grabbed="true"])')].reduce((b2,g2,j2)=>{const R2=g2.getBoundingClientRect(),M2=X-R2[K==="horizontal"?"left":"top"]-R2[K==="horizontal"?"width":"height"]/2;return M2<0&&M2>b2.offset?{offset:M2,element:g2,index:j2}:b2},{offset:Number.NEGATIVE_INFINITY,element:null,index:-1}),R=(O,X,K)=>{const f2=[...O.querySelectorAll('[draggable="true"]')],A2=O.querySelector('[aria-grabbed="true"]'),{width:b2,height:g2}=K,j2=(M2,P2,G2)=>{const C0=M2.x-P2/2,m0=M2.y-G2/2;return[{x:C0,y:m0},{x:C0+P2,y:m0},{x:C0,y:m0+G2},{x:C0+P2,y:m0+G2}]};return f2.reduce((M2,P2,G2)=>{const C0=P2.getBoundingClientRect(),m0=[{x:C0.left,y:C0.top},{x:C0.left+C0.width,y:C0.top},{x:C0.left,y:C0.top+C0.height},{x:C0.left+C0.width,y:C0.top+C0.height}],H0=j2(X,b2,g2);let v0=Number.POSITIVE_INFINITY,J2=G2,U0=Number.POSITIVE_INFINITY,b0=Number.POSITIVE_INFINITY;return m0.forEach((k0,J0)=>{H0.forEach(Y2=>{let L3=Number.POSITIVE_INFINITY;U0=Math.sqrt((k0.x-Y2.x)**2+(k0.y-Y2.y)**2),b0=Math.sqrt((k0.x-X.x)**2+(k0.y-X.y)**2),L3=Math.min(U0,b0),L3<v0&&(v0=L3,J0===1||J0===3?A2!==P2&&(J2=G2+1):J2=G2)})}),v0<M2.minDistance?{minDistance:v0,element:P2,index:J2,closestBasedOnCorner:U0,closestBasedonCursor:b0}:M2},{minDistance:Number.POSITIVE_INFINITY,element:null,index:-1,closestBasedOnCorner:0,closestBasedonCursor:0})};return z0.useEffect(()=>{const O=g.current;if(!O)return;const X=O.getBoundingClientRect();C(X),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)]),z0.useEffect(()=>{var g2,j2;const O=g.current;if(m(O),!O||!f||(g2=t.accepts)!=null&&g2.length&&!t.accepts.includes(((j2=o.active)==null?void 0:j2.identifier.type)??""))return;const{sorting:X}=i||{},K=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)},f2=R2=>{var M2,P2,G2,C0,m0,H0,v0,J2,U0,b0,k0,J0;if(R2.preventDefault(),(G2=(P2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:P2.highlightDrop)!=null&&G2.onDragOver&&g.current.classList.add(((H0=(m0=(C0=o.active)==null?void 0:C0.modifiers)==null?void 0:m0.highlightDrop)==null?void 0:H0.highlightClass)||"dnd-droppable-highlight"),l.isDragOver||e(Y2=>({...Y2,isDragOver:!0})),o.over===null&&a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),X!=null&&X.isEnabled&&((v0=X.list)!=null&&v0.length)){const Y2=(b0=(U0=(J2=o.active)==null?void 0:J2.DragNodeRef)==null?void 0:U0.current)==null?void 0:b0.getAttribute("data-dbn-sorting-index");let L3=null;if((X.sortingType==="vertical"||X.sortingType==="horizontal")&&(L3=Q(O,(X==null?void 0:X.sortingType)==="horizontal"?R2.clientX:R2.clientY,X==null?void 0:X.sortingType)),X.sortingType==="both-axis"){const B3=(k0=document.getElementById("CustomDragPreviewContainer"))==null?void 0:k0.getBoundingClientRect();L3=R(O,{x:R2.clientX,y:R2.clientY},{width:(B3==null?void 0:B3.width)??0,height:(B3==null?void 0:B3.height)??0})}const M1={before:parseInt(Y2??-1,10),after:L3==null?void 0:L3.index};(M1.before!==u.before||M1.after!==u.after)&&A(M1)}(J0=n==null?void 0:n.onDragOver)==null||J0.call(n,R2,o)},A2=R2=>{var M2,P2,G2,C0,m0,H0,v0;R2.preventDefault(),(G2=(P2=(M2=o.active)==null?void 0:M2.modifiers)==null?void 0:P2.highlightDrop)!=null&&G2.onDragOver&&g.current.classList.remove(((H0=(m0=(C0=o.active)==null?void 0:C0.modifiers)==null?void 0:m0.highlightDrop)==null?void 0:H0.highlightClass)||"dnd-droppable-highlight"),e(J2=>({...J2,isDragOver:!1})),(v0=n==null?void 0:n.onDragLeave)==null||v0.call(n,R2,o),a(null)},b2=R2=>{var m0,H0,v0,J2,U0,b0,k0,J0,Y2,L3;R2.preventDefault();const M2=g.current.contains((H0=(m0=o.active)==null?void 0:m0.DragNodeRef)==null?void 0:H0.current);let P2={...o};(U0=(J2=(v0=o.active)==null?void 0:v0.modifiers)==null?void 0:J2.highlightDrop)!=null&&U0.onDragOver&&g.current.classList.remove(((J0=(k0=(b0=o.active)==null?void 0:b0.modifiers)==null?void 0:k0.highlightDrop)==null?void 0:J0.highlightClass)||"dnd-droppable-highlight");let{before:G2,after:C0}=u;if(X!=null&&X.isEnabled&&((Y2=X.list)!=null&&Y2.length)){let M1=[...X.list];M2?M1=w(G2,C0,M1):G2=-1,P2={...o,sorting:{sortedList:M1,isSelfDrop:M2,ArrayElementSwap:w,sortingIndexes:{before:G2,after:C0}}},X.isEnabledAutoSort&&M2&&X.setList(M1)}e(M1=>({...M1,isDrop:!0})),(L3=n==null?void 0:n.onDrop)==null||L3.call(n,R2,P2),a(null)};return O.addEventListener("dragenter",K),O.addEventListener("dragover",f2),O.addEventListener("dragleave",A2),O.addEventListener("drop",b2),()=>{O.removeEventListener("dragenter",K),O.removeEventListener("dragover",f2),O.removeEventListener("dragleave",A2),O.removeEventListener("drop",b2)}},[g.current,t,f,i,n,u]),z0.useEffect(()=>{const O=g.current;O&&O.setAttribute("droppable",f?"true":"false")},[f]),{dragStatus:l,isEnableDrop:f,setIsEnableDrop:d,setDropNodeRef:g}},d70=(t,n,i)=>({autoCompleteDropdownOptions:z0.useMemo(()=>{if(!n.length)return[];const a=[];return n.forEach(s=>{s.columnsWithDataType.forEach(r=>{var g;const C=PJ2(((g=r==null?void 0:r.dataType)==null?void 0:g.toLowerCase())||""),l=ZJ2(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(([h,m])=>{e.add(h),m&&u.add(m)}),C){case"DATE":Ix.forEach(h=>h.synonyms.forEach(A.add,A));break;case"NUMBER":TE.forEach(h=>h.synonymns.forEach(A.add,A));break;case"STRING":Eh.forEach(h=>h.synonyms.forEach(A.add,A)),lb2.forEach(h=>h.synonyms.forEach(A.add,A));break}fL.forEach(h=>h.synonymns.forEach(A.add,A));const f=l.flatMap(h=>(tb==null?void 0:tb[h.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(h=>{a.push({alias:h,datatype:r.dataType,name:h,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],distinctValueSynonyms:[...u],type:"VALUE"})})})}),a},[n,i,t])}),g70=(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)||sV}${x10}`,{method:"POST",body:JSON.stringify({fileName:t,dashboardId:n}),headers:{"Content-Type":"application/json",...a?{}:{"X-Plugin-Token":o||""},...CV()||{},"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)}}}),h70=()=>{const[t,n]=z0.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,h;const f=((d=window==null?void 0:window.dbn)==null?void 0:d.isEnableProxyAuth)||!1;try{n({downloadProgress:!0,isLoading:!0});const m=await fetch(`${((g=window.dbn)==null?void 0:g.proxyAuthUrl)||((h=window.dbn)==null?void 0:h.baseUrl)||sV}${i30}`,{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||""},...CV()||{},"X-Plugin-Origin":window.location.host,...r?{"X-Dbn-Secret":C}:{},...r?{"X-Dbn-token":p_()||""}:{}}});if(!m.ok)throw new Error("Network response was not ok");const w=await m.blob(),Q=URL.createObjectURL(w),R=document.createElement("a");R.href=Q,R.download=`${o}.zip`,R.style.display="none",document.body.appendChild(R),n({downloadProgress:!1,isLoading:!1}),rP&&(document!=null&&document.createEvent)||R.click(),URL.revokeObjectURL(Q),document.body.removeChild(R)}catch{n({downloadProgress:!1,isLoading:!1}),alert("Error downloading the file. Please try later.")}},downloadState:t}},E70=({dashboardId:t,fileName:n,token:i})=>{const[o,a]=z0.useState(""),[s,r]=z0.useState(!1),[C,l]=z0.useState({isGettingPdf:!1}),{toPDF:e}=g70(n,t);return{toPDF:async()=>{if(l({isGettingPdf:!0}),a(""),r(!1),!i){a(Nu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1});return}try{await e(i),r(!0),setTimeout(()=>{r(!1)},2e3),l({isGettingPdf:!1})}catch{a(Nu),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1})}},isGettingPdf:C==null?void 0:C.isGettingPdf,error:o,isPdfExported:s}},dV={downloadCsv:"_downloadCsv_z5r12_1",downloadCsvWrapper:"_downloadCsvWrapper_z5r12_9",downloadCsvNote:"_downloadCsvNote_z5r12_45",downloadCsvNoteText:"_downloadCsvNoteText_z5r12_59"},DA={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"},g5=({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:h,containerClassName:m="",containerStyle:w,customClassName:Q="",isFilter:R,isApplyDashboardColor:N,...O})=>{var X,K,f2,A2;return E.jsxs("div",{className:`${DA["inputField-container"]} ${Q}`,children:[E.jsxs("div",{className:DA.upperContainer,id:`${(K=(X=i??a)==null?void 0:X.replaceAll(" ","-"))==null?void 0:K.toLowerCase()}-input`,"data-testid":`${(A2=(f2=i??a)==null?void 0:f2.replaceAll(" ","-"))==null?void 0:A2.toLowerCase()}-input`,children:[i?E.jsxs(E.Fragment,{children:[d==="floating"&&E.jsxs("label",{htmlFor:a,className:`${DA.floatingLabel} ${R?"dbn-selectBox-text":""} ${R&&N?"dbn-selectBox":""}`,children:[i,h?E.jsx("span",{className:DA.important,children:"*"}):null]}),d==="static"&&E.jsx("label",{htmlFor:a,className:`${DA.label} ${R?"dbn-selectBox-text":""} ${R&&N?"dbn-selectBox":""}`,children:E.jsxs(q7,{variant:"input-label",color:"primary",children:[i,h?E.jsx("span",{className:DA.important,children:"*"}):null]})})]}):null,E.jsxs("div",{className:`${DA.inputContainer} ${R&&N?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""} ${m} `,style:w,children:[f&&E.jsx("div",{className:DA.inlineLabelContainer,children:E.jsx(q7,{variant:"heading-6",children:f})}),A&&E.jsx("div",{className:`${DA.prefixContainer} ${DA.supportText}`,children:A}),l&&E.jsx("div",{className:"dbn-p-2",children:l}),E.jsx("input",{...O,value:g,ref:s,id:a,type:t,className:`${DA.input} ${O.className||""} ${r?DA.error:""} ${g?DA.inputVal:""} ${R&&N?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""}`,...n,disabled:o}),e&&E.jsx("div",{className:"dbn-p-2",children:e}),u&&E.jsx("div",{className:`${DA.suffixContainer} ${DA.supportText}`,children:u})]})]}),C&&E.jsx("div",{className:DA.supportText,children:C}),r&&E.jsx(q7,{variant:"body-text-2",color:"alert",children:r})]})},Ud={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"},zu=({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=z0.useRef(),[g,h]=z0.useState(!1),[m,w]=z0.useState(!1),[Q,R]=z0.useState(!1),N=X=>{X.target.classList.contains(Ud.modal)?w(!0):w(!1)},O=X=>{X.target.classList.contains(Ud.modal)?R(!0):R(!1)};return z0.useEffect(()=>{Q&&m&&(R(!1),w(!1))},[Q,m]),E.jsx(pE,{children:n||f?E.jsx("div",{className:`${Ud.modal} ${A?"dbn-items-end dbn-py-0":""}`,onMouseDown:O,onMouseUp:N,ref:d,style:{...l?{zIndex:l}:{},...f?{display:n?void 0:"none"}:{}},children:E.jsxs("div",{className:`${Ud.popup} ${g?Ud.popupFullScreen:""} ${e?Ud[`popup-${e}`]:""} ${A?"dbn-my-0 dbn-rounded-b-none dbn-rounded-t-3xl":""}`,onClick:X=>{X.stopPropagation()},children:[u?null:E.jsx("section",{className:Ud.header,children:s||E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-items-start dbn-gap-1.5",children:[E.jsxs("div",{className:Ud.headerTitle,children:[C,E.jsx(q7,{variant:"heading-3",color:"primary",children:o})]}),a&&E.jsx("div",{className:Ud.subHeadingTitle,children:E.jsx(q7,{variant:"body-text-3",color:"sec-text",children:a})})]}),E.jsx(C8,{"data-testid":"close-modal",variant:"tertiary",type:"button",onClick:i,leftIcon:E.jsx(m8,{name:"cross",size:"small"}),style:{padding:"0",height:"20px"},className:"dbn-p-1.5"})]})}),E.jsx("section",{className:Ud.content,children:t})]})}):null})},$f=({children:t,className:n})=>E.jsx("section",{className:`${Ud.footer} ${n}`,children:t}),p70=t=>{if(!t.length)return!1;const n=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;return t.every(i=>n.test(i))},x_=({onCloseModal:t,sharingSettingsId:n,metricItem:i,workspaceId:o})=>{const{data:a}=C70(o),[s,r]=z0.useState(!1),[C,l]=z0.useState(""),{mutate:e}=D30(),{handleSubmit:u,register:A,setValue:f,control:d,formState:{errors:g}}=sb(),h=z0.useMemo(()=>{const w=a;return{expireTimeInMin:(w==null?void 0:w.expireTimeInMin)||30,isEnable:w==null?void 0:w.isEnable}},[a]);return{onSumbitSendCsvUrl:({values:w,query:Q})=>{r(!0),l("");const R=h.expireTimeInMin||30,N=new Date(Date.now()+R*60*1e3),O=Q,X=w.emails;if(!p70(X)){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:X,expireCsvFileAt:N,expireUrlIn:R*60,externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,query:O,sharingSettingsId:n,subject:w.subject},{onSuccess(K){K?(r(!1),l(""),t==null||t(!1)):(r(!1),l(Nu))},onError(){r(!1),l(Nu)}})},isDisableDownloadSettings:!n||!h.isEnable,downloadCsvError:C,handleSubmit:u,isLoading:s,register:A,control:d,setValue:f,errors:g}},iy={required:"Required"};({...iy},{...iy}),{...iy};const gV={"tag-text":"_tag-text_677jk_7",inputFieldContainer:"_inputFieldContainer_677jk_21","tag-container":"_tag-container_677jk_29",important:"_important_677jk_45"},R_=({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:h,error:m})=>{const[w,Q]=z0.useState(),[R,N]=z0.useState(""),O=b2=>{Q(w==null?void 0:w.filter(g2=>g2!==b2)),s==null||s(w==null?void 0:w.filter(g2=>g2!==b2))},X=()=>{const b2=R.split(",").map(R2=>R2.trim()).filter(Boolean),g2=new Set;for(const R2 of b2){if(g2.has(R2)){g==null||g(`Duplicate ${(f==null?void 0:f.toLocaleLowerCase())||"value"} in input: "${R2}"`);return}if(w!=null&&w.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}g2.add(R2)}const j2=[...w||[],...b2];Q(j2),s==null||s(j2),N(""),g==null||g("")},K=b2=>{if(b2.key==="Enter"||b2.key==="Tab")b2.preventDefault(),X();else if(b2.key==="Backspace"&&(R==null?void 0:R.length)===0){Q(j2=>(j2==null||j2.pop(),[...j2||[]])),w==null||w.pop();const g2=[...w||[]];s==null||s(g2)}},f2=()=>{X()};z0.useEffect(()=>{C&&Array.isArray(C)?Q(C):Q([])},[C]);const A2=b2=>{const g2=b2.target.parentElement;g2.scrollLeft=g2.scrollWidth,N(b2.target.value),r==null||r(b2.target.value)};return z0.useEffect(()=>{g==null||g("")},[R]),E.jsx(RE,{name:o||"tags",control:n,defaultValue:"",render:({field:b2})=>{var R2,M2,P2,G2;const{ref:g2,...j2}=b2;return E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[a?E.jsxs(q7,{variant:"input-label",color:"primary",children:[a,l?E.jsx("span",{className:gV.important,children:"*"}):null]}):null,E.jsxs("div",{className:gV.inputFieldContainer,style:{width:u},id:`${(M2=(R2=a??t)==null?void 0:R2.replaceAll(" ","-"))==null?void 0:M2.toLowerCase()}-input`,"data-testid":`${(G2=(P2=a??t)==null?void 0:P2.replaceAll(" ","-"))==null?void 0:G2.toLowerCase()}-input`,children:[w!=null&&w.length?E.jsx("div",{className:gV["tag-container"],children:w==null?void 0:w.map(C0=>E.jsx(C8,{variant:"popover",type:"button",onClick:()=>O(C0),className:"dbn-flex dbn-font-semibold dbn-gap-2 dbn-px-2 dbn-py-1 dbn-bg-gray dbn-rounded",rightIcon:E.jsx(m8,{name:"cross",size:"xxs"}),children:E.jsx("span",{className:gV["tag-text"],children:C0})},C0))}):null,E.jsx("input",{...j2,type:"text",value:R,onChange:A2,onKeyDown:K,placeholder:w!=null&&w.length?"":i,disabled:e,className:`dbn-outline-none dbn-border-none dbn-text-sm ${w!=null&&w.length?"dbn-max-w-[400px]":"dbn-w-full"} ${{...h}}`,onBlur:f2})]})]}),d&&E.jsx(Il,{text:d,variant:"error"}),!d&&m&&E.jsx(q7,{variant:"body-text-2",color:"alert",children:m})]})}})};k9.memo(R_);const ic={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:Hu2,setPrototypeOf:Du2,isFrozen:v70,getPrototypeOf:I70,getOwnPropertyDescriptor:m70}=Object;let{freeze:oc,seal:ed,create:Su2}=Object,{apply:H_,construct:D_}=typeof Reflect<"u"&&Reflect;oc||(oc=function(n){return n}),ed||(ed=function(n){return n}),H_||(H_=function(n,i,o){return n.apply(i,o)}),D_||(D_=function(n,i){return new n(...i)});const hV=sc(Array.prototype.forEach),b70=sc(Array.prototype.lastIndexOf),Nu2=sc(Array.prototype.pop),dM=sc(Array.prototype.push),B70=sc(Array.prototype.splice),EV=sc(String.prototype.toLowerCase),S_=sc(String.prototype.toString),Vu2=sc(String.prototype.match),gM=sc(String.prototype.replace),y70=sc(String.prototype.indexOf),L70=sc(String.prototype.trim),jd=sc(Object.prototype.hasOwnProperty),ac=sc(RegExp.prototype.test),hM=w70(TypeError);function sc(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 H_(t,n,o)}}function w70(t){return function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return D_(t,i)}}function nC(t,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:EV;Du2&&Du2(t,null);let o=n.length;for(;o--;){let a=n[o];if(typeof a=="string"){const s=i(a);s!==a&&(v70(n)||(n[o]=s),a=s)}t[a]=!0}return t}function Q70(t){for(let n=0;n<t.length;n++)jd(t,n)||(t[n]=null);return t}function Am(t){const n=Su2(null);for(const[i,o]of Hu2(t))jd(t,i)&&(Array.isArray(o)?n[i]=Q70(o):o&&typeof o=="object"&&o.constructor===Object?n[i]=Am(o):n[i]=o);return n}function EM(t,n){for(;t!==null;){const o=m70(t,n);if(o){if(o.get)return sc(o.get);if(typeof o.value=="function")return sc(o.value)}t=I70(t)}function i(){return null}return i}const ku2=oc(["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"]),N_=oc(["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"]),V_=oc(["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"]),M70=oc(["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"]),k_=oc(["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"]),T70=oc(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ou2=oc(["#text"]),Pu2=oc(["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"]),O_=oc(["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"]),Zu2=oc(["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"]),pV=oc(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),x70=ed(/\{\{[\w\W]*|[\w\W]*\}\}/gm),R70=ed(/<%[\w\W]*|[\w\W]*%>/gm),H70=ed(/\$\{[\w\W]*/gm),D70=ed(/^data-[\-\w.\u00B7-\uFFFF]+$/),S70=ed(/^aria-[\-\w]+$/),Fu2=ed(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),N70=ed(/^(?:\w+script|data):/i),V70=ed(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Uu2=ed(/^html$/i),k70=ed(/^[a-z][.\w]*(-[.\w]+)+$/i);var ju2=Object.freeze({__proto__:null,ARIA_ATTR:S70,ATTR_WHITESPACE:V70,CUSTOM_ELEMENT:k70,DATA_ATTR:D70,DOCTYPE_NAME:Uu2,ERB_EXPR:R70,IS_ALLOWED_URI:Fu2,IS_SCRIPT_OR_DATA:N70,MUSTACHE_EXPR:x70,TMPLIT_EXPR:H70});const pM={element:1,text:3,progressingInstruction:7,comment:8,document:9},O70=function(){return typeof window>"u"?null:window},P70=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}},zu2=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Gu2(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:O70();const n=r6=>Gu2(r6);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==pM.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,h=EM(g,"cloneNode"),m=EM(g,"remove"),w=EM(g,"nextSibling"),Q=EM(g,"childNodes"),R=EM(g,"parentNode");if(typeof r=="function"){const r6=i.createElement("template");r6.content&&r6.content.ownerDocument&&(i=r6.content.ownerDocument)}let N,O="";const{implementation:X,createNodeIterator:K,createDocumentFragment:f2,getElementsByTagName:A2}=i,{importNode:b2}=o;let g2=zu2();n.isSupported=typeof Hu2=="function"&&typeof R=="function"&&X&&X.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:j2,ERB_EXPR:R2,TMPLIT_EXPR:M2,DATA_ATTR:P2,ARIA_ATTR:G2,IS_SCRIPT_OR_DATA:C0,ATTR_WHITESPACE:m0,CUSTOM_ELEMENT:H0}=ju2;let{IS_ALLOWED_URI:v0}=ju2,J2=null;const U0=nC({},[...ku2,...N_,...V_,...k_,...Ou2]);let b0=null;const k0=nC({},[...Pu2,...O_,...Zu2,...pV]);let J0=Object.seal(Su2(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}})),Y2=null,L3=null,M1=!0,B3=!0,j3=!1,w7=!0,l3=!1,c7=!0,T3=!1,y6=!1,t6=!1,C6=!1,n3=!1,t0=!1,V3=!0,Z7=!1;const e6="user-content-";let l7=!0,A6=!1,w6={},v1=null;const h3=nC({},["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 o7=null;const m7=nC({},["audio","video","img","source","image","track"]);let G3=null;const J3=nC({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),k7="http://www.w3.org/1998/Math/MathML",W7="http://www.w3.org/2000/svg",J7="http://www.w3.org/1999/xhtml";let e8=J7,z7=!1,x6=null;const c8=nC({},[k7,W7,J7],S_);let h9=nC({},["mi","mo","mn","ms","mtext"]),U8=nC({},["annotation-xml"]);const $9=nC({},["title","style","font","a","script"]);let o9=null;const M9=["application/xhtml+xml","text/html"],j8="text/html";let y5=null,H5=null;const _5=i.createElement("form"),T5=function(q3){return q3 instanceof RegExp||q3 instanceof Function},S8=function(){let q3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(H5&&H5===q3)){if((!q3||typeof q3!="object")&&(q3={}),q3=Am(q3),o9=M9.indexOf(q3.PARSER_MEDIA_TYPE)===-1?j8:q3.PARSER_MEDIA_TYPE,y5=o9==="application/xhtml+xml"?S_:EV,J2=jd(q3,"ALLOWED_TAGS")?nC({},q3.ALLOWED_TAGS,y5):U0,b0=jd(q3,"ALLOWED_ATTR")?nC({},q3.ALLOWED_ATTR,y5):k0,x6=jd(q3,"ALLOWED_NAMESPACES")?nC({},q3.ALLOWED_NAMESPACES,S_):c8,G3=jd(q3,"ADD_URI_SAFE_ATTR")?nC(Am(J3),q3.ADD_URI_SAFE_ATTR,y5):J3,o7=jd(q3,"ADD_DATA_URI_TAGS")?nC(Am(m7),q3.ADD_DATA_URI_TAGS,y5):m7,v1=jd(q3,"FORBID_CONTENTS")?nC({},q3.FORBID_CONTENTS,y5):h3,Y2=jd(q3,"FORBID_TAGS")?nC({},q3.FORBID_TAGS,y5):{},L3=jd(q3,"FORBID_ATTR")?nC({},q3.FORBID_ATTR,y5):{},w6=jd(q3,"USE_PROFILES")?q3.USE_PROFILES:!1,M1=q3.ALLOW_ARIA_ATTR!==!1,B3=q3.ALLOW_DATA_ATTR!==!1,j3=q3.ALLOW_UNKNOWN_PROTOCOLS||!1,w7=q3.ALLOW_SELF_CLOSE_IN_ATTR!==!1,l3=q3.SAFE_FOR_TEMPLATES||!1,c7=q3.SAFE_FOR_XML!==!1,T3=q3.WHOLE_DOCUMENT||!1,C6=q3.RETURN_DOM||!1,n3=q3.RETURN_DOM_FRAGMENT||!1,t0=q3.RETURN_TRUSTED_TYPE||!1,t6=q3.FORCE_BODY||!1,V3=q3.SANITIZE_DOM!==!1,Z7=q3.SANITIZE_NAMED_PROPS||!1,l7=q3.KEEP_CONTENT!==!1,A6=q3.IN_PLACE||!1,v0=q3.ALLOWED_URI_REGEXP||Fu2,e8=q3.NAMESPACE||J7,h9=q3.MATHML_TEXT_INTEGRATION_POINTS||h9,U8=q3.HTML_INTEGRATION_POINTS||U8,J0=q3.CUSTOM_ELEMENT_HANDLING||{},q3.CUSTOM_ELEMENT_HANDLING&&T5(q3.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(J0.tagNameCheck=q3.CUSTOM_ELEMENT_HANDLING.tagNameCheck),q3.CUSTOM_ELEMENT_HANDLING&&T5(q3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(J0.attributeNameCheck=q3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),q3.CUSTOM_ELEMENT_HANDLING&&typeof q3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(J0.allowCustomizedBuiltInElements=q3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),l3&&(B3=!1),n3&&(C6=!0),w6&&(J2=nC({},Ou2),b0=[],w6.html===!0&&(nC(J2,ku2),nC(b0,Pu2)),w6.svg===!0&&(nC(J2,N_),nC(b0,O_),nC(b0,pV)),w6.svgFilters===!0&&(nC(J2,V_),nC(b0,O_),nC(b0,pV)),w6.mathMl===!0&&(nC(J2,k_),nC(b0,Zu2),nC(b0,pV))),q3.ADD_TAGS&&(J2===U0&&(J2=Am(J2)),nC(J2,q3.ADD_TAGS,y5)),q3.ADD_ATTR&&(b0===k0&&(b0=Am(b0)),nC(b0,q3.ADD_ATTR,y5)),q3.ADD_URI_SAFE_ATTR&&nC(G3,q3.ADD_URI_SAFE_ATTR,y5),q3.FORBID_CONTENTS&&(v1===h3&&(v1=Am(v1)),nC(v1,q3.FORBID_CONTENTS,y5)),l7&&(J2["#text"]=!0),T3&&nC(J2,["html","head","body"]),J2.table&&(nC(J2,["tbody"]),delete Y2.tbody),q3.TRUSTED_TYPES_POLICY){if(typeof q3.TRUSTED_TYPES_POLICY.createHTML!="function")throw hM('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof q3.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hM('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=q3.TRUSTED_TYPES_POLICY,O=N.createHTML("")}else N===void 0&&(N=P70(d,a)),N!==null&&typeof O=="string"&&(O=N.createHTML(""));oc&&oc(q3),H5=q3}},W1=nC({},[...N_,...V_,...M70]),W9=nC({},[...k_,...T70]),I6=function(q3){let Z6=R(q3);(!Z6||!Z6.tagName)&&(Z6={namespaceURI:e8,tagName:"template"});const o8=EV(q3.tagName),D8=EV(Z6.tagName);return x6[q3.namespaceURI]?q3.namespaceURI===W7?Z6.namespaceURI===J7?o8==="svg":Z6.namespaceURI===k7?o8==="svg"&&(D8==="annotation-xml"||h9[D8]):!!W1[o8]:q3.namespaceURI===k7?Z6.namespaceURI===J7?o8==="math":Z6.namespaceURI===W7?o8==="math"&&U8[D8]:!!W9[o8]:q3.namespaceURI===J7?Z6.namespaceURI===W7&&!U8[D8]||Z6.namespaceURI===k7&&!h9[D8]?!1:!W9[o8]&&($9[o8]||!W1[o8]):!!(o9==="application/xhtml+xml"&&x6[q3.namespaceURI]):!1},l8=function(q3){dM(n.removed,{element:q3});try{R(q3).removeChild(q3)}catch{m(q3)}},h8=function(q3,Z6){try{dM(n.removed,{attribute:Z6.getAttributeNode(q3),from:Z6})}catch{dM(n.removed,{attribute:null,from:Z6})}if(Z6.removeAttribute(q3),q3==="is")if(C6||n3)try{l8(Z6)}catch{}else try{Z6.setAttribute(q3,"")}catch{}},Y6=function(q3){let Z6=null,o8=null;if(t6)q3="<remove></remove>"+q3;else{const k8=Vu2(q3,/^[\r\n\t ]+/);o8=k8&&k8[0]}o9==="application/xhtml+xml"&&e8===J7&&(q3='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+q3+"</body></html>");const D8=N?N.createHTML(q3):q3;if(e8===J7)try{Z6=new f().parseFromString(D8,o9)}catch{}if(!Z6||!Z6.documentElement){Z6=X.createDocument(e8,"template",null);try{Z6.documentElement.innerHTML=z7?O:D8}catch{}}const z8=Z6.body||Z6.documentElement;return q3&&o8&&z8.insertBefore(i.createTextNode(o8),z8.childNodes[0]||null),e8===J7?A2.call(Z6,T3?"html":"body")[0]:T3?Z6.documentElement:z8},Q8=function(q3){return K.call(q3.ownerDocument||q3,q3,e.SHOW_ELEMENT|e.SHOW_COMMENT|e.SHOW_TEXT|e.SHOW_PROCESSING_INSTRUCTION|e.SHOW_CDATA_SECTION,null)},x1=function(q3){return q3 instanceof A&&(typeof q3.nodeName!="string"||typeof q3.textContent!="string"||typeof q3.removeChild!="function"||!(q3.attributes instanceof u)||typeof q3.removeAttribute!="function"||typeof q3.setAttribute!="function"||typeof q3.namespaceURI!="string"||typeof q3.insertBefore!="function"||typeof q3.hasChildNodes!="function")},L7=function(q3){return typeof C=="function"&&q3 instanceof C};function O6(r6,q3,Z6){hV(r6,o8=>{o8.call(n,q3,Z6,H5)})}const x7=function(q3){let Z6=null;if(O6(g2.beforeSanitizeElements,q3,null),x1(q3))return l8(q3),!0;const o8=y5(q3.nodeName);if(O6(g2.uponSanitizeElement,q3,{tagName:o8,allowedTags:J2}),q3.hasChildNodes()&&!L7(q3.firstElementChild)&&ac(/<[/\w]/g,q3.innerHTML)&&ac(/<[/\w]/g,q3.textContent)||q3.nodeType===pM.progressingInstruction||c7&&q3.nodeType===pM.comment&&ac(/<[/\w]/g,q3.data))return l8(q3),!0;if(!J2[o8]||Y2[o8]){if(!Y2[o8]&&K6(o8)&&(J0.tagNameCheck instanceof RegExp&&ac(J0.tagNameCheck,o8)||J0.tagNameCheck instanceof Function&&J0.tagNameCheck(o8)))return!1;if(l7&&!v1[o8]){const D8=R(q3)||q3.parentNode,z8=Q(q3)||q3.childNodes;if(z8&&D8){const k8=z8.length;for(let k3=k8-1;k3>=0;--k3){const h5=h(z8[k3],!0);h5.__removalCount=(q3.__removalCount||0)+1,D8.insertBefore(h5,w(q3))}}}return l8(q3),!0}return q3 instanceof l&&!I6(q3)||(o8==="noscript"||o8==="noembed"||o8==="noframes")&&ac(/<\/no(script|embed|frames)/i,q3.innerHTML)?(l8(q3),!0):(l3&&q3.nodeType===pM.text&&(Z6=q3.textContent,hV([j2,R2,M2],D8=>{Z6=gM(Z6,D8," ")}),q3.textContent!==Z6&&(dM(n.removed,{element:q3.cloneNode()}),q3.textContent=Z6)),O6(g2.afterSanitizeElements,q3,null),!1)},a7=function(q3,Z6,o8){if(V3&&(Z6==="id"||Z6==="name")&&(o8 in i||o8 in _5))return!1;if(!(B3&&!L3[Z6]&&ac(P2,Z6))){if(!(M1&&ac(G2,Z6))){if(!b0[Z6]||L3[Z6]){if(!(K6(q3)&&(J0.tagNameCheck instanceof RegExp&&ac(J0.tagNameCheck,q3)||J0.tagNameCheck instanceof Function&&J0.tagNameCheck(q3))&&(J0.attributeNameCheck instanceof RegExp&&ac(J0.attributeNameCheck,Z6)||J0.attributeNameCheck instanceof Function&&J0.attributeNameCheck(Z6))||Z6==="is"&&J0.allowCustomizedBuiltInElements&&(J0.tagNameCheck instanceof RegExp&&ac(J0.tagNameCheck,o8)||J0.tagNameCheck instanceof Function&&J0.tagNameCheck(o8))))return!1}else if(!G3[Z6]){if(!ac(v0,gM(o8,m0,""))){if(!((Z6==="src"||Z6==="xlink:href"||Z6==="href")&&q3!=="script"&&y70(o8,"data:")===0&&o7[q3])){if(!(j3&&!ac(C0,gM(o8,m0,"")))){if(o8)return!1}}}}}}return!0},K6=function(q3){return q3!=="annotation-xml"&&Vu2(q3,H0)},o6=function(q3){O6(g2.beforeSanitizeAttributes,q3,null);const{attributes:Z6}=q3;if(!Z6||x1(q3))return;const o8={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:b0,forceKeepAttr:void 0};let D8=Z6.length;for(;D8--;){const z8=Z6[D8],{name:k8,namespaceURI:k3,value:h5}=z8,I8=y5(k8);let D9=k8==="value"?h5:L70(h5);if(o8.attrName=I8,o8.attrValue=D9,o8.keepAttr=!0,o8.forceKeepAttr=void 0,O6(g2.uponSanitizeAttribute,q3,o8),D9=o8.attrValue,Z7&&(I8==="id"||I8==="name")&&(h8(k8,q3),D9=e6+D9),c7&&ac(/((--!?|])>)|<\/(style|title)/i,D9)){h8(k8,q3);continue}if(o8.forceKeepAttr||(h8(k8,q3),!o8.keepAttr))continue;if(!w7&&ac(/\/>/i,D9)){h8(k8,q3);continue}l3&&hV([j2,R2,M2],A5=>{D9=gM(D9,A5," ")});const E8=y5(q3.nodeName);if(a7(E8,I8,D9)){if(N&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!k3)switch(d.getAttributeType(E8,I8)){case"TrustedHTML":{D9=N.createHTML(D9);break}case"TrustedScriptURL":{D9=N.createScriptURL(D9);break}}try{k3?q3.setAttributeNS(k3,k8,D9):q3.setAttribute(k8,D9),x1(q3)?l8(q3):Nu2(n.removed)}catch{}}}O6(g2.afterSanitizeAttributes,q3,null)},N7=function r6(q3){let Z6=null;const o8=Q8(q3);for(O6(g2.beforeSanitizeShadowDOM,q3,null);Z6=o8.nextNode();)O6(g2.uponSanitizeShadowNode,Z6,null),x7(Z6),o6(Z6),Z6.content instanceof s&&r6(Z6.content);O6(g2.afterSanitizeShadowDOM,q3,null)};return n.sanitize=function(r6){let q3=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Z6=null,o8=null,D8=null,z8=null;if(z7=!r6,z7&&(r6="<!-->"),typeof r6!="string"&&!L7(r6))if(typeof r6.toString=="function"){if(r6=r6.toString(),typeof r6!="string")throw hM("dirty is not a string, aborting")}else throw hM("toString is not a function");if(!n.isSupported)return r6;if(y6||S8(q3),n.removed=[],typeof r6=="string"&&(A6=!1),A6){if(r6.nodeName){const h5=y5(r6.nodeName);if(!J2[h5]||Y2[h5])throw hM("root node is forbidden and cannot be sanitized in-place")}}else if(r6 instanceof C)Z6=Y6("<!---->"),o8=Z6.ownerDocument.importNode(r6,!0),o8.nodeType===pM.element&&o8.nodeName==="BODY"||o8.nodeName==="HTML"?Z6=o8:Z6.appendChild(o8);else{if(!C6&&!l3&&!T3&&r6.indexOf("<")===-1)return N&&t0?N.createHTML(r6):r6;if(Z6=Y6(r6),!Z6)return C6?null:t0?O:""}Z6&&t6&&l8(Z6.firstChild);const k8=Q8(A6?r6:Z6);for(;D8=k8.nextNode();)x7(D8),o6(D8),D8.content instanceof s&&N7(D8.content);if(A6)return r6;if(C6){if(n3)for(z8=f2.call(Z6.ownerDocument);Z6.firstChild;)z8.appendChild(Z6.firstChild);else z8=Z6;return(b0.shadowroot||b0.shadowrootmode)&&(z8=b2.call(o,z8,!0)),z8}let k3=T3?Z6.outerHTML:Z6.innerHTML;return T3&&J2["!doctype"]&&Z6.ownerDocument&&Z6.ownerDocument.doctype&&Z6.ownerDocument.doctype.name&&ac(Uu2,Z6.ownerDocument.doctype.name)&&(k3="<!DOCTYPE "+Z6.ownerDocument.doctype.name+`>
588
588
  `+k3),l3&&hV([j2,R2,M2],h5=>{k3=gM(k3,h5," ")}),N&&t0?N.createHTML(k3):k3},n.setConfig=function(){let r6=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};S8(r6),y6=!0},n.clearConfig=function(){H5=null,y6=!1},n.isValidAttribute=function(r6,q3,Z6){H5||S8({});const o8=y5(r6),D8=y5(q3);return a7(o8,D8,Z6)},n.addHook=function(r6,q3){typeof q3=="function"&&dM(g2[r6],q3)},n.removeHook=function(r6,q3){if(q3!==void 0){const Z6=b70(g2[r6],q3);return Z6===-1?void 0:B70(g2[r6],Z6,1)[0]}return Nu2(g2[r6])},n.removeHooks=function(r6){g2[r6]=[]},n.removeAllHooks=function(){g2=zu2()},n}var Z70=Gu2();const vV=t=>Z70.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}}),Wa=({children:t,text:n,bulletText:i,className:o="",position:a="bottom",tooltipClass:s="",isSingleLineTxt:r=!0,showTooltip:C=!0,isAllowPosChange:l=!1})=>{const e=z0.useRef(null),[u,A]=z0.useState(a),f=312,d=40,g=z0.useCallback(()=>{if(!e.current||!l)return;const m=e.current.getBoundingClientRect(),w=window.innerWidth,Q=window.innerHeight,R=f/2;let N=m.right+f>w,O=m.left-f<0;(a.startsWith("top")||a.startsWith("bottom"))&&(N=m.left+R>w,O=m.right-R<0);const X=m.top-d<0,K=m.bottom+d>Q,A2={top:X?"bottom":N?"top-right":O?"top-left":"top",bottom:K?"top":N?"bottom-right":O?"bottom-left":"bottom",left:O?"right":"left",right:N?"left":"right","top-left":X&&O?"bottom-right":X?"bottom-left":O?"top-right":"top-left","top-right":X&&N?"bottom-left":X?"bottom-right":N?"top-left":"top-right","bottom-left":K&&O?"top-right":K?"top-left":O?"bottom-right":"bottom-left","bottom-right":K&&N?"top-left":K?"top-right":N?"bottom-left":"bottom-right","left-top-end":O&&X?"right-bottom-end":O?"right-top-end":X?"left-bottom-end":"left-top-end","left-bottom-end":O&&K?"right-top-end":O?"right-bottom-end":K?"left-top-end":"left-bottom-end","right-top-end":N&&X?"left-bottom-end":N?"left-top-end":X?"right-bottom-end":"right-top-end","right-bottom-end":N&&K?"left-top-end":N?"left-bottom-end":K?"right-top-end":"right-bottom-end"}[a]||a;A2!==u&&A(A2)},[a,u,l]);z0.useEffect(()=>{if(!C||!l)return;g(),window.addEventListener("resize",g),window.addEventListener("scroll",g);const m=e.current;return m&&m.addEventListener("mouseenter",g),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g),m&&m.removeEventListener("mouseenter",g)}},[C,l,g]);const h=(n||i)&&C;return E.jsxs("div",{ref:e,className:`${ic.container} ${o}`,children:[t,h&&E.jsxs("span",{className:`${ic.tooltip} ${s} ${ic[u]} ${r?"dbn-p-3":"dbn-p-4"} dbn-w-max`,style:{maxWidth:`${f}px`},children:[n&&E.jsx(q7,{variant:"body-text-2",color:"white",children:n}),i&&E.jsx("ul",{className:"dbn-w-full",children:i.map((m,w)=>E.jsxs("li",{className:"dbn-flex dbn-gap-2",children:[E.jsx(q7,{variant:"body-text-2",color:"white",children:"•"}),E.jsx(q7,{variant:"body-text-2",color:"white",children:m})]},w))})]})]})},Yu2=({children:t,text:n,subText:i,className:o,position:a="bottom",tooltipClass:s="",headingIcon:r})=>E.jsx(E.Fragment,{children:E.jsxs("div",{className:`${ic.container} ${o}`,children:[t,!n&&!i?null:E.jsx("span",{className:`${ic.subTooltip} ${s} ${ic[a]} ${i?ic.subPadding:ic.textPadding}`,style:{maxWidth:"246px"},children:E.jsxs("span",{className:"dbn-flex dbn-flex-col dbn-gap-2 ",children:[n?E.jsxs("span",{className:ic.heading,children:[r?E.jsx(m8,{name:r,color:"white"}):null," ",E.jsx(q7,{variant:"sec-heading-4",color:"white",children:n})]},n):null,i?E.jsx("span",{className:ic.subText,children:i},i):null]})})]})}),sf=({children:t,className:n,iconConfig:i,position:o,tooltipClass:a,text:s,isSingleLineTxt:r})=>E.jsx(Wa,{className:n,position:o,tooltipClass:`${a} dbn-w-max`,text:s,isSingleLineTxt:r,children:E.jsx(m8,{name:"info",size:i==null?void 0:i.size,color:i==null?void 0:i.color})}),Wu2=({title:t,html:n,className:i,position:o="right-top",setHoverLongDesc:a})=>{const[s,r]=z0.useState(!1),C=z0.useRef(null);return z0.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]),E.jsxs("div",{ref:C,"data-testid":`longDesc-${t==null?void 0:t.toLowerCase().replaceAll(" ","-")}`,className:`${ic.container} ${s?ic.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:[E.jsx(m8,{name:"info",size:"xs"}),E.jsx("div",{className:`${ic.tooltipMetric} ${ic[o]} ${i} dbn-longDesc`,children:E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[E.jsx("div",{className:"dbn-mx-1 dbn-text-sm dbn-text-left",children:E.jsx(q7,{variant:"sec-heading-4",color:"white",children:t})}),E.jsx("div",{className:`${ic.addedLink} dbn-p-1`,dangerouslySetInnerHTML:{__html:vV(n||"")}})]})})]})},IV=({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}=x_({onCloseModal:t,metricItem:i,sharingSettingsId:a,workspaceId:s}),h=()=>{var m;return E.jsx(E.Fragment,{children:E.jsxs("form",{onSubmit:C(w=>e({values:w,query:o})),children:[E.jsxs("div",{className:dV.downloadCsvWrapper,children:[E.jsx(g5,{type:"subject",label:"Subject",placeholder:"enter a subject",register:u("subject",iy),defaultValue:i==null?void 0:i.name,error:(m=g.subject)==null?void 0:m.message,isImportant:!0}),E.jsxs("div",{className:"dbn-w-full dbn-flex dbn-gap-1 dbn-flex-col",children:[E.jsxs("div",{className:"dbn-w-full dbn-flex dbn-gap-2",children:[E.jsxs(q7,{variant:"input-label",children:["Send to ",E.jsx("span",{className:"dbn-text-alert",children:"*"})]}),E.jsx(sf,{text:"Enter multiple email addresses separated by enter",iconConfig:{size:"xs",color:"primary-dark"},isSingleLineTxt:!1})]}),E.jsx(R_,{control:A,type:"text",label:"",placeholder:"Enter email addresses",onChangeTags:w=>f("emails",w),width:"100%",onChange:w=>f("emails",[w.trim()])})]}),r&&E.jsx(yx,{message:r}),E.jsx("div",{className:dV.downloadCsvNote,children:E.jsx("div",{className:dV.downloadCsvNoteText,children:E.jsxs(q7,{variant:"body-text-2",children:[E.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"]})})})]}),E.jsxs($f,{children:[E.jsx(C8,{variant:"tab",type:"button",onClick:()=>t(!1),isDisabled:l,children:"Cancel"}),E.jsx(C8,{variant:"primary",type:"submit",isDisabled:l||d,children:"Submit"})]})]})})};return E.jsx(zu,{isOpen:n,onClose:()=>t(!1),headerTitle:"Download Raw CSV",zIndex:99999999999,children:E.jsx("div",{className:dV.downloadCsv,children:E.jsx(h,{})})})},F70=k9.memo(IV),U70=({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:h,metricFilterOptions:m,enableDownloadCsv:w,enableMultiMetricFilters:Q,metricFilterPosition:R,enableEmailCsv:N,isDisableCardTitle:O,disableDownloadPng:X,onMinimize:K,isHideChartSettings:f2,isHideTablePreview:A2,dataMartRelationships:b2,isEnableCumulative:g2,isEnableDynamic:j2,isEnableStack:R2,metricCardColor:M2,language:P2,translationDictionary:G2,globalFilters:C0,calendarType:m0,isDisableClick:H0,disableDownloadDataNoFilters:v0=!1,disableDownloadUnderlyingDataNoFilters:J2=!1})=>{var V3;const[U0,b0]=z0.useState([]),[k0,J0]=z0.useState({isShow:!1}),[Y2,L3]=z0.useState({show:!1,filterValues:void 0}),{externalMetric:M1,rlsSettings:B3,sharingSettingsId:j3,companyId:w7,clientId:l3,tenancyLevel:c7,workspaceId:T3,clientColumnType:y6,isEnableMetricSummary:t6,isAllClient:C6,appFilters:n3,datasourceId:t0}=Tu2({token:t,metricId:n});return E.jsxs(E.Fragment,{children:[E.jsx(Rk,{disableDownloadDataNoFilters:v0,disableDownloadUnderlyingDataNoFilters:J2,calendarType:m0,disableFullscreen:!!g,language:P2,translationDictionary:G2,datasourceId:t0,isAllClient:C6,disableBorder:i,noDataImg:o,isShadowDisableOnHover:a||!1,isAllowedToSeeUnderlyingData:s,clientColumnType:y6,isEnableCumulative:g2,isDisableClick:H0,isEnableDynamic:j2,isEnableStack:R2,chartAppearance:r,hideDatePickerOptions:C,metricCardColor:M2,workspaceId:T3,guestToken:t,isFrontendApp:!1,downloadMetrics:U0,appearanceOptions:l,onDownload:(Z7,e6)=>{b0(e6?l7=>[...l7,{id:Z7,isInProgress:e6}]:l7=>l7.filter(A6=>A6.id!==Z7))},metricItem:M1,client:l3,dropdownTheme:e,underlyingTheme:u,colors:A||f,optionsIcon:d,onMaximize:g?void 0:({rlsFilters:Z7,appliedMetricFilters:e6})=>J0({isShow:!0,rlsFilters:Z7,appliedMetricFilters:e6}),companyTenancyType:c7,chartRendererType:h,param:B3,metricFilterOptions:m,enableDownloadCsv:w,enableMultiMetricFilters:Q,metricFilterPosition:R,onDownloadRawCsv:N?Z7=>L3({show:!0,filterValues:Z7}):void 0,isDisableCardTitle:O,appFilters:n3,isMergedMetric:!0,globalFilters:C0}),E.jsx(pE,{children:!g&&k0.isShow?E.jsx(Sk,{disableDownloadDataNoFilters:v0,disableDownloadUnderlyingDataNoFilters:J2,calendarType:m0,language:P2,translationDictionary:G2,appliedMetricFilters:(k0==null?void 0:k0.appliedMetricFilters)||[],datasourceId:t0,appFilters:n3,isAllClient:C6,isEnableMetricSummary:t6,hideDatePickerOptions:C,disableDownloadPng:X,chartAppearance:r,clientColumnType:y6,workspaceId:T3,guestToken:t,isFrontendApp:!1,downloadMetrics:U0,onDownload:(Z7,e6)=>{b0(e6?l7=>[...l7,{id:Z7,isInProgress:e6}]:l7=>l7.filter(A6=>A6.id!==Z7))},metric:M1,clientId:l3,colors:A||f,onMinimize:()=>{J0({isShow:!1}),K==null||K()},companyId:w7,tenancyLevel:c7,rlsFilters:k0.rlsFilters,sharingSettingsId:j3,externalDashboardId:"",userProvidedDashboardId:"",isShowChartConfigTab:!1,isHideChartSettings:f2,isHideTablePreview:A2,metricFilterOptions:m,globalFilters:C0}):null}),N&&E.jsx(F70,{workspaceId:T3,metricItem:M1,isShowRawCsvModal:Y2.show,onCloseModal:()=>L3({show:!1,filterValues:void 0}),sharingSettingsId:j3,query:lb({query:Od((M1==null?void 0:M1.query)||"",w7||""),dbName:(M1==null?void 0:M1.integrationName)||"",rlsConditions:((V3=M1==null?void 0:M1.rlsConditions)==null?void 0:V3.filter(Z7=>Z7.isAddOnMetrics))||[],tenancyLevel:c7,clientId:l3,values:Y2.filterValues,isAllClient:!1,clientColumnType:y6,dataMartRelationships:b2})})]})},mV="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",hC={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"},P_=({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 X,K;const[A,f]=z0.useState(i||{min:null,max:null}),d=(i==null?void 0:i.min)===null||(i==null?void 0:i.max)===null,g=z0.useRef(null),[h,m]=z0.useState(""),[w,Q]=z0.useState(""),R=()=>{var f2;f({min:null,max:null}),m(""),Q(""),(f2=g.current)==null||f2.click(),n&&t?t(A2=>A2==null?void 0:A2.filter(b2=>b2.label!==(n==null?void 0:n.label))):a&&(a==null||a(void 0))},N=()=>{var f2;if(A.min===null||A.max===null){Q("Invalid value");return}n&&t?t(A2=>{const b2={column:n.name,operator:qm,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||[]},g2=A2.findIndex(R2=>R2.label===n.label);if(g2===-1)return[...A2,b2];const j2=[...A2];return j2[g2]=b2,j2}):a&&(a==null||a({min:A.min,max:A.max})),m(`Between ${A.min} to ${A.max}`),Q(""),(f2=g.current)==null||f2.click()};z0.useEffect(()=>{f(i&&!d?i:{min:null,max:null}),m(i&&!d?`Between ${i.min} to ${i.max}`:"")},[i==null?void 0:i.max,i==null?void 0:i.min,d]);const O=window.CSS&&CSS.supports("width","clamp(1px, 1px, 1px)");return E.jsx(E.Fragment,{children:E.jsx(ul,{position:"bottom-start",buttonWidth:O&&e?`clamp(100px, 13cqw, ${C})`:C,tabMenu:!0,menuWidth:"200px",isDisabled:u,buttonContent:E.jsxs(E.Fragment,{children:[r==="static"&&E.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)}),E.jsxs("div",{className:hC.numberField,style:{borderRadius:l||"4px",containerType:"inline-size",opacity:u?.6:1},ref:g,"data-testid":(X=(n==null?void 0:n.label)||(n==null?void 0:n.name))==null?void 0:X.toLowerCase().replaceAll(" ","-").concat("-dropdown"),children:[E.jsxs("div",{className:hC.numberFieldLabelText,children:[r==="floating"&&E.jsx("span",{className:`${[hC.numberFieldLabel,hC.selectedLabel].join(" ")} ${e?"dbn-selectBox":""}`,children:s||(n==null?void 0:n.label)||(n==null?void 0:n.name)}),E.jsx("span",{className:`${hC.rangeValue} ${e?"dbn-selectBox":""}`,style:O&&e?{fontSize:"clamp(8px, 9cqw, 14px)"}:{fontSize:"14px"},children:h||"Select a value"})]}),E.jsx("span",{className:"dbn-interactive-element",children:E.jsx(m8,{name:"chevron-down",color:"gray"})})]})]}),children:E.jsxs("div",{className:hC.numberFieldWrapper,"data-testid":(K=(n==null?void 0:n.label)||(n==null?void 0:n.name))==null?void 0:K.toLowerCase().replaceAll(" ","-").concat("-menu"),children:[E.jsx(g5,{label:"minimum",type:"number",defaultValue:A.min,onChange:({target:{value:f2}})=>{f(A2=>({...A2,min:f2===""?null:Number(f2)}))}}),E.jsx(g5,{label:"maximum",type:"number",defaultValue:A.max,onChange:({target:{value:f2}})=>{f(A2=>({...A2,max:f2===""?null:Number(f2)}))}}),E.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[w&&E.jsx(q7,{variant:"body-text-2",color:"alert",children:w}),E.jsxs("div",{className:hC.numberFieldFooter,children:[E.jsx(C8,{type:"button",variant:"tertiary",onClick:R,children:"Clear"}),E.jsx(C8,{variant:"primary",type:"button",onClick:N,children:"Save"})]})]})]})})})},Z_=({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]=z0.useState(""),f=window.CSS&&CSS.supports("width","clamp(1px, 1px, 1px)");z0.useEffect(()=>{A((i==null?void 0:i.value)||"")},[i]);const d=z0.useMemo(()=>{if(a){if(a==="100%")return"100%";const h=`${parseInt(a,10)-44}px`;return f&&s?`clamp(100px, 13cqw, ${h})`:h}return"200px"},[a,s,f]);return E.jsxs("div",{className:a==="100%"?"dbn-w-full":"",children:[(t.label||t.name)&&C==="static"?E.jsx(E.Fragment,{children:s&&r?E.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?E.jsx("span",{className:hC.important,children:"*"}):null]}):E.jsxs(q7,{variant:"input-label",color:"primary-title",children:[t.label||t.name,l?E.jsx("span",{className:hC.important,children:"*"}):null]})}):null,E.jsxs("div",{className:hC.searchFilter,style:{borderRadius:e||"6px",opacity:o?.6:1,pointerEvents:o?"none":"auto"},children:[E.jsx(g5,{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}),E.jsx(C8,{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:E.jsx(m8,{name:"magnifying-glass",color:"white"})})]})]})},F_=({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:h,parentAppliedFilter:m,isDisableClick:w,isMobileView:Q})=>{var b2;const R=z0.useMemo(()=>e==="MULTI_DATABASE"&&a||"",[e,a]),N=z0.useCallback((g2,j2)=>{var G2,C0;const R2=((G2=t.find(m0=>m0.label===g2))==null?void 0:G2.value)||"",M2=(C0=t.find(m0=>m0.label===g2))==null?void 0:C0.selectedDropdownValue;let P2="";return M2&&!Array.isArray(M2)&&(P2=M2.label||""),j2==="string"?Array.isArray(R2)&&(R2!=null&&R2.length)?R2==null?void 0:R2.map(m0=>typeof m0=="object"?m0:{value:m0,label:m0}):[]:j2==="string"?Array.isArray(M2)?M2:[]:{label:P2||R2,value:R2}},[t]),O=z0.useCallback(g2=>{var M2;const j2=((M2=g2.dependOn)==null?void 0:M2.map(P2=>{const G2=[...t||[],...m||[]].find(C0=>P2.label===C0.label||P2.value===C0.column);if(G2){const C0=bV({operator:G2.operator,value:G2.value});return{as:"string",columnName:P2.customColumnName||G2.column,value:Cb(C0)}}return null}))||[],R2=j2==null?void 0:j2.filter(P2=>P2);return g2.clientColumn&&g2.isClientScoped&&g2.clientColumnType&&!s?[{columnName:g2.clientColumn,value:a,as:g2.clientColumnType},...R2]:R2},[t,a,s,m]),X=z0.useCallback(g2=>{var R2;const j2=(R2=A==null?void 0:A.clientLayout)!=null&&R2.length?A==null?void 0:A.clientLayout:A==null?void 0:A.adminLayout;return j2!=null&&j2.includes(g2.label)?j2==null?void 0:j2.indexOf(g2.label):j2!=null&&j2.includes(g2.name)?j2==null?void 0:j2.indexOf(g2.name):j2==null?void 0:j2.length},[A==null?void 0:A.adminLayout,A==null?void 0:A.clientLayout]),K=z0.useMemo(()=>{var g2,j2;return(j2=(g2=i==null?void 0:i[0])==null?void 0:g2.columns)==null?void 0:j2.filter(R2=>R2.isShowHorizontal).sort((R2,M2)=>X(R2)-X(M2))},[i,X]),f2=z0.useMemo(()=>{let g2=-2,j2=0;return(K==null?void 0:K.map(M2=>{let P2;return g2+2>=12?(g2=0,j2+=3,P2=0):(P2=g2+2,g2+=2),{i:M2.label||M2.name,w:2,h:3,x:P2,y:j2,minW:2,minH:1,maxH:3}}))||[]},[K,f]),A2=z0.useCallback(g2=>{var R2,M2;return((M2=(R2=t.find(P2=>P2.label===g2))==null?void 0:R2.value)==null?void 0:M2.presetDateOption)||""},[t]);return E.jsx(E.Fragment,{children:f?E.jsx(Nk,{layouts:{lg:f2},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:K==null?void 0:K.map(g2=>{var j2,R2,M2,P2,G2,C0,m0,H0,v0,J2,U0,b0,k0,J0,Y2,L3,M1,B3,j3,w7,l3,c7,T3,y6,t6,C6,n3,t0,V3,Z7,e6,l7,A6,w6,v1,h3,o7,m7,G3,J3;return E.jsxs("div",{className:hC.filterDropdown,style:{borderRadius:r.radius},id:g2.label||g2.name,tabIndex:0,role:"button",children:[!g2.isCustomFieldFilter&&(l==null?void 0:l(g2.label||g2.name||""))," ",g2.as==="date"&&E.jsx(E.Fragment,{children:E.jsx(VA,{datePickerFormat:r==null?void 0:r.datePickerFormat,label:g2.label||g2.name,hideDatePickerOptions:d,isFilter:!0,variant:r.variant==="static"?"static":"floatingLabel",buttonWidth:r.width,radius:r.radius,defaultValues:(j2=t.find(k7=>k7.label===g2.label))==null?void 0:j2.defaultValues,isDateReset:!t.filter(k7=>k7.as==="date").length,onChange:k7=>Fs({column:g2,operator:qm,setAppliedFilters:n,type:AL,value:k7!=null&&k7.startDate&&(k7!=null&&k7.endDate)?k7:void 0}),isDisabled:f})}),g2.as==="number"&&E.jsx(P_,{variant:r.variant,isFilter:!0,buttonWidth:r.width,radius:r.radius,setAppliedFilters:n,column:g2,defaultValues:(R2=t.find(k7=>k7.label===g2.label))==null?void 0:R2.defaultValues,isDisabled:f}),g2.as==="string"&&!g2.isVariableFilter&&!((M2=g2.filterVariant)!=null&&M2.value)&&(o!=null&&o.isInternal&&!g2.isManualOptions?E.jsx(Ug,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((P2=g2.autoSelectType)==null?void 0:P2.value)==="last",autoSelectCount:["last","first"].includes(((G2=g2.autoSelectType)==null?void 0:G2.value)||"")?g2.autoSelectCount:1,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,filter:{columnName:g2.filterType===su&&((C0=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:C0.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||((m0=i==null?void 0:i[0])==null?void 0:m0.tableName):(H0=i==null?void 0:i[0])==null?void 0:H0.tableName},isDisabled:f,customTable:g2.filterType===su&&((v0=g2==null?void 0:g2.selectedCustomColumn)!=null&&v0.columnName)&&((J2=g2==null?void 0:g2.selectedCustomColumn)!=null&&J2.query)?{alias:"custom_dbn_table",query:Bc({query:g2.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:N(g2.label||g2.name,"string")||[],autoSelected:!1,onChange:k7=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:k7!=null&&k7.length?k7:void 0})},isSearchEnabled:!0,label:g2.label||g2.name,filterClause:O(g2),isClearEnabled:g2.isEnableClearSelection}):E.jsx(_a,{isAutoSelectFromLast:((U0=g2.autoSelectType)==null?void 0:U0.value)==="last",autoSelectCount:["last","first"].includes(((b0=g2.autoSelectType)==null?void 0:b0.value)||"")?g2.autoSelectCount:1,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Wf(g2),labelVariant:r.variant,radius:r.radius,selectedOption:N(g2.label||g2.name,"string")||[],onChange:k7=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:k7!=null&&k7.length?k7:void 0})},isSearchEnabled:!0,label:g2.label||g2.name})),g2.as==="default"||g2.as==="boolean"||["default","boolean","string"].includes(g2.as||"")&&g2.isVariableFilter&&!((k0=g2.filterVariant)!=null&&k0.value)?o!=null&&o.isInternal&&!g2.isManualOptions?E.jsx(rE,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((J0=g2.autoSelectType)==null?void 0:J0.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:g2.filterType===su&&((Y2=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:Y2.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||((L3=i==null?void 0:i[0])==null?void 0:L3.tableName):(M1=i==null?void 0:i[0])==null?void 0:M1.tableName},customTable:g2.filterType===su&&((B3=g2==null?void 0:g2.selectedCustomColumn)!=null&&B3.columnName)&&((j3=g2==null?void 0:g2.selectedCustomColumn)!=null&&j3.query)?{alias:"custom_dbn_table",query:Bc({query:g2.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:N(g2.label||g2.name,"boolean"),onChange:k7=>{Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:k7!=null&&k7.value?k7:void 0})},isSearchEnabled:!0,label:g2.label||g2.name,filterClause:O(g2),isClearEnabled:g2.isEnableClearSelection}):E.jsx(oe,{isAutoSelectFromLast:((w7=g2.autoSelectType)==null?void 0:w7.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Wf(g2),labelVariant:r.variant,radius:r.radius,selectedOption:N(g2.label||g2.name,"boolean"),onChange:k7=>{Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:k7!=null&&k7.value?k7:void 0})},isClearEnabled:g2.isEnableClearSelection,isSearchEnabled:!0,label:g2.label||g2.name}):null,!!(g2.as==="string"&&((l3=g2.filterVariant)!=null&&l3.value))&&E.jsxs(E.Fragment,{children:[((c7=g2.filterVariant)==null?void 0:c7.value)==="like"&&E.jsx(Z_,{column:g2,isDisabled:f,buttonWidth:(r==null?void 0:r.width)||"200px",isFilter:!0,isApplyDashboardColor:!0,selectedValue:N(g2.label||g2.name,"boolean"),onClickSearch:k7=>Fs({column:g2,operator:jA,setAppliedFilters:n,type:uL,value:k7}),labelVariant:(r==null?void 0:r.variant)||"floating",radius:r==null?void 0:r.radius}),((T3=g2.filterVariant)==null?void 0:T3.value)==="IN"&&(!g2.isManualOptions&&(o!=null&&o.workspaceId)?E.jsx(Ug,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((y6=g2.autoSelectType)==null?void 0:y6.value)==="last",autoSelectCount:["last","first"].includes(((t6=g2.autoSelectType)==null?void 0:t6.value)||"")?g2.autoSelectCount:1,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,labelVariant:r.variant,radius:r.radius,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:g2.filterType===su&&((C6=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:C6.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||((n3=i==null?void 0:i[0])==null?void 0:n3.tableName):(t0=i==null?void 0:i[0])==null?void 0:t0.tableName,labelColumnName:g2.filterType===su?g2.customLabelColumn||"":g2.labelColumnName||""},customTable:g2.filterType===su&&((V3=g2==null?void 0:g2.selectedCustomColumn)!=null&&V3.columnName)&&((Z7=g2==null?void 0:g2.selectedCustomColumn)!=null&&Z7.query)?{alias:"custom_dbn_table",query:Bc({query:g2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,selectedOption:N(g2.label||g2.name,"string")||[],onChange:k7=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:k7!=null&&k7.length?k7:void 0})},isSearchEnabled:!0,label:g2.label||g2.name,filterClause:O(g2),isClearEnabled:g2.isEnableClearSelection}):E.jsx(_a,{isAutoSelectFromLast:((e6=g2.autoSelectType)==null?void 0:e6.value)==="last",autoSelectCount:["last","first"].includes(((l7=g2.autoSelectType)==null?void 0:l7.value)||"")?g2.autoSelectCount:1,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,radius:r.radius,options:Wf(g2),labelVariant:r.variant,selectedOption:N(g2.label||g2.name,"string")||[],onChange:k7=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:k7!=null&&k7.length?k7:void 0})},isSearchEnabled:!0,label:g2.label||g2.name})),((A6=g2.filterVariant)==null?void 0:A6.value)==="="&&(!g2.isManualOptions&&(o!=null&&o.workspaceId)?E.jsx(rE,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((w6=g2.autoSelectType)==null?void 0:w6.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,radius:r.radius,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:g2.filterType===su&&((v1=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:v1.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||((h3=i==null?void 0:i[0])==null?void 0:h3.tableName):(o7=i==null?void 0:i[0])==null?void 0:o7.tableName,labelColumnName:g2.filterType===su?g2.customLabelColumn||"":g2.labelColumnName||""},customTable:g2.filterType===su&&((m7=g2==null?void 0:g2.selectedCustomColumn)!=null&&m7.columnName)&&((G3=g2==null?void 0:g2.selectedCustomColumn)!=null&&G3.query)?{alias:"custom_dbn_table",query:Bc({query:g2.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:N(g2.label||g2.name,"boolean"),onChange:k7=>Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:k7!=null&&k7.value?k7:void 0}),isSearchEnabled:!0,isClearEnabled:g2.isEnableClearSelection,label:g2.label||g2.name,filterClause:O(g2)}):E.jsx(oe,{isAutoSelectFromLast:((J3=g2.autoSelectType)==null?void 0:J3.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,radius:r.radius,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Wf(g2),labelVariant:r.variant,selectedOption:N(g2.label||g2.name,"boolean"),onChange:k7=>Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:k7!=null&&k7.value?k7:void 0}),isSearchEnabled:!0,isClearEnabled:g2.isEnableClearSelection,label:g2.label||g2.name}))]})]},g2.label||g2.name)})},f?"reset":"default"):E.jsxs(E.Fragment,{children:[(b2=K==null?void 0:K.filter(g2=>g?!g2.isAppFilter:!0))==null?void 0:b2.map(g2=>{var j2,R2,M2,P2,G2,C0,m0,H0,v0,J2,U0,b0,k0,J0,Y2,L3,M1,B3,j3,w7,l3,c7,T3,y6,t6,C6,n3,t0,V3,Z7,e6,l7,A6,w6,v1,h3,o7,m7,G3,J3,k7,W7,J7,e8,z7,x6,c8,h9,U8,$9,o9,M9,j8,y5,H5,_5,T5,S8,W1,W9,I6,l8,h8,Y6,Q8,x1,L7,O6,x7,a7,K6,o6,N7,r6;return E.jsxs("div",{className:Q?"dbn-w-full":hC.filterDropdown,style:{borderRadius:r.radius,pointerEvents:w?"none":void 0},"data-testid":(j2=g2.label||g2.name)==null?void 0:j2.toLowerCase().replaceAll(" ","-").concat("-filter"),children:[!g2.isCustomFieldFilter&&(l==null?void 0:l(g2.label||g2.name||"")),g2.as==="date"&&E.jsx(E.Fragment,{children:((R2=g2.dateVariant)==null?void 0:R2.value)==="preset"?E.jsx(oe,{isAutoSelectFromLast:((M2=g2.autoSelectType)==null?void 0:M2.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,isFilter:!Q,isApplyDashboardColor:!Q,options:((P2=g2==null?void 0:g2.datePresetOptions)==null?void 0:P2.map(q3=>({value:q3.label,label:q3.label,presetDateOption:q3})))||[],labelVariant:r.variant,radius:r.radius,selectedOption:(C0=(G2=t.find(q3=>q3.label===g2.label))==null?void 0:G2.value)!=null&&C0.value?(m0=t.find(q3=>q3.label===g2.label))==null?void 0:m0.value:{value:"",label:""},onChange:q3=>{Fs({column:g2,operator:fl,setAppliedFilters:n,type:cL,value:q3!=null&&q3.value?q3:void 0})},isClearEnabled:g2.isEnableClearSelection,isSearchEnabled:!0,label:g2.label||g2.name,disableAutoClose:!0,children:((v0=(H0=A2(g2.label))==null?void 0:H0.type)==null?void 0:v0.value)==="custom"?E.jsx("div",{className:"dbn-p-1",children:E.jsx(VA,{datePickerFormat:r==null?void 0:r.datePickerFormat,isEnableSingleDate:((U0=(J2=A2(g2.label))==null?void 0:J2.customType)==null?void 0:U0.value)==="singleDate",label:((k0=(b0=A2(g2.label))==null?void 0:b0.customType)==null?void 0:k0.value)==="singleDate"?hx:Ex,hideDatePickerOptions:d,onChange:q3=>{var Z6;Fs({column:g2,operator:fl,setAppliedFilters:n,type:cL,value:{...(Z6=t.find(o8=>o8.label===g2.label))==null?void 0:Z6.value,presetDateOption:{...A2(g2.label),customDate:q3}}})},minDate:(J0=A2(g2.label))!=null&&J0.isDateRestricted&&((Y2=A2(g2.label))!=null&&Y2.restrictionDateFrom)?Pl((L3=A2(g2.label))==null?void 0:L3.restrictionDateFrom,!0):void 0,maxDate:(M1=A2(g2.label))!=null&&M1.isDateRestricted&&((B3=A2(g2.label))!=null&&B3.restrictionDateTo)?Pl((j3=A2(g2.label))==null?void 0:j3.restrictionDateTo):void 0,defaultValues:(l3=(w7=A2(g2.label))==null?void 0:w7.customDate)!=null&&l3.startDate&&((T3=(c7=A2(g2.label))==null?void 0:c7.customDate)!=null&&T3.endDate)?{startDate:new Date((t6=(y6=A2(g2.label))==null?void 0:y6.customDate)==null?void 0:t6.startDate),endDate:new Date((n3=(C6=A2(g2.label))==null?void 0:C6.customDate)==null?void 0:n3.endDate),timeGrainValue:((V3=(t0=A2(g2.label))==null?void 0:t0.customDate)==null?void 0:V3.timeGrainValue)||""}:void 0})}):null}):E.jsx(VA,{datePickerFormat:r==null?void 0:r.datePickerFormat,minDate:g2.isEnableDateRestriction&&((Z7=g2==null?void 0:g2.dateRestrictionRange)!=null&&Z7.from)?Pl((e6=g2==null?void 0:g2.dateRestrictionRange)==null?void 0:e6.from,!0):void 0,maxDate:g2.isEnableDateRestriction&&((l7=g2==null?void 0:g2.dateRestrictionRange)!=null&&l7.to)?Pl((A6=g2==null?void 0:g2.dateRestrictionRange)==null?void 0:A6.to):void 0,label:g2.label||g2.name,hideDatePickerOptions:d,isEnableSingleDate:((w6=g2.dateSelectionType)==null?void 0:w6.value)==="singleDate",buttonWidth:Q?"100%":r.width,isFilter:!Q,variant:r.variant==="static"?"static":"floatingLabel",radius:r.radius,defaultValues:(v1=t.find(q3=>q3.label===g2.label))==null?void 0:v1.defaultValues,isDateReset:!t.filter(q3=>q3.as==="date").length,onChange:q3=>Fs({column:g2,operator:qm,setAppliedFilters:n,type:AL,value:q3!=null&&q3.startDate&&(q3!=null&&q3.endDate)?q3:void 0})})}),g2.as==="number"&&E.jsx(P_,{variant:r.variant,buttonWidth:Q?"100%":r.width,isFilter:!Q,radius:r.radius,setAppliedFilters:n,column:g2,defaultValues:(h3=t.find(q3=>q3.label===g2.label))==null?void 0:h3.defaultValues}),g2.as==="string"&&!g2.isVariableFilter&&!((o7=g2.filterVariant)!=null&&o7.value)&&(o!=null&&o.isInternal&&!g2.isManualOptions?E.jsx(Ug,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((m7=g2.autoSelectType)==null?void 0:m7.value)==="last",autoSelectCount:["last","first"].includes(((G3=g2.autoSelectType)==null?void 0:G3.value)||"")?g2.autoSelectCount:1,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,filter:{columnName:g2.filterType===su&&((J3=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:J3.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||((k7=i==null?void 0:i[0])==null?void 0:k7.tableName):(W7=i==null?void 0:i[0])==null?void 0:W7.tableName},customTable:g2.filterType===su&&((J7=g2==null?void 0:g2.selectedCustomColumn)!=null&&J7.columnName)&&((e8=g2==null?void 0:g2.selectedCustomColumn)!=null&&e8.query)?{alias:"custom_dbn_table",query:Bc({query:g2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,isFilter:!Q,isApplyDashboardColor:!Q,radius:r.radius,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,selectedOption:N(g2.label||g2.name,"string")||[],autoSelected:!1,onChange:q3=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:q3!=null&&q3.length?q3:void 0})},isSearchEnabled:!0,label:g2.label||g2.name,filterClause:O(g2),isClearEnabled:g2.isEnableClearSelection}):E.jsx(_a,{isAutoSelectFromLast:((z7=g2.autoSelectType)==null?void 0:z7.value)==="last",isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,autoSelectCount:["last","first"].includes(((x6=g2.autoSelectType)==null?void 0:x6.value)||"")?g2.autoSelectCount:1,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,isFilter:!Q,isApplyDashboardColor:!Q,options:Wf(g2),labelVariant:r.variant,radius:r.radius,selectedOption:N(g2.label||g2.name,"string")||[],onChange:q3=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:q3!=null&&q3.length?q3:void 0})},isSearchEnabled:!0,label:g2.label||g2.name})),g2.as==="default"||g2.as==="boolean"||["default","boolean","string"].includes(g2.as||"")&&g2.isVariableFilter&&!((c8=g2.filterVariant)!=null&&c8.value)?o!=null&&o.isInternal&&!g2.isManualOptions?E.jsx(rE,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((h9=g2.autoSelectType)==null?void 0:h9.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,isFilter:!Q,isApplyDashboardColor:!Q,filter:{columnName:g2.filterType===su&&((U8=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:U8.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||(($9=i==null?void 0:i[0])==null?void 0:$9.tableName):(o9=i==null?void 0:i[0])==null?void 0:o9.tableName},customTable:g2.filterType===su&&((M9=g2==null?void 0:g2.selectedCustomColumn)!=null&&M9.columnName)&&((j8=g2==null?void 0:g2.selectedCustomColumn)!=null&&j8.query)?{alias:"custom_dbn_table",query:Bc({query:g2.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:N(g2.label||g2.name,"boolean"),onChange:q3=>{Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:q3!=null&&q3.value?q3:void 0})},isSearchEnabled:!0,label:g2.label||g2.name,filterClause:O(g2),isClearEnabled:g2.isEnableClearSelection}):E.jsx(oe,{isAutoSelectFromLast:((y5=g2.autoSelectType)==null?void 0:y5.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,isFilter:!Q,isApplyDashboardColor:!Q,options:Wf(g2),labelVariant:r.variant,radius:r.radius,selectedOption:N(g2.label||g2.name,"boolean"),onChange:q3=>{Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:q3!=null&&q3.value?q3:void 0})},isClearEnabled:g2.isEnableClearSelection,isSearchEnabled:!0,label:g2.label||g2.name}):null,!!(g2.as==="string"&&((H5=g2.filterVariant)!=null&&H5.value))&&E.jsxs(E.Fragment,{children:[((_5=g2.filterVariant)==null?void 0:_5.value)==="like"&&E.jsx(Z_,{column:g2,buttonWidth:Q?"100%":r==null?void 0:r.width,isFilter:!Q,isApplyDashboardColor:!Q,selectedValue:N(g2.label||g2.name,"boolean"),onClickSearch:q3=>Fs({column:g2,operator:jA,setAppliedFilters:n,type:uL,value:q3}),labelVariant:(r==null?void 0:r.variant)||"floating",radius:r==null?void 0:r.radius}),((T5=g2.filterVariant)==null?void 0:T5.value)==="IN"&&(!g2.isManualOptions&&(o!=null&&o.workspaceId)?E.jsx(Ug,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((S8=g2.autoSelectType)==null?void 0:S8.value)==="last",autoSelectCount:["last","first"].includes(((W1=g2.autoSelectType)==null?void 0:W1.value)||"")?g2.autoSelectCount:1,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,labelVariant:r.variant,radius:r.radius,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,isFilter:!Q,isApplyDashboardColor:!Q,filter:{columnName:g2.filterType===su&&((W9=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:W9.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||((I6=i==null?void 0:i[0])==null?void 0:I6.tableName):(l8=i==null?void 0:i[0])==null?void 0:l8.tableName,labelColumnName:g2.filterType===su?g2.customLabelColumn||"":g2.labelColumnName||""},customTable:g2.filterType===su&&((h8=g2==null?void 0:g2.selectedCustomColumn)!=null&&h8.columnName)&&((Y6=g2==null?void 0:g2.selectedCustomColumn)!=null&&Y6.query)?{alias:"custom_dbn_table",query:Bc({query:g2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,selectedOption:N(g2.label||g2.name,"string")||[],onChange:q3=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:q3!=null&&q3.length?q3:void 0})},isSearchEnabled:!0,label:g2.label||g2.name,filterClause:O(g2),isClearEnabled:g2.isEnableClearSelection}):E.jsx(_a,{isAutoSelectFromLast:((Q8=g2.autoSelectType)==null?void 0:Q8.value)==="last",autoSelectCount:["last","first"].includes(((x1=g2.autoSelectType)==null?void 0:x1.value)||"")?g2.autoSelectCount:1,isAutoSelectAll:g2==null?void 0:g2.isSelectAllMultiSelectOptions,isSelectAllEnabled:g2==null?void 0:g2.isSelectAllMultiSelect,isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,isFilter:!Q,isApplyDashboardColor:!Q,radius:r.radius,options:Wf(g2),labelVariant:r.variant,selectedOption:N(g2.label||g2.name,"string")||[],onChange:q3=>{Fs({column:g2,operator:au,setAppliedFilters:n,type:zA,value:q3!=null&&q3.length?q3:void 0})},isSearchEnabled:!0,label:g2.label||g2.name,isClearEnabled:g2.isEnableClearSelection})),((L7=g2.filterVariant)==null?void 0:L7.value)==="="&&(!g2.isManualOptions&&(o!=null&&o.workspaceId)?E.jsx(rE,{databaseName:R,datasourceId:h,isAutoSelectFromLast:((O6=g2.autoSelectType)==null?void 0:O6.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,radius:r.radius,isFilter:!Q,isApplyDashboardColor:!Q,filter:{columnName:g2.filterType===su&&((x7=g2==null?void 0:g2.selectedCustomColumn)==null?void 0:x7.columnName)||g2.name,tableName:g2.filterType==="auto"?g2.selectedTable||((a7=i==null?void 0:i[0])==null?void 0:a7.tableName):(K6=i==null?void 0:i[0])==null?void 0:K6.tableName,labelColumnName:g2.filterType===su?g2.customLabelColumn||"":g2.labelColumnName||""},customTable:g2.filterType===su&&((o6=g2==null?void 0:g2.selectedCustomColumn)!=null&&o6.columnName)&&((N7=g2==null?void 0:g2.selectedCustomColumn)!=null&&N7.query)?{alias:"custom_dbn_table",query:Bc({query:g2.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:N(g2.label||g2.name,"boolean"),onChange:q3=>Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:q3!=null&&q3.value?q3:void 0}),isSearchEnabled:!0,isClearEnabled:g2.isEnableClearSelection,label:g2.label||g2.name,filterClause:O(g2)}):E.jsx(oe,{isAutoSelectFromLast:((r6=g2.autoSelectType)==null?void 0:r6.value)==="last",isAutoSelectOption:g2.isAutoSelectFilterValue,buttonWidth:Q?"100%":r.width,menuWidth:Q?"100%":r.width,radius:r.radius,isFilter:!Q,isApplyDashboardColor:!Q,options:Wf(g2),labelVariant:r.variant,selectedOption:N(g2.label||g2.name,"boolean"),onChange:q3=>Fs({column:g2,operator:fl,setAppliedFilters:n,type:GA,value:q3!=null&&q3.value?q3:void 0}),isSearchEnabled:!0,isClearEnabled:g2.isEnableClearSelection,label:g2.label||g2.name}))]})]},g2.label||g2.name)}),C]})})},j70=k9.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:h,themeName:m,setAdminTheme:w,appearanceOptions:Q,isDisableCardTitle:R,hideDatePickerOptions:N,chartAppearance:O,hideMetricCardShadow:X,disableUnderlyingData:K,noDataImg:f2,disableDownloadPng:A2,disableMetricCardBorder:b2,isMergedCard:g2,chartColumns:j2,language:R2,translationDictionary:M2,globalFilterOptions:P2,calendarType:G2="default",disableDownloadDataNoFilters:C0=!1,disableDownloadUnderlyingDataNoFilters:m0=!1})=>{var W9,I6,l8,h8,Y6,Q8,x1,L7,O6,x7,a7,K6,o6,N7,r6,q3,Z6,o8,D8,z8,k8,k3,h5,I8,D9,E8,A5,y9,p5,T4,k4,Te,X5,te,V4,fe;const[H0,v0]=z0.useState([]),[J2,U0]=z0.useState({isShow:a==="fullscreen"}),[b0,k0]=z0.useState(!1),[J0,Y2]=z0.useState(!1),[L3,M1]=z0.useState(!1),[B3,j3]=z0.useState(!1),[w7,l3]=z0.useState({show:!1,filterValues:void 0}),[c7,T3]=z0.useState([]),[y6,t6]=z0.useState({width:"200px",variant:"floating",radius:"6px",datePickerFormat:""}),[C6,n3]=z0.useState({header:{fontColor:"",bgColor:"",fontWeight:""},content:{fontColor:"",lineGap:"",fontWeight:""}}),{externalMetric:t0,rlsSettings:V3,sharingSettingsId:Z7,companyId:e6,clientId:l7,tenancyLevel:A6,isLoading:w6,errorMsg:v1,adminTheme:h3,workspaceId:o7,clientColumnType:m7,isEnableMetricSummary:G3,isAllClient:J3,isShowUnderlyingData:k7,appFilters:W7,mergedMetricsId:J7,datasourceId:e8,mergedMetricLayout:z7,mergedDashboardFilters:x6,dashboardAppFilterValues:c8,nestedMetric:h9,token:U8}=Tu2({token:t,metricId:i}),$9=(W9=window==null?void 0:window.dbn)!=null&&W9.isEnableProxyAuth?U8:t,o9=z0.useMemo(()=>{var Y5,Q6,_8,k6,x8;return((x8=(k6=(_8=(Q6=(Y5=t0==null?void 0:t0.externalDashboardMetrics)==null?void 0:Y5[0])==null?void 0:Q6.externalDashboard)==null?void 0:_8.companyWorkspace)==null?void 0:k6.datamart)==null?void 0:x8.datamartRelationships)||[]},[t0]),{data:M9}=Mu2({token:$9,name:m||"",companyId:e6}),j8=z0.useMemo(()=>(M9==null?void 0:M9.theme)||h3,[h3,M9]),y5=z0.useMemo(()=>K!=null&&K.toString()?!K:k7,[K,k7]),H5=z0.useMemo(()=>z7==null?void 0:z7.map(Q6=>{const _8=Q6.i,k6=Q6.layout;return{i:_8,w:(k6==null?void 0:k6.w)??Q6.resizeAttributes.width??5,h:(k6==null?void 0:k6.h)??Q6.resizeAttributes.height??10,x:(k6==null?void 0:k6.x)??Q6.resizeAttributes.xAxis??0,y:(k6==null?void 0:k6.y)??Q6.resizeAttributes.yAxis??0,minW:Q6.isMetric?[L0.singleValue,L0.pivot,L0.pivotV2,L0.pivotV3,L0.progressBar,L0.linearGauge].includes(Q6==null?void 0:Q6.chartType)?2:3:1,minH:Q6.isMetric?[L0.singleValue,L0.pivot,L0.pivotV2,L0.pivotV3].includes(Q6==null?void 0:Q6.chartType)?2:[L0.progressBar,L0.linearGauge].includes(Q6==null?void 0:Q6.chartType)?3:8:Q6.description?2:1,maxH:(Q6==null?void 0:Q6.chartType)==="table"?1/0:15}}),[z7]),_5=z0.useMemo(()=>H5.sort((Y5,Q6)=>Y5.y!==Q6.y?Y5.y-Q6.y:Y5.x-Q6.x),[H5]),T5=z0.useMemo(()=>{var Q6,_8,k6;return n??((k6=(_8=(Q6=j8==null?void 0:j8.chart)==null?void 0:Q6.palettes)==null?void 0:_8.find(x8=>{var d9,j9;return x8.name===((j9=(d9=(M9==null?void 0:M9.theme)||h3)==null?void 0:d9.chart)==null?void 0:j9.selected)}))==null?void 0:k6.colors)},[j8,n]);z0.useEffect(()=>{var Y5,Q6,_8,k6,x8,d9,j9,t9,t8,z9,B9,S9,c9,L5,x5,c5,d4,N4,r5,i4;if(j8!=null&&j8.dashboard.selectBoxSize)switch(j8==null?void 0:j8.dashboard.selectBoxSize){case"small":t6(D4=>({...D4,width:"130px"}));break;case"medium":t6(D4=>({...D4,width:"180px"}));break;case"large":t6(D4=>({...D4,width:"250px"}));break;default:t6(D4=>({...D4,width:"200px"}))}j8!=null&&j8.dashboard.selectBoxVariant&&t6(D4=>({...D4,variant:j8.dashboard.selectBoxVariant})),j8!=null&&j8.dashboard.selectBoxBorderRadius&&t6(D4=>({...D4,radius:j8.dashboard.selectBoxBorderRadius})),(Y5=j8==null?void 0:j8.general)!=null&&Y5.datePickerFormat&&t6(D4=>{var b4;return{...D4,datePickerFormat:(b4=j8==null?void 0:j8.general)==null?void 0:b4.datePickerFormat}}),(Q6=j8==null?void 0:j8.dashboard)!=null&&Q6.underlyingData&&n3({header:{fontColor:((x8=(k6=(_8=j8==null?void 0:j8.dashboard)==null?void 0:_8.underlyingData)==null?void 0:k6.header)==null?void 0:x8.fontColor)||"#0D0D0D",bgColor:((t9=(j9=(d9=j8==null?void 0:j8.dashboard)==null?void 0:d9.underlyingData)==null?void 0:j9.header)==null?void 0:t9.bgColor)||"#f9fafb",fontWeight:((B9=(z9=(t8=j8==null?void 0:j8.dashboard)==null?void 0:t8.underlyingData)==null?void 0:z9.header)==null?void 0:B9.fontWeight)||"boldfont"},content:{fontColor:((L5=(c9=(S9=j8==null?void 0:j8.dashboard)==null?void 0:S9.underlyingData)==null?void 0:c9.content)==null?void 0:L5.fontColor)||"#222c3a",lineGap:((d4=(c5=(x5=j8==null?void 0:j8.dashboard)==null?void 0:x5.underlyingData)==null?void 0:c5.content)==null?void 0:d4.lineGap)||"24px",fontWeight:((i4=(r5=(N4=j8==null?void 0:j8.dashboard)==null?void 0:N4.underlyingData)==null?void 0:r5.content)==null?void 0:i4.fontWeight)||"500"}})},[j8]),z0.useEffect(()=>{w(j8)},[j8]);const S8=z0.useMemo(()=>!!(J7!=null&&J7.length)||!!(x6!=null&&x6.length),[J7,x6]),W1=z0.useMemo(()=>x6!=null&&x6.length?(x6==null?void 0:x6.map(Y5=>{var Q6,_8,k6;return{...Y5,...A6==="DATABASE"?{tableName:`${l7}.${(_8=(Q6=Y5==null?void 0:Y5.tableName)==null?void 0:Q6.split(/\.(?=[^.]*$)/))==null?void 0:_8[1]}`}:{},columns:((k6=Y5==null?void 0:Y5.columns)==null?void 0:k6.map(x8=>{var d9,j9;return{...x8,defaultValue:Ra2(x8,c8,P2),isManualOptions:!!((d9=P2==null?void 0:P2[x8==null?void 0:x8.label])!=null&&d9.options)||!!(x8!=null&&x8.isManualOptions),manualOptions:((j9=P2==null?void 0:P2[x8==null?void 0:x8.label])==null?void 0:j9.options)||(x8==null?void 0:x8.manualOptions)||[]}}))||[]}}))||[]:[],[x6,A6,l7,c8,P2]);return z0.useEffect(()=>{setTimeout(()=>{j3(!!localStorage.getItem("isDisableClick")||!1)},1e3)},[]),E.jsxs(E.Fragment,{children:[w6&&($9||(I6=window==null?void 0:window.dbn)!=null&&I6.isEnableProxyAuth)?E.jsx("div",{className:ry.loader,children:E.jsx(oA,{})}):null,(v1==="TOKEN_EXPIRED"&&($9||(l8=window==null?void 0:window.dbn)!=null&&l8.isEnableProxyAuth)?(h==null?void 0:h.tokenExpiry)||"Expired Token!":v1)||null,!$9&&!((h8=window==null?void 0:window.dbn)!=null&&h8.isEnableProxyAuth)&&!w6?E.jsxs("div",{className:ry["alt-container"],children:[h!=null&&h.tokenAbsent?null:E.jsx("img",{src:mV,alt:"no data",width:100,height:100}),(h==null?void 0:h.tokenAbsent)||"INVALID_TOKEN"]}):null,t0&&!w6?E.jsxs(E.Fragment,{children:[a==="card"?E.jsxs("div",{className:"dbn-w-full dbn-h-full",children:[(Y6=Object.keys(Q||{}))!=null&&Y6.length&&[s22,Pm2].includes((Q==null?void 0:Q.appearanceOptionsPosition)||"")?E.jsxs("div",{className:`dbn-w-full dbn-flex dbn-flex-wrap dbn-gap-4 dbn-pb-2 ${(Q==null?void 0:Q.appearanceOptionsPosition)===s22?"dbn-justify-start":"dbn-justify-end"}`,style:B3?{pointerEvents:"none"}:{},children:[(Q8=Q==null?void 0:Q.cumulativeBar)!=null&&Q8.isEnabled?E.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:E.jsx(Wa,{position:"bottom",text:"It demonstrates the accumulated values, providing insights into the overall trend or pattern in the data",isSingleLineTxt:!1,children:E.jsx(a4,{enabled:b0,name:"cumulative",onChange:()=>k0(!b0),placeholder:((x1=Q==null?void 0:Q.cumulativeBar)==null?void 0:x1.label)||"Cumulative"})})}):null,(L7=Q==null?void 0:Q.dynamicBehaviour)!=null&&L7.isEnabled?E.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:E.jsx(Wa,{position:"bottom",text:"It allows you to observe trends, fluctuations, or updates as they occur in a responsive visual representation",isSingleLineTxt:!1,children:E.jsx(a4,{enabled:J0,name:"dynamic",onChange:()=>Y2(!J0),placeholder:((O6=Q==null?void 0:Q.dynamicBehaviour)==null?void 0:O6.label)||"Dynamic"})})}):null,(x7=Q==null?void 0:Q.stackedBars)!=null&&x7.isEnabled?E.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:E.jsx(Wa,{position:"bottom",text:"It represents the percentage distribution of individual components relative to the whole.",isSingleLineTxt:!1,children:E.jsx(a4,{name:"full stacked",enabled:L3,onChange:()=>M1(!L3),placeholder:((a7=Q==null?void 0:Q.stackedBars)==null?void 0:a7.label)||"100% stacked bars"})})}):null]}):null,E.jsx("div",{className:`${ry["MetricList-wrapper"]} dbn-metric-chart
589
589
  ${S8&&g2?`dbn-metric-card dbn-metric-card-container ${ry.mergedCard}`:ry.flexDisplay}
590
590
  ${b2?"dbn-border-0":""}`,style:{background:S8&&g2&&((K6=j8==null?void 0:j8.dashboard)!=null&&K6.metricCardColor)?(o6=j8==null?void 0:j8.dashboard)==null?void 0:o6.metricCardColor:S8&&g2&&!((N7=j8==null?void 0:j8.dashboard)!=null&&N7.metricCardColor)?"dbn-bg-white":""},children:g2&&S8?E.jsxs(E.Fragment,{children:[!!((q3=(r6=W1==null?void 0:W1[0])==null?void 0:r6.columns)!=null&&q3.length)&&E.jsx("div",{className:"dbn-w-full dbn-flex dbn-gap-2 dbn-p-2 dbn-items-end dbn-z-[19] dbn-justify-start",children:E.jsx(F_,{isEditLayoutEnabled:!1,clientColumnType:m7,hideDatePickerOptions:[],appliedfilters:H0,setAppliedFilters:v0,isDisableClick:B3,filters:W1,internal:{isInternal:!0,workspaceId:o7||""},clientId:l7,isAllClient:J3,theme:y6,tenancyLevel:A6,layout:{adminLayout:((Z6=t0==null?void 0:t0.chartOptions)==null?void 0:Z6.filterLayout)||[],clientLayout:[],isLocked:!0,onChange:()=>{}},datasourceId:e8})}),E.jsx(Nk,{layouts:{lg:_5},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,...J7].map(Y5=>{var Q6,_8,k6,x8,d9,j9,t9;return E.jsx("div",{id:((_8=(Q6=z7==null?void 0:z7.find(t8=>(t8==null?void 0:t8.metricId)===Y5))==null?void 0:Q6.layout)==null?void 0:_8.i)||Y5,children:E.jsx(U70,{disableDownloadDataNoFilters:C0,disableDownloadUnderlyingDataNoFilters:m0,calendarType:G2,globalFilters:{tableName:(W1==null?void 0:W1.tableName)||"",filters:(k6=H0==null?void 0:H0.filter(t8=>t8==null?void 0:t8.value))==null?void 0:k6.map(t8=>Ta2(t8))},language:R2,translationDictionary:M2,dropdownTheme:y6,underlyingTheme:C6,isDisableClick:B3,metricId:Y5,token:$9,adminColors:T5,appearanceOptions:Q,metricCardColor:((x8=j8==null?void 0:j8.dashboard)==null?void 0:x8.metricCardColor)||"",chartAppearance:O,chartColors:n,chartRendererType:o,dataMartRelationships:o9,isEnableCumulative:b0,isEnableDynamic:J0,isEnableStack:L3,disableDownloadPng:A2,disableFullscreen:d,disableMetricCardBorder:b2,enableDownloadCsv:l,enableEmailCsv:e,enableMultiMetricFilters:A,hideDatePickerOptions:N,hideMetricCardShadow:X??((d9=j8==null?void 0:j8.cardCustomization)==null?void 0:d9.disableShadowOnHover)??!1,isDisableCardTitle:R,isEnableUnderlyingData:y5,isHideChartSettings:r,isHideTablePreview:C,metricFilterOptions:u,metricFilterPosition:f,noDataImg:f2,onMinimize:s,optionsIcon:g},Y5)},((t9=(j9=z7==null?void 0:z7.find(t8=>(t8==null?void 0:t8.metricId)===Y5))==null?void 0:j9.layout)==null?void 0:t9.i)||Y5)})},"default")]}):E.jsx(Rk,{disableDownloadDataNoFilters:C0,disableDownloadUnderlyingDataNoFilters:m0,disableFullscreen:!!d,language:R2,translationDictionary:M2,isDisableClick:B3,isEmbeddedMetric:!g2,datasourceId:e8,isAllClient:J3,disableBorder:b2,metricCardColor:((o8=j8==null?void 0:j8.dashboard)==null?void 0:o8.metricCardColor)||"",isEnableCumulative:b0,isEnableDynamic:J0,isEnableStack:L3,isMergedMetric:S8&&g2,noDataImg:f2,isShadowDisableOnHover:X??((D8=j8==null?void 0:j8.cardCustomization)==null?void 0:D8.disableShadowOnHover)??!1,isAllowedToSeeUnderlyingData:y5,clientColumnType:m7,chartAppearance:O,hideDatePickerOptions:N,workspaceId:o7,guestToken:$9,isFrontendApp:!1,downloadMetrics:c7,appearanceOptions:Q,onDownload:(Y5,Q6)=>{T3(Q6?_8=>[..._8,{id:Y5,isInProgress:Q6}]:_8=>_8.filter(k6=>k6.id!==Y5))},metricItem:j2!=null&&j2.isEnabled?{...t0,chartOptions:{...t0==null?void 0:t0.chartOptions,yAxisList:(j2==null?void 0:j2.measures)||[],xAxis:((z8=j2==null?void 0:j2.dimensions)==null?void 0:z8[0])||"",enduserMeasureAndDimensions:{isEnabled:j2==null?void 0:j2.isEnabled,dimensions:((k8=j2==null?void 0:j2.dimensions)==null?void 0:k8.map(Y5=>({value:Y5,label:Y5})))||[],measures:((k3=j2==null?void 0:j2.measures)==null?void 0:k3.map(Y5=>({value:Y5,label:Y5})))||[]}}}:t0,client:l7,dropdownTheme:y6,underlyingTheme:C6,colors:T5||n,optionsIcon:g,onMaximize:d&&!((I8=(h5=t0==null?void 0:t0.clickActions)==null?void 0:h5.chartWithMetric)!=null&&I8.isEnable)?void 0:({rlsFilters:Y5,appliedMetricFilters:Q6,isClickOnChart:_8})=>U0({isShow:!0,rlsFilters:Y5,appliedMetricFilters:Q6,isClickOnChart:_8}),companyTenancyType:A6,chartRendererType:o,param:V3,metricFilterOptions:u,enableDownloadCsv:l,enableMultiMetricFilters:A,metricFilterPosition:f,onDownloadRawCsv:e?Y5=>l3({show:!0,filterValues:Y5}):void 0,isDisableCardTitle:R,appFilters:W7,calendarType:G2})}),(D9=Object.keys(Q||{}))!=null&&D9.length&&[C22,l22].includes((Q==null?void 0:Q.appearanceOptionsPosition)||"")?E.jsxs("div",{className:`dbn-w-full dbn-flex dbn-flex-wrap dbn-gap-4 dbn-pt-2 ${(Q==null?void 0:Q.appearanceOptionsPosition)===C22?"dbn-justify-start":"dbn-justify-end"}`,style:B3?{pointerEvents:"none"}:{},children:[(E8=Q==null?void 0:Q.cumulativeBar)!=null&&E8.isEnabled?E.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:E.jsx(Wa,{position:"bottom",text:"It demonstrates the accumulated values, providing insights into the overall trend or pattern in the data",isSingleLineTxt:!1,children:E.jsx(a4,{enabled:b0,name:"cumulative",onChange:()=>k0(!b0),placeholder:((A5=Q==null?void 0:Q.cumulativeBar)==null?void 0:A5.label)||"Cumulative"})})}):null,(y9=Q==null?void 0:Q.dynamicBehaviour)!=null&&y9.isEnabled?E.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:E.jsx(Wa,{position:"bottom",text:"It allows you to observe trends, fluctuations, or updates as they occur in a responsive visual representation",isSingleLineTxt:!1,children:E.jsx(a4,{enabled:J0,name:"dynamic",onChange:()=>Y2(!J0),placeholder:((p5=Q==null?void 0:Q.dynamicBehaviour)==null?void 0:p5.label)||"Dynamic"})})}):null,(T4=Q==null?void 0:Q.stackedBars)!=null&&T4.isEnabled?E.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:E.jsx(Wa,{position:"bottom",text:"It represents the percentage distribution of individual components relative to the whole.",isSingleLineTxt:!1,children:E.jsx(a4,{name:"full stacked",enabled:L3,onChange:()=>M1(!L3),placeholder:((k4=Q==null?void 0:Q.stackedBars)==null?void 0:k4.label)||"100% stacked bars"})})}):null]}):null]}):null,(!d||J2!=null&&J2.isClickOnChart)&&J2.isShow||a==="fullscreen"?E.jsx(pE,{children:E.jsx(Sk,{refetchDashboardData:()=>{},onServerEvent:()=>{},disableDownloadDataNoFilters:C0,disableDownloadUnderlyingDataNoFilters:m0,calendarType:G2,language:R2,translationDictionary:M2,appliedMetricFilters:(J2==null?void 0:J2.appliedMetricFilters)||[],datasourceId:e8,appFilters:W7,isAllClient:J3,isEnableMetricSummary:G3,hideDatePickerOptions:N,disableDownloadPng:A2,chartAppearance:O,clientColumnType:m7,workspaceId:o7,guestToken:$9,isFrontendApp:!1,downloadMetrics:c7,onDownload:(Y5,Q6)=>{T3(Q6?_8=>[..._8,{id:Y5,isInProgress:Q6}]:_8=>_8.filter(k6=>k6.id!==Y5))},metric:j2!=null&&j2.isEnabled?{...J2!=null&&J2.isClickOnChart&&h9?h9:t0,chartOptions:{...(Te=J2!=null&&J2.isClickOnChart&&h9?h9:t0)==null?void 0:Te.chartOptions,yAxisList:(j2==null?void 0:j2.measures)||[],xAxis:((X5=j2==null?void 0:j2.dimensions)==null?void 0:X5[0])||"",enduserMeasureAndDimensions:{isEnabled:j2==null?void 0:j2.isEnabled,dimensions:((te=j2==null?void 0:j2.dimensions)==null?void 0:te.map(Y5=>({value:Y5,label:Y5})))||[],measures:((V4=j2==null?void 0:j2.measures)==null?void 0:V4.map(Y5=>({value:Y5,label:Y5})))||[]}}}:J2!=null&&J2.isClickOnChart&&h9?h9:t0,clientId:l7,colors:T5||n,onMinimize:()=>{U0({isShow:!1,isClickOnChart:!1}),s==null||s()},companyId:e6,tenancyLevel:A6,rlsFilters:J2.rlsFilters,sharingSettingsId:Z7,externalDashboardId:"",userProvidedDashboardId:"",isShowChartConfigTab:!1,isHideChartSettings:r,isHideTablePreview:C,metricFilterOptions:u})}):null,e?E.jsx(IV,{workspaceId:o7,metricItem:t0,isShowRawCsvModal:w7.show,onCloseModal:()=>l3({show:!1,filterValues:void 0}),sharingSettingsId:Z7,query:lb({query:Od((t0==null?void 0:t0.query)||"",e6||""),dbName:(t0==null?void 0:t0.integrationName)||"",rlsConditions:((fe=t0==null?void 0:t0.rlsConditions)==null?void 0:fe.filter(Y5=>Y5.isAddOnMetrics))||[],tenancyLevel:A6,clientId:l7,values:w7.filterValues,isAllClient:!1,clientColumnType:m7,dataMartRelationships:o9})}):null]}):null]})}),_u2=({componentName:t,adminTheme:n,isDisableCardShadow:i,theme:o,longDescriptionConfig:a,isDisableStrokeOpt:s})=>{var d,g,h;const C=new URLSearchParams(window.location.search).get("isDbn"),[l,e]=z0.useState(""),[u,A]=z0.useState(""),f=z0.useId();return z0.useEffect(()=>{const m=document.querySelector("#dbn-styles");m&&A(m.innerHTML)},[]),z0.useEffect(()=>{var w,Q,R,N,O,X,K,f2,A2,b2,g2,j2,R2,M2,P2,G2,C0,m0,H0,v0,J2,U0,b0,k0,J0,Y2,L3,M1,B3,j3,w7;if(!n)return e("");let m="";(w=n.general.fontFamily)!=null&&w.trim()&&(m=`