forked from duneanalytics/DuneQueryRepo
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path[dashboard]-b3156cbcc4c20fe8.js.download
2 lines (2 loc) · 47.7 KB
/
[dashboard]-b3156cbcc4c20fe8.js.download
1
2
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1897],{20640:function(e,t,r){"use strict";var n=r(11742),a={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var r,s,o,i,d,l,c,u,h=!1;t||(t={}),o=t.debug||!1;try{if(d=n(),l=document.createRange(),c=document.getSelection(),(u=document.createElement("span")).textContent=e,u.ariaHidden="true",u.style.all="unset",u.style.position="fixed",u.style.top=0,u.style.clip="rect(0, 0, 0, 0)",u.style.whiteSpace="pre",u.style.webkitUserSelect="text",u.style.MozUserSelect="text",u.style.msUserSelect="text",u.style.userSelect="text",u.addEventListener("copy",function(r){if(r.stopPropagation(),t.format){if(r.preventDefault(),void 0===r.clipboardData){o&&console.warn("unable to use e.clipboardData"),o&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var n=a[t.format]||a.default;window.clipboardData.setData(n,e)}else r.clipboardData.clearData(),r.clipboardData.setData(t.format,e)}t.onCopy&&(r.preventDefault(),t.onCopy(r.clipboardData))}),document.body.appendChild(u),l.selectNodeContents(u),c.addRange(l),!document.execCommand("copy"))throw Error("copy command was unsuccessful");h=!0}catch(n){o&&console.error("unable to copy using execCommand: ",n),o&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),h=!0}catch(n){o&&console.error("unable to copy using clipboardData: ",n),o&&console.error("falling back to prompt"),r="message"in t?t.message:"Copy to clipboard: #{key}, Enter",s=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",i=r.replace(/#{\s*key\s*}/g,s),window.prompt(i,e)}}finally{c&&("function"==typeof c.removeRange?c.removeRange(l):c.removeAllRanges()),u&&document.body.removeChild(u),d()}return h}},47556:function(e,t,r){var n=r(88668),a=r(47443),s=r(1196),o=r(29932),i=r(7518),d=r(74757),l=Math.min;e.exports=function(e,t,r){for(var c=r?s:a,u=e[0].length,h=e.length,p=h,b=Array(h),m=1/0,f=[];p--;){var x=e[p];p&&t&&(x=o(x,i(t))),m=l(x.length,m),b[p]=!r&&(t||u>=120&&x.length>=120)?new n(p&&x):void 0}x=e[0];var v=-1,y=b[0];e:for(;++v<u&&f.length<m;){var g=x[v],j=t?t(g):g;if(g=r||0!==g?g:0,!(y?d(y,j):c(f,j,r))){for(p=h;--p;){var _=b[p];if(!(_?d(_,j):c(e[p],j,r)))continue e}y&&y.push(j),f.push(g)}}return f}},24387:function(e,t,r){var n=r(29246);e.exports=function(e){return n(e)?e:[]}},71843:function(e,t,r){var n=r(29932),a=r(47556),s=r(67206),o=r(5976),i=r(24387),d=r(10928),l=o(function(e){var t=d(e),r=n(e,i);return t===d(r)?t=void 0:r.pop(),r.length&&r[0]===e[0]?a(r,s(t,2)):[]});e.exports=l},29246:function(e,t,r){var n=r(98612),a=r(37005);e.exports=function(e){return a(e)&&n(e)}},80158:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/[slug]/[dashboard]",function(){return r(94442)}])},22577:function(e,t,r){"use strict";r.d(t,{Y:function(){return tZ}});var n=r(85893),a=r(67294),s=r(76138),o=r(75546),i=r(79440),d=r(93836),l=r(83787);function c(e){let{session:t,activeContext:r,queryIds:n,parameters:a,performance:c,apiKey:u}=e;n.forEach(e=>{let n=(0,d.ZX)(e,a),h=n.every(l.in),p=(0,o.q)({queryId:e,parameters:n,can_refresh:h,apiKey:u,session:t});(0,i.d)({queryId:e,parameters:p.variables.parameters,requestContext:p.context,activeContext:r,executionType:h?"interactive":"viz_custom_params_refresh",performance:c}).then(()=>{s.gw.query({query:p.queryDoc,variables:p.variables,context:p.context,fetchPolicy:"network-only"})}).catch(()=>{})})}var u=r(10767),h=r.n(u),p=r(97560),b=r(80558),m=r(82729),f=r(32037),x=r(15183),v=r(59999),y=r(28174),g=r(39561),j=r(13426),_=r(51577),w=r(11163),C=r(39137),k=r(84937),D=r(57831),S=r(85361),z=r(78718),R=r.n(z),M=r(10933),I=r(73181),E=r(47730),O=r(46367);function P(){let e=(0,m._)(["\n mutation ForkDashboard(\n $existing_dashboard_id: Int!\n $new_dashboard_name: String!\n $new_dashboard_slug: String!\n $contextOwner: ContextOwner!\n ) {\n forkDashboard(\n dashboardId: $existing_dashboard_id\n dashboardName: $new_dashboard_name\n dashboardSlug: $new_dashboard_slug\n forkTo: $contextOwner\n ) {\n slug\n }\n }\n"]);return P=function(){return e},e}function N(e){let t=(0,D.kP)(),r=(0,S._0)(),[s,o]=a.useState(!1);if(!t||!t.user||!r)return null;let i=()=>o(e=>!e);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(E.u,{position:"below-center",label:"Fork",children:(0,n.jsx)(M.h,{onClick:i,size:"M",className:h().alignMiddle,theme:"tertiary","aria-label":"Fork",children:(0,n.jsx)(I.IconGitFork,{})})}),(0,n.jsx)(v.Vq,{label:"New dashboard",size:"sm",isOpen:s,onDismiss:i,children:(0,n.jsx)(T,{session:t,activeContext:r,dashboard:e.dashboard,close:i})})]})}function T(e){let[t,r]=a.useState(""),[s,o]=a.useState(""),[i,d]=a.useState(null),{session:l,activeContext:c}=e,u=(0,w.useRouter)(),p=a.useMemo(()=>s.trim()||(0,j.GD)(t),[s,t]),b=a.useMemo(()=>"https://dune.com/".concat(c.handle,"/").concat(p),[p]),[m,v]=(0,k.gIM)({context:{session:l},variables:{existing_dashboard_id:e.dashboard.id,new_dashboard_name:t,new_dashboard_slug:p,contextOwner:R()(c,["id","type"])}}),C=!1!==v.loading||void 0!==v.data;return a.useEffect(()=>{v.error&&(v.error.message.includes("dashboards_unique_user_slug_idx")||v.error.message.includes("dashboards_unique_team_slug_idx")?d(Error(s.trim()?"You already have a dashboard with this URL. Please pick another one.":"You already have a dashboard with this name. Please pick another one.")):q(v.error.message)?d(Error(v.error.message)):d(Error("Something went wrong")))},[v.error]),(0,n.jsx)("form",{onSubmit:e=>{if(e.preventDefault(),t&&t.trim()){if(!(0,j.w)(p)){d(Error("The URL you entered is not valid. It can only contain lowercase letters, numbers and dashes (-)"));return}}else{d(Error("Please enter a dashboard name"));return}d(null),m().then(e=>{if((0,O.n)(e.data)){let{slug:t}=e.data.forkDashboard;u.push("/".concat(c.handle,"/").concat(t))}else _.k.error("Expected data to be returned when forking dashboard but got:",e)}).catch(e=>{_.k.error(e)})},children:(0,n.jsxs)(y.Iv,{children:[(0,n.jsx)(y.Qy,{label:"Dashboard name",children:(0,n.jsxs)("div",{className:h().dashboardName,children:[(0,n.jsx)(g.oH,{placeholder:"My dashboard",value:t,onChange:e=>r(e.target.value)}),(0,n.jsx)("p",{className:h().linkPreview,title:b,children:b})]})}),(0,n.jsx)(y.Qy,{label:"Customize the URL",children:(0,n.jsx)(g.oH,{placeholder:p||"my-dashboard",value:s,onChange:e=>o(e.target.value)})}),(0,n.jsx)(y.o_,{children:(0,n.jsxs)(x.h,{children:[(0,n.jsx)(f.lr,{loading:C,type:"submit",size:"sm",color2:!0,children:C?"Saving...":"Save and open"}),(0,n.jsx)(f.lr,{onClick:e.close,loading:C,size:"sm",color2:!0,light:!0,children:"Cancel"})]})}),i&&!q(i.message)&&(0,n.jsx)(y.cp,{error:i})]})})}(0,C.Z)(P());let q=e=>e.includes("max_number_of_private_dashboards_reached")||e.includes("Reached max number of private dashboards.");var A=r(41655),L=r.n(A),F=r(54179),$=r(84541),Z=r(5153),U=r(14080),B=r(76679),H=r(75805),G=r(96981),Q=r(43965),K=r(57903),V=r(71909),W=r(45172),X=r(40802);function J(e){let{ownerId:t,dashboardId:r}=e,s=(0,D.kP)(),o=(0,V.J)(),[i,d]=(0,a.useState)({status:"idle"});return((0,a.useEffect)(()=>{"success"===i.status&&setTimeout(()=>d({status:"idle"}),1e3)},[i]),s)?"loading"===i.status?(0,n.jsx)(M.h,{size:"M",theme:"tertiary",loading:!0,children:(0,n.jsx)(H.IconLoading,{})}):"success"===i.status?(0,n.jsx)(E.u,{label:i.message,position:"below-center",forceOpen:!0,children:(0,n.jsx)(M.h,{size:"M",theme:"tertiary","aria-label":i.message,children:(0,n.jsx)(G.IconCheckmark,{})})}):(0,n.jsx)(F.c,{position:"cover-anchor-top-right",content:e=>{let{close:a}=e;return(0,n.jsxs)("div",{className:L().buttonGroup,children:[(0,n.jsx)(E.u,{label:"Copy screenshot to clipboard",position:"below-center",children:(0,n.jsx)(M.h,{size:"M",theme:"primary",onClick:()=>{d({status:"loading"}),(function(e,t){let{ownerId:r,dashboardId:a}=t;return(0,Q.P)(e,{domtoimageOptions:{scale:2}}).then(()=>{W.Z.trackEvent("Dashboard Screenshot Copied",{owner_id:r,dashboard_id:a})},e=>{throw e instanceof Error&&(e.message="Copy dashboard screenshot: "+e.message),X.Tb(e,{extra:{dashboardId:a}}),(0,K.Bh)({level:"error",title:"Could not copy screenshot",description:(0,n.jsx)(n.Fragment,{children:"Something went wrong when trying to copy screenshot of the dashboard."})}),e})})(document.querySelector("main"),{ownerId:t,dashboardId:r}).then(()=>d({status:"success",message:"Copied!"}),()=>d({status:"idle"}))},"aria-label":"Copy dashboard screenshot to clipboard",children:(0,n.jsx)(U.IconCopy,{})})}),(0,n.jsx)(E.u,{label:"Save screenshot",position:"below-center",children:(0,n.jsx)(M.h,{size:"M",theme:"primary",onClick:()=>{a(),d({status:"loading"}),(function(e,t){let{ownerId:r,dashboardId:a}=t;return(0,Q.d)(e,{fileName:document.title,domtoimageOptions:{scale:2}}).then(()=>{W.Z.trackEvent("Dashboard Screenshot Saved",{owner_id:r,dashboard_id:a})},e=>{throw e instanceof Error&&(e.message="Save visualization screenshot: "+e.message),X.Tb(e,{extra:{dashboardId:a}}),(0,K.Bh)({level:"error",title:"Could not save screenshot",description:(0,n.jsx)(n.Fragment,{children:"Something went wrong when trying to save screenshot of the dashboard."})}),e})})(document.querySelector("main"),{ownerId:t,dashboardId:r}).then(()=>d({status:"success",message:"Saved!"}),()=>d({status:"idle"}))},"aria-label":"Save dashboard screenshot",children:(0,n.jsx)(B.IconDownloadSimple,{})})})]})},children:(0,n.jsx)(M.h,{size:"M",theme:"tertiary","aria-label":"Take dashboard screenshot",children:(0,n.jsx)(Z.IconCamera,{})})}):(0,n.jsx)(E.u,{label:"Log in to take screenshot",position:"below-center",children:(0,n.jsx)($.w,{size:"M",theme:"tertiary",href:o,"aria-label":"Log in to take dashboard screenshot",children:(0,n.jsx)(Z.IconCamera,{})})})}var Y=r(82733),ee=r(80403),et=r(37242),er=r(91813),en=r(36568),ea=r(34201),es=r(31821),eo=r(12111),ei=r(74855),ed=r.n(ei),el=r(94184),ec=r.n(el),eu=r(1036),eh=r.n(eu),ep=r(46166),eb=r(45765),em=r(31544),ef=r.n(em),ex=r(4564),ev=r(61451),ey=r(44914),eg=r(10398),ej=r(2178),e_=r(34668),ew=r(41118);function eC(){let e=(0,m._)(["\n mutation InsertDashboardApiKey($dashboardId: Int!) {\n createDashboardApiKey(dashboardId: $dashboardId ) {\n id\n }\n }\n"]);return eC=function(){return e},e}let ek=e=>(0,n.jsx)(ex.u_,{size:"L",label:e.label,content:t=>{let{close:r}=t;return(0,n.jsx)(eD,{...e,onDismiss:r})},trigger:t=>{let{onClick:r}=t;return(0,n.jsx)(ev.z,{disabled:e.disabled,size:"M",theme:"tertiary",onClick:r,children:e.label})}}),eD=e=>{let{dashboard:t}=e,{session:r,sessionLoading:s}=a.useContext(D.B3),[o,i]=a.useState(!1),[d,l]=a.useState(""),c=(0,eb.c)(),u=(0,ey.Kz)({type:"owner"in e?e.owner.type:"user",id:"owner"in e?e.owner.id:-1});return(0,a.useEffect)(()=>{s||d||eS({...e,hasViewPermission:u},r).then(l).catch(c)},[r,s,d]),(0,a.useEffect)(()=>{o&&((0,K.Bh)({level:"success",title:"Link copied"}),e.onDismiss())},[o]),(0,n.jsxs)("div",{className:ef().body,children:[(0,n.jsx)("div",{className:ef().header,children:(0,n.jsxs)("div",{className:ef().titleRow,children:[(0,n.jsx)("h2",{children:"Share this dashboard"}),(0,n.jsx)(M.h,{theme:"ghost",size:"S",onClick:e.onDismiss,children:(0,n.jsx)(ew.IconCross,{})})]})}),(0,n.jsxs)("div",{className:ec()(ef().content,eh().modalContent),children:[(0,n.jsxs)("section",{children:[(0,n.jsx)(e_._,{htmlFor:"dashboardLink",children:"Dashboard url"}),(0,n.jsx)(eg.U,{id:"dashboardLink",size:"L",style:"contained",value:d,readOnly:!0,placeholder:"",onChange:()=>{}}),(0,n.jsx)(ed(),{text:d,onCopy:()=>{i(!0)},children:(0,n.jsxs)(ev.z,{size:"M",theme:"primary",children:[(0,n.jsx)(U.IconCopy,{}),"Copy"]})})]}),(0,n.jsx)(ej.G,{props:{type:"dashboard",dashboard:t},session:r})]})]})},eS=async(e,t)=>t&&e.dashboard.is_private&&e.hasViewPermission?ez(e.dashboard,t,e.owner):(0,ep.C_)(e.dashboard.owner.handle,e.dashboard.slug),ez=async(e,t,r)=>{let n=await eR(e.id,t);return(0,ep.C_)(r.handle,e.slug,n)},eR=async(e,t)=>{var r,n;let a=await s.bj.mutate({mutation:k.gJP,variables:{dashboardId:e},context:{session:t},fetchPolicy:"no-cache"});if(!(null===(n=a.data)||void 0===n?void 0:null===(r=n.createDashboardApiKey)||void 0===r?void 0:r.id))throw Error("could not create dashboard key");return a.data.createDashboardApiKey.id};(0,C.Z)(eC());var eM=r(26657),eI=r(93184),eE=r(26832),eO=r(92125),eP=r(35470),eN=r(28311);let eT=e=>e.dashboard.is_archived?(0,n.jsx)(E.u,{label:"Archived dashboards cannot be updated",position:"below-center",children:(0,n.jsx)(ev.z,{size:"M",theme:"tertiary",disabled:!0,children:"Add text widget"})}):(0,n.jsx)(v.Qd,{label:"Add text widget",size:"md",children:t=>(0,n.jsx)(eq,{...e,onDismiss:t})}),eq=e=>{let[t,r]=a.useState(!1),[s,o]=a.useState(""),i=(0,D.Xd)(),d=(0,eb.c)();return(0,n.jsx)("form",{onSubmit:t=>{t.preventDefault(),r(!0),(0,eN.Zo)(e.dashboard,s,i).then(()=>{var t;return W.Z.trackEvent("Dashboard Widget Added",{dashboard_id:e.dashboard.id}),null===(t=e.refresh)||void 0===t?void 0:t.call(e)}).then(()=>e.onDismiss()).catch(d)},children:(0,n.jsxs)(y.Iv,{children:[(0,n.jsx)(eP.x,{text:s,setText:o}),(0,n.jsx)(y.o_,{children:(0,n.jsxs)(x.h,{children:[(0,n.jsx)(f.lr,{loading:t,disabled:!s,type:"submit",size:"sm",color2:!0,children:"Save"}),(0,n.jsx)(f.lr,{onClick:e.onDismiss,loading:t,size:"sm",color2:!0,light:!0,children:"Cancel"})]})})]})})};var eA=r(66465),eL=r(79478),eF=r(89132),e$=r.n(eF),eZ=r(42665);function eU(e){let{activeContext:t,cost:r,queryCount:a,unexecutableQueryCount:s}=e;return(0,n.jsxs)("div",{className:ec()(ef().body),children:[(0,n.jsx)("div",{className:ef().header,children:(0,n.jsxs)("div",{className:ef().titleRow,children:[(0,n.jsxs)("h2",{children:["Run all ",a,s>0?" executable* ":" ","queries for this dashboard"]}),(0,n.jsx)(M.h,{size:"XS",theme:"ghost",onClick:e.close,children:(0,n.jsx)(ew.IconCross,{})})]})}),(0,n.jsxs)("div",{className:e$().content,children:[s>0&&(0,n.jsx)(eZ.P,{level:"warning",dismissable:!1,title:"*Deprecated datasets",description:(0,n.jsxs)(n.Fragment,{children:[s," queries on this dashboard can no longer be executed because they run against deprecated datasets."]})}),(0,n.jsx)(eZ.P,{level:"info",dismissable:!1,title:(0,n.jsxs)(n.Fragment,{children:["These executions will use ",r," credits from @",t.name," plan quota."]})})]}),(0,n.jsxs)("div",{className:ef().buttons,children:[(0,n.jsx)(ev.z,{size:"M",theme:"tertiary",onClick:e.close,children:"Cancel"}),(0,n.jsx)(ev.z,{size:"M",theme:"primary",autoFocus:!0,onClick:()=>{e.runAllQueries(),e.close()},children:"Run all queries"})]})]})}var eB=r(56598);function eH(e){let{activeContext:t,getCost:r,queryIdsWithNonDefaultParamsThatDidNotJustRun:s,queryIds:o,unexecutableQueryCount:i,runAllQueries:d,runQueriesWithNonDefaultParams:l}=e,[c,u]=(0,a.useState)(!1),h=s.length,p=o.length>s.length;return(0,n.jsxs)("div",{className:ec()(ef().body),children:[(0,n.jsxs)("div",{className:ef().header,children:[(0,n.jsxs)("div",{className:ef().titleRow,children:[(0,n.jsx)("h2",{children:"Run queries with parameters"}),(0,n.jsx)(M.h,{size:"XS",theme:"ghost",onClick:e.close,children:(0,n.jsx)(ew.IconCross,{})})]}),p&&(0,n.jsx)("p",{children:"Do you want to run only newly affected queries or run all queries?"})]}),(0,n.jsxs)("div",{className:ec()(ef().content,e$().content),children:[p&&(0,n.jsxs)(eB.S,{name:"with-hint",value:c?"all":"not-all",onChange:e=>u("all"===e),children:[(0,n.jsxs)(eB.D,{value:"not-all",hint:(0,n.jsxs)(n.Fragment,{children:["Use ",r(h)," credits from @",t.name," plan quota"]}),children:["Run ",eG(h)," affected by the parameter selection"]}),(0,n.jsxs)(eB.D,{value:"all",hint:(0,n.jsxs)(n.Fragment,{children:["Use ",r(o.length)," credits from @",t.name," plan quota"]}),children:["Run all ",eG(o.length)," in dashboard"]})]}),i>0&&(0,n.jsx)(eZ.P,{level:"warning",dismissable:!1,title:"*Deprecated datasets",description:(0,n.jsxs)(n.Fragment,{children:[i," queries on this dashboard can no longer be executed because they run against deprecated datasets."]})})]}),(0,n.jsxs)("div",{className:ef().buttons,children:[(0,n.jsx)(ev.z,{size:"M",theme:"tertiary",onClick:e.close,children:"Close"}),c?(0,n.jsx)(ev.z,{size:"M",theme:"primary",onClick:()=>{d(),e.close()},children:"Run all queries"}):(0,n.jsxs)(ev.z,{size:"M",theme:"primary",autoFocus:!0,onClick:()=>{l(),e.close()},children:["Run ",eG(h)]})]})]})}function eG(e){return(0,n.jsxs)(n.Fragment,{children:[e," ",1===e?"query":"queries"]})}function eQ(e){return(0,n.jsxs)("div",{className:ec()(ef().body),children:[(0,n.jsx)("div",{className:ef().header,children:(0,n.jsxs)("div",{className:ef().titleRow,children:[(0,n.jsx)("h2",{children:"Deprecated datasets"}),(0,n.jsx)(M.h,{size:"XS",theme:"ghost",onClick:e.close,children:(0,n.jsx)(ew.IconCross,{})})]})}),(0,n.jsx)("div",{className:ec()(ef().content,e$().content),children:(0,n.jsx)(eZ.P,{level:"warning",dismissable:!1,title:"*Deprecated datasets",description:(0,n.jsx)(n.Fragment,{children:"All the queries on this dashboard run against deprecated datasets and can no longer be executed."})})}),(0,n.jsx)("div",{className:ef().buttons,children:(0,n.jsx)(ev.z,{size:"M",theme:"tertiary",onClick:e.close,children:"Close"})})]})}var eK=r(54173),eV=r(23101),eW=r.n(eV),eX=r(71843),eJ=r.n(eX),eY=r(73874),e0=r(41685),e1=r(83959),e5=r(84899);let e2=(e,t)=>{let r,n;let s=(0,e0.m)(t),[o,i]=a.useState(),d=new Set,l=new Set,c=new Set;for(let t of e)if((0,eY.Vx)(t.visualization)){let e=t.visualization.query_details;e&&((0,e5.r)(e.dataset_id)?l.add(e.query_id):(d.add(e.query_id),c.add(e.dataset_id)))}if(c.forEach(e=>{n=n?eJ()(n,s(e),"publicPerformanceTierKey"):s(e).filter(e=>{let{credits:t}=e;return t>0})}),n){let e=(0,e1.g)(t,n);!o&&e&&i(e),o&&(r=n.find(e=>{let{publicPerformanceTierKey:t}=e;return t===o}))}return{queryIds:[...d],unexecutableQueryIds:[...l],performance:o,setPerformance:i,selectedPerformanceTier:r,performanceTiers:n||[]}};var e7=r(17870),e6=r(55601),e3=r(54015),e8=r(31269);let e4=e=>{let{dashboard:t,parameters:r,apiKey:s,executeQueries:o}=e,i=(0,D.kP)(),c=(0,S._0)(),{captureEvent:u}=(0,eA.z$)(),h=(0,V.J)(),{queryIds:p,unexecutableQueryIds:b,performance:m,setPerformance:f,selectedPerformanceTier:x,performanceTiers:v}=e2(t.visualization_widgets||[],c),[y,g]=(0,a.useState)([]);function j(e){g(t=>t.concat(e).filter((0,e8.uw)(e9)))}let _=p.filter(e=>{let t=(0,d.Jj)(e,r);return t.some(e=>!(0,l.in)(e)&&!y.find(e9(e)))}),w=!!c&&!!m;if(0===p.length)return b.length>0?(0,n.jsx)(ex.QC,{size:"M",label:"Apply parameters",content:e=>{let{close:t}=e;return(0,n.jsx)(eQ,{close:t})},trigger:e=>{let{onClick:t}=e;return(0,n.jsx)(ev.z,{onClick:t,size:"M",theme:"primary",children:"Run"})},isOpen:e.isRunModalOpen,setIsOpen:e.setIsRunModalOpen}):null;let C=m&&!!(null==v?void 0:v.length);if(!i||!i.user||!c)return(0,n.jsx)(eK.A,{theme:"primary",size:"M",href:h,children:"Run"});if(!w)return null;function k(){u("RefreshDashboard: Run Queries clicked"),e.parameters.state.onApply(),i&&c&&(o({session:i,activeContext:c,performance:m,queryIds:p,parameters:r,apiKey:s}),j(r.state.appliedMerged))}function z(){i&&c&&(o({session:i,activeContext:c,performance:m,queryIds:_,parameters:r,apiKey:s}),j(r.state.appliedMerged),u("Dashboard parameter apply modal: Applied interactively"))}let R=e=>{let{onClick:t}=e;return(0,n.jsxs)(ev.z,{onClick:t,size:"M",theme:"primary",children:[C&&(0,n.jsx)(e7.P,{performance:m}),"Run"]})};function M(e){return x&&C?e*x.credits:0}return(0,n.jsxs)(e3.f,{className:eW().refreshButtonGroup,children:[_.length>0?(0,n.jsx)(ex.QC,{size:"M",label:"Apply parameters",content:e=>{let{close:t}=e;return(0,n.jsx)(eH,{activeContext:c,getCost:M,queryIds:p,queryIdsWithNonDefaultParamsThatDidNotJustRun:_,unexecutableQueryCount:b.length,runAllQueries:k,runQueriesWithNonDefaultParams:z,close:t})},onDismiss:()=>{u("Dashboard parameter apply modal: Dismissed")},trigger:R,isOpen:e.isRunModalOpen,setIsOpen:e.setIsRunModalOpen}):(0,n.jsx)(ex.QC,{size:"M",label:"Refresh dashboard",content:e=>{let{close:t}=e;return(0,n.jsx)(eU,{activeContext:c,cost:M(p.length),queryCount:p.length,unexecutableQueryCount:b.length,runAllQueries:k,close:t})},trigger:R,isOpen:e.isRunModalOpen,setIsOpen:e.setIsRunModalOpen}),C&&(0,n.jsx)(e6.K,{performance:m,setPerformance:f,activeContext:c,performanceTiers:v,buttonTheme:"primary"})]})},e9=e=>t=>e.key===t.key&&e.value===t.value;var te=r(5505),tt=r(55417),tr=r(92101),tn=r(56446);function ta(){let e=(0,m._)(["\n mutation CreateDashboardSchedule(\n $dashboard_id: Int!\n $cron_expression: String!\n $performance: String!\n ) {\n createDashboardSchedule(\n dashboardId: $dashboard_id\n cronExpression: $cron_expression\n performance: $performance\n ) {\n dashboard_id: dashboardId\n }\n }\n"]);return ta=function(){return e},e}function ts(){let e=(0,m._)(["\n mutation UpdateDashboardSchedule(\n $cron_job_id: String!\n $cron_expression: String!\n $performance: String!\n ) {\n updateDashboardSchedule(\n cronJobId: $cron_job_id\n cronExpression: $cron_expression\n performance: $performance\n ) {\n dashboard_id: dashboardId\n }\n }\n"]);return ts=function(){return e},e}function to(){let e=(0,m._)(["\n mutation DeleteDashboardSchedule($cron_job_id: String!) {\n deleteDashboardSchedule(cronJobId: $cron_job_id) {\n cron_job_id: cronJobId\n }\n }\n"]);return to=function(){return e},e}(0,C.Z)(ta()),(0,C.Z)(ts()),(0,C.Z)(to());var ti=r(45466),td=r(38960);function tl(e){let t=(0,D.qy)(),r=(0,ey.l9)(e.dashboard.owner),a=e.dashboard.is_archived;return t&&r&&!a?(0,n.jsx)(tc,{session:t,dashboard:e.dashboard}):null}function tc(e){let{session:t,dashboard:r}=e,a=(0,tr.W_)(t,r.id),s=function(e,t,r){let n=(0,ti.gh)(e);return function(t){switch(t.type){case"user":return(0,td.r)(e);case"team":{let e=n.find(e=>e.id===t.id);if(!e)return;return(0,td.S)(e)}}}(t?t.owner:r)}(t,a,r.owner),{queryIds:o,performanceTiers:i}=e2(r.visualization_widgets||[],s);if(!s||0===o.length)return null;let d=a&&(0,tn.mB)(a.cronString);return(0,n.jsx)(ex.u_,{size:"M",label:"Dashboard execution schedule",content:e=>{let{close:d}=e;return(0,n.jsx)(tu,{session:t,contextOwner:s,performanceTiers:i,dashboard:r,queryCount:o.length,existingSchedule:a,close:d})},trigger:e=>{let{isOpen:t,onClick:r}=e;return(0,n.jsx)(E.u,{position:"below-center",label:"Schedule dashboard refresh",children:a?(0,n.jsxs)(ev.z,{size:"M",theme:"tertiary",className:t?"active":void 0,onClick:r,children:[(0,n.jsx)(te.IconClockHistory,{}),void 0===d?"Unknown":(0,tn.Sq)(d)]}):(0,n.jsx)(M.h,{size:"M",theme:"tertiary",className:t?"active":void 0,onClick:r,children:(0,n.jsx)(te.IconClockHistory,{})})})}})}function tu(e){let{session:t,contextOwner:r,performanceTiers:a,dashboard:s,queryCount:o,existingSchedule:i,close:d}=e,[l,c]=function(){let[e,t]=(0,k.TOF)();return[function(r,n,a){return new Promise(t.loading?()=>{}:t=>{e({context:{session:r},variables:{dashboard_id:n,cron_expression:a.cronString,performance:a.performanceTier},refetchQueries:[(0,tr.iD)(r,n)]}).then(()=>{var e;W.Z.trackEvent("Dashboard Schedule Created",{dashboard_id:n,interval:null!==(e=(0,tn.mB)(a.cronString))&&void 0!==e?e:a.cronString,performance:a.performanceTier}),t()},e=>{X.Tb("Failed to create dashboard schedule: "+e.message)})})},t]}(),[u,h]=function(){let[e,t]=(0,k.vT1)();return[function(r,n,a){return new Promise(t.loading?()=>{}:t=>{e({context:{session:r},variables:{cron_job_id:n.scheduleId,cron_expression:a.cronString,performance:a.performanceTier},refetchQueries:[(0,tr.iD)(r,n.dashboardId)]}).then(()=>{t()},e=>{e.message="Failed to update dashboard schedule: "+e.message,X.Tb(e)})})},t]}(),[p,b]=function(){let[e,t]=(0,k.PER)();return[function(r,n){return new Promise(t.loading?()=>{}:t=>{e({context:{session:r},variables:{cron_job_id:n.scheduleId},refetchQueries:[(0,tr.iD)(r,n.dashboardId)]}).then(()=>{t()},e=>{e.message="Failed to delete dashboard schedule: "+e.message,X.Tb(e)})})},t]}(),m=i?()=>p(t,{dashboardId:s.id,scheduleId:i.id}).then(d):void 0;return(0,n.jsx)(tt.E,{contextOwner:r,performanceTiers:a,queryCount:o,initialState:i,save:e=>{i?u(t,{dashboardId:s.id,scheduleId:i.id},e).then(d):l(t,s.id,e).then(d)},stop:m,close:d,error:c.error||b.error||h.error})}var th=r(63770);function tp(){let e=(0,m._)(["\n query FindDashboardFolder($id: Int!) {\n dashboard(id: $id) {\n is_archived: isArchived\n folder {\n id\n icon\n color\n name\n description\n path\n }\n }\n }\n"]);return tp=function(){return e},e}let tb=(e,t)=>{let r=(0,D.qy)(),n=(0,k.gYc)({skip:!r||!t||void 0===e,context:{session:r},variables:{id:e}});if((0,O.n)(n.data))return{folder:function(e){if((0,O.n)(e.data)){if(e.data.dashboard.is_archived)return{id:"",name:"Archived",path:"",icon:"archive",color:"red"};if(!e.data.dashboard.is_archived&&!(0,O.n)(e.data.dashboard.folder))return{id:"",name:"Creations",path:"",icon:"folder",color:"gray"};if(e.data.dashboard.folder){var t;return{id:e.data.dashboard.folder.id,name:null!==(t=e.data.dashboard.folder.name)&&void 0!==t?t:"Creations",path:e.data.dashboard.folder.path,icon:e.data.dashboard.folder.icon,color:e.data.dashboard.folder.color}}}}(n),refetch:()=>{n.refetch()}}};(0,C.Z)(tp());var tm=r(63750),tf=r(21708),tx=r.n(tf),tv=r(68357),ty=r(80949),tg=r(61575);function tj(e){let t=e.repo_link;return(0,tg.HH)(t)&&t_(t)?t:void 0}function t_(e){return e.startsWith("https://github.com/")&&/\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+/.test(new URL(e).pathname)}function tw(){let e=(0,m._)(["\n mutation UpdateDashboardRepoLink($input: UpdateDashboardInput!) {\n updateDashboard(input: $input) {\n id\n repoLink\n }\n }\n"]);return tw=function(){return e},e}function tC(e){var t;let{session:r,dashboard:s}=e;(0,a.useEffect)(()=>(W.Z.trackEvent("Edit Dashboard Repo Modal Opened"),()=>{W.Z.trackEvent("Edit Dashboard Repo Modal Closed")}),[]);let o=tj(s),[i,d]=(0,a.useState)(null!=o?o:""),[l,c]=(0,a.useState)(),[u,{loading:h}]=(0,k.Knb)(),p=async t=>{t_(t)&&(c(void 0),u({context:{session:r},variables:{input:{id:s.id,repoLink:t,isPrivate:s.is_private,name:s.name,slug:s.slug,userId:"user"===s.owner.type?s.owner.id:null,teamId:"team"===s.owner.type?s.owner.id:null,tags:s.tags}}}).then(e.close).catch(e=>{X.Tb("Could not update repo link for dashboard ".concat(s.id,": ").concat(e)),c("Unable to update repo link, please try again.")}),W.Z.trackEvent("Edit Dashboard Repo Modal Repo Link Set",{repoUrl:t}))},b=async t=>{t_(t)&&(c(void 0),u({context:{session:r},variables:{input:{id:s.id,repoLink:null,isPrivate:s.is_private,name:s.name,slug:s.slug,userId:"user"===s.owner.type?s.owner.id:null,teamId:"team"===s.owner.type?s.owner.id:null,tags:s.tags}}}).then(e.close).catch(e=>{X.Tb("Could not remove repo link for dashboard ".concat(s.id,": ").concat(e)),c("Unable to remove repo link, please try again.")}),W.Z.trackEvent("Edit Dashboard Repo Modal Repo Link Removed"))},m=Array.from(new Set(null===(t=s.visualization_widgets)||void 0===t?void 0:t.reduce((e,t)=>{var r,n;switch(null==t?void 0:null===(r=t.visualization)||void 0===r?void 0:r.type){case"text":case"param":break;default:{let r=null===(n=t.visualization.query_details)||void 0===n?void 0:n.query_id;(0,tg.C_)(r)&&e.push(r)}}return e},[])));return(0,n.jsxs)("div",{className:ef().body,children:[(0,n.jsxs)("div",{className:ef().header,children:[(0,n.jsxs)("div",{className:ef().titleRow,children:[(0,n.jsx)("h2",{children:"Turn your dashboard into a repo"}),(0,n.jsx)(M.h,{size:"XS",theme:"ghost",onClick:e.close,children:(0,n.jsx)(ew.IconCross,{})})]}),(0,n.jsx)("p",{className:ef().description,children:(0,n.jsx)("em",{children:"You will need at least a Plus plan to use this feature."})})]}),(0,n.jsxs)("div",{className:tx().content,children:[(0,n.jsxs)("p",{children:[(0,n.jsx)(tv.L,{size:"M",theme:"primary",href:"https://github.com/duneanalytics/DuneQueryRepo",target:"_blank",children:(0,n.jsx)("b",{children:"Use this repo template to create a GitHub repo"})})," ","for all queries in this dashboard. Copy and paste these ids into your `queries.yml` file:"]}),(0,n.jsx)("div",{className:tx().curlBlock,children:(0,n.jsx)("code",{children:(0,n.jsx)("ul",{children:m.map(e=>(0,n.jsxs)("li",{children:["- ",e]},e))})})}),(0,n.jsx)("p",{children:"Once you're set up, paste the link to your repo below."}),(0,n.jsx)(eg.U,{size:"M",style:"outlined",id:"https://github.com/duneanalytics/QueryRepo",label:"Paste your repo link",placeholder:"https://github.com/organization/repository",value:i,onChange:e=>d(e.target.value),error:i.length>0&&!t_(i)?"Must link to a GitHub repository":void 0}),(0,tg.HH)(o)&&(0,n.jsxs)("p",{children:["You have already linked this dashboard to"," ",(0,n.jsxs)(tv.L,{size:"M",theme:"secondary",href:o,target:"_blank",rel:"noreferrer",children:[o,(0,n.jsx)(ty.J,{icon:"external-link"})]})]}),(0,tg.C_)(l)&&(0,n.jsx)("p",{className:tx().error,children:l})]}),(0,n.jsxs)("div",{className:ef().buttons,children:[(0,n.jsx)(ev.z,{size:"M",theme:"tertiary",type:"button",onClick:e.close,children:"Cancel"}),(0,n.jsx)("hr",{className:ef().gapFillMiddle}),(0,tg.HH)(o)&&(0,n.jsx)(ev.z,{size:"M",theme:"danger",type:"button",disabled:!t_(i),loading:h,onClick:()=>b(i),children:"Remove Repo Link"}),(0,n.jsxs)(ev.z,{size:"M",theme:"primary",type:"button",disabled:!t_(i)||i===o,loading:h,onClick:()=>p(i),children:[(0,tg.HH)(o)?"Update":"Add"," Repo Link"]})]})]})}(0,C.Z)(tw());var tk=r(53439),tD=r.n(tk);function tS(e){let{repoLink:t}=e;return(0,a.useEffect)(()=>(W.Z.trackEvent("View Dashboard Repo Modal Opened"),()=>{W.Z.trackEvent("View Dashboard Repo Modal Closed")}),[]),(0,n.jsxs)("div",{className:ef().body,children:[(0,n.jsx)("div",{className:ef().header,children:(0,n.jsxs)("div",{className:ef().titleRow,children:[(0,n.jsx)("h2",{children:"Contribute or report a bug"}),(0,n.jsx)(M.h,{size:"XS",theme:"ghost",onClick:e.close,children:(0,n.jsx)(ew.IconCross,{})})]})}),(0,n.jsxs)("div",{className:tD().modalContent,children:[(0,n.jsx)("p",{children:"Go to the dashboard GitHub repo to:"}),(0,n.jsxs)("ul",{children:[(0,n.jsx)("li",{children:"\uD83D\uDC1B Report issues and bugs"}),(0,n.jsx)("li",{children:"\uD83D\uDCCA Suggest edits to queries and charts"}),(0,n.jsx)("li",{children:"\uD83D\uDE4B♀️ Ask questions about the dashboard or data"})]})]}),(0,n.jsxs)("div",{className:ef().buttons,children:[(0,n.jsx)(ev.z,{size:"M",theme:"tertiary",type:"button",onClick:e.close,children:"Close"}),(0,n.jsxs)(eK.A,{size:"M",theme:"primary",href:t,target:"_blank",rel:"noreferrer",onOpen:()=>{W.Z.trackEvent("View Dashboard Repo Modal Repo Link Clicked",{repoUrl:t})},children:["View on GitHub",(0,n.jsx)(tm.rFR,{})]})]})]})}function tz(e){let t=(0,D.kP)(),r=(0,ey.l9)(e.dashboard.owner),a=tj(e.dashboard);return r&&t?(0,n.jsx)(ex.u_,{size:"M",label:"Github",content:r=>{let{close:a}=r;return(0,n.jsx)(tC,{session:t,dashboard:e.dashboard,close:()=>{a(),e.refresh()}})},trigger:e=>{let{isOpen:t,onClick:r}=e;return(0,n.jsx)(E.u,{position:"below-center",label:"Set up a GitHub repo for your dashboard",children:(0,n.jsx)(M.h,{size:"M",theme:"tertiary",className:t?"active":void 0,onClick:r,children:(0,n.jsx)(tm.rFR,{})})})}}):(0,tg.HH)(a)?(0,n.jsx)(ex.u_,{size:"M",label:"Github",content:e=>{let{close:t}=e;return(0,n.jsx)(tS,{repoLink:a,close:t})},trigger:e=>{let{isOpen:t,onClick:r}=e;return(0,n.jsx)(E.u,{position:"below-center",label:"Contribute or report a bug",children:(0,n.jsx)(M.h,{size:"M",theme:"tertiary",className:t?"active":void 0,onClick:r,children:(0,n.jsx)(tm.rFR,{})})})}}):(0,n.jsx)(E.u,{position:"below-center",label:"A repo has not been set up for this dashboard yet",children:(0,n.jsx)(M.h,{size:"M",theme:"tertiary",disabled:!0,children:(0,n.jsx)(tm.rFR,{})})})}var tR=r(18099),tM=r(69501),tI=r(25657),tE=r(49996),tO=r(78444),tP=r(12637),tN=r(81745),tT=r.n(tN);function tq(){let e=(0,m._)(["\n query RelatedDashboards($dashboardId: Int!) {\n dashboard(id: $dashboardId) {\n id\n similarDashboards {\n __typename\n ...FDashboard\n }\n }\n }\n"]);return tq=function(){return e},e}(0,C.Z)(tq());var tA=r(39736);function tL(e){let{dashboard:t}=e,{relatedDashboards:r}=function(e){var t;let r=(0,D.kP)(),{data:n}=(0,k.hbo)({context:{session:r},variables:{dashboardId:e}}),a=(null==n?void 0:null===(t=n.dashboard)||void 0===t?void 0:t.similarDashboards)||[];return{relatedDashboards:a}}(t.id);return 0===r.length?null:(0,n.jsxs)("div",{className:tT().relatedDashboards,children:[(0,n.jsx)("div",{className:tT().title,children:(0,n.jsx)("h2",{children:"Users also view"})}),(0,n.jsx)(tA.A,{items:r,trackResultClick:(e,r)=>{W.Z.trackEvent("Related Dashboard Clicked",{source_dashboard_id:t.id,source_dashboard_name:t.name,source_dashboard_slug:t.slug,related_dashboard_id:e.id,related_dashboard_name:e.name,related_dashboard_slug:e.slug,related_dashboard_favorites:e.starCount,related_dashboard_is_trending:e.isTrending,result_position:r})}})]})}function tF(){let e=(0,m._)(["\n mutation UpsertDashboardWidgets($input: UpsertDashboardWidgetsInput!) {\n upsertDashboardWidgets(input: $input) {\n id\n textWidgets {\n id\n text\n options\n }\n visualizationWidgets {\n id\n options\n }\n paramWidgets {\n id\n options\n }\n }\n }\n\n"]);return tF=function(){return e},e}let t$=async e=>{var t,r,n;let{dashboard:a,session:o}=e,i=null!==(t=a.text_widgets)&&void 0!==t?t:[],d=null!==(r=a.visualization_widgets)&&void 0!==r?r:[],l=null!==(n=a.param_widgets)&&void 0!==n?n:[];if(!a.name)throw Error("missing dashboard name");let c=await s.bj.mutate({mutation:k.iF3,context:{session:o},variables:{input:{dashboardId:a.id,textWidgets:i.map(e=>({id:e.id,text:e.text,options:e.options})),paramWidgets:l.map(e=>({id:e.id,key:e.key,visualizationWidgetId:e.visualization_widget_id,queryId:e.query_id,options:e.options})),visualizationWidgets:d.map(e=>({id:e.id,visualizationId:e.visualization.id,options:e.options}))}},fetchPolicy:"network-only"});if(!(0,O.n)(c.data))throw Error("Failed to upsert dashboard widgets")};(0,C.Z)(tF());let tZ=e=>{var t;(0,tM.D)("Dashboard Page Max Memory Used",{dashboard_slug:e.urlParams.dashboard});let r=(0,eL.tZ)(e.urlParams.user,e.urlParams.dashboard,e.urlParams.apiKey),s=(0,ep.C_)(e.urlParams.user,e.urlParams.dashboard,e.urlParams.apiKey),{captureEvent:o}=(0,eA.z$)(),i=a.useCallback(async()=>{await r.mutate()},[r.mutate]);if(a.useEffect(()=>{var e;(null===(e=r.data)||void 0===e?void 0:e.id)&&(o("Dashboard Viewed",{dashboardId:r.data.id}),W.Z.trackEvent("Dashboard Viewed",{dashboard_id:r.data.id,slug:r.data.slug,is_private:r.data.is_private,...(0,tR.k)(r.data.owner)}),(0,tI.u)({event:"DASHBOARD_VIEW",properties:{id:r.data.id,..."team"===r.data.owner.type?{teamId:r.data.owner.id,userId:null}:{userId:r.data.owner.id,teamId:null}}}))},[null===(t=r.data)||void 0===t?void 0:t.id]),r.error instanceof er.d)return(0,n.jsx)(en.NotFoundPage,{});if(r.error)throw r.error;return r.data?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(es.yG,{title:r.data.name,preview:e.preview,screenshot:s,canonical:(0,ep.C_)(r.data.owner.handle,r.data.slug),isFrame:!0}),(0,n.jsx)(ee.h,{}),(0,n.jsxs)("main",{className:h().main,children:[(0,n.jsx)(tU,{dashboard:r.data,refresh:i,apiKey:e.urlParams.apiKey}),(0,n.jsx)(eM.L,{size:"lg"})]},r.data.slug)]}):(0,n.jsx)(et.h,{title:e.title,screenshot:s})},tU=e=>{let{session:t}=a.useContext(D.B3),[r,s]=a.useState(!1),[o,i]=a.useState(!1),l=(0,eb.c)(),c=(0,d.vQ)(e.dashboard),u=a.useCallback(e=>{t&&t$({dashboard:e,session:t}).catch(l)},[t]),h=a.useCallback(()=>{c.state.onApply()},[c.state]);return a.useEffect(()=>{(()=>{let e=window.location.hash;if(""!==e){let t=document.querySelector(e);null==t||t.scrollIntoView()}})()},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ea.T,{children:(0,n.jsxs)(Y.r,{children:[(0,n.jsx)(tB,{dashboard:e.dashboard,edit:r,setEdit:s,refresh:e.refresh,parameters:c,apiKey:e.apiKey,isRunModalOpen:o,setIsRunModalOpen:i}),(0,n.jsx)(eO.n,{dashboard:e.dashboard,refresh:e.refresh,apiKey:e.apiKey,parameters:c,onLayout:u,onApplyParam:h,openRunModal:()=>i(!0),edit:r,disabledParameters:void 0===t})]})}),!r&&(0,n.jsx)(ea.T,{size:"md",children:(0,n.jsx)(tL,{dashboard:e.dashboard})},e.dashboard.slug)]})},tB=e=>{var t;let r=(0,ey.l9)(e.dashboard.owner),a=tb(e.dashboard.id,r),i=null!==(t=e.dashboard.tags)&&void 0!==t?t:[],u=(0,tE.Y)(),p="V2"===u?e=>(function(e){let{session:t,activeContext:r,queryIds:n,parameters:a,performance:i,apiKey:c,executionService:u}=e;n.forEach(e=>{let n=(0,d.ZX)(e,a),h=n.every(l.in),p=(0,o.q)({queryId:e,parameters:n,can_refresh:h,apiKey:c,session:t});(0,tO.o)({executionService:u,queryId:e,parameters:p.variables.parameters,requestContext:p.context,activeContext:r,executionType:h?"interactive":"viz_custom_params_refresh",performance:i}).then(()=>{s.bj.query({query:p.queryDoc,variables:p.variables,context:p.context,fetchPolicy:"network-only"})}).catch(()=>{})})})({...e,executionService:tP.T}):c,m=!e.edit&&(0,n.jsx)(b.v,{entry:e.dashboard}),f=e.dashboard.is_archived?!e.edit&&(0,n.jsx)(E.u,{position:"below-center",label:"Archived dashboards cannot be shared",children:(0,n.jsx)(ev.z,{size:"M",theme:"tertiary",disabled:!0,children:"Share"})}):!e.edit&&(0,n.jsx)(ek,{label:"Share",dashboard:e.dashboard,owner:e.dashboard.owner}),x=!e.edit&&r&&(0,n.jsx)(N,{dashboard:e.dashboard}),v=!e.edit&&r&&(0,n.jsx)(tl,{dashboard:e.dashboard}),y=!e.edit&&(0,n.jsx)(e4,{dashboard:e.dashboard,parameters:e.parameters,apiKey:e.apiKey,isRunModalOpen:e.isRunModalOpen,setIsRunModalOpen:e.setIsRunModalOpen,executeQueries:p});return(0,n.jsx)(eo.B,{resourceType:"dashboard",owner:e.dashboard.owner,title:e.dashboard.name,private:e.dashboard.is_private,isArchived:e.dashboard.is_archived,tags:(0,n.jsx)(eI.$,{slug:"dashboards",tags:i}),isTrending:e.dashboard.isTrending,caption:(0,th.N)({dashboard:e.dashboard}),folder:a&&{contentItem:{type:"dashboard",id:e.dashboard.id},result:a.folder,refetchFolder:a.refetch},children:(0,n.jsxs)("div",{className:h().subHeaderToolbar,children:[m,(0,n.jsx)(tz,{dashboard:e.dashboard,refresh:e.refresh}),x,(0,n.jsx)(J,{ownerId:e.dashboard.owner.id,dashboardId:e.dashboard.id}),f,(0,n.jsx)(tH,{...e,onEditDashboardSettings:()=>{null==a||a.refetch()}}),v,y]})})},tH=e=>{let{session:t}=a.useContext(D.B3),[r,s]=a.useState(!1),o=(0,eb.c)(),i=(0,ey.l9)(e.dashboard.owner),d=async()=>{try{s(!0),await e.refresh(),e.setEdit(!1),s(!1),t&&e.parameters.state.defaults.length>0&&await (0,eN.TB)(e.dashboard,t)}catch(e){o(e)}};return t&&i?e.edit?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.k,{refresh:e.refresh,dashboard:e.dashboard,onEditDashboardSettings:e.onEditDashboardSettings}),(0,n.jsx)(eT,{dashboard:e.dashboard,refresh:e.refresh}),(0,n.jsx)(eE.k,{item:e.dashboard,refresh:e.refresh}),(0,n.jsx)(ev.z,{onClick:d,loading:r,size:"M",theme:"primary",children:"Done"})]}):(0,n.jsx)(ev.z,{theme:"tertiary",size:"M",onClick:()=>{e.setEdit(e=>!e)},children:"Edit"}):null}},59896:function(e,t,r){"use strict";r.d(t,{a:function(){return c},k:function(){return u}});var n=r(85893),a=r(24745),s=r(83402),o=r.n(s),i=r(1801),d=r(26089),l=r(47730);function c(e){return(0,n.jsx)("td",{className:o().statCell,children:(0,n.jsx)(u,{...e})})}function u(e){let{icon:t,count:r,trending:s}=e;return(0,n.jsxs)("div",{className:o().statAndTrending,children:[!0===s&&(0,n.jsx)("div",{className:o().trending,children:(0,n.jsx)(l.u,{position:"above-center",label:"Trending",children:(0,n.jsx)("div",{children:(0,n.jsx)(i.C,{size:"L",variant:"filled",color:"brand-orange",iconOnly:!0,children:(0,n.jsx)(d.IconChartLineUp,{})})})})}),(0,n.jsxs)("div",{className:o().stat,children:[(0,a.u)(r),t]})]})}},76896:function(e,t,r){"use strict";r.d(t,{i:function(){return o}});var n=r(85893),a=r(83402),s=r.n(a);function o(e){let{children:t}=e;return(0,n.jsx)("table",{className:s().table,children:(0,n.jsx)("tbody",{children:t})})}},26089:function(e,t,r){"use strict";r.r(t),r.d(t,{IconChartLineUp:function(){return a}});var n=r(85893);function a(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,n.jsx)("path",{d:"M14 13H2V3",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M13 4L8 9L6 7L2 11",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M13 6.5V4H10.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})}},73181:function(e,t,r){"use strict";r.r(t),r.d(t,{IconGitFork:function(){return a}});var n=r(85893);function a(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,n.jsx)("path",{d:"M8 13.5C8.9665 13.5 9.75 12.7165 9.75 11.75C9.75 10.7835 8.9665 10 8 10C7.0335 10 6.25 10.7835 6.25 11.75C6.25 12.7165 7.0335 13.5 8 13.5Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M11.75 6C12.7165 6 13.5 5.2165 13.5 4.25C13.5 3.2835 12.7165 2.5 11.75 2.5C10.7835 2.5 10 3.2835 10 4.25C10 5.2165 10.7835 6 11.75 6Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M4.25 6C5.2165 6 6 5.2165 6 4.25C6 3.2835 5.2165 2.5 4.25 2.5C3.2835 2.5 2.5 3.2835 2.5 4.25C2.5 5.2165 3.2835 6 4.25 6Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M4.25001 6V6.5C4.24919 6.69721 4.28742 6.89264 4.36251 7.075C4.4376 7.25736 4.54806 7.42305 4.68751 7.5625C4.82696 7.70196 4.99265 7.81241 5.17501 7.8875C5.35737 7.96259 5.5528 8.00083 5.75001 8H10.25C10.4472 8.00083 10.6427 7.96259 10.825 7.8875C11.0074 7.81241 11.1731 7.70196 11.3125 7.5625C11.452 7.42305 11.5624 7.25736 11.6375 7.075C11.7126 6.89264 11.7508 6.69721 11.75 6.5V6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M8 8V10",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})}},94442:function(e,t,r){"use strict";r.r(t),r.d(t,{__N_SSP:function(){return l},default:function(){return c}});var n=r(82729),a=r(85893),s=r(22577),o=r(11163),i=r(39137);function d(){let e=(0,n._)(["\n query FindDashboardNameWithRedirect($redirect_from: String!) {\n dashboards(filters: { redirectFrom: { equals: $redirect_from }}, pagination: { first: 1 }) {\n edges {\n node {\n id\n slug\n user {\n id\n name\n }\n team {\n id\n handle\n }\n }\n }\n }\n }\n"]);return d=function(){return e},e}var l=!0;function c(e){let{slug:t,dashboard:r}=(0,o.useRouter)().query;return(0,a.jsx)(s.Y,{...e,urlParams:{user:t,dashboard:r,apiKey:void 0}})}(0,i.Z)(d())},21708:function(e){e.exports={content:"EditGithubLinkModalContent_content__l9PTb",curlBlock:"EditGithubLinkModalContent_curlBlock__EZmek",error:"EditGithubLinkModalContent_error__5DmGc"}},53439:function(e){e.exports={modalContent:"ViewGithubLinkModalContent_modalContent__31_6h"}},89132:function(e){e.exports={content:"ParameterApplyModalContent_content__QHMfY"}},23101:function(e){e.exports={dialog:"RefreshDashboard_dialog__aXokH",medium:"RefreshDashboard_medium__lzBJT",buttons:"RefreshDashboard_buttons__pgTRm",refreshButtonGroup:"RefreshDashboard_refreshButtonGroup__j_bTl"}},81745:function(e){e.exports={relatedDashboards:"RelatedDashboards_relatedDashboards__e36zv",title:"RelatedDashboards_title__u80vx"}},41655:function(e){e.exports={buttonGroup:"ScreenshotDashboardButton_buttonGroup__86kSA"}},83402:function(e){e.exports={table:"styles_table__ro9iA",contentDetails:"styles_contentDetails___Vw__",mainCell:"styles_mainCell__vnAZ6",avatarCell:"styles_avatarCell__zxjXO",nameAndTags:"styles_nameAndTags__8CSWt",titleRow:"styles_titleRow__Svu3m",title:"styles_title__54Ftn",tags:"styles_tags__fQrYX",ownerAndDetails:"styles_ownerAndDetails__JBuUw",statsAndTrending:"styles_statsAndTrending__DEZJS",stat:"styles_stat__ztfBX",topicContent:"styles_topicContent__6GWMo",creator:"styles_creator__vj8e3",statsSet:"styles_statsSet__7_dO2",creatorRow:"styles_creatorRow__87eTV",topicText:"styles_topicText__HMnRY",statAndTrending:"styles_statAndTrending__LTIb1",trending:"styles_trending__pbZNh",statCell:"styles_statCell__vdcPM",topicButton:"styles_topicButton__WgLeR"}},74300:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.CopyToClipboard=void 0;var a=i(r(67294)),s=i(r(20640)),o=["text","onCopy","options","children"];function i(e){return e&&e.__esModule?e:{default:e}}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach(function(t){b(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(m,e);var t,r,i,d=(t=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=p(m);if(t){var a=p(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return function(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return h(e)}(this,e)});function m(){var e;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,m);for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return b(h(e=d.call.apply(d,[this].concat(r))),"onClick",function(t){var r=e.props,n=r.text,o=r.onCopy,i=r.children,d=r.options,l=a.default.Children.only(i),c=(0,s.default)(n,d);o&&o(n,c),l&&l.props&&"function"==typeof l.props.onClick&&l.props.onClick(t)}),e}return r=[{key:"render",value:function(){var e=this.props,t=(e.text,e.onCopy,e.options,e.children),r=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(e,o),n=a.default.Children.only(t);return a.default.cloneElement(n,l(l({},r),{},{onClick:this.onClick}))}}],c(m.prototype,r),i&&c(m,i),Object.defineProperty(m,"prototype",{writable:!1}),m}(a.default.PureComponent);t.CopyToClipboard=m,b(m,"defaultProps",{onCopy:void 0,options:void 0})},74855:function(e,t,r){"use strict";var n=r(74300).CopyToClipboard;n.CopyToClipboard=n,e.exports=n},11742:function(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,r=[],n=0;n<e.rangeCount;n++)r.push(e.getRangeAt(n));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||r.forEach(function(t){e.addRange(t)}),t&&t.focus()}}}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[9225,3318,8110,3295,777,6746,3829,1403,4094,2307,9512,9612,1444,9002,9938,9694,4974,819,1434,6532,184,4941,9736,2547,2882,7889,9774,2888,179],function(){return t(73611),t(80158)}),_N_E=e.O()}]);
//# sourceMappingURL=[dashboard]-b3156cbcc4c20fe8.js.map