@ukhomeoffice/cop-react-form-renderer 8.0.0-alpha.5 → 8.0.0-alpha.7
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.
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),T=require("@ukhomeoffice/cop-react-components"),O=require("react"),mt=require("uuid"),q=require("dayjs"),Re=require("dayjs/plugin/customParseFormat"),tn=require("dayjs/plugin/isToday"),Wr=require("dayjs/plugin/isLeapYear"),ve={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},zr="alert",Jr="autocomplete",Xr="calculation",Qr="checkboxes",Zr="collection",eo="collection-summary",to="container",no="date",so="details",ro="email",oo="file",io="heading",lo="html",ao="inset-text",co="list",uo="multifile",fo="paragraph",ho="phone-number",mo="radios",po="select",Eo="text",Ao="textarea",yo="time",To="warning",b={ALERT:zr,AUTOCOMPLETE:Jr,CALCULATION:Xr,CHECKBOXES:Qr,COLLECTION:Zr,COLLECTION_SUMMARY:eo,CONTAINER:to,DATE:no,DETAILS:so,EMAIL:ro,FILE:oo,HEADING:io,HTML:lo,INSET_TEXT:ao,LIST:co,MULTI_FILE:uo,PARAGRAPH:fo,PHONE_NUMBER:ho,RADIOS:mo,SELECT:po,TEXT:Eo,TEXT_AREA:Ao,TIME:yo,WARNING:To},So="blur",Co="submit",go="cancel",Te={BLUR:So,SUBMIT:Co,CANCEL:go},bo="cya",wo="hub",Io="partial-cya",te={CYA:bo,HUB:wo,PARTIAL_CYA:Io},_o="cya",Po="form",xo="form-with-task-list",No="hub-and-spoke",Oo="task-list",Ro="task-list-cya",vo="wizard",Z={CYA:_o,FORM:Po,FORM_WITH_TASK:xo,HUB:No,TASK:Oo,TASK_CYA:Ro,WIZARD:vo},Lo="CYA",Do="TASK",he={CYA:Lo,TASK:Do},Ut="cancel",cs="collectionAdd",us="collectionDuplicate",ds="collectionRemove",fs="navigate",Mt="saveAndContinue",kt="saveAndNavigate",$t="saveAndReturn",Bt="submit",st={CANCEL:Ut,COLLECTION_ADD:cs,COLLECTION_DUPLICATE:us,COLLECTION_REMOVE:ds,NAVIGATE:fs,SAVE_AND_CONTINUE:Mt,SAVE_AND_NAVIGATE:kt,SAVE_AND_RETURN:$t,SUBMIT:Bt},Fo={[Ut]:{type:Ut,validate:!1,label:"Cancel",classModifiers:"secondary"},[cs]:void 0,[us]:void 0,[ds]:void 0,[fs]:void 0,[Mt]:{type:Mt,validate:!0,label:"Save and continue"},[kt]:{type:kt,validate:!0,label:"Save and continue"},[$t]:{type:$t,validate:!1,label:"Save and return later",classModifiers:"secondary"},[Bt]:{type:Bt,validate:!0}},G={TYPES:st,DEFAULTS:Fo},hs="complete",ms="inProgress",ps="notStarted",Es="cannotStartYet",As="skipped",jo={COMPLETE:hs,IN_PROGRESS:ms,NOT_STARTED:ps,CANNOT_START_YET:Es,SKIPPED:As},Uo={[hs]:{label:"Completed",colour:"dark-blue"},[ms]:{label:"In Progress",colour:"white"},[ps]:{label:"Not Started",colour:"dark-grey"},[Es]:{label:"Cannot Start Yet",colour:"dark-grey"},[As]:{label:"Skipped",colour:"dark-grey"}},B={TYPES:jo,DETAILS:Uo},Mo={CollectionLabels:ve,ComponentTypes:b,EventTypes:Te,FormPages:te,FormTypes:Z,HubFormats:he,PageAction:G,TaskStates:B},ys=e=>{try{const t=ko(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},ko=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return Xe(e,(n,s)=>n*s);case"divide":return Xe(e,(n,s)=>n/s);case"plus":return Xe(e,(n,s)=>n+s);case"minus":return Xe(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},Xe=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return $o(n.map(s=>Bo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},$o=(e,t)=>{const n=t.formula.round;if(!n&&n!==0||!e)return e;if(n===0)return parseInt(e,10);const s=Math.pow(10,n);return Math.round((e+Number.EPSILON)*s)/s},Bo=(e,t)=>{const n=Object.keys(e);if(n.length===1){const s=n[0],r=e[s];switch(s){case"field":{const o=Yo(r,t);return!o&&o!==0?NaN:parseFloat(o)}case"value":return parseFloat(r);case"formula":return ys({...e,formData:t});default:throw new Error("Only accept following as argument field: {field, value, or formula}")}}else throw new Error("Argument cannot have more than one reference")},Yo=(e,t)=>T.Utils.interpolateString("${"+e+"}",t),Ho=(e,t)=>{if(["in","nin","includesAllOf","!includesAllOf"].includes(e.op))return e.values;if(typeof e.value=="string"&&e.value?.startsWith("field::")){const n=e.value.replace("field::","");return le.getSource(t,n)}return e.value},Qe=e=>{if(Array.isArray(e))return e.length;if(typeof e=="string"){const t=e.replace(/,/g,"");return Number.isNaN(t)?null:parseFloat(t)}return typeof e=="number"?e:null},nn=(e,t,n)=>{if(e&&typeof e=="object"){const s=Ho(e,n);switch(e.op){case"=":case"eq":return s===t;case"!=":case"<>":case"ne":case"neq":return s!==t;case"in":return Array.isArray(s)?s.includes(t):!1;case"nin":return Array.isArray(s)?s.includes(t)===!1:!0;case"<":{const r=Qe(t),o=Qe(s);return r!=null&&o!=null&&r<o}case">":{const r=Qe(t),o=Qe(s);return r!=null&&o!=null&&r>o}case"contains":return t?.toString().toLowerCase().includes(s);case"!contains":return!t?.toString().toLowerCase().includes(s);case"includes":return Array.isArray(t)?t.includes(s):!1;case"!includes":return Array.isArray(t)?!t.includes(s):!0;case"includesObjectProp":return Array.isArray(t)?t.some(r=>r[e.key]===s):!1;case"!includesObjectProp":return Array.isArray(t)?!t.some(r=>r[e.key]===s):!0;case"includesAllOf":return Array.isArray(t)?s.every(r=>t.includes(r)):!1;case"!includesAllOf":return Array.isArray(t)?!s.every(r=>t.includes(r)):!0;default:return!1}}return!0},Vo=e=>{if(e.show_when){let t=e.show_when.type?e.show_when.conditions:e.show_when;const n=e.full_path;return t=Array.isArray(t)?t:[t],t.map(s=>{const r=le.getDataPath(s.field,n);return{...s,field:r}})}},qo=e=>Array.isArray(e)||!!(e.field&&e.op),Ts=e=>e&&!qo(e)?Vo(e):e,Ss=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Ss(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?T.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=le.getSource(t,i);return nn(o,l,t)};return n==="and"?s.every(r):s.some(r)},xe=(e,t)=>{const n=Ts(e);return n?Ss(n,t):!0},Go=(e,t)=>{const n=Ts(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=le.getSource(t,r.field);return nn(r,o,t)}):!0},se={meetsOne:Go,meetsAll:xe,met:nn},Ko=(e,t)=>{const n=e;return t.forEach((s,r)=>{if(s.refdata_match){const o=s.refdata_match,i=Object.keys(o)[0],l=e.findIndex(a=>a[i]===o[i]);l>=0&&(n[l]={...e[l],nested:s.nested})}s.combineWithRefdata&&!n.includes(s)&&(r>0&&typeof t[r-1]=="string"&&n.push(t[r-1]),n.push(s))}),n},Ze=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?se.meetsOne(n,e.formData):se.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:T.Utils.interpolateString(n.value,e.formData),label:T.Utils.interpolateString(n.label,e.formData),hint:T.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),Wo=(e,t)=>{const n=e.formData[t].map(s=>({value:T.Utils.interpolateString(e.item.value,s),label:T.Utils.interpolateString(e.item.label,s),hint:T.Utils.interpolateString(e.item.hint,s)}));return e.data.options?[...n,...e.data.options]:n},Cs=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=Wo(e,e?.data?.collection);return t(Ze(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=Ko(e.options,e.data.options);return t(Ze(e,n))}if(e.options)return t(Ze(e,e.options));if(e.data&&e.data.options)return t(Ze(e,e.data.options))}return t([])},zo=6e3,Jo=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},xn=e=>e===0,gs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),Xo=(e,t)=>{let n=0;return e.synonyms.some(r=>gs(r,t))&&(n=4),n},Qo=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return gs(i,n)})&&(s=5),s},Zo=(e,t,n,s)=>{const r=n?n(e).toLowerCase():e.label.toLowerCase()||"";let o=0;const i=r.indexOf(t);return i!==-1&&(o=Jo(i,r)),xn(o)&&e.synonyms&&(o=Xo(e,t)),xn(o)&&s.item?.extraFieldsToSearch&&(o=Qo(s,e,t)),{score:o,label:r,option:e}},ei=(e,t,n)=>(s,r)=>{const o=Zo(r,e,t,n);return o.score>0&&s.push(o),s},ti=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),ni=e=>{let t=[];Cs(e,s=>{t=s});const n=e?.item?T.Utils.itemLabel(e.item):null;return(s,r)=>{const o=typeof s=="string"?s.toLowerCase():"",i=t.reduce(ei(o,n,e),[]).sort(ti).slice(0,zo).map(l=>l.option);r(i)}},Ie=".",sn="/",bs=`${Ie}${Ie}`,Nn=`${Ie}${sn}`,Yt=e=>e.join(Ie),Ht=(e,t=Ie)=>e.split(t),si=e=>e===bs,ri=e=>[Ie,bs].indexOf(e)>-1,oi=e=>e&&e.indexOf(Ie)===0,ii=e=>e.indexOf(Nn)===0?e:`${Nn}${e}`,li=(e,t)=>{const n=ii(t),s=Ht(n,sn).filter(si).length+1,r=e?Ht(e):[];return s>=r.length?"":Yt(r.slice(0,-s))},ai=(e,t)=>{const n=Ht(t,sn).filter(s=>!ri(s));return e?`${e}.${Yt(n)}`:Yt(n)},ci=(e,t)=>oi(e)?ai(li(t,e),e):e,ui=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},di=e=>e.includes("["),fi=e=>e.replace("]","").split("["),ee=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&di(s)){const[r,o]=fi(s);return ui(n[r],o)}return n?n[s]:void 0},e)},hi=(e,t)=>{let n=e.value||e.id,s=e.label||e.name;return t&&(n=e[t.value]||n,s=e[t.label]||s),{value:n?.toString(),label:s}},mi=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...hi(n,t)}):[],pi=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},ws=(e,t,n,s=!1)=>{if(t&&e){const r=s?t.replace(/\[/g,".").replace(/\]/g,"").split("."):t.split("."),o=r.pop();let i=e;r.forEach(l=>{(!i[l]||typeof i[l]!="object")&&(i[l]={}),i=i[l]}),i[o]=n}return e},Is=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=ee(n,e.source.field))},Ei=(e,t)=>{e.forEach(n=>Is(n,t))},Ai=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Is(s,t))})},yi=(e,t,n)=>{const s={...n};return Ei(t,s),Ai(e,s),s},Ti=(e,t)=>({...e,components:_s(e.components,t)}),Si=(e,t)=>({...e,item:_s(e.item,t)}),_s=(e,t)=>e.map(n=>Ps(n,t)),Ps=(e,t)=>{if(e){if(e.type===b.CONTAINER)return Ti(e,t);if(e.type===b.COLLECTION)return Si(e,t);if(e.type===b.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:T.Utils.interpolateString(e.data.url,t)}}}return e},le={applyFormula:ys,getAutocompleteSource:ni,getDataPath:ci,getOptions:Cs,getSource:ee,refData:{setupUrl:Ps,toOptions:mi},deleteValues:pi,setDataItem:ws,setupForm:yi},Ye=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,Ce=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t),He=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),Ce(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||le.getSource(t,s.full_path);Array.isArray(r.nested)&&Ye(o,r)&&Ce(r,t)&&(n=n.concat(r.nested))})}),n},On=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],Q=(e,t=[])=>{const n=Array.isArray(t)?[...On,...t]:On;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function xs(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ci}=Object.prototype,{getPrototypeOf:rn}=Object,{iterator:pt,toStringTag:Ns}=Symbol,Et=(e=>t=>{const n=Ci.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ae=e=>(e=e.toLowerCase(),t=>Et(t)===e),At=e=>t=>typeof t===e,{isArray:Le}=Array,Ne=At("undefined");function Ve(e){return e!==null&&!Ne(e)&&e.constructor!==null&&!Ne(e.constructor)&&ce(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Os=Ae("ArrayBuffer");function gi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Os(e.buffer),t}const bi=At("string"),ce=At("function"),Rs=At("number"),qe=e=>e!==null&&typeof e=="object",wi=e=>e===!0||e===!1,rt=e=>{if(Et(e)!=="object")return!1;const t=rn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ns in e)&&!(pt in e)},Ii=e=>{if(!qe(e)||Ve(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},_i=Ae("Date"),Pi=Ae("File"),xi=e=>!!(e&&typeof e.uri<"u"),Ni=e=>e&&typeof e.getParts<"u",Oi=Ae("Blob"),Ri=Ae("FileList"),vi=e=>qe(e)&&ce(e.pipe);function Li(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Rn=Li(),vn=typeof Rn.FormData<"u"?Rn.FormData:void 0,Di=e=>{let t;return e&&(vn&&e instanceof vn||ce(e.append)&&((t=Et(e))==="formdata"||t==="object"&&ce(e.toString)&&e.toString()==="[object FormData]"))},Fi=Ae("URLSearchParams"),[ji,Ui,Mi,ki]=["ReadableStream","Request","Response","Headers"].map(Ae),$i=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ge(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let s,r;if(typeof e!="object"&&(e=[e]),Le(e))for(s=0,r=e.length;s<r;s++)t.call(null,e[s],s,e);else{if(Ve(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(s=0;s<i;s++)l=o[s],t.call(null,e[l],l,e)}}function vs(e,t){if(Ve(e))return null;t=t.toLowerCase();const n=Object.keys(e);let s=n.length,r;for(;s-- >0;)if(r=n[s],t===r.toLowerCase())return r;return null}const be=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ls=e=>!Ne(e)&&e!==be;function Vt(){const{caseless:e,skipUndefined:t}=Ls(this)&&this||{},n={},s=(r,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=e&&vs(n,o)||o;rt(n[i])&&rt(r)?n[i]=Vt(n[i],r):rt(r)?n[i]=Vt({},r):Le(r)?n[i]=r.slice():(!t||!Ne(r))&&(n[i]=r)};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&Ge(arguments[r],s);return n}const Bi=(e,t,n,{allOwnKeys:s}={})=>(Ge(t,(r,o)=>{n&&ce(r)?Object.defineProperty(e,o,{value:xs(r,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),e),Yi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hi=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Vi=(e,t,n,s)=>{let r,o,i;const l={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)i=r[o],(!s||s(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&rn(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},qi=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},Gi=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Rs(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ki=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&rn(Uint8Array)),Wi=(e,t)=>{const s=(e&&e[pt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},zi=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},Ji=Ae("HTMLFormElement"),Xi=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),Ln=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Qi=Ae("RegExp"),Ds=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};Ge(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},Zi=e=>{Ds(e,(t,n)=>{if(ce(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=e[n];if(ce(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},el=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},tl=()=>{},nl=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function sl(e){return!!(e&&ce(e.append)&&e[Ns]==="FormData"&&e[pt])}const rl=e=>{const t=new Array(10),n=(s,r)=>{if(qe(s)){if(t.indexOf(s)>=0)return;if(Ve(s))return s;if(!("toJSON"in s)){t[r]=s;const o=Le(s)?[]:{};return Ge(s,(i,l)=>{const a=n(i,r+1);!Ne(a)&&(o[l]=a)}),t[r]=void 0,o}}return s};return n(e,0)},ol=Ae("AsyncFunction"),il=e=>e&&(qe(e)||ce(e))&&ce(e.then)&&ce(e.catch),Fs=((e,t)=>e?setImmediate:t?((n,s)=>(be.addEventListener("message",({source:r,data:o})=>{r===be&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),be.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ce(be.postMessage)),ll=typeof queueMicrotask<"u"?queueMicrotask.bind(be):typeof process<"u"&&process.nextTick||Fs,al=e=>e!=null&&ce(e[pt]),E={isArray:Le,isArrayBuffer:Os,isBuffer:Ve,isFormData:Di,isArrayBufferView:gi,isString:bi,isNumber:Rs,isBoolean:wi,isObject:qe,isPlainObject:rt,isEmptyObject:Ii,isReadableStream:ji,isRequest:Ui,isResponse:Mi,isHeaders:ki,isUndefined:Ne,isDate:_i,isFile:Pi,isReactNativeBlob:xi,isReactNative:Ni,isBlob:Oi,isRegExp:Qi,isFunction:ce,isStream:vi,isURLSearchParams:Fi,isTypedArray:Ki,isFileList:Ri,forEach:Ge,merge:Vt,extend:Bi,trim:$i,stripBOM:Yi,inherits:Hi,toFlatObject:Vi,kindOf:Et,kindOfTest:Ae,endsWith:qi,toArray:Gi,forEachEntry:Wi,matchAll:zi,isHTMLForm:Ji,hasOwnProperty:Ln,hasOwnProp:Ln,reduceDescriptors:Ds,freezeMethods:Zi,toObjectSet:el,toCamelCase:Xi,noop:tl,toFiniteNumber:nl,findKey:vs,global:be,isContextDefined:Ls,isSpecCompliantForm:sl,toJSONObject:rl,isAsyncFn:ol,isThenable:il,setImmediate:Fs,asap:ll,isIterable:al};let F=class js extends Error{static from(t,n,s,r,o,i){const l=new js(t.message,n||t.code,s,r,o);return l.cause=t,l.name=t.name,t.status!=null&&l.status==null&&(l.status=t.status),i&&Object.assign(l,i),l}constructor(t,n,s,r,o){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),s&&(this.config=s),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:E.toJSONObject(this.config),code:this.code,status:this.status}}};F.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";F.ERR_BAD_OPTION="ERR_BAD_OPTION";F.ECONNABORTED="ECONNABORTED";F.ETIMEDOUT="ETIMEDOUT";F.ERR_NETWORK="ERR_NETWORK";F.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";F.ERR_DEPRECATED="ERR_DEPRECATED";F.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";F.ERR_BAD_REQUEST="ERR_BAD_REQUEST";F.ERR_CANCELED="ERR_CANCELED";F.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";F.ERR_INVALID_URL="ERR_INVALID_URL";const cl=null;function qt(e){return E.isPlainObject(e)||E.isArray(e)}function Us(e){return E.endsWith(e,"[]")?e.slice(0,-2):e}function Nt(e,t,n){return e?e.concat(t).map(function(r,o){return r=Us(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function ul(e){return E.isArray(e)&&!e.some(qt)}const dl=E.toFlatObject(E,{},null,function(t){return/^is[A-Z]/.test(t)});function yt(e,t,n){if(!E.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=E.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,A){return!E.isUndefined(A[p])});const s=n.metaTokens,r=n.visitor||u,o=n.dots,i=n.indexes,a=(n.Blob||typeof Blob<"u"&&Blob)&&E.isSpecCompliantForm(t);if(!E.isFunction(r))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(E.isDate(h))return h.toISOString();if(E.isBoolean(h))return h.toString();if(!a&&E.isBlob(h))throw new F("Blob is not supported. Use a Buffer instead.");return E.isArrayBuffer(h)||E.isTypedArray(h)?a&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,p,A){let w=h;if(E.isReactNative(t)&&E.isReactNativeBlob(h))return t.append(Nt(A,p,o),c(h)),!1;if(h&&!A&&typeof h=="object"){if(E.endsWith(p,"{}"))p=s?p:p.slice(0,-2),h=JSON.stringify(h);else if(E.isArray(h)&&ul(h)||(E.isFileList(h)||E.endsWith(p,"[]"))&&(w=E.toArray(h)))return p=Us(p),w.forEach(function(C,I){!(E.isUndefined(C)||C===null)&&t.append(i===!0?Nt([p],I,o):i===null?p:p+"[]",c(C))}),!1}return qt(h)?!0:(t.append(Nt(A,p,o),c(h)),!1)}const m=[],f=Object.assign(dl,{defaultVisitor:u,convertValue:c,isVisitable:qt});function y(h,p){if(!E.isUndefined(h)){if(m.indexOf(h)!==-1)throw Error("Circular reference detected in "+p.join("."));m.push(h),E.forEach(h,function(w,L){(!(E.isUndefined(w)||w===null)&&r.call(t,w,E.isString(L)?L.trim():L,p,f))===!0&&y(w,p?p.concat(L):[L])}),m.pop()}}if(!E.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Dn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function on(e,t){this._pairs=[],e&&yt(e,this,t)}const Ms=on.prototype;Ms.append=function(t,n){this._pairs.push([t,n])};Ms.toString=function(t){const n=t?function(s){return t.call(this,s,Dn)}:Dn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function fl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ks(e,t,n){if(!t)return e;const s=n&&n.encode||fl,r=E.isFunction(n)?{serialize:n}:n,o=r&&r.serialize;let i;if(o?i=o(t,r):i=E.isURLSearchParams(t)?t.toString():new on(t,r).toString(s),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Fn{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){E.forEach(this.handlers,function(s){s!==null&&t(s)})}}const ln={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},hl=typeof URLSearchParams<"u"?URLSearchParams:on,ml=typeof FormData<"u"?FormData:null,pl=typeof Blob<"u"?Blob:null,El={isBrowser:!0,classes:{URLSearchParams:hl,FormData:ml,Blob:pl},protocols:["http","https","file","blob","url","data"]},an=typeof window<"u"&&typeof document<"u",Gt=typeof navigator=="object"&&navigator||void 0,Al=an&&(!Gt||["ReactNative","NativeScript","NS"].indexOf(Gt.product)<0),yl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tl=an&&window.location.href||"http://localhost",Sl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:an,hasStandardBrowserEnv:Al,hasStandardBrowserWebWorkerEnv:yl,navigator:Gt,origin:Tl},Symbol.toStringTag,{value:"Module"})),ie={...Sl,...El};function Cl(e,t){return yt(e,new ie.classes.URLSearchParams,{visitor:function(n,s,r,o){return ie.isNode&&E.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function gl(e){return E.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function bl(e){const t={},n=Object.keys(e);let s;const r=n.length;let o;for(s=0;s<r;s++)o=n[s],t[o]=e[o];return t}function $s(e){function t(n,s,r,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),a=o>=n.length;return i=!i&&E.isArray(r)?r.length:i,a?(E.hasOwnProp(r,i)?r[i]=[r[i],s]:r[i]=s,!l):((!r[i]||!E.isObject(r[i]))&&(r[i]=[]),t(n,s,r[i],o)&&E.isArray(r[i])&&(r[i]=bl(r[i])),!l)}if(E.isFormData(e)&&E.isFunction(e.entries)){const n={};return E.forEachEntry(e,(s,r)=>{t(gl(s),r,n,0)}),n}return null}function wl(e,t,n){if(E.isString(e))try{return(t||JSON.parse)(e),E.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const Ke={transitional:ln,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,o=E.isObject(t);if(o&&E.isHTMLForm(t)&&(t=new FormData(t)),E.isFormData(t))return r?JSON.stringify($s(t)):t;if(E.isArrayBuffer(t)||E.isBuffer(t)||E.isStream(t)||E.isFile(t)||E.isBlob(t)||E.isReadableStream(t))return t;if(E.isArrayBufferView(t))return t.buffer;if(E.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Cl(t,this.formSerializer).toString();if((l=E.isFileList(t))||s.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return yt(l?{"files[]":t}:t,a&&new a,this.formSerializer)}}return o||r?(n.setContentType("application/json",!1),wl(t)):t}],transformResponse:[function(t){const n=this.transitional||Ke.transitional,s=n&&n.forcedJSONParsing,r=this.responseType==="json";if(E.isResponse(t)||E.isReadableStream(t))return t;if(t&&E.isString(t)&&(s&&!this.responseType||r)){const i=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?F.from(l,F.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};E.forEach(["delete","get","head","post","put","patch"],e=>{Ke.headers[e]={}});const Il=E.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_l=e=>{const t={};let n,s,r;return e&&e.split(`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),T=require("@ukhomeoffice/cop-react-components"),O=require("react"),mt=require("uuid"),q=require("dayjs"),Re=require("dayjs/plugin/customParseFormat"),tn=require("dayjs/plugin/isToday"),Wr=require("dayjs/plugin/isLeapYear"),ve={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},zr="alert",Jr="autocomplete",Xr="calculation",Qr="checkboxes",Zr="collection",eo="collection-summary",to="container",no="date",so="details",ro="email",oo="file",io="heading",lo="html",ao="inset-text",co="list",uo="multifile",fo="paragraph",ho="phone-number",mo="radios",po="select",Eo="text",Ao="textarea",yo="time",To="warning",b={ALERT:zr,AUTOCOMPLETE:Jr,CALCULATION:Xr,CHECKBOXES:Qr,COLLECTION:Zr,COLLECTION_SUMMARY:eo,CONTAINER:to,DATE:no,DETAILS:so,EMAIL:ro,FILE:oo,HEADING:io,HTML:lo,INSET_TEXT:ao,LIST:co,MULTI_FILE:uo,PARAGRAPH:fo,PHONE_NUMBER:ho,RADIOS:mo,SELECT:po,TEXT:Eo,TEXT_AREA:Ao,TIME:yo,WARNING:To},So="blur",Co="submit",go="cancel",Te={BLUR:So,SUBMIT:Co,CANCEL:go},bo="cya",wo="hub",Io="partial-cya",te={CYA:bo,HUB:wo,PARTIAL_CYA:Io},_o="cya",Po="form",xo="form-with-task-list",No="hub-and-spoke",Oo="task-list",Ro="task-list-cya",vo="wizard",Z={CYA:_o,FORM:Po,FORM_WITH_TASK:xo,HUB:No,TASK:Oo,TASK_CYA:Ro,WIZARD:vo},Lo="CYA",Do="TASK",he={CYA:Lo,TASK:Do},Ut="cancel",cs="collectionAdd",us="collectionDuplicate",ds="collectionRemove",fs="navigate",Mt="saveAndContinue",kt="saveAndNavigate",$t="saveAndReturn",Bt="submit",st={CANCEL:Ut,COLLECTION_ADD:cs,COLLECTION_DUPLICATE:us,COLLECTION_REMOVE:ds,NAVIGATE:fs,SAVE_AND_CONTINUE:Mt,SAVE_AND_NAVIGATE:kt,SAVE_AND_RETURN:$t,SUBMIT:Bt},Fo={[Ut]:{type:Ut,validate:!1,label:"Cancel",classModifiers:"secondary"},[cs]:void 0,[us]:void 0,[ds]:void 0,[fs]:void 0,[Mt]:{type:Mt,validate:!0,label:"Save and continue"},[kt]:{type:kt,validate:!0,label:"Save and continue"},[$t]:{type:$t,validate:!1,label:"Save and return later",classModifiers:"secondary"},[Bt]:{type:Bt,validate:!0}},G={TYPES:st,DEFAULTS:Fo},hs="complete",ms="inProgress",ps="notStarted",Es="cannotStartYet",As="skipped",jo={COMPLETE:hs,IN_PROGRESS:ms,NOT_STARTED:ps,CANNOT_START_YET:Es,SKIPPED:As},Uo={[hs]:{label:"Completed",colour:"dark-blue"},[ms]:{label:"In Progress",colour:"white"},[ps]:{label:"Not Started",colour:"dark-grey"},[Es]:{label:"Cannot Start Yet",colour:"dark-grey"},[As]:{label:"Skipped",colour:"dark-grey"}},B={TYPES:jo,DETAILS:Uo},Mo={CollectionLabels:ve,ComponentTypes:b,EventTypes:Te,FormPages:te,FormTypes:Z,HubFormats:he,PageAction:G,TaskStates:B},ys=e=>{try{const t=ko(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},ko=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return Xe(e,(n,s)=>n*s);case"divide":return Xe(e,(n,s)=>n/s);case"plus":return Xe(e,(n,s)=>n+s);case"minus":return Xe(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},Xe=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return $o(n.map(s=>Bo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},$o=(e,t)=>{const n=t.formula.round;if(!n&&n!==0||!e)return e;if(n===0)return parseInt(e,10);const s=Math.pow(10,n);return Math.round((e+Number.EPSILON)*s)/s},Bo=(e,t)=>{const n=Object.keys(e);if(n.length===1){const s=n[0],r=e[s];switch(s){case"field":{const o=Yo(r,t);return!o&&o!==0?NaN:parseFloat(o)}case"value":return parseFloat(r);case"formula":return ys({...e,formData:t});default:throw new Error("Only accept following as argument field: {field, value, or formula}")}}else throw new Error("Argument cannot have more than one reference")},Yo=(e,t)=>T.Utils.interpolateString("${"+e+"}",t),Ho=(e,t)=>{if(["in","nin","includesAllOf","!includesAllOf"].includes(e.op))return e.values;if(typeof e.value=="string"&&e.value?.startsWith("field::")){const n=e.value.replace("field::","");return le.getSource(t,n)}return e.value},Qe=e=>{if(Array.isArray(e))return e.length;if(typeof e=="string"){const t=e.replace(/,/g,"");return Number.isNaN(t)?null:parseFloat(t)}return typeof e=="number"?e:null},nn=(e,t,n)=>{if(e&&typeof e=="object"){const s=Ho(e,n);switch(e.op){case"=":case"eq":return s===t;case"!=":case"<>":case"ne":case"neq":return s!==t;case"in":return Array.isArray(s)?s.includes(t):!1;case"nin":return Array.isArray(s)?s.includes(t)===!1:!0;case"<":{const r=Qe(t),o=Qe(s);return r!=null&&o!=null&&r<o}case">":{const r=Qe(t),o=Qe(s);return r!=null&&o!=null&&r>o}case"contains":return t?.toString().toLowerCase().includes(s);case"!contains":return!t?.toString().toLowerCase().includes(s);case"includes":return Array.isArray(t)?t.includes(s):!1;case"!includes":return Array.isArray(t)?!t.includes(s):!0;case"includesObjectProp":return Array.isArray(t)?t.some(r=>r[e.key]===s):!1;case"!includesObjectProp":return Array.isArray(t)?!t.some(r=>r[e.key]===s):!0;case"includesAllOf":return Array.isArray(t)?s.every(r=>t.includes(r)):!1;case"!includesAllOf":return Array.isArray(t)?!s.every(r=>t.includes(r)):!0;default:return!1}}return!0},Vo=e=>{if(e.show_when){let t=e.show_when.type?e.show_when.conditions:e.show_when;const n=e.full_path;return t=Array.isArray(t)?t:[t],t.map(s=>{const r=le.getDataPath(s.field,n);return{...s,field:r}})}},qo=e=>Array.isArray(e)||!!(e.field&&e.op),Ts=e=>e&&!qo(e)?Vo(e):e,Ss=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Ss(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?T.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=le.getSource(t,i);return nn(o,l,t)};return n==="and"?s.every(r):s.some(r)},xe=(e,t)=>{const n=Ts(e);return n?Ss(n,t):!0},Go=(e,t)=>{const n=Ts(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=le.getSource(t,r.field);return nn(r,o,t)}):!0},se={meetsOne:Go,meetsAll:xe,met:nn},Ko=(e,t)=>{const n=e;return t.forEach((s,r)=>{if(s.refdata_match){const o=s.refdata_match,i=Object.keys(o)[0],l=e.findIndex(a=>a[i]===o[i]);l>=0&&(n[l]={...e[l],nested:s.nested})}s.combineWithRefdata&&!n.includes(s)&&(r>0&&typeof t[r-1]=="string"&&n.push(t[r-1]),n.push(s))}),n},Ze=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?se.meetsOne(n,e.formData):se.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:T.Utils.interpolateString(n.value,e.formData),label:T.Utils.interpolateString(n.label,e.formData),hint:T.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),Wo=(e,t)=>{const n=e.formData[t].map(s=>({value:T.Utils.interpolateString(e.item.value,s),label:T.Utils.interpolateString(e.item.label,s),hint:T.Utils.interpolateString(e.item.hint,s)}));return e.data.options?[...n,...e.data.options]:n},Cs=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=Wo(e,e?.data?.collection);return t(Ze(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=Ko(e.options,e.data.options);return t(Ze(e,n))}if(e.options)return t(Ze(e,e.options));if(e.data&&e.data.options)return t(Ze(e,e.data.options))}return t([])},zo=6e3,Jo=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},xn=e=>e===0,gs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),Xo=(e,t)=>{let n=0;return e.synonyms.some(r=>gs(r,t))&&(n=4),n},Qo=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return gs(i,n)})&&(s=5),s},Zo=(e,t,n,s)=>{const r=n?n(e).toLowerCase():e.label.toLowerCase()||"";let o=0;const i=r.indexOf(t);return i!==-1&&(o=Jo(i,r)),xn(o)&&e.synonyms&&(o=Xo(e,t)),xn(o)&&s.item?.extraFieldsToSearch&&(o=Qo(s,e,t)),{score:o,label:r,option:e}},ei=(e,t,n)=>(s,r)=>{const o=Zo(r,e,t,n);return o.score>0&&s.push(o),s},ti=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),ni=e=>{let t=[];Cs(e,s=>{t=s});const n=e?.item?T.Utils.itemLabel(e.item):null;return(s,r)=>{const o=typeof s=="string"?s.toLowerCase():"",i=t.reduce(ei(o,n,e),[]).sort(ti).slice(0,zo).map(l=>l.option);r(i)}},Ie=".",sn="/",bs=`${Ie}${Ie}`,Nn=`${Ie}${sn}`,Yt=e=>e.join(Ie),Ht=(e,t=Ie)=>e.split(t),si=e=>e===bs,ri=e=>[Ie,bs].indexOf(e)>-1,oi=e=>e&&e.indexOf(Ie)===0,ii=e=>e.indexOf(Nn)===0?e:`${Nn}${e}`,li=(e,t)=>{const n=ii(t),s=Ht(n,sn).filter(si).length+1,r=e?Ht(e):[];return s>=r.length?"":Yt(r.slice(0,-s))},ai=(e,t)=>{const n=Ht(t,sn).filter(s=>!ri(s));return e?`${e}.${Yt(n)}`:Yt(n)},ci=(e,t)=>oi(e)?ai(li(t,e),e):e,ui=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},di=e=>e.includes("["),fi=e=>e.replace("]","").split("["),ee=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&di(s)){const[r,o]=fi(s);return ui(n[r],o)}return n?n[s]:void 0},e)},hi=(e,t)=>{let n=e.value||e.id,s=e.label||e.name;return t&&(n=e[t.value]||n,s=e[t.label]||s),{value:n?.toString(),label:s}},mi=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...hi(n,t)}):[],pi=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},ws=(e,t,n,s=!1)=>{if(t&&e){const r=s?t.replace(/\[/g,".").replace(/\]/g,"").split("."):t.split("."),o=r.pop();let i=e;r.forEach(l=>{(!i[l]||typeof i[l]!="object")&&(i[l]={}),i=i[l]}),i[o]=n}return e},Is=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=ee(n,e.source.field))},Ei=(e,t)=>{e.forEach(n=>Is(n,t))},Ai=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Is(s,t))})},yi=(e,t,n)=>{const s={...n};return Ei(t,s),Ai(e,s),s},Ti=(e,t)=>({...e,components:_s(e.components,t)}),Si=(e,t)=>({...e,item:_s(e.item,t)}),_s=(e,t)=>e.map(n=>Ps(n,t)),Ps=(e,t)=>{if(e){if(e.type===b.CONTAINER)return Ti(e,t);if(e.type===b.COLLECTION)return Si(e,t);if(e.type===b.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:T.Utils.interpolateString(e.data.url,t)}}}return e},le={applyFormula:ys,getAutocompleteSource:ni,getDataPath:ci,getOptions:Cs,getSource:ee,refData:{setupUrl:Ps,toOptions:mi},deleteValues:pi,setDataItem:ws,setupForm:yi},Ye=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,Ce=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t),He=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),Ce(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||le.getSource(t,s.full_path);Array.isArray(r.nested)&&Ye(o,r)&&Ce(r,t)&&(n=n.concat(r.nested))})}),n},On=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],Q=(e,t)=>{const n=Array.isArray(t)?[...On,...t]:On;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function xs(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ci}=Object.prototype,{getPrototypeOf:rn}=Object,{iterator:pt,toStringTag:Ns}=Symbol,Et=(e=>t=>{const n=Ci.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ae=e=>(e=e.toLowerCase(),t=>Et(t)===e),At=e=>t=>typeof t===e,{isArray:Le}=Array,Ne=At("undefined");function Ve(e){return e!==null&&!Ne(e)&&e.constructor!==null&&!Ne(e.constructor)&&ce(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Os=Ae("ArrayBuffer");function gi(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Os(e.buffer),t}const bi=At("string"),ce=At("function"),Rs=At("number"),qe=e=>e!==null&&typeof e=="object",wi=e=>e===!0||e===!1,rt=e=>{if(Et(e)!=="object")return!1;const t=rn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ns in e)&&!(pt in e)},Ii=e=>{if(!qe(e)||Ve(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},_i=Ae("Date"),Pi=Ae("File"),xi=e=>!!(e&&typeof e.uri<"u"),Ni=e=>e&&typeof e.getParts<"u",Oi=Ae("Blob"),Ri=Ae("FileList"),vi=e=>qe(e)&&ce(e.pipe);function Li(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Rn=Li(),vn=typeof Rn.FormData<"u"?Rn.FormData:void 0,Di=e=>{let t;return e&&(vn&&e instanceof vn||ce(e.append)&&((t=Et(e))==="formdata"||t==="object"&&ce(e.toString)&&e.toString()==="[object FormData]"))},Fi=Ae("URLSearchParams"),[ji,Ui,Mi,ki]=["ReadableStream","Request","Response","Headers"].map(Ae),$i=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ge(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let s,r;if(typeof e!="object"&&(e=[e]),Le(e))for(s=0,r=e.length;s<r;s++)t.call(null,e[s],s,e);else{if(Ve(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(s=0;s<i;s++)l=o[s],t.call(null,e[l],l,e)}}function vs(e,t){if(Ve(e))return null;t=t.toLowerCase();const n=Object.keys(e);let s=n.length,r;for(;s-- >0;)if(r=n[s],t===r.toLowerCase())return r;return null}const be=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ls=e=>!Ne(e)&&e!==be;function Vt(){const{caseless:e,skipUndefined:t}=Ls(this)&&this||{},n={},s=(r,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=e&&vs(n,o)||o;rt(n[i])&&rt(r)?n[i]=Vt(n[i],r):rt(r)?n[i]=Vt({},r):Le(r)?n[i]=r.slice():(!t||!Ne(r))&&(n[i]=r)};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&Ge(arguments[r],s);return n}const Bi=(e,t,n,{allOwnKeys:s}={})=>(Ge(t,(r,o)=>{n&&ce(r)?Object.defineProperty(e,o,{value:xs(r,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),e),Yi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hi=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Vi=(e,t,n,s)=>{let r,o,i;const l={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)i=r[o],(!s||s(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&rn(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},qi=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},Gi=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Rs(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ki=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&rn(Uint8Array)),Wi=(e,t)=>{const s=(e&&e[pt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},zi=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},Ji=Ae("HTMLFormElement"),Xi=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),Ln=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Qi=Ae("RegExp"),Ds=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};Ge(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},Zi=e=>{Ds(e,(t,n)=>{if(ce(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=e[n];if(ce(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},el=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},tl=()=>{},nl=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function sl(e){return!!(e&&ce(e.append)&&e[Ns]==="FormData"&&e[pt])}const rl=e=>{const t=new Array(10),n=(s,r)=>{if(qe(s)){if(t.indexOf(s)>=0)return;if(Ve(s))return s;if(!("toJSON"in s)){t[r]=s;const o=Le(s)?[]:{};return Ge(s,(i,l)=>{const a=n(i,r+1);!Ne(a)&&(o[l]=a)}),t[r]=void 0,o}}return s};return n(e,0)},ol=Ae("AsyncFunction"),il=e=>e&&(qe(e)||ce(e))&&ce(e.then)&&ce(e.catch),Fs=((e,t)=>e?setImmediate:t?((n,s)=>(be.addEventListener("message",({source:r,data:o})=>{r===be&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),be.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ce(be.postMessage)),ll=typeof queueMicrotask<"u"?queueMicrotask.bind(be):typeof process<"u"&&process.nextTick||Fs,al=e=>e!=null&&ce(e[pt]),E={isArray:Le,isArrayBuffer:Os,isBuffer:Ve,isFormData:Di,isArrayBufferView:gi,isString:bi,isNumber:Rs,isBoolean:wi,isObject:qe,isPlainObject:rt,isEmptyObject:Ii,isReadableStream:ji,isRequest:Ui,isResponse:Mi,isHeaders:ki,isUndefined:Ne,isDate:_i,isFile:Pi,isReactNativeBlob:xi,isReactNative:Ni,isBlob:Oi,isRegExp:Qi,isFunction:ce,isStream:vi,isURLSearchParams:Fi,isTypedArray:Ki,isFileList:Ri,forEach:Ge,merge:Vt,extend:Bi,trim:$i,stripBOM:Yi,inherits:Hi,toFlatObject:Vi,kindOf:Et,kindOfTest:Ae,endsWith:qi,toArray:Gi,forEachEntry:Wi,matchAll:zi,isHTMLForm:Ji,hasOwnProperty:Ln,hasOwnProp:Ln,reduceDescriptors:Ds,freezeMethods:Zi,toObjectSet:el,toCamelCase:Xi,noop:tl,toFiniteNumber:nl,findKey:vs,global:be,isContextDefined:Ls,isSpecCompliantForm:sl,toJSONObject:rl,isAsyncFn:ol,isThenable:il,setImmediate:Fs,asap:ll,isIterable:al};let F=class js extends Error{static from(t,n,s,r,o,i){const l=new js(t.message,n||t.code,s,r,o);return l.cause=t,l.name=t.name,t.status!=null&&l.status==null&&(l.status=t.status),i&&Object.assign(l,i),l}constructor(t,n,s,r,o){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),s&&(this.config=s),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:E.toJSONObject(this.config),code:this.code,status:this.status}}};F.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";F.ERR_BAD_OPTION="ERR_BAD_OPTION";F.ECONNABORTED="ECONNABORTED";F.ETIMEDOUT="ETIMEDOUT";F.ERR_NETWORK="ERR_NETWORK";F.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";F.ERR_DEPRECATED="ERR_DEPRECATED";F.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";F.ERR_BAD_REQUEST="ERR_BAD_REQUEST";F.ERR_CANCELED="ERR_CANCELED";F.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";F.ERR_INVALID_URL="ERR_INVALID_URL";const cl=null;function qt(e){return E.isPlainObject(e)||E.isArray(e)}function Us(e){return E.endsWith(e,"[]")?e.slice(0,-2):e}function Nt(e,t,n){return e?e.concat(t).map(function(r,o){return r=Us(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function ul(e){return E.isArray(e)&&!e.some(qt)}const dl=E.toFlatObject(E,{},null,function(t){return/^is[A-Z]/.test(t)});function yt(e,t,n){if(!E.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=E.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,A){return!E.isUndefined(A[p])});const s=n.metaTokens,r=n.visitor||u,o=n.dots,i=n.indexes,a=(n.Blob||typeof Blob<"u"&&Blob)&&E.isSpecCompliantForm(t);if(!E.isFunction(r))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(E.isDate(h))return h.toISOString();if(E.isBoolean(h))return h.toString();if(!a&&E.isBlob(h))throw new F("Blob is not supported. Use a Buffer instead.");return E.isArrayBuffer(h)||E.isTypedArray(h)?a&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,p,A){let w=h;if(E.isReactNative(t)&&E.isReactNativeBlob(h))return t.append(Nt(A,p,o),c(h)),!1;if(h&&!A&&typeof h=="object"){if(E.endsWith(p,"{}"))p=s?p:p.slice(0,-2),h=JSON.stringify(h);else if(E.isArray(h)&&ul(h)||(E.isFileList(h)||E.endsWith(p,"[]"))&&(w=E.toArray(h)))return p=Us(p),w.forEach(function(C,I){!(E.isUndefined(C)||C===null)&&t.append(i===!0?Nt([p],I,o):i===null?p:p+"[]",c(C))}),!1}return qt(h)?!0:(t.append(Nt(A,p,o),c(h)),!1)}const m=[],f=Object.assign(dl,{defaultVisitor:u,convertValue:c,isVisitable:qt});function y(h,p){if(!E.isUndefined(h)){if(m.indexOf(h)!==-1)throw Error("Circular reference detected in "+p.join("."));m.push(h),E.forEach(h,function(w,L){(!(E.isUndefined(w)||w===null)&&r.call(t,w,E.isString(L)?L.trim():L,p,f))===!0&&y(w,p?p.concat(L):[L])}),m.pop()}}if(!E.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Dn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function on(e,t){this._pairs=[],e&&yt(e,this,t)}const Ms=on.prototype;Ms.append=function(t,n){this._pairs.push([t,n])};Ms.toString=function(t){const n=t?function(s){return t.call(this,s,Dn)}:Dn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function fl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ks(e,t,n){if(!t)return e;const s=n&&n.encode||fl,r=E.isFunction(n)?{serialize:n}:n,o=r&&r.serialize;let i;if(o?i=o(t,r):i=E.isURLSearchParams(t)?t.toString():new on(t,r).toString(s),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Fn{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){E.forEach(this.handlers,function(s){s!==null&&t(s)})}}const ln={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},hl=typeof URLSearchParams<"u"?URLSearchParams:on,ml=typeof FormData<"u"?FormData:null,pl=typeof Blob<"u"?Blob:null,El={isBrowser:!0,classes:{URLSearchParams:hl,FormData:ml,Blob:pl},protocols:["http","https","file","blob","url","data"]},an=typeof window<"u"&&typeof document<"u",Gt=typeof navigator=="object"&&navigator||void 0,Al=an&&(!Gt||["ReactNative","NativeScript","NS"].indexOf(Gt.product)<0),yl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tl=an&&window.location.href||"http://localhost",Sl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:an,hasStandardBrowserEnv:Al,hasStandardBrowserWebWorkerEnv:yl,navigator:Gt,origin:Tl},Symbol.toStringTag,{value:"Module"})),ie={...Sl,...El};function Cl(e,t){return yt(e,new ie.classes.URLSearchParams,{visitor:function(n,s,r,o){return ie.isNode&&E.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function gl(e){return E.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function bl(e){const t={},n=Object.keys(e);let s;const r=n.length;let o;for(s=0;s<r;s++)o=n[s],t[o]=e[o];return t}function $s(e){function t(n,s,r,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),a=o>=n.length;return i=!i&&E.isArray(r)?r.length:i,a?(E.hasOwnProp(r,i)?r[i]=[r[i],s]:r[i]=s,!l):((!r[i]||!E.isObject(r[i]))&&(r[i]=[]),t(n,s,r[i],o)&&E.isArray(r[i])&&(r[i]=bl(r[i])),!l)}if(E.isFormData(e)&&E.isFunction(e.entries)){const n={};return E.forEachEntry(e,(s,r)=>{t(gl(s),r,n,0)}),n}return null}function wl(e,t,n){if(E.isString(e))try{return(t||JSON.parse)(e),E.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const Ke={transitional:ln,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,o=E.isObject(t);if(o&&E.isHTMLForm(t)&&(t=new FormData(t)),E.isFormData(t))return r?JSON.stringify($s(t)):t;if(E.isArrayBuffer(t)||E.isBuffer(t)||E.isStream(t)||E.isFile(t)||E.isBlob(t)||E.isReadableStream(t))return t;if(E.isArrayBufferView(t))return t.buffer;if(E.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Cl(t,this.formSerializer).toString();if((l=E.isFileList(t))||s.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return yt(l?{"files[]":t}:t,a&&new a,this.formSerializer)}}return o||r?(n.setContentType("application/json",!1),wl(t)):t}],transformResponse:[function(t){const n=this.transitional||Ke.transitional,s=n&&n.forcedJSONParsing,r=this.responseType==="json";if(E.isResponse(t)||E.isReadableStream(t))return t;if(t&&E.isString(t)&&(s&&!this.responseType||r)){const i=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?F.from(l,F.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};E.forEach(["delete","get","head","post","put","patch"],e=>{Ke.headers[e]={}});const Il=E.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_l=e=>{const t={};let n,s,r;return e&&e.split(`
|
|
2
2
|
`).forEach(function(i){r=i.indexOf(":"),n=i.substring(0,r).trim().toLowerCase(),s=i.substring(r+1).trim(),!(!n||t[n]&&Il[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t},jn=Symbol("internals"),Pl=e=>!/[\r\n]/.test(e);function Bs(e,t){if(!(e===!1||e==null)){if(E.isArray(e)){e.forEach(n=>Bs(n,t));return}if(!Pl(String(e)))throw new Error(`Invalid character in header content ["${t}"]`)}}function Me(e){return e&&String(e).trim().toLowerCase()}function xl(e){let t=e.length;for(;t>0;){const n=e.charCodeAt(t-1);if(n!==10&&n!==13)break;t-=1}return t===e.length?e:e.slice(0,t)}function ot(e){return e===!1||e==null?e:E.isArray(e)?e.map(ot):xl(String(e))}function Nl(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(e);)t[s[1]]=s[2];return t}const Ol=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ot(e,t,n,s,r){if(E.isFunction(s))return s.call(this,t,n);if(r&&(t=n),!!E.isString(t)){if(E.isString(s))return t.indexOf(s)!==-1;if(E.isRegExp(s))return s.test(t)}}function Rl(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function vl(e,t){const n=E.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+n,{value:function(r,o,i){return this[s].call(this,t,r,o,i)},configurable:!0})})}let ue=class{constructor(t){t&&this.set(t)}set(t,n,s){const r=this;function o(l,a,c){const u=Me(a);if(!u)throw new Error("header name must be a non-empty string");const m=E.findKey(r,u);(!m||r[m]===void 0||c===!0||c===void 0&&r[m]!==!1)&&(Bs(l,a),r[m||a]=ot(l))}const i=(l,a)=>E.forEach(l,(c,u)=>o(c,u,a));if(E.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(E.isString(t)&&(t=t.trim())&&!Ol(t))i(_l(t),n);else if(E.isObject(t)&&E.isIterable(t)){let l={},a,c;for(const u of t){if(!E.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[c=u[0]]=(a=l[c])?E.isArray(a)?[...a,u[1]]:[a,u[1]]:u[1]}i(l,n)}else t!=null&&o(n,t,s);return this}get(t,n){if(t=Me(t),t){const s=E.findKey(this,t);if(s){const r=this[s];if(!n)return r;if(n===!0)return Nl(r);if(E.isFunction(n))return n.call(this,r,s);if(E.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Me(t),t){const s=E.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||Ot(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let r=!1;function o(i){if(i=Me(i),i){const l=E.findKey(s,i);l&&(!n||Ot(s,s[l],l,n))&&(delete s[l],r=!0)}}return E.isArray(t)?t.forEach(o):o(t),r}clear(t){const n=Object.keys(this);let s=n.length,r=!1;for(;s--;){const o=n[s];(!t||Ot(this,this[o],o,t,!0))&&(delete this[o],r=!0)}return r}normalize(t){const n=this,s={};return E.forEach(this,(r,o)=>{const i=E.findKey(s,o);if(i){n[i]=ot(r),delete n[o];return}const l=t?Rl(o):String(o).trim();l!==o&&delete n[o],n[l]=ot(r),s[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return E.forEach(this,(s,r)=>{s!=null&&s!==!1&&(n[r]=t&&E.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
3
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(r=>s.set(r)),s}static accessor(t){const s=(this[jn]=this[jn]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=Me(i);s[l]||(vl(r,i),s[l]=!0)}return E.isArray(t)?t.forEach(o):o(t),this}};ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);E.reduceDescriptors(ue.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});E.freezeMethods(ue);function Rt(e,t){const n=this||Ke,s=t||n,r=ue.from(s.headers);let o=s.data;return E.forEach(e,function(l){o=l.call(n,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function Ys(e){return!!(e&&e.__CANCEL__)}let We=class extends F{constructor(t,n,s){super(t??"canceled",F.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function Hs(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new F("Request failed with status code "+n.status,[F.ERR_BAD_REQUEST,F.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ll(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dl(e,t){e=e||10;const n=new Array(e),s=new Array(e);let r=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const c=Date.now(),u=s[o];i||(i=c),n[r]=a,s[r]=c;let m=o,f=0;for(;m!==r;)f+=n[m++],m=m%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const y=u&&c-u;return y?Math.round(f*1e3/y):void 0}}function Fl(e,t){let n=0,s=1e3/t,r,o;const i=(c,u=Date.now())=>{n=u,r=null,o&&(clearTimeout(o),o=null),e(...c)};return[(...c)=>{const u=Date.now(),m=u-n;m>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-m)))},()=>r&&i(r)]}const ct=(e,t,n=3)=>{let s=0;const r=Dl(50,250);return Fl(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,a=i-s,c=r(a),u=i<=l;s=i;const m={loaded:i,total:l,progress:l?i/l:void 0,bytes:a,rate:c||void 0,estimated:c&&l&&u?(l-i)/c:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(m)},n)},Un=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},Mn=e=>(...t)=>E.asap(()=>e(...t)),jl=ie.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ie.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ie.origin),ie.navigator&&/(msie|trident)/i.test(ie.navigator.userAgent)):()=>!0,Ul=ie.hasStandardBrowserEnv?{write(e,t,n,s,r,o,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];E.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),E.isString(s)&&l.push(`path=${s}`),E.isString(r)&&l.push(`domain=${r}`),o===!0&&l.push("secure"),E.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ml(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function kl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Vs(e,t,n){let s=!Ml(t);return e&&(s||n==!1)?kl(e,t):t}const kn=e=>e instanceof ue?{...e}:e;function _e(e,t){t=t||{};const n={};function s(c,u,m,f){return E.isPlainObject(c)&&E.isPlainObject(u)?E.merge.call({caseless:f},c,u):E.isPlainObject(u)?E.merge({},u):E.isArray(u)?u.slice():u}function r(c,u,m,f){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c,m,f)}else return s(c,u,m,f)}function o(c,u){if(!E.isUndefined(u))return s(void 0,u)}function i(c,u){if(E.isUndefined(u)){if(!E.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,m){if(m in t)return s(c,u);if(m in e)return s(void 0,c)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(c,u,m)=>r(kn(c),kn(u),m,!0)};return E.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const m=E.hasOwnProp(a,u)?a[u]:r,f=m(e[u],t[u],u);E.isUndefined(f)&&m!==l||(n[u]=f)}),n}const qs=e=>{const t=_e({},e);let{data:n,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:o,headers:i,auth:l}=t;if(t.headers=i=ue.from(i),t.url=ks(Vs(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),E.isFormData(n)){if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(E.isFunction(n.getHeaders)){const a=n.getHeaders(),c=["content-type","content-length"];Object.entries(a).forEach(([u,m])=>{c.includes(u.toLowerCase())&&i.set(u,m)})}}if(ie.hasStandardBrowserEnv&&(s&&E.isFunction(s)&&(s=s(t)),s||s!==!1&&jl(t.url))){const a=r&&o&&Ul.read(o);a&&i.set(r,a)}return t},$l=typeof XMLHttpRequest<"u",Bl=$l&&function(e){return new Promise(function(n,s){const r=qs(e);let o=r.data;const i=ue.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,m,f,y,h;function p(){y&&y(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let A=new XMLHttpRequest;A.open(r.method.toUpperCase(),r.url,!0),A.timeout=r.timeout;function w(){if(!A)return;const C=ue.from("getAllResponseHeaders"in A&&A.getAllResponseHeaders()),_={data:!l||l==="text"||l==="json"?A.responseText:A.response,status:A.status,statusText:A.statusText,headers:C,config:e,request:A};Hs(function(S){n(S),p()},function(S){s(S),p()},_),A=null}"onloadend"in A?A.onloadend=w:A.onreadystatechange=function(){!A||A.readyState!==4||A.status===0&&!(A.responseURL&&A.responseURL.indexOf("file:")===0)||setTimeout(w)},A.onabort=function(){A&&(s(new F("Request aborted",F.ECONNABORTED,e,A)),A=null)},A.onerror=function(I){const _=I&&I.message?I.message:"Network Error",U=new F(_,F.ERR_NETWORK,e,A);U.event=I||null,s(U),A=null},A.ontimeout=function(){let I=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const _=r.transitional||ln;r.timeoutErrorMessage&&(I=r.timeoutErrorMessage),s(new F(I,_.clarifyTimeoutError?F.ETIMEDOUT:F.ECONNABORTED,e,A)),A=null},o===void 0&&i.setContentType(null),"setRequestHeader"in A&&E.forEach(i.toJSON(),function(I,_){A.setRequestHeader(_,I)}),E.isUndefined(r.withCredentials)||(A.withCredentials=!!r.withCredentials),l&&l!=="json"&&(A.responseType=r.responseType),c&&([f,h]=ct(c,!0),A.addEventListener("progress",f)),a&&A.upload&&([m,y]=ct(a),A.upload.addEventListener("progress",m),A.upload.addEventListener("loadend",y)),(r.cancelToken||r.signal)&&(u=C=>{A&&(s(!C||C.type?new We(null,e,A):C),A.abort(),A=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const L=Ll(r.url);if(L&&ie.protocols.indexOf(L)===-1){s(new F("Unsupported protocol "+L+":",F.ERR_BAD_REQUEST,e));return}A.send(o||null)})},Yl=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let s=new AbortController,r;const o=function(c){if(!r){r=!0,l();const u=c instanceof Error?c:this.reason;s.abort(u instanceof F?u:new We(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,o(new F(`timeout of ${t}ms exceeded`,F.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>c.addEventListener("abort",o));const{signal:a}=s;return a.unsubscribe=()=>E.asap(l),a}},Hl=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let s=0,r;for(;s<n;)r=s+t,yield e.slice(s,r),s=r},Vl=async function*(e,t){for await(const n of ql(e))yield*Hl(n,t)},ql=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:s}=await t.read();if(n)break;yield s}}finally{await t.cancel()}},$n=(e,t,n,s)=>{const r=Vl(e,t);let o=0,i,l=a=>{i||(i=!0,s&&s(a))};return new ReadableStream({async pull(a){try{const{done:c,value:u}=await r.next();if(c){l(),a.close();return}let m=u.byteLength;if(n){let f=o+=m;n(f)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})},Bn=64*1024,{isFunction:et}=E,Gl=(({Request:e,Response:t})=>({Request:e,Response:t}))(E.global),{ReadableStream:Yn,TextEncoder:Hn}=E.global,Vn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Kl=e=>{e=E.merge.call({skipUndefined:!0},Gl,e);const{fetch:t,Request:n,Response:s}=e,r=t?et(t):typeof fetch=="function",o=et(n),i=et(s);if(!r)return!1;const l=r&&et(Yn),a=r&&(typeof Hn=="function"?(h=>p=>h.encode(p))(new Hn):async h=>new Uint8Array(await new n(h).arrayBuffer())),c=o&&l&&Vn(()=>{let h=!1;const p=new Yn,A=new n(ie.origin,{body:p,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return p.cancel(),h&&!A}),u=i&&l&&Vn(()=>E.isReadableStream(new s("").body)),m={stream:u&&(h=>h.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!m[h]&&(m[h]=(p,A)=>{let w=p&&p[h];if(w)return w.call(p);throw new F(`Response type '${h}' is not supported`,F.ERR_NOT_SUPPORT,A)})});const f=async h=>{if(h==null)return 0;if(E.isBlob(h))return h.size;if(E.isSpecCompliantForm(h))return(await new n(ie.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(E.isArrayBufferView(h)||E.isArrayBuffer(h))return h.byteLength;if(E.isURLSearchParams(h)&&(h=h+""),E.isString(h))return(await a(h)).byteLength},y=async(h,p)=>{const A=E.toFiniteNumber(h.getContentLength());return A??f(p)};return async h=>{let{url:p,method:A,data:w,signal:L,cancelToken:C,timeout:I,onDownloadProgress:_,onUploadProgress:U,responseType:S,headers:R,withCredentials:v="same-origin",fetchOptions:D}=qs(h),x=t||fetch;S=S?(S+"").toLowerCase():"text";let k=Yl([L,C&&C.toAbortSignal()],I),P=null;const N=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let j;try{if(U&&c&&A!=="get"&&A!=="head"&&(j=await y(R,w))!==0){let J=new n(p,{method:"POST",body:w,duplex:"half"}),de;if(E.isFormData(w)&&(de=J.headers.get("content-type"))&&R.setContentType(de),J.body){const[ae,fe]=Un(j,ct(Mn(U)));w=$n(J.body,Bn,ae,fe)}}E.isString(v)||(v=v?"include":"omit");const M=o&&"credentials"in n.prototype,Y={...D,signal:k,method:A.toUpperCase(),headers:R.normalize().toJSON(),body:w,duplex:"half",credentials:M?v:void 0};P=o&&new n(p,Y);let H=await(o?x(P,D):x(p,Y));const V=u&&(S==="stream"||S==="response");if(u&&(_||V&&N)){const J={};["status","statusText","headers"].forEach(re=>{J[re]=H[re]});const de=E.toFiniteNumber(H.headers.get("content-length")),[ae,fe]=_&&Un(de,ct(Mn(_),!0))||[];H=new s($n(H.body,Bn,ae,()=>{fe&&fe(),N&&N()}),J)}S=S||"text";let K=await m[E.findKey(m,S)||"text"](H,h);return!V&&N&&N(),await new Promise((J,de)=>{Hs(J,de,{data:K,headers:ue.from(H.headers),status:H.status,statusText:H.statusText,config:h,request:P})})}catch(M){throw N&&N(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new F("Network Error",F.ERR_NETWORK,h,P,M&&M.response),{cause:M.cause||M}):F.from(M,M&&M.code,h,P,M&&M.response)}}},Wl=new Map,Gs=e=>{let t=e&&e.env||{};const{fetch:n,Request:s,Response:r}=t,o=[s,r,n];let i=o.length,l=i,a,c,u=Wl;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:Kl(t)),u=c;return c};Gs();const cn={http:cl,xhr:Bl,fetch:{get:Gs}};E.forEach(cn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const qn=e=>`- ${e}`,zl=e=>E.isFunction(e)||e===null||e===!1;function Jl(e,t){e=E.isArray(e)?e:[e];const{length:n}=e;let s,r;const o={};for(let i=0;i<n;i++){s=e[i];let l;if(r=s,!zl(s)&&(r=cn[(l=String(s)).toLowerCase()],r===void 0))throw new F(`Unknown adapter '${l}'`);if(r&&(E.isFunction(r)||(r=r.get(t))))break;o[l||"#"+i]=r}if(!r){const i=Object.entries(o).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
4
4
|
`+i.map(qn).join(`
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
`+o)}}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=_e(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&it.assertOptions(s,{silentJSONParsing:me.transitional(me.boolean),forcedJSONParsing:me.transitional(me.boolean),clarifyTimeoutError:me.transitional(me.boolean),legacyInterceptorReqResOrdering:me.transitional(me.boolean)},!1),r!=null&&(E.isFunction(r)?n.paramsSerializer={serialize:r}:it.assertOptions(r,{encode:me.function,serialize:me.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),it.assertOptions(n,{baseUrl:me.spelling("baseURL"),withXsrfToken:me.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&E.merge(o.common,o[n.method]);o&&E.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=ue.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;a=a&&p.synchronous;const A=n.transitional||ln;A&&A.legacyInterceptorReqResOrdering?l.unshift(p.fulfilled,p.rejected):l.push(p.fulfilled,p.rejected)});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let u,m=0,f;if(!a){const h=[Gn.bind(this),void 0];for(h.unshift(...l),h.push(...c),f=h.length,u=Promise.resolve(n);m<f;)u=u.then(h[m++],h[m++]);return u}f=l.length;let y=n;for(;m<f;){const h=l[m++],p=l[m++];try{y=h(y)}catch(A){p.call(this,A);break}}try{u=Gn.call(this,y)}catch(h){return Promise.reject(h)}for(m=0,f=c.length;m<f;)u=u.then(c[m++],c[m++]);return u}getUri(t){t=_e(this.defaults,t);const n=Vs(t.baseURL,t.url,t.allowAbsoluteUrls);return ks(n,t.params,t.paramsSerializer)}};E.forEach(["delete","get","head","options"],function(t){we.prototype[t]=function(n,s){return this.request(_e(s||{},{method:t,url:n,data:(s||{}).data}))}});E.forEach(["post","put","patch"],function(t){function n(s){return function(o,i,l){return this.request(_e(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}we.prototype[t]=n(),we.prototype[t+"Form"]=n(!0)});let Ql=class zs{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const s=this;this.promise.then(r=>{if(!s._listeners)return;let o=s._listeners.length;for(;o-- >0;)s._listeners[o](r);s._listeners=null}),this.promise.then=r=>{let o;const i=new Promise(l=>{s.subscribe(l),o=l}).then(r);return i.cancel=function(){s.unsubscribe(o)},i},t(function(o,i,l){s.reason||(s.reason=new We(o,i,l),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=s=>{t.abort(s)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new zs(function(r){t=r}),cancel:t}}};function Zl(e){return function(n){return e.apply(null,n)}}function ea(e){return E.isObject(e)&&e.isAxiosError===!0}const Kt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Kt).forEach(([e,t])=>{Kt[t]=e});function Js(e){const t=new we(e),n=xs(we.prototype.request,t);return E.extend(n,we.prototype,t,{allOwnKeys:!0}),E.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return Js(_e(e,r))},n}const z=Js(Ke);z.Axios=we;z.CanceledError=We;z.CancelToken=Ql;z.isCancel=Ys;z.VERSION=Ws;z.toFormData=yt;z.AxiosError=F;z.Cancel=z.CanceledError;z.all=function(t){return Promise.all(t)};z.spread=Zl;z.isAxiosError=ea;z.mergeConfig=_e;z.AxiosHeaders=ue;z.formToJSON=e=>$s(E.isHTMLForm(e)?new FormData(e):e);z.getAdapter=Ks.getAdapter;z.HttpStatusCode=Kt;z.default=z;const{Axios:Wd,AxiosError:zd,CanceledError:Jd,isCancel:Xd,CancelToken:Qd,VERSION:Zd,all:ef,Cancel:tf,isAxiosError:nf,spread:sf,toFormData:rf,AxiosHeaders:of,HttpStatusCode:lf,formToJSON:af,getAdapter:cf,mergeConfig:uf}=z,oe={onAction:(e,t)=>({formData:e,patch:t}),onChange:e=>{},onFormComplete:()=>{},onFormLoad:e=>{},onGetComponent:(e,t)=>null,onGetCYA:e=>null,onGetCYARows:(e,t,n)=>null,onGoingBack:()=>{},onPageChange:(e,t)=>e,onRequest:e=>e,onSubmit:(e,t,n,s)=>{typeof n=="function"&&n()},onValidate:(e,t)=>t,onCancel:e=>{}},Wn=Object.keys(oe),Xs=O.createContext(),Qs=({overrides:e={onAction:void 0,onCancel:void 0,onChange:void 0,onFormComplete:void 0,onFormLoad:void 0,onGetComponent:void 0,onGetCYA:void 0,onGetCYARows:void 0,onGoingBack:void 0,onPageChange:void 0,onRequest:void 0,onSubmit:void 0,onValidate:void 0},children:t=null})=>{const[n,s]=O.useState({onAction:e?.onAction||oe.onAction,onChange:e?.onChange||oe.onChange,onFormComplete:e?.onFormComplete||oe.onFormComplete,onFormLoad:e?.onFormLoad||oe.onFormLoad,onGetComponent:e?.onGetComponent||oe.onGetComponent,onGetCYA:e?.onGetCYA||oe.onGetCYA,onGetCYARows:e?.onGetCYARows||oe.onGetCYARows,onGoingBack:e?.onGoingBack||oe.onGoingBack,onPageChange:e?.onPageChange||oe.onPageChange,onRequest:e?.onRequest||oe.onRequest,onSubmit:e?.onSubmit||oe.onSubmit,onValidate:e?.onValidate||oe.onValidate,onCancel:e?.onCancel||oe.onCancel}),r=(i,l)=>{Wn.includes(i)&&s(a=>({...a,[i]:l||oe[i]}))},o=i=>{Wn.includes(i)&&s(l=>({...l,[i]:oe[i]}))};return d.jsx(Xs.Provider,{value:{hooks:n,addHook:r,removeHook:o},children:t})},ge=()=>O.useContext(Xs),ta=()=>{const{hooks:e}=ge(),[t,n]=O.useState({});return O.useEffect(()=>{const s=z.create({baseURL:"/"});return s.interceptors.request.use(e.onRequest),s.interceptors.response.use(r=>r,async r=>Promise.reject(r)),n({instance:s}),()=>{n({})}},[e]),t.instance},un=O.createContext(),Zs=({children:e=null})=>{const{hooks:t}=ge(),[n,s]=O.useState([]),[r,o]=O.useState([]),i=f=>{o(y=>[...y,...f].filter(h=>!!h))},l=f=>{typeof f=="function"&&o(y=>y.filter(h=>!f(h)))},a=()=>{r.length&&o([])},c=f=>{s(y=>[...y,...f].filter(h=>!!h))},u=()=>{o([]),s([])},m={page:f=>{const y=g.Validate.page(f,r),h=t.onValidate(f,y);return s(h),h},pages:f=>{const y=f.map(p=>g.Validate.page(p,r)),h=f.flatMap((p,A)=>t.onValidate(p,y[A]));return s(h),h}};return d.jsx(un.Provider,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:m},children:e})},De=()=>O.useContext(un),Lt={},Dt={},na="idle",sa="fetching",er="fetched",tr="error",ra=(e,t=!0)=>{const n=ta(),s=O.useRef(z.CancelToken.source()),[r,o]=O.useState(na),[i,l]=O.useState(null),[a,c]=O.useState(null),u=()=>{s.current&&s.current.cancel()};return O.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(sa);let f;if(t&&Lt[e])f=Lt[e];else{if(t&&Dt[e])throw Dt[e];f=(await n.get(e,{cancelToken:s.current.token}).catch(h=>{throw l(h),h})).data,t&&(Lt[e]=f)}c(f),o(er)}catch(f){t&&(Dt[e]=f),l(f),c(null),o(tr)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},oa="loading",lt="complete",ia=e=>{const t=e.data;if(t&&!t.options||t?.url)return T.Utils.interpolateString(t.url,e.formData)},la=(e,t)=>{const n=ia({...e,formData:t}),{status:s,data:r}=ra(n,e?.data?.useCache),[o,i]=O.useState([]),[l,a]=O.useState(oa);return O.useEffect(()=>{n?s===er?(r&&i(le.refData.toOptions(r.data||r,e.item)),a(lt)):s===tr&&(i([]),a(lt)):(e.data&&e.data.options&&i(le.refData.toOptions(e.data.options,e.item)),a(lt))},[e.id,s,r,n]),{data:o,status:l}},$e=(e,t)=>{const n=Q(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(T.FormGroup,{...n,onChange:null,children:t})},dn=(e,t,n,s,r={})=>{if(!t)return[];const o=g.CollectionPage.getData(t.collection.name,t.formData)||[];let i=[];return o.forEach(l=>{r={...r,[`${t.collection.name.split(".").pop()}ActiveId`]:l.id};const a=t.childPages?.flatMap(c=>{const u={...c,formData:{...n,...r}};if(c.childPages)return dn(e,u,n,s,r);const m=g.Validate.page(u);return s.onValidate(u,m)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},fn=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Fe,{component:{...t,readonly:!0},wrap:!1,value:e,formData:n}):Object.prototype.hasOwnProperty.call(e,"label")?e.label:e:(Object.prototype.hasOwnProperty.call(t||{},"cyaPlaceholder")?t?.cyaPlaceholder:s)||d.jsx(T.VisuallyHidden,{children:"No answer"}),aa="Continue",Wt=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?G.DEFAULTS[e]:e,r=G.DEFAULTS[e.type];return s?d.jsx(T.Button,{...n,className:s.className,classModifiers:s.classModifiers,start:s.start||!1,name:s.label,onClick:s.disabled?()=>{}:()=>t(s),children:s.label||r?.label||aa}):null},ca="hods-form-confirmation",ua="Are you sure?",da="Confirm",fa=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=T.Utils.classBuilder(ca,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||ua}),s,d.jsx(T.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||da}),d.jsx(T.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},hn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===b.CONTAINER?hn(t):ze.editable(t)?t:null).filter(t=>!!t):[],ha=e=>{const t=e.full_path||e.fieldId;return e.components.map(n=>{const s=t?`${t}.${n.fieldId}`:n.fieldId,r={...n,full_path:s};return n.type===b.CONTAINER?zt(r):(n.type===b.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===b.CONTAINER&&(r.data.options[i].nested[a]=zt(l))})}),r)})},zt=e=>{if(e){const t=ha(e);return{...e,components:t}}return e},ma=(e,t)=>e.some(n=>ze.show(n,t)),pa=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t);const n=hn(e);return n.length>0?ma(n,t):!0},St={editableComponents:hn,setup:zt,show:pa},Ea=(e,t)=>e.some(n=>Ce(n,t)),Ct=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t);const n=St.editableComponents(e);return n.length>0?Ea(n,t):!0},Aa=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!Ct(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(m=>m.id===a)});return}const c=l.components.find(m=>m.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){xe(a.show_when,{...t,...n})&&s.push({...u,show_when:c.show_when||[]});return}s.push(u)})});const r={...e.childPages[0],formData:t};r.components=s,r.actions=[{type:"save",label:"Save",validate:!0,classModifiers:"primary"},{type:"cancel",label:"Cancel",classModifiers:"secondary"}];const{id:o,...i}=n;return r.formData={...r.formData,...i,[`${e.collection?.name?.split(".").pop()}ActiveId`]:n.id},delete r.title,delete r.collection,r},mn=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(T.ButtonGroup,{children:e.map((n,s)=>d.jsx(Wt,{action:n,onAction:t},s))}),ya=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?se.meetsOne(t.runWhen?.constraint,e.formData):!1},nr="hods-form__page",pn=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=nr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:m})=>{const[f,y]=O.useState({}),{errors:h,validate:p}=De(),[A,w]=O.useState({}),[L,C]=O.useState(!1),I=O.useMemo(()=>ya(e),[e]);O.useEffect(()=>{C(!0)},[]),O.useEffect(()=>{L&&I&&p.page(e)},[m,L]);const _=({target:x})=>{const k=e,{value:P}=x;P?(k.formData[x.name]=P,y(N=>({...N,[x.name]:P})),w(N=>({...N,[x.component]:x.label}))):(delete k.formData[x.name],y(N=>{const{[x.name]:j,...M}=N;return M}),w(N=>{const{[x.component]:j,...M}=N;return M})),typeof o=="function"&&o(e.formData)};O.useEffect(()=>{const x=document.title.replace("Error: ","");document.title=h.length>0?"Error: "+x:x},[h]);const U=g.classBuilder(l,a,c),S=e;S.actions=S.actions?.map(x=>x.label?{...x,label:g.interpolateString(x.label,S.formData)}:x),S.formData=g.Operate.runPageOperations(S,{...S.formData,...f},s||_);const R=e.title?d.jsx(T.Heading,{size:e.titleSize,children:g.FormPage.getTitle(e.title,e.formData)}):d.jsx(T.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),v=e.components.filter(x=>g.Component.show(x,e.formData)).map((x,k)=>d.jsx(Fe,{component:x,onAction:P=>n(P,f,A),onChange:s||_,onTopLevelChange:r||_,value:e.formData[x.fieldId]||f[x.fieldId],formData:e.formData,pages:t,submitting:u},k));let D=null;return I&&h?.length>0?D=[{error:e?.customValidation?.[0]?.message}]:h?.length>0&&!I&&(D=h),d.jsxs("div",{className:U(),children:[D&&d.jsx(T.ErrorSummary,{errors:D,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:R}),v]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[R,v]}),d.jsx(mn,{actions:e.actions?.filter(x=>g.Component.show(x,e.formData)),onAction:x=>n(x,f,A)})]},e.id)},zn="hods-form-banner-strip",sr=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=g.classBuilder(zn,s,""),o=t.filter(i=>g.Component.show(i,n));return d.jsx("div",{id:e,className:r(),children:o.map((i,l)=>{const a=`${e}-banner-${l}`;if(typeof i=="string"||i.type==="plain"){const c=typeof i=="string"?i:i.text;return d.jsx("div",{id:a,className:r("banner"),children:d.jsx(T.Markup,{content:g.interpolateString(c,n)})},a)}return d.jsx(T.Tag,{classBlock:`${zn}__tag`,classModifiers:i.classModifiers,text:g.interpolateString(i.text,n)},a)})})},Ta=e=>{if(e&&e.action){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},En=({row:e})=>{const[t,n]=O.useState({});return O.useEffect(()=>{n(Ta(e))},[e,n]),e.action?d.jsxs(T.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(T.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},rr=({row:e,classes:t,showAction:n=!1})=>d.jsxs("dl",{className:t("row"),role:"listitem",children:[d.jsxs("dt",{className:t("key"),children:[e.key,!e.required&&" (optional)"]}),d.jsx("dd",{className:t("value"),children:e.value}),n&&d.jsx("dd",{className:t("actions"),children:e.action&&d.jsx(En,{row:e})})]}),or=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(T.SmallHeading,{children:e})}),at=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=wt(o,t);return t.type==="title"?d.jsx(or,{title:t.key,classes:n}):d.jsx(rr,{row:{key:i.key,value:d.jsx(fn,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Sa="govuk-summary-card",Ca="govuk-summary-list",tt="Item",nt="Change",Jn="Delete",ga="warning",ba=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=T.Utils.classBuilder(Sa,i,n.className),c=T.Utils.classBuilder(Ca,[]);return d.jsxs("div",{className:a(),id:e,children:[d.jsxs("div",{className:a("title-wrapper",[],"dark"),children:[d.jsxs("div",{className:a("title-content"),children:[d.jsx("h2",{className:a("title"),children:T.Utils.interpolateString(n.title||tt,{...t,index:t.index+1})}),n.banners&&d.jsx(sr,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t})]}),d.jsxs("ul",{className:a("actions"),children:[d.jsx("li",{className:a("action"),children:n.changeAction&&typeof s=="function"&&n.changeAction.classModifiers?d.jsx(T.Button,{id:`${e}.changeButton`,onClick:()=>s(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||nt} ${n.title||tt}`,{...t,index:t.index+1}),children:n.changeAction?.label||nt}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>s(n.changeAction.page,t.id),"aria-label":T.Utils.interpolateString(`${n.changeAction?.label||nt} ${n.title||tt}`,{...t,index:t.index+1}),children:n.changeAction?.label||nt})}),d.jsx("li",{className:a("action"),children:n.deleteAction&&typeof r=="function"&&d.jsx(T.Button,{id:`${e}.deleteButton`,onClick:()=>r(t),classModifiers:n.deleteAction.classModifiers||ga,"aria-label":T.Utils.interpolateString(`${n.deleteAction?.label||Jn} ${n.title||tt}`,{...t,index:t.index+1}),children:n.deleteAction.label||Jn})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const m=u.components.map(f=>g.Component.elevateNested([f],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(f=>{const h=f.columns.filter(p=>se.meetsAll(p,{...u.formData,...t})).flatMap(p=>p.fields||[]);return h.length?h.flatMap(p=>{const A=m.find(w=>w.fieldId===p);return A?at(u,A,c,t,l):null}):null})})})})]})},wa=({id:e,"data-testid":t,actions:n,onFullEdit:s=null,entryData:r,formData:o,name:i,autoFocus:l})=>Array.isArray(n)?d.jsx(d.Fragment,{children:n.filter(a=>g.Component.show(a,o)).map(a=>d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||Qn,"aria-label":g.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||Xn},e))}):d.jsx(T.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||Qn,"aria-label":g.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||Xn}),Ia=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},gt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Ia(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},ir=[b.ALERT,b.COLLECTION_SUMMARY,b.DETAILS,b.HEADING,b.HTML,b.INSET_TEXT],ut=(e,t)=>{if(!e||ir.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===b.COLLECTION){if(!ee(t,e.full_path||e.fieldId)?.length)return!1}else{const n=ee(t,e.fieldId);if(!n&&n!==!1&&n!==0)return!1}return e.type===b.CONTAINER?St.show(e,t):ze.show(e,t)},lr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>ir.includes(n.type)?null:{...n,...!n.full_path&&{full_path:`${t.full_path||`${e.full_path}.${t.fieldId}`}.${n.fieldId}`}}).filter(n=>!!n)}:{...t,...!t.full_path&&{full_path:`${e.full_path||e.fieldId}.${t.fieldId}`}})}),_a=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:gt(!1,e,t)}],Pa=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:b.CONTAINER,required:e.required,full_path:s,components:e.item.map(r=>({...r,label:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),xa=(e,t,n,s,r)=>{const o={...ve,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:r,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"title",action:null}:null},An=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&ut(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=Pa(t,o,l,a);return c=lr(c),[xa(t,o,e.id,l,a),...je(e,c,o,s,r)]}).filter(o=>!!o):_a(e,s),Na="hods-form-summary-card-details",ar=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=g.classBuilder(Na,r),a=O.useMemo(()=>t.map(u=>e.childPages.find(m=>m.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,m,f)=>{let y=0;return u.flatMap((h,p)=>{let A=0;const w=h.fields?.flatMap(C=>m.filter(_=>_.fieldId===C).map(_=>{if(!_||!Ce(_,{...f.formData,...s}))return null;if(_.type===b.CONTAINER){const U=je(f,_,s);return A+=1,d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:U.map(S=>{const R={...s,[S.fieldId]:s[_.fieldId]?.[S.fieldId]};return at(f,{...S,label:S.key},l,R,i)})},C)}if(_.type===b.COLLECTION){const U=An({...f,formData:{...f.formData,...s}},_,s[_.id]);A+=1;let S=0;return d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:U.map(R=>{const v={...s,[R.fieldId]:s[_.fieldId]?.[R.fieldId]},D=at(f,{...R,label:R.key},l,v,i);return R.type==="title"&&(S+=1,S>1)?d.jsx("div",{style:{marginTop:"40px"},children:D}):D})},C)}return A+=1,d.jsx("div",{className:l("field"),style:{"--column":y+1,"--row":A},role:"list",children:at(f,_,l,s,i)},C)})).filter(C=>!!C);return!(p===u.length-1)&&w.length!==0?(y+=2,[...w,d.jsx("div",{className:l("divider"),style:{"--column":y}},`divider${y}`)]):w}).filter(h=>!!h)};return e?.childPages?.filter(u=>g.FormPage.show(u,{...n,...s})).map(u=>{const m=g.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(f=>{if(f.show_when&&!g.Condition.meetsAll(f.show_when,{...n,...s}))return null;if(f.type==="childCollection"){const h=a.find(A=>A.collection.name===f.collectionName),p=s[f.collectionName.split(".").pop()]||[];return h&&p.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:f.title}),p.map(A=>d.jsx(ar,{masterPage:h,childMasterPages:[],formData:{...n,...s,...A},entryData:A,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const y=f.columns.filter(h=>se.meetsAll(h,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:g.FormPage.getConditionalText(f.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":y.length-1},children:c(y,m,u)})]},f.title)})}).filter(u=>!!u)||null},Oa="hods-form-summary-card",Xn="Change",Ra="Delete",va="Quick Edit",La="Duplicate",Da="Full details",Qn="secondary",Zn=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:m,hideDetails:f=!1})=>{const[y,h]=O.useState(!1),p=T.Utils.classBuilder(Oa,s,n.className),A=O.useMemo(()=>n.quickEdit?Aa(m,u,t):null,[m,n,u,t,y]),{addErrors:w,resetQuickEditErrors:L,clearTopLevelErrorsForCard:C,validate:I}=De(),{hooks:_}=ge(),U=async(S,R)=>{if(S.type==="cancel"&&(h(v=>!v),L?.()),S.type==="save"&&typeof l=="function"){const v={...A.formData,...R,[`${a}ActiveId`]:t.id},D=I.page({...A,formData:v});if(D.length)return;let x;await _.onSubmit("quickEdit",v,()=>{},P=>{x=P}),x&&w(x);const k=D.concat(x);if(k.length===0||k.length===1&&k[0]===void 0){C();const P=g.CollectionPage.getData(a,u),{isDuplicate:N,...j}=P[t.index];P[t.index]={...j,...R},l({target:{name:a,value:P}}),h(M=>!M)}}};return n.listView?d.jsx(ba,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:m,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:p(),id:e,children:[d.jsxs("div",{className:p("header"),children:[d.jsxs("div",{className:p("header-content"),children:[n.banners&&d.jsx(sr,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:p("header-content-title"),children:g.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:p("header-content-detail"),children:g.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:p("header-actions"),children:[n.quickEdit&&d.jsx(T.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>h(S=>!S),classModifiers:"primary",disabled:y,name:"QuickEdit",autoFocus:n.focusOn,children:va}),n.changeAction&&typeof r=="function"&&d.jsx(wa,{id:`${e}.changeButton`,"data-testid":"change-button",actions:n.changeAction,onFullEdit:r,entryData:t,formData:u,name:"Change",autoFocus:n.focusOn}),n.deleteAction&&typeof o=="function"&&d.jsx(T.Button,{id:`${e}.deleteButton`,onClick:()=>o(t),classModifiers:"secondary","aria-label":g.FormPage.getConditionalText(n.deleteAction?.aria_label,t),name:"Delete",children:n.deleteAction?.label||Ra}),n.duplicateAction&&typeof i=="function"&&d.jsx(T.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{i(t)},classModifiers:"secondary","aria-label":g.FormPage.getConditionalText(n.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:n.focusOn,children:n.duplicateAction?.label||La})]})]}),y&&A&&d.jsx(pn,{page:A,onAction:(S,R)=>U(S,R),className:p("editpage")}),d.jsx("div",{className:p("body"),children:!f&&d.jsx(T.Details,{summary:n.detailsTitle||Da,className:"details",children:d.jsx(ar,{masterPage:m,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},Fa=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=ge(),o=t.filter(m=>m.entryId===e)||[],[i,l]=O.useState(null),a=()=>{l(null)},c=m=>{l(f=>(f??[]).concat(m))},u={page:m=>{const f=g.Validate.page(m),y=r.onValidate(m,f);return l(y),y}};return d.jsx(un.Provider,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},es="Add",ja=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=ge(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:m,dequeueErrors:f}=De(),[y,h]=O.useState(null),p=O.useMemo(()=>g.CollectionPage.getData(e.collectionName,t)||[],[t]),A=Array.isArray(p)&&p.length>0?p.reduce((R,v)=>v.isDuplicate&&(!R||v.id>R.id)?v:R,null):null,w=O.useMemo(()=>{const R=e.collectionName.split(".");let v=g.CollectionPage.mergePages(o||[])||[];return R.reduce((D,x,k)=>{const P=k===0?`${D}${x}`:`${D}.${x}`;return k===R.length-1?v?.find(N=>N.collection?.name===P)||null:(v=v.find(N=>N.collection?.name===P)?.childPages||null,P)},"")},[o]),L=O.useMemo(()=>e.card.listView?w.childPages?.reduce((v,D)=>{const x=He(D.components,{...t,...y});return v.concat(x)},[])||[]:[],[w,t,y,e.card.listView]),C=()=>{u.length>0&&f(v=>v.raisedBy===e.id);const R=dn(e,w,t,i);R.length>0&&m(R)};O.useEffect(()=>{Array.isArray(p)&&p.length>0&&C()},[p]);const I=(R,v)=>{if(typeof n=="function"){const D=[...p],x=p.findIndex(N=>N.id===v),{isDuplicate:k,...P}=p[x];D[x]={...P},n({type:st.SAVE_AND_NAVIGATE,page:R,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:v},{field:e.collectionName,value:D,isCollection:!0}]})}},_=R=>{g.CollectionPage.duplicateEntry(e.collectionName,t,R.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const v=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:v,value:g.CollectionPage.getData(v,t)}}),C())},U=()=>{if(!y)return;g.CollectionPage.removeEntry(e.collectionName,t,y.id);const R=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:R,value:g.CollectionPage.getData(R,t)}}),h(null),C()},S=R=>{const v=L.find(x=>x.fieldId===R);if(!v)return null;const D=wt({...w,formData:{...t,...y}},v);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(fn,{value:D.value,component:D.component,formData:D.formData})},R)};return d.jsxs("div",{id:e.fieldId,children:[y&&d.jsx(fa,{id:`${e.fieldId}.confirmation`,message:g.interpolateString(e.confirmation?.message,{...y,index:y.index+1})||null,confirmLabel:g.interpolateString(e.confirmation?.label,y)||null,onConfirm:U,onCancel:()=>h(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(S)}):d.jsx(Zn,{id:`${e.fieldId}.confirmationChild`,entryData:y,config:e.card?{...e.card,quickEdit:null}:{},masterPage:w,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(Wt,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:g.interpolateString(e.addButton.label||es,{documents:p}),page:e.addButton.page,type:st.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:p.map((R,v)=>{const D=l.filter(P=>P.entryId===R.id).length>0,x={...e.card,...R.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...D&&e.errorCard?e.errorCard:{},focusOn:A?.id===R.id},k=`${e.fieldId}.summaryCard${R.id}`;return d.jsx("li",{children:d.jsx(Fa,{entryId:R.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const P=l.filter(N=>N.entryId!==R.id);c(),a(P)},children:d.jsx(Zn,{id:k,entryData:{...R,index:v},masterPage:w,config:x||{},onFullEdit:I,onDuplicate:_,onDelete:()=>h({...R,index:v}),onQuickEdit:P=>(C(),s(P)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:R.id===y?.id?["deleting-summary-card"]:[""],inError:l.filter(P=>P.entryId===R.id).length>0},k)})})})}),e.card.listView&&e.addButton&&d.jsx(Wt,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:g.interpolateString(e.addButton.label||es,{documents:p}),page:e.addButton.page,type:st.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},Ua="hods-form-collection",Ma=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=O.useState(t),a=p=>{l(p),typeof s=="function"&&s({target:{name:e.fieldId,value:p}})},c=({target:p})=>{if(typeof s=="function")if(p.name===g.Meta.name)s({target:p});else{const A=i.findIndex(w=>w.id===p.name);a([...i.slice(0,A),p.value,...i.slice(A+1)])}},u=async()=>{a([...i,{id:mt.v4()}])},m=async p=>{a(i.filter(A=>A.id!==p.id))},f=p=>p.initial&&!i.length?p.initial:p.add;O.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const p=i[i.length-1]?.id,w=document.getElementById(p)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');w&&w.length>0&&w[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),O.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const y={...ve,...e.labels},h=g.classBuilder(Ua,[],e.className);return d.jsxs("div",{className:h(),id:e.id,children:[e.label&&d.jsx(T.Label,{id:e.id,required:e.required,className:h("title"),children:e.label}),Array.isArray(i)&&i.map((p,A)=>{const w=`${e.full_path||e.fieldId}[${A}]`,L=(e.countOffset||0)+A+1,C=g.interpolateString(y.item,{...p,index:L}),I=g.interpolateString(y.remove,{...p,index:L}),_=e.disableAddAndRemove||A===0&&e.minimumEntries?"":e.removeLocation??"start",U=A!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${h("item")}`,style:U,children:[d.jsxs(T.Label,{id:p.id,required:!0,className:h("item-title"),children:[C,_==="start"&&d.jsx(T.Button,{onClick:()=>m(p),classModifiers:"secondary",children:I})]}),d.jsx(Cn,{container:{id:p.id,fieldId:p.id,type:"container",required:e.required,full_path:w,components:e.item.map(S=>{const{firstOnlyLabel:R,...v}=S;let{hint:D}=S;e.restrictHint&&A>0&&(D=void 0);let{label:x}=S;return A===0&&(x=S.firstOnlyLabel??S.label),{...v,hint:D,readonly:!!(e?.readonly||S.readonly),label:g.interpolateString(x,{...p,index:L}),full_path:`${w}.${S.fieldId}`}})},value:p,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),_==="end"&&d.jsx(T.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(T.Button,{onClick:()=>m(p),classModifiers:"secondary",children:I})})]},p.id)}),!e.disableAddAndRemove&&d.jsx(T.ButtonGroup,{children:d.jsx(T.Button,{onClick:u,classModifiers:"secondary",children:f(y)})})]})},ka=(e,t,n)=>{const s=e,r=typeof s.value=="object"?s.value?.value:s.value,o=n.find(i=>String(i.id)===r);return s.label=o===void 0?s.value||"":o.label,s.component=t.cya_label,s},$a=(e,t)=>typeof e=="string"?!!T.Utils.interpolateString(e,t):!!e,Ft=(e,t)=>{if(Array.isArray(t)){const n=t.find(s=>s.id===(e.full_path||e.id));if(n){const s={error:n.error};return n.properties&&(s.propsInError=n.properties),s}}},Ba=[b.RADIOS,b.CHECKBOXES,b.DATE,b.TIME],Ya=e=>e.fieldset||Ba.includes(e.type),Fe=({component:e,value:t=null,formData:n=null,wrap:s=!0,onAction:r,onChange:o,onTopLevelChange:i,pages:l=[],submitting:a=!1,...c})=>{const{hooks:u}=ge(),m=De(),{data:f,status:y}=la(e,n),[h,p]=O.useState([]);O.useEffect(()=>{y===lt&&p(f)},[e,f,y]);const A=({target:C})=>typeof o=="function"?(e.type===b.EMAIL&&(C.value=C.value.trim()),e.type===b.CHECKBOXES&&Array.isArray(C.value)&&C.value.forEach(I=>{I.children&&I.nested&&(delete I.children,delete I.nested)}),C=ka(C,e,f),e.type===b.SELECT&&C.value===""&&(C.value=null,C.label=null),o({target:C}),!0):!1;if(O.useEffect(()=>{const C=g.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&C&&typeof A=="function"&&A({target:{name:e.fieldId,value:C}})},[]),e.type===b.CONTAINER){let C=d.jsx(Cn,{...c,container:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||g.Component.defaultValue(e,n),formData:n});return e.fieldset&&(C=$e(e,C)),e.additionalValidation&&(C=$e({...e,...Ft(e,m?.errors)},C)),C}if(e.type===b.COLLECTION)return d.jsx(Ma,{...c,config:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||g.Component.defaultValue(e,n),formData:n});if(e.type===b.COLLECTION_SUMMARY)return $e({...e,...Ft(e,m?.errors)},d.jsx(ja,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const w=C=>{let I=e.full_path||e.fieldId;if(e.pageCollection){const _=g.CollectionPage.getActiveIndex(e.pageCollection.name,n);I=`${`${e.pageCollection.name}[${_}]`}.${I}`}i({target:{name:g.Meta.name,value:g.Meta.documents.setForField(C,n,I,e.allowMultiple)}})},L=({target:C})=>{if(A({target:C})){if(e.type===b.FILE)w([C.value]);else if(e.type===b.MULTI_FILE){const I=C.value.map((_,U)=>({..._,indexInField:U}));w(I)}}};return g.Component.get({...c,...e,id:e.full_path||e.id,...Ft(e,m?.errors),fieldset:Ya(e),disabled:$a(e.disabled,n),label:g.interpolateString(e.label,n),content:g.interpolateString(e.content,n),hint:g.interpolateString(e.hint,n),cya_label:g.interpolateString(e.cya_label,n),suffix:g.interpolateString(e.suffix,n),options:h,value:t,onChange:L,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},Ha=[b.AUTOCOMPLETE,b.CALCULATION,b.CHECKBOXES,b.COLLECTION_SUMMARY,b.DATE,b.EMAIL,b.FILE,b.MULTI_FILE,b.PHONE_NUMBER,b.RADIOS,b.SELECT,b.TEXT,b.TEXT_AREA,b.TIME],cr=e=>Ha.includes(e?.type)||e?.isEditable||!1,Va="govuk-list",qa="govuk-body",Ga=e=>{const t=Q(e),n=T.Utils.interpolateString(e.heading,e.formData),s=T.Utils.interpolateString(e.text,e.formData);return d.jsx(T.Alert,{...t,heading:n,children:s})},Ka=e=>{const t=Q(e),n=le.getAutocompleteSource(e);return d.jsx(T.Autocomplete,{...t,source:n})},Wa=e=>{let t=[];le.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:ur(e,s.nested)}:s);const n=Q(e);return d.jsx(T.Checkboxes,{...n,options:t})},za=e=>{const t=le.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=Q(e,["formula"]);return d.jsx(T.TextInput,{...n,readonly:!0})},Ja=e=>{const t=Q(e);return d.jsx(T.DateInput,{...t})},Xa=e=>{const t=Q(e,["tagName"]),n=bt(e);return d.jsx(T.Details,{...t,children:n})},Qa=e=>{const t=Q(e);return d.jsx(T.FileUpload,{...t})},Za=e=>{const t=Q(e);return d.jsx(T.MultiFileUpload,{...t})},ec=e=>{const t=Q(e);return d.jsx(T.Heading,{...t,children:e.content})},bt=e=>{const t=Q(e);return d.jsx(T.Markup,{...t})},tc=e=>{const t=Q(e);return d.jsx(T.InsetText,{...t,children:e.content})},nc=e=>{const t=Q(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=T.Utils.classBuilder(Va,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return bt({...t,className:r(),tagName:n,content:o,type:b.HTML})},sc=e=>{const t=Q(e);return bt({className:qa,...t,tagName:"p",type:b.HTML})},rc=e=>{let t=[];le.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:ur(e,s.nested)}:s);const n=Q(e);return d.jsx(T.Radios,{...n,options:t})},oc=e=>{const t=Q(e);return d.jsx(T.TextArea,{...t})},ic=e=>{const t=Q(e);return d.jsx(T.TextInput,{...t})},lc=e=>{const t=Q(e);return d.jsx(T.TimeInput,{...t})},ac=e=>{let t=[];le.getOptions(e,s=>{t=s});const n=Q(e);return d.jsx(T.Select,{...n,options:t})},cc=e=>{const t=Q(e);return d.jsx(T.WarningText,{...t,children:e.content})},uc=e=>{switch(e.type){case b.HTML:return bt(e);case b.HEADING:return ec(e);case b.INSET_TEXT:return tc(e);case b.TEXT:case b.EMAIL:case b.PHONE_NUMBER:return ic(e);case b.TEXT_AREA:return oc(e);case b.AUTOCOMPLETE:return Ka(e);case b.RADIOS:return rc(e);case b.CHECKBOXES:return Wa(e);case b.DATE:return Ja(e);case b.TIME:return lc(e);case b.FILE:return Qa(e);case b.MULTI_FILE:return Za(e);case b.WARNING:return cc(e);case b.SELECT:return ac(e);case b.DETAILS:return Xa(e);case b.CALCULATION:return za(e);case b.ALERT:return Ga(e);case b.PARAGRAPH:return sc(e);case b.LIST:return nc(e);default:return null}},dc=(e,t)=>{const n={...t};if(e.full_path){const s=e.full_path.split(".");s.pop(),s.push(n.fieldId),n.full_path=s.join(".")}return e.formData&&(n.value=e.formData[n.fieldId]||le.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:dr(n,!1)})):d.jsx(Fe,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},ur=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!se.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:dc(e,s)},s.id));return n.length>0?n:null},dr=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=uc(e);return s&&t&&cr(e)?$e(e,s):s},fc=e=>e.defaultValue||e.defaultObjectValue,hc=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?q().format("DD-MM-YYYY"):n},mc=(e,t)=>{const n={...e};let s=null;return!n.literal&&!n.sourced&&(n.sourced={...n}),n.literal&&(s={...n.literal}),n.sourced&&(s=s??{},Object.keys(n.sourced).every(r=>{const o=typeof n.sourced[r]=="string"&&ee(t,n.sourced[r]);return o===void 0&&n.skipIfSourceInvalid?(s=null,!1):(s[r]=o||n.sourced[r],!0)})),s},fr=(e,t)=>fc(e)?e.type===b.DATE?hc(e):(e.defaultObjectValue?mc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,pc={[b.COLLECTION]:[],[b.CONTAINER]:{}},Ec=(e,t)=>e&&(fr(e,t)||pc[e.type])||"",ze={clean:Q,defaultValue:Ec,defaultValueFromConfig:fr,editable:cr,elevateNested:He,get:dr,setupContainerPaths:lr,show:Ce,wrap:$e},Ac=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&Ye(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},wt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],Ac(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:T.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:ze.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:gt(t.readonly,e,n)}},je=(e,t,n,s,r)=>ut(t,{...e.formData,...n})?He(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>ut(i,{...e.formData,...n})).flatMap(i=>{const l=n?n[i.fieldId]:void 0;if(typeof r=="function"){const a=r({...e,formData:n},i,s);if(a)return a}return i.type===b.CONTAINER?je(e,i,{...l,...n},s,r):i.type===b.COLLECTION?An(e,i,l,s,r):wt({...e,formData:n},i,s)}):null,yc=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(n=>{g.Condition.met(n.condition,e.formData[n.condition.field])&&(t=Object.assign(t,n.properties))}),t},ts=(e,t,n="text")=>{if(typeof e=="string")return T.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const s=e.find(r=>typeof r=="string"?!0:xe(r.show_when,t));return typeof s=="string"?T.Utils.interpolateString(s,t):T.Utils.interpolateString(s[n],t)},Tc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Sc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return G.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return G.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),Tc(n)}}).filter(t=>!!t)},Cc=e=>({type:b.HTML,tagName:"p",content:e}),gc=(e,t)=>{const n=e.use.split("."),s=n.shift();let r=JSON.parse(JSON.stringify({...t.find(l=>l.id===s)})),o=r,i=r;for(;o&&n.length>0;){const l=n.shift();Array.isArray(o.components)?(i=o,i.components=i.components.filter(a=>a.id===l),i.components.length>0?o=i.components[0]:o=void 0):o=void 0}if(o)return o={cya_label:o.label,...o,...e},i&&i.id!==o.id?i.components=[o]:r=o,o.item&&Array.isArray(o.item)&&(o.item=o.item.map(l=>l.use?Jt(l,t):l)),r},Jt=(e,t)=>{if(e){const n=gc(e,t);if(n)return n}return{...e}},hr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return Cc(o);let i;return o.type===b.CONTAINER&&(o.components=o.components.map(l=>l.use?Jt(l,t):l)),o.use?i=Jt(o,t):i={...o},n?le.refData.setupUrl(i,n):i}),r=Sc(e);return St.setup({...e,formData:n,components:s,actions:r})},bc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...hr(s,t,n),index:r})):[],mr=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:Ct(e,t),Je={applyConditionalProperties:yc,getConditionalText:ts,get:hr,getAll:bc,getTitle:(e,t)=>ts(e,t,"title"),show:Ct,showCYA:mr},wc=(e,t)=>{if(!e)return null;if(!t)return e;const n={...e};return n.show_when?Array.isArray(t)?n.show_when=Array.isArray(n.show_when)?[...t,...n.show_when]:[...t,n.show_when]:n.show_when=Array.isArray(n.show_when)?[...n.show_when,t]:[n.show_when,t]:n.show_when=t,n},Ic=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},It=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},_c=e=>typeof e=="number"&&e>=0,pr=(e,t,n)=>{const s=e[0];if(e.length===1)return t[s]||null;const r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return _c(o)?(e.shift(),pr(e,t[s][o],n)):null},Ue=(e,t)=>{const n=e.split(".");return pr(n,t,t)},Er=(e,t,n,s=[],r={})=>{const o=Ue(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=mt.v4(),a={...i,...r,id:l};s.forEach(u=>delete a[u]);const c=o.findIndex(u=>u.id===n)+1;return c===-1?o.push(a):o.splice(c,0,a),t[`${e.split(".").pop()}ActiveId`]=a.id,l},Pc=(e,t)=>{const n=It(e,t);return Er(e,t,n)},xc=e=>typeof e=="number"&&e>=0,Ar=(e,t,n)=>{const s=e[0],r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return xc(o)?e.length===1?o:(e.shift(),Ar(e,t[s][o],n)):null},yr=(e,t)=>{const n=e.split(".");return Ar(n,t,t)},Nc=e=>({id:e.id,name:e.name,...e.collection.show_when&&{show_when:e.collection.show_when},orderInForm:e.orderInForm,deleteCollectionWhenHidden:e.deleteCollectionWhenHidden,collection:{masterPage:!0,...e.collection},formData:{...e.formData},childPages:[e]}),Oc=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},Rc=(e,t)=>{const n=e.collection.name.split(".");if(n.length===1)return!1;n.pop();const s=n.join("."),r=t[s]||null;return r?(r.childPages.push(e),r.childPages.sort((o,i)=>o.orderInForm-i.orderInForm),!0):!1},Tr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=Nc(s);return t[s.collection.name]=o,o}return Oc(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&Rc(s,t)?null:s).filter(s=>!!s)},vc=(e,t,n)=>{const s=Ue(e,t);if(!s)return null;const r=s.findIndex(l=>l.id===n);if(r===-1)return null;const o=s[r];s.splice(r,1);const i=t;return i[`${e}ActiveId`]=s.length>0?s[0].id:null,o},Lc=e=>typeof e=="number"&&e>=0,yn=(e,t,n)=>{const s=e.split("."),r=s[s.length-1];let o=n;s.some(i=>{if(o[i]||(o[i]=[]),!o[i].find(c=>c.id===n[`${i}ActiveId`])){const c=mt.v4();n[`${i}ActiveId`]=n[`${i}ActiveId`]||c,o[i].push({id:n[`${i}ActiveId`]})}if(i===r)return o[r]=t,!0;const l=n[`${i}ActiveId`],a=o[i]?.findIndex(c=>c.id===l);return Lc(a)?(o=o[i][a],!1):!0})},dt={addEntry:Ic,duplicateActiveEntry:Pc,duplicateEntry:Er,getActiveId:It,getActiveIndex:yr,getData:Ue,getErrorsForCollection:dn,mergePages:Tr,removeEntry:vc,setData:yn},Dc=e=>typeof e=="number"&&e>=0,Fc=(e,t,n,s,r,o)=>{const i=r?.label||ve.remove;return{pageId:e.id,fieldId:`delete${s}`,key:`delete${s}`,type:"action",action:{onAction:()=>{n(null,a=>{const c=a;if(!o)return c;Object.entries(o).forEach(f=>{const[y,h]=f;c[y]=h});const u=dt.getData(e.collection.name,c),m=u?.findIndex(f=>f.id===t.id);return Dc(m)&&u.splice(m,1),c})},label:T.Utils.interpolateString(i,{...t,index:s})}}},jc=(e,t,n,s,r,o={})=>{const i=r?.label||ve.change;return{pageId:e.id,fieldId:`change${s}${r.page}`,key:`change${s}${r.page}`,type:"action",action:{onAction:l=>{const a=c=>{const u=c;return Object.entries(o).forEach(m=>{const[f,y]=m;u[f]=y}),u};n(r.page?{pageId:r.page}:l,a)},label:T.Utils.interpolateString(i,{...t,index:s})}}},Uc=(e,t)=>t.show_when?xe(t.show_when,e):!0,Mc=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:b.CONTAINER,required:!0,full_path:s,components:e.components.map(r=>({...r,label:T.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),kc=(e,t,n,s,r)=>{const o={...ve,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${r}.Title`,key:T.Utils.interpolateString(o.item,{...t,index:s}),type:"heading",size:e.collection.titleSize||"s"}},$c=(e,t,n,s,r)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:T.Utils.interpolateString(e.text,r),type:s===null?"heading":"headingWithAction",size:e.size||"s",action:s===null?null:{onAction:s,label:"Change"}},Bc=(e,t,n,s)=>({pageId:e.id,fieldId:`${e.collection.name}Title`,full_path:`${e.collection.name}Title`,key:n?.text||t.charAt(0).toUpperCase()+t.slice(1),type:s==null?"heading":"headingWithAction",size:n?.size||"m",action:s===null?null:{onAction:s,label:"Change"}}),Yc=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>Uc(r,i)).map(i=>i.type==="remove"?Fc(e,t,n,s,i,o):i.type==="change"?jc(e,t,n,s,i,o):null).filter(i=>!!i),Sr=(e,t,n={})=>()=>{const s=r=>{const o=r;return Object.entries(n).forEach(i=>{const[l,a]=i;o[l]=a}),o};t({pageId:e.id},s)},Hc=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Cr(c,n,s,t,i));else if(c.collection.route&&(c=wc(c,c.collection.route)||c),mr(c,{...c.formData,...t})){const u=Sr(c,n,i);if(c.collection.heading){const y=c.collection.heading.changeLink?u:null,h=$c(c.collection.heading,c.id,r,y,t);l=l.concat(h)}const m=Mc(c,t,r,o),f=je({...c,formData:{...c.formData,...t}},m,{...c.formData,...t},u,s);l=l.concat(f)}}),l},Cr=(e,t,n,s,r={})=>{const o=e.collection.name.split(".").pop();let i=s[o]||null;const l=s[`${o}ActiveId`];if(!i||i.length===0)return[];let a=[];if(!e.collection.hideNameFromCYA){const f=e.collection.collectionHeading?.changeLinkPage?Sr({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(Bc(e,o,e.collection.collectionHeading,f))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?xe(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?xe(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((y,h)=>(c=h,y.id===l))]),i.forEach(f=>{if(!f)return;r={...r,[`${o}ActiveId`]:f.id};const y=c+1,h=e.collection?.actionPosition||"top",p=`${e.collection.name}[${c}]`,A=Yc(e,f,t,y,s,r);if(!u){const w=kc(e,f,e.id,y,p);a=a.concat(w)}h==="top"&&(a=a.concat(A)),a=a.concat(Hc(e.childPages,f,t,n,y,p,r)),h==="bottom"&&(a=a.concat(A)),c+=1}),a.filter(f=>!!f)},Vc=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Fe,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,qc=(e,t)=>{let n=-1;return{value:d.jsx(d.Fragment,{children:e.components.map(r=>{const o=t.findIndex(i=>i.id===r);return n<0&&(n=o),o>-1?Vc(t[o]):null})}),firstComponentIndex:n}},Gc=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=qc(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:gt(!1,e,s)},insertAt:o}},Kc=(e,t,n=null)=>{if(Je.showCYA(e,e.formData)){if(e.collection)return Cr(e,t,n,e.formData);const r=He(e.components,e.formData).filter(o=>ut(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case b.CONTAINER:return je(e,o,e.formData[o.fieldId],t,n);case b.COLLECTION:return An(e,o,e.formData[o.fieldId],t,n);default:return wt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=Gc(e,i,r,t);a>-1?r.splice(a,0,l):r.push(l)});const o=e.groups.flatMap(i=>i.components);return r.filter(i=>!o.includes(i.id))}return r}return[]},Wc={getRows:Kc,getCYARowsForContainer:je},gr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},br=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=gr(e.format,s[e.fieldId]))},wr=(e,t,n)=>{e.forEach(s=>br(s,t,n))},Ir=(e,t,n)=>{wr(e.components,t,n)},zc=(e,t,n)=>{e.forEach(s=>Ir(s,t,n))},Jc=(e,t,n)=>{const s={...t};return wr(e.components,s,n),zc(e.pages,s,n),s},Xc={component:br,data:gr,form:Jc,page:Ir},Qc=(e,t,n,s)=>{if(e===Z.HUB&&t){if(t.format===he.CYA)return he.CYA;if(t.components)return Je.get(t,n,s)}if(e===Z.TASK||e===Z.FORM_WITH_TASK)return he.TASK},Zc={get:Qc},Tn="meta",Sn="documents",Xt=e=>e?.[Tn]?.[Sn]||[],eu=(e,t,n,s)=>{const r=s?Xt(t):Xt(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Tn]:void 0,[Sn]:r}},tu={setForField:eu,get:Xt,name:Sn},nu={documents:tu,name:Tn},su=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return!!ee(t,n)}return!1},jt=(e,t)=>{if(e?.value)return e.value;const n=T.Utils.interpolateString(e?.field,t);return ee(t,n)},ru=(e,t)=>{if(!e||!t)return null;const n=T.Utils.interpolateString(e.target,t),s=ee(t,n),r=jt(e,t),o=jt(e.cutoff,t),i=jt(e.ignore,t);let l=null;return s&&r&&Array.isArray(s)&&s.every((a,c)=>c===o?!1:c===i?!0:a===r||e.key&&ee(a,e.key)===r?(l=c,!1):!0),typeof l=="number"?l.toString():l},ou=(e,t,n)=>{let s;if(e?.field){const r=T.Utils.interpolateString(e.field,t);s=ee(t,r)}else s=e?.value;s!=null&&e.name&&t[e.name]!==s&&n({target:{name:e.name,value:s}})},iu=(e,t)=>{if(e?.field){const n=T.Utils.interpolateString(e.field,t);return ee(t,n)||null}return e?.value||null},lu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},au=(e,t)=>{if(e?.condition){const n=e,s=T.Utils.interpolateString(n.field,t),r=ee(t,s);switch(n.condition){case"changes":{const o=`${s}LastValue`,i=n[o]||null;return i===null?(n[o]=r,!1):r!==i?(n[o]=r,!0):!1}case"isTruthy":return!!r;case"isFalsy":return!r;default:return!1}}return!0},cu=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=T.Utils.interpolateString(s,t),o=ee(t,r);return o?(n=o,!0):!1}),n||(e.fallback?T.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},uu=(e,t)=>{if(!e||!t)return null;const n=e.target.split(".");let s="";n.forEach(i=>{if(s!==""&&(s+="."),i.slice(-2)==="[]"){const l=i.slice(0,-2),a=yr(l,t);s+=`${l}[${a}]`}else s+=i});const r=T.Utils.interpolateString(s,t);return ee(t,r)?.length||0},du=(e,t)=>{const n=T.Utils.interpolateString(e.target,t),s=ee(t,n);return s&&Array.isArray(s)?s.some(r=>e.key?ee(r,e.key)===e.value:r===e.value):s&&typeof s=="object"?ee(s,e.key)===e.value:!1},fu={checkValueIsTruthy:su,getIndexOfMatchingValueIn:ru,doesContainValue:du,persistValueInFormData:ou,setValueInFormData:iu,deleteValueInFormData:lu,getLength:uu,getFirstOf:cu},hu=(e,t,n)=>{const s=fu[e.function];if(typeof s=="function")return s(e,t,n)},mu=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(au(s.run_when,t)){const r=hu(s,t,n);if(s.output){const o=T.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");ws(t,o,r)}}}),t),pu={runPageOperations:mu},Eu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),Au=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},yu=e=>/^-?\d+$/.test(e),ft=e=>yu(e)?e.padStart(2,"0"):"",ye=e=>{const[t,n,s]=e.split("-");return`${ft(t)}-${ft(n)}-${s}`},_r=e=>{const[t,n]=e.split(":");return`${ft(t)}:${ft(n)}`},Ee="DD-MM-YYYY";q.extend(Re);const Tu=(e,t)=>{const n=t.date?q(ye(t.date),Ee):q().add(t.value,t.unit);return q(ye(e),Ee).isAfter(n)};q.extend(Re);const Su=(e,t)=>{const n=t.date?q(ye(t.date),Ee):q().add(t.value,t.unit);return q(ye(e),Ee).isBefore(n)};q.extend(Re);const Cu=(e,t,n)=>{const s=n.components?.find(c=>c.fieldId===t.date),r=n.components?.find(c=>c.fieldId===t.time);if(!s||!r||!e)return!1;const o=e[n.fieldId]?.[t.date],i=e[n.fieldId]?.[t.time];if(!o||!i||Be(s,e[n.fieldId],e[n.fieldId])||Be(r,e[n.fieldId],e[n.fieldId]))return!0;const l=ye(e[n.fieldId]?.[t.date]),a=_r(e[n.fieldId]?.[t.time]);return q(`${l} ${a}`,`${Ee} HH:mm`).isBefore(q())};q.extend(Re);q.extend(tn);const gu=(e,t)=>{const n=q(ye(e),Ee).isBefore(q()),s=q(ye(e),Ee).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};q.extend(Re);q.extend(tn);const bu=(e,t)=>q(ye(e),Ee).isAfter(q())?!0:!!t?.todayAllowed&&q(ye(e),Ee).isToday(),wu=(e,t)=>e?e.length>t.value:!0,Iu=(e,t)=>e?e.length<t.value:!0,_u=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},Pu=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},xu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,Nu=(e,t)=>e?t.array.includes(e):!0,Ou=(e,t,n,s)=>{if(!e||!s)return!0;const r=It(t.collectionPath,s);return!Ue(t.collectionPath,s)?.some(l=>l.id===r?!1:t.caseInsensitive&&typeof e=="string"&&typeof l[n.id]=="string"?l[n.id].toUpperCase()===e.toUpperCase():l[n.id]===e)},Ru=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),vu=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,Lu=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,Du=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!Lu.test(t)}return!1},Fu=(e,t,n)=>n.components?.reduce((r,o)=>e[n.id]?.[o.id]?Array.isArray(e[n.id][o.id])&&e[n.id][o.id].length===0?r:r+1:r,0)<2,ju={conditionallyPermittedChange:Eu,conditionallyRequired:Au,mustBeAfter:Tu,mustBeBefore:Su,mustBeEarlierDateTime:Cu,mustBeGreaterThan:_u,mustBeInTheFuture:bu,mustBeInThePast:gu,mustBeLessThan:Pu,mustBeLongerThan:wu,mustBeNumbersOnly:xu,mustBeOneOf:Nu,mustBeShorterThan:Iu,mustBeUniqueInCollection:Ou,mustEnterAtLeastOne:Ru,mustHaveLessThanDecimalPlaces:vu,mustNotContainSql:Du,mustSelectOnlyOne:Fu},Uu=(e,t,n,s)=>{const r=ju[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Pr=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=Uu(t,r,e,n))}),s}},ht=(e,t,n)=>{if(!e)return[];const s=n||t,r=Pr(e,s);if(r)return{id:e.id,error:r};const o=[];if(Array.isArray(e.components)){const i=t&&e.fieldId?t[e.fieldId]:t;He(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(Be({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},Mu=(e,t,n)=>{const s=[];return e&&Array.isArray(e.item)&&Array.isArray(t)&&t.forEach((r,o)=>{const i=(e.countOffset||0)+o+1,l=`${e.full_path||e.fieldId}[${o}]`,a={full_path:l,components:e.item.map(c=>{const u={...c,full_path:`${l}.${c.fieldId}`};return c.custom_errors&&Array.isArray(c.custom_errors)&&(u.custom_errors=c.custom_errors.map(m=>({...m,message:T.Utils.interpolateString(o===0&&m.firstOnlyMessage?m.firstOnlyMessage:m.message,{index:i})}))),u})};s.push(ht(a,r,n))}),s.filter(r=>!!r).flat()};q.extend(Re);q.extend(tn);q.extend(Wr);const ku=(e,t)=>e==="02"?q().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,xr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ye(e),[n,s,r]=t.split("-"),o=parseInt(n,10),i=parseInt(s,10),l=[],a=[];if(r.length===0?(l.push("year"),a.push("Date must include a year")):r.length!==4&&(l.push("year"),a.push("Year must be 4 numbers")),s.length===0?(l.push("month"),a.push("Date must include a month")):(i>12||i<1)&&(l.push("month"),a.push("Month must be between 1 and 12")),n.length===0)l.push("day"),a.push("Date must include a day");else{const c=ku(s,r);(o>c||o<1)&&(l.push("day"),a.push(`Day must be between 1 and ${c}`))}if(l.length>0){const c={};return l.includes("day")&&(c.day=!0),l.includes("month")&&(c.month=!0),l.includes("year")&&(c.year=!0),{message:l.length===1?a[0]:"Enter a valid date",propsInError:c}}return q(t,Ee).format(Ee)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},$u=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,Bu=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,Nr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&($u.test(e)||Bu.test(e)))return;if(Array.isArray(n)){const r=n.filter(o=>o.type==="format");if(r&&r.length>0&&r[0].message)return r[0].message}return`Enter ${s} in the correct format, like jane.doe@homeoffice.gov.uk`}},Yu="Invalid files must be deleted",Or=(e,t)=>{if(!e)return;let n=!1;if(e.every(s=>(n=s.error,!n)),n){if(Array.isArray(t)){const s=t.filter(r=>r.type==="invalidFile");if(s&&s.length>0&&s[0].message)return s[0].message}return Yu}},Rr=(e,t,n,s)=>{if(e){if(typeof e=="string"){if(new RegExp(n).test(e))return;if(Array.isArray(s)){const o=s.filter(i=>i.type==="pattern");if(o?.[0]?.message)return o[0].message}}return t?`${t} failed regex validation`:"Component failed regex validation"}},vr=(e,t,n)=>{let s=!1;if((e||e===!1||e===0)&&(s=!0,typeof e=="string"?s=e.trim().length>0:Array.isArray(e)&&(s=e.length>0)),!s){if(Array.isArray(n)){const o=n.filter(i=>i.type==="required");if(o&&o.length>0&&o[0].message)return o[0].message}return`${t||"Field"} is required`}},Lr=(e,t,n,s,r,o=1e3)=>{if(!n||!r&&!t)return;if(r&&!t||t.length>o){if(Array.isArray(s)){const l=s.filter(a=>a.type==="length");if(l&&l.length>0&&l[0].message)return l[0].message}return`${e} must be ${o} characters or less`}},Dr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=_r(e),[n,s]=t.split(":"),r=parseInt(n,10),o=parseInt(s,10),i=[],l=[];if(/^\d{0,2}:\d{0,2}$/.test(e)||(i.push("invalid"),l.push("Enter a valid time")),n.length===0?(i.push("hour"),l.push("Time must include a hour")):(r>23||r<0)&&(i.push("hour"),l.push("Hour must be between 0 and 23")),s.length===0?(i.push("minute"),l.push("Time must include a minute")):(o>59||o<0)&&(i.push("minute"),l.push("Minute must be between 0 and 59")),i.length>0){const c={};return i.includes("hour")&&(c.hour=!0),i.includes("minute")&&(c.minute=!0),i.includes("invalid")&&(c.invalid=!0),{message:i.length>1?"Enter a valid time":l[0],propsInError:c}}return{message:void 0,propsInError:void 0}},Hu=(e,t)=>e?.type==="or"?se.meetsOne(e.conditions,t):se.meetsAll(e.conditions,t),Be=(e,t,n)=>{const s=n||t;if(!Ce(e,{...s,...t}))return;if(e.type===b.CONTAINER)return ht(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===b.COLLECTION_SUMMARY&&(l=Ue(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!Hu(e.requiredOverrideConditions,s))&&(r=vr(l,e.label,e.custom_errors)),!r){switch(e.type){case b.COLLECTION:return Mu(e,l,s);case b.EMAIL:r=Nr(l,e.label,e.custom_errors);break;case b.DATE:case b.TIME:{const a=e.type===b.DATE?xr:Dr,{message:c,propsInError:u}=a(l);o=u,r=c;break}case b.CHECKBOXES:case b.RADIOS:{let a=[];if(e.data.options?.forEach(c=>{c.nested&&Ye(n[e.id],c)&&(a=a.concat(ht({components:c.nested},n)))}),a.length>0)return a;break}case b.MULTI_FILE:r=Or(l,e.custom_errors);break;case b.TEXT_AREA:r=Lr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=Rr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Pr(e,l,n),e.type===b.DATE&&r&&(o={day:!0,month:!0,year:!0}))}if(r)return{id:e.full_path||e.id,error:r,properties:o}},Vu=(e,t=[])=>{let n=e.formData;if(e.collection){const s=dt.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...dt.getData(e.collection.name,e.formData)?.[s]})}return Ct(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!Ce(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(Be(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:T.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},qu={component:Be,container:ht,email:Nr,date:xr,multifile:Or,page:Vu,regex:Rr,required:vr,textarea:Lr,time:Dr},g={CheckYourAnswers:Wc,CollectionPage:dt,Component:ze,Condition:se,Container:St,Data:le,Format:Xc,FormPage:Je,Hub:Zc,Meta:nu,Operate:pu,Validate:qu,...T.Utils},Gu="hods-form-container",Cn=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:m})=>{if(typeof s=="function")if(m.name===g.Meta.name)s({target:m});else{const f={...t,[m.name]:m.value};s({target:{name:e.fieldId,value:f}})}},a=m=>{const f=`${e.full_path||e.fieldId}.${m.fieldId}`;return m.type===b.CONTAINER?g.Container.show({...m,full_path:f},n):g.Component.show({...m,full_path:f},{...n,...ee(n,e.full_path)})},c=g.classBuilder(Gu,[],e.className),u=T.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(T.MediumHeading,{children:e.title}),e.components&&e.components.filter(a).map((m,f)=>{const y=m.type===b.FILE?{}:"",h=t?t[m.fieldId]:y,p=`${e.full_path||e.fieldId}.${m.fieldId}`;return d.jsx(Fe,{...i,component:{...m,full_path:p,readonly:!!(e.readonly||m.readonly)},formData:n,value:h||y,wrap:r,onChange:l,onTopLevelChange:o},f)})]})},Ku=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,"action")){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},ns=({group:e})=>{const[t,n]=O.useState({});return O.useEffect(()=>{n(Ku(e))},[e,n]),e?.action?d.jsxs(T.Link,{...t,"aria-label":`${e.action.label} ${e.action.aria_suffix}`,children:[e.action.label,e.action.aria_suffix&&d.jsxs("span",{className:"mobile-text govuk-link",children:[" ",`${e.action.aria_suffix}`]})]}):null},Wu=({title:e,size:t="m",classes:n})=>d.jsxs("div",{className:`${n("heading")}`,role:"listitem",children:[t==="s"&&d.jsx(T.SmallHeading,{children:e}),t==="m"&&d.jsx(T.MediumHeading,{children:e})]}),zu=({row:e,classes:t,noChangeAction:n=!1})=>d.jsxs("div",{className:t("headingWithAction"),role:"listitem",children:[d.jsxs("td",{className:"heading-text",colSpan:"2",children:[e.size==="s"&&d.jsx(T.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(T.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(En,{row:{action:e.action}})})]}),Ju="govuk-summary-list",Qt=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=Ju,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=T.Utils.classBuilder(r,o,i),u=T.Utils.cleanHtmlAttributes(a);let m=null;if(s){const f=e.filter(y=>!!y.action);m=f?.length?f[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(f=>{const y=`${f.pageId}_${f.full_path||f.fieldId}`;return f.type==="title"?d.jsx(or,{title:f.key,classes:c},y):f.type==="heading"?d.jsx(Wu,{title:f.key,size:f.size||"s",classes:c},y):f.type==="headingWithAction"?d.jsx(zu,{row:f,classes:c,noChangeAction:t},y):f.type==="action"?t?null:d.jsx("div",{children:d.jsx(ns,{group:f})},`${y}-actions`):d.jsx(rr,{row:f,classes:c,showAction:!t},y)}).filter(f=>!!f),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(ns,{group:m})})]})})},Xu="hods-check-your-answers",Qu="Check your answers",ss=9,Zu=({title:e=Qu,titleSize:t="l",pages:n,actions:s=[],onAction:r,onRowAction:o,hide_page_titles:i=!1,hide_actions:l=!1,hide_title:a=!1,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:m,groups:f,sections:y=[],type:h,hideBlankRows:p=!1,optionalFieldPlaceholder:A})=>{const[w,L]=O.useState([]),[C,I]=O.useState([]),{errors:_}=De(),{hooks:U}=ge();O.useEffect(()=>{const N=(Y,H)=>g.CheckYourAnswers.getRows(Y,o,U.onGetCYARows).map((K,J)=>({...K,value:d.jsx(fn,{value:K.value,component:K.component,formData:Y.formData,placeholder:A},`${H}_${J}`)})),M=g.CollectionPage.mergePages(n).map((Y,H)=>{const V=N(Y,H);return V?.length?{...Y,rows:V}:null}).filter(Y=>!!Y);L(M)},[n,o,L]);const S=i?0:ss,R=N=>N===w.length-1;O.useEffect(()=>{(()=>{const j=Array.isArray(f)?f.map(M=>M.pageId):[];I(j)})()},[I,f]);const v=U.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:m,groups:f,errors:_,sections:y,type:h});if(v)return v;const D=N=>C.includes(N),x=N=>f?.find(j=>j.pageId===N),k=(N,j)=>{if(!N.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(T.SmallHeading,{children:g.FormPage.getTitle(N.title,N.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:g.FormPage.getTitle(N.title,N.formData)})]});const M=gt(!1,N,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(T.SmallHeading,{children:g.FormPage.getTitle(N.title,N.formData)}),j==="m"&&d.jsx(T.MediumHeading,{children:g.FormPage.getTitle(N.title,N.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(En,{row:{action:M}})})]})},P=()=>Array.from(new Set(_.map(j=>j.id))).map(j=>_.find(M=>M.id===j));return d.jsxs("div",{className:Xu,children:[e&&!a&&d.jsx(T.Heading,{size:t,children:e},"heading"),_&&_.length>0&&d.jsx(T.ErrorSummary,{errors:P()}),h===Z.TASK_CYA&&w.length>0&&y&&y.map(N=>N.tasks.filter(j=>j.state!==B.TYPES.SKIPPED).map((j,M)=>{const Y=w.filter(H=>j.pages.some(V=>V===H.name));return d.jsxs(O.Fragment,{children:[d.jsx(T.MediumHeading,{children:Y.length>0&&(j.displayName||j.name)}),Y.map((H,V)=>{const K=D(H.id)||u,J=!i&&H.title&&!D(H.id);return d.jsxs(O.Fragment,{children:[J&&k(H,"s"),d.jsx(Qt,{rows:H.rows,classModifiers:c,noChangeAction:K,noGroupAction:m,isGroup:D(H.id)})]},V)})]},M)})),h!==Z.TASK_CYA&&w&&w.map((N,j,M)=>{const Y=!p||N.collection?N.rows:N.rows.filter(ae=>ae?.value?.props?.value);if(Y.length===0)return null;const H=!i&&N.title&&!D(N.id),V=R(j)||D(M[j].id)||M.length>j+1&&D(M[j+1].id)?ss:S,K=D(N.id)?x(N.id):void 0,J=`govuk-!-margin-bottom-${V}`,de=D(N.id)||u;return d.jsxs(O.Fragment,{children:[H&&k(N,"m"),K&&d.jsx("div",{className:"group-title",children:d.jsx(T.MediumHeading,{children:K.title||g.FormPage.getTitle(N.title,N.formData)})}),d.jsx(Qt,{className:J,rows:Y,classModifiers:c,noChangeAction:de,noGroupAction:m,isGroup:D(N.id)})]},j)}),!l&&d.jsx(mn,{actions:s?.filter(N=>g.Component.show(N,n[n.length-1].formData)),onAction:N=>r(N)})]})},ed=nr,td=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=ed,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=O.useState({});let m=g.CollectionPage.getData(e.collection.name,e.formData)||[];const f=e.collection.name.split(".").pop();let y=g.CollectionPage.getActiveIndex(e.collection.name,e.formData);const h=e,p=({target:_})=>{g.CollectionPage.setData(h.collection.name,_.value,e.formData),m=_.value;const U=e.collection.name.split(".").shift();u(S=>({...S,[U]:g.CollectionPage.getData(U,e.formData)}))},A=({target:_})=>{h.formData[_.name]=_.value,u(U=>({...U,[_.name]:_.value}))},w=_=>{p({target:{value:_}}),typeof n=="function"&&n(e.formData)},L=_=>{y=m.length,A({target:{name:`${f}ActiveId`,value:_}})},C=_=>{s(_,c,{})},I=({target:_})=>{if(y===null){const U=mt.v4();L(U),w([...m,{id:U,[_.name]:_.value}])}else w([...m.slice(0,y),{...m[y],[_.name]:_.value},...m.slice(y+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(pn,{page:{...e,formData:{...e.formData,...m[y],[`${f}ActiveIndex`]:y,[`${f}NumberedIndex`]:typeof y=="number"?y+1:null},components:e.components.map(_=>({..._,pageCollection:{...e.collection}}))},pages:t,onAction:C,onWrapperChange:I,onTopLevelChange:A,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},nd="hods-task-list",sd=({state:e=B.TYPES.CANNOT_START_YET})=>{const t=T.Utils.classBuilder(nd,void 0,void 0),n=B.DETAILS[e]||B.DETAILS.cannotStartYet;return d.jsx(T.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},rd="hods-task-list",od=({task:e,onClick:t})=>{const n=T.Utils.classBuilder(rd,void 0,void 0),[s,r]=O.useState(e.state!==B.TYPES.CANNOT_START_YET),[o,i]=O.useState(e.state);O.useEffect(()=>{r(e.state!==B.TYPES.CANNOT_START_YET),i(e.state)},[e.state,r,i]);const l=e.displayName||e.name;return d.jsxs("li",{className:n("item"),children:[d.jsx("span",{className:n("task-name"),children:s?d.jsx(T.Link,{onClick:()=>t(e),onKeyPress:a=>{a.key==="Enter"&&t(e)},tabIndex:0,children:l}):l}),d.jsx(sd,{state:o})]})},id="hods-task-list",ld="Incomplete form",ad=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=ld,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=id,classModifiers:u=[],className:m="",formData:f={},annotations:y=[],...h})=>{const p=T.Utils.classBuilder(c,u,m),A=T.Utils.cleanHtmlAttributes(h),[w,L]=i.filter(S=>!S.skipped).reduce((S,R)=>[S[0]+(R.tasks?.filter(v=>v.state===B.TYPES.COMPLETE).length??0),S[1]+(R.tasks?.filter(v=>v.state!==B.TYPES.SKIPPED).length??0)],[0,0]),C=`${e}Notes`,{title:I,text:_}=s&&s||{},U=S=>{typeof a=="function"&&a(S)};return d.jsxs("div",{...A,id:e,className:p(),children:[n&&t&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:`${t}`})}),d.jsx("p",{className:"govuk-body govuk-!-font-weight-regular",children:`${n}`})]}),y.length>0&&y.map(S=>d.jsxs("div",{className:p("annotation"),children:[d.jsx("p",{className:`${p("annotation-key")} govuk-body`,children:T.Utils.interpolateString(S.key,f)}),d.jsx("p",{className:`${p("annotation-value")} govuk-body`,children:T.Utils.interpolateString(S.value,f)})]},S.key)),o&&L!==w&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:r})}),o&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-7",children:`You have completed ${w} of ${L} sections`}),I&&_&&Ce(s,f)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:T.Utils.interpolateString(I,f)})}),d.jsx(T.TextArea,{id:C,fieldId:C,readOnly:!0,value:T.Utils.interpolateString(_,f)})]}),i.filter(S=>!S.skipped).map((S,R)=>d.jsxs(O.Fragment,{children:[d.jsxs("h2",{className:p("section"),children:[i.length>1?`${R+1}. `:" ",S.name]}),S.label&&d.jsx(T.Hint,{children:S.label}),d.jsx("ol",{className:p("items"),children:S.tasks.filter(v=>v.state!==B.TYPES.SKIPPED).map(v=>d.jsx(od,{task:v,onClick:U},`${S.name}-${v.name}`))})]},`${S.name}`))]})},Fr=(e,t)=>e?.page||t,cd=(e,t,n)=>{const s=Fr(e.action,e.pageId);s!==t&&n(s)},ud=(e,t,n,s=void 0)=>{const r=Fr(e,t);r!==t&&n(r,s)},dd=(e,t)=>{t(e)},pe={cyaAction:cd,navigate:ud,submissionError:dd},fd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,hd=(e,t)=>t(e).length===0,md=["radios","checkboxes"],pd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Ed(e,t){const n=[];return e?.data?.options?.forEach(s=>{!Ye(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const jr=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!md.includes(s.type))return;Ed(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...pd(t.collection.name,t.formData),...n};const s=Ue(t.collection.name,n);if(s){const r=It(t.collection.name,n),o=s.map(i=>i.id===r?jr(i,{...t,collection:void 0}):i);yn(t.collection.name,o,n)}}return n},Ad=(e,t,n)=>{if(e===te.HUB&&n===he.CYA)return{title:""};if(e===te.CYA)return{};const s=t?.find(r=>r.id===e);if(s?.type===te.PARTIAL_CYA){const r=g.FormPage.applyConditionalProperties(s);return{title:r.title,hideChangeActions:r.hideChangeActions,hideGroupActions:r.hideGroupActions}}},Ur=(e,t,n)=>{if(e)return e===te.HUB?n===he.CYA||n===he.TASK?void 0:n:t.find(s=>s.id===e)},yd=(e,t,n)=>({pageId:e,cya:Ad(e,t,n),page:Ur(e,t,n)}),rs=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),Td=(e,t,n)=>e.page?.type===te.PARTIAL_CYA?rs(n||t,e.pageId):n||t,os=(e,t,n,s,r)=>{if(!t&&r===Z.FORM_WITH_TASK){if(s?.formStatus?.taskPage){const i=n.find(l=>l.id===s.formStatus.taskPage);return i?.type==="pre-task-list"?i.id:te.HUB}return n.length>0?n[0].id:void 0}let o;return e?.pages?.forEach(i=>{Je.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||te.HUB},Mr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!Je.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Sd=(e,t,n)=>Mr(e,t,n)||te.CYA,Cd=e=>e.length>0?e[0].id:void 0,Zt=(e,t,n,s,r)=>{if(s){if(s.type===G.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===G.TYPES.SAVE_AND_RETURN)return e===Z.HUB?te.HUB:void 0}switch(e){case Z.HUB:return os(s);case Z.CYA:return Sd(t,n,r);case Z.FORM_WITH_TASK:case Z.TASK:return os(s,n,t,r,e);case Z.WIZARD:return Mr(t,n,r);default:return Cd(t)}},gd=(e,t,n,s,r,o,i,l)=>{if(e===Z.TASK||e===Z.FORM_WITH_TASK){const a=r.formStatus||{};return a.tasks=a.tasks||{},a.tasks[o.name]=a.tasks[o.name]||{},n===(te.CYA||"submitForm")&&i?a.tasks[o.name].complete=!0:o.name?s?.type===G.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:Zt(e,t,n,s,r)}:o.pages?.includes(n)&&(a.tasks[o.name]={complete:!!s?.complete,currentPage:n}):l&&l.forEach(c=>{c.tasks.forEach(u=>{const m=u.pages[u.pages.length-1];(m===n||m.id===n)&&i&&u?.type==="pre-task-list"?a.tasks[u.name]={complete:i,currentPage:n}:u.pages.includes(n)&&u?.type==="pre-task-list"&&(a.tasks[u.name]={complete:!1,currentPage:n})})}),a.taskPage=a.tasks[o.name].currentPage,a}return s?.type===G.TYPES.SAVE_AND_RETURN?{page:n}:{page:Zt(e,t,n,s,r)}},bd=({complete:e,currentPage:t},n=B.TYPES.NOT_STARTED)=>e?B.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?B.TYPES.IN_PROGRESS:n,wd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===B.TYPES.SKIPPED?s:s&&o?.complete},!0),kr=(e,t)=>{const n=e[t-1].state;return n===B.TYPES.COMPLETE?!0:n===B.TYPES.SKIPPED?t-1===0?!0:kr(e,t-1):!1},Id=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return bd(s[e.name],e.state);if(r)return e.depends_on&&!wd(s,e.depends_on,e.ignoreSkipped)?B.TYPES.CANNOT_START_YET:B.TYPES.NOT_STARTED;let i=o;return t&&(i=kr(n,t)),i?B.TYPES.NOT_STARTED:B.TYPES.CANNOT_START_YET},_d=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==B.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Id(l,i,r,t,n,s)}),r},$r=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===B.TYPES.COMPLETE?!0:n===B.TYPES.SKIPPED?t-1===0?!0:$r(e,t-1):!1},Pd=(e,t,n=!1,s=null)=>{const r=e.map(i=>{const l=i.show_when?[i.show_when].flat():[];return s&&!g.Condition.meetsAll(l,s)?{...i,skipped:!0,tasks:i.tasks.map(a=>({...a,state:B.TYPES.SKIPPED}))}:{...i}});r.forEach(i=>{const l=i;l.tasks=l.tasks.map(a=>{const c=a.show_when?[a.show_when].flat():[];return s&&!g.Condition.meetsAll(c,s)?{...a,state:B.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===B.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:B.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||$r(r,l);a.tasks=_d(a,o,n,c)}),r},xd=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},Oe=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)Oe(e[r],t);const n=t.split(".");let s=e;for(let r=0;r<n.length-1;r+=1)if(s=s[n[r]],s===void 0)return;s[n[n.length-1]]&&delete s[n[n.length-1]]},Br=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},gn=(e,t)=>{const n=Br(e);return n?`${n}.${t}`:t},Nd=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];Object.keys(n).length===1&&Object.keys(n)[0]==="id"&&e.splice(t,1)}},Od=e=>{const t=(n,s)=>(typeof n=="object"&&n!==null&&(Array.isArray(n)?n.forEach(r=>{t(r,s)}):Object.keys(n).forEach(r=>{r==="field"&&s.push(n[r]),t(n[r],s)})),s);return e.show_when?new Set(t(e.show_when,[])||[]):null},Rd=(e,t)=>{const n=e.split(".");for(let s=n.length;s>0;s-=1){const r=n.slice(0,s).join("."),o=t.get(r);if(o)return o}return null},ke=(e,t)=>e.show_when?e.show_when?.type==="or"?se.meetsOne(e,t):se.meetsAll(e,t):!0,Yr=(e,t,n)=>{const s=t.get(e.use)??n.get(e.use)??e,r=JSON.parse(JSON.stringify(s));return e.use&&e.show_when&&(r.show_when=e.show_when),r},vd=(e,t,n)=>{const{meta:{documents:s}}=n,r=t[e.fieldId];if(!s||!r)return;const o=Array.isArray(r)?r:[r];for(let i=o.length-1;i>=0;i-=1){const l=s.findIndex(a=>a.url===o[i].url);l!==-1&&s.splice(l,1)}},en=e=>{if(Array.isArray(e))for(let t=e.length-1;t>=0;t-=1)Array.isArray(e[t])&&e[t].length===0?e.splice(t,1):en(e[t]),typeof e[t]=="object"&&Object.keys(e[t]).length===0&&e.splice(t,1);else e!==null&&typeof e=="object"&&Object.keys(e).forEach(t=>{Array.isArray(e[t])&&e[t].length===0?(e[`${t}ActiveId`]&&delete e[`${t}ActiveId`],delete e[`${t}ActiveId`],e[t]&&delete e[t]):en(e[t])})},Hr=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},Ld=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;Oe(e,t),Hr(n,r=>{const o=gn(t,r.fieldId);s[o]>1?s[o]-=1:Oe(e,o)})}},Dd=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&vd(r,n,s),r.preserveInPayload)return;Oe(n,r.fieldId),Hr(r,o=>{const i=gn(r.fieldId,o.fieldId);e.has(i)||Oe(n,i)})}})},is=e=>Array.isArray(e)?e:[e],Fd=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,m)=>{u.fieldId&&(m=m?`${m}.${u.fieldId}`:u.fieldId,o[m]=(o[m]||0)+1,u.path=m,c.show_when&&(u.show_when=u.show_when?[...is(c.show_when),...is(u.show_when)]:c.show_when),xd(m,u,r),u.components?u.components.forEach(f=>{a(c,f,m)}):u?.data?.options&&u?.data?.options?.forEach(f=>{if(f.nested){const y=!Ye(ee(s,m),f),h=f.show_when;f.nested.forEach(p=>{y&&i.push(gn(m,p.fieldId)),h&&(p.show_when=h),a(c,p,Br(m))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const m=Yr(u,t,n);a(c,m,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:Oe(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},jd=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=Od(s);if(r)if(t.has(s.path)){const o=t.get(s.path);r.forEach(i=>o.add(i))}else t.set(s.path,new Set(r))})}),t},Ud=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(f=>{const y=Rd(f,t);if(y)y.forEach(h=>{a.has(h)||i(a,h,u)});else{const h=/([a-zA-Z_$][\w$]*)\[\d+\]/,p=f.match(h);if(p){const A=p[1],w=s.get(A);w&&w.childPages?.forEach(L=>{if(L.show_when){const C=JSON.stringify(L.show_when),I=`It is not possible to reliably clean hidden data when a component is dependent on a
|
|
10
10
|
collection's data, and that collection is itself dependent on data elsewhere in the form.
|
|
11
11
|
The dependency path is ${f}, and the chained show_when is ${C}.
|
|
12
|
-
The form will need to be changed to break this chained dependency`;throw new Error(I)}})}}}),ke(c,o)||Ld(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(m=>{l.has(m)||i(l,m,e)})})},Md=(e,t,n,s)=>{e?.forEach((r,o)=>{ke(r,t)||(delete t[o],delete t[`${o}ActiveId`]);const i=t[o];i?.forEach(l=>{const a={...t,...l},c=new Set,u=new Map;r.childPages?.forEach(m=>{const f=ke(m,a);m.components?.forEach(y=>{const h=Yr(y,n,s);if(!h.fieldId)return;const p=ke(y,a);f&&p&&ke(h,a)?c.add(h.fieldId):u.set(h.id,h)})}),Dd(c,u,l,t)}),i&&Nd(i)})},kd=(e,t,n)=>{if(!e)return n;const s=new Map(t.components.map(u=>[u.id,u])),r=new Map(t.components.map(u=>[u.fieldId,u])),o=Tr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=Fd(o,s,r,n),c=jd(i);return Ud(c,i,l,a,t,n),Md(a,n,s,r),en(n),n},W={canActionProceed:fd,canCYASubmit:hd,cleanHiddenNestedData:jr,getFormState:yd,getRelevantPages:Td,getNextPageId:Zt,getPage:Ur,getSubmissionStatus:gd,getUpdatedSectionStates:Pd,clearOutUncompletedRoutes:kd},$d=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w)=>{if(t.type===G.TYPES.SUBMIT&&y!==he.TASK){if(e("submit"),W.canCYASubmit(n,s.pages)&&!A){w(!0);const L=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),C={pages:n,components:o};W.clearOutUncompletedRoutes(r,C,L),L.formStatus=W.getSubmissionStatus(a,n,c,t,L,u,!0),l(L),m.onSubmit(t.type,L,()=>{m.onFormComplete(),w(!1)},I=>{w(!1),pe.submissionError(I,f)})}}else{const C=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?W.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===G.TYPES.SAVE_AND_CONTINUE&&y===he.TASK&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(te.HUB)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SUBMIT&&y===he.TASK&&(e("submit"),C)){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),_={pages:n,components:o};W.clearOutUncompletedRoutes(r,_,I),I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{m.onFormComplete(),w(!1)},U=>{w(!1),pe.submissionError(U,f)})}if(t.type===G.TYPES.SAVE_AND_NAVIGATE&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(t.page)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SAVE_AND_RETURN&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!1),l(I),m.onSubmit(t.type,I,()=>{a===Z.TASK?h(void 0):h(te.HUB),w(!1)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.NAVIGATE&&(h(W.getNextPageId(a,n,c,t,p.page?.formData)),w(!1)),t.type===G.TYPES.CANCEL){const I=g.Format.form({pages:n,components:o},{...i},Te.CANCEL);m.onCancel(I),w(!1)}}},ls=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w,L,C,I,_)=>{const U={...r},S=o,R=s.onAction(S.page.formData,t,r,e.customAction);S.page.formData=R.formData;let v=R.patch;if(S.page.formData={...S.page.formData,...v},e.type===G.TYPES.CANCEL){s.onCancel(S.page.formData),I(!1);return}if(W.canActionProceed(e,S.page,i.page,_)&&(!C||e.ignoreSubmittingFlag))if(v=W.cleanHiddenNestedData(v,S.page),I(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(x=>{x.isCollection?yn(x.field,x.value,o.page.formData):g.Data.setDataItem(o.page.formData,x.field,x.value)}),S.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===G.TYPES.NAVIGATE)pe.navigate(e,f,l),I(!1);else{let D=V=>l(W.getNextPageId(a,u,f,e,V)),x,k;e.collection&&(x=e.collection,k=`addAnother${x.charAt(0).toUpperCase()+x.slice(1)}`.slice(0,-1));let P,N;switch(x&&(P=S.page.formData[x],P&&P.length>0&&S.page.formData[`${x}ActiveId`]&&(N=P.findIndex(V=>V.id===S.page.formData[`${x}ActiveId`]))),e.type){case G.TYPES.SUBMIT:y("submit");break;case G.TYPES.SAVE_AND_NAVIGATE:const V={...h};P&&P.length>0&&e.resetActiveId&&(S.page.formData[`${x}ActiveId`]=P[0].id),P&&P.length>0&&!e.resetActiveId&&(N!==void 0&&N+1<S.page.formData[x].length&&(S.page.formData[k]="Yes"),N!==void 0&&N+1===S.page.formData[x].length&&S.page.formData[k]&&(S.page.formData[k]="No")),D=()=>pe.navigate(e,f,l,V);break;case G.TYPES.COLLECTION_ADD:if(N===void 0||P.length===0||N+1===S.page.formData[x].length?g.CollectionPage.addEntry(e.collection,S.page.formData):S.page.formData[`${e.collection}ActiveId`]=P[N+1].id,S.page.formData[`${e.collection}`]&&S.page.formData[`${e.collection}`].length>0){const ae=S.page.formData[`${e.collection}`].length-1;Object.keys(S.page.formData[`${e.collection}`][ae]).filter(re=>re in S.page.formData&&re!=="id").forEach(re=>delete S.page.formData[re])}D=()=>pe.navigate(e,f,l);break;case G.TYPES.COLLECTION_DUPLICATE:g.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(D=()=>pe.navigate(e,f,l));break;case G.TYPES.COLLECTION_REMOVE:const K=e.targetId||S.page.formData[`${e.collection.split(".").pop()}ActiveId`],J=g.CollectionPage.removeEntry(e.collection,o.page.formData,K);e.recordRemoval&&(S.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...J});const de=S.page.formData.id;J!==null&&Object.keys(J).filter(fe=>fe in S.page.formData).forEach(fe=>delete S.page.formData[fe]),Object.assign(S.page.formData,P[P.length-1]),S.page.formData.id=de,P.length>0?S.page.formData[`${e.collection}ActiveId`]=P[P.length-1].id:(delete S.page.formData[`${e.collection}ActiveId`],delete S.page.formData[e.collection]),D=()=>pe.navigate(e,f,l);break}g.Data.deleteValues(r,o.page.formData);const j=g.Format.form({pages:u,components:m},{...r,...t,...o.page.formData},Te.SUBMIT);j.formStatus=W.getSubmissionStatus(a,u,f,e,j,h,!0,A?.sections),v&&p(j);const M={pages:u,components:m};e.type===G.TYPES.SUBMIT&&W.clearOutUncompletedRoutes(c,M,j);let Y,H;a===Z.HUB&&Object.keys(n).length>0&&(Y=Object.keys(n)[0],H=Object.values(n)[0]),s.onSubmit(e.type,j,V=>{const K={...j,...V};w({data:K}),D(K),I(!1)},(V,K=!0)=>{pe.submissionError(V,L),K&&p({...U}),I(!1)},Y,H,f)}},as=(e,t,n,s,r,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(a=>{i.fullPages.push(W.getPage(a,t))}),n(e);const l={...i};if(i.state===B.TYPES.COMPLETE&&!i.alwaysShowFirstPage)if(s?.noTaskCYAs){const a=r.formStatus.tasks[e.name].currentPage;o(i.pages[0]||a)}else i.customCYA?o(i.customCYA):o(te.CYA,l);else if(i.state===B.TYPES.IN_PROGRESS&&!i.alwaysShowFirstPage){const a=r.formStatus.tasks[e.name].currentPage;o(a||e.pages[0],l)}else i.firstPage?o(i.firstPage,l):o(i.pages[0],l)}},Vr=({title:e,titleSize:t,type:n,cleanseHiddenData:s=!1,components:r,pages:o,hub:i={nonSequential:!1,sections:[]},cya:l={actions:[],disableTaskSwitch:!1},data:a,hashLink:c=!1,hooks:u,classBlock:m=Bd,classModifiers:f=[],className:y="",hide_title:h,summaryListClassModifiers:p=[],noChangeAction:A=!1,newPageId:w="",viewOnly:L=!0,hideBlankRows:C=!1})=>d.jsx(Qs,{overrides:u,children:d.jsx(Zs,{children:d.jsx(Yd,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:m,classModifiers:f,className:y,hashLink:c,hide_title:h,summaryListClassModifiers:p,noChangeAction:A,newPageId:w,viewOnly:L,hideBlankRows:C})})}),Bd="hods-form",Yd=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:m,hashLink:f,hide_title:y,summaryListClassModifiers:h,noChangeAction:p,newPageId:A,viewOnly:w,hideBlankRows:L})=>{const[C,I]=O.useState({}),[_,U]=O.useState(),[S,R]=O.useState([]),[v,D]=O.useState(void 0),[x,k]=O.useState(W.getNextPageId(n,o,null,null,a)),[P,N]=O.useState(W.getFormState(x,S,v)),[j,M]=O.useState({}),[Y,H]=O.useState({}),[V,K]=O.useState("load"),[J,de]=O.useState(!1),[ae,fe]=O.useState(!1),{hooks:re}=ge(),{addErrors:_t,clearErrors:bn,errors:wn,validate:Pt}=De();window.onpopstate=$=>{if(!document.location.hash&&($.state&&$.state.fullPages!==void 0&&M(X=>({...X,fullPages:$.state?.fullPages})),bn(),de(!0),re.onGoingBack($.state?$.state:null,...P.page.formData),r&&S&&C&&P.page?.formData&&V===void 0)){const X=g.Format.form({pages:S,components:r},{...C,...P.page.formData},Te.SUBMIT);if(X?.formStatus?.taskPage){const ne=X.formStatus.tasks;Object.keys(ne).forEach(Se=>{const Pn=ne[Se];Pn.currentPage&&!Pn.complete&&delete ne[Se].currentPage}),delete X.formStatus.taskPage}I(X)}},O.useEffect(()=>{r&&o&&a&&(V==="load"||w)&&(I(g.Data.setupForm(o,r,a)),a.formStatus?.page&&k(a.formStatus.page))},[r,o,a,I,V,w]),O.useEffect(()=>{R(g.FormPage.getAll(o,r,{...C}))},[r,o,C,R]),O.useEffect(()=>{k($=>$||W.getNextPageId(n,S))},[n,S,k]),O.useEffect(()=>{D(g.Hub.get(n,i,r,{...C}))},[n,i,C,r,D]),O.useEffect(()=>{n===Z.HUB&&J&&C&&P.page?.formData&&(P.page.formData={...C}),de(!1),N(W.getFormState(x,S,v))},[S,v,x,N,n,J,C,P.page]),O.useEffect(()=>{K(void 0),re.onFormLoad($=>{M($)})},[re]),O.useEffect(()=>{H(i)},[i]),O.useEffect(()=>{_?.data&&(I(_.data),U(void 0))},[_,I,U]);const xt=i?.sections,In=i?.nonSequential;O.useEffect(()=>{const $=j.fullPages;if($&&($.forEach(X=>{const ne=X;ne&&(ne.formData=C)}),M(X=>({...X,fullPages:$}))),xt){const X=C?.formStatus?.tasks||{},ne=W.getUpdatedSectionStates(xt,X,In,C);H(Se=>({...Se,sections:[...ne]}))}},[j.fullPages,C,xt,In]);const Pe=($,X={})=>{bn(),k($),re.onPageChange($,X)};O.useEffect(()=>{A!==void 0&&k(A)},[A]);const _n=$=>{re.onChange($)},qr=($,X)=>{if(typeof X=="function"){const ne=X({...C});ne&&I(ne)}P.page?.type===te.PARTIAL_CYA&&!l.disableTaskSwitch&&Y.sections.every(ne=>ne.tasks.every(Se=>Se.pages.includes($.pageId)&&Se.name!==j.name?(as(Se,S,M,Y,C,Pe),!1):!0)),$&&pe.cyaAction($,x,Pe)},Gr=g.classBuilder(c,u,m);if(v===he.TASK){const $=l;$.actions=[G.TYPES.SAVE_AND_CONTINUE,G.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:Hd,nonSequential:Vd,...Kr}=Y;return d.jsxs("div",{className:Gr(),children:[e&&!y&&x===te.HUB&&d.jsx(T.Heading,{size:t,children:e}),P.cya&&d.jsx(Zu,{pages:W.getRelevantPages(P,S,j.fullPages),...l,...P.page?.type===te.PARTIAL_CYA&&{actions:P.page.actions?.filter($=>g.Component.show($,C))},...P.cya,onAction:$=>{$d(K,$,S,Pt,s,r,C,I,n,x,j,re,_t,v,Pe,P,ae,fe)},onRowAction:qr,summaryListClassModifiers:h,hide_title:y,noChangeAction:P.cya.hideChangeActions??p,noGroupAction:P.cya.hideGroupActions??!1,sections:typeof Y<"u"?Y.sections:[],type:n,hideBlankRows:L}),v===he.TASK&&P.pageId===te.HUB&&d.jsx(ad,{...Kr,refNumber:C.businessKey,onTaskAction:$=>{as($,S,M,Y,C,Pe)},annotations:Y?.taskListAnnotations||[],formData:C}),P.page&&!P.cya&&!P.page.collection&&d.jsx(pn,{page:P.page,pages:[...S],onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},onChange:_n,hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae,pageId:x}),P.page&&!P.cya&&P.page.collection&&d.jsx(td,{page:P.page,pages:S,onCollectionChange:_n,onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae})]})};exports.Container=Cn;exports.FormComponent=Fe;exports.FormRenderer=Vr;exports.FormTypes=Z;exports.HooksContextProvider=Qs;exports.HubFormats=he;exports.Models=Mo;exports.PageActions=mn;exports.SummaryList=Qt;exports.Utils=g;exports.ValidationContextProvider=Zs;exports.default=Vr;
|
|
12
|
+
The form will need to be changed to break this chained dependency`;throw new Error(I)}})}}}),ke(c,o)||Ld(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(m=>{l.has(m)||i(l,m,e)})})},Md=(e,t,n,s)=>{e?.forEach((r,o)=>{ke(r,t)||(delete t[o],delete t[`${o}ActiveId`]);const i=t[o];i?.forEach(l=>{const a={...t,...l},c=new Set,u=new Map;r.childPages?.forEach(m=>{const f=ke(m,a);m.components?.forEach(y=>{const h=Yr(y,n,s);if(!h.fieldId)return;const p=ke(y,a);f&&p&&ke(h,a)?c.add(h.fieldId):u.set(h.id,h)})}),Dd(c,u,l,t)}),i&&Nd(i)})},kd=(e,t,n)=>{if(!e)return n;const s=new Map(t.components.map(u=>[u.id,u])),r=new Map(t.components.map(u=>[u.fieldId,u])),o=Tr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=Fd(o,s,r,n),c=jd(i);return Ud(c,i,l,a,t,n),Md(a,n,s,r),en(n),n},W={canActionProceed:fd,canCYASubmit:hd,cleanHiddenNestedData:jr,getFormState:yd,getRelevantPages:Td,getNextPageId:Zt,getPage:Ur,getSubmissionStatus:gd,getUpdatedSectionStates:Pd,clearOutUncompletedRoutes:kd},$d=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w)=>{if(t.type===G.TYPES.SUBMIT&&y!==he.TASK){if(e("submit"),W.canCYASubmit(n,s.pages)&&!A){w(!0);const L=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),C={pages:n,components:o};W.clearOutUncompletedRoutes(r,C,L),L.formStatus=W.getSubmissionStatus(a,n,c,t,L,u,!0),l(L),m.onSubmit(t.type,L,()=>{m.onFormComplete(),w(!1)},I=>{w(!1),pe.submissionError(I,f)})}}else{const C=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?W.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===G.TYPES.SAVE_AND_CONTINUE&&y===he.TASK&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(te.HUB)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SUBMIT&&y===he.TASK&&(e("submit"),C)){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT),_={pages:n,components:o};W.clearOutUncompletedRoutes(r,_,I),I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{m.onFormComplete(),w(!1)},U=>{w(!1),pe.submissionError(U,f)})}if(t.type===G.TYPES.SAVE_AND_NAVIGATE&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!0),l(I),m.onSubmit(t.type,I,()=>{w(!1),h(t.page)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.SAVE_AND_RETURN&&C){const I=g.Format.form({pages:n,components:o},{...i},Te.SUBMIT);I.formStatus=W.getSubmissionStatus(a,n,c,t,I,u,!1),l(I),m.onSubmit(t.type,I,()=>{a===Z.TASK?h(void 0):h(te.HUB),w(!1)},_=>{w(!1),pe.submissionError(_,f)})}if(t.type===G.TYPES.NAVIGATE&&(h(W.getNextPageId(a,n,c,t,p.page?.formData)),w(!1)),t.type===G.TYPES.CANCEL){const I=g.Format.form({pages:n,components:o},{...i},Te.CANCEL);m.onCancel(I),w(!1)}}},ls=(e,t,n,s,r,o,i,l,a,c,u,m,f,y,h,p,A,w,L,C,I,_)=>{const U={...r},S=o,R=s.onAction(S.page.formData,t,r,e.customAction);S.page.formData=R.formData;let v=R.patch;if(S.page.formData={...S.page.formData,...v},e.type===G.TYPES.CANCEL){s.onCancel(S.page.formData),I(!1);return}if(W.canActionProceed(e,S.page,i.page,_)&&(!C||e.ignoreSubmittingFlag))if(v=W.cleanHiddenNestedData(v,S.page),I(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(x=>{x.isCollection?yn(x.field,x.value,o.page.formData):g.Data.setDataItem(o.page.formData,x.field,x.value)}),S.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===G.TYPES.NAVIGATE)pe.navigate(e,f,l),I(!1);else{let D=V=>l(W.getNextPageId(a,u,f,e,V)),x,k;e.collection&&(x=e.collection,k=`addAnother${x.charAt(0).toUpperCase()+x.slice(1)}`.slice(0,-1));let P,N;switch(x&&(P=S.page.formData[x],P&&P.length>0&&S.page.formData[`${x}ActiveId`]&&(N=P.findIndex(V=>V.id===S.page.formData[`${x}ActiveId`]))),e.type){case G.TYPES.SUBMIT:y("submit");break;case G.TYPES.SAVE_AND_NAVIGATE:const V={...h};P&&P.length>0&&e.resetActiveId&&(S.page.formData[`${x}ActiveId`]=P[0].id),P&&P.length>0&&!e.resetActiveId&&(N!==void 0&&N+1<S.page.formData[x].length&&(S.page.formData[k]="Yes"),N!==void 0&&N+1===S.page.formData[x].length&&S.page.formData[k]&&(S.page.formData[k]="No")),D=()=>pe.navigate(e,f,l,V);break;case G.TYPES.COLLECTION_ADD:if(N===void 0||P.length===0||N+1===S.page.formData[x].length?g.CollectionPage.addEntry(e.collection,S.page.formData):S.page.formData[`${e.collection}ActiveId`]=P[N+1].id,S.page.formData[`${e.collection}`]&&S.page.formData[`${e.collection}`].length>0){const ae=S.page.formData[`${e.collection}`].length-1;Object.keys(S.page.formData[`${e.collection}`][ae]).filter(re=>re in S.page.formData&&re!=="id").forEach(re=>delete S.page.formData[re])}D=()=>pe.navigate(e,f,l);break;case G.TYPES.COLLECTION_DUPLICATE:g.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(D=()=>pe.navigate(e,f,l));break;case G.TYPES.COLLECTION_REMOVE:const K=e.targetId||S.page.formData[`${e.collection.split(".").pop()}ActiveId`],J=g.CollectionPage.removeEntry(e.collection,o.page.formData,K);e.recordRemoval&&(S.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...J});const de=S.page.formData.id;J!==null&&Object.keys(J).filter(fe=>fe in S.page.formData).forEach(fe=>delete S.page.formData[fe]),Object.assign(S.page.formData,P[P.length-1]),S.page.formData.id=de,P.length>0?S.page.formData[`${e.collection}ActiveId`]=P[P.length-1].id:(delete S.page.formData[`${e.collection}ActiveId`],delete S.page.formData[e.collection]),D=()=>pe.navigate(e,f,l);break}g.Data.deleteValues(r,o.page.formData);const j=g.Format.form({pages:u,components:m},{...r,...t,...o.page.formData},Te.SUBMIT);j.formStatus=W.getSubmissionStatus(a,u,f,e,j,h,!0,A?.sections),v&&p(j);const M={pages:u,components:m};e.type===G.TYPES.SUBMIT&&W.clearOutUncompletedRoutes(c,M,j);let Y,H;a===Z.HUB&&Object.keys(n).length>0&&(Y=Object.keys(n)[0],H=Object.values(n)[0]),s.onSubmit(e.type,j,V=>{const K={...j,...V};w({data:K}),D(K),I(!1)},(V,K=!0)=>{pe.submissionError(V,L),K&&p({...U}),I(!1)},Y,H,f)}},as=(e,t,n,s,r,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(a=>{i.fullPages.push(W.getPage(a,t))}),n(e);const l={...i};if(i.state===B.TYPES.COMPLETE&&!i.alwaysShowFirstPage)if(s?.noTaskCYAs){const a=r.formStatus.tasks[e.name].currentPage;o(i.pages[0]||a)}else i.customCYA?o(i.customCYA):o(te.CYA,l);else if(i.state===B.TYPES.IN_PROGRESS&&!i.alwaysShowFirstPage){const a=r.formStatus.tasks[e.name].currentPage;o(a||e.pages[0],l)}else i.firstPage?o(i.firstPage,l):o(i.pages[0],l)}},Vr=({title:e,titleSize:t,type:n,cleanseHiddenData:s=!1,components:r,pages:o,hub:i={nonSequential:!1,sections:[]},cya:l={actions:[],disableTaskSwitch:!1},data:a,hashLink:c=!1,hooks:u,classBlock:m=Bd,classModifiers:f=[],className:y="",hide_title:h,summaryListClassModifiers:p=[],noChangeAction:A=!1,newPageId:w="",viewOnly:L=!0,hideBlankRows:C=!1})=>d.jsx(Qs,{overrides:u,children:d.jsx(Zs,{children:d.jsx(Yd,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:m,classModifiers:f,className:y,hashLink:c,hide_title:h,summaryListClassModifiers:p,noChangeAction:A,newPageId:w,viewOnly:L,hideBlankRows:C})})}),Bd="hods-form",Yd=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:m,hashLink:f,hide_title:y,summaryListClassModifiers:h,noChangeAction:p,newPageId:A,viewOnly:w,hideBlankRows:L})=>{const[C,I]=O.useState({}),[_,U]=O.useState(),[S,R]=O.useState([]),[v,D]=O.useState(void 0),[x,k]=O.useState(W.getNextPageId(n,o,null,null,a)),[P,N]=O.useState(W.getFormState(x,S,v)),[j,M]=O.useState({}),[Y,H]=O.useState({}),[V,K]=O.useState("load"),[J,de]=O.useState(!1),[ae,fe]=O.useState(!1),{hooks:re}=ge(),{addErrors:_t,clearErrors:bn,errors:wn,validate:Pt}=De();window.onpopstate=$=>{if(!document.location.hash&&($.state&&$.state.fullPages!==void 0&&M(X=>({...X,fullPages:$.state?.fullPages})),bn(),de(!0),re.onGoingBack($.state?$.state:null,P.page?.formData),r&&S&&C&&P.page?.formData&&V===void 0)){const X=g.Format.form({pages:S,components:r},{...C,...P.page.formData},Te.SUBMIT);if(X?.formStatus?.taskPage){const ne=X.formStatus.tasks;Object.keys(ne).forEach(Se=>{const Pn=ne[Se];Pn.currentPage&&!Pn.complete&&delete ne[Se].currentPage}),delete X.formStatus.taskPage}I(X)}},O.useEffect(()=>{r&&o&&a&&(V==="load"||w)&&(I(g.Data.setupForm(o,r,a)),a.formStatus?.page&&k(a.formStatus.page))},[r,o,a,I,V,w]),O.useEffect(()=>{R(g.FormPage.getAll(o,r,{...C}))},[r,o,C,R]),O.useEffect(()=>{k($=>$||W.getNextPageId(n,S))},[n,S,k]),O.useEffect(()=>{D(g.Hub.get(n,i,r,{...C}))},[n,i,C,r,D]),O.useEffect(()=>{n===Z.HUB&&J&&C&&P.page?.formData&&(P.page.formData={...C}),de(!1),N(W.getFormState(x,S,v))},[S,v,x,N,n,J,C,P.page]),O.useEffect(()=>{K(void 0),re.onFormLoad($=>{M($)})},[re]),O.useEffect(()=>{H(i)},[i]),O.useEffect(()=>{_?.data&&(I(_.data),U(void 0))},[_,I,U]);const xt=i?.sections,In=i?.nonSequential;O.useEffect(()=>{const $=j.fullPages;if($&&($.forEach(X=>{const ne=X;ne&&(ne.formData=C)}),M(X=>({...X,fullPages:$}))),xt){const X=C?.formStatus?.tasks||{},ne=W.getUpdatedSectionStates(xt,X,In,C);H(Se=>({...Se,sections:[...ne]}))}},[j.fullPages,C,xt,In]);const Pe=($,X={})=>{bn(),k($),re.onPageChange($,X)};O.useEffect(()=>{A!==void 0&&k(A)},[A]);const _n=$=>{re.onChange($)},qr=($,X)=>{if(typeof X=="function"){const ne=X({...C});ne&&I(ne)}P.page?.type===te.PARTIAL_CYA&&!l.disableTaskSwitch&&Y.sections.every(ne=>ne.tasks.every(Se=>Se.pages.includes($.pageId)&&Se.name!==j.name?(as(Se,S,M,Y,C,Pe),!1):!0)),$&&pe.cyaAction($,x,Pe)},Gr=g.classBuilder(c,u,m);if(v===he.TASK){const $=l;$.actions=[G.TYPES.SAVE_AND_CONTINUE,G.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:Hd,nonSequential:Vd,...Kr}=Y;return d.jsxs("div",{className:Gr(),children:[e&&!y&&x===te.HUB&&d.jsx(T.Heading,{size:t,children:e}),P.cya&&d.jsx(Zu,{pages:W.getRelevantPages(P,S,j.fullPages),...l,...P.page?.type===te.PARTIAL_CYA&&{actions:P.page.actions?.filter($=>g.Component.show($,C))},...P.cya,onAction:$=>{$d(K,$,S,Pt,s,r,C,I,n,x,j,re,_t,v,Pe,P,ae,fe)},onRowAction:qr,summaryListClassModifiers:h,hide_title:y,noChangeAction:P.cya.hideChangeActions??p,noGroupAction:P.cya.hideGroupActions??!1,sections:typeof Y<"u"?Y.sections:[],type:n,hideBlankRows:L}),v===he.TASK&&P.pageId===te.HUB&&d.jsx(ad,{...Kr,refNumber:C.businessKey,onTaskAction:$=>{as($,S,M,Y,C,Pe)},annotations:Y?.taskListAnnotations||[],formData:C}),P.page&&!P.cya&&!P.page.collection&&d.jsx(pn,{page:P.page,pages:[...S],onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},onChange:_n,hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae,pageId:x}),P.page&&!P.cya&&P.page.collection&&d.jsx(td,{page:P.page,pages:S,onCollectionChange:_n,onAction:($,X,ne)=>{ls($,X,ne,re,C,P,Pt,Pe,n,s,S,r,x,K,j,I,Y,U,_t,ae,fe,wn)},hashLink:f,classModifiers:P.page.classModifiers,className:P.page.className,submitting:ae})]})};exports.Container=Cn;exports.FormComponent=Fe;exports.FormRenderer=Vr;exports.FormTypes=Z;exports.HooksContextProvider=Qs;exports.HubFormats=he;exports.Models=Mo;exports.PageActions=mn;exports.SummaryList=Qt;exports.Utils=g;exports.ValidationContextProvider=Zs;exports.default=Vr;
|
package/dist/index.js
CHANGED
|
@@ -464,7 +464,7 @@ import './index.css';const $e = {
|
|
|
464
464
|
"full_path",
|
|
465
465
|
"fullPath",
|
|
466
466
|
"formData"
|
|
467
|
-
], ee = (e, t
|
|
467
|
+
], ee = (e, t) => {
|
|
468
468
|
const n = Array.isArray(t) ? [...Mn, ...t] : Mn;
|
|
469
469
|
return e && typeof e == "object" ? Object.keys(e).reduce((r, s) => n.includes(s) ? r : {
|
|
470
470
|
...r,
|
|
@@ -6154,7 +6154,7 @@ const to = (e, t) => {
|
|
|
6154
6154
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access -- FIXME
|
|
6155
6155
|
...Z,
|
|
6156
6156
|
fullPages: Y.state?.fullPages
|
|
6157
|
-
})), Ln(), he(!0), ie.onGoingBack(Y.state ? Y.state : null,
|
|
6157
|
+
})), Ln(), he(!0), ie.onGoingBack(Y.state ? Y.state : null, _.page?.formData), s && T && C && _.page?.formData && q === void 0)) {
|
|
6158
6158
|
const Z = S.Format.form({ pages: T, components: s }, { ...C, ..._.page.formData }, ge.SUBMIT);
|
|
6159
6159
|
if (Z?.formStatus?.taskPage) {
|
|
6160
6160
|
const se = Z.formStatus.tasks;
|
|
@@ -10,5 +10,5 @@ export declare const JSON_ONLY_PROPERTIES: string[];
|
|
|
10
10
|
* @param {Array} alsoRemove An array of additional properties to remove.
|
|
11
11
|
* @returns A clean(er) JSON object.
|
|
12
12
|
*/
|
|
13
|
-
declare const cleanAttributes: (options: any, alsoRemove?:
|
|
13
|
+
declare const cleanAttributes: (options: any, alsoRemove?: string[]) => {};
|
|
14
14
|
export default cleanAttributes;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const Component: {
|
|
2
|
-
clean: (options: any, alsoRemove?:
|
|
2
|
+
clean: (options: any, alsoRemove?: string[]) => {};
|
|
3
3
|
defaultValue: (component: any, formData: any) => any;
|
|
4
4
|
defaultValueFromConfig: (component: any, data: any) => any;
|
|
5
5
|
editable: (options: any) => any;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare const Utils: {
|
|
|
32
32
|
setData: (collectionName: any, newData: any, formData: any) => void;
|
|
33
33
|
};
|
|
34
34
|
Component: {
|
|
35
|
-
clean: (options: any, alsoRemove?:
|
|
35
|
+
clean: (options: any, alsoRemove?: string[]) => {};
|
|
36
36
|
defaultValue: (component: any, formData: any) => any;
|
|
37
37
|
defaultValueFromConfig: (component: any, data: any) => any;
|
|
38
38
|
editable: (options: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.7",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": "24.14.1"
|
|
6
6
|
},
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@ukhomeoffice/cop-react-components": "6.0.0",
|
|
28
|
+
"dayjs": "1.11.0",
|
|
28
29
|
"react": ">=16.14.0 <20",
|
|
29
|
-
"react-dom": ">=16.14.0 <20"
|
|
30
|
-
"dayjs": "1.11.0"
|
|
30
|
+
"react-dom": ">=16.14.0 <20"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@chromatic-com/storybook": "5.0.1",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"react-dom": "19.2.4",
|
|
65
65
|
"react-test-renderer": "19.2.4",
|
|
66
66
|
"rimraf": "6.1.2",
|
|
67
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
67
68
|
"sass-embedded": "1.97.3",
|
|
68
69
|
"storybook": "10.2.19",
|
|
69
70
|
"storybook-addon-mock": "^6.0.1",
|