@buildocsdev/sdk 1.1.24 → 1.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import {a,b as b$1}from'./chunk-5VSWNFWW.js';import {a as a$1}from'./chunk-POE6K4NQ.js';import {U,T,k}from'./chunk-TYVVEP34.js';import'./chunk-U4T4ACDE.js';import {b}from'./chunk-LBMVBVXW.js';import {q,a as a$2}from'./chunk-AYYTOQGP.js';import {c,d,p,m,N}from'./chunk-AR42AC7J.js';import'./chunk-5TBO732O.js';import {lazy,memo,useRef,useState,useEffect}from'react';import {withTranslation,useTranslation}from'react-i18next';import {useLocation}from'react-router-dom';import {LocalizationProvider,DateTimePicker,DatePicker}from'@mui/x-date-pickers';import Ft from'@mui/material/TextField';import X from'react-dom/client';import Et from'@mui/material/Tooltip';import Zt from'@mui/material/Box';import te from'@mui/material/Button';import Pt from'@mui/material/MenuList';import Nt from'@mui/material/MenuItem';import At from'@mui/material/Paper';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {nanoid}from'@reduxjs/toolkit';import ne from'react-dom/server';import'react-tabulator/lib/styles.css';import'react-tabulator/css/bootstrap/tabulator_bootstrap.min.css';import'react-tabulator/lib/css/bootstrap/tabulator_bootstrap.min.css';var $t=({cellElement:u,cell:t,actionHandler:o})=>{let {t:e}=useTranslation();t.getRow().getPosition();let i=u.getBoundingClientRect(),m=i.bottom+window.scrollY,a=i.left+window.scrollX;return jsx(At,{style:{position:"absolute",top:m+"px",left:a+"px",zIndex:2e3,minWidth:"150px"},children:jsx(Pt,{children:jsxs(Nt,{onClick:()=>o(t),children:[jsx(N,{style:{fontSize:"1em",marginRight:"0.5em"}})," ",e("Delete")]})})})},Ct=$t;var L=class u{static convertToVariables(t){let o={};for(let e in t)if(t.hasOwnProperty(e)&&(typeof t[e]=="string"||typeof t[e]=="number")){let n=Number(t[e]);isNaN(n)||(o[e]=n);}return o}static formulaHasFieldName(t,o){if(t.operands){for(let e of t.operands)if(typeof e=="string"&&e===o||typeof e=="object"&&u.formulaHasFieldName(e,o))return true}return false}static parseExpression(t){t=t.replace(/\s+/g,"");let o=/\(([^()]+)\)/;for(;o.test(t);)t=t.replace(o,(i,m)=>{let a=u.parseExpression(m.trim());return `@${JSON.stringify(a)}`});let n=u.tokenize(t).map(i=>i.startsWith("@")?JSON.parse(i.substring(1)):i);return u.parseTokens(n)}static tokenize(t){let o=[],e="",n=false,i=0;for(let m=0;m<t.length;m++){let a=t[m];if(a==="@"&&t[m+1]==="{"&&(e&&(o.push(e),e=""),n=true,i=0),n){e+=a,a==="{"?i++:a==="}"&&(i--,i===0&&(o.push(e),e="",n=false));continue}if("+-*/()".includes(a)){e&&(o.push(e),e=""),o.push(a);continue}e+=a;}return e&&o.push(e),o}static parseTokens(t){if(t.length===1){let a=t[0];if(typeof a=="string"){let s=parseFloat(a);return isNaN(s)?{operands:[a]}:{value:s}}if(typeof a=="object")return a}let o={"+":1,"-":1,"*":2,"/":2},e=1/0,n=-1;if(t.forEach((a,s)=>{if(typeof a=="string"&&a in o){let d=a;o[d]<=e&&(e=o[d],n=s);}}),n===-1)throw new Error(`Invalid expression: no operator found in tokens ${JSON.stringify(t)}`);let i=t.slice(0,n),m=t.slice(n+1);if(i.length===0||m.length===0)throw new Error(`Invalid expression: operator without operands in tokens ${JSON.stringify(t)}`);return {operator:t[n],operands:[u.parseTokens(i),u.parseTokens(m)]}}static evaluateFormula(t,o){if(t.value!==void 0)return t.value;let{operator:e,operands:n}=t;if(!e||!n||n.length!==2)throw new Error("Invalid parsed formula");let[i,m]=n.map(a=>{if(typeof a=="object"&&a.operands&&a.operands.length===1&&(a=a.operands[0]),typeof a=="string")return o[a]||0;if(typeof a=="number")return a;if(typeof a=="object")return u.evaluateFormula(a,o);throw new Error(`Unsupported operand type: ${JSON.stringify(a)}`)});switch(e){case "+":return i+m;case "-":return i-m;case "*":return i*m;case "/":return i/m;default:throw new Error(`Unsupported operator: ${e}`)}}static convertValuesToStrings(t){return t.map(o=>{let e={};for(let[n,i]of Object.entries(o))e[n]=i===void 0?"":String(i);return e})}static buildDependencyGraph(t){let o={};for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e],i=[],m=a=>{a.forEach(s=>{typeof s=="string"?i.push(s):typeof s=="object"&&"operands"in s&&s.operands&&m(s.operands);});};n.operands&&m(n.operands),o[e]=i;}return o}static topologicalSort(t){let o=new Set,e=[],n=i=>{o.has(i)||(o.add(i),(t[i]||[]).forEach(n),e.push(i));};return Object.keys(t).forEach(n),e}};var re=ne.renderToStaticMarkup(jsx(c,{}));if(typeof window!="undefined"&&window.ResizeObserver){let u=window.ResizeObserver;window.ResizeObserver=class extends u{constructor(t){let o;super((e,n)=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>t(e,n));});}};}var oe=lazy(()=>import('react-tabulator').then(u=>({default:u.ReactTabulator}))),ae=u=>{var o;if(!u.properties.folders)return null;var t=(o=u.context.params.folderData)==null?void 0:o.captions;return t==null||t.length===0?null:(t=t.slice(1),jsx("span",{style:{display:"flex",alignItems:"center"},children:t.map((e,n)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e,n<t.length-1&&jsx(d,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}})]},n))}))},ie=(u,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=u.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","M/D/YYYY","D/M/YYYY"];for(let F of h)if(r=a$1(w,F),r.isValid())break}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DD"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DatePicker,{value:a$1(f),onAccept:b,onChange:y,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},le=(u,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=u.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY HH:mm:ss","DD.MM.YYYY HH:mm","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm","YYYY-MM-DDTHH:mm:ss","MM/DD/YYYY HH:mm:ss","MM/DD/YYYY HH:mm","DD/MM/YYYY HH:mm:ss","DD/MM/YYYY HH:mm"];for(let F of h)if(r=a$1(w,F),r.isValid())break}if(!r||!r.isValid()){let h=["HH:mm:ss","HH:mm"];for(let F of h){let k=a$1(w,F,true);if(k.isValid()){r=(f?a$1(f):a$1()).hour(k.hour()).minute(k.minute()).second(k.second());break}}}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DDTHH:mm:ss"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DateTimePicker,{value:f?a$1(f):null,onAccept:b,onChange:y,ampm:false,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},se=(u,t,o,e)=>{var m;if(!u.alloweditrow||u.readonly===true)return;let n=(m=t.item_columntype)!=null?m:"freetext";t.item_columntype||(t.item_isdate===true?n="date":t.item_isdatetime===true?n="datetime":t.item_ischeckbox===true?n="checkbox":t.item_isprice===true?n="price":n="freetext");return n==="datetime"?(a,s,d,f,D)=>le(a,s,d,f,D,o.current,e,u.name):n==="date"?(a,s,d,f,D)=>ie(a,s,d,f,D,o.current,e,u.name):t.item_editor==="number"||n==="price"||n==="number"?"number":t.item_editor==="checkbox"||n==="checkbox"?"tickCross":"input"},ue=(u,t,o,e,n)=>{let i=u.getElement();i.style.backgroundColor="#f0f0f0",i.style.color="#555",i.style.pointerEvents="none";},Yt=(u,t,o,e,n,i)=>{var R;let m=(y,b,H)=>{if(!(H==="price"))return `<div class="tabulator-text">${y||""}</div>`;let x=e.item_format==="fixed-locale",h=x&&e.item_fixedlocale||n.current||void 0,F=b!==void 0&&b[e.item_inputfield]?b[e.item_inputfield]:e.item_currency,k$1=e.item_format==="locale"?k(n.current):void 0,A=x?k(e.item_fixedlocale||""):void 0,W=String(F!=null?F:""),K=W&&W.trim()!==""?W.trim():k$1!=null?k$1:A;try{let P,Q=e.item_currencydisplay||(x?"symbol":"");return K&&Q!==""?P=new Intl.NumberFormat(h,{style:"currency",currency:K,currencyDisplay:Q,minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0):P=new Intl.NumberFormat(h,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0),`<div class="tabulator-text">${P}</div>`}catch(P){return `<div class="tabulator-text">${(y||0).toFixed(2)}</div>`}};if(!t.alloweditrow)return;let a=(R=e.item_columntype)!=null?R:"freetext";e.item_columntype||(e.item_isdate===true?a="date":e.item_isdatetime===true?a="datetime":e.item_ischeckbox===true?a="checkbox":e.item_isprice===true||e.item_format==="locale"||e.item_format==="fixed-locale"?a="price":a="freetext");let s=e.item_readonly||i==="totals",d=a==="price",f=a==="number",D=a==="date",w=a==="datetime",E=a==="checkbox";return s?y=>{ue(y,t,e,n.current);let b=y.getValue();return i==="totals"&&(!e.item_bottomcalc||b==="")?"":m(b,o,a)}:w?y=>me(y,n.current)||"":D?y=>ce(y,n.current)||"":E?"tickCross":d?y=>{let b=y.getValue();return m(b,o,a)}:f?y=>{let b=y.getValue();if(b==null||b==="")return '<div class="tabulator-text"></div>';let H=parseFloat(b);return isNaN(H)?`<div class="tabulator-text">${b}</div>`:`<div class="tabulator-text">${H.toLocaleString(n.current||void 0,{minimumFractionDigits:0,maximumFractionDigits:10})}</div>`}:y=>`<div class="tabulator-text">${y.getValue()||""}</div>`},ce=(u,t)=>{let o=u.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L"))}catch(e){return a$1(o).format("YYYY-MM-DD")}},me=(u,t)=>{let o=u.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L LT"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L LT"))}catch(e){return a$1(o).format("YYYY-MM-DD HH:mm")}},de=(u,t)=>{if(u.alloweditrow&&t.item_editor==="checkbox")return {allowEmpty:true,crossElement:false,tickElement:re}},kt=withTranslation()(memo(function(t){var mt;let{runFormEvent:o,viewPort:e}=b(),n=useRef(null),i=useRef(null),m$1=useRef(null),[a$1,s]=useState(false),[d,f]=useState([]),[D,w]=useState([]),[E,R]=useState([]),[y,b$1]=useState(0),{t:H,i18n:z}=useTranslation(),x=(mt=z==null?void 0:z.language)==null?void 0:mt.substring(0,2),r=useRef(x!=null?x:""),h=useLocation(),[F,k]=useState(false),A=useRef(t.context.formData||{});useEffect(()=>{x&&a(x).catch(c=>{});},[x]),useEffect(()=>{if(r.current=x!=null?x:"",n.current)try{n.current.redraw(!0);}catch(c){}},[x]),useEffect(()=>{let c=()=>{n.current&&!e.isMobileDevice&&n.current.redraw();};return window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c);}},[]),useEffect(()=>{A.current=t.context.formData||{};let c=t.context.formData?t.context.formData[t.properties.name]:null;f(c?JSON.parse(c):[]);},[t.context.formData]),useEffect(()=>{var c;if(F&&n.current!=null){let M=(c=n.current)==null?void 0:c.getData();A.current&&(A.current[t.properties.name]=JSON.stringify(M)),k(false);}},[F]),useEffect(()=>((async()=>{var c,M;t.context.enableEventHandlers?await o({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,widgetContext:JSON.stringify({referer:h.pathname,parentWidgetId:It,hasParentForm:T.hasParentForm(),originator:(c=t.context.params)==null?void 0:c.originator,parent:t.context.params,folderData:(M=t.context.params)==null?void 0:M.folderData}),widgetEvent:U.onTableEditDataLoad,widgetName:t.properties.name.toLowerCase(),formData:t.context.formData}).then(C=>{if(C.meta.requestStatus==="fulfilled"){let p={...C.payload};if(Object.keys(p).length===0)return;if(!p.data){s(true);return}let v=p.data[t.properties.name];p.widgetData.length===0&&v!==void 0&&v!==null&&v.length>0?f(JSON.parse(v)):p.widgetData.length>0&&f(Object.values(p.widgetData)),s(true);}}):s(true);})(),()=>{if(n.current){try{typeof n.current.destroy=="function"&&n.current.destroy();}catch(c){}n.current=null;}}),[]);let W=c=>{var M,C;if(n.current){let p=c.getRow().getData()._id,Y=((M=n.current)==null?void 0:M.getData()).filter(_=>_._id!==p);(C=n.current)==null||C.setData(Y),k(true);}},K=(c,M)=>{if(P(t.properties))return;let C=document.querySelector(".menu-container");C&&C.remove();let p=document.createElement("div");p.className="menu-container",document.body.appendChild(p);let v=X.createRoot(p);v.render(jsx(Ct,{cellElement:c,cell:M,actionHandler:_=>{v.unmount(),p.remove(),document.removeEventListener("click",Y),W(_);}}));let Y=_=>{p.contains(_.target)||(v.unmount(),p.remove(),document.removeEventListener("click",Y));};document.addEventListener("click",Y);};useEffect(()=>{let c;(()=>{c=t.methodProvider.findWidgetItem(t.id);let C=[];c.item.properties.datasource.columns&&(c.item.properties.datasource.columns||[]).map(l=>{C[l[1]]=l[0];});let p=[];(c.item._children||[]).map(({properties:l})=>{l.item_name.toString()!==""&&l.item_increment&&p.push(l.item_name);}),R(p);let v=[];v.push({title:"",field:"remove",headerHozAlign:"center",hozAlign:"center",vertAlign:"middle",width:"1",formatter:l=>{let O=document.createElement("div");return O.style.cursor="pointer",O.style.color="#C0C0C0",O.style.fontSize="0.9rem",O.style.textAlign="center",X.createRoot(O).render(jsx(m,{})),O.addEventListener("click",B=>{B.stopPropagation();let $=l.getElement();K($,l);}),O}});let Y={},_={},I={},dt=100,ft=false;c.item._children.forEach(({properties:l})=>{dt+=parseInt(l.item_minsize,10)||0,l.item_bottomcalc&&(ft=true);}),b$1(dt),(c.item._children||[]).map(({properties:l})=>{var O,nt;if(l.item_name.toString()!==""){let B=l.item_title.split("!!!"),$=B.length>1&&B[0]||null,rt=B.length>1?B[1]:l.item_title;l.item_formula!=null&&l.item_formula.trim()!==""&&(_[l.item_name]=l.item_formula,I[l.item_name]=L.parseExpression(_[l.item_name]));let gt={cellEdited:S=>{let G=S.getField();k(true);let ot=(V,N)=>{let Z=L.buildDependencyGraph(I),at=L.topologicalSort(Z);at.forEach(tt=>{let yt=I[tt];if(yt){let jt=N.getData(),zt=L.evaluateFormula(yt,L.convertToVariables(jt));V!==tt&&(N.update({[tt]:parseFloat(zt.toFixed(2)).toFixed(2)}));}});};for(let V in I)if(Object.prototype.hasOwnProperty.call(I,V)){let N=I[V];if(N&&typeof N=="object"&&L.formulaHasFieldName(N,G)){let Z=S.getRow();if(Z){let at=S.getRow().getData(),it=L.evaluateFormula(N,L.convertToVariables(at));Z.update({[V]:parseFloat(it.toFixed(2)).toFixed(2)});}}}ot(G,S.getRow());},editor:se(t.properties,l,r,m$1),editable:!t.properties.readonly&&!l.item_readonly,field:l.item_name,formatter:Yt(n,t.properties,t.context.formData,l,r,"body"),formatterParams:de(t.properties,l),title:rt,titleFormatter:l.item_displaytooltip?()=>{let S=document.createElement("div");return X.createRoot(S).render(jsx(Et,{title:rt,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:rt})})),S}:void 0,cssClass:!t.properties.readonly&&!l.item_readonly?"tabulator-ellipsis":"tabulator-readonly",minWidth:parseInt(l.item_minsize,10)||void 0,headerHozAlign:(O=l.style.item_textalign)!=null?O:"center",hozAlign:(nt=l.style.item_ctextalign)!=null?nt:"center",vertAlign:"middle",bottomCalc:S=>l.item_bottomcalc?S.reduce((G,ot)=>{let V=parseFloat(String(ot).replace(",","."));return G+(isNaN(V)?0:V)},0):"",bottomCalcFormatter:ft?Yt(n,t.properties,t.context.formData,l,r,"totals"):void 0,headerSort:l.item_enablesorting};$?(Y[$]||(Y[$]=[]),Y[$].push(gt)):v.push(gt);}}),Object.entries(Y).forEach(([l,O])=>{v.push({title:l,columns:O,cssClass:t.properties.readonly?"tabulator-readonly":"tabulator-ellipsis"});}),w(v),s(true);})();},[t.properties,t.context.params.guid]),useEffect(()=>{n.current&&(n.current.setColumns(D),n.current.redraw());},[D]);let P=c=>!!(c.readonly&&!c.ignorereadonly);function Q(c){let M=C=>C.reduce((p,v)=>{var Y,_;if(v.field&&(p[v.field]="",E.includes(v.field))){let I=(_=(Y=n.current)==null?void 0:Y.getDataCount())!=null?_:0;I!==void 0&&(p[v.field]=String(I+1));}return v.columns&&Array.isArray(v.columns)&&Object.assign(p,M(v.columns)),p},{});return {_id:nanoid(11),...M(c)}}let Ot=()=>jsx(Et,{title:H("Add New"),children:jsx("span",{children:jsx(te,{disabled:P(t.properties),color:"primary",style:{marginRight:"5px"},onClick:()=>{n.current&&n.current.addRow(Q(D));},variant:"outlined",children:jsx(p,{})})})}),{hideaddbutton:_t,folders:Lt,visible:Ht}=t.properties,{tabId:It}=t;if(!Ht)return null;if(!a$1)return jsx(q,{text:"",size:40,textVariant:"body2",variant:void 0});let St={minHeight:t.properties.height,movableRows:false,movableColumns:false,rowHeight:40,layout:"fitColumns"},Vt=()=>{document.querySelectorAll(".tabulator-header-contents > br").forEach(C=>C.remove());document.querySelectorAll(".tabulator-footer");};return jsxs(Fragment,{children:[Lt&&jsx("div",{style:{paddingBottom:"0.8rem",fontSize:"0.85rem",color:"#666",marginLeft:"0.2rem"},children:ae(t)}),jsxs("div",{style:{padding:10,paddingBottom:0,overflowX:"auto"},ref:i,children:[jsx(Zt,{sx:{paddingBottom:1,paddingTop:1,paddingRight:1},children:!_t&&jsx(Ot,{})}),jsx(oe,{onRef:c=>n.current=c==null?void 0:c.current,data:d,columns:D,options:St,events:{tableBuilt:Vt},className:"tabulator",style:{marginBottom:0,minWidth:y+"px"}})]})]})}));kt.displayName="_Tabulator";var Ze=kt;export{Ze as TabulatorTable};
1
+ import {a,b as b$1}from'./chunk-5VSWNFWW.js';import {a as a$1}from'./chunk-POE6K4NQ.js';import {U,T,k}from'./chunk-TYVVEP34.js';import'./chunk-U4T4ACDE.js';import {b}from'./chunk-LBMVBVXW.js';import {q,a as a$2}from'./chunk-AYYTOQGP.js';import {c,d,p,m,N}from'./chunk-AR42AC7J.js';import'./chunk-5TBO732O.js';import {lazy,memo,useRef,useState,useEffect}from'react';import {withTranslation,useTranslation}from'react-i18next';import {useLocation}from'react-router-dom';import {LocalizationProvider,DateTimePicker,DatePicker}from'@mui/x-date-pickers';import Ft from'@mui/material/TextField';import X from'react-dom/client';import Et from'@mui/material/Tooltip';import Zt from'@mui/material/Box';import te from'@mui/material/Button';import Pt from'@mui/material/MenuList';import Nt from'@mui/material/MenuItem';import At from'@mui/material/Paper';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {nanoid}from'@reduxjs/toolkit';import ne from'react-dom/server';import'react-tabulator/lib/styles.css';import'react-tabulator/css/bootstrap/tabulator_bootstrap.min.css';import'react-tabulator/lib/css/bootstrap/tabulator_bootstrap.min.css';var $t=({cellElement:c,cell:t,actionHandler:o})=>{let {t:e}=useTranslation();t.getRow().getPosition();let i=c.getBoundingClientRect(),m=i.bottom+window.scrollY,a=i.left+window.scrollX;return jsx(At,{style:{position:"absolute",top:m+"px",left:a+"px",zIndex:2e3,minWidth:"150px"},children:jsx(Pt,{children:jsxs(Nt,{onClick:()=>o(t),children:[jsx(N,{style:{fontSize:"1em",marginRight:"0.5em"}})," ",e("Delete")]})})})},Ct=$t;var L=class c{static convertToVariables(t){let o={};for(let e in t)if(t.hasOwnProperty(e)&&(typeof t[e]=="string"||typeof t[e]=="number")){let n=Number(t[e]);isNaN(n)||(o[e]=n);}return o}static formulaHasFieldName(t,o){if(t.operands){for(let e of t.operands)if(typeof e=="string"&&e===o||typeof e=="object"&&c.formulaHasFieldName(e,o))return true}return false}static parseExpression(t){t=t.replace(/\s+/g,"");let o=/\(([^()]+)\)/;for(;o.test(t);)t=t.replace(o,(i,m)=>{let a=c.parseExpression(m.trim());return `@${JSON.stringify(a)}`});let n=c.tokenize(t).map(i=>i.startsWith("@")?JSON.parse(i.substring(1)):i);return c.parseTokens(n)}static tokenize(t){let o=[],e="",n=false,i=0;for(let m=0;m<t.length;m++){let a=t[m];if(a==="@"&&t[m+1]==="{"&&(e&&(o.push(e),e=""),n=true,i=0),n){e+=a,a==="{"?i++:a==="}"&&(i--,i===0&&(o.push(e),e="",n=false));continue}if("+-*/()".includes(a)){e&&(o.push(e),e=""),o.push(a);continue}e+=a;}return e&&o.push(e),o}static parseTokens(t){if(t.length===1){let a=t[0];if(typeof a=="string"){let s=parseFloat(a);return isNaN(s)?{operands:[a]}:{value:s}}if(typeof a=="object")return a}let o={"+":1,"-":1,"*":2,"/":2},e=1/0,n=-1;if(t.forEach((a,s)=>{if(typeof a=="string"&&a in o){let d=a;o[d]<=e&&(e=o[d],n=s);}}),n===-1)throw new Error(`Invalid expression: no operator found in tokens ${JSON.stringify(t)}`);let i=t.slice(0,n),m=t.slice(n+1);if(i.length===0||m.length===0)throw new Error(`Invalid expression: operator without operands in tokens ${JSON.stringify(t)}`);return {operator:t[n],operands:[c.parseTokens(i),c.parseTokens(m)]}}static evaluateFormula(t,o){if(t.value!==void 0)return t.value;let{operator:e,operands:n}=t;if(!e||!n||n.length!==2)throw new Error("Invalid parsed formula");let[i,m]=n.map(a=>{if(typeof a=="object"&&a.operands&&a.operands.length===1&&(a=a.operands[0]),typeof a=="string")return o[a]||0;if(typeof a=="number")return a;if(typeof a=="object")return c.evaluateFormula(a,o);throw new Error(`Unsupported operand type: ${JSON.stringify(a)}`)});switch(e){case "+":return i+m;case "-":return i-m;case "*":return i*m;case "/":return i/m;default:throw new Error(`Unsupported operator: ${e}`)}}static convertValuesToStrings(t){return t.map(o=>{let e={};for(let[n,i]of Object.entries(o))e[n]=i===void 0?"":String(i);return e})}static buildDependencyGraph(t){let o={};for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e],i=[],m=a=>{a.forEach(s=>{typeof s=="string"?i.push(s):typeof s=="object"&&"operands"in s&&s.operands&&m(s.operands);});};n.operands&&m(n.operands),o[e]=i;}return o}static topologicalSort(t){let o=new Set,e=[],n=i=>{o.has(i)||(o.add(i),(t[i]||[]).forEach(n),e.push(i));};return Object.keys(t).forEach(n),e}};var re=ne.renderToStaticMarkup(jsx(c,{}));if(typeof window!="undefined"&&window.ResizeObserver){let c=window.ResizeObserver;window.ResizeObserver=class extends c{constructor(t){let o;super((e,n)=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>t(e,n));});}};}var oe=lazy(()=>import('react-tabulator').then(c=>({default:c.ReactTabulator}))),ae=c=>{var o;if(!c.properties.folders)return null;var t=(o=c.context.params.folderData)==null?void 0:o.captions;return t==null||t.length===0?null:(t=t.slice(1),jsx("span",{style:{display:"flex",alignItems:"center"},children:t.map((e,n)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e,n<t.length-1&&jsx(d,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}})]},n))}))},ie=(c,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=c.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","M/D/YYYY","D/M/YYYY"];for(let F of h)if(r=a$1(w,F),r.isValid())break}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DD"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DatePicker,{value:a$1(f),onAccept:b,onChange:y,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},le=(c,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=c.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY HH:mm:ss","DD.MM.YYYY HH:mm","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm","YYYY-MM-DDTHH:mm:ss","MM/DD/YYYY HH:mm:ss","MM/DD/YYYY HH:mm","DD/MM/YYYY HH:mm:ss","DD/MM/YYYY HH:mm"];for(let F of h)if(r=a$1(w,F),r.isValid())break}if(!r||!r.isValid()){let h=["HH:mm:ss","HH:mm"];for(let F of h){let k=a$1(w,F,true);if(k.isValid()){r=(f?a$1(f):a$1()).hour(k.hour()).minute(k.minute()).second(k.second());break}}}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DDTHH:mm:ss"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DateTimePicker,{value:f?a$1(f):null,onAccept:b,onChange:y,ampm:false,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},se=(c,t,o,e)=>{var m;if(!c.alloweditrow||c.readonly===true)return;let n=(m=t.item_columntype)!=null?m:"freetext";t.item_columntype||(t.item_isdate===true?n="date":t.item_isdatetime===true?n="datetime":t.item_ischeckbox===true?n="checkbox":t.item_isprice===true?n="price":n="freetext");return n==="datetime"?(a,s,d,f,D)=>le(a,s,d,f,D,o.current,e,c.name):n==="date"?(a,s,d,f,D)=>ie(a,s,d,f,D,o.current,e,c.name):t.item_editor==="number"||n==="price"||n==="number"?"number":t.item_editor==="checkbox"||n==="checkbox"?"tickCross":"input"},ue=(c,t,o,e,n)=>{let i=c.getElement();i.style.backgroundColor="#f0f0f0",i.style.color="#555",i.style.pointerEvents="none";},Yt=(c,t,o,e,n,i)=>{var R;let m=(y,b,H)=>{if(!(H==="price"))return `<div class="tabulator-text">${y||""}</div>`;let x=e.item_format==="fixed-locale",h=x&&e.item_fixedlocale||n.current||void 0,F=b!==void 0&&b[e.item_inputfield]?b[e.item_inputfield]:e.item_currency,k$1=e.item_format==="locale"?k(n.current):void 0,A=x?k(e.item_fixedlocale||""):void 0,W=String(F!=null?F:""),K=W&&W.trim()!==""?W.trim():k$1!=null?k$1:A;try{let P,Q=e.item_currencydisplay||(x?"symbol":"");return K&&Q!==""?P=new Intl.NumberFormat(h,{style:"currency",currency:K,currencyDisplay:Q,minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0):P=new Intl.NumberFormat(h,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0),`<div class="tabulator-text">${P}</div>`}catch(P){return `<div class="tabulator-text">${(y||0).toFixed(2)}</div>`}};if(!t.alloweditrow)return;let a=(R=e.item_columntype)!=null?R:"freetext";e.item_columntype||(e.item_isdate===true?a="date":e.item_isdatetime===true?a="datetime":e.item_ischeckbox===true?a="checkbox":e.item_isprice===true||e.item_format==="locale"||e.item_format==="fixed-locale"?a="price":a="freetext");let s=e.item_readonly||i==="totals",d=a==="price",f=a==="number",D=a==="date",w=a==="datetime",E=a==="checkbox";return s?y=>{ue(y,t,e,n.current);let b=y.getValue();return i==="totals"&&(!e.item_bottomcalc||b==="")?"":m(b,o,a)}:w?y=>me(y,n.current)||"":D?y=>ce(y,n.current)||"":E?"tickCross":d?y=>{let b=y.getValue();return m(b,o,a)}:f?y=>{let b=y.getValue();if(b==null||b==="")return '<div class="tabulator-text"></div>';let H=parseFloat(b);return isNaN(H)?`<div class="tabulator-text">${b}</div>`:`<div class="tabulator-text">${H.toLocaleString(n.current||void 0,{minimumFractionDigits:0,maximumFractionDigits:10})}</div>`}:y=>`<div class="tabulator-text">${y.getValue()||""}</div>`},ce=(c,t)=>{let o=c.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L"))}catch(e){return a$1(o).format("YYYY-MM-DD")}},me=(c,t)=>{let o=c.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L LT"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L LT"))}catch(e){return a$1(o).format("YYYY-MM-DD HH:mm")}},de=(c,t)=>{if(c.alloweditrow&&t.item_editor==="checkbox")return {allowEmpty:true,crossElement:false,tickElement:re}},kt=withTranslation()(memo(function(t){var mt;let{runFormEvent:o,viewPort:e}=b(),n=useRef(null),i=useRef(null),m$1=useRef(null),[a$1,s]=useState(false),[d,f]=useState([]),[D,w]=useState([]),[E,R]=useState([]),[y,b$1]=useState(0),{t:H,i18n:z}=useTranslation(),x=(mt=z==null?void 0:z.language)==null?void 0:mt.substring(0,2),r=useRef(x!=null?x:""),h=useLocation(),[F,k]=useState(false),A=useRef(t.context.formData||{});useEffect(()=>{x&&a(x).catch(u=>{});},[x]),useEffect(()=>{if(r.current=x!=null?x:"",n.current)try{n.current.redraw(!0);}catch(u){}},[x]),useEffect(()=>{let u=()=>{n.current&&!e.isMobileDevice&&n.current.redraw();};return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u);}},[]),useEffect(()=>{A.current=t.context.formData||{};let u=t.context.formData?t.context.formData[t.properties.name]:null;f(u?JSON.parse(u):[]);},[t.context.formData]),useEffect(()=>{var u;if(F&&n.current!=null){let M=(u=n.current)==null?void 0:u.getData();A.current&&(A.current[t.properties.name]=JSON.stringify(M)),k(false);}},[F]),useEffect(()=>((async()=>{var u,M;t.context.enableEventHandlers?await o({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,widgetContext:JSON.stringify({referer:h.pathname,parentWidgetId:It,hasParentForm:T.hasParentForm(),originator:(u=t.context.params)==null?void 0:u.originator,parent:t.context.params,folderData:(M=t.context.params)==null?void 0:M.folderData}),widgetEvent:U.onTableEditDataLoad,widgetName:t.properties.name.toLowerCase(),formData:t.context.formData}).then(C=>{if(C.meta.requestStatus==="fulfilled"){let p={...C.payload};if(Object.keys(p).length===0)return;if(!p.data){s(true);return}let v=p.data[t.properties.name];p.widgetData.length===0&&v!==void 0&&v!==null&&v.length>0?f(JSON.parse(v)):p.widgetData.length>0&&f(Object.values(p.widgetData)),s(true);}}):s(true);})(),()=>{if(n.current){try{typeof n.current.destroy=="function"&&n.current.destroy();}catch(u){}n.current=null;}}),[]);let W=u=>{var M,C;if(n.current){let p=u.getRow().getData()._id,Y=((M=n.current)==null?void 0:M.getData()).filter(_=>_._id!==p);(C=n.current)==null||C.setData(Y),k(true);}},K=(u,M)=>{if(P(t.properties))return;let C=document.querySelector(".menu-container");C&&C.remove();let p=document.createElement("div");p.className="menu-container",document.body.appendChild(p);let v=X.createRoot(p);v.render(jsx(Ct,{cellElement:u,cell:M,actionHandler:_=>{v.unmount(),p.remove(),document.removeEventListener("click",Y),W(_);}}));let Y=_=>{p.contains(_.target)||(v.unmount(),p.remove(),document.removeEventListener("click",Y));};document.addEventListener("click",Y);};useEffect(()=>{let u;(()=>{if(u=t.methodProvider.findWidgetItem(t.id),!u)return;let C=[];u.item.properties.datasource.columns&&(u.item.properties.datasource.columns||[]).map(l=>{C[l[1]]=l[0];});let p=[];(u.item._children||[]).map(({properties:l})=>{l.item_name.toString()!==""&&l.item_increment&&p.push(l.item_name);}),R(p);let v=[];v.push({title:"",field:"remove",headerHozAlign:"center",hozAlign:"center",vertAlign:"middle",width:"1",formatter:l=>{let O=document.createElement("div");return O.style.cursor="pointer",O.style.color="#C0C0C0",O.style.fontSize="0.9rem",O.style.textAlign="center",X.createRoot(O).render(jsx(m,{})),O.addEventListener("click",B=>{B.stopPropagation();let $=l.getElement();K($,l);}),O}});let Y={},_={},I={},dt=100,ft=false;u.item._children.forEach(({properties:l})=>{dt+=parseInt(l.item_minsize,10)||0,l.item_bottomcalc&&(ft=true);}),b$1(dt),(u.item._children||[]).map(({properties:l})=>{var O,nt;if(l.item_name.toString()!==""){let B=l.item_title.split("!!!"),$=B.length>1&&B[0]||null,rt=B.length>1?B[1]:l.item_title;l.item_formula!=null&&l.item_formula.trim()!==""&&(_[l.item_name]=l.item_formula,I[l.item_name]=L.parseExpression(_[l.item_name]));let gt={cellEdited:S=>{let G=S.getField();k(true);let ot=(V,N)=>{let Z=L.buildDependencyGraph(I),at=L.topologicalSort(Z);at.forEach(tt=>{let yt=I[tt];if(yt){let jt=N.getData(),zt=L.evaluateFormula(yt,L.convertToVariables(jt));V!==tt&&(N.update({[tt]:parseFloat(zt.toFixed(2)).toFixed(2)}));}});};for(let V in I)if(Object.prototype.hasOwnProperty.call(I,V)){let N=I[V];if(N&&typeof N=="object"&&L.formulaHasFieldName(N,G)){let Z=S.getRow();if(Z){let at=S.getRow().getData(),it=L.evaluateFormula(N,L.convertToVariables(at));Z.update({[V]:parseFloat(it.toFixed(2)).toFixed(2)});}}}ot(G,S.getRow());},editor:se(t.properties,l,r,m$1),editable:!t.properties.readonly&&!l.item_readonly,field:l.item_name,formatter:Yt(n,t.properties,t.context.formData,l,r,"body"),formatterParams:de(t.properties,l),title:rt,titleFormatter:l.item_displaytooltip?()=>{let S=document.createElement("div");return X.createRoot(S).render(jsx(Et,{title:rt,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:rt})})),S}:void 0,cssClass:!t.properties.readonly&&!l.item_readonly?"tabulator-ellipsis":"tabulator-readonly",minWidth:parseInt(l.item_minsize,10)||void 0,headerHozAlign:(O=l.style.item_textalign)!=null?O:"center",hozAlign:(nt=l.style.item_ctextalign)!=null?nt:"center",vertAlign:"middle",bottomCalc:S=>l.item_bottomcalc?S.reduce((G,ot)=>{let V=parseFloat(String(ot).replace(",","."));return G+(isNaN(V)?0:V)},0):"",bottomCalcFormatter:ft?Yt(n,t.properties,t.context.formData,l,r,"totals"):void 0,headerSort:l.item_enablesorting};$?(Y[$]||(Y[$]=[]),Y[$].push(gt)):v.push(gt);}}),Object.entries(Y).forEach(([l,O])=>{v.push({title:l,columns:O,cssClass:t.properties.readonly?"tabulator-readonly":"tabulator-ellipsis"});}),w(v),s(true);})();},[t.properties,t.context.params.guid]),useEffect(()=>{n.current&&(n.current.setColumns(D),n.current.redraw());},[D]);let P=u=>!!(u.readonly&&!u.ignorereadonly);function Q(u){let M=C=>C.reduce((p,v)=>{var Y,_;if(v.field&&(p[v.field]="",E.includes(v.field))){let I=(_=(Y=n.current)==null?void 0:Y.getDataCount())!=null?_:0;I!==void 0&&(p[v.field]=String(I+1));}return v.columns&&Array.isArray(v.columns)&&Object.assign(p,M(v.columns)),p},{});return {_id:nanoid(11),...M(u)}}let Ot=()=>jsx(Et,{title:H("Add New"),children:jsx("span",{children:jsx(te,{disabled:P(t.properties),color:"primary",style:{marginRight:"5px"},onClick:()=>{n.current&&n.current.addRow(Q(D));},variant:"outlined",children:jsx(p,{})})})}),{hideaddbutton:_t,folders:Lt,visible:Ht}=t.properties,{tabId:It}=t;if(!Ht)return null;if(!a$1)return jsx(q,{text:"",size:40,textVariant:"body2",variant:void 0});let St={minHeight:t.properties.height,movableRows:false,movableColumns:false,rowHeight:40,layout:"fitColumns"},Vt=()=>{document.querySelectorAll(".tabulator-header-contents > br").forEach(C=>C.remove());document.querySelectorAll(".tabulator-footer");};return jsxs(Fragment,{children:[Lt&&jsx("div",{style:{paddingBottom:"0.8rem",fontSize:"0.85rem",color:"#666",marginLeft:"0.2rem"},children:ae(t)}),jsxs("div",{style:{padding:10,paddingBottom:0,overflowX:"auto"},ref:i,children:[jsx(Zt,{sx:{paddingBottom:1,paddingTop:1,paddingRight:1},children:!_t&&jsx(Ot,{})}),jsx(oe,{onRef:u=>n.current=u==null?void 0:u.current,data:d,columns:D,options:St,events:{tableBuilt:Vt},className:"tabulator",style:{marginBottom:0,minWidth:y+"px"}})]})]})}));kt.displayName="_Tabulator";var Ze=kt;export{Ze as TabulatorTable};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildocsdev/sdk",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
@@ -1,2 +0,0 @@
1
- import {a as a$1}from'./chunk-POE6K4NQ.js';import {g,i as i$1,l as l$1,k as k$1,d}from'./chunk-3UNAMWG4.js';import {b as b$1,f,e as e$1,g as g$2}from'./chunk-FRAOYRZD.js';import {b as b$2,a as a$3}from'./chunk-22LEYH6Q.js';import {y,z,B,T,U,x,A,k as k$2}from'./chunk-TYVVEP34.js';import {b}from'./chunk-LBMVBVXW.js';import {n,e,k,l,p,o,f as f$1,g as g$1,h,m as m$1}from'./chunk-AYYTOQGP.js';import {i,m,P,t,A as A$1,E,N,s}from'./chunk-AR42AC7J.js';import {a as a$2}from'./chunk-SDIZEEZP.js';import {a,c}from'./chunk-5TBO732O.js';import*as Te from'react';import Te__default,{memo,useRef,useState,useEffect,createElement,createContext,lazy,useCallback,startTransition,Suspense,useContext,useMemo}from'react';import {withTranslation,useTranslation}from'react-i18next';import {useLocation,useNavigate}from'react-router-dom';import {nanoid}from'@reduxjs/toolkit';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import ja from'@mui/material/Box';import Qr from'@mui/material/Button';import Kr from'@mui/material/Tooltip';import _i from'axios';import Gi from'@mui/material/CircularProgress';import zi from'@mui/material/LinearProgress';import lr from'@mui/material/IconButton';import Ml from'@mui/material/InputAdornment';import Bl from'@mui/icons-material/Visibility';import Nl from'@mui/icons-material/VisibilityOff';import {animated,useSpring}from'@react-spring/web';import {styled,alpha}from'@mui/material/styles';import Vl from'@mui/material/Collapse';import Ol from'@mui/material/Typography';import Hl from'@mui/icons-material/FolderRounded';import {RichTreeView}from'@mui/x-tree-view/RichTreeView';import {treeItemClasses}from'@mui/x-tree-view/TreeItem';import {unstable_useTreeItem2}from'@mui/x-tree-view/useTreeItem2';import {TreeItem2Root,TreeItem2Content,TreeItem2IconContainer,TreeItem2Checkbox,TreeItem2Label}from'@mui/x-tree-view/TreeItem2';import {TreeItem2Icon}from'@mui/x-tree-view/TreeItem2Icon';import {TreeItem2DragAndDropOverlay}from'@mui/x-tree-view/TreeItem2DragAndDropOverlay';import yt from'@mui/material/ListItemIcon';import wt from'@mui/material/ListItemText';import Ql from'@mui/material/Menu';import xt from'@mui/material/MenuItem';import wd from'i18next';import pd from'@mui/material/Backdrop';var An=a((Ue,_n)=>{Object.defineProperty(Ue,"__esModule",{value:true});function _e(t){return typeof t=="object"&&!("toString"in t)?Object.prototype.toString.call(t).slice(8,-1):t}var wr=typeof process=="object"&&true;function Me(t,e){if(!t)throw wr?new Error("Invariant failed"):new Error(e())}Ue.invariant=Me;var Bt=Object.prototype.hasOwnProperty,xr=Array.prototype.splice,Cr=Object.prototype.toString;function Ye(t){return Cr.call(t).slice(8,-1)}var bt=Object.assign||(function(t,e){return Nt(e).forEach(function(n){Bt.call(e,n)&&(t[n]=e[n]);}),t}),Nt=typeof Object.getOwnPropertySymbols=="function"?function(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.keys(t)};function je(t){return Array.isArray(t)?bt(t.constructor(t.length),t):Ye(t)==="Map"?new Map(t):Ye(t)==="Set"?new Set(t):t&&typeof t=="object"?bt(Object.create(Object.getPrototypeOf(t)),t):t}var Nn=(function(){function t(){this.commands=bt({},Ir),this.update=this.update.bind(this),this.update.extend=this.extend=this.extend.bind(this),this.update.isEquals=function(e,n){return e===n},this.update.newContext=function(){return new t().update};}return Object.defineProperty(t.prototype,"isEquals",{get:function(){return this.update.isEquals},set:function(e){this.update.isEquals=e;},enumerable:true,configurable:true}),t.prototype.extend=function(e,n){this.commands[e]=n;},t.prototype.update=function(e,n){var r=this,a=typeof n=="function"?{$apply:n}:n;Array.isArray(e)&&Array.isArray(a)||Me(!Array.isArray(a),function(){return "update(): You provided an invalid spec to update(). The spec may not contain an array except as the value of $set, $push, $unshift, $splice or any custom command allowing an array value."}),Me(typeof a=="object"&&a!==null,function(){return "update(): You provided an invalid spec to update(). The spec and every included key path must be plain objects containing one of the "+("following commands: "+Object.keys(r.commands).join(", ")+".")});var d=e;return Nt(a).forEach(function(l){if(Bt.call(r.commands,l)){var c=e===d;d=r.commands[l](a[l],d,a,e),c&&r.isEquals(d,e)&&(d=e);}else {var s=Ye(e)==="Map"?r.update(e.get(l),a[l]):r.update(e[l],a[l]),m=Ye(d)==="Map"?d.get(l):d[l];(!r.isEquals(s,m)||typeof s=="undefined"&&!Bt.call(e,l))&&(d===e&&(d=je(e)),Ye(d)==="Map"?d.set(l,s):d[l]=s);}}),d},t})();Ue.Context=Nn;var Ir={$push:function(t,e,n){return Mn(e,n,"$push"),t.length?e.concat(t):e},$unshift:function(t,e,n){return Mn(e,n,"$unshift"),t.length?t.concat(e):e},$splice:function(t,e,n,r){return Fr(e,n),t.forEach(function(a){Ln(a),e===r&&a.length&&(e=je(r)),xr.apply(e,a);}),e},$set:function(t,e,n){return Dr(n),t},$toggle:function(t,e){lt(t,"$toggle");var n=t.length?je(e):e;return t.forEach(function(r){n[r]=!e[r];}),n},$unset:function(t,e,n,r){return lt(t,"$unset"),t.forEach(function(a){Object.hasOwnProperty.call(e,a)&&(e===r&&(e=je(r)),delete e[a]);}),e},$add:function(t,e,n,r){return Bn(e,"$add"),lt(t,"$add"),Ye(e)==="Map"?t.forEach(function(a){var d=a[0],l=a[1];e===r&&e.get(d)!==l&&(e=je(r)),e.set(d,l);}):t.forEach(function(a){e===r&&!e.has(a)&&(e=je(r)),e.add(a);}),e},$remove:function(t,e,n,r){return Bn(e,"$remove"),lt(t,"$remove"),t.forEach(function(a){e===r&&e.has(a)&&(e=je(r)),e.delete(a);}),e},$merge:function(t,e,n,r){return Pr(e,t),Nt(t).forEach(function(a){t[a]!==e[a]&&(e===r&&(e=je(r)),e[a]=t[a]);}),e},$apply:function(t,e){return Tr(t),t(e)}},Lt=new Nn;Ue.isEquals=Lt.update.isEquals;Ue.extend=Lt.extend;Ue.default=Lt.update;Ue.default.default=_n.exports=bt(Ue.default,Ue);function Mn(t,e,n){Me(Array.isArray(t),function(){return "update(): expected target of "+_e(n)+" to be an array; got "+_e(t)+"."}),lt(e[n],n);}function lt(t,e){Me(Array.isArray(t),function(){return "update(): expected spec of "+_e(e)+" to be an array; got "+_e(t)+". Did you forget to wrap your parameter in an array?"});}function Fr(t,e){Me(Array.isArray(t),function(){return "Expected $splice target to be an array; got "+_e(t)}),Ln(e.$splice);}function Ln(t){Me(Array.isArray(t),function(){return "update(): expected spec of $splice to be an array of arrays; got "+_e(t)+". Did you forget to wrap your parameters in an array?"});}function Tr(t){Me(typeof t=="function",function(){return "update(): expected spec of $apply to be a function; got "+_e(t)+"."});}function Dr(t){Me(Object.keys(t).length===1,function(){return "Cannot have more than one key in an object with $set"});}function Pr(t,e){Me(e&&typeof e=="object",function(){return "update(): $merge expects a spec of type 'object'; got "+_e(e)}),Me(t&&typeof t=="object",function(){return "update(): $merge expects a target of type 'object'; got "+_e(t)});}function Bn(t,e){var n=Ye(t);Me(n==="Map"||n==="Set",function(){return "update(): "+_e(e)+" expects a target of type Set or Map; got "+_e(n)});}});var sr=c(An());var On=withTranslation()(memo(function(e){let{id:n,tabId:r,panelId:a,context:d,methodProvider:l,widgetsState:c}=e,s=l.findRowItem(r,a,n);return s?Te__default.createElement("div",{className:"row-container"},(s.item._children||[]).map(({rowId:m,id:b,component:F,properties:p})=>Te__default.createElement(Ae.getFormComponent(F,p),{key:"key_"+b,tabId:r,panelId:a,rowId:m,segmentId:b,properties:p,widgetsState:c,methodProvider:l,context:{...d},segmentsCount:s.item._children.length},null))):null}));On.displayName="_Rowcontainer";var Hn=On;var Un=withTranslation()(memo(function(e){let{tabId:n,panelId:r,rowId:a,segmentId:d,segmentsCount:l,properties:c,methodProvider:s,context:m,widgetsState:b}=e,F=s.findSegmentItem(n,r,a,d),p={...c.style};return Te__default.createElement("div",{className:"rowSegment",style:p},(F.item._children||[]).map(({id:f,component:u,properties:g})=>{let v=g.groupname?g.groupname:g.name;return Te__default.createElement(Ae.getFormComponent(u,g),{key:"key_"+f,context:{params:m.params,displayButtonLoader:m.displayButtonLoader,doValidateForm:m.doValidateForm,redrawComponent:m.redrawComponent,formDimension:m.formDimension,segmentDimensions:{minWidth:parseInt(p.minWidth)},tabIndex:m.tabIndex,formData:u.displayName==="_Fileuploader"||u.displayName==="_Label"||u.displayName==="_View"||u.displayName==="_Textinput"&&g.inputtype==="currency"?m.formData:[]},id:f,methodProvider:s,panelId:r,properties:{...g,visible:b!==void 0&&b.visibility[v]!==void 0?b.visibility[v]:g.visible,readonly:b!==void 0&&b.readonly[v]!==void 0?b.readonly[v]:g.readonly},rowId:a,segmentId:d,segmentsCount:l,tabId:n,value:m.formData!==void 0?m.formData[v]:void 0,fieldAllowedValues:m!=null&&m.fieldAllowedValues?m.fieldAllowedValues[v]:void 0,validationMessage:m!=null&&m.formValidationData&&m.formValidationData[v]!==void 0?m.formValidationData[v]:null},null)}))}));Un.displayName="_Rowsegment";var Gn=Un;function Or(t,e){return {id:t,value:e}}var $n=withTranslation()(memo(function(e){var _;let n$1=useRef(null),{datalength:r,id:a,forcereadonly:d,ignorereadonly:l,label:c,name:s,onchangehandler:m,placeholder:b$1,readonly:F,regex:p,searchbar:f,size:u,style:g,tabIndex:v,uppercasemode:w,variant:M,visible:x}=e.properties,R=useLocation(),{viewPort:O}=b(),{tabId:L}=e,[C,I]=useState(String((_=e.value)!=null?_:"")),[h,J]=Te__default.useState([]),Z=!!(C.trim()===""&&e.validationMessage!=null&&e.context.doValidateForm);useEffect(()=>{var D;I(String((D=e.value)!=null?D:""));},[e.value]),useEffect(()=>{let D=[];if(e.fieldAllowedValues){for(let H in e.fieldAllowedValues)D.push(Or(H,e.fieldAllowedValues[H]));J(D);}},[e.fieldAllowedValues]);let ee=D=>{var H;e.methodProvider.eventDispatcher({widgetName:s,widgetValue:D,widgetEvent:m?U.onChange:null,widgetContext:JSON.stringify({referer:R.pathname,parentWidgetId:L,hasParentForm:T.hasParentForm(),originator:(H=e.context.params)==null?void 0:H.originator})});},T$1=D=>{I(D);};return jsx(n,{autoFocus:false,data:h,disabled:!!(F&&!l),error:Z,helperText:Z?e.validationMessage:"",id:a,inputProps:{id:a,tabIndex:v,style:{...g},autoComplete:nanoid(5)},InputProps:{},inputRef:n$1,label:c,maxCharCount:r,name:s,onBlur:D=>{ee(D.target.value);},onInput:D=>{T$1(D.target.value),O.isMobileDevice&&ee(D.currentTarget.value);},onChange:D=>{C.trim()===""&&ee(D.target.value);},placeholder:b$1,readOnly:!!(F&&!l),regEx:p,searchBar:f,size:u!=null?u:"small",type:"text",inputtype:e.properties.inputType,toUpperCase:w,value:C,variant:M,visible:x})}));$n.displayName="_Input";var qn=$n;var jn=withTranslation()(memo(function(e){var D;let n$1=useRef(null),{datalength:r,id:a,forcereadonly:d,ignorereadonly:l,label:c,name:s,onchangehandler:m,placeholder:b$1,readonly:F,regex:p,size:f,style:u,tabIndex:g,uppercasemode:v,variant:w,visible:M}=e.properties,x=useLocation(),{viewPort:R}=b(),{tabId:O}=e,[L,C]=useState(String((D=e.value)!=null?D:"")),I=!!(L.trim()===""&&e.validationMessage!=null&&e.context.doValidateForm),[h,J]=useState(false),{t:Z}=useTranslation(),ee=()=>{navigator.clipboard.writeText(L).then(()=>{J(true),setTimeout(()=>J(false),2e4);});};useEffect(()=>{var H;C(String((H=e.value)!=null?H:""));},[e.value]);let T$1=H=>{var j;e.methodProvider.eventDispatcher({widgetName:s,widgetValue:H,widgetEvent:m?U.onChange:null,widgetContext:JSON.stringify({referer:x.pathname,parentWidgetId:O,hasParentForm:T.hasParentForm(),originator:(j=e.context.params)==null?void 0:j.originator})});},_=H=>{C(H);};return jsxs(ja,{display:"flex",alignItems:"flex-start",gap:0,children:[jsx(n,{autoFocus:false,disabled:!!(F&&!l),error:I,helperText:I?e.validationMessage:"",id:a,inputProps:{id:a,tabIndex:g,style:{...u},autoComplete:nanoid(5)},InputProps:{},inputRef:n$1,label:c,maxCharCount:r,name:s,onBlur:H=>{T$1(H.target.value);},onInput:H=>{_(H.target.value),R.isMobileDevice&&T$1(H.currentTarget.value);},onChange:H=>{L.trim()===""&&T$1(H.target.value);},placeholder:b$1,readOnly:!!(F&&!l),regEx:p,size:f,type:"text",inputtype:e.properties.inputType,toUpperCase:v,value:L,variant:w,visible:M}),M&&jsx(Kr,{title:Z(h?"copied!":"copy to clipboard"),children:jsx(Qr,{variant:"contained",style:{backgroundColor:"#C0C0C0",borderRadius:"0px 4px 4px 0px",boxShadow:"none",marginLeft:"-3px",border:"2px solid #C0C0C0",lineHeight:"24px",fontSize:"11px"},onClick:ee,startIcon:jsx(i,{}),children:Z("copy")})})]})}));jn.displayName="_InputWCopy";var Qn=jn;var Xn=withTranslation()(memo(function(e){useRef(null);let {tabId:r,id:a,context:d,widgetsState:l}=e,c=e.methodProvider.findWidgetItem(a),s=e.methodProvider.getActiveTabIndex(r,a),m=(p,f,u,g)=>{f||(p.target.style.background=g,p.target.style.color=u);},b=(p,f,u,g)=>{f||(p.target.style.background=g,p.target.style.color=u);},F=({children:p,...f})=>jsx(A,{onPointerUp:u=>u.stopPropagation(),onMouseOver:u=>m(u,f.selected,f.item_active_color,f.item_active_background_color),onMouseOut:u=>b(u,f.selected,f.item_default_color,f.item_default_background_color),style:{borderRadius:"5px 5px 0 0",marginRight:"1px",color:f.selected?f.item_active_color:f.item_default_color,background:f.selected?f.item_active_background_color:f.item_default_background_color,fontSize:f.item_fontsize,fontWeight:f.item_fontweight},selected:f.selected,children:p},f.id);return F.tabsRole="Tab",e.properties.visible?Te__default.createElement("div",{className:"form-tab-widget"},jsxs(y,{selectedIndex:s,onSelect:p=>e.methodProvider.setActiveTabIndex(r,a,p),children:[jsx(z,{children:(c.item._children||[]).map(({properties:p},f)=>!p.item_visible||l&&l.visibility&&l.visibility[p.item_name]===false?null:createElement(F,{...c.item.properties.tabsetup,...p,key:"TabCaptionComponent_"+a+"_"+f},p.item_title))}),(c.item._children||[]).map(({_children:p},f)=>jsx(B,{children:(p||[]).map(({tabId:u,panelId:g,id:v,type:w,component:M,properties:x},R)=>Te__default.createElement(Ae.getFormComponent(M,x),{key:"tabSubPanel_"+R,id:v,tabId:u,panelId:g,properties:{...x,visible:l!==void 0&&l.visibility[x.name]!==void 0?l.visibility[x.name]:x.visible,readonly:l!==void 0&&l.readonly[x.name]!==void 0?l.readonly[x.name]:x.readonly},className:w,widgetsState:l,methodProvider:e.methodProvider,context:{...d},segmentsCount:c.item._children.length,fieldAllowedValues:d!=null&&d.fieldAllowedValues?d.fieldAllowedValues[x.name]:void 0},null))},"TabPanel_"+a+"_"+f))]})):null}));Xn.displayName="_TabBox";var Yn=Xn;function ri(t,e){if(!e||Array.isArray(e)&&e.length===0)return t;let n=e;return t.replace(/<b>@(\w+)<\/b>|@(\w+)/g,(r,a,d)=>{let l=(a||d).toLowerCase(),c=n[l];return typeof c=="string"?a?`<b>${c}</b>`:c:r})}var ea=withTranslation()(memo(function(e){let{title:n,style:r,verticalalign:a,visible:d}=e.properties,l={paddingTop:"0px"};if(a==="bottom"&&(l.paddingTop="10px"),!d)return null;let c=ri(n,e.context.formData);return jsx("div",{style:{...r,...l},children:jsx("div",{style:{...r},dangerouslySetInnerHTML:{__html:c}})})}));ea.displayName="_Label";var ta=ea;var na=withTranslation()(memo(function(e$1){let n=useRef(null),{defaultvalue:r,id:a,ignorereadonly:d,label:l,labelplacement:c,name:s,onchangehandler:m,readonly:b,style:F,tabIndex:p,visible:f}=e$1.properties,u=s,g=e$1.value||"",v=useLocation(),{tabId:w}=e$1,M=!!(!g&&e$1.validationMessage!=null&&e$1.context.doValidateForm);return useEffect(()=>{!e$1.value&&r&&e$1.methodProvider.eventDispatcher({widgetName:u,widgetValue:e$1.properties.value,widgetEvent:null,widgetContext:JSON.stringify({referer:v.pathname,parentWidgetId:w,hasParentForm:T.hasParentForm()})});},[]),jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:F.textAlign,height:"100%"},children:jsx(e,{checkedIcon:void 0,defaultChecked:!!(e$1.value===void 0&&r),disabled:!!(b&&!d),error:M,helperText:M?e$1.validationMessage:"",icon:void 0,inputProps:{id:a,tabIndex:p},inputRef:n,labelText:l,labelPlacement:c,name:u,onChange:x=>{e$1.methodProvider.eventDispatcher({widgetName:u,widgetValue:x.target.checked?e$1.properties.value:"",widgetEvent:m?U.onChange:null,widgetContext:JSON.stringify({referer:v.pathname,parentWidgetId:w,hasParentForm:T.hasParentForm()})});},selectedValue:g,value:e$1.properties.value,visible:f})})}));na.displayName="_Checkbox";var aa=na;var ia=withTranslation()(memo(function(e){let n=useRef(null),{defaultvalue:r,groupname:a,id:d,ignorereadonly:l,label:c,labelplacement:s,name:m,onchangehandler:b,readonly:F,style:p,tabIndex:f,visible:u}=e.properties,g=useLocation(),{tabId:v}=e;useEffect(()=>{!x&&r&&O(e.properties.value);},[]);let w=a||m;let x=e.value||"",R=!!(e.validationMessage!=null&&e.context.doValidateForm),O=L=>{var C;e.methodProvider.eventDispatcher({widgetName:w,widgetValue:L,widgetEvent:b?U.onChange:null,widgetContext:JSON.stringify({referer:g.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),originator:(C=e.context.params)==null?void 0:C.originator})});};return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:p.textAlign,height:"100%"},children:jsx(k,{defaultValue:r?e.properties.value:"",disabled:!!(F&&!l),inputProps:{id:d,tabIndex:f,style:{...p}},error:R,helperText:R?e.validationMessage:"",inputRef:n,labelText:c,labelPlacement:s,name:w,onChange:L=>{x!==L.target.value.trim()&&O(L.target.value);},selectedValue:x,value:e.properties.value,visible:u})})}));ia.displayName="_Radio";var la=ia;var da=withTranslation()(memo(function(e){var ee;let n$1=useRef(null),{runFormEvent:r,viewPort:a}=b(),{id:d,autocompleteTextArea:l,ignorereadonly:c,label:s,name:m,onchangehandler:b$1,placeholder:F,required:p,requiredmessage:f,readonly:u,size:g,style:v,tabIndex:w,variant:M,visible:x}=e.properties,R=useLocation(),{tabId:O}=e,[L,C]=useState(String((ee=e.value)!=null?ee:""));useEffect(()=>{var T;C(String((T=e.value)!=null?T:""));},[e.value]);let I=!!(L.trim()===""&&e.validationMessage!=null&&e.context.doValidateForm),h=T$1=>{var _;e.methodProvider.eventDispatcher({widgetName:m,widgetValue:T$1,widgetEvent:b$1?U.onChange:null,widgetContext:JSON.stringify({referer:R.pathname,parentWidgetId:O,hasParentForm:T.hasParentForm(),originator:(_=e.context.params)==null?void 0:_.originator})});},J=async T=>{var _,D,H;try{let j=await r({pluginCode:e.context.params.pluginCode,formCode:e.context.params.formCode,guid:e.context.params.guid,projectGuid:e.context.params.pGuid,pGuid:e.context.params.pGuid,formData:(_=e.context.formData)!=null?_:{},widgetContext:JSON.stringify({}),widgetEvent:U.onGetCustomResponse,widgetName:m,widgetValue:JSON.stringify({methodName:"getAutoCompleteData",value:T})});if(((D=j.meta)==null?void 0:D.requestStatus)==="fulfilled"){let B=j.payload,S=(H=B==null?void 0:B.FECommand)==null?void 0:H.CustomResponse;if(Array.isArray(S))return S.filter(G=>typeof G=="string").map(G=>({label:G}))}}catch(j){}return []},Z=T=>{C(T);};return jsx(n,{autocompleteTextArea:l,autoFocus:false,disabled:!!(u&&!c),id:d,inputProps:{id:d,tabIndex:w,readOnly:!!(u&&!c),style:{...v}},error:I,helperText:I?e.validationMessage:"",InputProps:{},inputRef:n$1,label:s,multiline:true,name:m,onAutoCompleteChange:l?T=>J(T):void 0,onBlur:T=>{h(T.target.value);},onInput:T=>{Z(T.target.value),a.isMobileDevice&&h(T.currentTarget.value);},onChange:T=>{L.trim()===""&&h(T.target.value);},placeholder:F,readOnly:!!(u&&!c),size:g,type:"text",value:L,variant:M,visible:x})}));da.displayName="_Textarea";var sa=da;function ma(t,e){return {id:t,value:e}}var Ot="\xA4",ca=withTranslation()(memo(function(e){var D,H;let n=useRef(null),[r,a]=Te__default.useState(null),[d,l$1]=Te__default.useState([]),c=typeof e.value=="string"&&e.value!=null&&e.value.length>0?e.value.split(Ot):[],[s,m]=Te__default.useState(c),{id:b,ignorereadonly:F,label:p,multiple:f,name:u,onchangehandler:g,placeholder:v,readonly:w,rendertype:M,searchbar:x,size:R,tabIndex:O,variant:L,visible:C,dropvalues:I}=e.properties,h=useLocation(),{tabId:J}=e,{t:Z}=useTranslation();useEffect(()=>{let j=typeof e.value=="string"&&e.value!=null&&e.value.length>0?e.value.split(Ot):[];m(j);},[e.value]),useEffect(()=>{let j=M==="none"?[{id:"",value:""}]:[];if(e.fieldAllowedValues&&Object.keys(e.fieldAllowedValues).length>0){for(let B in e.fieldAllowedValues)j.push(ma(B,e.fieldAllowedValues[B]));l$1(j);}else if(I&&Array.isArray(I)&&I.length>0){for(let B of I)typeof B=="object"&&B!==null&&j.push(ma(B.id||"",B.value||""));l$1(j);}},[e.fieldAllowedValues,I]),useEffect(()=>{var j;if(r===false){let B=typeof e.value!="string"?e.value:[];(JSON.stringify(B)!==JSON.stringify(s)||s.length===0)&&e.methodProvider.eventDispatcher({widgetName:u,widgetValue:s.length>0?s.join(Ot):[],widgetEvent:g?U.onChange:null,widgetContext:JSON.stringify({referer:h.pathname,parentWidgetId:J,hasParentForm:T.hasParentForm(),originator:(j=e.context.params)==null?void 0:j.originator,folderData:e.context.params.folderData})});}},[r]);let ee=j=>{let{target:{value:B}}=j,S;f?S=typeof B=="string"?B.split(","):B:S=typeof B=="string"?[B]:B,m(S);},T$1=e.context.formDimension.width/e.segmentsCount;T$1=T$1<e.context.segmentDimensions.minWidth?e.context.segmentDimensions.minWidth:T$1-60;let _=!!(s.length===0&&e.validationMessage!=null&&e.context.doValidateForm);return jsx(l,{darkMode:false,data:d,error:_,helperText:_?e.validationMessage:"",inputProps:{tabIndex:O,style:{maxWidth:`${T$1}px`}},inputRef:n,onOpen:()=>{a(true);},onClose:()=>{a(false);},onChange:ee,id:b,label:p,multiple:f,placeholder:v,readOnly:w&&!F,renderType:M,noOptionsText:(H=(D=e.properties)==null?void 0:D.noOptionsLabel)!=null?H:Z("No options"),searchBar:x,selectDisplayProps:{style:{maxWidth:"100%",whiteSpace:M==="chip"?"normal":"nowrap"}},selectedValue:s,size:R,variant:L,width:"auto",visible:C})}));ca.displayName="_SelectBox";var ua=ca;var fa=withTranslation()(memo(function(e){var c;let{style:n,visible:r}=(c=e.properties)!=null?c:{},[a,d]=useState(false);if(useEffect(()=>{d(true);},[]),!a)return null;let l="form-widget form-placeholder-widget";return r||(l+=" visibilityOff"),jsx("div",{className:l,style:{...n,display:"flex",alignItems:"center",justifyContent:"center",width:"100%",textAlign:"center"}})}));fa.displayName="_Placeholder";var pa=fa;var ga=createContext({});function ha(){return useContext(ga)}var ba=ga;var $i=lazy(()=>import('./fileviewer-24IMJQQY.js'));function qi(){let[,t]=useState(0);return ()=>t(e=>e+1)}var xa=withTranslation()(memo(function(e){var we,ge;qi();let [r,a]=useState([]),[d,l]=useState(e.context.params),[c,s]=useState(false),[m,b$3]=useState(null),[F,p$1]=useState(false),[f$1,u]=useState(null),[g$1,v]=useState(0),{t:w}=useTranslation(),{iframeMode:M}=g(),x=ha(),R=W=>{var K;return (K=x[W])!=null?K:w(W)},{UserDialog:O}=b$1(),L=f(),{style:C,readonly:I,visible:h}=e.properties,[J,Z]=useState({showDialog:false,dialogTitle:"",dialogContent:"",buttonAgree:"",buttonDisagree:"",callBackFunc:()=>{}}),{appSettings:ee,viewPort:T$1,runFormDeleteFileEvent:_,runFormDownloadFileEvent:D,runFormGetLinkedFileEvent:H,runFormGetLinkedFileMetaEvent:j,runFormUploadFiles:B}=b();useEffect(()=>{l(e.context.params);},[e.context.params]),useEffect(()=>{let W=e.value?JSON.parse(e.value):[];return W&&(a(S(W,100)),s(true)),()=>{r&&(s(false),r.forEach(K=>{K.preview&&URL.revokeObjectURL(K.preview);}));}},[]);let S=(W,K)=>{let E=[];return W.forEach((z,o)=>{let te=new File([],z,{type:"image/jpeg"});Object.assign(te,{preview:null,uploadProgress:K}),E.push(te);}),E},G=useCallback(async W=>{var ie;let E=(await j({...d,projectGuid:e.context.params.pGuid,fieldName:e.properties.name,fileId:W,context:{action:"Preview"}})).payload,{linkedFileSize:z,linkedFileName:o,mimeType:te}=E;if(!z)throw new Error("File data or metadata is missing");let oe=(ie=ee==null?void 0:ee.MAX_DOWNLOAD_NOCHUNK_FILESIZE)!=null?ie:b$2.MAX_DOWNLOAD_NOCHUNK_FILESIZE;return z>oe?{type:"formbuilder/getlinkedfile",payload:{linkedFile:null,linkedFileSize:z,linkedFileName:o},meta:{requestStatus:"fulfilled"}}:await H({...d,projectGuid:e.context.params.pGuid,fieldName:e.properties.name,fileId:W,context:{action:"Load"}})},[d,e.context.params.pGuid,e.properties.name]),re=W=>{J.callBackFunc(W);},pe=async(W,K)=>{W&&await _({...e.context.params,projectGuid:e.context.params.pGuid,fieldName:e.properties.name,fileId:K}).then(E=>{if(E.meta.requestStatus==="fulfilled"){let z={...E.payload};z.linkedFileDeleteSuccess&&(L({toastID:nanoid(11),msg:R("The file has been successfully deleted"),clearQueue:false,hideProgressBar:false}),a(o=>o.filter(te=>te.name!==K)),e.methodProvider.eventDispatcher({widgetName:e.properties.name,widgetValue:JSON.stringify(z.linkedFiles),widgetEvent:null,widgetContext:null}));}}),Z({...J,showDialog:false,callBackFunc:E=>{}});},ye=async W=>{if(W)try{let K=await D({...e.context.params,projectGuid:e.context.params.pGuid,fieldName:e.properties.name,fileId:W}),E=new Blob([K]),z=window.URL.createObjectURL(E),o=document.createElement("a");o.href=z,o.setAttribute("download",W.split("/").pop()||"downloadedFile"),document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(z);}catch(K){}},se=useCallback(async(W,K)=>(K&&Z({showDialog:true,dialogTitle:R("Confirmation"),dialogContent:R("Are you sure you want to delete file?"),buttonAgree:R("Continue"),buttonDisagree:R("Close"),callBackFunc:E=>pe(E,K)}),null),[e.context.params,w]),A=useCallback(async(W,K)=>(K&&ye(K),null),[e.context.params]),ce=useCallback((W,K)=>{K&&startTransition(()=>{b$3(K);});},[]),Q=()=>{b$3(null);},ue=useCallback(async(W,K)=>{var E,z;if(W){let o=new FormData;for(let ie in e.context.params)e.context.params.hasOwnProperty(ie)&&o.append(ie,e.context.params[ie]);o.append("fieldName",e.properties.name),W.forEach(ie=>{o.append("files",ie);}),o.append("widgetContext",JSON.stringify({hasParentForm:T.hasParentForm(),originator:(E=e.context.params)==null?void 0:E.originator,folderData:(z=e.context.params)==null?void 0:z.folderData})),o.append("widgetEvent",U.onFileUploadEvent),o.append("widgetName",e.properties.name),o.append("formData",JSON.stringify({...e.context.formData}));let te=_i.CancelToken.source(),oe=W.map(ie=>Object.assign(ie,{preview:URL.createObjectURL(ie),uploadProgress:0}));a(r.concat(oe)),u(0),await B({content:o,cancelTokenSource:te,onUploadProgress:ie=>{let Ne=ie.total?Math.round(ie.loaded*100/ie.total):0;u(Ne);}}).then(ie=>{var ze,Ke,Ve;let Ne=[];if(ie.meta.requestStatus==="fulfilled"){let xe={...ie.payload};if((ze=xe.FECommand)!=null&&ze.FormValidationData&&Object.keys(xe.FECommand.FormValidationData).length>0){oe.forEach(Ce=>{Ce.preview&&URL.revokeObjectURL(Ce.preview);}),u(null),v(Ce=>Ce+1);let tt=r.filter(Ce=>Ce.uploadProgress===100);a(tt),e.methodProvider.eventDispatcher({widgetName:e.properties.name,widgetValue:JSON.stringify(r),widgetEvent:null,widgetContext:null,feCommand:xe.FECommand});}else if(xe.linkedFiles&&e.properties.name){Ne=S(xe.linkedFiles,100);let tt=Ne.map(Ce=>{let rt=Ce;return rt.uploadProgress=100,rt.preview=null,rt});oe.forEach(Ce=>{Ce.preview&&URL.revokeObjectURL(Ce.preview);}),u(null),v(Ce=>Ce+1),a(tt),l({...e.context.params,guid:(Ve=(Ke=xe.FECommand)==null?void 0:Ke.ReplaceContextRecordGuid)==null?void 0:Ve.guid}),xe.FECommand={...xe.FECommand,UpdateFieldAllowedValues:xe.fieldAllowedValues,UpdateFormData:xe.data},e.methodProvider.execCommands(xe.FECommand);}}});}},[r,e.context.params,e.methodProvider,e.properties.name,e.value]);return !c||!h?null:jsxs("div",{style:{...C,lineHeight:"1.1em"},children:[jsx(O,{...J,handleDialogClose:re}),jsxs("div",{style:{position:"relative",zIndex:1,isolation:"isolate"},children:[M&&jsx("div",{style:{position:"absolute",inset:0,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(255,255,255,0.85)",borderRadius:4,padding:"8px 16px",textAlign:"center",fontSize:"0.875rem",color:"#555"},children:w("File upload is available only when using the SDK")}),jsx(p,{defaultText:(ge=(we=e.properties)==null?void 0:we.dragDropLabel)!=null?ge:R("Drag and Drop..."),tryGetLinkedFile:G,onDeleteButtonPress:se,onDownloadButtonPress:A,onDownloadText:R("Download"),onDeleteText:R("Delete"),filesData:r,onDragText:"On drop text",onFilesDrop:ue,onPreviewButtonPress:ce,isMobileDevice:T$1.isMobileDevice,isReadonly:I},g$1),f$1!==null&&jsx(zi,{variant:"determinate",value:f$1,style:{marginTop:6,borderRadius:3,height:8}})]}),m!=null&&jsx(Suspense,{fallback:jsx(Gi,{}),children:jsx($i,{fileId:m,fileBase64:null,fieldName:e.properties.name,params:{...e.context.params,modalCloseFn:Q}},nanoid(11))})]})}));xa.displayName="_Fileuploader";var Ca=xa;var Ia=(t,e)=>"#"+t.replace(/^#/,"").replace(/../g,n=>("0"+Math.min(255,Math.max(0,parseInt(n,16)+e)).toString(16)).substring(-2)),Ta=withTranslation()(memo(function(e){var w,M;let{buttontype:n,colorSchema:r,fullWidth:a,name:d,style:l,tabIndex:c,title:s,variant:m,visible:b}=e.properties,F=useLocation(),{tabId:p}=e,f=(M=(w=e.context)==null?void 0:w.displayButtonLoader)!=null?M:false;if(!b)return null;let u=l.backgroundColor,g=u?Ia(u,-50):"";r&&(u=r+".main",g=r+".hover");let v={};return m==="outlined"?(Object.assign(v,{"&.MuiButtonBase-root":{fontSize:l.fontSize,fontWeight:l.fontWeight,border:"1px solid"+u,cursor:"pointer"}}),Object.assign(v,{"&.MuiButtonBase-root:hover":{border:g?"1px solid"+Ia(g,-50):""}})):(Object.assign(v,{"&.MuiButtonBase-root":{fontSize:l.fontSize,fontWeight:l.fontWeight,backgroundColor:u,cursor:"pointer"}}),Object.assign(v,{"&.MuiButtonBase-root:hover":{backgroundColor:g}})),jsx("div",{children:jsx(o,{variant:m,label:s,loading:f,onPointerUp:()=>{var x,R;e.methodProvider.eventDispatcher({widgetName:d,widgetValue:null,widgetEvent:U.getFormButtonEvent(n),widgetContext:JSON.stringify({referer:F.pathname,parentWidgetId:p,hasParentForm:T.hasParentForm(),originator:(x=e.context.params)==null?void 0:x.originator,parent:{widgetName:d,params:{pGuid:e.context.params.pGuid,pluginCode:e.context.params.pluginCode,formCode:e.context.params.formCode,guid:e.context.params.guid}},folderData:(R=e.context.params)==null?void 0:R.folderData})});},fullWidth:a,sx:v,tabIndex:c})})}));Ta.displayName="_Button";var Da=Ta;var Pa=withTranslation()(memo(function(e){var R,O,L;let n=useRef(null),{id:r,ignorereadonly:a,defaultvalue:d,dateformat:l,label:c,name:s,onchangehandler:m,readonly:b,size:F,tabIndex:p,variant:f,visible:u}=e.properties,g=useLocation(),{tabId:v}=e,w=!!(!e.value&&e.validationMessage!=null&&e.context.doValidateForm),M=C=>{var I;return e.methodProvider.eventDispatcher({widgetName:s,widgetValue:C!=null?C:"",widgetEvent:m?U.onChange:null,widgetContext:JSON.stringify({referer:g.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),originator:(I=e.context.params)==null?void 0:I.originator})})},x=(O=(R=e==null?void 0:e.i18n)==null?void 0:R.language)==null?void 0:O.substr(0,2);return jsx(f$1,{id:r,defaultvalue:d,disabled:!!(b&&!a),error:w,format:l!==void 0&&l!==""&&l!=null?l:void 0,helperText:w?e.validationMessage:"",inputRef:n,label:c,locale:x,name:s,onBlur:C=>{M(C?a$1(C).utc().format():null);},size:F,type:"datepicker",value:(L=e.value)!=null?L:"",variant:f,visible:u})}));Pa.displayName="_Textinput";var Ra=Pa;var Ea=withTranslation()(memo(function(e){var L,C,I;let n=useRef(null),{id:r,ignorereadonly:a,defaultvalue:d,dateformat:l,label:c,name:s,onchangehandler:m,readonly:b,size:F,tabIndex:p,variant:f,visible:u}=e.properties,g=useLocation(),{tabId:v}=e,[w,M]=useState(String((L=e.value)!=null?L:"")),x=!!(!w&&e.validationMessage!=null&&e.context.doValidateForm);useEffect(()=>{var h;M(String((h=e.value)!=null?h:""));},[e.value]);let R=h=>{var J;return M(h),e.methodProvider.eventDispatcher({widgetName:s,widgetValue:h!=null?h:"",widgetEvent:m?U.onChange:null,widgetContext:JSON.stringify({referer:g.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),originator:(J=e.context.params)==null?void 0:J.originator})})};useEffect(()=>{if(!e.value&&d){let h=d==="now"?a$1().utc().format():d==="start of day"?a$1().startOf("day").utc().format():null;h&&R(h);}},[]);let O=(I=(C=e==null?void 0:e.i18n)==null?void 0:C.language)==null?void 0:I.substr(0,2);return jsx(g$1,{autoFocus:false,defaultvalue:d,disabled:!!(b&&!a),error:x,format:l!==void 0&&l!==""&&l!=null?l:void 0,helperText:x?e.validationMessage:"",id:r,inputRef:n,label:c,locale:O,name:s,onChange:h=>{R(h?a$1(h).utc().format():null);},size:F,value:w,variant:f,visible:u})}));Ea.displayName="_Textinput";var ka=Ea;var Ma=withTranslation()(memo(function(e){var R,O,L;let n=useRef(null),{id:r,ignorereadonly:a,defaultvalue:d,dateformat:l,label:c,name:s,onchangehandler:m,readonly:b,size:F,tabIndex:p,variant:f,visible:u}=e.properties,g=useLocation(),{tabId:v}=e,w=!!(!e.value&&e.validationMessage!=null&&e.context.doValidateForm),M=C=>{var I;return e.methodProvider.eventDispatcher({widgetName:s,widgetValue:C!=null?C:"",widgetEvent:m?U.onChange:null,widgetContext:JSON.stringify({referer:g.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),originator:(I=e.context.params)==null?void 0:I.originator})})},x=(O=(R=e==null?void 0:e.i18n)==null?void 0:R.language)==null?void 0:O.substr(0,2);return jsx(h,{id:r,defaultvalue:d,disabled:!!(b&&!a),error:w,format:l!==void 0&&l!==""&&l!=null?l:void 0,helperText:w?e.validationMessage:"",inputRef:n,label:c,locale:x,name:s,onBlur:C=>{M(C?a$1(C).utc().format():null);},size:F,type:"datetimepicker",value:(L=e.value)!=null?L:"",variant:f,visible:u})}));Ma.displayName="_Textinput";var Ba=Ma;var Na=withTranslation()(memo(function(e){var T$1;let n$1=useRef(null),{datalength:r,id:a,forcereadonly:d,ignorereadonly:l,label:c,name:s,onchangehandler:m,placeholder:b$1,phoneformat:F,readonly:p,regex:f,size:u,style:g,tabIndex:v,uppercasemode:w,variant:M,visible:x}=e.properties,R=useLocation(),{i18n:O}=useTranslation(),{viewPort:L}=b(),{tabId:C}=e,[I,h]=useState(String((T$1=e.value)!=null?T$1:"")),J=!!(e.validationMessage!=null&&e.context.doValidateForm);useEffect(()=>{e.value!==void 0&&e.value!==null&&h(String(e.value));},[e.value]);let Z=_=>{var D;e.methodProvider.eventDispatcher({widgetName:s,widgetValue:_,widgetEvent:m?U.onChange:null,widgetContext:JSON.stringify({referer:R.pathname,parentWidgetId:C,hasParentForm:T.hasParentForm(),originator:(D=e.context.params)==null?void 0:D.originator})});},ee=_=>{h(_);};return jsx(n,{autoFocus:false,disabled:!!(p&&!l),error:J,helperText:J?e.validationMessage:"",id:a,inputProps:{id:a,tabIndex:v,style:{...g}},InputProps:{},inputRef:n$1,label:c,maxCharCount:r,name:s,onBlur:_=>{Z(_.target.value);},onInput:_=>{ee(_.target.value),L.isMobileDevice&&Z(_.currentTarget.value);},placeholder:b$1,locale:O==null?void 0:O.language,phoneFormat:F||void 0,readOnly:!!(p&&!l),regEx:f,size:u!=null?u:"small",type:F?"phone":"text",toUpperCase:w,value:I,variant:M,visible:x})}));Na.displayName="_PhoneInput";var La=Na;var Va=withTranslation()(memo(function(e){var ce;let n$1=useRef(null),{t:r,i18n:a}=useTranslation(),d=a==null?void 0:a.language,{currency_format:l,currency_assymbol:c,currency_currencydisplay:s,currency_fixedlocale:m,datalength:b$1,id:F,ignorereadonly:p,label:f,name:u,onchangehandler:g,placeholder:v,readonly:w,regex:M,size:x,style:R,tabIndex:O,uppercasemode:L,variant:C,visible:I}=e.properties,h=useLocation(),{viewPort:J}=b(),{tabId:Z}=e,[ee,T$1]=useState(String((ce=e.value)!=null?ce:"0")),[_,D]=useState(false),[H,j]=useState(0),B=useRef(0);useEffect(()=>{var Q;T$1(String((Q=e.value)!=null?Q:"0"));},[e.value]),useEffect(()=>{e.validationMessage!=null&&(B.current+=1,D(false));},[e.context.formValidationData]);let S=!!(!_&&e.validationMessage!=null&&e.context.doValidateForm),G=Q=>{var ue;e.methodProvider.eventDispatcher({widgetName:u,widgetValue:Q,widgetEvent:g?U.onChange:null,widgetContext:JSON.stringify({referer:h.pathname,parentWidgetId:Z,hasParentForm:T.hasParentForm(),originator:(ue=e.context.params)==null?void 0:ue.originator})});},re=Q=>{T$1(Q);},pe=l==="fixed-locale"&&m?m:d,ye=()=>{var we;if(s==="")return "";let Q=e.context.formData,ue=e.properties.currency_inputfield;return ue&&(Q!=null&&Q[ue])?Q[ue]:e.properties.currency_currency?e.properties.currency_currency:(l==="locale"||l==="fixed-locale")&&(we=k$2(pe!=null?pe:""))!=null?we:""},se=s==="symbol"?true:s==="code"?false:c!=null?c:false,A=l==="locale"||l==="fixed-locale"?"locale":l!=null?l:"";return jsx(n,{autoFocus:false,currency:ye(),disabled:!!(w&&!p),error:S,helperText:S?e.validationMessage:"",id:F,inputProps:{id:F,tabIndex:O,style:{...R,textAlign:"right"}},InputProps:{},inputRef:n$1,label:f,locale:pe,maxCharCount:b$1,name:u,onBlur:Q=>{D(true);let ue=Q.target.value;(ue==="0"||ue==="")&&j(we=>we+1),G(ue);},onInput:Q=>{re(Q.target.value),J.isMobileDevice&&G(Q.currentTarget.value);},onChange:Q=>{ee.trim()===""&&G(Q.target.value);},placeholder:v,readOnly:!!(w&&!p),regEx:M,size:x,type:"currency",toUpperCase:L,value:ee,variant:C,visible:I,format:A,assymbol:se},H)}));Va.displayName="_CurrencyInput";var Oa=Va;var Wa=withTranslation()(memo(function(e){var j,B;let n$1=useRef(null),{t:r,i18n:a}=useTranslation(),d=(j=a==null?void 0:a.language)==null?void 0:j.substring(0,2),{datalength:l,id:c,forcereadonly:s,ignorereadonly:m,label:b$1,name:F,onchangehandler:p,placeholder:f,readonly:u,regex:g,size:v,style:w,tabIndex:M,uppercasemode:x,variant:R,visible:O}=e.properties,[L,C]=useState(false),{viewPort:I}=b(),h=useLocation(),{tabId:J}=e,[Z,ee]=useState(String((B=e.value)!=null?B:"")),T$1=!!(Z.trim()===""&&e.validationMessage!=null&&e.context.doValidateForm);useEffect(()=>{var S;ee(String((S=e.value)!=null?S:""));},[e.value]);let _=()=>{C(S=>!S);},D=S=>{var G;e.methodProvider.eventDispatcher({widgetName:F,widgetValue:S,widgetEvent:p?U.onChange:null,widgetContext:JSON.stringify({referer:h.pathname,parentWidgetId:J,hasParentForm:T.hasParentForm(),originator:(G=e.context.params)==null?void 0:G.originator})});},H=S=>{ee(S);};return jsx(n,{autoFocus:false,disabled:!!(u&&!m),error:T$1,helperText:T$1?e.validationMessage:"",id:c,inputProps:{id:c,tabIndex:M,style:{...w,textAlign:"center"}},InputProps:{endAdornment:jsx(Ml,{position:"end",children:jsx(lr,{onClick:_,edge:"end",children:L?jsx(Bl,{}):jsx(Nl,{})})})},inputRef:n$1,label:b$1,locale:d,maxCharCount:l,name:F,onBlur:S=>{D(S.target.value);},onInput:S=>{H(S.target.value),I.isMobileDevice&&D(S.currentTarget.value);},onChange:S=>{Z.trim()===""&&D(S.target.value);},placeholder:f,readOnly:!!(u&&!m),regEx:g,size:v,type:"text",toUpperCase:x,value:Z,variant:R,visible:O,inputtype:L?"text":"password"})}));Wa.displayName="_PasswordInput";var Ua=Wa;var $a=styled(TreeItem2Root)(({theme:t})=>({color:t.palette.mode==="light"?t.palette.grey[800]:t.palette.grey[400],position:"relative",[`& .${treeItemClasses.groupTransition}`]:{marginLeft:t.spacing(3.5)}})),Zl=styled(TreeItem2Content)(({theme:t})=>({borderRadius:t.spacing(.3),marginBottom:t.spacing(.5),marginTop:t.spacing(.3),padding:t.spacing(.3),paddingRight:t.spacing(.1),fontWeight:500,"&.Mui-expanded ":{"&:not(.Mui-focused, .Mui-selected, .Mui-selected.Mui-focused) .labelIcon":{color:t.palette.mode==="light"?t.palette.primary.main:t.palette.primary.dark},"&::before":{content:'""',display:"block",position:"absolute",left:"16px",top:"34px",height:"calc(100% - 36px)",width:"1.5px",backgroundColor:t.palette.mode==="light"?t.palette.grey[300]:t.palette.grey[700]}},"&:hover":{backgroundColor:alpha(t.palette.primary.main,.1),color:t.palette.mode==="light"?t.palette.primary.main:"white"},"&.Mui-focused, &.Mui-selected, &.Mui-selected.Mui-focused":{backgroundColor:t.palette.mode==="light"?t.palette.primary.main:t.palette.primary.dark,color:t.palette.primary.contrastText,fontWeight:700}})),ed=styled(TreeItem2Content)(({theme:t})=>({borderRadius:t.spacing(.3),marginBottom:t.spacing(.5),marginTop:t.spacing(.3),padding:t.spacing(.3),paddingRight:t.spacing(.1),fontWeight:500,"&.Mui-expanded ":{"&:not(.Mui-focused, .Mui-selected, .Mui-selected.Mui-focused) .labelIcon":{},"&::before":{content:'""',display:"block",position:"absolute",left:"16px",top:"34px",height:"calc(100% - 36px)",width:"1.5px"}}})),td=animated(Vl);function qa(t){let e=useSpring({to:{opacity:t.in?1:0,transform:`translate3d(0,${t.in?0:20}px,0)`}});return jsx(td,{style:e,...t})}var od=styled(Ol)({color:"inherit",fontWeight:500});function Ja({icon:t,expandable:e,children:n,isFirstRootNode:r,...a}){return jsxs(TreeItem2Label,{...a,sx:{display:"flex",alignItems:"center",fontWeight:r?"700":"normal",backgroundColor:"transparent","&.Mui-focused, &.Mui-selected":{backgroundColor:"transparent"}},children:[t&&jsx(ja,{component:t,className:"labelIcon",color:"inherit",sx:{mr:1,fontSize:"1.2rem"}}),jsx(od,{sx:{fontSize:r?"1rem":"0.9rem",fontWeight:r?"700":"normal"},children:n})]})}var Ka=t=>Array.isArray(t)?t.length>0&&t.some(Ka):!!t,Ct=t$1=>{let e=null,n=t$1.action,r=t$1.applyInternalStyle?{fontSize:"1em",marginRight:"0.5em"}:{};return n==="add"?e=jsx(t,{style:r}):n==="edit"?e=jsx(A$1,{style:r}):n==="share"?e=jsx(E,{style:r}):n==="trash"&&(e=jsx(N,{style:r})),e},nd=Te.forwardRef(function(e,n){let{id:r,itemId:a,label:d,disabled:l,children:c,item:s,index:m$1,mode:b$1,setSelectedItem:F,treeCheckedItems:p,properties:f,disableRootItem:u,userData:g,formData:v,deletePrompt:w,selectedItem:M,execCommands:x$1,eventDispatcher:R,...O}=e,{getRootProps:L,getContentProps:C,getIconContainerProps:I,getCheckboxProps:h,getLabelProps:J,getGroupTransitionProps:Z,getDragAndDropOverlayProps:ee,status:T$1}=unstable_useTreeItem2({id:r,itemId:a,children:c,label:d,disabled:l,rootRef:n}),_=useLocation(),{t:D}=useTranslation(),[H,j]=Te.useState(null),B=!!H,S=Ka(c),G=m$1===0?void 0:Hl,[re,pe]=Te.useState(T$1.expanded),{runFormEvent:ye}=b(),se=useCallback(async(E,z,o,te,oe,ie)=>{var Ne,ze,Ke;E&&await ye({pluginCode:o.params.pluginCode,formCode:"FOLDER",guid:(Ne=o.params.folderData)==null?void 0:Ne.id,projectGuid:o.params.pGuid,pGuid:o.params.pGuid,widgetContext:JSON.stringify({referer:oe.pathname,parentWidgetId:ie,hasParentForm:T.hasParentForm(),originator:(ze=o.params)==null?void 0:ze.originator,parent:o.params,folderData:(Ke=o.params)==null?void 0:Ke.folderData}),widgetEvent:U.onDelete,widgetName:"delete",formData:o.formData}).then(Ve=>{if(Ve.meta.requestStatus==="fulfilled"){let xe={...Ve.payload};o.execCommands(xe.FECommand);}}),o.deletePrompt({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[e.params.pluginCode,e.params.folderData,e.params.pGuid,e.formData,e.deletePrompt,e.execCommands]),A=E=>{E.stopPropagation(),pe(z=>!z);},ce=E=>{E.stopPropagation(),j(E.currentTarget);},Q=()=>{j(null);},ue=useCallback(()=>{Q();let E="addbtn";return e.eventDispatcher({tabIndex:0,widgetName:E,widgetValue:null,widgetEvent:U.onFolderCreateRecordEvent,widgetContext:JSON.stringify({referer:_.pathname,parentWidgetId:"",hasParentForm:T.hasParentForm(),parentOriginator:{params:e.params.originator?e.params.originator.params:{}},originator:{params:e.params,widgetName:E},parent:{widgetName:E,params:e.params},isModal:true,folderData:e.params.folderData})})},[Q,_.pathname,e.params,e.eventDispatcher,T.hasParentForm]),we=useCallback(()=>{Q();let E="share";return e.eventDispatcher({tabIndex:0,widgetName:E,widgetValue:null,widgetEvent:U.onFolderShareRecordEvent,widgetContext:JSON.stringify({referer:_.pathname,parentWidgetId:"",hasParentForm:T.hasParentForm(),parentOriginator:{params:e.params.originator?e.params.originator.params:{}},originator:{params:{...e.params,guid:e.params.folderData.id},widgetName:E},parent:{widgetName:E,params:e.params},isModal:true,folderData:e.params.folderData})})},[e,_.pathname]),ge=useCallback(()=>{Q();let E="edit";return e.eventDispatcher({tabIndex:0,widgetName:E,widgetValue:null,widgetEvent:U.onFolderEditRecordEvent,widgetContext:JSON.stringify({referer:_.pathname,parentWidgetId:"",hasParentForm:T.hasParentForm(),parentOriginator:{params:e.params.originator?e.params.originator.params:{}},originator:{params:e.params,widgetName:E},parent:{widgetName:E,params:e.params},isModal:true,folderData:e.params.folderData})})},[e,_.pathname]),W=useCallback(async E=>{var z,o;await ye({pluginCode:e.params.pluginCode,formCode:e.params.formCode,guid:e.params.guid,projectGuid:e.params.pGuid,pGuid:e.params.pGuid,widgetContext:JSON.stringify({referer:_.pathname,parentWidgetId:null,hasParentForm:T.hasParentForm(),originator:(z=e.params)==null?void 0:z.originator,parent:e.params,folderData:(o=e.params)==null?void 0:o.folderData}),widgetEvent:U.onRefresh,widgetName:f==null?void 0:f.name,widgetValue:E,formData:v}).then(te=>{if(te.meta.requestStatus==="fulfilled"){let oe={...te.payload};oe.FECommand={...oe.FECommand,UpdateFormData:oe.data},e.execCommands(oe.FECommand);}});},[e,f==null?void 0:f.name,_.pathname]),K=useCallback(()=>{e.deletePrompt({delete:{showDialog:true,dialogTitle:D("Delete")+" ?",dialogContent:D("Are you certain that you wish to delete this folder?"),buttonAgree:D("Continue"),buttonDisagree:D("Close"),callBackFunc:E=>{E?se(E,"delete",e,{},_,""):se(false,"",e,{},_,"");}}});},[e,D,_,se]);if(b$1==="live"){let E=g.rightMode!=="Edit";return jsxs($a,{...L(O),sx:{"& > ul":{paddingLeft:"0.2rem",paddingRight:"0.1rem"}},children:[jsxs(Zl,{...C({className:x("content",{"Mui-expanded":re,"Mui-selected":T$1.selected,"Mui-focused":T$1.focused,"Mui-disabled":T$1.disabled})}),children:[m$1!==0&&jsxs(Fragment,{children:[jsx(TreeItem2IconContainer,{...I({status:T$1,onPointerUp:A}),children:jsx(TreeItem2Icon,{status:T$1})}),jsx(TreeItem2Checkbox,{...h()})]}),jsx(Ja,{...J({icon:G,expandable:S&&re,isFirstRootNode:m$1===0,onClick:z=>{F&&F(z,a),z.stopPropagation();}}),children:d}),!E&&e.selectedItem===a&&m$1!==0&&jsx(lr,{size:"small",onClick:ce,"aria-controls":B?"menu":void 0,"aria-haspopup":"true","aria-expanded":B?"true":void 0,style:{marginLeft:"auto",color:"#FFF",fontSize:"14px"},children:jsx(m,{})}),jsxs(Ql,{anchorEl:H,open:B,onClose:Q,onClick:z=>z.stopPropagation(),slotProps:{paper:{sx:{minWidth:"12em"}}},children:[jsxs(xt,{onClick:ue,children:[jsx(yt,{children:jsx(Ct,{action:"add",applyInternalStyle:true})}),jsx(wt,{primaryTypographyProps:{fontSize:"0.875rem"},children:D("New Folder")})]}),jsxs(xt,{onClick:ge,children:[jsx(yt,{children:jsx(Ct,{action:"edit",applyInternalStyle:true})}),jsx(wt,{children:D("Settings")})]}),jsxs(xt,{onClick:we,children:[jsx(yt,{children:jsx(Ct,{action:"share",applyInternalStyle:true})}),jsx(wt,{children:D("Share")})]}),jsxs(xt,{onClick:K,children:[jsx(yt,{children:jsx(Ct,{action:"trash",applyInternalStyle:true})}),jsx(wt,{children:D("Delete")})]})]}),jsx(TreeItem2DragAndDropOverlay,{...ee()})]}),c&&jsx(qa,{...Z(),in:re,children:c})]})}else {let E=false;return p&&p.length>0&&p.forEach((z,o)=>{if(z===a){E=true;return}}),jsxs($a,{...L({...O,expandable:false}),sx:{"& > ul":{paddingLeft:"1rem",paddingRight:"0rem"}},children:[jsxs(ed,{...C({className:x("content",{"Mui-expanded":true,"Mui-selected":T$1.selected,"Mui-focused":T$1.focused,"Mui-disabled":T$1.disabled})}),children:[m$1!==0&&jsx(Fragment,{children:jsx(TreeItem2Checkbox,{id:a,visible:true,checked:E,onPointerUp:z=>W(a),onResize:void 0,onResizeCapture:void 0,popover:void 0,popoverTargetAction:void 0,popoverTarget:void 0,inert:void 0,onToggle:void 0,onBeforeToggle:void 0,onTransitionCancel:void 0,onTransitionCancelCapture:void 0,onTransitionRun:void 0,onTransitionRunCapture:void 0,onTransitionStart:void 0,onTransitionStartCapture:void 0})}),jsx(Ja,{...J({icon:G,expandable:S,isFirstRootNode:m$1===0}),children:d}),jsx(TreeItem2DragAndDropOverlay,{...ee()})]}),c&&jsx(qa,{...Z(),in:true,children:c})]})}}),ad=t=>{let e=[],n=r=>{r.forEach(a=>{a.children&&a.children.length>0&&(e.push(a.id),n(a.children));});};return n(t),e},rd=(t,e)=>{let n=(r,a)=>{for(let d of r)if(d.id===a||d.children&&n(d.children,a))return d;return null};return n(t,e)},id=(t,e)=>{let n=[],r=(a,d,l=[])=>{for(let c of a){if(c.id===d)return n.push(...l),true;if(c.children&&r(c.children,d,[...l,c]))return true}return false};return r(t,e),n},Wt=(t,e)=>{for(let n of t){if(n.id===e)return n;if(n.children){let r=Wt(n.children,e);if(r)return r}}return null},It=(t,e)=>{for(let n of t){if(n.id===e)return [n.label];if(n.children){let r=It(n.children,e);if(r.length>0)return [n.label,...r]}}return []},ld=({eventDispatcher:t,execCommands:e,params:n,properties:r,redrawComponent:a,formlayout:d,onFolderSelected:l,onFolderAdded:c,formData:s,mode:m,checkedItems:b$2})=>{var H,j;let{runFormEvent:F}=b(),[p,f]=Te.useState([]),[u,g]=Te.useState(((H=n==null?void 0:n.folderData)==null?void 0:H.id)||null),[v,w]=Te.useState([]),[M,x]=Te.useState(b$2),[R,O]=Te.useState(false),[L,C]=Te.useState(),{UserDialog:I}=b$1();Te.useEffect(()=>{x(b$2);},[b$2]);let h=useCallback(T.debounce(async()=>{var B,S,G,re,pe,ye,se,A,ce,Q,ue;try{let we=await F({pluginCode:((B=n.sourcePluginCode)==null?void 0:B.trim())!==""?n.sourcePluginCode:n.pluginCode,formCode:((S=n.sourceFormCode)==null?void 0:S.trim())!==""?n.sourceFormCode:n.formCode,guid:n.guid,projectGuid:n.pGuid,pGuid:n.pGuid,widgetEvent:U.onFoldersDataLoad,widgetContext:JSON.stringify({originator:(G=n.originator)!=null?G:null})});if(we.meta.requestStatus==="fulfilled"){let ge={...we.payload};ge!=null&&ge.userData&&C(ge==null?void 0:ge.userData),(re=ge==null?void 0:ge.userData)!=null&&re.isContributor&&O(!0);let W=JSON.parse(ge.widgetData.treeData);if(f(W),(pe=n==null?void 0:n.folderData)!=null&&pe.addedFolderId){let K=rd(W,(ye=n==null?void 0:n.folderData)==null?void 0:ye.addedFolderId);if(K){let E=ad([K]);w(E),g((se=n==null?void 0:n.folderData)==null?void 0:se.addedFolderId);let z=It([K],(A=n==null?void 0:n.folderData)==null?void 0:A.addedFolderId);c(null,z);}}else if(v.length===0&&w([(ce=W[0])==null?void 0:ce.id]),!u){let K=(Q=W[0])==null?void 0:Q.id,E=(ue=W[0])==null?void 0:ue.isroot;g(K||null),l(K||null,E);}}}catch(we){}},500),[n]);Te.useEffect(()=>(h(),()=>{h.cancel();}),[h]),Te.useEffect(()=>{var B,S,G,re,pe,ye;if((B=n==null?void 0:n.folderData)!=null&&B.id){g(((S=n==null?void 0:n.folderData)==null?void 0:S.id)||null);let se=Wt(p,(G=n==null?void 0:n.folderData)==null?void 0:G.id),A=It(p,se==null?void 0:se.id),ce=[],Q=id(p,(re=n==null?void 0:n.folderData)==null?void 0:re.id);Q.length>0&&(Q.forEach(ue=>{ce.push(ue.id);}),ce.push((pe=n==null?void 0:n.folderData)==null?void 0:pe.id),w(ce)),l((ye=n==null?void 0:n.folderData)==null?void 0:ye.id,se==null?void 0:se.isroot,A);}},[(j=n==null?void 0:n.folderData)==null?void 0:j.id]);let[J,Z]=useState({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}}),ee=B=>J.delete.callBackFunc(B),T$1=B=>{Z(B);},_=(B,S)=>{g(S);let G=Wt(p,S),re=It(p,G==null?void 0:G.id);l(S,G==null?void 0:G.isroot,re);};return jsxs(Fragment,{children:[jsx(ja,{sx:{paddingTop:"5px"},children:jsx(RichTreeView,{items:p,selectedItems:u,expandedItems:v,sx:{height:"fit-content",flexGrow:1,maxWidth:250,overflowY:"auto"},slots:{item:B=>jsx(nd,{...B,mode:m,params:n,eventDispatcher:t,execCommands:e,deletePrompt:T$1,index:p.findIndex(S=>S.id===B.itemId),selectedItem:u,setSelectedItem:_,treeCheckedItems:M,disableRootItem:R,userData:L,formData:s,properties:r})},onSelectedItemsChange:_,onExpandedItemsChange:(B,S)=>{var re;let G=(re=p[0])==null?void 0:re.id;G&&!S.includes(G)?w(pe=>pe.includes(G)?pe:[...pe,G]):w(S);}})}),jsx(I,{...J.delete,handleDialogClose:ee})]})},mt=ld;var Ya=withTranslation()(memo(function(e){var m,b;let{style:n,verticalalign:r,plugincode:a,formcode:d,visible:l}=e.properties,c={paddingTop:"0px"};if(r==="bottom"&&(c.paddingTop="10px"),!l)return null;let s=(m=e.context.formData)!=null&&m[e.properties.name]?JSON.parse((b=e.context.formData)==null?void 0:b[e.properties.name]):{};return jsx("div",{style:{...n,...c,minHeight:"2rem"},children:jsx(mt,{params:{sourceFormCode:d,sourcePluginCode:a,pluginCode:e.context.params.pluginCode,formCode:e.context.params.formCode,guid:e.context.params.guid,pGuid:e.context.params.pGuid,originator:e.context.params.originator},properties:e.properties,checkedItems:s,redrawComponent:e.context.redrawComponent,eventDispatcher:e.methodProvider.eventDispatcher,execCommands:e.methodProvider.execCommands,formData:e.context.formData,formlayout:"folders",onFolderSelected:()=>{},onFolderAdded:()=>{},mode:"setup"})})}));Ya.displayName="_View";var Za=Ya;var md=lazy(()=>import('./tabulator-VYG4WA2T.js').then(t=>({default:t.TabulatorTable}))),cd=lazy(()=>import('./datatable-ILEPYRB3.js').then(t=>({default:t.Datatable}))),Ae=class{static getFormComponent(e,n){if(e.displayName==="_Rowcontainer")return Hn;if(e.displayName==="_Rowsegment")return Gn;if(e.displayName==="_Textinput"){if(n.inputtype==="input")return qn;if(n.inputtype==="inputwcopy")return Qn;if(n.inputtype==="currency")return Oa;if(n.inputtype==="password")return Ua;if(n.inputtype==="date")return Ra;if(n.inputtype==="time")return ka;if(n.inputtype==="datetime")return Ba;if(n.inputtype==="phone")return La}else {if(e.displayName==="_TabBox")return Yn;if(e.displayName==="_Button")return Da;if(e.displayName==="_Label")return ta;if(e.displayName==="_CheckBox")return aa;if(e.displayName==="_Radio")return la;if(e.displayName==="_Textarea")return sa;if(e.displayName==="_SelectBox")return ua;if(e.displayName==="_Placeholder")return pa;if(e.displayName==="_Fileuploader")return Ca;if(e.displayName==="_Table")return n.alloweditrow||n.tablemode!==void 0&&n.tablemode==="tabulator"?md:cd;if(e.displayName==="_View")return Za}return e}};function or(t,e,n){var r=this,a=useRef(null),d=useRef(0),l=useRef(null),c=useRef([]),s=useRef(),m=useRef(),b=useRef(t),F=useRef(true);useEffect(function(){b.current=t;},[t]);var p=!e&&e!==0&&typeof window!="undefined";if(typeof t!="function")throw new TypeError("Expected a function");e=+e||0;var f=!!(n=n||{}).leading,u=!("trailing"in n)||!!n.trailing,g="maxWait"in n,v=g?Math.max(+n.maxWait||0,e):null;useEffect(function(){return F.current=true,function(){F.current=false;}},[]);var w=useMemo(function(){var M=function(I){var h=c.current,J=s.current;return c.current=s.current=null,d.current=I,m.current=b.current.apply(J,h)},x=function(I,h){p&&cancelAnimationFrame(l.current),l.current=p?requestAnimationFrame(I):setTimeout(I,h);},R=function(I){if(!F.current)return false;var h=I-a.current;return !a.current||h>=e||h<0||g&&I-d.current>=v},O=function(I){return l.current=null,u&&c.current?M(I):(c.current=s.current=null,m.current)},L=function I(){var h=Date.now();if(R(h))return O(h);if(F.current){var J=e-(h-a.current),Z=g?Math.min(J,v-(h-d.current)):J;x(I,Z);}},C=function(){var I=Date.now(),h=R(I);if(c.current=[].slice.call(arguments),s.current=r,a.current=I,h){if(!l.current&&F.current)return d.current=a.current,x(L,e),f?M(a.current):m.current;if(g)return x(L,e),M(a.current)}return l.current||x(L,e),m.current};return C.cancel=function(){l.current&&(p?cancelAnimationFrame(l.current):clearTimeout(l.current)),d.current=0,c.current=a.current=s.current=l.current=null;},C.isPending=function(){return !!l.current},C.flush=function(){return l.current?O(Date.now()):m.current},C},[f,g,e,v,u,p]);return w}var bd=Te__default.createContext(void 0),ar=({children:t,eventDispatcher:e,redrawComponent:n,formlayout:r,params:a,onFolderSelected:d,onFolderAdded:l,formData:c,execCommands:s$1})=>{let[m,b$1]=useState(r),{viewPort:F}=b(),[p,f]=useState(false),{t:u}=useTranslation(),g=()=>f(x=>!x),v=()=>f(false),w={viewHolder:{display:"flex",position:"relative"},toggleButton:{position:"absolute",top:"1em",right:"1em",zIndex:1e3,background:"#FFF",color:"#3f86cc ",border:"1px solid #3f86cc",borderRadius:"50%",width:"35px",height:"35px",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer"},toggleButtonMenuActive:{background:"#3f86cc",color:"#FFF "},btreeContainerMobile:{position:"fixed",top:0,left:p?0:"-16rem",height:"100%",width:"16rem",backgroundColor:"#F8F8F8",borderRight:"1px solid #C0C0C0",transition:"left 0.3s ease",zIndex:999,padding:"0.5rem"},btreeContainerDesktop:{borderRight:"1px solid #C0C0C0"},mainContent:{flex:1,margin:"1em"}},M=()=>jsx(Ol,{variant:"h6",sx:{padding:"0.5em",fontWeight:"bold",borderBottom:"1px dashed #C0C0C0"},children:u("My Folders")});return jsxs(bd.Provider,{value:{layout:m,setLayout:b$1},children:[(!r||r==="regular")&&t,r==="folders"&&jsxs("div",{className:"viewHolder",style:w.viewHolder,children:[F.isMobileDevice?jsxs(Fragment,{children:[!p&&jsx("button",{onClick:g,style:{...w.toggleButton,...w.toggleButtonMenuActive},children:s({size:"1.3rem"})}),jsx(pd,{open:p,onClick:v,sx:{zIndex:998,backgroundColor:"rgba(0, 0, 0, 0.5)"}}),jsxs("div",{style:w.btreeContainerMobile,onClick:x=>x.stopPropagation(),children:[jsx("div",{style:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingLeft:"0.5rem"}}),jsx(M,{}),jsx(mt,{params:{...a,sourcePluginCode:a.pluginCode,sourceFormCode:a.formCode},redrawComponent:n,eventDispatcher:e,execCommands:s$1,formData:c,formlayout:r,onFolderSelected:d,onFolderAdded:l,mode:"live"})]})]}):jsxs("div",{className:"foldersHolder",style:w.btreeContainerDesktop,children:[jsx(M,{}),jsx(mt,{params:{...a,sourcePluginCode:a.pluginCode,sourceFormCode:a.formCode},redrawComponent:n,eventDispatcher:e,execCommands:s$1,formData:c,formlayout:r,onFolderSelected:d,onFolderAdded:l,mode:"live"})]}),jsx("div",{style:w.mainContent,children:t})]})]})};var Fd=lazy(()=>import('./fileviewer-24IMJQQY.js')),Td=lazy(()=>import('./formeditor-UADHD4JI.js').then(t=>({default:t.Formeditor}))),Tt=t=>new Promise(e=>setTimeout(e,t)),zt={command:{},params:{id:null,parentId:null,guid:"",pGuid:"",formCode:"",pluginCode:"",modal:false,modalCloseFn:()=>{},modalCloseAndOpenFn:()=>{},originator:{params:{pluginCode:"",formCode:"",guid:""}},parent:{widgetName:"",params:{pluginCode:"",formCode:"",guid:""}},hasParentForm:false,folderData:{id:"",label:"",isRoot:"",captions:[]}},doValidateForm:false,redrawComponent:false,redrawFoldersComponent:false,fieldAllowedValues:{},formData:{},widgetRelatedData:[],widgetsState:{visibility:{},readonly:{}},formDimension:{width:0,height:0},formValidationData:{},enableEventHandlers:false,isModal:false,hasParentForm:false,formLayout:"regular"},dr={containerSetup:{properties:{style:{minHeight:0}}},selectedWidgetProps:{title:"",subtitle:"",style:{},tabsetup:null,_path:{type:null,stricttype:null,component:null,tabId:null,panelId:null,rowId:null,segmentId:null,widgetId:null},lastActiveTabId:null}},Dd={id:"",parentId:"",pluginCode:"",formCode:"",guid:null,pGuid:void 0,isFormEditorMode:false,originator:{params:{pGuid:"",pluginCode:"",formCode:"",guid:""}},parent:{widgetName:"",params:{pGuid:"",pluginCode:"",formCode:"",guid:""}},folderData:{id:"",addedFolderId:"",isRoot:"",captions:[]},prefillData:void 0},Pd=memo(function({previewMode:e,className:n,maxWidth:r,setup:a,params:d$1,enableEventHandlers:l,modalCloseFn:c}){var Kt,Xt;let s={...d$1,modalCloseFn:c||(d$1==null?void 0:d$1.modalCloseFn)},m=useRef(null),[b$1,F]=useState(0),{registerFormSubmitEvent:p,checkFormAccess:f$1}=i$1(),{apiConfig:u,appSettings:g,viewPort:v,runLoadFormEvent:w,runServerPingEvent:M,runFormEvent:x,fetchUserMenu:R,signInUser:O,signOut:L}=b(),[C,I]=useState(null),h=useNavigate(),[J,Z]=useState(false),ee=useRef({}),[T$1,_]=useState({}),[D,H]=useState(null),[j,B]=useState(null),S=useLocation(),[G]=useState(v.width),[re]=useState(s.modal||false),[pe]=useState(T.hasParentForm()||!!(u!=null&&u.token)),[ye,se]=useState([]),A=ye.length>0?ye[ye.length-1]:Dd,[ce,Q]=useState(),[ue,we]=useState(true),{t:ge}=useTranslation(),W=e$1(),K=f(),E=g$2(),z={command:{},params:s,doValidateForm:false,redrawComponent:false,redrawFoldersComponent:false,fieldAllowedValues:{},formData:{},widgetRelatedData:[],widgetsState:{visibility:{},readonly:{}},formDimension:{width:b$1,height:0},formValidationData:{},enableEventHandlers:l,isModal:re,hasParentForm:pe,formLayout:"regular"},[o,te]=useState(z),[oe,ie]=useState({...dr,containerSetup:a}),Ne=or(()=>{m&&m.current&&F(m.current.offsetWidth);},200),ze=async(i,k)=>{await w({pluginCode:i.pluginCode,formCode:i.formCode,guid:i.guid,projectGuid:i.pGuid,pGuid:i.pGuid,originator:i.originator,parent:i.parent,previewMode:e,widgetContext:JSON.stringify({folderData:i.folderData,prefillData:i.prefillData})}).then(async P=>{var V,X,Y,ve,he,be,Fe,U;if(P.meta.requestStatus==="fulfilled"){let N={...P.payload};if(Object.keys(N).length===0)return;try{let me=window.location.hostname;if(!b$2.SKIP_ACCESS_VALIDATION_DOMAINS.some(We=>me===We||me.endsWith(`.${We}`))){let We=await f$1(i.formCode);(We==null?void 0:We.subscriptionPlan)!=null&&H(We.subscriptionPlan);}}catch(me){B({title:(X=(V=me==null?void 0:me.data)==null?void 0:V.error)!=null?X:"Form Unavailable",message:(ve=(Y=me==null?void 0:me.data)==null?void 0:Y.message)!=null?ve:"This form is temporarily unavailable."});return}if(N.uiTranslations&&Object.keys(N.uiTranslations).length>0){ee.current=N.uiTranslations,_(N.uiTranslations);let me=wd;me.addResourceBundle(me.language,"default",N.uiTranslations,true,true);}let Se={},de={visibility:{...o==null?void 0:o.widgetsState.visibility,...(he=N==null?void 0:N.widgetsState)==null?void 0:he.visibility},readonly:{...o==null?void 0:o.widgetsState.readonly,...(be=N==null?void 0:N.widgetsState)==null?void 0:be.readOnly}};if(k){te(me=>({...me,formData:N.data,fieldAllowedValues:N.fieldAllowedValues,widgetsState:de,formLayout:N.layout,requiredFields:N.requiredFields}));return}let De={},Le=[],Oe={},He=JSON.parse(N.definition);if(He==null){te({...z,redrawComponent:false,doValidateForm:false,command:{...N.FECommand},formData:{},widgetsState:de,formLayout:N.layout,requiredFields:N.requiredFields,params:{...z.params,folderData:N.folderData}});return}T.mapComponents(He._children);let Xe=He.properties;Le=He._children,Oe=He,ie({...oe,containerProps:Xe,selectedWidgetProps:{...oe.containerProps},containerData:Le,containerSetup:Oe}),Se=N.fieldAllowedValues,De=N.data,te({...z,formData:De,formLayout:N.layout,widgetsState:{visibility:{...o==null?void 0:o.widgetsState.visibility,...(Fe=N==null?void 0:N.widgetsState)==null?void 0:Fe.visibility},readonly:{...o==null?void 0:o.widgetsState.readonly,...(U=N==null?void 0:N.widgetsState)==null?void 0:U.readOnly}},requiredFields:N.requiredFields,command:{...N.FECommand},fieldAllowedValues:Se,params:{...z.params,folderData:N.folderData}}),Z(true);}});};if(useEffect(()=>(Ne(),ze(s,false),window.addEventListener("resize",Ne),()=>{te(()=>({...zt})),ie(dr),Z(false),window.removeEventListener("resize",Ne);}),[s.pGuid,s.guid,s.pluginCode,s.formCode]),useEffect(()=>{var X,Y,ve,he,be,Fe,U,N,Se,de,De,Le,Oe,He,Xe,me,Rt,We,Yt,Zt,eo,to,oo,no,ao,ro,io,lo,so,mo,co,uo,fo,po,go,ho,bo,vo,yo,wo,xo,Co,Io,Fo,To,Do,Po,Ro,So,Eo,ko,Mo,Bo,No,Lo,_o,Ao,Vo,Oo,Ho,Wo,Uo,Go,zo,$o,qo,Jo,jo,Qo,Ko,Xo,Yo,Zo,en,tn;let i=o,k=null,P=true,V=false;if((X=o.command)!=null&&X.Messages&&((Y=o.command)==null||Y.Messages.forEach(le=>{var Ee;let ae=(Ee=ee.current[le.text])!=null?Ee:ge(le.text);le.code==="NOTICE"?(V=true,E({toastID:nanoid(11),msg:ae,clearQueue:false,hideProgressBar:false})):le.code==="SUCCESS"?(V=true,K({toastID:nanoid(11),msg:ae,clearQueue:false,hideProgressBar:false})):le.code==="WARNING"&&(P=false,W({toastID:nanoid(11),msg:ae,clearQueue:false,hideProgressBar:false}));})),(ve=o.command)!=null&&ve.DisplayButtonLoader){te({...o,displayButtonLoader:true});return}if((he=o.command)!=null&&he.DisplayErrorPage){h("/pagenotfound");return}if((be=o.command)!=null&&be.MoveToTab){let le=(U=(Fe=o.command)==null?void 0:Fe.MoveToTab)==null?void 0:U.widgetName;if(le){let ae=T.getTabWidgetByFieldName(le,oe.containerSetup);ae!==null&&(ae==null?void 0:ae.tabId)!==void 0&&Ve(ae);}}if((N=o.command)!=null&&N.FormValidationData&&Object.keys(o.command.FormValidationData).length>0){let le=Object.keys(o.command.FormValidationData)[0];if(le){let ae=T.getTabWidgetByFieldName(le,oe.containerSetup);ae!==null&&(ae==null?void 0:ae.tabId)!==void 0&&Ve(ae),setTimeout(()=>{let Ee=[`[name="${le}"]`,`[data-field-name="${le}"]`,`#${le}`,`[id*="${le}"]`],Pe=null;for(let pt of Ee)try{if(Pe=document.querySelector(pt),Pe)break}catch(St){}Pe&&(Pe.scrollIntoView({behavior:"smooth",block:"center"}),(Pe.tagName==="INPUT"||Pe.tagName==="TEXTAREA"||Pe.tagName==="SELECT")&&Pe.focus());},100);}te({...o,doValidateForm:true,formValidationData:(Se=o.command)==null?void 0:Se.FormValidationData});return}else i={...i,formValidationData:{}};if((de=o.command)!=null&&de.FetchUserMenu&&R&&R({ProjectGuid:(Le=(De=o.command)==null?void 0:De.FetchUserMenu)==null?void 0:Le.projectGuid,pGuid:(He=(Oe=o.command)==null?void 0:Oe.FetchUserMenu)==null?void 0:He.projectGuid}),(Xe=o.command)!=null&&Xe.Redirect){s.modalCloseFn&&s.modalCloseFn(),h(`${(me=o.command)==null?void 0:me.Redirect.url}?ref=${(Yt=(We=(Rt=o.command)==null?void 0:Rt.Redirect)==null?void 0:We.context)==null?void 0:Yt.referer}`,{state:{from:(to=(eo=(Zt=o.command)==null?void 0:Zt.Redirect)==null?void 0:eo.context)==null?void 0:to.referer}});return}if((oo=o.command)!=null&&oo.BuildPlugin){h(`${(no=o.command)==null?void 0:no.BuildPlugin.url}?ref=${(ro=(ao=o.command)==null?void 0:ao.BuildPlugin)==null?void 0:ro.referer}`);return}if((io=o.command)!=null&&io.DisplayComponent&&I((lo=o.command)==null?void 0:lo.DisplayComponent),(so=o.command)!=null&&so.CloseDisplayComponent&&I(null),(mo=o.command)!=null&&mo.Login&&(async()=>{var le,ae,Ee,Pe,pt,St,on;O&&await O((le=o.command)==null?void 0:le.Login),R&&await R({ProjectGuid:T.extractProjectGuid((Ee=(ae=o.command)==null?void 0:ae.Login)==null?void 0:Ee.url),pGuid:T.extractProjectGuid((pt=(Pe=o.command)==null?void 0:Pe.Login)==null?void 0:pt.url)}),h(((on=(St=o.command)==null?void 0:St.Login)==null?void 0:on.url)||"/");})(),(co=o.command)!=null&&co.Logout&&(async()=>{var ae;(ae=o.command)!=null&&ae.Logout&&(L&&await L(),h("/"));})(),((uo=o.command)!=null&&uo.Cancel||(fo=o.command)!=null&&fo.CloseForm)&&(o.isModal&&s.modalCloseFn!==void 0?s.modalCloseFn(null,null,false,(po=o.command)==null?void 0:po.RedrawFolders):(k=T.getUrlParameter("ref"),k!=null&&h(k))),(go=o.command)!=null&&go.AfterRecordSave){let le=(ho=g==null?void 0:g.TOASTER_AUTOCLOSE)!=null?ho:b$2.TOASTER_AUTOCLOSE;if(k=T.getUrlParameter("ref"),((bo=o.command)==null?void 0:bo.AfterRecordSave.guid)==null)!((vo=o.command)!=null&&vo.OpenModal)&&s.modalCloseFn?s.modalCloseFn(null,null,false,null,null):(yo=o.command)!=null&&yo.OpenModal||(async()=>(await Tt(V?le:0),k!=null&&h(k)))();else if(o.isModal){let ae;(wo=o.command)!=null&&wo.HotReloadEnabled&&(ae=(xo=o.command)==null?void 0:xo.HotReloadEnabled),(Co=o.command)!=null&&Co.OpenModal||(async()=>{var Ee,Pe;await Tt(V?le:0),s.modalCloseFn&&s.modalCloseFn(ae,o.formData,(Ee=o.command)==null?void 0:Ee.RedrawScreen,(Pe=o.command)==null?void 0:Pe.RedrawFolders,null);})();}else {let ae=k!=null;if(!((Io=o.command)!=null&&Io.OpenModal)&&ae&&P)(async()=>(await Tt(V?le:0),k!=null&&h(k)))();else if(!((Fo=o.command)!=null&&Fo.OpenModal)){let Ee=S.pathname.replace(/\/new/gi,"/"+((To=o.command)==null?void 0:To.AfterRecordSave.guid.replace(/#/g,"%23")));h(Ee,{state:{from:S.pathname}}),i={...i,params:{...o.params,guid:(Do=o.command)==null?void 0:Do.AfterRecordSave.guid}};}}}if((Po=o.command)!=null&&Po.UpdateWidgetsState&&(i={...i,widgetsState:{visibility:{...i==null?void 0:i.widgetsState.visibility,...(So=(Ro=o.command)==null?void 0:Ro.UpdateWidgetsState)==null?void 0:So.visibility},readonly:{...i==null?void 0:i.widgetsState.readonly,...(ko=(Eo=o.command)==null?void 0:Eo.UpdateWidgetsState)==null?void 0:ko.readonly}}}),(Mo=o.command)!=null&&Mo.UpdateFieldAllowedValues&&(i={...i,fieldAllowedValues:{...(Bo=o.command)==null?void 0:Bo.UpdateFieldAllowedValues}}),(No=o.command)!=null&&No.UpdateFormData&&(i={...i,formData:{...(Lo=o.command)==null?void 0:Lo.UpdateFormData}}),(_o=o.command)!=null&&_o.UpdateFormDataItem&&(i={...i,formData:{...i.formData,[(Ao=o.command)==null?void 0:Ao.UpdateFormDataItem.name]:(Vo=o.command)==null?void 0:Vo.UpdateFormDataItem.value}}),((Ho=(Oo=o.command)==null?void 0:Oo.ReplaceContextRecordGuid)==null?void 0:Ho.guid)!=null&&(i={...i,displayButtonLoader:false,params:{...o.params,guid:(Wo=o.command)==null?void 0:Wo.ReplaceContextRecordGuid.guid}}),(Uo=o.command)!=null&&Uo.OpenModal){let le={...(Go=o.command)==null?void 0:Go.OpenModal,parentId:s.id};se(ae=>[...ae,le]),i={...i,command:{}};}(zo=o.command)!=null&&zo.PreviewDocument&&Q(($o=o.command)==null?void 0:$o.PreviewDocument),(qo=o.command)!=null&&qo.RedrawScreen&&(i={...i,redrawComponent:!o.redrawComponent,redrawFoldersComponent:!o.redrawFoldersComponent}),(Jo=o.command)!=null&&Jo.RedrawFolders&&(i={...i,params:{...o.params,folderData:{id:(Qo=(jo=o.command)==null?void 0:jo.RedrawFolders)==null?void 0:Qo.folderId,addedFolderId:(Xo=(Ko=o.command)==null?void 0:Ko.RedrawFolders)==null?void 0:Xo.folderId,isRoot:(Zo=(Yo=o.command)==null?void 0:Yo.RedrawFolders)==null?void 0:Zo.isRoot,captions:(tn=(en=o.command)==null?void 0:en.RedrawFolders)==null?void 0:tn.captions}}}),Object.keys(o.command).length>0&&(i={...i,command:{}},te(i));},[o.command]),j)return jsx(l$1,{title:j.title,message:j.message});if(!J)return Te__default.createElement("div",{},jsx(a$2,{message:ge("Please wait...")}));let Ke=(i,k)=>{let P={};return Object.entries(i).forEach(([V,X])=>{let Y=k[V];(Y==null||Y===""||Y==="0"||Y===0||Array.isArray(Y)&&Y.length===0)&&(P[V]=X);}),P},Ve=(i,k=false,P={})=>{let V=ut(null,i.tabId,i.index,k,P.containerSetup);if(V===void 0)return;let X=T.GetParentTabId(V.containerSetup,i.tabId);(X==null?void 0:X.tabId)!=null?(V=ut(null,X.tabId,X.index,false,V.containerSetup),V!==void 0&&Ve(X,true,V)):k===false&&ut(null,i.tabId,i.index,true);},xe=async i=>(te({...o,displayButtonLoader:true}),await x({pluginCode:i.pluginCode,formCode:i.formCode,guid:i.guid,projectGuid:i.projectGuid,pGuid:i.projectGuid,formData:{...i.formData,[i.fieldName]:i.value},widgetContext:JSON.stringify({referer:S.pathname,parentWidgetId:i.tabId,hasParentForm:T.hasParentForm(),originator:{widgetName:i.fieldName.toLowerCase(),params:o.params},parent:{widgetName:i.fieldName.toLowerCase(),params:o.params},parentOriginator:{params:o.params.originator?o.params.originator.params:{}},folderData:o.params.folderData}),widgetEvent:i.widgetEvent,widgetName:i.fieldName.toLowerCase(),widgetValue:i.widgetValue}).then(async k=>{var P,V,X,Y,ve,he,be,Fe;if(k.meta.requestStatus==="fulfilled"){let U={...k.payload};((P=U.FECommand)==null?void 0:P.ReplaceContextRecordGuid)!==void 0?(U.FECommand={Messages:(X=(V=U.FECommand)==null?void 0:V.Messages)!=null?X:[],UpdateFormData:U.data,ReplaceContextRecordGuid:(Y=U.FECommand)==null?void 0:Y.ReplaceContextRecordGuid},ot(U.FECommand)):(ve=U.FECommand)!=null&&ve.Messages?(U.FECommand={UpdateFormData:U.data,Messages:(he=U.FECommand)==null?void 0:he.Messages},ot(U.FECommand)):(be=U.FECommand)!=null&&be.FormValidationData&&(U.FECommand={FormValidationData:(Fe=U.FECommand)==null?void 0:Fe.FormValidationData},ot(U.FECommand));}else te({...o,displayButtonLoader:false});})),tt=i=>{let k=i.widgetContext,P=i.widgetEvent,V=i.widgetName.toLowerCase(),X=i.widgetValue,Y=i.feCommand||{},ve=i.skipFormDataItem||false;if(P!==null&&o.enableEventHandlers){if(i.autoSave){xe(i.autoSave);return}let he=X!=null&&ve===false?{...o.formData,[V]:X}:o.formData;if((P==null?void 0:P.toUpperCase())==="ONSAVE"&&o.requiredFields!=null){let be=Ke(o.requiredFields,he),Fe=Object.keys(o.formValidationData||{}).length>0,U=Object.keys(be).length>0;if((U||Fe)&&(te({...o,command:{...o.command,FormValidationData:be}}),U))return}(async()=>{var be,Fe;if((P==null?void 0:P.toUpperCase())==="ONSAVE")try{await p(o.params.formCode);}catch(U){if((U==null?void 0:U.status)===429)return}we(false),await x({pluginCode:o.params.pluginCode,formCode:o.params.formCode,guid:o.params.guid,projectGuid:(be=o.params.pGuid)!=null?be:"",pGuid:(Fe=o.params.pGuid)!=null?Fe:"",widgetContext:k,widgetEvent:P,widgetName:V,widgetValue:typeof X=="string"?X:X!=null?JSON.stringify(X):null,formData:he,widgetsState:o.widgetsState}).then(U=>{var N,Se;if(U.meta.requestStatus==="fulfilled"){if(U.payload instanceof Blob){te({...o,redrawComponent:!o.redrawComponent});return}let de={...U.payload};if(Object.keys(de).length===0)return;let De=JSON.parse(de.definition);if(De!=null){let Le=[],Oe={};T.mapComponents(De._children);let He=De.properties;Le=De._children,Oe=De,ie({...oe,containerProps:He,selectedWidgetProps:{...oe.selectedWidgetProps},containerData:Le,containerSetup:Oe});let Xe=V;if(Xe){let me=T.getTabWidgetByFieldName(Xe,Oe);me!==null&&(me==null?void 0:me.tabId)!==void 0&&Ve(me,true,{containerSetup:Oe});}}ve||(o.redrawComponent=false),te({...o,fieldAllowedValues:de.fieldAllowedValues,doValidateForm:true,command:{...de.FECommand},formData:{...o.formData,...de.data},widgetRelatedData:de.widgetRelatedData,widgetsState:{visibility:{...o==null?void 0:o.widgetsState.visibility,...(N=de==null?void 0:de.widgetsState)==null?void 0:N.visibility},readonly:{...o==null?void 0:o.widgetsState.readonly,...(Se=de==null?void 0:de.widgetsState)==null?void 0:Se.readOnly}},tabIndex:i.tabIndex?Number(i.tabIndex+1):0});}}).finally(async()=>{var U;if(we(true),(P==null?void 0:P.toUpperCase())==="ONSAVE"&&u!=null&&u.iframeMode&&u!=null&&u.token){let N=(U=oe.containerProps)==null?void 0:U.webhooks;if(Array.isArray(N)&&N.length>0){let Se={formCode:o.params.formCode,submittedAt:new Date().toISOString(),data:he};N.forEach(de=>{var De;de.enabled&&((De=de.url)!=null&&De.startsWith("http"))&&fetch(de.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Se),mode:"cors"}).then(Le=>{Le.ok||W({toastID:nanoid(11),msg:`Webhook failed: ${de.url}`,clearQueue:false,hideProgressBar:false});}).catch(Le=>{W({toastID:nanoid(11),msg:`Webhook failed: ${de.url}`,clearQueue:false,hideProgressBar:false});});});}}});})();}if(X!=null){let he={...o.formData,[V]:X};te({...o,command:Y,formData:he});}},Ce=(i,k,P)=>T.findRowItem(i,k,P,oe.containerSetup._children),rt=(i,k,P,V)=>T.findSegmentItem(i,k,P,V,oe.containerSetup._children),cr=i=>T.findWidgetByIdRecursive(oe.containerSetup._children,i),ur=(i,k)=>T.getActiveTabIndex(oe.containerSetup._children,k),ut=(i,k,P,V=true,X={})=>{let Y=Object.keys(X).length>0?X:oe.containerSetup,ve=T.getTabContainer(Y._children,k),he=T.getTabContainerChildrens(Y._children,k);if(he===void 0)return;for(let N=0;N<he.data.length;N++)he.data[N].activeTab="0";let be=he.data.filter((N,Se)=>Se===P)[0];be.properties={...ve.item.properties.tabsetup,...be.properties};let Fe=T.getNodeUpdatePath(he.path,{$splice:[[P,1,{...be,activeTab:"1"}]]});var U={containerSetup:{...Y,_children:(0, sr.default)(Y._children,Fe)},selectedWidgetProps:{...oe.selectedWidgetProps,tabsetup:{...be.properties},_path:{...oe.selectedWidgetProps._path,panelId:be.id},lastActiveTabId:k}};return V&&ie(U),U},fr=(i=true)=>{let k=zt;i&&(k={...o,redrawComponent:!o.redrawComponent,params:{...o.params,folderData:{id:"",isRoot:"",captions:[]}}}),te(k);},ot=i=>{te({...o,redrawComponent:!o.redrawComponent,command:{...i}});},$t=(i,k)=>{(async()=>{if(!M){i();return}await M({cmd:"ping"}).then(async P=>{(P==null?void 0:P.type)==="formbuilder/ping/rejected"?(W({toastID:nanoid(11),msg:"Application is being restarted. Please wait until it finishes....",clearQueue:false,hideProgressBar:false}),await Tt(1e3),$t(i)):i();});})();},Pt=(i,k=false,P,V=null)=>{$t(()=>{if(se(Y=>Y.slice(0,-1)),V!=null){let Y={...V,parentId:s.id};se(ve=>[...ve,Y]);}else if(i!=null){let Y={id:nanoid(5),pluginCode:i==null?void 0:i.pluginCode,formCode:i==null?void 0:i.formCode,guid:null,isFormEditorMode:true,parentId:s.id};se(ve=>[...ve,Y]);}if(ze(o.params,true),P){let Y=P==null?void 0:P.folderId;qt(Y,[]);}else te({...o,redrawComponent:!o.redrawComponent});}),k&&o.isModal&&ze(s,true);},pr=(i,k="",P)=>{let V={...o,redrawFoldersComponent:!o.redrawFoldersComponent,redrawComponent:!o.redrawComponent,params:{...o.params,folderData:{...o.params.folderData,addedFolderId:"",captions:P,id:i!==null?i:"",isRoot:k}}};te(V);},qt=(i,k)=>{let P=zt;i==null?P={...o,redrawFoldersComponent:!o.redrawFoldersComponent,params:{...o.params,folderData:{...o.params.folderData,addedFolderId:i!==null?i:"",captions:k}}}:P={...o,params:{...o.params,folderData:{...o.params.folderData,id:i!==null?i:"",addedFolderId:i!==null?i:"",isRoot:"",captions:k}}},te(P);},Jt=i=>{i&&se(k=>[...k.slice(0,-1),{...i,id:nanoid(5)}]);},gr=()=>{Q(void 0);},hr=()=>I(null),br=i=>{let{title:k,subtitle:P}=i,V=k;return P!==void 0&&String(P).trim()!==""&&(V=k+" - "+P),o.enableEventHandlers&&Object.keys((o==null?void 0:o.formData)||{}).length>0&&Object.entries(o.formData).forEach(([X,Y])=>{V=V.replace(`#${X}`,Y);}),V},{properties:Ie}=oe.containerSetup||{},{minHeight:jt}=(Ie==null?void 0:Ie.style)||{},ft={};jt&&(ft.minHeight=jt),re&&(ft={...ft,width:"100%",minWidth:G-G*.3,maxHeight:"calc(100dvh - 4rem)",overflow:"auto"});let Qt={};return e&&(Qt={overflowY:"scroll",height:"100vh",padding:"0px 10px 10px 10px"}),jsx(k$1.Provider,{value:D,children:jsx(ba.Provider,{value:T$1,children:jsxs(ar,{execCommands:ot,eventDispatcher:tt,redrawComponent:o.redrawFoldersComponent,formlayout:o.formLayout,params:o.params,onFolderSelected:pr,onFolderAdded:qt,formData:o.formData,children:[jsxs("div",{id:"main-content-wrapper",className:n,children:[jsx("div",{className:"content",children:jsx("div",{className:"main-content on-scrollbar",style:Qt,children:jsxs("div",{id:"formCanvas",ref:m,style:{maxWidth:r,border:(Ie==null?void 0:Ie.border)===false?"none":void 0},children:[jsxs("form",{onSubmit:i=>{i.preventDefault();},style:{position:"relative"},children:[Ie&&!Ie.hideheader&&jsxs("div",{className:"form-header top-border-radius",style:{backgroundColor:(Ie==null?void 0:Ie.headerbackground)===false?"transparent":void 0},children:[jsx("div",{style:{flex:1,marginLeft:"0.5rem"},children:Ie&&br(Ie)}),re&&s.modalCloseFn!==void 0&&jsx("div",{style:{width:"2.5em"},children:jsx(lr,{onClick:()=>s.modalCloseFn(null),children:Te__default.createElement(P)})})]}),Ie&&Ie.hideheader&&re&&s.modalCloseFn!==void 0&&jsx("div",{style:{position:"absolute",top:"0.5rem",right:"0.5rem",zIndex:9999},children:jsx(lr,{size:"medium",onClick:i=>{i.stopPropagation(),s.modalCloseFn(null);},sx:{backgroundColor:"rgba(255, 255, 255, 0.95)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"}},children:Te__default.createElement(P)})}),jsx("div",{style:ft,className:"form-container bottom-border-radius",children:jsx("div",{className:"form-container",children:jsx(m$1,{darkMode:false,noPadding:true,children:jsx(Suspense,{fallback:jsx(a$2,{}),children:jsx(Rd,{eventDispatcher:tt,context:o,formWidth:b$1,findRowItem:Ce,findSegmentItem:rt,findWidgetItem:cr,modal:re,getActiveTabIndex:ur,setActiveTabIndex:ut,setRedrawComponent:fr,execCommands:ot,widgets:oe.containerSetup})})})})})]}),C!==null&&jsx(d,{componentName:C.componentName,options:C.options,params:{params:(Kt=C.options)!=null&&Kt.contextParams?(Xt=C.options)==null?void 0:Xt.contextParams:o.params,formData:o.formData,execCommands:i=>ot(i),modalCloseFn:()=>hr(),modalCloseAndOpenFn:i=>Jt(i)}})]})})}),(D==null?void 0:D.toLowerCase())==="free"&&!re&&jsxs("div",{style:{textAlign:"center",padding:"12px 16px",fontSize:"13px",color:"#aaa"},children:["Powered by"," ",jsx("a",{href:"https://buildocs.com",target:"_blank",rel:"noopener noreferrer",style:{color:"#3498db",textDecoration:"none",fontWeight:500},children:"Buildocs"})]})]}),!ue&&jsx(a$2,{message:ge("Please wait...")}),!A.isFormEditorMode&&ce&&ce.fileId&&jsx(Suspense,{fallback:jsx(a$2,{message:ge("Loading viewer...")}),children:jsx(Fd,{fileId:ce.fileId,fileBase64:ce.data,fieldName:ce.fieldName,params:{...ce.context?ce.context:o.params,modalCloseFn:gr}},nanoid(11))}),!A.isFormEditorMode&&(A==null?void 0:A.pluginCode)&&(A==null?void 0:A.formCode)&&jsx(a$3,{component:jsx(Pd,{params:{id:A.id,parentId:A.parentId,pluginCode:A.pluginCode,formCode:A.formCode,guid:A.guid==null?"new":A.guid,pGuid:A.pGuid,modal:true,modalCloseFn:(i,k,P,V,X=null)=>Pt(i,P,V,X),modalCloseAndOpenFn:i=>Jt(i),originator:A.originator,parent:A.parent,folderData:A.folderData,prefillData:A.prefillData},enableEventHandlers:true}),id:A.id,onCloseModal:Pt,parentId:A.parentId},A.id),A.isFormEditorMode&&(A==null?void 0:A.pluginCode)&&(A==null?void 0:A.formCode)&&jsx(a$3,{component:jsx(Suspense,{fallback:jsx(a$2,{}),children:jsx(Td,{inPreviewMode:false,pluginCode:A.pluginCode,formCode:A.formCode,modal:true},nanoid(11))}),id:A.id,onCloseModal:()=>Pt(null,false,null),parentId:A.parentId,windowMode:"fullWindow"},A.id)]})})})}),Rd=t=>{let e=0,n=r=>{for(var a in r)typeof r[a]=="object"&&r[a]!==null?n(r[a]):a==="tabIndex"&&(t.modal?r[a]=0:r[a]=++e);};return n(t.widgets._children),(t.widgets._children||[]).map(({id:r,tabId:a,panelId:d,type:l,component:c,properties:s})=>Te__default.createElement(Ae.getFormComponent(c,s),{key:"key_"+r,id:r,tabId:a,panelId:d,className:l,context:{...t.context,formDimension:{width:t.formWidth,height:0}},properties:s,widgetsState:t.context.widgetsState,methodProvider:{eventDispatcher:t.eventDispatcher,findRowItem:t.findRowItem,findSegmentItem:t.findSegmentItem,findWidgetItem:t.findWidgetItem,getActiveTabIndex:t.getActiveTabIndex,setActiveTabIndex:t.setActiveTabIndex,setRedrawComponent:t.setRedrawComponent,execCommands:t.execCommands}},r))};
2
- export{An as a,Pd as b};
@@ -1 +0,0 @@
1
- import {d}from'./chunk-SYCZSSRF.js';import {a}from'./chunk-POE6K4NQ.js';import {e,b as b$1}from'./chunk-FRAOYRZD.js';import {U,T,k}from'./chunk-TYVVEP34.js';import'./chunk-U4T4ACDE.js';import {b}from'./chunk-LBMVBVXW.js';import {d as d$1,t,p,V,h,q,g,N,_,Y,W,X,Z,P,r,n,i,w,A,b as b$2,y,x,C,l,O,o}from'./chunk-AR42AC7J.js';import'./chunk-5TBO732O.js';import dt,{lazy,memo,useRef,useState,useEffect,useCallback,useMemo,Suspense}from'react';import {withTranslation,useTranslation}from'react-i18next';import qn from'@mui/material/CircularProgress';import Xt from'@mui/material/Box';import Fe from'@mui/material/Button';import $n from'@mui/material/Checkbox';import Kn from'@mui/material/ClickAwayListener';import Kt from'@mui/material/IconButton';import Qe from'@mui/material/ListItemIcon';import Xe from'@mui/material/ListItemText';import Ze from'@mui/material/MenuItem';import Qn from'@mui/material/MenuList';import re from'@mui/material/Tooltip';import {nanoid}from'@reduxjs/toolkit';import {useNavigate,useLocation}from'react-router-dom';import en from'@mui/material/Menu';import Zn from'axios';import ea from'@mui/icons-material/MoreVert';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var ta=lazy(()=>import('./buildocslib.esm-BUFQH2Q3.js').then(c=>({default:c.DatatableImb}))),na="#1976d2";var ut=(r=>(r[r.SIGN=0]="SIGN",r[r.CONFIRM=1]="CONFIRM",r))(ut||{}),tn=(l=>(l[l.SIGN=0]="SIGN",l[l.CONFIRM=1]="CONFIRM",l[l.EDIT=2]="EDIT",l))(tn||{}),et=(c,e,r,l,g)=>{var le,G,se,E,b;return e.methodProvider.eventDispatcher({skipFormDataItem:true,widgetName:e.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:c,rowData:{_id:(le=r._id)!=null?le:null,_sk:(G=r._sk)!=null?G:null,_code:(se=r._fcode)!=null?se:r._code,_origformcode:(E=r._origformcode)!=null?E:null,_plugincode:(b=r._plcode)!=null?b:r._plugincode}}),widgetEvent:U.onTableRunActionEvent,widgetContext:JSON.stringify({referer:l.pathname,parentWidgetId:g,hasParentForm:T.hasParentForm(),originator:{widgetName:e.properties.name.toLowerCase(),params:e.context.params},parent:{widgetName:e.properties.name.toLowerCase(),params:e.context.params},folderData:e.context.params.folderData})})},Se=(c,e)=>{var r,l;return !(c==="file"&&e.formLayout==="folders"&&((r=e.params.folderData)!=null&&r.isRoot||((l=e.params.folderData)==null?void 0:l.id)===null))},aa=({anchorEl:c,handleClose:e$1,setUploadMode:r,uploadMode:l,props:g,setLoaded:le})=>{let{runFormUploadFiles:G}=b(),se=e(),E=!!c,b$1=useRef(null),[ie,q]=useState([]),{t:ce}=useTranslation(),te=(de="file")=>{if(!Se(de,g.context)){se({toastID:nanoid(11),msg:ce("Please select a folder before uploading a file"),clearQueue:false,hideProgressBar:false});return}b$1.current&&b$1.current.click(),r(de),e$1();},$=async de=>{var m,R;let me=de.target.files;if(me){le(false);let _=Array.from(me).map(T=>({...T,uploadProgress:0})),x=new FormData;if(g.context.params)for(let T in g.context.params)g.context.params.hasOwnProperty(T)&&x.append(T,g.context.params[T]);x.append("fieldName",g.properties.name),Array.from(me).forEach(T=>{x.append("files",T);}),x.append("widgetContext",JSON.stringify({hasParentForm:T.hasParentForm(),originator:(m=g.context.params)==null?void 0:m.originator,folderData:(R=g.context.params)==null?void 0:R.folderData})),x.append("widgetEvent",U.onFileUploadCreateDocumentEvent),x.append("widgetName","attached_files"),x.append("formData",JSON.stringify({...g.context.formData})),x.append("uploadMode",l);let B=Zn.CancelToken.source();try{let T=await G({content:x,cancelTokenSource:B,onUploadProgress:X=>{let he=Math.round(X.loaded/_.length),ye=_.map(be=>({...be,uploadProgress:X.loaded===X.total?100:Math.round(he*100/be.size)}));q(be=>be.concat(ye));}});if(T.meta.requestStatus==="fulfilled"){let X={...T.payload};g.methodProvider.execCommands(X.FECommand);}}catch(T){}b$1.current&&(b$1.current.value="");}},Te=Se("file",g.context)?"inherit":"#C0C0C0";return jsxs(Fragment,{children:[jsx("input",{type:"file",name:"files",ref:b$1,style:{display:"none"},onChange:$,multiple:true}),jsxs(en,{anchorEl:c,open:E,onClose:e$1,MenuListProps:{"aria-labelledby":"upload-button"},children:[jsxs(Ze,{onPointerUp:()=>te("file"),children:[jsx(Qe,{sx:{color:Te},children:jsx(Pe,{action:"uploadfile",applyInternalStyle:true})}),jsx(Xe,{primary:ce("Upload File(s)"),primaryTypographyProps:{fontSize:"0.875rem",color:Te}})]},"Upload File(s)"),jsxs(Ze,{onPointerUp:()=>te("container"),children:[jsx(Qe,{children:jsx(Pe,{action:"uploadzipfile",applyInternalStyle:true})}),jsx(Xe,{primary:ce("Upload .ZIP Archive"),primaryTypographyProps:{fontSize:"0.875rem"}})]},"Upload .ZIP Archive")]})]})},oa=(c,e,r,l)=>(c._plugincode=e.context.params.pluginCode,c._origformcode=c._code=e.context.params.formCode,et("onrowcheckboxclicked",e,c,r,l)),ia=({value:c,style:e})=>{let[r,l]=dt.useState(false),g=dt.useRef(null);return jsx(re,{title:String(c!=null?c:"").trim()?c:"No data",open:r,arrow:true,children:jsx("div",{ref:g,style:e,onMouseEnter:()=>{g.current&&g.current.scrollWidth>g.current.clientWidth&&l(true);},onMouseLeave:()=>l(false),children:c||""})})},gt=c=>!!(c.readonly&&!c.ignorereadonly),st=c=>{let e=c.replace(/\s/g,""),r=e.lastIndexOf(","),l=e.lastIndexOf("."),g;return r>l?g=e.replace(/\./g,"").replace(",","."):l>r?g=e.replace(/,/g,""):g=e,parseFloat(g)},Qt=(c,e,r,l)=>c===0?"first":c<e?"previous":l>0&&(c+1)*r>=l?"last":"next",ct={rowsPerPage:0,pageIndex:0,serverPaginationEnabled:false,nextToken:"",paginationDirection:"first",previousToken:"",rowCount:0,qId:""},ra={string:"freetext",freetext:"freetext",currency:"price",price:"price",date:"date",datetime:"datetime",number:"number",checkbox:"checkbox"},nn=withTranslation()(memo(function(e$1){var bt,Ct,Dt;let r$1=useRef(false),{runFormEvent:l,viewPort:g$1}=b(),le=e(),{UserDialog:G}=b$1(),se=e$1.properties.name,E=d(se,e$1.properties.pagesize||50),{pageIndex:b$2,pageSize:ie}=E,[q$1,ce]=useState(null),[te,$]=useState(false),[Te,de]=useState("single"),[me,m]=useState([]),[R,_$1]=useState(0),[x,B]=useState(),[T$1,X$1]=useState(),[he,ye]=useState(false),[be,Be]=useState(false),[I,P$1]=useState({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}}),[M,O]=useState(true),[Z$1,Oe]=useState({}),ee=useRef(e$1),ve=useRef(e$1.context.formData);useEffect(()=>{ee.current=e$1;},[e$1]),useEffect(()=>{ve.current=e$1.context.formData;},[e$1.context.formData]);let[sa,an]=useState((bt=e$1.context)==null?void 0:bt.widgetRelatedData),ke=useCallback(async(a,t,i,d,o)=>{$(false),await l({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,formData:t.context.formData,widgetContext:JSON.stringify({referer:d.pathname,parentWidgetId:o,hasParentForm:T.hasParentForm(),originator:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parent:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parentOriginator:{params:t.context.params.originator?t.context.params.originator.params:{}},folderData:t.context.params.folderData}),widgetEvent:U.onTableEditRunActionEvent,widgetName:t.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:a,data:i})}).then(u=>{var w;if(u.meta.requestStatus==="fulfilled"){let y={...u.payload};y.FECommand={...y.FECommand,UpdateFieldAllowedValues:y.fieldAllowedValues,UpdateFormData:y.data,UpdateFormDataItem:{name:t.properties.name,value:(w=y.data)==null?void 0:w[t.properties.name]}},t.methodProvider.execCommands(y.FECommand);}});},[]),Ie=useCallback(async(a,t,i,d,o,u)=>{$(false),u.toggleAllRowsSelected(false),await l({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,widgetContext:JSON.stringify({referer:d.pathname,parentWidgetId:o,hasParentForm:T.hasParentForm(),originator:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parent:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parentOriginator:{params:t.context.params.originator?t.context.params.originator.params:{}},folderData:t.context.params.folderData}),widgetEvent:U.onTableRunBatchActionEvent,widgetName:t.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:a,data:i})}).then(w=>{if(w.meta.requestStatus==="fulfilled"){let y={...w.payload};y.widgetData&&m(Object.values(y.widgetData)),O(true),$(true),y.FECommand&&t.methodProvider.execCommands(y.FECommand);}});},[e$1.context.params.pluginCode,e$1.context.params.formCode,e$1.context.params.guid,e$1.context.params.pGuid,e$1.properties.name,e$1.context.formData]),on=useCallback((a,t,i,d,o,u)=>{a&&(i.properties.alloweditrow?ke("delete",i,JSON.stringify(d),o,u):et(t,i,d,o,u)),P$1({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[e$1.properties.alloweditrow]),yt=useCallback((a,t,i,d,o,u,w)=>{a&&Ie(t,i,d,u,w,o),P$1({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[Ie,P$1]),rn=a=>I.delete.callBackFunc(a),tt=a=>{P$1(a);},{alloweditrow:Ce,backendpagination:ne,colactions:ln,colgrouping:sn,colordering:cn,colresizing:dn,enableuploadfiles:mn,height:un,hideaddbutton:gn,newrecordurl:pt,folders:ze,pagination:fn,pagesize:Ue,rowactions:yn,rowactiontype:Ve,rowclickas:He,rowdensity:pn,rownumber:xn,rowselection:wn,rowvirtualization:hn,search:bn,searchtype:Ge,selectall:Cn,stickyheader:Dn,toolbarInternalActions:Rn,topToolbar:_n,visible:Fn}=e$1.properties,nt=fn===true,Tn=hn!==false&&!nt,In=nt,xt=Ve==="flat"||Ve==="menu"||Ve==="primary",wt=useNavigate(),F=useLocation(),{tabId:v}=e$1,{t:K,i18n:at}=useTranslation(),W$1=(Ct=at==null?void 0:at.language)==null?void 0:Ct.substring(0,2),ht=useCallback((a,t)=>{E.setLastEvaluatedKey(Number(a),t||null);},[E]),We=useCallback(a=>E.getLastEvaluatedKey(Number(a)),[E]),Le=useCallback(async(a,t,i,d,o)=>{var k,L;$(false),a&&(_$1(0),B(null),X$1(ct));let u=Qt(i.pageIndex,b$2,i.pageSize,R),w=We(i.pageIndex-1),y=u==="last"?"":d;he&&u!=="last"&&(u==="next"&&(y=We(i.pageIndex+1)),u==="previous"&&(w=We(i.pageIndex+1))),await l({DataTableMeta:{serverPaginationEnabled:ne,rowsPerPage:i.pageSize,pageIndex:i.pageIndex,nextToken:y,previousToken:w,paginationDirection:u==="last"?"last":t,rowCount:R,qId:o==null?void 0:o.qId,lastRequestLimit:o==null?void 0:o.lastRequestLimit,oppositeDirection:u==="last"||he},pluginCode:e$1.context.params.pluginCode,formCode:e$1.context.params.formCode,guid:e$1.context.params.guid,projectGuid:e$1.context.params.pGuid,pGuid:e$1.context.params.pGuid,widgetContext:JSON.stringify({referer:F.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),originator:(k=e$1.context.params)==null?void 0:k.originator,parent:e$1.context.params,folderData:(L=e$1.context.params)==null?void 0:L.folderData}),widgetEvent:Ce?U.onTableEditDataLoad:U.onTableDataLoad,widgetName:e$1.properties.name.toLowerCase(),formData:e$1.context.formData}).then(ae=>{var ue,N,j,pe,S,qe,ge,xe,Ae;if(ae.meta.requestStatus==="fulfilled"){let z={...ae.payload},U=(ue=z.data)==null?void 0:ue[e$1.properties.name];if(Array.isArray(z.widgetData)&&z.widgetData.length===0&&typeof U=="string"&&U.trim()!==""&&U!=="null"&&U!=="undefined"){let f=JSON.parse(U);m(f!=null?f:{});}else m(Object.values((N=z.widgetData)!=null?N:{})),_$1((pe=(j=z.tableMeta)==null?void 0:j.rowCount)!=null?pe:0),B((qe=(S=z.tableMeta)==null?void 0:S.nextToken)!=null?qe:null),X$1((ge=z.tableMeta)!=null?ge:{}),(xe=z.tableMeta)!=null&&xe.nextToken&&ht(i.pageIndex,(Ae=z.tableMeta)==null?void 0:Ae.nextToken),Be(false),z.widgetRelatedData&&Object.keys(z.widgetRelatedData).length>0&&(ee.current.context.widgetRelatedData=z.widgetRelatedData);O(a),$(true);}});},[ne,Ce,We,he,F.pathname,b$2,e$1.context.formData,e$1.context.params,e$1.properties.name,R,O,$,B,Be,_$1,m,X$1,ht,v]),Mn=useCallback(a=>{if(r$1.current&&!ne){r$1.current=false;return}let t;typeof a=="function"?t=a({pageIndex:b$2,pageSize:ie}):t=a;let i=Qt(t.pageIndex,b$2,t.pageSize,R);if(te&&M&&b$2>0){O(false);return}t.pageIndex!==b$2&&E.setPageIndex(Number(t.pageIndex)),t.pageSize!==ie&&E.setPageSize(Number(t.pageSize)),(ne&&t.pageIndex!==b$2||t.pageSize!==ie)&&(Be(true),i==="last"&&ye(true),i==="first"&&ye(false),Le(false,i,t,x,T$1));},[ne,b$2,R,te,M,ie,Le,x,T$1]);useEffect(()=>{var a;an((a=e$1.context)==null?void 0:a.widgetRelatedData);},[(Dt=e$1.context)==null?void 0:Dt.widgetRelatedData]),useEffect(()=>{r$1.current=true,E.reset(Number(Ue));},[e$1.properties.name,e$1.context.params]),useEffect(()=>{var a;if(Ce){let t=(a=e$1.context.formData)==null?void 0:a[e$1.properties.name];if(t){let i=typeof t=="string"?JSON.parse(t):t;m(i);}}},[e$1.context.formData]),useEffect(()=>{(async()=>{var a,t,i,d;if(e$1.context.enableEventHandlers){if(e$1.context.formLayout==="folders"&&!((t=(a=e$1.context.params)==null?void 0:a.folderData)!=null&&t.id)&&!((d=(i=e$1.context.params)==null?void 0:i.folderData)!=null&&d.isRoot))return;ne?b$2===0?Le(true,"first",{pageIndex:0,pageSize:Ue||100},"",ct):Le(false,"current",{pageIndex:b$2,pageSize:ie},x,T$1):Le(true,"first",{pageIndex:0,pageSize:Ue||100},"",ct);}else $(true);})();},[e$1.properties.name,e$1.context.redrawComponent,Ce,ne]);let je=e$1.methodProvider.findWidgetItem(e$1.id),Ne=[],Ye={};(je.item.properties.datasource.columns||[]).forEach(a=>{var t;Ne[a[1]]=a[0],a[2]&&(Ye[a[1]]=(t=ra[a[2]])!=null?t:"freetext");});let Sn=(je.item._children||[]).some(({properties:a})=>{var i,d;if(!a.item_bottomcalc)return false;let t=(d=(i=Ye[a.item_name])!=null?i:a.item_columntype)!=null?d:a.item_isprice?"price":"freetext";return t==="price"||t==="number"}),Pn=useMemo(()=>{let a$1=[];return (je.item._children||[]).map(({properties:t})=>{var i,d,o,u,w,y,k$1,L,ae,ue,N,j,pe;if(t.item_name.toString()!==""){let S=(i=Ye[t.item_name])!=null?i:"";S||(S=(d=t.item_columntype)!=null?d:"freetext",t.item_columntype||(t.item_isdate===true?S="date":t.item_isdatetime===true?S="datetime":t.item_ischeckbox===true?S="checkbox":t.item_isprice===true?S="price":S="freetext"));let qe=S==="checkbox",ge=S==="price",xe=S==="number",Ae=S==="date",z=S==="datetime",U={};qe?U={accessorKey:t.item_name,muiTableHeadCellProps:{align:(o=t.style.item_textalign)!=null?o:"left"},muiTableBodyCellProps:{align:(u=t.style.item_ctextalign)!=null?u:"left"},header:(w=Ne[t.item_name])!=null?w:t.item_title,Header:()=>{var s;let f=(s=Ne[t.item_name])!=null?s:t.item_title;return t.item_displaytooltip?jsx(re,{title:f,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:f})}):jsx("span",{children:f})},Cell:({row:f})=>{var s;return jsx("span",{style:{borderBottom:"none",padding:"0px",height:"36px"},children:jsx($n,{checked:Array.isArray((s=ee.current.context)==null?void 0:s.widgetRelatedData)&&ee.current.context.widgetRelatedData.includes(f.original._sk),onPointerUp:()=>oa(f.original,ee.current,F,v),style:{margin:0}})})},size:parseInt(t.item_minsize,10)||void 0,enableSorting:(y=t.item_enablesorting)!=null?y:false,enableHiding:(k$1=t.item_visible)!=null?k$1:true,grow:true}:(U={accessorKey:t.item_name.toString(),muiTableHeadCellProps:{align:(L=t.style.item_textalign)!=null?L:"left"},muiTableBodyCellProps:{align:(ae=t.style.item_ctextalign)!=null?ae:"left"},header:(ue=Ne[t.item_name])!=null?ue:t.item_title.toString(),Header:()=>{var s;let f=(s=Ne[t.item_name])!=null?s:t.item_title.toString();return t.item_displaytooltip?jsx(re,{title:f,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:f})}):jsx("span",{children:f})},size:parseInt(t.item_minsize,10)||void 0,enableSorting:(N=t.item_enablesorting)!=null?N:false,enableHiding:t.item_visible===true,grow:true,muiEditTextFieldProps:{required:true,error:!!(Z$1!=null&&Z$1.firstName),helperText:Z$1==null?void 0:Z$1.firstName,onFocus:()=>Oe({...Z$1,[t.item_name.toString()]:void 0})},Cell:({cell:f})=>{var A;let s=(A=f.getValue())!=null?A:"";if(ge&&s){let p=st(s);if(!isNaN(p)){let h=t.item_fixedlocale||"",Y=t.item_format==="fixed-locale"&&h?h:W$1||void 0,D=t.item_inputfield&&ve.current&&ve.current[t.item_inputfield]||""||t.item_currency||"",De=t.item_format==="locale"?k(W$1!=null?W$1:""):t.item_format==="fixed-locale"&&h?k(h):void 0,Re=D||De||"";try{let we=t.item_currencydisplay||"";Re&&we!==""?s=new Intl.NumberFormat(Y,{style:"currency",currency:Re,currencyDisplay:we,minimumFractionDigits:2,maximumFractionDigits:2}).format(p):s=new Intl.NumberFormat(Y,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(p);}catch(we){s=p.toFixed(2);}}}if(xe&&s){let p=st(s);isNaN(p)||(s=p.toLocaleString());}if(Ae&&s){let p=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(s)){let h=a(s);if(h.isValid())return h}return a(s,"DD.MM.YYYY",true)})();if(p.isValid())try{s=new Intl.DateTimeFormat(W$1||void 0,{dateStyle:"short"}).format(p.toDate());}catch(h){}}if(z&&s){let p=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(s)){let h=a(s);if(h.isValid())return h}return a(s,"DD.MM.YYYY HH:mm",true)})();if(p.isValid())try{s=new Intl.DateTimeFormat(W$1||void 0,{dateStyle:"short",timeStyle:"short"}).format(p.toDate());}catch(h){}}return t.item_displaytooltip?jsx(ia,{value:s,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:`${parseInt(t.item_maxsize,10)||150}px`,minWidth:"50px",cursor:"default"}}):jsx(Fragment,{children:s})}},t.item_bottomcalc&&(ge||xe)&&(U.muiTableFooterCellProps={align:(pe=(j=t.style)==null?void 0:j.item_ctextalign)!=null?pe:"left"},U.Footer=({table:f})=>{var Y,C;let s=(Y=f.getState().creatingRow)==null?void 0:Y.id,A=(C=f.getState().editingRow)==null?void 0:C.id,p=f.getFilteredRowModel().rows.reduce((D,De)=>{if(De.id===s||De.id===A)return D;let Re=De.getValue(t.item_name.toString()),we=st(String(Re!=null?Re:""));return D+(isNaN(we)?0:we)},0),h=p.toLocaleString(W$1||void 0,{minimumFractionDigits:ge||xe?2:0,maximumFractionDigits:ge||xe?2:0});if(ge){let D=t.item_fixedlocale||"",De=t.item_format==="fixed-locale"&&D?D:W$1||void 0,we=t.item_inputfield&&ve.current&&ve.current[t.item_inputfield]||""||t.item_currency||"",Hn=t.item_format==="locale"?k(W$1!=null?W$1:""):t.item_format==="fixed-locale"&&D?k(D):void 0,Rt=we||Hn||"",_t=t.item_currencydisplay||"";if(Rt&&_t!=="")try{h=new Intl.NumberFormat(De,{style:"currency",currency:Rt,currencyDisplay:_t,minimumFractionDigits:2,maximumFractionDigits:2}).format(p);}catch(ma){h=p.toFixed(2);}}return jsx("b",{children:h})})),Ae?U.sortingFn=(f,s,A)=>{let p=f.getValue(A),h=s.getValue(A),Y=C=>{if(!C)return a("1900-01-01");if(/^\d{4}-\d{2}-\d{2}/.test(C)){let D=a(C);if(D.isValid())return D}return a(C,"DD.MM.YYYY",true)};try{let C=Y(p),D=Y(h);return C.isBefore(D)?-1:C.isAfter(D)?1:0}catch(C){return 0}}:z?U.sortingFn=(f,s,A)=>{let p=f.getValue(A),h=s.getValue(A),Y=C=>{if(!C)return a("1900-01-01T00:00:00");if(/^\d{4}-\d{2}-\d{2}/.test(C)){let D=a(C);if(D.isValid())return D}return a(C,"DD.MM.YYYY HH:mm",true)};try{let C=Y(p),D=Y(h);return C.isBefore(D)?-1:C.isAfter(D)?1:0}catch(C){return 0}}:(ge||xe)&&(U.sortingFn=(f,s,A)=>{let p=parseFloat(f.getValue(A))||0,h=parseFloat(s.getValue(A))||0;return p-h}),He&&He!=="none"&&(U.Cell=({row:f})=>jsx("div",{style:{cursor:"pointer",width:"100%",padding:"0.7em"},onPointerUp:()=>{var A,p,h,Y,C,D;let s={pluginCode:f.original._plugincode,formCode:f.original._origformcode,guid:null,originator:(A=ee.current.context.params)==null?void 0:A.originator,pGuid:(p=ee.current.context.params)==null?void 0:p.pGuid,folderData:ee.current.context.params.folderData};He==="new"&&(Y=(h=ee.current.context)==null?void 0:h.params)!=null&&Y.modalCloseFn&&((D=(C=ee.current.context)==null?void 0:C.params)==null||D.modalCloseAndOpenFn(s));},children:f.getValue(t.item_name.toString())})),a$1.push(U);}}),a$1},[W$1,Z$1,He,v]),vn=a=>{ce(a.currentTarget);},kn=()=>{ce(null);},Ln=useCallback(()=>{var t,i;if(!ze)return null;var a=(i=(t=e$1.context.params)==null?void 0:t.folderData)==null?void 0:i.captions;return a==null||a.length===0?null:(a=a.slice(1),jsx("span",{style:{display:"flex",alignItems:"center"},children:a.map((d,o)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[d,o<a.length-1&&jsx(d$1,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}},`chevron-${o}`)]},`caption-${o}`))}))},[ze,e$1.context.params.folderData]),Nn={density:pn,expanded:true,grouping:[],isFullScreen:false,pagination:{pageIndex:b$2||0,pageSize:Number(ie)||Ue},columnVisibility:{id:false}},An=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,w,y,k,L,ae;let o=d.original;i.push({_sk:(u=o._sk)!=null?u:null,_code:(w=o._fcode)!=null?w:o._code,_origformcode:(k=(y=o._origformcode)!=null?y:o._fcode)!=null?k:o._code,_plugincode:(L=o._plcode)!=null?L:o._plugincode,_desc:(ae=o._desc)!=null?ae:null});}),i.length>0&&Ie("createsigncontainer",e$1,i,F,v,t);},[Ie,e$1,F,v]),En=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,w,y,k,L;let o=d.original;i.push({_sk:(u=o._sk)!=null?u:null,_code:(w=o._fcode)!=null?w:o._code,_origformcode:(k=(y=o._origformcode)!=null?y:o._fcode)!=null?k:o._code,_plugincode:(L=o._plcode)!=null?L:o._plugincode});}),i.length>0&&Ie("download",e$1,i,F,v,t);},[Ie,e$1,F,v]),Bn=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,w,y,k,L;let o=d.original;i.push({_sk:(u=o._sk)!=null?u:null,_code:(w=o._fcode)!=null?w:o._code,_origformcode:(k=(y=o._origformcode)!=null?y:o._fcode)!=null?k:o._code,_plugincode:(L=o._plcode)!=null?L:o._plugincode});}),tt({delete:{showDialog:true,dialogTitle:K("Delete")+" ?",dialogContent:K("Are you certain that you wish to delete selected records?"),buttonAgree:K("Continue"),buttonDisagree:K("Close"),callBackFunc:d=>yt(d,"delete",e$1,i,t,F,v)}});},[tt,yt,K,e$1,F,v]),On=useCallback(async({values:a,table:t})=>{ke("add",e$1,JSON.stringify(a),F,v),t.setCreatingRow(null);},[ke,e$1,F,v]),zn=useCallback(async({values:a,table:t,row:i})=>{let d={...i.original,...a};ke("edit",e$1,JSON.stringify(d),F,v),t.setEditingRow(null);},[ke,e$1,F,v]),[ca,Un]=useState(null);if(!Fn)return null;let Je=Se("file",e$1.context)?"primary":"#C0C0C0",Vn=Se("file",e$1.context)?"contained":"outlined";return jsxs(Fragment,{children:[ze&&jsx("div",{style:{paddingBottom:"0.8rem",fontSize:"0.85rem",color:"#666",marginLeft:"0.2rem"},children:Ln()}),jsx("div",{style:{maxWidth:e$1.context.isModal?g$1.width-30:void 0},children:jsx(Suspense,{fallback:jsx(qn,{}),children:jsx(ta,{locale:W$1,columns:Pn,enableBottomToolbar:In,enableTableFooter:Sn,createDisplayMode:"row",editDisplayMode:"row",enableEditing:false,enableColumnActions:ln,enableColumnOrdering:cn,enableColumnResizing:dn,enableGlobalFilter:bn,enableGlobalFilterModes:true,globalFilterModeOptions:[Ge||"startsWith"],globalFilterFn:Ge||"startsWith",enableGrouping:sn,enablePagination:nt,manualPagination:ne!=null?ne:false,enableRowActions:xt,enableRowNumbers:xn,enableRowSelection:wn,enableRowVirtualization:Tn,enableSelectAll:Cn,enableStickyHeader:Dn,enableToolbarInternalActions:Rn,enableTopToolbar:_n,onCreatingRowSave:On,onEditingRowSave:zn,darkMode:false,data:me,icons:{SaveIcon:()=>jsx(r,{color:na,style:{fontSize:"1.2rem"}}),CancelIcon:()=>jsx(P,{color:"gray",style:{fontSize:"1.2rem"}})},initialState:Nn,isLoading:!te,muiTableContainerProps:{sx:{maxHeight:un}},name:e$1.properties.name,pageIndex:b$2,pageSize:ie,muiPaginationProps:{rowsPerPageOptions:[50,100,300,500],disabled:be},onPaginationChange:Mn,positionActionsColumn:"last",displayColumnDefOptions:{"mrt-row-actions":xt?{header:"",minSize:g$1.isMobileDevice?75:270,enableHiding:false}:void 0},rowOnDoubleClick:a=>{!Ce&&!gt(e$1.properties)&&et("edit",e$1,a,F,v);},rowCount:ne?R:void 0,renderToolbarInternalActions:({table:a})=>jsx(Xt,{children:!g$1.isMobileDevice&&jsxs(Fragment,{children:[!Ce&&jsx(_,{table:a}),jsx(Y,{table:a}),jsx(W,{table:a}),jsx(X,{table:a}),!e$1.context.isModal&&jsx(Z,{table:a})]})}),renderTopToolbarCustomActions:({table:a})=>{var t$1,i,d,o,u,w,y,k,L,ae;return jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[a.getSelectedRowModel().rows.length===0&&ze&&e$1.context.formLayout==="folders"&&jsx(Fragment,{children:jsx(re,{title:(i=(t$1=e$1.properties)==null?void 0:t$1.newFolderLabel)!=null?i:K("New Folder"),children:jsx(Fe,{style:{marginRight:"5px"},color:"primary",onPointerUp:()=>e$1.context.isModal||e$1.context.hasParentForm?e$1.methodProvider.eventDispatcher({widgetName:e$1.properties.name.toLowerCase(),widgetValue:null,widgetEvent:U.onFolderCreateRecordEvent,widgetContext:JSON.stringify({referer:F.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),parentOriginator:{params:e$1.context.params.originator?e$1.context.params.originator.params:{}},originator:{params:e$1.context.params,widgetName:e$1.properties.name.toLowerCase()},parent:{widgetName:e$1.properties.name.toLowerCase(),params:e$1.context.params},isModal:e$1.context.isModal,folderData:e$1.context.params.folderData})}):wt(`${F.pathname}/new`,{state:{from:F.pathname}}),variant:"outlined",children:jsx(t,{})})})}),a.getSelectedRowModel().rows.length===0&&!gn&&jsx(Fragment,{children:jsx(re,{title:(o=(d=e$1.properties)==null?void 0:d.addrecordlabel)!=null?o:K("Add Record"),children:jsx(Fe,{disabled:gt(e$1.properties),color:"primary",sx:{color:Je,borderColor:Je},style:{marginRight:"5px"},onPointerUp:()=>{if(!Se("file",e$1.context)){le({toastID:nanoid(11),msg:K("Please select a folder before adding a document"),clearQueue:false,hideProgressBar:false});return}if(Ce){let ue={};(je.item._children||[]).forEach(({properties:N})=>{var pe,S;if(!N.item_increment||!N.item_name)return;let j=(pe=Ye[N.item_name])!=null?pe:"";j||(j=(S=N.item_columntype)!=null?S:"freetext",N.item_columntype||(N.item_isdate?j="date":N.item_isdatetime?j="datetime":N.item_ischeckbox?j="checkbox":N.item_isprice?j="price":j="freetext")),j==="number"&&(ue[N.item_name.toString()]=me.length+1);}),Object.keys(ue).length>0?a.setCreatingRow(V(a,ue)):a.setCreatingRow(true);}else return pt?wt(`${F.pathname}/${pt}`,{state:{from:F.pathname}}):e$1.methodProvider.eventDispatcher({widgetName:e$1.properties.name.toLowerCase(),widgetValue:null,widgetEvent:U.onTableCreateRecordEvent,widgetContext:JSON.stringify({referer:F.pathname,parentWidgetId:v,hasParentForm:true,parentOriginator:{params:e$1.context.params.originator?e$1.context.params.originator.params:{}},originator:{params:e$1.context.params,widgetName:e$1.properties.name.toLowerCase()},parent:{widgetName:e$1.properties.name.toLowerCase(),params:e$1.context.params},isModal:e$1.context.isModal,folderData:e$1.context.params.folderData})})},variant:"outlined",children:jsx(p,{})})})}),a.getSelectedRowModel().rows.length===0&&mn&&jsx(Fragment,{children:jsx(re,{title:(w=(u=e$1.properties)==null?void 0:u.uploadFilesLabel)!=null?w:K("Upload Files"),children:jsx(Fe,{color:"primary",onPointerUp:vn,variant:"outlined",children:jsx(h,{})})})}),a.getSelectedRowModel().rows.length>0&&jsxs(Fragment,{children:[e$1.context.formLayout==="folders"&&a.getSelectedRowModel().rows.length>1&&jsx(Fragment,{children:jsx(re,{title:K("Create Container"),children:jsx(Fe,{style:{marginRight:"5px",color:Je,borderColor:Je},onPointerUp:()=>{if(!Se("file",e$1.context)){le({toastID:nanoid(11),msg:K("Please select a folder before creating a container"),clearQueue:false,hideProgressBar:false});return}An(a.getSelectedRowModel().rows,a);},variant:Vn,children:jsx(q,{})})})}),jsxs(Fragment,{children:[jsx(re,{title:(k=(y=e$1.properties)==null?void 0:y.downloadLabel)!=null?k:K("Download"),children:jsx(Fe,{style:{marginRight:"5px"},onPointerUp:()=>En(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(g,{})})}),jsx(re,{title:(ae=(L=e$1.properties)==null?void 0:L.deleteLabel)!=null?ae:K("Delete"),children:jsx(Fe,{style:{marginRight:"5px"},onPointerUp:()=>Bn(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(N,{})})})]})]}),jsx(aa,{anchorEl:q$1,handleClose:kn,setUploadMode:de,uploadMode:Te,props:e$1,setLoaded:$})]})},...la(e$1,yn,Ve,g$1.isMobileDevice,tt,on)},W$1)})}),jsx(G,{...I.delete,handleDialogClose:rn})]})})),Pe=c=>{let e=null,r=c.action,l$1=c.applyInternalStyle?{fontSize:"1em",marginRight:"0.5em"}:{};return r==="open"?e=jsx(n,{style:l$1}):r==="copy"?e=jsx(i,{style:l$1}):r==="confirm"?e=jsx(w,{style:{...l$1,fontSize:"1.6em"}}):r==="edit"?e=jsx(A,{style:l$1}):r==="editrow"?e=jsx(n,{style:l$1}):r==="amend"?e=jsx(b$2,{style:l$1}):r==="delete"?e=jsx(N,{style:l$1}):r==="lock"?e=jsx(y,{style:l$1}):r==="unlock"?e=jsx(x,{style:l$1}):r==="print"?e=jsx(C,{style:l$1}):r==="preview"?e=jsx(n,{style:l$1}):r==="sign"?e=jsx(q,{style:l$1}):r==="download"?e=jsx(l,{style:l$1}):r==="uploadfile"?e=jsx(O,{style:l$1}):r==="uploadzipfile"&&(e=jsx(o,{style:l$1})),e},la=(c,e,r,l,g,le)=>{var de,me;let G=typeof e=="string"?JSON.parse(e):e!=null?e:[],se=useLocation(),{t:E}=useTranslation(),{tabId:b}=c,ie=(me=(de=c.properties)==null?void 0:de.rowactionlabels)!=null?me:{},q=(m,R)=>ie[m]||E(R),ce={color:"text.secondary","&:hover":{color:"primary.main"},"&:focus":{color:"primary.main"},fontSize:"1.1em",marginRight:"0.5em"},te=(m,R,_)=>m==="delete"?()=>{g({delete:{showDialog:true,dialogTitle:`${q("delete","Delete")} ?`,dialogContent:q("deleteConfirmContent","Are you certain that you wish to delete this record?"),buttonAgree:q("deleteConfirmAgree","Continue"),buttonDisagree:q("deleteConfirmDisagree","Close"),callBackFunc:x=>le(x,"delete",c,_,se,b)}});}:m==="editrow"?()=>{R.closeMenu(),R.table.setEditingRow(R.row);}:()=>{var x;(x=R.closeMenu)==null||x.call(R),et(m,c,_,se,b);},$=({entryType:m,mode:R})=>{let _=m.row.original,[x,B]=dt.useState(null),T=I=>{B(I.currentTarget);},X=()=>{B(null);},he=()=>jsx(Fragment,{children:Object.entries(G).map(([I,P])=>{if(!P)return null;let M=I.replace("action_",""),O=te(M,m,_);return jsx("span",{children:jsx(re,{title:q(M,M.charAt(0).toUpperCase()+M.slice(1)),children:jsx(Kt,{sx:ce,onPointerUp:O,children:jsx(Pe,{action:M})})})},I)})}),ye={};if(_._primAct){let I=_._primAct;if(Object.values(tn).includes(I)){Object.values(ut).includes(I)&&(ye.edit=true,G.action_edit&&delete G.action_edit);let P="action_"+I.toLowerCase();ye[P]=true,G[P]&&delete G[P];}}return jsxs(Xt,{sx:{display:"flex",flexWrap:"nowrap",gap:"8px",justifyContent:"center",alignItems:"center"},children:[R===0&&jsx(he,{}),R===1&&jsxs(Fragment,{children:[jsx(()=>jsx(Fragment,{children:Object.entries(ye).map(([I,P])=>{if(!P)return null;let M=I.replace("action_",""),O=te(M,m,_),Z=Object.values(ut).includes(M.toUpperCase()),Oe=M.charAt(0).toUpperCase()+M.slice(1),ee=Oe==="Edit"?q("open","Open"):q(M,Oe);return jsx(Fe,{onClick:O,startIcon:jsx(Pe,{action:M==="edit"?"open":M}),variant:"contained",size:"small",sx:{textTransform:"none",fontSize:"0.75rem",height:"28px",borderRadius:"4px",boxShadow:"none",backgroundColor:Z?"actionbtnok.main":"regularbtn.main",color:"#fff","&:hover":{backgroundColor:Z?"actionbtnok.hover":"regularbtn.hover",boxShadow:"none"},minInlineSize:"7.5em"},children:ee},I)})}),{}),jsx(()=>{let I=x?x.getBoundingClientRect():null;return jsxs("span",{style:{paddingLeft:"1.5em"},children:[jsx(Kt,{sx:ce,onClick:T,id:"dropdown-button",children:jsx(ea,{})}),jsx(en,{anchorEl:x,open:!!x,onClose:X,PaperProps:{sx:{borderRadius:2,minWidth:180,py:1,boxShadow:3,top:I?`${I.top+5}px !important`:"auto",left:I?`${I.left+15}px !important`:"auto",zIndex:P=>P.zIndex.modal+1}},children:Object.entries(G).map(([P,M])=>{if(!M)return null;let O=P.replace("action_","");return jsxs(Ze,{onClick:()=>{X(),te(O,m,_)();},sx:{px:2,py:1},children:[jsx(Qe,{sx:{minWidth:"unset",mr:1},children:jsx(Pe,{action:O==="print"?"preview":O,applyInternalStyle:true})}),jsx(Xe,{primaryTypographyProps:{fontSize:"0.875rem"},children:q(O,O.charAt(0).toUpperCase()+O.slice(1))})]},P)})})]})},{})]})]})},Te=m=>{let R=m.row.original;return [jsx(Kn,{onClickAway:()=>{var _;return (_=m.closeMenu)==null?void 0:_.call(m)},children:jsx(Qn,{sx:{minWidth:"12em",py:0,background:"none"},children:Object.entries(G).map(([_,x])=>{if(!x)return null;let B=_.replace("action_",""),T=te(B,m,R);return jsxs(Ze,{disabled:gt(c.properties),onPointerUp:T,children:[jsx(Qe,{children:jsx(Pe,{action:B==="print"?"preview":B,applyInternalStyle:true})}),jsx(Xe,{primaryTypographyProps:{fontSize:"0.875rem"},children:q(B,B.charAt(0).toUpperCase()+B.slice(1))})]},_)})})},"row-action-menu")]};return r==="flat"&&!l?{renderRowActions:m=>jsx($,{entryType:m,mode:0})}:r==="menu"||r!=="none"&&l?{renderRowActionMenuItems:m=>Te(m)}:r==="primary"?{renderRowActions:m=>jsx($,{entryType:m,mode:1})}:{}};nn.displayName="_Datatable";var Ya=nn;export{Ya as Datatable};