/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../core/Error","../../intl/date","../../intl/locale"],(function(e,t,r,n){"use strict";function a(e,t){const n=r.getDateTimeFormatter(t),a=Date.now(),l=n.formatToParts(a),c=new Set;l.filter((({type:e})=>"literal"===e)).forEach((({value:e})=>c.add(e)));let s=0;const f={};for(;l.length>0;){const{type:t,value:r}=l.shift();for(let n=0;n<r.length;n++,s++){const r=e.charAt(s);if(c.has(r)){s++;break}if("literal"===t)break;f[t]||(f[t]=[]),f[t].push(r)}}const u={};try{u.day=o(f.day.join("")),u.month=o(f.month.join("")),u.year=o((f.year||f.relatedYear).join(""))}catch(h){throw i(t)}if(isNaN(u.day)||isNaN(u.month)||isNaN(u.year))throw i(t);return u}function o(e){const t=[/٠/g,/١/g,/٢/g,/٣/g,/٤/g,/٥/g,/٦/g,/٧/g,/٨/g,/٩/g];for(let r=0;r<10;r++)e=e.replace(t[r],r.toString());return Number(e)}function i(e){return new t(`could not parse date input, expecting the following format: ${r.formatDate(Date.now(),e)}`)}const l={ar:6,"ar-dz":6,"ar-kw":6,"ar-ly":6,"ar-ma":1,"ar-sa":7,"ar-tn":1,bg:1,bs:1,ca:1,cs:1,da:1,de:1,"de-at":1,"de-ch":1,el:1,"en-au":1,"en-ca":7,"en-gb":1,"en-ie":1,"en-il":7,"en-in":7,"en-nz":1,"en-sg":7,es:1,"es-do":7,"es-mx":7,"es-us":7,et:1,fi:1,fr:1,"fr-ca":7,"fr-ch":1,he:7,hr:1,hu:1,id:7,it:1,"it-ch":1,ja:7,ko:7,lt:1,lv:1,nb:1,nl:1,"nl-be":1,pl:1,pt:7,"pt-br":7,ro:1,ru:1,sk:1,sl:1,sr:1,"sr-cyrl":1,sv:1,th:7,tr:1,uk:1,vi:1,"zh-cn":7,"zh-hk":7,"zh-mo":7,"zh-tw":7},c="Locale"in Intl&&"weekInfo"in Intl.Locale.prototype;function s(e){if(e=e.toLowerCase(),l[e])return l[e];if(c)try{const t=new Intl.Locale(e).weekInfo.firstDay;return l[e]=t,t}catch{}const t=n.getLanguage(e);return l[t]?l[t]:7}function f(e,t){return(t+7-s(e))%7}e.getFirstDayOfWeek=s,e.getLocaleDayOfWeek=f,e.parseDateIntoParts=a,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
