PageSourceSearch

https://app.currents.dev/assets/router-T-E0nb-o.js

js currents.dev collected 2026-09-25 20:49:18 UTC 127,024 bytes, 6 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/hookFilterTester-BVx1KuAL.js","assets/index-BFa3nKuT.js","assets/framerMotion-KnKeNhwd.js","assets/datepicker-CN3oO0F6.js","assets/charts-BEfaN6Tb.js","assets/visx-o561FtCw.js","assets/apollo-B9xYJgZj.js","assets/shiki-DSW_v8w1.js","assets/betterAuth-wecmey9t.js","assets/tanstack-82Oensom.js","assets/virtuoso-_8EeKo1c.js","assets/sentry-BM1d0HPc.js","assets/forms-BE_8TKCw.js","assets/amplitude-rTYtQKJT.js","assets/amplify-FijOe782.js","assets/qrcode-CMNUHY9J.js","assets/dnd-BjCurfON.js","assets/index-Bs_qMT-G.css"])))=>i.map(i=>d[i]);
2var wn=Object.defineProperty;var Tn=(e,n,r)=>n in e?wn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var Lt=(e,n,r)=>Tn(e,typeof n!="symbol"?n+"":n,r);import{gR as En,gS as Nn,bD as X,gT as Bt,gU as He,eh as L,a5 as W,gV as _n,a as t,j as s,ae as T,gW as et,W as R,ag as V,gX as Rn,U as D,cM as tt,a2 as P,ew as he,gY as z,gZ as Ln,a4 as x,g_ as On,Y as pe,g$ as Pn,h0 as Vn,ad as k,h1 as Dn,e3 as U,h2 as Hn,b0 as $,h3 as Mn,ah as Ft,aA as nt,$ as ae,h4 as rt,h5 as it,aK as O,h6 as Un,ez as Me,h7 as Ue,h8 as Y,h9 as Le,ha as Ne,an as Ke,m as $t,fk as jn,hb as Q,eF as Gn,hc as Bn,hd as Fn,bY as ve,he as $n,hf as zn,hg as Kn,hh as qn,hi as Xn,hj as Wn,hk as Jn,hl as Yn,hm as Zn,hn as Qn,ho as er,aW as tr,e9 as nr,hp as rr,hq as ir,b as zt,u as ar,hr as sr,F as at,hs as lr,ht as or,hu as cr,t as Kt,hv as dr,hw as ur,hx as hr,B as st,cj as qe,hy as pr,au as q,hz as Oe,hA as mr,hB as gr,hC as qt,e6 as fr,eT as br,ek as Se,hD as lt,em as ke,hE as xe,al as yr,cN as vr,hF as C,hG as Cr,hH as Xe,hI as Ir,hJ as Sr,ev as K,hK as kr,hL as Pe,eK as _e,hM as xr,hN as Ar,hO as wr,hP as Xt,dL as Wt,hQ as Tr,hR as Er,hS as Nr,hT as _r,b4 as ot,b6 as ct,b3 as dt,hU as Rr,hV as se,hW as Lr,hX as Or,ca as je,dV as me,dX as ut,hY as ht,aT as Ot,eD as Jt,hZ as Ve,h_ as pt,h$ as Pr,d_ as Ie,i0 as ge,i1 as fe,i2 as be,i3 as B,i4 as ye,i5 as Pt,i6 as mt,af as ee,i7 as gt,aG as Vr,I as Dr,cS as Vt,b8 as Hr,i8 as Mr,ft as Ur,i9 as jr,ia as Gr,ib as Br,ic as Fr,id as $r,ie as zr,ig as Kr,ih as qr,gB as Xr,ii as Wr,ij as Jr,eE as Yt,eo as De,cz as Yr,ik as Zr,T as Qr,il as ei,im as ti,io as ni,ip as ri,iq as ii,ir as ai,is as si,it as li,iu as oi,iv as ci,iw as di,ix as ui,iy as hi,iz as pi,z as ft}from"./index-BFa3nKuT.js";import{a as g,R as ne,f as mi,p as gi}from"./datepicker-CN3oO0F6.js";import"./visx-o561FtCw.js";import{u as J,C as w,a as oe,F as re,b as fi,c as Re}from"./forms-BE_8TKCw.js";import{L as Ae,J as bi}from"./jiraInstallation-D7CPfH8Z.js";import{u as bt}from"./useUnsavedChangesGuard-BDBmEdK7.js";import{u as yi,S as vi}from"./slackChannelSelection-DVj7-SPz.js";import{S as Ci,N as Ii}from"./badge-DVOh7qPn.js";import{A as Si,c as ki,a as xi,b as Ai}from"./accordion-SF-PpDjf.js";import"./framerMotion-KnKeNhwd.js";import"./charts-BEfaN6Tb.js";import"./apollo-B9xYJgZj.js";import"./shiki-DSW_v8w1.js";import"./betterAuth-wecmey9t.js";import"./tanstack-82Oensom.js";import"./virtuoso-_8EeKo1c.js";import"./sentry-BM1d0HPc.js";import"./amplitude-rTYtQKJT.js";import"./amplify-FijOe782.js";import"./qrcode-CMNUHY9J.js";import"./dnd-BjCurfON.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"01e610d75577dcaf5e5c9af84e79c9458f58a767"},e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=(function(r){for(var i=1;i<arguments.length;i++){var a=arguments[i];if(a!=null)for(var l in a)a.hasOwnProperty(l)&&(r[l]=a[l])}return r})({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:currents-dashboard":!0});var n=new e.Error().stack;
2n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="de9af760-35f2-4ff5-8687-de07c65aa3f9",e._sentryDebugIdIdentifier="sentry-dbid-de9af760-35f2-4ff5-8687-de07c65aa3f9")}catch{}})();const wi=(e,n)=>{const r="bitbucket.org",i="api.bitbucket.org",[a,l]=e.split("://"),[o,d,u]=l.split("/"),h=u.replace(".git",""),p=o===r?i:`${o}`;return`${a}://${p}/2.0/repositories/${d}/${h}/commit/${n}/statuses/build`},Ti=(e,n)=>{const r="github.com",i="api.github.com",[a,l]=e.split("://"),[o,d,u]=l.split("/"),h=o===r?i:`${o}/api/v3`;return`${a}://${h}/repos/${d}/${u}/statuses/${n}`};function Ei(e){return e.hookType==="GENERIC_HOOK"}function Ni(e){return e.hookType==="SLACK_HOOK"}function _i(e){return e.hookType==="GITHUB_STATUS_HOOK"}function Ri(e){return e.hookType==="BITBUCKET_STATUS_HOOK"}function Li(e){return e.hookType==="MSTEAMS_STATUS_HOOK"}const Oi=500,Dt=e=>{if(e.length>Oi)return!1;try{new RegExp(e)}catch{return!1}return En(e)},Z={exists:{label:"exists",description:"Field exists (not null nor undefined)",rightValueInputType:"none",defaultValue:void 0},doesNotExist:{label:"is missing",description:"Field is null or undefined",rightValueInputType:"none",defaultValue:void 0},isTrue:{label:"is true",description:"Field is true",rightValueInputType:"none",defaultValue:void 0},isFalse:{label:"is false",description:"Field is false",rightValueInputType:"none",defaultValue:void 0},eq:{label:"eq",description:"Exact match",rightValueInputType:"string",defaultValue:void 0},ne:{label:"ne",description:"Not equal to value",rightValueInputType:"string",defaultValue:void 0},in:{label:"is in",description:"Value is one of the items in the array",rightValueInputType:"stringArray",defaultValue:[]},notIn:{label:"is not in",description:"Value is not in the array",rightValueInputType:"stringArray",defaultValue:[]},matches:{label:"matches",description:"Matches regular expression pattern",rightValueInputType:"regexString",defaultValue:void 0},doesNotMatch:{label:"does not match",description:"Does not match regular expression pattern",rightValueInputType:"regexString",defaultValue:void 0},matchesAny:{label:"matches any",description:"Matches any of the regular expression patterns",rightValueInputType:"regexStringArray",defaultValue:[]},doesNotMatchAll:{label:"does not match all",description:"Does not match all of the regular expression patterns",rightValueInputType:"regexStringArray",defaultValue:[]},gt:{label:">",description:"Value is greater than",rightValueInputType:"number",defaultValue:void 0},gte:{label:">=",description:"Value is greater than or equal to",rightValueInputType:"number",defaultValue:void 0},lt:{label:"<",description:"Value is less than",rightValueInputType:"number",defaultValue:void 0},lte:{label:"<=",description:"Value is less than or equal to",rightValueInputType:"number",defaultValue:void 0},numberInRange:{label:"in range",description:"Value is within the range [min, max]",rightValueInputType:"numberRange",defaultValue:{min:void 0,max:void 0}},dateInRange:{label:"in range",description:"Value is within the range [min, max]",rightValueInputType:"dateRange",defaultValue:{min:void 0,max:void 0}},dateEq:{label:"eq",description:"Value is the date",rightValueInputType:"date",defaultValue:void 0},dateGt:{label:"after",description:"Value is after the date",rightValueInputType:"date",defaultValue:void 0},dateLt:{label:"before",description:"Value is before the date",rightValueInputType:"date",defaultValue:void 0},includesAll:{label:"includes all",description:"Array includes all items in the list",rightValueInputType:"stringArray",defaultValue:[]},includesSome:{label:"includes any",description:"Array includes at least one item in the list",rightValueInputType:"stringArray",defaultValue:[]},missingAll:{label:"missing all",description:"All items from the input list are missing from the array",rightValueInputType:"stringArray",defaultValue:[]},missingAny:{label:"missing any",description:"An input list item is missing from the array",rightValueInputType:"stringArray",defaultValue:[]},arrayMatchesAny:{label:"matches any",description:"An item in the list matches any regular expression pattern",rightValueInputType:"regexStringArray",defaultValue:[]},lengthEq:{label:".length ===",description:"Array length equals the value",rightValueInputType:"number",defaultValue:void 0}
2,lengthNe:{label:".length !==",description:"Array length does not equal the value",rightValueInputType:"number",defaultValue:void 0},lengthGt:{label:".length >",description:"Array length is greater than",rightValueInputType:"number",defaultValue:void 0},lengthGte:{label:".length >=",description:"Array length is greater than or equal to",rightValueInputType:"number",defaultValue:void 0},lengthLt:{label:".length <",description:"Array length is less than",rightValueInputType:"number",defaultValue:void 0},lengthLte:{label:".length <=",description:"Array length is less than or equal to",rightValueInputType:"number",defaultValue:void 0}},A=(e,n)=>({valid:!1,error:e,details:n}),Ht=e=>{try{return new RegExp(e),"Pattern may cause ReDoS vulnerability"}catch(n){return n instanceof Error?n.message:String(n)}},yt={none:{label:"None",description:"No input required",type:"none",serialize:()=>"",deserialize:()=>{},validate:()=>!0},string:{label:"String",description:"Single string value",type:"string",serialize:e=>e==null?"":typeof e=="string"?e:String(e),deserialize:e=>{if(!(!e||e.trim()===""))return e},validate:e=>e==null?A("Value is required"):typeof e!="string"?A("Invalid type",`Expected string, got ${typeof e}`):e.trim()===""?A("Value cannot be empty"):!0},number:{label:"Number",description:"Single number value",type:"number",modifiers:{allowDecimals:{label:"Allow Decimals",description:"Allow decimal numbers",defaultValue:!0}},serialize:e=>e==null?"":String(e),deserialize:e=>{if(!e||e.trim()==="")return;const n=Number(e);return isNaN(n)?void 0:n},validate:e=>{if(e==null)return A("Value is required");if(typeof e!="number"&&typeof e!="string")return A("Invalid type",`Expected number, got ${typeof e}`);const n=Number(e);return isNaN(n)?A("Invalid number",`"${e}" is not a number`):isFinite(n)?!0:A("Invalid number","Value must be finite")}},numberRange:{label:"Number Range",description:"Number range (min, max)",type:"numberRange",serialize:e=>e==null?"":JSON.stringify(e),deserialize:e=>!e||e.trim()===""?{min:void 0,max:void 0}:JSON.parse(e),validate:e=>{if(e==null)return A("Range is required");if(typeof e!="object"||Array.isArray(e))return A("Invalid type","Expected object with min/max properties");const n=e;if(n.min===void 0&&n.max===void 0)return A("Invalid range","At least one of min or max is required");if(n.min!==void 0){const r=Number(n.min);if(isNaN(r))return A("Invalid min value",`"${n.min}" is not a valid number`)}if(n.max!==void 0){const r=Number(n.max);if(isNaN(r))return A("Invalid max value",`"${n.max}" is not a valid number`)}if(n.min!==void 0&&n.max!==void 0){const r=Number(n.min),i=Number(n.max);if(r>i)return A("Invalid range",`Min (${r}) cannot be greater than max (${i})`)}return!0}},stringArray:{label:"String Array",description:"Multiple string values",type:"stringArray",serialize:e=>e==null?"":Array.isArray(e)?e.length===0?"":JSON.stringify(e.map(String)):JSON.stringify([String(e)]),deserialize:e=>{if(!e||e.trim()==="")return[];try{const n=JSON.parse(e);return Array.isArray(n)?n.map(String):[String(n)]}catch{return e.split(",").map(n=>n.trim()).filter(Boolean)}},validate:e=>{if(e==null)return A("Value is required");if(!Array.isArray(e))return A("Invalid type",`Expected array, got ${typeof e}`);if(e.length===0)return A("Array cannot be empty");for(let n=0;n<e.length;n++)if(typeof e[n]!="string")return A("Invalid item type",`Item at index ${n} is not a string`);return!0}},numberArray:{label:"Number Array",description:"Multiple number values",type:"numberArray",serialize:e=>e==null?"":Array.isArray(e)?e.length===0?"":e.map(String).join(","):String(e),deserialize:e=>{if(!e||e.trim()==="")return[];const n=e.split(",").map(r=>Number(r.trim())).filter(r=>!isNaN(r));return n.length>0?n:[]},validate:e=>{if(e==null)return A("Value is required");if(!Array.isArray(e))return A("Invalid type",`Expected array, got ${typeof e}`);if(e.length===0)return A("Array cannot be empty");for(let n=0;n<e.length;n++){const r=Number(e[n]);if(isNaN(r))return A("Invalid item",`Item at index ${n} ("${e[n]}") is not a valid number`)}return!0}},regexString:{label:"Regex String",description:"Single regular expression pattern",type:"regexString",modifiers:{caseSensitive:{label:"Case Sensitive",description:"Match case exactly",defaultValue:!0}},serialize:e=>e==null?"":typeof e=="string"?e:String(e),deserialize:e=>e||"",validate:e=>e==null||e===""?A("Regex pattern is required"):typeof e!="string"?A("Invalid type",`Expected string, got ${typeof e}`):Dt(e)?!0:A("Invalid regex pattern",Ht(e))}
2,regexStringArray:{label:"Regex String Array",description:"Multiple regular expression patterns",type:"regexStringArray",modifiers:{caseSensitive:{label:"Case Sensitive",description:"Match case exactly",defaultValue:!0}},serialize:e=>e==null?"":Array.isArray(e)?e.length===0?"":JSON.stringify(e.map(String)):JSON.stringify([String(e)]),deserialize:e=>{if(!e||e.trim()==="")return[];try{const n=JSON.parse(e);return Array.isArray(n)?n.map(String):[String(n)]}catch{return e.split(",").map(n=>n.trim()).filter(Boolean)}},validate:e=>{if(e==null)return A("Regex patterns are required");if(!Array.isArray(e))return A("Invalid type",`Expected array, got ${typeof e}`);if(e.length===0)return A("At least one regex pattern is required");for(let n=0;n<e.length;n++){const r=e[n];if(typeof r!="string")return A("Invalid item type",`Item at index ${n} is not a string`);if(!Dt(r))return A(`Invalid regex pattern at index ${n}`,Ht(r))}return!0}},date:{label:"Date",description:"Date value",type:"date",serialize:e=>e==null?"":String(e),deserialize:e=>e||"",validate:e=>{if(e==null||e==="")return A("Date is required");if(typeof e!="string")return A("Invalid type",`Expected string, got ${typeof e}`);const n=new Date(e);return isNaN(n.getTime())?A("Invalid date",`"${e}" is not a valid date`):!0}},dateRange:{label:"Date Range",description:"Date range (min, max)",type:"dateRange",modifiers:{inclusive:{label:"Inclusive",description:"Include boundary dates in the range",defaultValue:!0}},serialize:e=>{if(e==null)return"";if(typeof e=="object"&&"min"in e&&"max"in e){const n=e,r=[];return n.min&&r.push(`min:${n.min}`),n.max&&r.push(`max:${n.max}`),r.join("|")}return String(e)},deserialize:e=>{if(!e||e.trim()==="")return;const n=e.split("|"),r={};for(const i of n){const a=i.trim();a.startsWith("min:")?r.min=a.substring(4).trim():a.startsWith("max:")&&(r.max=a.substring(4).trim())}return Object.keys(r).length>0?r:void 0},validate:e=>{if(e==null)return A("Date range is required");if(typeof e!="object"||Array.isArray(e))return A("Invalid type","Expected object with min/max properties");const n=e;if(n.min===void 0&&n.max===void 0)return A("Invalid range","At least one of min or max date is required");if(n.min!==void 0){const r=new Date(n.min);if(isNaN(r.getTime()))return A("Invalid min date",`"${n.min}" is not a valid date`)}if(n.max!==void 0){const r=new Date(n.max);if(isNaN(r.getTime()))return A("Invalid max date",`"${n.max}" is not a valid date`)}if(n.min!==void 0&&n.max!==void 0){const r=new Date(n.min),i=new Date(n.max);if(r>i)return A("Invalid range",`Min date (${n.min}) cannot be after max date (${n.max})`)}return!0}},boolean:{label:"Boolean",description:"Boolean value",type:"boolean",serialize:e=>e==null?"":typeof e=="boolean"?e?"true":"false":String(e),deserialize:e=>{if(!e||e.trim()==="")return!1;const n=e.toLowerCase().trim();return n==="true"||n==="1"},validate:e=>e==null?A("Value is required"):typeof e!="boolean"?A("Invalid type",`Expected boolean, got ${typeof e}`):!0}};function Pi(e){const n=[],r=Z[e.operator];if(!r)return n.push({field:"operator",error:"Unknown operator",details:`Operator "${e.operator}" is not recognized`}),{valid:!1,errors:n};const i=r.rightValueInputType;e.right.type!==i&&n.push({field:"rightValueType",error:"Type mismatch",details:`Operator "${e.operator}" expects right value type "${i}", got "${e.right.type}"`});const a=yt[e.right.type];if(a){const l=a.validate(e.right.value);l!==!0&&n.push({field:"rightValue",error:l.error,details:l.details})}else n.push({field:"rightValueType",error:"Unknown right value type",details:`Right value type "${e.right.type}" is not recognized`});return{valid:n.length===0,errors:n}}const Mt={string:["exists","doesNotExist","eq","ne","in","notIn","matches","matchesAny","doesNotMatch","doesNotMatchAll"],number:["exists","doesNotExist","eq","ne","gt","gte","lt","lte","in","notIn","numberInRange"],boolean:["exists","doesNotExist","isTrue","isFalse"],date:["exists","doesNotExist","dateInRange","dateEq","dateGt","dateLt"],array:["exists","doesNotExist","includesAll","includesSome","missingAll","missingAny","arrayMatchesAny","lengthEq","lengthNe","lengthGt","lengthGte","lengthLt","lengthLte"],map:["exists","doesNotExist"]};function Vi(e){return e.includes("user:")?e.split("user:")[1].trim():e}function Di(e){if(e=e.trim(),e.includes("@")&&e.includes("."))return{entityType:"user",format:"email",value:Vi(e)};if(e.startsWith("@")&&!e.includes(":"))return{entityType:"group",format:"handle",value:e};const n=e.indexOf(":");if(n===-1)return null;const r=e.substring(0,n).toLowerCase(),i=e.substring(n+1).trim();if(r!=="user"&&r!=="group"&&r!=="team")return null;const a=r==="user"?"user":"group";return/^[US][A-Z0-9]+$/.test(i)?{entityType:a,format:"id",value:i}:a==="group"&&i.startsWith("@")?{entityType:"group",format:"handle",value:i}:i.includes("@")&&i.includes(".")?{entityType:"user",format:"email",value:i}:null}function Hi(e,n){if(!(e===void 0||e.length===0))for(const r of e){const i=Di(r);if(!i||i.entityType!==n)return r}}const Mi=e=>{const[n,{data:r,loading:i,error:a}]=Nn({fetchPolicy:"network-only"});function l({baseUrl:o,appId:d,appSecret:u}){n({variables:{input:{baseUrl:o,orgId:e,appId:d,appSecret:u}}})}return[l,{data:r,loading:i,error:a}]},Ut="https://gitlab.com",Ui=X(({org:e,isEnterpriseFeatureGated:n,callbackUrl:r})=>{var y;const{refetch:i}=Bt(),[a,l]=He(!1),o=L(e.orgId),d=W(),[u,{data:h,loading:p,error:c}]=Mi(e.orgId),{handleSubmit:S,register:f,watch:m,formState:{errors:v}}=J({mode:"onTouched",defaultValues:{baseUrl:Ut}}
2),b=m("baseUrl");return g.useEffect(()=>{if(!h)return;window.open(h.createGitlabIntegration.url,"gitlab","popup=1,width=640,height=480");const I=new BroadcastChannel("gitlab_setup");return I.onmessage=N=>{N.data==="gitlab_done"&&i()},()=>I&&I.close()},[h]),g.useEffect(()=>{c!=null&&c.message&&_n({uuid:"gitlab_create_integration_error",message:(c==null?void 0:c.message)??"Error creating Gitlab integration"})},[c]),t("form",{onSubmit:S(u),children:s(T,{flexDirection:"column",gap:d.layout.gap,children:[s(T,{justifyContent:"center",alignItems:"center",gap:d.layout.gapHalf,children:[t(et,{width:32,height:32}),t(R,{children:"Connect your GitLab organization"})]}),s(T,{flexDirection:"column",gap:d.layout.gapQuarter,children:[s(R,{small:!0,children:["1. Create a new"," ",t(V,{href:`${b||Ut}/-/profile/applications`,target:"_blank",rel:"noreferrer",icon:!0,children:"Gitlab OAuth App"}),", use the following redirect URI:"," "]}),t(Rn,{scale:D.scale.smaller,symbol:"",children:r}),s(R,{small:!0,children:["2. Select ",t(tt,{children:"api"})," scope for updating commit status and posting notes"]}),t(R,{small:!0,children:'3. Enter your app credentials and click "Connect" to continue the setup'})]}),t(P,{h:4}),t(he,{error:(y=v.baseUrl)==null?void 0:y.message,helpText:s(x,{children:["Change GitLab instance domain name for self-hosted integrations."," ",t(V,{href:"https://currents.dev/readme/integrations/gitlab",target:"_blank",icon:!0,rel:"noreferrer",children:"Read more"})]}),label:n?s(T,{gap:5,alignItems:"center",justifyContent:"space-between",children:[t("span",{children:"GitLab Instance Domain"}),t(On,{})]}):t(x,{children:"GitLab Instance Domain"}),children:t(z,{...f("baseUrl",{required:{value:!0,message:"Enter your GitLab domain"},validate:I=>Ln(I)?void 0:"Please enter a valid URL"}),width:"100%",placeholder:"Enter Gitlab base URL",readOnly:n})}),t(z,{...f("appId",{required:!0}),width:"100%",disabled:!o,placeholder:"Enter GitLab Application ID",children:t(pe,{title:"App ID"})}),t(z,{...f("appSecret",{required:!0}),width:"100%",disabled:!o,iconClickable:!0,iconRight:a?t(Pn,{}):t(Vn,{}),htmlType:a?"text":"password",onIconClick:()=>l(),placeholder:"Enter GitLab Application Secret",children:t(pe,{title:"App Secret"})}),t(T,{justifyContent:"flex-end",children:t(k,{htmlType:"submit",type:"accent",size:"large",disabled:!o,loading:p,children:"Connect"})})]})})});function ji({onDelete:e,loading:n}){const[r,i]=g.useState(!1);return s(x,{children:[r&&s(T,{children:[t(k,{type:"danger",onClick:()=>{e(),i(!1)},children:"Disconnect"}),t(P,{}),t(k,{type:"secondary",onClick:()=>i(!1),loading:n,children:"Cancel"})]}),!r&&t(k,{type:"danger",onClick:()=>i(!0),children:"Disconnect Project"})]})}function Gi(e){const{toast:n}=U();return Dn({update:(r,i)=>{var a;(a=i.data)!=null&&a.deleteGitlabProject&&r.modify({id:r.identify({__typename:"Project",projectId:e}),fields:{gitlabIntegration:()=>[]}})},onError:r=>{n.error({title:r.message})},onCompleted:()=>{n.success({title:"Disconnected Gitlab Project"})}})}function Bi(e){const{toast:n}=U();return Hn({update:(r,i)=>{var a;(a=i.data)!=null&&a.setGitlabProject&&r.modify({id:r.identify({__typename:"Project",projectId:e}),fields:{gitlabIntegration:()=>[{__ref:r.identify({__typename:"Project",projectId:e})}]}})},onError:r=>{n.error({title:r.message})},onCompleted:()=>{n.success({title:"Updated Gitlab Integration"})}})}const Fi=$(({project:e})=>{var M;const n=L(e.orgId),r=e!=null&&e.gitlabIntegration?e==null?void 0:e.gitlabIntegration[0]:null,[i,{loading:a}]=Bi(e.projectId),[l,{loading:o}]=Gi(e.projectId),{handleSubmit:d,formState:u,control:h,setValue:p,getValues:c,watch:S}=J({defaultValues:{gitlabProjectId:(r==null?void 0:r.gitlabProjectId)??"",prComment:(r==null?void 0:r.prComment)??!0,commitStatus:(r==null?void 0:r.commitStatus)??!0,singleNotification:(r==null?void 0:r.singleNotification)??!1}}),{commitStatus:f}=S(),{data:m,loading:v,refetch:b}=Mn({fetchPolicy:"network-only",variables:{input:{orgId:e.orgId}}});if(v)return t(Ft,{});function y(_){const H={prComment:!0,commitStatus:!0,singleNotification:!1};i({variables:{input:{orgId:e.orgId,projectId:e.projectId,...H,..._}}})}function I(){l({variables:{input:{orgId:e.orgId,projectId:e.projectId}}}),p("gitlabProjectId","")}const N=nt((m==null?void 0:m.getGitlabRepos)??[],"name","asc");return s("form",{onSubmit:d(y),children:[s(T,{flexDirection:"column",children:[t(he,{error:(M=u.errors.gitlabProjectId)==null?void 0:M.message,label:"Gitlab Project",children:t(w,{control:h,name:"gitlabProjectId",defaultValue:(r==null?void 0:r.gitlabProjectId)??"",render:({field:_})=>s(T,{alignItems:"center",justifyContent:"space-between",children:[t(ae,{disabled:!n,value:_.value,width:"100%",onChange:H=>_.onChange(H),children:N.map(H=>t(ae.Option,{value:String(H.repoId),children:H.name},H.repoId))}),t(P,{w:.5}),t(rt,{title:"Refetch Repositories",onClick:()=>b({input:{orgId:e.orgId}}),children:t(it,{size:D.icon.smaller})})]})})}),(r==null?void 0:r.gitlabProjectId)&&s(x,{children:[t(P,{h:2}),t(w,{control:h,name:"prComment",defaultValue:!!(r!=null&&r.prComment),render:({field:_})=>t(O,{title:"Merge Request Comment",description:s(x,{children:["Add a"," ",t(V,{icon:!0,href:"https://currents.dev/readme/integrations/gitlab#example-if-gitlab-merge-request-note",children:"note with run results summary"})," ","to Gitlab Merge Request"]}),disabled:!n,value:_.value,onChange:_.onChange})}),t(P,{h:2}),t(w,{control:h,name:"commitStatus",defaultValue:!!(r!=null&&r.commitStatus),render:({field:_})=>t(O,{title:"Commit Status",description:s(x,{children:["Update"," ",t(V,{icon:!0,href:"https://currents.dev/readme/integrations/gitlab#example-of-gitlab-commit-status",children:"commit status"})," ","with run results"]}),disabled:!n,value:_.value,onChange:_.onChange})}),!!f&&s(x,{children:[t(P,{h:2}),t(w,{control:h,name:"singleNotification",defaultValue:!!(r!=null&&r.singleNotification),render:({field:_})=>t(O,{title:"Single Notification",description:"Enabling will send a single notification for all groups in the project",disabled:!n,value:!!_.value,onChange:_.onChange})})]})]})]}),t(P,{h:2}),s(T,{justifyContent:"space-between",alignItems:"center",children:[n&&t(k,{type:"accent",size:"large",disabled:!u.isDirty||!c("gitlabProjectId")||!n,loading:a||v||o,htmlType:"submit",children:"Save"}),r&&n&&t(ji,{onDelete:I,loading:a||v||o})]})]})});function $i(e){const{toast:n}=U();return Un({update:(r,i)=>{var a;(a=i.data)!=null&&a.deleteGitlabIntegration&&r.modify({id:r.identify({__typename:"Organization",orgId:e}),fields:{gitlabApps:()=>[]}})},onError:r=>{n.error({title:r.message})},onCompleted:()=>{n.success({title:"Disabled Gitlab Integration"})}})}const Zt=({isInstalled:e,isConfigured:n=!1})=>{const r=W();return s(T,{alignItems:"center",gap:r.layout.gapHalf,className:"min-w-0",children:[t(et,{height:16,width:16,className:"shrink-0"}),e&&n&&s(x,{children:[t(Me,{className:"shrink-0",color:"green",size:D.icon.small}),t(R,{small:!0,className:"min-w-0 truncate",children:"GitLab App is installed"})]}),e&&!n&&s(x,{children:[t(Ue,{className:"shrink-0",color:"orange",size:D.icon.small}),t(R,{small:!0,className:"min-w-0 truncate",children:"GitLab App is installed but not configured"})]})]})},zi=X(({org:e,orgModel:n})=>
2{const r=Y(),i=W(),a=e.gitlabApps.length>0;return s(x,{children:[a&&s(T,{flexDirection:"column",gap:i.layout.gapHalf,children:[s(T,{alignItems:"center",justifyContent:"space-between",children:[t(Zt,{isInstalled:n.isGitLabAppEnabled(),isConfigured:r.isGitLabAppEnabled()}),t(Ki,{})]}),t(Le,{}),t(Fi,{})]}),!a&&t(Ui,{isEnterpriseFeatureGated:e.isEnterpriseFeatureGated,callbackUrl:e.gitlabCallbackUrl})]})}),Ki=X(({org:e})=>{const n=L(e.orgId),[r,{loading:i}]=$i(e.orgId),[a,l]=g.useState(!1);function o(){r({variables:{input:{orgId:e.orgId}}})}return s(x,{children:[n&&t(k,{type:"secondary",loading:i,onClick:()=>l(!0),children:"Uninstall"}),s(Ne,{visible:a,onClose:()=>l(!1),children:[t(Ne.Content,{children:"Uninstall Gitlab App?"}),t(Ne.Action,{passive:!0,onClick:()=>l(!1),children:"Close"}),t(Ne.Action,{onClick:o,children:t(Ke,{type:"warning",children:"Confirm"})})]})]})}),qi=$(({project:e})=>{const n=$t();return t(k,{type:"secondary",onClick:n(Q(e.orgId,e.projectId)),leftIcon:t(jn,{}),children:"Integrations"})}),Xi=$(({hookId:e,project:n})=>{const r=Gn(),i=L(n.orgId),[a,l]=g.useState(!1),[o,d]=g.useState(!1),[u,{loading:h}]=Bn(),{toast:p}=U();g.useEffect(()=>{o&&c(e)},[o]);async function c(S){try{await u({variables:{input:{projectId:n.projectId,hookId:S}},update:f=>{f.modify({id:f.identify({__typename:"Project",projectId:n.projectId}),fields:{hooks:(m,{readField:v})=>m.filter(b=>v("hookId",b)!==S)}}),p.success({title:"Removed Integration"})}}),r.push(Q(n.orgId,n.projectId))}catch(f){p.error({title:f.toString()})}}return s("div",{children:[a&&s("div",{className:"flex items-center gap-ui-v2-2",children:[t(k,{type:"danger",onClick:()=>d(!0),children:"Confirm"}),t(k,{type:"secondary",loading:h,onClick:()=>l(!1),children:"Cancel"})]}),i&&!a&&t(k,{leftIcon:t(Fn,{}),type:"danger",loading:h,onClick:()=>l(!0),children:"Remove"})]})}),we=({hookId:e,loading:n})=>{const r=L(),{formState:i}=oe();if(!r)return null;const a=Object.keys(i.errors).length>0;return s(ve.Footer,{className:"justify-end",children:[t(Xi,{hookId:e}),t(k,{type:"accent",disabled:a||!i.isDirty||!r,loading:n,htmlType:"submit",children:"Save"})]})},Qt=({dialogTitle:e,dialogDescription:n,onDisconnect:r,loading:i})=>{const[a,l]=ne.useState(!1);return s(Zn,{open:a,onOpenChange:l,children:[t($n,{asChild:!0,children:t(k,{type:"danger",children:"Disconnect"})}),s(zn,{children:[s(Kn,{children:[t(qn,{children:e}),t(Xn,{children:n})]}),s(Wn,{children:[t(Jn,{asChild:!0,children:t(k,{type:"secondary",disabled:i,children:"Cancel"})}),t(Yn,{asChild:!0,children:t(k,{type:"danger",loading:i,onClick:async()=>{await r(),l(!1)},children:"Disconnect"})})]})]})]})},Wi=new Set(["credentialsExpired","installationArchived"]),Ji=({icon:e,status:n,children:r})=>{const i=n.healthy?Me:Ue;return s("div",{className:"flex min-w-0 w-full items-center justify-between gap-2",children:[s("div",{className:"flex min-w-0 items-center gap-2",children:[t(e,{height:16,width:16,className:"shrink-0"}),t(i,{className:"shrink-0",color:n.healthy?"green":"orange",size:D.icon.small}),t(R,{small:!0,className:"min-w-0 truncate",children:n.text})]}),r&&t("div",{className:"flex shrink-0 items-center gap-2",children:r})]})},en=({icon:e,orgId:n,archivedAt:r,projectStatus:i,children:a,showDisconnect:l=!1,reauthButton:o,disconnectButton:d})=>{const u=L(n),h=i.issues.some(p=>Wi.has(p.code))&&u;return t(Ji,{icon:e,status:i,children:s("div",{className:"flex items-center gap-2",children:[h&&o,l&&u&&!r&&d,a]})})},te=$(({project:e,hookId:n,label:r="Configure"})=>t(tr,{font:D.font.smaller,href:er(e.orgId,e.projectId)+`/${n}`,children:t(k,{type:"secondary",rightIcon:t(Qn,{}),children:r})})),le=({children:e})=>t(nr,{hoverable:!0,width:"100%",children:t("div",{className:"flex min-w-0 w-full items-center justify-between gap-2 [&>*:first-child:not(:only-child)]:min-w-0 [&>*:first-child:not(:only-child)]:flex-1 [&>*:last-child:not(:only-child)]:shrink-0",children:e})}),Yi=X(Zi);function Zi({orgModel:e}){const n=Y();return s(le,{children:[t(Zt,{isInstalled:e.isGitLabAppEnabled(),isConfigured:n.isGitLabAppEnabled()}),t(te,{hookId:"gitlab",label:e.isGitLabAppEnabled()?"Configure":"Install GitLab App"})]})}function tn(e){const{toast:n}=U(),{refetch:r}=Bt(),[i,{loading:a}]=rr(),[l,{loading:o}
2]=ir(),d=g.useCallback(async(p,c,S,f)=>{var m;if(e)try{await p({variables:{orgId:e}}),n.success({title:c}),r(),(m=f==null?void 0:f.onSuccess)==null||m.call(f)}catch(v){n.error({title:`${S}${v.message}`})}},[e,n,r]),u=g.useCallback(async p=>{await d(i,"Currents Assistant enabled","Failed to enable assistant: ",p)},[d,i]),h=g.useCallback(async p=>{await d(l,"Currents Assistant disabled","Failed to disable assistant: ",p)},[d,l]);return{enableWithFeedback:u,disableWithFeedback:h,enabling:a,disabling:o}}function Qi(){var v;const e=zt(),n=ar(),r=L(),[i,a]=g.useState(!1),l=(e==null?void 0:e.orgId)??"",o=(n==null?void 0:n.isAssistantEnabled())??!1,{data:d}=sr({variables:{orgId:l},skip:!l||!o}),{enableWithFeedback:u,disableWithFeedback:h,enabling:p,disabling:c}=tn(l),S=()=>u(),f=()=>{c||h({onSuccess:()=>a(!1)})},m=["AI-powered assistant with knowledge of your test data","Ask questions about test runs, failures, and flaky tests","Get actionable insights and recommendations","Thread-based conversations with history"];return s("div",{className:"grid gap-ui-v2-4",children:[s("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-start gap-ui-v2-3",children:[t("div",{className:"grid h-10 w-10 place-items-center rounded-lg border border-border bg-muted",children:t(at,{className:"h-5 w-5"})}),s("div",{children:[t("h3",{className:"text-base font-semibold leading-none",children:"Currents Assistant"}),t("span",{className:`mt-0.5 text-xs font-medium leading-none ${o?"text-emerald-500":"text-muted-foreground"}`,children:o?"Enabled":"Disabled"})]})]}),o&&s("div",{className:"text-sm",children:[t("span",{className:"text-muted-foreground",children:"Agent ID: "}),(v=d==null?void 0:d.assistantAgent)!=null&&v.agentId?t("code",{className:"text-xs",children:d.assistantAgent.agentId}):t("span",{className:"text-xs text-muted-foreground/60",children:"Not provisioned"})]}),t(pe,{title:"Features"}),t("div",{className:"grid gap-2",children:m.map(b=>s("div",{className:"grid grid-cols-[auto_1fr] items-center gap-2 text-sm",children:[t(lr,{className:"h-3.5 w-3.5 text-emerald-500","aria-hidden":!0}),t("span",{className:"text-muted-foreground",children:b})]},b))}),t(P,{h:1}),!o&&r&&t("div",{children:t(k,{type:"accent",size:"large",disabled:!l,loading:p,onClick:S,children:"Enable Currents Assistant"})}),o&&r&&!i&&t("div",{children:t(k,{type:"danger",onClick:()=>a(!0),children:"Disable Currents Assistant"})}),i&&s("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-ui-v2-4",children:[t("p",{className:"mb-ui-v2-3 text-sm text-destructive",children:"This will permanently delete the assistant agent and all conversation history for this organization. This action cannot be undone."}),s("div",{className:"grid w-max grid-flow-col gap-2",children:[t(k,{type:"danger",onClick:f,children:"Confirm Disable"}),t(k,{type:"secondary",onClick:()=>a(!1),children:"Cancel"})]})]})]})}const nn=ne.createContext({installationId:null,setInstallationId:()=>{}}),ea=({org:e,project:n,children:r})=>{var d,u,h;const i=((d=e.githubInstallations)==null?void 0:d[0])??null,a=((h=(u=n.githubIntegration)==null?void 0:u[0])==null?void 0:h.installationId)??null,[l,o]=g.useState(a??i);return t(nn.Provider,{value:{installationId:l,setInstallationId:o},children:r})},rn=()=>g.useContext(nn);function ta(e){const{toast:n}=U();return or({update:(r,i)=>{var a;(a=i.data)!=null&&a.deleteGithubProjectIntegration&&r.modify({id:r.identify({__typename:"Project",projectId:e}),fields:{githubIntegration:()=>[]}})},onError:r=>{n.error({title:r.message})},onCompleted:()=>{n.success({title:"Disconnected GitHub Repository"})}})}function na(e){const{toast:n}=U();return cr({update:(r,i)=>{var a;(a=i.data)!=null&&a.updateGithubProjectIntegration&&r.modify({id:r.identify({__typename:"Project",projectId:e}),fields:{githubIntegration:()=>[{__ref:r.identify(i.data.updateGithubProjectIntegration)}]}})},onError:r=>{n.error({title:r.message})},onCompleted:()=>{n.success({title:"Updated GitHub Integration"})}})}const de={repoId:"",prComment:!0,keepPRComment:!1,commitStatus:!0,failedOnly:!1,commitStatusLabel:"Currents Tests",commitStatusFrameworkPrefix:!1,singleNotification:!1},ra=({orgId:e,projectId:n,installationId:r})=>{var Nt,_t,Rt;const i=dr(n),a=L(e),l=W(),o=ur("pr-review-comments"),[d,{loading:u}]=na(n),[h,{loading:p}]=ta(n),c=((i==null?void 0:i.githubIntegration)??[]).find(E=>E.installationId===r)??null,S={repoId:(c==null?void 0:c.repoId)??"",commitStatusLabel:(c==null?void 0:c.commitStatusLabel)??de.commitStatusLabel,prComment:(c==null?void 0:c.prComment)??!0,keepPRComment:(c==null?void 0:c.keepPRComment)??!1,commitStatus:(c==null?void 0:c.commitStatus)??!0,singleNotification:(c==null?void 0:c.singleNotification)??!1,commitStatusFrameworkPrefix:(c==null?void 0:c.commitStatusFrameworkPrefix)??!1},f=J({defaultValues:S,mode:"onChange"}),{handleSubmit:m,register:v,formState:{errors:b,isDirty:y},control:I,setValue:N,watch:M,reset:_}=f,{prComment:H,repoId:ie,commitStatusLabel:Et,commitStatus:In}=M(),{data:Fe,loading:Ce,refetch:Sn}=hr({variables:{input:{orgId:e,installationId:r}}});if(g.useEffect(()=>{_({...S,repoId:(c==null?void 0:c.repoId)??""})},[r]),!i)return null;if(Ce)return t(Ft,{children:"Fetching GitHub Repositories"});function kn(E){d({variables:{input:{...de,...E,orgId:e,projectId:n,commitStatusLabel:E.commitStatusLabel??(c==null?void 0:c.commitStatusLabel)??de.commitStatusLabel,commitStatusFrameworkPrefix:E.commitStatusFrameworkPrefix??(c==null?void 0:c.commitStatusFrameworkPrefix)??!1,installationId:r,prReviewComments:o?E.prReviewComments??!1:(c==null?void 0:c.prReviewComments)??null}}})}function xn(){h({variables:{input:{orgId:e,projectId:n}}}),N("repoId","")}const An=nt(((Nt=Fe==null?void 0:Fe.getGithubRepos)==null?void 0:Nt.repos)??[],"name","asc");return t(re,{...f,children:t("form",{onSubmit:m(kn),children:s(T,{flexDirection:"column",gap:l.layout.gap,children:[t(he,{error:(_t=b.repoId)==null?void 0:_t.message,label:"GitHub Repository",children:t(w,{control:I,name:"repoId",defaultValue:(c==null?void 0:c.repoId)??"",render:({field:E})=>s(T,{alignItems:"center",children:[t(ae,{disabled:!a,width:"100%",value:E.value,onChange:ce=>E.onChange(ce),children:An.map(ce=>s(ae.Option,{value:String(ce.id),children:[ce.owner,"/",ce.name]},ce.id))}),t(P,{w:.5}
2),t(st,{type:"secondary","aria-label":"Refetch repositories",title:"Refetch Repositories",icon:t(it,{}),loading:Ce,onClick:()=>Sn({input:{orgId:e,installationId:r}})})]})})}),(c==null?void 0:c.repoId)&&s(x,{children:[t(P,{h:2}),t(qe,{children:"Commit Status"}),t(w,{control:I,name:"commitStatus",defaultValue:!!(c!=null&&c.commitStatus),render:({field:E})=>t(O,{title:"Enable Commit Status",description:s(x,{children:["Update"," ",t(V,{icon:!0,href:"https://currents.dev/readme/integrations/github/github-app#commit-status-checks",children:"commit status"})," ","with run results"]}),value:E.value,disabled:!a,onChange:E.onChange})}),!!In&&s(x,{children:[t(he,{helpText:"Enter the commit status label - it will appear next to the commit status check",error:(Rt=b.commitStatusLabel)==null?void 0:Rt.message,label:"Commit Status Label (Optional)",children:s(T,{alignItems:"center",children:[t(z,{width:"100%",clearable:!0,disabled:!a||Ce,maxLength:16,...v("commitStatusLabel",{pattern:{value:/^[a-zA-Z0-9-_:. ]+$/,message:"Please use only letters, numbers, dashes, underscores, colons, spaces or periods"},maxLength:{value:16,message:"Commit status label must be 16 characters or less"},minLength:{value:3,message:"Commit status label must be at least 3 characters"}})}),a&&Et!==de.commitStatusLabel&&s(x,{children:[t(P,{}),t(pr,{span:!0,font:D.font.smaller,onClick:()=>{N("commitStatusLabel",de.commitStatusLabel,{shouldDirty:!0})},children:"Reset"})]})]})}),t(w,{control:I,name:"commitStatusFrameworkPrefix",defaultValue:!!(c!=null&&c.commitStatusFrameworkPrefix),render:({field:E})=>t(O,{title:"Framework Prefix",description:s(x,{children:["Prefix the commit status label with the framework name"," ",t("code",{children:`[Playwright] ${Et??de.commitStatusLabel}`})]}),value:!!E.value,disabled:!a,onChange:E.onChange})}),t(w,{control:I,name:"singleNotification",defaultValue:!!(c!=null&&c.singleNotification),render:({field:E})=>t(O,{title:"Single Commit Status for All Groups",description:"Enabling will update GitHub commit status once per run event, regardless of the number of groups",value:!!E.value,disabled:!a,onChange:E.onChange})})]}),t(P,{h:2}),t(qe,{children:"PR Comment"}),s(q.Container,{gap:2,children:[t(q,{xs:24,children:t(w,{control:I,name:"prComment",defaultValue:!!(c!=null&&c.prComment),render:({field:E})=>t(O,{title:"Enable PR Comment",description:s(x,{children:["Add a"," ",t(V,{icon:!0,href:"https://currents.dev/readme/integrations/github/github-app#pr-comment",children:"comment with run results"})," ","to GitHub Pull Request"]}),value:E.value,disabled:!a,onChange:E.onChange})})}),H&&s(x,{children:[t(q,{xs:24,children:t(w,{control:I,name:"failedOnly",defaultValue:!!(c!=null&&c.failedOnly),render:({field:E})=>t(O,{title:"Only Failed Runs",description:"Enabling will only post comments after a run fails",value:E.value,disabled:!a,onChange:E.onChange})})}),t(q,{xs:24,children:t(w,{control:I,name:"keepPRComment",defaultValue:!!(c!=null&&c.keepPRComment),render:({field:E})=>t(O,{title:"Keep Old Results",description:s(x,{children:["Keep"," ",t(V,{icon:!0,href:"https://currents.dev/readme/integrations/github/github-app#keep-old-results",children:"previously posted"})," ","comments with results"]}),value:!!E.value,disabled:!a,onChange:E.onChange})})}),o&&t(q,{xs:24,children:t(w,{control:I,name:"prReviewComments",defaultValue:!!(c!=null&&c.prReviewComments),render:({field:E})=>t(O,{title:"Post Error Details on Spec Files",description:"Add inline review comments with error details and Fix with AI links on failing spec files in the PR diff",value:!!E.value,disabled:!a,onChange:E.onChange})})})]})]})]}),t(P,{h:2}),s(q.Container,{gap:2,children:[t(q,{xs:12,children:a&&t(k,{type:"accent",size:"large",disabled:!y||!ie||!a,loading:u||Ce||p,htmlType:"submit",children:"Save"})}),t(q,{xs:12,justify:"flex-end",children:!!c&&a&&t(aa,{onDelete:xn,loading:u||Ce||p})})]})]})})})},ia=()=>{const e=zt(),[n]=Kt(),{installationId:r}=rn();return!e||!n||!r?null:t(ra,{orgId:e.orgId,projectId:n,installationId:r},n)};function aa({onDelete:e,loading:n}){const[r,i]=g.useState(!1);return s(x,{children:[r&&s(x,{children:[t(k,{type:"danger",onClick:()=>{e(),i(!1)},children:"Disconnect"}),t(P,{}),t(k,{type:"secondary",onClick:()=>i(!1),loading:n,children:"Cancel"})]}),!r&&t(k,{type:"danger",onClick:()=>i(!0),children:"Disconnect Repository"})]})}const an=({isInstalled:e,isConfigured:n=!1})=>s("div",{className:"flex min-w-0 items-center gap-2",children:[t(Oe,{height:16,width:16,className:"shrink-0"}),e&&n&&s(x,{children:[t(Me,{className:"shrink-0",color:"green",size:D.icon.small}),t(R,{small:!0,className:"min-w-0 truncate",children:"GitHub App is installed"})]}),e&&!n&&s(x,{children:[t(Ue,{className:"shrink-0",color:"orange",size:D.icon.small}),t(R,{small:!0,className:"min-w-0 truncate",children:"GitHub App is installed but not configured"})]})]}),sa=X(({org:e,orgModel:n})=>{var m;
2const r=W(),i=Y(),[a]=Kt(),l=L(e.orgId),{installationId:o,setInstallationId:d}=rn(),[u,{loading:h}]=mr({variables:{input:{orgId:e==null?void 0:e.orgId}},refetchQueries:["getBootstrapV2"]}),[p,{loading:c}]=gr({fetchPolicy:"network-only",onCompleted:v=>{var b,y;(b=v.githubInstallationRequest)!=null&&b.url&&(window.location.href=(y=v.githubInstallationRequest)==null?void 0:y.url)}}),S=qt(e.githubInstallationDetails,"installationId"),f=()=>{p({variables:{input:{orgId:e.orgId,projectId:a}}})};return o&&((m=e.githubInstallations)!=null&&m.length)?s(T,{flexDirection:"column",gap:r.layout.gap,width:"100%",children:[s(T,{alignItems:"center",gap:r.layout.gapQuarter,children:[t(an,{isInstalled:n.isGitHubAppEnabled(),isConfigured:i.isGitHubAppEnabled()}),l&&t(k,{type:"secondary",loading:c,onClick:f,style:{marginLeft:"auto"},children:"Configure"}),l&&t(k,{type:"secondary",disabled:!l,loading:c,onClick:f,leftIcon:t(fr,{}),title:"Connect New GitHub Organization",children:"Add Organization"})]}),t(Le,{}),t(qe,{children:"GitHub Organization"}),s(T,{flexDirection:"column",children:[t(pe,{title:`GitHub Organization (${e.githubInstallations.length})`}),s(T,{width:"100%",alignItems:"center",children:[t(ae,{disabled:h||!l,value:o,multiple:!1,width:"100%",onChange:v=>d(v),children:e.githubInstallations.map(v=>{var b;if((b=S[v])!=null&&b.length){const{avatarUrl:y,login:I}=S[v][0];return t(ae.Option,{value:v,children:s(T,{alignItems:"center",children:[!!y&&t("img",{src:y,alt:"",className:"h-6 w-6 rounded-full object-cover",onError:N=>{N.currentTarget.style.display="none"}}),t("span",{style:{paddingLeft:"0.5rem"},children:br(I,20)})]})},v)}return t(ae.Option,{value:v,children:v},v)})}),t(P,{w:.5}),t(st,{type:"secondary","aria-label":"Refresh organizations",icon:t(it,{}),disabled:!l,loading:h,onClick:()=>u()})]})]}),t(ia,{})]}):s(q.Container,{alignItems:"center",children:[s(Se,{children:[t(lt,{children:t(Oe,{height:32,width:32})}),t(ke,{children:t(R,{children:"Connect your GitHub organization"})}),t(xe,{children:t(k,{type:"accent",size:"large",disabled:!l,loading:c,onClick:f,children:"Connect"})})]}),e.hasPendingGitHubInstallations&&s(q,{xs:24,direction:"column",alignItems:"flex-start",children:[t(yr,{type:"warning",children:"Pending Approval"}),t(R,{children:"Installation request is pending for an approval by your GitHub organization's admin"})]})]})}),la=({org:e,project:n})=>t(ea,{org:e,project:n,children:t(sa,{})}),oa=X($(la)),ca=X(({orgModel:e})=>{const n=Y();return s(le,{children:[t(an,{isInstalled:e.isGitHubAppEnabled(),isConfigured:n.isGitHubAppEnabled()}),t(te,{hookId:"github",label:e.isGitHubAppEnabled()?"Configure":"Install GitHub App"})]})}),vt=e=>g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 128 128",...e},g.createElement("path",{d:"M27.255 80.719c0 7.33-5.978 13.317-13.309 13.317C6.616 94.036.63 88.049.63 80.719s5.987-13.317 13.317-13.317h13.309zm6.709 0c0-7.33 5.987-13.317 13.317-13.317s13.317 5.986 13.317 13.317v33.335c0 7.33-5.986 13.317-13.317 13.317-7.33 0-13.317-5.987-13.317-13.317zm0 0",fill:"#de1c59"}),g.createElement("path",{d:"M47.281 27.255c-7.33 0-13.317-5.978-13.317-13.309C33.964 6.616 39.951.63 47.281.63s13.317 5.987 13.317 13.317v13.309zm0 6.709c7.33 0 13.317 5.987 13.317 13.317s-5.986 13.317-13.317 13.317H13.946C6.616 60.598.63 54.612.63 47.281c0-7.33 5.987-13.317 13.317-13.317zm0 0",fill:"#35c5f0"}),g.createElement("path",{d:"M100.745 47.281c0-7.33 5.978-13.317 13.309-13.317 7.33 0 13.317 5.987 13.317 13.317s-5.987 13.317-13.317 13.317h-13.309zm-6.709 0c0 7.33-5.987 13.317-13.317 13.317s-13.317-5.986-13.317-13.317V13.946C67.402 6.616 73.388.63 80.719.63c7.33 0 13.317 5.987 13.317 13.317zm0 0",fill:"#2eb57d"}),g.createElement("path",{d:"M80.719 100.745c7.33 0 13.317 5.978 13.317 13.309 0 7.33-5.987 13.317-13.317 13.317s-13.317-5.987-13.317-13.317v-13.309zm0-6.709c-7.33 0-13.317-5.987-13.317-13.317s5.986-13.317 13.317-13.317h33.335c7.33 0 13.317 5.986 13.317 13.317 0 7.33-5.987 13.317-13.317 13.317zm0 0",fill:"#ebb02e"})),Ct=e=>g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e},g.createElement("path",{fill:"currentColor",d:"M2.886 4.18A11.982 11.982 0 0 1 11.99 0C18.624 0 24 5.376 24 12.009c0 3.64-1.62 6.903-4.18 9.105L2.887 4.18ZM1.817 5.626l16.556 16.556c-.524.33-1.075.62-1.65.866L.951 7.277c.247-.575.537-1.126.866-1.65ZM.322 9.163l14.515 14.515c-.71.172-1.443.282-2.195.322L0 11.358a12 12 0 0 1 .322-2.195Zm-.17 4.862 9.823 9.824a12.02 12.02 0 0 1-9.824-9.824Z"})),da=e=>g.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e}
2,g.createElement("path",{d:"M19 13.9032C19 13.4044 19.4044 13 19.9032 13H31.0968C31.5956 13 32 13.4044 32 13.9032V20.5C32 24.0899 29.0899 27 25.5 27C21.9101 27 19 24.0899 19 20.5V13.9032Z",fill:"url(#paint0_linear_87_7777)"}),g.createElement("path",{d:"M9 12.2258C9 11.5488 9.54881 11 10.2258 11H23.7742C24.4512 11 25 11.5488 25 12.2258V22C25 26.4183 21.4183 30 17 30C12.5817 30 9 26.4183 9 22V12.2258Z",fill:"url(#paint1_linear_87_7777)"}),g.createElement("circle",{cx:27,cy:8,r:3,fill:"#34439E"}),g.createElement("circle",{cx:27,cy:8,r:3,fill:"url(#paint2_linear_87_7777)"}),g.createElement("circle",{cx:18,cy:6,r:4,fill:"url(#paint3_linear_87_7777)"}),g.createElement("mask",{id:"mask0_87_7777",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:9,y:0,width:16,height:30},g.createElement("path",{d:"M17 10C19.7615 10 22 7.76147 22 5C22 2.23853 19.7615 0 17 0C14.2385 0 12 2.23853 12 5C12 7.76147 14.2385 10 17 10Z",fill:"url(#paint4_linear_87_7777)"}),g.createElement("path",{d:"M10.2258 11C9.54883 11 9 11.5488 9 12.2258V22C9 26.4183 12.5817 30 17 30C21.4183 30 25 26.4183 25 22V12.2258C25 11.5488 24.4512 11 23.7742 11H10.2258Z",fill:"url(#paint5_linear_87_7777)"})),g.createElement("g",{mask:"url(#mask0_87_7777)"},g.createElement("path",{d:"M7 12C7 10.3431 8.34315 9 10 9H17C18.6569 9 20 10.3431 20 12V24C20 25.6569 18.6569 27 17 27H7V12Z",fill:"#000000",fillOpacity:.3})),g.createElement("rect",{y:7,width:18,height:18,rx:2,fill:"url(#paint6_linear_87_7777)"}),g.createElement("path",{d:"M13 11H5V12.8347H7.99494V21H10.0051V12.8347H13V11Z",fill:"white"}),g.createElement("defs",null,g.createElement("linearGradient",{id:"paint0_linear_87_7777",x1:19,y1:13.7368,x2:32.1591,y2:22.3355,gradientUnits:"userSpaceOnUse"},g.createElement("stop",{stopColor:"#364088"}),g.createElement("stop",{offset:1,stopColor:"#6E7EE1"})),g.createElement("linearGradient",{id:"paint1_linear_87_7777",x1:9,y1:19.4038,x2:25,y2:19.4038,gradientUnits:"userSpaceOnUse"},g.createElement("stop",{stopColor:"#515FC4"}),g.createElement("stop",{offset:1,stopColor:"#7084EA"})),g.createElement("linearGradient",{id:"paint2_linear_87_7777",x1:24,y1:5.31579,x2:29.7963,y2:9.39469,gradientUnits:"userSpaceOnUse"},g.createElement("stop",{stopColor:"#364088"}),g.createElement("stop",{offset:1,stopColor:"#6E7EE1"})),g.createElement("linearGradient",{id:"paint3_linear_87_7777",x1:15.1429,y1:3.14286,x2:20.2857,y2:9.14286,gradientUnits:"userSpaceOnUse"},g.createElement("stop",{stopColor:"#4858AE"}),g.createElement("stop",{offset:1,stopColor:"#4E60CE"})),g.createElement("linearGradient",{id:"paint4_linear_87_7777",x1:13.4286,y1:1.42857,x2:19.8571,y2:8.92857,gradientUnits:"userSpaceOnUse"},g.createElement("stop",{stopColor:"#4858AE"}),g.createElement("stop",{offset:1,stopColor:"#4E60CE"})),g.createElement("linearGradient",{id:"paint5_linear_87_7777",x1:13.4286,y1:1.42857,x2:19.8571,y2:8.92857,gradientUnits:"userSpaceOnUse"},g.createElement("stop",{stopColor:"#4858AE"}),g.createElement("stop",{offset:1,stopColor:"#4E60CE"})),g.createElement("linearGradient",{id:"paint6_linear_87_7777",x1:-521539e-13,y1:16,x2:18,y2:16,gradientUnits:"userSpaceOnUse"},g.createElement("stop",{stopColor:"#2A3887"}),g.createElement("stop",{offset:1,stopColor:"#4C56B9"})))),ua=e=>g.createElement("svg",{width:"800px",height:"800px",viewBox:"0 -8.5 256 256",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",preserveAspectRatio:"xMidYMid",...e},g.createElement("g",null,g.createElement("path",{d:"M119.540432,100.502743 C108.930124,118.338815 98.7646301,135.611455 88.3876025,152.753617 C85.7226696,157.154315 84.4040417,160.738531 86.5332204,166.333309 C92.4107024,181.787152 84.1193605,196.825836 68.5350381,200.908244 C53.8383677,204.759349 39.5192953,195.099955 36.6032893,179.365384 C34.0194114,165.437749 44.8274148,151.78491 60.1824106,149.608284 C61.4694072,149.424428 62.7821041,149.402681 64.944891,149.240571 C72.469175,136.623655 80.1773157,123.700312 88.3025935,110.073173 C73.611854,95.4654658 64.8677898,78.3885437 66.803227,57.2292132 C68.1712787,42.2715849 74.0527146,29.3462646 84.8033863,18.7517722 C105.393354,-1.53572199 136.805164,-4.82141828 161.048542,10.7510424 C184.333097,25.7086706 194.996783,54.8450075 185.906752,79.7822957 C179.052655,77.9239597 172.151111,76.049808 164.563565,73.9917997 C167.418285,60.1274266 165.306899,47.6765751 155.95591,37.0109123 C149.777932,29.9690049 141.850349,26.2780332 132.835442,24.9178894 C114.764113,22.1877169 97.0209573,33.7983633 91.7563309,51.5355878 C85.7800012,71.6669027 94.8245623,88.1111998 119.540432,100.502743 L119.540432,100.502743 Z",fill:"#C73A63"}),g.createElement("path",{d:"M149.841194,79.4106285 C157.316054,92.5969067 164.905578,105.982857 172.427885,119.246236 C210.448
265,107.483365 239.114472,128.530009 249.398582,151.063322 C261.81978,178.282014 253.328765,210.520191 228.933162,227.312431 C203.893073,244.551464 172.226236,241.605803 150.040866,219.46195 C155.694953,214.729124 161.376716,209.974552 167.44794,204.895759 C189.360489,219.088306 208.525074,218.420096 222.753207,201.614016 C234.885769,187.277151 234.622834,165.900356 222.138374,151.863988 C207.730339,135.66681 188.431321,135.172572 165.103273,150.721309 C155.426087,133.553447 145.58086,116.521995 136.210101,99.2295848 C133.05093,93.4015266 129.561608,90.0209366 122.440622,88.7873178 C110.547271,86.7253555 102.868785,76.5124151 102.408155,65.0698097 C101.955433,53.7537294 108.621719,43.5249733 119.04224,39.5394355 C129.363912,35.5914599 141.476705,38.7783085 148.419765,47.554004 C154.093621,54.7244134 155.896602,62.7943365 152.911402,71.6372484 C152.081082,74.1025091 151.00562,76.4886916 149.841194,79.4106285 L149.841194,79.4106285 Z",fill:"#4B4B4B"}),g.createElement("path",{d:"M167.706921,187.209935 L121.936499,187.209935 C117.54964,205.253587 108.074103,219.821756 91.7464461,229.085759 C79.0544063,236.285822 65.3738898,238.72736 50.8136292,236.376762 C24.0061432,232.053165 2.08568567,207.920497 0.156179306,180.745298 C-2.02835403,149.962159 19.1309765,122.599149 47.3341915,116.452801 C49.2814904,123.524363 51.2485589,130.663141 53.1958579,137.716911 C27.3195169,150.919004 18.3639187,167.553089 25.6054984,188.352614 C31.9811726,206.657224 50.0900643,216.690262 69.7528413,212.809503 C89.8327554,208.847688 99.9567329,192.160226 98.7211371,165.37844 C117.75722,165.37844 136.809118,165.180745 155.847178,165.475311 C163.280522,165.591951 169.019617,164.820939 174.620326,158.267339 C183.840836,147.48306 200.811003,148.455721 210.741239,158.640984 C220.88894,169.049642 220.402609,185.79839 209.663799,195.768166 C199.302587,205.38802 182.933414,204.874012 173.240413,194.508846 C171.247644,192.37176 169.677943,189.835329 167.706921,187.209935 L167.706921,187.209935 Z",fill:"#4A4A4A"}))),It="flex flex-col gap-ui-v2-4 p-ui-v2-4",sn="flex flex-col gap-ui-v2-5 p-ui-v2-4",Te="flex flex-col gap-ui-v2-4",Ge=({children:e})=>t("span",{role:"heading","aria-level":3,className:"ty-heading text-ui-v2-content-primary-idle",children:e}),Be=g.forwardRef(function({revealLabel:n,defaultRevealed:r=!1,...i},a){const[l,o]=He(r);return t(K,{ref:a,htmlType:l?"text":"password",rightIcon:l?t(Ir,{}):t(Sr,{}),onRightIconClick:()=>o(),rightIconLabel:`${l?"Hide":"Show"} ${n}`,...i})}),ln=({label:e,description:n,onReset:r})=>s("div",{className:"flex flex-col items-stretch gap-ui-v2-1",children:[t("span",{className:"ty-text ty-strong text-ui-v2-content-primary-idle",children:e}),s("div",{className:"flex items-center gap-ui-v2-2",children:[t("span",{className:"ty-text text-ui-v2-content-secondary-idle",children:n}),t(k,{type:"secondary",onClick:r,children:"Reset"})]})]}),j=e=>{switch(e){case"GITHUB_APP":return"GitHub App";case"SLACK_HOOK":return"Slack Webhook";case"SLACK_APP":return"Slack App";case"LINEAR_APP":return"Linear App";case"JIRA_APP":return"Jira App";case"GITHUB_STATUS_HOOK":return"GitHub (Legacy)";case"BITBUCKET_STATUS_HOOK":return"BitBucket";case"GENERIC_HOOK":return"HTTP Webhook";case"MSTEAMS_STATUS_HOOK":return"Microsoft Teams";case"GITLAB_APP":return"GitLab App";case"ASSISTANT":return"Currents Assistant";default:return"Unknown"}},ha=e=>{var n;return((n=e.label)==null?void 0:n.trim())??j(e.hookType)},on=e=>{switch(e){case"RUN_CANCELED":return"Run Cancelled";case"RUN_START":return"Run Start";case"RUN_FINISH":return"Run Finish";case"RUN_TIMEOUT":return"Run Timeout";default:return"Unknown"}},Ee=(e,n)=>(r,i)=>{const a=i.data[n];a&&(r.modify({id:r.identify({__typename:"Project",projectId:a.projectId}),fields:{hooks:l=>l.map(o=>o.hookId!==a.hookId?o:{...i,...a})}}),e.success({title:"Integration Updated"}))},F=({hookType:e})=>{switch(e){case C.GITHUB_APP:return t(Oe,{size:14});case C.GITHUB_STATUS_HOOK:return t(Oe,{size:14});case C.GITLAB_APP:return t(et,{width:16,height:16});case C.SLACK_HOOK:case C.SLACK_APP:return t(vt,{width:16,height:16});case C.LINEAR_APP:return t(Ct,{width:16,height:16});
2case C.JIRA_APP:return t(Xe,{width:16,height:16});case C.MSTEAMS_STATUS_HOOK:return t(da,{width:16,height:16});case C.BITBUCKET_STATUS_HOOK:return t(Cr,{width:16,height:16});case C.GENERIC_HOOK:return t(ua,{width:16,height:16});case C.ASSISTANT:return t(at,{width:14,height:14});default:return t(vr,{size:14})}},pa=e=>{try{return wi(e,"fake"),!0}catch{return"Valid Bitbucket URL required, e.g. https://bitbucket.org/<project>/<repository>.git"}},ma=e=>{try{return Ti(e,"fake"),!0}catch{return"Valid Github URL required, e.g. https://github.com/<org>/<repository>.git"}},ga=e=>{try{return e&&JSON.parse(e),!0}catch{return"Cannot parse JSON, please enter a valid JSON"}},St=e=>{try{const n=new URL(e);return n.protocol&&n.hostname&&n.pathname?!0:"Please enter a valid URL"}catch{return"Please enter a valid URL"}},fa=$(({hook:e,project:n})=>{var I,N,M,_;const r=L(n.orgId),[i,,{setSwitchTrue:a}]=He(),{toast:l}=U(),[o,{loading:d}]=kr(),u=J({mode:"onChange"}),{register:h,handleSubmit:p,formState:{errors:c}}=u;async function S(H){try{const ie={...H,hookId:e.hookId,integrationId:e.integrationId??null,projectId:n.projectId,label:H.label??null};await o({variables:{input:ie},update:Ee(l,"updateBitbucketHook")})}catch(ie){l.error({title:ie.toString()})}}const f=!r||d,m=(I=c.url)==null?void 0:I.message,v=(N=c.bitbucketUsername)==null?void 0:N.message,b=(M=c.bitbucketToken)==null?void 0:M.message,y=(_=c.bitbucketBuildName)==null?void 0:_.message;return t(re,{...u,children:t("form",{onSubmit:p(S),children:s(ve,{level:1,padding:"none",children:[s("div",{className:It,children:[t(Ae,{initialValue:e.label,disabled:f}),t(K,{size:"large",label:"URL *",helperText:m??"Bitbucket repository URL, e.g. https://bitbucket.org/nasa/space-shuttle.git",error:!!m,htmlType:"url",defaultValue:e.url,...h("url",{required:{value:!0,message:"Bitbucket repository URL is required"},validate:{bitbucketUrlValidation:pa}}),required:!0,disabled:f}),t(K,{size:"large",label:"Username",helperText:v??"BitBucket username",error:!!v,...h("bitbucketUsername",{required:{value:!0,message:"Bitbucket username is required"}}),defaultValue:e.bitbucketUsername,disabled:f}),e.bitbucketToken&&!i&&t(ln,{label:"App Password",description:"Using saved BitBucket App Password.",onReset:a}),(!e.bitbucketToken||i)&&t(Be,{size:"large",label:"App Password",helperText:b??s(x,{children:["Bitbucket App Password with ",t(tt,{children:"repo:write"})," ","access."," ",t(V,{icon:!0,target:"_blank",rel:"noopener noreferrer",href:"https://bitbucket.org/account/settings/app-passwords/",children:"Create One"})]}),error:!!b,revealLabel:"App Password",autoComplete:"new-password",...h("bitbucketToken",{required:{value:!0,message:"Bitbucket token is required"}}),defaultValue:"",disabled:f}),t(K,{size:"large",label:"Build Name (optional)",helperText:y??'Build name used for status updates. Default value is "currents.dev"',error:!!y,name:"bitbucketBuildName",defaultValue:e.bitbucketBuildName,disabled:f})]}),t(we,{hookId:e.hookId,loading:d})]})})})}),kt=({hook:e,disabled:n,failedOnly:r})=>{var h;const{formState:{errors:i},control:a,setValue:l,getValues:o}=oe();g.useEffect(()=>{if(r){const p=o("hookEvents");l("hookEvents",p.filter(c=>c!==Pe.RUN_START))}},[r]);const d=(h=i.hookEvents)==null?void 0:h.message,u=ba(r??!1).map(p=>({value:Pe[p],label:on(p)}));return t(w,{control:a,name:"hookEvents",defaultValue:e.hookEvents,render:({field:p})=>s(_e,{size:"large",value:p.value??[],onValueChange:c=>p.onChange([...c]),options:u,disabled:n,children:[t(_e.Trigger,{label:"Events (Optional)",helperText:d??"Events to trigger the integration. Leaving this field blank activates all the events.",error:!!d,placeholder:"All events",removableChips:!0}),t(_e.Content,{children:u.map(c=>t(_e.Item,{value:c.value,children:c.label},c.value))})]})})};function ba(e){const n=[];return e&&n.push(Pe.RUN_START.toString()),Object.keys(Pe).filter(r=>!n.includes(r)).sort()}const ya=()=>t(V,{icon:!0,href:"https://currents.dev/readme/integrations/github/github-oauth",children:"Help"}),va=()=>t(V,{icon:!0,href:"https://currents.dev/readme/integrations/http-webhooks",children:"Help"}),Ca=$(({hook:e,project:n})=>{var m,v;const r=L(n.orgId),{toast:i}=U(),[a,{loading:l}]=xr(),o=J({mode:"onChange"}),{register:d,handleSubmit:u,formState:{errors:h}}=o;async function p(b){try{const y={...b,hookId:e.hookId,integrationId:e.integrationId??null,projectId:n.projectId,label:b.label??null};await a({variables:{input:y},update:Ee(i,"updateGenericHook")})}catch(y){i.error({title:y.toString()})}}const c=!r||l,S=(m=h.url)==null?void 0:m.message,f=(v=h.headers)==null?void 0:v.message;return t(re,{...o,children:t("form",{onSubmit:u(p),children:s(ve,{level:1,padding:"none",children:[s("div",{className:It,children:[t(Ae,{initialValue:e.label,disabled:c}),t(K,{size:"large",label:"URL",helperText:S??s(x,{children:["This URL must be publicly available. ",t(va,{})]}),error:!!S,htmlType:"url",defaultValue:e.url,...d("url",{required:{value:!0,message:"Webhook URL is required"},validate:{httpUrlValidation:St}}),disabled:c}),t(K,{size:"large",label:"Headers (Optional)",helperText:f??"Stringified JSON object with key values for POST call headers.",error:!!f,...d("headers",{validate:{jsonValidation:ga}}),placeholder:'e.g. {"X-api-key":"tough-key"}',defaultValue:e.headers,disabled:c}),t(kt,{hook:e,disabled:c})]}),t(we,{hookId:e.hookId,loading:l})]})})})}),Ia=$(({hook:e,project:n})=>{var y,I,N;const r=L(n.orgId),[i,,{setSwitchTrue:a}]=He(),{toast:l}=U(),[o,{loading:d}]=Ar(),u=J({mode:"onChange"}),{register:h,handleSubmit:p,formState:{errors:c}}=u;async function S(M){try{const _={...M,hookId:e.hookId,integrationId:e.integrationId??null,projectId:n.projectId,label:M.label??null};await o({variables:{input:_},update:Ee(l,"updateGithubHook")})}catch(_){l.error({title:_.toString()})}}const f=!r||d,m=(y=c.url)==null?void 0:y.message,v=(I=c.githubToken)==null?void 0:I.message,b=(N=c.githubContext)==null?void 0:N.message;return t(re,{...u,children:t("form",{onSubmit:p(S),children:s(ve,{level:1,padding:"none",children:[s("div",{className:It,children:[t(Ae,{initialValue:e.label,disabled:f}),t(K,{size:"large",label:"URL",helperText:m??s(x,{children:["GitHub repository URL, e.g. https://github.com/nasa/space-shuttle."," ",t(ya,{})]}),error:!!m,htmlType:"url",...h("url",{required:{value:!0,message:"Github repository URL is required"},validate:{githubUrlValidation:ma}}),defaultValue:e.url,disabled:f}),e.githubToken&&!i&&t(ln,{label:"GitHub Token",description:"Using saved GitHub token.",onReset:a}),(!e.githubToken||i)&&t(Be,{size:"large",label:"GitHub Token",helperText:v??s(x,{children:["Your private GitHub token with ",t(tt,{children:"repo:status"})," ","permissions."," ",t(V,{icon:!0,target:"_blank",rel:"noopener noreferrer",href:"https://github.com/settings/tokens/new?scopes=repo&description=currents.dev",children:"Create One"})]}),error:!!v,autoComplete:"new-password",revealLabel:"GitHub token",
2id:"new-password",...h("githubToken",{required:{value:!0,message:"GitHub token is required"}}),defaultValue:"",disabled:f}),t(K,{size:"large",label:"Status Label (Optional)",helperText:b??'GitHub status label. Default value is "currents.dev".',error:!!b,name:"githubContext",defaultValue:e.githubContext,disabled:f})]}),t(we,{hookId:e.hookId,loading:d})]})})})}),Sa=g.lazy(()=>Wt(()=>import("./hookFilterTester-BVx1KuAL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),ka=({control:e,hook:n,isAdmin:r,errors:i,filterTester:a})=>{var o;const l=(o=i.tagsFilter)==null?void 0:o.message;return s("div",{className:Te,children:[t(Ge,{children:"Filters"}),s("div",{className:"flex flex-col items-start gap-ui-v2-2",children:[t(K,{size:"large",label:"Tags Filter (optional)",helperText:l??s(x,{children:["Trigger notifications only for tagged runs, with at least one tag matching the filter."," ",t(V,{icon:!0,target:"_blank",rel:"noopener noreferrer",href:"https://currents.dev/readme/integrations/ms-teams",children:"Guide"})]}),error:!!l,className:"w-full",defaultValue:n.tagsFilter,htmlType:"text",...e.register("tagsFilter",{maxLength:{value:64,message:"Tags filter can't be longer than 64 characters"}}),disabled:!r}),a]})]})},xa=$(({hook:e,project:n})=>{var y;const r=L(n.orgId),{toast:i}=U(),[a,{loading:l}]=wr(),o=J({mode:"onChange",defaultValues:{url:e.url,failedOnly:!!e.failedOnly,hookEvents:e.hookEvents,label:e.label,tagsFilter:e.tagsFilter??""}}),{register:d,handleSubmit:u,formState:{errors:h},control:p,watch:c}=o,S=c("failedOnly"),f=c("tagsFilter"),m=g.useMemo(()=>t(g.Suspense,{fallback:t(x,{}),children:t(Sa,{tagsFilter:f,integrationName:"MS Teams"})}),[f]);async function v(I){const N=Xt(I,["url","failedOnly","hookEvents","label","tagsFilter"]),M={projectId:n.projectId,hookId:e.hookId,integrationId:e.integrationId??null,failedOnly:N.failedOnly??e.failedOnly??!1,hookEvents:N.hookEvents??e.hookEvents,url:N.url??e.url,label:N.label??null,tagsFilter:N.tagsFilter??e.tagsFilter??null};try{await a({variables:{input:M},update:Ee(i,"updateMSTeamsHook")}),o.reset(I)}catch(_){i.error({title:_.toString()})}}const b=(y=h.url)==null?void 0:y.message;return t(re,{...o,children:t("form",{onSubmit:u(v),children:s(ve,{level:1,padding:"none",children:[s("div",{className:sn,children:[s("div",{className:Te,children:[t(Ae,{initialValue:e.label,disabled:!r}),t(Be,{size:"large",label:"MS Teams Webhook URL",helperText:b??s(x,{children:["Incoming Webhook URL, e.g. https://currents463.webhook.office.com/webhookb2/xxx/yyy."," ",t(V,{icon:!0,target:"_blank",rel:"noopener noreferrer",href:"https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook",children:"Guide"})]}),error:!!b,revealLabel:"webhook URL",defaultRevealed:!0,defaultValue:e.url,...d("url",{required:{value:!0,message:"MS Teams Webhook URL is required"},validate:{httpUrlValidation:St}}),disabled:!r}),t(w,{name:"failedOnly",control:p,defaultValue:!!e.failedOnly,render:({field:I})=>t(O,{title:"Notify Only About Failed Runs",description:"Enabling will only notify MS Teams about failed and timed out runs",value:!!I.value,disabled:!r,onChange:I.onChange})}),!S&&t(kt,{hook:e,disabled:!r||l})]}),t(ka,{control:p,hook:e,isAdmin:r,errors:h,filterTester:m})]}),t(we,{hookId:e.hookId,loading:l})]})})})}),Aa=g.lazy(()=>Wt(()=>import("./hookFilterTester-BVx1KuAL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),wa=({formMethods:e,hook:n,isAdmin:r,errors:i})=>{var l;const a=(l=i.url)==null?void 0:l.message;return s("div",{className:Te,children:[t(Ge,{children:"Details"}),t(Ae,{initialValue:n.label,disabled:!r}),t(Be,{size:"large",label:"Slack Webhook URL",helperText:a??s(x,{children:["Incoming Webhook URL, e.g. https://hooks.slack.com/services/XXX/YYY/ZZZ."," ",t(V,{icon:!0,target:"_blank",rel:"noopener noreferrer",href:"https://api.slack.com/messaging/webhooks",children:"Guide"})]}),error:!!a,revealLabel:"webhook URL",defaultRevealed:!0,defaultValue:n.url,...e.register("url",{required:{value:!0,message:"Slack Webhook URL is required"},validate:{httpUrlValidation:St}}),disabled:!r})]})}
2,Ta=({control:e,hook:n,isAdmin:r,errors:i,filterTester:a})=>{var d,u;const l=(d=i.branchFilter)==null?void 0:d.message,o=(u=i.tagsFilter)==null?void 0:u.message;return s("div",{className:Te,children:[t(Ge,{children:"Filters"}),t(K,{size:"large",label:"Branch Name Filter (optional)",helperText:l??s(x,{children:["Trigger notifications only for branch names matching the filter."," ",t(V,{icon:!0,target:"_blank",rel:"noopener noreferrer",href:"https://currents.dev/readme/integrations/slack#how-to-enable-slack-integration-for-cypress-tests",children:"Guide"})]}),error:!!l,defaultValue:n.branchFilter,htmlType:"text",...e.register("branchFilter",{maxLength:{value:64,message:"Branch name filter can't be longer than 64 characters"}}),disabled:!r}),s("div",{className:"flex flex-col items-start gap-ui-v2-2",children:[t(K,{size:"large",label:"Tags Filter (optional)",helperText:o??s(x,{children:["Trigger notifications only for tagged runs, with at least one tag matching the filter."," ",t(V,{icon:!0,target:"_blank",rel:"noopener noreferrer",href:"https://currents.dev/readme/integrations/slack#how-to-enable-slack-integration-for-cypress-tests",children:"Guide"})]}),error:!!o,className:"w-full",defaultValue:n.tagsFilter,htmlType:"text",...e.register("tagsFilter",{maxLength:{value:64,message:"Tags filter can't be longer than 64 characters"}}),disabled:!r}),a]})]})},Ea=({control:e,hook:n,isAdmin:r,loading:i,failedOnly:a})=>s("div",{className:Te,children:[t(Ge,{children:"Settings"}),t(w,{name:"failedOnly",control:e,defaultValue:!!n.failedOnly,render:({field:l})=>t(O,{title:"Only Failed Runs",description:"Enabling will only notify Slack about failed runs",value:l.value,disabled:!r,onChange:l.onChange})}),t(w,{name:"singleNotification",control:e,defaultValue:!!n.singleNotification,render:({field:l})=>t(O,{title:"Single Notification for all groups",description:"Enabling will notify Slack once per run event, regardless of the number of groups",value:l.value,disabled:!r,onChange:l.onChange})}),t(kt,{failedOnly:!!a,hook:n,disabled:!r||i})]}),Na=$(({hook:e,project:n})=>{const r=L(n.orgId),{toast:i}=U(),[a,{loading:l}]=Tr(),o=J({mode:"onChange",defaultValues:{url:e.url,failedOnly:!!e.failedOnly,singleNotification:!!e.singleNotification,hookEvents:e.hookEvents,branchFilter:e.branchFilter??"",tagsFilter:e.tagsFilter??"",label:e.label??""}}),{handleSubmit:d,formState:{errors:u},control:h,watch:p}=o,c=p("failedOnly"),S=p("tagsFilter"),f=g.useMemo(()=>t(g.Suspense,{fallback:t(x,{}),children:t(Aa,{tagsFilter:S,integrationName:"Slack"})}),[S]);async function m(v){const b=Xt(v,["url","failedOnly","singleNotification","hookEvents","branchFilter","tagsFilter","label"]),y={projectId:n.projectId,hookId:e.hookId,integrationId:e.integrationId??null,failedOnly:b.failedOnly??e.failedOnly??!1,singleNotification:b.singleNotification??e.singleNotification??!1,hookEvents:b.hookEvents??e.hookEvents,url:b.url??e.url,branchFilter:b.branchFilter??e.branchFilter??null,tagsFilter:b.tagsFilter??e.tagsFilter??null,label:b.label??e.label??null};try{await a({variables:{input:y},update:Ee(i,"updateSlackHook")})}catch(I){i.error({title:I.toString()})}}return t(re,{...o,children:t("form",{onSubmit:d(m),children:s(ve,{level:1,padding:"none",children:[s("div",{className:sn,children:[t(wa,{formMethods:o,hook:e,isAdmin:r,errors:u}),t(Ea,{control:h,hook:e,isAdmin:r,loading:l,failedOnly:!!c}),t(Ta,{control:h,hook:e,isAdmin:r,errors:u,filterTester:f})]}),t(we,{hookId:e.hookId,loading:l})]})})})}),_a=({hook:e})=>s("div",{className:"flex flex-col gap-ui-v2-4",children:[s("span",{role:"heading","aria-level":2,className:"ty-heading capitalize tracking-tight text-ui-v2-content-primary-idle",children:["Edit ",j(e.hookType)," Integration"]}),t(Ra,{hook:e})]}),Ra=({hook:e})=>s(x,{children:[_i(e)&&t(Ia,{hook:e}),Ei(e)&&t(Ca,{hook:e}),Ni(e)&&t(Na,{hook:e}),Ri(e)&&t(fa,{hook:e}),Li(e)&&t(xa,{hook:e})]}),cn=ne.createContext({installation:null,loading:!1}),xt=()=>ne.useContext(cn),dn=({children:e})=>{const n=Y(),{installations:r,loading:i}=Er({orgId:n.project.orgId}),a=g.useMemo(()=>Nr(r),[r]),l=g.useMemo(()=>a?new _r(a):null,[a]);return t(cn.Provider,{value:{installation:l,loading:i},children:e})},La="Only organization admins can perform this action.";function At({isAdmin:e,disabled:n,loading:r=!1,leftIcon:i,...a}){const o=t(k,{...a,disabled:n||!e,loading:r,leftIcon:i});return e?o:s(dt,{children:[t(ot,{asChild:!0,children:t("span",{className:"inline-flex",children:o})}),t(ct,{children:La})]})}const un="linear_setup",hn="linear_done",Oa="noopener,noreferrer,width=600,height=800",Pa="Unable to start Linear c
2onnection. Please try again.",Va="Unable to start Linear connection.",Da="Linear connected successfully",Ha="Linear re-authenticated successfully";let ue=null,$e=null;function Ma(){$e||($e=new BroadcastChannel(un),$e.onmessage=e=>{e.data!==hn||!ue||(se.success({title:ue}),ue=null)})}function pn(){const[e,{loading:n}]=Rr({fetchPolicy:"network-only"});return{startConnection:g.useCallback(({orgId:i,projectId:a,installationId:l})=>(ue=l!==null?Ha:Da,Ma(),e({variables:{input:{orgId:i,projectId:a,installationId:l}}}).then(({data:o})=>{var u;const d=(u=o==null?void 0:o.linearInstallationRequest)==null?void 0:u.url;if(!d){ue=null,se.error({title:Pa});return}window.open(d,"_blank",Oa)}).catch(o=>{ue=null,se.error({title:o.message??Va})})),[e]),loading:n}}const Ua=({orgId:e,projectId:n})=>{const r=L(e),{startConnection:i,loading:a}=pn();return s(Se,{children:[t(lt,{children:t(Ct,{height:32,width:32})}),t(ke,{children:t(R,{children:"Connect Currents Linear App to Workspace"})}),t(xe,{children:t(At,{isAdmin:r,type:"accent",size:"large",loading:a,onClick:()=>i({orgId:e,projectId:n,installationId:null}),children:"Connect Linear App"})})]})},ja=()=>({enabled:!0});function mn({installationId:e}){const[n,{loading:r}]=Lr({update(a,l){var o;(o=l.data)!=null&&o.upsertLinearProjectSettings&&a.modify({id:a.identify({__typename:"LinearInstallation",id:e}),fields:{projectSettings:(d=[])=>{const u=a.identify({__typename:"LinearProjectSettings",id:l.data.upsertLinearProjectSettings.id});return!u||d.some(h=>h.__ref===u)?d:[{__ref:u},...d]}}})}});return{upsertLinearProjectSettings:async(a,l)=>{const{showSuccessToast:o=!0,successMessage:d="Configuration saved"}=l??{};return n({variables:{input:a},onCompleted:()=>{o&&se.success({title:d})},onError:u=>{se.error({title:u.message})}})},loading:r}}const Ga={dialogTitle:"Disconnect Linear App?",dialogDescription:"This will revoke all Linear permissions and disable the integration for all projects using this installation. You can reinstall the app at any time."},Ba="Linear app successfully disconnected",Fa="Unable to disconnect Linear.",$a=({installation:e,projectId:n,orgId:r})=>{const{startConnection:i,loading:a}=pn();return t(k,{type:"secondary",loading:a,onClick:()=>i({orgId:r,projectId:n,installationId:e.installation.id}),children:"Re-authenticate"})},za=({installation:e,orgId:n,onDisconnect:r})=>{const[i,{loading:a}]=Or({variables:{input:{orgId:n,installationId:e.installation.id}},refetchQueries:["LinearInstallationList"],awaitRefetchQueries:!0,onCompleted:l=>{se.success({title:l.uninstallLinearApp.message||Ba}),r==null||r()},onError:l=>{se.error({title:l.message??Fa})}});return t(Qt,{...Ga,loading:a,onDisconnect:async()=>{a||await i()}})},Ka=({installation:e,projectId:n,children:r,onDisconnect:i,showDisconnect:a=!1})=>{const{orgId:l,archivedAt:o}=e.installation;return t(en,{icon:Ct,orgId:l,archivedAt:o,projectStatus:e.getProjectStatus(n),showDisconnect:a,reauthButton:t($a,{installation:e,projectId:n,orgId:l}),disconnectButton:t(za,{installation:e,orgId:l,onDisconnect:i}),children:r})},We=({installation:e,projectId:n,children:r,showDisconnect:i=!1,onDisconnect:a})=>t(le,{children:t(Ka,{installation:e,projectId:n,showDisconnect:i,onDisconnect:a,children:r})}),qa=({orgId:e,projectId:n,installation:r})=>{const i=L(e),a=r.getProjectSetting(n),{upsertLinearProjectSettings:l,loading:o}=mn({installationId:r.installation.id});return a?s(x,{children:[t(We,{installation:r,projectId:n,showDisconnect:!0}),t(Xa,{orgId:e,projectId:n,installation:r.installation,linearProjectSettings:a})]}):s(x,{children:[t(We,{installation:r,projectId:n,showDisconnect:!0}),s(Se,{children:[t(ke,{children:"Linear is connected for your organization, but not set up for this project yet."}),t(xe,{children:t(At,{isAdmin:i,type:"accent",size:"large",loading:o,onClick:async()=>{try{await l({projectId:n,orgId:e,installationId:r.installation.id,...ja()},{successMessage:"Linear enabled for this project"})}catch{}},children:"Enable for this project"})})]})]})},Xa=({orgId:e,projectId:n,installation:r,linearProjectSettings:i})=>{const a=L(e),{upsertLinearProjectSettings:l,loading:o}=mn({installationId:r.id}),d=J({mode:"onChange",defaultValues:{enabled:i.settings.enabled}}),{control:u,handleSubmit:h,reset:p,formState:{isDirty:c,isValid:S}}=d,f=!a;g.useEffect(()=>{p({enabled:i.settings.enabled},{keepDirtyValues:!0})},[i.settings.enabled,i.settings.id,p]);const{UnsavedChangesPrompt:m}=bt({isDirty:c});return s(re,{...d,children:[t(m,{}),t("form",{id:"linear-integration-form",onSubmit:f?b=>b.preventDefault():h(async b=>{try{await l({projectId:n,orgId:e,installationId:r.id,enabled:b.enabled}),p(b)}catch{}}),children:s("div",{className:"space-y-ui-v2-4",children:[t(P,{h:4}),t("div",{className:"flex flex-col gap-6 pt-6",children:t(w,{name:"enabled",control:u,render:({field:b})=>t(O,{title:"Enable Linear Integration",description:"Enable or disable Linear integration for this project",value:!!b.value,onChange:f?()=>{}:b.onChange,disabled:f})})}),t("div",{className:"flex justify-end py-6",children:t(At,{isAdmin:a,type:"accent",size:"large",htmlType:"submit",disabled:!c||!S,loading:o,children:"Save Configuration"})})]})})]})};function Wa(){g.useEffect(()=>{const e=new BroadcastChannel(un);return e.postMessage(hn),()=>e.close()},[])}const Ja=$(({project:e})=>{const{path:n}=je(),{installation:r}=xt();return s(ut,{children:[t(me,{path:`${n}/success`,children:t(Ya,{})}),t(me,{path:n,children:r?t(qa,{orgId:e.orgId,projectId:e.projectId,installation:r}):t(Ua,{orgId:e.orgId,projectId:e.projectId})})]})});function Ya(){return Wa(),s(ht,{className:"flex flex-col gap-6",children:["Congratulations! Linear authorization is complete. You can close this window.",t(k,{onClick:()=>window.close(),children:"Close Window"})]})}const gn=ne.createContext({installation:null,loading:!1}),wt=()=>ne.useContext(gn),fn=({children:e})=>{const n=Y(),{installations:r,loading:i}=yi({orgId:n.project.orgId,projectId:n.project.projectId}),a=g.useMemo(()=>r!=null&&r[0]?new Za(r==null?void 0:r[0]):null,[r]);return t(gn.Provider,{value:{installation:a,loading:i},children:e})};class Za{constructor(n){Lt(this,"projectSettings");this.installation=n,this.projectSettings=this.installation.projectSettings.map(r=>new Qa(r))}getInstallationHealth(){return{isAuthenticated:Ot(this.installation.expiresAfter)>new Date,archivation:this.installation.archivedAt?{archivedAt:Ot(this.installation.archivedAt),archivedBy:this.installation.archivedBy}:null}}getProjectStatus(n){const r=[],i=o=>{r.push({code:o,message:es[o]})};this.getInstallationHealth().isAuthenticated||i("credentialsExpired"),this.installation.archivedAt&&i("installationArchived");const a=this.getProjectSetting(n);if(!a)i("missingProjectSettings");else{const o=a.getEnablement();o.enabled||i("projectDisabled"),o.allDestinationsHaveChannels||i("missingChannels"),o.allDestinationsDisabled&&i("allDestinationsDisabled")}const l=r.length===0;return{healthy:l,text:l?"Slack App is active and configured for this project":r[0].message,issues:r}}getProjectSetting(n){return this.projectSettings.find(r=>r.settings.projectId===n)}}class Qa{constructor(n){this.settings=n}getEnablement(){const n=this.settings.destinations,r=Array.isArray(n)&&n.length>0;return{enabled:this.settings.enabled,allDestinationsHaveChannels:r&&n.every(i=>!!i.channelId),allDestinationsDisabled:r&&n.every(i=>!i.enabled)}}getEnablementText(){const n=this.getEnablement();return n.enabled?n.allDestinationsHaveChannels?n.allDestinationsDisabled?"All destinations are disabled":"Enabled":"Channels not configured":"Disabled"}}const es={credentialsExpired:"Slack App credentials expired. Re-authenticate to resume notifications.",installationArchived:"Slack App is archived. Restore or reinstall it to resume notifications.",missingProjectSettings:"Slack App is installed but not configured for this project.",projectDisabled:"Notifications are disabled for this project.",missingChannels:"Some destinations do not have a channel selected.",allDestinationsDisabled:"All destinations are disabled."},ts=({orgId:e,projectId:n})=>{const r=L(e),[i,{loading:a}]=Jt({fetchPolicy:"network-only"});return s(Se,{children:[t(lt,{children:t(vt,{height:32,width:32})}),t(ke,{children:t(R,{children:"Connect Currents Slack App to Workspace"})}),t(xe,{children:t(k,{type:"accent",size:"large",disabled:!r,loading:a,onClick:()=>i({variables:{input:{orgId:e,projectId:n,installationId:null}}}).then(({data:l})=>{var o;window.open((o=l==null?void 0:l.slackInstallationRequest)==null?void 0:o.url,"_blank","noopener,noreferrer,width=600,height=800")}),children:"Connect Slack App"})})]})};function Tt(e=16){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=new Uint8Array(e);return crypto.getRandomValues(r),Array.from(r,i=>n[i%n.length]).join("")}const G={channelId:"",channelName:"",useThreads:!0,enabled:!0,runOutcome:{enabled:!0,events:[Ve.RunCanceled,Ve.RunTimeout],mode:"always",notifyOnRecovery:!1,filters:{combinator:"and",conditions:[]}},testResults:{enabled:!1,annotationEnabled:!1,outcome:["failed","flaky"],mentionRules:[],filters:{combinator:"and",conditions:[]}}},ns=()=>({enabled:!0,destinations:[bn(Tt())]});function bn(e){return{id:e,...G,runOutcome:{...G.runOutcome,events:[...G.runOutcome.events],filters:{combinator:"and",conditions:[]}},testResults:{...G.testResults,outcome:[...G.testResults.outcome],mentionRules:[],filters:{combinator:"and",conditions:[]}}}}
2const rs=({value:e,onChange:n,placeholder:r="Enter value",disabled:i=!1})=>t(z,{value:e??"",onChange:a=>n(a.target.value),placeholder:r,disabled:i,width:"100%"}),is=({value:e,onChange:n,placeholder:r="Enter number",disabled:i=!1,allowDecimals:a=!0})=>{const l=o=>{const d=o.target.value;if(d===""){n("");return}(a?/^-?\d*\.?\d*$/:/^-?\d*$/).test(d)&&n(d)};return t(z,{htmlType:"number",value:e!==void 0?String(e):"",onChange:l,placeholder:r,disabled:i,width:"100%",step:a?"any":"1"})},as=({value:e,onChange:n,placeholder:r="Enter number",disabled:i=!1})=>{const a=o=>{n({...e??{},min:o.target.value?Number(o.target.value):void 0})},l=o=>{n({...e??{},max:o.target.value?Number(o.target.value):void 0})};return s("div",{className:"flex items-center gap-2",children:[t(z,{htmlType:"number",value:(e==null?void 0:e.min)!==void 0?String(e.min):"",onChange:a,placeholder:r,disabled:i,width:"100%"}),t("span",{className:"text-sm text-theme-foreground",children:"to"}),t(z,{htmlType:"number",value:(e==null?void 0:e.max)!==void 0?String(e.max):"",onChange:l,placeholder:r,disabled:i,width:"100%"})]})},Je=({value:e,onChange:n,placeholder:r="Type a value and press Enter",disabled:i=!1})=>t(pt,{values:e??[],onChange:a=>n(a),placeholder:r,disabled:i,maxVisibleBadges:3}),ss=({value:e,onChange:n,placeholder:r="Type a number and press Enter",disabled:i=!1,allowDecimals:a=!0})=>{const l=ne.useMemo(()=>e?e.map(d=>String(d)):[],[e]);return t(pt,{values:l,onChange:d=>{const u=a?/^-?\d*\.?\d*$/:/^-?\d*$/,h=d.map(p=>{const c=p.trim();return c===""?null:u.test(c)?a?parseFloat(c):parseInt(c,10):null}).filter(p=>p!==null);n(h)},placeholder:r,disabled:i,maxVisibleBadges:3,valueTransformer:d=>{const u=d.trim();return u===""?"":(a?/^-?\d*\.?\d*$/:/^-?\d*$/).test(u)?u:""}})},ls=({value:e,onChange:n,placeholder:r="Enter regex pattern",disabled:i=!1,caseSensitive:a=!0,onCaseSensitiveChange:l})=>s("div",{className:"flex flex-col gap-2 w-full",children:[t(Pr,{value:e??"",onChange:d=>{n(d??"",!0)},placeholder:r,disabled:i,isRegex:!0,toggleDisabled:!0}),l&&t(Ie,{checked:a,onChange:d=>l(d.target.checked),disabled:i,label:"Case sensitive"})]}),os=({value:e,onChange:n,placeholder:r="Type a regex pattern and press Enter",disabled:i=!1,caseSensitive:a=!0,onCaseSensitiveChange:l})=>s("div",{className:"flex flex-col gap-2",children:[t(pt,{values:e??[],onChange:o=>n(o),placeholder:r,disabled:i,maxVisibleBadges:3,isRegex:!0,enableRegexToggle:!1}),l&&t(Ie,{checked:a,onChange:o=>l(o.target.checked),disabled:i,label:"Case sensitive"})]});function Ye(e){return mi(gi(e),"yyyy-MM-dd'T'HH:mm")}const cs=({value:e,onChange:n,disabled:r=!1,inclusive:i=!0,onInclusiveChange:a})=>{const l=d=>{n({...e??{},min:d.target.value||void 0})},o=d=>{n({...e??{},max:d.target.value||void 0})};return s("div",{className:"flex flex-col gap-2",children:[s("div",{className:"flex items-center gap-2",children:[t(z,{htmlType:"datetime-local",value:e!=null&&e.min?Ye(e.min):"",onChange:l,placeholder:"Min date",disabled:r,width:"100%"}),t("span",{className:"text-sm text-muted-foreground",children:"to"}),t(z,{htmlType:"datetime-local",value:e!=null&&e.max?Ye(e.max):"",onChange:o,placeholder:"Max date",disabled:r,width:"100%"})]}),a&&t(Ie,{checked:i,onChange:d=>a(d.target.checked),disabled:r,label:"Inclusive (include boundary dates)"})]})},ds=({value:e,onChange:n,disabled:r=!1})=>{const i=a=>{n(a.target.value)};return t("div",{className:"flex flex-col gap-2",children:t(z,{htmlType:"datetime-local",value:e?Ye(e):"",onChange:i,placeholder:"Date and time",disabled:r,width:"100%"})})},us=({value:e,onChange:n,disabled:r=!1})=>s(ye,{value:e===null?"":String(e),onValueChange:i=>n(i==="true"),disabled:r,children:[t(fe,{style:{width:"100%"},children:t(ge,{placeholder:"Select value"})}),s(be,{children:[t(B,{value:"true",children:"True"}),t(B,{value:"false",children:"False"})]})]}),hs=({inputType:e,right:n,onChange:r,disabled:i=!1,modifiers:a={},onModifierChange:l})=>{var u,h,p,c,S,f,m,v,b,y;const o=yt[n.type];if(!o)return null;const d=n.value;return e==="none"?null:e==="string"?t(rs,{value:d,onChange:r,disabled:i}):e==="stringArray"?t(Je,{value:Array.isArray(d)?d:[],onChange:r,disabled:i}):e==="number"?t(is,{value:d??"",onChange:r,disabled:i,allowDecimals:a.allowDecimals??((h=(u=o.modifiers)==null?void 0:u.allowDecimals)==null?void 0:h.defaultValue)??!0}):e==="numberRange"?t(as,{value:d??null,onChange:r,disabled:i}):e==="numberArray"?t(ss,{value:Array.isArray(d)?d:[],onChange:r,disabled:i,allowDecimals:a.allowDecimals??((c=(p=o.modifiers)==null?void 0:p.allowDecimals)==null?void 0:c.defaultValue)??!0}):e==="regexString"?t(ls,{value:d??"",onChange:I=>r(I),disabled:i,caseSensitive:a.caseSensitive??((f=(S=o.modifiers)==null?void 0:S.caseSensitive)==null?void 0:f.defaultValue)??!0,onCaseSensitiveChange:l?I=>l("caseSensitive",I):void 0}):e==="regexStringArray"?t(os,{value:Array.isArray(d)?d:[],onChange:r,disabled:i,caseSensitive:a.caseSensitive??((v
2=(m=o.modifiers)==null?void 0:m.caseSensitive)==null?void 0:v.defaultValue)??!0,onCaseSensitiveChange:l?I=>l("caseSensitive",I):void 0}):e==="date"?t(ds,{value:d??null,onChange:r,disabled:i}):e==="dateRange"?t(cs,{value:d??null,onChange:r,disabled:i,inclusive:a.inclusive??((y=(b=o.modifiers)==null?void 0:b.inclusive)==null?void 0:y.defaultValue)??!0,onInclusiveChange:l?I=>l("inclusive",I):void 0}):e==="boolean"?t(us,{value:d??null,onChange:r,disabled:i}):null},ps=({condition:e,availableLeftValueTypes:n,onChange:r,onRemove:i,disabled:a=!1})=>{var f;const{left:l,operator:o,right:d}=e,u=m=>{const v=n.find(I=>I.sourceType===m);if(!v)return;const y=Mt[v.valueType][0]??"exists";r({left:v,operator:y,right:{value:Z[y].defaultValue,type:Z[y].rightValueInputType}})},h=m=>{r({...e,operator:m,right:{value:Z[m].defaultValue,type:Z[m].rightValueInputType}})},p=m=>{r({...e,right:{...d,value:m}})},c=(m,v)=>{r({...e,right:{...d,modifiers:{...d.modifiers,[m]:v}}})},S=ne.useMemo(()=>yt[d.type].validate(d.value),[d.type,d.value]);return s("div",{className:"grid grid-cols-[max-content_max-content_1fr_40px] align-baseline gap-2 items-start",children:[t("div",{className:"w-full",children:s(ye,{value:l.sourceType,onValueChange:u,disabled:a,children:[t(fe,{children:t(ge,{})}),t(be,{children:n.map(({sourceType:m,label:v,description:b},y)=>s(B,{value:m,multiLine:!0,children:[t(Pt,{children:t("div",{className:"text-sm font-medium text-theme-foreground",children:v})}),t("div",{className:"text-xs mt-0.5 text-muted-foreground",children:b})]},`${m}-${y}-${v}`))})]})}),t("div",{className:"w-full",children:s(ye,{value:o,onValueChange:h,disabled:a,children:[t(fe,{children:t(ge,{})}),t(be,{children:Mt[l.valueType].map(m=>s(B,{value:m,multiLine:!0,children:[t(Pt,{children:t("div",{className:"text-sm font-medium text-theme-foreground",children:Z[m].label})}),t("div",{className:"text-xs mt-0.5 text-muted-foreground",children:Z[m].description})]},m))})]})}),s("div",{className:"w-full",children:[t(hs,{inputType:((f=Z[o])==null?void 0:f.rightValueInputType)??"none",right:d,onChange:p,disabled:a,modifiers:d.modifiers,onModifierChange:c}),t("div",{className:"text-theme-warning text-sm py-2 flex items-center gap-2 font-medium rounded-md",children:S!==!0?S.error:null})]}),i&&!a?t("div",{className:"justify-self-end",children:t(rt,{onClick:i,children:t(mt,{size:D.icon.small})})}):t("span",{})]})},yn=({value:e,onChange:n,availableLeftValueTypes:r,disabled:i=!1,showCombinator:a=!0,headerTitle:l="Conditions & Filters",headerDescription:o="Only apply when conditions match",addButtonLabel:d="Add Condition",maxConditions:u=10})=>{const{combinator:h,conditions:p}=e,c=r??[],S=b=>{n({...e,combinator:b})},f=()=>{const b=c[0],y={left:{valueType:b.valueType,sourceType:b.sourceType,label:b.label,description:b.description},operator:"exists",right:{value:void 0,type:"none"}};n({...e,conditions:[...p,y]})},m=(b,y)=>{const I=[...p];I[b]=y,n({...e,conditions:I})},v=b=>{const y=p.filter((I,N)=>N!==b);n({...e,conditions:y})};return s("div",{className:"flex flex-col gap-ui-v2-4",children:[s("div",{className:"flex items-center justify-between w-full gap-2",children:[s("div",{children:[t(ee,{className:"text-theme-foreground",children:l}),t(R,{children:o})]}),t(k,{type:"secondary",onClick:f,leftIcon:t(gt,{}),disabled:i||p.length>=u,children:d})]}),u!==void 0&&p.length>=u&&s("div",{className:"text-theme-warning text-sm py-2 flex items-center gap-2 font-medium rounded-md",children:["Maximum ",u," ",Vr("condition",u)," supported"]}),p.length>0&&s("div",{className:"flex flex-col gap-ui-v2-4",children:[a&&p.length>1&&s("div",{className:"flex items-center gap-2",children:[t(R,{children:"Match"}),s(ye,{value:h,onValueChange:S,disabled:i,children:[t(fe,{size:"sm",children:t(ge,{})}),s(be,{children:[t(B,{value:"and",children:"All (AND)"}),t(B,{value:"or",children:"Any (OR)"})]})]}),t(R,{children:"of the following conditions:"})]}),t("div",{className:"flex flex-col gap-2",children:p.map((b,y)=>t(ps,{condition:b,availableLeftValueTypes:c,onChange:I=>m(y,I),onRemove:()=>v(y),disabled:i},y))})]})]})};function ms(e){if(!(e!=null&&e.conditions)||e.conditions.length===0)return!0;for(let n=0;n<e.conditions.length;n++){const r=e.conditions[n],i=Pi(r);
2if(!i.valid){const a=i.errors.map(l=>`${l.error}${l.details?`: ${l.details}`:""}`).join(", ");return`Condition ${n+1}: ${a}`}}return!0}const gs=()=>[{sourceType:"git_branch",valueType:"string",label:"Git Branch",description:"The git branch name for the test run"},{sourceType:"git_commit_message",valueType:"string",label:"Git Commit Message",description:"The git commit message that triggered the run"},{sourceType:"tags",valueType:"array",label:"Tags",description:"The tags associated with the test run"}],vn=()=>[{sourceType:"git_branch",valueType:"string",label:"Git Branch",description:"The git branch name for the test run"},{sourceType:"git_commit_message",valueType:"string",label:"Git Commit Message",description:"The git commit message that triggered the run"},{sourceType:"tags",valueType:"array",label:"Tags",description:"The tags associated with the test"},{sourceType:"test_title",valueType:"string",label:"Test Title",description:"The title of the test"},{sourceType:"test_file_path",valueType:"string",label:"Test File Path",description:"The file path of the test"}],jt=({destinationId:e,filterKey:n,control:r,availableLeftValueTypes:i,disabled:a=!1})=>t(w,{control:r,name:`destinations.${e}.${n}`,rules:{validate:l=>ms(l)},render:({field:l})=>t(yn,{value:l.value,onChange:l.onChange,availableLeftValueTypes:i,disabled:a,headerTitle:"Conditions & Filters",headerDescription:"Only send when conditions match",addButtonLabel:"Add Condition",maxConditions:5})});function Gt(e,n){const r=Hi(e,n);return r===void 0?!0:n==="user"?`Invalid user mention "${r}". Use an email ([email protected]) or Slack user ID (user:UXXXXXXX).`:`Invalid group mention "${r}". Use a handle (@team-handle) or Slack group ID (group:SXXXXXXX).`}const fs=({fieldPath:e,disabled:n=!1})=>{const r=oe();return s("div",{className:"flex flex-col gap-ui-v2-3",children:[t(w,{control:r.control,name:`${e}.mentions.users`,defaultValue:[],rules:{validate:i=>Gt(i,"user")},render:({field:i,fieldState:a})=>{var l;return t(he,{label:"Mention Users",error:(l=a.error)==null?void 0:l.message,helpText:s("span",{children:["Enter user emails ([email protected]) or Slack user IDs (user:UXXXXXXX)."," ",t(V,{href:"https://docs.currents.dev/resources/integrations/slack/slack-app#mention-formats",icon:!0,children:"Learn more"})]}),children:t(Je,{value:i.value||[],onChange:i.onChange,placeholder:"[email protected] or user:UXXXXXXX",disabled:n})})}}),t(w,{control:r.control,name:`${e}.mentions.groups`,defaultValue:[],rules:{validate:i=>Gt(i,"group")},render:({field:i,fieldState:a})=>{var l;return t(he,{label:"Mention Groups",error:(l=a.error)==null?void 0:l.message,helpText:s("span",{children:["Enter group handles (@team-handle) or Slack group IDs (group:SXXXXXXX)."," ",t(V,{href:"https://docs.currents.dev/resources/integrations/slack/slack-app#mention-formats",icon:!0,children:"Learn more"})]}),children:t(Je,{value:i.value||[],onChange:i.onChange,placeholder:"@team-handle or group:SXXXXXXX",disabled:n})})}})]})},bs=({destinationId:e,disabled:n=!1})=>{const r=oe(),{fields:i,append:a,remove:l}=fi({control:r.control,name:`destinations.${e}.testResults.mentionRules`}),o=()=>{const u={id:Tt(),conditions:{combinator:"and",conditions:[]},mentions:{users:[],groups:[]}};a(u)},d=u=>{l(u)};return s("div",{children:[s("div",{className:"flex items-center justify-between w-full gap-2",children:[s("div",{children:[t(ee,{className:"text-theme-foreground",children:"Mention Rules"}),t(R,{children:"Mention users or groups based on configuration rules"})]}),!n&&t(k,{onClick:o,leftIcon:t(gt,{}),type:"secondary",children:"Add Rule"})]}),i.length>0&&t("div",{className:"flex flex-col gap-6 mt-6",children:i.map((u,h)=>s("div",{className:"flex flex-col gap-ui-v2-4 p-ui-v2-4 border border-theme-border rounded-lg",children:[s("div",{className:"flex items-center justify-between",children:[s("div",{className:"text-sm font-semibold text-theme-foreground",children:["Rule ",h+1]}),!n&&t(k,{onClick:()=>d(h),leftIcon:t(mt,{}),type:"danger",children:"Remove Rule"})]}),s("div",{className:"flex flex-col gap-2",children:[s(ee,{children:["Mention If"," ",s(dt,{children:[t(ot,{children:t(Dr,{size:D.icon.tiny})}),t(ct,{children:"If no conditions defined, mention all specified users and groups"})]})]}),t(w,{control:r.control,name:`destinations.${e}.testResults.mentionRules.${h}.conditions`,render:({field:p})=>t(yn,{value:p.value,onChange:p.onChange,availableLeftValueTypes:vn(),disabled:n,showCombinator:!0,headerTitle:"",headerDescription:"",addButtonLabel:"Add Condition"})})]}),t("div",{className:"flex flex-col gap-2",children:t(fs,{fieldPath:`destinations.${e}.testResults.mentionRules.${h}`,disabled:n})})]},u.id))})]})},ys=({destinationId:e,orgId:n,installationId:r,disabled:i=!1})=>{const a=oe(),l=Re({control:a.control,name:`destinations.${e}.runOutcome.enabled`}),o=Re({control:a.control,name:`destinations.${e}.testResults.enabled`}),d=Re({control:a.control,name:`destinations.${e}.runOutcome.mode`});return s("div",{className:"flex flex-col gap-8 p-ui-v2-4 rounded",children:[t(w,{control:a.control,name:`destinations.${e}.enabled`,render:({field:u})=>t(O,{title:"Enable Destination",description:"Enable or disable this destination",value:!!u.value,onChange:i?()=>{}
2:u.onChange,disabled:i})}),t(w,{name:`destinations.${e}.useThreads`,control:a.control,defaultValue:G.useThreads,render:({field:u})=>t(O,{title:"Message Threading",description:"Send messages related to the same run in a single thread. If disabled, send standalone messages.",value:!!u.value,onChange:i?()=>{}:u.onChange,disabled:i})}),t(w,{control:a.control,name:`destinations.${e}.channelId`,render:({field:u,fieldState:h})=>{var p;return t(vi,{orgId:n,installationId:r,value:{channelId:a.getValues(`destinations.${e}.channelId`),channelName:a.getValues(`destinations.${e}.channelName`)??""},onValueChange:c=>{u.onChange((c==null?void 0:c.channelId)??""),a.setValue(`destinations.${e}.channelName`,(c==null?void 0:c.channelName)??"")},error:(p=h.error)==null?void 0:p.message,disabled:i})}}),s("div",{className:"flex flex-col gap-8",children:[s("div",{className:"flex flex-col gap-8 border border-theme-accent-2 rounded bg-theme-accent-1 p-ui-v2-4",children:[t(w,{name:`destinations.${e}.runOutcome.enabled`,control:a.control,defaultValue:G.runOutcome.enabled,render:({field:u})=>t(x,{children:t(O,{title:"Send Run Notifications",description:"Send messages for the entire run",value:!!u.value,onChange:i?()=>{}:u.onChange,disabled:i})})}),l&&s(x,{children:[s("div",{className:"flex flex-col gap-2",children:[t(ee,{className:"text-theme-foreground",children:"Send Run Lifecycle Notifications"}),t("div",{className:"flex flex-col gap-2 pl-2",children:t(w,{name:`destinations.${e}.runOutcome.events`,control:a.control,defaultValue:G.runOutcome.events,render:({field:u})=>t("div",{className:"flex flex-col gap-2",children:[{value:Ve.RunCanceled,description:"Notify when a run is cancelled, reporting the known test results"},{value:Ve.RunTimeout,description:"Notify when a run times out, reporting the known test results"}].map(h=>s("div",{className:`flex items-center gap-2 text-theme-secondary 
3                                has-[:checked]:text-theme-foreground
4                                `,children:[t(Ie,{id:h.value,checked:u.value.includes(h.value),onChange:p=>{i||(p.target.checked?u.onChange([...u.value,h.value]):u.onChange(u.value.filter(c=>c!==h.value)))},disabled:i}),s(dt,{children:[t(ot,{children:t(Vt,{htmlFor:h.value,children:on(h.value)})}),t(ct,{children:h.description})]})]},h.value))})})})]}),t(w,{name:`destinations.${e}.runOutcome.mode`,control:a.control,defaultValue:G.runOutcome.mode,render:({field:u})=>s("div",{className:"flex flex-col gap-2",children:[t(ee,{className:"text-theme-foreground",children:"Send Run Results Notification"}),s(ye,{value:u.value,onValueChange:u.onChange,disabled:i,children:[t(fe,{children:t(ge,{})}),s(be,{children:[t(B,{value:"always",children:"Always send"}),t(B,{value:"failures_only",children:"Only when there are failures"}),t(B,{value:"failures_or_flaky",children:"Only when there are failed or flaky tests"}),t(B,{value:"passed_only",children:"Only when all tests are passing"})]})]}),d==="failures_only"&&t(w,{name:`destinations.${e}.runOutcome.notifyOnRecovery`,control:a.control,defaultValue:G.runOutcome.notifyOnRecovery,render:({field:h})=>s("div",{className:"flex flex-col gap-2",children:[s("div",{className:"flex items-center gap-2 text-theme-secondary has-[:checked]:text-theme-foreground",children:[t(Ie,{id:`${e}-notify-on-recovery`,checked:!!h.value,onChange:p=>{i||h.onChange(p.target.checked)},disabled:i}),t(Vt,{htmlFor:`${e}-notify-on-recovery`,children:"Notify when the branch recovers"})]}),h.value&&t(Hr,{type:"info",fullWidth:!0,description:"Recovery notifications require Git branch metadata. Runs without a branch will only notify on failure."})]})})]})}),t(jt,{destinationId:e,filterKey:"runOutcome.filters",control:a.control,disabled:i,availableLeftValueTypes:gs()})]})]}),s("div",{className:"flex flex-col gap-8 border border-theme-accent-2 rounded bg-theme-accent-1 p-ui-v2-4",children:[t(w,{name:`destinations.${e}.testResults.enabled`,control:a.control,defaultValue:G.testResults.enabled,render:({field:u})=>t(O,{title:"Send individual test notifications",description:"Notify about individual failed or flaky tests, mention users and groups",value:!!u.value,onChange:i?()=>{}
4:u.onChange,disabled:i})}),o&&s(x,{children:[s("div",{className:"flex flex-col gap-6",children:[s("div",{className:"pt-6",children:[t(ee,{children:"Notify about failed or flaky tests"}),t(Le,{className:"w-full",h:.5})]}),t(w,{name:`destinations.${e}.testResults.outcome`,control:a.control,defaultValue:G.testResults.outcome,render:({field:u})=>{const h=c=>c.includes("failed")&&c.includes("flaky")?"failed_and_flaky":c.includes("failed")?"failed":c.includes("flaky")?"flaky":"failed",p=c=>c==="failed_and_flaky"?["failed","flaky"]:c==="failed"?["failed"]:c==="flaky"?["flaky"]:["failed"];return s(ye,{value:h(u.value||["failed"]),onValueChange:c=>{i||u.onChange(p(c))},disabled:i,children:[t(fe,{children:t(ge,{})}),s(be,{children:[t(B,{value:"failed",children:"Notify if test failed"}),t(B,{value:"flaky",children:"Notify if test flaked"}),t(B,{value:"failed_and_flaky",children:"Notify if test failed or flaked"})]})]})}}),t(jt,{destinationId:e,filterKey:"testResults.filters",control:a.control,disabled:i,availableLeftValueTypes:vn()})]}),s("div",{className:"pt-6 flex flex-col gap-8",children:[s("div",{children:[t(ee,{children:"Mention users and groups"}),t(Le,{className:"w-full",h:.5})]}),t(w,{name:`destinations.${e}.testResults.annotationEnabled`,control:a.control,defaultValue:G.testResults.annotationEnabled,render:({field:u})=>t(O,{title:"Annotation Mentions",description:s("span",{children:["Mention users or groups defined in test annotations."," ",t(V,{href:"https://docs.currents.dev/resources/integrations/slack/slack-app#mention-formats",icon:!0,children:"Learn more"}),"."]}),value:!!u.value,onChange:i?()=>{}:u.onChange,disabled:i})}),t(bs,{destinationId:e,disabled:i})]})]})]})]})]})},vs=({destinationId:e,onRemove:n,canRemove:r,orgId:i,installationId:a,disabled:l=!1})=>{const[o,d]=g.useState(!1),u=oe(),h=u.watch(`destinations.${e}`),{shouldAllowClose:p}=bt({isDirty:u.formState.isDirty});return s(qr,{open:o,onOpenChange:S=>{!S&&!p()||d(S)},children:[t(jr,{asChild:!0,children:s("div",{className:"group flex items-center justify-between gap-1 p-1 w-full bg-theme-accent-1 rounded p-ui-v2-4 hover:text-theme-foreground cursor-pointer",children:[s("div",{className:"flex items-center justify-between w-full gap-2",children:[s("div",{children:[h.channelName&&s(k,{leftIcon:t(Mr,{}),children:["#",h.channelName]}),!h.channelName&&t(k,{leftIcon:t(Ur,{}),children:"No channel selected"})]}),h.enabled?t(Ci,{type:"success",scale:D.scale.tiny,children:"Enabled"}):t(Ii,{children:"Disabled"})]}),t("div",{className:"flex items-center gap-ui-v2-4",children:!l&&r&&t(rt,{onClick:S=>{S.stopPropagation(),n()},children:t(mt,{size:D.icon.smaller})})})]})}),s(Gr,{className:"min-w-[720px] overflow-hidden",children:[s("div",{className:"flex min-h-0 flex-1 flex-col gap-ui-v2-4 overflow-y-auto",children:[s(Br,{children:[t(Fr,{children:"Edit Slack Destination"}),t($r,{children:"Change Slack destination settings. Click save when you're done."})]}),t(ys,{destinationId:e,orgId:i,installationId:a,disabled:l})]}),s(zr,{children:[t(k,{type:"accent",htmlType:"submit",form:"slack-integration-form",disabled:!u.formState.isValid||l||!u.formState.isDirty,loading:u.formState.isSubmitting,children:"Save changes"}),t(Kr,{asChild:!0,children:t(k,{type:"secondary",children:"Close"})})]})]})]})},Cs=({orgId:e,installationId:n,disabled:r=!1,maxDestinations:i})=>{const a=oe(),l=Math.max(i??10,0),o=W(),d=L(e),u=Re({control:a.control,name:"destinations"})||{},h=Object.keys(u).sort(),p=()=>{const f=Tt(),m=a.getValues("destinations")||{};a.setValue("destinations",{...m,[f]:bn(f)},{shouldDirty:!0})},c=f=>{if(h.length>1){const m=a.getValues("destinations")||{},{[f]:v,...b}=m;a.setValue("destinations",b,{shouldDirty:!0})}},S=h.length>=l;return s(T,{flexDirection:"column",gap:o.layout.gap,children:[s(T,{alignItems:"center",justifyContent:"space-between",width:"100%",children:[s("div",{children:[t(ee,{className:"text-theme-foreground",children:"Destinations"}),t(R,{children:"Configure multiple Slack channels with custom rules"})]}),t(k,{onClick:p,leftIcon:t(gt,{}
4),type:"secondary",disabled:S||!d||r,children:"Add Destination"})]}),S&&s("div",{className:"fancy-card text-theme-warning text-sm p-6 flex items-center gap-2 font-medium rounded-md",children:[t(Xr,{size:D.icon.smaller})," You can have up to"," ",l," destinations"]}),h.map(f=>t(vs,{destinationId:f,onRemove:()=>c(f),canRemove:h.length>1,orgId:e,installationId:n,disabled:r},f))]})};function Cn({installationId:e}){const{toast:n}=U(),[r,{loading:i}]=Wr({update(l,o){var d;(d=o.data)!=null&&d.upsertSlackProjectSettings&&l.modify({id:l.identify({__typename:"SlackInstallation",id:e}),fields:{projectSettings:(u=[])=>{const h=l.identify({__typename:"SlackProjectSettings",id:o.data.upsertSlackProjectSettings.id});return!h||u.some(p=>p.__ref===h)?u:[{__ref:h},...u]}}})}});return{upsertSlackSettings:async(l,o)=>{const{showSuccessToast:d=!0,successMessage:u="Configuration saved"}=o??{};return r({variables:{input:l},onCompleted:()=>{d&&n.success({title:u})},onError:h=>{n.error({title:h.message})}})},loading:i}}const Is={dialogTitle:"Disconnect Slack App?",dialogDescription:"This will revoke all Slack permissions and disable notifications for all projects using this installation. You can reinstall the app at any time."},Ss=({installation:e,projectId:n,orgId:r})=>{const[i,{loading:a,error:l}]=Jt({fetchPolicy:"network-only"});return Yt(l),t(k,{type:"secondary",loading:a,onClick:()=>i({variables:{input:{orgId:r,projectId:n,installationId:e.installation.id}}}).then(({data:d})=>{var u;window.open((u=d==null?void 0:d.slackInstallationRequest)==null?void 0:u.url,"_blank","noopener,noreferrer,width=600,height=800")}),children:"Re-authenticate"})},ks=({installation:e,orgId:n,onDisconnect:r})=>{const[i,{loading:a,error:l}]=Jr({variables:{input:{orgId:n,installationId:e.installation.id}},onCompleted:r});return Yt(l),t(Qt,{...Is,loading:a,onDisconnect:async()=>{a||await i()}})},xs=({installation:e,projectId:n,children:r,onDisconnect:i,showDisconnect:a=!1})=>{const{orgId:l,archivedAt:o}=e.installation;return t(en,{icon:vt,orgId:l,archivedAt:o,projectStatus:e.getProjectStatus(n),showDisconnect:a,reauthButton:t(Ss,{installation:e,projectId:n,orgId:l}),disconnectButton:t(ks,{installation:e,orgId:l,onDisconnect:i}),children:r})},Ze=({installation:e,projectId:n,children:r,showDisconnect:i=!1})=>t(le,{children:t(xs,{installation:e,projectId:n,showDisconnect:i,children:r})}),As=({orgId:e,projectId:n,installation:r})=>{const i=r.getProjectSetting(n),{upsertSlackSettings:a,loading:l}=Cn({installationId:r.installation.id});return i?s(x,{children:[t(Ze,{installation:r,projectId:n,showDisconnect:!0}),t(ws,{orgId:e,projectId:n,installation:r.installation,slackProjectSettings:i})]}):s(x,{children:[t(Ze,{installation:r,projectId:n,showDisconnect:!0}),s(Se,{children:[t(ke,{children:"Slack Notifications are disabled for this project."}),t(xe,{children:t(k,{type:"accent",size:"large",loading:l,onClick:async()=>{try{await a({projectId:n,orgId:e,installationId:r.installation.id,...ns()},{showSuccessToast:!1})}catch{}},children:"Enable Notifications"})})]})]})},ws=({orgId:e,projectId:n,installation:r,slackProjectSettings:i})=>{const a=L(e),{upsertSlackSettings:l,loading:o}=Cn({installationId:r.id}),d=J({mode:"onChange",defaultValues:{enabled:i.settings.enabled,destinations:i.settings.destinations}}),{control:u,handleSubmit:h,formState:p,reset:c}=d,S=!a,{UnsavedChangesPrompt:f}=bt({isDirty:p.isDirty});return s(re,{...d,children:[t(f,{}),t("form",{id:"slack-integration-form",onSubmit:S?v=>v.preventDefault():h(async v=>{try{await l({projectId:n,orgId:e,installationId:r.id,enabled:v.enabled,destinations:Object.values(v.destinations)}),c(v)}catch{}}),children:s("div",{className:"space-y-ui-v2-4",children:[t(P,{h:4}),s("div",{className:"flex flex-col gap-6 pt-6",children:[t(w,{name:"enabled",control:u,defaultValue:!0,render:({field:v})=>t(O,{title:"Enable Slack Notifications",description:"Enable or disable Slack notifications for this project",value:!!v.value,onChange:S?()=>{}:v.onChange,disabled:S})}),t(Cs,{orgId:e,installationId:r.id,disabled:S,maxDestinations:i.settings.maxDestinations})]}),t("div",{className:"flex justify-end py-6",children:t(k,{type:"accent",size:"large",htmlType:"submit",disabled:!p.isDirty||!p.isValid||!a,loading:o,children:"Save Configuration"})})]})})]})},Ts=$(({project:e})=>{const{path:n}=je(),{installation:r}=wt();return t(De,{children:s(ut,{children:[t(me,{path:`${n}/success`,children:s(ht,{className:"flex flex-col gap-6",children:["Congratulations! You have successfully installed Currents Slack App!",t(k,{type:"secondary",onClick:()=>window.close(),children:"Close Window"})]})}),t(me,{path:[`${n}/destination/:destinationId`,n],children:r?t(As,{orgId:e.orgId,projectId:e.projectId,installation:r}):t(ts,{orgId:e.orgId,projectId:e.projectId})})]})})}),Es=()=>{const{integrationId:e}=je().params,r=Y().project.hooks.find(a=>a.hookId===e);return r?t(De,{children:t(_a,{hook:r})}
4):["github","gitlab","jira","slack","linear","assistant"].some(a=>a===e)?t("div",{children:s(De,{children:[e==="github"&&t(oa,{}),e==="gitlab"&&t(zi,{}),e==="jira"&&t(bi,{}),e==="slack"&&t(fn,{children:t(Ts,{})}),e==="linear"&&t(dn,{children:t(Ja,{})}),e==="assistant"&&t(Qi,{})]})}):s("div",{children:[t(qi,{}),t(P,{h:1}),s(ht,{children:[t(P,{h:2}),t("h3",{children:"Integration not found"}),t("p",{children:"The requested integration does not exist or has been removed from the project."})]})]})},Ns=({hook:e})=>{const n=W();return s(le,{children:[s(T,{gap:n.layout.gapHalf,alignItems:"center",className:"min-w-0",children:[t("span",{className:"shrink-0",children:t(F,{hookType:e.hookType})}),t(Yr,{children:t(R,{span:!0,children:ha(e)})})]}),t(te,{hookId:e.hookId})]})},_s=X(({org:e})=>{var i;const n=W();if(e.jiraInstallations&&((i=e.jiraInstallations)==null?void 0:i.length)>0){const a=(e.jiraInstallations??[]).some(l=>l.status!==Zr.Active);return s(le,{children:[s(T,{alignItems:"center",gap:n.layout.gapHalf,className:"min-w-0",children:[t(Xe,{height:16,width:16,className:"shrink-0"}),a&&t(Qr,{text:"Some Jira installations are inactive. Please check the configuration.",children:t(Ue,{className:"shrink-0",color:n.palette.warning})}),t(R,{span:!0,className:"min-w-0 truncate",children:"Jira App"})]}),t(te,{hookId:"jira",label:"Configure"})]})}return s(le,{children:[t(Xe,{height:16,width:16,className:"shrink-0"}),t(te,{hookId:"jira",label:"Link Jira App"})]})}),Rs=e=>g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"41 43 172 172",...e},g.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M195.9 107.8c-2.84-27.64-18.85-62.98-60.73-64.4h-3.09c-29.9 0-52.18 21.88-56.84 52.31c-2.68 9.26-2.46 20.79-4.86 35.12c-2.48 14.9-7.38 20.23-10.77 28.96c-1.88 5.11-1.19 17.58 10.84 18.65c6.63.59 14.92-2.78 15.03-3.96c-2.25 4.59-5.08 12.84-4.78 19.82c.6 11.64 8.71 17.78 21.25 17.78c14.07 0 24.1-8.4 30.32-12.14c3.01 7.78 6.93 12.14 14.41 12.14c13.02 0 27.47-13.13 33.84-23.58c11.19-19.55 18.26-42.4 16.17-71.32c-.08-2.87-.35-6.08-.79-9.38M135.1 90.55c-7.28-.54-7.85 8.36-7.85 14.05c0 6.08 1.6 13.14 7.96 13.14c6.6 0 8.92-8.08 8.92-13.14c0-5.56-1.59-14.05-9.03-14.05m29.3 0c-7.27-.54-8.66 7.59-8.66 14.05c0 5.82 1.51 13.14 8.07 13.14c7.38 0 8.83-9.57 8.83-13.14c0-5.89-2.01-14.05-8.24-14.05"})),Ls=e=>g.createElement("svg",{width:228,height:120,viewBox:"0 0 228 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},g.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M204 48C192.817 48 183.42 40.3514 180.756 30H153.248C147.382 30 142.376 34.241 141.412 40.0272L140.425 45.9456C139.489 51.5648 136.646 56.4554 132.626 60C136.646 63.5446 139.489 68.4352 140.425 74.0544L141.412 79.9728C142.376 85.759 147.382 90 153.248 90H156.756C159.42 79.6486 168.817 72 180 72C193.255 72 204 82.7452 204 96C204 109.255 193.255 120 180 120C168.817 120 159.42 112.351 156.756 102H153.248C141.516 102 131.504 93.5181 129.575 81.9456L128.588 76.0272C127.624 70.241 122.618 66 116.752 66H107.244C104.58 76.3514 95.183 84 84 84C72.817 84 63.4204 76.3514 60.7561 66H47.2439C44.5796 76.3514 35.183 84 24 84C10.7452 84 0 73.2548 0 60C0 46.7452 10.7452 36 24 36C35.183 36 44.5796 43.6486 47.2439 54H60.7561C63.4204 43.6486 72.817 36 84 36C95.183 36 104.58 43.6486 107.244 54H116.752C122.618 54 127.624 49.759 128.588 43.9728L129.575 38.0544C131.504 26.4819 141.516 18 153.248 18L180.756 18C183.42 7.64864 192.817 0 204 0C217.255 0 228 10.7452 228 24C228 37.2548 217.255 48 204 48ZM204 36C210.627 36 216 30.6274 216 24C216 17.3726 210.627 12 204 12C197.373 12 192 17.3726 192 24C192 30.6274 197.373 36 204 36ZM24 72C30.6274 72 36 66.6274 36 60C36 53.3726 30.6274 48 24 48C17.3726 48 12 53.3726 12 60C12 66.6274 17.3726 72 24 72ZM96 60C96 66.6274 90.6274 72 84 72C77.3726 72 72 66.6274 72 60C72 53.3726 77.3726 48 84 48C90.6274 48 96 53.3726 96 60ZM192 96C192 102.627 186.627 108 180 108C173.373 108 168 102.627 168 96C168 89.3726 173.373 84 180 84C186.627 84 192 89.3726 192 96Z",fill:"#EA4B71"})),Os=e=>g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},g.createElement("path",{fill:"currentColor",d:"M23.15 2.587L18.21.21a1.49 1.49 0 0 0-1.705.29l-9.46 8.63l-4.12-3.128a1 1 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12L.326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a1 1 0 0 0 1.276.057l4.12-3.128l9.46 8.63a1.49 1.49 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352m-5.146 14.861L10.826 12l7.178-5.448z"}));function Ps(e){const n=e.replace(/[\r\n\u2028\u2029]+/g," ").trim(),r
4=Math.max(0,...[...n.matchAll(/`+/g)].map(l=>l[0].length)),i="`".repeat(r+1),a=n.startsWith("`")||n.endsWith("`")?` ${n} `:n;return`${i}${a}${i}`}function Vs({origin:e,orgId:n,projectId:r,projectName:i}){const a=`${e}${ti(n)}`,l=Ps(i);return["Set up the Currents MCP server for this repository, so you can read our CI test results from Currents while working on tests.","","## Steps","",`1. Find a Currents API key: use \`CURRENTS_API_KEY\` from the environment if it is already set, otherwise ask me for one. Keys live at ${a}, which only an org admin can open — if I am not one, I get a key from an admin. Do not invent a key, and do not commit one.`,"2. Register the server with the agent runtime this repository uses.","","   Claude Code:","","   ```bash","   claude mcp add --transport stdio currents --env CURRENTS_API_KEY=$CURRENTS_API_KEY -- npx -y @currents/mcp","   ```","","   Cursor, VS Code, or any client configured through `mcp.json`:","","   ```json","   {",'     "mcpServers": {','       "currents": {','         "command": "npx",','         "args": ["-y", "@currents/mcp"],','         "env": { "CURRENTS_API_KEY": "<my key>" }',"       }","     }","   }","   ```","","   Write that config where the client keeps per-user settings, not into a repository-scoped `.cursor/mcp.json` or `.vscode/mcp.json` — those get committed and the key with them.","","3. Reload the client so it picks the server up.","4. Verify the connection: call `currents-get-project` with the project ID below. It should return the project named below.","","## This project","",`- **Project:** ${l}`,`- **Project ID:** \`${r}\``,`- **Docs:** ${ei}`].join(`
5`)}const Ds=1e3,Hs=3e3,Ms=1e4;function Qe(e){window.open(e,"_blank","noopener,noreferrer")}function Us(e,n,r){if(e.startsWith("http")){Qe(e);return}if(!n){window.location.assign(e);return}window.location.assign(e),window.setTimeout(()=>{document.hidden||!document.hasFocus()||(r(n),window.setTimeout(()=>Qe(n.url),Hs))},Ds)}const ze={label:"Open VSX Registry",url:"https://open-vsx.org/extension/currents/currents"},js=()=>[{description:"Integrate with GitHub for commit statuses and PR comments.",label:()=>j(C.GITHUB_APP),icon:()=>t(F,{hookType:C.GITHUB_APP}),hookType:C.GITHUB_APP,docsUrl:"https://docs.currents.dev/resources/integrations/github/github-app",features:["Post PR comments with test results","Block PRs until tests pass","Connect multiple GitHub organizations","Customize filters and labels","Test run details with inline links"]},{description:"Integrate with GitLab for commit statuses and PR comments.",label:()=>j(C.GITLAB_APP),icon:()=>t(F,{hookType:C.GITLAB_APP}),hookType:C.GITLAB_APP,docsUrl:"https://docs.currents.dev/resources/integrations/gitlab",features:["Post Merge Request notes with test results","Block Pipelines until tests pass","Customize filters and labels","Test run details with inline links"]},{description:"Connect Currents to your Slack Workspace.",label:()=>j(C.SLACK_APP),icon:()=>t(F,{hookType:C.SLACK_APP}),hookType:C.SLACK_APP,docsUrl:"https://docs.currents.dev/resources/integrations/slack/slack-app",features:["Post run details to multiple Slack channels","Flexible notification filters and destination settings","Mention test owners on failed and flaky tests","Run summary and test results notifications","Inline traces and failure details"]},{description:"Connect Currents to your Linear workspace.",label:()=>s("span",{className:"inline-flex items-center gap-ui-v2-2 align-middle",children:[j(C.LINEAR_APP),t("span",{className:"inline-flex h-4 items-center mt-0.5 rounded-ui-v2-default bg-ui-v2-ui-warning-inverted-idle px-ui-v2-1_5 ty-text-sm text-ui-v2-content-warning-idle",children:"NEW!"})]}),icon:()=>t(F,{hookType:C.LINEAR_APP}),hookType:C.LINEAR_APP,docsUrl:"https://docs.currents.dev/resources/integrations/linear",features:["Create Linear issues from failed and flaky tests","Pre-fill issues with run, test, and error context","Open linked Linear issues from test results"]},{description:"Legacy Slack integration using webhooks.",label:()=>j(C.SLACK_HOOK),icon:()=>t(F,{hookType:C.SLACK_HOOK}),hookType:C.SLACK_HOOK,docsUrl:"https://docs.currents.dev/resources/integrations/slack/slack-webhook",features:["Multiple integrations supp
5orted","Notify test owners on test failures","Failures and flakiness summary","Customizable filters"]},{description:"Securely interact with the Jira API.",label:()=>j(C.JIRA_APP),icon:()=>t(F,{hookType:C.JIRA_APP}),hookType:C.JIRA_APP,docsUrl:"https://docs.currents.dev/resources/integrations/jira",features:["Triage failures without leaving Currents","Create Jira issues from failed tests","Update run and test details to Jira issues"]},{description:"Configure custom webhooks for your project.",label:()=>j(C.GENERIC_HOOK),icon:()=>t(F,{hookType:C.GENERIC_HOOK}),hookType:C.GENERIC_HOOK,docsUrl:"https://docs.currents.dev/resources/integrations/http-webhooks",features:["Post run details to any HTTP endpoint","Authentication via headers","Multiple integrations supported"]},{description:"Integrate with BitBucket for commit statuses and PR comments.",hookType:C.BITBUCKET_STATUS_HOOK,docsUrl:"https://docs.currents.dev/resources/integrations/bitbucket",icon:()=>t(F,{hookType:C.BITBUCKET_STATUS_HOOK}),label:()=>j(C.BITBUCKET_STATUS_HOOK),features:["Post PR comments with test results","Block PRs with commit status checks","Customize filters and labels","Test run details with inline links"]},{description:"Send notifications to Microsoft Teams channels.",hookType:C.MSTEAMS_STATUS_HOOK,docsUrl:"https://docs.currents.dev/resources/integrations/microsoft-teams",icon:()=>t(F,{hookType:C.MSTEAMS_STATUS_HOOK}),label:()=>j(C.MSTEAMS_STATUS_HOOK),features:["Post Run details to Teams channels","Customize filters and labels","Multiple Teams channels supported"]},{description:"Integrate with GitHub using legacy status hooks.",hookType:C.GITHUB_STATUS_HOOK,docsUrl:"https://docs.currents.dev/resources/integrations/github",icon:()=>t(F,{hookType:C.GITHUB_STATUS_HOOK}),label:()=>j(C.GITHUB_STATUS_HOOK),features:["Post commit statuses to GitHub","Block PRs until tests pass","GitHub Enterprise support"]},{description:"AI-powered assistant for test analytics and insights.",label:()=>j(C.ASSISTANT),icon:()=>t(F,{hookType:C.ASSISTANT}),hookType:C.ASSISTANT,features:["Ask questions about test runs and failures","Get actionable insights and recommendations","Thread-based conversations with history"]},{label:()=>s("span",{className:"inline-flex items-center gap-ui-v2-2 align-middle",children:["IDE Extension",t("span",{className:"inline-flex h-4 items-center mt-0.5 rounded-ui-v2-default bg-ui-v2-ui-warning-inverted-idle px-ui-v2-1_5 ty-text-sm text-ui-v2-content-warning-idle",children:"NEW!"})]}),hookType:C.IDE_EXTENSION,description:"Triage and fix CI test failures inside VS Code, Cursor, and other VS Code-compatible editors.",icon:()=>t(di,{}),docsUrl:"https://docs.currents.dev/ai/ide-extension",installLinks:[{label:"VS Code",icon:t(Os,{className:"size-4"}),url:"vscode:extension/currents.currents",fallback:{label:"VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=currents.currents"}},{label:"Cursor",icon:t(ci,{className:"size-4"}),url:"cursor:extension/currents.currents",fallback:ze},{label:"Kiro",icon:t(Rs,{className:"size-4"}),url:"kiro:extension/currents.currents",fallback:ze},{label:"Others",url:ze.url}],features:["Browse runs and pull requests in the sidebar","Error messages, stack traces, and Playwright traces inline","Fix with agent, using the failure context from CI","Flakiest and slowest tests over the last 14 to 90 days"]},{label:()=>"Currents MCP Server",description:"Connect AI agents to Currents to fix or optimize tests failing in CI.",icon:()=>t(ui,{}),link:"https://github.com/currents-dev/currents-mcp",features:["Automatically fix failing tests","Provide AI agent with test run context"],copyPrompt:{label:"Copy setup prompt",build:Vs}},{label:()=>"n8n",description:"Connect Currents to n8n workflows for automation and integrations.",icon:()=>t(Ls,{className:"w-6 h-6"}),link:"https://n8n.io/integrations/currents/",features:["Workflow automation with test results","Connect to thousands of apps and services"]}],Gs=({integration:e,isAdmin:n,createNewHook:r,isInstalled:i,loading:a,project:l})=>{const o=W(),{toast:d}=U(),u=e.copyPrompt,h=e.installLinks??[],p=h.length>0;function c({label:m,url:v,fallback:b}){Us(v,b,y=>{d.info({title:`${m} isn't installed`,description:`Opening the ${y.label} instead.`,duration:Ms,actions:t(k,{size:"default",onClick:()=>Qe(y.url),children:"Open now"})})})}async function S(m){try{await navigator.clipboard.writeText(m.build({...l,origin:window.location.origin})),d.success({title:"Prompt copied to clipboard",description:"Paste it into your coding agent to run the setup."})}catch{d.error({title:"Unable to copy the prompt"})}}function f(m){n&&("hookType"in m&&m.hookType&&r(m.hookType),"link"in m&&m.link&&window.open(m.link,"_blank","noopener,noreferrer"))}return t($s,{children:s(T,{flexDirection:"column",gap:o.layout.gapHalf,children:[s("div",{children:[s(T,{alignItems:"center",justifyContent:"space-between",gap:o.layout.gapHalf,children:[s(T,{alignItems:"center",gap:o.layout.gapHalf,children:[t(Fs,{children:t(e.icon,{})}),t(Ke,{span:!0,b:!0,font:D.font.small,children:t(e.label,{})})]}),(e.docsUrl||e.link)&&t(V,{font:D.font.smaller,icon:!0,target:"_blank",href:e.docsUrl??e.link,children:"Docs"})]}),t(R,{span:!0,children:e.description})]}),t("div",{children:e.features&&t(T,{flexDirection:"column",gap:o.layout.gapQuarter,children:e.features.map(m=>s(T,{alignItems:"center",gap:o.layout.gapHalf,children:[t(Me,{color:"green",size:12}),t(R,{span:!0,font:D.font.smaller,children:m})]},m))})}),p&&s("div",{className:"flex flex-col gap-ui-v2-2",children:[t(R,{span:!0,font:D.font.smaller,children:"Install for"}),t("div",{className:"flex items-center gap-ui-v2-2",children:h.map(m=>m.icon?t(st,{type:"accent",size:"large",icon:m.icon,"aria-label":`Install in ${m.label}`,title:`Install in ${m.label}`,onClick:()=>c(m)},m.url):t(k,{type:"accent",size:"large",onClick:()=>c(m),children:m.label},m.url))})]}),u&&t(k,{type:"accent",size:"large",leftIcon:t(hi,{}),onClick:()=>S(u),className:"mt-auto",children:u.label}
5),!p&&!e.link&&!i&&t(k,{type:"accent",size:"large",onClick:()=>f(e),disabled:!n,loading:a,className:"mt-auto",children:"Add Integration"}),!p&&!e.link&&i&&s(T,{alignItems:"center",gap:o.layout.gapHalf,className:"mt-auto",children:[t(pi,{color:"green",size:20}),t(Ke,{small:!0,type:"secondary",children:"Installed"})]})]})})},Bs=ft("div",{target:"e1o11ojg2"})("display:grid;grid-template-columns:repeat(auto-fit, minmax(300px, 1fr));gap:",e=>e.theme.layout.gap,";justify-content:center;"),Fs=ft("div",{target:"e1o11ojg1"})("display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:",e=>e.theme.layout.radius,";background-color:",e=>e.theme.palette.background,";border:1px solid ",e=>e.theme.palette.border,";"),$s=ft("div",{target:"e1o11ojg0"})("display:grid;grid-template-rows:1fr auto;border-radius:",e=>e.theme.layout.radius,";padding:",e=>e.theme.layout.gap,";border:1px solid ",e=>e.theme.palette.border,";background-color:",e=>e.theme.palette.accents_1,";"),zs=X(({orgModel:e})=>{const n=Y(),{toast:r}=U(),i=L(),a=$t(),{installation:l}=wt(),{installation:o}=xt(),[d]=ni(),[u]=ri(),[h]=ii(),[p]=ai(),[c]=si(),{enableWithFeedback:S}=tn(n.project.orgId),[f,m]=g.useState(null);async function v(y){if(!i){r.error({title:"You do not have permission to add integrations."});return}m(y);try{await b(y)}finally{m(null)}}async function b(y){if(y===C.SLACK_APP){a(Q(n.project.orgId,n.project.projectId)+"/slack")();return}if(y===C.LINEAR_APP){a(Q(n.project.orgId,n.project.projectId)+"/linear")();return}if(y===C.GITHUB_APP){a(Q(n.project.orgId,n.project.projectId)+"/github")();return}if(y===C.GITLAB_APP){a(Q(n.project.orgId,n.project.projectId)+"/gitlab")();return}if(y===C.ASSISTANT){await S({onSuccess:()=>a(Q(n.project.orgId,n.project.projectId)+"/assistant")()});return}if(y===C.JIRA_APP){a(oi(n.project.orgId,n.project.projectId))();return}let I=null;switch(y){case C.SLACK_HOOK:I=h;break;case C.MSTEAMS_STATUS_HOOK:I=p;break;case C.BITBUCKET_STATUS_HOOK:I=u;break;case C.GENERIC_HOOK:I=d;break;case C.GITHUB_STATUS_HOOK:I=c;break;default:throw new Error("Unknown integration type")}try{if(!I)return;const N=await I({variables:{input:{projectId:n.project.projectId,label:null}},update:(M,{data:_})=>{const H=Object.values(_||{}).find(Boolean);H&&(M.modify({id:M.identify({__typename:"Project",projectId:n.project.projectId}),fields:{hooks(ie=[]){return[...ie,H]}}}),a(Q(n.project.orgId,n.project.projectId)+`/${H.hookId}`)())}});if(N.errors){r.error({title:N.errors[0].message});return}r.success({title:"Integration added successfully!"})}catch(N){r.error({title:N.toString()})}}return t(Bs,{children:js().map(y=>t(Gs,{integration:y,isAdmin:i,isInstalled:[e.isGitHubAppEnabled()&&y.hookType===C.GITHUB_APP,e.isGitLabAppEnabled()&&y.hookType===C.GITLAB_APP,e.isJiraAppEnabled()&&y.hookType===C.JIRA_APP,!!l&&y.hookType===C.SLACK_APP,!!o&&y.hookType===C.LINEAR_APP,e.isAssistantEnabled()&&y.hookType===C.ASSISTANT].some(Boolean),createNewHook:v,loading:f===y.hookType,project:{orgId:n.project.orgId,projectId:n.project.projectId,projectName:n.project.name}},li(y.label().toString())))})}),Ks=()=>t(dn,{children:t(fn,{children:t(De,{children:s("div",{className:"flex flex-col gap-2",children:[t(qs,{}),t(pe,{title:"Available Integrations"}),t(zs,{})]})})})}),qs=X(({orgModel:e})=>{const n=W(),r=Y(),i=qt(r.project.hooks,o=>o.hookType),{installation:a}=wt(),{installation:l}=xt();return!e.hasAnyIntegration()&&!r.hasAnyIntegration()&&!a&&!l?null:s(x,{children:[t(pe,{title:"Enabled Integrations"}),e.isAssistantEnabled()&&s("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border p-ui-v2-3",children:[s("div",{className:"flex min-w-0 items-center gap-2",children:[t(at,{className:"h-4 w-4 shrink-0"}),t("span",{className:"min-w-0 truncate text-sm font-medium",children:"Currents Assistant"})]}),t(te,{hookId:"assistant",label:"Configure"})]}),e.isGitHubAppEnabled()&&t(ca,{}),e.isGitLabAppEnabled()&&t(Yi,{}),e.isJiraAppEnabled()&&t(_s,{}),a&&t(Ze,{installation:a,projectId:r.project.projectId,children:t(te,{hookId:"slack",label:"Configure"})}),l&&t(We,{installation:l,projectId:r.project.projectId,children:t(te,{hookId:"linear",label:"Configure"})}),Object.keys(i).sort().filter(o=>i[o].length>0).map(o=>t("div",{className:"flex flex-col gap-1 py-2 font-medium",children:t(Si,{type:"single",collapsible:!0,defaultValue:i[o].length>2?"closed":o,children:s(ki,{value:o,children:[t(xi,{children:`${j(o)} (${i[o].length})`}),t(Ai,{className:"max-h-[500px] overflow-y-auto scrollbar-thin scrollbar-thumb-theme-secondary scrollbar-track-theme-background scroll-fade-y pt-ui-v2-4",children:t(T,{flexDirection:"column",gap:n.layout.gapQuarter,children:nt(i[o],"createdAt").map(d=>t(Ns,{hook:d},d.hookId))})})]})})},o)),t(P,{h:2})]})});function fl(){const{path:e}=je();return s(ut,{children:[t(me,{path:`${e}/:integrationId`,children:t(Es,{})}),t(me,{path:e,children:t(Ks,{})})]})}export{fl as default};
6//# sourceMappingURL=router-T-E0nb-o.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.