UNPKG

@egovernments/digit-ui-module-hcmmicroplanning

Version:

HCM-Microplanning

1 lines 325 kB
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("@egovernments/digit-ui-react-components"),n=require("react"),r=e(n),o=require("react-router-dom"),i=require("react-i18next"),a=require("@egovernments/digit-ui-svg-components"),l=require("@egovernments/digit-ui-components"),u=e(require("geojson-validation")),s=e(require("ajv")),c=require("uuid"),d=e(require("exceljs")),p=e(require("shpjs")),f=e(require("jszip")),m=require("react-drag-drop-files"),v=e(require("leaflet"));require("leaflet/dist/leaflet.css");var h=e(require("chroma-js"));require("react-router-dom/cjs/react-router-dom.min"),require("@egovernments/digit-ui-libraries"),require("xlsx");var g=e(require("axios"));require("react-dom");var y=require("react-query");const E=n.createContext(),b={},S=function(e,t){switch(void 0===e&&(e=b),t.type){case"SETINITDATA":return{...e,...t.state};default:return e}},C=()=>n.useContext(E),O=e=>{let{children:t}=e;const[o,i]=n.useReducer(S,b);return r.createElement(E.Provider,{value:{state:o,dispatch:i}},t)},N="Excel",w="boundaryCode",T={GeoJSON:"application/geo+json",Shapefile:"application/shapefile",Excel:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},D=[{percent:0,color:"#edd1cf"},{percent:100,color:"#b52626"}],R="MICROPLAN_BOUNDARY_DATA_SHEET",I=()=>{const{tourState:e,setTourState:a}=t.useTourState(),{state:l}=C();return i.useTranslation(),o.useLocation(),r.createElement(n.Fragment,null,r.createElement(t.Tutorial,{tutorial:e,updateTutorial:a,theme:{zIndex:500,primaryColor:"#C84C0E"}}),r.createElement("div",{className:"wbh-header"},r.createElement(t.Help,{startTour:()=>{null!=l&&l.tourStateData&&a(l.tourStateData)},labelClassName:"help-label"})))},A=e=>{const{t:u}=i.useTranslation(),s=o.useHistory(),{id:c=""}=Digit.Hooks.useQueryParams();return r.createElement(n.Fragment,null,r.createElement(o.Link,{to:`/${window.contextPath}/employee/microplanning/create-microplan?id=${c}`},r.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",padding:"2rem","font-weight":"700","font-size":"2rem",color:"rgb(0,0,0)"}},u("CREATE_MICROPLAN_GUIDELINES"))),r.createElement(l.ActionBar,{className:"guideline-actionbar-content"},r.createElement(t.Button,{type:"button",className:"custom-button",label:u("GUIDELINES_NEXT"),onButtonClick:()=>{s.push(`/${window.contextPath}/employee/microplanning/create-microplan?id=${c}`)},isSuffix:!0,variation:"primary",textStyles:{padding:0,margin:0}},r.createElement(a.ArrowForward,{className:"icon",width:"1.5rem",height:"1.5rem",fill:"rgb(255,255,255)"}))))},P=function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const e=1&o?t:n;if(e){try{L(r,1,e(this.v))}catch(e){L(r,2,e)}return r}return this}return this.o=function(e){try{const o=e.v;1&e.s?L(r,1,t?t(o):o):n?L(r,1,n(o)):L(r,2,o)}catch(e){L(r,2,e)}},r},e}();function L(e,t,n){if(!e.s){if(n instanceof P){if(!n.s)return void(n.o=L.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(L.bind(null,e,t),L.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}function M(e){return e instanceof P&&1&e.s}function k(e,t){var n,r=-1;e:{for(var o=0;o<t.length;o++){var i=t[o][0];if(i){var a=i();if(a&&a.then)break e;if(a===e){r=o;break}}else r=o}if(-1!==r){do{for(var l=t[r][1];!l;)r++,l=t[r][1];var u=l();if(u&&u.then){n=!0;break e}var s=t[r][2];r++}while(s&&!s());return u}}const c=new P,d=L.bind(null,c,2);return(n?u.then(p):a.then(function n(a){for(;;){if(a===e){r=o;break}if(++o===t.length){if(-1!==r)break;return void L(c,1,u)}if(i=t[o][0]){if((a=i())&&a.then)return void a.then(n).then(void 0,d)}else r=o}do{for(var l=t[r][1];!l;)r++,l=t[r][1];var u=l();if(u&&u.then)return void u.then(p).then(void 0,d);var s=t[r][2];r++}while(s&&!s());L(c,1,u)})).then(void 0,d),c;function p(e){for(;;){var n=t[r][2];if(!n||n())break;r++;for(var o=t[r][1];!o;)r++,o=t[r][1];if((e=o())&&e.then)return void e.then(p).then(void 0,d)}L(c,1,e)}}function x(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var j=[{id:0,name:"MICROPLAN_DETAILS",component:"MicroplanDetails",checkForCompleteness:!0},{id:1,name:"UPLOAD_DATA",component:"Upload",checkForCompleteness:!0},{id:2,name:"HYPOTHESIS",component:"Hypothesis",checkForCompleteness:!0},{id:3,name:"FORMULA_CONFIGURATION",component:"RuleEngine",checkForCompleteness:!0},{id:4,name:"MAPPING",component:"Mapping",checkForCompleteness:!1},{id:5,name:"MICROPLAN_GENERATION",component:"MicroplanPreview",checkForCompleteness:!1}];const U=e=>{let{headerBarMain:o,headerBarEnd:i,popupStyles:a,children:l={},actionCancelLabel:u,actionCancelOnSubmit:s,actionSaveLabel:c,actionSaveOnSubmit:d,error:p,setError:f,formId:m,isDisabled:v,hideSubmit:h,style:g={},footerLeftButtonstyle:y={},footerRightButtonstyle:E={},footerLeftButtonBody:_,footerRightButtonBody:b,popupModuleMianStyles:S,headerBarMainStyle:C,isOBPSFlow:O=!1,popupModuleActionBarStyles:N={}}=e;return Digit.Utils.browser.isMobile(),n.useEffect(()=>(document.body.style.overflowY="hidden",()=>{document.body.style.overflowY="auto"}),[]),r.createElement(t.PopUp,null,r.createElement("div",{className:"popup-module",style:a},r.createElement(t.HeaderBar,{main:o,end:i,style:C||{}}),r.createElement("div",{className:"popup-module-main",style:S||{}},l,r.createElement("div",{className:"popup-module-action-bar",style:H(O,N)},u||_?r.createElement(t.ButtonSelector,{textStyles:{margin:"0px"},ButtonBody:_,theme:"border",label:u,onSubmit:s,style:Object.keys(g).length>0?g:y}):null,h?null:r.createElement(t.ButtonSelector,{textStyles:{margin:"0px"},ButtonBody:b,label:c,onSubmit:d,formId:m,isDisabled:v,style:Object.keys(g).length>0?g:E})))),p&&r.createElement(t.Toast,{label:p,onClose:()=>f(null),type:"error"}))},H=(e,t)=>e?mobileView?{position:"absolute",bottom:"5%",right:"10%",left:window.location.href.includes("employee")?"0%":"7%"}:{marginRight:"18px"}:t,F=e=>{let{closeModal:t,LeftButtonHandler:n,RightButtonHandler:o,footerLeftButtonBody:i,footerRightButtonBody:l,header:u,bodyText:s,body:c,popupStyles:d,headerBarMainStyle:p,popupModuleActionBarStyles:f,hideSubmit:m,closeButton:v=!1,actionCancelLabel:h}=e;return r.createElement(U,{headerBarMain:u,headerBarEnd:v?r.createElement("button",{type:"button",className:"microplan-close-button",onClick:t}," ",r.createElement(a.Close,{width:"1.5rem",height:"1.5rem",fill:"#000000"})):"",actionCancelOnSubmit:n,actionSaveOnSubmit:o,formId:"microplanning",popupStyles:{width:"33.375rem",borderRadius:"0.25rem",...d||{}},headerBarMainStyle:{margin:0,width:"33.375rem",overflow:"hidden",...p||{}},popupModuleMianStyles:{margin:0,padding:0},popupModuleActionBarStyles:f||{justifyContent:"space-between",padding:"1rem"},style:{},hideSubmit:m||!1,footerLeftButtonstyle:{padding:0,alignSelf:"flex-start",height:"fit-content",textStyles:{fontWeight:"600"},backgroundColor:"rgba(255, 255, 255, 1)",color:"#C84C0E",minWidth:"15.063rem",border:"0.063rem solid #C84C0E"},footerRightButtonstyle:{padding:0,alignSelf:"flex-end",height:"fit-content",textStyles:{fontWeight:"500"},backgroundColor:"#C84C0E",color:"rgba(255, 255, 255, 1)",minWidth:"15.063rem",boxShadow:"0px -2px 0px 0px rgba(11, 12, 12, 1) inset"},footerLeftButtonBody:i,footerRightButtonBody:l,actionCancelLabel:h},s&&r.createElement("div",{className:"modal-body"},r.createElement("p",{className:"modal-main-body-p"},s)),c||"")},B=new s({allErrors:!0});B.addKeyword("isRequired"),B.addKeyword("isLocationDataColumns"),B.addKeyword("isRuleConfigureInputs"),B.addKeyword("isFilterPropertyOfMapSection"),B.addKeyword("isVisualizationPropertyOfMapSection"),B.addKeyword("toShowInMicroplanPreview"),u.define("Position",e=>{let t=[];return(e[0]<-180||e[0]>180)&&t.push("Location Coordinates Error: the x must be between -180 and 180"),(e[1]<-90||e[1]>90)&&t.push("Location Coordinates Error: the y must be between -90 and 90"),t});const V=e=>{let{uploadedData:o,resourceMapping:i,setResourceMapping:a,schema:u,setToast:s,hierarchy:c,close:d,t:p}=e;if(!o)return r.createElement("div",{className:"spatial-data-property-mapping"}," ",p("NO_DATA_TO_DO_MAPPING"));const f=n.useRef([]),[m,v]=n.useState(null),[h,g]=n.useState(0),y=n.useRef(null);n.useEffect(()=>{null!==m&&g(0)},[m]),n.useEffect(()=>{if(h<3)g(e=>e+1);else if(null!==m&&f.current[m])try{const e=f.current[m],t=f.current[m].children[1];if(e){const t=y.current,n=e.getBoundingClientRect(),r=t.getBoundingClientRect();t.scrollTo({top:t.scrollTop+(n.top-r.top)-100,behavior:"smooth"})}t&&t.focus()}catch(e){console.error("Error scrolling to element:",e)}},[h,m]),n.useEffect(()=>{if(null!==m){const e=new MutationObserver(()=>{g(e=>e+1)});return f.current[m]&&e.observe(f.current[m],{childList:!0,subtree:!0}),()=>e.disconnect()}},[m]);const[E,_]=n.useState([]),[b,S]=n.useState([]);n.useEffect(()=>{if(!u||!u.schema||!u.schema.Properties)return s({state:"error",message:p("ERROR_VALIDATION_SCHEMA_ABSENT")});const e=Object.keys(u.schema.Properties);if(e){const t=u&&!u.doHierarchyCheckInUploadedData?e:[...c,...e];S(t)}},[u]),n.useEffect(()=>{var e;const t=new Set;null==o||null===(e=o.features)||void 0===e||e.forEach(e=>{Object.keys(e.properties).forEach(e=>t.add(e))});for(const e of t)e.length<2&&(s({state:"error",message:p("ERROR_FIELD_LENGTH")}),d());_(e=>[...e,...t])},[o]);const C=e=>{let{id:t,index:o}=e;const[u,s]=n.useState("");n.useEffect(()=>{const e=i.find(e=>e.mappedTo===t);e?s({code:e.mappedFrom}):s()},[t,i]);const c=e=>{v(e===m?null:e)};return r.createElement("div",{ref:e=>{f.current[o]=e},onClick:()=>c(o),onKeyDown:()=>c(o)},r.createElement(l.Dropdown,{variant:"select-dropdown",t:p,isMandatory:!1,option:null==E?void 0:E.map(e=>({code:e})),selected:u,optionKey:"code",select:e=>{const n=e.code;s(e),a(e=>[...e.filter(e=>!(e.mappedTo===t||e.mappedFrom===n)),{mappedTo:t,mappedFrom:n}])},style:{width:"100%",backgroundColor:"rgb(0,0,0,0)"},showToolTip:!0}))},O=n.useMemo(()=>[{Header:p("COLUMNS_IN_TEMPLATE"),accessor:"COLUMNS_IN_TEMPLATE"},{Header:p("COLUMNS_IN_USER_UPLOAD"),accessor:"COLUMNS_IN_USER_UPLOAD",Cell:e=>{let{cell:{value:t},row:{index:o}}=e;return n.useMemo(()=>r.createElement(C,{key:t,id:t,index:o}),[t,o])}}],[E,a,i,p,f]),N=n.useMemo(()=>b.map(e=>({COLUMNS_IN_TEMPLATE:p(e),COLUMNS_IN_USER_UPLOAD:e})),[b]);return r.createElement("div",{className:"spatial-data-property-mapping",ref:y},r.createElement(t.Table,{customTableWrapperClassName:"",t:p,disableSort:!0,autoSort:!1,manualPagination:!1,isPaginationRequired:!0,data:N,columns:O,getCellProps:e=>({style:{}}),getHeaderProps:e=>({style:{}})}))},G=e=>{var o,a,l,u,s;const{t:c}=i.useTranslation(),d=null==e?void 0:e.sheetsData,[p,f]=n.useState(Object.keys(d).length>0?Object.keys(d)[0]:void 0);return r.createElement("div",{className:"preview-data "},r.createElement("div",{className:"operational-buttons",style:{...null==e?void 0:e.btnStyle}},r.createElement(t.Button,{label:c("BUTTON_BACK"),variation:"secondary",icon:r.createElement(t.SVG.ArrowBack,{height:"2rem",width:"2rem",fill:"#C84C0E"}),type:"button",onButtonClick:()=>null==e?void 0:e.onBack()}),r.createElement(t.Button,{label:c("BUTTON_DOWNLOAD"),variation:"secondary",icon:r.createElement(t.DownloadIcon,{height:"1.25rem",width:"1.25rem",fill:"#C84C0E"}),type:"button",onButtonClick:()=>null==e?void 0:e.onDownload()})),r.createElement("div",{className:"excel-wrapper"},(null==e||null===(o=e.errorLocationObject)||void 0===o?void 0:o[p])&&r.createElement("p",{className:"error-user-directions"},c("USER_DIRECTIONS_FOR_ERROR_MESSAGE")),r.createElement("div",{key:null==d?void 0:d[p],className:"sheet-wrapper",style:null!=e&&null!==(a=e.errorLocationObject)&&void 0!==a&&a[p]?{height:"72.5vh"}:{}},r.createElement("table",{className:"excel-table"},r.createElement("thead",null,r.createElement("tr",null,null==d||null===(l=d[p])||void 0===l||null===(u=l[0])||void 0===u?void 0:u.filter(e=>e).map(e=>r.createElement("th",{key:e},c(e))))),r.createElement("tbody",null,null==d||null===(s=d[p])||void 0===s?void 0:s.slice(1).map((t,n)=>{var o,i;return r.createElement("tr",{key:n},null===(o=Object.values(null==d||null===(i=d[p])||void 0===i?void 0:i[0]))||void 0===o?void 0:o.map((o,i)=>{try{var a,l,u,s,f,m,v,h,g;const o=null==d||null===(a=d[p])||void 0===a||null===(l=a[0])||void 0===l?void 0:l[i],y=o?null==e||null===(u=e.errorLocationObject)||void 0===u||null===(s=u[p])||void 0===s||null===(f=s[n])||void 0===f?void 0:f[o]:void 0;let E;if("object"==typeof(null==y?void 0:y[0])){let{error:e,...t}=y[0];E=c(e,null==t?void 0:t.values)}else E=!(null==y||!y[0])&&c(null==y?void 0:y[0]);const _="object"==typeof(null==e||null===(m=e.errorLocationObject)||void 0===m||null===(v=m[p])||void 0===v?void 0:v[n])?0!==Object.keys(null==e||null===(h=e.errorLocationObject)||void 0===h||null===(g=h[p])||void 0===g?void 0:g[n]).length:void 0;return r.createElement("td",{key:i,style:{...!t[i]&&0!==t[i]||isNaN(t[i])||!isFinite(t[i])?{}:{textAlign:"end"},...E?{backgroundColor:"rgb(250,148,148)"}:{}},title:E||void 0},0===i&&_&&r.createElement("div",{className:"edited-row-marker"}),!t[i]&&0!==t[i]||"object"==typeof t[i]?"":t[i])}catch(e){console.error("Error while showing data upload previwe",e.message)}}))})))),r.createElement("div",{className:"excel-tab-list"},Object.entries(d).map((t,n)=>{var o;let[i,a]=t;return r.createElement("button",{type:"button",key:i,className:"tab "+(i===p?"active":""),onClick:()=>{f(i)},style:{...null!=e&&null!==(o=e.errorLocationObject)&&void 0!==o&&o[i]?{backgroundColor:"rgb(250,148,148)",color:"black"}:{}}},i)}))))};var $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function W(e,t){return e(t={exports:{}},t.exports),t.exports}var z="function"==typeof Symbol&&Symbol.for,Y=z?Symbol.for("react.element"):60103,q=z?Symbol.for("react.portal"):60106,Z=z?Symbol.for("react.fragment"):60107,K=z?Symbol.for("react.strict_mode"):60108,J=z?Symbol.for("react.profiler"):60114,X=z?Symbol.for("react.provider"):60109,Q=z?Symbol.for("react.context"):60110,ee=z?Symbol.for("react.async_mode"):60111,te=z?Symbol.for("react.concurrent_mode"):60111,ne=z?Symbol.for("react.forward_ref"):60112,re=z?Symbol.for("react.suspense"):60113,oe=z?Symbol.for("react.suspense_list"):60120,ie=z?Symbol.for("react.memo"):60115,ae=z?Symbol.for("react.lazy"):60116,le=z?Symbol.for("react.block"):60121,ue=z?Symbol.for("react.fundamental"):60117,se=z?Symbol.for("react.responder"):60118,ce=z?Symbol.for("react.scope"):60119;function de(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case Y:switch(e=e.type){case ee:case te:case Z:case J:case K:case re:return e;default:switch(e=e&&e.$$typeof){case Q:case ne:case ae:case ie:case X:return e;default:return t}}case q:return t}}}function pe(e){return de(e)===te}var fe={AsyncMode:ee,ConcurrentMode:te,ContextConsumer:Q,ContextProvider:X,Element:Y,ForwardRef:ne,Fragment:Z,Lazy:ae,Memo:ie,Portal:q,Profiler:J,StrictMode:K,Suspense:re,isAsyncMode:function(e){return pe(e)||de(e)===ee},isConcurrentMode:pe,isContextConsumer:function(e){return de(e)===Q},isContextProvider:function(e){return de(e)===X},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===Y},isForwardRef:function(e){return de(e)===ne},isFragment:function(e){return de(e)===Z},isLazy:function(e){return de(e)===ae},isMemo:function(e){return de(e)===ie},isPortal:function(e){return de(e)===q},isProfiler:function(e){return de(e)===J},isStrictMode:function(e){return de(e)===K},isSuspense:function(e){return de(e)===re},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===Z||e===te||e===J||e===K||e===re||e===oe||"object"==typeof e&&null!==e&&(e.$$typeof===ae||e.$$typeof===ie||e.$$typeof===X||e.$$typeof===Q||e.$$typeof===ne||e.$$typeof===ue||e.$$typeof===se||e.$$typeof===ce||e.$$typeof===le)},typeOf:de},me=W(function(e,t){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,n=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,l=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,s=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,f=e?Symbol.for("react.suspense_list"):60120,m=e?Symbol.for("react.memo"):60115,v=e?Symbol.for("react.lazy"):60116,h=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,y=e?Symbol.for("react.responder"):60118,E=e?Symbol.for("react.scope"):60119;function _(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:var f=e.type;switch(f){case s:case c:case o:case a:case i:case p:return f;default:var h=f&&f.$$typeof;switch(h){case u:case d:case v:case m:case l:return h;default:return t}}case r:return t}}}var b=c,S=u,C=l,O=n,N=d,w=o,T=v,D=m,R=r,I=a,A=i,P=p,L=!1;function M(e){return _(e)===c}t.AsyncMode=s,t.ConcurrentMode=b,t.ContextConsumer=S,t.ContextProvider=C,t.Element=O,t.ForwardRef=N,t.Fragment=w,t.Lazy=T,t.Memo=D,t.Portal=R,t.Profiler=I,t.StrictMode=A,t.Suspense=P,t.isAsyncMode=function(e){return L||(L=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),M(e)||_(e)===s},t.isConcurrentMode=M,t.isContextConsumer=function(e){return _(e)===u},t.isContextProvider=function(e){return _(e)===l},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return _(e)===d},t.isFragment=function(e){return _(e)===o},t.isLazy=function(e){return _(e)===v},t.isMemo=function(e){return _(e)===m},t.isPortal=function(e){return _(e)===r},t.isProfiler=function(e){return _(e)===a},t.isStrictMode=function(e){return _(e)===i},t.isSuspense=function(e){return _(e)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===c||e===a||e===i||e===p||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===m||e.$$typeof===l||e.$$typeof===u||e.$$typeof===d||e.$$typeof===g||e.$$typeof===y||e.$$typeof===E||e.$$typeof===h)},t.typeOf=_}()}),ve=W(function(e){e.exports="production"===process.env.NODE_ENV?fe:me}),he=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;function Ee(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var _e=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,r,o=Ee(e),i=1;i<arguments.length;i++){for(var a in n=Object(arguments[i]))ge.call(n,a)&&(o[a]=n[a]);if(he){r=he(n);for(var l=0;l<r.length;l++)ye.call(n,r[l])&&(o[r[l]]=n[r[l]])}}return o},be="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Se=Function.call.bind(Object.prototype.hasOwnProperty),Ce=function(){};if("production"!==process.env.NODE_ENV){var Oe=be,Ne={},we=Se;Ce=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function Te(e,t,n,r,o){if("production"!==process.env.NODE_ENV)for(var i in e)if(we(e,i)){var a;try{if("function"!=typeof e[i]){var l=Error((r||"React class")+": "+n+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}a=e[i](t,i,r,n,null,Oe)}catch(e){a=e}if(!a||a instanceof Error||Ce((r||"React class")+": type specification of "+n+" `"+i+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),a instanceof Error&&!(a.message in Ne)){Ne[a.message]=!0;var u=o?o():"";Ce("Failed "+n+" type: "+a.message+(null!=u?u:""))}}}Te.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(Ne={})};var De=Te,Re=function(){};function Ie(){return null}function Ae(){}function Pe(){}"production"!==process.env.NODE_ENV&&(Re=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),Pe.resetWarningCache=Ae;var Le=W(function(e){e.exports="production"!==process.env.NODE_ENV?function(e,t){var n="function"==typeof Symbol&&Symbol.iterator,r={array:l("array"),bigint:l("bigint"),bool:l("boolean"),func:l("function"),number:l("number"),object:l("object"),string:l("string"),symbol:l("symbol"),any:a(Ie),arrayOf:function(e){return a(function(t,n,r,o,a){if("function"!=typeof e)return new i("Property `"+a+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var l=t[n];if(!Array.isArray(l))return new i("Invalid "+o+" `"+a+"` of type `"+c(l)+"` supplied to `"+r+"`, expected an array.");for(var u=0;u<l.length;u++){var s=e(l,u,r,o,a+"["+u+"]",be);if(s instanceof Error)return s}return null})},element:a(function(t,n,r,o,a){var l=t[n];return e(l)?null:new i("Invalid "+o+" `"+a+"` of type `"+c(l)+"` supplied to `"+r+"`, expected a single ReactElement.")}),elementType:a(function(e,t,n,r,o){var a=e[t];return ve.isValidElementType(a)?null:new i("Invalid "+r+" `"+o+"` of type `"+c(a)+"` supplied to `"+n+"`, expected a single ReactElement type.")}),instanceOf:function(e){return a(function(t,n,r,o,a){var l;return t[n]instanceof e?null:new i("Invalid "+o+" `"+a+"` of type `"+((l=t[n]).constructor&&l.constructor.name?l.constructor.name:"<<anonymous>>")+"` supplied to `"+r+"`, expected instance of `"+(e.name||"<<anonymous>>")+"`.")})},node:a(function(e,t,n,r,o){return s(e[t])?null:new i("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(e){return a(function(t,n,r,o,a){if("function"!=typeof e)return new i("Property `"+a+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var l=t[n],u=c(l);if("object"!==u)return new i("Invalid "+o+" `"+a+"` of type `"+u+"` supplied to `"+r+"`, expected an object.");for(var s in l)if(Se(l,s)){var d=e(l,s,r,o,a+"."+s,be);if(d instanceof Error)return d}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&Re(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),Ie;function t(t,n,r,a,l){for(var u=t[n],s=0;s<e.length;s++)if(o(u,e[s]))return null;var c=JSON.stringify(e,function(e,t){return"symbol"===d(t)?String(t):t});return new i("Invalid "+a+" `"+l+"` of value `"+String(u)+"` supplied to `"+r+"`, expected one of "+c+".")}return a(t)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&Re("Invalid argument supplied to oneOfType, expected an instance of array."),Ie;for(var t=0;t<e.length;t++){var n=e[t];if("function"!=typeof n)return Re("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+p(n)+" at index "+t+"."),Ie}return a(function(t,n,r,o,a){for(var l=[],u=0;u<e.length;u++){var s=(0,e[u])(t,n,r,o,a,be);if(null==s)return null;s.data&&Se(s.data,"expectedType")&&l.push(s.data.expectedType)}return new i("Invalid "+o+" `"+a+"` supplied to `"+r+"`"+(l.length>0?", expected one of type ["+l.join(", ")+"]":"")+".")})},shape:function(e){return a(function(t,n,r,o,a){var l=t[n],s=c(l);if("object"!==s)return new i("Invalid "+o+" `"+a+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");for(var p in e){var f=e[p];if("function"!=typeof f)return u(r,o,a,p,d(f));var m=f(l,p,r,o,a+"."+p,be);if(m)return m}return null})},exact:function(e){return a(function(t,n,r,o,a){var l=t[n],s=c(l);if("object"!==s)return new i("Invalid "+o+" `"+a+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");var p=_e({},t[n],e);for(var f in p){var m=e[f];if(Se(e,f)&&"function"!=typeof m)return u(r,o,a,f,d(m));if(!m)return new i("Invalid "+o+" `"+a+"` key `"+f+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(t[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var v=m(l,f,r,o,a+"."+f,be);if(v)return v}return null})}};function o(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function i(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function a(e){function t(t,n,r,o,a,l,u){if(o=o||"<<anonymous>>",l=l||r,u!==be){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}return null==n[r]?t?new i(null===n[r]?"The "+a+" `"+l+"` is marked as required in `"+o+"`, but its value is `null`.":"The "+a+" `"+l+"` is marked as required in `"+o+"`, but its value is `undefined`."):null:e(n,r,o,a,l)}process;var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function l(e){return a(function(t,n,r,o,a,l){var u=t[n];return c(u)!==e?new i("Invalid "+o+" `"+a+"` of type `"+d(u)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null})}function u(e,t,n,r,o){return new i((e||"React class")+": "+t+" type `"+n+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function s(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(s);if(null===t||e(t))return!0;var r=function(e){var t=e&&(n&&e[n]||e["@@iterator"]);if("function"==typeof t)return t}(t);if(!r)return!1;var o,i=r.call(t);if(r!==t.entries){for(;!(o=i.next()).done;)if(!s(o.value))return!1}else for(;!(o=i.next()).done;){var a=o.value;if(a&&!s(a[1]))return!1}return!0;default:return!1}}function c(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function d(e){if(null==e)return""+e;var t=c(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function p(e){var t=d(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return i.prototype=Error.prototype,r.checkPropTypes=De,r.resetWarningCache=De.resetWarningCache,r.PropTypes=r,r}(ve.isElement):function(){function e(e,t,n,r,o,i){if(i!==be){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:Pe,resetWarningCache:Ae};return n.PropTypes=n,n}()});const Me=e=>r.createElement("div",{className:"button-type-1",role:"button","aria-label":e.text,tabIndex:0},r.createElement("p",null,e.text));Me.propTypes={text:Le.string.isRequired};const ke=e=>r.createElement("div",{className:"button-type-2",role:"button",tabIndex:0,"aria-label":e.text},e.showDownloadIcon&&r.createElement("div",{className:"icon"},r.createElement(a.FileDownload,{fill:"white",height:"24",width:"24"})),r.createElement("p",null,e.text));ke.propTypes={text:Le.string.isRequired,showDownloadIcon:Le.bool};const xe=e=>r.createElement("p",{className:"modal-header "+(e.className?e.className:""),style:e.style},e.label);xe.propTypes={label:Le.string.isRequired,className:Le.string,style:Le.object};const je=e=>{let{clickHandler:t,style:n={}}=e;return r.createElement("button",{type:"button","aria-label":"Close",className:"microplan-close-button",onClick:t,style:n}," ",r.createElement(a.Close,{width:"1.5rem",height:"1.5rem",fill:"#000000"}))};je.propTypes={clickHandler:Le.func.isRequired,style:Le.object};const Ue=e=>({microplanDetails:{name:"microplanDetails",run:!0,steps:[{content:e("HELP_MICROPLAN_DETAILS_CAMPAIGN_DETAILS"),target:".microplan-campaign-detials",disableBeacon:!0,placement:"bottom",title:"",disableScrolling:!0,disableOverlay:!0},{content:e("HELP_MICROPLAN_DETAILS_MICROPLAN_NAME"),target:".microplan-name",disableBeacon:!0,placement:"bottom",title:"",disableScrolling:!0,disableOverlay:!0}],tourActive:!0},upload:{name:"upload",run:!0,steps:[{content:e("HELP_UPLOAD_FILETYPE_OPTION_CONTAINER"),target:".upload-option-container",disableBeacon:!0,placement:"top-end",title:"",disableScrolling:!0,disableOverlay:!0}],tourActive:!0},hypothesis:{name:"hypothesis",run:!0,steps:[{content:e("HELP_HYPOTHESIS_INTERACTABLE_SECTION"),target:".hypothesis-help",disableBeacon:!0,placement:"right-start",title:"",disableScrolling:!0,disableOverlay:!0},{content:e("HELP_HYPOTHESIS_ADD_BUTTON"),target:".add-button-help",disableBeacon:!0,placement:"top-start",title:"",disableOverlay:!0}],tourActive:!0},ruleEngine:{name:"ruleEngine",run:!0,steps:[{content:e("HELP_RULE_ENGINE_INTERACTABLE_SECTION"),target:".rule-engine-help",disableBeacon:!0,placement:"right-start",title:"",disableScrolling:!0,disableOverlay:!0},{content:e("HELP_RULE_ENGINE_INPUT"),target:".user-input-section .interactable-section .select-and-input-wrapper-first .input",disableBeacon:!0,placement:"top-end",title:"",disableOverlay:!0},{content:e("HELP_RULE_ENGINE_DELETE_BUTTON"),target:".select-and-input-wrapper-first .delete-button",disableBeacon:!0,placement:"left-start",title:"",disableOverlay:!0},{content:e("HELP_RULE_ENGINE_ADD_BUTTON"),target:".add-button-help",disableBeacon:!0,placement:"top-start",title:"",disableOverlay:!0}],tourActive:!0},mapping:{name:"mapping",run:!0,steps:[{content:e("HELP_MAPPING_BOUNDARY_SELECTION"),target:".filter-by-boundary .button-primary",disableBeacon:!0,placement:"right-end",title:"",disableScrolling:!0,disableOverlay:!0},{content:e("HELP_MAPPING_BASE_MAP"),target:".base-map-selector .icon-first",disableBeacon:!0,placement:"left-start",title:"",disableScrolling:!0,disableOverlay:!0},{content:e("HELP_MAPPING_FILTER"),target:".filter-icon p",disableBeacon:!0,placement:"left-start",title:"",disableScrolling:!0,disableOverlay:!0},{content:e("HELP_MAPPING_VIRTUALIZATION"),target:".virtualization-icon p",disableBeacon:!0,placement:"left-start",title:"",disableScrolling:!0,disableOverlay:!0},{content:e("HELP_MAPPING_MAP_GEOMETRIES"),target:".map-container",disableBeacon:!0,placement:"top-end",title:"",disableScrolling:!0,disableOverlay:!0}],tourActive:!0},microplanPreview:{name:"microplanPreview",run:!0,steps:[{content:e("HELP_MICROPLAN_DETAILS_EDIT_ROWS"),target:".preview-container",disableBeacon:!0,placement:"top-end",title:"",disableOverlay:!0,disableScrolling:!0}],tourActive:!0}});function He(e){e.eachRow({includeEmpty:!0},e=>{e.eachCell({includeEmpty:!0},e=>{e.font={...e.font||{},name:"Roboto"}})})}const Fe=function(e,t,n){try{const r={url:"/boundary-service/boundary-relationships/_search",params:{tenantId:e,hierarchyType:t,codes:n,includeChildren:!0},body:{}};let o;const i=x(function(){return Promise.resolve(Digit.CustomService.getResponse(r)).then(function(e){var t,n;o=(null==e||null===(t=e.TenantBoundary)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.boundary)||{}})},function(e){console.error("Error in fetching boundary Data: ",e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},Be=(e,t,n)=>{if(!t)return e;let r=[];const o=function(e,t,n,r){if(void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===r&&(r=[]),!e||!Array.isArray(e))return;const i=[...t];let a=[...r],l=new Set(n);for(const t of e)if(null!=t&&t.code){const e=[...i,null==t?void 0:t.code];let n;l.add(t.boundaryType),t.children&&(n=o(t.children,e,l,[...a,e])),n&&(a=n.tempDataAccumulator,l=n.tempHierarchyAccumulator)}return{tempDataAccumulator:a,tempHierarchyAccumulator:l}};let{tempDataAccumulator:i,tempHierarchyAccumulator:a}=o(t);a=[...a].map(e=>`${n}_${Digit.Utils.microplan.transformIntoLocalisationCode(e)}`),i=[[...a],...i];const l=Math.max(...i.map(e=>e.length))-1;return i=i.map((e,t)=>{let n=e;if(0!==t){n||(n=[]);const e=n.length;for(;n.length<=l;)n.push("");n.push(n[e-1])}else n.push(w);return n}),r=[...e,...r,{sheetName:R,data:i}],r},Ve=(e,t)=>{for(;e.length<t;)e.push([]);const n=Math.max(...e.map(e=>e.length));return e.map(e=>[...e,...new Array(n-e.length).fill("")])},Ge=e=>e?"DISPLAY_"+e:e,$e=(e,t,n)=>{var r;if(!t)return e;let o=(null===(r=t.schema)||void 0===r?void 0:r.Properties)||{};const i=[],a=[[],[],[],[]];for(const[e,t]of Object.entries(o))e!==w&&a[0].push(Ge(e));n&&a[0].push(...n);for(let{sheetName:t,data:n}of e)n=Ve(n,4),a.forEach((e,t)=>{n[t]=n[t]?[...n[t],...e]:[...e]}),i.push({sheetName:t,data:n});return i},We=(e,t)=>{const n={},r={};let o=[],i=!0;for(let a=1;a<e.length;a++){const l=e[a],u=l[t];o.length&&""!==u&&(r[u]=o),""===u&&i?o.push(l):o=[],n[u]||""===u||(n[u]={sheetName:u,data:[e[0]]}),u===l[t]&&""!==u&&n[u].data.push(l),i=""===u}return{sheetsMap:n,danglingDataMap:r}},ze=(e,t)=>t?e.map(function e(n){const r=null==t?void 0:t.find(e=>e.code===n.code&&e.type===n.boundaryType);if(!r)return{...n,children:n.children.map(e)};if(!n.children.length)return{...n,children:[]};if(r.includeAllChildren)return{...n,children:n.children.map(e)};const o=n.children.filter(e=>t.some(t=>t.code===e.code&&t.type===e.boundaryType)).map(e);return{...n,children:o}}):e,Ye=new s({allErrors:!0});Ye.addKeyword("isRequired"),Ye.addKeyword("isLocationDataColumns"),Ye.addKeyword("isRuleConfigureInputs"),Ye.addKeyword("isFilterPropertyOfMapSection"),Ye.addKeyword("isVisualizationPropertyOfMapSection"),Ye.addKeyword("toShowInMicroplanPreview");const qe=function(e,t,n){void 0===n&&(n=!1);try{const r=new d.Workbook;for(const[n,o]of Object.entries(e)){const e=r.addWorksheet(n);Ze(e,o,t)}return Promise.resolve(n?r:Qe(r))}catch(e){return Promise.reject(e)}},Ze=(e,t,n)=>{t.forEach((r,o)=>{const i=e.addRow(r);null!=n&&n.errorColumn&&o>0&&Ke(i,t[0],n)}),Je(e),Xe(e)},Ke=(e,t,n)=>{const r=t.indexOf(n.errorColumn);if(-1!==r){const t=e.getCell(r+1);if(n.style&&t)for(const e in n.style)t[e]=n.style[e]}},Je=e=>{const t=e.getRow(1);t&&(t.font={bold:!0})},Xe=e=>{e.eachRow((t,n)=>{t.eachCell((t,n)=>{const r=e.getColumn(n).width||40,o=Math.max(r,t.value.toString().length+2);e.getColumn(n).width=o})})},Qe=function(e){try{return Promise.resolve(e.xlsx.writeBuffer({compression:!0})).then(function(e){return new Blob([e],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})})}catch(e){return Promise.reject(e)}},et=function(e,t){void 0===t&&(t={});try{return Promise.resolve(new Promise((n,r)=>{const o=new FileReader;o.onload=function(e){try{const r=x(function(){return Promise.resolve(tt(e.target.result)).then(function(e){const r=nt(e,t);n(r)})},function(e){console.error(e),n({error:!0})});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},o.onerror=e=>{console.error(e),n({error:!0,details:e})},o.readAsArrayBuffer(e)}))}catch(e){return Promise.reject(e)}},tt=function(e){try{const t=new d.Workbook;return Promise.resolve(t.xlsx.load(e)).then(function(){return t})}catch(e){return Promise.reject(e)}},nt=(e,t)=>{const n={};return e.eachSheet(e=>{const r=rt(e,t);0!==r.length&&0!==(null==r?void 0:r[0].length)&&(n[e.name]=r)}),n},rt=(e,t)=>{const n=[];let r=[];return e.eachRow({includeEmpty:!0},(e,o)=>{const i=ot(e.values);t.header&&1===o?r=i:n.push(t.header&&r.length>0?it(i,r):i)}),at(n),n},ot=e=>e.slice(1).map(e=>"string"==typeof e?e.trim():e),it=(e,t)=>{const n={};return t.forEach((t,r)=>{n[t]=e[r]}),n},at=e=>{for(;e.length>0&&lt(e[e.length-1]);)e.pop()},lt=e=>Array.isArray(e)?0===e.filter(e=>""!==e).length:"object"==typeof e&&null!==e&&0===Object.values(e).filter(e=>""!==e).length,ut=e=>{if("object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>ut(e));const t={};for(const n in e)if(Object.hasOwn(e,n)){const r=e[n];t[n.trim()]="string"==typeof r?r.trim():"object"==typeof r?ut(r):r}return t},st=(e,t,n,r)=>e?e.find(e=>e.fileType===n&&e.templateIdentifier===r&&(!e.campaignType||e.campaignType===t))||{}:e,ct=(e,t,n)=>{const r=e.getWorksheet(n);r&&(r.getRow(1).eachCell(e=>{e.fill={type:"pattern",pattern:"solid",fgColor:{argb:"f25449"}},e.alignment={vertical:"middle",horizontal:"center",wrapText:!0}}),function(e,t){e.eachRow((e,n)=>{1!==n&&e.eachCell({includeEmpty:!0},n=>{n.alignment={vertical:"middle",horizontal:"left",wrapText:!0};const r=Math.ceil((null==n?void 0:n.value.length)/100);e.height=17*r,null!=t&&t.includes(n.value)&&(n.font={bold:!0})})}),e.getColumn(1).width=130,He(e)}(r,t))},dt=function(e,t,n,r){try{try{e.eachSheet((e,o)=>{e.getRow(1).eachCell((e,o)=>{const i=e.value.toString();null!=t&&t.includes(i)?e.fill={type:"pattern",pattern:"solid",fgColor:{argb:"ff9248"}}:null!=n&&n.includes(i)?e.fill={type:"pattern",pattern:"solid",fgColor:{argb:"93C47D"}}:null!=r&&r.includes(i)&&(e.fill={type:"pattern",pattern:"solid",fgColor:{argb:"CCCC00"}})})})}catch(e){console.error("Error coloring headers:",e)}return Promise.resolve()}catch(e){return Promise.reject(e)}},pt=(e,t,n,r)=>r.find(r=>r.campaignType?r.campaignType===e&&r.type===t&&r.section===n:r.type===t&&r.section===n),ft=(e,t,n,r)=>{const o=e[0].length;e[0].push(r("MICROPLAN_ERROR_STATUS_COLUMN"),r("MICROPLAN_ERROR_COLUMN"));for(let a=1;a<e.length;a++){var i;const l=e[a];o>l.length&&l.push(...Array(o-l.length).fill(""));const u=null==n||null===(i=n[t])||void 0===i?void 0:i[a-1];if(u){const e=Object.entries(u).map(e=>{let[t,n]=e;return`${r(t)}: ${n.map(e=>r(e)).join(", ")}`}).join(". ");l.push(r("MICROPLAN_ERROR_STATUS_INVALID"),e)}else l.push("")}},mt=function(e,t,n,r,o,i,a,l){try{var u;const s=((e,t,n,r,o,i,a)=>{const l={};for(const u of e){const e=[...u.data];if(e[0]=e[0].map(e=>e!==w&&t.includes(e)?a(_t(e)):a(e)),u.sheetName!==a(R)&&u.sheetName!==a(i)&&ft(e,u.sheetName,n,a),(u.sheetName===a("MICROPLAN_FACILITY_DATA_SHEET")||o.includes(u.sheetName))&&(e[0]=e[0].map(e=>e===a(w)?a(_t(w)):e),r.every(t=>e[0].includes(t))))for(let t=0;t<e.length;t++)e[t]=e[t].slice(r.length);l[u.sheetName]=e}return l})(_.cloneDeep(e),null!=n&&null!==(u=n.schema)&&void 0!==u&&u.Properties?Object.keys(n.schema.Properties):[],t,r,a,i,l);return Promise.resolve(vt(s,{errorColumns:[l("MICROPLAN_ERROR_STATUS_COLUMN"),l("MICROPLAN_ERROR_COLUMN")],style:{font:{color:{argb:"B91900"}},border:{top:{style:"thin",color:{argb:"B91900"}},left:{style:"thin",color:{argb:"B91900"}},bottom:{style:"thin",color:{argb:"B91900"}},right:{style:"thin",color:{argb:"B91900"}}}}},l)).then(function(e){return((e,t,n,r,o)=>{var i;const a=[...t.map(e=>o(e)),o("boundaryCode")],l=null!=r&&null!==(i=r.schema)&&void 0!==i&&i.Properties?[...Object.keys(r.schema.Properties).map(e=>o(_t(e))),o(_t("boundaryCode"))]:[];dt(e,a,l,[o("MICROPLAN_ERROR_STATUS_COLUMN"),o("MICROPLAN_ERROR_COLUMN")])})(e,r,0,n,l),ct(e,null==o?void 0:o.map(e=>l(null==e?void 0:e.header)),l(i)),Promise.resolve(e.xlsx.writeBuffer({compression:!0}).then(e=>new Blob([e],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})))})}catch(e){return Promise.reject(e)}},vt=function(e,t,n){try{const r=new d.Workbook;for(const[o,i]of Object.entries(e)){const e=r.addWorksheet(o);let a=0,l=-1;for(const r of i){const o=e.addRow(r);if(0!==(null==r?void 0:r.filter(e=>""!==e).length)&&null!=t&&t.errorColumns)for(const e of null==t?void 0:t.errorColumns){const n=i[0].indexOf(e);if(-1!==n){const e=n+1;if(e>0){const n=o.getCell(e);if(t.style&&n)for(const e in t.style)n[e]=t.style[e]}}}0===a&&o.eachCell((t,r)=>{t.font={bold:!0},t.alignment={vertical:"middle",horizontal:"center",wrapText:!0},t.value===n(w)||t.value===n(_t(w))?(l=r,e.getColumn(r).width=50):e.getColumn(r).width=40}),o.eachCell({includeEmpty:!0},(e,t)=>{e.alignment={vertical:"middle",wrapText:t!==l}}),a++}e.getRow(1)&&(e.getRow(1).font={bold:!0})}return Promise.resolve(r)}catch(e){return Promise.reject(e)}},ht=function(e,t,n){try{const r={};return Promise.resolve(function(){if(e&&!e.doHierarchyCheckInUploadedData)return x(function(){var e;function o(){var e,o;const i=null===(e=Be([],l,null==t?void 0:t.hierarchyType))||void 0===e||null===(o=e[0])||void 0===o?void 0:o.data;return i.forEach((e,t)=>{var o;if(0===t)return;let a=null==i||null===(o=i[0])||void 0===o?void 0:o.indexOf(w);r[e[a]]=a>=e.length?e.slice().map(n):e.slice(0,a).concat(e.slice(a+1)).map(n)}),r}const i=null==t||null===(e=t.boundaries)||void 0===e?void 0:e.filter(e=>e.isRoot),a=Digit.SessionStorage.get("microplanHelperData")||{};let l,u=a.filteredBoundaries;const s=function(){var e;if(!u)return Promise.resolve(Fe(Digit.ULBService.getCurrentTenantId(),null==t?void 0:t.hierarchyType,null==i||null===(e=i[0])||void 0===e?void 0:e.code)).then(function(e){u=e,l=ze(u,null==t?void 0:t.boundaries),Digit.SessionStorage.set("microplanHelperData",{...a,filteredBoundaries:l})});l=u}();return s&&s.then?s.then(o):o()},function(e){console.error(null==e?void 0:e.message)})}())}catch(e){return Promise.reject(e)}},gt=(e,t,n,r)=>{const o=r("MICROPLAN_FACILITY_DATA_SHEET"),i=r("MICROPLAN_ACTIVE");if(null==e||!e[o])return e;const a=e[o];return{[o]:n?a.filter(e=>(null==e?void 0:e[t])===i):(()=>{var e;const n=null===(e=a[0])||void 0===e?void 0:e.findIndex(e=>e===t);return-1===n?a:a.filter((e,t)=>0===t||(null==e?void 0:e[n])===i)})()}},yt=function(e,t,n,r,o,i,a,l,u){try{return Promise.resolve(x(function(){return Promise.resolve(et(e,{header:0})).then(function(e){const s=[];if(e[a(R)]&&(s.push({sheetName:a(R),data:e[a(R)],position:-1}),delete e[a(R)]),!e[a(u)])return{check:!1,interruptUpload:!0,fileDataToStore:{},toast:{state:"error",message:a("ERROR_READ_ME_MISSING")}};s.push({sheetName:a(u),data:e[a(u)],position:0}),delete e[a(u)];let{tempResourceMappingData:c,tempFileDataToStore:d}=((e,t,n,r,o)=>{const i=[],a={};if(n.id===N&&r){var l;const n=new Set(Object.values(r).flatMap(e=>(null==e?void 0:e[0])||[]));null!=e&&null!==(l=e.schema)&&void 0!==l&&l.Properties&&Object.keys(e.schema.Properties).map(e=>_t(e)).concat([...t,w]).forEach(e=>{var t;n.has(o(e))&&i.push({mappedFrom:o(e),mappedTo:(t=e,t&&t.startsWith("DISPLAY_")?t.substring("DISPLAY".length+1):t)})}),Object.entries(r).forEach(e=>{let[t,n]=e;const r=[],o=[],l=[];if(n&&n.length>0){n[0].forEach((e,t)=>{var n;const r=null===(n=i.find(t=>t.mappedFrom===e))||void 0===n?void 0:n.mappedTo;r?o.push(r):l.push(t)});for(let e=1;e<(null==n?void 0:n.length);e++){let t=[];for(let r=0;r<n[e].length;r++)l.includes(r)||t.push(n[e][r]);r.push(t)}}a[t]=[o,...r]})}return{tempResourceMappingData:i,tempFileDataToStore:a}})(t,n,r,e,a);return Promise.resolve(qe(d)).then(function(r){return e=r,Promise.resolve(et(e,{header:1})).then(function(e){var r,u,p,f,m,v,h;if(e){const t={},n=Object.keys(e);Object.keys(d).forEach(e=>{n.includes(e)&&(t[e]=d[e])}),d=t}if(null!==(r=e)&&void 0!==r&&r.error)return{check:!1,interruptUpload:!0,error:e.error,fileDataToStore:{},toast:{state:"error",message:a("ERROR_CORRUPTED_FILE")}};let g=[w];g=[...n,w];let y,E,_,b=Object.values(d),S=!0,C=Object.entries((null==t||null===(u=t.schema)||void 0===u?void 0:u.Properties)||{}).reduce((e,t)=>{let[n,r]=t;return null!=r&&r.isLocationDataColumns&&e.push(n),e},[])||[];return b.forEach(e=>{const n=e[0];var r;0!==(null==n?void 0:n.length)&&(null!==(r=g)&&void 0!==r&&r.every(e=>n.includes(e))||(t&&!t.doHierarchyCheckInUploadedData?S=!1:y={check:!1,interruptUpload:!0,error:a("ERROR_BOUNDARY_DATA_COLUMNS_ABSENT"),fileDataToStore:{},toast:{state:"error",message:a("ERROR_BOUNDARY_DATA_COLUMNS_ABSENT")}}),null!=C&&C.every(e=>n.includes(e))||(_={state:"warning",message:a("ERROR_UPLOAD_EXCEL_LOCATION_DATA_MISSING")}))}),!y||null!==(p=y)&&void 0!==p&&p.check?null!=t&&null!==(f=t.schema)&&void 0!==f&&f.Properties&&Object.keys(t.schema.Properties).includes(t.activeInactiveField)&&null!==(m=t.schema.Properties)&&void 0!==m&&null!==(v=m[t.activeInactiveField])&&void 0!==v&&v.isRequired&&!Object.values(d).reduce((e,n)=>{var r;const o=null==n||null===(r=n[0])||void 0===r?void 0:r.indexOf(t.activeInactiveField),i=-1!==o?n.slice().every(e=>!(null==e||!e[o])):void 0;return e&&-1!==o&&i},!0)?{check:!1,errors:[],interruptUpload:!0,fileDataToStore:{},toast:{state:"error",message:a("ERROR_ACTIVE_INACTIVE_COLUMN_MISSING",{columnName:a(t.activeInactiveField)})}}:null!=t&&t.activeInactiveField&&null!=t&&null!==(h=t.schema)&&void 0!==h&&h.Properties&&Object.keys(t.schema.Properties).includes(t.activeInactiveField)&&(e=gt(e,t.activeInactiveField,!0,a),d=gt(d,t.activeInactiveField,!1,a),!Object.values(d).reduce((e,t)=>e&&(null==t?void 0:t.length)>1,!0))?{check:!1,errors:[],interruptUpload:!0,fileDataToStore:{},toast:{state:"error",message:a("ERROR_ACTIVE_DATA_MISSING")}}:Promise.resolve(function(e,t,n){try{try{const r=((e,t,n)=>{const{required:r,properties:o}=(e=>({required:Object.entries((null==e?void 0:e.Properties)||{}).reduce((e,t)=>{let[n,r]=t;return null!=r&&r.isRequired&&e.push(n),e},[]),properties:e.Properties}))(t),i=((e,t)=>({type:"object",patternProperties:{".*":{type:"array",items:{type:"object",properties:e,required:t,additionalProperties:!0}}},minProperties:1,additionalProperties:!1}))(o,r),a=Ye.compile(i),l=a(e),u=(e=>Object.entries((null==e?void 0:e.Properties)||{}).reduce((e,t)=>{let[n,r]=t;return null!=r&&r.isLocationDataColumns&&e.push(n),e},[]))(t);if(!l){const e=((e,t,n)=>{const r={};let o="false";const i=new Set;let a={};return e.forEach(e=>{let l,u="";switch(e.keyword){case"additionalProperties":u="ERROR_ADDITIONAL_PROPERTIES",o="true";break;case"type":{var s;const n=e.instancePath.split("/"),r=null===(s=e.params)||void 0===s?void 0:s.type;l=n,u=t.includes(n[n.length-1])?"ERROR_INCORRECT_LOCATION_COORDINATES":"number"===r?"ERROR_MUST_BE_A_NUMBER":"ERROR_MUST_BE_A_STRING",o="true"}break;case"required":{const t=e.params.missingProperty;l=[...e.instancePath.split("/"),t],u="ERROR_MANDATORY_FIELDS_CANT_BE_EMPTY",i.add(t),o="true"}break;case"maximum":case"minimum":{const n=e.instancePath.split("/");l=n,u=t.includes(n[l.length-1])?"ERROR_INCORRECT_LOCATION_COORDINATES":"ERROR_DATA_EXCEEDS_LIMIT_CONSTRAINTS",o="true"}break;case"pattern":u="ERROR_VALUE_NOT_ALLOWED",o="true";break;case"minProperties":o="minProperties";break;case"enum":var c,d;l=e.instancePath.split("/"),u={error:"ERROR_UPLOAD_DATA_ENUM",values:{allowedValues:null===(c=e.params)||void 0===c||null===(d=c.allowedValues)||void 0===d?void 0:d.map(e=>n(e)).join(", ")}},o="true";break;default:o="unknown"}switch(u&&l&&((e,t,n)=>{if(!t.length)return;let r=e;for(let e=0;e<t.length-1;e++)r[t[e]]||(r[t[e]]={}),r=r[t[e]];r[t[t.length-1]]||(r[t[t.length-1]]=[]),r[t[t.length-1]]=[...new Set([...r[t[t.length-1]],n])]})(r,l.slice(1,4),u),o){case"true":a={dataError:"ERROR_REFER_UPLOAD_PREVIEW_TO_SEE_THE_ERRORS"};break;case"minProperties":a={minProperties:"ERROR_UPLOADED_DATA_IS_EMPTY"};break;case"unknown":a={unknown:"ERROR_UNKNOWN"}}}),{valid:!o,message:a?[...new Set(Object.values(a))]:[],errors:r,missingColumnsList:i}})(a.errors,u,n);return Ye.removeSchema(),e}return Ye.removeSchema(),{valid:l}})(e,t,n);return Promise.resolve(r.valid?{valid:!0}:{valid:!1,message:r.message,errors:r.errors,missingProperties:r.missingColumnsList})}catch(e){return console.error("Error in excel validations: ",null==e?void 0:e.message),Promise.resolve({valid:!1,message:["ERROR_PARSING_FILE"]})}}catch(e){return Promise.reject(e)}}(e,t.schema,a)).then(function(e){function r(){return d=Et(d,u),Promise.resolve(Ot(d,l,N,a)).then(function(e){const t=!(!E&&e&&0===Object.keys(e).length)&&Digit.Utils.microplan.mergeDeep(E,e);return p&&t&&i(["ERROR_REFER_UPLOAD_PREVIEW_TO_SEE_THE_ERRORS"]),{check:p&&!t,errors:t,errorMsg:y||(t?["ERROR_REFER_UPLOAD_PREVIEW_TO_SEE_THE_ERRORS"]:void 0),fileDataToStore:d,tempResourceMappingData:c,toast:_,additionalSheets:s}})}e.valid||i(e.message),y=e.message,E=e.errors;const u=e.missingProperties;let p=e.valid;const f=x(function(){const e=function(e){if(t&&!t.doHierarchyCheckInUploadedData&&!S&&o&&(!u||null!==(e=[...u])&&void 0!==e&&e.includes(w)))return Promise.resolve(ht(t,l,a)).then(function(e){for(const i in d){var t,r;const a=null===(t=d[i])||void 0===t||null===(r=t[0])||void 0===r?void 0:r.indexOf(w);if(-1!==a){const t=[];for(let r=0;r<d[i].length;r++){var o;let l=d[i][r];const u=null===(o=l[a])||void 0===o?void 0:o.split(",").map(e=>e.trim());if(u)for(const o of u){const i=[...l];i[a]=o,t.push([...e[o]?e[o]:0!==r?new Array(n.length).fill(""):[],...i])}else t.push([...new Array(n.length).fill(""),...l])}d[i]=t}d[i][0]=[...n,...d[i][0]]}})}();if(e&&e.then)return e.then(function(){})},function(e){console.error("Error in boundary adding operaiton: ",e)});return f&&f.then?f.then(r):r()}):y})})})},function(e){console.error("Error in handling Excel file:",e.message)}))}catch(e){return Promise.reject(e)}},Et=(e,t)=>{if(!e||!t)return e;let n={};return Object.entries(e).forEach((e,r)=>{var o;let[i,a]=e;const l=null===(o=[...t])||void 0===o?void 0:o.reduce((e,t)=>{var n;return null!=a&&null!==(n=a[0])&&void 0!==n&&n.includes(t)||e.push(t),e},[]),u=0!==(null==a?void 0:a[0].length)?[...a[0],...l]:[...l];n[i]=[u,...a.slice(1)]}),n},_t=e=>e?"DISPLAY_"+e:e,bt=(e,t,n,r)=>