1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7434],{78343:function(e,n,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/pvm/survey",function(){return r(4578)}])},5623:function(e,n,r){"use strict";var t=r(85893),i=r(27948),o=r(15861),a=r(98456),u=r(62714);n.Z=function(){var e=(0,u.$G)("loader").t;return(0,t.jsxs)(i.Z,{component:"main",maxWidth:"xs",sx:{textAlign:"center",mt:30},children:[(0,t.jsx)(o.Z,{variant:"h4",fontWeight:400,gutterBottom:!0,component:"div",color:"primary",children:e("loading")}),(0,t.jsx)(a.Z,{color:"primary"})]})}},81347:function(e,n,r){"use strict";var t=r(26042),i=r(69396),o=r(99534),a=r(85893),u=r(87357),s=r(15861);n.Z=function(e){var n=e.title,r=e.icon,l=(0,o.Z)(e,["title","icon"]);return(0,a.jsxs)(u.Z,(0,i.Z)((0,t.Z)({display:"flex",alignItems:"center",my:2},l),{children:[(0,a.jsx)(r,{sx:{height:"1.45rem",color:"primary.main"}}),(0,a.jsx)(s.Z,{variant:"h4",fontWeight:500,color:"primary",ml:2,children:n})]}))}},4578:function(e,n,r){"use strict";r.r(n),r.d(n,{__N_SSP:function(){return Zn},default:function(){return jn}});var t=r(47568),i=r(14924),o=r(26042),a=r(69396),u=r(828),s=r(51351),l=r(29815),d=r(10092),c=r(85893),f=r(24196),p=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){switch(n.label){case 0:return[4,f.Z.get("survey-v2/hierarchy")];case 1:return e=n.sent(),[2,e.data]}}))}));return function(){return e.apply(this,arguments)}}(),v=function(){var e=(0,t.Z)((function(e){var n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return[4,f.Z.get("survey-v2/question",{params:e})];case 1:return n=r.sent(),[2,n.data]}}))}));return function(n){return e.apply(this,arguments)}}(),_=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){switch(n.label){case 0:return[4,f.Z.get("survey-v2/version")];case 1:return e=n.sent(),[2,e.data]}}))}));return function(){return e.apply(this,arguments)}}(),h=function(){var e=(0,t.Z)((function(e){var n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return[4,f.Z.get("survey-v2/group-answer",{params:e})];case 1:return n=r.sent(),[2,n.data]}}))}));return function(n){return e.apply(this,arguments)}}(),x=function(){var e=(0,t.Z)((function(e){var n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return[4,f.Z.post("survey-v2/group-answer",e)];case 1:return n=r.sent(),[2,n.data]}}))}));return function(n){return e.apply(this,arguments)}}(),m=function(){var e=(0,t.Z)((function(e){var n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return[4,f.Z.post("survey-v2/group-answer/submit",e)];case 1:return n=r.sent(),[2,n.data]}}))}));return function(n){return e.apply(this,arguments)}}(),g=function(){var e=(0,t.Z)((function(e){var n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return[4,f.Z.put("survey-v2/answer",e)];case 1:return n=r.sent(),[2,n.data]}}))}));return function(n){return e.apply(this,arguments)}}(),y=function(){var e=(0,t.Z)((function(){return(0,d.__generator)(this,(function(e){switch(e.label){case 0:return[4,f.Z.get("/pvm/regulations")];case 1:return[2,e.sent().data]}}))}));return function(){return e.apply(this,arguments)}}(),w=function(){var e=(0,t.Z)((function(e){return(0,d.__generator)(this,(function(n){switch(n.label){case 0:return[4,f.Z.post("/pvm/regulations/".concat(e,"/accept"))];case 1:return n.sent(),[2]}}))}));return function(n){return e.apply(this,arguments)}}(),b=r(83321),Z=r(87357),j=r(98456),q=r(64666),S=r(6514),A=r(58951),k=r(31425),C=r(67294),Q=r(7514),E=(0,C.forwardRef)((function(e,n){var r=e.groupAnswerId,i=e.setGroupAnswers,o=e.disabled,a=e.surveyAlreadySubmitted,u=e.onBeforeSubmit,s=e.showTrigger,f=void 0===s||s,p=(0,Q.VY)().setAlert,v=(0,C.useState)(!1),_=v[0],h=v[1],x=(0,C.useState)(!1),g=x[0],y=x[1],w=function(){var e=(0,t.Z)((function(){return(0,d.__generator)(this,(function(e){switch(e.label){case 0:if(!u)return y(!0),[2];e.label=1;case 1:return e.trys.push([1,,3,4]),h(!0),[4,u()];case 2:return e.sent()&&y(!0),[3,4];case 3:return h(!1),[7];case 4:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();(0,C.useImperativeHandle)(n,(function(){return{open:function(){o||_||a||w()}}}));var E=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,3,4]),h(!0),[4,m({group_answer_id:r})];case 1:return e=n.sent(),i((function(n){return(0,l.Z)(n.map((function(n){return n.id===r?e:n})))})),p({message:"Obrigado pelo preenchimento da pesquisa. Question\xe1rio enviado com sucesso!",alertType:"success",autoHideDuration:6e3}),[3,4];case 2:return n.sent(),p({message:"Falha ao enviar formul\xe1rio",alertType:"error",autoHideDuration:6e3}),[3,4];case 3:return h(!1),y(!1),[7];case 4:return[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,c.jsxs)(c.Fragment,{children:[f&&(0,c.jsxs)(b.Z,{variant:"contained",size:"small",sx:{textTransform:"none",borderRadius:1.5},disabled:o||_||a,onClick:w,children:[a?"Avalia\xe7\xe3o j\xe1 respondida":"Enviar avalia\xe7\xe3o",!!_&&(0,c.jsx)(Z.Z,{ml:1,lineHeight:1,children:(0,c.jsx)(j.Z,{color:"inherit",size:"1.25rem"})})]}),(0,c.jsxs)(q.Z,{open:!!g,onClose:function(){return y(!1)},children:[(0,c.jsx)(S.Z,{children:(0,c.jsx)(A.Z,{children:"Voc\xea esta prestes a enviar a avalia\xe7\xe3o. Deseja continuar?"})}),(0,c.jsxs)(k.Z,{children:[(0,c.jsx)(b.Z,{onClick:function(){return y(!1)},children:"Cancelar"}),(0,c.jsx)(b.Z,{onClick:function(){E(),y(!1)},autoFocus:!0,children:"Confirmar"})]})]})]})})),B=r(37645),M=r(15861),z=r(67720);function N(e){return e.split("\n").map((function(e){return e.trim()})).filter((function(e){return e.length>0})).join("\n\n")}function V(e){var n,r=e.open,i=e.regulations,o=e.onClose,a=e.onAccept,s=e.onAllAccepted,l=C.useRef(null),f=(0,u.Z)(C.useState(0),2),p=f[0],v=f[1],_=(0,u.Z)(C.useState(!1),2),h=_[0],x=_[1],m=(0,u.Z)(C.useState(!1),2),g=m[0],y=m[1],w=(0,u.Z)(C.useState(!1),2),A=w[0],Q=w[1],E=i.length,V=null!==(n=i[p])&&void 0!==n?n:null,P=C.useMemo((function(){return V?function(e,n){var r=e.toLowerCase().includes("termo de aceite")?function(e){var n=e.indexOf("Declara\xe7\xe3o Final de Aceite");if(-1===n)return e;var r=e.lastIndexOf("\n",n);return-1===r?e:e.slice(0,r).trimEnd()}(n):n;return{body:N(r)}}(V.title,V.regulation_text):{body:""}}),[null===V||void 0===V?void 0:V.solution_acceptance_id]).body;C.useEffect((function(){r&&v(0)}),[r]),C.useEffect((function(){r&&V&&(x(!1),Q(!1),requestAnimationFrame((function(){var e=l.current;e&&(e.scrollTop=0,e.scrollHeight<=e.clientHeight&&x(!0))})))}),[r,null===V||void 0===V?void 0:V.solution_acceptance_id]);var I,L=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){switch(n.label){case 0:if(!V||!h||g)return[2];y(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,a(V.solution_acceptance_id)];case 2:return n.sent(),(e=p+1)>=E?s():v(e),[3,5];case 3:return n.sent(),[3,5];case 4:return y(!1),[7];case 5:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(q.Z,{open:r,onClose:function(e,n){"backdropClick"!==n&&"escapeKeyDown"!==n||Q(!0)},maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:2,overflow:"hidden",width:"1200px",p:{xs:2,sm:3}}},children:[(0,c.jsxs)(B.Z,{sx:{fontWeight:700,display:"flex",alignItems:"center",gap:1},children:[null!==(I=null===V||void 0===V?void 0:V.title)&&void 0!==I?I:"Regulamento",E>1&&(0,c.jsxs)(M.Z,{component:"span",sx:{fontSize:13,fontWeight:400,color:"#6B7280"},children:["(",p+1," de ",E,")"]})]}),(0,c.jsx)(z.Z,{}),(0,c.jsxs)(S.Z,{sx:{pt:2},children:[(0,c.jsx)(Z.Z,{ref:l,onScroll:function(){var e=l.current;if(e){e.scrollTop+e.clientHeight>=e.scrollHeight-4&&x(!0)}},sx:{border:"1px solid #E5E7EB",borderRadius:1.5,p:2,height:320,overflowY:"auto",backgroundColor:"#fff"},children:V?(0,c.jsx)(M.Z,{sx:{whiteSpace:"pre-wrap",color:"#111827",fontSize:"15px",lineHeight:1.8},children:P}):(0,c.jsx)(Z.Z,{sx:{display:"flex",justifyContent:"center",py:4},children:(0,c.jsx)(j.Z,{size:24})})}),!h&&(0,c.jsx)(Z.Z,{sx:{mt:2},children:(0,c.jsx)(M.Z,{variant:"caption",sx:{color:"#6B7280"},children:"Role at\xe9 o final para aceitar"})})]}),(0,c.jsxs)(k.Z,{sx:{p:2,display:{xs:"flex"},justifyContent:{xs:"center",sm:"flex-end"}},children:[(0,c.jsx)(b.Z,{onClick:function(){return Q(!0)},variant:"contained",sx:{backgroundColor:"#003087",width:"132px",color:"#fff","&:hover":{backgroundColor:"#001f5c"}},children:"Recusar"}),(0,c.jsx)(b.Z,{onClick:L,variant:"contained",disabled:!V||!h||g,sx:{backgroundColor:"#72B055",width:"132px","&:hover":{backgroundColor:"#5a9643"},"&.Mui-disabled":{backgroundColor:"#C0C0C0",color:"#fff"}},children:"Aceitar"})]})]}),(0,c.jsxs)(q.Z,{open:A,onClose:function(){return Q(!1)},PaperProps:{sx:{borderRadius:2,width:543,p:1}},children:[(0,c.jsx)(B.Z,{sx:{fontWeight:700},children:"Voc\xea tem certeza que deseja recusar o regulamento?"}),(0,c.jsx)(S.Z,{children:(0,c.jsx)(M.Z,{fontSize:12,color:"#4B5563",children:"O acesso a todas as funcionalidades s\xf3 \xe9 liberado ap\xf3s o aceite do regulamento. Caso opte por recusar, voc\xea ser\xe1 redirecionado para nossa tela de login. Deseja realmente recusar os termos presentes do regulamento?"})}),(0,c.jsxs)(k.Z,{sx:{justifyContent:"space-between",p:2},children:[(0,c.jsx)(b.Z,{variant:"outlined",onClick:function(){return Q(!1)},sx:{textTransform:"none",borderColor:"#1D51A3",color:"#1D51A3",fontFamily:"Poppins",fontWeight:400,fontSize:"12px",lineHeight:1,letterSpacing:0},children:"Visualizar regulamento"}),(0,c.jsx)(b.Z,{variant:"contained",onClick:o,sx:{textTransform:"none",backgroundColor:"#1D51A3","&:hover":{backgroundColor:"#08214F"},fontFamily:"Poppins",fontWeight:400,fontSize:"12px",lineHeight:1,letterSpacing:0},children:"Recusar e voltar para tela de login"})]})]})]})}var P,I=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){switch(n.label){case 0:return[4,f.Z.get("profile-hierarchy/filter-hierarchy/industry-customer")];case 1:return e=n.sent(),[2,e.data]}}))}));return function(){return e.apply(this,arguments)}}(),L=r(23966),F=r(2734),D=r(94054),R=r(18360),T=r(18972),W=r(55113),H=r(62286),O=function(e){var n,r,i=e.progressValue,u=void 0===i?0:i,s=e.firstTitle,f=e.secondTitle,p=e.completedTabsCount,v=void 0===p?0:p,h=e.totalTabsCount,x=void 0===h?0:h,m=e.onLevel1Change,g=e.onLevel2Change,y=e.onYearChange,w=e.onSubmitForm,b=e.surveyAlreadySubmitted,q=void 0!==b&&b,S=e.canAutoSelectYear,A=void 0===S||S,k=(0,F.Z)(),Q=(0,L.aC)().user,E=(0,C.useState)([]),B=E[0],z=E[1],N=(0,C.useState)([]),V=N[0],P=N[1],O=(0,C.useState)(null),K=O[0],U=O[1],G=(0,C.useState)(null),J=G[0],Y=G[1],$=(0,C.useState)(null),X=$[0],ee=$[1];(0,C.useEffect)((function(){var e=function(){var e=(0,t.Z)((function(){var e,n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,I()];case 1:return e=r.sent(),z(e),[3,3];case 2:return n=r.sent(),console.error(n),[3,3];case 3:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();e()}),[]),(0,C.useEffect)((function(){var e=function(){var e=(0,t.Z)((function(){var e,n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,_()];case 1:return e=r.sent(),P(e),[3,3];case 2:return n=r.sent(),console.error(n),[3,3];case 3:return[2]}}))}));return function(){return e.apply(this,arguments)}}();e()}),[]);var ne,re,te=(0,C.useMemo)((function(){var e;if(1===(null===Q||void 0===Q?void 0:Q.industry_id))return!0;var n=function(e){if(!e)return null;try{var n=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=JSON.parse(atob(n));return JSON.parse(r.sub)}catch(t){return null}},r=(0,H.parseCookies)(),t=r.token,i=r.original_refresh_token,o=n(t);return 1===(null===o||void 0===o?void 0:o.industry_id)||1===(null===o||void 0===o?void 0:o.original_industry_id)||1===(null===(e=n(i))||void 0===e?void 0:e.industry_id)}),[Q]),ie=(0,C.useMemo)((function(){var e=null!==B&&void 0!==B?B:[],n=new Map;return e.forEach((function(e){var r;(null!==(r=e.users)&&void 0!==r?r:[]).forEach((function(e){var r,t,i=n.get(e.user_id);i?(null!==(r=e.users)&&void 0!==r?r:[]).forEach((function(e){i.users.some((function(n){return n.industry_customer_id===e.industry_customer_id}))||i.users.push(e)})):n.set(e.user_id,(0,a.Z)((0,o.Z)({},e),{users:(0,l.Z)(null!==(t=e.users)&&void 0!==t?t:[])}))}))})),Array.from(n.values()).sort((function(e,n){return e.name.localeCompare(n.name)}))}),[B]),oe=(0,C.useMemo)((function(){var e;return(null!==(ne=null===(e=ie.find((function(e){return e.user_id===K})))||void 0===e?void 0:e.users)&&void 0!==ne?ne:[]).sort((function(e,n){return e.name.localeCompare(n.name)}))}),[ie,K]),ae=!te&&1===ie.length,ue=!te&&1===oe.length;(0,C.useEffect)((function(){te||1!==ie.length||null!==K||(U(ie[0].user_id),null===m||void 0===m||m(ie[0].user_id))}),[ie,te,K]),(0,C.useEffect)((function(){1===oe.length&&null===J&&(Y(oe[0].industry_customer_id),null===g||void 0===g||g(oe[0].industry_customer_id))}),[oe,J]),(0,C.useEffect)((function(){A&&null!==J&&1===V.length&&null===X&&(ee(V[0].id),null===y||void 0===y||y(V[0].id,V[0].year))}),[A,V,X,J]);var se,le=null!==(re=null!==s&&void 0!==s?s:null===ie||void 0===ie||null===(n=ie[0])||void 0===n?void 0:n.profile_name)&&void 0!==re?re:"Executivo de vendas",de=null!==(se=null!==f&&void 0!==f?f:null===oe||void 0===oe||null===(r=oe[0])||void 0===r?void 0:r.profile_name)&&void 0!==se?se:"Distribuidor (a)",ce=100===u;return(0,c.jsxs)(Z.Z,{display:"flex",alignItems:"flex-end",flexWrap:"wrap",width:"100%",sx:{rowGap:2,columnGap:3},children:[(0,c.jsxs)(Z.Z,{display:"flex",alignItems:"center",flexWrap:"wrap",gap:2,sx:{boxShadow:"1px 3px 4px rgba(0, 0, 0, 0.15)",borderRadius:1,backgroundColor:"#fff",flex:"1 1 480px",minWidth:280,minHeight:"78px",paddingLeft:"15px",paddingRight:"15px",paddingTop:"8px",paddingBottom:"8px",justifyContent:"space-around"},children:[(0,c.jsxs)(D.Z,{sx:{flex:"1 1 180px",minWidth:150},children:[(0,c.jsx)(M.Z,{variant:"body2",ml:1,gutterBottom:!0,sx:{fontSize:"15px",fontFamily:"Poppins",fontWeight:300,color:"#2E2E2E"},children:le}),(0,c.jsx)(R.Z,{color:"primary",sx:{color:"grey.800",backgroundColor:"#fff",borderRadius:1,fontSize:"13px","&.Mui-disabled":{backgroundColor:"grey.400"},width:"100%",height:"32px"},displayEmpty:!0,renderValue:function(e){var n;return e?null===(n=ie.find((function(n){return n.user_id===Number(e)})))||void 0===n?void 0:n.name:(0,c.jsx)(c.Fragment,{children:"Selecione aqui"})},size:"small",SelectDisplayProps:{style:{padding:k.spacing(.5,1.5)}},MenuProps:{sx:{maxHeight:"60%"},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"}},fullWidth:!0,disabled:!ie.length||ae,value:null!==K&&void 0!==K?K:"",onChange:function(e){var n=Number(e.target.value);U(n),Y(null),ee(null),null===m||void 0===m||m(n),null===g||void 0===g||g(null),null===y||void 0===y||y(null,null)},children:ie.map((function(e,n){return(0,c.jsx)(T.Z,{value:String(e.user_id),children:e.name},n)}))})]}),(0,c.jsxs)(D.Z,{sx:{flex:"1 1 180px",minWidth:150},children:[(0,c.jsx)(M.Z,{variant:"body2",ml:1,gutterBottom:!0,sx:{fontSize:"15px",fontFamily:"Poppins",fontWeight:300,color:"#2E2E2E"},children:de}),(0,c.jsx)(R.Z,{color:"primary",sx:{color:"grey.800",backgroundColor:"#fff",borderRadius:1,fontSize:"13px","&.Mu
1i-disabled":{backgroundColor:"grey.400"},width:"100%",height:"32px"},displayEmpty:!0,renderValue:function(e){var n;return e?null===(n=oe.find((function(n){return n.industry_customer_id===Number(e)})))||void 0===n?void 0:n.name:(0,c.jsx)(c.Fragment,{children:"Selecione aqui"})},size:"small",SelectDisplayProps:{style:{padding:k.spacing(.5,1.5)}},MenuProps:{sx:{maxHeight:"60%"},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"}},fullWidth:!0,disabled:!oe.length||ue,value:null!==J&&void 0!==J?J:"",onChange:function(e){var n=Number(e.target.value);Y(n),ee(null),null===g||void 0===g||g(n),null===y||void 0===y||y(null,null)},children:oe.map((function(e,n){return(0,c.jsx)(T.Z,{value:String(e.industry_customer_id),sx:{height:"32px",px:2,py:1},children:e.name},n)}))})]}),(0,c.jsxs)(Z.Z,{sx:{flex:"1 1 180px",minWidth:150},children:[(0,c.jsx)(M.Z,{ml:1,gutterBottom:!0,sx:{fontSize:"15px",fontFamily:"Poppins",fontWeight:300,color:"#2E2E2E"},children:"Ano"}),(0,c.jsx)(R.Z,{sx:{color:"grey.800",backgroundColor:"#fff",borderRadius:1,fontSize:"13px","&.Mui-disabled":{backgroundColor:"grey.400"},width:"100%",height:"32px"},MenuProps:{sx:{maxHeight:"60%"},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"}},displayEmpty:!0,disabled:!V.length,renderValue:function(e){var n;return e?null===(n=V.find((function(n){return n.id===Number(e)})))||void 0===n?void 0:n.year.toString():(0,c.jsx)(c.Fragment,{children:"Selecione aqui"})},size:"small",SelectDisplayProps:{style:{padding:"0.2rem 0.6rem",paddingRight:"1.5rem"}}
1,fullWidth:!0,value:null!==X&&void 0!==X?X:"",onChange:function(e){var n,r,t=Number(e.target.value);ee(t);var i=null!==(r=null===(n=V.find((function(e){return e.id===t})))||void 0===n?void 0:n.year)&&void 0!==r?r:null;null===y||void 0===y||y(t,i)},children:V.map((function(e){return(0,c.jsx)(T.Z,{value:e.id,sx:{height:"32px",px:2,py:1},children:e.year},e.id)}))})]})]}),(0,c.jsxs)(W.Z,{elevation:0,sx:{display:"flex",alignItems:"center",gap:2,p:"6px 16px",border:"1px solid",borderColor:"grey.200",borderRadius:"8px",backgroundColor:"#fff",boxShadow:"1px 3px 4px rgba(0, 0, 0, 0.15)",flex:"0 1 320px",minWidth:280,height:"78px",boxSizing:"border-box"},children:[(0,c.jsxs)(Z.Z,{sx:{position:"relative",display:"inline-flex"},children:[(0,c.jsx)(j.Z,{variant:"determinate",value:100,size:50,thickness:5,sx:{position:"absolute",top:0,left:0,color:"grey.200",transform:"rotate(110deg) !important","& .MuiCircularProgress-circle":{strokeLinecap:"round"}}}),(0,c.jsx)(j.Z,{variant:"determinate",value:u,color:ce?"success":"primary",size:50,thickness:5,sx:{transform:"rotate(110deg) !important","& .MuiCircularProgress-circle":{strokeLinecap:"round"}}}),(0,c.jsx)(Z.Z,{sx:{top:0,left:0,bottom:0,right:0,position:"absolute",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,c.jsx)(M.Z,{variant:"caption",sx:{fontSize:"1rem",fontWeight:"bold",color:ce?"success.main":"text.secondary"},children:"".concat(u,"%")})})]}),(0,c.jsxs)(Z.Z,{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,children:[(0,c.jsx)(M.Z,{sx:{fontSize:ce?"16px":"11px",lineHeight:1.1,color:ce?"success.main":"text.primary"},children:ce?"Preenchido com sucesso!":"Confira seu progresso"}),!q&&(0,c.jsx)(M.Z,{onClick:ce?w:void 0,sx:{fontSize:"12px",lineHeight:1.2,color:ce?"primary.main":"#707070",textDecoration:ce?"underline":"none",cursor:ce?"pointer":"default","&:hover":{color:ce?"primary.dark":"primary.main"}},children:ce?"Clique aqui e envie seu formul\xe1rio":"Voc\xea j\xe1 preencheu ".concat(v," de ").concat(x," question\xe1rios.")})]})]})]})};function K(e,n,r,t){var i=function(i){if(e.hasOwnProperty(i)){var u=e[i],s=U(i),l=s.question_id,d=s.repeat_value,c=n.find((function(e){return e.id===l}));if(!c)return console.warn("Quest\xe3o n\xe3o encontrada para o ID: ".concat(l)),"continue";var f=c.question_type_answer,p=null,v=null,_=null;switch(f){case P.Text:case P.Textarea:case P.Date:case P.Select:case P.Radio:p=u;break;case P.Money:var h="".concat(null!==u&&void 0!==u?u:"").replace(/[^\d]/g,"");v=""===h?null:Number(h)/100;break;case P.Number:case P.Percentage:v=""===u||null===u||void 0===u?null:Number(u);break;case P.Multiselect:case P.Checkbox:_=Array.isArray(u)?u.filter((function(e){return""!=="".concat(e).trim()})):[];break;default:console.warn("Tipo de resposta desconhecido: ".concat(f))}a.push((0,o.Z)({question_id:l,survey_group_id:r,answer_string:p,answer_number:v,answer_arraystring:_,repeat_value:d},t&&{pillar_id:t.pillar_id,applicable_questions_count:t.applicable_questions_count,answered_questions_count:t.answered_questions_count}))}},a=[];for(var u in e)i(u);return a}function U(e){for(var n=e.split("_"),r=0,t=[],i=0;i<n.length;i++)"q"===n[i]&&(r=parseInt(n[i+1],10)),"r"===n[i]&&t.push(n[i+1]);return{question_id:r,repeat_value:t.length?t.join("."):null}}!function(e){e.Text="text",e.Textarea="textarea",e.Number="number",e.Money="money",e.Percentage="percentage",e.Date="date",e.Select="select",e.Multiselect="multiselect",e.Radio="radio",e.Checkbox="checkbox",e.Unknown="unknown"}(P||(P={}));var G,J=r(1604),Y=J.z.string({required_error:"Este campo \xe9 obrigat\xf3rio",invalid_type_error:"Este campo \xe9 obrigat\xf3rio",description:"Este campo \xe9 obrigat\xf3rio"}).refine((function(e){return""!==e.trim()}),{message:"Este campo \xe9 obrigat\xf3rio"}),$=(G={},(0,i.Z)(G,P.Text,Y),(0,i.Z)(G,P.Textarea,Y),(0,i.Z)(G,P.Number,J.z.preprocess((function(e){return""===e?void 0:Number(e)}),J.z.number({required_error:"Deve ser um n\xfamero",invalid_type_error:"Deve ser um n\xfamero"}).nonnegative("Deve ser um n\xfamero n\xe3o negativo"))),(0,i.Z)(G,P.Money,J.z.preprocess((function(e){return""===e?void 0:parseFloat(String(e).replace(/[^\d]/g,""))/100}
1),J.z.number({required_error:"Deve ser um n\xfamero",invalid_type_error:"Deve ser um valor monet\xe1rio v\xe1lido"}).nonnegative("Deve ser um valor n\xe3o negativo"))),(0,i.Z)(G,P.Percentage,J.z.preprocess((function(e){return""===e?void 0:Number(e)}),J.z.number({required_error:"Deve ser um n\xfamero",invalid_type_error:"Deve ser um n\xfamero"}).min(0,"M\xednimo 0%").max(100,"M\xe1ximo 100%"))),(0,i.Z)(G,P.Date,Y),(0,i.Z)(G,P.Select,Y),(0,i.Z)(G,P.Multiselect,J.z.array(Y,{description:"Selecione pelo menos uma op\xe7\xe3o",invalid_type_error:"Selecione pelo menos uma op\xe7\xe3o",required_error:"Selecione pelo menos uma op\xe7\xe3o"}).nonempty("Selecione pelo menos uma op\xe7\xe3o")),(0,i.Z)(G,P.Radio,Y),(0,i.Z)(G,P.Checkbox,J.z.array(Y).nonempty("Selecione pelo menos uma op\xe7\xe3o")),(0,i.Z)(G,P.Unknown,J.z.optional(J.z.any())),G);function X(e){var n=new Map;e.forEach((function(e){n.set(e.id,(0,a.Z)((0,o.Z)({},e),{children:[]}))}));var r=new Set;e.forEach((function(e){if(null!==e.question_parent_id){var t=n.get(e.question_parent_id);!!t&&(!!t.group_questions_when_parent||!!e.show_case_answer_parent&&!e.question_show_case_parent_id)&&(t.children.push(n.get(e.id)),r.add(e.id))}}));var t=[];return e.forEach((function(e){r.has(e.id)||t.push(n.get(e.id))})),t}function ee(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(e.repeat_for_each_value||e.question_parent_id||!e.question_dependency_id)return null;if(r.has(e.id))return null;r.add(e.id);var t=n(e.question_dependency_id);return t?t.group_questions_inline?t.id:ee(t,n,r):null}function ne(e,n){var r=n(e);if(!r)return null;if(!r.question_parent_id)return"answer_q_".concat(e);var t=ne(r.question_parent_id,n);return null===t?null:"".concat(t,"_q_").concat(e)}function re(e,n,r,t){if(!n)return[];var i=t(e);if(!i)return[];var o=ne(e,t);if(null===o)return[];var a=i.question_dependency_id;if(!a)return[];for(var u=Number(r("answer_q_".concat(a)))||0,s=[],l=0;l<u;l++){var d=r("".concat(o,"_r_").concat(l));Array.isArray(d)&&d.includes(n)&&s.push({label:(l+1).toString(),index:l})}return s}function te(e,n,r,t){var i=r.find((function(n){return n.question_show_case_parent_id===e&&!!n.show_case_answer_parent}));if(!i)return n;var o,a=i.show_case_answer_parent;if(!n.includes(a))return n;var u=t(null!==(o=ne(i.id,(function(e){return r.find((function(n){return n.id===e}))})))&&void 0!==o?o:"answer_q_".concat(i.id)),s="string"===typeof u?u.split(",").map((function(e){return e.trim()})).filter(Boolean):[];return(0,l.Z)(n.filter((function(e){return e!==a}))).concat((0,l.Z)(s))}function ie(e){var n=[],r=!0,t=!1,i=void 0;try{for(var o,a=function(){var r=o.value;if(!r.question_parent_anchor_id)return"continue";var t=e.find((function(e){return e.id===r.question_parent_anchor_id}));if(!t)return"continue";n.push({parentQuestion:t,childQuestion:r,message:"N\xe3o pode ser maior que a quantidade de funcion\xe1rios do time comercial informada acima"})},u=e[Symbol.iterator]();!(r=(o=u.next()).done);r=!0)a()}catch(s){t=!0,i=s}finally{try{r||null==u.return||u.return()}finally{if(t)throw i}}return n}var oe="Este campo \xe9 obrigat\xf3rio";function ae(e,n,r){var t=e.find((function(e){return"2.1.12"===e.hierarchy_default}));if(!t)return[];var i=[];return ve(t,i,"",n,e,r),i.map((function(e){return e.key})).filter((function(e){return function(e){var n=/_q_(\d+)$/.exec(e);return n?Number(n[1]):null}(e)!==t.id}))}function ue(e){return void 0===e||null===e||("string"===typeof e?""===e.trim():!!Array.isArray(e)&&0===e.length)}function se(e){return le.apply(this,arguments)}function le(){return(le=(0,t.Z)((function(e){var n,r,t,i,o,a,u,s,l,c,f,p,v,_,h,x,m,g,y,w,b,Z,j,q,S,A,k,C,Q,E,B,M,z,N,V,P,I,L,F,D,R,T,W,H,O,K,U,G,J,Y,X,ee,re,te,se,le,de,ce,pe,_e,he;return(0,d.__generator)(this,(function(d){switch(d.label){case 0:n=e.clearErrors,r=e.setError,t=e.selectedQuestion,i=e.watchedAnswers,o=e.questions,a=e.getAnswer,u=e.validateRepeatIndex,n(),ve(t,s=[],"",i,o,a,u,void 0,l=[],c=[]),f=!0,p=!0,v=!1,_=void 0,d.label=1;case 1:d.trys.push([1,6,7,8]),h=s[Symbol.iterator](),d.label=2;case 2:return(p=(x=h.next()).done)?[3,5]:(m=x.value,[4,$[m.type].safeParse(i[m.key])]);case 3:(g=d.sent()).success||(r(m.key,{type:"manual",message:g.error.errors[0].message}),f=!1),d.label=4;case 4:return p=!0,[3,2];case 5:return[3,8];case 6:return y=d.sent(),v=!0,_=y,[3,8];case 7:try{p||null==h.return||h.return()}finally{if(v)throw _}
1return[7];case 8:w=!0,b=!1,Z=void 0;try{for(j=ae(o,i,a)[Symbol.iterator]();!(w=(q=j.next()).done);w=!0)S=q.value,ue(i[S])&&(r(S,{type:"manual",message:oe}),f=!1)}catch(y){b=!0,Z=y}finally{try{w||null==j.return||j.return()}finally{if(b)throw Z}}A=!0,k=!1,C=void 0;try{for(Q=c[Symbol.iterator]();!(A=(E=Q.next()).done);A=!0){B=E.value,M=!0,z=!1,N=void 0;try{for(V=B.keys[Symbol.iterator]();!(M=(P=V.next()).done);M=!0)I=P.value,r(I,{type:"manual",message:"Cada ind\xfastria selecionada deve estar em pelo menos uma pasta. Sem pasta: ".concat(B.missing.join(", "))})}catch(y){z=!0,N=y}finally{try{M||null==V.return||V.return()}finally{if(z)throw N}}f=!1}}catch(y){k=!0,C=y}finally{try{A||null==Q.return||Q.return()}finally{if(k)throw C}}L=!0,F=!1,D=void 0;try{for(R=ie(o)[Symbol.iterator]();!(L=(T=R.next()).done);L=!0)W=T.value,H=function(e){return fe(e,o)},O=ne(W.parentQuestion.id,H),K=ne(W.childQuestion.id,H),O&&K&&(U=Number(i[O]),G=Number(i[K]),Number.isFinite(U)&&Number.isFinite(G)&&G>U&&(r(K,{type:"manual",message:W.message}),f=!1))}catch(y){F=!0,D=y}finally{try{L||null==R.return||R.return()}finally{if(F)throw D}}J=!0,Y=!1,X=void 0;try{for(ee=l[Symbol.iterator]();!(J=(re=ee.next()).done);J=!0)if(te=re.value,se=te.keys.reduce((function(e,n){return e+(Number(i[n])||0)}),0),Math.abs(se-100)>.001){le=!0,de=!1,ce=void 0;try{for(pe=te.keys[Symbol.iterator]();!(le=(_e=pe.next()).done);le=!0)he=_e.value,r(he,{type:"manual",message:"A soma dos percentuais entre as pastas deve ser 100%"})}catch(y){de=!0,ce=y}finally{try{le||null==pe.return||pe.return()}finally{if(de)throw ce}}f=!1}}catch(y){Y=!0,X=y}finally{try{J||null==ee.return||ee.return()}finally{if(Y)throw X}}return[2,{isValid:f,validations:s}]}}))}))).apply(this,arguments)}function de(e,n){return n?"".concat(n,"_q_").concat(e):"answer_q_".concat(e)}function ce(e,n){return Array.isArray(e)?e.includes(n):void 0!==e&&null!==e&&"".concat(e)===n}function fe(e,n){return n.find((function(n){return n.id===e}))}function pe(e,n){var r;return(null===(r=e.children)||void 0===r?void 0:r.length)?e.children:n.filter((function(n){return n.question_parent_id===e.id&&(!!e.group_questions_when_parent||!!n.show_case_answer_parent&&!n.question_show_case_parent_id)}))}function ve(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",t=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,u=arguments.length>7?arguments[7]:void 0,s=arguments.length>8?arguments[8]:void 0,l=arguments.length>9?arguments[9]:void 0;if(e.question_show_case_parent_id&&e.show_case_answer_parent){var d=t["answer_q_".concat(e.question_show_case_parent_id)],c=ce(d,e.show_case_answer_parent),f=c;if(!f){var p,v,_=o(e.question_show_case_parent_id,""),h=null!==(v=null!==(p=null===_||void 0===_?void 0:_.answer_arraystring)&&void 0!==p?p:null===_||void 0===_?void 0:_.answer_string)&&void 0!==v?v:null===_||void 0===_?void 0:_.answer_number;f=ce(h,e.show_case_answer_parent)}if(!f)return}else if(e.question_parent_id&&e.show_case_answer_parent){var x=t[r],m=Array.isArray(x)?x.includes(e.show_case_answer_parent):x===e.show_case_answer_parent;if(!m)return}var g=de(e.id,r),y=e.repeat_for_each_value&&e.question_dependency_id?fe(e.question_dependency_id,i):void 0,w=!!e.question_parent_id&&!!r&&(null===y||void 0===y?void 0:y.question_type_answer)===P.Unknown;if(e.repeat_for_each_value&&e.question_dependency_id&&!w){var b=de(e.question_dependency_id,""),Z=t[b],j=fe(e.question_dependency_id,i);if(j){var q=j.question_type_answer;if(q===P.Multiselect&&Array.isArray(Z))for(var S=function(r){if(void 0!==a&&a!==r)return"continue";var u="".concat(g,"_r_").concat(r);e.question_type_answer!==P.Unknown&&n.push({key:u,type:e.question_type_answer});var d=A[r];pe(e,i).forEach((function(e){ve(e,n,u,t,i,o,void 0,d,s,l)}))},A=te(e.question_dependency_id,Z,i,(function(e){return t[e]})),k=0;k<A.length;k++)S(k);else if(q===P.Number){for(var C=function(r){if(void 0!==a&&a!==r)return"continue";var u="".concat(g,"_r_").concat(r);e.question_type_answer!==P.Unknown&&n.push({key:u,type:e.question_type_answer});var d=(r+1).toString();
1pe(e,i).forEach((function(e){ve(e,n,u,t,i,o,void 0,d,s,l)}))},Q=Number(Z)||0,E=0;E<Q;E++)C(E);if(l&&void 0===a&&e.question_type_answer===P.Multiselect&&e.question_options_dependency_id&&Q>0){var B,M=e.question_options_dependency_id,z=null!==(B=ne(M,(function(e){return fe(e,i)})))&&void 0!==B?B:"answer_q_".concat(M),N=t[z],V=te(M,Array.isArray(N)?N:[],i,(function(e){return t[e]}));if(V.length){for(var I=new Set,L=[],F=0;F<Q;F++){var D="".concat(g,"_r_").concat(F);L.push(D);var R=t[D];Array.isArray(R)&&R.forEach((function(e){return I.add(e)}))}var T=V.filter((function(e){return!I.has(e)}));T.length&&l.push({keys:L,missing:T})}}}}}else if(e.repeat_for_each_value&&e.question_reverse_lookup_id){var W=e.question_reverse_lookup_id,H=function(e){return fe(e,i)},O=re(W,null!==u&&void 0!==u?u:"",(function(e){return t[e]}),H),K=[],U=!0,G=!1,J=void 0;try{for(var Y,$=function(){var r=Y.value.index;if(void 0!==a&&a!==r)return"continue";var d="".concat(g,"_r_").concat(r);e.question_type_answer!==P.Unknown&&n.push({key:d,type:e.question_type_answer}),K.push(d),pe(e,i).forEach((function(e){ve(e,n,d,t,i,o,void 0,u,s,l)}))},X=O[Symbol.iterator]();!(U=(Y=X.next()).done);U=!0)$()}catch(oe){G=!0,J=oe}finally{try{U||null==X.return||X.return()}finally{if(G)throw J}}K.length>0&&s&&s.push({keys:K})}else{e.question_type_answer!==P.Unknown&&n.push({key:g,type:e.question_type_answer}),pe(e,i).forEach((function(e){ve(e,n,g,t,i,o,void 0,u,s,l)}));var ie=i.filter((function(n){return n.question_dependency_id===e.id&&!n.question_parent_id&&(n.repeat_for_each_value||null!==ee(n,(function(e){return fe(e,i)})))}));ie.forEach((function(e){ve(e,n,"",t,i,o,void 0,void 0,s,l)}))}}var _e=function(e){return null!==e.answer_arraystring?e.answer_arraystring.length>0:null!==e.answer_string?""!==e.answer_string.trim():null!==e.answer_number},he=function(e,n,r){if(n&&e in n)return void 0!==(t=n[e])&&null!==t&&(Array.isArray(t)?t.length>0:"string"!==typeof t||""!==t.trim());var t,i,o=U(e),a=o.question_id,u=o.repeat_value,s=r.find((function(e){return e.question_id===a&&(null!==(i=e.repeat_value)&&void 0!==i?i:"")===(null!==u&&void 0!==u?u:"")}));return!!s&&_e(s)},xe=function(e,n,r,t){var i=0,o=0;return e.forEach((function(e){if("unknown"!==e.question_type_answer){var a=t.get(e.id);if(null===a||void 0===a?void 0:a.length)return i+=a.length,void(o+=a.filter((function(e){return he(e,r,n)})).length);e.repeat_for_each_value||function(e,n,r){if(!e.show_case_answer_parent)return!0;if(e.question_show_case_parent_id){if(ce(null===r||void 0===r?void 0:r["answer_q_".concat(e.question_show_case_parent_id)],e.show_case_answer_parent))return!0;var t,i,o=n.find((function(n){return n.question_id===e.question_show_case_parent_id}));return ce(null!==(i=null!==(t=null===o||void 0===o?void 0:o.answer_arraystring)&&void 0!==t?t:null===o||void 0===o?void 0:o.answer_string)&&void 0!==i?i:null===o||void 0===o?void 0:o.answer_number,e.show_case_answer_parent)}var a=n.find((function(n){return n.question_id===e.question_parent_id}));return!!a&&(Array.isArray(a.answer_arraystring)?a.answer_arraystring.includes(e.show_case_answer_parent):a.answer_string===e.show_case_answer_parent)}(e,n,r)&&(i++,n.some((function(n){return n.question_id===e.id&&_e(n)}))&&o++)}})),{total:i,answered:o}};function me(e,n,r,t){var i,u=new Map,s=function(e){var n=new Map;return e.forEach((function(e){var r=U(e).question_id;if(r){var t,i=null!==(t=n.get(r))&&void 0!==t?t:[];i.push(e),n.set(r,i)}})),n}(function(e,n,r){var t=[];return X(e).forEach((function(i){ve(i,t,"",n,e,r)})),Array.from(new Set(t.map((function(e){return e.key}))))}(n,null!==t&&void 0!==t?t:{},(function(e,n){return r.find((function(r){return r.question_id===e&&(null!==(i=r.repeat_value)&&void 0!==i?i:"")===(null!==n&&void 0!==n?n:"")}))})));return e.forEach((function(e){u.has(e.pillar_id)||u.set(e.pillar_id,(0,a.Z)((0,o.Z)({},e),{question_count:0,question_count_answered:0,levels:[]}));var i=u.get(e.pillar_id),l=n.filter((function(n){return n.pillar_id===e.pillar_id})),d=xe(l,r,t,s);i.question_count=d.total,i.question_count_answered=d.answered;var c=i.levels.find((function(n){return n.level_2_id===e.level_2_id}));if(!c){var f=l.filter((function(n){return n.level_2_id===e.level_2_id})),p=xe(f,r,t,s);c=(0,a.Z)((0,o.Z)({},e),{question_count:p.total,question_count_answered:p.answered,levels:[]}),i.levels.push(c)}if(e.level_3_id){var v=c.levels.find((function(n){return n.level_3_id===e.level_3_id}));if(!v){var _=n.filter((function(n){return n.pillar_id===e.pillar_id&&n.level_2_id===e.level_2_id&&n.level_3_id===e.level_3_id})),h=xe(_,r,t,s);v=(0,a.Z)((0,o.Z)({},e),{question_count:h.total,question_count_answered:h.answered,levels:[]}),c.levels.push(v)}if(e.level_4_id){var x=v.levels.find((function(n){return n.level_4_id===e.level_4_id}));if(!x){var m=n.filter((function(n){return n.pillar_id===e.pillar_id&&n.level_2_id===e.level_2_id&&n.level_3_id===e.level_3_id&&n.level_4_id===e.level_4_id})),g=xe(m,r,t,s);x=(0,a.Z)((0,o.Z)({},e),{question_count:g.total,question_count_answered:g.answered}),v.levels.push(x)}}}})),Array.from(u.values())}var ge=r(2783),ye=r(90948),we=r(4020);(0,ye.ZP)(ge.Z)((function(e){var n;return n={color:e.theme.palette.grey[200]},(0,i.Z)(n,"& .".concat(we.Z.iconContainer),{display:"none"}),(0,i.Z)(n,"& .".concat(we.Z.label),{padding:"0"}),(0,i.Z)(n,"& .".concat(we.Z.expanded),{padding:"0"}),(0,i.Z)(n,"& .".concat(we.Z.content),(0,i.Z)({padding:"0"},"& .".concat(we.Z.iconContainer),{display:"none"})),n}));var be=Object.values(P);function Ze(e){if(!e)return P.Unknown;var n=e.trim().toLowerCase().replace(/[\s_-]/g,""),r=be.find((function(e){return e.replace(/[\s_-]/g,"")===n}));return null!==r&&void 0!==r?r:P.Unknown}function je(e){if(null===e||void 0===e||""===e)return null;if("number"===typeof e)return Number.isFinite(e)?e:null;var n=e.match(/-?\d+/);return n?Number(n[0]):null}var qe=function(e){var n=e.question,r=e.answers,t=e.getQuestion,i=e.parentKey,o=void 0===i?"":i,a=e.parentLabel,u=e.getAnswer,s=e.surveyAlreadySubmitted,l=(e.step,e.upsertQuestions),d=e.control,c=e.watch,f=e.setValue,p=e.allQuestions,v=n.id,_=n.question_dependency_id,h=n.question_reverse_lookup_id,x=n.question_parent_id,m=n.question_show_case_parent_id,g=n.show_case_answer_parent,y=n.group_questions_when_parent,w=n.repeat_for_each_value,b=(n.hierarchy_default,n.question,n.children),Z=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,t=n?"".concat(n,"_q_").concat(e):"answer_q_".concat(e);return r&&(t+="_r_".concat(r)),t},j=function(e,n){return Array.isArray(e)?e.includes(n):void 0!==e&&null!==e&&"".concat(e)===n};if(!function(){if(m&&g){var e=c("answer_q_".concat(m));if(j(e,g))return!0;var n,r,t=u(m,""),i=null!==(r=null!==(n=null===t||void 0===t?void 0:t.answer_arraystring)&&void 0!==n?n:null===t||void 0===t?void 0:t.answer_string)&&void 0!==r?r:null===t||void 0===t?void 0:t.answer_number;return j(i,g)}if(x&&g){var a=c(o);return Array.isArray(a)?a.includes(g):a===g}return!0}())return null;var q=function(){if(w&&_){var e=Z(_,""),n=c(e),r=t(_).question_type_answer;if(r===P.Multiselect&&Array.isArray(n))return te(_,n,null!==p&&void 0!==p?p:[],c).map((function(e,n){return{label:e,index:n}}));if(r===P.Number){var i=Number(n);return Array.from({length:i}).map((function(e,n){return{label:(n+1).toString(),index:n}}))}}return w&&h?re(h,null!==a&&void 0!==a?a:"",c,t):[]}();if(!h||0!==q.length){if(q.length>0)return q.forEach((function(e){var i=e.label,a=e.index,l="".concat(Z(v,o,a.toString()));Se({question:n,control:d,watch:c,name:l,getAnswer:u,disabled:s||!!n.disabled,setValue:f}),null===b||void 0===b||b.forEach((function(e){return qe({question:e,answers:r,getQuestion:t,getAnswer:u,parentKey:l,parentLabel:i,surveyAlreadySubmitted:s,control:d,watch:c,setValue:f,allQuestions:p})}))}));var S=Z(v,o);Se({question:n,control:d,watch:c,name:S,getAnswer:u,disabled:s||!!n.disabled,setValue:f}),null===b||void 0===b||b.filter((function(e){return y||!!e.show_case_answer_parent&&!e.question_show_case_parent_id}
1)).forEach((function(e){return qe({question:e,answers:r,getQuestion:t,getAnswer:u,parentKey:S,parentLabel:a,surveyAlreadySubmitted:s,upsertQuestions:l,control:d,watch:c,allQuestions:p,setValue:f})})),null===p||void 0===p||p.filter((function(e){return e.repeat_for_each_value&&e.question_dependency_id===v&&!e.question_parent_id})).forEach((function(e){qe({question:e,answers:r,getQuestion:t,getAnswer:u,parentKey:"",parentLabel:void 0,surveyAlreadySubmitted:s,upsertQuestions:l,control:d,watch:c,setValue:f,allQuestions:p})}))}},Se=function(e){var n=e.question,r=e.name,t=e.watch,i=e.getAnswer,o=e.setValue,a=U(null!==r&&void 0!==r?r:""),u=i(a.question_id,a.repeat_value||""),s=Array.isArray(null===u||void 0===u?void 0:u.answer_arraystring)?u.answer_arraystring.filter((function(e){return""!=="".concat(e).trim()})):null===u||void 0===u?void 0:u.answer_arraystring,d=(null===u||void 0===u?void 0:u.answer_string)||(null!==(null===u||void 0===u?void 0:u.answer_number)&&void 0!==(null===u||void 0===u?void 0:u.answer_number)?u.answer_number:s),c=t(r),f=Array.isArray(c)&&!c.length?d:c||d;if(n.default_option)if(n.question_type_answer===P.Multiselect||n.question_type_answer===P.Checkbox){var p=Array.isArray(f)?f:[];p.includes(n.default_option)||(f=(0,l.Z)(p).concat([n.default_option]))}else f||(f=n.default_option);if(n.question_type_answer===P.Money)return f?void o(r,f.toLocaleString("pt-BR",{style:"currency",currency:"BRL"}),{shouldValidate:!0}):void o(r,"",{shouldValidate:!1});o(r,f,{shouldValidate:!0})},Ae=r(53219),ke=function(e){return(0,c.jsx)(Ae.Z,(0,a.Z)((0,o.Z)({},e),{viewBox:"0 0 18 18",children:(0,c.jsx)("g",{fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:(0,c.jsx)("path",{d:"M2.25 15.75h13.5M6.75 6h.75M6.75 9h.75M6.75 12h.75M10.5 6h.75M10.5 9h.75M10.5 12h.75M3.75 15.75v-12a1.5 1.5 0 0 1 1.5-1.5h7.5a1.5 1.5 0 0 1 1.5 1.5v12"})})}))},Ce=function(e){return(0,c.jsxs)(Ae.Z,(0,a.Z)((0,o.Z)({},e),{viewBox:"0 0 16 16",children:[(0,c.jsx)("circle",{cx:"8",cy:"8",r:"7.5",fill:e.color?"currentColor":"#03a72e",stroke:e.color?"currentColor":"#03a72e"}),(0,c.jsx)("path",{stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"m5 8 2 2 4-4"})]}))},Qe=function(e){return(0,c.jsx)(Ae.Z,(0,a.Z)((0,o.Z)({},e),{viewBox:"0 0 18 18",children:(0,c.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M3.75 12.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 0 0-3 0M11.25 12.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 0 0-3 0"}),(0,c.jsx)("path",{d:"M3.75 12.75h-1.5v-3m-.75-6h8.25v9m-3 0h4.5M9.75 4.5h3.75l2.25 3.75v4.5h-1.5m1.5-4.5h-6M2.25 6.75h3"})]})}))},Ee=function(e){return(0,c.jsx)(Ae.Z,(0,a.Z)((0,o.Z)({},e),{viewBox:"0 0 18 18",children:(0,c.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{fill:"currentColor",d:"M6.375 7.125a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5"}),(0,c.jsx)("path",{d:"M3 5.25v2.894c0 .403.16.79.445 1.074l6.087 6.087a1.517 1.517 0 0 0 2.148 0l3.625-3.625a1.517 1.517 0 0 0 0-2.148L9.218 3.445A1.52 1.52 0 0 0 8.143 3H5.25A2.25 2.25 0 0 0 3 5.25"})]})}))},Be=function(e){return(0,c.jsx)(Ae.Z,(0,a.Z)((0,o.Z)({},e),{viewBox:"0 0 18 18",children:(0,c.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M8.25 9a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0"}),(0,c.jsx)("path",{d:"M9 5.25A3.75 3.75 0 1 0 12.75 9"}),(0,c.jsx)("path",{d:"M9.75 2.291a6.75 6.75 0 1 0 5.955 5.96"}),(0,c.jsx)("path",{d:"M11.25 4.5v2.25h2.25l2.25-2.25H13.5V2.25zM11.25 6.75 9 9"})]})}))},Me=function(e){return(0,c.jsx)(Ae.Z,(0,a.Z)((0,o.Z)({},e),{viewBox:"0 0 18 18",children:(0,c.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M7.5 13.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 0 0-3 0M3.75 4.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 0 0-3 0M11.25 4.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 0 0-3 0"}),(0,c.jsx)("path",{d:"M5.25 6v1.5A1.5 1.5 0 0 0 6.75 9h4.5a1.5 1.5 0 0 0 1.5-1.5V6M9 9v3"})]})}))},ze=r(67358),Ne=r(38895),Ve=r(22797),Pe=r(21023),Ie=r(26447),Le=r(82783),Fe=r(87536),De=r(50135),Re=r(87109),Te=r(56815),We=r(75438),He=r(50480),Oe=r(69368),Ke=r(59334),Ue=r(53457),Ge=r(42761),Je=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()},Ye=function(e){var n=e.question,r=e.name,t=e.control,i=e.watch,u=e.disabled,s=void 0!==u&&u,d=e.getAnswer,f=e.flatQuestions,p=e.onAnswerBlur,v=(0,Fe.Gc)().setValue,_=(0,C.useState)(""),h=_[0],x=_[1],m=n.question_type_answer,g=n.question_options_dependency_id,y=Array.isArray(null===n||void 0===n?void 0:n.question_options)?n.question_options:[];if(g){var w,b,j=null!==(w=ne(g,(function(e){return f.find((function(n){return n.id===e}))})))&&void 0!==w?w:"answer_q_".concat(g),q=null!==(b=i(j))&&void 0!==b?b:[],S=te(g,q,f,i);y=S.length?S:y}(0,C.useEffect)((function(){var e=U(null!==r&&void 0!==r?r:""),t=d(e.question_id,e.repeat_value||""),o=Array.isArray(null===t||void 0===t?void 0:t.answer_arraystring)?t.answer_arraystring.filter((function(e){return""!=="".concat(e).trim()})):null===t||void 0===t?void 0:t.answer_arraystring,a=(null===t||void 0===t?void 0:t.answer_string)||(null!==(null===t||void 0===t?void 0:t.answer_number)&&void 0!==(null===t||void 0===t?void 0:t.answer_number)?t.answer_number:o),u=i(r),s=Array.isArray(u)&&!u.length?a:u||a;if(n.default_option)if(n.question_type_answer===P.Multiselect||n.question_type_answer===P.Checkbox){var c=Array.isArray(s)?s:[];c.includes(n.default_option)||(s=(0,l.Z)(c).concat([n.default_option]))}else s||(s=n.default_option);if(n.question_type_answer!==P.Money)v(r,s,{shouldValidate:!0});
1else{var f=s?s.toLocaleString("pt-BR",{style:"currency",currency:"BRL"}):"";v(r,f,{shouldValidate:!1})}}),[r]);var A=i(r),k=Array.isArray(A)?A.join("|"):"";(0,C.useEffect)((function(){if(m===P.Multiselect&&Array.isArray(A)){var e=function(e){return f.find((function(n){return n.id===e}))},r=f.filter((function(e){return e.question_options_dependency_id===n.id}));if(r.length){var t=te(n.id,A,f,i),o=function(e){var n=i(e);if(Array.isArray(n)){var r=n.filter((function(e){return t.includes(e)}));r.length!==n.length&&v(e,r,{shouldDirty:!0})}};r.forEach((function(n){var r=ne(n.id,e);if(r)if(n.repeat_for_each_value){if(n.question_dependency_id){var t=e(n.question_dependency_id);if((null===t||void 0===t?void 0:t.question_type_answer)===P.Number)for(var a=Number(i("answer_q_".concat(n.question_dependency_id)))||0,u=0;u<a;u++)o("".concat(r,"_r_").concat(u))}}else o(r)}))}}}),[k]);var Q=y.join("|");switch((0,C.useEffect)((function(){if(g){var e=i(r);if(Array.isArray(e)){var n=e.filter((function(e){return y.includes(e)}));n.length!==e.length&&v(r,n,{shouldDirty:!0})}else e&&!y.includes(e)&&v(r,"",{shouldDirty:!0})}}),[Q,r]),m){case P.Text:return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:"",render:function(e){var n,r=e.field,t=e.fieldState;return(0,c.jsx)(De.Z,(0,a.Z)((0,o.Z)({size:"small"},r),{onBlur:function(){r.onBlur(),null===p||void 0===p||p()},error:!!t.error,helperText:null===(n=t.error)||void 0===n?void 0:n.message,fullWidth:!0,disabled:s,hiddenLabel:!0,placeholder:"Digite aqui sua resposta",sx:{"& .MuiInputBase-root":{height:"32px"}}}))}},r);case P.Textarea:var E;return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:"",render:function(e){var n,r,t=e.field,i=e.fieldState;return(0,c.jsx)(De.Z,(0,a.Z)((0,o.Z)({size:"small"},t),{onBlur:function(){t.onBlur(),null===p||void 0===p||p()},error:!!i.error,helperText:(0,c.jsxs)(Z.Z,{component:"span",sx:{display:"flex",justifyContent:"space-between"},children:[(0,c.jsx)("span",{children:null===(n=i.error)||void 0===n?void 0:n.message}),(0,c.jsxs)(Z.Z,{component:"span",color:"rgba(0, 0, 0, 0.6)",children:[null!==(E=null===t||void 0===t||null===(r=t.value)||void 0===r?void 0:r.length)&&void 0!==E?E:0,"/1000"]})]}),fullWidth:!0,multiline:!0,rows:4,disabled:s,hiddenLabel:!0,inputProps:{maxLength:1e3}}))}},r);case P.Money:return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:"",render:function(e){var n,r=e.field,t=e.fieldState;return(0,c.jsx)(De.Z,(0,a.Z)((0,o.Z)({size:"small"},r),{value:r.value,onChange:function(e){r.onChange(function(e){var n,r=null!==(n=null===e||void 0===e?void 0:e.replace(/[^\d]/g,""))&&void 0!==n?n:"";return""===r?"":(Number(r)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}(e.target.value))},onBlur:function(){r.onBlur(),null===p||void 0===p||p()},inputProps:{pattern:"d+(?:[.,]d+)?"},placeholder:"R$ 0,00",type:"text",error:!!t.error,helperText:null===(n=t.error)||void 0===n?void 0:n.message,fullWidth:!0,disabled:s,hiddenLabel:!0,sx:{"& .MuiInputBase-root":{height:"32px"}}}))}},r);case P.Number:case P.Percentage:return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:"",render:function(e){var n,r=e.field,t=e.fieldState;return(0,c.jsx)(De.Z,(0,a.Z)((0,o.Z)({size:"small"},r),{onBlur:function(){r.onBlur(),null===p||void 0===p||p()},type:"number",error:!!t.error,helperText:null===(n=t.error)||void 0===n?void 0:n.message,fullWidth:!0,disabled:s,hiddenLabel:!0,InputProps:m===P.Percentage?{endAdornment:(0,c.jsx)(Re.Z,{position:"end",children:"%"})}:void 0,sx:{"& .MuiInputBase-root":{height:"32px"}}}))}},r);case P.Date:return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:"",render:function(e){var n,r=e.field,t=e.fieldState;return(0,c.jsx)(De.Z,(0,a.Z)((0,o.Z)({size:"small"},r),{onBlur:function(){r.onBlur(),null===p||void 0===p||p()},type:"date",InputLabelProps:{shrink:!0},error:!!t.error,helperText:null===(n=t.error)||void 0===n?void 0:n.message,fullWidth:!0,disabled:s,hiddenLabel:!0,sx:{"& .MuiInputBase-root":{height:"32px"}}}))}},r);case P.Select:return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:"",render:function(e){var n=e.field,r=e.fieldState;return(0,c.jsxs)(D.Z,{fullWidth:!0,error:!!r.error,children:[(0,c.jsx)(R.Z,(0,a.Z)((0,o.Z)({},n),{onBlur:function(){n.onBlur(),null===p||void 0===p||p()},displayEmpty:!0,renderValue:function(e){return e||(0,c.jsx)(Z.Z,{component:"span",color:"rgba(0, 0, 0, 0.42)",children:"Selecione aqui"})},disabled:s,size:"small",sx:{height:"32px"},children:null===y||void 0===y?void 0:y.map((function(e,n){return(0,c.jsx)(T.Z,{value:e,children:e},n)}))})),r.error&&(0,c.jsx)(Te.Z,{children:r.error.message})]})}},r);case P.Multiselect:var B=h?null===y||void 0===y?void 0:y.filter((function(e){return Je(e).includes(Je(h))})):y;return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:[],render:function(e){var r=e.field,t=e.fieldState,i=Array.isArray(r.value)?r.value:[],u=null!==B&&void 0!==B?B:[],d=u.length>0&&u.every((function(e){return i.includes(e)})),f=u.some((function(e){return i.includes(e)}));return(0,c.jsxs)(D.Z,{fullWidth:!0,error:!!t.error,children:[(0,c.jsxs)(R.Z,(0,a.Z)((0,o.Z)({},r),{value:i,onBlur:function(){r.onBlur(),null===p||void 0===p||p()},multiple:!0,displayEmpty:!0,onClose:function(){return x("")},MenuProps:{autoFocus:!1,PaperProps:{style:{maxHeight:320}}},renderValue:function(e){return e.length?e.join(", "):(0,c.jsx)(Z.Z,{component:"span",color:"rgba(0, 0, 0, 0.42)",children:"Selecione aqui"})},disabled:s,size:"small",sx:{height:"32px"},children:[(0,c.jsxs)(We.Z,{sx:{p:1,lineHeight:"normal"},children:[(0,c.jsx)(De.Z,{size:"small",autoFocus:!0,fullWidth:!0,placeholder:"Buscar...",value:h,onChange:function(e){return x(e.target.value)},InputProps:{startAdornment:(0,c.jsx)(Re.Z,{position:"start",children:(0,c.jsx)(Ge.Z,{fontSize:"small"})})},onKeyDown:function(e){"Escape"!==e.key&&e.stopPropagation()}}),u.length>0&&(0,c.jsx)(He.Z,{sx:{ml:0,mt:.5},onClick:function(e){return e.stopPropagation()},control:(0,c.jsx)(Oe.Z,{size:"small",checked:d,indeterminate:f&&!d,onChange:function(){var e=new Set(u);
1if(d){var t=i.filter((function(r){return!e.has(r)||r===n.default_option}));r.onChange(t)}else{var o=Array.from(new Set((0,l.Z)(i).concat((0,l.Z)(u))));r.onChange(o)}}}),label:"Selecionar todos"})]}),u.map((function(e){return(0,c.jsxs)(T.Z,{value:e,disabled:e===n.default_option,children:[(0,c.jsx)(Oe.Z,{checked:i.includes(e)}),(0,c.jsx)(Ke.Z,{primary:e})]},e)}))]})),t.error&&(0,c.jsx)(Te.Z,{children:t.error.message})]})}},r);case P.Radio:return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:"",render:function(e){var n=e.field,r=e.fieldState;return(0,c.jsxs)(D.Z,{fullWidth:!0,error:!!r.error,children:[(0,c.jsx)(R.Z,(0,a.Z)((0,o.Z)({},n),{onBlur:function(){n.onBlur(),null===p||void 0===p||p()},displayEmpty:!0,renderValue:function(e){return e||(0,c.jsx)(Z.Z,{component:"span",color:"rgba(0, 0, 0, 0.42)",children:"Selecione aqui"})},disabled:s,size:"small",sx:{height:"32px"},children:null===y||void 0===y?void 0:y.map((function(e,n){return(0,c.jsx)(T.Z,{value:e,children:e},n)}))})),r.error&&(0,c.jsx)(Te.Z,{children:r.error.message})]})}},r);case P.Checkbox:return(0,c.jsx)(Fe.Qr,{name:r,control:t,defaultValue:[],render:function(e){var r=e.field,t=e.fieldState;return(0,c.jsxs)(D.Z,{fullWidth:!0,error:!!t.error,children:[(0,c.jsx)(Ue.Z,{style:{display:"flex",flexDirection:"row",gap:"8px",flexWrap:"wrap"},children:null===y||void 0===y?void 0:y.map((function(e,t){return(0,c.jsx)(He.Z,{value:e,control:(0,c.jsx)(Oe.Z,(0,a.Z)((0,o.Z)({},r),{checked:r.value.includes(e),onChange:function(n){var t=(0,l.Z)(r.value);if(n.target.checked)t.push(e);else{var i=t.indexOf(e);-1!==i&&t.splice(i,1)}r.onChange(t)},onBlur:function(){r.onBlur(),null===p||void 0===p||p()},disabled:s||e===n.default_option,size:"small"})),label:e},t)}))}),t.error&&(0,c.jsx)(Te.Z,{children:t.error.message})]})}},r);default:return null}},$e=r(78298),Xe=r(13379),en=r(23508),nn=r(2548),rn="#F4F7FD",tn=function(e){var n=e.title,r=e.expanded,t=e.onToggle,i=e.children;return(0,c.jsxs)(ze.Z,{disableGutters:!0,elevation:0,expanded:r,onChange:function(e,n){return t(n)},sx:{backgroundColor:rn,border:"1px solid #EBEBEB",borderRadius:"4px",overflow:"hidden","&:before":{display:"none"}},children:[(0,c.jsx)(Ne.Z,{expandIcon:(0,c.jsx)(en.Z,{color:"primary"}),sx:{backgroundColor:rn,minHeight:"48px",px:3,"& .MuiAccordionSummary-content":{my:1}},children:(0,c.jsx)(M.Z,{variant:"body1",color:"primary",fontWeight:700,children:n})}),(0,c.jsx)(Ve.Z,{sx:{p:0,backgroundColor:rn},children:i})]})},on={flex:"1 1 66%",minWidth:0},an={flex:"1 1 34%",minWidth:0},un=function(e){var n=e.tooltip;return n?(0,c.jsx)(Pe.Z,{title:n,arrow:!0,placement:"top",children:(0,c.jsx)(nn.Z,{color:"primary",sx:{fontSize:16,ml:.5,verticalAlign:"middle",cursor:"help"}})}):null},sn=function(e){var n=e.explanation,r=e.sx;return n?(0,c.jsx)(M.Z,{sx:(0,o.Z)({fontFamily:"Poppins",fontSize:"14px",fontWeight:300,color:"#707070",mt:.5},r),children:n}):null},ln=function(e){var n=e.children,r=e.hideBottomBorder;return(0,c.jsx)(W.Z,{elevation:0,square:!0,sx:{px:3,borderRadius:0,borderBottom:r?"none":"1px solid",borderColor:"divider",backgroundColor:"transparent"},children:(0,c.jsx)(Z.Z,{py:3,children:n})})},dn=function(e){var n=e.question,r=e.answers,s=e.getQuestion,l=e.parentKey,f=void 0===l?"":l,p=e.parentLabel,v=e.getAnswer,_=e.surveyAlreadySubmitted,h=e.step,x=e.upsertQuestions,m=e.nextQuestionLoading,g=e.handlePreviousQuestion,y=e.handleNextQuestion,w=e.isQuestionMain,q=e.handleValidateQuestion,S=e.flatQuestions,A=e.disabledButtonNextQuestion,k=e.hideNavigationButtons,Q=e.layout,E=void 0===Q?"default":Q,B=e.dependentRepeatQuestions,z=e.forcedRepeatItem,N=e.renderAsSubquestion,V=e.hideBottomBorder,I=e.inlineDependentQuestions,L=e.renderAsInlineGroupItem,F=(0,Fe.Gc)(),D=F.control,R=F.watch,T=F.setError,H=F.clearErrors,O=F.setValue,K=(0,u.Z)(C.useState(null!==h&&void 0!==h?h:0),2),U=K[0],G=K[1],J=(0,u.Z)(C.useState(!1),2),Y=J[0],$=J[1],X=(0,u.Z)(C.useState({}),2),ee=X[0],ie=X[1],oe=(0,u.Z)(C.useState({}),2),ae=oe[0],ue=oe[1],le=(0,u.Z)(C.useState({}),2),de=le[0],ce=le[1];C.useEffect((function(){if(n.repeat_for_each_value&&n.question_reverse_lookup_id){var e=re(n.question_reverse_lookup_id,null!==p&&void 0!==p?p:"",R,s);if(1===e.length){var r=f?"".concat(f,"_q_").concat(n.id):"answer_q_".concat(n.id),t="".concat(r,"_r_").concat(e[0].index);100!==Number(R(t))&&O(t,100,{shouldDirty:!0,shouldValidate:!0})}}}));var fe=function(){var e=(0,t.Z)((function(e){return(0,d.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,6,7]),$(!0),[4,se({clearErrors:H,setError:T,selectedQuestion:n,watchedAnswers:r,questions:S,getAnswer:v,validateRepeatIndex:U})];case 1:return t.sent().isValid?x?[4,x(!1)]:[3,3]:[3,4];case 2:t.sent(),t.label=3;case 3:e||G((function(e){return e+1})),t.label=4;case 4:return[3,7];case 5:throw t.sent();case 6:return $(!1),[7];case 7:return[2]}}
1))}));return function(n){return e.apply(this,arguments)}}(),pe=n.id,ve=n.question_dependency_id,_e=n.question_reverse_lookup_id,he=n.question_parent_id,xe=n.question_show_case_parent_id,me=n.show_case_answer_parent,ge=n.group_questions_when_parent,ye=n.repeat_for_each_value,we=n.hierarchy_default,be=n.question,Ze=n.question_explanation,je=n.question_tooltip,qe=n.question_type_answer,Se=n.children,Ae=!!qe&&qe!==P.Unknown,ke=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,t=n?"".concat(n,"_q_").concat(e):"answer_q_".concat(e);return r&&(t+="_r_".concat(r)),t},Ce=function(e,n){return Array.isArray(e)?e.includes(n):void 0!==e&&null!==e&&"".concat(e)===n},Qe=function(e){return!!e.show_case_answer_parent&&(!e.question_show_case_parent_id||e.question_show_case_parent_id===e.question_parent_id)};if(!function(){if(xe&&me){var e=R("answer_q_".concat(xe));if(Ce(e,me))return!0;var n,r,t=v(xe,""),i=null!==(r=null!==(n=null===t||void 0===t?void 0:t.answer_arraystring)&&void 0!==n?n:null===t||void 0===t?void 0:t.answer_string)&&void 0!==r?r:null===t||void 0===t?void 0:t.answer_number;return Ce(i,me)}if(he&&me){var o=R(f);return Array.isArray(o)?o.includes(me):o===me}return!0}())return null;if(!ye&&qe===P.Unknown&&ve&&(null===Se||void 0===Se?void 0:Se.length)){var Ee=s(ve);if((null===Ee||void 0===Ee?void 0:Ee.question_type_answer)===P.Number){var Be=R(ke(ve,""));if(!(Number(Be)>0))return null}}var Me=z?[z]:function(){if(ye&&ve){var e=ke(ve,""),n=R(e),r=s(ve).question_type_answer;if(r===P.Multiselect&&Array.isArray(n))return te(ve,n,S,R).map((function(e,n){return{label:e,index:n}}));if(r===P.Number){var t=Number(n);return Array.from({length:t}).map((function(e,n){return{label:(n+1).toString(),index:n}}))}}return ye&&_e?re(_e,null!==p&&void 0!==p?p:"",R,s):[]}(),ze=!z&&ye&&ve?s(ve):void 0,Ne=(null===ze||void 0===ze?void 0:ze.question_type_answer)===P.Number,Ve=!z&&ye&&!!_e,Pe=!!he&&!!f&&(null===ze||void 0===ze?void 0:ze.question_type_answer)===P.Unknown;if(!z&&ye&&0===Me.length&&!Pe)return null;if(Me.length>0){if(Ve)return 1===Me.length?(0,c.jsx)(Z.Z,{sx:{borderBottom:"1px solid",borderColor:"divider"}}):(0,c.jsx)(Z.Z,{sx:{display:"flex",flexDirection:"column",gap:"4px",pt:2,pb:3,borderBottom:"1px solid",borderColor:"divider"},children:Me.map((function(e){var r=e.label,t=e.index,i="".concat(ke(pe,f,t.toString()));return(0,c.jsx)(Z.Z,{sx:{borderLeft:"3px solid",borderColor:"primary.main",ml:3,pl:2,pr:3,py:1.5},children:(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"center",sx:{gap:"1rem"},children:[(0,c.jsxs)(Z.Z,{sx:on,children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[be," ",(0,c.jsx)(M.Z,{component:"span",fontWeight:700,fontSize:"16px",children:"".concat(r,":")}),(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze})]}),(0,c.jsx)(Z.Z,{sx:an,children:(0,c.jsx)(Ye,{question:n,control:D,watch:R,name:i,getAnswer:v,disabled:_||!!n.disabled,flatQuestions:S,onAnswerBlur:function(){var e;return null===x||void 0===x||null===(e=x(!1))||void 0===e?void 0:e.catch((function(e){return console.error("Falha ao salvar automaticamente:",e)}))}})})]})},"".concat(pe,"-").concat(r,"-").concat(t,"-").concat(i))}))});if(n.group_questions_when_repeat)return(0,c.jsx)(Z.Z,{sx:{display:"flex",flexDirection:"column",gap:"8px",mt:2,mb:2,pb:3,pl:6,pr:3,borderBottom:"1px solid",borderColor:"divider"},children:Me.map((function(e){var t=e.label,u=e.index,l="".concat(ke(pe,f,u.toString()));return(0,c.jsxs)(tn,{title:Ne||Ve?"Pasta: ".concat(t):"Detalhes de ".concat(t),expanded:!!ee[u],onToggle:function(e){return ie((function(n){return(0,a.Z)((0,o.Z)({},n),(0,i.Z)({},u,e))}))},children:[(0,c.jsx)(ln,{children:(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"center",sx:{gap:"1rem"},children:[(0,c.jsxs)(Z.Z,{sx:on,children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[Ae?"".concat(be," ").concat(t):be,(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze})]}),(0,c.jsx)(Z.Z,{sx:an,children:(0,c.jsx)(Ye,{question:n,control:D,watch:R,name:l,getAnswer:v,disabled:_||!!n.disabled,flatQuestions:S,onAnswerBlur:function(){var e;return null===x||void 0===x||null===(e=x(!1))||void 0===e?void 0:e.catch((function(e){return console.error("Falha ao salvar automaticamente:",e)}))}})})]})}),null===Se||void 0===Se?void 0:Se.map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:l,parentLabel:t,surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A},"".concat(e.id,"-").concat(t,"-").concat(u))}))]},"".concat(pe,"-").concat(t,"-").concat(u,"-").concat(l))}))});
1var De,Re,Te=Me[U].index,We="".concat(ke(pe,f,Te.toString())),He=Me[U].label,Oe=!!(null===Se||void 0===Se?void 0:Se.some((function(e){return!!e.question_reverse_lookup_id&&!!e.repeat_for_each_value}))),Ke=null!==(De=null===Se||void 0===Se?void 0:Se.filter((function(e){return!!e.question_show_case_parent_id&&e.question_show_case_parent_id!==pe&&!!e.show_case_answer_parent})))&&void 0!==De?De:[],Ue=null!==(Re=null===Se||void 0===Se?void 0:Se.filter((function(e){return!Ke.includes(e)})))&&void 0!==Re?Re:[],Ge=[];if(Ke.length){var Je,en,nn=Ke[0].question_show_case_parent_id,rn=R("answer_q_".concat(nn));(Array.isArray(rn)?rn:null!==(en=null===(Je=v(nn,""))||void 0===Je?void 0:Je.answer_arraystring)&&void 0!==en?en:[]).forEach((function(e){var n=Ke.filter((function(n){return n.show_case_answer_parent===e}));n.length&&Ge.push({label:e,childQuestions:n})}))}var cn=Ue.some((function(e){return Qe(e)&&Ce(R(We),e.show_case_answer_parent)}));return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(ln,{hideBottomBorder:Oe||Ge.length>0||cn,children:(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"center",sx:{gap:"1rem"},children:[(0,c.jsxs)(Z.Z,{sx:on,children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[Ae?"".concat(be," ").concat(He):be,(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze})]}),(0,c.jsx)(Z.Z,{sx:an,children:(0,c.jsx)(Ye,{question:n,control:D,watch:R,name:We,getAnswer:v,disabled:_||!!n.disabled,flatQuestions:S,onAnswerBlur:function(){var e;return null===x||void 0===x||null===(e=x(!1))||void 0===e?void 0:e.catch((function(e){return console.error("Falha ao salvar automaticamente:",e)}))}})})]})}),Ue.map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:We,parentLabel:He,surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A,renderAsSubquestion:Qe(e)},"".concat(e.id,"-").concat(He,"-").concat(Te))})),Ge.length>0&&(0,c.jsx)(Z.Z,{sx:{display:"flex",flexDirection:"column",gap:"8px",mt:2,mb:2,pb:3,pl:6,pr:3,borderBottom:"1px solid",borderColor:"divider"},children:Ge.map((function(e){var n=e.label,t=e.childQuestions;return(0,c.jsx)(tn,{title:"Perguntas referente a: ".concat(n),expanded:!!de[n],onToggle:function(e){return ce((function(r){return(0,a.Z)((0,o.Z)({},r),(0,i.Z)({},n,e))}))},children:t.map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:We,parentLabel:He,surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A},"".concat(e.id,"-").concat(n,"-").concat(He,"-").concat(Te))}))},"".concat(pe,"-ext-").concat(n,"-").concat(Te))}))}),w&&!k?(0,c.jsx)(Le.Z,{variant:"text",steps:Me.length,position:"static",sx:{marginTop:3,px:0,backgroundColor:"transparent"},activeStep:U,backButton:(0,c.jsx)(b.Z,{variant:"contained",size:"small",sx:{textTransform:"none",borderRadius:1.5},startIcon:(0,c.jsx)($e.Z,{}),onClick:function(){0===U?g():G((function(e){return e-1}))},disabled:m||Y,children:"Anterior"}),nextButton:(0,c.jsxs)(b.Z,{variant:"contained",size:"small",sx:{textTransform:"none",borderRadius:1.5},endIcon:m||Y?null:(0,c.jsx)(Xe.Z,{}),onClick:function(){var e=U===Me.length-1;e?y():fe(e)},disabled:m||Y,children:[m||Y?(0,c.jsx)(Z.Z,{mr:1,lineHeight:1,children:(0,c.jsx)(j.Z,{color:"inherit",size:"1.25rem"})}):null,"Pr\xf3xima"]})}):null]})}var fn,pn,vn=ke(pe,f),_n=R(vn),hn=Array.isArray(_n)?_n:[],xn=te(pe,hn,S,R),mn=(null===B||void 0===B?void 0:B.length)&&xn.length?xn.map((function(e,n){return{label:e,index:n}})):[],gn=null!==(fn=null===B||void 0===B?void 0:B.filter((function(e){var n;return e.question_type_answer===P.Unknown&&!(null===(n=e.children)||void 0===n?void 0:n.length)})))&&void 0!==fn?fn:[],yn=null!==(pn=null===B||void 0===B?void 0:B.filter((function(e){return!gn.includes(e)})))&&void 0!==pn?pn:[],wn=function(e){var n=!0,r=!1,t=void 0;try{for(var i,o=(null!==e&&void 0!==e?e:[])[Symbol.iterator]();!(n=(i=o.next()).done);
1n=!0){var a=i.value;if(a.question_reverse_lookup_id)return a.question_reverse_lookup_id;var u=wn(a.children);if(u)return u}}catch(s){r=!0,t=s}finally{try{n||null==o.return||o.return()}finally{if(r)throw t}}return null},bn=[];if(mn.length>0){var Zn=wn(B);if(Zn){var jn=S.find((function(e){return e.id===Zn})),qn=ne(Zn,(function(e){return S.find((function(n){return n.id===e}))})),Sn=(null===jn||void 0===jn?void 0:jn.question_dependency_id)&&Number(R("answer_q_".concat(jn.question_dependency_id)))||0,An=new Set;if(qn)for(var kn=0;kn<Sn;kn++){var Cn=R("".concat(qn,"_r_").concat(kn));Array.isArray(Cn)&&Cn.forEach((function(e){return An.add(e)}))}bn=mn.map((function(e){return e.label})).filter((function(e){return!An.has(e)}))}}var Qn=bn.length>0,En=[];qe===P.Multiselect&&ge&&(null===Se||void 0===Se?void 0:Se.length)&&Array.isArray(_n)&&_n.forEach((function(e){var n=Se.filter((function(n){return n.show_case_answer_parent===e&&!n.question_show_case_parent_id}));n.length&&En.push({label:e,childQuestions:n})}));var Bn=new Set(En.flatMap((function(e){return e.childQuestions.map((function(e){return e.id}))}))),Mn=null===Se||void 0===Se?void 0:Se.filter((function(e){return!Bn.has(e.id)})),zn=!!(null===Mn||void 0===Mn?void 0:Mn.some((function(e){return Qe(e)&&Ce(R(vn),e.show_case_answer_parent)})));if("grid"===E)return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(W.Z,{elevation:0,sx:{p:2,height:"100%",display:"flex",flexDirection:"column",gap:1},children:[(0,c.jsxs)(Z.Z,{children:[(0,c.jsxs)(M.Z,{variant:"body2",fontSize:"16px",children:[be,(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze,sx:{fontSize:"12px"}})]}),(0,c.jsx)(Ye,{question:n,control:D,watch:R,name:vn,getAnswer:v,disabled:_||!!n.disabled,flatQuestions:S,onAnswerBlur:function(){var e;return null===x||void 0===x||null===(e=x(!1))||void 0===e?void 0:e.catch((function(e){return console.error("Falha ao salvar automaticamente:",e)}))}})]}),ge&&(null===Se||void 0===Se?void 0:Se.map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:vn,parentLabel:p,surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A},e.id)})))]});var Nn=qe===P.Unknown&&!!(null===Se||void 0===Se?void 0:Se.length),Vn=S.some((function(e){return e.question_dependency_id===pe&&!e.question_parent_id&&(!e.repeat_for_each_value&&e.question_type_answer===P.Unknown&&(!!e.group_questions_when_parent&&S.some((function(n){return n.question_parent_id===e.id}))))})),Pn=mn.length>0&&!Qn,In=!!(null===I||void 0===I?void 0:I.length),Ln=!!we&&S.some((function(e){return!!e.question_reverse_lookup_id&&!!e.hierarchy_default&&e.hierarchy_default!==we&&e.hierarchy_default.startsWith("".concat(we,"."))}));return(0,c.jsxs)(c.Fragment,{children:[Nn?(0,c.jsxs)(Z.Z,{sx:{pl:6,pr:3,pt:3,pb:2},children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[be,(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze})]}):N?(0,c.jsx)(Z.Z,{sx:{pt:1.5,pb:3,borderBottom:V?"none":"1px solid",borderColor:"divider"},children:(0,c.jsx)(Z.Z,{sx:{borderLeft:"3px solid",borderColor:"primary.main",ml:6,pl:2,pr:3,py:1.5},children:(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"center",sx:{gap:"1rem"},children:[(0,c.jsxs)(Z.Z,{sx:on,children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[be,(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze})]}),(0,c.jsx)(Z.Z,{sx:an,children:(0,c.jsx)(Ye,{question:n,control:D,watch:R,name:vn,getAnswer:v,disabled:_||!!n.disabled,flatQuestions:S,onAnswerBlur:function(){var e;return null===x||void 0===x||null===(e=x(!1))||void 0===e?void 0:e.catch((function(e){return console.error("Falha ao salvar automaticamente:",e)}))}})})]})})}):L?(0,c.jsx)(Z.Z,{sx:{py:1.5},children:(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"center",sx:{gap:"1rem"},children:[(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"flex-start",spacing:2.5,sx:on,children:[Ae&&(0,c.jsx)(Z.Z,{sx:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"primary.main",flexShrink:0,mt:"8px"}}),(0,c.jsxs)(Z.Z,{children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[be,(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze})]})]}),(0,c.jsx)(Z.Z,{sx:an,children:(0,c.jsx)(Ye,{question:n,control:D,watch:R,name:vn,getAnswer:v,disabled:_||!!n.disabled,flatQuestions:S,onAnswerBlur:function(){var e;return null===x||void 0===x||null===(e=x(!1))||void 0===e?void 0:e.catch((function(e){return console.error("Falha ao salvar automaticamente:",e)}))}})})]})}):(0,c.jsx)(ln,{hideBottomBorder:Vn||Pn||Ln||En.length>0||zn||In,children:(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"center",sx:{gap:"1rem"},children:[(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"flex-start",spacing:2.5,sx:on,children:[Ae&&(0,c.jsx)(Z.Z,{sx:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"primary.main",flexShrink:0,mt:"8px"}}),(0,c.jsxs)(Z.Z,{children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[be,(0,c.jsx)(un,{tooltip:je})]}),(0,c.jsx)(sn,{explanation:Ze})]})]}),(0,c.jsx)(Z.Z,{sx:an,children:(0,c.jsx)(Ye,{question:n,control:D,watch:R,name:vn,getAnswer:v,disabled:_||!!n.disabled,flatQuestions:S,onAnswerBlur:function(){var e;return null===x||void 0===x||null===(e=x(!1))||void 0===e?void 0:e.catch((function(e){return console.error("Falha ao salvar automaticamente:",e)}))}})})]})}),null===Mn||void 0===Mn?void 0:Mn.filter((function(e){return ge||!!e.show_case_answer_parent&&!e.question_show_case_parent_id})).map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:vn,parentLabel:p,renderAsSubquestion:Qe(e),hideBottomBorder:Qe(e)&&(Pn||In),surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A},e.id)})),In&&(0,c.jsx)(Z.Z,{sx:{pl:6,pr:3,pb:3,borderBottom:Pn?"none":"1px solid",borderColor:"divider"},children:I.map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:"",parentLabel:p,renderAsInlineGroupItem:!0,surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A},e.id)}))}),En.length>0&&(0,c.jsx)(Z.Z,{sx:{display:"flex",flexDirection:"column",gap:"8px",mt:2,mb:2,pb:3,borderBottom:"1px solid",borderColor:"divider"},children:En.map((function(e){var n=e.label,t=e.childQuestions;return(0,c.jsx)(tn,{title:"Perguntas referente a: ".concat(n),expanded:!!de[n],onToggle:function(e){return ce((function(r){return(0,a.Z)((0,o.Z)({},r),(0,i.Z)({},n,e))}))},children:t.map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:vn,parentLabel:n,surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A},"".concat(e.id,"-").concat(n))}))},"".concat(pe,"-sc-").concat(n))}))}),Pn&&(0,c.jsxs)(c.Fragment,{children:[gn.map((function(e){return(0,c.jsxs)(Z.Z,{sx:{pl:6,pr:3,pt:3},children:[(0,c.jsxs)(M.Z,{variant:"body1",fontSize:"16px",children:[e.question,(0,c.jsx)(un,{tooltip:e.question_tooltip})]}),(0,c.jsx)(sn,{explanation:e.question_explanation})]},e.id)})),(0,c.jsx)(Z.Z,{sx:{display:"flex",flexDirection:"column",gap:"8px",mt:2,mb:2,pb:3,pl:6,pr:3,borderBottom:"1px solid",borderColor:"divider"},children:mn.map((function(e){var n=e.label,t=e.index;return(0,c.jsx)(tn,{title:"Perguntas referente a: ".concat(n),expanded:!!ae[t],onToggle:function(e){return ue((function(n){return(0,a.Z)((0,o.Z)({},n),(0,i.Z)({},t,e))}))},children:yn.map((function(e){return(0,c.jsx)(dn,{question:e,answers:r,getQuestion:s,getAnswer:v,parentKey:"",parentLabel:n,forcedRepeatItem:{label:n,index:t},surveyAlreadySubmitted:_,upsertQuestions:x,nextQuestionLoading:m,handlePreviousQuestion:g,handleNextQuestion:y,handleValidateQuestion:q,flatQuestions:S,disabledButtonNextQuestion:A},"".concat(e.id,"-").concat(n,"-").concat(t))}))},"".concat(pe,"-dep-").concat(n,"-").concat(t))}))})]}),w&&!k?(0,c.jsxs)(Z.Z,{display:"flex",alignItems:"center",justifyContent:"space-between",mt:3,children:[(0,c.jsx)(b.Z,{variant:"contained",size:"small",sx:{textTransform:"none",borderRadius:1.5},startIcon:(0,c.jsx)($e.Z,{}),onClick:g,disabled:m||Y,children:"Anterior"}),(0,c.jsxs)(b.Z,{variant:"contained",size:"small",sx:{textTransform:"none",borderRadius:1.5},endIcon:m||Y?null:(0,c.jsx)(Xe.Z,{}),onClick:y,disabled:m||Y||A,children:[m||Y?(0,c.jsx)(Z.Z,{mr:1,lineHeight:1,children:(0,c.jsx)(j.Z,{color:"inherit",size:"1.25rem"})}):null,"Pr\xf3xima"]})]}):null]})},cn=r(5623),fn=r(81347),pn=r(80612),vn=r(26215),_n=r(85938),hn=r(27948),xn=r(11703),mn=r(40044),gn=r(87918),yn=r(57922),wn=r(62714),bn=[{industry_id:10,questions
1Hiearchy:["1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8"]}];var Zn=!0,jn=function(e){e=null!==e?e:(0,s.Z)(new TypeError("Cannot destructure undefined"));var n,r=(0,L.aC)(),f=r.industryPath,_=r.signOut,m=(0,wn.$G)("survey").t,q=(0,C.useState)(!1),S=q[0],A=q[1],k=(0,C.useState)([]),B=k[0],z=k[1];(0,C.useEffect)((function(){y().then((function(e){var n=e.mustAcceptRegulations,r=e.pendingRegulations;n&&r.length>0&&(z(r),A(!0))})).catch((function(e){return console.error("Erro ao buscar regulamento:",e)}))}),[]);var N,P=(0,C.useState)([]),I=P[0],F=P[1],D=(0,C.useState)([]),R=D[0],T=D[1],W=(0,C.useState)(),H=W[0],G=W[1],J=(0,C.useState)(),Y=J[0],$=J[1],re=(0,C.useState)([]),te=re[0],ie=re[1],oe=(0,C.useState)(!1),ae=oe[0],ue=oe[1],le=(0,C.useState)(null),de=le[0],ce=le[1],fe=(0,C.useState)(null),pe=fe[0],ve=fe[1],_e=(0,Fe.cI)({mode:"all"}),he=_e.handleSubmit,xe=_e.watch,ge=_e.reset,ye=_e.setValue,we=_e.setError,be=_e.clearErrors,Se=_e.getFieldState,Ae=(0,C.useRef)({}),ze=(0,C.useRef)(null),Ne=xe(),Ve=null!==(N=null===(n=R.find((function(e){return 210===e.id})))||void 0===n?void 0:n.question_options)&&void 0!==N?N:[],Pe=Array.isArray(Ne.answer_q_210)?Ne.answer_q_210:[],Le=("string"===typeof Ne.answer_q_211?Ne.answer_q_211:"").split(",").map((function(e){return e.trim()})).filter(Boolean);(0,C.useEffect)((function(){var e=(0,l.Z)(Pe.map((function(e){return{index:Ve.indexOf(e),value:e}}))).concat((0,l.Z)(Le.map((function(e){return{index:null,value:e}}))));console.log("Ind\xfastrias combinadas (210 + 211):",e)}),[JSON.stringify(Pe),JSON.stringify(Le),JSON.stringify(Ve)]);var De=(0,Q.VY)().setAlert,Re=(0,C.useState)(!1),Te=Re[0],We=Re[1],He=(0,C.useState)(!1),Oe=He[0],Ke=He[1],Ue=(0,C.useState)(null),Ge=Ue[0],Je=Ue[1],Ye=(0,C.useState)(null),nn=Ye[0],rn=Ye[1];(0,C.useEffect)((function(){var e=K({answer_q_210:Ne.answer_q_210,answer_q_211:Ne.answer_q_211,answer_q_214:Ne.answer_q_214},R,null!==Ge&&void 0!==Ge?Ge:0);console.log("Payload que seria salvo (210, 211, 214):",e)}),[JSON.stringify(Ne.answer_q_210),JSON.stringify(Ne.answer_q_211),JSON.stringify(Ne.answer_q_214),R.length,Ge]);var tn={Institucional:ke,"Opera\xe7\xf5es Comerciais":Qe,Comercial:Ee,"Execu\xe7\xe3o":Be,Estrutura:Me};(0,C.useEffect)((function(){pe&&de&&Ge&&An()}),[pe,Ge,de]),(0,C.useEffect)((function(){de&&Sn()}),[de]);var on=(0,C.useMemo)((function(){return te.find((function(e){return e.id===Ge}))}),[Ge,te]),an=(0,C.useMemo)((function(){return"submitted"===(null===on||void 0===on?void 0:on.status)}),[on]),un=(0,C.useMemo)((function(){var e;return me(I,R,null!==(e=null===on||void 0===on?void 0:on.answers)&&void 0!==e?e:[],Ne)}),[I,R,on,Ne]),sn=(0,C.useMemo)((function(){return X(R)}),[R]),ln=(0,C.useMemo)((function(){var e=new Map;return sn.forEach((function(n){if(n.repeat_for_each_value&&n.question_dependency_id&&!n.question_parent_id){var r,t=null!==(r=e.get(n.question_dependency_id))&&void 0!==r?r:[];t.push(n),e.set(n.question_dependency_id,t)}})),e}),[sn]),Zn=(0,C.useMemo)((function(){var e=new Set;return ln.forEach((function(n){return n.forEach((function(n){return e.add(n.id)}))})),e}),[ln]),jn=(0,C.useMemo)((function(){var e=new Map;sn.forEach((function(n){return e.set(n.id,n)}));var n=new Map;return sn.forEach((function(r){var t=ee(r,(function(n){return e.get(n)}));if(null!==t){var i,o=null!==(i=n.get(t))&&void 0!==i?i:[];o.push(r),n.set(t,o)}})),n}),[sn]),qn=(0,C.useMemo)((function(){var e=new Set;return jn.forEach((function(n){return n.forEach((function(n){return e.add(n.id)}))})),e}),[jn]),Sn=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){switch(n.label){case 0:return de?[4,h({industry_customer_id:de})]:[2];case 1:return e=n.sent(),ie(e),ue(!0),[2]}}))}));return function(){return e.apply(this,arguments)}}(),An=function(){var e=(0,t.Z)((function(){var e,n,r,t,i,s,l,c,f,_,h,x,m,g,y,w;return(0,d.__generator)(this,(function(d){switch(d.label){case 0:We(!0),d.label=1;case 1:return d.trys.push([1,3,4,5]),[4,Promise.all([p(),v({version_id:null!==pe&&void 0!==pe?pe:void 0})])];case 2:if(e=u.Z.apply(void 0,[d.sent(),2]),n=e[0],r=e[1],!(null===n||void 0===n?void 0:n.length)||!(null===r||void 0===r?void 0:r.length))return[2];t=function(e){var n=new Map;e.forEach((function(e){return n.set(e.id,e)}));var r=function(e){return!e.question_parent_id&&!!e.repeat_for_each_value&&!!e.question_dependency_id},t=new Map,i=function(e,o){if(t.has(e.id))return t.get(e.id);if(o.has(e.id))return!1;if(e.group_questions_when_parent)return t.set(e.id,!0),!0;if(!r(e))return t.set(e.id,!1),!1;var a=n.get(e.question_dependency_id);if(!a||!a.repeat_for_each_value)return t.set(e.id,!1),!1;var u=i(a,new Set(o).add(e.id));return t.set(e.id,u),u},o=function(e){for(var r,t=e,i=new Set;t.repeat_for_each_value&&t.question_dependency_id;){if(i.has(t.id))return null;i.add(t.id);var o=n.get(t.question_dependency_id);if(!o)return t.question_dependency_id;if(!o.repeat_for_each_value)return o.id;t=o}return null!==(r=t.question_dependency_id)&&void 0!==r?r:null},a=new Map;return e.forEach((function(e){if(r(e)){var n=i(e,new Set);a.set(e.id,{repeats:n,rootId:n?o(e):null})}})),a}(r),i=r.map((function(e){var n,r,i,u,s=t.get(e.id);return(0,a.Z)((0,o.Z)({},e),{question_type_answer:Ze(e.question_type_answer),hierarchy_position:null!==(u=null===(n=e.hierarchy_default)||void 0===n?void 0:n.split(".").map(Number))&&void 0!==u?u:[],question_options_dependency_id:je(e.question_options_dependency_id),question_dependency_id:(null===s||void 0===s?void 0:s.repeats)?s.rootId:e.question_dependency_id,repeat_for_each_value:s&&!s.repeats?null:e.repeat_for_each_value,disabled:null===(r=null===bn||void 0===bn?void 0:bn.find((function(e){return e.industry_id===(null===on||void 0===on?void 0:on.industry_id)}
1)))||void 0===r||null===(i=r.questionsHiearchy)||void 0===i?void 0:i.includes(e.hierarchy_default),children:[]})})).sort((function(e,n){for(var r=e.hierarchy_position,t=n.hierarchy_position,i=0;i<Math.max(r.length,t.length);i++){var o=r[i]||0,a=t[i]||0;if(o!==a)return o-a}return 0})),s=n.map((function(e){var n=i.filter((function(n){return"".concat(n.pillar_id,".").concat(n.level_2_id,".").concat(n.level_3_id,".").concat(n.level_4_id)==="".concat(e.pillar_id,".").concat(e.level_2_id,".").concat(e.level_3_id,".").concat(e.level_4_id)})).length;return(0,a.Z)((0,o.Z)({},e),{question_count:n,levels:[],questions:[]})})).sort((function(e,n){for(var r=[e.pillar_id,e.level_2_id,e.level_3_id,e.level_4_id],t=[n.pillar_id,n.level_2_id,n.level_3_id,n.level_4_id],i=0;i<Math.max(r.length,t.length);i++){var o=r[i]||0,a=t[i]||0;if(o!==a)return o-a}return 0})),l=s[0],on&&10===on.industry_id&&(c={"1.1.1":on.industry_customer.name,"1.1.2":on.industry_customer.company_legal_name,"1.1.3":on.industry_customer.vat_code,"1.1.4":on.industry_customer.address_postal_code,"1.1.5":on.industry_customer.operational_area,"1.1.6":on.industry_customer.address_street,"1.1.7":on.industry_customer.address_neighborhood,"1.1.8":on.industry_customer.city},Object.entries(c).forEach((function(e){var n=(0,u.Z)(e,2),r=n[0],t=n[1],o=i.find((function(e){return e.hierarchy_default===r}));if(o){var a=ne(o.id,(function(e){return i.find((function(n){return n.id===e}))}));a&&ye(a,null!==t&&void 0!==t?t:"",{shouldDirty:!0})}}))),G(l),F(s),T(i),f=X(i),$(null===f||void 0===f?void 0:f[0]),_=!0,h=!1,x=void 0;try{for(m=X(i)[Symbol.iterator]();!(_=(g=m.next()).done);_=!0)y=g.value,qe({question:y,answers:null!==(w=null===on||void 0===on?void 0:on.answers)&&void 0!==w?w:[],getQuestion:function(e){return i.find((function(n){return n.id===e}))},getAnswer:Dn,parentKey:"",surveyAlreadySubmitted:an,control:_e.control,watch:_e.watch,setValue:ye,allQuestions:i})}catch(b){h=!0,x=b}finally{try{_||null==m.return||m.return()}finally{if(h)throw x}}return[3,5];case 3:return d.sent(),[3,5];case 4:return We(!1),[7];case 5:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}(),kn=(0,C.useMemo)((function(){return un.reduce((function(e,n){return e+n.question_count}),0)}),[un,on]),Cn=(0,C.useMemo)((function(){return un.reduce((function(e,n){return e+n.question_count_answered}),0)}),[un,on]),Qn=(0,C.useMemo)((function(){return un.filter((function(e){return e.question_count>0&&e.question_count_answered===e.question_count})).length}),[un]),En=(0,C.useMemo)((function(){return 0===kn?0:Cn===kn?100:Math.min(99,Math.round(Cn/kn*100))}),[kn,Cn]),Bn=function(e,n,r,t){var i=I.find((function(i){return i.pillar_id===e&&i.level_2_id===n&&i.level_3_id===r&&i.level_4_id===t}));i&&G(i)},Mn=(0,C.useMemo)((function(){var e,n=un.find((function(e){return e.pillar_id===(null===H||void 0===H?void 0:H.pillar_id)}));return null!==(e=null===n||void 0===n?void 0:n.levels)&&void 0!==e?e:[]}),[un,H]),zn=(0,C.useRef)(null);(0,C.useEffect)((function(){var e=null===H||void 0===H?void 0:H.pillar_id;if(null!=e&&zn.current!==e){var n=Mn.find((function(e){return sn.some((function(n){return n.pillar_id===e.pillar_id&&n.level_2_id===e.level_2_id}))}));n&&(zn.current=e,rn(n.level_2_id))}}),[null===H||void 0===H?void 0:H.pillar_id,Mn,sn]);var Nn=un.findIndex((function(e){return e.pillar_id===(null===H||void 0===H?void 0:H.pillar_id)})),Vn=-1!==Nn&&Nn===un.length-1,Pn=(0,C.useMemo)((function(){return sn.filter((function(e){return e.pillar_id===(null===H||void 0===H?void 0:H.pillar_id)}))}),[sn,H]),In=function(e){var n=un[e];if(n){G(n);var r=sn.find((function(e){return e.pillar_id===n.pillar_id}));r&&$(r)}},Ln=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){return Y?(e=function(e,n){var r=e.findIndex((function(e){return e.id===n.id}));return r>0?n=e[r-1]:null}(sn,Y),e?(Y.pillar_id===e.pillar_id&&Y.level_2_id===e.level_2_id&&Y.level_3_id===e.level_3_id&&Y.level_4_id===e.level_4_id||Bn(e.pillar_id,e.level_2_id,e.level_3_id,e.level_4_id),$(e)):De({message:"Voc\xea est\xe1 na primeira quest\xe3o.",alertType:"info",autoHideDuration:2e3}),[2]):[2]}))}));return function(){return e.apply(this,arguments)}}(),Fn=function(e){return R.find((function(n){return n.id===e}))},Dn=function(e,n){return null===on||void 0===on?void 0:on.answers.find((function(r){var t;return r.question_id===e&&(null!==(t=r.repeat_value)&&void 0!==t?t:"")===(null!==n&&void 0!==n?n:"")}))},Rn=function(){var e=(0,t.Z)((function(e,n,r){var t,u,s,c,f,p,v,_;return(0,d.__generator)(this,(function(d){switch(d.label){case 0:return t={},e.filter((function(e){var n,r,t,i=JSON.stringify(null!==(t=Ne[e.key])&&void 0!==t?t:null);if(Se(e.key).isDirty)return Ae.current[e.key]!==i;var o,a=U(e.key),u=a.question_id,s=a.repeat_value,l=Dn(u,s||"");if(!l)return!1;var d=(null!==(o=null===(n=l.answer_arraystring)||void 0===n?void 0:n.length)&&void 0!==o?o:0)>0||!!(null===(r=l.answer_string)||void 0===r?void 0:r.trim())||null!==l.answer_number,c=Ne[e.key],f=Array.isArray(c)?0===c.length:!c||""==="".concat(c).trim();return d&&f})).forEach((function(e){t=(0,a.Z)((0,o.Z)({},t),(0,i.Z)({},e.key,Ne[e.key]))})),u=un.find((function(e){return e.pillar_id===r})),s=u?{pillar_id:u.pillar_id,applicable_questions_count:u.question_count,answered_questions_count:u.question_count_answered}:void 0,c=K(t,R,Ge,s),f=c.map((function(e){return g(e)})),[4,Promise.all(f)];case 1:return p=d.sent(),_=null!==(v=null===on||void 0===on?void 0:on.answers)&&void 0!==v?v:[],p.forEach((function(e){var n,r,t=_.findIndex((function(t){return t.question_id===e.question_id&&(null!==(n=t.repeat_value)&&void 0!==n?n:"")===(null!==(r=e.repeat_value)&&void 0!==r?r:"")}));-1!==t?_[t]=e:_.push(e)})),ie((function(e){return(0,l.Z)(e.map((function(e){return e.id===Ge?(0,a.Z)((0,o.Z)({},e),{answers:_}):e})))})),Object.keys(t).forEach((function(e){var n;Ae.current[e]=JSON.stringify(null!==(n=t[e])&&void 0!==n?n:null)})),f.length&&De({message:n?"Formul\xe1rio salvo com sucesso":"Formul\xe1rio salvo de forma parcial",alertType:"success",autoHideDuration:6e3}),[2,!0]}}))}));return function(n,r,t){return e.apply(this,arguments)}}(),Tn=function(){var e=(0,t.Z)((function(e,n){var r,t,i,o;return(0,d.__generator)(this,(function(a){switch(a.label){case 0:return r=n.shoulCheckIsValid,[4,se({clearErrors:be,setError:we,selectedQuestion:e,watchedAnswers:Ne,questions:R,getAnswer:Dn})];case 1:return t=a.sent(),i=t.isValid,o=t.validations,!i&&r?[2,!1]:[2,Rn(o,i,e.pillar_id)]}}))}));return function(n,r){return e.apply(this,arguments)}}(),Wn=function(){var e=(0,t.Z)((function(e,n){var r,t,i,o,a,u,s,l,c,f,p,v;return(0,d.__generator)(this,(function(d){switch(d.label){case 0:r=n.shoulCheckIsValid,be(),i=!0,o=[],a=!0,u=!1,s=void 0,d.label=1;case 1:d.trys.push([1,6,7,8]),l=e[Symbol.iterator](),d.label=2;case 2:return(a=(c=l.next()).done)?[3,5]:(f=c.value,[4,se({clearErrors:function(){},setError:we,selectedQuestion:f,watchedAnswers:Ne,questions:R,getAnswer:Dn})]);case 3:(p=d.sent()).isValid||(i=!1),o=o.concat(p.validations),d.label=4;case 4:return a=!0,[3,2];case 5:return[3,8];case 6:return v=d.sent(),u=!0,s=v,[3,8];case 7:try{a||null==l.return||l.return()}finally{if(u)throw s}
1return[7];case 8:return!i&&r?[2,!1]:[2,Rn(o,i,null===(t=e[0])||void 0===t?void 0:t.pillar_id)]}}))}));return function(n,r){return e.apply(this,arguments)}}(),Hn=function(){var e=(0,t.Z)((function(){var e;return(0,d.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),Ke(!0),Y?an?[3,2]:[4,Tn(Y,{shoulCheckIsValid:!0})]:[2];case 1:if(!n.sent())return[2];n.label=2;case 2:return e=function(e,n){var r=e.findIndex((function(e){return e.id===n.id}));return r>=0&&r<e.length-1?n=e[r+1]:null}(sn,Y),e?(Y.pillar_id===e.pillar_id&&Y.level_2_id===e.level_2_id&&Y.level_3_id===e.level_3_id&&Y.level_4_id===e.level_4_id||Bn(e.pillar_id,e.level_2_id,e.level_3_id,e.level_4_id),$(e)):De({message:"Voc\xea est\xe1 na \xfaltima quest\xe3o. Por favor, envie a avalia\xe7\xe3o",alertType:"info",autoHideDuration:6e3}),[3,5];case 3:return n.sent(),De({message:"Falha ao salvar formul\xe1rio",alertType:"error",autoHideDuration:6e3}),[3,5];case 4:return Ke(!1),[7];case 5:return[2]}}))}));return function(){return e.apply(this,arguments)}}(),On=function(){var e=(0,t.Z)((function(){return(0,d.__generator)(this,(function(e){return an?[2,!0]:[2,Wn(Pn,{shoulCheckIsValid:!0})]}))}));return function(){return e.apply(this,arguments)}}();return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(pn.Z,{display:"block",children:(0,c.jsxs)(hn.Z,{sx:{flexGrow:1},children:[(0,c.jsx)(fn.Z,{title:m(["title.".concat(f.replaceAll("/","")),"title.default"]),icon:_n.Z}),(0,c.jsx)(M.Z,{color:"#707070",mt:3,mb:3,sx:{fontSize:"14px",fontFamily:"Poppins",fontStyle:"normal",fontWeight:400},children:"Reserve alguns minutos para responder aos question\xe1rios abaixo."}),(0,c.jsx)(Z.Z,{display:"flex",alignItems:"center",children:(0,c.jsx)(O,{progressValue:En,completedTabsCount:Qn,totalTabsCount:un.length,canAutoSelectYear:ae,surveyAlreadySubmitted:an,onSubmitForm:function(){var e;return null===(e=ze.current)||void 0===e?void 0:e.open()},onLevel2Change:function(e){F([]),T([]),G(null),$(null),Ke(!1),Je(null),ie([]),ue(!1),ce(null),ve(null),zn.current=null,ge({}),e&&ce(e)},onYearChange:function(){var e=(0,t.Z)((function(e,n){var r,t;return(0,d.__generator)(this,(function(i){switch(i.label){case 0:if(ve(e),r=te.find((function(e){return e.year===n})))return Je(r.id),[2];if(!de||!e)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,x({industry_customer_id:de,year:e})];case 2:return t=i.sent(),ie((function(e){return(0,l.Z)(e).concat([t])})),Je(t.id),[3,4];case 3:return i.sent(),De({message:"N\xe3o foi poss\xedvel iniciar o question\xe1rio para esse ano.",alertType:"error",autoHideDuration:6e3}),[3,4];case 4:return[2]}}
1))}));return function(n,r){return e.apply(this,arguments)}}()})}),Te?(0,c.jsx)(cn.Z,{}):(0,c.jsxs)(Z.Z,{display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",mt:4,children:[un.length?(0,c.jsx)(Z.Z,{width:"100%",children:(0,c.jsx)(xn.Z,{value:un.findIndex((function(e){return e.pillar_id===(null===H||void 0===H?void 0:H.pillar_id)})),onChange:function(e,n){return In(n)},sx:{width:"100%",height:"50px",fontSize:"13px","& .MuiTabs-flexContainer":{width:"100%",height:"50px"}},children:un.map((function(e){var n=tn[e.pillar_name],r=0===e.question_count?0:e.question_count_answered===e.question_count?100:Math.min(99,Math.round(e.question_count_answered/e.question_count*100));return(0,c.jsx)(mn.Z,{sx:{fontFamily:"'Poppins'",fontStyle:"normal",fontWeight:500,fontSize:"13px",lineHeight:"24px",color:"#707070",textTransform:"none",border:"1px solid #EBEBEB",flex:"1 0 auto",minWidth:"fit-content",height:"50px",minHeight:"50px",whiteSpace:"nowrap","&.Mui-selected":{backgroundColor:"#FFFFFF"}},label:(0,c.jsxs)(Ie.Z,{direction:"row",spacing:2,alignItems:"center",style:{paddingLeft:"16px",paddingRight:"16px"},children:[n&&(0,c.jsx)(n,{sx:{fontSize:18,flexShrink:0}}),(0,c.jsx)("span",{style:{fontFamily:"Poppins",fontStyle:"normal",fontWeight:"100",fontSize:"13px",lineHeight:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.pillar_name}),100===r?(0,c.jsx)(Ce,{sx:{fontSize:20,flexShrink:0}}):(0,c.jsx)(gn.Z,{label:"".concat(r,"%"),color:r>0?"primary":"default",size:"small"})]})},e.pillar_id)}))})}):null,(0,c.jsx)(Z.Z,{width:"100%",minWidth:300,sx:{padding:"1rem",background:"#FFFFFF",boxShadow:"1px 3px 4px rgba(0, 0, 0, 0.15)",borderRadius:"0px 0px 8px 8px"},children:(0,c.jsx)(Fe.RV,(0,a.Z)((0,o.Z)({},_e),{children:(0,c.jsx)("form",{onSubmit:he((function(e){ge(e.answers)})),style:{display:"flex",flexDirection:"column",gap:"18px"},children:H&&Mn.length>0&&(0,c.jsxs)(c.Fragment,{children:[Mn.map((function(e){var n=nn===e.level_2_id,r=sn.filter((function(n){return n.pillar_id===e.pillar_id&&n.level_2_id===e.level_2_id}));if(0===r.length)return null;var t=r.filter((function(e){return 1===e.grid_id})),i=r.filter((function(e){return 1!==e.grid_id&&!Zn.has(e.id)&&!qn.has(e.id)}));return(0,c.jsxs)(Z.Z,{width:"100%",style:{border:"1px solid #EBEBEB",borderRadius:"4px"},children:[(0,c.jsxs)(Ie.Z,{direction:"row",alignItems:"center",spacing:1,onClick:function(){return function(e){rn((function(n){return n===e.level_2_id?null:e.level_2_id}))}(e)},sx:{cursor:"pointer",userSelect:"none",borderBottom:"1px solid #EBEBEB",height:"3rem"},children:[n?(0,c.jsx)(en.Z,{color:"primary"}):(0,c.jsx)(vn.Z,{color:"primary"}),(0,c.jsx)(M.Z,{variant:"body1",color:"primary",fontWeight:700,children:"".concat(e.level_2_name)})]}),(0,c.jsxs)(yn.Z,{in:n,sx:{paddingX:"5px"},children:[n&&t.length>0&&(0,c.jsx)(Z.Z,{sx:{display:"flex",flexDirection:"column",gap:"12px",mb:2},children:Array.from({length:Math.ceil(t.length/3)},(function(e,n){return t.slice(3*n,3*n+3)})).map((function(e,n){return(0,c.jsx)(Z.Z,{sx:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:"12px",pb:2,borderBottom:"1px solid",borderColor:"divider"},children:e.map((function(e){return(0,c.jsx)(dn,{question:e,answers:Ne,getQuestion:Fn,getAnswer:Dn,surveyAlreadySubmitted:an,upsertQuestions:function(n){return Tn(e,{shoulCheckIsValid:n})},nextQuestionLoading:Oe,handlePreviousQuestion:Ln,handleNextQuestion:Hn,isQuestionMain:!1,hideNavigationButtons:!0,handleValidateQuestion:function(){return!1},flatQuestions:R,disabledButtonNextQuestion:!1,layout:"grid"},e.id)}))},n)}))}),n&&i.map((function(e){return(0,c.jsx)(dn,{question:e,answers:Ne,getQuestion:Fn,getAnswer:Dn,surveyAlreadySubmitted:an,upsertQuestions:function(n){return Tn(e,{shoulCheckIsValid:n})},nextQuestionLoading:Oe,handlePreviousQuestion:Ln,handleNextQuestion:Hn,isQuestionMain:!0,hideNavigationButtons:!0,handleValidateQuestion:function(){return!1},flatQuestions:R,disabledButtonNextQuestion:!1,dependentRepeatQuestions:ln.get(e.id),inlineDependentQuestions:jn.get(e.id)},e.id)}))]})]},e.level_2_id)})),(0,c.jsxs)(Z.Z,{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",mt:3,children:[(0,c.jsx)(b.Z,{variant:"contained",size:"small",sx:{textTransform:"none",borderRadius:1.5},startIcon:(0,c.jsx)($e.Z,{}),onClick:function(){Nn<=0?De({message:"Voc\xea est\xe1 no primeiro pilar.",alertType:"info",autoHideDuration:2e3}):In(Nn-1)},disabled:Oe||Nn<=0,children:"Anterior"}),(0,c.jsx)(E,{ref:ze,showTrigger:Vn,groupAnswerId:null!==Ge&&void 0!==Ge?Ge:void 0,setGroupAnswers:ie,disabled:Oe||En<100,surveyAlreadySubmitted:an,onBeforeSubmit:On}),!Vn&&(0,c.jsxs)(b.Z,{variant:"contained",size:"small",sx:{textTransform:"none",borderRadius:1.5},endIcon:Oe?null:(0,c.jsx)(Xe.Z,{}),onClick:function(){Vn||In(Nn+1)},disabled:Oe,children:[Oe?(0,c.jsx)(Z.Z,{mr:1,lineHeight:1,children:(0,c.jsx)(j.Z,{color:"inherit",size:"1.25rem"})}):null,"Pr\xf3ximo"]})]})]})})}))})]})]})}),(0,c.jsx)(V,{open:S,regulations:B,onClose:function(){_()},onAccept:function(){var e=(0,t.Z)((function(e){var n;return(0,d.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,w(e)];case 1:return r.sent(),[3,3];case 2:throw n=r.sent(),console.error("Erro ao aceitar regulamento",n),n;case 3:return[2]}}
1))}));return function(n){return e.apply(this,arguments)}}(),onAllAccepted:function(){A(!1)}})]})}}},function(e){e.O(0,[251,3970,8360,1664,210,3795,2055,2244,1179,135,9912,5252,2420,9646,5779,612,9774,2888,179],(function(){return n=78343,e(e.s=n);var n}));var n=e.O();_N_E=n}]);
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.