@jdlien/validator-utils 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -114,3 +114,79 @@ Build the project for testing/release:
114
114
  ```bash
115
115
  pnpm build
116
116
  ```
117
+
118
+ ### Release Checklist
119
+
120
+ 1. Ensure 100% test coverage: `pnpm coverage`
121
+ 2. Check bundle size hasn't grown unexpectedly: `pnpm size:wire`
122
+ 3. Update version in `package.json` with correct semantic versioning
123
+ 4. Update `CHANGELOG.md` with details of all changes
124
+ 5. Update `README.md` to ensure documentation is current
125
+ 6. Verify new functions are exported from `index.ts`
126
+ 7. Run `pnpm build` and ensure it completes with no errors
127
+ 8. Commit and push all changes to git
128
+ 9. Tag the release to match `package.json` version: `git tag v2.x.x && git push --tags`
129
+ 10. Publish to npm: `pnpm publish` (may require `npm login` first)
130
+ 11. Update live demo at https://jdlien.com/validator/: pull, `pnpm update` and `pnpm build` on server
131
+
132
+ ## FAQ
133
+
134
+ ### What date formats does `parseDate` accept?
135
+
136
+ Very flexible. It handles ISO 8601 (`2024-01-15`), US (`01/15/2024`, `1-15-24`), European (`15.01.2024`), named months (`Jan 15, 2024`, `15 January 2024`), compact (`20240115`, `240115`), relative keywords (`today`, `tomorrow`, `yesterday`), and two-digit years (interpreted within 20 years of current date). Day names are ignored. The parser intelligently determines what format dates are in based on heuristics, so even more formats than this are supported. For the most part, if it looks like a date used in the western world, it's supported.
137
+
138
+ ### Does it handle timezones?
139
+
140
+ No. All dates are parsed and returned in local time. If you pass an ISO string with a timezone offset, the timezone is ignored and the literal date/time values are used.
141
+
142
+ ### Does it support non-English date formats?
143
+
144
+ Yes. It fully supports Chinese (`2024年1月15日`), Japanese, and Korean (`2024년 1월 15일`) date formats. It also recognizes common French (`février`, `avril`, `mai`, `juin`, `juillet`, `août`) and Spanish (`enero`, `abril`, `agosto`) month prefixes, and falls back to the browser's `Date` parser for additional locales.
145
+
146
+ ### Why does `parseDate` return an Invalid Date?
147
+
148
+ Common causes: unrecognized format, ambiguous input the parser can't resolve, or genuinely invalid dates. Try a more explicit format like `YYYY-MM-DD`. Use `isDate()` to check validity before using the result.
149
+
150
+ ### Can I tree-shake to only include functions I use?
151
+
152
+ Yes. The package has `"sideEffects": false` in package.json, so bundlers can eliminate unused exports. Use named imports (`import { parseDate } from '...'`) for best results.
153
+
154
+ ### Why is the ESM build larger than CJS?
155
+
156
+ The ESM build (~15KB) preserves newlines for debuggability; CJS/UMD (~12KB) are fully minified. The gzipped sizes are nearly identical (~4.7-5.2KB) since whitespace compresses well.
157
+
158
+ ### Does it work in Node.js?
159
+
160
+ Mostly. Two functions require a browser environment:
161
+ - `isColor()` uses `CSS.supports()` — returns `false` in Node for non-trivial colors
162
+ - `parseColor()` uses a canvas element — will throw in Node without a canvas polyfill
163
+
164
+ All other functions work in Node.js.
165
+
166
+ ### What browsers are supported?
167
+
168
+ Modern browsers (ES2020+). No IE11 support. The UMD build works in any browser that supports ES6.
169
+
170
+ ### When should I use this vs `@jdlien/validator`?
171
+
172
+ Use **validator-utils** when you only need parsing/validation functions (e.g., `parseDate`, `isEmail`). Use **@jdlien/validator** when you need form validation with error messages, DOM integration, and field-level validation rules.
173
+
174
+ ### Why use this instead of date-fns, dayjs, or moment.js?
175
+
176
+ Size and focus. This library is ~5KB gzipped vs 20-70KB+ for full date libraries. It's optimized for parsing messy user input (forms), not date manipulation. If you need date arithmetic, duration formatting, or timezone support, use a dedicated date library.
177
+
178
+ ### Are TypeScript types included?
179
+
180
+ Yes. Type declarations are bundled in the package (`dist/index.d.ts`).
181
+
182
+ ### How strict is date validation?
183
+
184
+ `parseDate` is lenient — it tries to extract a valid date from messy input. A nonexistent date like "feb30" or "Apr 31" will 'wrap' to the next month and return 'March 2' or 'May 1' of the current year. Completely invalid dates or nonsensical input returns `Invalid Date`. Use `isDate()` to verify the result is valid before using it.
185
+
186
+ ### What counts as a valid email?
187
+
188
+ The `isEmail` function uses a practical regex that covers most real-world addresses: alphanumeric local parts with common special characters, domain with at least one dot, and a 2+ character TLD. By design, it's not fully RFC 5322 compliant (which allows quoted strings and other rarities).
189
+
190
+ ### Does `isNANPTel` require dashes?
191
+
192
+ `isNANPTel` validates the format `###-###-####` with dashes. Use `parseNANPTel` first to normalize various inputs (spaces, dots, parentheses) into this format, then validate.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=/^(?:[a-z+]+:)?\/\//i,C=/^(?:[-a-z+]+:)?\/\//i,R=/^\d{5}(-\d{4})?$/,H=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,_=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,I=/^\d{3}-\d{3}-\d{4}$/,B=/^-?\d*$/,L=/^-?\d*\.?\d*$/;function h(e){let t=e.trim().toLowerCase();if(t==="now"){const u=new Date;return{hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds()}}if(t==="noon")return{hour:12,minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let i=+s[1],a=+(s[2]||0),o=+(s[3]||0);const c=s[4]?.toLowerCase();return c==="p"&&i<12&&(i+=12),c==="a"&&i===12&&(i=0),i>23||a>59||o>59?null:{hour:i,minute:a,second:o}}function P(e){return h(e)!==null}function Z(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const z="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",A=new RegExp(`(${z})[a-z]*`,"i");function O(e){return new Date(`1 ${e} 2000`).getMonth()}function M(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function T(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="tomorrow")return new Date(n.setDate(n.getDate()+1));t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let s=0,i=0,a=0;const o=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(o){const p=h(o[1]);if(p&&({hour:s,minute:i,second:a}=p),t=t.replace(o[0],"").trim(),!t||t.length<=2){const g=new Date;return new Date(g.getFullYear(),g.getMonth(),g.getDate(),s,i,a)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),s,i,a);if(/^\d{6}$/.test(t))return new Date(M(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),s,i,a);const c=t.match(A);let u=-1,l=0,r=0;c&&(u=O(c[1]),t=t.replace(c[0]," ").trim());const m=t.match(/'(\d{2})\b/);m&&(l=M(+m[1]),t=t.replace(m[0]," ").trim());const d=t.match(/\d+/g)?.map(Number)||[];if(u>=0)d.length>=2?d[0]>99?(l=d[0],r=d[1]):d[1]>99?(l=d[1],r=d[0]):d[0]>31?(r=d[1],l=M(d[0])):d[1]>31?(r=d[0],l=M(d[1])):(r=d[0],l=l||M(d[1])):d.length===1&&(r=d[0],l=l||new Date().getFullYear());else if(d.length>=3){const[p,g,f]=d;p>31?(l=p,u=g-1,r=f):p>12&&f>12?(r=p,u=g-1,l=f>31?f:M(f)):f>31||f>12?(u=p-1,r=g,l=f>31?f:M(f)):(g>12,u=p-1,r=g,l=M(f))}else d.length===2&&(u=d[0]-1,r=d[1],l=l||new Date().getFullYear());return l&&u>=0&&r&&r>=1&&r<=31?new Date(l>99?l:M(l),u,r,s,i,a):new Date("")}function w(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(c,u,l,r,m)=>`${u}${m?`${l}:${r}:${m}`:`${l}:${r}`}`),/^now$/i.test(t)){const c=new Date;return c.setMilliseconds(0),c}if(/^noon$/i.test(t)){const c=new Date;return new Date(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0)}let n=null,s=t;const i=[/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const c of i){const u=t.match(c);if(u){const l=h(u[0]);if(l){n=l,s=t.replace(u[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const c=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(c){const u=c[2],l=(c[3]||"").replace(/\s+/g,"");let r=u+l;u.length===6&&(r=`${u.slice(0,2)}:${u.slice(2,4)}:${u.slice(4,6)}${l}`);const m=h(r);m&&(n=m,s=c[1])}}if(!n){const c=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(c){const u=c[2]+(c[3]||""),l=h(u);l&&A.test(c[1])&&(n=l,s=c[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const c=new Date;return new Date(c.getFullYear(),c.getMonth(),c.getDate(),n.hour,n.minute,n.second)}const a=T(s);if(isNaN(a.getTime()))return null;const o=n||{hour:0,minute:0,second:0};return new Date(a.getFullYear(),a.getMonth(),a.getDate(),o.hour,o.minute,o.second)}function Y(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=T(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),i=e.getDate(),a=e.getDay(),o=e.getHours(),c=e.getMinutes(),u=e.getSeconds(),l=e.getMilliseconds(),r=(b,$=2)=>String(b).padStart($,"0"),m=o%12||12,d=o<12?"AM":"PM",p=["January","February","March","April","May","June","July","August","September","October","November","December"],g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f={YYYY:n,YY:String(n).slice(-2),MMMM:p[s],MMM:p[s].slice(0,3),MM:r(s+1),M:s+1,DD:r(i),D:i,dddd:g[a],ddd:g[a].slice(0,3),dd:g[a].slice(0,2),d:a,HH:r(o),H:o,hh:r(m),h:m,mm:r(c),m:c,ss:r(u),s:u,SSS:r(l,3),A:d,a:d.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(b,$)=>$??String(f[b]))}const j={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},K=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function U(e){return e.replace(K,t=>j[t])}function x(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(T(e).getTime())}function G(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=w(e);return t!==null&&!isNaN(t.getTime())}function V(e,t="YYYY-MMM-DD"){const n=T(e);return isNaN(n.getTime())?"":Y(n,t)}function k(e,t="YYYY-MMM-DD h:mm A"){const n=w(e);return n&&!isNaN(n.getTime())?Y(n,t):""}function J(e,t="h:mm A"){const n=h(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),Y(s,t)}const y={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function W(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const i in y)if(s.startsWith(i))return y[i];throw new Error("Invalid month name: "+e)}function E(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,i]=t,a=parseInt(s)*(n==="-"?-1:1),o=new Date;switch(o.setHours(0,0,0,0),i.toLowerCase()){case"d":o.setDate(o.getDate()+a);break;case"w":o.setDate(o.getDate()+a*7);break;case"m":o.setMonth(o.getMonth()+a);break;case"y":o.setFullYear(o.getFullYear()+a);break}return o}const S=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bnow\b|T\d{1,2})/i,X=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function v(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const r=new Date;return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}const n=r=>{const m=r.trim();if(!m)return{date:null,hasTime:!1,valid:!0};const d=E(m);if(d)return{date:d,hasTime:!1,valid:!0};const p=m.search(X);if(p===-1)return{date:null,hasTime:!1,valid:!1};const g=m.search(S);if(g!==-1&&g<p)return{date:null,hasTime:!1,valid:!1};const f=w(m);return f&&!isNaN(f.getTime())?{date:f,hasTime:S.test(m),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let r=0;r<t.length;r+=1){if(t[r]!==":")continue;const m=n(t.slice(0,r)),d=n(t.slice(r+1));if(m.valid&&d.valid){s={start:m,end:d};break}}if(!s){const r=n(t);return r.valid&&r.date?r.hasTime?e.getTime()===r.date.getTime():e.getFullYear()===r.date.getFullYear()&&e.getMonth()===r.date.getMonth()&&e.getDate()===r.date.getDate():!0}const i=s.start,a=s.end,c=i.hasTime||a.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let u=null;i.date&&(u=i.hasTime?i.date.getTime():new Date(i.date.getFullYear(),i.date.getMonth(),i.date.getDate()).getTime());let l=null;return a.date&&(l=a.hasTime?a.date.getTime():new Date(a.date.getFullYear(),a.date.getMonth(),a.date.getDate(),23,59,59,999).getTime()),!(u!==null&&c<u||l!==null&&c>l)}function q(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Q(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function ee(e){return e.length<=255&&_.test(e)}function te(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function ne(e){return I.test(e)}function re(e){return e.replace(/[^0-9]/g,"")}function se(e){return B.test(e)}function ie(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,i=!1;for(let a=0;a<t.length;a+=1){const o=t[a];if(o==="-"){!i&&n.length===0&&(n+="-",i=!0);continue}if(o==="."){s||(n+=".",s=!0);continue}n+=o}return n}function ae(e){return L.test(e)}const oe={"":1,K:1e3,M:1e6,G:1e9,T:1e12},ce={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function le(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),i=n[2]?.toUpperCase()||"",a=i.includes("I"),o=i.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(a?ce:oe)[o]}function ue(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let i=0,a=e;for(;a>=n&&i<s.length-1;)a/=n,i++;let o=Math.round(a*10)/10;return o>=n&&i<s.length-1&&(o=1,i++),`${o%1===0?o.toFixed(0):o.toFixed(1)} ${s[i]}`}function de(e){return e=e.trim(),F.test(e)?e:"https://"+e}function me(e){return C.test(e)}function fe(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function ge(e){return R.test(e)}function pe(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function Me(e){return H.test(e)}function he(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let D=null;const N=new Map;function Te(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);D||(D=document.createElement("canvas"),D.willReadFrequently=!0);const t=D.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function De(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}exports.formatBytes=ue;exports.formatDateTime=Y;exports.isColor=he;exports.isDate=x;exports.isDateInRange=v;exports.isDateTime=G;exports.isEmail=ee;exports.isFormControl=q;exports.isInteger=se;exports.isMeridiem=Z;exports.isNANPTel=ne;exports.isNumber=ae;exports.isPostalCA=Me;exports.isTime=P;exports.isType=Q;exports.isUrl=me;exports.isZip=ge;exports.momentToFPFormat=U;exports.monthToNumber=W;exports.normalizeValidationResult=De;exports.parseBytes=le;exports.parseColor=Te;exports.parseDate=T;exports.parseDateTime=w;exports.parseDateTimeToString=k;exports.parseDateToString=V;exports.parseInteger=re;exports.parseNANPTel=te;exports.parseNumber=ie;exports.parsePostalCA=pe;exports.parseRelativeDate=E;exports.parseTime=h;exports.parseTimeToString=J;exports.parseUrl=de;exports.parseZip=fe;exports.yearToFull=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=/^(?:[a-z+]+:)?\/\//i,R=/^(?:[-a-z+]+:)?\/\//i,H=/^\d{5}(-\d{4})?$/,_=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,I=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,B=/^\d{3}-\d{3}-\d{4}$/,L=/^-?\d*$/,P=/^-?\d*\.?\d*$/,y={midnight:0,noon:12,midday:12};function D(e){let t=e.trim().toLowerCase().replace(/\.+$/g,"");if(t==="now"){const u=new Date;return{hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds()}}if(t in y)return{hour:y[t],minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let i=+s[1],o=+(s[2]||0),c=+(s[3]||0);const a=s[4]?.toLowerCase();return a==="p"&&i<12&&(i+=12),a==="a"&&i===12&&(i=0),i>23||o>59||c>59?null:{hour:i,minute:o,second:c}}function Z(e){return D(e)!==null}function z(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const O="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",E=new RegExp(`(${O})[a-z]*`,"i");function j(e){return new Date(`1 ${e} 2000`).getMonth()}function h(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function T(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="yesterday")return new Date(n.setDate(n.getDate()-1));if(t==="tomorrow")return new Date(new Date().setHours(0,0,0,0)+864e5);const s=e.match(/(\d{2,4})\s*[年년]\s*(\d{1,2})\s*[月월]\s*(\d{1,2})\s*[日일]?/);if(s)return new Date(h(+s[1]),+s[2]-1,+s[3],0,0,0);t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let i=0,o=0,c=0;const a=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(a){const f=D(a[1]);if(f&&({hour:i,minute:o,second:c}=f),t=t.replace(a[0],"").trim(),!t||t.length<=2){const g=new Date;return new Date(g.getFullYear(),g.getMonth(),g.getDate(),i,o,c)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),i,o,c);if(/^\d{6}$/.test(t))return new Date(h(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),i,o,c);const u=t.match(E);let d=-1,r=0,l=0;u&&(d=j(u[1]),t=t.replace(u[0]," ").trim());const M=t.match(/'(\d{2})\b/);M&&(r=h(+M[1]),t=t.replace(M[0]," ").trim());const m=t.match(/\d+/g)?.map(Number)||[];if(d>=0)m.length>=2?m[0]>99?(r=m[0],l=m[1]):m[1]>99?(r=m[1],l=m[0]):m[0]>31?(l=m[1],r=h(m[0])):m[1]>31?(l=m[0],r=h(m[1])):(l=m[0],r=r||h(m[1])):m.length===1&&(l=m[0],r=r||new Date().getFullYear());else if(m.length>=3){const[f,g,p]=m;f>31?(r=f,d=g-1,l=p):f>12&&p>12?(l=f,d=g-1,r=p>31?p:h(p)):p>31||p>12?(d=f-1,l=g,r=p>31?p:h(p)):(g>12,d=f-1,l=g,r=h(p))}else m.length===2&&(d=m[0]-1,l=m[1],r=r||new Date().getFullYear());return r&&d>=0&&l&&l>=1&&l<=31?new Date(r>99?r:h(r),d,l,i,o,c):new Date("")}function b(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(a,u,d,r,l)=>`${u}${l?`${d}:${r}:${l}`:`${d}:${r}`}`),/^now$/i.test(t)){const a=new Date;return a.setMilliseconds(0),a}if(/^(noon|midday)$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),12,0,0)}if(/^midnight$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0)}let n=null,s=t;const i=[/\bmidnight\b/i,/\bmidday\b/i,/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const a of i){const u=t.match(a);if(u){const d=D(u[0]);if(d){n=d,s=t.replace(u[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const a=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(a){const u=a[2],d=(a[3]||"").replace(/\s+/g,"");let r=u+d;u.length===6&&(r=`${u.slice(0,2)}:${u.slice(2,4)}:${u.slice(4,6)}${d}`);const l=D(r);l&&(n=l,s=a[1])}}if(!n){const a=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(a){const u=a[2]+(a[3]||""),d=D(u);d&&E.test(a[1])&&(n=d,s=a[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),n.hour,n.minute,n.second)}const o=T(s);if(isNaN(o.getTime()))return null;const c=n||{hour:0,minute:0,second:0};return new Date(o.getFullYear(),o.getMonth(),o.getDate(),c.hour,c.minute,c.second)}function Y(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=T(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),i=e.getDate(),o=e.getDay(),c=e.getHours(),a=e.getMinutes(),u=e.getSeconds(),d=e.getMilliseconds(),r=(p,$=2)=>String(p).padStart($,"0"),l=c%12||12,M=c<12?"AM":"PM",m=["January","February","March","April","May","June","July","August","September","October","November","December"],f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],g={YYYY:n,YY:String(n).slice(-2),MMMM:m[s],MMM:m[s].slice(0,3),MM:r(s+1),M:s+1,DD:r(i),D:i,dddd:f[o],ddd:f[o].slice(0,3),dd:f[o].slice(0,2),d:o,HH:r(c),H:c,hh:r(l),h:l,mm:r(a),m:a,ss:r(u),s:u,SSS:r(d,3),A:M,a:M.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(p,$)=>$??String(g[p]))}const K={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},U=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function x(e){return e.replace(U,t=>K[t])}function k(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(T(e).getTime())}function G(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=b(e);return t!==null&&!isNaN(t.getTime())}function V(e,t="YYYY-MMM-DD"){const n=T(e);return isNaN(n.getTime())?"":Y(n,t)}function J(e,t="YYYY-MMM-DD h:mm A"){const n=b(e);return n&&!isNaN(n.getTime())?Y(n,t):""}function W(e,t="h:mm A"){const n=D(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),Y(s,t)}const S={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function X(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const i in S)if(s.startsWith(i))return S[i];throw new Error("Invalid month name: "+e)}function F(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,i]=t,o=parseInt(s)*(n==="-"?-1:1),c=new Date;switch(c.setHours(0,0,0,0),i.toLowerCase()){case"d":c.setDate(c.getDate()+o);break;case"w":c.setDate(c.getDate()+o*7);break;case"m":c.setMonth(c.getMonth()+o);break;case"y":c.setFullYear(c.getFullYear()+o);break}return c}const A=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bmidday\b|\bmidnight\b|\bnow\b|T\d{1,2})/i,q=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function v(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const r=new Date;return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}const n=r=>{const l=r.trim();if(!l)return{date:null,hasTime:!1,valid:!0};const M=F(l);if(M)return{date:M,hasTime:!1,valid:!0};const m=l.search(q);if(m===-1)return{date:null,hasTime:!1,valid:!1};const f=l.search(A);if(f!==-1&&f<m)return{date:null,hasTime:!1,valid:!1};const g=b(l);return g&&!isNaN(g.getTime())?{date:g,hasTime:A.test(l),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let r=0;r<t.length;r+=1){if(t[r]!==":")continue;const l=n(t.slice(0,r)),M=n(t.slice(r+1));if(l.valid&&M.valid){s={start:l,end:M};break}}if(!s){const r=n(t);return r.valid&&r.date?r.hasTime?e.getTime()===r.date.getTime():e.getFullYear()===r.date.getFullYear()&&e.getMonth()===r.date.getMonth()&&e.getDate()===r.date.getDate():!0}const i=s.start,o=s.end,a=i.hasTime||o.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let u=null;i.date&&(u=i.hasTime?i.date.getTime():new Date(i.date.getFullYear(),i.date.getMonth(),i.date.getDate()).getTime());let d=null;return o.date&&(d=o.hasTime?o.date.getTime():new Date(o.date.getFullYear(),o.date.getMonth(),o.date.getDate(),23,59,59,999).getTime()),!(u!==null&&a<u||d!==null&&a>d)}function Q(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function ee(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function te(e){return e.length<=255&&I.test(e)}function ne(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function re(e){return B.test(e)}function se(e){return e.replace(/[^0-9]/g,"")}function ie(e){return L.test(e)}function ae(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,i=!1;for(let o=0;o<t.length;o+=1){const c=t[o];if(c==="-"){!i&&n.length===0&&(n+="-",i=!0);continue}if(c==="."){s||(n+=".",s=!0);continue}n+=c}return n}function oe(e){return P.test(e)}const ce={"":1,K:1e3,M:1e6,G:1e9,T:1e12},le={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function ue(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),i=n[2]?.toUpperCase()||"",o=i.includes("I"),c=i.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(o?le:ce)[c]}function de(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let i=0,o=e;for(;o>=n&&i<s.length-1;)o/=n,i++;let c=Math.round(o*10)/10;return c>=n&&i<s.length-1&&(c=1,i++),`${c%1===0?c.toFixed(0):c.toFixed(1)} ${s[i]}`}function me(e){return e=e.trim(),C.test(e)?e:"https://"+e}function fe(e){return R.test(e)}function ge(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function pe(e){return H.test(e)}function Me(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function he(e){return _.test(e)}function De(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let w=null;const N=new Map;function Te(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);w||(w=document.createElement("canvas"),w.willReadFrequently=!0);const t=w.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function we(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}exports.formatBytes=de;exports.formatDateTime=Y;exports.isColor=De;exports.isDate=k;exports.isDateInRange=v;exports.isDateTime=G;exports.isEmail=te;exports.isFormControl=Q;exports.isInteger=ie;exports.isMeridiem=z;exports.isNANPTel=re;exports.isNumber=oe;exports.isPostalCA=he;exports.isTime=Z;exports.isType=ee;exports.isUrl=fe;exports.isZip=pe;exports.momentToFPFormat=x;exports.monthToNumber=X;exports.normalizeValidationResult=we;exports.parseBytes=ue;exports.parseColor=Te;exports.parseDate=T;exports.parseDateTime=b;exports.parseDateTimeToString=J;exports.parseDateToString=V;exports.parseInteger=se;exports.parseNANPTel=ne;exports.parseNumber=ae;exports.parsePostalCA=Me;exports.parseRelativeDate=F;exports.parseTime=D;exports.parseTimeToString=W;exports.parseUrl=me;exports.parseZip=ge;exports.yearToFull=h;
@@ -1 +1 @@
1
- (function(a,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(a=typeof globalThis<"u"?globalThis:a||self,D(a.validatorUtils={}))})(this,(function(a){"use strict";const D=/^(?:[a-z+]+:)?\/\//i,R=/^(?:[-a-z+]+:)?\/\//i,H=/^\d{5}(-\d{4})?$/,_=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,I=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,B=/^\d{3}-\d{3}-\d{4}$/,L=/^-?\d*$/,P=/^-?\d*\.?\d*$/;function p(e){let t=e.trim().toLowerCase();if(t==="now"){const d=new Date;return{hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds()}}if(t==="noon")return{hour:12,minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let r=+s[1],o=+(s[2]||0),c=+(s[3]||0);const l=s[4]?.toLowerCase();return l==="p"&&r<12&&(r+=12),l==="a"&&r===12&&(r=0),r>23||o>59||c>59?null:{hour:r,minute:o,second:c}}function Z(e){return p(e)!==null}function z(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const j="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",A=new RegExp(`(${j})[a-z]*`,"i");function O(e){return new Date(`1 ${e} 2000`).getMonth()}function T(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function w(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="tomorrow")return new Date(n.setDate(n.getDate()+1));t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let s=0,r=0,o=0;const c=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(c){const h=p(c[1]);if(h&&({hour:s,minute:r,second:o}=h),t=t.replace(c[0],"").trim(),!t||t.length<=2){const M=new Date;return new Date(M.getFullYear(),M.getMonth(),M.getDate(),s,r,o)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),s,r,o);if(/^\d{6}$/.test(t))return new Date(T(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),s,r,o);const l=t.match(A);let d=-1,u=0,i=0;l&&(d=O(l[1]),t=t.replace(l[0]," ").trim());const f=t.match(/'(\d{2})\b/);f&&(u=T(+f[1]),t=t.replace(f[0]," ").trim());const m=t.match(/\d+/g)?.map(Number)||[];if(d>=0)m.length>=2?m[0]>99?(u=m[0],i=m[1]):m[1]>99?(u=m[1],i=m[0]):m[0]>31?(i=m[1],u=T(m[0])):m[1]>31?(i=m[0],u=T(m[1])):(i=m[0],u=u||T(m[1])):m.length===1&&(i=m[0],u=u||new Date().getFullYear());else if(m.length>=3){const[h,M,g]=m;h>31?(u=h,d=M-1,i=g):h>12&&g>12?(i=h,d=M-1,u=g>31?g:T(g)):g>31||g>12?(d=h-1,i=M,u=g>31?g:T(g)):(M>12,d=h-1,i=M,u=T(g))}else m.length===2&&(d=m[0]-1,i=m[1],u=u||new Date().getFullYear());return u&&d>=0&&i&&i>=1&&i<=31?new Date(u>99?u:T(u),d,i,s,r,o):new Date("")}function Y(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(l,d,u,i,f)=>`${d}${f?`${u}:${i}:${f}`:`${u}:${i}`}`),/^now$/i.test(t)){const l=new Date;return l.setMilliseconds(0),l}if(/^noon$/i.test(t)){const l=new Date;return new Date(l.getFullYear(),l.getMonth(),l.getDate(),12,0,0)}let n=null,s=t;const r=[/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const l of r){const d=t.match(l);if(d){const u=p(d[0]);if(u){n=u,s=t.replace(d[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const l=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(l){const d=l[2],u=(l[3]||"").replace(/\s+/g,"");let i=d+u;d.length===6&&(i=`${d.slice(0,2)}:${d.slice(2,4)}:${d.slice(4,6)}${u}`);const f=p(i);f&&(n=f,s=l[1])}}if(!n){const l=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(l){const d=l[2]+(l[3]||""),u=p(d);u&&A.test(l[1])&&(n=u,s=l[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const l=new Date;return new Date(l.getFullYear(),l.getMonth(),l.getDate(),n.hour,n.minute,n.second)}const o=w(s);if(isNaN(o.getTime()))return null;const c=n||{hour:0,minute:0,second:0};return new Date(o.getFullYear(),o.getMonth(),o.getDate(),c.hour,c.minute,c.second)}function b(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=w(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),r=e.getDate(),o=e.getDay(),c=e.getHours(),l=e.getMinutes(),d=e.getSeconds(),u=e.getMilliseconds(),i=(y,S=2)=>String(y).padStart(S,"0"),f=c%12||12,m=c<12?"AM":"PM",h=["January","February","March","April","May","June","July","August","September","October","November","December"],M=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],g={YYYY:n,YY:String(n).slice(-2),MMMM:h[s],MMM:h[s].slice(0,3),MM:i(s+1),M:s+1,DD:i(r),D:r,dddd:M[o],ddd:M[o].slice(0,3),dd:M[o].slice(0,2),d:o,HH:i(c),H:c,hh:i(f),h:f,mm:i(l),m:l,ss:i(d),s:d,SSS:i(u,3),A:m,a:m.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(y,S)=>S??String(g[y]))}const U={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},K=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function G(e){return e.replace(K,t=>U[t])}function V(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(w(e).getTime())}function k(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=Y(e);return t!==null&&!isNaN(t.getTime())}function J(e,t="YYYY-MMM-DD"){const n=w(e);return isNaN(n.getTime())?"":b(n,t)}function W(e,t="YYYY-MMM-DD h:mm A"){const n=Y(e);return n&&!isNaN(n.getTime())?b(n,t):""}function v(e,t="h:mm A"){const n=p(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),b(s,t)}const E={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function X(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const r in E)if(s.startsWith(r))return E[r];throw new Error("Invalid month name: "+e)}function F(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,r]=t,o=parseInt(s)*(n==="-"?-1:1),c=new Date;switch(c.setHours(0,0,0,0),r.toLowerCase()){case"d":c.setDate(c.getDate()+o);break;case"w":c.setDate(c.getDate()+o*7);break;case"m":c.setMonth(c.getMonth()+o);break;case"y":c.setFullYear(c.getFullYear()+o);break}return c}const C=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bnow\b|T\d{1,2})/i,q=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function Q(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const i=new Date;return e.getFullYear()===i.getFullYear()&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()}const n=i=>{const f=i.trim();if(!f)return{date:null,hasTime:!1,valid:!0};const m=F(f);if(m)return{date:m,hasTime:!1,valid:!0};const h=f.search(q);if(h===-1)return{date:null,hasTime:!1,valid:!1};const M=f.search(C);if(M!==-1&&M<h)return{date:null,hasTime:!1,valid:!1};const g=Y(f);return g&&!isNaN(g.getTime())?{date:g,hasTime:C.test(f),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let i=0;i<t.length;i+=1){if(t[i]!==":")continue;const f=n(t.slice(0,i)),m=n(t.slice(i+1));if(f.valid&&m.valid){s={start:f,end:m};break}}if(!s){const i=n(t);return i.valid&&i.date?i.hasTime?e.getTime()===i.date.getTime():e.getFullYear()===i.date.getFullYear()&&e.getMonth()===i.date.getMonth()&&e.getDate()===i.date.getDate():!0}const r=s.start,o=s.end,l=r.hasTime||o.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let d=null;r.date&&(d=r.hasTime?r.date.getTime():new Date(r.date.getFullYear(),r.date.getMonth(),r.date.getDate()).getTime());let u=null;return o.date&&(u=o.hasTime?o.date.getTime():new Date(o.date.getFullYear(),o.date.getMonth(),o.date.getDate(),23,59,59,999).getTime()),!(d!==null&&l<d||u!==null&&l>u)}function x(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function ee(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function te(e){return e.length<=255&&I.test(e)}function ne(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function ie(e){return B.test(e)}function se(e){return e.replace(/[^0-9]/g,"")}function re(e){return L.test(e)}function ae(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,r=!1;for(let o=0;o<t.length;o+=1){const c=t[o];if(c==="-"){!r&&n.length===0&&(n+="-",r=!0);continue}if(c==="."){s||(n+=".",s=!0);continue}n+=c}return n}function oe(e){return P.test(e)}const ce={"":1,K:1e3,M:1e6,G:1e9,T:1e12},le={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function ue(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),r=n[2]?.toUpperCase()||"",o=r.includes("I"),c=r.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(o?le:ce)[c]}function de(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let r=0,o=e;for(;o>=n&&r<s.length-1;)o/=n,r++;let c=Math.round(o*10)/10;return c>=n&&r<s.length-1&&(c=1,r++),`${c%1===0?c.toFixed(0):c.toFixed(1)} ${s[r]}`}function me(e){return e=e.trim(),D.test(e)?e:"https://"+e}function fe(e){return R.test(e)}function ge(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function Me(e){return H.test(e)}function he(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function Te(e){return _.test(e)}function pe(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let $=null;const N=new Map;function De(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);$||($=document.createElement("canvas"),$.willReadFrequently=!0);const t=$.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function we(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}a.formatBytes=de,a.formatDateTime=b,a.isColor=pe,a.isDate=V,a.isDateInRange=Q,a.isDateTime=k,a.isEmail=te,a.isFormControl=x,a.isInteger=re,a.isMeridiem=z,a.isNANPTel=ie,a.isNumber=oe,a.isPostalCA=Te,a.isTime=Z,a.isType=ee,a.isUrl=fe,a.isZip=Me,a.momentToFPFormat=G,a.monthToNumber=X,a.normalizeValidationResult=we,a.parseBytes=ue,a.parseColor=De,a.parseDate=w,a.parseDateTime=Y,a.parseDateTimeToString=W,a.parseDateToString=J,a.parseInteger=se,a.parseNANPTel=ne,a.parseNumber=ae,a.parsePostalCA=he,a.parseRelativeDate=F,a.parseTime=p,a.parseTimeToString=v,a.parseUrl=me,a.parseZip=ge,a.yearToFull=T,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(o,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(o=typeof globalThis<"u"?globalThis:o||self,w(o.validatorUtils={}))})(this,(function(o){"use strict";const w=/^(?:[a-z+]+:)?\/\//i,H=/^(?:[-a-z+]+:)?\/\//i,_=/^\d{5}(-\d{4})?$/,I=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,B=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,L=/^\d{3}-\d{3}-\d{4}$/,P=/^-?\d*$/,Z=/^-?\d*\.?\d*$/,A={midnight:0,noon:12,midday:12};function p(e){let t=e.trim().toLowerCase().replace(/\.+$/g,"");if(t==="now"){const d=new Date;return{hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds()}}if(t in A)return{hour:A[t],minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let r=+s[1],c=+(s[2]||0),l=+(s[3]||0);const a=s[4]?.toLowerCase();return a==="p"&&r<12&&(r+=12),a==="a"&&r===12&&(r=0),r>23||c>59||l>59?null:{hour:r,minute:c,second:l}}function z(e){return p(e)!==null}function j(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const O="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",E=new RegExp(`(${O})[a-z]*`,"i");function K(e){return new Date(`1 ${e} 2000`).getMonth()}function D(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function b(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="yesterday")return new Date(n.setDate(n.getDate()-1));if(t==="tomorrow")return new Date(new Date().setHours(0,0,0,0)+864e5);const s=e.match(/(\d{2,4})\s*[年년]\s*(\d{1,2})\s*[月월]\s*(\d{1,2})\s*[日일]?/);if(s)return new Date(D(+s[1]),+s[2]-1,+s[3],0,0,0);t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let r=0,c=0,l=0;const a=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(a){const g=p(a[1]);if(g&&({hour:r,minute:c,second:l}=g),t=t.replace(a[0],"").trim(),!t||t.length<=2){const M=new Date;return new Date(M.getFullYear(),M.getMonth(),M.getDate(),r,c,l)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),r,c,l);if(/^\d{6}$/.test(t))return new Date(D(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),r,c,l);const d=t.match(E);let m=-1,i=0,u=0;d&&(m=K(d[1]),t=t.replace(d[0]," ").trim());const T=t.match(/'(\d{2})\b/);T&&(i=D(+T[1]),t=t.replace(T[0]," ").trim());const f=t.match(/\d+/g)?.map(Number)||[];if(m>=0)f.length>=2?f[0]>99?(i=f[0],u=f[1]):f[1]>99?(i=f[1],u=f[0]):f[0]>31?(u=f[1],i=D(f[0])):f[1]>31?(u=f[0],i=D(f[1])):(u=f[0],i=i||D(f[1])):f.length===1&&(u=f[0],i=i||new Date().getFullYear());else if(f.length>=3){const[g,M,h]=f;g>31?(i=g,m=M-1,u=h):g>12&&h>12?(u=g,m=M-1,i=h>31?h:D(h)):h>31||h>12?(m=g-1,u=M,i=h>31?h:D(h)):(M>12,m=g-1,u=M,i=D(h))}else f.length===2&&(m=f[0]-1,u=f[1],i=i||new Date().getFullYear());return i&&m>=0&&u&&u>=1&&u<=31?new Date(i>99?i:D(i),m,u,r,c,l):new Date("")}function Y(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(a,d,m,i,u)=>`${d}${u?`${m}:${i}:${u}`:`${m}:${i}`}`),/^now$/i.test(t)){const a=new Date;return a.setMilliseconds(0),a}if(/^(noon|midday)$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),12,0,0)}if(/^midnight$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0)}let n=null,s=t;const r=[/\bmidnight\b/i,/\bmidday\b/i,/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const a of r){const d=t.match(a);if(d){const m=p(d[0]);if(m){n=m,s=t.replace(d[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const a=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(a){const d=a[2],m=(a[3]||"").replace(/\s+/g,"");let i=d+m;d.length===6&&(i=`${d.slice(0,2)}:${d.slice(2,4)}:${d.slice(4,6)}${m}`);const u=p(i);u&&(n=u,s=a[1])}}if(!n){const a=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(a){const d=a[2]+(a[3]||""),m=p(d);m&&E.test(a[1])&&(n=m,s=a[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),n.hour,n.minute,n.second)}const c=b(s);if(isNaN(c.getTime()))return null;const l=n||{hour:0,minute:0,second:0};return new Date(c.getFullYear(),c.getMonth(),c.getDate(),l.hour,l.minute,l.second)}function $(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=b(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),r=e.getDate(),c=e.getDay(),l=e.getHours(),a=e.getMinutes(),d=e.getSeconds(),m=e.getMilliseconds(),i=(h,S=2)=>String(h).padStart(S,"0"),u=l%12||12,T=l<12?"AM":"PM",f=["January","February","March","April","May","June","July","August","September","October","November","December"],g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],M={YYYY:n,YY:String(n).slice(-2),MMMM:f[s],MMM:f[s].slice(0,3),MM:i(s+1),M:s+1,DD:i(r),D:r,dddd:g[c],ddd:g[c].slice(0,3),dd:g[c].slice(0,2),d:c,HH:i(l),H:l,hh:i(u),h:u,mm:i(a),m:a,ss:i(d),s:d,SSS:i(m,3),A:T,a:T.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(h,S)=>S??String(M[h]))}const U={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},k=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function G(e){return e.replace(k,t=>U[t])}function V(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(b(e).getTime())}function J(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=Y(e);return t!==null&&!isNaN(t.getTime())}function W(e,t="YYYY-MMM-DD"){const n=b(e);return isNaN(n.getTime())?"":$(n,t)}function X(e,t="YYYY-MMM-DD h:mm A"){const n=Y(e);return n&&!isNaN(n.getTime())?$(n,t):""}function v(e,t="h:mm A"){const n=p(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),$(s,t)}const F={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function q(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const r in F)if(s.startsWith(r))return F[r];throw new Error("Invalid month name: "+e)}function C(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,r]=t,c=parseInt(s)*(n==="-"?-1:1),l=new Date;switch(l.setHours(0,0,0,0),r.toLowerCase()){case"d":l.setDate(l.getDate()+c);break;case"w":l.setDate(l.getDate()+c*7);break;case"m":l.setMonth(l.getMonth()+c);break;case"y":l.setFullYear(l.getFullYear()+c);break}return l}const R=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bmidday\b|\bmidnight\b|\bnow\b|T\d{1,2})/i,Q=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function x(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const i=new Date;return e.getFullYear()===i.getFullYear()&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()}const n=i=>{const u=i.trim();if(!u)return{date:null,hasTime:!1,valid:!0};const T=C(u);if(T)return{date:T,hasTime:!1,valid:!0};const f=u.search(Q);if(f===-1)return{date:null,hasTime:!1,valid:!1};const g=u.search(R);if(g!==-1&&g<f)return{date:null,hasTime:!1,valid:!1};const M=Y(u);return M&&!isNaN(M.getTime())?{date:M,hasTime:R.test(u),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let i=0;i<t.length;i+=1){if(t[i]!==":")continue;const u=n(t.slice(0,i)),T=n(t.slice(i+1));if(u.valid&&T.valid){s={start:u,end:T};break}}if(!s){const i=n(t);return i.valid&&i.date?i.hasTime?e.getTime()===i.date.getTime():e.getFullYear()===i.date.getFullYear()&&e.getMonth()===i.date.getMonth()&&e.getDate()===i.date.getDate():!0}const r=s.start,c=s.end,a=r.hasTime||c.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let d=null;r.date&&(d=r.hasTime?r.date.getTime():new Date(r.date.getFullYear(),r.date.getMonth(),r.date.getDate()).getTime());let m=null;return c.date&&(m=c.hasTime?c.date.getTime():new Date(c.date.getFullYear(),c.date.getMonth(),c.date.getDate(),23,59,59,999).getTime()),!(d!==null&&a<d||m!==null&&a>m)}function ee(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function te(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function ne(e){return e.length<=255&&B.test(e)}function ie(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function se(e){return L.test(e)}function re(e){return e.replace(/[^0-9]/g,"")}function ae(e){return P.test(e)}function oe(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,r=!1;for(let c=0;c<t.length;c+=1){const l=t[c];if(l==="-"){!r&&n.length===0&&(n+="-",r=!0);continue}if(l==="."){s||(n+=".",s=!0);continue}n+=l}return n}function ce(e){return Z.test(e)}const le={"":1,K:1e3,M:1e6,G:1e9,T:1e12},ue={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function de(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),r=n[2]?.toUpperCase()||"",c=r.includes("I"),l=r.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(c?ue:le)[l]}function me(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let r=0,c=e;for(;c>=n&&r<s.length-1;)c/=n,r++;let l=Math.round(c*10)/10;return l>=n&&r<s.length-1&&(l=1,r++),`${l%1===0?l.toFixed(0):l.toFixed(1)} ${s[r]}`}function fe(e){return e=e.trim(),w.test(e)?e:"https://"+e}function ge(e){return H.test(e)}function Me(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function he(e){return _.test(e)}function De(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function Te(e){return I.test(e)}function pe(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let y=null;const N=new Map;function we(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);y||(y=document.createElement("canvas"),y.willReadFrequently=!0);const t=y.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function be(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}o.formatBytes=me,o.formatDateTime=$,o.isColor=pe,o.isDate=V,o.isDateInRange=x,o.isDateTime=J,o.isEmail=ne,o.isFormControl=ee,o.isInteger=ae,o.isMeridiem=j,o.isNANPTel=se,o.isNumber=ce,o.isPostalCA=Te,o.isTime=z,o.isType=te,o.isUrl=ge,o.isZip=he,o.momentToFPFormat=G,o.monthToNumber=q,o.normalizeValidationResult=be,o.parseBytes=de,o.parseColor=we,o.parseDate=b,o.parseDateTime=Y,o.parseDateTimeToString=X,o.parseDateToString=W,o.parseInteger=re,o.parseNANPTel=ie,o.parseNumber=oe,o.parsePostalCA=De,o.parseRelativeDate=C,o.parseTime=p,o.parseTimeToString=v,o.parseUrl=fe,o.parseZip=Me,o.yearToFull=D,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
@@ -1,84 +1,94 @@
1
- const E = /^(?:[a-z+]+:)?\/\//i, F = /^(?:[-a-z+]+:)?\/\//i, H = /^\d{5}(-\d{4})?$/, _ = /^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/, C = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/, R = /^\d{3}-\d{3}-\d{4}$/, I = /^-?\d*$/, B = /^-?\d*\.?\d*$/;
2
- function h(e) {
3
- let t = e.trim().toLowerCase();
1
+ const F = /^(?:[a-z+]+:)?\/\//i, H = /^(?:[-a-z+]+:)?\/\//i, _ = /^\d{5}(-\d{4})?$/, R = /^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/, C = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/, I = /^\d{3}-\d{3}-\d{4}$/, B = /^-?\d*$/, L = /^-?\d*\.?\d*$/, N = { midnight: 0, noon: 12, midday: 12 };
2
+ function D(e) {
3
+ let t = e.trim().toLowerCase().replace(/\.+$/g, "");
4
4
  if (t === "now") {
5
5
  const l = /* @__PURE__ */ new Date();
6
6
  return { hour: l.getHours(), minute: l.getMinutes(), second: l.getSeconds() };
7
7
  }
8
- if (t === "noon") return { hour: 12, minute: 0, second: 0 };
8
+ if (t in N) return { hour: N[t], minute: 0, second: 0 };
9
9
  t = t.replace(/\s+/g, "").replace(/\.+$/g, "");
10
10
  const s = t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i, "$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);
11
11
  if (!s) return null;
12
- let i = +s[1], a = +(s[2] || 0), o = +(s[3] || 0);
13
- const c = s[4]?.toLowerCase();
14
- return c === "p" && i < 12 && (i += 12), c === "a" && i === 12 && (i = 0), i > 23 || a > 59 || o > 59 ? null : { hour: i, minute: a, second: o };
12
+ let i = +s[1], o = +(s[2] || 0), c = +(s[3] || 0);
13
+ const a = s[4]?.toLowerCase();
14
+ return a === "p" && i < 12 && (i += 12), a === "a" && i === 12 && (i = 0), i > 23 || o > 59 || c > 59 ? null : { hour: i, minute: o, second: c };
15
15
  }
16
- function U(e) {
17
- return h(e) !== null;
16
+ function k(e) {
17
+ return D(e) !== null;
18
18
  }
19
19
  function G(e) {
20
20
  return /^[ap]\.?m?\.?$/i.test(e.replace(/\s/g, ""));
21
21
  }
22
- const L = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec", A = new RegExp(`(${L})[a-z]*`, "i");
23
- function P(e) {
22
+ const P = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec", A = new RegExp(`(${P})[a-z]*`, "i");
23
+ function z(e) {
24
24
  return (/* @__PURE__ */ new Date(`1 ${e} 2000`)).getMonth();
25
25
  }
26
- function M(e) {
26
+ function h(e) {
27
27
  if (typeof e == "string" && (e = parseInt(e.replace(/\D/g, ""))), e > 99) return e;
28
28
  const t = ((/* @__PURE__ */ new Date()).getFullYear() + 20) % 100;
29
29
  return e + (e < t ? 2e3 : 1900);
30
30
  }
31
- function T(e) {
31
+ function w(e) {
32
32
  if (e instanceof Date) return e;
33
33
  let t = e.trim().toLowerCase();
34
34
  const n = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0));
35
35
  if (/^(now|today)$/.test(t)) return n;
36
- if (t === "tomorrow") return new Date(n.setDate(n.getDate() + 1));
36
+ if (t === "yesterday") return new Date(n.setDate(n.getDate() - 1));
37
+ if (t === "tomorrow") return new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0) + 864e5);
38
+ const s = e.match(/(\d{2,4})\s*[年년]\s*(\d{1,2})\s*[月월]\s*(\d{1,2})\s*[日일]?/);
39
+ if (s)
40
+ return new Date(h(+s[1]), +s[2] - 1, +s[3], 0, 0, 0);
37
41
  t = t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi, "").trim();
38
- let s = 0, i = 0, a = 0;
39
- const o = t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);
40
- if (o) {
41
- const p = h(o[1]);
42
- if (p && ({ hour: s, minute: i, second: a } = p), t = t.replace(o[0], "").trim(), !t || t.length <= 2) {
42
+ let i = 0, o = 0, c = 0;
43
+ const a = t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);
44
+ if (a) {
45
+ const f = D(a[1]);
46
+ if (f && ({ hour: i, minute: o, second: c } = f), t = t.replace(a[0], "").trim(), !t || t.length <= 2) {
43
47
  const g = /* @__PURE__ */ new Date();
44
- return new Date(g.getFullYear(), g.getMonth(), g.getDate(), s, i, a);
48
+ return new Date(g.getFullYear(), g.getMonth(), g.getDate(), i, o, c);
45
49
  }
46
50
  }
47
51
  if (/^\d{8}$/.test(t))
48
- return new Date(+t.slice(0, 4), +t.slice(4, 6) - 1, +t.slice(6, 8), s, i, a);
52
+ return new Date(+t.slice(0, 4), +t.slice(4, 6) - 1, +t.slice(6, 8), i, o, c);
49
53
  if (/^\d{6}$/.test(t))
50
- return new Date(M(+t.slice(0, 2)), +t.slice(2, 4) - 1, +t.slice(4, 6), s, i, a);
51
- const c = t.match(A);
52
- let l = -1, u = 0, r = 0;
53
- c && (l = P(c[1]), t = t.replace(c[0], " ").trim());
54
- const f = t.match(/'(\d{2})\b/);
55
- f && (u = M(+f[1]), t = t.replace(f[0], " ").trim());
56
- const d = t.match(/\d+/g)?.map(Number) || [];
57
- if (l >= 0)
58
- d.length >= 2 ? d[0] > 99 ? (u = d[0], r = d[1]) : d[1] > 99 ? (u = d[1], r = d[0]) : d[0] > 31 ? (r = d[1], u = M(d[0])) : d[1] > 31 ? (r = d[0], u = M(d[1])) : (r = d[0], u = u || M(d[1])) : d.length === 1 && (r = d[0], u = u || (/* @__PURE__ */ new Date()).getFullYear());
59
- else if (d.length >= 3) {
60
- const [p, g, m] = d;
61
- p > 31 ? (u = p, l = g - 1, r = m) : p > 12 && m > 12 ? (r = p, l = g - 1, u = m > 31 ? m : M(m)) : m > 31 || m > 12 ? (l = p - 1, r = g, u = m > 31 ? m : M(m)) : (g > 12, l = p - 1, r = g, u = M(m));
62
- } else d.length === 2 && (l = d[0] - 1, r = d[1], u = u || (/* @__PURE__ */ new Date()).getFullYear());
63
- return u && l >= 0 && r && r >= 1 && r <= 31 ? new Date(u > 99 ? u : M(u), l, r, s, i, a) : /* @__PURE__ */ new Date("");
64
- }
65
- function b(e) {
54
+ return new Date(h(+t.slice(0, 2)), +t.slice(2, 4) - 1, +t.slice(4, 6), i, o, c);
55
+ const l = t.match(A);
56
+ let d = -1, r = 0, u = 0;
57
+ l && (d = z(l[1]), t = t.replace(l[0], " ").trim());
58
+ const M = t.match(/'(\d{2})\b/);
59
+ M && (r = h(+M[1]), t = t.replace(M[0], " ").trim());
60
+ const m = t.match(/\d+/g)?.map(Number) || [];
61
+ if (d >= 0)
62
+ m.length >= 2 ? m[0] > 99 ? (r = m[0], u = m[1]) : m[1] > 99 ? (r = m[1], u = m[0]) : m[0] > 31 ? (u = m[1], r = h(m[0])) : m[1] > 31 ? (u = m[0], r = h(m[1])) : (u = m[0], r = r || h(m[1])) : m.length === 1 && (u = m[0], r = r || (/* @__PURE__ */ new Date()).getFullYear());
63
+ else if (m.length >= 3) {
64
+ const [f, g, p] = m;
65
+ f > 31 ? (r = f, d = g - 1, u = p) : f > 12 && p > 12 ? (u = f, d = g - 1, r = p > 31 ? p : h(p)) : p > 31 || p > 12 ? (d = f - 1, u = g, r = p > 31 ? p : h(p)) : (g > 12, d = f - 1, u = g, r = h(p));
66
+ } else m.length === 2 && (d = m[0] - 1, u = m[1], r = r || (/* @__PURE__ */ new Date()).getFullYear());
67
+ return r && d >= 0 && u && u >= 1 && u <= 31 ? new Date(r > 99 ? r : h(r), d, u, i, o, c) : /* @__PURE__ */ new Date("");
68
+ }
69
+ function $(e) {
66
70
  if (e instanceof Date) return e;
67
71
  let t = e.trim();
68
72
  if (t.length < 3) return null;
69
73
  if (t = t.replace(/(\d)T(\d)/i, "$1 $2"), t = t.replace(
70
74
  /(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,
71
- (c, l, u, r, f) => `${l}${f ? `${u}:${r}:${f}` : `${u}:${r}`}`
75
+ (a, l, d, r, u) => `${l}${u ? `${d}:${r}:${u}` : `${d}:${r}`}`
72
76
  ), /^now$/i.test(t)) {
73
- const c = /* @__PURE__ */ new Date();
74
- return c.setMilliseconds(0), c;
77
+ const a = /* @__PURE__ */ new Date();
78
+ return a.setMilliseconds(0), a;
79
+ }
80
+ if (/^(noon|midday)$/i.test(t)) {
81
+ const a = /* @__PURE__ */ new Date();
82
+ return new Date(a.getFullYear(), a.getMonth(), a.getDate(), 12, 0, 0);
75
83
  }
76
- if (/^noon$/i.test(t)) {
77
- const c = /* @__PURE__ */ new Date();
78
- return new Date(c.getFullYear(), c.getMonth(), c.getDate(), 12, 0, 0);
84
+ if (/^midnight$/i.test(t)) {
85
+ const a = /* @__PURE__ */ new Date();
86
+ return new Date(a.getFullYear(), a.getMonth(), a.getDate(), 0, 0, 0);
79
87
  }
80
88
  let n = null, s = t;
81
89
  const i = [
90
+ /\bmidnight\b/i,
91
+ /\bmidday\b/i,
82
92
  /(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,
83
93
  // 14:30, 2:30pm, 1:5
84
94
  /\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,
@@ -86,77 +96,77 @@ function b(e) {
86
96
  /\b(\d{3,4})([ap])m?\b/i
87
97
  // 1430pm, 230p, 1200AM
88
98
  ];
89
- for (const c of i) {
90
- const l = t.match(c);
99
+ for (const a of i) {
100
+ const l = t.match(a);
91
101
  if (l) {
92
- const u = h(l[0]);
93
- if (u) {
94
- n = u, s = t.replace(l[0], " ").replace(/[\s.]+$/g, "").replace(/\s+/g, " ").trim();
102
+ const d = D(l[0]);
103
+ if (d) {
104
+ n = d, s = t.replace(l[0], " ").replace(/[\s.]+$/g, "").replace(/\s+/g, " ").trim();
95
105
  break;
96
106
  }
97
107
  }
98
108
  }
99
109
  if (!n) {
100
- const c = s.match(
110
+ const a = s.match(
101
111
  /^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i
102
112
  );
103
- if (c) {
104
- const l = c[2], u = (c[3] || "").replace(/\s+/g, "");
105
- let r = l + u;
106
- l.length === 6 && (r = `${l.slice(0, 2)}:${l.slice(2, 4)}:${l.slice(4, 6)}${u}`);
107
- const f = h(r);
108
- f && (n = f, s = c[1]);
113
+ if (a) {
114
+ const l = a[2], d = (a[3] || "").replace(/\s+/g, "");
115
+ let r = l + d;
116
+ l.length === 6 && (r = `${l.slice(0, 2)}:${l.slice(2, 4)}:${l.slice(4, 6)}${d}`);
117
+ const u = D(r);
118
+ u && (n = u, s = a[1]);
109
119
  }
110
120
  }
111
121
  if (!n) {
112
- const c = s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);
113
- if (c) {
114
- const l = c[2] + (c[3] || ""), u = h(l);
115
- u && A.test(c[1]) && (n = u, s = c[1]);
122
+ const a = s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);
123
+ if (a) {
124
+ const l = a[2] + (a[3] || ""), d = D(l);
125
+ d && A.test(a[1]) && (n = d, s = a[1]);
116
126
  }
117
127
  }
118
128
  if (n && (!s || /^,?\s*$/.test(s))) {
119
- const c = /* @__PURE__ */ new Date();
120
- return new Date(c.getFullYear(), c.getMonth(), c.getDate(), n.hour, n.minute, n.second);
129
+ const a = /* @__PURE__ */ new Date();
130
+ return new Date(a.getFullYear(), a.getMonth(), a.getDate(), n.hour, n.minute, n.second);
121
131
  }
122
- const a = T(s);
123
- if (isNaN(a.getTime())) return null;
124
- const o = n || { hour: 0, minute: 0, second: 0 };
125
- return new Date(a.getFullYear(), a.getMonth(), a.getDate(), o.hour, o.minute, o.second);
126
- }
127
- function N(e, t = "YYYY-MM-DD") {
128
- if (typeof e == "string" && (e = T(e)), isNaN(e.getTime())) return "";
129
- const n = e.getFullYear(), s = e.getMonth(), i = e.getDate(), a = e.getDay(), o = e.getHours(), c = e.getMinutes(), l = e.getSeconds(), u = e.getMilliseconds(), r = (w, Y = 2) => String(w).padStart(Y, "0"), f = o % 12 || 12, d = o < 12 ? "AM" : "PM", p = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], g = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], m = {
132
+ const o = w(s);
133
+ if (isNaN(o.getTime())) return null;
134
+ const c = n || { hour: 0, minute: 0, second: 0 };
135
+ return new Date(o.getFullYear(), o.getMonth(), o.getDate(), c.hour, c.minute, c.second);
136
+ }
137
+ function y(e, t = "YYYY-MM-DD") {
138
+ if (typeof e == "string" && (e = w(e)), isNaN(e.getTime())) return "";
139
+ const n = e.getFullYear(), s = e.getMonth(), i = e.getDate(), o = e.getDay(), c = e.getHours(), a = e.getMinutes(), l = e.getSeconds(), d = e.getMilliseconds(), r = (p, Y = 2) => String(p).padStart(Y, "0"), u = c % 12 || 12, M = c < 12 ? "AM" : "PM", m = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], f = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], g = {
130
140
  YYYY: n,
131
141
  YY: String(n).slice(-2),
132
- MMMM: p[s],
133
- MMM: p[s].slice(0, 3),
142
+ MMMM: m[s],
143
+ MMM: m[s].slice(0, 3),
134
144
  MM: r(s + 1),
135
145
  M: s + 1,
136
146
  DD: r(i),
137
147
  D: i,
138
- dddd: g[a],
139
- ddd: g[a].slice(0, 3),
140
- dd: g[a].slice(0, 2),
141
- d: a,
142
- HH: r(o),
143
- H: o,
144
- hh: r(f),
145
- h: f,
146
- mm: r(c),
147
- m: c,
148
+ dddd: f[o],
149
+ ddd: f[o].slice(0, 3),
150
+ dd: f[o].slice(0, 2),
151
+ d: o,
152
+ HH: r(c),
153
+ H: c,
154
+ hh: r(u),
155
+ h: u,
156
+ mm: r(a),
157
+ m: a,
148
158
  ss: r(l),
149
159
  s: l,
150
- SSS: r(u, 3),
151
- A: d,
152
- a: d.toLowerCase()
160
+ SSS: r(d, 3),
161
+ A: M,
162
+ a: M.toLowerCase()
153
163
  };
154
164
  return t.replace(
155
165
  /\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,
156
- (w, Y) => Y ?? String(m[w])
166
+ (p, Y) => Y ?? String(g[p])
157
167
  );
158
168
  }
159
- const z = {
169
+ const Z = {
160
170
  YYYY: "Y",
161
171
  YY: "y",
162
172
  MMMM: "F",
@@ -178,33 +188,33 @@ const z = {
178
188
  s: "s",
179
189
  A: "K",
180
190
  a: "K"
181
- }, Z = /YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;
182
- function k(e) {
183
- return e.replace(Z, (t) => z[t]);
184
- }
191
+ }, K = /YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;
185
192
  function V(e) {
186
- return typeof e != "string" && !(e instanceof Date) ? !1 : !isNaN(T(e).getTime());
193
+ return e.replace(K, (t) => Z[t]);
187
194
  }
188
195
  function J(e) {
196
+ return typeof e != "string" && !(e instanceof Date) ? !1 : !isNaN(w(e).getTime());
197
+ }
198
+ function W(e) {
189
199
  if (typeof e != "string" && !(e instanceof Date)) return !1;
190
- const t = b(e);
200
+ const t = $(e);
191
201
  return t !== null && !isNaN(t.getTime());
192
202
  }
193
- function W(e, t = "YYYY-MMM-DD") {
194
- const n = T(e);
195
- return isNaN(n.getTime()) ? "" : N(n, t);
203
+ function X(e, t = "YYYY-MMM-DD") {
204
+ const n = w(e);
205
+ return isNaN(n.getTime()) ? "" : y(n, t);
196
206
  }
197
- function X(e, t = "YYYY-MMM-DD h:mm A") {
198
- const n = b(e);
199
- return n && !isNaN(n.getTime()) ? N(n, t) : "";
207
+ function q(e, t = "YYYY-MMM-DD h:mm A") {
208
+ const n = $(e);
209
+ return n && !isNaN(n.getTime()) ? y(n, t) : "";
200
210
  }
201
- function q(e, t = "h:mm A") {
202
- const n = h(e);
211
+ function Q(e, t = "h:mm A") {
212
+ const n = D(e);
203
213
  if (!n) return "";
204
214
  const s = /* @__PURE__ */ new Date();
205
- return s.setHours(n.hour, n.minute, n.second, 0), N(s, t);
215
+ return s.setHours(n.hour, n.minute, n.second, 0), y(s, t);
206
216
  }
207
- const y = {
217
+ const S = {
208
218
  ja: 0,
209
219
  en: 0,
210
220
  fe: 1,
@@ -230,31 +240,31 @@ function v(e) {
230
240
  const n = (/* @__PURE__ */ new Date(`1 ${e} 2000`)).getMonth();
231
241
  if (!isNaN(n)) return n;
232
242
  const s = e.toLowerCase();
233
- for (const i in y) if (s.startsWith(i)) return y[i];
243
+ for (const i in S) if (s.startsWith(i)) return S[i];
234
244
  throw new Error("Invalid month name: " + e);
235
245
  }
236
- function x(e) {
246
+ function O(e) {
237
247
  const t = e.match(/^([+-])?(\d+)([dwmy])$/i);
238
248
  if (!t) return null;
239
- const [, n, s, i] = t, a = parseInt(s) * (n === "-" ? -1 : 1), o = /* @__PURE__ */ new Date();
240
- switch (o.setHours(0, 0, 0, 0), i.toLowerCase()) {
249
+ const [, n, s, i] = t, o = parseInt(s) * (n === "-" ? -1 : 1), c = /* @__PURE__ */ new Date();
250
+ switch (c.setHours(0, 0, 0, 0), i.toLowerCase()) {
241
251
  case "d":
242
- o.setDate(o.getDate() + a);
252
+ c.setDate(c.getDate() + o);
243
253
  break;
244
254
  case "w":
245
- o.setDate(o.getDate() + a * 7);
255
+ c.setDate(c.getDate() + o * 7);
246
256
  break;
247
257
  case "m":
248
- o.setMonth(o.getMonth() + a);
258
+ c.setMonth(c.getMonth() + o);
249
259
  break;
250
260
  case "y":
251
- o.setFullYear(o.getFullYear() + a);
261
+ c.setFullYear(c.getFullYear() + o);
252
262
  break;
253
263
  }
254
- return o;
264
+ return c;
255
265
  }
256
- const S = /(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bnow\b|T\d{1,2})/i, K = /(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;
257
- function Q(e, t) {
266
+ const E = /(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bmidday\b|\bmidnight\b|\bnow\b|T\d{1,2})/i, j = /(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;
267
+ function ee(e, t) {
258
268
  if (t === "past")
259
269
  return e <= /* @__PURE__ */ new Date();
260
270
  if (t === "future")
@@ -264,24 +274,24 @@ function Q(e, t) {
264
274
  return e.getFullYear() === r.getFullYear() && e.getMonth() === r.getMonth() && e.getDate() === r.getDate();
265
275
  }
266
276
  const n = (r) => {
267
- const f = r.trim();
268
- if (!f) return { date: null, hasTime: !1, valid: !0 };
269
- const d = x(f);
270
- if (d) return { date: d, hasTime: !1, valid: !0 };
271
- const p = f.search(K);
272
- if (p === -1) return { date: null, hasTime: !1, valid: !1 };
273
- const g = f.search(S);
274
- if (g !== -1 && g < p) return { date: null, hasTime: !1, valid: !1 };
275
- const m = b(f);
276
- return m && !isNaN(m.getTime()) ? { date: m, hasTime: S.test(f), valid: !0 } : { date: null, hasTime: !1, valid: !1 };
277
+ const u = r.trim();
278
+ if (!u) return { date: null, hasTime: !1, valid: !0 };
279
+ const M = O(u);
280
+ if (M) return { date: M, hasTime: !1, valid: !0 };
281
+ const m = u.search(j);
282
+ if (m === -1) return { date: null, hasTime: !1, valid: !1 };
283
+ const f = u.search(E);
284
+ if (f !== -1 && f < m) return { date: null, hasTime: !1, valid: !1 };
285
+ const g = $(u);
286
+ return g && !isNaN(g.getTime()) ? { date: g, hasTime: E.test(u), valid: !0 } : { date: null, hasTime: !1, valid: !1 };
277
287
  };
278
288
  let s = null;
279
289
  if (t.includes(":"))
280
290
  for (let r = 0; r < t.length; r += 1) {
281
291
  if (t[r] !== ":") continue;
282
- const f = n(t.slice(0, r)), d = n(t.slice(r + 1));
283
- if (f.valid && d.valid) {
284
- s = { start: f, end: d };
292
+ const u = n(t.slice(0, r)), M = n(t.slice(r + 1));
293
+ if (u.valid && M.valid) {
294
+ s = { start: u, end: M };
285
295
  break;
286
296
  }
287
297
  }
@@ -289,142 +299,142 @@ function Q(e, t) {
289
299
  const r = n(t);
290
300
  return r.valid && r.date ? r.hasTime ? e.getTime() === r.date.getTime() : e.getFullYear() === r.date.getFullYear() && e.getMonth() === r.date.getMonth() && e.getDate() === r.date.getDate() : !0;
291
301
  }
292
- const i = s.start, a = s.end, c = i.hasTime || a.hasTime ? e.getTime() : new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
302
+ const i = s.start, o = s.end, a = i.hasTime || o.hasTime ? e.getTime() : new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
293
303
  let l = null;
294
304
  i.date && (l = i.hasTime ? i.date.getTime() : new Date(i.date.getFullYear(), i.date.getMonth(), i.date.getDate()).getTime());
295
- let u = null;
296
- return a.date && (u = a.hasTime ? a.date.getTime() : new Date(a.date.getFullYear(), a.date.getMonth(), a.date.getDate(), 23, 59, 59, 999).getTime()), !(l !== null && c < l || u !== null && c > u);
305
+ let d = null;
306
+ return o.date && (d = o.hasTime ? o.date.getTime() : new Date(o.date.getFullYear(), o.date.getMonth(), o.date.getDate(), 23, 59, 59, 999).getTime()), !(l !== null && a < l || d !== null && a > d);
297
307
  }
298
- function ee(e) {
308
+ function te(e) {
299
309
  return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
300
310
  }
301
- function te(e, t) {
311
+ function ne(e, t) {
302
312
  return typeof t == "string" && (t = [t]), t.includes(e.dataset.type || "") || t.includes(e.type);
303
313
  }
304
- function ne(e) {
305
- return e.length <= 255 && C.test(e);
306
- }
307
314
  function re(e) {
308
- return e.replace(/^[^2-90]+/g, "").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/, "$1-$2-$3$4");
315
+ return e.length <= 255 && C.test(e);
309
316
  }
310
317
  function se(e) {
311
- return R.test(e);
318
+ return e.replace(/^[^2-90]+/g, "").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/, "$1-$2-$3$4");
312
319
  }
313
320
  function ie(e) {
314
- return e.replace(/[^0-9]/g, "");
321
+ return I.test(e);
315
322
  }
316
323
  function ae(e) {
317
- return I.test(e);
324
+ return e.replace(/[^0-9]/g, "");
318
325
  }
319
326
  function oe(e) {
327
+ return B.test(e);
328
+ }
329
+ function ce(e) {
320
330
  const t = e.replace(/[^\-0-9.]/g, "");
321
331
  let n = "", s = !1, i = !1;
322
- for (let a = 0; a < t.length; a += 1) {
323
- const o = t[a];
324
- if (o === "-") {
332
+ for (let o = 0; o < t.length; o += 1) {
333
+ const c = t[o];
334
+ if (c === "-") {
325
335
  !i && n.length === 0 && (n += "-", i = !0);
326
336
  continue;
327
337
  }
328
- if (o === ".") {
338
+ if (c === ".") {
329
339
  s || (n += ".", s = !0);
330
340
  continue;
331
341
  }
332
- n += o;
342
+ n += c;
333
343
  }
334
344
  return n;
335
345
  }
336
- function ce(e) {
337
- return B.test(e);
338
- }
339
- const O = { "": 1, K: 1e3, M: 1e6, G: 1e9, T: 1e12 }, j = { "": 1, K: 1024, M: 1024 ** 2, G: 1024 ** 3, T: 1024 ** 4 };
340
346
  function ue(e) {
347
+ return L.test(e);
348
+ }
349
+ const x = { "": 1, K: 1e3, M: 1e6, G: 1e9, T: 1e12 }, U = { "": 1, K: 1024, M: 1024 ** 2, G: 1024 ** 3, T: 1024 ** 4 };
350
+ function le(e) {
341
351
  const n = e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);
342
352
  if (!n) return NaN;
343
- const s = Number.parseFloat(n[1]), i = n[2]?.toUpperCase() || "", a = i.includes("I"), o = i.replace(/I?B$/i, "").replace(/I$/i, "") || "";
344
- return s * (a ? j : O)[o];
353
+ const s = Number.parseFloat(n[1]), i = n[2]?.toUpperCase() || "", o = i.includes("I"), c = i.replace(/I?B$/i, "").replace(/I$/i, "") || "";
354
+ return s * (o ? U : x)[c];
345
355
  }
346
- function le(e, t = !0) {
356
+ function de(e, t = !0) {
347
357
  const n = t ? 1e3 : 1024, s = ["B", "KB", "MB", "GB", "TB"];
348
358
  if (e < n) return `${e} B`;
349
- let i = 0, a = e;
350
- for (; a >= n && i < s.length - 1; )
351
- a /= n, i++;
352
- let o = Math.round(a * 10) / 10;
353
- return o >= n && i < s.length - 1 && (o = 1, i++), `${o % 1 === 0 ? o.toFixed(0) : o.toFixed(1)} ${s[i]}`;
359
+ let i = 0, o = e;
360
+ for (; o >= n && i < s.length - 1; )
361
+ o /= n, i++;
362
+ let c = Math.round(o * 10) / 10;
363
+ return c >= n && i < s.length - 1 && (c = 1, i++), `${c % 1 === 0 ? c.toFixed(0) : c.toFixed(1)} ${s[i]}`;
354
364
  }
355
- function de(e) {
356
- return e = e.trim(), E.test(e) ? e : "https://" + e;
365
+ function me(e) {
366
+ return e = e.trim(), F.test(e) ? e : "https://" + e;
357
367
  }
358
368
  function fe(e) {
359
- return F.test(e);
360
- }
361
- function me(e) {
362
- return e = e.replace(/[^0-9]/g, "").replace(/(.{5})(.*)/, "$1-$2").trim(), e.length === 6 ? e.replace(/-/, "") : e;
369
+ return H.test(e);
363
370
  }
364
371
  function ge(e) {
365
- return H.test(e);
372
+ return e = e.replace(/[^0-9]/g, "").replace(/(.{5})(.*)/, "$1-$2").trim(), e.length === 6 ? e.replace(/-/, "") : e;
366
373
  }
367
374
  function pe(e) {
368
- return e.toUpperCase().replace(/[^A-Z0-9]/g, "").replace(/(.{3})\s*(.*)/, "$1 $2").trim();
375
+ return _.test(e);
369
376
  }
370
377
  function Me(e) {
371
- return _.test(e);
378
+ return e.toUpperCase().replace(/[^A-Z0-9]/g, "").replace(/(.{3})\s*(.*)/, "$1 $2").trim();
372
379
  }
373
380
  function he(e) {
374
- return ["transparent", "currentColor"].includes(e) ? !0 : !e.trim() || typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("color", e);
381
+ return R.test(e);
375
382
  }
376
- let D = null;
377
- const $ = /* @__PURE__ */ new Map();
378
383
  function De(e) {
384
+ return ["transparent", "currentColor"].includes(e) ? !0 : !e.trim() || typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("color", e);
385
+ }
386
+ let T = null;
387
+ const b = /* @__PURE__ */ new Map();
388
+ function Te(e) {
379
389
  if (e = e.trim().toLowerCase(), ["transparent", "currentcolor"].includes(e)) return e;
380
- if ($.has(e)) return $.get(e);
381
- D || (D = document.createElement("canvas"), D.willReadFrequently = !0);
382
- const t = D.getContext("2d");
390
+ if (b.has(e)) return b.get(e);
391
+ T || (T = document.createElement("canvas"), T.willReadFrequently = !0);
392
+ const t = T.getContext("2d");
383
393
  t.fillStyle = e, t.fillRect(0, 0, 1, 1);
384
394
  const n = t.getImageData(0, 0, 1, 1).data, s = "#" + ("000000" + (n[0] << 16 | n[1] << 8 | n[2]).toString(16)).slice(-6);
385
- return $.set(e, s), s;
395
+ return b.set(e, s), s;
386
396
  }
387
- function Te(e) {
397
+ function we(e) {
388
398
  if (typeof e == "boolean") return { valid: e, error: !1, messages: [] };
389
399
  if (typeof e == "string") return { valid: !1, error: !1, messages: [e] };
390
400
  const t = { valid: e.valid, error: e.error ?? !1, messages: [] };
391
401
  return typeof e.message == "string" ? t.messages = [e.message] : typeof e.messages == "string" ? t.messages = [e.messages] : Array.isArray(e.messages) && (t.messages = e.messages), t;
392
402
  }
393
403
  export {
394
- le as formatBytes,
395
- N as formatDateTime,
396
- he as isColor,
397
- V as isDate,
398
- Q as isDateInRange,
399
- J as isDateTime,
400
- ne as isEmail,
401
- ee as isFormControl,
402
- ae as isInteger,
404
+ de as formatBytes,
405
+ y as formatDateTime,
406
+ De as isColor,
407
+ J as isDate,
408
+ ee as isDateInRange,
409
+ W as isDateTime,
410
+ re as isEmail,
411
+ te as isFormControl,
412
+ oe as isInteger,
403
413
  G as isMeridiem,
404
- se as isNANPTel,
405
- ce as isNumber,
406
- Me as isPostalCA,
407
- U as isTime,
408
- te as isType,
414
+ ie as isNANPTel,
415
+ ue as isNumber,
416
+ he as isPostalCA,
417
+ k as isTime,
418
+ ne as isType,
409
419
  fe as isUrl,
410
- ge as isZip,
411
- k as momentToFPFormat,
420
+ pe as isZip,
421
+ V as momentToFPFormat,
412
422
  v as monthToNumber,
413
- Te as normalizeValidationResult,
414
- ue as parseBytes,
415
- De as parseColor,
416
- T as parseDate,
417
- b as parseDateTime,
418
- X as parseDateTimeToString,
419
- W as parseDateToString,
420
- ie as parseInteger,
421
- re as parseNANPTel,
422
- oe as parseNumber,
423
- pe as parsePostalCA,
424
- x as parseRelativeDate,
425
- h as parseTime,
426
- q as parseTimeToString,
427
- de as parseUrl,
428
- me as parseZip,
429
- M as yearToFull
423
+ we as normalizeValidationResult,
424
+ le as parseBytes,
425
+ Te as parseColor,
426
+ w as parseDate,
427
+ $ as parseDateTime,
428
+ q as parseDateTimeToString,
429
+ X as parseDateToString,
430
+ ae as parseInteger,
431
+ se as parseNANPTel,
432
+ ce as parseNumber,
433
+ Me as parsePostalCA,
434
+ O as parseRelativeDate,
435
+ D as parseTime,
436
+ Q as parseTimeToString,
437
+ me as parseUrl,
438
+ ge as parseZip,
439
+ h as yearToFull
430
440
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdlien/validator-utils",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "main": "dist/validator-utils.cjs",
6
6
  "module": "dist/validator-utils.mjs",