PageSourceSearch

https://dashboard.knock.app/assets/index-Bf0YuWH1.js

js knock.app collected 2026-10-02 02:43:13 UTC 49,237 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d6b7d4ee-fffe-538b-9abf-7ef7a2748f75")}catch(e){}}();
3import{r as h,aQ as it,c as ve,d7 as E,d8 as nt,j as e,s as f,u as v,O as D,a2 as at,a as rt,e as y,E as U,b as re,d9 as xe,da as be,bH as ot,w as Z,y as st,db as lt,f as dt,ac as ct,bI as mt,H as ut}from"./index-BibjyPTE.js";import{A as pt}from"./AccountLayout-Cr2S8RDa.js";import{b as ht,u as z,y as ft,bw as vt,aJ as gt,m as yt,aK as kt,ac as ge,X as xt,dA as bt,aV as jt,b4 as Nt,W as oe,B as K,s as L,a as Ct,A as St}from"./Breadcrumb-EkcGPuP6.js";import{e as ze,G as wt,a as At,A as Tt}from"./GoalActionsMenu-CJBPbZPe.js";import{g as Et}from"./index-BRysSYGQ.js";import{r as M,P as It}from"./index-BUirL_DR.js";import{b as _e}from"./index-BllNGK-1.js";import{P as Dt,f as Ft}from"./PaginationControl-FIBHHrtU.js";import{T as g,g as Ke,a as Rt}from"./index-CsS8R63j.js";import{u as Ot}from"./useUrlCursorPaging-BcOJbTm2.js";import{u as ye}from"./useQuery-ChrxxERi.js";import{V as je}from"./index-jJ9-bWWS.js";import{R as Pt}from"./RecipientToken-Bao0TGju.js";import{D as ue}from"./DateTimePopover-BnEafoam.js";import Ne from"./refresh-ccw-y_JS4yjW.js";import{a as Ce,f as Gt}from"./numbers-DfiUvO2J.js";import{L as Lt,C as Vt,a as zt,b as _t}from"./shared-DEy64M9h.js";import{d as Me}from"./dayjs.min-J7d3xnl3.js";import{r as Kt,D as Mt,u as Wt,K as Ut,M as $t,e as Ht,s as Bt,Z as qt,L as Qt,C as Yt,h as Zt,c as Xt,f as Se,k as we,N as Jt,n as Ae,R as ei,J as se,X as ti,I as ii,T as ni,O as V,Y as ai,P as ri,Q as Te,S as Ee}from"./CartesianChart-CAYzLhdA.js";import{C as oi,R as Ie}from"./ReferenceLine-Byqm6VCx.js";import si from"./chart-no-axes-combined-CvFeY9Id.js";import{a as li}from"./audienceEventOptions-BAu8Wuvb.js";import{f as di}from"./conditionConverters-CyNSmhaL.js";import{f as ci}from"./goalConditionCellUtils-CqPvoMYl.js";import{R as Y}from"./ReadOnlyCondition-CPTWUK4f.js";import{u as mi,G as ui,e as pi,f as hi,a as fi,g as le,h as vi,j as I,i as gi,b as yi}from"./constants-D_8YM-z8.js";import{C as de}from"./index-qYAPjvJR.js";import ki from"./chevrons-down-up-DuYClSbo.js";import{u as W}from"./index-DlyMlN9-.js";import{a as xi}from"./index-p-nHktlA.js";import{u as bi}from"./useLocalStorage-4sZ8gRoN.js";import{M as ji,a as ce}from"./MetricCardRow-CNpfDhT0.js";import{u as X}from"./useKnockToast-Co4WD0qW.js";import{C as Ni}from"./ResourceCommitPromote-BUButU3l.js";import{R as Ci,a as Si}from"./ResourceCommits-BoeVAv48.js";import{E as wi}from"./EditableTitle--cAzVWSi.js";import{P as Ai}from"./PageHeaderTgraph-_40XlxIb.js";import"./react-hotkeys-hook.esm-uGxPHoQD.js";import{a as Ti}from"./formHelpers-FXshqlws.js";import{u as We}from"./useAgentHttpClient-D6WK9D1F.js";import{u as Ei}from"./useLeavePrevention-BMnXLqas.js";import{h as Ue}from"./paths-BWPz_M_c.js";import{f as Ii,h as Di}from"./environment-CuwLrmDK.js";import{C as Fi}from"./CenteredSpinner-Cw-HfplT.js";import{I as Ri}from"./ItemNotFound-C1S8VUHL.js";import{u as Oi}from"./useGoal-BckybKi5.js";import"./MainHeader-DWpc0SF1.js";import"./AgentToggleButton-1PU_txNJ.js";import"./useCurrentUser-BfvTNe4N.js";import"./index-DXLYvgu0.js";import"./index-DToj8SII.js";import"./arrow-right-BxMu1bB5.js";import"./fragments.typegen-CqjmN_fH.js";import"./index-0bv2VSDu.js";import"./sun-CqwZJF6X.js";import"./moon-8eKTJhJO.js";import"./monitor-BZujgGmU.js";import"./AccountAvatar-iRJn78zS.js";import"./gql.typegen-1kWCHIrk.js";import"./index-CZsZYQTi.js";import"./index-C4ev2U8w.js";import"./formik.esm-BdcHBANq.js";import"./get-DuPZLZpA.js";import"./index-UJmbo33A.js";import"./check-goOWWmpv.js";import"./chevron-right-DJ2xXW7k.js";import"./smile-CfqF-oqN.js";import"./frown-CpJAC9xF.js";import"./bug-NwV40jxU.js";import"./keyboard-aYAzyJT8.js";import"./messages-square-BltroTB3.js";import"./useAnimatedText-4tQOqGt5.js";import"./house-AlB8_a7B.js";import"./package-BnUdsTjX.js";import"./localStorage-ChIflZH5.js";import"./user-plus-CYzsZm23.js";import"./circle-question-mark-uqaUqbxd.js";import"./check-check-Jw5J0cHX.js";import"./Meta-CR0s0B-S.js";import"./useClipboard-B0VW0Njm.js";import"./fragments-gZyjuvDu.js";import"./useLazyQuery-DcFJpl-i.js";import"./mail-QKnCcR9w.js";import"./slugify-Bf4wVM_c.js";import"./audienceReferences-nXLW1bBe.js";import"./CloneToEnvironmentField-BKQHRGja.js";import"./ellipsis-vertical-Bsn6xSHN.js";import"./archive-BWGxlGoN.js";import"./types-3Mxs7ypx.js";import"./index-Bqum08hH.js";import"./pageIndex-DvygOM4U.js";import"./recipients-CBmZKwLS.js";import"./dates-DjzzusVh.js";import"./utcTime-DFe7Npw5.js";import"./string-B_J5Q0ZO.js";import"./config-sZY0AIYX.js";import"./user-check-CRJDTb7M.js";import"./zap-BxvpFNLD.js";import"./config-S-4tB8sX.js";import"./helpers-EoOUn5m1.js";import"./navigation-off-COP1YBQt.js";import"./mail-x-CUfE6FBd.js";import"./mail-warning-g-RK_oNH.js";import"./mail-check-EmWyJCSp.js";import"./eye-tk9sEj5z.js";import"./book-open-check-VvZGV1aV.js";import"./mail-open-cKk9ckaT.js";import"./mail-plus-IxfoeYdV.js";import"./mouse-pointer-click-CQBnxY8t.js";import"./useAudienceFromConditionArgument-BLzT2708.js";import"./helpers-B9-wM7xc.js";import"./hooks-DRkJHAuC.js";import"./helpers-CcFxNo8i.js";import"./eye-off-CK50g1PQ.js";import"./deriveEventVariablesFromSampleLog-BCIw-I95.js";import"./AudienceSelectorField-BgMEPIos.js";import"./AudienceSearchCombobox-BQEOuvQg.js";import"./graphql-Bt4ZtNHA.js";import"./useAudience-LVxQZvBP.js";import"./gql.typegen-CXOZ2V90.js";import"./WorkflowStepFieldLabel-hBNfYMUO.js";import"./recipientPath-DVZVjDJ5.js";import"./PropertySelectorMenu-CtiFCBxq.js";import"./use-motion-value--HMAJCCV.js";import"./animate-D63uxMra.js";import"./brackets-5kztHFXn.js";import"./PropertySelectorInputField-DGGS44ni.js";import"./PropertySelectorField-WuK-xcC3.js";import"./ConnectDataSourcesPanel-BqpP0xQB.js";import"./TemplateSection-C_1bcZB-.js";import"./Brandmark-DkUhmZnC.js";import"./puzzle-CVu_6Psr.js";import"./index-BvrzL5IR.js";import"./workos-BW7N1x5_.js";import"./index-Cg8LDkRd.js";import"./TenantToken-D4UckXLG.js";import"./WorkflowSelector-Cw6sR_-Q.js";import"./useAllWorkflows-CE-0NQvm.js";import"./gql-Df8GL-1o.js";import"./Badges-BXjwsN6i.js";import"./Table-CaebTTA6.js";/* empty css                     */import"./DotCanvas-HCdpGqmD.js";
3import"./DottedBackground-ByxXXPSg.js";import"./useDotBackground-DbO_waYH.js";import"./TruncateMiddle-D647irH7.js";import"./brandmarkIcons-CTYpVLBs.js";import"./move-right-B7JbXTfE.js";import"./OperatorField-Bq3mV9ph.js";import"./Primitives-DuG09iZR.js";import"./cloneDeep-BZde2shh.js";import"./_initCloneObject-rh81Yd20.js";import"./OperatorField-ClRgkdX1.js";import"./SourceEventSearch-CG7-i65a.js";import"./useAllSourceEvents-4mfEs4rN.js";import"./gql.typegen-B9CXSFYO.js";import"./useSamplePayload-ByOZXl6t.js";import"./gql.typegen-D112thwe.js";import"./SamplePayloadDisplay-C9Hl_TKD.js";import"./ReadOnlyJsonCodeBlock-kyPdUBPc.js";import"./expand-BqMaSUcy.js";import"./refresh-cw-BfUIA_92.js";import"./gql-DE20YUEL.js";import"./UpdateMessageTypeModal-CZx-iamn.js";import"./type-CAeIcp0q.js";import"./heading-1-ByNMX4Gd.js";import"./heading-2-CGIc_7T6.js";import"./heading-3-c2FnuBnE.js";import"./text-quote-C6KPGMvh.js";import"./code-CX4Djp09.js";import"./bell-dot-B79NaKjK.js";import"./corner-down-right-KzQFbMwo.js";import"./repeat-ByZnRHmY.js";import"./shield-off-BAuesC87.js";import"./list-tree-DPbtu1iI.js";import"./clipboard-copy-CjaBVJ2t.js";import"./message-square-off-BBcduPxH.js";import"./file-code-corner-BZp7k3PQ.js";import"./languages-ByVwu1BP.js";import"./schemaPropertyVisibility-CvQXqUYU.js";import"./text-cursor-input-CQ6dZEN2.js";import"./IconPicker-C_rOz2mh.js";import"./rectangle-horizontal-DdI7at32.js";import"./toggle-right-CLZfyPVf.js";import"./file-down-A5e9ckuo.js";import"./square-check-big-L0btkLEs.js";import"./list-todo-r8KpTzRQ.js";import"./link-2-CWxKks6V.js";import"./palette-B3LreSDw.js";import"./hash-CZWT4h2t.js";import"./ColorPopoverContent.styles-B8eyq-2a.js";import"./AssetPickerHost-D_r6mCdr.js";import"./trash-2-DiganWf-.js";import"./gql.typegen-DYWTVK5j.js";import"./ImageUploadMetadataContext-Do2AJgBG.js";import"./helpers-DOEGB2cR.js";import"./MessageTypePreviewRenderer-BJyUwWC0.js";import"./useIframeThemeSync-D3Fz-nTI.js";import"./previewRequestQueue-t-f775tb.js";import"./TableColumnManager-B1o5SMFm.js";import"./sortable.esm-Db5-IM2K.js";import"./pin-DtvjhFCP.js";import"./useResourceChangeCounts-CGmb_i7b.js";import"./commits-DU3eqEiB.js";import"./useSubscription-CdUCuNOu.js";import"./merge-Bpphc1Ck.js";import"./isPlainObject-3rdonpEy.js";import"./_setToString-BqVw3WOv.js";import"./isPlainObject-BuZ6-dWq.js";import"./useWorkflow-CTbtuO4M.js";import"./git-commit-horizontal-CEI3htyJ.js";import"./gql-CGK4EQDH.js";import"./gql.typegen-mTchMjgM.js";import"./git-pull-request-draft-BlQ-tZwz.js";import"./delete-B6VulfDU.js";import"./navigation-8uFS96WC.js";import"./git-pull-request-DXr6t2Tt.js";import"./useCommits-D-baLO9h.js";import"./utils-CRiRZYlJ.js";import"./undo-2-CbnzviFh.js";import"./gql-GLMazpq4.js";import"./ActivityCell-CzL32YU-.js";import"./Timeline-dGTrJ0Y1.js";import"./clock-r-WPI5e6.js";import"./arrow-down-from-line-DqYT6Z8l.js";function De(t,i){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);i&&(a=a.filter(function(d){return Object.getOwnPropertyDescriptor(t,d).enumerable})),n.push.apply(n,a)}return n}function Fe(t){for(var i=1;i<arguments.length;i++){var n=arguments[i]!=null?arguments[i]:{};i%2?De(Object(n),!0).forEach(function(a){Pi(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):De(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Pi(t,i,n){return(i=Gi(i))in t?Object.defineProperty(t,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[i]=n,t}function Gi(t){var i=Li(t,"string");return typeof i=="symbol"?i:i+""}function Li(t,i){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,i);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(t)}function pe(){return pe=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var a in n)({}).hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},pe.apply(null,arguments)}var Vi=(t,i,n,a,d)=>{var o=Ae(t),r=Ae(i),s=Xt(),c=Se(p=>we(p,"xAxis",n,s)),m=Se(p=>we(p,"yAxis",a,s));if(!o||!r||c==null||m==null)return null;var u=new oi({x:c,y:m}),l=u.map({x:t,y:i},{position:"middle"});return d==="discard"&&!u.isInRange(l)?null:l};function zi(t){var i=Wt();return h.useEffect(()=>(i(Ut(t)),()=>{i($t(t))})),null}var _i=(t,i)=>{var n;return h.isValidElement(t)?n=h.cloneElement(t,i):typeof t=="function"?n=t(i):n=h.createElement(Jt,pe({},i,{cx:i.cx,cy:i.cy,className:"recharts-reference-dot-dot"})),n};function Ki(t){var i=t.x,n=t.y,a=t.r,d=Ht(),o=Vi(i,n,t.xAxisId,t.yAxisId,t.ifOverflow);if(!o)return null;var r=o.x,s=o.y,c=t.shape,m=t.className,u=t.ifOverflow,l=u==="hidden"?"url(#".concat(d,")"):void 0,p=Fe(Fe({clipPath:l},Bt(t)),{},{cx:r??void 0,cy:s??void 0});return h.createElement(qt,{zIndex:t.zIndex},h.createElement(Qt,{className:it("recharts-reference-dot",m)},_i(c,p),h.createElement(Yt,{x:r-a,y:s-a,width:2*a,height:2*a,upperWidth:2*a,lowerWidth:2*a},h.createElement(Zt,{label:t.label}),t.children)))}var Mi={ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,label:!1,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1,zIndex:Mt.scatter};function $e(t){var i=Kt(t,Mi),n=i.x,a=i.y,d=i.r,o=i.ifOverflow,r=i.yAxisId,s=i.xAxisId;return h.createElement(h.Fragment,null,h.createElement(zi,{y:a,x:n,r:d,yAxisId:r,xAxisId:s,ifOverflow:o}),h.createElement(Ki,i))}$e.displayName="ReferenceDot";const J=(t,i)=>{ht({signalKey:t?`knock:goal:refetch:${t}`:void 0,fn:()=>i(),skip:!t})},Wi={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GoalCompletions"}
3,variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"environmentId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"goalId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"after"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"before"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"pageSize"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"attribution"}},type:{kind:"NamedType",name:{kind:"Name",value:"GoalCompletionAttributionFilter"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"resourceType"}},type:{kind:"NamedType",name:{kind:"Name",value:"GoalAttachedResourceType"}}}
3,{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"resourceKey"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"recipientId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"goalCompletions"},arguments:[{kind:"Argument",name:{kind:"Name",value:"environmentId"},value:{kind:"Variable",name:{kind:"Name",value:"environmentId"}}},{kind:"Argument",name:{kind:"Name",value:"goalId"},value:{kind:"Variable",name:{kind:"Name",value:"goalId"}}},{kind:"Argument",name:{kind:"Name",value:"after"},value:{kind:"Variable",name:{kind:"Name",value:"after"}}},{kind:"Argument",name:{kind:"Name",value:"before"},value:{kind:"Variable",name:{kind:"Name",value:"before"}}},{kind:"Argument",name:{kind:"Name",value:"pageSize"},value:{kind:"Variable",name:{kind:"Name",value:"pageSize"}}},{kind:"Argument",name:{kind:"Name",value:"attribution"},value:{kind:"Variable",name:{kind:"Name",value:"attribution"}}},{kind:"Argument",name:{kind:"Name",value:"resourceType"},value:{kind:"Variable",name:{kind:"Name",value:"resourceType"}}},{kind:"Argument",name:{kind:"Name",value:"resourceKey"},value:{kind:"Variable",name:{kind:"Name",value:"resourceKey"}}},{kind:"Argument",name:{kind:"Name",value:"recipientId"},value:{kind:"Variable",name:{kind:"Name",value:"recipientId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"items"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"happenedAt"}},{kind:"Field",name:{kind:"Name",value:"recipientId"}},{kind:"Field",name:{kind:"Name",value:"recipientEmail"}},{kind:"Field",name:{kind:"Name",value:"eventKey"}},{kind:"Field",name:{kind:"Name",value:"attribution"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"resourceType"}},{kind:"Field",name:{kind:"Name",value:"resourceKey"}},{kind:"Field",name:{kind:"Name",value:"resourceName"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"pageInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"after"}},{kind:"Field",name:{kind:"Name",value:"before"}},{kind:"Field",name:{kind:"Name",value:"limit"}},{kind:"Field",name:{kind:"Name",value:"totalCount"}}]}}]}}]}}]},Ui=Wi,He=25,$i=300,Hi=new Set(Object.values(E)),he=t=>Hi.has(t),Be=(t,i)=>`${t.toLowerCase()}:${i}`,Bi=t=>{const i=t.indexOf(":");if(i===-1)return null;const n=Object.values(nt).find(d=>d.toLowerCase()===t.slice(0,i)),a=t.slice(i+1);return!n||!a?null:{resourceType:n,resourceKey:a}},qi=t=>{const i=he(t)?null:Bi(t);return i?{attribution:E.Attributed,...i}:{attribution:he(t)?t:E.All,resourceType:void 0,resourceKey:void 0}},Re=t=>typeof t=="string"?t:"",Qi=({goalId:t})=>{const i=ve(),{environment:n}=z(),{cursor:a,pageIndex:d,paginate:o}=Ot(),r=Re(i.query.attribution)||E.All,s=Re(i.query.recipientId),[c,m]=h.useState(s),u=h.useRef(null),[l,p]=h.useState(s);s!==l&&(p(s),s!==u.current&&m(s)),h.useEffect(()=>{u.current=null},[s]);const b=h.useRef(i.query);h.useEffect(()=>{b.current=i.query},[i.query]);const j=x=>{const C={...b.current};delete C.before,delete C.after,delete C.page,Object.entries(x).forEach(([F,Q])=>{Q?C[F]=Q:delete C[F]}),i.push({pathname:i.pathname,query:C},void 0,{shallow:!0})},N=x=>{u.current=x,j({recipientId:x||void 0})},w=!n?.id||!t,{attribution:k,resourceType:ee,resourceKey:H}=qi(r),B=!!s||r!==E.All,{data:R,previousData:te,loading:ie,error:ne,refetch:q}=ye(Ui,{skip:w,variables:{environmentId:n?.id??"",goalId:t??"",after:a.after,before:a.before,pageSize:He,attribution:k,resourceType:ee,resourceKey:H,recipientId:s||void 0,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},fetchPolicy:"cache-and-network"});J(t,q);const O=ft(x=>N(x),$i),A=R??te,P=A?.goalCompletions.pageInfo??null,G=!R&&P?{...P,after:null,before:null}:P,ae=x=>j({attribution:x===E.All?void 0:x}),_=x=>
3{m(x);const C=x.trim();if(!C){O.cancel(),N("");return}O(C)};return{items:A?.goalCompletions.items??[],pageInfo:G,loading:!w&&ie&&!R,error:ne,refetch:q,pageIndex:d,setPageState:o,attributionFilter:r,onAttributionFilterChange:ae,recipientId:c,onRecipientIdChange:_,isFiltered:B}},Yi="No eligible attribution window at the time of completion.",$={ALL:"All",ATTRIBUTED:"Attributed",UNATTRIBUTED:"Not attributed"},Zi=({completion:t})=>e.jsxs(g.Row,{children:[e.jsx(g.RawCell,{widthPx:180,children:e.jsx(je.Root,{color:"green",size:"1",children:e.jsx(je.Text,{family:"mono",children:t.eventKey})})}),e.jsx(g.RawCell,{children:e.jsx(Pt,{recipient:{__typename:"ExternalUser",id:t.recipientId,email:t.recipientEmail}})}),e.jsx(g.RawCell,{children:t.attribution?e.jsx(ze,{type:t.attribution.resourceType,resourceKey:t.attribution.resourceKey,name:t.attribution.resourceName}):e.jsx(_e,{label:Yi,children:e.jsx(f,{as:"span",size:"1",color:"gray",style:{cursor:"text"},children:"— Not attributed"})})}),e.jsx(g.TextCell,{widthPx:200,justifyContent:"flex-end",isTruncated:!1,children:e.jsx(ue,{dateTime:t.happenedAt,side:"top",align:"end",triggerTextProps:{size:"1"}})})]}),Xi=(t,i)=>he(t)?$[t]:i.find(n=>Be(n.type,n.key)===t)?.name??$.ALL,Ji=({goal:t})=>{const{items:i,pageInfo:n,loading:a,error:d,refetch:o,pageIndex:r,setPageState:s,attributionFilter:c,onAttributionFilterChange:m,recipientId:u,onRecipientIdChange:l,isFiltered:p}=Qi({goalId:t.id}),b=t.attachments.length>0,j=Xi(c,t.attachments),N=Ke({loading:a,data:i,error:d,searchQuery:p?u.trim()||c:void 0}),w=Rt(N)||N==="search_results"||N==="searching";return e.jsxs(v,{direction:"column",h:"full",w:"full",overflow:"hidden",children:[e.jsxs(v,{direction:"row",alignItems:"center",justify:"flex-start",px:"4",py:"3",gap:"2",children:[e.jsx(Et,{placeholder:"Search recipient ID","aria-label":"Search by recipient ID",minW:"80",LeadingComponent:e.jsx(rt,{icon:vt,"aria-hidden":!0,color:"gray"}),TrailingComponent:u?e.jsx(D,{size:"0",variant:"ghost",color:"gray",icon:{icon:at,alt:"Clear recipient filter"},onClick:()=>l("")}):void 0,value:u,onChange:k=>l(k.target.value),size:"1"}),b&&e.jsx(y,{maxW:"56",children:e.jsxs(M.Root,{size:"1",value:c,onValueChange:m,contentProps:{minW:"56",maxW:"80"},triggerProps:{children:e.jsx(It,{as:"span",size:"1",maxW:"full",children:`Attribution: ${j}`})},children:[e.jsx(M.Option,{value:E.All,children:$.ALL}),e.jsx(M.Option,{value:E.Attributed,children:$.ATTRIBUTED}),e.jsx(M.Option,{value:E.Unattributed,children:$.UNATTRIBUTED}),t.attachments.map(k=>e.jsx(M.Option,{value:Be(k.type,k.key),children:k.name},`${k.type}:${k.key}`))]})}),e.jsx(y,{ml:"auto",children:e.jsx(_e,{label:"Refetch completions",children:e.jsx(D,{variant:"outline","aria-label":"Refetch completions",size:"1",onClick:()=>{o()},icon:{icon:Ne,"aria-hidden":!0}})})})]}),e.jsx(y,{h:"full",overflow:"auto",style:{flexGrow:1},children:e.jsxs(g.Root,{status:N,enableKeyboardNavigation:!0,children:[e.jsx(g.StatusView,{matchStatus:"empty",children:e.jsx(U,{icon:{icon:gt,"aria-hidden":!0},title:"No completions yet",description:"Completions appear when recipients trigger this goal's event."})}),e.jsx(g.StatusView,{matchStatus:"error",children:e.jsx(U,{icon:{icon:yt,"aria-hidden":!0},title:"An error occurred",description:"There was an error fetching completions. Please try again. If the error persists, please contact support.",Actions:e.jsx(U.ActionButton,{leadingIcon:{icon:Ne,"aria-hidden":!0},onClick:()=>{o()},children:"Refresh"})})}),e.jsxs(g.Header,{children:[e.jsx(g.HeaderCell,{widthPx:180,children:"Event"}),e.jsx(g.HeaderCell,{children:"Recipient"}),e.jsx(g.HeaderCell,{children:"Attributed to"}),e.jsx(g.HeaderCell,{widthPx:200,justifyContent:"flex-end",children:"Occurred at"})]}),e.jsx(g.Body,{children:i.map(k=>e.jsx(Zi,{completion:k},k.id))}),e.jsx(g.StatusView,{matchStatus:"no_results",children:e.jsx(U,{icon:{icon:kt,"aria-hidden":!0},title:"No results found",description:"We could not find any completions that match your filters. Try adjusting or removing some filters and try again."})}),w&&n&&e.jsx(g.Footer,{positionMode:"sticky",children:e.jsx(y,{px:"4",pb:"3",w:"full",children:e.jsx(Dt,{pageInfo:n,setPageState:s,countLabel:Ft({pageIndex:r,pageSize:He,visibleCount:i.length,totalCount:n.totalCount})})})})]})}),e.jsx(y,{px:"4",py:"3",borderTop:"px",children:e.jsx(f,{as:"p",size:"0",color:"gray",children:"Completions are matched from event history and are retroactive. Attribution appears within 15 minutes of a completion inside an eligible window."})})]})},Oe=[{variableKey:"resource",label:"Resource"},{variableKey:"window",label:"Window",widthPx:80},{variableKey:"eligible",label:"Eligible",widthPx:100},{variableKey:"completions",label:"Completions",widthPx:120},{variableKey:"rate",label:"Rate",widthPx:80}],qe=new Set(["eligible","completions","rate"]),en=new Set(["window","eligible","completions","rate"]),tn=({completions:t,eligible:i})=>i==null||i<=0||t===void 0?"—":`${(t/i*100).toFixed(2)}%`,nn=()=>e.jsxs(f,{as:"span",size:"1",children:["Recipients whose attribution window has started.",e.jsx("br",{}),"Messaging reached them, and a completion can be attributed.",e.jsx("br",{}),"Anchored to first message sent for workflows and broadcasts, or message created for guides."]}),an=({row:t,columns:i})=>{const n=i.some(a=>qe.has(a.variableKey));return e.jsxs(g.Row,{children:[e.jsx(g.RawCell,{column:i[0],children:e.jsx(ze,{type:t.resourceType,resourceKey:t.resourceKey,name:t.resourceName})}),e.jsx(g.RawCell,{column:i[1],justify:"flex-end",children:e.jsx(f,{as:"span",size:"1",style:{fontVariantNumeric:"tabular-nums"},children:t.attributionWindowDays==null?"—":`${t.attributionWindowDays}d`})}),n&&e.jsxs(e.Fragment,{children:[e.jsx(g.RawCell,{column:i[2],justify:"flex-end",children:e.jsx(f,{as:"span",size:"1",style:{fontVariantNumeric:"tabular-nums"},children:Ce(t.uniqueRecipients,"—")})}),e.jsx(g.RawCell,{column:i[3],justify:"flex-end",children:e.jsx(f,{as:"span",size:"1",color:"green",style:{fontVariantNumeric:"tabular-nums"},children:Ce(t.attributedCompletions??0)})}),e.jsx(g.RawCell,{column:i[4],justify:"flex-end",children:e.jsx(f,{as:"span",size:"1",color:"green",style:{fontVariantNumeric:"tabular-nums"},children:tn({completions:t.attributedCompletions,eligible:t.uniqueRecipients})})})]})]})},Qe=({mode:t="summary",rows:i,isLoading:n})=>{const a=t==="completions"?Oe:Oe.filter(r=>!qe.has(r.variableKey)),d=Ke({loading:n===!0,data:i,error:void 0}),o=t==="completions";return e.jsxs(g.Root,{status:d,children:[o&&e.jsx(g.Header,{bg:"transparent",children:a.map(r=>e.jsx(g.HeaderCell,{column:r.variableKey==="eligible"?{...r,headerTooltip:e.jsx(nn,{})}:r,justify:en.has(r.variableKey)?"flex-end":void 0,children:r.label},r.variableKey))}),e.jsx(g.Body,{children:i.map(r=>e.jsx(an,{row:r,columns:a},`${r.resourceType}-${r.resourceKey}`))})]})},rn=({goal:t})=>{const i=t.attachments,{workflowsPath:n,broadcastsPath:a,guidesPath:d}=ge(),o=i.map(r=>({resourceType:r.type,resourceKey:r.key,resourceName:r.name||r.ke
3y,attributionWindowDays:r.attributionWindowDays}));return e.jsx(y,{p:"4",borderTop:"px",borderColor:"gray-4",children:e.jsxs(v,{direction:"column",gap:"2",children:[e.jsx(f,{as:"h2",size:"2",weight:"medium",leading:"3",children:"Attached to"}),i.length===0?e.jsx(y,{border:"px",borderStyle:"dashed",rounded:"4",p:"4",children:e.jsxs(f,{as:"p",size:"1",color:"gray",children:["Not attached to any messaging yet. Attach this goal to a"," ",e.jsx(re,{href:n(),children:e.jsx(f,{as:"span",size:"1",color:"accent",children:"workflow"})}),","," ",e.jsx(re,{href:a(),children:e.jsx(f,{as:"span",size:"1",color:"accent",children:"broadcast"})}),", or"," ",e.jsx(re,{href:d(),children:e.jsx(f,{as:"span",size:"1",color:"accent",children:"guide"})})," ","to measure completions."]})}):e.jsx(y,{overflow:"hidden",mx:"-4",children:e.jsx(Qe,{rows:o})})]})})},on=t=>t.slice(0,10),Ye=t=>Me(t).format("YYYY-MM-DD"),sn=({day:t,days:i})=>{const n=new Date(`${on(t)}T00:00:00.000Z`);return n.setUTCDate(n.getUTCDate()+i),n.toISOString().slice(0,10)},ln=({rows:t,emptyRow:i})=>{if(t.length===0)return t;const n=t[t.length-1];if(!n)return t;const a=sn({day:n.x,days:1});return[...t,i(a)]},Pe=({event:t,rows:i})=>{const n=Ye(t.occurredAt);return i.find(a=>a.x===n)??i.find(a=>a.x>n)??null},Ge=({events:t,firstDay:i,lastDay:n})=>t.filter(a=>{const d=Ye(a.occurredAt);return d>=i&&d<=n}),Le=({markers:t,dayOf:i,occurredAtOf:n,prefer:a})=>{const d=t.reduce((o,r)=>{const s=i(r),c=o.get(s);if(!c)return o.set(s,r);if(a){const m=a(r),u=a(c);if(m&&!u)return o.set(s,r);if(!m&&u)return o}return n(r).localeCompare(n(c))>0?o.set(s,r):o},new Map);return Array.from(d.values())},fe=220,T={completions:{name:"Completions",color:"var(--tgph-blue-7)"},attributed:{name:"Attributed completions",color:"var(--tgph-green-9)"}},dn="var(--tgph-green-11)",cn="var(--tgph-gray-9)",mn="var(--tgph-gray-11)",un="var(--tgph-gray-8)",pn="var(--tgph-gray-11)",hn={[be.Attached]:{fill:T.attributed.color,labelFill:dn,label:"attached"},[be.Detached]:{fill:cn,labelFill:mn,label:"detached"}},fn=({counts:t,attachmentEvents:i,versionEvents:n})=>{const a=ln({rows:t.map(l=>({x:l.day,completions:l.completions,attributedCompletions:l.attributedCompletions??null})),emptyRow:l=>({x:l,completions:null,attributedCompletions:null})}),d=a.some(l=>l.attributedCompletions!=null),o=a[0]?.x,r=a[a.length-1]?.x,s=o&&r?{firstDay:o,lastDay:r}:null,c=Le({markers:s?Ge({events:i,...s}).flatMap(l=>{const p=Pe({event:l,rows:a});return p?[{event:l,point:p}]:[]}):[],dayOf:l=>l.point.x,occurredAtOf:l=>l.event.occurredAt}),m=Le({markers:s?Ge({events:n,...s}).flatMap(l=>{const p=Pe({event:l,rows:a});return p?[{event:l,x:p.x}]:[]}):[],dayOf:l=>l.x,occurredAtOf:l=>l.event.occurredAt,prefer:l=>l.event.type===xe.Created}),u={fontSize:V.tickFontSize,fontFamily:V.fontFamily,fill:se.mutedText,...ni};return e.jsx(ei,{width:"100%",height:fe,children:e.jsxs(Lt,{data:a,margin:{top:16,right:16,bottom:0,left:0},children:[e.jsx(Vt,{stroke:se.gridline,strokeDasharray:"2 3",vertical:!1}),e.jsx(ti,{dataKey:"x",tick:u,axisLine:!1,tickLine:!1,minTickGap:44,tickFormatter:ii}),e.jsx(ai,{tick:u,axisLine:!1,tickLine:!1,width:36,tickFormatter:Gt,domain:[0,"auto"]}),e.jsx(ri,{content:e.jsx(zt,{}),cursor:{stroke:se.gridline}}),e.jsx(Te,{type:"monotone",dataKey:"completions",name:T.completions.name,stroke:T.completions.color,strokeWidth:2,dot:!1,isAnimationActive:!1}),d&&e.jsx(Te,{type:"monotone",dataKey:"attributedCompletions",name:T.attributed.name,stroke:T.attributed.color,strokeWidth:2,dot:!1,connectNulls:!1,isAnimationActive:!1}),m.map(({event:l,x:p})=>e.jsx(Ie,{x:p,stroke:un,strokeDasharray:"3 3",strokeWidth:1,children:e.jsx(Ee,{value:l.type===xe.Created?"goal created":"goal updated",position:"insideBottom",offset:8,style:{fill:pn,fontSize:V.labelFontSize,fontFamily:V.fontFamily}})},`version-${p}`)),c.map(({event:l,point:p})=>{const b=l.resourceName||l.resourceKey,j=hn[l.type],N=`${p.x}-${l.resourceKey}`;return e.jsxs(h.Fragment,{children:[e.jsx(Ie,{x:p.x,stroke:"transparent",children:e.jsx(Ee,{value:`${j.label} · ${b}`,position:"insideTop",offset:8,style:{fill:j.labelFill,fontSize:V.labelFontSize,fontFamily:V.fontFamily}})}),e.jsx($e,{x:p.x,y:p.attributedCompletions??p.completions??0,r:4,fill:j.fill,stroke:"var(--tgph-surface-1)",strokeWidth:2})]},`attachment-${N}`)})]})})},vn=({counts:t,status:i,attachmentEvents:n,versionEvents:a})=>{const d=t.some(r=>r.attributedCompletions!=null),o=[{name:T.completions.name,color:T.completions.
3color},...i==="ready"&&d?[{name:T.attributed.name,color:T.attributed.color}]:[]];return e.jsxs(v,{direction:"column",gap:"2",w:"full",children:[e.jsxs(v,{direction:"row",align:"baseline",justify:"space-between",w:"full",children:[e.jsxs(v,{direction:"row",align:"baseline",gap:"1",children:[e.jsx(f,{as:"h2",size:"2",weight:"medium",children:"Goal completions"}),e.jsx(f,{as:"label",color:"gray",size:"1",weight:"medium",children:"· Last 30 days"})]}),i==="ready"&&e.jsx(_t,{items:o})]}),i==="ready"?e.jsx(fn,{counts:t,attachmentEvents:n,versionEvents:a}):i==="loading"?e.jsx(xt,{w:"full",style:{height:fe}}):e.jsx(v,{align:"center",justify:"center",w:"full",style:{height:fe},children:e.jsx(U,{icon:{icon:si,"aria-hidden":!0},title:"Unable to load completions",description:"Goal completion data could not be loaded. Try refreshing the page."})}),e.jsx(y,{children:e.jsxs(f,{as:"p",size:"0",color:"disabled",px:"4",children:["Completions are retroactive from event history. ",e.jsx("br",{}),"Attributed completions can take up to 15 minutes to appear."]})})]})},Ze=(t,i)=>{const[n,a]=h.useState(null);return{isEditing:n!==null,startEditing:()=>a(t),cancelEditing:()=>{n!==null&&i(n),a(null)}}},gn=({goal:t,draft:i,onDraftChange:n,onCancel:a})=>{const[d,o]=h.useState(!1),r=mi(i),s=t.attachments.length;return e.jsx(y,{children:e.jsxs(v,{direction:"column",gap:"2",children:[e.jsxs(v,{direction:"row",align:"center",justify:"space-between",children:[e.jsx(f,{as:"span",size:"2",weight:"medium",children:"Editing condition"}),e.jsx(D,{size:"1",variant:"outline",onClick:a,children:"Cancel"})]}),e.jsxs(v,{direction:"column",gap:"2",p:"3",rounded:"4",shadow:"1",children:[e.jsxs(v,{direction:"column",gap:"4",w:"full",children:[e.jsx(ui,{value:i,onValueChange:n}),e.jsx(pi,{value:i,onValueChange:n,eventSample:{payload:r.payload,environmentSettingsId:r.environmentSettingsId,sampleEvent:r.sampleEvent,sourceTypeForKey:r.sourceTypeForKey}})]}),i.eventType===ot.IntegrationSource&&i.eventKey.length>0&&e.jsxs(v,{direction:"column",gap:"2",children:[e.jsx(D,{size:"1",variant:"soft",color:"gray",w:"full",trailingIcon:{icon:d?ki:bt,"aria-hidden":!0},onClick:()=>o(c=>!c),children:d?"Hide sample payload":"View sample payload"}),d&&e.jsx(hi,{eventName:r.eventName,payload:r.payload,loading:r.loading})]})]}),s>0&&e.jsx(de.Root,{color:"blue",align:"flex-start",children:e.jsx(de.Content,{children:e.jsxs(de.Description,{children:["Saving updates this goal everywhere it's attached. The"," ",s," attached"," ",s===1?"resource":"resources"," will start measuring against the new condition right away."]})})})]})})},Ve=({children:t})=>e.jsxs(v,{direction:"column",gap:"2",children:[e.jsx(f,{as:"span",size:"1",weight:"medium",children:"Completes when"}),e.jsx(v,{direction:"row",align:"center",gap:"1_5",wrap:"wrap",children:t})]}),me=({children:t})=>e.jsx(f,{as:"span",size:"1",color:"gray",weight:"medium",children:t}),yn=new Set(Object.values(st)),kn=t=>yn.has(t),xn=({condition:t,leadIn:i})=>{const n=String(t.operator);if(!kn(n))return null;const a={operator:n,variable:di(t.variable??""),argument:t.argument};return e.jsxs(Y.Root,{condition:a,children:[e.jsx(f,{as:"span",size:"1",color:"gray",children:i}),e.jsx(Y.Variable,{}),e.jsx(Y.Operator,{}),e.jsx(Y.Argument,{})]})},bn=({goal:t,condition:i,onConditionChange:n,canEdit:a})=>{const{isEditing:d,startEditing:o,cancelEditing:r}=Ze(i,n),s=t.condition?.event,c=ci(t.condition?.matchConditions);return e.jsx(y,{p:"4",borderTop:"px",borderColor:"gray-4",children:e.jsxs(v,{direction:"column",gap:"2",children:[!d&&e.jsxs(v,{direction:"row",align:"center",justify:"space-between",children:[e.jsx(f,{as:"h2",size:"2",weight:"medium",children:"Condition"}),a&&e.jsx(D,{size:"1",variant:"outline","aria-label":"Edit condition",onClick:o,children:"Edit"})]}),d?e.jsx(gn,{goal:t,draft:i,onDraftChange:n,onCancel:r}):e.jsx(y,{bg:"surface-1",shadow:"1",rounded:"4",p:"3",children:s?.__typename==="WaitForEventIntegrationSourceEvent"?e.jsxs(v,{direction:"column",gap:"2",children:[e.jsxs(Ve,{children:[e.jsx(Z,{as:"span",size:"1",color:"green",children:s.integrationEventKey??"event"}),e.jsx(me,{children:"fires for the recipient"})]}),s.recipientPath?e.jsxs(v,{direction:"row",align:"center",gap:"1_5",wrap:"wrap",children:[e.jsx(me,{children:"Recipient path"}),e.jsx(Z,{as:"span",size:"1",color:"green",children:s.recipientPath})]}):null,c.map((m,u)=>e.jsx(xn,{condition:m,leadIn:u===0?"where":"and"},u))]}):s?.__typename==="WaitForEventAudienceEvent"?e.jsxs(Ve,{children:[e.jsxs(me,{children:["the recipient"," ",li(s.audienceEventKey)]}),e.jsx(Z,{as:"span",size:"1",color:"green",children:s.audienceKey??"audience"})]}):e.jsx(f,{as:"span",size:"1",color:"gray",children:"No condition configured."})})]})})},jn=({goal:t,description:i,onDescriptionChange:n,canEdit:a})=>{const[d,o]=bi("goal:details:open",!0),{isEditing:r,startEditing:s,cancelEditing:c}=Ze(i,n);return e.jsx(xi,{open:d,onOpenChange:o,variant:"transparent",maxW:"full",bodyProps:{pt:"0"},title:e.jsx(f,{as:"h2",size:"2",weight:"medium",children:"Details"}),actions:a?r?e.jsx(D,{size:"1",variant:"outline","aria-label":"Cancel editing description",onClick:c,children:"Cancel"}):e.jsx(D,{size:"1",variant:"outline","aria-label":"Edit description",onClick:()=>{o(!0),s()},children:"Edit"}):void 0,content:e.jsxs(W.List,{children:[e.jsx(W.Item,{label:"Key",minH:"6",align:"baseline",children:e.jsx(Z,{as:"span",size:"1",color:"gray",variant:"ghost",children:t.key})}),e.jsx(W.Item,{label:"Description",align:"baseline",children:r?e.jsx(jt,{as:"textarea",size:"1",w:"full",value:i,maxLength:fi,onChange:m=>n(m.target.value),onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),c())}}):e.jsx(f,{as:"span",size:"1",children:i||"—"})}),e.jsx(W.Item,{label:"Created",minH:"6",align:"baseline",children:e.jsx(ue,{dateTime:t.insertedAt,triggerTextProps:{size:"1"}})}),e.jsx(W.Item,{label:"Updated",minH:"6",align:"baseline",children:e.jsx(ue,{dateTime:t.updatedAt,triggerTextProps:{size:"1"}})})]})})},Nn=({completions:t,attributedCompletions:i,uniqueRecipients:n,windowDays:a,isAttached:d,resourceCount:o,status:r})=>{const s=o===1?"resource":"resources",c=r==="loading",m=r==="error",u=!d,l=n===1?"recipient":"recipients",p=r!=="ready"||n==null?"Of — eligible recipients":`Of ${n.toLocaleStr
3ing()} eligible ${l}`,b=d?`Last ${a} days · ${o} ${s}`:"Requires an attached resource";return e.jsxs(ji,{align:"flex-start",children:[e.jsxs(v,{direction:"column",gap:"1",style:{flex:"1 1 0%",minWidth:"80px"},children:[e.jsx(ce,{title:"Completions",value:t,isLoading:c,isError:m,tooltipLabel:"Every time the goal condition was met, regardless of messaging."}),e.jsxs(f,{as:"p",size:"0",color:"gray",px:"1_5",children:["Last ",a," days · all recipients"]})]}),e.jsxs(v,{direction:"column",gap:"1",style:{flex:"1 1 0%",minWidth:"80px"},children:[e.jsx(ce,{title:"Attributed completions",value:i,isLoading:c,isError:m||u,tooltipLabel:"Completions by recipients within an attribution window of messaging this goal is attached to.",color:"green"}),e.jsx(f,{as:"p",size:"0",color:"gray",px:"1_5",children:b})]}),e.jsxs(v,{direction:"column",gap:"1",style:{flex:"1 1 0%",minWidth:"80px"},children:[e.jsx(ce,{title:"Completion rate",value:i,total:n??0,displayMode:"percentage",isLoading:c,isError:m||u,tooltipLabel:"Attributed completions divided by unique recipients messaged in the period.",color:"green"}),e.jsx(f,{as:"p",size:"0",color:"gray",px:"1_5",children:p})]})]})},Cn={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetGoalChartEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"environmentId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"key"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"goal"},arguments:[{kind:"Argument",name:{kind:"Name",value:"environmentId"},value:{kind:"Variable",name:{kind:"Name",value:"environmentId"}}},{kind:"Argument",name:{kind:"Name",value:"key"},value:{kind:"Variable",name:{kind:"Name",value:"key"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"attachmentEvents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"occurredAt"}},{kind:"Field",name:{kind:"Name",value:"resourceKey"}},{kind:"Field",name:{kind:"Name",value:"resourceName"}}]}},{kind:"Field",name:{kind:"Name",value:"versionEvents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"occurredAt"}},{kind:"Field",name:{kind:"Name",value:"versionId"}}]}}]}}]}}]},Sn=Cn,wn=({goalKey:t,goalId:i})=>{const{environment:n}=z(),a=X(),d=!n?.id||!t,{data:o,loading:r,error:s,refetch:c}=ye(Sn,{skip:d,variables:{environmentId:n?.id??"",key:t??""},fetchPolicy:"cache-and-network",onError:()=>{a({title:"There was an error loading goal reporting.",status:"error"})}});return J(i,c),{attachmentEvents:o?.goal?.attachmentEvents??[],versionEvents:o?.goal?.versionEvents??[],loading:!d&&r&&!o,error:s}},An={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GoalCompletionsAggregate"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"environmentId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"goalId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"GoalCompletionsAggregateInput"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"goalCompletionsAggregate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"environmentId"},value:{kind:"Variable",name:{kind:"Name",value:"environmentId"}}},{kind:"Argument",name:{kind:"Name",value:"goalId"},value:{kind:"Variable",name:{kind:"Name",value:"goalId"}}},{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"goalId"}},{kind:"Field",name:{kind:"Name",value:"totals"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"completions"}},{kind:"Field",name:{kind:"Name",value:"attributedCompletions"}},{kind:"Field",name:{kind:"Name",value:"uniqueRecipients"}}]}},{kind:"Field",name:{kind:"Name",value:"counts"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"day"}},{kind:"Field",name:{kind:"Name",value:"completions"}},{kind:"Field",name:{kind:"Name",value:"attributedCompletions"}}]}},{kind:"Field",name:{kind:"Name",value:"byResource"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"resourceType"}},{kind:"Field",name:{kind:"Name",value:"resourceKey"}},{kind:"Field",name:{kind:"Name",value:"resourceName"}}
3,{kind:"Field",name:{kind:"Name",value:"attributionWindowDays"}},{kind:"Field",name:{kind:"Name",value:"attributedCompletions"}},{kind:"Field",name:{kind:"Name",value:"uniqueRecipients"}}]}}]}}]}}]},Tn=An,Xe=30,En=({skip:t,loading:i,hasAggregate:n})=>t||i&&!n?"loading":n?"ready":"error",In=({goalId:t})=>{const{environment:i}=z(),n=X(),a=h.useMemo(()=>{const u=Me();return{startingAt:u.subtract(Xe-1,"day").startOf("day").format(),endingAt:u.format()}},[]),d=!i?.id||!t,{data:o,loading:r,error:s,refetch:c}=ye(Tn,{skip:d,variables:{environmentId:i?.id??"",goalId:t??"",input:{startingAt:a.startingAt,endingAt:a.endingAt,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,groupBy:lt.Resource}},fetchPolicy:"cache-and-network",onError:()=>{n({title:"There was an error loading goal reporting.",status:"error"})}});J(t,c);const m=o?.goalCompletionsAggregate??null;return{aggregate:m,loading:!d&&r&&!o,status:En({skip:d,loading:r,hasAggregate:m!==null}),error:s,refetch:c}},Dn=({goal:t,description:i,onDescriptionChange:n,condition:a,onConditionChange:d,savedRevision:o,canEdit:r})=>{const s=t.attachments.length>0,{aggregate:c,status:m}=In({goalId:t.id}),{attachmentEvents:u,versionEvents:l}=wn({goalKey:t.key,goalId:t.id});return e.jsx(y,{w:"full",h:"full",overflow:"hidden",children:e.jsxs(v,{direction:"row",h:"full",w:"full",overflow:"hidden",children:[e.jsxs(y,{as:"section",borderRight:"px",borderColor:"gray-4",h:"full",overflow:"auto",style:{width:"33%",minWidth:400,flexShrink:0},children:[e.jsx(jn,{goal:t,description:i,onDescriptionChange:n,canEdit:r},`details-${o}`),e.jsx(bn,{goal:t,condition:a,onConditionChange:d,canEdit:r},`condition-${o}`),e.jsx(rn,{goal:t})]}),e.jsx(y,{as:"section",h:"full",overflow:"auto",style:{flexGrow:1},children:e.jsxs(v,{direction:"column",gap:"6",p:"6",children:[e.jsx(Nn,{completions:c?.totals.completions,attributedCompletions:c?.totals.attributedCompletions,uniqueRecipients:c?.totals.uniqueRecipients,windowDays:Xe,isAttached:s,resourceCount:t.attachments.length,status:m}),e.jsx(vn,{counts:c?.counts??[],status:m,attachmentEvents:u,versionEvents:l}),s&&e.jsxs(v,{direction:"column",gap:"3",w:"full",children:[e.jsx(f,{as:"h2",size:"2",weight:"medium",children:"Completions by resource"}),e.jsx(y,{overflow:"hidden",mx:"-4",children:e.jsx(Qe,{mode:"completions",rows:c?.byResource??[],isLoading:m==="loading"})}),e.jsx(f,{as:"p",size:"0",color:"disabled",px:"4",children:"When a recipient is in multiple resources targeting this goal, the completion is attributed to the last one that sent a message."})]})]})})]})})},Fn=({goal:t})=>e.jsx(Nt,{children:e.jsx(Ni,{children:e.jsx(Ci,{children:e.jsx(y,{w:"full",py:"6",children:e.jsx(Si,{object:{__typename:"Goal",key:t.key},emptyStateText:"No past changes for this goal.",hideHelperText:!0,showPromotedCommits:null,title:"Version history"})})})})}),Rn={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpdateGoal"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UpdateGoalInput"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"updateGoal"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"goal"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"key"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"description"}}]}},{kind:"Field",name:{kind:"Name",value:"errors"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"field"}},{kind:"Field",name:{kind:"Name",value:"message"}}]}}]}}]}}]},On=Rn,Pn=()=>{const t=X(),{environment:i}=z(),[n,{loading:a}]=dt(On);return{updateGoal:async o=>{if(!i?.id)throw new Error("Environment is required.");const s=(await n({variables:{input:{environmentId:i.id,id:o.id,name:o.name,description:o.description||null,...o.condition?{condition:o.condition}:{}}},refetchQueries:["GetGoal","ListGoals"],awaitRefetchQueries:!0})).data?.updateGoal;if(s?.errors?.length){const{fieldErrors:c,nonFieldErrors:m}=Ti({errors:s.errors,values:o});return m.forEach(u=>{t({title:u.message||"Failed to update goal.",status:"error"})}),{goal:null,fieldErrors:c}}return{goal:s?.goal??null,fieldErrors:[]}},loading:a}},Gn=({goal:t})=>{const i=ve(),n=X(),{seat:a,account:d}=We(),{environment:o,isBranchEnv:r,project:s}=z(),{goalPath:c,goalsPath:m}=ge(),{updateGoal:u,loading:l}=Pn(),[p,b]=h.useState(t.name),[j,N]=h.useState(t.description??""),[w,k]=h.useState(()=>le(t)),[ee,H]=h.useState(!1),[B,R]=h.useState(!1),[te,ie]=h.useState(!1),[ne,q]=h.useState(0);h.useEffect(()=>{k(le(t))},[t.id,t.updatedAt]);const O=Ue(a,"goals:manage",o)&&!r,A=O&&!!o&&Ii(o,d),P=O,G=O&&Di(s?.environments??[],d),ae=le(t),_=vi(ae,w),x=p.trim()!==t.name.trim()||j.trim()!==(t.description??"").trim()||_;Ei(A&&(x||te));const C=typeof i.query.tab=="string"?i.query.tab:I[0].path,F=S=>{o&&(S===""?i.push(c({key:t.key})):i.push(c({key:t.key},{tab:S})))},Q=async S=>{b(S)},Je=async()=>{const S=p.trim();if(!S){n({title:"Name is required.",status:"error"});return}if(_&&!gi(w)){n({title:"Finish the goal condition before saving.",status:"error"});return}try{const{goal:et,fieldErrors:ke}=await u({id:t.id,name:S,description:j.trim(),..._?{condition:yi(w)}:{}});if(ke.length>0){n({title:ke[0]?.message??"Failed to save goal.",status:"error"});return}if(!et)return;n({title:"Goal updated",status:"success"}),q(tt=>tt+1)}catch{n({title:"Failed to save goal.",status:"error"})}};return oe({name:"Switch to first tab",callback:()=>F(I[0].path),options:{nameOverride:`Switch to ${I[0].label}`,group:"Tabs",enabled:!!o}}),oe({name:"Switch to second tab",callback:()=>F(I[1].path),options:{nameOverride:`Switch to ${I[1].label}`,group:"Tabs",enabled:!!o}}),oe({name:"Switch to third tab",callback:()=>F(I[2].path),options:{nameOverride:`Switch to ${I[2].label}`,group:"Tabs",enabled:!!o}}),o?e.jsxs(e.Fragment,{children:[e.jsx(K.Portal,{children:e.jsxs(K.Container,{children:[e.jsx(K.Item,{href:m(),children:"Goals"}),e.jsx(K.Separator,{}),e.jsx(K.Item,{href:c({key:t.key}),children:t.name})]})}),e.jsx(y,{children:e.jsx(Ai,{title:e.jsx(wi,{value:p,onSave:Q,onEditingChange:ie,isDisabled:!A}),actions:e.jsxs(v,{direction:"row",align:"center",gap:"2",children:[A?e.jsx(D,{size:"1",variant:"solid",color:"accent",disabled:!x||l||!p.trim(),onClick:()=>{Je()},children:"Save"}):void 0,P||G?e.jsx(wt,{goalName:t.name,canArchive:P,canClone:G,onClone:()=>R(!0),onArchive:()=>H(!0)}):void 0]})})}),e.jsxs(L,{value:C,onValueChange:F,as:v,direction:"column",style:{flexGrow:1},children:[e.jsx(L.List,{pl:"2",mb:"0",w:"full",borderBottomWidth:"px",pt:"3",children:I.map(S=>e.jsx(L.Tab,{value:S.path,children:S.label},S.path||"overview"))}),e.jsx(L.Panel,{value:"",style:{flexGrow:1},children:e.jsx(Dn,{goal:t,description:j,onDescriptionChange:N,condition:w,onConditionChange:k,savedRevision:ne,canEdit:A})}),e.jsx(L.Panel,{value:"completions",style:{flexGrow:1},children:e.jsx(Ji,{goal:t},t.id)}),e.jsx(L.Panel,{value:"changes",style:{flexGrow:1},children:e.jsx(Fn,{goal:t})})]}),(A||G)&&e.jsxs(e.Fragment,{children:[G&&B&&e.jsx(At,{goal:t,isOpen:B,onClose:()=>R(!1)}),A&&e.jsx(Tt,{goal:{id:t.id,name:t.name},attachments:t.attachments,isOpen:ee,onClose:()=>H(!1),onSuccess:()=>{i.push(m())}})]})]}):null},Ln=({children:t})=>{const{seat:i,account:n}=We(),{environment:a,isBranchEnv:d}=z(),{goalsPath:o}=ge(),r=ct(),s=ve(),c=!!r[mt],m=Ue(i,"goals:read",a),u=typeof s.query.key=="string"?s.query.key:void 0,{goal:l,loading:p,refetch:b}=Oi({goalKey:u,skip:!u||!c||!m});return Ct({type:"activeGoalKey",value:l?.key,skip:!l?.key}),J(l?.id,b),!c||!m?e.jsx(St,{}):p&&!l?e.jsx(Fi,{}):l?e.jsxs(v,{direction:"column",h:"full",children:[e.jsx(ut,{children:e.jsxs("title",{children:[l.name," | Goals | Knock"]})}),t({goal:l})]}):e.jsx(Ri,{account:n,currentEnvironment:a,itemType:"goal",onViewAll:()=>{!n?.slug||!a?.slug||s.push(o())},onViewAllMessage:d?"View goals on this branch":"View goals in this environment"})},Vn=({goal:t})=>e.jsx(Gn,{goal:t},t.id),zn=({page:t})=>e.jsx(pt,{verifyPermission:"goals:read",isPageFlush:!0,isDisabledOnBranches:!0,children:e.jsx(Ln,{children:({goal:i})=>h.cloneElement(t,{goal:i})})});Vn.getLayout=t=>e.jsx(zn,{page:t});export{Vn as default};
4
5//# debugId=d6b7d4ee-fffe-538b-9abf-7ef7a2748f75

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.