@lifesg/web-frontend-engine 1.19.14 → 1.19.15

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.
Files changed (23) hide show
  1. package/chunks/{file-upload-manager.88131e38.js → file-upload-manager.1786802e.js} +2 -2
  2. package/chunks/{file-upload-manager.88131e38.js.map → file-upload-manager.1786802e.js.map} +1 -1
  3. package/chunks/{index.5a6b29eb.js → index.54c2add7.js} +2 -2
  4. package/chunks/{index.5a6b29eb.js.map → index.54c2add7.js.map} +1 -1
  5. package/chunks/{index.fc8f504e.js → index.a88ac40b.js} +5 -5
  6. package/chunks/{index.fc8f504e.js.map → index.a88ac40b.js.map} +1 -1
  7. package/chunks/{index.4b4ecdb7.js → index.b9888bc5.js} +2 -2
  8. package/chunks/{index.4b4ecdb7.js.map → index.b9888bc5.js.map} +1 -1
  9. package/chunks/{location-modal.ddb76a07.js → location-modal.53039680.js} +2 -2
  10. package/chunks/{location-modal.ddb76a07.js.map → location-modal.53039680.js.map} +1 -1
  11. package/cjs/chunks/{file-upload-manager.981ed57b.js → file-upload-manager.8b3a773b.js} +2 -2
  12. package/cjs/chunks/{file-upload-manager.981ed57b.js.map → file-upload-manager.8b3a773b.js.map} +1 -1
  13. package/cjs/chunks/{index.e35c6aea.js → index.b063ce55.js} +5 -5
  14. package/cjs/chunks/{index.e35c6aea.js.map → index.b063ce55.js.map} +1 -1
  15. package/cjs/chunks/{index.aa390365.js → index.ca424cf5.js} +2 -2
  16. package/cjs/chunks/{index.aa390365.js.map → index.ca424cf5.js.map} +1 -1
  17. package/cjs/chunks/{index.71a851b1.js → index.d42f693a.js} +2 -2
  18. package/cjs/chunks/{index.71a851b1.js.map → index.d42f693a.js.map} +1 -1
  19. package/cjs/chunks/{location-modal.d4929e93.js → location-modal.f9df87bc.js} +2 -2
  20. package/cjs/chunks/{location-modal.d4929e93.js.map → location-modal.f9df87bc.js.map} +1 -1
  21. package/cjs/index.js +1 -1
  22. package/index.js +1 -1
  23. package/package.json +3 -3
@@ -381,7 +381,7 @@ function aN(e){return"[object Object]"===Object.prototype.toString.call(e)}Objec
381
381
  margin: 0;
382
382
  padding: 0;
383
383
  }
384
- `,Y$=({Field:t,id:n,schema:r,warning:i})=>{const{control:a,setValue:o}=Be(),{formSchema:{defaultValues:c,restoreMode:l="none"}}=Kk(),{getField:d,setField:f,setRegisteredFields:p}=Jk(),{removeFieldValidationConfig:h}=Xk(),m=s(l);u((()=>{m.current=l}),[l]),QI((()=>(o(n,d(n)),p((e=>[...e,n])),()=>{switch(m.current){case"default-value":f(n,c?.[n]);break;case"none":{const e=d(n);li(e)?f(n,[]):E$(e)?f(n,""):(BI(e)||zI(e))&&f(n,void 0);break}}p((e=>e.filter((e=>e!==n)))),h(n)})),[]);const g=(t,n)=>{const r=n.label;return"string"==typeof r?{children:e(vI,{inline:!0,children:r})}:r&&"object"==typeof r&&r.mainLabel?{children:e(vI,{inline:!0,children:r.mainLabel}),subtitle:e(W$,{className:"sub-label",children:r.subLabel}),addon:r.hint?.content?{type:"popover",content:e(q$,{className:"label-hint",children:r.hint?.content}),"data-testid":(n["data-testid"]||t)+"-popover",zIndex:r.hint?.zIndex}:void 0}:void 0};return e(tt,{control:a,name:n,shouldUnregister:!0,render:({field:a,fieldState:o})=>{const s={...a,id:n,formattedLabel:g(n,r),value:d(n),warning:i,ref:void 0};return e(t,{schema:r,...s,...o})}})},W$=M(vI)`
384
+ `,Y$=({Field:t,id:n,schema:r,warning:i})=>{const{control:a,setValue:o}=Be(),{formSchema:{defaultValues:c,restoreMode:l="none"}}=Kk(),{getField:d,setField:f,setRegisteredFields:p}=Jk(),{removeFieldValidationConfig:h}=Xk(),m=s(l);u((()=>{m.current=l}),[l]),QI((()=>(o(n,d(n)),p((e=>[...e,n])),()=>{switch(m.current){case"default-value":f(n,c?.[n]);break;case"none":{const e=d(n);li(e)?f(n,[]):E$(e)?f(n,""):(BI(e)||zI(e))&&f(n,void 0);break}}p((e=>e.filter((e=>e!==n)))),h(n)})),[]);const g=(t,n)=>{const r=n.label;return"string"==typeof r?{children:e(vI,{inline:!0,children:r})}:r&&"object"==typeof r&&r.mainLabel?{children:e(vI,{inline:!0,children:r.mainLabel}),subtitle:e(W$,{className:"sub-label",children:r.subLabel}),addon:r.hint?.content?{type:"popover",content:e(q$,{className:"label-hint",children:r.hint?.content}),"data-testid":(n["data-testid"]||t)+"-popover",zIndex:r.hint?.zIndex}:void 0}:void 0};return e(tt,{control:a,name:n,shouldUnregister:!0,render:({field:a,fieldState:o})=>{const{ref:s,...u}=a,c={...u,id:n,formattedLabel:g(n,r),value:d(n),warning:i};return e(t,{schema:r,...c,...o})}})},W$=M(vI)`
385
385
  &.sub-label {
386
386
  display: block;
387
387
  ${w.getFontFamily("BodySmall",400)};
@@ -433,7 +433,7 @@ function aN(e){return"[object Object]"===Object.prototype.toString.call(e)}Objec
433
433
  cursor: pointer;
434
434
  `,pF=M(k)`
435
435
  margin-top: 0.5rem;
436
- `;var hF=ci,mF=li,gF=mn?mn.isConcatSpreadable:void 0;var yF=Ma,_F=function(e){return mF(e)||hF(e)||!!(gF&&e&&e[gF])};var vF=function e(t,n,r,i,a){var o=-1,s=t.length;for(r||(r=_F),a||(a=[]);++o<s;){var u=t[o];n>0&&r(u)?n>1?e(u,n-1,r,i,a):yF(a,u):i||(a[a.length]=u)}return a};var bF=qa,AF=function(){},EF=bF&&1/AS(new bF([,-0]))[1]==1/0?function(e){return new bF(e)}:AF,SF=bA,wF=OA,xF=NA,MF=CA,TF=EF,OF=AS;var NF=function(e,t,n){var r=-1,i=wF,a=e.length,o=!0,s=[],u=s;if(n)o=!1,i=xF;else if(a>=200){var c=t?null:TF(e);if(c)return OF(c);o=!1,i=MF,u=new SF}else u=t?[]:s;e:for(;++r<a;){var l=e[r],d=t?t(l):l;if(l=n||0!==l?l:0,o&&d==d){for(var f=u.length;f--;)if(u[f]===d)continue e;t&&u.push(d),s.push(l)}else i(u,d,n)||(u!==s&&u.push(d),s.push(l))}return s},CF=z$,DF=vF,LF=NF;var IF=function(e,t,n){var r=e.length;if(r<2)return r?LF(e[0]):[];for(var i=-1,a=Array(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=CF(a[i]||o,e[s],t,n));return LF(DF(a,1),t,n)},kF=ma,$F=IF,RF=tE,zF=XA((function(e){return $F(kF(e,RF))}));const FF=a({files:[],setFiles:()=>null,currentFileIds:[],setCurrentFileIds:()=>null}),PF=({children:t})=>{const[n,r]=o([]),[i,a]=o([]),s=c((()=>({files:n,setFiles:r,currentFileIds:i,setCurrentFileIds:a})),[n,i]);return e(FF.Provider,{value:s,children:t})};var ZF,UF;!function(e){e.findAvailableSlot=e=>{const t=e.reduce(((e,{slot:t})=>t>e?t:e),0),n=Math.max(t,e.length),r=Array(n).fill(0).map(((e,t)=>t)),i=e.map((({slot:e})=>e));return r.filter((e=>!i.includes(e)))[0]??n}}(ZF||(ZF={})),function(e){e[e.INJECTED=-99]="INJECTED",e[e.INJECTING=-98]="INJECTING",e[e.TO_DELETE=-4]="TO_DELETE",e[e.ERROR_FORMAT=-3]="ERROR_FORMAT",e[e.ERROR_GENERIC=-2]="ERROR_GENERIC",e[e.ERROR_SIZE=-1]="ERROR_SIZE",e[e.NONE=0]="NONE",e[e.UPLOAD_READY=4]="UPLOAD_READY",e[e.UPLOADING=5]="UPLOADING",e[e.UPLOADED=6]="UPLOADED"}(UF||(UF={}));const jF=y((()=>import("./file-upload-manager.88131e38.js"))),BF=r=>{const{id:i,error:a,isDirty:c,isTouched:f,value:p,schema:{compressImages:h,description:m,label:g,uploadOnAddingFile:y,validation:v,warning:b,...A},warning:E}=r,{files:S,currentFileIds:w,setFiles:x}=l(FF),M=s({}),T=s({}),O=s({}),N=s({}),{setFieldValidationConfig:C}=Xk(),{dispatchFieldEvent:D}=ek(),{clearErrors:L,setError:I}=Be(),[k,$]=o(),R=s(S),z=d(((e,t)=>{const n=[...t],r=n.length;e.forEach(((e,t)=>{!T.current.max||r+t<T.current.max?(n.push({...e,slot:ZF.findAvailableSlot(n)}),L(i)):I(i,{type:"max",message:T.current.errorMessage||sm.UPLOAD().MAX_FILES(T.current.max)})})),x(n)}),[L,i,I,x]);u((()=>{R.current=S}),[S]),u((()=>{D("mount",i)}),[D,i]),u((()=>{const e=v?.find((e=>"required"in e)),t=v?.find((e=>"fileType"in e)),n=v?.find((e=>"maxSizeInKb"in e)),r=v?.find((e=>"upload"in e&&e.upload));M.current=t?.fileType?t:{},O.current=n?.maxSizeInKb>0?n:{},N.current=r||{};const a=v?.find((e=>"length"in e)),o=v?.find((e=>"max"in e));T.current=a?{max:a.length,errorMessage:a.errorMessage}:o?{max:o.max,errorMessage:o.errorMessage}:{},C(i,FM().of(RM().shape({dataURL:Ax(),fileId:Ax(),fileName:Ax(),fileUrl:Ax(),uploadResponse:RM()})).test("is-empty-array",e?.errorMessage||sm.UPLOAD().REQUIRED,(t=>!t||!e?.required||t.length>0)).test("max-size-in-kb",O.current.errorMessage||sm.UPLOAD().MAX_FILE_SIZE(O.current.maxSizeInKb),(e=>!(e&&Array.isArray(e)&&O.current.maxSizeInKb)||S.filter((e=>e.status===UF.UPLOADED)).every((e=>"base64"===y.type?om.getFilesizeFromBase64(e.dataURL)<=1024*O.current.maxSizeInKb:"multipart"===y.type?e.rawFile.size<=1024*O.current.maxSizeInKb:void 0)))).test("max-files",T.current.errorMessage||sm.UPLOAD().MAX_FILES(T.current.max),(e=>!(e&&Array.isArray(e)&&T.current.max)||e.length<=T.current.max)),v)}),[v,S.map((e=>e.status)).join(",")]),u((()=>{if(!c&&!f){const e=Array.isArray(p)?p:[];if(!(zF(e.map((({fileId:e})=>e)),w).length>0))return;const t=[];e.forEach((({dataURL:e,fileId:n,fileName:r,fileUrl:i,uploadResponse:a})=>{t.push({addedFrom:"schema",dataURL:e,fileItem:{id:n},uploadResponse:a,fileUrl:i,rawFile:{name:r},slot:null,status:UF.INJECTED})})),z(t,[])}}),[z,c,f,w,p]),u((()=>{if(a?.message)try{const{message:e,fileErrors:t}=JSON.parse(a.message);t&&x(R.current.map((e=>{const n=t[e.fileItem.id];return n?{...e,fileItem:{...e.fileItem,errorMessage:n}}:e}))),e&&$(e)}catch(e){$(a.message)}else $(void 0)}),[a?.message,x]);const F=t=>t?e(vI,{children:t}):null;return t(n,{children:[e(_,{fallback:null,children:e(jF,{id:i,fileTypeRule:M.current,maxFileSizeRule:O.current,uploadRule:N.current,upload:y,value:p,compressImages:!!h})}),e(J,{...A,accept:M.current.fileType?.map((e=>`.${e}`)).join(","),description:F(m),errorMessage:F(k),fileItems:S.filter((({fileItem:e,status:t})=>!!e&&t!==UF.INJECTED&&t!==UF.INJECTING)).map((({fileItem:e})=>e)),id:i,maxFiles:T.current.max,onChange:e=>{z(e.map((e=>({addedFrom:"input",rawFile:e,slot:null,status:UF.NONE}))),S)},onDelete:e=>{x(S.map((t=>t.fileItem.id!==e.id?t:{...t,status:UF.TO_DELETE}))),L(i)},title:F(g),warning:F(E||b)})]})},VF=a({images:[],setImages:()=>null,errorCount:0,setErrorCount:()=>null,currentFileIds:[],setCurrentFileIds:()=>null}),GF=({children:t})=>{const[n,r]=o([]),[i,a]=o(0),[s,u]=o([]);return e(VF.Provider,{value:{images:n,setImages:r,errorCount:i,setErrorCount:a,currentFileIds:s,setCurrentFileIds:u},children:t})};var HF;!function(e){e.findAvailableSlot=e=>{const t=e.reduce(((e,{slot:t})=>t>e?t:e),0),n=Math.max(t,e.length),r=Array(n).fill(0).map(((e,t)=>t)),i=e.map((({slot:e})=>e));return r.filter((e=>!i.includes(e)))[0]??n}}(HF||(HF={}));const YF=["jpg","gif","png","heic","heif","webp"];var WF;!function(e){e[e.INJECTED=-99]="INJECTED",e[e.ERROR_CUSTOM_MUTED=-7]="ERROR_CUSTOM_MUTED",e[e.ERROR_EXCEED=-6]="ERROR_EXCEED",e[e.ERROR_CUSTOM=-5]="ERROR_CUSTOM",e[e.TO_DELETE=-4]="TO_DELETE",e[e.ERROR_FORMAT=-3]="ERROR_FORMAT",e[e.ERROR_GENERIC=-2]="ERROR_GENERIC",e[e.ERROR_SIZE=-1]="ERROR_SIZE",e[e.NONE=0]="NONE",e[e.TO_RECOMPRESS=1]="TO_RECOMPRESS",e[e.COMPRESSED=2]="COMPRESSED",e[e.RECOMPRESSED=2]="RECOMPRESSED",e[e.CONVERTED=2]="CONVERTED",e[e.EDITED=3]="EDITED",e[e.UPLOAD_READY=4]="UPLOAD_READY",e[e.UPLOADING=5]="UPLOADING",e[e.UPLOADED=6]="UPLOADED",e[e.PENDING=7]="PENDING"}(WF||(WF={}));var qF,KF={exports:{}},JF={exports:{}},XF={};var QF,eP,tP,nP,rP,iP,aP,oP,sP,uP,cP,lP,dP,fP,pP={};
436
+ `;var hF=ci,mF=li,gF=mn?mn.isConcatSpreadable:void 0;var yF=Ma,_F=function(e){return mF(e)||hF(e)||!!(gF&&e&&e[gF])};var vF=function e(t,n,r,i,a){var o=-1,s=t.length;for(r||(r=_F),a||(a=[]);++o<s;){var u=t[o];n>0&&r(u)?n>1?e(u,n-1,r,i,a):yF(a,u):i||(a[a.length]=u)}return a};var bF=qa,AF=function(){},EF=bF&&1/AS(new bF([,-0]))[1]==1/0?function(e){return new bF(e)}:AF,SF=bA,wF=OA,xF=NA,MF=CA,TF=EF,OF=AS;var NF=function(e,t,n){var r=-1,i=wF,a=e.length,o=!0,s=[],u=s;if(n)o=!1,i=xF;else if(a>=200){var c=t?null:TF(e);if(c)return OF(c);o=!1,i=MF,u=new SF}else u=t?[]:s;e:for(;++r<a;){var l=e[r],d=t?t(l):l;if(l=n||0!==l?l:0,o&&d==d){for(var f=u.length;f--;)if(u[f]===d)continue e;t&&u.push(d),s.push(l)}else i(u,d,n)||(u!==s&&u.push(d),s.push(l))}return s},CF=z$,DF=vF,LF=NF;var IF=function(e,t,n){var r=e.length;if(r<2)return r?LF(e[0]):[];for(var i=-1,a=Array(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=CF(a[i]||o,e[s],t,n));return LF(DF(a,1),t,n)},kF=ma,$F=IF,RF=tE,zF=XA((function(e){return $F(kF(e,RF))}));const FF=a({files:[],setFiles:()=>null,currentFileIds:[],setCurrentFileIds:()=>null}),PF=({children:t})=>{const[n,r]=o([]),[i,a]=o([]),s=c((()=>({files:n,setFiles:r,currentFileIds:i,setCurrentFileIds:a})),[n,i]);return e(FF.Provider,{value:s,children:t})};var ZF,UF;!function(e){e.findAvailableSlot=e=>{const t=e.reduce(((e,{slot:t})=>t>e?t:e),0),n=Math.max(t,e.length),r=Array(n).fill(0).map(((e,t)=>t)),i=e.map((({slot:e})=>e));return r.filter((e=>!i.includes(e)))[0]??n}}(ZF||(ZF={})),function(e){e[e.INJECTED=-99]="INJECTED",e[e.INJECTING=-98]="INJECTING",e[e.TO_DELETE=-4]="TO_DELETE",e[e.ERROR_FORMAT=-3]="ERROR_FORMAT",e[e.ERROR_GENERIC=-2]="ERROR_GENERIC",e[e.ERROR_SIZE=-1]="ERROR_SIZE",e[e.NONE=0]="NONE",e[e.UPLOAD_READY=4]="UPLOAD_READY",e[e.UPLOADING=5]="UPLOADING",e[e.UPLOADED=6]="UPLOADED"}(UF||(UF={}));const jF=y((()=>import("./file-upload-manager.1786802e.js"))),BF=r=>{const{id:i,error:a,isDirty:c,isTouched:f,value:p,schema:{compressImages:h,description:m,label:g,uploadOnAddingFile:y,validation:v,warning:b,...A},warning:E}=r,{files:S,currentFileIds:w,setFiles:x}=l(FF),M=s({}),T=s({}),O=s({}),N=s({}),{setFieldValidationConfig:C}=Xk(),{dispatchFieldEvent:D}=ek(),{clearErrors:L,setError:I}=Be(),[k,$]=o(),R=s(S),z=d(((e,t)=>{const n=[...t],r=n.length;e.forEach(((e,t)=>{!T.current.max||r+t<T.current.max?(n.push({...e,slot:ZF.findAvailableSlot(n)}),L(i)):I(i,{type:"max",message:T.current.errorMessage||sm.UPLOAD().MAX_FILES(T.current.max)})})),x(n)}),[L,i,I,x]);u((()=>{R.current=S}),[S]),u((()=>{D("mount",i)}),[D,i]),u((()=>{const e=v?.find((e=>"required"in e)),t=v?.find((e=>"fileType"in e)),n=v?.find((e=>"maxSizeInKb"in e)),r=v?.find((e=>"upload"in e&&e.upload));M.current=t?.fileType?t:{},O.current=n?.maxSizeInKb>0?n:{},N.current=r||{};const a=v?.find((e=>"length"in e)),o=v?.find((e=>"max"in e));T.current=a?{max:a.length,errorMessage:a.errorMessage}:o?{max:o.max,errorMessage:o.errorMessage}:{},C(i,FM().of(RM().shape({dataURL:Ax(),fileId:Ax(),fileName:Ax(),fileUrl:Ax(),uploadResponse:RM()})).test("is-empty-array",e?.errorMessage||sm.UPLOAD().REQUIRED,(t=>!t||!e?.required||t.length>0)).test("max-size-in-kb",O.current.errorMessage||sm.UPLOAD().MAX_FILE_SIZE(O.current.maxSizeInKb),(e=>!(e&&Array.isArray(e)&&O.current.maxSizeInKb)||S.filter((e=>e.status===UF.UPLOADED)).every((e=>"base64"===y.type?om.getFilesizeFromBase64(e.dataURL)<=1024*O.current.maxSizeInKb:"multipart"===y.type?e.rawFile.size<=1024*O.current.maxSizeInKb:void 0)))).test("max-files",T.current.errorMessage||sm.UPLOAD().MAX_FILES(T.current.max),(e=>!(e&&Array.isArray(e)&&T.current.max)||e.length<=T.current.max)),v)}),[v,S.map((e=>e.status)).join(",")]),u((()=>{if(!c&&!f){const e=Array.isArray(p)?p:[];if(!(zF(e.map((({fileId:e})=>e)),w).length>0))return;const t=[];e.forEach((({dataURL:e,fileId:n,fileName:r,fileUrl:i,uploadResponse:a})=>{t.push({addedFrom:"schema",dataURL:e,fileItem:{id:n},uploadResponse:a,fileUrl:i,rawFile:{name:r},slot:null,status:UF.INJECTED})})),z(t,[])}}),[z,c,f,w,p]),u((()=>{if(a?.message)try{const{message:e,fileErrors:t}=JSON.parse(a.message);t&&x(R.current.map((e=>{const n=t[e.fileItem.id];return n?{...e,fileItem:{...e.fileItem,errorMessage:n}}:e}))),e&&$(e)}catch(e){$(a.message)}else $(void 0)}),[a?.message,x]);const F=t=>t?e(vI,{children:t}):null;return t(n,{children:[e(_,{fallback:null,children:e(jF,{id:i,fileTypeRule:M.current,maxFileSizeRule:O.current,uploadRule:N.current,upload:y,value:p,compressImages:!!h})}),e(J,{...A,accept:M.current.fileType?.map((e=>`.${e}`)).join(","),description:F(m),errorMessage:F(k),fileItems:S.filter((({fileItem:e,status:t})=>!!e&&t!==UF.INJECTED&&t!==UF.INJECTING)).map((({fileItem:e})=>e)),id:i,maxFiles:T.current.max,onChange:e=>{z(e.map((e=>({addedFrom:"input",rawFile:e,slot:null,status:UF.NONE}))),S)},onDelete:e=>{x(S.map((t=>t.fileItem.id!==e.id?t:{...t,status:UF.TO_DELETE}))),L(i)},title:F(g),warning:F(E||b)})]})},VF=a({images:[],setImages:()=>null,errorCount:0,setErrorCount:()=>null,currentFileIds:[],setCurrentFileIds:()=>null}),GF=({children:t})=>{const[n,r]=o([]),[i,a]=o(0),[s,u]=o([]);return e(VF.Provider,{value:{images:n,setImages:r,errorCount:i,setErrorCount:a,currentFileIds:s,setCurrentFileIds:u},children:t})};var HF;!function(e){e.findAvailableSlot=e=>{const t=e.reduce(((e,{slot:t})=>t>e?t:e),0),n=Math.max(t,e.length),r=Array(n).fill(0).map(((e,t)=>t)),i=e.map((({slot:e})=>e));return r.filter((e=>!i.includes(e)))[0]??n}}(HF||(HF={}));const YF=["jpg","gif","png","heic","heif","webp"];var WF;!function(e){e[e.INJECTED=-99]="INJECTED",e[e.ERROR_CUSTOM_MUTED=-7]="ERROR_CUSTOM_MUTED",e[e.ERROR_EXCEED=-6]="ERROR_EXCEED",e[e.ERROR_CUSTOM=-5]="ERROR_CUSTOM",e[e.TO_DELETE=-4]="TO_DELETE",e[e.ERROR_FORMAT=-3]="ERROR_FORMAT",e[e.ERROR_GENERIC=-2]="ERROR_GENERIC",e[e.ERROR_SIZE=-1]="ERROR_SIZE",e[e.NONE=0]="NONE",e[e.TO_RECOMPRESS=1]="TO_RECOMPRESS",e[e.COMPRESSED=2]="COMPRESSED",e[e.RECOMPRESSED=2]="RECOMPRESSED",e[e.CONVERTED=2]="CONVERTED",e[e.EDITED=3]="EDITED",e[e.UPLOAD_READY=4]="UPLOAD_READY",e[e.UPLOADING=5]="UPLOADING",e[e.UPLOADED=6]="UPLOADED",e[e.PENDING=7]="PENDING"}(WF||(WF={}));var qF,KF={exports:{}},JF={exports:{}},XF={};var QF,eP,tP,nP,rP,iP,aP,oP,sP,uP,cP,lP,dP,fP,pP={};
437
437
  /** @license React v16.13.1
438
438
  * react-is.development.js
439
439
  *
@@ -927,7 +927,7 @@ object-assign
927
927
  stroke: ${x.Primary};
928
928
  stroke-width: 1;
929
929
  }
930
- `,CU=r=>{const{accepts:i,activeFileIndex:a,capture:o,id:u="image-thumbnails",images:c,maxFiles:l,onClickThumbnail:d,onSelectFile:f,multiple:p}=r,h=s(null),m=N(),g=async e=>{const t=Array.from(e.target.files||[]);t.length&&setTimeout((()=>{f(t)}),100)},y=()=>h?.current?.click();return t(AU,{id:dA.generateId(u),children:[c.map(((n,r)=>n.status===WF.NONE?e(MU,{children:[...Array(4)].map(((t,n)=>e(xU,{},`dot-${n}`)))},r):n.status>WF.NONE||n.status===WF.ERROR_CUSTOM_MUTED?e(EU,{id:dA.generateId(u,`item-${r+1}`),"data-testid":dA.generateId(u,`item-${r+1}`),src:n.thumbnailDataURL||n.dataURL||"https://assets.life.gov.sg/web-frontend-engine/img/icons/photo-placeholder-add.svg",type:"button","aria-label":`thumbnail of ${n.name}`,onClick:()=>d(r),children:e(TU,{isSelected:a===r})},r):"reviewModal"===n.addedFrom||n.status<WF.NONE?t(EU,{id:dA.generateId(u,`item-${r+1}`),"data-testid":dA.generateId(u,`item-${r+1}`),type:"button","aria-label":`error with ${n.name}`,onClick:()=>d(r),error:!0,children:[e(TU,{isSelected:a===r}),e(SU,{})]},r):void 0)),(c.filter((({status:e,addedFrom:t})=>e>=WF.NONE||e===WF.ERROR_CUSTOM_MUTED||"reviewModal"===t)).length<l||!l)&&t(n,{children:[e(OU,{id:dA.generateId(u,"file-input"),"data-testid":dA.generateId(u,"file-input"),type:"file","aria-hidden":"true",tabIndex:-1,capture:o,ref:h,accept:i.map((e=>`.${e}`)).join(", "),onChange:g,multiple:p,value:""}),e(NU,{type:"button",id:dA.generateId(u,"add-image-button"),"data-testid":dA.generateId(u,"add-image-button"),"aria-label":"add image",onClick:y,theme:m||ie,children:e(ae,{})})]})]})},DU=y((()=>import("./index.5a6b29eb.js"))),LU=[{color:"#282828",label:"black"},{color:"#FFF",colorScheme:"light",label:"white"},{color:"#017cd3",label:"blue"},{color:"#fb0101",label:"red"},{color:"#22910c",label:"green"},{color:"#f8e821",label:"yellow"}],IU=r=>{const{accepts:i,capture:a,className:c,compress:f,dimensions:p,id:h="image-review",maxFiles:m,maxSizeInKb:g,onExit:y,outputType:v,show:b,multiple:A,maxFilesErrorMessage:E,imageReviewModalStyles:S}=r,{images:w,setImages:x}=l(VF),{dispatchFieldEvent:M,addFieldEventListener:T,removeFieldEventListener:O}=ek(),N=n$(b),[C,L]=o(w.length-1),[I,k]=o(!1),[$,R]=o(),z=!!w?.find((({status:e})=>e===WF.NONE)),[F,P]=o(LU[0].color),[Z,U]=o(!1),j=s(null),B=!!w?.find((({addedFrom:e,status:t})=>"reviewModal"===e&&t<=WF.NONE))||!w.length,V=d((e=>{e.detail.removePendingImages&&x((e=>e.filter((({status:e})=>e===WF.UPLOADED||e===WF.ERROR_CUSTOM_MUTED)))),y()}),[y,x]),G=e=>{!m||e.length+w.filter((({status:e,addedFrom:t})=>e>=WF.NONE||"reviewModal"===t)).length<=m?e.forEach((e=>{x((t=>{const n=HF.findAvailableSlot(t);return[...t,{id:lm(),file:e,name:e.name,dimensions:p,status:WF.NONE,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))})):x((t=>{const n=HF.findAvailableSlot(t);return[...t,{id:lm(),file:e[0],name:e[0].name,dimensions:p,status:WF.ERROR_EXCEED,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))},H=e=>{e&&(x((e=>e.map(((e,t)=>({...e,...t===C?{status:WF.TO_DELETE}:{}}))))),L(Math.max(0,C-1))),R(null)},Y=d((()=>{x((e=>e.filter((({status:e})=>e>=WF.NONE||e===WF.ERROR_CUSTOM_MUTED)).map((e=>{const t={...e};return e.drawingDataURL&&(t.dataURL=e.drawingDataURL),e.status<WF.UPLOAD_READY&&e.status>WF.NONE&&(t.status=WF.UPLOAD_READY),t.drawingDataURL=void 0,t.drawing=void 0,t}))))}),[x]),W=()=>{!M("save-review-images",h,{images:w,retry:W})||(Y(),y())},q=()=>{k(!0),P(LU[0].color)},K=async()=>{const{dataURL:e,drawing:t}=j.current?.export()||{},n=await Gb.dataUrlToImage(e),r=await Gb.resampleImage(n,{scale:96/n.width,type:om.fileExtensionToMimeType(v)}),i=await om.fileToDataUrl(r);x((n=>{const r=[...n];return r[C]={...r[C],thumbnailDataURL:i,drawingDataURL:e,drawing:t,status:f?WF.TO_RECOMPRESS:WF.EDITED},r})),k(!1),Q()},J=()=>{Q(),U(!0)},Q=()=>{P(""),U(!1)};u((()=>{const e={"trigger-save-review-images":Y,"dismiss-review-modal":V};return Object.entries(e).forEach((([e,t])=>{T(e,h,t)})),()=>{Object.entries(e).forEach((([e,t])=>{O(e,h,t)}))}}),[T,V,Y,h,O]),u((()=>{L(w.length-1)}),[w.length]),u((()=>{b?M("show-review-modal",h):N&&M("hide-review-modal",h)}),[b]);return e(D,{id:dA.generateId(h,void 0,b?"show":"hide"),className:c?`${c}-review`:void 0,show:b,children:e(eU,{className:c?`${c}-review-modal-box`:void 0,imageReviewModalStyles:S,showCloseButton:!1,children:b?t(n,{children:[e(tU,{className:c?`${c}-header`:void 0,$drawActive:I,children:t(n,I?{children:[e(aU,{id:dA.generateId(h,"clear-drawing-button"),"data-testid":dA.generateId(h,"clear-drawing-button"),onClick:()=>R("clear-drawing"),children:"Clear"}),e(aU,{id:dA.generateId(h,"save-drawing"),"data-testid":dA.generateId(h,"save-drawing"),onClick:K,children:"Save"})]}:{children:[e(nU,{id:dA.generateId(h,"close-button"),"data-testid":dA.generateId(h,"close-button"),"aria-label":"exit review modal",onClick:()=>R("exit"),children:e(X,{type:"cross"})}),e(rU,{weight:"semibold",children:"Review photos"})]})}),t(oU,{children:[w.length>0&&e(pU,{className:c?`${c}-editor`:void 0,children:e(_,{fallback:null,children:e(DU,{baseImageDataURL:w[C]?.dataURL,drawing:w[C]?.drawing,color:I?F:void 0,erase:!!I&&Z,ref:j,maxSizeInKb:g})})}),w.length>0&&e(sU,{children:"Loading Preview..."}),!I&&w[C]?.status>=WF.NONE&&t(uU,{children:[t(cU,{id:dA.generateId(h,"draw-button"),"data-testid":dA.generateId(h,"draw-button"),onClick:q,disabled:z,children:[e(dU,{$disabled:z}),e(lU,{weight:"semibold",$disabled:z,children:"Draw"})]}),t(cU,{id:dA.generateId(h,"delete-button"),"data-testid":dA.generateId(h,"delete-button"),onClick:()=>R("delete"),disabled:z,children:[e(fU,{$disabled:z}),e(lU,{weight:"semibold",$disabled:z,children:"Delete"})]})]}),w[C]?.status<WF.NONE&&e(XZ,{id:`${h}-photo-error`,image:w[C],accepts:i,maxSizeInKb:g,onClickOk:()=>H(!0),maxFilesErrorMessage:E,maxFiles:m})]}),e(hU,{className:c?`${c}-footer`:void 0,children:t(n,I?{children:[e(gU,{id:dA.generateId(h,"eraser-button"),"data-testid":dA.generateId(h,"eraser-button"),"aria-label":"eraser",onClick:J,children:e(yU,{$eraseMode:Z})}),e(vU,{children:LU.map((({color:t,colorScheme:n,label:r},i)=>e(bU,{id:dA.generateId(h,`palette-color-${i}`),"aria-label":`${r} brush`,$color:t,$colorScheme:n,onClick:()=>(e=>{Q(),P(e)})(t),children:F===t&&e(_U,{$colorScheme:n})},t)))})]}:{children:[e(CU,{id:`${h}-image-thumbnails`,activeFileIndex:C,accepts:i,capture:a,maxFiles:m,images:w,onClickThumbnail:L,onSelectFile:G,multiple:A}),e(mU,{id:dA.generateId(h,"save-button"),"data-testid":dA.generateId(h,"save-button"),onClick:W,disabled:B,children:"Save"})]})}),e(QZ,{images:w,show:$,onDecideClearDrawing:e=>{e&&j.current.clearDrawing(),R(null)},onDecideDelete:H,onDecideExit:e=>{e&&(x(w.filter((({addedFrom:e,status:t})=>t>=WF.UPLOADED||t<WF.NONE&&"dragInput"===e)).map((e=>({...e,drawingDataURL:void 0,drawing:void 0})))),y()),R(null)}})]}):e(n,{})})})},kU=y((()=>import("./index.4b4ecdb7.js"))),$U=r=>{const{schema:{buttonLabel:i,capture:a,className:s,compress:c,description:d,dimensions:f={width:1e3,height:1e3},editImage:p,label:h,outputType:m="jpg",uploadOnAddingFile:g,validation:y,multiple:v,imageReviewModalStyles:b},id:A,isDirty:E,isTouched:S,value:w,warning:x,...M}=r,{images:T,setImages:O,currentFileIds:N}=l(VF),C=n$(T),[D,L]=o([...YF]),[I,k]=o(0),[$,R]=o(0),[z,F]=o(!1),[P,Z]=o(!1),{setFieldValidationConfig:U}=Xk(),{dispatchFieldEvent:j}=ek();u((()=>{j("mount",A)}),[j,A]),u((()=>{if(!E&&!S){const e=Array.isArray(w)?w:[];if(!(zF(e.map((({fileId:e})=>e)),N).length>0))return;const t=[];e.forEach((({fileId:e,fileName:n,dataURL:r,uploadResponse:i},a)=>{const o={id:e||lm(),file:{},name:n,dimensions:{width:10,height:10},dataURL:r,status:WF.INJECTED,addedFrom:"schema",uploadProgress:100,slot:a,uploadResponse:i};t.push(o)})),O(t)}}),[E,S,N,O,w]),u((()=>{const e=y?.find((e=>"required"in e)),t=y?.find((e=>"fileType"in e)),n=y?.find((e=>"maxSizeInKb"in e));t?.fileType&&t?.fileType!==D&&L(t?.fileType),n?.maxSizeInKb&&n?.maxSizeInKb!==$&&R(n?.maxSizeInKb);const r=y?.find((e=>"length"in e)),i=y?.find((e=>"max"in e));let a;r?a={maxFiles:r.length,errorMessage:r.errorMessage}:i&&(a={maxFiles:i.max,errorMessage:i.errorMessage}),a?.maxFiles&&I!==a.maxFiles&&k(a.maxFiles),U(A,FM().of(RM().shape({fileName:Ax(),dataURL:Ax()})).test("is-empty-array",e?.errorMessage||sm.UPLOAD("photo").REQUIRED,(t=>!t||!e?.required||t.length>0)).test("max-size-in-kb",n?.errorMessage||sm.UPLOAD("photo").MAX_FILE_SIZE(n?.maxSizeInKb),(e=>!(e&&Array.isArray(e)&&n?.maxSizeInKb)||e.every((e=>om.getFilesizeFromBase64(e.dataURL)<=1024*n?.maxSizeInKb)))),y)}),[y]),u((()=>{T.some(((e,t)=>{const n=C?.[t];if(e.status!==n?.status||e.dataURL!==n.dataURL)switch(e.status){case WF.COMPRESSED:case WF.CONVERTED:if(p&&!P)return fA.isMobileView()?Z(!0):F(!0),!0}})),0===T.length&&Z(!1)}),[T.map((e=>e.status)).join(","),T.map((e=>e.dataURL)).join(",")]);const B=(e=!1)=>{e?p&&(document.body.classList.remove("lifesg-ds-overlay-open"),Z(!0)):O((e=>e.map((e=>e.status<WF.UPLOAD_READY&&e.status>WF.NONE?{...e,status:WF.UPLOAD_READY}:e)))),F(!1)};return t(n,{children:[e(_,{fallback:null,children:e(kU,{accepts:D,compress:!!c,dimensions:f,editImage:p,id:A,maxSizeInKb:$,outputType:m,upload:g,value:w})}),e(GZ,{id:A,capture:a,className:s,label:h,description:d,buttonLabel:i,accepts:D,maxFiles:I,maxSizeInKb:$,dimensions:f,errorMessage:M.error?.message,validation:y,multiple:v,warning:x}),e(tT,{id:`${A}-review-prompt`,title:"Review photos?",size:"large",show:z,description:"This lets you check if you've selected the correct photos, and draw on them to highlight the issue.",buttons:[{id:"ok",title:"Ok",onClick:()=>B(!0)},{id:"skip",title:"Skip",buttonStyle:"secondary",onClick:()=>B()}]}),(()=>{const t=y?.find((e=>"max"in e));return e(IU,{accepts:D,dimensions:f,id:A,className:s,maxFiles:I,maxFilesErrorMessage:t?.errorMessage,maxSizeInKb:$,onExit:()=>Z(!1),outputType:m,show:P,multiple:v,capture:a,imageReviewModalStyles:b})})()]})},RU=T`
930
+ `,CU=r=>{const{accepts:i,activeFileIndex:a,capture:o,id:u="image-thumbnails",images:c,maxFiles:l,onClickThumbnail:d,onSelectFile:f,multiple:p}=r,h=s(null),m=N(),g=async e=>{const t=Array.from(e.target.files||[]);t.length&&setTimeout((()=>{f(t)}),100)},y=()=>h?.current?.click();return t(AU,{id:dA.generateId(u),children:[c.map(((n,r)=>n.status===WF.NONE?e(MU,{children:[...Array(4)].map(((t,n)=>e(xU,{},`dot-${n}`)))},r):n.status>WF.NONE||n.status===WF.ERROR_CUSTOM_MUTED?e(EU,{id:dA.generateId(u,`item-${r+1}`),"data-testid":dA.generateId(u,`item-${r+1}`),src:n.thumbnailDataURL||n.dataURL||"https://assets.life.gov.sg/web-frontend-engine/img/icons/photo-placeholder-add.svg",type:"button","aria-label":`thumbnail of ${n.name}`,onClick:()=>d(r),children:e(TU,{isSelected:a===r})},r):"reviewModal"===n.addedFrom||n.status<WF.NONE?t(EU,{id:dA.generateId(u,`item-${r+1}`),"data-testid":dA.generateId(u,`item-${r+1}`),type:"button","aria-label":`error with ${n.name}`,onClick:()=>d(r),error:!0,children:[e(TU,{isSelected:a===r}),e(SU,{})]},r):void 0)),(c.filter((({status:e,addedFrom:t})=>e>=WF.NONE||e===WF.ERROR_CUSTOM_MUTED||"reviewModal"===t)).length<l||!l)&&t(n,{children:[e(OU,{id:dA.generateId(u,"file-input"),"data-testid":dA.generateId(u,"file-input"),type:"file","aria-hidden":"true",tabIndex:-1,capture:o,ref:h,accept:i.map((e=>`.${e}`)).join(", "),onChange:g,multiple:p,value:""}),e(NU,{type:"button",id:dA.generateId(u,"add-image-button"),"data-testid":dA.generateId(u,"add-image-button"),"aria-label":"add image",onClick:y,theme:m||ie,children:e(ae,{})})]})]})},DU=y((()=>import("./index.54c2add7.js"))),LU=[{color:"#282828",label:"black"},{color:"#FFF",colorScheme:"light",label:"white"},{color:"#017cd3",label:"blue"},{color:"#fb0101",label:"red"},{color:"#22910c",label:"green"},{color:"#f8e821",label:"yellow"}],IU=r=>{const{accepts:i,capture:a,className:c,compress:f,dimensions:p,id:h="image-review",maxFiles:m,maxSizeInKb:g,onExit:y,outputType:v,show:b,multiple:A,maxFilesErrorMessage:E,imageReviewModalStyles:S}=r,{images:w,setImages:x}=l(VF),{dispatchFieldEvent:M,addFieldEventListener:T,removeFieldEventListener:O}=ek(),N=n$(b),[C,L]=o(w.length-1),[I,k]=o(!1),[$,R]=o(),z=!!w?.find((({status:e})=>e===WF.NONE)),[F,P]=o(LU[0].color),[Z,U]=o(!1),j=s(null),B=!!w?.find((({addedFrom:e,status:t})=>"reviewModal"===e&&t<=WF.NONE))||!w.length,V=d((e=>{e.detail.removePendingImages&&x((e=>e.filter((({status:e})=>e===WF.UPLOADED||e===WF.ERROR_CUSTOM_MUTED)))),y()}),[y,x]),G=e=>{!m||e.length+w.filter((({status:e,addedFrom:t})=>e>=WF.NONE||"reviewModal"===t)).length<=m?e.forEach((e=>{x((t=>{const n=HF.findAvailableSlot(t);return[...t,{id:lm(),file:e,name:e.name,dimensions:p,status:WF.NONE,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))})):x((t=>{const n=HF.findAvailableSlot(t);return[...t,{id:lm(),file:e[0],name:e[0].name,dimensions:p,status:WF.ERROR_EXCEED,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))},H=e=>{e&&(x((e=>e.map(((e,t)=>({...e,...t===C?{status:WF.TO_DELETE}:{}}))))),L(Math.max(0,C-1))),R(null)},Y=d((()=>{x((e=>e.filter((({status:e})=>e>=WF.NONE||e===WF.ERROR_CUSTOM_MUTED)).map((e=>{const t={...e};return e.drawingDataURL&&(t.dataURL=e.drawingDataURL),e.status<WF.UPLOAD_READY&&e.status>WF.NONE&&(t.status=WF.UPLOAD_READY),t.drawingDataURL=void 0,t.drawing=void 0,t}))))}),[x]),W=()=>{!M("save-review-images",h,{images:w,retry:W})||(Y(),y())},q=()=>{k(!0),P(LU[0].color)},K=async()=>{const{dataURL:e,drawing:t}=j.current?.export()||{},n=await Gb.dataUrlToImage(e),r=await Gb.resampleImage(n,{scale:96/n.width,type:om.fileExtensionToMimeType(v)}),i=await om.fileToDataUrl(r);x((n=>{const r=[...n];return r[C]={...r[C],thumbnailDataURL:i,drawingDataURL:e,drawing:t,status:f?WF.TO_RECOMPRESS:WF.EDITED},r})),k(!1),Q()},J=()=>{Q(),U(!0)},Q=()=>{P(""),U(!1)};u((()=>{const e={"trigger-save-review-images":Y,"dismiss-review-modal":V};return Object.entries(e).forEach((([e,t])=>{T(e,h,t)})),()=>{Object.entries(e).forEach((([e,t])=>{O(e,h,t)}))}}),[T,V,Y,h,O]),u((()=>{L(w.length-1)}),[w.length]),u((()=>{b?M("show-review-modal",h):N&&M("hide-review-modal",h)}),[b]);return e(D,{id:dA.generateId(h,void 0,b?"show":"hide"),className:c?`${c}-review`:void 0,show:b,children:e(eU,{className:c?`${c}-review-modal-box`:void 0,imageReviewModalStyles:S,showCloseButton:!1,children:b?t(n,{children:[e(tU,{className:c?`${c}-header`:void 0,$drawActive:I,children:t(n,I?{children:[e(aU,{id:dA.generateId(h,"clear-drawing-button"),"data-testid":dA.generateId(h,"clear-drawing-button"),onClick:()=>R("clear-drawing"),children:"Clear"}),e(aU,{id:dA.generateId(h,"save-drawing"),"data-testid":dA.generateId(h,"save-drawing"),onClick:K,children:"Save"})]}:{children:[e(nU,{id:dA.generateId(h,"close-button"),"data-testid":dA.generateId(h,"close-button"),"aria-label":"exit review modal",onClick:()=>R("exit"),children:e(X,{type:"cross"})}),e(rU,{weight:"semibold",children:"Review photos"})]})}),t(oU,{children:[w.length>0&&e(pU,{className:c?`${c}-editor`:void 0,children:e(_,{fallback:null,children:e(DU,{baseImageDataURL:w[C]?.dataURL,drawing:w[C]?.drawing,color:I?F:void 0,erase:!!I&&Z,ref:j,maxSizeInKb:g})})}),w.length>0&&e(sU,{children:"Loading Preview..."}),!I&&w[C]?.status>=WF.NONE&&t(uU,{children:[t(cU,{id:dA.generateId(h,"draw-button"),"data-testid":dA.generateId(h,"draw-button"),onClick:q,disabled:z,children:[e(dU,{$disabled:z}),e(lU,{weight:"semibold",$disabled:z,children:"Draw"})]}),t(cU,{id:dA.generateId(h,"delete-button"),"data-testid":dA.generateId(h,"delete-button"),onClick:()=>R("delete"),disabled:z,children:[e(fU,{$disabled:z}),e(lU,{weight:"semibold",$disabled:z,children:"Delete"})]})]}),w[C]?.status<WF.NONE&&e(XZ,{id:`${h}-photo-error`,image:w[C],accepts:i,maxSizeInKb:g,onClickOk:()=>H(!0),maxFilesErrorMessage:E,maxFiles:m})]}),e(hU,{className:c?`${c}-footer`:void 0,children:t(n,I?{children:[e(gU,{id:dA.generateId(h,"eraser-button"),"data-testid":dA.generateId(h,"eraser-button"),"aria-label":"eraser",onClick:J,children:e(yU,{$eraseMode:Z})}),e(vU,{children:LU.map((({color:t,colorScheme:n,label:r},i)=>e(bU,{id:dA.generateId(h,`palette-color-${i}`),"aria-label":`${r} brush`,$color:t,$colorScheme:n,onClick:()=>(e=>{Q(),P(e)})(t),children:F===t&&e(_U,{$colorScheme:n})},t)))})]}:{children:[e(CU,{id:`${h}-image-thumbnails`,activeFileIndex:C,accepts:i,capture:a,maxFiles:m,images:w,onClickThumbnail:L,onSelectFile:G,multiple:A}),e(mU,{id:dA.generateId(h,"save-button"),"data-testid":dA.generateId(h,"save-button"),onClick:W,disabled:B,children:"Save"})]})}),e(QZ,{images:w,show:$,onDecideClearDrawing:e=>{e&&j.current.clearDrawing(),R(null)},onDecideDelete:H,onDecideExit:e=>{e&&(x(w.filter((({addedFrom:e,status:t})=>t>=WF.UPLOADED||t<WF.NONE&&"dragInput"===e)).map((e=>({...e,drawingDataURL:void 0,drawing:void 0})))),y()),R(null)}})]}):e(n,{})})})},kU=y((()=>import("./index.b9888bc5.js"))),$U=r=>{const{schema:{buttonLabel:i,capture:a,className:s,compress:c,description:d,dimensions:f={width:1e3,height:1e3},editImage:p,label:h,outputType:m="jpg",uploadOnAddingFile:g,validation:y,multiple:v,imageReviewModalStyles:b},id:A,isDirty:E,isTouched:S,value:w,warning:x,...M}=r,{images:T,setImages:O,currentFileIds:N}=l(VF),C=n$(T),[D,L]=o([...YF]),[I,k]=o(0),[$,R]=o(0),[z,F]=o(!1),[P,Z]=o(!1),{setFieldValidationConfig:U}=Xk(),{dispatchFieldEvent:j}=ek();u((()=>{j("mount",A)}),[j,A]),u((()=>{if(!E&&!S){const e=Array.isArray(w)?w:[];if(!(zF(e.map((({fileId:e})=>e)),N).length>0))return;const t=[];e.forEach((({fileId:e,fileName:n,dataURL:r,uploadResponse:i},a)=>{const o={id:e||lm(),file:{},name:n,dimensions:{width:10,height:10},dataURL:r,status:WF.INJECTED,addedFrom:"schema",uploadProgress:100,slot:a,uploadResponse:i};t.push(o)})),O(t)}}),[E,S,N,O,w]),u((()=>{const e=y?.find((e=>"required"in e)),t=y?.find((e=>"fileType"in e)),n=y?.find((e=>"maxSizeInKb"in e));t?.fileType&&t?.fileType!==D&&L(t?.fileType),n?.maxSizeInKb&&n?.maxSizeInKb!==$&&R(n?.maxSizeInKb);const r=y?.find((e=>"length"in e)),i=y?.find((e=>"max"in e));let a;r?a={maxFiles:r.length,errorMessage:r.errorMessage}:i&&(a={maxFiles:i.max,errorMessage:i.errorMessage}),a?.maxFiles&&I!==a.maxFiles&&k(a.maxFiles),U(A,FM().of(RM().shape({fileName:Ax(),dataURL:Ax()})).test("is-empty-array",e?.errorMessage||sm.UPLOAD("photo").REQUIRED,(t=>!t||!e?.required||t.length>0)).test("max-size-in-kb",n?.errorMessage||sm.UPLOAD("photo").MAX_FILE_SIZE(n?.maxSizeInKb),(e=>!(e&&Array.isArray(e)&&n?.maxSizeInKb)||e.every((e=>om.getFilesizeFromBase64(e.dataURL)<=1024*n?.maxSizeInKb)))),y)}),[y]),u((()=>{T.some(((e,t)=>{const n=C?.[t];if(e.status!==n?.status||e.dataURL!==n.dataURL)switch(e.status){case WF.COMPRESSED:case WF.CONVERTED:if(p&&!P)return fA.isMobileView()?Z(!0):F(!0),!0}})),0===T.length&&Z(!1)}),[T.map((e=>e.status)).join(","),T.map((e=>e.dataURL)).join(",")]);const B=(e=!1)=>{e?p&&(document.body.classList.remove("lifesg-ds-overlay-open"),Z(!0)):O((e=>e.map((e=>e.status<WF.UPLOAD_READY&&e.status>WF.NONE?{...e,status:WF.UPLOAD_READY}:e)))),F(!1)};return t(n,{children:[e(_,{fallback:null,children:e(kU,{accepts:D,compress:!!c,dimensions:f,editImage:p,id:A,maxSizeInKb:$,outputType:m,upload:g,value:w})}),e(GZ,{id:A,capture:a,className:s,label:h,description:d,buttonLabel:i,accepts:D,maxFiles:I,maxSizeInKb:$,dimensions:f,errorMessage:M.error?.message,validation:y,multiple:v,warning:x}),e(tT,{id:`${A}-review-prompt`,title:"Review photos?",size:"large",show:z,description:"This lets you check if you've selected the correct photos, and draw on them to highlight the issue.",buttons:[{id:"ok",title:"Ok",onClick:()=>B(!0)},{id:"skip",title:"Skip",buttonStyle:"secondary",onClick:()=>B()}]}),(()=>{const t=y?.find((e=>"max"in e));return e(IU,{accepts:D,dimensions:f,id:A,className:s,maxFiles:I,maxFilesErrorMessage:t?.errorMessage,maxSizeInKb:$,onExit:()=>Z(!1),outputType:m,show:P,multiple:v,capture:a,imageReviewModalStyles:b})})()]})},RU=T`
931
931
  border: 1px solid ${x.Accent.Light[1]};
932
932
  box-shadow: none;
933
933
  `,zU=T`
@@ -1010,7 +1010,7 @@ object-assign
1010
1010
  ${e=>T`
1011
1011
  margin-left: ${e.$readOnly?"0.25rem":"0.75rem"};
1012
1012
  `}
1013
- `,jU=n=>{const{id:r,"data-testid":i,className:a,disabled:o,readOnly:s,onFocus:u,value:c,placeholder:l,error:d}=n;return t(PU,{id:r,"data-testid":i,type:"button",className:a,disabled:o,$readOnly:s,$error:d,onFocus:u,onClick:e=>{o||e.currentTarget.focus()},tabIndex:o?-1:0,"aria-disabled":o||void 0,"aria-haspopup":"dialog","aria-readonly":s,children:[e(ZU,l&&!c?{$placeholder:!0,$disabled:o,children:l}:{$disabled:o,children:c}),e(UU,{$disabled:o,$readOnly:s,"aria-hidden":"true",children:e(se,{})})]})},BU=t=>{const{id:n,label:r,className:i,locationInputPlaceholder:a="",onFocus:o,value:s,errorMessage:u,disabled:c,readOnly:l}=t;return e(W.CustomField,{id:dA.generateId(n,"location-input"),"data-testid":dA.generateId(n,"location-input"),label:r,errorMessage:u,children:e(jU,{id:dA.generateId(n,"location-input-base"),"data-testid":dA.generateId(n,"location-input-base"),disabled:c,readOnly:l,placeholder:a,onFocus:o,value:s,error:!!u,className:i})})},VU=y((()=>import("./location-modal.ddb76a07.js")));class GU extends Error{code;message;constructor(e){super(),Object.assign(this,e)}}const HU=M(S.BodySmall)`
1013
+ `,jU=n=>{const{id:r,"data-testid":i,className:a,disabled:o,readOnly:s,onFocus:u,value:c,placeholder:l,error:d}=n;return t(PU,{id:r,"data-testid":i,type:"button",className:a,disabled:o,$readOnly:s,$error:d,onFocus:u,onClick:e=>{o||e.currentTarget.focus()},tabIndex:o?-1:0,"aria-disabled":o||void 0,"aria-haspopup":"dialog","aria-readonly":s,children:[e(ZU,l&&!c?{$placeholder:!0,$disabled:o,children:l}:{$disabled:o,children:c}),e(UU,{$disabled:o,$readOnly:s,"aria-hidden":"true",children:e(se,{})})]})},BU=t=>{const{id:n,label:r,className:i,locationInputPlaceholder:a="",onFocus:o,value:s,errorMessage:u,disabled:c,readOnly:l}=t;return e(W.CustomField,{id:dA.generateId(n,"location-input"),"data-testid":dA.generateId(n,"location-input"),label:r,errorMessage:u,children:e(jU,{id:dA.generateId(n,"location-input-base"),"data-testid":dA.generateId(n,"location-input-base"),disabled:c,readOnly:l,placeholder:a,onFocus:o,value:s,error:!!u,className:i})})},VU=y((()=>import("./location-modal.53039680.js")));class GU extends Error{code;message;constructor(e){super(),Object.assign(this,e)}}const HU=M(S.BodySmall)`
1014
1014
  cursor: ${e=>e.disabled?"not-allowed":"pointer"};
1015
1015
  `,YU=M(le)`
1016
1016
  margin-right: 5px;
@@ -1051,4 +1051,4 @@ object-assign
1051
1051
  `,cj=M.div`
1052
1052
  flex: 1;
1053
1053
  `,lj=t=>{const{sectionSchema:{children:n,layoutType:r},...i}=t;switch(r){case"grid":return e($.Section,{children:e(uj,{type:"grid",children:e(sj,{...i,children:n})})});case"contain":return e($.Content,{children:e(cj,{children:e(sj,{...i,children:n})})});default:return e(sj,{...i,children:n})}},dj=()=>{const{formSchema:{sections:r,overrides:i},overrideSchema:a}=Kk();return e(n,{children:(()=>{const o=a(r,i);return o?Object.entries(o).map((([t,n],r)=>e(lj,{id:t,sectionSchema:n},`section-${r}`))):t(n,{children:["Unable to render Frontend Engine schema, make sure schema is declared within ",e("code",{children:"sections"}),"."]})})()})},fj=h(((r,a)=>{const{data:c,className:l=null,components:f,onSubmit:p,onSubmitError:h,wrapInForm:g=!0}=r,{className:y=null,defaultValues:_,id:v,stripUnknown:b,revalidationMode:A="onChange",validationMode:E="onTouched"}=c||{},{addFieldEventListener:S,dispatchFieldEvent:w,removeFieldEventListener:x}=ek(),{setCustomComponents:M}=XI(),{setSubmitHandler:T,setWrapInForm:O}=e$(),{addWarnings:N,performSoftValidation:C,softValidationSchema:D,hardValidationSchema:L,rebuildValidationSchema:I,yupId:k}=r$(),$=function(e={}){const t=i.useRef(void 0),n=i.useRef(void 0),[r,a]=i.useState({isDirty:!1,isValidating:!1,isLoading:ut(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ut(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...zt(e),formState:r});const o=t.current.control;return o._options=e,Ke({subject:o._subjects.state,next:e=>{Ye(e,o._proxyFormState,o._updateFormState,!0)&&a({...o._formState})}}),i.useEffect((()=>o._disableForm(e.disabled)),[o,e.disabled]),i.useEffect((()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==r.isDirty&&o._subjects.state.next({isDirty:e})}}),[o,r.isDirty]),i.useEffect((()=>{e.values&&!wt(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values,a((e=>({...e})))):o._resetDefaultValues()}),[e.values,o]),i.useEffect((()=>{e.errors&&o._setErrors(e.errors)}),[e.errors,o]),i.useEffect((()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()})),i.useEffect((()=>{e.shouldUnregister&&o._subjects.values.next({values:o._getWatch()})}),[e.shouldUnregister,o]),t.current.formState=Ge(r,o),t.current}({mode:E,reValidateMode:A,defaultValues:_,resolver:async(e,t,n)=>(C(D,e),await function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),function(r,i,a){try{return Promise.resolve(function(o,s){try{var u=(t.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e["sync"===n.mode?"validateSync":"validate"](r,Object.assign({abortEarly:!1},t,{context:i}))).then((function(e){return a.shouldUseNativeValidation&&Pt({},a),{values:n.rawValues?r:e,errors:{}}})))}catch(e){return s(e)}return u&&u.then?u.then(void 0,s):u}(0,(function(e){if(!e.inner)throw e;return{values:{},errors:Zt((t=e,n=!a.shouldUseNativeValidation&&"all"===a.criteriaMode,(t.inner||[]).reduce((function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var r=e[t.path].types,i=r&&r[t.type];e[t.path]=nt(t.path,n,e,t.type,i?[].concat(i,t.message):t.message)}return e}),{})),a)};var t,n})))}catch(e){return Promise.reject(e)}}}(L)(e,t,n))}),{setFormSchema:R}=Kk(),{reset:z,handleSubmit:F,getValues:P,setValue:Z,setError:U,trigger:j,formState:B,clearErrors:V}=$,{resetFields:G,setFields:H,getFormValues:Y,registeredFields:W}=Jk($),q=s(W),{checkIsFormValid:K}=((e,t)=>{const{data:n,onChange:r,onValueChange:i}=e,{stripUnknown:a}=n||{},{hardValidationSchema:c}=r$(),{formValidationConfig:l}=Xk(),{watch:f,getValues:p,formState:h,clearErrors:m}=t,{setFields:g,setField:y,getFormValues:_}=Jk(t),[v,b]=o({}),[A,E]=o(!1),S=n$(l),w=n$(c),x=s(void 0),M=s(void 0),T=d(((e=!1)=>{if(!e)try{return c.validateSync(p()),!0}catch(e){return!1}return(async()=>{try{return await c.validate(p()),!0}catch(e){return!1}})()}),[p,c]),O=s((async()=>{}));return O.current=async()=>{const e=_(void 0,a),t=await T(!0);i&&Object.keys(l||{}).length&&(M.current===t&&PI(x.current,e)||i(e,t)),x.current=e,M.current=t},u((()=>{const e=f(((e,{name:t})=>{t?y(t,e[t]):g(e)}));return()=>e.unsubscribe()}),[]),u((()=>{if(r&&Object.keys(l||{}).length){const e=f((async()=>{const e=await T(!0);r(_(void 0,a),e)}));return T(!0).then((e=>r(_(void 0,a),e))),()=>e.unsubscribe()}}),[T,r,f,l]),u((()=>{const e=f((async()=>{await O.current()}));return()=>e.unsubscribe()}),[f]),u((()=>{if(S){const e=e=>Object.entries(e).map((([e,{validationRules:t}])=>[e,t])),t=e(S),n=e(l);PI(t,n)||E(!0)}}),[l]),u((()=>{A&&w!==c&&O.current().then((()=>E(!1)))}),[A,c]),u((()=>{const e=h.errors;if(e&&!cA(e)){const e=f((e=>{const t=Object.fromEntries(Object.entries(h.errors).filter((([e,t])=>"api"===t.type)));t&&!cA(t)&&Object.keys(t).forEach((t=>{v[t]!==e[t]&&m(t)})),b(e)}));return()=>e.unsubscribe()}}),[h,f]),{checkIsFormValid:T}})(r,$);m(a,(()=>({addFieldEventListener:S,addCustomValidation:J,dispatchFieldEvent:w,getValues:e=>Y(e,b),isDirty:B.isDirty,isValid:K,validate:j,removeFieldEventListener:x,reset:(e,t)=>{z(e,t),G("function"==typeof e?e($.getValues())??_:e??_)},setErrors:ee,clearErrors:V,setWarnings:te,setValue:Z,submit:F(X,Q)})));const J=(e,t,n,r=!1)=>{kI.addCondition(e,t,n,k,r),I()},X=d((()=>{p?.(Y(void 0,b))}),[Y,p,b]),Q=d((e=>{setTimeout((()=>h?.(e)))}),[h]),ee=e=>{Object.entries(e).forEach((([e,t])=>{q.current.includes(e)&&(Array.isArray(t)?U(e,{type:"api",message:t[0]}):U(e,"object"==typeof t?{type:"api",message:JSON.stringify(t)}:{type:"api",message:t}))}))},te=e=>{const t={};Object.entries(e).forEach((([e,n])=>{q.current.includes(e)&&(t[e]=n)})),N(t)};u((()=>{H(P())}),[]),zs((()=>{z(Cs(_))}),[_]),Rs((()=>{R(c)}),[c||{}]),u((()=>{M(f)}),[f]),u((()=>{T((()=>F(X,Q)))}),[X,Q]),u((()=>{O(g)}),[g]),u((()=>{q.current=W}),[W]);const ne=v?`frontend-engine-${v}`:"frontend-engine",re=[l,y].join(" ").trim(),ie=g?"form":"div";return c?e(Ve,{...$,children:e(ie,{id:ne,"data-testid":v?dA.generateId(v,"frontend-engine"):ne,className:re,noValidate:!0,onSubmit:F(X,Q),ref:a,children:e(dj,{})})}):t(n,{children:["Missing ",e("code",{children:"data"})," prop, unable to render Frontend Engine."]})})),pj=h(((t,n)=>e(JI,{children:e(fj,{...t,ref:n})})));export{fl as A,QM as D,UF as E,FF as F,GU as G,Gb as I,xI as L,MI as O,tT as P,vI as S,dA as T,fA as W,Be as a,ek as b,sm as c,om as d,VF as e,WF as f,lm as g,Ut as h,SI as i,wI as j,cm as k,bI as l,Qk as m,pj as n,c$ as o,tj as p,n$ as u};
1054
- //# sourceMappingURL=index.fc8f504e.js.map
1054
+ //# sourceMappingURL=index.a88ac40b.js.map