@questwork/q-utilities 0.1.30 → 0.1.33

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.
@@ -0,0 +1,12 @@
1
+ var Bn=Object.defineProperty;var Un=(f,S,I)=>S in f?Bn(f,S,{enumerable:!0,configurable:!0,writable:!0,value:I}):f[S]=I;var Nt=(f,S,I)=>Un(f,typeof S!="symbol"?S+"":S,I);(function(f){"use strict";function S({allowCoordinator:n,allowOwner:e,query:t={},required:r,user:i}){if(!i)throw new Error("Require login.");i.permission;const s=i.permission.getScopes(r||{})||[];!s||s.length,s.includes("*")||(t.tenantCode=i.tenantCode),s.includes("TENANT")||(t.eventShortCode=i.eventShortCode),n&&t.registrationGroupCode&&i.myManagedRegistrationGroupCodes.includes(t.registrationGroupCode)?t.__ALLOW_COORDINATOR=!0:s.includes("EVENT")||(t.eventRegistrationCode=i.eventRegistrationCode),e&&(t.__ALLOW_OWNER=!0);const a=i.getExcludedFields(r);return a.length>0&&(t.__EXCLUDED_FIELDS=a),t.__LOGIN_SUBJECT_CODE=i.loginSubjectCode,t}function I(n,e){const t=new Date(n),r=e?new Date(e):new Date;if(isNaN(t.getTime())||isNaN(r.getTime())||t>r)return null;let i=r.getFullYear()-t.getFullYear();const s=r.getMonth()-t.getMonth();return(s<0||s===0&&r.getDate()<t.getDate())&&i--,i}function ie(n,{source:e,target:t}){return n.meta?((!n.meta.creator||n.meta.creator===e.getId())&&(n.meta.creator=t.getId()),(!n.meta.owner||n.meta.owner===e.getId())&&(n.meta.owner=t.getId())):((!n.creator||n.creator===e.getId())&&(n.creator=t.getId()),(!n.owner||n.owner===e.getId())&&(n.owner=t.getId())),n}function z(n){return n!=null&&typeof n!="boolean"&&String(n).trim()!==""&&!isNaN(Number(n))}function _(n,e){let t=n,r=e;if(typeof n=="string"&&(t=t.split(".")),!Array.isArray(n)&&typeof n=="object"){const{keys:s,obj:a}=n;t=s,r=a}if(t.length===0)return r;const i=t.shift();return r&&Object.prototype.hasOwnProperty.call(r,i)?_(t,r[i]):r&&i?t.length>0?_(t,r[i]):r[i]:r}function Dt(n){const e={};for(const[t,r]of Object.entries(n)){const i=t.match(/^(.*?)\|(boolean|date|html|number|string)$/);let s=t,a=null;i&&(s=i[1],a=i[2]);const o=s.split(".");let u=e;for(let c=0;c<o.length-1;c++){const d=o[c];(!u[d]||typeof u[d]!="object")&&(u[d]={}),u=u[d]}const l=o[o.length-1];if(a==="boolean")r===1||r==="1"||r===!0||r==="true"||r==="TRUE"?u[l]=!0:r===0||r==="0"||r===!1||r==="false"||r==="FALSE"?u[l]=!1:u[l]=!!r;else if(a==="number")u[l]=Number(r)||0;else if(a==="date")u[l]=new Date(r);else if(a==="html")if(r&&typeof r=="string"){let c=[];r.includes(`
2
+
3
+ `)||r.includes(`\r
4
+ \r
5
+ `)?c=r.split(/\r?\n\s*\r?\n/).filter(d=>d.trim()!==""):c=r.split(/\r?\n/).filter(d=>d.trim()!==""),c.length>0?u[l]=c.map(d=>`<div>${d.trim()}</div>`).join(""):u[l]=r?`<div>${r}</div>`:""}else u[l]=r?`<div>${r.toString()}</div>`:"";else if(r==null)u[l]="";else if(typeof r=="number")u[l]=r;else if(typeof r=="string"&&r.trim()!==""){const c=r.trim();/^-?\d+$/.test(c)?u[l]=Number.parseInt(c,10):/^-?\d+\.\d+$/.test(c)?u[l]=Number.parseFloat(c):u[l]=r}else u[l]=(r==null?void 0:r.toString())||""}return e}function Mt(n,e){return e.split(".").reduce((r,i)=>{if(i.endsWith("[]")){const s=i.slice(0,-2);return Array.isArray(r[s])?r[s]:[]}if(i.includes("[")&&i.includes("]")){const s=i.match(/(\w+)\[(\d+)\]/);if(s){const a=s[1],o=s[2];return r&&r[a]&&r[a][o]}}else return r&&Array.isArray(r)?r.map(s=>s[i]):r&&r[i]},n)}function jt(n,e){return e.split(".").reduce((t,r)=>t&&t[r]!==void 0?t[r]:void 0,n)}function kt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp)&&Object.prototype.toString.call(n)==="[object Object]"}function se(n,...e){if(!e.length)return n;const t=e.shift();if(ae(n)&&ae(t))for(const r in t)ae(t[r])?(n[r]||(n[r]={}),se(n[r],t[r])):n[r]=t[r];return se(n,...e)}function xt(n,e,t){const r=e.split(".");let i=n;for(let o=0;o<r.length-1;o++){const u=r[o];let l,c;const d=u.match(/^(\w+)\[(\d+)\]$/);if(d){for(l=d[1],c=Number.parseInt(d[2],10),(!i[l]||!Array.isArray(i[l]))&&(i[l]=[]);i[l].length<=c;)i[l].push(void 0);i[l][c]==null&&(i[l][c]={}),i=i[l][c]}else i[u]||(i[u]={}),i=i[u]}const s=r[r.length-1],a=s.match(/^(\w+)\[(\d+)\]$/);if(a){const o=a[1],u=Number.parseInt(a[2],10);for((!i[o]||!Array.isArray(i[o]))&&(i[o]=[]);i[o].length<=u;)i[o].push(void 0);i[o][u]=t}else i[s]=t}function ae(n){return n&&typeof n=="object"&&!Array.isArray(n)}const b={expandDotNotation:Dt,get:Mt,getNestedValue:jt,isPlainObject:kt,merge:se,set:xt};class E{constructor(e={}){e=e||{},this.key=e.key||null,this.value=typeof e.value<"u"?e.value:""}static init(e={}){if(e instanceof this)return e;const t=new this(e);return t.isValid?t:null}static initFromArray(e=[]){return Array.isArray(e)?e.map(t=>this.init(t)):[]}static initOnlyValidFromArray(e=[]){return this.initFromArray(e).filter(t=>t)}static get _classname(){return"KeyValueObject"}static get _superclass(){return"KeyValueObject"}static addItem(e,t,r){e.push(this.init({key:t,value:r}))}static addRecord(e=[],t,r){return this.hasKeyValue(e,t,r)||e.push(this.init({key:t,value:r})),e}static appendRecord(e=[],t,r){return e.map(i=>(this.sameKey(i,t)&&(i.value=[...i.value,...r]),i))}static appendValueArray(e=[],t,r){return e.map(i=>(this.sameKey(i,t)&&(i.value=[...i.value,...r]),i))}static foundByKey(e=[],t){return e.find(i=>this.sameKey(i,t))||null}static foundValueByKey(e=[],t){const r=this.foundByKey(e,t);return r?r.value:null}static fromObject(e={}){return Object.keys(e).reduce((t,r)=>(t.push(this.init({key:r,value:e[r]})),t),[])}static getValueByKey(e=[],t){return this.foundValueByKey(e,t)}static getMetadataValueByKeyAsArray(e=[],t){const r=this.getValueByKey(e,t);return r?b.isPlainObject(r)?Object.keys(r).reduce((i,s)=>(i.push({key:s,value:r[s]}),i),[]):r:[]}static getValueByKeyFromArray(e=[],t){if(e.length===0)return null;const i=e.shift().find(s=>this.sameKey(s,t));return i&&i.value?i.value:this.getValueByKeyFromArray(e,t)}static getValuesByKey(e=[],t){return e.reduce((r,i)=>(this.sameKey(i,t)&&r.push(i.value),r),[])}static hasKeyValue(e=[],t,r){return typeof r>"u"?e.filter(i=>this.sameKey(i,t)).length>0:e.filter(i=>this.sameKey(i,t)&&ve(i.value,r)).length>0}static insertOrUpdateRecord(e=[],t,r){let i=[...e];return this.hasKeyValue(e,t)?i=this.updateRecord(e,t,r):i.push(this.init({key:t,value:r})),i}static keys(e=[]){return Array.isArray(e)?e.reduce((t,r)=>(t.push(r.key),t),[]):[]}static mapToKeyValue(e=[],t="key",r="value"){return Array.isArray(e)?e.reduce((i,s)=>{if(s&&typeof s=="object"){const a=b.get(s,t),o=b.get(s,r);a!=null&&i.push(this.init({key:a,value:o!==void 0?o:""}))}return i},[]):[]}static merge(e,t){return(t||[]).map(r=>{const i=e.find(s=>s.key===r.key);i?i.value=Ft(r.value,i.value):e.push(r)}),e}static removeByKey(e,t){return e.reduce((r,i)=>(this.sameKey(i,t)||r.push(i),r),[])}static removeByKeys(e,t){return e.reduce((r,i)=>(t.includes(i.key)||r.push(i),r),[])}static sameKey(e,t){return e?ve(e.key,t):!1}static toObject(e=[]){return Array.isArray(e)?e.reduce((t,r)=>(t[r.key]=r.value,t),{}):{}}static toString(e=[],t="; "){return Array.isArray(e)?e.reduce((r,i)=>(r.push(`${i.key}: ${i.value}`),r),[]).join(t):""}static updateRecord(e=[],t,r){return e.map(i=>this.sameKey(i,t)?{...i,value:r}:i)}static updateOrInsertRecord(e=[],t,r){return this.insertOrUpdateRecord(e,t,r)}static updateRecordsFromArray(e=[],t=[]){if(Array.isArray(e)&&Array.isArray(t)){const r=this.toObject(e),i=this.toObject(t);return this.fromObject({...r,...i})}return[]}static values(e=[]){return Array.isArray(e)?e.reduce((t,r)=>(t.push(r.value),t),[]):[]}get isValid(){return!!this.key}get toObject(){const e={};return this.isValid&&(e[this.key]=this.value),e}}function Ft(n,e){return n===void 0?e:Array.isArray(n)&&Array.isArray(e)?[...new Set([...n,...e])]:typeof n=="object"&&typeof e=="object"&&!Array.isArray(n)&&!Array.isArray(e)?{...n,...e}:e}function ve(n,e){return n===e}function C(n,e,t=Pt,r=E){if(!n)return!0;if(typeof t!="function"||r&&typeof r!="function")return!1;const{key:i="",value:s,placeholder:a,keyValuePath:o=""}=n,[u]=Object.keys(s);if(!i&&typeof a>"u")switch(u){case"$and":return s.$and.reduce((c,d)=>c&&C(d,e,t,r),!0);case"$or":return s.$or.reduce((c,d)=>c||C(d,e,t,r),!1);default:return!1}let l=typeof a>"u"?t(i,e):a;if(o){const c=r.toObject(l);l=t(o,c)}switch(u){case"$after":{if(z(s==null?void 0:s.$after)){const c=Number(String(s==null?void 0:s.$after));return Date.now()>c}return!1}case"$before":{if(z(s==null?void 0:s.$before)){const c=Number(String(s==null?void 0:s.$before));return Date.now()<c}return!1}case"$empty":return l==null===s.$empty;case"$eq":return l===s.$eq;case"$gt":return l>s.$gt;case"$gte":return l>=s.$gte;case"$hasOverlap":return Lt(l,s.$hasOverlap);case"$lt":return l<s.$lt;case"$lte":return l<=s.$lte;case"$in":return Array.isArray(l)?!!l.find(c=>s.$in.includes(c)):typeof l!="object"?!!s.$in.includes(l):!1;case"$includes":return Array.isArray(l)?l.includes(s.$includes):!1;case"$intervalTimeGt":{const c=new Date().getTime(),d=new Date(l).getTime();return c-d>s.$intervalTimeGt}case"$intervalTimeLt":{const c=new Date().getTime(),d=new Date(l).getTime();return c-d<s.$intervalTimeLt}case"$inValue":{const c=t(s.$inValue,e),d=Array.isArray(c)?c:[];return Array.isArray(l)?!!l.find(m=>d.includes(m)):typeof l=="string"?!!d.includes(l):!1}case"$isToday":{const c=new Date,d=c.setHours(0,0,0,0),m=c.setHours(23,59,59,59),h=new Date(l).getTime();return(d<=h&&m>=h)===s.$isToday}case"$ne":return l!==s.$ne;case"$notIn":return Array.isArray(l)?!l.find(c=>s.$notIn.includes(c)):typeof l!="object"?!s.$notIn.includes(l):!1;case"$notInValue":{const c=t(s.$notInValue,e),d=Array.isArray(c)?c:[];return Array.isArray(l)?!l.find(m=>d.includes(m)):typeof l!="object"?!d.includes(l):!1}case"$range":{const[c,d]=s.$range;return typeof c=="number"&&typeof d=="number"&&l>=c&&l<=d}default:return!1}}function Pt(n,e){return _(n.split("."),e)}function Lt(n,e){let t=n,r=e;typeof t=="string"&&(t=t.split(",")),typeof r=="string"&&(r=r.split(","));const i=new Set(t);return r.find(s=>i.has(s))}function oe(n,e){const t=n&&n instanceof Date?n:new Date(n),r=["日","一","二","三","四","五","六"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],a=e||"YYYY/MM/DD hh:mm",o=t.getDay(),u=s[o],l=r[o],c=i[o],d=t.getFullYear(),m=t.getMonth()+1,h=t.getDate(),g=t.getHours(),v=t.getMinutes(),D=t.getSeconds();return a.replace("YYYY",d).replace("MM",$(m)).replace("MM",$(m)).replace("DD",$(h)).replace("hh",$(g)).replace("mm",$(v)).replace("ss",$(D)).replace("M",m).replace("D",h).replace("h",g).replace("m",v).replace("s",D).replace("EEEE",$(c)).replace("EEE",$(l)).replace("EE",$(u)).replace("E",$(o))}function $(n){return n<10?`0${n}`:n}const p={argumentEmptyException:"Argument is empty",argumentFormatException:"Incorrect number or format of argument",invalidFuntionException:"Function Name is invalid",invalidRegExpException:"Invalid regular expression",isNotAFunctionException:"Is not a function",notExistException:"Key does not exist",resultEmptyException:"Result is empty",resultMoreThanOneException:"More than one result"};class y extends Error{constructor(e){super(e),this.message=e}}const Vt="_EMPTY",Oe=["concatIf","divide","eq","exec","filterAll","filterOne","formatDate","get","gt","gte","isEmpty","isNotEmpty","join","lt","lte","map","neq","removeHtml","replaceChar","sum","toLowerCase","toUpperCase"],Re="_HIDE",Bt="_NOT_EMPTY",w="_SELF",Ut=["<%=","%>"],Kt=["{{","}}"];function Te(n,e){if(typeof n!="string")throw new y(`_concatIf: ${p.argumentFormatException}: the data must be string :${n.join(", ")}`);if(e.length!==3)throw new y(`_concatIf: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;const[t,r,i]=e;if([Vt,Bt].includes(t)||r.length!==2)throw new y(`concatIf: ${p.argumentEmptyException}: ${t}, ${r}`);return n===""&&i.includes(Re)?"":n!==""&&(n!==null||n!==void 0)&&i.includes(Re)?`${r[0]}${n}${r[r.length-1]}`:i}function Ie(n,e){try{return Number.isNaN(n)?n:n/e}catch(t){throw t}}function Ne(n,e){if(e.length!==3)throw new y(`eq: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n===t?e[1]:e[2]}function Ht(n,e){try{const[t,...r]=e;return n[t](...r)}catch(t){throw t}}function le(n,e){try{if(!Array.isArray(e)||e.length===0)throw new y(p.argumentEmptyException);return!Array.isArray(n)||n.length===0?[]:typeof n[0]=="object"?De(n,e):typeof n[0]=="string"||typeof n[0]=="number"?Wt(n,e):[]}catch(t){throw t}}function Wt(n,e){const t=e.flat();return n.filter(r=>t.some(i=>Me(i,r)))}function De(n,e){if(e.length===1){const s=e[0];return n.filter(a=>s.includes(".")?_(s.split("."),a):Object.prototype.hasOwnProperty.call(a,s))}if(e.length>2){let s=n;for(let a=0;a<e.length;a+=2){const o=[e[a],e[a+1]];s=De(s,o)}return s}const[t,...r]=e,i=r.flat();return n.filter(s=>{const a=t.includes(".")?_(t.split("."),s):s[t];return i.some(o=>Me(o,a))})}function Me(n,e){if(n===void 0&&e===void 0||n===null&&e===null)return!0;if(typeof n=="boolean")return n===e;if(n===""||n==="*")return e==null?!1:typeof e=="string"?n===""?e==="":e!=="":Array.isArray(e)?n===""?e.length===0:e.length!==0:n!=="";if(Yt(n))return n===e;if(n.startsWith("[")&&n.endsWith("]"))return n==="[]"?Array.isArray(e)&&e.length===0:n==="[*]"?Array.isArray(e)&&e.length!==0:!1;const{operator:t,value:r}=qt(n);if(!t||r!==0&&!r)return!1;switch(t){case">":return e>r;case"<":return e<r;case"!=":return e!==r;case">=":return e>=r;case"<=":return e<=r;default:return!1}}function Yt(n){return typeof n=="string"?!(n.startsWith("[")&&n.endsWith("]")||/!=|>=|<=|>|</.test(n)):!Number.isNaN(n)}function qt(n){const t=["!=",">=","<=",">","<"].find(s=>n.startsWith(s));if(!t)return{operator:null,value:null};const r=n.slice(t.length);if(/^[a-z]*$/i.test(r)&&t!=="!=")return{operator:null,value:null};const i=!Number.isNaN(Number.parseFloat(r))&&!Number.isNaN(r)?Number(r):r;return{operator:t,value:i}}function zt(n,e){try{const t=le(n,e);if(t.length===1)return t[0];if(t.length===0)return null;throw new y(p.resultMoreThanOneException)}catch(t){throw t}}function je(n,e){if(e.length===0)throw new y(`_formateDate: ${p.argumentFormatException}: format parts must be not empty array`);if(n==null)return null;const t=new Date(n),r={yyyy:String(t.getFullYear()),mm:String(t.getMonth()+1).padStart(2,"0"),dd:String(t.getDate()).padStart(2,"0")},i=["yyyy","mm","dd"];if(e.filter(a=>a.length>1&&!i.includes(a)).length>0)throw new y(`_formateDate: ${p.argumentFormatException}: the format type is not valid: ${e.join(", ")}`);return e.reduce((a,o)=>a+(r[o]||o),"")}function G(n,e,t=null){try{if(e===null||typeof e>"u"||e==="")throw new y(p.argumentEmptyException);if(n===null)return null;if(e.includes(".")){const r=e.split(".");if(r.length>1){const i=r.shift(),s=r.join(".");return typeof n[i]<"u"?G(n[i],s,t):ke(e,t)}}return typeof n[e]<"u"?n[e]:ke(e,t)}catch(r){throw r}}function ke(n,e){return e!==null?e:null}function xe(n,e){if(e.length!==3)throw new y(`_gt: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n>t?e[1]:e[2]}function Fe(n,e){if(e.length!==3)throw new y(`_gte: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n>=t?e[1]:e[2]}function Pe(n,e){if(e.length!==2)throw new y(`_isEmpty: ${p.argumentFormatException}: ${e.join(", ")}`);return e.includes(w)&&(e=e.map(t=>t===w?n:t)),n!==null&&typeof n=="object"&&Object.keys(n).length===0||n===""||n===null||n===void 0||n.length===0?e[0]:e[1]}function Le(n,e){if(e.length!==2)throw new y(`_isNotEmpty: ${p.argumentFormatException}: ${e.join(", ")}`);return e.includes(w)&&(e=e.map(t=>t===w?n:t)),n!==null&&typeof n=="object"&&Object.keys(n).length===0||Array.isArray(n)&&n.length===0||typeof n=="string"&&n===""||n==null?e[1]:e[0]}function Ve(n,e){try{return n.length===0?"":n.length===1?Be(n[0]):n.map(t=>Be(t)).join(e)}catch(t){throw t}}function Be(n){return JSON.stringify(n).replace(/"([^"]+)":/g,"$1: ").replace(/"([^"]+)"/g,"$1").replace(/,/g,", ")}function Ue(n,e){if(e.length!==3)throw new y(`_lt: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n<t?e[1]:e[2]}function Ke(n,e){if(e.length!==3)throw new y(`_lte: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n<=t?e[1]:e[2]}function He(n,e){try{if(e.length===0)throw new y(p.argumentEmptyException);return n===null||typeof n>"u"?null:n.reduce((r,i)=>{e.length===1&&Array.isArray(e[0])&&(e=e[0],r.hasFormat=!0);const s=e.map(a=>{if(a.includes(".")){const o=a.split("."),u=o[0];o.shift();const l=o.join(".");return G(i[u],l)}return typeof i[a]<"u"?i[a]:null});return r.hasFormat?r.content.push(s):r.content=r.content.concat(s),r},{content:[],hasFormat:!1}).content}catch(t){throw t}}function We(n,e){if(e.length!==3)throw new y(`_neq: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n!==t?e[1]:e[2]}function Ye(n,e){if(n==null)return null;if(!Array.isArray(e))throw new y(`_removeHtml: ${p.argumentFormatException}: args parts must be array`);return Gt(n,e[0])}function Gt(n,e=`
6
+ `){typeof e!="string"&&(e=`
7
+ `);let r=n.replace(/&nbsp;/g," ").replace(/\s+/g," ").replace(/<\/?(p|div|h[1-6]|ul|ol|li|pre|section|article|table|tr|td|th)(\s[^>]*)?>/gi,"~~~").replace(/<br\s*\/?>/gi,"~~~").replace(/<[^>]+>/g,"").replace(/~{3,}/g,e).trim();return e===""?r=r.replace(/\s+/g," "):(r=r.replace(new RegExp(`${ue(e)}+`,"g"),e),r=r.replace(new RegExp(`^${ue(e)}|${ue(e)}$`,"g"),"")),r}function ue(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qe(n,e){if(n==null)return null;if(!Array.isArray(e))throw new y(`_replaceChar: ${p.argumentFormatException}: args parts must be array`);return Jt(n,e[0],e[1])}function Jt(n,e,t){return!n||!e?n:n.replace(new RegExp(e,"g"),t)}function ze(n,e){return Number.isNaN(n)||n===null||typeof n>"u"||n===""?n:e.reduce((t,r)=>t+r,n)}function Ge(n,e){if(e!==void 0)throw new y(`_toLowerCase: ${p.argumentFormatException}: ${e.join(", ")}`);return n===null||typeof n>"u"||typeof n!="string"?null:String(n).toLowerCase()}function Je(n,e){if(typeof n!="string")throw new y(`_toUpperCase: ${p.argumentFormatException}: the data must be string: ${n}`);if(e!==void 0)throw new y(`_toUpperCase: ${p.argumentFormatException}: the argument must be empty: ${e.join(", ")}`);return n===null||typeof n>"u"||typeof n!="string"?null:String(n).toUpperCase()}class ce{constructor(e){this.data=e}static init(e){return new this(e)}static initFromArray(e=[]){return Array.isArray(e)?e.map(t=>this.init(t)):[]}static initOnlyValidFromArray(e=[]){return this.initFromArray(e).filter(t=>t)}static concatIf(e,t){return Te(e,t)}static divide(e,t){return Ie(e,t)}static eq(e,t){return Ne(e,t)}static filterAll(e,t){return le(e,t)}static formatDate(e,t){return je(e,t)}static get(e,t,r=null){return G(e,t,r)}static gt(e,t){return xe(e,t)}static gte(e,t){return Fe(e,t)}static isEmpty(e,t){return Pe(e,t)}static isNotEmpty(e,t){return Le(e,t)}static join(e,t=""){return Ve(e,t)}static lt(e,t){return Ue(e,t)}static lte(e,t){return Ke(e,t)}static map(e,t=[]){return He(e,t)}static neq(e,t){return We(e,t)}static removeHtml(e,t){return Ye(e,t)}static replaceChar(e,t){return qe(e,t)}static sum(e,t){return ze(e,t)}static toLowerCase(e,t){return Ge(e,t)}static toUpperCase(e,t){return Je(e,t)}static parseFunction(e){return Ze(e,Oe)}static parseParams(e){return Xe(e)}pipe(e=""){this.delimiters=e.substring(0,2)==="{{"?Kt:Ut;const t=new RegExp(`${this.delimiters[0]}\\s(.*?)\\s${this.delimiters[1]}`),r=e.match(t);if(r!==null)try{return Ze(r[1],Oe).reduce((s,a)=>en(s,a.name,a.args),this.data)}catch(i){throw new y(`TemplateCompiler engine error: ${i.message}`)}throw new y(`TemplateCompiler engine error: ${p.invalidRegExpException}`)}}function Ze(n,e){const t=/(\w+)\(((?:[^()]|\((?:[^()]|\([^()]*\))*\))*)\)/;let r;if(n.includes("|")){r=[];let i="",s=0,a=null;for(let o=0;o<n.length;o++){const u=n[o];if((u==='"'||u==="'")&&(o===0||n[o-1]!=="\\")){a===u?a=null:a===null&&(a=u),i+=u;continue}a===null&&(u==="("?s++:u===")"&&s--),u==="|"&&s===0&&a===null?(r.push(i),i=""):i+=u}i&&r.push(i)}else r=[n];return r.reduce((i,s)=>{const a=s.match(t);if(a!==null){const o=a[1],u=a[2],l=Xe(u);if(e.includes(o))i.push({name:o,args:l});else throw new y(`${o} is not a valid function`)}return i},[])}function Xe(n){const e=n.trim();return e?e.includes(",")?Zt(e).map(r=>fe(r.trim())):[fe(e)]:[]}function Zt(n){const e=[];let t="",r=0,i=0,s=null;for(let a=0;a<n.length;a++){const o=n[a];if((o==='"'||o==="'")&&(a===0||n[a-1]!=="\\")){s===o?s=null:s===null&&(s=o),t+=o;continue}if(s!==null){t+=o;continue}o==="["?r++:o==="]"?r--:o==="("?i++:o===")"&&i--,o===","&&s===null&&r===0&&i===0?(e.push(t),t=""):t+=o}return t&&e.push(t),e}function fe(n){if(typeof n!="string")return n;const e=n.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.substring(1,e.length-1);const t=Qt(e);return typeof t!="string"?t:e.startsWith("[")&&e.endsWith("]")?Xt(e):n}function Xt(n){const e=n.substring(1,n.length-1).trim();if(!e)return[];const t=[];let r="",i=null;for(let s=0;s<e.length;s++){const a=e[s];if((a==='"'||a==="'")&&(s===0||e[s-1]!=="\\")){i===a?i=null:i===null&&(i=a),r+=a;continue}a===","&&i===null?(r.trim()&&t.push(r.trim()),r=""):r+=a}return r.trim()&&t.push(r.trim()),t.map(s=>fe(s))}function Qt(n){if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return n.substring(1,n.length-1);if(n==="true")return!0;if(n==="false")return!1;if(n!=="undefined")return n==="null"?null:!Number.isNaN(n)&&!Number.isNaN(Number.parseFloat(n))?Number(n):n}function en(n,e,t){try{let r;switch(e){case"concatIf":return Te(n,t);case"divide":return Ie(n,t);case"eq":return Ne(n,t);case"exec":return Ht(n,t);case"filterAll":return le(n,t);case"filterOne":return zt(n,t);case"formatDate":return je(n,t);case"get":if(t.length>2)throw new y(p.argumentFormatException);return t.length===2&&(r=t[t.length-1]),G(n,t[0],r);case"gt":return xe(n,t);case"gte":return Fe(n,t);case"isEmpty":return Pe(n,t);case"isNotEmpty":return Le(n,t);case"join":return Ve(n,t[0]);case"lt":return Ue(n,t);case"lte":return Ke(n,t);case"map":return He(n,t);case"neq":return We(n,t);case"removeHtml":return Ye(n,t);case"replaceChar":return qe(n,t);case"sum":return ze(n,t);case"toLowerCase":return Ge(n);case"toUpperCase":return Je(n);default:throw new Error(`${e} is not a valid function`)}}catch(r){throw r}}function J(n,e){return n.reduce((t,r)=>{const{type:i,value:s="",restriction:a,template:o,format:u,showMinutes:l}=r;switch(i){case"array":{if(C(a,e,_)){const c=_(s.split("."),e)||[];t+=c.reduce((d,m)=>d+=J(o,m),"")}break}case"date":{if(C(a,e,_)){const c=_(s.split("."),e)||"";t+=oe(c,u).toString()}break}case"ellipsis":{if(C(a,e,_)){const{maxLength:c}=r,d=_(s.split("."),e)||"";d.length<=c?t+=d.toString():t+=`${d.substr(0,c)}...`}break}case"group":{if(C(a,e,_))return J(s,e);break}case"label":{C(a,e,_)&&(t+=s.toString());break}case"templateCompiler":{if(C(a,e,_)){const c=new ce({data:e});t+=c.pipe(s)}break}case"value":{if(C(a,e,_)){const c=_(s.split("."),e)||"";t+=c.toString()}break}}return t},"")}function Qe(n,e=/\$\{(.+?)\}/g,t,r){if(!n)return"";const i=typeof r=="function"?r:_,s=new RegExp(e,"g");return n.replace(s,(a,o)=>{const u=i({keys:o.split("."),obj:t});return u==null?"":typeof u=="object"?JSON.stringify(u):u})}function tn(n,e=0){try{if(typeof n=="number")return n.toString().length===10&&(n=n*1e3),new Date(n);if(typeof n=="string"&&n.length===8){const t=Number.parseInt(n.slice(0,4),10),r=Number.parseInt(n.slice(4,6),10)-1,i=Number.parseInt(n.slice(6,8),10);return new Date(t,r,i)}return new Date(n)}catch{throw new Error("input does not meet the requirements")}}class V{constructor({date:e,isUTC:t,is24Hour:r,timezoneOffset:i=0}={}){this.date=e,this.isUTC=t,this.is24Hour=r,this.timezoneOffset=i}getDateComponent(e){if(this.timezoneOffset!==0){const t=this.timezoneOffset*60*1e3;return new Date(this.date.getTime()+t)[`getUTC${e}`]()}else return this.isUTC?this.date[`getUTC${e}`]():this.date[`get${e}`]()}process(e){return e}}function k(n,e="0"){if(typeof n!="number")throw new TypeError("Parameter must be of number");return n<10?`${e}${n}`:n}class nn extends V{process(e){const t=this.getDateComponent("Date");return e=e.replace("DD",k(t)),e}}const rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];class sn extends V{process(e){const t=this.getDateComponent("Month");return e=e.replace("MMM",rn[t]),e=e.replace("MM",k(t+1)),e}}class an extends V{process(e){const t=this.getDateComponent("FullYear");return e=e.replace("yyyy",t),e=e.replace("YYYY",t),e=e.replace("yy",t.toString().slice(-2)),e=e.replace("YY",t.toString().slice(-2)),e}}class on extends V{process(e){let t=this.getDateComponent("Hours");const r=!this.is24Hour;if(r&&t>12&&(t-=12),r&&t===0&&(t=12),e=e.replace("HH",k(this.getDateComponent("Hours"))),e=e.replace("hh",k(t)),this.is24Hour)e=e.replace(/\s*\bA\b\s*/g," "),e=e.replace(/\s*\ba\b\s*/g," "),e=e.replace(/\s+/g," ").trim();else{if(e.includes("A")){const i=this.getDateComponent("Hours")>=12?"PM":"AM";e=e.replace(/\bA\b/g,i)}if(e.includes("a")){const i=this.getDateComponent("Hours")>=12?"pm":"am";e=e.replace(/\ba\b/g,i)}}return e=e.replace("mm",k(this.getDateComponent("Minutes"))),e=e.replace("ss",k(this.getDateComponent("Seconds"))),e}}class ln extends V{process(e){if(e.includes("Z"))if(this.isUTC)e=e.replace("Z","+0000");else{const t=this.date.getTimezoneOffset(),r=t>0?"-":"+",i=Math.abs(t),s=Math.floor(i/60),a=i%60,o=`${r}${s.toString().padStart(2,"0")}${a.toString().padStart(2,"0")}`;e=e.replace("Z",o)}if(e.includes("ddd")){const t=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],r=this.getDateComponent("Day");e=e.replace("ddd",t[r])}if(e.includes("dd")){const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=this.getDateComponent("Day");e=e.replace("dd",t[r])}return e}}function un({date:n,format:e,isUTC:t,is24Hour:r,timezoneOffset:i=0}){return[ln,nn,sn,an,on].reduce((s,a)=>new a({date:n,isUTC:t,is24Hour:r,timezoneOffset:i}).process(s),e)}function et(n,e){const t=e||"YYYY/MM/DD hh:mm",r=t.includes("HH");let i=null;if(t.includes("Z"))i=0;else if(t.includes("+")){const a=t.match(/[+-]\d{2}:?\d{2}/);if(a){const o=a[0],u=o[0]==="+"?1:-1,l=parseInt(o.slice(1,3),10),c=o.includes(":")?parseInt(o.slice(4,6),10):parseInt(o.slice(3,5),10);i=u*(l*60+c)}}const s=tn(n,i===null?0:i);return un({date:s,format:t,isUTC:i!==null,is24Hour:r,timezoneOffset:i===null?0:i})}function tt(n,e={}){const{preserveBasicWhitespace:t=!0,removeNewlines:r=!1}=e;if(typeof n!="string")return{hasControlChars:!1,matches:[],inputType:typeof n,message:"Input is not a string"};const i=[];let s;return t&&!r?s=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g:s=/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,n.replace(s,(a,o)=>(i.push({character:a,code:a.charCodeAt(0),hex:"0x"+a.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0"),position:o,context:cn(n,o,10)}),"")),{hasControlChars:i.length>0,matches:i,totalFound:i.length,inputPreview:n.length>50?n.substring(0,50)+"...":n,inputLength:n.length,optionsUsed:{preserveBasicWhitespace:t},regexPattern:s.toString()}}function cn(n,e,t=10){const r=Math.max(0,e-t),i=Math.min(n.length,e+t+1);let s=n.substring(r,i);return s=s.replace(/[\x00-\x1F\x7F-\x9F]/g,a=>"\\u"+a.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")),s}function nt(n){console.log("=== Control Character Detection Report ==="),console.log(`Input: "${n.inputPreview}" (${n.inputLength} chars)`),console.log(`Options: preserveBasicWhitespace = ${n.optionsUsed.preserveBasicWhitespace}`),console.log(`Regex pattern: ${n.regexPattern}`),console.log(`Control characters found: ${n.totalFound}`),n.hasControlChars?(console.log(`
8
+ 📋 Matches found:`),n.matches.forEach((e,t)=>{console.log(`
9
+ ${t+1}. Character: ${JSON.stringify(e.character)}`),console.log(` Code: ${e.code} (${e.hex})`),console.log(` Position: ${e.position}`),console.log(` Context: "...${e.context}..."`)})):console.log("✅ No control characters detected in Phase 1 range"),console.log("=== End Report ===")}function rt(n,e){n=n||{},e=e||{};const{firstName:t,middleName:r,noFirstName:i,prefix:s,title:a,upperCaseLastName:o=!0}=e;e.hasAsianCharacters=!1;let u=[];if((s||a)&&n.prefix){const c=de(e);u=c(u,n.prefix),u=c(u,n.title)}if(t!==!1&&!i){const c=de(e);u=c(u,n.firstName),u=c(u,n.givenName)}r===!0&&n.middleName&&(e.hasAsianCharacters=e.hasAsianCharacters||it(n.middleName.toString()),u.push(n.middleName.toString()));const l=de(e,o);return u=l(u,n.lastName),u=l(u,n.familyName),u=l(u,n.surname),e.hasAsianCharacters?u.reverse().join(""):u.join(" ")}function de(n={},e=!1){let t=!1;return(r,i)=>{if(!t&&i){t=!0,n.hasAsianCharacters=n.hasAsianCharacters||it(i.toString());const s=e?i.toString().toUpperCase():i.toString();r.push(s)}return r}}function it(n){return/[\u3400-\u9FBF]/.test(n)}function st({dataUrl:n="",filename:e=""}={}){const t=document.createElement("a");t.download=e,t.href=n,document.body.appendChild(t),t.click(),document.body.removeChild(t)}function at(n){return String(n).replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function fn({responseHelper:n,handler:e,ignoreError:t=!1}){return async(r,i,s)=>{const a=typeof i=="function"&&!s,o=a?r:null,u=a?r.request:r,l=a?r.response:i,c=a?i:s;try{return await e({req:u,res:l}),a?await c():c()}catch(d){if(t)return a?await c():c();if(!n){if(a)throw d;return c(d)}const m=d.status||400,h=d.message||"An error occurred",g=n.standardizeResponse({err:d,message:h});a?(o.status=m,o.body=g):l.status(m).json(g)}}}function dn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{query:s}=t,a=await e.findAll({query:s});r.locals.findAllResult=a,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}function hn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{params:s,query:a}=t,{id:o}=s,u=await e.findOne({query:{...a,id:o}});r.locals.findOneResult=u,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}function mn(n,{query:e={}}={}){!e.__EXCLUDED_FIELDS||Array.isArray(e.__EXCLUDED_FIELDS)&&e.__EXCLUDED_FIELDS.length===0||(n.push({$set:{__originalEmail:"$_eventRegistration.email",__originalPhone:"$_eventRegistration.phone",__queryArr:{$ifNull:[e.__EXCLUDED_FIELDS||[],[]]},__isMyself:{$eq:["$_eventRegistration.loginSubjectCode",e.__LOGIN_SUBJECT_CODE]},__isGroupCoordinator:!!e.__ALLOW_COORDINATOR,__hasEventRegistration:{$ne:["$_eventRegistration",null]}}}),n.push({$set:{__shouldShowEmail:{$and:["$__hasEventRegistration",{$or:["$__isMyself","$__isGroupCoordinator",{$not:{$in:["email","$__queryArr"]}}]}]},__shouldShowPhone:{$and:["$__hasEventRegistration",{$or:["$__isMyself","$__isGroupCoordinator",{$not:{$in:["phone","$__queryArr"]}}]}]}}}),n.push({$set:{"_eventRegistration.email":{$cond:["$__shouldShowEmail","$__originalEmail","$$REMOVE"]},"_eventRegistration.phone":{$cond:["$__shouldShowPhone","$__originalPhone","$$REMOVE"]}}}),n.push({$unset:["__originalEmail","__originalPhone","__isMyself","__isGroupCoordinator","__queryArr","__hasEventRegistration","__shouldShowEmail","__shouldShowPhone"]}))}function yn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{body:s}=t;let a;Array.isArray(s)?a=await e.saveAll({docs:s}):a=await e.saveOne({doc:s}),r.locals.postResult=a,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}function pn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{body:s,params:a}=t,{id:o}=a;if(o!==s.id)throw new Error("id in params and body must be same");const{data:u}=await e.findOne({query:{id:o}}),l=u[0];l.update(s);const c=await e.saveOne({doc:l});r.locals.updateOneResult=c,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}const ot={customHandler:fn,findAllResult:dn,findOneResult:hn,hideSensitiveFields:mn,postResult:yn,updateOneResult:pn};function lt(n){const e=/[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,}/gi,t=new Set;return n?(n.forEach(r=>{if(!(!r||typeof r!="string"||!r.trim()))try{const s=r.replace(/[\u200B-\u200D\uFEFF\u202A-\u202E]/g,"").replace(/[<>]/g," ").replace(/\s+/g," ").trim().match(e);s&&s.forEach(a=>t.add(a.toLowerCase()))}catch(i){console.warn("Failed to process entry:",r,i)}}),Array.from(t).sort((r,i)=>r.localeCompare(i))):[]}async function Z(n,e,t){return new Promise((r,i)=>{const s=n[Symbol.iterator]();let a=0;const o=async u=>{const l=s.next();if(l.done){r(u);return}try{const[c,d]=await Promise.all([u,l.value]);o(e(c,d,a++))}catch(c){i(c)}};o(t)})}class X{constructor(e){e=e||{},this.model=e.model,this._sharedOptions=e._sharedOptions,this._queryOptions=e._queryOptions,this._saveOptions=e._saveOptions,this._Class=e._constructor&&e._constructor._Class?e._constructor._Class:null}static init(e={}){return T(this,e)}static get _classname(){return"Repo"}static get _superclass(){return"Repo"}get _classname(){return"Repo"}get _superclass(){return"Repo"}get isValid(){return this.model&&typeof this.model.deleteOne=="function"&&typeof this.model.findAll=="function"&&typeof this.model.saveOne=="function"}get queryOptions(){return{...this._sharedOptions,...this._queryOptions}}get saveOptions(){return{...this._sharedOptions,...this._saveOptions}}init(e){return this._Class&&typeof this._Class.init=="function"?this._Class.init(e):e}async deleteOne({id:e}){try{return{...await this.model.deleteOne({_id:e}),isNew:!1,data:[]}}catch(t){throw t}}findAll({config:e={},query:t,systemLog:r}){const i=Q({systemLog:r,label:"REPO_READ",message:`fn ${this._classname}.prototype.findAll`,input:[{query:{...t},systemLog:{...r}}]}),s={...this.queryOptions,...e};return new Promise((a,o)=>{this.model.findAll(t,s,(u,l,c)=>{if(u)i({level:"warn",output:u.toString()}),o(u);else{const d={isNew:!1,data:l,total:c||l.length};i({level:"info",output:{...d}}),a(d)}})})}findOne({config:e={},query:t,systemLog:r}){const i=Q({systemLog:r,label:"REPO_READ",message:`fn ${this._classname}.prototype.findOne`,input:[{query:{...t},systemLog:{...r}}]}),s={...this.queryOptions,...e};return new Promise((a,o)=>{this.model.findAll(t,s,(u,l)=>{if(u)o(u);else if(l.length===1){const c={isNew:!1,data:l,total:1};i({level:"info",output:{...c}}),a(c)}else l.length===0?o(new Error("record not found")):o(new Error("more than one is found"))})}).catch(a=>{throw i({level:"warn",output:a.toString()}),a})}saveAll({config:e={},docs:t,systemLog:r}){let i;const s=Q({systemLog:r,label:"REPO_WRITE",message:`fn ${this._classname}.prototype.saveAll`,input:[{config:e,docs:[...t],systemLog:{...r}}]});return(typeof this.model.saveAll=="function"?this.model.saveAll({config:e,docs:t}):gn({config:e,docs:t,service:this})).then(o=>{o.length!==1&&(i=null);const u={data:o,isNew:i,total:o.length};return s({level:"info",output:{...u}}),u}).catch(o=>{throw s({level:"warn",output:o.toString()}),o})}saveOne({config:e={},doc:t,systemLog:r}){const i=Q({systemLog:r,label:"REPO_WRITE",message:`fn ${this._classname}.prototype.saveOne`,input:[{config:e,doc:{...t},systemLog:{...r}}]}),s={...this.saveOptions,...e};return new Promise((a,o)=>{this.model.saveOne(t,s,(u,l)=>{u?(i({level:"warn",output:u.toString()}),o(u)):(i({level:"info",output:{...l}}),a(l))})})}}function Q({systemLog:n,label:e,message:t,input:r}={}){return({level:i,messgae:s,output:a}={})=>{n&&n.systemLogHelper&&n.systemLogHelper.log({batchId:n.batchId,label:e,level:i,message:s||t,data:{payload:{input:r,output:a}}})}}async function gn({config:n={},docs:e,service:t}){let r=null;return n.session||t.saveOptions.session?r=await _e(e,async i=>{if(i){const s=await t.saveOne({config:n,doc:i});return(s._data||s.data)[0]}return null},{concurrency:1}):r=await Promise.all(e.map(async i=>{if(i){const s=await t.saveOne({config:n,doc:i});return(s._data||s.data)[0]}return null})),r}class he{constructor(e={}){e=e||{},this._data=e.data||e._data||[],this.err=e.err,this.isNew=e.isNew||!1,this.message=e.message,this.total=e.total||0,this._instanceBuilder=e._instanceBuilder}static init(e={}){return e instanceof this?e:new this(e)}static get _classname(){return"ApiResponse"}static get _superclass(){return"ApiResponse"}get data(){return this._instanceBuilder&&typeof this._instanceBuilder=="function"?this._data.map(this._instanceBuilder):this._data}}function N({repo:n,result:e}){return he.init({...e,_instanceBuilder:t=>n.init(t)})}class me{constructor({repo:e}){this.repo=e}static get _classname(){return"Service"}static get _superclass(){return"Service"}async deleteOne({id:e}){const t=await this.repo.deleteOne({id:e});return N({repo:this.repo,result:t})}async findAll({config:e={},query:t={},systemLog:r}={}){const i=await this.repo.findAll({config:e,query:t,systemLog:r});return N({repo:this.repo,result:i})}async findOne({config:e={},query:t={},systemLog:r}={}){const i=await this.repo.findOne({config:e,query:t,systemLog:r});return N({repo:this.repo,result:i})}init(e){return this.repo.init(e)}initFromArray(e=[]){return Array.isArray(e)?e.map(t=>this.init(t)):[]}initOnlyValidFromArray(e=[]){return this.initFromArray(e).filter(t=>t)}async saveAll({config:e={},docs:t=[],systemLog:r}={}){const i=t.map(a=>e.skipInit?a:this.init(a)),s=await this.repo.saveAll({config:e,docs:i,systemLog:r});return N({repo:this.repo,result:s})}async saveOne({config:e={},doc:t={},systemLog:r}={}){const i=e.skipInit?t:this.init(t);if(i){const s=await this.repo.saveOne({config:e,doc:i,systemLog:r});return N({repo:this.repo,result:s})}return{isNew:null,data:[],err:new Error("doc is not a valid instance")}}}function ye({repo:n}){if(n===void 0)throw new Error("repo is required.");if(n._superclass!==X._superclass)throw new Error("repo is not an instance of Repo.");return new me({repo:n})}async function ut({body:n={},GeneralModel:e,UniqueKeyGenerator:t,resourceInfo:r}){const{resources:i,data:s,globalShared:a={},shared:o={},relationship:u={}}=n,l=r||n.resourceInfo;return _n(s,a,o),await Z(i,async(d,m)=>{const h=An(m,l,t,e);wn(s,u[m],d);const g=s[m],v=await h.saveAll({docs:[].concat(g)});return d[m]=Array.isArray(g)?v._data:v._data[0],d},{})}function _n(n,e={},t={}){Object.keys(t).forEach(r=>{const i=n[r];Array.isArray(i)?n[r]=i.map(s=>b.merge({},s,e,t[r]||{})):n[r]=b.merge({},i,e,t[r]||{})})}function wn(n,e={},t){Object.keys(e).forEach(r=>{const i=e[r],s=b.get(t,i);b.set(n,r,s)})}function An(n,e,t,r){const{collectionName:i,fields:s}=e[n],a=t.makeGenerator(s),o=new r({collectionName:i,uniqueKeyGenerator:a});return ye({repo:new X({model:o})})}function pe(n,e,t,r,i){const s=i||E;return!Array.isArray(n)||n.length===0?null:n.reduce((a,o)=>{const{key:u,type:l,value:c,restriction:d}=o;if(r&&typeof r=="function"?r({rule:d,data:e}):!0){let h=c;switch(l){case"array":{h=c.map(g=>t({keys:g.value.split("."),obj:e}));break}case"fromKeyValue":{const{dataPath:g,key:v}=c,D=t({keys:g.split("."),obj:e});h=s.getValuesByKey(D,v)[0];break}case"toKeyValue":{const g=t({keys:c.split("."),obj:e});h=s.fromObject(g);break}case"nested":{h=pe(c,e,t,r);break}case"path":{h=t({keys:c.split("."),obj:e});break}case"orgin":{h=c;break}case"origin":{h=c;break}default:{h=c;break}}return u?{...a,[u]:h}:typeof h=="string"?h:{...a,...h}}return a},{})}function ct(n,e){return!e||typeof e!="string"?{}:n.reduce((t,r)=>(t[r[e]]||(t[r[e]]=0),t[r[e]]++,t),{})}function T(n,e){if(e instanceof n)return e;try{const t=new n(e);return t.isValid!==!1?t:null}catch(t){return console.log(`init failed for class: ${n._classname||"no _classname"}`,t),null}}function B(n,e){return Array.isArray(e)?e.map(t=>T(n,t)):[]}function ee(n,e){return B(n,e).filter(t=>t)}function ft(n,e){const t=Array.isArray(n)?n:[],r=Array.isArray(e)?e:[],i=new Map,s=(a,o)=>a===void 0?o:Array.isArray(a)&&Array.isArray(o)?[...new Set([...a,...o])]:typeof a=="object"&&typeof o=="object"&&!Array.isArray(a)&&!Array.isArray(o)?{...a,...o}:o;return t.forEach(a=>{i.set(a.key,a.value)}),r.forEach(a=>{const o=i.get(a.key);i.set(a.key,s(o,a.value))}),Array.from(i.entries()).map(([a,o])=>({key:a,value:o}))}function ge(n,e=6){return n=n.toString(),n.length<e?ge(`0${n}`,e):n}async function _e(n,e,{concurrency:t=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:i}={}){return new Promise((s,a)=>{if(n[Symbol.iterator]===void 0&&n[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof n})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(t)&&t>=1||t===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${t}\` (${typeof t})`);const o=[],u=[],l=new Map;let c=!1,d=!1,m=!1,h=0,g=0;const v=n[Symbol.iterator]===void 0?n[Symbol.asyncIterator]():n[Symbol.iterator](),D=()=>{L(i.reason)},Tt=()=>{i==null||i.removeEventListener("abort",D)},It=R=>{s(R),Tt()},L=R=>{c=!0,d=!0,a(R),Tt()};i&&(i.aborted&&L(i.reason),i.addEventListener("abort",D,{once:!0}));const $e=async()=>{if(d)return;const R=await v.next(),q=g;if(g++,R.done){if(m=!0,h===0&&!d){if(!r&&u.length>0){L(new AggregateError(u));return}if(d=!0,l.size===0){It(o);return}const M=[];for(const[j,Vn]of o.entries())l.get(j)!==x&&M.push(Vn);It(M)}return}h++,(async()=>{try{const M=await R.value;if(d)return;const j=await e(M,q);j===x&&l.set(q,j),o[q]=j,h--,await $e()}catch(M){if(r)L(M);else{u.push(M),h--;try{await $e()}catch(j){L(j)}}}})()};(async()=>{for(let R=0;R<t;R++){try{await $e()}catch(q){L(q);break}if(m||c)break}})()})}function dt(n,e,{concurrency:t=Number.POSITIVE_INFINITY,backpressure:r=t}={}){if(n[Symbol.iterator]===void 0&&n[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof n})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(t)&&t>=1||t===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${t}\` (${typeof t})`);if(!(Number.isSafeInteger(r)&&r>=t||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${t}) and up or \`Infinity\`, got \`${r}\` (${typeof r})`);return{async*[Symbol.asyncIterator](){const i=n[Symbol.asyncIterator]===void 0?n[Symbol.iterator]():n[Symbol.asyncIterator](),s=[];let a=0,o=!1,u=0;function l(){if(o||!(a<t&&s.length<r))return;a++;const c=(async()=>{const{done:d,value:m}=await i.next();if(d)return a--,{done:!0};l();try{const h=await e(await m,u++);if(a--,h===x){const g=s.indexOf(c);g>0&&s.splice(g,1)}return l(),{done:!1,value:h}}catch(h){return a--,o=!0,{error:h}}})();s.push(c)}for(l();s.length>0;){const{error:c,done:d,value:m}=await s[0];if(s.shift(),c)throw c;if(d)return;l(),m!==x&&(yield m)}}}}const x=Symbol("skip");function ht({engine:n,template:e,value:t}={}){if(!e)return"";const r=n.init(t),i=/\{\{\s(.*?)\s\}\}/g;return e.replace(i,s=>{const a=r.pipe(s);return a==null?"":typeof a=="object"?JSON.stringify(a):a})}function mt({content:n,mapping:e}){let t=!1;typeof n=="object"&&n!==null&&(n=JSON.stringify(n),t=!0);const r=/\[\[\s*([^[\]]+?)\s*\]\]/g,i=n.replace(r,(s,a)=>{const o=a.trim();if(/^[\w.\-]+$/.test(o)){const u=o.split(".");let l=e;for(const c of u)if(c&&(l=l==null?void 0:l[c],l===void 0))break;if(l!==void 0)return l}return`<%= ${o} %>`});return t?JSON.parse(i):i}function yt(n,e={}){const{normalizeWhitespace:t=!0,removeNewlines:r=!1,trim:i=!0,preserveBasicWhitespace:s=!0,debug:a=!1}=e;if(typeof n!="string")return n;let o=n;if(a&&(console.log("Original input:",JSON.stringify(n)),console.log("Options:",{normalizeWhitespace:t,removeNewlines:r,trim:i,preserveBasicWhitespace:s})),s&&!r)if(a){const u=[];o=o.replace(/[\x00-\x08\v\f\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,l=>(u.push({char:l,code:l.charCodeAt(0),hex:`0x${l.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")}`}),"")),u.length>0?(console.log("Phase 1 (preserve mode) - Removed characters:"),u.forEach(l=>{console.log(` - Character: ${JSON.stringify(l.char)}, Code: ${l.code}, Hex: ${l.hex}`)}),console.log(`Removed ${u.length} control character(s)`)):console.log("Phase 1 (preserve mode) - No control characters found")}else o=o.replace(/[\x00-\x08\v\f\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,"");else if(a){const u=[];o=o.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,l=>(u.push({char:l,code:l.charCodeAt(0),hex:`0x${l.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")}`}),"")),u.length>0?(console.log("Phase 1 (full removal mode) - Removed characters:"),u.forEach(l=>{console.log(` - Character: ${JSON.stringify(l.char)}, Code: ${l.code}, Hex: ${l.hex}`)}),console.log(`Removed ${u.length} control character(s)`)):console.log("Phase 1 (full removal mode) - No control characters found")}else o=o.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,"");return a&&console.log("After Phase 1:",JSON.stringify(o)),r&&(a?(o=o.replace(/[\r\n]+/g," "),console.log("Phase 2 - Converted newlines to spaces")):o=o.replace(/[\r\n]+/g," ")),t&&(a?(o=o.replace(/[ \t]+/g," "),console.log("Phase 2 - Normalized whitespace")):o=o.replace(/[ \t]+/g," ")),a&&console.log("After Phase 2:",JSON.stringify(o)),i&&(a?(o=o.trim(),console.log("Phase 3 - Trimmed leading/trailing whitespace")):o=o.trim()),a&&(console.log("Final result:",JSON.stringify(o)),console.log("--- Sanitization complete ---")),o}function we(n){return n&&typeof n.toString=="function"?n.toString():n}function pt(n){const e=[...n];for(let t=e.length-1;t>=0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e}function U(n,e="_"){return n===null||typeof n>"u"||typeof n.toString>"u"?null:n.toString().trim().toUpperCase().replace("-",e).replace(" ",e)}function En(n,e=34){const t=Cn(e);return bn(n,t)}function bn(n,e){const{byCode:t}=e;if(n===0)return t[0];let r="";const i=e.length;for(;n>0;)r=t[n%i]+r,n=Math.floor(n/i);return r}function Cn(n){let e="9876543210ABCDEFGHJKLMNPQRSTUVWXYZ";return n===58&&(e="9876543210ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz"),$n(e)}function Sn(n){return gt(`${n}`).toLowerCase().split(" ").join("-")}function $n(n){const e={},t={},{length:r}=n;let i;for(let s=0;s<r;s++)i=n[s],e[s]=i,t[i]=s;return{byCode:e,byChar:t,length:r}}function vn(n,e){return typeof n!="string"||typeof e!="string"?!1:n.trim().toUpperCase()===e.trim().toUpperCase()}function gt(n){return n.replace(/\s+/g,"-").replace(/[.,\/#!$%\^&\*;:{}=\_`~()]/g,"")}function On({len:n=16,pattern:e="a1"}={}){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",r="abcdefghijklmnopqrstuvwxyz",i="1234567890",s="~!@#$%^&*_+-=";let a="";e.includes("A")&&(a+=t),e.includes("a")&&(a+=r),e.includes("1")&&(a+=i),e.includes("#")&&(a+=s);const o=[...a];return[...new Array(n)].map(u=>o[Math.random()*o.length|0]).join``}function Rn(n){return(typeof n!="string"?n.toString():n).split("").reverse().join("")}function Tn(n){return typeof(n==null?void 0:n.toUpperCase)=="function"?n.toUpperCase():""}function In(n){let e=34,t=8;n===void 0||(typeof n=="number"?e=n:typeof n=="object"&&n!==null&&(e=n.base??e,t=n.len??t));const r=new Date().valueOf(),i=On({len:t,pattern:"1"}),s=Rn(`${r}${i}`);return En(s,e)}function Nn(n){return n?n.trim().split(/\s+/).map((e,t)=>e?t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"").join(""):""}function Dn(n){return n?n.trim().toLowerCase():""}function Mn(n){return/[^\w\s]|_/g.test(n.replace(/_/g,""))?null:n.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/[\s\-\.]+/g,"_").toUpperCase().replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")}const te={getCssClass:Sn,isSame:vn,punctuationless:gt,safeToUpperCase:Tn,setCode:In,toCamelCase:Nn,toLowerCase:Dn,toScreamingSnakeCase:Mn};function Ae(n,e){n.add({meta:{active:{type:Boolean,default:!0},created:{type:Number},creator:{type:String},deleted:{type:Boolean,default:!1},modified:{type:Number},owner:{type:String}}}),n.pre("save",function(t){this.meta.modified=Date.now(),t()}),n.index({"meta.active":1,"meta.deleted":1},{name:"tracking_status_index",background:!0,partialFilterExpression:{"meta.active":!0,"meta.deleted":!1}})}function _t(n,e){n.path("meta")||Ae(n),n.add({metadata:[{type:Object}],remarks:[{type:Object}],tenantCode:{type:String,required:!0}}),n.index({tenantCode:1},{name:"tenant_core_index",background:!0}),n.indexes().some(i=>i.name==="tenant_status_index")||n.index({tenantCode:1,_type:1},{name:"tenant_status_index",background:!0,partialFilterExpression:{_type:"Tenant","meta.active":!0,"meta.deleted":!1}})}const jn=Object.freeze(Object.defineProperty({__proto__:null,authorize:S,calculateAge:I,changeCreatorOwner:ie,concatStringByArray:J,convertString:Qe,convertTimestampToString:et,detectControlCharacters:tt,displayName:rt,downloadFileByUrl:st,escapeRegex:at,expressHelper:ot,extractEmails:lt,formatDate:oe,generalPost:ut,getObjectByArr:pe,getValidation:C,getValueByKeys:_,groupArrayByKey:ct,init:T,initFromArray:B,initOnlyValidFromArray:ee,isConvertibleToNumber:z,mergeArraysByKey:ft,objectHelper:b,pMap:_e,pMapIterable:dt,pMapSkip:x,pReduce:Z,padZeros:ge,printControlCharReport:nt,renderByTemplate:ht,replacePlaceholders:mt,sanitizeText:yt,setId:we,shuffleArray:pt,stringFormatter:U,stringHelper:te,tenantPlugin:_t,trackingPlugin:Ae},Symbol.toStringTag,{value:"Module"}));class wt{constructor(e){e=e||{},this.expiration=e.expiration||null,this.s3Client=e.s3Client||null,this.getIdToken=e.getIdToken,this.region=e.region||"ap-east-1",this.roleArn=e.roleArn,this.roleSessionName=e.roleSessionName||"web-identity-session",this.durationSession=e.durationSession||3600,this.awsClientSts=e.awsClientSts,this.awsClientS3=e.awsClientS3}static dummyData(){return{getIdToken:()=>"mock-web-identity-token",roleArn:"arn:aws:iam::846252828949:role/oidcS3Jccpa",awsClientSts:{STSClient:class{},AssumeRoleWithWebIdentityCommand:class{}},awsClientS3:{S3Client:class{},PutObjectCommand:class{},GetObjectCommand:class{},DeleteObjectCommand:class{}}}}static init(e={}){if(e instanceof this)return e;try{const t=new this(e);return t.isValid?t:null}catch{return null}}get isExpired(){if(!this.expiration)return!0;const e=new Date,t=1*60*1e3;return e>=new Date(this.expiration.getTime()-t)}get isValid(){if(!this.getIdToken)throw new Error("Missing required configuration: getIdToken function");if(!this.roleArn)throw new Error("Missing required configuration: roleArn");if(!this.awsClientSts)throw new Error("Missing required AWS awsClientSts client configuration");if(!this.awsClientSts.STSClient)throw new Error("Missing STSClient in AWS awsClientSts client configuration");if(!this.awsClientSts.AssumeRoleWithWebIdentityCommand)throw new Error("Missing AssumeRoleWithWebIdentityCommand in AWS awsClientSts client configuration");if(!this.awsClientS3)throw new Error("Missing required AWS awsClientS3 client configuration");const e=["S3Client","PutObjectCommand","GetObjectCommand","DeleteObjectCommand"];for(const t of e)if(!this.awsClientS3[t])throw new Error(`Missing ${t} in AWS awsClientS3 client configuration`);return!0}async refreshCredentials(){try{if(!await this.getIdToken())throw new Error("getIdToken function returned empty or invalid token");const i=(await new this.awsClientSts.STSClient({region:this.region}).send(new this.awsClientSts.AssumeRoleWithWebIdentityCommand({RoleArn:this.roleArn,RoleSessionName:this.roleSessionName,WebIdentityToken:await this.getIdToken(),DurationSeconds:this.durationSession}))).Credentials;if(!i)throw new Error("No credentials returned from awsClientSts");return this.expiration=i.Expiration,this.s3Client=new this.awsClientS3.S3Client({region:this.region,credentials:{accessKeyId:i.AccessKeyId,secretAccessKey:i.SecretAccessKey,sessionToken:i.SessionToken}}),this}catch(e){throw new Error(`Failed to refresh credentials: ${e.message}`)}}async getS3Client(){return(this.isExpired||!this.s3Client)&&await this.refreshCredentials(),this.s3Client}async putObject(e){try{const t=await this.getS3Client(),r=new this.awsClientS3.PutObjectCommand(e);await t.send(r);const i=e.Key.split("/");return{url:`https://s3.${this.region}.amazonaws.com/${e.Bucket}/${e.Key}`,filename:i.pop(),folder:e.Bucket,subFolders:i}}catch(t){throw new Error(`Failed to put object: ${t.message}`)}}async getObject(e){try{const t=await this.getS3Client(),r=new this.awsClientS3.GetObjectCommand(e),i=await t.send(r);return{body:i.Body,contentType:i.ContentType,lastModified:i.LastModified,contentLength:i.ContentLength}}catch(t){throw new Error(`Failed to get object: ${t.message}`)}}async deleteObject(e){try{const t=await this.getS3Client(),r=new this.awsClientS3.DeleteObjectCommand(e);return await t.send(r),!0}catch(t){throw new Error(`Failed to delete object: ${t.message}`)}}}const Ee="_";class O extends E{static init(e={}){if(e instanceof this)return e;const t=new this({...e,key:U(e.key,Ee)});return t.isValid?t:null}static get _classname(){return"Metadata"}static mapToKeyValue(e=[],t="key",r="value"){return Array.isArray(e)?e.reduce((i,s)=>{if(s&&typeof s=="object"){const a=b.get(s,t),o=b.get(s,r);if(a!=null){const u=o!==void 0?te.toScreamingSnakeCase(String(o)):"";i.push(this.init({key:a,value:u}))}}return i},[]):[]}static merge(e,t){return(t||[]).map(r=>{const i=e.find(s=>At(s.key,r.key));return i?i.value=kn(r.value,i.value):e.push(r),r}),e}static sameKey(e,t){return At(e.key,t)}}function At(n,e){return U(n,Ee)===U(e,Ee)}function kn(n,e){return n===void 0?e:Array.isArray(n)&&Array.isArray(e)?[...new Set([...n,...e])]:typeof n=="object"&&typeof e=="object"&&!Array.isArray(n)&&!Array.isArray(e)?{...n,...e}:e}class K{constructor(e={}){var i,s,a,o,u,l;e=e||{};const t=e._id||e.id;this.id=we(t),this._type=e._type||"TrackedEntity";const r=Date.now();this.meta={active:((i=e.meta)==null?void 0:i.active)??e.active??!0,created:((s=e.meta)==null?void 0:s.created)??(e.created?new Date(e.created).getTime():r),creator:((a=e.meta)==null?void 0:a.creator)??e.creator??"",deleted:((o=e.meta)==null?void 0:o.deleted)??e.deleted??!1,modified:((u=e.meta)==null?void 0:u.modified)??(e.modified?new Date(e.modified).getTime():r),owner:((l=e.meta)==null?void 0:l.owner)??e.owner??""}}static dummyData(){const e=Date.now();return{meta:{active:!0,deleted:!1,created:e,creator:"creator",modified:e,owner:"owner"}}}static get _classname(){return"TrackedEntity"}static get _superclass(){return"TrackedEntity"}static init(e={}){return T(this,e)}static initFromArray(e=[]){return B(this,e)}static initOnlyValidFromArray(e=[]){return ee(this,e)}get __valid(){return{}}get isValid(){return!!this}get active(){var e;return((e=this.meta)==null?void 0:e.active)??this.active}get created(){var e;return((e=this.meta)==null?void 0:e.created)??this.created}get creator(){var e;return((e=this.meta)==null?void 0:e.creator)??this.creator}get deleted(){var e;return((e=this.meta)==null?void 0:e.deleted)??this.deleted}get modified(){var e;return((e=this.meta)==null?void 0:e.modified)??this.modified}get owner(){var e;return((e=this.meta)==null?void 0:e.owner)??this.owner}changeCreatorOwner({source:e,target:t}){return ie(this,{source:e,target:t}).setModified()}delete(){return this.setDeleted()}setActive(){return this.meta?this.meta.active=!0:this.active=!0,this}setDeleted(){return this.meta?this.meta.deleted=!0:this.deleted=!0,this}setModified(){const e=Date.now();return this.meta?this.meta.modified=e:this.modified=e,this}setOwner(e){return e?(this.meta?this.meta.owner=e:this.owner=e,this):this}unsetActive(){return this.meta?this.meta.active=!1:this.active=!1,this}unsetDeleted(){return this.meta?this.meta.deleted=!1:this.deleted=!1,this}update(e){const t=this.constructor.ALLOWED_META_PROPS,r={...this.meta};return e.meta&&t.forEach(i=>{e.meta.hasOwnProperty(i)&&(r[i]=e.meta[i])}),t.forEach(i=>{e.hasOwnProperty(i)&&(r[i]=e[i])}),JSON.stringify(this.meta)!==JSON.stringify(r)&&(this.meta=r),this.setModified()}}Nt(K,"ALLOWED_META_PROPS",["active","deleted","owner"]);class Et extends K{constructor(e){e=e||{},super(e),this.id=e.id,this.body=e.body,this.data=e.data,this.dirty=e.dirty,this.metadata=O.initOnlyValidFromArray(e.metadata),this.remarks=E.initOnlyValidFromArray(e.remarks),this.threadID=e.threadID,this.title=e.title}static get _classname(){return"PushEnvelope"}static get _superclass(){return"PushEnvelope"}static init(e={}){return T(this,e)}get _classname(){return"PushEnvelope"}get _superclass(){return"PushEnvelope"}get isValid(){return super.isValid&&this.data}}const A={trace:{weight:10,name:"TRACE"},debug:{weight:20,name:"DEBUG"},info:{weight:30,name:"INFO"},warn:{weight:40,name:"WARN"},error:{weight:50,name:"ERROR"},critical:{weight:60,name:"CRITICAL"},alert:{weight:70,name:"ALERT"},emergency:{weight:80,name:"EMERGENCY"}};class be{constructor(e={}){e=e||{},this.data=e.data,this.level=e.level,this.timestamp=e.timestamp,this.stackTrace=xn(e),this.name=e.name??"",this.zone=e.zone}toString(){return`[${this.logName(this)}] ${this.serialize(this)}
10
+ ${this.stackTrace||""}
11
+ ${this.zone||""}`}logName(){let e=`${this.timestamp}`;return this.level.name&&(e+=`>${this.level.name}`),this.name&&(e+=`>${this.name}`),e}serialize(){var e;return this.data instanceof Error||typeof((e=this.data)==null?void 0:e.message)<"u"?this.data.message:this.data===null?"null":this.data===void 0?"undefined":typeof this.data=="object"?JSON.stringify(this.data):this.data.toString()}}function xn(n){var e;return n.stackTrace?n.stackTrace:n.data instanceof Error||typeof((e=n.data)==null?void 0:e.stack)<"u"?n.data.stack:null}let Ce;class F{constructor(e={}){const{level:t}=e;this._level=t??A.debug,this._handlers=new Map}static getInstance(e){return Ce||(Ce=new F(e)),Ce}setLevel(e){return this._level=e,this}addHandler(e){return e instanceof F&&this._handlers.set(e.constructor,e),this}removeHandler(e){return this._handlers.delete(e),this}receive({record:e}){var t,r;((t=e.level)==null?void 0:t.weight)<((r=this._level)==null?void 0:r.weight)||(this._handlers.forEach(i=>{i.receive({record:e})}),this.logBody(e))}logBody(e){}trace(e,t){return this._log({level:A.trace,object:t,options:e})}debug(e,t){return this._log({level:A.debug,object:t,options:e})}info(e,t){return this._log({level:A.info,object:t,options:e})}warn(e,t){return this._log({level:A.warn,object:t,options:e})}error(e,t){return this._log({level:A.error,object:t,options:e})}critical(e,t){return this._log({level:A.critical,object:t,options:e})}_log({level:e,object:t,options:r}){typeof t>"u"&&(t=r,r="");const i=Date.now(),s=new be({data:t,level:e,timestamp:i,stackTrace:(t==null?void 0:t.stack)??(r==null?void 0:r.stack)??null,name:r??""});return this.receive({record:s})}}class bt extends F{constructor(e={}){const{format:t}=e;super(e),this.format=t}logBody(e){const t=e.logName(),r=this.format?this.format(e):e.serialize();switch(e.level){case A.error:case A.critical:case A.alert:case A.emergency:console.error(`[${t}] ${r}`,e.stackTrace||"");break;case A.warn:console.warn(`[${t}] ${r}`,e.stackTrace||"");break;case A.info:console.error(`[${t}] ${r}`,e.stackTrace||"");break;case A.debug:console.error(`[${t}] ${r}`,e.stackTrace||"");break;default:console.error(`[${t}] ${r}`,e.stackTrace||"")}}}const ne={debug:{name:"DEBUG"},production:{name:"PRODUCTION"}};function Ct(n){const e=n.toLowerCase();return ne[e]?ne[e]:null}const Fn=["attributes","ref"];class H{constructor(e={}){e=e||{},this.attributes=E.initOnlyValidFromArray(e.attributes),this.ref=e.ref||{}}static get _classname(){return"QMeta"}static get _superclass(){return"QMeta"}static init(e={}){return e instanceof H?e:new H(e)}addAttribute(e){const t=E.init(e);if(!t)throw new Error("invalid meta attribute");return this.attributes.push(t),this}update(e){return Object.keys(e).forEach(t=>{Fn.includes(t)&&(t==="attributes"?this[t]=E.initOnlyValidFromArray(e[t]):this[t]=e[t])}),this}}class re{constructor(e){e=e||{};const{_Actor:t}=e._constructor||{};this._Actor=t,this._actor=e._actor,this.actorCode=typeof e=="number"?null:e.actorCode||null,this.timestamp=typeof e=="number"?e:e.timestamp||null}static get _classname(){return"ActionRecord"}static get _superclass(){return"ActionRecord"}static dummyData(){return{timestamp:new Date().valueOf()}}static init(e={}){return T(this,e)}get _classname(){return"ActionRecord"}get _superclass(){return"ActionRecord"}get actor(){return this._Actor&&typeof this._Actor.init=="function"?this._Actor.init(this._actor):this._actor}get isValid(){return!!this.timestamp}update(e){return typeof e=="number"?(this.timestamp=e,this):(Object.keys(e).forEach(t=>{this[t]=e[t]}),this)}}const Pn=["_ActionRecord","created"];class Se{constructor(e){e=e||{};const{_ActionRecord:t}=e._constructor||{};this._ActionRecord=t&&t._superclass===re._superclass?t:re,this.created=this._ActionRecord.init(e.created||{timestamp:new Date().valueOf()})}static get _classname(){return"Status"}static get _superclass(){return"Status"}static dummyData(){return{}}static init(e={}){return T(this,e)}static initFromArray(e=[]){return B(this,e)}static initOnlyValidFromArray(e=[]){return ee(this,e)}get _classname(){return"Status"}get _superclass(){return"Status"}get isCreated(){var e;return((e=this.created)==null?void 0:e.timestamp)!==null}get isValid(){return!!this}setValue(e,t,r){const i=e||Date.now();return this[r]=this[r]instanceof this._ActionRecord?this[r].update({actorCode:t,timestamp:i}):this._ActionRecord.init({actorCode:t,timestamp:i}),this}update(e){return Object.keys(e).forEach(t=>{Pn.includes(t)||(this[t]=this[t]instanceof this._ActionRecord?this[t].update(e[t]):this._ActionRecord.init(e[t]))}),this}}class St extends Se{constructor(e){e=e||{},super(e),this.archived=this._ActionRecord.init(e.archived),this.completed=this._ActionRecord.init(e.completed),this.discarded=this._ActionRecord.init(e.discarded),this.drafted=this._ActionRecord.init(e.drafted)}static get _classname(){return"StatusDocument"}get _classname(){return"StatusDocument"}get isArchived(){var e;return((e=this.created)==null?void 0:e.timestamp)!==null}get isCompleted(){var e;return((e=this.completed)==null?void 0:e.timestamp)!==null}get isDiscarded(){var e;return((e=this.discarded)==null?void 0:e.timestamp)!==null}get isDrafted(){var e;return((e=this.drafted)==null?void 0:e.timestamp)!==null}get isValid(){return super.isValid}setArchived(e,t){return this.setValue(e,t,"archived")}setCompleted(e,t){return this.setValue(e,t,"completed")}setDiscarded(e,t){return this.setValue(e,t,"discarded")}setDrafted(e,t){return this.setValue(e,t,"drafted")}}class $t extends K{constructor(e={}){e=e||{},super(e),this._type=e._type||"TenantAwareEntity",this._tenant=e._tenant,this.metadata=O.initOnlyValidFromArray(e.metadata),this.remarks=E.initOnlyValidFromArray(e.remarks),this.tenantCode=e.tenantCode}static dummyData(){return{...super.dummyData(),metadata:[],remarks:[],tenantCode:"tenantCode"}}static get _classname(){return"TenantAwareEntity"}static get _superclass(){return"TenantAwareEntity"}get __valid(){return{...super.__valid,tenantCode:this.tenantCode}}get isValid(){return super.isValid&&!!this.tenantCode}insertOrUpdateMetadata(e,t){return this.metadata=O.insertOrUpdateRecord(this.metadata,e,t),this}getMetadata(){return this.metadata}getMetadataByKey(e){return O.foundByKey(this.metadata,e)}getMetadataValueByKey(e){const t=this.getMetadataByKey(e);return t?t.value:null}getMetadataValueByKeys(e,t){if(!Array.isArray(e))return null;if(t=t||this.metadata,e.length===0)return t;const r=e.shift(),i=O.getMetadataValueByKeyAsArray(t,r);return this.getMetadataValueByKeys(e,i)}getMetadataValueByKeyAsArray(e){return O.getMetadataValueByKeyAsArray(this.metadata,e)}getRemarks(){return this.remarks}getRemarkByKey(e){return E.foundByKey(this.remarks,e)}getRemarksValueByKey(e){const t=this.getRemarkByKey(e);return t?t.value:null}getTenantCode(){return this.tenantCode}update(e){return e.metadata&&Array.isArray(e.metadata)&&(this.metadata=O.initOnlyValidFromArray(e.metadata)),e.remarks&&Array.isArray(e.remarks)&&(this.remarks=E.initOnlyValidFromArray(e.remarks)),super.update(e)}}class vt{static get _classname(){return"UniqueKeyGenerator"}static get _superclass(){return"UniqueKeyGenerator"}static makeFormatter({fieldName:e,format:t,options:r}){switch(t){case"set_code":return Ot(e);default:return Ot(e)}}static makeGenerator(e){const t=e.map(r=>this.makeFormatter(r));return async r=>await Z(t,async(s,a)=>{const o=await a(r);return Object.assign(s,o)},r)}}function Ot(n,e){return async(t={})=>t[n]?{}:{[n]:te.setCode()}}class W{constructor(e={}){this.blockUI=e.blockUI??!1,this.callback=e.callback??null,this.data=e.data??null,this.event=e.event??null,this.reloadPage=e.reloadPage??!1,this.sessionId=e.sessionId??null,this.timeout=e.timeout??3e4}static get _classname(){return"WebAppRequest"}static get _superclass(){return"WebAppRequest"}static init(e){if(e instanceof W)return e;const t=new W(e);return t.isValid?t:null}static dummyData(){return{data:null,sessionId:"sessionId"}}get isValid(){return!!this.sessionId}getId(){try{return this.sessionId}catch{return null}}}const Rt={EXCUTE_EVENT_ERROR:"EXCUTE_EVENT_ERROR",NOT_FOUND:"NOT_FOUND",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",UNAUTHORIZED:"UNAUTHORIZED",VALIDATION_ERROR:"VALIDATION_ERROR"};class P{constructor(e={}){this.code=e.code??null,this.message=e.message??"",this.timestamp=e.timestamp??null}static init(e){if(e instanceof P)return e;const t=new P(e);return t.isValid?t:null}get isValid(){return!!this.code}}class Y{constructor(e={}){this.data=e.data??null,this.errorDetail=P.init(e.errorDetail),this.sessionId=e.sessionId??null,this.success=e.success??!1}static get _classname(){return"WebAppResponse"}static get _superclass(){return"WebAppResponse"}static init(e){if(e instanceof Y)return e;const t=new Y(e);return t.isValid?t:null}static dummyData(){return{data:null,errorDetail:null,sessionId:"sessionId",success:!1}}get isValid(){return!!this.sessionId}getId(){try{return this.sessionId}catch{return null}}}const Ln={...jn,...Object.freeze(Object.defineProperty({__proto__:null,ActionRecord:re,ApiResponse:he,AwsStsS3Client:wt,ConsoleLog:bt,ERROR_CODES:Rt,ErrorDetail:P,KeyValueObject:E,LogRecord:be,Metadata:O,PushEnvelope:Et,QLog:F,QLogEnv:ne,QLogLevel:A,QMeta:H,Repo:X,Service:me,Status:Se,StatusDocument:St,TemplateCompiler:ce,TenantAwareEntity:$t,TrackedEntity:K,UniqueKeyGenerator:vt,WebAppRequest:W,WebAppResponse:Y,getQLogEnv:Ct,makeApiResponse:N,makeService:ye},Symbol.toStringTag,{value:"Module"}))};f.ActionRecord=re,f.ApiResponse=he,f.AwsStsS3Client=wt,f.ConsoleLog=bt,f.ERROR_CODES=Rt,f.ErrorDetail=P,f.KeyValueObject=E,f.LogRecord=be,f.Metadata=O,f.PushEnvelope=Et,f.QLog=F,f.QLogEnv=ne,f.QLogLevel=A,f.QMeta=H,f.Repo=X,f.Service=me,f.Status=Se,f.StatusDocument=St,f.TemplateCompiler=ce,f.TenantAwareEntity=$t,f.TrackedEntity=K,f.UniqueKeyGenerator=vt,f.WebAppRequest=W,f.WebAppResponse=Y,f.authorize=S,f.calculateAge=I,f.changeCreatorOwner=ie,f.concatStringByArray=J,f.convertString=Qe,f.convertTimestampToString=et,f.default=Ln,f.detectControlCharacters=tt,f.displayName=rt,f.downloadFileByUrl=st,f.escapeRegex=at,f.expressHelper=ot,f.extractEmails=lt,f.formatDate=oe,f.generalPost=ut,f.getObjectByArr=pe,f.getQLogEnv=Ct,f.getValidation=C,f.getValueByKeys=_,f.groupArrayByKey=ct,f.init=T,f.initFromArray=B,f.initOnlyValidFromArray=ee,f.isConvertibleToNumber=z,f.makeApiResponse=N,f.makeService=ye,f.mergeArraysByKey=ft,f.objectHelper=b,f.pMap=_e,f.pMapIterable=dt,f.pMapSkip=x,f.pReduce=Z,f.padZeros=ge,f.printControlCharReport=nt,f.renderByTemplate=ht,f.replacePlaceholders=mt,f.sanitizeText=yt,f.setId=we,f.shuffleArray=pt,f.stringFormatter=U,f.stringHelper=te,f.tenantPlugin=_t,f.trackingPlugin=Ae,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})})(this.qUtilities=this.qUtilities||{});
12
+ //# sourceMappingURL=q-utilities.iife.js.map
@@ -0,0 +1,12 @@
1
+ (function(f,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(f=typeof globalThis<"u"?globalThis:f||self,E(f.qUtilities=f.qUtilities||{}))})(this,function(f){"use strict";var Bn=Object.defineProperty;var Un=(f,E,I)=>E in f?Bn(f,E,{enumerable:!0,configurable:!0,writable:!0,value:I}):f[E]=I;var Nt=(f,E,I)=>Un(f,typeof E!="symbol"?E+"":E,I);function E({allowCoordinator:n,allowOwner:e,query:t={},required:r,user:i}){if(!i)throw new Error("Require login.");i.permission;const s=i.permission.getScopes(r||{})||[];!s||s.length,s.includes("*")||(t.tenantCode=i.tenantCode),s.includes("TENANT")||(t.eventShortCode=i.eventShortCode),n&&t.registrationGroupCode&&i.myManagedRegistrationGroupCodes.includes(t.registrationGroupCode)?t.__ALLOW_COORDINATOR=!0:s.includes("EVENT")||(t.eventRegistrationCode=i.eventRegistrationCode),e&&(t.__ALLOW_OWNER=!0);const a=i.getExcludedFields(r);return a.length>0&&(t.__EXCLUDED_FIELDS=a),t.__LOGIN_SUBJECT_CODE=i.loginSubjectCode,t}function I(n,e){const t=new Date(n),r=e?new Date(e):new Date;if(isNaN(t.getTime())||isNaN(r.getTime())||t>r)return null;let i=r.getFullYear()-t.getFullYear();const s=r.getMonth()-t.getMonth();return(s<0||s===0&&r.getDate()<t.getDate())&&i--,i}function ie(n,{source:e,target:t}){return n.meta?((!n.meta.creator||n.meta.creator===e.getId())&&(n.meta.creator=t.getId()),(!n.meta.owner||n.meta.owner===e.getId())&&(n.meta.owner=t.getId())):((!n.creator||n.creator===e.getId())&&(n.creator=t.getId()),(!n.owner||n.owner===e.getId())&&(n.owner=t.getId())),n}function z(n){return n!=null&&typeof n!="boolean"&&String(n).trim()!==""&&!isNaN(Number(n))}function _(n,e){let t=n,r=e;if(typeof n=="string"&&(t=t.split(".")),!Array.isArray(n)&&typeof n=="object"){const{keys:s,obj:a}=n;t=s,r=a}if(t.length===0)return r;const i=t.shift();return r&&Object.prototype.hasOwnProperty.call(r,i)?_(t,r[i]):r&&i?t.length>0?_(t,r[i]):r[i]:r}function Dt(n){const e={};for(const[t,r]of Object.entries(n)){const i=t.match(/^(.*?)\|(boolean|date|html|number|string)$/);let s=t,a=null;i&&(s=i[1],a=i[2]);const o=s.split(".");let l=e;for(let c=0;c<o.length-1;c++){const d=o[c];(!l[d]||typeof l[d]!="object")&&(l[d]={}),l=l[d]}const u=o[o.length-1];if(a==="boolean")r===1||r==="1"||r===!0||r==="true"||r==="TRUE"?l[u]=!0:r===0||r==="0"||r===!1||r==="false"||r==="FALSE"?l[u]=!1:l[u]=!!r;else if(a==="number")l[u]=Number(r)||0;else if(a==="date")l[u]=new Date(r);else if(a==="html")if(r&&typeof r=="string"){let c=[];r.includes(`
2
+
3
+ `)||r.includes(`\r
4
+ \r
5
+ `)?c=r.split(/\r?\n\s*\r?\n/).filter(d=>d.trim()!==""):c=r.split(/\r?\n/).filter(d=>d.trim()!==""),c.length>0?l[u]=c.map(d=>`<div>${d.trim()}</div>`).join(""):l[u]=r?`<div>${r}</div>`:""}else l[u]=r?`<div>${r.toString()}</div>`:"";else if(r==null)l[u]="";else if(typeof r=="number")l[u]=r;else if(typeof r=="string"&&r.trim()!==""){const c=r.trim();/^-?\d+$/.test(c)?l[u]=Number.parseInt(c,10):/^-?\d+\.\d+$/.test(c)?l[u]=Number.parseFloat(c):l[u]=r}else l[u]=(r==null?void 0:r.toString())||""}return e}function Mt(n,e){return e.split(".").reduce((r,i)=>{if(i.endsWith("[]")){const s=i.slice(0,-2);return Array.isArray(r[s])?r[s]:[]}if(i.includes("[")&&i.includes("]")){const s=i.match(/(\w+)\[(\d+)\]/);if(s){const a=s[1],o=s[2];return r&&r[a]&&r[a][o]}}else return r&&Array.isArray(r)?r.map(s=>s[i]):r&&r[i]},n)}function jt(n,e){return e.split(".").reduce((t,r)=>t&&t[r]!==void 0?t[r]:void 0,n)}function kt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp)&&Object.prototype.toString.call(n)==="[object Object]"}function se(n,...e){if(!e.length)return n;const t=e.shift();if(ae(n)&&ae(t))for(const r in t)ae(t[r])?(n[r]||(n[r]={}),se(n[r],t[r])):n[r]=t[r];return se(n,...e)}function xt(n,e,t){const r=e.split(".");let i=n;for(let o=0;o<r.length-1;o++){const l=r[o];let u,c;const d=l.match(/^(\w+)\[(\d+)\]$/);if(d){for(u=d[1],c=Number.parseInt(d[2],10),(!i[u]||!Array.isArray(i[u]))&&(i[u]=[]);i[u].length<=c;)i[u].push(void 0);i[u][c]==null&&(i[u][c]={}),i=i[u][c]}else i[l]||(i[l]={}),i=i[l]}const s=r[r.length-1],a=s.match(/^(\w+)\[(\d+)\]$/);if(a){const o=a[1],l=Number.parseInt(a[2],10);for((!i[o]||!Array.isArray(i[o]))&&(i[o]=[]);i[o].length<=l;)i[o].push(void 0);i[o][l]=t}else i[s]=t}function ae(n){return n&&typeof n=="object"&&!Array.isArray(n)}const C={expandDotNotation:Dt,get:Mt,getNestedValue:jt,isPlainObject:kt,merge:se,set:xt};class b{constructor(e={}){e=e||{},this.key=e.key||null,this.value=typeof e.value<"u"?e.value:""}static init(e={}){if(e instanceof this)return e;const t=new this(e);return t.isValid?t:null}static initFromArray(e=[]){return Array.isArray(e)?e.map(t=>this.init(t)):[]}static initOnlyValidFromArray(e=[]){return this.initFromArray(e).filter(t=>t)}static get _classname(){return"KeyValueObject"}static get _superclass(){return"KeyValueObject"}static addItem(e,t,r){e.push(this.init({key:t,value:r}))}static addRecord(e=[],t,r){return this.hasKeyValue(e,t,r)||e.push(this.init({key:t,value:r})),e}static appendRecord(e=[],t,r){return e.map(i=>(this.sameKey(i,t)&&(i.value=[...i.value,...r]),i))}static appendValueArray(e=[],t,r){return e.map(i=>(this.sameKey(i,t)&&(i.value=[...i.value,...r]),i))}static foundByKey(e=[],t){return e.find(i=>this.sameKey(i,t))||null}static foundValueByKey(e=[],t){const r=this.foundByKey(e,t);return r?r.value:null}static fromObject(e={}){return Object.keys(e).reduce((t,r)=>(t.push(this.init({key:r,value:e[r]})),t),[])}static getValueByKey(e=[],t){return this.foundValueByKey(e,t)}static getMetadataValueByKeyAsArray(e=[],t){const r=this.getValueByKey(e,t);return r?C.isPlainObject(r)?Object.keys(r).reduce((i,s)=>(i.push({key:s,value:r[s]}),i),[]):r:[]}static getValueByKeyFromArray(e=[],t){if(e.length===0)return null;const i=e.shift().find(s=>this.sameKey(s,t));return i&&i.value?i.value:this.getValueByKeyFromArray(e,t)}static getValuesByKey(e=[],t){return e.reduce((r,i)=>(this.sameKey(i,t)&&r.push(i.value),r),[])}static hasKeyValue(e=[],t,r){return typeof r>"u"?e.filter(i=>this.sameKey(i,t)).length>0:e.filter(i=>this.sameKey(i,t)&&ve(i.value,r)).length>0}static insertOrUpdateRecord(e=[],t,r){let i=[...e];return this.hasKeyValue(e,t)?i=this.updateRecord(e,t,r):i.push(this.init({key:t,value:r})),i}static keys(e=[]){return Array.isArray(e)?e.reduce((t,r)=>(t.push(r.key),t),[]):[]}static mapToKeyValue(e=[],t="key",r="value"){return Array.isArray(e)?e.reduce((i,s)=>{if(s&&typeof s=="object"){const a=C.get(s,t),o=C.get(s,r);a!=null&&i.push(this.init({key:a,value:o!==void 0?o:""}))}return i},[]):[]}static merge(e,t){return(t||[]).map(r=>{const i=e.find(s=>s.key===r.key);i?i.value=Ft(r.value,i.value):e.push(r)}),e}static removeByKey(e,t){return e.reduce((r,i)=>(this.sameKey(i,t)||r.push(i),r),[])}static removeByKeys(e,t){return e.reduce((r,i)=>(t.includes(i.key)||r.push(i),r),[])}static sameKey(e,t){return e?ve(e.key,t):!1}static toObject(e=[]){return Array.isArray(e)?e.reduce((t,r)=>(t[r.key]=r.value,t),{}):{}}static toString(e=[],t="; "){return Array.isArray(e)?e.reduce((r,i)=>(r.push(`${i.key}: ${i.value}`),r),[]).join(t):""}static updateRecord(e=[],t,r){return e.map(i=>this.sameKey(i,t)?{...i,value:r}:i)}static updateOrInsertRecord(e=[],t,r){return this.insertOrUpdateRecord(e,t,r)}static updateRecordsFromArray(e=[],t=[]){if(Array.isArray(e)&&Array.isArray(t)){const r=this.toObject(e),i=this.toObject(t);return this.fromObject({...r,...i})}return[]}static values(e=[]){return Array.isArray(e)?e.reduce((t,r)=>(t.push(r.value),t),[]):[]}get isValid(){return!!this.key}get toObject(){const e={};return this.isValid&&(e[this.key]=this.value),e}}function Ft(n,e){return n===void 0?e:Array.isArray(n)&&Array.isArray(e)?[...new Set([...n,...e])]:typeof n=="object"&&typeof e=="object"&&!Array.isArray(n)&&!Array.isArray(e)?{...n,...e}:e}function ve(n,e){return n===e}function S(n,e,t=Pt,r=b){if(!n)return!0;if(typeof t!="function"||r&&typeof r!="function")return!1;const{key:i="",value:s,placeholder:a,keyValuePath:o=""}=n,[l]=Object.keys(s);if(!i&&typeof a>"u")switch(l){case"$and":return s.$and.reduce((c,d)=>c&&S(d,e,t,r),!0);case"$or":return s.$or.reduce((c,d)=>c||S(d,e,t,r),!1);default:return!1}let u=typeof a>"u"?t(i,e):a;if(o){const c=r.toObject(u);u=t(o,c)}switch(l){case"$after":{if(z(s==null?void 0:s.$after)){const c=Number(String(s==null?void 0:s.$after));return Date.now()>c}return!1}case"$before":{if(z(s==null?void 0:s.$before)){const c=Number(String(s==null?void 0:s.$before));return Date.now()<c}return!1}case"$empty":return u==null===s.$empty;case"$eq":return u===s.$eq;case"$gt":return u>s.$gt;case"$gte":return u>=s.$gte;case"$hasOverlap":return Lt(u,s.$hasOverlap);case"$lt":return u<s.$lt;case"$lte":return u<=s.$lte;case"$in":return Array.isArray(u)?!!u.find(c=>s.$in.includes(c)):typeof u!="object"?!!s.$in.includes(u):!1;case"$includes":return Array.isArray(u)?u.includes(s.$includes):!1;case"$intervalTimeGt":{const c=new Date().getTime(),d=new Date(u).getTime();return c-d>s.$intervalTimeGt}case"$intervalTimeLt":{const c=new Date().getTime(),d=new Date(u).getTime();return c-d<s.$intervalTimeLt}case"$inValue":{const c=t(s.$inValue,e),d=Array.isArray(c)?c:[];return Array.isArray(u)?!!u.find(m=>d.includes(m)):typeof u=="string"?!!d.includes(u):!1}case"$isToday":{const c=new Date,d=c.setHours(0,0,0,0),m=c.setHours(23,59,59,59),h=new Date(u).getTime();return(d<=h&&m>=h)===s.$isToday}case"$ne":return u!==s.$ne;case"$notIn":return Array.isArray(u)?!u.find(c=>s.$notIn.includes(c)):typeof u!="object"?!s.$notIn.includes(u):!1;case"$notInValue":{const c=t(s.$notInValue,e),d=Array.isArray(c)?c:[];return Array.isArray(u)?!u.find(m=>d.includes(m)):typeof u!="object"?!d.includes(u):!1}case"$range":{const[c,d]=s.$range;return typeof c=="number"&&typeof d=="number"&&u>=c&&u<=d}default:return!1}}function Pt(n,e){return _(n.split("."),e)}function Lt(n,e){let t=n,r=e;typeof t=="string"&&(t=t.split(",")),typeof r=="string"&&(r=r.split(","));const i=new Set(t);return r.find(s=>i.has(s))}function oe(n,e){const t=n&&n instanceof Date?n:new Date(n),r=["日","一","二","三","四","五","六"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],a=e||"YYYY/MM/DD hh:mm",o=t.getDay(),l=s[o],u=r[o],c=i[o],d=t.getFullYear(),m=t.getMonth()+1,h=t.getDate(),g=t.getHours(),v=t.getMinutes(),D=t.getSeconds();return a.replace("YYYY",d).replace("MM",$(m)).replace("MM",$(m)).replace("DD",$(h)).replace("hh",$(g)).replace("mm",$(v)).replace("ss",$(D)).replace("M",m).replace("D",h).replace("h",g).replace("m",v).replace("s",D).replace("EEEE",$(c)).replace("EEE",$(u)).replace("EE",$(l)).replace("E",$(o))}function $(n){return n<10?`0${n}`:n}const p={argumentEmptyException:"Argument is empty",argumentFormatException:"Incorrect number or format of argument",invalidFuntionException:"Function Name is invalid",invalidRegExpException:"Invalid regular expression",isNotAFunctionException:"Is not a function",notExistException:"Key does not exist",resultEmptyException:"Result is empty",resultMoreThanOneException:"More than one result"};class y extends Error{constructor(e){super(e),this.message=e}}const Vt="_EMPTY",Oe=["concatIf","divide","eq","exec","filterAll","filterOne","formatDate","get","gt","gte","isEmpty","isNotEmpty","join","lt","lte","map","neq","removeHtml","replaceChar","sum","toLowerCase","toUpperCase"],Re="_HIDE",Bt="_NOT_EMPTY",w="_SELF",Ut=["<%=","%>"],Kt=["{{","}}"];function Te(n,e){if(typeof n!="string")throw new y(`_concatIf: ${p.argumentFormatException}: the data must be string :${n.join(", ")}`);if(e.length!==3)throw new y(`_concatIf: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;const[t,r,i]=e;if([Vt,Bt].includes(t)||r.length!==2)throw new y(`concatIf: ${p.argumentEmptyException}: ${t}, ${r}`);return n===""&&i.includes(Re)?"":n!==""&&(n!==null||n!==void 0)&&i.includes(Re)?`${r[0]}${n}${r[r.length-1]}`:i}function Ie(n,e){try{return Number.isNaN(n)?n:n/e}catch(t){throw t}}function Ne(n,e){if(e.length!==3)throw new y(`eq: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n===t?e[1]:e[2]}function Ht(n,e){try{const[t,...r]=e;return n[t](...r)}catch(t){throw t}}function ue(n,e){try{if(!Array.isArray(e)||e.length===0)throw new y(p.argumentEmptyException);return!Array.isArray(n)||n.length===0?[]:typeof n[0]=="object"?De(n,e):typeof n[0]=="string"||typeof n[0]=="number"?Wt(n,e):[]}catch(t){throw t}}function Wt(n,e){const t=e.flat();return n.filter(r=>t.some(i=>Me(i,r)))}function De(n,e){if(e.length===1){const s=e[0];return n.filter(a=>s.includes(".")?_(s.split("."),a):Object.prototype.hasOwnProperty.call(a,s))}if(e.length>2){let s=n;for(let a=0;a<e.length;a+=2){const o=[e[a],e[a+1]];s=De(s,o)}return s}const[t,...r]=e,i=r.flat();return n.filter(s=>{const a=t.includes(".")?_(t.split("."),s):s[t];return i.some(o=>Me(o,a))})}function Me(n,e){if(n===void 0&&e===void 0||n===null&&e===null)return!0;if(typeof n=="boolean")return n===e;if(n===""||n==="*")return e==null?!1:typeof e=="string"?n===""?e==="":e!=="":Array.isArray(e)?n===""?e.length===0:e.length!==0:n!=="";if(Yt(n))return n===e;if(n.startsWith("[")&&n.endsWith("]"))return n==="[]"?Array.isArray(e)&&e.length===0:n==="[*]"?Array.isArray(e)&&e.length!==0:!1;const{operator:t,value:r}=qt(n);if(!t||r!==0&&!r)return!1;switch(t){case">":return e>r;case"<":return e<r;case"!=":return e!==r;case">=":return e>=r;case"<=":return e<=r;default:return!1}}function Yt(n){return typeof n=="string"?!(n.startsWith("[")&&n.endsWith("]")||/!=|>=|<=|>|</.test(n)):!Number.isNaN(n)}function qt(n){const t=["!=",">=","<=",">","<"].find(s=>n.startsWith(s));if(!t)return{operator:null,value:null};const r=n.slice(t.length);if(/^[a-z]*$/i.test(r)&&t!=="!=")return{operator:null,value:null};const i=!Number.isNaN(Number.parseFloat(r))&&!Number.isNaN(r)?Number(r):r;return{operator:t,value:i}}function zt(n,e){try{const t=ue(n,e);if(t.length===1)return t[0];if(t.length===0)return null;throw new y(p.resultMoreThanOneException)}catch(t){throw t}}function je(n,e){if(e.length===0)throw new y(`_formateDate: ${p.argumentFormatException}: format parts must be not empty array`);if(n==null)return null;const t=new Date(n),r={yyyy:String(t.getFullYear()),mm:String(t.getMonth()+1).padStart(2,"0"),dd:String(t.getDate()).padStart(2,"0")},i=["yyyy","mm","dd"];if(e.filter(a=>a.length>1&&!i.includes(a)).length>0)throw new y(`_formateDate: ${p.argumentFormatException}: the format type is not valid: ${e.join(", ")}`);return e.reduce((a,o)=>a+(r[o]||o),"")}function G(n,e,t=null){try{if(e===null||typeof e>"u"||e==="")throw new y(p.argumentEmptyException);if(n===null)return null;if(e.includes(".")){const r=e.split(".");if(r.length>1){const i=r.shift(),s=r.join(".");return typeof n[i]<"u"?G(n[i],s,t):ke(e,t)}}return typeof n[e]<"u"?n[e]:ke(e,t)}catch(r){throw r}}function ke(n,e){return e!==null?e:null}function xe(n,e){if(e.length!==3)throw new y(`_gt: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n>t?e[1]:e[2]}function Fe(n,e){if(e.length!==3)throw new y(`_gte: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n>=t?e[1]:e[2]}function Pe(n,e){if(e.length!==2)throw new y(`_isEmpty: ${p.argumentFormatException}: ${e.join(", ")}`);return e.includes(w)&&(e=e.map(t=>t===w?n:t)),n!==null&&typeof n=="object"&&Object.keys(n).length===0||n===""||n===null||n===void 0||n.length===0?e[0]:e[1]}function Le(n,e){if(e.length!==2)throw new y(`_isNotEmpty: ${p.argumentFormatException}: ${e.join(", ")}`);return e.includes(w)&&(e=e.map(t=>t===w?n:t)),n!==null&&typeof n=="object"&&Object.keys(n).length===0||Array.isArray(n)&&n.length===0||typeof n=="string"&&n===""||n==null?e[1]:e[0]}function Ve(n,e){try{return n.length===0?"":n.length===1?Be(n[0]):n.map(t=>Be(t)).join(e)}catch(t){throw t}}function Be(n){return JSON.stringify(n).replace(/"([^"]+)":/g,"$1: ").replace(/"([^"]+)"/g,"$1").replace(/,/g,", ")}function Ue(n,e){if(e.length!==3)throw new y(`_lt: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n<t?e[1]:e[2]}function Ke(n,e){if(e.length!==3)throw new y(`_lte: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n<=t?e[1]:e[2]}function He(n,e){try{if(e.length===0)throw new y(p.argumentEmptyException);return n===null||typeof n>"u"?null:n.reduce((r,i)=>{e.length===1&&Array.isArray(e[0])&&(e=e[0],r.hasFormat=!0);const s=e.map(a=>{if(a.includes(".")){const o=a.split("."),l=o[0];o.shift();const u=o.join(".");return G(i[l],u)}return typeof i[a]<"u"?i[a]:null});return r.hasFormat?r.content.push(s):r.content=r.content.concat(s),r},{content:[],hasFormat:!1}).content}catch(t){throw t}}function We(n,e){if(e.length!==3)throw new y(`_neq: ${p.argumentFormatException}: ${e.join(", ")}`);if(n===null||typeof n>"u")return null;e.includes(w)&&(e=e.map(r=>r===w?n:r));const t=e[0];return n!==t?e[1]:e[2]}function Ye(n,e){if(n==null)return null;if(!Array.isArray(e))throw new y(`_removeHtml: ${p.argumentFormatException}: args parts must be array`);return Gt(n,e[0])}function Gt(n,e=`
6
+ `){typeof e!="string"&&(e=`
7
+ `);let r=n.replace(/&nbsp;/g," ").replace(/\s+/g," ").replace(/<\/?(p|div|h[1-6]|ul|ol|li|pre|section|article|table|tr|td|th)(\s[^>]*)?>/gi,"~~~").replace(/<br\s*\/?>/gi,"~~~").replace(/<[^>]+>/g,"").replace(/~{3,}/g,e).trim();return e===""?r=r.replace(/\s+/g," "):(r=r.replace(new RegExp(`${le(e)}+`,"g"),e),r=r.replace(new RegExp(`^${le(e)}|${le(e)}$`,"g"),"")),r}function le(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qe(n,e){if(n==null)return null;if(!Array.isArray(e))throw new y(`_replaceChar: ${p.argumentFormatException}: args parts must be array`);return Jt(n,e[0],e[1])}function Jt(n,e,t){return!n||!e?n:n.replace(new RegExp(e,"g"),t)}function ze(n,e){return Number.isNaN(n)||n===null||typeof n>"u"||n===""?n:e.reduce((t,r)=>t+r,n)}function Ge(n,e){if(e!==void 0)throw new y(`_toLowerCase: ${p.argumentFormatException}: ${e.join(", ")}`);return n===null||typeof n>"u"||typeof n!="string"?null:String(n).toLowerCase()}function Je(n,e){if(typeof n!="string")throw new y(`_toUpperCase: ${p.argumentFormatException}: the data must be string: ${n}`);if(e!==void 0)throw new y(`_toUpperCase: ${p.argumentFormatException}: the argument must be empty: ${e.join(", ")}`);return n===null||typeof n>"u"||typeof n!="string"?null:String(n).toUpperCase()}class ce{constructor(e){this.data=e}static init(e){return new this(e)}static initFromArray(e=[]){return Array.isArray(e)?e.map(t=>this.init(t)):[]}static initOnlyValidFromArray(e=[]){return this.initFromArray(e).filter(t=>t)}static concatIf(e,t){return Te(e,t)}static divide(e,t){return Ie(e,t)}static eq(e,t){return Ne(e,t)}static filterAll(e,t){return ue(e,t)}static formatDate(e,t){return je(e,t)}static get(e,t,r=null){return G(e,t,r)}static gt(e,t){return xe(e,t)}static gte(e,t){return Fe(e,t)}static isEmpty(e,t){return Pe(e,t)}static isNotEmpty(e,t){return Le(e,t)}static join(e,t=""){return Ve(e,t)}static lt(e,t){return Ue(e,t)}static lte(e,t){return Ke(e,t)}static map(e,t=[]){return He(e,t)}static neq(e,t){return We(e,t)}static removeHtml(e,t){return Ye(e,t)}static replaceChar(e,t){return qe(e,t)}static sum(e,t){return ze(e,t)}static toLowerCase(e,t){return Ge(e,t)}static toUpperCase(e,t){return Je(e,t)}static parseFunction(e){return Ze(e,Oe)}static parseParams(e){return Xe(e)}pipe(e=""){this.delimiters=e.substring(0,2)==="{{"?Kt:Ut;const t=new RegExp(`${this.delimiters[0]}\\s(.*?)\\s${this.delimiters[1]}`),r=e.match(t);if(r!==null)try{return Ze(r[1],Oe).reduce((s,a)=>en(s,a.name,a.args),this.data)}catch(i){throw new y(`TemplateCompiler engine error: ${i.message}`)}throw new y(`TemplateCompiler engine error: ${p.invalidRegExpException}`)}}function Ze(n,e){const t=/(\w+)\(((?:[^()]|\((?:[^()]|\([^()]*\))*\))*)\)/;let r;if(n.includes("|")){r=[];let i="",s=0,a=null;for(let o=0;o<n.length;o++){const l=n[o];if((l==='"'||l==="'")&&(o===0||n[o-1]!=="\\")){a===l?a=null:a===null&&(a=l),i+=l;continue}a===null&&(l==="("?s++:l===")"&&s--),l==="|"&&s===0&&a===null?(r.push(i),i=""):i+=l}i&&r.push(i)}else r=[n];return r.reduce((i,s)=>{const a=s.match(t);if(a!==null){const o=a[1],l=a[2],u=Xe(l);if(e.includes(o))i.push({name:o,args:u});else throw new y(`${o} is not a valid function`)}return i},[])}function Xe(n){const e=n.trim();return e?e.includes(",")?Zt(e).map(r=>fe(r.trim())):[fe(e)]:[]}function Zt(n){const e=[];let t="",r=0,i=0,s=null;for(let a=0;a<n.length;a++){const o=n[a];if((o==='"'||o==="'")&&(a===0||n[a-1]!=="\\")){s===o?s=null:s===null&&(s=o),t+=o;continue}if(s!==null){t+=o;continue}o==="["?r++:o==="]"?r--:o==="("?i++:o===")"&&i--,o===","&&s===null&&r===0&&i===0?(e.push(t),t=""):t+=o}return t&&e.push(t),e}function fe(n){if(typeof n!="string")return n;const e=n.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.substring(1,e.length-1);const t=Qt(e);return typeof t!="string"?t:e.startsWith("[")&&e.endsWith("]")?Xt(e):n}function Xt(n){const e=n.substring(1,n.length-1).trim();if(!e)return[];const t=[];let r="",i=null;for(let s=0;s<e.length;s++){const a=e[s];if((a==='"'||a==="'")&&(s===0||e[s-1]!=="\\")){i===a?i=null:i===null&&(i=a),r+=a;continue}a===","&&i===null?(r.trim()&&t.push(r.trim()),r=""):r+=a}return r.trim()&&t.push(r.trim()),t.map(s=>fe(s))}function Qt(n){if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return n.substring(1,n.length-1);if(n==="true")return!0;if(n==="false")return!1;if(n!=="undefined")return n==="null"?null:!Number.isNaN(n)&&!Number.isNaN(Number.parseFloat(n))?Number(n):n}function en(n,e,t){try{let r;switch(e){case"concatIf":return Te(n,t);case"divide":return Ie(n,t);case"eq":return Ne(n,t);case"exec":return Ht(n,t);case"filterAll":return ue(n,t);case"filterOne":return zt(n,t);case"formatDate":return je(n,t);case"get":if(t.length>2)throw new y(p.argumentFormatException);return t.length===2&&(r=t[t.length-1]),G(n,t[0],r);case"gt":return xe(n,t);case"gte":return Fe(n,t);case"isEmpty":return Pe(n,t);case"isNotEmpty":return Le(n,t);case"join":return Ve(n,t[0]);case"lt":return Ue(n,t);case"lte":return Ke(n,t);case"map":return He(n,t);case"neq":return We(n,t);case"removeHtml":return Ye(n,t);case"replaceChar":return qe(n,t);case"sum":return ze(n,t);case"toLowerCase":return Ge(n);case"toUpperCase":return Je(n);default:throw new Error(`${e} is not a valid function`)}}catch(r){throw r}}function J(n,e){return n.reduce((t,r)=>{const{type:i,value:s="",restriction:a,template:o,format:l,showMinutes:u}=r;switch(i){case"array":{if(S(a,e,_)){const c=_(s.split("."),e)||[];t+=c.reduce((d,m)=>d+=J(o,m),"")}break}case"date":{if(S(a,e,_)){const c=_(s.split("."),e)||"";t+=oe(c,l).toString()}break}case"ellipsis":{if(S(a,e,_)){const{maxLength:c}=r,d=_(s.split("."),e)||"";d.length<=c?t+=d.toString():t+=`${d.substr(0,c)}...`}break}case"group":{if(S(a,e,_))return J(s,e);break}case"label":{S(a,e,_)&&(t+=s.toString());break}case"templateCompiler":{if(S(a,e,_)){const c=new ce({data:e});t+=c.pipe(s)}break}case"value":{if(S(a,e,_)){const c=_(s.split("."),e)||"";t+=c.toString()}break}}return t},"")}function Qe(n,e=/\$\{(.+?)\}/g,t,r){if(!n)return"";const i=typeof r=="function"?r:_,s=new RegExp(e,"g");return n.replace(s,(a,o)=>{const l=i({keys:o.split("."),obj:t});return l==null?"":typeof l=="object"?JSON.stringify(l):l})}function tn(n,e=0){try{if(typeof n=="number")return n.toString().length===10&&(n=n*1e3),new Date(n);if(typeof n=="string"&&n.length===8){const t=Number.parseInt(n.slice(0,4),10),r=Number.parseInt(n.slice(4,6),10)-1,i=Number.parseInt(n.slice(6,8),10);return new Date(t,r,i)}return new Date(n)}catch{throw new Error("input does not meet the requirements")}}class V{constructor({date:e,isUTC:t,is24Hour:r,timezoneOffset:i=0}={}){this.date=e,this.isUTC=t,this.is24Hour=r,this.timezoneOffset=i}getDateComponent(e){if(this.timezoneOffset!==0){const t=this.timezoneOffset*60*1e3;return new Date(this.date.getTime()+t)[`getUTC${e}`]()}else return this.isUTC?this.date[`getUTC${e}`]():this.date[`get${e}`]()}process(e){return e}}function k(n,e="0"){if(typeof n!="number")throw new TypeError("Parameter must be of number");return n<10?`${e}${n}`:n}class nn extends V{process(e){const t=this.getDateComponent("Date");return e=e.replace("DD",k(t)),e}}const rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];class sn extends V{process(e){const t=this.getDateComponent("Month");return e=e.replace("MMM",rn[t]),e=e.replace("MM",k(t+1)),e}}class an extends V{process(e){const t=this.getDateComponent("FullYear");return e=e.replace("yyyy",t),e=e.replace("YYYY",t),e=e.replace("yy",t.toString().slice(-2)),e=e.replace("YY",t.toString().slice(-2)),e}}class on extends V{process(e){let t=this.getDateComponent("Hours");const r=!this.is24Hour;if(r&&t>12&&(t-=12),r&&t===0&&(t=12),e=e.replace("HH",k(this.getDateComponent("Hours"))),e=e.replace("hh",k(t)),this.is24Hour)e=e.replace(/\s*\bA\b\s*/g," "),e=e.replace(/\s*\ba\b\s*/g," "),e=e.replace(/\s+/g," ").trim();else{if(e.includes("A")){const i=this.getDateComponent("Hours")>=12?"PM":"AM";e=e.replace(/\bA\b/g,i)}if(e.includes("a")){const i=this.getDateComponent("Hours")>=12?"pm":"am";e=e.replace(/\ba\b/g,i)}}return e=e.replace("mm",k(this.getDateComponent("Minutes"))),e=e.replace("ss",k(this.getDateComponent("Seconds"))),e}}class un extends V{process(e){if(e.includes("Z"))if(this.isUTC)e=e.replace("Z","+0000");else{const t=this.date.getTimezoneOffset(),r=t>0?"-":"+",i=Math.abs(t),s=Math.floor(i/60),a=i%60,o=`${r}${s.toString().padStart(2,"0")}${a.toString().padStart(2,"0")}`;e=e.replace("Z",o)}if(e.includes("ddd")){const t=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],r=this.getDateComponent("Day");e=e.replace("ddd",t[r])}if(e.includes("dd")){const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=this.getDateComponent("Day");e=e.replace("dd",t[r])}return e}}function ln({date:n,format:e,isUTC:t,is24Hour:r,timezoneOffset:i=0}){return[un,nn,sn,an,on].reduce((s,a)=>new a({date:n,isUTC:t,is24Hour:r,timezoneOffset:i}).process(s),e)}function et(n,e){const t=e||"YYYY/MM/DD hh:mm",r=t.includes("HH");let i=null;if(t.includes("Z"))i=0;else if(t.includes("+")){const a=t.match(/[+-]\d{2}:?\d{2}/);if(a){const o=a[0],l=o[0]==="+"?1:-1,u=parseInt(o.slice(1,3),10),c=o.includes(":")?parseInt(o.slice(4,6),10):parseInt(o.slice(3,5),10);i=l*(u*60+c)}}const s=tn(n,i===null?0:i);return ln({date:s,format:t,isUTC:i!==null,is24Hour:r,timezoneOffset:i===null?0:i})}function tt(n,e={}){const{preserveBasicWhitespace:t=!0,removeNewlines:r=!1}=e;if(typeof n!="string")return{hasControlChars:!1,matches:[],inputType:typeof n,message:"Input is not a string"};const i=[];let s;return t&&!r?s=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g:s=/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,n.replace(s,(a,o)=>(i.push({character:a,code:a.charCodeAt(0),hex:"0x"+a.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0"),position:o,context:cn(n,o,10)}),"")),{hasControlChars:i.length>0,matches:i,totalFound:i.length,inputPreview:n.length>50?n.substring(0,50)+"...":n,inputLength:n.length,optionsUsed:{preserveBasicWhitespace:t},regexPattern:s.toString()}}function cn(n,e,t=10){const r=Math.max(0,e-t),i=Math.min(n.length,e+t+1);let s=n.substring(r,i);return s=s.replace(/[\x00-\x1F\x7F-\x9F]/g,a=>"\\u"+a.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")),s}function nt(n){console.log("=== Control Character Detection Report ==="),console.log(`Input: "${n.inputPreview}" (${n.inputLength} chars)`),console.log(`Options: preserveBasicWhitespace = ${n.optionsUsed.preserveBasicWhitespace}`),console.log(`Regex pattern: ${n.regexPattern}`),console.log(`Control characters found: ${n.totalFound}`),n.hasControlChars?(console.log(`
8
+ 📋 Matches found:`),n.matches.forEach((e,t)=>{console.log(`
9
+ ${t+1}. Character: ${JSON.stringify(e.character)}`),console.log(` Code: ${e.code} (${e.hex})`),console.log(` Position: ${e.position}`),console.log(` Context: "...${e.context}..."`)})):console.log("✅ No control characters detected in Phase 1 range"),console.log("=== End Report ===")}function rt(n,e){n=n||{},e=e||{};const{firstName:t,middleName:r,noFirstName:i,prefix:s,title:a,upperCaseLastName:o=!0}=e;e.hasAsianCharacters=!1;let l=[];if((s||a)&&n.prefix){const c=de(e);l=c(l,n.prefix),l=c(l,n.title)}if(t!==!1&&!i){const c=de(e);l=c(l,n.firstName),l=c(l,n.givenName)}r===!0&&n.middleName&&(e.hasAsianCharacters=e.hasAsianCharacters||it(n.middleName.toString()),l.push(n.middleName.toString()));const u=de(e,o);return l=u(l,n.lastName),l=u(l,n.familyName),l=u(l,n.surname),e.hasAsianCharacters?l.reverse().join(""):l.join(" ")}function de(n={},e=!1){let t=!1;return(r,i)=>{if(!t&&i){t=!0,n.hasAsianCharacters=n.hasAsianCharacters||it(i.toString());const s=e?i.toString().toUpperCase():i.toString();r.push(s)}return r}}function it(n){return/[\u3400-\u9FBF]/.test(n)}function st({dataUrl:n="",filename:e=""}={}){const t=document.createElement("a");t.download=e,t.href=n,document.body.appendChild(t),t.click(),document.body.removeChild(t)}function at(n){return String(n).replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function fn({responseHelper:n,handler:e,ignoreError:t=!1}){return async(r,i,s)=>{const a=typeof i=="function"&&!s,o=a?r:null,l=a?r.request:r,u=a?r.response:i,c=a?i:s;try{return await e({req:l,res:u}),a?await c():c()}catch(d){if(t)return a?await c():c();if(!n){if(a)throw d;return c(d)}const m=d.status||400,h=d.message||"An error occurred",g=n.standardizeResponse({err:d,message:h});a?(o.status=m,o.body=g):u.status(m).json(g)}}}function dn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{query:s}=t,a=await e.findAll({query:s});r.locals.findAllResult=a,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}function hn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{params:s,query:a}=t,{id:o}=s,l=await e.findOne({query:{...a,id:o}});r.locals.findOneResult=l,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}function mn(n,{query:e={}}={}){!e.__EXCLUDED_FIELDS||Array.isArray(e.__EXCLUDED_FIELDS)&&e.__EXCLUDED_FIELDS.length===0||(n.push({$set:{__originalEmail:"$_eventRegistration.email",__originalPhone:"$_eventRegistration.phone",__queryArr:{$ifNull:[e.__EXCLUDED_FIELDS||[],[]]},__isMyself:{$eq:["$_eventRegistration.loginSubjectCode",e.__LOGIN_SUBJECT_CODE]},__isGroupCoordinator:!!e.__ALLOW_COORDINATOR,__hasEventRegistration:{$ne:["$_eventRegistration",null]}}}),n.push({$set:{__shouldShowEmail:{$and:["$__hasEventRegistration",{$or:["$__isMyself","$__isGroupCoordinator",{$not:{$in:["email","$__queryArr"]}}]}]},__shouldShowPhone:{$and:["$__hasEventRegistration",{$or:["$__isMyself","$__isGroupCoordinator",{$not:{$in:["phone","$__queryArr"]}}]}]}}}),n.push({$set:{"_eventRegistration.email":{$cond:["$__shouldShowEmail","$__originalEmail","$$REMOVE"]},"_eventRegistration.phone":{$cond:["$__shouldShowPhone","$__originalPhone","$$REMOVE"]}}}),n.push({$unset:["__originalEmail","__originalPhone","__isMyself","__isGroupCoordinator","__queryArr","__hasEventRegistration","__shouldShowEmail","__shouldShowPhone"]}))}function yn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{body:s}=t;let a;Array.isArray(s)?a=await e.saveAll({docs:s}):a=await e.saveOne({doc:s}),r.locals.postResult=a,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}function pn({responseHelper:n,service:e}){return async(t,r,i)=>{try{const{body:s,params:a}=t,{id:o}=a;if(o!==s.id)throw new Error("id in params and body must be same");const{data:l}=await e.findOne({query:{id:o}}),u=l[0];u.update(s);const c=await e.saveOne({doc:u});r.locals.updateOneResult=c,await i()}catch(s){r.status(400).json(n.standardizeResponse({err:s,message:s.message||s}))}}}const ot={customHandler:fn,findAllResult:dn,findOneResult:hn,hideSensitiveFields:mn,postResult:yn,updateOneResult:pn};function ut(n){const e=/[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,}/gi,t=new Set;return n?(n.forEach(r=>{if(!(!r||typeof r!="string"||!r.trim()))try{const s=r.replace(/[\u200B-\u200D\uFEFF\u202A-\u202E]/g,"").replace(/[<>]/g," ").replace(/\s+/g," ").trim().match(e);s&&s.forEach(a=>t.add(a.toLowerCase()))}catch(i){console.warn("Failed to process entry:",r,i)}}),Array.from(t).sort((r,i)=>r.localeCompare(i))):[]}async function Z(n,e,t){return new Promise((r,i)=>{const s=n[Symbol.iterator]();let a=0;const o=async l=>{const u=s.next();if(u.done){r(l);return}try{const[c,d]=await Promise.all([l,u.value]);o(e(c,d,a++))}catch(c){i(c)}};o(t)})}class X{constructor(e){e=e||{},this.model=e.model,this._sharedOptions=e._sharedOptions,this._queryOptions=e._queryOptions,this._saveOptions=e._saveOptions,this._Class=e._constructor&&e._constructor._Class?e._constructor._Class:null}static init(e={}){return T(this,e)}static get _classname(){return"Repo"}static get _superclass(){return"Repo"}get _classname(){return"Repo"}get _superclass(){return"Repo"}get isValid(){return this.model&&typeof this.model.deleteOne=="function"&&typeof this.model.findAll=="function"&&typeof this.model.saveOne=="function"}get queryOptions(){return{...this._sharedOptions,...this._queryOptions}}get saveOptions(){return{...this._sharedOptions,...this._saveOptions}}init(e){return this._Class&&typeof this._Class.init=="function"?this._Class.init(e):e}async deleteOne({id:e}){try{return{...await this.model.deleteOne({_id:e}),isNew:!1,data:[]}}catch(t){throw t}}findAll({config:e={},query:t,systemLog:r}){const i=Q({systemLog:r,label:"REPO_READ",message:`fn ${this._classname}.prototype.findAll`,input:[{query:{...t},systemLog:{...r}}]}),s={...this.queryOptions,...e};return new Promise((a,o)=>{this.model.findAll(t,s,(l,u,c)=>{if(l)i({level:"warn",output:l.toString()}),o(l);else{const d={isNew:!1,data:u,total:c||u.length};i({level:"info",output:{...d}}),a(d)}})})}findOne({config:e={},query:t,systemLog:r}){const i=Q({systemLog:r,label:"REPO_READ",message:`fn ${this._classname}.prototype.findOne`,input:[{query:{...t},systemLog:{...r}}]}),s={...this.queryOptions,...e};return new Promise((a,o)=>{this.model.findAll(t,s,(l,u)=>{if(l)o(l);else if(u.length===1){const c={isNew:!1,data:u,total:1};i({level:"info",output:{...c}}),a(c)}else u.length===0?o(new Error("record not found")):o(new Error("more than one is found"))})}).catch(a=>{throw i({level:"warn",output:a.toString()}),a})}saveAll({config:e={},docs:t,systemLog:r}){let i;const s=Q({systemLog:r,label:"REPO_WRITE",message:`fn ${this._classname}.prototype.saveAll`,input:[{config:e,docs:[...t],systemLog:{...r}}]});return(typeof this.model.saveAll=="function"?this.model.saveAll({config:e,docs:t}):gn({config:e,docs:t,service:this})).then(o=>{o.length!==1&&(i=null);const l={data:o,isNew:i,total:o.length};return s({level:"info",output:{...l}}),l}).catch(o=>{throw s({level:"warn",output:o.toString()}),o})}saveOne({config:e={},doc:t,systemLog:r}){const i=Q({systemLog:r,label:"REPO_WRITE",message:`fn ${this._classname}.prototype.saveOne`,input:[{config:e,doc:{...t},systemLog:{...r}}]}),s={...this.saveOptions,...e};return new Promise((a,o)=>{this.model.saveOne(t,s,(l,u)=>{l?(i({level:"warn",output:l.toString()}),o(l)):(i({level:"info",output:{...u}}),a(u))})})}}function Q({systemLog:n,label:e,message:t,input:r}={}){return({level:i,messgae:s,output:a}={})=>{n&&n.systemLogHelper&&n.systemLogHelper.log({batchId:n.batchId,label:e,level:i,message:s||t,data:{payload:{input:r,output:a}}})}}async function gn({config:n={},docs:e,service:t}){let r=null;return n.session||t.saveOptions.session?r=await _e(e,async i=>{if(i){const s=await t.saveOne({config:n,doc:i});return(s._data||s.data)[0]}return null},{concurrency:1}):r=await Promise.all(e.map(async i=>{if(i){const s=await t.saveOne({config:n,doc:i});return(s._data||s.data)[0]}return null})),r}class he{constructor(e={}){e=e||{},this._data=e.data||e._data||[],this.err=e.err,this.isNew=e.isNew||!1,this.message=e.message,this.total=e.total||0,this._instanceBuilder=e._instanceBuilder}static init(e={}){return e instanceof this?e:new this(e)}static get _classname(){return"ApiResponse"}static get _superclass(){return"ApiResponse"}get data(){return this._instanceBuilder&&typeof this._instanceBuilder=="function"?this._data.map(this._instanceBuilder):this._data}}function N({repo:n,result:e}){return he.init({...e,_instanceBuilder:t=>n.init(t)})}class me{constructor({repo:e}){this.repo=e}static get _classname(){return"Service"}static get _superclass(){return"Service"}async deleteOne({id:e}){const t=await this.repo.deleteOne({id:e});return N({repo:this.repo,result:t})}async findAll({config:e={},query:t={},systemLog:r}={}){const i=await this.repo.findAll({config:e,query:t,systemLog:r});return N({repo:this.repo,result:i})}async findOne({config:e={},query:t={},systemLog:r}={}){const i=await this.repo.findOne({config:e,query:t,systemLog:r});return N({repo:this.repo,result:i})}init(e){return this.repo.init(e)}initFromArray(e=[]){return Array.isArray(e)?e.map(t=>this.init(t)):[]}initOnlyValidFromArray(e=[]){return this.initFromArray(e).filter(t=>t)}async saveAll({config:e={},docs:t=[],systemLog:r}={}){const i=t.map(a=>e.skipInit?a:this.init(a)),s=await this.repo.saveAll({config:e,docs:i,systemLog:r});return N({repo:this.repo,result:s})}async saveOne({config:e={},doc:t={},systemLog:r}={}){const i=e.skipInit?t:this.init(t);if(i){const s=await this.repo.saveOne({config:e,doc:i,systemLog:r});return N({repo:this.repo,result:s})}return{isNew:null,data:[],err:new Error("doc is not a valid instance")}}}function ye({repo:n}){if(n===void 0)throw new Error("repo is required.");if(n._superclass!==X._superclass)throw new Error("repo is not an instance of Repo.");return new me({repo:n})}async function lt({body:n={},GeneralModel:e,UniqueKeyGenerator:t,resourceInfo:r}){const{resources:i,data:s,globalShared:a={},shared:o={},relationship:l={}}=n,u=r||n.resourceInfo;return _n(s,a,o),await Z(i,async(d,m)=>{const h=An(m,u,t,e);wn(s,l[m],d);const g=s[m],v=await h.saveAll({docs:[].concat(g)});return d[m]=Array.isArray(g)?v._data:v._data[0],d},{})}function _n(n,e={},t={}){Object.keys(t).forEach(r=>{const i=n[r];Array.isArray(i)?n[r]=i.map(s=>C.merge({},s,e,t[r]||{})):n[r]=C.merge({},i,e,t[r]||{})})}function wn(n,e={},t){Object.keys(e).forEach(r=>{const i=e[r],s=C.get(t,i);C.set(n,r,s)})}function An(n,e,t,r){const{collectionName:i,fields:s}=e[n],a=t.makeGenerator(s),o=new r({collectionName:i,uniqueKeyGenerator:a});return ye({repo:new X({model:o})})}function pe(n,e,t,r,i){const s=i||b;return!Array.isArray(n)||n.length===0?null:n.reduce((a,o)=>{const{key:l,type:u,value:c,restriction:d}=o;if(r&&typeof r=="function"?r({rule:d,data:e}):!0){let h=c;switch(u){case"array":{h=c.map(g=>t({keys:g.value.split("."),obj:e}));break}case"fromKeyValue":{const{dataPath:g,key:v}=c,D=t({keys:g.split("."),obj:e});h=s.getValuesByKey(D,v)[0];break}case"toKeyValue":{const g=t({keys:c.split("."),obj:e});h=s.fromObject(g);break}case"nested":{h=pe(c,e,t,r);break}case"path":{h=t({keys:c.split("."),obj:e});break}case"orgin":{h=c;break}case"origin":{h=c;break}default:{h=c;break}}return l?{...a,[l]:h}:typeof h=="string"?h:{...a,...h}}return a},{})}function ct(n,e){return!e||typeof e!="string"?{}:n.reduce((t,r)=>(t[r[e]]||(t[r[e]]=0),t[r[e]]++,t),{})}function T(n,e){if(e instanceof n)return e;try{const t=new n(e);return t.isValid!==!1?t:null}catch(t){return console.log(`init failed for class: ${n._classname||"no _classname"}`,t),null}}function B(n,e){return Array.isArray(e)?e.map(t=>T(n,t)):[]}function ee(n,e){return B(n,e).filter(t=>t)}function ft(n,e){const t=Array.isArray(n)?n:[],r=Array.isArray(e)?e:[],i=new Map,s=(a,o)=>a===void 0?o:Array.isArray(a)&&Array.isArray(o)?[...new Set([...a,...o])]:typeof a=="object"&&typeof o=="object"&&!Array.isArray(a)&&!Array.isArray(o)?{...a,...o}:o;return t.forEach(a=>{i.set(a.key,a.value)}),r.forEach(a=>{const o=i.get(a.key);i.set(a.key,s(o,a.value))}),Array.from(i.entries()).map(([a,o])=>({key:a,value:o}))}function ge(n,e=6){return n=n.toString(),n.length<e?ge(`0${n}`,e):n}async function _e(n,e,{concurrency:t=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:i}={}){return new Promise((s,a)=>{if(n[Symbol.iterator]===void 0&&n[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof n})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(t)&&t>=1||t===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${t}\` (${typeof t})`);const o=[],l=[],u=new Map;let c=!1,d=!1,m=!1,h=0,g=0;const v=n[Symbol.iterator]===void 0?n[Symbol.asyncIterator]():n[Symbol.iterator](),D=()=>{L(i.reason)},Tt=()=>{i==null||i.removeEventListener("abort",D)},It=R=>{s(R),Tt()},L=R=>{c=!0,d=!0,a(R),Tt()};i&&(i.aborted&&L(i.reason),i.addEventListener("abort",D,{once:!0}));const $e=async()=>{if(d)return;const R=await v.next(),q=g;if(g++,R.done){if(m=!0,h===0&&!d){if(!r&&l.length>0){L(new AggregateError(l));return}if(d=!0,u.size===0){It(o);return}const M=[];for(const[j,Vn]of o.entries())u.get(j)!==x&&M.push(Vn);It(M)}return}h++,(async()=>{try{const M=await R.value;if(d)return;const j=await e(M,q);j===x&&u.set(q,j),o[q]=j,h--,await $e()}catch(M){if(r)L(M);else{l.push(M),h--;try{await $e()}catch(j){L(j)}}}})()};(async()=>{for(let R=0;R<t;R++){try{await $e()}catch(q){L(q);break}if(m||c)break}})()})}function dt(n,e,{concurrency:t=Number.POSITIVE_INFINITY,backpressure:r=t}={}){if(n[Symbol.iterator]===void 0&&n[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof n})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(t)&&t>=1||t===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${t}\` (${typeof t})`);if(!(Number.isSafeInteger(r)&&r>=t||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${t}) and up or \`Infinity\`, got \`${r}\` (${typeof r})`);return{async*[Symbol.asyncIterator](){const i=n[Symbol.asyncIterator]===void 0?n[Symbol.iterator]():n[Symbol.asyncIterator](),s=[];let a=0,o=!1,l=0;function u(){if(o||!(a<t&&s.length<r))return;a++;const c=(async()=>{const{done:d,value:m}=await i.next();if(d)return a--,{done:!0};u();try{const h=await e(await m,l++);if(a--,h===x){const g=s.indexOf(c);g>0&&s.splice(g,1)}return u(),{done:!1,value:h}}catch(h){return a--,o=!0,{error:h}}})();s.push(c)}for(u();s.length>0;){const{error:c,done:d,value:m}=await s[0];if(s.shift(),c)throw c;if(d)return;u(),m!==x&&(yield m)}}}}const x=Symbol("skip");function ht({engine:n,template:e,value:t}={}){if(!e)return"";const r=n.init(t),i=/\{\{\s(.*?)\s\}\}/g;return e.replace(i,s=>{const a=r.pipe(s);return a==null?"":typeof a=="object"?JSON.stringify(a):a})}function mt({content:n,mapping:e}){let t=!1;typeof n=="object"&&n!==null&&(n=JSON.stringify(n),t=!0);const r=/\[\[\s*([^[\]]+?)\s*\]\]/g,i=n.replace(r,(s,a)=>{const o=a.trim();if(/^[\w.\-]+$/.test(o)){const l=o.split(".");let u=e;for(const c of l)if(c&&(u=u==null?void 0:u[c],u===void 0))break;if(u!==void 0)return u}return`<%= ${o} %>`});return t?JSON.parse(i):i}function yt(n,e={}){const{normalizeWhitespace:t=!0,removeNewlines:r=!1,trim:i=!0,preserveBasicWhitespace:s=!0,debug:a=!1}=e;if(typeof n!="string")return n;let o=n;if(a&&(console.log("Original input:",JSON.stringify(n)),console.log("Options:",{normalizeWhitespace:t,removeNewlines:r,trim:i,preserveBasicWhitespace:s})),s&&!r)if(a){const l=[];o=o.replace(/[\x00-\x08\v\f\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,u=>(l.push({char:u,code:u.charCodeAt(0),hex:`0x${u.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")}`}),"")),l.length>0?(console.log("Phase 1 (preserve mode) - Removed characters:"),l.forEach(u=>{console.log(` - Character: ${JSON.stringify(u.char)}, Code: ${u.code}, Hex: ${u.hex}`)}),console.log(`Removed ${l.length} control character(s)`)):console.log("Phase 1 (preserve mode) - No control characters found")}else o=o.replace(/[\x00-\x08\v\f\x0E-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,"");else if(a){const l=[];o=o.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,u=>(l.push({char:u,code:u.charCodeAt(0),hex:`0x${u.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")}`}),"")),l.length>0?(console.log("Phase 1 (full removal mode) - Removed characters:"),l.forEach(u=>{console.log(` - Character: ${JSON.stringify(u.char)}, Code: ${u.code}, Hex: ${u.hex}`)}),console.log(`Removed ${l.length} control character(s)`)):console.log("Phase 1 (full removal mode) - No control characters found")}else o=o.replace(/[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF\u202A-\u202E]/g,"");return a&&console.log("After Phase 1:",JSON.stringify(o)),r&&(a?(o=o.replace(/[\r\n]+/g," "),console.log("Phase 2 - Converted newlines to spaces")):o=o.replace(/[\r\n]+/g," ")),t&&(a?(o=o.replace(/[ \t]+/g," "),console.log("Phase 2 - Normalized whitespace")):o=o.replace(/[ \t]+/g," ")),a&&console.log("After Phase 2:",JSON.stringify(o)),i&&(a?(o=o.trim(),console.log("Phase 3 - Trimmed leading/trailing whitespace")):o=o.trim()),a&&(console.log("Final result:",JSON.stringify(o)),console.log("--- Sanitization complete ---")),o}function we(n){return n&&typeof n.toString=="function"?n.toString():n}function pt(n){const e=[...n];for(let t=e.length-1;t>=0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e}function U(n,e="_"){return n===null||typeof n>"u"||typeof n.toString>"u"?null:n.toString().trim().toUpperCase().replace("-",e).replace(" ",e)}function En(n,e=34){const t=Cn(e);return bn(n,t)}function bn(n,e){const{byCode:t}=e;if(n===0)return t[0];let r="";const i=e.length;for(;n>0;)r=t[n%i]+r,n=Math.floor(n/i);return r}function Cn(n){let e="9876543210ABCDEFGHJKLMNPQRSTUVWXYZ";return n===58&&(e="9876543210ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz"),$n(e)}function Sn(n){return gt(`${n}`).toLowerCase().split(" ").join("-")}function $n(n){const e={},t={},{length:r}=n;let i;for(let s=0;s<r;s++)i=n[s],e[s]=i,t[i]=s;return{byCode:e,byChar:t,length:r}}function vn(n,e){return typeof n!="string"||typeof e!="string"?!1:n.trim().toUpperCase()===e.trim().toUpperCase()}function gt(n){return n.replace(/\s+/g,"-").replace(/[.,\/#!$%\^&\*;:{}=\_`~()]/g,"")}function On({len:n=16,pattern:e="a1"}={}){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",r="abcdefghijklmnopqrstuvwxyz",i="1234567890",s="~!@#$%^&*_+-=";let a="";e.includes("A")&&(a+=t),e.includes("a")&&(a+=r),e.includes("1")&&(a+=i),e.includes("#")&&(a+=s);const o=[...a];return[...new Array(n)].map(l=>o[Math.random()*o.length|0]).join``}function Rn(n){return(typeof n!="string"?n.toString():n).split("").reverse().join("")}function Tn(n){return typeof(n==null?void 0:n.toUpperCase)=="function"?n.toUpperCase():""}function In(n){let e=34,t=8;n===void 0||(typeof n=="number"?e=n:typeof n=="object"&&n!==null&&(e=n.base??e,t=n.len??t));const r=new Date().valueOf(),i=On({len:t,pattern:"1"}),s=Rn(`${r}${i}`);return En(s,e)}function Nn(n){return n?n.trim().split(/\s+/).map((e,t)=>e?t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"").join(""):""}function Dn(n){return n?n.trim().toLowerCase():""}function Mn(n){return/[^\w\s]|_/g.test(n.replace(/_/g,""))?null:n.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/[\s\-\.]+/g,"_").toUpperCase().replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")}const te={getCssClass:Sn,isSame:vn,punctuationless:gt,safeToUpperCase:Tn,setCode:In,toCamelCase:Nn,toLowerCase:Dn,toScreamingSnakeCase:Mn};function Ae(n,e){n.add({meta:{active:{type:Boolean,default:!0},created:{type:Number},creator:{type:String},deleted:{type:Boolean,default:!1},modified:{type:Number},owner:{type:String}}}),n.pre("save",function(t){this.meta.modified=Date.now(),t()}),n.index({"meta.active":1,"meta.deleted":1},{name:"tracking_status_index",background:!0,partialFilterExpression:{"meta.active":!0,"meta.deleted":!1}})}function _t(n,e){n.path("meta")||Ae(n),n.add({metadata:[{type:Object}],remarks:[{type:Object}],tenantCode:{type:String,required:!0}}),n.index({tenantCode:1},{name:"tenant_core_index",background:!0}),n.indexes().some(i=>i.name==="tenant_status_index")||n.index({tenantCode:1,_type:1},{name:"tenant_status_index",background:!0,partialFilterExpression:{_type:"Tenant","meta.active":!0,"meta.deleted":!1}})}const jn=Object.freeze(Object.defineProperty({__proto__:null,authorize:E,calculateAge:I,changeCreatorOwner:ie,concatStringByArray:J,convertString:Qe,convertTimestampToString:et,detectControlCharacters:tt,displayName:rt,downloadFileByUrl:st,escapeRegex:at,expressHelper:ot,extractEmails:ut,formatDate:oe,generalPost:lt,getObjectByArr:pe,getValidation:S,getValueByKeys:_,groupArrayByKey:ct,init:T,initFromArray:B,initOnlyValidFromArray:ee,isConvertibleToNumber:z,mergeArraysByKey:ft,objectHelper:C,pMap:_e,pMapIterable:dt,pMapSkip:x,pReduce:Z,padZeros:ge,printControlCharReport:nt,renderByTemplate:ht,replacePlaceholders:mt,sanitizeText:yt,setId:we,shuffleArray:pt,stringFormatter:U,stringHelper:te,tenantPlugin:_t,trackingPlugin:Ae},Symbol.toStringTag,{value:"Module"}));class wt{constructor(e){e=e||{},this.expiration=e.expiration||null,this.s3Client=e.s3Client||null,this.getIdToken=e.getIdToken,this.region=e.region||"ap-east-1",this.roleArn=e.roleArn,this.roleSessionName=e.roleSessionName||"web-identity-session",this.durationSession=e.durationSession||3600,this.awsClientSts=e.awsClientSts,this.awsClientS3=e.awsClientS3}static dummyData(){return{getIdToken:()=>"mock-web-identity-token",roleArn:"arn:aws:iam::846252828949:role/oidcS3Jccpa",awsClientSts:{STSClient:class{},AssumeRoleWithWebIdentityCommand:class{}},awsClientS3:{S3Client:class{},PutObjectCommand:class{},GetObjectCommand:class{},DeleteObjectCommand:class{}}}}static init(e={}){if(e instanceof this)return e;try{const t=new this(e);return t.isValid?t:null}catch{return null}}get isExpired(){if(!this.expiration)return!0;const e=new Date,t=1*60*1e3;return e>=new Date(this.expiration.getTime()-t)}get isValid(){if(!this.getIdToken)throw new Error("Missing required configuration: getIdToken function");if(!this.roleArn)throw new Error("Missing required configuration: roleArn");if(!this.awsClientSts)throw new Error("Missing required AWS awsClientSts client configuration");if(!this.awsClientSts.STSClient)throw new Error("Missing STSClient in AWS awsClientSts client configuration");if(!this.awsClientSts.AssumeRoleWithWebIdentityCommand)throw new Error("Missing AssumeRoleWithWebIdentityCommand in AWS awsClientSts client configuration");if(!this.awsClientS3)throw new Error("Missing required AWS awsClientS3 client configuration");const e=["S3Client","PutObjectCommand","GetObjectCommand","DeleteObjectCommand"];for(const t of e)if(!this.awsClientS3[t])throw new Error(`Missing ${t} in AWS awsClientS3 client configuration`);return!0}async refreshCredentials(){try{if(!await this.getIdToken())throw new Error("getIdToken function returned empty or invalid token");const i=(await new this.awsClientSts.STSClient({region:this.region}).send(new this.awsClientSts.AssumeRoleWithWebIdentityCommand({RoleArn:this.roleArn,RoleSessionName:this.roleSessionName,WebIdentityToken:await this.getIdToken(),DurationSeconds:this.durationSession}))).Credentials;if(!i)throw new Error("No credentials returned from awsClientSts");return this.expiration=i.Expiration,this.s3Client=new this.awsClientS3.S3Client({region:this.region,credentials:{accessKeyId:i.AccessKeyId,secretAccessKey:i.SecretAccessKey,sessionToken:i.SessionToken}}),this}catch(e){throw new Error(`Failed to refresh credentials: ${e.message}`)}}async getS3Client(){return(this.isExpired||!this.s3Client)&&await this.refreshCredentials(),this.s3Client}async putObject(e){try{const t=await this.getS3Client(),r=new this.awsClientS3.PutObjectCommand(e);await t.send(r);const i=e.Key.split("/");return{url:`https://s3.${this.region}.amazonaws.com/${e.Bucket}/${e.Key}`,filename:i.pop(),folder:e.Bucket,subFolders:i}}catch(t){throw new Error(`Failed to put object: ${t.message}`)}}async getObject(e){try{const t=await this.getS3Client(),r=new this.awsClientS3.GetObjectCommand(e),i=await t.send(r);return{body:i.Body,contentType:i.ContentType,lastModified:i.LastModified,contentLength:i.ContentLength}}catch(t){throw new Error(`Failed to get object: ${t.message}`)}}async deleteObject(e){try{const t=await this.getS3Client(),r=new this.awsClientS3.DeleteObjectCommand(e);return await t.send(r),!0}catch(t){throw new Error(`Failed to delete object: ${t.message}`)}}}const Ee="_";class O extends b{static init(e={}){if(e instanceof this)return e;const t=new this({...e,key:U(e.key,Ee)});return t.isValid?t:null}static get _classname(){return"Metadata"}static mapToKeyValue(e=[],t="key",r="value"){return Array.isArray(e)?e.reduce((i,s)=>{if(s&&typeof s=="object"){const a=C.get(s,t),o=C.get(s,r);if(a!=null){const l=o!==void 0?te.toScreamingSnakeCase(String(o)):"";i.push(this.init({key:a,value:l}))}}return i},[]):[]}static merge(e,t){return(t||[]).map(r=>{const i=e.find(s=>At(s.key,r.key));return i?i.value=kn(r.value,i.value):e.push(r),r}),e}static sameKey(e,t){return At(e.key,t)}}function At(n,e){return U(n,Ee)===U(e,Ee)}function kn(n,e){return n===void 0?e:Array.isArray(n)&&Array.isArray(e)?[...new Set([...n,...e])]:typeof n=="object"&&typeof e=="object"&&!Array.isArray(n)&&!Array.isArray(e)?{...n,...e}:e}class K{constructor(e={}){var i,s,a,o,l,u;e=e||{};const t=e._id||e.id;this.id=we(t),this._type=e._type||"TrackedEntity";const r=Date.now();this.meta={active:((i=e.meta)==null?void 0:i.active)??e.active??!0,created:((s=e.meta)==null?void 0:s.created)??(e.created?new Date(e.created).getTime():r),creator:((a=e.meta)==null?void 0:a.creator)??e.creator??"",deleted:((o=e.meta)==null?void 0:o.deleted)??e.deleted??!1,modified:((l=e.meta)==null?void 0:l.modified)??(e.modified?new Date(e.modified).getTime():r),owner:((u=e.meta)==null?void 0:u.owner)??e.owner??""}}static dummyData(){const e=Date.now();return{meta:{active:!0,deleted:!1,created:e,creator:"creator",modified:e,owner:"owner"}}}static get _classname(){return"TrackedEntity"}static get _superclass(){return"TrackedEntity"}static init(e={}){return T(this,e)}static initFromArray(e=[]){return B(this,e)}static initOnlyValidFromArray(e=[]){return ee(this,e)}get __valid(){return{}}get isValid(){return!!this}get active(){var e;return((e=this.meta)==null?void 0:e.active)??this.active}get created(){var e;return((e=this.meta)==null?void 0:e.created)??this.created}get creator(){var e;return((e=this.meta)==null?void 0:e.creator)??this.creator}get deleted(){var e;return((e=this.meta)==null?void 0:e.deleted)??this.deleted}get modified(){var e;return((e=this.meta)==null?void 0:e.modified)??this.modified}get owner(){var e;return((e=this.meta)==null?void 0:e.owner)??this.owner}changeCreatorOwner({source:e,target:t}){return ie(this,{source:e,target:t}).setModified()}delete(){return this.setDeleted()}setActive(){return this.meta?this.meta.active=!0:this.active=!0,this}setDeleted(){return this.meta?this.meta.deleted=!0:this.deleted=!0,this}setModified(){const e=Date.now();return this.meta?this.meta.modified=e:this.modified=e,this}setOwner(e){return e?(this.meta?this.meta.owner=e:this.owner=e,this):this}unsetActive(){return this.meta?this.meta.active=!1:this.active=!1,this}unsetDeleted(){return this.meta?this.meta.deleted=!1:this.deleted=!1,this}update(e){const t=this.constructor.ALLOWED_META_PROPS,r={...this.meta};return e.meta&&t.forEach(i=>{e.meta.hasOwnProperty(i)&&(r[i]=e.meta[i])}),t.forEach(i=>{e.hasOwnProperty(i)&&(r[i]=e[i])}),JSON.stringify(this.meta)!==JSON.stringify(r)&&(this.meta=r),this.setModified()}}Nt(K,"ALLOWED_META_PROPS",["active","deleted","owner"]);class Et extends K{constructor(e){e=e||{},super(e),this.id=e.id,this.body=e.body,this.data=e.data,this.dirty=e.dirty,this.metadata=O.initOnlyValidFromArray(e.metadata),this.remarks=b.initOnlyValidFromArray(e.remarks),this.threadID=e.threadID,this.title=e.title}static get _classname(){return"PushEnvelope"}static get _superclass(){return"PushEnvelope"}static init(e={}){return T(this,e)}get _classname(){return"PushEnvelope"}get _superclass(){return"PushEnvelope"}get isValid(){return super.isValid&&this.data}}const A={trace:{weight:10,name:"TRACE"},debug:{weight:20,name:"DEBUG"},info:{weight:30,name:"INFO"},warn:{weight:40,name:"WARN"},error:{weight:50,name:"ERROR"},critical:{weight:60,name:"CRITICAL"},alert:{weight:70,name:"ALERT"},emergency:{weight:80,name:"EMERGENCY"}};class be{constructor(e={}){e=e||{},this.data=e.data,this.level=e.level,this.timestamp=e.timestamp,this.stackTrace=xn(e),this.name=e.name??"",this.zone=e.zone}toString(){return`[${this.logName(this)}] ${this.serialize(this)}
10
+ ${this.stackTrace||""}
11
+ ${this.zone||""}`}logName(){let e=`${this.timestamp}`;return this.level.name&&(e+=`>${this.level.name}`),this.name&&(e+=`>${this.name}`),e}serialize(){var e;return this.data instanceof Error||typeof((e=this.data)==null?void 0:e.message)<"u"?this.data.message:this.data===null?"null":this.data===void 0?"undefined":typeof this.data=="object"?JSON.stringify(this.data):this.data.toString()}}function xn(n){var e;return n.stackTrace?n.stackTrace:n.data instanceof Error||typeof((e=n.data)==null?void 0:e.stack)<"u"?n.data.stack:null}let Ce;class F{constructor(e={}){const{level:t}=e;this._level=t??A.debug,this._handlers=new Map}static getInstance(e){return Ce||(Ce=new F(e)),Ce}setLevel(e){return this._level=e,this}addHandler(e){return e instanceof F&&this._handlers.set(e.constructor,e),this}removeHandler(e){return this._handlers.delete(e),this}receive({record:e}){var t,r;((t=e.level)==null?void 0:t.weight)<((r=this._level)==null?void 0:r.weight)||(this._handlers.forEach(i=>{i.receive({record:e})}),this.logBody(e))}logBody(e){}trace(e,t){return this._log({level:A.trace,object:t,options:e})}debug(e,t){return this._log({level:A.debug,object:t,options:e})}info(e,t){return this._log({level:A.info,object:t,options:e})}warn(e,t){return this._log({level:A.warn,object:t,options:e})}error(e,t){return this._log({level:A.error,object:t,options:e})}critical(e,t){return this._log({level:A.critical,object:t,options:e})}_log({level:e,object:t,options:r}){typeof t>"u"&&(t=r,r="");const i=Date.now(),s=new be({data:t,level:e,timestamp:i,stackTrace:(t==null?void 0:t.stack)??(r==null?void 0:r.stack)??null,name:r??""});return this.receive({record:s})}}class bt extends F{constructor(e={}){const{format:t}=e;super(e),this.format=t}logBody(e){const t=e.logName(),r=this.format?this.format(e):e.serialize();switch(e.level){case A.error:case A.critical:case A.alert:case A.emergency:console.error(`[${t}] ${r}`,e.stackTrace||"");break;case A.warn:console.warn(`[${t}] ${r}`,e.stackTrace||"");break;case A.info:console.error(`[${t}] ${r}`,e.stackTrace||"");break;case A.debug:console.error(`[${t}] ${r}`,e.stackTrace||"");break;default:console.error(`[${t}] ${r}`,e.stackTrace||"")}}}const ne={debug:{name:"DEBUG"},production:{name:"PRODUCTION"}};function Ct(n){const e=n.toLowerCase();return ne[e]?ne[e]:null}const Fn=["attributes","ref"];class H{constructor(e={}){e=e||{},this.attributes=b.initOnlyValidFromArray(e.attributes),this.ref=e.ref||{}}static get _classname(){return"QMeta"}static get _superclass(){return"QMeta"}static init(e={}){return e instanceof H?e:new H(e)}addAttribute(e){const t=b.init(e);if(!t)throw new Error("invalid meta attribute");return this.attributes.push(t),this}update(e){return Object.keys(e).forEach(t=>{Fn.includes(t)&&(t==="attributes"?this[t]=b.initOnlyValidFromArray(e[t]):this[t]=e[t])}),this}}class re{constructor(e){e=e||{};const{_Actor:t}=e._constructor||{};this._Actor=t,this._actor=e._actor,this.actorCode=typeof e=="number"?null:e.actorCode||null,this.timestamp=typeof e=="number"?e:e.timestamp||null}static get _classname(){return"ActionRecord"}static get _superclass(){return"ActionRecord"}static dummyData(){return{timestamp:new Date().valueOf()}}static init(e={}){return T(this,e)}get _classname(){return"ActionRecord"}get _superclass(){return"ActionRecord"}get actor(){return this._Actor&&typeof this._Actor.init=="function"?this._Actor.init(this._actor):this._actor}get isValid(){return!!this.timestamp}update(e){return typeof e=="number"?(this.timestamp=e,this):(Object.keys(e).forEach(t=>{this[t]=e[t]}),this)}}const Pn=["_ActionRecord","created"];class Se{constructor(e){e=e||{};const{_ActionRecord:t}=e._constructor||{};this._ActionRecord=t&&t._superclass===re._superclass?t:re,this.created=this._ActionRecord.init(e.created||{timestamp:new Date().valueOf()})}static get _classname(){return"Status"}static get _superclass(){return"Status"}static dummyData(){return{}}static init(e={}){return T(this,e)}static initFromArray(e=[]){return B(this,e)}static initOnlyValidFromArray(e=[]){return ee(this,e)}get _classname(){return"Status"}get _superclass(){return"Status"}get isCreated(){var e;return((e=this.created)==null?void 0:e.timestamp)!==null}get isValid(){return!!this}setValue(e,t,r){const i=e||Date.now();return this[r]=this[r]instanceof this._ActionRecord?this[r].update({actorCode:t,timestamp:i}):this._ActionRecord.init({actorCode:t,timestamp:i}),this}update(e){return Object.keys(e).forEach(t=>{Pn.includes(t)||(this[t]=this[t]instanceof this._ActionRecord?this[t].update(e[t]):this._ActionRecord.init(e[t]))}),this}}class St extends Se{constructor(e){e=e||{},super(e),this.archived=this._ActionRecord.init(e.archived),this.completed=this._ActionRecord.init(e.completed),this.discarded=this._ActionRecord.init(e.discarded),this.drafted=this._ActionRecord.init(e.drafted)}static get _classname(){return"StatusDocument"}get _classname(){return"StatusDocument"}get isArchived(){var e;return((e=this.created)==null?void 0:e.timestamp)!==null}get isCompleted(){var e;return((e=this.completed)==null?void 0:e.timestamp)!==null}get isDiscarded(){var e;return((e=this.discarded)==null?void 0:e.timestamp)!==null}get isDrafted(){var e;return((e=this.drafted)==null?void 0:e.timestamp)!==null}get isValid(){return super.isValid}setArchived(e,t){return this.setValue(e,t,"archived")}setCompleted(e,t){return this.setValue(e,t,"completed")}setDiscarded(e,t){return this.setValue(e,t,"discarded")}setDrafted(e,t){return this.setValue(e,t,"drafted")}}class $t extends K{constructor(e={}){e=e||{},super(e),this._type=e._type||"TenantAwareEntity",this._tenant=e._tenant,this.metadata=O.initOnlyValidFromArray(e.metadata),this.remarks=b.initOnlyValidFromArray(e.remarks),this.tenantCode=e.tenantCode}static dummyData(){return{...super.dummyData(),metadata:[],remarks:[],tenantCode:"tenantCode"}}static get _classname(){return"TenantAwareEntity"}static get _superclass(){return"TenantAwareEntity"}get __valid(){return{...super.__valid,tenantCode:this.tenantCode}}get isValid(){return super.isValid&&!!this.tenantCode}insertOrUpdateMetadata(e,t){return this.metadata=O.insertOrUpdateRecord(this.metadata,e,t),this}getMetadata(){return this.metadata}getMetadataByKey(e){return O.foundByKey(this.metadata,e)}getMetadataValueByKey(e){const t=this.getMetadataByKey(e);return t?t.value:null}getMetadataValueByKeys(e,t){if(!Array.isArray(e))return null;if(t=t||this.metadata,e.length===0)return t;const r=e.shift(),i=O.getMetadataValueByKeyAsArray(t,r);return this.getMetadataValueByKeys(e,i)}getMetadataValueByKeyAsArray(e){return O.getMetadataValueByKeyAsArray(this.metadata,e)}getRemarks(){return this.remarks}getRemarkByKey(e){return b.foundByKey(this.remarks,e)}getRemarksValueByKey(e){const t=this.getRemarkByKey(e);return t?t.value:null}getTenantCode(){return this.tenantCode}update(e){return e.metadata&&Array.isArray(e.metadata)&&(this.metadata=O.initOnlyValidFromArray(e.metadata)),e.remarks&&Array.isArray(e.remarks)&&(this.remarks=b.initOnlyValidFromArray(e.remarks)),super.update(e)}}class vt{static get _classname(){return"UniqueKeyGenerator"}static get _superclass(){return"UniqueKeyGenerator"}static makeFormatter({fieldName:e,format:t,options:r}){switch(t){case"set_code":return Ot(e);default:return Ot(e)}}static makeGenerator(e){const t=e.map(r=>this.makeFormatter(r));return async r=>await Z(t,async(s,a)=>{const o=await a(r);return Object.assign(s,o)},r)}}function Ot(n,e){return async(t={})=>t[n]?{}:{[n]:te.setCode()}}class W{constructor(e={}){this.blockUI=e.blockUI??!1,this.callback=e.callback??null,this.data=e.data??null,this.event=e.event??null,this.reloadPage=e.reloadPage??!1,this.sessionId=e.sessionId??null,this.timeout=e.timeout??3e4}static get _classname(){return"WebAppRequest"}static get _superclass(){return"WebAppRequest"}static init(e){if(e instanceof W)return e;const t=new W(e);return t.isValid?t:null}static dummyData(){return{data:null,sessionId:"sessionId"}}get isValid(){return!!this.sessionId}getId(){try{return this.sessionId}catch{return null}}}const Rt={EXCUTE_EVENT_ERROR:"EXCUTE_EVENT_ERROR",NOT_FOUND:"NOT_FOUND",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",UNAUTHORIZED:"UNAUTHORIZED",VALIDATION_ERROR:"VALIDATION_ERROR"};class P{constructor(e={}){this.code=e.code??null,this.message=e.message??"",this.timestamp=e.timestamp??null}static init(e){if(e instanceof P)return e;const t=new P(e);return t.isValid?t:null}get isValid(){return!!this.code}}class Y{constructor(e={}){this.data=e.data??null,this.errorDetail=P.init(e.errorDetail),this.sessionId=e.sessionId??null,this.success=e.success??!1}static get _classname(){return"WebAppResponse"}static get _superclass(){return"WebAppResponse"}static init(e){if(e instanceof Y)return e;const t=new Y(e);return t.isValid?t:null}static dummyData(){return{data:null,errorDetail:null,sessionId:"sessionId",success:!1}}get isValid(){return!!this.sessionId}getId(){try{return this.sessionId}catch{return null}}}const Ln={...jn,...Object.freeze(Object.defineProperty({__proto__:null,ActionRecord:re,ApiResponse:he,AwsStsS3Client:wt,ConsoleLog:bt,ERROR_CODES:Rt,ErrorDetail:P,KeyValueObject:b,LogRecord:be,Metadata:O,PushEnvelope:Et,QLog:F,QLogEnv:ne,QLogLevel:A,QMeta:H,Repo:X,Service:me,Status:Se,StatusDocument:St,TemplateCompiler:ce,TenantAwareEntity:$t,TrackedEntity:K,UniqueKeyGenerator:vt,WebAppRequest:W,WebAppResponse:Y,getQLogEnv:Ct,makeApiResponse:N,makeService:ye},Symbol.toStringTag,{value:"Module"}))};f.ActionRecord=re,f.ApiResponse=he,f.AwsStsS3Client=wt,f.ConsoleLog=bt,f.ERROR_CODES=Rt,f.ErrorDetail=P,f.KeyValueObject=b,f.LogRecord=be,f.Metadata=O,f.PushEnvelope=Et,f.QLog=F,f.QLogEnv=ne,f.QLogLevel=A,f.QMeta=H,f.Repo=X,f.Service=me,f.Status=Se,f.StatusDocument=St,f.TemplateCompiler=ce,f.TenantAwareEntity=$t,f.TrackedEntity=K,f.UniqueKeyGenerator=vt,f.WebAppRequest=W,f.WebAppResponse=Y,f.authorize=E,f.calculateAge=I,f.changeCreatorOwner=ie,f.concatStringByArray=J,f.convertString=Qe,f.convertTimestampToString=et,f.default=Ln,f.detectControlCharacters=tt,f.displayName=rt,f.downloadFileByUrl=st,f.escapeRegex=at,f.expressHelper=ot,f.extractEmails=ut,f.formatDate=oe,f.generalPost=lt,f.getObjectByArr=pe,f.getQLogEnv=Ct,f.getValidation=S,f.getValueByKeys=_,f.groupArrayByKey=ct,f.init=T,f.initFromArray=B,f.initOnlyValidFromArray=ee,f.isConvertibleToNumber=z,f.makeApiResponse=N,f.makeService=ye,f.mergeArraysByKey=ft,f.objectHelper=C,f.pMap=_e,f.pMapIterable=dt,f.pMapSkip=x,f.pReduce=Z,f.padZeros=ge,f.printControlCharReport=nt,f.renderByTemplate=ht,f.replacePlaceholders=mt,f.sanitizeText=yt,f.setId=we,f.shuffleArray=pt,f.stringFormatter=U,f.stringHelper=te,f.tenantPlugin=_t,f.trackingPlugin=Ae,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
12
+ //# sourceMappingURL=q-utilities.umd.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@questwork/q-utilities",
3
- "version": "0.1.30",
4
- "description": "Questwork QUtilities",
3
+ "version": "0.1.33",
4
+ "description": "Questwork qUtilities",
5
5
  "author": {
6
6
  "name": "Questwork Consulting Limited",
7
7
  "email": "info@questwork.com",
@@ -9,45 +9,43 @@
9
9
  },
10
10
  "license": "MIT",
11
11
  "scripts": {
12
- "build": "cross-env NODE_ENV=production minimize=false gulp",
13
- "build:wp": "cross-env NODE_ENV=production minimize=false gulp wp",
12
+ "build": "vite build",
13
+ "build:copy": "vite build && pnpm run copy",
14
+ "copy": "pnpm run copy:congress && pnpm run copy:wordpress",
15
+ "copy:congress": "cp dist/q-utilities.umd.js ../congress.system/public/libs/q-utilities/",
16
+ "copy:wordpress": "cp dist/q-utilities.umd.js ../wordpress.plugins/wp-q-components/assets/js/q-utilities/",
14
17
  "lint": "eslint .",
15
- "test:helpers": "NODE_ENV=test mocha --exit 'lib/helpers/test.setup.js' 'lib/helpers/**/*.spec.js'",
16
- "test:models": "NODE_ENV=test mocha --exit 'lib/test.setup.js' 'lib/**/*.spec.js'"
18
+ "test": "vitest run",
19
+ "test:runtime": "node tests/runtime-test.js",
20
+ "test:all": "pnpm run build && pnpm run test:runtime"
17
21
  },
18
22
  "type": "module",
19
23
  "exports": {
20
24
  ".": {
21
- "require": "./dist/index.min.cjs",
25
+ "require": "./dist/q-utilities.cjs",
22
26
  "import": "./dist/q-utilities.esm.js",
23
- "default": "./dist/q-utilities.min.js"
27
+ "default": "./dist/q-utilities.umd.js",
28
+ "types": "./dist/q-utilities.d.ts"
24
29
  }
25
30
  },
26
- "dependencies": {
27
- "bwip-js": "^4.7.0"
28
- },
31
+ "types": "./dist/q-utilities.d.ts",
29
32
  "devDependencies": {
30
33
  "@aws-sdk/client-s3": "^3.812.0",
31
34
  "@aws-sdk/client-sts": "^3.812.0",
32
- "@babel/core": "^7.27.1",
33
- "@babel/eslint-parser": "^7.27.1",
34
35
  "@jmespath-community/jmespath": "^1.3.0",
35
36
  "@questwork/q-eslint-config": "^0.1.8",
36
- "babel-loader": "^8.2.4",
37
- "babel-plugin-component": "^1.1.1",
37
+ "@types/chai": "^4.3.16",
38
+ "@types/mocha": "^10.0.10",
39
+ "@types/sinon": "^17.0.3",
40
+ "@types/sinon-chai": "^3.2.12",
38
41
  "chai": "^4.5.0",
39
- "clean-webpack-plugin": "^4.0.0",
40
- "cross-env": "^7.0.3",
41
- "del": "^8.0.0",
42
42
  "eslint": "^9.32.0",
43
- "gulp": "^4.0.2",
44
- "gulp-rename": "^2.0.0",
45
- "mocha": "^7.2.0",
46
43
  "sinon": "9.2.4",
47
44
  "sinon-chai": "3.7.0",
48
- "webpack": "^5.75.0",
49
- "webpack-cli": "^4.9.2",
50
- "webpack-node-externals": "^3.0.0"
45
+ "typescript": "^5.9.3",
46
+ "vite": "^5.4.10",
47
+ "vite-plugin-dts": "^4.5.4",
48
+ "vitest": "^2.1.4"
51
49
  },
52
50
  "engines": {
53
51
  "node": ">=10.0.0"
@@ -1,60 +0,0 @@
1
- name: Publish to npm on Tag
2
- on:
3
- push:
4
- tags:
5
- - 'v*'
6
- workflow_dispatch:
7
-
8
- jobs:
9
- publish:
10
- runs-on: ubuntu-latest
11
- permissions:
12
- contents: read
13
- id-token: write # OIDC
14
- # environment: production
15
- steps:
16
- - uses: actions/checkout@v4
17
- with:
18
- fetch-depth: 0 # Needed to get tag information
19
-
20
- - name: Install pnpm
21
- uses: pnpm/action-setup@v4
22
- with:
23
- version: 9
24
-
25
- - uses: actions/setup-node@v4
26
- with:
27
- node-version: 20.x
28
- registry-url: https://registry.npmjs.org/
29
- cache: pnpm
30
-
31
- - name: Install dependencies
32
- run: pnpm install
33
-
34
- - name: Build
35
- run: |
36
- BUILD_COMMAND=$(node -p "(require('./package.json').scripts || {}).build")
37
- if [ "$BUILD_COMMAND" = "undefined" ]; then
38
- echo "::notice::Can't find a build script in package.json, skip."
39
- else
40
- pnpm run build
41
- fi
42
-
43
- # - name: Publish to npm
44
- # # if: steps.version-check.outputs.should_publish == 'true'
45
- # run: pnpm publish --no-git-checks --access public
46
- # env:
47
- # NODE_AUTH_TOKEN: ${{ secrets.QW_NPM_TOKEN }}
48
-
49
- - name: Update npm
50
- run: |
51
- NPM_VERSION=$(npm -v)
52
- echo "Current npm version: $NPM_VERSION"
53
- if ! npx semver -r ">=11.5.1" "$NPM_VERSION"; then
54
- echo "npm version $NPM_VERSION is too old. Installing latest npm..."
55
- npm install -g npm@latest
56
- echo "Updated npm version: $(npm -v)"
57
- fi
58
-
59
- - name: Publish to npm
60
- run: npm publish --no-git-checks --access public