var _=Object.defineProperty;var S=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var I=(t,s,a)=>s in t?_(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,g=(t,s)=>{for(var a in s||(s={}))q.call(s,a)&&I(t,a,s[a]);if(S)for(var a of S(s))w.call(s,a)&&I(t,a,s[a]);return t};import{r as c,j as e,_ as n,L as P,c as z,D as F,a as H,S as T,W as L,h as E,V as B}from"./main-634.js";import{m as K}from"./bf-25-81.js";import{S as M}from"./bf-54-258.js";import{a6 as D,a7 as V}from"./bf-746-82.js";import{I as C}from"./bf-942-184.js";import{N as R}from"./bf-509-180.js";import{N as W}from"./bf-123-109.js";import{H as G,h as J,c as Z}from"./bf-387-205.js";import"./bf-275-83.js";import"./bf-822-108.js";import"./bf-438-114.js";function O({hubspotConf:t,setHubspotConf:s,step:a,setstep:j,isInfo:p}){const[d,x]=c.useState(!1),[r,u]=c.useState({name:"",api_key:""}),[v,h]=c.useState(!1),[y,k]=c.useState(!1),N=()=>{const l=g({},t);if(!l.name||!l.api_key){u({name:l.name?"":n("Integration name cann't be empty"),api_key:l.api_key?"":n("API Key cann't be empty")});return}k("auth");const m={api_key:l.api_key};z(m,"bitforms_hubspot_authorize").then(o=>{const{data:A}=o;A&&x(!0),h(!0),k(!1)})},f=l=>{const m=g({},t),o=g({},r);o[l.target.name]="",m[l.target.name]=l.target.value,u(o),s(m)},i=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),j(2)},b=`
    <h4> Step of generating  Access Token:</h4>
    <ul>
      <li>Login to your HubSpot account, click the <b>Settings</b> icon settings in the main navigation bar..</li>
      <li>In the left sidebar menu, navigate to <b>Integrations > Private App</b>.</li>
      <li>Give name and description and select all necessary scope.</li>
      <li>Then create Access token.</li>
  </ul>
  `;return e.jsxs("div",{className:"btcd-stp-page",style:{width:a===1&&900,height:a===1&&"auto"},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:f,name:"name",value:t==null?void 0:t.name,type:"text",placeholder:n("Integration Name..."),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:r.name}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("API Key:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:f,name:"api_key",value:t==null?void 0:t.api_key,type:"text",placeholder:n("API Key..."),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:r.api_key}),e.jsxs("small",{className:"d-blk mt-5",children:[n("To get API , Please Visit")," ",e.jsx("a",{className:"btcd-link",href:"https://app.hubspot.com/api-key",target:"_blank",rel:"noreferrer",children:n("Hubspot API Console")})]}),y==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(P,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),v&&!d&&!y&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),"Sorry, API key is invalid"]}),!p&&e.jsxs(e.Fragment,{children:[e.jsx(D,{handleAuthorize:N,isAuthorized:d,isLoading:y}),e.jsx("br",{}),e.jsx(W,{nextPageHandler:()=>i(),disabled:!d})]}),e.jsx(R,{note:b})]})}function re({formFields:t,setIntegration:s,integrations:a,allIntegURL:j}){const p=F(),[d,x]=c.useState(!1),[r,u]=c.useState(1),[v,h]=c.useState({show:!1}),{css:y}=H(),k=[{key:"email",label:"Email",required:!0},{key:"firstname",label:"First Name",required:!1},{key:"lastname",label:"Last Name",required:!1},{key:"website",label:"Website",required:!1},{key:"company",label:"Company",required:!1},{key:"phone",label:"Phone",required:!1},{key:"address",label:"Address",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1},{key:"zip",label:"Zip",required:!1},{key:"jobtitle",label:"Job Title",required:!1}],N=[{key:"dealname",label:"Deal Name",required:!0},{key:"amount",label:"Amount",required:!1},{key:"closedate",label:"Close Date",required:!1}],f=[{key:"subject",label:"Ticket Name",required:!0},{key:"content",label:"Ticket description",required:!1}],[i,b]=c.useState({name:"Hubspot",type:"Hubspot",api_key:"",field_map:[{formField:"",hubspotField:""}],actions:{},contactFields:k,dealFields:N,ticketFields:f}),l=()=>{V(a,s,j,i,p)},m=o=>{if(!Z(i)){B.error("Please map mandatory fields");return}i.field_map.length>0&&u(o)};return e.jsxs("div",{children:[e.jsx(T,{snack:v,setSnackbar:h}),e.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:e.jsx(M,{step:3,active:r})}),e.jsx(O,{hubspotConf:i,setHubspotConf:b,step:r,setstep:u,isLoading:d,setIsLoading:x,setSnackbar:h}),e.jsxs("div",{className:"btcd-stp-page",style:g({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[e.jsx(G,{formFields:t,handleInput:o=>J(o,i,b),hubspotConf:i,setHubspotConf:b,isLoading:d,setIsLoading:x,setSnackbar:h}),e.jsxs(L,{variant:"success",onClick:()=>m(3),disabled:!(i!=null&&i.actionName),className:y(E.ftRight),children:[n("Next"),e.jsx(K,{className:"ml-1 rev-icn"})]})]}),e.jsx(C,{step:r,saveConfig:()=>l()})]})}export{re as default};
