@planningcenter/core-automations 1.12.2 → 1.12.3-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core-automations.esm.js +1 -1
- package/dist/cjs/core-automations.esm.js.map +1 -1
- package/dist/cjs/core-automations.js +1 -1
- package/dist/cjs/core-automations.js.map +1 -1
- package/dist/cjs/core-automations.modern.mjs +1 -1
- package/dist/cjs/core-automations.modern.mjs.map +1 -1
- package/dist/cjs/core-automations.umd.js +1 -1
- package/dist/cjs/core-automations.umd.js.map +1 -1
- package/dist/types/src/automation.d.ts.map +1 -1
- package/dist/types/src/utils/theme.d.ts +2 -0
- package/dist/types/src/utils/theme.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@planningcenter/api-client"),require("@planningcenter/tapestry"),require("@planningcenter/tapestry-react"),require("react"),require("lodash/sortBy"),require("lodash"),require("moment"),require("@planningcenter/sweetalert2"),require("sweetalert2/dist/sweetalert2"),require("react-dom"),require("@planningcenter/icons/paths/church-center"),require("@planningcenter/icons/paths/services")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@planningcenter/api-client","@planningcenter/tapestry","@planningcenter/tapestry-react","react","lodash/sortBy","lodash","moment","@planningcenter/sweetalert2","sweetalert2/dist/sweetalert2","react-dom","@planningcenter/icons/paths/church-center","@planningcenter/icons/paths/services"],t):t((e||self).coreAutomations={},e.jsxRuntime,e.apiClient,e.tapestry,e.tapestryReact,e.react,e.sortBy,e.lodash,e.moment,e.sweetalert2,e.Swal,e.reactDom,e.churchCenter,e.services)}(this,function(e,t,n,i,a,r,o,s,l,c,d,u,p,h){function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function g(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t}var w=/*#__PURE__*/m(r),f=/*#__PURE__*/m(o),x=/*#__PURE__*/m(l),v=/*#__PURE__*/m(d),b=/*#__PURE__*/g(p),k=/*#__PURE__*/g(h);const j=()=>t.jsxs("svg",{id:"automations_blank","data-name":"Automations Blank",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 111.112 84.832",className:"symbol",children:[t.jsx("title",{children:"Automations"}),t.jsx("g",{opacity:"0.6",children:t.jsx("path",{d:"M107.784,46.051A57.416,57.416,0,0,1,85.26,75.058c-9.7,6.247-20.045,7.792-31.912,5.185-11.74-2.638-23.339-8-32.92-13.088-9.51-5.342-17-10.236-18.863-17.925C-.26,41.753,3.737,31.4,13.347,21.194,22.85,11.162,37.968,1.853,55.948.321,73.8-1.476,90.2,4.478,99.608,13.164,109.257,21.9,111.921,33.784,107.784,46.051Z",fill:"#e1f0f9",className:"svg-background-blob"})}),t.jsx("path",{d:"M81,27.269v31.8a2.685,2.685,0,0,1-2.685,2.685H44.564a2.685,2.685,0,0,1-2.685-2.685V15.425a2.685,2.685,0,0,1,2.685-2.685h21.91a2.681,2.681,0,0,1,1.9.786L80.217,25.371A2.685,2.685,0,0,1,81,27.269Z",fill:"#fff"}),t.jsx("path",{d:"M68.479,13.633v9.8a2.035,2.035,0,0,0,2.035,2.034h9.877Z",fill:"#c9d8e2"}),t.jsx("rect",{x:"51.214",y:"41.285",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),t.jsx("rect",{x:"51.214",y:"48.434",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),t.jsx("rect",{x:"51.214",y:"34.136",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),t.jsx("rect",{x:"11.771",y:"44.005",width:"50.915",height:"6.664",transform:"translate(-22.93 44.557) rotate(-49.171)",fill:"#454942"}),t.jsx("path",{d:"M56.283,30.38l-7.557,8.745a5.968,5.968,0,0,0-2.005-2.734,6.292,6.292,0,0,0-3.036-1.624l7.555-8.743a6.275,6.275,0,0,1,3.038,1.624A5.959,5.959,0,0,1,56.283,30.38Z",fill:"#fcc846"}),t.jsx("path",{d:"M58.088,28.29l-7.556,8.745a5.968,5.968,0,0,0-2-2.734,6.3,6.3,0,0,0-3.036-1.624l7.555-8.743a6.274,6.274,0,0,1,3.037,1.624A5.959,5.959,0,0,1,58.088,28.29Z",fill:"#48a5e5"}),t.jsx("path",{d:"M58.724,10.432l1.17,2.7a2.129,2.129,0,0,0,1.4,1.207l2.843.765a.73.73,0,0,1,.1,1.375l-2.7,1.17a2.125,2.125,0,0,0-1.207,1.4L59.56,21.89a.73.73,0,0,1-1.374.1l-1.17-2.7a2.125,2.125,0,0,0-1.4-1.206l-2.843-.766a.73.73,0,0,1-.1-1.374l2.7-1.17a2.121,2.121,0,0,0,1.206-1.4l.766-2.844A.73.73,0,0,1,58.724,10.432Z",fill:"#fcc846"}),t.jsx("path",{d:"M44.544,19.294l1.024.868a.968.968,0,0,0,.814.21l1.316-.261a.333.333,0,0,1,.319.541l-.868,1.024a.968.968,0,0,0-.21.814l.261,1.316a.333.333,0,0,1-.541.319l-1.024-.868a.968.968,0,0,0-.814-.21l-1.316.261a.333.333,0,0,1-.319-.541l.868-1.024a.967.967,0,0,0,.21-.814L44,19.613A.333.333,0,0,1,44.544,19.294Z",fill:"#fcc846"}),t.jsx("path",{d:"M64.223,25.729l.869,2.005a1.575,1.575,0,0,0,1.036.895l2.109.568a.542.542,0,0,1,.075,1.02l-2,.868a1.576,1.576,0,0,0-.9,1.036l-.568,2.11a.541.541,0,0,1-1.019.074L62.955,32.3a1.572,1.572,0,0,0-1.036-.895l-2.109-.568a.542.542,0,0,1-.075-1.02l2.005-.868a1.572,1.572,0,0,0,.895-1.036L63.2,25.8A.541.541,0,0,1,64.223,25.729Z",fill:"#fcc846"})]}),y=/*#__PURE__*/r.createContext({dateFormat:null,olsonTimeZone:null,twentyFourHourTime:null});v.default.mixin(c.standardAlertOptions),v.default.mixin(c.successAlertOptions);const S=v.default.mixin(c.errorAlertOptions),C=v.default.mixin(c.standardConfirmOptions),z=v.default.mixin(c.destroyConfirmOptions),_=v.default.mixin(c.createConfirmOptions),P=function(e){try{return Promise.all(e.map(function(e){try{const t=function(){if(function(e){return["AddToWorkflowOperationDefinition","CustomFieldBooleanOperationDefinition","CustomFieldCheckboxesOperationDefinition","CustomFieldDateOperationDefinition","CustomFieldNumberOperationDefinition","CustomFieldSelectOperationDefinition","CustomFieldStringOperationDefinition","CustomFieldTextOperationDefinition"].includes(e.operationDefinitionClassName)}(e))return Promise.resolve(function(e){try{function t(){return n||e.description}let n="";const i=function(){if("AddToWorkflowOperationDefinition"===e.operationDefinitionClassName)return Promise.resolve(function(e){try{return Promise.resolve(O.get({data:{fields:{Workflow:"name,archived_at"},where:{id:e}},url:"workflows"}).catch(()=>[{data:{name:""}}])).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(e.operationParams.workflowId)).then(function(t){const i=t[0];if(i?.name){let t;t=i.archivedAt?`[archived] ${i.name}`:i.name,n=e.description.replace("[Hidden Workflow]",t)}});{const t=e.operationParams.definitionIdentifier.match(/(\d+)_field_definition/)[1];return Promise.resolve(function(e){try{return Promise.resolve(O.get({data:{fields:{FieldDefinition:"name,data_type,field_options",FieldOption:"value"},include:"field_options"},url:`field_definitions/${e}`}).catch(()=>({data:{name:""}}))).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(t)).then(function(t){t.name&&(n=e.description.replace("[Hidden Custom Field]",t.name),n+=e.operationParams.values||"checkboxes"!==t.dataType?` (${function(e,t){switch(t.dataType){case"checkboxes":return Object.entries(e.operationParams.values).map(([e,n])=>{const i=t.fieldOptions.find(t=>t.id===parseInt(e,10))?.value||"[Hidden value]";return`${T(n)} ${i}`}).join(", ");case"select":return e.operationParams.value?t.fieldOptions.find(t=>t.id===parseInt(e.operationParams.value.toString(),10))?.value||"[Hidden value]":"Unanswered";case"boolean":switch(e.operationParams.value){case"true":return"Yes";case"false":return"No";default:return"Unanswered"}default:return e.operationParams.value??"Unanswered"}}(e,t)})`:"")})}}();return Promise.resolve(i&&i.then?i.then(t):t())}catch(a){return Promise.reject(a)}}(e)).then(function(t){e.description=t})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function T(e){return e.charAt(0).toUpperCase()+e.slice(1)}const O=new n.Client({app:"people",version:"2025-03-20"});function A(e){return e.listClass?`${e.id}_${e.listClass}`:"PersonSearch"===e.kind?`${e.id}_PersonSearch`:null}function V(e){if(e.definitionClass.match(/^CustomField\w+OperationDefinition$/))return"Update [Hidden Custom Field]"}function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function F({field:e,loadedLists:t}){if(e.list)return e.list;if(A(e))return t[A(e)];throw new Error(`Don't know how to get list for ${JSON.stringify(e)}`)}function L(e,t){return e.filter(e=>{if(Object.prototype.hasOwnProperty.call(e,"renderIf")){const n=e.renderIf,i=Object.keys(n)[0];return s.isBoolean(n)?n:n[i]===t[i]}return!0})}function $({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n,description:i}){if("AddToWorkflowOperationDefinition"===e.definitionClass){const e=n.workflow_id_WorkflowsList,a=e&&e.find(e=>e.value.toString()===t.workflow_id)?.description;return i.replace(a,"[Hidden Workflow]")}return e.definitionClass.match(/^CustomField\w+OperationDefinition$/)?"":i}({description:e.definitionFields.map(e=>{if(!I(t,e.id))return null;const i=t[e.id];let a;switch(e.kind){case"Select":case"SelectSearch":case"PersonSearch":case"RadioButtons":return a=F({field:e,loadedLists:n}),a&&a.find(e=>e.value.toString()===i)?.description;case"Checkbox":return i&&e.label;case"Checkboxes":return a=F({field:e,loadedLists:n}),a.filter(e=>I(i,e.value)).map(e=>`${T(i[e.value])} ${e.description}`).join(", ");case"NumberField":case"TextField":case"TextArea":case"DateField":return i;default:throw new Error(`Don't know how to build value for field with kind ${e.kind}`)}}).filter(e=>e).join(", "),loadedLists:n,selectedDefinition:e,selectedFieldOptions:t})}function B(e){return e.replace(/%m/,"MM").replace(/%d/,"DD").replace(/%Y/,"YYYY").replace(/%y/,"YY")}function D(e,t){const n=x.default(e,"YYYY-MM-DD");if(!n.isValid())return"";const i=B(t);return n.format(i)}function H(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function R(e){return e.replace(/s$/,"")}function N(e){const t=e.split("/");return{appName:t[0],resourceId:t[t.length-1],resourcePath:t.slice(2,-1).join("/"),resourceType:t[t.length-2]}}function W(e,t){return"403"===e.errors?.[0]?.status?`You don't have permission to ${t||"modify"} this automation.`:null}const E=function(e){try{const t=e.data.map(e=>G(e));return Promise.resolve(function(n,i){try{var a=Promise.resolve(M(t)).then(function(t){return{events:e,people:t}})}catch(e){return i()}return a&&a.then?a.then(void 0,i):a}(0,function(){return{events:e,people:[]}}))}catch(e){return Promise.reject(e)}},M=function(e){try{return Promise.resolve(Y.get({data:{fields:{Person:"id,name"},where:{id:e.join(",")}},url:"people"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},q=function(e,t,n){try{return Promise.resolve(U.get({data:{_e:e,fields:{Delivery:"status,response_body,created_at",Event:"id,created_at,last_delivery,payload,status,uuid,person"},include:"last_delivery",order:"-created_at",...n},url:`automation_subscriptions/${t}/events`}))}catch(e){return Promise.reject(e)}},U=new n.Client({app:"webhooks",version:"2022-10-20"}),Y=new n.Client({app:"people",version:"2022-07-14"}),Z={delivered:{label:"Success",value:["delivered"]},failed:{label:"Failed",value:["failed","duplicated"]},ignored:{label:"Ignored",value:["ignored_duplicated","ignored_failed","ignored_skipped"]},pending:{label:"Pending",value:["pending"]},skipped:{label:"Paused",value:["skipped"]}};function Q({events:e,people:t}){const n=e.data.reduce((e,n)=>{const i=G(n),a=t.find(e=>i.toString()===e.id.toString());return e.push(a?{...n,person:{id:a.id,name:a.name}}:{...n,person:{id:i,name:"[Hidden]"}}),e},[]);return{...e,data:n}}function G(e){return e.personId}function J({automation:e,triggerResource:n,filterWhere:o,onEventsStatusChange:s}){const{events:l,loading:c,paginationProps:d,refresh:u,params:p,setParams:h}=function(e,t,n){const[i,a]=r.useState(),[o,s]=r.useState(!1),[l,c]=r.useState({}),[d,u]=r.useState(n?{where:{status:n}}:{}),[p,h]=r.useState(),{offset:m,paginationProps:g,resetOffset:w}=function(e,t){const[n,i]=r.useState(0);return{offset:n,paginationProps:{currentPage:Math.floor(n/50)+1,onPageChange:function(e){i(50*(e-1))},totalPages:Math.ceil(t/50)},resetOffset:r.useCallback(()=>{i(0)},[])}}(0,p?.totalCount);r.useEffect(()=>{o||l[m]||(s(!0),q(t,e,{offset:m,per_page:50,...d}).then(E).then(Q).then(e=>{c(t=>({...t,[m]:e.data})),h(e.meta),s(!1)}).catch(x))},[e,t,o,d,m,l]);const f=r.useCallback(()=>{c({}),h(void 0),w()},[w]);function x(e){a(()=>{throw e})}return r.useEffect(()=>{f()},[f,d]),{events:l[m]||[],loading:o,paginationProps:g,params:d,refresh:f,setParams:u}}(e.id,n,o),{dateFormat:m,olsonTimeZone:g,twentyFourHourTime:w}=r.useContext(y),f=p.where&&Object.keys(p.where).length>0,v=function(e){const t=x.default(e,"YYYY-MM-DD");return x.default().diff(t,"days")}(e.createdAt)<=32,b=D(e.createdAt,m),k=v?`Automation history started on ${b}`:"Automation history is saved for 32 days",S=[{cell:e=>t.jsx(ee,{status:e.status}),css:{padding:"8px 12px"},header:"Status"},{cell:e=>x.default(e.createdAt).utcOffset(g).format(function({dateFormat:e,twentyFourHourTime:t}){return`${B(e)} ${t?"HH:mm":"h:mm A"}`}({dateFormat:m,twentyFourHourTime:w})),header:"Date and time"},{cell:e=>t.jsx(a.Link,{to:`/people/AC${e.person.id}`,children:e.person.name}),css:{maxWidth:"33%"},header:"Profile"},{cell:e=>t.jsx(te,{event:e}),css:{flex:1},header:"Message"},{cell:i=>![...Z.delivered.value,...Z.pending.value].includes(i.status)&&t.jsxs(t.Fragment,{children:[t.jsx(X,{automationId:e.id,event:i,triggerResource:n,onEventsStatusChange:s}),![...Z.ignored.value].includes(i.status)&&t.jsx(K,{automationId:e.id,event:i,triggerResource:n,refreshHistory:u,onEventsStatusChange:s})]}),css:{textAlign:"right"},header:"",minWidth:"84px"}];return t.jsxs(a.StackView,{spacing:i.token("--t-spacing-4"),children:[t.jsxs(a.StackView,{spacing:i.token("--t-spacing-half"),children:[t.jsx(a.Heading,{level:3,size:"16px",color:i.token("--t-text-color-default-secondary"),weight:i.token("--t-font-weight-medium"),children:e.description}),t.jsx(a.Text,{color:i.token("--t-text-color-default-secondary"),size:i.token("--t-font-size-xs"),italic:!0,children:k})]}),t.jsxs(a.StackView,{spacing:i.token("--t-spacing-2"),children:[t.jsx(a.Box,{minHeight:7,children:!c&&(l.length||f)&&t.jsxs(a.StackView,{alignItems:"end",axis:"horizontal",distribution:"space-between",spacing:i.token("--t-spacing-1"),children:[t.jsxs(a.StackView,{width:"max-content",children:[t.jsx(a.Input.InputLabel,{fontWeight:i.token("--t-font-weight-medium"),color:i.token("--t-text-color-default-primary"),controls:"select-status",children:"Filter by status"}),t.jsxs(a.Select,{id:"select-status",emptyValue:null,onChange:({selectedValue:e})=>{h({where:e?{status:e}:null})},title:"Status",value:p.where?.status,children:[t.jsx(a.Select.Option,{value:null,children:"All"}),Object.values(Z).map(e=>t.jsx(a.Select.Option,{value:e.value.join(","),children:e.label},e.value))]})]}),t.jsx(a.Button,{iconLeft:{name:"general.refresh"},onClick:u,theme:"primary",variant:"outline",width:12,children:"Refresh"})]})}),t.jsx(a.Box,{maxHeight:"70vh",minHeight:36,overflow:"auto",children:t.jsx(a.DataTable,{columns:S,data:l,empty:t.jsxs(a.StackView,{alignment:"center",distribution:"center",minHeight:20,maxWidth:45,spacing:i.token("--t-spacing-1"),marginTop:f?-4:-8,marginBottom:f?4:void 0,children:[t.jsx(a.Box,{css:{svg:{height:15,width:20}},children:t.jsx(j,{})}),t.jsx(a.Heading,{color:i.token("--t-text-color-default-headline"),fontWeight:i.token("--t-font-weight-medium"),level:4,size:i.token("--t-font-size-lg"),children:"No history found"}),t.jsxs(a.Text,{fontSize:i.token("--t-font-size-md"),textAlign:"center",children:["No events ",f&&"matching your filters"," were triggered for this automation"," ",v?`since ${b}.`:"in the last 32 days."]}),f&&t.jsx(a.Button,{marginTop:i.token("--t-spacing-1"),onClick:()=>h({}),theme:"primary",title:"Clear filters",variant:"outline"})]}),loading:c,loadingTitle:"Loading automation history...",variant:{bodyCell:{alignItems:"start",fontSize:i.token("--t-font-size-sm"),lineHeight:"20px",padding:"10px 12px"},bodyRow:({rowData:e})=>({backgroundColor:[...Z.ignored.value].includes(e.status)?i.token("--t-fill-color-neutral-090"):void 0,minHeight:"36px"}),headerCell:{padding:"8px 12px"},headerRow:{minHeight:"36px"}},...d})})]})]})}function X({automationId:e,event:n,triggerResource:o,onEventsStatusChange:s}){const[l,c]=r.useState(n.status),d=Z.pending.value.includes(l)?"Sending":Z.delivered.value.includes(l)?"Sent":Z.skipped.value.includes(l)?"Run now":"Retry",u=Z.delivered.value.includes(l)?{color:i.token("--t-text-color-status-success"),name:"general.check"}:void 0;return t.jsx(a.Button,{title:d,onClick:function(){c(Z.pending.value.join(",")),U.post({data:{_e:o,data:{attributes:{}}},url:`/automation_subscriptions/${e}/events/${n.id}/redeliver`}).then(e=>{c(Z.delivered.value.join(",")),s(e.meta.eventsStatus)}).catch(()=>{c(Z.failed.value.join(",")),S.fire({text:"There was a problem retrying this automation. Please try again in a few moments.",title:"Uh oh!"})})},iconLeft:u,disabled:l!==n.status,variant:"naked",color:Z.delivered.value.includes(l)?i.token("--t-text-color-status-success"):Z.pending.value.includes(l)?i.token("--t-text-color-default-placeholder"):i.token("--t-text-color-interaction-primary"),theme:"primary",size:"xs"})}function K({automationId:e,event:n,triggerResource:i,refreshHistory:r,onEventsStatusChange:o}){return t.jsx(a.Button,{title:"Ignore",onClick:function(){U.post({data:{_e:i,data:{attributes:{}}},url:`/automation_subscriptions/${e}/events/${n.id}/ignore`}).then(e=>{o(e.meta.eventsStatus)}).then(()=>r()).catch(()=>{S.fire({text:"There was a problem ignoring this event. Please try again in a few moments.",title:"Uh oh!"})})},variant:"naked",color:"linkForeground",theme:"primary",size:"xs"})}function ee({status:e}){const n=Z.pending.value.includes(e)?{border:i.token("--t-border-color-default-dark"),text:i.token("--t-text-color-default-primary")}:Z.delivered.value.includes(e)?{border:i.token("--t-border-color-status-success"),text:i.token("--t-text-color-status-success")}:Z.skipped.value.includes(e)?{border:i.token("--t-border-color-status-warning"),text:i.token("--t-text-color-status-warning")}:Z.ignored.value.includes(e)?{border:i.token("--t-border-color-default-dark"),text:i.token("--t-text-color-default-secondary")}:{border:i.token("--t-border-color-status-error"),text:i.token("--t-text-color-status-error")},r=Z.pending.value.includes(e)?"general.clock":Z.skipped.value.includes(e)?"services.pause":Z.delivered.value.includes(e)?"general.checkCircle":Z.ignored.value.includes(e)?"general.inactive":"general.exclamationTriangle",o=Z.failed.value.includes(e)?Z.failed.label:Z.ignored.value.includes(e)?Z.ignored.label:Z[e].label;return t.jsx(a.Badge,{color:{background:"transparent",foreground:n.text},css:{paddingLeft:3.5,paddingRight:1.5},fontSize:i.token("--t-font-size-xs"),radius:"pill",renderLeft:t.jsx(a.Icon,{name:r,color:n.border,marginLeft:i.token("--t-spacing-1")}),size:"sm",stroke:n.border,strokeAlign:"inside",strokeWeight:1,title:o})}function te({event:e}){const{status:n,lastDelivery:r}=e,o=function(e,n){let i=null;switch(e){case"skipped":case"ignored_skipped":i="Automation was paused and did not run on this profile";break;case"failed":case"duplicated":case"ignored_failed":case"ignored_duplicated":i=function(e,n){const i={403:"Owner doesn't have permission to perform this action.",404:"Owner lacks access to target product or resource doesn't exist.",422:"The automation action failed to run",default:"An error occurred",duplicated_event:"Didn't run because the same action had already been performed less than 60 seconds ago",failed_without_deliveries:"Didn't run because the owner doesn't have permissions in this product."};return t.jsx(a.StackView,{flex:1,whiteSpace:"normal",children:e?t.jsx(ne,{details:function(e){if(!e?.responseBody)return null;let t;try{t=JSON.parse(e.responseBody)}catch{t={errors:["Server Error"]}}return function(e){return e?.errors?e.errors.map(e=>"string"==typeof e&&e.match(/Archived profiles/)?e.replace(/Archived profiles/,"Archived profiles."):e):[]}(t).join(", ")||t?.message}(e),status:e.status,children:i[e.status]||i.default}):["duplicated","ignored_duplicated"].includes(n)?i.duplicated_event:i.failed_without_deliveries})}(n,e)}return i}(n,r);return o?t.jsx(a.Box,{fontSize:i.token("--t-font-size-sm"),fontStyle:"italic",lineHeight:"16px",maxWidth:"100%",paddingTop:"1px",whiteSpace:"normal",children:o}):null}function ne({children:e,details:n,status:o}){const[s,l]=r.useState(!1);return t.jsxs(a.StackView,{spacing:i.token("--t-spacing-1"),children:[t.jsxs(a.Box,{children:[e," ",n&&t.jsx(a.Button,{inline:!0,onClick:function(){l(e=>!e)},size:"xs",theme:"primary",variant:"naked",fontStyle:"normal",children:"Details"})]}),s?t.jsx(a.Box,{padding:1,background:i.token("--t-fill-color-neutral-090"),children:t.jsxs(a.Text,{fontFamily:"monospace",fontSize:i.token("--t-font-size-xs"),lineHeight:"1.2",children:[o&&`${o}: `,n]})}):null]})}class ie extends w.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t.jsxs(a.Alert,{type:"error",marginVertical:i.token("--t-spacing-1"),children:["The application hit an unexpected error. If this persists after a few minutes, please let us know so we can get it fixed for you."," ",t.jsx("a",{style:{whiteSpace:"nowrap"},onClick:()=>window.Helpdesk.load(),children:"Contact support"})]}):this.props.children}}var ae=e=>t.jsx(ie,{children:t.jsx(J,{...e})});function re({onClick:e}){return t.jsx(a.Button,{as:"button",height:i.token("--t-element-size-md"),icon:{color:i.token("--t-icon-color-default-dim"),name:"general.x"},onClick:e,size:"sm",title:"Close",variant:"naked"})}function oe({children:e,onRequestClose:n,open:r,theme:o}){/*#__PURE__*/return u.createPortal(t.jsx(a.ThemeProvider,{theme:o,children:t.jsxs(a.Modal,{open:r,onRequestClose:n,maxWidth:120,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:i.token("--t-spacing-4"),paddingBottom:i.token("--t-spacing-3"),radius:i.token("--t-border-radius-lg"),children:[t.jsxs(a.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[t.jsx(a.Heading,{level:2,color:i.token("--t-text-color-default-headline"),fontWeight:i.token("--t-font-weight-medium"),fontSize:i.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Automation history"}),t.jsx(re,{onClick:n})]}),e]})}),document.body)}const se=function(e){try{return Promise.resolve(ce.get({data:{fields:{Person:"avatar"}},url:"me"})).then(function({data:{avatar:t}}){return{avatar:t,subscription:e}})}catch(e){return Promise.reject(e)}},le=new n.Client({app:"webhooks",version:"2022-10-20"}),ce=new n.Client({app:"people"}),de=/*#__PURE__*/r.createContext(null);function ue({updateAutomation:e,onDelete:n,theme:i,openHistoryNow:a=!1,disabled:r,disabledReason:o,...s}){return t.jsxs(ge,{theme:i,updateAutomation:e,...s,children:[t.jsxs(we,{children:[t.jsx(xe,{}),t.jsx(fe,{onDelete:n,openHistoryNow:a,disabled:r,disabledReason:o})]}),t.jsx(ke,{}),t.jsx(be,{})]})}function pe(e){return t.jsxs(ge,{automation:e.automation,children:[t.jsxs(we,{children:[t.jsx(xe,{}),t.jsx(me,{})]}),t.jsx(he,{}),t.jsx(ve,{})]})}function he(){const{automation:e}=r.useContext(de),n=e.triggerEventDescription,{name:o,description:l}=ye(e.description),c=e.active?void 0:.5;return t.jsxs(a.StackView,{paddingVertical:i.token("--t-spacing-2"),flex:1,opacity:c,children:[t.jsx(a.Heading,{level:3,size:i.token("--t-font-size-xl"),weight:i.token("--t-font-weight-medium"),marginBottom:i.token("--t-spacing-half"),truncate:!0,children:o}),t.jsxs(a.StackView,{spacing:.75,children:[t.jsxs(a.Text,{size:i.token("--t-font-size-sm"),color:i.token("--t-text-color-default-primary"),lineHeight:"1.2",children:[n,", then ",s.lowerFirst(o)," ",je(e)]}),t.jsx(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:s.truncate(Se(l),{length:160,separator:" "})})]})]})}function me(){const{automation:e}=r.useContext(de);return t.jsx(a.Button,{external:!0,iconLeft:{name:"general.newWindow"},variant:"naked",size:"sm",to:e.triggerAdminUrl,disabled:!e.canManage,tooltip:e.canManage?void 0:"You do not have access to this resource",color:i.token("--t-text-color-default-secondary"),hover:{backgroundColor:"highlight",color:i.token("--t-text-color-default-secondary")},children:"Manage"})}function ge({automation:e,updateAutomation:n,children:i,theme:r,...o}){return t.jsx(de.Provider,{value:{automation:e,theme:r,updateAutomation:n,...o},children:t.jsx(a.Card,{radius:4,padding:2,children:i})})}function we({children:e}){const{automation:n}=r.useContext(de);return t.jsx(a.StackView,{axis:"horizontal",alignment:"center",padding:0,distribution:"space-between",opacity:n.active?void 0:.5,children:e})}function fe({onDelete:e,openHistoryNow:n=!1,disabled:o,disabledReason:s}){const{automation:l,currentPersonCanCreate:c,currentPersonId:d,trigger:u,theme:p,updateAutomation:h}=r.useContext(de),[m,g]=r.useState(n),w=l.active,{name:f}=ye(l.description);return t.jsxs(t.Fragment,{children:[t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[t.jsxs(a.Dropdown,{icon:{color:i.token("--t-icon-color-default-primary"),name:"churchCenter.threeDots"},iconRight:!1,title:"Actions",variant:"naked",size:"md",disabled:o,children:[t.jsx(a.Dropdown.Item,{onSelect:()=>{g(!0)},children:"History"}),c&&t.jsx(a.Dropdown.Item,l.createdById===d?{disabled:!0,children:t.jsx(a.Tooltip,{placement:"left",openDelay:250,title:"This automation is already assigned to you.",children:t.jsx(a.Text,{children:"Reassign to me..."})})}:{onSelect:function(){C.fire({text:"This automation will run with your permission levels. Other administrators who can see this automation can grant it their permissions by reassigning it to themselves.",title:"Reassign automation?"}).then(({isConfirmed:e})=>{e&&le.post({data:{_e:u.resource,data:{attributes:{}}},url:`/automation_subscriptions/${l.id}/self_assign`}).then(({data:e})=>se(e)).then(({subscription:e,avatar:t})=>{h(n=>({...n,createdBy:{...n.createdBy,avatarUrl:t},createdById:e.createdById,createdByName:e.createdByName}))}).catch(e=>{const t=W(e,"update")||"There was a problem updating this automation. Please try again in a few moments.";S.fire({text:t,title:"Uh oh!"})})})},children:"Reassign to me..."}),t.jsx(a.Dropdown.Item,{onSelect:function(){z.fire({confirmButtonText:"Yes, delete automation",text:`Are you sure you want to delete the "${f}" automation? This cannot be undone.`,title:"Delete this automation?"}).then(({isConfirmed:t})=>{t&&e(l.id)})},children:"Delete..."})]}),t.jsx(a.ToggleSwitch,{isChecked:w,size:"sm",onClick:function(){le.patch({data:{_e:u.resource,data:{attributes:{active:!w}}},url:`/automation_subscriptions/${l.id}`}).then(e=>{h(t=>({...t,active:e.data.active}))}).catch(e=>{const t=W(e,"pause")||`There was a problem ${w?"pausing":"unpausing"} this automation. Please try again in a few moments.`;S.fire({text:t,title:"Uh oh!"})})},tooltip:o?s:w?"Pause automation":"Enable automation",disabled:o})]}),t.jsx(oe,{open:m,onRequestClose:()=>g(!1),theme:p,children:t.jsx(ae,{automation:l,triggerResource:u.resource,onEventsStatusChange:function(e){h(t=>({...t,eventsStatus:e}))}})})]})}function xe(){const{automation:e}=r.useContext(de),n=e.name.split(".")[0];return t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:.5,children:[t.jsx(a.Logo,{markOnly:!0,name:n,size:"sm",theme:"color"}),t.jsx(a.Icon,{name:"general.rightArrow",size:1.5}),t.jsx(a.Logo,{markOnly:!0,name:e.operationAppName,size:"sm",theme:"color"})]})}function ve(){const{automation:e}=r.useContext(de),{dateFormat:n}=r.useContext(y),o=`${e.createdByName} ${e.createdBy?.id?"":"(deleted profile)"}`,s=e.active?void 0:.5;return t.jsxs(t.Fragment,{children:[t.jsx(a.Divider,{marginHorizontal:-2}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:i.token("--t-spacing-1"),opacity:s,children:[t.jsxs(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",D(e.createdAt,n)]}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-half"),maxWidth:"calc(100% - 136px)",children:[e.createdBy?.avatarUrl&&t.jsx(a.Avatar,{width:2,height:2,basis:2,source:e.createdBy.avatarUrl},o),t.jsx(a.Text,{size:5,truncate:!0,children:o})]})]})]})}function be(){const{dateFormat:e}=r.useContext(y),{automation:n,trigger:o,theme:s,updateAutomation:l}=r.useContext(de),c=`${n.createdByName} ${n.createdBy?.id?"":"(deleted profile)"}`,d=n.active?void 0:.5,u={color:i.token("--t-text-color-default-secondary"),fontSize:i.token("--t-font-size-xs"),fontWeight:i.token("--t-font-weight-normal"),paddingHorizontal:i.token("--t-spacing-1"),radius:"pill",size:"xs",variant:"naked"},[p,h]=r.useState({filter:null,historyVisible:!1});return t.jsxs(t.Fragment,{children:[t.jsx(a.Divider,{marginHorizontal:-2}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:i.token("--t-spacing-1"),opacity:d,children:[t.jsxs(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",D(n.createdAt,e)]}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-fourth"),children:[!!n.eventsStatus?.skipped&&t.jsxs(a.Button,{...u,"aria-label":`${n.eventsStatus.skipped} skipped`,onClick:function(){h({filter:"skipped",historyVisible:!0})},tooltip:`${n.eventsStatus.skipped?.toLocaleString()} skipped events`,children:[t.jsx(a.Box,{backgroundColor:i.token("--t-fill-color-status-warning-solid"),marginRight:i.token("--t-spacing-half"),radius:"circle",height:"10px",width:"10px",padding:i.token("--t-spacing-fourth"),children:t.jsx(a.Icon,{name:"services.pause",size:"6px",title:"Skipped",color:"white"})}),`${n.eventsStatus.skipped?.toLocaleString()}`]}),!!n.eventsStatus?.failed&&t.jsx(a.Button,{...u,"aria-label":`${n.eventsStatus.failed} failed`,iconLeft:{color:i.token("--t-icon-color-status-error-primary"),marginRight:i.token("--t-spacing-half"),name:"general.exclamationTriangle",size:"10px",title:"Failed"},onClick:function(){h({filter:"failed,duplicated",historyVisible:!0})},title:`${n.eventsStatus.failed?.toLocaleString()}`,tooltip:`${n.eventsStatus.failed?.toLocaleString()} failed events`})]}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",distribution:"end",flex:1,spacing:i.token("--t-spacing-half"),marginLeft:"auto",children:[n.createdBy?.avatarUrl&&t.jsx(a.Avatar,{width:i.token("--t-element-size-md"),height:i.token("--t-element-size-md"),basis:i.token("--t-element-size-md"),source:n.createdBy.avatarUrl},c),t.jsx(a.Text,{size:i.token("--t-font-size-sm"),truncate:!0,children:c})]})]}),t.jsx(oe,{open:p.historyVisible,onRequestClose:()=>h({filter:null,historyVisible:!1}),theme:s,children:t.jsx(ae,{automation:n,triggerResource:o.resource,filterWhere:p.filter,onEventsStatusChange:function(e){l(t=>({...t,eventsStatus:e}))}})})]})}function ke(){const{automation:e,trigger:n}=r.useContext(de),{name:o,description:l}=ye(e.description),c=e.active?void 0:.5,d=["When a person",s.lowerFirst(n.event.description)+",","then",s.lowerFirst(o),je(e)].join(" ");return t.jsxs(a.StackView,{paddingVertical:i.token("--t-spacing-2"),flex:1,opacity:c,children:[t.jsx(a.Heading,{level:3,size:i.token("--t-font-size-xl"),weight:i.token("--t-font-weight-bold"),marginBottom:i.token("--t-spacing-half"),truncate:!0,children:o}),t.jsxs(a.StackView,{spacing:.75,children:[t.jsx(a.Text,{size:i.token("--t-font-size-sm"),color:i.token("--t-text-color-default-primary"),lineHeight:"1.2",children:d}),t.jsx(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:s.truncate(Se(l),{length:160,separator:" "})})]})]})}function je(e){return e?.triggerParams?.useTriggerPersonOverride?"(also applies to joint donor)":""}function ye(e){const t=/^(.+?)\(([^()]*?)\)$/.exec(e);return t?{description:t[2],name:t[1].trim()}:{name:e}}function Se(e){return e?.startsWith("[archived]")?e.replace("[archived]","[Archived]"):e}const Ce=function(){try{return Promise.resolve(Pe.get({data:{fields:{App:["name"],PersonApp:["app","allow_pco_login"]},include:["app"]},url:"/me/person_apps"}).then(({data:e})=>e.filter(e=>e.allowPcoLogin).map(e=>e.app.name.toLowerCase())))}catch(e){return Promise.reject(e)}},ze=function(e){try{const t=s.compact(s.uniq(e.map(e=>e.createdById)));return Promise.resolve(function(n,i){try{var a=Promise.resolve(Pe.get({data:{fields:{Person:"avatar"},where:{id:t.join(",")}},url:"people"})).then(function({data:t}){return{profiles:t,subscriptions:e}})}catch(e){return i()}return a&&a.then?a.then(void 0,i):a}(0,function(){return{profiles:[],subscriptions:e}}))}catch(e){return Promise.reject(e)}},_e=new n.Client({app:"webhooks",version:"2022-10-20"}),Pe=new n.Client({app:"people"});function Te({profiles:e,subscriptions:t}){return t.map(t=>{const n=e.find(e=>e.id===t.createdById);return{...t,createdBy:{...t.createdBy,avatarUrl:n?.avatar}}})}const Oe=function(e){try{const t={people:["forms","lists"],registrations:["events"],services:["teams"]},n=["giving"],i=e.reduce((e,t)=>{const n=t.triggerResource.replace(/signup/,"event"),{appName:i,resourceType:a,resourcePath:r,resourceId:o}=N(n);return e[i]||(e[i]={}),e[i][a]||(e[i][a]={}),e[i][a].resoucePath||(e[i][a].resourcePath=r),e[i][a].ids||(e[i][a].ids=[]),e[i][a].ids.push(o),e},{}),a=Object.keys(i).flatMap(e=>Object.entries(i[e]).flatMap(([i,a])=>(n.includes(e)?Le:t[e]?.includes(i)?Ie:Fe)({appName:e,ids:a.ids,resourcePath:a.resourcePath,resourceType:i})));return Promise.resolve(Promise.allSettled(a)).then(function(t){return{automations:e,triggerResources:(n=t,n.reduce((e,t)=>("fulfilled"===t.status&&(e=e.concat(t.value)),e),[]).flatMap(e=>e.data))};var n})}catch(e){return Promise.reject(e)}},Ae=function(e){try{return Promise.resolve(Ve.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,trigger_resource,trigger_params",Person:"name"},include:"created_by"},url:"incoming_automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},Ve=new n.Client({app:"webhooks",version:"2022-10-20"});function Ie({appName:e,resourcePath:t,resourceType:n,ids:i}){return $e({appName:e,params:{where:{id:i.join(",")}},path:t,resourceType:n})}function Fe({appName:e,resourcePath:t,resourceType:n,ids:i}){return i.map(i=>$e({appName:e,path:`${t}/${i}`,resourceType:n}))}function Le(e){return new Promise((e,t)=>{t()})}function $e({appName:e,path:t,resourceType:i,params:a={}}){const r=new n.Client({app:e}),o=s.upperFirst(R(i));return r.get({data:{fields:{[o]:["name","name_or_description"]},...a},url:t})}function Be({encryptedParam:e,trigger:n}){const[o,l]=r.useState(!0),[c,d]=r.useState();r.useEffect(()=>{Ce().then(t=>{Ae(e).then(ze).then(Te).then(P).then(Oe).then(({automations:e,triggerResources:n})=>function({automations:e,triggerResources:t,operationApps:n}){return e.map(e=>{const{appName:i,resourceType:a,resourceId:r}=N(e.triggerResource);if("giving"===i)return e.triggerEventDescription=function(e){switch(e.name.replace("giving.v2.events.","")){case"donation.payment_successful":return"When a person gives";case"profile.first_donated_automation":return"When a person gives for the first time";case"recurring_donation.setup_successful":return"When a person sets up a recurring donation";default:return null}}(e),e.canManage=n.find(e=>"giving"===e),e;const o=t.find(e=>e.id.toString()==r.toString()),l=o?o.name||o.nameOrDescription:`[Hidden ${s.upperFirst(R(a))}]`;return e.triggerEventDescription=function(e,t){const n=function(e){switch(e.replace("v2.events.","")){case"groups.membership.created":return"joins";case"groups.membership.destroyed":return"leaves";case"people.list_result.created":case"services.team_person.created":return"is added to";case"people.list_result.destroyed":case"services.team_person.destroyed":return"is removed from";case"people.form_submission.created":return"submits";case"registrations.attendee.created":return"is registered as a new attendee for";case"registrations.attendee.cancelled":return"is canceled as an attendee for";case"registrations.registration.created":return"is the registration contact on a new registration for";case"registrations.registration.cancelled":return"is the registration contact on a canceled registration for";default:return null}}(e.name),{resourceType:i}=N(e.triggerResource);if(!n){const e=s.truncate(t,{length:160,separator:" "});return`When the automation is triggered from ${R(i)} "${e}"`}return`When a person ${n} ${R(i)} "${t}"`}(e,l),e.canManage=!!o,e})}({automations:e,operationApps:t,triggerResources:n})).then(d).then(()=>l(!1))})},[e]);const u=!o&&0===c.length;return t.jsxs(t.Fragment,{children:[t.jsx(a.Box,{borderBottom:`1px solid ${i.token("--t-border-color-default-base")}`,marginBottom:i.token("--t-spacing-2"),marginHorizontal:-3,marginTop:n?12:0,paddingHorizontal:i.token("--t-spacing-3"),paddingVertical:i.token("--t-spacing-2"),children:t.jsx(a.Heading,{color:i.token("--t-text-color-default-headline"),level:2,size:i.token("--t-font-size-lg"),children:o?"Incoming automations":H(c.length,"incoming automation")})}),u?t.jsx(a.Text,{color:i.token("--t-text-color-default-secondary"),marginVertical:i.token("--t-spacing-3"),children:"Automations that perform actions on this resource will be listed here."}):o?t.jsx(a.Summary,{image:t.jsx(a.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading incoming automations..."}):t.jsx(a.TileView,{spacing:i.token("--t-spacing-3"),marginVertical:i.token("--t-spacing-3"),minCellWidth:45,children:c.map(e=>t.jsx(pe,{automation:e},e.id))})]})}function De(e){return`OPERATION_${e.definitionClass}${e.definitionIdentifier||""}`}function He(e){return`SECTION_${e}`}function Re(e){return e.map(({label:e,value:n})=>t.jsx(a.Select.Option,{value:n,children:e},n))}function Ne(e){const n=s.groupBy(e,"group");return Object.keys(n).sort().map(e=>"null"===e?Re(n[e]):t.jsx(a.Select.OptionGroup,{title:e,children:Re(n[e])},e))}const We=({selectedOperation:e,onOperationDefinitionChange:n,operationDefinitions:r})=>{const o=e?.section,l=r.map(e=>({...e,id:De(e)})),c=l.filter(e=>null===e.section),d=s.uniqBy(r,"section").filter(e=>!!e.section).map(e=>({group:e.sectionGroup,label:e.section,value:He(e.section)})),u=o?l.filter(e=>e.section===o):[];function p({selectedValue:e}){switch(function(e){if(e.startsWith("SECTION"))return"section";if(e.startsWith("OPERATION"))return"operation";if(e)throw new Error(`Unexpected value: ${e}`);return null}(e)){case"section":n(r.find(t=>He(t.section)===e));break;case"operation":n(r.find(t=>De(t)===e));break;case null:n(null)}}function h(e){return Ne(e.map(e=>({group:e.group,label:e.description,value:e.id})))}return t.jsxs(a.StackView,{spacing:i.token("--t-spacing-1"),children:[t.jsxs(a.Select,{emptyValue:"Select an action",id:"select-action",onChange:p,size:"lg","data-testid":"operation-select",children:[h(c),Ne(d)]}),u.length>0&&t.jsx(a.Select,{defaultValue:u[0].id,onChange:p,size:"lg",children:h(u)})]})},Ee=({canAccessPeople:e,field:n,onChange:o,value:l,selectedFieldOptions:c,loadListForField:d,loadedLists:u,loadingLists:p})=>{const h=function(e){const[t,n]=r.useState(e);return r.useEffect(()=>{const i=e();s.isEqual(i,t)||n(i)},[e,t]),t}(()=>function({field:e,selectedFieldOptions:t}){return(e.dependsOn||[]).reduce((e,n)=>(Object.prototype.hasOwnProperty.call(t,n)&&(e[s.camelCase(n)]=t[n]),e),{})}({field:n,selectedFieldOptions:c}));r.useEffect(()=>{n.listClass&&d({dependencies:h,field:n})},[n,h,d]);const m=n.list||u[A(n)]||[],g=m.filter(e=>!e.automationNotAllowed),w=n.listClass&&p[A(n)];return t.jsxs(a.StackView,{marginBottom:2,spacing:.5,children:[t.jsxs(a.Input.InputLabel,{color:i.token("--t-text-color-default-headline"),fontSize:i.token("--t-font-size-sm"),fontWeight:i.token("--t-font-weight-medium"),controls:n.id,children:[n.description,n.info&&t.jsx(a.HelperDrawer.Toggle,{drawerId:`${n.id}_help`,marginLeft:1})]}),t.jsx(a.Box,{children:w?t.jsx(et,{}):function(){switch(n.kind){case"Select":return t.jsx(Me,{fieldId:n.id,listOptions:g,onChange:o,value:l,description:n.description});case"SelectSearch":return t.jsx(qe,{fieldId:n.id,listOptions:g,onChange:o,value:l});case"Checkbox":return t.jsx(Ye,{field:n,value:l,onChange:o});case"TextArea":return t.jsx(Ze,{field:n,onChange:o,value:l});case"DateField":return t.jsx(Qe,{field:n,onChange:o,value:l});case"Checkboxes":return t.jsx(Ge,{fieldId:n.id,options:g,onChange:o});case"NumberField":return t.jsx(Je,{field:n,onChange:o,value:l});case"PersonSearch":return t.jsx(Ue,{canAccessPeople:e,field:n,onChange:o,listOptions:m,isLoading:p[A(n)],loadListForField:d,value:l});case"TextField":return t.jsx(Xe,{field:n,onChange:o,value:l});case"RadioButtons":return t.jsx(Ke,{field:n,options:m,onChange:o,value:l});case"StaticText":return t.jsx(a.Text,{dangerouslySetInnerHTML:{__html:n.content}});default:return console.warn(`Unknown field kind "${n.kind}"`),null}}()}),n.info&&t.jsx(a.HelperDrawer,{id:`${n.id}_help`,marginTop:i.token("--t-spacing-half"),children:t.jsx(a.Box,{dangerouslySetInnerHTML:{__html:n.info}})})]})},Me=({fieldId:e,listOptions:n,onChange:i,value:r,description:o})=>{const l=n?.find(e=>"no-option"===e.value),c=s.groupBy(n,"group"),d=Object.keys(c).sort(),u=()=>d.map(e=>"null"===e||"undefined"===e?p(c[e]):t.jsx(a.Select.OptionGroup,{title:e,children:p(c[e])},e)),p=e=>e.map(e=>t.jsx(a.Select.Option,{value:e.value.toString(),disabled:e.disabled,children:e.description},e.value));return t.jsx(a.Select,{id:e,onChange:({selectedValue:t})=>{i({fieldId:e,value:t})},disabled:u().length<1,emptyValue:0===u().length?"No options available":l?.description||(e=>{let t="Select ";return e?["a","e","i","o","u"].includes(e.charAt(0))?t+=`an ${e}`:t+=`a ${e}`:t+="a value",t})(o?.toLowerCase()),size:"lg",value:r||l?.value||null,placement:"bottom-start",children:u()})},qe=({fieldId:e,listOptions:n,onChange:o,value:l})=>{const c=n.find(e=>e.value?.toString()===l),d=c?.description||"",[u,p]=r.useState(""),[h,m]=r.useState(d),[g,w]=r.useState(!1),[f,x]=r.useState(!1);d!==u&&(p(d),m(d),w(!1));let v=s.sortBy(s.uniqBy(n,"value"),"group");if(g){const e=h.toLowerCase();v=v.filter(t=>`${t.description} ${t.group}`.toLowerCase().includes(e))}return t.jsx(a.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},css:{"[role='combobox']":{cursor:n.length>0?"pointer":"not-allowed"}},cursor:"pointer",disabled:0===n.length,onBlur:()=>{x(!1),m(d)},onChange:e=>{m(e.target.value),w(!0),x(!0)},onClear:f?()=>{m(""),w(!1)}:void 0,onFocus:e=>e.target.select(),onSelect:t=>{(t=>{o({fieldId:e,value:t})})(t.value),m(t.description),w(!1),x(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:n.length>0?"Select an option":"No options available",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:t.jsx(a.Icon,{name:"general.search",size:"md"}),renderRight:t.jsx(a.Icon,{name:"general.downCaret"}),size:"lg",value:h,children:n.length>0&&t.jsx(t.Fragment,{children:v.length>0?v.map((e,n)=>{const r=e.value.toString()===l;return t.jsxs(a.Combobox.Item,{"aria-label":e.description,disabled:e.disabled,index:n,paddingLeft:4.25,renderLeft:t.jsx(a.Icon,{marginLeft:-.5,name:r?"general.check":"",size:"sm"}),role:"option",spacing:i.token("--t-spacing-1"),value:{description:e.description,value:e.value.toString()},children:[t.jsx(a.Text,{truncate:!0,children:t.jsx(a.Highlight,{text:e.description,query:h})}),e.group&&t.jsx(a.Badge,{title:t.jsx(a.Highlight,{text:e.group,query:h}),size:"sm",marginLeft:"auto"})]},e.value)}):t.jsx(a.Menu.Item,{children:t.jsxs(a.Text,{children:['No results for "',h,'"']})})})})},Ue=({canAccessPeople:e,field:n,isLoading:o,listOptions:l,loadListForField:c,onChange:d,value:u})=>{const p=r.useCallback(e=>{c({dependencies:{query:e},field:n})},[c]),h=r.useMemo(()=>s.debounce(p,300),[p]),m=r.useCallback(t=>{e&&(t.trim().length>0?h(t):h.cancel())},[h]),g=r.useMemo(()=>({description:"Myself",value:"self"}),[]),w=r.useMemo(()=>e?l:[g],[g,l]).find(e=>e.value===u),f=w?.description||"",[x,v]=r.useState(f),[b,k]=r.useState(!1);function j(e){v(e),m(e),0===e.trim().length&&y(null)}const y=e=>{d({fieldId:n.id,value:e})};return t.jsx(a.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},cursor:"pointer",onBlur:()=>{k(!1),j(f)},onChange:e=>{j(e.target.value),k(!0)},onClear:b?()=>{j("")}:void 0,onFocus:e=>e.target.select(),onSelect:e=>{y(e.value),j(e.description),k(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:"Search",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:w&&w.meta?.avatar?t.jsx(a.Avatar,{size:"sm",source:w.meta.avatar}):t.jsx(a.Icon,{name:"general.search",size:"md"}),renderRight:t.jsx(a.Icon,{name:"general.downCaret"}),size:"lg",value:x,children:e?x.trim().length>0?l.length>0?l.map((e,n)=>t.jsx(a.Combobox.Item,{"aria-label":e.description,index:n,paddingLeft:4.25,renderLeft:t.jsx(a.Avatar,{marginLeft:-.5,source:e.meta.avatar,size:"sm"}),role:"option",spacing:i.token("--t-spacing-1"),value:e,children:t.jsx(a.Text,{truncate:!0,children:t.jsx(a.Highlight,{text:e.description,query:x})})},e.value)):t.jsx(a.Combobox.Item,o?{children:t.jsx(a.Text,{children:"Loading..."})}:{children:t.jsx(a.Text,{children:"No results"})}):t.jsx(a.Combobox.Item,{children:t.jsx(a.Text,{children:"Type to search"})}):t.jsx(a.Combobox.Item,{value:g,index:0,role:"option",children:t.jsx(a.Text,{children:g.description})})})},Ye=({field:e,value:n,onChange:i})=>t.jsx(a.Checkbox,{disabled:e.disabled,label:e.label,checked:n||!1,onChange:t=>{i({fieldId:e.id,value:t.target.checked})}}),Ze=({field:e,value:n,onChange:i})=>t.jsx(a.Box,{children:t.jsx(a.TextArea,{value:n,placeholder:e.placeholder,onChange:t=>{i({fieldId:e.id,value:t.target.value})},size:"lg"})}),Qe=({field:e,value:n,onChange:i})=>{const{dateFormat:o}=r.useContext(y),[s,l]=r.useState(!1),c=e.customValue||"Day automation runs",d="Day before automation runs",u=o.replace(/%m/,"M").replace(/%d/,"d").replace(/%Y/,"y").replace(/%y/,"yy"),[p,h]=r.useState(x.default(n).toDate()),m=e.allowUnansweredOption??!1;return t.jsxs(a.StackView,{axis:"horizontal",children:[t.jsxs(a.Select,{onChange:({selectedValue:t})=>{t===c||t===d?(l(!1),i({fieldId:e.id,value:t})):"specific-date"===t?(i({fieldId:e.id,value:null}),l(!0)):(l(!1),i({fieldId:e.id,value:null}))},size:"lg",placement:"bottom-start",children:[t.jsx(a.Select.Option,{value:c,children:c}),!e.customValue&&t.jsx(a.Select.Option,{value:d,children:d}),t.jsx(a.Select.Option,{value:"specific-date",children:"A specific date"}),m&&t.jsx(a.Select.Option,{value:"unanswered",children:"Unanswered"})]}),s&&t.jsx(a.Box,{children:t.jsx(a.DateField,{defaultOpen:!0,formatValue:u,marginLeft:1,onChange:t=>{i({fieldId:e.id,value:D(t,o)}),h(t)},size:"lg",value:p})})]})},Ge=({fieldId:e,options:n,onChange:i})=>{const[o,s]=r.useState({});return t.jsx(a.StackView,{spacing:1,children:n.map(n=>t.jsxs(a.Box,{children:[t.jsx(a.Input.InputLabel,{controls:`checkboxes_${e}_${n.value}`,children:n.description||n.value}),t.jsxs(a.Select,{id:`checkboxes_${e}_${n.value}`,onChange:({selectedValue:t})=>((t,n)=>{const a={...o};a[n]=t,s(a),i({fieldId:e,value:a})})(t,n.value),size:"lg",emptyValue:"Don't change",children:[t.jsx(a.Select.Option,{value:"check",children:"Check"}),t.jsx(a.Select.Option,{value:"uncheck",children:"Uncheck"})]})]},n.value))})},Je=({field:e,onChange:n,value:o})=>{const s=e.minValue>=0?e.minValue:1,l=e.maxValue>=1&&e.maxValue<=365?e.maxValue:365,[c,d]=r.useState(Number(e.defaultValue)||1);return r.useEffect(()=>{n({fieldId:e.id,value:e.defaultValue||1})},[e]),t.jsxs(a.StackView,{children:[t.jsx(a.Input.InputBox,{children:t.jsx(a.NumberField,{onChange:t=>{const i=Number(t)||0;d(i),n({fieldId:e.id,value:Math.min(Math.max(i,s),l)})},placeholder:e.placeholder,size:"lg",value:o,min:s,max:l,hasControls:!0})}),c>l&&t.jsx(a.Alert,{type:"error",paddingHorizontal:i.token("--t-spacing-1"),paddingVertical:i.token("--t-spacing-half"),display:"inline-block",marginTop:1.5,children:t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[t.jsx(a.Icon,{name:"general.exclamationTriangle",size:"sm",color:"delete45"}),t.jsxs(a.Text,{size:i.token("--t-font-size-md"),children:["Value cannot exceed ",l,"."]})]})})]})},Xe=({field:e,value:n,onChange:i})=>t.jsx(a.Box,{children:t.jsx(a.Input,{size:"lg",value:n,id:e.id,placeholder:e.placeholder,onChange:t=>{i({fieldId:e.id,value:t.target.value})}})}),Ke=({field:e,options:n,onChange:i,value:r})=>{const o=t=>{i({fieldId:e.id,value:t.target.value})};return t.jsx(a.StackView,{marginTop:1,spacing:.5,children:n.map(e=>t.jsx(a.Radio,{checked:r===e.value,label:e.description||e.value,onChange:o,size:"md",value:e.value},e.value))})},et=()=>t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:i.token("--t-spacing-1"),radius:i.token("--t-border-radius-md"),border:`1px solid ${i.token("--t-border-color-default-base")}`,children:[t.jsx(a.Spinner,{size:"xs"}),t.jsx(a.Text,{fontSize:i.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]}),tt=({canAccessPeople:e,definitionFields:n,onChange:i,selectedFieldOptions:a,loadListForField:o,loadedLists:s,loadingLists:l})=>{r.useEffect(()=>{const e=n.reduce((e,t)=>(Object.prototype.hasOwnProperty.call(t,"defaultValue")?e[t.id]=t.defaultValue:"DateField"===t.kind&&(e[t.id]=t.customValue||"Date automation runs"),e),{});i(e)},[n,i]);const c=L(n,a),d=({fieldId:e,value:t})=>{const r={...a},o=n.filter(e=>e.dependsOn);o.map(t=>{if(t.dependsOn.includes(e)){const e=o.find(e=>e.dependsOn.includes(t.id));e&&delete r[e.id],delete r[t.id],void 0!==t.defaultValue&&void 0===r[t.id]&&(r[t.id]=t.defaultValue)}}),"no-option"===t?delete r[e]:r[e]=t,i({...r})};return n.length?t.jsx("div",{children:c.map(n=>t.jsx(Ee,{canAccessPeople:e,field:n,onChange:d,value:a[n.id],selectedFieldOptions:a,loadListForField:o,loadedLists:s,loadingLists:l},n.id))}):null},nt=function(e){try{return Promise.resolve(ot.get({data:{fields:{OperationDefinition:"definition_class,definition_fields,definition_identifier,description,group,section,section_group,footer_message"},filter:"automation_allowed"},url:`/operation_apps/${e}/operation_definitions`}).then(({data:e})=>e))}catch(e){return Promise.reject(e)}},it=function(){try{return Promise.resolve(ot.get({data:{fields:{OperationApp:"name"}},url:"/operation_apps"}).then(({data:e})=>e.map(e=>e.name)))}catch(e){return Promise.reject(e)}},at=function(){try{return Promise.resolve(rt.get({data:{fields:{Topbar:"apps"}},url:"/me/topbar"}).then(({data:e})=>e.apps.map(e=>e.name)))}catch(e){return Promise.reject(e)}},rt=new n.Client({app:"people",env:window.railsEnv,version:"LATEST"}),ot=new n.Client({app:"webhooks",env:window.railsEnv,version:"LATEST"}),st={css:{borderRadius:i.token("--t-border-radius-md")},paddingHorizontal:1.75,paddingVertical:1.25,type:"error"},lt=({afterCreateOptions:e,blankStateLink:n,debugMode:o=!1,defaultApp:l,description:c,onRequestClose:d,trigger:u})=>{const[p,h]=r.useState(u.events[0]),[m,g]=r.useState({}),[w,f]=r.useState(l),[x,v]=r.useState([]),[b,k]=r.useState([]),[j,y]=r.useState(!0),[S,C]=r.useState(),[z,P]=r.useState({}),[T,O]=r.useState({}),[I,F]=r.useState({}),[L,B]=r.useState(!1),[D,H]=r.useState({}),[R,N]=r.useState(!1),[W,E]=r.useState({}),M=r.useRef(null),q=r.useMemo(()=>x.map(e=>e.id).includes("people"),[x]),U=S?.definitionIdentifier,Y="danger"===S?.footerMessage?.kind,Z=r.useCallback(({field:e,dependencies:t})=>{F(t=>({...t,[A(e)]:!0})),function({app:e,field:t,definitionIdentifier:n,dependencies:i}){try{return"PersonSearch"===t.kind?Promise.resolve(rt.get({data:{fields:{Person:"avatar,name"},where:{search_name_or_email:i.query,status:"active"}},url:"/people"})).then(function({data:e}){return e.map(e=>({description:e.name,meta:{avatar:e.avatar},value:e.id.toString()}))}):Promise.resolve(ot.get({data:{...i,definitionIdentifier:n,fields:{OperationDefinitionList:"values"}},url:`/operation_apps/${e}/operation_definition_lists/${t.listClass}`})).then(function({data:e}){return e.values})}catch(e){return Promise.reject(e)}}({app:w,definitionIdentifier:U,dependencies:t,field:e}).then(t=>{O(n=>({...n,[A(e)]:t})),F(t=>({...t,[A(e)]:!1}))}).catch(e=>H({selected_definition:e}))},[w,U]);r.useEffect(()=>{H({}),function(){try{return Promise.resolve(Promise.all([at(),it()])).then(function([e,t]){return e.filter(e=>t.includes(e)).sort().map(e=>({id:e.toLowerCase(),name:e}))})}catch(e){return Promise.reject(e)}}().then(e=>{v(e);const t=e.find(e=>e.id===l)?l:e[0].id;f(t),nt(t).then(e=>{M.current||(k(e),y(!1))}).catch(e=>H({definitions:e}))})},[l]),r.useEffect(()=>{H({})},[z]);const Q=s.cloneDeep("conditions"in p?p.conditions:u.conditions);for(const e in m)s.set(Q,e,m[e]);const G="dynamicConditions"in p?p.dynamicConditions:u.dynamicConditions;function J(){const e=function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return{description:$({loadedLists:n||{},selectedDefinition:e,selectedFieldOptions:t}),name:(i=e,V(i)||i.description)};var i}({loadedLists:T,selectedDefinition:S,selectedFieldOptions:z});let t=e.name;return e.description&&(t+=` (${e.description})`),t}function X(t){B(!0),ot.post({data:t,url:"/me/automation_subscriptions"}).then(()=>{e?.onConfirm&&R?(d(),e.onConfirm({...t})):window.location.reload()}).catch(e=>{B(!1),e.errors?H({automation:e.errors}):alert("something even worse happened!")})}return t.jsxs(a.StackView,{paddingTop:4,spacing:2,children:[c&&t.jsx(a.Box,{children:t.jsxs(a.Text,{style:{color:i.token("--t-text-color-default-primary"),fontSize:i.token("--t-font-size-md"),lineHeight:1.65,marginBottom:i.token("--t-spacing-2")},children:[c," ",t.jsx(a.Link,{external:!0,to:n,children:"Learn more"})]})}),D.automation&&t.jsx(a.Alert,{...st,children:t.jsx(a.Text,{children:"There was an error creating your automation. Please change your selections and try again or contact support if the problem persists."})}),t.jsxs(a.StackView,{spacing:1,children:[t.jsx(a.Input.InputLabel,{color:i.token("--t-text-color-default-primary"),controls:"select-trigger-event",fontSize:i.token("--t-font-size-md"),fontWeight:i.token("--t-font-weight-medium"),children:"When a person..."}),t.jsx(a.Select,{id:"select-trigger-event",onChange:({selectedValue:e})=>(e=>{h(e),g({})})(e),size:"lg",value:p,children:u.events.map((e,n)=>t.jsx(a.Select.Option,{value:e,children:e.description},`${e.name}_${n}`))}),G?.length>0&&t.jsx(tt,{canAccessPeople:q,definitionFields:G,selectedFieldOptions:m,onChange:g,loadedLists:{},loadingLists:{},loadListForField:()=>null})]}),t.jsxs(a.StackView,{spacing:1,children:[x.length>0?t.jsx(ht,{selectedApp:w,operationApps:x,onOperationAppChange:e=>{f(e),y(!0),k([]),M.current=e,C(null),P({}),H({}),nt(e).then(k).then(()=>y(!1)).catch(e=>H({definitions:e}))}}):t.jsxs(a.StackView,{spacing:1,children:[t.jsx(a.Text,{color:i.token("--t-text-color-default-headline"),fontSize:i.token("--t-font-size-md"),fontWeight:i.token("--t-font-weight-medium"),children:"Then perform an action in..."}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:i.token("--t-spacing-1"),radius:4,border:`1px solid ${i.token("--t-border-color-default-base")}`,children:[t.jsx(a.Spinner,{size:"xs"}),t.jsx(a.Text,{fontSize:i.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]})]}),D.definitions?t.jsx(a.Alert,{marginTop:i.token("--t-spacing-1"),...st,children:t.jsx(a.Text,{children:"There was a problem looking up automations. Please contact support if the problem persists."})}):j?t.jsx(mt,{}):t.jsx(We,{selectedOperation:S,operationDefinitions:b,onOperationDefinitionChange:e=>{C(e),H({}),P({})}})]}),S&&(D.selected_definition?t.jsx(a.Alert,{...st,children:t.jsx(a.Text,{children:"There was a problem looking up automation options. Please contact support if the problem persists."})}):t.jsxs(t.Fragment,{children:[t.jsx(tt,{canAccessPeople:q,definitionFields:S.definitionFields||[],onChange:P,selectedFieldOptions:z,loadedLists:T,loadListForField:Z,loadingLists:I}),e?.label&&t.jsx(a.Checkbox,{disabled:L||ct(S,z),label:e.label,checked:R,onChange:()=>N(!R)}),p?.triggerParams?.map((e,n)=>t.jsx(a.Checkbox,{label:e.description,checked:W&&W[e.key]||e.defaultValue,onChange:t=>{E(n=>({...n,[`${e.key}`]:t.target.checked}))}},`${e.key}_${n}`)),Y&&t.jsx(a.Alert,{...st,children:t.jsxs(a.StackView,{axis:"horizontal",spacing:1.5,children:[t.jsx(a.Icon,{size:i.token("--t-element-size-lg"),name:"general.exclamationTriangle",color:i.token("--t-icon-color-status-error-primary")}),t.jsx(a.Text,{dangerouslySetInnerHTML:{__html:S.footerMessage?.html}})]})})]})),o&&t.jsx("pre",{children:JSON.stringify({description:S&&J(),loadedLists:T,selectedDefinition:S,selectedFieldOptions:z,triggerConditions:Q},null,4)}),t.jsxs(a.StackView,{alignment:"center",axis:"horizontal",borderTop:`1px solid ${i.token("--t-border-color-default-base")}`,distribution:"end",marginTop:2,marginHorizontal:-4,paddingHorizontal:4,paddingTop:3,spacing:2,children:[t.jsx(a.Button,{color:i.token("--t-text-color-default-headline"),"data-modal-close":!0,fontWeight:i.token("--t-font-weight-normal"),onClick:d,size:"md",title:"Cancel",variant:"naked"}),t.jsx(a.Button,{disabled:L||Y||ct(S,z),onClick:function(){if(L)return;const t={...z};S.definitionIdentifier&&(t.definition_identifier=S.definitionIdentifier);const n={_e:u.resource,data:{attributes:{description:J(),name:p.name,operation_app_name:w,operation_definition_class_name:S.definitionClass,operation_params:t,trigger_conditions:Q,trigger_params:W},type:"AutomationSubscription"}};R?_.fire({cancelButtonText:"Cancel",confirmButtonText:"Yes, perform action",text:"This will happen immediately after creating your new automation. Are you sure?",title:`${e.label}?`}).then(e=>{e.value?X(n):(B(!1),N(!1))}):X(n)},size:"md",theme:"primary",title:pt(S,z),variant:"fill","data-testid":"create-automation"})]})]})};function ct(e,t){if(e){const n=L(e.definitionFields,t),i=n.filter(e=>e.required),a=n.filter(e=>dt(e));return!i.every(e=>ut(e,t))||!a.every(e=>ut(e,t))}return!0}function dt(e){return"Select"===e.kind||"SelectSearch"===e.kind}function ut(e,t){return dt(e)?t.hasOwnProperty(e.id):t.hasOwnProperty(e.id)&&t[e.id]&&""!==t[e.id].toString().trim()}function pt(e,t){const n=function(e,t){if(!e?.definitionFields)return;const n=L(e.definitionFields,t);for(const e of n)if(e.required&&!ut(e,t))return e.description}(e,t);return e?n?`Select a${n.charAt(0).match(/[aeiou]/i)?"n":""} ${n.toLowerCase()}`:"Create automation":"Select an action"}const ht=({onOperationAppChange:e,operationApps:n,selectedApp:r})=>t.jsxs(a.StackView,{spacing:1,children:[t.jsx(a.Input.InputLabel,{color:i.token("--t-text-color-default-headline"),controls:"select-product",fontSize:i.token("--t-font-size-md"),fontWeight:i.token("--t-font-weight-medium"),children:"Then perform an action in..."}),t.jsx(a.Select,{autoFocus:!0,id:"select-product",onChange:({selectedValue:t})=>{e(t)},size:"lg",value:r,children:n.map(e=>t.jsx(a.Select.Option,{value:e.id,children:e.name},e.id))})]}),mt=()=>t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:i.token("--t-spacing-1"),radius:i.token("--t-border-radius-md"),border:`1px solid ${i.token("--t-border-color-default-base")}`,children:[t.jsx(a.Spinner,{size:"xs"}),t.jsx(a.Text,{fontSize:i.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]});function gt({onClick:e}){return t.jsx(a.Button,{as:"button",height:i.token("--t-element-size-md"),icon:{color:i.token("--t-icon-color-default-dim"),name:"general.x"},onClick:e,size:"sm",title:"Close",variant:"naked"})}function wt({children:e,onRequestClose:n,open:r,theme:o}){/*#__PURE__*/return u.createPortal(t.jsxs(a.ThemeProvider,{theme:o,children:[t.jsxs(a.Modal,{open:r,onRequestClose:n,maxWidth:75,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:i.token("--t-spacing-4"),paddingBottom:i.token("--t-spacing-3"),radius:i.token("--t-border-radius-lg"),zIndex:10009,children:[t.jsxs(a.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[t.jsx(a.Heading,{level:2,color:i.token("--t-text-color-default-headline"),fontWeight:i.token("--t-font-weight-medium"),fontSize:i.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Create automation"}),t.jsx(gt,{onClick:n})]}),e]}),t.jsx("style",{children:"\n .swal2-container.swal2-backdrop-show { z-index: 10001 }\n "})]}),document.body)}const ft={churchCenter:b,services:k},xt=new n.Client({app:"webhooks",version:"2022-10-20"});function vt({afterCreateOptions:e,automations:n,blankStateLink:o,canCreate:s,defaultApp:l,description:c,hasActiveAutomations:d,loading:u,onPauseAutomations:p,theme:h,trigger:m}){const[g,w]=r.useState(!1),f=s&&!d,x=n.filter(e=>e.active).length,v=n.filter(e=>!e.active).length;return t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",backgroundColor:f?i.token("--t-fill-color-status-warning-ghost"):void 0,borderBottom:f?void 0:`1px solid ${i.token("--t-border-color-default-base")}`,"data-testid":"automations-header",distribution:"space-between",marginHorizontal:-3,marginBottom:i.token("--t-spacing-2"),marginTop:-3,paddingHorizontal:i.token("--t-spacing-3"),paddingVertical:i.token("--t-spacing-2"),spacing:i.token("--t-spacing-2"),wrap:!0,zIndex:2,children:[s&&!d?t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",marginHorizontal:1,spacing:1,children:[t.jsx(a.Icon,{size:2,color:i.token("--t-icon-color-status-warning-primary"),name:"general.exclamationTriangle"}),t.jsx(a.Heading,{color:i.token("--t-text-color-default-headline"),level:2,size:i.token("--t-font-size-lg"),children:"Automations are currently paused"})]}):t.jsxs(a.Heading,{color:i.token("--t-text-color-default-headline"),level:2,size:i.token("--t-font-size-lg"),children:[u?"Active automations":H(x,"active automation"),v>0?` (${v} paused)`:""]}),s&&(d?t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),children:[n.length>0&&t.jsx(a.Button,{onClick:p,variant:"outline",children:"Pause automations"}),t.jsx(a.Button,{theme:"primary",variant:"fill",onClick:()=>w(!0),children:"Create automation"}),t.jsx(wt,{open:g,onRequestClose:()=>w(!1),theme:h,children:t.jsx(lt,{description:c,blankStateLink:o,defaultApp:l,trigger:m,onRequestClose:()=>w(!1),afterCreateOptions:e})})]}):t.jsx(a.Box,{children:t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[t.jsx(a.Button,{onClick:p,theme:"primary",variant:"outline",children:"Enable automations"}),t.jsx(a.Button,{theme:"primary",disabled:!0,tooltip:{title:"Automations must be enabled to create new ones"},children:"Create automation"})]})}))]})}e.Automations=function({afterCreateOptions:e,blankStateDescription:n,blankStateLink:o="https://pcopeople.zendesk.com/hc/en-us/articles/217582148-Automations",currentPersonId:s,currentPersonCanCreate:l,defaultApp:c,incomingAutomationsParam:d,theme:u,trigger:p,currentOrganization:h,permissionDeniedReason:m="You need permissions of Editor or above to add an automation.",disabled:g=!1,disabledReason:w="Not allowed"}){r.useEffect(()=>{if(!p)return k(!1);(function(e){try{return Promise.resolve(_e.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,events_status,trigger_params",Person:"name"},include:"created_by"},url:"automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}})(p.resource).then(ze).then(Te).then(P).then(v).then(()=>k(!1))},[p?.resource]);const[x,v]=r.useState([]),[b,k]=r.useState(!0),[C,z]=r.useState(!1),{dateFormat:_,twentyFourHourTime:T,olsonTimeZone:O}=h,A=new URLSearchParams(window.location.search).get("automation_id"),V={...u,icons:{...ft}};r.useEffect(()=>{document.body.toggleAttribute("data-loading-automations",b)},[b]);const I=!x.length||x.some(e=>e.active);function F(e){xt.delete({data:{_e:p.resource},url:`/automation_subscriptions/${e}`}).then(()=>v(x.filter(t=>t.id!==e))).catch(e=>{const t=W(e,"delete")||"There was a problem deleting this automation. Please try again in a few moments.";S.fire({text:t,title:"Uh oh!"})})}const L={color:i.token("--t-text-color-default-primary"),level:2,size:i.token("--t-font-size-2xl"),weight:i.token("--t-font-weight-bold")},$={color:i.token("--t-text-color-default-secondary"),lineHeight:3,size:i.token("--t-font-size-md")};return t.jsxs(a.ThemeProvider,{theme:V,children:[t.jsxs(y.Provider,{value:{dateFormat:_,olsonTimeZone:O,twentyFourHourTime:T},children:[p&&t.jsx(vt,{automations:x,blankStateLink:o,canCreate:l&&!g,loading:b,defaultApp:c,description:n,theme:V,trigger:p,hasActiveAutomations:I,onPauseAutomations:function(){xt.post({data:{data:{attributes:{_e:p.resource,active:!I}}},url:"/pause_automations"}).then(()=>{window.location.reload()})},afterCreateOptions:e}),b?t.jsx(a.Summary,{image:t.jsx(a.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading automations..."}):p?t.jsx(a.Box,{"data-testid":"automations-section",children:x?.length>0?t.jsx(a.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:f.default(x,"id").map(e=>{return t.jsx(ue,{automation:e,updateAutomation:(i=e,e=>{const t="function"==typeof e?e(i):e,n=[...x.filter(e=>e.id!==t.id),t];v(n)}),onDelete:F,theme:V,openHistoryNow:e.id===Number(A),trigger:{event:(n=e,p.events.find(e=>e.name===n.name)),resource:p.resource},currentPersonId:s,currentPersonCanCreate:l,disabled:g,disabledReason:w},e.id);var n,i})}):t.jsxs(a.StackView,{margin:i.token("--t-spacing-6"),spacing:i.token("--t-spacing-2"),alignment:"center",mediaQueries:{lg:{axis:"horizontal",distribution:"center",spacing:i.token("--t-spacing-6")}},children:[t.jsx(a.Box,{css:{".symbol":{height:"100%",width:"100%"}},maxWidth:24,mediaQueries:{lg:{maxWidth:40}},children:t.jsx(j,{})}),t.jsx(a.StackView,{alignment:"center",spacing:i.token("--t-spacing-1"),maxWidth:45,mediaQueries:{lg:{alignment:"start",textAlign:"left"}},textAlign:"center",children:t.jsxs(t.Fragment,l?{children:[t.jsx(a.Heading,{...L,children:"Add an automation"}),t.jsx(a.StackView,{alignment:"center",marginBottom:i.token("--t-spacing-1"),mediaQueries:{lg:{alignment:"start"}},spacing:1,children:t.jsx(a.Text,{...$,children:n})}),t.jsxs(a.StackView,{axis:"horizontal",spacing:i.token("--t-spacing-1"),children:[t.jsx(a.Button,{variant:"outline",to:o,color:`${i.token("--t-text-color-status-neutral")} !important`,children:"Learn more"}),t.jsx(a.Button,{as:"button",theme:"primary",variant:"fill",onClick:()=>z(!0),children:"Create automation"})]}),t.jsx(wt,{open:C,onRequestClose:()=>z(!1),theme:V,children:t.jsx(lt,{defaultApp:c,description:n,blankStateLink:o,onRequestClose:()=>z(!1),trigger:p,afterCreateOptions:e})})]}:{children:[t.jsx(a.Heading,{...L,children:"Automations"}),t.jsx(a.Text,{...$,children:m})]})})]})}):t.jsx(t.Fragment,{}),d&&t.jsx(Be,{encryptedParam:d,trigger:p})]}),t.jsx("style",{children:'.swal2-popup{box-shadow:0 0 20px 0 rgba(0,0,0,.15)}.swal2-container .tds-btn{opacity:1}div:where(.swal2-container) div:where(.swal2-actions){border-top:var(--t-border-width-default) solid var(--t-border-color-default-base);gap:var(--t-spacing-1)}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto!important}body.swal2-no-backdrop .swal2-container{background-color:transparent!important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--t-fill-color-transparency-dark-static-040)}body.swal2-toast-shown .swal2-container{background-color:transparent;box-sizing:border-box;max-width:100%;pointer-events:none;width:360px}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-left,body.swal2-toast-shown .swal2-container.swal2-top-start{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-left,body.swal2-toast-shown .swal2-container.swal2-center-start{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%,-50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-left,body.swal2-toast-shown .swal2-container.swal2-bottom-start{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static!important}}div:where(.swal2-container){-webkit-overflow-scrolling:touch;box-sizing:border-box;display:grid;grid-template-areas:"top-start top top-end" "center-start center center-end" "bottom-start bottom-center bottom-end";grid-template-rows:minmax(min-content,auto) minmax(min-content,auto) minmax(min-content,auto);height:100%;inset:0;overflow-x:hidden;padding:var(--t-spacing-2);position:fixed;transition:background-color .1s;z-index:1060}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--t-fill-color-transparency-dark-static-040)}div:where(.swal2-container).swal2-backdrop-hide{background:transparent!important}div:where(.swal2-container).swal2-bottom-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-top-start{grid-template-columns:minmax(0,1fr) auto auto}div:where(.swal2-container).swal2-bottom,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-top{grid-template-columns:auto minmax(0,1fr) auto}div:where(.swal2-container).swal2-bottom-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-top-end{grid-template-columns:auto auto minmax(0,1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-left>.swal2-popup,div:where(.swal2-container).swal2-center-start>.swal2-popup{align-self:center;grid-row:2}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-left>.swal2-popup,div:where(.swal2-container).swal2-bottom-start>.swal2-popup{align-self:end;grid-column:1;grid-row:3}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup,div:where(.swal2-container).swal2-grow-row>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{align-self:stretch;grid-row:1/4}div:where(.swal2-container).swal2-no-transition{transition:none!important}div:where(.swal2-container) div:where(.swal2-popup){background:var(--t-surface-color-card);border:var(--swal2-border);border-radius:var(--t-border-radius-lg);box-sizing:border-box;color:var(--t-text-color-default-primary);display:none;font-family:inherit;font-size:var(--t-font-size-md);grid-template-columns:minmax(0,100%);max-width:100%;padding:0 0 var(--t-spacing-3);position:relative;width:600px}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){word-wrap:break-word;color:var(--t-text-color-default-headline);cursor:auto;font-size:var(--t-font-size-2xl);font-weight:600;margin:0;max-width:100%;padding:var(--t-spacing-1) var(--t-spacing-4) 0;position:relative;text-align:center;text-transform:none}div:where(.swal2-container) div:where(.swal2-actions){align-items:center;box-sizing:border-box;display:flex;flex-wrap:wrap;justify-content:center;margin:var(--t-spacing-4) auto 0;padding:var(--t-spacing-3) var(--t-spacing-1) 0;width:100%;z-index:1}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(transparent,transparent)}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(transparent,transparent)}div:where(.swal2-container) div:where(.swal2-loader){align-items:center;animation:none;border:0 solid transparent;border-radius:0;display:none;height:auto;justify-content:center;margin:0;width:auto}div:where(.swal2-container) button:where(.swal2-styled){box-shadow:0 0 0 3px transparent;font-weight:var(--t-font-weight-normal);margin:0;padding:var(--t-spacing-1);transition:box-shadow .1s}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){background:initial;background-color:var(--t-fill-color-button-interaction-solid-default);border:0;border-radius:var(--t-border-radius-default);color:var(--t-text-color-default-inverted);font-size:var(--t-font-size-md)}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):focus-visible{box-shadow:none}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){background:initial;background-color:var(--t-fill-color-button-delete-solid-default);border:0;border-radius:var(--t-border-radius-default);color:var(--t-text-color-default-inverted);font-size:var(--t-font-size-md)}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):focus-visible{box-shadow:none}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){background:initial;background-color:transparent;border:0;border-radius:var(--t-border-radius-default);color:var(--t-text-color-status-neutral);font-size:var(--t-font-size-md)}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):focus-visible{box-shadow:none}div:where(.swal2-container) button:where(.swal2-styled).swal2-default-outline:focus-visible{box-shadow:0 0 0 3px rgba(100,150,200,.5)}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){border-top:1px solid var(--t-border-color-default-base);color:inherit;cursor:auto;font-size:1em;margin:1em 0 0;padding:1em 1em 0;text-align:center}div:where(.swal2-container) .swal2-timer-progress-bar-container{border-bottom-left-radius:var(--t-border-radius-lg);border-bottom-right-radius:var(--t-border-radius-lg);bottom:0;grid-column:auto!important;left:0;overflow:hidden;position:absolute;right:0}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){background:rgba(var(--t-fill-color-neutral-000),.2);height:.25em;width:100%}div:where(.swal2-container) img:where(.swal2-image){cursor:auto;margin:var(--t-spacing-4) auto var(--t-spacing-2);max-width:100%}div:where(.swal2-container) button:where(.swal2-close){align-items:center;background:transparent;border:none;border-radius:var(--t-border-radius-lg);color:var(--t-icon-color-default-dim);cursor:pointer;font-family:monospace;font-size:2.5em;height:1.2em;justify-content:center;justify-self:end;margin-bottom:-1.2em;margin-right:0;margin-top:0;overflow:hidden;padding:0;transition:color .1s,box-shadow .1s;width:1.2em;z-index:2}div:where(.swal2-container) button:where(.swal2-close):hover{background:transparent;color:var(--t-icon-color-status-error-primary);transform:none}div:where(.swal2-container) button:where(.swal2-close):focus-visible{box-shadow:inset 0 0 0 3px rgba(100,150,200,.5);outline:none}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){word-wrap:break-word;color:inherit;cursor:auto;font-size:var(--t-font-size-md);font-weight:var(--t-font-weight-normal);justify-content:center;line-height:1.4;margin:0;overflow:auto;padding:var(--t-spacing-2) var(--t-spacing-4) 0;text-align:center;word-break:break-word;z-index:1}div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) label:where(.swal2-checkbox),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) textarea:where(.swal2-textarea){margin:var(--t-spacing-2) var(--t-spacing-4) 0!important}div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) textarea:where(.swal2-textarea){background:var(--swal2-input-background);border:var(--t-border-width-default) solid var(--t-border-color-default-base);border-radius:var(--t-border-radius-default);box-shadow:none;box-sizing:border-box;color:inherit;font-size:var(--t-font-size-md);transition:border-color .1s,box-shadow .1s;width:auto!important}div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:var(--t-icon-color-status-error-primary)!important;box-shadow:0 0 2px var(--t-icon-color-status-error-primary)!important}div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--t-border-width-default) solid var(--t-border-color-control-info);box-shadow:inset 0 1px 1px rgba(var(--t-fill-color-neutral-000),.06),0 0 0 3px rgba(100,150,200,.5);outline:none}div:where(.swal2-container) input:where(.swal2-file)::-moz-placeholder,div:where(.swal2-container) input:where(.swal2-input)::-moz-placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::-moz-placeholder{color:var(--t-text-color-default-placeholder)}div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:var(--t-text-color-default-placeholder)}div:where(.swal2-container) .swal2-range{background:var(--t-surface-color-card);margin:var(--t-spacing-2) var(--t-spacing-4) 0!important}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{color:inherit;font-weight:600;text-align:center;width:20%}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{font-size:var(--t-font-size-md);height:40px;line-height:40px;padding:0}div:where(.swal2-container) .swal2-input{height:40px;padding:0 var(--t-spacing-1)}div:where(.swal2-container) .swal2-file{background:var(--swal2-input-background);font-size:var(--t-font-size-md);margin-left:auto;margin-right:auto;width:75%}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{background:var(--swal2-input-background);color:inherit;font-size:var(--t-font-size-md);max-width:100%;min-width:50%;padding:.375em .625em}div:where(.swal2-container) .swal2-checkbox,div:where(.swal2-container) .swal2-radio{align-items:center;background:var(--t-surface-color-card);color:inherit;justify-content:center}div:where(.swal2-container) .swal2-checkbox label,div:where(.swal2-container) .swal2-radio label{font-size:var(--t-font-size-md);margin:0 .6em}div:where(.swal2-container) .swal2-checkbox input,div:where(.swal2-container) .swal2-radio input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;background:var(--t-fill-color-status-neutral-ghost);color:var(--t-text-color-default-primary);font-size:1em;font-weight:300;justify-content:center;margin:1em 0 0;overflow:hidden;padding:.625em}div:where(.swal2-container) div:where(.swal2-validation-message):before{background-color:var(--t-icon-color-status-error-primary);border-radius:50%;color:var(--t-fill-color-neutral-100);content:"!";display:inline-block;font-weight:600;height:1.5em;line-height:1.5em;margin:0 .625em;min-width:1.5em;text-align:center;width:1.5em}div:where(.swal2-container) .swal2-progress-steps{align-items:center;background:transparent;flex-wrap:wrap;font-weight:600;margin:1.25em auto;max-width:100%;padding:0}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{background:var(--t-fill-color-status-info-solid);border-radius:2em;color:var(--t-fill-color-neutral-100);flex-shrink:0;height:2em;line-height:2em;text-align:center;width:2em;z-index:20}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:var(--t-fill-color-status-info-solid)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--t-fill-color-status-info-ghost);color:var(--t-fill-color-neutral-100)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--t-fill-color-status-info-ghost)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{background:var(--t-fill-color-status-info-solid);flex-shrink:0;height:.4em;margin:0 -1px;width:2.5em;z-index:10}div:where(.swal2-icon){border:0 solid transparent;border-color:var(--t-icon-color-default-primary);border-radius:50%;box-sizing:content-box;cursor:default;font-family:inherit;height:var(--t-element-size-3xl);justify-content:center;line-height:var(--t-element-size-3xl);margin:2.5em auto .6em;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--t-element-size-3xl)}div:where(.swal2-icon) .swal2-icon-content{align-items:center;display:flex;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:var(--t-icon-color-status-error-primary);color:var(--t-icon-color-status-error-primary)}div:where(.swal2-icon).swal2-error .swal2-x-mark{flex-grow:1;position:relative}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{background-color:var(--t-icon-color-status-error-primary);border-radius:.125em;display:block;height:.3125em;position:absolute;top:2.3125em;width:2.9375em}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-warning{border-color:var(--t-icon-color-status-warning-primary);color:var(--t-icon-color-status-warning-primary)}div:where(.swal2-icon).swal2-info{border-color:var(--t-icon-color-status-info-primary);color:var(--t-icon-color-status-info-primary)}div:where(.swal2-icon).swal2-question{border-color:var(--t-icon-color-status-info-primary);color:var(--t-icon-color-status-info-primary)}div:where(.swal2-icon).swal2-success{border-color:var(--t-icon-color-status-success-primary);color:var(--t-icon-color-status-success-primary)}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{border-radius:50%;height:7.5em;position:absolute;width:3.75em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{border-radius:7.5em 0 0 7.5em;left:-2.0635em;top:-.4375em;transform:rotate(-45deg);transform-origin:3.75em 3.75em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{border-radius:0 7.5em 7.5em 0;left:1.875em;top:-.6875em;transform:rotate(-45deg);transform-origin:0 3.75em}div:where(.swal2-icon).swal2-success .swal2-success-ring{border:.25em solid var(--t-icon-color-status-success-secondary);border-radius:50%;box-sizing:content-box;height:100%;left:-.25em;position:absolute;top:-.25em;width:100%;z-index:2}div:where(.swal2-icon).swal2-success .swal2-success-fix{height:5.625em;left:1.625em;position:absolute;top:.5em;transform:rotate(-45deg);width:.4375em;z-index:1}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{background-color:var(--t-icon-color-status-success-primary);border-radius:.125em;display:block;height:.3125em;position:absolute;z-index:2}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{left:.8125em;top:2.875em;transform:rotate(45deg);width:1.5625em}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{right:.5em;top:2.375em;transform:rotate(-45deg);width:2.9375em}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-hide,.swal2-show{animation:none}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{height:50px;overflow:scroll;position:absolute;top:-9999px;width:50px}.svg-background-blob{fill:var(--t-fill-color-status-info-ghost)}:root[data-color-mode=dark] .svg-background-blob{fill:var(--t-fill-color-status-neutral-ghost)}@media (prefers-color-scheme:dark){:root[data-color-mode=system] .svg-bg-blob{fill:var(--t-fill-color-status-neutral-ghost)}}'})]})}});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@planningcenter/api-client"),require("@planningcenter/tapestry"),require("@planningcenter/tapestry-react"),require("react"),require("lodash/sortBy"),require("lodash"),require("moment"),require("@planningcenter/sweetalert2"),require("sweetalert2/dist/sweetalert2"),require("react-dom"),require("@planningcenter/icons/paths/church-center"),require("@planningcenter/icons/paths/logomark"),require("@planningcenter/icons/paths/services")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@planningcenter/api-client","@planningcenter/tapestry","@planningcenter/tapestry-react","react","lodash/sortBy","lodash","moment","@planningcenter/sweetalert2","sweetalert2/dist/sweetalert2","react-dom","@planningcenter/icons/paths/church-center","@planningcenter/icons/paths/logomark","@planningcenter/icons/paths/services"],t):t((e||self).coreAutomations={},e.jsxRuntime,e.apiClient,e.tapestry,e.tapestryReact,e.react,e.sortBy,e.lodash,e.moment,e.sweetalert2,e.Swal,e.reactDom,e.churchCenter,e.logomark,e.services)}(this,function(e,t,n,i,a,r,o,s,l,c,d,u,p,h,m){function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function w(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t}var f=/*#__PURE__*/g(r),x=/*#__PURE__*/g(o),v=/*#__PURE__*/g(l),b=/*#__PURE__*/g(d),k=/*#__PURE__*/w(p),j=/*#__PURE__*/w(h),y=/*#__PURE__*/w(m);const S=()=>t.jsxs("svg",{id:"automations_blank","data-name":"Automations Blank",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 111.112 84.832",className:"symbol",children:[t.jsx("title",{children:"Automations"}),t.jsx("g",{opacity:"0.6",children:t.jsx("path",{d:"M107.784,46.051A57.416,57.416,0,0,1,85.26,75.058c-9.7,6.247-20.045,7.792-31.912,5.185-11.74-2.638-23.339-8-32.92-13.088-9.51-5.342-17-10.236-18.863-17.925C-.26,41.753,3.737,31.4,13.347,21.194,22.85,11.162,37.968,1.853,55.948.321,73.8-1.476,90.2,4.478,99.608,13.164,109.257,21.9,111.921,33.784,107.784,46.051Z",fill:"#e1f0f9",className:"svg-background-blob"})}),t.jsx("path",{d:"M81,27.269v31.8a2.685,2.685,0,0,1-2.685,2.685H44.564a2.685,2.685,0,0,1-2.685-2.685V15.425a2.685,2.685,0,0,1,2.685-2.685h21.91a2.681,2.681,0,0,1,1.9.786L80.217,25.371A2.685,2.685,0,0,1,81,27.269Z",fill:"#fff"}),t.jsx("path",{d:"M68.479,13.633v9.8a2.035,2.035,0,0,0,2.035,2.034h9.877Z",fill:"#c9d8e2"}),t.jsx("rect",{x:"51.214",y:"41.285",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),t.jsx("rect",{x:"51.214",y:"48.434",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),t.jsx("rect",{x:"51.214",y:"34.136",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),t.jsx("rect",{x:"11.771",y:"44.005",width:"50.915",height:"6.664",transform:"translate(-22.93 44.557) rotate(-49.171)",fill:"#454942"}),t.jsx("path",{d:"M56.283,30.38l-7.557,8.745a5.968,5.968,0,0,0-2.005-2.734,6.292,6.292,0,0,0-3.036-1.624l7.555-8.743a6.275,6.275,0,0,1,3.038,1.624A5.959,5.959,0,0,1,56.283,30.38Z",fill:"#fcc846"}),t.jsx("path",{d:"M58.088,28.29l-7.556,8.745a5.968,5.968,0,0,0-2-2.734,6.3,6.3,0,0,0-3.036-1.624l7.555-8.743a6.274,6.274,0,0,1,3.037,1.624A5.959,5.959,0,0,1,58.088,28.29Z",fill:"#48a5e5"}),t.jsx("path",{d:"M58.724,10.432l1.17,2.7a2.129,2.129,0,0,0,1.4,1.207l2.843.765a.73.73,0,0,1,.1,1.375l-2.7,1.17a2.125,2.125,0,0,0-1.207,1.4L59.56,21.89a.73.73,0,0,1-1.374.1l-1.17-2.7a2.125,2.125,0,0,0-1.4-1.206l-2.843-.766a.73.73,0,0,1-.1-1.374l2.7-1.17a2.121,2.121,0,0,0,1.206-1.4l.766-2.844A.73.73,0,0,1,58.724,10.432Z",fill:"#fcc846"}),t.jsx("path",{d:"M44.544,19.294l1.024.868a.968.968,0,0,0,.814.21l1.316-.261a.333.333,0,0,1,.319.541l-.868,1.024a.968.968,0,0,0-.21.814l.261,1.316a.333.333,0,0,1-.541.319l-1.024-.868a.968.968,0,0,0-.814-.21l-1.316.261a.333.333,0,0,1-.319-.541l.868-1.024a.967.967,0,0,0,.21-.814L44,19.613A.333.333,0,0,1,44.544,19.294Z",fill:"#fcc846"}),t.jsx("path",{d:"M64.223,25.729l.869,2.005a1.575,1.575,0,0,0,1.036.895l2.109.568a.542.542,0,0,1,.075,1.02l-2,.868a1.576,1.576,0,0,0-.9,1.036l-.568,2.11a.541.541,0,0,1-1.019.074L62.955,32.3a1.572,1.572,0,0,0-1.036-.895l-2.109-.568a.542.542,0,0,1-.075-1.02l2.005-.868a1.572,1.572,0,0,0,.895-1.036L63.2,25.8A.541.541,0,0,1,64.223,25.729Z",fill:"#fcc846"})]}),C=/*#__PURE__*/r.createContext({dateFormat:null,olsonTimeZone:null,twentyFourHourTime:null});b.default.mixin(c.standardAlertOptions),b.default.mixin(c.successAlertOptions);const z=b.default.mixin(c.errorAlertOptions),_=b.default.mixin(c.standardConfirmOptions),P=b.default.mixin(c.destroyConfirmOptions),T=b.default.mixin(c.createConfirmOptions),O=function(e){try{return Promise.all(e.map(function(e){try{const t=function(){if(function(e){return["AddToWorkflowOperationDefinition","CustomFieldBooleanOperationDefinition","CustomFieldCheckboxesOperationDefinition","CustomFieldDateOperationDefinition","CustomFieldNumberOperationDefinition","CustomFieldSelectOperationDefinition","CustomFieldStringOperationDefinition","CustomFieldTextOperationDefinition"].includes(e.operationDefinitionClassName)}(e))return Promise.resolve(function(e){try{function t(){return n||e.description}let n="";const i=function(){if("AddToWorkflowOperationDefinition"===e.operationDefinitionClassName)return Promise.resolve(function(e){try{return Promise.resolve(I.get({data:{fields:{Workflow:"name,archived_at"},where:{id:e}},url:"workflows"}).catch(()=>[{data:{name:""}}])).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(e.operationParams.workflowId)).then(function(t){const i=t[0];if(i?.name){let t;t=i.archivedAt?`[archived] ${i.name}`:i.name,n=e.description.replace("[Hidden Workflow]",t)}});{const t=e.operationParams.definitionIdentifier.match(/(\d+)_field_definition/)[1];return Promise.resolve(function(e){try{return Promise.resolve(I.get({data:{fields:{FieldDefinition:"name,data_type,field_options",FieldOption:"value"},include:"field_options"},url:`field_definitions/${e}`}).catch(()=>({data:{name:""}}))).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(t)).then(function(t){t.name&&(n=e.description.replace("[Hidden Custom Field]",t.name),n+=e.operationParams.values||"checkboxes"!==t.dataType?` (${function(e,t){switch(t.dataType){case"checkboxes":return Object.entries(e.operationParams.values).map(([e,n])=>{const i=t.fieldOptions.find(t=>t.id===parseInt(e,10))?.value||"[Hidden value]";return`${A(n)} ${i}`}).join(", ");case"select":return e.operationParams.value?t.fieldOptions.find(t=>t.id===parseInt(e.operationParams.value.toString(),10))?.value||"[Hidden value]":"Unanswered";case"boolean":switch(e.operationParams.value){case"true":return"Yes";case"false":return"No";default:return"Unanswered"}default:return e.operationParams.value??"Unanswered"}}(e,t)})`:"")})}}();return Promise.resolve(i&&i.then?i.then(t):t())}catch(a){return Promise.reject(a)}}(e)).then(function(t){e.description=t})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function A(e){return e.charAt(0).toUpperCase()+e.slice(1)}const I=new n.Client({app:"people",version:"2025-03-20"});function V(e){return e.listClass?`${e.id}_${e.listClass}`:"PersonSearch"===e.kind?`${e.id}_PersonSearch`:null}function F(e){if(e.definitionClass.match(/^CustomField\w+OperationDefinition$/))return"Update [Hidden Custom Field]"}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $({field:e,loadedLists:t}){if(e.list)return e.list;if(V(e))return t[V(e)];throw new Error(`Don't know how to get list for ${JSON.stringify(e)}`)}function B(e,t){return e.filter(e=>{if(Object.prototype.hasOwnProperty.call(e,"renderIf")){const n=e.renderIf,i=Object.keys(n)[0];return s.isBoolean(n)?n:n[i]===t[i]}return!0})}function D({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n,description:i}){if("AddToWorkflowOperationDefinition"===e.definitionClass){const e=n.workflow_id_WorkflowsList,a=e&&e.find(e=>e.value.toString()===t.workflow_id)?.description;return i.replace(a,"[Hidden Workflow]")}return e.definitionClass.match(/^CustomField\w+OperationDefinition$/)?"":i}({description:e.definitionFields.map(e=>{if(!L(t,e.id))return null;const i=t[e.id];let a;switch(e.kind){case"Select":case"SelectSearch":case"PersonSearch":case"RadioButtons":return a=$({field:e,loadedLists:n}),a&&a.find(e=>e.value.toString()===i)?.description;case"Checkbox":return i&&e.label;case"Checkboxes":return a=$({field:e,loadedLists:n}),a.filter(e=>L(i,e.value)).map(e=>`${A(i[e.value])} ${e.description}`).join(", ");case"NumberField":case"TextField":case"TextArea":case"DateField":return i;default:throw new Error(`Don't know how to build value for field with kind ${e.kind}`)}}).filter(e=>e).join(", "),loadedLists:n,selectedDefinition:e,selectedFieldOptions:t})}function H(e){return e.replace(/%m/,"MM").replace(/%d/,"DD").replace(/%Y/,"YYYY").replace(/%y/,"YY")}function R(e,t){const n=v.default(e,"YYYY-MM-DD");if(!n.isValid())return"";const i=H(t);return n.format(i)}function N(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function W(e){return e.replace(/s$/,"")}function E(e){const t=e.split("/");return{appName:t[0],resourceId:t[t.length-1],resourcePath:t.slice(2,-1).join("/"),resourceType:t[t.length-2]}}function M(e,t){return"403"===e.errors?.[0]?.status?`You don't have permission to ${t||"modify"} this automation.`:null}const q=function(e){try{const t=e.data.map(e=>X(e));return Promise.resolve(function(n,i){try{var a=Promise.resolve(U(t)).then(function(t){return{events:e,people:t}})}catch(e){return i()}return a&&a.then?a.then(void 0,i):a}(0,function(){return{events:e,people:[]}}))}catch(e){return Promise.reject(e)}},U=function(e){try{return Promise.resolve(Q.get({data:{fields:{Person:"id,name"},where:{id:e.join(",")}},url:"people"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},Y=function(e,t,n){try{return Promise.resolve(Z.get({data:{_e:e,fields:{Delivery:"status,response_body,created_at",Event:"id,created_at,last_delivery,payload,status,uuid,person"},include:"last_delivery",order:"-created_at",...n},url:`automation_subscriptions/${t}/events`}))}catch(e){return Promise.reject(e)}},Z=new n.Client({app:"webhooks",version:"2022-10-20"}),Q=new n.Client({app:"people",version:"2022-07-14"}),G={delivered:{label:"Success",value:["delivered"]},failed:{label:"Failed",value:["failed","duplicated"]},ignored:{label:"Ignored",value:["ignored_duplicated","ignored_failed","ignored_skipped"]},pending:{label:"Pending",value:["pending"]},skipped:{label:"Paused",value:["skipped"]}};function J({events:e,people:t}){const n=e.data.reduce((e,n)=>{const i=X(n),a=t.find(e=>i.toString()===e.id.toString());return e.push(a?{...n,person:{id:a.id,name:a.name}}:{...n,person:{id:i,name:"[Hidden]"}}),e},[]);return{...e,data:n}}function X(e){return e.personId}function K({automation:e,triggerResource:n,filterWhere:o,onEventsStatusChange:s}){const{events:l,loading:c,paginationProps:d,refresh:u,params:p,setParams:h}=function(e,t,n){const[i,a]=r.useState(),[o,s]=r.useState(!1),[l,c]=r.useState({}),[d,u]=r.useState(n?{where:{status:n}}:{}),[p,h]=r.useState(),{offset:m,paginationProps:g,resetOffset:w}=function(e,t){const[n,i]=r.useState(0);return{offset:n,paginationProps:{currentPage:Math.floor(n/50)+1,onPageChange:function(e){i(50*(e-1))},totalPages:Math.ceil(t/50)},resetOffset:r.useCallback(()=>{i(0)},[])}}(0,p?.totalCount);r.useEffect(()=>{o||l[m]||(s(!0),Y(t,e,{offset:m,per_page:50,...d}).then(q).then(J).then(e=>{c(t=>({...t,[m]:e.data})),h(e.meta),s(!1)}).catch(x))},[e,t,o,d,m,l]);const f=r.useCallback(()=>{c({}),h(void 0),w()},[w]);function x(e){a(()=>{throw e})}return r.useEffect(()=>{f()},[f,d]),{events:l[m]||[],loading:o,paginationProps:g,params:d,refresh:f,setParams:u}}(e.id,n,o),{dateFormat:m,olsonTimeZone:g,twentyFourHourTime:w}=r.useContext(C),f=p.where&&Object.keys(p.where).length>0,x=function(e){const t=v.default(e,"YYYY-MM-DD");return v.default().diff(t,"days")}(e.createdAt)<=32,b=R(e.createdAt,m),k=x?`Automation history started on ${b}`:"Automation history is saved for 32 days",j=[{cell:e=>t.jsx(ne,{status:e.status}),css:{padding:"8px 12px"},header:"Status"},{cell:e=>v.default(e.createdAt).utcOffset(g).format(function({dateFormat:e,twentyFourHourTime:t}){return`${H(e)} ${t?"HH:mm":"h:mm A"}`}({dateFormat:m,twentyFourHourTime:w})),header:"Date and time"},{cell:e=>t.jsx(a.Link,{to:`/people/AC${e.person.id}`,children:e.person.name}),css:{maxWidth:"33%"},header:"Profile"},{cell:e=>t.jsx(ie,{event:e}),css:{flex:1},header:"Message"},{cell:i=>![...G.delivered.value,...G.pending.value].includes(i.status)&&t.jsxs(t.Fragment,{children:[t.jsx(ee,{automationId:e.id,event:i,triggerResource:n,onEventsStatusChange:s}),![...G.ignored.value].includes(i.status)&&t.jsx(te,{automationId:e.id,event:i,triggerResource:n,refreshHistory:u,onEventsStatusChange:s})]}),css:{textAlign:"right"},header:"",minWidth:"84px"}];return t.jsxs(a.StackView,{spacing:i.token("--t-spacing-4"),children:[t.jsxs(a.StackView,{spacing:i.token("--t-spacing-half"),children:[t.jsx(a.Heading,{level:3,size:"16px",color:i.token("--t-text-color-default-secondary"),weight:i.token("--t-font-weight-medium"),children:e.description}),t.jsx(a.Text,{color:i.token("--t-text-color-default-secondary"),size:i.token("--t-font-size-xs"),italic:!0,children:k})]}),t.jsxs(a.StackView,{spacing:i.token("--t-spacing-2"),children:[t.jsx(a.Box,{minHeight:7,children:!c&&(l.length||f)&&t.jsxs(a.StackView,{alignItems:"end",axis:"horizontal",distribution:"space-between",spacing:i.token("--t-spacing-1"),children:[t.jsxs(a.StackView,{width:"max-content",children:[t.jsx(a.Input.InputLabel,{fontWeight:i.token("--t-font-weight-medium"),color:i.token("--t-text-color-default-primary"),controls:"select-status",children:"Filter by status"}),t.jsxs(a.Select,{id:"select-status",emptyValue:null,onChange:({selectedValue:e})=>{h({where:e?{status:e}:null})},title:"Status",value:p.where?.status,children:[t.jsx(a.Select.Option,{value:null,children:"All"}),Object.values(G).map(e=>t.jsx(a.Select.Option,{value:e.value.join(","),children:e.label},e.value))]})]}),t.jsx(a.Button,{iconLeft:{name:"general.refresh"},onClick:u,theme:"primary",variant:"outline",width:12,children:"Refresh"})]})}),t.jsx(a.Box,{maxHeight:"70vh",minHeight:36,overflow:"auto",children:t.jsx(a.DataTable,{columns:j,data:l,empty:t.jsxs(a.StackView,{alignment:"center",distribution:"center",minHeight:20,maxWidth:45,spacing:i.token("--t-spacing-1"),marginTop:f?-4:-8,marginBottom:f?4:void 0,children:[t.jsx(a.Box,{css:{svg:{height:15,width:20}},children:t.jsx(S,{})}),t.jsx(a.Heading,{color:i.token("--t-text-color-default-headline"),fontWeight:i.token("--t-font-weight-medium"),level:4,size:i.token("--t-font-size-lg"),children:"No history found"}),t.jsxs(a.Text,{fontSize:i.token("--t-font-size-md"),textAlign:"center",children:["No events ",f&&"matching your filters"," were triggered for this automation"," ",x?`since ${b}.`:"in the last 32 days."]}),f&&t.jsx(a.Button,{marginTop:i.token("--t-spacing-1"),onClick:()=>h({}),theme:"primary",title:"Clear filters",variant:"outline"})]}),loading:c,loadingTitle:"Loading automation history...",variant:{bodyCell:{alignItems:"start",fontSize:i.token("--t-font-size-sm"),lineHeight:"20px",padding:"10px 12px"},bodyRow:({rowData:e})=>({backgroundColor:[...G.ignored.value].includes(e.status)?i.token("--t-fill-color-neutral-090"):void 0,minHeight:"36px"}),headerCell:{padding:"8px 12px"},headerRow:{minHeight:"36px"}},...d})})]})]})}function ee({automationId:e,event:n,triggerResource:o,onEventsStatusChange:s}){const[l,c]=r.useState(n.status),d=G.pending.value.includes(l)?"Sending":G.delivered.value.includes(l)?"Sent":G.skipped.value.includes(l)?"Run now":"Retry",u=G.delivered.value.includes(l)?{color:i.token("--t-text-color-status-success"),name:"general.check"}:void 0;return t.jsx(a.Button,{title:d,onClick:function(){c(G.pending.value.join(",")),Z.post({data:{_e:o,data:{attributes:{}}},url:`/automation_subscriptions/${e}/events/${n.id}/redeliver`}).then(e=>{c(G.delivered.value.join(",")),s(e.meta.eventsStatus)}).catch(()=>{c(G.failed.value.join(",")),z.fire({text:"There was a problem retrying this automation. Please try again in a few moments.",title:"Uh oh!"})})},iconLeft:u,disabled:l!==n.status,variant:"naked",color:G.delivered.value.includes(l)?i.token("--t-text-color-status-success"):G.pending.value.includes(l)?i.token("--t-text-color-default-placeholder"):i.token("--t-text-color-interaction-primary"),theme:"primary",size:"xs"})}function te({automationId:e,event:n,triggerResource:i,refreshHistory:r,onEventsStatusChange:o}){return t.jsx(a.Button,{title:"Ignore",onClick:function(){Z.post({data:{_e:i,data:{attributes:{}}},url:`/automation_subscriptions/${e}/events/${n.id}/ignore`}).then(e=>{o(e.meta.eventsStatus)}).then(()=>r()).catch(()=>{z.fire({text:"There was a problem ignoring this event. Please try again in a few moments.",title:"Uh oh!"})})},variant:"naked",color:"linkForeground",theme:"primary",size:"xs"})}function ne({status:e}){const n=G.pending.value.includes(e)?{border:i.token("--t-border-color-default-dark"),text:i.token("--t-text-color-default-primary")}:G.delivered.value.includes(e)?{border:i.token("--t-border-color-status-success"),text:i.token("--t-text-color-status-success")}:G.skipped.value.includes(e)?{border:i.token("--t-border-color-status-warning"),text:i.token("--t-text-color-status-warning")}:G.ignored.value.includes(e)?{border:i.token("--t-border-color-default-dark"),text:i.token("--t-text-color-default-secondary")}:{border:i.token("--t-border-color-status-error"),text:i.token("--t-text-color-status-error")},r=G.pending.value.includes(e)?"general.clock":G.skipped.value.includes(e)?"services.pause":G.delivered.value.includes(e)?"general.checkCircle":G.ignored.value.includes(e)?"general.inactive":"general.exclamationTriangle",o=G.failed.value.includes(e)?G.failed.label:G.ignored.value.includes(e)?G.ignored.label:G[e].label;return t.jsx(a.Badge,{color:{background:"transparent",foreground:n.text},css:{paddingLeft:3.5,paddingRight:1.5},fontSize:i.token("--t-font-size-xs"),radius:"pill",renderLeft:t.jsx(a.Icon,{name:r,color:n.border,marginLeft:i.token("--t-spacing-1")}),size:"sm",stroke:n.border,strokeAlign:"inside",strokeWeight:1,title:o})}function ie({event:e}){const{status:n,lastDelivery:r}=e,o=function(e,n){let i=null;switch(e){case"skipped":case"ignored_skipped":i="Automation was paused and did not run on this profile";break;case"failed":case"duplicated":case"ignored_failed":case"ignored_duplicated":i=function(e,n){const i={403:"Owner doesn't have permission to perform this action.",404:"Owner lacks access to target product or resource doesn't exist.",422:"The automation action failed to run",default:"An error occurred",duplicated_event:"Didn't run because the same action had already been performed less than 60 seconds ago",failed_without_deliveries:"Didn't run because the owner doesn't have permissions in this product."};return t.jsx(a.StackView,{flex:1,whiteSpace:"normal",children:e?t.jsx(ae,{details:function(e){if(!e?.responseBody)return null;let t;try{t=JSON.parse(e.responseBody)}catch{t={errors:["Server Error"]}}return function(e){return e?.errors?e.errors.map(e=>"string"==typeof e&&e.match(/Archived profiles/)?e.replace(/Archived profiles/,"Archived profiles."):e):[]}(t).join(", ")||t?.message}(e),status:e.status,children:i[e.status]||i.default}):["duplicated","ignored_duplicated"].includes(n)?i.duplicated_event:i.failed_without_deliveries})}(n,e)}return i}(n,r);return o?t.jsx(a.Box,{fontSize:i.token("--t-font-size-sm"),fontStyle:"italic",lineHeight:"16px",maxWidth:"100%",paddingTop:"1px",whiteSpace:"normal",children:o}):null}function ae({children:e,details:n,status:o}){const[s,l]=r.useState(!1);return t.jsxs(a.StackView,{spacing:i.token("--t-spacing-1"),children:[t.jsxs(a.Box,{children:[e," ",n&&t.jsx(a.Button,{inline:!0,onClick:function(){l(e=>!e)},size:"xs",theme:"primary",variant:"naked",fontStyle:"normal",children:"Details"})]}),s?t.jsx(a.Box,{padding:1,background:i.token("--t-fill-color-neutral-090"),children:t.jsxs(a.Text,{fontFamily:"monospace",fontSize:i.token("--t-font-size-xs"),lineHeight:"1.2",children:[o&&`${o}: `,n]})}):null]})}class re extends f.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t.jsxs(a.Alert,{type:"error",marginVertical:i.token("--t-spacing-1"),children:["The application hit an unexpected error. If this persists after a few minutes, please let us know so we can get it fixed for you."," ",t.jsx("a",{style:{whiteSpace:"nowrap"},onClick:()=>window.Helpdesk.load(),children:"Contact support"})]}):this.props.children}}var oe=e=>t.jsx(re,{children:t.jsx(K,{...e})});function se({onClick:e}){return t.jsx(a.Button,{as:"button",height:i.token("--t-element-size-md"),icon:{color:i.token("--t-icon-color-default-dim"),name:"general.x"},onClick:e,size:"sm",title:"Close",variant:"naked"})}function le({children:e,onRequestClose:n,open:r,theme:o}){/*#__PURE__*/return u.createPortal(t.jsx(a.ThemeProvider,{theme:o,children:t.jsxs(a.Modal,{open:r,onRequestClose:n,maxWidth:120,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:i.token("--t-spacing-4"),paddingBottom:i.token("--t-spacing-3"),radius:i.token("--t-border-radius-lg"),children:[t.jsxs(a.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[t.jsx(a.Heading,{level:2,color:i.token("--t-text-color-default-headline"),fontWeight:i.token("--t-font-weight-medium"),fontSize:i.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Automation history"}),t.jsx(se,{onClick:n})]}),e]})}),document.body)}const ce=function(e){try{return Promise.resolve(ue.get({data:{fields:{Person:"avatar"}},url:"me"})).then(function({data:{avatar:t}}){return{avatar:t,subscription:e}})}catch(e){return Promise.reject(e)}},de=new n.Client({app:"webhooks",version:"2022-10-20"}),ue=new n.Client({app:"people"}),pe=/*#__PURE__*/r.createContext(null);function he({updateAutomation:e,onDelete:n,theme:i,openHistoryNow:a=!1,disabled:r,disabledReason:o,...s}){return t.jsxs(fe,{theme:i,updateAutomation:e,...s,children:[t.jsxs(xe,{children:[t.jsx(be,{}),t.jsx(ve,{onDelete:n,openHistoryNow:a,disabled:r,disabledReason:o})]}),t.jsx(ye,{}),t.jsx(je,{})]})}function me(e){return t.jsxs(fe,{automation:e.automation,children:[t.jsxs(xe,{children:[t.jsx(be,{}),t.jsx(we,{})]}),t.jsx(ge,{}),t.jsx(ke,{})]})}function ge(){const{automation:e}=r.useContext(pe),n=e.triggerEventDescription,{name:o,description:l}=Ce(e.description),c=e.active?void 0:.5;return t.jsxs(a.StackView,{paddingVertical:i.token("--t-spacing-2"),flex:1,opacity:c,children:[t.jsx(a.Heading,{level:3,size:i.token("--t-font-size-xl"),weight:i.token("--t-font-weight-medium"),marginBottom:i.token("--t-spacing-half"),truncate:!0,children:o}),t.jsxs(a.StackView,{spacing:.75,children:[t.jsxs(a.Text,{size:i.token("--t-font-size-sm"),color:i.token("--t-text-color-default-primary"),lineHeight:"1.2",children:[n,", then ",s.lowerFirst(o)," ",Se(e)]}),t.jsx(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:s.truncate(ze(l),{length:160,separator:" "})})]})]})}function we(){const{automation:e}=r.useContext(pe);return t.jsx(a.Button,{external:!0,iconLeft:{name:"general.newWindow"},variant:"naked",size:"sm",to:e.triggerAdminUrl,disabled:!e.canManage,tooltip:e.canManage?void 0:"You do not have access to this resource",color:i.token("--t-text-color-default-secondary"),hover:{backgroundColor:"highlight",color:i.token("--t-text-color-default-secondary")},children:"Manage"})}function fe({automation:e,updateAutomation:n,children:i,theme:r,...o}){return t.jsx(pe.Provider,{value:{automation:e,theme:r,updateAutomation:n,...o},children:t.jsx(a.Card,{radius:4,padding:2,children:i})})}function xe({children:e}){const{automation:n}=r.useContext(pe);return t.jsx(a.StackView,{axis:"horizontal",alignment:"center",padding:0,distribution:"space-between",opacity:n.active?void 0:.5,children:e})}function ve({onDelete:e,openHistoryNow:n=!1,disabled:o,disabledReason:s}){const{automation:l,currentPersonCanCreate:c,currentPersonId:d,trigger:u,theme:p,updateAutomation:h}=r.useContext(pe),[m,g]=r.useState(n),w=l.active,{name:f}=Ce(l.description);return t.jsxs(t.Fragment,{children:[t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[t.jsxs(a.Dropdown,{icon:{color:i.token("--t-icon-color-default-primary"),name:"churchCenter.threeDots"},iconRight:!1,title:"Actions",variant:"naked",size:"md",disabled:o,children:[t.jsx(a.Dropdown.Item,{onSelect:()=>{g(!0)},children:"History"}),c&&t.jsx(a.Dropdown.Item,l.createdById===d?{disabled:!0,children:t.jsx(a.Tooltip,{placement:"left",openDelay:250,title:"This automation is already assigned to you.",children:t.jsx(a.Text,{children:"Reassign to me..."})})}:{onSelect:function(){_.fire({text:"This automation will run with your permission levels. Other administrators who can see this automation can grant it their permissions by reassigning it to themselves.",title:"Reassign automation?"}).then(({isConfirmed:e})=>{e&&de.post({data:{_e:u.resource,data:{attributes:{}}},url:`/automation_subscriptions/${l.id}/self_assign`}).then(({data:e})=>ce(e)).then(({subscription:e,avatar:t})=>{h(n=>({...n,createdBy:{...n.createdBy,avatarUrl:t},createdById:e.createdById,createdByName:e.createdByName}))}).catch(e=>{const t=M(e,"update")||"There was a problem updating this automation. Please try again in a few moments.";z.fire({text:t,title:"Uh oh!"})})})},children:"Reassign to me..."}),t.jsx(a.Dropdown.Item,{onSelect:function(){P.fire({confirmButtonText:"Yes, delete automation",text:`Are you sure you want to delete the "${f}" automation? This cannot be undone.`,title:"Delete this automation?"}).then(({isConfirmed:t})=>{t&&e(l.id)})},children:"Delete..."})]}),t.jsx(a.ToggleSwitch,{isChecked:w,size:"sm",onClick:function(){de.patch({data:{_e:u.resource,data:{attributes:{active:!w}}},url:`/automation_subscriptions/${l.id}`}).then(e=>{h(t=>({...t,active:e.data.active}))}).catch(e=>{const t=M(e,"pause")||`There was a problem ${w?"pausing":"unpausing"} this automation. Please try again in a few moments.`;z.fire({text:t,title:"Uh oh!"})})},tooltip:o?s:w?"Pause automation":"Enable automation",disabled:o})]}),t.jsx(le,{open:m,onRequestClose:()=>g(!1),theme:p,children:t.jsx(oe,{automation:l,triggerResource:u.resource,onEventsStatusChange:function(e){h(t=>({...t,eventsStatus:e}))}})})]})}function be(){const{automation:e}=r.useContext(pe),n=e.name.split(".")[0];return t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:.5,children:[t.jsx(a.Icon,{name:`logomark.${s.camelCase(n)}`,size:2,color:n.toLowerCase()}),t.jsx(a.Icon,{name:"general.rightArrow",size:1.5}),t.jsx(a.Icon,{name:`logomark.${s.camelCase(e.operationAppName)}`,size:2,color:e.operationAppName.toLowerCase()})]})}function ke(){const{automation:e}=r.useContext(pe),{dateFormat:n}=r.useContext(C),o=`${e.createdByName} ${e.createdBy?.id?"":"(deleted profile)"}`,s=e.active?void 0:.5;return t.jsxs(t.Fragment,{children:[t.jsx(a.Divider,{marginHorizontal:-2}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:i.token("--t-spacing-1"),opacity:s,children:[t.jsxs(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",R(e.createdAt,n)]}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-half"),maxWidth:"calc(100% - 136px)",children:[e.createdBy?.avatarUrl&&t.jsx(a.Avatar,{width:2,height:2,basis:2,source:e.createdBy.avatarUrl},o),t.jsx(a.Text,{size:5,truncate:!0,children:o})]})]})]})}function je(){const{dateFormat:e}=r.useContext(C),{automation:n,trigger:o,theme:s,updateAutomation:l}=r.useContext(pe),c=`${n.createdByName} ${n.createdBy?.id?"":"(deleted profile)"}`,d=n.active?void 0:.5,u={color:i.token("--t-text-color-default-secondary"),fontSize:i.token("--t-font-size-xs"),fontWeight:i.token("--t-font-weight-normal"),paddingHorizontal:i.token("--t-spacing-1"),radius:"pill",size:"xs",variant:"naked"},[p,h]=r.useState({filter:null,historyVisible:!1});return t.jsxs(t.Fragment,{children:[t.jsx(a.Divider,{marginHorizontal:-2}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:i.token("--t-spacing-1"),opacity:d,children:[t.jsxs(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",R(n.createdAt,e)]}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-fourth"),children:[!!n.eventsStatus?.skipped&&t.jsxs(a.Button,{...u,"aria-label":`${n.eventsStatus.skipped} skipped`,onClick:function(){h({filter:"skipped",historyVisible:!0})},tooltip:`${n.eventsStatus.skipped?.toLocaleString()} skipped events`,children:[t.jsx(a.Box,{backgroundColor:i.token("--t-fill-color-status-warning-solid"),marginRight:i.token("--t-spacing-half"),radius:"circle",height:"10px",width:"10px",padding:i.token("--t-spacing-fourth"),children:t.jsx(a.Icon,{name:"services.pause",size:"6px",title:"Skipped",color:"white"})}),`${n.eventsStatus.skipped?.toLocaleString()}`]}),!!n.eventsStatus?.failed&&t.jsx(a.Button,{...u,"aria-label":`${n.eventsStatus.failed} failed`,iconLeft:{color:i.token("--t-icon-color-status-error-primary"),marginRight:i.token("--t-spacing-half"),name:"general.exclamationTriangle",size:"10px",title:"Failed"},onClick:function(){h({filter:"failed,duplicated",historyVisible:!0})},title:`${n.eventsStatus.failed?.toLocaleString()}`,tooltip:`${n.eventsStatus.failed?.toLocaleString()} failed events`})]}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",distribution:"end",flex:1,spacing:i.token("--t-spacing-half"),marginLeft:"auto",children:[n.createdBy?.avatarUrl&&t.jsx(a.Avatar,{width:i.token("--t-element-size-md"),height:i.token("--t-element-size-md"),basis:i.token("--t-element-size-md"),source:n.createdBy.avatarUrl},c),t.jsx(a.Text,{size:i.token("--t-font-size-sm"),truncate:!0,children:c})]})]}),t.jsx(le,{open:p.historyVisible,onRequestClose:()=>h({filter:null,historyVisible:!1}),theme:s,children:t.jsx(oe,{automation:n,triggerResource:o.resource,filterWhere:p.filter,onEventsStatusChange:function(e){l(t=>({...t,eventsStatus:e}))}})})]})}function ye(){const{automation:e,trigger:n}=r.useContext(pe),{name:o,description:l}=Ce(e.description),c=e.active?void 0:.5,d=["When a person",s.lowerFirst(n.event.description)+",","then",s.lowerFirst(o),Se(e)].join(" ");return t.jsxs(a.StackView,{paddingVertical:i.token("--t-spacing-2"),flex:1,opacity:c,children:[t.jsx(a.Heading,{level:3,size:i.token("--t-font-size-xl"),weight:i.token("--t-font-weight-bold"),marginBottom:i.token("--t-spacing-half"),truncate:!0,children:o}),t.jsxs(a.StackView,{spacing:.75,children:[t.jsx(a.Text,{size:i.token("--t-font-size-sm"),color:i.token("--t-text-color-default-primary"),lineHeight:"1.2",children:d}),t.jsx(a.Text,{size:i.token("--t-font-size-xs"),color:i.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:s.truncate(ze(l),{length:160,separator:" "})})]})]})}function Se(e){return e?.triggerParams?.useTriggerPersonOverride?"(also applies to joint donor)":""}function Ce(e){const t=/^(.+?)\(([^()]*?)\)$/.exec(e);return t?{description:t[2],name:t[1].trim()}:{name:e}}function ze(e){return e?.startsWith("[archived]")?e.replace("[archived]","[Archived]"):e}const _e=function(){try{return Promise.resolve(Oe.get({data:{fields:{App:["name"],PersonApp:["app","allow_pco_login"]},include:["app"]},url:"/me/person_apps"}).then(({data:e})=>e.filter(e=>e.allowPcoLogin).map(e=>e.app.name.toLowerCase())))}catch(e){return Promise.reject(e)}},Pe=function(e){try{const t=s.compact(s.uniq(e.map(e=>e.createdById)));return Promise.resolve(function(n,i){try{var a=Promise.resolve(Oe.get({data:{fields:{Person:"avatar"},where:{id:t.join(",")}},url:"people"})).then(function({data:t}){return{profiles:t,subscriptions:e}})}catch(e){return i()}return a&&a.then?a.then(void 0,i):a}(0,function(){return{profiles:[],subscriptions:e}}))}catch(e){return Promise.reject(e)}},Te=new n.Client({app:"webhooks",version:"2022-10-20"}),Oe=new n.Client({app:"people"});function Ae({profiles:e,subscriptions:t}){return t.map(t=>{const n=e.find(e=>e.id===t.createdById);return{...t,createdBy:{...t.createdBy,avatarUrl:n?.avatar}}})}const Ie=function(e){try{const t={people:["forms","lists"],registrations:["events"],services:["teams"]},n=["giving"],i=e.reduce((e,t)=>{const n=t.triggerResource.replace(/signup/,"event"),{appName:i,resourceType:a,resourcePath:r,resourceId:o}=E(n);return e[i]||(e[i]={}),e[i][a]||(e[i][a]={}),e[i][a].resoucePath||(e[i][a].resourcePath=r),e[i][a].ids||(e[i][a].ids=[]),e[i][a].ids.push(o),e},{}),a=Object.keys(i).flatMap(e=>Object.entries(i[e]).flatMap(([i,a])=>(n.includes(e)?Be:t[e]?.includes(i)?Le:$e)({appName:e,ids:a.ids,resourcePath:a.resourcePath,resourceType:i})));return Promise.resolve(Promise.allSettled(a)).then(function(t){return{automations:e,triggerResources:(n=t,n.reduce((e,t)=>("fulfilled"===t.status&&(e=e.concat(t.value)),e),[]).flatMap(e=>e.data))};var n})}catch(e){return Promise.reject(e)}},Ve=function(e){try{return Promise.resolve(Fe.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,trigger_resource,trigger_params",Person:"name"},include:"created_by"},url:"incoming_automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},Fe=new n.Client({app:"webhooks",version:"2022-10-20"});function Le({appName:e,resourcePath:t,resourceType:n,ids:i}){return De({appName:e,params:{where:{id:i.join(",")}},path:t,resourceType:n})}function $e({appName:e,resourcePath:t,resourceType:n,ids:i}){return i.map(i=>De({appName:e,path:`${t}/${i}`,resourceType:n}))}function Be(e){return new Promise((e,t)=>{t()})}function De({appName:e,path:t,resourceType:i,params:a={}}){const r=new n.Client({app:e}),o=s.upperFirst(W(i));return r.get({data:{fields:{[o]:["name","name_or_description"]},...a},url:t})}function He({encryptedParam:e,trigger:n}){const[o,l]=r.useState(!0),[c,d]=r.useState();r.useEffect(()=>{_e().then(t=>{Ve(e).then(Pe).then(Ae).then(O).then(Ie).then(({automations:e,triggerResources:n})=>function({automations:e,triggerResources:t,operationApps:n}){return e.map(e=>{const{appName:i,resourceType:a,resourceId:r}=E(e.triggerResource);if("giving"===i)return e.triggerEventDescription=function(e){switch(e.name.replace("giving.v2.events.","")){case"donation.payment_successful":return"When a person gives";case"profile.first_donated_automation":return"When a person gives for the first time";case"recurring_donation.setup_successful":return"When a person sets up a recurring donation";default:return null}}(e),e.canManage=n.find(e=>"giving"===e),e;const o=t.find(e=>e.id.toString()==r.toString()),l=o?o.name||o.nameOrDescription:`[Hidden ${s.upperFirst(W(a))}]`;return e.triggerEventDescription=function(e,t){const n=function(e){switch(e.replace("v2.events.","")){case"groups.membership.created":return"joins";case"groups.membership.destroyed":return"leaves";case"people.list_result.created":case"services.team_person.created":return"is added to";case"people.list_result.destroyed":case"services.team_person.destroyed":return"is removed from";case"people.form_submission.created":return"submits";case"registrations.attendee.created":return"is registered as a new attendee for";case"registrations.attendee.cancelled":return"is canceled as an attendee for";case"registrations.registration.created":return"is the registration contact on a new registration for";case"registrations.registration.cancelled":return"is the registration contact on a canceled registration for";default:return null}}(e.name),{resourceType:i}=E(e.triggerResource);if(!n){const e=s.truncate(t,{length:160,separator:" "});return`When the automation is triggered from ${W(i)} "${e}"`}return`When a person ${n} ${W(i)} "${t}"`}(e,l),e.canManage=!!o,e})}({automations:e,operationApps:t,triggerResources:n})).then(d).then(()=>l(!1))})},[e]);const u=!o&&0===c.length;return t.jsxs(t.Fragment,{children:[t.jsx(a.Box,{borderBottom:`1px solid ${i.token("--t-border-color-default-base")}`,marginBottom:i.token("--t-spacing-2"),marginHorizontal:-3,marginTop:n?12:0,paddingHorizontal:i.token("--t-spacing-3"),paddingVertical:i.token("--t-spacing-2"),children:t.jsx(a.Heading,{color:i.token("--t-text-color-default-headline"),level:2,size:i.token("--t-font-size-lg"),children:o?"Incoming automations":N(c.length,"incoming automation")})}),u?t.jsx(a.Text,{color:i.token("--t-text-color-default-secondary"),marginVertical:i.token("--t-spacing-3"),children:"Automations that perform actions on this resource will be listed here."}):o?t.jsx(a.Summary,{image:t.jsx(a.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading incoming automations..."}):t.jsx(a.TileView,{spacing:i.token("--t-spacing-3"),marginVertical:i.token("--t-spacing-3"),minCellWidth:45,children:c.map(e=>t.jsx(me,{automation:e},e.id))})]})}function Re(e){return`OPERATION_${e.definitionClass}${e.definitionIdentifier||""}`}function Ne(e){return`SECTION_${e}`}function We(e){return e.map(({label:e,value:n})=>t.jsx(a.Select.Option,{value:n,children:e},n))}function Ee(e){const n=s.groupBy(e,"group");return Object.keys(n).sort().map(e=>"null"===e?We(n[e]):t.jsx(a.Select.OptionGroup,{title:e,children:We(n[e])},e))}const Me=({selectedOperation:e,onOperationDefinitionChange:n,operationDefinitions:r})=>{const o=e?.section,l=r.map(e=>({...e,id:Re(e)})),c=l.filter(e=>null===e.section),d=s.uniqBy(r,"section").filter(e=>!!e.section).map(e=>({group:e.sectionGroup,label:e.section,value:Ne(e.section)})),u=o?l.filter(e=>e.section===o):[];function p({selectedValue:e}){switch(function(e){if(e.startsWith("SECTION"))return"section";if(e.startsWith("OPERATION"))return"operation";if(e)throw new Error(`Unexpected value: ${e}`);return null}(e)){case"section":n(r.find(t=>Ne(t.section)===e));break;case"operation":n(r.find(t=>Re(t)===e));break;case null:n(null)}}function h(e){return Ee(e.map(e=>({group:e.group,label:e.description,value:e.id})))}return t.jsxs(a.StackView,{spacing:i.token("--t-spacing-1"),children:[t.jsxs(a.Select,{emptyValue:"Select an action",id:"select-action",onChange:p,size:"lg","data-testid":"operation-select",children:[h(c),Ee(d)]}),u.length>0&&t.jsx(a.Select,{defaultValue:u[0].id,onChange:p,size:"lg",children:h(u)})]})},qe=({canAccessPeople:e,field:n,onChange:o,value:l,selectedFieldOptions:c,loadListForField:d,loadedLists:u,loadingLists:p})=>{const h=function(e){const[t,n]=r.useState(e);return r.useEffect(()=>{const i=e();s.isEqual(i,t)||n(i)},[e,t]),t}(()=>function({field:e,selectedFieldOptions:t}){return(e.dependsOn||[]).reduce((e,n)=>(Object.prototype.hasOwnProperty.call(t,n)&&(e[s.camelCase(n)]=t[n]),e),{})}({field:n,selectedFieldOptions:c}));r.useEffect(()=>{n.listClass&&d({dependencies:h,field:n})},[n,h,d]);const m=n.list||u[V(n)]||[],g=m.filter(e=>!e.automationNotAllowed),w=n.listClass&&p[V(n)];return t.jsxs(a.StackView,{marginBottom:2,spacing:.5,children:[t.jsxs(a.Input.InputLabel,{color:i.token("--t-text-color-default-headline"),fontSize:i.token("--t-font-size-sm"),fontWeight:i.token("--t-font-weight-medium"),controls:n.id,children:[n.description,n.info&&t.jsx(a.HelperDrawer.Toggle,{drawerId:`${n.id}_help`,marginLeft:1})]}),t.jsx(a.Box,{children:w?t.jsx(nt,{}):function(){switch(n.kind){case"Select":return t.jsx(Ue,{fieldId:n.id,listOptions:g,onChange:o,value:l,description:n.description});case"SelectSearch":return t.jsx(Ye,{fieldId:n.id,listOptions:g,onChange:o,value:l});case"Checkbox":return t.jsx(Qe,{field:n,value:l,onChange:o});case"TextArea":return t.jsx(Ge,{field:n,onChange:o,value:l});case"DateField":return t.jsx(Je,{field:n,onChange:o,value:l});case"Checkboxes":return t.jsx(Xe,{fieldId:n.id,options:g,onChange:o});case"NumberField":return t.jsx(Ke,{field:n,onChange:o,value:l});case"PersonSearch":return t.jsx(Ze,{canAccessPeople:e,field:n,onChange:o,listOptions:m,isLoading:p[V(n)],loadListForField:d,value:l});case"TextField":return t.jsx(et,{field:n,onChange:o,value:l});case"RadioButtons":return t.jsx(tt,{field:n,options:m,onChange:o,value:l});case"StaticText":return t.jsx(a.Text,{dangerouslySetInnerHTML:{__html:n.content}});default:return console.warn(`Unknown field kind "${n.kind}"`),null}}()}),n.info&&t.jsx(a.HelperDrawer,{id:`${n.id}_help`,marginTop:i.token("--t-spacing-half"),children:t.jsx(a.Box,{dangerouslySetInnerHTML:{__html:n.info}})})]})},Ue=({fieldId:e,listOptions:n,onChange:i,value:r,description:o})=>{const l=n?.find(e=>"no-option"===e.value),c=s.groupBy(n,"group"),d=Object.keys(c).sort(),u=()=>d.map(e=>"null"===e||"undefined"===e?p(c[e]):t.jsx(a.Select.OptionGroup,{title:e,children:p(c[e])},e)),p=e=>e.map(e=>t.jsx(a.Select.Option,{value:e.value.toString(),disabled:e.disabled,children:e.description},e.value));return t.jsx(a.Select,{id:e,onChange:({selectedValue:t})=>{i({fieldId:e,value:t})},disabled:u().length<1,emptyValue:0===u().length?"No options available":l?.description||(e=>{let t="Select ";return e?["a","e","i","o","u"].includes(e.charAt(0))?t+=`an ${e}`:t+=`a ${e}`:t+="a value",t})(o?.toLowerCase()),size:"lg",value:r||l?.value||null,placement:"bottom-start",children:u()})},Ye=({fieldId:e,listOptions:n,onChange:o,value:l})=>{const c=n.find(e=>e.value?.toString()===l),d=c?.description||"",[u,p]=r.useState(""),[h,m]=r.useState(d),[g,w]=r.useState(!1),[f,x]=r.useState(!1);d!==u&&(p(d),m(d),w(!1));let v=s.sortBy(s.uniqBy(n,"value"),"group");if(g){const e=h.toLowerCase();v=v.filter(t=>`${t.description} ${t.group}`.toLowerCase().includes(e))}return t.jsx(a.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},css:{"[role='combobox']":{cursor:n.length>0?"pointer":"not-allowed"}},cursor:"pointer",disabled:0===n.length,onBlur:()=>{x(!1),m(d)},onChange:e=>{m(e.target.value),w(!0),x(!0)},onClear:f?()=>{m(""),w(!1)}:void 0,onFocus:e=>e.target.select(),onSelect:t=>{(t=>{o({fieldId:e,value:t})})(t.value),m(t.description),w(!1),x(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:n.length>0?"Select an option":"No options available",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:t.jsx(a.Icon,{name:"general.search",size:"md"}),renderRight:t.jsx(a.Icon,{name:"general.downCaret"}),size:"lg",value:h,children:n.length>0&&t.jsx(t.Fragment,{children:v.length>0?v.map((e,n)=>{const r=e.value.toString()===l;return t.jsxs(a.Combobox.Item,{"aria-label":e.description,disabled:e.disabled,index:n,paddingLeft:4.25,renderLeft:t.jsx(a.Icon,{marginLeft:-.5,name:r?"general.check":"",size:"sm"}),role:"option",spacing:i.token("--t-spacing-1"),value:{description:e.description,value:e.value.toString()},children:[t.jsx(a.Text,{truncate:!0,children:t.jsx(a.Highlight,{text:e.description,query:h})}),e.group&&t.jsx(a.Badge,{title:t.jsx(a.Highlight,{text:e.group,query:h}),size:"sm",marginLeft:"auto"})]},e.value)}):t.jsx(a.Menu.Item,{children:t.jsxs(a.Text,{children:['No results for "',h,'"']})})})})},Ze=({canAccessPeople:e,field:n,isLoading:o,listOptions:l,loadListForField:c,onChange:d,value:u})=>{const p=r.useCallback(e=>{c({dependencies:{query:e},field:n})},[c]),h=r.useMemo(()=>s.debounce(p,300),[p]),m=r.useCallback(t=>{e&&(t.trim().length>0?h(t):h.cancel())},[h]),g=r.useMemo(()=>({description:"Myself",value:"self"}),[]),w=r.useMemo(()=>e?l:[g],[g,l]).find(e=>e.value===u),f=w?.description||"",[x,v]=r.useState(f),[b,k]=r.useState(!1);function j(e){v(e),m(e),0===e.trim().length&&y(null)}const y=e=>{d({fieldId:n.id,value:e})};return t.jsx(a.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},cursor:"pointer",onBlur:()=>{k(!1),j(f)},onChange:e=>{j(e.target.value),k(!0)},onClear:b?()=>{j("")}:void 0,onFocus:e=>e.target.select(),onSelect:e=>{y(e.value),j(e.description),k(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:"Search",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:w&&w.meta?.avatar?t.jsx(a.Avatar,{size:"sm",source:w.meta.avatar}):t.jsx(a.Icon,{name:"general.search",size:"md"}),renderRight:t.jsx(a.Icon,{name:"general.downCaret"}),size:"lg",value:x,children:e?x.trim().length>0?l.length>0?l.map((e,n)=>t.jsx(a.Combobox.Item,{"aria-label":e.description,index:n,paddingLeft:4.25,renderLeft:t.jsx(a.Avatar,{marginLeft:-.5,source:e.meta.avatar,size:"sm"}),role:"option",spacing:i.token("--t-spacing-1"),value:e,children:t.jsx(a.Text,{truncate:!0,children:t.jsx(a.Highlight,{text:e.description,query:x})})},e.value)):t.jsx(a.Combobox.Item,o?{children:t.jsx(a.Text,{children:"Loading..."})}:{children:t.jsx(a.Text,{children:"No results"})}):t.jsx(a.Combobox.Item,{children:t.jsx(a.Text,{children:"Type to search"})}):t.jsx(a.Combobox.Item,{value:g,index:0,role:"option",children:t.jsx(a.Text,{children:g.description})})})},Qe=({field:e,value:n,onChange:i})=>t.jsx(a.Checkbox,{disabled:e.disabled,label:e.label,checked:n||!1,onChange:t=>{i({fieldId:e.id,value:t.target.checked})}}),Ge=({field:e,value:n,onChange:i})=>t.jsx(a.Box,{children:t.jsx(a.TextArea,{value:n,placeholder:e.placeholder,onChange:t=>{i({fieldId:e.id,value:t.target.value})},size:"lg"})}),Je=({field:e,value:n,onChange:i})=>{const{dateFormat:o}=r.useContext(C),[s,l]=r.useState(!1),c=e.customValue||"Day automation runs",d="Day before automation runs",u=o.replace(/%m/,"M").replace(/%d/,"d").replace(/%Y/,"y").replace(/%y/,"yy"),[p,h]=r.useState(v.default(n).toDate()),m=e.allowUnansweredOption??!1;return t.jsxs(a.StackView,{axis:"horizontal",children:[t.jsxs(a.Select,{onChange:({selectedValue:t})=>{t===c||t===d?(l(!1),i({fieldId:e.id,value:t})):"specific-date"===t?(i({fieldId:e.id,value:null}),l(!0)):(l(!1),i({fieldId:e.id,value:null}))},size:"lg",placement:"bottom-start",children:[t.jsx(a.Select.Option,{value:c,children:c}),!e.customValue&&t.jsx(a.Select.Option,{value:d,children:d}),t.jsx(a.Select.Option,{value:"specific-date",children:"A specific date"}),m&&t.jsx(a.Select.Option,{value:"unanswered",children:"Unanswered"})]}),s&&t.jsx(a.Box,{children:t.jsx(a.DateField,{defaultOpen:!0,formatValue:u,marginLeft:1,onChange:t=>{i({fieldId:e.id,value:R(t,o)}),h(t)},size:"lg",value:p})})]})},Xe=({fieldId:e,options:n,onChange:i})=>{const[o,s]=r.useState({});return t.jsx(a.StackView,{spacing:1,children:n.map(n=>t.jsxs(a.Box,{children:[t.jsx(a.Input.InputLabel,{controls:`checkboxes_${e}_${n.value}`,children:n.description||n.value}),t.jsxs(a.Select,{id:`checkboxes_${e}_${n.value}`,onChange:({selectedValue:t})=>((t,n)=>{const a={...o};a[n]=t,s(a),i({fieldId:e,value:a})})(t,n.value),size:"lg",emptyValue:"Don't change",children:[t.jsx(a.Select.Option,{value:"check",children:"Check"}),t.jsx(a.Select.Option,{value:"uncheck",children:"Uncheck"})]})]},n.value))})},Ke=({field:e,onChange:n,value:o})=>{const s=e.minValue>=0?e.minValue:1,l=e.maxValue>=1&&e.maxValue<=365?e.maxValue:365,[c,d]=r.useState(Number(e.defaultValue)||1);return r.useEffect(()=>{n({fieldId:e.id,value:e.defaultValue||1})},[e]),t.jsxs(a.StackView,{children:[t.jsx(a.Input.InputBox,{children:t.jsx(a.NumberField,{onChange:t=>{const i=Number(t)||0;d(i),n({fieldId:e.id,value:Math.min(Math.max(i,s),l)})},placeholder:e.placeholder,size:"lg",value:o,min:s,max:l,hasControls:!0})}),c>l&&t.jsx(a.Alert,{type:"error",paddingHorizontal:i.token("--t-spacing-1"),paddingVertical:i.token("--t-spacing-half"),display:"inline-block",marginTop:1.5,children:t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[t.jsx(a.Icon,{name:"general.exclamationTriangle",size:"sm",color:"delete45"}),t.jsxs(a.Text,{size:i.token("--t-font-size-md"),children:["Value cannot exceed ",l,"."]})]})})]})},et=({field:e,value:n,onChange:i})=>t.jsx(a.Box,{children:t.jsx(a.Input,{size:"lg",value:n,id:e.id,placeholder:e.placeholder,onChange:t=>{i({fieldId:e.id,value:t.target.value})}})}),tt=({field:e,options:n,onChange:i,value:r})=>{const o=t=>{i({fieldId:e.id,value:t.target.value})};return t.jsx(a.StackView,{marginTop:1,spacing:.5,children:n.map(e=>t.jsx(a.Radio,{checked:r===e.value,label:e.description||e.value,onChange:o,size:"md",value:e.value},e.value))})},nt=()=>t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:i.token("--t-spacing-1"),radius:i.token("--t-border-radius-md"),border:`1px solid ${i.token("--t-border-color-default-base")}`,children:[t.jsx(a.Spinner,{size:"xs"}),t.jsx(a.Text,{fontSize:i.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]}),it=({canAccessPeople:e,definitionFields:n,onChange:i,selectedFieldOptions:a,loadListForField:o,loadedLists:s,loadingLists:l})=>{r.useEffect(()=>{const e=n.reduce((e,t)=>(Object.prototype.hasOwnProperty.call(t,"defaultValue")?e[t.id]=t.defaultValue:"DateField"===t.kind&&(e[t.id]=t.customValue||"Date automation runs"),e),{});i(e)},[n,i]);const c=B(n,a),d=({fieldId:e,value:t})=>{const r={...a},o=n.filter(e=>e.dependsOn);o.map(t=>{if(t.dependsOn.includes(e)){const e=o.find(e=>e.dependsOn.includes(t.id));e&&delete r[e.id],delete r[t.id],void 0!==t.defaultValue&&void 0===r[t.id]&&(r[t.id]=t.defaultValue)}}),"no-option"===t?delete r[e]:r[e]=t,i({...r})};return n.length?t.jsx("div",{children:c.map(n=>t.jsx(qe,{canAccessPeople:e,field:n,onChange:d,value:a[n.id],selectedFieldOptions:a,loadListForField:o,loadedLists:s,loadingLists:l},n.id))}):null},at=function(e){try{return Promise.resolve(lt.get({data:{fields:{OperationDefinition:"definition_class,definition_fields,definition_identifier,description,group,section,section_group,footer_message"},filter:"automation_allowed"},url:`/operation_apps/${e}/operation_definitions`}).then(({data:e})=>e))}catch(e){return Promise.reject(e)}},rt=function(){try{return Promise.resolve(lt.get({data:{fields:{OperationApp:"name"}},url:"/operation_apps"}).then(({data:e})=>e.map(e=>e.name)))}catch(e){return Promise.reject(e)}},ot=function(){try{return Promise.resolve(st.get({data:{fields:{Topbar:"apps"}},url:"/me/topbar"}).then(({data:e})=>e.apps.map(e=>e.name)))}catch(e){return Promise.reject(e)}},st=new n.Client({app:"people",env:window.railsEnv,version:"LATEST"}),lt=new n.Client({app:"webhooks",env:window.railsEnv,version:"LATEST"}),ct={css:{borderRadius:i.token("--t-border-radius-md")},paddingHorizontal:1.75,paddingVertical:1.25,type:"error"},dt=({afterCreateOptions:e,blankStateLink:n,debugMode:o=!1,defaultApp:l,description:c,onRequestClose:d,trigger:u})=>{const[p,h]=r.useState(u.events[0]),[m,g]=r.useState({}),[w,f]=r.useState(l),[x,v]=r.useState([]),[b,k]=r.useState([]),[j,y]=r.useState(!0),[S,C]=r.useState(),[z,_]=r.useState({}),[P,O]=r.useState({}),[A,I]=r.useState({}),[L,$]=r.useState(!1),[B,H]=r.useState({}),[R,N]=r.useState(!1),[W,E]=r.useState({}),M=r.useRef(null),q=r.useMemo(()=>x.map(e=>e.id).includes("people"),[x]),U=S?.definitionIdentifier,Y="danger"===S?.footerMessage?.kind,Z=r.useCallback(({field:e,dependencies:t})=>{I(t=>({...t,[V(e)]:!0})),function({app:e,field:t,definitionIdentifier:n,dependencies:i}){try{return"PersonSearch"===t.kind?Promise.resolve(st.get({data:{fields:{Person:"avatar,name"},where:{search_name_or_email:i.query,status:"active"}},url:"/people"})).then(function({data:e}){return e.map(e=>({description:e.name,meta:{avatar:e.avatar},value:e.id.toString()}))}):Promise.resolve(lt.get({data:{...i,definitionIdentifier:n,fields:{OperationDefinitionList:"values"}},url:`/operation_apps/${e}/operation_definition_lists/${t.listClass}`})).then(function({data:e}){return e.values})}catch(e){return Promise.reject(e)}}({app:w,definitionIdentifier:U,dependencies:t,field:e}).then(t=>{O(n=>({...n,[V(e)]:t})),I(t=>({...t,[V(e)]:!1}))}).catch(e=>H({selected_definition:e}))},[w,U]);r.useEffect(()=>{H({}),function(){try{return Promise.resolve(Promise.all([ot(),rt()])).then(function([e,t]){return e.filter(e=>t.includes(e)).sort().map(e=>({id:e.toLowerCase(),name:e}))})}catch(e){return Promise.reject(e)}}().then(e=>{v(e);const t=e.find(e=>e.id===l)?l:e[0].id;f(t),at(t).then(e=>{M.current||(k(e),y(!1))}).catch(e=>H({definitions:e}))})},[l]),r.useEffect(()=>{H({})},[z]);const Q=s.cloneDeep("conditions"in p?p.conditions:u.conditions);for(const e in m)s.set(Q,e,m[e]);const G="dynamicConditions"in p?p.dynamicConditions:u.dynamicConditions;function J(){const e=function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return{description:D({loadedLists:n||{},selectedDefinition:e,selectedFieldOptions:t}),name:(i=e,F(i)||i.description)};var i}({loadedLists:P,selectedDefinition:S,selectedFieldOptions:z});let t=e.name;return e.description&&(t+=` (${e.description})`),t}function X(t){$(!0),lt.post({data:t,url:"/me/automation_subscriptions"}).then(()=>{e?.onConfirm&&R?(d(),e.onConfirm({...t})):window.location.reload()}).catch(e=>{$(!1),e.errors?H({automation:e.errors}):alert("something even worse happened!")})}return t.jsxs(a.StackView,{paddingTop:4,spacing:2,children:[c&&t.jsx(a.Box,{children:t.jsxs(a.Text,{style:{color:i.token("--t-text-color-default-primary"),fontSize:i.token("--t-font-size-md"),lineHeight:1.65,marginBottom:i.token("--t-spacing-2")},children:[c," ",t.jsx(a.Link,{external:!0,to:n,children:"Learn more"})]})}),B.automation&&t.jsx(a.Alert,{...ct,children:t.jsx(a.Text,{children:"There was an error creating your automation. Please change your selections and try again or contact support if the problem persists."})}),t.jsxs(a.StackView,{spacing:1,children:[t.jsx(a.Input.InputLabel,{color:i.token("--t-text-color-default-primary"),controls:"select-trigger-event",fontSize:i.token("--t-font-size-md"),fontWeight:i.token("--t-font-weight-medium"),children:"When a person..."}),t.jsx(a.Select,{id:"select-trigger-event",onChange:({selectedValue:e})=>(e=>{h(e),g({})})(e),size:"lg",value:p,children:u.events.map((e,n)=>t.jsx(a.Select.Option,{value:e,children:e.description},`${e.name}_${n}`))}),G?.length>0&&t.jsx(it,{canAccessPeople:q,definitionFields:G,selectedFieldOptions:m,onChange:g,loadedLists:{},loadingLists:{},loadListForField:()=>null})]}),t.jsxs(a.StackView,{spacing:1,children:[x.length>0?t.jsx(gt,{selectedApp:w,operationApps:x,onOperationAppChange:e=>{f(e),y(!0),k([]),M.current=e,C(null),_({}),H({}),at(e).then(k).then(()=>y(!1)).catch(e=>H({definitions:e}))}}):t.jsxs(a.StackView,{spacing:1,children:[t.jsx(a.Text,{color:i.token("--t-text-color-default-headline"),fontSize:i.token("--t-font-size-md"),fontWeight:i.token("--t-font-weight-medium"),children:"Then perform an action in..."}),t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:i.token("--t-spacing-1"),radius:4,border:`1px solid ${i.token("--t-border-color-default-base")}`,children:[t.jsx(a.Spinner,{size:"xs"}),t.jsx(a.Text,{fontSize:i.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]})]}),B.definitions?t.jsx(a.Alert,{marginTop:i.token("--t-spacing-1"),...ct,children:t.jsx(a.Text,{children:"There was a problem looking up automations. Please contact support if the problem persists."})}):j?t.jsx(wt,{}):t.jsx(Me,{selectedOperation:S,operationDefinitions:b,onOperationDefinitionChange:e=>{C(e),H({}),_({})}})]}),S&&(B.selected_definition?t.jsx(a.Alert,{...ct,children:t.jsx(a.Text,{children:"There was a problem looking up automation options. Please contact support if the problem persists."})}):t.jsxs(t.Fragment,{children:[t.jsx(it,{canAccessPeople:q,definitionFields:S.definitionFields||[],onChange:_,selectedFieldOptions:z,loadedLists:P,loadListForField:Z,loadingLists:A}),e?.label&&t.jsx(a.Checkbox,{disabled:L||ut(S,z),label:e.label,checked:R,onChange:()=>N(!R)}),p?.triggerParams?.map((e,n)=>t.jsx(a.Checkbox,{label:e.description,checked:W&&W[e.key]||e.defaultValue,onChange:t=>{E(n=>({...n,[`${e.key}`]:t.target.checked}))}},`${e.key}_${n}`)),Y&&t.jsx(a.Alert,{...ct,children:t.jsxs(a.StackView,{axis:"horizontal",spacing:1.5,children:[t.jsx(a.Icon,{size:i.token("--t-element-size-lg"),name:"general.exclamationTriangle",color:i.token("--t-icon-color-status-error-primary")}),t.jsx(a.Text,{dangerouslySetInnerHTML:{__html:S.footerMessage?.html}})]})})]})),o&&t.jsx("pre",{children:JSON.stringify({description:S&&J(),loadedLists:P,selectedDefinition:S,selectedFieldOptions:z,triggerConditions:Q},null,4)}),t.jsxs(a.StackView,{alignment:"center",axis:"horizontal",borderTop:`1px solid ${i.token("--t-border-color-default-base")}`,distribution:"end",marginTop:2,marginHorizontal:-4,paddingHorizontal:4,paddingTop:3,spacing:2,children:[t.jsx(a.Button,{color:i.token("--t-text-color-default-headline"),"data-modal-close":!0,fontWeight:i.token("--t-font-weight-normal"),onClick:d,size:"md",title:"Cancel",variant:"naked"}),t.jsx(a.Button,{disabled:L||Y||ut(S,z),onClick:function(){if(L)return;const t={...z};S.definitionIdentifier&&(t.definition_identifier=S.definitionIdentifier);const n={_e:u.resource,data:{attributes:{description:J(),name:p.name,operation_app_name:w,operation_definition_class_name:S.definitionClass,operation_params:t,trigger_conditions:Q,trigger_params:W},type:"AutomationSubscription"}};R?T.fire({cancelButtonText:"Cancel",confirmButtonText:"Yes, perform action",text:"This will happen immediately after creating your new automation. Are you sure?",title:`${e.label}?`}).then(e=>{e.value?X(n):($(!1),N(!1))}):X(n)},size:"md",theme:"primary",title:mt(S,z),variant:"fill","data-testid":"create-automation"})]})]})};function ut(e,t){if(e){const n=B(e.definitionFields,t),i=n.filter(e=>e.required),a=n.filter(e=>pt(e));return!i.every(e=>ht(e,t))||!a.every(e=>ht(e,t))}return!0}function pt(e){return"Select"===e.kind||"SelectSearch"===e.kind}function ht(e,t){return pt(e)?t.hasOwnProperty(e.id):t.hasOwnProperty(e.id)&&t[e.id]&&""!==t[e.id].toString().trim()}function mt(e,t){const n=function(e,t){if(!e?.definitionFields)return;const n=B(e.definitionFields,t);for(const e of n)if(e.required&&!ht(e,t))return e.description}(e,t);return e?n?`Select a${n.charAt(0).match(/[aeiou]/i)?"n":""} ${n.toLowerCase()}`:"Create automation":"Select an action"}const gt=({onOperationAppChange:e,operationApps:n,selectedApp:r})=>t.jsxs(a.StackView,{spacing:1,children:[t.jsx(a.Input.InputLabel,{color:i.token("--t-text-color-default-headline"),controls:"select-product",fontSize:i.token("--t-font-size-md"),fontWeight:i.token("--t-font-weight-medium"),children:"Then perform an action in..."}),t.jsx(a.Select,{autoFocus:!0,id:"select-product",onChange:({selectedValue:t})=>{e(t)},size:"lg",value:r,children:n.map(e=>t.jsx(a.Select.Option,{value:e.id,children:e.name},e.id))})]}),wt=()=>t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:i.token("--t-spacing-1"),radius:i.token("--t-border-radius-md"),border:`1px solid ${i.token("--t-border-color-default-base")}`,children:[t.jsx(a.Spinner,{size:"xs"}),t.jsx(a.Text,{fontSize:i.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]});function ft({onClick:e}){return t.jsx(a.Button,{as:"button",height:i.token("--t-element-size-md"),icon:{color:i.token("--t-icon-color-default-dim"),name:"general.x"},onClick:e,size:"sm",title:"Close",variant:"naked"})}function xt({children:e,onRequestClose:n,open:r,theme:o}){/*#__PURE__*/return u.createPortal(t.jsxs(a.ThemeProvider,{theme:o,children:[t.jsxs(a.Modal,{open:r,onRequestClose:n,maxWidth:75,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:i.token("--t-spacing-4"),paddingBottom:i.token("--t-spacing-3"),radius:i.token("--t-border-radius-lg"),zIndex:10009,children:[t.jsxs(a.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[t.jsx(a.Heading,{level:2,color:i.token("--t-text-color-default-headline"),fontWeight:i.token("--t-font-weight-medium"),fontSize:i.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Create automation"}),t.jsx(ft,{onClick:n})]}),e]}),t.jsx("style",{children:"\n .swal2-container.swal2-backdrop-show { z-index: 10001 }\n "})]}),document.body)}const vt={churchCenter:k,logomark:j,services:y},bt=new n.Client({app:"webhooks",version:"2022-10-20"});function kt({afterCreateOptions:e,automations:n,blankStateLink:o,canCreate:s,defaultApp:l,description:c,hasActiveAutomations:d,loading:u,onPauseAutomations:p,theme:h,trigger:m}){const[g,w]=r.useState(!1),f=s&&!d,x=n.filter(e=>e.active).length,v=n.filter(e=>!e.active).length;return t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",backgroundColor:f?i.token("--t-fill-color-status-warning-ghost"):void 0,borderBottom:f?void 0:`1px solid ${i.token("--t-border-color-default-base")}`,"data-testid":"automations-header",distribution:"space-between",marginHorizontal:-3,marginBottom:i.token("--t-spacing-2"),marginTop:-3,paddingHorizontal:i.token("--t-spacing-3"),paddingVertical:i.token("--t-spacing-2"),spacing:i.token("--t-spacing-2"),wrap:!0,zIndex:2,children:[s&&!d?t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",marginHorizontal:1,spacing:1,children:[t.jsx(a.Icon,{size:2,color:i.token("--t-icon-color-status-warning-primary"),name:"general.exclamationTriangle"}),t.jsx(a.Heading,{color:i.token("--t-text-color-default-headline"),level:2,size:i.token("--t-font-size-lg"),children:"Automations are currently paused"})]}):t.jsxs(a.Heading,{color:i.token("--t-text-color-default-headline"),level:2,size:i.token("--t-font-size-lg"),children:[u?"Active automations":N(x,"active automation"),v>0?` (${v} paused)`:""]}),s&&(d?t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:i.token("--t-spacing-1"),children:[n.length>0&&t.jsx(a.Button,{onClick:p,variant:"outline",children:"Pause automations"}),t.jsx(a.Button,{theme:"primary",variant:"fill",onClick:()=>w(!0),children:"Create automation"}),t.jsx(xt,{open:g,onRequestClose:()=>w(!1),theme:h,children:t.jsx(dt,{description:c,blankStateLink:o,defaultApp:l,trigger:m,onRequestClose:()=>w(!1),afterCreateOptions:e})})]}):t.jsx(a.Box,{children:t.jsxs(a.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[t.jsx(a.Button,{onClick:p,theme:"primary",variant:"outline",children:"Enable automations"}),t.jsx(a.Button,{theme:"primary",disabled:!0,tooltip:{title:"Automations must be enabled to create new ones"},children:"Create automation"})]})}))]})}e.Automations=function({afterCreateOptions:e,blankStateDescription:n,blankStateLink:o="https://pcopeople.zendesk.com/hc/en-us/articles/217582148-Automations",currentPersonId:s,currentPersonCanCreate:l,defaultApp:c,incomingAutomationsParam:d,theme:u,trigger:p,currentOrganization:h,permissionDeniedReason:m="You need permissions of Editor or above to add an automation.",disabled:g=!1,disabledReason:w="Not allowed"}){r.useEffect(()=>{if(!p)return k(!1);(function(e){try{return Promise.resolve(Te.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,events_status,trigger_params",Person:"name"},include:"created_by"},url:"automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}})(p.resource).then(Pe).then(Ae).then(O).then(v).then(()=>k(!1))},[p?.resource]);const[f,v]=r.useState([]),[b,k]=r.useState(!0),[j,y]=r.useState(!1),{dateFormat:_,twentyFourHourTime:P,olsonTimeZone:T}=h,A=new URLSearchParams(window.location.search).get("automation_id"),I={...u,icons:{...vt}};r.useEffect(()=>{document.body.toggleAttribute("data-loading-automations",b)},[b]);const V=!f.length||f.some(e=>e.active);function F(e){bt.delete({data:{_e:p.resource},url:`/automation_subscriptions/${e}`}).then(()=>v(f.filter(t=>t.id!==e))).catch(e=>{const t=M(e,"delete")||"There was a problem deleting this automation. Please try again in a few moments.";z.fire({text:t,title:"Uh oh!"})})}const L={color:i.token("--t-text-color-default-primary"),level:2,size:i.token("--t-font-size-2xl"),weight:i.token("--t-font-weight-bold")},$={color:i.token("--t-text-color-default-secondary"),lineHeight:3,size:i.token("--t-font-size-md")};return t.jsxs(a.ThemeProvider,{theme:I,children:[t.jsxs(C.Provider,{value:{dateFormat:_,olsonTimeZone:T,twentyFourHourTime:P},children:[p&&t.jsx(kt,{automations:f,blankStateLink:o,canCreate:l&&!g,loading:b,defaultApp:c,description:n,theme:I,trigger:p,hasActiveAutomations:V,onPauseAutomations:function(){bt.post({data:{data:{attributes:{_e:p.resource,active:!V}}},url:"/pause_automations"}).then(()=>{window.location.reload()})},afterCreateOptions:e}),b?t.jsx(a.Summary,{image:t.jsx(a.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading automations..."}):p?t.jsx(a.Box,{"data-testid":"automations-section",children:f?.length>0?t.jsx(a.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:x.default(f,"id").map(e=>{return t.jsx(he,{automation:e,updateAutomation:(i=e,e=>{const t="function"==typeof e?e(i):e,n=[...f.filter(e=>e.id!==t.id),t];v(n)}),onDelete:F,theme:I,openHistoryNow:e.id===Number(A),trigger:{event:(n=e,p.events.find(e=>e.name===n.name)),resource:p.resource},currentPersonId:s,currentPersonCanCreate:l,disabled:g,disabledReason:w},e.id);var n,i})}):t.jsxs(a.StackView,{margin:i.token("--t-spacing-6"),spacing:i.token("--t-spacing-2"),alignment:"center",mediaQueries:{lg:{axis:"horizontal",distribution:"center",spacing:i.token("--t-spacing-6")}},children:[t.jsx(a.Box,{css:{".symbol":{height:"100%",width:"100%"}},maxWidth:24,mediaQueries:{lg:{maxWidth:40}},children:t.jsx(S,{})}),t.jsx(a.StackView,{alignment:"center",spacing:i.token("--t-spacing-1"),maxWidth:45,mediaQueries:{lg:{alignment:"start",textAlign:"left"}},textAlign:"center",children:t.jsxs(t.Fragment,l?{children:[t.jsx(a.Heading,{...L,children:"Add an automation"}),t.jsx(a.StackView,{alignment:"center",marginBottom:i.token("--t-spacing-1"),mediaQueries:{lg:{alignment:"start"}},spacing:1,children:t.jsx(a.Text,{...$,children:n})}),t.jsxs(a.StackView,{axis:"horizontal",spacing:i.token("--t-spacing-1"),children:[t.jsx(a.Button,{variant:"outline",to:o,color:`${i.token("--t-text-color-status-neutral")} !important`,children:"Learn more"}),t.jsx(a.Button,{as:"button",theme:"primary",variant:"fill",onClick:()=>y(!0),children:"Create automation"})]}),t.jsx(xt,{open:j,onRequestClose:()=>y(!1),theme:I,children:t.jsx(dt,{defaultApp:c,description:n,blankStateLink:o,onRequestClose:()=>y(!1),trigger:p,afterCreateOptions:e})})]}:{children:[t.jsx(a.Heading,{...L,children:"Automations"}),t.jsx(a.Text,{...$,children:m})]})})]})}):t.jsx(t.Fragment,{}),d&&t.jsx(He,{encryptedParam:d,trigger:p})]}),t.jsx("style",{children:'.swal2-popup{box-shadow:0 0 20px 0 rgba(0,0,0,.15)}.swal2-container .tds-btn{opacity:1}div:where(.swal2-container) div:where(.swal2-actions){border-top:var(--t-border-width-default) solid var(--t-border-color-default-base);gap:var(--t-spacing-1)}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto!important}body.swal2-no-backdrop .swal2-container{background-color:transparent!important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--t-fill-color-transparency-dark-static-040)}body.swal2-toast-shown .swal2-container{background-color:transparent;box-sizing:border-box;max-width:100%;pointer-events:none;width:360px}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-left,body.swal2-toast-shown .swal2-container.swal2-top-start{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-left,body.swal2-toast-shown .swal2-container.swal2-center-start{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%,-50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-left,body.swal2-toast-shown .swal2-container.swal2-bottom-start{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static!important}}div:where(.swal2-container){-webkit-overflow-scrolling:touch;box-sizing:border-box;display:grid;grid-template-areas:"top-start top top-end" "center-start center center-end" "bottom-start bottom-center bottom-end";grid-template-rows:minmax(min-content,auto) minmax(min-content,auto) minmax(min-content,auto);height:100%;inset:0;overflow-x:hidden;padding:var(--t-spacing-2);position:fixed;transition:background-color .1s;z-index:1060}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--t-fill-color-transparency-dark-static-040)}div:where(.swal2-container).swal2-backdrop-hide{background:transparent!important}div:where(.swal2-container).swal2-bottom-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-top-start{grid-template-columns:minmax(0,1fr) auto auto}div:where(.swal2-container).swal2-bottom,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-top{grid-template-columns:auto minmax(0,1fr) auto}div:where(.swal2-container).swal2-bottom-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-top-end{grid-template-columns:auto auto minmax(0,1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-left>.swal2-popup,div:where(.swal2-container).swal2-center-start>.swal2-popup{align-self:center;grid-row:2}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-left>.swal2-popup,div:where(.swal2-container).swal2-bottom-start>.swal2-popup{align-self:end;grid-column:1;grid-row:3}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup,div:where(.swal2-container).swal2-grow-row>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{align-self:stretch;grid-row:1/4}div:where(.swal2-container).swal2-no-transition{transition:none!important}div:where(.swal2-container) div:where(.swal2-popup){background:var(--t-surface-color-card);border:var(--swal2-border);border-radius:var(--t-border-radius-lg);box-sizing:border-box;color:var(--t-text-color-default-primary);display:none;font-family:inherit;font-size:var(--t-font-size-md);grid-template-columns:minmax(0,100%);max-width:100%;padding:0 0 var(--t-spacing-3);position:relative;width:600px}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){word-wrap:break-word;color:var(--t-text-color-default-headline);cursor:auto;font-size:var(--t-font-size-2xl);font-weight:600;margin:0;max-width:100%;padding:var(--t-spacing-1) var(--t-spacing-4) 0;position:relative;text-align:center;text-transform:none}div:where(.swal2-container) div:where(.swal2-actions){align-items:center;box-sizing:border-box;display:flex;flex-wrap:wrap;justify-content:center;margin:var(--t-spacing-4) auto 0;padding:var(--t-spacing-3) var(--t-spacing-1) 0;width:100%;z-index:1}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(transparent,transparent)}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(transparent,transparent)}div:where(.swal2-container) div:where(.swal2-loader){align-items:center;animation:none;border:0 solid transparent;border-radius:0;display:none;height:auto;justify-content:center;margin:0;width:auto}div:where(.swal2-container) button:where(.swal2-styled){box-shadow:0 0 0 3px transparent;font-weight:var(--t-font-weight-normal);margin:0;padding:var(--t-spacing-1);transition:box-shadow .1s}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){background:initial;background-color:var(--t-fill-color-button-interaction-solid-default);border:0;border-radius:var(--t-border-radius-default);color:var(--t-text-color-default-inverted);font-size:var(--t-font-size-md)}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):focus-visible{box-shadow:none}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){background:initial;background-color:var(--t-fill-color-button-delete-solid-default);border:0;border-radius:var(--t-border-radius-default);color:var(--t-text-color-default-inverted);font-size:var(--t-font-size-md)}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):focus-visible{box-shadow:none}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){background:initial;background-color:transparent;border:0;border-radius:var(--t-border-radius-default);color:var(--t-text-color-status-neutral);font-size:var(--t-font-size-md)}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):focus-visible{box-shadow:none}div:where(.swal2-container) button:where(.swal2-styled).swal2-default-outline:focus-visible{box-shadow:0 0 0 3px rgba(100,150,200,.5)}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){border-top:1px solid var(--t-border-color-default-base);color:inherit;cursor:auto;font-size:1em;margin:1em 0 0;padding:1em 1em 0;text-align:center}div:where(.swal2-container) .swal2-timer-progress-bar-container{border-bottom-left-radius:var(--t-border-radius-lg);border-bottom-right-radius:var(--t-border-radius-lg);bottom:0;grid-column:auto!important;left:0;overflow:hidden;position:absolute;right:0}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){background:rgba(var(--t-fill-color-neutral-000),.2);height:.25em;width:100%}div:where(.swal2-container) img:where(.swal2-image){cursor:auto;margin:var(--t-spacing-4) auto var(--t-spacing-2);max-width:100%}div:where(.swal2-container) button:where(.swal2-close){align-items:center;background:transparent;border:none;border-radius:var(--t-border-radius-lg);color:var(--t-icon-color-default-dim);cursor:pointer;font-family:monospace;font-size:2.5em;height:1.2em;justify-content:center;justify-self:end;margin-bottom:-1.2em;margin-right:0;margin-top:0;overflow:hidden;padding:0;transition:color .1s,box-shadow .1s;width:1.2em;z-index:2}div:where(.swal2-container) button:where(.swal2-close):hover{background:transparent;color:var(--t-icon-color-status-error-primary);transform:none}div:where(.swal2-container) button:where(.swal2-close):focus-visible{box-shadow:inset 0 0 0 3px rgba(100,150,200,.5);outline:none}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){word-wrap:break-word;color:inherit;cursor:auto;font-size:var(--t-font-size-md);font-weight:var(--t-font-weight-normal);justify-content:center;line-height:1.4;margin:0;overflow:auto;padding:var(--t-spacing-2) var(--t-spacing-4) 0;text-align:center;word-break:break-word;z-index:1}div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) label:where(.swal2-checkbox),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) textarea:where(.swal2-textarea){margin:var(--t-spacing-2) var(--t-spacing-4) 0!important}div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) textarea:where(.swal2-textarea){background:var(--swal2-input-background);border:var(--t-border-width-default) solid var(--t-border-color-default-base);border-radius:var(--t-border-radius-default);box-shadow:none;box-sizing:border-box;color:inherit;font-size:var(--t-font-size-md);transition:border-color .1s,box-shadow .1s;width:auto!important}div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:var(--t-icon-color-status-error-primary)!important;box-shadow:0 0 2px var(--t-icon-color-status-error-primary)!important}div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--t-border-width-default) solid var(--t-border-color-control-info);box-shadow:inset 0 1px 1px rgba(var(--t-fill-color-neutral-000),.06),0 0 0 3px rgba(100,150,200,.5);outline:none}div:where(.swal2-container) input:where(.swal2-file)::-moz-placeholder,div:where(.swal2-container) input:where(.swal2-input)::-moz-placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::-moz-placeholder{color:var(--t-text-color-default-placeholder)}div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:var(--t-text-color-default-placeholder)}div:where(.swal2-container) .swal2-range{background:var(--t-surface-color-card);margin:var(--t-spacing-2) var(--t-spacing-4) 0!important}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{color:inherit;font-weight:600;text-align:center;width:20%}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{font-size:var(--t-font-size-md);height:40px;line-height:40px;padding:0}div:where(.swal2-container) .swal2-input{height:40px;padding:0 var(--t-spacing-1)}div:where(.swal2-container) .swal2-file{background:var(--swal2-input-background);font-size:var(--t-font-size-md);margin-left:auto;margin-right:auto;width:75%}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{background:var(--swal2-input-background);color:inherit;font-size:var(--t-font-size-md);max-width:100%;min-width:50%;padding:.375em .625em}div:where(.swal2-container) .swal2-checkbox,div:where(.swal2-container) .swal2-radio{align-items:center;background:var(--t-surface-color-card);color:inherit;justify-content:center}div:where(.swal2-container) .swal2-checkbox label,div:where(.swal2-container) .swal2-radio label{font-size:var(--t-font-size-md);margin:0 .6em}div:where(.swal2-container) .swal2-checkbox input,div:where(.swal2-container) .swal2-radio input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;background:var(--t-fill-color-status-neutral-ghost);color:var(--t-text-color-default-primary);font-size:1em;font-weight:300;justify-content:center;margin:1em 0 0;overflow:hidden;padding:.625em}div:where(.swal2-container) div:where(.swal2-validation-message):before{background-color:var(--t-icon-color-status-error-primary);border-radius:50%;color:var(--t-fill-color-neutral-100);content:"!";display:inline-block;font-weight:600;height:1.5em;line-height:1.5em;margin:0 .625em;min-width:1.5em;text-align:center;width:1.5em}div:where(.swal2-container) .swal2-progress-steps{align-items:center;background:transparent;flex-wrap:wrap;font-weight:600;margin:1.25em auto;max-width:100%;padding:0}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{background:var(--t-fill-color-status-info-solid);border-radius:2em;color:var(--t-fill-color-neutral-100);flex-shrink:0;height:2em;line-height:2em;text-align:center;width:2em;z-index:20}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:var(--t-fill-color-status-info-solid)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--t-fill-color-status-info-ghost);color:var(--t-fill-color-neutral-100)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--t-fill-color-status-info-ghost)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{background:var(--t-fill-color-status-info-solid);flex-shrink:0;height:.4em;margin:0 -1px;width:2.5em;z-index:10}div:where(.swal2-icon){border:0 solid transparent;border-color:var(--t-icon-color-default-primary);border-radius:50%;box-sizing:content-box;cursor:default;font-family:inherit;height:var(--t-element-size-3xl);justify-content:center;line-height:var(--t-element-size-3xl);margin:2.5em auto .6em;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--t-element-size-3xl)}div:where(.swal2-icon) .swal2-icon-content{align-items:center;display:flex;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:var(--t-icon-color-status-error-primary);color:var(--t-icon-color-status-error-primary)}div:where(.swal2-icon).swal2-error .swal2-x-mark{flex-grow:1;position:relative}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{background-color:var(--t-icon-color-status-error-primary);border-radius:.125em;display:block;height:.3125em;position:absolute;top:2.3125em;width:2.9375em}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-warning{border-color:var(--t-icon-color-status-warning-primary);color:var(--t-icon-color-status-warning-primary)}div:where(.swal2-icon).swal2-info{border-color:var(--t-icon-color-status-info-primary);color:var(--t-icon-color-status-info-primary)}div:where(.swal2-icon).swal2-question{border-color:var(--t-icon-color-status-info-primary);color:var(--t-icon-color-status-info-primary)}div:where(.swal2-icon).swal2-success{border-color:var(--t-icon-color-status-success-primary);color:var(--t-icon-color-status-success-primary)}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{border-radius:50%;height:7.5em;position:absolute;width:3.75em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{border-radius:7.5em 0 0 7.5em;left:-2.0635em;top:-.4375em;transform:rotate(-45deg);transform-origin:3.75em 3.75em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{border-radius:0 7.5em 7.5em 0;left:1.875em;top:-.6875em;transform:rotate(-45deg);transform-origin:0 3.75em}div:where(.swal2-icon).swal2-success .swal2-success-ring{border:.25em solid var(--t-icon-color-status-success-secondary);border-radius:50%;box-sizing:content-box;height:100%;left:-.25em;position:absolute;top:-.25em;width:100%;z-index:2}div:where(.swal2-icon).swal2-success .swal2-success-fix{height:5.625em;left:1.625em;position:absolute;top:.5em;transform:rotate(-45deg);width:.4375em;z-index:1}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{background-color:var(--t-icon-color-status-success-primary);border-radius:.125em;display:block;height:.3125em;position:absolute;z-index:2}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{left:.8125em;top:2.875em;transform:rotate(45deg);width:1.5625em}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{right:.5em;top:2.375em;transform:rotate(-45deg);width:2.9375em}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-hide,.swal2-show{animation:none}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{height:50px;overflow:scroll;position:absolute;top:-9999px;width:50px}.svg-background-blob{fill:var(--t-fill-color-status-info-ghost)}:root[data-color-mode=dark] .svg-background-blob{fill:var(--t-fill-color-status-neutral-ghost)}@media (prefers-color-scheme:dark){:root[data-color-mode=system] .svg-bg-blob{fill:var(--t-fill-color-status-neutral-ghost)}}'})]})}});
|
|
2
2
|
//# sourceMappingURL=core-automations.umd.js.map
|