1import{a as H,b as O}from"./chunk-4NYTBAZH.js";import{a as Y}from"./chunk-B54J6LCG.js";import{a as R}from"./chunk-XDBIWCAA.js";import"./chunk-W323E7QA.js";import{a as B}from"./chunk-FXPIADUL.js";import"./chunk-ZI3WPPR4.js";import"./chunk-DYQFFG4Y.js";import{a as N}from"./chunk-HYMXAMIQ.js";import"./chunk-EHTCWYEV.js";import"./chunk-PZDGU76M.js";import"./chunk-IAGBHLIO.js";import{a as M}from"./chunk-6G5F7JGU.js";import"./chunk-SBNMS4AZ.js";import"./chunk-J4BQZTAP.js";import{a as j}from"./chunk-CAQTW5HZ.js";import"./chunk-R7MHRZZF.js";import{a as W}from"./chunk-TQXKOZHM.js";import{d as D}from"./chunk-AHXKBI54.js";import"./chunk-ZNNARHB3.js";import"./chunk-FM6WEN77.js";import"./chunk-GFJSPWE5.js";import{a as E}from"./chunk-JN4JOTVR.js";import{o as V}from"./chunk-XNCE5XQE.js";import"./chunk-Y3UL24R4.js";import{a as U}from"./chunk-7YNIFFAM.js";import"./chunk-KDVL22EY.js";import"./chunk-OEOOLALO.js";import"./chunk-O4GQHPXB.js";import{d as $}from"./chunk-SAMU6LRI.js";import{m as z}from"./chunk-FBILCCFV.js";import{Fb as d,Gb as h,Nb as u,Ob as p,Pb as _,Tb as S,Zb as w,_b as r,bc as I,fc as k,hc as C,i as s,ia as y,jc as T,mb as c,mc as A,oa as o,pb as P,qa as F,va as f,vc as v,wa as g,wc as x,yb as m}from"./chunk-3J5ILERG.js";var b=(()=>{class n{constructor(){this.firebaseFunctionsService=o(V),this.authStore=o(E),this.formService=o(D)}openAuth(t,e){return s(this,null,function*(){let i=this.authStore.selectedWorkspace,a={workspaceId:i,projectId:e},{authUrl:q,state:G}=yield this.firebaseFunctionsService.callFunction("getAuthUrlSlack",a),{code:J,state:K}=yield O(q);if(G===K){let L={workspaceId:i,projectId:e,formId:t,code:J};return yield this.firebaseFunctionsService.callFunction("exchangeTokenSlack",L)}return null})}setPlugin(t,e,i){return this.formService.updatePlugin(t,e,"slack",i)}setActiveStatus(t,e,i){return this.formService.updatePlugin(t,e,"slack",{active:i})}destroy(t,e){return this.formService.removePlugin(t,e,"slack")}static{this.\u0275fac=function(e){return new(e||n)}}static{this.\u0275prov=y({token:n,factory:n.\u0275fac})}}return n})();function X(n,l){n&1&&_(0,"img",9)}function Z(n,l){if(n&1){let t=S();u(0,"button",5),w("click",function(){f(t);let i=r(),a=r(2);return g(a.doAuthorize(i.projectId))}),u(1,"div",6),_(2,"img",7),p(),k(3),d(4,X,1,0,"img",8),p()}if(n&2){let t=r(2),e=r();m("disabled",e.authorizing||t.subscriptionPlan==="free"),c(3),C(" ",e.authorizing?"Hold on...":"Connect to Slack"," "),c(),h(4,e.authorizing?4:-1)}}function tt(n,l){if(n&1&&(u(0,"fun-block",10)(1,"div",11)(2,"div",12)(3,"h4",13),k(4,"Channel"),p(),u(5,"p",14),k(6),p()()()()),n&2){let t=r();c(5),I("title",t.plugin==null||t.plugin.webhook==null?null:t.plugin.webhook.channel),c(),C(" ",t.plugin==null||t.plugin.webhook==null?null:t.plugin.webhook.channel," ")}}function et(n,l){if(n&1){let t=S();u(0,"fun-plugin-shell",1),w("activatePlugin",function(i){f(t);let a=r(2);return g(a.doActivatePlugin(i))})("removePlugin",function(){f(t);let i=r(2);return g(i.doRemovePlugin())}),u(1,"fun-content-title",2),_(2,"fun-unlock",3),p(),d(3,Z,5,3,"button",4)(4,tt,7,2),p()}if(n&2){let t=r();m("workspace",t)("plugin",l.plugin)("isConnected",!!(l.plugin!=null&&l.plugin.webhook)),c(),m("heading","Slack Plugin")("description","Send new form results to a Slack channel or direct message")("icon","plugins/slack"),c(),m("workspace",t),c(),h(3,l.plugin!=null&&l.plugin.webhook?4:3)}}function nt(n,l){if(n&1&&(d(0,et,5,8,"fun-plugin-shell",0),v(1,"async")),n&2){let t=r(),e;h(0,(e=x(1,1,t.form$))?0:-1,e)}}var Pt=(()=>{class n{constructor(){this.cd=o(P),this.formStore=o(U),this.workspaceStore=o(N),this.slackService=o(b),this.notification=o(W),this.confirm=o(j),this.authorizing=!1}ngOnInit(){this.workspace$=this.workspaceStore.read(),this.form$=this.formStore.singleFormWithPlugin$(this.id,"slack")}get formId(){return this.formStore.getFormIdFromAliasId(this.id)}doAuthorize(t){return s(this,null,function*(){try{this.authorizing=!0;let e=yield this.slackService.openAuth(this.formId,t);e&&e.accessToken&&e.webhook&&(yield this.slackService.setPlugin(this.formId,this.id,e))}catch(e){e instanceof H||this.notification.show("error",e.message)}finally{this.authorizing=!1,this.cd.detectChanges()}})}doActivatePlugin(t){return s(this,null,function*(){try{yield this.slackService.setActiveStatus(this.formId,this.id,t)}catch{this.notification.show("error","Something went wrong")}})}doRemovePlugin(){return s(this,null,function*(){try{this.confirm.ask({message:"Remove Plugin and Data?",cancelText:"No",confirmText:"Yes, Confirm"},()=>s(this,null,function*(){yield this.slackService.destroy(this.formId,this.id)}))}catch(t){$(t)||this.notification.show("error","Something went wrong")}})}static{this.\u0275fac=function(e){return new(e||n)}}static{this.\u0275cmp=F({type:n,selectors:[["fun-slack"]],inputs:{id:"id"},standalone:!0,features:[T([b]),A],decls:2,vars:3,consts:[["pluginName","Slack","pluginSlug","slack",3,"workspace","plugin","isConnected"],["pluginName","Slack","pluginSlug","slack",3,"workspace","plugin","isConnected","activatePlugin","removePlugin"],[3,"heading","description","icon"],[1,"block","mt-2",3,"workspace"],["type","button","class","overflow-hidden relative flex items-center py-2 pr-4 pl-12 text-white text-md font-bold bg-primary hover:bg-primary-light rounded-full focus:outline-none",3,"disabled"],["type","button",1,"overflow-hidden","relative","flex","items-center","py-2","pr-4","pl-12","text-white","text-md","font-bold","bg-primary","hover:bg-primary-light","rounded-full","focus:outline-none",3,"disabled","click"],[1,"flex","justify-center","items-center","p-2","absolute","top-0","left-0","bottom-0","bg-primary-light","w-10"],["src","/assets/img/icon/plugins/providers/slack.svg",1,"w-4","h-4"],["class","ml-2 w-6 h-6","src","/assets/img/icon/working-white.svg","alt","Working Spinner Icon"],["src","/assets/img/icon/working-white.svg","alt","Working Spinner Icon",1,"ml-2","w-6","h-6"],["position","none"],[1,"bg-white","p-2","rounded-md","border","border-secondary-dark","shadow-sm","flex","items-center"],[1,"w-full","p-2"],[1,"font-bold"],[1,"text-sm","truncate",3,"title"]],template:function(e,i){if(e&1&&(d(0,nt,2,3),v(1,"async")),e&2){let a;h(0,(a=x(1,1,i.workspace$))?0:-1,a)}},dependencies:[M,Y,R,B,z],encapsulation:2})}}return n})();export{Pt as FunSlackComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.