ch(e=>{(0,aB.default)({getState:t}).error(`API call to functions.workflows.steps.aiFilePrecheck with reason ${i} failed, initiated by generated fetcher`),r(e)})}));lV.meta={name:"functionsWorkflowsStepsAiFilePrecheckFetcher",key:"createFetcherFunctionsWorkflowsStepsAiFilePrecheckFetcher",description:"functions.workflows.steps.aiFilePrecheck generated fetcher"};let lH=new c.Ay("workflow_builder"),lq=(0,aB.default)({label:aW.y}),checkAiFileUploadPermitted=async(e,t,a)=>{try{let n=await e(lV({mimetype:t.type,fileSize:t.size,reason:"ai-step-file-upload-pre-check"}));if(!n.ok||n.is_permitted)return null;if(!n.is_mimetype_supported)return{id:`unsupported_type_${t.name}`,message:a?lH.t('The file type "{filetype}" is not supported. Supported types: {supportedTypes}',{filetype:t.type||"unknown",supportedTypes:n.supported_mimetypes.join(", ")}):`The file type "${t.type||"unknown"}" is not supported. Supported types: ${n.supported_mimetypes.join(", ")}`};let r=Math.round(n.size_limit/1048576);return{id:`too_large_${t.name}`,message:a?lH.t('The file "{filename}" exceeds the {sizeLimitMB} MB size limit for its file type.',{filename:t.name,sizeLimitMB:String(r)}):`The file "${t.name}" exceeds the ${r} MB size limit for its file type.`}}catch(e){return lq.error(Error(`AI file upload pre-check failed: ${e}`)),null}};var lU=a(0x11cab3cb4),lz=a(0x18785321b),lj=a(0x1a2b0bc8d),lG=a(0xddc78dc5),l$=a(0x2278818de),lK=a(0x22809c249),lY=a(0x1c2e38de1),lQ=a(0x3143105f),lZ=a(0x113ec6ce5);let lJ=new c.Ay("workflow_builder"),TestFileUpload=({value:e,parameter:t,callbackId:a,onChange:n})=>{let i=(0,l.wA)(),o=(0,r.useRef)(null),s=(0,M.d4)(N.dI),c="maxItems"in t&&t.maxItems||e9.$,d=e9.e,u=(0,M.d4)(lY.p),m=u===lY.v.DISABLE_ALL,p=u===lY.v.IMAGES_ONLY,[b,f]=(0,r.useState)([]),[g,_]=(0,r.useState)([]),[y,x]=(0,r.useState)(m?[{id:"disable_all_error",message:s?lJ.t("File uploads to this workspace have been disabled at the request of your administrator."):"File uploads to this workspace have been disabled at the request of your administrator."}]:[]),[v,E]=(0,r.useState)(!1),k=(0,M.d4)(lj.$),w=(0,r.useMemo)(()=>{let e=[...b,...g];return k.filter(t=>e.includes(t.id))},[k,b,g]),S=(0,r.useCallback)(e=>{_(t=>[...t,e.id])},[]),C=(0,r.useCallback)(a=>{_(e=>e.filter(e=>e!==a.id)),f(r=>{let l=[...r,a.id],i=[];e&&(i=Array.isArray(e)?e:[e]);let o=[...new Set([...i,...l])];return n(t,1===c?o[0]:o),l})},[n,t,e,c]),A=(0,r.useCallback)(a=>{f(r=>{let l=r.filter(e=>e!==a.id),i=[];e&&(i=Array.isArray(e)?e:[e]);let o=[...new Set([...i,...l])].filter(e=>e!==a.id);return n(t,1===c?o[0]||void 0:o),l})},[n,t,e,c]),T=(0,r.useCallback)(e=>{_(t=>t.filter(t=>t!==e.id))},[]),I=(0,r.useCallback)(e=>{let t={id:e.id,message:s?lJ.t("There was a problem uploading the file {filename}. Please try again in a few minutes.",{filename:e.name}):`There was a problem uploading the file ${e.name}. Please try again in a few minutes.`};x(e=>[t,...e])},[s]),L=(0,r.useCallback)(async e=>{x([]);let t=(0,l$.l)({filesToUpload:e,existingFiles:w,maxFiles:c,maxFileSizeBytes:d});if(t)return void x([t]);if(s&&a===e6.oW.AiAnswer){E(!0);try{let t=(await Promise.all(e.map(e=>checkAiFileUploadPermitted(i,e,s)))).filter(e=>null!==e);if(t.length>0)return void x(t)}finally{E(!1)}}i((0,lZ.Z)({filesToUpload:e,onFilePending:S,onFileUploaded:C,onPendingFileRemoved:T,onUploadError:I}))},[a,i,s,w,c,d,S,C,T,I]),O=(0,r.useCallback)(e=>{e.length>0&&L(e)},[L]),F=(0,r.useCallback)(()=>{o.current&&o.current.click()},[]),D=(0,r.useCallback)((e,t)=>{1===w.length&&x([]),i((0,lQ.n)({file:t,onFileRemoved:A,onPendingFileRemoved:T}))},[i,w.length,A,T]),P=s?lJ.t("Add another file"):"Add another file",R=s?lJ.t("Upload file"):"Upload file",B=s?lJ.t("Checking file\u2026"):"Checking file...",W=(0,r.useMemo)(()=>v?B:w.length>0?P:R,[v,B,w.length,P,R]);return r.createElement("div",null,w.length>0&&r.createElement(lU.F,{files:w,onRemoveFile:D}),r.createElement(lz.M,{errors:y}),r.createElement(h.Ay,{onClick:F,disabled:m||v,type:"outline"},W),r.createElement(lK.A,{ref:o,multiple:c>1,onFilesSelectedHandler:O,...(0,lG.y)({filetypes:void 0,isUploadImageOnly:p,isUploadDisabled:m})}))};function isFormFieldDropdown(e){return"slack#/types/limited_rich_text"===e.type&&"choices"in e&&Array.isArray(e.choices)&&e.choices.length>0}function normalizeDropdownParameter(e){return isFormFieldDropdown(e)?{...e,choices:e.choices.map(e=>({...e,value:e.id}))}:e}function normalizeDropdownValue(e,t){if(!isFormFieldDropdown(e)||!Array.isArray(t))return t;try{let a=JSON.stringify(t),n=e.choices.find(e=>{try{return JSON.stringify(e.value)===a}catch{return!1}});return n?.id||t}catch{return t}}function initializeAndNormalizeInputVariables(e,t){let a={...e},n=new Map;return t.forEach(e=>{let t=e.metadata,r=t.name;if(isFormFieldDropdown(t)&&n.set(r,t.choices),a[r]?.value||void 0===t.default||(a[r]={value:t.default,hidden:!1,locked:!1}),isFormFieldDropdown(t)&&a[r]?.value){let e=normalizeDropdownValue(t,a[r].value);a[r]={...a[r],value:e}}}),{inputVariables:a,originalChoicesMap:n}}function createDropdownAwareChangeHandler(e,t){return(a,n,r,l)=>{let i=e.get(a.name);if(i&&i&&"string"==typeof n){let e=i.find(e=>e.id===n);if(e&&Array.isArray(e.value))return void t(a,e.value,r,l)}t(a,n,r,l)}}function normalizeInputVariablesForDropdowns(e,t){let a={...e};return t.forEach(e=>{let t=e.metadata;if(isFormFieldDropdown(t)&&a[t.name]?.value){let e=normalizeDropdownValue(t,a[t.name].value);a[t.name]={...a[t.name],value:e}}}),a}TestFileUpload.displayName="TestFileUpload";var lX=a(0x3264c4f4),l0=a(0x1840248cf);function wrapWithWorkflowTokenDelimiters(e){return`{{${e}}}`}function processChunkElement(e,t){if((0,lX.ed)(e)){let a=(0,l0.z)(e.id);if(a&&t(a))return{...e,id:a}}if("elements"in e&&Array.isArray(e.elements)){let a=e.elements.map(e=>processChunkElement(e,t));return{...e,elements:a}}return e}function processTopLevelElement(e,t){if(!("elements"in e)||!Array.isArray(e.elements))return e;if("rich_text_list"===e.type){let a=e.elements.map(e=>processTopLevelElement(e,t));return{...e,elements:a}}let a=e.elements.map(e=>processChunkElement(e,t));return{...e,elements:a}}function extractMacroVariablesFromRichText(e,t){let a;if(!Array.isArray(e))return e;if(t)if("function"==typeof t)a=t;else{let e=new Set(t.filter(e=>{let t=e.metadata.type;return t&&!isParameterTypeSupportedInInputRenderingEngine(t)}).map(e=>wrapWithWorkflowTokenDelimiters(e.name)));a=t=>e.has(t)}else a=()=>!0;return e.map(e=>e?.type==="rich_text"&&Array.isArray(e.elements)?{...e,elements:e.elements.map(e=>processTopLevelElement(e,a))}:e)}function isParameterTypeSupportedInInputRenderingEngine(e){return[e6.HN.SlackTypesMessageContext,e6.HN.SlackTypesUserId,e6.HN.SlackTypesChannelId,e6.HN.SlackTypesUsergroupId,e6.HN.SlackTypesListId,e6.HN.SlackTypesCanvasId,e6.HN.SlackTypesChannelCanvasId,e6.HN.SlackTypesCanvasTemplateId,e6.HN.SlackTypesTeamId,e6.HN.Integer,e6.HN.Number,e6.HN.Boolean,e6.HN.String,e6.HN.SlackUserPermission,e6.HN.Array,e6.HN.SlackTypesTimestamp,e6.HN.SlackTypesRichText,e6.HN.SlackTypesExpandedRichText,e6.HN.SlackTypesBlocks,e6.HN.SlackTypesLimitedRichText,e6.HN.SlackTypesSalesforceRecordId,e6.HN.SlackTypesDate,e6.HN.DateTime,e6.HN.Reaction,e6.HN.SlackTypesCredentialOauth2,e6.HN.Timezone,e6.HN.SlackTypesUserContext,e6.HN.SlackTypesInteractivity].includes(e)}let l1=new c.Ay("workflow_builder"),l2=[],l4=[],StepTestModalContent=({closeButtonText:e,saveButtonText:t,segment:a,workflow:n,requiredVariables:l,isLoading:i,onCloseButtonClick:o,onSave:s})=>{let c=(0,M.d4)(N.dI),d=(0,e5.Dp)(a),u=(0,r.useMemo)(()=>r.createElement("div",{className:lD().titleContainer},a.config.slackFunction?.title||"",r.createElement(ns.v,{style:ns.u.Jade},c?l1.t("Test run"):"Test run")),[c,a.config.slackFunction?.title]),m=(0,nR.A)(),p=(0,e4.EM)(a),b=(0,r.useMemo)(()=>{let e={};for(let t of l.referencedVariables)e[t.metadata.name]=t.name;return e},[l.referencedVariables]),f=(0,r.useMemo)(()=>a.config.slackFunction?.input_parameters.map(e=>e.name)??[],[a.config.slackFunction?.input_parameters]),g=(0,r.useCallback)(()=>{(0,aE.ft)({clogger:m,uiArgs:{step:tK.UiStep.WORKFLOWS_TEST_RUN_VARIABLES_MODAL},wbArgs:{workflow_id:n.workflow.id,is_hermes:!0}}),o()},[m,o,n.workflow.id]),{inputVariables:_,originalChoicesMap:x}=(0,r.useMemo)(()=>initializeAndNormalizeInputVariables(a.config.inputs,l.referencedVariables),[a.config.inputs,l.referencedVariables]),[v,E]=(0,r.useState)(_),k=(0,r.useMemo)(()=>{let e={};for(let t of l.referencedVariables){let a=t.metadata.name;if(!f.includes(a)&&void 0!==t.metadata.default){let n=b[a];n&&(e[n]=t.metadata.default)}}return e},[l.referencedVariables,f,b]),[w,S]=(0,r.useState)(k),C=(0,r.useCallback)((e,t,a,n)=>{if(E(a=>({...a,[e.name]:{...a[e.name]||{},value:t}})),!f.includes(e.name)){let a=b[e.name];S(e=>({...e,[a]:t}))}},[f,b]),A=(0,r.useMemo)(()=>l.referencedVariables.filter(e=>!!e.metadata.is_required&&!e.metadata.isOptional&&!v[e.metadata.name]?.value),[l.referencedVariables,v]),T=(0,r.useCallback)(e=>{var t,a;let n;s({stepInputs:(t=Object.fromEntries(Object.entries(v).filter(([e])=>f.includes(e))),a=l.referencedVariables,n={},Object.entries(t).forEach(([e,t])=>{if(t?.value&&Array.isArray(t.value)){let r=extractMacroVariablesFromRichText(t.value,a);n[e]={...t,value:r}}else n[e]=t}),n),stepExecutionData:w})},[s,v,w,f,l]);(0,r.useEffect)(()=>{(0,aE.Vb)({clogger:m,uiArgs:{step:tK.UiStep.WORKFLOWS_AI_STEP_DEFAULT_MODAL},wbArgs:{workflow_id:n.workflow.id,is_hermes:!0}})},[m,n.workflow.id]);let I=(0,r.useMemo)(()=>createDropdownAwareChangeHandler(x,C),[C,x]),L=(0,r.useMemo)(()=>normalizeInputVariablesForDropdowns(v,l.referencedVariables),[v,l.referencedVariables]);return r.createElement(r.Fragment,null,r.createElement(tS.rQ,null,r.createElement(tS.Rc,{title:u})),r.createElement(tS.$m,null,r.createElement(tS.qf,{className:"padding_top_50 padding_bottom_50"},r.createElement("div",null,l.referencedVariables.length>0&&r.createElement("div",null,r.createElement("p",null,c?l1.t("Provide the below inputs to test run this step"):"Provide the below inputs to test run this step"),l.referencedVariables.map(e=>{let t=normalizeDropdownParameter(e.metadata);return t.type===e6.TE.Array&&t.items?.type===e6.TE.SlackTypesFileId?r.createElement(y.A,{key:e.metadata.name,text:e.metadata.title,className:"margin_bottom_100"},r.createElement(TestFileUpload,{value:"",parameter:t,callbackId:d,onChange:I})):r.createElement(eK.v,{key:e.name,functionId:a.config.function_id,configuredParameters:L,onChange:I,variables:p,allowVariables:!1,callbackId:d,parameter:t,oAuthParameter:void 0,inputParameters:l2,keyValueParameters:l4,enableRichTextDropdowns:!0,enableStringFallback:!0})}))))),r.createElement(tS.jl,null,r.createElement(tS.ox,null,r.createElement(tS.s_,{onClick:g,type:"outline","aria-label":e},e),r.createElement(h.lV,{"data-qa":"step-test-modal__save-button",ariaLoadingMessage:c?l1.t("Running"):"Running",disabled:A.length>0,loading:i,onClick:T,"aria-label":t},t))))};function stripVariablePrefix(e){if(e.startsWith("inputs.")){let t=e.split("__");if(2===t.length)return t[1]}return e}function extractSegmentVariables(e,t,a){let{availableData:n,trigger:r}=t,l=new Map,i=new Map,o=new Map,s={get undefinedVariables(){return Array.from(l.values())},get hiddenVariables(){return Array.from(i.values())},get referencedVariables(){return Array.from(o.values())}},c=/\{\{([^}]+?)\}\}/g,handleVariable=(a,s)=>{let c=`{{${a}}}`,d=stripVariablePrefix(a),u=`{{data.${d}}}`,m=n[c]||r?.outputs[u]||r?.outputs[`{{${d}}}`];if(m){let e,n=(e=>{let a=e.match(/^steps\.([^.]+?)\.fields\.([^.]+?)$/);if(!a)return;let[,n,r]=a,l=t.workflow?.steps?.find(e=>e.id===n);if(!l||l.function?.callback_id!=="open_form")return;let i=l.inputs?.fields?.value;if(Array.isArray(i))return i.find(e=>e.name===r)})(a);n&&(m={...m,...n,title:m.title||n.title,description:m.description||n.description,name:m.name}),e=!(!s.startsWith("inputs[")||n?.optional)||(n&&"optional"in n?!n.optional:"object"==typeof m&&"is_required"in m&&!!m.is_required);let r={...m,name:`${m.source_id?`${m.source_id}.`:""}${m.name}`||a,is_required:e};("slack#/types/message_context"===r.type||r.is_hidden?i:o).set(a,{name:a,location:s,metadata:r})}else e.config.slackFunction?.input_parameters.some(e=>e.name===a&&e.is_required)||l.set(a,{name:a,location:s})},checkForVariables=(e,t)=>{if("string"==typeof e)for(let a of e.matchAll(c))handleVariable(a[1],t);else Array.isArray(e)?e.forEach((e,a)=>{checkForVariables(e,`${t}[${a}]`)}):e&&"object"==typeof e&&Object.entries(e).forEach(([e,a])=>{checkForVariables(a,`${t}.${e}`)})},d=new Set;return Object.entries(e.config.inputs).forEach(([e,t])=>{if("string"==typeof t.value){let e=t.value.match(c);e&&e.forEach(e=>{let t=e.slice(2,-2);d.add(t)})}d.add(`inputs.${e}`),checkForVariables(t.value,`inputs[${e}]`)}),e.config.slackFunction?.input_parameters.forEach(e=>{if(e.is_required){let t=e.name;d.has(t)||n[`{{${t}}}`]||n[`{{inputs.${r?.id}__${t}}}`]||r?.outputs[`{{data.${t}}}`]||s.undefinedVariables.push({name:t,location:`input_parameters.${e.name}`})}}),a?.includeInputs&&e.config.slackFunction?.input_parameters.forEach(t=>{let a=t.name,n=e.config.inputs?.[t.name]?.value;if(!("string"==typeof n&&c.test(n))&&!o.has(a)&&!i.has(a)){let e={type:t.type,title:t.title,name:t.name,is_required:t.is_required,description:t.description};"array"===t.type&&t.items&&(e.items=t.items),void 0!==n&&(e.value=n),o.set(a,{name:a,location:`input_parameters.${t.name}`,metadata:e})}}),s}StepTestModalContent.displayName="StepTestModalContent";let l8=new c.Ay("workflow_builder"),StepTestModal=({segment:e,workflow:t,onTestRun:a,autoRun:n=!1})=>{let i=(0,l.wA)(),o=(0,M.d4)(N.dI),[s,c]=(0,r.useState)(!1),d=(0,r.useCallback)(()=>{c(!1),i((0,lT.O)())},[i]),u=(0,r.useMemo)(()=>extractSegmentVariables(e,t),[e,t]),m=(0,r.useCallback)(({stepInputs:e,stepExecutionData:t})=>{c(!0),a&&a(e,t,d)},[a,d]),p=(0,r.useMemo)(()=>u&&0===u.referencedVariables.length&&n,[u,n]);(0,r.useEffect)(()=>{p&&m({stepInputs:e.config.inputs,stepExecutionData:{}})},[p,m,e.config.inputs]);let b=(0,r.useCallback)(()=>{d()},[d]),f=o?l8.t("Test {stepName}",{stepName:e.config.slackFunction?.title}):`Test ${e.config.slackFunction?.title}`;return p?null:r.createElement(t0.v,{contentLabel:f,modalClassName:lD().step_test_modal,centered:!0,shouldCloseOnOverlayClick:!0},r.createElement(StepTestModalContent,{segment:e,workflow:t,requiredVariables:u,closeButtonText:l8.t("Cancel"),saveButtonText:o?l8.t("Run"):"Run",onCloseButtonClick:b,onSave:m,isLoading:s}))};StepTestModal.displayName="StepTestModal";var l5=a(0xc3cbf6b1);let l6=new c.Ay("workflow_builder"),AiStreamingError=({containerRef:e,showScrollButton:t,error:a})=>{let n=(0,M.d4)(N.dI),l=((e,t,a={})=>{let n=r.useRef(null);return(0,r.useEffect)(()=>{let{current:r}=n;if(!r||!window.IntersectionObserver)return;let l=a.threshold||1,i=new IntersectionObserver(([t])=>{e(t.intersectionRatio{i.unobserve(r),i.disconnect()}},[n,a,e,t]),n})(t,e,{threshold:1}),i={permission_denied:n?l6.t("This result may be incomplete because the user doesn\u2019t have permission to access the given context"):"This result may be incomplete because the user doesn\u2019t have permission to access the given context",max_tokens_reached:n?l6.t("This result may be incomplete because the AI reached its limit."):"This result may be incomplete because the AI reached its limit.",request_limit_exceeded:n?l6.t("This result may be incomplete because the request loop limit was exceeded."):"This result may be incomplete because the request loop limit was exceeded.",ai_answer_failed:n?l6.t("This result may be incomplete because the AI answering failed"):"This result may be incomplete because the AI answering failed",ai_answer_blocked:n?l6.t("This result may be incomplete because the AI answer is blocked by guardrails"):"This result may be incomplete because the AI answer is blocked by guardrails",llm_permanent_error:n?l6.t("This result may be incomplete because the AI had a problem fulfilling the request"):"This result may be incomplete because the AI had a problem fulfilling the request",llm_input_too_long_error:n?l6.t("This result may be incomplete because the input was too large. Try reducing the number or size of files, or shortening your prompt"):"This result may be incomplete because the input was too large. Try reducing the number or size of files, or shortening your prompt"};return r.createElement("div",{ref:l,className:lN().testPromptPanelStreamingError},r.createElement(u.Ay,{type:"boxed",level:"error",align:"left"},r.createElement("span",null,i[a])))};AiStreamingError.displayName="AiStreamingError";let SparkleWithGradientSVG=()=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},r.createElement("path",{d:"M12.6123 10.8047C12.6718 10.6857 12.8417 10.6858 12.8984 10.8047L13.3125 11.6289C13.4372 11.8753 13.6355 12.0793 13.8848 12.2012L14.71 12.6143C14.8289 12.6737 14.8288 12.8436 14.71 12.9004L13.8848 13.3145C13.6383 13.4391 13.4343 13.6375 13.3125 13.8867L12.8984 14.7109C12.8389 14.8298 12.669 14.8299 12.6123 14.7109L12.1982 13.8867C12.0735 13.6403 11.8754 13.4362 11.626 13.3145L10.8018 12.9004C10.6827 12.8409 10.6827 12.6709 10.8018 12.6143L11.626 12.2012C11.8725 12.0766 12.0764 11.8781 12.1982 11.6289L12.6123 10.8047ZM5.62598 3.4541C5.76203 3.17933 6.15594 3.17933 6.29199 3.4541L7.25293 5.37695C7.54204 5.95483 8.00968 6.422 8.58789 6.71094L10.5127 7.67188C10.787 7.80798 10.787 8.20078 10.5127 8.33691L8.58789 9.29785C8.0097 9.58678 7.54204 10.054 7.25293 10.6318L6.29199 12.5557C6.15588 12.83 5.76217 12.8299 5.62598 12.5557L4.66504 10.6318C4.37597 10.054 3.9082 9.5868 3.33008 9.29785L1.40527 8.33691C1.13068 8.20086 1.13066 7.80791 1.40527 7.67188L3.33008 6.71094C3.90818 6.42199 4.37597 5.95475 4.66504 5.37695L5.62598 3.4541ZM12.6123 1.28906C12.6719 1.17044 12.8416 1.17059 12.8984 1.28906L13.3125 2.11328C13.4371 2.35958 13.6356 2.56371 13.8848 2.68555L14.71 3.09961C14.829 3.15912 14.829 3.32909 14.71 3.38574L13.8848 3.79883C13.6383 3.92343 13.4344 4.12197 13.3125 4.37109L12.8984 5.19531C12.8389 5.31429 12.669 5.31429 12.6123 5.19531L12.1982 4.37109C12.0735 4.12485 11.8752 3.92056 11.626 3.79883L10.8018 3.38574C10.6827 3.32625 10.6827 3.15626 10.8018 3.09961L11.626 2.68555C11.8726 2.56091 12.0764 2.36255 12.1982 2.11328L12.6123 1.28906Z",fill:"url(#paint0_linear_481_30170)"}),r.createElement("defs",null,r.createElement("linearGradient",{id:"paint0_linear_481_30170",x1:"14.7992",y1:"8.0002",x2:"1.19922",y2:"8.0002",gradientUnits:"userSpaceOnUse"},r.createElement("stop",{stopColor:"#83388A"}),r.createElement("stop",{offset:"1",stopColor:"#EABDFB"}))));var l3=a(0x24e7004c6);let l7=new c.Ay("workflow_builder"),ViewErrorButton=({onClick:e})=>{let t=(0,M.d4)(N.dI)?l7.t("View Error"):"View Error";return r.createElement(h.Nm,{className:lN().viewErrorButton,onClick:e,"aria-label":t},r.createElement("span",{className:lN().jumpIcon},r.createElement(p.Ah,{inline:!0,name:"arrow-up"})),t)};ViewErrorButton.displayName="ViewErrorButton";var l9=a(0x113cdbbd7),ie=a(0x1b3ecb90f),it=a(0x146369fa8),ia=a(0x4e250925);let ir=new c.Ay("workflow_builder"),extractRichText=e=>{let t=[];return e&&Array.isArray(e)&&e.forEach(e=>{e.type===lL.WP.rich_text&&t.push(e)}),t},TestPromptPanel=({segment:e,workflow:t,disabled:a,testKey:n})=>{let i=(0,M.d4)(N.dI),s=(0,r.useRef)(null),c=(0,r.useRef)(null),d=(0,l.wA)(),u=(0,nR.A)(),[m,b]=(0,r.useState)(!1),[f,g]=(0,r.useState)(!1),[_,y]=(0,r.useState)(!1),[x,v]=(0,r.useState)(!1),[E,k]=(0,r.useState)(void 0),w=(0,r.useRef)(null),[S,C]=(0,r.useState)(n),[A,T]=(0,r.useState)(void 0),I=(0,r.useCallback)(e=>{g(!1),T({blocks:extractRichText(e)})},[]),L=(0,r.useCallback)((e,a)=>{d((0,ia.VL)({referenceId:a,appId:t.workflow.app_id})).then(e=>{e?.ok&&e.response.answer&&T({ai_context:{result_status:aX.uX.COMPLETE},blocks:extractRichText(e.response.answer)})})},[d,t.workflow.app_id,T]),O=(0,r.useCallback)((e,t)=>{g(!1),t?k(e):y(!0)},[]),{handleSubmit:F}=(0,l3.M)({workflowId:t.workflow.id,onStreamedResponse:I,onComplete:L,onError:O}),D=(0,r.useCallback)(async(t,a,n)=>{T(void 0),g(!0),b(!0),k(void 0),y(!1),F({segment:e,stepInputs:t,stepExecutionData:a}).then(e=>{e?.ok?y(!1):(g(!1),y(!0))}).catch(()=>{g(!1),y(!0)}).finally(()=>{n()})},[F,e,b,g,y,k]),P=(0,r.useCallback)(()=>{d((0,ap.q)({element:r.createElement(StepTestModal,{segment:e,workflow:t,onTestRun:D,autoRun:!0}),isStackable:!0}))},[d,e,t,D]),R=(0,r.useCallback)(()=>{(0,aE.K$)({clogger:u,uiArgs:{step:tK.UiStep.WORKFLOWS_AI_STEP_DEFAULT_MODAL},uiProperties:{element_name:aE.KC.AiStepTestRun}}),P()},[u,P]);(0,r.useEffect)(()=>{n!==S&&(C(n),f||P())},[n,S,P,f]);let B=(0,r.useCallback)(e=>{let t=(0,lO.cX)()?e.metaKey:e.ctrlKey;e.target instanceof HTMLAnchorElement&&"button"in e&&0===e.button&&!t&&(e.preventDefault(),e.stopPropagation())},[]),W=(0,r.useCallback)(()=>{c.current?.scrollIntoView({behavior:"smooth"})},[]);(0,r.useEffect)(()=>{A&&w.current?.querySelectorAll("a").forEach(e=>{e.onclick=B})},[A,B]);let V=(0,r.useCallback)(()=>_?r.createElement(l5.y,{onRetry:P,disabled:a??!1}):A?r.createElement("div",{ref:w,className:lN().testPromptPanelResultContent},r.createElement(it.o,{msg:A,blocksContainerContext:l9.pi.ai_app,inline:!0}),_&&r.createElement(l5.y,{onRetry:P,disabled:a??!1})):null,[A,_,P,a]);return r.createElement("div",{className:lN().testPromptPanelOuterContainer,ref:s},E&&x?r.createElement(ViewErrorButton,{onClick:W}):null,r.createElement(tS.$m,{"aria-labelledby":"simulate-prompt-output-header-text",id:"simulate-prompt-output-content"},r.createElement("div",{ref:c,className:lN().testPromptPanelContainer},r.createElement("div",{className:o()(lN().testPromptPanel,{[lN().testPromptPanelShowResult]:m||f,[lN().testPromptShowResponse]:m&&!f&&!_,[lN().testPromptPanelStreamingError]:E})},r.createElement("div",{className:lN().testContentModalContentSection},m||f?r.createElement(r.Fragment,null,E&&"string"==typeof E.cause?r.createElement(AiStreamingError,{containerRef:s,error:E.cause,showScrollButton:v}):null,A&&r.createElement("div",{className:lN().generatedContentContainer},r.createElement(SparkleWithGradientSVG,null),i?ir.t("Generated content"):"Generated content"),r.createElement("div",{className:lN().testPromptPanelResult},f?r.createElement(AiStepLoadingAnimation,{lineCount:6,className:lN().testPromptPanelResultLoading}):V())):r.createElement("div",{className:lN().testPromptPanelEmptyState},r.createElement("div",{className:lN().testPromptPanelEmptyStateContent},r.createElement("div",null,r.createElement(ie.Ay,{text:":test_tube:",emojiSize:ie.lw.MEDIUM})),r.createElement("h2",{className:lN().testPromptPanelEmptyStateTitle},i?ir.t("Test your prompt"):"Test your prompt"),r.createElement("div",null,i?ir.t("If you choose to test the efficacy of your prompt, you will be guided to provide the required inputs for execution."):"If you choose to test the efficacy of your prompt, you will be guided to provide the required inputs for execution."),r.createElement(h.$n,{type:"outline",className:lN().testPromptButton,disabled:a,onClick:R},i?ir.t("Test Prompt"):"Test Prompt",r.createElement(p.Ah,{name:"play",size:"18"})))))),r.createElement("div",{className:o()(lN().testPromptPanelFooter,{[lN().resultLoading]:f})},i?ir.t("This tool uses AI to generate responses, so some information may be inaccurate."):"This tool uses AI to generate responses, so some information may be inaccurate."))))};TestPromptPanel.displayName="TestPromptPanel";var il=a(0x133aaa7da),ii=a(0x1a043bf26),io=a(0x409e023f),is=a(0x32d3ef3d),ic=a(0xfa28400d),id=a(0x9798b7f),iu=a(0x7729d35b),im=a(0x135b7b386),ip=a(0x184767f39);let ib="knowledge-source-form-modal",ig="knowledge-source-alert",ih={[im.wo]:"select_sheet",[im.y]:"select_document"},i_={[im.wo]:"sheet_id",[im.y]:"document_id"},iy=Object.keys(ih),ix="requestable",iv="requested",iE="addable",ik="inactive",iw="connected",iS={[ip.pY.INIT_APP_REQUEST_FLOW]:ix,[ip.pY.SHOW_STEP_FUNCTION]:iE,[ip.pY.INSTALL_SHOW_STEP_FUNCTION]:iE,[ip.pY.APP_DENIED]:ik,[ip.pY.APP_REQUEST_IS_PENDING]:iv,[ip.pY.APP_HIDDEN]:ik};var iC=((n={}).Single="single",n.First="first",n.Middle="middle",n.Last="last",n);let getKnowledgeSourceUrl=(e,t)=>{if(!t?.app_id)return;let a=i_[t.app_id];if(!a)return;let n=e.inputs[a];if(!n?.value)return;let r="string"==typeof n.value?n.value:String(n.value);switch(t.app_id){case im.wo:return`https://docs.google.com/spreadsheets/d/${r}`;case im.y:return`https://docs.google.com/document/d/${r}`;default:return}};var iA=a(0x5dd1c0f2),iT=a(0x216c59e11),iI=a.n(iT);let iN={name:"trash"},iM=new c.Ay("workflow_builder"),KnowledgeSourceEntity=({knowledgeSource:e,stepId:t,onRemove:a,renderedInListVariant:n,hasFocus:l})=>{let i=(0,M.d4)(t=>(0,t5.hj)(t,e.function_id)),s=(0,M.d4)(N.kZ),c=(({knowledgeSource:e,workflowId:t,stepId:a})=>{let n=(0,M.d4)(e=>t?(0,ng.W_)(e,t):void 0),l=(0,r.useMemo)(()=>{if(a&&e.id&&n)return n[a]?.[e.id]},[n,a,e.id]);return(0,r.useMemo)(()=>l?.loading?is.w.loading:l?.error?is.w.error:(l?.options,is.w.enabled),[l])})({knowledgeSource:e,workflowId:(0,aD.Y)(),stepId:t}),d=(0,r.useMemo)(()=>getKnowledgeSourceUrl(e,i),[e,i]),u=(0,M.d4)(e=>i?.app_id?(0,iA.jH)(e,i.app_id):""),m=c===is.w.error,p=(0,r.useCallback)(e=>{e.stopPropagation(),a?.()},[a]),b=(0,r.useMemo)(()=>r.createElement(v.Ay,{tip:s?iM.t("Remove variable"):"Remove variable"},r.createElement(x.A,{"aria-label":s?iM.t("Remove variable"):"Remove variable",svgIconProps:iN,onClick:p})),[p,s]),f=(0,r.useMemo)(()=>{if(!i?.app_id)return i?.title||i?.description||"";let t=i_[i.app_id];if(t){let a=e.inputs[t],n=a?.value,r=a?.label;return("object"==typeof r&&r?r[n]:void 0)??""}return i.description},[i,e.inputs]),g=(0,r.useMemo)(()=>m?r.createElement("span",{className:o()(iI().secondaryLabel,iI().errorLabel)},s?iM.t("Cannot access file"):"Cannot access file"):d?l?r.createElement("span",{className:iI().secondaryLabel},s?iM.t("Open resource"):"Open resource"):r.createElement("span",{className:iI().secondaryLabel},r.createElement("span",{className:iI().hoverText},s?iM.t("Open resource"):"Open resource"),r.createElement("span",{className:iI().baseText},u)):u,[m,d,u,l,s]),h=(0,r.useMemo)(()=>r.createElement("div",{className:iI().knowledgeSourceEntityContent},r.createElement(iu.A,{entityState:c,suppressDefaultColors:!0},r.createElement(T.z,{appId:i?.app_id})),r.createElement("div",{className:iI().labelWrap},r.createElement(id.A,{entityState:c,size:is.S.compact,primaryLabel:f,secondaryLabel:g}))),[c,i?.app_id,f,g]);return r.createElement(ic.Ay,{size:is.S.compact,entityState:c,isRemovable:!1,isInteractive:!0,isFullWidth:!0,isFullHeight:!0,customMaxWidth:"100%",actionsBar:b,forceShowActionsBar:!0,shouldShrinkUnderDefaultWidth:!0,renderedInListVariant:n},h)};KnowledgeSourceEntity.displayName="KnowledgeSourceEntity";var iL=a(0x1eac8b1c1),iO=a.n(iL);let ConnectorSourceRow=({knowledgeSource:e,stepId:t,variant:a,params:n,externalResourcesArray:l,inputParameters:i,onChange:o})=>{let s=(0,r.useCallback)(()=>{let t=l.filter(t=>t.id!==e.id),a=i.find(e=>e.name===lA.c.EXTERNAL_RESOURCES);a&&o(a,t)},[l,e.id,i,o]);return r.createElement("div",{className:iO().knowledgeSourceRow,style:{height:"62px"}},r.createElement(KnowledgeSourceEntity,{key:e.id,knowledgeSource:e,stepId:t,onRemove:s,renderedInListVariant:a,hasFocus:n.hasFocus||n.hasFocusWithin}))};ConnectorSourceRow.displayName="ConnectorSourceRow";let iF="connector",iD="canvas",iP="list",iR="file",iB="upload_file";var iW=a(0x22f5cc45d);let iV={name:"trash"},iH=new c.Ay("workflow_builder"),FileSourceRow=({item:e,itemValue:t,variant:a,params:n,configuredParameters:l,inputParameters:i,onChange:s})=>{let c=(0,r.useMemo)(()=>{let t;t=e.type===iD?lA.c.CANVAS_IDS:e.type===iP?lA.c.LIST_IDS:lA.c.FILE_IDS;let a=l[t]?.value??[];return Array.isArray(a)?a:[]},[l,e.type]),d=(0,r.useCallback)(t=>{let a;t.stopPropagation(),a=e.type===iD?lA.c.CANVAS_IDS:e.type===iP?lA.c.LIST_IDS:lA.c.FILE_IDS;let n=c.filter(t=>t!==e.id),r=i.find(e=>e.name===a);r&&s(r,n)},[c,e.id,e.type,i,s]),u=(0,r.useMemo)(()=>r.createElement(v.Ay,{tip:iH.t("Remove")},r.createElement(x.A,{"aria-label":iH.t("Remove"),svgIconProps:iV,onClick:d})),[d]);return r.createElement(iW.A,{key:e.id,fileId:t,className:o()("p-explorer_result--list",{"p-explorer_result--list--first":a===iC.First||a===iC.Single,"p-explorer_result--list--last":a===iC.Last||a===iC.Single}),showActions:!1,forceClickStyles:!0,secondaryContent:u,containerHasFocus:n.hasFocus,useListStyling:!0,forceHoverVisible:n.hasFocus})};FileSourceRow.displayName="FileSourceRow";let iq={name:"trash",size:"16"},iU=new c.Ay("workflow_builder"),VariableEntity=({primaryLabel:e,onRemove:t,isMissing:a=!1,renderedInListVariant:n,sourceLabel:l})=>{let i=(0,M.d4)(N.kZ),o=is.w.enabled,s=(0,r.useMemo)(()=>a?r.createElement("span",{className:iI().missingLabel},e):e,[a,e]),c=(0,r.useMemo)(()=>{let e=iU.t("Variable"),t=l?`${e} \xb7 ${l}`:e;return a?r.createElement("span",{className:iI().missingLabel},t):t},[a,l]),d=(0,r.useMemo)(()=>r.createElement("div",{className:iI().knowledgeSourceEntityContent},r.createElement(iu.A,{entityState:o,suppressDefaultColors:!0},r.createElement("div",{className:`${iI().variableIconContainer} ${a?iI().missing:""}`},r.createElement(p.Ah,{name:"css",size:"20"}))),r.createElement("div",{className:iI().labelWrap},r.createElement(id.A,{entityState:o,size:is.S.compact,primaryLabel:s,secondaryLabel:c}))),[o,s,c,a,"css"]),u=(0,r.useMemo)(()=>t?e=>{e.preventDefault(),e.stopPropagation(),t()}:void 0,[t]),m=(0,r.useMemo)(()=>r.createElement(v.Ay,{tip:i?iU.t("Remove variable"):"Remove variable"},r.createElement(x.A,{"aria-label":i?iU.t("Remove variable"):"Remove variable",svgIconProps:iq,onClick:u})),[u,i]);return r.createElement(ic.Ay,{size:is.S.compact,entityState:o,isRemovable:!1,isInteractive:!1,isFullWidth:!0,isFullHeight:!0,customMaxWidth:"100%",actionsBar:m,forceShowActionsBar:!0,shouldShrinkUnderDefaultWidth:!0,renderedInListVariant:n},d)};VariableEntity.displayName="VariableEntity";var iz=a(0x1e1fc678);let getSourceLabelForVariable=(e,t)=>{let a=t.groups.find(t=>t.id===e.source_id);if(a)return a.stepIndex?`Step ${a.stepIndex}`:(0,iz.T)(a.type,a.label,a.subtype)},ij=new c.Ay("workflow_builder"),VariableSourceRow=({item:e,itemValue:t,variant:a,variables:n,configuredParameters:l,inputParameters:i,onChange:s})=>{let c=(0,eX.x)(n.list,t),d=c&&!c.isTombstone?c.label:ij.t("Missing Data"),u=!c||c.isTombstone,m=c?getSourceLabelForVariable(c,n):void 0,p={[iD]:lA.c.CANVAS_IDS,[iP]:lA.c.LIST_IDS,[iR]:lA.c.FILE_IDS}[e.type],b=(0,r.useMemo)(()=>{let e=l[p]?.value??[];return Array.isArray(e)?e:[]},[l,p]),f=(0,r.useCallback)(()=>{let t=b.filter(t=>t!==e.id),a=i.find(e=>e.name===p);a&&s(a,t)},[b,i,e.id,p,s]);return r.createElement("div",{className:o()(iO().knowledgeSourceRow),style:{height:"62px"}},r.createElement(VariableEntity,{key:e.id,primaryLabel:d,onRemove:f,isMissing:u,renderedInListVariant:a,sourceLabel:m}))};VariableSourceRow.displayName="VariableSourceRow";let KnowledgeSourceRow=({item:e,variant:t,stepId:a,variables:n,params:l,externalResourcesArray:i,configuredParameters:o,inputParameters:s,onChange:c})=>{if(e.type===iF)return r.createElement(ConnectorSourceRow,{knowledgeSource:e.data,stepId:a,params:l,variant:t,externalResourcesArray:i,inputParameters:s,onChange:c});let d=e.data;return"string"==typeof d&&(0,e0.bs)(d)?r.createElement(VariableSourceRow,{item:e,itemValue:d,variant:t,variables:n,configuredParameters:o,inputParameters:s,onChange:c}):r.createElement(FileSourceRow,{item:e,itemValue:d,variant:t,params:l,configuredParameters:o,inputParameters:s,onChange:c})};KnowledgeSourceRow.displayName="KnowledgeSourceRow";var iG=a(0xcb24a23b),i$=a(0xbd3de346);let iK=new c.Ay("workflow_builder"),isFileUnavailable=e=>!e||e.isNonExistent||(0,i$.c4)(e)||(0,i$.uO)(e),useKnowledgeSourceAlerts=({segment:e,workflow:t,configuredParameters:a,variables:n})=>{let l=(0,e8.DY)(t),i=(0,M.d4)(N.kZ),o=(0,M.d4)(aC.Pz),s=(0,a0.XS)(t,e),c=(0,a0.nh)(t,e,s),d=(0,M.d4)(e=>(0,ng.W_)(e,l)),u=(0,r.useMemo)(()=>{let t=d?.[e.id];return!!t&&Object.values(t).some(e=>e.error)},[d,e.id]),m=(0,r.useMemo)(()=>{let e=a[lA.c.CANVAS_IDS]?.value??[];return Array.isArray(e)?e:[]},[a]),p=(0,r.useMemo)(()=>{let e=a[lA.c.LIST_IDS]?.value??[];return Array.isArray(e)?e:[]},[a]),b=(0,r.useMemo)(()=>{let e=a[lA.c.FILE_IDS]?.value??[];return Array.isArray(e)?e:[]},[a]),f=m.length>0||p.length>0||b.length>0,g=(0,M.d4)(e=>(0,aC.bO)(e,[...m,...p,...b])),h=(0,r.useMemo)(()=>{let t=e.config.slackFunction?.input_parameters;return t?{canvasParameter:t.find(e=>e.name===lA.c.CANVAS_IDS),listParameter:t.find(e=>e.name===lA.c.LIST_IDS),fileParameter:t.find(e=>e.name===lA.c.FILE_IDS)}:{}},[e.config.slackFunction?.input_parameters]),_=(0,r.useMemo)(()=>b.some(e=>{let t=o?o[e]:void 0;return!(0,e0.cn)(e)&&isFileUnavailable(t)}),[b,o]),y=(0,r.useMemo)(()=>m.some(e=>{let t=o?o[e]:void 0;return!(0,e0.cn)(e)&&isFileUnavailable(t)}),[m,o]),x=(0,r.useMemo)(()=>p.some(e=>{let t=o?o[e]:void 0;return!(0,e0.cn)(e)&&isFileUnavailable(t)}),[p,o]),v=(0,r.useMemo)(()=>(({canvasArray:e,listArray:t,fileArray:a},{canvasParameter:n,listParameter:r,fileParameter:l},i,o)=>{let s=new Map;if(n){let[t]=(0,iG.g)({variables:i,id:lA.c.CANVAS_IDS,value:e,isValidEmptyObject:!0,isRequired:n.is_required??!1,parameter:n,arrayItemType:n.items?.type,allFiles:o});s.set(lA.c.CANVAS_IDS,t)}if(r){let[e]=(0,iG.g)({variables:i,id:lA.c.LIST_IDS,value:t,isValidEmptyObject:!0,isRequired:r.is_required??!1,parameter:r,arrayItemType:r.items?.type,allFiles:o});s.set(lA.c.LIST_IDS,e)}if(l){let[e]=(0,iG.g)({variables:i,id:lA.c.FILE_IDS,value:a,isValidEmptyObject:!0,isRequired:l.is_required??!1,parameter:l,arrayItemType:l.items?.type,allFiles:o});s.set(lA.c.FILE_IDS,e)}return s})({canvasArray:m,listArray:p,fileArray:b},h,n,o),[m,p,b,h,n,o]),E=[...v.values()].flat(),k=(0,r.useMemo)(()=>{if(u)return{text:i?iK.t("There is an issue accessing a connected data source."):"There is an issue accessing a connected data source.",level:"error"};if(_&&E.some(e=>e.id.endsWith("_is_deleted_file"))||y&&s?.includes("workflow_canvas_not_found")||x&&s?.includes("workflow_list_not_found"))return{text:i?iK.t("One or more selected files were not found. Choose a different file to continue."):"One or more selected files were not found. Choose a different file to continue.",level:"error"};if(c&&s===r8.oh.FILE_SIZE_TOO_LARGE){let e=g.find(e=>!!e?.name&&c.includes(e?.name))?.id;if(e&&b.includes(e))return{text:c,level:"error"}}let e=v.get(lA.c.CANVAS_IDS)??[],t=v.get(lA.c.LIST_IDS)??[],a=v.get(lA.c.FILE_IDS)??[];return e.some(e=>e.id.endsWith("_is_greater_than_max"))?{text:i?iK.t("You can have a maximum of 10 {entityName}.",{entityName:iK.t("Canvases",{fallbackHash:"e2d397a06197e996f48faa9c0abfd3a2a80d15de",fallbackHashNs:"files"})}):`You can have a maximum of 10 ${iK.t("Canvases",{fallbackHash:"e2d397a06197e996f48faa9c0abfd3a2a80d15de",fallbackHashNs:"files"})}.`,level:"error"}:t.some(e=>e.id.endsWith("_is_greater_than_max"))?{text:i?iK.t("You can have a maximum of 10 {entityName}.",{entityName:iK.t("Lists",{fallbackHash:"57c9502a7d7d48fd4a86b45fefb2b163491c3ae1",fallbackHashNs:"files"})}):`You can have a maximum of 10 ${iK.t("Lists",{fallbackHash:"57c9502a7d7d48fd4a86b45fefb2b163491c3ae1",fallbackHashNs:"files"})}.`,level:"error"}:a.some(e=>e.id.endsWith("_is_greater_than_max"))?{text:i?iK.t("You can have a maximum of 10 {entityName}.",{entityName:iK.t("Files")}):`You can have a maximum of 10 ${iK.t("Files")}.`,level:"error"}:E.some(e=>e.id.endsWith("_is_missing_variables"))?{text:i?iK.t("Knowledge sources contain a missing variable.",{fallbackHash:"8224d4b6336ff8635e6cccf713f44fb694e92c70"}):"Knowledge sources contain a missing variable.",level:"error"}:E.some(e=>e.id.endsWith("_is_unavailable_variables"))?{text:i?iK.t("Knowledge sources contain an unavailable variable.",{fallbackHash:"02605f6dabeee59a9b76627b21f072b71011da74"}):"Knowledge sources contain an unavailable variable.",level:"error"}:E.some(e=>e.id.endsWith("_mixed_with_array_variables"))?{text:iK.t("Variables containing multiple items must not be mixed wih other items of the same type",{fallbackHash:"02605f6dabeee59a9b76627b21f072b71011da74"}),level:"error"}:i&&f?{text:iK.t("The contents of any Canvas, List, or File used with this step can be shared via the AI response and become visible to workflow users. Make sure you\u2019re ok with sharing this content before continuing."),level:"warning"}:null},[u,_,E,y,s,x,c,v,i,f,g,b]),w=k?.level==="error";return{alert:k,hasError:w}};var iY=a(0xc6a2c86f),iQ=a(0x6e0e2fb2),iZ=a(0xbe3df8c1),iJ=a(0x19561ce96),iX=a(0x212b4c697),i0=a(0x45cdfa9c),i1=a(0x16af7d0de);let i2=new c.Ay("workflow_builder"),KnowledgeSourceForm=({hermesFunction:e,functionCallbackId:t,onConfiguredParametersChange:a,onValidationChange:n,knowledgeSource:l,type:i,inputParameter:o,existingParameters:s,stepId:c})=>{let d=(0,M.d4)(N.kZ),m=(0,aD.Y)(),p=(0,r.useMemo)(()=>{let t=i===iF?e.input_parameters??[]:[o],a=(0,i0.k)(t);return{...e,input_parameters:a}},[e,i,o]),b=(0,r.useMemo)(()=>{let e;return e=i===iF?l?.inputs??{}:{[o.name]:{value:s}},{id:l?.id??c??`temp_third_party_${t}`,type:rV.SLACK_FUNCTION,config:{function_id:l?.id??p.id,inputs:e,slackFunction:p,workflow_id:m}}},[i,l?.id,l?.inputs,t,p,m,o.name,s,c]),[f,g]=useSegmentReducer((0,r.useMemo)(()=>getSegmentReducer(b,{},t),[b,t]),b),h=f.segment;(0,r.useEffect)(()=>{a(h.config.inputs||{})},[h,a]),(0,r.useEffect)(()=>{n(f.computed?.isValid??!1)},[f.computed?.isValid,n]);let _=(0,r.useCallback)(()=>{},[]),y=(0,r.useMemo)(()=>{let e=h.config.inputs?.[o.name]?.value;return Array.isArray(e)?e.filter(e=>"string"==typeof e):[]},[h,o.name]),x=(0,r.useCallback)((e,t)=>{let n=Array.isArray(t)?t:[t];a({...h.config.inputs||{},[o.name]:{value:n}})},[h,o,a]);return i===iB?r.createElement("div",null,y.length>0&&r.createElement("div",{className:"margin_bottom_100"},r.createElement(u.Ay,{level:u.A_.warning},d?i2.t("The contents of any {fileType} used with this step can be shared via the AI response and become visible to workflow users. Make sure you\u2019re ok with sharing this content before continuing.",{fileType:i2.t("File",{fallbackHashNs:"files"})}):"The contents of any file used with this step can be shared via the AI response and become visible to workflow users. Make sure you\u2019re ok with sharing this content before continuing")),r.createElement("label",{htmlFor:"upload-file-input",className:"c-label"},o.title||i2.t("File",{fallbackHashNs:"files"})),r.createElement(TestFileUpload,{value:y,parameter:o,callbackId:t,onChange:x})):r.createElement(C.ZH.Provider,{value:g},r.createElement(SlackFunctionSegmentForm,{state:f,isExistingStep:!1,switchPane:_,activePane:tg.k.DEFAULT,noFormPadding:!0,allowVariables:i!==iF,isFunctionForKnowledgeSource:!0}))};KnowledgeSourceForm.displayName="KnowledgeSourceForm";let KnowledgeSourceFormModal=({onSave:e,appId:t,inputParameter:a,existingParameters:n,type:i,id:o,stepId:s})=>{let c=(0,l.wA)(),[d,m]=(0,r.useState)({}),[p,b]=(0,r.useState)(!1),f=(0,aD.Y)(),g=(0,M.d4)(N.kZ),_=(0,r.useMemo)(()=>{if(t)return ih[t]},[t]),y=(0,r.useMemo)(()=>{if(i===iF)return(Array.isArray(n)?n:[]).find(e=>"object"==typeof e&&e&&"id"in e&&e?.id===o)},[i,n,o]),x=(0,M.d4)(e=>{if(_)return(0,t5.sw)(e,[_])?.[0]}),v=(0,M.d4)(e=>(0,t5.hj)(e,i1.Ez.ai_answer,!0)),E=x??v,w=(0,r.useCallback)(e=>{m(e)},[]),S=(0,r.useCallback)(e=>{b(e)},[]),C=(0,r.useMemo)(()=>{if(i!==iF||0===Object.keys(d).length)return!1;let e=Array.isArray(n)?n:[];return o?e.filter(e=>e.id!==o).some(e=>(0,rm.A)(e.inputs,d)):e.some(e=>{if(!t)return!1;let a=i_[t];return!!e.inputs[a]&&!!d[a]&&(0,rm.A)(e.inputs[a],d[a])})},[i,t,n,o,d]),A=(0,r.useCallback)(()=>{e(i===iF?{inputParameter:a,configuredParameters:{id:o??(0,k.A)(),function_id:E.id,inputs:d,workflow_id:f}}:{inputParameter:a,configuredParameters:d}),c((0,lT.O)({closeNamed:[ib]}))},[i,a,o,E,d,e,c,f]),T=(0,r.useCallback)(()=>{c((0,lT.O)({closeNamed:[ib]}))},[c]),I=(0,r.useMemo)(()=>{if(i===iF)return!!E?.input_parameters?.length&&E.input_parameters.every(e=>{if(!e.is_required)return!0;let t=d[e.name]?.value;return null!=t&&""!==t});let e=d[a.name]?.value;return Array.isArray(e)&&e.length>0||"string"==typeof e&&(0,e0.cn)(e)},[i,E,d,a]),L=(0,r.useMemo)(()=>p&&I,[p,I]);return r.createElement(tS.aF,{onClose:T,contentLabel:g?i2.t("Add Knowledge Source"):"Add Knowledge Source",shouldCloseOnOverlayClick:!1},r.createElement(tS.$m,null,r.createElement(tS.rQ,null,r.createElement(tS.Rc,{title:g?i2.t("Add Knowledge Source"):"Add Knowledge Source"})),r.createElement(tS.qf,null,C&&r.createElement(u.Ay,{level:u.A_.error},g?i2.t("This knowledge source has already been selected. Please choose a different one."):"This knowledge source has already been selected. Please choose a different one."),E&&!(0,rZ.GU)(E)&&r.createElement("div",{className:"margin_top_100 margin_bottom_100"},r.createElement(KnowledgeSourceForm,{key:`form-${E.id}-${_}-${i}`,hermesFunction:E,functionCallbackId:_??"unknown",onConfiguredParametersChange:w,onValidationChange:S,knowledgeSource:y,type:i,inputParameter:a,existingParameters:n,stepId:s})))),r.createElement(tS.jl,null,r.createElement(tS.ox,null,r.createElement(h.Ay,{type:"outline",onClick:T,"aria-label":i2.t("Cancel")},i2.t("Cancel")),r.createElement(h.lV,{type:"primary",disabled:!L||i===iF&&(!t||C),onClick:A,"aria-label":g?i2.t("Add Data Source"):"Add Data Source"},g?i2.t("Add Data Source"):"Add Data Source"))))};KnowledgeSourceFormModal.displayName="KnowledgeSourceFormModal";let i4=new c.Ay("workflow_builder"),KnowledgeSourceMenuItemLabel=({provider:e,status:t})=>{let a=(0,M.d4)(t=>(0,iJ.dJ)(t,e)),n=(0,M.d4)(N.kZ),l=a?.app?.profile?.name,i=(0,r.useMemo)(()=>t===iw?n?i4.t("Connected"):"Connected":t===ix?n?i4.t("Request access"):"Request access":t===iv?n?i4.t("Pending approval"):"Pending approval":"loading"===t?i4.t("Loading"):i4.t("Connect"),[t,n]);return r.createElement("span",{className:iO().knowledgeSourceMenuItemLabel},r.createElement("span",{className:iO().knowledgeSourceMenuItemLeft},a?.app?.profile?.icons?.image32?r.createElement("img",{className:iO().knowledgeSourceMenuItemIcon,src:a?.app?.profile?.icons?.image32,alt:"","data-qa":"knowledge-source-menu-item-icon"}):null,l),r.createElement("span",{className:iO().knowledgeSourceMenuItemRight},i,t===iw&&r.createElement(p.Ah,{name:"check-circle",size:"18"})))};KnowledgeSourceMenuItemLabel.displayName="KnowledgeSourceMenuItemLabel";var i8=a(0x1a02c72b5),i5=a(0xd6a16321),i6=a(0xc4548bcd),i3=a(0x1d600678);let i7=a.p+"ai-step-external-resources-icons-2ccf34e.png",i9=new c.Ay("workflow_builder"),MenuItemLabel=({icon:e,label:t,sourceLabel:a})=>r.createElement("span",{className:iO().knowledgeSourceMenuItemTitleWrap},r.createElement("span",{className:iO().knowledgeSourceMenuItemLeft},r.createElement(p.Ah,{name:e,size:"18"})),r.createElement(a_.A,{lines:1},t),a&&r.createElement("span",{className:iO().knowledgeSourceMenuItemStepIndex},r.createElement(a_.A,{lines:1},a)));MenuItemLabel.displayName="MenuItemLabel";let KnowledgeSourcesCard=({segment:e,workflow:t,onChange:a,configuredParameters:n,inputParameters:i,variables:o})=>{let s=(0,l.wA)(),{openSpeedBump:c,closeSpeedBump:d}=(0,C.qE)(),m=(0,M.d4)(N.kZ),b=(0,M.d4)(N.oI),f=(0,M.d4)(e=>"allow_all"===(0,i3.x)(e,"disable_file_uploads")),g=(0,M.d4)(e=>(0,i3.x)(e,"slack_ai_files_search_opt_out")),_=g?.all_file_opt_out??!1,x=(0,lC.A)({variables:o,callbackId:(0,e5.Dp)(e),isTriggerSegment:!1})??o,{alert:v}=useKnowledgeSourceAlerts({segment:e,workflow:t,configuredParameters:n,variables:x}),E=(0,r.useMemo)(()=>x.list.filter(e=>{let t=e.type===e6.TE.Array?e.items?.type:e.type;return t&&(t===e6.TE.SlackTypesCanvasId||t===e6.TE.SlackTypesListId||t===e6.TE.SlackTypesFileId)&&!e.isDisabled}),[x]),k=i.find(e=>e.name===lA.c.EXTERNAL_RESOURCES),w=i.find(e=>e.name===lA.c.CANVAS_IDS),S=i.find(e=>e.name===lA.c.LIST_IDS),A=(0,r.useMemo)(()=>{let e=i.find(e=>e.name===lA.c.FILE_IDS);if(e)return{...e,is_hidden:!1}},[i]),T=(0,r.useMemo)(()=>n[lA.c.EXTERNAL_RESOURCES]?.value??[],[n]),I=(0,r.useMemo)(()=>{let e=n[lA.c.CANVAS_IDS]?.value??[];return Array.isArray(e)?e:[]},[n]),L=(0,r.useMemo)(()=>{let e=n[lA.c.LIST_IDS]?.value??[];return Array.isArray(e)?e:[]},[n]),O=(0,r.useMemo)(()=>{let e=n[lA.c.FILE_IDS]?.value??[];return"string"==typeof e&&(0,e0.cn)(e)?[e]:Array.isArray(e)?e:[]},[n]),F=(({stepId:e,fetchFunctionAuths:t})=>{let a=(0,aD.Y)(),n=(0,e2.j)(),i=n&&"workflow"in n?(0,e8.Dv)(e,n.workflow):void 0,o=(0,l.wA)(),[s,c]=(0,r.useState)(iQ.r.NOT_STARTED),d=(0,M.d4)(e=>(0,t5.sw)(e,Object.values(ih))),u=(0,r.useMemo)(()=>d.map(e=>e?.id),[d]),m=(0,M.d4)(r4.mh),p=(0,r.useMemo)(()=>Object.values(m).flatMap(e=>e.validTokens).join("-"),[m]),b=(0,iY.A)(p)!==p;(0,r.useEffect)(()=>{let fetchFunctionAuth=async()=>{c(iQ.r.IN_FLIGHT);try{u.forEach(async(t,n)=>{if(t){let r={functionId:t,id:e,inputs:i?.inputs??{}};await o((0,iZ.J)({appId:iy[n],functionId:t,workflowId:a,step:r}))}})}catch{c(iQ.r.ERROR)}finally{c(iQ.r.FINISHED)}};(b||t)&&fetchFunctionAuth()},[u,o,i,a,b,t,e]),(0,r.useEffect)(()=>()=>{o((0,iX.RZ)()),c(iQ.r.NOT_STARTED)},[]);let f=(0,r.useMemo)(()=>e=>(0,iJ.Rp)(e,iy),[]),g=(0,M.d4)(f),h=(0,M.d4)(e=>(0,iA.Aw)(e,iy)),_=(0,r.useMemo)(()=>iy.reduce((e,t)=>{let a=g[t]?.distributionStatus,n=g[t]?.configurationStatus;if(h[t])if(a){let r;e[t]=(r=iS[a])===iE&&n!==ip.aW.READY?iv:r}else e[t]=iE;else e[t]=ik;return e},{}),[g,h]);return(0,r.useMemo)(()=>iy.reduce((e,t)=>{let a=(Object.values(m).find(e=>e.appId===t)?.validTokens??[]).length>0;return s===iQ.r.IN_FLIGHT?e[t]="loading":_[t]===iE?e[t]=a?"connected":"connect":e[t]=_[t],e},{}),[m,_,s])})({stepId:e.id,fetchFunctionAuths:0===T.length}),D=(0,r.useCallback)(e=>{if(e.inputParameter.name===lA.c.EXTERNAL_RESOURCES){let t=i.find(e=>e.name===lA.c.EXTERNAL_RESOURCES);t&&"inputs"in e.configuredParameters&&"function_id"in e.configuredParameters&&"id"in e.configuredParameters&&a(t,[...T.filter(t=>t.id!==e.configuredParameters.id),e.configuredParameters])}else{if("inputs"in e.configuredParameters)return;a(e.inputParameter,e.configuredParameters[e.inputParameter.name]?.value)}},[T,i,a]),P=(0,r.useCallback)(({type:t,appId:a,sourceId:n})=>{let l,i;t===iD?(l=w,i=I):t===iP?(l=S,i=L):t===iR||t===iB?(l=A,i=O):(l=k,i=T),l&&(a&&t===iF&&F[a]===ix?s((0,ap.q)({name:ib,isStackable:!0,element:r.createElement(io.u,{appId:a})})):s((0,ap.q)({name:ib,isStackable:!0,element:r.createElement(KnowledgeSourceFormModal,{inputParameter:l,existingParameters:i,type:t,onSave:D,appId:a,id:n,stepId:e.id})})))},[F,w,I,S,L,A,O,k,T,s,D,e.id]),R=(0,r.useCallback)(e=>()=>{P(e)},[P]),B=(0,r.useCallback)(e=>r.createElement(KnowledgeSourceMenuItemLabel,{provider:e,status:F[e]}),[F]),W=(0,r.useCallback)(e=>{let t=e.type===e6.TE.Array?e.items?.type:e.type;return t===e6.TE.SlackTypesCanvasId?I.some(t=>void 0!==(0,eX.x)([e],t)):t===e6.TE.SlackTypesListId?L.some(t=>void 0!==(0,eX.x)([e],t)):t===e6.TE.SlackTypesFileId&&O.some(t=>void 0!==(0,eX.x)([e],t))},[I,L,O]),V=(0,r.useCallback)(e=>{let t,n,r=e.type===e6.TE.Array?e.items?.type:e.type;if(r===e6.TE.SlackTypesCanvasId)t=w,n=I;else if(r===e6.TE.SlackTypesListId)t=S,n=L;else{if(r!==e6.TE.SlackTypesFileId)return;t=A,n=O}t&&(n.includes(e.id)?a(t,n.filter(t=>t!==e.id)):a(t,[...n,e.id]))},[w,I,S,L,A,O,a]),H=(0,r.useCallback)(e=>()=>{V(e)},[V]),q=(0,r.useCallback)(e=>{let t=b?Object.keys(ih).map(e=>{if(F[e]===ik)return null;let t=F[e]===iv||"config_required"===F[e];return r.createElement(j.Dr,{key:`${e}-${F[e]}`,label:B(e),onSelected:R({type:iF,appId:e}),disabled:t})}):[],a=m?[r.createElement(j.Dr,{key:"canvas-entity",label:r.createElement(MenuItemLabel,{icon:"canvas-content",label:i9.t("Canvas")}),onSelected:R({type:iD}),disabled:!1}),r.createElement(j.Dr,{key:"list-entity",label:r.createElement(MenuItemLabel,{icon:"lists",label:i9.t("List")}),onSelected:R({type:iP}),disabled:!1})]:[];m&&!_&&a.push(r.createElement(j.Dr,{key:"select-file-entity",label:r.createElement(MenuItemLabel,{icon:"file-browser",label:i9.t("Files")}),onSelected:R({type:iR}),disabled:!1})),f&&m&&!_&&a.push(r.createElement(j.Dr,{key:"file-entity",label:r.createElement(MenuItemLabel,{icon:"file-upload",label:m?i9.t("Upload a File"):"Upload a File"}),onSelected:R({type:iB}),disabled:!1}));let n=E.map(e=>r.createElement(j.Dr,{key:`var-${e.id}`,type:il.A.checkbox,checked:W(e),label:r.createElement(MenuItemLabel,{icon:"css",label:e.label,sourceLabel:getSourceLabelForVariable(e,o)}),onSelected:H(e)})),l=n.length>0&&(t.length>0||a.length>0),i=t.length>0&&(n.length>0||a.length>0);return r.createElement(j.Ay,{...e,width:340},a,l&&r.createElement(j.bX,null),n.length>0&&n,i&&r.createElement(j.bX,null),t)},[b,m,R,f,_,E,F,B,W,H,o]),U=(0,r.useMemo)(()=>m?[...I.map(e=>({type:iD,id:e,data:e})),...L.map(e=>({type:iP,id:e,data:e})),...O.map(e=>({type:iR,id:e,data:e})),...T.map(e=>({type:iF,id:e.id,data:e}))]:T.map(e=>({type:iF,id:e.id,data:e})),[m,I,L,O,T]),z=(0,r.useMemo)(()=>T.map(e=>e.function_id),[T]),G=(0,M.d4)(e=>(0,t5.gL)(e,{ids:z})),$=(0,r.useMemo)(()=>{let e={};return T.forEach((t,a)=>{let n=G[a],r=getKnowledgeSourceUrl(t,n);e[t.id]={url:r,appId:n?.app_id??"",functionId:t.function_id}}),e},[T,G]),K=(0,r.useMemo)(()=>U.map(e=>e.id),[U]),Y=(0,r.useCallback)(e=>{c({heading:m?i9.t("Discard changes and open resource?"):"Discard changes and open resource?",message:i9.rt("Your work will not be saved."),onCancel:d,onContinue:()=>{d(),e()},continueButtonLabel:m?i9.t("Discard & Open"):"Discard & Open"})},[c,m,d]),Q=(0,r.useCallback)(e=>{let t=U.find(t=>t.id===e.id);if(t&&!("string"==typeof t.id&&(0,e0.bs)(t.id))){if(t.type===iF){let e=t.data,a=$[e.id];a?.url?(0,i6.A)(a.url):P({type:iF,appId:a?.appId??"",sourceId:e.id});return}t.type===iD&&Y(()=>{s((0,i8.o)((0,i5.mo)({id:t.data}))),s((0,lT.O)())}),t.type===iP&&Y(()=>{s((0,i8.o)((0,i5.st)({listId:t.data}))),s((0,lT.O)())}),t.type===iR&&Y(()=>{s((0,i8.o)((0,i5.EJ)(t.data))),s((0,lT.O)())})}},[U,$,s,P,Y]),Z=(0,r.useCallback)(e=>{let t=U.length;return 1===t?iC.Single:0===e?iC.First:e===t-1?iC.Last:iC.Middle},[U.length]),J=(0,r.useCallback)((t,l)=>{let s=U[t];if(!s)return null;let c=Z(t);return r.createElement(KnowledgeSourceRow,{item:s,variant:c,stepId:e.id,variables:o,params:l,externalResourcesArray:T,configuredParameters:n,inputParameters:i,onChange:a})},[U,Z,e.id,o,T,n,i,a]);return(b||m)&&(!b||m||0!==Object.keys(F).length)?r.createElement("div",{className:"margin_top_100 margin_bottom_100"},r.createElement("div",{className:iO().knowledgeSourcesHeader},r.createElement(y.A,{text:m?i9.t("Files & external sources"):"Files & external sources"}),r.createElement(j.cQ,{renderMenu:q,position:"bottom-right",closeOnSelect:!0},r.createElement(h.$n,{type:"ghost",size:"small","aria-label":m?i9.t("Add a Source"):"Add a Source"},r.createElement("span",{className:"margin_right_25"},r.createElement(p.Ah,{name:"plus"})),m?i9.t("Add a Source"):"Add a Source"))),v&&r.createElement(u.Ay,{id:ig,level:"error"===v.level?u.A_.error:u.A_.warning,className:"margin_bottom_100"},v.text),0===U.length?r.createElement("div",{className:iO().emptyStateContainer},r.createElement("p",{className:iO().emptyStateText},r.createElement("strong",null,m?i9.t("Add files, canvases, lists, or connected sources (Google Drive, Confluence, etc.) the AI can reference"):"Add files, canvases, lists, or connected sources (Google Drive, Confluence, etc.) the AI can reference")),r.createElement("img",{src:i7,className:iO().emptyStateImage,alt:""})):r.createElement("div",{className:iO().knowledgeSourcesList},r.createElement(lk.A,{disableHeight:!0},({width:e})=>r.createElement(ii.A,{width:e,height:62*U.length,keys:K,onItemClick:Q,rowRenderer:J})))):null};KnowledgeSourcesCard.displayName="KnowledgeSourcesCard";let oe=new c.Ay("workflow_builder"),AiStepRightPanel=({segment:e,workflow:t,testDisabled:a,configuredParameters:n,nonPromptSlackFunctionParameters:l,onChange:i,variables:s,formatVariableBeforeInsert:c,callbackId:d})=>{let m=(0,M.d4)(N.kZ),b=(0,M.d4)(N.dI),f=(0,nR.A)(),[g,_]=(0,r.useState)(!0),[y,x]=(0,r.useState)(!1),[v,E]=(0,r.useState)(k.A),w=(0,r.useCallback)((e,t)=>{let a=t??!y;x(a),a&&_(!1)},[y,_]),S=(0,r.useMemo)(()=>m?l.filter(e=>e.name!==lA.c.EXTERNAL_RESOURCES&&e.name!==lA.c.CANVAS_IDS&&e.name!==lA.c.LIST_IDS&&e.name!==lA.c.FILE_IDS):l,[m,l]),C=(0,r.useCallback)((e,t)=>{let a=t??!g;_(a),a&&w(void 0,!1)},[g,w]),A=(0,r.useMemo)(()=>({...e,config:{...e.config,inputs:n}}),[e,n]),T=(0,r.useCallback)(e=>{e.stopPropagation(),(0,aE.K$)({clogger:f,uiArgs:{step:tK.UiStep.WORKFLOWS_AI_STEP_DEFAULT_MODAL},uiProperties:{element_name:aE.KC.AiStepTestRun}}),w(void 0,!0),E((0,k.A)())},[f,w,E]);return r.createElement("div",{className:lN().aiStepRightPanel},r.createElement("div",{className:o()(lN().sectionContainer,lN().contentSourcesContainer,{[lN().expanded]:g})},r.createElement("div",{className:lN().sectionHeader},r.createElement(h.Nm,{onClick:C,className:lN().sectionHeaderContent,"aria-expanded":g,"aria-controls":"context-sources-content"},r.createElement(p.Ah,{name:g?"caret-down-full":"caret-up-full"}),r.createElement("div",{id:"context-sources-header-text",className:lN().sectionHeaderText},b?oe.t("Context sources"):"Context sources"))),r.createElement(tS.$m,{"aria-labelledby":"context-sources-header-text",id:"context-sources-content"},r.createElement("div",{className:lN().contentSourcesContent},S&&S.length>0&&r.createElement(aj.v,{inputParameters:S,configuredParameters:n,onChange:i,variables:s,formatVariableBeforeInsert:c,callbackId:d,stepId:e.id,oAuthParameter:void 0}),r.createElement(KnowledgeSourcesCard,{segment:e,workflow:t,onChange:i,configuredParameters:n,inputParameters:l,variables:s}),r.createElement(u.Ay,{level:u.A_.info},b?oe.t("Links included in the prompt or additional context will not be crawled or used to generate responses."):"Links included in the prompt or additional context will not be crawled or used to generate responses.")))),r.createElement("div",{className:o()(lN().sectionContainer,lN().testPromptContainer,{[lN().expanded]:y})},r.createElement("div",{className:lN().sectionHeader},r.createElement(h.Nm,{onClick:w,className:lN().sectionHeaderContent,"aria-expanded":y,"aria-controls":"simulate-prompt-output-content"},r.createElement(p.Ah,{name:y?"caret-down-full":"caret-up-full"}),r.createElement("div",{id:"simulate-prompt-output-header-text",className:lN().sectionHeaderText},b?oe.t("Simulate prompt output"):"Simulate prompt output")),r.createElement(t7.Ay,{className:lN().sectionHeaderButton,onClick:T,disabled:a,type:"outline",size:"small"},r.createElement(p.Ah,{name:"ai-sparkle"}),oe.t("Run"))),r.createElement(TestPromptPanel,{segment:A,workflow:t,disabled:a,testKey:v})))};AiStepRightPanel.displayName="AiStepRightPanel";let ot=new c.Ay("workflow_builder"),AiStepDefaultModal=({title:e,onClose:t,icon:a,segment:n,onSave:i,workflow:s,speedBumpContext:c,saving:d=!1,saveError:u=null,renderSaveError:m,isExistingSegment:p=!1,isSegmentModified:b=!1,onNavigateBack:f})=>{let _=(0,M.d4)(N.dI),y=(0,e4.EM)(n),x=(0,e5.Dp)(n),v=(0,l.wA)(),{showSpeedBump:E}=(0,ae.k)(),{speedBumpState:w}=c,[S,T]=(0,r.useState)(k.A),L=(0,r.useCallback)(()=>{T((0,k.A)())},[]),{isValid:O=!1}=(0,C.Qk)(),[,F]=(0,r.useState)("0"),{onSubmit:D,shouldEnableSaveForInitialSubmit:P,hasBlockingError:R}=(0,I.b)(F),B=(0,e5.ln)(n),W=(0,r.useMemo)(()=>B?.map(e=>(0,eU.w)(e))||[],[B]),V=W?.find(e=>e.name===lA.c.PROMPT),H=W?.filter(e=>e.name!==lA.c.PROMPT),{configuredParameters:q,formatVariableBeforeInsert:U,onChange:z}=(({segment:e,variables:t,inputParameters:a,slackFunction:n})=>{let l=(0,C.rC)(),i=(0,M.d4)(N.$T),o=(0,r.useMemo)(()=>{let t={};return(0,ty.q2)(e)?n?(0,ty.Jl)(e,n,i):t:(a&&0!==a.length&&a.forEach(a=>{let n=(0,e5.RE)(e,a.name);n&&(t[a.name]=n)}),t)},[i,a,e,n]),s=(0,r.useCallback)((e,t)=>{let{source:a,sourceReference:r}=e;return("trigger"===a&&r&&l((0,A.aI)({value:r})),t?.skipMacro)?e:(0,e3.Xq)(e,{fromRichText:t?.isRichText,appId:n?.app_id,parameterType:t?.parameterType,stepId:n?.id,callbackId:n?.callback_id})},[n?.app_id,n?.id,n?.callback_id,l]),c=(0,r.useCallback)(e=>{let a=[],fillRequiredContextRecursively=(e,n,r=0)=>{r>=n||(e&&"object"==typeof e?Object.values(e):[e]).forEach(e=>{if("string"==typeof e&&(0,e0.cn)(e)){let n=(0,eX.x)(t.list,e);if(!n)return;"trigger"===n.source&&n.sourceReference&&a.push(n.sourceReference)}null!==e&&"object"==typeof e&&fillRequiredContextRecursively(e,n,r+1)})};fillRequiredContextRecursively(e,10),l((0,A.aI)({value:a}))},[l,t.list]);return{configuredParameters:o,formatVariableBeforeInsert:s,onChange:(0,r.useCallback)((e,t,a,n)=>{c(t),n?.dynamicInputState&&l((0,tG.T)({[e.name]:n.dynamicInputState})),l((0,tG.qq)({parameter:e,value:t,label:a,options:n,experimentThirdPartyUserFormParityGroupOn:i}))},[l,i,c])}})({segment:n,variables:y,inputParameters:B,slackFunction:(0,e5.P)(n)}),{hasError:j}=useKnowledgeSourceAlerts({segment:n,workflow:s,configuredParameters:q,variables:y}),G=(0,r.useMemo)(()=>{let e=b||!p,t=!d&&!R&&e&&O;return P||t},[d,R,O,p,b,P]),$=(0,r.useCallback)(()=>{!j&&(!O||P||d||i(),P&&D())},[j,O,P,d,i,D]);(0,r.useEffect)(()=>{E(w.isVisible??!1)},[w.isVisible,E]);let K=(0,r.useCallback)(()=>r.createElement(tS.ty,{heading:w.heading,cancelButtonLabel:w.cancelButtonLabel,continueButtonLabel:w.continueButtonLabel,continueButtonIsDisabled:w.continueButtonIsDisabled,continueButtonIsLoading:d,continueButtonType:w.continueButtonType,onCancel:w.onCancel,onContinue:w.onContinue,description:w.message}),[w.cancelButtonLabel,w.continueButtonIsDisabled,w.continueButtonLabel,w.continueButtonType,w.heading,w.message,w.onCancel,w.onContinue,d]),Y=(0,r.useMemo)(()=>V?.type===e6.HN.SlackTypesRichText?V:void 0,[V]),Q=(0,r.useMemo)(()=>r.createElement(AiPromptEditorModal,{parameter:Y,value:q[lA.c.PROMPT]?.value||g.Ml,onChange:z,variables:y,formatVariableBeforeInsert:U,parameters:W,configuredParameters:q,callbackId:x,experimentWfbAiAnswerStepGroupOn:_,onClose:L,allowVariables:!0,workflowId:s.workflow.id,segment:n}),[Y,q,z,y,U,W,x,_,L,s.workflow.id,n]),Z=(0,r.useCallback)(()=>{V&&Y&&v((0,ap.q)({element:Q,isStackable:!0}))},[V,Y,v,Q]),J=(0,r.useCallback)(()=>{f?.()},[f]),X=(0,r.useMemo)(()=>({segment:n,enableExpandCollapsePromptButton:!0,onExpandCollapsePromptClick:Z,onCollapsePromptClick:L,enablePromptToolsButton:!0,isPromptExpanded:!1}),[n,Z,L]);return r.createElement(r.Fragment,null,r.createElement(tS.rQ,null,f&&r.createElement(ai.E,{workflowId:s.workflow.id,onNavigateBack:J,isSegmentModal:!0}),r.createElement(tS.Rc,null,r.createElement("div",{className:o()(lN().modalTitleBarContentContainer,{[lN().hasNoBackButton]:!f})},r.createElement("div",{className:lN().modalTitleBarContentLeft},a,r.createElement("h1",{className:lN().modalTitleText},e))))),r.createElement("div",{className:lN().modalContent},r.createElement(FillParentContainer,null,r.createElement("div",{className:lN().inputParametersWrapper},r.createElement("div",{className:lN().promptInputWrapper},V&&Y&&r.createElement(CustomPromptInput,{key:S,labelClassName:lN().promptLabel,parameter:Y,value:q[lA.c.PROMPT]?.value||g.Ml,onChange:z,variables:y,formatVariableBeforeInsert:U,parameters:W,configuredParameters:q,callbackId:x,allowVariables:!0,required:Y.is_required,experimentWfbAiAnswerStepGroupOn:_,wfbAiPromptButtons:X}),u&&m&&r.createElement(tB.A,null,m(u))),r.createElement(AiStepRightPanel,{segment:n,workflow:s,testDisabled:d||R||!O||j,configuredParameters:q,nonPromptSlackFunctionParameters:H,onChange:z,variables:y,formatVariableBeforeInsert:U,callbackId:x})))),r.createElement(tS.jl,{renderSpeedBump:K},r.createElement(tS.ox,null,r.createElement(h.Ay,{type:"outline",onClick:t,disabled:d,"aria-label":ot.t("Cancel")},ot.t("Cancel")),r.createElement(h.lV,{type:"primary",loading:d,disabled:j||!G,"aria-describedby":j?ig:void 0,onClick:$,"aria-label":ot.t("Save")},ot.t("Save")))))};AiStepDefaultModal.displayName="AiStepDefaultModal";var oa=a(0x1f355b555),on=a(0x62eaf10),or=a.n(on);let loading_skeleton_LoadingSkeleton=()=>r.createElement(tS.qf,null,r.createElement("div",{"data-qa":"button-add-edit-modal-loading-skeleton",className:or().loadingSkeleton},r.createElement("div",{className:or().loadingContainer},r.createElement(eR.A,{width:"100%",height:140,borderRadius:4}),r.createElement("div",{className:or().label},r.createElement(eR.A,{width:"25%",height:22,borderRadius:4})),r.createElement("div",{className:"display_flex flex_direction_row gap_50"},r.createElement(eR.A,{width:"75%",height:36,borderRadius:4}),r.createElement(eR.A,{width:"25%",height:36,borderRadius:4})),r.createElement("div",{className:or().label},r.createElement(eR.A,{width:"25%",height:22,borderRadius:4})),r.createElement(eR.A,{width:"100%",height:36,borderRadius:4}),r.createElement("div",{className:or().label},r.createElement("div",{className:or().checkbox},r.createElement(eR.A,{width:"25%",height:36,borderRadius:4}),r.createElement(eR.A,{width:"25%",height:36,borderRadius:4}))),r.createElement("div",{className:or().label},r.createElement(eR.A,{width:"100%",height:6,borderRadius:4})))));loading_skeleton_LoadingSkeleton.displayName="LoadingSkeleton";var ol=a(0xc70ec6a6),oi=a.n(ol);let oo=new c.Ay("workflow_builder"),button_color_ButtonColorOptionLabel=({buttonStyle:e})=>r.createElement("div",{className:o()(oi().optionLabelColor,oi()[`optionLabelColor__${e}`])},r.createElement("span",{className:"offscreen"},{primary:oo.t("Primary (green)",{fallbackHash:"ba144ea01fa9962c0dbe1fe6c4c113d0063fa55f"}),outline:oo.t("Outline"),danger:oo.t("Danger (red)",{fallbackHash:"f99914a1464040a7af118f93747699cf8566efa3"})}[e]),r.createElement(p.Ah,{name:"formatting"}));button_color_ButtonColorOptionLabel.displayName="ButtonColorOptionLabel";let button_color_ButtonColor=({buttonStyle:e,handleChange:t})=>{let a=(0,r.useMemo)(()=>[{label:r.createElement(button_color_ButtonColorOptionLabel,{buttonStyle:"outline"}),value:"outline"},{label:r.createElement(button_color_ButtonColorOptionLabel,{buttonStyle:"primary"}),value:"primary"},{label:r.createElement(button_color_ButtonColorOptionLabel,{buttonStyle:"danger"}),value:"danger"}],[]),n=(0,r.useMemo)(()=>a.find(t=>t.value===(e??"outline")),[e,a]),l=(0,r.useCallback)(({value:e})=>{t("outline"===e?void 0:e)},[t]);return r.createElement(y.A,{"data-qa":"send-message-button-color",htmlFor:"send-message-button-color",text:oo.t("Color"),"aria-label":oo.t("Button Color",{fallbackHash:"1d0c8304baedcf8e3a78982c2e7c0b04622bf2a0",fallbackHashNs:"lists"}),className:""},r.createElement(ef.Ay,{options:a,width:"100",onOptionSelected:l,selectedOption:n}))};button_color_ButtonColor.displayName="ButtonColor";var os=a(0x234aee340),oc=a.n(os);let od=new c.Ay("workflow_builder"),ButtonConfigurations=({button:e,variables:t,onChange:a,onTypeChange:n,onBehaviourChange:l,formatVariableBeforeInsert:i,multipleContinueButtonsExist:o,continueButtonExists:s,hasDuplicateContinueLabel:c,isNestedStep:d})=>{let u=(0,r.useCallback)(t=>{a({text:{...e.text,text:t}})},[a,e]),m=(0,r.useCallback)(e=>l(e),[l]),p=(0,r.useCallback)(e=>n(e),[n]),b=(0,r.useCallback)(e=>a({style:e}),[a]),f=(0,r.useMemo)(()=>c?od.t("Please choose a different label, this one already exists."):"",[c]),g=od.t("Example: Continue");return r.createElement("div",{className:"padding_bottom_100"},r.createElement("div",{className:oc().buttonDisplayContainer},r.createElement("div",{className:oc().buttonLabel},r.createElement(y.A,{htmlFor:"message_button_label_input",text:od.t("Button label"),id:"message_button_label_label"}),r.createElement(tt.A,{autoFocus:!0,"data-qa":"send-message-button-text",isRequired:!0,name:"message_button_label_input",id:"message_button_label_input","aria-labelledby":"message_button_label_label",value:e?.text.text,placeholder:e?.text.text||g,onChange:u,maxCharacterLimit:nG.c$,minCharacterLimit:nG.CL,errorText:f,autoComplete:"off",useInlineAlert:!0})),r.createElement(button_color_ButtonColor,{handleChange:b,buttonStyle:e?.style})),r.createElement(ButtonConfiguration,{handleChange:m,handleTypeChange:p,button:e,variables:t,formatVariableBeforeInsert:i,continueButtonExists:s,multipleContinueButtonsExist:o,isNestedStep:d}))};ButtonConfigurations.displayName="ButtonConfigurations";var ou=a(0x93d35cfe),om=a(0x19a0423f0),op=a.n(om);let ob=new c.Ay("workflow_builder"),ButtonsPreview=({variables:e,buttons:t})=>{let a=ob.t("This is a preview of how your button looks in a message!"),n=(0,r.useMemo)(()=>(0,nd.hH)(t,a),[t,a]),l=(0,e2.j)(),i=(0,r.useMemo)(()=>(0,e8.BQ)(l),[l]),o=(0,r.useMemo)(()=>(0,e8.DU)(l),[l]),s=(0,r.useMemo)(()=>(0,e8.DY)(l),[l]);return r.createElement("div",{className:op().previewContainer},r.createElement(nc.X,{noPointerEvents:!0,isInert:!0},r.createElement(ou.Y,{blocks:n,dataList:e.list,workflowName:i,workflowIcon:o,workflowId:s})))};ButtonsPreview.displayName="ButtonsPreview";var of=a(0x1ad596f5f),og=a(0x6b359530),oh=a(0x235d78b7c),o_=a(0x88881d67),oy=a(0xf33a4f91),ox=a(0x1ba35eb3b),ov=a(0x4b32db5f),oE=a(0x10d53599f),ok=a(0x213c0555e),ow=a(0x19dc73101),oS=a(0x4f725d55),oC=a(0xd2fa49d0),oA=a(0xdcfa8f6a),oT=a.n(oA),oI=a(0x2310bfb55),oN=a.n(oI);let oM=new c.Ay("workflow_builder"),AllowedEntitiesConfigurationInput=({value:e,onChange:t,variables:a,formatVariableBeforeInsert:n})=>{let l=(0,E.A)(),[i,s]=(0,r.useState)(!!e),c=(0,r.useCallback)(()=>{t(i?void 0:{member_ids:[]}),s(!i)},[i,t]),d=oM.t("Select users"),{onVariableMenuOpen:u}=(0,nt.e)(),m=(0,r.useMemo)(()=>(0,af.A)(e?.member_ids)?[{id:"member_ids_is_required",message:oM.t("This field is required.")}]:[],[e]),{onBlur:p,okayToDisplay:b}=(0,I.K)({errorMessage:void 0,isErrored:m.length>0}),f=(0,r.useMemo)(()=>"string"==typeof e?.member_ids?[e?.member_ids]:e?.member_ids,[e?.member_ids]),[g,h]=(0,r.useState)(f),_=(0,r.useCallback)(e=>(p(),t({member_ids:e})),[p,t]),x=(0,r.useCallback)(e=>{if((0,e0.cn)(e)){let t=(0,eX.x)(a.list,e);return!!t&&t.isAvailable&&!t.isTombstone&&t.type===e6.TE.Array}return!1},[a]),v=(0,r.useCallback)(e=>{let t=e.map(e=>e.value),a=t;return h(t),t.some(e=>x(e))&&(a=1===t.length?t[0]:t.filter(e=>!(0,e0.cn)(e)||!x(e))),_(a)},[_,x]),k=(0,r.useCallback)((e,t)=>{let n=`${t}-${e}`,r=!1,l="string"==typeof e?e:String(e);if("string"==typeof e&&(0,e0.cn)(e)){let t=(0,eX.x)(a.list,e);if(!t)return{key:n,label:oM.t("Missing Data"),isError:!1,svgIcon:{name:"css"},value:e};if(l=t.label||l,r=!t.isAvailable||t.isTombstone,t.type===e6.TE.Array){let e=!!g&&g.length>1;l=oM.t("{selectedDataLabel} (multiple)",{selectedDataLabel:t.label}),r=r||e}return{key:n,label:l,svgIcon:{name:"css"},value:t.id,isError:r}}return{key:n,label:l,value:e,isError:r}},[a.list,g]),w=(0,r.useMemo)(()=>"object"==typeof g?g?.map(k):"string"==typeof e?.member_ids?[k(e?.member_ids,0)]:e?.member_ids.map(k),[k,e?.member_ids,g]),S=(0,r.useCallback)(e=>"array"===e.type?!e.items||"slack#/types/mixed"===e.items.type||(0,ox.WL)(e.items)||(0,ox.kv)(e.items):(0,ox.WL)(e)||(0,ox.kv)(e),[]),C=(0,r.useMemo)(()=>(0,o_.PW)(a.groups,S),[S,a.groups]),A=(0,r.useMemo)(()=>(0,ov.T)(C),[C]),T=(0,r.useCallback)(a=>{let r=n?.(a,{}).id??"",l=Array.from(e?.member_ids||[]),i=[...l,r];return l=Array.from(g||[]),i=a.type===e6.TE.Array?r:i,h([...l,r]),t({member_ids:i})},[n,e?.member_ids,t,g]),N=(0,r.useCallback)(e=>"string"==typeof e.value&&(0,oS.A)(e.value)?r.createElement(oE.A,{id:e.value,showAvatar:!0}):"string"==typeof e.value&&(0,oC.A)(e.value)?r.createElement(ok.A,{id:e.value,showDescription:!1}):e.data&&e.data.label?r.createElement(og.R,{data:e.data}):e.label,[]),M=(0,r.useCallback)((e,t)=>{let a=[],n=(0,of.A)(A,t);return n.length>0&&a.push(...n),e.length>0&&a.push(...e),lP.S.resolve(a)},[A]),L=(0,r.useMemo)(()=>{let e=oy.R_;return{...{...e,entities:{...e.entities,userGroups:{includeFromAnotherTeam:!0}}},filter:()=>!0}},[]),O=(0,r.useMemo)(()=>r.createElement(ow.h,{id:l,onSelectedItemsChange:v,placeholderText:d,renderOption:N,searcherOptions:L,selectedOptions:w,selectId:l,width:"100%",className:o()(oT().entity),isInvalid:b&&m.length>0,processOptions:M,errors:b?m:void 0,allowVariables:!0,expandOnFocus:!0,onBlur:p,isRequired:!0}),[l,m,b,p,v,M,N,L,w,d]),F=oM.t("Restrict to specific users"),D=r.createElement("span",{"aria-hidden":!0},oM.t("Only certain users can click the button")),P=r.createElement("span",{className:"offscreen",id:"button_user_acl-description"},oM.t("Only certain users can click the button"));return r.createElement("div",{className:"margin_bottom_100"},r.createElement(y.A,{htmlFor:"button_user_acl_label",className:nk().switch_container,type:"inline",text:F,subtext:D},P,r.createElement(nx.A,{isToggled:i,onChange:c,ariaLabel:F,ariaDescribedBy:"button_user_acl-description"})),i&&r.createElement("div",{className:"display_flex","data-qa":"array-input"},r.createElement("div",{className:oN().inline_width},O),r.createElement(oh.jx,{onSelect:T,data:a.groups,customDataFilter:S,renderIconInline:!0,onMenuTriggerClick:u,className:oN().dynamicDataMenuButton})))};AllowedEntitiesConfigurationInput.displayName="AllowedEntitiesConfigurationInput";var oL=a(0x1b1820b2c),oO=a(0x380ee7b0);let oF="RELATIVE",oD="FIXED",oP=new c.Ay("workflow_builder"),ButtonExpiryTimestampInput=({value:e,onChange:t,variables:a,isButtonExpired:n,formatVariableBeforeInsert:l})=>{let i=(0,E.A)(),o=(0,E.A)(),{viewOnly:s,onVariableMenuOpen:c}=(0,nt.e)(),[d,u]=(0,r.useState)(!!e),m=(0,r.useMemo)(()=>e&&(0,eG.r2)(a.list,String(e.timestamp)),[e,a.list]),p=a.list.find(e=>"event_timestamp"===e.name),b=(0,r.useCallback)(()=>{!0===d?t(void 0):t({type:oF,timestamp:p?.id||(0,oa.Ay)().unix(),after_days:30}),u(!d)},[d,t,p]),f=(0,r.useCallback)(({target:a})=>{let{value:n}=a,r=p&&n===oF?p.id:(0,oa.Ay)().unix();e&&t({...e,timestamp:r,type:n,after_days:n===oF?e.after_days??30:void 0})},[e,t,p]),g=(0,r.useCallback)(a=>{let n=l?.(a,{isRichText:!1,skipMacro:!0}).id??a.id;if(e)return t({...e,timestamp:n})},[l,e,t]),h=(0,r.useCallback)(a=>{if(e)return t({...e,timestamp:parseInt(a,10)||(0,oa.Ay)().unix()})},[t,e]),_=(0,r.useCallback)(e=>(0,ox.p0)(e),[]),x=(0,r.useCallback)(a=>{if(e)return t({...e,after_days:e?.type===oF?Number(a):void 0})},[t,e]),renderDatetimeInput=()=>r.createElement(r.Fragment,null,m?r.createElement("div",{className:nk().variableContainer},r.createElement(oO.P,{onChange:h,value:String(e?.timestamp??""),variables:a,customDataFilter:_,label:"button-expiry-timestamp",isDisabled:s,formatVariableBeforeInsert:l,parameterType:e6.TE.SlackTypesTimestamp})):r.createElement("div",{className:nk().timestampWrapper},r.createElement(oL.A,{id:i,className:nk().timestampInlineDateTimePicker,onChange:h,valueFormat:"X",value:String(e?.timestamp??""),"aria-label":"button-expiry-timestamp",isRequired:!0,showTimeZone:!1,disabled:s,isInvalid:n}),r.createElement(oh.jx,{onSelect:g,data:a.groups,customDataFilter:_,renderIconInline:!0,isDisabled:s,onMenuTriggerClick:c}))),v=oP.t("Expires"),k=r.createElement("span",{"aria-hidden":!0},oP.t("Disable button on a certain date")),w=r.createElement("span",{className:"offscreen",id:"button_expires-description"},oP.t("Disable button on a certain date"));return r.createElement(r.Fragment,null,r.createElement(y.A,{htmlFor:"button_expires_label",className:nk().switch_container,type:"inline",text:v,subtext:k},w,r.createElement(nx.A,{isToggled:d,onChange:b,ariaLabel:v,ariaDescribedBy:"button_expires-description"})),d&&r.createElement(tJ.A,{className:"margin_bottom_100","data-qa":""},r.createElement(y.A,{className:"margin_top_25",text:oP.t("Days after a certain date"),type:"inline",cursor:"pointer"},r.createElement(t2.A,{checked:e?.type===oF,onChange:f,"data-qa":"button-expiry-relative",value:oF})),e?.type===oF&&r.createElement("div",{className:nk().relativeExpiryContainer},r.createElement("div",{className:nk().afterDaysContainer},r.createElement(tt.A,{id:o,min:1,max:365,name:"after_days",value:e?.after_days??1,onChange:x,type:"number",placeholder:"Days",className:nk().afterDays,suffix:e?.after_days===1?"day":"days"}),r.createElement("span",{className:"margin_left_50"},oP.t("after"))),renderDatetimeInput()),r.createElement(y.A,{text:oP.t("On a certain date"),type:"inline",cursor:"pointer"},r.createElement(t2.A,{checked:e?.type===oD,onChange:f,"data-qa":"button-expiry-fixed",value:oD})),e?.type===oD&&renderDatetimeInput()))};ButtonExpiryTimestampInput.displayName="ButtonExpiryTimestampInput";let InteractivityConfiguration=({interactivityConfig:e={is_button_multi_click:!1,expiry:void 0,allowed_entities:void 0},onChange:t,variables:a,formatVariableBeforeInsert:n,isButtonExpired:l})=>{let i=e?.allowed_entities,o=e?.expiry,s=(0,r.useCallback)(a=>t({...e,allowed_entities:a}),[t,e]),c=(0,r.useCallback)(a=>t({...e,expiry:a?{...e.expiry,...a}:void 0}),[t,e]);return r.createElement(r.Fragment,null,r.createElement(AllowedEntitiesConfigurationInput,{value:i,onChange:s,variables:a,formatVariableBeforeInsert:n}),r.createElement(ButtonExpiryTimestampInput,{value:o,onChange:c,variables:a,formatVariableBeforeInsert:n,isButtonExpired:l}))};InteractivityConfiguration.displayName="InteractivityConfiguration";let oR=new c.Ay("workflow_builder"),ButtonClickTypeConfiguration=({isMultiClick:e,isMutuallyExclusive:t,onChange:a})=>{let n=(0,r.useCallback)(()=>a({is_button_multi_click:!e}),[a,e]),l=oR.t("Single-click"),i=r.createElement("span",{"aria-hidden":!0},oR.t("Button can only be clicked once")),o=r.createElement("span",{className:"offscreen",id:"button_click_type-description"},oR.t("Button can only be clicked once"));return r.createElement("div",{className:"margin_top_50 margin_bottom_100"},r.createElement(y.A,{htmlFor:"button_click_type_label",className:nk().switch_container,type:"inline",text:oR.t("Single-click"),subtext:i},o,r.createElement(nx.A,{isToggled:!e,onChange:n,ariaLabel:l,isDisabled:t,ariaDescribedBy:"button_click_type-description"})))};ButtonClickTypeConfiguration.displayName="ButtonClickTypeConfiguration";let oB=new c.Ay("workflow_builder"),ButtonsAddEditModal=({buttonIndex:e=-1,operation:t,segment:a,switchPane:n,formatVariableBeforeInsert:l,onChange:i,afterStepId:o,isExistingSegment:s})=>{let[c,d]=(0,r.useState)(!1),u=(0,e4.EM)(a),m=((0,e5.RE)(a,nv.z.INTERACTIVE_BLOCKS)?.value??[]).find(e=>"actions"===e.type),b=(0,r.useMemo)(()=>m?.elements||[],[m?.elements]),f=(0,r.useMemo)(()=>(0,e5.RE)(a,nv.z.INTERACTIVITY_CONFIGURATION)?.value||{},[a]),g=(0,e2.j)(),_=(0,e8.W0)(s?a.id:o,g),y=b[e],v=f?.actions?.[y?.action_id],[E,k]=(0,r.useState)(y),[w,S]=(0,r.useState)(v),C=b.map((t,a)=>e===a?E:t),A=w?.is_button_multi_click??!1,T=w?.is_mutually_exclusive??!1,{speedBumpState:I,closeSpeedBump:N,openSpeedBump:M}=(0,tw.v)(),[L,O]=(0,r.useState)("edit"===t),F=(0,r.useCallback)(()=>{n&&n(tg.k.DEFAULT)},[n]),D=!(E&&"url"in E||E?.type==="workflow_button"),P=(0,r.useCallback)(()=>{if(!D){let e={actions:{...f.actions,[E?.action_id]:{is_button_multi_click:!0}}};i&&i(C,e)}O(!L)},[L,O,D,E,f,i,C]),R=(0,r.useCallback)(()=>{let e={actions:{...f.actions,[E?.action_id]:w}};i&&i(C,e)},[E,i,C,w,f]),B=(0,r.useCallback)(()=>{let t=b.filter((t,a)=>a!==e),a={actions:(0,nl.A)(f.actions,E?.action_id)};i&&i(t,a)},[f,E,i,b,e]),W=(0,r.useCallback)(e=>{k({...E,...e,text:{...E?.text,...e?.text}})},[E,k]),V=(0,r.useCallback)(e=>{let t={...E};switch(e){case"workflow_button":t.type=e,"value"in t&&delete t.value,"url"in t&&delete t.url;break;case"link":t.type="button",t.url="",delete t.workflow,"value"in t&&delete t.value;break;default:t.type=e,t.value="button","url"in t&&delete t.url}k(t);let a={...w,is_mutually_exclusive:T,is_button_multi_click:A};if((0,nd.O0)(t)&&!(0,nd.O0)(E)){let e=Object.values(f.actions||{}).some(e=>e.is_mutually_exclusive);a.is_mutually_exclusive=e,a.is_button_multi_click=!e&&A}S(a)},[E,k,f,A,T,w]),H=(0,r.useCallback)(e=>{S({...w,...e})},[w,S]),q=(0,r.useMemo)(()=>{let e=w?.expiry;if("number"!=typeof e?.timestamp)return!1;if(e?.type===oD)return e?.timestamp<(0,oa.Ay)().unix();let t=e?.after_days??1;return(e?.timestamp??0)+24*t*3600<(0,oa.Ay)().unix()},[w]),U=(0,r.useMemo)(()=>(0,nS.P6)(C),[C]),z=(0,r.useMemo)(()=>{let e=E?.text.text.length>nG.c$||E?.text.text.length{(0,rm.A)(y,E)&&(0,rm.A)(v,w)&&!z&&"add"!==t?F():M()},[y,E,v,w,M,F,t,z]),G=(0,r.useCallback)(()=>{(0,rm.A)(y,E)&&(0,rm.A)(v,w)||R(),F()},[y,E,v,w,R,F]),$=(0,r.useCallback)(()=>{let e="primary";switch(y&&y.style){case"primary":e="danger";break;case"danger":e=void 0}let t=(0,nS.OK)(!1,"",e),a=(0,nd.A6)(t.action_id,"callbackId",{actions:{...f.actions,[y.action_id]:w}},T);i?.([...C,t],a),t&&t?.action_id&&(k(t),S(a.actions[t?.action_id]),O(!1)),d(!0),n?.(tg.k.INTERACTIVE_BLOCKS_ADD_EDIT,{buttonIndex:b.length,formatVariableBeforeInsert:l,onChange:i}),setTimeout(()=>{d(!1)},300)},[y,w,C,f.actions,T,i,n,b.length,l]),K=(0,r.useCallback)(()=>{N()},[N]),Y=(0,r.useCallback)(()=>{"add"===t&&B(),F()},[B,t,F]),Q=(0,r.useMemo)(()=>r.createElement(x.A,{onClick:j,"aria-label":oB.t("Back")},r.createElement(p.Ah,{name:"caret-left-full",size:"20"})),[j]);(0,tk.M)("keyup",e=>{e.key===tC.D.ESCAPE&&j()});let Z=oB.t("Hide advanced options"),J=oB.t("Advanced options"),X=oB.t("Edit button"),ee=oB.t("Add button"),et="edit"===t?X:ee,ea=(0,nd.AI)(b),en=(0,nd.fd)(b);return r.createElement(r.Fragment,null,r.createElement(tS.rQ,null,r.createElement(tS.Rc,{title:et,icon:Q})),r.createElement(tS.$m,{className:"c-buttons-add-edit-modal__content"},c?r.createElement(loading_skeleton_LoadingSkeleton,null):r.createElement(r.Fragment,null,r.createElement(ButtonsPreview,{variables:u,buttons:C}),r.createElement(tS.qf,null,r.createElement(ButtonConfigurations,{button:E,variables:u,onChange:W,onTypeChange:V,onBehaviourChange:W,formatVariableBeforeInsert:l,multipleContinueButtonsExist:en,continueButtonExists:ea,hasDuplicateContinueLabel:U,isNestedStep:_}),D&&r.createElement(ButtonClickTypeConfiguration,{isMultiClick:A,isMutuallyExclusive:T,onChange:H})),D&&r.createElement(tS.qf,null,r.createElement(h.Nm,{"data-qa":"advanced-options",onClick:P,className:or().advancedOptions,id:"advanced-options-disclosure-control","aria-label":J,"aria-expanded":L},r.createElement("span",{className:or().advancedOptionsLabel},L?Z:J),r.createElement("hr",{"aria-hidden":!0,className:or().hr})),L&&r.createElement("div",{role:"group","aria-labelledby":"advanced-options-disclosure-control",hidden:!L},r.createElement(InteractivityConfiguration,{interactivityConfig:w,onChange:H,variables:u,isButtonExpired:q,formatVariableBeforeInsert:l}))))),I.isVisible?r.createElement(tS.ty,{heading:oB.t("Discard changes?"),description:oB.t("Your changes will not be saved."),cancelButtonLabel:oB.t("Keep Editing"),continueButtonLabel:oB.t("Close and Discard"),onCancel:K,onContinue:Y}):r.createElement(tS.jl,null,r.createElement(h.Ay,{type:"outline",onClick:$,disabled:z||b.length>=5},oB.t("Add Another Button")),r.createElement(tS.ox,null,r.createElement(h.Ay,{type:"primary",onClick:G,disabled:z},oB.t("Done")))))};ButtonsAddEditModal.displayName="ButtonsAddEditModal";var oW=a(0x1ee062b2e),oV=a(0x242503693),oH=a(0x16349a51f),oq=a(0x16ffed5ab),oU=a(0xf8631f1b),oz=a.n(oU);let oj=new c.Ay("workflow_builder"),MultiPaneSegmentFormModal=({onCancel:e,onSave:t,renderSaveError:a,segment:n,submitLabel:i,cancelLabel:c,afterStepId:f,isExistingSegment:g,isTrigger:h=!1,defaultPane:_=tg.k.DEFAULT,onNavigateBack:y})=>{let x=(0,nR.A)(),v=(0,l.wA)(),E=(0,e2.j)(),k=(0,e8.DY)(E),w=(0,M.d4)(N.Lh),{transitionFocusTo:A}=(0,r.useContext)(d.Ay),I=!!E&&(0,tM.I)(E.workflow.steps||[]).length>0,L=n?.type,O=(0,lp.E)(n),F=(0,t$.GS)(n),D=F?(0,e5.Dp)(n):void 0,P=F?(0,e5.P)(n):void 0,R=!!E&&(0,e8.a6)(E),B=(0,M.d4)(N.tQ),W=useTriggerDisplayContent()(n),V=(0,M.d4)(e=>P?.title??(0,th.Kb)(e,{type:n.type,subtype:O})??""),H=V;h&&!R&&(H=W.label||oj.t("Change how this workflow starts"));let q=(0,r.useMemo)(()=>I,[I]),U=useSegmentReducer(getSegmentReducer(n,{},D),n),[z,j]=U,G=(0,r.useRef)(z.segment),$=(0,r.useRef)(z);$.current=z;let K=(0,ty.q2)($.current.segment),Y=(0,ty.RK)($.current.segment);useSegmentFormInitializer({isOpenForm:K,segment:$.current.segment});let Q=(0,tw.v)(),{closeSpeedBump:Z,openSpeedBump:J}=Q,[X,ee]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(null),en=((e,t,a,n)=>{if(n)return!!a&&a.trigger?.type!==t.type||!(0,rm.A)({...t.config,url:void 0},{...e.config,url:void 0});let r=excludeFieldsForComparison(e),l=(e=>{let{type:t,id:a,derived:n,config:r,coachmarkText:l,...i}=e;return{type:t,id:a,config:r,..."coachmarkText"in e&&{coachmarkText:l},..."derived"in e&&{derived:n},..."stepType"in i&&{stepType:i.stepType},..."subtype"in i&&{subtype:i.subtype}}})(excludeFieldsForComparison((e=>{if(!(0,t$.GS)(e))return e;let t={...e.config.inputs};return e.config.slackFunction?.input_parameters.forEach(e=>{var a;(e.type===e6.TE.SlackTypesRichText||e.type===e6.TE.SlackTypesExpandedRichText||e.type===e6.TE.SlackTypesBlocks)&&t[e.name]&&(t[e.name]={...t[e.name],value:Array.isArray(a=t[e.name].value)&&0===a.length?null:a})}),{...e,config:{...e.config,inputs:t}}})(t)));return!(0,rm.A)(r,l)})(G.current,$.current.segment,E,h),er=((e,t)=>{if((0,rY.Z)(t)&&(0,rY.Z)(e)){let a=(0,rK.ln)(e)?.find(({type:e})=>e===e6.TE.SlackTypesCredentialOauth2);if(!a)return!1;let n=(0,rK.RE)(e,a.name)?.value,r=(0,rK.RE)(t,a.name)?.value;return n?.external_token_id!==r?.external_token_id}if((0,t$.GS)(t)&&(0,t$.GS)(e)){let a=(0,e5.ln)(e)?.find(({type:e})=>e===e6.TE.SlackTypesCredentialOauth2);if(!a)return!1;let n=(0,e5.RE)(e,a.name)?.value,r=(0,e5.RE)(t,a.name)?.value;return n?.external_token_id!==r?.external_token_id}return!1})(G.current,$.current.segment),el=(0,r.useMemo)(()=>{let e=g?aE.KC.EditStep:aE.KC.AddStep,t=h&&n.config&&"event"in n.config?n.config.event?.eventType:void 0;return{elementName:h?aE.KC.EditTrigger:e,workflowBuilderStepType:h?L:D,workflowBuilderTriggerSubtype:t?(0,oW.y)(t):void 0,workflowBuilderWorkflowId:k}},[g,h,L,D,n.config,k]),ei=(0,r.useCallback)(()=>{(0,lE.tv)({workflowId:k||"",segmentId:h?lo.m.TRIGGER:n.id,level:u.A_.success})},[h,n.id,k]),eo=(0,r.useCallback)(()=>{let e;if(h||(e=oj.rt('"{segmentTitle}" step added',{segmentTitle:V})),g&&(e=h?oj.t("Workflow start has been updated"):oj.rt('"{segmentTitle}" step updated',{segmentTitle:V})),e)return v((0,oq.M)({element:r.createElement(b.A,null,e)}))},[v,g,h,V]),es=(0,r.useCallback)(()=>{ea(null),ee(!0);let e=(0,t$.GS)($.current.segment)&&(0,e5.mV)($.current.segment)&&!(0,ty.q2)($.current.segment)&&(0,t$.GS)($.current.segment)?(0,ty.$c)($.current.segment):$.current.segment;t(e).then(()=>v((0,lT.O)())).then(ei).then(()=>ee(!1)).then(()=>eo()).then(()=>{h||A({focusKey:oV.Ay.PAGE_CONTENT_WORKFLOW_EDITOR_STEP_PREVIEW,focusMetadata:{id:e.id}})}).catch(e=>{ea({...e,name:e.name}),ee(!1),Z()})},[t,ei,v,eo,A,h,Z]),ec=(0,r.useCallback)(()=>{let t=h&&n.config&&"event"in n.config?n.config.event?.eventType:void 0;(0,aE.ft)({clogger:x,wbArgs:{workflow_id:k,is_hermes:!0,...h&&t&&{trigger_subtype:(0,oW.y)(t)}}}),e&&e(),v((0,lT.O)()),v((0,oH.dV)(G.current.id)),v((0,r2.br)({workflowId:k||""}))},[x,k,e,v,h,n.config]),ed=(0,r.useCallback)(()=>{en?J({heading:oj.t("Discard changes?"),message:oj.rt("Your work will not be saved."),onCancel:Z,onContinue:()=>{if(ec(),!g){let e=h?ls.hf:f||ls.kr;A({focusKey:oV.Ay.PAGE_CONTENT_WORKFLOW_EDITOR_STEP_PREVIEW,focusMetadata:{id:e}})}}}):ec()},[en,ec,J,Z,h,g,A,f]),eu=n?.type===rs.SJ,em=P?.app_id,ep=(0,r.useMemo)(()=>{if(W.icon)return W.icon;if(em)return r.createElement("span",{className:oz().title_icon},r.createElement(T.z,{appId:em}));let e=P?.callback_id??"";(0,nu.Ag)(n)&&(e=li.ad);let t=(0,S.m)(e);return e?r.createElement("span",{className:oz().title_icon},r.createElement(p.Ah,{"data-qa":"svg-icon",name:t,size:"20"})):null},[W.icon,em,P?.callback_id,n]),eb=(0,r.useCallback)(({activePane:e,switchPane:t})=>r.createElement(SegmentFormModal,{title:H,icon:ep,onSave:es,onClose:ed,saving:X,saveError:et,renderSaveError:a,segment:n,submitLabel:i,cancelLabel:c,afterStepId:f,currentSegmentState:$.current.segment,segmentReducer:U,speedBumpContext:Q,isTrigger:h,isExistingSegment:g,isAuthTokenModified:er,isSegmentModified:en,baseAutoClogProps:el,switchPane:t,activePane:e,onNavigateBack:y}),[H,ep,es,ed,X,et,a,n,i,c,f,U,Q,h,g,er,en,el,y]),ef=(0,r.useMemo)(()=>({[tg.k.DEFAULT]:{render:({switchPane:e})=>eb({switchPane:e,activePane:tg.k.DEFAULT}),modalProps:{contentLabel:V}},[tg.k.THIRD_PARTY_USER_FORM_CONFIG]:{render:({switchPane:e})=>eb({switchPane:e,activePane:tg.k.THIRD_PARTY_USER_FORM_CONFIG}),modalProps:{contentLabel:V}},[tg.k.FORM_WRAPPED_SELECTION]:{render:({switchPane:e})=>r.createElement(FormWrappedSelectionModal,{title:H,icon:ep,onClose:ed,switchPane:e,appId:em,segment:n,activePane:tg.k.FORM_WRAPPED_SELECTION}),modalProps:{contentLabel:V}},[tg.k.PARENT_INPUTS]:{render:({switchPane:e})=>eb({switchPane:e,activePane:tg.k.PARENT_INPUTS}),modalProps:{contentLabel:V}},[tg.k.CHILD_INPUTS]:{render:({switchPane:e})=>eb({switchPane:e,activePane:tg.k.CHILD_INPUTS}),modalProps:{contentLabel:V}},[tg.k.FORM_WRAPPED_INPUTS]:{render:({switchPane:e})=>r.createElement(FormWrappedInputsModal,{title:H,icon:ep,onSave:es,onClose:ed,saving:X,saveError:et,renderSaveError:a,segment:$.current.segment,submitLabel:i,cancelLabel:c,segmentReducer:U,speedBumpContext:Q,isExistingSegment:g,isSegmentModified:en,baseAutoClogProps:el,switchPane:e}),modalProps:{contentLabel:V}},[tg.k.OPEN_FORM_QUESTION_EDIT]:{render:({switchPane:e,questionIndex:t})=>K&&(0,t$.GS)($.current.segment)?r.createElement(QuestionEditModal,{questionIndex:t,switchPane:e,segment:$.current.segment}):null,modalProps:{contentLabel:V,showCloseButton:!1,shouldCloseOnOverlayClick:!1,closeModal:()=>{}}},[tg.k.INTERACTIVE_BLOCKS_ADD_EDIT]:{render:({switchPane:e,buttonIndex:t,operation:a,formatVariableBeforeInsert:n,onChange:l})=>Y&&(0,t$.GS)($.current.segment)?r.createElement(ButtonsAddEditModal,{buttonIndex:t,switchPane:e,operation:a??"add",segment:$.current.segment,formatVariableBeforeInsert:n,onChange:l,afterStepId:f,isExistingSegment:g}):null,modalProps:{contentLabel:V,showCloseButton:!1,shouldCloseOnOverlayClick:!1,closeModal:()=>{}}},[tg.k.FORM_LOADING_SCREEN]:{render:({switchPane:e,heading:t,redirectPane:a})=>r.createElement(FormLoadingScreen,{switchPane:e,heading:t,redirectPane:a??tg.k.DEFAULT}),modalProps:{contentLabel:V,showCloseButton:!1,shouldCloseOnOverlayClick:!1,closeModal:()=>{}}},[tg.k.AI_STEP_DEFAULT]:{render:({switchPane:e})=>(0,t$.GS)($.current.segment)?r.createElement(AiStepDefaultModal,{title:V,icon:ep,switchPane:e,onClose:ed,onSave:es,segment:$.current.segment,workflow:E,speedBumpContext:Q,saving:X,saveError:et,renderSaveError:a,isExistingSegment:g,isSegmentModified:en,onNavigateBack:y}):null,modalProps:{contentLabel:V,showCloseButton:!0,shouldCloseOnOverlayClick:!0,fullscreen:!0,maxWidth:1024}}}),[V,eb,H,ep,ed,em,n,es,X,et,a,i,c,U,Q,g,en,el,K,Y,f,E,y]),eg=(0,r.useMemo)(()=>r.createElement(m.A,{panes:ef,defaultPane:_,onClose:ed,forceSpeedBumpEnabled:!0,shouldCloseOnOverlayClick:!X,maxWidth:eu?1200:void 0,className:"c-segment_modal--hermes_workflow",dataQa:h?"trigger-modal":"step-modal",centered:!B,overlayClassName:o()({[oz().modal_overlay]:B})}),[_,B,eu,h,X,ed,ef]);return r.createElement(s.A,{eventId:tK.EventId.WORKFLOW_BUILDER,uiStep:tK.UiStep.WORKFLOW_EDITOR,...el},r.createElement(C.us.Provider,{value:Q},r.createElement(ValidationProvider,{computed:z.computed},r.createElement(C.ZH.Provider,{value:j},w&&r.createElement(e2.X.Provider,{value:E},r.createElement(tj.U.Provider,{value:q},eg)),!w&&eg))))};MultiPaneSegmentFormModal.displayName="MultiPaneSegmentFormModal"},0x426feba4:(e,t,a)=>{"use strict";a.d(t,{l:()=>UpdateTriggerErrorMessage,y:()=>SaveNewWorkflowErrorMessage});var n=a(0xbad225b5);let r=new(a(0x20482ad21)).Ay("workflow_builder"),SaveNewWorkflowErrorMessage=({error:e})=>{let t="default";return(e||{}).name,t=r.t("Sorry, there was a problem trying to save your workflow."),n.createElement("span",null,t)};SaveNewWorkflowErrorMessage.displayName="SaveNewWorkflowErrorMessage";let UpdateTriggerErrorMessage=({error:e})=>{let t="";return t="insufficient_posting_permissions"===(e||{}).name?r.t("You don\u2019t have posting permissions for one or more channels in this trigger.",{fallbackHash:"c2fdb696683556283da97a9f3184ad82dcf1f622",fallbackHashNs:"workflow_builder"}):r.t("Sorry, there was a problem trying to update your trigger."),n.createElement("span",null,t)};UpdateTriggerErrorMessage.displayName="UpdateTriggerErrorMessage"},0x22c41b907:(e,t,a)=>{"use strict";a.d(t,{k:()=>n});let n={DEFAULT:"default",PARENT_INPUTS:"parent-inputs",CHILD_INPUTS:"child-inputs",OPEN_FORM_QUESTION_EDIT:"open-form-question-edit",FORM_WRAPPED_INPUTS:"form-wrapped-inputs",INTERACTIVE_BLOCKS_ADD_EDIT:"interactive-blocks-add-edit",FORM_WRAPPED_SELECTION:"form-wrapped-selection",THIRD_PARTY_USER_FORM_CONFIG:"third-party-user-form-config",FORM_LOADING_SCREEN:"form-loading-screen",AI_STEP_DEFAULT:"ai-step-default"}},0x161478d06:(e,t,a)=>{"use strict";a.d(t,{$:()=>SegmentFormWrapper});var n=a(0xbad225b5),r=a(0x120c268ad),l=a.n(r),i=a(0x1407c6c2c),o=a(0x20482ad21),s=a(0x1d2cd7755),c=a(0x10598eeca),d=a(0x88dc61ea),u=a(0x106f35107),m=a(0x63978f20),p=a.n(m);let b=new o.Ay("workflow_builder"),f={display:"none"};(function CoachmarkEditField({coachmarkText:e,onUpdateCoachmarkText:t}){let a=(0,i.A)();return n.createElement(s.A,{htmlFor:a,text:"Edit Coachmark"},n.createElement(c.A,{id:a,value:e,onChange:t}))}).displayName="CoachmarkEditField";let SegmentFormWrapper=({children:e,noSubmit:t=!1,noPadding:a=!1,className:r,segment:i})=>{let o=(0,d.Hj)(),s=(0,d.rC)(),c=(i?.coachmarkText,(0,n.useCallback)(e=>{s((0,u.RJ)({coachmarkData:e}))},[s]),n.createElement(n.Fragment,null,e,!1));return n.createElement("div",{"data-qa":"segment-form-wrapper",className:l()({[p().withPadding]:!a},r)},t?c:n.createElement("form",{onSubmit:o},c,n.createElement("button",{style:f,type:"submit"},b.t("Submit"))))};SegmentFormWrapper.displayName="SegmentFormWrapper"},0x6713bca9:(e,t,a)=>{"use strict";a.d(t,{J:()=>SegmentIcon});var n=a(0xbad225b5),r=a(0x120c268ad),l=a.n(r),i=a(0x344bb842),o=a(0x2501a2cee),s=a(0x4c96e5d9),c=a(0x12cef2078),d=a(0x1f495452e),u=a.n(d);let SegmentIcon=({icon:e,isFocusedOrHovering:t})=>{if(e&&"object"==typeof e&&"onClick"in e&&void 0!==e?.onClick){let{label:a,onClick:r,svgIconProps:o,svgIconPropsOnHover:d}=e,m=l()(u().outline_container,u().with_background,{[u().show_outline]:t}),p=d&&t?d:o,b={"aria-controls":e["aria-controls"],"aria-expanded":e["aria-expanded"]};return n.createElement(c.X,{preventDefault:!0,stopPropagation:!1},n.createElement("div",{className:m},n.createElement(s.Ay,{tip:a,delay:s.PK},n.createElement(i.A,{svgIconProps:p,"aria-label":a,onClick:r,className:u().icon_button,ref:"ref"in e?e.ref:void 0,...b}))))}return(0,n.isValidElement)(e)?e:n.createElement("div",{className:u().container,"data-qa":"segment-icon"},n.createElement(o.Ah,{name:e,size:"20"}))};SegmentIcon.displayName="SegmentIcon"},0x240c7a514:(e,t,a)=>{"use strict";a.d(t,{H8:()=>getStepMenuButtons,Xw:()=>getTriggerMenuButtons,iT:()=>buildStepButtons,jh:()=>hasPermissionsForSegment,rz:()=>getSegmentPreviewIcon,so:()=>getNextStepActionSubtitle});var n=a(0xbad225b5),r=a(0xbe0b63ff),l=a(0x20482ad21),i=a(0x210b99e76),o=a(0x1bffa495d),s=a(0x1c27a9e4a),c=a(0xaaa6bbd0),d=a(0x171a52b74),u=a(0x20d4168fd),m=a(0x154dd8295),p=a(0x24e22e0a6),b=a(0x23a4b0853),f=a(0x1d3efd4ea),g=a(0x1d9a37519),h=a(0x184767f39),_=a(0x1e9a6d1d),y=a(0x148f558fa),x=a.n(y);let{INIT_APP_REQUEST_FLOW:v,INSTALL_SHOW_STEP_FUNCTION:E,SHOW_STEP_FUNCTION:k,APP_DENIED:w,APP_REQUEST_IS_PENDING:S}=h.pY,C=new l.Ay("workflow_builder"),buildStepButtons=({methods:{onEdit:e,onAboutClick:t,onDelete:a,onMoveUp:r,onMoveDown:l,onAddBranch:i,onDuplicate:o},viewOnly:s,segment:c,branchNameFallback:p,hasMaxNumberOfSteps:f,maxNumberOfSteps:g})=>{let h="";(0,d.GS)(c)&&(h=c?.config?.slackFunction?.title??"");let _=C.t("Move {stepTitle} step up",{stepTitle:h}),y=C.t("Move {stepTitle} step down",{stepTitle:h}),x=C.t("Edit {stepTitle} step",{stepTitle:h}),v=C.t("View {stepTitle} step",{stepTitle:h}),E=C.t("Delete {stepTitle} step",{stepTitle:h}),k=C.t("Duplicate {stepTitle} step",{stepTitle:h}),w=C.t("Add a branch");if((0,m.Ag)(c)){let e=(0,u.At)(c);h=e?e?C.t("{branchName} branch",{branchName:e}):"":p??"",_=C.t("Move {stepTitle} up",{stepTitle:h,fallbackHash:"b4f57cd0cd5c7d88461c1718646713dea47a36c9"}),y=C.t("Move {stepTitle} down",{stepTitle:h,fallbackHash:"260ff8ae7182fc851337b6b2fdb25f8cac2b8d47"}),x=C.t("Edit {stepTitle}",{stepTitle:h,fallbackHash:"2c79c2f8fe6cef139b77391f6699a0512a187188"}),v=C.t("View {stepTitle}",{stepTitle:h,fallbackHash:"dcad67b0405f9754a0d00a9f9fc2cb144f73c98a"}),E=C.t("Delete {stepTitle}",{stepTitle:h,fallbackHash:"0294209f799931433e4e7346620d4304addd4900"}),k=C.t("Duplicate {stepTitle}",{stepTitle:h,fallbackHash:"c37523340d01438b5ca803203fa36081df3a6629"})}return Object.fromEntries(Object.entries({moveUp:{tooltip:n.createElement("span",{"aria-hidden":!0},C.t("Move up")),onClick:r,ariaLabel:_,autoClogProps:{elementName:b.KC.MoveStepUp,onClick:{enableClogAction:!0}}},moveDown:{tooltip:n.createElement("span",{"aria-hidden":!0},C.t("Move down")),onClick:l,ariaLabel:y,autoClogProps:{elementName:b.KC.MoveStepDown,onClick:{enableClogAction:!0}}},edit:{tooltip:n.createElement("span",{"aria-hidden":!0},s?C.t("View"):C.t("Edit")),onClick:e,ariaLabel:s?v:x,autoClogProps:{elementName:b.KC.EditStep,onClick:{enableClogAction:!0}}},about:{tooltip:n.createElement("span",{"aria-hidden":!0},C.t("About this step")),onClick:t,ariaLabel:C.t("About this step")},remove:{tooltip:n.createElement("span",{"aria-hidden":!0},C.t("Delete")),onClick:a,ariaLabel:E,autoClogProps:{elementName:b.KC.DeleteStep,onClick:{enableClogAction:!0}}},addBranch:{tooltip:w,onClick:i,ariaLabel:w,autoClogProps:{elementName:b.KC.AddBranch,onClick:{enableClogAction:!0}}},duplicate:{tooltip:f?C.t("Workflow has reached {max_number_of_steps}-step limit",{max_number_of_steps:g,fallbackHash:"732ddc07733ebd62fa52955da986308c3c54ea06"}):C.t("Duplicate"),onClick:o,isDisabled:f,ariaLabel:k,autoClogProps:{elementName:b.KC.DuplicateStep,onClick:{enableClogAction:!0}}}}).filter(([,{onClick:e}])=>!!e))};buildStepButtons.displayName="buildStepButtons";let getTriggerMenuButtons=({edit:e,copy:t},a)=>[...a?[{key:"segment_copy_link_btn",tooltip:t.tooltip,onClick:t.onClick,ariaLabel:t.ariaLabel,dataQa:"segment_copy_link_btn",dataId:"segment_copy_link_btn",svgIconProps:{name:"link",size:"20"}}]:[],{key:"segment_edit_btn",tooltip:e.tooltip,onClick:e.onClick,ariaLabel:e.ariaLabel,dataQa:"segment_edit_btn",dataId:"segment_edit_btn",svgIconProps:{name:"edit",size:"20"}}],getStepMenuButtons=({moveUp:e,moveDown:t,edit:a,remove:n,addBranch:r,duplicate:l},{viewOnly:i,firstStep:o,lastStep:s,isDragDisabled:c,isUnknownStep:d,isSwitch:u})=>[...!e||!t||i||d||u?[]:[...o?[]:[{key:"segment_move_up_btn",tooltip:e.tooltip,onClick:e.onClick,ariaLabel:e.ariaLabel,isDisabled:c,dataQa:"segment_move_up_btn",dataId:"segment_move_up_btn",svgIconProps:{name:"arrow-up",size:"20"},autoClogProps:e.autoClogProps}],...s?[]:[{key:"segment_move_down_btn",tooltip:t.tooltip,onClick:t.onClick,ariaLabel:t.ariaLabel,isDisabled:c,dataQa:"segment_move_down_btn",dataId:"segment_move_down_btn",svgIconProps:{name:"arrow-down",size:"20"},autoClogProps:t.autoClogProps}]],...n&&(!i||u)?[{key:`${d?"unknown_":""}segment${u?"_switch":""}_delete_btn`,tooltip:n.tooltip,onClick:n.onClick,ariaLabel:n.ariaLabel,dataQa:`${d?"unknown_":""}segment${u?"_switch":""}_delete_btn`,dataId:`${d?"unknown_":""}segment${u?"_switch":""}_delete_btn`,svgIconProps:{name:"trash",size:"20"},autoClogProps:n.autoClogProps}]:[],...!l||i||d||u?[]:[{key:"segment_duplicate_btn",tooltip:l.tooltip,onClick:l.onClick,ariaLabel:l.ariaLabel,isDisabled:l.isDisabled,dataQa:"segment_duplicate_btn",dataId:"segment_duplicate_btn",svgIconProps:{name:"copy",size:"20"},autoClogProps:l.autoClogProps}],...!a||d||u?[]:[{key:"segment_edit_btn",tooltip:a.tooltip,onClick:a.onClick,ariaLabel:a.ariaLabel,dataQa:"segment_edit_btn",dataId:"segment_edit_btn",svgIconProps:{name:"edit",size:"20"},autoClogProps:a.autoClogProps}],...r&&u?[{key:"segment_addBranch_btn",tooltip:r.tooltip,onClick:r.onClick,ariaLabel:r.ariaLabel,dataQa:"segment_addBranch_btn",dataId:"segment_addBranch_btn",svgIconProps:{name:"add-branch",size:"20"},autoClogProps:r.autoClogProps}]:[]],hasPermissionsForSegment=e=>null===e||e===k||e===E,getNextStepActionSubtitle=e=>{switch(e){case v:return n.createElement("span",{className:x().stepInitRequest},C.t("Request this step"));case S:return n.createElement("span",null,C.t("Approval requested"));case w:return n.createElement("span",{className:x().stepRestricted},C.t("This step is restricted"));default:return}};getNextStepActionSubtitle.displayName="getNextStepActionSubtitle";let getSegmentPreviewIcon=({segment:e,wrappedFunctionDetails:t})=>{if((0,d.GS)(e)){let a=(0,c.Pv)(e)?t??e.config.wrappedSlackFunction:e.config.slackFunction;if((0,r.GU)(a))return n.createElement(f.A,{size:36});if(a?.type===_.A.BuiltIn)return(0,i.m)(a?.callback_id);if(a?.app_id)return n.createElement(g.z,{appId:a.app_id,size:24})}else if((0,p.Z)(e)){let t=e.config.service.function;if(t?.app_id)return n.createElement(g.z,{appId:t.app_id,size:24})}let a=(0,s.E)(e);return(0,o.pA)({type:e.type,subtype:a})};getSegmentPreviewIcon.displayName="getSegmentPreviewIcon"},0x8d9b2838:(e,t,a)=>{"use strict";a.d(t,{v:()=>useEditTemplateModal});var n=a(0xbad225b5),r=a(0x16cf1da63),l=a(0x20482ad21),i=a(0x24546e7f2),o=a(0x15ab42d61),s=a(0xdac250),c=a(0x3c838d6a),d=a(0xd013226d),u=a(0x5b0d97fd),m=a(0xa263fbfd),p=a(0x1a5ac3a0c),b=a(0x145d46a61),f=a(0x235bbf477),g=a(0x226892387),h=a(0x1fcbb004d),_=a(0x16ffed5ab);let y=new l.Ay("workflow_builder"),TemplateEditModal=()=>{let e=(0,m.X)(),t=(0,g.d4)(b.dm),a=(0,g.d4)(b.kY),l=(0,r.wA)(),f=(0,n.useCallback)(()=>l((0,h.O)()),[l]),[_,x]=(0,n.useState)(""),[v,E]=(0,n.useState)(""),[k,w]=(0,n.useState)(""),[S,C]=(0,n.useState)(!1),[A,T]=(0,n.useState)(""),I=(0,n.useMemo)(()=>({[u.C7.Details]:{render:({switchPane:e})=>n.createElement(d.R,{templateName:_,setTemplateName:x,description:v,setDescription:E,iconUrl:k,switchPane:e,madLib:A,setMadLib:T,modalType:"edit"}),modalProps:{contentLabel:y.t("Finish Up Template")}},[u.C7.BasicDetails]:{render:({switchPane:e})=>n.createElement(c.R,{templateName:_,setTemplateName:x,description:v,setDescription:E,iconUrl:k,switchPane:e,modalType:"edit"}),modalProps:{contentLabel:y.t("Edit details")}},[u.C7.UploadImg]:{render:({switchPane:e,file:t})=>n.createElement(s.Z,{onClose:f,nextPane:u.C7.CropImg,prevPane:a?u.C7.BasicDetails:u.C7.Details,setOnCropImagePane:C,switchPane:e,file:t}),modalProps:{contentLabel:y.t("Edit Avatar Upload")}},[u.C7.CropImg]:{render:({switchPane:e,imageId:t,avatarUrl:r})=>n.createElement(o._,{workflowName:_,workflowDescription:v,onClose:f,nextPane:a?u.C7.BasicDetails:u.C7.Details,prevPane:a?u.C7.BasicDetails:u.C7.Details,showPreview:!1,setOnCropImagePane:C,setIconUrl:w,avatarUrl:r||"",imageId:t||"",switchPane:e}),modalProps:{contentLabel:y.t("Edit Avatar Upload")}},[u.C7.Confirmation]:{render:()=>n.createElement(TemplateEditConfirmation,{onClose:f}),modalProps:{contentLabel:y.t("Template Edit Confirmation")}}}),[_,v,k,A,f,a]);return((0,n.useEffect)(()=>{e&&(x(e.workflow.title),E(e.workflow.description),T(e.madLibSentence||""),e.workflow.icons?.image_192&&w((0,p.DU)(e.workflow)))},[e]),t&&e)?n.createElement(i.A,{closeModal:f,defaultPane:a?u.C7.BasicDetails:u.C7.Details,panes:I,dataQa:"template-edit-modal",showCloseButton:!S}):null};function TemplateEditConfirmation({onClose:e}){let t=(0,r.wA)(),a=y.t("Template Updated");return(0,n.useEffect)(()=>{t((0,_.M)({element:n.createElement(f.V,{message:a})})),e()},[t,e,a]),null}TemplateEditModal.displayName="TemplateEditModal",TemplateEditConfirmation.displayName="TemplateEditConfirmation";var x=a(0x46dbff89);function useEditTemplateModal(){let e=(0,r.wA)(),t=(0,m.X)();return{openEditModal:(0,n.useCallback)(()=>{let a=n.createElement(m.Z.Provider,{value:t},n.createElement(TemplateEditModal,null));e((0,x.q)({isStackable:!0,element:a}))},[e,t])}}useEditTemplateModal.displayName="useEditTemplateModal"},0x2d26ca33:(e,t,a)=>{"use strict";a.d(t,{K:()=>useTemplateFetch});var n=a(0xbad225b5),r=a(0x16cf1da63),l=a(0xe874a88a),i=a(0x1a5ac3a0c),o=a(0x14b92995e),s=a(0xf5bbd10a),c=a(0x145d46a61),d=a(0x16e94c2bd),u=a(0x24fc5dd2c),m=a(0x226892387);function useTemplateFetch(e){let t=(0,m.d4)(c.dm),a=(0,r.wA)(),p=(0,s.A)(),[b,f]=(0,n.useState)(),[g,h]=(0,n.useState)(!1),[_,y]=(0,n.useState)(!0),[x,v]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{t&&_&&(async()=>{if(!e)return l.S.reject(Error("No templateId"));try{return v(!1),h(!0),await a((0,o.l)({templateId:e,reason:"load-template-get-as-decorated-workflow"}))}catch(t){return p.error(`Something went wrong when trying to fetch a workflow with templateId: ${e}`,t),l.S.reject(t)}finally{h(!1)}})().then(e=>{let t=(0,d.l_)(e.workflow),a={...e.trigger,type:(0,u.k)(e.trigger.type)},n=(0,i.Ln)(t);f({...e,workflow:t,trigger:a,segments:n})}).catch(()=>{v(!0)}).finally(()=>{y(!1)})},[a,_,p,e,t]),b&&b.workflow&&b.trigger&&b.segments)?{templateId:e||"",failedToFetch:x,dateUpdated:b?.date_updated,workflow:b?.workflow,trigger:b?.trigger,availableData:b?.available_data,expressionData:b?.expression_data??{},segments:b?.segments,isFetchingTemplate:g,categories:b?.categories||[],madLibSentence:b?.madlibs_config?.sentence,templateState:b?.state,collaboratorIds:b?.collaborator_ids||[],refetchTemplate:()=>y(!0)}:null}},0x18bdc312b:(e,t,a)=>{"use strict";a.d(t,{f:()=>useValidateTemplateName});var n=a(0xbad225b5),r=a(0x16cf1da63),l=a(0xe874a88a),i=a(0x22a29f141),o=a(0x1dfdeb1c8),s=a(0x1ec68d6a3),c=a(0xe747dd27);let d=(0,o.A)("workflows.templates.validate generated fetcher",(e,t,a)=>new l.S((n,r)=>{let{abortSignal:l,reason:o,...d}=a,u=(0,c.VA)(d);e((0,i.apiCall)({method:"workflows.templates.validate",args:u,abortSignal:l,reason:o})).then(e=>{n(e)}).catch(e=>{(0,s.default)({getState:t}).error(`API call to workflows.templates.validate with reason ${o} failed, initiated by generated fetcher`),r(e)})}));function useValidateTemplateName(){let e=(0,r.wA)();return{isTemplateNameValid:(0,n.useCallback)(async t=>{try{return await e(d({name:t,reason:"validate-template-name"})),!0}catch{return!1}},[e])}}d.meta={name:"workflowsTemplatesValidateFetcher",key:"createFetcherWorkflowsTemplatesValidateFetcher",description:"workflows.templates.validate generated fetcher"}},0xcbde109e:(e,t,a)=>{"use strict";a.d(t,{i:()=>MadLibsModal});var n=a(0xbad225b5),r=a(0x16cf1da63),l=a(0x20482ad21),i=a(0x11a296110),o=a(0x1d2cd7755),s=a(0x126f22530),c=a(0x145d46a61),d=a(0x20e80190e),u=a(0x226892387),m=a(0x1fcbb004d);let p=new l.Ay("workflow_builder");function MadLibsModal({templateTitle:e,onGenerate:t}){let a=(0,u.d4)(c.dm),l=(0,r.wA)(),[b,f]=(0,n.useState)(e),g=(0,n.useCallback)(()=>l((0,m.O)()),[l]),h=(0,n.useCallback)(()=>{t(b),g()},[t,g,b]);return a?n.createElement(d.dW,{contentLabel:p.t("Generate Madlibs"),closeModal:g},n.createElement(d.rQ,null,n.createElement(d.Rc,{title:p.t("Generate Madlibs")})),n.createElement(d.$m,null,n.createElement(d.qf,null,n.createElement(o.A,{text:p.rt("Goal: Briefly explain what this workflow achieves")},n.createElement(s.A,{id:"madlibs-goal",type:"text",name:"name",value:b,onChange:f,placeholder:"",autoComplete:"off",focusOnMount:!0,useInlineAlert:!0})))),n.createElement(d.jl,null,n.createElement(d.ox,null,n.createElement(i.Ay,{type:"outline",onClick:g},p.t("Cancel")),n.createElement(i.lV,{onClick:h,"aria-label":p.t("Generate")},p.t("Generate"))))):null}MadLibsModal.displayName="MadLibsModal"},0x3c838d6a:(e,t,a)=>{"use strict";a.d(t,{R:()=>TemplateBasicDetailsPane});var n=a(0xbad225b5),r=a(0x16cf1da63),l=a(0x120c268ad),i=a.n(l),o=a(0x2286acf6c),s=a(0x20482ad21),c=a(0x11a296110),d=a(0x1d2cd7755),u=a(0x126f22530),m=a(0x5299a396),p=a(0x1e586fbba),b=a(0x1b7f0cd57),f=a(0xa3743afa),g=a(0x18bdc312b),h=a(0x23515fd5),_=a(0x5b0d97fd),y=a(0xa263fbfd),x=a(0x937a43ca),v=a(0x145d46a61),E=a(0x20e80190e),k=a(0x1dae1e14d),w=a(0xf3c231c),S=a(0x226892387),C=a(0x1fcbb004d),A=a(0x254059bfb),T=a.n(A);let I=new s.Ay("workflow_builder");function TemplateBasicDetailsPane({switchPane:e,templateName:t,setTemplateName:a,description:l,setDescription:s,iconUrl:A,modalType:N="publish",publishStepNumber:M,totalNumberOfPublishSteps:L}){let O=(0,y.X)(),{isTemplateNameValid:F}=(0,g.f)(),D=(0,r.wA)(),[P,R]=(0,n.useState)(!1),B=(0,S.d4)(v.dm),W="publish"===N,V=(0,n.useCallback)(()=>D((0,C.O)()),[D]),H=(0,n.useRef)(null),q=(0,n.useCallback)(()=>H?.current?.click(),[]),U=(0,n.useCallback)(t=>{let a=(t.target.files||[])[0];a&&e(_.C7.UploadImg,{file:a})},[e]),[z,j]=(0,n.useState)(!1),G=(0,n.useMemo)(()=>!!(0,k.A)(t),[t]),$=(0,n.useMemo)(()=>!!(0,w.A)(t,f.p),[t]),K=(0,n.useMemo)(()=>(0,x.Zb)(t),[t]),Y=(0,n.useMemo)(()=>(0,x.yA)(t),[t]),Q=(0,n.useMemo)(()=>(0,x.L8)(t),[t]),Z=(0,n.useMemo)(()=>Y?I.t("Whoops! That name is reserved."):K?B?I.t("Template names can\u2019t support special characters (i.e. !#$%&)."):"Template names can\u2019t support special characters (i.e. !#$%&).":Q?B?I.t("Whoops! Template names cannot have emojis."):"Whoops! Template names cannot have emojis.":z?I.t("This template already exists, choose a different name."):"",[B,K,Y,Q,z]),J=(0,n.useMemo)(()=>!!(0,k.A)(l),[l]),X=(0,n.useMemo)(()=>!!(0,w.A)(l,f.p),[l]),ee=(0,n.useMemo)(()=>(0,o.A)(e=>{F(e).then(e=>{e||j(!0)})},600),[F]),et=(0,n.useCallback)(async e=>{j(!1),a(e);let t=e.trim();t.length&&t!==O?.workflow.title&&ee(t)},[a,O?.workflow.title,ee]),ea=(0,n.useCallback)(async()=>{if(W)return void e(_.C7.AdvancedDetails);if(O){R(!1);try{await D((0,h.J7)({...O,description:l,templateName:t,iconUrl:A,prevTemplateState:O.templateState})),O.refetchTemplate?.(),e(_.C7.Confirmation)}catch{R(!0)}}},[l,D,A,W,e,O,t]),en=(0,n.useMemo)(()=>!!Z||G||$||J||X,[Z,G,$,J,X]);return B?n.createElement(n.Fragment,null,n.createElement(E.rQ,null,n.createElement(E.Rc,{id:"story__title-bar",title:W?I.t("Publish Template"):I.t("Edit details")})),n.createElement(E.$m,null,n.createElement(E.qf,null,n.createElement(d.A,{text:I.t("Template Name")},n.createElement(u.A,{id:"template-details-name",type:"text",maxCharacterLimit:f.p,minCharacterLimit:f.H,name:"name",value:t,onChange:et,placeholder:I.t("Something short and descriptive"),errorText:Z,autoComplete:"off",focusOnMount:!0,"data-qa":"workflow-details-modal-name__input",useInlineAlert:!0,isRequired:!0})),n.createElement(d.A,{text:I.t("Description")},n.createElement(m.A,{id:"workflow-details-modal_d