@databrainhq/plugin 0.16.22 → 0.16.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -594,7 +594,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
594
594
|
FETCH NEXT ${S} ROWS ONLY`;r||s||C?e=T$2({sqlQuery:e,existingOffset:d,existingLimit:b,outputQuery:N,isRemove:a}):e=nW(e,`limit ${b}`,a?"":`limit ${S} ${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 ${b||u} rows only`:(/fetch/i.test(e)||/offset/i.test(e))&&(e=M$2({sql:e,newLimit:u,newOffset:l,isRemove:a})):a||(e+=` limit ${u} ${l!=="0"?`OFFSET ${l}`:""}`);return e},GB=(t,n)=>(t==null?void 0:t.label)||n||(t==null?void 0:t.tableName)||"",bS=({onSubmit:t,defaultValues:n,onCancel:i,error:o,isCreatingMetric:a})=>{var f;const{register:s,handleSubmit:r,setValue:C,formState:{errors:l},watch:e}=cb(),u=e("name"),A=e("metricId");return F0.useEffect(()=>{!n||a||(C("name",n.name),C("description",n.description),C("metricId",n.metricId))},[n]),F0.useEffect(()=>{var d;!n&&((d=u==null?void 0:u.trim())==null?void 0:d.length)>=4&&!A&&C("metricId",`${u}_${em(10)}`)},[n,u]),h.jsxs("form",{onSubmit:r(d=>t(d,!1)),children:[h.jsxs("div",{className:s02.container,children:[h.jsx(K9,{name:"name",type:"text",placeholder:"What is the name of the metric?",label:"Metric Name",register:s("name",{required:{value:!0,message:"Metric name is required"}}),error:(f=l.name)==null?void 0:f.message,defaultValue:n==null?void 0:n.name,isImportant:!0}),h.jsx(ai0,{className:s02.field,id:"desc",placeholder:"What is the name of the metric?",label:"Description",rows:5,register:s("description"),defaultValue:n==null?void 0:n.description})]}),!!o&&h.jsx(e6,{variant:"body-text-2",color:"alert",children:o}),a&&h.jsx("div",{className:"dbn-absolute dbn-w-full dbn-h-full dbn-top-0 dbn-bg-black/[0.1]",children:h.jsx(CA,{})}),h.jsxs(rd,{children:[h.jsx(a8,{type:"reset",variant:"tab",onClick:i,children:"Cancel"}),h.jsx(a8,{type:"submit",variant:"primary",isDisabled:a,children:"Save"})]})]})},El={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 iW(t,n){return iW=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},iW(t,n)}function nm(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,iW(t,n)}var D$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])})},xs2={error:null},N$2=function(t){nm(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=xs2,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(xs2)},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&&D$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(F0.isValidElement(l))return l;if(typeof r=="function")return r(e);if(C)return F0.createElement(C,e);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(F0.Component),YB=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 BS=typeof window>"u";function rA(){}function S$2(t,n){return typeof t=="function"?t(n):t}function oW(t){return typeof t=="number"&&t>=0&&t!==1/0}function yS(t){return Array.isArray(t)?t:[t]}function Rs2(t,n){return Math.max(t+(n||0)-Date.now(),0)}function LS(t,n,i){return JQ(t)?typeof n=="function"?$s({},i,{queryKey:t,queryFn:n}):$s({},n,{queryKey:t}):t}function V$2(t,n,i){return JQ(t)?typeof n=="function"?$s({},i,{mutationKey:t,mutationFn:n}):$s({},n,{mutationKey:t}):typeof t=="function"?$s({},n,{mutationFn:t}):$s({},t)}function xp(t,n,i){return JQ(t)?[$s({},n,{queryKey:t}),i]:[t||{},n]}function k$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 Hs2(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(JQ(C)){if(o){if(n.queryHash!==aW(C,n.options))return!1}else if(!wS(n.queryKey,C))return!1}var e=k$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 Ds2(t,n){var i=t.exact,o=t.fetching,a=t.predicate,s=t.mutationKey;if(JQ(s)){if(!n.options.mutationKey)return!1;if(i){if(im(n.options.mutationKey)!==im(s))return!1}else if(!wS(n.options.mutationKey,s))return!1}return!(typeof o=="boolean"&&n.state.status==="loading"!==o||a&&!a(n))}function aW(t,n){var i=(n==null?void 0:n.queryKeyHashFn)||im;return i(t)}function im(t){var n=yS(t);return O$2(n)}function O$2(t){return JSON.stringify(t,function(n,i){return sW(i)?Object.keys(i).sort().reduce(function(o,a){return o[a]=i[a],o},{}):i})}function wS(t,n){return Ns2(yS(t),yS(n))}function Ns2(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!Ns2(t[i],n[i])}):!1}function QS(t,n){if(t===n)return t;var i=Array.isArray(t)&&Array.isArray(n);if(i||sW(t)&&sW(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]=QS(t[e],n[e]),r[e]===t[e]&&C++}return o===s&&C===o?t:r}return n}function P$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 sW(t){if(!Ss2(t))return!1;var n=t.constructor;if(typeof n>"u")return!0;var i=n.prototype;return!(!Ss2(i)||!i.hasOwnProperty("isPrototypeOf"))}function Ss2(t){return Object.prototype.toString.call(t)==="[object Object]"}function JQ(t){return typeof t=="string"||Array.isArray(t)}function Z$2(t){return new Promise(function(n){setTimeout(n,t)})}function Vs2(t){Promise.resolve().then(t).catch(function(n){return setTimeout(function(){throw n})})}function ks2(){if(typeof AbortController=="function")return new AbortController}var F$2=function(t){nm(n,t);function n(){var o;return o=t.call(this)||this,o.setup=function(a){var s;if(!BS&&((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}(YB),qQ=new F$2,U$2=function(t){nm(n,t);function n(){var o;return o=t.call(this)||this,o.setup=function(a){var s;if(!BS&&((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}(YB),MS=new U$2;function j$2(t){return Math.min(1e3*Math.pow(2,t),3e4)}function TS(t){return typeof(t==null?void 0:t.cancel)=="function"}var Os2=function(n){this.revert=n==null?void 0:n.revert,this.silent=n==null?void 0:n.silent};function xS(t){return t instanceof Os2}var Ps2=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(p){if(!i.isResolved&&(e(new Os2(p)),i.abort==null||i.abort(),TS(d)))try{d.cancel()}catch{}},i.isTransportCancelable=TS(d),Promise.resolve(d).then(l).catch(function(g){var p,b;if(!i.isResolved){var w=(p=n.retry)!=null?p:3,T=(b=n.retryDelay)!=null?b:j$2,H=typeof T=="function"?T(i.failureCount,g):T,S=w===!0||typeof w=="number"&&i.failureCount<w||typeof w=="function"&&w(i.failureCount,g);if(o||!S){e(g);return}i.failureCount++,n.onFail==null||n.onFail(i.failureCount,g),Z$2(H).then(function(){if(!qQ.isFocused()||!MS.isOnline())return u()}).then(function(){o?e(g):f()})}})}};A()},z$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):Vs2(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&&Vs2(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}(),Ql=new z$2,Zs2=console;function RS(){return Zs2}function G$2(t){Zs2=t}var Y$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(),oW(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=S$2(o,C);return(s=(r=this.options).isDataEqual)!=null&&s.call(r,C,l)?l=C:this.options.structuralSharing!==!1&&(l=QS(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(rA).catch(rA):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||!Rs2(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(T){return T.options.queryFn});u&&this.setOptions(u.options)}var A=yS(this.queryKey),f=ks2(),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")},p={fetchOptions:a,options:this.options,queryKey:A,state:this.state,fetchFn:g,meta:this.meta};if((r=this.options.behavior)!=null&&r.onFetch){var b;(b=this.options.behavior)==null||b.onFetch(p)}if(this.revertState=this.state,!this.state.isFetching||this.state.fetchMeta!==((C=p.fetchOptions)==null?void 0:C.meta)){var w;this.dispatch({type:"fetch",meta:(w=p.fetchOptions)==null?void 0:w.meta})}return this.retryer=new Ps2({fn:p.fetchFn,abort:f==null||(l=f.abort)==null?void 0:l.bind(f),onSuccess:function(H){s.setData(H),s.cache.config.onSuccess==null||s.cache.config.onSuccess(H,s),s.cacheTime===0&&s.optionalRemove()},onError:function(H){xS(H)&&H.silent||s.dispatch({type:"error",error:H}),xS(H)||(s.cache.config.onError==null||s.cache.config.onError(H,s),RS().error(H)),s.cacheTime===0&&s.optionalRemove()},onFail:function(){s.dispatch({type:"failed"})},onPause:function(){s.dispatch({type:"pause"})},onContinue:function(){s.dispatch({type:"continue"})},retry:p.options.retry,retryDelay:p.options.retryDelay}),this.promise=this.retryer.promise,this.promise},n.dispatch=function(o){var a=this;this.state=this.reducer(this.state,o),Ql.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 xS(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}(),W$2=function(t){nm(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:aW(l,s),u=this.get(e);return u||(u=new Y$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;Ql.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=xp(a,s),C=r[0];return typeof C.exact>"u"&&(C.exact=!0),this.queries.find(function(l){return Hs2(C,l)})},i.findAll=function(a,s){var r=xp(a,s),C=r[0];return Object.keys(C).length>0?this.queries.filter(function(l){return Hs2(C,l)}):this.queries},i.notify=function(a){var s=this;Ql.batch(function(){s.listeners.forEach(function(r){r(a)})})},i.onFocus=function(){var a=this;Ql.batch(function(){a.queries.forEach(function(s){s.onFocus()})})},i.onOnline=function(){var a=this;Ql.batch(function(){a.queries.forEach(function(s){s.onOnline()})})},n}(YB),_$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||Fs2(),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(rA).catch(rA)):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),RS().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 Ps2({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=X$2(this.state,o),Ql.batch(function(){a.observers.forEach(function(s){s.onMutationUpdate(o)}),a.mutationCache.notify(a)})},t}();function Fs2(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}function X$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 K$2=function(t){nm(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 _$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;Ql.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 Ds2(a,s)})},i.findAll=function(a){return this.mutations.filter(function(s){return Ds2(a,s)})},i.notify=function(a){var s=this;Ql.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 Ql.batch(function(){return a.reduce(function(s,r){return s.then(function(){return r.continue().catch(rA)})},Promise.resolve())})},n}(YB);function J$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)||[],p=ks2(),b=p==null?void 0:p.signal,w=g,T=!1,H=n.options.queryFn||function(){return Promise.reject("Missing queryFn")},S=function(m2,k2,W2,c0){return w=c0?[k2].concat(w):[].concat(w,[k2]),c0?[W2].concat(m2):[].concat(m2,[W2])},N=function(m2,k2,W2,c0){if(T)return Promise.reject("Cancelled");if(typeof W2>"u"&&!k2&&m2.length)return Promise.resolve(m2);var p0={queryKey:n.queryKey,signal:b,pageParam:W2,meta:n.meta},L0=H(p0),b0=Promise.resolve(L0).then(function(t1){return S(m2,W2,t1,c0)});if(TS(L0)){var j2=b0;j2.cancel=L0.cancel}return b0},X;if(!d.length)X=N([]);else if(A){var W=typeof u<"u",f2=W?u:Us2(n.options,d);X=N(d,W,f2)}else if(f){var Q2=typeof u<"u",I2=Q2?u:q$2(n.options,d);X=N(d,Q2,I2,!0)}else(function(){w=[];var M2=typeof n.options.getNextPageParam>"u",m2=l&&d[0]?l(d[0],0,d):!0;X=m2?N([],M2,g[0]):Promise.resolve(S([],g[0],d[0]));for(var k2=function(p0){X=X.then(function(L0){var b0=l&&d[p0]?l(d[p0],p0,d):!0;if(b0){var j2=M2?g[p0]:Us2(n.options,L0);return N(L0,M2,j2)}return Promise.resolve(S(L0,g[p0],d[p0]))})},W2=1;W2<d.length;W2++)k2(W2)})();var r2=X.then(function(M2){return{pages:M2,pageParams:w}}),D2=r2;return D2.cancel=function(){T=!0,p==null||p.abort(),TS(X)&&X.cancel()},r2}}}}function Us2(t,n){return t.getNextPageParam==null?void 0:t.getNextPageParam(n[n.length-1],n)}function q$2(t,n){return t.getPreviousPageParam==null?void 0:t.getPreviousPageParam(n[0],n)}var $$2=function(){function t(i){i===void 0&&(i={}),this.queryCache=i.queryCache||new W$2,this.mutationCache=i.mutationCache||new K$2,this.defaultOptions=i.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}var n=t.prototype;return n.mount=function(){var o=this;this.unsubscribeFocus=qQ.subscribe(function(){qQ.isFocused()&&MS.isOnline()&&(o.mutationCache.onFocus(),o.queryCache.onFocus())}),this.unsubscribeOnline=MS.subscribe(function(){qQ.isFocused()&&MS.isOnline()&&(o.mutationCache.onOnline(),o.queryCache.onOnline())})},n.unmount=function(){var o,a;(o=this.unsubscribeFocus)==null||o.call(this),(a=this.unsubscribeOnline)==null||a.call(this)},n.isFetching=function(o,a){var s=xp(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=LS(o),C=this.defaultQueryOptions(r);return this.queryCache.build(this,C).setData(a,s)},n.setQueriesData=function(o,a,s){var r=this;return Ql.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=xp(o,a),r=s[0],C=this.queryCache;Ql.batch(function(){C.findAll(r).forEach(function(l){C.remove(l)})})},n.resetQueries=function(o,a,s){var r=this,C=xp(o,a,s),l=C[0],e=C[1],u=this.queryCache,A=$s({},l,{active:!0});return Ql.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=xp(o,a,s),l=C[0],e=C[1],u=e===void 0?{}:e;typeof u.revert>"u"&&(u.revert=!0);var A=Ql.batch(function(){return r.queryCache.findAll(l).map(function(f){return f.cancel(u)})});return Promise.all(A).then(rA).catch(rA)},n.invalidateQueries=function(o,a,s){var r,C,l,e=this,u=xp(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 Ql.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=xp(o,a,s),l=C[0],e=C[1],u=Ql.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(rA);return e!=null&&e.throwOnError||(A=A.catch(rA)),A},n.fetchQuery=function(o,a,s){var r=LS(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(rA).catch(rA)},n.fetchInfiniteQuery=function(o,a,s){var r=LS(o,a,s);return r.behavior=J$2(),this.fetchQuery(r)},n.prefetchInfiniteQuery=function(o,a,s){return this.fetchInfiniteQuery(o,a,s).then(rA).catch(rA)},n.cancelMutations=function(){var o=this,a=Ql.batch(function(){return o.mutationCache.getAll().map(function(s){return s.cancel()})});return Promise.all(a).then(rA).catch(rA)},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 im(o)===im(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 wS(o,s.queryKey)}))==null?void 0:a.defaultOptions:void 0},n.setMutationDefaults=function(o,a){var s=this.mutationDefaults.find(function(r){return im(o)===im(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 wS(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=aW(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}(),e20=function(t){nm(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),js2(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},i.onUnsubscribe=function(){this.listeners.length||this.destroy()},i.shouldFetchOnReconnect=function(){return CW(this.currentQuery,this.options,this.options.refetchOnReconnect)},i.shouldFetchOnWindowFocus=function(){return CW(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(rA)),s},i.updateStaleTimeout=function(){var a=this;if(this.clearStaleTimeout(),!(BS||this.currentResult.isStale||!oW(this.options.staleTime))){var s=Rs2(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,!(BS||this.options.enabled===!1||!oW(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(function(){(s.options.refetchIntervalInBackground||qQ.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,p=g.dataUpdatedAt,b=g.error,w=g.errorUpdatedAt,T=g.isFetching,H=g.status,S=!1,N=!1,X;if(s.optimisticResults){var W=this.hasListeners(),f2=!W&&js2(a,s),Q2=W&&zs2(a,r,s,C);(f2||Q2)&&(T=!0,p||(H="loading"))}if(s.keepPreviousData&&!g.dataUpdateCount&&(d!=null&&d.isSuccess)&&H!=="error")X=d.data,p=d.dataUpdatedAt,H=d.status,S=!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=QS(l==null?void 0:l.data,X)),this.selectResult=X,this.selectError=null}catch(D2){RS().error(D2),this.selectError=D2}else X=g.data;if(typeof s.placeholderData<"u"&&typeof X>"u"&&(H==="loading"||H==="idle")){var I2;if(l!=null&&l.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData))I2=l.data;else if(I2=typeof s.placeholderData=="function"?s.placeholderData():s.placeholderData,s.select&&typeof I2<"u")try{I2=s.select(I2),s.structuralSharing!==!1&&(I2=QS(l==null?void 0:l.data,I2)),this.selectError=null}catch(D2){RS().error(D2),this.selectError=D2}typeof I2<"u"&&(H="success",X=I2,N=!0)}this.selectError&&(b=this.selectError,X=this.selectResult,w=Date.now(),H="error");var r2={status:H,isLoading:H==="loading",isSuccess:H==="success",isError:H==="error",isIdle:H==="idle",data:X,dataUpdatedAt:p,error:b,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:T,isRefetching:T&&H!=="loading",isLoadingError:H==="error"&&g.dataUpdatedAt===0,isPlaceholderData:N,isPreviousData:S,isRefetchError:H==="error"&&g.dataUpdatedAt!==0,isStale:lW(a,s),refetch:this.refetch,remove:this.remove};return r2},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(p){return p===u}),g=l==null?void 0:l.some(function(p){return p===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,!P$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"&&!xS(a.error)&&(s.onError=!0),this.updateResult(s),this.hasListeners()&&this.updateTimers()},i.notify=function(a){var s=this;Ql.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}(YB);function t20(t,n){return n.enabled!==!1&&!t.state.dataUpdatedAt&&!(t.state.status==="error"&&n.retryOnMount===!1)}function js2(t,n){return t20(t,n)||t.state.dataUpdatedAt>0&&CW(t,n,n.refetchOnMount)}function CW(t,n,i){if(n.enabled!==!1){var o=typeof i=="function"?i(t):i;return o==="always"||o!==!1&&lW(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")&&lW(t,i)}function lW(t,n){return t.isStaleByTime(n.staleTime)}var r20=function(t){nm(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:Fs2(),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;Ql.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}(YB),uW=cx();const AW=pA(uW);var n20=AW.unstable_batchedUpdates;Ql.setBatchNotifyFunction(n20);var i20=console;G$2(i20);var Gs2=w9.createContext(void 0),Ys2=w9.createContext(!1);function Ws2(t){return t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=Gs2),window.ReactQueryClientContext):Gs2}var cW=function(){var n=w9.useContext(Ws2(w9.useContext(Ys2)));if(!n)throw new Error("No QueryClient set, use QueryClientProvider to set one");return n},o20=function(n){var i=n.client,o=n.contextSharing,a=o===void 0?!1:o,s=n.children;w9.useEffect(function(){return i.mount(),function(){i.unmount()}},[i]);var r=Ws2(a);return w9.createElement(Ys2.Provider,{value:a},w9.createElement(r.Provider,{value:i},s))};function a20(){var t=!1;return{clearReset:function(){t=!1},reset:function(){t=!0},isReset:function(){return t}}}var s20=w9.createContext(a20()),C20=function(){return w9.useContext(s20)};function _s2(t,n,i){return typeof n=="function"?n.apply(void 0,i):typeof n=="boolean"?n:!!t}function Zl(t,n,i){var o=w9.useRef(!1),a=w9.useState(0),s=a[1],r=V$2(t,n,i),C=cW(),l=w9.useRef();l.current?l.current.setOptions(r):l.current=new r20(C,r);var e=l.current.getCurrentResult();w9.useEffect(function(){o.current=!0;var A=l.current.subscribe(Ql.batchCalls(function(){o.current&&s(function(f){return f+1})}));return function(){o.current=!1,A()}},[]);var u=w9.useCallback(function(A,f){l.current.mutate(A,f).catch(rA)},[]);if(e.error&&_s2(void 0,l.current.options.useErrorBoundary,[e.error]))throw e.error;return $s({},e,{mutate:u,mutateAsync:e.mutate})}function l20(t,n){var i=w9.useRef(!1),o=w9.useState(0),a=o[1],s=cW(),r=C20(),C=s.defaultQueryObserverOptions(t);C.optimisticResults=!0,C.onError&&(C.onError=Ql.batchCalls(C.onError)),C.onSuccess&&(C.onSuccess=Ql.batchCalls(C.onSuccess)),C.onSettled&&(C.onSettled=Ql.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=w9.useState(function(){return new n(s,C)}),e=l[0],u=e.getOptimisticResult(C);if(w9.useEffect(function(){i.current=!0,r.clearReset();var A=e.subscribe(Ql.batchCalls(function(){i.current&&a(function(f){return f+1})}));return e.updateResult(),function(){i.current=!1,A()}},[r,e]),w9.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&&_s2(C.suspense,C.useErrorBoundary,[u.error,e.getCurrentQuery()]))throw u.error;return C.notifyOnChangeProps==="tracked"&&(u=e.trackResult(u,C)),u}function Rp(t,n,i){var o=LS(t,n,i);return l20(o,e20)}var Ud,c4=typeof window<"u"?window:void 0,Sc=typeof globalThis<"u"?globalThis:c4,Xs2=Array.prototype,Ks2=Xs2.forEach,Js2=Xs2.indexOf,uf=Sc==null?void 0:Sc.navigator,Pn=Sc==null?void 0:Sc.document,Jf=Sc==null?void 0:Sc.location,fW=Sc==null?void 0:Sc.fetch,dW=Sc!=null&&Sc.XMLHttpRequest&&"withCredentials"in new Sc.XMLHttpRequest?Sc.XMLHttpRequest:void 0,qs2=Sc==null?void 0:Sc.AbortController,cu=uf==null?void 0:uf.userAgent,Zs=c4??{},$h={DEBUG:!1,LIB_VERSION:"1.234.1"},gW="$copy_autocapture",u20=["$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"})(Ud||(Ud={}));var A20=["fatal","error","warning","log","info","debug"];function rC(t,n){return t.indexOf(n)!==-1}var HS=function(t){return t.trim()},hW=function(t){return t.replace(/^\$/,"")},c20=Array.isArray,$s2=Object.prototype,eC2=$s2.hasOwnProperty,DS=$s2.toString,Fl=c20||function(t){return DS.call(t)==="[object Array]"},jd=t=>typeof t=="function",Ul=t=>t===Object(t)&&!Fl(t),WB=t=>{if(Ul(t)){for(var n in t)if(eC2.call(t,n))return!1;return!0}return!1},wr=t=>t===void 0,fu=t=>DS.call(t)=="[object String]",EW=t=>fu(t)&&t.trim().length===0,Hp=t=>t===null,rl=t=>wr(t)||Hp(t),nc=t=>DS.call(t)=="[object Number]",Dp=t=>DS.call(t)==="[object Boolean]",f20=t=>t instanceof FormData,d20=t=>rC(u20,t),tC2=t=>{var n={_log:function(i){if(c4&&($h.DEBUG||Zs.POSTHOG_DEBUG)&&!wr(c4.console)&&c4.console){for(var o=("__rrweb_original__"in c4.console[i])?c4.console[i].__rrweb_original__:c4.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=>tC2("".concat(t," ").concat(i))};return n},zi=tC2("[PostHog.js]"),DA=zi.createLogger,g20=DA("[ExternalScriptsLoader]"),rC2=(t,n,i)=>{if(t.config.disable_external_dependency_loading)return g20.warn("".concat(n," was requested but loading of external scripts is disabled.")),i("Loading of external scripts is disabled");var o=Pn==null?void 0:Pn.querySelectorAll("script");if(o){for(var a=0;a<o.length;a++)if(o[a].src===n)return i()}var s=()=>{if(!Pn)return i("document not found");var r=Pn.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=Pn.querySelectorAll("body > script");l.length>0?(C=l[0].parentNode)===null||C===void 0||C.insertBefore(r,l[0]):Pn.body.appendChild(r)};Pn!=null&&Pn.body?s():Pn==null||Pn.addEventListener("DOMContentLoaded",s)};function nC2(t,n){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),i.push.apply(i,o)}return i}function S4(t){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?nC2(Object(i),!0).forEach(function(o){kt(t,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):nC2(Object(i)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(i,o))})}return t}function kt(t,n,i){return n in t?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,t}function iC2(t,n){if(t==null)return{};var i,o,a=function(r,C){if(r==null)return{};var l,e,u={},A=Object.keys(r);for(e=0;e<A.length;e++)l=A[e],C.indexOf(l)>=0||(u[l]=r[l]);return u}(t,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)i=s[o],n.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(a[i]=t[i])}return a}Zs.__PosthogExtensions__=Zs.__PosthogExtensions__||{},Zs.__PosthogExtensions__.loadExternalDependency=(t,n,i)=>{var o="/static/".concat(n,".js")+"?v=".concat(t.version);if(n==="remote-config"&&(o="/array/".concat(t.config.token,"/config.js")),n==="toolbar"){var a=3e5,s=Math.floor(Date.now()/a)*a;o="".concat(o,"&t=").concat(s)}var r=t.requestRouter.endpointFor("assets",o);rC2(t,r,i)},Zs.__PosthogExtensions__.loadSiteApp=(t,n,i)=>{var o=t.requestRouter.endpointFor("api",n);rC2(t,o,i)};var NS={};function Np(t,n,i){if(Fl(t)){if(Ks2&&t.forEach===Ks2)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)===NS)return}}}function ol(t,n,i){if(!rl(t)){if(Fl(t))return Np(t,n,i);if(f20(t)){for(var o of t.entries())if(n.call(i,o[1],o[0])===NS)return}else for(var a in t)if(eC2.call(t,a)&&n.call(i,t[a],a)===NS)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 Np(i,function(a){for(var s in a)a[s]!==void 0&&(t[s]=a[s])}),t},SS=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 Np(i,function(a){Np(a,function(s){t.push(s)})}),t};function VS(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 oC2=function(t){try{return t()}catch{return}},h20=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){zi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),zi.critical(a)}}},$Q=function(t){var n={};return ol(t,function(i,o){fu(i)&&i.length>0&&(n[o]=i)}),n};function E20(t,n){return i=t,o=s=>fu(s)&&!Hp(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=[],Np(r,e=>{l.push(s(e))})):(l={},ol(r,(e,u)=>{a.has(e)||(l[u]=s(e,u))})),l);var l}(i);var i,o,a}var p20=["herokuapp.com","vercel.app","netlify.app"];function v20(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 p20)if(i===o)return!1;return!0}function aC2(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 sC2="$people_distinct_id",eM="__alias",tM="__timers",CC2="$autocapture_disabled_server_side",pW="$heatmaps_enabled_server_side",lC2="$exception_capture_enabled_server_side",uC2="$web_vitals_enabled_server_side",AC2="$dead_clicks_enabled_server_side",cC2="$web_vitals_allowed_metrics",vW="$session_recording_enabled_server_side",fC2="$console_log_recording_enabled_server_side",dC2="$session_recording_network_payload_capture",gC2="$session_recording_masking",hC2="$session_recording_canvas_recording",EC2="$replay_sample_rate",pC2="$replay_minimum_duration",vC2="$replay_script_config",kS="$sesid",rM="$session_is_sampled",IW="$session_recording_url_trigger_activated_session",mW="$session_recording_event_trigger_activated_session",_B="$enabled_feature_flags",OS="$early_access_features",bW="$feature_flag_details",nM="$stored_person_properties",om="$stored_group_properties",BW="$surveys",PS="$surveys_activated",ZS="$flag_call_reported",eE="$user_state",yW="$client_session_props",LW="$capture_rate_limit",wW="$initial_campaign_params",QW="$initial_referrer_info",MW="$initial_person_info",FS="$epp",IC2="__POSTHOG_TOOLBAR__",mC2="$posthog_cookieless",I20=[sC2,eM,"__cmpns",tM,vW,pW,kS,_B,eE,OS,bW,om,nM,BW,ZS,yW,LW,wW,QW,FS];function bC2(t){var n;return t instanceof Element&&(t.id===IC2||!((n=t.closest)===null||n===void 0||!n.call(t,".toolbar-global-fade-container")))}function US(t){return!!t&&t.nodeType===1}function Sp(t,n){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===n.toLowerCase()}function BC2(t){return!!t&&t.nodeType===3}function yC2(t){return!!t&&t.nodeType===11}function TW(t){return t?HS(t).split(/\s+/):[]}function LC2(t){var n=c4==null?void 0:c4.location.href;return!!(n&&t&&t.some(i=>n.match(i)))}function jS(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 TW(n)}function wC2(t){return rl(t)?null:HS(t).split(/(\s+)/).filter(n=>XB(n)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function zS(t){var n="";return RW(t)&&!TC2(t)&&t.childNodes&&t.childNodes.length&&ol(t.childNodes,function(i){var o;BC2(i)&&i.textContent&&(n+=(o=wC2(i.textContent))!==null&&o!==void 0?o:"")}),HS(n)}function QC2(t){return wr(t.target)?t.srcElement||null:(n=t.target)!==null&&n!==void 0&&n.shadowRoot?t.composedPath()[0]||null:t.target||null;var n}var xW=["a","button","form","input","select","textarea","label"];function MC2(t){var n=t.parentNode;return!(!n||!US(n))&&n}function m20(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(!c4||!t||Sp(t,"html")||!US(t)||i!=null&&i.url_allowlist&&!LC2(i.url_allowlist)||i!=null&&i.url_ignorelist&&LC2(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&&!Sp(e,"body");)if(yC2(e.parentNode))C.push(e.parentNode.host),e=e.parentNode.host;else{if(!(l=MC2(e)))break;if(o||xW.indexOf(l.tagName.toLowerCase())>-1)r=!0;else{var u=c4.getComputedStyle(l);u&&u.getPropertyValue("cursor")==="pointer"&&(r=!0)}C.push(l),e=l}if(!function(d,g){var p=g==null?void 0:g.element_allowlist;if(wr(p))return!0;var b=function(H){if(p.some(S=>H.tagName.toLowerCase()===S))return{v:!0}};for(var w of d){var T=b(w);if(typeof T=="object")return T.v}return!1}(C,i)||!function(d,g){var p=g==null?void 0:g.css_selector_allowlist;if(wr(p))return!0;var b=function(H){if(p.some(S=>H.matches(S)))return{v:!0}};for(var w of d){var T=b(w);if(typeof T=="object")return T.v}return!1}(C,i))return!1;var A=c4.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&&(xW.indexOf(f)>-1||t.getAttribute("contenteditable")==="true")}}function RW(t){for(var n=t;n.parentNode&&!Sp(n,"body");n=n.parentNode){var i=jS(n);if(rC(i,"ph-sensitive")||rC(i,"ph-no-capture"))return!1}if(rC(jS(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 TC2(t){return!!(Sp(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Sp(t,"select")||Sp(t,"textarea")||t.getAttribute("contenteditable")==="true")}var xC2="(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})",b20=new RegExp("^(?:".concat(xC2,")$")),B20=new RegExp(xC2),RC2="\\d{3}-?\\d{2}-?\\d{4}",y20=new RegExp("^(".concat(RC2,")$")),L20=new RegExp("(".concat(RC2,")"));function XB(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(rl(t)||fu(t)&&(t=HS(t),(n?b20:B20).test((t||"").replace(/[- ]/g,""))||(n?y20:L20).test(t)))}function HC2(t){var n=zS(t);return XB(n="".concat(n," ").concat(DC2(t)).trim())?n:""}function DC2(t){var n="";return t&&t.childNodes&&t.childNodes.length&&ol(t.childNodes,function(i){var o;if(i&&((o=i.tagName)===null||o===void 0?void 0:o.toLowerCase())==="span")try{var a=zS(i);n="".concat(n," ").concat(a).trim(),i.childNodes&&i.childNodes.length&&(n="".concat(n," ").concat(DC2(i)).trim())}catch(s){zi.error("[AutoCapture]",s)}}),n}function w20(t){return function(n){var i=n.map(o=>{var a,s,r="";if(o.tag_name&&(r+=o.tag_name),o.attr_class)for(var C of(o.attr_class.sort(),o.attr_class))r+=".".concat(C.replace(/"/g,""));var l=S4(S4(S4(S4({},o.text?{text:o.text}:{}),{},{"nth-child":(a=o.nth_child)!==null&&a!==void 0?a:0,"nth-of-type":(s=o.nth_of_type)!==null&&s!==void 0?s:0},o.href?{href:o.href}:{}),o.attr_id?{attr_id:o.attr_id}:{}),o.attributes),e={};return VS(l).sort((u,A)=>{var[f]=u,[d]=A;return f.localeCompare(d)}).forEach(u=>{var[A,f]=u;return e[NC2(A.toString())]=NC2(f.toString())}),r+=":",r+=VS(l).map(u=>{var[A,f]=u;return"".concat(A,'="').concat(f,'"')}).join("")});return i.join(";")}(function(n){return n.map(i=>{var o,a,s={text:(o=i.$el_text)===null||o===void 0?void 0:o.slice(0,400),tag_name:i.tag_name,href:(a=i.attr__href)===null||a===void 0?void 0:a.slice(0,2048),attr_class:Q20(i),attr_id:i.attr__id,nth_child:i.nth_child,nth_of_type:i.nth_of_type,attributes:{}};return VS(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 NC2(t){return t.replace(/"|\\"/g,'\\"')}function Q20(t){var n=t.attr__class;return n?Fl(n)?n:TW(n):void 0}class SC2{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 M20=["localhost","127.0.0.1"],KB=t=>{var n=Pn==null?void 0:Pn.createElement("a");return wr(n)?null:(n.href=t,n)},T20=function(t){var n,i,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",a=[];return ol(t,function(s,r){wr(s)||wr(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)},GS=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{zi.error("Skipping decoding for malformed query param: "+r)}return r.replace(/\+/g," ")},HW=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},YS=function(t,n){var i=t.match(new RegExp(n+"=([^&]*)"));return i?i[1]:null},VC2=DA("[AutoCapture]");function DW(t,n){return n.length>t?n.slice(0,t)+"...":n}function x20(t){if(t.previousElementSibling)return t.previousElementSibling;var n=t;do n=n.previousSibling;while(n&&!US(n));return n}function R20(t,n,i,o){var a=t.tagName.toLowerCase(),s={tag_name:a};xW.indexOf(a)>-1&&!i&&(a.toLowerCase()==="a"||a.toLowerCase()==="button"?s.$el_text=DW(1024,HC2(t)):s.$el_text=DW(1024,zS(t)));var r=jS(t);r.length>0&&(s.classes=r.filter(function(u){return u!==""})),ol(t.attributes,function(u){var A;if((!TC2(t)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(o==null||!o.includes(u.name))&&!n&&XB(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=TW(f).join(" ")),s["attr__"+u.name]=DW(1024,f)}});for(var C=1,l=1,e=t;e=x20(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&&!Sp(u,"body");)yC2(u.parentNode)?(e.push(u.parentNode.host),u=u.parentNode.host):(e.push(u.parentNode),u=u.parentNode);var A,f=[],d={},g=!1,p=!1;if(ol(e,S=>{var N=RW(S);S.tagName.toLowerCase()==="a"&&(g=S.getAttribute("href"),g=N&&g&&XB(g)&&g),rC(jS(S),"ph-no-capture")&&(p=!0),f.push(R20(S,s,r,C));var X=function(W){if(!RW(W))return{};var f2={};return ol(W.attributes,function(Q2){if(Q2.name&&Q2.name.indexOf("data-ph-capture-attribute")===0){var I2=Q2.name.replace("data-ph-capture-attribute-",""),r2=Q2.value;I2&&r2&&XB(r2)&&(f2[I2]=r2)}}),f2}(S);du(d,X)}),p)return{props:{},explicitNoCapture:p};if(r||(t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?f[0].$el_text=HC2(t):f[0].$el_text=zS(t)),g){var b,w;f[0].attr__href=g;var T=(b=KB(g))===null||b===void 0?void 0:b.host,H=c4==null||(w=c4.location)===null||w===void 0?void 0:w.host;T&&H&&T!==H&&(A=g)}return{props:du({$event_type:a.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:w20(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 D20{constructor(n){kt(this,"_initialized",!1),kt(this,"_isDisabledServerSide",null),kt(this,"rageclicks",new SC2),kt(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(c4&&Pn){var n=o=>{o=o||(c4==null?void 0:c4.event);try{this._captureEvent(o)}catch(a){VC2.error("Failed to capture event",a)}};if($l(Pn,"submit",n,{capture:!0}),$l(Pn,"change",n,{capture:!0}),$l(Pn,"click",n,{capture:!0}),this.config.capture_copied_text){var i=o=>{o=o||(c4==null?void 0:c4.event),this._captureEvent(o,gW)};$l(Pn,"copy",i,{capture:!0}),$l(Pn,"cut",i,{capture:!0})}}}else VC2.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({[CC2]:!!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=Pn==null?void 0:Pn.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[CC2],a=this._isDisabledServerSide;if(Hp(a)&&!Dp(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=QC2(n);BC2(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===gW;if(a&&m20(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===gW){var e,u=wC2(c4==null||(e=c4.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 jd(Pn==null?void 0:Pn.querySelectorAll)}}Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return nc(t)&&isFinite(t)&&Math.floor(t)===t});var kC2="0123456789abcdef";class WS{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 WS(s)}toString(){for(var n="",i=0;i<this.bytes.length;i++)n=n+kC2.charAt(this.bytes[i]>>>4)+kC2.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 WS(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 N20{constructor(){kt(this,"timestamp",0),kt(this,"counter",0),kt(this,"random",new S20)}generate(){var n=this.generateOrAbort();if(wr(n)){this.timestamp=0;var i=this.generateOrAbort();if(wr(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 WS.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 OC2,PC2=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};c4&&!wr(c4.crypto)&&crypto.getRandomValues&&(PC2=t=>crypto.getRandomValues(t));class S20{constructor(){kt(this,"buffer",new Uint32Array(8)),kt(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(PC2(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var Vp=()=>V20().toString(),V20=()=>(OC2||(OC2=new N20)).generate(),k20="Thu, 01 Jan 1970 00:00:00 GMT",iM="",O20=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function P20(t,n){if(n){var i=function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pn;if(iM)return iM;if(!s||["localhost","127.0.0.1"].includes(a))return"";for(var r=a.split("."),C=Math.min(r.length,8),l="dmn_chk_"+Vp(),e=new RegExp("(^|;)\\s*"+l+"=1");!iM&&C--;){var u=r.slice(C).join("."),A=l+"=1;domain=."+u;s.cookie=A,e.test(s.cookie)&&(s.cookie=A+";expires="+k20,iM=u)}return iM}(t);if(!i){var o=(a=>{var s=a.match(O20);return s?s[0]:""})(t);o!==i&&zi.info("Warning: cookie subdomain discovery mismatch",o,i),i=o}return i?"; domain=."+i:""}return""}var kp,tE={is_supported:()=>!!Pn,error:function(t){zi.error("cookieStore error: "+t)},get:function(t){if(Pn){try{for(var n=t+"=",i=Pn.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(tE.get(t))||{}}catch{}return n},set:function(t,n,i,o,a){if(Pn)try{var s="",r="",C=P20(Pn.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&&zi.warn("cookieStore warning: large cookie, len="+e.length),Pn.cookie=e,e}catch{return}},remove:function(t,n){try{tE.set(t,"",-1,n)}catch{return}}},NW=null,Qu={is_supported:function(){if(!Hp(NW))return NW;var t=!0;if(wr(c4))t=!1;else try{var n="__mplssupport__";Qu.set(n,"xyz"),Qu.get(n)!=='"xyz"'&&(t=!1),Qu.remove(n)}catch{t=!1}return t||zi.error("localStorage unsupported; falling back to cookie store"),NW=t,t},error:function(t){zi.error("localStorage error: "+t)},get:function(t){try{return c4==null?void 0:c4.localStorage.getItem(t)}catch(n){Qu.error(n)}return null},parse:function(t){try{return JSON.parse(Qu.get(t))||{}}catch{}return null},set:function(t,n){try{c4==null||c4.localStorage.setItem(t,JSON.stringify(n))}catch(i){Qu.error(i)}},remove:function(t){try{c4==null||c4.localStorage.removeItem(t)}catch(n){Qu.error(n)}}},Z20=["distinct_id",kS,rM,FS,MW],_S=S4(S4({},Qu),{},{parse:function(t){try{var n={};try{n=tE.parse(t)||{}}catch{}var i=du(n,JSON.parse(Qu.get(t)||"{}"));return Qu.set(t,i),i}catch{}return null},set:function(t,n,i,o,a,s){try{Qu.set(t,n,void 0,void 0,s);var r={};Z20.forEach(C=>{n[C]&&(r[C]=n[C])}),Object.keys(r).length&&tE.set(t,r,i,o,a,s)}catch(C){Qu.error(C)}},remove:function(t,n){try{c4==null||c4.localStorage.removeItem(t),tE.remove(t,n)}catch(i){Qu.error(i)}}}),XS={},F20={is_supported:function(){return!0},error:function(t){zi.error("memoryStorage error: "+t)},get:function(t){return XS[t]||null},parse:function(t){return XS[t]||null},set:function(t,n){XS[t]=n},remove:function(t){delete XS[t]}},am=null,nA={is_supported:function(){if(!Hp(am))return am;if(am=!0,wr(c4))am=!1;else try{var t="__support__";nA.set(t,"xyz"),nA.get(t)!=='"xyz"'&&(am=!1),nA.remove(t)}catch{am=!1}return am},error:function(t){zi.error("sessionStorage error: ",t)},get:function(t){try{return c4==null?void 0:c4.sessionStorage.getItem(t)}catch(n){nA.error(n)}return null},parse:function(t){try{return JSON.parse(nA.get(t))||null}catch{}return null},set:function(t,n){try{c4==null||c4.sessionStorage.setItem(t,JSON.stringify(n))}catch(i){nA.error(i)}},remove:function(t){try{c4==null||c4.sessionStorage.removeItem(t)}catch(n){nA.error(n)}}};(function(t){t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED"})(kp||(kp={}));class U20{constructor(n){this.instance=n}get config(){return this.instance.config}get consent(){return this.getDnt()?kp.DENIED:this.storedConsent}isOptedOut(){return this.consent===kp.DENIED||this.consent===kp.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"?kp.GRANTED:n==="0"?kp.DENIED:kp.PENDING}get storage(){if(!this._storage){var n=this.config.opt_out_capturing_persistence_type;this._storage=n==="localStorage"?Qu:tE;var i=n==="localStorage"?tE:Qu;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&&!!aC2([uf==null?void 0:uf.doNotTrack,uf==null?void 0:uf.msDoNotTrack,Zs.doNotTrack],n=>rC([!0,1,"1","yes"],n))}}var KS=DA("[Dead Clicks]"),j20=()=>!0,z20=t=>{var n,i=!((n=t.instance.persistence)===null||n===void 0||!n.get_property(AC2)),o=t.instance.config.capture_dead_clicks;return Dp(o)?o:i};class ZC2{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({[AC2]:n==null?void 0:n.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(n){var i,o,a;(i=Zs.__PosthogExtensions__)!==null&&i!==void 0&&i.initDeadClicksAutocapture&&n(),(o=Zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"dead-clicks-autocapture",s=>{s?KS.error("failed to load script",s):n()})}start(){var n;if(Pn){if(!this._lazyLoadedDeadClicksAutocapture&&(n=Zs.__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=Zs.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this._lazyLoadedDeadClicksAutocapture.start(Pn),KS.info("starting...")}}else KS.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,KS.info("stopping..."))}}var JS=DA("[ExceptionAutocapture]");class G20{constructor(n){var i;kt(this,"startCapturing",()=>{var o,a,s,r,C,l;if(c4&&this.isEnabled){var e=(o=Zs.__PosthogExtensions__)===null||o===void 0||(a=o.errorWrappingFunctions)===null||a===void 0?void 0:a.wrapOnError,u=(s=Zs.__PosthogExtensions__)===null||s===void 0||(r=s.errorWrappingFunctions)===null||r===void 0?void 0:r.wrapUnhandledRejection,A=(C=Zs.__PosthogExtensions__)===null||C===void 0||(l=C.errorWrappingFunctions)===null||l===void 0?void 0:l.wrapConsoleError;if(e&&u&&A)try{this.unwrapOnError||(this.unwrapOnError=e(this.captureException.bind(this))),this.unwrapUnhandledRejection||(this.unwrapUnhandledRejection=u(this.captureException.bind(this))),this.unwrapConsoleError||(this.unwrapConsoleError=A(this.captureException.bind(this)))}catch(f){JS.error("failed to start",f),this.stopCapturing()}else JS.error("failed to load error wrapping functions - cannot start")}}),this.instance=n,this.remoteEnabled=!((i=this.instance.persistence)===null||i===void 0||!i.props[lC2]),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=S4(S4({},i),n):(wr(n)?this.remoteEnabled:n)&&(i=S4(S4({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}get hasHandlers(){return!wr(this.unwrapOnError)&&!wr(this.unwrapUnhandledRejection)&&!wr(this.unwrapConsoleError)}startIfEnabled(){this.isEnabled&&!this.hasHandlers&&(JS.info("enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(n){var i,o;this.hasHandlers&&n(),(i=Zs.__PosthogExtensions__)===null||i===void 0||(o=i.loadExternalDependency)===null||o===void 0||o.call(i,this.instance,"exception-autocapture",a=>{if(a)return JS.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({[lC2]: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 FC2(t){return!wr(Event)&&UC2(t,Event)}function UC2(t,n){try{return t instanceof n}catch{return!1}}function qS(t,n){return Object.prototype.toString.call(t)==="[object ".concat(n,"]")}function SW(t){return qS(t,"DOMError")}var jC2=/\(error: (.*)\)/,zC2=50,JB="?";function VW(t,n,i,o){var a={platform:"web:javascript",filename:t,function:n==="<anonymous>"?JB:n,in_app:!0};return wr(i)||(a.lineno=i),wr(o)||(a.colno=o),a}var Y20=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,W20=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_20=/\((\S*)(?::(\d+))(?::(\d+))\)/,X20=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,K20=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,J20=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var o=n.sort((a,s)=>a[0]-s[0]).map(a=>a[1]);return function(a){for(var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=[],C=a.split(`
|
|
595
595
|
`),l=s;l<C.length;l++){var e=C[l];if(!(e.length>1024)){var u=jC2.test(e)?e.replace(jC2,"$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(p=>S4(S4({},p),{},{filename:p.filename||q20(g).filename,function:p.function||JB}))}(r)}}([30,t=>{var n=Y20.exec(t);if(n){var[,i,o,a]=n;return VW(i,JB,+o,+a)}var s=W20.exec(t);if(s){if(s[2]&&s[2].indexOf("eval")===0){var r=_20.exec(s[2]);r&&(s[2]=r[1],s[3]=r[2],s[4]=r[3])}var[C,l]=YC2(s[1]||JB,s[2]);return VW(l,C,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,t=>{var n=X20.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var i=K20.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]||JB;return[a,o]=YC2(a,o),VW(o,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}]);function q20(t){return t[t.length-1]||{}}var $S,GC2,kW,YC2=(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]:JB,i?"safari-extension:".concat(n):"safari-web-extension:".concat(n)]:[t,n]},$20=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function OW(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=t.stacktrace||t.stack||"",o=function(r){return r&&e00.test(r.message)?1:0}(t);try{var a=J20,s=function(r,C){var l=function(e){var u=globalThis._posthogChunkIds;if(!u)return{};var A=Object.keys(u);return kW&&A.length===GC2||(GC2=A.length,kW=A.reduce((f,d)=>{$S||($S={});var g=$S[d];if(g)f[g[0]]=g[1];else for(var p=e(d),b=p.length-1;b>=0;b--){var w=p[b],T=w==null?void 0:w.filename,H=u[d];if(T&&H){f[T]=H,$S[d]=[T,H];break}}return f},{})),kW}(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 e00=/Minified React error #\d+;/i;function PW(t,n){var i,o,a=OW(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 ZW(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=OW(n.syntheticException,1);l.length&&(C.stacktrace={frames:l,type:"raw"})}return{$exception_list:[C],$exception_level:"error"}}function t00(t){return fu(t)&&!EW(t)&&A20.indexOf(t)>=0}function r00(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:FC2(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=OW(n==null?void 0:n.syntheticException,1);e.length&&(l.stacktrace={frames:e,type:"raw"})}return{$exception_list:[l],$exception_level:t00(t.level)?t.level:"error"}}function n00(t,n){var{error:i,event:o}=t,a={$exception_list:[]},s=i||o;if(SW(s)||function(d){return qS(d,"DOMException")}(s)){var r=s;if(function(d){return"stack"in d}(s))a=PW(s,n);else{var C=r.name||(SW(r)?"DOMError":"DOMException"),l=r.message?"".concat(C,": ").concat(r.message):C,e=SW(r)?"DOMError":"DOMException";a=ZW(l,S4(S4({},n),{},{overrideExceptionType:e,defaultExceptionMessage:l}))}return"code"in r&&(a.$exception_DOMException_code="".concat(r.code)),a}if(function(d){return qS(d,"ErrorEvent")}(s)&&s.error)return PW(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 UC2(d,Error)}}(s))return PW(s,n);if(function(d){return qS(d,"Object")}(s)||FC2(s))return r00(s,n);if(wr(i)&&fu(o)){var u="Error",A=o,f=o.match($20);return f&&(u=f[1],A=f[2]),ZW(A,S4(S4({},n),{},{overrideExceptionType:u,defaultExceptionMessage:A}))}return ZW(s,n)}function eV(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 FW(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[FW({size:eV(o),data:o,sessionId:t.sessionId,windowId:t.windowId}),FW({size:eV(a),data:a,sessionId:t.sessionId,windowId:t.windowId})].flatMap(s=>s)}return[t]}var rE=(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))(rE||{}),zd=(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))(zd||{}),UW="[SessionRecording]",jW="redacted",tV={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"]},i00=["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"],o00=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],a00=["/s/","/e/","/i/"];function WC2(t,n,i,o){if(rl(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?UW+" ".concat(o," body too large to record (").concat(a," bytes)"):t}function _C2(t,n){if(rl(t))return t;var i=t;return XB(i,!1)||(i=UW+" "+n+" body "+jW),ol(o00,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=UW+" "+n+" body "+jW+" as might contain: "+o)}),i}var s00=(t,n)=>{var i,o,a,s={payloadSizeLimitBytes:tV.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...tV.performanceEntryTypeToObserve],payloadHostDenyList:[...n.payloadHostDenyList||[],...tV.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=WC2(f.requestBody,f.requestHeaders,a,"Request")),f!=null&&f.responseBody&&(f.responseBody=WC2(f.responseBody,f.responseHeaders,a,"Response")),f)),u=f=>{return e(((p,b)=>{var w,T=KB(p.name),H=b.indexOf("http")===0?(w=KB(b))===null||w===void 0?void 0:w.pathname:b;H==="/"&&(H="");var S=T==null?void 0:T.pathname.replace(H||"","");if(!(T&&S&&a00.some(N=>S.indexOf(N)===0)))return p})((g=(d=f).requestHeaders,rl(g)||ol(Object.keys(g??{}),p=>{i00.includes(p.toLowerCase())&&(g[p]=jW)}),d),t.api_host));var d,g},A=jd(t.session_recording.maskNetworkRequestFn);return A&&jd(t.session_recording.maskCapturedNetworkRequestFn)&&zi.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),A&&(t.session_recording.maskCapturedNetworkRequestFn=f=>{var d=t.session_recording.maskNetworkRequestFn({url:f.name});return S4(S4({},f),{},{name:d==null?void 0:d.url})}),s.maskRequestFn=jd(t.session_recording.maskCapturedNetworkRequestFn)?f=>{var d,g,p,b=u(f);return b&&(d=(g=(p=t.session_recording).maskCapturedNetworkRequestFn)===null||g===void 0?void 0:g.call(p,b))!==null&&d!==void 0?d:void 0}:f=>function(d){if(!wr(d))return d.requestBody=_C2(d.requestBody,"Request"),d.responseBody=_C2(d.responseBody,"Response"),d}(u(f)),S4(S4(S4({},tV),s),{},{recordHeaders:r,recordBody:C,recordPerformance:l,recordInitialRequests:l})};function qf(t,n,i,o,a){return n>i&&(zi.warn("min cannot be greater than max."),n=i),nc(t)?t>i?(o&&zi.warn(o+" cannot be greater than max: "+i+". Using max value instead."),i):t<n?(o&&zi.warn(o+" cannot be less than min: "+n+". Using min value instead."),n):t:(o&&zi.warn(o+" must be a number. using max or fallback. max: "+i+", fallback: "+a),qf(a||i,n,i,o))}class C00{constructor(n){var i,o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};kt(this,"bucketSize",100),kt(this,"refillRate",10),kt(this,"mutationBuckets",{}),kt(this,"loggedTracker",{}),kt(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]})}),kt(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]}),kt(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)}),kt(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=qf((i=this.options.refillRate)!==null&&i!==void 0?i:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=qf((o=this.options.bucketSize)!==null&&o!==void 0?o:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}}var $f=Uint8Array,Vc=Uint16Array,qB=Uint32Array,zW=new $f([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]),GW=new $f([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]),XC2=new $f([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),KC2=function(t,n){for(var i=new Vc(31),o=0;o<31;++o)i[o]=n+=1<<t[o-1];var a=new qB(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]},JC2=KC2(zW,2),l00=JC2[0],YW=JC2[1];l00[28]=258,YW[258]=28;for(var qC2=KC2(GW,0)[1],$C2=new Vc(32768),pl=0;pl<32768;++pl){var sm=(43690&pl)>>>1|(21845&pl)<<1;sm=(61680&(sm=(52428&sm)>>>2|(13107&sm)<<2))>>>4|(3855&sm)<<4,$C2[pl]=((65280&sm)>>>8|(255&sm)<<8)>>>1}var oM=function(t,n,i){for(var o=t.length,a=0,s=new Vc(n);a<o;++a)++s[t[a]-1];var r,C=new Vc(n);for(a=0;a<n;++a)C[a]=C[a-1]+s[a-1]<<1;for(r=new Vc(o),a=0;a<o;++a)r[a]=$C2[C[t[a]-1]++]>>>15-t[a];return r},Cm=new $f(288);for(pl=0;pl<144;++pl)Cm[pl]=8;for(pl=144;pl<256;++pl)Cm[pl]=9;for(pl=256;pl<280;++pl)Cm[pl]=7;for(pl=280;pl<288;++pl)Cm[pl]=8;var rV=new $f(32);for(pl=0;pl<32;++pl)rV[pl]=5;var u00=oM(Cm,9),A00=oM(rV,5),el2=function(t){return(t/8>>0)+(7&t&&1)},tl2=function(t,n,i){(i==null||i>t.length)&&(i=t.length);var o=new(t instanceof Vc?Vc:t instanceof qB?qB:$f)(i-n);return o.set(t.subarray(n,i)),o},nE=function(t,n,i){i<<=7&n;var o=n/8>>0;t[o]|=i,t[o+1]|=i>>>8},aM=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},WW=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 $f(0),0];if(a==1){var r=new $f(i[0].s+1);return r[i[0].s]=1,[r,1]}i.sort(function(N,X){return N.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 Vc(f+1),g=_W(i[u-1],d,0);if(g>n){o=0;var p=0,b=g-n,w=1<<b;for(s.sort(function(N,X){return d[X.s]-d[N.s]||N.f-X.f});o<a;++o){var T=s[o].s;if(!(d[T]>n))break;p+=w-(1<<g-d[T]),d[T]=n}for(p>>>=b;p>0;){var H=s[o].s;d[H]<n?p-=1<<n-d[H]++-1:++o}for(;o>=0&&p;--o){var S=s[o].s;d[S]==n&&(--d[S],++p)}g=n}return[new $f(d),g]},_W=function(t,n,i){return t.s==-1?Math.max(_W(t.l,n,i+1),_W(t.r,n,i+1)):n[t.s]=i},rl2=function(t){for(var n=t.length;n&&!t[--n];);for(var i=new Vc(++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]},sM=function(t,n){for(var i=0,o=0;o<n.length;++o)i+=t[o]*n[o];return i},XW=function(t,n,i){var o=i.length,a=el2(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)},nl2=function(t,n,i,o,a,s,r,C,l,e,u){nE(n,u++,i),++a[256];for(var A=WW(a,15),f=A[0],d=A[1],g=WW(s,15),p=g[0],b=g[1],w=rl2(f),T=w[0],H=w[1],S=rl2(p),N=S[0],X=S[1],W=new Vc(19),f2=0;f2<T.length;++f2)W[31&T[f2]]++;for(f2=0;f2<N.length;++f2)W[31&N[f2]]++;for(var Q2=WW(W,7),I2=Q2[0],r2=Q2[1],D2=19;D2>4&&!I2[XC2[D2-1]];--D2);var M2,m2,k2,W2,c0=e+5<<3,p0=sM(a,Cm)+sM(s,rV)+r,L0=sM(a,f)+sM(s,p)+r+14+3*D2+sM(W,I2)+(2*W[16]+3*W[17]+7*W[18]);if(c0<=p0&&c0<=L0)return XW(n,u,t.subarray(l,l+e));if(nE(n,u,1+(L0<p0)),u+=2,L0<p0){M2=oM(f,d),m2=f,k2=oM(p,b),W2=p;var b0=oM(I2,r2);for(nE(n,u,H-257),nE(n,u+5,X-1),nE(n,u+10,D2-4),u+=14,f2=0;f2<D2;++f2)nE(n,u+3*f2,I2[XC2[f2]]);u+=3*D2;for(var j2=[T,N],t1=0;t1<2;++t1){var h0=j2[t1];for(f2=0;f2<h0.length;++f2){var O0=31&h0[f2];nE(n,u,b0[O0]),u+=I2[O0],O0>15&&(nE(n,u,h0[f2]>>>5&127),u+=h0[f2]>>>12)}}}else M2=u00,m2=Cm,k2=A00,W2=rV;for(f2=0;f2<C;++f2)if(o[f2]>255){O0=o[f2]>>>18&31,aM(n,u,M2[O0+257]),u+=m2[O0+257],O0>7&&(nE(n,u,o[f2]>>>23&31),u+=zW[O0]);var U0=31&o[f2];aM(n,u,k2[U0]),u+=W2[U0],U0>3&&(aM(n,u,o[f2]>>>5&8191),u+=GW[U0])}else aM(n,u,M2[o[f2]]),u+=m2[o[f2]];return aM(n,u,M2[256]),u+m2[256]},c00=new qB([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),f00=function(){for(var t=new qB(256),n=0;n<256;++n){for(var i=n,o=9;--o;)i=(1&i&&3988292384)^i>>>1;t[n]=i}return t}(),d00=function(){var t=4294967295;return{p:function(n){for(var i=t,o=0;o<n.length;++o)i=f00[255&i^n[o]]^i>>>8;t=i},d:function(){return 4294967295^t}}},g00=function(t,n,i,o,a){return function(s,r,C,l,e,u){var A=s.length,f=new $f(l+A+5*(1+Math.floor(A/7e3))+e),d=f.subarray(l,f.length-e),g=0;if(!r||A<8)for(var p=0;p<=A;p+=65535){var b=p+65535;b<A?g=XW(d,g,s.subarray(p,b)):(d[p]=u,g=XW(d,g,s.subarray(p,A)))}else{for(var w=c00[r-1],T=w>>>13,H=8191&w,S=(1<<C)-1,N=new Vc(32768),X=new Vc(S+1),W=Math.ceil(C/3),f2=2*W,Q2=function(h6){return(s[h6]^s[h6+1]<<W^s[h6+2]<<f2)&S},I2=new qB(25e3),r2=new Vc(288),D2=new Vc(32),M2=0,m2=0,k2=(p=0,0),W2=0,c0=0;p<A;++p){var p0=Q2(p),L0=32767&p,b0=X[p0];if(N[L0]=b0,X[p0]=L0,W2<=p){var j2=A-p;if((M2>7e3||k2>24576)&&j2>423){g=nl2(s,d,0,I2,r2,D2,m2,k2,c0,p-c0,g),k2=M2=m2=0,c0=p;for(var t1=0;t1<286;++t1)r2[t1]=0;for(t1=0;t1<30;++t1)D2[t1]=0}var h0=2,O0=0,U0=H,X2=L0-b0&32767;if(j2>2&&p0==Q2(p-X2))for(var Q3=Math.min(T,j2)-1,x1=Math.min(32767,p),v3=Math.min(258,j2);X2<=x1&&--U0&&L0!=b0;){if(s[p+h0]==s[p+h0-X2]){for(var W3=0;W3<v3&&s[p+W3]==s[p+W3-X2];++W3);if(W3>h0){if(h0=W3,O0=X2,W3>Q3)break;var g7=Math.min(X2,W3-2),I3=0;for(t1=0;t1<g7;++t1){var $3=p-X2+t1+32768&32767,b7=$3-N[$3]+32768&32767;b7>I3&&(I3=b7,b0=$3)}}}X2+=(L0=b0)-(b0=N[L0])+32768&32767}if(O0){I2[k2++]=268435456|YW[h0]<<18|qC2[O0];var I7=31&YW[h0],R6=31&qC2[O0];m2+=zW[I7]+GW[R6],++r2[257+I7],++D2[R6],W2=p+h0,++M2}else I2[k2++]=s[p],++r2[s[p]]}}g=nl2(s,d,u,I2,r2,D2,m2,k2,c0,p-c0,g)}return tl2(f,0,l+el2(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)},KW=function(t,n,i){for(;i;++n)t[n]=i,i>>>=8},h00=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&&KW(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)}},E00=function(t){return 10+(t.filename&&t.filename.length+1||0)};function il2(t,n){n===void 0&&(n={});var i=d00(),o=t.length;i.p(t);var a=g00(t,n,E00(n),8),s=a.length;return h00(a,n),KW(a,s-8,i.d()),KW(a,s-4,o),a}function ol2(t,n){var i=t.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var o=new $f(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 $f(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 tl2(o,0,a)}function p00(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<qf(100*n,0,100)}var CM="[SessionRecording]",NA=DA(CM);function nV(){var t,n;return Zs==null||(t=Zs.__PosthogExtensions__)===null||t===void 0||(n=t.rrweb)===null||n===void 0?void 0:n.record}var v00=3e5,I00=[zd.MouseMove,zd.MouseInteraction,zd.Scroll,zd.ViewportResize,zd.Input,zd.TouchMove,zd.MediaInteraction,zd.Drag],al2=t=>({rrwebMethod:t,enqueuedAt:Date.now(),attempt:1});function lm(t){return function(n,i){for(var o="",a=0;a<n.length;){var s=n[a++];o+=String.fromCharCode(s)}return o}(il2(ol2(JSON.stringify(t))))}function sl2(t){return t.type===rE.Custom&&t.data.tag==="sessionIdle"}function Cl2(t,n){return n.some(i=>i.matching==="regex"&&new RegExp(i.url).test(t))}class m00{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(CM+" 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:v00}get isSampled(){var n=this.instance.get_property(rM);return Dp(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(vW),i=!this.instance.config.disable_session_recording;return c4&&n&&i}get isConsoleLogCaptureEnabled(){var n=!!this.instance.get_property(fC2),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(hC2),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:qf(u,0,12,"canvas recording fps",4),quality:qf(A,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var n,i,o=this.instance.get_property(dC2),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=!!(Dp(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(gC2),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 wr(e)&&wr(u)&&wr(A)?void 0:{maskAllInputs:e==null||e,maskTextSelector:u,blockSelector:A}}get sampleRate(){var n=this.instance.get_property(EC2);return nc(n)?n:null}get minimumDuration(){var n=this.instance.get_property(pC2);return nc(n)?n:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":rl(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":Dp(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(IW))===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(mW))===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(kt(this,"queuedRRWebEvents",[]),kt(this,"isIdle","unknown"),kt(this,"_linkedFlagSeen",!1),kt(this,"_lastActivityTimestamp",Date.now()),kt(this,"_linkedFlag",null),kt(this,"_removePageViewCaptureHook",void 0),kt(this,"_onSessionIdListener",void 0),kt(this,"_persistDecideOnSessionListener",void 0),kt(this,"_samplingSessionListener",void 0),kt(this,"_urlTriggers",[]),kt(this,"_urlBlocklist",[]),kt(this,"_urlBlocked",!1),kt(this,"_eventTriggers",[]),kt(this,"_removeEventTriggerCaptureHook",void 0),kt(this,"_forceAllowLocalhostNetworkCapture",!1),kt(this,"_onBeforeUnload",()=>{this._flushBuffer()}),kt(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),kt(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),kt(this,"_onVisibilityChange",()=>{if(Pn!=null&&Pn.visibilityState){var a="window "+Pn.visibilityState;this._tryAddCustomEvent(a,{})}}),this.instance=n,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw NA.error("started without valid sessionManager"),new Error(CM+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(CM+" 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&&NA.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(c4,"beforeunload",this._onBeforeUnload),$l(c4,"offline",this._onOffline),$l(c4,"online",this._onOnline),$l(c4,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),rl(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){NA.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(mW),(C=this.instance)===null||C===void 0||(l=C.persistence)===null||l===void 0||l.unregister(IW))}))):this.stopRecording()}stopRecording(){var n,i,o,a;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,c4==null||c4.removeEventListener("beforeunload",this._onBeforeUnload),c4==null||c4.removeEventListener("offline",this._onOffline),c4==null||c4.removeEventListener("online",this._onOnline),c4==null||c4.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,NA.info("stopped"))}makeSamplingDecision(n){var i,o=this.sessionId!==n,a=this.sampleRate;if(nc(a)){var s=this.isSampled,r=o||!Dp(s),C=r?p00(n,a):s;r&&(C?this._reportStarted("sampled"):NA.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({[rM]:C})}else{var l;(l=this.instance.persistence)===null||l===void 0||l.register({[rM]: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(),!rl(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(){nc(this.sampleRate)&&rl(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,p=rl(g)?null:parseFloat(g),b=(r=n.sessionRecording)===null||r===void 0?void 0:r.minimumDurationMilliseconds;o.register({[vW]:!!n.sessionRecording,[fC2]:(C=n.sessionRecording)===null||C===void 0?void 0:C.consoleLogRecordingEnabled,[dC2]:S4({capturePerformance:n.capturePerformance},(l=n.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[gC2]:(e=n.sessionRecording)===null||e===void 0?void 0:e.masking,[hC2]:{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},[EC2]:p,[pC2]:wr(b)?null:b,[vC2]:(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(!wr(Object.assign)&&!wr(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var i,o;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),nV()?this._onScriptLoaded():(i=Zs.__PosthogExtensions__)===null||i===void 0||(o=i.loadExternalDependency)===null||o===void 0||o.call(i,this.instance,this.scriptName,a=>{if(a)return NA.error("could not load recorder",a);this._onScriptLoaded()}),NA.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(vC2))===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}):NA.warn("could not emit queued rrweb event.",i,n),!1}}_tryAddCustomEvent(n,i){return this._tryRRWebMethod(al2(()=>nV().addCustomEvent(n,i)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(al2(()=>nV().takeFullSnapshot()))}_onScriptLoaded(){var n,i,o,a,s={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},r=this.instance.config.session_recording;for(var[C,l]of Object.entries(r||{}))C in s&&(C==="maskInputOptions"?s.maskInputOptions=S4({password:!0},l):s[C]=l);this.canvasRecording&&this.canvasRecording.enabled&&(s.recordCanvas=!0,s.sampling={canvas:this.canvasRecording.fps},s.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking&&(s.maskAllInputs=(i=this.masking.maskAllInputs)===null||i===void 0||i,s.maskTextSelector=(o=this.masking.maskTextSelector)!==null&&o!==void 0?o:void 0,s.blockSelector=(a=this.masking.blockSelector)!==null&&a!==void 0?a:void 0);var e=nV();if(e){this.mutationRateLimiter=(n=this.mutationRateLimiter)!==null&&n!==void 0?n:new C00(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");NA.info(d,{node:f}),this.log(CM+" "+d,"warn")}});var u=this._gatherRRWebPlugins();this.stopRrweb=e(S4({emit:A=>{this.onRRwebEmit(A)},plugins:u},s)),this._lastActivityTimestamp=Date.now(),this.isIdle=Dp(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 NA.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle!==!0){var n=this.fullSnapshotIntervalMillis;n&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},n))}}_gatherRRWebPlugins(){var n,i,o,a,s=[],r=(n=Zs.__PosthogExtensions__)===null||n===void 0||(i=n.rrwebPlugins)===null||i===void 0?void 0:i.getRecordConsolePlugin;r&&this.isConsoleLogCaptureEnabled&&s.push(r());var C=(o=Zs.__PosthogExtensions__)===null||o===void 0||(a=o.rrwebPlugins)===null||a===void 0?void 0:a.getRecordNetworkPlugin;return this.networkPayloadCapture&&jd(C)&&(!M20.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?s.push(C(s00(this.instance.config,this.networkPayloadCapture))):NA.info("NetworkCapture not started because we are on localhost.")),s}onRRwebEmit(n){var i;if(this._processQueuedEvents(),n&&Ul(n)){if(n.type===rE.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===rE.Custom&&A.data.tag==="recording paused"}(n)){n.type===rE.FullSnapshot&&this._scheduleFullSnapshot(),n.type===rE.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||sl2(s)){if(sl2(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(eV(A)<1024)return A;try{if(A.type===rE.FullSnapshot)return S4(S4({},A),{},{data:lm(A.data),cv:"2024-10"});if(A.type===rE.IncrementalSnapshot&&A.data.source===zd.Mutation)return S4(S4({},A),{},{cv:"2024-10",data:S4(S4({},A.data),{},{texts:lm(A.data.texts),attributes:lm(A.data.attributes),removes:lm(A.data.removes),adds:lm(A.data.adds)})});if(A.type===rE.IncrementalSnapshot&&A.data.source===zd.StyleSheetRule)return S4(S4({},A),{},{cv:"2024-10",data:S4(S4({},A.data),{},{adds:A.data.adds?lm(A.data.adds):void 0,removes:A.data.removes?lm(A.data.removes):void 0})})}catch(f){NA.error("could not compress event - will use uncompressed event",f)}return A}(s):s,u={$snapshot_bytes:eV(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&&c4){var n=this._maskUrl(c4.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=nc(i)&&i>=0,a=nc(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&&FW(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:$h.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(c4!==void 0&&c4.location.href){var n=c4.location.href,i=this._urlBlocked,o=Cl2(n,this._urlBlocklist);o&&!i?this._pauseRecording():!o&&i&&this._resumeRecording(),Cl2(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"?IW:mW]:this.sessionId}),this._flushBuffer(),this._reportStarted(n+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),NA.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"}),NA.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&rl(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",n=>{try{this._eventTriggers.includes(n.event)&&this._activateTrigger("event")}catch(i){NA.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({[rM]:!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}),NA.info(n.replace("_"," "),i),rC(["recording_initialized","session_id_changed"],n)||this._tryAddCustomEvent(n,i)}}var JW=DA("[SegmentIntegration]");function b00(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()||Vp();o.config.get_device_id=e,l.id()&&(o.register({distinct_id:l.id(),$device_id:e()}),o.persistence.set_property(eE,"identified")),a()},C=s.user();"then"in C&&jd(C.then)?C.then(l=>r(l)):r(C)})(t,()=>{i.register((o=>{Promise&&Promise.resolve||JW.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()||(JW.info("No userId set, resetting PostHog"),o.reset()),s.event.userId&&s.event.userId!==o.get_distinct_id()&&(JW.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 ll2="posthog-js";function ul2(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(p=>S4(S4({},p),{},{stacktrace:p.stacktrace?S4(S4({},p.stacktrace),{},{type:"raw",frames:(p.stacktrace.frames||[]).map(b=>S4(S4({},b),{},{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 B00{constructor(n,i,o,a,s){this.name=ll2,this.setupOnce=function(r){r(ul2(n,{organization:i,projectId:o,prefix:a,severityAllowList:s}))}}}var iE,y00=c4!=null&&c4.location?YS(c4.location.hash,"__posthog")||YS(location.hash,"state"):null,Al2="_postHogToolbarParams",cl2=DA("[Toolbar]");(function(t){t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED"})(iE||(iE={}));class L00{constructor(n){this.instance=n}setToolbarState(n){Zs.ph_toolbar_state=n}getToolbarState(){var n;return(n=Zs.ph_toolbar_state)!==null&&n!==void 0?n:iE.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(!c4||!Pn)return!1;o=(n=o)!==null&&n!==void 0?n:c4.location,s=(i=s)!==null&&i!==void 0?i:c4.history;try{if(!a){try{c4.localStorage.setItem("test","test"),c4.localStorage.removeItem("test")}catch{return!1}a=c4==null?void 0:c4.localStorage}var r,C=y00||YS(o.hash,"__posthog")||YS(o.hash,"state"),l=C?oC2(()=>JSON.parse(atob(decodeURIComponent(C))))||oC2(()=>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(Al2)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token)&&(this.loadToolbar(r),!0)}catch{return!1}}_callLoadToolbar(n){var i=Zs.ph_load_toolbar||Zs.ph_load_editor;!rl(i)&&jd(i)?i(n,this.instance):cl2.warn("No toolbar load function found")}loadToolbar(n){var i=!(Pn==null||!Pn.getElementById(IC2));if(!c4||i)return!1;var o=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,a=S4(S4({token:this.instance.config.token},n),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},o?{instrument:!1}:{});if(c4.localStorage.setItem(Al2,JSON.stringify(S4(S4({},a),{},{source:void 0}))),this.getToolbarState()===iE.LOADED)this._callLoadToolbar(a);else if(this.getToolbarState()===iE.UNINITIALIZED){var s,r;this.setToolbarState(iE.LOADING),(s=Zs.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"toolbar",C=>{if(C)return cl2.error("[Toolbar] Failed to load",C),void this.setToolbarState(iE.UNINITIALIZED);this.setToolbarState(iE.LOADED),this._callLoadToolbar(a)}),$l(c4,"turbolinks:load",()=>{this.setToolbarState(iE.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 w00=DA("[TracingHeaders]");class Q00{constructor(n){kt(this,"_restoreXHRPatch",void 0),kt(this,"_restoreFetchPatch",void 0),kt(this,"_startCapturing",()=>{var i,o,a,s;wr(this._restoreXHRPatch)&&((i=Zs.__PosthogExtensions__)===null||i===void 0||(o=i.tracingHeadersPatchFns)===null||o===void 0||o._patchXHR(this.instance.sessionManager)),wr(this._restoreFetchPatch)&&((a=Zs.__PosthogExtensions__)===null||a===void 0||(s=a.tracingHeadersPatchFns)===null||s===void 0||s._patchFetch(this.instance.sessionManager))}),this.instance=n}_loadScript(n){var i,o,a;(i=Zs.__PosthogExtensions__)!==null&&i!==void 0&&i.tracingHeadersPatchFns&&n(),(o=Zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"tracing-headers",s=>{if(s)return w00.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 um=DA("[Web Vitals]"),fl2=9e5;class M00{constructor(n){var i;kt(this,"_enabledServerSide",!1),kt(this,"_initialized",!1),kt(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),kt(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((o,a)=>S4(S4({},o),{},{["$web_vitals_".concat(a.name,"_event")]:S4({},a),["$web_vitals_".concat(a.name,"_value")]:a.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),kt(this,"_addToBuffer",o=>{var a,s=(a=this.instance.sessionManager)===null||a===void 0?void 0:a.checkAndGetSessionAndWindowId(!0);if(wr(s))um.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();wr(r)||(rl(o==null?void 0:o.name)||rl(o==null?void 0:o.value)?um.error("Invalid metric received",o):this._maxAllowedValue&&o.value>=this._maxAllowedValue?um.error("Ignoring metric with value >= "+this._maxAllowedValue,o):(this.buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),wr(this.buffer.url)&&(this.buffer.url=r),this.buffer.firstMetricTimestamp=wr(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,o.attribution&&o.attribution.interactionTargetElement&&(o.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(S4(S4({},o),{},{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),kt(this,"_startCapturing",()=>{var o,a,s,r,C=Zs.__PosthogExtensions__;wr(C)||wr(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):um.error("web vitals callbacks not loaded - not starting")}),this.instance=n,this._enabledServerSide=!((i=this.instance.persistence)===null||i===void 0||!i.props[uC2]),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 wr(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)&&nc(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:fl2;return 0<n&&n<=6e4?fl2:n}get isEnabled(){var n=Ul(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return Dp(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(um.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({[uC2]:i}),this.instance.persistence.register({[cC2]:o})),this._enabledServerSide=i,this.startIfEnabled()}loadScript(n){var i,o,a;(i=Zs.__PosthogExtensions__)!==null&&i!==void 0&&i.postHogWebVitalsCallbacks&&n(),(o=Zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"web-vitals",s=>{s?um.error("failed to load script",s):n()})}_currentURL(){var n=c4?c4.location.href:void 0;return n||um.error("Could not determine current URL"),n}}var T00=DA("[Heatmaps]");function dl2(t){return Ul(t)&&"clientX"in t&&"clientY"in t&&nc(t.clientX)&&nc(t.clientY)}class x00{constructor(n){var i;kt(this,"rageclicks",new SC2),kt(this,"_enabledServerSide",!1),kt(this,"_initialized",!1),kt(this,"_flushInterval",null),this.instance=n,this._enabledServerSide=!((i=this.instance.persistence)===null||i===void 0||!i.props[pW])}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 wr(this.instance.config.capture_heatmaps)?wr(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;T00.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({[pW]: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(){c4&&Pn&&($l(c4,"beforeunload",this.flush.bind(this)),$l(Pn,"click",n=>this._onClick(n||(c4==null?void 0:c4.event)),{capture:!0}),$l(Pn,"mousemove",n=>this._onMouseMove(n||(c4==null?void 0:c4.event)),{capture:!0}),this.deadClicksCapture=new ZC2(this.instance,j20,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&&US(u)&&!Sp(u,"body");){if(u===e)return!1;if(rC(l,c4==null?void 0:c4.getComputedStyle(u).position))return!0;u=MC2(u)}return!1}(QC2(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(!bC2(n.target)&&dl2(n)){var a=this._getProperties(n,o);(i=this.rageclicks)!==null&&i!==void 0&&i.isRageClick(n.clientX,n.clientY,new Date().getTime())&&this._capture(S4(S4({},a),{},{type:"rageclick"})),this._capture(a)}}_onMouseMove(n){!bC2(n.target)&&dl2(n)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(n,"mousemove"))},500))}_capture(n){if(c4){var i=c4.location.href;this.buffer=this.buffer||{},this.buffer[i]||(this.buffer[i]=[]),this.buffer[i].push(n)}}flush(){this.buffer&&!WB(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class R00{constructor(n){this._instance=n}doPageView(n,i){var o,a=this._previousPageViewProperties(n,i);return this._currentPageview={pathname:(o=c4==null?void 0:c4.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(!(wr(r)||wr(C)||wr(l)||wr(e)||wr(u)||wr(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:qf(C/r,0,1),d=r<=1?1:qf(l/r,0,1),g=e<=1?1:qf(u/e,0,1),p=e<=1?1:qf(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:p})}}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 ed="Mobile",iV="iOS",Ug="Android",lM="Tablet",gl2=Ug+" "+lM,hl2="iPad",El2="Apple",pl2=El2+" Watch",uM="Safari",$B="BlackBerry",vl2="Samsung",Il2=vl2+"Browser",ml2=vl2+" Internet",Am="Chrome",D00=Am+" OS",bl2=Am+" "+iV,qW="Internet Explorer",Bl2=qW+" "+ed,$W="Opera",N00=$W+" Mini",e_="Edge",yl2="Microsoft "+e_,ey="Firefox",Ll2=ey+" "+iV,AM="Nintendo",cM="PlayStation",ty="Xbox",wl2=Ug+" "+ed,Ql2=ed+" "+uM,fM="Windows",t_=fM+" Phone",Ml2="Nokia",r_="Ouya",Tl2="Generic",S00=Tl2+" "+ed.toLowerCase(),xl2=Tl2+" "+lM.toLowerCase(),n_="Konqueror",ic="(\\d+(\\.\\d+)?)",i_=new RegExp("Version/"+ic),V00=new RegExp(ty,"i"),k00=new RegExp(cM+" \\w+","i"),O00=new RegExp(AM+" \\w+","i"),o_=new RegExp($B+"|PlayBook|BB10","i"),P00={"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"},a_,Z00=(t,n)=>n&&rC(n,El2)||function(i){return rC(i,uM)&&!rC(i,Am)&&!rC(i,Ug)}(t),Rl2=function(t,n){return n=n||"",rC(t," OPR/")&&rC(t,"Mini")?N00:rC(t," OPR/")?$W:o_.test(t)?$B:rC(t,"IE"+ed)||rC(t,"WPDesktop")?Bl2:rC(t,Il2)?ml2:rC(t,e_)||rC(t,"Edg/")?yl2:rC(t,"FBIOS")?"Facebook "+ed:rC(t,"UCWEB")||rC(t,"UCBrowser")?"UC Browser":rC(t,"CriOS")?bl2:rC(t,"CrMo")||rC(t,Am)?Am:rC(t,Ug)&&rC(t,uM)?wl2:rC(t,"FxiOS")?Ll2:rC(t.toLowerCase(),n_.toLowerCase())?n_:Z00(t,n)?rC(t,ed)?Ql2:uM:rC(t,ey)?ey:rC(t,"MSIE")||rC(t,"Trident/")?qW:rC(t,"Gecko")?ey:""},F00={[Bl2]:[new RegExp("rv:"+ic)],[yl2]:[new RegExp(e_+"?\\/"+ic)],[Am]:[new RegExp("("+Am+"|CrMo)\\/"+ic)],[bl2]:[new RegExp("CriOS\\/"+ic)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ic)],[uM]:[i_],[Ql2]:[i_],[$W]:[new RegExp("(Opera|OPR)\\/"+ic)],[ey]:[new RegExp(ey+"\\/"+ic)],[Ll2]:[new RegExp("FxiOS\\/"+ic)],[n_]:[new RegExp("Konqueror[:/]?"+ic,"i")],[$B]:[new RegExp($B+" "+ic),i_],[wl2]:[new RegExp("android\\s"+ic,"i")],[ml2]:[new RegExp(Il2+"\\/"+ic)],[qW]:[new RegExp("(rv:|MSIE )"+ic)],Mozilla:[new RegExp("rv:"+ic)]},Hl2=[[new RegExp(ty+"; "+ty+" (.*?)[);]","i"),t=>[ty,t&&t[1]||""]],[new RegExp(AM,"i"),[AM,""]],[new RegExp(cM,"i"),[cM,""]],[o_,[$B,""]],[new RegExp(fM,"i"),(t,n)=>{if(/Phone/.test(n)||/WPDesktop/.test(n))return[t_,""];if(new RegExp(ed).test(n)&&!/IEMobile\b/.test(n))return[fM+" "+ed,""];var i=/Windows NT ([0-9.]+)/i.exec(n);if(i&&i[1]){var o=i[1],a=P00[o]||"";return/arm/i.test(n)&&(a="RT"),[fM,a]}return[fM,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var n=[t[3],t[4],t[5]||"0"];return[iV,n.join(".")]}return[iV,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var n="";return t&&t.length>=3&&(n=wr(t[2])?t[3]:t[2]),["watchOS",n]}],[new RegExp("("+Ug+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Ug+")","i"),t=>{if(t&&t[2]){var n=[t[2],t[3],t[4]||"0"];return[Ug,n.join(".")]}return[Ug,""]}],[/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/,[D00,""]],[/Linux|debian/i,["Linux",""]]],Dl2=function(t){return O00.test(t)?AM:k00.test(t)?cM:V00.test(t)?ty:new RegExp(r_,"i").test(t)?r_:new RegExp("("+t_+"|WPDesktop)","i").test(t)?t_:/iPad/.test(t)?hl2:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?pl2:o_.test(t)?$B:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Ml2,"i").test(t)?Ml2:/(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(ed).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)?Ug:gl2:Ug:new RegExp("(pda|"+ed+")","i").test(t)?S00:new RegExp(lM,"i").test(t)&&!new RegExp(lM+" pc","i").test(t)?xl2:""},oV="https?://(.*)",aV=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],U00=SS(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],aV),s_="<masked>",Ml={campaignParams:function(){var{customTrackedParams:t,maskPersonalDataProperties:n,customPersonalDataProperties:i}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!Pn)return{};var o=n?SS([],aV,i||[]):[];return this._campaignParamsFromUrl(HW(Pn.URL,o,s_),t)},_campaignParamsFromUrl:function(t,n){var i=U00.concat(n||[]),o={};return ol(i,function(a){var s=GS(t,a);o[a]=s||null}),o},_searchEngine:function(t){return t?t.search(oV+"google.([^/?]*)")===0?"google":t.search(oV+"bing.com")===0?"bing":t.search(oV+"yahoo.com")===0?"yahoo":t.search(oV+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(t){var n=Ml._searchEngine(t),i=n!="yahoo"?"q":"p",o={};if(!Hp(n)){o.$search_engine=n;var a=Pn?GS(Pn.referrer,i):"";a.length&&(o.ph_keyword=a)}return o},searchInfo:function(){var t=Pn==null?void 0:Pn.referrer;return t?this._searchInfoFromReferrer(t):{}},browser:Rl2,browserVersion:function(t,n){var i=Rl2(t,n),o=F00[i];if(wr(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<Hl2.length;n++){var[i,o]=Hl2[n],a=i.exec(t),s=a&&(jd(o)?o(a,t):o);if(s)return s}return["",""]},device:Dl2,deviceType:function(t){var n=Dl2(t);return n===hl2||n===gl2||n==="Kobo"||n==="Kindle Fire"||n===xl2?lM:n===AM||n===ty||n===cM||n===r_?"Console":n===pl2?"Wearable":n?ed:"Desktop"},referrer:function(){return(Pn==null?void 0:Pn.referrer)||"$direct"},referringDomain:function(){var t;return Pn!=null&&Pn.referrer&&((t=KB(Pn.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?SS([],aV,n||[]):[],o=Jf==null?void 0:Jf.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:o?HW(o,i,s_):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=KB(i))===null||n===void 0?void 0:n.host};if(o){a.$current_url=o;var s=KB(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 ol(n,function(o,a){i["$initial_".concat(hW(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?SS([],aV,n||[]):[],[o,a]=Ml.os(cu);return du($Q({$os:o,$os_version:a,$browser:Ml.browser(cu,navigator.vendor),$device:Ml.device(cu),$device_type:Ml.deviceType(cu),$timezone:Ml.timezone(),$timezone_offset:Ml.timezoneOffset()}),{$current_url:HW(Jf==null?void 0:Jf.href,i,s_),$host:Jf==null?void 0:Jf.host,$pathname:Jf==null?void 0:Jf.pathname,$raw_user_agent:cu.length>1e3?cu.substring(0,997)+"...":cu,$browser_version:Ml.browserVersion(cu,navigator.vendor),$browser_language:Ml.browserLanguage(),$browser_language_prefix:Ml.browserLanguagePrefix(),$screen_height:c4==null?void 0:c4.screen.height,$screen_width:c4==null?void 0:c4.screen.width,$viewport_height:c4==null?void 0:c4.innerHeight,$viewport_width:c4==null?void 0:c4.innerWidth,$lib:"web",$lib_version:$h.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]=Ml.os(cu);return du($Q({$os:t,$os_version:n,$browser:Ml.browser(cu,navigator.vendor)}),{$browser_version:Ml.browserVersion(cu,navigator.vendor)})}},jg=DA("[FeatureFlags]"),C_="$active_feature_flags",ry="$override_feature_flags",Nl2="$feature_flag_payloads",dM="$override_feature_flag_payloads",Sl2="$feature_flag_request_id",Vl2=t=>{var n={};for(var[i,o]of VS(t||{}))o&&(n[i]=o);return n},j00=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]}))):jg.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"})(a_||(a_={}));class z00{constructor(n){kt(this,"_override_warning",!1),kt(this,"_hasLoadedFlags",!1),kt(this,"_requestInFlight",!1),kt(this,"_reloadingDisabled",!1),kt(this,"_additionalReloadRequested",!1),kt(this,"_decideCalled",!1),kt(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(bW),i=this.instance.get_property(ry),o=this.instance.get_property(dM);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=wr(u)?(C=e==null?void 0:e.enabled)!==null&&C!==void 0&&C:!!u,f=wr(u)?e.variant:typeof u=="string"?u:void 0,d=o==null?void 0:o[r],g=S4(S4({},e),{},{enabled:A,variant:A?f??(e==null?void 0:e.variant):void 0});A!==(e==null?void 0:e.enabled)&&(g.original_enabled=e==null?void 0:e.enabled),f!==(e==null?void 0:e.variant)&&(g.original_variant=e==null?void 0:e.variant),d&&(g.metadata=S4(S4({},e==null?void 0:e.metadata),{},{payload:d,original_payload:e==null||(l=e.metadata)===null||l===void 0?void 0:l.payload})),a[r]=g}return this._override_warning||(jg.warn(" Overriding feature flag details!",{flagDetails:n,overriddenPayloads:o,finalDetails:a}),this._override_warning=!0),a}getFlagVariants(){var n=this.instance.get_property(_B),i=this.instance.get_property(ry);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||(jg.warn(" Overriding feature flags!",{enabledFlags:n,overriddenFlags:i,finalFlags:o}),this._override_warning=!0),o}getFlagPayloads(){var n=this.instance.get_property(Nl2),i=this.instance.get_property(dM);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||(jg.warn(" Overriding feature flag payloads!",{flagPayloads:n,overriddenPayloads:i,finalPayloads:o}),this._override_warning=!0),o}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout(()=>{this._callDecideEndpoint()},5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(n){this.$anon_distinct_id=n}setReloadingPaused(n){this._reloadingDisabled=n}_callDecideEndpoint(n){var i;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var o={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:S4(S4({},((i=this.instance.persistence)===null||i===void 0?void 0:i.get_initial_props())||{}),this.instance.get_property(nM)||{}),group_properties:this.instance.get_property(om)};(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=Ml.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:Ud.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(a_.FeatureFlags)?jg.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(Sl2)||void 0,r=this.instance.get_property(ZS)||{};if((i.send_event||!("send_event"in i))&&(!(n in r)||!r[n].includes(a))){var C,l,e,u,A,f,d,g,p,b,w;Fl(r[n])?r[n].push(a):r[n]=[a],(C=this.instance.persistence)===null||C===void 0||C.register({[ZS]:r});var T=this.getFeatureFlagDetails(n),H={$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};wr(T==null||(f=T.metadata)===null||f===void 0?void 0:f.version)||(H.$feature_flag_version=T.metadata.version);var S,N=(d=T==null||(g=T.reason)===null||g===void 0?void 0:g.description)!==null&&d!==void 0?d:T==null||(p=T.reason)===null||p===void 0?void 0:p.code;N&&(H.$feature_flag_reason=N),T!=null&&(b=T.metadata)!==null&&b!==void 0&&b.id&&(H.$feature_flag_id=T.metadata.id),wr(T==null?void 0:T.original_variant)&&wr(T==null?void 0:T.original_enabled)||(H.$feature_flag_original_response=wr(T.original_variant)?T.original_enabled:T.original_variant),T!=null&&(w=T.metadata)!==null&&w!==void 0&&w.original_payload&&(H.$feature_flag_original_payload=T==null||(S=T.metadata)===null||S===void 0?void 0:S.original_payload),this.instance.capture("$feature_flag_called",H)}return o}jg.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:Ud.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);jg.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=j00(r),f=A.flags,d=A.featureFlags,g=A.featureFlagPayloads;if(d){var p=r.requestId;if(Fl(d)){jg.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var b={};if(d)for(var w=0;w<d.length;w++)b[d[w]]=!0;C&&C.register({[C_]:d,[_B]:b})}else{var T=d,H=g,S=f;r.errorsWhileComputingFlags&&(T=S4(S4({},l),T),H=S4(S4({},e),H),S=S4(S4({},u),S)),C&&C.register(S4({[C_]:Object.keys(Vl2(T)),[_B]:T||{},[Nl2]:H||{},[bW]:S||{}},p?{[Sl2]:p}:{}))}}})(n,this.instance.persistence,o,a,s),this._fireFeatureFlagsCallbacks(i)}}override(n){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];jg.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:n,suppressWarning:i})}overrideFeatureFlags(n){if(!this.instance.__loaded||!this.instance.persistence)return jg.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(n===!1)return this.instance.persistence.unregister(ry),this.instance.persistence.unregister(dM),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(ry);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({[ry]:a})}else this.instance.persistence.register({[ry]:o.flags})}return"payloads"in o&&(o.payloads===!1?this.instance.persistence.unregister(dM):o.payloads&&this.instance.persistence.register({[dM]: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(OS)||[]).find(l=>l.flagKey===n),s={["$feature_enrollment/".concat(n)]:i},r={$feature_flag:n,$feature_enrollment:i,$set:s};a&&(r.$early_access_feature_name=a.name),this.instance.capture("$feature_enrollment_update",r),this.setPersonPropertiesForFlags(s,!1);var C=S4(S4({},this.getFlagVariants()),{},{[n]:i});(o=this.instance.persistence)===null||o===void 0||o.register({[C_]:Object.keys(Vl2(C)),[_B]: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(OS),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({[OS]: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(nM)||{};this.instance.register({[nM]:S4(S4({},o),n)}),i&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(nM)}setGroupPropertiesForFlags(n){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],o=this.instance.get_property(om)||{};Object.keys(o).length!==0&&Object.keys(o).forEach(a=>{o[a]=S4(S4({},o[a]),n[a]),delete n[a]}),this.instance.register({[om]:S4(S4({},o),n)}),i&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(n){if(n){var i=this.instance.get_property(om)||{};this.instance.register({[om]:S4(S4({},i),{},{[n]:{}})})}else this.instance.unregister(om)}}var G00=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class l_{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&&zi.info("Persistence loaded",n.persistence,S4({},this.props)),this.update_config(n,n),this.save()}buildStorage(n){G00.indexOf(n.persistence.toLowerCase())===-1&&(zi.critical("Unknown persistence type "+n.persistence+"; falling back to localStorage+cookie"),n.persistence="localStorage+cookie");var i=n.persistence.toLowerCase();return i==="localstorage"&&Qu.is_supported()?Qu:i==="localstorage+cookie"&&_S.is_supported()?_S:i==="sessionstorage"&&nA.is_supported()?nA:i==="memory"?F20:i==="cookie"?tE:_S.is_supported()?_S:tE}properties(){var n={};return ol(this.props,function(i,o){if(o===_B&&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,(Hp(r=I20)?l:Js2&&r.indexOf===Js2?r.indexOf(C)!=-1:(ol(r,function(e){if(l||(l=e===C))return NS}),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)){wr(i)&&(i="None"),this.expire_days=wr(o)?this.default_expiry:o;var a=!1;if(ol(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=wr(i)?this.default_expiry:i;var o=!1;if(ol(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=Ml.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});WB($Q(n))||this.register(n),this.campaign_params_saved=!0}}update_search_keyword(){this.register(Ml.searchInfo())}update_referrer_info(){this.register_once(Ml.referrerInfo(),void 0)}set_initial_person_info(){this.props[wW]||this.props[QW]||this.register_once({[MW]:Ml.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return $Q({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var n={};ol([QW,wW],a=>{var s=this.props[a];s&&ol(s,function(r,C){n["$initial_"+hW(C)]=r})});var i=this.props[MW];if(i){var o=Ml.initialPersonPropsFromInfo(i);du(n,o)}return n}safe_merge(n){return ol(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[tM]||{};o[n]=i,this.props[tM]=o,this.save()}remove_event_timer(n){var i=(this.props[tM]||{})[n];return wr(i)||(delete this.props[tM][n],this.save()),i}get_property(n){return this.props[n]}set_property(n,i){this.props[n]=i,this.save()}}var kl2,jl,Ol2,cm,Pl2,Zl2,u_,Fl2,Ul2,jl2,zl2,Gl2,A_={},Yl2=[],Y00=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,c_=Array.isArray;function Op(t,n){for(var i in n)t[i]=n[i];return t}function Wl2(t){var n=t.parentNode;n&&n.removeChild(t)}function f_(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??++Ol2,__i:-1,__u:0};return a==null&&jl.vnode!=null&&jl.vnode(s),s}function d_(t){return t.children}function sV(t,n){this.props=t,this.context=n}function ny(t,n){if(n==null)return t.__?ny(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"?ny(t):null}function _l2(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 _l2(t)}}function g_(t){(!t.__d&&(t.__d=!0)&&cm.push(t)&&!CV.__r++||Pl2!==jl.debounceRendering)&&((Pl2=jl.debounceRendering)||Zl2)(CV)}function CV(){var t,n,i,o,a,s,r,C,l;for(cm.sort(u_);t=cm.shift();)t.__d&&(n=cm.length,o=void 0,s=(a=(i=t).__v).__e,C=[],l=[],(r=i.__P)&&((o=Op({},a)).__v=a.__v+1,jl.vnode&&jl.vnode(o),eu2(r,o,a,i.__n,r.ownerSVGElement!==void 0,32&a.__u?[s]:null,C,s??ny(a),!!(32&a.__u),l),o.__.__k[o.__i]=o,X00(C,o,l),o.__e!=s&&_l2(o)),cm.length>n&&cm.sort(u_));CV.__r=0}function Xl2(t,n,i,o,a,s,r,C,l,e,u){var A,f,d,g,p,b=o&&o.__k||Yl2,w=n.length;for(i.__d=l,W00(i,n,b),l=i.__d,A=0;A<w;A++)(d=i.__k[A])!=null&&typeof d!="boolean"&&typeof d!="function"&&(f=d.__i===-1?A_:b[d.__i]||A_,d.__i=A,eu2(t,d,f,a,s,r,C,l,e,u),g=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&h_(f.ref,null,d),u.push(d.ref,d.__c||g,d)),p==null&&g!=null&&(p=g),65536&d.__u||f.__k===d.__k?l=Kl2(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=p}function W00(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?f_(null,a,null,null,a):c_(a)?f_(d_,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?f_(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a)!=null?(a.__=t,a.__b=t.__b+1,C=_00(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=ny(s)),E_(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=ny(s)),E_(s,s))}function Kl2(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=Kl2(o[a],n,i));return n}return t.__e!=n&&(i.insertBefore(t.__e,n||null),n=t.__e),n&&n.nextSibling}function _00(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 Jl2(t,n,i){n[0]==="-"?t.setProperty(n,i??""):t[n]=i==null?"":typeof i!="number"||Y00.test(n)?i:i+"px"}function lV(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||Jl2(t.style,n,"");if(i)for(n in i)o&&i[n]===o[n]||Jl2(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?$l2:ql2,s)):t.removeEventListener(n,s?$l2:ql2,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 ql2(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 $l2(t){return this.l[t.type+!0](jl.event?jl.event(t):t)}function eu2(t,n,i,o,a,s,r,C,l,e){var u,A,f,d,g,p,b,w,T,H,S,N,X,W,f2,Q2=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 Q2=="function")try{if(w=n.props,T=(u=Q2.contextType)&&o[u.__c],H=u?T?T.props.value:u.__:o,i.__c?b=(A=n.__c=i.__c).__=A.__E:("prototype"in Q2&&Q2.prototype.render?n.__c=A=new Q2(w,H):(n.__c=A=new sV(w,H),A.constructor=Q2,A.render=J00),T&&T.sub(A),A.props=w,A.state||(A.state={}),A.context=H,A.__n=o,f=A.__d=!0,A.__h=[],A._sb=[]),A.__s==null&&(A.__s=A.state),Q2.getDerivedStateFromProps!=null&&(A.__s==A.state&&(A.__s=Op({},A.__s)),Op(A.__s,Q2.getDerivedStateFromProps(w,A.__s))),d=A.props,g=A.state,A.__v=n,f)Q2.getDerivedStateFromProps==null&&A.componentWillMount!=null&&A.componentWillMount(),A.componentDidMount!=null&&A.__h.push(A.componentDidMount);else{if(Q2.getDerivedStateFromProps==null&&w!==d&&A.componentWillReceiveProps!=null&&A.componentWillReceiveProps(w,H),!A.__e&&(A.shouldComponentUpdate!=null&&A.shouldComponentUpdate(w,A.__s,H)===!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(I2){I2&&(I2.__=n)}),S=0;S<A._sb.length;S++)A.__h.push(A._sb[S]);A._sb=[],A.__h.length&&r.push(A);break e}A.componentWillUpdate!=null&&A.componentWillUpdate(w,A.__s,H),A.componentDidUpdate!=null&&A.__h.push(function(){A.componentDidUpdate(d,g,p)})}if(A.context=H,A.props=w,A.__P=t,A.__e=!1,N=jl.__r,X=0,"prototype"in Q2&&Q2.prototype.render){for(A.state=A.__s,A.__d=!1,N&&N(n),u=A.render(A.props,A.state,A.context),W=0;W<A._sb.length;W++)A.__h.push(A._sb[W]);A._sb=[]}else do A.__d=!1,N&&N(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=Op(Op({},o),A.getChildContext())),f||A.getSnapshotBeforeUpdate==null||(p=A.getSnapshotBeforeUpdate(d,g)),Xl2(t,c_(f2=u!=null&&u.type===d_&&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),b&&(A.__E=A.__=null)}catch(I2){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(I2,n,i)}else s==null&&n.__v===i.__v?(n.__k=i.__k,n.__e=i.__e):n.__e=K00(i.__e,n,i,o,a,s,r,l,e);(u=jl.diffed)&&u(n)}function X00(t,n,i){n.__d=void 0;for(var o=0;o<i.length;o++)h_(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 K00(t,n,i,o,a,s,r,C,l){var e,u,A,f,d,g,p,b=i.props,w=n.props,T=n.type;if(T==="svg"&&(a=!0),s!=null){for(e=0;e<s.length;e++)if((d=s[e])&&"setAttribute"in d==!!T&&(T?d.localName===T:d.nodeType===3)){t=d,s[e]=null;break}}if(t==null){if(T===null)return document.createTextNode(w);t=a?document.createElementNS("http://www.w3.org/2000/svg",T):document.createElement(T,w.is&&w),s=null,C=!1}if(T===null)b===w||C&&t.data===w||(t.data=w);else{if(s=s&&kl2.call(t.childNodes),b=i.props||A_,!C&&s!=null)for(b={},e=0;e<t.attributes.length;e++)b[(d=t.attributes[e]).name]=d.value;for(e in b)d=b[e],e=="children"||(e=="dangerouslySetInnerHTML"?A=d:e==="key"||e in w||lV(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"?p=d:e==="key"||C&&typeof d!="function"||b[e]===d||lV(t,e,d,b[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=""),Xl2(t,c_(f)?f:[f],n,i,o,a&&T!=="foreignObject",s,r,s?s[0]:i.__k&&ny(i,0),C,l),s!=null)for(e=s.length;e--;)s[e]!=null&&Wl2(s[e]);C||(e="value",g!==void 0&&(g!==t[e]||T==="progress"&&!g||T==="option"&&g!==b[e])&&lV(t,e,g,b[e],!1),e="checked",p!==void 0&&p!==t[e]&&lV(t,e,p,b[e],!1))}return t}function h_(t,n,i){try{typeof t=="function"?t(n):t.current=n}catch(o){jl.__e(o,i)}}function E_(t,n,i){var o,a;if(jl.unmount&&jl.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||h_(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]&&E_(o[a],n,i||typeof t.type!="function");i||t.__e==null||Wl2(t.__e),t.__=t.__e=t.__d=void 0}function J00(t,n,i){return this.constructor(t,i)}kl2=Yl2.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}},Ol2=0,sV.prototype.setState=function(t,n){var i;i=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Op({},this.state),typeof t=="function"&&(t=t(Op({},i),this.props)),t&&Op(i,t),t!=null&&this.__v&&(n&&this._sb.push(n),g_(this))},sV.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),g_(this))},sV.prototype.render=d_,cm=[],Zl2=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,u_=function(t,n){return t.__v.__b-n.__v.__b},CV.__r=0,Fl2=0,function(t){t.Popover="popover",t.API="api",t.Widget="widget"}(Ul2||(Ul2={})),function(t){t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link"}(jl2||(jl2={})),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"}(Gl2||(Gl2={})),function(t,n){var i={__c:n="__cC"+Fl2++,__: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,g_(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 iy=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 tu2{constructor(){kt(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 fm{constructor(n){kt(this,"_debugEventEmitter",new tu2),kt(this,"checkStep",(i,o)=>this.checkStepEvent(i,o)&&this.checkStepUrl(i,o)&&this.checkStepElement(i,o)),kt(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(!wr((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(!wr((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"||!fm.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!!c4&&iy(n,i);case"exact":return i===n;case"contains":var a=fm.escapeStringRegexp(i).replace(/_/g,".").replace(/%/g,".*");return iy(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&&!fm.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&&!fm.matchString(s.text||"",i==null?void 0:i.text,(i==null?void 0:i.text_matching)||"exact")&&!fm.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 gM{constructor(n){this.instance=n,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(n){var i;wr((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 fm(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 p=this.actionToSurveys.get(g.name);p&&p.push(o.id),this.actionToSurveys.set(g.name,p||[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[PS])||[];if(gM.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[PS])||[];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({[PS]:[...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[PS];return o||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}kt(gM,"SURVEY_SHOWN_EVENT_NAME","survey shown");var iA=DA("[Surveys]"),ru2={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=>iy(n,i)),not_regex:(t,n)=>t.every(i=>!iy(n,i)),exact:(t,n)=>t.some(i=>n===i),is_not:(t,n)=>t.every(i=>n!==i)};function nu2(t){return t??"icontains"}class q00{constructor(n){kt(this,"_isFetchingSurveys",!1),kt(this,"_isInitializingSurveys",!1),kt(this,"_surveyCallbacks",[]),this.instance=n,this._surveyEventReceiver=null}onRemoteConfig(n){var i=n.surveys;if(rl(i))return iA.warn("Decide not loaded yet. Not loading surveys.");var o=Fl(i);this._hasSurveys=o?i.length>0:i,iA.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)iA.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)iA.info("Disabled. Not loading surveys.");else{var n=Zs==null?void 0:Zs.__PosthogExtensions__;if(n)if(this._hasSurveys){this._isInitializingSurveys=!0;try{var i=n.generateSurveys;if(i)this._surveyManager=i(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new gM(this.instance),iA.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 iA.error("Could not load surveys script",s),void(this._isInitializingSurveys=!1);this._surveyManager=n.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new gM(this.instance),iA.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var a="PostHog loadExternalDependency extension not found. Cannot load remote config.";iA.error(a),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:a})}}}catch(s){throw iA.error("Error initializing surveys",s),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),s}}else iA.info("No surveys to load.");else iA.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 iA.info("Disabled. Not loading surveys."),n([]);var o=this.instance.get_property(BW);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 iA.error(C),n([],{isLoaded:!1,error:C})}var l,e=a.json.surveys||[],u=e.filter(A=>{var f,d,g,p,b,w,T,H,S,N,X,W;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)&&((p=A.conditions)===null||p===void 0||(b=p.events)===null||b===void 0||(w=b.values)===null||w===void 0?void 0:w.length)>0||((T=A.conditions)===null||T===void 0?void 0:T.actions)&&((H=A.conditions)===null||H===void 0||(S=H.actions)===null||S===void 0?void 0:S.values)&&((N=A.conditions)===null||N===void 0||(X=N.actions)===null||X===void 0||(W=X.values)===null||W===void 0?void 0:W.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({[BW]: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){iA.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,p,b;if((g=d.conditions)===null||g===void 0||!g.url)return!0;var w=c4==null||(p=c4.location)===null||p===void 0?void 0:p.href;if(!w)return!1;var T=[d.conditions.url];return ru2[nu2((b=d.conditions)===null||b===void 0?void 0:b.urlMatchType)](T,w)}(l),A=(e=l.conditions)===null||e===void 0||!e.selector||(Pn==null?void 0:Pn.querySelector(l.conditions.selector)),f=function(d){var g,p,b;if((g=d.conditions)===null||g===void 0||!g.deviceTypes||((p=d.conditions)===null||p===void 0?void 0:p.deviceTypes.length)===0)return!0;if(!cu)return!1;var w=Ml.deviceType(cu);return ru2[nu2((b=d.conditions)===null||b===void 0?void 0:b.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,p,b,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 T=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),H=this.isSurveyFeatureFlagEnabled(l.targeting_flag_key),S=((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,N=((g=(p=l.conditions)===null||p===void 0||(b=p.actions)===null||b===void 0||(w=b.values)===null||w===void 0?void 0:w.length)!==null&&g!==void 0?g:0)>0,X=!S&&!N||(r==null?void 0:r.includes(l.id)),W=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),f2=this.checkFlags(l);return T&&H&&W&&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 rl((i=Zs.__PosthogExtensions__)===null||i===void 0?void 0:i.canActivateRepeatedly)?(iA.warn("init was not called"),!1):Zs.__PosthogExtensions__.canActivateRepeatedly(n)}canRenderSurvey(n){rl(this._surveyManager)?iA.warn("init was not called"):this.getSurveys(i=>{var o=i.filter(a=>a.id===n)[0];this._surveyManager.canRenderSurvey(o)})}renderSurvey(n,i){rl(this._surveyManager)?iA.warn("init was not called"):this.getSurveys(o=>{var a=o.filter(s=>s.id===n)[0];this._surveyManager.renderSurvey(a,Pn==null?void 0:Pn.querySelector(i))})}}var iu2=DA("[RateLimiter]");class $00{constructor(n){var i,o;kt(this,"serverLimits",{}),kt(this,"lastEventRateLimited",!1),kt(this,"checkForLimiting",a=>{var s=a.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(r=>{iu2.info("".concat(r||"events"," is quota limited.")),this.serverLimits[r]=new Date().getTime()+6e4})}catch(r){return void iu2.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(LW))!==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(LW,r),{isRateLimited:C,remainingTokens:r.tokens}}isServerRateLimited(n){var i=this.serverLimits[n||"events"]||!1;return i!==!1&&new Date().getTime()<i}}var dm=DA("[RemoteConfig]");class e10{constructor(n){this.instance=n}get remoteConfig(){var n,i;return(n=Zs._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(i=n[this.instance.config.token])===null||i===void 0?void 0:i.config}_loadRemoteConfigJs(n){var i,o,a;(i=Zs.__PosthogExtensions__)!==null&&i!==void 0&&i.loadExternalDependency?(o=Zs.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"remote-config",()=>n(this.remoteConfig)):(dm.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 dm.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void dm.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(n=>{if(!n)return dm.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){dm.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()):dm.info("__preview_remote_config is disabled. Logging config instead",n):dm.error("Failed to fetch remote config from PostHog.")}}var t10=function(t){var n,i,o,a,s="";for(n=i=0,o=(t=(t+"").replace(/\r\n/g,`
|
|
596
596
|
`).replace(/\r/g,`
|
|
597
|
-
`)).length,a=0;a<o;a++){var r=t.charCodeAt(a),C=null;r<128?i++:C=r>127&&r<2048?String.fromCharCode(r>>6|192,63&r|128):String.fromCharCode(r>>12|224,r>>6&63|128,63&r|128),Hp(C)||(i>n&&(s+=t.substring(n,i)),s+=C,n=i=a+1)}return i>n&&(s+=t.substring(n,t.length)),s},r10=!!dW||!!fW,ou2="text/plain",uV=(t,n)=>{var[i,o]=t.split("?"),a=S4({},n);o==null||o.split("&").forEach(r=>{var[C]=r.split("=");delete a[C]});var s=T20(a);return s=s?(o?o+"&":"")+s:o,"".concat(i,"?").concat(s)},hM=(t,n)=>JSON.stringify(t,(i,o)=>typeof o=="bigint"?o.toString():o,n),p_=t=>{var{data:n,compression:i}=t;if(n){if(i===Ud.GZipJS){var o=il2(ol2(hM(n)),{mtime:0}),a=new Blob([o],{type:ou2});return{contentType:ou2,body:a,estimatedSize:a.size}}if(i===Ud.Base64){var s=function(l){var e,u,A,f,d,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p=0,b=0,w="",T=[];if(!l)return l;l=t10(l);do e=(d=l.charCodeAt(p++)<<16|l.charCodeAt(p++)<<8|l.charCodeAt(p++))>>18&63,u=d>>12&63,A=d>>6&63,f=63&d,T[b++]=g.charAt(e)+g.charAt(u)+g.charAt(A)+g.charAt(f);while(p<l.length);switch(w=T.join(""),l.length%3){case 1:w=w.slice(0,-2)+"==";break;case 2:w=w.slice(0,-1)+"="}return w}(hM(n)),r=(l=>"data="+encodeURIComponent(typeof l=="string"?l:hM(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var C=hM(n);return{contentType:"application/json",body:C,estimatedSize:new Blob([C]).size}}},EM=[];fW&&EM.push({transport:"fetch",method:t=>{var n,i,{contentType:o,body:a,estimatedSize:s}=(n=p_(t))!==null&&n!==void 0?n:{},r=new Headers;ol(t.headers,function(u,A){r.append(A,u)}),o&&r.append("Content-Type",o);var C=t.url,l=null;if(qs2){var e=new qs2;l={signal:e.signal,timeout:setTimeout(()=>e.abort(),t.timeout)}}fW(C,S4({method:(t==null?void 0:t.method)||"GET",headers:r,keepalive:t.method==="POST"&&(s||0)<52428.8,body:a,signal:(i=l)===null||i===void 0?void 0:i.signal},t.fetchOptions)).then(u=>u.text().then(A=>{var f,d={statusCode:u.status,text:A};if(u.status===200)try{d.json=JSON.parse(A)}catch(g){zi.error(g)}(f=t.callback)===null||f===void 0||f.call(t,d)})).catch(u=>{var A;zi.error(u),(A=t.callback)===null||A===void 0||A.call(t,{statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),dW&&EM.push({transport:"XHR",method:t=>{var n,i=new dW;i.open(t.method||"GET",t.url,!0);var{contentType:o,body:a}=(n=p_(t))!==null&&n!==void 0?n:{};ol(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)}}),uf!=null&&uf.sendBeacon&&EM.push({transport:"sendBeacon",method:t=>{var n=uV(t.url,{beacon:"1"});try{var i,{contentType:o,body:a}=(i=p_(t))!==null&&i!==void 0?i:{},s=typeof a=="string"?new Blob([a],{type:o}):a;uf.sendBeacon(n,s)}catch{}}});var v_=3e3;class n10{constructor(n,i){kt(this,"isPaused",!0),kt(this,"queue",[]),this.flushTimeoutMs=qf((i==null?void 0:i.flush_interval_ms)||v_,250,5e3,"flush interval",v_),this.sendRequest=n}enqueue(n){this.queue.push(n),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var n=this.queue.length>0?this.formatQueue():{},i=Object.values(n),o=[...i.filter(a=>a.url.indexOf("/e")===0),...i.filter(a=>a.url.indexOf("/e")!==0)];o.map(a=>{this.sendRequest(S4(S4({},a),{},{transport:"sendBeacon"}))})}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var n=this;this.isPaused||(this.flushTimeout=setTimeout(()=>{if(this.clearFlushTimeout(),this.queue.length>0){var i=this.formatQueue(),o=function(s){var r=i[s],C=new Date().getTime();r.data&&Fl(r.data)&&ol(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 ol(this.queue,i=>{var o,a=i,s=(a?a.batchKey:null)||a.url;wr(n[s])&&(n[s]=S4(S4({},a),{},{data:[]})),(o=n[s].data)===null||o===void 0||o.push(a.data)}),this.queue=[],n}}var i10=["retriesPerformedSoFar"];class o10{constructor(n){kt(this,"isPolling",!1),kt(this,"pollIntervalMs",3e3),kt(this,"queue",[]),this.instance=n,this.queue=[],this.areWeOnline=!0,!wr(c4)&&"onLine"in c4.navigator&&(this.areWeOnline=c4.navigator.onLine,$l(c4,"online",()=>{this.areWeOnline=!0,this.flush()}),$l(c4,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(n){var{retriesPerformedSoFar:i}=n,o=iC2(n,i10);nc(i)&&i>0&&(o.url=uV(o.url,{retry_count:i})),this.instance._send_request(S4(S4({},o),{},{callback:a=>{var s;a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(i??0)<10?this.enqueue(S4({retriesPerformedSoFar:i},o)):(s=o.callback)===null||s===void 0||s.call(o,a)}}))}enqueue(n){var i=n.retriesPerformedSoFar||0;n.retriesPerformedSoFar=i+1;var o=function(r){var C=3e3*Math.pow(2,r),l=C/2,e=Math.min(18e5,C),u=(Math.random()-.5)*(e-l);return Math.ceil(e+u)}(i),a=Date.now()+o;this.queue.push({retryAt:a,requestOptions:n});var s="Enqueued failed request for retry in ".concat(o);navigator.onLine||(s+=" (Browser is offline)"),zi.warn(s),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout(()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()},this.pollIntervalMs)}flush(){var n=Date.now(),i=[],o=this.queue.filter(s=>s.retryAt<n||(i.push(s),!1));if(this.queue=i,o.length>0)for(var{requestOptions:a}of o)this.retriableRequest(a)}unload(){for(var{requestOptions:n}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(S4(S4({},n),{},{transport:"sendBeacon"}))}catch(i){zi.error(i)}this.queue=[]}}class a10{constructor(n){kt(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(c4,"scroll",this._updateScrollData,{capture:!0}),$l(c4,"scrollend",this._updateScrollData,{capture:!0}),$l(c4,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return c4==null?void 0:c4.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=c4==null?void 0:c4.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 c4&&(c4.scrollY||c4.pageYOffset||c4.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var n=this.scrollElement();return n&&n.scrollLeft||0}return c4&&(c4.scrollX||c4.pageXOffset||c4.document.documentElement.scrollLeft)||0}}var s10=t=>Ml.personInfo({maskPersonalDataProperties:t==null?void 0:t.config.mask_personal_data_properties,customPersonalDataProperties:t==null?void 0:t.config.custom_personal_data_properties});class C10{constructor(n,i,o,a){kt(this,"_onSessionIdCallback",s=>{var r=this._getStored();if(!r||r.sessionId!==s){var C={sessionId:s,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[yW]:C})}}),this.instance=n,this._sessionIdManager=i,this._persistence=o,this._sessionSourceParamGenerator=a||s10,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[yW]}getSetOnceProps(){var n,i=(n=this._getStored())===null||n===void 0?void 0:n.props;return i?"r"in i?Ml.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 ol($Q(this.getSetOnceProps()),(i,o)=>{o==="$current_url"&&(o="url"),n["$session_entry_".concat(hW(o))]=i}),n}}var au2=DA("[SessionId]");class l10{constructor(n,i,o){var a;if(kt(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||Vp,this._windowIdGenerator=o||Vp;var s=this.config.persistence_name||this.config.token,r=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*qf(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=nA.parse(this._window_id_storage_key),l=nA.parse(this._primary_window_exists_storage_key);C&&!l?this._windowId=C:nA.remove(this._window_id_storage_key),nA.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){au2.error("Invalid sessionID in bootstrap",u)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(n){return wr(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&&nA.is_supported()}_setWindowId(n){n!==this._windowId&&(this._windowId=n,this._canUseSessionStorage()&&nA.set(this._window_id_storage_key,n))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?nA.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({[kS]:[i,n,o]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var n=this.persistence.props[kS];return Fl(n)&&n.length===2&&n.push(n[0]),n||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){$l(c4,"beforeunload",()=>{this._canUseSessionStorage()&&nA.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=nc(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(),au2.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 u10=["$set_once","$set"],Pp=DA("[SiteApps]");class A10{constructor(n){this.instance=n,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(n,i){if(i){var o=this.globalsForEvent(i);this.bufferedInvocations.push(o),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var n,i;return(n=Zs._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(i=n[this.instance.config.token])===null||i===void 0?void 0:i.siteApps}init(){if(this.isEnabled){var n=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{n(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(n){var i,o,a,s,r,C,l;if(!n)throw new Error("Event payload is required");var e={},u=this.instance.get_property("$groups")||[],A=this.instance.get_property("$stored_group_properties")||{};for(var[f,d]of Object.entries(A))e[f]={id:u[f],type:f,properties:d};var{$set_once:g,$set:p}=n;return{event:S4(S4({},iC2(n,u10)),{},{properties:S4(S4(S4({},n.properties),p?{$set:S4(S4({},(i=(o=n.properties)===null||o===void 0?void 0:o.$set)!==null&&i!==void 0?i:{}),p)}:{}),g?{$set_once:S4(S4({},(a=(s=n.properties)===null||s===void 0?void 0:s.$set_once)!==null&&a!==void 0?a:{}),g)}:{}),elements_chain:(r=(C=n.properties)===null||C===void 0?void 0:C.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(l=n.properties)===null||l===void 0?void 0:l.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:e}}setupSiteApp(n){var i=this.apps[n.id],o=()=>{var C;!i.errored&&this.bufferedInvocations.length&&(Pp.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,Pp.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){Pp.error("Error while initializing PostHog app with config id ".concat(n.id),C),s(!1)}if(a&&i.loaded)try{o()}catch(C){Pp.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){Pp.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 Pp.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((o=this.stopBuffering)===null||o===void 0||o.call(this),(a=n.siteApps)!==null&&a!==void 0&&a.length)if(this.isEnabled){var r=function(e,u){var A,f;Zs["__$$ph_site_app_".concat(e)]=s.instance,(A=Zs.__PosthogExtensions__)===null||A===void 0||(f=A.loadSiteApp)===null||f===void 0||f.call(A,s.instance,u,d=>{if(d)return Pp.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 Pp.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var gm,c10=["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"],su2=function(t,n){if(!t)return!1;var i=t.toLowerCase();return c10.concat(n||[]).some(o=>{var a=o.toLowerCase();return i.indexOf(a)!==-1})},Cu2=function(t,n){if(!t)return!1;var i=t.userAgent;if(i&&su2(i,n))return!0;try{var o=t==null?void 0:t.userAgentData;if(o!=null&&o.brands&&o.brands.some(a=>su2(a==null?void 0:a.brand,n)))return!0}catch{}return!!t.webdriver};function I_(t,n,i){return hM({distinct_id:t,userPropertiesToSet:n,userPropertiesToSetOnce:i})}(function(t){t.US="us",t.EU="eu",t.CUSTOM="custom"})(gm||(gm={}));var lu2="i.posthog.com";class f10{constructor(n){kt(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(lu2),".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]=gm.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=gm.EU:this._regionCache[this.apiHost]=gm.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===gm.CUSTOM)return this.apiHost+i;var o=lu2+i;switch(n){case"assets":return"https://".concat(this.region,"-assets.").concat(o);case"api":return"https://".concat(this.region,".").concat(o)}}}var d10={icontains:(t,n)=>!!c4&&n.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,n)=>!!c4&&n.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,n)=>!!c4&&iy(n.href,t),not_regex:(t,n)=>!!c4&&!iy(n.href,t),exact:(t,n)=>n.href===t,is_not:(t,n)=>n.href!==t};class SA{constructor(n){var i=this;kt(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var o=arguments.length>0&&arguments[0]!==void 0&&arguments[0];i.getWebExperiments(a=>{SA.logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,a.forEach(s=>{if(s.feature_flag_key){var r;i._flagToExperiments&&(SA.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];SA.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())SA.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(rl(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();SA.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=SA.getWindowLocation();if(n!=null&&n.search){var i=GS(n==null?void 0:n.search,"__experiment_id"),o=GS(n==null?void 0:n.search,"__experiment_variant");i&&o&&(SA.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&&(SA.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!rl(n.conditions)&&SA.matchUrlConditions(n)&&SA.matchUTMConditions(n)}static matchUrlConditions(n){var i;if(rl(n.conditions)||rl((i=n.conditions)===null||i===void 0?void 0:i.url))return!0;var o,a,s,r=SA.getWindowLocation();return!!r&&((o=n.conditions)===null||o===void 0||!o.url||d10[(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 c4==null?void 0:c4.location}static matchUTMConditions(n){var i;if(rl(n.conditions)||rl((i=n.conditions)===null||i===void 0?void 0:i.utm))return!0;var o=Ml.campaignParams();if(o.utm_source){var a,s,r,C,l,e,u,A,f,d,g,p,b,w,T,H,S=(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,N=(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||(p=g.utm)===null||p===void 0?void 0:p.utm_medium)==o.utm_medium,W=(b=n.conditions)===null||b===void 0||(w=b.utm)===null||w===void 0||!w.utm_term||((T=n.conditions)===null||T===void 0||(H=T.utm)===null||H===void 0?void 0:H.utm_term)==o.utm_term;return S&&X&&W&&N}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];zi.info("[WebExperiments] ".concat(n),o)}applyTransforms(n,i,o){this._is_bot()?SA.logInfo("Refusing to render web experiment since the viewer is a likely bot"):i!=="control"?o.forEach(a=>{if(a.selector){var s;SA.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)})}}):SA.logInfo("Control variants leave the page unmodified.")}_is_bot(){return uf&&this.instance?Cu2(uf,this.instance.config.custom_blocked_useragents):void 0}}var pM={},m_=()=>{},oy="posthog",uu2=!r10&&(cu==null?void 0:cu.indexOf("MSIE"))===-1&&(cu==null?void 0:cu.indexOf("Mozilla"))===-1,Au2=()=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:v20(Pn==null?void 0:Pn.location),persistence:"localStorage+cookie",persistence_name:"",loaded:m_,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:Jf&&fu(Jf==null?void 0:Jf.search)&&Jf.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:(c4==null||(t=c4.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;zi.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:v_},_onCapture:m_}},cu2=t=>{var n={};wr(t.process_person)||(n.person_profiles=t.process_person),wr(t.xhr_headers)||(n.request_headers=t.xhr_headers),wr(t.cookie_name)||(n.persistence_name=t.cookie_name),wr(t.disable_cookie)||(n.disable_persistence=t.disable_cookie),wr(t.store_google)||(n.save_campaign_params=t.store_google),wr(t.verbose)||(n.debug=t.verbose);var i=du({},n,t);return Fl(t.property_blacklist)&&(wr(t.property_denylist)?i.property_denylist=t.property_blacklist:Fl(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:zi.error("Invalid value for property_denylist config: "+t.property_denylist)),i};class g10{constructor(){kt(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(n){zi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=n}}class AV{get decideEndpointWasHit(){var n,i;return(n=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&n!==void 0&&n}constructor(){kt(this,"webPerformance",new g10),kt(this,"_personProcessingSetOncePropertiesSent",!1),kt(this,"version",$h.LIB_VERSION),kt(this,"_internalEventEmitter",new tu2),this.config=Au2(),this.SentryIntegration=B00,this.sentryIntegration=n=>function(i,o){var a=ul2(i,o);return{name:ll2,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 z00(this),this.toolbar=new L00(this),this.scrollManager=new a10(this),this.pageViewManager=new R00(this),this.surveys=new q00(this),this.experiments=new SA(this),this.exceptions=new H00(this),this.rateLimiter=new $00(this),this.requestRouter=new f10(this),this.consent=new U20(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=>zi.info('send "'.concat(n==null?void 0:n.event,'"'),n))}init(n,i,o){if(o&&o!==oy){var a,s=(a=pM[o])!==null&&a!==void 0?a:new AV;return s._init(n,i,o),pM[o]=s,pM[oy][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(wr(n)||EW(n))return zi.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 zi.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({},Au2(),cu2(a),{name:s,token:n})),this.config.on_xhr_error&&zi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=a.disable_compression?void 0:Ud.GZipJS,this.persistence=new l_(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new l_(S4(S4({},this.config),{},{persistence:"sessionStorage"}));var r=S4({},this.persistence.props),C=S4({},this.sessionPersistence.props);if(this._requestQueue=new n10(w=>this._send_retriable_request(w),this.config.request_queue_config),this._retryQueue=new o10(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new l10(this),this.sessionPropsManager=new C10(this,this.sessionManager,this.persistence)),new Q00(this).startIfEnabledOrStop(),this.siteApps=new A10(this),(i=this.siteApps)===null||i===void 0||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new m00(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new D20(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new x00(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new M00(this),this.exceptionObserver=new G20(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new ZC2(this,z20),this.deadClicksAutocapture.startIfEnabled(),$h.DEBUG=$h.DEBUG||this.config.debug,$h.DEBUG&&zi.info("Starting in debug mode",{this:this,config:a,thisC:S4({},this.config),p:r,s:C}),this._sync_opt_out_with_persistence(),((o=a.bootstrap)===null||o===void 0?void 0:o.distinctID)!==void 0){var l,e,u=this.config.get_device_id(Vp()),A=(l=a.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?u:a.bootstrap.distinctID;this.persistence.set_property(eE,(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 T,H;return!((T=a.bootstrap)===null||T===void 0||(H=T.featureFlags)===null||H===void 0||!H[w])}).reduce((w,T)=>{var H,S;return w[T]=((H=a.bootstrap)===null||H===void 0||(S=H.featureFlags)===null||S===void 0?void 0:S[T])||!1,w},{}),p=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlagPayloads)||{}).filter(w=>g[w]).reduce((w,T)=>{var H,S,N,X;return(H=a.bootstrap)!==null&&H!==void 0&&(S=H.featureFlagPayloads)!==null&&S!==void 0&&S[T]&&(w[T]=(N=a.bootstrap)===null||N===void 0||(X=N.featureFlagPayloads)===null||X===void 0?void 0:X[T]),w},{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:p})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:mC2,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Vp());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(eE,"anonymous")}return $l(c4,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),a.segment?b00(this,()=>this._loaded()):this._loaded(),jd(this.config._onCapture)&&this.config._onCapture!==m_&&(zi.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(!Pn||!Pn.body)return zi.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,Ud.GZipJS)?Ud.GZipJS:rC(n.supportedCompression,Ud.Base64)?Ud.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){zi.critical("`loaded` function failed",n)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new e10(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()||Np(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&&(uu2?this.__request_queue.push(n):this.rateLimiter.isServerRateLimited(n.batchKey)||(n.transport=n.transport||this.config.api_transport,n.url=uV(n.url,{ip:this.config.ip?1:0}),n.headers=S4({},this.config.request_headers),n.compression=n.compression==="best-available"?this.compression:n.compression,n.fetchOptions=n.fetchOptions||this.config.fetch_options,(i=>{var o,a,s,r=S4({},i);r.timeout=r.timeout||6e4,r.url=uV(r.url,{_:new Date().getTime().toString(),ver:$h.LIB_VERSION,compression:r.compression});var C=(o=r.transport)!==null&&o!==void 0?o:"fetch",l=(a=(s=aC2(EM,e=>e.transport===C))===null||s===void 0?void 0:s.method)!==null&&a!==void 0?a:EM[0].method;if(!l)throw new Error("No available transport method");l(r)})(S4(S4({},n),{},{callback:i=>{var o,a,s;this.rateLimiter.checkForLimiting(i),i.statusCode>=400&&((a=(s=this.config).on_request_error)===null||a===void 0||a.call(s,i)),(o=n.callback)===null||o===void 0||o.call(n,i)}}))))}_send_retriable_request(n){this._retryQueue?this._retryQueue.retriableRequest(n):this._send_request(n)}_execute_array(n){var i,o=[],a=[],s=[];Np(n,C=>{C&&(i=C[0],Fl(i)?s.push(C):jd(C)?C.call(this):Fl(C)&&i==="alias"?o.push(C):Fl(C)&&i.indexOf("capture")!==-1&&jd(this[i])?s.push(C):a.push(C))});var r=function(C,l){Np(C,function(e){if(Fl(e[0])){var u=l;ol(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(!wr(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)&&(zi.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=Vp(),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=E20(e,o!=null&&o._noTruncate?null:this.config.properties_string_max_length)).timestamp=C,wr(o==null?void 0:o.timestamp)||(e.properties.$event_time_override_provided=!0,e.properties.$event_time_override_system_time=r);var A=S4(S4({},e.properties.$set),e.$set);if(WB(A)||this.setPersonPropertiesForFlags(A),!rl(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}zi.critical("This capture call is ignored due to client rate limiting.")}}else zi.error("No event name provided to posthog.capture")}else zi.uninitializedWarning("posthog.capture")}_addCaptureHook(n){return this.on("eventCaptured",i=>n(i.event,i))}_calculate_event_properties(n,i,o,a){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return i;var s=this.persistence.remove_event_timer(n),r=S4({},i);if(r.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(r.$cookieless_mode=!0),n==="$snapshot"){var C=S4(S4({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=C.distinct_id,(!fu(r.distinct_id)&&!nc(r.distinct_id)||EW(r.distinct_id))&&zi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var l,e=Ml.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===gm.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"&&Pn&&(r.title=Pn.title),!wr(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)?ol(this.config.property_denylist,function(w){delete r[w]}):zi.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(zi.error("sanitize_properties is deprecated. Use before_send instead"),r=p(r,n));var b=this._hasPersonProcessing();return r.$process_person_profile=b,b&&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&&(zi.error("sanitize_properties is deprecated. Use before_send instead"),s=r(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,WB(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 zi.uninitializedWarning("posthog.identify");if(nc(n)&&(n=n.toString(),zi.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()))zi.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(eM)&&(this.unregister(eM),this.register({distinct_id:n}));var r=(this.persistence.get_property(eE)||"anonymous")==="anonymous";n!==a&&r?(this.persistence.set_property(eE,"identified"),this.setPersonPropertiesForFlags(S4(S4({},o||{}),i||{}),!1),this.capture("$identify",{distinct_id:n,$anon_distinct_id:a},{$set:i||{},$set_once:o||{}}),this.featureFlags.setAnonymousDistinctId(a),this._cachedIdentify=I_(n,i,o)):(i||o)&&(this._cachedIdentify!==I_(n,i,o)?(this.setPersonProperties(i,o),this._cachedIdentify=I_(n,i,o)):zi.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),n!==a&&(this.reloadFeatureFlags(),this.unregister(ZS))}}else zi.error("Unique user id has not been set in posthog.identify")}setPersonProperties(n,i){(n||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(S4(S4({},i||{}),n||{})),this.capture("$set",{$set:n||{},$set_once:i||{}}))}group(n,i,o){if(n&&i){if(this._requirePersonProcessing("posthog.group")){var a=this.getGroups();a[n]!==i&&this.resetGroupPropertiesForFlags(n),this.register({$groups:S4(S4({},a),{},{[n]:i})}),o&&(this.capture("$groupidentify",{$group_type:n,$group_key:i,$group_set:o}),this.setGroupPropertiesForFlags({[n]:o})),a[n]===i||o||this.reloadFeatureFlags()}}else zi.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(zi.info("reset"),!this.__loaded)return zi.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(eE,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:mC2,$device_id:null},"");else{var C=this.config.get_device_id(Vp());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(sC2)?(zi.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(wr(i)&&(i=this.get_distinct_id()),n!==i?(this._register_single(eM,n),this.capture("$create_alias",{alias:n,distinct_id:i})):(zi.warn("alias matches current distinct_id - skipping api call."),this.identify(n),-1)):void 0}set_config(n){var i,o,a,s,r=S4({},this.config);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 l_(S4(S4({},this.config),{},{persistence:"sessionStorage"})),Qu.is_supported()&&Qu.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&($h.DEBUG=!0,zi.info("set_config",JSON.stringify({config:n,oldConfig:r,newConfig:S4({},this.config)},null,2))),(o=this.sessionRecording)===null||o===void 0||o.startIfEnabledOrStop(),(a=this.autocapture)===null||a===void 0||a.startIfEnabled(),(s=this.heatmaps)===null||s===void 0||s.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(n){var i=n===!0,o={sampling:i||!(n==null||!n.sampling),linked_flag:i||!(n==null||!n.linked_flag),url_trigger:i||!(n==null||!n.url_trigger),event_trigger:i||!(n==null||!n.event_trigger)};if(Object.values(o).some(Boolean)){var a,s,r,C,l;(a=this.sessionManager)===null||a===void 0||a.checkAndGetSessionAndWindowId(),o.sampling&&((s=this.sessionRecording)===null||s===void 0||s.overrideSampling()),o.linked_flag&&((r=this.sessionRecording)===null||r===void 0||r.overrideLinkedFlag()),o.url_trigger&&((C=this.sessionRecording)===null||C===void 0||C.overrideTrigger("url")),o.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var n;return!((n=this.sessionRecording)===null||n===void 0||!n.started)}captureException(n,i){var o=new Error("PostHog syntheticException");this.exceptions.sendExceptionEvent(S4(S4({},n00((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:oy;return i!==oy&&(i=oy+"."+i),i}_isIdentified(){var n,i;return((n=this.persistence)===null||n===void 0?void 0:n.get_property(eE))==="identified"||((i=this.sessionPersistence)===null||i===void 0?void 0:i.get_property(eE))==="identified"}_hasPersonProcessing(){var n,i,o,a;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&WB(this.getGroups())&&((n=this.persistence)===null||n===void 0||(i=n.props)===null||i===void 0||!i[eM])&&((o=this.persistence)===null||o===void 0||(a=o.props)===null||a===void 0||!a[FS]))}_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"?(zi.error(n+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(FS,!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(),(wr(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 uf?Cu2(uf,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Pn&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:Pn.title},{send_instantly:!0}))}debug(n){n===!1?(c4==null||c4.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(c4==null||c4.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(rl(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),rl(o)){var s="Event '".concat(n.event,"' was rejected in beforeSend function");return d20(n.event)?zi.warn("".concat(s,". This can cause unexpected behavior.")):zi.info(s),null}o.properties&&!WB(o.properties)||zi.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]]=h20(t.prototype[n[i]])})(AV,["identify"]);var fu2,h10=(fu2=pM[oy]=new AV,function(){function t(){t.done||(t.done=!0,uu2=!1,ol(pM,function(n){n._dom_loaded()}))}Pn!=null&&Pn.addEventListener?Pn.readyState==="complete"?t():$l(Pn,"DOMContentLoaded",t,{capture:!1}):c4&&zi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),fu2);const E10=new $$2({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),du2=({children:t,theme:n})=>{F0.useEffect(()=>{!n||!Object.keys(n).length||EB2(n)},[n]);const i=(o,a)=>{h10.capture("sth_went_wrong",{message:o.message,stack:o.stack,componentStack:a.componentStack})};return h.jsx(N$2,{FallbackComponent:Rb2,onError:i,children:h.jsx(o20,{client:E10,children:t})})},ay={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"},gu2=F0.createContext({isLoading:void 0,data:void 0,token:void 0,refetch:void 0}),cV=()=>F0.useContext(gu2),fV="https://api.usedatabrain.com",zu="/api/v2/dashboard",sy="/api/v2/metric",zg="/api/v3/metric",p10="dashboardData",v10=`${zu}/embeddedMetric`,I10="embeddedMetric",m10=`${sy}/layout`,hu2="dashboardLayout",b10=`${zu}/scheduledReportV2`,B10="dashboardScheduledReportV2",y10=`${sy}/saveLayout`,L10="saveLayout",w10=`${zu}/saveScheduleReport`,Q10="saveScheduleReport",M10=`${zu}/deleteScheduleReport`,T10="deleteScheduleReport",x10=`${zu}/createMetric`,R10="createMetric",H10=`${zu}/updateMetric`,D10="updateMetric",N10=`${zu}/updateAdminMetric`,S10="updateAdminMetric",V10=`${zu}/generateMetric`,k10="generateMetric",O10=`${zu}/datasetMetricCreation`,P10="datasetMetricCreation",Z10=`${zu}/previewTable`,F10="previewTable",U10=`${zu}/generatetMetricData`,j10="/generatetMetricData",z10=`${zu}/getOpenaiChatResponse`,G10="getOpenaiChatResponse",Y10=`${zu}/getDashboardScreenshot`,W10=`${zu}/createDashboardFilterView`,_10="createDashboardFilterView",X10=`${zu}/getDashboardFilterView`,K10="getDashboardFilterView",J10=`${zu}/getTheme`,q10="getTheme",$10=`${zg}/query`,e30="query",t30=`${zg}/datasetMetricCreation`,r30="newDatasetMetricCreation",n30=`${zg}/generateDataReport`,i30="generateDataReport",o30=`${zg}/chatQuery`,a30="chatQuery",s30=`${sy}/rawDownloadSettings`,C30="rawDownloadSettings",l30=`${sy}/column`,u30="column",A30=`${sy}/underlyingData`,c30="underlyingData",f30=`${sy}/invokeShareCsv`,d30="invokeShareCsv",g30=`${zg}/markArchived`,h30="markArchived",E30=`${zg}/publishMetrics`,p30="publishMetrics",v30=`${zg}/download-csv`,I30=`${zg}/downloadDashboardMetrics`,m30="IS_LOADING",b30="DATA_LOADED",B30=`${zg}/summarizeMetric`,y30="summarizeMetric",L30=`${zg}/createGuestTokenUsageLog`,w30="createGuestTokenUsageLog",Eu2="ENTER_FULL_SCREEN_MODE",pu2="EXIT_FULL_SCREEN_MODE",Q30="ENTER_SCHEDULED_REPORT_MODE",M30="SAVE_SCHEDULED_REPORT",vu2="EXIT_SCHEDULED_REPORT_MODE",T30="ENTER_CUSTOMIZE_LAYOUT_MODE",Iu2="EXIT_CUSTOMIZE_LAYOUT_MODE",mu2="SAVE_LAYOUT",x30="ENTER_MANAGE_METRICS_MODE",bu2="EXIT_MANAGE_METRICS_MODE",R30="SAVE_MANAGE_METRICS",H30="ARCHIVE_METRIC",Bu2="DOWNLOAD_METRIC",yu2="DOWNLOAD_METRIC_WITHOUT_FILTERS",D30="SAVE_METRIC_PNG",N30="METRIC_FILTER_APPLIED",S30="DASHBOARD_FILTER_APPLIED",V30="CREATE_METRIC",Lu2="UPDATE_METRIC",b_=()=>localStorage.getItem(fb2),dV=()=>{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},OC=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":b_()||""}:{},...dV()||{}}};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)||fV}${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},k30=()=>Zl(L10,t=>OC(y10,{method:"POST",data:t})),O30=()=>Zl(Q10,t=>OC(w10,{method:"POST",data:t.data,token:t.token})),wu2=()=>Zl(T10,t=>OC(M10,{method:"POST",data:t,token:t.token})),P30=()=>Zl(R10,({data:t,token:n})=>OC(x10,{method:"POST",data:t,token:n})),Z30=()=>Zl(D10,({data:t,token:n})=>OC(H10,{method:"POST",data:t,token:n})),F30=()=>Zl(S10,({data:t,token:n})=>OC(N10,{method:"POST",data:t,token:n})),U30=()=>Zl(k10,({data:t,token:n})=>OC(V10,{method:"POST",data:t,token:n})),Qu2=()=>Zl(P10,({data:t,token:n})=>OC(O10,{method:"POST",data:t,token:n})),j30=()=>Zl(F10,({data:t,token:n})=>OC(Z10,{method:"POST",data:t,token:n})),z30=()=>Zl(j10,({data:t,token:n})=>OC(U10,{method:"POST",data:t,token:n})),G30=()=>Zl(G10,({data:t,token:n})=>OC(z10,{method:"POST",data:t,token:n})),Y30=()=>Zl(_10,({data:t,token:n})=>OC(W10,{method:"POST",data:t,token:n})),B_=()=>Zl(u30,t=>OC(l30,{method:"POST",data:t})),W30=()=>Zl(c30,t=>OC(A30,{method:"POST",data:t})),_30=()=>Zl(d30,t=>OC(f30,{method:"POST",data:t})),X30=()=>Zl(h30,({data:t,token:n})=>OC(g30,{method:"POST",data:t,token:n})),K30=()=>Zl(p30,({data:t,token:n})=>OC(E30,{method:"POST",data:t,token:n})),J30=()=>Zl(r30,({data:t,token:n,clientId:i,isFrontendApp:o})=>OC(t30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),Mu2=()=>Zl(i30,({data:t,token:n,clientId:i,isFrontendApp:o})=>OC(n30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),q30=()=>Zl(a30,({data:t,token:n,clientId:i,isFrontendApp:o})=>OC(o30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),$30=()=>Zl(y30,({data:t,isFrontendApp:n,clientId:i,token:o})=>OC(B30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),e70=()=>Zl(w30,({data:t,isFrontendApp:n,clientId:i,token:o})=>OC(L30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),y_=()=>{const{mutateAsync:t}=e70();return{saveLogsAsync:async i=>{t(i)}}},vM=({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:p,metric:b,datasetMetricSettings:w,drillDownSettings:T,onServerEvent:H})=>{var U0,X2,Q3;const{token:S,data:N}=cV(),[X,W]=F0.useState(""),{mutate:f2,isLoading:Q2}=P30(),{mutate:I2}=j30(),{saveLogsAsync:r2}=y_(),{register:D2,setValue:M2,watch:m2,handleSubmit:k2,control:W2,reset:c0}=cb(),p0=x1=>{W(""),C==null||C.chartType,m0.singleValue,f2({data:{companyId:e,companyIntegrationId:n,description:x1.description,inputFields:i,metricId:x1.metricId,name:x1.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(v3=>({externalDashboardId:v3})),isEnableGroupBy:d,groupBy:g??{},selectedGroupBy:p,drillDownSettings:T},token:S},{onSuccess:async v3=>{var W3,g7,I3;(W3=v3==null?void 0:v3.insert_externalMetrics_one)!=null&&W3.id?(await r2({clientId:l,data:{companyId:e,feature:"CREATE_METRIC",metricId:(g7=v3==null?void 0:v3.insert_externalMetrics_one)==null?void 0:g7.metricId},isFrontendApp:!1,token:S}),await(t==null?void 0:t((I3=v3==null?void 0:v3.insert_externalMetrics_one)==null?void 0:I3.id)),H==null||H(V30)):W("Metric Id already exists")},onError:()=>{W&&W("Metric Id already exists")}})},{mutateAsync:L0,isLoading:b0}=F30(),{mutateAsync:j2,isLoading:t1}=Z30(),h0=F0.useCallback((x1,v3)=>{var g7,I3,$3;W("");let W3={};if(v3&&(W3={isDisableCardAppearance:x1.isDisableCardAppearance,titleAlignment:x1.titleAlignment,descAlignment:x1.descAlignment,...x1.text?{textBox:{text:x1.text,fontWeight:x1.fontWeight||"400",fontColor:x1.fontColor||"",fontSize:x1.fontSize||"14px",alignment:x1.textAlignment||"left",link:x1.textLink,isOpenInNewTab:x1.isOpenInNewTab,targetWord:x1.targetWord}}:null}),!(b!=null&&b.isCreatedByClient))L0({data:{externalMetricId:b==null?void 0:b.id,clientId:l,object:{clientId:l,companyId:e,companyIntegrationId:n||(b==null?void 0:b.companyIntegrationId),description:x1.description,inputFields:i,metricId:x1.metricId===(b==null?void 0:b.metricId)?`update_${x1.metricId}_by_${l}_${Date.now()}`:x1.metricId,name:v3?(g7=x1==null?void 0:x1.elementTitle)==null?void 0:g7.trim():(I3=x1==null?void 0:x1.name)==null?void 0:I3.trim(),query:o,metricQuery:a,datasetMetricSettings:w,integrationName:s,outputColumns:r,createdBy:l||"external user",isCreatedByClient:!!l,isLive:u||x1.isLive,chartOptions:C,drillDownSettings:T,elementSettings:W3,isMetric:!v3,...v3?{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(b7=>({externalDashboardId:b7}))}}},token:S},{onSuccess:async b7=>{var I7;!(b7!=null&&b7.insert_clientDeletedMetrics_one)||!(b7!=null&&b7.insert_externalMetrics_one)||(W(""),await r2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(I7=b7==null?void 0:b7.insert_externalMetrics_one)==null?void 0:I7.metricId},isFrontendApp:!1,token:S}),await(t==null?void 0:t()),H==null||H(Lu2))},onError:()=>{W("Something went wrong! Please try again later.")}});else{const b7={chartOptions:C,datasetMetricSettings:w,description:x1.description,query:o,metricQuery:a,drillDownSettings:T,elementSettings:W3,isMetric:!v3,...v3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}}};x1.description&&(b7.description=x1.description),x1.metricId&&(b7.metricId=x1.metricId),x1.name&&!v3&&(b7.name=x1.name),x1.elementTitle&&v3&&(b7.name=x1==null?void 0:x1.elementTitle),($3=Object.keys(W3))!=null&&$3.length&&(b7.elementSettings=W3),j2({data:{externalMetricId:b==null?void 0:b.id,set:b7},token:S},{onSuccess:async I7=>{var R6,h6;(R6=I7==null?void 0:I7.update_externalMetrics_by_pk)!=null&&R6.id&&(W(""),await r2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(h6=I7==null?void 0:I7.update_externalMetrics_by_pk)==null?void 0:h6.metricId},isFrontendApp:!1,token:S}),await(t==null?void 0:t()),H==null||H(Lu2))},onError:()=>{W("Something went wrong! Please try again later.")}})}},[C,b,j2,L0,l,e,n,s,u,f,o,i,r,a,w]),O0=F0.useCallback(x1=>{W("");const v3={isPublished:!(x1!=null&&x1.isPublished)};j2({data:{externalMetricId:x1==null?void 0:x1.id,set:v3},token:S},{onSuccess:async W3=>{var g7,I3;(g7=W3==null?void 0:W3.update_externalMetrics_by_pk)!=null&&g7.id&&(W(""),await r2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(I3=W3==null?void 0:W3.update_externalMetrics_by_pk)==null?void 0:I3.metricId},isFrontendApp:!1,token:S}),t==null||t())},onError:()=>{W("Something went wrong! Please try again later.")}})},[b]);return{createExternalMetric:p0,updateExternalMetric:h0,error:X,isLoading:Q2||b0||t1,clientSubsetData:N==null?void 0:N.clientSubsetData,previewTable:I2,token:S,workspaceId:(U0=N==null?void 0:N.workspace)==null?void 0:U0.id,dashboardOptions:[{value:(X2=N==null?void 0:N.externalDashboard)==null?void 0:X2.id,label:((Q3=N==null?void 0:N.externalDashboard)==null?void 0:Q3.name)||"Dashboard"}],isDatabaseTenancy:(N==null?void 0:N.companyTenancyType)===AL,register:D2,setValue:M2,watch:m2,handleSubmit:k2,control:W2,reset:c0,onPublishMetric:O0}},Tu2=()=>{const{mutate:t,isLoading:n,error:i}=U30(),{mutate:o,mutateAsync:a}=B_();return{generateDatasetMetric:t,isGeneratingDataset:n,generateError:i,fetchColumnValues:o,fetchColumnValuesAsync:a}};let t70=0;function r70(t,n){const i=`atom${++t70}`,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 td={},Zp=Symbol(),L_=t=>!!t[Zp],gV=t=>!t[Zp].c,IM=t=>{var n;const{b:i,c:o}=t[Zp];o&&(o(),(n=i70.get(i))==null||n())},hV=(t,n)=>{const i=t[Zp].o,o=n[Zp].o;return i===o||t===o||L_(i)&&hV(i,n)},w_=(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[Zp]=i,o},n70=t=>w_(t[Zp].b,t[Zp].o),i70=new WeakMap,Q_=t=>"init"in t,M_="r",T_="w",EV="c",x_="s",xu2="h",o70="n",a70="l",s70="a",C70="m",l70=t=>{const n=new WeakMap,i=new WeakMap,o=new Map;let a,s;(td&&"production")!=="production"&&(a=new Set,s=new Set);const r=new WeakMap,C=(b0,j2,t1)=>{let h0=r.get(j2);h0||(h0=new Map,r.set(j2,h0)),t1.then(()=>{h0.get(b0)===t1&&(h0.delete(b0),h0.size||r.delete(j2))}),h0.set(b0,t1)},l=b0=>{const j2=new Set,t1=r.get(b0);return t1&&(r.delete(b0),t1.forEach((h0,O0)=>{IM(h0),j2.add(O0)})),j2},e=new WeakMap,u=b0=>{let j2=e.get(b0);return j2||(j2=new Map,e.set(b0,j2)),j2},A=(b0,j2)=>{if(b0){const t1=u(b0);let h0=t1.get(j2);return h0||(h0=A(b0.p,j2),h0&&"p"in h0&&gV(h0.p)&&(h0=void 0),h0&&t1.set(j2,h0)),h0}return n.get(j2)},f=(b0,j2,t1)=>{if((td&&"production")!=="production"&&Object.freeze(t1),b0)u(b0).set(j2,t1);else{const h0=n.get(j2);n.set(j2,t1),o.has(j2)||o.set(j2,h0)}},d=(b0,j2=new Map,t1)=>{if(!t1)return j2;const h0=new Map;let O0=!1;return t1.forEach(U0=>{var X2;const Q3=((X2=A(b0,U0))==null?void 0:X2.r)||0;h0.set(U0,Q3),j2.get(U0)!==Q3&&(O0=!0)}),j2.size===h0.size&&!O0?j2:h0},g=(b0,j2,t1,h0,O0)=>{const U0=A(b0,j2);if(U0){if(O0&&(!("p"in U0)||!hV(U0.p,O0)))return U0;"p"in U0&&IM(U0.p)}const X2={v:t1,r:(U0==null?void 0:U0.r)||0,y:!0,d:d(b0,U0==null?void 0:U0.d,h0)};let Q3=!(U0!=null&&U0.y);return!U0||!("v"in U0)||!Object.is(U0.v,t1)?(Q3=!0,++X2.r,X2.d.has(j2)&&(X2.d=new Map(X2.d).set(j2,X2.r))):X2.d!==U0.d&&(X2.d.size!==U0.d.size||!Array.from(X2.d.keys()).every(x1=>U0.d.has(x1)))&&(Q3=!0,Promise.resolve().then(()=>{k2(b0)})),U0&&!Q3?U0:(f(b0,j2,X2),X2)},p=(b0,j2,t1,h0,O0)=>{const U0=A(b0,j2);if(U0){if(O0&&(!("p"in U0)||!hV(U0.p,O0)))return U0;"p"in U0&&IM(U0.p)}const X2={e:t1,r:((U0==null?void 0:U0.r)||0)+1,y:!0,d:d(b0,U0==null?void 0:U0.d,h0)};return f(b0,j2,X2),X2},b=(b0,j2,t1,h0)=>{const O0=A(b0,j2);if(O0&&"p"in O0){if(hV(O0.p,t1)&&!gV(O0.p))return O0.y?O0:{...O0,y:!0};IM(O0.p)}C(b0,j2,t1);const U0={p:t1,r:((O0==null?void 0:O0.r)||0)+1,y:!0,d:d(b0,O0==null?void 0:O0.d,h0)};return f(b0,j2,U0),U0},w=(b0,j2,t1,h0)=>{if(t1 instanceof Promise){const O0=w_(t1,t1.then(U0=>{g(b0,j2,U0,h0,O0)}).catch(U0=>{if(U0 instanceof Promise)return L_(U0)?U0.then(()=>{H(b0,j2,!0)}):U0;p(b0,j2,U0,h0,O0)}));return b(b0,j2,O0,h0)}return g(b0,j2,t1,h0)},T=(b0,j2)=>{const t1=A(b0,j2);if(t1){const h0={...t1,y:!1};f(b0,j2,h0)}else(td&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",j2)},H=(b0,j2,t1)=>{if(!t1){const O0=A(b0,j2);if(O0){if(O0.y&&"p"in O0&&!gV(O0.p))return O0;if(O0.d.forEach((U0,X2)=>{if(X2!==j2)if(!i.has(X2))H(b0,X2);else{const Q3=A(b0,X2);Q3&&!Q3.y&&H(b0,X2)}}),Array.from(O0.d).every(([U0,X2])=>{const Q3=A(b0,U0);return Q3&&!("p"in Q3)&&Q3.r===X2}))return O0.y?O0:{...O0,y:!0}}}const h0=new Set;try{const O0=j2.read(U0=>{h0.add(U0);const X2=U0===j2?A(b0,U0):H(b0,U0);if(X2){if("e"in X2)throw X2.e;if("p"in X2)throw X2.p;return X2.v}if(Q_(U0))return U0.init;throw new Error("no atom init")});return w(b0,j2,O0,h0)}catch(O0){if(O0 instanceof Promise){const U0=L_(O0)&&gV(O0)?n70(O0):w_(O0,O0);return b(b0,j2,U0,h0)}return p(b0,j2,O0,h0)}},S=(b0,j2)=>H(j2,b0),N=(b0,j2)=>{let t1=i.get(j2);return t1||(t1=D2(b0,j2)),t1},X=(b0,j2)=>!j2.l.size&&(!j2.t.size||j2.t.size===1&&j2.t.has(b0)),W=(b0,j2)=>{const t1=i.get(j2);t1&&X(j2,t1)&&M2(b0,j2)},f2=(b0,j2)=>{const t1=i.get(j2);t1==null||t1.t.forEach(h0=>{h0!==j2&&(T(b0,h0),f2(b0,h0))})},Q2=(b0,j2,t1)=>{let h0=!0;const O0=(Q3,x1)=>{const v3=H(b0,Q3);if("e"in v3)throw v3.e;if("p"in v3){if(x1!=null&&x1.unstable_promise)return v3.p.then(()=>{const W3=A(b0,Q3);return W3&&"p"in W3&&W3.p===v3.p?new Promise(g7=>setTimeout(g7)).then(()=>O0(Q3,x1)):O0(Q3,x1)});throw(td&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",Q3),v3.p}if("v"in v3)return v3.v;throw(td&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",Q3),new Error("no value found")},U0=(Q3,x1)=>{let v3;if(Q3===j2){if(!Q_(Q3))throw new Error("atom not writable");l(Q3).forEach($3=>{$3!==b0&&w($3,Q3,x1)});const g7=A(b0,Q3),I3=w(b0,Q3,x1);g7!==I3&&f2(b0,Q3)}else v3=Q2(b0,Q3,x1);return h0||k2(b0),v3},X2=j2.write(O0,U0,t1);return h0=!1,X2},I2=(b0,j2,t1)=>{const h0=Q2(t1,b0,j2);return k2(t1),h0},r2=b0=>!!b0.write,D2=(b0,j2,t1)=>{const h0={t:new Set(t1&&[t1]),l:new Set};if(i.set(j2,h0),(td&&"production")!=="production"&&s.add(j2),H(void 0,j2).d.forEach((U0,X2)=>{const Q3=i.get(X2);Q3?Q3.t.add(j2):X2!==j2&&D2(b0,X2,j2)}),r2(j2)&&j2.onMount){const U0=Q3=>I2(j2,Q3,b0),X2=j2.onMount(U0);b0=void 0,X2&&(h0.u=X2)}return h0},M2=(b0,j2)=>{var t1;const h0=(t1=i.get(j2))==null?void 0:t1.u;h0&&h0(),i.delete(j2),(td&&"production")!=="production"&&s.delete(j2);const O0=A(b0,j2);O0?("p"in O0&&IM(O0.p),O0.d.forEach((U0,X2)=>{if(X2!==j2){const Q3=i.get(X2);Q3&&(Q3.t.delete(j2),X(X2,Q3)&&M2(b0,X2))}})):(td&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",j2)},m2=(b0,j2,t1,h0)=>{const O0=new Set(t1.d.keys());h0==null||h0.forEach((U0,X2)=>{if(O0.has(X2)){O0.delete(X2);return}const Q3=i.get(X2);Q3&&(Q3.t.delete(j2),X(X2,Q3)&&M2(b0,X2))}),O0.forEach(U0=>{const X2=i.get(U0);X2?X2.t.add(j2):i.has(j2)&&D2(b0,U0,j2)})},k2=b0=>{if(b0){u(b0).forEach((t1,h0)=>{const O0=n.get(h0);if(t1!==O0){const U0=i.get(h0);U0==null||U0.l.forEach(X2=>X2(b0))}});return}for(;o.size;){const j2=Array.from(o);o.clear(),j2.forEach(([t1,h0])=>{const O0=A(void 0,t1);if(O0&&O0.d!==(h0==null?void 0:h0.d)&&m2(void 0,t1,O0,h0==null?void 0:h0.d),h0&&!h0.y&&(O0!=null&&O0.y))return;const U0=i.get(t1);U0==null||U0.l.forEach(X2=>X2())})}(td&&"production")!=="production"&&a.forEach(j2=>j2())},W2=b0=>{u(b0).forEach((t1,h0)=>{const O0=n.get(h0);(!O0||t1.r>O0.r||t1.y!==O0.y||t1.r===O0.r&&t1.d!==O0.d)&&(n.set(h0,t1),t1.d!==(O0==null?void 0:O0.d)&&m2(b0,h0,t1,O0==null?void 0:O0.d))})},c0=(b0,j2)=>{j2&&W2(j2),k2(void 0)},p0=(b0,j2,t1)=>{const O0=N(t1,b0).l;return O0.add(j2),()=>{O0.delete(j2),W(t1,b0)}},L0=(b0,j2)=>{for(const[t1,h0]of b0)Q_(t1)&&(w(j2,t1,h0),f2(j2,t1));k2(j2)};return(td&&"production")!=="production"?{[M_]:S,[T_]:I2,[EV]:c0,[x_]:p0,[xu2]:L0,[o70]:b0=>(a.add(b0),()=>{a.delete(b0)}),[a70]:()=>s.values(),[s70]:b0=>n.get(b0),[C70]:b0=>i.get(b0)}:{[M_]:S,[T_]:I2,[EV]:c0,[x_]:p0,[xu2]:L0}},u70=(t,n)=>({s:n?n(t).SECRET_INTERNAL_store:l70()}),R_=new Map,Ru2=t=>(R_.has(t)||R_.set(t,F0.createContext(u70())),R_.get(t));function Hu2(t,n){return r70(t)}function A70(t,n){const i=Ru2(n),o=F0.useContext(i),{s:a,v:s}=o,r=f=>{const d=a[M_](t,f);if((td&&"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]=F0.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)),F0.useEffect(()=>{const{v:f}=o;f&&a[EV](t,f);const d=a[x_](t,u,f);return u(f),d},[a,t,o]),F0.useEffect(()=>{a[EV](t,C)}),F0.useDebugValue(A),A}function c70(t,n){const i=Ru2(n),{s:o,w:a}=F0.useContext(i);return F0.useCallback(r=>{if((td&&"production")!=="production"&&!("write"in t))throw new Error("not writable atom");const C=l=>o[T_](t,r,l);return a?a(C):C()},[o,a,t])}function H_(t,n){return"scope"in t&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),n=t.scope),[A70(t,n),c70(t,n)]}const pV=({onOutsideClick:t,wrapRef:n,portalRef:i})=>{F0.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])},f70=({wrapRef:t,portalRef:n,autoCloseParent:i=!1})=>{const[o]=H_(RA2);F0.useEffect(()=>{const a=s=>{o==null||o.forEach(r=>{var l,e,u,A,f,d,g,p;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 b=o.find(w=>{var H,S;const T=((H=r.popperElement)==null?void 0:H.contains(w.referenceElement))&&(w.isOpen===!0||w.isMenuOpen===!0);return i?T&&((S=w.popperElement)==null?void 0:S.contains("composedPath"in s?s.composedPath()[0]:s.target)):T});b?((u=b==null?void 0:b.setOpen)==null||u.call(b,!0),(A=b==null?void 0:b.setMenuOpen)==null||A.call(b,!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),(p=r.setMenuOpen)==null||p.call(r,!0))})};return document.addEventListener("click",a,!0),()=>{document.removeEventListener("click",a,!0)}},[t,n,o])},d70=({token:t,dashboardId:n,configId:i,isEn:o})=>{var a;return Rp([p10,{dashboardId:n,configId:i,token:t,isEn:o}],()=>{const s=n?`${zu}?dashboardId=${n}${i?`&configId=${i}`:""}${`&isEn=${o}`}`:zu;return OC(s,{method:"GET",token:t})},{enabled:!!t||!!((a=window==null?void 0:window.dbn)!=null&&a.isEnableProxyAuth)})},g70=(t,n)=>Rp([hu2,{dashboardId:t,clientId:n}],()=>OC(`${m10}?id=${t}&clientId=${n}`,{method:"GET"}),{enabled:!!t&&!!n}),h70=(t,n,i)=>Rp(B10,()=>OC(`${b10}?externalDashboardId=${n}${i?`&embedId=${i}`:""}`,{method:"GET",token:t}),{enabled:!!t&&!!n}),E70=(t,n)=>{var i;return Rp([I10,{id:n}],()=>OC(`${v10}?metricId=${n}`,{method:"GET",token:t}),{enabled:!!t||!!((i=window==null?void 0:window.dbn)!=null&&i.isEnableProxyAuth)})},Du2=({token:t,name:n,companyId:i})=>Rp([q10,{name:n}],()=>OC(J10,{method:"POST",token:t,data:{name:n,companyId:i}}),{enabled:!!(n&&t&&i)}),p70=({token:t,dashboardId:n})=>Rp([K10,{dashboardId:n}],()=>OC(X10,{method:"POST",token:t,data:{dashboardId:n}}),{enabled:!!(t&&n)}),v70=({externalDashboardId:t,clientId:n})=>{const i=cW(),{data:o,isLoading:a}=g70(t,n),[s,r,C,l]=F0.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}=k30();return{saveLayout:F0.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([hu2,{dashboardId:t,clientId:n}],p=>({...p,...g}))}})},[e,n,t]),layout:s,dashboardFiltersLayout:r,gridMargin:l,isLayoutLocked:C,isLoadingLayout:a||u}},I70=({query:t,limit:n,offset:i,dbName:o})=>{const a=Bf===(o==null?void 0:o.toLowerCase()),s=Pu===(o==null?void 0:o.toLowerCase()),r=vA===(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())==Pu||(o==null?void 0:o.toLowerCase())==Bf||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},m70=({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:p}=W30();return{getUnderlyingData:({columnName:w,value:T,setData:H,setLoading:S,isSingleValueChart:N,clientColumnType:X})=>{const W=o==="MULTI_DATABASE"&&n||"",f2=g&&d?d:I70({query:s,limit:"5000",dbName:i}),Q2=db({clientColumnType:X,query:f2||"",dbName:i,rlsConditions:A,tenancyLevel:o||"TABLE",clientId:n,globalFilters:e,values:a,isAllClient:u,dataMartRelationships:f});H([]),S(!0),p({columnName:N?void 0:w,companyId:r,query:lf(Q2,r),value:N?void 0:T.toString().replace(/'/g,"''"),workspaceId:C,metricId:l,isCustomSql:g&&!!d,databaseName:W,datasourceId:t},{onSuccess(I2){const r2=I2==null?void 0:I2.data;r2&&Array.isArray(r2)&&r2.length?(H(r2),S(!1)):(H([]),S(!1))},onError(){H([]),S(!1)}})}}},b70=({clientId:t,data:n,token:i,isFrontendApp:o,isFullScreen:a=""},s)=>Rp([e30,n,t,o,i,a],()=>{var r,C,l;return OC($10,{method:"POST",data:{...n||{},...!o&&i?{...(r=n==null?void 0:n.rlsConditions)!=null&&r.length?{rlsConditions:zB(n==null?void 0:n.rlsConditions,i)}:{},...(l=(C=n==null?void 0:n.globalFilters)==null?void 0:C.filters)!=null&&l.length?{globalFilters:zB(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}),B70=t=>Rp([C30,t],()=>OC(`${s30}?id=${t}`,{method:"GET"}),{enabled:!!t}),vV={timeSeriesSettingsContainer:"_timeSeriesSettingsContainer_3qyzb_1",timeSeriesSettingsType:"_timeSeriesSettingsType_3qyzb_9",featToggle:"_featToggle_3qyzb_17",dynamicFormat:"_dynamicFormat_3qyzb_33"},y70=[{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"}],L70=({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 p=`${n.options[d].split("____")[0]}____${g}`,b=`${n.options[d].split("____")[0]}`;t(w=>{var T,H,S,N;return{...w,groupBySettings:{...w.groupBySettings,options:(T=w.groupBySettings.options)==null?void 0:T.map((X,W)=>W===d?p:X),value:((H=w.groupBySettings.options)==null?void 0:H.find((X,W)=>W===d))===((S=w==null?void 0:w.groupBySettings)==null?void 0:S.value)?b:(N=w==null?void 0:w.groupBySettings)==null?void 0:N.value}}})}else{const p=`${n.options[d]}____${g}`,b=`${n.options[d]}`;t(w=>{var T,H,S,N;return{...w,groupBySettings:{...w.groupBySettings,options:(T=w.groupBySettings.options)==null?void 0:T.map((X,W)=>W===d?p:X),value:((H=w.groupBySettings.options)==null?void 0:H.find((X,W)=>W===d))===((S=w==null?void 0:w.groupBySettings)==null?void 0:S.value)?b:(N=w==null?void 0:w.groupBySettings)==null?void 0:N.value}}})}};return h.jsxs("div",{className:vV.timeSeriesSettingsContainer,children:[h.jsx(e6,{variant:"heading-5",children:"Time Series Settings"}),h.jsx(G4,{label:"Series Type",options:y70,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(p=>({column:p,type:d.value}))}))},menuWidth:"100%",buttonWidth:"100%"}),h.jsx(e6,{variant:"body-text-2",children:"Group format"}),h.jsxs("div",{className:vV.timeSeriesSettingsType,children:[h.jsx(uc,{"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(p=>p.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}),h.jsx(uc,{"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(p=>p.value),fillXAxis:!1,isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[2]))}}),h.jsx(uc,{"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(p=>p.value),fillXAxis:!1,isGlobalFilter:!0,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[0]))}})]}),n.isDynamic?h.jsxs("div",{className:vV.dynamicFormat,children:[h.jsx(rs,{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(p=>p.value))||["monthly"],fillXAxis:[Jc.daily,Jc.weekly,Jc.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)=>h.jsx(K9,{label:d.split("____").length>1?d.split("____")[0]:d,type:"text",value:d.split("____").length>1?d.split("____")[1]:d,placeholder:"Save as",onChange:p=>{r(g,p.target.value)}}))]}):h.jsxs(h.Fragment,{children:[(n==null?void 0:n.isGlobalFilter)&&h.jsxs(h.Fragment,{children:[h.jsx(G4,{label:"Dashboard Filter",menuWidth:"100%",buttonWidth:"100%",options:s,selectedOption:n.globalFilterOption||{value:"",label:""},onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,globalFilterOption:d,formatWithValue:[]}}))}}),!!((u=(e=n==null?void 0:n.globalFilterOption)==null?void 0:e.presetDateOptions)!=null&&u.length)&&h.jsx(za,{direction:"col",className:"dbn-gap-3",children:cC==null?void 0:cC.map(d=>{var g,p,b,w,T,H,S;return h.jsxs(za,{className:"dbn-w-full dbn-gap-2",alignItems:"center",justify:"between",children:[h.jsx(ff,{checked:!!((g=n==null?void 0:n.formatWithValue)!=null&&g.find(N=>N.format===d.value&&N.isEnable)),onChange:({target:{checked:N}})=>{t(X=>{var W,f2,Q2,I2,r2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(W=X==null?void 0:X.groupBySettings)==null?void 0:W.formatWithValue)==null?void 0:f2.filter(D2=>D2.format!==d.value))||[],{format:d.value,isEnable:N,value:((r2=(I2=(Q2=X==null?void 0:X.groupBySettings)==null?void 0:Q2.formatWithValue)==null?void 0:I2.find(D2=>D2.format===d.value))==null?void 0:r2.value)||""}]}}})},label:d.value}),h.jsx("div",{className:"dbn-w-full",children:h.jsx(G4,{placeholder:"Select a Filter Value",menuWidth:"100%",buttonWidth:"100%",options:((p=n==null?void 0:n.globalFilterOption)==null?void 0:p.presetDateOptions)||[],selectedOption:{value:((w=(b=n==null?void 0:n.formatWithValue)==null?void 0:b.find(N=>N.format===d.value))==null?void 0:w.value)||"",label:((H=(T=n==null?void 0:n.formatWithValue)==null?void 0:T.find(N=>N.format===d.value))==null?void 0:H.value)||""},isDisabled:!((S=n==null?void 0:n.formatWithValue)!=null&&S.find(N=>N.format===d.value&&N.isEnable)),onChange:N=>{t(X=>{var W,f2,Q2,I2,r2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(W=X==null?void 0:X.groupBySettings)==null?void 0:W.formatWithValue)==null?void 0:f2.filter(D2=>D2.format!==d.value))||[],{format:d.value,isEnable:!!((r2=(I2=(Q2=X==null?void 0:X.groupBySettings)==null?void 0:Q2.formatWithValue)==null?void 0:I2.find(D2=>D2.format===d.value))!=null&&r2.isEnable),value:(N==null?void 0:N.value)||""}]}}})}})})]})})})]}),h.jsx(G4,{label:"Format Type",menuWidth:"100%",buttonWidth:"100%",options:cC,selectedOption:(cC==null?void 0:cC.find(d=>{var g,p;return((g=d.value)==null?void 0:g.toLowerCase())===((p=n==null?void 0:n.value)==null?void 0:p.toLowerCase())}))||(cC==null?void 0:cC[2]),onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:d.value}})),a==null||a(d)}}),[Jc.month,Jc.quarter].includes(n.value.toLowerCase())&&h.jsxs("div",{className:vV.featToggle,children:[h.jsx(G5,{name:"fill axis",enabled:n.fillXAxis,onChange:()=>t(d=>({...d,groupBySettings:{...d.groupBySettings,fillXAxis:!d.groupBySettings.fillXAxis}}))}),h.jsxs("span",{className:"dbn-flex dbn-gap-2 dbn-items-center",children:[h.jsx(e6,{variant:"body-text-2",children:"Fill X-axis"}),h.jsx(Af,{position:"top",iconConfig:{size:"xs",color:"primary"},text:"Enable to fill missing months or dates.",tooltipClass:"dbn-w-[300px]"})]})]})]})]})},oc=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)})},kc=t=>{const n=new Date(t);return n instanceof Date&&!Number.isNaN(n.getTime())?n:null},D_=({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:p,setMetricStore:b,onServerEvent:w,clientColumnType:T,datasourceId:H,appliedCardMetricFilters:S,language:N,translationDictionary:X,calendarType:W,setLoadedCardMetadata:f2,isFullScreen:Q2,setMetricMetadata:I2,viewMetricData:r2,generatingPdf:D2,dataMartTables:M2})=>{var U9,E4,f4,y4,I4,ne,H4,X4,L4,Re,W4,Ee,C1,z1,Y3,S3,K7,s3,a7,y6,F6,z8,K8,c9,R9,q9,M1,R3,J3,H7,m6,g8,n8,d8,N8,_8,f5,Y9,s5,Z5,Z4,le,Ve,pe,tt,mt,Zr,sn,xn,ci,ii,oi,Ti,Hi,gn,Yr,fi,Gi,Ae,Hr,Cn,di,Xn,Er,ln;const[m2,k2]=F0.useState(!1),[W2,c0]=F0.useState(!0),p0=$30(),[L0,b0]=F0.useState(""),[j2,t1]=F0.useState(""),[h0,O0]=F0.useState(!1),U0=F0.useRef(null),[X2,Q3]=F0.useState({limit:10,offset:0}),[x1,v3]=F0.useState(0),[W3,g7]=F0.useState(0),[I3,$3]=F0.useState((t==null?void 0:t.rlsConditions)||[]),[b7,I7]=F0.useState([]),[R6,h6]=F0.useState(!1),[w3,t0]=F0.useState(),[z3,X7]=F0.useState([]),[Y7,l6]=F0.useState(""),[c6,H6]=F0.useState([]),[I1,l3]=F0.useState({isOpen:!1,report:"",isLoading:!1}),[q3,T7]=F0.useState(!1),[h7,g3]=F0.useState([]),[p7,N7]=F0.useState([]),[D7,j6]=F0.useState({isEnableGroupBy:!1,isEnableCrossFilter:!1,drillType:""}),[q7,M6]=F0.useState([]),[C8,a9]=F0.useState(!1),[T8,y9]=F0.useState(!1),[O8,O9]=F0.useState([]),[L8,o5]=F0.useState({}),[W9,p5]=F0.useState(!1),[v5,p4]=F0.useState(null),[T1,s9]=F0.useState(t==null?void 0:t.chartOptions),[S9,g5]=F0.useState({data:[],error:"",isLoading:!1,currentValue:""}),n5=F0.useMemo(()=>{var $6,J6;return!!((J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)!=null&&J6.isPythonMode)},[(E4=(U9=t==null?void 0:t.datasetMetricSettings)==null?void 0:U9.newDatasetSettings)==null?void 0:E4.isPythonMode]),Y5=F0.useMemo(()=>{var $6,J6,n9,B8,L9;return((L9=(B8=(n9=(J6=($6=t==null?void 0:t.externalDashboardMetrics)==null?void 0:$6[0])==null?void 0:J6.externalDashboard)==null?void 0:n9.companyWorkspace)==null?void 0:B8.datamart)==null?void 0:L9.datamartRelationships)||[]},[t]),r5=F0.useMemo(()=>{const $6={};if(i!=null&&i.values)for(const J6 in i.values){const n9=`${J6}_variable`;$6[n9]=i.values[J6]}return $6},[i==null?void 0:i.values]),E3=F0.useMemo(()=>{var n9,B8,L9;const $6=(B8=(n9=t==null?void 0:t.datasetMetricSettings)==null?void 0:n9.newDatasetSettings)==null?void 0:B8.selectedMainTable,J6=M2==null?void 0:M2.find(w8=>w8.tableName===($6==null?void 0:$6.tableName));return((L9=J6==null?void 0:J6.customColumnFields)==null?void 0:L9.map(w8=>{var _9,l5,T5,d4,j5,z6;return{value:w8==null?void 0:w8.columnName,label:w8==null?void 0:w8.columnName,isCustomField:!0,column:{uniqueId:em(10),alias:w8==null?void 0:w8.columnName,configType:"DIMENSION",datatype:w8==null?void 0:w8.datatype,dropType:"DIMENSION",index:1e3,name:w8==null?void 0:w8.columnName,parentAlias:`${$I($6==null?void 0:$6.schemaName,((_9=t==null?void 0:t.companyIntegration)==null?void 0:_9.name)||"")}_${(l5=$6==null?void 0:$6.tableName)==null?void 0:l5.replaceAll(" ","_")}`,table:(d4=(T5=t==null?void 0:t.datasetMetricSettings)==null?void 0:T5.newDatasetSettings)==null?void 0:d4.selectedMainTable,type:"DEFAULT",draggableItemData:{column:{name:w8==null?void 0:w8.columnName,dataType:w8==null?void 0:w8.datatype,as:w8==null?void 0:w8.datatype},table:(z6=(j5=t==null?void 0:t.datasetMetricSettings)==null?void 0:j5.newDatasetSettings)==null?void 0:z6.selectedMainTable},label:"",sql:""}}}))||[]},[(y4=(f4=t==null?void 0:t.datasetMetricSettings)==null?void 0:f4.newDatasetSettings)==null?void 0:y4.selectedMainTable,(I4=t==null?void 0:t.companyIntegration)==null?void 0:I4.name,M2]),D8=F0.useMemo(()=>{var $6,J6,n9,B8,L9,w8,_9,l5,T5,d4,j5,z6,W8,d5;return{isAllClient:u,id:t==null?void 0:t.id,tenancyLevel:a,rlsConditions:[...O8||[],...($6=T1==null?void 0:T1.tableSettings)!=null&&$6.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?(J6=b7==null?void 0:b7.map(I5=>I5.condition))==null?void 0:J6.filter(I5=>Gx(I5)):[]],globalFilters:n5?void 0:{...n,filters:(n9=n==null?void 0:n.filters)==null?void 0:n9.filter(I5=>{var Qe;return Array.isArray(I5==null?void 0:I5.value)?(Qe=I5==null?void 0:I5.value)==null?void 0:Qe.length:I5})},filterValues:n5?void 0:r5,limit:(B8=T1==null?void 0:T1.tableSettings)!=null&&B8.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?Math.min(X2.limit,1e3):void 0,offset:(L9=T1==null?void 0:T1.tableSettings)!=null&&L9.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?X2.offset:void 0,disableStringify:!0,pivotHeaders:((w8=T1==null?void 0:T1.pivotTableSettings2)==null?void 0:w8.headers)||[],timeseriesSettings:n5?void 0:{format:((T5=(l5=(_9=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:_9.groupBySettings)==null?void 0:l5.value)==null?void 0:T5.toLowerCase())||"monthly",seriesField:(T1==null?void 0:T1.seriesField)||"",isFiscal:W==="ind"},chartSeriesField:(T1==null?void 0:T1.seriesField)!=="ungrouped"&&(T1!=null&&T1.seriesField)&&(T1!=null&&T1.isDynamicSeries)?T1==null?void 0:T1.seriesField:void 0,comparisonCount:W3,dynamicXAxis:{isEnable:!!((d4=T1==null?void 0:T1.dynamicXAxis)!=null&&d4.isEnabled||(j5=T1==null?void 0:T1.enduserMeasureAndDimensions)!=null&&j5.isEnabled)&&Bh.includes((T1==null?void 0:T1.chartType)||""),xaxis:(T1==null?void 0:T1.xAxis)||"",customField:(W8=(z6=T1==null?void 0:T1.dynamicXAxis)==null?void 0:z6.selectedOption)==null?void 0:W8.column},dbId:H,elementSettings:(d5=t==null?void 0:t.elementSettings)==null?void 0:d5.metricExpression,drillConfig:D7==null?void 0:D7.configV2,isEncrypted:!!(!A&&f)}},[T1,u,t,O8,n5,r5,p7,a,n,X2,W3,Bh,H,W,D7==null?void 0:D7.configV2,f,A,JSON.stringify(b7)]),{data:o7,isLoading:j7,error:p6,refetch:s6}=b70({data:D8,clientId:A?d||"":o,token:f,isFrontendApp:A,isFullScreen:Q2},{onSuccess:$6=>{var n9;const J6=cB2($6);f2&&((n9=J6==null?void 0:J6.error)==null?void 0:n9.code)!=="E1001"&&(f2==null||f2(B8=>{var L9;return[...(B8==null?void 0:B8.filter(w8=>(w8==null?void 0:w8.id)!==(D8==null?void 0:D8.id)))||[],{id:D8==null?void 0:D8.id,isDataFound:!!(J6!=null&&J6.length)&&((T1==null?void 0:T1.chartType)!==m0.singleValue||((L9=J6==null?void 0:J6[0])==null?void 0:L9[(T1==null?void 0:T1.singleValue)||""])!==null)}]}))}}),{mutate:u6}=J30(),{mutateAsync:v7}=Mu2();F0.useEffect(()=>{var J6;const $6=((J6=t==null?void 0:t.rlsConditions)==null?void 0:J6.map(n9=>{var T5,d4,j5,z6,W8,d5,I5,Qe,xe,ce,at,ye,F4,Ue,wt;let B8=n9;if(e){const te=dB2(B8,e);te&&(B8={...B8,filterType:"manual",value:te.value?B8.datatype==="string"&&((T5=B8==null?void 0:B8.filterVariant)==null?void 0:T5.value)===au?[te.value]:te.value:B8.value,options:B8.datatype==="date"?(d4=te.options)==null?void 0:d4.map(Le=>({...Le,startDate:kc(Le.fromDate)??Le.startDate,endDate:kc(Le.toDate)??Le.endDate,minDate:kc(Le.minDate)??void 0,maxDate:kc(Le.maxDate)??void 0,fromDate:kc(Le.fromDate)??void 0,toDate:kc(Le.toDate)??void 0})):te.options,variableOptions:B8.datatype==="date"?(j5=te.options)==null?void 0:j5.map(Le=>({range:Le.range,startDate:kc(Le.fromDate)??Le.startDate,endDate:kc(Le.toDate)??Le.endDate,minDate:kc(Le.minDate)??void 0,maxDate:kc(Le.maxDate)??void 0,fromDate:kc(Le.fromDate)??void 0,toDate:kc(Le.toDate)??void 0,value:Le.name,label:Le.name})):(z6=te.options)==null?void 0:z6.map(Le=>({value:Le,label:Le})),selectedVariableValue:te.value?B8.datatype==="string"?{value:te.value,label:te.value}:{startDate:kc((d5=(W8=te.options)==null?void 0:W8.find(Le=>Le.name===te.value))==null?void 0:d5.fromDate),endDate:kc((Qe=(I5=te.options)==null?void 0:I5.find(Le=>Le.name===te.value))==null?void 0:Qe.toDate),value:te.value,label:te.value}:B8.selectedVariableValue})}const w8=[...((at=(ce=(xe=r2==null?void 0:r2.metricViewFilters)==null?void 0:xe.find(te=>te.id===(t==null?void 0:t.id)))==null?void 0:ce.filters)==null?void 0:at.filter(te=>!(S!=null&&S.find(Le=>(te==null?void 0:te.name)===(Le==null?void 0:Le.name)))))||[],...S||[]].find(te=>B8.name===te.name);if(w8!=null&&w8.value&&(B8={...B8,...w8!=null&&w8.value?{value:w8==null?void 0:w8.value}:{},...w8!=null&&w8.selectedDropdownValue?{selectedDropdownValue:w8==null?void 0:w8.selectedDropdownValue}:{},...w8!=null&&w8.selectedVariableValue?{selectedVariableValue:w8==null?void 0:w8.selectedVariableValue}:{}}),(B8==null?void 0:B8.datatype)==="date"&&((ye=B8==null?void 0:B8.options)==null?void 0:ye.find(te=>te.range==="Custom Date"))&&(B8==null?void 0:B8.isEnableDynamicDate)&&((F4=B8==null?void 0:B8.dynamicDate)==null?void 0:F4.value)){const te=Oa2(((Ue=ob==null?void 0:ob.find(Kn=>{var Ce;return Kn.value===((Ce=B8==null?void 0:B8.dynamicDate)==null?void 0:Ce.value)}))==null?void 0:Ue.count)||0),Le=Uc(te),ai=Uc(te);B8={...B8,options:(wt=B8==null?void 0:B8.options)==null?void 0:wt.map(Kn=>Kn.range==="Custom Date"?{...Kn,startDate:te,endDate:te,timeGrainValue:`${Le} - ${ai}`}:Kn)}}return a==="DATABASE"?{...B8,tableName:`${o}.${n9.tableName.split(".").slice(1).join(".")}`}:B8}))||[];$3($6||[])},[t==null?void 0:t.rlsConditions,e,a,o,S,r2]),F0.useEffect(()=>{let $6;return j7?c0(!0):$6=setTimeout(()=>{c0(!1)},300),()=>clearTimeout($6)},[j7]),F0.useEffect(()=>{t!=null&&t.id&&I2&&!n5&&(t!=null&&t.isMetric)&&(I2==null||I2($6=>{var J6,n9,B8,L9,w8,_9,l5,T5,d4,j5,z6;return[...($6==null?void 0:$6.filter(W8=>W8.id!==(t==null?void 0:t.id)))||[],{filters:[...O8||[],...(J6=T1==null?void 0:T1.tableSettings)!=null&&J6.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?(n9=b7==null?void 0:b7.map(W8=>W8.condition))==null?void 0:n9.filter(W8=>Gx(W8)):[]],xAxisSettings:{isEnable:!!((B8=T1==null?void 0:T1.dynamicXAxis)!=null&&B8.isEnabled||(L9=T1==null?void 0:T1.enduserMeasureAndDimensions)!=null&&L9.isEnabled)&&Bh.includes((T1==null?void 0:T1.chartType)||""),xaxis:(T1==null?void 0:T1.xAxis)||""},yAxisSettings:{isEnable:!!(!((w8=T1==null?void 0:T1.dynamicYAxis)!=null&&w8.isEnabled)||!((_9=T1==null?void 0:T1.dynamicYAxis)!=null&&_9.selectedOption)||Array.isArray((l5=T1==null?void 0:T1.dynamicYAxis)==null?void 0:l5.selectedOption)),yAxis:((T5=T1==null?void 0:T1.dynamicYAxis)==null?void 0:T5.selectedOption)||""},id:t==null?void 0:t.id,metricRequestData:{isAllClient:u,timeseriesSettings:n5?void 0:{format:((z6=(j5=(d4=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:d4.groupBySettings)==null?void 0:j5.value)==null?void 0:z6.toLowerCase())||"monthly",seriesField:(T1==null?void 0:T1.seriesField)||"",isFiscal:W==="ind"}}}]}))},[t==null?void 0:t.id,t==null?void 0:t.isMetric,O8,T1==null?void 0:T1.timeSeriesSettings,T1==null?void 0:T1.seriesField,n5,W,u,b7,(ne=T1==null?void 0:T1.tableSettings)==null?void 0:ne.isServerSidePagination,T1==null?void 0:T1.chartType,T1==null?void 0:T1.dynamicYAxis,T1==null?void 0:T1.dynamicXAxis]),F0.useEffect(()=>{var $6,J6,n9,B8,L9,w8;if(($6=t==null?void 0:t.drillDownSettings)!=null&&$6.isEnableGroupBy){const _9=t==null?void 0:t.datasetMetricSettings;!((J6=t==null?void 0:t.drillDownSettings)!=null&&J6.configV2)&&!(D7!=null&&D7.configV2)&&((B8=(n9=_9==null?void 0:_9.newDatasetSettings)==null?void 0:n9.selectedMetrics)!=null&&B8.length)&&((w8=(L9=_9==null?void 0:_9.newDatasetSettings)==null?void 0:L9.selectedDims)!=null&&w8.length)?j6(l5=>{var T5,d4,j5;return{...(t==null?void 0:t.drillDownSettings)||{},configV2:{isEnable:!!((T5=t==null?void 0:t.drillDownSettings)!=null&&T5.isEnableGroupBy),levels:(j5=(d4=_9==null?void 0:_9.newDatasetSettings)==null?void 0:d4.selectedDims)==null?void 0:j5.map((z6,W8)=>{var I5,Qe,xe,ce;const d5=(xe=(Qe=(I5=t==null?void 0:t.drillDownSettings)==null?void 0:I5.drilldownChartSettings)==null?void 0:Qe.find(at=>(at==null?void 0:at.name)===(z6==null?void 0:z6.alias)))==null?void 0:xe.chartSettings;return{name:`Drill Level ${W8+1}`,chartSettings:d5||T1,index:em(4),isEnable:W8===0,dimensions:[z6],measures:((ce=_9==null?void 0:_9.newDatasetSettings)==null?void 0:ce.selectedMetrics)||[]}})}}}):D7!=null&&D7.isEnableGroupBy||j6(t==null?void 0:t.drillDownSettings)}},[(H4=t==null?void 0:t.drillDownSettings)==null?void 0:H4.isEnableGroupBy,(X4=t==null?void 0:t.drillDownSettings)==null?void 0:X4.configV2,t==null?void 0:t.datasetMetricSettings,T1]);const{mutateAsync:G3}=B_(),F3=F0.useMemo(()=>{var n9,B8,L9,w8,_9,l5,T5,d4,j5,z6,W8,d5,I5,Qe,xe,ce;const $6=((n9=t==null?void 0:t.datasetMetricSettings)==null?void 0:n9.metricVariables)||[];if(!$6||!Array.isArray($6)||!($6!=null&&$6.length))return[];const J6=[];for(let at=0;at<($6==null?void 0:$6.length);at++){const ye=$6[at],F4=ye.type.value==="custom"&&ye.customQuery&&ye.customColumnName,Ue=F4?{query:db({query:(ye==null?void 0:ye.customQuery)||"",tenancyLevel:a,clientId:o,isAllClient:u,clientColumnType:T||"STRING",dbName:(B8=t==null?void 0:t.companyIntegration)==null?void 0:B8.name,rlsConditions:O8==null?void 0:O8.filter(Ce=>Ce.isVariableFilter),globalFilters:{...n,filters:(L9=n==null?void 0:n.filters)==null?void 0:L9.filter(Ce=>{var Kt;return(Ce==null?void 0:Ce.isVariableFilter)&&!!(Array.isArray(Ce==null?void 0:Ce.value)?(Kt=Ce==null?void 0:Ce.value)!=null&&Kt.length:Ce)})}}),alias:vP}:void 0,wt=(w8=ye.dependOnOptions)!=null&&w8.length?O8==null?void 0:O8.filter(Ce=>ye.dependOnOptions.some(Kt=>{var pr;return Kt.type==="metric"&&((pr=Kt.filter)==null?void 0:pr.value)===Ce.name&&Kt.column})):[],te=(_9=ye.dependOnOptions)!=null&&_9.length?(l5=n==null?void 0:n.filters)==null?void 0:l5.filter(Ce=>{var Kt;return Array.isArray(Ce==null?void 0:Ce.value)?(Kt=Ce==null?void 0:Ce.value)==null?void 0:Kt.length:Ce&&ye.dependOnOptions.some(pr=>{var Cr;return pr.type==="dashboard"&&((Cr=pr.filter)==null?void 0:Cr.value)===Ce.label&&pr.column})}):[],Le=wt==null?void 0:wt.map(Ce=>{var Kt;return{columnName:((Kt=ye.dependOnOptions.find(pr=>{var Cr;return Ce.name===((Cr=pr.filter)==null?void 0:Cr.value)}))==null?void 0:Kt.column)||"",value:Ce.value,as:"string"}}),ai=te==null?void 0:te.map(Ce=>{var Kt;return{columnName:((Kt=ye.dependOnOptions.find(pr=>{var Cr;return Ce.label===((Cr=pr.filter)==null?void 0:Cr.value)}))==null?void 0:Kt.column)||"",value:fb(Ce==null?void 0:Ce.value),as:"string"}});ye.isClientScoped&&o&&T&&!u&&a==="TABLE"&&((d4=(T5=ye.clientColumn)==null?void 0:T5.name)!=null&&d4.value)&&((z6=(j5=ye.clientColumn)==null?void 0:j5.datatype)!=null&&z6.value)&&Le.push({columnName:(d5=(W8=ye.clientColumn)==null?void 0:W8.name)==null?void 0:d5.value,value:o,as:(Qe=(I5=ye.clientColumn)==null?void 0:I5.datatype)==null?void 0:Qe.value});const Kn=[...Le,...ai];J6.push({object:{wId:g,tableName:F4?"":(xe=ye==null?void 0:ye.table)==null?void 0:xe.value,columnName:F4?(ye==null?void 0:ye.customColumnName)||"":((ce=ye==null?void 0:ye.column)==null?void 0:ce.value)||"",filter:Kn,customTable:Ue,limit:"1",datasourceId:H,databaseName:a==="MULTI_DATABASE"&&o||""},element:ye})}return J6},[(L4=t==null?void 0:t.datasetMetricSettings)==null?void 0:L4.metricVariables,JSON.stringify(n==null?void 0:n.filters),O8,T,g,a,o,u,H]),x7=async $6=>{var n9,B8,L9,w8,_9;k2(!0);const J6={};$6==null||$6.forEach(l5=>{var T5,d4;J6[(T5=l5==null?void 0:l5.element)==null?void 0:T5.name]=((d4=l5==null?void 0:l5.element)==null?void 0:d4.defaultValue)||""}),o5(J6);for(let l5=0;l5<($6==null?void 0:$6.length);l5++){const T5=$6[l5];if(J6[T5.element.name]=T5.element.defaultValue||"",k2(!0),T5.object.wId&&(!((B8=(n9=T5==null?void 0:T5.object)==null?void 0:n9.customTable)!=null&&B8.query)||!((_9=(w8=(L9=T5==null?void 0:T5.object)==null?void 0:L9.customTable)==null?void 0:w8.query)!=null&&_9.includes("{{")))){const d4=await G3(T5.object);d4!=null&&d4.data&&Array.isArray(d4.data)&&o5(j5=>{var z6,W8;return{...j5,[T5.element.name]:((W8=(z6=d4==null?void 0:d4.data)==null?void 0:z6[0])==null?void 0:W8.value)||T5.element.defaultValue||""}})}}setTimeout(()=>{k2(!1)},200)};F0.useEffect(()=>{F3!=null&&F3.length&&x7(F3)},[JSON.stringify(F3)]);const y7=F0.useMemo(()=>{var $6,J6,n9,B8;return(B8=(n9=(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)==null?void 0:J6.selectedDims)==null?void 0:n9[0])==null?void 0:B8.name},[t]);F0.useMemo(()=>{var $6,J6,n9,B8;return xa2(((B8=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.selectedDimensions)==null?void 0:B8[p7.length<((n9=(J6=t==null?void 0:t.datasetMetricSettings)==null?void 0:J6.selectedDimensions)==null?void 0:n9.length)?p7.length:0])||"")},[t==null?void 0:t.datasetMetricSettings,p7]),F0.useEffect(()=>{var n9,B8,L9;const J6=((n9=t==null?void 0:t.drillDownSettings)==null?void 0:n9.isEnableGroupBy)?I3||[]:[...I3!=null&&I3.length?I3:[],...l||[]];(B8=J6==null?void 0:J6.filter(w8=>w8.isAddOnMetrics))!=null&&B8.length?O9((L9=J6.filter(w8=>w8.isAddOnMetrics))==null?void 0:L9.map(w8=>{var _9,l5,T5,d4,j5;return s?{...w8,dimensionColumn:(T1==null?void 0:T1.xAxis)||"",measureColumn:((_9=T1==null?void 0:T1.yAxisList)==null?void 0:_9[0])||"",options:w8.datatype!==Ku?[]:w8.options,variableOptions:w8.datatype!==Ku?[]:w8.variableOptions}:{...w8,dimensionColumn:(T1==null?void 0:T1.xAxis)||"",measureColumn:((l5=T1==null?void 0:T1.yAxisList)==null?void 0:l5[0])||"",value:w8.isAppFilter?w8.datatype==="date"?(T5=w8==null?void 0:w8.options)==null?void 0:T5.find(z6=>{var W8;return z6.name===((W8=r==null?void 0:r.values)==null?void 0:W8[w8.name])||w8.value}):((d4=r==null?void 0:r.values)==null?void 0:d4[w8.name])||w8.value:w8.value,options:w8.datatype!==Ku?[]:(j5=w8==null?void 0:w8.options)==null?void 0:j5.map(z6=>W==="ind"&&w8.datatype===Ku?{...z6,isFiscal:!0}:z6),variableOptions:w8.datatype!==Ku?[]:w8.variableOptions}}).filter(w8=>Gx(w8))):O9([])},[I3,r,l,(Re=t==null?void 0:t.drillDownSettings)==null?void 0:Re.isEnableGroupBy,a,s,o,W]);const Q6=F0.useMemo(()=>{var $6,J6,n9;return(T1==null?void 0:T1.chartType)===m0.singleValue&&!!(($6=T1==null?void 0:T1.customSettings)!=null&&$6.comparisonValueShow)&&!!((J6=T1==null?void 0:T1.customSettings)!=null&&J6.comparisonTimeGrain)&&!!((n9=T1==null?void 0:T1.customSettings)!=null&&n9.comparisonTimePeriod)&&!!(T1!=null&&T1.singleValue)},[T1]);F0.useEffect(()=>{var L9,w8,_9,l5,T5;const $6=o7;let J6=$6!=null&&$6.data&&typeof $6.data=="string"?JSON.parse($6.data):$6!=null&&$6.data&&Array.isArray($6==null?void 0:$6.data)?$6==null?void 0:$6.data:[];g5({data:[],error:"",isLoading:!1,currentValue:""}),(T1==null?void 0:T1.chartType)===m0.table&&v3(($6==null?void 0:$6.totalRecords)||0),J6=Va2(J6||[],((w8=(L9=t==null?void 0:t.datasetMetricSettings)==null?void 0:L9.newDatasetSettings)==null?void 0:w8.selectedDims)||[],((l5=(_9=t==null?void 0:t.datasetMetricSettings)==null?void 0:_9.newDatasetSettings)==null?void 0:l5.selectedMetrics)||[]);const n9=(()=>{var d4,j5,z6,W8;if(!Array.isArray(J6))return[];if(((j5=(d4=t==null?void 0:t.companyIntegration)==null?void 0:d4.name)==null?void 0:j5.toLowerCase())===Ag&&!n5){const d5=(z6=t==null?void 0:t.datasetMetricSettings)==null?void 0:z6.newDatasetSettings,I5=(d5==null?void 0:d5.selectedMetrics)||[],Qe=((W8=d5==null?void 0:d5.selectedDims)==null?void 0:W8.filter(ce=>{var at,ye;return!((ye=(at=ce==null?void 0:ce.alias)==null?void 0:at.toLowerCase())!=null&&ye.match(/monthly|quarterly|weekly|yearly|daily/))}))||[],xe=[...Qe==null?void 0:Qe.map(ce=>ce.alias),...I5==null?void 0:I5.map(ce=>ce.alias)];return Sa2(xe,J6)}return J6})();if(X7(n9),(T5=t==null?void 0:t.datasetMetricSettings)!=null&&T5.isUseRawSQL){const d4=Object.keys((n9==null?void 0:n9[0])||{})||[];s9(j5=>({...j5,yAxisList:d4||(j5==null?void 0:j5.yAxisList)||[]}))}const B8=$6==null?void 0:$6.metaData;M6(_Y(B8==null?void 0:B8.groupbyColumnList)),l3(d4=>({...d4,report:"",isLoading:d4==null?void 0:d4.isLoading,isOpen:d4==null?void 0:d4.isOpen}))},[o7,t==null?void 0:t.datasetMetricSettings,n5]),F0.useEffect(()=>{var $6,J6;(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.createdSorts)!=null&&J6.length?p5(!0):p5(!1)},[(Ee=(W4=t==null?void 0:t.datasetMetricSettings)==null?void 0:W4.createdSorts)==null?void 0:Ee.length]),F0.useEffect(()=>{var $6,J6;(T1==null?void 0:T1.chartType)===m0.timeSeries&&((J6=($6=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:$6.groupBySettings)!=null&&J6.value)&&!n5&&s9(n9=>{var B8,L9,w8;return{...n9,xAxis:`${(w8=(L9=(B8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:B8.groupBySettings)==null?void 0:L9.value)==null?void 0:w8.toLowerCase()} of ${y7}`}})},[z3,T1==null?void 0:T1.chartType,T1==null?void 0:T1.timeSeriesSettings,n5]),F0.useEffect(()=>{var $6;if(T1!=null&&T1.isEnableComparisonFilter&&[m0.line].includes(T1==null?void 0:T1.chartType)){const J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings,n9=(J6==null?void 0:J6.selectedMetrics)||[],B8=Object==null?void 0:Object.keys((z3==null?void 0:z3[0])||{});s9(L9=>({...L9,yAxisList:[...B8.filter(w8=>n9==null?void 0:n9.some(_9=>w8.startsWith(_9.alias)))]}))}},[z3,T1==null?void 0:T1.isEnableComparisonFilter,W3,T1==null?void 0:T1.chartType]);const T6=F0.useCallback(($6,J6,n9,B8,L9,w8)=>{w==null||w(N30,t==null?void 0:t.id),$3(B8?_9=>_9==null?void 0:_9.map(l5=>{var T5,d4;return l5.name===$6?{...l5,value:J6,options:(T5=l5.options)==null?void 0:T5.map(j5=>J6===j5.name?{...j5,...B8,timeGrainValue:w8}:j5),variableOptions:(d4=l5.variableOptions)==null?void 0:d4.map(j5=>j5.value===J6?{...j5,...B8,timeGrainValue:w8}:j5),selectedVariableValue:{value:J6,label:J6,endDate:B8.endDate,startDate:B8.startDate,timeGrainValue:w8}}:l5}):L9?_9=>_9==null?void 0:_9.map(l5=>l5.name===$6?{...l5,value:L9!=null&&L9.length?L9==null?void 0:L9.map(T5=>T5.value):void 0,selectedDropdownValue:L9!=null&&L9.length?L9:void 0}:l5):_9=>_9==null?void 0:_9.map(l5=>l5.name===$6?{...l5,value:J6,selectedVariableValue:{value:J6,label:J6},selectedDropdownValue:{value:J6,label:n9||J6}}:l5))},[]),N6=F0.useCallback($6=>{var J6,n9;$6!=null&&$6.event&&((n9=(J6=$6==null?void 0:$6.event)==null?void 0:J6.event)==null||n9.preventDefault()),t0($6)},[I3]),{getUnderlyingData:M3}=m70({clientName:o,dbName:(C1=t==null?void 0:t.companyIntegration)==null?void 0:C1.name,tenancyType:a,values:r5,companyId:t==null?void 0:t.companyId,query:Fd(t==null?void 0:t.query,t==null?void 0:t.companyId),workspaceId:g,metricId:t==null?void 0:t.id,rlsConditions:O8,globalFilters:n,isAllClient:!!u,dataMartRelationships:Y5,customSql:(Y3=(z1=t==null?void 0:t.clickActions)==null?void 0:z1.underlyingData)==null?void 0:Y3.sql,isEnableCustomSQL:(T1==null?void 0:T1.chartType)===m0.singleValue&&((K7=(S3=t==null?void 0:t.clickActions)==null?void 0:S3.underlyingData)==null?void 0:K7.isEnable)&&((a7=(s3=t==null?void 0:t.clickActions)==null?void 0:s3.underlyingData)==null?void 0:a7.sql),datasourceId:H}),D9=F0.useMemo(()=>Array.isArray(z3)&&z3.length&&(w3!=null&&w3.name)?z3==null?void 0:z3.map($6=>{const J6=Object.entries($6).find(([,n9])=>(typeof n9=="number"&&typeof(w3==null?void 0:w3.name)=="string"?n9==null?void 0:n9.toString():n9)===w3.name);return J6==null?void 0:J6[0]}).filter($6=>$6)[0]:"",[z3,w3==null?void 0:w3.name]),h8=async($6,J6,n9,B8)=>{var Ue,wt,te,Le,ai,Kn,Ce,Kt,pr,Cr,hn,En,Qr,Rn,ho,Jn,Zn,Yi,Wi,Vi,So,Dr,xi,Eo,na,ga,Go;const L9=t==null?void 0:t.datasetMetricSettings;if(!(D7!=null&&D7.configV2)||!((Ue=L9==null?void 0:L9.newDatasetSettings)!=null&&Ue.configuration)||!((wt=t==null?void 0:t.companyIntegration)!=null&&wt.name)||!$6)return;let w8=$6;const _9=(w8==null?void 0:w8.levels)||[],l5=_9==null?void 0:_9.find(ve=>n9?ve.index===n9:ve==null?void 0:ve.isEnable),T5=_9==null?void 0:_9.findIndex(ve=>n9?ve.index===n9:ve==null?void 0:ve.isEnable),d4=T5>=0&&T5<(_9==null?void 0:_9.length)-1,j5=d4?_9==null?void 0:_9[T5+1]:_9==null?void 0:_9[0],z6=J6==null?void 0:J6.name,W8=(J6==null?void 0:J6.rowFilters)||[],d5=(Le=(te=l5==null?void 0:l5.dimensions)==null?void 0:te[0])==null?void 0:Le.alias;!l5||B8?w8={...w8||{},levels:((ai=w8==null?void 0:w8.levels)==null?void 0:ai.map((ve,Mr)=>Mr==0?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:n9&&l5?w8={...w8||{},levels:((Kn=w8==null?void 0:w8.levels)==null?void 0:Kn.map((ve,Mr)=>ve.index===(l5==null?void 0:l5.index)?{...ve,filters:[...(l5==null?void 0:l5.filters)||[]],isEnable:!0}:{...ve,filters:Mr>T5?[]:ve==null?void 0:ve.filters,isEnable:!1}))||[]}:(z6&&d5||W8!=null&&W8.length)&&l5?w8={...w8||{},levels:((Ce=w8==null?void 0:w8.levels)==null?void 0:Ce.map(ve=>ve.index===(j5==null?void 0:j5.index)?{...ve,filters:d4?[...(l5==null?void 0:l5.filters)||[],...W8!=null&&W8.length?W8:[{columnName:d5,value:z6}]]:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:w8={...w8||{},levels:((Kt=w8==null?void 0:w8.levels)==null?void 0:Kt.map(ve=>ve.index===(l5==null?void 0:l5.index)?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]},w8={...w8||{},levels:((pr=w8==null?void 0:w8.levels)==null?void 0:pr.map(ve=>{var Mr,ki;return{...ve,dimensions:((Mr=ve==null?void 0:ve.dimensions)==null?void 0:Mr.filter(er=>{var tr,un;return(un=(tr=L9==null?void 0:L9.newDatasetSettings)==null?void 0:tr.selectedDims)==null?void 0:un.some(e9=>e9.alias===(er==null?void 0:er.alias))}))||[],measures:((ki=ve==null?void 0:ve.measures)==null?void 0:ki.filter(er=>{var tr,un;return(un=(tr=L9==null?void 0:L9.newDatasetSettings)==null?void 0:tr.selectedMetrics)==null?void 0:un.some(e9=>e9.alias===(er==null?void 0:er.alias))}))||[]}}))||[]};const I5=(Cr=w8==null?void 0:w8.levels)==null?void 0:Cr.find(ve=>ve==null?void 0:ve.isEnable),Qe=!!((Qr=(En=w8==null?void 0:w8.levels)==null?void 0:En[((hn=w8==null?void 0:w8.levels)==null?void 0:hn.length)-1])!=null&&Qr.isEnable);(ho=(Rn=w8==null?void 0:w8.levels)==null?void 0:Rn[0])==null||ho.isEnable;const xe=(I5==null?void 0:I5.chartSettings)||T1,ce=(xe==null?void 0:xe.chartType)===m0.table,at=[...((Jn=I5==null?void 0:I5.dimensions)==null?void 0:Jn.map(ve=>ve.alias))||[],...((Zn=I5==null?void 0:I5.measures)==null?void 0:Zn.map(ve=>ve.alias))||[]],ye={...xe,xAxis:((Wi=(Yi=I5==null?void 0:I5.dimensions)==null?void 0:Yi[0])==null?void 0:Wi.alias)||"",yAxisList:Qe&&!(xe!=null&&xe.chartType)||ce?at:((Vi=I5==null?void 0:I5.measures)==null?void 0:Vi.map(ve=>ve.alias))||[],chartType:Qe&&!(xe!=null&&xe.chartType)?m0.table:xe==null?void 0:xe.chartType},F4=`${(xi=(Dr=(So=I5==null?void 0:I5.dimensions)==null?void 0:So[0])==null?void 0:Dr.table)==null?void 0:xi.schemaName}.${(ga=(na=(Eo=I5==null?void 0:I5.dimensions)==null?void 0:Eo[0])==null?void 0:na.table)==null?void 0:ga.tableName}`;if(j6(ve=>{var Mr;return{...ve,configV2:{...w8||{},levels:((Mr=w8==null?void 0:w8.levels)==null?void 0:Mr.map(ki=>ki.index===(I5==null?void 0:I5.index)?{...ki,chartSettings:ye}:ki))||[]}}}),s9(ve=>ye),(Go=t==null?void 0:t.drillDownSettings)!=null&&Go.isEnableCrossFilter){const ve=(()=>{var Mr;if(B8||n9)return[];if((z6&&d5||W8!=null&&W8.length)&&l5){if(W8!=null&&W8.length){const ki=(Mr=W8==null?void 0:W8.map(er=>{var e9,z5,T4,At;const tr=(z5=(e9=L9==null?void 0:L9.newDatasetSettings)==null?void 0:e9.selectedDims)==null?void 0:z5.find(Ht=>(Ht==null?void 0:Ht.alias)===(er==null?void 0:er.columnName)),un=`${(T4=tr==null?void 0:tr.table)==null?void 0:T4.schemaName}.${(At=tr==null?void 0:tr.table)==null?void 0:At.tableName}`;if(tr)return{columnName:er==null?void 0:er.columnName,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[er==null?void 0:er.value],tableName:a==="DATABASE"?`${o}.${un==null?void 0:un.split(".").slice(1).join(".")}`:un,value:[er==null?void 0:er.value]}}))==null?void 0:Mr.filter(er=>er);return[...l||[],...ki]}if(d5&&z6)return[...l||[],{columnName:d5,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[z6],tableName:a==="DATABASE"?`${o}.${F4==null?void 0:F4.split(".").slice(1).join(".")}`:F4,value:[z6]}]}return[]})();C==null||C(ve)}},t9=async($6,J6)=>{await h8(D7==null?void 0:D7.configV2,$6)},o8=({filters:$6,nextLevel:J6,currentValue:n9})=>{var at,ye;const B8=(at=t==null?void 0:t.datasetMetricSettings)==null?void 0:at.newDatasetSettings,L9=B8==null?void 0:B8.configuration,w8=(B8==null?void 0:B8.selectedDims)||[],_9=(B8==null?void 0:B8.selectedMetrics)||[],l5=((ye=t==null?void 0:t.datasetMetricSettings)==null?void 0:ye.createdSorts)||[],{headerColumns:T5,nonHeaderColumns:d4}=w8.reduce((F4,Ue)=>{var wt,te;return(te=(wt=T1==null?void 0:T1.pivotTableSettings2)==null?void 0:wt.headers)!=null&&te.includes(Ue.alias)?F4.headerColumns.push(Ue):F4.nonHeaderColumns.push(Ue),F4},{headerColumns:[],nonHeaderColumns:[]}),j5=$6==null?void 0:$6.map(F4=>`${F4.columnName};;${F4.value}`).join(";;");g5(F4=>({...F4,data:F4.data.filter(Ue=>Ue.key!==j5),error:"",isLoading:!0,currentValue:n9}));const z6=d4.slice(0,J6),W8=$6==null?void 0:$6.map(F4=>{const Ue=w8.find(wt=>wt.alias===F4.columnName);if(Ue)return{alias:Ue.alias||"",columnName:Ue.name,dataType:Ue.datatype,method:"=",parentAlias:Ue.parentAlias,type:"dimension",value:F4.value,relationOperator:"AND"}}).filter(F4=>F4),d5=[...z6,..._9,...T5],{aggregates:I5,dimensions:Qe}=wu(d5),xe=FJ2(l5),ce={...L9,dimensions:Qe,aggregates:I5,filters:[...L9.filters,...W8],orders:(xe==null?void 0:xe.filter(F4=>(F4==null?void 0:F4.type)==="selected_column"?d5==null?void 0:d5.some(Ue=>(Ue==null?void 0:Ue.alias)===(F4==null?void 0:F4.name)):!0))||[],isApplyGlobalFilter:!0,isApplyMetricFilter:!0,globalFilters:n,rlsConditions:O8};u6({data:{configuration:ce,id:g,datasourceId:H,dashboardId:"",isCreateMetric:!0},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(F4){const Ue=F4==null?void 0:F4.error,wt=F4==null?void 0:F4.data;Ue!=null&&Ue.message?g5(te=>({...te,error:Ue==null?void 0:Ue.message,isLoading:!1,currentValue:""})):(g5(te=>({data:[...te.data,{key:j5,data:Array.isArray(wt)?wt:[]}],error:"",isLoading:!1,currentValue:""})),s9(te=>{var Le,ai;return{...te,pivotTableSettings2:{...T1==null?void 0:T1.pivotTableSettings2,dimensions:UB(z6,((Le=t==null?void 0:t.companyIntegration)==null?void 0:Le.name)||""),headers:UB(T5,((ai=t==null?void 0:t.companyIntegration)==null?void 0:ai.name)||"")}}}))}})},r9=F0.useCallback(async($6,J6)=>{await h8(D7==null?void 0:D7.configV2,void 0,$6,J6)},[D7==null?void 0:D7.configV2]),y8=F0.useCallback($6=>{var J6;if($6)$3(n9=>[...n9==null?void 0:n9.filter(B8=>B8.group!==`${W3}`)]),g7(n9=>n9-1);else{const n9=(J6=I3.filter(B8=>!(B8!=null&&B8.group)))==null?void 0:J6.map(B8=>{var L9,w8,_9,l5;return{...B8,name:`${B8==null?void 0:B8.name}_${W3+1}`,group:`${W3+1}`,dependOn:B8.dependOn?{value:`${(L9=B8.dependOn)==null?void 0:L9.value}_${W3+1}`,label:`${(w8=B8.dependOn)==null?void 0:w8.label}_${W3+1}`,customColumnName:(_9=B8.dependOn)==null?void 0:_9.customColumnName}:void 0,dependOns:((l5=B8==null?void 0:B8.dependOns)==null?void 0:l5.map(T5=>({value:`${T5==null?void 0:T5.value}_${W3+1}`,label:`${T5==null?void 0:T5.label}_${W3+1}`,customColumnName:T5==null?void 0:T5.customColumnName})))||[]}});n9.length&&($3(B8=>[...B8,...n9]),g7(B8=>B8+1))}},[I3]),k9=F0.useCallback(async()=>{I1.report?l3($6=>({...$6,isOpen:!0})):(l3({report:"",isLoading:!0,isOpen:!0}),await v7({data:{data:z3,wId:g},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess($6){const J6=$6==null?void 0:$6.content;l3(n9=>({...n9,report:J6||"",isLoading:!1}))},onError(){l3($6=>({...$6,report:"",isLoading:!1}))}}))},[z3,o,A,f,d,o,I1]),w5=F0.useMemo(()=>{var T5,d4,j5,z6,W8,d5;const $6=(T5=t==null?void 0:t.datasetMetricSettings)==null?void 0:T5.newDatasetSettings,J6=$6==null?void 0:$6.configuration,n9=Yx(z3||[]);let B8=n9;const L9=((d4=$6==null?void 0:$6.selectedDims)==null?void 0:d4.some(I5=>{var Qe,xe,ce;return ul.includes(((xe=(Qe=I5==null?void 0:I5.cast)==null?void 0:Qe.value)==null?void 0:xe.toLowerCase())||((ce=I5==null?void 0:I5.datatype)==null?void 0:ce.toLowerCase())||"")}))||VJ2((z3==null?void 0:z3[0])||""),w8=((j5=$6==null?void 0:$6.selectedDims)==null?void 0:j5.length)>1&&((z6=$6==null?void 0:$6.selectedMetrics)==null?void 0:z6.length)>0,_9=[m0.pivot,m0.pivotV2,m0.pivotV3,m0.timeSeries,m0.treeMap,m0.indianMap,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap],l5=!!((W8=J6==null?void 0:J6.aggregates)!=null&&W8.length)&&!!((d5=J6==null?void 0:J6.dimensions)!=null&&d5.length);return l5&&L9&&(B8=[...n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5))),..._9]),l5&&!L9&&(B8=[...n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5))),..._9==null?void 0:_9.filter(I5=>I5!==m0.timeSeries)]),!l5&&L9&&(B8=[...n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5))),m0.timeSeries]),!l5&&!L9&&(B8=n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5)))),D7!=null&&D7.isEnableGroupBy&&(D7!=null&&D7.configV2)&&(B8=B8==null?void 0:B8.filter(I5=>ib==null?void 0:ib.includes(I5))),w8||(B8=B8==null?void 0:B8.filter(I5=>I5!==m0.bubbleV2)),B8},[z3,T1==null?void 0:T1.xAxis,D7==null?void 0:D7.isEnableGroupBy,D7==null?void 0:D7.configV2,(z8=(F6=(y6=t==null?void 0:t.datasetMetricSettings)==null?void 0:y6.newDatasetSettings)==null?void 0:F6.configuration)==null?void 0:z8.aggregates,(R9=(c9=(K8=t==null?void 0:t.datasetMetricSettings)==null?void 0:K8.newDatasetSettings)==null?void 0:c9.configuration)==null?void 0:R9.dimensions]),o9=$6=>{var l5,T5,d4;const J6=(l5=t==null?void 0:t.datasetMetricSettings)==null?void 0:l5.newDatasetSettings,n9=J6==null?void 0:J6.configuration,B8=(J6==null?void 0:J6.selectedDims)||[],L9=(J6==null?void 0:J6.selectedMetrics)||[],w8=(T5=t==null?void 0:t.companyIntegration)==null?void 0:T5.name,_9=(d4=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:d4.isEnabled;kJ2({chartAggregateColumns:XY(UB((L9==null?void 0:L9.filter(j5=>{var z6,W8;return j5.configType==="AGGREGATE"&&_9?(W8=(z6=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:z6.measures)==null?void 0:W8.some(d5=>d5.value===j5.alias):!0}))||[],w8),z3||[]),chartDimensions:XY(UB((B8==null?void 0:B8.filter(j5=>{var z6,W8;return _9?(W8=(z6=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:z6.dimensions)==null?void 0:W8.some(d5=>d5.value===j5.alias):!0}))||[],w8),z3||[]),chartMetrics:XY(UB((L9==null?void 0:L9.filter(j5=>{var z6,W8;return _9?(W8=(z6=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:z6.measures)==null?void 0:W8.some(d5=>d5.value===j5.alias):!0}))||[],w8),z3||[]),chartSettings:T1,chartTimeColumns:UB(B8==null?void 0:B8.filter(j5=>{var z6;return ul.includes((z6=j5.datatype)==null?void 0:z6.toLowerCase())}),w8),chartType:$6,configAggregates:n9==null?void 0:n9.aggregates,configuration:J6==null?void 0:J6.configuration,pivotHeaderColumns:[],resultData:z3||[],setChartSettings:s9})},C4=F0.useMemo(()=>RP(I3.filter($6=>$6.group&&$6.isAddOnMetrics&&!$6.isAppFilter),"group"),[I3]),P5=F0.useMemo(()=>{var n9,B8;return((n9=T1==null?void 0:T1.customSettings)==null?void 0:n9.comparisonValueShow)&&(T1==null?void 0:T1.chartType)===m0.singleValue?(B8=n==null?void 0:n.filters)==null?void 0:B8.find(L9=>(L9==null?void 0:L9.as)==="date"):void 0},[(q9=T1==null?void 0:T1.customSettings)==null?void 0:q9.comparisonValueShow,T1==null?void 0:T1.chartType,(M1=n==null?void 0:n.filters)==null?void 0:M1.find($6=>($6==null?void 0:$6.as)==="date")]);F0.useEffect(()=>{z3!=null&&z3.length&&q7.length?a9(!0):a9(!1)},[z3,q7.length,t==null?void 0:t.integrationName,t==null?void 0:t.query]);const D5=F0.useMemo(()=>{var $6,J6,n9,B8,L9,w8;return(n9=(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)==null?void 0:J6.selectedMetrics)!=null&&n9.some(_9=>_9.configType==="AGGREGATE")?((w8=(L9=(B8=t==null?void 0:t.datasetMetricSettings)==null?void 0:B8.newDatasetSettings)==null?void 0:L9.selectedDims)==null?void 0:w8.map(_9=>({value:_9.alias,label:_9.alias})))||[]:[]},[(R3=t==null?void 0:t.datasetMetricSettings)==null?void 0:R3.newDatasetSettings]),X5=F0.useMemo(()=>{var $6,J6,n9;return((n9=(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)==null?void 0:J6.selectedMetrics)==null?void 0:n9.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)})))||[]},[(H7=(J3=t==null?void 0:t.datasetMetricSettings)==null?void 0:J3.newDatasetSettings)==null?void 0:H7.selectedMetrics]),{metricFilters:R4,leftPositionedMetricFilters:V5,rightPositionedMetricFilters:u8}=F0.useMemo(()=>{const $6=I3.filter(L9=>!L9.isAppFilter);let J6=$6.filter(L9=>L9.isAddOnMetrics);D2&&(J6=J6.filter(L9=>Gx(L9,!0)));const n9=[],B8=[];return J6.forEach(L9=>{L9.position==="top-right"?B8.push(L9):n9.push(L9)}),{metricFilters:$6,leftPositionedMetricFilters:n9,rightPositionedMetricFilters:B8}},[I3]),j8=[m0.pie,m0.doughnut,m0.rose,m0.funnel,m0.singleValue,m0.table,m0.pivot,m0.horizontalStackTable,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.sankey,m0.timeSeries,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap,m0.boxplot,m0.timeSeries,m0.gantt].includes(T1==null?void 0:T1.chartType)||((T1==null?void 0:T1.isMultiDimension)||(T1==null?void 0:T1.isDynamicSeries))&&(T1==null?void 0:T1.seriesField)!=="ungrouped",A8=F0.useMemo(()=>{var J6;const $6=((J6=t==null?void 0:t.dataSecuritySettings)==null?void 0:J6.csvColumns)||[];return z3!=null&&z3.length?z3==null?void 0:z3.map(n9=>{const B8={};for(const L9 in n9)$6!=null&&$6.includes(L9)||(B8[L9]=n9[L9]);return B8}):[]},[z3,t==null?void 0:t.dataSecuritySettings]);F0.useEffect(()=>{var $6,J6;T1||(s9(t==null?void 0:t.chartOptions),Q3({limit:parseInt(((J6=($6=t==null?void 0:t.chartOptions)==null?void 0:$6.tableSettings)==null?void 0:J6.defaultRowSize)||"100",10),offset:0}))},[t==null?void 0:t.chartOptions,T1]),F0.useEffect(()=>{var $6,J6,n9,B8,L9,w8,_9,l5,T5,d4;if((T1==null?void 0:T1.chartType)===m0.timeSeries&&((J6=($6=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:$6.groupBySettings)!=null&&J6.isGlobalFilter)&&y7){const j5=(B8=(n9=n==null?void 0:n.filters)==null?void 0:n9.find(z6=>{var W8,d5,I5;return z6.label===((I5=(d5=(W8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:W8.groupBySettings)==null?void 0:d5.globalFilterOption)==null?void 0:I5.value)}))==null?void 0:B8.value;if((typeof j5=="string"||typeof j5=="object"&&(j5!=null&&j5.value))&&j5){const z6=typeof j5=="string"?(L9=fb(j5))==null?void 0:L9.toLowerCase():((d4=(T5=(l5=(_9=(w8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:w8.groupBySettings)==null?void 0:_9.formatWithValue)==null?void 0:l5.find(W8=>W8.value===fb(j5==null?void 0:j5.value)))==null?void 0:T5.format)==null?void 0:d4.toLowerCase())||"";cC!=null&&cC.find(W8=>{var d5;return((d5=W8==null?void 0:W8.value)==null?void 0:d5.toLowerCase())===z6})&&s9(W8=>{var d5;return{...W8,timeSeriesSettings:{...W8==null?void 0:W8.timeSeriesSettings,groupBySettings:{...(d5=W8==null?void 0:W8.timeSeriesSettings)==null?void 0:d5.groupBySettings,value:z6}},xAxis:n5?W8.xAxis:`${z6} of ${y7}`}})}}},[n,T1==null?void 0:T1.chartType,(g8=(m6=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:m6.groupBySettings)==null?void 0:g8.isGlobalFilter,(d8=(n8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:n8.groupBySettings)==null?void 0:d8.globalFilterOption,y7]),F0.useEffect(()=>{var $6,J6,n9,B8;T1!=null&&T1.isDynamicSeries&&(($6=T1==null?void 0:T1.seriesOptions)!=null&&$6.includes("ungrouped")?T1!=null&&T1.ungroupedAlias?p4((J6=T1==null?void 0:T1.seriesOptions)==null?void 0:J6.map(L9=>L9==="ungrouped"?{value:L9,label:T1==null?void 0:T1.ungroupedAlias}:{value:L9,label:L9})):p4((n9=T1==null?void 0:T1.seriesOptions)==null?void 0:n9.map(L9=>({value:L9,label:L9}))):p4([...((B8=T1==null?void 0:T1.seriesOptions)==null?void 0:B8.map(L9=>({value:L9,label:L9})))??[]]))},[T1==null?void 0:T1.seriesOptions,T1==null?void 0:T1.isDynamicSeries,T1==null?void 0:T1.ungroupedAlias]);const[D6,G9]=F0.useState(!1),J8=$6=>{$6.key==="Control"&&G9(!0)},f9=$6=>{$6.key==="Control"&&G9(!1)};F0.useEffect(()=>{z3!=null&&z3.length&&H6(Object.keys((z3==null?void 0:z3[0])||{}))},[z3==null?void 0:z3.length]),F0.useEffect(()=>{var $6,J6;return(J6=($6=T1==null?void 0:T1.customSettings)==null?void 0:$6.chartZoom)!=null&&J6.isZoomEnabled&&(window.addEventListener("keydown",J8),window.addEventListener("keyup",f9)),()=>{window.removeEventListener("keydown",J8),window.removeEventListener("keyup",f9)}},[]);const Q9=F0.useMemo(()=>{let $6=!1;if(z3!=null&&z3.length){const J6=T1==null?void 0:T1.singleValue;$6=z3[0][J6]===null&&(T1==null?void 0:T1.chartType)==="singleValue"}return $6},[z3==null?void 0:z3.length,T1==null?void 0:T1.singleValue,(T1==null?void 0:T1.chartType)==="singleValue"]),r8=F0.useMemo(()=>Xf({chartOptions:T1,data:z3||[]}),[z3,T1==null?void 0:T1.xAxis,T1==null?void 0:T1.yAxisList,(N8=T1==null?void 0:T1.dynamicXAxis)==null?void 0:N8.isEnabled,T1==null?void 0:T1.chartType,T1==null?void 0:T1.seriesField,(_8=T1==null?void 0:T1.customSettings)==null?void 0:_8.cumulativeBar,T1==null?void 0:T1.isGroupXAxis,(f5=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:f5.seriesType[0],(s5=(Y9=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:Y9.groupBySettings)==null?void 0:s5.fillXAxis]),d9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.name)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.name,L8,X,N]),C9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.longDescription)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.longDescription,L8,N,X]),h9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.description)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.description,L8,N,X]),V9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.footNote)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.footNote,L8,N,X]),a5=F0.useMemo(()=>{var $6;return`${(($6=z3==null?void 0:z3[0])==null?void 0:$6.dbn_metric_expression_data)||"No Data Found"}`},[z3]),P9=F0.useMemo(()=>{var $6;return($6=t==null?void 0:t.rlsConditions)==null?void 0:$6.map(J6=>{var B8,L9,w8,_9;if((J6==null?void 0:J6.datatype)==="date"&&((B8=J6==null?void 0:J6.options)==null?void 0:B8.find(l5=>l5.range==="Custom Date"))&&(J6==null?void 0:J6.isEnableDynamicDate)&&((L9=J6==null?void 0:J6.dynamicDate)==null?void 0:L9.value)){const l5=Oa2(((w8=ob==null?void 0:ob.find(j5=>{var z6;return j5.value===((z6=J6==null?void 0:J6.dynamicDate)==null?void 0:z6.value)}))==null?void 0:w8.count)||0),T5=Uc(l5),d4=Uc(l5);return{...J6,options:(_9=J6==null?void 0:J6.options)==null?void 0:_9.map(j5=>j5.range==="Custom Date"?{...j5,startDate:l5,endDate:l5,timeGrainValue:`${T5} - ${d4}`}:j5)}}return J6})},[t==null?void 0:t.rlsConditions]);F0.useLayoutEffect(()=>{j7&&(b==null||b($6=>{const J6=new Map($6);return J6.set(t==null?void 0:t.id,{data:{data:[],name:"",description:""},isLoading:j7,key:""}),J6})),o7!=null&&o7.data&&p&&(b==null||b($6=>{const J6=new Map($6);return J6.set(t==null?void 0:t.id,{data:{data:o7==null?void 0:o7.data,name:(t==null?void 0:t.name)||"",description:(t==null?void 0:t.description)||""},isLoading:j7,key:JSON.stringify(D8)}),J6}))},[o7==null?void 0:o7.data,j7]);const N4=()=>{var J6,n9,B8;return(((B8=(n9=(J6=t==null?void 0:t.elementSettings)==null?void 0:J6.summary)==null?void 0:n9.metricList)==null?void 0:B8.map(L9=>{var w8;return(w8=p==null?void 0:p.get(L9==null?void 0:L9.value))==null?void 0:w8.isLoading}))||[]).some(L9=>L9===!0)};F0.useLayoutEffect(()=>{var $6,J6,n9,B8,L9,w8,_9,l5,T5,d4,j5;if((J6=($6=t==null?void 0:t.elementSettings)==null?void 0:$6.summary)!=null&&J6.metricList&&(p!=null&&p.get(t==null?void 0:t.id))&&!h0&&!N4()){const z6=((L9=(B8=(n9=t==null?void 0:t.elementSettings)==null?void 0:n9.summary)==null?void 0:B8.metricList)==null?void 0:L9.map(W8=>{var d5,I5,Qe,xe,ce,at,ye,F4,Ue;return{data:(Qe=(I5=(d5=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:d5.data)==null?void 0:I5.data)!=null&&Qe.length?(ce=(xe=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:xe.data)==null?void 0:ce.data:{},metricName:(ye=(at=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:at.data)==null?void 0:ye.name,metricDescription:(Ue=(F4=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:F4.data)==null?void 0:Ue.description}}))||[];b0(""),t1(""),!z6.some(W8=>Object.keys(W8.data).length===0)&&!h0&&(O0(()=>!0),p0.mutate({data:{metricData:z6,summaryPrompt:(_9=(w8=t==null?void 0:t.elementSettings)==null?void 0:w8.summary)==null?void 0:_9.summaryPrompt,id:t==null?void 0:t.id,filters:`${(j5=(d4=(T5=(l5=t==null?void 0:t.elementSettings)==null?void 0:l5.summary)==null?void 0:T5.metricList)==null?void 0:d4.map(W8=>{var d5;return(d5=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:d5.key}))==null?void 0:j5.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:W8=>{W8.summary?(b0(W8.summary),t1("")):(t1(v22),b0("")),O0(()=>!1)},onSettled:()=>{O0(()=>!1)},onError:W8=>{O0(()=>!1),t1(W8.message),b0("")}}))}},[t==null?void 0:t.elementSettings,p]),F0.useEffect(()=>{var B8,L9,w8,_9,l5,T5,d4,j5,z6,W8,d5,I5,Qe,xe,ce,at,ye,F4,Ue,wt,te,Le,ai,Kn;const $6=oc(((B8=T1==null?void 0:T1.customSettings)==null?void 0:B8.comboAxisSettings)||[]),J6=(L9=$6==null?void 0:$6.map(Ce=>Ce==null?void 0:Ce.measures))==null?void 0:L9.flat(),n9=(w8=T1==null?void 0:T1.yAxisList)==null?void 0:w8.every(Ce=>J6==null?void 0:J6.includes(Ce));if((_9=T1==null?void 0:T1.yAxisList)!=null&&_9.length&&((l5=T1==null?void 0:T1.yAxisList)==null?void 0:l5.length)!==(J6==null?void 0:J6.length)&&!(J6!=null&&J6.length)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((T1==null?void 0:T1.chartType)||"")){const Ce=(d4=(T5=T1==null?void 0:T1.yAxisList)==null?void 0:T5.filter(En=>{var Qr;return!((Qr=T1==null?void 0:T1.comboBarList)!=null&&Qr.includes(En))}))==null?void 0:d4.filter(En=>!(J6!=null&&J6.includes(En))),Kt=((z6=(j5=T1==null?void 0:T1.customSettings)==null?void 0:j5.comboStackAxisSymbols)==null?void 0:z6.name)||"",pr=(I5=(d5=(W8=T1==null?void 0:T1.customSettings)==null?void 0:W8.comboLabelFormatter)==null?void 0:d5.find(En=>En.axis===(Kt||"stack")))==null?void 0:I5.formatter,Cr=(Qe=T1==null?void 0:T1.comboBarList)==null?void 0:Qe.join(" and "),hn=(at=(ce=(xe=T1==null?void 0:T1.customSettings)==null?void 0:xe.comboLabelFormatter)==null?void 0:ce.find(En=>En.axis===Cr))==null?void 0:at.formatter;s9(En=>{var Qr,Rn,ho,Jn,Zn,Yi,Wi,Vi,So,Dr,xi,Eo,na,ga,Go,ve,Mr,ki,er;return{...En,customSettings:{...En.customSettings,comboAxisSettings:oc([...((Qr=En.customSettings)==null?void 0:Qr.comboAxisSettings)||[],...Ce==null?void 0:Ce.map(tr=>{var z5,T4,At,Ht,Wr,it;const un=(At=(T4=(z5=T1==null?void 0:T1.customSettings)==null?void 0:z5.comboLabelFormatter)==null?void 0:T4.find(bt=>bt.axis===tr))==null?void 0:At.formatter,e9=(Wr=(Ht=T1==null?void 0:T1.customSettings)==null?void 0:Ht.comboAxisSymbols)==null?void 0:Wr.find(bt=>bt.name===tr);return{axis:tr,measures:[tr],chartTypes:[{axis:tr,type:"line"}],numberFormatter:(it=T1==null?void 0:T1.customSettings)==null?void 0:it.numberFormatter,labelFormatter:un,prefix:(e9==null?void 0:e9.prefix)||"",suffix:(e9==null?void 0:e9.suffix)||"",isEnableLabelFormatter:!!(un!=null&&un.length)}}),...(Rn=T1==null?void 0:T1.comboBarList)!=null&&Rn.length&&((ho=T1==null?void 0:T1.customSettings)!=null&&ho.isCombineBarAxis||(Jn=T1==null?void 0:T1.customSettings)!=null&&Jn.isStackBar)?[{axis:(Zn=T1==null?void 0:T1.customSettings)!=null&&Zn.isStackBar&&Kt||Cr,measures:T1==null?void 0:T1.comboBarList,chartTypes:(Yi=T1==null?void 0:T1.comboBarList)==null?void 0:Yi.map(tr=>({axis:tr,type:"bar"})),isEnableStackBar:(Wi=T1==null?void 0:T1.customSettings)==null?void 0:Wi.isStackBar,numberFormatter:(Vi=T1==null?void 0:T1.customSettings)==null?void 0:Vi.numberFormatter,...(So=T1==null?void 0:T1.customSettings)!=null&&So.isStackBar?{prefix:((xi=(Dr=T1==null?void 0:T1.customSettings)==null?void 0:Dr.comboStackAxisSymbols)==null?void 0:xi.prefix)||"",suffix:((na=(Eo=T1==null?void 0:T1.customSettings)==null?void 0:Eo.comboStackAxisSymbols)==null?void 0:na.suffix)||"",labelFormatter:pr,isEnableLabelFormatter:!!(pr!=null&&pr.length)}:{prefix:((ga=T1==null?void 0:T1.customSettings)==null?void 0:ga.combinedAxisPrefix)||"",suffix:((Go=T1==null?void 0:T1.customSettings)==null?void 0:Go.combinedAxisSuffix)||"",labelFormatter:hn,isEnableLabelFormatter:!!(hn!=null&&hn.length)}}]:[],...(ve=T1==null?void 0:T1.comboBarList)!=null&&ve.length&&!((Mr=T1==null?void 0:T1.customSettings)!=null&&Mr.isCombineBarAxis)&&!((ki=T1==null?void 0:T1.customSettings)!=null&&ki.isStackBar)?(er=T1==null?void 0:T1.comboBarList)==null?void 0:er.map(tr=>{var z5,T4,At,Ht,Wr,it;const un=(At=(T4=(z5=T1==null?void 0:T1.customSettings)==null?void 0:z5.comboLabelFormatter)==null?void 0:T4.find(bt=>bt.axis===tr))==null?void 0:At.formatter,e9=(Wr=(Ht=T1==null?void 0:T1.customSettings)==null?void 0:Ht.comboAxisSymbols)==null?void 0:Wr.find(bt=>bt.name===tr);return{axis:tr,measures:[tr],chartTypes:[{axis:tr,type:"bar"}],numberFormatter:(it=T1==null?void 0:T1.customSettings)==null?void 0:it.numberFormatter,labelFormatter:un,prefix:(e9==null?void 0:e9.prefix)||"",suffix:(e9==null?void 0:e9.suffix)||"",isEnableLabelFormatter:!!(un!=null&&un.length)}}):[]].filter(tr=>{var un;return(un=tr==null?void 0:tr.measures)==null?void 0:un.length})),comboAxisSymbols:[],combinedAxisPrefix:"",combinedAxisSuffix:"",comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}})}if(J6!=null&&J6.length&&((ye=T1==null?void 0:T1.yAxisList)!=null&&ye.length)&&(((F4=T1==null?void 0:T1.yAxisList)==null?void 0:F4.length)!==(J6==null?void 0:J6.length)||((Ue=T1==null?void 0:T1.yAxisList)==null?void 0:Ue.length)===(J6==null?void 0:J6.length)&&!n9)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((T1==null?void 0:T1.chartType)||"")){const Ce=(wt=T1==null?void 0:T1.yAxisList)==null?void 0:wt.filter(pr=>!(J6!=null&&J6.includes(pr))),Kt=J6==null?void 0:J6.filter(pr=>{var Cr;return!((Cr=T1==null?void 0:T1.yAxisList)!=null&&Cr.includes(pr))});Kt==null||Kt.forEach(pr=>{var Qr,Rn,ho;const Cr=(Rn=(Qr=T1==null?void 0:T1.customSettings)==null?void 0:Qr.comboAxisSettings)==null?void 0:Rn.find(Jn=>{var Zn;return(Zn=Jn.measures)==null?void 0:Zn.includes(pr)}),hn=Cr==null?void 0:Cr.axis,En=(((ho=Cr==null?void 0:Cr.measures)==null?void 0:ho.length)||0)>1;s9(Jn=>{var Zn,Yi,Wi,Vi,So;return{...Jn,customSettings:{...Jn.customSettings,comboAxisSettings:oc(En?((Wi=(Yi=(Zn=Jn.customSettings)==null?void 0:Zn.comboAxisSettings)==null?void 0:Yi.map(Dr=>{var xi;return Dr.axis===hn?{...Dr,measures:(xi=Dr==null?void 0:Dr.measures)==null?void 0:xi.filter(Eo=>Eo!==pr)}:Dr}))==null?void 0:Wi.filter(Dr=>{var xi;return(xi=Dr==null?void 0:Dr.measures)==null?void 0:xi.length}))||[]:((So=(Vi=Jn.customSettings)==null?void 0:Vi.comboAxisSettings)==null?void 0:So.filter(Dr=>{var xi;return Dr.axis!==hn&&((xi=Dr==null?void 0:Dr.measures)==null?void 0:xi.length)}))||[])}}})}),Ce!=null&&Ce.length&&s9(pr=>{var Cr;return{...pr,customSettings:{...pr.customSettings,comboAxisSettings:oc([...((Cr=pr.customSettings)==null?void 0:Cr.comboAxisSettings)||[],...Ce==null?void 0:Ce.map(hn=>({axis:hn,measures:[hn],chartTypes:[{axis:hn,type:"line"}]}))].filter(hn=>{var En;return(En=hn==null?void 0:hn.measures)==null?void 0:En.length})||[])}}})}J6!=null&&J6.length&&((te=T1==null?void 0:T1.yAxisList)!=null&&te.length)&&((Le=T1==null?void 0:T1.yAxisList)==null?void 0:Le.length)===(J6==null?void 0:J6.length)&&n9&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((T1==null?void 0:T1.chartType)||"")&&((Kn=(ai=T1==null?void 0:T1.customSettings)==null?void 0:ai.comboAxisSettings)==null?void 0:Kn.length)!==($6==null?void 0:$6.length)&&s9(Ce=>({...Ce,customSettings:{...Ce==null?void 0:Ce.customSettings,comboAxisSettings:$6}}))},[T1==null?void 0:T1.yAxisList,(Z5=T1==null?void 0:T1.customSettings)==null?void 0:Z5.comboAxisSettings,T1==null?void 0:T1.comboBarList,(Z4=T1==null?void 0:T1.customSettings)==null?void 0:Z4.isCombineBarAxis,(le=T1==null?void 0:T1.customSettings)==null?void 0:le.isStackBar,(pe=(Ve=T1==null?void 0:T1.customSettings)==null?void 0:Ve.comboStackAxisSymbols)==null?void 0:pe.name,(mt=(tt=T1==null?void 0:T1.customSettings)==null?void 0:tt.comboStackAxisSymbols)==null?void 0:mt.prefix,(sn=(Zr=T1==null?void 0:T1.customSettings)==null?void 0:Zr.comboStackAxisSymbols)==null?void 0:sn.suffix,(xn=T1==null?void 0:T1.customSettings)==null?void 0:xn.comboLabelFormatter,(ci=T1==null?void 0:T1.customSettings)==null?void 0:ci.comboAxisSymbols,(ii=T1==null?void 0:T1.customSettings)==null?void 0:ii.numberFormatter,(oi=T1==null?void 0:T1.customSettings)==null?void 0:oi.combinedAxisPrefix,(Ti=T1==null?void 0:T1.customSettings)==null?void 0:Ti.combinedAxisSuffix,T1==null?void 0:T1.chartType]),F0.useEffect(()=>{var $6,J6,n9;($6=T1==null?void 0:T1.yAxisList)!=null&&$6.length&&((J6=T1==null?void 0:T1.yAxisList)==null?void 0:J6.length)<5&&(T1==null?void 0:T1.chartType)===m0.boxplot&&s9(B8=>({...B8,chartType:m0.line})),!((n9=T1==null?void 0:T1.yAxisList)!=null&&n9.length)&&(T1==null?void 0:T1.chartType)===m0.funnelV2&&s9(B8=>({...B8,chartType:m0.singleValue}))},[T1==null?void 0:T1.chartType,(Hi=T1==null?void 0:T1.yAxisList)==null?void 0:Hi.length]);const e4=({columnAlias:$6,value:J6,isClear:n9=!1})=>{const B8=t==null?void 0:t.datasetMetricSettings;B8&&ZJ2({columnAlias:$6,datasetSettings:B8,setTableColumnFilters:I7,value:J6,isClear:n9})};return F0.useEffect(()=>{var J6,n9,B8,L9;if(!((J6=T1==null?void 0:T1.dynamicYAxis)!=null&&J6.isEnabled)||!((n9=T1==null?void 0:T1.dynamicYAxis)!=null&&n9.selectedOption)||Array.isArray((B8=T1==null?void 0:T1.dynamicYAxis)==null?void 0:B8.selectedOption))return;const $6=(L9=T1==null?void 0:T1.dynamicYAxis)==null?void 0:L9.selectedOption;s9(w8=>({...w8,dynamicYAxis:{...w8==null?void 0:w8.dynamicYAxis,selectedOption:[$6]},yAxisList:[$6==null?void 0:$6.value]}))},[(gn=T1==null?void 0:T1.dynamicYAxis)==null?void 0:gn.selectedOption,(Yr=T1==null?void 0:T1.dynamicYAxis)==null?void 0:Yr.isEnabled]),F0.useEffect(()=>{var B8,L9,w8,_9,l5,T5,d4,j5;const $6=(B8=r2==null?void 0:r2.yAxisSettings)==null?void 0:B8.find(z6=>{var W8,d5,I5,Qe,xe;return((W8=z6==null?void 0:z6.yAxisSettings)==null?void 0:W8.isEnable)&&(z6==null?void 0:z6.id)===(t==null?void 0:t.id)&&((d5=z6==null?void 0:z6.yAxisSettings)==null?void 0:d5.yAxis)&&Array.isArray((I5=z6==null?void 0:z6.yAxisSettings)==null?void 0:I5.yAxis)&&((xe=(Qe=z6==null?void 0:z6.yAxisSettings)==null?void 0:Qe.yAxis)==null?void 0:xe.length)>0}),J6=(L9=r2==null?void 0:r2.xAxisSettings)==null?void 0:L9.find(z6=>{var W8,d5;return((W8=z6==null?void 0:z6.xAxisSettings)==null?void 0:W8.isEnable)&&(z6==null?void 0:z6.id)===(t==null?void 0:t.id)&&((d5=z6==null?void 0:z6.xAxisSettings)==null?void 0:d5.xaxis)});if(!((w8=T1==null?void 0:T1.dynamicYAxis)!=null&&w8.isEnabled)&&!((_9=T1==null?void 0:T1.dynamicXAxis)!=null&&_9.isEnabled)&&!((l5=D7==null?void 0:D7.configV2)!=null&&l5.isEnable)||!$6&&!J6&&!((T5=D7==null?void 0:D7.configV2)!=null&&T5.isEnable)){s9(z6=>(t==null?void 0:t.chartOptions)||z6);return}const n9=(j5=(d4=$6==null?void 0:$6.yAxisSettings)==null?void 0:d4.yAxis)==null?void 0:j5[0];s9(z6=>{var W8,d5,I5,Qe,xe,ce,at;return{...z6,dynamicYAxis:{...z6==null?void 0:z6.dynamicYAxis,selectedOption:n9?[n9]:((W8=z6==null?void 0:z6.dynamicYAxis)==null?void 0:W8.selectedOption)||[]},dynamicXAxis:{...z6==null?void 0:z6.dynamicXAxis,selectedOption:(d5=J6==null?void 0:J6.xAxisSettings)!=null&&d5.xaxis?{value:(I5=J6==null?void 0:J6.xAxisSettings)==null?void 0:I5.xaxis,label:(Qe=J6==null?void 0:J6.xAxisSettings)==null?void 0:Qe.xaxis}:((xe=z6==null?void 0:z6.dynamicXAxis)==null?void 0:xe.selectedOption)||[]},yAxisList:n9!=null&&n9.value?[n9==null?void 0:n9.value]:(z6==null?void 0:z6.yAxisList)||[],xAxis:(ce=J6==null?void 0:J6.xAxisSettings)!=null&&ce.xaxis?(at=J6==null?void 0:J6.xAxisSettings)==null?void 0:at.xaxis:(z6==null?void 0:z6.xAxis)||""}})},[r2==null?void 0:r2.yAxisSettings,t==null?void 0:t.id,r2==null?void 0:r2.xAxisSettings,(fi=T1==null?void 0:T1.dynamicYAxis)==null?void 0:fi.isEnabled,(Gi=T1==null?void 0:T1.dynamicXAxis)==null?void 0:Gi.isEnabled,(Ae=D7==null?void 0:D7.configV2)==null?void 0:Ae.isEnable]),F0.useEffect(()=>{var $6,J6,n9;($6=T1==null?void 0:T1.customSettings)!=null&&$6.isShowDuration&&(T1==null?void 0:T1.chartType)===m0.gantt&&!((n9=(J6=T1==null?void 0:T1.customSettings)==null?void 0:J6.ganttTooltipKeys)!=null&&n9.includes("Duration"))&&s9(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"]}}})},[(Hr=T1==null?void 0:T1.customSettings)==null?void 0:Hr.isShowDuration,T1==null?void 0:T1.chartType,(Cn=T1==null?void 0:T1.customSettings)==null?void 0:Cn.ganttTooltipKeys]),{elementSummary:L0,elementSummaryError:j2,isLoadingSummary:h0,isMetricListLoading:N4,onDrillLevelClick:r9,onDrillDown:t9,handleChartClick:N6,dataDb:z3,getUnderlyingData:M3,onChangeFilterValue:T6,isShowChartPopup:R6,setShowChartPopup:h6,columnName:D9,chartParams:w3,isQueryLoading:j7||m2||W2,isSingleValueNull:Q9,dynamicOptions:v5,chartSettings:T1,setChartSettings:s9,isEnableZoom:D6,filterValues:r5,containerRef:U0,drilledLevel:p7.length,dimensions:((Xn=(di=t==null?void 0:t.datasetMetricSettings)==null?void 0:di.selectedDimensions)==null?void 0:Xn.map($6=>xa2($6||"none")))||[],rlsConditions:I3,setRlsConditions:$3,setTableLimit:Q3,isEnableNextBtn:x1>(X2==null?void 0:X2.limit)+(X2==null?void 0:X2.offset),isEnablePrevBtn:(X2==null?void 0:X2.offset)!==0,paginationInfo:{limit:X2==null?void 0:X2.limit,offset:X2==null?void 0:X2.offset,totalRecords:x1},onChangePage:($6,J6,n9)=>{Q3(J6?{limit:J6,offset:0}:B8=>{let L9;return n9||n9===0?L9=n9:$6?L9=B8.offset>B8.limit?B8.offset-B8.limit:0:L9=B8.offset+B8.limit,{limit:B8.limit,offset:L9}})},isExternalChart:((Er=T1==null?void 0:T1.tableSettings)==null?void 0:Er.isServerSidePagination)&&(T1==null?void 0:T1.chartType)===m0.table,isEnablePivotTable:C8,groupByList:q7,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:$6=>{$3(J6=>J6==null?void 0:J6.map(n9=>n9.name===$6.name&&n9.datatype===$6.datatype&&n9.tableName===$6.tableName&&n9.columnName===$6.columnName?{...n9,isAddOnMetrics:!n9.isAddOnMetrics}:n9))},metricFilters:R4,leftPositionedMetricFilters:V5,rightPositionedMetricFilters:u8,drillFilters:p7,drillType:(ln=t==null?void 0:t.drillDownSettings)==null?void 0:ln.drillType,tableResultsDownloadData:A8,appliedMetricFilters:O8,pivotHeaderOptions:D5,pivotDrillState:S9,onDrillPivotTable:o8,legendData:r8,timeseriesDimension:y7,isPythonMode:n5,sortOrder:Y7,setSortOrder:l6,isNotFirstRender:q3,setNotFirstRender:T7,isSorted:W9,isInavlidForSort:j8,onAddComparison:y8,groupedRlsConditions:C4,onGenerateMetricSummary:k9,summary:I1,setSummary:l3,dataMartRelationships:Y5,onChartChange:o9,isCompareValue:Q6,isShowChartPropertyPanel:T8,setShowChartPropertyPanel:y9,columnList:c6,variables:L8,metricName:d9,longDescription:C9,footNote:V9,description:h9,drilldownCols:h7,switchMeasureOptions:X5,metricExpressionResult:a5,dateFilter:P5,drillDownSettings:D7,enabledCharts:w5,tableColumnFilters:b7,onChangePaginationColumnFilters:e4,queryError:p6||(o7==null?void 0:o7.error),refetchMetricData:s6,customSwitchXAxis:E3,savedMetricFilters:P9||[]}},w70=({metricId:t,onSuccess:n,token:i})=>{const{mutateAsync:o,isLoading:a}=X30();return{handleArchiveMetric:F0.useCallback(async()=>{!t||!i||await o({data:{id:t},token:i},{onSuccess:async r=>{r!=null&&r.error||await n()}})},[o,t]),isLoading:a}},Nu2=({token:t,metricId:n})=>{var M2;const[i,o]=F0.useState(!0),{data:a,isLoading:s}=E70(t,n),{externalMetric:r,sharingSettingsId:C,adminTheme:l,params:e,companyId:u,clientId:A,errorMsg:f,clientColumnType:d,isEnableMetricSummary:g,isAllClient:p,isShowUnderlyingData:b,appFilters:w,mergedMetricsId:T,datasourceId:H,mergedMetricLayout:S,mergedDashboardFilters:N,dashboardAppFilterValues:X,filterLayout:W,nestedMetric:f2,guestToken:Q2}=F0.useMemo(()=>{var k2,W2;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:(k2=m2==null?void 0:m2.error)==null?void 0:k2.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:(W2=window==null?void 0:window.dbn)!=null&&W2.isEnableProxyAuth?Fd(m2==null?void 0:m2.token,m2==null?void 0:m2.companyId):m2==null?void 0:m2.token}},[a,(M2=window==null?void 0:window.dbn)==null?void 0:M2.isEnableProxyAuth]),{rlsSettings:I2,tenancyLevel:r2,workspaceId:D2}=F0.useMemo(()=>{var k2,W2;if(!e)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const m2=JSON.parse(e);return{rlsSettings:(k2=m2.rlsSettings)==null?void 0:k2.find(c0=>c0.metricId===n),tenancyLevel:m2.companyTenancyType||"TABLE",workspaceId:((W2=m2==null?void 0:m2.workspace)==null?void 0:W2.id)||""}},[e,n]);return F0.useEffect(()=>{s&&o(!0),(r||f||!s)&&o(!1)},[s,r,f]),{externalMetric:r,sharingSettingsId:C,companyId:u,clientId:A,rlsSettings:I2,tenancyLevel:r2,isLoading:i,errorMsg:f,adminTheme:l,workspaceId:D2,clientColumnType:d,isEnableMetricSummary:g,isAllClient:p,isShowUnderlyingData:b,appFilters:w,mergedMetricsId:T,datasourceId:H,mergedMetricLayout:S,mergedDashboardFilters:N,dashboardAppFilterValues:X,filterLayout:W,nestedMetric:f2,token:Q2}},Q70=Hu2({active:null,over:null,DragPreviewCreateRoot:null,draggables:[],droppables:[]}),Su2=()=>{const[t,n]=H_(Q70);return{dndState:t,setActive:r=>{n(C=>({...C,active:r}))},setOver:r=>{n(C=>({...C,over:r}))},setDraggables:r=>{n(C=>{var u;const l=(u=C.draggables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,draggables:[...C.draggables,r]};const e=[...C.draggables];return e[l]=r,{...C,draggables:e}})},setDropables:r=>{n(C=>{var u;const l=(u=C.droppables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,droppables:[...C.droppables,r]};const e=[...C.droppables];return e[l]=r,{...C,droppables:e}})},setDndState:n}},M70=({identifier:t,data:n,modifiers:i,events:o,CustomDragPreview:a,disabled:s=!1,dropText:r})=>{const{dndState:C,setActive:l,setDndState:e,setDraggables:u}=Su2(),[A,f]=F0.useState(!1),[d,g]=F0.useState(!0),[p,b]=F0.useState(null),w=F0.useRef(null),T=F0.useRef(null),H={"data-type":t.type||t.id,id:`draggable-${t.id}`,role:"button",tabindex:"0",draggable:d?"true":"false","aria-grabbed":"false"},S=X=>{Object.entries(H).forEach(([W,f2])=>{X.setAttribute(W,f2)})},N=()=>{var X;T.current&&((X=C.DragPreviewCreateRoot)==null||X.render(a))};return F0.useEffect(()=>{if(a&&(T.current=document.getElementById("CustomDragPreviewContainer"),T.current===null)){T.current=document.createElement("div"),T.current.setAttribute("id","CustomDragPreviewContainer"),document.body.appendChild(T.current);const X=tI2.createRoot(T.current);e(W=>({...W,DragPreviewCreateRoot:X}))}},[]),F0.useEffect(()=>{if(w.current){const X=w.current.getBoundingClientRect();b(X),u({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:p,events:o,isDragging:A,isEnableDrag:d})}},[w.current,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i),JSON.stringify(o),JSON.stringify(A)]),F0.useEffect(()=>{const X=w.current;if(!X)return;S(X);const W=Q2=>{var I2,r2,D2,M2;if(f(!0),l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:p,events:o,isDragging:A,isEnableDrag:d}),X.setAttribute("aria-grabbed","true"),r?(I2=Q2.dataTransfer)==null||I2.setData("text/plain",r):(r2=Q2.dataTransfer)==null||r2.setData("text/plain",JSON.stringify({data:n})),(D2=o==null?void 0:o.onDragStart)==null||D2.call(o,Q2,C),T.current){const m2=T.current.getBoundingClientRect();(M2=Q2.dataTransfer)==null||M2.setDragImage(T.current,m2.width/2,m2.height/2)}},f2=Q2=>{var I2;X.setAttribute("aria-grabbed","false"),f(!1),l(null),(I2=o==null?void 0:o.onDragEnd)==null||I2.call(o,Q2,C)};return X.addEventListener("mousedown",()=>{a&&N()}),X.addEventListener("dragstart",W),X.addEventListener("dragend",f2),()=>{X.removeEventListener("dragstart",W),X.removeEventListener("dragend",f2)}},[w.current,JSON.stringify(t),JSON.stringify(n),C.DragPreviewCreateRoot]),F0.useEffect(()=>{const X=w.current;X&&X.setAttribute("draggable",d?"true":"false")},[d]),F0.useEffect(()=>{var W,f2,Q2,I2;let X=[];return A&&(l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:p,events:o,isDragging:A,isEnableDrag:d}),(W=i==null?void 0:i.highlightDrop)!=null&&W.onDrag&&(X=((Q2=(f2=C.droppables)==null?void 0:f2.filter(r2=>((r2==null?void 0:r2.identifier.accepts)??[]).includes(t.type??"")&&(r2==null?void 0:r2.isEnableDrop)))==null?void 0:Q2.map(r2=>r2==null?void 0:r2.setDropNodeRef.current))??[],(I2=i==null?void 0:i.highlightDrop)!=null&&I2.onDrag&&X.forEach(r2=>{var D2;r2==null||r2.classList.add(((D2=i==null?void 0:i.highlightDrop)==null?void 0:D2.highlightClass)||"dnd-droppable-highlight")}))),()=>{X.forEach(r2=>{var D2;r2==null||r2.classList.remove(((D2=i==null?void 0:i.highlightDrop)==null?void 0:D2.highlightClass)||"dnd-droppable-highlight")})}},[A]),F0.useEffect(()=>{g(!s)},[s]),{isDragging:A,isEnableDrag:d,setIsEnableDrag:g,DragNodeRef:w}},Vu2=({identifier:t,events:n,modifiers:i})=>{var S;const{dndState:o,setOver:a,setDropables:s}=Su2(),[r,C]=F0.useState(null),[l,e]=F0.useState({isDragOver:!1,isDrop:!1}),[u,A]=F0.useState({before:-1,after:-1}),[f,d]=F0.useState(!0),g=F0.useRef(null),p={"data-type":((S=t.accepts)==null?void 0:S.join("-"))??"",id:`droppable-${t.id}`,droppable:f?"true":"false"},b=N=>{Object.entries(p).forEach(([X,W])=>{N.setAttribute(X,W)})},w=(N,X,W)=>{const f2=[...W];N=N===-1?f2.length-1:N;const[Q2]=f2.splice(N,1);return X===-1?f2.push(Q2):f2.splice(X,0,Q2),f2},T=(N,X,W)=>[...N.querySelectorAll('[draggable="true"]:not([aria-grabbed="true"])')].reduce((I2,r2,D2)=>{const M2=r2.getBoundingClientRect(),m2=X-M2[W==="horizontal"?"left":"top"]-M2[W==="horizontal"?"width":"height"]/2;return m2<0&&m2>I2.offset?{offset:m2,element:r2,index:D2}:I2},{offset:Number.NEGATIVE_INFINITY,element:null,index:-1}),H=(N,X,W)=>{const f2=[...N.querySelectorAll('[draggable="true"]')],Q2=N.querySelector('[aria-grabbed="true"]'),{width:I2,height:r2}=W,D2=(m2,k2,W2)=>{const c0=m2.x-k2/2,p0=m2.y-W2/2;return[{x:c0,y:p0},{x:c0+k2,y:p0},{x:c0,y:p0+W2},{x:c0+k2,y:p0+W2}]};return f2.reduce((m2,k2,W2)=>{const c0=k2.getBoundingClientRect(),p0=[{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}],L0=D2(X,I2,r2);let b0=Number.POSITIVE_INFINITY,j2=W2,t1=Number.POSITIVE_INFINITY,h0=Number.POSITIVE_INFINITY;return p0.forEach((O0,U0)=>{L0.forEach(X2=>{let Q3=Number.POSITIVE_INFINITY;t1=Math.sqrt((O0.x-X2.x)**2+(O0.y-X2.y)**2),h0=Math.sqrt((O0.x-X.x)**2+(O0.y-X.y)**2),Q3=Math.min(t1,h0),Q3<b0&&(b0=Q3,U0===1||U0===3?Q2!==k2&&(j2=W2+1):j2=W2)})}),b0<m2.minDistance?{minDistance:b0,element:k2,index:j2,closestBasedOnCorner:t1,closestBasedonCursor:h0}:m2},{minDistance:Number.POSITIVE_INFINITY,element:null,index:-1,closestBasedOnCorner:0,closestBasedonCursor:0})};return F0.useEffect(()=>{const N=g.current;if(!N)return;const X=N.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)]),F0.useEffect(()=>{var r2,D2;const N=g.current;if(b(N),!N||!f||(r2=t.accepts)!=null&&r2.length&&!t.accepts.includes(((D2=o.active)==null?void 0:D2.identifier.type)??""))return;const{sorting:X}=i||{},W=M2=>{var m2;M2.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,M2,o)},f2=M2=>{var m2,k2,W2,c0,p0,L0,b0,j2,t1,h0,O0,U0;if(M2.preventDefault(),(W2=(k2=(m2=o.active)==null?void 0:m2.modifiers)==null?void 0:k2.highlightDrop)!=null&&W2.onDragOver&&g.current.classList.add(((L0=(p0=(c0=o.active)==null?void 0:c0.modifiers)==null?void 0:p0.highlightDrop)==null?void 0:L0.highlightClass)||"dnd-droppable-highlight"),l.isDragOver||e(X2=>({...X2,isDragOver:!0})),o.over===null&&a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),X!=null&&X.isEnabled&&((b0=X.list)!=null&&b0.length)){const X2=(h0=(t1=(j2=o.active)==null?void 0:j2.DragNodeRef)==null?void 0:t1.current)==null?void 0:h0.getAttribute("data-dbn-sorting-index");let Q3=null;if((X.sortingType==="vertical"||X.sortingType==="horizontal")&&(Q3=T(N,(X==null?void 0:X.sortingType)==="horizontal"?M2.clientX:M2.clientY,X==null?void 0:X.sortingType)),X.sortingType==="both-axis"){const v3=(O0=document.getElementById("CustomDragPreviewContainer"))==null?void 0:O0.getBoundingClientRect();Q3=H(N,{x:M2.clientX,y:M2.clientY},{width:(v3==null?void 0:v3.width)??0,height:(v3==null?void 0:v3.height)??0})}const x1={before:parseInt(X2??-1,10),after:Q3==null?void 0:Q3.index};(x1.before!==u.before||x1.after!==u.after)&&A(x1)}(U0=n==null?void 0:n.onDragOver)==null||U0.call(n,M2,o)},Q2=M2=>{var m2,k2,W2,c0,p0,L0,b0;M2.preventDefault(),(W2=(k2=(m2=o.active)==null?void 0:m2.modifiers)==null?void 0:k2.highlightDrop)!=null&&W2.onDragOver&&g.current.classList.remove(((L0=(p0=(c0=o.active)==null?void 0:c0.modifiers)==null?void 0:p0.highlightDrop)==null?void 0:L0.highlightClass)||"dnd-droppable-highlight"),e(j2=>({...j2,isDragOver:!1})),(b0=n==null?void 0:n.onDragLeave)==null||b0.call(n,M2,o),a(null)},I2=M2=>{var p0,L0,b0,j2,t1,h0,O0,U0,X2,Q3;M2.preventDefault();const m2=g.current.contains((L0=(p0=o.active)==null?void 0:p0.DragNodeRef)==null?void 0:L0.current);let k2={...o};(t1=(j2=(b0=o.active)==null?void 0:b0.modifiers)==null?void 0:j2.highlightDrop)!=null&&t1.onDragOver&&g.current.classList.remove(((U0=(O0=(h0=o.active)==null?void 0:h0.modifiers)==null?void 0:O0.highlightDrop)==null?void 0:U0.highlightClass)||"dnd-droppable-highlight");let{before:W2,after:c0}=u;if(X!=null&&X.isEnabled&&((X2=X.list)!=null&&X2.length)){let x1=[...X.list];m2?x1=w(W2,c0,x1):W2=-1,k2={...o,sorting:{sortedList:x1,isSelfDrop:m2,ArrayElementSwap:w,sortingIndexes:{before:W2,after:c0}}},X.isEnabledAutoSort&&m2&&X.setList(x1)}e(x1=>({...x1,isDrop:!0})),(Q3=n==null?void 0:n.onDrop)==null||Q3.call(n,M2,k2),a(null)};return N.addEventListener("dragenter",W),N.addEventListener("dragover",f2),N.addEventListener("dragleave",Q2),N.addEventListener("drop",I2),()=>{N.removeEventListener("dragenter",W),N.removeEventListener("dragover",f2),N.removeEventListener("dragleave",Q2),N.removeEventListener("drop",I2)}},[g.current,t,f,i,n,u]),F0.useEffect(()=>{const N=g.current;N&&N.setAttribute("droppable",f?"true":"false")},[f]),{dragStatus:l,isEnableDrop:f,setIsEnableDrop:d,setDropNodeRef:g}},T70=(t,n,i)=>({autoCompleteDropdownOptions:F0.useMemo(()=>{if(!n.length)return[];const a=[];return n.forEach(s=>{s.columnsWithDataType.forEach(r=>{var g;const C=tq2(((g=r==null?void 0:r.dataType)==null?void 0:g.toLowerCase())||""),l=rq2(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(([p,b])=>{e.add(p),b&&u.add(b)}),C){case"DATE":Mx.forEach(p=>p.synonyms.forEach(A.add,A));break;case"NUMBER":DE.forEach(p=>p.synonymns.forEach(A.add,A));break;case"STRING":vh.forEach(p=>p.synonyms.forEach(A.add,A)),Bb2.forEach(p=>p.synonyms.forEach(A.add,A));break}pL.forEach(p=>p.synonymns.forEach(A.add,A));const f=l.flatMap(p=>(ab==null?void 0:ab[p.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(p=>{a.push({alias:p,datatype:r.dataType,name:p,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],distinctValueSynonyms:[...u],type:"VALUE"})})})}),a},[n,i,t])}),x70=(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)||fV}${Y10}`,{method:"POST",body:JSON.stringify({fileName:t,dashboardId:n}),headers:{"Content-Type":"application/json",...a?{}:{"X-Plugin-Token":o||""},...dV()||{},"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)}}}),R70=()=>{const[t,n]=F0.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,p;const f=((d=window==null?void 0:window.dbn)==null?void 0:d.isEnableProxyAuth)||!1;try{n({downloadProgress:!0,isLoading:!0});const b=await fetch(`${((g=window.dbn)==null?void 0:g.proxyAuthUrl)||((p=window.dbn)==null?void 0:p.baseUrl)||fV}${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||""},...dV()||{},"X-Plugin-Origin":window.location.host,...r?{"X-Dbn-Secret":C}:{},...r?{"X-Dbn-token":b_()||""}:{}}});if(!b.ok)throw new Error("Network response was not ok");const w=await b.blob(),T=URL.createObjectURL(w),H=document.createElement("a");H.href=T,H.download=`${o}.zip`,H.style.display="none",document.body.appendChild(H),n({downloadProgress:!1,isLoading:!1}),lP&&(document!=null&&document.createEvent)||H.click(),URL.revokeObjectURL(T),document.body.removeChild(H)}catch{n({downloadProgress:!1,isLoading:!1}),alert("Error downloading the file. Please try later.")}},downloadState:t}},H70=({dashboardId:t,fileName:n,token:i})=>{const[o,a]=F0.useState(""),[s,r]=F0.useState(!1),[C,l]=F0.useState({isGettingPdf:!1}),{toPDF:e}=x70(n,t);return{toPDF:async()=>{if(l({isGettingPdf:!0}),a(""),r(!1),!i){a(ku),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1});return}try{await e(i),r(!0),setTimeout(()=>{r(!1)},2e3),l({isGettingPdf:!1})}catch{a(ku),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1})}},isGettingPdf:C==null?void 0:C.isGettingPdf,error:o,isPdfExported:s}},IV={downloadCsv:"_downloadCsv_z5r12_1",downloadCsvWrapper:"_downloadCsvWrapper_z5r12_9",downloadCsvNote:"_downloadCsvNote_z5r12_45",downloadCsvNoteText:"_downloadCsvNoteText_z5r12_59"},VA={label:"_label_lpfkf_1","inputField-container":"_inputField-container_lpfkf_25",upperContainer:"_upperContainer_lpfkf_31",input:"_input_lpfkf_25",supportText:"_supportText_lpfkf_49",error:"_error_lpfkf_55",inputVal:"_inputVal_lpfkf_61",inputContainer:"_inputContainer_lpfkf_67",floatingLabel:"_floatingLabel_lpfkf_81",suffixContainer:"_suffixContainer_lpfkf_89",prefixContainer:"_prefixContainer_lpfkf_95",inlineLabelContainer:"_inlineLabelContainer_lpfkf_101",important:"_important_lpfkf_109"},K9=({type:t="text",register:n,label:i,isDisabled:o,id:a,elementRef:s,error:r,supportingText:C,leftIcon:l,rightIcon:e,addSuffix:u,addPrefix:A,inlineLabel:f,labelVariant:d="static",value:g,isImportant:p,containerClassName:b="",containerStyle:w,customClassName:T="",isFilter:H,isApplyDashboardColor:S,...N})=>{var X,W,f2,Q2;return h.jsxs("div",{className:`${VA["inputField-container"]} ${T}`,children:[h.jsxs("div",{className:VA.upperContainer,id:`${(W=(X=i??a)==null?void 0:X.replaceAll(" ","-"))==null?void 0:W.toLowerCase()}-input`,"data-testid":`${(Q2=(f2=i??a)==null?void 0:f2.replaceAll(" ","-"))==null?void 0:Q2.toLowerCase()}-input`,children:[i?h.jsxs(h.Fragment,{children:[d==="floating"&&h.jsxs("label",{htmlFor:a,className:`${VA.floatingLabel} ${H?"dbn-selectBox-text":""} ${H&&S?"dbn-selectBox":""}`,children:[i,p?h.jsx("span",{className:VA.important,children:"*"}):null]}),d==="static"&&h.jsx("label",{htmlFor:a,className:`${VA.label} ${H?"dbn-selectBox-text":""} ${H&&S?"dbn-selectBox":""}`,children:h.jsxs(e6,{variant:"input-label",color:"primary",children:[i,p?h.jsx("span",{className:VA.important,children:"*"}):null]})})]}):null,h.jsxs("div",{className:`${VA.inputContainer} ${H&&S?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""} ${b} `,style:w,children:[f&&h.jsx("div",{className:VA.inlineLabelContainer,children:h.jsx(e6,{variant:"heading-6",children:f})}),A&&h.jsx("div",{className:`${VA.prefixContainer} ${VA.supportText}`,children:A}),l&&h.jsx("div",{className:"dbn-p-2",children:l}),h.jsx("input",{...N,value:g,ref:s,id:a,type:t,className:`${VA.input} ${N.className||""} ${r?VA.error:""} ${g?VA.inputVal:""} ${H&&S?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""}`,...n,disabled:o}),e&&h.jsx("div",{className:"dbn-p-2",children:e}),u&&h.jsx("div",{className:`${VA.suffixContainer} ${VA.supportText}`,children:u})]})]}),C&&h.jsx("div",{className:VA.supportText,children:C}),r&&h.jsx(e6,{variant:"body-text-2",color:"alert",children:r})]})},Gd={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"},Gu=({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=F0.useRef(),[g,p]=F0.useState(!1),[b,w]=F0.useState(!1),[T,H]=F0.useState(!1),S=X=>{X.target.classList.contains(Gd.modal)?w(!0):w(!1)},N=X=>{X.target.classList.contains(Gd.modal)?H(!0):H(!1)};return F0.useEffect(()=>{T&&b&&(H(!1),w(!1))},[T,b]),h.jsx(mE,{children:n||f?h.jsx("div",{className:`${Gd.modal} ${A?"dbn-items-end dbn-py-0":""}`,onMouseDown:N,onMouseUp:S,ref:d,style:{...l?{zIndex:l}:{},...f?{display:n?void 0:"none"}:{}},children:h.jsxs("div",{className:`${Gd.popup} ${g?Gd.popupFullScreen:""} ${e?Gd[`popup-${e}`]:""} ${A?"dbn-my-0 dbn-rounded-b-none dbn-rounded-t-3xl":""}`,onClick:X=>{X.stopPropagation()},children:[u?null:h.jsx("section",{className:Gd.header,children:s||h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-items-start dbn-gap-1.5",children:[h.jsxs("div",{className:Gd.headerTitle,children:[C,h.jsx(e6,{variant:"heading-3",color:"primary",children:o})]}),a&&h.jsx("div",{className:Gd.subHeadingTitle,children:h.jsx(e6,{variant:"body-text-3",color:"sec-text",children:a})})]}),h.jsx(a8,{"data-testid":"close-modal",variant:"tertiary",type:"button",onClick:i,leftIcon:h.jsx(p8,{name:"cross",size:"small"}),style:{padding:"0",height:"20px"},className:"dbn-p-1.5"})]})}),h.jsx("section",{className:Gd.content,children:t})]})}):null})},rd=({children:t,className:n})=>h.jsx("section",{className:`${Gd.footer} ${n}`,children:t}),D70=t=>{if(!t.length)return!1;const n=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;return t.every(i=>n.test(i))},N_=({onCloseModal:t,sharingSettingsId:n,metricItem:i,workspaceId:o})=>{const{data:a}=B70(o),[s,r]=F0.useState(!1),[C,l]=F0.useState(""),{mutate:e}=_30(),{handleSubmit:u,register:A,setValue:f,control:d,formState:{errors:g}}=cb(),p=F0.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:T})=>{r(!0),l("");const H=p.expireTimeInMin||30,S=new Date(Date.now()+H*60*1e3),N=T,X=w.emails;if(!D70(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:S,expireUrlIn:H*60,externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,query:N,sharingSettingsId:n,subject:w.subject},{onSuccess(W){W?(r(!1),l(""),t==null||t(!1)):(r(!1),l(ku))},onError(){r(!1),l(ku)}})},isDisableDownloadSettings:!n||!p.isEnable,downloadCsvError:C,handleSubmit:u,isLoading:s,register:A,control:d,setValue:f,errors:g}},Cy={required:"Required"};({...Cy},{...Cy}),{...Cy};const mV={"tag-text":"_tag-text_677jk_7",inputFieldContainer:"_inputFieldContainer_677jk_21","tag-container":"_tag-container_677jk_29",important:"_important_677jk_45"},S_=({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:p,error:b})=>{const[w,T]=F0.useState(),[H,S]=F0.useState(""),N=I2=>{T(w==null?void 0:w.filter(r2=>r2!==I2)),s==null||s(w==null?void 0:w.filter(r2=>r2!==I2))},X=()=>{const I2=H.split(",").map(M2=>M2.trim()).filter(Boolean),r2=new Set;for(const M2 of I2){if(r2.has(M2)){g==null||g(`Duplicate ${(f==null?void 0:f.toLocaleLowerCase())||"value"} in input: "${M2}"`);return}if(w!=null&&w.includes(M2)){g==null||g(`"${M2}" already added`);return}if(A&&!A.test(M2)){g==null||g(`Invalid ${(f==null?void 0:f.toLocaleLowerCase())||"input"}: "${M2}"`);return}r2.add(M2)}const D2=[...w||[],...I2];T(D2),s==null||s(D2),S(""),g==null||g("")},W=I2=>{if(I2.key==="Enter"||I2.key==="Tab")I2.preventDefault(),X();else if(I2.key==="Backspace"&&(H==null?void 0:H.length)===0){T(D2=>(D2==null||D2.pop(),[...D2||[]])),w==null||w.pop();const r2=[...w||[]];s==null||s(r2)}},f2=()=>{X()};F0.useEffect(()=>{C&&Array.isArray(C)?T(C):T([])},[C]);const Q2=I2=>{const r2=I2.target.parentElement;r2.scrollLeft=r2.scrollWidth,S(I2.target.value),r==null||r(I2.target.value)};return F0.useEffect(()=>{g==null||g("")},[H]),h.jsx(NE,{name:o||"tags",control:n,defaultValue:"",render:({field:I2})=>{var M2,m2,k2,W2;const{ref:r2,...D2}=I2;return h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[a?h.jsxs(e6,{variant:"input-label",color:"primary",children:[a,l?h.jsx("span",{className:mV.important,children:"*"}):null]}):null,h.jsxs("div",{className:mV.inputFieldContainer,style:{width:u},id:`${(m2=(M2=a??t)==null?void 0:M2.replaceAll(" ","-"))==null?void 0:m2.toLowerCase()}-input`,"data-testid":`${(W2=(k2=a??t)==null?void 0:k2.replaceAll(" ","-"))==null?void 0:W2.toLowerCase()}-input`,children:[w!=null&&w.length?h.jsx("div",{className:mV["tag-container"],children:w==null?void 0:w.map(c0=>h.jsx(a8,{variant:"popover",type:"button",onClick:()=>N(c0),className:"dbn-flex dbn-font-semibold dbn-gap-2 dbn-px-2 dbn-py-1 dbn-bg-gray dbn-rounded",rightIcon:h.jsx(p8,{name:"cross",size:"xxs"}),children:h.jsx("span",{className:mV["tag-text"],children:c0})},c0))}):null,h.jsx("input",{...D2,type:"text",value:H,onChange:Q2,onKeyDown:W,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"} ${{...p}}`,onBlur:f2})]})]}),d&&h.jsx(bl,{text:d,variant:"error"}),!d&&b&&h.jsx(e6,{variant:"body-text-2",color:"alert",children:b})]})}})};w9.memo(S_);const ac={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:ku2,setPrototypeOf:Ou2,isFrozen:N70,getPrototypeOf:S70,getOwnPropertyDescriptor:V70}=Object;let{freeze:sc,seal:nd,create:Pu2}=Object,{apply:V_,construct:k_}=typeof Reflect<"u"&&Reflect;sc||(sc=function(n){return n}),nd||(nd=function(n){return n}),V_||(V_=function(n,i,o){return n.apply(i,o)}),k_||(k_=function(n,i){return new n(...i)});const bV=lc(Array.prototype.forEach),k70=lc(Array.prototype.lastIndexOf),Zu2=lc(Array.prototype.pop),mM=lc(Array.prototype.push),O70=lc(Array.prototype.splice),BV=lc(String.prototype.toLowerCase),O_=lc(String.prototype.toString),Fu2=lc(String.prototype.match),bM=lc(String.prototype.replace),P70=lc(String.prototype.indexOf),Z70=lc(String.prototype.trim),Yd=lc(Object.prototype.hasOwnProperty),Cc=lc(RegExp.prototype.test),BM=F70(TypeError);function lc(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 V_(t,n,o)}}function F70(t){return function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return k_(t,i)}}function nC(t,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:BV;Ou2&&Ou2(t,null);let o=n.length;for(;o--;){let a=n[o];if(typeof a=="string"){const s=i(a);s!==a&&(N70(n)||(n[o]=s),a=s)}t[a]=!0}return t}function U70(t){for(let n=0;n<t.length;n++)Yd(t,n)||(t[n]=null);return t}function hm(t){const n=Pu2(null);for(const[i,o]of ku2(t))Yd(t,i)&&(Array.isArray(o)?n[i]=U70(o):o&&typeof o=="object"&&o.constructor===Object?n[i]=hm(o):n[i]=o);return n}function yM(t,n){for(;t!==null;){const o=V70(t,n);if(o){if(o.get)return lc(o.get);if(typeof o.value=="function")return lc(o.value)}t=S70(t)}function i(){return null}return i}const Uu2=sc(["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"]),P_=sc(["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"]),Z_=sc(["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"]),j70=sc(["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"]),F_=sc(["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"]),z70=sc(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ju2=sc(["#text"]),zu2=sc(["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"]),U_=sc(["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"]),Gu2=sc(["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"]),yV=sc(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),G70=nd(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y70=nd(/<%[\w\W]*|[\w\W]*%>/gm),W70=nd(/\$\{[\w\W]*/gm),_70=nd(/^data-[\-\w.\u00B7-\uFFFF]+$/),X70=nd(/^aria-[\-\w]+$/),Yu2=nd(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),K70=nd(/^(?:\w+script|data):/i),J70=nd(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wu2=nd(/^html$/i),q70=nd(/^[a-z][.\w]*(-[.\w]+)+$/i);var _u2=Object.freeze({__proto__:null,ARIA_ATTR:X70,ATTR_WHITESPACE:J70,CUSTOM_ELEMENT:q70,DATA_ATTR:_70,DOCTYPE_NAME:Wu2,ERB_EXPR:Y70,IS_ALLOWED_URI:Yu2,IS_SCRIPT_OR_DATA:K70,MUSTACHE_EXPR:G70,TMPLIT_EXPR:W70});const LM={element:1,text:3,progressingInstruction:7,comment:8,document:9},$70=function(){return typeof window>"u"?null:window},e60=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}},Xu2=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ku2(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:$70();const n=G3=>Ku2(G3);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==LM.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,p=yM(g,"cloneNode"),b=yM(g,"remove"),w=yM(g,"nextSibling"),T=yM(g,"childNodes"),H=yM(g,"parentNode");if(typeof r=="function"){const G3=i.createElement("template");G3.content&&G3.content.ownerDocument&&(i=G3.content.ownerDocument)}let S,N="";const{implementation:X,createNodeIterator:W,createDocumentFragment:f2,getElementsByTagName:Q2}=i,{importNode:I2}=o;let r2=Xu2();n.isSupported=typeof ku2=="function"&&typeof H=="function"&&X&&X.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:D2,ERB_EXPR:M2,TMPLIT_EXPR:m2,DATA_ATTR:k2,ARIA_ATTR:W2,IS_SCRIPT_OR_DATA:c0,ATTR_WHITESPACE:p0,CUSTOM_ELEMENT:L0}=_u2;let{IS_ALLOWED_URI:b0}=_u2,j2=null;const t1=nC({},[...Uu2,...P_,...Z_,...F_,...ju2]);let h0=null;const O0=nC({},[...zu2,...U_,...Gu2,...yV]);let U0=Object.seal(Pu2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),X2=null,Q3=null,x1=!0,v3=!0,W3=!1,g7=!0,I3=!1,$3=!0,b7=!1,I7=!1,R6=!1,h6=!1,w3=!1,t0=!1,z3=!0,X7=!1;const Y7="user-content-";let l6=!0,c6=!1,H6={},I1=null;const l3=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 q3=null;const T7=nC({},["audio","video","img","source","image","track"]);let h7=null;const g3=nC({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),p7="http://www.w3.org/1998/Math/MathML",N7="http://www.w3.org/2000/svg",D7="http://www.w3.org/1999/xhtml";let j6=D7,q7=!1,M6=null;const C8=nC({},[p7,N7,D7],O_);let a9=nC({},["mi","mo","mn","ms","mtext"]),T8=nC({},["annotation-xml"]);const y9=nC({},["title","style","font","a","script"]);let O8=null;const O9=["application/xhtml+xml","text/html"],L8="text/html";let o5=null,W9=null;const p5=i.createElement("form"),v5=function(F3){return F3 instanceof RegExp||F3 instanceof Function},p4=function(){let F3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(W9&&W9===F3)){if((!F3||typeof F3!="object")&&(F3={}),F3=hm(F3),O8=O9.indexOf(F3.PARSER_MEDIA_TYPE)===-1?L8:F3.PARSER_MEDIA_TYPE,o5=O8==="application/xhtml+xml"?O_:BV,j2=Yd(F3,"ALLOWED_TAGS")?nC({},F3.ALLOWED_TAGS,o5):t1,h0=Yd(F3,"ALLOWED_ATTR")?nC({},F3.ALLOWED_ATTR,o5):O0,M6=Yd(F3,"ALLOWED_NAMESPACES")?nC({},F3.ALLOWED_NAMESPACES,O_):C8,h7=Yd(F3,"ADD_URI_SAFE_ATTR")?nC(hm(g3),F3.ADD_URI_SAFE_ATTR,o5):g3,q3=Yd(F3,"ADD_DATA_URI_TAGS")?nC(hm(T7),F3.ADD_DATA_URI_TAGS,o5):T7,I1=Yd(F3,"FORBID_CONTENTS")?nC({},F3.FORBID_CONTENTS,o5):l3,X2=Yd(F3,"FORBID_TAGS")?nC({},F3.FORBID_TAGS,o5):{},Q3=Yd(F3,"FORBID_ATTR")?nC({},F3.FORBID_ATTR,o5):{},H6=Yd(F3,"USE_PROFILES")?F3.USE_PROFILES:!1,x1=F3.ALLOW_ARIA_ATTR!==!1,v3=F3.ALLOW_DATA_ATTR!==!1,W3=F3.ALLOW_UNKNOWN_PROTOCOLS||!1,g7=F3.ALLOW_SELF_CLOSE_IN_ATTR!==!1,I3=F3.SAFE_FOR_TEMPLATES||!1,$3=F3.SAFE_FOR_XML!==!1,b7=F3.WHOLE_DOCUMENT||!1,h6=F3.RETURN_DOM||!1,w3=F3.RETURN_DOM_FRAGMENT||!1,t0=F3.RETURN_TRUSTED_TYPE||!1,R6=F3.FORCE_BODY||!1,z3=F3.SANITIZE_DOM!==!1,X7=F3.SANITIZE_NAMED_PROPS||!1,l6=F3.KEEP_CONTENT!==!1,c6=F3.IN_PLACE||!1,b0=F3.ALLOWED_URI_REGEXP||Yu2,j6=F3.NAMESPACE||D7,a9=F3.MATHML_TEXT_INTEGRATION_POINTS||a9,T8=F3.HTML_INTEGRATION_POINTS||T8,U0=F3.CUSTOM_ELEMENT_HANDLING||{},F3.CUSTOM_ELEMENT_HANDLING&&v5(F3.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U0.tagNameCheck=F3.CUSTOM_ELEMENT_HANDLING.tagNameCheck),F3.CUSTOM_ELEMENT_HANDLING&&v5(F3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U0.attributeNameCheck=F3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),F3.CUSTOM_ELEMENT_HANDLING&&typeof F3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(U0.allowCustomizedBuiltInElements=F3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),I3&&(v3=!1),w3&&(h6=!0),H6&&(j2=nC({},ju2),h0=[],H6.html===!0&&(nC(j2,Uu2),nC(h0,zu2)),H6.svg===!0&&(nC(j2,P_),nC(h0,U_),nC(h0,yV)),H6.svgFilters===!0&&(nC(j2,Z_),nC(h0,U_),nC(h0,yV)),H6.mathMl===!0&&(nC(j2,F_),nC(h0,Gu2),nC(h0,yV))),F3.ADD_TAGS&&(j2===t1&&(j2=hm(j2)),nC(j2,F3.ADD_TAGS,o5)),F3.ADD_ATTR&&(h0===O0&&(h0=hm(h0)),nC(h0,F3.ADD_ATTR,o5)),F3.ADD_URI_SAFE_ATTR&&nC(h7,F3.ADD_URI_SAFE_ATTR,o5),F3.FORBID_CONTENTS&&(I1===l3&&(I1=hm(I1)),nC(I1,F3.FORBID_CONTENTS,o5)),l6&&(j2["#text"]=!0),b7&&nC(j2,["html","head","body"]),j2.table&&(nC(j2,["tbody"]),delete X2.tbody),F3.TRUSTED_TYPES_POLICY){if(typeof F3.TRUSTED_TYPES_POLICY.createHTML!="function")throw BM('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F3.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw BM('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=F3.TRUSTED_TYPES_POLICY,N=S.createHTML("")}else S===void 0&&(S=e60(d,a)),S!==null&&typeof N=="string"&&(N=S.createHTML(""));sc&&sc(F3),W9=F3}},T1=nC({},[...P_,...Z_,...j70]),s9=nC({},[...F_,...z70]),S9=function(F3){let x7=H(F3);(!x7||!x7.tagName)&&(x7={namespaceURI:j6,tagName:"template"});const y7=BV(F3.tagName),Q6=BV(x7.tagName);return M6[F3.namespaceURI]?F3.namespaceURI===N7?x7.namespaceURI===D7?y7==="svg":x7.namespaceURI===p7?y7==="svg"&&(Q6==="annotation-xml"||a9[Q6]):!!T1[y7]:F3.namespaceURI===p7?x7.namespaceURI===D7?y7==="math":x7.namespaceURI===N7?y7==="math"&&T8[Q6]:!!s9[y7]:F3.namespaceURI===D7?x7.namespaceURI===N7&&!T8[Q6]||x7.namespaceURI===p7&&!a9[Q6]?!1:!s9[y7]&&(y9[y7]||!T1[y7]):!!(O8==="application/xhtml+xml"&&M6[F3.namespaceURI]):!1},g5=function(F3){mM(n.removed,{element:F3});try{H(F3).removeChild(F3)}catch{b(F3)}},n5=function(F3,x7){try{mM(n.removed,{attribute:x7.getAttributeNode(F3),from:x7})}catch{mM(n.removed,{attribute:null,from:x7})}if(x7.removeAttribute(F3),F3==="is")if(h6||w3)try{g5(x7)}catch{}else try{x7.setAttribute(F3,"")}catch{}},Y5=function(F3){let x7=null,y7=null;if(R6)F3="<remove></remove>"+F3;else{const N6=Fu2(F3,/^[\r\n\t ]+/);y7=N6&&N6[0]}O8==="application/xhtml+xml"&&j6===D7&&(F3='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F3+"</body></html>");const Q6=S?S.createHTML(F3):F3;if(j6===D7)try{x7=new f().parseFromString(Q6,O8)}catch{}if(!x7||!x7.documentElement){x7=X.createDocument(j6,"template",null);try{x7.documentElement.innerHTML=q7?N:Q6}catch{}}const T6=x7.body||x7.documentElement;return F3&&y7&&T6.insertBefore(i.createTextNode(y7),T6.childNodes[0]||null),j6===D7?Q2.call(x7,b7?"html":"body")[0]:b7?x7.documentElement:T6},r5=function(F3){return W.call(F3.ownerDocument||F3,F3,e.SHOW_ELEMENT|e.SHOW_COMMENT|e.SHOW_TEXT|e.SHOW_PROCESSING_INSTRUCTION|e.SHOW_CDATA_SECTION,null)},E3=function(F3){return F3 instanceof A&&(typeof F3.nodeName!="string"||typeof F3.textContent!="string"||typeof F3.removeChild!="function"||!(F3.attributes instanceof u)||typeof F3.removeAttribute!="function"||typeof F3.setAttribute!="function"||typeof F3.namespaceURI!="string"||typeof F3.insertBefore!="function"||typeof F3.hasChildNodes!="function")},D8=function(F3){return typeof C=="function"&&F3 instanceof C};function o7(G3,F3,x7){bV(G3,y7=>{y7.call(n,F3,x7,W9)})}const j7=function(F3){let x7=null;if(o7(r2.beforeSanitizeElements,F3,null),E3(F3))return g5(F3),!0;const y7=o5(F3.nodeName);if(o7(r2.uponSanitizeElement,F3,{tagName:y7,allowedTags:j2}),F3.hasChildNodes()&&!D8(F3.firstElementChild)&&Cc(/<[/\w]/g,F3.innerHTML)&&Cc(/<[/\w]/g,F3.textContent)||F3.nodeType===LM.progressingInstruction||$3&&F3.nodeType===LM.comment&&Cc(/<[/\w]/g,F3.data))return g5(F3),!0;if(!j2[y7]||X2[y7]){if(!X2[y7]&&s6(y7)&&(U0.tagNameCheck instanceof RegExp&&Cc(U0.tagNameCheck,y7)||U0.tagNameCheck instanceof Function&&U0.tagNameCheck(y7)))return!1;if(l6&&!I1[y7]){const Q6=H(F3)||F3.parentNode,T6=T(F3)||F3.childNodes;if(T6&&Q6){const N6=T6.length;for(let M3=N6-1;M3>=0;--M3){const D9=p(T6[M3],!0);D9.__removalCount=(F3.__removalCount||0)+1,Q6.insertBefore(D9,w(F3))}}}return g5(F3),!0}return F3 instanceof l&&!S9(F3)||(y7==="noscript"||y7==="noembed"||y7==="noframes")&&Cc(/<\/no(script|embed|frames)/i,F3.innerHTML)?(g5(F3),!0):(I3&&F3.nodeType===LM.text&&(x7=F3.textContent,bV([D2,M2,m2],Q6=>{x7=bM(x7,Q6," ")}),F3.textContent!==x7&&(mM(n.removed,{element:F3.cloneNode()}),F3.textContent=x7)),o7(r2.afterSanitizeElements,F3,null),!1)},p6=function(F3,x7,y7){if(z3&&(x7==="id"||x7==="name")&&(y7 in i||y7 in p5))return!1;if(!(v3&&!Q3[x7]&&Cc(k2,x7))){if(!(x1&&Cc(W2,x7))){if(!h0[x7]||Q3[x7]){if(!(s6(F3)&&(U0.tagNameCheck instanceof RegExp&&Cc(U0.tagNameCheck,F3)||U0.tagNameCheck instanceof Function&&U0.tagNameCheck(F3))&&(U0.attributeNameCheck instanceof RegExp&&Cc(U0.attributeNameCheck,x7)||U0.attributeNameCheck instanceof Function&&U0.attributeNameCheck(x7))||x7==="is"&&U0.allowCustomizedBuiltInElements&&(U0.tagNameCheck instanceof RegExp&&Cc(U0.tagNameCheck,y7)||U0.tagNameCheck instanceof Function&&U0.tagNameCheck(y7))))return!1}else if(!h7[x7]){if(!Cc(b0,bM(y7,p0,""))){if(!((x7==="src"||x7==="xlink:href"||x7==="href")&&F3!=="script"&&P70(y7,"data:")===0&&q3[F3])){if(!(W3&&!Cc(c0,bM(y7,p0,"")))){if(y7)return!1}}}}}}return!0},s6=function(F3){return F3!=="annotation-xml"&&Fu2(F3,L0)},u6=function(F3){o7(r2.beforeSanitizeAttributes,F3,null);const{attributes:x7}=F3;if(!x7||E3(F3))return;const y7={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:h0,forceKeepAttr:void 0};let Q6=x7.length;for(;Q6--;){const T6=x7[Q6],{name:N6,namespaceURI:M3,value:D9}=T6,h8=o5(N6);let t9=N6==="value"?D9:Z70(D9);if(y7.attrName=h8,y7.attrValue=t9,y7.keepAttr=!0,y7.forceKeepAttr=void 0,o7(r2.uponSanitizeAttribute,F3,y7),t9=y7.attrValue,X7&&(h8==="id"||h8==="name")&&(n5(N6,F3),t9=Y7+t9),$3&&Cc(/((--!?|])>)|<\/(style|title)/i,t9)){n5(N6,F3);continue}if(y7.forceKeepAttr||(n5(N6,F3),!y7.keepAttr))continue;if(!g7&&Cc(/\/>/i,t9)){n5(N6,F3);continue}I3&&bV([D2,M2,m2],r9=>{t9=bM(t9,r9," ")});const o8=o5(F3.nodeName);if(p6(o8,h8,t9)){if(S&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!M3)switch(d.getAttributeType(o8,h8)){case"TrustedHTML":{t9=S.createHTML(t9);break}case"TrustedScriptURL":{t9=S.createScriptURL(t9);break}}try{M3?F3.setAttributeNS(M3,N6,t9):F3.setAttribute(N6,t9),E3(F3)?g5(F3):Zu2(n.removed)}catch{}}}o7(r2.afterSanitizeAttributes,F3,null)},v7=function G3(F3){let x7=null;const y7=r5(F3);for(o7(r2.beforeSanitizeShadowDOM,F3,null);x7=y7.nextNode();)o7(r2.uponSanitizeShadowNode,x7,null),j7(x7),u6(x7),x7.content instanceof s&&G3(x7.content);o7(r2.afterSanitizeShadowDOM,F3,null)};return n.sanitize=function(G3){let F3=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x7=null,y7=null,Q6=null,T6=null;if(q7=!G3,q7&&(G3="<!-->"),typeof G3!="string"&&!D8(G3))if(typeof G3.toString=="function"){if(G3=G3.toString(),typeof G3!="string")throw BM("dirty is not a string, aborting")}else throw BM("toString is not a function");if(!n.isSupported)return G3;if(I7||p4(F3),n.removed=[],typeof G3=="string"&&(c6=!1),c6){if(G3.nodeName){const D9=o5(G3.nodeName);if(!j2[D9]||X2[D9])throw BM("root node is forbidden and cannot be sanitized in-place")}}else if(G3 instanceof C)x7=Y5("<!---->"),y7=x7.ownerDocument.importNode(G3,!0),y7.nodeType===LM.element&&y7.nodeName==="BODY"||y7.nodeName==="HTML"?x7=y7:x7.appendChild(y7);else{if(!h6&&!I3&&!b7&&G3.indexOf("<")===-1)return S&&t0?S.createHTML(G3):G3;if(x7=Y5(G3),!x7)return h6?null:t0?N:""}x7&&R6&&g5(x7.firstChild);const N6=r5(c6?G3:x7);for(;Q6=N6.nextNode();)j7(Q6),u6(Q6),Q6.content instanceof s&&v7(Q6.content);if(c6)return G3;if(h6){if(w3)for(T6=f2.call(x7.ownerDocument);x7.firstChild;)T6.appendChild(x7.firstChild);else T6=x7;return(h0.shadowroot||h0.shadowrootmode)&&(T6=I2.call(o,T6,!0)),T6}let M3=b7?x7.outerHTML:x7.innerHTML;return b7&&j2["!doctype"]&&x7.ownerDocument&&x7.ownerDocument.doctype&&x7.ownerDocument.doctype.name&&Cc(Wu2,x7.ownerDocument.doctype.name)&&(M3="<!DOCTYPE "+x7.ownerDocument.doctype.name+`>
|
|
597
|
+
`)).length,a=0;a<o;a++){var r=t.charCodeAt(a),C=null;r<128?i++:C=r>127&&r<2048?String.fromCharCode(r>>6|192,63&r|128):String.fromCharCode(r>>12|224,r>>6&63|128,63&r|128),Hp(C)||(i>n&&(s+=t.substring(n,i)),s+=C,n=i=a+1)}return i>n&&(s+=t.substring(n,t.length)),s},r10=!!dW||!!fW,ou2="text/plain",uV=(t,n)=>{var[i,o]=t.split("?"),a=S4({},n);o==null||o.split("&").forEach(r=>{var[C]=r.split("=");delete a[C]});var s=T20(a);return s=s?(o?o+"&":"")+s:o,"".concat(i,"?").concat(s)},hM=(t,n)=>JSON.stringify(t,(i,o)=>typeof o=="bigint"?o.toString():o,n),p_=t=>{var{data:n,compression:i}=t;if(n){if(i===Ud.GZipJS){var o=il2(ol2(hM(n)),{mtime:0}),a=new Blob([o],{type:ou2});return{contentType:ou2,body:a,estimatedSize:a.size}}if(i===Ud.Base64){var s=function(l){var e,u,A,f,d,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p=0,b=0,w="",T=[];if(!l)return l;l=t10(l);do e=(d=l.charCodeAt(p++)<<16|l.charCodeAt(p++)<<8|l.charCodeAt(p++))>>18&63,u=d>>12&63,A=d>>6&63,f=63&d,T[b++]=g.charAt(e)+g.charAt(u)+g.charAt(A)+g.charAt(f);while(p<l.length);switch(w=T.join(""),l.length%3){case 1:w=w.slice(0,-2)+"==";break;case 2:w=w.slice(0,-1)+"="}return w}(hM(n)),r=(l=>"data="+encodeURIComponent(typeof l=="string"?l:hM(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var C=hM(n);return{contentType:"application/json",body:C,estimatedSize:new Blob([C]).size}}},EM=[];fW&&EM.push({transport:"fetch",method:t=>{var n,i,{contentType:o,body:a,estimatedSize:s}=(n=p_(t))!==null&&n!==void 0?n:{},r=new Headers;ol(t.headers,function(u,A){r.append(A,u)}),o&&r.append("Content-Type",o);var C=t.url,l=null;if(qs2){var e=new qs2;l={signal:e.signal,timeout:setTimeout(()=>e.abort(),t.timeout)}}fW(C,S4({method:(t==null?void 0:t.method)||"GET",headers:r,keepalive:t.method==="POST"&&(s||0)<52428.8,body:a,signal:(i=l)===null||i===void 0?void 0:i.signal},t.fetchOptions)).then(u=>u.text().then(A=>{var f,d={statusCode:u.status,text:A};if(u.status===200)try{d.json=JSON.parse(A)}catch(g){zi.error(g)}(f=t.callback)===null||f===void 0||f.call(t,d)})).catch(u=>{var A;zi.error(u),(A=t.callback)===null||A===void 0||A.call(t,{statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),dW&&EM.push({transport:"XHR",method:t=>{var n,i=new dW;i.open(t.method||"GET",t.url,!0);var{contentType:o,body:a}=(n=p_(t))!==null&&n!==void 0?n:{};ol(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)}}),uf!=null&&uf.sendBeacon&&EM.push({transport:"sendBeacon",method:t=>{var n=uV(t.url,{beacon:"1"});try{var i,{contentType:o,body:a}=(i=p_(t))!==null&&i!==void 0?i:{},s=typeof a=="string"?new Blob([a],{type:o}):a;uf.sendBeacon(n,s)}catch{}}});var v_=3e3;class n10{constructor(n,i){kt(this,"isPaused",!0),kt(this,"queue",[]),this.flushTimeoutMs=qf((i==null?void 0:i.flush_interval_ms)||v_,250,5e3,"flush interval",v_),this.sendRequest=n}enqueue(n){this.queue.push(n),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var n=this.queue.length>0?this.formatQueue():{},i=Object.values(n),o=[...i.filter(a=>a.url.indexOf("/e")===0),...i.filter(a=>a.url.indexOf("/e")!==0)];o.map(a=>{this.sendRequest(S4(S4({},a),{},{transport:"sendBeacon"}))})}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var n=this;this.isPaused||(this.flushTimeout=setTimeout(()=>{if(this.clearFlushTimeout(),this.queue.length>0){var i=this.formatQueue(),o=function(s){var r=i[s],C=new Date().getTime();r.data&&Fl(r.data)&&ol(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 ol(this.queue,i=>{var o,a=i,s=(a?a.batchKey:null)||a.url;wr(n[s])&&(n[s]=S4(S4({},a),{},{data:[]})),(o=n[s].data)===null||o===void 0||o.push(a.data)}),this.queue=[],n}}var i10=["retriesPerformedSoFar"];class o10{constructor(n){kt(this,"isPolling",!1),kt(this,"pollIntervalMs",3e3),kt(this,"queue",[]),this.instance=n,this.queue=[],this.areWeOnline=!0,!wr(c4)&&"onLine"in c4.navigator&&(this.areWeOnline=c4.navigator.onLine,$l(c4,"online",()=>{this.areWeOnline=!0,this.flush()}),$l(c4,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(n){var{retriesPerformedSoFar:i}=n,o=iC2(n,i10);nc(i)&&i>0&&(o.url=uV(o.url,{retry_count:i})),this.instance._send_request(S4(S4({},o),{},{callback:a=>{var s;a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(i??0)<10?this.enqueue(S4({retriesPerformedSoFar:i},o)):(s=o.callback)===null||s===void 0||s.call(o,a)}}))}enqueue(n){var i=n.retriesPerformedSoFar||0;n.retriesPerformedSoFar=i+1;var o=function(r){var C=3e3*Math.pow(2,r),l=C/2,e=Math.min(18e5,C),u=(Math.random()-.5)*(e-l);return Math.ceil(e+u)}(i),a=Date.now()+o;this.queue.push({retryAt:a,requestOptions:n});var s="Enqueued failed request for retry in ".concat(o);navigator.onLine||(s+=" (Browser is offline)"),zi.warn(s),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout(()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()},this.pollIntervalMs)}flush(){var n=Date.now(),i=[],o=this.queue.filter(s=>s.retryAt<n||(i.push(s),!1));if(this.queue=i,o.length>0)for(var{requestOptions:a}of o)this.retriableRequest(a)}unload(){for(var{requestOptions:n}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(S4(S4({},n),{},{transport:"sendBeacon"}))}catch(i){zi.error(i)}this.queue=[]}}class a10{constructor(n){kt(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(c4,"scroll",this._updateScrollData,{capture:!0}),$l(c4,"scrollend",this._updateScrollData,{capture:!0}),$l(c4,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return c4==null?void 0:c4.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=c4==null?void 0:c4.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 c4&&(c4.scrollY||c4.pageYOffset||c4.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var n=this.scrollElement();return n&&n.scrollLeft||0}return c4&&(c4.scrollX||c4.pageXOffset||c4.document.documentElement.scrollLeft)||0}}var s10=t=>Ml.personInfo({maskPersonalDataProperties:t==null?void 0:t.config.mask_personal_data_properties,customPersonalDataProperties:t==null?void 0:t.config.custom_personal_data_properties});class C10{constructor(n,i,o,a){kt(this,"_onSessionIdCallback",s=>{var r=this._getStored();if(!r||r.sessionId!==s){var C={sessionId:s,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[yW]:C})}}),this.instance=n,this._sessionIdManager=i,this._persistence=o,this._sessionSourceParamGenerator=a||s10,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[yW]}getSetOnceProps(){var n,i=(n=this._getStored())===null||n===void 0?void 0:n.props;return i?"r"in i?Ml.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 ol($Q(this.getSetOnceProps()),(i,o)=>{o==="$current_url"&&(o="url"),n["$session_entry_".concat(hW(o))]=i}),n}}var au2=DA("[SessionId]");class l10{constructor(n,i,o){var a;if(kt(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||Vp,this._windowIdGenerator=o||Vp;var s=this.config.persistence_name||this.config.token,r=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*qf(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=nA.parse(this._window_id_storage_key),l=nA.parse(this._primary_window_exists_storage_key);C&&!l?this._windowId=C:nA.remove(this._window_id_storage_key),nA.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){au2.error("Invalid sessionID in bootstrap",u)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(n){return wr(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&&nA.is_supported()}_setWindowId(n){n!==this._windowId&&(this._windowId=n,this._canUseSessionStorage()&&nA.set(this._window_id_storage_key,n))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?nA.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({[kS]:[i,n,o]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var n=this.persistence.props[kS];return Fl(n)&&n.length===2&&n.push(n[0]),n||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){$l(c4,"beforeunload",()=>{this._canUseSessionStorage()&&nA.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=nc(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(),au2.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 u10=["$set_once","$set"],Pp=DA("[SiteApps]");class A10{constructor(n){this.instance=n,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(n,i){if(i){var o=this.globalsForEvent(i);this.bufferedInvocations.push(o),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var n,i;return(n=Zs._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(i=n[this.instance.config.token])===null||i===void 0?void 0:i.siteApps}init(){if(this.isEnabled){var n=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{n(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(n){var i,o,a,s,r,C,l;if(!n)throw new Error("Event payload is required");var e={},u=this.instance.get_property("$groups")||[],A=this.instance.get_property("$stored_group_properties")||{};for(var[f,d]of Object.entries(A))e[f]={id:u[f],type:f,properties:d};var{$set_once:g,$set:p}=n;return{event:S4(S4({},iC2(n,u10)),{},{properties:S4(S4(S4({},n.properties),p?{$set:S4(S4({},(i=(o=n.properties)===null||o===void 0?void 0:o.$set)!==null&&i!==void 0?i:{}),p)}:{}),g?{$set_once:S4(S4({},(a=(s=n.properties)===null||s===void 0?void 0:s.$set_once)!==null&&a!==void 0?a:{}),g)}:{}),elements_chain:(r=(C=n.properties)===null||C===void 0?void 0:C.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(l=n.properties)===null||l===void 0?void 0:l.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:e}}setupSiteApp(n){var i=this.apps[n.id],o=()=>{var C;!i.errored&&this.bufferedInvocations.length&&(Pp.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,Pp.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){Pp.error("Error while initializing PostHog app with config id ".concat(n.id),C),s(!1)}if(a&&i.loaded)try{o()}catch(C){Pp.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){Pp.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 Pp.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((o=this.stopBuffering)===null||o===void 0||o.call(this),(a=n.siteApps)!==null&&a!==void 0&&a.length)if(this.isEnabled){var r=function(e,u){var A,f;Zs["__$$ph_site_app_".concat(e)]=s.instance,(A=Zs.__PosthogExtensions__)===null||A===void 0||(f=A.loadSiteApp)===null||f===void 0||f.call(A,s.instance,u,d=>{if(d)return Pp.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 Pp.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var gm,c10=["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"],su2=function(t,n){if(!t)return!1;var i=t.toLowerCase();return c10.concat(n||[]).some(o=>{var a=o.toLowerCase();return i.indexOf(a)!==-1})},Cu2=function(t,n){if(!t)return!1;var i=t.userAgent;if(i&&su2(i,n))return!0;try{var o=t==null?void 0:t.userAgentData;if(o!=null&&o.brands&&o.brands.some(a=>su2(a==null?void 0:a.brand,n)))return!0}catch{}return!!t.webdriver};function I_(t,n,i){return hM({distinct_id:t,userPropertiesToSet:n,userPropertiesToSetOnce:i})}(function(t){t.US="us",t.EU="eu",t.CUSTOM="custom"})(gm||(gm={}));var lu2="i.posthog.com";class f10{constructor(n){kt(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(lu2),".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]=gm.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=gm.EU:this._regionCache[this.apiHost]=gm.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===gm.CUSTOM)return this.apiHost+i;var o=lu2+i;switch(n){case"assets":return"https://".concat(this.region,"-assets.").concat(o);case"api":return"https://".concat(this.region,".").concat(o)}}}var d10={icontains:(t,n)=>!!c4&&n.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,n)=>!!c4&&n.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,n)=>!!c4&&iy(n.href,t),not_regex:(t,n)=>!!c4&&!iy(n.href,t),exact:(t,n)=>n.href===t,is_not:(t,n)=>n.href!==t};class SA{constructor(n){var i=this;kt(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var o=arguments.length>0&&arguments[0]!==void 0&&arguments[0];i.getWebExperiments(a=>{SA.logInfo("retrieved web experiments from the server"),i._flagToExperiments=new Map,a.forEach(s=>{if(s.feature_flag_key){var r;i._flagToExperiments&&(SA.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];SA.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())SA.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(rl(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();SA.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=SA.getWindowLocation();if(n!=null&&n.search){var i=GS(n==null?void 0:n.search,"__experiment_id"),o=GS(n==null?void 0:n.search,"__experiment_variant");i&&o&&(SA.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&&(SA.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!rl(n.conditions)&&SA.matchUrlConditions(n)&&SA.matchUTMConditions(n)}static matchUrlConditions(n){var i;if(rl(n.conditions)||rl((i=n.conditions)===null||i===void 0?void 0:i.url))return!0;var o,a,s,r=SA.getWindowLocation();return!!r&&((o=n.conditions)===null||o===void 0||!o.url||d10[(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 c4==null?void 0:c4.location}static matchUTMConditions(n){var i;if(rl(n.conditions)||rl((i=n.conditions)===null||i===void 0?void 0:i.utm))return!0;var o=Ml.campaignParams();if(o.utm_source){var a,s,r,C,l,e,u,A,f,d,g,p,b,w,T,H,S=(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,N=(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||(p=g.utm)===null||p===void 0?void 0:p.utm_medium)==o.utm_medium,W=(b=n.conditions)===null||b===void 0||(w=b.utm)===null||w===void 0||!w.utm_term||((T=n.conditions)===null||T===void 0||(H=T.utm)===null||H===void 0?void 0:H.utm_term)==o.utm_term;return S&&X&&W&&N}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];zi.info("[WebExperiments] ".concat(n),o)}applyTransforms(n,i,o){this._is_bot()?SA.logInfo("Refusing to render web experiment since the viewer is a likely bot"):i!=="control"?o.forEach(a=>{if(a.selector){var s;SA.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)})}}):SA.logInfo("Control variants leave the page unmodified.")}_is_bot(){return uf&&this.instance?Cu2(uf,this.instance.config.custom_blocked_useragents):void 0}}var pM={},m_=()=>{},oy="posthog",uu2=!r10&&(cu==null?void 0:cu.indexOf("MSIE"))===-1&&(cu==null?void 0:cu.indexOf("Mozilla"))===-1,Au2=()=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:v20(Pn==null?void 0:Pn.location),persistence:"localStorage+cookie",persistence_name:"",loaded:m_,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:Jf&&fu(Jf==null?void 0:Jf.search)&&Jf.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:(c4==null||(t=c4.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;zi.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:v_},_onCapture:m_}},cu2=t=>{var n={};wr(t.process_person)||(n.person_profiles=t.process_person),wr(t.xhr_headers)||(n.request_headers=t.xhr_headers),wr(t.cookie_name)||(n.persistence_name=t.cookie_name),wr(t.disable_cookie)||(n.disable_persistence=t.disable_cookie),wr(t.store_google)||(n.save_campaign_params=t.store_google),wr(t.verbose)||(n.debug=t.verbose);var i=du({},n,t);return Fl(t.property_blacklist)&&(wr(t.property_denylist)?i.property_denylist=t.property_blacklist:Fl(t.property_denylist)?i.property_denylist=[...t.property_blacklist,...t.property_denylist]:zi.error("Invalid value for property_denylist config: "+t.property_denylist)),i};class g10{constructor(){kt(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(n){zi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=n}}class AV{get decideEndpointWasHit(){var n,i;return(n=(i=this.featureFlags)===null||i===void 0?void 0:i.hasLoadedFlags)!==null&&n!==void 0&&n}constructor(){kt(this,"webPerformance",new g10),kt(this,"_personProcessingSetOncePropertiesSent",!1),kt(this,"version",$h.LIB_VERSION),kt(this,"_internalEventEmitter",new tu2),this.config=Au2(),this.SentryIntegration=B00,this.sentryIntegration=n=>function(i,o){var a=ul2(i,o);return{name:ll2,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 z00(this),this.toolbar=new L00(this),this.scrollManager=new a10(this),this.pageViewManager=new R00(this),this.surveys=new q00(this),this.experiments=new SA(this),this.exceptions=new H00(this),this.rateLimiter=new $00(this),this.requestRouter=new f10(this),this.consent=new U20(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=>zi.info('send "'.concat(n==null?void 0:n.event,'"'),n))}init(n,i,o){if(o&&o!==oy){var a,s=(a=pM[o])!==null&&a!==void 0?a:new AV;return s._init(n,i,o),pM[o]=s,pM[oy][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(wr(n)||EW(n))return zi.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 zi.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({},Au2(),cu2(a),{name:s,token:n})),this.config.on_xhr_error&&zi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=a.disable_compression?void 0:Ud.GZipJS,this.persistence=new l_(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new l_(S4(S4({},this.config),{},{persistence:"sessionStorage"}));var r=S4({},this.persistence.props),C=S4({},this.sessionPersistence.props);if(this._requestQueue=new n10(w=>this._send_retriable_request(w),this.config.request_queue_config),this._retryQueue=new o10(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new l10(this),this.sessionPropsManager=new C10(this,this.sessionManager,this.persistence)),new Q00(this).startIfEnabledOrStop(),this.siteApps=new A10(this),(i=this.siteApps)===null||i===void 0||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new m00(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new D20(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new x00(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new M00(this),this.exceptionObserver=new G20(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new ZC2(this,z20),this.deadClicksAutocapture.startIfEnabled(),$h.DEBUG=$h.DEBUG||this.config.debug,$h.DEBUG&&zi.info("Starting in debug mode",{this:this,config:a,thisC:S4({},this.config),p:r,s:C}),this._sync_opt_out_with_persistence(),((o=a.bootstrap)===null||o===void 0?void 0:o.distinctID)!==void 0){var l,e,u=this.config.get_device_id(Vp()),A=(l=a.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?u:a.bootstrap.distinctID;this.persistence.set_property(eE,(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 T,H;return!((T=a.bootstrap)===null||T===void 0||(H=T.featureFlags)===null||H===void 0||!H[w])}).reduce((w,T)=>{var H,S;return w[T]=((H=a.bootstrap)===null||H===void 0||(S=H.featureFlags)===null||S===void 0?void 0:S[T])||!1,w},{}),p=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlagPayloads)||{}).filter(w=>g[w]).reduce((w,T)=>{var H,S,N,X;return(H=a.bootstrap)!==null&&H!==void 0&&(S=H.featureFlagPayloads)!==null&&S!==void 0&&S[T]&&(w[T]=(N=a.bootstrap)===null||N===void 0||(X=N.featureFlagPayloads)===null||X===void 0?void 0:X[T]),w},{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:p})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:mC2,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Vp());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(eE,"anonymous")}return $l(c4,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),a.segment?b00(this,()=>this._loaded()):this._loaded(),jd(this.config._onCapture)&&this.config._onCapture!==m_&&(zi.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(!Pn||!Pn.body)return zi.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,Ud.GZipJS)?Ud.GZipJS:rC(n.supportedCompression,Ud.Base64)?Ud.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){zi.critical("`loaded` function failed",n)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new e10(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()||Np(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&&(uu2?this.__request_queue.push(n):this.rateLimiter.isServerRateLimited(n.batchKey)||(n.transport=n.transport||this.config.api_transport,n.url=uV(n.url,{ip:this.config.ip?1:0}),n.headers=S4({},this.config.request_headers),n.compression=n.compression==="best-available"?this.compression:n.compression,n.fetchOptions=n.fetchOptions||this.config.fetch_options,(i=>{var o,a,s,r=S4({},i);r.timeout=r.timeout||6e4,r.url=uV(r.url,{_:new Date().getTime().toString(),ver:$h.LIB_VERSION,compression:r.compression});var C=(o=r.transport)!==null&&o!==void 0?o:"fetch",l=(a=(s=aC2(EM,e=>e.transport===C))===null||s===void 0?void 0:s.method)!==null&&a!==void 0?a:EM[0].method;if(!l)throw new Error("No available transport method");l(r)})(S4(S4({},n),{},{callback:i=>{var o,a,s;this.rateLimiter.checkForLimiting(i),i.statusCode>=400&&((a=(s=this.config).on_request_error)===null||a===void 0||a.call(s,i)),(o=n.callback)===null||o===void 0||o.call(n,i)}}))))}_send_retriable_request(n){this._retryQueue?this._retryQueue.retriableRequest(n):this._send_request(n)}_execute_array(n){var i,o=[],a=[],s=[];Np(n,C=>{C&&(i=C[0],Fl(i)?s.push(C):jd(C)?C.call(this):Fl(C)&&i==="alias"?o.push(C):Fl(C)&&i.indexOf("capture")!==-1&&jd(this[i])?s.push(C):a.push(C))});var r=function(C,l){Np(C,function(e){if(Fl(e[0])){var u=l;ol(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(!wr(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)&&(zi.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=Vp(),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=E20(e,o!=null&&o._noTruncate?null:this.config.properties_string_max_length)).timestamp=C,wr(o==null?void 0:o.timestamp)||(e.properties.$event_time_override_provided=!0,e.properties.$event_time_override_system_time=r);var A=S4(S4({},e.properties.$set),e.$set);if(WB(A)||this.setPersonPropertiesForFlags(A),!rl(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}zi.critical("This capture call is ignored due to client rate limiting.")}}else zi.error("No event name provided to posthog.capture")}else zi.uninitializedWarning("posthog.capture")}_addCaptureHook(n){return this.on("eventCaptured",i=>n(i.event,i))}_calculate_event_properties(n,i,o,a){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return i;var s=this.persistence.remove_event_timer(n),r=S4({},i);if(r.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(r.$cookieless_mode=!0),n==="$snapshot"){var C=S4(S4({},this.persistence.properties()),this.sessionPersistence.properties());return r.distinct_id=C.distinct_id,(!fu(r.distinct_id)&&!nc(r.distinct_id)||EW(r.distinct_id))&&zi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),r}var l,e=Ml.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===gm.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"&&Pn&&(r.title=Pn.title),!wr(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)?ol(this.config.property_denylist,function(w){delete r[w]}):zi.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(zi.error("sanitize_properties is deprecated. Use before_send instead"),r=p(r,n));var b=this._hasPersonProcessing();return r.$process_person_profile=b,b&&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&&(zi.error("sanitize_properties is deprecated. Use before_send instead"),s=r(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,WB(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 zi.uninitializedWarning("posthog.identify");if(nc(n)&&(n=n.toString(),zi.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()))zi.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(eM)&&(this.unregister(eM),this.register({distinct_id:n}));var r=(this.persistence.get_property(eE)||"anonymous")==="anonymous";n!==a&&r?(this.persistence.set_property(eE,"identified"),this.setPersonPropertiesForFlags(S4(S4({},o||{}),i||{}),!1),this.capture("$identify",{distinct_id:n,$anon_distinct_id:a},{$set:i||{},$set_once:o||{}}),this.featureFlags.setAnonymousDistinctId(a),this._cachedIdentify=I_(n,i,o)):(i||o)&&(this._cachedIdentify!==I_(n,i,o)?(this.setPersonProperties(i,o),this._cachedIdentify=I_(n,i,o)):zi.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),n!==a&&(this.reloadFeatureFlags(),this.unregister(ZS))}}else zi.error("Unique user id has not been set in posthog.identify")}setPersonProperties(n,i){(n||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(S4(S4({},i||{}),n||{})),this.capture("$set",{$set:n||{},$set_once:i||{}}))}group(n,i,o){if(n&&i){if(this._requirePersonProcessing("posthog.group")){var a=this.getGroups();a[n]!==i&&this.resetGroupPropertiesForFlags(n),this.register({$groups:S4(S4({},a),{},{[n]:i})}),o&&(this.capture("$groupidentify",{$group_type:n,$group_key:i,$group_set:o}),this.setGroupPropertiesForFlags({[n]:o})),a[n]===i||o||this.reloadFeatureFlags()}}else zi.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(zi.info("reset"),!this.__loaded)return zi.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(eE,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:mC2,$device_id:null},"");else{var C=this.config.get_device_id(Vp());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(sC2)?(zi.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(wr(i)&&(i=this.get_distinct_id()),n!==i?(this._register_single(eM,n),this.capture("$create_alias",{alias:n,distinct_id:i})):(zi.warn("alias matches current distinct_id - skipping api call."),this.identify(n),-1)):void 0}set_config(n){var i,o,a,s,r=S4({},this.config);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 l_(S4(S4({},this.config),{},{persistence:"sessionStorage"})),Qu.is_supported()&&Qu.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&($h.DEBUG=!0,zi.info("set_config",JSON.stringify({config:n,oldConfig:r,newConfig:S4({},this.config)},null,2))),(o=this.sessionRecording)===null||o===void 0||o.startIfEnabledOrStop(),(a=this.autocapture)===null||a===void 0||a.startIfEnabled(),(s=this.heatmaps)===null||s===void 0||s.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(n){var i=n===!0,o={sampling:i||!(n==null||!n.sampling),linked_flag:i||!(n==null||!n.linked_flag),url_trigger:i||!(n==null||!n.url_trigger),event_trigger:i||!(n==null||!n.event_trigger)};if(Object.values(o).some(Boolean)){var a,s,r,C,l;(a=this.sessionManager)===null||a===void 0||a.checkAndGetSessionAndWindowId(),o.sampling&&((s=this.sessionRecording)===null||s===void 0||s.overrideSampling()),o.linked_flag&&((r=this.sessionRecording)===null||r===void 0||r.overrideLinkedFlag()),o.url_trigger&&((C=this.sessionRecording)===null||C===void 0||C.overrideTrigger("url")),o.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var n;return!((n=this.sessionRecording)===null||n===void 0||!n.started)}captureException(n,i){var o=new Error("PostHog syntheticException");this.exceptions.sendExceptionEvent(S4(S4({},n00((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:oy;return i!==oy&&(i=oy+"."+i),i}_isIdentified(){var n,i;return((n=this.persistence)===null||n===void 0?void 0:n.get_property(eE))==="identified"||((i=this.sessionPersistence)===null||i===void 0?void 0:i.get_property(eE))==="identified"}_hasPersonProcessing(){var n,i,o,a;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&WB(this.getGroups())&&((n=this.persistence)===null||n===void 0||(i=n.props)===null||i===void 0||!i[eM])&&((o=this.persistence)===null||o===void 0||(a=o.props)===null||a===void 0||!a[FS]))}_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"?(zi.error(n+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(FS,!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(),(wr(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 uf?Cu2(uf,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Pn&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:Pn.title},{send_instantly:!0}))}debug(n){n===!1?(c4==null||c4.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(c4==null||c4.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(rl(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),rl(o)){var s="Event '".concat(n.event,"' was rejected in beforeSend function");return d20(n.event)?zi.warn("".concat(s,". This can cause unexpected behavior.")):zi.info(s),null}o.properties&&!WB(o.properties)||zi.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]]=h20(t.prototype[n[i]])})(AV,["identify"]);var fu2,h10=(fu2=pM[oy]=new AV,function(){function t(){t.done||(t.done=!0,uu2=!1,ol(pM,function(n){n._dom_loaded()}))}Pn!=null&&Pn.addEventListener?Pn.readyState==="complete"?t():$l(Pn,"DOMContentLoaded",t,{capture:!1}):c4&&zi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),fu2);const E10=new $$2({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),du2=({children:t,theme:n})=>{F0.useEffect(()=>{!n||!Object.keys(n).length||EB2(n)},[n]);const i=(o,a)=>{h10.capture("sth_went_wrong",{message:o.message,stack:o.stack,componentStack:a.componentStack})};return h.jsx(N$2,{FallbackComponent:Rb2,onError:i,children:h.jsx(o20,{client:E10,children:t})})},ay={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"},gu2=F0.createContext({isLoading:void 0,data:void 0,token:void 0,refetch:void 0}),cV=()=>F0.useContext(gu2),fV="https://api.usedatabrain.com",zu="/api/v2/dashboard",sy="/api/v2/metric",zg="/api/v3/metric",p10="dashboardData",v10=`${zu}/embeddedMetric`,I10="embeddedMetric",m10=`${sy}/layout`,hu2="dashboardLayout",b10=`${zu}/scheduledReportV2`,B10="dashboardScheduledReportV2",y10=`${sy}/saveLayout`,L10="saveLayout",w10=`${zu}/saveScheduleReport`,Q10="saveScheduleReport",M10=`${zu}/deleteScheduleReport`,T10="deleteScheduleReport",x10=`${zu}/createMetric`,R10="createMetric",H10=`${zu}/updateMetric`,D10="updateMetric",N10=`${zu}/updateAdminMetric`,S10="updateAdminMetric",V10=`${zu}/generateMetric`,k10="generateMetric",O10=`${zu}/datasetMetricCreation`,P10="datasetMetricCreation",Z10=`${zu}/previewTable`,F10="previewTable",U10=`${zu}/generatetMetricData`,j10="/generatetMetricData",z10=`${zu}/getOpenaiChatResponse`,G10="getOpenaiChatResponse",Y10=`${zu}/getDashboardScreenshot`,W10=`${zu}/createDashboardFilterView`,_10="createDashboardFilterView",X10=`${zu}/getDashboardFilterView`,K10="getDashboardFilterView",J10=`${zu}/getTheme`,q10="getTheme",$10=`${zg}/query`,e30="query",t30=`${zg}/datasetMetricCreation`,r30="newDatasetMetricCreation",n30=`${zg}/generateDataReport`,i30="generateDataReport",o30=`${zg}/chatQuery`,a30="chatQuery",s30=`${sy}/rawDownloadSettings`,C30="rawDownloadSettings",l30=`${sy}/column`,u30="column",A30=`${sy}/underlyingData`,c30="underlyingData",f30=`${sy}/invokeShareCsv`,d30="invokeShareCsv",g30=`${zg}/markArchived`,h30="markArchived",E30=`${zg}/publishMetrics`,p30="publishMetrics",v30=`${zg}/download-csv`,I30=`${zg}/downloadDashboardMetrics`,m30="IS_LOADING",b30="DATA_LOADED",B30=`${zg}/summarizeMetric`,y30="summarizeMetric",L30=`${zg}/createGuestTokenUsageLog`,w30="createGuestTokenUsageLog",Eu2="ENTER_FULL_SCREEN_MODE",pu2="EXIT_FULL_SCREEN_MODE",Q30="ENTER_SCHEDULED_REPORT_MODE",M30="SAVE_SCHEDULED_REPORT",vu2="EXIT_SCHEDULED_REPORT_MODE",T30="ENTER_CUSTOMIZE_LAYOUT_MODE",Iu2="EXIT_CUSTOMIZE_LAYOUT_MODE",mu2="SAVE_LAYOUT",x30="ENTER_MANAGE_METRICS_MODE",bu2="EXIT_MANAGE_METRICS_MODE",R30="SAVE_MANAGE_METRICS",H30="ARCHIVE_METRIC",Bu2="DOWNLOAD_METRIC",yu2="DOWNLOAD_METRIC_WITHOUT_FILTERS",D30="SAVE_METRIC_PNG",N30="METRIC_FILTER_APPLIED",S30="DASHBOARD_FILTER_APPLIED",V30="CREATE_METRIC",Lu2="UPDATE_METRIC",b_=()=>localStorage.getItem(fb2),dV=()=>{var o,a,s;const t=((o=window==null?void 0:window.dbn)==null?void 0:o.proxyAuthUrl)||"",n=((a=window==null?void 0:window.dbn)==null?void 0:a.proxyAuthKey)||"";return((s=window==null?void 0:window.dbn)==null?void 0:s.isEnableProxyAuth)||!1?{"X-Proxy-Auth-key":n,"X-Proxy-Auth-Url":t,"X-Authorization":n}:null},OC=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":b_()||""}:{},...dV()||{}}};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)||fV}${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},k30=()=>Zl(L10,t=>OC(y10,{method:"POST",data:t})),O30=()=>Zl(Q10,t=>OC(w10,{method:"POST",data:t.data,token:t.token})),wu2=()=>Zl(T10,t=>OC(M10,{method:"POST",data:t,token:t.token})),P30=()=>Zl(R10,({data:t,token:n})=>OC(x10,{method:"POST",data:t,token:n})),Z30=()=>Zl(D10,({data:t,token:n})=>OC(H10,{method:"POST",data:t,token:n})),F30=()=>Zl(S10,({data:t,token:n})=>OC(N10,{method:"POST",data:t,token:n})),U30=()=>Zl(k10,({data:t,token:n})=>OC(V10,{method:"POST",data:t,token:n})),Qu2=()=>Zl(P10,({data:t,token:n})=>OC(O10,{method:"POST",data:t,token:n})),j30=()=>Zl(F10,({data:t,token:n})=>OC(Z10,{method:"POST",data:t,token:n})),z30=()=>Zl(j10,({data:t,token:n})=>OC(U10,{method:"POST",data:t,token:n})),G30=()=>Zl(G10,({data:t,token:n})=>OC(z10,{method:"POST",data:t,token:n})),Y30=()=>Zl(_10,({data:t,token:n})=>OC(W10,{method:"POST",data:t,token:n})),B_=()=>Zl(u30,t=>OC(l30,{method:"POST",data:t})),W30=()=>Zl(c30,t=>OC(A30,{method:"POST",data:t})),_30=()=>Zl(d30,t=>OC(f30,{method:"POST",data:t})),X30=()=>Zl(h30,({data:t,token:n})=>OC(g30,{method:"POST",data:t,token:n})),K30=()=>Zl(p30,({data:t,token:n})=>OC(E30,{method:"POST",data:t,token:n})),J30=()=>Zl(r30,({data:t,token:n,clientId:i,isFrontendApp:o})=>OC(t30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),Mu2=()=>Zl(i30,({data:t,token:n,clientId:i,isFrontendApp:o})=>OC(n30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),q30=()=>Zl(a30,({data:t,token:n,clientId:i,isFrontendApp:o})=>OC(o30,{method:"POST",data:t,isFrontend:o,clientId:i,token:n})),$30=()=>Zl(y30,({data:t,isFrontendApp:n,clientId:i,token:o})=>OC(B30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),e70=()=>Zl(w30,({data:t,isFrontendApp:n,clientId:i,token:o})=>OC(L30,{method:"POST",data:t,isFrontend:n,clientId:i,token:o})),y_=()=>{const{mutateAsync:t}=e70();return{saveLogsAsync:async i=>{t(i)}}},vM=({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:p,metric:b,datasetMetricSettings:w,drillDownSettings:T,onServerEvent:H})=>{var U0,X2,Q3;const{token:S,data:N}=cV(),[X,W]=F0.useState(""),{mutate:f2,isLoading:Q2}=P30(),{mutate:I2}=j30(),{saveLogsAsync:r2}=y_(),{register:D2,setValue:M2,watch:m2,handleSubmit:k2,control:W2,reset:c0}=cb(),p0=x1=>{W(""),C==null||C.chartType,m0.singleValue,f2({data:{companyId:e,companyIntegrationId:n,description:x1.description,inputFields:i,metricId:x1.metricId,name:x1.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(v3=>({externalDashboardId:v3})),isEnableGroupBy:d,groupBy:g??{},selectedGroupBy:p,drillDownSettings:T},token:S},{onSuccess:async v3=>{var W3,g7,I3;(W3=v3==null?void 0:v3.insert_externalMetrics_one)!=null&&W3.id?(await r2({clientId:l,data:{companyId:e,feature:"CREATE_METRIC",metricId:(g7=v3==null?void 0:v3.insert_externalMetrics_one)==null?void 0:g7.metricId},isFrontendApp:!1,token:S}),await(t==null?void 0:t((I3=v3==null?void 0:v3.insert_externalMetrics_one)==null?void 0:I3.id)),H==null||H(V30)):W("Metric Id already exists")},onError:()=>{W&&W("Metric Id already exists")}})},{mutateAsync:L0,isLoading:b0}=F30(),{mutateAsync:j2,isLoading:t1}=Z30(),h0=F0.useCallback((x1,v3)=>{var g7,I3,$3;W("");let W3={};if(v3&&(W3={isDisableCardAppearance:x1.isDisableCardAppearance,titleAlignment:x1.titleAlignment,descAlignment:x1.descAlignment,...x1.text?{textBox:{text:x1.text,fontWeight:x1.fontWeight||"400",fontColor:x1.fontColor||"",fontSize:x1.fontSize||"14px",alignment:x1.textAlignment||"left",link:x1.textLink,isOpenInNewTab:x1.isOpenInNewTab,targetWord:x1.targetWord}}:null}),!(b!=null&&b.isCreatedByClient))L0({data:{externalMetricId:b==null?void 0:b.id,clientId:l,object:{clientId:l,companyId:e,companyIntegrationId:n||(b==null?void 0:b.companyIntegrationId),description:x1.description,inputFields:i,metricId:x1.metricId===(b==null?void 0:b.metricId)?`update_${x1.metricId}_by_${l}_${Date.now()}`:x1.metricId,name:v3?(g7=x1==null?void 0:x1.elementTitle)==null?void 0:g7.trim():(I3=x1==null?void 0:x1.name)==null?void 0:I3.trim(),query:o,metricQuery:a,datasetMetricSettings:w,integrationName:s,outputColumns:r,createdBy:l||"external user",isCreatedByClient:!!l,isLive:u||x1.isLive,chartOptions:C,drillDownSettings:T,elementSettings:W3,isMetric:!v3,...v3?{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(b7=>({externalDashboardId:b7}))}}},token:S},{onSuccess:async b7=>{var I7;!(b7!=null&&b7.insert_clientDeletedMetrics_one)||!(b7!=null&&b7.insert_externalMetrics_one)||(W(""),await r2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(I7=b7==null?void 0:b7.insert_externalMetrics_one)==null?void 0:I7.metricId},isFrontendApp:!1,token:S}),await(t==null?void 0:t()),H==null||H(Lu2))},onError:()=>{W("Something went wrong! Please try again later.")}});else{const b7={chartOptions:C,datasetMetricSettings:w,description:x1.description,query:o,metricQuery:a,drillDownSettings:T,elementSettings:W3,isMetric:!v3,...v3?{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:3}}:{resizeAttributes:{width:6,xAxis:0,yAxis:0,height:10}}};x1.description&&(b7.description=x1.description),x1.metricId&&(b7.metricId=x1.metricId),x1.name&&!v3&&(b7.name=x1.name),x1.elementTitle&&v3&&(b7.name=x1==null?void 0:x1.elementTitle),($3=Object.keys(W3))!=null&&$3.length&&(b7.elementSettings=W3),j2({data:{externalMetricId:b==null?void 0:b.id,set:b7},token:S},{onSuccess:async I7=>{var R6,h6;(R6=I7==null?void 0:I7.update_externalMetrics_by_pk)!=null&&R6.id&&(W(""),await r2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(h6=I7==null?void 0:I7.update_externalMetrics_by_pk)==null?void 0:h6.metricId},isFrontendApp:!1,token:S}),await(t==null?void 0:t()),H==null||H(Lu2))},onError:()=>{W("Something went wrong! Please try again later.")}})}},[C,b,j2,L0,l,e,n,s,u,f,o,i,r,a,w]),O0=F0.useCallback(x1=>{W("");const v3={isPublished:!(x1!=null&&x1.isPublished)};j2({data:{externalMetricId:x1==null?void 0:x1.id,set:v3},token:S},{onSuccess:async W3=>{var g7,I3;(g7=W3==null?void 0:W3.update_externalMetrics_by_pk)!=null&&g7.id&&(W(""),await r2({clientId:l,data:{companyId:e,feature:"UPDATE_METRIC",metricId:(I3=W3==null?void 0:W3.update_externalMetrics_by_pk)==null?void 0:I3.metricId},isFrontendApp:!1,token:S}),t==null||t())},onError:()=>{W("Something went wrong! Please try again later.")}})},[b]);return{createExternalMetric:p0,updateExternalMetric:h0,error:X,isLoading:Q2||b0||t1,clientSubsetData:N==null?void 0:N.clientSubsetData,previewTable:I2,token:S,workspaceId:(U0=N==null?void 0:N.workspace)==null?void 0:U0.id,dashboardOptions:[{value:(X2=N==null?void 0:N.externalDashboard)==null?void 0:X2.id,label:((Q3=N==null?void 0:N.externalDashboard)==null?void 0:Q3.name)||"Dashboard"}],isDatabaseTenancy:(N==null?void 0:N.companyTenancyType)===AL,register:D2,setValue:M2,watch:m2,handleSubmit:k2,control:W2,reset:c0,onPublishMetric:O0}},Tu2=()=>{const{mutate:t,isLoading:n,error:i}=U30(),{mutate:o,mutateAsync:a}=B_();return{generateDatasetMetric:t,isGeneratingDataset:n,generateError:i,fetchColumnValues:o,fetchColumnValuesAsync:a}};let t70=0;function r70(t,n){const i=`atom${++t70}`,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 td={},Zp=Symbol(),L_=t=>!!t[Zp],gV=t=>!t[Zp].c,IM=t=>{var n;const{b:i,c:o}=t[Zp];o&&(o(),(n=i70.get(i))==null||n())},hV=(t,n)=>{const i=t[Zp].o,o=n[Zp].o;return i===o||t===o||L_(i)&&hV(i,n)},w_=(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[Zp]=i,o},n70=t=>w_(t[Zp].b,t[Zp].o),i70=new WeakMap,Q_=t=>"init"in t,M_="r",T_="w",EV="c",x_="s",xu2="h",o70="n",a70="l",s70="a",C70="m",l70=t=>{const n=new WeakMap,i=new WeakMap,o=new Map;let a,s;(td&&"production")!=="production"&&(a=new Set,s=new Set);const r=new WeakMap,C=(b0,j2,t1)=>{let h0=r.get(j2);h0||(h0=new Map,r.set(j2,h0)),t1.then(()=>{h0.get(b0)===t1&&(h0.delete(b0),h0.size||r.delete(j2))}),h0.set(b0,t1)},l=b0=>{const j2=new Set,t1=r.get(b0);return t1&&(r.delete(b0),t1.forEach((h0,O0)=>{IM(h0),j2.add(O0)})),j2},e=new WeakMap,u=b0=>{let j2=e.get(b0);return j2||(j2=new Map,e.set(b0,j2)),j2},A=(b0,j2)=>{if(b0){const t1=u(b0);let h0=t1.get(j2);return h0||(h0=A(b0.p,j2),h0&&"p"in h0&&gV(h0.p)&&(h0=void 0),h0&&t1.set(j2,h0)),h0}return n.get(j2)},f=(b0,j2,t1)=>{if((td&&"production")!=="production"&&Object.freeze(t1),b0)u(b0).set(j2,t1);else{const h0=n.get(j2);n.set(j2,t1),o.has(j2)||o.set(j2,h0)}},d=(b0,j2=new Map,t1)=>{if(!t1)return j2;const h0=new Map;let O0=!1;return t1.forEach(U0=>{var X2;const Q3=((X2=A(b0,U0))==null?void 0:X2.r)||0;h0.set(U0,Q3),j2.get(U0)!==Q3&&(O0=!0)}),j2.size===h0.size&&!O0?j2:h0},g=(b0,j2,t1,h0,O0)=>{const U0=A(b0,j2);if(U0){if(O0&&(!("p"in U0)||!hV(U0.p,O0)))return U0;"p"in U0&&IM(U0.p)}const X2={v:t1,r:(U0==null?void 0:U0.r)||0,y:!0,d:d(b0,U0==null?void 0:U0.d,h0)};let Q3=!(U0!=null&&U0.y);return!U0||!("v"in U0)||!Object.is(U0.v,t1)?(Q3=!0,++X2.r,X2.d.has(j2)&&(X2.d=new Map(X2.d).set(j2,X2.r))):X2.d!==U0.d&&(X2.d.size!==U0.d.size||!Array.from(X2.d.keys()).every(x1=>U0.d.has(x1)))&&(Q3=!0,Promise.resolve().then(()=>{k2(b0)})),U0&&!Q3?U0:(f(b0,j2,X2),X2)},p=(b0,j2,t1,h0,O0)=>{const U0=A(b0,j2);if(U0){if(O0&&(!("p"in U0)||!hV(U0.p,O0)))return U0;"p"in U0&&IM(U0.p)}const X2={e:t1,r:((U0==null?void 0:U0.r)||0)+1,y:!0,d:d(b0,U0==null?void 0:U0.d,h0)};return f(b0,j2,X2),X2},b=(b0,j2,t1,h0)=>{const O0=A(b0,j2);if(O0&&"p"in O0){if(hV(O0.p,t1)&&!gV(O0.p))return O0.y?O0:{...O0,y:!0};IM(O0.p)}C(b0,j2,t1);const U0={p:t1,r:((O0==null?void 0:O0.r)||0)+1,y:!0,d:d(b0,O0==null?void 0:O0.d,h0)};return f(b0,j2,U0),U0},w=(b0,j2,t1,h0)=>{if(t1 instanceof Promise){const O0=w_(t1,t1.then(U0=>{g(b0,j2,U0,h0,O0)}).catch(U0=>{if(U0 instanceof Promise)return L_(U0)?U0.then(()=>{H(b0,j2,!0)}):U0;p(b0,j2,U0,h0,O0)}));return b(b0,j2,O0,h0)}return g(b0,j2,t1,h0)},T=(b0,j2)=>{const t1=A(b0,j2);if(t1){const h0={...t1,y:!1};f(b0,j2,h0)}else(td&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",j2)},H=(b0,j2,t1)=>{if(!t1){const O0=A(b0,j2);if(O0){if(O0.y&&"p"in O0&&!gV(O0.p))return O0;if(O0.d.forEach((U0,X2)=>{if(X2!==j2)if(!i.has(X2))H(b0,X2);else{const Q3=A(b0,X2);Q3&&!Q3.y&&H(b0,X2)}}),Array.from(O0.d).every(([U0,X2])=>{const Q3=A(b0,U0);return Q3&&!("p"in Q3)&&Q3.r===X2}))return O0.y?O0:{...O0,y:!0}}}const h0=new Set;try{const O0=j2.read(U0=>{h0.add(U0);const X2=U0===j2?A(b0,U0):H(b0,U0);if(X2){if("e"in X2)throw X2.e;if("p"in X2)throw X2.p;return X2.v}if(Q_(U0))return U0.init;throw new Error("no atom init")});return w(b0,j2,O0,h0)}catch(O0){if(O0 instanceof Promise){const U0=L_(O0)&&gV(O0)?n70(O0):w_(O0,O0);return b(b0,j2,U0,h0)}return p(b0,j2,O0,h0)}},S=(b0,j2)=>H(j2,b0),N=(b0,j2)=>{let t1=i.get(j2);return t1||(t1=D2(b0,j2)),t1},X=(b0,j2)=>!j2.l.size&&(!j2.t.size||j2.t.size===1&&j2.t.has(b0)),W=(b0,j2)=>{const t1=i.get(j2);t1&&X(j2,t1)&&M2(b0,j2)},f2=(b0,j2)=>{const t1=i.get(j2);t1==null||t1.t.forEach(h0=>{h0!==j2&&(T(b0,h0),f2(b0,h0))})},Q2=(b0,j2,t1)=>{let h0=!0;const O0=(Q3,x1)=>{const v3=H(b0,Q3);if("e"in v3)throw v3.e;if("p"in v3){if(x1!=null&&x1.unstable_promise)return v3.p.then(()=>{const W3=A(b0,Q3);return W3&&"p"in W3&&W3.p===v3.p?new Promise(g7=>setTimeout(g7)).then(()=>O0(Q3,x1)):O0(Q3,x1)});throw(td&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",Q3),v3.p}if("v"in v3)return v3.v;throw(td&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",Q3),new Error("no value found")},U0=(Q3,x1)=>{let v3;if(Q3===j2){if(!Q_(Q3))throw new Error("atom not writable");l(Q3).forEach($3=>{$3!==b0&&w($3,Q3,x1)});const g7=A(b0,Q3),I3=w(b0,Q3,x1);g7!==I3&&f2(b0,Q3)}else v3=Q2(b0,Q3,x1);return h0||k2(b0),v3},X2=j2.write(O0,U0,t1);return h0=!1,X2},I2=(b0,j2,t1)=>{const h0=Q2(t1,b0,j2);return k2(t1),h0},r2=b0=>!!b0.write,D2=(b0,j2,t1)=>{const h0={t:new Set(t1&&[t1]),l:new Set};if(i.set(j2,h0),(td&&"production")!=="production"&&s.add(j2),H(void 0,j2).d.forEach((U0,X2)=>{const Q3=i.get(X2);Q3?Q3.t.add(j2):X2!==j2&&D2(b0,X2,j2)}),r2(j2)&&j2.onMount){const U0=Q3=>I2(j2,Q3,b0),X2=j2.onMount(U0);b0=void 0,X2&&(h0.u=X2)}return h0},M2=(b0,j2)=>{var t1;const h0=(t1=i.get(j2))==null?void 0:t1.u;h0&&h0(),i.delete(j2),(td&&"production")!=="production"&&s.delete(j2);const O0=A(b0,j2);O0?("p"in O0&&IM(O0.p),O0.d.forEach((U0,X2)=>{if(X2!==j2){const Q3=i.get(X2);Q3&&(Q3.t.delete(j2),X(X2,Q3)&&M2(b0,X2))}})):(td&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",j2)},m2=(b0,j2,t1,h0)=>{const O0=new Set(t1.d.keys());h0==null||h0.forEach((U0,X2)=>{if(O0.has(X2)){O0.delete(X2);return}const Q3=i.get(X2);Q3&&(Q3.t.delete(j2),X(X2,Q3)&&M2(b0,X2))}),O0.forEach(U0=>{const X2=i.get(U0);X2?X2.t.add(j2):i.has(j2)&&D2(b0,U0,j2)})},k2=b0=>{if(b0){u(b0).forEach((t1,h0)=>{const O0=n.get(h0);if(t1!==O0){const U0=i.get(h0);U0==null||U0.l.forEach(X2=>X2(b0))}});return}for(;o.size;){const j2=Array.from(o);o.clear(),j2.forEach(([t1,h0])=>{const O0=A(void 0,t1);if(O0&&O0.d!==(h0==null?void 0:h0.d)&&m2(void 0,t1,O0,h0==null?void 0:h0.d),h0&&!h0.y&&(O0!=null&&O0.y))return;const U0=i.get(t1);U0==null||U0.l.forEach(X2=>X2())})}(td&&"production")!=="production"&&a.forEach(j2=>j2())},W2=b0=>{u(b0).forEach((t1,h0)=>{const O0=n.get(h0);(!O0||t1.r>O0.r||t1.y!==O0.y||t1.r===O0.r&&t1.d!==O0.d)&&(n.set(h0,t1),t1.d!==(O0==null?void 0:O0.d)&&m2(b0,h0,t1,O0==null?void 0:O0.d))})},c0=(b0,j2)=>{j2&&W2(j2),k2(void 0)},p0=(b0,j2,t1)=>{const O0=N(t1,b0).l;return O0.add(j2),()=>{O0.delete(j2),W(t1,b0)}},L0=(b0,j2)=>{for(const[t1,h0]of b0)Q_(t1)&&(w(j2,t1,h0),f2(j2,t1));k2(j2)};return(td&&"production")!=="production"?{[M_]:S,[T_]:I2,[EV]:c0,[x_]:p0,[xu2]:L0,[o70]:b0=>(a.add(b0),()=>{a.delete(b0)}),[a70]:()=>s.values(),[s70]:b0=>n.get(b0),[C70]:b0=>i.get(b0)}:{[M_]:S,[T_]:I2,[EV]:c0,[x_]:p0,[xu2]:L0}},u70=(t,n)=>({s:n?n(t).SECRET_INTERNAL_store:l70()}),R_=new Map,Ru2=t=>(R_.has(t)||R_.set(t,F0.createContext(u70())),R_.get(t));function Hu2(t,n){return r70(t)}function A70(t,n){const i=Ru2(n),o=F0.useContext(i),{s:a,v:s}=o,r=f=>{const d=a[M_](t,f);if((td&&"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]=F0.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)),F0.useEffect(()=>{const{v:f}=o;f&&a[EV](t,f);const d=a[x_](t,u,f);return u(f),d},[a,t,o]),F0.useEffect(()=>{a[EV](t,C)}),F0.useDebugValue(A),A}function c70(t,n){const i=Ru2(n),{s:o,w:a}=F0.useContext(i);return F0.useCallback(r=>{if((td&&"production")!=="production"&&!("write"in t))throw new Error("not writable atom");const C=l=>o[T_](t,r,l);return a?a(C):C()},[o,a,t])}function H_(t,n){return"scope"in t&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),n=t.scope),[A70(t,n),c70(t,n)]}const pV=({onOutsideClick:t,wrapRef:n,portalRef:i})=>{F0.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])},f70=({wrapRef:t,portalRef:n,autoCloseParent:i=!1})=>{const[o]=H_(RA2);F0.useEffect(()=>{const a=s=>{o==null||o.forEach(r=>{var l,e,u,A,f,d,g,p;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 b=o.find(w=>{var H,S;const T=((H=r.popperElement)==null?void 0:H.contains(w.referenceElement))&&(w.isOpen===!0||w.isMenuOpen===!0);return i?T&&((S=w.popperElement)==null?void 0:S.contains("composedPath"in s?s.composedPath()[0]:s.target)):T});b?((u=b==null?void 0:b.setOpen)==null||u.call(b,!0),(A=b==null?void 0:b.setMenuOpen)==null||A.call(b,!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),(p=r.setMenuOpen)==null||p.call(r,!0))})};return document.addEventListener("click",a,!0),()=>{document.removeEventListener("click",a,!0)}},[t,n,o])},d70=({token:t,dashboardId:n,configId:i,isEn:o})=>{var a;return Rp([p10,{dashboardId:n,configId:i,token:t,isEn:o}],()=>{const s=n?`${zu}?dashboardId=${n}${i?`&configId=${i}`:""}${`&isEn=${o}`}`:zu;return OC(s,{method:"GET",token:t})},{enabled:!!t||!!((a=window==null?void 0:window.dbn)!=null&&a.isEnableProxyAuth)})},g70=(t,n)=>Rp([hu2,{dashboardId:t,clientId:n}],()=>OC(`${m10}?id=${t}&clientId=${n}`,{method:"GET"}),{enabled:!!t&&!!n}),h70=(t,n,i)=>Rp(B10,()=>OC(`${b10}?externalDashboardId=${n}${i?`&embedId=${i}`:""}`,{method:"GET",token:t}),{enabled:!!t&&!!n}),E70=(t,n)=>{var i;return Rp([I10,{id:n}],()=>OC(`${v10}?metricId=${n}`,{method:"GET",token:t}),{enabled:!!t||!!((i=window==null?void 0:window.dbn)!=null&&i.isEnableProxyAuth)})},Du2=({token:t,name:n,companyId:i})=>Rp([q10,{name:n}],()=>OC(J10,{method:"POST",token:t,data:{name:n,companyId:i}}),{enabled:!!(n&&t&&i)}),p70=({token:t,dashboardId:n})=>Rp([K10,{dashboardId:n}],()=>OC(X10,{method:"POST",token:t,data:{dashboardId:n}}),{enabled:!!(t&&n)}),v70=({externalDashboardId:t,clientId:n})=>{const i=cW(),{data:o,isLoading:a}=g70(t,n),[s,r,C,l]=F0.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}=k30();return{saveLayout:F0.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([hu2,{dashboardId:t,clientId:n}],p=>({...p,...g}))}})},[e,n,t]),layout:s,dashboardFiltersLayout:r,gridMargin:l,isLayoutLocked:C,isLoadingLayout:a||u}},I70=({query:t,limit:n,offset:i,dbName:o})=>{const a=Bf===(o==null?void 0:o.toLowerCase()),s=Pu===(o==null?void 0:o.toLowerCase()),r=vA===(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())==Pu||(o==null?void 0:o.toLowerCase())==Bf||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},m70=({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:p}=W30();return{getUnderlyingData:({columnName:w,value:T,setData:H,setLoading:S,isSingleValueChart:N,clientColumnType:X})=>{const W=o==="MULTI_DATABASE"&&n||"",f2=g&&d?d:I70({query:s,limit:"5000",dbName:i}),Q2=db({clientColumnType:X,query:f2||"",dbName:i,rlsConditions:A,tenancyLevel:o||"TABLE",clientId:n,globalFilters:e,values:a,isAllClient:u,dataMartRelationships:f});H([]),S(!0),p({columnName:N?void 0:w,companyId:r,query:lf(Q2,r),value:N?void 0:T.toString().replace(/'/g,"''"),workspaceId:C,metricId:l,isCustomSql:g&&!!d,databaseName:W,datasourceId:t},{onSuccess(I2){const r2=I2==null?void 0:I2.data;r2&&Array.isArray(r2)&&r2.length?(H(r2),S(!1)):(H([]),S(!1))},onError(){H([]),S(!1)}})}}},b70=({clientId:t,data:n,token:i,isFrontendApp:o,isFullScreen:a=""},s)=>Rp([e30,n,t,o,i,a],()=>{var r,C,l;return OC($10,{method:"POST",data:{...n||{},...!o&&i?{...(r=n==null?void 0:n.rlsConditions)!=null&&r.length?{rlsConditions:zB(n==null?void 0:n.rlsConditions,i)}:{},...(l=(C=n==null?void 0:n.globalFilters)==null?void 0:C.filters)!=null&&l.length?{globalFilters:zB(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}),B70=t=>Rp([C30,t],()=>OC(`${s30}?id=${t}`,{method:"GET"}),{enabled:!!t}),vV={timeSeriesSettingsContainer:"_timeSeriesSettingsContainer_3qyzb_1",timeSeriesSettingsType:"_timeSeriesSettingsType_3qyzb_9",featToggle:"_featToggle_3qyzb_17",dynamicFormat:"_dynamicFormat_3qyzb_33"},y70=[{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"}],L70=({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 p=`${n.options[d].split("____")[0]}____${g}`,b=`${n.options[d].split("____")[0]}`;t(w=>{var T,H,S,N;return{...w,groupBySettings:{...w.groupBySettings,options:(T=w.groupBySettings.options)==null?void 0:T.map((X,W)=>W===d?p:X),value:((H=w.groupBySettings.options)==null?void 0:H.find((X,W)=>W===d))===((S=w==null?void 0:w.groupBySettings)==null?void 0:S.value)?b:(N=w==null?void 0:w.groupBySettings)==null?void 0:N.value}}})}else{const p=`${n.options[d]}____${g}`,b=`${n.options[d]}`;t(w=>{var T,H,S,N;return{...w,groupBySettings:{...w.groupBySettings,options:(T=w.groupBySettings.options)==null?void 0:T.map((X,W)=>W===d?p:X),value:((H=w.groupBySettings.options)==null?void 0:H.find((X,W)=>W===d))===((S=w==null?void 0:w.groupBySettings)==null?void 0:S.value)?b:(N=w==null?void 0:w.groupBySettings)==null?void 0:N.value}}})}};return h.jsxs("div",{className:vV.timeSeriesSettingsContainer,children:[h.jsx(e6,{variant:"heading-5",children:"Time Series Settings"}),h.jsx(G4,{label:"Series Type",options:y70,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(p=>({column:p,type:d.value}))}))},menuWidth:"100%",buttonWidth:"100%"}),h.jsx(e6,{variant:"body-text-2",children:"Group format"}),h.jsxs("div",{className:vV.timeSeriesSettingsType,children:[h.jsx(uc,{"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(p=>p.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}),h.jsx(uc,{"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(p=>p.value),fillXAxis:!1,isGlobalFilter:!1,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[2]))}}),h.jsx(uc,{"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(p=>p.value),fillXAxis:!1,isGlobalFilter:!0,globalFilterOption:{label:"",value:""}}})),a==null||a(cC==null?void 0:cC[0]))}})]}),n.isDynamic?h.jsxs("div",{className:vV.dynamicFormat,children:[h.jsx(rs,{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(p=>p.value))||["monthly"],fillXAxis:[Jc.daily,Jc.weekly,Jc.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)=>h.jsx(K9,{label:d.split("____").length>1?d.split("____")[0]:d,type:"text",value:d.split("____").length>1?d.split("____")[1]:d,placeholder:"Save as",onChange:p=>{r(g,p.target.value)}}))]}):h.jsxs(h.Fragment,{children:[(n==null?void 0:n.isGlobalFilter)&&h.jsxs(h.Fragment,{children:[h.jsx(G4,{label:"Dashboard Filter",menuWidth:"100%",buttonWidth:"100%",options:s,selectedOption:n.globalFilterOption||{value:"",label:""},onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,globalFilterOption:d,formatWithValue:[]}}))}}),!!((u=(e=n==null?void 0:n.globalFilterOption)==null?void 0:e.presetDateOptions)!=null&&u.length)&&h.jsx(za,{direction:"col",className:"dbn-gap-3",children:cC==null?void 0:cC.map(d=>{var g,p,b,w,T,H,S;return h.jsxs(za,{className:"dbn-w-full dbn-gap-2",alignItems:"center",justify:"between",children:[h.jsx(ff,{checked:!!((g=n==null?void 0:n.formatWithValue)!=null&&g.find(N=>N.format===d.value&&N.isEnable)),onChange:({target:{checked:N}})=>{t(X=>{var W,f2,Q2,I2,r2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(W=X==null?void 0:X.groupBySettings)==null?void 0:W.formatWithValue)==null?void 0:f2.filter(D2=>D2.format!==d.value))||[],{format:d.value,isEnable:N,value:((r2=(I2=(Q2=X==null?void 0:X.groupBySettings)==null?void 0:Q2.formatWithValue)==null?void 0:I2.find(D2=>D2.format===d.value))==null?void 0:r2.value)||""}]}}})},label:d.value}),h.jsx("div",{className:"dbn-w-full",children:h.jsx(G4,{placeholder:"Select a Filter Value",menuWidth:"100%",buttonWidth:"100%",options:((p=n==null?void 0:n.globalFilterOption)==null?void 0:p.presetDateOptions)||[],selectedOption:{value:((w=(b=n==null?void 0:n.formatWithValue)==null?void 0:b.find(N=>N.format===d.value))==null?void 0:w.value)||"",label:((H=(T=n==null?void 0:n.formatWithValue)==null?void 0:T.find(N=>N.format===d.value))==null?void 0:H.value)||""},isDisabled:!((S=n==null?void 0:n.formatWithValue)!=null&&S.find(N=>N.format===d.value&&N.isEnable)),onChange:N=>{t(X=>{var W,f2,Q2,I2,r2;return{...X,groupBySettings:{...X.groupBySettings,formatWithValue:[...((f2=(W=X==null?void 0:X.groupBySettings)==null?void 0:W.formatWithValue)==null?void 0:f2.filter(D2=>D2.format!==d.value))||[],{format:d.value,isEnable:!!((r2=(I2=(Q2=X==null?void 0:X.groupBySettings)==null?void 0:Q2.formatWithValue)==null?void 0:I2.find(D2=>D2.format===d.value))!=null&&r2.isEnable),value:(N==null?void 0:N.value)||""}]}}})}})})]})})})]}),h.jsx(G4,{label:"Format Type",menuWidth:"100%",buttonWidth:"100%",options:cC,selectedOption:(cC==null?void 0:cC.find(d=>{var g,p;return((g=d.value)==null?void 0:g.toLowerCase())===((p=n==null?void 0:n.value)==null?void 0:p.toLowerCase())}))||(cC==null?void 0:cC[2]),onChange:d=>{t(g=>({...g,groupBySettings:{...g.groupBySettings,value:d.value}})),a==null||a(d)}}),[Jc.month,Jc.quarter].includes(n.value.toLowerCase())&&h.jsxs("div",{className:vV.featToggle,children:[h.jsx(G5,{name:"fill axis",enabled:n.fillXAxis,onChange:()=>t(d=>({...d,groupBySettings:{...d.groupBySettings,fillXAxis:!d.groupBySettings.fillXAxis}}))}),h.jsxs("span",{className:"dbn-flex dbn-gap-2 dbn-items-center",children:[h.jsx(e6,{variant:"body-text-2",children:"Fill X-axis"}),h.jsx(Af,{position:"top",iconConfig:{size:"xs",color:"primary"},text:"Enable to fill missing months or dates.",tooltipClass:"dbn-w-[300px]"})]})]})]})]})},oc=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)})},kc=t=>{const n=new Date(t);return n instanceof Date&&!Number.isNaN(n.getTime())?n:null},D_=({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:p,setMetricStore:b,onServerEvent:w,clientColumnType:T,datasourceId:H,appliedCardMetricFilters:S,language:N,translationDictionary:X,calendarType:W,setLoadedCardMetadata:f2,isFullScreen:Q2,setMetricMetadata:I2,viewMetricData:r2,generatingPdf:D2,dataMartTables:M2})=>{var U9,E4,f4,y4,I4,ne,H4,X4,L4,Re,W4,Ee,C1,z1,Y3,S3,K7,s3,a7,y6,F6,z8,K8,c9,R9,q9,M1,R3,J3,H7,m6,g8,n8,d8,N8,_8,f5,Y9,s5,Z5,Z4,le,Ve,pe,tt,mt,Zr,sn,xn,ci,ii,oi,Ti,Hi,gn,Yr,fi,Gi,Ae,Hr,Cn,di,Xn,Er,ln;const[m2,k2]=F0.useState(!1),[W2,c0]=F0.useState(!0),p0=$30(),[L0,b0]=F0.useState(""),[j2,t1]=F0.useState(""),[h0,O0]=F0.useState(!1),U0=F0.useRef(null),[X2,Q3]=F0.useState({limit:10,offset:0}),[x1,v3]=F0.useState(0),[W3,g7]=F0.useState(0),[I3,$3]=F0.useState((t==null?void 0:t.rlsConditions)||[]),[b7,I7]=F0.useState([]),[R6,h6]=F0.useState(!1),[w3,t0]=F0.useState(),[z3,X7]=F0.useState([]),[Y7,l6]=F0.useState(""),[c6,H6]=F0.useState([]),[I1,l3]=F0.useState({isOpen:!1,report:"",isLoading:!1}),[q3,T7]=F0.useState(!1),[h7,g3]=F0.useState([]),[p7,N7]=F0.useState([]),[D7,j6]=F0.useState({isEnableGroupBy:!1,isEnableCrossFilter:!1,drillType:""}),[q7,M6]=F0.useState([]),[C8,a9]=F0.useState(!1),[T8,y9]=F0.useState(!1),[O8,O9]=F0.useState([]),[L8,o5]=F0.useState({}),[W9,p5]=F0.useState(!1),[v5,p4]=F0.useState(null),[T1,s9]=F0.useState(t==null?void 0:t.chartOptions),[S9,g5]=F0.useState({data:[],error:"",isLoading:!1,currentValue:""}),n5=F0.useMemo(()=>{var $6,J6;return!!((J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)!=null&&J6.isPythonMode)},[(E4=(U9=t==null?void 0:t.datasetMetricSettings)==null?void 0:U9.newDatasetSettings)==null?void 0:E4.isPythonMode]),Y5=F0.useMemo(()=>{var $6,J6,n9,B8,L9;return((L9=(B8=(n9=(J6=($6=t==null?void 0:t.externalDashboardMetrics)==null?void 0:$6[0])==null?void 0:J6.externalDashboard)==null?void 0:n9.companyWorkspace)==null?void 0:B8.datamart)==null?void 0:L9.datamartRelationships)||[]},[t]),r5=F0.useMemo(()=>{const $6={};if(i!=null&&i.values)for(const J6 in i.values){const n9=`${J6}_variable`;$6[n9]=i.values[J6]}return $6},[i==null?void 0:i.values]),E3=F0.useMemo(()=>{var n9,B8,L9;const $6=(B8=(n9=t==null?void 0:t.datasetMetricSettings)==null?void 0:n9.newDatasetSettings)==null?void 0:B8.selectedMainTable,J6=M2==null?void 0:M2.find(w8=>w8.tableName===($6==null?void 0:$6.tableName));return((L9=J6==null?void 0:J6.customColumnFields)==null?void 0:L9.map(w8=>{var _9,l5,T5,d4,j5,z6;return{value:w8==null?void 0:w8.columnName,label:w8==null?void 0:w8.columnName,isCustomField:!0,column:{uniqueId:em(10),alias:w8==null?void 0:w8.columnName,configType:"DIMENSION",datatype:w8==null?void 0:w8.datatype,dropType:"DIMENSION",index:1e3,name:w8==null?void 0:w8.columnName,parentAlias:`${$I($6==null?void 0:$6.schemaName,((_9=t==null?void 0:t.companyIntegration)==null?void 0:_9.name)||"")}_${(l5=$6==null?void 0:$6.tableName)==null?void 0:l5.replaceAll(" ","_")}`,table:(d4=(T5=t==null?void 0:t.datasetMetricSettings)==null?void 0:T5.newDatasetSettings)==null?void 0:d4.selectedMainTable,type:"DEFAULT",draggableItemData:{column:{name:w8==null?void 0:w8.columnName,dataType:w8==null?void 0:w8.datatype,as:w8==null?void 0:w8.datatype},table:(z6=(j5=t==null?void 0:t.datasetMetricSettings)==null?void 0:j5.newDatasetSettings)==null?void 0:z6.selectedMainTable},label:"",sql:""}}}))||[]},[(y4=(f4=t==null?void 0:t.datasetMetricSettings)==null?void 0:f4.newDatasetSettings)==null?void 0:y4.selectedMainTable,(I4=t==null?void 0:t.companyIntegration)==null?void 0:I4.name,M2]),D8=F0.useMemo(()=>{var $6,J6,n9,B8,L9,w8,_9,l5,T5,d4,j5,z6,W8,d5;return{isAllClient:u,id:t==null?void 0:t.id,tenancyLevel:a,rlsConditions:[...O8||[],...($6=T1==null?void 0:T1.tableSettings)!=null&&$6.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?(J6=b7==null?void 0:b7.map(I5=>I5.condition))==null?void 0:J6.filter(I5=>Gx(I5)):[]],globalFilters:n5?void 0:{...n,filters:(n9=n==null?void 0:n.filters)==null?void 0:n9.filter(I5=>{var Qe;return Array.isArray(I5==null?void 0:I5.value)?(Qe=I5==null?void 0:I5.value)==null?void 0:Qe.length:I5})},filterValues:n5?void 0:r5,limit:(B8=T1==null?void 0:T1.tableSettings)!=null&&B8.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?Math.min(X2.limit,1e3):void 0,offset:(L9=T1==null?void 0:T1.tableSettings)!=null&&L9.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?X2.offset:void 0,disableStringify:!0,pivotHeaders:((w8=T1==null?void 0:T1.pivotTableSettings2)==null?void 0:w8.headers)||[],timeseriesSettings:n5?void 0:{format:((T5=(l5=(_9=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:_9.groupBySettings)==null?void 0:l5.value)==null?void 0:T5.toLowerCase())||"monthly",seriesField:(T1==null?void 0:T1.seriesField)||"",isFiscal:W==="ind"},chartSeriesField:(T1==null?void 0:T1.seriesField)!=="ungrouped"&&(T1!=null&&T1.seriesField)&&(T1!=null&&T1.isDynamicSeries)?T1==null?void 0:T1.seriesField:void 0,comparisonCount:W3,dynamicXAxis:{isEnable:!!((d4=T1==null?void 0:T1.dynamicXAxis)!=null&&d4.isEnabled||(j5=T1==null?void 0:T1.enduserMeasureAndDimensions)!=null&&j5.isEnabled)&&Bh.includes((T1==null?void 0:T1.chartType)||""),xaxis:(T1==null?void 0:T1.xAxis)||"",customField:(W8=(z6=T1==null?void 0:T1.dynamicXAxis)==null?void 0:z6.selectedOption)==null?void 0:W8.column},dbId:H,elementSettings:(d5=t==null?void 0:t.elementSettings)==null?void 0:d5.metricExpression,drillConfig:D7==null?void 0:D7.configV2,isEncrypted:!!(!A&&f)}},[T1,u,t,O8,n5,r5,p7,a,n,X2,W3,Bh,H,W,D7==null?void 0:D7.configV2,f,A,JSON.stringify(b7)]),{data:o7,isLoading:j7,error:p6,refetch:s6}=b70({data:D8,clientId:A?d||"":o,token:f,isFrontendApp:A,isFullScreen:Q2},{onSuccess:$6=>{var n9;const J6=cB2($6);f2&&((n9=J6==null?void 0:J6.error)==null?void 0:n9.code)!=="E1001"&&(f2==null||f2(B8=>{var L9;return[...(B8==null?void 0:B8.filter(w8=>(w8==null?void 0:w8.id)!==(D8==null?void 0:D8.id)))||[],{id:D8==null?void 0:D8.id,isDataFound:!!(J6!=null&&J6.length)&&((T1==null?void 0:T1.chartType)!==m0.singleValue||((L9=J6==null?void 0:J6[0])==null?void 0:L9[(T1==null?void 0:T1.singleValue)||""])!==null)}]}))}}),{mutate:u6}=J30(),{mutateAsync:v7}=Mu2();F0.useEffect(()=>{var J6;const $6=((J6=t==null?void 0:t.rlsConditions)==null?void 0:J6.map(n9=>{var T5,d4,j5,z6,W8,d5,I5,Qe,xe,ce,at,ye,F4,Ue,wt;let B8=n9;if(e){const te=dB2(B8,e);te&&(B8={...B8,filterType:"manual",value:te.value?B8.datatype==="string"&&((T5=B8==null?void 0:B8.filterVariant)==null?void 0:T5.value)===au?[te.value]:te.value:B8.value,options:B8.datatype==="date"?(d4=te.options)==null?void 0:d4.map(Le=>({...Le,startDate:kc(Le.fromDate)??Le.startDate,endDate:kc(Le.toDate)??Le.endDate,minDate:kc(Le.minDate)??void 0,maxDate:kc(Le.maxDate)??void 0,fromDate:kc(Le.fromDate)??void 0,toDate:kc(Le.toDate)??void 0})):te.options,variableOptions:B8.datatype==="date"?(j5=te.options)==null?void 0:j5.map(Le=>({range:Le.range,startDate:kc(Le.fromDate)??Le.startDate,endDate:kc(Le.toDate)??Le.endDate,minDate:kc(Le.minDate)??void 0,maxDate:kc(Le.maxDate)??void 0,fromDate:kc(Le.fromDate)??void 0,toDate:kc(Le.toDate)??void 0,value:Le.name,label:Le.name})):(z6=te.options)==null?void 0:z6.map(Le=>({value:Le,label:Le})),selectedVariableValue:te.value?B8.datatype==="string"?{value:te.value,label:te.value}:{startDate:kc((d5=(W8=te.options)==null?void 0:W8.find(Le=>Le.name===te.value))==null?void 0:d5.fromDate),endDate:kc((Qe=(I5=te.options)==null?void 0:I5.find(Le=>Le.name===te.value))==null?void 0:Qe.toDate),value:te.value,label:te.value}:B8.selectedVariableValue})}const w8=[...((at=(ce=(xe=r2==null?void 0:r2.metricViewFilters)==null?void 0:xe.find(te=>te.id===(t==null?void 0:t.id)))==null?void 0:ce.filters)==null?void 0:at.filter(te=>!(S!=null&&S.find(Le=>(te==null?void 0:te.name)===(Le==null?void 0:Le.name)))))||[],...S||[]].find(te=>B8.name===te.name);if(w8!=null&&w8.value&&(B8={...B8,...w8!=null&&w8.value?{value:w8==null?void 0:w8.value}:{},...w8!=null&&w8.selectedDropdownValue?{selectedDropdownValue:w8==null?void 0:w8.selectedDropdownValue}:{},...w8!=null&&w8.selectedVariableValue?{selectedVariableValue:w8==null?void 0:w8.selectedVariableValue}:{}}),(B8==null?void 0:B8.datatype)==="date"&&((ye=B8==null?void 0:B8.options)==null?void 0:ye.find(te=>te.range==="Custom Date"))&&(B8==null?void 0:B8.isEnableDynamicDate)&&((F4=B8==null?void 0:B8.dynamicDate)==null?void 0:F4.value)){const te=Oa2(((Ue=ob==null?void 0:ob.find(Kn=>{var Ce;return Kn.value===((Ce=B8==null?void 0:B8.dynamicDate)==null?void 0:Ce.value)}))==null?void 0:Ue.count)||0),Le=Uc(te),ai=Uc(te);B8={...B8,options:(wt=B8==null?void 0:B8.options)==null?void 0:wt.map(Kn=>Kn.range==="Custom Date"?{...Kn,startDate:te,endDate:te,timeGrainValue:`${Le} - ${ai}`}:Kn)}}return a==="DATABASE"?{...B8,tableName:`${o}.${n9.tableName.split(".").slice(1).join(".")}`}:B8}))||[];$3($6||[])},[t==null?void 0:t.rlsConditions,e,a,o,S,r2]),F0.useEffect(()=>{let $6;return j7?c0(!0):$6=setTimeout(()=>{c0(!1)},300),()=>clearTimeout($6)},[j7]),F0.useEffect(()=>{t!=null&&t.id&&I2&&!n5&&(t!=null&&t.isMetric)&&(I2==null||I2($6=>{var J6,n9,B8,L9,w8,_9,l5,T5,d4,j5,z6;return[...($6==null?void 0:$6.filter(W8=>W8.id!==(t==null?void 0:t.id)))||[],{filters:[...O8||[],...(J6=T1==null?void 0:T1.tableSettings)!=null&&J6.isServerSidePagination&&(T1==null?void 0:T1.chartType)===m0.table?(n9=b7==null?void 0:b7.map(W8=>W8.condition))==null?void 0:n9.filter(W8=>Gx(W8)):[]],xAxisSettings:{isEnable:!!((B8=T1==null?void 0:T1.dynamicXAxis)!=null&&B8.isEnabled||(L9=T1==null?void 0:T1.enduserMeasureAndDimensions)!=null&&L9.isEnabled)&&Bh.includes((T1==null?void 0:T1.chartType)||""),xaxis:(T1==null?void 0:T1.xAxis)||""},yAxisSettings:{isEnable:!!(!((w8=T1==null?void 0:T1.dynamicYAxis)!=null&&w8.isEnabled)||!((_9=T1==null?void 0:T1.dynamicYAxis)!=null&&_9.selectedOption)||Array.isArray((l5=T1==null?void 0:T1.dynamicYAxis)==null?void 0:l5.selectedOption)),yAxis:((T5=T1==null?void 0:T1.dynamicYAxis)==null?void 0:T5.selectedOption)||""},id:t==null?void 0:t.id,metricRequestData:{isAllClient:u,timeseriesSettings:n5?void 0:{format:((z6=(j5=(d4=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:d4.groupBySettings)==null?void 0:j5.value)==null?void 0:z6.toLowerCase())||"monthly",seriesField:(T1==null?void 0:T1.seriesField)||"",isFiscal:W==="ind"}}}]}))},[t==null?void 0:t.id,t==null?void 0:t.isMetric,O8,T1==null?void 0:T1.timeSeriesSettings,T1==null?void 0:T1.seriesField,n5,W,u,b7,(ne=T1==null?void 0:T1.tableSettings)==null?void 0:ne.isServerSidePagination,T1==null?void 0:T1.chartType,T1==null?void 0:T1.dynamicYAxis,T1==null?void 0:T1.dynamicXAxis]),F0.useEffect(()=>{var $6,J6,n9,B8,L9,w8;if(($6=t==null?void 0:t.drillDownSettings)!=null&&$6.isEnableGroupBy){const _9=t==null?void 0:t.datasetMetricSettings;!((J6=t==null?void 0:t.drillDownSettings)!=null&&J6.configV2)&&!(D7!=null&&D7.configV2)&&((B8=(n9=_9==null?void 0:_9.newDatasetSettings)==null?void 0:n9.selectedMetrics)!=null&&B8.length)&&((w8=(L9=_9==null?void 0:_9.newDatasetSettings)==null?void 0:L9.selectedDims)!=null&&w8.length)?j6(l5=>{var T5,d4,j5;return{...(t==null?void 0:t.drillDownSettings)||{},configV2:{isEnable:!!((T5=t==null?void 0:t.drillDownSettings)!=null&&T5.isEnableGroupBy),levels:(j5=(d4=_9==null?void 0:_9.newDatasetSettings)==null?void 0:d4.selectedDims)==null?void 0:j5.map((z6,W8)=>{var I5,Qe,xe,ce;const d5=(xe=(Qe=(I5=t==null?void 0:t.drillDownSettings)==null?void 0:I5.drilldownChartSettings)==null?void 0:Qe.find(at=>(at==null?void 0:at.name)===(z6==null?void 0:z6.alias)))==null?void 0:xe.chartSettings;return{name:`Drill Level ${W8+1}`,chartSettings:d5||T1,index:em(4),isEnable:W8===0,dimensions:[z6],measures:((ce=_9==null?void 0:_9.newDatasetSettings)==null?void 0:ce.selectedMetrics)||[]}})}}}):D7!=null&&D7.isEnableGroupBy||j6(t==null?void 0:t.drillDownSettings)}},[(H4=t==null?void 0:t.drillDownSettings)==null?void 0:H4.isEnableGroupBy,(X4=t==null?void 0:t.drillDownSettings)==null?void 0:X4.configV2,t==null?void 0:t.datasetMetricSettings,T1]);const{mutateAsync:G3}=B_(),F3=F0.useMemo(()=>{var n9,B8,L9,w8,_9,l5,T5,d4,j5,z6,W8,d5,I5,Qe,xe,ce;const $6=((n9=t==null?void 0:t.datasetMetricSettings)==null?void 0:n9.metricVariables)||[];if(!$6||!Array.isArray($6)||!($6!=null&&$6.length))return[];const J6=[];for(let at=0;at<($6==null?void 0:$6.length);at++){const ye=$6[at],F4=ye.type.value==="custom"&&ye.customQuery&&ye.customColumnName,Ue=F4?{query:db({query:(ye==null?void 0:ye.customQuery)||"",tenancyLevel:a,clientId:o,isAllClient:u,clientColumnType:T||"STRING",dbName:(B8=t==null?void 0:t.companyIntegration)==null?void 0:B8.name,rlsConditions:O8==null?void 0:O8.filter(Ce=>Ce.isVariableFilter),globalFilters:{...n,filters:(L9=n==null?void 0:n.filters)==null?void 0:L9.filter(Ce=>{var Kt;return(Ce==null?void 0:Ce.isVariableFilter)&&!!(Array.isArray(Ce==null?void 0:Ce.value)?(Kt=Ce==null?void 0:Ce.value)!=null&&Kt.length:Ce)})}}),alias:vP}:void 0,wt=(w8=ye.dependOnOptions)!=null&&w8.length?O8==null?void 0:O8.filter(Ce=>ye.dependOnOptions.some(Kt=>{var pr;return Kt.type==="metric"&&((pr=Kt.filter)==null?void 0:pr.value)===Ce.name&&Kt.column})):[],te=(_9=ye.dependOnOptions)!=null&&_9.length?(l5=n==null?void 0:n.filters)==null?void 0:l5.filter(Ce=>{var Kt;return Array.isArray(Ce==null?void 0:Ce.value)?(Kt=Ce==null?void 0:Ce.value)==null?void 0:Kt.length:Ce&&ye.dependOnOptions.some(pr=>{var Cr;return pr.type==="dashboard"&&((Cr=pr.filter)==null?void 0:Cr.value)===Ce.label&&pr.column})}):[],Le=wt==null?void 0:wt.map(Ce=>{var Kt;return{columnName:((Kt=ye.dependOnOptions.find(pr=>{var Cr;return Ce.name===((Cr=pr.filter)==null?void 0:Cr.value)}))==null?void 0:Kt.column)||"",value:Ce.value,as:"string"}}),ai=te==null?void 0:te.map(Ce=>{var Kt;return{columnName:((Kt=ye.dependOnOptions.find(pr=>{var Cr;return Ce.label===((Cr=pr.filter)==null?void 0:Cr.value)}))==null?void 0:Kt.column)||"",value:fb(Ce==null?void 0:Ce.value),as:"string"}});ye.isClientScoped&&o&&T&&!u&&a==="TABLE"&&((d4=(T5=ye.clientColumn)==null?void 0:T5.name)!=null&&d4.value)&&((z6=(j5=ye.clientColumn)==null?void 0:j5.datatype)!=null&&z6.value)&&Le.push({columnName:(d5=(W8=ye.clientColumn)==null?void 0:W8.name)==null?void 0:d5.value,value:o,as:(Qe=(I5=ye.clientColumn)==null?void 0:I5.datatype)==null?void 0:Qe.value});const Kn=[...Le,...ai];J6.push({object:{wId:g,tableName:F4?"":(xe=ye==null?void 0:ye.table)==null?void 0:xe.value,columnName:F4?(ye==null?void 0:ye.customColumnName)||"":((ce=ye==null?void 0:ye.column)==null?void 0:ce.value)||"",filter:Kn,customTable:Ue,limit:"1",datasourceId:H,databaseName:a==="MULTI_DATABASE"&&o||""},element:ye})}return J6},[(L4=t==null?void 0:t.datasetMetricSettings)==null?void 0:L4.metricVariables,JSON.stringify(n==null?void 0:n.filters),O8,T,g,a,o,u,H]),x7=async $6=>{var n9,B8,L9,w8,_9;k2(!0);const J6={};$6==null||$6.forEach(l5=>{var T5,d4;J6[(T5=l5==null?void 0:l5.element)==null?void 0:T5.name]=((d4=l5==null?void 0:l5.element)==null?void 0:d4.defaultValue)||""}),o5(J6);for(let l5=0;l5<($6==null?void 0:$6.length);l5++){const T5=$6[l5];if(J6[T5.element.name]=T5.element.defaultValue||"",k2(!0),T5.object.wId&&(!((B8=(n9=T5==null?void 0:T5.object)==null?void 0:n9.customTable)!=null&&B8.query)||!((_9=(w8=(L9=T5==null?void 0:T5.object)==null?void 0:L9.customTable)==null?void 0:w8.query)!=null&&_9.includes("{{")))){const d4=await G3(T5.object);d4!=null&&d4.data&&Array.isArray(d4.data)&&o5(j5=>{var z6,W8;return{...j5,[T5.element.name]:((W8=(z6=d4==null?void 0:d4.data)==null?void 0:z6[0])==null?void 0:W8.value)||T5.element.defaultValue||""}})}}setTimeout(()=>{k2(!1)},200)};F0.useEffect(()=>{F3!=null&&F3.length&&x7(F3)},[JSON.stringify(F3)]);const y7=F0.useMemo(()=>{var $6,J6,n9,B8;return(B8=(n9=(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)==null?void 0:J6.selectedDims)==null?void 0:n9[0])==null?void 0:B8.name},[t]);F0.useMemo(()=>{var $6,J6,n9,B8;return xa2(((B8=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.selectedDimensions)==null?void 0:B8[p7.length<((n9=(J6=t==null?void 0:t.datasetMetricSettings)==null?void 0:J6.selectedDimensions)==null?void 0:n9.length)?p7.length:0])||"")},[t==null?void 0:t.datasetMetricSettings,p7]),F0.useEffect(()=>{var n9,B8,L9;const J6=((n9=t==null?void 0:t.drillDownSettings)==null?void 0:n9.isEnableGroupBy)?I3||[]:[...I3!=null&&I3.length?I3:[],...l||[]];(B8=J6==null?void 0:J6.filter(w8=>w8.isAddOnMetrics))!=null&&B8.length?O9((L9=J6.filter(w8=>w8.isAddOnMetrics))==null?void 0:L9.map(w8=>{var _9,l5,T5,d4,j5;return s?{...w8,dimensionColumn:(T1==null?void 0:T1.xAxis)||"",measureColumn:((_9=T1==null?void 0:T1.yAxisList)==null?void 0:_9[0])||"",options:w8.datatype!==Ku?[]:w8.options,variableOptions:w8.datatype!==Ku?[]:w8.variableOptions}:{...w8,dimensionColumn:(T1==null?void 0:T1.xAxis)||"",measureColumn:((l5=T1==null?void 0:T1.yAxisList)==null?void 0:l5[0])||"",value:w8.isAppFilter?w8.datatype==="date"?(T5=w8==null?void 0:w8.options)==null?void 0:T5.find(z6=>{var W8;return z6.name===((W8=r==null?void 0:r.values)==null?void 0:W8[w8.name])||w8.value}):((d4=r==null?void 0:r.values)==null?void 0:d4[w8.name])||w8.value:w8.value,options:w8.datatype!==Ku?[]:(j5=w8==null?void 0:w8.options)==null?void 0:j5.map(z6=>W==="ind"&&w8.datatype===Ku?{...z6,isFiscal:!0}:z6),variableOptions:w8.datatype!==Ku?[]:w8.variableOptions}}).filter(w8=>Gx(w8))):O9([])},[I3,r,l,(Re=t==null?void 0:t.drillDownSettings)==null?void 0:Re.isEnableGroupBy,a,s,o,W]);const Q6=F0.useMemo(()=>{var $6,J6,n9;return(T1==null?void 0:T1.chartType)===m0.singleValue&&!!(($6=T1==null?void 0:T1.customSettings)!=null&&$6.comparisonValueShow)&&!!((J6=T1==null?void 0:T1.customSettings)!=null&&J6.comparisonTimeGrain)&&!!((n9=T1==null?void 0:T1.customSettings)!=null&&n9.comparisonTimePeriod)&&!!(T1!=null&&T1.singleValue)},[T1]);F0.useEffect(()=>{var L9,w8,_9,l5,T5;const $6=o7;let J6=$6!=null&&$6.data&&typeof $6.data=="string"?JSON.parse($6.data):$6!=null&&$6.data&&Array.isArray($6==null?void 0:$6.data)?$6==null?void 0:$6.data:[];g5({data:[],error:"",isLoading:!1,currentValue:""}),(T1==null?void 0:T1.chartType)===m0.table&&v3(($6==null?void 0:$6.totalRecords)||0),J6=Va2(J6||[],((w8=(L9=t==null?void 0:t.datasetMetricSettings)==null?void 0:L9.newDatasetSettings)==null?void 0:w8.selectedDims)||[],((l5=(_9=t==null?void 0:t.datasetMetricSettings)==null?void 0:_9.newDatasetSettings)==null?void 0:l5.selectedMetrics)||[]);const n9=(()=>{var d4,j5,z6,W8;if(!Array.isArray(J6))return[];if(((j5=(d4=t==null?void 0:t.companyIntegration)==null?void 0:d4.name)==null?void 0:j5.toLowerCase())===Ag&&!n5){const d5=(z6=t==null?void 0:t.datasetMetricSettings)==null?void 0:z6.newDatasetSettings,I5=(d5==null?void 0:d5.selectedMetrics)||[],Qe=((W8=d5==null?void 0:d5.selectedDims)==null?void 0:W8.filter(ce=>{var at,ye;return!((ye=(at=ce==null?void 0:ce.alias)==null?void 0:at.toLowerCase())!=null&&ye.match(/monthly|quarterly|weekly|yearly|daily/))}))||[],xe=[...Qe==null?void 0:Qe.map(ce=>ce.alias),...I5==null?void 0:I5.map(ce=>ce.alias)];return Sa2(xe,J6)}return J6})();if(X7(n9),(T5=t==null?void 0:t.datasetMetricSettings)!=null&&T5.isUseRawSQL){const d4=Object.keys((n9==null?void 0:n9[0])||{})||[];s9(j5=>({...j5,yAxisList:d4||(j5==null?void 0:j5.yAxisList)||[]}))}const B8=$6==null?void 0:$6.metaData;M6(_Y(B8==null?void 0:B8.groupbyColumnList)),l3(d4=>({...d4,report:"",isLoading:d4==null?void 0:d4.isLoading,isOpen:d4==null?void 0:d4.isOpen}))},[o7,t==null?void 0:t.datasetMetricSettings,n5]),F0.useEffect(()=>{var $6,J6;(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.createdSorts)!=null&&J6.length?p5(!0):p5(!1)},[(Ee=(W4=t==null?void 0:t.datasetMetricSettings)==null?void 0:W4.createdSorts)==null?void 0:Ee.length]),F0.useEffect(()=>{var $6,J6;(T1==null?void 0:T1.chartType)===m0.timeSeries&&((J6=($6=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:$6.groupBySettings)!=null&&J6.value)&&!n5&&s9(n9=>{var B8,L9,w8;return{...n9,xAxis:`${(w8=(L9=(B8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:B8.groupBySettings)==null?void 0:L9.value)==null?void 0:w8.toLowerCase()} of ${y7}`}})},[z3,T1==null?void 0:T1.chartType,T1==null?void 0:T1.timeSeriesSettings,n5]),F0.useEffect(()=>{var $6;if(T1!=null&&T1.isEnableComparisonFilter&&[m0.line].includes(T1==null?void 0:T1.chartType)){const J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings,n9=(J6==null?void 0:J6.selectedMetrics)||[],B8=Object==null?void 0:Object.keys((z3==null?void 0:z3[0])||{});s9(L9=>({...L9,yAxisList:[...B8.filter(w8=>n9==null?void 0:n9.some(_9=>w8.startsWith(_9.alias)))]}))}},[z3,T1==null?void 0:T1.isEnableComparisonFilter,W3,T1==null?void 0:T1.chartType]);const T6=F0.useCallback(($6,J6,n9,B8,L9,w8)=>{w==null||w(N30,t==null?void 0:t.id),$3(B8?_9=>_9==null?void 0:_9.map(l5=>{var T5,d4;return l5.name===$6?{...l5,value:J6,options:(T5=l5.options)==null?void 0:T5.map(j5=>J6===j5.name?{...j5,...B8,timeGrainValue:w8}:j5),variableOptions:(d4=l5.variableOptions)==null?void 0:d4.map(j5=>j5.value===J6?{...j5,...B8,timeGrainValue:w8}:j5),selectedVariableValue:{value:J6,label:J6,endDate:B8.endDate,startDate:B8.startDate,timeGrainValue:w8}}:l5}):L9?_9=>_9==null?void 0:_9.map(l5=>l5.name===$6?{...l5,value:L9!=null&&L9.length?L9==null?void 0:L9.map(T5=>T5.value):void 0,selectedDropdownValue:L9!=null&&L9.length?L9:void 0}:l5):_9=>_9==null?void 0:_9.map(l5=>l5.name===$6?{...l5,value:J6,selectedVariableValue:{value:J6,label:J6},selectedDropdownValue:{value:J6,label:n9||J6}}:l5))},[]),N6=F0.useCallback($6=>{var J6,n9;$6!=null&&$6.event&&((n9=(J6=$6==null?void 0:$6.event)==null?void 0:J6.event)==null||n9.preventDefault()),t0($6)},[I3]),{getUnderlyingData:M3}=m70({clientName:o,dbName:(C1=t==null?void 0:t.companyIntegration)==null?void 0:C1.name,tenancyType:a,values:r5,companyId:t==null?void 0:t.companyId,query:Fd(t==null?void 0:t.query,t==null?void 0:t.companyId),workspaceId:g,metricId:t==null?void 0:t.id,rlsConditions:O8,globalFilters:n,isAllClient:!!u,dataMartRelationships:Y5,customSql:(Y3=(z1=t==null?void 0:t.clickActions)==null?void 0:z1.underlyingData)==null?void 0:Y3.sql,isEnableCustomSQL:(T1==null?void 0:T1.chartType)===m0.singleValue&&((K7=(S3=t==null?void 0:t.clickActions)==null?void 0:S3.underlyingData)==null?void 0:K7.isEnable)&&((a7=(s3=t==null?void 0:t.clickActions)==null?void 0:s3.underlyingData)==null?void 0:a7.sql),datasourceId:H}),D9=F0.useMemo(()=>Array.isArray(z3)&&z3.length&&(w3!=null&&w3.name)?z3==null?void 0:z3.map($6=>{const J6=Object.entries($6).find(([,n9])=>(typeof n9=="number"&&typeof(w3==null?void 0:w3.name)=="string"?n9==null?void 0:n9.toString():n9)===w3.name);return J6==null?void 0:J6[0]}).filter($6=>$6)[0]:"",[z3,w3==null?void 0:w3.name]),h8=async($6,J6,n9,B8)=>{var Ue,wt,te,Le,ai,Kn,Ce,Kt,pr,Cr,hn,En,Qr,Rn,ho,Jn,Zn,Yi,Wi,Vi,So,Dr,xi,Eo,na,ga,Go;const L9=t==null?void 0:t.datasetMetricSettings;if(!(D7!=null&&D7.configV2)||!((Ue=L9==null?void 0:L9.newDatasetSettings)!=null&&Ue.configuration)||!((wt=t==null?void 0:t.companyIntegration)!=null&&wt.name)||!$6)return;let w8=$6;const _9=(w8==null?void 0:w8.levels)||[],l5=_9==null?void 0:_9.find(ve=>n9?ve.index===n9:ve==null?void 0:ve.isEnable),T5=_9==null?void 0:_9.findIndex(ve=>n9?ve.index===n9:ve==null?void 0:ve.isEnable),d4=T5>=0&&T5<(_9==null?void 0:_9.length)-1,j5=d4?_9==null?void 0:_9[T5+1]:_9==null?void 0:_9[0],z6=J6==null?void 0:J6.name,W8=(J6==null?void 0:J6.rowFilters)||[],d5=(Le=(te=l5==null?void 0:l5.dimensions)==null?void 0:te[0])==null?void 0:Le.alias;!l5||B8?w8={...w8||{},levels:((ai=w8==null?void 0:w8.levels)==null?void 0:ai.map((ve,Mr)=>Mr==0?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:n9&&l5?w8={...w8||{},levels:((Kn=w8==null?void 0:w8.levels)==null?void 0:Kn.map((ve,Mr)=>ve.index===(l5==null?void 0:l5.index)?{...ve,filters:[...(l5==null?void 0:l5.filters)||[]],isEnable:!0}:{...ve,filters:Mr>T5?[]:ve==null?void 0:ve.filters,isEnable:!1}))||[]}:(z6&&d5||W8!=null&&W8.length)&&l5?w8={...w8||{},levels:((Ce=w8==null?void 0:w8.levels)==null?void 0:Ce.map(ve=>ve.index===(j5==null?void 0:j5.index)?{...ve,filters:d4?[...(l5==null?void 0:l5.filters)||[],...W8!=null&&W8.length?W8:[{columnName:d5,value:z6}]]:[],isEnable:!0}:{...ve,isEnable:!1}))||[]}:w8={...w8||{},levels:((Kt=w8==null?void 0:w8.levels)==null?void 0:Kt.map(ve=>ve.index===(l5==null?void 0:l5.index)?{...ve,filters:[],isEnable:!0}:{...ve,isEnable:!1}))||[]},w8={...w8||{},levels:((pr=w8==null?void 0:w8.levels)==null?void 0:pr.map(ve=>{var Mr,ki;return{...ve,dimensions:((Mr=ve==null?void 0:ve.dimensions)==null?void 0:Mr.filter(er=>{var tr,un;return(un=(tr=L9==null?void 0:L9.newDatasetSettings)==null?void 0:tr.selectedDims)==null?void 0:un.some(e9=>e9.alias===(er==null?void 0:er.alias))}))||[],measures:((ki=ve==null?void 0:ve.measures)==null?void 0:ki.filter(er=>{var tr,un;return(un=(tr=L9==null?void 0:L9.newDatasetSettings)==null?void 0:tr.selectedMetrics)==null?void 0:un.some(e9=>e9.alias===(er==null?void 0:er.alias))}))||[]}}))||[]};const I5=(Cr=w8==null?void 0:w8.levels)==null?void 0:Cr.find(ve=>ve==null?void 0:ve.isEnable),Qe=!!((Qr=(En=w8==null?void 0:w8.levels)==null?void 0:En[((hn=w8==null?void 0:w8.levels)==null?void 0:hn.length)-1])!=null&&Qr.isEnable);(ho=(Rn=w8==null?void 0:w8.levels)==null?void 0:Rn[0])==null||ho.isEnable;const xe=(I5==null?void 0:I5.chartSettings)||T1,ce=(xe==null?void 0:xe.chartType)===m0.table,at=[...((Jn=I5==null?void 0:I5.dimensions)==null?void 0:Jn.map(ve=>ve.alias))||[],...((Zn=I5==null?void 0:I5.measures)==null?void 0:Zn.map(ve=>ve.alias))||[]],ye={...xe,xAxis:((Wi=(Yi=I5==null?void 0:I5.dimensions)==null?void 0:Yi[0])==null?void 0:Wi.alias)||"",yAxisList:Qe&&!(xe!=null&&xe.chartType)||ce?at:((Vi=I5==null?void 0:I5.measures)==null?void 0:Vi.map(ve=>ve.alias))||[],chartType:Qe&&!(xe!=null&&xe.chartType)?m0.table:xe==null?void 0:xe.chartType},F4=`${(xi=(Dr=(So=I5==null?void 0:I5.dimensions)==null?void 0:So[0])==null?void 0:Dr.table)==null?void 0:xi.schemaName}.${(ga=(na=(Eo=I5==null?void 0:I5.dimensions)==null?void 0:Eo[0])==null?void 0:na.table)==null?void 0:ga.tableName}`;if(j6(ve=>{var Mr;return{...ve,configV2:{...w8||{},levels:((Mr=w8==null?void 0:w8.levels)==null?void 0:Mr.map(ki=>ki.index===(I5==null?void 0:I5.index)?{...ki,chartSettings:ye}:ki))||[]}}}),s9(ve=>ye),(Go=t==null?void 0:t.drillDownSettings)!=null&&Go.isEnableCrossFilter){const ve=(()=>{var Mr;if(B8||n9)return[];if((z6&&d5||W8!=null&&W8.length)&&l5){if(W8!=null&&W8.length){const ki=(Mr=W8==null?void 0:W8.map(er=>{var e9,z5,T4,At;const tr=(z5=(e9=L9==null?void 0:L9.newDatasetSettings)==null?void 0:e9.selectedDims)==null?void 0:z5.find(Ht=>(Ht==null?void 0:Ht.alias)===(er==null?void 0:er.columnName)),un=`${(T4=tr==null?void 0:tr.table)==null?void 0:T4.schemaName}.${(At=tr==null?void 0:tr.table)==null?void 0:At.tableName}`;if(tr)return{columnName:er==null?void 0:er.columnName,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[er==null?void 0:er.value],tableName:a==="DATABASE"?`${o}.${un==null?void 0:un.split(".").slice(1).join(".")}`:un,value:[er==null?void 0:er.value]}}))==null?void 0:Mr.filter(er=>er);return[...l||[],...ki]}if(d5&&z6)return[...l||[],{columnName:d5,datatype:"string",isAddOnMetrics:!0,name:"cross-filter",options:[z6],tableName:a==="DATABASE"?`${o}.${F4==null?void 0:F4.split(".").slice(1).join(".")}`:F4,value:[z6]}]}return[]})();C==null||C(ve)}},t9=async($6,J6)=>{await h8(D7==null?void 0:D7.configV2,$6)},o8=({filters:$6,nextLevel:J6,currentValue:n9})=>{var at,ye;const B8=(at=t==null?void 0:t.datasetMetricSettings)==null?void 0:at.newDatasetSettings,L9=B8==null?void 0:B8.configuration,w8=(B8==null?void 0:B8.selectedDims)||[],_9=(B8==null?void 0:B8.selectedMetrics)||[],l5=((ye=t==null?void 0:t.datasetMetricSettings)==null?void 0:ye.createdSorts)||[],{headerColumns:T5,nonHeaderColumns:d4}=w8.reduce((F4,Ue)=>{var wt,te;return(te=(wt=T1==null?void 0:T1.pivotTableSettings2)==null?void 0:wt.headers)!=null&&te.includes(Ue.alias)?F4.headerColumns.push(Ue):F4.nonHeaderColumns.push(Ue),F4},{headerColumns:[],nonHeaderColumns:[]}),j5=$6==null?void 0:$6.map(F4=>`${F4.columnName};;${F4.value}`).join(";;");g5(F4=>({...F4,data:F4.data.filter(Ue=>Ue.key!==j5),error:"",isLoading:!0,currentValue:n9}));const z6=d4.slice(0,J6),W8=$6==null?void 0:$6.map(F4=>{const Ue=w8.find(wt=>wt.alias===F4.columnName);if(Ue)return{alias:Ue.alias||"",columnName:Ue.name,dataType:Ue.datatype,method:"=",parentAlias:Ue.parentAlias,type:"dimension",value:F4.value,relationOperator:"AND"}}).filter(F4=>F4),d5=[...z6,..._9,...T5],{aggregates:I5,dimensions:Qe}=wu(d5),xe=FJ2(l5),ce={...L9,dimensions:Qe,aggregates:I5,filters:[...L9.filters,...W8],orders:(xe==null?void 0:xe.filter(F4=>(F4==null?void 0:F4.type)==="selected_column"?d5==null?void 0:d5.some(Ue=>(Ue==null?void 0:Ue.alias)===(F4==null?void 0:F4.name)):!0))||[],isApplyGlobalFilter:!0,isApplyMetricFilter:!0,globalFilters:n,rlsConditions:O8};u6({data:{configuration:ce,id:g,datasourceId:H,dashboardId:"",isCreateMetric:!0},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess(F4){const Ue=F4==null?void 0:F4.error,wt=F4==null?void 0:F4.data;Ue!=null&&Ue.message?g5(te=>({...te,error:Ue==null?void 0:Ue.message,isLoading:!1,currentValue:""})):(g5(te=>({data:[...te.data,{key:j5,data:Array.isArray(wt)?wt:[]}],error:"",isLoading:!1,currentValue:""})),s9(te=>{var Le,ai;return{...te,pivotTableSettings2:{...T1==null?void 0:T1.pivotTableSettings2,dimensions:UB(z6,((Le=t==null?void 0:t.companyIntegration)==null?void 0:Le.name)||""),headers:UB(T5,((ai=t==null?void 0:t.companyIntegration)==null?void 0:ai.name)||"")}}}))}})},r9=F0.useCallback(async($6,J6)=>{await h8(D7==null?void 0:D7.configV2,void 0,$6,J6)},[D7==null?void 0:D7.configV2]),y8=F0.useCallback($6=>{var J6;if($6)$3(n9=>[...n9==null?void 0:n9.filter(B8=>B8.group!==`${W3}`)]),g7(n9=>n9-1);else{const n9=(J6=I3.filter(B8=>!(B8!=null&&B8.group)))==null?void 0:J6.map(B8=>{var L9,w8,_9,l5;return{...B8,name:`${B8==null?void 0:B8.name}_${W3+1}`,group:`${W3+1}`,dependOn:B8.dependOn?{value:`${(L9=B8.dependOn)==null?void 0:L9.value}_${W3+1}`,label:`${(w8=B8.dependOn)==null?void 0:w8.label}_${W3+1}`,customColumnName:(_9=B8.dependOn)==null?void 0:_9.customColumnName}:void 0,dependOns:((l5=B8==null?void 0:B8.dependOns)==null?void 0:l5.map(T5=>({value:`${T5==null?void 0:T5.value}_${W3+1}`,label:`${T5==null?void 0:T5.label}_${W3+1}`,customColumnName:T5==null?void 0:T5.customColumnName})))||[]}});n9.length&&($3(B8=>[...B8,...n9]),g7(B8=>B8+1))}},[I3]),k9=F0.useCallback(async()=>{I1.report?l3($6=>({...$6,isOpen:!0})):(l3({report:"",isLoading:!0,isOpen:!0}),await v7({data:{data:z3,wId:g},clientId:A?d||"":o,token:f||"",isFrontendApp:A},{onSuccess($6){const J6=$6==null?void 0:$6.content;l3(n9=>({...n9,report:J6||"",isLoading:!1}))},onError(){l3($6=>({...$6,report:"",isLoading:!1}))}}))},[z3,o,A,f,d,o,I1]),w5=F0.useMemo(()=>{var T5,d4,j5,z6,W8,d5;const $6=(T5=t==null?void 0:t.datasetMetricSettings)==null?void 0:T5.newDatasetSettings,J6=$6==null?void 0:$6.configuration,n9=Yx(z3||[]);let B8=n9;const L9=((d4=$6==null?void 0:$6.selectedDims)==null?void 0:d4.some(I5=>{var Qe,xe,ce;return ul.includes(((xe=(Qe=I5==null?void 0:I5.cast)==null?void 0:Qe.value)==null?void 0:xe.toLowerCase())||((ce=I5==null?void 0:I5.datatype)==null?void 0:ce.toLowerCase())||"")}))||VJ2((z3==null?void 0:z3[0])||""),w8=((j5=$6==null?void 0:$6.selectedDims)==null?void 0:j5.length)>1&&((z6=$6==null?void 0:$6.selectedMetrics)==null?void 0:z6.length)>0,_9=[m0.pivot,m0.pivotV2,m0.pivotV3,m0.timeSeries,m0.treeMap,m0.indianMap,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap],l5=!!((W8=J6==null?void 0:J6.aggregates)!=null&&W8.length)&&!!((d5=J6==null?void 0:J6.dimensions)!=null&&d5.length);return l5&&L9&&(B8=[...n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5))),..._9]),l5&&!L9&&(B8=[...n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5))),..._9==null?void 0:_9.filter(I5=>I5!==m0.timeSeries)]),!l5&&L9&&(B8=[...n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5))),m0.timeSeries]),!l5&&!L9&&(B8=n9==null?void 0:n9.filter(I5=>!(_9!=null&&_9.includes(I5)))),D7!=null&&D7.isEnableGroupBy&&(D7!=null&&D7.configV2)&&(B8=B8==null?void 0:B8.filter(I5=>ib==null?void 0:ib.includes(I5))),w8||(B8=B8==null?void 0:B8.filter(I5=>I5!==m0.bubbleV2)),B8},[z3,T1==null?void 0:T1.xAxis,D7==null?void 0:D7.isEnableGroupBy,D7==null?void 0:D7.configV2,(z8=(F6=(y6=t==null?void 0:t.datasetMetricSettings)==null?void 0:y6.newDatasetSettings)==null?void 0:F6.configuration)==null?void 0:z8.aggregates,(R9=(c9=(K8=t==null?void 0:t.datasetMetricSettings)==null?void 0:K8.newDatasetSettings)==null?void 0:c9.configuration)==null?void 0:R9.dimensions]),o9=$6=>{var l5,T5,d4;const J6=(l5=t==null?void 0:t.datasetMetricSettings)==null?void 0:l5.newDatasetSettings,n9=J6==null?void 0:J6.configuration,B8=(J6==null?void 0:J6.selectedDims)||[],L9=(J6==null?void 0:J6.selectedMetrics)||[],w8=(T5=t==null?void 0:t.companyIntegration)==null?void 0:T5.name,_9=(d4=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:d4.isEnabled;kJ2({chartAggregateColumns:XY(UB((L9==null?void 0:L9.filter(j5=>{var z6,W8;return j5.configType==="AGGREGATE"&&_9?(W8=(z6=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:z6.measures)==null?void 0:W8.some(d5=>d5.value===j5.alias):!0}))||[],w8),z3||[]),chartDimensions:XY(UB((B8==null?void 0:B8.filter(j5=>{var z6,W8;return _9?(W8=(z6=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:z6.dimensions)==null?void 0:W8.some(d5=>d5.value===j5.alias):!0}))||[],w8),z3||[]),chartMetrics:XY(UB((L9==null?void 0:L9.filter(j5=>{var z6,W8;return _9?(W8=(z6=T1==null?void 0:T1.enduserMeasureAndDimensions)==null?void 0:z6.measures)==null?void 0:W8.some(d5=>d5.value===j5.alias):!0}))||[],w8),z3||[]),chartSettings:T1,chartTimeColumns:UB(B8==null?void 0:B8.filter(j5=>{var z6;return ul.includes((z6=j5.datatype)==null?void 0:z6.toLowerCase())}),w8),chartType:$6,configAggregates:n9==null?void 0:n9.aggregates,configuration:J6==null?void 0:J6.configuration,pivotHeaderColumns:[],resultData:z3||[],setChartSettings:s9})},C4=F0.useMemo(()=>RP(I3.filter($6=>$6.group&&$6.isAddOnMetrics&&!$6.isAppFilter),"group"),[I3]),P5=F0.useMemo(()=>{var n9,B8;return((n9=T1==null?void 0:T1.customSettings)==null?void 0:n9.comparisonValueShow)&&(T1==null?void 0:T1.chartType)===m0.singleValue?(B8=n==null?void 0:n.filters)==null?void 0:B8.find(L9=>(L9==null?void 0:L9.as)==="date"):void 0},[(q9=T1==null?void 0:T1.customSettings)==null?void 0:q9.comparisonValueShow,T1==null?void 0:T1.chartType,(M1=n==null?void 0:n.filters)==null?void 0:M1.find($6=>($6==null?void 0:$6.as)==="date")]);F0.useEffect(()=>{z3!=null&&z3.length&&q7.length?a9(!0):a9(!1)},[z3,q7.length,t==null?void 0:t.integrationName,t==null?void 0:t.query]);const D5=F0.useMemo(()=>{var $6,J6,n9,B8,L9,w8;return(n9=(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)==null?void 0:J6.selectedMetrics)!=null&&n9.some(_9=>_9.configType==="AGGREGATE")?((w8=(L9=(B8=t==null?void 0:t.datasetMetricSettings)==null?void 0:B8.newDatasetSettings)==null?void 0:L9.selectedDims)==null?void 0:w8.map(_9=>({value:_9.alias,label:_9.alias})))||[]:[]},[(R3=t==null?void 0:t.datasetMetricSettings)==null?void 0:R3.newDatasetSettings]),X5=F0.useMemo(()=>{var $6,J6,n9;return((n9=(J6=($6=t==null?void 0:t.datasetMetricSettings)==null?void 0:$6.newDatasetSettings)==null?void 0:J6.selectedMetrics)==null?void 0:n9.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)})))||[]},[(H7=(J3=t==null?void 0:t.datasetMetricSettings)==null?void 0:J3.newDatasetSettings)==null?void 0:H7.selectedMetrics]),{metricFilters:R4,leftPositionedMetricFilters:V5,rightPositionedMetricFilters:u8}=F0.useMemo(()=>{const $6=I3.filter(L9=>!L9.isAppFilter);let J6=$6.filter(L9=>L9.isAddOnMetrics);D2&&(J6=J6.filter(L9=>Gx(L9,!0)));const n9=[],B8=[];return J6.forEach(L9=>{L9.position==="top-right"?B8.push(L9):n9.push(L9)}),{metricFilters:$6,leftPositionedMetricFilters:n9,rightPositionedMetricFilters:B8}},[I3]),j8=[m0.pie,m0.doughnut,m0.rose,m0.funnel,m0.singleValue,m0.table,m0.pivot,m0.horizontalStackTable,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.sankey,m0.timeSeries,m0.geoBarMap,m0.geoMap,m0.geoScatterMap,m0.worldMap,m0.boxplot,m0.timeSeries,m0.gantt].includes(T1==null?void 0:T1.chartType)||((T1==null?void 0:T1.isMultiDimension)||(T1==null?void 0:T1.isDynamicSeries))&&(T1==null?void 0:T1.seriesField)!=="ungrouped",A8=F0.useMemo(()=>{var J6;const $6=((J6=t==null?void 0:t.dataSecuritySettings)==null?void 0:J6.csvColumns)||[];return z3!=null&&z3.length?z3==null?void 0:z3.map(n9=>{const B8={};for(const L9 in n9)$6!=null&&$6.includes(L9)||(B8[L9]=n9[L9]);return B8}):[]},[z3,t==null?void 0:t.dataSecuritySettings]);F0.useEffect(()=>{var $6,J6;T1||(s9(t==null?void 0:t.chartOptions),Q3({limit:parseInt(((J6=($6=t==null?void 0:t.chartOptions)==null?void 0:$6.tableSettings)==null?void 0:J6.defaultRowSize)||"100",10),offset:0}))},[t==null?void 0:t.chartOptions,T1]),F0.useEffect(()=>{var $6,J6,n9,B8,L9,w8,_9,l5,T5,d4;if((T1==null?void 0:T1.chartType)===m0.timeSeries&&((J6=($6=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:$6.groupBySettings)!=null&&J6.isGlobalFilter)&&y7){const j5=(B8=(n9=n==null?void 0:n.filters)==null?void 0:n9.find(z6=>{var W8,d5,I5;return z6.label===((I5=(d5=(W8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:W8.groupBySettings)==null?void 0:d5.globalFilterOption)==null?void 0:I5.value)}))==null?void 0:B8.value;if((typeof j5=="string"||typeof j5=="object"&&(j5!=null&&j5.value))&&j5){const z6=typeof j5=="string"?(L9=fb(j5))==null?void 0:L9.toLowerCase():((d4=(T5=(l5=(_9=(w8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:w8.groupBySettings)==null?void 0:_9.formatWithValue)==null?void 0:l5.find(W8=>W8.value===fb(j5==null?void 0:j5.value)))==null?void 0:T5.format)==null?void 0:d4.toLowerCase())||"";cC!=null&&cC.find(W8=>{var d5;return((d5=W8==null?void 0:W8.value)==null?void 0:d5.toLowerCase())===z6})&&s9(W8=>{var d5;return{...W8,timeSeriesSettings:{...W8==null?void 0:W8.timeSeriesSettings,groupBySettings:{...(d5=W8==null?void 0:W8.timeSeriesSettings)==null?void 0:d5.groupBySettings,value:z6}},xAxis:n5?W8.xAxis:`${z6} of ${y7}`}})}}},[n,T1==null?void 0:T1.chartType,(g8=(m6=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:m6.groupBySettings)==null?void 0:g8.isGlobalFilter,(d8=(n8=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:n8.groupBySettings)==null?void 0:d8.globalFilterOption,y7]),F0.useEffect(()=>{var $6,J6,n9,B8;T1!=null&&T1.isDynamicSeries&&(($6=T1==null?void 0:T1.seriesOptions)!=null&&$6.includes("ungrouped")?T1!=null&&T1.ungroupedAlias?p4((J6=T1==null?void 0:T1.seriesOptions)==null?void 0:J6.map(L9=>L9==="ungrouped"?{value:L9,label:T1==null?void 0:T1.ungroupedAlias}:{value:L9,label:L9})):p4((n9=T1==null?void 0:T1.seriesOptions)==null?void 0:n9.map(L9=>({value:L9,label:L9}))):p4([...((B8=T1==null?void 0:T1.seriesOptions)==null?void 0:B8.map(L9=>({value:L9,label:L9})))??[]]))},[T1==null?void 0:T1.seriesOptions,T1==null?void 0:T1.isDynamicSeries,T1==null?void 0:T1.ungroupedAlias]);const[D6,G9]=F0.useState(!1),J8=$6=>{$6.key==="Control"&&G9(!0)},f9=$6=>{$6.key==="Control"&&G9(!1)};F0.useEffect(()=>{z3!=null&&z3.length&&H6(Object.keys((z3==null?void 0:z3[0])||{}))},[z3==null?void 0:z3.length]),F0.useEffect(()=>{var $6,J6;return(J6=($6=T1==null?void 0:T1.customSettings)==null?void 0:$6.chartZoom)!=null&&J6.isZoomEnabled&&(window.addEventListener("keydown",J8),window.addEventListener("keyup",f9)),()=>{window.removeEventListener("keydown",J8),window.removeEventListener("keyup",f9)}},[]);const Q9=F0.useMemo(()=>{let $6=!1;if(z3!=null&&z3.length){const J6=T1==null?void 0:T1.singleValue;$6=z3[0][J6]===null&&(T1==null?void 0:T1.chartType)==="singleValue"}return $6},[z3==null?void 0:z3.length,T1==null?void 0:T1.singleValue,(T1==null?void 0:T1.chartType)==="singleValue"]),r8=F0.useMemo(()=>Xf({chartOptions:T1,data:z3||[]}),[z3,T1==null?void 0:T1.xAxis,T1==null?void 0:T1.yAxisList,(N8=T1==null?void 0:T1.dynamicXAxis)==null?void 0:N8.isEnabled,T1==null?void 0:T1.chartType,T1==null?void 0:T1.seriesField,(_8=T1==null?void 0:T1.customSettings)==null?void 0:_8.cumulativeBar,T1==null?void 0:T1.isGroupXAxis,(f5=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:f5.seriesType[0],(s5=(Y9=T1==null?void 0:T1.timeSeriesSettings)==null?void 0:Y9.groupBySettings)==null?void 0:s5.fillXAxis]),d9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.name)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.name,L8,X,N]),C9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.longDescription)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.longDescription,L8,N,X]),h9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.description)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.description,L8,N,X]),V9=F0.useMemo(()=>NC({text:DC((t==null?void 0:t.footNote)||"",L8)||"",selectedLanguage:N,translationDictionary:X}),[t==null?void 0:t.footNote,L8,N,X]),a5=F0.useMemo(()=>{var $6;return`${(($6=z3==null?void 0:z3[0])==null?void 0:$6.dbn_metric_expression_data)||"No Data Found"}`},[z3]),P9=F0.useMemo(()=>{var $6;return($6=t==null?void 0:t.rlsConditions)==null?void 0:$6.map(J6=>{var B8,L9,w8,_9;if((J6==null?void 0:J6.datatype)==="date"&&((B8=J6==null?void 0:J6.options)==null?void 0:B8.find(l5=>l5.range==="Custom Date"))&&(J6==null?void 0:J6.isEnableDynamicDate)&&((L9=J6==null?void 0:J6.dynamicDate)==null?void 0:L9.value)){const l5=Oa2(((w8=ob==null?void 0:ob.find(j5=>{var z6;return j5.value===((z6=J6==null?void 0:J6.dynamicDate)==null?void 0:z6.value)}))==null?void 0:w8.count)||0),T5=Uc(l5),d4=Uc(l5);return{...J6,options:(_9=J6==null?void 0:J6.options)==null?void 0:_9.map(j5=>j5.range==="Custom Date"?{...j5,startDate:l5,endDate:l5,timeGrainValue:`${T5} - ${d4}`}:j5)}}return J6})},[t==null?void 0:t.rlsConditions]);F0.useLayoutEffect(()=>{j7&&(b==null||b($6=>{const J6=new Map($6);return J6.set(t==null?void 0:t.id,{data:{data:[],name:"",description:""},isLoading:j7,key:""}),J6})),o7!=null&&o7.data&&p&&(b==null||b($6=>{const J6=new Map($6);return J6.set(t==null?void 0:t.id,{data:{data:o7==null?void 0:o7.data,name:(t==null?void 0:t.name)||"",description:(t==null?void 0:t.description)||""},isLoading:j7,key:JSON.stringify(D8)}),J6}))},[o7==null?void 0:o7.data,j7]);const N4=()=>{var J6,n9,B8;return(((B8=(n9=(J6=t==null?void 0:t.elementSettings)==null?void 0:J6.summary)==null?void 0:n9.metricList)==null?void 0:B8.map(L9=>{var w8;return(w8=p==null?void 0:p.get(L9==null?void 0:L9.value))==null?void 0:w8.isLoading}))||[]).some(L9=>L9===!0)};F0.useLayoutEffect(()=>{var $6,J6,n9,B8,L9,w8,_9,l5,T5,d4,j5;if((J6=($6=t==null?void 0:t.elementSettings)==null?void 0:$6.summary)!=null&&J6.metricList&&(p!=null&&p.get(t==null?void 0:t.id))&&!h0&&!N4()){const z6=((L9=(B8=(n9=t==null?void 0:t.elementSettings)==null?void 0:n9.summary)==null?void 0:B8.metricList)==null?void 0:L9.map(W8=>{var d5,I5,Qe,xe,ce,at,ye,F4,Ue;return{data:(Qe=(I5=(d5=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:d5.data)==null?void 0:I5.data)!=null&&Qe.length?(ce=(xe=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:xe.data)==null?void 0:ce.data:{},metricName:(ye=(at=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:at.data)==null?void 0:ye.name,metricDescription:(Ue=(F4=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:F4.data)==null?void 0:Ue.description}}))||[];b0(""),t1(""),!z6.some(W8=>Object.keys(W8.data).length===0)&&!h0&&(O0(()=>!0),p0.mutate({data:{metricData:z6,summaryPrompt:(_9=(w8=t==null?void 0:t.elementSettings)==null?void 0:w8.summary)==null?void 0:_9.summaryPrompt,id:t==null?void 0:t.id,filters:`${(j5=(d4=(T5=(l5=t==null?void 0:t.elementSettings)==null?void 0:l5.summary)==null?void 0:T5.metricList)==null?void 0:d4.map(W8=>{var d5;return(d5=p==null?void 0:p.get(W8==null?void 0:W8.value))==null?void 0:d5.key}))==null?void 0:j5.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:W8=>{W8.summary?(b0(W8.summary),t1("")):(t1(v22),b0("")),O0(()=>!1)},onSettled:()=>{O0(()=>!1)},onError:W8=>{O0(()=>!1),t1(W8.message),b0("")}}))}},[t==null?void 0:t.elementSettings,p]),F0.useEffect(()=>{var B8,L9,w8,_9,l5,T5,d4,j5,z6,W8,d5,I5,Qe,xe,ce,at,ye,F4,Ue,wt,te,Le,ai,Kn;const $6=oc(((B8=T1==null?void 0:T1.customSettings)==null?void 0:B8.comboAxisSettings)||[]),J6=(L9=$6==null?void 0:$6.map(Ce=>Ce==null?void 0:Ce.measures))==null?void 0:L9.flat(),n9=(w8=T1==null?void 0:T1.yAxisList)==null?void 0:w8.every(Ce=>J6==null?void 0:J6.includes(Ce));if((_9=T1==null?void 0:T1.yAxisList)!=null&&_9.length&&((l5=T1==null?void 0:T1.yAxisList)==null?void 0:l5.length)!==(J6==null?void 0:J6.length)&&!(J6!=null&&J6.length)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((T1==null?void 0:T1.chartType)||"")){const Ce=(d4=(T5=T1==null?void 0:T1.yAxisList)==null?void 0:T5.filter(En=>{var Qr;return!((Qr=T1==null?void 0:T1.comboBarList)!=null&&Qr.includes(En))}))==null?void 0:d4.filter(En=>!(J6!=null&&J6.includes(En))),Kt=((z6=(j5=T1==null?void 0:T1.customSettings)==null?void 0:j5.comboStackAxisSymbols)==null?void 0:z6.name)||"",pr=(I5=(d5=(W8=T1==null?void 0:T1.customSettings)==null?void 0:W8.comboLabelFormatter)==null?void 0:d5.find(En=>En.axis===(Kt||"stack")))==null?void 0:I5.formatter,Cr=(Qe=T1==null?void 0:T1.comboBarList)==null?void 0:Qe.join(" and "),hn=(at=(ce=(xe=T1==null?void 0:T1.customSettings)==null?void 0:xe.comboLabelFormatter)==null?void 0:ce.find(En=>En.axis===Cr))==null?void 0:at.formatter;s9(En=>{var Qr,Rn,ho,Jn,Zn,Yi,Wi,Vi,So,Dr,xi,Eo,na,ga,Go,ve,Mr,ki,er;return{...En,customSettings:{...En.customSettings,comboAxisSettings:oc([...((Qr=En.customSettings)==null?void 0:Qr.comboAxisSettings)||[],...Ce==null?void 0:Ce.map(tr=>{var z5,T4,At,Ht,Wr,it;const un=(At=(T4=(z5=T1==null?void 0:T1.customSettings)==null?void 0:z5.comboLabelFormatter)==null?void 0:T4.find(bt=>bt.axis===tr))==null?void 0:At.formatter,e9=(Wr=(Ht=T1==null?void 0:T1.customSettings)==null?void 0:Ht.comboAxisSymbols)==null?void 0:Wr.find(bt=>bt.name===tr);return{axis:tr,measures:[tr],chartTypes:[{axis:tr,type:"line"}],numberFormatter:(it=T1==null?void 0:T1.customSettings)==null?void 0:it.numberFormatter,labelFormatter:un,prefix:(e9==null?void 0:e9.prefix)||"",suffix:(e9==null?void 0:e9.suffix)||"",isEnableLabelFormatter:!!(un!=null&&un.length)}}),...(Rn=T1==null?void 0:T1.comboBarList)!=null&&Rn.length&&((ho=T1==null?void 0:T1.customSettings)!=null&&ho.isCombineBarAxis||(Jn=T1==null?void 0:T1.customSettings)!=null&&Jn.isStackBar)?[{axis:(Zn=T1==null?void 0:T1.customSettings)!=null&&Zn.isStackBar&&Kt||Cr,measures:T1==null?void 0:T1.comboBarList,chartTypes:(Yi=T1==null?void 0:T1.comboBarList)==null?void 0:Yi.map(tr=>({axis:tr,type:"bar"})),isEnableStackBar:(Wi=T1==null?void 0:T1.customSettings)==null?void 0:Wi.isStackBar,numberFormatter:(Vi=T1==null?void 0:T1.customSettings)==null?void 0:Vi.numberFormatter,...(So=T1==null?void 0:T1.customSettings)!=null&&So.isStackBar?{prefix:((xi=(Dr=T1==null?void 0:T1.customSettings)==null?void 0:Dr.comboStackAxisSymbols)==null?void 0:xi.prefix)||"",suffix:((na=(Eo=T1==null?void 0:T1.customSettings)==null?void 0:Eo.comboStackAxisSymbols)==null?void 0:na.suffix)||"",labelFormatter:pr,isEnableLabelFormatter:!!(pr!=null&&pr.length)}:{prefix:((ga=T1==null?void 0:T1.customSettings)==null?void 0:ga.combinedAxisPrefix)||"",suffix:((Go=T1==null?void 0:T1.customSettings)==null?void 0:Go.combinedAxisSuffix)||"",labelFormatter:hn,isEnableLabelFormatter:!!(hn!=null&&hn.length)}}]:[],...(ve=T1==null?void 0:T1.comboBarList)!=null&&ve.length&&!((Mr=T1==null?void 0:T1.customSettings)!=null&&Mr.isCombineBarAxis)&&!((ki=T1==null?void 0:T1.customSettings)!=null&&ki.isStackBar)?(er=T1==null?void 0:T1.comboBarList)==null?void 0:er.map(tr=>{var z5,T4,At,Ht,Wr,it;const un=(At=(T4=(z5=T1==null?void 0:T1.customSettings)==null?void 0:z5.comboLabelFormatter)==null?void 0:T4.find(bt=>bt.axis===tr))==null?void 0:At.formatter,e9=(Wr=(Ht=T1==null?void 0:T1.customSettings)==null?void 0:Ht.comboAxisSymbols)==null?void 0:Wr.find(bt=>bt.name===tr);return{axis:tr,measures:[tr],chartTypes:[{axis:tr,type:"bar"}],numberFormatter:(it=T1==null?void 0:T1.customSettings)==null?void 0:it.numberFormatter,labelFormatter:un,prefix:(e9==null?void 0:e9.prefix)||"",suffix:(e9==null?void 0:e9.suffix)||"",isEnableLabelFormatter:!!(un!=null&&un.length)}}):[]].filter(tr=>{var un;return(un=tr==null?void 0:tr.measures)==null?void 0:un.length})),comboAxisSymbols:[],combinedAxisPrefix:"",combinedAxisSuffix:"",comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}})}if(J6!=null&&J6.length&&((ye=T1==null?void 0:T1.yAxisList)!=null&&ye.length)&&(((F4=T1==null?void 0:T1.yAxisList)==null?void 0:F4.length)!==(J6==null?void 0:J6.length)||((Ue=T1==null?void 0:T1.yAxisList)==null?void 0:Ue.length)===(J6==null?void 0:J6.length)&&!n9)&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((T1==null?void 0:T1.chartType)||"")){const Ce=(wt=T1==null?void 0:T1.yAxisList)==null?void 0:wt.filter(pr=>!(J6!=null&&J6.includes(pr))),Kt=J6==null?void 0:J6.filter(pr=>{var Cr;return!((Cr=T1==null?void 0:T1.yAxisList)!=null&&Cr.includes(pr))});Kt==null||Kt.forEach(pr=>{var Qr,Rn,ho;const Cr=(Rn=(Qr=T1==null?void 0:T1.customSettings)==null?void 0:Qr.comboAxisSettings)==null?void 0:Rn.find(Jn=>{var Zn;return(Zn=Jn.measures)==null?void 0:Zn.includes(pr)}),hn=Cr==null?void 0:Cr.axis,En=(((ho=Cr==null?void 0:Cr.measures)==null?void 0:ho.length)||0)>1;s9(Jn=>{var Zn,Yi,Wi,Vi,So;return{...Jn,customSettings:{...Jn.customSettings,comboAxisSettings:oc(En?((Wi=(Yi=(Zn=Jn.customSettings)==null?void 0:Zn.comboAxisSettings)==null?void 0:Yi.map(Dr=>{var xi;return Dr.axis===hn?{...Dr,measures:(xi=Dr==null?void 0:Dr.measures)==null?void 0:xi.filter(Eo=>Eo!==pr)}:Dr}))==null?void 0:Wi.filter(Dr=>{var xi;return(xi=Dr==null?void 0:Dr.measures)==null?void 0:xi.length}))||[]:((So=(Vi=Jn.customSettings)==null?void 0:Vi.comboAxisSettings)==null?void 0:So.filter(Dr=>{var xi;return Dr.axis!==hn&&((xi=Dr==null?void 0:Dr.measures)==null?void 0:xi.length)}))||[])}}})}),Ce!=null&&Ce.length&&s9(pr=>{var Cr;return{...pr,customSettings:{...pr.customSettings,comboAxisSettings:oc([...((Cr=pr.customSettings)==null?void 0:Cr.comboAxisSettings)||[],...Ce==null?void 0:Ce.map(hn=>({axis:hn,measures:[hn],chartTypes:[{axis:hn,type:"line"}]}))].filter(hn=>{var En;return(En=hn==null?void 0:hn.measures)==null?void 0:En.length})||[])}}})}J6!=null&&J6.length&&((te=T1==null?void 0:T1.yAxisList)!=null&&te.length)&&((Le=T1==null?void 0:T1.yAxisList)==null?void 0:Le.length)===(J6==null?void 0:J6.length)&&n9&&[m0.combo,m0.timeSeries,m0.horizontalCombo].includes((T1==null?void 0:T1.chartType)||"")&&((Kn=(ai=T1==null?void 0:T1.customSettings)==null?void 0:ai.comboAxisSettings)==null?void 0:Kn.length)!==($6==null?void 0:$6.length)&&s9(Ce=>({...Ce,customSettings:{...Ce==null?void 0:Ce.customSettings,comboAxisSettings:$6}}))},[T1==null?void 0:T1.yAxisList,(Z5=T1==null?void 0:T1.customSettings)==null?void 0:Z5.comboAxisSettings,T1==null?void 0:T1.comboBarList,(Z4=T1==null?void 0:T1.customSettings)==null?void 0:Z4.isCombineBarAxis,(le=T1==null?void 0:T1.customSettings)==null?void 0:le.isStackBar,(pe=(Ve=T1==null?void 0:T1.customSettings)==null?void 0:Ve.comboStackAxisSymbols)==null?void 0:pe.name,(mt=(tt=T1==null?void 0:T1.customSettings)==null?void 0:tt.comboStackAxisSymbols)==null?void 0:mt.prefix,(sn=(Zr=T1==null?void 0:T1.customSettings)==null?void 0:Zr.comboStackAxisSymbols)==null?void 0:sn.suffix,(xn=T1==null?void 0:T1.customSettings)==null?void 0:xn.comboLabelFormatter,(ci=T1==null?void 0:T1.customSettings)==null?void 0:ci.comboAxisSymbols,(ii=T1==null?void 0:T1.customSettings)==null?void 0:ii.numberFormatter,(oi=T1==null?void 0:T1.customSettings)==null?void 0:oi.combinedAxisPrefix,(Ti=T1==null?void 0:T1.customSettings)==null?void 0:Ti.combinedAxisSuffix,T1==null?void 0:T1.chartType]),F0.useEffect(()=>{var $6,J6,n9;($6=T1==null?void 0:T1.yAxisList)!=null&&$6.length&&((J6=T1==null?void 0:T1.yAxisList)==null?void 0:J6.length)<5&&(T1==null?void 0:T1.chartType)===m0.boxplot&&s9(B8=>({...B8,chartType:m0.line})),!((n9=T1==null?void 0:T1.yAxisList)!=null&&n9.length)&&(T1==null?void 0:T1.chartType)===m0.funnelV2&&s9(B8=>({...B8,chartType:m0.singleValue}))},[T1==null?void 0:T1.chartType,(Hi=T1==null?void 0:T1.yAxisList)==null?void 0:Hi.length]);const e4=({columnAlias:$6,value:J6,isClear:n9=!1})=>{const B8=t==null?void 0:t.datasetMetricSettings;B8&&ZJ2({columnAlias:$6,datasetSettings:B8,setTableColumnFilters:I7,value:J6,isClear:n9})};return F0.useEffect(()=>{var J6,n9,B8,L9;if(!((J6=T1==null?void 0:T1.dynamicYAxis)!=null&&J6.isEnabled)||!((n9=T1==null?void 0:T1.dynamicYAxis)!=null&&n9.selectedOption)||Array.isArray((B8=T1==null?void 0:T1.dynamicYAxis)==null?void 0:B8.selectedOption))return;const $6=(L9=T1==null?void 0:T1.dynamicYAxis)==null?void 0:L9.selectedOption;s9(w8=>({...w8,dynamicYAxis:{...w8==null?void 0:w8.dynamicYAxis,selectedOption:[$6]},yAxisList:[$6==null?void 0:$6.value]}))},[(gn=T1==null?void 0:T1.dynamicYAxis)==null?void 0:gn.selectedOption,(Yr=T1==null?void 0:T1.dynamicYAxis)==null?void 0:Yr.isEnabled]),F0.useEffect(()=>{var B8,L9,w8,_9,l5,T5,d4,j5;const $6=(B8=r2==null?void 0:r2.yAxisSettings)==null?void 0:B8.find(z6=>{var W8,d5,I5,Qe,xe;return((W8=z6==null?void 0:z6.yAxisSettings)==null?void 0:W8.isEnable)&&(z6==null?void 0:z6.id)===(t==null?void 0:t.id)&&((d5=z6==null?void 0:z6.yAxisSettings)==null?void 0:d5.yAxis)&&Array.isArray((I5=z6==null?void 0:z6.yAxisSettings)==null?void 0:I5.yAxis)&&((xe=(Qe=z6==null?void 0:z6.yAxisSettings)==null?void 0:Qe.yAxis)==null?void 0:xe.length)>0}),J6=(L9=r2==null?void 0:r2.xAxisSettings)==null?void 0:L9.find(z6=>{var W8,d5;return((W8=z6==null?void 0:z6.xAxisSettings)==null?void 0:W8.isEnable)&&(z6==null?void 0:z6.id)===(t==null?void 0:t.id)&&((d5=z6==null?void 0:z6.xAxisSettings)==null?void 0:d5.xaxis)});if(!((w8=T1==null?void 0:T1.dynamicYAxis)!=null&&w8.isEnabled)&&!((_9=T1==null?void 0:T1.dynamicXAxis)!=null&&_9.isEnabled)&&!((l5=D7==null?void 0:D7.configV2)!=null&&l5.isEnable)||!$6&&!J6&&!((T5=D7==null?void 0:D7.configV2)!=null&&T5.isEnable)){s9(z6=>(t==null?void 0:t.chartOptions)||z6);return}const n9=(j5=(d4=$6==null?void 0:$6.yAxisSettings)==null?void 0:d4.yAxis)==null?void 0:j5[0];s9(z6=>{var W8,d5,I5,Qe,xe,ce,at;return{...z6,dynamicYAxis:{...z6==null?void 0:z6.dynamicYAxis,selectedOption:n9?[n9]:((W8=z6==null?void 0:z6.dynamicYAxis)==null?void 0:W8.selectedOption)||[]},dynamicXAxis:{...z6==null?void 0:z6.dynamicXAxis,selectedOption:(d5=J6==null?void 0:J6.xAxisSettings)!=null&&d5.xaxis?{value:(I5=J6==null?void 0:J6.xAxisSettings)==null?void 0:I5.xaxis,label:(Qe=J6==null?void 0:J6.xAxisSettings)==null?void 0:Qe.xaxis}:((xe=z6==null?void 0:z6.dynamicXAxis)==null?void 0:xe.selectedOption)||[]},yAxisList:n9!=null&&n9.value?[n9==null?void 0:n9.value]:(z6==null?void 0:z6.yAxisList)||[],xAxis:(ce=J6==null?void 0:J6.xAxisSettings)!=null&&ce.xaxis?(at=J6==null?void 0:J6.xAxisSettings)==null?void 0:at.xaxis:(z6==null?void 0:z6.xAxis)||""}})},[r2==null?void 0:r2.yAxisSettings,t==null?void 0:t.id,r2==null?void 0:r2.xAxisSettings,(fi=T1==null?void 0:T1.dynamicYAxis)==null?void 0:fi.isEnabled,(Gi=T1==null?void 0:T1.dynamicXAxis)==null?void 0:Gi.isEnabled,(Ae=D7==null?void 0:D7.configV2)==null?void 0:Ae.isEnable]),F0.useEffect(()=>{var $6,J6,n9;($6=T1==null?void 0:T1.customSettings)!=null&&$6.isShowDuration&&(T1==null?void 0:T1.chartType)===m0.gantt&&!((n9=(J6=T1==null?void 0:T1.customSettings)==null?void 0:J6.ganttTooltipKeys)!=null&&n9.includes("Duration"))&&s9(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"]}}})},[(Hr=T1==null?void 0:T1.customSettings)==null?void 0:Hr.isShowDuration,T1==null?void 0:T1.chartType,(Cn=T1==null?void 0:T1.customSettings)==null?void 0:Cn.ganttTooltipKeys]),{elementSummary:L0,elementSummaryError:j2,isLoadingSummary:h0,isMetricListLoading:N4,onDrillLevelClick:r9,onDrillDown:t9,handleChartClick:N6,dataDb:z3,getUnderlyingData:M3,onChangeFilterValue:T6,isShowChartPopup:R6,setShowChartPopup:h6,columnName:D9,chartParams:w3,isQueryLoading:j7||m2||W2,isSingleValueNull:Q9,dynamicOptions:v5,chartSettings:T1,setChartSettings:s9,isEnableZoom:D6,filterValues:r5,containerRef:U0,drilledLevel:p7.length,dimensions:((Xn=(di=t==null?void 0:t.datasetMetricSettings)==null?void 0:di.selectedDimensions)==null?void 0:Xn.map($6=>xa2($6||"none")))||[],rlsConditions:I3,setRlsConditions:$3,setTableLimit:Q3,isEnableNextBtn:x1>(X2==null?void 0:X2.limit)+(X2==null?void 0:X2.offset),isEnablePrevBtn:(X2==null?void 0:X2.offset)!==0,paginationInfo:{limit:X2==null?void 0:X2.limit,offset:X2==null?void 0:X2.offset,totalRecords:x1},onChangePage:($6,J6,n9)=>{Q3(J6?{limit:J6,offset:0}:B8=>{let L9;return n9||n9===0?L9=n9:$6?L9=B8.offset>B8.limit?B8.offset-B8.limit:0:L9=B8.offset+B8.limit,{limit:B8.limit,offset:L9}})},isExternalChart:((Er=T1==null?void 0:T1.tableSettings)==null?void 0:Er.isServerSidePagination)&&(T1==null?void 0:T1.chartType)===m0.table,isEnablePivotTable:C8,groupByList:q7,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:$6=>{$3(J6=>J6==null?void 0:J6.map(n9=>n9.name===$6.name&&n9.datatype===$6.datatype&&n9.tableName===$6.tableName&&n9.columnName===$6.columnName?{...n9,isAddOnMetrics:!n9.isAddOnMetrics}:n9))},metricFilters:R4,leftPositionedMetricFilters:V5,rightPositionedMetricFilters:u8,drillFilters:p7,drillType:(ln=t==null?void 0:t.drillDownSettings)==null?void 0:ln.drillType,tableResultsDownloadData:A8,appliedMetricFilters:O8,pivotHeaderOptions:D5,pivotDrillState:S9,onDrillPivotTable:o8,legendData:r8,timeseriesDimension:y7,isPythonMode:n5,sortOrder:Y7,setSortOrder:l6,isNotFirstRender:q3,setNotFirstRender:T7,isSorted:W9,isInavlidForSort:j8,onAddComparison:y8,groupedRlsConditions:C4,onGenerateMetricSummary:k9,summary:I1,setSummary:l3,dataMartRelationships:Y5,onChartChange:o9,isCompareValue:Q6,isShowChartPropertyPanel:T8,setShowChartPropertyPanel:y9,columnList:c6,variables:L8,metricName:d9,longDescription:C9,footNote:V9,description:h9,drilldownCols:h7,switchMeasureOptions:X5,metricExpressionResult:a5,dateFilter:P5,drillDownSettings:D7,enabledCharts:w5,tableColumnFilters:b7,onChangePaginationColumnFilters:e4,queryError:p6||(o7==null?void 0:o7.error),refetchMetricData:s6,customSwitchXAxis:E3,savedMetricFilters:P9||[]}},w70=({metricId:t,onSuccess:n,token:i})=>{const{mutateAsync:o,isLoading:a}=X30();return{handleArchiveMetric:F0.useCallback(async()=>{!t||!i||await o({data:{id:t},token:i},{onSuccess:async r=>{r!=null&&r.error||await n()}})},[o,t]),isLoading:a}},Nu2=({token:t,metricId:n})=>{var M2;const[i,o]=F0.useState(!0),{data:a,isLoading:s}=E70(t,n),{externalMetric:r,sharingSettingsId:C,adminTheme:l,params:e,companyId:u,clientId:A,errorMsg:f,clientColumnType:d,isEnableMetricSummary:g,isAllClient:p,isShowUnderlyingData:b,appFilters:w,mergedMetricsId:T,datasourceId:H,mergedMetricLayout:S,mergedDashboardFilters:N,dashboardAppFilterValues:X,filterLayout:W,nestedMetric:f2,guestToken:Q2}=F0.useMemo(()=>{var k2,W2;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:(k2=m2==null?void 0:m2.error)==null?void 0:k2.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:(W2=window==null?void 0:window.dbn)!=null&&W2.isEnableProxyAuth?Fd(m2==null?void 0:m2.token,m2==null?void 0:m2.companyId):m2==null?void 0:m2.token}},[a,(M2=window==null?void 0:window.dbn)==null?void 0:M2.isEnableProxyAuth]),{rlsSettings:I2,tenancyLevel:r2,workspaceId:D2}=F0.useMemo(()=>{var k2,W2;if(!e)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const m2=JSON.parse(e);return{rlsSettings:(k2=m2.rlsSettings)==null?void 0:k2.find(c0=>c0.metricId===n),tenancyLevel:m2.companyTenancyType||"TABLE",workspaceId:((W2=m2==null?void 0:m2.workspace)==null?void 0:W2.id)||""}},[e,n]);return F0.useEffect(()=>{s&&o(!0),(r||f||!s)&&o(!1)},[s,r,f]),{externalMetric:r,sharingSettingsId:C,companyId:u,clientId:A,rlsSettings:I2,tenancyLevel:r2,isLoading:i,errorMsg:f,adminTheme:l,workspaceId:D2,clientColumnType:d,isEnableMetricSummary:g,isAllClient:p,isShowUnderlyingData:b,appFilters:w,mergedMetricsId:T,datasourceId:H,mergedMetricLayout:S,mergedDashboardFilters:N,dashboardAppFilterValues:X,filterLayout:W,nestedMetric:f2,token:Q2}},Q70=Hu2({active:null,over:null,DragPreviewCreateRoot:null,draggables:[],droppables:[]}),Su2=()=>{const[t,n]=H_(Q70);return{dndState:t,setActive:r=>{n(C=>({...C,active:r}))},setOver:r=>{n(C=>({...C,over:r}))},setDraggables:r=>{n(C=>{var u;const l=(u=C.draggables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,draggables:[...C.draggables,r]};const e=[...C.draggables];return e[l]=r,{...C,draggables:e}})},setDropables:r=>{n(C=>{var u;const l=(u=C.droppables)==null?void 0:u.findIndex(A=>(A==null?void 0:A.identifier.id)===(r==null?void 0:r.identifier.id));if(l===-1)return{...C,droppables:[...C.droppables,r]};const e=[...C.droppables];return e[l]=r,{...C,droppables:e}})},setDndState:n}},M70=({identifier:t,data:n,modifiers:i,events:o,CustomDragPreview:a,disabled:s=!1,dropText:r})=>{const{dndState:C,setActive:l,setDndState:e,setDraggables:u}=Su2(),[A,f]=F0.useState(!1),[d,g]=F0.useState(!0),[p,b]=F0.useState(null),w=F0.useRef(null),T=F0.useRef(null),H={"data-type":t.type||t.id,id:`draggable-${t.id}`,role:"button",tabindex:"0",draggable:d?"true":"false","aria-grabbed":"false"},S=X=>{Object.entries(H).forEach(([W,f2])=>{X.setAttribute(W,f2)})},N=()=>{var X;T.current&&((X=C.DragPreviewCreateRoot)==null||X.render(a))};return F0.useEffect(()=>{if(a&&(T.current=document.getElementById("CustomDragPreviewContainer"),T.current===null)){T.current=document.createElement("div"),T.current.setAttribute("id","CustomDragPreviewContainer"),document.body.appendChild(T.current);const X=tI2.createRoot(T.current);e(W=>({...W,DragPreviewCreateRoot:X}))}},[]),F0.useEffect(()=>{if(w.current){const X=w.current.getBoundingClientRect();b(X),u({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:p,events:o,isDragging:A,isEnableDrag:d})}},[w.current,JSON.stringify(t),JSON.stringify(n),JSON.stringify(i),JSON.stringify(o),JSON.stringify(A)]),F0.useEffect(()=>{const X=w.current;if(!X)return;S(X);const W=Q2=>{var I2,r2,D2,M2;if(f(!0),l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:p,events:o,isDragging:A,isEnableDrag:d}),X.setAttribute("aria-grabbed","true"),r?(I2=Q2.dataTransfer)==null||I2.setData("text/plain",r):(r2=Q2.dataTransfer)==null||r2.setData("text/plain",JSON.stringify({data:n})),(D2=o==null?void 0:o.onDragStart)==null||D2.call(o,Q2,C),T.current){const m2=T.current.getBoundingClientRect();(M2=Q2.dataTransfer)==null||M2.setDragImage(T.current,m2.width/2,m2.height/2)}},f2=Q2=>{var I2;X.setAttribute("aria-grabbed","false"),f(!1),l(null),(I2=o==null?void 0:o.onDragEnd)==null||I2.call(o,Q2,C)};return X.addEventListener("mousedown",()=>{a&&N()}),X.addEventListener("dragstart",W),X.addEventListener("dragend",f2),()=>{X.removeEventListener("dragstart",W),X.removeEventListener("dragend",f2)}},[w.current,JSON.stringify(t),JSON.stringify(n),C.DragPreviewCreateRoot]),F0.useEffect(()=>{const X=w.current;X&&X.setAttribute("draggable",d?"true":"false")},[d]),F0.useEffect(()=>{var W,f2,Q2,I2;let X=[];return A&&(l({identifier:t,data:n,modifiers:i,DragNodeRef:w,rect:p,events:o,isDragging:A,isEnableDrag:d}),(W=i==null?void 0:i.highlightDrop)!=null&&W.onDrag&&(X=((Q2=(f2=C.droppables)==null?void 0:f2.filter(r2=>((r2==null?void 0:r2.identifier.accepts)??[]).includes(t.type??"")&&(r2==null?void 0:r2.isEnableDrop)))==null?void 0:Q2.map(r2=>r2==null?void 0:r2.setDropNodeRef.current))??[],(I2=i==null?void 0:i.highlightDrop)!=null&&I2.onDrag&&X.forEach(r2=>{var D2;r2==null||r2.classList.add(((D2=i==null?void 0:i.highlightDrop)==null?void 0:D2.highlightClass)||"dnd-droppable-highlight")}))),()=>{X.forEach(r2=>{var D2;r2==null||r2.classList.remove(((D2=i==null?void 0:i.highlightDrop)==null?void 0:D2.highlightClass)||"dnd-droppable-highlight")})}},[A]),F0.useEffect(()=>{g(!s)},[s]),{isDragging:A,isEnableDrag:d,setIsEnableDrag:g,DragNodeRef:w}},Vu2=({identifier:t,events:n,modifiers:i})=>{var S;const{dndState:o,setOver:a,setDropables:s}=Su2(),[r,C]=F0.useState(null),[l,e]=F0.useState({isDragOver:!1,isDrop:!1}),[u,A]=F0.useState({before:-1,after:-1}),[f,d]=F0.useState(!0),g=F0.useRef(null),p={"data-type":((S=t.accepts)==null?void 0:S.join("-"))??"",id:`droppable-${t.id}`,droppable:f?"true":"false"},b=N=>{Object.entries(p).forEach(([X,W])=>{N.setAttribute(X,W)})},w=(N,X,W)=>{const f2=[...W];N=N===-1?f2.length-1:N;const[Q2]=f2.splice(N,1);return X===-1?f2.push(Q2):f2.splice(X,0,Q2),f2},T=(N,X,W)=>[...N.querySelectorAll('[draggable="true"]:not([aria-grabbed="true"])')].reduce((I2,r2,D2)=>{const M2=r2.getBoundingClientRect(),m2=X-M2[W==="horizontal"?"left":"top"]-M2[W==="horizontal"?"width":"height"]/2;return m2<0&&m2>I2.offset?{offset:m2,element:r2,index:D2}:I2},{offset:Number.NEGATIVE_INFINITY,element:null,index:-1}),H=(N,X,W)=>{const f2=[...N.querySelectorAll('[draggable="true"]')],Q2=N.querySelector('[aria-grabbed="true"]'),{width:I2,height:r2}=W,D2=(m2,k2,W2)=>{const c0=m2.x-k2/2,p0=m2.y-W2/2;return[{x:c0,y:p0},{x:c0+k2,y:p0},{x:c0,y:p0+W2},{x:c0+k2,y:p0+W2}]};return f2.reduce((m2,k2,W2)=>{const c0=k2.getBoundingClientRect(),p0=[{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}],L0=D2(X,I2,r2);let b0=Number.POSITIVE_INFINITY,j2=W2,t1=Number.POSITIVE_INFINITY,h0=Number.POSITIVE_INFINITY;return p0.forEach((O0,U0)=>{L0.forEach(X2=>{let Q3=Number.POSITIVE_INFINITY;t1=Math.sqrt((O0.x-X2.x)**2+(O0.y-X2.y)**2),h0=Math.sqrt((O0.x-X.x)**2+(O0.y-X.y)**2),Q3=Math.min(t1,h0),Q3<b0&&(b0=Q3,U0===1||U0===3?Q2!==k2&&(j2=W2+1):j2=W2)})}),b0<m2.minDistance?{minDistance:b0,element:k2,index:j2,closestBasedOnCorner:t1,closestBasedonCursor:h0}:m2},{minDistance:Number.POSITIVE_INFINITY,element:null,index:-1,closestBasedOnCorner:0,closestBasedonCursor:0})};return F0.useEffect(()=>{const N=g.current;if(!N)return;const X=N.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)]),F0.useEffect(()=>{var r2,D2;const N=g.current;if(b(N),!N||!f||(r2=t.accepts)!=null&&r2.length&&!t.accepts.includes(((D2=o.active)==null?void 0:D2.identifier.type)??""))return;const{sorting:X}=i||{},W=M2=>{var m2;M2.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,M2,o)},f2=M2=>{var m2,k2,W2,c0,p0,L0,b0,j2,t1,h0,O0,U0;if(M2.preventDefault(),(W2=(k2=(m2=o.active)==null?void 0:m2.modifiers)==null?void 0:k2.highlightDrop)!=null&&W2.onDragOver&&g.current.classList.add(((L0=(p0=(c0=o.active)==null?void 0:c0.modifiers)==null?void 0:p0.highlightDrop)==null?void 0:L0.highlightClass)||"dnd-droppable-highlight"),l.isDragOver||e(X2=>({...X2,isDragOver:!0})),o.over===null&&a({identifier:t,setDropNodeRef:g,events:n,modifiers:i,rect:r,isEnableDrop:f,dragStatus:l}),X!=null&&X.isEnabled&&((b0=X.list)!=null&&b0.length)){const X2=(h0=(t1=(j2=o.active)==null?void 0:j2.DragNodeRef)==null?void 0:t1.current)==null?void 0:h0.getAttribute("data-dbn-sorting-index");let Q3=null;if((X.sortingType==="vertical"||X.sortingType==="horizontal")&&(Q3=T(N,(X==null?void 0:X.sortingType)==="horizontal"?M2.clientX:M2.clientY,X==null?void 0:X.sortingType)),X.sortingType==="both-axis"){const v3=(O0=document.getElementById("CustomDragPreviewContainer"))==null?void 0:O0.getBoundingClientRect();Q3=H(N,{x:M2.clientX,y:M2.clientY},{width:(v3==null?void 0:v3.width)??0,height:(v3==null?void 0:v3.height)??0})}const x1={before:parseInt(X2??-1,10),after:Q3==null?void 0:Q3.index};(x1.before!==u.before||x1.after!==u.after)&&A(x1)}(U0=n==null?void 0:n.onDragOver)==null||U0.call(n,M2,o)},Q2=M2=>{var m2,k2,W2,c0,p0,L0,b0;M2.preventDefault(),(W2=(k2=(m2=o.active)==null?void 0:m2.modifiers)==null?void 0:k2.highlightDrop)!=null&&W2.onDragOver&&g.current.classList.remove(((L0=(p0=(c0=o.active)==null?void 0:c0.modifiers)==null?void 0:p0.highlightDrop)==null?void 0:L0.highlightClass)||"dnd-droppable-highlight"),e(j2=>({...j2,isDragOver:!1})),(b0=n==null?void 0:n.onDragLeave)==null||b0.call(n,M2,o),a(null)},I2=M2=>{var p0,L0,b0,j2,t1,h0,O0,U0,X2,Q3;M2.preventDefault();const m2=g.current.contains((L0=(p0=o.active)==null?void 0:p0.DragNodeRef)==null?void 0:L0.current);let k2={...o};(t1=(j2=(b0=o.active)==null?void 0:b0.modifiers)==null?void 0:j2.highlightDrop)!=null&&t1.onDragOver&&g.current.classList.remove(((U0=(O0=(h0=o.active)==null?void 0:h0.modifiers)==null?void 0:O0.highlightDrop)==null?void 0:U0.highlightClass)||"dnd-droppable-highlight");let{before:W2,after:c0}=u;if(X!=null&&X.isEnabled&&((X2=X.list)!=null&&X2.length)){let x1=[...X.list];m2?x1=w(W2,c0,x1):W2=-1,k2={...o,sorting:{sortedList:x1,isSelfDrop:m2,ArrayElementSwap:w,sortingIndexes:{before:W2,after:c0}}},X.isEnabledAutoSort&&m2&&X.setList(x1)}e(x1=>({...x1,isDrop:!0})),(Q3=n==null?void 0:n.onDrop)==null||Q3.call(n,M2,k2),a(null)};return N.addEventListener("dragenter",W),N.addEventListener("dragover",f2),N.addEventListener("dragleave",Q2),N.addEventListener("drop",I2),()=>{N.removeEventListener("dragenter",W),N.removeEventListener("dragover",f2),N.removeEventListener("dragleave",Q2),N.removeEventListener("drop",I2)}},[g.current,t,f,i,n,u]),F0.useEffect(()=>{const N=g.current;N&&N.setAttribute("droppable",f?"true":"false")},[f]),{dragStatus:l,isEnableDrop:f,setIsEnableDrop:d,setDropNodeRef:g}},T70=(t,n,i)=>({autoCompleteDropdownOptions:F0.useMemo(()=>{if(!n.length)return[];const a=[];return n.forEach(s=>{s.columnsWithDataType.forEach(r=>{var g;const C=tq2(((g=r==null?void 0:r.dataType)==null?void 0:g.toLowerCase())||""),l=rq2(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(([p,b])=>{e.add(p),b&&u.add(b)}),C){case"DATE":Mx.forEach(p=>p.synonyms.forEach(A.add,A));break;case"NUMBER":DE.forEach(p=>p.synonymns.forEach(A.add,A));break;case"STRING":vh.forEach(p=>p.synonyms.forEach(A.add,A)),Bb2.forEach(p=>p.synonyms.forEach(A.add,A));break}pL.forEach(p=>p.synonymns.forEach(A.add,A));const f=l.flatMap(p=>(ab==null?void 0:ab[p.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(p=>{a.push({alias:p,datatype:r.dataType,name:p,schemaName:s.schemaName||"",tableName:s.tableName,columnSynonyms:r.synonyms||[],distinctValueSynonyms:[...u],type:"VALUE"})})})}),a},[n,i,t])}),x70=(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)||fV}${Y10}`,{method:"POST",body:JSON.stringify({fileName:t,dashboardId:n}),headers:{"Content-Type":"application/json",...a?{}:{"X-Plugin-Token":o||""},...dV()||{},"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)}}}),R70=()=>{const[t,n]=F0.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,p;const f=((d=window==null?void 0:window.dbn)==null?void 0:d.isEnableProxyAuth)||!1;try{n({downloadProgress:!0,isLoading:!0});const b=await fetch(`${((g=window.dbn)==null?void 0:g.proxyAuthUrl)||((p=window.dbn)==null?void 0:p.baseUrl)||fV}${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||""},...dV()||{},"X-Plugin-Origin":window.location.host,...r?{"X-Dbn-Secret":C}:{},...r?{"X-Dbn-token":b_()||""}:{}}});if(!b.ok)throw new Error("Network response was not ok");const w=await b.blob(),T=URL.createObjectURL(w),H=document.createElement("a");H.href=T,H.download=`${o}.zip`,H.style.display="none",document.body.appendChild(H),n({downloadProgress:!1,isLoading:!1}),lP&&(document!=null&&document.createEvent)||H.click(),URL.revokeObjectURL(T),document.body.removeChild(H)}catch{n({downloadProgress:!1,isLoading:!1}),alert("Error downloading the file. Please try later.")}},downloadState:t}},H70=({dashboardId:t,fileName:n,token:i})=>{const[o,a]=F0.useState(""),[s,r]=F0.useState(!1),[C,l]=F0.useState({isGettingPdf:!1}),{toPDF:e}=x70(n,t);return{toPDF:async()=>{if(l({isGettingPdf:!0}),a(""),r(!1),!i){a(ku),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1});return}try{await e(i),r(!0),setTimeout(()=>{r(!1)},2e3),l({isGettingPdf:!1})}catch{a(ku),r(!1),setTimeout(()=>{a("")},2e3),l({isGettingPdf:!1})}},isGettingPdf:C==null?void 0:C.isGettingPdf,error:o,isPdfExported:s}},IV={downloadCsv:"_downloadCsv_z5r12_1",downloadCsvWrapper:"_downloadCsvWrapper_z5r12_9",downloadCsvNote:"_downloadCsvNote_z5r12_45",downloadCsvNoteText:"_downloadCsvNoteText_z5r12_59"},VA={label:"_label_lpfkf_1","inputField-container":"_inputField-container_lpfkf_25",upperContainer:"_upperContainer_lpfkf_31",input:"_input_lpfkf_25",supportText:"_supportText_lpfkf_49",error:"_error_lpfkf_55",inputVal:"_inputVal_lpfkf_61",inputContainer:"_inputContainer_lpfkf_67",floatingLabel:"_floatingLabel_lpfkf_81",suffixContainer:"_suffixContainer_lpfkf_89",prefixContainer:"_prefixContainer_lpfkf_95",inlineLabelContainer:"_inlineLabelContainer_lpfkf_101",important:"_important_lpfkf_109"},K9=({type:t="text",register:n,label:i,isDisabled:o,id:a,elementRef:s,error:r,supportingText:C,leftIcon:l,rightIcon:e,addSuffix:u,addPrefix:A,inlineLabel:f,labelVariant:d="static",value:g,isImportant:p,containerClassName:b="",containerStyle:w,customClassName:T="",isFilter:H,isApplyDashboardColor:S,...N})=>{var X,W,f2,Q2;return h.jsxs("div",{className:`${VA["inputField-container"]} ${T}`,children:[h.jsxs("div",{className:VA.upperContainer,id:`${(W=(X=i??a)==null?void 0:X.replaceAll(" ","-"))==null?void 0:W.toLowerCase()}-input`,"data-testid":`${(Q2=(f2=i??a)==null?void 0:f2.replaceAll(" ","-"))==null?void 0:Q2.toLowerCase()}-input`,children:[i?h.jsxs(h.Fragment,{children:[d==="floating"&&h.jsxs("label",{htmlFor:a,className:`${VA.floatingLabel} ${H?"dbn-selectBox-text":""} ${H&&S?"dbn-selectBox":""}`,children:[i,p?h.jsx("span",{className:VA.important,children:"*"}):null]}),d==="static"&&h.jsx("label",{htmlFor:a,className:`${VA.label} ${H?"dbn-selectBox-text":""} ${H&&S?"dbn-selectBox":""}`,children:h.jsxs(e6,{variant:"input-label",color:"primary",children:[i,p?h.jsx("span",{className:VA.important,children:"*"}):null]})})]}):null,h.jsxs("div",{className:`${VA.inputContainer} ${H&&S?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""} ${b} `,style:w,children:[f&&h.jsx("div",{className:VA.inlineLabelContainer,children:h.jsx(e6,{variant:"heading-6",children:f})}),A&&h.jsx("div",{className:`${VA.prefixContainer} ${VA.supportText}`,children:A}),l&&h.jsx("div",{className:"dbn-p-2",children:l}),h.jsx("input",{...N,value:g,ref:s,id:a,type:t,className:`${VA.input} ${N.className||""} ${r?VA.error:""} ${g?VA.inputVal:""} ${H&&S?"dbn-selectBox dbn-rounded-r-none dbn-outline-none dbn-border-none":""}`,...n,disabled:o}),e&&h.jsx("div",{className:"dbn-p-2",children:e}),u&&h.jsx("div",{className:`${VA.suffixContainer} ${VA.supportText}`,children:u})]})]}),C&&h.jsx("div",{className:VA.supportText,children:C}),r&&h.jsx(e6,{variant:"body-text-2",color:"alert",children:r})]})},Gd={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"},Gu=({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=F0.useRef(),[g,p]=F0.useState(!1),[b,w]=F0.useState(!1),[T,H]=F0.useState(!1),S=X=>{X.target.classList.contains(Gd.modal)?w(!0):w(!1)},N=X=>{X.target.classList.contains(Gd.modal)?H(!0):H(!1)};return F0.useEffect(()=>{T&&b&&(H(!1),w(!1))},[T,b]),h.jsx(mE,{children:n||f?h.jsx("div",{className:`${Gd.modal} ${A?"dbn-items-end dbn-py-0":""}`,onMouseDown:N,onMouseUp:S,ref:d,style:{...l?{zIndex:l}:{},...f?{display:n?void 0:"none"}:{}},children:h.jsxs("div",{className:`${Gd.popup} ${g?Gd.popupFullScreen:""} ${e?Gd[`popup-${e}`]:""} ${A?"dbn-my-0 dbn-rounded-b-none dbn-rounded-t-3xl":""}`,onClick:X=>{X.stopPropagation()},children:[u?null:h.jsx("section",{className:Gd.header,children:s||h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-items-start dbn-gap-1.5",children:[h.jsxs("div",{className:Gd.headerTitle,children:[C,h.jsx(e6,{variant:"heading-3",color:"primary",children:o})]}),a&&h.jsx("div",{className:Gd.subHeadingTitle,children:h.jsx(e6,{variant:"body-text-3",color:"sec-text",children:a})})]}),h.jsx(a8,{"data-testid":"close-modal",variant:"tertiary",type:"button",onClick:i,leftIcon:h.jsx(p8,{name:"cross",size:"small"}),style:{padding:"0",height:"20px"},className:"dbn-p-1.5"})]})}),h.jsx("section",{className:Gd.content,children:t})]})}):null})},rd=({children:t,className:n})=>h.jsx("section",{className:`${Gd.footer} ${n}`,children:t}),D70=t=>{if(!t.length)return!1;const n=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;return t.every(i=>n.test(i))},N_=({onCloseModal:t,sharingSettingsId:n,metricItem:i,workspaceId:o})=>{const{data:a}=B70(o),[s,r]=F0.useState(!1),[C,l]=F0.useState(""),{mutate:e}=_30(),{handleSubmit:u,register:A,setValue:f,control:d,formState:{errors:g}}=cb(),p=F0.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:T})=>{r(!0),l("");const H=p.expireTimeInMin||30,S=new Date(Date.now()+H*60*1e3),N=T,X=w.emails;if(!D70(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:S,expireUrlIn:H*60,externalMetricId:i==null?void 0:i.id,integrationId:i==null?void 0:i.companyIntegrationId,integrationName:i==null?void 0:i.integrationName,query:N,sharingSettingsId:n,subject:w.subject},{onSuccess(W){W?(r(!1),l(""),t==null||t(!1)):(r(!1),l(ku))},onError(){r(!1),l(ku)}})},isDisableDownloadSettings:!n||!p.isEnable,downloadCsvError:C,handleSubmit:u,isLoading:s,register:A,control:d,setValue:f,errors:g}},Cy={required:"Required"};({...Cy},{...Cy}),{...Cy};const mV={"tag-text":"_tag-text_677jk_7",inputFieldContainer:"_inputFieldContainer_677jk_21","tag-container":"_tag-container_677jk_29",important:"_important_677jk_45"},S_=({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:p,error:b})=>{const[w,T]=F0.useState(),[H,S]=F0.useState(""),N=I2=>{T(w==null?void 0:w.filter(r2=>r2!==I2)),s==null||s(w==null?void 0:w.filter(r2=>r2!==I2))},X=()=>{const I2=H.split(",").map(M2=>M2.trim()).filter(Boolean),r2=new Set;for(const M2 of I2){if(r2.has(M2)){g==null||g(`Duplicate ${(f==null?void 0:f.toLocaleLowerCase())||"value"} in input: "${M2}"`);return}if(w!=null&&w.includes(M2)){g==null||g(`"${M2}" already added`);return}if(A&&!A.test(M2)){g==null||g(`Invalid ${(f==null?void 0:f.toLocaleLowerCase())||"input"}: "${M2}"`);return}r2.add(M2)}const D2=[...w||[],...I2];T(D2),s==null||s(D2),S(""),g==null||g("")},W=I2=>{if(I2.key==="Enter"||I2.key==="Tab")I2.preventDefault(),X();else if(I2.key==="Backspace"&&(H==null?void 0:H.length)===0){T(D2=>(D2==null||D2.pop(),[...D2||[]])),w==null||w.pop();const r2=[...w||[]];s==null||s(r2)}},f2=()=>{X()};F0.useEffect(()=>{C&&Array.isArray(C)?T(C):T([])},[C]);const Q2=I2=>{const r2=I2.target.parentElement;r2.scrollLeft=r2.scrollWidth,S(I2.target.value),r==null||r(I2.target.value)};return F0.useEffect(()=>{g==null||g("")},[H]),h.jsx(NE,{name:o||"tags",control:n,defaultValue:"",render:({field:I2})=>{var M2,m2,k2,W2;const{ref:r2,...D2}=I2;return h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[a?h.jsxs(e6,{variant:"input-label",color:"primary",children:[a,l?h.jsx("span",{className:mV.important,children:"*"}):null]}):null,h.jsxs("div",{className:mV.inputFieldContainer,style:{width:u},id:`${(m2=(M2=a??t)==null?void 0:M2.replaceAll(" ","-"))==null?void 0:m2.toLowerCase()}-input`,"data-testid":`${(W2=(k2=a??t)==null?void 0:k2.replaceAll(" ","-"))==null?void 0:W2.toLowerCase()}-input`,children:[w!=null&&w.length?h.jsx("div",{className:mV["tag-container"],children:w==null?void 0:w.map(c0=>h.jsx(a8,{variant:"popover",type:"button",onClick:()=>N(c0),className:"dbn-flex dbn-font-semibold dbn-gap-2 dbn-px-2 dbn-py-1 dbn-bg-gray dbn-rounded",rightIcon:h.jsx(p8,{name:"cross",size:"xxs"}),children:h.jsx("span",{className:mV["tag-text"],children:c0})},c0))}):null,h.jsx("input",{...D2,type:"text",value:H,onChange:Q2,onKeyDown:W,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"} ${{...p}}`,onBlur:f2})]})]}),d&&h.jsx(bl,{text:d,variant:"error"}),!d&&b&&h.jsx(e6,{variant:"body-text-2",color:"alert",children:b})]})}})};w9.memo(S_);const ac={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:ku2,setPrototypeOf:Ou2,isFrozen:N70,getPrototypeOf:S70,getOwnPropertyDescriptor:V70}=Object;let{freeze:sc,seal:nd,create:Pu2}=Object,{apply:V_,construct:k_}=typeof Reflect<"u"&&Reflect;sc||(sc=function(n){return n}),nd||(nd=function(n){return n}),V_||(V_=function(n,i,o){return n.apply(i,o)}),k_||(k_=function(n,i){return new n(...i)});const bV=lc(Array.prototype.forEach),k70=lc(Array.prototype.lastIndexOf),Zu2=lc(Array.prototype.pop),mM=lc(Array.prototype.push),O70=lc(Array.prototype.splice),BV=lc(String.prototype.toLowerCase),O_=lc(String.prototype.toString),Fu2=lc(String.prototype.match),bM=lc(String.prototype.replace),P70=lc(String.prototype.indexOf),Z70=lc(String.prototype.trim),Yd=lc(Object.prototype.hasOwnProperty),Cc=lc(RegExp.prototype.test),BM=F70(TypeError);function lc(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 V_(t,n,o)}}function F70(t){return function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return k_(t,i)}}function nC(t,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:BV;Ou2&&Ou2(t,null);let o=n.length;for(;o--;){let a=n[o];if(typeof a=="string"){const s=i(a);s!==a&&(N70(n)||(n[o]=s),a=s)}t[a]=!0}return t}function U70(t){for(let n=0;n<t.length;n++)Yd(t,n)||(t[n]=null);return t}function hm(t){const n=Pu2(null);for(const[i,o]of ku2(t))Yd(t,i)&&(Array.isArray(o)?n[i]=U70(o):o&&typeof o=="object"&&o.constructor===Object?n[i]=hm(o):n[i]=o);return n}function yM(t,n){for(;t!==null;){const o=V70(t,n);if(o){if(o.get)return lc(o.get);if(typeof o.value=="function")return lc(o.value)}t=S70(t)}function i(){return null}return i}const Uu2=sc(["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"]),P_=sc(["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"]),Z_=sc(["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"]),j70=sc(["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"]),F_=sc(["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"]),z70=sc(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ju2=sc(["#text"]),zu2=sc(["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"]),U_=sc(["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"]),Gu2=sc(["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"]),yV=sc(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),G70=nd(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y70=nd(/<%[\w\W]*|[\w\W]*%>/gm),W70=nd(/\$\{[\w\W]*/gm),_70=nd(/^data-[\-\w.\u00B7-\uFFFF]+$/),X70=nd(/^aria-[\-\w]+$/),Yu2=nd(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),K70=nd(/^(?:\w+script|data):/i),J70=nd(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wu2=nd(/^html$/i),q70=nd(/^[a-z][.\w]*(-[.\w]+)+$/i);var _u2=Object.freeze({__proto__:null,ARIA_ATTR:X70,ATTR_WHITESPACE:J70,CUSTOM_ELEMENT:q70,DATA_ATTR:_70,DOCTYPE_NAME:Wu2,ERB_EXPR:Y70,IS_ALLOWED_URI:Yu2,IS_SCRIPT_OR_DATA:K70,MUSTACHE_EXPR:G70,TMPLIT_EXPR:W70});const LM={element:1,text:3,progressingInstruction:7,comment:8,document:9},$70=function(){return typeof window>"u"?null:window},e60=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}},Xu2=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ku2(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:$70();const n=G3=>Ku2(G3);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==LM.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,p=yM(g,"cloneNode"),b=yM(g,"remove"),w=yM(g,"nextSibling"),T=yM(g,"childNodes"),H=yM(g,"parentNode");if(typeof r=="function"){const G3=i.createElement("template");G3.content&&G3.content.ownerDocument&&(i=G3.content.ownerDocument)}let S,N="";const{implementation:X,createNodeIterator:W,createDocumentFragment:f2,getElementsByTagName:Q2}=i,{importNode:I2}=o;let r2=Xu2();n.isSupported=typeof ku2=="function"&&typeof H=="function"&&X&&X.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:D2,ERB_EXPR:M2,TMPLIT_EXPR:m2,DATA_ATTR:k2,ARIA_ATTR:W2,IS_SCRIPT_OR_DATA:c0,ATTR_WHITESPACE:p0,CUSTOM_ELEMENT:L0}=_u2;let{IS_ALLOWED_URI:b0}=_u2,j2=null;const t1=nC({},[...Uu2,...P_,...Z_,...F_,...ju2]);let h0=null;const O0=nC({},[...zu2,...U_,...Gu2,...yV]);let U0=Object.seal(Pu2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),X2=null,Q3=null,x1=!0,v3=!0,W3=!1,g7=!0,I3=!1,$3=!0,b7=!1,I7=!1,R6=!1,h6=!1,w3=!1,t0=!1,z3=!0,X7=!1;const Y7="user-content-";let l6=!0,c6=!1,H6={},I1=null;const l3=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 q3=null;const T7=nC({},["audio","video","img","source","image","track"]);let h7=null;const g3=nC({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),p7="http://www.w3.org/1998/Math/MathML",N7="http://www.w3.org/2000/svg",D7="http://www.w3.org/1999/xhtml";let j6=D7,q7=!1,M6=null;const C8=nC({},[p7,N7,D7],O_);let a9=nC({},["mi","mo","mn","ms","mtext"]),T8=nC({},["annotation-xml"]);const y9=nC({},["title","style","font","a","script"]);let O8=null;const O9=["application/xhtml+xml","text/html"],L8="text/html";let o5=null,W9=null;const p5=i.createElement("form"),v5=function(F3){return F3 instanceof RegExp||F3 instanceof Function},p4=function(){let F3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(W9&&W9===F3)){if((!F3||typeof F3!="object")&&(F3={}),F3=hm(F3),O8=O9.indexOf(F3.PARSER_MEDIA_TYPE)===-1?L8:F3.PARSER_MEDIA_TYPE,o5=O8==="application/xhtml+xml"?O_:BV,j2=Yd(F3,"ALLOWED_TAGS")?nC({},F3.ALLOWED_TAGS,o5):t1,h0=Yd(F3,"ALLOWED_ATTR")?nC({},F3.ALLOWED_ATTR,o5):O0,M6=Yd(F3,"ALLOWED_NAMESPACES")?nC({},F3.ALLOWED_NAMESPACES,O_):C8,h7=Yd(F3,"ADD_URI_SAFE_ATTR")?nC(hm(g3),F3.ADD_URI_SAFE_ATTR,o5):g3,q3=Yd(F3,"ADD_DATA_URI_TAGS")?nC(hm(T7),F3.ADD_DATA_URI_TAGS,o5):T7,I1=Yd(F3,"FORBID_CONTENTS")?nC({},F3.FORBID_CONTENTS,o5):l3,X2=Yd(F3,"FORBID_TAGS")?nC({},F3.FORBID_TAGS,o5):{},Q3=Yd(F3,"FORBID_ATTR")?nC({},F3.FORBID_ATTR,o5):{},H6=Yd(F3,"USE_PROFILES")?F3.USE_PROFILES:!1,x1=F3.ALLOW_ARIA_ATTR!==!1,v3=F3.ALLOW_DATA_ATTR!==!1,W3=F3.ALLOW_UNKNOWN_PROTOCOLS||!1,g7=F3.ALLOW_SELF_CLOSE_IN_ATTR!==!1,I3=F3.SAFE_FOR_TEMPLATES||!1,$3=F3.SAFE_FOR_XML!==!1,b7=F3.WHOLE_DOCUMENT||!1,h6=F3.RETURN_DOM||!1,w3=F3.RETURN_DOM_FRAGMENT||!1,t0=F3.RETURN_TRUSTED_TYPE||!1,R6=F3.FORCE_BODY||!1,z3=F3.SANITIZE_DOM!==!1,X7=F3.SANITIZE_NAMED_PROPS||!1,l6=F3.KEEP_CONTENT!==!1,c6=F3.IN_PLACE||!1,b0=F3.ALLOWED_URI_REGEXP||Yu2,j6=F3.NAMESPACE||D7,a9=F3.MATHML_TEXT_INTEGRATION_POINTS||a9,T8=F3.HTML_INTEGRATION_POINTS||T8,U0=F3.CUSTOM_ELEMENT_HANDLING||{},F3.CUSTOM_ELEMENT_HANDLING&&v5(F3.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U0.tagNameCheck=F3.CUSTOM_ELEMENT_HANDLING.tagNameCheck),F3.CUSTOM_ELEMENT_HANDLING&&v5(F3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U0.attributeNameCheck=F3.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),F3.CUSTOM_ELEMENT_HANDLING&&typeof F3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(U0.allowCustomizedBuiltInElements=F3.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),I3&&(v3=!1),w3&&(h6=!0),H6&&(j2=nC({},ju2),h0=[],H6.html===!0&&(nC(j2,Uu2),nC(h0,zu2)),H6.svg===!0&&(nC(j2,P_),nC(h0,U_),nC(h0,yV)),H6.svgFilters===!0&&(nC(j2,Z_),nC(h0,U_),nC(h0,yV)),H6.mathMl===!0&&(nC(j2,F_),nC(h0,Gu2),nC(h0,yV))),F3.ADD_TAGS&&(j2===t1&&(j2=hm(j2)),nC(j2,F3.ADD_TAGS,o5)),F3.ADD_ATTR&&(h0===O0&&(h0=hm(h0)),nC(h0,F3.ADD_ATTR,o5)),F3.ADD_URI_SAFE_ATTR&&nC(h7,F3.ADD_URI_SAFE_ATTR,o5),F3.FORBID_CONTENTS&&(I1===l3&&(I1=hm(I1)),nC(I1,F3.FORBID_CONTENTS,o5)),l6&&(j2["#text"]=!0),b7&&nC(j2,["html","head","body"]),j2.table&&(nC(j2,["tbody"]),delete X2.tbody),F3.TRUSTED_TYPES_POLICY){if(typeof F3.TRUSTED_TYPES_POLICY.createHTML!="function")throw BM('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F3.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw BM('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=F3.TRUSTED_TYPES_POLICY,N=S.createHTML("")}else S===void 0&&(S=e60(d,a)),S!==null&&typeof N=="string"&&(N=S.createHTML(""));sc&&sc(F3),W9=F3}},T1=nC({},[...P_,...Z_,...j70]),s9=nC({},[...F_,...z70]),S9=function(F3){let x7=H(F3);(!x7||!x7.tagName)&&(x7={namespaceURI:j6,tagName:"template"});const y7=BV(F3.tagName),Q6=BV(x7.tagName);return M6[F3.namespaceURI]?F3.namespaceURI===N7?x7.namespaceURI===D7?y7==="svg":x7.namespaceURI===p7?y7==="svg"&&(Q6==="annotation-xml"||a9[Q6]):!!T1[y7]:F3.namespaceURI===p7?x7.namespaceURI===D7?y7==="math":x7.namespaceURI===N7?y7==="math"&&T8[Q6]:!!s9[y7]:F3.namespaceURI===D7?x7.namespaceURI===N7&&!T8[Q6]||x7.namespaceURI===p7&&!a9[Q6]?!1:!s9[y7]&&(y9[y7]||!T1[y7]):!!(O8==="application/xhtml+xml"&&M6[F3.namespaceURI]):!1},g5=function(F3){mM(n.removed,{element:F3});try{H(F3).removeChild(F3)}catch{b(F3)}},n5=function(F3,x7){try{mM(n.removed,{attribute:x7.getAttributeNode(F3),from:x7})}catch{mM(n.removed,{attribute:null,from:x7})}if(x7.removeAttribute(F3),F3==="is")if(h6||w3)try{g5(x7)}catch{}else try{x7.setAttribute(F3,"")}catch{}},Y5=function(F3){let x7=null,y7=null;if(R6)F3="<remove></remove>"+F3;else{const N6=Fu2(F3,/^[\r\n\t ]+/);y7=N6&&N6[0]}O8==="application/xhtml+xml"&&j6===D7&&(F3='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F3+"</body></html>");const Q6=S?S.createHTML(F3):F3;if(j6===D7)try{x7=new f().parseFromString(Q6,O8)}catch{}if(!x7||!x7.documentElement){x7=X.createDocument(j6,"template",null);try{x7.documentElement.innerHTML=q7?N:Q6}catch{}}const T6=x7.body||x7.documentElement;return F3&&y7&&T6.insertBefore(i.createTextNode(y7),T6.childNodes[0]||null),j6===D7?Q2.call(x7,b7?"html":"body")[0]:b7?x7.documentElement:T6},r5=function(F3){return W.call(F3.ownerDocument||F3,F3,e.SHOW_ELEMENT|e.SHOW_COMMENT|e.SHOW_TEXT|e.SHOW_PROCESSING_INSTRUCTION|e.SHOW_CDATA_SECTION,null)},E3=function(F3){return F3 instanceof A&&(typeof F3.nodeName!="string"||typeof F3.textContent!="string"||typeof F3.removeChild!="function"||!(F3.attributes instanceof u)||typeof F3.removeAttribute!="function"||typeof F3.setAttribute!="function"||typeof F3.namespaceURI!="string"||typeof F3.insertBefore!="function"||typeof F3.hasChildNodes!="function")},D8=function(F3){return typeof C=="function"&&F3 instanceof C};function o7(G3,F3,x7){bV(G3,y7=>{y7.call(n,F3,x7,W9)})}const j7=function(F3){let x7=null;if(o7(r2.beforeSanitizeElements,F3,null),E3(F3))return g5(F3),!0;const y7=o5(F3.nodeName);if(o7(r2.uponSanitizeElement,F3,{tagName:y7,allowedTags:j2}),F3.hasChildNodes()&&!D8(F3.firstElementChild)&&Cc(/<[/\w]/g,F3.innerHTML)&&Cc(/<[/\w]/g,F3.textContent)||F3.nodeType===LM.progressingInstruction||$3&&F3.nodeType===LM.comment&&Cc(/<[/\w]/g,F3.data))return g5(F3),!0;if(!j2[y7]||X2[y7]){if(!X2[y7]&&s6(y7)&&(U0.tagNameCheck instanceof RegExp&&Cc(U0.tagNameCheck,y7)||U0.tagNameCheck instanceof Function&&U0.tagNameCheck(y7)))return!1;if(l6&&!I1[y7]){const Q6=H(F3)||F3.parentNode,T6=T(F3)||F3.childNodes;if(T6&&Q6){const N6=T6.length;for(let M3=N6-1;M3>=0;--M3){const D9=p(T6[M3],!0);D9.__removalCount=(F3.__removalCount||0)+1,Q6.insertBefore(D9,w(F3))}}}return g5(F3),!0}return F3 instanceof l&&!S9(F3)||(y7==="noscript"||y7==="noembed"||y7==="noframes")&&Cc(/<\/no(script|embed|frames)/i,F3.innerHTML)?(g5(F3),!0):(I3&&F3.nodeType===LM.text&&(x7=F3.textContent,bV([D2,M2,m2],Q6=>{x7=bM(x7,Q6," ")}),F3.textContent!==x7&&(mM(n.removed,{element:F3.cloneNode()}),F3.textContent=x7)),o7(r2.afterSanitizeElements,F3,null),!1)},p6=function(F3,x7,y7){if(z3&&(x7==="id"||x7==="name")&&(y7 in i||y7 in p5))return!1;if(!(v3&&!Q3[x7]&&Cc(k2,x7))){if(!(x1&&Cc(W2,x7))){if(!h0[x7]||Q3[x7]){if(!(s6(F3)&&(U0.tagNameCheck instanceof RegExp&&Cc(U0.tagNameCheck,F3)||U0.tagNameCheck instanceof Function&&U0.tagNameCheck(F3))&&(U0.attributeNameCheck instanceof RegExp&&Cc(U0.attributeNameCheck,x7)||U0.attributeNameCheck instanceof Function&&U0.attributeNameCheck(x7))||x7==="is"&&U0.allowCustomizedBuiltInElements&&(U0.tagNameCheck instanceof RegExp&&Cc(U0.tagNameCheck,y7)||U0.tagNameCheck instanceof Function&&U0.tagNameCheck(y7))))return!1}else if(!h7[x7]){if(!Cc(b0,bM(y7,p0,""))){if(!((x7==="src"||x7==="xlink:href"||x7==="href")&&F3!=="script"&&P70(y7,"data:")===0&&q3[F3])){if(!(W3&&!Cc(c0,bM(y7,p0,"")))){if(y7)return!1}}}}}}return!0},s6=function(F3){return F3!=="annotation-xml"&&Fu2(F3,L0)},u6=function(F3){o7(r2.beforeSanitizeAttributes,F3,null);const{attributes:x7}=F3;if(!x7||E3(F3))return;const y7={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:h0,forceKeepAttr:void 0};let Q6=x7.length;for(;Q6--;){const T6=x7[Q6],{name:N6,namespaceURI:M3,value:D9}=T6,h8=o5(N6);let t9=N6==="value"?D9:Z70(D9);if(y7.attrName=h8,y7.attrValue=t9,y7.keepAttr=!0,y7.forceKeepAttr=void 0,o7(r2.uponSanitizeAttribute,F3,y7),t9=y7.attrValue,X7&&(h8==="id"||h8==="name")&&(n5(N6,F3),t9=Y7+t9),$3&&Cc(/((--!?|])>)|<\/(style|title)/i,t9)){n5(N6,F3);continue}if(y7.forceKeepAttr||(n5(N6,F3),!y7.keepAttr))continue;if(!g7&&Cc(/\/>/i,t9)){n5(N6,F3);continue}I3&&bV([D2,M2,m2],r9=>{t9=bM(t9,r9," ")});const o8=o5(F3.nodeName);if(p6(o8,h8,t9)){if(S&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!M3)switch(d.getAttributeType(o8,h8)){case"TrustedHTML":{t9=S.createHTML(t9);break}case"TrustedScriptURL":{t9=S.createScriptURL(t9);break}}try{M3?F3.setAttributeNS(M3,N6,t9):F3.setAttribute(N6,t9),E3(F3)?g5(F3):Zu2(n.removed)}catch{}}}o7(r2.afterSanitizeAttributes,F3,null)},v7=function G3(F3){let x7=null;const y7=r5(F3);for(o7(r2.beforeSanitizeShadowDOM,F3,null);x7=y7.nextNode();)o7(r2.uponSanitizeShadowNode,x7,null),j7(x7),u6(x7),x7.content instanceof s&&G3(x7.content);o7(r2.afterSanitizeShadowDOM,F3,null)};return n.sanitize=function(G3){let F3=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x7=null,y7=null,Q6=null,T6=null;if(q7=!G3,q7&&(G3="<!-->"),typeof G3!="string"&&!D8(G3))if(typeof G3.toString=="function"){if(G3=G3.toString(),typeof G3!="string")throw BM("dirty is not a string, aborting")}else throw BM("toString is not a function");if(!n.isSupported)return G3;if(I7||p4(F3),n.removed=[],typeof G3=="string"&&(c6=!1),c6){if(G3.nodeName){const D9=o5(G3.nodeName);if(!j2[D9]||X2[D9])throw BM("root node is forbidden and cannot be sanitized in-place")}}else if(G3 instanceof C)x7=Y5("<!---->"),y7=x7.ownerDocument.importNode(G3,!0),y7.nodeType===LM.element&&y7.nodeName==="BODY"||y7.nodeName==="HTML"?x7=y7:x7.appendChild(y7);else{if(!h6&&!I3&&!b7&&G3.indexOf("<")===-1)return S&&t0?S.createHTML(G3):G3;if(x7=Y5(G3),!x7)return h6?null:t0?N:""}x7&&R6&&g5(x7.firstChild);const N6=r5(c6?G3:x7);for(;Q6=N6.nextNode();)j7(Q6),u6(Q6),Q6.content instanceof s&&v7(Q6.content);if(c6)return G3;if(h6){if(w3)for(T6=f2.call(x7.ownerDocument);x7.firstChild;)T6.appendChild(x7.firstChild);else T6=x7;return(h0.shadowroot||h0.shadowrootmode)&&(T6=I2.call(o,T6,!0)),T6}let M3=b7?x7.outerHTML:x7.innerHTML;return b7&&j2["!doctype"]&&x7.ownerDocument&&x7.ownerDocument.doctype&&x7.ownerDocument.doctype.name&&Cc(Wu2,x7.ownerDocument.doctype.name)&&(M3="<!DOCTYPE "+x7.ownerDocument.doctype.name+`>
|
|
598
598
|
`+M3),I3&&bV([D2,M2,m2],D9=>{M3=bM(M3,D9," ")}),S&&t0?S.createHTML(M3):M3},n.setConfig=function(){let G3=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};p4(G3),I7=!0},n.clearConfig=function(){W9=null,I7=!1},n.isValidAttribute=function(G3,F3,x7){W9||p4({});const y7=o5(G3),Q6=o5(F3);return p6(y7,Q6,x7)},n.addHook=function(G3,F3){typeof F3=="function"&&mM(r2[G3],F3)},n.removeHook=function(G3,F3){if(F3!==void 0){const x7=k70(r2[G3],F3);return x7===-1?void 0:O70(r2[G3],x7,1)[0]}return Zu2(r2[G3])},n.removeHooks=function(G3){r2[G3]=[]},n.removeAllHooks=function(){r2=Xu2()},n}var Ju2=Ku2();const LV=t=>Ju2.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}}),pa=({children:t,text:n,bulletText:i,className:o="",position:a="bottom",tooltipClass:s="",isSingleLineTxt:r=!0,showTooltip:C=!0,isAllowPosChange:l=!1})=>{const e=F0.useRef(null),[u,A]=F0.useState(a),f=312,d=40,g=F0.useCallback(()=>{if(!e.current||!l)return;const b=e.current.getBoundingClientRect(),w=window.innerWidth,T=window.innerHeight,H=f/2;let S=b.right+f>w,N=b.left-f<0;(a.startsWith("top")||a.startsWith("bottom"))&&(S=b.left+H>w,N=b.right-H<0);const X=b.top-d<0,W=b.bottom+d>T,Q2={top:X?"bottom":S?"top-right":N?"top-left":"top",bottom:W?"top":S?"bottom-right":N?"bottom-left":"bottom",left:N?"right":"left",right:S?"left":"right","top-left":X&&N?"bottom-right":X?"bottom-left":N?"top-right":"top-left","top-right":X&&S?"bottom-left":X?"bottom-right":S?"top-left":"top-right","bottom-left":W&&N?"top-right":W?"top-left":N?"bottom-right":"bottom-left","bottom-right":W&&S?"top-left":W?"top-right":S?"bottom-left":"bottom-right","left-top-end":N&&X?"right-bottom-end":N?"right-top-end":X?"left-bottom-end":"left-top-end","left-bottom-end":N&&W?"right-top-end":N?"right-bottom-end":W?"left-top-end":"left-bottom-end","right-top-end":S&&X?"left-bottom-end":S?"left-top-end":X?"right-bottom-end":"right-top-end","right-bottom-end":S&&W?"left-top-end":S?"left-bottom-end":W?"right-top-end":"right-bottom-end"}[a]||a;Q2!==u&&A(Q2)},[a,u,l]);F0.useEffect(()=>{if(!C||!l)return;g(),window.addEventListener("resize",g),window.addEventListener("scroll",g);const b=e.current;return b&&b.addEventListener("mouseenter",g),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g),b&&b.removeEventListener("mouseenter",g)}},[C,l,g]);const p=(n||i)&&C;return h.jsxs("div",{ref:e,className:`${ac.container} ${o}`,children:[t,p&&h.jsxs("span",{className:`${ac.tooltip} ${s} ${ac[u]} ${r?"dbn-p-3":"dbn-p-4"} dbn-w-max`,style:{maxWidth:`${f}px`},children:[n&&h.jsx(e6,{variant:"body-text-2",color:"white",children:n}),i&&h.jsx("ul",{className:"dbn-w-full",children:i.map((b,w)=>h.jsxs("li",{className:"dbn-flex dbn-gap-2",children:[h.jsx(e6,{variant:"body-text-2",color:"white",children:"•"}),h.jsx(e6,{variant:"body-text-2",color:"white",children:b})]},w))})]})]})},qu2=({children:t,text:n,subText:i,className:o,position:a="bottom",tooltipClass:s="",headingIcon:r})=>h.jsx(h.Fragment,{children:h.jsxs("div",{className:`${ac.container} ${o}`,children:[t,!n&&!i?null:h.jsx("span",{className:`${ac.subTooltip} ${s} ${ac[a]} ${i?ac.subPadding:ac.textPadding}`,style:{maxWidth:"246px"},children:h.jsxs("span",{className:"dbn-flex dbn-flex-col dbn-gap-2 ",children:[n?h.jsxs("span",{className:ac.heading,children:[r?h.jsx(p8,{name:r,color:"white"}):null," ",h.jsx(e6,{variant:"sec-heading-4",color:"white",children:n})]},n):null,i?h.jsx("span",{className:ac.subText,children:i},i):null]})})]})}),Af=({children:t,className:n,iconConfig:i,position:o,tooltipClass:a,text:s,isSingleLineTxt:r})=>h.jsx(pa,{className:n,position:o,tooltipClass:`${a} dbn-w-max`,text:s,isSingleLineTxt:r,children:h.jsx(p8,{name:"info",size:i==null?void 0:i.size,color:i==null?void 0:i.color})}),$u2=({title:t,html:n,className:i,position:o="right-top",setHoverLongDesc:a})=>{const[s,r]=F0.useState(!1),C=F0.useRef(null);return F0.useEffect(()=>{const l=e=>{C.current&&!C.current.contains(e.target)&&(r(!1),a==null||a(!1))};return s&&document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[s,a]),h.jsxs("div",{ref:C,"data-testid":`longDesc-${t==null?void 0:t.toLowerCase().replaceAll(" ","-")}`,className:`${ac.container} ${s?ac.active:""}`,onMouseOver:()=>!s&&(a==null?void 0:a(!0)),onMouseOut:()=>!s&&(a==null?void 0:a(!1)),onClick:l=>{l.stopPropagation(),r(!0),a==null||a(!0)},children:[h.jsx(p8,{name:"info",size:"xs"}),h.jsx("div",{className:`${ac.tooltipMetric} ${ac[o]} ${i} dbn-longDesc`,children:h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-2",children:[h.jsx("div",{className:"dbn-mx-1 dbn-text-sm dbn-text-left",children:h.jsx(e6,{variant:"sec-heading-4",color:"white",children:t})}),h.jsx("div",{className:`${ac.addedLink} dbn-p-1`,dangerouslySetInnerHTML:{__html:LV(n||"")}})]})})]})},wV=({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}=N_({onCloseModal:t,metricItem:i,sharingSettingsId:a,workspaceId:s}),p=()=>{var b;return h.jsx(h.Fragment,{children:h.jsxs("form",{onSubmit:C(w=>e({values:w,query:o})),children:[h.jsxs("div",{className:IV.downloadCsvWrapper,children:[h.jsx(K9,{type:"subject",label:"Subject",placeholder:"enter a subject",register:u("subject",Cy),defaultValue:i==null?void 0:i.name,error:(b=g.subject)==null?void 0:b.message,isImportant:!0}),h.jsxs("div",{className:"dbn-w-full dbn-flex dbn-gap-1 dbn-flex-col",children:[h.jsxs("div",{className:"dbn-w-full dbn-flex dbn-gap-2",children:[h.jsxs(e6,{variant:"input-label",children:["Send to ",h.jsx("span",{className:"dbn-text-alert",children:"*"})]}),h.jsx(Af,{text:"Enter multiple email addresses separated by enter",iconConfig:{size:"xs",color:"primary-dark"},isSingleLineTxt:!1})]}),h.jsx(S_,{control:A,type:"text",label:"",placeholder:"Enter email addresses",onChangeTags:w=>f("emails",w),width:"100%",onChange:w=>f("emails",[w.trim()])})]}),r&&h.jsx(Hx,{message:r}),h.jsx("div",{className:IV.downloadCsvNote,children:h.jsx("div",{className:IV.downloadCsvNoteText,children:h.jsxs(e6,{variant:"body-text-2",children:[h.jsx("b",{children:"Note:"})," You will shortly receive a mail with CSV download URL to the above email id(s), once you click on Submit"]})})})]}),h.jsxs(rd,{children:[h.jsx(a8,{variant:"tab",type:"button",onClick:()=>t(!1),isDisabled:l,children:"Cancel"}),h.jsx(a8,{variant:"primary",type:"submit",isDisabled:l||d,children:"Submit"})]})]})})};return h.jsx(Gu,{isOpen:n,onClose:()=>t(!1),headerTitle:"Download Raw CSV",zIndex:99999999999,children:h.jsx("div",{className:IV.downloadCsv,children:h.jsx(p,{})})})},t60=w9.memo(wV),r60=({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:p,metricFilterOptions:b,enableDownloadCsv:w,enableMultiMetricFilters:T,metricFilterPosition:H,enableEmailCsv:S,isDisableCardTitle:N,disableDownloadPng:X,onMinimize:W,isHideChartSettings:f2,isHideTablePreview:Q2,dataMartRelationships:I2,isEnableCumulative:r2,isEnableDynamic:D2,isEnableStack:M2,metricCardColor:m2,language:k2,translationDictionary:W2,globalFilters:c0,calendarType:p0,isDisableClick:L0,disableDownloadDataNoFilters:b0=!1,disableDownloadUnderlyingDataNoFilters:j2=!1})=>{var z3;const[t1,h0]=F0.useState([]),[O0,U0]=F0.useState({isShow:!1}),[X2,Q3]=F0.useState({show:!1,filterValues:void 0}),{externalMetric:x1,rlsSettings:v3,sharingSettingsId:W3,companyId:g7,clientId:I3,tenancyLevel:$3,workspaceId:b7,clientColumnType:I7,isEnableMetricSummary:R6,isAllClient:h6,appFilters:w3,datasourceId:t0}=Nu2({token:t,metricId:n});return h.jsxs(h.Fragment,{children:[h.jsx(Ok,{disableDownloadDataNoFilters:b0,disableDownloadUnderlyingDataNoFilters:j2,calendarType:p0,disableFullscreen:!!g,language:k2,translationDictionary:W2,datasourceId:t0,isAllClient:h6,disableBorder:i,noDataImg:o,isShadowDisableOnHover:a||!1,isAllowedToSeeUnderlyingData:s,clientColumnType:I7,isEnableCumulative:r2,isDisableClick:L0,isEnableDynamic:D2,isEnableStack:M2,chartAppearance:r,hideDatePickerOptions:C,metricCardColor:m2,workspaceId:b7,guestToken:t,isFrontendApp:!1,downloadMetrics:t1,appearanceOptions:l,onDownload:(X7,Y7)=>{h0(Y7?l6=>[...l6,{id:X7,isInProgress:Y7}]:l6=>l6.filter(c6=>c6.id!==X7))},metricItem:x1,client:I3,dropdownTheme:e,underlyingTheme:u,colors:A||f,optionsIcon:d,onMaximize:g?void 0:({rlsFilters:X7,appliedMetricFilters:Y7})=>U0({isShow:!0,rlsFilters:X7,appliedMetricFilters:Y7}),companyTenancyType:$3,chartRendererType:p,param:v3,metricFilterOptions:b,enableDownloadCsv:w,enableMultiMetricFilters:T,metricFilterPosition:H,onDownloadRawCsv:S?X7=>Q3({show:!0,filterValues:X7}):void 0,isDisableCardTitle:N,appFilters:w3,isMergedMetric:!0,globalFilters:c0}),h.jsx(mE,{children:!g&&O0.isShow?h.jsx(Fk,{disableDownloadDataNoFilters:b0,disableDownloadUnderlyingDataNoFilters:j2,calendarType:p0,language:k2,translationDictionary:W2,appliedMetricFilters:(O0==null?void 0:O0.appliedMetricFilters)||[],datasourceId:t0,appFilters:w3,isAllClient:h6,isEnableMetricSummary:R6,hideDatePickerOptions:C,disableDownloadPng:X,chartAppearance:r,clientColumnType:I7,workspaceId:b7,guestToken:t,isFrontendApp:!1,downloadMetrics:t1,onDownload:(X7,Y7)=>{h0(Y7?l6=>[...l6,{id:X7,isInProgress:Y7}]:l6=>l6.filter(c6=>c6.id!==X7))},metric:x1,clientId:I3,colors:A||f,onMinimize:()=>{U0({isShow:!1}),W==null||W()},companyId:g7,tenancyLevel:$3,rlsFilters:O0.rlsFilters,sharingSettingsId:W3,externalDashboardId:"",userProvidedDashboardId:"",isShowChartConfigTab:!1,isHideChartSettings:f2,isHideTablePreview:Q2,metricFilterOptions:b,globalFilters:c0}):null}),S&&h.jsx(t60,{workspaceId:b7,metricItem:x1,isShowRawCsvModal:X2.show,onCloseModal:()=>Q3({show:!1,filterValues:void 0}),sharingSettingsId:W3,query:db({query:Fd((x1==null?void 0:x1.query)||"",g7||""),dbName:(x1==null?void 0:x1.integrationName)||"",rlsConditions:((z3=x1==null?void 0:x1.rlsConditions)==null?void 0:z3.filter(X7=>X7.isAddOnMetrics))||[],tenancyLevel:$3,clientId:I3,values:X2.filterValues,isAllClient:!1,clientColumnType:I7,dataMartRelationships:I2})})]})},QV="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"},j_=({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,W;const[A,f]=F0.useState(i||{min:null,max:null}),d=(i==null?void 0:i.min)===null||(i==null?void 0:i.max)===null,g=F0.useRef(null),[p,b]=F0.useState(""),[w,T]=F0.useState(""),H=()=>{var f2;f({min:null,max:null}),b(""),T(""),(f2=g.current)==null||f2.click(),n&&t?t(Q2=>Q2==null?void 0:Q2.filter(I2=>I2.label!==(n==null?void 0:n.label))):a&&(a==null||a(void 0))},S=()=>{var f2;if(A.min===null||A.max===null){T("Invalid value");return}n&&t?t(Q2=>{const I2={column:n.name,operator:nb,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||[]},r2=Q2.findIndex(M2=>M2.label===n.label);if(r2===-1)return[...Q2,I2];const D2=[...Q2];return D2[r2]=I2,D2}):a&&(a==null||a({min:A.min,max:A.max})),b(`Between ${A.min} to ${A.max}`),T(""),(f2=g.current)==null||f2.click()};F0.useEffect(()=>{f(i&&!d?i:{min:null,max:null}),b(i&&!d?`Between ${i.min} to ${i.max}`:"")},[i==null?void 0:i.max,i==null?void 0:i.min,d]);const N=window.CSS&&CSS.supports("width","clamp(1px, 1px, 1px)");return h.jsx(h.Fragment,{children:h.jsx(al,{position:"bottom-start",buttonWidth:N&&e?`clamp(100px, 13cqw, ${C})`:C,tabMenu:!0,menuWidth:"200px",isDisabled:u,buttonContent:h.jsxs(h.Fragment,{children:[r==="static"&&h.jsx("span",{className:`dbn-inline-block dbn-text-xs dbn-leading-6 dbn-font-medium dbn-font-sans ${e?"dbn-selectBox":""}`,children:s||(n==null?void 0:n.label)||(n==null?void 0:n.name)}),h.jsxs("div",{className: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:[h.jsxs("div",{className:hC.numberFieldLabelText,children:[r==="floating"&&h.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)}),h.jsx("span",{className:`${hC.rangeValue} ${e?"dbn-selectBox":""}`,style:N&&e?{fontSize:"clamp(8px, 9cqw, 14px)"}:{fontSize:"14px"},children:p||"Select a value"})]}),h.jsx("span",{className:"dbn-interactive-element",children:h.jsx(p8,{name:"chevron-down",color:"gray"})})]})]}),children:h.jsxs("div",{className:hC.numberFieldWrapper,"data-testid":(W=(n==null?void 0:n.label)||(n==null?void 0:n.name))==null?void 0:W.toLowerCase().replaceAll(" ","-").concat("-menu"),children:[h.jsx(K9,{label:"minimum",type:"number",defaultValue:A.min,onChange:({target:{value:f2}})=>{f(Q2=>({...Q2,min:f2===""?null:Number(f2)}))}}),h.jsx(K9,{label:"maximum",type:"number",defaultValue:A.max,onChange:({target:{value:f2}})=>{f(Q2=>({...Q2,max:f2===""?null:Number(f2)}))}}),h.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-gap-1",children:[w&&h.jsx(e6,{variant:"body-text-2",color:"alert",children:w}),h.jsxs("div",{className:hC.numberFieldFooter,children:[h.jsx(a8,{type:"button",variant:"tertiary",onClick:H,children:"Clear"}),h.jsx(a8,{variant:"primary",type:"button",onClick:S,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]=F0.useState(""),f=window.CSS&&CSS.supports("width","clamp(1px, 1px, 1px)");F0.useEffect(()=>{A((i==null?void 0:i.value)||"")},[i]);const d=F0.useMemo(()=>{if(a){if(a==="100%")return"100%";const p=`${parseInt(a,10)-44}px`;return f&&s?`clamp(100px, 13cqw, ${p})`:p}return"200px"},[a,s,f]);return h.jsxs("div",{className:a==="100%"?"dbn-w-full":"",children:[(t.label||t.name)&&C==="static"?h.jsx(h.Fragment,{children:s&&r?h.jsxs("span",{className:"dbn-text-xs dbn-leading-6 dbn-font-normal dbn-inline-block dbn-font-sans dbn-selectBox",children:[t.label||t.name,l?h.jsx("span",{className:hC.important,children:"*"}):null]}):h.jsxs(e6,{variant:"input-label",color:"primary-title",children:[t.label||t.name,l?h.jsx("span",{className:hC.important,children:"*"}):null]})}):null,h.jsxs("div",{className:hC.searchFilter,style:{borderRadius:e||"6px",opacity:o?.6:1,pointerEvents:o?"none":"auto"},children:[h.jsx(K9,{id:`${t.label||t.name}-search`,label:C==="static"?"":t.label||t.name,labelVariant:"floating",isFilter:s,isApplyDashboardColor:r,value:u,onChange:({target:{value:g}})=>A(g),style:{...d?{width:d}:{},borderTopLeftRadius:e||"6px",borderBottomLeftRadius:e||"6px"},className:"dbn-truncate",containerStyle:{borderTopLeftRadius:e||"6px",borderBottomLeftRadius:e||"6px"},isDisabled:o}),h.jsx(a8,{id:"search","data-testid":"search-btn",variant:"primary",className:"dbn-rounded-l-none",style:{borderRadius:e||"6px"},onClick:()=>{n(u!=null&&u.length?u:void 0)},isDisabled:o,children:h.jsx(p8,{name:"magnifying-glass",color:"white"})})]})]})},G_=({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:p,parentAppliedFilter:b,isDisableClick:w,isMobileView:T})=>{var I2;const H=F0.useMemo(()=>e==="MULTI_DATABASE"&&a||"",[e,a]),S=F0.useCallback((r2,D2)=>{var W2,c0;const M2=((W2=t.find(p0=>p0.label===r2))==null?void 0:W2.value)||"",m2=(c0=t.find(p0=>p0.label===r2))==null?void 0:c0.selectedDropdownValue;let k2="";return m2&&!Array.isArray(m2)&&(k2=m2.label||""),D2==="string"?Array.isArray(M2)&&(M2!=null&&M2.length)?M2==null?void 0:M2.map(p0=>typeof p0=="object"?p0:{value:p0,label:p0}):[]:D2==="string"?Array.isArray(m2)?m2:[]:{label:k2||M2,value:M2}},[t]),N=F0.useCallback(r2=>{var m2;const D2=((m2=r2.dependOn)==null?void 0:m2.map(k2=>{const W2=[...t||[],...b||[]].find(c0=>k2.label===c0.label||k2.value===c0.column);if(W2){const c0=MV({operator:W2.operator,value:W2.value});return{as:"string",columnName:k2.customColumnName||W2.column,value:fb(c0)}}return null}))||[],M2=D2==null?void 0:D2.filter(k2=>k2);return r2.clientColumn&&r2.isClientScoped&&r2.clientColumnType&&!s?[{columnName:r2.clientColumn,value:a,as:r2.clientColumnType},...M2]:M2},[t,a,s,b]),X=F0.useCallback(r2=>{var M2;const D2=(M2=A==null?void 0:A.clientLayout)!=null&&M2.length?A==null?void 0:A.clientLayout:A==null?void 0:A.adminLayout;return D2!=null&&D2.includes(r2.label)?D2==null?void 0:D2.indexOf(r2.label):D2!=null&&D2.includes(r2.name)?D2==null?void 0:D2.indexOf(r2.name):D2==null?void 0:D2.length},[A==null?void 0:A.adminLayout,A==null?void 0:A.clientLayout]),W=F0.useMemo(()=>{var r2,D2;return(D2=(r2=i==null?void 0:i[0])==null?void 0:r2.columns)==null?void 0:D2.filter(M2=>M2.isShowHorizontal).sort((M2,m2)=>X(M2)-X(m2))},[i,X]),f2=F0.useMemo(()=>{let r2=-2,D2=0;return(W==null?void 0:W.map(m2=>{let k2;return r2+2>=12?(r2=0,D2+=3,k2=0):(k2=r2+2,r2+=2),{i:m2.label||m2.name,w:2,h:3,x:k2,y:D2,minW:2,minH:1,maxH:3}}))||[]},[W,f]),Q2=F0.useCallback(r2=>{var M2,m2;return((m2=(M2=t.find(k2=>k2.label===r2))==null?void 0:M2.value)==null?void 0:m2.presetDateOption)||""},[t]);return h.jsx(h.Fragment,{children:f?h.jsx(Uk,{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:W==null?void 0:W.map(r2=>{var D2,M2,m2,k2,W2,c0,p0,L0,b0,j2,t1,h0,O0,U0,X2,Q3,x1,v3,W3,g7,I3,$3,b7,I7,R6,h6,w3,t0,z3,X7,Y7,l6,c6,H6,I1,l3,q3,T7,h7,g3;return h.jsxs("div",{className:hC.filterDropdown,style:{borderRadius:r.radius},id:r2.label||r2.name,tabIndex:0,role:"button",children:[!r2.isCustomFieldFilter&&(l==null?void 0:l(r2.label||r2.name||""))," ",r2.as==="date"&&h.jsx(h.Fragment,{children:h.jsx(sA,{datePickerFormat:r==null?void 0:r.datePickerFormat,label:r2.label||r2.name,hideDatePickerOptions:d,isFilter:!0,variant:r.variant==="static"?"static":"floatingLabel",buttonWidth:r.width,radius:r.radius,defaultValues:(D2=t.find(p7=>p7.label===r2.label))==null?void 0:D2.defaultValues,isDateReset:!t.filter(p7=>p7.as==="date").length,onChange:p7=>Us({column:r2,operator:nb,setAppliedFilters:n,type:gL,value:p7!=null&&p7.startDate&&(p7!=null&&p7.endDate)?p7:void 0}),isDisabled:f})}),r2.as==="number"&&h.jsx(j_,{variant:r.variant,isFilter:!0,buttonWidth:r.width,radius:r.radius,setAppliedFilters:n,column:r2,defaultValues:(M2=t.find(p7=>p7.label===r2.label))==null?void 0:M2.defaultValues,isDisabled:f}),r2.as==="string"&&!r2.isVariableFilter&&!((m2=r2.filterVariant)!=null&&m2.value)&&(o!=null&&o.isInternal&&!r2.isManualOptions?h.jsx(Gg,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((k2=r2.autoSelectType)==null?void 0:k2.value)==="last",autoSelectCount:["last","first"].includes(((W2=r2.autoSelectType)==null?void 0:W2.value)||"")?r2.autoSelectCount:1,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,filter:{columnName:r2.filterType===su&&((c0=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:c0.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((p0=i==null?void 0:i[0])==null?void 0:p0.tableName):(L0=i==null?void 0:i[0])==null?void 0:L0.tableName},isDisabled:f,customTable:r2.filterType===su&&((b0=r2==null?void 0:r2.selectedCustomColumn)!=null&&b0.columnName)&&((j2=r2==null?void 0:r2.selectedCustomColumn)!=null&&j2.query)?{alias:"custom_dbn_table",query:Lc({query:r2.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:S(r2.label||r2.name,"string")||[],autoSelected:!1,onChange:p7=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:p7!=null&&p7.length?p7:void 0})},isSearchEnabled:!0,label:r2.label||r2.name,filterClause:N(r2),isClearEnabled:r2.isEnableClearSelection}):h.jsx(rs,{isAutoSelectFromLast:((t1=r2.autoSelectType)==null?void 0:t1.value)==="last",autoSelectCount:["last","first"].includes(((h0=r2.autoSelectType)==null?void 0:h0.value)||"")?r2.autoSelectCount:1,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Kf(r2),labelVariant:r.variant,radius:r.radius,selectedOption:S(r2.label||r2.name,"string")||[],onChange:p7=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:p7!=null&&p7.length?p7:void 0})},isSearchEnabled:!0,label:r2.label||r2.name})),r2.as==="default"||r2.as==="boolean"||["default","boolean","string"].includes(r2.as||"")&&r2.isVariableFilter&&!((O0=r2.filterVariant)!=null&&O0.value)?o!=null&&o.isInternal&&!r2.isManualOptions?h.jsx(oE,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((U0=r2.autoSelectType)==null?void 0:U0.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:r2.filterType===su&&((X2=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:X2.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((Q3=i==null?void 0:i[0])==null?void 0:Q3.tableName):(x1=i==null?void 0:i[0])==null?void 0:x1.tableName},customTable:r2.filterType===su&&((v3=r2==null?void 0:r2.selectedCustomColumn)!=null&&v3.columnName)&&((W3=r2==null?void 0:r2.selectedCustomColumn)!=null&&W3.query)?{alias:"custom_dbn_table",query:Lc({query:r2.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:S(r2.label||r2.name,"boolean"),onChange:p7=>{Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:p7!=null&&p7.value?p7:void 0})},isSearchEnabled:!0,label:r2.label||r2.name,filterClause:N(r2),isClearEnabled:r2.isEnableClearSelection}):h.jsx(G4,{isAutoSelectFromLast:((g7=r2.autoSelectType)==null?void 0:g7.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Kf(r2),labelVariant:r.variant,radius:r.radius,selectedOption:S(r2.label||r2.name,"boolean"),onChange:p7=>{Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:p7!=null&&p7.value?p7:void 0})},isClearEnabled:r2.isEnableClearSelection,isSearchEnabled:!0,label:r2.label||r2.name}):null,!!(r2.as==="string"&&((I3=r2.filterVariant)!=null&&I3.value))&&h.jsxs(h.Fragment,{children:[(($3=r2.filterVariant)==null?void 0:$3.value)==="like"&&h.jsx(z_,{column:r2,isDisabled:f,buttonWidth:(r==null?void 0:r.width)||"200px",isFilter:!0,isApplyDashboardColor:!0,selectedValue:S(r2.label||r2.name,"boolean"),onClickSearch:p7=>Us({column:r2,operator:GA,setAppliedFilters:n,type:dL,value:p7}),labelVariant:(r==null?void 0:r.variant)||"floating",radius:r==null?void 0:r.radius}),((b7=r2.filterVariant)==null?void 0:b7.value)==="IN"&&(!r2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(Gg,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((I7=r2.autoSelectType)==null?void 0:I7.value)==="last",autoSelectCount:["last","first"].includes(((R6=r2.autoSelectType)==null?void 0:R6.value)||"")?r2.autoSelectCount:1,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,labelVariant:r.variant,radius:r.radius,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:r2.filterType===su&&((h6=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:h6.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((w3=i==null?void 0:i[0])==null?void 0:w3.tableName):(t0=i==null?void 0:i[0])==null?void 0:t0.tableName,labelColumnName:r2.filterType===su?r2.customLabelColumn||"":r2.labelColumnName||""},customTable:r2.filterType===su&&((z3=r2==null?void 0:r2.selectedCustomColumn)!=null&&z3.columnName)&&((X7=r2==null?void 0:r2.selectedCustomColumn)!=null&&X7.query)?{alias:"custom_dbn_table",query:Lc({query:r2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,selectedOption:S(r2.label||r2.name,"string")||[],onChange:p7=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:p7!=null&&p7.length?p7:void 0})},isSearchEnabled:!0,label:r2.label||r2.name,filterClause:N(r2),isClearEnabled:r2.isEnableClearSelection}):h.jsx(rs,{isAutoSelectFromLast:((Y7=r2.autoSelectType)==null?void 0:Y7.value)==="last",autoSelectCount:["last","first"].includes(((l6=r2.autoSelectType)==null?void 0:l6.value)||"")?r2.autoSelectCount:1,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,buttonWidth:r.width,menuWidth:r.width,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,radius:r.radius,options:Kf(r2),labelVariant:r.variant,selectedOption:S(r2.label||r2.name,"string")||[],onChange:p7=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:p7!=null&&p7.length?p7:void 0})},isSearchEnabled:!0,label:r2.label||r2.name})),((c6=r2.filterVariant)==null?void 0:c6.value)==="="&&(!r2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(oE,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((H6=r2.autoSelectType)==null?void 0:H6.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,radius:r.radius,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,filter:{columnName:r2.filterType===su&&((I1=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:I1.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((l3=i==null?void 0:i[0])==null?void 0:l3.tableName):(q3=i==null?void 0:i[0])==null?void 0:q3.tableName,labelColumnName:r2.filterType===su?r2.customLabelColumn||"":r2.labelColumnName||""},customTable:r2.filterType===su&&((T7=r2==null?void 0:r2.selectedCustomColumn)!=null&&T7.columnName)&&((h7=r2==null?void 0:r2.selectedCustomColumn)!=null&&h7.query)?{alias:"custom_dbn_table",query:Lc({query:r2.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:S(r2.label||r2.name,"boolean"),onChange:p7=>Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:p7!=null&&p7.value?p7:void 0}),isSearchEnabled:!0,isClearEnabled:r2.isEnableClearSelection,label:r2.label||r2.name,filterClause:N(r2)}):h.jsx(G4,{isAutoSelectFromLast:((g3=r2.autoSelectType)==null?void 0:g3.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:r.width,menuWidth:r.width,radius:r.radius,isDisabled:f,isFilter:!0,isApplyDashboardColor:!0,options:Kf(r2),labelVariant:r.variant,selectedOption:S(r2.label||r2.name,"boolean"),onChange:p7=>Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:p7!=null&&p7.value?p7:void 0}),isSearchEnabled:!0,isClearEnabled:r2.isEnableClearSelection,label:r2.label||r2.name}))]})]},r2.label||r2.name)})},f?"reset":"default"):h.jsxs(h.Fragment,{children:[(I2=W==null?void 0:W.filter(r2=>g?!r2.isAppFilter:!0))==null?void 0:I2.map(r2=>{var D2,M2,m2,k2,W2,c0,p0,L0,b0,j2,t1,h0,O0,U0,X2,Q3,x1,v3,W3,g7,I3,$3,b7,I7,R6,h6,w3,t0,z3,X7,Y7,l6,c6,H6,I1,l3,q3,T7,h7,g3,p7,N7,D7,j6,q7,M6,C8,a9,T8,y9,O8,O9,L8,o5,W9,p5,v5,p4,T1,s9,S9,g5,n5,Y5,r5,E3,D8,o7,j7,p6,s6,u6,v7,G3,F3,x7,y7,Q6;return h.jsxs("div",{className:T?"dbn-w-full":hC.filterDropdown,style:{borderRadius:r.radius,pointerEvents:w?"none":void 0},"data-testid":(D2=r2.label||r2.name)==null?void 0:D2.toLowerCase().replaceAll(" ","-").concat("-filter"),children:[!r2.isCustomFieldFilter&&(l==null?void 0:l(r2.label||r2.name||"")),r2.as==="date"&&h.jsx(h.Fragment,{children:((M2=r2.dateVariant)==null?void 0:M2.value)==="preset"?h.jsx(G4,{isAutoSelectFromLast:((m2=r2.autoSelectType)==null?void 0:m2.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,isFilter:!T,isApplyDashboardColor:!T,options:((k2=r2==null?void 0:r2.datePresetOptions)==null?void 0:k2.map(T6=>({value:T6.label,label:T6.label,presetDateOption:T6})))||[],labelVariant:r.variant,radius:r.radius,defaultOption:(W2=r2==null?void 0:r2.defaultValue)!=null&&W2.value?{value:(c0=r2==null?void 0:r2.defaultValue)==null?void 0:c0.value,label:(p0=r2==null?void 0:r2.defaultValue)==null?void 0:p0.label,presetDateOption:(L0=r2==null?void 0:r2.defaultValue)==null?void 0:L0.presetDateOption}:{value:"",label:""},selectedOption:(j2=(b0=t.find(T6=>T6.label===r2.label))==null?void 0:b0.value)!=null&&j2.value?(t1=t.find(T6=>T6.label===r2.label))==null?void 0:t1.value:{value:"",label:""},onChange:T6=>{Us({column:r2,operator:dl,setAppliedFilters:n,type:hL,value:T6!=null&&T6.value?T6:void 0})},isClearEnabled:r2.isEnableClearSelection,isSearchEnabled:!0,label:r2.label||r2.name,disableAutoClose:!0,children:((O0=(h0=Q2(r2.label))==null?void 0:h0.type)==null?void 0:O0.value)==="custom"?h.jsx("div",{className:"dbn-p-1",children:h.jsx(sA,{datePickerFormat:r==null?void 0:r.datePickerFormat,isEnableSingleDate:((X2=(U0=Q2(r2.label))==null?void 0:U0.customType)==null?void 0:X2.value)==="singleDate",label:((x1=(Q3=Q2(r2.label))==null?void 0:Q3.customType)==null?void 0:x1.value)==="singleDate"?Bx:yx,hideDatePickerOptions:d,onChange:T6=>{var N6;Us({column:r2,operator:dl,setAppliedFilters:n,type:hL,value:{...(N6=t.find(M3=>M3.label===r2.label))==null?void 0:N6.value,presetDateOption:{...Q2(r2.label),customDate:T6}}})},minDate:(v3=Q2(r2.label))!=null&&v3.isDateRestricted&&((W3=Q2(r2.label))!=null&&W3.restrictionDateFrom)?Pl((g7=Q2(r2.label))==null?void 0:g7.restrictionDateFrom,!0):void 0,maxDate:(I3=Q2(r2.label))!=null&&I3.isDateRestricted&&(($3=Q2(r2.label))!=null&&$3.restrictionDateTo)?Pl((b7=Q2(r2.label))==null?void 0:b7.restrictionDateTo):void 0,defaultValues:(R6=(I7=Q2(r2.label))==null?void 0:I7.customDate)!=null&&R6.startDate&&((w3=(h6=Q2(r2.label))==null?void 0:h6.customDate)!=null&&w3.endDate)?{startDate:new Date((z3=(t0=Q2(r2.label))==null?void 0:t0.customDate)==null?void 0:z3.startDate),endDate:new Date((Y7=(X7=Q2(r2.label))==null?void 0:X7.customDate)==null?void 0:Y7.endDate),timeGrainValue:((c6=(l6=Q2(r2.label))==null?void 0:l6.customDate)==null?void 0:c6.timeGrainValue)||""}:void 0})}):null}):h.jsx(sA,{datePickerFormat:r==null?void 0:r.datePickerFormat,minDate:r2.isEnableDateRestriction&&((H6=r2==null?void 0:r2.dateRestrictionRange)!=null&&H6.from)?Pl((I1=r2==null?void 0:r2.dateRestrictionRange)==null?void 0:I1.from,!0):void 0,maxDate:r2.isEnableDateRestriction&&((l3=r2==null?void 0:r2.dateRestrictionRange)!=null&&l3.to)?Pl((q3=r2==null?void 0:r2.dateRestrictionRange)==null?void 0:q3.to):void 0,label:r2.label||r2.name,hideDatePickerOptions:d,isEnableSingleDate:((T7=r2.dateSelectionType)==null?void 0:T7.value)==="singleDate",buttonWidth:T?"100%":r.width,isFilter:!T,variant:r.variant==="static"?"static":"floatingLabel",radius:r.radius,defaultValues:(h7=t.find(T6=>T6.label===r2.label))==null?void 0:h7.defaultValues,defaultOption:Pa2(r2),isDateReset:!t.filter(T6=>T6.as==="date").length,onChange:T6=>Us({column:r2,operator:nb,setAppliedFilters:n,type:gL,value:T6!=null&&T6.startDate&&(T6!=null&&T6.endDate)?T6:void 0})})}),r2.as==="number"&&h.jsx(j_,{variant:r.variant,buttonWidth:T?"100%":r.width,isFilter:!T,radius:r.radius,setAppliedFilters:n,column:r2,defaultValues:(g3=t.find(T6=>T6.label===r2.label))==null?void 0:g3.defaultValues}),r2.as==="string"&&!r2.isVariableFilter&&!((p7=r2.filterVariant)!=null&&p7.value)&&(o!=null&&o.isInternal&&!r2.isManualOptions?h.jsx(Gg,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((N7=r2.autoSelectType)==null?void 0:N7.value)==="last",autoSelectCount:["last","first"].includes(((D7=r2.autoSelectType)==null?void 0:D7.value)||"")?r2.autoSelectCount:1,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,filter:{columnName:r2.filterType===su&&((j6=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:j6.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((q7=i==null?void 0:i[0])==null?void 0:q7.tableName):(M6=i==null?void 0:i[0])==null?void 0:M6.tableName},customTable:r2.filterType===su&&((C8=r2==null?void 0:r2.selectedCustomColumn)!=null&&C8.columnName)&&((a9=r2==null?void 0:r2.selectedCustomColumn)!=null&&a9.query)?{alias:"custom_dbn_table",query:Lc({query:r2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,isFilter:!T,isApplyDashboardColor:!T,radius:r.radius,workspaceId:o==null?void 0:o.workspaceId,labelVariant:r.variant,selectedOption:S(r2.label||r2.name,"string")||[],autoSelected:!1,onChange:T6=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:T6!=null&&T6.length?T6:void 0})},isSearchEnabled:!0,label:r2.label||r2.name,filterClause:N(r2),isClearEnabled:r2.isEnableClearSelection}):h.jsx(rs,{isAutoSelectFromLast:((T8=r2.autoSelectType)==null?void 0:T8.value)==="last",isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,autoSelectCount:["last","first"].includes(((y9=r2.autoSelectType)==null?void 0:y9.value)||"")?r2.autoSelectCount:1,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,isFilter:!T,isApplyDashboardColor:!T,options:Kf(r2),labelVariant:r.variant,radius:r.radius,selectedOption:S(r2.label||r2.name,"string")||[],onChange:T6=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:T6!=null&&T6.length?T6:void 0})},isSearchEnabled:!0,label:r2.label||r2.name})),r2.as==="default"||r2.as==="boolean"||["default","boolean","string"].includes(r2.as||"")&&r2.isVariableFilter&&!((O8=r2.filterVariant)!=null&&O8.value)?o!=null&&o.isInternal&&!r2.isManualOptions?h.jsx(oE,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((O9=r2.autoSelectType)==null?void 0:O9.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,isFilter:!T,isApplyDashboardColor:!T,filter:{columnName:r2.filterType===su&&((L8=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:L8.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((o5=i==null?void 0:i[0])==null?void 0:o5.tableName):(W9=i==null?void 0:i[0])==null?void 0:W9.tableName},customTable:r2.filterType===su&&((p5=r2==null?void 0:r2.selectedCustomColumn)!=null&&p5.columnName)&&((v5=r2==null?void 0:r2.selectedCustomColumn)!=null&&v5.query)?{alias:"custom_dbn_table",query:Lc({query:r2.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:S(r2.label||r2.name,"boolean"),onChange:T6=>{Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:T6!=null&&T6.value?T6:void 0})},isSearchEnabled:!0,label:r2.label||r2.name,filterClause:N(r2),isClearEnabled:r2.isEnableClearSelection}):h.jsx(G4,{isAutoSelectFromLast:((p4=r2.autoSelectType)==null?void 0:p4.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,isFilter:!T,isApplyDashboardColor:!T,options:Kf(r2),labelVariant:r.variant,radius:r.radius,selectedOption:S(r2.label||r2.name,"boolean"),onChange:T6=>{Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:T6!=null&&T6.value?T6:void 0})},isClearEnabled:r2.isEnableClearSelection,isSearchEnabled:!0,label:r2.label||r2.name}):null,!!(r2.as==="string"&&((T1=r2.filterVariant)!=null&&T1.value))&&h.jsxs(h.Fragment,{children:[((s9=r2.filterVariant)==null?void 0:s9.value)==="like"&&h.jsx(z_,{column:r2,buttonWidth:T?"100%":r==null?void 0:r.width,isFilter:!T,isApplyDashboardColor:!T,selectedValue:S(r2.label||r2.name,"boolean"),onClickSearch:T6=>Us({column:r2,operator:GA,setAppliedFilters:n,type:dL,value:T6}),labelVariant:(r==null?void 0:r.variant)||"floating",radius:r==null?void 0:r.radius}),((S9=r2.filterVariant)==null?void 0:S9.value)==="IN"&&(!r2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(Gg,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((g5=r2.autoSelectType)==null?void 0:g5.value)==="last",autoSelectCount:["last","first"].includes(((n5=r2.autoSelectType)==null?void 0:n5.value)||"")?r2.autoSelectCount:1,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,labelVariant:r.variant,radius:r.radius,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,isFilter:!T,isApplyDashboardColor:!T,filter:{columnName:r2.filterType===su&&((Y5=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:Y5.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((r5=i==null?void 0:i[0])==null?void 0:r5.tableName):(E3=i==null?void 0:i[0])==null?void 0:E3.tableName,labelColumnName:r2.filterType===su?r2.customLabelColumn||"":r2.labelColumnName||""},customTable:r2.filterType===su&&((D8=r2==null?void 0:r2.selectedCustomColumn)!=null&&D8.columnName)&&((o7=r2==null?void 0:r2.selectedCustomColumn)!=null&&o7.query)?{alias:"custom_dbn_table",query:Lc({query:r2.selectedCustomColumn.query,tenancyLevel:e,clientId:a,isAllClient:s,clientColumnType:u})}:void 0,workspaceId:o==null?void 0:o.workspaceId,selectedOption:S(r2.label||r2.name,"string")||[],onChange:T6=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:T6!=null&&T6.length?T6:void 0})},isSearchEnabled:!0,label:r2.label||r2.name,filterClause:N(r2),isClearEnabled:r2.isEnableClearSelection}):h.jsx(rs,{isAutoSelectFromLast:((j7=r2.autoSelectType)==null?void 0:j7.value)==="last",autoSelectCount:["last","first"].includes(((p6=r2.autoSelectType)==null?void 0:p6.value)||"")?r2.autoSelectCount:1,isAutoSelectAll:r2==null?void 0:r2.isSelectAllMultiSelectOptions,isSelectAllEnabled:r2==null?void 0:r2.isSelectAllMultiSelect,isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,isFilter:!T,isApplyDashboardColor:!T,radius:r.radius,options:Kf(r2),labelVariant:r.variant,selectedOption:S(r2.label||r2.name,"string")||[],onChange:T6=>{Us({column:r2,operator:au,setAppliedFilters:n,type:YA,value:T6!=null&&T6.length?T6:void 0})},isSearchEnabled:!0,label:r2.label||r2.name,isClearEnabled:r2.isEnableClearSelection})),((s6=r2.filterVariant)==null?void 0:s6.value)==="="&&(!r2.isManualOptions&&(o!=null&&o.workspaceId)?h.jsx(oE,{databaseName:H,datasourceId:p,isAutoSelectFromLast:((u6=r2.autoSelectType)==null?void 0:u6.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,radius:r.radius,isFilter:!T,isApplyDashboardColor:!T,filter:{columnName:r2.filterType===su&&((v7=r2==null?void 0:r2.selectedCustomColumn)==null?void 0:v7.columnName)||r2.name,tableName:r2.filterType==="auto"?r2.selectedTable||((G3=i==null?void 0:i[0])==null?void 0:G3.tableName):(F3=i==null?void 0:i[0])==null?void 0:F3.tableName,labelColumnName:r2.filterType===su?r2.customLabelColumn||"":r2.labelColumnName||""},customTable:r2.filterType===su&&((x7=r2==null?void 0:r2.selectedCustomColumn)!=null&&x7.columnName)&&((y7=r2==null?void 0:r2.selectedCustomColumn)!=null&&y7.query)?{alias:"custom_dbn_table",query:Lc({query:r2.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:S(r2.label||r2.name,"boolean"),onChange:T6=>Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:T6!=null&&T6.value?T6:void 0}),isSearchEnabled:!0,isClearEnabled:r2.isEnableClearSelection,label:r2.label||r2.name,filterClause:N(r2)}):h.jsx(G4,{isAutoSelectFromLast:((Q6=r2.autoSelectType)==null?void 0:Q6.value)==="last",isAutoSelectOption:r2.isAutoSelectFilterValue,buttonWidth:T?"100%":r.width,menuWidth:T?"100%":r.width,radius:r.radius,isFilter:!T,isApplyDashboardColor:!T,options:Kf(r2),labelVariant:r.variant,selectedOption:S(r2.label||r2.name,"boolean"),onChange:T6=>Us({column:r2,operator:dl,setAppliedFilters:n,type:WA,value:T6!=null&&T6.value?T6:void 0}),isSearchEnabled:!0,isClearEnabled:r2.isEnableClearSelection,label:r2.label||r2.name}))]})]},r2.label||r2.name)}),C]})})},n60=w9.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:p,themeName:b,setAdminTheme:w,appearanceOptions:T,isDisableCardTitle:H,hideDatePickerOptions:S,chartAppearance:N,hideMetricCardShadow:X,disableUnderlyingData:W,noDataImg:f2,disableDownloadPng:Q2,disableMetricCardBorder:I2,isMergedCard:r2,chartColumns:D2,language:M2,translationDictionary:m2,globalFilterOptions:k2,calendarType:W2="default",disableDownloadDataNoFilters:c0=!1,disableDownloadUnderlyingDataNoFilters:p0=!1})=>{var s9,S9,g5,n5,Y5,r5,E3,D8,o7,j7,p6,s6,u6,v7,G3,F3,x7,y7,Q6,T6,N6,M3,D9,h8,t9,o8,r9,y8,k9,w5,o9,C4,P5,D5,X5,R4;const[L0,b0]=F0.useState([]),[j2,t1]=F0.useState({isShow:a==="fullscreen"}),[h0,O0]=F0.useState(!1),[U0,X2]=F0.useState(!1),[Q3,x1]=F0.useState(!1),[v3,W3]=F0.useState(!1),[g7,I3]=F0.useState({show:!1,filterValues:void 0}),[$3,b7]=F0.useState([]),[I7,R6]=F0.useState({width:"200px",variant:"floating",radius:"6px",datePickerFormat:""}),[h6,w3]=F0.useState({header:{fontColor:"",bgColor:"",fontWeight:""},content:{fontColor:"",lineGap:"",fontWeight:""}}),{externalMetric:t0,rlsSettings:z3,sharingSettingsId:X7,companyId:Y7,clientId:l6,tenancyLevel:c6,isLoading:H6,errorMsg:I1,adminTheme:l3,workspaceId:q3,clientColumnType:T7,isEnableMetricSummary:h7,isAllClient:g3,isShowUnderlyingData:p7,appFilters:N7,mergedMetricsId:D7,datasourceId:j6,mergedMetricLayout:q7,mergedDashboardFilters:M6,dashboardAppFilterValues:C8,nestedMetric:a9,token:T8}=Nu2({token:t,metricId:i}),y9=(s9=window==null?void 0:window.dbn)!=null&&s9.isEnableProxyAuth?T8:t,O8=F0.useMemo(()=>{var V5,u8,j8,A8,D6;return((D6=(A8=(j8=(u8=(V5=t0==null?void 0:t0.externalDashboardMetrics)==null?void 0:V5[0])==null?void 0:u8.externalDashboard)==null?void 0:j8.companyWorkspace)==null?void 0:A8.datamart)==null?void 0:D6.datamartRelationships)||[]},[t0]),{data:O9}=Du2({token:y9,name:b||"",companyId:Y7}),L8=F0.useMemo(()=>(O9==null?void 0:O9.theme)||l3,[l3,O9]),o5=F0.useMemo(()=>W!=null&&W.toString()?!W:p7,[W,p7]),W9=F0.useMemo(()=>q7==null?void 0:q7.map(u8=>{const j8=u8.i,A8=u8.layout;return{i:j8,w:(A8==null?void 0:A8.w)??u8.resizeAttributes.width??5,h:(A8==null?void 0:A8.h)??u8.resizeAttributes.height??10,x:(A8==null?void 0:A8.x)??u8.resizeAttributes.xAxis??0,y:(A8==null?void 0:A8.y)??u8.resizeAttributes.yAxis??0,minW:u8.isMetric?[m0.singleValue,m0.pivot,m0.pivotV2,m0.pivotV3,m0.progressBar,m0.linearGauge].includes(u8==null?void 0:u8.chartType)?2:3:1,minH:u8.isMetric?[m0.singleValue,m0.pivot,m0.pivotV2,m0.pivotV3].includes(u8==null?void 0:u8.chartType)?2:[m0.progressBar,m0.linearGauge].includes(u8==null?void 0:u8.chartType)?3:8:u8.description?2:1,maxH:(u8==null?void 0:u8.chartType)==="table"?1/0:15}}),[q7]),p5=F0.useMemo(()=>W9.sort((V5,u8)=>V5.y!==u8.y?V5.y-u8.y:V5.x-u8.x),[W9]),v5=F0.useMemo(()=>{var u8,j8,A8;return n??((A8=(j8=(u8=L8==null?void 0:L8.chart)==null?void 0:u8.palettes)==null?void 0:j8.find(D6=>{var G9,J8;return D6.name===((J8=(G9=(O9==null?void 0:O9.theme)||l3)==null?void 0:G9.chart)==null?void 0:J8.selected)}))==null?void 0:A8.colors)},[L8,n]);F0.useEffect(()=>{var V5,u8,j8,A8,D6,G9,J8,f9,Q9,r8,d9,C9,h9,V9,a5,P9,N4,e4,U9,E4,f4,y4,I4,ne,H4,X4;if(L8!=null&&L8.dashboard.selectBoxSize)switch(L8==null?void 0:L8.dashboard.selectBoxSize){case"small":R6(L4=>({...L4,width:"130px"}));break;case"medium":R6(L4=>({...L4,width:"180px"}));break;case"large":R6(L4=>({...L4,width:"250px"}));break;default:R6(L4=>({...L4,width:"200px"}))}L8!=null&&L8.dashboard.selectBoxVariant&&R6(L4=>({...L4,variant:L8.dashboard.selectBoxVariant})),L8!=null&&L8.dashboard.selectBoxBorderRadius&&R6(L4=>({...L4,radius:L8.dashboard.selectBoxBorderRadius})),(V5=L8==null?void 0:L8.general)!=null&&V5.datePickerFormat&&R6(L4=>{var Re;return{...L4,datePickerFormat:(Re=L8==null?void 0:L8.general)==null?void 0:Re.datePickerFormat}}),(u8=L8==null?void 0:L8.dashboard)!=null&&u8.underlyingData&&w3({header:{fontColor:((D6=(A8=(j8=L8==null?void 0:L8.dashboard)==null?void 0:j8.underlyingData)==null?void 0:A8.header)==null?void 0:D6.fontColor)||"#0D0D0D",bgColor:((f9=(J8=(G9=L8==null?void 0:L8.dashboard)==null?void 0:G9.underlyingData)==null?void 0:J8.header)==null?void 0:f9.bgColor)||"#f9fafb",fontWeight:((d9=(r8=(Q9=L8==null?void 0:L8.dashboard)==null?void 0:Q9.underlyingData)==null?void 0:r8.header)==null?void 0:d9.fontWeight)||"boldfont",fontSize:(V9=(h9=(C9=L8==null?void 0:L8.dashboard)==null?void 0:C9.underlyingData)==null?void 0:h9.header)==null?void 0:V9.fontSize},content:{fontColor:((N4=(P9=(a5=L8==null?void 0:L8.dashboard)==null?void 0:a5.underlyingData)==null?void 0:P9.content)==null?void 0:N4.fontColor)||"#222c3a",lineGap:((E4=(U9=(e4=L8==null?void 0:L8.dashboard)==null?void 0:e4.underlyingData)==null?void 0:U9.content)==null?void 0:E4.lineGap)||"24px",fontWeight:((I4=(y4=(f4=L8==null?void 0:L8.dashboard)==null?void 0:f4.underlyingData)==null?void 0:y4.content)==null?void 0:I4.fontWeight)||"500",fontSize:(X4=(H4=(ne=L8==null?void 0:L8.dashboard)==null?void 0:ne.underlyingData)==null?void 0:H4.content)==null?void 0:X4.fontSize}})},[L8]),F0.useEffect(()=>{w(L8)},[L8]);const p4=F0.useMemo(()=>!!(D7!=null&&D7.length)||!!(M6!=null&&M6.length),[D7,M6]),T1=F0.useMemo(()=>M6!=null&&M6.length?(M6==null?void 0:M6.map(V5=>{var u8,j8,A8;return{...V5,...c6==="DATABASE"?{tableName:`${l6}.${(j8=(u8=V5==null?void 0:V5.tableName)==null?void 0:u8.split(/\.(?=[^.]*$)/))==null?void 0:j8[1]}`}:{},columns:((A8=V5==null?void 0:V5.columns)==null?void 0:A8.map(D6=>{var G9,J8;return{...D6,defaultValue:Na2(D6,C8,k2),isManualOptions:!!((G9=k2==null?void 0:k2[D6==null?void 0:D6.label])!=null&&G9.options)||!!(D6!=null&&D6.isManualOptions),manualOptions:((J8=k2==null?void 0:k2[D6==null?void 0:D6.label])==null?void 0:J8.options)||(D6==null?void 0:D6.manualOptions)||[]}}))||[]}}))||[]:[],[M6,c6,l6,C8,k2]);return F0.useEffect(()=>{setTimeout(()=>{W3(!!localStorage.getItem("isDisableClick")||!1)},1e3)},[]),h.jsxs(h.Fragment,{children:[H6&&(y9||(S9=window==null?void 0:window.dbn)!=null&&S9.isEnableProxyAuth)?h.jsx("div",{className:ay.loader,children:h.jsx(CA,{})}):null,(I1==="TOKEN_EXPIRED"&&(y9||(g5=window==null?void 0:window.dbn)!=null&&g5.isEnableProxyAuth)?(p==null?void 0:p.tokenExpiry)||"Expired Token!":I1)||null,!y9&&!((n5=window==null?void 0:window.dbn)!=null&&n5.isEnableProxyAuth)&&!H6?h.jsxs("div",{className:ay["alt-container"],children:[p!=null&&p.tokenAbsent?null:h.jsx("img",{src:QV,alt:"no data",width:100,height:100}),(p==null?void 0:p.tokenAbsent)||"INVALID_TOKEN"]}):null,t0&&!H6?h.jsxs(h.Fragment,{children:[a==="card"?h.jsxs("div",{className:"dbn-w-full dbn-h-full",children:[(Y5=Object.keys(T||{}))!=null&&Y5.length&&[A22,qm2].includes((T==null?void 0:T.appearanceOptionsPosition)||"")?h.jsxs("div",{className:`dbn-w-full dbn-flex dbn-flex-wrap dbn-gap-4 dbn-pb-2 ${(T==null?void 0:T.appearanceOptionsPosition)===A22?"dbn-justify-start":"dbn-justify-end"}`,style:v3?{pointerEvents:"none"}:{},children:[(r5=T==null?void 0:T.cumulativeBar)!=null&&r5.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(pa,{position:"bottom",text:"It demonstrates the accumulated values, providing insights into the overall trend or pattern in the data",isSingleLineTxt:!1,children:h.jsx(G5,{enabled:h0,name:"cumulative",onChange:()=>O0(!h0),placeholder:((E3=T==null?void 0:T.cumulativeBar)==null?void 0:E3.label)||"Cumulative"})})}):null,(D8=T==null?void 0:T.dynamicBehaviour)!=null&&D8.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(pa,{position:"bottom",text:"It allows you to observe trends, fluctuations, or updates as they occur in a responsive visual representation",isSingleLineTxt:!1,children:h.jsx(G5,{enabled:U0,name:"dynamic",onChange:()=>X2(!U0),placeholder:((o7=T==null?void 0:T.dynamicBehaviour)==null?void 0:o7.label)||"Dynamic"})})}):null,(j7=T==null?void 0:T.stackedBars)!=null&&j7.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(pa,{position:"bottom",text:"It represents the percentage distribution of individual components relative to the whole.",isSingleLineTxt:!1,children:h.jsx(G5,{name:"full stacked",enabled:Q3,onChange:()=>x1(!Q3),placeholder:((p6=T==null?void 0:T.stackedBars)==null?void 0:p6.label)||"100% stacked bars"})})}):null]}):null,h.jsx("div",{className:`${ay["MetricList-wrapper"]} dbn-metric-chart
|
|
599
599
|
${p4&&r2?`dbn-metric-card dbn-metric-card-container ${ay.mergedCard}`:ay.flexDisplay}
|
|
600
600
|
${I2?"dbn-border-0":""}`,style:{background:p4&&r2&&((s6=L8==null?void 0:L8.dashboard)!=null&&s6.metricCardColor)?(u6=L8==null?void 0:L8.dashboard)==null?void 0:u6.metricCardColor:p4&&r2&&!((v7=L8==null?void 0:L8.dashboard)!=null&&v7.metricCardColor)?"dbn-bg-white":""},children:r2&&p4?h.jsxs(h.Fragment,{children:[!!((F3=(G3=T1==null?void 0:T1[0])==null?void 0:G3.columns)!=null&&F3.length)&&h.jsx("div",{className:"dbn-w-full dbn-flex dbn-gap-2 dbn-p-2 dbn-items-end dbn-z-[19] dbn-justify-start",children:h.jsx(G_,{isEditLayoutEnabled:!1,clientColumnType:T7,hideDatePickerOptions:[],appliedfilters:L0,setAppliedFilters:b0,isDisableClick:v3,filters:T1,internal:{isInternal:!0,workspaceId:q3||""},clientId:l6,isAllClient:g3,theme:I7,tenancyLevel:c6,layout:{adminLayout:((x7=t0==null?void 0:t0.chartOptions)==null?void 0:x7.filterLayout)||[],clientLayout:[],isLocked:!0,onChange:()=>{}},datasourceId:j6})}),h.jsx(Uk,{layouts:{lg:p5},rowHeight:30,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:12,sm:12,xs:4,xxs:2},margin:[10,10],containerPadding:[0,0],draggableHandle:"metric-sub-card",isDraggable:!1,isDroppable:!1,isResizable:!1,children:[t0==null?void 0:t0.metricId,...D7].map(V5=>{var u8,j8,A8,D6,G9,J8,f9;return h.jsx("div",{id:((j8=(u8=q7==null?void 0:q7.find(Q9=>(Q9==null?void 0:Q9.metricId)===V5))==null?void 0:u8.layout)==null?void 0:j8.i)||V5,children:h.jsx(r60,{disableDownloadDataNoFilters:c0,disableDownloadUnderlyingDataNoFilters:p0,calendarType:W2,globalFilters:{tableName:(T1==null?void 0:T1.tableName)||"",filters:(A8=L0==null?void 0:L0.filter(Q9=>Q9==null?void 0:Q9.value))==null?void 0:A8.map(Q9=>Ha2(Q9))},language:M2,translationDictionary:m2,dropdownTheme:I7,underlyingTheme:h6,isDisableClick:v3,metricId:V5,token:y9,adminColors:v5,appearanceOptions:T,metricCardColor:((D6=L8==null?void 0:L8.dashboard)==null?void 0:D6.metricCardColor)||"",chartAppearance:N,chartColors:n,chartRendererType:o,dataMartRelationships:O8,isEnableCumulative:h0,isEnableDynamic:U0,isEnableStack:Q3,disableDownloadPng:Q2,disableFullscreen:d,disableMetricCardBorder:I2,enableDownloadCsv:l,enableEmailCsv:e,enableMultiMetricFilters:A,hideDatePickerOptions:S,hideMetricCardShadow:X??((G9=L8==null?void 0:L8.cardCustomization)==null?void 0:G9.disableShadowOnHover)??!1,isDisableCardTitle:H,isEnableUnderlyingData:o5,isHideChartSettings:r,isHideTablePreview:C,metricFilterOptions:u,metricFilterPosition:f,noDataImg:f2,onMinimize:s,optionsIcon:g},V5)},((f9=(J8=q7==null?void 0:q7.find(Q9=>(Q9==null?void 0:Q9.metricId)===V5))==null?void 0:J8.layout)==null?void 0:f9.i)||V5)})},"default")]}):h.jsx(Ok,{disableDownloadDataNoFilters:c0,disableDownloadUnderlyingDataNoFilters:p0,disableFullscreen:!!d,language:M2,translationDictionary:m2,isDisableClick:v3,isEmbeddedMetric:!r2,datasourceId:j6,isAllClient:g3,disableBorder:I2,metricCardColor:((y7=L8==null?void 0:L8.dashboard)==null?void 0:y7.metricCardColor)||"",isEnableCumulative:h0,isEnableDynamic:U0,isEnableStack:Q3,isMergedMetric:p4&&r2,noDataImg:f2,isShadowDisableOnHover:X??((Q6=L8==null?void 0:L8.cardCustomization)==null?void 0:Q6.disableShadowOnHover)??!1,isAllowedToSeeUnderlyingData:o5,clientColumnType:T7,chartAppearance:N,hideDatePickerOptions:S,workspaceId:q3,guestToken:y9,isFrontendApp:!1,downloadMetrics:$3,appearanceOptions:T,onDownload:(V5,u8)=>{b7(u8?j8=>[...j8,{id:V5,isInProgress:u8}]:j8=>j8.filter(A8=>A8.id!==V5))},metricItem:D2!=null&&D2.isEnabled?{...t0,chartOptions:{...t0==null?void 0:t0.chartOptions,yAxisList:(D2==null?void 0:D2.measures)||[],xAxis:((T6=D2==null?void 0:D2.dimensions)==null?void 0:T6[0])||"",enduserMeasureAndDimensions:{isEnabled:D2==null?void 0:D2.isEnabled,dimensions:((N6=D2==null?void 0:D2.dimensions)==null?void 0:N6.map(V5=>({value:V5,label:V5})))||[],measures:((M3=D2==null?void 0:D2.measures)==null?void 0:M3.map(V5=>({value:V5,label:V5})))||[]}}}:t0,client:l6,dropdownTheme:I7,underlyingTheme:h6,colors:v5||n,optionsIcon:g,onMaximize:d&&!((h8=(D9=t0==null?void 0:t0.clickActions)==null?void 0:D9.chartWithMetric)!=null&&h8.isEnable)?void 0:({rlsFilters:V5,appliedMetricFilters:u8,isClickOnChart:j8})=>t1({isShow:!0,rlsFilters:V5,appliedMetricFilters:u8,isClickOnChart:j8}),companyTenancyType:c6,chartRendererType:o,param:z3,metricFilterOptions:u,enableDownloadCsv:l,enableMultiMetricFilters:A,metricFilterPosition:f,onDownloadRawCsv:e?V5=>I3({show:!0,filterValues:V5}):void 0,isDisableCardTitle:H,appFilters:N7,calendarType:W2})}),(t9=Object.keys(T||{}))!=null&&t9.length&&[c22,f22].includes((T==null?void 0:T.appearanceOptionsPosition)||"")?h.jsxs("div",{className:`dbn-w-full dbn-flex dbn-flex-wrap dbn-gap-4 dbn-pt-2 ${(T==null?void 0:T.appearanceOptionsPosition)===c22?"dbn-justify-start":"dbn-justify-end"}`,style:v3?{pointerEvents:"none"}:{},children:[(o8=T==null?void 0:T.cumulativeBar)!=null&&o8.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(pa,{position:"bottom",text:"It demonstrates the accumulated values, providing insights into the overall trend or pattern in the data",isSingleLineTxt:!1,children:h.jsx(G5,{enabled:h0,name:"cumulative",onChange:()=>O0(!h0),placeholder:((r9=T==null?void 0:T.cumulativeBar)==null?void 0:r9.label)||"Cumulative"})})}):null,(y8=T==null?void 0:T.dynamicBehaviour)!=null&&y8.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(pa,{position:"bottom",text:"It allows you to observe trends, fluctuations, or updates as they occur in a responsive visual representation",isSingleLineTxt:!1,children:h.jsx(G5,{enabled:U0,name:"dynamic",onChange:()=>X2(!U0),placeholder:((k9=T==null?void 0:T.dynamicBehaviour)==null?void 0:k9.label)||"Dynamic"})})}):null,(w5=T==null?void 0:T.stackedBars)!=null&&w5.isEnabled?h.jsx("span",{className:"dbn-flex dbn-gap-1 dbn-items-center",children:h.jsx(pa,{position:"bottom",text:"It represents the percentage distribution of individual components relative to the whole.",isSingleLineTxt:!1,children:h.jsx(G5,{name:"full stacked",enabled:Q3,onChange:()=>x1(!Q3),placeholder:((o9=T==null?void 0:T.stackedBars)==null?void 0:o9.label)||"100% stacked bars"})})}):null]}):null]}):null,(!d||j2!=null&&j2.isClickOnChart)&&j2.isShow||a==="fullscreen"?h.jsx(mE,{children:h.jsx(Fk,{refetchDashboardData:()=>{},onServerEvent:()=>{},disableDownloadDataNoFilters:c0,disableDownloadUnderlyingDataNoFilters:p0,calendarType:W2,language:M2,translationDictionary:m2,appliedMetricFilters:(j2==null?void 0:j2.appliedMetricFilters)||[],datasourceId:j6,appFilters:N7,isAllClient:g3,isEnableMetricSummary:h7,hideDatePickerOptions:S,disableDownloadPng:Q2,chartAppearance:N,clientColumnType:T7,workspaceId:q3,guestToken:y9,isFrontendApp:!1,downloadMetrics:$3,onDownload:(V5,u8)=>{b7(u8?j8=>[...j8,{id:V5,isInProgress:u8}]:j8=>j8.filter(A8=>A8.id!==V5))},metric:D2!=null&&D2.isEnabled?{...j2!=null&&j2.isClickOnChart&&a9?a9:t0,chartOptions:{...(C4=j2!=null&&j2.isClickOnChart&&a9?a9:t0)==null?void 0:C4.chartOptions,yAxisList:(D2==null?void 0:D2.measures)||[],xAxis:((P5=D2==null?void 0:D2.dimensions)==null?void 0:P5[0])||"",enduserMeasureAndDimensions:{isEnabled:D2==null?void 0:D2.isEnabled,dimensions:((D5=D2==null?void 0:D2.dimensions)==null?void 0:D5.map(V5=>({value:V5,label:V5})))||[],measures:((X5=D2==null?void 0:D2.measures)==null?void 0:X5.map(V5=>({value:V5,label:V5})))||[]}}}:j2!=null&&j2.isClickOnChart&&a9?a9:t0,clientId:l6,colors:v5||n,onMinimize:()=>{t1({isShow:!1,isClickOnChart:!1}),s==null||s()},companyId:Y7,tenancyLevel:c6,rlsFilters:j2.rlsFilters,sharingSettingsId:X7,externalDashboardId:"",userProvidedDashboardId:"",isShowChartConfigTab:!1,isHideChartSettings:r,isHideTablePreview:C,metricFilterOptions:u})}):null,e?h.jsx(wV,{workspaceId:q3,metricItem:t0,isShowRawCsvModal:g7.show,onCloseModal:()=>I3({show:!1,filterValues:void 0}),sharingSettingsId:X7,query:db({query:Fd((t0==null?void 0:t0.query)||"",Y7||""),dbName:(t0==null?void 0:t0.integrationName)||"",rlsConditions:((R4=t0==null?void 0:t0.rlsConditions)==null?void 0:R4.filter(V5=>V5.isAddOnMetrics))||[],tenancyLevel:c6,clientId:l6,values:g7.filterValues,isAllClient:!1,clientColumnType:T7,dataMartRelationships:O8})}):null]}):null]})}),eA2=({componentName:t,adminTheme:n,isDisableCardShadow:i,theme:o,longDescriptionConfig:a,isDisableStrokeOpt:s})=>{var d,g,p;const C=new URLSearchParams(window.location.search).get("isDbn"),[l,e]=F0.useState(""),[u,A]=F0.useState(""),f=F0.useId();return F0.useEffect(()=>{const b=document.querySelector("#dbn-styles");b&&A(b.innerHTML)},[]),F0.useEffect(()=>{var w,T,H,S,N,X,W,f2,Q2,I2,r2,D2,M2,m2,k2,W2,c0,p0,L0,b0,j2,t1,h0,O0,U0,X2,Q3,x1,v3,W3,g7,I3;if(!n)return e("");let b="";(w=n.general.fontFamily)!=null&&w.trim()&&(b=`
|