cotomy 0.3.15 → 0.3.17
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 +15 -9
- package/dist/browser/cotomy.js +57 -8
- package/dist/browser/cotomy.js.map +1 -1
- package/dist/browser/cotomy.min.js +1 -1
- package/dist/browser/cotomy.min.js.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/view.js +57 -8
- package/dist/esm/view.js.map +1 -1
- package/dist/types/view.d.ts +6 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cotomy=e():t.Cotomy=e()}(this,()=>(()=>{var t={48:t=>{var e,n="undefined"!=typeof window&&(window.crypto||window.msCrypto)||"undefined"!=typeof self&&self.crypto;if(n){var r=Math.pow(2,32)-1;e=function(){return Math.abs(n.getRandomValues(new Uint32Array(1))[0]/r)}}else e=Math.random;t.exports=e},146:(t,e,n)=>{var r=n(473),i="object"==typeof window?window:self,s=Object.keys(i).length,o=r(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+s.toString(36),4);t.exports=function(){return o}},353:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,n="millisecond",r="second",i="minute",s="hour",o="day",a="week",l="month",c="quarter",u="year",h="date",d="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},y=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},p={s:y,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+y(r,2,"0")+":"+y(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,l),s=n-i<0,o=e.clone().add(r+(s?-1:1),l);return+(-(r+(n-i)/(s?i-o:o-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:l,y:u,w:a,d:o,D:h,h:s,m:i,s:r,ms:n,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},E="en",T={};T[E]=g;var v="$isDayjsObject",b=function(t){return t instanceof O||!(!t||!t[v])},_=function t(e,n,r){var i;if(!e)return E;if("string"==typeof e){var s=e.toLowerCase();T[s]&&(i=s),n&&(T[s]=n,i=s);var o=e.split("-");if(!i&&o.length>1)return t(o[0])}else{var a=e.name;T[a]=e,i=a}return!r&&i&&(E=i),i||!r&&E},A=function(t,e){if(b(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new O(n)},w=p;w.l=_,w.i=b,w.w=function(t,e){return A(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var O=function(){function g(t){this.$L=_(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[v]=!0}var y=g.prototype;return y.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(w.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(m);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},y.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},y.$utils=function(){return w},y.isValid=function(){return!(this.$d.toString()===d)},y.isSame=function(t,e){var n=A(t);return this.startOf(e)<=n&&n<=this.endOf(e)},y.isAfter=function(t,e){return A(t)<this.startOf(e)},y.isBefore=function(t,e){return this.endOf(e)<A(t)},y.$g=function(t,e,n){return w.u(t)?this[e]:this.set(n,t)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(t,e){var n=this,c=!!w.u(e)||e,d=w.p(t),m=function(t,e){var r=w.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return c?r:r.endOf(o)},f=function(t,e){return w.w(n.toDate()[t].apply(n.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},g=this.$W,y=this.$M,p=this.$D,E="set"+(this.$u?"UTC":"");switch(d){case u:return c?m(1,0):m(31,11);case l:return c?m(1,y):m(0,y+1);case a:var T=this.$locale().weekStart||0,v=(g<T?g+7:g)-T;return m(c?p-v:p+(6-v),y);case o:case h:return f(E+"Hours",0);case s:return f(E+"Minutes",1);case i:return f(E+"Seconds",2);case r:return f(E+"Milliseconds",3);default:return this.clone()}},y.endOf=function(t){return this.startOf(t,!1)},y.$set=function(t,e){var a,c=w.p(t),d="set"+(this.$u?"UTC":""),m=(a={},a[o]=d+"Date",a[h]=d+"Date",a[l]=d+"Month",a[u]=d+"FullYear",a[s]=d+"Hours",a[i]=d+"Minutes",a[r]=d+"Seconds",a[n]=d+"Milliseconds",a)[c],f=c===o?this.$D+(e-this.$W):e;if(c===l||c===u){var g=this.clone().set(h,1);g.$d[m](f),g.init(),this.$d=g.set(h,Math.min(this.$D,g.daysInMonth())).$d}else m&&this.$d[m](f);return this.init(),this},y.set=function(t,e){return this.clone().$set(t,e)},y.get=function(t){return this[w.p(t)]()},y.add=function(n,c){var h,d=this;n=Number(n);var m=w.p(c),f=function(t){var e=A(d);return w.w(e.date(e.date()+Math.round(t*n)),d)};if(m===l)return this.set(l,this.$M+n);if(m===u)return this.set(u,this.$y+n);if(m===o)return f(1);if(m===a)return f(7);var g=(h={},h[i]=t,h[s]=e,h[r]=1e3,h)[m]||1,y=this.$d.getTime()+n*g;return w.w(y,this)},y.subtract=function(t,e){return this.add(-1*t,e)},y.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||d;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=w.z(this),s=this.$H,o=this.$m,a=this.$M,l=n.weekdays,c=n.months,u=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},m=function(t){return w.s(s%12||12,t,"0")},g=u||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(f,function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return w.s(e.$y,4,"0");case"M":return a+1;case"MM":return w.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return w.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,l,2);case"ddd":return h(n.weekdaysShort,e.$W,l,3);case"dddd":return l[e.$W];case"H":return String(s);case"HH":return w.s(s,2,"0");case"h":return m(1);case"hh":return m(2);case"a":return g(s,o,!0);case"A":return g(s,o,!1);case"m":return String(o);case"mm":return w.s(o,2,"0");case"s":return String(e.$s);case"ss":return w.s(e.$s,2,"0");case"SSS":return w.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")})},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(n,h,d){var m,f=this,g=w.p(h),y=A(n),p=(y.utcOffset()-this.utcOffset())*t,E=this-y,T=function(){return w.m(f,y)};switch(g){case u:m=T()/12;break;case l:m=T();break;case c:m=T()/3;break;case a:m=(E-p)/6048e5;break;case o:m=(E-p)/864e5;break;case s:m=E/e;break;case i:m=E/t;break;case r:m=E/1e3;break;default:m=E}return d?m:w.a(m)},y.daysInMonth=function(){return this.endOf(l).$D},y.$locale=function(){return T[this.$L]},y.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=_(t,e,!0);return r&&(n.$L=r),n},y.clone=function(){return w.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},g}(),I=O.prototype;return A.prototype=I,[["$ms",n],["$s",r],["$m",i],["$H",s],["$W",o],["$M",l],["$y",u],["$D",h]].forEach(function(t){I[t[1]]=function(e){return this.$g(e,t[0],t[1])}}),A.extend=function(t,e){return t.$i||(t(e,O,A),t.$i=!0),A},A.locale=_,A.isDayjs=b,A.unix=function(t){return A(1e3*t)},A.en=T[E],A.Ls=T,A.p={},A}()},473:t=>{t.exports=function(t,e){var n="000000000"+t;return n.substr(n.length-e)}},569:function(t){t.exports=function(){"use strict";var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,r,i){var s,o=function(t,n,r){void 0===r&&(r={});var i=new Date(t),s=function(t,n){void 0===n&&(n={});var r=n.timeZoneName||"short",i=t+"|"+r,s=e[i];return s||(s=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:r}),e[i]=s),s}(n,r);return s.formatToParts(i)},a=function(e,n){for(var r=o(e,n),s=[],a=0;a<r.length;a+=1){var l=r[a],c=l.type,u=l.value,h=t[c];h>=0&&(s[h]=parseInt(u,10))}var d=s[3],m=24===d?0:d,f=s[0]+"-"+s[1]+"-"+s[2]+" "+m+":"+s[4]+":"+s[5]+":000",g=+e;return(i.utc(f).valueOf()-(g-=g%1e3))/6e4},l=r.prototype;l.tz=function(t,e){void 0===t&&(t=s);var n,r=this.utcOffset(),o=this.toDate(),a=o.toLocaleString("en-US",{timeZone:t}),l=Math.round((o-new Date(a))/1e3/60),c=15*-Math.round(o.getTimezoneOffset()/15)-l;if(Number(c)){if(n=i(a,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(c,!0),e){var u=n.utcOffset();n=n.add(r-u,"minute")}}else n=this.utcOffset(0,e);return n.$x.$timezone=t,n},l.offsetName=function(t){var e=this.$x.$timezone||i.tz.guess(),n=o(this.valueOf(),e,{timeZoneName:t}).find(function(t){return"timezonename"===t.type.toLowerCase()});return n&&n.value};var c=l.startOf;l.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return c.call(this,t,e);var n=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return c.call(n,t,e).tz(this.$x.$timezone,!0)},i.tz=function(t,e,n){var r=n&&e,o=n||e||s,l=a(+i(),o);if("string"!=typeof t)return i(t).tz(o);var c=function(t,e,n){var r=t-60*e*1e3,i=a(r,n);if(e===i)return[r,e];var s=a(r-=60*(i-e)*1e3,n);return i===s?[r,i]:[t-60*Math.min(i,s)*1e3,Math.max(i,s)]}(i.utc(t,r).valueOf(),l,o),u=c[0],h=c[1],d=i(u).utcOffset(h);return d.$x.$timezone=o,d},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(t){s=t}}}()},584:(t,e,n)=>{var r=n(146),i=n(473),s=n(48),o=0,a=Math.pow(36,4);function l(){return i((s()*a|0).toString(36),4)}function c(){return o=o<a?o:0,++o-1}function u(){return"c"+(new Date).getTime().toString(36)+i(c().toString(36),4)+r()+(l()+l())}u.slug=function(){var t=(new Date).getTime().toString(36),e=c().toString(36).slice(-4),n=r().slice(0,1)+r().slice(-1),i=l().slice(-2);return t.slice(-2)+e+n+i},u.isCuid=function(t){return"string"==typeof t&&!!t.startsWith("c")},u.isSlug=function(t){if("string"!=typeof t)return!1;var e=t.length;return e>=7&&e<=10},u.fingerprint=r,t.exports=u},826:function(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,i,s){var o=i.prototype;s.utc=function(t){return new i({date:t,utc:!0,args:arguments})},o.utc=function(e){var n=s(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},o.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=o.parse;o.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),a.call(this,t)};var l=o.init;o.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else l.call(this)};var c=o.utcOffset;o.utcOffset=function(r,i){var s=this.$utils().u;if(s(r))return this.$u?0:s(this.$offset)?c.call(this):this.$offset;if("string"==typeof r&&(r=function(t){void 0===t&&(t="");var r=t.match(e);if(!r)return null;var i=(""+r[0]).match(n)||["-",0,0],s=i[0],o=60*+i[1]+ +i[2];return 0===o?0:"+"===s?o:-o}(r),null===r))return this;var o=Math.abs(r)<=16?60*r:r,a=this;if(i)return a.$offset=o,a.$u=0===r,a;if(0!==r){var l=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(o+l,t)).$offset=o,a.$x.$localOffset=l}else a=this.utc();return a};var u=o.format;o.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return u.call(this,e)},o.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var h=o.toDate;o.toDate=function(t){return"s"===t&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=o.diff;o.diff=function(t,e,n){if(t&&this.$u===t.$u)return d.call(this,t,e,n);var r=this.local(),i=s(t).local();return d.call(r,i,e,n)}}}()}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{CotomyApi:()=>L,CotomyApiException:()=>y,CotomyApiFailedEvent:()=>P,CotomyApiForm:()=>x,CotomyApiResponse:()=>C,CotomyBracketBindNameGenerator:()=>R,CotomyConflictException:()=>b,CotomyDebugFeature:()=>e,CotomyDebugSettings:()=>o,CotomyDotBindNameGenerator:()=>D,CotomyElement:()=>m,CotomyEntityApiForm:()=>F,CotomyEntityFillApiForm:()=>H,CotomyForbiddenException:()=>T,CotomyForm:()=>U,CotomyHttpClientError:()=>p,CotomyHttpServerError:()=>w,CotomyInvalidFormDataBodyException:()=>I,CotomyMetaElement:()=>f,CotomyNotFoundException:()=>v,CotomyPageController:()=>W,CotomyQueryForm:()=>M,CotomyRequestInvalidException:()=>_,CotomyResponseJsonParseException:()=>O,CotomyTooManyRequestsException:()=>A,CotomyUnauthorizedException:()=>E,CotomyUrl:()=>z,CotomyViewRenderer:()=>$,CotomyWindow:()=>g});var t,e,i=n(353),s=n.n(i);!function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLY_HINTS=103]="EARLY_HINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",t[t.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.IM_A_TEAPOT=418]="IM_A_TEAPOT",t[t.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",t[t.METHOD_FAILURE=420]="METHOD_FAILURE",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"}(t||(t={})),function(t){t.Api="api",t.Fill="fill",t.Bind="bind",t.FormData="formdata",t.Html="html",t.Page="page",t.FormLoad="formload"}(e||(e={}));class o{static isEnabled(t){const e=localStorage.getItem(this.PREFIX);return t&&"true"===localStorage.getItem(`${this.PREFIX}:${String(t)}`)||"true"===e}static enable(t){localStorage.setItem(`${this.PREFIX}:${String(t)}`,"true")}static disable(t){localStorage.setItem(`${this.PREFIX}:${String(t)}`,"false")}static enableAll(){localStorage.setItem(this.PREFIX,"true")}static disableAll(){localStorage.setItem(this.PREFIX,"false")}static clear(t){t?localStorage.removeItem(`${this.PREFIX}:${String(t)}`):localStorage.removeItem(this.PREFIX)}}o.PREFIX="cotomy:debug";var a=n(584),l=n.n(a);class c{constructor(t,e,n){this.handle=t,this.wrapper=e,this.options=n}get current(){return this.wrapper??this.handle}equals(t,e,n,r){let i,s,o,a="strict";return t instanceof c?(i=t.handle,s=t.wrapper,o=t.options,a=e??"strict"):(i=t,"string"==typeof e?(a=e,s=n,o=void 0):(o=e,s=n,a=r??"strict")),this.handle===i&&("strict"!==a||this.wrapper===s)&&c.optionsEquals(this.options,o)}static optionsEquals(t,e){const n=(t,e)=>t?.[e]??!1,r=t=>t?.signal,i=r(t)===r(e);return n(t,"capture")===n(e,"capture")&&n(t,"once")===n(e,"once")&&n(t,"passive")===n(e,"passive")&&i}}class u{constructor(t){this.target=t,this._registory=new Map}ensure(t){return this._registory.get(t)??this._registory.set(t,[]).get(t)}find(t,e){return this._registory.get(t)?.find(t=>t.equals(e))??void 0}add(t,e){e.options?.once&&this.remove(t,e),this.find(t,e)||(this.ensure(t).push(e),this.target.element.addEventListener(t,e.current,e.options))}remove(t,e){if(!e){const e=this._registory.get(t);if(!e)return;return e.forEach(e=>this.target.element.removeEventListener(t,e.current,e.options?.capture??!1)),void this._registory.delete(t)}const n=this._registory.get(t);if(n){const r=[];for(const i of n)i.equals(e,"remove")?this.target.element.removeEventListener(t,i.current,i.options?.capture??!1):r.push(i);0===r.length?this._registory.delete(t):this._registory.set(t,r)}}get empty(){return 0===this._registory.size}}class h{constructor(){this._registry=new Map}static get instance(){return this._instance??(this._instance=new h)}map(t){const e=t.scopeId;let n=this._registry.get(e);return n||(n=new u(t),this._registry.set(e,n)),n}on(t,e,n){this.map(e).add(t,n)}off(t,e,n){const r=this._registry.get(e.scopeId);r&&(n?r.remove(t,n):r.remove(t),r.empty&&this._registry.delete(e.scopeId))}clear(t){this._registry.delete(t.scopeId)}}class d{constructor(t={}){this.behavior="smooth",this.onlyIfNeeded=!0,this.block="nearest",this.inline="nearest",void 0!==t.behavior&&(this.behavior=t.behavior),void 0!==t.onlyIfNeeded&&(this.onlyIfNeeded=t.onlyIfNeeded),void 0!==t.block&&(this.block=t.block),void 0!==t.inline&&(this.inline=t.inline)}resolveBehavior(){return this.behavior}static from(t){return t instanceof d?t:new d(t??{})}}class m{static encodeHtml(t){const e=document.createElement("div");return e.textContent=t??"",e.innerHTML}static createHTMLElement(t){const e=t.match(/<\s*([a-z0-9]+)/i);if(!e)throw new Error(`Invalid HTML: cannot extract tag from "${t}"`);const n=e[1].toLowerCase(),r={tr:{prefix:"<table><tbody>",suffix:"</tbody></table>"},td:{prefix:"<table><tbody><tr>",suffix:"</tr></tbody></table>"},th:{prefix:"<table><tbody><tr>",suffix:"</tr></tbody></table>"},thead:{prefix:"<table>",suffix:"</table>"},tbody:{prefix:"<table>",suffix:"</table>"},tfoot:{prefix:"<table>",suffix:"</table>"},caption:{prefix:"<table>",suffix:"</table>"},colgroup:{prefix:"<table>",suffix:"</table>"},col:{prefix:"<table><colgroup>",suffix:"</colgroup></table>"},option:{prefix:"<select>",suffix:"</select>"},optgroup:{prefix:"<select>",suffix:"</select>"},legend:{prefix:"<fieldset>",suffix:"</fieldset>"},li:{prefix:"<ul>",suffix:"</ul>"}}[n],i=r?`${r.prefix}${t}${r.suffix}`:t,s=(new DOMParser).parseFromString(i,"text/html");if(s.querySelector("parsererror"))throw new Error(`HTML parsing failed for tag <${n}>: "${t}"`);if(1!==s.body.children.length)throw new Error(`CotomyElement requires a single root element, but got ${s.body.children.length}.`);const o=s.body.querySelector(n);if(!o)throw new Error(`Parsed but <${n}> element not found: "${t}"`);return o}static first(t,e){const n=document.querySelector(t);if(n)return new(e??m)(n)}static last(t,e){return m.find(t,e).pop()}static find(t,e){const n=document.querySelectorAll(t),r=e??m;return Array.from(n).map(t=>new r(t))}static contains(t){return null!==document.querySelector(t)}static byId(t,e){const n=document.getElementById(t);return n?new(e??m)(n):void 0}static containsById(t){return null!==document.getElementById(t)}static empty(t){return new(t??m)(document.createElement("div")).attribute("data-cotomy-empty","").style("display","none")}constructor(t){this._parentElement=null,t instanceof HTMLElement?this._element=t:"string"==typeof t?this._element=m.createHTMLElement(t):(this._element=m.createHTMLElement("html"in t?t.html:`<${t.tagname}></${t.tagname}>`),"tagname"in t&&t.text&&(this._element.textContent=t.text),t.css&&this.useScopedCss(t.css),o.isEnabled(e.Html)&&("html"in t&&console.debug(`CotomyElement {html: "${t.html}" } is created`),"tagname"in t&&console.debug(`CotomyElement {tagname: "${t.tagname}", text: "${t.text??""}"} is created`),t.css&&console.debug(`CotomyElement {css: "${t.css}" } is applied`))),this.setInstanceId()}setInstanceId(){this.hasAttribute("data-cotomy-instance")||(this.attribute("data-cotomy-instance",l()()),this.removed(()=>{this._element=m.createHTMLElement('<div data-cotomy-invalidated style="display: none;"></div>'),h.instance.clear(this)}),this.on("cotomy:transitstart",()=>{this.attribute("data-cotomy-moving",""),this.find("[data-cotomy-instance]").forEach(t=>t.attribute("data-cotomy-moving",""))}),this.on("cotomy:transitend",()=>{this.attribute("data-cotomy-moving",null),this.find("[data-cotomy-instance]").forEach(t=>t.attribute("data-cotomy-moving",null))}))}get instanceId(){return this.attribute("data-cotomy-instance")}get scopeId(){return this.hasAttribute("data-cotomy-scopeid")||this.attribute("data-cotomy-scopeid",l()()),this.attribute("data-cotomy-scopeid")}get stylable(){return!["script","style","link","meta"].includes(this.tagname)}get scopedCssElementId(){return`css-${this.scopeId}`}useScopedCss(t){if(t&&this.stylable){const e=this.scopedCssElementId;m.find(`#${e}`).forEach(t=>t.remove());const n=document.createElement("style"),r=t.replace(/\[scope\]/g,`[data-cotomy-scopeid="${this.scopeId}"]`),i=document.createTextNode(r);n.appendChild(i),n.id=e,(m.first("head")||new m({html:"<head></head>"}).prependTo(new m(document.documentElement))).append(new m(n)),this.removed(()=>{m.find(`#${e}`).forEach(t=>t.remove())})}return this}listenLayoutEvents(){return this.attribute(m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE,""),this}get id(){return this.attribute("id")}generateId(t="__cotomy_elem__"){return this.id||this.attribute("id",`${t}${l()()}`),this}get element(){return this._element}clone(t){const e=t??m,n=this.element.cloneNode(!0);if(n.hasAttribute("data-cotomy-invalidated"))throw new Error("Cannot clone an invalidated CotomyElement.");return["data-cotomy-instance","data-cotomy-scopeid","data-cotomy-moving"].forEach(t=>{n.removeAttribute(t),n.querySelectorAll(`[${t}]`).forEach(e=>e.removeAttribute(t))}),new e(n)}get tagname(){return this.element.tagName.toLowerCase()}is(t){const e=t.split(/\s+(?![^\[]*\])|(?<=\>)\s+/);let n=this.element;for(let t=e.length-1;t>=0;t--){let r=e[t].trim(),i=!1;if(r.startsWith(">")&&(i=!0,r=r.slice(1).trim()),!n||!n.matches(r))return!1;if(i)n=n.parentElement;else if(t>0)for(;n&&!n.matches(e[t-1].trim());)n=n.parentElement}return!0}match(t){try{return this.element.matches(t)}catch{return!1}}get empty(){return new Set(["input","select","textarea","img","video","audio","br","hr","iframe","embed","canvas","object","svg","source","track","col","link","meta","base"]).has(this.tagname)||this._element.hasAttribute("data-cotomy-empty")||""===this._element.innerHTML.trim()}get attached(){return document.contains(this.element)}get readonly(){return"readOnly"in this.element?this.element.readOnly:this.element.hasAttribute("readonly")}set readonly(t){"readOnly"in this.element?this.element.readOnly=t:t?this.attribute("readonly","readonly"):this.attribute("readonly",null)}get value(){return"value"in this.element?this.element.value:this.attribute("data-cotomy-value")??""}set value(t){"value"in this.element?this.element.value=t:this.attribute("data-cotomy-value",t)}get text(){return this.element.textContent??""}set text(t){this.element.textContent=t??""}get html(){return this.element.innerHTML}set html(t){this.element.innerHTML=t}setFocus(){return this.element.focus(),this}get visible(){if(!this.attached)return!1;if(!this.element.offsetParent&&!document.contains(this.element))return!1;const t=this.element.getBoundingClientRect();if(t.width>0&&t.height>0){const t=this.getComputedStyle();return"none"!==t.display&&"hidden"!==t.visibility&&"collapse"!==t.visibility}return!1}get enabled(){return!(this.element.hasAttribute("disabled")&&null!==this.element.getAttribute("disabled"))}set enabled(t){t?this.element.removeAttribute("disabled"):this.element.setAttribute("disabled","disabled")}get invalidated(){return this.element.hasAttribute("data-cotomy-invalidated")}remove(){this.invalidated||this._element.remove()}clear(){return this.find("*").forEach(t=>t.remove()),this.text="",this}get width(){return this.element.offsetWidth}set width(t){let e=t.toString()+"px";this.style("width",e)}get height(){return this.element.offsetHeight}set height(t){let e=t.toString()+"px";this.style("height",e)}get innerWidth(){return this.element.clientWidth}get innerHeight(){return this.element.clientHeight}get outerWidth(){const t=this.getComputedStyle(),e=parseFloat(t.marginLeft)+parseFloat(t.marginRight);return this.element.offsetWidth+e}get outerHeight(){const t=this.getComputedStyle(),e=parseFloat(t.marginTop)+parseFloat(t.marginBottom);return this.element.offsetHeight+e}get scrollHeight(){return this.element.scrollHeight}get scrollWidth(){return this.element.scrollWidth}get scrollTop(){return this.element.scrollTop}get position(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left}}get absolutePosition(){const t=this.element.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}get screenPosition(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left}}get rect(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}get innerRect(){const t=this.element.getBoundingClientRect(),e=this.getComputedStyle(),n=parseFloat(e.paddingTop),r=parseFloat(e.paddingRight),i=parseFloat(e.paddingBottom),s=parseFloat(e.paddingLeft);return{top:t.top+n,left:t.left+s,width:t.width-s-r,height:t.height-n-i}}get outerRect(){const t=this.element.getBoundingClientRect(),e=this.getComputedStyle(),n=parseFloat(e.marginTop),r=parseFloat(e.marginRight),i=parseFloat(e.marginBottom),s=parseFloat(e.marginLeft);return{top:t.top-n,left:t.left-s,width:t.width+s+r,height:t.height+n+i}}get padding(){const t=this.getComputedStyle();return{top:parseFloat(t.paddingTop),right:parseFloat(t.paddingRight),bottom:parseFloat(t.paddingBottom),left:parseFloat(t.paddingLeft)}}get margin(){const t=this.getComputedStyle();return{top:parseFloat(t.marginTop),right:parseFloat(t.marginRight),bottom:parseFloat(t.marginBottom),left:parseFloat(t.marginLeft)}}get inViewport(){const t=this.element.getBoundingClientRect();return t.top<window.innerHeight&&t.bottom>0}get isAboveViewport(){return this.element.getBoundingClientRect().bottom<0}get isBelowViewport(){return this.element.getBoundingClientRect().top>window.innerHeight}get isLeftViewport(){return this.element.getBoundingClientRect().right<0}get isRightViewport(){return this.element.getBoundingClientRect().left>window.innerWidth}static isScrollableOverflow(t){const e=(t??"").toLowerCase();return"auto"===e||"scroll"===e}static findNearestScrollableAncestor(t){let e=t.parentElement;for(;e;){if(e===document.body||e===document.documentElement)return null;const t=window.getComputedStyle(e),n=t.overflowY,r=t.overflowX,i=m.isScrollableOverflow(n)&&e.scrollHeight>e.clientHeight,s=m.isScrollableOverflow(r)&&e.scrollWidth>e.clientWidth;if(i||s)return e;e=e.parentElement}return null}static computeAlignedScroll(t,e,n,r,i,s){const o=t+e;return s&&n>=t&&r<=o?null:"start"===i?n:"end"===i?r-e:"center"===i?n-(e-(r-n))/2:n<t?n:r>o?r-e:null}scrollIn(t={}){if(!this.attached)return this;const e=d.from(t),n=e.resolveBehavior(),r=e.onlyIfNeeded,i=e.block,s=e.inline,o=m.findNearestScrollableAncestor(this.element);if(o){const t=this.element.getBoundingClientRect(),e=o.getBoundingClientRect(),a=t.top-e.top+o.scrollTop,l=t.bottom-e.top+o.scrollTop,c=t.left-e.left+o.scrollLeft,u=t.right-e.left+o.scrollLeft,h=m.computeAlignedScroll(o.scrollTop,o.clientHeight,a,l,i,r),d=m.computeAlignedScroll(o.scrollLeft,o.clientWidth,c,u,s,r);if(!r||null!==h||null!==d){const t=h??o.scrollTop,e=d??o.scrollLeft;o.scrollTo?.({top:t,left:e,behavior:n}),o.scrollTo||(o.scrollTop=t,o.scrollLeft=e)}return this}const a=this.element.getBoundingClientRect(),l=window.scrollY||document.documentElement.scrollTop,c=window.scrollX||document.documentElement.scrollLeft,u=l+a.top,h=l+a.bottom,f=c+a.left,g=c+a.right,y=m.computeAlignedScroll(l,window.innerHeight,u,h,i,r),p=m.computeAlignedScroll(c,window.innerWidth,f,g,s,r);return r&&null===y&&null===p||window.scrollTo({top:y??l,left:p??c,behavior:n}),this}scrollTo(t,e={}){if("string"==typeof t){const n=this.first(t);return n?.scrollIn(e),this}return t instanceof m?(t.scrollIn(e),this):(new m(t).scrollIn(e),this)}comesBefore(t){const e=this.element.compareDocumentPosition(t.element);return!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&0!==(e&Node.DOCUMENT_POSITION_FOLLOWING)}comesAfter(t){const e=this.element.compareDocumentPosition(t.element);return!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&0!==(e&Node.DOCUMENT_POSITION_PRECEDING)}hasAttribute(t){return this.element.hasAttribute(t)}attribute(t,e){return 1===arguments.length?this.element.hasAttribute(t)?this.element.getAttribute(t):void 0:null===e?(this.element.removeAttribute(t),this):(this.element.setAttribute(t,e?.toString()??""),this)}hasClass(t){return this.element.classList.contains(t)}addClass(t){return this.element.classList.add(t),this}removeClass(t){return this.element.classList.remove(t),this}toggleClass(t,e){return this.element.classList.toggle(t,e),this}style(t,e){return 1===arguments.length?this.element.style.getPropertyValue(t):null==e?(this.element.style.removeProperty(t),this):(this.element.style.setProperty(t,e),this)}getComputedStyle(){return window.getComputedStyle(this.element)}computedStyle(t){return window.getComputedStyle(this.element).getPropertyValue(t)}get parent(){return null==this._parentElement&&null!==this.element.parentElement&&(this._parentElement=new m(this.element.parentElement)),this._parentElement??m.empty()}get parents(){let t=[],e=this.element.parentElement;for(;null!==e;)t.push(new m(e)),e=e.parentElement;return t}hasChildren(t="*"){return null!==this.element.querySelector(t)}children(t="*",e){const n=Array.from(this.element.querySelectorAll(t)).filter(t=>t.parentElement===this.element),r=e??m;return n.filter(t=>t instanceof HTMLElement).map(t=>new r(t))}firstChild(t="*",e){return this.children(t,e).shift()??void 0}lastChild(t="*",e){return this.children(t,e).pop()??void 0}closest(t,e){const n=this.element.closest(t);if(null!==n&&n instanceof HTMLElement)return new(e??m)(n)}previousSibling(t="*",e){const n=this.element.previousElementSibling;if(null!==n&&n instanceof HTMLElement){const r=new(e??m)(n);return r.match(t)?r:r.previousSibling(t,e)}}nextSibling(t="*",e){const n=this.element.nextElementSibling;if(null!==n&&n instanceof HTMLElement){const r=new(e??m)(n);return r.match(t)?r:r.nextSibling(t,e)}}siblings(t="*",e){const n=this.element.parentElement;if(!n)return[];const r=e??m;return Array.from(n.children).filter(t=>t instanceof HTMLElement&&t!==this.element).map(t=>new r(t)).filter(e=>e.match(t))}find(t,e){return Array.from(this.element.querySelectorAll(t)).map(t=>new(e??m)(t))}first(t="*",e){return this.find(t,e).shift()??void 0}last(t="*",e){return this.find(t,e).pop()??void 0}contains(t){return this.find(t).length>0}static runWithMoveEvents(t,e){t.trigger("cotomy:transitstart");try{e()}finally{t.trigger("cotomy:transitend")}}prepend(t){return m.runWithMoveEvents(t,()=>{this.element.prepend(t.element)}),this}append(t){return m.runWithMoveEvents(t,()=>{this.element.append(t.element)}),this}appendAll(t){return t.forEach(t=>this.append(t)),this}insertBefore(t){return m.runWithMoveEvents(t,()=>{this.element.before(t.element)}),this}insertAfter(t){return m.runWithMoveEvents(t,()=>{this.element.after(t.element)}),this}appendTo(t){return m.runWithMoveEvents(this,()=>{t.element.append(this.element)}),this}prependTo(t){return m.runWithMoveEvents(this,()=>{t.element.prepend(this.element)}),this}trigger(t,e){return this.element.dispatchEvent(e??new Event(t,{bubbles:!0})),this}on(t,e,n){return(Array.isArray(t)?t:[t]).forEach(t=>{const r=new c(e,void 0,n);h.instance.on(t,this,r)}),this}onSubTree(t,e,n,r){const i=t=>{const r=t.target;if(r&&r.closest(e))return n(t)};return(Array.isArray(t)?t:[t]).forEach(t=>{const e=new c(n,i,r);h.instance.on(t,this,e)}),this}once(t,e,n){const r={...n??{},once:!0};return this.off(t,e,r),(Array.isArray(t)?t:[t]).forEach(t=>{const n=new c(e,void 0,r);h.instance.on(t,this,n)}),this}off(t,e,n){return(Array.isArray(t)?t:[t]).forEach(t=>{if(e){const r=new c(e,void 0,n);h.instance.off(t,this,r)}else h.instance.off(t,this)}),this}click(t){return t?this.element.addEventListener("click",async e=>await t(e)):this.trigger("click"),this}dblclick(t){return t?this.element.addEventListener("dblclick",async e=>await t(e)):this.trigger("dblclick"),this}mouseover(t){return t?this.element.addEventListener("mouseover",async e=>await t(e)):this.trigger("mouseover"),this}mouseout(t){return t?this.element.addEventListener("mouseout",async e=>await t(e)):this.trigger("mouseout"),this}mousedown(t){return t?this.element.addEventListener("mousedown",async e=>await t(e)):this.trigger("mousedown"),this}mouseup(t){return t?this.element.addEventListener("mouseup",async e=>await t(e)):this.trigger("mouseup"),this}mousemove(t){return t?this.element.addEventListener("mousemove",async e=>await t(e)):this.trigger("mousemove"),this}mouseenter(t){return t?this.element.addEventListener("mouseenter",async e=>await t(e)):this.trigger("mouseenter"),this}mouseleave(t){return t?this.element.addEventListener("mouseleave",async e=>await t(e)):this.trigger("mouseleave"),this}dragstart(t){return t?this.element.addEventListener("dragstart",async e=>await t(e)):this.trigger("dragstart"),this}dragend(t){return t?this.element.addEventListener("dragend",async e=>await t(e)):this.trigger("dragend"),this}dragover(t){return t?this.element.addEventListener("dragover",async e=>await t(e)):this.trigger("dragover"),this}dragenter(t){return t?this.element.addEventListener("dragenter",async e=>await t(e)):this.trigger("dragenter"),this}dragleave(t){return t?this.element.addEventListener("dragleave",async e=>await t(e)):this.trigger("dragleave"),this}drop(t){return t?this.element.addEventListener("drop",async e=>await t(e)):this.trigger("drop"),this}drag(t){return t?this.element.addEventListener("drag",async e=>await t(e)):this.trigger("drag"),this}removed(t){return this.element.addEventListener("removed",async e=>await t(e)),this}keydown(t){return t?this.element.addEventListener("keydown",async e=>await t(e)):this.trigger("keydown"),this}keyup(t){return t?this.element.addEventListener("keyup",async e=>await t(e)):this.trigger("keyup"),this}keypress(t){return t?this.element.addEventListener("keypress",async e=>await t(e)):this.trigger("keypress"),this}change(t){return t?this.element.addEventListener("change",async e=>await t(e)):this.trigger("change"),this}input(t){return t?this.element.addEventListener("input",async e=>await t(e)):this.trigger("input"),this}static get intersectionObserver(){return m._intersectionObserver=m._intersectionObserver??new IntersectionObserver(t=>{t.filter(t=>t.isIntersecting).forEach(t=>t.target.dispatchEvent(new Event("inview"))),t.filter(t=>!t.isIntersecting).forEach(t=>t.target.dispatchEvent(new Event("outview")))})}inview(t){return t?(m.intersectionObserver.observe(this.element),this.element.addEventListener("inview",async e=>await t(e))):this.trigger("inview"),this}outview(t){return t?(m.intersectionObserver.observe(this.element),this.element.addEventListener("outview",async e=>await t(e))):this.trigger("outview"),this}focus(t){return t?this.element.addEventListener("focus",async e=>await t(e)):this.trigger("focus"),this}blur(t){return t?this.element.addEventListener("blur",async e=>await t(e)):this.trigger("blur"),this}focusin(t){return t?this.element.addEventListener("focusin",async e=>await t(e)):this.trigger("focusin"),this}focusout(t){return t?this.element.addEventListener("focusout",async e=>await t(e)):this.trigger("focusout"),this}filedrop(t){return this.element.addEventListener("drop",async e=>{e.preventDefault();const n=e.dataTransfer;n&&n.files&&await t(Array.from(n.files))}),this}resize(t){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:resize",async e=>await t(e)):this.trigger("cotomy:resize"),this}scroll(t){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:scroll",async e=>await t(e)):this.trigger("cotomy:scroll"),this}changeLayout(t){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:changelayout",async e=>await t(e)):this.trigger("cotomy:changelayout"),this}}m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE="data-cotomy-layout",m._intersectionObserver=null;class f extends m{static get(t){return m.first(`meta[name="${t}" i]`,f)??m.empty(f)}get content(){return this.attribute("content")??""}}class g{constructor(){this._body=m.empty(),this._mutationObserver=null,this._reloading=!1,this._eventHandlers={}}static get instance(){return g._instance??(g._instance=new g)}get initialized(){return this._body.attached}initialize(){if(!this.initialized){if(!document.body)throw new Error("<body> element not found. DOM may not be ready.");this._body=m.first("body"),["resize","scroll","orientationchange","fullscreenchange","cotomy:ready"].forEach(t=>{window.addEventListener(t,()=>{const t=new CustomEvent("cotomy:changelayout");window.dispatchEvent(t)},{passive:!0})}),document.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault()}),this.resize(()=>{document.querySelectorAll(`[${m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:resize"))})}),this.scroll(()=>{document.querySelectorAll(`[${m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:scroll"))})}),this.changeLayout(()=>{document.querySelectorAll(`[${m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:changelayout"))})}),this._mutationObserver=new MutationObserver(t=>{t.forEach(t=>{t.removedNodes.forEach(t=>{if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement){const e=new m(t);e.hasAttribute("data-cotomy-moving")||e.attached||e.trigger("removed")}})})}),this._mutationObserver.observe(this.body.element,{childList:!0,subtree:!0})}return this}get reloading(){return this._reloading}reload(){this._reloading=!0,location.reload()}get body(){return this._body}append(t){return this._body.append(t),this}moveNext(t,e=!1){const n=Array.from(this.body.element.querySelectorAll("input, a, select, button, textarea")).map(t=>new m(t)).filter(t=>t.width>0&&t.height>0&&t.visible&&t.enabled&&!t.hasAttribute("readonly"));let r=n.map(t=>t.element).indexOf(t.element)+(e?-1:1);r>=n.length?r=0:r<0&&(r=n.length-1),n[r]&&n[r].setFocus()}trigger(t,e){return window.dispatchEvent(e??new Event(t,{bubbles:!0})),this}on(t,e){return(Array.isArray(t)?t:[t]).forEach(t=>{this._eventHandlers[t]||(this._eventHandlers[t]=[]),this._eventHandlers[t].push(e),window.addEventListener(t,e)}),this}off(t,e){return(Array.isArray(t)?t:[t]).forEach(t=>{if(e){window.removeEventListener(t,e);const n=this._eventHandlers[t]?.filter(t=>t!==e)??[];n.length>0?this._eventHandlers[t]=n:delete this._eventHandlers[t]}else{for(const e of this._eventHandlers[t]??[])window.removeEventListener(t,e);delete this._eventHandlers[t]}}),this}load(t){return this.on("load",t)}ready(t){return this.on("cotomy:ready",t)}resize(t){return t?this.on("resize",t):this.trigger("resize")}scroll(t){return t?this.on("scroll",t):this.trigger("scroll")}scrollTo(t,e={}){if("string"==typeof t){const n=m.first(t);return n?.scrollIn(e),this}return t instanceof m?(t.scrollIn(e),this):(new m(t).scrollIn(e),this)}changeLayout(t){return t?this.on("cotomy:changelayout",t):this.trigger("cotomy:changelayout")}pageshow(t){return t?this.on("pageshow",t):this.trigger("pageshow")}get scrollTop(){return window.scrollY||document.documentElement.scrollTop}get scrollLeft(){return window.scrollX||document.documentElement.scrollLeft}get width(){return window.innerWidth}get height(){return window.innerHeight}get documentWidth(){return document.documentElement.scrollWidth}get documentHeight(){return document.documentElement.scrollHeight}}g._instance=null;class y extends Error{constructor(t,e,n,r=""){super(e),this.status=t,this.message=e,this.response=n,this.bodyText=r,this.name="CotomyApiException"}}class p extends y{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyHttpClientError"}}class E extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyUnauthorizedException"}}class T extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyForbiddenException"}}class v extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyNotFoundException"}}class b extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyConflictException"}}class _ extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyRequestInvalidException"}}class A extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyTooManyRequestsException"}}class w extends y{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyHttpServerError"}}class O extends Error{constructor(t="Failed to parse JSON response."){super(t),this.name="CotomyResponseJsonParseException"}}class I extends Error{constructor(t="Body must be an instance of FormData."){super(t),this.name="CotomyInvalidFormDataBodyException"}}class S{}S.GET="GET",S.POST="POST",S.PUT="PUT",S.PATCH="PATCH",S.DELETE="DELETE",S.HEAD="HEAD",S.OPTIONS="OPTIONS",S.TRACE="TRACE",S.CONNECT="CONNECT";class N{static getMessage(t){return this._responseMessages[t]||`Unexpected error: ${t}`}}N._responseMessages={[t.BAD_REQUEST]:"There is an error in the input. Please check and try again.",[t.UNAUTHORIZED]:"You are not authenticated. Please log in again.",[t.FORBIDDEN]:"You do not have permission to use this feature. If necessary, please contact the administrator.",[t.NOT_FOUND]:"The specified information could not be found. It may have been deleted. Please start over or contact the administrator.",[t.METHOD_NOT_ALLOWED]:"This operation is currently prohibited on the server.",[t.NOT_ACCEPTABLE]:"The request cannot be accepted. Processing has been stopped.",[t.PROXY_AUTHENTICATION_REQUIRED]:"Proxy authentication is required for internet access.",[t.REQUEST_TIMEOUT]:"The request timed out. Please try again.",[t.CONFLICT]:"The identifier you are trying to register already exists. Please check the content and try again.",[t.PAYMENT_REQUIRED]:"Payment is required for this operation. Please check.",[t.GONE]:"The requested resource is no longer available.",[t.LENGTH_REQUIRED]:"The Content-Length header field is required for the request.",[t.PRECONDITION_FAILED]:"The request failed because the precondition was not met.",[t.UNSUPPORTED_MEDIA_TYPE]:"The requested media type is not supported.",[t.EXPECTATION_FAILED]:"The server cannot meet the Expect header of the request.",[t.MISDIRECTED_REQUEST]:"The server cannot appropriately process this request.",[t.UNPROCESSABLE_ENTITY]:"There is an error in the request content.",[t.LOCKED]:"The requested resource is locked.",[t.FAILED_DEPENDENCY]:"The request failed due to dependency on a previous failed request.",[t.UPGRADE_REQUIRED]:"A protocol upgrade is required to perform this operation.",[t.PRECONDITION_REQUIRED]:"This request requires a precondition.",[t.TOO_MANY_REQUESTS]:"Too many requests have been sent in a short time. Please wait and try again.",[t.REQUEST_HEADER_FIELDS_TOO_LARGE]:"The request headers are too large.",[t.INTERNAL_SERVER_ERROR]:"An unexpected error occurred. Please try again later.",[t.BAD_GATEWAY]:"The server is currently overloaded. Please wait and try again later.",[t.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[t.GATEWAY_TIMEOUT]:"The communication timed out. Please try again.",[t.HTTP_VERSION_NOT_SUPPORTED]:"The current communication method is not supported.",[t.NOT_IMPLEMENTED]:"The server does not support the requested functionality.",[t.INSUFFICIENT_STORAGE]:"The server has insufficient storage.",[t.NETWORK_AUTHENTICATION_REQUIRED]:"Network authentication is required.",413:"The payload of the request is too large. Please check the size.",414:"The request URI is too long.",416:"The requested range is invalid.",508:"The server detected a loop.",510:"The request does not include the required extensions."};class C{constructor(t){this._response=t,this._object=null,this._text=null}get available(){return!!this._response}get empty(){return!this._response||0===this._response.status}get ok(){return this._response?.ok??!1}get status(){return this._response?.status??0}get statusText(){return this._response?.statusText??""}get headers(){return this._response?.headers??new Headers}async textAsync(){return this._response?this._text??(this._text=await(this._response?.text())):""}async _ensureJsonParsedAsync(t){if(this._response&&null===this._object)try{const e=await this.textAsync();this._object=e?JSON.parse(e):t}catch(t){throw new O(`Failed to parse JSON response: ${t instanceof Error?t.message:String(t)}`)}return this._object??t}async objectAsync(t={}){return await this._ensureJsonParsedAsync(t)}async arrayAsync(t=[]){const e=await this._ensureJsonParsedAsync(t);return Array.isArray(e)?e:t}}class R{create(t,e){return e?`${e}[${t}]`:t}createIndex(t,e){return this.create(String(e),t)}}class D{create(t,e){return e?`${e}.${t}`:t}createIndex(t,e){return t?`${t}[${e}]`:`[${e}]`}}class ${constructor(t,e){this.element=t,this.bindNameGenerator=e,this._renderers={},this._builded=!1}get locale(){const t=(navigator.languages&&navigator.languages.length?navigator.languages:[navigator.language]).filter(Boolean);let e=this.element.attribute("data-cotomy-locale")||this.element.closest("[data-cotomy-locale]")?.attribute("data-cotomy-locale")||t[0]||"en-US";return e.includes("-")?e.split("-")[0]:e}renderer(t,e){return this._renderers[t]=e,this}get renderers(){return this.initialize(),this._renderers}get initialized(){return this._builded}initialize(){return this.initialized||(this.renderer("mail",(t,e)=>{e&&new m(`<a href="mailto:${e}">${e}</a>`).appendTo(t)}),this.renderer("tel",(t,e)=>{e&&new m(`<a href="tel:${e}">${e}</a>`).appendTo(t)}),this.renderer("url",(t,e)=>{e&&new m(`<a href="${e}" target="_blank">${e}</a>`).appendTo(t)}),this.renderer("number",(t,e)=>{if(null!=e){const n=t.attribute("data-cotomy-currency")||t.closest("[data-cotomy-currency]")?.attribute("data-cotomy-currency"),r=t.attribute("data-cotomy-fraction-digits")||t.closest("[data-cotomy-fraction-digits]")?.attribute("data-cotomy-fraction-digits"),i=r?Number.parseInt(r,10):void 0,s={...n?{style:"currency",currency:n}:{},...Number.isFinite(i)&&i&&i>=0&&i<=20?{minimumFractionDigits:i,maximumFractionDigits:i}:{}};t.text=new Intl.NumberFormat(this.locale,s).format(e)}}),this.renderer("utc",(t,e)=>{if(e){const n=/[+-]\d{2}:\d{2}$/.test(e)?new Date(e):new Date(`${e}Z`);if(!isNaN(n.getTime())){const e=t.attribute("data-cotomy-format")??"YYYY/MM/DD HH:mm";t.text=s()(n).format(e)}}}),this.renderer("date",(t,e)=>{if(e){const n=new Date(e);if(!isNaN(n.getTime())){const e=t.attribute("data-cotomy-format")??"YYYY/MM/DD";t.text=s()(n).format(e)}}}),this._builded=!0),this}bindPrimitiveValue(t,n){this.element.find(`[data-cotomy-bind="${t}" i]`).forEach(r=>{o.isEnabled(e.Bind)&&console.debug(`Binding data to element [data-cotomy-bind="${t}"]:`,n);const i=r.attribute("data-cotomy-bindtype")?.toLowerCase();i&&this.renderers[i]?this.renderers[i](r,n):r.text=String(n??"")})}async applyArrayAsync(t,e){for(let n=0;n<t.length;n++){const r=t[n],i=this.bindNameGenerator.createIndex(e,n);Array.isArray(r)?await this.applyArrayAsync(r,i):r&&"object"==typeof r?await this.applyObjectAsync(r,i):this.bindPrimitiveValue(i,r)}}async applyObjectAsync(t,e=void 0){e||this.element.find("[data-cotomy-bind]").forEach(t=>t.clear());for(const[n,r]of Object.entries(await t)){const t=this.bindNameGenerator.create(n,e);Array.isArray(r)?await this.applyArrayAsync(r,t):r&&"object"==typeof r?await this.applyObjectAsync(r,t):this.bindPrimitiveValue(t,r)}}async applyAsync(t){if(!t.available)throw new Error("Response is not available.");return await this.applyObjectAsync(await t.objectAsync()),this}}class L{constructor(t={baseUrl:null,headers:null,credentials:null,redirect:null,cache:null,referrerPolicy:null,mode:null,keepalive:!0,integrity:""}){this._options=t,this._abortController=new AbortController}get baseUrl(){return this._options.baseUrl||""}get headers(){return this._options.headers||{}}get credentials(){return this._options.credentials||"same-origin"}get redirect(){return this._options.redirect||"follow"}get cache(){return this._options.cache||"no-cache"}get referrerPolicy(){return this._options.referrerPolicy||"no-referrer"}get mode(){return this._options.mode||"cors"}get keepalive(){return this._options.keepalive||!0}get integrity(){return this._options.integrity||""}get abortController(){return this._abortController}async requestAsync(n,r,i,s,a){o.isEnabled(e.Api)&&console.debug(`API request: ${n} ${r}`,{body:i,headers:this.headers});const l={"application/json":t=>JSON.stringify(t),"application/x-www-form-urlencoded":t=>{if(t instanceof globalThis.FormData){let e=new URLSearchParams;return t.forEach((t,n)=>{e.append(n,String(t))}),e.toString()}return new URLSearchParams(t).toString()},"multipart/form-data":t=>{if(t instanceof globalThis.FormData)return t;const e=new globalThis.FormData;for(const[n,r]of Object.entries(t))e.append(n,String(r));return e}},c=/^[a-zA-Z]/.test(r)?r:`${(this.baseUrl||"").replace(/\/$/,"")}/${r.replace(/^\//,"")}`,u=new Headers(this.headers);u.has("Content-Type")&&"multipart/form-data"===u.get("Content-Type")&&u.delete("Content-Type");const h=u.get("Content-Type")||"multipart/form-data";if("multipart/form-data"===h&&i&&!(i instanceof globalThis.FormData)&&("object"!=typeof i||Array.isArray(i)))throw new I("Body must be FormData or a plain object when using multipart/form-data.");const d=new(a??C)(await fetch(c,{method:n,headers:u,credentials:this.credentials,body:i?l[h]?l[h](i):i:void 0,signal:s??this._abortController.signal,redirect:this.redirect,cache:this.cache,referrerPolicy:this.referrerPolicy,mode:this.mode,keepalive:this.keepalive,integrity:this.integrity}));if(o.isEnabled(e.Api)&&console.debug(`response body: ${d.status} ${d.statusText}`,await d.textAsync()),d.status>=400&&d.status<600){const n=await d.textAsync().catch(()=>"No response body available"),r=d.statusText||N.getMessage(d.status)||`Unexpected error: ${d.status}`;switch(o.isEnabled(e.Api)&&console.error(`API request failed: ${r}`,d,n),d.status){case t.BAD_REQUEST:case t.UNPROCESSABLE_ENTITY:throw new _(d.status,r,d,n);case t.UNAUTHORIZED:throw new E(d.status,r,d,n);case t.FORBIDDEN:throw new T(d.status,r,d,n);case t.NOT_FOUND:throw new v(d.status,r,d,n);case t.CONFLICT:case t.GONE:throw new b(d.status,r,d,n);case t.TOO_MANY_REQUESTS:throw new A(d.status,r,d,n);default:throw d.status<500?new p(d.status,r,d,n):new w(d.status,r,d,n)}}return d}async getAsync(t,n){let r="";if(n instanceof globalThis.FormData){let t=new URLSearchParams;n.forEach((e,n)=>{t.append(n,String(e))}),r=t.toString()}else n&&(r=new URLSearchParams(Object.fromEntries(Object.entries(n).map(([t,e])=>[t,String(e)]))).toString());const i=r?`${t}?${r}`:t;return o.isEnabled(e.Api)&&console.debug(`GET request to: ${i}`),this.requestAsync(S.GET,i)}async postAsync(t,e){return this.requestAsync(S.POST,t,e)}async putAsync(t,e){return this.requestAsync(S.PUT,t,e)}async patchAsync(t,e){return this.requestAsync(S.PATCH,t,e)}async deleteAsync(t){return this.requestAsync(S.DELETE,t)}async headAsync(t){return this.requestAsync(S.HEAD,t)}async optionsAsync(t){return this.requestAsync(S.OPTIONS,t)}async traceAsync(t){return this.requestAsync(S.TRACE,t)}async connectAsync(t){return this.requestAsync(S.CONNECT,t)}async submitAsync(t){return t.method.toUpperCase()===S.GET?this.getAsync(t.action,t.body):this.requestAsync(t.method.toUpperCase(),t.action,t.body)}}class U extends m{generateId(t="__cotomy_form__"){return super.generateId(t)}get method(){return this.attribute("method")??"get"}get actionUrl(){return this.attribute("action")??location.pathname+location.search}async reloadAsync(){g.instance.reload()}get autoReload(){return"false"!==this.attribute("data-cotomy-autoreload")}set autoReload(t){t?this.attribute("data-cotomy-autoreload",null):this.attribute("data-cotomy-autoreload","false")}get initialized(){return this.hasAttribute("data-cotomy-initialized")}initialize(){return this.initialized||(this.on("submit",async t=>{t.preventDefault(),t.stopPropagation(),await this.submitAsync()}),this.attribute("data-cotomy-initialized","")),this}}class M extends U{get method(){return"get"}async submitAsync(){const t=this.actionUrl,e={},n=t.split("?")[1];n&&n.split("&").forEach(t=>{const[n,r]=t.split("=");n&&r&&(e[n]=decodeURIComponent(r))}),this.find("[name]").forEach(t=>{const n=t.attribute("name");if(n){const r=t.value;r?e[n]=encodeURIComponent(r):delete e[n]}});const r=Object.entries(e).map(([t,e])=>`${t}=${e}`).join("&");location.href=`${t.split("?")[0]}?${r}`}}class P extends Event{constructor(t,e="cotomy:apifailed"){super(e,{bubbles:!0,cancelable:!0}),this._response=t}get response(){return this._response}}class x extends U{apiClient(){return new L}get actionUrl(){return this.attribute("action")}apiFailed(t){return this.on("cotomy:apifailed",async e=>{await t(e)}),this}triggerApiFailedEvent(t){this.trigger("cotomy:apifailed",new P(t)),o.isEnabled(e.Api)&&console.error("API request failed:",t)}submitFailed(t){return this.on("cotomy:submitfailed",async e=>{await t(e)}),this}triggerSubmitFailedEvent(t){this.trigger("cotomy:submitfailed",new P(t,"cotomy:submitfailed")),o.isEnabled(e.Api)&&console.error("Submit failed:",t)}get method(){return this.attribute("method")??"post"}formData(){const t=this.element,n=new FormData(t);return this.find("input[type=datetime-local][name]:not([disabled])").forEach(t=>{const e=t.value;if(e){const r=new Date(e);isNaN(r.getTime())||n.set(t.attribute("name"),s()(r).format("YYYY-MM-DDTHH:mmZ"))}}),o.isEnabled(e.FormData)&&console.debug("FormData:",Array.from(n.entries())),n}async submitAsync(){const t=this.formData();await this.submitToApiAsync(t)}async submitToApiAsync(t){const e=this.apiClient();try{return await e.submitAsync({method:this.method,action:this.actionUrl,body:t})}catch(t){throw t instanceof y&&(this.triggerApiFailedEvent(t.response),this.triggerSubmitFailedEvent(t.response)),t}}}class F extends x{get entityKey(){return this.attribute("data-cotomy-entity-key")||void 0}get requiresEntityKey(){return"false"!==this.attribute("data-cotomy-identify")}get hasEntityKey(){return!!this.entityKey}get actionUrl(){const t=this.attribute("action"),e=t.replace(/\/+$/,"");return this.entityKey?`${e}/${encodeURIComponent(this.entityKey)}`:t.endsWith("/")?t:`${e}/`}get method(){return this.hasAttribute("method")&&""!==this.attribute("method")?this.attribute("method"):this.hasEntityKey?"put":"post"}setEntityKey(n){if(this.requiresEntityKey&&n.status===t.CREATED){if(this.hasEntityKey)return void(o.isEnabled(e.FormLoad)&&console.warn("Entity key already exists, but server responded with 201 Created. Possible duplicate POST."));const t=n.headers.get("Location");if(!t)return;const r=t=>{const e=t.replace(/[?#].*$/,"");return e.endsWith("/")?e.slice(0,-1):e},i=e=>{try{return new URL(e,t).pathname}catch{return e}},s=r(i(this.attribute("action"))),a=r(i(t)),l=s.split("/"),c=a.split("/");if(!(c.length>=l.length&&l.every((t,e)=>t===c[e])))throw new Error(`Location path does not start with action path. action="${s}", location="${a}"`);const u=c.slice(l.length).filter(Boolean);if(1!==u.length||!u[0]){const t=`Location does not contain a single entity key segment.\n action="${s}", location="${a}", added=["${u.join('","')}"]`;throw new Error(t)}this.attribute("data-cotomy-entity-key",u[0])}}async submitToApiAsync(e){const n=await super.submitToApiAsync(e);return this.requiresEntityKey&&n.status===t.CREATED&&this.setEntityKey(n),n}}class H extends F{constructor(){super(...arguments),this._fillers={}}filler(t,e){return this._fillers[t]=e,this}initialize(){return this.initialized||(super.initialize(),this.filler("datetime-local",(t,e)=>{const n=/[+-]\d{2}:\d{2}$/.test(e)?new Date(e):new Date(`${e}Z`);isNaN(n.getTime())?t.value="":t.value=s()(n).format("YYYY-MM-DDTHH:mm")}),this.filler("checkbox",(t,e)=>{t.attribute("checked",null),e&&t.attribute("checked","")}),this.filler("radio",(t,e)=>{t.attribute("checked",null),t.value===e&&t.attribute("checked","")}),g.instance.ready(async()=>{await this.loadAsync()})),this}async reloadAsync(){await this.loadAsync()}loadActionUrl(){return this.actionUrl}bindNameGenerator(){return new R}renderer(){return new $(this,this.bindNameGenerator())}canLoad(){return this.hasEntityKey}async loadAsync(){if(!this.canLoad())return new C;const t=this.apiClient();try{const e=await t.getAsync(this.loadActionUrl());return await this.fillAsync(e),e}catch(t){if(t instanceof y&&this.triggerApiFailedEvent(t.response),t instanceof v)return t.response;throw t}}applyValueToInputs(t,n){this.find(`input[name="${t}" i]:not([data-cotomy-fill="false"]):not([multiple]),\n textarea[name="${t}" i]:not([data-cotomy-fill="false"]), \n select[name="${t}" i]:not([data-cotomy-fill="false"]):not([multiple])`).forEach(r=>{o.isEnabled(e.Fill)&&console.debug(`Filling input[name="${t}"] with value:`,n);const i=r.attribute("type")?.toLowerCase();i&&this._fillers[i]?this._fillers[i](r,n):r.value=String(n||"")})}async fillArrayAsync(t,e,n){for(let r=0;r<e.length;r++){const i=e[r],s=t.createIndex(n,r);Array.isArray(i)?await this.fillArrayAsync(t,i,s):i&&"object"==typeof i?await this.fillObjectAsync(t,i,s):this.applyValueToInputs(s,i)}}async fillObjectAsync(t,e,n=void 0){for(const[r,i]of Object.entries(e)){if(r.endsWith("[]"))continue;const e=t.create(r,n);Array.isArray(i)?await this.fillArrayAsync(t,i,e):i&&"object"==typeof i?await this.fillObjectAsync(t,i,e):this.applyValueToInputs(e,i)}}async fillAsync(t){t.ok&&t.available&&(await this.fillObjectAsync(this.bindNameGenerator(),await t.objectAsync()),await this.renderer().applyAsync(t)),this.find("textarea").forEach(t=>t.input())}async submitToApiAsync(t){const e=await super.submitToApiAsync(t);return e.ok&&await this.fillAsync(e),e}}var Y=n(569),B=n.n(Y),q=n(826),k=n.n(q);s().extend(k()),s().extend(B());class z{static location(){return new z}constructor(t=null){this._url=new URL(t??location.pathname+location.search,location.origin)}get url(){return this._url.pathname+this._url.search}get path(){return this._url.pathname}get segments(){return this._url.pathname.split("/").filter(t=>t.length>0)}get query(){return this._url.search.replace(/^\?/,"")}get parameters(){const t={};return this._url.searchParams.forEach((e,n)=>{t[n]=e}),t}redirect(){window.location.href=this.url}replace(){window.location.replace(this.url)}replaceState(t=null,e=""){window.history.replaceState(t,e,this.url)}}class W{constructor(){this._forms={}}static set(t){if(this._instance)throw new Error("PageController is already initialized.");return this._instance=new t,g.instance.load(async()=>{o.isEnabled(e.Page)&&console.debug("CotomyPageController initialize."),g.instance.initialize(),await W._instance.initializeAsync(),g.instance.trigger("cotomy:ready")}),this._instance}static get(){if(!(this._instance instanceof W))throw new Error("PageController is not initialized. Use CotomyPageController.set() to initialize it.");return this._instance}setForm(t){return t.id||t.generateId(),this._forms[t.id]=t,t.removed(()=>{delete this._forms[t.id]}),t.initialize()}getForm(t,e){const n=this._forms[t];if(n){if(e&&!(n instanceof e))throw new Error(`Form "${t}" is not instance of expected type.`);return n}}forms(){return Object.values(this._forms)}async restoreAsync(){for(const t of this.forms()){if(g.instance.reloading)break;t.autoReload&&await t.reloadAsync()}}isValidUtcDateString(t){return s()(t).isValid()&&(t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t))}initializeDateTimeElements(){g.instance.body.find("[data-cotomy-datetime]:not([data-cotomy-formatted])").forEach(t=>{if(s()(t.text).isValid()){const e=t.attribute("data-cotomy-timezone")||t.closest("[data-cotomy-timezone]")?.attribute("data-cotomy-timezone"),n=t.attribute("data-cotomy-format")??"YYYY-MM-DD HH:mm",r=this.isValidUtcDateString(t.text)?s()(t.text):s()(`${s()(t.text).format("YYYY-MM-DDTHH:mm:ss")}Z`),i="local"===t.attribute("data-cotomy-datetime")?r:r.utc();t.text=e&&""!==e.trim()?i.tz(e).format(n):i.format(n),t.attribute("data-cotomy-formatted","")}})}async initializeAsync(){this.initializeDateTimeElements(),g.instance.pageshow(async t=>{t.persisted&&(await this.restoreAsync(),g.instance.reloading&&t.stopImmediatePropagation())})}get body(){return g.instance.body}get url(){return new z}}W._instance=null})(),r})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cotomy=e():t.Cotomy=e()}(this,()=>(()=>{var t={48:t=>{var e,n="undefined"!=typeof window&&(window.crypto||window.msCrypto)||"undefined"!=typeof self&&self.crypto;if(n){var r=Math.pow(2,32)-1;e=function(){return Math.abs(n.getRandomValues(new Uint32Array(1))[0]/r)}}else e=Math.random;t.exports=e},146:(t,e,n)=>{var r=n(473),i="object"==typeof window?window:self,s=Object.keys(i).length,o=r(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+s.toString(36),4);t.exports=function(){return o}},353:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,n="millisecond",r="second",i="minute",s="hour",o="day",a="week",l="month",c="quarter",u="year",h="date",d="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},y=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},p={s:y,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+y(r,2,"0")+":"+y(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,l),s=n-i<0,o=e.clone().add(r+(s?-1:1),l);return+(-(r+(n-i)/(s?i-o:o-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:l,y:u,w:a,d:o,D:h,h:s,m:i,s:r,ms:n,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},E="en",T={};T[E]=g;var v="$isDayjsObject",b=function(t){return t instanceof O||!(!t||!t[v])},_=function t(e,n,r){var i;if(!e)return E;if("string"==typeof e){var s=e.toLowerCase();T[s]&&(i=s),n&&(T[s]=n,i=s);var o=e.split("-");if(!i&&o.length>1)return t(o[0])}else{var a=e.name;T[a]=e,i=a}return!r&&i&&(E=i),i||!r&&E},A=function(t,e){if(b(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new O(n)},w=p;w.l=_,w.i=b,w.w=function(t,e){return A(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var O=function(){function g(t){this.$L=_(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[v]=!0}var y=g.prototype;return y.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(w.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(m);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},y.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},y.$utils=function(){return w},y.isValid=function(){return!(this.$d.toString()===d)},y.isSame=function(t,e){var n=A(t);return this.startOf(e)<=n&&n<=this.endOf(e)},y.isAfter=function(t,e){return A(t)<this.startOf(e)},y.isBefore=function(t,e){return this.endOf(e)<A(t)},y.$g=function(t,e,n){return w.u(t)?this[e]:this.set(n,t)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(t,e){var n=this,c=!!w.u(e)||e,d=w.p(t),m=function(t,e){var r=w.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return c?r:r.endOf(o)},f=function(t,e){return w.w(n.toDate()[t].apply(n.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},g=this.$W,y=this.$M,p=this.$D,E="set"+(this.$u?"UTC":"");switch(d){case u:return c?m(1,0):m(31,11);case l:return c?m(1,y):m(0,y+1);case a:var T=this.$locale().weekStart||0,v=(g<T?g+7:g)-T;return m(c?p-v:p+(6-v),y);case o:case h:return f(E+"Hours",0);case s:return f(E+"Minutes",1);case i:return f(E+"Seconds",2);case r:return f(E+"Milliseconds",3);default:return this.clone()}},y.endOf=function(t){return this.startOf(t,!1)},y.$set=function(t,e){var a,c=w.p(t),d="set"+(this.$u?"UTC":""),m=(a={},a[o]=d+"Date",a[h]=d+"Date",a[l]=d+"Month",a[u]=d+"FullYear",a[s]=d+"Hours",a[i]=d+"Minutes",a[r]=d+"Seconds",a[n]=d+"Milliseconds",a)[c],f=c===o?this.$D+(e-this.$W):e;if(c===l||c===u){var g=this.clone().set(h,1);g.$d[m](f),g.init(),this.$d=g.set(h,Math.min(this.$D,g.daysInMonth())).$d}else m&&this.$d[m](f);return this.init(),this},y.set=function(t,e){return this.clone().$set(t,e)},y.get=function(t){return this[w.p(t)]()},y.add=function(n,c){var h,d=this;n=Number(n);var m=w.p(c),f=function(t){var e=A(d);return w.w(e.date(e.date()+Math.round(t*n)),d)};if(m===l)return this.set(l,this.$M+n);if(m===u)return this.set(u,this.$y+n);if(m===o)return f(1);if(m===a)return f(7);var g=(h={},h[i]=t,h[s]=e,h[r]=1e3,h)[m]||1,y=this.$d.getTime()+n*g;return w.w(y,this)},y.subtract=function(t,e){return this.add(-1*t,e)},y.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||d;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=w.z(this),s=this.$H,o=this.$m,a=this.$M,l=n.weekdays,c=n.months,u=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},m=function(t){return w.s(s%12||12,t,"0")},g=u||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(f,function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return w.s(e.$y,4,"0");case"M":return a+1;case"MM":return w.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return w.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,l,2);case"ddd":return h(n.weekdaysShort,e.$W,l,3);case"dddd":return l[e.$W];case"H":return String(s);case"HH":return w.s(s,2,"0");case"h":return m(1);case"hh":return m(2);case"a":return g(s,o,!0);case"A":return g(s,o,!1);case"m":return String(o);case"mm":return w.s(o,2,"0");case"s":return String(e.$s);case"ss":return w.s(e.$s,2,"0");case"SSS":return w.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")})},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(n,h,d){var m,f=this,g=w.p(h),y=A(n),p=(y.utcOffset()-this.utcOffset())*t,E=this-y,T=function(){return w.m(f,y)};switch(g){case u:m=T()/12;break;case l:m=T();break;case c:m=T()/3;break;case a:m=(E-p)/6048e5;break;case o:m=(E-p)/864e5;break;case s:m=E/e;break;case i:m=E/t;break;case r:m=E/1e3;break;default:m=E}return d?m:w.a(m)},y.daysInMonth=function(){return this.endOf(l).$D},y.$locale=function(){return T[this.$L]},y.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=_(t,e,!0);return r&&(n.$L=r),n},y.clone=function(){return w.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},g}(),S=O.prototype;return A.prototype=S,[["$ms",n],["$s",r],["$m",i],["$H",s],["$W",o],["$M",l],["$y",u],["$D",h]].forEach(function(t){S[t[1]]=function(e){return this.$g(e,t[0],t[1])}}),A.extend=function(t,e){return t.$i||(t(e,O,A),t.$i=!0),A},A.locale=_,A.isDayjs=b,A.unix=function(t){return A(1e3*t)},A.en=T[E],A.Ls=T,A.p={},A}()},473:t=>{t.exports=function(t,e){var n="000000000"+t;return n.substr(n.length-e)}},569:function(t){t.exports=function(){"use strict";var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,r,i){var s,o=function(t,n,r){void 0===r&&(r={});var i=new Date(t),s=function(t,n){void 0===n&&(n={});var r=n.timeZoneName||"short",i=t+"|"+r,s=e[i];return s||(s=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:r}),e[i]=s),s}(n,r);return s.formatToParts(i)},a=function(e,n){for(var r=o(e,n),s=[],a=0;a<r.length;a+=1){var l=r[a],c=l.type,u=l.value,h=t[c];h>=0&&(s[h]=parseInt(u,10))}var d=s[3],m=24===d?0:d,f=s[0]+"-"+s[1]+"-"+s[2]+" "+m+":"+s[4]+":"+s[5]+":000",g=+e;return(i.utc(f).valueOf()-(g-=g%1e3))/6e4},l=r.prototype;l.tz=function(t,e){void 0===t&&(t=s);var n,r=this.utcOffset(),o=this.toDate(),a=o.toLocaleString("en-US",{timeZone:t}),l=Math.round((o-new Date(a))/1e3/60),c=15*-Math.round(o.getTimezoneOffset()/15)-l;if(Number(c)){if(n=i(a,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(c,!0),e){var u=n.utcOffset();n=n.add(r-u,"minute")}}else n=this.utcOffset(0,e);return n.$x.$timezone=t,n},l.offsetName=function(t){var e=this.$x.$timezone||i.tz.guess(),n=o(this.valueOf(),e,{timeZoneName:t}).find(function(t){return"timezonename"===t.type.toLowerCase()});return n&&n.value};var c=l.startOf;l.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return c.call(this,t,e);var n=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return c.call(n,t,e).tz(this.$x.$timezone,!0)},i.tz=function(t,e,n){var r=n&&e,o=n||e||s,l=a(+i(),o);if("string"!=typeof t)return i(t).tz(o);var c=function(t,e,n){var r=t-60*e*1e3,i=a(r,n);if(e===i)return[r,e];var s=a(r-=60*(i-e)*1e3,n);return i===s?[r,i]:[t-60*Math.min(i,s)*1e3,Math.max(i,s)]}(i.utc(t,r).valueOf(),l,o),u=c[0],h=c[1],d=i(u).utcOffset(h);return d.$x.$timezone=o,d},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(t){s=t}}}()},584:(t,e,n)=>{var r=n(146),i=n(473),s=n(48),o=0,a=Math.pow(36,4);function l(){return i((s()*a|0).toString(36),4)}function c(){return o=o<a?o:0,++o-1}function u(){return"c"+(new Date).getTime().toString(36)+i(c().toString(36),4)+r()+(l()+l())}u.slug=function(){var t=(new Date).getTime().toString(36),e=c().toString(36).slice(-4),n=r().slice(0,1)+r().slice(-1),i=l().slice(-2);return t.slice(-2)+e+n+i},u.isCuid=function(t){return"string"==typeof t&&!!t.startsWith("c")},u.isSlug=function(t){if("string"!=typeof t)return!1;var e=t.length;return e>=7&&e<=10},u.fingerprint=r,t.exports=u},826:function(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,i,s){var o=i.prototype;s.utc=function(t){return new i({date:t,utc:!0,args:arguments})},o.utc=function(e){var n=s(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},o.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=o.parse;o.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),a.call(this,t)};var l=o.init;o.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else l.call(this)};var c=o.utcOffset;o.utcOffset=function(r,i){var s=this.$utils().u;if(s(r))return this.$u?0:s(this.$offset)?c.call(this):this.$offset;if("string"==typeof r&&(r=function(t){void 0===t&&(t="");var r=t.match(e);if(!r)return null;var i=(""+r[0]).match(n)||["-",0,0],s=i[0],o=60*+i[1]+ +i[2];return 0===o?0:"+"===s?o:-o}(r),null===r))return this;var o=Math.abs(r)<=16?60*r:r,a=this;if(i)return a.$offset=o,a.$u=0===r,a;if(0!==r){var l=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(o+l,t)).$offset=o,a.$x.$localOffset=l}else a=this.utc();return a};var u=o.format;o.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return u.call(this,e)},o.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var h=o.toDate;o.toDate=function(t){return"s"===t&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=o.diff;o.diff=function(t,e,n){if(t&&this.$u===t.$u)return d.call(this,t,e,n);var r=this.local(),i=s(t).local();return d.call(r,i,e,n)}}}()}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{CotomyApi:()=>L,CotomyApiException:()=>y,CotomyApiFailedEvent:()=>P,CotomyApiForm:()=>x,CotomyApiResponse:()=>N,CotomyBracketBindNameGenerator:()=>R,CotomyConflictException:()=>b,CotomyDebugFeature:()=>e,CotomyDebugSettings:()=>o,CotomyDotBindNameGenerator:()=>D,CotomyElement:()=>m,CotomyEntityApiForm:()=>F,CotomyEntityFillApiForm:()=>H,CotomyForbiddenException:()=>T,CotomyForm:()=>U,CotomyHttpClientError:()=>p,CotomyHttpServerError:()=>w,CotomyInvalidFormDataBodyException:()=>S,CotomyMetaElement:()=>f,CotomyNotFoundException:()=>v,CotomyPageController:()=>W,CotomyQueryForm:()=>M,CotomyRequestInvalidException:()=>_,CotomyResponseJsonParseException:()=>O,CotomyTooManyRequestsException:()=>A,CotomyUnauthorizedException:()=>E,CotomyUrl:()=>z,CotomyViewRenderer:()=>$,CotomyWindow:()=>g});var t,e,i=n(353),s=n.n(i);!function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLY_HINTS=103]="EARLY_HINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",t[t.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.IM_A_TEAPOT=418]="IM_A_TEAPOT",t[t.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",t[t.METHOD_FAILURE=420]="METHOD_FAILURE",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"}(t||(t={})),function(t){t.Api="api",t.Fill="fill",t.Bind="bind",t.FormData="formdata",t.Html="html",t.Page="page",t.FormLoad="formload"}(e||(e={}));class o{static isEnabled(t){const e=localStorage.getItem(this.PREFIX);return t&&"true"===localStorage.getItem(`${this.PREFIX}:${String(t)}`)||"true"===e}static enable(t){localStorage.setItem(`${this.PREFIX}:${String(t)}`,"true")}static disable(t){localStorage.setItem(`${this.PREFIX}:${String(t)}`,"false")}static enableAll(){localStorage.setItem(this.PREFIX,"true")}static disableAll(){localStorage.setItem(this.PREFIX,"false")}static clear(t){t?localStorage.removeItem(`${this.PREFIX}:${String(t)}`):localStorage.removeItem(this.PREFIX)}}o.PREFIX="cotomy:debug";var a=n(584),l=n.n(a);class c{constructor(t,e,n){this.handle=t,this.wrapper=e,this.options=n}get current(){return this.wrapper??this.handle}equals(t,e,n,r){let i,s,o,a="strict";return t instanceof c?(i=t.handle,s=t.wrapper,o=t.options,a=e??"strict"):(i=t,"string"==typeof e?(a=e,s=n,o=void 0):(o=e,s=n,a=r??"strict")),this.handle===i&&("strict"!==a||this.wrapper===s)&&c.optionsEquals(this.options,o)}static optionsEquals(t,e){const n=(t,e)=>t?.[e]??!1,r=t=>t?.signal,i=r(t)===r(e);return n(t,"capture")===n(e,"capture")&&n(t,"once")===n(e,"once")&&n(t,"passive")===n(e,"passive")&&i}}class u{constructor(t){this.target=t,this._registory=new Map}ensure(t){return this._registory.get(t)??this._registory.set(t,[]).get(t)}find(t,e){return this._registory.get(t)?.find(t=>t.equals(e))??void 0}add(t,e){e.options?.once&&this.remove(t,e),this.find(t,e)||(this.ensure(t).push(e),this.target.element.addEventListener(t,e.current,e.options))}remove(t,e){if(!e){const e=this._registory.get(t);if(!e)return;return e.forEach(e=>this.target.element.removeEventListener(t,e.current,e.options?.capture??!1)),void this._registory.delete(t)}const n=this._registory.get(t);if(n){const r=[];for(const i of n)i.equals(e,"remove")?this.target.element.removeEventListener(t,i.current,i.options?.capture??!1):r.push(i);0===r.length?this._registory.delete(t):this._registory.set(t,r)}}get empty(){return 0===this._registory.size}}class h{constructor(){this._registry=new Map}static get instance(){return this._instance??(this._instance=new h)}map(t){const e=t.instanceId;let n=this._registry.get(e);return n||(n=new u(t),this._registry.set(e,n)),n}on(t,e,n){this.map(e).add(t,n)}off(t,e,n){const r=this._registry.get(e.instanceId);r&&(n?r.remove(t,n):r.remove(t),r.empty&&this._registry.delete(e.instanceId))}clear(t){this._registry.delete(t.instanceId)}}class d{constructor(t={}){this.behavior="smooth",this.onlyIfNeeded=!0,this.block="nearest",this.inline="nearest",void 0!==t.behavior&&(this.behavior=t.behavior),void 0!==t.onlyIfNeeded&&(this.onlyIfNeeded=t.onlyIfNeeded),void 0!==t.block&&(this.block=t.block),void 0!==t.inline&&(this.inline=t.inline)}resolveBehavior(){return this.behavior}static from(t){return t instanceof d?t:new d(t??{})}}class m{static encodeHtml(t){const e=document.createElement("div");return e.textContent=t??"",e.innerHTML}static createHTMLElement(t){const e=t.match(/<\s*([a-z0-9]+)/i);if(!e)throw new Error(`Invalid HTML: cannot extract tag from "${t}"`);const n=e[1].toLowerCase(),r={tr:{prefix:"<table><tbody>",suffix:"</tbody></table>"},td:{prefix:"<table><tbody><tr>",suffix:"</tr></tbody></table>"},th:{prefix:"<table><tbody><tr>",suffix:"</tr></tbody></table>"},thead:{prefix:"<table>",suffix:"</table>"},tbody:{prefix:"<table>",suffix:"</table>"},tfoot:{prefix:"<table>",suffix:"</table>"},caption:{prefix:"<table>",suffix:"</table>"},colgroup:{prefix:"<table>",suffix:"</table>"},col:{prefix:"<table><colgroup>",suffix:"</colgroup></table>"},option:{prefix:"<select>",suffix:"</select>"},optgroup:{prefix:"<select>",suffix:"</select>"},legend:{prefix:"<fieldset>",suffix:"</fieldset>"},li:{prefix:"<ul>",suffix:"</ul>"}}[n],i=r?`${r.prefix}${t}${r.suffix}`:t,s=(new DOMParser).parseFromString(i,"text/html");if(s.querySelector("parsererror"))throw new Error(`HTML parsing failed for tag <${n}>: "${t}"`);if(1!==s.body.children.length)throw new Error(`CotomyElement requires a single root element, but got ${s.body.children.length}.`);const o=s.body.querySelector(n);if(!o)throw new Error(`Parsed but <${n}> element not found: "${t}"`);return o}static first(t,e){const n=document.querySelector(t);if(n)return new(e??m)(n)}static last(t,e){return m.find(t,e).pop()}static find(t,e){const n=document.querySelectorAll(t),r=e??m;return Array.from(n).map(t=>new r(t))}static contains(t){return null!==document.querySelector(t)}static byId(t,e){const n=document.getElementById(t);return n?new(e??m)(n):void 0}static containsById(t){return null!==document.getElementById(t)}static empty(t){return new(t??m)(document.createElement("div")).attribute("data-cotomy-empty","").style("display","none")}constructor(t){this._parentElement=null,t instanceof HTMLElement?this._element=t:"string"==typeof t?this._element=m.createHTMLElement(t):(this._element=m.createHTMLElement("html"in t?t.html:`<${t.tagname}></${t.tagname}>`),"tagname"in t&&t.text&&(this._element.textContent=t.text),t.css&&this.useScopedCss(t.css),o.isEnabled(e.Html)&&("html"in t&&console.debug(`CotomyElement {html: "${t.html}" } is created`),"tagname"in t&&console.debug(`CotomyElement {tagname: "${t.tagname}", text: "${t.text??""}"} is created`),t.css&&console.debug(`CotomyElement {css: "${t.css}" } is applied`))),this.setInstanceId()}setInstanceId(){this.hasAttribute("data-cotomy-instance")||(this.attribute("data-cotomy-instance",l()()),this.removed(()=>{this._element=m.createHTMLElement('<div data-cotomy-invalidated style="display: none;"></div>'),h.instance.clear(this)}),this.on("cotomy:transitstart",()=>{this.attribute("data-cotomy-moving",""),this.find("[data-cotomy-instance]").forEach(t=>t.attribute("data-cotomy-moving",""))}),this.on("cotomy:transitend",()=>{this.attribute("data-cotomy-moving",null),this.find("[data-cotomy-instance]").forEach(t=>t.attribute("data-cotomy-moving",null))}))}get instanceId(){return this.attribute("data-cotomy-instance")}get scopeId(){return this.hasAttribute("data-cotomy-scopeid")||this.attribute("data-cotomy-scopeid",l()()),this.attribute("data-cotomy-scopeid")}get stylable(){return!["script","style","link","meta"].includes(this.tagname)}get scopedCssElementId(){return`css-${this.scopeId}`}useScopedCss(t){if(t&&this.stylable){this._scopedCss=t;const e=this.scopedCssElementId;m.find(`#${e}`).forEach(t=>t.remove());const n=document.createElement("style"),r=t.replace(/\[scope\]/g,`[data-cotomy-scopeid="${this.scopeId}"]`),i=document.createTextNode(r);n.appendChild(i),n.id=e,(m.first("head")||new m({html:"<head></head>"}).prependTo(new m(document.documentElement))).append(new m(n)),this.removed(()=>{null!==document.querySelector(`[data-cotomy-scopeid="${this.scopeId}"]`)||m.find(`#${e}`).forEach(t=>t.remove())})}return this}ensureScopedCss(){if(!this._scopedCss||!this.stylable)return;const t=this.scopedCssElementId;document.getElementById(t)||this.useScopedCss(this._scopedCss)}listenLayoutEvents(){return this.attribute(m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE,""),this}get id(){return this.attribute("id")}generateId(t="__cotomy_elem__"){return this.id||this.attribute("id",`${t}${l()()}`),this}get element(){return this._element}clone(t){const e=t??m,n=this.element.cloneNode(!0);if(n.hasAttribute("data-cotomy-invalidated"))throw new Error("Cannot clone an invalidated CotomyElement.");["data-cotomy-instance","data-cotomy-moving"].forEach(t=>{n.removeAttribute(t),n.querySelectorAll(`[${t}]`).forEach(e=>e.removeAttribute(t))});const r=new e(n);return r._scopedCss=this._scopedCss,r}get tagname(){return this.element.tagName.toLowerCase()}is(t){const e=t.split(/\s+(?![^\[]*\])|(?<=\>)\s+/);let n=this.element;for(let t=e.length-1;t>=0;t--){let r=e[t].trim(),i=!1;if(r.startsWith(">")&&(i=!0,r=r.slice(1).trim()),!n||!n.matches(r))return!1;if(i)n=n.parentElement;else if(t>0)for(;n&&!n.matches(e[t-1].trim());)n=n.parentElement}return!0}match(t){try{return this.element.matches(t)}catch{return!1}}get empty(){return new Set(["input","select","textarea","img","video","audio","br","hr","iframe","embed","canvas","object","svg","source","track","col","link","meta","base"]).has(this.tagname)||this._element.hasAttribute("data-cotomy-empty")||""===this._element.innerHTML.trim()}get attached(){return document.contains(this.element)}get readonly(){return"readOnly"in this.element?this.element.readOnly:this.element.hasAttribute("readonly")}set readonly(t){"readOnly"in this.element?this.element.readOnly=t:t?this.attribute("readonly","readonly"):this.attribute("readonly",null)}get value(){return"value"in this.element?this.element.value:this.attribute("data-cotomy-value")??""}set value(t){"value"in this.element?this.element.value=t:this.attribute("data-cotomy-value",t)}get text(){return this.element.textContent??""}set text(t){this.element.textContent=t??""}get html(){return this.element.innerHTML}set html(t){this.element.innerHTML=t}setFocus(){return this.element.focus(),this}get visible(){if(!this.attached)return!1;if(!this.element.offsetParent&&!document.contains(this.element))return!1;const t=this.element.getBoundingClientRect();if(t.width>0&&t.height>0){const t=this.getComputedStyle();return"none"!==t.display&&"hidden"!==t.visibility&&"collapse"!==t.visibility}return!1}get enabled(){return!(this.element.hasAttribute("disabled")&&null!==this.element.getAttribute("disabled"))}set enabled(t){t?this.element.removeAttribute("disabled"):this.element.setAttribute("disabled","disabled")}get invalidated(){return this.element.hasAttribute("data-cotomy-invalidated")}remove(){this.invalidated||this._element.remove()}clear(){return this.find("*").forEach(t=>t.remove()),this.text="",this}get width(){return this.element.offsetWidth}set width(t){let e=t.toString()+"px";this.style("width",e)}get height(){return this.element.offsetHeight}set height(t){let e=t.toString()+"px";this.style("height",e)}get innerWidth(){return this.element.clientWidth}get innerHeight(){return this.element.clientHeight}get outerWidth(){const t=this.getComputedStyle(),e=parseFloat(t.marginLeft)+parseFloat(t.marginRight);return this.element.offsetWidth+e}get outerHeight(){const t=this.getComputedStyle(),e=parseFloat(t.marginTop)+parseFloat(t.marginBottom);return this.element.offsetHeight+e}get scrollHeight(){return this.element.scrollHeight}get scrollWidth(){return this.element.scrollWidth}get scrollTop(){return this.element.scrollTop}get position(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left}}get absolutePosition(){const t=this.element.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}get screenPosition(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left}}get rect(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}get innerRect(){const t=this.element.getBoundingClientRect(),e=this.getComputedStyle(),n=parseFloat(e.paddingTop),r=parseFloat(e.paddingRight),i=parseFloat(e.paddingBottom),s=parseFloat(e.paddingLeft);return{top:t.top+n,left:t.left+s,width:t.width-s-r,height:t.height-n-i}}get outerRect(){const t=this.element.getBoundingClientRect(),e=this.getComputedStyle(),n=parseFloat(e.marginTop),r=parseFloat(e.marginRight),i=parseFloat(e.marginBottom),s=parseFloat(e.marginLeft);return{top:t.top-n,left:t.left-s,width:t.width+s+r,height:t.height+n+i}}static overlapsRect(t,e){if(t.width<=0||t.height<=0||e.width<=0||e.height<=0)return!1;const n=t.left+t.width,r=t.top+t.height,i=e.left+e.width,s=e.top+e.height;return t.left<i&&n>e.left&&t.top<s&&r>e.top}overlaps(t){return!(!this.attached||!t.attached)&&this.element!==t.element&&m.overlapsRect(this.rect,t.rect)}get overlapElements(){return this.attached?m.find("[data-cotomy-instance]").filter(t=>t.element!==this.element).filter(t=>this.overlaps(t)):[]}get padding(){const t=this.getComputedStyle();return{top:parseFloat(t.paddingTop),right:parseFloat(t.paddingRight),bottom:parseFloat(t.paddingBottom),left:parseFloat(t.paddingLeft)}}get margin(){const t=this.getComputedStyle();return{top:parseFloat(t.marginTop),right:parseFloat(t.marginRight),bottom:parseFloat(t.marginBottom),left:parseFloat(t.marginLeft)}}get inViewport(){const t=this.element.getBoundingClientRect();return t.top<window.innerHeight&&t.bottom>0}get isAboveViewport(){return this.element.getBoundingClientRect().bottom<0}get isBelowViewport(){return this.element.getBoundingClientRect().top>window.innerHeight}get isLeftViewport(){return this.element.getBoundingClientRect().right<0}get isRightViewport(){return this.element.getBoundingClientRect().left>window.innerWidth}static isScrollableOverflow(t){const e=(t??"").toLowerCase();return"auto"===e||"scroll"===e}static findNearestScrollableAncestor(t){let e=t.parentElement;for(;e;){if(e===document.body||e===document.documentElement)return null;const t=window.getComputedStyle(e),n=t.overflowY,r=t.overflowX,i=m.isScrollableOverflow(n)&&e.scrollHeight>e.clientHeight,s=m.isScrollableOverflow(r)&&e.scrollWidth>e.clientWidth;if(i||s)return e;e=e.parentElement}return null}static computeAlignedScroll(t,e,n,r,i,s){const o=t+e;return s&&n>=t&&r<=o?null:"start"===i?n:"end"===i?r-e:"center"===i?n-(e-(r-n))/2:n<t?n:r>o?r-e:null}scrollIn(t={}){if(!this.attached)return this;const e=d.from(t),n=e.resolveBehavior(),r=e.onlyIfNeeded,i=e.block,s=e.inline,o=m.findNearestScrollableAncestor(this.element);if(o){const t=this.element.getBoundingClientRect(),e=o.getBoundingClientRect(),a=t.top-e.top+o.scrollTop,l=t.bottom-e.top+o.scrollTop,c=t.left-e.left+o.scrollLeft,u=t.right-e.left+o.scrollLeft,h=m.computeAlignedScroll(o.scrollTop,o.clientHeight,a,l,i,r),d=m.computeAlignedScroll(o.scrollLeft,o.clientWidth,c,u,s,r);if(!r||null!==h||null!==d){const t=h??o.scrollTop,e=d??o.scrollLeft;o.scrollTo?.({top:t,left:e,behavior:n}),o.scrollTo||(o.scrollTop=t,o.scrollLeft=e)}return this}const a=this.element.getBoundingClientRect(),l=window.scrollY||document.documentElement.scrollTop,c=window.scrollX||document.documentElement.scrollLeft,u=l+a.top,h=l+a.bottom,f=c+a.left,g=c+a.right,y=m.computeAlignedScroll(l,window.innerHeight,u,h,i,r),p=m.computeAlignedScroll(c,window.innerWidth,f,g,s,r);return r&&null===y&&null===p||window.scrollTo({top:y??l,left:p??c,behavior:n}),this}scrollTo(t,e={}){if("string"==typeof t){const n=this.first(t);return n?.scrollIn(e),this}return t instanceof m?(t.scrollIn(e),this):(new m(t).scrollIn(e),this)}comesBefore(t){const e=this.element.compareDocumentPosition(t.element);return!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&0!==(e&Node.DOCUMENT_POSITION_FOLLOWING)}comesAfter(t){const e=this.element.compareDocumentPosition(t.element);return!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&0!==(e&Node.DOCUMENT_POSITION_PRECEDING)}hasAttribute(t){return this.element.hasAttribute(t)}attribute(t,e){return 1===arguments.length?this.element.hasAttribute(t)?this.element.getAttribute(t):void 0:null===e?(this.element.removeAttribute(t),this):(this.element.setAttribute(t,e?.toString()??""),this)}hasClass(t){return this.element.classList.contains(t)}addClass(t){return this.element.classList.add(t),this}removeClass(t){return this.element.classList.remove(t),this}toggleClass(t,e){return this.element.classList.toggle(t,e),this}style(t,e){return 1===arguments.length?this.element.style.getPropertyValue(t):null==e?(this.element.style.removeProperty(t),this):(this.element.style.setProperty(t,e),this)}getComputedStyle(){return window.getComputedStyle(this.element)}computedStyle(t){return window.getComputedStyle(this.element).getPropertyValue(t)}get parent(){return null==this._parentElement&&null!==this.element.parentElement&&(this._parentElement=new m(this.element.parentElement)),this._parentElement??m.empty()}get parents(){let t=[],e=this.element.parentElement;for(;null!==e;)t.push(new m(e)),e=e.parentElement;return t}hasChildren(t="*"){return null!==this.element.querySelector(t)}children(t="*",e){const n=Array.from(this.element.querySelectorAll(t)).filter(t=>t.parentElement===this.element),r=e??m;return n.filter(t=>t instanceof HTMLElement).map(t=>new r(t))}firstChild(t="*",e){return this.children(t,e).shift()??void 0}lastChild(t="*",e){return this.children(t,e).pop()??void 0}closest(t,e){const n=this.element.closest(t);if(null!==n&&n instanceof HTMLElement)return new(e??m)(n)}previousSibling(t="*",e){const n=this.element.previousElementSibling;if(null!==n&&n instanceof HTMLElement){const r=new(e??m)(n);return r.match(t)?r:r.previousSibling(t,e)}}nextSibling(t="*",e){const n=this.element.nextElementSibling;if(null!==n&&n instanceof HTMLElement){const r=new(e??m)(n);return r.match(t)?r:r.nextSibling(t,e)}}siblings(t="*",e){const n=this.element.parentElement;if(!n)return[];const r=e??m;return Array.from(n.children).filter(t=>t instanceof HTMLElement&&t!==this.element).map(t=>new r(t)).filter(e=>e.match(t))}find(t,e){return Array.from(this.element.querySelectorAll(t)).map(t=>new(e??m)(t))}first(t="*",e){return this.find(t,e).shift()??void 0}last(t="*",e){return this.find(t,e).pop()??void 0}contains(t){return this.find(t).length>0}static runWithMoveEvents(t,e){t.trigger("cotomy:transitstart");try{e()}finally{t.trigger("cotomy:transitend")}}prepend(t){return m.runWithMoveEvents(t,()=>{this.element.prepend(t.element)}),t.ensureScopedCss(),this}append(t){return m.runWithMoveEvents(t,()=>{this.element.append(t.element)}),t.ensureScopedCss(),this}appendAll(t){return t.forEach(t=>this.append(t)),this}insertBefore(t){return m.runWithMoveEvents(t,()=>{this.element.before(t.element)}),t.ensureScopedCss(),this}insertAfter(t){return m.runWithMoveEvents(t,()=>{this.element.after(t.element)}),t.ensureScopedCss(),this}appendTo(t){return m.runWithMoveEvents(this,()=>{t.element.append(this.element)}),this.ensureScopedCss(),this}prependTo(t){return m.runWithMoveEvents(this,()=>{t.element.prepend(this.element)}),this.ensureScopedCss(),this}trigger(t,e){return this.element.dispatchEvent(e??new Event(t,{bubbles:!0})),this}on(t,e,n){return(Array.isArray(t)?t:[t]).forEach(t=>{const r=new c(e,void 0,n);h.instance.on(t,this,r)}),this}onSubTree(t,e,n,r){const i=t=>{const r=t.target;if(r&&r.closest(e))return n(t)};return(Array.isArray(t)?t:[t]).forEach(t=>{const e=new c(n,i,r);h.instance.on(t,this,e)}),this}once(t,e,n){const r={...n??{},once:!0};return this.off(t,e,r),(Array.isArray(t)?t:[t]).forEach(t=>{const n=new c(e,void 0,r);h.instance.on(t,this,n)}),this}off(t,e,n){return(Array.isArray(t)?t:[t]).forEach(t=>{if(e){const r=new c(e,void 0,n);h.instance.off(t,this,r)}else h.instance.off(t,this)}),this}click(t){return t?this.element.addEventListener("click",async e=>await t(e)):this.trigger("click"),this}dblclick(t){return t?this.element.addEventListener("dblclick",async e=>await t(e)):this.trigger("dblclick"),this}mouseover(t){return t?this.element.addEventListener("mouseover",async e=>await t(e)):this.trigger("mouseover"),this}mouseout(t){return t?this.element.addEventListener("mouseout",async e=>await t(e)):this.trigger("mouseout"),this}mousedown(t){return t?this.element.addEventListener("mousedown",async e=>await t(e)):this.trigger("mousedown"),this}mouseup(t){return t?this.element.addEventListener("mouseup",async e=>await t(e)):this.trigger("mouseup"),this}mousemove(t){return t?this.element.addEventListener("mousemove",async e=>await t(e)):this.trigger("mousemove"),this}mouseenter(t){return t?this.element.addEventListener("mouseenter",async e=>await t(e)):this.trigger("mouseenter"),this}mouseleave(t){return t?this.element.addEventListener("mouseleave",async e=>await t(e)):this.trigger("mouseleave"),this}dragstart(t){return t?this.element.addEventListener("dragstart",async e=>await t(e)):this.trigger("dragstart"),this}dragend(t){return t?this.element.addEventListener("dragend",async e=>await t(e)):this.trigger("dragend"),this}dragover(t){return t?this.element.addEventListener("dragover",async e=>await t(e)):this.trigger("dragover"),this}dragenter(t){return t?this.element.addEventListener("dragenter",async e=>await t(e)):this.trigger("dragenter"),this}dragleave(t){return t?this.element.addEventListener("dragleave",async e=>await t(e)):this.trigger("dragleave"),this}drop(t){return t?this.element.addEventListener("drop",async e=>await t(e)):this.trigger("drop"),this}drag(t){return t?this.element.addEventListener("drag",async e=>await t(e)):this.trigger("drag"),this}removed(t){return this.element.addEventListener("removed",async e=>await t(e)),this}keydown(t){return t?this.element.addEventListener("keydown",async e=>await t(e)):this.trigger("keydown"),this}keyup(t){return t?this.element.addEventListener("keyup",async e=>await t(e)):this.trigger("keyup"),this}keypress(t){return t?this.element.addEventListener("keypress",async e=>await t(e)):this.trigger("keypress"),this}change(t){return t?this.element.addEventListener("change",async e=>await t(e)):this.trigger("change"),this}input(t){return t?this.element.addEventListener("input",async e=>await t(e)):this.trigger("input"),this}static get intersectionObserver(){return m._intersectionObserver=m._intersectionObserver??new IntersectionObserver(t=>{t.filter(t=>t.isIntersecting).forEach(t=>t.target.dispatchEvent(new Event("inview"))),t.filter(t=>!t.isIntersecting).forEach(t=>t.target.dispatchEvent(new Event("outview")))})}inview(t){return t?(m.intersectionObserver.observe(this.element),this.element.addEventListener("inview",async e=>await t(e))):this.trigger("inview"),this}outview(t){return t?(m.intersectionObserver.observe(this.element),this.element.addEventListener("outview",async e=>await t(e))):this.trigger("outview"),this}focus(t){return t?this.element.addEventListener("focus",async e=>await t(e)):this.trigger("focus"),this}blur(t){return t?this.element.addEventListener("blur",async e=>await t(e)):this.trigger("blur"),this}focusin(t){return t?this.element.addEventListener("focusin",async e=>await t(e)):this.trigger("focusin"),this}focusout(t){return t?this.element.addEventListener("focusout",async e=>await t(e)):this.trigger("focusout"),this}filedrop(t){return this.element.addEventListener("drop",async e=>{e.preventDefault();const n=e.dataTransfer;n&&n.files&&await t(Array.from(n.files))}),this}resize(t){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:resize",async e=>await t(e)):this.trigger("cotomy:resize"),this}scroll(t){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:scroll",async e=>await t(e)):this.trigger("cotomy:scroll"),this}changeLayout(t){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:changelayout",async e=>await t(e)):this.trigger("cotomy:changelayout"),this}}m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE="data-cotomy-layout",m._intersectionObserver=null;class f extends m{static get(t){return m.first(`meta[name="${t}" i]`,f)??m.empty(f)}get content(){return this.attribute("content")??""}}class g{constructor(){this._body=m.empty(),this._mutationObserver=null,this._reloading=!1,this._eventHandlers={}}static get instance(){return g._instance??(g._instance=new g)}get initialized(){return this._body.attached}initialize(){if(!this.initialized){if(!document.body)throw new Error("<body> element not found. DOM may not be ready.");this._body=m.first("body"),["resize","scroll","orientationchange","fullscreenchange","cotomy:ready"].forEach(t=>{window.addEventListener(t,()=>{const t=new CustomEvent("cotomy:changelayout");window.dispatchEvent(t)},{passive:!0})}),document.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault()}),this.resize(()=>{document.querySelectorAll(`[${m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:resize"))})}),this.scroll(()=>{document.querySelectorAll(`[${m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:scroll"))})}),this.changeLayout(()=>{document.querySelectorAll(`[${m.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:changelayout"))})}),this._mutationObserver=new MutationObserver(t=>{t.forEach(t=>{t.removedNodes.forEach(t=>{if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement){const e=new m(t);e.hasAttribute("data-cotomy-moving")||e.attached||e.trigger("removed")}})})}),this._mutationObserver.observe(this.body.element,{childList:!0,subtree:!0})}return this}get reloading(){return this._reloading}reload(){this._reloading=!0,location.reload()}get body(){return this._body}append(t){return this._body.append(t),this}moveNext(t,e=!1){const n=Array.from(this.body.element.querySelectorAll("input, a, select, button, textarea")).map(t=>new m(t)).filter(t=>t.width>0&&t.height>0&&t.visible&&t.enabled&&!t.hasAttribute("readonly"));let r=n.map(t=>t.element).indexOf(t.element)+(e?-1:1);r>=n.length?r=0:r<0&&(r=n.length-1),n[r]&&n[r].setFocus()}trigger(t,e){return window.dispatchEvent(e??new Event(t,{bubbles:!0})),this}on(t,e){return(Array.isArray(t)?t:[t]).forEach(t=>{this._eventHandlers[t]||(this._eventHandlers[t]=[]),this._eventHandlers[t].push(e),window.addEventListener(t,e)}),this}off(t,e){return(Array.isArray(t)?t:[t]).forEach(t=>{if(e){window.removeEventListener(t,e);const n=this._eventHandlers[t]?.filter(t=>t!==e)??[];n.length>0?this._eventHandlers[t]=n:delete this._eventHandlers[t]}else{for(const e of this._eventHandlers[t]??[])window.removeEventListener(t,e);delete this._eventHandlers[t]}}),this}load(t){return this.on("load",t)}ready(t){return this.on("cotomy:ready",t)}resize(t){return t?this.on("resize",t):this.trigger("resize")}scroll(t){return t?this.on("scroll",t):this.trigger("scroll")}scrollTo(t,e={}){if("string"==typeof t){const n=m.first(t);return n?.scrollIn(e),this}return t instanceof m?(t.scrollIn(e),this):(new m(t).scrollIn(e),this)}changeLayout(t){return t?this.on("cotomy:changelayout",t):this.trigger("cotomy:changelayout")}pageshow(t){return t?this.on("pageshow",t):this.trigger("pageshow")}get scrollTop(){return window.scrollY||document.documentElement.scrollTop}get scrollLeft(){return window.scrollX||document.documentElement.scrollLeft}get width(){return window.innerWidth}get height(){return window.innerHeight}get documentWidth(){return document.documentElement.scrollWidth}get documentHeight(){return document.documentElement.scrollHeight}}g._instance=null;class y extends Error{constructor(t,e,n,r=""){super(e),this.status=t,this.message=e,this.response=n,this.bodyText=r,this.name="CotomyApiException"}}class p extends y{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyHttpClientError"}}class E extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyUnauthorizedException"}}class T extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyForbiddenException"}}class v extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyNotFoundException"}}class b extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyConflictException"}}class _ extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyRequestInvalidException"}}class A extends p{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyTooManyRequestsException"}}class w extends y{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyHttpServerError"}}class O extends Error{constructor(t="Failed to parse JSON response."){super(t),this.name="CotomyResponseJsonParseException"}}class S extends Error{constructor(t="Body must be an instance of FormData."){super(t),this.name="CotomyInvalidFormDataBodyException"}}class I{}I.GET="GET",I.POST="POST",I.PUT="PUT",I.PATCH="PATCH",I.DELETE="DELETE",I.HEAD="HEAD",I.OPTIONS="OPTIONS",I.TRACE="TRACE",I.CONNECT="CONNECT";class C{static getMessage(t){return this._responseMessages[t]||`Unexpected error: ${t}`}}C._responseMessages={[t.BAD_REQUEST]:"There is an error in the input. Please check and try again.",[t.UNAUTHORIZED]:"You are not authenticated. Please log in again.",[t.FORBIDDEN]:"You do not have permission to use this feature. If necessary, please contact the administrator.",[t.NOT_FOUND]:"The specified information could not be found. It may have been deleted. Please start over or contact the administrator.",[t.METHOD_NOT_ALLOWED]:"This operation is currently prohibited on the server.",[t.NOT_ACCEPTABLE]:"The request cannot be accepted. Processing has been stopped.",[t.PROXY_AUTHENTICATION_REQUIRED]:"Proxy authentication is required for internet access.",[t.REQUEST_TIMEOUT]:"The request timed out. Please try again.",[t.CONFLICT]:"The identifier you are trying to register already exists. Please check the content and try again.",[t.PAYMENT_REQUIRED]:"Payment is required for this operation. Please check.",[t.GONE]:"The requested resource is no longer available.",[t.LENGTH_REQUIRED]:"The Content-Length header field is required for the request.",[t.PRECONDITION_FAILED]:"The request failed because the precondition was not met.",[t.UNSUPPORTED_MEDIA_TYPE]:"The requested media type is not supported.",[t.EXPECTATION_FAILED]:"The server cannot meet the Expect header of the request.",[t.MISDIRECTED_REQUEST]:"The server cannot appropriately process this request.",[t.UNPROCESSABLE_ENTITY]:"There is an error in the request content.",[t.LOCKED]:"The requested resource is locked.",[t.FAILED_DEPENDENCY]:"The request failed due to dependency on a previous failed request.",[t.UPGRADE_REQUIRED]:"A protocol upgrade is required to perform this operation.",[t.PRECONDITION_REQUIRED]:"This request requires a precondition.",[t.TOO_MANY_REQUESTS]:"Too many requests have been sent in a short time. Please wait and try again.",[t.REQUEST_HEADER_FIELDS_TOO_LARGE]:"The request headers are too large.",[t.INTERNAL_SERVER_ERROR]:"An unexpected error occurred. Please try again later.",[t.BAD_GATEWAY]:"The server is currently overloaded. Please wait and try again later.",[t.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[t.GATEWAY_TIMEOUT]:"The communication timed out. Please try again.",[t.HTTP_VERSION_NOT_SUPPORTED]:"The current communication method is not supported.",[t.NOT_IMPLEMENTED]:"The server does not support the requested functionality.",[t.INSUFFICIENT_STORAGE]:"The server has insufficient storage.",[t.NETWORK_AUTHENTICATION_REQUIRED]:"Network authentication is required.",413:"The payload of the request is too large. Please check the size.",414:"The request URI is too long.",416:"The requested range is invalid.",508:"The server detected a loop.",510:"The request does not include the required extensions."};class N{constructor(t){this._response=t,this._object=null,this._text=null}get available(){return!!this._response}get empty(){return!this._response||0===this._response.status}get ok(){return this._response?.ok??!1}get status(){return this._response?.status??0}get statusText(){return this._response?.statusText??""}get headers(){return this._response?.headers??new Headers}async textAsync(){return this._response?this._text??(this._text=await(this._response?.text())):""}async _ensureJsonParsedAsync(t){if(this._response&&null===this._object)try{const e=await this.textAsync();this._object=e?JSON.parse(e):t}catch(t){throw new O(`Failed to parse JSON response: ${t instanceof Error?t.message:String(t)}`)}return this._object??t}async objectAsync(t={}){return await this._ensureJsonParsedAsync(t)}async arrayAsync(t=[]){const e=await this._ensureJsonParsedAsync(t);return Array.isArray(e)?e:t}}class R{create(t,e){return e?`${e}[${t}]`:t}createIndex(t,e){return this.create(String(e),t)}}class D{create(t,e){return e?`${e}.${t}`:t}createIndex(t,e){return t?`${t}[${e}]`:`[${e}]`}}class ${constructor(t,e){this.element=t,this.bindNameGenerator=e,this._renderers={},this._builded=!1}get locale(){const t=(navigator.languages&&navigator.languages.length?navigator.languages:[navigator.language]).filter(Boolean);let e=this.element.attribute("data-cotomy-locale")||this.element.closest("[data-cotomy-locale]")?.attribute("data-cotomy-locale")||t[0]||"en-US";return e.includes("-")?e.split("-")[0]:e}renderer(t,e){return this._renderers[t]=e,this}get renderers(){return this.initialize(),this._renderers}get initialized(){return this._builded}initialize(){return this.initialized||(this.renderer("mail",(t,e)=>{e&&new m(`<a href="mailto:${e}">${e}</a>`).appendTo(t)}),this.renderer("tel",(t,e)=>{e&&new m(`<a href="tel:${e}">${e}</a>`).appendTo(t)}),this.renderer("url",(t,e)=>{e&&new m(`<a href="${e}" target="_blank">${e}</a>`).appendTo(t)}),this.renderer("number",(t,e)=>{if(null!=e){const n=t.attribute("data-cotomy-currency")||t.closest("[data-cotomy-currency]")?.attribute("data-cotomy-currency"),r=t.attribute("data-cotomy-fraction-digits")||t.closest("[data-cotomy-fraction-digits]")?.attribute("data-cotomy-fraction-digits"),i=r?Number.parseInt(r,10):void 0,s={...n?{style:"currency",currency:n}:{},...Number.isFinite(i)&&i&&i>=0&&i<=20?{minimumFractionDigits:i,maximumFractionDigits:i}:{}};t.text=new Intl.NumberFormat(this.locale,s).format(e)}}),this.renderer("utc",(t,e)=>{if(e){const n=/[+-]\d{2}:\d{2}$/.test(e)?new Date(e):new Date(`${e}Z`);if(!isNaN(n.getTime())){const e=t.attribute("data-cotomy-format")??"YYYY/MM/DD HH:mm";t.text=s()(n).format(e)}}}),this.renderer("date",(t,e)=>{if(e){const n=new Date(e);if(!isNaN(n.getTime())){const e=t.attribute("data-cotomy-format")??"YYYY/MM/DD";t.text=s()(n).format(e)}}}),this._builded=!0),this}bindPrimitiveValue(t,n){this.element.find(`[data-cotomy-bind="${t}" i]`).forEach(r=>{o.isEnabled(e.Bind)&&console.debug(`Binding data to element [data-cotomy-bind="${t}"]:`,n);const i=r.attribute("data-cotomy-bindtype")?.toLowerCase();i&&this.renderers[i]?this.renderers[i](r,n):r.text=String(n??"")})}async applyArrayAsync(t,e){for(let n=0;n<t.length;n++){const r=t[n],i=this.bindNameGenerator.createIndex(e,n);Array.isArray(r)?await this.applyArrayAsync(r,i):r&&"object"==typeof r?await this.applyObjectAsync(r,i):this.bindPrimitiveValue(i,r)}}async applyObjectAsync(t,e=void 0){e||this.element.find("[data-cotomy-bind]").forEach(t=>t.clear());for(const[n,r]of Object.entries(await t)){const t=this.bindNameGenerator.create(n,e);Array.isArray(r)?await this.applyArrayAsync(r,t):r&&"object"==typeof r?await this.applyObjectAsync(r,t):this.bindPrimitiveValue(t,r)}}async applyAsync(t){if(!t.available)throw new Error("Response is not available.");return await this.applyObjectAsync(await t.objectAsync()),this}}class L{constructor(t={baseUrl:null,headers:null,credentials:null,redirect:null,cache:null,referrerPolicy:null,mode:null,keepalive:!0,integrity:""}){this._options=t,this._abortController=new AbortController}get baseUrl(){return this._options.baseUrl||""}get headers(){return this._options.headers||{}}get credentials(){return this._options.credentials||"same-origin"}get redirect(){return this._options.redirect||"follow"}get cache(){return this._options.cache||"no-cache"}get referrerPolicy(){return this._options.referrerPolicy||"no-referrer"}get mode(){return this._options.mode||"cors"}get keepalive(){return this._options.keepalive||!0}get integrity(){return this._options.integrity||""}get abortController(){return this._abortController}async requestAsync(n,r,i,s,a){o.isEnabled(e.Api)&&console.debug(`API request: ${n} ${r}`,{body:i,headers:this.headers});const l={"application/json":t=>JSON.stringify(t),"application/x-www-form-urlencoded":t=>{if(t instanceof globalThis.FormData){let e=new URLSearchParams;return t.forEach((t,n)=>{e.append(n,String(t))}),e.toString()}return new URLSearchParams(t).toString()},"multipart/form-data":t=>{if(t instanceof globalThis.FormData)return t;const e=new globalThis.FormData;for(const[n,r]of Object.entries(t))e.append(n,String(r));return e}},c=/^[a-zA-Z]/.test(r)?r:`${(this.baseUrl||"").replace(/\/$/,"")}/${r.replace(/^\//,"")}`,u=new Headers(this.headers);u.has("Content-Type")&&"multipart/form-data"===u.get("Content-Type")&&u.delete("Content-Type");const h=u.get("Content-Type")||"multipart/form-data";if("multipart/form-data"===h&&i&&!(i instanceof globalThis.FormData)&&("object"!=typeof i||Array.isArray(i)))throw new S("Body must be FormData or a plain object when using multipart/form-data.");const d=new(a??N)(await fetch(c,{method:n,headers:u,credentials:this.credentials,body:i?l[h]?l[h](i):i:void 0,signal:s??this._abortController.signal,redirect:this.redirect,cache:this.cache,referrerPolicy:this.referrerPolicy,mode:this.mode,keepalive:this.keepalive,integrity:this.integrity}));if(o.isEnabled(e.Api)&&console.debug(`response body: ${d.status} ${d.statusText}`,await d.textAsync()),d.status>=400&&d.status<600){const n=await d.textAsync().catch(()=>"No response body available"),r=d.statusText||C.getMessage(d.status)||`Unexpected error: ${d.status}`;switch(o.isEnabled(e.Api)&&console.error(`API request failed: ${r}`,d,n),d.status){case t.BAD_REQUEST:case t.UNPROCESSABLE_ENTITY:throw new _(d.status,r,d,n);case t.UNAUTHORIZED:throw new E(d.status,r,d,n);case t.FORBIDDEN:throw new T(d.status,r,d,n);case t.NOT_FOUND:throw new v(d.status,r,d,n);case t.CONFLICT:case t.GONE:throw new b(d.status,r,d,n);case t.TOO_MANY_REQUESTS:throw new A(d.status,r,d,n);default:throw d.status<500?new p(d.status,r,d,n):new w(d.status,r,d,n)}}return d}async getAsync(t,n){let r="";if(n instanceof globalThis.FormData){let t=new URLSearchParams;n.forEach((e,n)=>{t.append(n,String(e))}),r=t.toString()}else n&&(r=new URLSearchParams(Object.fromEntries(Object.entries(n).map(([t,e])=>[t,String(e)]))).toString());const i=r?`${t}?${r}`:t;return o.isEnabled(e.Api)&&console.debug(`GET request to: ${i}`),this.requestAsync(I.GET,i)}async postAsync(t,e){return this.requestAsync(I.POST,t,e)}async putAsync(t,e){return this.requestAsync(I.PUT,t,e)}async patchAsync(t,e){return this.requestAsync(I.PATCH,t,e)}async deleteAsync(t){return this.requestAsync(I.DELETE,t)}async headAsync(t){return this.requestAsync(I.HEAD,t)}async optionsAsync(t){return this.requestAsync(I.OPTIONS,t)}async traceAsync(t){return this.requestAsync(I.TRACE,t)}async connectAsync(t){return this.requestAsync(I.CONNECT,t)}async submitAsync(t){return t.method.toUpperCase()===I.GET?this.getAsync(t.action,t.body):this.requestAsync(t.method.toUpperCase(),t.action,t.body)}}class U extends m{generateId(t="__cotomy_form__"){return super.generateId(t)}get method(){return this.attribute("method")??"get"}get actionUrl(){return this.attribute("action")??location.pathname+location.search}async reloadAsync(){g.instance.reload()}get autoReload(){return"false"!==this.attribute("data-cotomy-autoreload")}set autoReload(t){t?this.attribute("data-cotomy-autoreload",null):this.attribute("data-cotomy-autoreload","false")}get initialized(){return this.hasAttribute("data-cotomy-initialized")}initialize(){return this.initialized||(this.on("submit",async t=>{t.preventDefault(),t.stopPropagation(),await this.submitAsync()}),this.attribute("data-cotomy-initialized","")),this}}class M extends U{get method(){return"get"}async submitAsync(){const t=this.actionUrl,e={},n=t.split("?")[1];n&&n.split("&").forEach(t=>{const[n,r]=t.split("=");n&&r&&(e[n]=decodeURIComponent(r))}),this.find("[name]").forEach(t=>{const n=t.attribute("name");if(n){const r=t.value;r?e[n]=encodeURIComponent(r):delete e[n]}});const r=Object.entries(e).map(([t,e])=>`${t}=${e}`).join("&");location.href=`${t.split("?")[0]}?${r}`}}class P extends Event{constructor(t,e="cotomy:apifailed"){super(e,{bubbles:!0,cancelable:!0}),this._response=t}get response(){return this._response}}class x extends U{apiClient(){return new L}get actionUrl(){return this.attribute("action")}apiFailed(t){return this.on("cotomy:apifailed",async e=>{await t(e)}),this}triggerApiFailedEvent(t){this.trigger("cotomy:apifailed",new P(t)),o.isEnabled(e.Api)&&console.error("API request failed:",t)}submitFailed(t){return this.on("cotomy:submitfailed",async e=>{await t(e)}),this}triggerSubmitFailedEvent(t){this.trigger("cotomy:submitfailed",new P(t,"cotomy:submitfailed")),o.isEnabled(e.Api)&&console.error("Submit failed:",t)}get method(){return this.attribute("method")??"post"}formData(){const t=this.element,n=new FormData(t);return this.find("input[type=datetime-local][name]:not([disabled])").forEach(t=>{const e=t.value;if(e){const r=new Date(e);isNaN(r.getTime())||n.set(t.attribute("name"),s()(r).format("YYYY-MM-DDTHH:mmZ"))}}),o.isEnabled(e.FormData)&&console.debug("FormData:",Array.from(n.entries())),n}async submitAsync(){const t=this.formData();await this.submitToApiAsync(t)}async submitToApiAsync(t){const e=this.apiClient();try{return await e.submitAsync({method:this.method,action:this.actionUrl,body:t})}catch(t){throw t instanceof y&&(this.triggerApiFailedEvent(t.response),this.triggerSubmitFailedEvent(t.response)),t}}}class F extends x{get entityKey(){return this.attribute("data-cotomy-entity-key")||void 0}get requiresEntityKey(){return"false"!==this.attribute("data-cotomy-identify")}get hasEntityKey(){return!!this.entityKey}get actionUrl(){const t=this.attribute("action"),e=t.replace(/\/+$/,"");return this.entityKey?`${e}/${encodeURIComponent(this.entityKey)}`:t.endsWith("/")?t:`${e}/`}get method(){return this.hasAttribute("method")&&""!==this.attribute("method")?this.attribute("method"):this.hasEntityKey?"put":"post"}setEntityKey(n){if(this.requiresEntityKey&&n.status===t.CREATED){if(this.hasEntityKey)return void(o.isEnabled(e.FormLoad)&&console.warn("Entity key already exists, but server responded with 201 Created. Possible duplicate POST."));const t=n.headers.get("Location");if(!t)return;const r=t=>{const e=t.replace(/[?#].*$/,"");return e.endsWith("/")?e.slice(0,-1):e},i=e=>{try{return new URL(e,t).pathname}catch{return e}},s=r(i(this.attribute("action"))),a=r(i(t)),l=s.split("/"),c=a.split("/");if(!(c.length>=l.length&&l.every((t,e)=>t===c[e])))throw new Error(`Location path does not start with action path. action="${s}", location="${a}"`);const u=c.slice(l.length).filter(Boolean);if(1!==u.length||!u[0]){const t=`Location does not contain a single entity key segment.\n action="${s}", location="${a}", added=["${u.join('","')}"]`;throw new Error(t)}this.attribute("data-cotomy-entity-key",u[0])}}async submitToApiAsync(e){const n=await super.submitToApiAsync(e);return this.requiresEntityKey&&n.status===t.CREATED&&this.setEntityKey(n),n}}class H extends F{constructor(){super(...arguments),this._fillers={}}filler(t,e){return this._fillers[t]=e,this}initialize(){return this.initialized||(super.initialize(),this.filler("datetime-local",(t,e)=>{const n=/[+-]\d{2}:\d{2}$/.test(e)?new Date(e):new Date(`${e}Z`);isNaN(n.getTime())?t.value="":t.value=s()(n).format("YYYY-MM-DDTHH:mm")}),this.filler("checkbox",(t,e)=>{t.attribute("checked",null),e&&t.attribute("checked","")}),this.filler("radio",(t,e)=>{t.attribute("checked",null),t.value===e&&t.attribute("checked","")}),g.instance.ready(async()=>{await this.loadAsync()})),this}async reloadAsync(){await this.loadAsync()}loadActionUrl(){return this.actionUrl}bindNameGenerator(){return new R}renderer(){return new $(this,this.bindNameGenerator())}canLoad(){return this.hasEntityKey}async loadAsync(){if(!this.canLoad())return new N;const t=this.apiClient();try{const e=await t.getAsync(this.loadActionUrl());return await this.fillAsync(e),e}catch(t){if(t instanceof y&&this.triggerApiFailedEvent(t.response),t instanceof v)return t.response;throw t}}applyValueToInputs(t,n){this.find(`input[name="${t}" i]:not([data-cotomy-fill="false"]):not([multiple]),\n textarea[name="${t}" i]:not([data-cotomy-fill="false"]), \n select[name="${t}" i]:not([data-cotomy-fill="false"]):not([multiple])`).forEach(r=>{o.isEnabled(e.Fill)&&console.debug(`Filling input[name="${t}"] with value:`,n);const i=r.attribute("type")?.toLowerCase();i&&this._fillers[i]?this._fillers[i](r,n):r.value=String(n||"")})}async fillArrayAsync(t,e,n){for(let r=0;r<e.length;r++){const i=e[r],s=t.createIndex(n,r);Array.isArray(i)?await this.fillArrayAsync(t,i,s):i&&"object"==typeof i?await this.fillObjectAsync(t,i,s):this.applyValueToInputs(s,i)}}async fillObjectAsync(t,e,n=void 0){for(const[r,i]of Object.entries(e)){if(r.endsWith("[]"))continue;const e=t.create(r,n);Array.isArray(i)?await this.fillArrayAsync(t,i,e):i&&"object"==typeof i?await this.fillObjectAsync(t,i,e):this.applyValueToInputs(e,i)}}async fillAsync(t){t.ok&&t.available&&(await this.fillObjectAsync(this.bindNameGenerator(),await t.objectAsync()),await this.renderer().applyAsync(t)),this.find("textarea").forEach(t=>t.input())}async submitToApiAsync(t){const e=await super.submitToApiAsync(t);return e.ok&&await this.fillAsync(e),e}}var Y=n(569),B=n.n(Y),q=n(826),k=n.n(q);s().extend(k()),s().extend(B());class z{static location(){return new z}constructor(t=null){this._url=new URL(t??location.pathname+location.search,location.origin)}get url(){return this._url.pathname+this._url.search}get path(){return this._url.pathname}get segments(){return this._url.pathname.split("/").filter(t=>t.length>0)}get query(){return this._url.search.replace(/^\?/,"")}get parameters(){const t={};return this._url.searchParams.forEach((e,n)=>{t[n]=e}),t}redirect(){window.location.href=this.url}replace(){window.location.replace(this.url)}replaceState(t=null,e=""){window.history.replaceState(t,e,this.url)}}class W{constructor(){this._forms={}}static set(t){if(this._instance)throw new Error("PageController is already initialized.");return this._instance=new t,g.instance.load(async()=>{o.isEnabled(e.Page)&&console.debug("CotomyPageController initialize."),g.instance.initialize(),await W._instance.initializeAsync(),g.instance.trigger("cotomy:ready")}),this._instance}static get(){if(!(this._instance instanceof W))throw new Error("PageController is not initialized. Use CotomyPageController.set() to initialize it.");return this._instance}setForm(t){return t.id||t.generateId(),this._forms[t.id]=t,t.removed(()=>{delete this._forms[t.id]}),t.initialize()}getForm(t,e){const n=this._forms[t];if(n){if(e&&!(n instanceof e))throw new Error(`Form "${t}" is not instance of expected type.`);return n}}forms(){return Object.values(this._forms)}async restoreAsync(){for(const t of this.forms()){if(g.instance.reloading)break;t.autoReload&&await t.reloadAsync()}}isValidUtcDateString(t){return s()(t).isValid()&&(t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t))}initializeDateTimeElements(){g.instance.body.find("[data-cotomy-datetime]:not([data-cotomy-formatted])").forEach(t=>{if(s()(t.text).isValid()){const e=t.attribute("data-cotomy-timezone")||t.closest("[data-cotomy-timezone]")?.attribute("data-cotomy-timezone"),n=t.attribute("data-cotomy-format")??"YYYY-MM-DD HH:mm",r=this.isValidUtcDateString(t.text)?s()(t.text):s()(`${s()(t.text).format("YYYY-MM-DDTHH:mm:ss")}Z`),i="local"===t.attribute("data-cotomy-datetime")?r:r.utc();t.text=e&&""!==e.trim()?i.tz(e).format(n):i.format(n),t.attribute("data-cotomy-formatted","")}})}async initializeAsync(){this.initializeDateTimeElements(),g.instance.pageshow(async t=>{t.persisted&&(await this.restoreAsync(),g.instance.reloading&&t.stopImmediatePropagation())})}get body(){return g.instance.body}get url(){return new z}}W._instance=null})(),r})());
|
|
2
2
|
//# sourceMappingURL=cotomy.min.js.map
|