@planningcenter/core-automations 1.12.2-rc.0 → 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
|
-
var e=require("react/jsx-runtime"),t=require("@planningcenter/api-client"),n=require("@planningcenter/tapestry"),i=require("@planningcenter/tapestry-react"),a=require("react"),r=require("lodash/sortBy"),o=require("lodash"),s=require("moment"),l=require("@planningcenter/sweetalert2"),c=require("sweetalert2/dist/sweetalert2"),d=require("react-dom"),u=require("@planningcenter/icons/paths/church-center"),p=require("@planningcenter/icons/paths/services");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function m(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 g=/*#__PURE__*/h(a),w=/*#__PURE__*/h(r),f=/*#__PURE__*/h(s),x=/*#__PURE__*/h(c),v=/*#__PURE__*/m(u),b=/*#__PURE__*/m(p);const k=()=>e.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:[e.jsx("title",{children:"Automations"}),e.jsx("g",{opacity:"0.6",children:e.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"})}),e.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"}),e.jsx("path",{d:"M68.479,13.633v9.8a2.035,2.035,0,0,0,2.035,2.034h9.877Z",fill:"#c9d8e2"}),e.jsx("rect",{x:"51.214",y:"41.285",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"48.434",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"34.136",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"})]}),j=/*#__PURE__*/a.createContext({dateFormat:null,olsonTimeZone:null,twentyFourHourTime:null});x.default.mixin(l.standardAlertOptions),x.default.mixin(l.successAlertOptions);const y=x.default.mixin(l.errorAlertOptions),S=x.default.mixin(l.standardConfirmOptions),C=x.default.mixin(l.destroyConfirmOptions),z=x.default.mixin(l.createConfirmOptions),_=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(T.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(T.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`${P(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 P(e){return e.charAt(0).toUpperCase()+e.slice(1)}const T=new t.Client({app:"people",version:"2025-03-20"});function O(e){return e.listClass?`${e.id}_${e.listClass}`:"PersonSearch"===e.kind?`${e.id}_PersonSearch`:null}function A(e){if(e.definitionClass.match(/^CustomField\w+OperationDefinition$/))return"Update [Hidden Custom Field]"}function V(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function I({field:e,loadedLists:t}){if(e.list)return e.list;if(O(e))return t[O(e)];throw new Error(`Don't know how to get list for ${JSON.stringify(e)}`)}function F(e,t){return e.filter(e=>{if(Object.prototype.hasOwnProperty.call(e,"renderIf")){const n=e.renderIf,i=Object.keys(n)[0];return o.isBoolean(n)?n:n[i]===t[i]}return!0})}function L({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(!V(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=I({field:e,loadedLists:n}),a&&a.find(e=>e.value.toString()===i)?.description;case"Checkbox":return i&&e.label;case"Checkboxes":return a=I({field:e,loadedLists:n}),a.filter(e=>V(i,e.value)).map(e=>`${P(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 $(e){return e.replace(/%m/,"MM").replace(/%d/,"DD").replace(/%Y/,"YYYY").replace(/%y/,"YY")}function B(e,t){const n=f.default(e,"YYYY-MM-DD");if(!n.isValid())return"";const i=$(t);return n.format(i)}function D(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function H(e){return e.replace(/s$/,"")}function R(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 N(e,t){return"403"===e.errors?.[0]?.status?`You don't have permission to ${t||"modify"} this automation.`:null}const W=function(e){try{const t=e.data.map(e=>Q(e));return Promise.resolve(function(n,i){try{var a=Promise.resolve(E(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)}},E=function(e){try{return Promise.resolve(U.get({data:{fields:{Person:"id,name"},where:{id:e.join(",")}},url:"people"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},M=function(e,t,n){try{return Promise.resolve(q.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)}},q=new t.Client({app:"webhooks",version:"2022-10-20"}),U=new t.Client({app:"people",version:"2022-07-14"}),Y={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 Z({events:e,people:t}){const n=e.data.reduce((e,n)=>{const i=Q(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 Q(e){return e.personId}function G({automation:t,triggerResource:r,filterWhere:o,onEventsStatusChange:s}){const{events:l,loading:c,paginationProps:d,refresh:u,params:p,setParams:h}=function(e,t,n){const[i,r]=a.useState(),[o,s]=a.useState(!1),[l,c]=a.useState({}),[d,u]=a.useState(n?{where:{status:n}}:{}),[p,h]=a.useState(),{offset:m,paginationProps:g,resetOffset:w}=function(e,t){const[n,i]=a.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:a.useCallback(()=>{i(0)},[])}}(0,p?.totalCount);a.useEffect(()=>{o||l[m]||(s(!0),M(t,e,{offset:m,per_page:50,...d}).then(W).then(Z).then(e=>{c(t=>({...t,[m]:e.data})),h(e.meta),s(!1)}).catch(x))},[e,t,o,d,m,l]);const f=a.useCallback(()=>{c({}),h(void 0),w()},[w]);function x(e){r(()=>{throw e})}return a.useEffect(()=>{f()},[f,d]),{events:l[m]||[],loading:o,paginationProps:g,params:d,refresh:f,setParams:u}}(t.id,r,o),{dateFormat:m,olsonTimeZone:g,twentyFourHourTime:w}=a.useContext(j),x=p.where&&Object.keys(p.where).length>0,v=function(e){const t=f.default(e,"YYYY-MM-DD");return f.default().diff(t,"days")}(t.createdAt)<=32,b=B(t.createdAt,m),y=v?`Automation history started on ${b}`:"Automation history is saved for 32 days",S=[{cell:t=>e.jsx(K,{status:t.status}),css:{padding:"8px 12px"},header:"Status"},{cell:e=>f.default(e.createdAt).utcOffset(g).format(function({dateFormat:e,twentyFourHourTime:t}){return`${$(e)} ${t?"HH:mm":"h:mm A"}`}({dateFormat:m,twentyFourHourTime:w})),header:"Date and time"},{cell:t=>e.jsx(i.Link,{to:`/people/AC${t.person.id}`,children:t.person.name}),css:{maxWidth:"33%"},header:"Profile"},{cell:t=>e.jsx(ee,{event:t}),css:{flex:1},header:"Message"},{cell:n=>![...Y.delivered.value,...Y.pending.value].includes(n.status)&&e.jsxs(e.Fragment,{children:[e.jsx(J,{automationId:t.id,event:n,triggerResource:r,onEventsStatusChange:s}),![...Y.ignored.value].includes(n.status)&&e.jsx(X,{automationId:t.id,event:n,triggerResource:r,refreshHistory:u,onEventsStatusChange:s})]}),css:{textAlign:"right"},header:"",minWidth:"84px"}];return e.jsxs(i.StackView,{spacing:n.token("--t-spacing-4"),children:[e.jsxs(i.StackView,{spacing:n.token("--t-spacing-half"),children:[e.jsx(i.Heading,{level:3,size:"16px",color:n.token("--t-text-color-default-secondary"),weight:n.token("--t-font-weight-medium"),children:t.description}),e.jsx(i.Text,{color:n.token("--t-text-color-default-secondary"),size:n.token("--t-font-size-xs"),italic:!0,children:y})]}),e.jsxs(i.StackView,{spacing:n.token("--t-spacing-2"),children:[e.jsx(i.Box,{minHeight:7,children:!c&&(l.length||x)&&e.jsxs(i.StackView,{alignItems:"end",axis:"horizontal",distribution:"space-between",spacing:n.token("--t-spacing-1"),children:[e.jsxs(i.StackView,{width:"max-content",children:[e.jsx(i.Input.InputLabel,{fontWeight:n.token("--t-font-weight-medium"),color:n.token("--t-text-color-default-primary"),controls:"select-status",children:"Filter by status"}),e.jsxs(i.Select,{id:"select-status",emptyValue:null,onChange:({selectedValue:e})=>{h({where:e?{status:e}:null})},title:"Status",value:p.where?.status,children:[e.jsx(i.Select.Option,{value:null,children:"All"}),Object.values(Y).map(t=>e.jsx(i.Select.Option,{value:t.value.join(","),children:t.label},t.value))]})]}),e.jsx(i.Button,{iconLeft:{name:"general.refresh"},onClick:u,theme:"primary",variant:"outline",width:12,children:"Refresh"})]})}),e.jsx(i.Box,{maxHeight:"70vh",minHeight:36,overflow:"auto",children:e.jsx(i.DataTable,{columns:S,data:l,empty:e.jsxs(i.StackView,{alignment:"center",distribution:"center",minHeight:20,maxWidth:45,spacing:n.token("--t-spacing-1"),marginTop:x?-4:-8,marginBottom:x?4:void 0,children:[e.jsx(i.Box,{css:{svg:{height:15,width:20}},children:e.jsx(k,{})}),e.jsx(i.Heading,{color:n.token("--t-text-color-default-headline"),fontWeight:n.token("--t-font-weight-medium"),level:4,size:n.token("--t-font-size-lg"),children:"No history found"}),e.jsxs(i.Text,{fontSize:n.token("--t-font-size-md"),textAlign:"center",children:["No events ",x&&"matching your filters"," were triggered for this automation"," ",v?`since ${b}.`:"in the last 32 days."]}),x&&e.jsx(i.Button,{marginTop:n.token("--t-spacing-1"),onClick:()=>h({}),theme:"primary",title:"Clear filters",variant:"outline"})]}),loading:c,loadingTitle:"Loading automation history...",variant:{bodyCell:{alignItems:"start",fontSize:n.token("--t-font-size-sm"),lineHeight:"20px",padding:"10px 12px"},bodyRow:({rowData:e})=>({backgroundColor:[...Y.ignored.value].includes(e.status)?n.token("--t-fill-color-neutral-090"):void 0,minHeight:"36px"}),headerCell:{padding:"8px 12px"},headerRow:{minHeight:"36px"}},...d})})]})]})}function J({automationId:t,event:r,triggerResource:o,onEventsStatusChange:s}){const[l,c]=a.useState(r.status),d=Y.pending.value.includes(l)?"Sending":Y.delivered.value.includes(l)?"Sent":Y.skipped.value.includes(l)?"Run now":"Retry",u=Y.delivered.value.includes(l)?{color:n.token("--t-text-color-status-success"),name:"general.check"}:void 0;return e.jsx(i.Button,{title:d,onClick:function(){c(Y.pending.value.join(",")),q.post({data:{_e:o,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${r.id}/redeliver`}).then(e=>{c(Y.delivered.value.join(",")),s(e.meta.eventsStatus)}).catch(()=>{c(Y.failed.value.join(",")),y.fire({text:"There was a problem retrying this automation. Please try again in a few moments.",title:"Uh oh!"})})},iconLeft:u,disabled:l!==r.status,variant:"naked",color:Y.delivered.value.includes(l)?n.token("--t-text-color-status-success"):Y.pending.value.includes(l)?n.token("--t-text-color-default-placeholder"):n.token("--t-text-color-interaction-primary"),theme:"primary",size:"xs"})}function X({automationId:t,event:n,triggerResource:a,refreshHistory:r,onEventsStatusChange:o}){return e.jsx(i.Button,{title:"Ignore",onClick:function(){q.post({data:{_e:a,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${n.id}/ignore`}).then(e=>{o(e.meta.eventsStatus)}).then(()=>r()).catch(()=>{y.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 K({status:t}){const a=Y.pending.value.includes(t)?{border:n.token("--t-border-color-default-dark"),text:n.token("--t-text-color-default-primary")}:Y.delivered.value.includes(t)?{border:n.token("--t-border-color-status-success"),text:n.token("--t-text-color-status-success")}:Y.skipped.value.includes(t)?{border:n.token("--t-border-color-status-warning"),text:n.token("--t-text-color-status-warning")}:Y.ignored.value.includes(t)?{border:n.token("--t-border-color-default-dark"),text:n.token("--t-text-color-default-secondary")}:{border:n.token("--t-border-color-status-error"),text:n.token("--t-text-color-status-error")},r=Y.pending.value.includes(t)?"general.clock":Y.skipped.value.includes(t)?"services.pause":Y.delivered.value.includes(t)?"general.checkCircle":Y.ignored.value.includes(t)?"general.inactive":"general.exclamationTriangle",o=Y.failed.value.includes(t)?Y.failed.label:Y.ignored.value.includes(t)?Y.ignored.label:Y[t].label;return e.jsx(i.Badge,{color:{background:"transparent",foreground:a.text},css:{paddingLeft:3.5,paddingRight:1.5},fontSize:n.token("--t-font-size-xs"),radius:"pill",renderLeft:e.jsx(i.Icon,{name:r,color:a.border,marginLeft:n.token("--t-spacing-1")}),size:"sm",stroke:a.border,strokeAlign:"inside",strokeWeight:1,title:o})}function ee({event:t}){const{status:a,lastDelivery:r}=t,o=function(t,n){let a=null;switch(t){case"skipped":case"ignored_skipped":a="Automation was paused and did not run on this profile";break;case"failed":case"duplicated":case"ignored_failed":case"ignored_duplicated":a=function(t,n){const a={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 e.jsx(i.StackView,{flex:1,whiteSpace:"normal",children:t?e.jsx(te,{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}(t),status:t.status,children:a[t.status]||a.default}):["duplicated","ignored_duplicated"].includes(n)?a.duplicated_event:a.failed_without_deliveries})}(n,t)}return a}(a,r);return o?e.jsx(i.Box,{fontSize:n.token("--t-font-size-sm"),fontStyle:"italic",lineHeight:"16px",maxWidth:"100%",paddingTop:"1px",whiteSpace:"normal",children:o}):null}function te({children:t,details:r,status:o}){const[s,l]=a.useState(!1);return e.jsxs(i.StackView,{spacing:n.token("--t-spacing-1"),children:[e.jsxs(i.Box,{children:[t," ",r&&e.jsx(i.Button,{inline:!0,onClick:function(){l(e=>!e)},size:"xs",theme:"primary",variant:"naked",fontStyle:"normal",children:"Details"})]}),s?e.jsx(i.Box,{padding:1,background:n.token("--t-fill-color-neutral-090"),children:e.jsxs(i.Text,{fontFamily:"monospace",fontSize:n.token("--t-font-size-xs"),lineHeight:"1.2",children:[o&&`${o}: `,r]})}):null]})}class ne extends g.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs(i.Alert,{type:"error",marginVertical:n.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."," ",e.jsx("a",{style:{whiteSpace:"nowrap"},onClick:()=>window.Helpdesk.load(),children:"Contact support"})]}):this.props.children}}var ie=t=>e.jsx(ne,{children:e.jsx(G,{...t})});function ae({onClick:t}){return e.jsx(i.Button,{as:"button",height:n.token("--t-element-size-md"),icon:{color:n.token("--t-icon-color-default-dim"),name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function re({children:t,onRequestClose:a,open:r,theme:o}){/*#__PURE__*/return d.createPortal(e.jsx(i.ThemeProvider,{theme:o,children:e.jsxs(i.Modal,{open:r,onRequestClose:a,maxWidth:120,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:n.token("--t-spacing-4"),paddingBottom:n.token("--t-spacing-3"),radius:n.token("--t-border-radius-lg"),children:[e.jsxs(i.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(i.Heading,{level:2,color:n.token("--t-text-color-default-headline"),fontWeight:n.token("--t-font-weight-medium"),fontSize:n.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Automation history"}),e.jsx(ae,{onClick:a})]}),t]})}),document.body)}const oe=function(e){try{return Promise.resolve(le.get({data:{fields:{Person:"avatar"}},url:"me"})).then(function({data:{avatar:t}}){return{avatar:t,subscription:e}})}catch(e){return Promise.reject(e)}},se=new t.Client({app:"webhooks",version:"2022-10-20"}),le=new t.Client({app:"people"}),ce=/*#__PURE__*/a.createContext(null);function de({updateAutomation:t,onDelete:n,theme:i,openHistoryNow:a=!1,disabled:r,disabledReason:o,...s}){return e.jsxs(me,{theme:i,updateAutomation:t,...s,children:[e.jsxs(ge,{children:[e.jsx(fe,{}),e.jsx(we,{onDelete:n,openHistoryNow:a,disabled:r,disabledReason:o})]}),e.jsx(be,{}),e.jsx(ve,{})]})}function ue(t){return e.jsxs(me,{automation:t.automation,children:[e.jsxs(ge,{children:[e.jsx(fe,{}),e.jsx(he,{})]}),e.jsx(pe,{}),e.jsx(xe,{})]})}function pe(){const{automation:t}=a.useContext(ce),r=t.triggerEventDescription,{name:s,description:l}=je(t.description),c=t.active?void 0:.5;return e.jsxs(i.StackView,{paddingVertical:n.token("--t-spacing-2"),flex:1,opacity:c,children:[e.jsx(i.Heading,{level:3,size:n.token("--t-font-size-xl"),weight:n.token("--t-font-weight-medium"),marginBottom:n.token("--t-spacing-half"),truncate:!0,children:s}),e.jsxs(i.StackView,{spacing:.75,children:[e.jsxs(i.Text,{size:n.token("--t-font-size-sm"),color:n.token("--t-text-color-default-primary"),lineHeight:"1.2",children:[r,", then ",o.lowerFirst(s)," ",ke(t)]}),e.jsx(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:o.truncate(ye(l),{length:160,separator:" "})})]})]})}function he(){const{automation:t}=a.useContext(ce);return e.jsx(i.Button,{external:!0,iconLeft:{name:"general.newWindow"},variant:"naked",size:"sm",to:t.triggerAdminUrl,disabled:!t.canManage,tooltip:t.canManage?void 0:"You do not have access to this resource",color:n.token("--t-text-color-default-secondary"),hover:{backgroundColor:"highlight",color:n.token("--t-text-color-default-secondary")},children:"Manage"})}function me({automation:t,updateAutomation:n,children:a,theme:r,...o}){return e.jsx(ce.Provider,{value:{automation:t,theme:r,updateAutomation:n,...o},children:e.jsx(i.Card,{radius:4,padding:2,children:a})})}function ge({children:t}){const{automation:n}=a.useContext(ce);return e.jsx(i.StackView,{axis:"horizontal",alignment:"center",padding:0,distribution:"space-between",opacity:n.active?void 0:.5,children:t})}function we({onDelete:t,openHistoryNow:r=!1,disabled:o,disabledReason:s}){const{automation:l,currentPersonCanCreate:c,currentPersonId:d,trigger:u,theme:p,updateAutomation:h}=a.useContext(ce),[m,g]=a.useState(r),w=l.active,{name:f}=je(l.description);return e.jsxs(e.Fragment,{children:[e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsxs(i.Dropdown,{icon:{color:n.token("--t-icon-color-default-primary"),name:"churchCenter.threeDots"},iconRight:!1,title:"Actions",variant:"naked",size:"md",disabled:o,children:[e.jsx(i.Dropdown.Item,{onSelect:()=>{g(!0)},children:"History"}),c&&e.jsx(i.Dropdown.Item,l.createdById===d?{disabled:!0,children:e.jsx(i.Tooltip,{placement:"left",openDelay:250,title:"This automation is already assigned to you.",children:e.jsx(i.Text,{children:"Reassign to me..."})})}:{onSelect:function(){S.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&&se.post({data:{_e:u.resource,data:{attributes:{}}},url:`/automation_subscriptions/${l.id}/self_assign`}).then(({data:e})=>oe(e)).then(({subscription:e,avatar:t})=>{h(n=>({...n,createdBy:{...n.createdBy,avatarUrl:t},createdById:e.createdById,createdByName:e.createdByName}))}).catch(e=>{const t=N(e,"update")||"There was a problem updating this automation. Please try again in a few moments.";y.fire({text:t,title:"Uh oh!"})})})},children:"Reassign to me..."}),e.jsx(i.Dropdown.Item,{onSelect:function(){C.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:e})=>{e&&t(l.id)})},children:"Delete..."})]}),e.jsx(i.ToggleSwitch,{isChecked:w,size:"sm",onClick:function(){se.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=N(e,"pause")||`There was a problem ${w?"pausing":"unpausing"} this automation. Please try again in a few moments.`;y.fire({text:t,title:"Uh oh!"})})},tooltip:o?s:w?"Pause automation":"Enable automation",disabled:o})]}),e.jsx(re,{open:m,onRequestClose:()=>g(!1),theme:p,children:e.jsx(ie,{automation:l,triggerResource:u.resource,onEventsStatusChange:function(e){h(t=>({...t,eventsStatus:e}))}})})]})}function fe(){const{automation:t}=a.useContext(ce),n=t.name.split(".")[0];return e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:.5,children:[e.jsx(i.Logo,{markOnly:!0,name:n,size:"sm",theme:"color"}),e.jsx(i.Icon,{name:"general.rightArrow",size:1.5}),e.jsx(i.Logo,{markOnly:!0,name:t.operationAppName,size:"sm",theme:"color"})]})}function xe(){const{automation:t}=a.useContext(ce),{dateFormat:r}=a.useContext(j),o=`${t.createdByName} ${t.createdBy?.id?"":"(deleted profile)"}`,s=t.active?void 0:.5;return e.jsxs(e.Fragment,{children:[e.jsx(i.Divider,{marginHorizontal:-2}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:n.token("--t-spacing-1"),opacity:s,children:[e.jsxs(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",B(t.createdAt,r)]}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-half"),maxWidth:"calc(100% - 136px)",children:[t.createdBy?.avatarUrl&&e.jsx(i.Avatar,{width:2,height:2,basis:2,source:t.createdBy.avatarUrl},o),e.jsx(i.Text,{size:5,truncate:!0,children:o})]})]})]})}function ve(){const{dateFormat:t}=a.useContext(j),{automation:r,trigger:o,theme:s,updateAutomation:l}=a.useContext(ce),c=`${r.createdByName} ${r.createdBy?.id?"":"(deleted profile)"}`,d=r.active?void 0:.5,u={color:n.token("--t-text-color-default-secondary"),fontSize:n.token("--t-font-size-xs"),fontWeight:n.token("--t-font-weight-normal"),paddingHorizontal:n.token("--t-spacing-1"),radius:"pill",size:"xs",variant:"naked"},[p,h]=a.useState({filter:null,historyVisible:!1});return e.jsxs(e.Fragment,{children:[e.jsx(i.Divider,{marginHorizontal:-2}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:n.token("--t-spacing-1"),opacity:d,children:[e.jsxs(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",B(r.createdAt,t)]}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-fourth"),children:[!!r.eventsStatus?.skipped&&e.jsxs(i.Button,{...u,"aria-label":`${r.eventsStatus.skipped} skipped`,onClick:function(){h({filter:"skipped",historyVisible:!0})},tooltip:`${r.eventsStatus.skipped?.toLocaleString()} skipped events`,children:[e.jsx(i.Box,{backgroundColor:n.token("--t-fill-color-status-warning-solid"),marginRight:n.token("--t-spacing-half"),radius:"circle",height:"10px",width:"10px",padding:n.token("--t-spacing-fourth"),children:e.jsx(i.Icon,{name:"services.pause",size:"6px",title:"Skipped",color:"white"})}),`${r.eventsStatus.skipped?.toLocaleString()}`]}),!!r.eventsStatus?.failed&&e.jsx(i.Button,{...u,"aria-label":`${r.eventsStatus.failed} failed`,iconLeft:{color:n.token("--t-icon-color-status-error-primary"),marginRight:n.token("--t-spacing-half"),name:"general.exclamationTriangle",size:"10px",title:"Failed"},onClick:function(){h({filter:"failed,duplicated",historyVisible:!0})},title:`${r.eventsStatus.failed?.toLocaleString()}`,tooltip:`${r.eventsStatus.failed?.toLocaleString()} failed events`})]}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",distribution:"end",flex:1,spacing:n.token("--t-spacing-half"),marginLeft:"auto",children:[r.createdBy?.avatarUrl&&e.jsx(i.Avatar,{width:n.token("--t-element-size-md"),height:n.token("--t-element-size-md"),basis:n.token("--t-element-size-md"),source:r.createdBy.avatarUrl},c),e.jsx(i.Text,{size:n.token("--t-font-size-sm"),truncate:!0,children:c})]})]}),e.jsx(re,{open:p.historyVisible,onRequestClose:()=>h({filter:null,historyVisible:!1}),theme:s,children:e.jsx(ie,{automation:r,triggerResource:o.resource,filterWhere:p.filter,onEventsStatusChange:function(e){l(t=>({...t,eventsStatus:e}))}})})]})}function be(){const{automation:t,trigger:r}=a.useContext(ce),{name:s,description:l}=je(t.description),c=t.active?void 0:.5,d=["When a person",o.lowerFirst(r.event.description)+",","then",o.lowerFirst(s),ke(t)].join(" ");return e.jsxs(i.StackView,{paddingVertical:n.token("--t-spacing-2"),flex:1,opacity:c,children:[e.jsx(i.Heading,{level:3,size:n.token("--t-font-size-xl"),weight:n.token("--t-font-weight-bold"),marginBottom:n.token("--t-spacing-half"),truncate:!0,children:s}),e.jsxs(i.StackView,{spacing:.75,children:[e.jsx(i.Text,{size:n.token("--t-font-size-sm"),color:n.token("--t-text-color-default-primary"),lineHeight:"1.2",children:d}),e.jsx(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:o.truncate(ye(l),{length:160,separator:" "})})]})]})}function ke(e){return e?.triggerParams?.useTriggerPersonOverride?"(also applies to joint donor)":""}function je(e){const t=/^(.+?)\(([^()]*?)\)$/.exec(e);return t?{description:t[2],name:t[1].trim()}:{name:e}}function ye(e){return e?.startsWith("[archived]")?e.replace("[archived]","[Archived]"):e}const Se=function(){try{return Promise.resolve(_e.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)}},Ce=function(e){try{const t=o.compact(o.uniq(e.map(e=>e.createdById)));return Promise.resolve(function(n,i){try{var a=Promise.resolve(_e.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)}},ze=new t.Client({app:"webhooks",version:"2022-10-20"}),_e=new t.Client({app:"people"});function Pe({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 Te=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}=R(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)?Fe:t[e]?.includes(i)?Ve:Ie)({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)}},Oe=function(e){try{return Promise.resolve(Ae.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)}},Ae=new t.Client({app:"webhooks",version:"2022-10-20"});function Ve({appName:e,resourcePath:t,resourceType:n,ids:i}){return Le({appName:e,params:{where:{id:i.join(",")}},path:t,resourceType:n})}function Ie({appName:e,resourcePath:t,resourceType:n,ids:i}){return i.map(i=>Le({appName:e,path:`${t}/${i}`,resourceType:n}))}function Fe(e){return new Promise((e,t)=>{t()})}function Le({appName:e,path:n,resourceType:i,params:a={}}){const r=new t.Client({app:e}),s=o.upperFirst(H(i));return r.get({data:{fields:{[s]:["name","name_or_description"]},...a},url:n})}function $e({encryptedParam:t,trigger:r}){const[s,l]=a.useState(!0),[c,d]=a.useState();a.useEffect(()=>{Se().then(e=>{Oe(t).then(Ce).then(Pe).then(_).then(Te).then(({automations:t,triggerResources:n})=>function({automations:e,triggerResources:t,operationApps:n}){return e.map(e=>{const{appName:i,resourceType:a,resourceId:r}=R(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 s=t.find(e=>e.id.toString()==r.toString()),l=s?s.name||s.nameOrDescription:`[Hidden ${o.upperFirst(H(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}=R(e.triggerResource);if(!n){const e=o.truncate(t,{length:160,separator:" "});return`When the automation is triggered from ${H(i)} "${e}"`}return`When a person ${n} ${H(i)} "${t}"`}(e,l),e.canManage=!!s,e})}({automations:t,operationApps:e,triggerResources:n})).then(d).then(()=>l(!1))})},[t]);const u=!s&&0===c.length;return e.jsxs(e.Fragment,{children:[e.jsx(i.Box,{borderBottom:`1px solid ${n.token("--t-border-color-default-base")}`,marginBottom:n.token("--t-spacing-2"),marginHorizontal:-3,marginTop:r?12:0,paddingHorizontal:n.token("--t-spacing-3"),paddingVertical:n.token("--t-spacing-2"),children:e.jsx(i.Heading,{color:n.token("--t-text-color-default-headline"),level:2,size:n.token("--t-font-size-lg"),children:s?"Incoming automations":D(c.length,"incoming automation")})}),u?e.jsx(i.Text,{color:n.token("--t-text-color-default-secondary"),marginVertical:n.token("--t-spacing-3"),children:"Automations that perform actions on this resource will be listed here."}):s?e.jsx(i.Summary,{image:e.jsx(i.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading incoming automations..."}):e.jsx(i.TileView,{spacing:n.token("--t-spacing-3"),marginVertical:n.token("--t-spacing-3"),minCellWidth:45,children:c.map(t=>e.jsx(ue,{automation:t},t.id))})]})}function Be(e){return`OPERATION_${e.definitionClass}${e.definitionIdentifier||""}`}function De(e){return`SECTION_${e}`}function He(t){return t.map(({label:t,value:n})=>e.jsx(i.Select.Option,{value:n,children:t},n))}function Re(t){const n=o.groupBy(t,"group");return Object.keys(n).sort().map(t=>"null"===t?He(n[t]):e.jsx(i.Select.OptionGroup,{title:t,children:He(n[t])},t))}const Ne=({selectedOperation:t,onOperationDefinitionChange:a,operationDefinitions:r})=>{const s=t?.section,l=r.map(e=>({...e,id:Be(e)})),c=l.filter(e=>null===e.section),d=o.uniqBy(r,"section").filter(e=>!!e.section).map(e=>({group:e.sectionGroup,label:e.section,value:De(e.section)})),u=s?l.filter(e=>e.section===s):[];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":a(r.find(t=>De(t.section)===e));break;case"operation":a(r.find(t=>Be(t)===e));break;case null:a(null)}}function h(e){return Re(e.map(e=>({group:e.group,label:e.description,value:e.id})))}return e.jsxs(i.StackView,{spacing:n.token("--t-spacing-1"),children:[e.jsxs(i.Select,{emptyValue:"Select an action",id:"select-action",onChange:p,size:"lg","data-testid":"operation-select",children:[h(c),Re(d)]}),u.length>0&&e.jsx(i.Select,{defaultValue:u[0].id,onChange:p,size:"lg",children:h(u)})]})},We=({canAccessPeople:t,field:r,onChange:s,value:l,selectedFieldOptions:c,loadListForField:d,loadedLists:u,loadingLists:p})=>{const h=function(e){const[t,n]=a.useState(e);return a.useEffect(()=>{const i=e();o.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[o.camelCase(n)]=t[n]),e),{})}({field:r,selectedFieldOptions:c}));a.useEffect(()=>{r.listClass&&d({dependencies:h,field:r})},[r,h,d]);const m=r.list||u[O(r)]||[],g=m.filter(e=>!e.automationNotAllowed),w=r.listClass&&p[O(r)];return e.jsxs(i.StackView,{marginBottom:2,spacing:.5,children:[e.jsxs(i.Input.InputLabel,{color:n.token("--t-text-color-default-headline"),fontSize:n.token("--t-font-size-sm"),fontWeight:n.token("--t-font-weight-medium"),controls:r.id,children:[r.description,r.info&&e.jsx(i.HelperDrawer.Toggle,{drawerId:`${r.id}_help`,marginLeft:1})]}),e.jsx(i.Box,{children:w?e.jsx(Ke,{}):function(){switch(r.kind){case"Select":return e.jsx(Ee,{fieldId:r.id,listOptions:g,onChange:s,value:l,description:r.description});case"SelectSearch":return e.jsx(Me,{fieldId:r.id,listOptions:g,onChange:s,value:l});case"Checkbox":return e.jsx(Ue,{field:r,value:l,onChange:s});case"TextArea":return e.jsx(Ye,{field:r,onChange:s,value:l});case"DateField":return e.jsx(Ze,{field:r,onChange:s,value:l});case"Checkboxes":return e.jsx(Qe,{fieldId:r.id,options:g,onChange:s});case"NumberField":return e.jsx(Ge,{field:r,onChange:s,value:l});case"PersonSearch":return e.jsx(qe,{canAccessPeople:t,field:r,onChange:s,listOptions:m,isLoading:p[O(r)],loadListForField:d,value:l});case"TextField":return e.jsx(Je,{field:r,onChange:s,value:l});case"RadioButtons":return e.jsx(Xe,{field:r,options:m,onChange:s,value:l});case"StaticText":return e.jsx(i.Text,{dangerouslySetInnerHTML:{__html:r.content}});default:return console.warn(`Unknown field kind "${r.kind}"`),null}}()}),r.info&&e.jsx(i.HelperDrawer,{id:`${r.id}_help`,marginTop:n.token("--t-spacing-half"),children:e.jsx(i.Box,{dangerouslySetInnerHTML:{__html:r.info}})})]})},Ee=({fieldId:t,listOptions:n,onChange:a,value:r,description:s})=>{const l=n?.find(e=>"no-option"===e.value),c=o.groupBy(n,"group"),d=Object.keys(c).sort(),u=()=>d.map(t=>"null"===t||"undefined"===t?p(c[t]):e.jsx(i.Select.OptionGroup,{title:t,children:p(c[t])},t)),p=t=>t.map(t=>e.jsx(i.Select.Option,{value:t.value.toString(),disabled:t.disabled,children:t.description},t.value));return e.jsx(i.Select,{id:t,onChange:({selectedValue:e})=>{a({fieldId:t,value:e})},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})(s?.toLowerCase()),size:"lg",value:r||l?.value||null,placement:"bottom-start",children:u()})},Me=({fieldId:t,listOptions:r,onChange:s,value:l})=>{const c=r.find(e=>e.value?.toString()===l),d=c?.description||"",[u,p]=a.useState(""),[h,m]=a.useState(d),[g,w]=a.useState(!1),[f,x]=a.useState(!1);d!==u&&(p(d),m(d),w(!1));let v=o.sortBy(o.uniqBy(r,"value"),"group");if(g){const e=h.toLowerCase();v=v.filter(t=>`${t.description} ${t.group}`.toLowerCase().includes(e))}return e.jsx(i.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},css:{"[role='combobox']":{cursor:r.length>0?"pointer":"not-allowed"}},cursor:"pointer",disabled:0===r.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:e=>{(e=>{s({fieldId:t,value:e})})(e.value),m(e.description),w(!1),x(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:r.length>0?"Select an option":"No options available",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:e.jsx(i.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(i.Icon,{name:"general.downCaret"}),size:"lg",value:h,children:r.length>0&&e.jsx(e.Fragment,{children:v.length>0?v.map((t,a)=>{const r=t.value.toString()===l;return e.jsxs(i.Combobox.Item,{"aria-label":t.description,disabled:t.disabled,index:a,paddingLeft:4.25,renderLeft:e.jsx(i.Icon,{marginLeft:-.5,name:r?"general.check":"",size:"sm"}),role:"option",spacing:n.token("--t-spacing-1"),value:{description:t.description,value:t.value.toString()},children:[e.jsx(i.Text,{truncate:!0,children:e.jsx(i.Highlight,{text:t.description,query:h})}),t.group&&e.jsx(i.Badge,{title:e.jsx(i.Highlight,{text:t.group,query:h}),size:"sm",marginLeft:"auto"})]},t.value)}):e.jsx(i.Menu.Item,{children:e.jsxs(i.Text,{children:['No results for "',h,'"']})})})})},qe=({canAccessPeople:t,field:r,isLoading:s,listOptions:l,loadListForField:c,onChange:d,value:u})=>{const p=a.useCallback(e=>{c({dependencies:{query:e},field:r})},[c]),h=a.useMemo(()=>o.debounce(p,300),[p]),m=a.useCallback(e=>{t&&(e.trim().length>0?h(e):h.cancel())},[h]),g=a.useMemo(()=>({description:"Myself",value:"self"}),[]),w=a.useMemo(()=>t?l:[g],[g,l]).find(e=>e.value===u),f=w?.description||"",[x,v]=a.useState(f),[b,k]=a.useState(!1);function j(e){v(e),m(e),0===e.trim().length&&y(null)}const y=e=>{d({fieldId:r.id,value:e})};return e.jsx(i.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?e.jsx(i.Avatar,{size:"sm",source:w.meta.avatar}):e.jsx(i.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(i.Icon,{name:"general.downCaret"}),size:"lg",value:x,children:t?x.trim().length>0?l.length>0?l.map((t,a)=>e.jsx(i.Combobox.Item,{"aria-label":t.description,index:a,paddingLeft:4.25,renderLeft:e.jsx(i.Avatar,{marginLeft:-.5,source:t.meta.avatar,size:"sm"}),role:"option",spacing:n.token("--t-spacing-1"),value:t,children:e.jsx(i.Text,{truncate:!0,children:e.jsx(i.Highlight,{text:t.description,query:x})})},t.value)):e.jsx(i.Combobox.Item,s?{children:e.jsx(i.Text,{children:"Loading..."})}:{children:e.jsx(i.Text,{children:"No results"})}):e.jsx(i.Combobox.Item,{children:e.jsx(i.Text,{children:"Type to search"})}):e.jsx(i.Combobox.Item,{value:g,index:0,role:"option",children:e.jsx(i.Text,{children:g.description})})})},Ue=({field:t,value:n,onChange:a})=>e.jsx(i.Checkbox,{disabled:t.disabled,label:t.label,checked:n||!1,onChange:e=>{a({fieldId:t.id,value:e.target.checked})}}),Ye=({field:t,value:n,onChange:a})=>e.jsx(i.Box,{children:e.jsx(i.TextArea,{value:n,placeholder:t.placeholder,onChange:e=>{a({fieldId:t.id,value:e.target.value})},size:"lg"})}),Ze=({field:t,value:n,onChange:r})=>{const{dateFormat:o}=a.useContext(j),[s,l]=a.useState(!1),c=t.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]=a.useState(f.default(n).toDate()),m=t.allowUnansweredOption??!1;return e.jsxs(i.StackView,{axis:"horizontal",children:[e.jsxs(i.Select,{onChange:({selectedValue:e})=>{e===c||e===d?(l(!1),r({fieldId:t.id,value:e})):"specific-date"===e?(r({fieldId:t.id,value:null}),l(!0)):(l(!1),r({fieldId:t.id,value:null}))},size:"lg",placement:"bottom-start",children:[e.jsx(i.Select.Option,{value:c,children:c}),!t.customValue&&e.jsx(i.Select.Option,{value:d,children:d}),e.jsx(i.Select.Option,{value:"specific-date",children:"A specific date"}),m&&e.jsx(i.Select.Option,{value:"unanswered",children:"Unanswered"})]}),s&&e.jsx(i.Box,{children:e.jsx(i.DateField,{defaultOpen:!0,formatValue:u,marginLeft:1,onChange:e=>{r({fieldId:t.id,value:B(e,o)}),h(e)},size:"lg",value:p})})]})},Qe=({fieldId:t,options:n,onChange:r})=>{const[o,s]=a.useState({});return e.jsx(i.StackView,{spacing:1,children:n.map(n=>e.jsxs(i.Box,{children:[e.jsx(i.Input.InputLabel,{controls:`checkboxes_${t}_${n.value}`,children:n.description||n.value}),e.jsxs(i.Select,{id:`checkboxes_${t}_${n.value}`,onChange:({selectedValue:e})=>((e,n)=>{const i={...o};i[n]=e,s(i),r({fieldId:t,value:i})})(e,n.value),size:"lg",emptyValue:"Don't change",children:[e.jsx(i.Select.Option,{value:"check",children:"Check"}),e.jsx(i.Select.Option,{value:"uncheck",children:"Uncheck"})]})]},n.value))})},Ge=({field:t,onChange:r,value:o})=>{const s=t.minValue>=0?t.minValue:1,l=t.maxValue>=1&&t.maxValue<=365?t.maxValue:365,[c,d]=a.useState(Number(t.defaultValue)||1);return a.useEffect(()=>{r({fieldId:t.id,value:t.defaultValue||1})},[t]),e.jsxs(i.StackView,{children:[e.jsx(i.Input.InputBox,{children:e.jsx(i.NumberField,{onChange:e=>{const n=Number(e)||0;d(n),r({fieldId:t.id,value:Math.min(Math.max(n,s),l)})},placeholder:t.placeholder,size:"lg",value:o,min:s,max:l,hasControls:!0})}),c>l&&e.jsx(i.Alert,{type:"error",paddingHorizontal:n.token("--t-spacing-1"),paddingVertical:n.token("--t-spacing-half"),display:"inline-block",marginTop:1.5,children:e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsx(i.Icon,{name:"general.exclamationTriangle",size:"sm",color:"delete45"}),e.jsxs(i.Text,{size:n.token("--t-font-size-md"),children:["Value cannot exceed ",l,"."]})]})})]})},Je=({field:t,value:n,onChange:a})=>e.jsx(i.Box,{children:e.jsx(i.Input,{size:"lg",value:n,id:t.id,placeholder:t.placeholder,onChange:e=>{a({fieldId:t.id,value:e.target.value})}})}),Xe=({field:t,options:n,onChange:a,value:r})=>{const o=e=>{a({fieldId:t.id,value:e.target.value})};return e.jsx(i.StackView,{marginTop:1,spacing:.5,children:n.map(t=>e.jsx(i.Radio,{checked:r===t.value,label:t.description||t.value,onChange:o,size:"md",value:t.value},t.value))})},Ke=()=>e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:n.token("--t-spacing-1"),radius:n.token("--t-border-radius-md"),border:`1px solid ${n.token("--t-border-color-default-base")}`,children:[e.jsx(i.Spinner,{size:"xs"}),e.jsx(i.Text,{fontSize:n.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]}),et=({canAccessPeople:t,definitionFields:n,onChange:i,selectedFieldOptions:r,loadListForField:o,loadedLists:s,loadingLists:l})=>{a.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=F(n,r),d=({fieldId:e,value:t})=>{const a={...r},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 a[e.id],delete a[t.id],void 0!==t.defaultValue&&void 0===a[t.id]&&(a[t.id]=t.defaultValue)}}),"no-option"===t?delete a[e]:a[e]=t,i({...a})};return n.length?e.jsx("div",{children:c.map(n=>e.jsx(We,{canAccessPeople:t,field:n,onChange:d,value:r[n.id],selectedFieldOptions:r,loadListForField:o,loadedLists:s,loadingLists:l},n.id))}):null},tt=function(e){try{return Promise.resolve(rt.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)}},nt=function(){try{return Promise.resolve(rt.get({data:{fields:{OperationApp:"name"}},url:"/operation_apps"}).then(({data:e})=>e.map(e=>e.name)))}catch(e){return Promise.reject(e)}},it=function(){try{return Promise.resolve(at.get({data:{fields:{Topbar:"apps"}},url:"/me/topbar"}).then(({data:e})=>e.apps.map(e=>e.name)))}catch(e){return Promise.reject(e)}},at=new t.Client({app:"people",env:window.railsEnv,version:"LATEST"}),rt=new t.Client({app:"webhooks",env:window.railsEnv,version:"LATEST"}),ot={css:{borderRadius:n.token("--t-border-radius-md")},paddingHorizontal:1.75,paddingVertical:1.25,type:"error"},st=({afterCreateOptions:t,blankStateLink:r,debugMode:s=!1,defaultApp:l,description:c,onRequestClose:d,trigger:u})=>{const[p,h]=a.useState(u.events[0]),[m,g]=a.useState({}),[w,f]=a.useState(l),[x,v]=a.useState([]),[b,k]=a.useState([]),[j,y]=a.useState(!0),[S,C]=a.useState(),[_,P]=a.useState({}),[T,V]=a.useState({}),[I,F]=a.useState({}),[$,B]=a.useState(!1),[D,H]=a.useState({}),[R,N]=a.useState(!1),[W,E]=a.useState({}),M=a.useRef(null),q=a.useMemo(()=>x.map(e=>e.id).includes("people"),[x]),U=S?.definitionIdentifier,Y="danger"===S?.footerMessage?.kind,Z=a.useCallback(({field:e,dependencies:t})=>{F(t=>({...t,[O(e)]:!0})),function({app:e,field:t,definitionIdentifier:n,dependencies:i}){try{return"PersonSearch"===t.kind?Promise.resolve(at.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(rt.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=>{V(n=>({...n,[O(e)]:t})),F(t=>({...t,[O(e)]:!1}))}).catch(e=>H({selected_definition:e}))},[w,U]);a.useEffect(()=>{H({}),function(){try{return Promise.resolve(Promise.all([it(),nt()])).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),tt(t).then(e=>{M.current||(k(e),y(!1))}).catch(e=>H({definitions:e}))})},[l]),a.useEffect(()=>{H({})},[_]);const Q=o.cloneDeep("conditions"in p?p.conditions:u.conditions);for(const e in m)o.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:L({loadedLists:n||{},selectedDefinition:e,selectedFieldOptions:t}),name:(i=e,A(i)||i.description)};var i}({loadedLists:T,selectedDefinition:S,selectedFieldOptions:_});let t=e.name;return e.description&&(t+=` (${e.description})`),t}function X(e){B(!0),rt.post({data:e,url:"/me/automation_subscriptions"}).then(()=>{t?.onConfirm&&R?(d(),t.onConfirm({...e})):window.location.reload()}).catch(e=>{B(!1),e.errors?H({automation:e.errors}):alert("something even worse happened!")})}return e.jsxs(i.StackView,{paddingTop:4,spacing:2,children:[c&&e.jsx(i.Box,{children:e.jsxs(i.Text,{style:{color:n.token("--t-text-color-default-primary"),fontSize:n.token("--t-font-size-md"),lineHeight:1.65,marginBottom:n.token("--t-spacing-2")},children:[c," ",e.jsx(i.Link,{external:!0,to:r,children:"Learn more"})]})}),D.automation&&e.jsx(i.Alert,{...ot,children:e.jsx(i.Text,{children:"There was an error creating your automation. Please change your selections and try again or contact support if the problem persists."})}),e.jsxs(i.StackView,{spacing:1,children:[e.jsx(i.Input.InputLabel,{color:n.token("--t-text-color-default-primary"),controls:"select-trigger-event",fontSize:n.token("--t-font-size-md"),fontWeight:n.token("--t-font-weight-medium"),children:"When a person..."}),e.jsx(i.Select,{id:"select-trigger-event",onChange:({selectedValue:e})=>(e=>{h(e),g({})})(e),size:"lg",value:p,children:u.events.map((t,n)=>e.jsx(i.Select.Option,{value:t,children:t.description},`${t.name}_${n}`))}),G?.length>0&&e.jsx(et,{canAccessPeople:q,definitionFields:G,selectedFieldOptions:m,onChange:g,loadedLists:{},loadingLists:{},loadListForField:()=>null})]}),e.jsxs(i.StackView,{spacing:1,children:[x.length>0?e.jsx(pt,{selectedApp:w,operationApps:x,onOperationAppChange:e=>{f(e),y(!0),k([]),M.current=e,C(null),P({}),H({}),tt(e).then(k).then(()=>y(!1)).catch(e=>H({definitions:e}))}}):e.jsxs(i.StackView,{spacing:1,children:[e.jsx(i.Text,{color:n.token("--t-text-color-default-headline"),fontSize:n.token("--t-font-size-md"),fontWeight:n.token("--t-font-weight-medium"),children:"Then perform an action in..."}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:n.token("--t-spacing-1"),radius:4,border:`1px solid ${n.token("--t-border-color-default-base")}`,children:[e.jsx(i.Spinner,{size:"xs"}),e.jsx(i.Text,{fontSize:n.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]})]}),D.definitions?e.jsx(i.Alert,{marginTop:n.token("--t-spacing-1"),...ot,children:e.jsx(i.Text,{children:"There was a problem looking up automations. Please contact support if the problem persists."})}):j?e.jsx(ht,{}):e.jsx(Ne,{selectedOperation:S,operationDefinitions:b,onOperationDefinitionChange:e=>{C(e),H({}),P({})}})]}),S&&(D.selected_definition?e.jsx(i.Alert,{...ot,children:e.jsx(i.Text,{children:"There was a problem looking up automation options. Please contact support if the problem persists."})}):e.jsxs(e.Fragment,{children:[e.jsx(et,{canAccessPeople:q,definitionFields:S.definitionFields||[],onChange:P,selectedFieldOptions:_,loadedLists:T,loadListForField:Z,loadingLists:I}),t?.label&&e.jsx(i.Checkbox,{disabled:$||lt(S,_),label:t.label,checked:R,onChange:()=>N(!R)}),p?.triggerParams?.map((t,n)=>e.jsx(i.Checkbox,{label:t.description,checked:W&&W[t.key]||t.defaultValue,onChange:e=>{E(n=>({...n,[`${t.key}`]:e.target.checked}))}},`${t.key}_${n}`)),Y&&e.jsx(i.Alert,{...ot,children:e.jsxs(i.StackView,{axis:"horizontal",spacing:1.5,children:[e.jsx(i.Icon,{size:n.token("--t-element-size-lg"),name:"general.exclamationTriangle",color:n.token("--t-icon-color-status-error-primary")}),e.jsx(i.Text,{dangerouslySetInnerHTML:{__html:S.footerMessage?.html}})]})})]})),s&&e.jsx("pre",{children:JSON.stringify({description:S&&J(),loadedLists:T,selectedDefinition:S,selectedFieldOptions:_,triggerConditions:Q},null,4)}),e.jsxs(i.StackView,{alignment:"center",axis:"horizontal",borderTop:`1px solid ${n.token("--t-border-color-default-base")}`,distribution:"end",marginTop:2,marginHorizontal:-4,paddingHorizontal:4,paddingTop:3,spacing:2,children:[e.jsx(i.Button,{color:n.token("--t-text-color-default-headline"),"data-modal-close":!0,fontWeight:n.token("--t-font-weight-normal"),onClick:d,size:"md",title:"Cancel",variant:"naked"}),e.jsx(i.Button,{disabled:$||Y||lt(S,_),onClick:function(){if($)return;const e={..._};S.definitionIdentifier&&(e.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:e,trigger_conditions:Q,trigger_params:W},type:"AutomationSubscription"}};R?z.fire({cancelButtonText:"Cancel",confirmButtonText:"Yes, perform action",text:"This will happen immediately after creating your new automation. Are you sure?",title:`${t.label}?`}).then(e=>{e.value?X(n):(B(!1),N(!1))}):X(n)},size:"md",theme:"primary",title:ut(S,_),variant:"fill","data-testid":"create-automation"})]})]})};function lt(e,t){if(e){const n=F(e.definitionFields,t),i=n.filter(e=>e.required),a=n.filter(e=>ct(e));return!i.every(e=>dt(e,t))||!a.every(e=>dt(e,t))}return!0}function ct(e){return"Select"===e.kind||"SelectSearch"===e.kind}function dt(e,t){return ct(e)?t.hasOwnProperty(e.id):t.hasOwnProperty(e.id)&&t[e.id]&&""!==t[e.id].toString().trim()}function ut(e,t){const n=function(e,t){if(!e?.definitionFields)return;const n=F(e.definitionFields,t);for(const e of n)if(e.required&&!dt(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 pt=({onOperationAppChange:t,operationApps:a,selectedApp:r})=>e.jsxs(i.StackView,{spacing:1,children:[e.jsx(i.Input.InputLabel,{color:n.token("--t-text-color-default-headline"),controls:"select-product",fontSize:n.token("--t-font-size-md"),fontWeight:n.token("--t-font-weight-medium"),children:"Then perform an action in..."}),e.jsx(i.Select,{autoFocus:!0,id:"select-product",onChange:({selectedValue:e})=>{t(e)},size:"lg",value:r,children:a.map(t=>e.jsx(i.Select.Option,{value:t.id,children:t.name},t.id))})]}),ht=()=>e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:n.token("--t-spacing-1"),radius:n.token("--t-border-radius-md"),border:`1px solid ${n.token("--t-border-color-default-base")}`,children:[e.jsx(i.Spinner,{size:"xs"}),e.jsx(i.Text,{fontSize:n.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]});function mt({onClick:t}){return e.jsx(i.Button,{as:"button",height:n.token("--t-element-size-md"),icon:{color:n.token("--t-icon-color-default-dim"),name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function gt({children:t,onRequestClose:a,open:r,theme:o}){/*#__PURE__*/return d.createPortal(e.jsxs(i.ThemeProvider,{theme:o,children:[e.jsxs(i.Modal,{open:r,onRequestClose:a,maxWidth:75,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:n.token("--t-spacing-4"),paddingBottom:n.token("--t-spacing-3"),radius:n.token("--t-border-radius-lg"),zIndex:10009,children:[e.jsxs(i.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(i.Heading,{level:2,color:n.token("--t-text-color-default-headline"),fontWeight:n.token("--t-font-weight-medium"),fontSize:n.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Create automation"}),e.jsx(mt,{onClick:a})]}),t]}),e.jsx("style",{children:"\n .swal2-container.swal2-backdrop-show { z-index: 10001 }\n "})]}),document.body)}const wt={churchCenter:v,services:b},ft=new t.Client({app:"webhooks",version:"2022-10-20"});function xt({afterCreateOptions:t,automations:r,blankStateLink:o,canCreate:s,defaultApp:l,description:c,hasActiveAutomations:d,loading:u,onPauseAutomations:p,theme:h,trigger:m}){const[g,w]=a.useState(!1),f=s&&!d,x=r.filter(e=>e.active).length,v=r.filter(e=>!e.active).length;return e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",backgroundColor:f?n.token("--t-fill-color-status-warning-ghost"):void 0,borderBottom:f?void 0:`1px solid ${n.token("--t-border-color-default-base")}`,"data-testid":"automations-header",distribution:"space-between",marginHorizontal:-3,marginBottom:n.token("--t-spacing-2"),marginTop:-3,paddingHorizontal:n.token("--t-spacing-3"),paddingVertical:n.token("--t-spacing-2"),spacing:n.token("--t-spacing-2"),wrap:!0,zIndex:2,children:[s&&!d?e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",marginHorizontal:1,spacing:1,children:[e.jsx(i.Icon,{size:2,color:n.token("--t-icon-color-status-warning-primary"),name:"general.exclamationTriangle"}),e.jsx(i.Heading,{color:n.token("--t-text-color-default-headline"),level:2,size:n.token("--t-font-size-lg"),children:"Automations are currently paused"})]}):e.jsxs(i.Heading,{color:n.token("--t-text-color-default-headline"),level:2,size:n.token("--t-font-size-lg"),children:[u?"Active automations":D(x,"active automation"),v>0?` (${v} paused)`:""]}),s&&(d?e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),children:[r.length>0&&e.jsx(i.Button,{onClick:p,variant:"outline",children:"Pause automations"}),e.jsx(i.Button,{theme:"primary",variant:"fill",onClick:()=>w(!0),children:"Create automation"}),e.jsx(gt,{open:g,onRequestClose:()=>w(!1),theme:h,children:e.jsx(st,{description:c,blankStateLink:o,defaultApp:l,trigger:m,onRequestClose:()=>w(!1),afterCreateOptions:t})})]}):e.jsx(i.Box,{children:e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[e.jsx(i.Button,{onClick:p,theme:"primary",variant:"outline",children:"Enable automations"}),e.jsx(i.Button,{theme:"primary",disabled:!0,tooltip:{title:"Automations must be enabled to create new ones"},children:"Create automation"})]})}))]})}exports.Automations=function({afterCreateOptions:t,blankStateDescription:r,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:f="Not allowed"}){a.useEffect(()=>{if(!p)return S(!1);(function(e){try{return Promise.resolve(ze.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(Ce).then(Pe).then(_).then(v).then(()=>S(!1))},[p?.resource]);const[x,v]=a.useState([]),[b,S]=a.useState(!0),[C,z]=a.useState(!1),{dateFormat:P,twentyFourHourTime:T,olsonTimeZone:O}=h,A=new URLSearchParams(window.location.search).get("automation_id"),V={...u,icons:{...wt}};a.useEffect(()=>{document.body.toggleAttribute("data-loading-automations",b)},[b]);const I=!x.length||x.some(e=>e.active);function F(e){ft.delete({data:{_e:p.resource},url:`/automation_subscriptions/${e}`}).then(()=>v(x.filter(t=>t.id!==e))).catch(e=>{const t=N(e,"delete")||"There was a problem deleting this automation. Please try again in a few moments.";y.fire({text:t,title:"Uh oh!"})})}const L={color:n.token("--t-text-color-default-primary"),level:2,size:n.token("--t-font-size-2xl"),weight:n.token("--t-font-weight-bold")},$={color:n.token("--t-text-color-default-secondary"),lineHeight:3,size:n.token("--t-font-size-md")};return e.jsxs(i.ThemeProvider,{theme:V,children:[e.jsxs(j.Provider,{value:{dateFormat:P,olsonTimeZone:O,twentyFourHourTime:T},children:[p&&e.jsx(xt,{automations:x,blankStateLink:o,canCreate:l&&!g,loading:b,defaultApp:c,description:r,theme:V,trigger:p,hasActiveAutomations:I,onPauseAutomations:function(){ft.post({data:{data:{attributes:{_e:p.resource,active:!I}}},url:"/pause_automations"}).then(()=>{window.location.reload()})},afterCreateOptions:t}),b?e.jsx(i.Summary,{image:e.jsx(i.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading automations..."}):p?e.jsx(i.Box,{"data-testid":"automations-section",children:x?.length>0?e.jsx(i.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:w.default(x,"id").map(t=>{return e.jsx(de,{automation:t,updateAutomation:(i=t,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:t.id===Number(A),trigger:{event:(n=t,p.events.find(e=>e.name===n.name)),resource:p.resource},currentPersonId:s,currentPersonCanCreate:l,disabled:g,disabledReason:f},t.id);var n,i})}):e.jsxs(i.StackView,{margin:n.token("--t-spacing-6"),spacing:n.token("--t-spacing-2"),alignment:"center",mediaQueries:{lg:{axis:"horizontal",distribution:"center",spacing:n.token("--t-spacing-6")}},children:[e.jsx(i.Box,{css:{".symbol":{height:"100%",width:"100%"}},maxWidth:24,mediaQueries:{lg:{maxWidth:40}},children:e.jsx(k,{})}),e.jsx(i.StackView,{alignment:"center",spacing:n.token("--t-spacing-1"),maxWidth:45,mediaQueries:{lg:{alignment:"start",textAlign:"left"}},textAlign:"center",children:e.jsxs(e.Fragment,l?{children:[e.jsx(i.Heading,{...L,children:"Add an automation"}),e.jsx(i.StackView,{alignment:"center",marginBottom:n.token("--t-spacing-1"),mediaQueries:{lg:{alignment:"start"}},spacing:1,children:e.jsx(i.Text,{...$,children:r})}),e.jsxs(i.StackView,{axis:"horizontal",spacing:n.token("--t-spacing-1"),children:[e.jsx(i.Button,{variant:"outline",to:o,color:`${n.token("--t-text-color-status-neutral")} !important`,children:"Learn more"}),e.jsx(i.Button,{as:"button",theme:"primary",variant:"fill",onClick:()=>z(!0),children:"Create automation"})]}),e.jsx(gt,{open:C,onRequestClose:()=>z(!1),theme:V,children:e.jsx(st,{defaultApp:c,description:r,blankStateLink:o,onRequestClose:()=>z(!1),trigger:p,afterCreateOptions:t})})]}:{children:[e.jsx(i.Heading,{...L,children:"Automations"}),e.jsx(i.Text,{...$,children:m})]})})]})}):e.jsx(e.Fragment,{}),d&&e.jsx($e,{encryptedParam:d,trigger:p})]}),e.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
|
+
var e=require("react/jsx-runtime"),t=require("@planningcenter/api-client"),n=require("@planningcenter/tapestry"),i=require("@planningcenter/tapestry-react"),a=require("react"),o=require("lodash/sortBy"),r=require("lodash"),s=require("moment"),l=require("@planningcenter/sweetalert2"),c=require("sweetalert2/dist/sweetalert2"),d=require("react-dom"),u=require("@planningcenter/icons/paths/church-center"),p=require("@planningcenter/icons/paths/logomark"),h=require("@planningcenter/icons/paths/services");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(a),f=/*#__PURE__*/m(o),x=/*#__PURE__*/m(s),v=/*#__PURE__*/m(c),b=/*#__PURE__*/g(u),k=/*#__PURE__*/g(p),j=/*#__PURE__*/g(h);const y=()=>e.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:[e.jsx("title",{children:"Automations"}),e.jsx("g",{opacity:"0.6",children:e.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"})}),e.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"}),e.jsx("path",{d:"M68.479,13.633v9.8a2.035,2.035,0,0,0,2.035,2.034h9.877Z",fill:"#c9d8e2"}),e.jsx("rect",{x:"51.214",y:"41.285",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"48.434",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"34.136",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"}),e.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"})]}),S=/*#__PURE__*/a.createContext({dateFormat:null,olsonTimeZone:null,twentyFourHourTime:null});v.default.mixin(l.standardAlertOptions),v.default.mixin(l.successAlertOptions);const C=v.default.mixin(l.errorAlertOptions),z=v.default.mixin(l.standardConfirmOptions),_=v.default.mixin(l.destroyConfirmOptions),P=v.default.mixin(l.createConfirmOptions),T=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(A.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(A.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`${O(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 O(e){return e.charAt(0).toUpperCase()+e.slice(1)}const A=new t.Client({app:"people",version:"2025-03-20"});function I(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 F(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function L({field:e,loadedLists:t}){if(e.list)return e.list;if(I(e))return t[I(e)];throw new Error(`Don't know how to get list for ${JSON.stringify(e)}`)}function $(e,t){return e.filter(e=>{if(Object.prototype.hasOwnProperty.call(e,"renderIf")){const n=e.renderIf,i=Object.keys(n)[0];return r.isBoolean(n)?n:n[i]===t[i]}return!0})}function B({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(!F(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=L({field:e,loadedLists:n}),a&&a.find(e=>e.value.toString()===i)?.description;case"Checkbox":return i&&e.label;case"Checkboxes":return a=L({field:e,loadedLists:n}),a.filter(e=>F(i,e.value)).map(e=>`${O(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 D(e){return e.replace(/%m/,"MM").replace(/%d/,"DD").replace(/%Y/,"YYYY").replace(/%y/,"YY")}function H(e,t){const n=x.default(e,"YYYY-MM-DD");if(!n.isValid())return"";const i=D(t);return n.format(i)}function R(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function N(e){return e.replace(/s$/,"")}function W(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 E(e,t){return"403"===e.errors?.[0]?.status?`You don't have permission to ${t||"modify"} this automation.`:null}const M=function(e){try{const t=e.data.map(e=>J(e));return Promise.resolve(function(n,i){try{var a=Promise.resolve(q(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)}},q=function(e){try{return Promise.resolve(Z.get({data:{fields:{Person:"id,name"},where:{id:e.join(",")}},url:"people"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},U=function(e,t,n){try{return Promise.resolve(Y.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)}},Y=new t.Client({app:"webhooks",version:"2022-10-20"}),Z=new t.Client({app:"people",version:"2022-07-14"}),Q={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 G({events:e,people:t}){const n=e.data.reduce((e,n)=>{const i=J(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 J(e){return e.personId}function X({automation:t,triggerResource:o,filterWhere:r,onEventsStatusChange:s}){const{events:l,loading:c,paginationProps:d,refresh:u,params:p,setParams:h}=function(e,t,n){const[i,o]=a.useState(),[r,s]=a.useState(!1),[l,c]=a.useState({}),[d,u]=a.useState(n?{where:{status:n}}:{}),[p,h]=a.useState(),{offset:m,paginationProps:g,resetOffset:w}=function(e,t){const[n,i]=a.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:a.useCallback(()=>{i(0)},[])}}(0,p?.totalCount);a.useEffect(()=>{r||l[m]||(s(!0),U(t,e,{offset:m,per_page:50,...d}).then(M).then(G).then(e=>{c(t=>({...t,[m]:e.data})),h(e.meta),s(!1)}).catch(x))},[e,t,r,d,m,l]);const f=a.useCallback(()=>{c({}),h(void 0),w()},[w]);function x(e){o(()=>{throw e})}return a.useEffect(()=>{f()},[f,d]),{events:l[m]||[],loading:r,paginationProps:g,params:d,refresh:f,setParams:u}}(t.id,o,r),{dateFormat:m,olsonTimeZone:g,twentyFourHourTime:w}=a.useContext(S),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")}(t.createdAt)<=32,b=H(t.createdAt,m),k=v?`Automation history started on ${b}`:"Automation history is saved for 32 days",j=[{cell:t=>e.jsx(te,{status:t.status}),css:{padding:"8px 12px"},header:"Status"},{cell:e=>x.default(e.createdAt).utcOffset(g).format(function({dateFormat:e,twentyFourHourTime:t}){return`${D(e)} ${t?"HH:mm":"h:mm A"}`}({dateFormat:m,twentyFourHourTime:w})),header:"Date and time"},{cell:t=>e.jsx(i.Link,{to:`/people/AC${t.person.id}`,children:t.person.name}),css:{maxWidth:"33%"},header:"Profile"},{cell:t=>e.jsx(ne,{event:t}),css:{flex:1},header:"Message"},{cell:n=>![...Q.delivered.value,...Q.pending.value].includes(n.status)&&e.jsxs(e.Fragment,{children:[e.jsx(K,{automationId:t.id,event:n,triggerResource:o,onEventsStatusChange:s}),![...Q.ignored.value].includes(n.status)&&e.jsx(ee,{automationId:t.id,event:n,triggerResource:o,refreshHistory:u,onEventsStatusChange:s})]}),css:{textAlign:"right"},header:"",minWidth:"84px"}];return e.jsxs(i.StackView,{spacing:n.token("--t-spacing-4"),children:[e.jsxs(i.StackView,{spacing:n.token("--t-spacing-half"),children:[e.jsx(i.Heading,{level:3,size:"16px",color:n.token("--t-text-color-default-secondary"),weight:n.token("--t-font-weight-medium"),children:t.description}),e.jsx(i.Text,{color:n.token("--t-text-color-default-secondary"),size:n.token("--t-font-size-xs"),italic:!0,children:k})]}),e.jsxs(i.StackView,{spacing:n.token("--t-spacing-2"),children:[e.jsx(i.Box,{minHeight:7,children:!c&&(l.length||f)&&e.jsxs(i.StackView,{alignItems:"end",axis:"horizontal",distribution:"space-between",spacing:n.token("--t-spacing-1"),children:[e.jsxs(i.StackView,{width:"max-content",children:[e.jsx(i.Input.InputLabel,{fontWeight:n.token("--t-font-weight-medium"),color:n.token("--t-text-color-default-primary"),controls:"select-status",children:"Filter by status"}),e.jsxs(i.Select,{id:"select-status",emptyValue:null,onChange:({selectedValue:e})=>{h({where:e?{status:e}:null})},title:"Status",value:p.where?.status,children:[e.jsx(i.Select.Option,{value:null,children:"All"}),Object.values(Q).map(t=>e.jsx(i.Select.Option,{value:t.value.join(","),children:t.label},t.value))]})]}),e.jsx(i.Button,{iconLeft:{name:"general.refresh"},onClick:u,theme:"primary",variant:"outline",width:12,children:"Refresh"})]})}),e.jsx(i.Box,{maxHeight:"70vh",minHeight:36,overflow:"auto",children:e.jsx(i.DataTable,{columns:j,data:l,empty:e.jsxs(i.StackView,{alignment:"center",distribution:"center",minHeight:20,maxWidth:45,spacing:n.token("--t-spacing-1"),marginTop:f?-4:-8,marginBottom:f?4:void 0,children:[e.jsx(i.Box,{css:{svg:{height:15,width:20}},children:e.jsx(y,{})}),e.jsx(i.Heading,{color:n.token("--t-text-color-default-headline"),fontWeight:n.token("--t-font-weight-medium"),level:4,size:n.token("--t-font-size-lg"),children:"No history found"}),e.jsxs(i.Text,{fontSize:n.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&&e.jsx(i.Button,{marginTop:n.token("--t-spacing-1"),onClick:()=>h({}),theme:"primary",title:"Clear filters",variant:"outline"})]}),loading:c,loadingTitle:"Loading automation history...",variant:{bodyCell:{alignItems:"start",fontSize:n.token("--t-font-size-sm"),lineHeight:"20px",padding:"10px 12px"},bodyRow:({rowData:e})=>({backgroundColor:[...Q.ignored.value].includes(e.status)?n.token("--t-fill-color-neutral-090"):void 0,minHeight:"36px"}),headerCell:{padding:"8px 12px"},headerRow:{minHeight:"36px"}},...d})})]})]})}function K({automationId:t,event:o,triggerResource:r,onEventsStatusChange:s}){const[l,c]=a.useState(o.status),d=Q.pending.value.includes(l)?"Sending":Q.delivered.value.includes(l)?"Sent":Q.skipped.value.includes(l)?"Run now":"Retry",u=Q.delivered.value.includes(l)?{color:n.token("--t-text-color-status-success"),name:"general.check"}:void 0;return e.jsx(i.Button,{title:d,onClick:function(){c(Q.pending.value.join(",")),Y.post({data:{_e:r,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${o.id}/redeliver`}).then(e=>{c(Q.delivered.value.join(",")),s(e.meta.eventsStatus)}).catch(()=>{c(Q.failed.value.join(",")),C.fire({text:"There was a problem retrying this automation. Please try again in a few moments.",title:"Uh oh!"})})},iconLeft:u,disabled:l!==o.status,variant:"naked",color:Q.delivered.value.includes(l)?n.token("--t-text-color-status-success"):Q.pending.value.includes(l)?n.token("--t-text-color-default-placeholder"):n.token("--t-text-color-interaction-primary"),theme:"primary",size:"xs"})}function ee({automationId:t,event:n,triggerResource:a,refreshHistory:o,onEventsStatusChange:r}){return e.jsx(i.Button,{title:"Ignore",onClick:function(){Y.post({data:{_e:a,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${n.id}/ignore`}).then(e=>{r(e.meta.eventsStatus)}).then(()=>o()).catch(()=>{C.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 te({status:t}){const a=Q.pending.value.includes(t)?{border:n.token("--t-border-color-default-dark"),text:n.token("--t-text-color-default-primary")}:Q.delivered.value.includes(t)?{border:n.token("--t-border-color-status-success"),text:n.token("--t-text-color-status-success")}:Q.skipped.value.includes(t)?{border:n.token("--t-border-color-status-warning"),text:n.token("--t-text-color-status-warning")}:Q.ignored.value.includes(t)?{border:n.token("--t-border-color-default-dark"),text:n.token("--t-text-color-default-secondary")}:{border:n.token("--t-border-color-status-error"),text:n.token("--t-text-color-status-error")},o=Q.pending.value.includes(t)?"general.clock":Q.skipped.value.includes(t)?"services.pause":Q.delivered.value.includes(t)?"general.checkCircle":Q.ignored.value.includes(t)?"general.inactive":"general.exclamationTriangle",r=Q.failed.value.includes(t)?Q.failed.label:Q.ignored.value.includes(t)?Q.ignored.label:Q[t].label;return e.jsx(i.Badge,{color:{background:"transparent",foreground:a.text},css:{paddingLeft:3.5,paddingRight:1.5},fontSize:n.token("--t-font-size-xs"),radius:"pill",renderLeft:e.jsx(i.Icon,{name:o,color:a.border,marginLeft:n.token("--t-spacing-1")}),size:"sm",stroke:a.border,strokeAlign:"inside",strokeWeight:1,title:r})}function ne({event:t}){const{status:a,lastDelivery:o}=t,r=function(t,n){let a=null;switch(t){case"skipped":case"ignored_skipped":a="Automation was paused and did not run on this profile";break;case"failed":case"duplicated":case"ignored_failed":case"ignored_duplicated":a=function(t,n){const a={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 e.jsx(i.StackView,{flex:1,whiteSpace:"normal",children:t?e.jsx(ie,{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}(t),status:t.status,children:a[t.status]||a.default}):["duplicated","ignored_duplicated"].includes(n)?a.duplicated_event:a.failed_without_deliveries})}(n,t)}return a}(a,o);return r?e.jsx(i.Box,{fontSize:n.token("--t-font-size-sm"),fontStyle:"italic",lineHeight:"16px",maxWidth:"100%",paddingTop:"1px",whiteSpace:"normal",children:r}):null}function ie({children:t,details:o,status:r}){const[s,l]=a.useState(!1);return e.jsxs(i.StackView,{spacing:n.token("--t-spacing-1"),children:[e.jsxs(i.Box,{children:[t," ",o&&e.jsx(i.Button,{inline:!0,onClick:function(){l(e=>!e)},size:"xs",theme:"primary",variant:"naked",fontStyle:"normal",children:"Details"})]}),s?e.jsx(i.Box,{padding:1,background:n.token("--t-fill-color-neutral-090"),children:e.jsxs(i.Text,{fontFamily:"monospace",fontSize:n.token("--t-font-size-xs"),lineHeight:"1.2",children:[r&&`${r}: `,o]})}):null]})}class ae extends w.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs(i.Alert,{type:"error",marginVertical:n.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."," ",e.jsx("a",{style:{whiteSpace:"nowrap"},onClick:()=>window.Helpdesk.load(),children:"Contact support"})]}):this.props.children}}var oe=t=>e.jsx(ae,{children:e.jsx(X,{...t})});function re({onClick:t}){return e.jsx(i.Button,{as:"button",height:n.token("--t-element-size-md"),icon:{color:n.token("--t-icon-color-default-dim"),name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function se({children:t,onRequestClose:a,open:o,theme:r}){/*#__PURE__*/return d.createPortal(e.jsx(i.ThemeProvider,{theme:r,children:e.jsxs(i.Modal,{open:o,onRequestClose:a,maxWidth:120,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:n.token("--t-spacing-4"),paddingBottom:n.token("--t-spacing-3"),radius:n.token("--t-border-radius-lg"),children:[e.jsxs(i.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(i.Heading,{level:2,color:n.token("--t-text-color-default-headline"),fontWeight:n.token("--t-font-weight-medium"),fontSize:n.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Automation history"}),e.jsx(re,{onClick:a})]}),t]})}),document.body)}const le=function(e){try{return Promise.resolve(de.get({data:{fields:{Person:"avatar"}},url:"me"})).then(function({data:{avatar:t}}){return{avatar:t,subscription:e}})}catch(e){return Promise.reject(e)}},ce=new t.Client({app:"webhooks",version:"2022-10-20"}),de=new t.Client({app:"people"}),ue=/*#__PURE__*/a.createContext(null);function pe({updateAutomation:t,onDelete:n,theme:i,openHistoryNow:a=!1,disabled:o,disabledReason:r,...s}){return e.jsxs(we,{theme:i,updateAutomation:t,...s,children:[e.jsxs(fe,{children:[e.jsx(ve,{}),e.jsx(xe,{onDelete:n,openHistoryNow:a,disabled:o,disabledReason:r})]}),e.jsx(je,{}),e.jsx(ke,{})]})}function he(t){return e.jsxs(we,{automation:t.automation,children:[e.jsxs(fe,{children:[e.jsx(ve,{}),e.jsx(ge,{})]}),e.jsx(me,{}),e.jsx(be,{})]})}function me(){const{automation:t}=a.useContext(ue),o=t.triggerEventDescription,{name:s,description:l}=Se(t.description),c=t.active?void 0:.5;return e.jsxs(i.StackView,{paddingVertical:n.token("--t-spacing-2"),flex:1,opacity:c,children:[e.jsx(i.Heading,{level:3,size:n.token("--t-font-size-xl"),weight:n.token("--t-font-weight-medium"),marginBottom:n.token("--t-spacing-half"),truncate:!0,children:s}),e.jsxs(i.StackView,{spacing:.75,children:[e.jsxs(i.Text,{size:n.token("--t-font-size-sm"),color:n.token("--t-text-color-default-primary"),lineHeight:"1.2",children:[o,", then ",r.lowerFirst(s)," ",ye(t)]}),e.jsx(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:r.truncate(Ce(l),{length:160,separator:" "})})]})]})}function ge(){const{automation:t}=a.useContext(ue);return e.jsx(i.Button,{external:!0,iconLeft:{name:"general.newWindow"},variant:"naked",size:"sm",to:t.triggerAdminUrl,disabled:!t.canManage,tooltip:t.canManage?void 0:"You do not have access to this resource",color:n.token("--t-text-color-default-secondary"),hover:{backgroundColor:"highlight",color:n.token("--t-text-color-default-secondary")},children:"Manage"})}function we({automation:t,updateAutomation:n,children:a,theme:o,...r}){return e.jsx(ue.Provider,{value:{automation:t,theme:o,updateAutomation:n,...r},children:e.jsx(i.Card,{radius:4,padding:2,children:a})})}function fe({children:t}){const{automation:n}=a.useContext(ue);return e.jsx(i.StackView,{axis:"horizontal",alignment:"center",padding:0,distribution:"space-between",opacity:n.active?void 0:.5,children:t})}function xe({onDelete:t,openHistoryNow:o=!1,disabled:r,disabledReason:s}){const{automation:l,currentPersonCanCreate:c,currentPersonId:d,trigger:u,theme:p,updateAutomation:h}=a.useContext(ue),[m,g]=a.useState(o),w=l.active,{name:f}=Se(l.description);return e.jsxs(e.Fragment,{children:[e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsxs(i.Dropdown,{icon:{color:n.token("--t-icon-color-default-primary"),name:"churchCenter.threeDots"},iconRight:!1,title:"Actions",variant:"naked",size:"md",disabled:r,children:[e.jsx(i.Dropdown.Item,{onSelect:()=>{g(!0)},children:"History"}),c&&e.jsx(i.Dropdown.Item,l.createdById===d?{disabled:!0,children:e.jsx(i.Tooltip,{placement:"left",openDelay:250,title:"This automation is already assigned to you.",children:e.jsx(i.Text,{children:"Reassign to me..."})})}:{onSelect:function(){z.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&&ce.post({data:{_e:u.resource,data:{attributes:{}}},url:`/automation_subscriptions/${l.id}/self_assign`}).then(({data:e})=>le(e)).then(({subscription:e,avatar:t})=>{h(n=>({...n,createdBy:{...n.createdBy,avatarUrl:t},createdById:e.createdById,createdByName:e.createdByName}))}).catch(e=>{const t=E(e,"update")||"There was a problem updating this automation. Please try again in a few moments.";C.fire({text:t,title:"Uh oh!"})})})},children:"Reassign to me..."}),e.jsx(i.Dropdown.Item,{onSelect:function(){_.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:e})=>{e&&t(l.id)})},children:"Delete..."})]}),e.jsx(i.ToggleSwitch,{isChecked:w,size:"sm",onClick:function(){ce.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=E(e,"pause")||`There was a problem ${w?"pausing":"unpausing"} this automation. Please try again in a few moments.`;C.fire({text:t,title:"Uh oh!"})})},tooltip:r?s:w?"Pause automation":"Enable automation",disabled:r})]}),e.jsx(se,{open:m,onRequestClose:()=>g(!1),theme:p,children:e.jsx(oe,{automation:l,triggerResource:u.resource,onEventsStatusChange:function(e){h(t=>({...t,eventsStatus:e}))}})})]})}function ve(){const{automation:t}=a.useContext(ue),n=t.name.split(".")[0];return e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:.5,children:[e.jsx(i.Icon,{name:`logomark.${r.camelCase(n)}`,size:2,color:n.toLowerCase()}),e.jsx(i.Icon,{name:"general.rightArrow",size:1.5}),e.jsx(i.Icon,{name:`logomark.${r.camelCase(t.operationAppName)}`,size:2,color:t.operationAppName.toLowerCase()})]})}function be(){const{automation:t}=a.useContext(ue),{dateFormat:o}=a.useContext(S),r=`${t.createdByName} ${t.createdBy?.id?"":"(deleted profile)"}`,s=t.active?void 0:.5;return e.jsxs(e.Fragment,{children:[e.jsx(i.Divider,{marginHorizontal:-2}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:n.token("--t-spacing-1"),opacity:s,children:[e.jsxs(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",H(t.createdAt,o)]}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-half"),maxWidth:"calc(100% - 136px)",children:[t.createdBy?.avatarUrl&&e.jsx(i.Avatar,{width:2,height:2,basis:2,source:t.createdBy.avatarUrl},r),e.jsx(i.Text,{size:5,truncate:!0,children:r})]})]})]})}function ke(){const{dateFormat:t}=a.useContext(S),{automation:o,trigger:r,theme:s,updateAutomation:l}=a.useContext(ue),c=`${o.createdByName} ${o.createdBy?.id?"":"(deleted profile)"}`,d=o.active?void 0:.5,u={color:n.token("--t-text-color-default-secondary"),fontSize:n.token("--t-font-size-xs"),fontWeight:n.token("--t-font-weight-normal"),paddingHorizontal:n.token("--t-spacing-1"),radius:"pill",size:"xs",variant:"naked"},[p,h]=a.useState({filter:null,historyVisible:!1});return e.jsxs(e.Fragment,{children:[e.jsx(i.Divider,{marginHorizontal:-2}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:n.token("--t-spacing-1"),opacity:d,children:[e.jsxs(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-placeholder"),whiteSpace:"nowrap",children:["Updated ",H(o.createdAt,t)]}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-fourth"),children:[!!o.eventsStatus?.skipped&&e.jsxs(i.Button,{...u,"aria-label":`${o.eventsStatus.skipped} skipped`,onClick:function(){h({filter:"skipped",historyVisible:!0})},tooltip:`${o.eventsStatus.skipped?.toLocaleString()} skipped events`,children:[e.jsx(i.Box,{backgroundColor:n.token("--t-fill-color-status-warning-solid"),marginRight:n.token("--t-spacing-half"),radius:"circle",height:"10px",width:"10px",padding:n.token("--t-spacing-fourth"),children:e.jsx(i.Icon,{name:"services.pause",size:"6px",title:"Skipped",color:"white"})}),`${o.eventsStatus.skipped?.toLocaleString()}`]}),!!o.eventsStatus?.failed&&e.jsx(i.Button,{...u,"aria-label":`${o.eventsStatus.failed} failed`,iconLeft:{color:n.token("--t-icon-color-status-error-primary"),marginRight:n.token("--t-spacing-half"),name:"general.exclamationTriangle",size:"10px",title:"Failed"},onClick:function(){h({filter:"failed,duplicated",historyVisible:!0})},title:`${o.eventsStatus.failed?.toLocaleString()}`,tooltip:`${o.eventsStatus.failed?.toLocaleString()} failed events`})]}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",distribution:"end",flex:1,spacing:n.token("--t-spacing-half"),marginLeft:"auto",children:[o.createdBy?.avatarUrl&&e.jsx(i.Avatar,{width:n.token("--t-element-size-md"),height:n.token("--t-element-size-md"),basis:n.token("--t-element-size-md"),source:o.createdBy.avatarUrl},c),e.jsx(i.Text,{size:n.token("--t-font-size-sm"),truncate:!0,children:c})]})]}),e.jsx(se,{open:p.historyVisible,onRequestClose:()=>h({filter:null,historyVisible:!1}),theme:s,children:e.jsx(oe,{automation:o,triggerResource:r.resource,filterWhere:p.filter,onEventsStatusChange:function(e){l(t=>({...t,eventsStatus:e}))}})})]})}function je(){const{automation:t,trigger:o}=a.useContext(ue),{name:s,description:l}=Se(t.description),c=t.active?void 0:.5,d=["When a person",r.lowerFirst(o.event.description)+",","then",r.lowerFirst(s),ye(t)].join(" ");return e.jsxs(i.StackView,{paddingVertical:n.token("--t-spacing-2"),flex:1,opacity:c,children:[e.jsx(i.Heading,{level:3,size:n.token("--t-font-size-xl"),weight:n.token("--t-font-weight-bold"),marginBottom:n.token("--t-spacing-half"),truncate:!0,children:s}),e.jsxs(i.StackView,{spacing:.75,children:[e.jsx(i.Text,{size:n.token("--t-font-size-sm"),color:n.token("--t-text-color-default-primary"),lineHeight:"1.2",children:d}),e.jsx(i.Text,{size:n.token("--t-font-size-xs"),color:n.token("--t-text-color-default-secondary"),lineHeight:"1.2",children:r.truncate(Ce(l),{length:160,separator:" "})})]})]})}function ye(e){return e?.triggerParams?.useTriggerPersonOverride?"(also applies to joint donor)":""}function Se(e){const t=/^(.+?)\(([^()]*?)\)$/.exec(e);return t?{description:t[2],name:t[1].trim()}:{name:e}}function Ce(e){return e?.startsWith("[archived]")?e.replace("[archived]","[Archived]"):e}const ze=function(){try{return Promise.resolve(Te.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)}},_e=function(e){try{const t=r.compact(r.uniq(e.map(e=>e.createdById)));return Promise.resolve(function(n,i){try{var a=Promise.resolve(Te.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)}},Pe=new t.Client({app:"webhooks",version:"2022-10-20"}),Te=new t.Client({app:"people"});function Oe({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 Ae=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:o,resourceId:r}=W(n);return e[i]||(e[i]={}),e[i][a]||(e[i][a]={}),e[i][a].resoucePath||(e[i][a].resourcePath=o),e[i][a].ids||(e[i][a].ids=[]),e[i][a].ids.push(r),e},{}),a=Object.keys(i).flatMap(e=>Object.entries(i[e]).flatMap(([i,a])=>(n.includes(e)?$e:t[e]?.includes(i)?Fe:Le)({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)}},Ie=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 t.Client({app:"webhooks",version:"2022-10-20"});function Fe({appName:e,resourcePath:t,resourceType:n,ids:i}){return Be({appName:e,params:{where:{id:i.join(",")}},path:t,resourceType:n})}function Le({appName:e,resourcePath:t,resourceType:n,ids:i}){return i.map(i=>Be({appName:e,path:`${t}/${i}`,resourceType:n}))}function $e(e){return new Promise((e,t)=>{t()})}function Be({appName:e,path:n,resourceType:i,params:a={}}){const o=new t.Client({app:e}),s=r.upperFirst(N(i));return o.get({data:{fields:{[s]:["name","name_or_description"]},...a},url:n})}function De({encryptedParam:t,trigger:o}){const[s,l]=a.useState(!0),[c,d]=a.useState();a.useEffect(()=>{ze().then(e=>{Ie(t).then(_e).then(Oe).then(T).then(Ae).then(({automations:t,triggerResources:n})=>function({automations:e,triggerResources:t,operationApps:n}){return e.map(e=>{const{appName:i,resourceType:a,resourceId:o}=W(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 s=t.find(e=>e.id.toString()==o.toString()),l=s?s.name||s.nameOrDescription:`[Hidden ${r.upperFirst(N(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}=W(e.triggerResource);if(!n){const e=r.truncate(t,{length:160,separator:" "});return`When the automation is triggered from ${N(i)} "${e}"`}return`When a person ${n} ${N(i)} "${t}"`}(e,l),e.canManage=!!s,e})}({automations:t,operationApps:e,triggerResources:n})).then(d).then(()=>l(!1))})},[t]);const u=!s&&0===c.length;return e.jsxs(e.Fragment,{children:[e.jsx(i.Box,{borderBottom:`1px solid ${n.token("--t-border-color-default-base")}`,marginBottom:n.token("--t-spacing-2"),marginHorizontal:-3,marginTop:o?12:0,paddingHorizontal:n.token("--t-spacing-3"),paddingVertical:n.token("--t-spacing-2"),children:e.jsx(i.Heading,{color:n.token("--t-text-color-default-headline"),level:2,size:n.token("--t-font-size-lg"),children:s?"Incoming automations":R(c.length,"incoming automation")})}),u?e.jsx(i.Text,{color:n.token("--t-text-color-default-secondary"),marginVertical:n.token("--t-spacing-3"),children:"Automations that perform actions on this resource will be listed here."}):s?e.jsx(i.Summary,{image:e.jsx(i.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading incoming automations..."}):e.jsx(i.TileView,{spacing:n.token("--t-spacing-3"),marginVertical:n.token("--t-spacing-3"),minCellWidth:45,children:c.map(t=>e.jsx(he,{automation:t},t.id))})]})}function He(e){return`OPERATION_${e.definitionClass}${e.definitionIdentifier||""}`}function Re(e){return`SECTION_${e}`}function Ne(t){return t.map(({label:t,value:n})=>e.jsx(i.Select.Option,{value:n,children:t},n))}function We(t){const n=r.groupBy(t,"group");return Object.keys(n).sort().map(t=>"null"===t?Ne(n[t]):e.jsx(i.Select.OptionGroup,{title:t,children:Ne(n[t])},t))}const Ee=({selectedOperation:t,onOperationDefinitionChange:a,operationDefinitions:o})=>{const s=t?.section,l=o.map(e=>({...e,id:He(e)})),c=l.filter(e=>null===e.section),d=r.uniqBy(o,"section").filter(e=>!!e.section).map(e=>({group:e.sectionGroup,label:e.section,value:Re(e.section)})),u=s?l.filter(e=>e.section===s):[];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":a(o.find(t=>Re(t.section)===e));break;case"operation":a(o.find(t=>He(t)===e));break;case null:a(null)}}function h(e){return We(e.map(e=>({group:e.group,label:e.description,value:e.id})))}return e.jsxs(i.StackView,{spacing:n.token("--t-spacing-1"),children:[e.jsxs(i.Select,{emptyValue:"Select an action",id:"select-action",onChange:p,size:"lg","data-testid":"operation-select",children:[h(c),We(d)]}),u.length>0&&e.jsx(i.Select,{defaultValue:u[0].id,onChange:p,size:"lg",children:h(u)})]})},Me=({canAccessPeople:t,field:o,onChange:s,value:l,selectedFieldOptions:c,loadListForField:d,loadedLists:u,loadingLists:p})=>{const h=function(e){const[t,n]=a.useState(e);return a.useEffect(()=>{const i=e();r.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[r.camelCase(n)]=t[n]),e),{})}({field:o,selectedFieldOptions:c}));a.useEffect(()=>{o.listClass&&d({dependencies:h,field:o})},[o,h,d]);const m=o.list||u[I(o)]||[],g=m.filter(e=>!e.automationNotAllowed),w=o.listClass&&p[I(o)];return e.jsxs(i.StackView,{marginBottom:2,spacing:.5,children:[e.jsxs(i.Input.InputLabel,{color:n.token("--t-text-color-default-headline"),fontSize:n.token("--t-font-size-sm"),fontWeight:n.token("--t-font-weight-medium"),controls:o.id,children:[o.description,o.info&&e.jsx(i.HelperDrawer.Toggle,{drawerId:`${o.id}_help`,marginLeft:1})]}),e.jsx(i.Box,{children:w?e.jsx(tt,{}):function(){switch(o.kind){case"Select":return e.jsx(qe,{fieldId:o.id,listOptions:g,onChange:s,value:l,description:o.description});case"SelectSearch":return e.jsx(Ue,{fieldId:o.id,listOptions:g,onChange:s,value:l});case"Checkbox":return e.jsx(Ze,{field:o,value:l,onChange:s});case"TextArea":return e.jsx(Qe,{field:o,onChange:s,value:l});case"DateField":return e.jsx(Ge,{field:o,onChange:s,value:l});case"Checkboxes":return e.jsx(Je,{fieldId:o.id,options:g,onChange:s});case"NumberField":return e.jsx(Xe,{field:o,onChange:s,value:l});case"PersonSearch":return e.jsx(Ye,{canAccessPeople:t,field:o,onChange:s,listOptions:m,isLoading:p[I(o)],loadListForField:d,value:l});case"TextField":return e.jsx(Ke,{field:o,onChange:s,value:l});case"RadioButtons":return e.jsx(et,{field:o,options:m,onChange:s,value:l});case"StaticText":return e.jsx(i.Text,{dangerouslySetInnerHTML:{__html:o.content}});default:return console.warn(`Unknown field kind "${o.kind}"`),null}}()}),o.info&&e.jsx(i.HelperDrawer,{id:`${o.id}_help`,marginTop:n.token("--t-spacing-half"),children:e.jsx(i.Box,{dangerouslySetInnerHTML:{__html:o.info}})})]})},qe=({fieldId:t,listOptions:n,onChange:a,value:o,description:s})=>{const l=n?.find(e=>"no-option"===e.value),c=r.groupBy(n,"group"),d=Object.keys(c).sort(),u=()=>d.map(t=>"null"===t||"undefined"===t?p(c[t]):e.jsx(i.Select.OptionGroup,{title:t,children:p(c[t])},t)),p=t=>t.map(t=>e.jsx(i.Select.Option,{value:t.value.toString(),disabled:t.disabled,children:t.description},t.value));return e.jsx(i.Select,{id:t,onChange:({selectedValue:e})=>{a({fieldId:t,value:e})},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})(s?.toLowerCase()),size:"lg",value:o||l?.value||null,placement:"bottom-start",children:u()})},Ue=({fieldId:t,listOptions:o,onChange:s,value:l})=>{const c=o.find(e=>e.value?.toString()===l),d=c?.description||"",[u,p]=a.useState(""),[h,m]=a.useState(d),[g,w]=a.useState(!1),[f,x]=a.useState(!1);d!==u&&(p(d),m(d),w(!1));let v=r.sortBy(r.uniqBy(o,"value"),"group");if(g){const e=h.toLowerCase();v=v.filter(t=>`${t.description} ${t.group}`.toLowerCase().includes(e))}return e.jsx(i.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},css:{"[role='combobox']":{cursor:o.length>0?"pointer":"not-allowed"}},cursor:"pointer",disabled:0===o.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:e=>{(e=>{s({fieldId:t,value:e})})(e.value),m(e.description),w(!1),x(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:o.length>0?"Select an option":"No options available",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:e.jsx(i.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(i.Icon,{name:"general.downCaret"}),size:"lg",value:h,children:o.length>0&&e.jsx(e.Fragment,{children:v.length>0?v.map((t,a)=>{const o=t.value.toString()===l;return e.jsxs(i.Combobox.Item,{"aria-label":t.description,disabled:t.disabled,index:a,paddingLeft:4.25,renderLeft:e.jsx(i.Icon,{marginLeft:-.5,name:o?"general.check":"",size:"sm"}),role:"option",spacing:n.token("--t-spacing-1"),value:{description:t.description,value:t.value.toString()},children:[e.jsx(i.Text,{truncate:!0,children:e.jsx(i.Highlight,{text:t.description,query:h})}),t.group&&e.jsx(i.Badge,{title:e.jsx(i.Highlight,{text:t.group,query:h}),size:"sm",marginLeft:"auto"})]},t.value)}):e.jsx(i.Menu.Item,{children:e.jsxs(i.Text,{children:['No results for "',h,'"']})})})})},Ye=({canAccessPeople:t,field:o,isLoading:s,listOptions:l,loadListForField:c,onChange:d,value:u})=>{const p=a.useCallback(e=>{c({dependencies:{query:e},field:o})},[c]),h=a.useMemo(()=>r.debounce(p,300),[p]),m=a.useCallback(e=>{t&&(e.trim().length>0?h(e):h.cancel())},[h]),g=a.useMemo(()=>({description:"Myself",value:"self"}),[]),w=a.useMemo(()=>t?l:[g],[g,l]).find(e=>e.value===u),f=w?.description||"",[x,v]=a.useState(f),[b,k]=a.useState(!1);function j(e){v(e),m(e),0===e.trim().length&&y(null)}const y=e=>{d({fieldId:o.id,value:e})};return e.jsx(i.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?e.jsx(i.Avatar,{size:"sm",source:w.meta.avatar}):e.jsx(i.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(i.Icon,{name:"general.downCaret"}),size:"lg",value:x,children:t?x.trim().length>0?l.length>0?l.map((t,a)=>e.jsx(i.Combobox.Item,{"aria-label":t.description,index:a,paddingLeft:4.25,renderLeft:e.jsx(i.Avatar,{marginLeft:-.5,source:t.meta.avatar,size:"sm"}),role:"option",spacing:n.token("--t-spacing-1"),value:t,children:e.jsx(i.Text,{truncate:!0,children:e.jsx(i.Highlight,{text:t.description,query:x})})},t.value)):e.jsx(i.Combobox.Item,s?{children:e.jsx(i.Text,{children:"Loading..."})}:{children:e.jsx(i.Text,{children:"No results"})}):e.jsx(i.Combobox.Item,{children:e.jsx(i.Text,{children:"Type to search"})}):e.jsx(i.Combobox.Item,{value:g,index:0,role:"option",children:e.jsx(i.Text,{children:g.description})})})},Ze=({field:t,value:n,onChange:a})=>e.jsx(i.Checkbox,{disabled:t.disabled,label:t.label,checked:n||!1,onChange:e=>{a({fieldId:t.id,value:e.target.checked})}}),Qe=({field:t,value:n,onChange:a})=>e.jsx(i.Box,{children:e.jsx(i.TextArea,{value:n,placeholder:t.placeholder,onChange:e=>{a({fieldId:t.id,value:e.target.value})},size:"lg"})}),Ge=({field:t,value:n,onChange:o})=>{const{dateFormat:r}=a.useContext(S),[s,l]=a.useState(!1),c=t.customValue||"Day automation runs",d="Day before automation runs",u=r.replace(/%m/,"M").replace(/%d/,"d").replace(/%Y/,"y").replace(/%y/,"yy"),[p,h]=a.useState(x.default(n).toDate()),m=t.allowUnansweredOption??!1;return e.jsxs(i.StackView,{axis:"horizontal",children:[e.jsxs(i.Select,{onChange:({selectedValue:e})=>{e===c||e===d?(l(!1),o({fieldId:t.id,value:e})):"specific-date"===e?(o({fieldId:t.id,value:null}),l(!0)):(l(!1),o({fieldId:t.id,value:null}))},size:"lg",placement:"bottom-start",children:[e.jsx(i.Select.Option,{value:c,children:c}),!t.customValue&&e.jsx(i.Select.Option,{value:d,children:d}),e.jsx(i.Select.Option,{value:"specific-date",children:"A specific date"}),m&&e.jsx(i.Select.Option,{value:"unanswered",children:"Unanswered"})]}),s&&e.jsx(i.Box,{children:e.jsx(i.DateField,{defaultOpen:!0,formatValue:u,marginLeft:1,onChange:e=>{o({fieldId:t.id,value:H(e,r)}),h(e)},size:"lg",value:p})})]})},Je=({fieldId:t,options:n,onChange:o})=>{const[r,s]=a.useState({});return e.jsx(i.StackView,{spacing:1,children:n.map(n=>e.jsxs(i.Box,{children:[e.jsx(i.Input.InputLabel,{controls:`checkboxes_${t}_${n.value}`,children:n.description||n.value}),e.jsxs(i.Select,{id:`checkboxes_${t}_${n.value}`,onChange:({selectedValue:e})=>((e,n)=>{const i={...r};i[n]=e,s(i),o({fieldId:t,value:i})})(e,n.value),size:"lg",emptyValue:"Don't change",children:[e.jsx(i.Select.Option,{value:"check",children:"Check"}),e.jsx(i.Select.Option,{value:"uncheck",children:"Uncheck"})]})]},n.value))})},Xe=({field:t,onChange:o,value:r})=>{const s=t.minValue>=0?t.minValue:1,l=t.maxValue>=1&&t.maxValue<=365?t.maxValue:365,[c,d]=a.useState(Number(t.defaultValue)||1);return a.useEffect(()=>{o({fieldId:t.id,value:t.defaultValue||1})},[t]),e.jsxs(i.StackView,{children:[e.jsx(i.Input.InputBox,{children:e.jsx(i.NumberField,{onChange:e=>{const n=Number(e)||0;d(n),o({fieldId:t.id,value:Math.min(Math.max(n,s),l)})},placeholder:t.placeholder,size:"lg",value:r,min:s,max:l,hasControls:!0})}),c>l&&e.jsx(i.Alert,{type:"error",paddingHorizontal:n.token("--t-spacing-1"),paddingVertical:n.token("--t-spacing-half"),display:"inline-block",marginTop:1.5,children:e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsx(i.Icon,{name:"general.exclamationTriangle",size:"sm",color:"delete45"}),e.jsxs(i.Text,{size:n.token("--t-font-size-md"),children:["Value cannot exceed ",l,"."]})]})})]})},Ke=({field:t,value:n,onChange:a})=>e.jsx(i.Box,{children:e.jsx(i.Input,{size:"lg",value:n,id:t.id,placeholder:t.placeholder,onChange:e=>{a({fieldId:t.id,value:e.target.value})}})}),et=({field:t,options:n,onChange:a,value:o})=>{const r=e=>{a({fieldId:t.id,value:e.target.value})};return e.jsx(i.StackView,{marginTop:1,spacing:.5,children:n.map(t=>e.jsx(i.Radio,{checked:o===t.value,label:t.description||t.value,onChange:r,size:"md",value:t.value},t.value))})},tt=()=>e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:n.token("--t-spacing-1"),radius:n.token("--t-border-radius-md"),border:`1px solid ${n.token("--t-border-color-default-base")}`,children:[e.jsx(i.Spinner,{size:"xs"}),e.jsx(i.Text,{fontSize:n.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]}),nt=({canAccessPeople:t,definitionFields:n,onChange:i,selectedFieldOptions:o,loadListForField:r,loadedLists:s,loadingLists:l})=>{a.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=$(n,o),d=({fieldId:e,value:t})=>{const a={...o},r=n.filter(e=>e.dependsOn);r.map(t=>{if(t.dependsOn.includes(e)){const e=r.find(e=>e.dependsOn.includes(t.id));e&&delete a[e.id],delete a[t.id],void 0!==t.defaultValue&&void 0===a[t.id]&&(a[t.id]=t.defaultValue)}}),"no-option"===t?delete a[e]:a[e]=t,i({...a})};return n.length?e.jsx("div",{children:c.map(n=>e.jsx(Me,{canAccessPeople:t,field:n,onChange:d,value:o[n.id],selectedFieldOptions:o,loadListForField:r,loadedLists:s,loadingLists:l},n.id))}):null},it=function(e){try{return Promise.resolve(st.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)}},at=function(){try{return Promise.resolve(st.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(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 t.Client({app:"people",env:window.railsEnv,version:"LATEST"}),st=new t.Client({app:"webhooks",env:window.railsEnv,version:"LATEST"}),lt={css:{borderRadius:n.token("--t-border-radius-md")},paddingHorizontal:1.75,paddingVertical:1.25,type:"error"},ct=({afterCreateOptions:t,blankStateLink:o,debugMode:s=!1,defaultApp:l,description:c,onRequestClose:d,trigger:u})=>{const[p,h]=a.useState(u.events[0]),[m,g]=a.useState({}),[w,f]=a.useState(l),[x,v]=a.useState([]),[b,k]=a.useState([]),[j,y]=a.useState(!0),[S,C]=a.useState(),[z,_]=a.useState({}),[T,O]=a.useState({}),[A,F]=a.useState({}),[L,$]=a.useState(!1),[D,H]=a.useState({}),[R,N]=a.useState(!1),[W,E]=a.useState({}),M=a.useRef(null),q=a.useMemo(()=>x.map(e=>e.id).includes("people"),[x]),U=S?.definitionIdentifier,Y="danger"===S?.footerMessage?.kind,Z=a.useCallback(({field:e,dependencies:t})=>{F(t=>({...t,[I(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(st.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,[I(e)]:t})),F(t=>({...t,[I(e)]:!1}))}).catch(e=>H({selected_definition:e}))},[w,U]);a.useEffect(()=>{H({}),function(){try{return Promise.resolve(Promise.all([ot(),at()])).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),it(t).then(e=>{M.current||(k(e),y(!1))}).catch(e=>H({definitions:e}))})},[l]),a.useEffect(()=>{H({})},[z]);const Q=r.cloneDeep("conditions"in p?p.conditions:u.conditions);for(const e in m)r.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:B({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(e){$(!0),st.post({data:e,url:"/me/automation_subscriptions"}).then(()=>{t?.onConfirm&&R?(d(),t.onConfirm({...e})):window.location.reload()}).catch(e=>{$(!1),e.errors?H({automation:e.errors}):alert("something even worse happened!")})}return e.jsxs(i.StackView,{paddingTop:4,spacing:2,children:[c&&e.jsx(i.Box,{children:e.jsxs(i.Text,{style:{color:n.token("--t-text-color-default-primary"),fontSize:n.token("--t-font-size-md"),lineHeight:1.65,marginBottom:n.token("--t-spacing-2")},children:[c," ",e.jsx(i.Link,{external:!0,to:o,children:"Learn more"})]})}),D.automation&&e.jsx(i.Alert,{...lt,children:e.jsx(i.Text,{children:"There was an error creating your automation. Please change your selections and try again or contact support if the problem persists."})}),e.jsxs(i.StackView,{spacing:1,children:[e.jsx(i.Input.InputLabel,{color:n.token("--t-text-color-default-primary"),controls:"select-trigger-event",fontSize:n.token("--t-font-size-md"),fontWeight:n.token("--t-font-weight-medium"),children:"When a person..."}),e.jsx(i.Select,{id:"select-trigger-event",onChange:({selectedValue:e})=>(e=>{h(e),g({})})(e),size:"lg",value:p,children:u.events.map((t,n)=>e.jsx(i.Select.Option,{value:t,children:t.description},`${t.name}_${n}`))}),G?.length>0&&e.jsx(nt,{canAccessPeople:q,definitionFields:G,selectedFieldOptions:m,onChange:g,loadedLists:{},loadingLists:{},loadListForField:()=>null})]}),e.jsxs(i.StackView,{spacing:1,children:[x.length>0?e.jsx(mt,{selectedApp:w,operationApps:x,onOperationAppChange:e=>{f(e),y(!0),k([]),M.current=e,C(null),_({}),H({}),it(e).then(k).then(()=>y(!1)).catch(e=>H({definitions:e}))}}):e.jsxs(i.StackView,{spacing:1,children:[e.jsx(i.Text,{color:n.token("--t-text-color-default-headline"),fontSize:n.token("--t-font-size-md"),fontWeight:n.token("--t-font-weight-medium"),children:"Then perform an action in..."}),e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:n.token("--t-spacing-1"),radius:4,border:`1px solid ${n.token("--t-border-color-default-base")}`,children:[e.jsx(i.Spinner,{size:"xs"}),e.jsx(i.Text,{fontSize:n.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]})]}),D.definitions?e.jsx(i.Alert,{marginTop:n.token("--t-spacing-1"),...lt,children:e.jsx(i.Text,{children:"There was a problem looking up automations. Please contact support if the problem persists."})}):j?e.jsx(gt,{}):e.jsx(Ee,{selectedOperation:S,operationDefinitions:b,onOperationDefinitionChange:e=>{C(e),H({}),_({})}})]}),S&&(D.selected_definition?e.jsx(i.Alert,{...lt,children:e.jsx(i.Text,{children:"There was a problem looking up automation options. Please contact support if the problem persists."})}):e.jsxs(e.Fragment,{children:[e.jsx(nt,{canAccessPeople:q,definitionFields:S.definitionFields||[],onChange:_,selectedFieldOptions:z,loadedLists:T,loadListForField:Z,loadingLists:A}),t?.label&&e.jsx(i.Checkbox,{disabled:L||dt(S,z),label:t.label,checked:R,onChange:()=>N(!R)}),p?.triggerParams?.map((t,n)=>e.jsx(i.Checkbox,{label:t.description,checked:W&&W[t.key]||t.defaultValue,onChange:e=>{E(n=>({...n,[`${t.key}`]:e.target.checked}))}},`${t.key}_${n}`)),Y&&e.jsx(i.Alert,{...lt,children:e.jsxs(i.StackView,{axis:"horizontal",spacing:1.5,children:[e.jsx(i.Icon,{size:n.token("--t-element-size-lg"),name:"general.exclamationTriangle",color:n.token("--t-icon-color-status-error-primary")}),e.jsx(i.Text,{dangerouslySetInnerHTML:{__html:S.footerMessage?.html}})]})})]})),s&&e.jsx("pre",{children:JSON.stringify({description:S&&J(),loadedLists:T,selectedDefinition:S,selectedFieldOptions:z,triggerConditions:Q},null,4)}),e.jsxs(i.StackView,{alignment:"center",axis:"horizontal",borderTop:`1px solid ${n.token("--t-border-color-default-base")}`,distribution:"end",marginTop:2,marginHorizontal:-4,paddingHorizontal:4,paddingTop:3,spacing:2,children:[e.jsx(i.Button,{color:n.token("--t-text-color-default-headline"),"data-modal-close":!0,fontWeight:n.token("--t-font-weight-normal"),onClick:d,size:"md",title:"Cancel",variant:"naked"}),e.jsx(i.Button,{disabled:L||Y||dt(S,z),onClick:function(){if(L)return;const e={...z};S.definitionIdentifier&&(e.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:e,trigger_conditions:Q,trigger_params:W},type:"AutomationSubscription"}};R?P.fire({cancelButtonText:"Cancel",confirmButtonText:"Yes, perform action",text:"This will happen immediately after creating your new automation. Are you sure?",title:`${t.label}?`}).then(e=>{e.value?X(n):($(!1),N(!1))}):X(n)},size:"md",theme:"primary",title:ht(S,z),variant:"fill","data-testid":"create-automation"})]})]})};function dt(e,t){if(e){const n=$(e.definitionFields,t),i=n.filter(e=>e.required),a=n.filter(e=>ut(e));return!i.every(e=>pt(e,t))||!a.every(e=>pt(e,t))}return!0}function ut(e){return"Select"===e.kind||"SelectSearch"===e.kind}function pt(e,t){return ut(e)?t.hasOwnProperty(e.id):t.hasOwnProperty(e.id)&&t[e.id]&&""!==t[e.id].toString().trim()}function ht(e,t){const n=function(e,t){if(!e?.definitionFields)return;const n=$(e.definitionFields,t);for(const e of n)if(e.required&&!pt(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 mt=({onOperationAppChange:t,operationApps:a,selectedApp:o})=>e.jsxs(i.StackView,{spacing:1,children:[e.jsx(i.Input.InputLabel,{color:n.token("--t-text-color-default-headline"),controls:"select-product",fontSize:n.token("--t-font-size-md"),fontWeight:n.token("--t-font-weight-medium"),children:"Then perform an action in..."}),e.jsx(i.Select,{autoFocus:!0,id:"select-product",onChange:({selectedValue:e})=>{t(e)},size:"lg",value:o,children:a.map(t=>e.jsx(i.Select.Option,{value:t.id,children:t.name},t.id))})]}),gt=()=>e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),paddingHorizontal:1.75,paddingVertical:n.token("--t-spacing-1"),radius:n.token("--t-border-radius-md"),border:`1px solid ${n.token("--t-border-color-default-base")}`,children:[e.jsx(i.Spinner,{size:"xs"}),e.jsx(i.Text,{fontSize:n.token("--t-font-size-md"),lineHeight:2.75,children:"Loading"})]});function wt({onClick:t}){return e.jsx(i.Button,{as:"button",height:n.token("--t-element-size-md"),icon:{color:n.token("--t-icon-color-default-dim"),name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function ft({children:t,onRequestClose:a,open:o,theme:r}){/*#__PURE__*/return d.createPortal(e.jsxs(i.ThemeProvider,{theme:r,children:[e.jsxs(i.Modal,{open:o,onRequestClose:a,maxWidth:75,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:n.token("--t-spacing-4"),paddingBottom:n.token("--t-spacing-3"),radius:n.token("--t-border-radius-lg"),zIndex:10009,children:[e.jsxs(i.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(i.Heading,{level:2,color:n.token("--t-text-color-default-headline"),fontWeight:n.token("--t-font-weight-medium"),fontSize:n.token("--t-font-size-2xl"),lineHeight:"1.4",children:"Create automation"}),e.jsx(wt,{onClick:a})]}),t]}),e.jsx("style",{children:"\n .swal2-container.swal2-backdrop-show { z-index: 10001 }\n "})]}),document.body)}const xt={churchCenter:b,logomark:k,services:j},vt=new t.Client({app:"webhooks",version:"2022-10-20"});function bt({afterCreateOptions:t,automations:o,blankStateLink:r,canCreate:s,defaultApp:l,description:c,hasActiveAutomations:d,loading:u,onPauseAutomations:p,theme:h,trigger:m}){const[g,w]=a.useState(!1),f=s&&!d,x=o.filter(e=>e.active).length,v=o.filter(e=>!e.active).length;return e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",backgroundColor:f?n.token("--t-fill-color-status-warning-ghost"):void 0,borderBottom:f?void 0:`1px solid ${n.token("--t-border-color-default-base")}`,"data-testid":"automations-header",distribution:"space-between",marginHorizontal:-3,marginBottom:n.token("--t-spacing-2"),marginTop:-3,paddingHorizontal:n.token("--t-spacing-3"),paddingVertical:n.token("--t-spacing-2"),spacing:n.token("--t-spacing-2"),wrap:!0,zIndex:2,children:[s&&!d?e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",marginHorizontal:1,spacing:1,children:[e.jsx(i.Icon,{size:2,color:n.token("--t-icon-color-status-warning-primary"),name:"general.exclamationTriangle"}),e.jsx(i.Heading,{color:n.token("--t-text-color-default-headline"),level:2,size:n.token("--t-font-size-lg"),children:"Automations are currently paused"})]}):e.jsxs(i.Heading,{color:n.token("--t-text-color-default-headline"),level:2,size:n.token("--t-font-size-lg"),children:[u?"Active automations":R(x,"active automation"),v>0?` (${v} paused)`:""]}),s&&(d?e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:n.token("--t-spacing-1"),children:[o.length>0&&e.jsx(i.Button,{onClick:p,variant:"outline",children:"Pause automations"}),e.jsx(i.Button,{theme:"primary",variant:"fill",onClick:()=>w(!0),children:"Create automation"}),e.jsx(ft,{open:g,onRequestClose:()=>w(!1),theme:h,children:e.jsx(ct,{description:c,blankStateLink:r,defaultApp:l,trigger:m,onRequestClose:()=>w(!1),afterCreateOptions:t})})]}):e.jsx(i.Box,{children:e.jsxs(i.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[e.jsx(i.Button,{onClick:p,theme:"primary",variant:"outline",children:"Enable automations"}),e.jsx(i.Button,{theme:"primary",disabled:!0,tooltip:{title:"Automations must be enabled to create new ones"},children:"Create automation"})]})}))]})}exports.Automations=function({afterCreateOptions:t,blankStateDescription:o,blankStateLink:r="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"}){a.useEffect(()=>{if(!p)return k(!1);(function(e){try{return Promise.resolve(Pe.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(_e).then(Oe).then(T).then(v).then(()=>k(!1))},[p?.resource]);const[x,v]=a.useState([]),[b,k]=a.useState(!0),[j,z]=a.useState(!1),{dateFormat:_,twentyFourHourTime:P,olsonTimeZone:O}=h,A=new URLSearchParams(window.location.search).get("automation_id"),I={...u,icons:{...xt}};a.useEffect(()=>{document.body.toggleAttribute("data-loading-automations",b)},[b]);const V=!x.length||x.some(e=>e.active);function F(e){vt.delete({data:{_e:p.resource},url:`/automation_subscriptions/${e}`}).then(()=>v(x.filter(t=>t.id!==e))).catch(e=>{const t=E(e,"delete")||"There was a problem deleting this automation. Please try again in a few moments.";C.fire({text:t,title:"Uh oh!"})})}const L={color:n.token("--t-text-color-default-primary"),level:2,size:n.token("--t-font-size-2xl"),weight:n.token("--t-font-weight-bold")},$={color:n.token("--t-text-color-default-secondary"),lineHeight:3,size:n.token("--t-font-size-md")};return e.jsxs(i.ThemeProvider,{theme:I,children:[e.jsxs(S.Provider,{value:{dateFormat:_,olsonTimeZone:O,twentyFourHourTime:P},children:[p&&e.jsx(bt,{automations:x,blankStateLink:r,canCreate:l&&!g,loading:b,defaultApp:c,description:o,theme:I,trigger:p,hasActiveAutomations:V,onPauseAutomations:function(){vt.post({data:{data:{attributes:{_e:p.resource,active:!V}}},url:"/pause_automations"}).then(()=>{window.location.reload()})},afterCreateOptions:t}),b?e.jsx(i.Summary,{image:e.jsx(i.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading automations..."}):p?e.jsx(i.Box,{"data-testid":"automations-section",children:x?.length>0?e.jsx(i.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:f.default(x,"id").map(t=>{return e.jsx(pe,{automation:t,updateAutomation:(i=t,e=>{const t="function"==typeof e?e(i):e,n=[...x.filter(e=>e.id!==t.id),t];v(n)}),onDelete:F,theme:I,openHistoryNow:t.id===Number(A),trigger:{event:(n=t,p.events.find(e=>e.name===n.name)),resource:p.resource},currentPersonId:s,currentPersonCanCreate:l,disabled:g,disabledReason:w},t.id);var n,i})}):e.jsxs(i.StackView,{margin:n.token("--t-spacing-6"),spacing:n.token("--t-spacing-2"),alignment:"center",mediaQueries:{lg:{axis:"horizontal",distribution:"center",spacing:n.token("--t-spacing-6")}},children:[e.jsx(i.Box,{css:{".symbol":{height:"100%",width:"100%"}},maxWidth:24,mediaQueries:{lg:{maxWidth:40}},children:e.jsx(y,{})}),e.jsx(i.StackView,{alignment:"center",spacing:n.token("--t-spacing-1"),maxWidth:45,mediaQueries:{lg:{alignment:"start",textAlign:"left"}},textAlign:"center",children:e.jsxs(e.Fragment,l?{children:[e.jsx(i.Heading,{...L,children:"Add an automation"}),e.jsx(i.StackView,{alignment:"center",marginBottom:n.token("--t-spacing-1"),mediaQueries:{lg:{alignment:"start"}},spacing:1,children:e.jsx(i.Text,{...$,children:o})}),e.jsxs(i.StackView,{axis:"horizontal",spacing:n.token("--t-spacing-1"),children:[e.jsx(i.Button,{variant:"outline",to:r,color:`${n.token("--t-text-color-status-neutral")} !important`,children:"Learn more"}),e.jsx(i.Button,{as:"button",theme:"primary",variant:"fill",onClick:()=>z(!0),children:"Create automation"})]}),e.jsx(ft,{open:j,onRequestClose:()=>z(!1),theme:I,children:e.jsx(ct,{defaultApp:c,description:o,blankStateLink:r,onRequestClose:()=>z(!1),trigger:p,afterCreateOptions:t})})]}:{children:[e.jsx(i.Heading,{...L,children:"Automations"}),e.jsx(i.Text,{...$,children:m})]})})]})}):e.jsx(e.Fragment,{}),d&&e.jsx(De,{encryptedParam:d,trigger:p})]}),e.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.js.map
|