import{rL as e,rM as E,CJ as t,l as n,Fw as T}from"./c2ee0272b-DPDuX889.js";import{u as A,d as s}from"./vendor-query-CRl6sF7K.js";import{r}from"./vendor-react-Dp9pL_Wn.js";import{oF as R,oE as N,oG as i,oH as o}from"./index-XoaBlZfC.js";function I(e){const E=()=>{"visible"===document.visibilityState&&e()};return document.addEventListener("visibilitychange",E),window.addEventListener("focus",E),()=>{document.removeEventListener("visibilitychange",E),window.removeEventListener("focus",E)}}const O=8,c=T;function S(){const{activeOrganization:e}=n(),E=e?.uuid,t=r.useRef(0);r.useEffect(()=>()=>{t.current+=1},[]);const T=r.useRef(E);return r.useLayoutEffect(()=>{T.current=E},[E]),r.useCallback(()=>{const e=++t.current,n=E;return{superseded:()=>e!==t.current||n!==T.current,owns:()=>e===t.current}},[E])}function L(n){const T=n?.invalidateAuth??!1,O=A(),{refresh:L,isRefreshing:u,isRepoListFetching:a}=function(){const[e,n]=r.useState(!1),T=R({skipStatus:!1,enabled:!1}),{forceRefresh:i}=N(),o=S(),I=A(),O=s({predicate:e=>"string"==typeof e.queryKey[0]&&c.includes(e.queryKey[0])});return{refresh:r.useCallback(async e=>{const A=o();n(!0);try{if(!e?.skipResync){const e=await T.refetch();if(A.superseded())return;const t=(e.data??T.data)?.repos??[];await E(t,8,async e=>{A.superseded()||await i(e.repo)})}if(A.superseded())return;const[n]=await Promise.all([T.refetch({cancelRefetch:!e?.skipResync}),I.invalidateQueries({queryKey:[t]},{cancelRefetch:!e?.skipResync})]);return A.superseded()?void 0:n?.data}finally{A.owns()&&n(!1)}},[T,i,o,I]),isRefreshing:e,isRepoListFetching:T.isFetching||O>0}}(),[C,D]=r.useState(!1),d=r.useCallback(async E=>{D(!0);try{T&&await O.invalidateQueries({queryKey:[e]},{cancelRefetch:!1});const t=await L(E);m.current?.(t)}finally{D(!1)}},[T,O,L]),U=r.useRef(d),f=r.useRef(L);r.useEffect(()=>{U.current=d,f.current=L},[d,L]);const l=r.useRef(n?.onInstallComplete),m=r.useRef(n?.onRefreshed);r.useEffect(()=>{l.current=n?.onInstallComplete,m.current=n?.onRefreshed},[n?.onInstallComplete,n?.onRefreshed]);const P=r.useRef(null);return r.useEffect(()=>I(()=>{const e=P.current;e&&(P.current=null,U.current(e))}),[]),function(e){const E=r.useRef(e);r.useEffect(()=>{E.current=e},[e]),r.useEffect(()=>{const e=i(),t=t=>{"GITHUB_INSTALL_COMPLETE"===t.data.type&&(o(e),E.current(t.data))};return e.addEventListener("message",t),()=>{e.removeEventListener("message",t),e.close()}},[])}(e=>{l.current?.(e),f.current().then(e=>m.current?.(e))}),{arm:r.useCallback(e=>{const E=e?.skipResync??!1,t=P.current?.skipResync??!0;P.current={skipResync:E&&t}},[]),refresh:d,isRefreshing:u||C,isRepoListFetching:a}}
/*!-----------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
 * Released under the MIT license
 * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
 *-----------------------------------------------------------------------------*/const u=Object.freeze(Object.defineProperty({__proto__:null,conf:{comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["[","]"],["(",")"],["{","}"]],autoClosingPairs:[{open:'"',close:'"',notIn:["string","comment"]},{open:"'",close:"'",notIn:["string","comment"]},{open:"[",close:"]",notIn:["string","comment"]},{open:"(",close:")",notIn:["string","comment"]},{open:"{",close:"}",notIn:["string","comment"]}]},language:{defaultToken:"",tokenPostfix:".msdax",ignoreCase:!0,brackets:[{open:"[",close:"]",token:"delimiter.square"},{open:"{",close:"}",token:"delimiter.brackets"},{open:"(",close:")",token:"delimiter.parenthesis"}],keywords:["VAR","RETURN","NOT","EVALUATE","DATATABLE","ORDER","BY","START","AT","DEFINE","MEASURE","ASC","DESC","IN","BOOLEAN","DOUBLE","INTEGER","DATETIME","CURRENCY","STRING"],functions:["CLOSINGBALANCEMONTH","CLOSINGBALANCEQUARTER","CLOSINGBALANCEYEAR","DATEADD","DATESBETWEEN","DATESINPERIOD","DATESMTD","DATESQTD","DATESYTD","ENDOFMONTH","ENDOFQUARTER","ENDOFYEAR","FIRSTDATE","FIRSTNONBLANK","LASTDATE","LASTNONBLANK","NEXTDAY","NEXTMONTH","NEXTQUARTER","NEXTYEAR","OPENINGBALANCEMONTH","OPENINGBALANCEQUARTER","OPENINGBALANCEYEAR","PARALLELPERIOD","PREVIOUSDAY","PREVIOUSMONTH","PREVIOUSQUARTER","PREVIOUSYEAR","SAMEPERIODLASTYEAR","STARTOFMONTH","STARTOFQUARTER","STARTOFYEAR","TOTALMTD","TOTALQTD","TOTALYTD","ADDCOLUMNS","ADDMISSINGITEMS","ALL","ALLEXCEPT","ALLNOBLANKROW","ALLSELECTED","CALCULATE","CALCULATETABLE","CALENDAR","CALENDARAUTO","CROSSFILTER","CROSSJOIN","CURRENTGROUP","DATATABLE","DETAILROWS","DISTINCT","EARLIER","EARLIEST","EXCEPT","FILTER","FILTERS","GENERATE","GENERATEALL","GROUPBY","IGNORE","INTERSECT","ISONORAFTER","KEEPFILTERS","LOOKUPVALUE","NATURALINNERJOIN","NATURALLEFTOUTERJOIN","RELATED","RELATEDTABLE","ROLLUP","ROLLUPADDISSUBTOTAL","ROLLUPGROUP","ROLLUPISSUBTOTAL","ROW","SAMPLE","SELECTCOLUMNS","SUBSTITUTEWITHINDEX","SUMMARIZE","SUMMARIZECOLUMNS","TOPN","TREATAS","UNION","USERELATIONSHIP","VALUES","SUM","SUMX","PATH","PATHCONTAINS","PATHITEM","PATHITEMREVERSE","PATHLENGTH","AVERAGE","AVERAGEA","AVERAGEX","COUNT","COUNTA","COUNTAX","COUNTBLANK","COUNTROWS","COUNTX","DISTINCTCOUNT","DIVIDE","GEOMEAN","GEOMEANX","MAX","MAXA","MAXX","MEDIAN","MEDIANX","MIN","MINA","MINX","PERCENTILE.EXC","PERCENTILE.INC","PERCENTILEX.EXC","PERCENTILEX.INC","PRODUCT","PRODUCTX","RANK.EQ","RANKX","STDEV.P","STDEV.S","STDEVX.P","STDEVX.S","VAR.P","VAR.S","VARX.P","VARX.S","XIRR","XNPV","DATE","DATEDIFF","DATEVALUE","DAY","EDATE","EOMONTH","HOUR","MINUTE","MONTH","NOW","SECOND","TIME","TIMEVALUE","TODAY","WEEKDAY","WEEKNUM","YEAR","YEARFRAC","CONTAINS","CONTAINSROW","CUSTOMDATA","ERROR","HASONEFILTER","HASONEVALUE","ISBLANK","ISCROSSFILTERED","ISEMPTY","ISERROR","ISEVEN","ISFILTERED","ISLOGICAL","ISNONTEXT","ISNUMBER","ISODD","ISSUBTOTAL","ISTEXT","USERNAME","USERPRINCIPALNAME","AND","FALSE","IF","IFERROR","NOT","OR","SWITCH","TRUE","ABS","ACOS","ACOSH","ACOT","ACOTH","ASIN","ASINH","ATAN","ATANH","BETA.DIST","BETA.INV","CEILING","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","COMBIN","COMBINA","CONFIDENCE.NORM","CONFIDENCE.T","COS","COSH","COT","COTH","CURRENCY","DEGREES","EVEN","EXP","EXPON.DIST","FACT","FLOOR","GCD","INT","ISO.CEILING","LCM","LN","LOG","LOG10","MOD","MROUND","ODD","PERMUT","PI","POISSON.DIST","POWER","QUOTIENT","RADIANS","RAND","RANDBETWEEN","ROUND","ROUNDDOWN","ROUNDUP","SIGN","SIN","SINH","SQRT","SQRTPI","TAN","TANH","TRUNC","BLANK","CONCATENATE","CONCATENATEX","EXACT","FIND","FIXED","FORMAT","LEFT","LEN","LOWER","MID","REPLACE","REPT","RIGHT","SEARCH","SUBSTITUTE","TRIM","UNICHAR","UNICODE","UPPER","VALUE"],tokenizer:{root:[{include:"@comments"},{include:"@whitespace"},{include:"@numbers"},{include:"@strings"},{include:"@complexIdentifiers"},[/[;,.]/,"delimiter"],[/[({})]/,"@brackets"],[/[a-z_][a-zA-Z0-9_]*/,{cases:{"@keywords":"keyword","@functions":"keyword","@default":"identifier"}}],[/[<>=!%&+\-*/|~^]/,"operator"]],whitespace:[[/\s+/,"white"]],comments:[[/\/\/+.*/,"comment"],[/\/\*/,{token:"comment.quote",next:"@comment"}]],comment:[[/[^*/]+/,"comment"],[/\*\//,{token:"comment.quote",next:"@pop"}],[/./,"comment"]],numbers:[[/0[xX][0-9a-fA-F]*/,"number"],[/[$][+-]*\d*(\.\d*)?/,"number"],[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/,"number"]],strings:[[/N"/,{token:"string",next:"@string"}],[/"/,{token:"string",next:"@string"}]],string:[[/[^"]+/,"string"],[/""/,"string"],[/"/,{token:"string",next:"@pop"}]],complexIdentifiers:[[/\[/,{token:"identifier.quote",next:"@bracketedIdentifier"}],[/'/,{token:"identifier.quote",next:"@quotedIdentifier"}]],bracketedIdentifier:[[/[^\]]+/,"identifier"],[/]]/,"identifier"],[/]/,{token:"identifier.quote",next:"@pop"}]],quotedIdentifier:[[/[^']+/,"identifier"],[/''/,"identifier"],[/'/,{token:"identifier.quote",next:"@pop"}]]}}},Symbol.toStringTag,{value:"Module"}));export{O as R,L as a,I as b,u as m,S as u};
