hakumi_components 0.1.13.pre → 0.1.15.pre
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/hakumi_components.js +117 -1
- data/app/form_builders/hakumi/form_builder.rb +2 -2
- data/app/javascript/hakumi_components/_controllers_manifest.js +151 -0
- data/app/javascript/hakumi_components/controllers/hakumi/admin_panel_controller.js +1 -1
- data/app/javascript/hakumi_components/controllers/hakumi/drawer_controller.js +1 -1
- data/app/javascript/hakumi_components/controllers/hakumi/modal_controller.js +1 -1
- data/app/javascript/hakumi_components/controllers/hakumi/notification_controller.js +1 -1
- data/app/javascript/hakumi_components/controllers/hakumi/theme_controller.js +1 -1
- data/app/javascript/hakumi_components/core/overlay_container.js +22 -0
- data/app/javascript/hakumi_components/index.js +9 -39
- data/lib/generators/hakumi/install_generator.rb +132 -0
- data/lib/hakumi_components/version.rb +1 -1
- data/sig/generators/hakumi/install_generator.rbs +11 -0
- data/sig/hakumi/form_builder.rbs +29 -0
- metadata +6 -1
|
@@ -1 +1,117 @@
|
|
|
1
|
-
var Ze=Object.create;var De=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var de=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var qe=(t,e,r,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of Be(e))!Ve.call(t,f)&&f!==r&&De(t,f,{get:()=>e[f],enumerable:!(c=Je(e,f))||c.enumerable});return t};var le=(t,e,r)=>(r=t!=null?Ze(Re(t)):{},qe(e||!t||!t.__esModule?De(r,"default",{value:t,enumerable:!0}):r,t));var Le=de((we,ke)=>{(function(t,e){typeof we=="object"&&typeof ke<"u"?ke.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).dayjs=e()})(we,function(){"use strict";var t=1e3,e=6e4,r=36e5,c="millisecond",f="second",y="minute",D="hour",v="day",w="week",O="month",x="quarter",H="year",L="date",Z="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|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,k={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(a){var o=["th","st","nd","rd"],n=a%100;return"["+a+(o[(n-20)%10]||o[n]||o[0])+"]"}},$=function(a,o,n){var s=String(a);return!s||s.length>=o?a:""+Array(o+1-s.length).join(n)+a},A={s:$,z:function(a){var o=-a.utcOffset(),n=Math.abs(o),s=Math.floor(n/60),i=n%60;return(o<=0?"+":"-")+$(s,2,"0")+":"+$(i,2,"0")},m:function a(o,n){if(o.date()<n.date())return-a(n,o);var s=12*(n.year()-o.year())+(n.month()-o.month()),i=o.clone().add(s,O),u=n-i<0,d=o.clone().add(s+(u?-1:1),O);return+(-(s+(n-i)/(u?i-d:d-i))||0)},a:function(a){return a<0?Math.ceil(a)||0:Math.floor(a)},p:function(a){return{M:O,y:H,w,d:v,D:L,h:D,m:y,s:f,ms:c,Q:x}[a]||String(a||"").toLowerCase().replace(/s$/,"")},u:function(a){return a===void 0}},S="en",j={};j[S]=k;var I="$isDayjsObject",T=function(a){return a instanceof Y||!(!a||!a[I])},M=function a(o,n,s){var i;if(!o)return S;if(typeof o=="string"){var u=o.toLowerCase();j[u]&&(i=u),n&&(j[u]=n,i=u);var d=o.split("-");if(!i&&d.length>1)return a(d[0])}else{var p=o.name;j[p]=o,i=p}return!s&&i&&(S=i),i||!s&&S},g=function(a,o){if(T(a))return a.clone();var n=typeof o=="object"?o:{};return n.date=a,n.args=arguments,new Y(n)},m=A;m.l=M,m.i=T,m.w=function(a,o){return g(a,{locale:o.$L,utc:o.$u,x:o.$x,$offset:o.$offset})};var Y=function(){function a(n){this.$L=M(n.locale,null,!0),this.parse(n),this.$x=this.$x||n.x||{},this[I]=!0}var o=a.prototype;return o.parse=function(n){this.$d=function(s){var i=s.date,u=s.utc;if(i===null)return new Date(NaN);if(m.u(i))return new Date;if(i instanceof Date)return new Date(i);if(typeof i=="string"&&!/Z$/i.test(i)){var d=i.match(l);if(d){var p=d[2]-1||0,C=(d[7]||"0").substring(0,3);return u?new Date(Date.UTC(d[1],p,d[3]||1,d[4]||0,d[5]||0,d[6]||0,C)):new Date(d[1],p,d[3]||1,d[4]||0,d[5]||0,d[6]||0,C)}}return new Date(i)}(n),this.init()},o.init=function(){var n=this.$d;this.$y=n.getFullYear(),this.$M=n.getMonth(),this.$D=n.getDate(),this.$W=n.getDay(),this.$H=n.getHours(),this.$m=n.getMinutes(),this.$s=n.getSeconds(),this.$ms=n.getMilliseconds()},o.$utils=function(){return m},o.isValid=function(){return this.$d.toString()!==Z},o.isSame=function(n,s){var i=g(n);return this.startOf(s)<=i&&i<=this.endOf(s)},o.isAfter=function(n,s){return g(n)<this.startOf(s)},o.isBefore=function(n,s){return this.endOf(s)<g(n)},o.$g=function(n,s,i){return m.u(n)?this[s]:this.set(i,n)},o.unix=function(){return Math.floor(this.valueOf()/1e3)},o.valueOf=function(){return this.$d.getTime()},o.startOf=function(n,s){var i=this,u=!!m.u(s)||s,d=m.p(n),p=function(P,W){var N=m.w(i.$u?Date.UTC(i.$y,W,P):new Date(i.$y,W,P),i);return u?N:N.endOf(v)},C=function(P,W){return m.w(i.toDate()[P].apply(i.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(W)),i)},b=this.$W,_=this.$M,F=this.$D,R="set"+(this.$u?"UTC":"");switch(d){case H:return u?p(1,0):p(31,11);case O:return u?p(1,_):p(0,_+1);case w:var J=this.$locale().weekStart||0,z=(b<J?b+7:b)-J;return p(u?F-z:F+(6-z),_);case v:case L:return C(R+"Hours",0);case D:return C(R+"Minutes",1);case y:return C(R+"Seconds",2);case f:return C(R+"Milliseconds",3);default:return this.clone()}},o.endOf=function(n){return this.startOf(n,!1)},o.$set=function(n,s){var i,u=m.p(n),d="set"+(this.$u?"UTC":""),p=(i={},i[v]=d+"Date",i[L]=d+"Date",i[O]=d+"Month",i[H]=d+"FullYear",i[D]=d+"Hours",i[y]=d+"Minutes",i[f]=d+"Seconds",i[c]=d+"Milliseconds",i)[u],C=u===v?this.$D+(s-this.$W):s;if(u===O||u===H){var b=this.clone().set(L,1);b.$d[p](C),b.init(),this.$d=b.set(L,Math.min(this.$D,b.daysInMonth())).$d}else p&&this.$d[p](C);return this.init(),this},o.set=function(n,s){return this.clone().$set(n,s)},o.get=function(n){return this[m.p(n)]()},o.add=function(n,s){var i,u=this;n=Number(n);var d=m.p(s),p=function(_){var F=g(u);return m.w(F.date(F.date()+Math.round(_*n)),u)};if(d===O)return this.set(O,this.$M+n);if(d===H)return this.set(H,this.$y+n);if(d===v)return p(1);if(d===w)return p(7);var C=(i={},i[y]=e,i[D]=r,i[f]=t,i)[d]||1,b=this.$d.getTime()+n*C;return m.w(b,this)},o.subtract=function(n,s){return this.add(-1*n,s)},o.format=function(n){var s=this,i=this.$locale();if(!this.isValid())return i.invalidDate||Z;var u=n||"YYYY-MM-DDTHH:mm:ssZ",d=m.z(this),p=this.$H,C=this.$m,b=this.$M,_=i.weekdays,F=i.months,R=i.meridiem,J=function(W,N,B,V){return W&&(W[N]||W(s,u))||B[N].slice(0,V)},z=function(W){return m.s(p%12||12,W,"0")},P=R||function(W,N,B){var V=W<12?"AM":"PM";return B?V.toLowerCase():V};return u.replace(h,function(W,N){return N||function(B){switch(B){case"YY":return String(s.$y).slice(-2);case"YYYY":return m.s(s.$y,4,"0");case"M":return b+1;case"MM":return m.s(b+1,2,"0");case"MMM":return J(i.monthsShort,b,F,3);case"MMMM":return J(F,b);case"D":return s.$D;case"DD":return m.s(s.$D,2,"0");case"d":return String(s.$W);case"dd":return J(i.weekdaysMin,s.$W,_,2);case"ddd":return J(i.weekdaysShort,s.$W,_,3);case"dddd":return _[s.$W];case"H":return String(p);case"HH":return m.s(p,2,"0");case"h":return z(1);case"hh":return z(2);case"a":return P(p,C,!0);case"A":return P(p,C,!1);case"m":return String(C);case"mm":return m.s(C,2,"0");case"s":return String(s.$s);case"ss":return m.s(s.$s,2,"0");case"SSS":return m.s(s.$ms,3,"0");case"Z":return d}return null}(W)||d.replace(":","")})},o.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},o.diff=function(n,s,i){var u,d=this,p=m.p(s),C=g(n),b=(C.utcOffset()-this.utcOffset())*e,_=this-C,F=function(){return m.m(d,C)};switch(p){case H:u=F()/12;break;case O:u=F();break;case x:u=F()/3;break;case w:u=(_-b)/6048e5;break;case v:u=(_-b)/864e5;break;case D:u=_/r;break;case y:u=_/e;break;case f:u=_/t;break;default:u=_}return i?u:m.a(u)},o.daysInMonth=function(){return this.endOf(O).$D},o.$locale=function(){return j[this.$L]},o.locale=function(n,s){if(!n)return this.$L;var i=this.clone(),u=M(n,s,!0);return u&&(i.$L=u),i},o.clone=function(){return m.w(this.$d,this)},o.toDate=function(){return new Date(this.valueOf())},o.toJSON=function(){return this.isValid()?this.toISOString():null},o.toISOString=function(){return this.$d.toISOString()},o.toString=function(){return this.$d.toUTCString()},a}(),E=Y.prototype;return g.prototype=E,[["$ms",c],["$s",f],["$m",y],["$H",D],["$W",v],["$M",O],["$y",H],["$D",L]].forEach(function(a){E[a[1]]=function(o){return this.$g(o,a[0],a[1])}}),g.extend=function(a,o){return a.$i||(a(o,Y,g),a.$i=!0),g},g.locale=M,g.isDayjs=T,g.unix=function(a){return g(1e3*a)},g.en=j[S],g.Ls=j,g.p={},g})});var Ae=de(($e,ve)=>{(function(t,e){typeof $e=="object"&&typeof ve<"u"?ve.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).dayjs_plugin_isoWeek=e()})($e,function(){"use strict";var t="day";return function(e,r,c){var f=function(v){return v.add(4-v.isoWeekday(),t)},y=r.prototype;y.isoWeekYear=function(){return f(this).year()},y.isoWeek=function(v){if(!this.$utils().u(v))return this.add(7*(v-this.isoWeek()),t);var w,O,x,H,L=f(this),Z=(w=this.isoWeekYear(),O=this.$u,x=(O?c.utc:c)().year(w).startOf("year"),H=4-x.isoWeekday(),x.isoWeekday()>4&&(H+=7),x.add(H,t));return L.diff(Z,"week")+1},y.isoWeekday=function(v){return this.$utils().u(v)?this.day()||7:this.day(this.day()%7?v:v-7)};var D=y.startOf;y.startOf=function(v,w){var O=this.$utils(),x=!!O.u(w)||w;return O.p(v)==="isoweek"?x?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):D.bind(this)(v,w)}}})});var je=de((Me,Ce)=>{(function(t,e){typeof Me=="object"&&typeof Ce<"u"?Ce.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).dayjs_plugin_customParseFormat=e()})(Me,function(){"use strict";var t={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},e=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,r=/\d/,c=/\d\d/,f=/\d\d?/,y=/\d*[^-_:/,()\s\d]+/,D={},v=function(l){return(l=+l)+(l>68?1900:2e3)},w=function(l){return function(h){this[l]=+h}},O=[/[+-]\d\d:?(\d\d)?|Z/,function(l){(this.zone||(this.zone={})).offset=function(h){if(!h||h==="Z")return 0;var k=h.match(/([+-]|\d\d)/g),$=60*k[1]+(+k[2]||0);return $===0?0:k[0]==="+"?-$:$}(l)}],x=function(l){var h=D[l];return h&&(h.indexOf?h:h.s.concat(h.f))},H=function(l,h){var k,$=D.meridiem;if($){for(var A=1;A<=24;A+=1)if(l.indexOf($(A,0,h))>-1){k=A>12;break}}else k=l===(h?"pm":"PM");return k},L={A:[y,function(l){this.afternoon=H(l,!1)}],a:[y,function(l){this.afternoon=H(l,!0)}],Q:[r,function(l){this.month=3*(l-1)+1}],S:[r,function(l){this.milliseconds=100*+l}],SS:[c,function(l){this.milliseconds=10*+l}],SSS:[/\d{3}/,function(l){this.milliseconds=+l}],s:[f,w("seconds")],ss:[f,w("seconds")],m:[f,w("minutes")],mm:[f,w("minutes")],H:[f,w("hours")],h:[f,w("hours")],HH:[f,w("hours")],hh:[f,w("hours")],D:[f,w("day")],DD:[c,w("day")],Do:[y,function(l){var h=D.ordinal,k=l.match(/\d+/);if(this.day=k[0],h)for(var $=1;$<=31;$+=1)h($).replace(/\[|\]/g,"")===l&&(this.day=$)}],w:[f,w("week")],ww:[c,w("week")],M:[f,w("month")],MM:[c,w("month")],MMM:[y,function(l){var h=x("months"),k=(x("monthsShort")||h.map(function($){return $.slice(0,3)})).indexOf(l)+1;if(k<1)throw new Error;this.month=k%12||k}],MMMM:[y,function(l){var h=x("months").indexOf(l)+1;if(h<1)throw new Error;this.month=h%12||h}],Y:[/[+-]?\d+/,w("year")],YY:[c,function(l){this.year=v(l)}],YYYY:[/\d{4}/,w("year")],Z:O,ZZ:O};function Z(l){var h,k;h=l,k=D&&D.formats;for(var $=(l=h.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(g,m,Y){var E=Y&&Y.toUpperCase();return m||k[Y]||t[Y]||k[E].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(a,o,n){return o||n.slice(1)})})).match(e),A=$.length,S=0;S<A;S+=1){var j=$[S],I=L[j],T=I&&I[0],M=I&&I[1];$[S]=M?{regex:T,parser:M}:j.replace(/^\[|\]$/g,"")}return function(g){for(var m={},Y=0,E=0;Y<A;Y+=1){var a=$[Y];if(typeof a=="string")E+=a.length;else{var o=a.regex,n=a.parser,s=g.slice(E),i=o.exec(s)[0];n.call(m,i),g=g.replace(i,"")}}return function(u){var d=u.afternoon;if(d!==void 0){var p=u.hours;d?p<12&&(u.hours+=12):p===12&&(u.hours=0),delete u.afternoon}}(m),m}}return function(l,h,k){k.p.customParseFormat=!0,l&&l.parseTwoDigitYear&&(v=l.parseTwoDigitYear);var $=h.prototype,A=$.parse;$.parse=function(S){var j=S.date,I=S.utc,T=S.args;this.$u=I;var M=T[1];if(typeof M=="string"){var g=T[2]===!0,m=T[3]===!0,Y=g||m,E=T[2];m&&(E=T[2]),D=this.$locale(),!g&&E&&(D=k.Ls[E]),this.$d=function(s,i,u,d){try{if(["x","X"].indexOf(i)>-1)return new Date((i==="X"?1e3:1)*s);var p=Z(i)(s),C=p.year,b=p.month,_=p.day,F=p.hours,R=p.minutes,J=p.seconds,z=p.milliseconds,P=p.zone,W=p.week,N=new Date,B=_||(C||b?1:N.getDate()),V=C||N.getFullYear(),te=0;C&&!b||(te=b>0?b-1:N.getMonth());var ne,ae=F||0,ue=R||0,ce=J||0,fe=z||0;return P?new Date(Date.UTC(V,te,B,ae,ue,ce,fe+60*P.offset*1e3)):u?new Date(Date.UTC(V,te,B,ae,ue,ce,fe)):(ne=new Date(V,te,B,ae,ue,ce,fe),W&&(ne=d(ne).week(W).toDate()),ne)}catch{return new Date("")}}(j,M,I,k),this.init(),E&&E!==!0&&(this.$L=this.locale(E).$L),Y&&j!=this.format(M)&&(this.$d=new Date("")),D={}}else if(M instanceof Array)for(var a=M.length,o=1;o<=a;o+=1){T[1]=M[o-1];var n=k.apply(this,T);if(n.isValid()){this.$d=n.$d,this.$L=n.$L,this.init();break}o===a&&(this.$d=new Date(""))}else A.call(this,S)}}})});var Se=t=>t||(typeof window<"u"&&window.HakumiComponentsConfig?.baseUrl?window.HakumiComponentsConfig.baseUrl:"/hakumi/components");var q=(t,e="hakumi-component")=>{if(!t.id){let r=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2,10);t.id=`${e}-${r}`}return t.id},be=t=>{let e=typeof t=="string"?document.querySelector(t):t;if(!e)throw new Error("[HakumiComponents] Target element not found");return e},me=(t,e)=>{let r=document.createElement("template");r.innerHTML=String(t).trim();let c=r.content.firstElementChild;if(!c)throw new Error(`[HakumiComponents] Empty markup for ${e}`);return c},Oe=()=>new Promise(t=>requestAnimationFrame(t));var re=new Map,K=(t,e)=>{if(!t)throw new Error("[HakumiComponents] Missing id for registration");re.set(t,e),typeof window<"u"&&window.dispatchEvent(new CustomEvent("hakumi-component:registered",{detail:{id:t,instance:e}}))},Q=t=>{t&&(re.delete(t),typeof window<"u"&&window.dispatchEvent(new CustomEvent("hakumi-component:unregistered",{detail:{id:t}})))},X=t=>re.get(t),Ye=()=>Array.from(re.entries(),([t,e])=>({id:t,instance:e}));var ze=t=>`.hakumi-${t.replace(/_/g,"-")}`,he=new Map,He=t=>{try{return sessionStorage.getItem(t)}catch{return null}},xe=(t,e)=>{try{sessionStorage.setItem(t,e)}catch{}},Ke=t=>{try{sessionStorage.removeItem(t)}catch{}},Qe=()=>{try{return window.self!==window.top}catch{return!0}},_e=(t,e)=>`hakumi:rcache:${e}:${t}`,pe=(t,e)=>`hakumi:rcachemeta:${e}:${t}`,Ee=t=>t?.hakumiComponent,Xe=(t,e,r)=>{let c=He(pe(t,e));if(!c)return null;let f;try{f=JSON.parse(c)}catch{return Ke(pe(t,e)),null}return!f?.ts||typeof f.ts!="number"||r!=null&&Date.now()-f.ts>r?null:He(_e(t,e))},Ge=(t,e,r)=>{xe(_e(t,e),r),xe(pe(t,e),JSON.stringify({ts:Date.now()}))},We=async(t,{params:e={},target:r=typeof document<"u"?document.body:null,format:c="html",baseUrl:f=null,mode:y="append",allowInIframe:D=!1,singletonSelector:v=ze,cache:w=!0,cacheTtlMs:O=5*60*1e3}={})=>{if(!D&&typeof window<"u"&&Qe())return{id:null,element:null,instance:null};if(!t)throw new Error("[HakumiComponents] Missing component name for render");if(!r)throw new Error("[HakumiComponents] Missing target for render");let x=v(t),H=document.querySelector(x),L=Ee(H);if(L?.singleton){let h=q(H,`hakumi-${t}`);L?.apply?.(e);let k=L?.api??X(h);return{id:h,element:H,instance:k}}let Z=he.get(x);if(Z){let h=await Z;return Ee(h.element)?.apply?.(e),h}let l=(async()=>{let h=be(r),k=t.replace(/-/g,"_"),$=new URL(`${Se(f)}/${k}`,window.location?.origin||"http://localhost"),A={...e};y==="destroy_on_close"&&(A.destroy_on_close=!0),Object.entries(A).forEach(([Y,E])=>{E!=null&&$.searchParams.set(Y,E)});let S=null;if(w&&y!=="replace"){let Y=Xe(k,c,O);if(Y)try{S=me(Y,t),S.setAttribute("data-hakumi-render-cache","1"),h.appendChild(S),q(S,`hakumi-${t}`)}catch{}}let I=await fetch($,{headers:{Accept:c==="json"?"application/json":"text/html"}});if(!I.ok)throw new Error(`[HakumiComponents] Failed to render ${t}: ${I.status}`);let T=c==="json"?(await I.json()).html:await I.text();w&&Ge(k,c,T);let M=me(T,t);y==="replace"?(h.innerHTML="",h.appendChild(M)):S&&S.isConnected?S.replaceWith(M):h.appendChild(M);let g=q(M,`hakumi-${t}`);if(y==="destroy_on_close"){let Y=()=>{M.remove(),Q(g)};M.addEventListener("hakumi-component:hidden",Y,{once:!0})}await Oe();let m=X(g);return m||(K(g,M),m=X(g)),M.hakumiComponent?.api&&(m=M.hakumiComponent.api),{id:g,element:M,instance:m}})();he.set(x,l);try{return await l}finally{he.delete(x)}};var G={get(t){try{return localStorage.getItem(t)}catch{return null}},set(t,e){try{localStorage.setItem(t,e)}catch{}},remove(t){try{localStorage.removeItem(t)}catch{}}},oe={get(t){let e=G.get(t);if(!e)return null;try{return JSON.parse(e)}catch{return null}},set(t,e){try{G.set(t,JSON.stringify(e))}catch{}}},Te=!1,ge=new Set,ye=!1,ie=()=>{ye||(ye=!0,queueMicrotask(()=>{ye=!1;for(let t of ge)try{t()}catch{}}))},et=()=>{Te||typeof document>"u"||(Te=!0,document.addEventListener("turbo:load",ie),document.addEventListener("turbo:render",ie),window.addEventListener("popstate",ie),window.addEventListener("hashchange",ie))},Ie=new Map,tt={storage:{get:G.get,set:G.set,remove:G.remove,getJson:oe.get,setJson:oe.set},save(t,{version:e=1,state:r}){if(r==null)return G.remove(t);oe.set(t,{v:e,state:r})},load(t){return oe.get(t)},bootstrap(t,e){if(typeof t!="string"||t.length===0)throw new Error("[HakumiComponents] Persistence.bootstrap(key, fn) missing key");if(typeof e!="function")throw new Error("[HakumiComponents] Persistence.bootstrap(key, fn) expects a function");let r=Ie.get(t);if(r)return r;let c=()=>{let y=this.load(t);if(y)try{e(y)}catch{}};c();let f=this.onNavigate(c);return Ie.set(t,f),f},onNavigate(t){if(typeof document>"u")return()=>{};if(typeof t!="function")throw new Error("[HakumiComponents] Persistence.onNavigate(fn) expects a function");return et(),ge.add(t),()=>ge.delete(t)},ensureHost({id:t,controllerName:e,tagName:r="div",display:c="none",parent:f=()=>document.body}){if(typeof document>"u")return null;let y=document.getElementById(t);y||(y=document.createElement(r),y.id=t,y.style.display=c,f().appendChild(y));let D=(y.getAttribute("data-controller")||"").split(" ").filter(Boolean);return D.includes(e)||(D.push(e),y.setAttribute("data-controller",D.join(" "))),y}};var U=le(Le(),1),Fe=le(Ae(),1),Ue=le(je(),1);U.default.extend(Fe.default);U.default.extend(Ue.default);var nt="YYYY-MM-DD HH:mm:ss",rt="YYYY-MM-DD HH:mm",ee=class{static getMondayOfWeek(e){return(0,U.default)(e).startOf("isoWeek")}static getISOWeek(e){return(0,U.default)(e).isoWeek()}static getISOWeekYear(e){return(0,U.default)(e).isoWeekYear()}static getSundayOfWeek(e){return(0,U.default)(e).endOf("isoWeek")}static formatDataDate(e){return(0,U.default)(e).format("YYYY-MM-DD")}static parseDataDate(e){return(0,U.default)(e)}static isInMonth(e,r,c){return e.month()+1===r&&e.year()===c}static isSameISOWeek(e,r){return e.isoWeek()===r.isoWeek()&&e.isoWeekYear()===r.isoWeekYear()}static getDatesInWeek(e){let r=this.getMondayOfWeek(e);return Array.from({length:7},(c,f)=>r.add(f,"day"))}static getMondayOfISOWeek(e,r){return(0,U.default)(`${e}-01-04`).startOf("isoWeek").add(r-1,"week")}static format(e,r){return e?(0,U.default)(e).format(r):""}static formatISO(e,r=!0){if(!e)return"";let c=r?nt:rt;return(0,U.default)(e).format(c)}static parse(e,r=null){return e?r?(0,U.default)(e,r):(0,U.default)(e):null}static isValid(e,r=null){let c=this.parse(e,r);return c&&c.isValid()}};import{Controller as ot}from"@hotwired/stimulus";var se=class extends ot{connect(){let e=this.isHakumiController();typeof this.registerApi=="function"?this.registerApi():e||(this.element.hakumiComponent||={name:this.componentName(),version:1,singleton:!1,api:{}}),q(this.element,this.defaultIdPrefix()),typeof this.setup=="function"&&this.setup(),this.validateContract(),K(this.element.id,this.element.hakumiComponent.api),this.element.hakumiComponent.singleton&&typeof window<"u"&&window.HakumiComponents&&(window.HakumiComponents[this.element.hakumiComponent.name]=this.element.hakumiComponent.api)}disconnect(){typeof this.teardown=="function"&&this.teardown();let e=this.element?.hakumiComponent;e?.singleton&&typeof window<"u"&&window.HakumiComponents&&window.HakumiComponents[e.name]===e.api&&delete window.HakumiComponents[e.name],this.element?.id&&Q(this.element.id)}validateContract(){let e=this.isHakumiController(),r=this.element.hakumiComponent;if(e&&typeof this.registerApi!="function")throw new Error(`[HakumiComponents] ${this.identifier} must implement registerApi()`);if(!r)throw new Error(`[HakumiComponents] Missing hakumiComponent for ${this.identifier}`);if(!r.name)throw new Error(`[HakumiComponents] Missing hakumiComponent.name for ${this.identifier}`);if(r.version!==1)throw new Error(`[HakumiComponents] Unsupported hakumiComponent.version for ${r.name}`);if(typeof r.singleton!="boolean")throw new Error(`[HakumiComponents] hakumiComponent.singleton must be boolean (${r.name})`);if(!r.api||typeof r.api!="object")throw new Error(`[HakumiComponents] hakumiComponent.api must be object (${r.name})`);if(e&&Object.keys(r.api).length===0)throw new Error(`[HakumiComponents] hakumiComponent.api cannot be empty (${r.name})`);if(r.apply&&typeof r.apply!="function")throw new Error(`[HakumiComponents] hakumiComponent.apply must be function (${r.name})`);if(r.destroy&&typeof r.destroy!="function")throw new Error(`[HakumiComponents] hakumiComponent.destroy must be function (${r.name})`)}componentName(){return String(this.identifier||"").replace(/^hakumi--/,"").replace(/--/g,"_").replace(/-/g,"_")||"unknown"}defaultIdPrefix(){return`hakumi-${this.componentName()}`}isHakumiController(){return String(this.identifier||"").startsWith("hakumi--")}setup(){}teardown(){}registerApi(){}};var Ne=()=>{if(typeof document>"u")return null;let t=document.getElementById("hakumi-overlay-root");if(t)return t;let e=document.createElement("div");return e.id="hakumi-overlay-root",e.setAttribute("data-hakumi-overlay-container",""),document.body?document.body.appendChild(e):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(e)}),e};var Pe={renderComponent:We,register:K,unregister:Q,get:X,list:Ye,ensureId:q,ensureOverlayContainer:Ne,DateHelper:ee};typeof window<"u"&&(window.HakumiComponents=Pe,Ne());var St=t=>{if(!t)throw new Error("[HakumiComponents] Missing Stimulus application");let e=import.meta.glob("./controllers/hakumi/**/*_controller.js",{eager:!0}),r=Object.values(e).map(c=>c.default).filter(Boolean);for(let c of r)if(typeof c.mount=="function")try{c.mount()}catch(f){console.error("[HakumiComponents] mount() failed",f)}Object.entries(e).forEach(([c,f])=>{let y=c.replace("./controllers/","").replace("_controller.js","").replace(/\//g,"--").replace(/_/g,"-");t.register(y,f.default)})},bt=Pe;export{ee as DateHelper,Pe as HakumiComponents,tt as Persistence,se as RegistryController,bt as default,q as ensureId,Ne as ensureOverlayContainer,X as get,Ye as list,K as register,St as registerHakumiControllers,We as renderComponent,Q as unregister};
|
|
1
|
+
var cr=Object.create;var wa=Object.defineProperty;var dr=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,fr=Object.prototype.hasOwnProperty;var K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var gr=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of pr(t))!fr.call(e,a)&&a!==i&&wa(e,a,{get:()=>t[a],enumerable:!(s=dr(t,a))||s.enumerable});return e};var Dt=(e,t,i)=>(i=e!=null?cr(mr(e)):{},gr(t||!e||!e.__esModule?wa(i,"default",{value:e,enumerable:!0}):i,e));var Ia=K((Vs,Es)=>{(function(e,t){typeof Vs=="object"&&typeof Es<"u"?Es.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs=t()})(Vs,function(){"use strict";var e=1e3,t=6e4,i=36e5,s="millisecond",a="second",n="minute",r="hour",o="day",l="week",h="month",u="quarter",c="year",d="date",g="Invalid Date",p=/^(\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,C={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(S){var y=["th","st","nd","rd"],v=S%100;return"["+S+(y[(v-20)%10]||y[v]||y[0])+"]"}},V=function(S,y,v){var w=String(S);return!w||w.length>=y?S:""+Array(y+1-w.length).join(v)+S},B={s:V,z:function(S){var y=-S.utcOffset(),v=Math.abs(y),w=Math.floor(v/60),b=v%60;return(y<=0?"+":"-")+V(w,2,"0")+":"+V(b,2,"0")},m:function S(y,v){if(y.date()<v.date())return-S(v,y);var w=12*(v.year()-y.year())+(v.month()-y.month()),b=y.clone().add(w,h),x=v-b<0,D=y.clone().add(w+(x?-1:1),h);return+(-(w+(v-b)/(x?b-D:D-b))||0)},a:function(S){return S<0?Math.ceil(S)||0:Math.floor(S)},p:function(S){return{M:h,y:c,w:l,d:o,D:d,h:r,m:n,s:a,ms:s,Q:u}[S]||String(S||"").toLowerCase().replace(/s$/,"")},u:function(S){return S===void 0}},O="en",$={};$[O]=C;var T="$isDayjsObject",R=function(S){return S instanceof q||!(!S||!S[T])},I=function S(y,v,w){var b;if(!y)return O;if(typeof y=="string"){var x=y.toLowerCase();$[x]&&(b=x),v&&($[x]=v,b=x);var D=y.split("-");if(!b&&D.length>1)return S(D[0])}else{var H=y.name;$[H]=y,b=H}return!w&&b&&(O=b),b||!w&&O},P=function(S,y){if(R(S))return S.clone();var v=typeof y=="object"?y:{};return v.date=S,v.args=arguments,new q(v)},E=B;E.l=I,E.i=R,E.w=function(S,y){return P(S,{locale:y.$L,utc:y.$u,x:y.$x,$offset:y.$offset})};var q=function(){function S(v){this.$L=I(v.locale,null,!0),this.parse(v),this.$x=this.$x||v.x||{},this[T]=!0}var y=S.prototype;return y.parse=function(v){this.$d=function(w){var b=w.date,x=w.utc;if(b===null)return new Date(NaN);if(E.u(b))return new Date;if(b instanceof Date)return new Date(b);if(typeof b=="string"&&!/Z$/i.test(b)){var D=b.match(p);if(D){var H=D[2]-1||0,W=(D[7]||"0").substring(0,3);return x?new Date(Date.UTC(D[1],H,D[3]||1,D[4]||0,D[5]||0,D[6]||0,W)):new Date(D[1],H,D[3]||1,D[4]||0,D[5]||0,D[6]||0,W)}}return new Date(b)}(v),this.init()},y.init=function(){var v=this.$d;this.$y=v.getFullYear(),this.$M=v.getMonth(),this.$D=v.getDate(),this.$W=v.getDay(),this.$H=v.getHours(),this.$m=v.getMinutes(),this.$s=v.getSeconds(),this.$ms=v.getMilliseconds()},y.$utils=function(){return E},y.isValid=function(){return this.$d.toString()!==g},y.isSame=function(v,w){var b=P(v);return this.startOf(w)<=b&&b<=this.endOf(w)},y.isAfter=function(v,w){return P(v)<this.startOf(w)},y.isBefore=function(v,w){return this.endOf(w)<P(v)},y.$g=function(v,w,b){return E.u(v)?this[w]:this.set(b,v)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(v,w){var b=this,x=!!E.u(w)||w,D=E.p(v),H=function(be,ie){var pe=E.w(b.$u?Date.UTC(b.$y,ie,be):new Date(b.$y,ie,be),b);return x?pe:pe.endOf(o)},W=function(be,ie){return E.w(b.toDate()[be].apply(b.toDate("s"),(x?[0,0,0,0]:[23,59,59,999]).slice(ie)),b)},Y=this.$W,Q=this.$M,oe=this.$D,Le="set"+(this.$u?"UTC":"");switch(D){case c:return x?H(1,0):H(31,11);case h:return x?H(1,Q):H(0,Q+1);case l:var Te=this.$locale().weekStart||0,Be=(Y<Te?Y+7:Y)-Te;return H(x?oe-Be:oe+(6-Be),Q);case o:case d:return W(Le+"Hours",0);case r:return W(Le+"Minutes",1);case n:return W(Le+"Seconds",2);case a:return W(Le+"Milliseconds",3);default:return this.clone()}},y.endOf=function(v){return this.startOf(v,!1)},y.$set=function(v,w){var b,x=E.p(v),D="set"+(this.$u?"UTC":""),H=(b={},b[o]=D+"Date",b[d]=D+"Date",b[h]=D+"Month",b[c]=D+"FullYear",b[r]=D+"Hours",b[n]=D+"Minutes",b[a]=D+"Seconds",b[s]=D+"Milliseconds",b)[x],W=x===o?this.$D+(w-this.$W):w;if(x===h||x===c){var Y=this.clone().set(d,1);Y.$d[H](W),Y.init(),this.$d=Y.set(d,Math.min(this.$D,Y.daysInMonth())).$d}else H&&this.$d[H](W);return this.init(),this},y.set=function(v,w){return this.clone().$set(v,w)},y.get=function(v){return this[E.p(v)]()},y.add=function(v,w){var b,x=this;v=Number(v);var D=E.p(w),H=function(Q){var oe=P(x);return E.w(oe.date(oe.date()+Math.round(Q*v)),x)};if(D===h)return this.set(h,this.$M+v);if(D===c)return this.set(c,this.$y+v);if(D===o)return H(1);if(D===l)return H(7);var W=(b={},b[n]=t,b[r]=i,b[a]=e,b)[D]||1,Y=this.$d.getTime()+v*W;return E.w(Y,this)},y.subtract=function(v,w){return this.add(-1*v,w)},y.format=function(v){var w=this,b=this.$locale();if(!this.isValid())return b.invalidDate||g;var x=v||"YYYY-MM-DDTHH:mm:ssZ",D=E.z(this),H=this.$H,W=this.$m,Y=this.$M,Q=b.weekdays,oe=b.months,Le=b.meridiem,Te=function(ie,pe,Ce,De){return ie&&(ie[pe]||ie(w,x))||Ce[pe].slice(0,De)},Be=function(ie){return E.s(H%12||12,ie,"0")},be=Le||function(ie,pe,Ce){var De=ie<12?"AM":"PM";return Ce?De.toLowerCase():De};return x.replace(f,function(ie,pe){return pe||function(Ce){switch(Ce){case"YY":return String(w.$y).slice(-2);case"YYYY":return E.s(w.$y,4,"0");case"M":return Y+1;case"MM":return E.s(Y+1,2,"0");case"MMM":return Te(b.monthsShort,Y,oe,3);case"MMMM":return Te(oe,Y);case"D":return w.$D;case"DD":return E.s(w.$D,2,"0");case"d":return String(w.$W);case"dd":return Te(b.weekdaysMin,w.$W,Q,2);case"ddd":return Te(b.weekdaysShort,w.$W,Q,3);case"dddd":return Q[w.$W];case"H":return String(H);case"HH":return E.s(H,2,"0");case"h":return Be(1);case"hh":return Be(2);case"a":return be(H,W,!0);case"A":return be(H,W,!1);case"m":return String(W);case"mm":return E.s(W,2,"0");case"s":return String(w.$s);case"ss":return E.s(w.$s,2,"0");case"SSS":return E.s(w.$ms,3,"0");case"Z":return D}return null}(ie)||D.replace(":","")})},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(v,w,b){var x,D=this,H=E.p(w),W=P(v),Y=(W.utcOffset()-this.utcOffset())*t,Q=this-W,oe=function(){return E.m(D,W)};switch(H){case c:x=oe()/12;break;case h:x=oe();break;case u:x=oe()/3;break;case l:x=(Q-Y)/6048e5;break;case o:x=(Q-Y)/864e5;break;case r:x=Q/i;break;case n:x=Q/t;break;case a:x=Q/e;break;default:x=Q}return b?x:E.a(x)},y.daysInMonth=function(){return this.endOf(h).$D},y.$locale=function(){return $[this.$L]},y.locale=function(v,w){if(!v)return this.$L;var b=this.clone(),x=I(v,w,!0);return x&&(b.$L=x),b},y.clone=function(){return E.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()},S}(),U=q.prototype;return P.prototype=U,[["$ms",s],["$s",a],["$m",n],["$H",r],["$W",o],["$M",h],["$y",c],["$D",d]].forEach(function(S){U[S[1]]=function(y){return this.$g(y,S[0],S[1])}}),P.extend=function(S,y){return S.$i||(S(y,q,P),S.$i=!0),P},P.locale=I,P.isDayjs=R,P.unix=function(S){return P(1e3*S)},P.en=$[O],P.Ls=$,P.p={},P})});var Oa=K((xs,Ls)=>{(function(e,t){typeof xs=="object"&&typeof Ls<"u"?Ls.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_isoWeek=t()})(xs,function(){"use strict";var e="day";return function(t,i,s){var a=function(o){return o.add(4-o.isoWeekday(),e)},n=i.prototype;n.isoWeekYear=function(){return a(this).year()},n.isoWeek=function(o){if(!this.$utils().u(o))return this.add(7*(o-this.isoWeek()),e);var l,h,u,c,d=a(this),g=(l=this.isoWeekYear(),h=this.$u,u=(h?s.utc:s)().year(l).startOf("year"),c=4-u.isoWeekday(),u.isoWeekday()>4&&(c+=7),u.add(c,e));return d.diff(g,"week")+1},n.isoWeekday=function(o){return this.$utils().u(o)?this.day()||7:this.day(this.day()%7?o:o-7)};var r=n.startOf;n.startOf=function(o,l){var h=this.$utils(),u=!!h.u(l)||l;return h.p(o)==="isoweek"?u?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):r.bind(this)(o,l)}}})});var Pa=K((Ds,As)=>{(function(e,t){typeof Ds=="object"&&typeof As<"u"?As.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_customParseFormat=t()})(Ds,function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,i=/\d/,s=/\d\d/,a=/\d\d?/,n=/\d*[^-_:/,()\s\d]+/,r={},o=function(p){return(p=+p)+(p>68?1900:2e3)},l=function(p){return function(f){this[p]=+f}},h=[/[+-]\d\d:?(\d\d)?|Z/,function(p){(this.zone||(this.zone={})).offset=function(f){if(!f||f==="Z")return 0;var C=f.match(/([+-]|\d\d)/g),V=60*C[1]+(+C[2]||0);return V===0?0:C[0]==="+"?-V:V}(p)}],u=function(p){var f=r[p];return f&&(f.indexOf?f:f.s.concat(f.f))},c=function(p,f){var C,V=r.meridiem;if(V){for(var B=1;B<=24;B+=1)if(p.indexOf(V(B,0,f))>-1){C=B>12;break}}else C=p===(f?"pm":"PM");return C},d={A:[n,function(p){this.afternoon=c(p,!1)}],a:[n,function(p){this.afternoon=c(p,!0)}],Q:[i,function(p){this.month=3*(p-1)+1}],S:[i,function(p){this.milliseconds=100*+p}],SS:[s,function(p){this.milliseconds=10*+p}],SSS:[/\d{3}/,function(p){this.milliseconds=+p}],s:[a,l("seconds")],ss:[a,l("seconds")],m:[a,l("minutes")],mm:[a,l("minutes")],H:[a,l("hours")],h:[a,l("hours")],HH:[a,l("hours")],hh:[a,l("hours")],D:[a,l("day")],DD:[s,l("day")],Do:[n,function(p){var f=r.ordinal,C=p.match(/\d+/);if(this.day=C[0],f)for(var V=1;V<=31;V+=1)f(V).replace(/\[|\]/g,"")===p&&(this.day=V)}],w:[a,l("week")],ww:[s,l("week")],M:[a,l("month")],MM:[s,l("month")],MMM:[n,function(p){var f=u("months"),C=(u("monthsShort")||f.map(function(V){return V.slice(0,3)})).indexOf(p)+1;if(C<1)throw new Error;this.month=C%12||C}],MMMM:[n,function(p){var f=u("months").indexOf(p)+1;if(f<1)throw new Error;this.month=f%12||f}],Y:[/[+-]?\d+/,l("year")],YY:[s,function(p){this.year=o(p)}],YYYY:[/\d{4}/,l("year")],Z:h,ZZ:h};function g(p){var f,C;f=p,C=r&&r.formats;for(var V=(p=f.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(P,E,q){var U=q&&q.toUpperCase();return E||C[q]||e[q]||C[U].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(S,y,v){return y||v.slice(1)})})).match(t),B=V.length,O=0;O<B;O+=1){var $=V[O],T=d[$],R=T&&T[0],I=T&&T[1];V[O]=I?{regex:R,parser:I}:$.replace(/^\[|\]$/g,"")}return function(P){for(var E={},q=0,U=0;q<B;q+=1){var S=V[q];if(typeof S=="string")U+=S.length;else{var y=S.regex,v=S.parser,w=P.slice(U),b=y.exec(w)[0];v.call(E,b),P=P.replace(b,"")}}return function(x){var D=x.afternoon;if(D!==void 0){var H=x.hours;D?H<12&&(x.hours+=12):H===12&&(x.hours=0),delete x.afternoon}}(E),E}}return function(p,f,C){C.p.customParseFormat=!0,p&&p.parseTwoDigitYear&&(o=p.parseTwoDigitYear);var V=f.prototype,B=V.parse;V.parse=function(O){var $=O.date,T=O.utc,R=O.args;this.$u=T;var I=R[1];if(typeof I=="string"){var P=R[2]===!0,E=R[3]===!0,q=P||E,U=R[2];E&&(U=R[2]),r=this.$locale(),!P&&U&&(r=C.Ls[U]),this.$d=function(w,b,x,D){try{if(["x","X"].indexOf(b)>-1)return new Date((b==="X"?1e3:1)*w);var H=g(b)(w),W=H.year,Y=H.month,Q=H.day,oe=H.hours,Le=H.minutes,Te=H.seconds,Be=H.milliseconds,be=H.zone,ie=H.week,pe=new Date,Ce=Q||(W||Y?1:pe.getDate()),De=W||pe.getFullYear(),xt=0;W&&!Y||(xt=Y>0?Y-1:pe.getMonth());var Lt,gs=oe||0,vs=Le||0,ys=Te||0,bs=Be||0;return be?new Date(Date.UTC(De,xt,Ce,gs,vs,ys,bs+60*be.offset*1e3)):x?new Date(Date.UTC(De,xt,Ce,gs,vs,ys,bs)):(Lt=new Date(De,xt,Ce,gs,vs,ys,bs),ie&&(Lt=D(Lt).week(ie).toDate()),Lt)}catch{return new Date("")}}($,I,T,C),this.init(),U&&U!==!0&&(this.$L=this.locale(U).$L),q&&$!=this.format(I)&&(this.$d=new Date("")),r={}}else if(I instanceof Array)for(var S=I.length,y=1;y<=S;y+=1){R[1]=I[y-1];var v=C.apply(this,R);if(v.isValid()){this.$d=v.$d,this.$L=v.$L,this.init();break}y===S&&(this.$d=new Date(""))}else B.call(this,O)}}})});var $a=K((Mh,Fa)=>{Fa.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var Ae=K(Ne=>{var _s,Lr=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Ne.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};Ne.getSymbolTotalCodewords=function(t){return Lr[t]};Ne.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};Ne.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');_s=t};Ne.isKanjiModeEnabled=function(){return typeof _s<"u"};Ne.toSJIS=function(t){return _s(t)}});var ni=K(fe=>{fe.L={bit:1};fe.M={bit:0};fe.Q={bit:3};fe.H={bit:2};function Dr(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return fe.L;case"m":case"medium":return fe.M;case"q":case"quartile":return fe.Q;case"h":case"high":return fe.H;default:throw new Error("Unknown EC Level: "+e)}}fe.isValid=function(t){return t&&typeof t.bit<"u"&&t.bit>=0&&t.bit<4};fe.from=function(t,i){if(fe.isValid(t))return t;try{return Dr(t)}catch{return i}}});var qa=K((Oh,za)=>{function Ka(){this.buffer=[],this.length=0}Ka.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let i=0;i<t;i++)this.putBit((e>>>t-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};za.exports=Ka});var Wa=K((Ph,Ua)=>{function ht(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}ht.prototype.set=function(e,t,i,s){let a=e*this.size+t;this.data[a]=i,s&&(this.reservedBit[a]=!0)};ht.prototype.get=function(e,t){return this.data[e*this.size+t]};ht.prototype.xor=function(e,t,i){this.data[e*this.size+t]^=i};ht.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};Ua.exports=ht});var Ya=K(ri=>{var Ar=Ae().getSymbolSize;ri.getRowColCoords=function(t){if(t===1)return[];let i=Math.floor(t/7)+2,s=Ar(t),a=s===145?26:Math.ceil((s-13)/(2*i-2))*2,n=[s-7];for(let r=1;r<i-1;r++)n[r]=n[r-1]-a;return n.push(6),n.reverse()};ri.getPositions=function(t){let i=[],s=ri.getRowColCoords(t),a=s.length;for(let n=0;n<a;n++)for(let r=0;r<a;r++)n===0&&r===0||n===0&&r===a-1||n===a-1&&r===0||i.push([s[n],s[r]]);return i}});var Ga=K(Xa=>{var Mr=Ae().getSymbolSize,ja=7;Xa.getPositions=function(t){let i=Mr(t);return[[0,0],[i-ja,0],[0,i-ja]]}});var Ja=K(j=>{j.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var Fe={N1:3,N2:3,N3:40,N4:10};j.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7};j.from=function(t){return j.isValid(t)?parseInt(t,10):void 0};j.getPenaltyN1=function(t){let i=t.size,s=0,a=0,n=0,r=null,o=null;for(let l=0;l<i;l++){a=n=0,r=o=null;for(let h=0;h<i;h++){let u=t.get(l,h);u===r?a++:(a>=5&&(s+=Fe.N1+(a-5)),r=u,a=1),u=t.get(h,l),u===o?n++:(n>=5&&(s+=Fe.N1+(n-5)),o=u,n=1)}a>=5&&(s+=Fe.N1+(a-5)),n>=5&&(s+=Fe.N1+(n-5))}return s};j.getPenaltyN2=function(t){let i=t.size,s=0;for(let a=0;a<i-1;a++)for(let n=0;n<i-1;n++){let r=t.get(a,n)+t.get(a,n+1)+t.get(a+1,n)+t.get(a+1,n+1);(r===4||r===0)&&s++}return s*Fe.N2};j.getPenaltyN3=function(t){let i=t.size,s=0,a=0,n=0;for(let r=0;r<i;r++){a=n=0;for(let o=0;o<i;o++)a=a<<1&2047|t.get(r,o),o>=10&&(a===1488||a===93)&&s++,n=n<<1&2047|t.get(o,r),o>=10&&(n===1488||n===93)&&s++}return s*Fe.N3};j.getPenaltyN4=function(t){let i=0,s=t.data.length;for(let n=0;n<s;n++)i+=t.data[n];return Math.abs(Math.ceil(i*100/s/5)-10)*Fe.N4};function _r(e,t,i){switch(e){case j.Patterns.PATTERN000:return(t+i)%2===0;case j.Patterns.PATTERN001:return t%2===0;case j.Patterns.PATTERN010:return i%3===0;case j.Patterns.PATTERN011:return(t+i)%3===0;case j.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(i/3))%2===0;case j.Patterns.PATTERN101:return t*i%2+t*i%3===0;case j.Patterns.PATTERN110:return(t*i%2+t*i%3)%2===0;case j.Patterns.PATTERN111:return(t*i%3+(t+i)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}}j.applyMask=function(t,i){let s=i.size;for(let a=0;a<s;a++)for(let n=0;n<s;n++)i.isReserved(n,a)||i.xor(n,a,_r(t,n,a))};j.getBestMask=function(t,i){let s=Object.keys(j.Patterns).length,a=0,n=1/0;for(let r=0;r<s;r++){i(r),j.applyMask(r,t);let o=j.getPenaltyN1(t)+j.getPenaltyN2(t)+j.getPenaltyN3(t)+j.getPenaltyN4(t);j.applyMask(r,t),o<n&&(n=o,a=r)}return a}});var Os=K(Is=>{var Me=ni(),oi=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],li=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Is.getBlocksCount=function(t,i){switch(i){case Me.L:return oi[(t-1)*4+0];case Me.M:return oi[(t-1)*4+1];case Me.Q:return oi[(t-1)*4+2];case Me.H:return oi[(t-1)*4+3];default:return}};Is.getTotalCodewordsCount=function(t,i){switch(i){case Me.L:return li[(t-1)*4+0];case Me.M:return li[(t-1)*4+1];case Me.Q:return li[(t-1)*4+2];case Me.H:return li[(t-1)*4+3];default:return}}});var Qa=K(ui=>{var ut=new Uint8Array(512),hi=new Uint8Array(256);(function(){let t=1;for(let i=0;i<255;i++)ut[i]=t,hi[t]=i,t<<=1,t&256&&(t^=285);for(let i=255;i<512;i++)ut[i]=ut[i-255]})();ui.log=function(t){if(t<1)throw new Error("log("+t+")");return hi[t]};ui.exp=function(t){return ut[t]};ui.mul=function(t,i){return t===0||i===0?0:ut[hi[t]+hi[i]]}});var Za=K(ct=>{var Ps=Qa();ct.mul=function(t,i){let s=new Uint8Array(t.length+i.length-1);for(let a=0;a<t.length;a++)for(let n=0;n<i.length;n++)s[a+n]^=Ps.mul(t[a],i[n]);return s};ct.mod=function(t,i){let s=new Uint8Array(t);for(;s.length-i.length>=0;){let a=s[0];for(let r=0;r<i.length;r++)s[r]^=Ps.mul(i[r],a);let n=0;for(;n<s.length&&s[n]===0;)n++;s=s.slice(n)}return s};ct.generateECPolynomial=function(t){let i=new Uint8Array([1]);for(let s=0;s<t;s++)i=ct.mul(i,new Uint8Array([1,Ps.exp(s)]));return i}});var sn=K((Kh,tn)=>{var en=Za();function Hs(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Hs.prototype.initialize=function(t){this.degree=t,this.genPoly=en.generateECPolynomial(this.degree)};Hs.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");let i=new Uint8Array(t.length+this.degree);i.set(t);let s=en.mod(i,this.genPoly),a=this.degree-s.length;if(a>0){let n=new Uint8Array(this.degree);return n.set(s,a),n}return s};tn.exports=Hs});var Bs=K(an=>{an.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}});var Rs=K(Se=>{var nn="[0-9]+",Ir="[A-Z $%*+\\-./:]+",dt="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";dt=dt.replace(/u/g,"\\u");var Or="(?:(?![A-Z0-9 $%*+\\-./:]|"+dt+`)(?:.|[\r
|
|
2
|
+
]))+`;Se.KANJI=new RegExp(dt,"g");Se.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Se.BYTE=new RegExp(Or,"g");Se.NUMERIC=new RegExp(nn,"g");Se.ALPHANUMERIC=new RegExp(Ir,"g");var Pr=new RegExp("^"+dt+"$"),Hr=new RegExp("^"+nn+"$"),Br=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Se.testKanji=function(t){return Pr.test(t)};Se.testNumeric=function(t){return Hr.test(t)};Se.testAlphanumeric=function(t){return Br.test(t)}});var _e=K(Z=>{var Rr=Bs(),Ns=Rs();Z.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};Z.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};Z.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};Z.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};Z.MIXED={bit:-1};Z.getCharCountIndicator=function(t,i){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!Rr.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?t.ccBits[0]:i<27?t.ccBits[1]:t.ccBits[2]};Z.getBestModeForData=function(t){return Ns.testNumeric(t)?Z.NUMERIC:Ns.testAlphanumeric(t)?Z.ALPHANUMERIC:Ns.testKanji(t)?Z.KANJI:Z.BYTE};Z.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")};Z.isValid=function(t){return t&&t.bit&&t.ccBits};function Nr(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return Z.NUMERIC;case"alphanumeric":return Z.ALPHANUMERIC;case"kanji":return Z.KANJI;case"byte":return Z.BYTE;default:throw new Error("Unknown mode: "+e)}}Z.from=function(t,i){if(Z.isValid(t))return t;try{return Nr(t)}catch{return i}}});var un=K($e=>{var ci=Ae(),Fr=Os(),rn=ni(),Ie=_e(),Fs=Bs(),ln=7973,on=ci.getBCHDigit(ln);function $r(e,t,i){for(let s=1;s<=40;s++)if(t<=$e.getCapacity(s,i,e))return s}function hn(e,t){return Ie.getCharCountIndicator(e,t)+4}function Kr(e,t){let i=0;return e.forEach(function(s){let a=hn(s.mode,t);i+=a+s.getBitsLength()}),i}function zr(e,t){for(let i=1;i<=40;i++)if(Kr(e,i)<=$e.getCapacity(i,t,Ie.MIXED))return i}$e.from=function(t,i){return Fs.isValid(t)?parseInt(t,10):i};$e.getCapacity=function(t,i,s){if(!Fs.isValid(t))throw new Error("Invalid QR Code version");typeof s>"u"&&(s=Ie.BYTE);let a=ci.getSymbolTotalCodewords(t),n=Fr.getTotalCodewordsCount(t,i),r=(a-n)*8;if(s===Ie.MIXED)return r;let o=r-hn(s,t);switch(s){case Ie.NUMERIC:return Math.floor(o/10*3);case Ie.ALPHANUMERIC:return Math.floor(o/11*2);case Ie.KANJI:return Math.floor(o/13);case Ie.BYTE:default:return Math.floor(o/8)}};$e.getBestVersionForData=function(t,i){let s,a=rn.from(i,rn.M);if(Array.isArray(t)){if(t.length>1)return zr(t,a);if(t.length===0)return 1;s=t[0]}else s=t;return $r(s.mode,s.getLength(),a)};$e.getEncodedBits=function(t){if(!Fs.isValid(t)||t<7)throw new Error("Invalid QR Code version");let i=t<<12;for(;ci.getBCHDigit(i)-on>=0;)i^=ln<<ci.getBCHDigit(i)-on;return t<<12|i}});var mn=K(pn=>{var $s=Ae(),dn=1335,qr=21522,cn=$s.getBCHDigit(dn);pn.getEncodedBits=function(t,i){let s=t.bit<<3|i,a=s<<10;for(;$s.getBCHDigit(a)-cn>=0;)a^=dn<<$s.getBCHDigit(a)-cn;return(s<<10|a)^qr}});var gn=K((jh,fn)=>{var Ur=_e();function Qe(e){this.mode=Ur.NUMERIC,this.data=e.toString()}Qe.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Qe.prototype.getLength=function(){return this.data.length};Qe.prototype.getBitsLength=function(){return Qe.getBitsLength(this.data.length)};Qe.prototype.write=function(t){let i,s,a;for(i=0;i+3<=this.data.length;i+=3)s=this.data.substr(i,3),a=parseInt(s,10),t.put(a,10);let n=this.data.length-i;n>0&&(s=this.data.substr(i),a=parseInt(s,10),t.put(a,n*3+1))};fn.exports=Qe});var yn=K((Xh,vn)=>{var Wr=_e(),Ks=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ze(e){this.mode=Wr.ALPHANUMERIC,this.data=e}Ze.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Ze.prototype.getLength=function(){return this.data.length};Ze.prototype.getBitsLength=function(){return Ze.getBitsLength(this.data.length)};Ze.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let s=Ks.indexOf(this.data[i])*45;s+=Ks.indexOf(this.data[i+1]),t.put(s,11)}this.data.length%2&&t.put(Ks.indexOf(this.data[i]),6)};vn.exports=Ze});var kn=K((Gh,bn)=>{var Yr=_e();function et(e){this.mode=Yr.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}et.getBitsLength=function(t){return t*8};et.prototype.getLength=function(){return this.data.length};et.prototype.getBitsLength=function(){return et.getBitsLength(this.data.length)};et.prototype.write=function(e){for(let t=0,i=this.data.length;t<i;t++)e.put(this.data[t],8)};bn.exports=et});var Tn=K((Jh,wn)=>{var jr=_e(),Xr=Ae();function tt(e){this.mode=jr.KANJI,this.data=e}tt.getBitsLength=function(t){return t*13};tt.prototype.getLength=function(){return this.data.length};tt.prototype.getBitsLength=function(){return tt.getBitsLength(this.data.length)};tt.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let i=Xr.toSJIS(this.data[t]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
3
|
+
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),e.put(i,13)}};wn.exports=tt});var Cn=K((Qh,zs)=>{"use strict";var pt={single_source_shortest_paths:function(e,t,i){var s={},a={};a[t]=0;var n=pt.PriorityQueue.make();n.push(t,0);for(var r,o,l,h,u,c,d,g,p;!n.empty();){r=n.pop(),o=r.value,h=r.cost,u=e[o]||{};for(l in u)u.hasOwnProperty(l)&&(c=u[l],d=h+c,g=a[l],p=typeof a[l]>"u",(p||g>d)&&(a[l]=d,n.push(l,d),s[l]=o))}if(typeof i<"u"&&typeof a[i]>"u"){var f=["Could not find a path from ",t," to ",i,"."].join("");throw new Error(f)}return s},extract_shortest_path_from_predecessor_list:function(e,t){for(var i=[],s=t,a;s;)i.push(s),a=e[s],s=e[s];return i.reverse(),i},find_path:function(e,t,i){var s=pt.single_source_shortest_paths(e,t,i);return pt.extract_shortest_path_from_predecessor_list(s,i)},PriorityQueue:{make:function(e){var t=pt.PriorityQueue,i={},s;e=e||{};for(s in t)t.hasOwnProperty(s)&&(i[s]=t[s]);return i.queue=[],i.sorter=e.sorter||t.default_sorter,i},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var i={value:e,cost:t};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof zs<"u"&&(zs.exports=pt)});var Mn=K(it=>{var z=_e(),En=gn(),xn=yn(),Ln=kn(),Dn=Tn(),mt=Rs(),di=Ae(),Gr=Cn();function Sn(e){return unescape(encodeURIComponent(e)).length}function ft(e,t,i){let s=[],a;for(;(a=e.exec(i))!==null;)s.push({data:a[0],index:a.index,mode:t,length:a[0].length});return s}function An(e){let t=ft(mt.NUMERIC,z.NUMERIC,e),i=ft(mt.ALPHANUMERIC,z.ALPHANUMERIC,e),s,a;return di.isKanjiModeEnabled()?(s=ft(mt.BYTE,z.BYTE,e),a=ft(mt.KANJI,z.KANJI,e)):(s=ft(mt.BYTE_KANJI,z.BYTE,e),a=[]),t.concat(i,s,a).sort(function(r,o){return r.index-o.index}).map(function(r){return{data:r.data,mode:r.mode,length:r.length}})}function qs(e,t){switch(t){case z.NUMERIC:return En.getBitsLength(e);case z.ALPHANUMERIC:return xn.getBitsLength(e);case z.KANJI:return Dn.getBitsLength(e);case z.BYTE:return Ln.getBitsLength(e)}}function Jr(e){return e.reduce(function(t,i){let s=t.length-1>=0?t[t.length-1]:null;return s&&s.mode===i.mode?(t[t.length-1].data+=i.data,t):(t.push(i),t)},[])}function Qr(e){let t=[];for(let i=0;i<e.length;i++){let s=e[i];switch(s.mode){case z.NUMERIC:t.push([s,{data:s.data,mode:z.ALPHANUMERIC,length:s.length},{data:s.data,mode:z.BYTE,length:s.length}]);break;case z.ALPHANUMERIC:t.push([s,{data:s.data,mode:z.BYTE,length:s.length}]);break;case z.KANJI:t.push([s,{data:s.data,mode:z.BYTE,length:Sn(s.data)}]);break;case z.BYTE:t.push([{data:s.data,mode:z.BYTE,length:Sn(s.data)}])}}return t}function Zr(e,t){let i={},s={start:{}},a=["start"];for(let n=0;n<e.length;n++){let r=e[n],o=[];for(let l=0;l<r.length;l++){let h=r[l],u=""+n+l;o.push(u),i[u]={node:h,lastCount:0},s[u]={};for(let c=0;c<a.length;c++){let d=a[c];i[d]&&i[d].node.mode===h.mode?(s[d][u]=qs(i[d].lastCount+h.length,h.mode)-qs(i[d].lastCount,h.mode),i[d].lastCount+=h.length):(i[d]&&(i[d].lastCount=h.length),s[d][u]=qs(h.length,h.mode)+4+z.getCharCountIndicator(h.mode,t))}}a=o}for(let n=0;n<a.length;n++)s[a[n]].end=0;return{map:s,table:i}}function Vn(e,t){let i,s=z.getBestModeForData(e);if(i=z.from(t,s),i!==z.BYTE&&i.bit<s.bit)throw new Error('"'+e+'" cannot be encoded with mode '+z.toString(i)+`.
|
|
4
|
+
Suggested mode is: `+z.toString(s));switch(i===z.KANJI&&!di.isKanjiModeEnabled()&&(i=z.BYTE),i){case z.NUMERIC:return new En(e);case z.ALPHANUMERIC:return new xn(e);case z.KANJI:return new Dn(e);case z.BYTE:return new Ln(e)}}it.fromArray=function(t){return t.reduce(function(i,s){return typeof s=="string"?i.push(Vn(s,null)):s.data&&i.push(Vn(s.data,s.mode)),i},[])};it.fromString=function(t,i){let s=An(t,di.isKanjiModeEnabled()),a=Qr(s),n=Zr(a,i),r=Gr.find_path(n.map,"start","end"),o=[];for(let l=1;l<r.length-1;l++)o.push(n.table[r[l]].node);return it.fromArray(Jr(o))};it.rawSplit=function(t){return it.fromArray(An(t,di.isKanjiModeEnabled()))}});var In=K(_n=>{var mi=Ae(),Us=ni(),eo=qa(),to=Wa(),io=Ya(),so=Ga(),js=Ja(),Xs=Os(),ao=sn(),pi=un(),no=mn(),ro=_e(),Ws=Mn();function oo(e,t){let i=e.size,s=so.getPositions(t);for(let a=0;a<s.length;a++){let n=s[a][0],r=s[a][1];for(let o=-1;o<=7;o++)if(!(n+o<=-1||i<=n+o))for(let l=-1;l<=7;l++)r+l<=-1||i<=r+l||(o>=0&&o<=6&&(l===0||l===6)||l>=0&&l<=6&&(o===0||o===6)||o>=2&&o<=4&&l>=2&&l<=4?e.set(n+o,r+l,!0,!0):e.set(n+o,r+l,!1,!0))}}function lo(e){let t=e.size;for(let i=8;i<t-8;i++){let s=i%2===0;e.set(i,6,s,!0),e.set(6,i,s,!0)}}function ho(e,t){let i=io.getPositions(t);for(let s=0;s<i.length;s++){let a=i[s][0],n=i[s][1];for(let r=-2;r<=2;r++)for(let o=-2;o<=2;o++)r===-2||r===2||o===-2||o===2||r===0&&o===0?e.set(a+r,n+o,!0,!0):e.set(a+r,n+o,!1,!0)}}function uo(e,t){let i=e.size,s=pi.getEncodedBits(t),a,n,r;for(let o=0;o<18;o++)a=Math.floor(o/3),n=o%3+i-8-3,r=(s>>o&1)===1,e.set(a,n,r,!0),e.set(n,a,r,!0)}function Ys(e,t,i){let s=e.size,a=no.getEncodedBits(t,i),n,r;for(n=0;n<15;n++)r=(a>>n&1)===1,n<6?e.set(n,8,r,!0):n<8?e.set(n+1,8,r,!0):e.set(s-15+n,8,r,!0),n<8?e.set(8,s-n-1,r,!0):n<9?e.set(8,15-n-1+1,r,!0):e.set(8,15-n-1,r,!0);e.set(s-8,8,1,!0)}function co(e,t){let i=e.size,s=-1,a=i-1,n=7,r=0;for(let o=i-1;o>0;o-=2)for(o===6&&o--;;){for(let l=0;l<2;l++)if(!e.isReserved(a,o-l)){let h=!1;r<t.length&&(h=(t[r]>>>n&1)===1),e.set(a,o-l,h),n--,n===-1&&(r++,n=7)}if(a+=s,a<0||i<=a){a-=s,s=-s;break}}}function po(e,t,i){let s=new eo;i.forEach(function(l){s.put(l.mode.bit,4),s.put(l.getLength(),ro.getCharCountIndicator(l.mode,e)),l.write(s)});let a=mi.getSymbolTotalCodewords(e),n=Xs.getTotalCodewordsCount(e,t),r=(a-n)*8;for(s.getLengthInBits()+4<=r&&s.put(0,4);s.getLengthInBits()%8!==0;)s.putBit(0);let o=(r-s.getLengthInBits())/8;for(let l=0;l<o;l++)s.put(l%2?17:236,8);return mo(s,e,t)}function mo(e,t,i){let s=mi.getSymbolTotalCodewords(t),a=Xs.getTotalCodewordsCount(t,i),n=s-a,r=Xs.getBlocksCount(t,i),o=s%r,l=r-o,h=Math.floor(s/r),u=Math.floor(n/r),c=u+1,d=h-u,g=new ao(d),p=0,f=new Array(r),C=new Array(r),V=0,B=new Uint8Array(e.buffer);for(let I=0;I<r;I++){let P=I<l?u:c;f[I]=B.slice(p,p+P),C[I]=g.encode(f[I]),p+=P,V=Math.max(V,P)}let O=new Uint8Array(s),$=0,T,R;for(T=0;T<V;T++)for(R=0;R<r;R++)T<f[R].length&&(O[$++]=f[R][T]);for(T=0;T<d;T++)for(R=0;R<r;R++)O[$++]=C[R][T];return O}function fo(e,t,i,s){let a;if(Array.isArray(e))a=Ws.fromArray(e);else if(typeof e=="string"){let h=t;if(!h){let u=Ws.rawSplit(e);h=pi.getBestVersionForData(u,i)}a=Ws.fromString(e,h||40)}else throw new Error("Invalid data");let n=pi.getBestVersionForData(a,i);if(!n)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=n;else if(t<n)throw new Error(`
|
|
5
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
+
Minimum version required to store current data is: `+n+`.
|
|
7
|
+
`);let r=po(t,i,a),o=mi.getSymbolSize(t),l=new to(o);return oo(l,t),lo(l),ho(l,t),Ys(l,i,0),t>=7&&uo(l,t),co(l,r),isNaN(s)&&(s=js.getBestMask(l,Ys.bind(null,l,i))),js.applyMask(s,l),Ys(l,i,s),{modules:l,version:t,errorCorrectionLevel:i,maskPattern:s,segments:a}}_n.create=function(t,i){if(typeof t>"u"||t==="")throw new Error("No input text");let s=Us.M,a,n;return typeof i<"u"&&(s=Us.from(i.errorCorrectionLevel,Us.M),a=pi.from(i.version),n=js.from(i.maskPattern),i.toSJISFunc&&mi.setToSJISFunction(i.toSJISFunc)),fo(t,a,s,n)}});var Gs=K(Ke=>{function On(e){if(typeof e=="number"&&(e=e.toString()),typeof e!="string")throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||t.length===5||t.length>8)throw new Error("Invalid hex color: "+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(s){return[s,s]}))),t.length===6&&t.push("F","F");let i=parseInt(t.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+t.slice(0,6).join("")}}Ke.getOptions=function(t){t||(t={}),t.color||(t.color={});let i=typeof t.margin>"u"||t.margin===null||t.margin<0?4:t.margin,s=t.width&&t.width>=21?t.width:void 0,a=t.scale||4;return{width:s,scale:s?4:a,margin:i,color:{dark:On(t.color.dark||"#000000ff"),light:On(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}};Ke.getScale=function(t,i){return i.width&&i.width>=t+i.margin*2?i.width/(t+i.margin*2):i.scale};Ke.getImageWidth=function(t,i){let s=Ke.getScale(t,i);return Math.floor((t+i.margin*2)*s)};Ke.qrToImageData=function(t,i,s){let a=i.modules.size,n=i.modules.data,r=Ke.getScale(a,s),o=Math.floor((a+s.margin*2)*r),l=s.margin*r,h=[s.color.light,s.color.dark];for(let u=0;u<o;u++)for(let c=0;c<o;c++){let d=(u*o+c)*4,g=s.color.light;if(u>=l&&c>=l&&u<o-l&&c<o-l){let p=Math.floor((u-l)/r),f=Math.floor((c-l)/r);g=h[n[p*a+f]?1:0]}t[d++]=g.r,t[d++]=g.g,t[d++]=g.b,t[d]=g.a}}});var Pn=K(fi=>{var Js=Gs();function go(e,t,i){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=i,t.width=i,t.style.height=i+"px",t.style.width=i+"px"}function vo(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}fi.render=function(t,i,s){let a=s,n=i;typeof a>"u"&&(!i||!i.getContext)&&(a=i,i=void 0),i||(n=vo()),a=Js.getOptions(a);let r=Js.getImageWidth(t.modules.size,a),o=n.getContext("2d"),l=o.createImageData(r,r);return Js.qrToImageData(l.data,t,a),go(o,n,r),o.putImageData(l,0,0),n};fi.renderToDataURL=function(t,i,s){let a=s;typeof a>"u"&&(!i||!i.getContext)&&(a=i,i=void 0),a||(a={});let n=fi.render(t,i,a),r=a.type||"image/png",o=a.rendererOpts||{};return n.toDataURL(r,o.quality)}});var Rn=K(Bn=>{var yo=Gs();function Hn(e,t){let i=e.a/255,s=t+'="'+e.hex+'"';return i<1?s+" "+t+'-opacity="'+i.toFixed(2).slice(1)+'"':s}function Qs(e,t,i){let s=e+t;return typeof i<"u"&&(s+=" "+i),s}function bo(e,t,i){let s="",a=0,n=!1,r=0;for(let o=0;o<e.length;o++){let l=Math.floor(o%t),h=Math.floor(o/t);!l&&!n&&(n=!0),e[o]?(r++,o>0&&l>0&&e[o-1]||(s+=n?Qs("M",l+i,.5+h+i):Qs("m",a,0),a=0,n=!1),l+1<t&&e[o+1]||(s+=Qs("h",r),r=0)):a++}return s}Bn.render=function(t,i,s){let a=yo.getOptions(i),n=t.modules.size,r=t.modules.data,o=n+a.margin*2,l=a.color.light.a?"<path "+Hn(a.color.light,"fill")+' d="M0 0h'+o+"v"+o+'H0z"/>':"",h="<path "+Hn(a.color.dark,"stroke")+' d="'+bo(r,n,a.margin)+'"/>',u='viewBox="0 0 '+o+" "+o+'"',d='<svg xmlns="http://www.w3.org/2000/svg" '+(a.width?'width="'+a.width+'" height="'+a.width+'" ':"")+u+' shape-rendering="crispEdges">'+l+h+`</svg>
|
|
8
|
+
`;return typeof s=="function"&&s(null,d),d}});var Fn=K(gt=>{var ko=$a(),Zs=In(),Nn=Pn(),wo=Rn();function ea(e,t,i,s,a){let n=[].slice.call(arguments,1),r=n.length,o=typeof n[r-1]=="function";if(!o&&!ko())throw new Error("Callback required as last argument");if(o){if(r<2)throw new Error("Too few arguments provided");r===2?(a=i,i=t,t=s=void 0):r===3&&(t.getContext&&typeof a>"u"?(a=s,s=void 0):(a=s,s=i,i=t,t=void 0))}else{if(r<1)throw new Error("Too few arguments provided");return r===1?(i=t,t=s=void 0):r===2&&!t.getContext&&(s=i,i=t,t=void 0),new Promise(function(l,h){try{let u=Zs.create(i,s);l(e(u,t,s))}catch(u){h(u)}})}try{let l=Zs.create(i,s);a(null,e(l,t,s))}catch(l){a(l)}}gt.create=Zs.create;gt.toCanvas=ea.bind(null,Nn.render);gt.toDataURL=ea.bind(null,Nn.renderToDataURL);gt.toString=ea.bind(null,function(e,t,i){return wo.render(e,i)})});var Ta=e=>e||(typeof window<"u"&&window.HakumiComponentsConfig?.baseUrl?window.HakumiComponentsConfig.baseUrl:"/hakumi/components");var me=(e,t="hakumi-component")=>{if(!e.id){let i=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2,10);e.id=`${t}-${i}`}return e.id},Ca=e=>{let t=typeof e=="string"?document.querySelector(e):e;if(!t)throw new Error("[HakumiComponents] Target element not found");return t},ks=(e,t)=>{let i=document.createElement("template");i.innerHTML=String(e).trim();let s=i.content.firstElementChild;if(!s)throw new Error(`[HakumiComponents] Empty markup for ${t}`);return s},Sa=()=>new Promise(e=>requestAnimationFrame(e));var At=new Map,je=(e,t)=>{if(!e)throw new Error("[HakumiComponents] Missing id for registration");At.set(e,t),typeof window<"u"&&window.dispatchEvent(new CustomEvent("hakumi-component:registered",{detail:{id:e,instance:t}}))},Xe=e=>{e&&(At.delete(e),typeof window<"u"&&window.dispatchEvent(new CustomEvent("hakumi-component:unregistered",{detail:{id:e}})))},Ge=e=>At.get(e),Va=()=>Array.from(At.entries(),([e,t])=>({id:e,instance:t}));var vr=e=>`.hakumi-${e.replace(/_/g,"-")}`,ws=new Map,Ea=e=>{try{return sessionStorage.getItem(e)}catch{return null}},xa=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}},yr=e=>{try{sessionStorage.removeItem(e)}catch{}},br=()=>{try{return window.self!==window.top}catch{return!0}},Da=(e,t)=>`hakumi:rcache:${t}:${e}`,Ts=(e,t)=>`hakumi:rcachemeta:${t}:${e}`,La=e=>e?.hakumiComponent,kr=(e,t,i)=>{let s=Ea(Ts(e,t));if(!s)return null;let a;try{a=JSON.parse(s)}catch{return yr(Ts(e,t)),null}return!a?.ts||typeof a.ts!="number"||i!=null&&Date.now()-a.ts>i?null:Ea(Da(e,t))},wr=(e,t,i)=>{xa(Da(e,t),i),xa(Ts(e,t),JSON.stringify({ts:Date.now()}))},Aa=async(e,{params:t={},target:i=typeof document<"u"?document.body:null,format:s="html",baseUrl:a=null,mode:n="append",allowInIframe:r=!1,singletonSelector:o=vr,cache:l=!0,cacheTtlMs:h=5*60*1e3}={})=>{if(!r&&typeof window<"u"&&br())return{id:null,element:null,instance:null};if(!e)throw new Error("[HakumiComponents] Missing component name for render");if(!i)throw new Error("[HakumiComponents] Missing target for render");let u=o(e),c=document.querySelector(u),d=La(c);if(d?.singleton){let f=me(c,`hakumi-${e}`);d?.apply?.(t);let C=d?.api??Ge(f);return{id:f,element:c,instance:C}}let g=ws.get(u);if(g){let f=await g;return La(f.element)?.apply?.(t),f}let p=(async()=>{let f=Ca(i),C=e.replace(/-/g,"_"),V=new URL(`${Ta(a)}/${C}`,window.location?.origin||"http://localhost"),B={...t};n==="destroy_on_close"&&(B.destroy_on_close=!0),Object.entries(B).forEach(([q,U])=>{U!=null&&V.searchParams.set(q,U)});let O=null;if(l&&n!=="replace"){let q=kr(C,s,h);if(q)try{O=ks(q,e),O.setAttribute("data-hakumi-render-cache","1"),f.appendChild(O),me(O,`hakumi-${e}`)}catch{}}let T=await fetch(V,{headers:{Accept:s==="json"?"application/json":"text/html"}});if(!T.ok)throw new Error(`[HakumiComponents] Failed to render ${e}: ${T.status}`);let R=s==="json"?(await T.json()).html:await T.text();l&&wr(C,s,R);let I=ks(R,e);n==="replace"?(f.innerHTML="",f.appendChild(I)):O&&O.isConnected?O.replaceWith(I):f.appendChild(I);let P=me(I,`hakumi-${e}`);if(n==="destroy_on_close"){let q=()=>{I.remove(),Xe(P)};I.addEventListener("hakumi-component:hidden",q,{once:!0})}await Sa();let E=Ge(P);return E||(je(P,I),E=Ge(P)),I.hakumiComponent?.api&&(E=I.hakumiComponent.api),{id:P,element:I,instance:E}})();ws.set(u,p);try{return await p}finally{ws.delete(u)}};var Je={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}},remove(e){try{localStorage.removeItem(e)}catch{}}},Mt={get(e){let t=Je.get(e);if(!t)return null;try{return JSON.parse(t)}catch{return null}},set(e,t){try{Je.set(e,JSON.stringify(t))}catch{}}},Ma=!1,Ss=new Set,Cs=!1,_t=()=>{Cs||(Cs=!0,queueMicrotask(()=>{Cs=!1;for(let e of Ss)try{e()}catch{}}))},Tr=()=>{Ma||typeof document>"u"||(Ma=!0,document.addEventListener("turbo:load",_t),document.addEventListener("turbo:render",_t),window.addEventListener("popstate",_t),window.addEventListener("hashchange",_t))},_a=new Map,se={storage:{get:Je.get,set:Je.set,remove:Je.remove,getJson:Mt.get,setJson:Mt.set},save(e,{version:t=1,state:i}){if(i==null)return Je.remove(e);Mt.set(e,{v:t,state:i})},load(e){return Mt.get(e)},bootstrap(e,t){if(typeof e!="string"||e.length===0)throw new Error("[HakumiComponents] Persistence.bootstrap(key, fn) missing key");if(typeof t!="function")throw new Error("[HakumiComponents] Persistence.bootstrap(key, fn) expects a function");let i=_a.get(e);if(i)return i;let s=()=>{let n=this.load(e);if(n)try{t(n)}catch{}};s();let a=this.onNavigate(s);return _a.set(e,a),a},onNavigate(e){if(typeof document>"u")return()=>{};if(typeof e!="function")throw new Error("[HakumiComponents] Persistence.onNavigate(fn) expects a function");return Tr(),Ss.add(e),()=>Ss.delete(e)},ensureHost({id:e,controllerName:t,tagName:i="div",display:s="none",parent:a=()=>document.body}){if(typeof document>"u")return null;let n=document.getElementById(e);n||(n=document.createElement(i),n.id=e,n.style.display=s,a().appendChild(n));let r=(n.getAttribute("data-controller")||"").split(" ").filter(Boolean);return r.includes(t)||(r.push(t),n.setAttribute("data-controller",r.join(" "))),n}};var Re=()=>{if(typeof document>"u")return null;let e=document.getElementById("hakumi-overlay-root");if(e)return e;let t=document.createElement("div");return t.id="hakumi-overlay-root",t.setAttribute("data-hakumi-overlay-container",""),document.body?document.body.appendChild(t):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(t)}),t};var le=Dt(Ia(),1),Ha=Dt(Oa(),1),Ba=Dt(Pa(),1);le.default.extend(Ha.default);le.default.extend(Ba.default);var It="YYYY-MM-DD",Ot="YYYY-MM-DD HH:mm:ss",Pt="YYYY-MM-DD HH:mm",L=class{static getMondayOfWeek(t){return(0,le.default)(t).startOf("isoWeek")}static getISOWeek(t){return(0,le.default)(t).isoWeek()}static getISOWeekYear(t){return(0,le.default)(t).isoWeekYear()}static getSundayOfWeek(t){return(0,le.default)(t).endOf("isoWeek")}static formatDataDate(t){return(0,le.default)(t).format("YYYY-MM-DD")}static parseDataDate(t){return(0,le.default)(t)}static isInMonth(t,i,s){return t.month()+1===i&&t.year()===s}static isSameISOWeek(t,i){return t.isoWeek()===i.isoWeek()&&t.isoWeekYear()===i.isoWeekYear()}static getDatesInWeek(t){let i=this.getMondayOfWeek(t);return Array.from({length:7},(s,a)=>i.add(a,"day"))}static getMondayOfISOWeek(t,i){return(0,le.default)(`${t}-01-04`).startOf("isoWeek").add(i-1,"week")}static format(t,i){return t?(0,le.default)(t).format(i):""}static formatISO(t,i=!0){if(!t)return"";let s=i?Ot:Pt;return(0,le.default)(t).format(s)}static parse(t,i=null){return t?i?(0,le.default)(t,i):(0,le.default)(t):null}static isValid(t,i=null){let s=this.parse(t,i);return s&&s.isValid()}};import{Controller as Cr}from"@hotwired/stimulus";var m=class extends Cr{connect(){let t=this.isHakumiController();typeof this.registerApi=="function"?this.registerApi():t||(this.element.hakumiComponent||={name:this.componentName(),version:1,singleton:!1,api:{}}),me(this.element,this.defaultIdPrefix()),typeof this.setup=="function"&&this.setup(),this.validateContract(),je(this.element.id,this.element.hakumiComponent.api),this.element.hakumiComponent.singleton&&typeof window<"u"&&window.HakumiComponents&&(window.HakumiComponents[this.element.hakumiComponent.name]=this.element.hakumiComponent.api)}disconnect(){typeof this.teardown=="function"&&this.teardown();let t=this.element?.hakumiComponent;t?.singleton&&typeof window<"u"&&window.HakumiComponents&&window.HakumiComponents[t.name]===t.api&&delete window.HakumiComponents[t.name],this.element?.id&&Xe(this.element.id)}validateContract(){let t=this.isHakumiController(),i=this.element.hakumiComponent;if(t&&typeof this.registerApi!="function")throw new Error(`[HakumiComponents] ${this.identifier} must implement registerApi()`);if(!i)throw new Error(`[HakumiComponents] Missing hakumiComponent for ${this.identifier}`);if(!i.name)throw new Error(`[HakumiComponents] Missing hakumiComponent.name for ${this.identifier}`);if(i.version!==1)throw new Error(`[HakumiComponents] Unsupported hakumiComponent.version for ${i.name}`);if(typeof i.singleton!="boolean")throw new Error(`[HakumiComponents] hakumiComponent.singleton must be boolean (${i.name})`);if(!i.api||typeof i.api!="object")throw new Error(`[HakumiComponents] hakumiComponent.api must be object (${i.name})`);if(t&&Object.keys(i.api).length===0)throw new Error(`[HakumiComponents] hakumiComponent.api cannot be empty (${i.name})`);if(i.apply&&typeof i.apply!="function")throw new Error(`[HakumiComponents] hakumiComponent.apply must be function (${i.name})`);if(i.destroy&&typeof i.destroy!="function")throw new Error(`[HakumiComponents] hakumiComponent.destroy must be function (${i.name})`)}componentName(){return String(this.identifier||"").replace(/^hakumi--/,"").replace(/--/g,"_").replace(/-/g,"_")||"unknown"}defaultIdPrefix(){return`hakumi-${this.componentName()}`}isHakumiController(){return String(this.identifier||"").startsWith("hakumi--")}setup(){}teardown(){}registerApi(){}};var Ra={open:{true:"open",false:"closed"},visible:{true:"visible",false:"hidden"},active:{true:"active",false:"inactive"},expanded:{true:"expanded",false:"collapsed"},collapsed:{true:"collapsed",false:"expanded"},disabled:{true:"disabled",false:"enabled"}},Ms="hakumi:admin-panel",Ht=class extends m{static targets=["body","empty","summary","search","typeFilter","stateFilter"];static mount(){se.bootstrap(Ms,({state:e})=>{e.visible&&window.HakumiComponents.renderComponent("admin_panel")})}setup(){se.save(Ms,{version:1,state:{visible:!0}}),this.refresh(),this.updateLayout(),this.setupListeners()}setupListeners(){this.boundRefresh=this.refresh.bind(this),window.addEventListener("hakumi-component:registered",this.boundRefresh),window.addEventListener("hakumi-component:unregistered",this.boundRefresh)}updateLayout(){document.body.style.paddingBottom="400px"}teardown(){document.body.style.paddingBottom="0px",this.boundRefresh&&(window.removeEventListener("hakumi-component:registered",this.boundRefresh),window.removeEventListener("hakumi-component:unregistered",this.boundRefresh))}registerApi(){this.element.hakumiComponent={name:"admin_panel",version:1,singleton:!0,api:{refresh:()=>this.refresh(),close:()=>this.close()}}}refresh(e){e&&e.preventDefault(),this.updateLayout(),this.entries=this.fetchEntries(),this.updateFilterOptions(),this.applyFilters()}close(e){e&&e.preventDefault(),se.save(Ms,{version:1,state:{visible:!1}}),this.element.remove()}applyFilters(){let e=this.searchTarget.value.trim().toLowerCase(),t=this.typeFilterTarget.value,i=this.stateFilterTarget.value,s=this.entries.filter(a=>{let n=!e||a.id.toLowerCase().includes(e),r=!t||a.type===t,o=!i||a.state.label===i;return n&&r&&o});this.renderSummary(s.length,this.entries.length),this.renderTable(s)}invoke(e){e.preventDefault(),e.stopPropagation();let t=e.currentTarget,{id:i,method:s}=t.dataset;if(!i||!s)return;let a=window.HakumiComponents?.get?.(i);if(!a||typeof a[s]!="function")return;let n=[];if(t.tagName==="FORM"){let r=new FormData(t);n=Array.from(r.values()).map(o=>this.parseArgument(o))}try{a[s](...n)}catch(r){console.error(`[HakumiComponents] Failed to invoke ${s} on ${i}`,r)}this.refresh()}fetchEntries(){return window.HakumiComponents?.list?window.HakumiComponents.list().map(({id:e,instance:t})=>{let i=document.getElementById(e);if(!i)return null;let a=i.hakumiComponent?.name||"\u2014",n=this.buildState(i,t),r=this.collectMethods(t);return{id:e,type:a,state:n,methods:r}}).filter(Boolean):[]}updateFilterOptions(){let e=this.typeFilterTarget.value,t=this.stateFilterTarget.value,i=Array.from(new Set(this.entries.map(a=>a.type))).sort(),s=Array.from(new Set(this.entries.map(a=>a.state.label))).sort();this.populateSelect(this.typeFilterTarget,i,e),this.populateSelect(this.stateFilterTarget,s,t)}populateSelect(e,t,i){let s=t.includes(i)?i:"";e.querySelectorAll("option:not([value=''])").forEach(a=>a.remove()),t.forEach(a=>{let n=document.createElement("option");n.value=a,n.textContent=a,e.appendChild(n)}),e.value=s}renderSummary(e,t){this.summaryTarget.textContent=`${e} of ${t} components visible.`}renderTable(e){if(this.bodyTarget.innerHTML="",e.length===0){this.emptyTarget.hidden=!1;return}this.emptyTarget.hidden=!0,e.forEach(t=>{let i=document.createElement("tr");i.appendChild(this.buildTextCell(t.id)),i.appendChild(this.buildTextCell(t.type)),i.appendChild(this.buildStateCell(t.state)),i.appendChild(this.buildMethodsCell(t)),this.bodyTarget.appendChild(i)})}buildTextCell(e){let t=document.createElement("td");return t.textContent=e,t}buildStateCell(e){let t=document.createElement("td"),i=document.createElement("div");if(i.classList.add("hakumi-admin-panel__state"),i.textContent=e.label,t.appendChild(i),e.values&&Object.keys(e.values).length>0){let s=document.createElement("pre");s.classList.add("hakumi-admin-panel__state-values"),s.textContent=JSON.stringify(e.values,null,2),t.appendChild(s)}return t}buildMethodsCell(e){let t=document.createElement("td"),i=document.createElement("div");if(i.classList.add("hakumi-admin-panel__methods"),!e.methods||e.methods.length===0){let s=document.createElement("span");return s.classList.add("hakumi-admin-panel__method-empty"),s.textContent="No public API methods",i.appendChild(s),t.appendChild(i),t}return e.methods.forEach(s=>{i.appendChild(this.buildMethodEntry(e.id,s))}),t.appendChild(i),t}buildMethodEntry(e,t){let i=document.createElement("div");i.classList.add("hakumi-admin-panel__method-entry");let s=document.createElement("span");return s.classList.add("hakumi-admin-panel__method"),s.textContent=`${t.name}(${t.arity})`,i.appendChild(s),t.arity===0?i.appendChild(this.buildMethodButton(e,t.name)):i.appendChild(this.buildMethodForm(e,t)),i}buildMethodButton(e,t){let i=document.createElement("button");return i.type="button",i.classList.add("hakumi-admin-panel__action"),i.dataset.action="hakumi--admin-panel#invoke",i.dataset.id=e,i.dataset.method=t,i.textContent="Run",i}buildMethodForm(e,t){let i=document.createElement("form");i.classList.add("hakumi-admin-panel__action-form"),i.dataset.action="submit->hakumi--admin-panel#invoke",i.dataset.id=e,i.dataset.method=t.name;for(let a=0;a<t.arity;a+=1){let n=document.createElement("input");n.type="text",n.name=`arg-${a}`,n.placeholder=`arg${a+1}`,n.classList.add("hakumi-admin-panel__action-input"),i.appendChild(n)}let s=document.createElement("button");return s.type="submit",s.classList.add("hakumi-admin-panel__action"),s.textContent="Run",i.appendChild(s),i}collectMethods(e){return!e||typeof e!="object"?[]:Object.keys(e).filter(t=>typeof e[t]=="function").map(t=>({name:t,arity:e[t].length})).sort((t,i)=>t.name.localeCompare(i.name))}parseArgument(e){let t=String(e??"").trim();if(t!=="")try{return JSON.parse(t)}catch{return t}}buildState(e,t){let i=this.extractValues(e,t);return{label:this.detectStateLabel(e,i),values:i}}extractValues(e,t){let i={};if(!e)return i;let s=e.hakumiComponent?.name;if(!s)return i;let a=this.application.getControllerForElementAndIdentifier(e,`hakumi--${s.replace(/_/g,"-")}`);if(a){let n=a.constructor.values;n&&Object.keys(n).forEach(r=>{let o=`${r}Value`;o in a&&(i[r]=a[o])})}return typeof t?.getState=="function"&&Object.assign(i,t.getState()),i}detectStateLabel(e,t){if(!t)return"\u2014";if(t.label)return t.label;let i=Object.keys(Ra);for(let s of i)if(s in t)return Ra[s][t[s]]||"\u2014";return"\u2014"}};var Bt=class extends m{static targets=["placeholder","content"];static values={offsetTop:Number,offsetBottom:Number,targetSelector:String,zIndex:Number};setup(){this.affixed=!1,this.handleScroll=this.updatePosition.bind(this),this.handleResize=this.updatePosition.bind(this),this.scrollTarget=this.resolveTarget(),this.attachListeners(),this.updatePosition()}teardown(){this.detachListeners()}registerApi(){this.element.hakumiComponent={name:"affix",version:1,singleton:!1,api:{check:()=>this.updatePosition(),update:()=>this.updatePosition(),isAffixed:()=>this.affixed,getState:()=>({affixed:this.affixed,offsetTop:this.offsetTop,offsetBottom:this.offsetBottom,targetSelector:this.targetSelectorValue||null}),setOffsetTop:e=>this.setOffsetTop(e),setOffsetBottom:e=>this.setOffsetBottom(e)}},this.#e()}disconnect(){delete this.element.hakumiAffix,super.disconnect()}updatePosition(){if(!this.hasContentTarget||!this.hasPlaceholderTarget)return;this.offsetTop=this.resolveOffsetTop(),this.offsetBottom=this.resolveOffsetBottom();let e=this.offsetBottom!==null&&this.offsetBottom!==void 0,t=this.placeholderTarget.getBoundingClientRect(),i=this.contentTarget.getBoundingClientRect(),s=this.getTargetRect(),a=!1,n=null,r=null;if(e){let o=s.bottom-this.offsetBottom;a=t.bottom>=o,r=window.innerHeight-s.bottom+this.offsetBottom}else{let o=s.top+this.offsetTop;a=t.top<=o,n=o}a?this.applyAffix({top:n,bottom:r,placeholderRect:t,contentRect:i,useBottom:e}):this.resetAffix(),this.updateState(a,e)}setOffsetTop(e){this.offsetTopValue=Number(e||0),this.element.dataset.hakumiAffixOffsetTopValue=String(this.offsetTopValue),this.element.removeAttribute("data-hakumi--affix-offset-bottom-value"),this.offsetBottomValue=void 0,this.updatePosition()}setOffsetBottom(e){this.offsetBottomValue=Number(e||0),this.element.dataset.hakumiAffixOffsetBottomValue=String(this.offsetBottomValue),this.element.removeAttribute("data-hakumi--affix-offset-top-value"),this.offsetTopValue=void 0,this.updatePosition()}applyAffix({top:e,bottom:t,placeholderRect:i,contentRect:s,useBottom:a}){this.placeholderTarget.style.height=`${s.height}px`,this.placeholderTarget.style.width=`${s.width}px`,this.contentTarget.style.position="fixed",this.contentTarget.style.left=`${i.left}px`,this.contentTarget.style.width=`${i.width}px`,a?(this.contentTarget.style.bottom=`${t}px`,this.contentTarget.style.top=""):(this.contentTarget.style.top=`${e}px`,this.contentTarget.style.bottom=""),this.hasZIndexValue&&(this.contentTarget.style.zIndex=String(this.zIndexValue))}resetAffix(){this.placeholderTarget.style.height="",this.placeholderTarget.style.width="",this.contentTarget.style.position="",this.contentTarget.style.left="",this.contentTarget.style.top="",this.contentTarget.style.bottom="",this.contentTarget.style.width="",this.contentTarget.style.zIndex=""}updateState(e,t){let i=this.affixed!==e;this.affixed=e,this.element.classList.toggle("hakumi-affix-affixed",e),this.element.classList.toggle("hakumi-affix-affixed-top",e&&!t),this.element.classList.toggle("hakumi-affix-affixed-bottom",e&&t),i&&this.dispatch("change",{detail:{affixed:e,offsetTop:this.offsetTop,offsetBottom:this.offsetBottom}})}attachListeners(){(this.scrollTarget||window).addEventListener("scroll",this.handleScroll,{passive:!0}),window.addEventListener("resize",this.handleResize)}detachListeners(){(this.scrollTarget||window).removeEventListener("scroll",this.handleScroll),window.removeEventListener("resize",this.handleResize)}resolveTarget(){return this.hasTargetSelectorValue&&document.querySelector(this.targetSelectorValue)||window}getTargetRect(){return this.scrollTarget===window?{top:0,bottom:window.innerHeight}:this.scrollTarget.getBoundingClientRect()}resolveOffsetTop(){return this.hasOffsetBottomValue?0:this.hasOffsetTopValue?Number(this.offsetTopValue):0}resolveOffsetBottom(){return this.hasOffsetBottomValue?Number(this.offsetBottomValue):null}#e(){this.element.hakumiAffix={check:()=>this.updatePosition(),update:()=>this.updatePosition(),isAffixed:()=>this.affixed,getState:()=>({affixed:this.affixed,offsetTop:this.offsetTop,offsetBottom:this.offsetBottom,targetSelector:this.targetSelectorValue||null}),setOffsetTop:e=>this.setOffsetTop(e),setOffsetBottom:e=>this.setOffsetBottom(e)}}};var Rt=class extends m{static targets=["ink","link"];static values={offsetTop:{type:Number,default:0},targetOffset:{type:Number,default:0},bounds:{type:Number,default:5},replace:{type:Boolean,default:!1},direction:{type:String,default:"vertical"}};setup(){this.handleScroll=this.handleScroll.bind(this),this.scrollContainer=this.getScrollContainer(),this.scrollContainer.addEventListener("scroll",this.handleScroll,{passive:!0}),this.linkClickHandlers=new Map,requestAnimationFrame(()=>this.handleScroll())}teardown(){this.scrollContainer&&this.scrollContainer.removeEventListener("scroll",this.handleScroll),this.linkClickHandlers&&(this.linkClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.linkClickHandlers.clear())}registerApi(){this.element.hakumiComponent={name:"anchor",version:1,singleton:!1,api:{scrollTo:e=>this.scrollTo(e),setActive:e=>this.setActiveByHref(e),getActiveHref:()=>this.getActiveHref(),refresh:()=>this.handleScroll()}}}getScrollContainer(){return window}handleScroll(){let e=this.linkTargets;if(!e.length)return;let t=this.getScrollTop(),i=this.targetOffsetValue||this.offsetTopValue,s=null,a=null;for(let n of e){let r=n.dataset.href;if(!r||!r.startsWith("#"))continue;let o=r.slice(1),l=document.getElementById(o);if(!l)continue;l.getBoundingClientRect().top+t-this.getContainerTop()<=t+i+this.boundsValue&&(s=n,a=l)}this.updateActiveLink(s),this.updateInkPosition(s)}getScrollTop(){return this.scrollContainer===window?window.pageYOffset||document.documentElement.scrollTop:this.scrollContainer.scrollTop}getContainerTop(){return this.scrollContainer===window?0:this.scrollContainer.getBoundingClientRect().top}updateActiveLink(e){this.linkTargets.forEach(t=>{t.classList.remove("hakumi-anchor-link-active")}),e&&e.classList.add("hakumi-anchor-link-active")}updateInkPosition(e){if(!this.hasInkTarget)return;let t=this.inkTarget;if(!e){t.classList.remove("hakumi-anchor-ink-visible");return}if(t.classList.add("hakumi-anchor-ink-visible"),this.directionValue==="horizontal"){let i=this.element.getBoundingClientRect(),s=e.querySelector(".hakumi-anchor-link-title");if(s){let a=s.getBoundingClientRect();t.style.left=`${a.left-i.left}px`,t.style.width=`${a.width}px`}}else{let i=this.element.querySelector(".hakumi-anchor").getBoundingClientRect(),s=e.querySelector(".hakumi-anchor-link-title");if(s){let a=s.getBoundingClientRect();t.style.top=`${a.top-i.top}px`,t.style.height=`${a.height}px`}}}linkTargetConnected(e){let t=e.querySelector("a");if(t){let i=s=>this.handleLinkClick(s,e);this.linkClickHandlers?.set(t,i),t.addEventListener("click",i)}}linkTargetDisconnected(e){let t=e.querySelector("a");if(!t||!this.linkClickHandlers)return;let i=this.linkClickHandlers.get(t);i&&(t.removeEventListener("click",i),this.linkClickHandlers.delete(t))}handleLinkClick(e,t){let i=t.dataset.href;if(!i||!i.startsWith("#"))return;e.preventDefault();let s=i.slice(1),a=document.getElementById(s);if(!a)return;let n=this.targetOffsetValue||this.offsetTopValue,r=a.getBoundingClientRect().top+window.pageYOffset-n;window.scrollTo({top:r,behavior:"smooth"}),this.replaceValue?history.replaceState(null,"",i):history.pushState(null,"",i),this.updateActiveLink(t),this.updateInkPosition(t)}scrollTo(e){let t=e?.startsWith("#")?e:`#${e}`,i=this.linkTargets.find(s=>s.dataset.href===t);i&&this.handleLinkClick(new Event("click"),i)}setActiveByHref(e){let t=e?.startsWith("#")?e:`#${e}`,i=this.linkTargets.find(s=>s.dataset.href===t);i&&(this.updateActiveLink(i),this.updateInkPosition(i))}getActiveHref(){return this.linkTargets.find(t=>t.classList.contains("hakumi-anchor-link-active"))?.dataset?.href||null}};var Nt=class extends m{static values={visibilityHeight:{type:Number,default:400},targetSelector:String};setup(){this._isVisible=!1,this.handleScroll=this.checkVisibility.bind(this),this.targetElement=this.resolveTarget(),this.attachScrollListener(),this.checkVisibility()}teardown(){this.detachScrollListener()}registerApi(){this.element.hakumiComponent={name:"back_top",version:1,singleton:!1,api:{scrollToTop:()=>this.scroll(new Event("click")),check:()=>this.checkVisibility(),isVisible:()=>this._isVisible,getState:()=>({visible:this._isVisible,scrollTop:this.getScrollTop(),visibilityHeight:this.visibilityHeightValue})}}}scroll(e){e&&e.preventDefault();let t=this.resolveTarget();t===window||t===document.documentElement||t===document.body?window.scrollTo({top:0,behavior:"smooth"}):t.scrollTo({top:0,behavior:"smooth"})}checkVisibility(){let t=this.getScrollTop()>=this.visibilityHeightValue;this._isVisible=t,this.element.classList.toggle("is-visible",t)}attachScrollListener(){this.scrollContainer().addEventListener("scroll",this.handleScroll,{passive:!0})}detachScrollListener(){this.scrollContainer().removeEventListener("scroll",this.handleScroll)}scrollContainer(){return this.targetElement||window}resolveTarget(){return this.hasTargetSelectorValue&&document.querySelector(this.targetSelectorValue)||window}getScrollTop(){let e=this.scrollContainer();return e===window?window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0:e.scrollTop}};var Ft=class extends m{static targets=["panel"];static values={layout:String,resizable:Boolean};setup(){this.resizableValue&&(this.panels=this.panelTargets,this.isDragging=!1,this.currentPanel=null,this.startPos=0,this.startSize=0,this.boundResize=this.resize.bind(this),this.boundStopResize=this.stopResize.bind(this),this.initializeResizeBars())}teardown(){this.removeResizeBars(),document.removeEventListener("mousemove",this.boundResize),document.removeEventListener("mouseup",this.boundStopResize)}registerApi(){this.element.hakumiComponent={name:"splitter",version:1,singleton:!1,api:{getLayout:()=>this.layoutValue,getPanels:()=>this.panelTargets}}}initializeResizeBars(){this.panels.forEach((e,t)=>{if(t<this.panels.length-1){let i=this.createResizeBar(t);e.insertAdjacentElement("afterend",i)}})}createResizeBar(e){let t=document.createElement("div");return t.className=`hakumi-splitter-bar hakumi-splitter-bar-${this.layoutValue}`,t.dataset.panelIndex=e,t.addEventListener("mousedown",this.startResize.bind(this)),t}removeResizeBars(){this.element.querySelectorAll(".hakumi-splitter-bar").forEach(e=>{e.remove()})}startResize(e){e.preventDefault();let t=parseInt(e.currentTarget.dataset.panelIndex);this.currentPanel=this.panels[t],this.nextPanel=this.panels[t+1],this.layoutValue==="horizontal"?(this.startPos=e.clientX,this.startSize=this.currentPanel.offsetWidth,this.nextStartSize=this.nextPanel.offsetWidth):(this.startPos=e.clientY,this.startSize=this.currentPanel.offsetHeight,this.nextStartSize=this.nextPanel.offsetHeight),this.isDragging=!0,e.currentTarget.classList.add("hakumi-splitter-bar-dragging"),document.addEventListener("mousemove",this.boundResize),document.addEventListener("mouseup",this.boundStopResize),document.body.style.cursor=this.layoutValue==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none"}resize(e){if(!this.isDragging)return;let t=this.layoutValue==="horizontal"?e.clientX-this.startPos:e.clientY-this.startPos,i=this.startSize+t,s=this.nextStartSize-t,a=this.layoutValue==="horizontal"?this.element.offsetWidth:this.element.offsetHeight,o=(this.panels.length-1)*8,l=0;this.panels.forEach((p,f)=>{let C=Array.from(this.panels).indexOf(this.currentPanel),V=Array.from(this.panels).indexOf(this.nextPanel);if(f!==C&&f!==V){let B=this.layoutValue==="horizontal"?p.offsetWidth:p.offsetHeight;l+=B}});let h=a-o-l,u=this.currentPanel.getAttribute("data-hakumi--splitter-min-value"),c=this.currentPanel.getAttribute("data-hakumi--splitter-max-value"),d=this.nextPanel.getAttribute("data-hakumi--splitter-min-value"),g=this.nextPanel.getAttribute("data-hakumi--splitter-max-value");u&&i<parseInt(u)&&(i=parseInt(u)),c&&i>parseInt(c)&&(i=parseInt(c)),i<0&&(i=0),i>h&&(i=h),s=h-i,d&&s<parseInt(d)&&(s=parseInt(d),i=h-s),g&&s>parseInt(g)&&(s=parseInt(g),i=h-s),s<0&&(s=0),this.currentPanel.style.flex=`0 0 ${i}px`,this.nextPanel.style.flex=`0 0 ${s}px`,this.layoutValue==="horizontal"?(this.currentPanel.style.width=`${i}px`,this.nextPanel.style.width=`${s}px`):(this.currentPanel.style.height=`${i}px`,this.nextPanel.style.height=`${s}px`)}stopResize(e){this.isDragging&&(this.isDragging=!1,this.element.querySelectorAll(".hakumi-splitter-bar-dragging").forEach(t=>{t.classList.remove("hakumi-splitter-bar-dragging")}),document.removeEventListener("mousemove",this.boundResize),document.removeEventListener("mouseup",this.boundStopResize),document.body.style.cursor="",document.body.style.userSelect="")}};var $t=class extends m{static targets=["message","description"];registerApi(){this.element.hakumiComponent={name:"alert",version:1,singleton:!1,api:{close:()=>this.close(),setMessage:e=>this.setMessage(e),setDescription:e=>this.setDescription(e),getMessage:()=>this.getMessage(),getDescription:()=>this.getDescription()}}}close(e){e&&e.preventDefault(),this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0})),this.element.remove()}setMessage(e){this.hasMessageTarget&&(this.messageTarget.textContent=e)}setDescription(e){this.hasDescriptionTarget&&(this.descriptionTarget.textContent=e)}getMessage(){return this.hasMessageTarget?this.messageTarget.textContent:null}getDescription(){return this.hasDescriptionTarget?this.descriptionTarget.textContent:null}};var Kt=class extends m{static targets=["mask","wrapper","body"];static values={open:Boolean,placement:String,maskClosable:{type:Boolean,default:!0},keyboard:{type:Boolean,default:!0},destroyOnClose:{type:Boolean,default:!1}};setup(){let e=Re();e&&this.element.parentElement!==e&&e.appendChild(this.element),this.boundKeydown=this.handleKeydown.bind(this),document.addEventListener("keydown",this.boundKeydown),this.openValue||(this.element.style.display="none",this.element.classList.remove("hakumi-drawer-open"),this.element.setAttribute("aria-hidden","true")),this.handleOpenChange()}teardown(){this.closeTimeout&&clearTimeout(this.closeTimeout),document.removeEventListener("keydown",this.boundKeydown)}registerApi(){this.element.hakumiComponent={name:"drawer",version:1,singleton:!1,api:{open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),isOpen:()=>this.openValue,getState:()=>({open:this.openValue,placement:this.placementValue,maskClosable:this.maskClosableValue,keyboard:this.keyboardValue,destroyOnClose:this.destroyOnCloseValue})}}}open(){this.openValue=!0}close(){this.openValue=!1,this.dispatch("close")}toggle(){this.openValue=!this.openValue}openValueChanged(){this.handleOpenChange()}handleOpenChange(){this.openValue?(this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null),this.element.style.display="block",this.element.classList.add("hakumi-drawer-open"),this.element.removeAttribute("aria-hidden"),document.body.style.overflow="hidden",document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",this.hasWrapperTarget&&this.wrapperTarget.focus()):(this.element.classList.remove("hakumi-drawer-open"),this.closeTimeout=setTimeout(()=>{this.openValue||(this.element.style.display="none",this.element.setAttribute("aria-hidden","true"),document.body.style.overflow="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0}))),this.closeTimeout=null},300))}handleMaskClick(){this.maskClosableValue&&this.close()}handleKeydown(e){this.openValue&&this.keyboardValue&&e.key==="Escape"&&this.close()}};var Sr=3,Vr=200,zt=class extends m{static values={duration:Number,maxCount:Number,top:Number,payload:String};setup(){this.notices=new Map,this.noticeOrder=[],this.timers=new Map,this.#e(),this.#t()}teardown(){this.#m()}open(e={}){let t=this.#s(e);if(!t.message)return null;let i=t.key||this.#f();if(this.notices.has(i))return this.#u(i,t),i;let s=this.#n(t,i);return this.#r(i,s),this.#h(i,t.duration),i}success(e,t={}){return this.open({...t,message:e,type:"success"})}info(e,t={}){return this.open({...t,message:e,type:"info"})}warning(e,t={}){return this.open({...t,message:e,type:"warning"})}error(e,t={}){return this.open({...t,message:e,type:"error"})}loading(e,t={}){return this.open({...t,message:e,type:"loading"})}close(e){if(!e)return;let t=this.notices.get(e);t&&this.#l(e,t)}destroy(){this.noticeOrder.forEach(e=>{let t=this.notices.get(e);t&&this.#l(e,t,!0)}),this.noticeOrder=[]}getState(){return{count:this.noticeOrder.length,maxCount:this.maxCountValue||null,top:this.topValue||null}}#e(){this.hasTopValue&&this.element.style.setProperty("--hakumi-message-top",`${this.topValue}px`)}#t(){if(!this.hasPayloadValue||this.payloadValue.trim()===""||this.element.querySelector(".hakumi-message-notice"))return;let t=this.#i(this.payloadValue);t&&this.open(t)}#i(e){try{return JSON.parse(e)}catch(t){return console.warn("[HakumiComponents] Invalid message payload",t),null}}#s(e){let t=e.type||null,i=this.#a(e.duration,t),s=e.message??e.content;return{message:s?String(s):null,type:t,duration:i,key:e.key,icon:e.icon,closable:e.closable===!0||e.closable==="true"}}#a(e,t){return e===0||e==="0"?0:e?Number(e):t==="loading"?0:this.hasDurationValue?this.durationValue:Sr}#n(e,t){let i=document.createElement("div");i.className="hakumi-message-notice hakumi-message-notice-enter",i.dataset.key=t;let s=document.createElement("div");s.className="hakumi-message-notice-content";let a=document.createElement("div");a.className=this.#o(e.type);let n=this.#p(e.type,e.icon);if(n){let o=document.createElement("span");o.className="hakumi-message-icon",o.innerHTML=n,a.appendChild(o)}let r=document.createElement("span");if(r.className="hakumi-message-content",r.textContent=e.message,a.appendChild(r),s.appendChild(a),e.closable){let o=document.createElement("button");o.type="button",o.className="hakumi-message-close",o.setAttribute("aria-label","Close"),o.innerHTML=this.#v(),o.addEventListener("click",()=>this.close(t)),s.appendChild(o)}return i.appendChild(s),requestAnimationFrame(()=>{i.classList.add("hakumi-message-notice-enter-active"),i.classList.remove("hakumi-message-notice-enter")}),i}#o(e){let t=["hakumi-message-custom-content"];return e&&t.push(`hakumi-message-${e}`),t.join(" ")}#r(e,t){this.element.appendChild(t),this.notices.set(e,t),this.noticeOrder.push(e),this.#d()}#u(e,t){let i=this.notices.get(e);if(!i)return;let s=i.querySelector(".hakumi-message-notice-content");if(!s)return;let a=s.querySelector(".hakumi-message-custom-content");if(a){a.className=this.#o(t.type);let n=a.querySelector(".hakumi-message-icon"),r=this.#p(t.type,t.icon);if(r)if(n)n.innerHTML=r;else{let l=document.createElement("span");l.className="hakumi-message-icon",l.innerHTML=r,a.prepend(l)}else n&&n.remove();let o=a.querySelector(".hakumi-message-content");o&&(o.textContent=t.message)}this.#h(e,t.duration)}#h(e,t){if(this.timers.has(e)&&(clearTimeout(this.timers.get(e)),this.timers.delete(e)),t===0)return;let i=setTimeout(()=>{let s=this.notices.get(e);s&&this.#l(e,s)},t*1e3);this.timers.set(e,i)}#l(e,t,i=!1){this.timers.has(e)&&(clearTimeout(this.timers.get(e)),this.timers.delete(e));let s=()=>{t.remove(),this.notices.delete(e),this.noticeOrder=this.noticeOrder.filter(a=>a!==e),this.noticeOrder.length===0&&this.#c()};if(i){s();return}t.classList.add("hakumi-message-notice-leave"),requestAnimationFrame(()=>{t.classList.add("hakumi-message-notice-leave-active")}),setTimeout(s,Vr)}#c(){this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0}))}#d(){if(!this.maxCountValue||this.noticeOrder.length<=this.maxCountValue)return;let e=this.noticeOrder.length-this.maxCountValue;this.noticeOrder.slice(0,e).forEach(i=>{let s=this.notices.get(i);s&&this.#l(i,s)})}#m(){this.timers.forEach(e=>clearTimeout(e)),this.timers.clear()}#f(){return`hakumi-message-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}#p(e,t){if(t===!1||t==="none")return null;let i=t||e;return this.#g()[i]||null}#g(){return{success:'<span role="img" aria-label="check-circle" class="anticon anticon-check-circle"><svg viewBox="64 64 896 896" focusable="false" aria-hidden="true" width="1em" height="1em" fill="currentColor"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"></path></svg></span>',info:'<span role="img" aria-label="info-circle" class="anticon anticon-info-circle"><svg viewBox="64 64 896 896" focusable="false" aria-hidden="true" width="1em" height="1em" fill="currentColor"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"></path></svg></span>',warning:'<span role="img" aria-label="exclamation-circle" class="anticon anticon-exclamation-circle"><svg viewBox="64 64 896 896" focusable="false" aria-hidden="true" width="1em" height="1em" fill="currentColor"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"></path></svg></span>',error:'<span role="img" aria-label="close-circle" class="anticon anticon-close-circle"><svg fill-rule="evenodd" viewBox="64 64 896 896" focusable="false" aria-hidden="true" width="1em" height="1em" fill="currentColor"><path d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"></path></svg></span>',loading:'<span role="img" aria-label="loading" class="anticon anticon-loading"><svg viewBox="0 0 1024 1024" focusable="false" aria-hidden="true" width="1em" height="1em" fill="currentColor"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span>'}}#v(){return'<span role="img" aria-label="close" class="anticon anticon-close"><svg viewBox="64 64 896 896" focusable="false" aria-hidden="true" width="1em" height="1em" fill="currentColor"><path d="M563.8 512l262.5-312.9a8.7 8.7 0 00-1.4-12.2l-45.4-37.8a8.7 8.7 0 00-12.2 1.4L512 427.2 256.7 150.5a8.7 8.7 0 00-12.2-1.4l-45.4 37.8a8.7 8.7 0 00-1.4 12.2L460.2 512 197.7 824.9a8.7 8.7 0 001.4 12.2l45.4 37.8a8.7 8.7 0 0012.2-1.4L512 596.8l255.3 276.7a8.7 8.7 0 0012.2 1.4l45.4-37.8a8.7 8.7 0 001.4-12.2L563.8 512z"></path></svg></span>'}registerApi(){let e={open:t=>this.open(t),success:(t,i)=>this.success(t,i),info:(t,i)=>this.info(t,i),warning:(t,i)=>this.warning(t,i),error:(t,i)=>this.error(t,i),loading:(t,i)=>this.loading(t,i),close:t=>this.close(t),destroy:()=>this.destroy(),getState:()=>this.getState()};this.element.hakumiComponent={name:"message",version:1,singleton:!0,api:e,apply:(t={})=>(t&&Object.keys(t).length>0&&e.open(t),null)}}};var qt=class extends m{static targets=["mask","wrapper"];static values={open:Boolean,maskClosable:{type:Boolean,default:!0},keyboard:{type:Boolean,default:!0},confirmLoading:Boolean};setup(){let e=Re();e&&this.element.parentElement!==e&&e.appendChild(this.element),this.openValue||(this.element.style.display="none"),this.handleOpenChange(),this.boundHandleClick=this.handleClick.bind(this),this.element.addEventListener("click",this.boundHandleClick)}teardown(){this.animationTimeout&&clearTimeout(this.animationTimeout),this.element.removeEventListener("click",this.boundHandleClick)}registerApi(){let e={open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),isOpen:()=>this.openValue,getState:()=>({open:this.openValue,maskClosable:this.maskClosableValue,keyboard:this.keyboardValue,confirmLoading:this.confirmLoadingValue})};this.element.hakumiComponent={name:"modal",version:1,singleton:!1,api:e,destroy:()=>e.close()}}open(){this.openValue=!0}toggle(){this.openValue?this.close():this.open()}handleClick(e){let t=e.target.closest("[data-hakumi-modal-close]");e.target.closest("[data-hakumi-modal-ok]")&&this.handleOk(e),t&&this.close()}openValueChanged(){this.handleOpenChange()}handleOpenChange(){let e=this.element.querySelector(".hakumi-modal"),t=this.maskTarget;this.openValue?(this.element.style.display="block",document.body.style.overflow="hidden",document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",requestAnimationFrame(()=>{t&&(t.classList.remove("fade-leave","fade-leave-active"),t.classList.add("fade-enter","fade-enter-active")),e&&(e.classList.remove("hakumi-zoom-leave","hakumi-zoom-leave-active"),e.classList.add("hakumi-zoom-enter","hakumi-zoom-enter-active"))})):(t&&(t.classList.remove("fade-enter","fade-enter-active"),t.classList.add("fade-leave","fade-leave-active")),e&&(e.classList.remove("hakumi-zoom-enter","hakumi-zoom-enter-active"),e.classList.add("hakumi-zoom-leave","hakumi-zoom-leave-active")),this.animationTimeout=setTimeout(()=>{this.openValue||(this.element.style.display="none",document.body.style.overflow="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0}))),this.animationTimeout=null},300))}close(){this.openValue=!1,this.dispatch("cancel")}handleMaskClick(e){this.maskClosableValue&&this.close()}handleWrapperClick(e){e.target===this.wrapperTarget&&this.maskClosableValue&&this.close()}handleKeydown(e){this.keyboardValue&&e.key==="Escape"&&this.close()}handleOk(e){this.dispatch("ok")}handleCancel(e){this.close()}};var Ut=class extends m{static values={modalId:String};setup(){this.boundOpen=this.open.bind(this),this.element.addEventListener("click",this.boundOpen)}teardown(){this.element.removeEventListener("click",this.boundOpen),this.boundOpen=null}registerApi(){let e={open:()=>this.open(new Event("click")),getModalId:()=>this.modalIdValue};this.element.hakumiComponent={name:"modal_trigger",version:1,singleton:!1,api:e}}open(e){let t=document.getElementById(this.modalIdValue);if(!t){console.warn(`[HakumiComponents] Modal with ID '${this.modalIdValue}' not found`);return}let i=this.application.getControllerForElementAndIdentifier(t,"hakumi--modal");i&&(i.openValue=!0)}};var Er=4.5,xr=200,Na=new Set(["top","topLeft","topRight","bottom","bottomLeft","bottomRight"]),Wt="hakumi:notifications",Yt=class extends m{static values={duration:Number,maxCount:Number,top:Number,bottom:Number,placement:String,pauseOnHover:Boolean,showProgress:Boolean,stackThreshold:Number,payload:String};static mount(){se.bootstrap(Wt,({state:e})=>{e?.notices?.length>0&&se.ensureHost({id:"notification",controllerName:"hakumi--notification",display:"block"})})}setup(){this.notices=new Map,this.noticeOrder=[],this.timers=new Map,this.timerMeta=new Map,this._containers=new Map,this._config=this.#e(),this.#r(),this.#s(),this.#a()}teardown(){this.#E()}config(e={}){return this._config={...this._config,...this.#t(e)},this.#r(),this.getState()}open(e={}){let t=this.#o(e);if(!t.title)return null;let i=t.key||this.#D();if(t.key=i,this.notices.has(i))return this.#c(i,t),i;let s=this.#h(t);return this.#l(i,s,t.placement),this.#d(i,t.duration,t.pauseOnHover),this.#g(),this.#v(t.placement),t.duration===0&&this.#n(),i}success(e,t={}){return this.open({...this.#i(e,"success"),...t})}info(e,t={}){return this.open({...this.#i(e,"info"),...t})}warning(e,t={}){return this.open({...this.#i(e,"warning"),...t})}error(e,t={}){return this.open({...this.#i(e,"error"),...t})}close(e){let t=this.notices.get(e);t&&this.#p(e,t)}destroy(e=null){if(e){this.close(e);return}this.noticeOrder.forEach(t=>this.close(t))}getState(){return{count:this.noticeOrder.length,config:{...this._config}}}#e(){return this.#t({duration:this.hasDurationValue?this.durationValue:Er,maxCount:this.hasMaxCountValue?this.maxCountValue:null,top:this.hasTopValue?this.topValue:24,bottom:this.hasBottomValue?this.bottomValue:24,placement:this.hasPlacementValue?this.placementValue:"topRight",pauseOnHover:this.hasPauseOnHoverValue?this.pauseOnHoverValue:!0,showProgress:this.hasShowProgressValue?this.showProgressValue:!1,stackThreshold:this.hasStackThresholdValue?this.stackThresholdValue:3})}#t(e={}){let t={...e};return t.placement&&!Na.has(t.placement)&&(t.placement="topRight"),t}#i(e,t){return typeof e=="string"?{title:e,type:t}:{...e,type:t}}#s(){if(this.hasPayloadValue)try{let e=JSON.parse(this.payloadValue);e&&this.open(e)}catch{}}#a(){let e=se.load(Wt);e?.state?.notices&&e.state.notices.forEach(t=>{this.notices.has(t.key)||this.open({...t,_fromPersistence:!0})})}#n(){let e=Array.from(this.notices.keys()).map(t=>this.notices.get(t).__hakumi_payload).filter(t=>t&&t.duration===0);e.length>0?se.save(Wt,{version:1,state:{notices:e}}):se.storage.remove(Wt)}#o(e={}){let t=this._config,i=e.placement||t.placement;return{key:e.key,type:e.type||null,placement:Na.has(i)?i:"topRight",duration:e.duration!==void 0?Number(e.duration):t.duration,pauseOnHover:e.pauseOnHover!==void 0?!!e.pauseOnHover:t.pauseOnHover,showProgress:e.showProgress!==void 0?!!e.showProgress:t.showProgress,title:e.title||e.message||null,description:e.description||null,icon:e.icon??null,closeIcon:e.closeIcon,showClose:e.closeIcon!==!1,btn:e.btn||null,className:e.className||e.class||null,_fromPersistence:!!e._fromPersistence}}#r(){this.element.style.setProperty("--hakumi-notification-top",`${this._config.top}px`),this.element.style.setProperty("--hakumi-notification-bottom",`${this._config.bottom}px`)}#u(e){let t=e||"topRight",i=this._containers.get(t);return(!i||!i.isConnected)&&(i=document.createElement("div"),i.className=`hakumi-notification-container hakumi-notification-${t}`,this.element.appendChild(i),this._containers.set(t,i)),i}#h(e){let t=document.createElement("div");t.className="hakumi-notification-notice",e._fromPersistence?t.classList.add("hakumi-notification-notice-enter-active"):t.classList.add("hakumi-notification-notice-enter"),e.type&&t.classList.add(`hakumi-notification-notice-${e.type}`),e.className&&t.classList.add(e.className),t.__hakumi_payload=e;let i=this.#y(e.type,e.icon);i&&t.classList.add("hakumi-notification-notice-with-icon");let s=document.createElement("div");if(s.className="hakumi-notification-notice-content",i){let n=document.createElement("div");n.className="hakumi-notification-notice-icon",n.innerHTML=i,t.appendChild(n)}let a=document.createElement("div");if(a.className="hakumi-notification-notice-message",a.textContent=e.title,s.appendChild(a),e.description){let n=document.createElement("div");n.className="hakumi-notification-notice-description",n.textContent=e.description,s.appendChild(n)}if(e.btn){let n=document.createElement("div");n.className="hakumi-notification-notice-btn",e.btn instanceof Node?n.appendChild(e.btn):n.innerHTML=e.btn,s.appendChild(n)}if(t.appendChild(s),e.showClose){let n=document.createElement("button");n.className="hakumi-notification-notice-close",n.innerHTML=this.#w(e.closeIcon),n.onclick=r=>{r.stopPropagation(),this.close(e.key)},t.appendChild(n)}if(e.showProgress&&e.duration>0){let n=document.createElement("div");n.className="hakumi-notification-notice-progress",n.style.setProperty("--hakumi-notification-progress-duration-ms",`${e.duration*1e3}ms`),t.appendChild(n)}return t.onmouseenter=()=>this.#m(e.key),t.onmouseleave=()=>this.#f(e.key),e._fromPersistence||requestAnimationFrame(()=>{t.classList.add("hakumi-notification-notice-enter-active"),t.classList.remove("hakumi-notification-notice-enter")}),t}#l(e,t,i){this.#u(i).appendChild(t),this.notices.set(e,t),this.noticeOrder.push(e)}#c(e,t){let i=this.notices.get(e);i&&i.remove(),this.notices.delete(e),this.noticeOrder=this.noticeOrder.filter(s=>s!==e),this.open(t)}#d(e,t,i){if(this.#V(e),t<=0)return;let s=t*1e3,a=Date.now(),n=setTimeout(()=>this.close(e),s);this.timers.set(e,n),this.timerMeta.set(e,{startedAt:a,totalMs:s,remainingMs:s,paused:!1,pauseOnHover:i})}#m(e){let t=this.timerMeta.get(e);!t||!t.pauseOnHover||t.paused||(this.#V(e),t.remainingMs-=Date.now()-t.startedAt,t.paused=!0,this.notices.get(e)?.classList.add("hakumi-notification-notice-paused"))}#f(e){let t=this.timerMeta.get(e);if(!t||!t.paused)return;t.paused=!1,t.startedAt=Date.now();let i=setTimeout(()=>this.close(e),t.remainingMs);this.timers.set(e,i),this.notices.get(e)?.classList.remove("hakumi-notification-notice-paused")}#p(e,t){this.#V(e),t.classList.add("hakumi-notification-notice-leave-active"),setTimeout(()=>{let i=t.__hakumi_payload?.duration===0;t.remove(),this.notices.delete(e),this.noticeOrder=this.noticeOrder.filter(s=>s!==e),i&&this.#n(),this.noticeOrder.length===0&&this.#x()},xr)}#g(){let e=this._config.maxCount;e&&this.noticeOrder.length>e&&this.close(this.noticeOrder[0])}#v(e){let t=this._config.stackThreshold;if(!t)return;let i=this.#u(e),s=i.querySelectorAll(".hakumi-notification-notice");i.classList.toggle("hakumi-notification-stack",s.length>t)}#V(e){this.timers.has(e)&&(clearTimeout(this.timers.get(e)),this.timers.delete(e))}#E(){this.timers.forEach(e=>clearTimeout(e)),this.timers.clear()}#D(){return`hakumi-notice-${Math.random().toString(36).slice(2,9)}`}#x(){this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0}))}#y(e,t){return t===!1?null:typeof t=="string"&&t.startsWith("<")?t:{success:'<span class="anticon anticon-check-circle"><svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"></path></svg></span>',info:'<span class="anticon anticon-info-circle"><svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"></path></svg></span>',warning:'<span class="anticon anticon-exclamation-circle"><svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"></path></svg></span>',error:'<span class="anticon anticon-close-circle"><svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"></path></svg></span>'}[t||e]||null}#w(e){return e||'<span class="anticon anticon-close"><svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M563.8 512l262.5-312.9a8.7 8.7 0 00-1.4-12.2l-45.4-37.8a8.7 8.7 0 00-12.2 1.4L512 427.2 256.7 150.5a8.7 8.7 0 00-12.2-1.4l-45.4 37.8a8.7 8.7 0 00-1.4 12.2L460.2 512 197.7 824.9a8.7 8.7 0 001.4 12.2l45.4 37.8a8.7 8.7 0 0012.2-1.4L512 596.8l255.3 276.7a8.7 8.7 0 0012.2 1.4l45.4-37.8a8.7 8.7 0 001.4-12.2L563.8 512z"></path></svg></span>'}registerApi(){let e={open:t=>this.open(t),success:(t,i)=>this.success(t,i),info:(t,i)=>this.info(t,i),warning:(t,i)=>this.warning(t,i),error:(t,i)=>this.error(t,i),close:t=>this.close(t),destroy:t=>this.destroy(t),config:t=>this.config(t),getState:()=>this.getState()};this.element.hakumiComponent={name:"notification",version:1,singleton:!0,api:e,apply:(t={})=>(Object.keys(t).length>0&&e.open(t),null)}}};var jt=class extends m{static targets=["trigger","popover","okButton","cancelButton"];static values={placement:{type:String,default:"top"},trigger:{type:String,default:"click"},disabled:{type:Boolean,default:!1},open:{type:Boolean,default:!1},autoAdjustOverflow:{type:Boolean,default:!0}};registerApi(){this.element.hakumiComponent={name:"popconfirm",version:1,singleton:!1,api:{open:()=>this.open(),close:()=>this.close(),confirm:()=>this.confirm(),cancel:()=>this.cancel(),setLoading:e=>this.setLoading(e)}}}setup(){this.isOpen=this.openValue,this.isLoading=!1,this.setupTriggerEvents(),this.setupButtonEvents(),this._popover=this.popoverTarget,this.isOpen&&this.show()}teardown(){this.removeTriggerEvents(),this.removeButtonEvents(),this._popover&&this._popover.parentElement===document.body&&this.element.appendChild(this._popover)}setupTriggerEvents(){this.hasTriggerTarget&&(this.onTriggerClick=e=>{this.disabledValue||this.toggle()},this.onTriggerHoverEnter=()=>{this.disabledValue||this.show()},this.onTriggerHoverLeave=()=>{this.disabledValue||this.hide()},this.triggerValue==="click"?(this.triggerTarget.addEventListener("click",this.onTriggerClick),this.triggerTarget.setAttribute("aria-haspopup","true"),this.triggerTarget.setAttribute("aria-expanded","false"),this.onDocumentClick=e=>{if(!this.isOpen)return;this.element.contains(e.target)||this._popover&&this._popover.contains(e.target)||this.hide()},document.addEventListener("click",this.onDocumentClick)):this.triggerValue==="hover"&&(this.triggerTarget.addEventListener("mouseenter",this.onTriggerHoverEnter),this.triggerTarget.addEventListener("mouseleave",this.onTriggerHoverLeave)))}removeTriggerEvents(){this.hasTriggerTarget&&(this.triggerTarget.removeEventListener("click",this.onTriggerClick),this.triggerTarget.removeEventListener("mouseenter",this.onTriggerHoverEnter),this.triggerTarget.removeEventListener("mouseleave",this.onTriggerHoverLeave)),this.onDocumentClick&&document.removeEventListener("click",this.onDocumentClick)}setupButtonEvents(){this.handleConfirm=this.confirm.bind(this),this.handleCancel=this.cancel.bind(this),this.hasOkButtonTarget&&this.okButtonTarget.addEventListener("click",this.handleConfirm),this.hasCancelButtonTarget&&this.cancelButtonTarget.addEventListener("click",this.handleCancel)}removeButtonEvents(){this.hasOkButtonTarget&&this.okButtonTarget.removeEventListener("click",this.handleConfirm),this.hasCancelButtonTarget&&this.cancelButtonTarget.removeEventListener("click",this.handleCancel)}toggle(){this.isOpen?this.hide():this.show()}show(){if(this.disabledValue)return;this.isOpen=!0;let e=this._popover||this.popoverTarget;e.style.display="block",this.triggerTarget.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{e.classList.add("hakumi-popconfirm-visible"),this.#e()})}hide(){if(this.isLoading)return;this.isOpen=!1;let e=this._popover||this.popoverTarget;e.classList.remove("hakumi-popconfirm-visible"),this.triggerTarget.setAttribute("aria-expanded","false"),setTimeout(()=>{this.isOpen||(e.style.display="none",e.parentElement===document.body&&this.element.appendChild(e))},300),this.dispatch("hidden",{prefix:"hakumi-popconfirm"})}open(){this.show()}close(){this.hide()}async confirm(e){e&&e.stopPropagation();let t={api:this.element.hakumiComponent.api,promise:null};if(!this.dispatch("confirm",{cancelable:!0,prefix:"hakumi-popconfirm",detail:t}).defaultPrevented)if(t.promise&&typeof t.promise.then=="function")try{this.setLoading(!0),await t.promise,this.hide()}catch(s){console.error("[HakumiComponents] Popconfirm async error:",s),this.dispatch("confirm-error",{detail:{error:s},prefix:"hakumi-popconfirm"})}finally{this.setLoading(!1)}else this.isLoading||this.hide()}cancel(e){e&&e.stopPropagation(),this.dispatch("cancel",{prefix:"hakumi-popconfirm"}),this.hide()}setLoading(e){if(this.isLoading=e,this.hasOkButtonTarget){this.okButtonTarget.classList.toggle("hakumi-btn-loading",e),this.okButtonTarget.disabled=e;let t=this.okButtonTarget.querySelector(".anticon");t&&(t.style.display=e?"none":"")}}#e(){if(!this.hasTriggerTarget)return;let e=this.triggerTarget,t=this._popover||this.popoverTarget,i=8;t.parentElement!==document.body&&document.body.appendChild(t),t.style.visibility="hidden",t.style.display="block",t.style.position="absolute";let s=t.getBoundingClientRect();t.style.visibility="";let a={width:window.innerWidth,height:window.innerHeight},n=this.placementValue;if(n==="auto"&&(n=this._chooseBestPlacement(e,s,i,a)),this.autoAdjustOverflowValue){let l=c=>{let d=e.getBoundingClientRect(),g=this._calculateViewportCoords(c,d,s,i);return{top:g.top<0,bottom:g.top+s.height>a.height,left:g.left<0,right:g.left+s.width>a.width}},h=l(n),u=n.match(/^(top|bottom|left|right)/)[1];if(h[u]){let c={top:"bottom",bottom:"top",left:"right",right:"left"},d=n.replace(u,c[u]);l(d)[c[u]]||(n=d)}}let r=e.getBoundingClientRect(),o=this._calculateViewportCoords(n,r,s,i);t.style.top=`${o.top+window.scrollY}px`,t.style.left=`${o.left+window.scrollX}px`,t.style.zIndex="1030",t.setAttribute("data-hakumi--popconfirm-placement-value",n)}_chooseBestPlacement(e,t,i,s){let a=e.getBoundingClientRect(),n={top:a.top,bottom:s.height-a.bottom,left:a.left,right:s.width-a.right},r=t.width,o=t.height,l=h=>{let u=h==="top"||h==="bottom"?o:r;return n[h]>=u+i};return l("top")||l("bottom")?n.top>=n.bottom?"top":"bottom":l("left")||l("right")?n.left>=n.right?"left":"right":Object.entries(n).reduce((h,u)=>h[1]>u[1]?h:u)[0]}_calculateViewportCoords(e,t,i,s){let{top:a,left:n,width:r,height:o}=t,{width:l,height:h}=i,u=0,c=0;switch(e){case"top":case"topLeft":case"topRight":u=a-h-s;break;case"bottom":case"bottomLeft":case"bottomRight":u=a+o+s;break;case"left":case"leftTop":case"leftBottom":u=a+(o-h)/2,e==="leftTop"&&(u=a),e==="leftBottom"&&(u=a+o-h);break;case"right":case"rightTop":case"rightBottom":u=a+(o-h)/2,e==="rightTop"&&(u=a),e==="rightBottom"&&(u=a+o-h);break}switch(e){case"top":case"bottom":c=n+(r-l)/2;break;case"topLeft":case"bottomLeft":c=n;break;case"topRight":case"bottomRight":c=n+r-l;break;case"left":case"leftTop":case"leftBottom":c=n-l-s;break;case"right":case"rightTop":case"rightBottom":c=n+r+s;break}return{top:u,left:c}}};var Xt=class extends m{static targets=["trigger","popover","arrow"];static values={placement:{type:String,default:"top"},trigger:{type:String,default:"hover"},disabled:{type:Boolean,default:!1},open:{type:Boolean,default:void 0},arrow:{type:Boolean,default:!0},autoAdjustOverflow:{type:Boolean,default:!0}};registerApi(){let e={open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),isOpen:()=>this.isOpen,getState:()=>({open:this.isOpen,placement:this.placementValue,trigger:this.triggerModes,arrow:this.arrowValue,disabled:this.disabledValue}),setPlacement:t=>this.setPlacement(t),setOpen:t=>this.setOpen(t)};this.element.hakumiComponent={name:"popover",version:1,singleton:!1,api:e},this.#n(e)}setup(){this.isOpen=!1,this.hideTimeout=null,this.triggerModes=this.#s(),this._popover=this.popoverTarget,this.setupTriggerEvents(),this.hasOpenValue&&this.openValue!==void 0&&(this.isOpen=this.openValue,this.updateVisibility())}teardown(){this.removeTriggerEvents();let e=this.popoverElement;e&&e.parentElement===document.body&&this.element.appendChild(e)}disconnect(){delete this.element.hakumiPopover,super.disconnect()}setupTriggerEvents(){if(this.hasTriggerTarget){if(this.onTriggerClick=e=>{this.disabledValue||(e.preventDefault(),this.toggle())},this.onTriggerHoverEnter=()=>{this.disabledValue||(this.#i(),this.show())},this.onTriggerHoverLeave=()=>{this.disabledValue||this.#t()},this.onPopoverHoverEnter=()=>{this.disabledValue||(this.#i(),this.show())},this.onPopoverHoverLeave=()=>{this.disabledValue||this.#t()},this.triggerModes.includes("click")?(this.triggerTarget.addEventListener("click",this.onTriggerClick),this.triggerTarget.setAttribute("aria-haspopup","dialog"),this.triggerTarget.setAttribute("aria-expanded","false"),this.#o()):this.#r(),this.triggerModes.includes("hover")){this.triggerTarget.addEventListener("mouseenter",this.onTriggerHoverEnter),this.triggerTarget.addEventListener("mouseleave",this.onTriggerHoverLeave);let e=this.popoverElement;e&&(e.addEventListener("mouseenter",this.onPopoverHoverEnter),e.addEventListener("mouseleave",this.onPopoverHoverLeave))}this.triggerModes.includes("focus")&&(this.onTriggerFocusIn=()=>{this.disabledValue||this.show()},this.onTriggerFocusOut=()=>{this.disabledValue||this.hide()},this.triggerTarget.addEventListener("focusin",this.onTriggerFocusIn),this.triggerTarget.addEventListener("focusout",this.onTriggerFocusOut))}}removeTriggerEvents(){if(!this.hasTriggerTarget)return;this.triggerTarget.removeEventListener("click",this.onTriggerClick),this.triggerTarget.removeEventListener("mouseenter",this.onTriggerHoverEnter),this.triggerTarget.removeEventListener("mouseleave",this.onTriggerHoverLeave),this.triggerTarget.removeEventListener("focusin",this.onTriggerFocusIn),this.triggerTarget.removeEventListener("focusout",this.onTriggerFocusOut);let e=this.popoverElement;e&&(e.removeEventListener("mouseenter",this.onPopoverHoverEnter),e.removeEventListener("mouseleave",this.onPopoverHoverLeave)),this.#r()}show(){this.disabledValue||this.#a()||(this.isOpen=!0,this.updateVisibility())}hide(){this.disabledValue||this.#a()||(this.isOpen=!1,this.updateVisibility(),this.dispatch("hidden",{prefix:"hakumi-popover"}),this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0})))}open(){this.isOpen=!0,this.updateVisibility()}close(){this.isOpen=!1,this.updateVisibility(),this.dispatch("hidden",{prefix:"hakumi-popover"}),this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0}))}toggle(){if(this.#a()){this.setOpen(!this.isOpen);return}this.isOpen?this.hide():this.show()}updateVisibility(){let e=this.popoverElement;e&&(this.isOpen?(e.style.display="block",this.triggerTarget.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{e.classList.add("hakumi-popover-visible"),this.#e()})):(e.classList.remove("hakumi-popover-visible"),this.triggerTarget.setAttribute("aria-expanded","false"),setTimeout(()=>{this.isOpen||(e.style.display="none",e.parentElement===document.body&&this.element.appendChild(e))},300)))}openValueChanged(){this.openValue!==void 0&&(this.isOpen=this.openValue,this.updateVisibility())}setOpen(e){this.openValue=!!e,this.isOpen=this.openValue,this.updateVisibility()}setPlacement(e){this.placementValue=e,this.isOpen&&this.#e()}#e(){if(!this.hasTriggerTarget)return;let e=this.triggerTarget,t=this.popoverElement,i=this.arrowValue?8:4;t.parentElement!==document.body&&document.body.appendChild(t),t.style.visibility="hidden",t.style.display="block",t.style.position="absolute";let s=t.getBoundingClientRect();t.style.visibility="";let a={width:window.innerWidth,height:window.innerHeight},n=this.placementValue;if(n==="auto"&&(n=this._chooseBestPlacement(e,s,i,a)),this.autoAdjustOverflowValue){let l=d=>{let g=e.getBoundingClientRect(),p=this._calculateViewportCoords(d,g,s,i);return{top:p.top<0,bottom:p.top+s.height>a.height,left:p.left<0,right:p.left+s.width>a.width}},h=l(n),u=n.match(/^(top|bottom|left|right)/),c=u?u[1]:"top";if(h[c]){let d={top:"bottom",bottom:"top",left:"right",right:"left"},g=n.replace(c,d[c]);l(g)[d[c]]||(n=g)}}let r=e.getBoundingClientRect(),o=this._calculateViewportCoords(n,r,s,i);t.style.top=`${o.top+window.scrollY}px`,t.style.left=`${o.left+window.scrollX}px`,t.style.zIndex="1030",t.setAttribute("data-hakumi--popover-placement-value",n)}_chooseBestPlacement(e,t,i,s){let a=e.getBoundingClientRect(),n={top:a.top,bottom:s.height-a.bottom,left:a.left,right:s.width-a.right},r=t.width,o=t.height,l=h=>{let u=h==="top"||h==="bottom"?o:r;return n[h]>=u+i};return l("top")||l("bottom")?n.top>=n.bottom?"top":"bottom":l("left")||l("right")?n.left>=n.right?"left":"right":Object.entries(n).reduce((h,u)=>h[1]>u[1]?h:u)[0]}_calculateViewportCoords(e,t,i,s){let{top:a,left:n,width:r,height:o}=t,{width:l,height:h}=i,u=0,c=0;switch(e){case"top":case"topLeft":case"topRight":u=a-h-s;break;case"bottom":case"bottomLeft":case"bottomRight":u=a+o+s;break;case"left":case"leftTop":case"leftBottom":u=a+(o-h)/2,e==="leftTop"&&(u=a),e==="leftBottom"&&(u=a+o-h);break;case"right":case"rightTop":case"rightBottom":u=a+(o-h)/2,e==="rightTop"&&(u=a),e==="rightBottom"&&(u=a+o-h);break}switch(e){case"top":case"bottom":c=n+(r-l)/2;break;case"topLeft":case"bottomLeft":c=n;break;case"topRight":case"bottomRight":c=n+r-l;break;case"left":case"leftTop":case"leftBottom":c=n-l-s;break;case"right":case"rightTop":case"rightBottom":c=n+r+s;break}return{top:u,left:c}}#t(){this.#i(),this.hideTimeout=setTimeout(()=>this.hide(),120)}#i(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}get popoverElement(){return!this._popover&&this.hasPopoverTarget&&(this._popover=this.popoverTarget),this._popover}#s(){return this.triggerValue?this.triggerValue.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):[]}#a(){return this.hasOpenValue&&this.openValue!==void 0}#n(e){this.element.hakumiPopover={open:()=>e.open(),close:()=>e.close(),toggle:()=>e.toggle(),isOpen:()=>e.isOpen(),getState:()=>e.getState(),setPlacement:t=>e.setPlacement(t),setOpen:t=>e.setOpen(t)}}#o(){this.boundOutsideHandlers||!this.triggerModes.includes("click")||(this.boundOutsideHandlers={},this.#u().forEach(e=>{let t=i=>this.#h(i);this.boundOutsideHandlers[e]=t,document.addEventListener(e,t,!0)}))}#r(){this.boundOutsideHandlers&&(Object.entries(this.boundOutsideHandlers).forEach(([e,t])=>{document.removeEventListener(e,t,!0)}),this.boundOutsideHandlers=null)}#u(){return["pointerdown","mousedown","touchstart","click"]}#h(e){if(!this.isOpen||this.disabledValue||this.#a())return;let t=this.popoverElement,i=this.element.contains(e.target),s=t?.contains(e.target);!i&&!s&&this.hide()}};var Gt=class extends m{static values={percent:{type:Number,default:0},successPercent:{type:Number,default:0},type:{type:String,default:"line"},status:{type:String,default:"normal"},statusExplicit:{type:Boolean,default:!1},steps:{type:Number,default:0},gapDegree:{type:Number,default:0},gapPosition:{type:String,default:"top"},strokeWidth:{type:Number,default:0},showInfo:{type:Boolean,default:!0},customInfo:{type:Boolean,default:!1}};setup(){this.#a()}registerApi(){this.element.hakumiComponent={name:"progress",version:1,singleton:!1,api:{getPercent:()=>this.percentValue,setPercent:e=>this.setPercent(e),adjustPercent:e=>this.adjustPercent(e),increase:()=>this.increase(),decrease:()=>this.decrease(),getStatus:()=>this.statusValue,setStatus:e=>this.setStatus(e)}}}setPercent(e){let t=this.#t(e);t!==this.percentValue&&(this.percentValue=t,this.#i(),this.#a())}adjustPercent(e){let t=Number(e);return Number.isNaN(t)||t===0?this.percentValue:(this.setPercent(this.percentValue+t),this.percentValue)}increase(){return this.adjustPercent(this.#e())}decrease(){return this.adjustPercent(-this.#e())}setStatus(e){e&&(this.statusValue=e,this.#s())}#e(){return this.stepsValue>0?100/this.stepsValue:10}#t(e){let t=Number(e);return Number.isNaN(t)?0:Math.max(0,Math.min(100,t))}#i(){if(this.statusExplicitValue){this.#s();return}let e=this.percentValue>=100?"success":"normal";this.statusValue=e,this.#s()}#s(){let e="hakumi-progress-status-";this.element.classList.forEach(t=>{t.startsWith(e)&&this.element.classList.remove(t)}),this.element.classList.add(`${e}${this.statusValue}`)}#a(){this.element.setAttribute("aria-valuenow",String(this.percentValue)),this.typeValue==="line"?this.#n():this.#r(),this.#h()}#n(){if(this.stepsValue>0){this.#o();return}let e=this.element.querySelector(".hakumi-progress-bg");e&&(e.style.width=`${this.percentValue}%`);let t=this.element.querySelector(".hakumi-progress-success-bg");t&&(t.style.width=`${this.successPercentValue}%`)}#o(){let e=this.element.querySelectorAll(".hakumi-progress-steps-item"),t=this.stepsValue,i=this.percentValue/100*t;e.forEach((s,a)=>{let n=i>a,r=a===Math.floor(i)&&i<t;s.classList.toggle("hakumi-progress-steps-item-active",n),s.classList.toggle("hakumi-progress-steps-item-current",r)})}#r(){if(this.stepsValue>0){this.#u();return}let e=this.element.querySelector(".hakumi-progress-circle-path");if(!e)return;let i=50-(this.strokeWidthValue||6)/2,s=2*Math.PI*i,a=this.gapDegreeValue||(this.typeValue==="dashboard"?75:0),n=s*(a/360),o=(s-n)*(this.percentValue/100);e.setAttribute("stroke-dasharray",`${o.toFixed(2)} ${s.toFixed(2)}`),e.setAttribute("stroke-dashoffset",(n/2).toFixed(2))}#u(){let e=this.element.querySelectorAll(".hakumi-progress-circle-step"),t=this.stepsValue,i=this.percentValue/100*t;e.forEach(s=>{let a=Number(s.dataset.stepIndex||0),n=i>a,r=a===Math.floor(i)&&i<t;s.classList.toggle("hakumi-progress-circle-step-active",n),s.classList.toggle("hakumi-progress-circle-step-current",r)})}#h(){if(!this.showInfoValue||this.customInfoValue)return;let e=this.element.querySelector(".hakumi-progress-text");e&&(e.textContent=`${this.percentValue}%`)}};var Jt=class extends m{static targets=["overlay","container","text"];static values={spinning:{type:Boolean,default:!0},delay:{type:Number,default:0},percent:{type:String,default:""}};setup(){this.visibleSpinning=this.element.classList.contains("hakumi-spin-spinning"),this.progressElement=this.element.querySelector(".hakumi-progress"),this.#e()}registerApi(){this.element.hakumiComponent={name:"spin",version:1,singleton:!1,api:{show:()=>this.show(),hide:()=>this.hide(),toggle:()=>this.toggle(),isSpinning:()=>this.spinningValue,setPercent:e=>this.setPercent(e),setTip:e=>this.setTip(e)}},this.#s()}disconnect(){delete this.element.hakumiSpin,super.disconnect()}spinningValueChanged(){this.#e()}delayValueChanged(){this.#e()}show(){this.spinningValue=!0}hide(){this.spinningValue=!1}toggle(){this.spinningValue=!this.spinningValue}setPercent(e){e!=null&&(this.percentValue=String(e),this.#i(e))}setTip(e){this.hasTextTarget&&(this.textTarget.textContent=e,this.element.classList.toggle("hakumi-spin-show-text",!!e))}#e(){if(this.delayTimeout&&(clearTimeout(this.delayTimeout),this.delayTimeout=null),!this.spinningValue){this.#t(!1);return}let e=this.delayValue||0;if(e>0){this.#t(!1,{silent:!0}),this.delayTimeout=setTimeout(()=>{this.spinningValue&&this.#t(!0)},e);return}this.#t(!0)}#t(e,{silent:t}={}){this.element.classList.toggle("hakumi-spin-spinning",e),this.element.setAttribute("aria-busy",this.spinningValue?"true":"false"),this.visibleSpinning&&!e&&!t&&this.element.dispatchEvent(new CustomEvent("hakumi-component:hidden",{bubbles:!0})),this.visibleSpinning=e}#i(e){if(!this.progressElement)return;let t=this.progressElement.hakumiComponent?.api;if(t&&typeof t.setPercent=="function"){t.setPercent(e);return}this.progressElement.setAttribute("aria-valuenow",String(e))}#s(){this.element.hakumiSpin={show:()=>this.show(),hide:()=>this.hide(),toggle:()=>this.toggle(),isSpinning:()=>this.spinningValue,setPercent:e=>this.setPercent(e),setTip:e=>this.setTip(e)}}};var Qt=class extends m{static targets=["trigger","tooltip"];static values={placement:{type:String,default:"top"},trigger:{type:String,default:"hover"},arrow:{type:Boolean,default:!0},open:{type:Boolean,default:void 0},fresh:{type:Boolean,default:!1},color:{type:String,default:""}};setup(){this.isOpen=!1,this.setupTriggerEvents(),this.hasOpenValue&&this.openValue!==void 0&&(this.isOpen=this.openValue,this.updateVisibility()),this.colorValue&&this.applyCustomColor(this.colorValue)}teardown(){this.removeTriggerEvents()}registerApi(){this.element.hakumiComponent={name:"tooltip",version:1,singleton:!1,api:{open:()=>this.open(),close:()=>this.close(),show:()=>this.show(),hide:()=>this.hide(),toggle:()=>this.toggle(),isOpen:()=>this.isOpen,getState:()=>({open:this.isOpen,placement:this.placementValue,color:this.colorValue}),setPlacement:e=>this.setPlacement(e),setColor:e=>this.setColor(e)}}}setupTriggerEvents(){if(this.hasTriggerTarget)switch(this.triggerValue){case"hover":this.triggerTarget.addEventListener("mouseenter",this.boundShow=this.show.bind(this)),this.triggerTarget.addEventListener("mouseleave",this.boundHide=this.hide.bind(this)),this.hasTooltipTarget&&(this.tooltipTarget.addEventListener("mouseenter",this.boundTooltipShow=this.show.bind(this)),this.tooltipTarget.addEventListener("mouseleave",this.boundTooltipHide=this.hide.bind(this)));break;case"focus":this.triggerTarget.addEventListener("focusin",this.boundShow=this.show.bind(this)),this.triggerTarget.addEventListener("focusout",this.boundHide=this.hide.bind(this));break;case"click":this.triggerTarget.addEventListener("click",this.boundToggle=this.toggle.bind(this)),document.addEventListener("click",this.boundDocumentClick=this.handleDocumentClick.bind(this));break}}removeTriggerEvents(){if(this.hasTriggerTarget)switch(this.triggerValue){case"hover":this.boundShow&&this.triggerTarget.removeEventListener("mouseenter",this.boundShow),this.boundHide&&this.triggerTarget.removeEventListener("mouseleave",this.boundHide),this.hasTooltipTarget&&(this.boundTooltipShow&&this.tooltipTarget.removeEventListener("mouseenter",this.boundTooltipShow),this.boundTooltipHide&&this.tooltipTarget.removeEventListener("mouseleave",this.boundTooltipHide));break;case"focus":this.boundShow&&this.triggerTarget.removeEventListener("focusin",this.boundShow),this.boundHide&&this.triggerTarget.removeEventListener("focusout",this.boundHide);break;case"click":this.boundToggle&&this.triggerTarget.removeEventListener("click",this.boundToggle),this.boundDocumentClick&&document.removeEventListener("click",this.boundDocumentClick);break}}show(){this.hasOpenValue&&this.openValue!==void 0&&!this.freshValue||(this.isOpen=!0,this.updateVisibility(),this.dispatch("show"))}hide(){this.hasOpenValue&&this.openValue!==void 0&&!this.freshValue||(this.isOpen=!1,this.updateVisibility(),this.dispatch("hide"))}open(){this.show()}close(){this.hide()}toggle(){this.isOpen?this.hide():this.show()}handleDocumentClick(e){!this.element.contains(e.target)&&this.isOpen&&this.hide()}updateVisibility(){this.hasTooltipTarget&&(this.isOpen?(this.applyPlacement(this.placementValue),this.element.classList.add("hakumi-tooltip-open"),this.tooltipTarget.classList.add("hakumi-tooltip-visible"),requestAnimationFrame(()=>this.autoShift())):(this.element.classList.remove("hakumi-tooltip-open"),this.tooltipTarget.classList.remove("hakumi-tooltip-visible")))}autoShift(){if(!this.hasTooltipTarget||!this.isOpen)return;let t=this.tooltipTarget.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,a=8,n=this.placementValue,r=t.top<a,o=t.bottom>s-a,l=t.left<a,h=t.right>i-a;r&&n.startsWith("top")?n=n.replace("top","bottom"):o&&n.startsWith("bottom")&&(n=n.replace("bottom","top")),l&&n.startsWith("left")?n=n.replace("left","right"):h&&n.startsWith("right")&&(n=n.replace("right","left")),n!==this.placementValue&&this.applyPlacement(n)}applyPlacement(e){if(!this.hasTooltipTarget)return;["top","top-left","top-right","bottom","bottom-left","bottom-right","left","left-top","left-bottom","right","right-top","right-bottom"].forEach(i=>{this.tooltipTarget.classList.remove(`hakumi-tooltip-placement-${i}`)}),this.tooltipTarget.classList.add(`hakumi-tooltip-placement-${e}`)}setPlacement(e){if(!this.hasTooltipTarget)return;let t=`hakumi-tooltip-placement-${this.placementValue}`;this.tooltipTarget.classList.remove(t),this.placementValue=e;let i=`hakumi-tooltip-placement-${e}`;this.tooltipTarget.classList.add(i)}openValueChanged(){this.openValue!==void 0&&(this.isOpen=this.openValue,this.updateVisibility())}setColor(e){this.colorValue=e,this.applyCustomColor(e)}applyCustomColor(e){if(!this.hasTooltipTarget||!e)return;let t=this.tooltipTarget.querySelector(".hakumi-tooltip-inner"),i=this.tooltipTarget.querySelector(".hakumi-tooltip-arrow");t&&(t.style.backgroundColor=e,t.style.color=this.#e(e)),i&&(i.style.borderColor=`${e} transparent`)}#e(e){let t=this.#t(e);if(!t)return"#fff";let[i,s,a]=t.map(r=>r/255);return .299*i+.587*s+.114*a>.5?"rgba(0, 0, 0, 0.88)":"#fff"}#t(e){if(e.startsWith("#")){let t=e.slice(1);return t.length===3&&(t=t.split("").map(i=>i+i).join("")),t.length!==6?null:[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}if(e.startsWith("rgb")){let t=e.match(/\d+/g);if(t&&t.length>=3)return t.slice(0,3).map(Number)}return null}};var Zt=class extends m{static targets=["mask","panel","title","body","progress","prev","next","finish","close","arrow"];static values={open:{type:Boolean,default:!1},current:{type:Number,default:0},steps:{type:Array,default:[]},placement:{type:String,default:"bottom"},mask:{type:Boolean,default:!0},maskClosable:{type:Boolean,default:!0},closable:{type:Boolean,default:!0},showProgress:{type:Boolean,default:!0}};registerApi(){let e={open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),isOpen:()=>this.openValue,next:()=>this.next(),prev:()=>this.prev(),goTo:t=>this.goTo(t),getCurrent:()=>this.currentIndex,getState:()=>({open:this.openValue,current:this.currentIndex,steps:this.stepsValue,placement:this.placementValue})};this.element.hakumiComponent={name:"tour",version:1,singleton:!1,api:e}}setup(){this.currentIndex=this.currentValue||0,this.activeTarget=null,this.lastFocused=null,this.scrollPosition={top:0,left:0},this.timeouts=[],this.boundHandleKeydown=this.handleKeydown.bind(this),this.boundHandleResize=this.positionPanel.bind(this),this.boundHandleScroll=this.handleScroll.bind(this),this.boundHandlePrev=()=>this.prev(),this.boundHandleNext=()=>this.next(),this.boundHandleFinish=()=>this.finish(),this.boundHandleClose=()=>this.close(),this.boundHandleMask=()=>this.handleMaskClick(),this.hasPrevTarget&&this.prevTarget.addEventListener("click",this.boundHandlePrev),this.hasNextTarget&&this.nextTarget.addEventListener("click",this.boundHandleNext),this.hasFinishTarget&&this.finishTarget.addEventListener("click",this.boundHandleFinish),this.hasCloseTarget&&this.closeTarget.addEventListener("click",this.boundHandleClose),this.hasMaskTarget&&this.maskTarget.addEventListener("click",this.boundHandleMask),this.updateStep(),this.updateVisibility()}teardown(){this.hasPrevTarget&&this.prevTarget.removeEventListener("click",this.boundHandlePrev),this.hasNextTarget&&this.nextTarget.removeEventListener("click",this.boundHandleNext),this.hasFinishTarget&&this.finishTarget.removeEventListener("click",this.boundHandleFinish),this.hasCloseTarget&&this.closeTarget.removeEventListener("click",this.boundHandleClose),this.hasMaskTarget&&this.maskTarget.removeEventListener("click",this.boundHandleMask),document.removeEventListener("keydown",this.boundHandleKeydown),window.removeEventListener("resize",this.boundHandleResize),window.removeEventListener("scroll",this.boundHandleScroll,!0),this.clearTimeouts(),this.unlockScroll(),this.updateTargetHighlight(null)}clearTimeouts(){this.timeouts&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[])}safeSetTimeout(e,t){let i=setTimeout(e,t);return this.timeouts&&this.timeouts.push(i),i}open(){this.openValue=!0,this.dispatch("open")}close(){this.openValue=!1,this.dispatch("close")}toggle(){this.openValue?this.close():this.open()}next(){this.currentIndex>=this.stepsValue.length-1||this.goTo(this.currentIndex+1)}prev(){this.currentIndex<=0||this.goTo(this.currentIndex-1)}goTo(e){let t=Math.max(0,Math.min(Number(e)||0,this.stepsValue.length-1));t!==this.currentIndex&&(this.currentIndex=t,this.currentValue=t,this.dispatch("change",{detail:{current:this.currentIndex}}))}finish(){this.dispatch("finish",{detail:{current:this.currentIndex}}),this.close()}openValueChanged(){this.updateVisibility()}currentValueChanged(){this.currentIndex=this.currentValue||0,this.updateStep()}updateVisibility(){this.element.classList.toggle("hakumi-tour-open",this.openValue),this.openValue?(this.scrollTargetIntoView(),this.safeSetTimeout(()=>{typeof window>"u"||typeof document>"u"||(this.lockScroll(),this.lastFocused=document.activeElement,this.hasPanelTarget&&this.panelTarget.focus({preventScroll:!0}),this.boundHandleKeydown&&document.addEventListener("keydown",this.boundHandleKeydown),this.boundHandleResize&&window.addEventListener("resize",this.boundHandleResize),this.boundHandleScroll&&window.addEventListener("scroll",this.boundHandleScroll,!0),this.updateTargetHighlight(this.currentStep.target),requestAnimationFrame(()=>this.positionPanel()))},100)):(this.unlockScroll(),this.boundHandleKeydown&&document.removeEventListener("keydown",this.boundHandleKeydown),this.boundHandleResize&&window.removeEventListener("resize",this.boundHandleResize),this.boundHandleScroll&&window.removeEventListener("scroll",this.boundHandleScroll,!0),this.updateTargetHighlight(null),this.restoreFocus()),this.updateMaskVisibility()}updateStep(){let e=this.currentStep;this.hasTitleTarget&&(this.titleTarget.textContent=e.title||""),this.hasBodyTarget&&(this.bodyTarget.textContent=e.body||""),this.hasProgressTarget&&(this.progressTarget.textContent=this.showProgressValue&&this.stepsValue.length>0?`${this.currentIndex+1} / ${this.stepsValue.length}`:"",this.progressTarget.style.display=this.showProgressValue?"":"none"),this.hasCloseTarget&&(this.closeTarget.style.display=this.closableValue?"":"none"),this.updateButtons(),this.setPlacement(e.placement||this.placementValue),this.openValue&&(this.scrollTargetIntoView(),this.updateTargetHighlight(e.target))}updateButtons(){let e=this.currentIndex<=0,t=this.currentIndex>=this.stepsValue.length-1;this.hasPrevTarget&&(this.prevTarget.disabled=e),this.hasNextTarget&&(this.nextTarget.style.display=t?"none":""),this.hasFinishTarget&&(this.finishTarget.style.display=t?"":"none")}lockScroll(){if(typeof window>"u"||typeof document>"u")return;this.scrollPosition={top:window.pageYOffset||document.documentElement.scrollTop,left:window.pageXOffset||document.documentElement.scrollLeft};let e=window.innerWidth-document.documentElement.clientWidth;document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.paddingRight=`${e}px`,document.documentElement.style.position="fixed",document.documentElement.style.top=`-${this.scrollPosition.top}px`,document.documentElement.style.left=`-${this.scrollPosition.left}px`,document.documentElement.style.width="100%"}unlockScroll(){typeof document>"u"||(document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.paddingRight="",document.documentElement.style.position="",document.documentElement.style.top="",document.documentElement.style.left="",document.documentElement.style.width="",typeof window<"u"&&this.scrollPosition&&window.scrollTo(this.scrollPosition.left,this.scrollPosition.top))}scrollTargetIntoView(){if(typeof window>"u"||typeof document>"u")return;let e=this.resolveTarget(this.currentStep.target);if(!e)return;let t=document.documentElement.style.position==="fixed";t&&this.unlockScroll(),this.safeSetTimeout(()=>{if(typeof window>"u"||!e)return;let i=e.getBoundingClientRect();i.top>=0&&i.left>=0&&i.bottom<=window.innerHeight&&i.right<=window.innerWidth||e.scrollIntoView({behavior:"smooth",block:"center"}),t&&this.safeSetTimeout(()=>{typeof window>"u"||(this.lockScroll(),requestAnimationFrame(()=>this.positionPanel()))},300)},0)}handleScroll(e){if(this.openValue&&e.target!==this.panelTarget)return e.preventDefault(),e.stopPropagation(),!1}updateMaskVisibility(){if(this.hasMaskTarget){if(!this.maskValue){this.maskTarget.style.display="none";return}this.maskTarget.style.display=this.openValue?"":"none"}}setPlacement(e){if(!this.hasPanelTarget)return;let t=e||this.placementValue||"bottom";this.panelTarget.setAttribute("data-hakumi-tour-placement",t),this.openValue&&this.positionPanel()}positionPanel(){if(!this.hasPanelTarget||!this.openValue)return;let e=this.panelTarget;e.style.left="0px",e.style.top="0px";let t=this.currentStep,i=this.resolveTarget(t.target),s=t.placement||this.placementValue,a=16,n=12,r=e.getBoundingClientRect(),o=0,l=0;if(i){let h=i.getBoundingClientRect();switch(s){case"top":case"top-left":case"top-right":o=h.top-r.height-a;break;case"bottom":case"bottom-left":case"bottom-right":o=h.bottom+a;break;case"left":case"left-top":case"left-bottom":o=h.top+(h.height-r.height)/2,s==="left-top"&&(o=h.top),s==="left-bottom"&&(o=h.bottom-r.height);break;case"right":case"right-top":case"right-bottom":o=h.top+(h.height-r.height)/2,s==="right-top"&&(o=h.top),s==="right-bottom"&&(o=h.bottom-r.height);break;default:o=h.bottom+a}switch(s){case"top":case"bottom":l=h.left+(h.width-r.width)/2;break;case"top-left":case"bottom-left":l=h.left;break;case"top-right":case"bottom-right":l=h.right-r.width;break;case"left":case"left-top":case"left-bottom":l=h.left-r.width-a;break;case"right":case"right-top":case"right-bottom":l=h.right+a;break;default:l=h.left}}else o=(window.innerHeight-r.height)/2,l=(window.innerWidth-r.width)/2,this.hasArrowTarget&&(this.arrowTarget.style.display="none");this.hasArrowTarget&&i&&(this.arrowTarget.style.display=""),o=Math.min(Math.max(o,n),window.innerHeight-r.height-n),l=Math.min(Math.max(l,n),window.innerWidth-r.width-n),e.style.top=`${o}px`,e.style.left=`${l}px`}updateTargetHighlight(e){this.activeTarget&&(this.activeTarget.classList.remove("hakumi-tour-target-active"),this.activeTarget=null);let t=this.resolveTarget(e);t&&(t.classList.add("hakumi-tour-target-active"),this.activeTarget=t)}resolveTarget(e){return e?e instanceof HTMLElement?e:typeof e=="string"?e.startsWith("#")||e.startsWith(".")||e.startsWith("[")?document.querySelector(e):document.getElementById(e)||document.querySelector(e):null:null}handleMaskClick(){this.maskClosableValue&&this.close()}handleKeydown(e){if(this.openValue){if(e.key==="Escape"&&this.closableValue){e.preventDefault(),this.close();return}if(e.key==="ArrowRight"){e.preventDefault(),this.next();return}if(e.key==="ArrowLeft"){e.preventDefault(),this.prev();return}e.key==="Tab"&&this.trapFocus(e)}}trapFocus(e){if(!this.hasPanelTarget)return;let t=this.panelTarget.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])"),i=Array.from(t).filter(n=>!n.disabled&&n.offsetParent!==null);if(i.length===0)return;let s=i[0],a=i[i.length-1];e.shiftKey&&document.activeElement===s?(e.preventDefault(),a.focus()):!e.shiftKey&&document.activeElement===a&&(e.preventDefault(),s.focus())}restoreFocus(){this.lastFocused&&typeof this.lastFocused.focus=="function"&&(this.lastFocused.focus({preventScroll:!0}),this.lastFocused=null)}get currentStep(){return this.stepsValue[this.currentIndex]||{}}};var ei=class extends m{static targets=["text"];setup(){requestAnimationFrame(()=>this.autoScale())}registerApi(){this.element.hakumiComponent={name:"avatar_text",version:1,singleton:!1,api:{rescale:()=>this.autoScale()}}}autoScale(){if(!this.hasTextTarget)return;let e=this.element,t=this.textTarget;t.style.transform="",t.style.transformOrigin="center",e.offsetHeight;let i=e.offsetWidth,s=t.scrollWidth,a=8;if(!(i===0||s===0))if(i-a<s){let n=(i-a)/s;t.style.transform=`scale(${n})`}else t.style.transform=""}};var ti=class extends m{static targets=["yearSelect","monthSelect","modeSegmented","body"];static values={mode:{type:String,default:"month"},year:{type:Number,default:new Date().getFullYear()},month:{type:Number,default:new Date().getMonth()+1},fullscreen:{type:Boolean,default:!0},locale:{type:String,default:"en"},selectedDate:{type:String,default:""},static:{type:Boolean,default:!1},events:{type:Object,default:{}},userPreferredMonth:{type:Number,default:0},userPreferredYear:{type:Number,default:0},rangeStartDate:{type:String,default:""},rangeEndDate:{type:String,default:""},hoveredDate:{type:String,default:""}};static locales={en:{daysShort:["Mo","Tu","We","Th","Fr","Sa","Su"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],monthsFull:["January","February","March","April","May","June","July","August","September","October","November","December"]},es:{daysShort:["Lu","Ma","Mi","Ju","Vi","S\xE1","Do"],monthsShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],monthsFull:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]}};setup(){this.#e()}teardown(){delete this.element.hakumiCalendar}#e(){this.boundChangeYear=this.changeYear.bind(this),this.boundChangeMonth=this.changeMonth.bind(this),this.boundChangeMode=this.changeMode.bind(this),this.element.addEventListener("hakumi--select:change",e=>{let t=e.target;t.matches("[data-hakumi--calendar-target='yearSelect']")?this.boundChangeYear(e):t.matches("[data-hakumi--calendar-target='monthSelect']")&&this.boundChangeMonth(e)}),this.element.addEventListener("hakumi--segmented:change",this.boundChangeMode)}yearValueChanged(){this.#r(),this.#x()}monthValueChanged(){this.#r(),this.#y()}modeValueChanged(){this.#r(),this.#w(),this.#t()}#t(){this.hasMonthSelectTarget&&this.#i(this.monthSelectTarget,e=>{e.setValue(this.monthValue)}),this.hasYearSelectTarget&&this.#i(this.yearSelectTarget,e=>{e.setValue(this.yearValue)})}#i(e,t,i=10){if(!e)return;let s=0,a=()=>{let n=e.hakumiComponent?.api;n?t(n):s<i&&(s++,requestAnimationFrame(a))};a()}changeYear(e){let t=parseInt(e.target.value||e.detail?.value,10);isNaN(t)||(this.yearValue=t,this.#b())}changeMonth(e){let t=parseInt(e.target.value||e.detail?.value,10);isNaN(t)||(this.monthValue=t,this.#b())}changeMode(e){let t=e.detail?.value||e.target?.value;t&&(t==="month"||t==="year")&&(this.modeValue=t,this.#L())}selectDate(e){let t=e.currentTarget,i=t.dataset.date;if(!i||t.classList.contains("hakumi-calendar-cell-disabled"))return;if(this.element.classList.contains("hakumi-calendar-show-week")){let a=L.parseDataDate(i),n=L.getMondayOfWeek(a),r=!L.isInMonth(a,this.monthValue,this.yearValue);if(this.selectedDateValue=L.formatDataDate(n),r)this.monthValue=a.month()+1,this.yearValue=a.year(),this.userPreferredMonthValue=this.monthValue,this.userPreferredYearValue=this.yearValue;else{let o=t.closest("tr");o&&(this.element.querySelectorAll(".hakumi-calendar-row-selected").forEach(l=>l.classList.remove("hakumi-calendar-row-selected")),o.classList.add("hakumi-calendar-row-selected"))}this.#k(n.toDate())}else{let a=L.parseDataDate(i);L.isInMonth(a,this.monthValue,this.yearValue)||(this.monthValue=a.month()+1,this.yearValue=a.year()),this.selectedDateValue=i,this.#E(t),this.#k(a.toDate())}}handleCellHover(e){let t=e.currentTarget,i=t.dataset.date;i&&(t.classList.contains("hakumi-calendar-cell-disabled")||this.rangeStartDateValue&&!this.rangeEndDateValue&&(this.setHoveredDate(i),this.dispatch("cell-hover",{detail:{date:L.parseDataDate(i).toDate()}})))}selectWeek(e){let i=e.currentTarget.closest("tr");if(!i)return;let s=i.querySelectorAll("[data-date]");if(s.length<7)return;let a=s[3],n=L.parseDataDate(a.dataset.date),r=L.getMondayOfWeek(n),o=!L.isInMonth(n,this.monthValue,this.yearValue);this.selectedDateValue=L.formatDataDate(r),o?(this.monthValue=n.month()+1,this.yearValue=n.year(),this.userPreferredMonthValue=this.monthValue,this.userPreferredYearValue=this.yearValue):(this.element.querySelectorAll(".hakumi-calendar-row-selected").forEach(l=>l.classList.remove("hakumi-calendar-row-selected")),i.classList.add("hakumi-calendar-row-selected")),this.#k(r.toDate())}selectMonth(e){let t=e.currentTarget,i=parseInt(t.dataset.month,10);if(isNaN(i))return;this.monthValue=i;let s=new Date(this.yearValue,i-1,1);this.selectedDateValue=L.formatDataDate(s),this.staticValue||(this.modeValue="month"),this.#k(s)}selectQuarter(e){let t=e.currentTarget,i=parseInt(t.dataset.quarter,10);if(isNaN(i))return;let s=(i-1)*3+1;this.monthValue=s;let a=new Date(this.yearValue,s-1,1);this.selectedDateValue=L.formatDataDate(a),this.#k({year:this.yearValue,quarter:i})}selectYear(e){let t=e.currentTarget,i=parseInt(t.dataset.year,10);if(isNaN(i))return;this.yearValue=i;let s=new Date(i,0,1);this.selectedDateValue=L.formatDataDate(s),this.#k(s)}getValue(){return new Date(this.yearValue,this.monthValue-1,1)}getSelectedDate(){return this.selectedDateValue?L.parseDataDate(this.selectedDateValue).toDate():null}setValue(e,t={}){if(e instanceof Date){let i=this.element.classList.contains("hakumi-calendar-show-week"),s=t.navigate===!0;if(this.selectedDateValue=L.formatDataDate(e),i){let a=L.parseDataDate(L.formatDataDate(e));this.userPreferredMonthValue>0&&this.userPreferredYearValue>0?(this.yearValue=this.userPreferredYearValue,this.monthValue=this.userPreferredMonthValue):(!this.monthValue||!this.yearValue||this.monthValue===1&&this.yearValue===1970)&&(this.yearValue=a.year(),this.monthValue=a.month()+1)}else s?(this.yearValue=e.getFullYear(),this.monthValue=e.getMonth()+1):this.modeValue!=="month"&&this.modeValue!=="quarter"&&this.modeValue!=="year"&&(this.yearValue=e.getFullYear(),this.monthValue=e.getMonth()+1);this.#r(),this.#b()}}clearSelection(){this.selectedDateValue="",this.#r()}setRange(e,t,i=null){this.rangeStartDateValue=this.#s(e)||"",this.rangeEndDateValue=this.#s(t)||"",this.hoveredDateValue=i?this.#s(i):"",this.#r()}clearRange(){this.rangeStartDateValue="",this.rangeEndDateValue="",this.hoveredDateValue="",this.#r()}getRange(){return{start:this.rangeStartDateValue||null,end:this.rangeEndDateValue||null,hovered:this.hoveredDateValue||null}}setHoveredDate(e){this.hoveredDateValue=e?this.#s(e):"",this.#r()}getMode(){return this.modeValue}setMode(e){(e==="month"||e==="year")&&(this.modeValue=e,this.#L())}goToToday(){let e=new Date;this.yearValue=e.getFullYear(),this.monthValue=e.getMonth()+1,this.#b()}nextMonth(){this.monthValue===12?(this.monthValue=1,this.yearValue+=1):this.monthValue+=1,this.#b()}prevMonth(){this.monthValue===1?(this.monthValue=12,this.yearValue-=1):this.monthValue-=1,this.#b()}nextYear(){this.yearValue+=1,this.#b()}prevYear(){this.yearValue-=1,this.#b()}nextDecade(){this.yearValue+=10,this.#b()}prevDecade(){this.yearValue-=10,this.#b()}getEvents(){return{...this.eventsValue}}setEvents(e){this.eventsValue=this.#a(e),this.staticValue||this.#r(),this.#n()}addEvent(e,t){let i=this.#s(e),s={...this.eventsValue};s[i]||(s[i]=[]),s[i].push({id:t.id||null,type:t.type||"default",content:t.content||"",html:t.html||null}),this.eventsValue=s,this.staticValue||this.#r(),this.#n()}updateEvent(e,t){let i={...this.eventsValue},s=!1;return Object.keys(i).forEach(a=>{let n=i[a].findIndex(r=>r.id===e);n!==-1&&(i[a][n]={...i[a][n],...t},s=!0)}),s&&(this.eventsValue=i,this.staticValue||this.#r(),this.#n()),s}removeEvent(e,t=null){let i=this.#s(e),s={...this.eventsValue};return s[i]?(t===null?delete s[i]:typeof t=="number"&&t>=0&&t<s[i].length&&(s[i].splice(t,1),s[i].length===0&&delete s[i]),this.eventsValue=s,this.staticValue||this.#r(),this.#n(),!0):!1}removeEventById(e){let t={...this.eventsValue},i=!1;return Object.keys(t).forEach(s=>{let a=t[s].findIndex(n=>n.id===e);a!==-1&&(t[s].splice(a,1),t[s].length===0&&delete t[s],i=!0)}),i&&(this.eventsValue=t,this.staticValue||this.#r(),this.#n()),i}getEventById(e){for(let t of Object.keys(this.eventsValue)){let i=this.eventsValue[t].find(s=>s.id===e);if(i)return{...i,date:t}}return null}getEventsForDate(e){let t=this.#s(e);return this.eventsValue[t]||[]}clearEvents(){this.eventsValue={},this.staticValue||this.#r(),this.#n()}#s(e){return e instanceof Date?L.formatDataDate(e):String(e)}#a(e){if(!e||typeof e!="object")return{};let t={};return Object.keys(e).forEach(i=>{let s=this.#s(i);t[s]=e[i].map(a=>({id:a.id||null,type:a.type||"default",content:a.content||"",html:a.html||null}))}),t}#n(){this.dispatch("eventsChange",{detail:{events:this.getEvents()}})}#o(){return this.constructor.locales[this.localeValue]||this.constructor.locales.en}#r(){let e=this.element.querySelector(".hakumi-calendar-body");if(e)switch(this.modeValue){case"month":e.innerHTML=this.#u();break;case"year":e.innerHTML=this.#h();break;case"quarter":e.innerHTML=this.#c();break;case"decade":e.innerHTML=this.#d();break;default:e.innerHTML=this.#u()}}#u(){let e=this.#o(),t=this.#m(this.yearValue,this.monthValue),i=this.element.classList.contains("hakumi-calendar-show-week"),s=L.formatDataDate(new Date),a=`<table class="hakumi-calendar-table">
|
|
9
|
+
<thead class="hakumi-calendar-thead">
|
|
10
|
+
<tr>`;return i&&(a+='<th class="hakumi-calendar-cell hakumi-calendar-cell-week-header"></th>'),e.daysShort.forEach(n=>{a+=`<th class="hakumi-calendar-cell hakumi-calendar-column-header">
|
|
11
|
+
<span class="hakumi-calendar-column-header-inner">${n}</span>
|
|
12
|
+
</th>`}),a+='</tr></thead><tbody class="hakumi-calendar-tbody">',t.forEach(n=>{let r=n.weekSelected?"hakumi-calendar-row hakumi-calendar-row-selected":"hakumi-calendar-row";a+=`<tr class="${r}">`,i&&(a+=`<td class="hakumi-calendar-cell hakumi-calendar-cell-week" data-action="click->hakumi--calendar#selectWeek">
|
|
13
|
+
<div class="hakumi-calendar-week-number">${n.weekNumber}</div>
|
|
14
|
+
</td>`),n.days.forEach(o=>{let l=this.#f(o,s),h=this.#p(o.dateStr),u=this.rangeStartDateValue&&!this.rangeEndDateValue?"click->hakumi--calendar#selectDate mouseenter->hakumi--calendar#handleCellHover":"click->hakumi--calendar#selectDate";a+=`<td class="${l}" data-date="${o.dateStr}" data-action="${u}">
|
|
15
|
+
<div class="hakumi-calendar-date">
|
|
16
|
+
<div class="hakumi-calendar-date-value">${o.day}</div>
|
|
17
|
+
${h?`<div class="hakumi-calendar-date-content">${h}</div>`:""}
|
|
18
|
+
</div>
|
|
19
|
+
</td>`}),a+="</tr>"}),a+="</tbody></table>",a}#h(){let e=this.#o(),t=new Date().getMonth()+1,i=new Date().getFullYear(),s=this.selectedDateValue?L.parseDataDate(this.selectedDateValue):null,a=s?s.month()+1:null,n=s?s.year():null,r='<div class="hakumi-calendar-month-panel">';for(let o=0;o<4;o++){r+='<div class="hakumi-calendar-month-panel-row">';for(let l=0;l<3;l++){let h=o*3+l+1,u=h===t&&this.yearValue===i,c=a&&h===a&&this.yearValue===n,d="hakumi-calendar-cell hakumi-calendar-cell-month";c&&(d+=" hakumi-calendar-cell-selected"),u&&!this.staticValue&&(d+=" hakumi-calendar-cell-current");let g=this.#l(this.yearValue,h);r+=`<div class="${d}" data-month="${h}" data-action="click->hakumi--calendar#selectMonth">
|
|
20
|
+
<div class="hakumi-calendar-month-cell-inner">
|
|
21
|
+
<div class="hakumi-calendar-month-value">${e.monthsShort[h-1]}</div>
|
|
22
|
+
${g}
|
|
23
|
+
</div>
|
|
24
|
+
</div>`}r+="</div>"}return r+="</div>",r}#l(e,t){let i=this.eventsValue;if(!i||Object.keys(i).length===0)return"";let s=new Set;if(Object.keys(i).forEach(n=>{let r=L.parseDataDate(n);r.year()===e&&r.month()+1===t&&i[n].forEach(o=>{s.add(o.type||"default")})}),s.size===0)return"";let a='<div class="hakumi-calendar-month-events">';return s.forEach(n=>{a+=`<span class="hakumi-calendar-month-event-dot hakumi-calendar-month-event-${n}"></span>`}),a+="</div>",a}#c(){let e=new Date().getFullYear(),t=Math.floor(new Date().getMonth()/3)+1,i=this.selectedDateValue?L.parseDataDate(this.selectedDateValue):null,s=i?Math.floor(i.month()/3)+1:null,a=i?i.year():null,n='<div class="hakumi-calendar-quarter-panel">';for(let r=0;r<2;r++){n+='<div class="hakumi-calendar-quarter-panel-row">';for(let o=0;o<2;o++){let l=r*2+o+1,h=l===t&&this.yearValue===e,u=s&&l===s&&this.yearValue===a,c="hakumi-calendar-cell hakumi-calendar-cell-quarter";u&&(c+=" hakumi-calendar-cell-selected"),h&&!this.staticValue&&(c+=" hakumi-calendar-cell-current"),n+=`<div class="${c}" data-quarter="${l}" data-action="click->hakumi--calendar#selectQuarter">
|
|
25
|
+
<div class="hakumi-calendar-quarter-cell-inner">
|
|
26
|
+
<div class="hakumi-calendar-quarter-value">Q${l}</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>`}n+="</div>"}return n+="</div>",n}#d(){let e=new Date().getFullYear(),t=this.selectedDateValue?L.parseDataDate(this.selectedDateValue):null,i=t?t.year():null,s=Math.floor(this.yearValue/10)*10,a=s-1,n=s+10,r='<div class="hakumi-calendar-year-panel">';for(let o=0;o<4;o++){r+='<div class="hakumi-calendar-year-panel-row">';for(let l=0;l<3;l++){let h=a+o*3+l,u=h===e,c=i&&h===i,d=h>=s&&h<s+10,g="hakumi-calendar-cell hakumi-calendar-cell-year";c&&(g+=" hakumi-calendar-cell-selected"),u&&!this.staticValue&&(g+=" hakumi-calendar-cell-current"),d||(g+=" hakumi-calendar-cell-disabled"),r+=`<div class="${g}" data-year="${h}" data-action="click->hakumi--calendar#selectYear">
|
|
29
|
+
<div class="hakumi-calendar-year-cell-inner">
|
|
30
|
+
<div class="hakumi-calendar-year-value">${h}</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>`}r+="</div>"}return r+="</div>",r}#m(e,t){let i=L.parseDataDate(`${e}-${String(t).padStart(2,"0")}-01`),s=i.endOf("month"),a=L.getMondayOfWeek(i),n=a.add(41,"day"),r=this.selectedDateValue?L.parseDataDate(this.selectedDateValue):null,o=r?L.getISOWeek(r):null,l=r?L.getISOWeekYear(r):null,h=this.element.classList.contains("hakumi-calendar-show-week"),u=[],c=a;for(;c.isBefore(n.add(1,"day"),"day");){let d={weekNumber:null,weekSelected:!1,days:[]};for(let V=0;V<7;V++)d.days.push({date:c.toDate(),dateStr:L.formatDataDate(c),day:c.date(),inMonth:c.month()+1===t,weekend:c.day()===0||c.day()===6}),c=c.add(1,"day");let g=d.days[3],p=L.parseDataDate(g.dateStr),f=L.getISOWeek(p),C=L.getISOWeekYear(p);d.weekNumber=f,d.weekSelected=h&&o===f&&l===C,u.push(d)}return u}#f(e,t){let i=["hakumi-calendar-cell"],s=this.element.classList.contains("hakumi-calendar-show-week");if(e.inMonth&&i.push("hakumi-calendar-cell-in-view"),e.dateStr===t&&!s&&i.push("hakumi-calendar-cell-today"),e.dateStr===this.selectedDateValue&&!s&&i.push("hakumi-calendar-cell-selected"),e.weekend&&e.dateStr!==this.selectedDateValue&&i.push("hakumi-calendar-cell-weekend"),this.rangeStartDateValue||this.rangeEndDateValue){let a=this.rangeStartDateValue?new Date(this.rangeStartDateValue):null,n=this.rangeEndDateValue?new Date(this.rangeEndDateValue):null,r=this.hoveredDateValue?new Date(this.hoveredDateValue):null,o=new Date(e.dateStr);a&&e.dateStr===this.rangeStartDateValue&&i.push("hakumi-calendar-cell-range-start"),n&&e.dateStr===this.rangeEndDateValue&&i.push("hakumi-calendar-cell-range-end"),a&&n?o>a&&o<n&&i.push("hakumi-calendar-cell-in-range"):a&&r&&!n&&(o>a&&o<=r||o<a&&o>=r)&&(i.push("hakumi-calendar-cell-in-range"),i.push("hakumi-calendar-cell-range-hover"))}return i.join(" ")}#p(e){let t=this.eventsValue[e];return!t||t.length===0?"":t.map(i=>{let s=i.type||"default",a=this.#V(i.content),n=i.html||this.#g(s,a);return`<div class="hakumi-calendar-event hakumi-calendar-event-${s}" title="${a}">${n}</div>`}).join("")}#g(e,t){return`<span class="hakumi-badge hakumi-badge-status">
|
|
33
|
+
<span class="hakumi-badge-status-dot ${this.#v(e)}"></span>
|
|
34
|
+
<span class="hakumi-badge-status-text">${t}</span>
|
|
35
|
+
</span>`}#v(e){let t={success:"hakumi-badge-status-success",warning:"hakumi-badge-status-warning",error:"hakumi-badge-status-error",default:"hakumi-badge-status-default"};return t[e]||t.default}#V(e){let t=document.createElement("div");return t.textContent=e,t.innerHTML}#E(e){this.element.querySelectorAll(".hakumi-calendar-cell-selected").forEach(t=>t.classList.remove("hakumi-calendar-cell-selected")),e.classList.add("hakumi-calendar-cell-selected")}#D(e){this.element.querySelectorAll(".hakumi-calendar-cell-month.hakumi-calendar-cell-selected").forEach(t=>t.classList.remove("hakumi-calendar-cell-selected")),e.classList.add("hakumi-calendar-cell-selected")}#x(){if(this.hasYearSelectTarget){let t=this.yearSelectTarget.hakumiComponent?.api;t?.setValue&&t.setValue(this.yearValue)}}#y(){if(this.hasMonthSelectTarget){let t=this.monthSelectTarget.hakumiComponent?.api;t?.setValue&&t.setValue(this.monthValue)}}#w(){if(this.hasModeSegmentedTarget){let t=this.modeSegmentedTarget.hakumiComponent?.api;t?.setValue&&t.setValue(this.modeValue)}}#b(){this.dispatch("change",{detail:{year:this.yearValue,month:this.monthValue,date:this.getValue()}})}#L(){this.dispatch("panelChange",{detail:{mode:this.modeValue,year:this.yearValue,month:this.monthValue}})}#k(e){let t=e instanceof Date?{date:e,source:this.modeValue==="month"?"date":"month"}:{...e,source:"quarter"};this.dispatch("select",{detail:t})}registerApi(){let e={getValue:()=>this.getValue(),getSelectedDate:()=>this.getSelectedDate(),setValue:(t,i)=>this.setValue(t,i),clearSelection:()=>this.clearSelection(),getMode:()=>this.getMode(),setMode:t=>this.setMode(t),goToToday:()=>this.goToToday(),nextMonth:()=>this.nextMonth(),prevMonth:()=>this.prevMonth(),nextYear:()=>this.nextYear(),prevYear:()=>this.prevYear(),nextDecade:()=>this.nextDecade(),prevDecade:()=>this.prevDecade(),refresh:()=>this.#r(),getEvents:()=>this.getEvents(),setEvents:t=>this.setEvents(t),addEvent:(t,i)=>this.addEvent(t,i),updateEvent:(t,i)=>this.updateEvent(t,i),removeEvent:(t,i)=>this.removeEvent(t,i),removeEventById:t=>this.removeEventById(t),getEventById:t=>this.getEventById(t),getEventsForDate:t=>this.getEventsForDate(t),clearEvents:()=>this.clearEvents(),setRange:(t,i,s)=>this.setRange(t,i,s),clearRange:()=>this.clearRange(),getRange:()=>this.getRange(),setHoveredDate:t=>this.setHoveredDate(t)};this.element.hakumiComponent={name:"calendar",version:1,singleton:!1,api:e},this.element.hakumiCalendar=e}};var ii=class extends m{static targets=["container","track","slide","dots","dot","dotProgress","prevArrow","nextArrow"];static values={autoplay:{type:Boolean,default:!1},autoplaySpeed:{type:Number,default:3e3},infinite:{type:Boolean,default:!0},fade:{type:Boolean,default:!1},adaptiveHeight:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},arrows:{type:Boolean,default:!1},dots:{type:Boolean,default:!0},dotPlacement:{type:String,default:"bottom"},speed:{type:Number,default:500},easing:{type:String,default:"linear"},waitForAnimate:{type:Boolean,default:!1},autoplayDotDuration:{type:Boolean,default:!1},currentIndex:{type:Number,default:0}};setup(){this._isAnimating=!1,this._autoplayTimer=null,this._dragging=!1,this._dragStartX=0,this._dragDeltaX=0,this.#t(),this.#i(!0),this.#s(),this.#a(),this.adaptiveHeightValue&&this.#n(),this.#h(),this.#o()}teardown(){this.#r(),this.#l()}registerApi(){this.element.hakumiComponent={name:"carousel",version:1,singleton:!1,api:{getCurrent:()=>this.currentIndexValue,getSlideCount:()=>this.slideCount,next:()=>this.next(),prev:()=>this.prev(),goTo:(e,t=!1)=>{if(t){let i=this.speedValue,s=this.waitForAnimateValue;this.speedValue=0,this.waitForAnimateValue=!1,this.#e(e),this.speedValue=i,this.waitForAnimateValue=s}else this.#e(e)}}}}next(){this.#e(this.currentIndexValue+1)}prev(){this.#e(this.currentIndexValue-1)}goToFromDot(e){let t=parseInt(e.currentTarget.dataset.index,10);Number.isNaN(t)||this.#e(t)}get slideCount(){return this.hasSlideTarget?this.slideTargets.length:0}#e(e,t={}){if(this.slideCount===0||this.waitForAnimateValue&&this._isAnimating)return;let i=e;this.infiniteValue?i=(i%this.slideCount+this.slideCount)%this.slideCount:i=Math.max(0,Math.min(i,this.slideCount-1));let s=this.currentIndexValue;if(i===s)return;this._isAnimating=!0,this.#r(),this.dispatch("beforeChange",{detail:{current:s,next:i}}),this.currentIndexValue=i,this.#i(),this.#s(),this.#a(),this.adaptiveHeightValue&&this.#n();let a=Math.max(0,this.speedValue);a===0?(this._isAnimating=!1,this.dispatch("afterChange",{detail:{current:i,previous:s}}),this.#o()):window.setTimeout(()=>{this._isAnimating=!1,this.dispatch("afterChange",{detail:{current:i,previous:s}}),this.#o()},a)}#t(){this.hasTrackTarget&&(this.fadeValue?this.trackTarget.style.transition="":(this.trackTarget.style.transitionProperty="transform",this.trackTarget.style.transitionTimingFunction=this.easingValue,this.trackTarget.style.transitionDuration=`${this.speedValue}ms`))}#i(e=!1){if(!this.hasSlideTarget)return;let t=this.currentIndexValue;if(this.fadeValue){this.slideTargets.forEach((s,a)=>{let n=a===t;s.classList.toggle("hakumi-carousel-slide-active",n),s.setAttribute("aria-hidden",(!n).toString())});return}if(!this.hasTrackTarget)return;let i=-t*100;if(e){let s=this.trackTarget.style.transitionDuration;this.trackTarget.style.transitionDuration="0ms",this.trackTarget.style.transform=`translateX(${i}%)`,this.trackTarget.getBoundingClientRect(),this.trackTarget.style.transitionDuration=s||`${this.speedValue}ms`}else this.trackTarget.style.transform=`translateX(${i}%)`;this.slideTargets.forEach((s,a)=>{let n=a===t;s.classList.toggle("hakumi-carousel-slide-active",n),s.setAttribute("aria-hidden",(!n).toString())})}#s(){if(!this.hasDotTarget)return;let e=this.currentIndexValue;this.dotTargets.forEach((t,i)=>{let s=i===e;t.classList.toggle("hakumi-carousel-dot-active",s);let a=t.querySelector(".hakumi-carousel-dot-button");a&&a.setAttribute("aria-current",s?"true":"false")})}#a(){if(this.arrowsValue&&!this.infiniteValue&&this.slideCount>0){let e=this.currentIndexValue===0,t=this.currentIndexValue===this.slideCount-1;this.hasPrevArrowTarget&&(this.prevArrowTarget.classList.toggle("hakumi-carousel-arrow-disabled",e),this.prevArrowTarget.disabled=e),this.hasNextArrowTarget&&(this.nextArrowTarget.classList.toggle("hakumi-carousel-arrow-disabled",t),this.nextArrowTarget.disabled=t)}}#n(){if(!this.hasContainerTarget||!this.hasSlideTarget)return;let e=this.slideTargets[this.currentIndexValue];if(!e)return;let t=e.getBoundingClientRect();this.containerTarget.style.height=`${t.height}px`}#o(){!this.autoplayValue||this.slideCount<=1||(this.#u(),this._autoplayTimer=window.setInterval(()=>{this.next()},this.autoplaySpeedValue))}#r(){this._autoplayTimer&&(window.clearInterval(this._autoplayTimer),this._autoplayTimer=null),this.autoplayDotDurationValue&&this.hasDotProgressTarget&&this.dotProgressTargets.forEach(e=>{e.style.transition="",e.style.width=""})}#u(){if(!this.autoplayDotDurationValue||!this.hasDotProgressTarget)return;let e=this.currentIndexValue;this.dotProgressTargets.forEach((t,i)=>{t.style.transition="none",t.style.width="0%",i===e&&requestAnimationFrame(()=>{t.style.transition=`width ${this.autoplaySpeedValue}ms linear`,t.style.width="100%"})})}#h(){!this.draggableValue||!this.hasContainerTarget||this.fadeValue||(this._onPointerDown=this.#c.bind(this),this._onPointerMove=this.#d.bind(this),this._onPointerUp=this.#m.bind(this),this.containerTarget.addEventListener("pointerdown",this._onPointerDown))}#l(){!this._onPointerDown||!this.hasContainerTarget||(this.containerTarget.removeEventListener("pointerdown",this._onPointerDown),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp))}#c(e){e.button===0&&(this._dragging=!0,this._dragStartX=e.clientX,this._dragDeltaX=0,this.#r(),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp))}#d(e){if(!this._dragging||!this.hasTrackTarget)return;this._dragDeltaX=e.clientX-this._dragStartX;let t=this.containerTarget.clientWidth||1,i=this._dragDeltaX/t*100,s=-this.currentIndexValue*100;this.trackTarget.style.transitionDuration="0ms",this.trackTarget.style.transform=`translateX(${s+i}%)`}#m(){if(!this._dragging)return;this._dragging=!1,document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp);let t=(this.containerTarget.clientWidth||1)*.15,i=this._dragDeltaX;this.trackTarget.style.transitionDuration=`${this.speedValue}ms`,i>t?this.prev():i<-t?this.next():(this.#i(),this.#o())}};var si=class extends m{static targets=["item","content"];static values={accordion:{type:Boolean,default:!1},activeKeys:Array,collapsible:String,bordered:{type:Boolean,default:!0},ghost:{type:Boolean,default:!1}};setup(){Array.isArray(this.activeKeysValue)||(this.activeKeysValue=[]),this.#e()}registerApi(){this.element.hakumiComponent={name:"collapse",version:1,singleton:!1,api:{getActiveKeys:()=>[...this.activeKeysValue],setActiveKeys:e=>{let t=[...this.activeKeysValue],i=Array.isArray(e)?e.map(String):[];this.activeKeysValue=i,this.#e(),this.dispatch("afterChange",{detail:{activeKeys:i,previousActiveKeys:t}})},open:e=>{let t=String(e);this.activeKeysValue.includes(t)||(this.activeKeysValue=this.accordionValue?[t]:[...this.activeKeysValue.map(String),t],this.#e())},close:e=>{let t=String(e);this.activeKeysValue=this.activeKeysValue.filter(i=>String(i)!==t),this.#e()},toggle:e=>this.#t(e),isAccordion:()=>this.accordionValue,isOpen:e=>e==null?this.activeKeysValue.length>0:this.activeKeysValue.map(String).includes(String(e)),getState:()=>({activeKeys:[...this.activeKeysValue],accordion:this.accordionValue})}}}toggle(e){e&&(e.preventDefault(),e.stopPropagation());let t=e.currentTarget?.dataset?.key||e.target?.closest(".hakumi-collapse-header")?.dataset?.key;t&&this.#t(t)}#e(){let e=new Set(this.activeKeysValue.map(String));this.#s((t,i)=>{let s=e.has(i);t.classList.toggle("hakumi-collapse-item-active",s);let a=this.#a(i);a&&a.classList.toggle("hakumi-collapse-content-active",s);let n=t.querySelector(".hakumi-collapse-header .hakumi-collapse-arrow");n&&n.classList.toggle("hakumi-collapse-arrow-rotated",s)})}#t(e){let i=this.#i().find(o=>o.dataset.key===String(e));if(!i||i.dataset.disabled==="true")return;let s=[...this.activeKeysValue],a,n=this.activeKeysValue.map(String).includes(String(e));this.accordionValue?a=n?[]:[String(e)]:n?a=this.activeKeysValue.filter(o=>String(o)!==String(e)):a=[...this.activeKeysValue.map(String),String(e)],this.dispatch("beforeChange",{detail:{currentActiveKeys:s,nextActiveKeys:a,toggledKey:String(e)}}),!n?this.#n(e):this.#o(e),this.activeKeysValue=a,this.#e(),this.dispatch("afterChange",{detail:{activeKeys:a,previousActiveKeys:s,toggledKey:String(e)}})}#i(){return this.hasItemTarget?this.itemTargets:Array.from(this.element.querySelectorAll('[data-hakumi--collapse-target="item"]'))}#s(e){this.#i().forEach(t=>e(t,t.dataset.key))}#a(e){return this.element.querySelector(`[data-hakumi--collapse-target="content"][data-key="${CSS.escape(String(e))}"]`)}#n(e){let t=this.#a(e);if(!t)return;let i=t.querySelector(".hakumi-collapse-content-box");if(!i)return;t.classList.add("hakumi-collapse-content-active"),t.style.height="0px",t.offsetHeight;let s=i.scrollHeight;t.style.height=`${s}px`;let a=()=>{t.style.height="auto",t.removeEventListener("transitionend",a)};t.addEventListener("transitionend",a)}#o(e){let t=this.#a(e);if(!t)return;let i=t.querySelector(".hakumi-collapse-content-box");if(!i)return;let s=i.scrollHeight;t.style.height=`${s}px`,t.offsetHeight,t.style.height="0px";let a=()=>{t.classList.remove("hakumi-collapse-content-active"),t.style.height="0px",t.removeEventListener("transitionend",a)};t.addEventListener("transitionend",a)}};var ai=class extends m{static targets=["img","mask","placeholder","errorPlaceholder","previewTemplate"];static values={src:String,previewSrc:String,alt:String,fallback:String,items:{type:Array,default:[]},current:{type:Number,default:0},maskClosable:{type:Boolean,default:!1}};#e=!1;#t=1;#i=0;#s=!1;#a=!1;#n=0;#o=0;#r=!1;#u={x:0,y:0};#h=null;#l=null;setup(){this.element.classList.contains("hakumi-image-preview-group")||this.itemsValue.length>0?this.#c():this.hasImgTarget&&this.imgTarget.complete&&(this.imgTarget.naturalWidth===0?this.handleError():this.handleLoad())}teardown(){this.#d()}registerApi(){this.element.hakumiComponent={name:"image",version:1,singleton:!1,api:{open:e=>this.openPreview(e),close:()=>this.closePreview(),prev:()=>this.#p(),next:()=>this.#g(),goTo:e=>this.#v(e),zoomIn:()=>this.#k(),zoomOut:()=>this.#T(),rotateLeft:()=>this.#A(),rotateRight:()=>this.#I(),flipX:()=>this.#_(),flipY:()=>this.#O(),reset:()=>this.#C(),getTransform:()=>this.#B()}}}#c(){if(this.itemsValue.length===0){let e=this.element.querySelectorAll(".hakumi-image img"),t=Array.from(e).map(i=>({src:i.dataset.previewSrc||i.src,alt:i.alt||""}));this.itemsValue=t}}handleLoad(){this.element.classList.remove("hakumi-image-error"),this.element.classList.add("hakumi-image-loaded"),this.hasErrorPlaceholderTarget&&(this.errorPlaceholderTarget.style.display="none")}handleError(){this.element.classList.add("hakumi-image-error"),this.imgTarget.style.display="none";let e=()=>{this.hasErrorPlaceholderTarget&&(this.errorPlaceholderTarget.style.display="flex")};if(this.fallbackValue){let t=new Image;t.src=this.fallbackValue,t.onload=()=>{this.imgTarget.src=this.fallbackValue,this.imgTarget.onerror=null,this.imgTarget.style.display="",this.element.classList.remove("hakumi-image-error"),this.element.classList.add("hakumi-image-loaded"),this.#e=!0,this.hasErrorPlaceholderTarget&&(this.errorPlaceholderTarget.style.display="none")},t.onerror=()=>{console.warn("Fallback image failed to load:",this.fallbackValue),e()}}else e()}openPreview(e){if(e&&e.preventDefault&&e.preventDefault(),this.itemsValue.length>0){let t=0;typeof e=="number"?t=e:e?.detail?.index!==void 0?t=e.detail.index:t=parseInt(e?.currentTarget?.closest("[data-index]")?.dataset?.index||0),this.currentValue=t}this.#C(),this.#m(),this.#V(),this.#f(),requestAnimationFrame(()=>{this.#h?.classList.add("hakumi-image-preview-active")}),document.body.style.overflow="hidden"}closePreview(){this.#d()}#d(){this.#h&&(this.#h.classList.remove("hakumi-image-preview-active"),setTimeout(()=>{this.#E(),this.#h?.remove(),this.#h=null,this.#l=null,document.body.style.overflow=""},300))}#m(){let e=this.itemsValue.length>0,t=e?this.itemsValue:[{src:this.#e?this.fallbackValue:this.previewSrcValue||this.srcValue,alt:this.altValue}],i=e&&t.length>1,s=this.previewTemplateTarget.content.cloneNode(!0);this.#h=s.firstElementChild;let a=this.#h.querySelector(".hakumi-image-preview-nav-wrapper");a&&(i?(a.style.display="block",this.#h.querySelector(".hakumi-image-preview-counter-total").textContent=t.length):a.style.display="none"),document.body.appendChild(this.#h),this.#l=this.#h.querySelector(".hakumi-image-preview-img"),me(this.#h,"hakumi-image-preview"),this.#h.dataset.controller="hakumi--image",this.#h.querySelectorAll("[data-action]").forEach(n=>{let r=n.dataset.action;n.removeAttribute("data-action"),n.addEventListener("click",o=>{let[,l]=r.match(/->hakumi--image#(\w+)/)||[];l&&typeof this[l]=="function"&&this[l](o)})}),i&&(this.#h.querySelector(".hakumi-image-preview-switch-left")?.addEventListener("click",()=>this.#p()),this.#h.querySelector(".hakumi-image-preview-switch-right")?.addEventListener("click",()=>this.#g())),this.maskClosableValue&&this.#h.querySelector(".hakumi-image-preview-wrap")?.addEventListener("click",r=>{(r.target.classList.contains("hakumi-image-preview-wrap")||r.target.classList.contains("hakumi-image-preview-body"))&&this.closePreview()})}#f(){if(!this.#l)return;let e,t;if(this.itemsValue.length>0){let s=this.itemsValue[this.currentValue];e=s.src,t=s.alt}else e=this.#e?this.fallbackValue:this.previewSrcValue||this.srcValue,t=this.altValue;this.#l.src=e,this.#l.alt=t||"";let i=this.#h?.querySelector(".hakumi-image-preview-counter-current");i&&(i.textContent=this.currentValue+1)}#p(){let e=this.itemsValue;e.length<=1||(this.currentValue=(this.currentValue-1+e.length)%e.length,this.#C(),this.#f())}#g(){let e=this.itemsValue;e.length<=1||(this.currentValue=(this.currentValue+1)%e.length,this.#C(),this.#f())}#v(e){let t=this.itemsValue;e<0||e>=t.length||(this.currentValue=e,this.#C(),this.#f())}#V(){this._handleKeydown=this.#D.bind(this),this._handleWheel=this.#x.bind(this),this._handleMouseDown=this.#y.bind(this),this._handleMouseMove=this.#w.bind(this),this._handleMouseUp=this.#b.bind(this),this._handleDoubleClick=this.#L.bind(this),document.addEventListener("keydown",this._handleKeydown),this.#l?.addEventListener("wheel",this._handleWheel,{passive:!1}),this.#l?.addEventListener("mousedown",this._handleMouseDown),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp),this.#l?.addEventListener("dblclick",this._handleDoubleClick)}#E(){document.removeEventListener("keydown",this._handleKeydown),this.#l?.removeEventListener("wheel",this._handleWheel),this.#l?.removeEventListener("mousedown",this._handleMouseDown),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this.#l?.removeEventListener("dblclick",this._handleDoubleClick)}#D(e){switch(e.key){case"Escape":this.closePreview();break;case"+":case"=":this.#k();break;case"-":this.#T();break}}#x(e){e.preventDefault(),e.deltaY<0?this.#k():this.#T()}#y(e){e.button===0&&(this.#r=!0,this.#u={x:e.clientX-this.#n,y:e.clientY-this.#o},this.#l.classList.add("hakumi-image-preview-img-dragging"))}#w(e){this.#r&&(this.#n=e.clientX-this.#u.x,this.#o=e.clientY-this.#u.y,this.#S())}#b(){this.#r=!1,this.#l?.classList.remove("hakumi-image-preview-img-dragging")}#L(){this.#C()}handleZoomIn(){this.#k()}handleZoomOut(){this.#T()}handleRotateLeft(){this.#A()}handleRotateRight(){this.#I()}handleFlipX(){this.#_()}handleFlipY(){this.#O()}#k(){this.#t=Math.min(this.#t*1.25,10),this.#S()}#T(){this.#t=Math.max(this.#t/1.25,.1),this.#S()}#A(){this.#i-=90,this.#S()}#I(){this.#i+=90,this.#S()}#_(){this.#s=!this.#s,this.#S()}#O(){this.#a=!this.#a,this.#S()}#C(){this.#t=1,this.#i=0,this.#s=!1,this.#a=!1,this.#n=0,this.#o=0,this.#S()}#S(){if(!this.#l)return;let e=this.#s?-1:1,t=this.#a?-1:1;this.#l.style.transform=`
|
|
36
|
+
translate(${this.#n}px, ${this.#o}px)
|
|
37
|
+
scale(${this.#t*e}, ${this.#t*t})
|
|
38
|
+
rotate(${this.#i}deg)
|
|
39
|
+
`.trim()}#B(){return{scale:this.#t,rotate:this.#i,flipX:this.#s,flipY:this.#a,x:this.#n,y:this.#o}}};var ta=Dt(Fn(),1);var gi=class extends m{static targets=["renderer"];static values={value:String,size:Number,type:String,color:String,bgColor:String,errorLevel:String,status:String,downloadName:String};registerApi(){let e={getValue:()=>this.valueValue,setValue:t=>this.setValue(t),getSize:()=>this.sizeValue,setSize:t=>this.setSize(t),getType:()=>this.typeValue,setType:t=>this.setType(t),setColors:({color:t,bgColor:i}={})=>this.setColors({color:t,bgColor:i}),setErrorLevel:t=>this.setErrorLevel(t),getDataUrl:()=>this.getDataUrl(),download:t=>this.download(t),rerender:()=>this.renderCode(),getState:()=>({value:this.valueValue,size:this.sizeValue,type:this.typeValue,errorLevel:this.errorLevelValue,status:this.statusValue,color:this.colorValue,bgColor:this.bgColorValue})};this.element.hakumiComponent={name:"qr_code",version:1,singleton:!1,api:e},this.#r(e)}setup(){this.#u(),this.#h(),this.renderCode()}disconnect(){this.#l(),delete this.element.hakumiQrCode,super.disconnect()}valueValueChanged(){this.renderCode()}sizeValueChanged(){this.#u(),this.renderCode()}typeValueChanged(){this.renderCode()}colorValueChanged(){this.renderCode()}bgColorValueChanged(){this.renderCode()}errorLevelValueChanged(){this.renderCode()}statusValueChanged(){this.renderCode()}async renderCode(){if(!this.hasRendererTarget)return;let e=this.valueValue;if(!e){this.rendererTarget.innerHTML="";return}let t=(this.typeValue||"canvas").toLowerCase(),i={margin:0,width:this.sizeValue||160,errorCorrectionLevel:(this.errorLevelValue||"M").toUpperCase(),color:{dark:this.#t(this.colorValue,"--color-text","#000000"),light:this.#t(this.bgColorValue,"--color-bg-container","#ffffff")}};try{if(t==="svg"){let s=await ta.default.toString(e,{type:"svg",...i});this.rendererTarget.innerHTML=s,this.svgMarkup=s,this.canvasElement=null}else{let s=this.#e();await ta.default.toCanvas(s,e,i),this.svgMarkup=null}}catch(s){console.error("[HakumiComponents] Failed to render QR code",s)}}setValue(e){this.valueValue=e}setSize(e){let t=Number(e);return Number.isNaN(t)||t<=0?!1:(this.sizeValue=t,!0)}setType(e){if(!e)return!1;let t=String(e).toLowerCase();return["canvas","svg"].includes(t)?(this.typeValue=t,!0):!1}setColors({color:e,bgColor:t}={}){return typeof e=="string"&&(this.colorValue=e),typeof t=="string"&&(this.bgColorValue=t),!0}setErrorLevel(e){if(!e)return!1;let t=String(e).trim().toUpperCase();return["L","M","Q","H"].includes(t)?(this.errorLevelValue=t,!0):!1}getDataUrl(){return this.canvasElement?this.canvasElement.toDataURL("image/png"):this.svgMarkup?`data:image/svg+xml;utf8,${encodeURIComponent(this.svgMarkup)}`:null}download(e){let t=this.getDataUrl();if(!t)return!1;let i=document.createElement("a");return i.href=t,i.download=e||this.downloadNameValue||"qr-code",i.click(),!0}#e(){if(this.canvasElement)return this.canvasElement;this.rendererTarget.innerHTML="";let e=document.createElement("canvas");return e.className="hakumi-qr-code-canvas",this.rendererTarget.appendChild(e),this.canvasElement=e,e}#t(e,t,i){let s=this.#i(e,t);return this.#s(s)||i}#i(e,t){let i=e&&e.trim()!==""?e.trim():null;if(!i||i.startsWith("var(")){let s=i?i.match(/var\((--[^)\s,]+)(?:,[^)]+)?\)/):null;return s?this.#o(s[1]):this.#o(t)}return i}#s(e){if(!e)return null;let t=e.trim();if(t==="")return null;if(t.startsWith("#"))return this.#a(t);if(/^rgba?/i.test(t)){let i=t.match(/^rgba?\(([^)]+)\)$/i);if(!i)return null;let s=i[1].split(",").map(o=>parseFloat(o.trim())).filter(o=>!Number.isNaN(o));if(s.length<3)return null;let[a,n,r]=s;return this.#n(a,n,r)}return null}#a(e){let t=e.replace("#","");return t.length===3||t.length===4?`#${t.slice(0,3).split("").map(i=>i+i).join("")}`:t.length===6||t.length===8?`#${t.slice(0,6)}`:null}#n(e,t,i){let s=a=>{let n=Math.round(a);return Number.isNaN(n)?0:Math.max(0,Math.min(255,n))};return`#${[s(e),s(t),s(i)].map(a=>a.toString(16).padStart(2,"0")).join("")}`}#o(e,t){return e&&getComputedStyle(this.element).getPropertyValue(e).trim()||t}#r(e){this.element.hakumiQrCode={getValue:()=>e.getValue(),setValue:t=>e.setValue(t),getSize:()=>e.getSize(),setSize:t=>e.setSize(t),getType:()=>e.getType(),setType:t=>e.setType(t),setColors:t=>e.setColors(t),setErrorLevel:t=>e.setErrorLevel(t),getDataUrl:()=>e.getDataUrl(),download:t=>e.download(t),rerender:()=>e.rerender(),getState:()=>e.getState()}}#u(){if(!this.sizeValue)return;let e=Math.max(1,Number(this.sizeValue));this.element.style.setProperty("--hakumi-qr-code-size",`${e}px`)}#h(){this._themeChangeHandler||(this._themeChangeHandler=()=>this.renderCode(),window.addEventListener("theme-changed",this._themeChangeHandler))}#l(){this._themeChangeHandler&&(window.removeEventListener("theme-changed",this._themeChangeHandler),this._themeChangeHandler=null)}};var vi=class extends m{static targets=["input","item","track"];static values={value:String,disabled:Boolean};setup(){this._name=this.inputTargets[0]?.name||`segmented_${Date.now()}`;let e=this.#s(this.valueValue??this.#i());this._currentValue=e,this._defaultValue=e,this.valueValue=e??"",this.#t(),this._initResizeObserver()}valueValueChanged(){this._currentValue=this.#s(this.valueValue),this.#t()}registerApi(){let e={getValue:()=>this.getValue(),setValue:t=>this.setValue(t),reset:()=>this.reset(),clear:()=>this.clear(),getOptions:()=>this.getOptions()};this.element.hakumiComponent={name:"segmented",version:1,singleton:!1,api:e},this.#e(e)}disconnect(){this._destroyResizeObserver(),delete this.element.hakumiSegmented,super.disconnect()}select(e){let t=e.target;!t||t.disabled||this.#a(t.value,{animate:!0})}getValue(){return this._currentValue??null}setValue(e){this.#a(e,{animate:!0})}clear(){this.#a(null,{animate:!0})}reset(){this.#a(this._defaultValue??null,{animate:!0})}getOptions(){return this.itemTargets.map(e=>{let t=e.querySelector("input[type='radio']");return{label:e.dataset.label||e.textContent?.trim(),value:t?.value,disabled:t?.disabled||e.dataset.disabled==="true",selected:t?.checked||!1}})}#e(e){this.element.hakumiSegmented=e}#t(){let e=this.itemTargets.find(s=>s.classList.contains("hakumi-segmented-item-selected"));this.inputTargets.forEach(s=>{let a=this._currentValue!==null&&s.value===this._currentValue;s.checked=a;let n=s.closest(".hakumi-segmented-item");n&&n.classList.toggle("hakumi-segmented-item-selected",a)});let t=this.itemTargets.find(s=>s.classList.contains("hakumi-segmented-item-selected"));this._pendingAnimation&&e&&t&&e!==t?(this._pendingAnimation=!1,requestAnimationFrame(()=>{setTimeout(()=>this._updateTrack(),80)})):this._updateTrack()}_updateTrack(){if(!this.hasTrackTarget)return;let e=this.trackTarget,t=this.itemTargets.find(r=>r.classList.contains("hakumi-segmented-item-selected"));if(!t){e.style.opacity="0",e.style.transform="translate3d(0, 0, 0)",e.style.width="0",e.style.height="0";return}let{offsetLeft:i,offsetTop:s,offsetWidth:a,offsetHeight:n}=t;e.style.width=`${a}px`,e.style.height=`${n}px`,e.style.transform=`translate3d(${i}px, ${s}px, 0)`,e.style.opacity="1"}_initResizeObserver(){typeof ResizeObserver>"u"||(this._resizeObserver=new ResizeObserver(()=>this._updateTrack()),this._resizeObserver.observe(this.element))}_destroyResizeObserver(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null)}#i(){let e=this.inputTargets.find(t=>t.checked);return e?e.value:null}#s(e){if(e==null)return null;let t=e.toString().trim();return t===""?null:t}#a(e,{animate:t=!1}={}){let i=this.#s(e);this._currentValue=i,this.valueValue=i??"",t&&(this._pendingAnimation=!0),this.dispatch("change",{detail:{value:i}})}};var yi=class extends m{static targets=["value"];static values={value:Number,animated:Boolean,duration:Number,precision:Number,countdown:Boolean,targetTimestamp:Number,format:String};setup(){this._initialized=!1,this._currentValue=this.hasValueValue?this.valueValue:null,this._initialValue=this._currentValue,this._running=!1,this._remainingMs=null,this._initialRemainingMs=null,this.countdownValue?(this._targetTimestamp=this.hasTargetTimestampValue?this.targetTimestampValue:null,this._targetTimestamp&&(this._initialRemainingMs=Math.max(0,this._targetTimestamp-Date.now()),this._remainingMs=this._initialRemainingMs),this.start()):this._currentValue!==null&&(this.animatedValue?this.#s(0,this._currentValue):this.#i(this._currentValue)),this._initialized=!0}registerApi(){let e={getValue:()=>this.getValue(),setValue:(t,i={})=>this.setValue(t,i),start:()=>this.start(),pause:()=>this.pause(),reset:()=>this.reset(),isRunning:()=>this.isRunning()};this.element.hakumiComponent={name:"statistic",version:1,singleton:!1,api:e},this.#r(e)}disconnect(){this.pause(),delete this.element.hakumiStatistic,super.disconnect()}valueValueChanged(e,t){if(!this._initialized||this.countdownValue)return;let i=Number.isFinite(t)?t:0,s=Number.isFinite(e)?e:null;this._currentValue=s,s!==null&&(this.animatedValue?this.#s(i,s):this.#i(s))}targetTimestampValueChanged(e){this.countdownValue&&(this._targetTimestamp=e,this._initialRemainingMs=Math.max(0,this._targetTimestamp-Date.now()),this._remainingMs=this._initialRemainingMs,this.reset())}getValue(){return this.countdownValue?this._remainingMs:this._currentValue}setValue(e,t={}){if(this.countdownValue){let s=this.#o(e);s&&(this.targetTimestampValue=s);return}let i=this.#n(e);i!==null&&(this.valueValue=i,t.animate===!1&&this.hasValueTarget&&this.#i(i))}start(){!this.countdownValue||this._running||!this._targetTimestamp&&this._remainingMs===null||(!this._targetTimestamp&&this._remainingMs!==null&&(this._targetTimestamp=Date.now()+this._remainingMs),this._running=!0,this.#e(),this._interval=setInterval(()=>this.#e(),1e3))}pause(){this._running&&(this._running=!1,this._interval&&(clearInterval(this._interval),this._interval=null),this._targetTimestamp&&(this._remainingMs=Math.max(0,this._targetTimestamp-Date.now())))}reset(){this.pause(),this._initialRemainingMs!==null&&(this._remainingMs=this._initialRemainingMs,this._targetTimestamp=Date.now()+this._initialRemainingMs,this.#t(this._remainingMs)),this.start()}isRunning(){return this._running}#e(){if(!this._targetTimestamp)return;let e=Math.max(0,this._targetTimestamp-Date.now());this._remainingMs=e,this.#t(e),e<=0&&this.pause()}#t(e){if(!this.hasValueTarget)return;let t=this.hasFormatValue?this.formatValue:"HH:mm:ss",i=Math.max(0,Math.floor(e/1e3)),s=Math.floor(i/86400),a=Math.floor(i/3600),n=a%24,r=Math.floor(i/60)%60,o=i%60,h=t.includes("DD")?n:a,u=t.replace("DD",String(s).padStart(2,"0")).replace("HH",String(h).padStart(2,"0")).replace("mm",String(r).padStart(2,"0")).replace("ss",String(o).padStart(2,"0"));this.valueTarget.textContent=u}#i(e){if(!this.hasValueTarget)return;let t=this.#a();this.valueTarget.textContent=t?t.format(e):String(e)}#s(e,t){if(!this.hasValueTarget)return;let i=this.hasDurationValue?this.durationValue:800,s=performance.now(),a=this.#a(),n=r=>{let o=Math.min(1,(r-s)/i),l=e+(t-e)*o,h=a?a.format(l):String(l);this.valueTarget.textContent=h,o<1&&requestAnimationFrame(n)};requestAnimationFrame(n)}#a(){return this.hasPrecisionValue&&Number.isFinite(this.precisionValue)?new Intl.NumberFormat(void 0,{minimumFractionDigits:this.precisionValue,maximumFractionDigits:this.precisionValue}):new Intl.NumberFormat}#n(e){if(e==null)return null;let t=Number(e);return Number.isNaN(t)?null:t}#o(e){if(!e)return null;if(e instanceof Date)return e.getTime();let t=Number(e);return Number.isNaN(t)?null:t}#r(e){this.element.hakumiStatistic=e}};function $n(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),i.push.apply(i,s)}return i}function we(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?$n(Object(i),!0).forEach(function(s){To(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):$n(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}function Ci(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ci=function(t){return typeof t}:Ci=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ci(e)}function To(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ee(){return Ee=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},Ee.apply(this,arguments)}function Co(e,t){if(e==null)return{};var i={},s=Object.keys(e),a,n;for(n=0;n<s.length;n++)a=s[n],!(t.indexOf(a)>=0)&&(i[a]=e[a]);return i}function So(e,t){if(e==null)return{};var i=Co(e,t),s,a;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(a=0;a<n.length;a++)s=n[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(i[s]=e[s])}return i}var Vo="1.15.6";function Ve(e){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(e)}var xe=Ve(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Vt=Ve(/Edge/i),Kn=Ve(/firefox/i),kt=Ve(/safari/i)&&!Ve(/chrome/i)&&!Ve(/android/i),fa=Ve(/iP(ad|od|hone)/i),Gn=Ve(/chrome/i)&&Ve(/android/i),Jn={capture:!1,passive:!1};function F(e,t,i){e.addEventListener(t,i,!xe&&Jn)}function N(e,t,i){e.removeEventListener(t,i,!xe&&Jn)}function Li(e,t){if(t){if(t[0]===">"&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch{return!1}return!1}}function Qn(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function ye(e,t,i,s){if(e){i=i||document;do{if(t!=null&&(t[0]===">"?e.parentNode===i&&Li(e,t):Li(e,t))||s&&e===i)return e;if(e===i)break}while(e=Qn(e))}return null}var zn=/\s+/g;function ce(e,t,i){if(e&&t)if(e.classList)e.classList[i?"add":"remove"](t);else{var s=(" "+e.className+" ").replace(zn," ").replace(" "+t+" "," ");e.className=(s+(i?" "+t:"")).replace(zn," ")}}function A(e,t,i){var s=e&&e.style;if(s){if(i===void 0)return document.defaultView&&document.defaultView.getComputedStyle?i=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(i=e.currentStyle),t===void 0?i:i[t];!(t in s)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),s[t]=i+(typeof i=="string"?"":"px")}}function ot(e,t){var i="";if(typeof e=="string")i=e;else do{var s=A(e,"transform");s&&s!=="none"&&(i=s+" "+i)}while(!t&&(e=e.parentNode));var a=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return a&&new a(i)}function Zn(e,t,i){if(e){var s=e.getElementsByTagName(t),a=0,n=s.length;if(i)for(;a<n;a++)i(s[a],a);return s}return[]}function ke(){var e=document.scrollingElement;return e||document.documentElement}function te(e,t,i,s,a){if(!(!e.getBoundingClientRect&&e!==window)){var n,r,o,l,h,u,c;if(e!==window&&e.parentNode&&e!==ke()?(n=e.getBoundingClientRect(),r=n.top,o=n.left,l=n.bottom,h=n.right,u=n.height,c=n.width):(r=0,o=0,l=window.innerHeight,h=window.innerWidth,u=window.innerHeight,c=window.innerWidth),(t||i)&&e!==window&&(a=a||e.parentNode,!xe))do if(a&&a.getBoundingClientRect&&(A(a,"transform")!=="none"||i&&A(a,"position")!=="static")){var d=a.getBoundingClientRect();r-=d.top+parseInt(A(a,"border-top-width")),o-=d.left+parseInt(A(a,"border-left-width")),l=r+n.height,h=o+n.width;break}while(a=a.parentNode);if(s&&e!==window){var g=ot(a||e),p=g&&g.a,f=g&&g.d;g&&(r/=f,o/=p,c/=p,u/=f,l=r+u,h=o+c)}return{top:r,left:o,bottom:l,right:h,width:c,height:u}}}function qn(e,t,i){for(var s=He(e,!0),a=te(e)[t];s;){var n=te(s)[i],r=void 0;if(i==="top"||i==="left"?r=a>=n:r=a<=n,!r)return s;if(s===ke())break;s=He(s,!1)}return!1}function lt(e,t,i,s){for(var a=0,n=0,r=e.children;n<r.length;){if(r[n].style.display!=="none"&&r[n]!==M.ghost&&(s||r[n]!==M.dragged)&&ye(r[n],i.draggable,e,!1)){if(a===t)return r[n];a++}n++}return null}function ga(e,t){for(var i=e.lastElementChild;i&&(i===M.ghost||A(i,"display")==="none"||t&&!Li(i,t));)i=i.previousElementSibling;return i||null}function ge(e,t){var i=0;if(!e||!e.parentNode)return-1;for(;e=e.previousElementSibling;)e.nodeName.toUpperCase()!=="TEMPLATE"&&e!==M.clone&&(!t||Li(e,t))&&i++;return i}function Un(e){var t=0,i=0,s=ke();if(e)do{var a=ot(e),n=a.a,r=a.d;t+=e.scrollLeft*n,i+=e.scrollTop*r}while(e!==s&&(e=e.parentNode));return[t,i]}function Eo(e,t){for(var i in e)if(e.hasOwnProperty(i)){for(var s in t)if(t.hasOwnProperty(s)&&t[s]===e[i][s])return Number(i)}return-1}function He(e,t){if(!e||!e.getBoundingClientRect)return ke();var i=e,s=!1;do if(i.clientWidth<i.scrollWidth||i.clientHeight<i.scrollHeight){var a=A(i);if(i.clientWidth<i.scrollWidth&&(a.overflowX=="auto"||a.overflowX=="scroll")||i.clientHeight<i.scrollHeight&&(a.overflowY=="auto"||a.overflowY=="scroll")){if(!i.getBoundingClientRect||i===document.body)return ke();if(s||t)return i;s=!0}}while(i=i.parentNode);return ke()}function xo(e,t){if(e&&t)for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function ia(e,t){return Math.round(e.top)===Math.round(t.top)&&Math.round(e.left)===Math.round(t.left)&&Math.round(e.height)===Math.round(t.height)&&Math.round(e.width)===Math.round(t.width)}var wt;function er(e,t){return function(){if(!wt){var i=arguments,s=this;i.length===1?e.call(s,i[0]):e.apply(s,i),wt=setTimeout(function(){wt=void 0},t)}}}function Lo(){clearTimeout(wt),wt=void 0}function tr(e,t,i){e.scrollLeft+=t,e.scrollTop+=i}function ir(e){var t=window.Polymer,i=window.jQuery||window.Zepto;return t&&t.dom?t.dom(e).cloneNode(!0):i?i(e).clone(!0)[0]:e.cloneNode(!0)}function sr(e,t,i){var s={};return Array.from(e.children).forEach(function(a){var n,r,o,l;if(!(!ye(a,t.draggable,e,!1)||a.animated||a===i)){var h=te(a);s.left=Math.min((n=s.left)!==null&&n!==void 0?n:1/0,h.left),s.top=Math.min((r=s.top)!==null&&r!==void 0?r:1/0,h.top),s.right=Math.max((o=s.right)!==null&&o!==void 0?o:-1/0,h.right),s.bottom=Math.max((l=s.bottom)!==null&&l!==void 0?l:-1/0,h.bottom)}}),s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}var ue="Sortable"+new Date().getTime();function Do(){var e=[],t;return{captureAnimationState:function(){if(e=[],!!this.options.animation){var s=[].slice.call(this.el.children);s.forEach(function(a){if(!(A(a,"display")==="none"||a===M.ghost)){e.push({target:a,rect:te(a)});var n=we({},e[e.length-1].rect);if(a.thisAnimationDuration){var r=ot(a,!0);r&&(n.top-=r.f,n.left-=r.e)}a.fromRect=n}})}},addAnimationState:function(s){e.push(s)},removeAnimationState:function(s){e.splice(Eo(e,{target:s}),1)},animateAll:function(s){var a=this;if(!this.options.animation){clearTimeout(t),typeof s=="function"&&s();return}var n=!1,r=0;e.forEach(function(o){var l=0,h=o.target,u=h.fromRect,c=te(h),d=h.prevFromRect,g=h.prevToRect,p=o.rect,f=ot(h,!0);f&&(c.top-=f.f,c.left-=f.e),h.toRect=c,h.thisAnimationDuration&&ia(d,c)&&!ia(u,c)&&(p.top-c.top)/(p.left-c.left)===(u.top-c.top)/(u.left-c.left)&&(l=Mo(p,d,g,a.options)),ia(c,u)||(h.prevFromRect=u,h.prevToRect=c,l||(l=a.options.animation),a.animate(h,p,c,l)),l&&(n=!0,r=Math.max(r,l),clearTimeout(h.animationResetTimer),h.animationResetTimer=setTimeout(function(){h.animationTime=0,h.prevFromRect=null,h.fromRect=null,h.prevToRect=null,h.thisAnimationDuration=null},l),h.thisAnimationDuration=l)}),clearTimeout(t),n?t=setTimeout(function(){typeof s=="function"&&s()},r):typeof s=="function"&&s(),e=[]},animate:function(s,a,n,r){if(r){A(s,"transition",""),A(s,"transform","");var o=ot(this.el),l=o&&o.a,h=o&&o.d,u=(a.left-n.left)/(l||1),c=(a.top-n.top)/(h||1);s.animatingX=!!u,s.animatingY=!!c,A(s,"transform","translate3d("+u+"px,"+c+"px,0)"),this.forRepaintDummy=Ao(s),A(s,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),A(s,"transform","translate3d(0,0,0)"),typeof s.animated=="number"&&clearTimeout(s.animated),s.animated=setTimeout(function(){A(s,"transition",""),A(s,"transform",""),s.animated=!1,s.animatingX=!1,s.animatingY=!1},r)}}}}function Ao(e){return e.offsetWidth}function Mo(e,t,i,s){return Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))/Math.sqrt(Math.pow(t.top-i.top,2)+Math.pow(t.left-i.left,2))*s.animation}var st=[],sa={initializeByDefault:!0},Et={mount:function(t){for(var i in sa)sa.hasOwnProperty(i)&&!(i in t)&&(t[i]=sa[i]);st.forEach(function(s){if(s.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),st.push(t)},pluginEvent:function(t,i,s){var a=this;this.eventCanceled=!1,s.cancel=function(){a.eventCanceled=!0};var n=t+"Global";st.forEach(function(r){i[r.pluginName]&&(i[r.pluginName][n]&&i[r.pluginName][n](we({sortable:i},s)),i.options[r.pluginName]&&i[r.pluginName][t]&&i[r.pluginName][t](we({sortable:i},s)))})},initializePlugins:function(t,i,s,a){st.forEach(function(o){var l=o.pluginName;if(!(!t.options[l]&&!o.initializeByDefault)){var h=new o(t,i,t.options);h.sortable=t,h.options=t.options,t[l]=h,Ee(s,h.defaults)}});for(var n in t.options)if(t.options.hasOwnProperty(n)){var r=this.modifyOption(t,n,t.options[n]);typeof r<"u"&&(t.options[n]=r)}},getEventProperties:function(t,i){var s={};return st.forEach(function(a){typeof a.eventProperties=="function"&&Ee(s,a.eventProperties.call(i[a.pluginName],t))}),s},modifyOption:function(t,i,s){var a;return st.forEach(function(n){t[n.pluginName]&&n.optionListeners&&typeof n.optionListeners[i]=="function"&&(a=n.optionListeners[i].call(t[n.pluginName],s))}),a}};function _o(e){var t=e.sortable,i=e.rootEl,s=e.name,a=e.targetEl,n=e.cloneEl,r=e.toEl,o=e.fromEl,l=e.oldIndex,h=e.newIndex,u=e.oldDraggableIndex,c=e.newDraggableIndex,d=e.originalEvent,g=e.putSortable,p=e.extraEventProperties;if(t=t||i&&i[ue],!!t){var f,C=t.options,V="on"+s.charAt(0).toUpperCase()+s.substr(1);window.CustomEvent&&!xe&&!Vt?f=new CustomEvent(s,{bubbles:!0,cancelable:!0}):(f=document.createEvent("Event"),f.initEvent(s,!0,!0)),f.to=r||i,f.from=o||i,f.item=a||i,f.clone=n,f.oldIndex=l,f.newIndex=h,f.oldDraggableIndex=u,f.newDraggableIndex=c,f.originalEvent=d,f.pullMode=g?g.lastPutMode:void 0;var B=we(we({},p),Et.getEventProperties(s,t));for(var O in B)f[O]=B[O];i&&i.dispatchEvent(f),C[V]&&C[V].call(t,f)}}var Io=["evt"],he=function(t,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=s.evt,n=So(s,Io);Et.pluginEvent.bind(M)(t,i,we({dragEl:k,parentEl:J,ghostEl:_,rootEl:X,nextEl:Ue,lastDownEl:Si,cloneEl:G,cloneHidden:Pe,dragStarted:vt,putSortable:ae,activeSortable:M.active,originalEvent:a,oldIndex:rt,oldDraggableIndex:Tt,newIndex:de,newDraggableIndex:Oe,hideGhostForTarget:or,unhideGhostForTarget:lr,cloneNowHidden:function(){Pe=!0},cloneNowShown:function(){Pe=!1},dispatchSortableEvent:function(o){re({sortable:i,name:o,originalEvent:a})}},n))};function re(e){_o(we({putSortable:ae,cloneEl:G,targetEl:k,rootEl:X,oldIndex:rt,oldDraggableIndex:Tt,newIndex:de,newDraggableIndex:Oe},e))}var k,J,_,X,Ue,Si,G,Pe,rt,de,Tt,Oe,bi,ae,nt=!1,Di=!1,Ai=[],ze,ve,aa,na,Wn,Yn,vt,at,Ct,St=!1,ki=!1,Vi,ne,ra=[],ca=!1,Mi=[],Ii=typeof document<"u",wi=fa,jn=Vt||xe?"cssFloat":"float",Oo=Ii&&!Gn&&!fa&&"draggable"in document.createElement("div"),ar=function(){if(Ii){if(xe)return!1;var e=document.createElement("x");return e.style.cssText="pointer-events:auto",e.style.pointerEvents==="auto"}}(),nr=function(t,i){var s=A(t),a=parseInt(s.width)-parseInt(s.paddingLeft)-parseInt(s.paddingRight)-parseInt(s.borderLeftWidth)-parseInt(s.borderRightWidth),n=lt(t,0,i),r=lt(t,1,i),o=n&&A(n),l=r&&A(r),h=o&&parseInt(o.marginLeft)+parseInt(o.marginRight)+te(n).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+te(r).width;if(s.display==="flex")return s.flexDirection==="column"||s.flexDirection==="column-reverse"?"vertical":"horizontal";if(s.display==="grid")return s.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(n&&o.float&&o.float!=="none"){var c=o.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===c)?"vertical":"horizontal"}return n&&(o.display==="block"||o.display==="flex"||o.display==="table"||o.display==="grid"||h>=a&&s[jn]==="none"||r&&s[jn]==="none"&&h+u>a)?"vertical":"horizontal"},Po=function(t,i,s){var a=s?t.left:t.top,n=s?t.right:t.bottom,r=s?t.width:t.height,o=s?i.left:i.top,l=s?i.right:i.bottom,h=s?i.width:i.height;return a===o||n===l||a+r/2===o+h/2},Ho=function(t,i){var s;return Ai.some(function(a){var n=a[ue].options.emptyInsertThreshold;if(!(!n||ga(a))){var r=te(a),o=t>=r.left-n&&t<=r.right+n,l=i>=r.top-n&&i<=r.bottom+n;if(o&&l)return s=a}}),s},rr=function(t){function i(n,r){return function(o,l,h,u){var c=o.options.group.name&&l.options.group.name&&o.options.group.name===l.options.group.name;if(n==null&&(r||c))return!0;if(n==null||n===!1)return!1;if(r&&n==="clone")return n;if(typeof n=="function")return i(n(o,l,h,u),r)(o,l,h,u);var d=(r?o:l).options.group.name;return n===!0||typeof n=="string"&&n===d||n.join&&n.indexOf(d)>-1}}var s={},a=t.group;(!a||Ci(a)!="object")&&(a={name:a}),s.name=a.name,s.checkPull=i(a.pull,!0),s.checkPut=i(a.put),s.revertClone=a.revertClone,t.group=s},or=function(){!ar&&_&&A(_,"display","none")},lr=function(){!ar&&_&&A(_,"display","")};Ii&&!Gn&&document.addEventListener("click",function(e){if(Di)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),Di=!1,!1},!0);var qe=function(t){if(k){t=t.touches?t.touches[0]:t;var i=Ho(t.clientX,t.clientY);if(i){var s={};for(var a in t)t.hasOwnProperty(a)&&(s[a]=t[a]);s.target=s.rootEl=i,s.preventDefault=void 0,s.stopPropagation=void 0,i[ue]._onDragOver(s)}}},Bo=function(t){k&&k.parentNode[ue]._isOutsideThisEl(t.target)};function M(e,t){if(!(e&&e.nodeType&&e.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=Ee({},t),e[ue]=this;var i={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return nr(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,o){r.setData("Text",o.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:M.supportPointer!==!1&&"PointerEvent"in window&&(!kt||fa),emptyInsertThreshold:5};Et.initializePlugins(this,e,i);for(var s in i)!(s in t)&&(t[s]=i[s]);rr(t);for(var a in this)a.charAt(0)==="_"&&typeof this[a]=="function"&&(this[a]=this[a].bind(this));this.nativeDraggable=t.forceFallback?!1:Oo,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?F(e,"pointerdown",this._onTapStart):(F(e,"mousedown",this._onTapStart),F(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(F(e,"dragover",this),F(e,"dragenter",this)),Ai.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),Ee(this,Do())}M.prototype={constructor:M,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(at=null)},_getDirection:function(t,i){return typeof this.options.direction=="function"?this.options.direction.call(this,t,i,k):this.options.direction},_onTapStart:function(t){if(t.cancelable){var i=this,s=this.el,a=this.options,n=a.preventOnFilter,r=t.type,o=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,l=(o||t).target,h=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,u=a.filter;if(Uo(s),!k&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||a.disabled)&&!h.isContentEditable&&!(!this.nativeDraggable&&kt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=ye(l,a.draggable,s,!1),!(l&&l.animated)&&Si!==l)){if(rt=ge(l),Tt=ge(l,a.draggable),typeof u=="function"){if(u.call(this,t,l,this)){re({sortable:i,rootEl:h,name:"filter",targetEl:l,toEl:s,fromEl:s}),he("filter",i,{evt:t}),n&&t.preventDefault();return}}else if(u&&(u=u.split(",").some(function(c){if(c=ye(h,c.trim(),s,!1),c)return re({sortable:i,rootEl:c,name:"filter",targetEl:l,fromEl:s,toEl:s}),he("filter",i,{evt:t}),!0}),u)){n&&t.preventDefault();return}a.handle&&!ye(h,a.handle,s,!1)||this._prepareDragStart(t,o,l)}}},_prepareDragStart:function(t,i,s){var a=this,n=a.el,r=a.options,o=n.ownerDocument,l;if(s&&!k&&s.parentNode===n){var h=te(s);if(X=n,k=s,J=k.parentNode,Ue=k.nextSibling,Si=s,bi=r.group,M.dragged=k,ze={target:k,clientX:(i||t).clientX,clientY:(i||t).clientY},Wn=ze.clientX-h.left,Yn=ze.clientY-h.top,this._lastX=(i||t).clientX,this._lastY=(i||t).clientY,k.style["will-change"]="all",l=function(){if(he("delayEnded",a,{evt:t}),M.eventCanceled){a._onDrop();return}a._disableDelayedDragEvents(),!Kn&&a.nativeDraggable&&(k.draggable=!0),a._triggerDragStart(t,i),re({sortable:a,name:"choose",originalEvent:t}),ce(k,r.chosenClass,!0)},r.ignore.split(",").forEach(function(u){Zn(k,u.trim(),oa)}),F(o,"dragover",qe),F(o,"mousemove",qe),F(o,"touchmove",qe),r.supportPointer?(F(o,"pointerup",a._onDrop),!this.nativeDraggable&&F(o,"pointercancel",a._onDrop)):(F(o,"mouseup",a._onDrop),F(o,"touchend",a._onDrop),F(o,"touchcancel",a._onDrop)),Kn&&this.nativeDraggable&&(this.options.touchStartThreshold=4,k.draggable=!0),he("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||i)&&(!this.nativeDraggable||!(Vt||xe))){if(M.eventCanceled){this._onDrop();return}r.supportPointer?(F(o,"pointerup",a._disableDelayedDrag),F(o,"pointercancel",a._disableDelayedDrag)):(F(o,"mouseup",a._disableDelayedDrag),F(o,"touchend",a._disableDelayedDrag),F(o,"touchcancel",a._disableDelayedDrag)),F(o,"mousemove",a._delayedDragTouchMoveHandler),F(o,"touchmove",a._delayedDragTouchMoveHandler),r.supportPointer&&F(o,"pointermove",a._delayedDragTouchMoveHandler),a._dragStartTimer=setTimeout(l,r.delay)}else l()}},_delayedDragTouchMoveHandler:function(t){var i=t.touches?t.touches[0]:t;Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){k&&oa(k),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;N(t,"mouseup",this._disableDelayedDrag),N(t,"touchend",this._disableDelayedDrag),N(t,"touchcancel",this._disableDelayedDrag),N(t,"pointerup",this._disableDelayedDrag),N(t,"pointercancel",this._disableDelayedDrag),N(t,"mousemove",this._delayedDragTouchMoveHandler),N(t,"touchmove",this._delayedDragTouchMoveHandler),N(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,i){i=i||t.pointerType=="touch"&&t,!this.nativeDraggable||i?this.options.supportPointer?F(document,"pointermove",this._onTouchMove):i?F(document,"touchmove",this._onTouchMove):F(document,"mousemove",this._onTouchMove):(F(k,"dragend",this),F(X,"dragstart",this._onDragStart));try{document.selection?Ei(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,i){if(nt=!1,X&&k){he("dragStarted",this,{evt:i}),this.nativeDraggable&&F(document,"dragover",Bo);var s=this.options;!t&&ce(k,s.dragClass,!1),ce(k,s.ghostClass,!0),M.active=this,t&&this._appendGhost(),re({sortable:this,name:"start",originalEvent:i})}else this._nulling()},_emulateDragOver:function(){if(ve){this._lastX=ve.clientX,this._lastY=ve.clientY,or();for(var t=document.elementFromPoint(ve.clientX,ve.clientY),i=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(ve.clientX,ve.clientY),t!==i);)i=t;if(k.parentNode[ue]._isOutsideThisEl(t),i)do{if(i[ue]){var s=void 0;if(s=i[ue]._onDragOver({clientX:ve.clientX,clientY:ve.clientY,target:t,rootEl:i}),s&&!this.options.dragoverBubble)break}t=i}while(i=Qn(i));lr()}},_onTouchMove:function(t){if(ze){var i=this.options,s=i.fallbackTolerance,a=i.fallbackOffset,n=t.touches?t.touches[0]:t,r=_&&ot(_,!0),o=_&&r&&r.a,l=_&&r&&r.d,h=wi&&ne&&Un(ne),u=(n.clientX-ze.clientX+a.x)/(o||1)+(h?h[0]-ra[0]:0)/(o||1),c=(n.clientY-ze.clientY+a.y)/(l||1)+(h?h[1]-ra[1]:0)/(l||1);if(!M.active&&!nt){if(s&&Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))<s)return;this._onDragStart(t,!0)}if(_){r?(r.e+=u-(aa||0),r.f+=c-(na||0)):r={a:1,b:0,c:0,d:1,e:u,f:c};var d="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");A(_,"webkitTransform",d),A(_,"mozTransform",d),A(_,"msTransform",d),A(_,"transform",d),aa=u,na=c,ve=n}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!_){var t=this.options.fallbackOnBody?document.body:X,i=te(k,!0,wi,!0,t),s=this.options;if(wi){for(ne=t;A(ne,"position")==="static"&&A(ne,"transform")==="none"&&ne!==document;)ne=ne.parentNode;ne!==document.body&&ne!==document.documentElement?(ne===document&&(ne=ke()),i.top+=ne.scrollTop,i.left+=ne.scrollLeft):ne=ke(),ra=Un(ne)}_=k.cloneNode(!0),ce(_,s.ghostClass,!1),ce(_,s.fallbackClass,!0),ce(_,s.dragClass,!0),A(_,"transition",""),A(_,"transform",""),A(_,"box-sizing","border-box"),A(_,"margin",0),A(_,"top",i.top),A(_,"left",i.left),A(_,"width",i.width),A(_,"height",i.height),A(_,"opacity","0.8"),A(_,"position",wi?"absolute":"fixed"),A(_,"zIndex","100000"),A(_,"pointerEvents","none"),M.ghost=_,t.appendChild(_),A(_,"transform-origin",Wn/parseInt(_.style.width)*100+"% "+Yn/parseInt(_.style.height)*100+"%")}},_onDragStart:function(t,i){var s=this,a=t.dataTransfer,n=s.options;if(he("dragStart",this,{evt:t}),M.eventCanceled){this._onDrop();return}he("setupClone",this),M.eventCanceled||(G=ir(k),G.removeAttribute("id"),G.draggable=!1,G.style["will-change"]="",this._hideClone(),ce(G,this.options.chosenClass,!1),M.clone=G),s.cloneId=Ei(function(){he("clone",s),!M.eventCanceled&&(s.options.removeCloneOnHide||X.insertBefore(G,k),s._hideClone(),re({sortable:s,name:"clone"}))}),!i&&ce(k,n.dragClass,!0),i?(Di=!0,s._loopId=setInterval(s._emulateDragOver,50)):(N(document,"mouseup",s._onDrop),N(document,"touchend",s._onDrop),N(document,"touchcancel",s._onDrop),a&&(a.effectAllowed="move",n.setData&&n.setData.call(s,a,k)),F(document,"drop",s),A(k,"transform","translateZ(0)")),nt=!0,s._dragStartId=Ei(s._dragStarted.bind(s,i,t)),F(document,"selectstart",s),vt=!0,window.getSelection().removeAllRanges(),kt&&A(document.body,"user-select","none")},_onDragOver:function(t){var i=this.el,s=t.target,a,n,r,o=this.options,l=o.group,h=M.active,u=bi===l,c=o.sort,d=ae||h,g,p=this,f=!1;if(ca)return;function C(D,H){he(D,p,we({evt:t,isOwner:u,axis:g?"vertical":"horizontal",revert:r,dragRect:a,targetRect:n,canSort:c,fromSortable:d,target:s,completed:B,onMove:function(Y,Q){return Ti(X,i,k,a,Y,te(Y),t,Q)},changed:O},H))}function V(){C("dragOverAnimationCapture"),p.captureAnimationState(),p!==d&&d.captureAnimationState()}function B(D){return C("dragOverCompleted",{insertion:D}),D&&(u?h._hideClone():h._showClone(p),p!==d&&(ce(k,ae?ae.options.ghostClass:h.options.ghostClass,!1),ce(k,o.ghostClass,!0)),ae!==p&&p!==M.active?ae=p:p===M.active&&ae&&(ae=null),d===p&&(p._ignoreWhileAnimating=s),p.animateAll(function(){C("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(s===k&&!k.animated||s===i&&!s.animated)&&(at=null),!o.dragoverBubble&&!t.rootEl&&s!==document&&(k.parentNode[ue]._isOutsideThisEl(t.target),!D&&qe(t)),!o.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),f=!0}function O(){de=ge(k),Oe=ge(k,o.draggable),re({sortable:p,name:"change",toEl:i,newIndex:de,newDraggableIndex:Oe,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),s=ye(s,o.draggable,i,!0),C("dragOver"),M.eventCanceled)return f;if(k.contains(t.target)||s.animated&&s.animatingX&&s.animatingY||p._ignoreWhileAnimating===s)return B(!1);if(Di=!1,h&&!o.disabled&&(u?c||(r=J!==X):ae===this||(this.lastPutMode=bi.checkPull(this,h,k,t))&&l.checkPut(this,h,k,t))){if(g=this._getDirection(t,s)==="vertical",a=te(k),C("dragOverValid"),M.eventCanceled)return f;if(r)return J=X,V(),this._hideClone(),C("revert"),M.eventCanceled||(Ue?X.insertBefore(k,Ue):X.appendChild(k)),B(!0);var $=ga(i,o.draggable);if(!$||$o(t,g,this)&&!$.animated){if($===k)return B(!1);if($&&i===t.target&&(s=$),s&&(n=te(s)),Ti(X,i,k,a,s,n,t,!!s)!==!1)return V(),$&&$.nextSibling?i.insertBefore(k,$.nextSibling):i.appendChild(k),J=i,O(),B(!0)}else if($&&Fo(t,g,this)){var T=lt(i,0,o,!0);if(T===k)return B(!1);if(s=T,n=te(s),Ti(X,i,k,a,s,n,t,!1)!==!1)return V(),i.insertBefore(k,T),J=i,O(),B(!0)}else if(s.parentNode===i){n=te(s);var R=0,I,P=k.parentNode!==i,E=!Po(k.animated&&k.toRect||a,s.animated&&s.toRect||n,g),q=g?"top":"left",U=qn(s,"top","top")||qn(k,"top","top"),S=U?U.scrollTop:void 0;at!==s&&(I=n[q],St=!1,ki=!E&&o.invertSwap||P),R=Ko(t,s,n,g,E?1:o.swapThreshold,o.invertedSwapThreshold==null?o.swapThreshold:o.invertedSwapThreshold,ki,at===s);var y;if(R!==0){var v=ge(k);do v-=R,y=J.children[v];while(y&&(A(y,"display")==="none"||y===_))}if(R===0||y===s)return B(!1);at=s,Ct=R;var w=s.nextElementSibling,b=!1;b=R===1;var x=Ti(X,i,k,a,s,n,t,b);if(x!==!1)return(x===1||x===-1)&&(b=x===1),ca=!0,setTimeout(No,30),V(),b&&!w?i.appendChild(k):s.parentNode.insertBefore(k,b?w:s),U&&tr(U,0,S-U.scrollTop),J=k.parentNode,I!==void 0&&!ki&&(Vi=Math.abs(I-te(s)[q])),O(),B(!0)}if(i.contains(k))return B(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){N(document,"mousemove",this._onTouchMove),N(document,"touchmove",this._onTouchMove),N(document,"pointermove",this._onTouchMove),N(document,"dragover",qe),N(document,"mousemove",qe),N(document,"touchmove",qe)},_offUpEvents:function(){var t=this.el.ownerDocument;N(t,"mouseup",this._onDrop),N(t,"touchend",this._onDrop),N(t,"pointerup",this._onDrop),N(t,"pointercancel",this._onDrop),N(t,"touchcancel",this._onDrop),N(document,"selectstart",this)},_onDrop:function(t){var i=this.el,s=this.options;if(de=ge(k),Oe=ge(k,s.draggable),he("drop",this,{evt:t}),J=k&&k.parentNode,de=ge(k),Oe=ge(k,s.draggable),M.eventCanceled){this._nulling();return}nt=!1,ki=!1,St=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),da(this.cloneId),da(this._dragStartId),this.nativeDraggable&&(N(document,"drop",this),N(i,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),kt&&A(document.body,"user-select",""),A(k,"transform",""),t&&(vt&&(t.cancelable&&t.preventDefault(),!s.dropBubble&&t.stopPropagation()),_&&_.parentNode&&_.parentNode.removeChild(_),(X===J||ae&&ae.lastPutMode!=="clone")&&G&&G.parentNode&&G.parentNode.removeChild(G),k&&(this.nativeDraggable&&N(k,"dragend",this),oa(k),k.style["will-change"]="",vt&&!nt&&ce(k,ae?ae.options.ghostClass:this.options.ghostClass,!1),ce(k,this.options.chosenClass,!1),re({sortable:this,name:"unchoose",toEl:J,newIndex:null,newDraggableIndex:null,originalEvent:t}),X!==J?(de>=0&&(re({rootEl:J,name:"add",toEl:J,fromEl:X,originalEvent:t}),re({sortable:this,name:"remove",toEl:J,originalEvent:t}),re({rootEl:J,name:"sort",toEl:J,fromEl:X,originalEvent:t}),re({sortable:this,name:"sort",toEl:J,originalEvent:t})),ae&&ae.save()):de!==rt&&de>=0&&(re({sortable:this,name:"update",toEl:J,originalEvent:t}),re({sortable:this,name:"sort",toEl:J,originalEvent:t})),M.active&&((de==null||de===-1)&&(de=rt,Oe=Tt),re({sortable:this,name:"end",toEl:J,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){he("nulling",this),X=k=J=_=Ue=G=Si=Pe=ze=ve=vt=de=Oe=rt=Tt=at=Ct=ae=bi=M.dragged=M.ghost=M.clone=M.active=null,Mi.forEach(function(t){t.checked=!0}),Mi.length=aa=na=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":k&&(this._onDragOver(t),Ro(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],i,s=this.el.children,a=0,n=s.length,r=this.options;a<n;a++)i=s[a],ye(i,r.draggable,this.el,!1)&&t.push(i.getAttribute(r.dataIdAttr)||qo(i));return t},sort:function(t,i){var s={},a=this.el;this.toArray().forEach(function(n,r){var o=a.children[r];ye(o,this.options.draggable,a,!1)&&(s[n]=o)},this),i&&this.captureAnimationState(),t.forEach(function(n){s[n]&&(a.removeChild(s[n]),a.appendChild(s[n]))}),i&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,i){return ye(t,i||this.options.draggable,this.el,!1)},option:function(t,i){var s=this.options;if(i===void 0)return s[t];var a=Et.modifyOption(this,t,i);typeof a<"u"?s[t]=a:s[t]=i,t==="group"&&rr(s)},destroy:function(){he("destroy",this);var t=this.el;t[ue]=null,N(t,"mousedown",this._onTapStart),N(t,"touchstart",this._onTapStart),N(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(N(t,"dragover",this),N(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(i){i.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ai.splice(Ai.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!Pe){if(he("hideClone",this),M.eventCanceled)return;A(G,"display","none"),this.options.removeCloneOnHide&&G.parentNode&&G.parentNode.removeChild(G),Pe=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(Pe){if(he("showClone",this),M.eventCanceled)return;k.parentNode==X&&!this.options.group.revertClone?X.insertBefore(G,k):Ue?X.insertBefore(G,Ue):X.appendChild(G),this.options.group.revertClone&&this.animate(k,G),A(G,"display",""),Pe=!1}}};function Ro(e){e.dataTransfer&&(e.dataTransfer.dropEffect="move"),e.cancelable&&e.preventDefault()}function Ti(e,t,i,s,a,n,r,o){var l,h=e[ue],u=h.options.onMove,c;return window.CustomEvent&&!xe&&!Vt?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=t,l.from=e,l.dragged=i,l.draggedRect=s,l.related=a||t,l.relatedRect=n||te(t),l.willInsertAfter=o,l.originalEvent=r,e.dispatchEvent(l),u&&(c=u.call(h,l,r)),c}function oa(e){e.draggable=!1}function No(){ca=!1}function Fo(e,t,i){var s=te(lt(i.el,0,i.options,!0)),a=sr(i.el,i.options,_),n=10;return t?e.clientX<a.left-n||e.clientY<s.top&&e.clientX<s.right:e.clientY<a.top-n||e.clientY<s.bottom&&e.clientX<s.left}function $o(e,t,i){var s=te(ga(i.el,i.options.draggable)),a=sr(i.el,i.options,_),n=10;return t?e.clientX>a.right+n||e.clientY>s.bottom&&e.clientX>s.left:e.clientY>a.bottom+n||e.clientX>s.right&&e.clientY>s.top}function Ko(e,t,i,s,a,n,r,o){var l=s?e.clientY:e.clientX,h=s?i.height:i.width,u=s?i.top:i.left,c=s?i.bottom:i.right,d=!1;if(!r){if(o&&Vi<h*a){if(!St&&(Ct===1?l>u+h*n/2:l<c-h*n/2)&&(St=!0),St)d=!0;else if(Ct===1?l<u+Vi:l>c-Vi)return-Ct}else if(l>u+h*(1-a)/2&&l<c-h*(1-a)/2)return zo(t)}return d=d||r,d&&(l<u+h*n/2||l>c-h*n/2)?l>u+h/2?1:-1:0}function zo(e){return ge(k)<ge(e)?1:-1}function qo(e){for(var t=e.tagName+e.className+e.src+e.href+e.textContent,i=t.length,s=0;i--;)s+=t.charCodeAt(i);return s.toString(36)}function Uo(e){Mi.length=0;for(var t=e.getElementsByTagName("input"),i=t.length;i--;){var s=t[i];s.checked&&Mi.push(s)}}function Ei(e){return setTimeout(e,0)}function da(e){return clearTimeout(e)}Ii&&F(document,"touchmove",function(e){(M.active||nt)&&e.cancelable&&e.preventDefault()});M.utils={on:F,off:N,css:A,find:Zn,is:function(t,i){return!!ye(t,i,t,!1)},extend:xo,throttle:er,closest:ye,toggleClass:ce,clone:ir,index:ge,nextTick:Ei,cancelNextTick:da,detectDirection:nr,getChild:lt,expando:ue};M.get=function(e){return e[ue]};M.mount=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t[0].constructor===Array&&(t=t[0]),t.forEach(function(s){if(!s.prototype||!s.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(s));s.utils&&(M.utils=we(we({},M.utils),s.utils)),Et.mount(s)})};M.create=function(e,t){return new M(e,t)};M.version=Vo;var ee=[],yt,pa,ma=!1,la,ha,_i,bt;function Wo(){function e(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}return e.prototype={dragStarted:function(i){var s=i.originalEvent;this.sortable.nativeDraggable?F(document,"dragover",this._handleAutoScroll):this.options.supportPointer?F(document,"pointermove",this._handleFallbackAutoScroll):s.touches?F(document,"touchmove",this._handleFallbackAutoScroll):F(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(i){var s=i.originalEvent;!this.options.dragOverBubble&&!s.rootEl&&this._handleAutoScroll(s)},drop:function(){this.sortable.nativeDraggable?N(document,"dragover",this._handleAutoScroll):(N(document,"pointermove",this._handleFallbackAutoScroll),N(document,"touchmove",this._handleFallbackAutoScroll),N(document,"mousemove",this._handleFallbackAutoScroll)),Xn(),xi(),Lo()},nulling:function(){_i=pa=yt=ma=bt=la=ha=null,ee.length=0},_handleFallbackAutoScroll:function(i){this._handleAutoScroll(i,!0)},_handleAutoScroll:function(i,s){var a=this,n=(i.touches?i.touches[0]:i).clientX,r=(i.touches?i.touches[0]:i).clientY,o=document.elementFromPoint(n,r);if(_i=i,s||this.options.forceAutoScrollFallback||Vt||xe||kt){ua(i,this.options,o,s);var l=He(o,!0);ma&&(!bt||n!==la||r!==ha)&&(bt&&Xn(),bt=setInterval(function(){var h=He(document.elementFromPoint(n,r),!0);h!==l&&(l=h,xi()),ua(i,a.options,h,s)},10),la=n,ha=r)}else{if(!this.options.bubbleScroll||He(o,!0)===ke()){xi();return}ua(i,this.options,He(o,!1),!1)}}},Ee(e,{pluginName:"scroll",initializeByDefault:!0})}function xi(){ee.forEach(function(e){clearInterval(e.pid)}),ee=[]}function Xn(){clearInterval(bt)}var ua=er(function(e,t,i,s){if(t.scroll){var a=(e.touches?e.touches[0]:e).clientX,n=(e.touches?e.touches[0]:e).clientY,r=t.scrollSensitivity,o=t.scrollSpeed,l=ke(),h=!1,u;pa!==i&&(pa=i,xi(),yt=t.scroll,u=t.scrollFn,yt===!0&&(yt=He(i,!0)));var c=0,d=yt;do{var g=d,p=te(g),f=p.top,C=p.bottom,V=p.left,B=p.right,O=p.width,$=p.height,T=void 0,R=void 0,I=g.scrollWidth,P=g.scrollHeight,E=A(g),q=g.scrollLeft,U=g.scrollTop;g===l?(T=O<I&&(E.overflowX==="auto"||E.overflowX==="scroll"||E.overflowX==="visible"),R=$<P&&(E.overflowY==="auto"||E.overflowY==="scroll"||E.overflowY==="visible")):(T=O<I&&(E.overflowX==="auto"||E.overflowX==="scroll"),R=$<P&&(E.overflowY==="auto"||E.overflowY==="scroll"));var S=T&&(Math.abs(B-a)<=r&&q+O<I)-(Math.abs(V-a)<=r&&!!q),y=R&&(Math.abs(C-n)<=r&&U+$<P)-(Math.abs(f-n)<=r&&!!U);if(!ee[c])for(var v=0;v<=c;v++)ee[v]||(ee[v]={});(ee[c].vx!=S||ee[c].vy!=y||ee[c].el!==g)&&(ee[c].el=g,ee[c].vx=S,ee[c].vy=y,clearInterval(ee[c].pid),(S!=0||y!=0)&&(h=!0,ee[c].pid=setInterval(function(){s&&this.layer===0&&M.active._onTouchMove(_i);var w=ee[this.layer].vy?ee[this.layer].vy*o:0,b=ee[this.layer].vx?ee[this.layer].vx*o:0;typeof u=="function"&&u.call(M.dragged.parentNode[ue],b,w,e,_i,ee[this.layer].el)!=="continue"||tr(ee[this.layer].el,b,w)}.bind({layer:c}),24))),c++}while(t.bubbleScroll&&d!==l&&(d=He(d,!1)));ma=h}},30),hr=function(t){var i=t.originalEvent,s=t.putSortable,a=t.dragEl,n=t.activeSortable,r=t.dispatchSortableEvent,o=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(i){var h=s||n;o();var u=i.changedTouches&&i.changedTouches.length?i.changedTouches[0]:i,c=document.elementFromPoint(u.clientX,u.clientY);l(),h&&!h.el.contains(c)&&(r("spill"),this.onSpill({dragEl:a,putSortable:s}))}};function va(){}va.prototype={startIndex:null,dragStart:function(t){var i=t.oldDraggableIndex;this.startIndex=i},onSpill:function(t){var i=t.dragEl,s=t.putSortable;this.sortable.captureAnimationState(),s&&s.captureAnimationState();var a=lt(this.sortable.el,this.startIndex,this.options);a?this.sortable.el.insertBefore(i,a):this.sortable.el.appendChild(i),this.sortable.animateAll(),s&&s.animateAll()},drop:hr};Ee(va,{pluginName:"revertOnSpill"});function ya(){}ya.prototype={onSpill:function(t){var i=t.dragEl,s=t.putSortable,a=s||this.sortable;a.captureAnimationState(),i.parentNode&&i.parentNode.removeChild(i),a.animateAll()},drop:hr};Ee(ya,{pluginName:"removeOnSpill"});M.mount(new Wo);M.mount(ya,va);var We=M;var Oi=class extends m{static targets=["row","selectionCheckbox","selectionAll","expandToggle","filterDropdown","filterOption","filterSearch","scrollContainer","dragHandle","scrollBar","scrollBarThumb"];static values={selectedRowKeys:String,selectionType:String,preserveSelectedRowKeys:Boolean,sortDirections:String,filterOnClose:Boolean,filterMode:String,filterSearch:Boolean,editableConfig:Object,serverSide:Boolean,href:String,sortFieldParam:{type:String,default:"sort_field"},sortOrderParam:{type:String,default:"sort_order"},turboFrame:String,rowDrag:{type:Boolean,default:!1},rowDragHandle:{type:Boolean,default:!1},columnDrag:{type:Boolean,default:!1},dataUrl:String,columnsConfig:String,pageSize:{type:Number,default:10}};setup(){this._selectedRowKeys=new Set(this.#H(this.selectedRowKeysValue,[])),this._selectionType=this.selectionTypeValue||"checkbox",this._sortDirections=(this.sortDirectionsValue||"ascend,descend").split(","),this._filters=new Map,this._sorter=null,this._expandedRowKeys=new Set(this.#b()),this._shouldCellUpdateHooks=new Map,this._rowSortable=null,this._columnSortable=null,this._pagination={current:1,pageSize:this.pageSizeValue||10,total:0},this._columnsConfig=this.#H(this.columnsConfigValue,[]),this.#y(),this.#I(),this.#O(),this.#C(),this.#S(),this.#K(),this.#o()}registerApi(){let e={getSelectedRowKeys:()=>this.getSelectedRowKeys(),setSelectedRowKeys:t=>this.setSelectedRowKeys(t),clearSelection:()=>this.clearSelection(),selectAll:()=>this.selectAll(),invertSelection:()=>this.invertSelection(),getSorter:()=>this.getSorter(),setSorter:t=>this.setSorter(t),clearSorter:()=>this.clearSorter(),getFilters:()=>this.getFilters(),setFilters:t=>this.setFilters(t),clearFilters:(t={})=>this.clearFilters(t),getExpandedRowKeys:()=>this.getExpandedRowKeys(),setExpandedRowKeys:t=>this.setExpandedRowKeys(t),toggleRowExpansion:t=>this.toggleRowExpansion(t),registerShouldCellUpdate:(t,i)=>this.registerShouldCellUpdate(t,i),unregisterShouldCellUpdate:t=>this.unregisterShouldCellUpdate(t),getRowOrder:()=>this.getRowOrder(),getColumnOrder:()=>this.getColumnOrder(),loadData:(t={})=>this.loadData(t),setPage:t=>this.setPage(t),setPageSize:t=>this.setPageSize(t),getPagination:()=>this.getPagination(),refresh:()=>this.refresh()};this.element.hakumiComponent={name:"table",version:1,singleton:!1,api:e},this.#V(e)}disconnect(){this.#B(),this._rowSortable&&(this._rowSortable.destroy(),this._rowSortable=null),this._columnSortable&&(this._columnSortable.destroy(),this._columnSortable=null),delete this.element.hakumiTable,super.disconnect()}toggleAll(e){if(this._selectionType!=="checkbox")return;let t=e.target.checked,i=this.#w();t?i.forEach(s=>this._selectedRowKeys.add(s)):this.preserveSelectedRowKeysValue||this._selectedRowKeys.clear(),this.#y(),this.#M()}toggleRow(e){let t=e.target.dataset.rowKey;t&&(this._selectionType==="radio"?(this._selectedRowKeys.clear(),e.target.checked&&this._selectedRowKeys.add(t)):e.target.checked?this._selectedRowKeys.add(t):this.preserveSelectedRowKeysValue||this._selectedRowKeys.delete(t),this.#y(),this.#M())}toggleExpand(e){e.preventDefault();let t=e.currentTarget.dataset.rowKey;t&&this.toggleRowExpansion(t)}toggleSort(e){let t=e.currentTarget;if(!t.dataset.sortable||t.dataset.sortable==="false"||e.target.closest(".hakumi-table-filter"))return;let i=t.dataset.columnKey,s=this._sorter?.field===i||this._sorter?.key===i?this._sorter.order:null,a=this.#$(s);this.setSorter({key:i,order:a})}toggleFilter(e){e.preventDefault()}applyFilters(e){let i=e.target.closest(".hakumi-table-filter-dropdown");if(!i)return;let s=i.dataset.columnKey,a=i.dataset.filterMultiple==="true",n=Array.from(i.querySelectorAll("input:checked")).map(r=>r.value);if(!a&&n.length>1){let r=n[n.length-1];i.querySelectorAll("input").forEach(o=>{o.checked=o.value===r}),this._filters.set(s,[r])}else this._filters.set(s,n);this.filterOnCloseValue&&this.#T()}confirmFilters(e){e.preventDefault(),this.#T(),e.currentTarget.closest("details")?.removeAttribute("open")}clearFilters(e={}){let t=e?.preventDefault?{closeDropdown:!0,confirm:!0}:e;e?.preventDefault&&e.preventDefault();let{closeDropdown:i=!0,confirm:s=!0}=t;this._filters.clear(),this.filterOptionTargets.forEach(a=>{a.checked=!1}),s&&this.#T(),i&&this.element.querySelectorAll("details[open]").forEach(a=>a.removeAttribute("open"))}filterSearch(e){let t=e.target,i=t.value.toLowerCase();(t.closest(".hakumi-table-filter-dropdown")?.querySelectorAll(".hakumi-table-filter-option")||[]).forEach(a=>{let n=a.textContent.toLowerCase();a.style.display=n.includes(i)?"":"none"})}getSelectedRowKeys(){return Array.from(this._selectedRowKeys)}setSelectedRowKeys(e){this._selectedRowKeys=new Set(Array(e).map(String)),this.#y(),this.#M()}clearSelection(){this._selectedRowKeys.clear(),this.#y(),this.#M()}selectAll(){this.#w().forEach(e=>this._selectedRowKeys.add(e)),this.#y(),this.#M()}invertSelection(){let e=this.#w(),t=new Set;e.forEach(i=>{this._selectedRowKeys.has(i)||t.add(i)}),this._selectedRowKeys=t,this.#y(),this.#M()}getSorter(){return this._sorter}setSorter(e){if(!e||!e.key||!e.order){this.clearSorter();return}this._sorter={field:e.key,order:e.order},this.#L(),this.hasDataUrlValue?(this._pagination.current=1,this.loadData()):this.#E()?this.#D():this.#k(),this.#P()}clearSorter(){this._sorter=null,this.#L(),this.hasDataUrlValue?(this._pagination.current=1,this.loadData()):this.#E()&&this.#D(),this.#P()}getFilters(){return Object.fromEntries(this._filters.entries())}setFilters(e={}){this._filters=new Map(Object.entries(e).map(([t,i])=>[t,Array(i)])),this.#_(),this.#T()}getExpandedRowKeys(){return Array.from(this._expandedRowKeys)}setExpandedRowKeys(e){this._expandedRowKeys=new Set(Array(e).map(String)),this.#C()}toggleRowExpansion(e){let t=String(e);this._expandedRowKeys.has(t)?this._expandedRowKeys.delete(t):this._expandedRowKeys.add(t),this.#C(),this.#P()}registerShouldCellUpdate(e,t){if(typeof t!="function"){console.warn(`[Hakumi Table] registerShouldCellUpdate: "${e}" must be a function`);return}this._shouldCellUpdateHooks.set(e,t)}unregisterShouldCellUpdate(e){this._shouldCellUpdateHooks.delete(e)}getRowOrder(){return this.rowTargets.filter(t=>t.dataset.rowType==="data").map(t=>t.dataset.rowKey)}getColumnOrder(){let e=this.element.querySelector(".hakumi-table-header-row");if(!e)return[];let t=e.querySelectorAll("th[data-column-key]");return Array.from(t).map(i=>i.dataset.columnKey)}async loadData(e={}){if(!this.hasDataUrlValue)return null;let t=e.page??this._pagination.current,i=e.pageSize??this._pagination.pageSize,s=e.sorter??this._sorter,a=new URLSearchParams;a.set("page",t),a.set("per_page",i),s?.field&&(a.set("sort_field",s.field),a.set("sort_order",s.order||"ascend"));let n=`${this.dataUrlValue}?${a.toString()}`;this.element.classList.add("hakumi-table-loading");try{let r=await fetch(n,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);let o=await r.json();return this._pagination={current:o.pagination.current,pageSize:o.pagination.pageSize,total:o.pagination.total},o.sorter&&(this._sorter=o.sorter),this.#e(o.data),this.#h(),this.#a(o),o}catch(r){throw this.#n(r),r}finally{this.element.classList.remove("hakumi-table-loading")}}setPage(e){if(!(e<1))return this._pagination.current=e,this.loadData({page:e})}setPageSize(e){return this._pagination.pageSize=e,this._pagination.current=1,this.loadData({page:1,pageSize:e})}getPagination(){return{...this._pagination}}refresh(){return this.loadData()}#e(e){let t=this.element.querySelector("tbody");if(!t)return;let i=this.#t(),s=e.map((a,n)=>this.#i(a,n,i));t.innerHTML=s.join(""),this.#y()}#t(){let e=this.element.querySelector(".hakumi-table-header-row");return e?Array.from(e.querySelectorAll("th[data-column-key]")).map(t=>({key:t.dataset.columnKey,dataIndex:t.dataset.field||t.dataset.columnKey,sortValue:t.dataset.sortField})):[]}#i(e,t,i){let s=e.key||e.id||t,a=i.map(n=>{let r=e[n.dataIndex]??"",o=n.sortValue?e[n.sortValue]??r:r;return`<td class="hakumi-table-cell" data-column-key="${n.key}" data-sort-value="${this.#s(o)}">${this.#s(r)}</td>`}).join("");return`<tr class="hakumi-table-row" data-row-key="${s}" data-row-type="data" data-hakumi--table-target="row">${a}</tr>`}#s(e){let t=document.createElement("div");return t.textContent=String(e),t.innerHTML}#a(e){this.dispatch("loadComplete",{detail:e})}#n(e){this.dispatch("loadError",{detail:{error:e}})}#o(){this.hasDataUrlValue&&(this.#r(),this.#l(),this.loadData())}#r(){let e=this.element.querySelector(".hakumi-table-pagination .hakumi-pagination");if(!e)return;let t=this.application.getControllerForElementAndIdentifier(e,"hakumi--pagination");t&&(this._pagination.pageSize=t.pageSizeValue||this._pagination.pageSize)}#u(){let e=this.element.querySelector(".hakumi-table-pagination .hakumi-pagination");return e?.hakumiPagination||e?.hakumiComponent?.api}#h(){let e=this.element.querySelector(".hakumi-table-pagination .hakumi-pagination");if(!e)return;let t=this.application.getControllerForElementAndIdentifier(e,"hakumi--pagination");if(!t)return;let{current:i,pageSize:s,total:a}=this._pagination;t.totalValue=a,t.pageSizeValue=s,t.currentValue=i,t.refresh()}#l(){let e=this.element.querySelector(".hakumi-table-pagination");!e||e._paginationBound||(e._paginationBound=!0,e.addEventListener("hakumi--pagination:change",t=>{t.stopPropagation();let i=t.detail.current;i!==this._pagination.current&&(this._pagination.current=i,this.loadData())}),e.addEventListener("hakumi--pagination:sizeChange",t=>{t.stopPropagation();let i=t.detail.pageSize;i!==this._pagination.pageSize&&(this._pagination.pageSize=i,this._pagination.current=1,this.loadData())}))}editCell(e){let t=e.currentTarget;if(t.querySelector(".hakumi-table-cell-editor"))return;((this.editableConfigValue||{}).mode||"cell")==="row"?this.#d(t):this.#c(t)}#c(e){let{input:t,editor:i,originalContent:s,originalValue:a,config:n}=this.#x(e);t.focus();let o=e.closest("tr")?.dataset.rowKey,l=n.key||e.dataset.columnKey,h=n.data_index,u=()=>{if(!i.isConnected)return;let d=t.value,g={rowKey:o,columnKey:l,dataIndex:h,value:d,originalValue:a};if(!this.#g(e,g)){s&&(s.style.display=""),i.remove();return}s&&(s.textContent=d,s.style.display=""),e.dataset.value=d,i.remove(),this.#m(g)},c=()=>{i.isConnected&&(s&&(s.style.display=""),i.remove())};t.addEventListener("blur",u),t.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),t.blur()):d.key==="Escape"&&(d.preventDefault(),t.removeEventListener("blur",u),c())})}#d(e){let t=e.closest("tr");if(!t||t.classList.contains("hakumi-table-row-editing"))return;t.classList.add("hakumi-table-row-editing");let i=t.dataset.rowKey,s=t.querySelectorAll("td[data-editable='true']"),a=[];s.forEach(l=>{let{input:h,originalContent:u,originalValue:c,config:d}=this.#x(l);h.dataset.columnKey=d.key||l.dataset.columnKey,h.dataset.dataIndex=d.data_index,h.dataset.originalValue=c,a.push({cell:l,input:h,originalContent:u,originalValue:c,config:d})});let n=e.querySelector(".hakumi-table-cell-input");n?n.focus():a.length>0&&a[0].input.focus();let r=()=>{let l=[],h=!0;if(a.forEach(({cell:u,input:c,originalContent:d,originalValue:g,config:p})=>{let f=c.value,C=p.key||u.dataset.columnKey,V=p.data_index,B={rowKey:i,columnKey:C,dataIndex:V,value:f,originalValue:g};if(!this.#g(u,B)){h=!1;return}l.push({cell:u,originalContent:d,newValue:f,detail:B})}),!h){o();return}l.forEach(({cell:u,originalContent:c,newValue:d})=>{c&&(c.textContent=d,c.style.display=""),u.dataset.value=d,u.querySelector(".hakumi-table-cell-editor")?.remove()}),t.classList.remove("hakumi-table-row-editing"),this.#f({rowKey:i,changes:l.map(({detail:u})=>u)})},o=()=>{a.forEach(({cell:l,originalContent:h})=>{h&&(h.style.display=""),l.querySelector(".hakumi-table-cell-editor")?.remove()}),t.classList.remove("hakumi-table-row-editing")};a.forEach(({input:l})=>{l.addEventListener("keydown",h=>{h.key==="Enter"?(h.preventDefault(),r()):h.key==="Escape"&&(h.preventDefault(),o())})}),this.element.dispatchEvent(new CustomEvent("hakumi:table:row-editing",{bubbles:!0,detail:{rowKey:i,save:r,cancel:o}}))}#m(e){this.element.dispatchEvent(new CustomEvent("hakumi:table:edit",{bubbles:!0,detail:e}))}#f(e){let t=this.#p(e.changes);this.element.dispatchEvent(new CustomEvent("hakumi:table:row-edit",{bubbles:!0,detail:{...e,params:t}}))}#p(e){let t={};return!e||!Array.isArray(e)||e.forEach(({columnKey:i,dataIndex:s,value:a})=>{let n=s||i;n&&(t[n]=a)}),t}#g(e,t){let i=e?.dataset.shouldCellUpdate;if(!i)return!0;let s=this.#v(i);if(typeof s!="function")return console.warn(`[Hakumi Table] shouldCellUpdate hook "${i}" is not a function`),!0;try{let a=s(t);return a===!1?!1:typeof a=="string"?(this.element.dispatchEvent(new CustomEvent("hakumi:table:cell-update-prevented",{bubbles:!0,detail:{...t,reason:a}})),!1):!0}catch(a){return console.error(`[Hakumi Table] shouldCellUpdate hook "${i}" failed`,a),!0}}#v(e){return e?this._shouldCellUpdateHooks.has(e)?this._shouldCellUpdateHooks.get(e):typeof window>"u"?null:window.HakumiTableShouldCellUpdate&&typeof window.HakumiTableShouldCellUpdate[e]=="function"?window.HakumiTableShouldCellUpdate[e]:e.split(".").reduce((t,i)=>t?t[i]:void 0,window):null}#V(e){this.element.hakumiTable=e}#E(){return this.serverSideValue||this.hasHrefValue}#D(){if(!this.hasHrefValue)return;let e=new URL(this.hrefValue,window.location.origin);if(new URL(window.location.href).searchParams.forEach((i,s)=>{e.searchParams.has(s)||e.searchParams.set(s,i)}),this._sorter&&this._sorter.key&&this._sorter.order?(e.searchParams.set(this.sortFieldParamValue,this._sorter.key),e.searchParams.set(this.sortOrderParamValue,this._sorter.order)):(e.searchParams.delete(this.sortFieldParamValue),e.searchParams.delete(this.sortOrderParamValue)),e.searchParams.set("page","1"),this.hasTurboFrameValue&&this.turboFrameValue){let i=document.getElementById(this.turboFrameValue);if(i){i.src=e.toString();return}}window.Turbo?window.Turbo.visit(e.toString()):window.location.href=e.toString()}#x(e){let t=this.#H(e.dataset.editableConfig,{}),i=e.querySelector(".hakumi-table-cell-content"),s=e.dataset.value??(i?.textContent?.trim()||""),a=document.createElement("div");a.className="hakumi-table-cell-editor";let n=document.createElement("input");return n.type=t.input_type||"text",n.value=s,n.className="hakumi-table-cell-input",a.appendChild(n),i&&(i.style.display="none"),e.appendChild(a),{input:n,editor:a,originalContent:i,originalValue:s,config:t}}#y(){let e=this._selectedRowKeys;this.selectionCheckboxTargets.forEach(t=>{let i=String(t.dataset.rowKey);t.checked=e.has(i);let s=t.closest("tr");s&&s.classList.toggle("hakumi-table-row-selected",t.checked)}),this.selectionAllTargets.forEach(t=>{let i=this.#w().length,s=e.size;t.checked=i>0&&s===i,t.indeterminate=s>0&&s<i})}#w(){return this.rowTargets.filter(e=>e.dataset.rowType==="data").map(e=>String(e.dataset.rowKey))}#b(){let e=this.element.querySelectorAll("tr[data-row-type='expanded'].is-expanded");return Array.from(e).map(t=>String(t.dataset.rowKey))}#L(){let e=this.element.querySelectorAll("th[data-column-key]"),t=this._sorter?.field||this._sorter?.key;e.forEach(i=>{t&&i.dataset.columnKey===String(t)?(i.dataset.sortOrder=this._sorter.order,i.classList.add("hakumi-table-header-sorted")):(delete i.dataset.sortOrder,i.classList.remove("hakumi-table-header-sorted"))})}#k(){if(!this._sorter||!this._sorter.order)return;let e=this.element.querySelector("tbody");if(!e)return;let t=this._sorter.field||this._sorter.key,i=this.rowTargets.filter(a=>a.dataset.rowType==="data"),s=(a,n)=>{let r=this.#A(a,t),o=this.#A(n,t);return r===o?0:this._sorter.order==="ascend"?r>o?1:-1:r<o?1:-1};i.sort(s),i.forEach(a=>{let n=e.querySelector(`tr[data-row-type='expanded'][data-row-key='${a.dataset.rowKey}']`);e.appendChild(a),n&&e.appendChild(n)})}#T(){let e=this._filters;this.rowTargets.forEach(t=>{if(t.dataset.rowType!=="data")return;let i=Array.from(e.entries()).every(([a,n])=>{if(!n||n.length===0)return!0;let r=this.#A(t,a);return n.includes(r)});t.hidden=!i;let s=t.nextElementSibling;s?.dataset.rowType==="expanded"&&(s.hidden=!i||!this._expandedRowKeys.has(String(t.dataset.rowKey)))}),this.#P()}#A(e,t){let i=e.querySelector(`td[data-column-key='${t}']`),s=i?.dataset.sortValue||i?.textContent?.trim()||"",a=Number.parseFloat(s);return!Number.isNaN(a)&&s!==""?a:s}#I(){this.element.querySelectorAll("th[data-default-filter]").forEach(t=>{let i=this.#H(t.dataset.defaultFilter,[]);i.length>0&&this._filters.set(t.dataset.columnKey,i)}),this._filters.size>0&&(this.#_(),this.#T())}#_(){this.filterOptionTargets.forEach(e=>{let t=e.closest(".hakumi-table-filter-dropdown")?.dataset.columnKey,i=this._filters.get(t)||[];e.checked=i.includes(e.value)})}#O(){let e=this.element.querySelectorAll("th[data-default-sort]");for(let t of e){let i=t.dataset.defaultSort;if(i&&i!==""){this._sorter={key:t.dataset.columnKey,order:i},this.#L(),this.#E()||this.#k();break}}}#C(){this.rowTargets.forEach(e=>{if(e.dataset.rowType!=="data")return;let t=String(e.dataset.rowKey),i=e.nextElementSibling;if(!i||i.dataset.rowType!=="expanded")return;let s=this._expandedRowKeys.has(t);i.hidden=!s,i.classList.toggle("is-expanded",s);let a=e.querySelector("[data-hakumi--table-target='expandToggle']");a&&(a.setAttribute("aria-expanded",s),a.classList.toggle("is-expanded",s))})}#S(){this.hasScrollContainerTarget&&(this._scrollHandler||=()=>this.#R(),this.scrollContainerTarget.addEventListener("scroll",this._scrollHandler,{passive:!0}),this.hasScrollBarTarget&&(this._scrollBarHandler||=()=>this.#N(),this.scrollBarTarget.addEventListener("scroll",this._scrollBarHandler,{passive:!0}),this.#F()),this.#R())}#B(){this._scrollHandler&&this.hasScrollContainerTarget&&this.scrollContainerTarget.removeEventListener("scroll",this._scrollHandler),this._scrollBarHandler&&this.hasScrollBarTarget&&this.scrollBarTarget.removeEventListener("scroll",this._scrollBarHandler),this._scrollHandler=null,this._scrollBarHandler=null}#R(){if(!this.hasScrollContainerTarget)return;let e=this.scrollContainerTarget,t=e.scrollWidth-e.clientWidth,i=e.scrollLeft>0,s=e.scrollLeft<t-1;this.element.classList.toggle("hakumi-table-scroll-left",i),this.element.classList.toggle("hakumi-table-scroll-right",s),this.hasScrollBarTarget&&!this._syncingFromBar&&(this._syncingFromContainer=!0,this.scrollBarTarget.scrollLeft=e.scrollLeft,this._syncingFromContainer=!1)}#N(){!this.hasScrollContainerTarget||this._syncingFromContainer||(this._syncingFromBar=!0,this.scrollContainerTarget.scrollLeft=this.scrollBarTarget.scrollLeft,this._syncingFromBar=!1)}#F(){if(!this.hasScrollBarThumbTarget||!this.hasScrollContainerTarget)return;let e=this.scrollContainerTarget;this.scrollBarThumbTarget.style.width=`${e.scrollWidth}px`}#$(e){if(!e)return this._sortDirections[0];let t=this._sortDirections.indexOf(e);return t===-1||t===this._sortDirections.length-1?null:this._sortDirections[t+1]}#M(){this.element.dispatchEvent(new CustomEvent("hakumi:table:selection-change",{bubbles:!0,detail:{selectedRowKeys:this.getSelectedRowKeys()}}))}#P(){this.element.dispatchEvent(new CustomEvent("hakumi:table:change",{bubbles:!0,detail:{selectedRowKeys:this.getSelectedRowKeys(),sorter:this._sorter,filters:this.getFilters()}}))}#H(e,t){try{return JSON.parse(e||"")}catch{return t}}#K(){this.rowDragValue&&this.#z(),this.columnDragValue&&this.#q()}#z(){let e=this.element.querySelector("tbody");if(!e)return;let t={animation:150,ghostClass:"hakumi-table-row-ghost",chosenClass:"hakumi-table-row-chosen",dragClass:"hakumi-table-row-drag",filter:".hakumi-table-expanded-row",onEnd:i=>{if(i.oldIndex===i.newIndex)return;let s=i.item,a=s.dataset.rowKey,n=s.nextElementSibling;n?.dataset.rowType==="expanded"&&s.parentNode.insertBefore(n,s.nextSibling),this.#W(i.oldIndex,i.newIndex,a)}};this.rowDragHandleValue&&(t.handle=".hakumi-table-drag-handle"),this._rowSortable=We.create(e,t)}#q(){let e=this.element.querySelector(".hakumi-table-header-row");e&&(this._columnSortable=We.create(e,{animation:150,ghostClass:"hakumi-table-column-ghost",chosenClass:"hakumi-table-column-chosen",dragClass:"hakumi-table-column-drag",filter:".hakumi-table-selection-column, .hakumi-table-expand-column",onEnd:t=>{if(t.oldIndex===t.newIndex)return;let s=t.item.dataset.columnKey;this.#U(t.oldIndex,t.newIndex),this.#Y(t.oldIndex,t.newIndex,s)}}))}#U(e,t){this.element.querySelectorAll("tbody tr").forEach(s=>{let a=Array.from(s.children);if(a[e]&&a[t]){let n=a[e],r=e<t?a[t].nextSibling:a[t];s.insertBefore(n,r)}})}#W(e,t,i){this.element.dispatchEvent(new CustomEvent("hakumi--table:rowReorder",{bubbles:!0,detail:{oldIndex:e,newIndex:t,rowKey:i,order:this.getRowOrder()}}))}#Y(e,t,i){this.element.dispatchEvent(new CustomEvent("hakumi--table:columnReorder",{bubbles:!0,detail:{oldIndex:e,newIndex:t,columnKey:i,order:this.getColumnOrder()}}))}};var Pi=class extends m{static targets=["tab","pane","inkBar","navList","navWrap","operations","overflowSelect"];static values={activeKey:String,tabPosition:{type:String,default:"top"},indicatorSize:{type:Number,default:0},indicatorAlign:{type:String,default:"center"},tabTemplate:String,paneTemplate:String,closeButtonTemplate:String};setup(){this._isUpdating=!1,this.#e(),!this.activeKeyValue&&this._tabs.length>0&&(this.activeKeyValue=this._tabs[0].key),requestAnimationFrame(()=>{this.#v(),this.#p()}),this.boundResize=()=>{this._isUpdating||(this.#v(),this.#p())},window.addEventListener("resize",this.boundResize),this.hasNavWrapTarget&&(this.resizeObserver=new ResizeObserver(()=>{this._isUpdating||(this.#v(),this.#p())}),this.resizeObserver.observe(this.navWrapTarget))}teardown(){window.removeEventListener("resize",this.boundResize),this.resizeObserver&&this.resizeObserver.disconnect()}registerApi(){this.element.hakumiComponent={name:"tabs",version:1,singleton:!1,api:{getActiveKey:()=>this.activeKeyValue,getValue:()=>this.activeKeyValue,setActiveKey:e=>this.#h(e),setValue:e=>this.#h(e),getItems:()=>this.#u(),next:()=>this.#d(),prev:()=>this.#m(),removeTab:e=>this.#f(e),addTab:(e={})=>this.#a(e),reset:()=>this.#l()}}}#e(){this._tabs=[],this.tabTargets.forEach(e=>{let t=e.dataset.key,i=this.paneTargets.find(s=>s.dataset.key===t);this._tabs.push({key:t,label:e.querySelector(".hakumi-tabs-tab-label")?.textContent||t,disabled:e.classList.contains("hakumi-tabs-tab-disabled"),closable:e.querySelector(".hakumi-tabs-tab-remove")!==null,tabEl:e,paneEl:i})})}#t(e){if(!e.tabEl)return;let t=this.#i();this.navListTarget.insertBefore(e.tabEl,t)}#i(){return this.element.querySelector(".hakumi-tabs-nav-add")||this.inkBarTarget||null}#s(e){if(!this.hasNavListTarget)return 0;let t=window.getComputedStyle(this.navListTarget),i=s=>{let a=parseFloat(s);return Number.isFinite(a)?a:0};return i(e?t.rowGap||t.gap:t.columnGap||t.gap)}#a({key:e,label:t,content:i="",closable:s=!0,activate:a=!0}){let n=e||`tab-${Date.now()}`,r=t||"New Tab",o=this.#n(n,r,s),l=this.#o(n,i),h={key:n,label:r,disabled:!1,closable:s,tabEl:o,paneEl:l};this._tabs.push(h),this.#t(h);let u=this.element.querySelector(".hakumi-tabs-content-holder");return u&&u.appendChild(l),this.dispatch("tabAdded",{detail:{key:n,label:r}}),a&&requestAnimationFrame(()=>this.#c(n)),this.#p(),n}#n(e,t,i){if(this.hasTabTemplateValue){let a=i?this.#r(e):"",n=this.tabTemplateValue.replace(/\{\{key\}\}/g,e).replace(/\{\{label\}\}/g,t).replace(/\{\{closeButton\}\}/g,a),r=document.createElement("template");return r.innerHTML=n.trim(),r.content.firstChild}let s=document.createElement("div");return s.className="hakumi-tabs-tab",s.dataset.key=e,s.dataset.antTabsTarget="tab",s.dataset.action="click->hakumi--tabs#selectTab",s.innerHTML=`
|
|
40
|
+
<div class="hakumi-tabs-tab-btn">
|
|
41
|
+
<span class="hakumi-tabs-tab-label">${t}</span>
|
|
42
|
+
</div>
|
|
43
|
+
${i?this.#r(e):""}
|
|
44
|
+
`,s}#o(e,t){if(this.hasPaneTemplateValue){let s=this.paneTemplateValue.replace(/\{\{key\}\}/g,e).replace(/\{\{content\}\}/g,t),a=document.createElement("template");return a.innerHTML=s.trim(),a.content.firstChild}let i=document.createElement("div");return i.className="hakumi-tabs-tabpane hakumi-tabs-tabpane-hidden",i.dataset.key=e,i.dataset.antTabsTarget="pane",i.setAttribute("aria-hidden","true"),i.innerHTML=t,i}#r(e){if(this.hasCloseButtonTemplateValue)return this.closeButtonTemplateValue.replace(/\{\{key\}\}/g,e);let t=this.element.querySelector(".hakumi-tabs-tab-remove");if(t){let i=t.cloneNode(!0);return i.dataset.key=e,i.outerHTML}return`
|
|
45
|
+
<button type="button" class="hakumi-button hakumi-button-text hakumi-button-small hakumi-tabs-tab-remove" data-key="${e}" data-action="click->hakumi--tabs#removeTab">
|
|
46
|
+
<span class="hakumi-icon hakumi-icon-close"><svg viewBox="64 64 896 896" focusable="false" fill="currentColor" width="1em" height="1em"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></span>
|
|
47
|
+
</button>
|
|
48
|
+
`}#u(){return this._tabs.map(e=>({key:e.key,label:e.label,disabled:e.disabled,active:e.key===this.activeKeyValue}))}#h(e){this.#c(e)}#l(){let e=this._tabs.find(t=>!t.disabled);e&&this.#c(e.key)}#c(e){let t=this._tabs.find(s=>s.key===e);if(!t||t.disabled)return;let i=this.activeKeyValue;e!==i&&(this._tabs.forEach(s=>{let a=s.key===e;s.tabEl&&(s.tabEl.classList.toggle("hakumi-tabs-tab-active",a),s.tabEl.setAttribute("aria-selected",a.toString()),s.tabEl.setAttribute("tabindex",a?"0":"-1")),s.paneEl&&(s.paneEl.classList.toggle("hakumi-tabs-tabpane-active",a),s.paneEl.classList.toggle("hakumi-tabs-tabpane-hidden",!a),s.paneEl.setAttribute("aria-hidden",(!a).toString()))}),this.activeKeyValue=e,this.#p(),this.#v(),this.dispatch("change",{detail:{activeKey:e,previousKey:i}}))}#d(){let t=(this._tabs.findIndex(s=>s.key===this.activeKeyValue)+1)%this._tabs.length,i=this._tabs[t];i&&!i.disabled&&this.#c(i.key)}#m(){let e=this._tabs.findIndex(s=>s.key===this.activeKeyValue),t=e===0?this._tabs.length-1:e-1,i=this._tabs[t];i&&!i.disabled&&this.#c(i.key)}#f(e){let t=this._tabs.findIndex(a=>a.key===e);if(t===-1)return;let i=this._tabs[t],s=e===this.activeKeyValue;if(this.dispatch("edit",{detail:{type:"remove",key:e}}),i.tabEl&&i.tabEl.remove(),i.paneEl&&i.paneEl.remove(),this._tabs.splice(t,1),s&&this._tabs.length>0){let a=Math.min(t,this._tabs.length-1);this.#c(this._tabs[a].key)}this.#p(),this.#v()}selectTab(e){let i=e.currentTarget.dataset.key;this.#c(i)}removeTab(e){e&&e.stopPropagation();let t=e.currentTarget.dataset.key;this.#f(t)}addTab(e){e&&e.preventDefault(),this.dispatch("add",{detail:{action:"add"}})}selectFromOverflow(e){let t=e.target,i=t.value;i&&(this.#c(i),this.#p(),t.value="")}#p(){if(!(!this.hasNavWrapTarget||!this.hasNavListTarget||!this.hasOperationsTarget)&&!this._isUpdating){this._isUpdating=!0;try{let e=["left","right"].includes(this.tabPositionValue),t=e?this.navWrapTarget.clientHeight:this.navWrapTarget.clientWidth,i=this.element.querySelector(".hakumi-tabs-nav-add"),s=i?e?i.offsetHeight:i.offsetWidth:0,a=50,n=new Map;this._tabs.forEach(T=>{T.tabEl&&(T.tabEl.classList.remove("hakumi-tabs-tab-hidden"),n.set(T.key,e?T.tabEl.offsetHeight:T.tabEl.offsetWidth))});let r=this.#s(e),o=0;n.forEach(T=>o+=T),o+=Math.max(this._tabs.length-1,0)*r;let l=o>t-s,h=t-s-(l?a:0),u=this._tabs.find(T=>T.key===this.activeKeyValue),c=u&&n.get(u.key)||0,d=Math.max(h-c,0),g=u?1:0,p=new Set,f=new Set;u&&p.add(u),this._tabs.forEach(T=>{if(!T.tabEl||T===u)return;let I=(n.get(T.key)||0)+(g>0?r:0);d>=I?(p.add(T),d-=I,g+=1):f.add(T)});let C=this._tabs.filter(T=>p.has(T)),V=this._tabs.filter(T=>f.has(T)),B=this.navListTarget,O=this.#i();C.forEach(T=>{T.tabEl&&B.insertBefore(T.tabEl,O)}),V.forEach(T=>{T.tabEl&&B.insertBefore(T.tabEl,O)}),this._tabs.forEach(T=>{if(!T.tabEl)return;let R=f.has(T);T.tabEl.classList.toggle("hakumi-tabs-tab-hidden",R)});let $=V.length>0;this.operationsTarget.style.display=$?"flex":"none",this.hasInkBarTarget&&this.inkBarTarget.classList.remove("hakumi-tabs-ink-bar-hidden"),$&&this.hasOverflowSelectTarget&&this.#g(V)}finally{this._isUpdating=!1}}}#g(e){let i=(this.overflowSelectTarget.querySelector(".hakumi-select")||this.overflowSelectTarget).querySelector(".hakumi-select-dropdown");if(i){let s=i.querySelector(".hakumi-select-options")||i;s.innerHTML="",e.forEach(a=>{let n=document.createElement("div");n.className="hakumi-select-item hakumi-select-item-option",n.dataset.value=a.key,n.dataset.label=a.label,n.dataset.antSelectTarget="option",n.dataset.action="click->hakumi--select#select",n.setAttribute("role","option"),n.innerHTML=`<div class="hakumi-select-item-option-content">${a.label}</div>`,s.appendChild(n)})}}#v(){if(!this.hasInkBarTarget||!this.hasNavListTarget)return;let e=this._tabs.find(r=>r.key===this.activeKeyValue);if(!e||!e.tabEl){this.inkBarTarget.style.width="0";return}let t=e.tabEl;if(t.classList.contains("hakumi-tabs-tab-hidden"))return;let i=["left","right"].includes(this.tabPositionValue),s=this.indicatorSizeValue>0,a=this.navListTarget.getBoundingClientRect(),n=t.getBoundingClientRect();if(i){let r=n.height,o=s?Math.min(this.indicatorSizeValue,r):r,l=n.top-a.top;if(s&&o<r){let h=r-o;this.indicatorAlignValue==="center"?l+=h/2:this.indicatorAlignValue==="end"&&(l+=h)}this.inkBarTarget.style.top=`${l}px`,this.inkBarTarget.style.height=`${o}px`,this.inkBarTarget.style.width="2px",this.inkBarTarget.style.left=""}else{let r=n.width,o=s?Math.min(this.indicatorSizeValue,r):r,l=n.left-a.left;if(s&&o<r){let h=r-o;this.indicatorAlignValue==="center"?l+=h/2:this.indicatorAlignValue==="end"&&(l+=h)}this.inkBarTarget.style.left=`${l}px`,this.inkBarTarget.style.width=`${o}px`,this.inkBarTarget.style.height="2px",this.inkBarTarget.style.top=""}}};import{Controller as Yo}from"@hotwired/stimulus";var Hi=class extends Yo{static values={checkable:{type:Boolean,default:!1},checked:{type:Boolean,default:!1}};connect(){this.#i(),this.checkableValue&&this.element.addEventListener("click",this.#e)}disconnect(){delete this.element.hakumiTag,this.checkableValue&&this.element.removeEventListener("click",this.#e)}close(e){if(e&&e.stopPropagation(),this.element.classList.add("hakumi-tag-hidden"),this.dispatch("close",{detail:{element:this.element},cancelable:!0}).defaultPrevented){this.element.classList.remove("hakumi-tag-hidden");return}setTimeout(()=>{this.dispatch("afterClose",{detail:{element:this.element}}),this.element.remove()},200)}toggle(){this.checkableValue&&(this.checkedValue=!this.checkedValue,this.#t(),this.dispatch("change",{detail:{checked:this.checkedValue,element:this.element}}))}check(){!this.checkableValue||this.checkedValue||(this.checkedValue=!0,this.#t(),this.dispatch("change",{detail:{checked:!0,element:this.element}}))}uncheck(){!this.checkableValue||!this.checkedValue||(this.checkedValue=!1,this.#t(),this.dispatch("change",{detail:{checked:!1,element:this.element}}))}isChecked(){return this.checkedValue}#e=e=>{e.target.closest(".hakumi-tag-close-icon")||this.toggle()};#t(){this.element.classList.toggle("hakumi-tag-checkable-checked",this.checkedValue)}#i(){this.element.hakumiTag={close:()=>this.close(),toggle:()=>this.toggle(),check:()=>this.check(),uncheck:()=>this.uncheck(),isChecked:()=>this.isChecked()}}};import{Controller as jo}from"@hotwired/stimulus";var Bi=class extends jo{static values={sortable:{type:Boolean,default:!1},animation:{type:Number,default:150}};connect(){this._sortable=null,this.sortableValue&&this.#e(),this.#i()}disconnect(){this.#t(),delete this.element.hakumiTagGroup}sortableValueChanged(){this.sortableValue?this.#e():this.#t()}enableSorting(){this.sortableValue=!0}disableSorting(){this.sortableValue=!1}isSortingEnabled(){return this.sortableValue}getTags(){return Array.from(this.element.querySelectorAll(".hakumi-tag"))}getTagValues(){return this.getTags().map(e=>e.textContent.trim())}#e(){this._sortable||(this._sortable=We.create(this.element,{animation:this.animationValue,draggable:".hakumi-tag",ghostClass:"hakumi-tag-ghost",chosenClass:"hakumi-tag-chosen",dragClass:"hakumi-tag-drag",onStart:e=>{this.dispatch("sortStart",{detail:{item:e.item,oldIndex:e.oldIndex}})},onEnd:e=>{this.dispatch("sortEnd",{detail:{item:e.item,oldIndex:e.oldIndex,newIndex:e.newIndex,values:this.getTagValues()}})}}))}#t(){this._sortable&&(this._sortable.destroy(),this._sortable=null)}#i(){this.element.hakumiTagGroup={enableSorting:()=>this.enableSorting(),disableSorting:()=>this.disableSorting(),isSortingEnabled:()=>this.isSortingEnabled(),getTags:()=>this.getTags(),getTagValues:()=>this.getTagValues()}}};var Ri=class extends m{static values={reverse:{type:Boolean,default:!1}};setup(){this.itemsContainer=this.element.querySelector(".hakumi-timeline-items"),this.#e()}registerApi(){this.element.hakumiComponent={name:"timeline",version:1,singleton:!1,api:{getItems:()=>this.getItems(),getReverse:()=>this.reverseValue,setReverse:e=>this.setReverse(e),toggleReverse:()=>this.toggleReverse()}},this.#t()}disconnect(){delete this.element.hakumiTimeline,super.disconnect()}setReverse(e){this.reverseValue=!!e}toggleReverse(){this.setReverse(!this.reverseValue)}getItems(){return this.itemsContainer?Array.from(this.itemsContainer.querySelectorAll(".hakumi-timeline-item")).map(e=>({index:Number(e.dataset.timelineIndex||0),title:e.querySelector(".hakumi-timeline-item-title")?.textContent?.trim()||null,content:e.querySelector(".hakumi-timeline-item-content")?.textContent?.trim()||null,pending:e.classList.contains("hakumi-timeline-item-pending")})):[]}reverseValueChanged(){this.#e()}#e(){if(!this.itemsContainer)return;this.element.classList.toggle("hakumi-timeline-reverse",this.reverseValue);let e=Array.from(this.itemsContainer.querySelectorAll(".hakumi-timeline-item")),t=e.sort((i,s)=>{let a=Number(i.dataset.timelineIndex||0),n=Number(s.dataset.timelineIndex||0);return a-n});this.reverseValue&&t.reverse(),e.forEach(i=>i.classList.remove("hakumi-timeline-item-last")),t.length>0&&t[t.length-1].classList.add("hakumi-timeline-item-last"),t.forEach(i=>this.itemsContainer.appendChild(i))}#t(){this.element.hakumiTimeline={getItems:()=>this.getItems(),getReverse:()=>this.reverseValue,setReverse:e=>this.setReverse(e),toggleReverse:()=>this.toggleReverse()}}};var Ni=class extends m{static targets=["node","children","checkbox","switcher","title","searchInput","list","nodeTemplate","indent"];static values={checkable:{type:Boolean,default:!1},selectable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},defaultExpandKeys:{type:Array,default:[]},defaultSelectedKeys:{type:Array,default:[]},defaultCheckedKeys:{type:Array,default:[]},expandedKeys:Array,selectedKeys:Array,checkedKeys:Array,showLine:{type:Boolean,default:!1},switcherIcon:{type:String,default:""},icon:{type:String,default:""},directory:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},blockNode:{type:Boolean,default:!1},searchable:{type:Boolean,default:!1},height:Number,checkStrictly:{type:Boolean,default:!1}};setup(){this.nodeMap=new Map,this.sortables=new Map,this.searching=!1,this.previousExpandedKeys=null,this.expandedKeys=new Set(this.hasExpandedKeysValue?this.expandedKeysValue:this.defaultExpandKeysValue),this.selectedKeys=new Set(this.hasSelectedKeysValue?this.selectedKeysValue:this.defaultSelectedKeysValue),this.checkedKeys=new Set(this.hasCheckedKeysValue?this.checkedKeysValue:this.defaultCheckedKeysValue),this.halfCheckedKeys=new Set,this.buildNodeMap(),this.applyExpandedStates(),this.applySelectedStates(),this.applyCheckedStates(!0),this.draggableValue&&this.setupSortables()}teardown(){this.destroySortables()}disconnect(){delete this.element.hakumiTree,super.disconnect()}registerApi(){let e={getSelectedKeys:()=>Array.from(this.selectedKeys),setSelectedKeys:t=>this.setSelectedKeys(t),getCheckedKeys:()=>Array.from(this.checkedKeys),setCheckedKeys:t=>this.setCheckedKeys(t),getHalfCheckedKeys:()=>Array.from(this.halfCheckedKeys),getExpandedKeys:()=>Array.from(this.expandedKeys),setExpandedKeys:t=>this.setExpandedKeys(t),expandAll:()=>this.expandAll(),collapseAll:()=>this.collapseAll(),toggleNode:t=>this.toggleNodeByKey(t),selectNode:(t,i={})=>this.selectNodeByKey(t,i),checkNode:(t,i=!0)=>this.checkNodeByKey(t,i),addNodes:(t,i)=>this.addNodes(t,i),setLoading:(t,i)=>this.setLoading(t,i),setError:(t,i=!0)=>this.setError(t,i)};this.element.hakumiComponent={name:"tree",version:1,singleton:!1,api:e},this.element.hakumiTree=e}buildNodeMap(){this.nodeMap.clear(),this.nodeTargets.forEach(e=>{let t=e.dataset.key,i=e.dataset.parentKey||null;this.nodeMap.set(t,{element:e,key:t,parentKey:i,children:[]})}),this.nodeMap.forEach(e=>{e.parentKey&&this.nodeMap.has(e.parentKey)&&this.nodeMap.get(e.parentKey).children.push(e.key)})}applyExpandedStates(){this.nodeMap.forEach(e=>{let t=this.expandedKeys.has(e.key);e.element.classList.toggle("hakumi-tree-node-expanded",t),e.element.dataset.leaf==="true"?e.element.removeAttribute("aria-expanded"):e.element.setAttribute("aria-expanded",t)})}applySelectedStates(){this.nodeMap.forEach(e=>{let t=this.selectedKeys.has(e.key);e.element.classList.toggle("hakumi-tree-node-selected",t),e.element.setAttribute("aria-selected",t)})}applyCheckedStates(e=!1){if(this.checkableValue){if(!this.checkStrictlyValue&&e){let t=new Set(this.checkedKeys);this.checkedKeys.forEach(i=>{this.getDescendants(i).forEach(s=>t.add(s))}),this.checkedKeys=t,this.updateAncestorsFromChecked()}this.nodeMap.forEach(t=>{let i=this.checkedKeys.has(t.key),s=this.halfCheckedKeys.has(t.key);t.element.classList.toggle("hakumi-tree-node-checked",i),t.element.classList.toggle("hakumi-tree-node-half-checked",s);let a=t.element.querySelector(".hakumi-tree-checkbox");a&&(a.setAttribute("aria-checked",s?"mixed":String(i)),a.classList.toggle("hakumi-tree-checkbox-checked",i),a.classList.toggle("hakumi-tree-checkbox-indeterminate",s))})}}toggle(e){e.preventDefault(),e.stopPropagation();let t=this.closestNode(e);!t||t.dataset.leaf==="true"||this.toggleNodeByKey(t.dataset.key)}select(e){e.preventDefault(),e.stopPropagation();let t=this.closestNode(e);if(!t)return;let i=t.dataset.key,s=t.dataset.selectable!=="false",a=t.dataset.disabled==="true"||this.disabledValue;if(!this.selectableValue||!s||a)return;let n={multiple:this.multipleValue||this.directoryValue&&(e.metaKey||e.ctrlKey)};this.selectNodeByKey(i,n)}toggleCheck(e){e.preventDefault(),e.stopPropagation();let t=this.closestNode(e);if(!t)return;let i=t.dataset.key,s=t.dataset.disabled==="true"||this.disabledValue,a=e.currentTarget.dataset.disabled==="true";if(s||a)return;let n=!this.checkedKeys.has(i);this.checkNodeByKey(i,n)}toggleNodeByKey(e){this.expandedKeys.has(e)?this.expandedKeys.delete(e):(this.expandedKeys.add(e),this.maybeLoadAsync(e)),this.applyExpandedStates(),this.dispatch("expand",{detail:{expandedKeys:Array.from(this.expandedKeys),key:e}})}selectNodeByKey(e,t={}){t.multiple||this.selectedKeys.clear(),this.selectedKeys.has(e)&&t.multiple?this.selectedKeys.delete(e):this.selectedKeys.add(e),this.applySelectedStates(),this.dispatch("select",{detail:{selectedKeys:Array.from(this.selectedKeys),key:e}})}checkNodeByKey(e,t=!0){this.checkStrictlyValue?(t?this.checkedKeys.add(e):this.checkedKeys.delete(e),this.halfCheckedKeys.delete(e)):this.toggleCheckedCascade(e,t),this.applyCheckedStates(),this.dispatch("check",{detail:{checkedKeys:Array.from(this.checkedKeys),halfCheckedKeys:Array.from(this.halfCheckedKeys),key:e,checked:t}})}toggleCheckedCascade(e,t){let i=this.getDescendants(e);t?(this.checkedKeys.add(e),i.forEach(s=>this.checkedKeys.add(s))):(this.checkedKeys.delete(e),i.forEach(s=>this.checkedKeys.delete(s))),this.halfCheckedKeys.clear(),this.updateAncestorsFromChecked()}updateAncestorsFromChecked(){Array.from(this.nodeMap.values()).sort((t,i)=>{let s=parseInt(t.element.dataset.level||"0",10);return parseInt(i.element.dataset.level||"0",10)-s}).forEach(t=>{if(!t.children.length)return;let i=t.children.every(a=>this.checkedKeys.has(a)),s=t.children.some(a=>this.checkedKeys.has(a)||this.halfCheckedKeys.has(a));i?(this.checkedKeys.add(t.key),this.halfCheckedKeys.delete(t.key)):s?(this.checkedKeys.delete(t.key),this.halfCheckedKeys.add(t.key)):(this.checkedKeys.delete(t.key),this.halfCheckedKeys.delete(t.key))})}setSelectedKeys(e){this.selectedKeys=new Set(e||[]),this.applySelectedStates()}setCheckedKeys(e){this.checkedKeys=new Set(e||[]),this.halfCheckedKeys.clear(),this.applyCheckedStates(!0)}setExpandedKeys(e){this.expandedKeys=new Set(e||[]),this.applyExpandedStates()}expandAll(){this.nodeMap.forEach(e=>{e.element.dataset.leaf!=="true"&&this.expandedKeys.add(e.key)}),this.applyExpandedStates()}collapseAll(){this.expandedKeys.clear(),this.applyExpandedStates()}getDescendants(e){if(!this.nodeMap.get(e))return[];let i=[],s=a=>{let n=this.nodeMap.get(a);n&&n.children.forEach(r=>{i.push(r),s(r)})};return s(e),i}maybeLoadAsync(e){let t=this.nodeMap.get(e);if(!t)return;let i=t.element.dataset.async==="true",s=t.element.querySelector(".hakumi-tree-children");!i||s||(this.setLoading(e,!0),this.dispatch("load",{detail:{key:e,node:t.element}}))}setLoading(e,t){let i=this.nodeMap.get(e);if(!i)return;i.element.dataset.loading=t?"true":"false",i.element.classList.toggle("hakumi-tree-node-loading",t),t&&this.setError(e,!1);let s=i.element.querySelector(".hakumi-tree-switcher");if(s)if(t){let a=s.querySelector(".hakumi-tree-switcher-icon");if(a&&(a.style.display="none"),!s.querySelector(".hakumi-tree-loading-icon")){let n=document.createElement("span");n.className="hakumi-tree-loading-icon",n.innerHTML=`<svg viewBox="0 0 1024 1024" width="1em" height="1em" fill="currentColor">
|
|
49
|
+
<path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"/>
|
|
50
|
+
</svg>`,s.appendChild(n)}}else{let a=s.querySelector(".hakumi-tree-switcher-icon");a&&(a.style.display="");let n=s.querySelector(".hakumi-tree-loading-icon");n&&n.remove()}}setError(e,t=!0){let i=this.nodeMap.get(e);i&&(i.element.dataset.error=t?"true":"false",i.element.classList.toggle("hakumi-tree-node-error",t),t&&this.setLoading(e,!1))}markAsLeaf(e){let t=this.nodeMap.get(e);if(!t)return;t.element.dataset.leaf="true",t.element.dataset.async="false",t.element.classList.add("hakumi-tree-node-leaf"),t.element.removeAttribute("aria-expanded");let i=t.element.querySelector(".hakumi-tree-switcher");i&&(i.classList.add("hakumi-tree-switcher-leaf"),i.removeAttribute("data-action"),i.innerHTML='<span class="hakumi-tree-switcher-noop"></span>')}addNodes(e,t){if(!t||t.length===0){this.markAsLeaf(e),this.setLoading(e,!1);return}let i=this.nodeMap.get(e);if(!i)return;if(i.element.dataset.leaf==="true"){i.element.dataset.leaf="false",i.element.classList.remove("hakumi-tree-node-leaf");let n=i.element.querySelector(".hakumi-tree-switcher");if(n&&(n.classList.remove("hakumi-tree-switcher-leaf"),n.dataset.action="click->hakumi--tree#toggle",n&&!n.querySelector(".hakumi-tree-switcher-icon"))){let l=this.nodeTemplateTarget.content.cloneNode(!0).querySelector(".hakumi-tree-switcher").querySelector(".hakumi-tree-switcher-icon");l&&n.appendChild(l.cloneNode(!0))}}let s=i.element.querySelector(".hakumi-tree-children");s||(s=document.createElement("div"),s.className="hakumi-tree-children",s.setAttribute("role","group"),s.dataset.hakumiTreeTarget="children",i.element.appendChild(s));let a=parseInt(i.element.dataset.level||"0",10);t.forEach((n,r)=>{let o=r<t.length-1,l=this.createNodeElement(n,a+1,e,o);s.appendChild(l)}),this.buildNodeMap(),this.applyExpandedStates(),this.applySelectedStates(),this.applyCheckedStates(!0),this.draggableValue&&this.setupSortables()}createNodeElement(e,t,i,s=!1){let a=String(e.key),n=e.title||e.key,r=Array.isArray(e.children)&&e.children.length>0,o=e.is_leaf===!0||!r&&!e.async,h=this.nodeTemplateTarget.content.cloneNode(!0).querySelector(".hakumi-tree-node");h.dataset.key=a,h.dataset.parentKey=i,h.dataset.level=String(t),h.dataset.title=n,h.dataset.selectable=e.selectable===!1?"false":"true",h.dataset.checkable=e.checkable===!1?"false":"true",h.dataset.disabled=e.disabled?"true":"false",h.dataset.leaf=o?"true":"false",h.dataset.async=e.async?"true":"false",h.dataset.hasNext=s?"true":"false",h.setAttribute("aria-selected","false");let u=h.querySelector(".hakumi-tree-indent");if(u)if(i&&this.nodeMap.has(i)){let p=this.nodeMap.get(i),f=p.element.querySelector(".hakumi-tree-indent");f&&Array.from(f.children).forEach(V=>{u.appendChild(V.cloneNode(!0))});let C=document.createElement("span");C.className="hakumi-tree-indent-unit",p.element.dataset.hasNext==="true"&&C.classList.add("hakumi-tree-indent-unit-active"),u.appendChild(C)}else for(let p=0;p<t;p++){let f=document.createElement("span");f.className="hakumi-tree-indent-unit",u.appendChild(f)}let c=h.querySelector(".hakumi-tree-switcher");c&&(c.dataset.key=a,o?(c.classList.add("hakumi-tree-switcher-leaf"),c.removeAttribute("data-action"),c.innerHTML='<span class="hakumi-tree-switcher-noop"></span>'):c.dataset.action="click->hakumi--tree#toggle");let d=h.querySelector(".hakumi-tree-checkbox");d&&(this.checkableValue&&e.checkable!==!1?(d.dataset.action="click->hakumi--tree#toggleCheck",d.dataset.key=a):d.remove());let g=h.querySelector(".hakumi-tree-title");if(g){g.dataset.action="click->hakumi--tree#select",g.dataset.key=a;let p=g.querySelector(".hakumi-tree-title-text");p&&(p.dataset.title=n,p.textContent=n)}if(r){let p=h.querySelector(".hakumi-tree-children");p&&e.children.forEach((f,C)=>{let V=C<e.children.length-1;p.appendChild(this.createNodeElement(f,t+1,a,V))})}return h}setupSortables(){this.destroySortables();let e=new Set;this.hasListTarget&&e.add(this.listTarget),this.childrenTargets.forEach(t=>e.add(t)),e.forEach(t=>{let i=We.create(t,{animation:150,group:"hakumi-tree",draggable:".hakumi-tree-node",handle:".hakumi-tree-node-content",ghostClass:"hakumi-tree-node-ghost",chosenClass:"hakumi-tree-node-chosen",dragClass:"hakumi-tree-node-drag",onEnd:s=>{let a=s.item,n=a.closest(".hakumi-tree-node"),r=n?n.dataset.key:null;a.dataset.parentKey=r||"",this.buildNodeMap(),this.dispatch("dragEnd",{detail:{key:a.dataset.key,parentKey:r,oldIndex:s.oldIndex,newIndex:s.newIndex}})}});this.sortables.set(t,i)})}destroySortables(){this.sortables.forEach(e=>e.destroy()),this.sortables.clear()}search(e){let t=e.target.value||"";this.applySearch(t)}applySearch(e){let t=e.trim().toLowerCase();if(!t){this.searching&&this.previousExpandedKeys&&(this.expandedKeys=new Set(this.previousExpandedKeys)),this.searching=!1,this.previousExpandedKeys=null,this.nodeMap.forEach(s=>{s.element.classList.remove("hakumi-tree-node-hidden");let a=s.element.querySelector(".hakumi-tree-title-text");a&&(a.textContent=a.dataset.title||"")}),this.applyExpandedStates();return}this.searching||(this.previousExpandedKeys=new Set(this.expandedKeys),this.searching=!0);let i=new Set;this.nodeMap.forEach(s=>{if((s.element.dataset.title||"").toLowerCase().includes(t)){i.add(s.key);let n=s.parentKey;for(;n;){i.add(n);let r=this.nodeMap.get(n);n=r?r.parentKey:null}}}),this.nodeMap.forEach(s=>{let a=i.has(s.key);s.element.classList.toggle("hakumi-tree-node-hidden",!a);let n=s.element.querySelector(".hakumi-tree-title-text");if(!n)return;let r=n.dataset.title||"",l=r.toLowerCase().indexOf(t);if(l>=0){let h=r.slice(0,l),u=r.slice(l,l+t.length),c=r.slice(l+t.length);n.innerHTML=`${h}<span class="hakumi-tree-title-highlight">${u}</span>${c}`}else n.textContent=r}),i.forEach(s=>{let a=this.nodeMap.get(s);a&&a.element.dataset.leaf!=="true"&&this.expandedKeys.add(a.key)}),this.applyExpandedStates()}closestNode(e){return e.currentTarget.closest(".hakumi-tree-node")}};var Fi=class extends m{static values={loading:Boolean};setup(){this.boundRipple=this.createRipple.bind(this),this.element.addEventListener("click",this.boundRipple)}teardown(){this.element.removeEventListener("click",this.boundRipple)}handleClick(e){(this.loadingValue||this.element.disabled)&&(e.preventDefault(),e.stopImmediatePropagation())}createRipple(e){let t=e.currentTarget,i=document.createElement("span"),s=Math.max(t.clientWidth,t.clientHeight),a=s/2,n=t.getBoundingClientRect();i.style.width=i.style.height=`${s}px`,i.style.left=`${e.clientX-n.left-a}px`,i.style.top=`${e.clientY-n.top-a}px`,i.classList.add("hakumi-button-ripple");let r=t.getElementsByClassName("hakumi-button-ripple")[0];r&&r.remove(),t.appendChild(i),setTimeout(()=>{i.remove()},600)}registerApi(){let e={setLoading:t=>{this.loadingValue=!!t},isLoading:()=>this.loadingValue,ripple:t=>this.createRipple(t)};this.element.hakumiComponent={name:"button",version:1,singleton:!1,api:e}}};var $i=class extends m{static targets=["trigger","menu"];static values={trigger:{type:String,default:"hover"},placement:{type:String,default:"bottom-left"},disabled:{type:Boolean,default:!1}};setup(){this.boundCloseOnClickOutside=this.closeOnClickOutside.bind(this),document.addEventListener("click",this.boundCloseOnClickOutside),this.triggerValue==="context_menu"&&(this.boundContextMenu=this.handleContextMenu.bind(this),this.triggerTarget.addEventListener("contextmenu",this.boundContextMenu))}teardown(){document.removeEventListener("click",this.boundCloseOnClickOutside),this.boundContextMenu&&(this.triggerTarget.removeEventListener("contextmenu",this.boundContextMenu),this.boundContextMenu=null),this.boundCloseOnClickOutside=null}registerApi(){let e={open:()=>this.open(),close:()=>this.close(),toggle:t=>this.toggle(t||new Event("click")),isOpen:()=>this.isOpen(),getState:()=>({open:this.isOpen(),disabled:this.disabledValue,trigger:this.triggerValue,placement:this.placementValue})};this.element.hakumiComponent={name:"dropdown",version:1,singleton:!1,api:e}}isOpen(){return this.menuTarget.classList.contains("hakumi-dropdown-open")}show(e){this.disabledValue||this.menuTarget.classList.add("hakumi-dropdown-open")}hide(e){this.disabledValue||setTimeout(()=>{this.element.matches(":hover")||this.menuTarget.classList.remove("hakumi-dropdown-open")},100)}toggle(e){this.disabledValue||(e&&e.stopPropagation(),this.menuTarget.classList.toggle("hakumi-dropdown-open"))}handleContextMenu(e){this.disabledValue||(e.preventDefault(),this.menuTarget.classList.add("hakumi-dropdown-open"))}closeOnClickOutside(e){this.element.contains(e.target)||this.menuTarget.classList.remove("hakumi-dropdown-open")}open(){this.disabledValue||this.menuTarget.classList.add("hakumi-dropdown-open")}close(){this.menuTarget.classList.remove("hakumi-dropdown-open")}};var Ki=class extends m{static targets=["actions"];static values={defaultOpen:Boolean};setup(){this.open=this.defaultOpenValue,this.updateState()}registerApi(){this.element.hakumiComponent={name:"float_button_group",version:1,singleton:!1,api:{open:()=>this.openGroup(),close:()=>this.closeGroup(),toggle:e=>this.toggle(e||new Event("click")),isOpen:()=>this.open}}}toggle(e){e&&e.preventDefault(),this.open=!this.open,this.updateState()}updateState(){this.hasActionsTarget&&(this.actionsTarget.classList.toggle("open",this.open),this.element.classList.toggle("open",this.open))}openGroup(){this.open||(this.open=!0,this.updateState())}closeGroup(){this.open&&(this.open=!1,this.updateState())}};var zi=class extends m{static targets=["item","submenu"];static values={mode:{type:String,default:"vertical"},selectable:{type:Boolean,default:!0},multiple:{type:Boolean,default:!1},inlineCollapsed:{type:Boolean,default:!1},inlineIndent:{type:Number,default:24},defaultSelectedKeys:{type:Array,default:[]},defaultOpenKeys:{type:Array,default:[]},triggerSubmenuAction:{type:String,default:"hover"}};setup(){this.submenuHoverHandlers=new Map,this.itemClickHandlers=new Map,this.selectedKeys=new Set(this.defaultSelectedKeysValue),this.openKeys=new Set(this.defaultOpenKeysValue),this.originalWidth=this.element.style.width||"",this.applySelectedStates(),this.applyOpenStates(),this.inlineCollapsedValue&&this.applyCollapsedState(),this.modeValue!=="inline"&&this.setupHoverHandlers()}teardown(){this.removeHoverHandlers(),this.removeCollapsedHoverHandlers(),this.itemClickHandlers&&(this.itemClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.itemClickHandlers.clear())}registerApi(){this.element.hakumiComponent={name:"menu",version:1,singleton:!1,api:{toggleCollapsed:()=>this.toggleCollapsed(),collapse:()=>this.collapse(),expand:()=>this.expand(),isCollapsed:()=>this.inlineCollapsedValue,getSelectedKeys:()=>Array.from(this.selectedKeys),setSelectedKeys:e=>this.setSelectedKeys(e),selectItem:e=>this.selectItemByKey(e),deselectItem:e=>this.deselectItemByKey(e),getOpenKeys:()=>Array.from(this.openKeys),setOpenKeys:e=>this.setOpenKeys(e),openSubmenu:e=>this.openSubmenuByKey(e),closeSubmenu:e=>this.closeSubmenuByKey(e),toggleSubmenuByKey:e=>this.toggleSubmenuByKey(e),closeAllSubmenus:()=>this.closeAllSubmenus(),getMode:()=>this.modeValue}}}collapse(){this.inlineCollapsedValue||(this.inlineCollapsedValue=!0,this.applyCollapsedState(),this.#e())}expand(){this.inlineCollapsedValue&&(this.inlineCollapsedValue=!1,this.applyCollapsedState(),this.#e())}#e(){this.dispatch("collapse",{detail:{collapsed:this.inlineCollapsedValue}})}setSelectedKeys(e){this.selectedKeys=new Set(e),this.applySelectedStates(),this.#t()}selectItemByKey(e){this.multipleValue?this.selectedKeys.add(e):(this.selectedKeys.clear(),this.selectedKeys.add(e)),this.applySelectedStates(),this.#t()}deselectItemByKey(e){this.selectedKeys.delete(e),this.applySelectedStates(),this.#t()}#t(){this.dispatch("select",{detail:{selectedKeys:Array.from(this.selectedKeys)}})}setOpenKeys(e){this.submenuTargets.forEach(t=>{t.classList.remove("hakumi-menu-submenu-open")}),this.openKeys=new Set(e),this.applyOpenStates()}openSubmenuByKey(e){let t=this.#i(e);t&&this.openSubmenu(t)}closeSubmenuByKey(e){let t=this.#i(e);t&&this.closeSubmenu(t)}toggleSubmenuByKey(e){let t=this.#i(e);t&&(t.classList.contains("hakumi-menu-submenu-open")?this.closeSubmenu(t):this.openSubmenu(t))}#i(e){return this.submenuTargets.find(t=>t.dataset.menuKey===e)}toggleCollapsed(){this.inlineCollapsedValue=!this.inlineCollapsedValue,this.applyCollapsedState(),this.dispatch("collapse",{detail:{collapsed:this.inlineCollapsedValue}})}applyCollapsedState(){this.inlineCollapsedValue?(this.element.classList.add("hakumi-menu-inline-collapsed"),this.element.style.width="80px",this.closeAllSubmenus(),this.setupCollapsedHoverHandlers()):(this.element.classList.remove("hakumi-menu-inline-collapsed"),this.element.style.width=this.originalWidth,this.removeCollapsedHoverHandlers())}setupHoverHandlers(){this.submenuTargets.forEach(e=>{if(this.triggerSubmenuActionValue==="hover"){let t=()=>this.openSubmenu(e),i=()=>this.closeSubmenu(e);this.submenuHoverHandlers.set(e,{enterHandler:t,leaveHandler:i}),e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",i)}})}removeHoverHandlers(){this.submenuHoverHandlers&&(this.submenuHoverHandlers.forEach((e,t)=>{t.removeEventListener("mouseenter",e.enterHandler),t.removeEventListener("mouseleave",e.leaveHandler)}),this.submenuHoverHandlers.clear())}setupCollapsedHoverHandlers(){this.submenuTargets.forEach(e=>{let t=()=>this.openSubmenu(e),i=()=>this.closeSubmenu(e);e._collapsedEnterHandler=t,e._collapsedLeaveHandler=i,e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",i)}),this.#s()}removeCollapsedHoverHandlers(){this.submenuTargets.forEach(e=>{e._collapsedEnterHandler&&(e.removeEventListener("mouseenter",e._collapsedEnterHandler),e.removeEventListener("mouseleave",e._collapsedLeaveHandler),delete e._collapsedEnterHandler,delete e._collapsedLeaveHandler)}),this.#a()}#s(){this.#n().forEach(t=>{let i=t.querySelector(".hakumi-menu-title-content")?.textContent?.trim();if(!i)return;let s=()=>this.#o(t,i),a=()=>this.#r(t);t._tooltipEnterHandler=s,t._tooltipLeaveHandler=a,t.addEventListener("mouseenter",s),t.addEventListener("mouseleave",a)})}#a(){this.#n().forEach(t=>{t._tooltipEnterHandler&&(t.removeEventListener("mouseenter",t._tooltipEnterHandler),t.removeEventListener("mouseleave",t._tooltipLeaveHandler),delete t._tooltipEnterHandler,delete t._tooltipLeaveHandler),this.#r(t)})}#n(){let e=this.element,t=[];return this.itemTargets.forEach(i=>{i.parentElement===e&&t.push(i)}),t}#o(e,t){if(e._tooltip)return;let i=document.createElement("div");i.className="hakumi-tooltip-wrapper hakumi-tooltip-open",me(i,"hakumi-tooltip"),i.setAttribute("data-controller","hakumi--tooltip"),i.setAttribute("data-hakumi--tooltip-placement-value","right"),i.setAttribute("data-hakumi--tooltip-trigger-value","hover"),i.style.position="fixed",i.style.zIndex="1070",i.innerHTML=`
|
|
51
|
+
<div class="hakumi-tooltip hakumi-tooltip-placement-right hakumi-tooltip-visible" data-hakumi--tooltip-target="tooltip">
|
|
52
|
+
<div class="hakumi-tooltip-arrow"></div>
|
|
53
|
+
<div class="hakumi-tooltip-content">
|
|
54
|
+
<div class="hakumi-tooltip-inner">${t}</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
`,document.body.appendChild(i),e._tooltip=i;let s=e.getBoundingClientRect();i.style.left=`${s.right+4}px`,i.style.top=`${s.top+s.height/2}px`,i.style.transform="translateY(-50%)"}#r(e){e._tooltip&&(e._tooltip.remove(),delete e._tooltip)}closeAllSubmenus(){this.submenuTargets.forEach(e=>{e.classList.remove("hakumi-menu-submenu-open");let t=e.dataset.menuKey;t&&this.openKeys.delete(t)})}toggleSubmenu(e){let t=e.target.closest(".hakumi-menu-submenu");t&&(t.classList.contains("hakumi-menu-submenu-disabled")||this.inlineCollapsedValue||(this.modeValue==="inline"||this.triggerSubmenuActionValue==="click")&&(e.preventDefault(),e.stopPropagation(),t.classList.contains("hakumi-menu-submenu-open")?this.closeSubmenu(t):this.openSubmenu(t)))}openSubmenu(e){let t=e.dataset.menuKey;t&&this.openKeys.add(t),e.classList.add("hakumi-menu-submenu-open")}closeSubmenu(e){let t=e.dataset.menuKey;t&&this.openKeys.delete(t),e.classList.remove("hakumi-menu-submenu-open")}selectItem(e){if(!this.selectableValue)return;let t=e.target.closest(".hakumi-menu-item");if(!t||t.classList.contains("hakumi-menu-item-disabled")||t.querySelector("a[target='_blank']"))return;let s=t.dataset.menuKey;s&&(this.multipleValue?this.selectedKeys.has(s)?this.selectedKeys.delete(s):this.selectedKeys.add(s):(this.selectedKeys.clear(),this.selectedKeys.add(s)),this.applySelectedStates(),this.dispatch("select",{detail:{key:s,selectedKeys:Array.from(this.selectedKeys)}}))}applySelectedStates(){this.itemTargets.forEach(e=>{e.classList.remove("hakumi-menu-item-selected")}),this.submenuTargets.forEach(e=>{e.classList.remove("hakumi-menu-submenu-selected")}),this.itemTargets.forEach(e=>{let t=e.dataset.menuKey;this.selectedKeys&&this.selectedKeys.has(t)&&(e.classList.add("hakumi-menu-item-selected"),this.#u(e))})}#u(e){let t=e.parentElement;for(;t&&!t.classList.contains("hakumi-menu-root");)t.classList.contains("hakumi-menu-submenu")&&t.classList.add("hakumi-menu-submenu-selected"),t=t.parentElement}applyOpenStates(){this.submenuTargets.forEach(e=>{let t=e.dataset.menuKey;this.openKeys&&this.openKeys.has(t)&&e.classList.add("hakumi-menu-submenu-open")})}itemTargetConnected(e){let t=i=>this.selectItem(i);this.itemClickHandlers?.set(e,t),e.addEventListener("click",t)}itemTargetDisconnected(e){let t=this.itemClickHandlers?.get(e);t&&(e.removeEventListener("click",t),this.itemClickHandlers.delete(e))}};var qi=class extends m{static targets=["prev","next","page","jumpPrev","jumpNext","sizeChanger","quickJumper","simpleInput"];static values={current:{type:Number,default:1},pageSize:{type:Number,default:10},total:{type:Number,default:0},disabled:{type:Boolean,default:!1},simple:{type:Boolean,default:!1},href:{type:String,default:""},pageParam:{type:String,default:"page"},perPageParam:{type:String,default:"per_page"},turboFrame:{type:String,default:""},turboAction:{type:String,default:""},preserveParams:{type:String,default:""}};setup(){this.#e()}teardown(){this.#t()}registerApi(){this.element.hakumiComponent={name:"pagination",version:1,singleton:!1,api:{getCurrent:()=>this.currentValue,setCurrent:e=>this.goTo(e),goTo:e=>this.goTo(e),getPageSize:()=>this.pageSizeValue,setPageSize:e=>this.changeSize(e),getTotal:()=>this.totalValue,setTotal:e=>this.setTotal(e),getTotalPages:()=>this.totalPages,next:()=>this.next(),prev:()=>this.prev(),jumpNext:()=>this.jumpNext(),jumpPrev:()=>this.jumpPrev(),refresh:()=>this.refresh()}}}setTotal(e){this.totalValue=e,this.#s(!0)}refresh(){this.#s(!0)}get totalPages(){return Math.ceil(this.totalValue/this.pageSizeValue)}#e(){this.hasSizeChangerTarget&&(this.boundOnSizeChange=this.#i.bind(this),this.sizeChangerTarget.addEventListener("hakumi--select:change",this.boundOnSizeChange))}#t(){!this.hasSizeChangerTarget||!this.boundOnSizeChange||this.sizeChangerTarget.removeEventListener("hakumi--select:change",this.boundOnSizeChange)}#i(e){if(!this.sizeChangerTarget.contains(e.target))return;let{value:t}=e.detail,i=parseInt(t,10);i&&i!==this.pageSizeValue&&this.changeSize(i)}prev(){this.disabledValue||this.currentValue<=1||this.goTo(this.currentValue-1)}next(){this.disabledValue||this.currentValue>=this.totalPages||this.goTo(this.currentValue+1)}jumpPrev(){this.disabledValue||this.goTo(Math.max(1,this.currentValue-5))}jumpNext(){this.disabledValue||this.goTo(Math.min(this.totalPages,this.currentValue+5))}goToPage(e){if(this.disabledValue)return;let t=parseInt(e.currentTarget.dataset.page,10);t&&t!==this.currentValue&&this.goTo(t)}jumpToPage(e){if(this.disabledValue)return;let t=e.currentTarget,i=parseInt(t.value,10);i&&i>=1&&i<=this.totalPages&&i!==this.currentValue&&this.goTo(i),this.simpleValue||(t.value="")}goTo(e){let t=Math.max(1,Math.min(e,this.totalPages));t!==this.currentValue&&(this.currentValue=t,this.#s(),this.#r(),this.#h())}changeSize(e){let t=this.totalPages;this.pageSizeValue=e;let i=this.totalPages;this.currentValue>i&&(this.currentValue=i||1),this.#s(t!==i),this.#u(),this.#h()}#s(e=!1){if(e||this.totalPages>7?this.#a():this.pageTargets.forEach(t=>{let i=parseInt(t.dataset.page,10);t.classList.toggle("hakumi-pagination-item-active",i===this.currentValue)}),this.hasPrevTarget){let t=this.currentValue<=1;this.prevTarget.classList.toggle("hakumi-pagination-disabled",t);let i=this.prevTarget.querySelector("button");i&&(i.disabled=t)}if(this.hasNextTarget){let t=this.currentValue>=this.totalPages;this.nextTarget.classList.toggle("hakumi-pagination-disabled",t);let i=this.nextTarget.querySelector("button");i&&(i.disabled=t)}if(this.hasSimpleInputTarget&&(this.simpleInputTarget.value=this.currentValue),this.hasSizeChangerTarget){let t=this.element.querySelector(".hakumi-pagination-simple-total");t&&(t.textContent=this.totalPages)}}#a(){let e=this.hasPrevTarget?this.prevTarget:null,t=this.hasNextTarget?this.nextTarget:null;if(!e||!t)return;let i=[],s=e.nextElementSibling;for(;s&&s!==t;)(s.classList.contains("hakumi-pagination-item")||s.classList.contains("hakumi-pagination-jump-prev")||s.classList.contains("hakumi-pagination-jump-next"))&&i.push(s),s=s.nextElementSibling;i.forEach(r=>r.remove());let a=this.#o(),n=document.createDocumentFragment();a.forEach(r=>{if(r.type==="page"){let o=document.createElement("li");o.className=`hakumi-pagination-item hakumi-pagination-item-${r.number}${r.number===this.currentValue?" hakumi-pagination-item-active":""}`,o.dataset.page=r.number,o.dataset.action="click->hakumi--pagination#goToPage",o.dataset.antPaginationTarget="page",o.innerHTML=`<a rel="nofollow">${r.number}</a>`,n.appendChild(o)}else r.type==="jump_prev"?n.appendChild(this.#n("prev")):r.type==="jump_next"&&n.appendChild(this.#n("next"))}),t.parentNode.insertBefore(n,t)}#n(e){let t=document.createElement("li");return t.className=`hakumi-pagination-jump-${e} hakumi-pagination-jump-${e}-custom-icon`,t.dataset.action=`click->hakumi--pagination#jump${e==="prev"?"Prev":"Next"}`,t.dataset.antPaginationTarget=`jump${e==="prev"?"Prev":"Next"}`,t.innerHTML=`
|
|
58
|
+
<a rel="nofollow" class="hakumi-pagination-item-link">
|
|
59
|
+
<span class="hakumi-pagination-item-container">
|
|
60
|
+
<span class="hakumi-pagination-item-link-icon">
|
|
61
|
+
<span class="hakumi-icon hakumi-icon-double-${e==="prev"?"left":"right"}">
|
|
62
|
+
<svg viewBox="64 64 896 896" focusable="false" fill="currentColor" width="1em" height="1em">
|
|
63
|
+
${e==="prev"?'<path d="M272.9 512l265.4-339.1c4.1-5.2.4-12.9-6.3-12.9h-77.3c-4.9 0-9.6 2.3-12.6 6.1L186.8 492.3a31.99 31.99 0 000 39.5l255.3 326.1c3 3.9 7.7 6.1 12.6 6.1H532c6.7 0 10.4-7.7 6.3-12.9L272.9 512zm304 0l265.4-339.1c4.1-5.2.4-12.9-6.3-12.9h-77.3c-4.9 0-9.6 2.3-12.6 6.1L490.8 492.3a31.99 31.99 0 000 39.5l255.3 326.1c3 3.9 7.7 6.1 12.6 6.1H836c6.7 0 10.4-7.7 6.3-12.9L576.9 512z"></path>':'<path d="M533.2 492.3L277.9 166.1c-3-3.9-7.7-6.1-12.6-6.1H188c-6.7 0-10.4 7.7-6.3 12.9L447.1 512 181.7 851.1A7.98 7.98 0 00188 864h77.3c4.9 0 9.6-2.3 12.6-6.1l255.3-326.1c9.1-11.7 9.1-27.9 0-39.5zm304 0L581.9 166.1c-3-3.9-7.7-6.1-12.6-6.1H492c-6.7 0-10.4 7.7-6.3 12.9L751.1 512 485.7 851.1A7.98 7.98 0 00492 864h77.3c4.9 0 9.6-2.3 12.6-6.1l255.3-326.1c9.1-11.7 9.1-27.9 0-39.5z"></path>'}
|
|
64
|
+
</svg>
|
|
65
|
+
</span>
|
|
66
|
+
</span>
|
|
67
|
+
<span class="hakumi-pagination-item-ellipsis">
|
|
68
|
+
<span class="hakumi-icon hakumi-icon-ellipsis">
|
|
69
|
+
<svg viewBox="64 64 896 896" focusable="false" fill="currentColor" width="1em" height="1em">
|
|
70
|
+
<path d="M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"></path>
|
|
71
|
+
</svg>
|
|
72
|
+
</span>
|
|
73
|
+
</span>
|
|
74
|
+
</span>
|
|
75
|
+
</a>
|
|
76
|
+
`,t}#o(){let e=[],t=this.totalPages,i=this.currentValue;if(e.push({type:"page",number:1}),t<=7)for(let s=2;s<=t;s++)e.push({type:"page",number:s});else if(i<=4){for(let s=2;s<=5;s++)e.push({type:"page",number:s});e.push({type:"jump_next"}),e.push({type:"page",number:t})}else if(i>=t-3){e.push({type:"jump_prev"});for(let s=t-4;s<=t;s++)e.push({type:"page",number:s})}else{e.push({type:"jump_prev"});for(let s=i-1;s<=i+1;s++)e.push({type:"page",number:s});e.push({type:"jump_next"}),e.push({type:"page",number:t})}return e}#r(){this.dispatch("change",{detail:{current:this.currentValue,pageSize:this.pageSizeValue,total:this.totalValue}})}#u(){this.dispatch("sizeChange",{detail:{current:this.currentValue,pageSize:this.pageSizeValue,total:this.totalValue}})}#h(){if(!this.hrefValue)return;let e=this.#l();if(this.turboFrameValue){let t=document.getElementById(this.turboFrameValue);if(t){t.src=e;return}}if(this.turboActionValue&&window.Turbo){window.Turbo.visit(e,{action:this.turboActionValue});return}window.Turbo?window.Turbo.visit(e):window.location.href=e}#l(){let e=new URL(this.hrefValue,window.location.origin);if(this.hasPreserveParamsValue&&this.preserveParamsValue){let t=this.preserveParamsValue.split(",").map(s=>s.trim()),i=this.#c();i&&t.forEach(s=>{let a=this.#d(s),n=i.dataset[a];n&&e.searchParams.set(s,n)})}return e.searchParams.set(this.pageParamValue,this.currentValue),e.searchParams.set(this.perPageParamValue,this.pageSizeValue),e.toString()}#c(){let e=this.element.closest("[data-pagination-state]");if(e)return e;let t=null;return this.hasTurboFrameValue&&this.turboFrameValue&&(t=document.getElementById(this.turboFrameValue)),t||(t=this.element.closest("turbo-frame")),t?.querySelector("[data-pagination-state]")}#d(e){return e.replace(/_([a-z])/g,(t,i)=>i.toUpperCase())}};var Ui=class extends m{static values={current:{type:Number,default:0},clickable:{type:Boolean,default:!1}};registerApi(){this.element.hakumiComponent={name:"steps",version:1,singleton:!1,api:{getCurrent:()=>this.currentValue,setCurrent:e=>{let t=this.currentValue;this.currentValue=e,this.#e(t),this.#a(e,t)},goTo:e=>{this.element.hakumiComponent.api.setCurrent(e)},next:()=>{let e=this.element.querySelectorAll(".hakumi-steps-item");this.currentValue<e.length-1&&this.element.hakumiComponent.api.setCurrent(this.currentValue+1)},prev:()=>{this.currentValue>0&&this.element.hakumiComponent.api.setCurrent(this.currentValue-1)},isClickable:()=>this.clickableValue}}}selectStep(e){if(!this.clickableValue)return;let t=parseInt(e.currentTarget.dataset.stepIndex,10);if(isNaN(t)||e.currentTarget.classList.contains("hakumi-steps-item-disabled"))return;let s=this.currentValue;this.currentValue=t,this.#e(s),this.#a(t,s)}#e(e){this.element.querySelectorAll(".hakumi-steps-item").forEach((i,s)=>{if(i.classList.remove("hakumi-steps-item-wait","hakumi-steps-item-process","hakumi-steps-item-finish"),i.dataset.status==="error"){i.classList.add("hakumi-steps-item-error");return}s<this.currentValue?(i.classList.add("hakumi-steps-item-finish"),this.#t(i,"finish",s)):s===this.currentValue?(i.classList.add("hakumi-steps-item-process"),this.#t(i,"process",s)):(i.classList.add("hakumi-steps-item-wait"),this.#t(i,"wait",s))})}#t(e,t,i){if(e.classList.contains("hakumi-steps-item-custom"))return;let s=e.querySelector(".hakumi-steps-icon");s&&(s.classList.contains("hakumi-steps-icon-dot")||(t==="finish"?s.innerHTML=this.#i():t==="error"?s.innerHTML=this.#s():s.textContent=i+1))}#i(){return'<span class="hakumi-icon"><svg viewBox="64 64 896 896" focusable="false" data-icon="check" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"></path></svg></span>'}#s(){return'<span class="hakumi-icon"><svg viewBox="64 64 896 896" focusable="false" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></span>'}#a(e,t){this.dispatch("change",{detail:{current:e,previous:t}})}};var Wi=class extends m{static targets=["input","dropdown","option","empty","clear","optionTemplate"];static values={caseSensitive:{type:Boolean,default:!1},filterMode:{type:String,default:"contains"}};setup(){this._open=!1,this._activeIndex=-1,this.#a()}registerApi(){this.element.hakumiComponent={name:"autocomplete",version:1,singleton:!1,api:{getValue:()=>this.inputTarget.value,setValue:e=>this.setValue(e),setOptions:(e,t)=>this.setOptions(e,t),open:()=>this.open(),close:()=>this.close(),clear:()=>this.clear(),filter:e=>this.filterOptions(e),focus:()=>this.focus(),blur:()=>this.blur()}}}onInput(e){let t=e.target.value||"";this.filterOptions(t),this.open()}onKeydown(e){if(this.hasOptionTarget)switch(e.key){case"ArrowDown":e.preventDefault(),this._open||this.open(),this.#i(1);break;case"ArrowUp":e.preventDefault(),this._open||this.open(),this.#i(-1);break;case"Enter":if(!this._open)return;e.preventDefault();let t=this.#e();if(t.length===0)return;let i=this._activeIndex>=0&&this._activeIndex<t.length?this._activeIndex:0;this.#s(t[i]);break;case"Escape":this.close();break;default:break}}onBlur(){setTimeout(()=>{this._mouseDownOnOption||this.close(),this._mouseDownOnOption=!1},100)}open(){this._open||(this._open=!0,this.hasDropdownTarget&&this.dropdownTarget.classList.remove("hakumi-auto-complete-dropdown-hidden"),this.inputTarget.setAttribute("aria-expanded","true"),this.#t(),this.dispatch("open",{detail:{value:this.inputTarget.value}}))}close(){this._open&&(this._open=!1,this.hasDropdownTarget&&this.dropdownTarget.classList.add("hakumi-auto-complete-dropdown-hidden"),this.inputTarget.setAttribute("aria-expanded","false"),this.#t(),this.dispatch("close",{detail:{value:this.inputTarget.value}}))}clear(e){e&&e.preventDefault(),this.inputTarget.value="",this.filterOptions(""),this.close(),this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatch("clear",{detail:{value:"",label:""}})}select(e){e.preventDefault(),this._mouseDownOnOption=!0;let t=e.currentTarget;this.#s(t)}focus(){this.hasInputTarget&&this.inputTarget.focus()}blur(){this.hasInputTarget&&this.inputTarget.blur()}setValue(e){this.inputTarget.value=e||"",this.filterOptions(this.inputTarget.value)}setOptions(e=[],t={}){let{append:i=!1}=t||{},s=this.#n(e);i||this.#r(),this.#u(s),this.filterOptions(this.inputTarget.value||"")}filterOptions(e){let t=this.caseSensitiveValue?e||"":(e||"").toLowerCase(),i=!1;this.optionTargets.forEach(a=>{let n=a.dataset.label||a.dataset.value||"",r=this.caseSensitiveValue?n:n.toLowerCase(),o=!1;t===""?o=!0:this.filterModeValue==="starts_with"?o=r.startsWith(t):o=r.includes(t),a.classList.toggle("hakumi-auto-complete-item-hidden",!o),o&&(i=!0)}),this.element.querySelectorAll(".hakumi-auto-complete-group").forEach(a=>{let n=a.querySelector(".hakumi-auto-complete-item:not(.hakumi-auto-complete-item-hidden)");a.style.display=n?"block":"none"}),this.hasEmptyTarget&&(this.emptyTarget.style.display=i?"none":"block"),this.#t()}#e(){return this.optionTargets.filter(e=>!e.classList.contains("hakumi-auto-complete-item-hidden"))}#t(){this._activeIndex=-1,this.optionTargets.forEach(e=>{e.classList.remove("hakumi-auto-complete-item-active")})}#i(e){let t=this.#e();if(t.length===0)return;this._activeIndex===-1?this._activeIndex=e>0?0:t.length-1:this._activeIndex=(this._activeIndex+e+t.length)%t.length,t.forEach((s,a)=>{s.classList.toggle("hakumi-auto-complete-item-active",a===this._activeIndex)});let i=t[this._activeIndex];if(i&&this.hasDropdownTarget){let s=this.dropdownTarget,a=i.getBoundingClientRect(),n=s.getBoundingClientRect();a.top<n.top?s.scrollTop-=n.top-a.top:a.bottom>n.bottom&&(s.scrollTop+=a.bottom-n.bottom)}}#s(e){let t=e.dataset.value||"",i=e.dataset.label||t;this.inputTarget.value=t,this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatch("select",{detail:{value:t,label:i}}),this.close()}#a(){if(!this.hasEmptyTarget)return;let e=this.#e().length>0;this.emptyTarget.style.display=e?"none":"block"}#n(e){return(e||[]).map(t=>this.#o(t)).filter(Boolean)}#o(e){if(e==null)return null;if(typeof e=="string")return{label:e,value:e};if(Array.isArray(e)){let[t,i]=e,s=t??i??"",a=i??t??"";return{label:String(s),value:String(a)}}if(typeof e=="object"){let t=e.label??e.value??"",i=e.value??e.label??"";return{label:String(t),value:String(i)}}return null}#r(){this.hasDropdownTarget&&this.dropdownTarget.querySelectorAll(".hakumi-auto-complete-item").forEach(e=>e.remove())}#u(e){if(!this.hasDropdownTarget||e.length===0)return;let t=document.createDocumentFragment();if(e.forEach(s=>{let a=this.#h(s);a&&t.appendChild(a)}),t.childNodes.length===0)return;let i=this.hasEmptyTarget?this.emptyTarget:null;this.dropdownTarget.insertBefore(t,i)}#h(e){let t=this.#l,i=t?t.cloneNode(!0):this.#c();if(!i)return null;let s=e.label??e.value??"",a=e.value??e.label??"";i.setAttribute("data-value",a),i.setAttribute("data-label",s);let n=i.querySelector(".hakumi-auto-complete-item-label");return n&&(n.textContent=s),i}get#l(){return this.hasOptionTemplateTarget?this.optionTemplateTarget.content.cloneNode(!0).firstElementChild:null}#c(){let e=document.createElement("div");e.className="hakumi-auto-complete-item",e.setAttribute("role","option"),e.setAttribute("data-action","mousedown->hakumi--autocomplete#select click->hakumi--autocomplete#select"),e.setAttribute("data-hakumi--autocomplete-target","option");let t=document.createElement("span");return t.className="hakumi-auto-complete-item-label",e.appendChild(t),e}};var Yi=class extends m{static targets=["input","label","placeholder","menus","hiddenInput","clearBtn","menuItem"];static values={options:Array,value:Array,trigger:{type:String,default:"click"},changeOnSelect:Boolean,disabled:Boolean};setup(){this.clickOutsideHandler=this.clickOutside.bind(this),document.addEventListener("click",this.clickOutsideHandler),this.activePath=[],this.initialized=!1,this.valueValue.length>0&&(this.activePath=[...this.valueValue],this.updateLabelFromValue())}teardown(){document.removeEventListener("click",this.clickOutsideHandler)}registerApi(){this.element.hakumiComponent={name:"cascader",version:1,singleton:!1,api:{getValue:()=>[...this.valueValue],setValue:(e=[])=>this.setValuePath(e),getLabel:()=>this.labelsForPath(this.valueValue).join(" / "),open:()=>this.open(),close:()=>this.close(),clear:()=>this.clear(),isOpen:()=>this.element.classList.contains("hakumi-cascader-open")}}}toggle(e){this.disabledValue||(e.stopPropagation(),e.preventDefault(),this.element.classList.contains("hakumi-cascader-open")?this.close():this.open())}open(){this.element.classList.add("hakumi-cascader-open","hakumi-cascader-focused"),this.menusTarget.classList.remove("hakumi-cascader-menus-hidden"),this.renderMenus()}close(){this.element.classList.remove("hakumi-cascader-open","hakumi-cascader-focused"),this.menusTarget.classList.add("hakumi-cascader-menus-hidden")}clickOutside(e){!this.element.contains(e.target)&&this.element.classList.contains("hakumi-cascader-open")&&this.close()}preventClose(e){e.stopPropagation()}renderMenus(){let e=this.optionsValue,t=0;for(;e&&e.length>0;){this.syncLevel(e,t);let i=this.activePath[t];if(i){let s=e.find(a=>String(a.value)===String(i));s&&s.children?(e=s.children,t++):e=null}else e=null}for(;this.menusTarget.children.length>t+1;)this.menusTarget.removeChild(this.menusTarget.lastChild)}syncLevel(e,t){let i=this.menusTarget.children[t],s=t===0?"root":String(this.activePath[t-1]);if(i&&i.dataset.parent!==s){for(;this.menusTarget.children.length>t;)this.menusTarget.removeChild(this.menusTarget.lastChild);i=null}i?this.updateActiveState(i,t):(i=this.createMenu(e,t,s),this.menusTarget.appendChild(i))}createMenu(e,t,i){let s=document.createElement("ul");return s.className="hakumi-cascader-menu",s.setAttribute("role","menu"),s.dataset.parent=i,e.forEach(a=>{let n=a.disabled,r=document.createElement("li");r.className="hakumi-cascader-menu-item",n&&r.classList.add("hakumi-cascader-menu-item-disabled"),r.dataset.value=a.value,r.dataset.label=a.label,r.dataset.level=t,r.dataset.hasChildren=!!(a.children&&a.children.length>0),n||(this.triggerValue==="hover"?(r.addEventListener("mouseenter",()=>this.handleOptionActivate(a,t)),r.addEventListener("click",()=>this.handleOptionClick(a,t))):r.addEventListener("click",()=>this.handleOptionClick(a,t))),r.innerHTML=`
|
|
77
|
+
<div class="hakumi-cascader-menu-item-content">${a.label}</div>
|
|
78
|
+
${a.children&&a.children.length>0?'<span class="hakumi-cascader-menu-item-expand-icon"><span role="img" aria-label="right" class="anticon anticon-right"><svg viewBox="64 64 896 896" focusable="false" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3 6.1 7.7 6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg></span></span>':""}
|
|
79
|
+
`,s.appendChild(r)}),this.updateActiveState(s,t),s}updateActiveState(e,t){let i=String(this.activePath[t]);Array.from(e.children).forEach(s=>{s.dataset.value===i?s.classList.add("hakumi-cascader-menu-item-active"):s.classList.remove("hakumi-cascader-menu-item-active")})}isActive(e,t){return String(this.activePath[t])===String(e)}handleOptionClick(e,t){this.handleOptionActivate(e,t);let i=!(e.children&&e.children.length>0);(i||this.changeOnSelectValue)&&(this.select(this.activePath),i&&this.close())}handleOptionActivate(e,t){this.activePath=this.activePath.slice(0,t),this.activePath.push(e.value),this.renderMenus()}select(e){this.valueValue=[...e],this.updateLabelFromValue(),this.hiddenInputTarget.value=this.valueValue.join(","),this.dispatch("change",{detail:{value:this.valueValue}}),this.hasClearBtnTarget&&(this.clearBtnTarget.style.opacity="1")}setValuePath(e=[]){Array.isArray(e)&&(this.valueValue=[...e],this.activePath=[...e],this.renderMenus(),this.hiddenInputTarget.value=this.valueValue.join(","),this.updateLabelFromValue())}updateLabelFromValue(){if(this.valueValue.length===0){this.placeholderTarget.style.display="block",this.hasLabelTarget&&(this.labelTarget.style.display="none"),this.hasClearBtnTarget&&(this.clearBtnTarget.style.opacity="0"),this.element.classList.remove("hakumi-cascader-has-value");return}let t=this.labelsForPath(this.valueValue).join(" / ");this.hasLabelTarget&&(this.labelTarget.textContent=t,this.labelTarget.title=t,this.labelTarget.style.display="block"),this.placeholderTarget.style.display="none",this.element.classList.add("hakumi-cascader-has-value"),this.hasClearBtnTarget&&(this.clearBtnTarget.style.opacity="1")}clear(e){e&&e.stopPropagation(),this.valueValue=[],this.activePath=[],this.hiddenInputTarget.value="",this.updateLabelFromValue(),this.close(),this.dispatch("change",{detail:{value:[]}})}labelsForPath(e=[]){let t=[],i=this.optionsValue;for(let s of e){let a=i.find(n=>String(n.value)===String(s));if(a)t.push(a.label),i=a.children||[];else break}return t}};var ji=class extends m{static targets=["input","checkbox"];static values={checked:Boolean,indeterminate:Boolean};setup(){this.#e(),this.#t()}registerApi(){this.element.hakumiComponent={name:"checkbox",version:1,singleton:!1,api:{setChecked:e=>this.setChecked(e),setIndeterminate:e=>this.setIndeterminate(e),isChecked:()=>this.checkedValue,isIndeterminate:()=>this.indeterminateValue}}}checkedValueChanged(){this.#t()}indeterminateValueChanged(){this.#e()}toggle(e){this.checkedValue=this.inputTarget.checked,this.indeterminateValue=!1,this.dispatch("change",{detail:{checked:this.checkedValue,value:this.inputTarget.value}})}setChecked(e){this.inputTarget.checked=e,this.checkedValue=e,this.indeterminateValue=!1}setIndeterminate(e){this.indeterminateValue=e}#e(){this.hasInputTarget&&(this.inputTarget.indeterminate=this.indeterminateValue),this.hasCheckboxTarget&&(this.indeterminateValue?this.checkboxTarget.classList.add("hakumi-checkbox-indeterminate"):this.checkboxTarget.classList.remove("hakumi-checkbox-indeterminate"))}#t(){this.hasInputTarget&&this.inputTarget.checked!==this.checkedValue&&(this.inputTarget.checked=this.checkedValue),this.hasCheckboxTarget&&(this.checkedValue?this.checkboxTarget.classList.add("hakumi-checkbox-checked"):this.checkboxTarget.classList.remove("hakumi-checkbox-checked"))}};var Xi=class extends m{static values={value:Array};setup(){this._subscribers=new Set,this.boundHandleChildChange=this.handleChildChange.bind(this),this.element.addEventListener("hakumi--checkbox:change",this.boundHandleChildChange),this.#e()}valueValueChanged(){this.#e()}teardown(){this.element.removeEventListener("hakumi--checkbox:change",this.boundHandleChildChange)}registerApi(){this.element.hakumiComponent={name:"checkbox_group",version:1,singleton:!1,api:{getValue:()=>this.getValue(),getAllValues:()=>this.getAllValues(),setValue:e=>this.setValue(e),selectAll:()=>this.selectAll(),clearAll:()=>this.clearAll(),onChange:e=>this.#i(e),offChange:e=>this.#s(e)}}}handleChildChange(e){e.stopPropagation();let{value:t,checked:i}=e.detail,s=[...this.valueValue];if(i)s.includes(t)||s.push(t);else{let a=s.indexOf(t);a>-1&&s.splice(a,1)}this.valueValue=s,this.dispatch("change",{detail:{value:this.valueValue}})}setValue(e){this.valueValue=e,this.#e(),this.dispatch("change",{detail:{value:this.valueValue}}),this.#a()}getValue(){return this.valueValue}getAllValues(){return this.#t()}selectAll(){this.setValue(this.#t())}clearAll(){this.setValue([])}#e(){this.element.querySelectorAll('[data-controller~="hakumi--checkbox"]').forEach(t=>{let i=t.querySelector('input[type="checkbox"]');if(!i)return;let s=i.value,a=this.valueValue.includes(s);t.hakumiComponent?.api?t.hakumiComponent.api.setChecked(a):i.checked=a})}#t(){return Array.from(new Set(Array.from(this.element.querySelectorAll('input[type="checkbox"]')).map(e=>e.value)))}#i(e){return typeof e=="function"?(this._subscribers.add(e),()=>this.#s(e)):()=>{}}#s(e){e&&this._subscribers.delete(e)}#a(){this._subscribers&&this._subscribers.forEach(e=>{try{e(this.getValue())}catch(t){console.error("antCheckboxGroup onChange callback failed",t)}})}};var Gi=class extends m{static targets=["trigger","colorBlock","displayText","clearBtn","panel","saturation","saturationHandler","hueSlider","hueHandler","alphaSlider","alphaHandler","colorInput","formatSelect","hiddenInput"];static values={value:String,defaultValue:String,format:{type:String,default:"hex"},trigger:{type:String,default:"click"},placement:{type:String,default:"bottom_left"},disabled:Boolean,disabledAlpha:Boolean,allowClear:Boolean,showText:Boolean,showFormatSelect:{type:Boolean,default:!0}};setup(){this.isOpen=!1,this.isDragging=!1,this.dragType=null;let e=this.valueValue||this.defaultValueValue||"#1677ff";this.hsv=this.parseColorToHSV(e),this.alpha=this.extractAlpha(e),this.boundOutsideClick=this.handleOutsideClick.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this),this.boundMouseUp=this.handleMouseUp.bind(this),this.updateUI(),this.syncDisabledState(),this.triggerValue==="hover"&&(this.element.addEventListener("mouseenter",()=>this.open()),this.element.addEventListener("mouseleave",()=>this.close()))}teardown(){document.removeEventListener("click",this.boundOutsideClick),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("mouseup",this.boundMouseUp)}registerApi(){this.element.hakumiComponent={name:"color_picker",version:1,singleton:!1,api:{getValue:()=>this.getCurrentColor(),setValue:e=>this.setValue(e),open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),clear:()=>this.clear(),getFormat:()=>this.formatValue,setFormat:e=>this.setFormat(e),getHSV:()=>({...this.hsv}),getAlpha:()=>this.alpha}}}toggle(e){e&&e.stopPropagation(),!this.disabledValue&&(this.isOpen?this.close():this.open())}open(){this.disabledValue||this.isOpen||(this.isOpen=!0,this.element.classList.add("hakumi-color-picker-open"),this.hasPanelTarget&&this.panelTarget.classList.remove("hakumi-color-picker-panel-hidden"),this.hasTriggerTarget&&this.triggerTarget.setAttribute("aria-expanded","true"),document.addEventListener("click",this.boundOutsideClick),this.dispatchEvent("open-change",{open:!0}))}close(){this.isOpen&&(this.isOpen=!1,this.element.classList.remove("hakumi-color-picker-open"),this.hasPanelTarget&&this.panelTarget.classList.add("hakumi-color-picker-panel-hidden"),this.hasTriggerTarget&&this.triggerTarget.setAttribute("aria-expanded","false"),document.removeEventListener("click",this.boundOutsideClick),this.dispatchEvent("open-change",{open:!1}))}handleOutsideClick(e){this.element.contains(e.target)||this.close()}stopPropagation(e){e.stopPropagation()}clear(e){e&&e.stopPropagation(),!this.disabledValue&&(this.hsv={h:215,s:91,v:100},this.alpha=1,this.updateUI(),this.updateHiddenInput(""),this.dispatchEvent("change",{value:"",hsv:this.hsv,alpha:this.alpha}))}setValue(e){this.disabledValue||(this.hsv=this.parseColorToHSV(e),this.alpha=this.extractAlpha(e),this.updateUI(),this.updateHiddenInput(e),this.dispatchEvent("change",{value:e,hsv:this.hsv,alpha:this.alpha}))}setFormat(e){["hex","rgb","hsl","hsb"].includes(e)&&this.showFormatSelectValue&&(this.formatValue=e,this.hasFormatSelectTarget&&(this.formatSelectTarget.value=e),this.updateColorInput())}startSaturationDrag(e){this.disabledValue||(e.preventDefault(),this.isDragging=!0,this.dragType="saturation",document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("mouseup",this.boundMouseUp),this.updateSaturationFromMouse(e))}startHueDrag(e){this.disabledValue||(e.preventDefault(),this.isDragging=!0,this.dragType="hue",document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("mouseup",this.boundMouseUp),this.updateHueFromMouse(e))}startAlphaDrag(e){this.disabledValue||(e.preventDefault(),this.isDragging=!0,this.dragType="alpha",document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("mouseup",this.boundMouseUp),this.updateAlphaFromMouse(e))}handleMouseMove(e){if(this.isDragging)switch(e.preventDefault(),this.dragType){case"saturation":this.updateSaturationFromMouse(e);break;case"hue":this.updateHueFromMouse(e);break;case"alpha":this.updateAlphaFromMouse(e);break}}handleMouseUp(e){this.isDragging&&(this.isDragging=!1,this.dragType=null,document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("mouseup",this.boundMouseUp))}updateSaturationFromMouse(e){if(!this.hasSaturationTarget)return;let t=this.saturationTarget.getBoundingClientRect(),i=Math.max(0,Math.min(e.clientX-t.left,t.width)),s=Math.max(0,Math.min(e.clientY-t.top,t.height));this.hsv.s=Math.round(i/t.width*100),this.hsv.v=Math.round((1-s/t.height)*100),this.updateUI(),this.emitColorChange()}updateHueFromMouse(e){if(!this.hasHueSliderTarget)return;let t=this.hueSliderTarget.getBoundingClientRect(),i=Math.max(0,Math.min(e.clientX-t.left,t.width));this.hsv.h=Math.round(i/t.width*360),this.updateUI(),this.emitColorChange()}updateAlphaFromMouse(e){if(!this.hasAlphaSliderTarget)return;let t=this.alphaSliderTarget.getBoundingClientRect(),i=Math.max(0,Math.min(e.clientX-t.left,t.width));this.alpha=Math.round(i/t.width*100)/100,this.updateUI(),this.emitColorChange()}handleColorInput(e){let t=e.target.value;this.isValidColor(t)?e.target.classList.remove("hakumi-color-picker-input-invalid"):e.target.classList.add("hakumi-color-picker-input-invalid")}handleColorInputChange(e){let t=e.target.value;this.isValidColor(t)&&(this.hsv=this.parseColorToHSV(t),this.alpha=this.extractAlpha(t),this.updateUI(),this.emitColorChange(),e.target.classList.remove("hakumi-color-picker-input-invalid"))}handleFormatChange(e){this.setFormat(e.target.value)}selectPreset(e){if(this.disabledValue)return;let t=e.currentTarget.dataset.color;this.setValue(t)}updateUI(){this.updateSaturationPanel(),this.updateSaturationHandler(),this.updateHueSlider(),this.updateHueHandler(),this.updateAlphaSlider(),this.updateAlphaHandler(),this.updateColorBlock(),this.updateColorInput(),this.updateDisplayText(),this.updateClearButton()}updateSaturationPanel(){if(!this.hasSaturationTarget)return;let e=this.hsv.h,t=this.hsvToRgb(e,100,100);this.saturationTarget.style.backgroundColor=`rgb(${t.r}, ${t.g}, ${t.b})`}updateSaturationHandler(){if(!this.hasSaturationHandlerTarget||!this.hasSaturationTarget)return;let e=this.hsv.s,t=100-this.hsv.v;this.saturationHandlerTarget.style.left=`${e}%`,this.saturationHandlerTarget.style.top=`${t}%`}updateHueSlider(){}updateHueHandler(){if(!this.hasHueHandlerTarget)return;let e=this.hsv.h/360*100;this.hueHandlerTarget.style.left=`${e}%`}updateAlphaSlider(){if(!this.hasAlphaSliderTarget)return;let e=this.hsvToRgb(this.hsv.h,this.hsv.s,this.hsv.v),t=`rgb(${e.r}, ${e.g}, ${e.b})`;this.alphaSliderTarget.style.background=`
|
|
80
|
+
linear-gradient(to right, transparent, ${t}),
|
|
81
|
+
conic-gradient(#d3d3d3 0.25turn, #fff 0turn 0.5turn, #d3d3d3 0turn 0.75turn, #fff 0turn 1turn)
|
|
82
|
+
`,this.alphaSliderTarget.style.backgroundSize="100%, 8px 8px"}updateAlphaHandler(){if(!this.hasAlphaHandlerTarget)return;let e=this.alpha*100;this.alphaHandlerTarget.style.left=`${e}%`}updateColorBlock(){if(!this.hasColorBlockTarget)return;let e=this.getCurrentColor();this.colorBlockTarget.style.backgroundColor=e}updateColorInput(){if(!this.hasColorInputTarget)return;let e=this.getCurrentColor();this.colorInputTarget.value=e}updateDisplayText(){if(!this.hasDisplayTextTarget)return;let e=this.getCurrentColor();this.displayTextTarget.textContent=e}updateClearButton(){if(!this.allowClearValue||!this.hasClearBtnTarget)return;let e=!!this.getCurrentColor();this.clearBtnTarget.style.display=e?"":"none"}updateHiddenInput(e=null){if(!this.hasHiddenInputTarget)return;let t=e!==null?e:this.getCurrentColor();this.hiddenInputTarget.value=t,this.hiddenInputTarget.dispatchEvent(new Event("change",{bubbles:!0}))}getCurrentColor(){switch(this.formatValue){case"hex":return this.hsvToHex(this.hsv.h,this.hsv.s,this.hsv.v,this.alpha);case"rgb":return this.hsvToRgbString(this.hsv.h,this.hsv.s,this.hsv.v,this.alpha);case"hsl":return this.hsvToHslString(this.hsv.h,this.hsv.s,this.hsv.v,this.alpha);case"hsb":return this.hsvToHsbString(this.hsv.h,this.hsv.s,this.hsv.v,this.alpha);default:return this.hsvToHex(this.hsv.h,this.hsv.s,this.hsv.v,this.alpha)}}parseColorToHSV(e){return e?(e=e.trim(),e.startsWith("#")?this.hexToHsv(e):e.startsWith("rgb")?this.rgbStringToHsv(e):e.startsWith("hsl")?this.hslStringToHsv(e):e.startsWith("hsb")?this.hsbStringToHsv(e):{h:215,s:91,v:100}):{h:215,s:91,v:100}}extractAlpha(e){if(!e)return 1;if(e=e.trim(),e.startsWith("rgba")){let t=e.match(/rgba?\(([^)]+)\)/);if(t){let i=t[1].split(",").map(s=>s.trim());if(i[3])return parseFloat(i[3])}}if(e.startsWith("hsla")){let t=e.match(/hsla?\(([^)]+)\)/);if(t){let i=t[1].split(",").map(s=>s.trim());if(i[3])return parseFloat(i[3])}}if(e.startsWith("#")&&e.length===9){let t=parseInt(e.slice(7,9),16);return Math.round(t/255*100)/100}return 1}hsvToRgb(e,t,i){e=e/360,t=t/100,i=i/100;let s=Math.floor(e*6),a=e*6-s,n=i*(1-t),r=i*(1-a*t),o=i*(1-(1-a)*t),l,h,u;switch(s%6){case 0:l=i,h=o,u=n;break;case 1:l=r,h=i,u=n;break;case 2:l=n,h=i,u=o;break;case 3:l=n,h=r,u=i;break;case 4:l=o,h=n,u=i;break;case 5:l=i,h=n,u=r;break}return{r:Math.round(l*255),g:Math.round(h*255),b:Math.round(u*255)}}rgbToHsv(e,t,i){e=e/255,t=t/255,i=i/255;let s=Math.max(e,t,i),a=Math.min(e,t,i),n=s-a,r=0,o=s===0?0:n/s,l=s;return n!==0&&(s===e?r=((t-i)/n+(t<i?6:0))/6:s===t?r=((i-e)/n+2)/6:r=((e-t)/n+4)/6),{h:Math.round(r*360),s:Math.round(o*100),v:Math.round(l*100)}}hexToHsv(e){e=e.replace("#","");let t=parseInt(e.slice(0,2),16),i=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16);return this.rgbToHsv(t,i,s)}hsvToHex(e,t,i,s=1){let a=this.hsvToRgb(e,t,i),n=`#${this.toHex(a.r)}${this.toHex(a.g)}${this.toHex(a.b)}`;if(s<1&&!this.disabledAlphaValue){let r=this.toHex(Math.round(s*255));return`${n}${r}`}return n}toHex(e){let t=e.toString(16);return t.length===1?"0"+t:t}rgbStringToHsv(e){let t=e.match(/rgba?\(([^)]+)\)/);if(!t)return{h:215,s:91,v:100};let[i,s,a]=t[1].split(",").map(n=>parseInt(n.trim()));return this.rgbToHsv(i,s,a)}hsvToRgbString(e,t,i,s=1){let a=this.hsvToRgb(e,t,i);return s<1&&!this.disabledAlphaValue?`rgba(${a.r}, ${a.g}, ${a.b}, ${s})`:`rgb(${a.r}, ${a.g}, ${a.b})`}hslStringToHsv(e){let t=e.match(/hsla?\(([^)]+)\)/);if(!t)return{h:215,s:91,v:100};let i=t[1].split(",").map(r=>r.trim()),s=parseFloat(i[0]),a=parseFloat(i[1]),n=parseFloat(i[2]);return this.hslToHsv(s,a,n)}hslToHsv(e,t,i){t=t/100,i=i/100;let s=i+t*Math.min(i,1-i),a=s===0?0:2*(1-i/s);return{h:Math.round(e),s:Math.round(a*100),v:Math.round(s*100)}}hsvToHsl(e,t,i){t=t/100,i=i/100;let s=i*(1-t/2),a=s===0||s===1?0:(i-s)/Math.min(s,1-s);return{h:Math.round(e),s:Math.round(a*100),l:Math.round(s*100)}}hsvToHslString(e,t,i,s=1){let a=this.hsvToHsl(e,t,i);return s<1&&!this.disabledAlphaValue?`hsla(${a.h}, ${a.s}%, ${a.l}%, ${s})`:`hsl(${a.h}, ${a.s}%, ${a.l}%)`}hsbStringToHsv(e){let t=e.match(/hsba?\(([^)]+)\)/);if(!t)return{h:215,s:91,v:100};let i=t[1].split(",").map(s=>s.trim());return{h:Math.round(parseFloat(i[0])),s:Math.round(parseFloat(i[1])),v:Math.round(parseFloat(i[2]))}}hsvToHsbString(e,t,i,s=1){return s<1&&!this.disabledAlphaValue?`hsba(${e}, ${t}%, ${i}%, ${s})`:`hsb(${e}, ${t}%, ${i}%)`}isValidColor(e){return e?(e=e.trim(),!!(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(e)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/.test(e)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/.test(e)||/^hsba?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/.test(e))):!1}syncDisabledState(){this.element.classList.toggle("hakumi-color-picker-disabled",this.disabledValue),this.hasTriggerTarget&&(this.triggerTarget.setAttribute("aria-disabled",this.disabledValue),this.triggerTarget.tabIndex=this.disabledValue?-1:0)}emitColorChange(){let e=this.getCurrentColor();this.updateHiddenInput(e),this.dispatchEvent("change",{value:e,hsv:{...this.hsv},alpha:this.alpha,format:this.formatValue})}dispatchEvent(e,t){this.element.dispatchEvent(new CustomEvent(`hakumi:color-picker:${e}`,{detail:t,bubbles:!0}))}};var Ji=class extends m{static targets=["hiddenInput","displayInput","input","panel","clear","startInput","endInput","hourOption","minuteOption","secondOption","periodOption","nowBtn","okBtn"];static values={allowClear:Boolean,disabled:Boolean,picker:String,range:Boolean,showTime:Boolean,showSeconds:Boolean,displayFormat:String};setup(){this.isOpen=!1,this.activeRange="start",this.disabledDate=null,this.boundClickOutside=this.handleClickOutside.bind(this),document.addEventListener("click",this.boundClickOutside),this.tempRangeStart=null,this.tempRangeEnd=null}teardown(){if(document.removeEventListener("click",this.boundClickOutside),this.rangeValue&&this.hasPanelTarget){let e=this.panelTarget.querySelectorAll(".hakumi-calendar"),[t,i]=e;t&&this.boundSyncFromStart&&t.removeEventListener("hakumi--calendar:change",this.boundSyncFromStart),i&&this.boundSyncFromEnd&&i.removeEventListener("hakumi--calendar:change",this.boundSyncFromEnd),t&&this.boundHandleHover&&t.removeEventListener("hakumi--calendar:cell-hover",this.boundHandleHover),i&&this.boundHandleHover&&i.removeEventListener("hakumi--calendar:cell-hover",this.boundHandleHover)}}registerApi(){this.element.hakumiComponent={name:"date_picker",version:1,singleton:!1,api:{getValue:()=>this.getValue(),setValue:e=>this.setValue(e),open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),clear:()=>this.clear(),focus:()=>this.focus(),blur:()=>this.blur(),setDisabledDate:e=>this.setDisabledDate(e)}}}getValue(){return this.rangeValue?{startValue:this.hasStartInputTarget?this.startInputTarget.value:"",endValue:this.hasEndInputTarget?this.endInputTarget.value:""}:this.hasHiddenInputTarget?this.hiddenInputTarget.value:""}setValue(e){if(this.rangeValue){let i=e?.startValue??e?.[0]??"",s=e?.endValue??e?.[1]??"";this.hasStartInputTarget&&(this.startInputTarget.value=i),this.hasEndInputTarget&&(this.endInputTarget.value=s),this.updateClearVisibility(),this.dispatchChangeEvent({startValue:i,endValue:s});return}let t=e??"";this.hasHiddenInputTarget&&(this.hiddenInputTarget.value=t),this.hasDisplayInputTarget&&(this.displayInputTarget.value=this.formatForDisplay(t)),this.updateClearVisibility(),this.dispatchChangeEvent({value:t})}formatForDisplay(e){if(!e)return"";let t=this.displayFormatValue||this.getDefaultDisplayFormat();return L.format(e,t)}getDefaultDisplayFormat(){return this.showTimeValue?this.showSecondsValue?Ot:Pt:It}getISOFormat(){return this.showTimeValue?this.showSecondsValue?Ot:Pt:It}toggle(e){e&&e.stopPropagation(),!this.disabledValue&&(this.isOpen?this.close():this.open())}open(){this.disabledValue||this.isOpen||(this.isOpen=!0,this.element.classList.add("hakumi-date-picker-open","hakumi-date-picker-focused"),this.showPanel(!0),this.showTimeValue&&this.initializeTimeFromInput(),this.rangeValue?this.waitForCalendarApi().then(()=>{this.syncRangeCalendars(),this.setupRangeCalendarListeners(),this.syncCalendarWithInput()}):this.waitForCalendarApi().then(()=>this.syncCalendarWithInput()),this.dispatchOpenChange(!0))}initializeTimeFromInput(){let e=this.hasHiddenInputTarget?this.hiddenInputTarget.value:"",t=e.match(/(\d{2}):(\d{2})(?::(\d{2}))?$/);if(t){let i=parseInt(t[1],10),s;this.hasPeriodOptionTarget&&(i===0?(i=12,s="AM"):i<12?s="AM":(i===12||(i-=12),s="PM")),this.selectedTime={hour:String(i).padStart(2,"0"),minute:t[2],second:t[3]||"00"},s&&(this.selectedTime.period=s)}else this.selectedTime={hour:"00",minute:"00",second:"00"};if(e){let i=e.match(/^(\d{4}-\d{2}-\d{2})/);i&&(this.selectedDate=L.parseDataDate(i[1]).toDate())}this.updateTimeSelection()}waitForCalendarApi(e=50,t=10){return new Promise(i=>{let s=0,a=()=>{let n=this.panelTarget?.querySelectorAll(".hakumi-calendar");if(this.rangeValue){if(n?.length===2&&n[0]?.hakumiComponent?.api?.refresh&&n[1]?.hakumiComponent?.api?.refresh){i();return}}else if(n?.[0]?.hakumiComponent?.api?.refresh){i();return}s<e?(s++,requestAnimationFrame(()=>setTimeout(a,t))):i()};requestAnimationFrame(a)})}syncCalendarWithInput(){if(!this.hasPanelTarget)return;let e=this.hasHiddenInputTarget?this.hiddenInputTarget.value:"";this.panelTarget.querySelectorAll(".hakumi-calendar").forEach(i=>{let s=i.hakumiComponent?.api;if(s)if(e){let a=this.parseInputValue(e);a&&(s.setValue(a),s.refresh())}else s.clearSelection(),s.refresh()})}parseInputValue(e){if(!e)return null;let t=this.pickerValue||"date";try{switch(t){case"quarter":{let i=e.match(/Q(\d) (\d{4})/);if(!i)return null;let s=parseInt(i[1],10),a=parseInt(i[2],10),n=(s-1)*3+1;return L.parseDataDate(`${a}-${String(n).padStart(2,"0")}-01`).toDate()}case"year":{let i=parseInt(e,10);return isNaN(i)?null:L.parseDataDate(`${i}-01-01`).toDate()}case"month":{let[i,s]=e.split("-").map(a=>parseInt(a,10));return isNaN(i)||isNaN(s)?null:L.parseDataDate(`${i}-${String(s).padStart(2,"0")}-01`).toDate()}case"week":{let i=e.split("-W"),s=parseInt(i[0],10),a=parseInt(i[1],10);return isNaN(s)||isNaN(a)?null:L.getMondayOfISOWeek(s,a).toDate()}default:{let i=L.parseDataDate(e);return i.isValid()?i.toDate():null}}}catch{return null}}close(){this.isOpen&&(this.isOpen=!1,this.element.classList.remove("hakumi-date-picker-open","hakumi-date-picker-focused"),this.showPanel(!1),this.showTimeValue&&(this.selectedDate=null,this.selectedTime=null),this.rangeValue&&(this.tempRangeStart=null,this.tempRangeEnd=null,this.clearRangeVisuals()),this.dispatchOpenChange(!1))}updateRangeVisuals(){if(!this.rangeValue||!this.hasPanelTarget)return;this.panelTarget.querySelectorAll(".hakumi-calendar").forEach(t=>{let i=t.hakumiComponent?.api;i&&(this.tempRangeStart&&this.tempRangeEnd?i.setRange(this.tempRangeStart,this.tempRangeEnd,null):this.tempRangeStart?i.setRange(this.tempRangeStart,null,null):i.clearRange())})}clearRangeVisuals(){if(!this.hasPanelTarget)return;this.panelTarget.querySelectorAll(".hakumi-calendar").forEach(t=>{let i=t.hakumiComponent?.api;i&&i.clearRange()})}syncRangeCalendars(){if(!this.rangeValue||!this.hasPanelTarget)return;let e=this.panelTarget.querySelectorAll(".hakumi-calendar");if(e.length!==2)return;let t=e[0],i=e[1],s=t.hakumiComponent?.api,a=i.hakumiComponent?.api;if(!s||!a)return;let n=s.getValue(),r=n.getMonth(),o=n.getFullYear(),l=r+1,h=o;l>11&&(l=0,h+=1);let u=new Date(h,l,1);a.setValue(u,{navigate:!0})}setupRangeCalendarListeners(){if(!this.rangeValue||!this.hasPanelTarget)return;let e=this.panelTarget.querySelectorAll(".hakumi-calendar");if(e.length!==2)return;let t=e[0],i=e[1];this.boundSyncFromStart&&t.removeEventListener("hakumi--calendar:change",this.boundSyncFromStart),this.boundSyncFromEnd&&i.removeEventListener("hakumi--calendar:change",this.boundSyncFromEnd),this.boundSyncFromStart=s=>{let a=t.hakumiComponent?.api,n=i.hakumiComponent?.api;if(!a||!n)return;let r=a.getValue(),o=r.getMonth(),l=r.getFullYear(),h=o+1,u=l;h>11&&(h=0,u+=1);let c=n.getValue(),d=c.getMonth(),g=c.getFullYear();(d!==h||g!==u)&&n.setValue(new Date(u,h,1),{navigate:!0})},this.boundSyncFromEnd=s=>{let a=t.hakumiComponent?.api,n=i.hakumiComponent?.api;if(!a||!n)return;let r=n.getValue(),o=r.getMonth(),l=r.getFullYear(),h=o-1,u=l;h<0&&(h=11,u-=1);let c=a.getValue(),d=c.getMonth(),g=c.getFullYear();(d!==h||g!==u)&&a.setValue(new Date(u,h,1),{navigate:!0})},this.boundHandleHover=s=>{let a=s.detail?.date;if(!a)return;this.panelTarget.querySelectorAll(".hakumi-calendar").forEach(r=>{let o=r.hakumiComponent?.api;o&&o.setHoveredDate(a)})},t.addEventListener("hakumi--calendar:change",this.boundSyncFromStart),i.addEventListener("hakumi--calendar:change",this.boundSyncFromEnd),t.addEventListener("hakumi--calendar:cell-hover",this.boundHandleHover),i.addEventListener("hakumi--calendar:cell-hover",this.boundHandleHover)}clear(e){e&&e.stopPropagation(),!this.disabledValue&&(this.rangeValue?(this.hasStartInputTarget&&(this.startInputTarget.value=""),this.hasEndInputTarget&&(this.endInputTarget.value=""),this.dispatchChangeEvent({startValue:"",endValue:""})):(this.hasHiddenInputTarget&&(this.hiddenInputTarget.value=""),this.hasDisplayInputTarget&&(this.displayInputTarget.value=""),this.dispatchChangeEvent({value:""})),this.updateClearVisibility())}focus(){this.disabledValue||(this.rangeValue&&this.hasStartInputTarget?this.startInputTarget.focus():this.hasInputTarget&&this.inputTarget.focus())}blur(){this.rangeValue?(this.hasStartInputTarget&&this.startInputTarget.blur(),this.hasEndInputTarget&&this.endInputTarget.blur()):this.hasInputTarget&&this.inputTarget.blur()}activateStart(e){e&&e.stopPropagation(),!this.disabledValue&&(this.activeRange="start",this.open())}activateEnd(e){e&&e.stopPropagation(),!this.disabledValue&&(this.activeRange="end",this.open())}handleCalendarSelect(e){let t=e.detail?.date,i=e.detail;if(i?.quarter){let a=i.quarter,n=i.year||new Date().getFullYear(),r=`Q${a} ${n}`;this.setValue(r),this.rangeValue||this.syncCalendarWithInput(),this.close();return}if(!(t instanceof Date)||this.isDateDisabled(t))return;if(this.showTimeValue){if(this.selectedDate=t,!this.selectedTime){let n=(this.hasHiddenInputTarget?this.hiddenInputTarget.value:"").match(/(\d{2}):(\d{2})(?::(\d{2}))?$/);n?this.selectedTime={hour:n[1],minute:n[2],second:n[3]||"00"}:this.selectedTime={hour:"00",minute:"00",second:"00"},this.updateTimeSelection()}return}let s=this.formatDate(t);if(this.rangeValue){if(!this.tempRangeStart)this.tempRangeStart=t,this.tempRangeEnd=null,this.hasStartInputTarget&&(this.startInputTarget.value=s),this.hasEndInputTarget&&(this.endInputTarget.value=""),this.updateRangeVisuals(),this.dispatchChangeEvent({startValue:s,endValue:""});else if(this.tempRangeEnd)this.tempRangeStart=t,this.tempRangeEnd=null,this.hasStartInputTarget&&(this.startInputTarget.value=s),this.hasEndInputTarget&&(this.endInputTarget.value=""),this.updateRangeVisuals(),this.dispatchChangeEvent({startValue:s,endValue:""});else{let a=t;a<this.tempRangeStart?(this.tempRangeStart=a,this.tempRangeEnd=null,this.hasStartInputTarget&&(this.startInputTarget.value=s),this.hasEndInputTarget&&(this.endInputTarget.value=""),this.updateRangeVisuals(),this.dispatchChangeEvent({startValue:s,endValue:""})):(this.tempRangeEnd=a,this.hasEndInputTarget&&(this.endInputTarget.value=s),this.updateRangeVisuals(),this.dispatchChangeEvent({startValue:this.hasStartInputTarget?this.startInputTarget.value:"",endValue:s}),this.updateClearVisibility(),this.close())}this.updateClearVisibility();return}this.setValue(s),this.syncCalendarWithInput(),this.updateClearVisibility(),this.close()}setDisabledDate(e){this.disabledDate=e}isDateDisabled(e){return typeof this.disabledDate=="function"?this.disabledDate(e):!1}showPanel(e){this.hasPanelTarget&&(e?this.panelTarget.classList.remove("hakumi-date-picker-panel-hidden"):this.panelTarget.classList.add("hakumi-date-picker-panel-hidden"))}updateClearVisibility(){if(!this.hasClearTarget||!this.allowClearValue)return;let e=this.rangeValue?this.hasStartInputTarget&&this.startInputTarget.value||this.hasEndInputTarget&&this.endInputTarget.value:this.hasHiddenInputTarget&&this.hiddenInputTarget.value;this.clearTarget.style.display=e?"":"none"}formatDate(e,t=null){if(!e)return"";if(!(e instanceof Date))return String(e);switch(this.pickerValue||"date"){case"year":return String(e.getFullYear());case"month":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`;case"week":{let s=L.getISOWeek(e);return`${L.getISOWeekYear(e)}-W${String(s).padStart(2,"0")}`}case"quarter":return`Q${Math.floor(e.getMonth()/3)+1} ${e.getFullYear()}`;default:{let s=L.formatDataDate(e);if(t&&this.showTimeValue){let a=this.showSecondsValue?`${t.hour}:${t.minute}:${t.second}`:`${t.hour}:${t.minute}`;return`${s} ${a}`}return s}}}handleClickOutside(e){document.body.contains(e.target)&&(this.element.contains(e.target)||this.close())}dispatchChangeEvent(e){this.element.dispatchEvent(new CustomEvent("hakumi:date-picker:change",{bubbles:!0,detail:e}))}dispatchOpenChange(e){this.element.dispatchEvent(new CustomEvent("hakumi:date-picker:open-change",{bubbles:!0,detail:{open:e}}))}selectHour(e){this.selectedTime=this.selectedTime||{hour:"00",minute:"00",second:"00"},this.selectedTime.hour=e.currentTarget.dataset.value,this.updateTimeSelection()}selectMinute(e){this.selectedTime=this.selectedTime||{hour:"00",minute:"00",second:"00"},this.selectedTime.minute=e.currentTarget.dataset.value,this.updateTimeSelection()}selectSecond(e){this.selectedTime=this.selectedTime||{hour:"00",minute:"00",second:"00"},this.selectedTime.second=e.currentTarget.dataset.value,this.updateTimeSelection()}selectPeriod(e){this.selectedTime=this.selectedTime||{hour:"12",minute:"00",second:"00"},this.selectedTime.period=e.currentTarget.dataset.value,this.updateTimeSelection()}updateTimeSelection(){this.selectedTime&&(this.hourOptionTargets.forEach(e=>{e.classList.toggle("hakumi-time-picker-cell-selected",e.dataset.value===this.selectedTime.hour)}),this.minuteOptionTargets.forEach(e=>{e.classList.toggle("hakumi-time-picker-cell-selected",e.dataset.value===this.selectedTime.minute)}),this.secondOptionTargets.forEach(e=>{e.classList.toggle("hakumi-time-picker-cell-selected",e.dataset.value===this.selectedTime.second)}),this.hasPeriodOptionTarget&&this.periodOptionTargets.forEach(e=>{e.classList.toggle("hakumi-time-picker-cell-selected",e.dataset.value===this.selectedTime.period)}))}setNow(){let e=new Date;this.selectedDate=e,this.selectedTime={hour:String(e.getHours()).padStart(2,"0"),minute:String(e.getMinutes()).padStart(2,"0"),second:String(e.getSeconds()).padStart(2,"0")};let t=L.format(e,It),i=this.element.querySelector(".hakumi-calendar");i&&i.hakumiComponent&&i.hakumiComponent.api.setValue(t),this.updateTimeSelection(),this.confirmDateTime()}confirmDateTime(){let e=this.selectedDate;if(!e){let r=this.element.querySelector(".hakumi-calendar");if(!r||!r.hakumiComponent)return;let o=r.hakumiComponent.api.getValue();if(!o)return;e=L.parseDataDate(o).toDate()}let t=this.selectedTime||{hour:"00",minute:"00",second:"00"},i=parseInt(t.hour,10);t.period&&(t.period==="PM"&&i<12?i+=12:t.period==="AM"&&i===12&&(i=0));let s=new Date(e);s.setHours(i),s.setMinutes(parseInt(t.minute,10)),s.setSeconds(parseInt(t.second,10));let a=this.getISOFormat(),n=L.format(s,a);this.setValue(n),this.close()}};var Qi=class{constructor(){this.validators=this.initializeValidators()}initializeValidators(){return{required:(t,i)=>({valid:!(t==null||t===""||Array.isArray(t)&&t.length===0),message:i.message||"This field is required"}),minLength:(t,i)=>t?{valid:String(t).length>=i.value,message:i.message||`Minimum ${i.value} characters required`}:{valid:!0},maxLength:(t,i)=>t?{valid:String(t).length<=i.value,message:i.message||`Maximum ${i.value} characters allowed`}:{valid:!0},min:(t,i)=>!t&&t!==0?{valid:!0}:{valid:Number(t)>=i.value,message:i.message||`Minimum value is ${i.value}`},max:(t,i)=>!t&&t!==0?{valid:!0}:{valid:Number(t)<=i.value,message:i.message||`Maximum value is ${i.value}`},pattern:(t,i)=>t?{valid:new RegExp(i.value).test(String(t)),message:i.message||"Invalid format"}:{valid:!0},email:(t,i)=>t?{valid:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t)),message:i.message||"Invalid email format"}:{valid:!0},url:(t,i)=>{if(!t)return{valid:!0};try{return new URL(String(t)),{valid:!0}}catch{return{valid:!1,message:i.message||"Invalid URL format"}}},match:(t,i,s={})=>{if(!t)return{valid:!0};let a=i.value||i.field;if(!a)return console.error("Match validator requires a field name in rule.value or rule.field"),{valid:!0};let n=s[a];return{valid:t===n,message:i.message||`Must match ${a}`}},custom:(t,i)=>{if(typeof i.validator!="function")return console.error("Custom validator must be a function"),{valid:!0};try{let s=i.validator(t);return typeof s=="boolean"?{valid:s,message:i.message||"Validation failed"}:s}catch(s){return console.error("Custom validator error:",s),{valid:!1,message:i.message||"Validation error"}}}}}validate(t,i,s={}){if(!i||i.length===0)return{valid:!0,errors:[]};let a=[];for(let n of i){if(n.dependent){if(!this.checkDependency(n.dependent,s))continue;if(n.dependent.rules){let u=this.validate(t,n.dependent.rules,s);u.valid||a.push(...u.errors)}continue}let r=this.getValidatorType(n);if(!r)continue;let o=this.validators[r];if(!o){console.warn(`Unknown validator type: ${r}`);continue}let l=o(t,n,s);l.valid||a.push(l.message)}return{valid:a.length===0,errors:a}}checkDependency(t,i){let s=i[t.field];return t.value!==void 0?s===t.value:t.validator?t.validator(s,i):!!s}getValidatorType(t){let i=Object.keys(this.validators);for(let a of i)if(t[a]!==void 0||a==="custom"&&t.validator)return!t.value&&t[a]!==void 0&&t[a]!==!0&&(t.value=t[a]),a;let s={min_length:"minLength",max_length:"maxLength"};for(let[a,n]of Object.entries(s))if(t[a]!==void 0)return t[n]=t[a],t.value=t[a],delete t[a],n;return null}registerValidator(t,i){this.validators[t]=i}},ba=new Qi;var Zi=class extends m{static values={dependencies:Array,fieldName:String,rules:Array};setup(){console.log("[FormItemController] Setup",{fieldName:this.fieldNameValue,dependencies:this.dependenciesValue,rules:this.rulesValue}),this.hasInteracted=!1,this.setupListeners(),this.setupFormSubmitValidation()}teardown(){this.removeListeners(),this.removeFormSubmitValidation()}registerApi(){this.element.hakumiComponent={name:"form_item",version:1,singleton:!1,api:{validate:()=>this.validate(),clearError:()=>this.clearError(),reset:()=>this.resetValidation(),getState:()=>({hasError:this.element.classList.contains("hakumi-form-item-has-error"),hasInteracted:this.hasInteracted})}}}setupFormSubmitValidation(){let e=this.element.closest("form");e&&(this.boundSubmitHandler=this.handleFormSubmit.bind(this),e.addEventListener("submit",this.boundSubmitHandler))}removeFormSubmitValidation(){let e=this.element.closest("form");!e||!this.boundSubmitHandler||e.removeEventListener("submit",this.boundSubmitHandler)}handleFormSubmit(e){this.hasInteracted=!0;let t=this.element.querySelector("input, textarea");if(!t)return;let i=t.value;if(this.hasRulesValue&&this.rulesValue.length>0){let s=this.collectFormData(),a=ba.validate(i,this.rulesValue,s);a.valid||(e.preventDefault(),this.showError(a.errors[0]),console.log("[FormItemController] Form submission prevented due to validation error"))}}setupListeners(){if(this.boundValidate=this.validate.bind(this),this.hasRulesValue&&this.rulesValue.length>0){let i=this.element.querySelector("input, textarea");i&&(i.addEventListener("input",this.boundValidate),i.addEventListener("blur",this.boundValidate),console.log("[FormItemController] Attached validation listeners to current field"))}let e=[];if(this.hasDependenciesValue&&e.push(...this.dependenciesValue),this.hasRulesValue&&this.rulesValue.forEach(i=>{i.match&&e.push(i.match),i.dependent&&i.dependent.field&&e.push(i.dependent.field)}),e=[...new Set(e)],e.length===0)return;console.log("[FormItemController] Setting up dependency listeners for:",e),this.dependencyFields=[];let t=this.element.querySelector("input, textarea");t&&(t.addEventListener("input",this.boundValidate),t.addEventListener("change",this.boundValidate),console.log("[FormItemController] Attached listeners to current field")),e.forEach(i=>{let s=this.findField(i);console.log("[FormItemController] Looking for field:",i,"Found:",s),s?(this.dependencyFields.push(s),s.addEventListener("input",this.boundValidate),s.addEventListener("change",this.boundValidate),console.log("[FormItemController] Attached listeners to:",i)):console.warn("[FormItemController] Could not find dependency field:",i)})}removeListeners(){if(!this.boundValidate)return;let e=this.element.querySelector("input, textarea");e&&(e.removeEventListener("input",this.boundValidate),e.removeEventListener("blur",this.boundValidate),e.removeEventListener("change",this.boundValidate)),this.dependencyFields&&this.dependencyFields.forEach(t=>{t.removeEventListener("input",this.boundValidate),t.removeEventListener("change",this.boundValidate)})}findField(e){let t=this.element.closest("form");if(!t)return null;let i=t.querySelector(`[name="${e}"]`);return i||(i=t.querySelector(`#${e}`),i)||(i=t.querySelector(`[name*="[${e}]"]`),i)||(i=t.querySelector(`[name$="${e}"]`)),i}validate(){console.log("[FormItemController] validate() called, hasInteracted:",this.hasInteracted),this.hasInteracted||(this.hasInteracted=!0);let e=this.element.querySelector("input, textarea");if(!e){console.warn("[FormItemController] No input/textarea found in element");return}console.log("[FormItemController] Current field:",e);let t=e.value;this.hasRulesValue&&this.rulesValue.length>0&&(console.log("[FormItemController] Running rule-based validation"),this.validateWithRules(t))}validateWithRules(e){let t=this.collectFormData(),i=ba.validate(e,this.rulesValue,t);console.log("[FormItemController] Validation result:",i),i.valid?this.clearError():this.showError(i.errors[0])}collectFormData(){let e=this.element.closest("form");if(!e)return{};let t={};return e.querySelectorAll("input, textarea, select").forEach(s=>{if(s.name){let a=s.name.match(/\[([^\]]+)\]$/),n=a?a[1]:s.name;t[n]=s.value}}),t}showError(e){this.element.classList.add("hakumi-form-item-has-error");let t=this.element.querySelector(".hakumi-form-item-explain");if(!t){let s=this.element.querySelector(".hakumi-form-item-control");s&&(t=document.createElement("div"),t.className="hakumi-form-item-explain",s.appendChild(t))}if(t){let s=t.querySelector(".hakumi-form-item-explain-error");s||(s=document.createElement("div"),s.className="hakumi-form-item-explain-error",s.setAttribute("role","alert"),t.innerHTML="",t.appendChild(s)),s.textContent=e}let i=this.element.querySelector("input, textarea");i&&i.setAttribute("aria-invalid","true"),this.updateSubmitButton(!0)}clearError(){this.element.classList.remove("hakumi-form-item-has-error");let e=this.element.querySelector(".hakumi-form-item-explain");if(e&&e.querySelector(".hakumi-form-item-explain-error")){let s=this.element.querySelector(".hakumi-form-item-extra");s?(e.innerHTML="",e.appendChild(s)):e.remove()}let t=this.element.querySelector("input, textarea");t&&t.removeAttribute("aria-invalid"),this.updateSubmitButton(!1)}updateSubmitButton(e){let t=this.element.closest("form");if(!t)return;let i=t.querySelector('button[type="submit"], input[type="submit"]');i&&(e?(i.setAttribute("disabled","disabled"),console.log("[FormItemController] Submit button disabled")):t.querySelectorAll(".hakumi-form-item-has-error").length===0?(i.removeAttribute("disabled"),console.log("[FormItemController] Submit button enabled")):console.log("[FormItemController] Submit button still disabled (other errors present)"))}resetValidation(){this.hasInteracted=!1,this.clearError()}};var es=class extends m{static targets=["input"];static values={hasClear:{type:Boolean,default:!1}};setup(){this.updateClearIconVisibility()}registerApi(){this.element.hakumiComponent={name:"input",version:1,singleton:!1,api:{getValue:()=>this.inputTarget.value,setValue:e=>this.setValue(e),clear:()=>this.clear(),focus:()=>this.inputTarget.focus(),blur:()=>this.inputTarget.blur()}}}handleInput(){this.updateClearIconVisibility()}clear(){let e=this.element.querySelector("input");e&&(e.value="",e.focus(),e.dispatchEvent(new Event("input",{bubbles:!0})),this.updateClearIconVisibility())}updateClearIconVisibility(){if(!this.hasClearValue)return;let e=this.element.querySelector("input"),t=this.element.querySelector(".hakumi-input-clear-icon");e&&t&&(e.value.length>0?(t.classList.remove("hakumi-input-clear-icon-hidden"),t.classList.add("hakumi-input-clear-icon-visible")):(t.classList.remove("hakumi-input-clear-icon-visible"),t.classList.add("hakumi-input-clear-icon-hidden")))}focus(){this.element.classList.add("hakumi-input-affix-wrapper-focused")}blur(){this.element.classList.remove("hakumi-input-affix-wrapper-focused")}setValue(e){let t=this.inputTarget;t&&(t.value=e??"",t.dispatchEvent(new Event("input",{bubbles:!0})),this.updateClearIconVisibility())}};var ts=class extends m{static targets=["input","up","down"];static values={min:String,max:String,step:{type:String,default:"1"},precision:Number,keyboard:{type:Boolean,default:!0},wheel:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},formatterOptions:Object};setup(){this.rawValue=this.inputTarget.value,this.syncFromInput()}teardown(){this.rawValue=null}registerApi(){this.element.hakumiComponent={name:"input_number",version:1,singleton:!1,api:{getValue:()=>this.getValue(),setValue:e=>this.setValue(e),clear:()=>this.clear(),focus:()=>this.focus(),blur:()=>this.blur()}}}handleInput(){this.rawValue=this.inputTarget.value,this.updateRangeState(this.rawValue),this.updateAria(this.rawValue),this.updateHandlersState(this.rawValue)}handleFocus(){this.element.classList.add("hakumi-input-number-focused"),this.formatterOptionsValue&&this.rawValue!==""&&(this.inputTarget.value=this.rawValue),this.dispatch("focus")}handleBlur(){this.element.classList.remove("hakumi-input-number-focused"),this.commitInput(),this.dispatch("blur")}handleKeydown(e){this.keyboardValue&&(e.key==="ArrowUp"&&(e.preventDefault(),this.stepUp()),e.key==="ArrowDown"&&(e.preventDefault(),this.stepDown()))}handleWheel(e){this.wheelValue&&document.activeElement===this.inputTarget&&(e.preventDefault(),e.deltaY<0?this.stepUp():e.deltaY>0&&this.stepDown())}handleStepUp(e){e&&e.preventDefault(),this.stepUp()}handleStepDown(e){e&&e.preventDefault(),this.stepDown()}getValue(){return this.rawValue??""}setValue(e){this.commitValue(e)}clear(){this.commitValue("")}focus(){this.hasInputTarget&&this.inputTarget.focus()}blur(){this.hasInputTarget&&this.inputTarget.blur()}syncFromInput(){this.hasInputTarget&&this.commitValue(this.inputTarget.value,{dispatch:!1})}commitInput(){this.commitValue(this.inputTarget.value)}commitValue(e,t={}){let{dispatch:i=!0}=t,s=e==null?"":String(e).trim();if(s===""){this.applyValue(""),i&&this.dispatch("change",{detail:{value:""}});return}let a=this.resolvePrecision(s),n=this.parseToUnits(s,a);if(n===null){this.applyValue(""),i&&this.dispatch("change",{detail:{value:""}});return}let r=this.clampUnits(n,a),o=this.formatFromUnits(r,a);this.applyValue(o),i&&this.dispatch("change",{detail:{value:o}})}applyValue(e){this.rawValue=e;let t=this.formatDisplayValue(e);this.inputTarget.value=t,this.updateAria(e),this.updateRangeState(e),this.updateHandlersState(e)}stepUp(){this.disabledValue||this.inputTarget.disabled||this.inputTarget.readOnly||this.stepBy(1)}stepDown(){this.disabledValue||this.inputTarget.disabled||this.inputTarget.readOnly||this.stepBy(-1)}stepBy(e){let t=this.rawValue===""?"0":this.rawValue,i=this.resolvePrecision(t),s=this.parseToUnits(t,i)??0n,a=this.parseToUnits(this.stepValue,i)??1n,n=s+a*BigInt(e),r=this.clampUnits(n,i),o=this.formatFromUnits(r,i);this.applyValue(o),this.dispatch("step",{detail:{value:o,direction:e}}),this.dispatch("change",{detail:{value:o}})}updateAria(e){if(!this.hasInputTarget)return;let t=e===""?null:e;t?this.inputTarget.setAttribute("aria-valuenow",t):this.inputTarget.removeAttribute("aria-valuenow")}updateRangeState(e){if(!e||e==="-"){this.element.classList.remove("hakumi-input-number-out-of-range");return}let t=this.resolvePrecision(e),i=this.parseToUnits(e,t);if(i===null)return;let s=this.hasMinValue?this.parseToUnits(this.minValue,t):null,a=this.hasMaxValue?this.parseToUnits(this.maxValue,t):null,n=s!==null&&i<s||a!==null&&i>a;this.element.classList.toggle("hakumi-input-number-out-of-range",n)}updateHandlersState(e){if(!this.hasUpTarget||!this.hasDownTarget)return;if(this.disabledValue||this.inputTarget.disabled||this.inputTarget.readOnly){this.upTarget.disabled=!0,this.downTarget.disabled=!0;return}let t=this.resolvePrecision(e||"0"),i=this.parseToUnits(e||"0",t)??0n,s=this.hasMinValue?this.parseToUnits(this.minValue,t):null,a=this.hasMaxValue?this.parseToUnits(this.maxValue,t):null,n=a!==null&&i>=a,r=s!==null&&i<=s;this.upTarget.disabled=n,this.downTarget.disabled=r}resolvePrecision(e){let t=this.decimalPlaces(this.stepValue),i=this.decimalPlaces(e);return this.hasPrecisionValue&&Number.isFinite(this.precisionValue)?Math.max(this.precisionValue,t):Math.max(t,i)}decimalPlaces(e){if(e==null)return 0;let t=String(e),i=t.indexOf(".");return i===-1?0:t.length-i-1}parseToUnits(e,t){let i=this.sanitize(e);if(!i)return null;let s=i.startsWith("-"),a=s?i.slice(1):i,[n,r=""]=a.split("."),o=r.padEnd(t,"0").slice(0,t),l=`${n||"0"}${o}`;if(l==="")return null;let h=BigInt(l);return s?-h:h}formatFromUnits(e,t){let i=e<0,a=(i?-e:e).toString().padStart(t+1,"0"),n=t>0?a.slice(0,-t):a,r=t>0?a.slice(-t):"",o=t>0?`${n}.${r}`:n;return i?`-${o}`:o}clampUnits(e,t){let i=e;if(this.hasMinValue){let s=this.parseToUnits(this.minValue,t);s!==null&&i<s&&(i=s)}if(this.hasMaxValue){let s=this.parseToUnits(this.maxValue,t);s!==null&&i>s&&(i=s)}return i}formatDisplayValue(e){if(e==="")return"";if(!this.formatterOptionsValue||e.replace(/[^\d]/g,"").length>15)return e;let i=Number(e);return Number.isFinite(i)?new Intl.NumberFormat(void 0,this.formatterOptionsValue).format(i):e}sanitize(e){if(e==null)return"";let t=String(e).trim();if(t===""||t==="-")return"";let i=t.replace(/[^0-9.\-]/g,""),s=i.startsWith("-");i=i.replace(/\-/g,""),s&&(i=`-${i}`);let a=i.split(".");return a.length<=1?i:`${a.shift()}.${a.join("")}`}};var is=class extends m{static targets=["input","icon","toggleButton"];static values={visible:{type:Boolean,default:!1}};setup(){this.updateInputType(),this.updateIcon()}registerApi(){this.element.hakumiComponent={name:"input_password",version:1,singleton:!1,api:{getValue:()=>this.getValue(),setValue:e=>this.setValue(e),clear:()=>this.clear(),focus:()=>this.focus(),blur:()=>this.blur(),toggle:e=>this.toggle(e||new Event("click")),show:()=>this.setVisible(!0),hide:()=>this.setVisible(!1),isVisible:()=>this.visibleValue}}}toggle(e){e&&e.preventDefault(),this.visibleValue=!this.visibleValue}visibleValueChanged(){this.updateInputType(),this.updateIcon()}updateInputType(){this.hasInputTarget&&(this.inputTarget.type=this.visibleValue?"text":"password")}updateIcon(){if(this.hasIconTarget){let t=this.iconTarget.querySelector("svg");t&&(this.visibleValue?t.innerHTML=this.getEyeIconPath():t.innerHTML=this.getEyeInvisibleIconPath())}}getEyeIconPath(){return'<path d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 0 0 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"/>'}getEyeInvisibleIconPath(){return'<path d="M942.2 486.2Q889.47 375.11 816.7 305l-50.88 50.88C807.31 395.53 843.45 447.4 874.7 512 791.5 684.2 673.4 766 512 766q-72.67 0-133.87-22.38L323 798.75Q408 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 0 0 0-51.5zm-63.57-320.64L836 122.88a8 8 0 0 0-11.32 0L715.31 232.2Q624.86 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 0 0 0 51.5q56.69 119.4 136.5 191.41L112.48 835a8 8 0 0 0 0 11.31L155.17 889a8 8 0 0 0 11.31 0l712.15-712.12a8 8 0 0 0 0-11.32zM149.3 512C232.6 339.8 350.7 258 512 258c54.54 0 104.13 9.36 149.12 28.39l-70.3 70.3a176 176 0 0 0-238.13 238.13l-83.42 83.42C223.1 637.49 183.3 582.28 149.3 512zm246.7 0a112.11 112.11 0 0 1 146.2-106.69L401.31 546.2A112 112 0 0 1 396 512z"/><path d="M508 624c-3.46 0-6.87-.16-10.25-.47l-52.82 52.82a176.09 176.09 0 0 0 227.42-227.42l-52.82 52.82c.31 3.38.47 6.79.47 10.25a111.94 111.94 0 0 1-112 112z"/>'}getValue(){return this.hasInputTarget?this.inputTarget.value:""}setValue(e){this.hasInputTarget&&(this.inputTarget.value=e??"",this.inputTarget.dispatchEvent(new Event("input",{bubbles:!0})))}clear(){this.setValue("")}focus(){this.hasInputTarget&&this.inputTarget.focus()}blur(){this.hasInputTarget&&this.inputTarget.blur()}setVisible(e){this.visibleValue=!!e}};var ss=class extends m{static values={autosize:{type:Boolean,default:!1},maxlength:Number};setup(){this.autosizeValue&&this.resize(),this.updateCount()}registerApi(){this.element.hakumiComponent={name:"input_textarea",version:1,singleton:!1,api:{getValue:()=>this.getValue(),setValue:e=>this.setValue(e),clear:()=>this.clear(),resize:()=>this.resize(),updateCount:()=>this.updateCount(),focus:()=>this.focus(),blur:()=>this.blur()}}}handleInput(){this.autosizeValue&&this.resize(),this.updateCount()}updateCount(){let e=this.element.querySelector("textarea");if(!e)return;let t=e.value.length;this.hasMaxlengthValue?this.element.setAttribute("data-count",`${t} / ${this.maxlengthValue}`):this.element.setAttribute("data-count",t)}resize(){let e=this.element.querySelector("textarea");e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}getValue(){let e=this.element.querySelector("textarea");return e?e.value:""}setValue(e){let t=this.element.querySelector("textarea");t&&(t.value=e??"",t.dispatchEvent(new Event("input",{bubbles:!0})),this.autosizeValue&&this.resize(),this.updateCount())}clear(){this.setValue("")}focus(){let e=this.element.querySelector("textarea");e&&e.focus()}blur(){let e=this.element.querySelector("textarea");e&&e.blur()}};var as=class extends m{static targets=["input","textarea","dropdown","option","empty"];static values={options:Array,prefix:Array,split:{type:String,default:" "},filterOption:{type:String,default:"contains"},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},autoSize:{type:Boolean,default:!1}};get fieldTarget(){return this.hasInputTarget?this.inputTarget:this.textareaTarget}get hasFieldTarget(){return this.hasInputTarget||this.hasTextareaTarget}setup(){this.activePrefix=null,this.activeStartIndex=null,this.activeQuery="",this.autoSizeValue&&this.resize(),this.#s()}teardown(){this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null)}registerApi(){this.element.hakumiComponent={name:"mentions",version:1,singleton:!1,api:{getValue:()=>this.getValue(),setValue:e=>this.setValue(e),getMentions:()=>this.getMentions(),focus:()=>this.focus(),blur:()=>this.blur(),insertMention:e=>this.insertMention(e)}}}handleInput(){this.disabledValue||this.readonlyValue||(this.updateSuggestions(),this.autoSizeValue&&this.resize(),this.#n())}handleKeydown(e){e.key==="Escape"&&this.closeDropdown()}handleFocus(){this.disabledValue||this.readonlyValue||this.updateSuggestions()}handleBlur(){clearTimeout(this.blurTimeout),this.blurTimeout=setTimeout(()=>this.closeDropdown(),100)}select(e){if(this.disabledValue||this.readonlyValue)return;e.preventDefault();let t=e.currentTarget,i=t.dataset.value||t.dataset.label||t.textContent.trim(),s=t.dataset.label||i;this.insertMention(i),this.#o({value:i,label:s})}updateSuggestions(){let e=this.#e();if(!e){this.activePrefix=null,this.activeStartIndex=null,this.activeQuery="",this.closeDropdown();return}let{query:t,prefix:i,startIndex:s}=e;this.activePrefix=i,this.activeStartIndex=s,this.activeQuery=t,this.#t(t),this.openDropdown(),this.#r({query:t,prefix:i})}handleScroll(){this.hasDropdownTarget&&!this.dropdownTarget.classList.contains("hakumi-mentions-dropdown-hidden")&&this.#u()}openDropdown(){this.hasDropdownTarget&&(this.#u(),this.dropdownTarget.classList.remove("hakumi-mentions-dropdown-hidden"))}closeDropdown(){this.hasDropdownTarget&&this.dropdownTarget.classList.add("hakumi-mentions-dropdown-hidden")}getValue(){return this.hasFieldTarget?this.fieldTarget.value:""}setValue(e){this.hasFieldTarget&&(this.fieldTarget.value=e??"",this.fieldTarget.dispatchEvent(new Event("input",{bubbles:!0})),this.autoSizeValue&&this.resize())}getMentions(){let e=this.getValue(),t=this.#a();return!e||t.length===0?[]:e.split(/\s+/).filter(i=>t.some(s=>i.startsWith(s))).map(i=>{let s=t.find(n=>i.startsWith(n));return i.replace(s,"").replace(/[.,!?:;\)\]\}]+$/,"")})}focus(){this.hasFieldTarget&&this.fieldTarget.focus()}blur(){this.hasFieldTarget&&this.fieldTarget.blur()}insertMention(e){if(!this.hasFieldTarget)return;let t=this.fieldTarget,i=t.value,s=t.selectionStart??i.length,a=this.activePrefix||this.#a()[0]||"",n=this.splitValue||" ",r=this.activeStartIndex??i.lastIndexOf(a,s);if(r<0&&s===0){let g=`${a}${e}${n}`;t.value=g+i,t.setSelectionRange(g.length,g.length),t.dispatchEvent(new Event("input",{bubbles:!0})),this.closeDropdown();return}if(r<0){t.value=i+`${a}${e}${n}`,t.dispatchEvent(new Event("input",{bubbles:!0})),this.closeDropdown();return}let o=i.slice(0,r),l=i.slice(s),h=n&&l.startsWith(n)?"":n,u=`${a}${e}${h}`,c=`${o}${u}${l}`;t.value=c;let d=o.length+u.length;t.setSelectionRange(d,d),t.dispatchEvent(new Event("input",{bubbles:!0})),this.closeDropdown()}resize(){this.hasTextareaTarget&&(this.textareaTarget.style.height="auto",this.textareaTarget.style.height=`${this.textareaTarget.scrollHeight}px`)}#e(){if(!this.hasFieldTarget)return null;let e=this.fieldTarget.value,t=this.fieldTarget.selectionStart??e.length,i=e.slice(0,t),s=this.#a(),a=this.splitValue||" ",n=a?i.lastIndexOf(a):-1,r=null;return s.forEach(o=>{let l=i.lastIndexOf(o);if(l<0||l<n)return;let h=i.slice(l+o.length);r={prefix:o,query:h,startIndex:l}}),r}#t(e){let t=this.filterOptionValue,i=e.toLowerCase(),s=0;this.optionTargets.forEach(a=>{let n=(a.dataset.label||a.textContent).toLowerCase(),r=!0;t&&t!=="false"&&(t==="starts_with"?r=n.startsWith(i):r=n.includes(i)),a.classList.toggle("hakumi-mentions-option-hidden",!r),r&&(s+=1)}),this.#i(s===0)}#i(e){this.hasEmptyTarget&&(this.emptyTarget.style.display=e?"block":"none")}#s(){this.hasEmptyTarget&&this.#i(this.optionTargets.length===0)}#a(){return Array.isArray(this.prefixValue)?this.prefixValue:[]}#n(){this.element.dispatchEvent(new CustomEvent("hakumi:mentions:change",{bubbles:!0,detail:{value:this.getValue(),mentions:this.getMentions()}}))}#o(e){this.element.dispatchEvent(new CustomEvent("hakumi:mentions:select",{bubbles:!0,detail:e}))}#r(e){this.element.dispatchEvent(new CustomEvent("hakumi:mentions:search",{bubbles:!0,detail:e}))}#u(){if(!this.hasFieldTarget||!this.hasDropdownTarget)return;let e=this.fieldTarget,t=this.dropdownTarget,i=this.activeStartIndex??e.selectionStart,s=this.#h(e,i),a=s.top+s.height+2,n=s.left,r=e.getBoundingClientRect(),o=t.getBoundingClientRect(),l=window.innerWidth,h=window.innerHeight;r.left+n+o.width>l&&(n=Math.max(0,e.offsetWidth-o.width)),r.top+a+o.height>h&&s.top>o.height&&(a=s.top-o.height-2),t.style.top=`${a}px`,t.style.left=`${n}px`}#h(e,t){let i=document.createElement("div"),s=window.getComputedStyle(e);i.style.position="absolute",i.style.visibility="hidden",i.style.whiteSpace="pre-wrap",i.style.wordWrap="break-word",i.style.overflowWrap="break-word",i.style.top="0",i.style.left="0",["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"].forEach(c=>{i.style[c]=s[c]});let n=e.value.substring(0,t);i.textContent=n;let r=document.createElement("span");r.textContent=e.value.substring(t)||".",i.appendChild(r),document.body.appendChild(i);let o=r.getBoundingClientRect(),l=i.getBoundingClientRect(),h=parseInt(s.lineHeight);isNaN(h)&&(h=parseInt(s.fontSize)*1.2);let u={top:o.top-l.top-e.scrollTop,left:o.left-l.left-e.scrollLeft,height:h};return document.body.removeChild(i),u}};var ns=class extends m{static targets=["input","radio"];static values={checked:Boolean,variant:String};setup(){this.#t()}registerApi(){this.element.hakumiComponent={name:"radio",version:1,singleton:!1,api:{setChecked:e=>this.setChecked(e),isChecked:()=>this.checkedValue}}}checkedValueChanged(){this.#t()}toggle(){this.hasInputTarget&&(this.checkedValue=this.inputTarget.checked,this.#e(),this.dispatch("change",{detail:{checked:this.checkedValue,value:this.inputTarget.value,name:this.inputTarget.name}}))}setChecked(e){this.hasInputTarget&&(this.inputTarget.checked=e),this.checkedValue=e,this.#e()}#e(){if(!this.hasInputTarget)return;let e=this.inputTarget.name;if(!e)return;(this.element.closest(".hakumi-radio-group")||document).querySelectorAll('[data-controller~="hakumi--radio"]').forEach(s=>{let a=s.querySelector('input[type="radio"]');if(!a||a.name!==e)return;let n=this.application?.getControllerForElementAndIdentifier(s,"hakumi--radio");n?n.checkedValue=a.checked:this.#i(s,a.checked,a.disabled)})}#t(){this.hasInputTarget&&this.inputTarget.checked!==this.checkedValue&&(this.inputTarget.checked=this.checkedValue),this.#i(this.element,this.checkedValue,this.hasInputTarget?this.inputTarget.disabled:!1),this.#s()}#i(e,t,i){let s=this.variantValue==="button"?"hakumi-radio-button-wrapper":"hakumi-radio-wrapper";e.classList.toggle(`${s}-checked`,t),e.classList.toggle(`${s}-disabled`,i)}#s(){this.hasRadioTarget&&(this.radioTarget.classList.toggle("hakumi-radio-checked",this.checkedValue),this.radioTarget.classList.toggle("hakumi-radio-disabled",this.hasInputTarget?this.inputTarget.disabled:!1))}};var rs=class extends m{static targets=["input","star"];static values={count:Number,allowHalf:Boolean,allowClear:Boolean,disabled:Boolean,readonly:Boolean,value:Number};setup(){this.currentValue=this.valueValue||0,this.#i(),this.#a(this.currentValue),this.#e(),this.#t(),this.#o()}teardown(){this.boundKeyHandler&&this.element.removeEventListener("keydown",this.boundKeyHandler)}registerApi(){this.element.hakumiComponent={name:"rate",version:1,singleton:!1,api:{setValue:e=>this.setValue(e),getValue:()=>this.currentValue,clear:()=>this.clear(),setDisabled:e=>this.setDisabled(e),isDisabled:()=>this.disabledValue,toggleDisabled:()=>this.setDisabled(!this.disabledValue),disable:()=>this.setDisabled(!0),enable:()=>this.setDisabled(!1),setReadonly:e=>this.setReadonly(e),isReadonly:()=>this.readonlyValue,toggleReadonly:()=>this.setReadonly(!this.readonlyValue),setAllowClear:e=>this.setAllowClear(e),isAllowClear:()=>this.allowClearValue,toggleAllowClear:()=>this.setAllowClear(!this.allowClearValue),setAllowHalf:e=>this.setAllowHalf(e),isAllowHalf:()=>this.allowHalfValue,toggleAllowHalf:()=>this.setAllowHalf(!this.allowHalfValue)}}}valueValueChanged(e){this.currentValue=Number(e||0),this.#i(),this.#a(this.currentValue)}onHover(e){if(this.#n())return;let t=this.#s(e);this.#a(t)}onLeave(){this.#n()||this.#a(this.currentValue)}onClick(e){if(this.#n())return;let t=this.#s(e);this.allowClearValue&&t===this.currentValue&&(t=0),this.setValue(t),this.dispatch("change",{detail:{value:t}})}setValue(e){this.currentValue=Number(e||0),this.valueValue=this.currentValue,this.#i(),this.#a(this.currentValue)}clear(){this.setValue(0)}setDisabled(e){this.disabledValue=!!e}setReadonly(e){this.readonlyValue=!!e}setAllowClear(e){this.allowClearValue=!!e}setAllowHalf(e){this.allowHalfValue=!!e,this.#a(this.currentValue)}disabledValueChanged(){this.#e()}readonlyValueChanged(){this.#t()}#e(){let e=this.disabledValue;this.element.classList.toggle("hakumi-rate-disabled",e),this.element.setAttribute("aria-disabled",String(e)),this.#n()?this.element.setAttribute("tabindex","-1"):this.element.setAttribute("tabindex","0"),this.hasInputTarget&&(this.inputTarget.disabled=e)}#t(){let e=this.readonlyValue;this.element.classList.toggle("hakumi-rate-readonly",e),this.element.setAttribute("aria-readonly",String(e)),this.#n()?this.element.setAttribute("tabindex","-1"):this.element.setAttribute("tabindex","0")}#i(){this.hasInputTarget&&(this.inputTarget.value=this.currentValue)}#s(e){let t=e.currentTarget,i=Number(t.dataset.index);if(!this.allowHalfValue)return i;let s=t.getBoundingClientRect();return e.clientX-s.left<=s.width/2?i-.5:i}#a(e){let t=Math.floor(e),i=e-t>0,s=this.allowHalfValue&&i;this.starTargets.forEach(a=>{let n=Number(a.dataset.index),r=n<=t,o=n===t+1&&s;a.classList.toggle("hakumi-rate-star-full",r),a.classList.toggle("hakumi-rate-star-half",o),a.classList.toggle("hakumi-rate-star-zero",!r&&!o)}),this.element.classList.toggle("hakumi-rate-has-value",e>0),this.element.setAttribute("aria-valuenow",e)}#n(){return this.disabledValue||this.readonlyValue}#o(){this.boundKeyHandler=this.#r.bind(this),this.element.addEventListener("keydown",this.boundKeyHandler),!this.#n()&&!this.element.hasAttribute("tabindex")&&this.element.setAttribute("tabindex","0")}#r(e){if(this.#n())return;let t=!1,i=this.currentValue;switch(e.key){case"ArrowRight":case"ArrowUp":i=Math.min(this.countValue,this.currentValue+(this.allowHalfValue?.5:1)),t=!0;break;case"ArrowLeft":case"ArrowDown":i=Math.max(0,this.currentValue-(this.allowHalfValue?.5:1)),t=!0;break;case"Home":i=this.allowClearValue?0:this.allowHalfValue?.5:1,t=!0;break;case"End":i=this.countValue,t=!0;break;case"Enter":case" ":this.allowClearValue&&(i=this.currentValue===0?this.countValue:0,t=!0);break}t&&(e.preventDefault(),this.setValue(i),this.dispatch("change",{detail:{value:i}}))}};var os=class extends m{static targets=["input","label","placeholder","dropdown","option","clearBtn","searchInput","empty"];static values={allowClear:Boolean,disabled:Boolean,showSearch:Boolean,trigger:{type:String,default:"click"}};setup(){this.clickOutsideHandler=this.clickOutside.bind(this),document.addEventListener("click",this.clickOutsideHandler),this.triggerValue==="hover"&&(this.boundPositionDropdown=()=>this.#t(),this.element.addEventListener("mouseenter",this.boundPositionDropdown))}teardown(){document.removeEventListener("click",this.clickOutsideHandler),this.boundPositionDropdown&&this.element.removeEventListener("mouseenter",this.boundPositionDropdown)}registerApi(){this.element.hakumiComponent={name:"select",version:1,singleton:!1,api:{getValue:()=>this.inputTarget.value,setValue:e=>this.setValueByValue(e),getLabel:()=>this.hasLabelTarget?this.labelTarget.textContent:this.hasSearchInputTarget?this.searchInputTarget.value:"",open:()=>this.open(),close:()=>this.close(),clear:()=>this.clearValue(),isOpen:()=>this.element.classList.contains("hakumi-select-open")}}}setValueByValue(e){let t=this.optionTargets.find(i=>i.dataset.value===String(e));t&&this.selectItem(t)}clearValue(){this.inputTarget.value="",this.hasSearchInputTarget&&(this.searchInputTarget.value=""),this.hasLabelTarget&&(this.labelTarget.textContent="",this.labelTarget.style.display="none"),this.hasPlaceholderTarget&&(this.placeholderTarget.style.display="block"),this.optionTargets.forEach(e=>{e.classList.remove("hakumi-select-item-option-selected"),e.setAttribute("aria-selected","false")}),this.hasClearBtnTarget&&(this.clearBtnTarget.style.display="none"),this.element.classList.remove("hakumi-select-has-value"),this.dispatch("change",{detail:{value:"",label:""}})}toggle(e){this.disabledValue||(e&&e.stopPropagation(),!(this.hasSearchInputTarget&&e&&e.target===this.searchInputTarget&&this.element.classList.contains("hakumi-select-open"))&&(this.element.classList.contains("hakumi-select-open")?this.close():this.open()))}open(){this.element.classList.add("hakumi-select-open","hakumi-select-focused"),this.dropdownTarget.classList.remove("hakumi-select-dropdown-hidden"),this.#t(),this.#e(),this.hasSearchInputTarget&&this.searchInputTarget.focus()}#e(){let e=this.optionTargets.find(t=>t.classList.contains("hakumi-select-item-option-selected"));e&&this.hasDropdownTarget&&requestAnimationFrame(()=>{let t=this.dropdownTarget,i=e.offsetTop,s=e.offsetHeight,a=t.clientHeight,n=i-a/2+s/2;t.scrollTop=Math.max(0,n)})}#t(){let e=this.dropdownTarget;if(window.getComputedStyle(e).position==="fixed"){let i=this.element.getBoundingClientRect();e.style.top=`${i.bottom+4}px`,e.style.left=`${i.left}px`}}close(){this.element.classList.remove("hakumi-select-open","hakumi-select-focused"),this.dropdownTarget.classList.add("hakumi-select-dropdown-hidden"),this.hasSearchInputTarget&&(this.inputTarget.value!==""||(this.searchInputTarget.value=""),this.searchInputTarget.blur(),this.filterOptions(""))}select(e){e&&e.stopPropagation();let t=e.currentTarget;this.selectItem(t)}selectItem(e){let t=e.dataset.value,i=e.dataset.label,s=this.element.classList.contains("hakumi-select-borderless");this.inputTarget.value=t,this.hasSearchInputTarget&&(this.searchInputTarget.value=i),this.hasLabelTarget&&!s&&(this.labelTarget.textContent=i,this.labelTarget.style.display="block"),this.hasPlaceholderTarget&&!s&&(this.placeholderTarget.style.display="none"),this.optionTargets.forEach(a=>{a.dataset.value===t?(a.classList.add("hakumi-select-item-option-selected"),a.setAttribute("aria-selected","true")):(a.classList.remove("hakumi-select-item-option-selected"),a.setAttribute("aria-selected","false"))}),this.allowClearValue&&this.hasClearBtnTarget&&!s&&(this.clearBtnTarget.style.display=""),this.element.classList.add("hakumi-select-has-value"),this.close(),this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatch("change",{detail:{value:t,label:i}})}clear(e){e&&e.stopPropagation(),this.inputTarget.value="",this.hasSearchInputTarget&&(this.searchInputTarget.value=""),this.hasLabelTarget&&(this.labelTarget.textContent="",this.labelTarget.style.display="none"),this.hasPlaceholderTarget&&(this.placeholderTarget.style.display="block"),this.optionTargets.forEach(t=>{t.classList.remove("hakumi-select-item-option-selected"),t.setAttribute("aria-selected","false")}),this.hasClearBtnTarget&&(this.clearBtnTarget.style.display="none"),this.element.classList.remove("hakumi-select-has-value"),this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatch("change",{detail:{value:"",label:""}})}clickOutside(e){this.element.contains(e.target)||this.close()}onSearchInput(e){let t=e.target.value;this.filterOptions(t),t.length>0?this.hasLabelTarget&&(this.labelTarget.style.display="none"):this.inputTarget.value&&this.hasLabelTarget&&(this.labelTarget.style.display="block")}onSearchKeydown(e){if(e.key==="Enter"){e.preventDefault();let t=this.optionTargets.find(i=>!i.classList.contains("hakumi-select-item-hidden"));t&&this.selectItem(t)}else e.key==="Escape"&&(e.preventDefault(),this.close())}filterOptions(e){let t=e.toLowerCase(),i=!1;this.optionTargets.forEach(s=>{s.dataset.label.toLowerCase().includes(t)?(s.classList.remove("hakumi-select-item-hidden"),i=!0):s.classList.add("hakumi-select-item-hidden")}),this.hasEmptyTarget&&(this.emptyTarget.style.display=i?"none":"block")}};var Ye=(e,t,i)=>Math.min(Math.max(e,t),i),ls=class extends m{static targets=["rail","track","handle","tooltip","input","marks","dots"];static values={min:{type:Number,default:0},max:{type:Number,default:100},step:{type:Number,default:1},range:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},keyboard:{type:Boolean,default:!0},allowCross:{type:Boolean,default:!0},handleMin:Array,handleMax:Array,tooltipVisible:{type:Boolean,default:!1},value:Array,defaultValue:Array};setup(){this.boundDragMove=this.onDragMove.bind(this),this.boundDragEnd=this.onDragEnd.bind(this),this.boundKeydown=this.onKeydown.bind(this),this._activeHandleIndex=null,this._values=this.#g(),this._suppressValueChange=!0,this.valueValue=this.rangeValue?[...this._values]:[this._values[0]],this._suppressValueChange=!1,this.syncInputs(),this.updateUI(),this.attachEvents()}teardown(){this.detachEvents()}registerApi(){this.element.hakumiComponent={name:"slider",version:1,singleton:!1,api:{getValue:()=>this.getValue(),setValue:e=>this.setValue(e),reset:()=>this.reset(),focus:()=>this.focus(),blur:()=>this.blur(),setDisabled:e=>this.setDisabled(e),isDisabled:()=>this.disabledValue,toggleDisabled:()=>this.setDisabled(!this.disabledValue),disable:()=>this.setDisabled(!0),enable:()=>this.setDisabled(!1),getMin:()=>this.minValue,getMax:()=>this.maxValue,getStep:()=>this.stepValue,isRange:()=>this.rangeValue,isVertical:()=>this.verticalValue}}}valueValueChanged(){if(this._suppressValueChange)return;let e=this.#m(this.valueValue);e&&(this._values=e,this.updateUI())}disabledValueChanged(){this.#e()}setDisabled(e){this.disabledValue=!!e}#e(){let e=this.disabledValue;this.element.classList.toggle("hakumi-slider-disabled",e),this.handleTargets.forEach(t=>{t.setAttribute("aria-disabled",String(e)),t.setAttribute("tabindex",e?"-1":"0")}),this.inputTargets.forEach(t=>{t.disabled=e})}attachEvents(){this.hasRailTarget&&(this.railTarget.addEventListener("mousedown",e=>this.onRailClick(e)),this.railTarget.addEventListener("touchstart",e=>this.onRailClick(e),{passive:!1})),this.handleTargets.forEach(e=>{e.addEventListener("mousedown",t=>this.onHandleDown(t,e)),e.addEventListener("touchstart",t=>this.onHandleDown(t,e),{passive:!1}),e.addEventListener("keydown",this.boundKeydown),e.addEventListener("focus",()=>this.onHandleFocus(e)),e.addEventListener("blur",()=>this.onHandleBlur(e))})}detachEvents(){document.removeEventListener("mousemove",this.boundDragMove),document.removeEventListener("mouseup",this.boundDragEnd),document.removeEventListener("touchmove",this.boundDragMove),document.removeEventListener("touchend",this.boundDragEnd)}getValue(){return this.rangeValue?[this._values[0],this._values[1]]:this._values[0]}setValue(e){let t=this.#m(e);t&&(this._values=t,this.commitValue(),this.updateUI())}reset(){this._values=this.#g(!0),this.commitValue(),this.updateUI()}focus(){this.handleTargets[0]?.focus()}blur(){this.handleTargets.forEach(e=>e.blur())}onHandleDown(e,t){if(this.disabledValue)return;e.preventDefault();let i=Number(t.dataset.index||0);this._activeHandleIndex=i,this.showTooltip(i),document.addEventListener("mousemove",this.boundDragMove),document.addEventListener("mouseup",this.boundDragEnd),document.addEventListener("touchmove",this.boundDragMove,{passive:!1}),document.addEventListener("touchend",this.boundDragEnd)}onDragMove(e){if(this._activeHandleIndex===null||this.disabledValue)return;e.preventDefault();let t=this.#u(e);this.updateValueFromPercent(this._activeHandleIndex,t)}onDragEnd(){this._activeHandleIndex!==null&&(this.hideTooltip(this._activeHandleIndex),this._activeHandleIndex=null,document.removeEventListener("mousemove",this.boundDragMove),document.removeEventListener("mouseup",this.boundDragEnd),document.removeEventListener("touchmove",this.boundDragMove),document.removeEventListener("touchend",this.boundDragEnd))}onRailClick(e){if(this.disabledValue)return;e.preventDefault();let t=this.#u(e),i=this.#l(t);this._activeHandleIndex=i,this.updateValueFromPercent(i,t),this._activeHandleIndex=null}onKeydown(e){if(!this.keyboardValue||this.disabledValue)return;let t=e.currentTarget,i=Number(t.dataset.index||0);(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),this.stepBy(i,1)),(e.key==="ArrowLeft"||e.key==="ArrowDown")&&(e.preventDefault(),this.stepBy(i,-1)),e.key==="Home"&&(e.preventDefault(),this.setHandleValue(i,this.minValue)),e.key==="End"&&(e.preventDefault(),this.setHandleValue(i,this.maxValue))}onHandleFocus(e){e.classList.add("hakumi-slider-handle-focused");let t=Number(e.dataset.index||0);this.showTooltip(t)}onHandleBlur(e){e.classList.remove("hakumi-slider-handle-focused");let t=Number(e.dataset.index||0);this.hideTooltip(t)}updateValueFromPercent(e,t){let i=this.minValue+(this.maxValue-this.minValue)*t,s=this.#d(i);this.setHandleValue(e,s)}setHandleValue(e,t){let i=this.#s(t,e);if(this.rangeValue){let s=[...this._values];this.allowCrossValue?(s[e]=i,s[0]>s[1]&&s.reverse()):(e===0?i=Math.min(i,this._values[1]):i=Math.max(i,this._values[0]),s[e]=i),this._values=s}else this._values=[i];this.commitValue(),this.updateUI()}#t(e){return this.hasHandleMinValue&&this.handleMinValue[e]!=null?this.handleMinValue[e]:this.minValue}#i(e){return this.hasHandleMaxValue&&this.handleMaxValue[e]!=null?this.handleMaxValue[e]:this.maxValue}#s(e,t){let i=Number(e),s=Number.isNaN(i)?this.#t(t):i,a=this.#t(t),n=this.#i(t);return Ye(this.#d(s),a,n)}stepBy(e,t){let i=this._values[e]+this.stepValue*t;this.setHandleValue(e,i)}commitValue(){this.inputTargets.forEach((e,t)=>{e.value=this._values[t]??this._values[0]}),this._suppressValueChange=!0,this.valueValue=this.rangeValue?[...this._values]:[this._values[0]],this._suppressValueChange=!1,this.dispatch("change",{detail:{value:this.getValue()}})}syncInputs(){this.inputTargets.forEach((e,t)=>{e.value=this._values[t]??this._values[0]})}updateUI(){let e=this._values.map(t=>this.#c(t));this.handleTargets.forEach((t,i)=>{let s=e[i]??e[0];this.#r(t,s),this.#o(t,this._values[i]??this._values[0]),this.updateTooltip(i)}),this.#n(e),this.updateDots(e)}updateTooltip(e){let t=this.tooltipTargets[e];if(!t)return;let i=this._values[e]??this._values[0];t.textContent=i,this.tooltipVisibleValue&&t.classList.add("hakumi-slider-tooltip-visible")}showTooltip(e){this.tooltipTargets[e]?.classList.add("hakumi-slider-tooltip-visible")}hideTooltip(e){if(this.tooltipVisibleValue)return;this.tooltipTargets[e]?.classList.remove("hakumi-slider-tooltip-visible")}updateDots(e){if(!this.hasDotsTarget)return;let t=this.rangeValue?[Math.min(...e),Math.max(...e)]:[0,e[0]];this.dotsTarget.querySelectorAll(".hakumi-slider-dot").forEach(s=>{let a=this.#a(s),n=a>=t[0]&&a<=t[1];s.classList.toggle("hakumi-slider-dot-active",n)})}#a(e){let t=this.verticalValue?e.style.bottom:e.style.left;return t?parseFloat(t)/100:0}#n(e){if(!this.hasTrackTarget)return;let t=this.trackTarget;if(this.rangeValue){let i=Math.min(...e),s=Math.max(...e);this.verticalValue?(t.style.height=`calc((100% - 12px) * ${s-i})`,t.style.bottom=`calc(6px + (100% - 12px) * ${i})`):(t.style.width=`calc((100% - 12px) * ${s-i})`,t.style.left=`calc(6px + (100% - 12px) * ${i})`)}else{let i=e[0];this.verticalValue?(t.style.height=`calc((100% - 12px) * ${i})`,t.style.bottom="6px"):(t.style.width=`calc((100% - 12px) * ${i})`,t.style.left="6px")}}#o(e,t){e.setAttribute("aria-valuenow",t),e.setAttribute("aria-valuetext",t)}#r(e,t){this.verticalValue?(e.style.bottom=`calc(6px + (100% - 12px) * ${t})`,e.style.left="50%"):(e.style.left=`calc(6px + (100% - 12px) * ${t})`,e.style.top="50%")}#u(e){let i=this.railTarget.getBoundingClientRect(),s=this.#h(e);if(!s)return 0;if(this.verticalValue){let n=i.bottom-s.y;return Ye(n/i.height,0,1)}let a=s.x-i.left;return Ye(a/i.width,0,1)}#h(e){return e.touches&&e.touches[0]?{x:e.touches[0].clientX,y:e.touches[0].clientY}:{x:e.clientX,y:e.clientY}}#l(e){if(!this.rangeValue)return 0;let t=this._values.map(i=>Math.abs(this.#c(i)-e));return t[0]<=t[1]?0:1}#c(e){return this.maxValue===this.minValue?0:Ye((e-this.minValue)/(this.maxValue-this.minValue),0,1)}#d(e){let t=this.stepValue||1;if(t<=0)return Ye(e,this.minValue,this.maxValue);let i=Math.round((e-this.minValue)/t),s=this.minValue+i*t;return Ye(s,this.minValue,this.maxValue)}#m(e){if(e==null)return null;if(this.rangeValue){let i=Array.isArray(e)?e:[e,e];return i.length<2&&(i[1]=i[0]),this.#f(i)}let t=Number(Array.isArray(e)?e[0]:e);return[this.#p(t)]}#f(e){let t=this.#p(e[0]),i=this.#p(e[1]);return t<=i?[t,i]:[i,t]}#p(e){let t=Number(e),i=Number.isNaN(t)?this.minValue:t;return Ye(this.#d(i),this.minValue,this.maxValue)}#g(e=!1){let t=e?this.defaultValueValue:this.valueValue?.length?this.valueValue:this.defaultValueValue;if(t&&t.length)return this.#m(t)??[this.minValue];let i=this.rangeValue?[this.minValue,this.maxValue]:[this.minValue];return this.#m(i)??[this.minValue]}};var hs=class extends m{static targets=["input"];static values={checked:Boolean,disabled:Boolean,loading:Boolean};setup(){this.#e(),this.#a(),this.#n()}teardown(){this.boundKeyHandler&&this.element.removeEventListener("keydown",this.boundKeyHandler)}registerApi(){this.element.hakumiComponent={name:"switch",version:1,singleton:!1,api:{setChecked:e=>this.setChecked(e),setDisabled:e=>this.setDisabled(e),setLoading:e=>this.setLoading(e),isChecked:()=>this.checkedValue,isDisabled:()=>this.disabledValue,isLoading:()=>this.loadingValue,toggleChecked:()=>this.setChecked(!this.checkedValue),toggleDisabled:()=>this.setDisabled(!this.disabledValue),toggleLoading:()=>this.setLoading(!this.loadingValue),check:()=>this.setChecked(!0),uncheck:()=>this.setChecked(!1),enable:()=>this.setDisabled(!1),disable:()=>this.setDisabled(!0)}}}checkedValueChanged(){this.#t()}disabledValueChanged(){this.#i()}loadingValueChanged(){this.#s()}toggle(e){if(this.disabledValue||this.loadingValue){e.preventDefault(),this.hasInputTarget&&(this.inputTarget.checked=this.checkedValue);return}this.checkedValue=this.inputTarget.checked,this.dispatch("change",{detail:{checked:this.checkedValue}})}setChecked(e){this.checkedValue=!!e}setDisabled(e){this.disabledValue=!!e}setLoading(e){this.loadingValue=!!e}#e(){this.#t(),this.#i(),this.#s()}#t(){this.hasInputTarget&&this.inputTarget.checked!==this.checkedValue&&(this.inputTarget.checked=this.checkedValue),this.element.classList.toggle("hakumi-switch-checked",this.checkedValue),this.element.setAttribute("aria-checked",String(this.checkedValue))}#i(){let e=this.disabledValue;this.element.classList.toggle("hakumi-switch-disabled",e),this.element.setAttribute("aria-disabled",String(e||this.loadingValue)),this.hasInputTarget&&(this.inputTarget.disabled=e||this.loadingValue)}#s(){let e=this.loadingValue;this.element.classList.toggle("hakumi-switch-loading",e),this.element.setAttribute("aria-busy",String(e)),this.hasInputTarget&&(this.inputTarget.disabled=this.disabledValue||e)}#a(){let e=this.element.offsetWidth,t=this.element.querySelector(".hakumi-switch-handle");if(t){let i=t.offsetWidth,s=e-i-4;this.element.style.setProperty("--handle-translate",`${s}px`)}}#n(){this.boundKeyHandler=this.#o.bind(this),this.element.addEventListener("keydown",this.boundKeyHandler)}#o(e){if(e.key===" "||e.key==="Enter"){if(e.preventDefault(),this.disabledValue||this.loadingValue)return;this.setChecked(!this.checkedValue)}}};var us=class extends m{static targets=["input","dropdown","hourOption","minuteOption","secondOption","periodOption","clearBtn","nowBtn"];static values={allowClear:Boolean,disabled:Boolean,useTwelveHours:Boolean,format:String,hourStep:Number,minuteStep:Number,secondStep:Number,showNow:Boolean};setup(){this.clickOutsideHandler=this.handleClickOutside.bind(this),this.clickOutsideListenerActive=!1,this.setValue(this.inputTarget.value,{emit:!1})}teardown(){this.removeClickOutsideListener()}addClickOutsideListener(){this.clickOutsideListenerActive||setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler),this.clickOutsideListenerActive=!0},0)}removeClickOutsideListener(){this.clickOutsideListenerActive&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideListenerActive=!1)}registerApi(){this.element.hakumiComponent={name:"time_picker",version:1,singleton:!1,api:{getValue:()=>this.inputTarget.value,setValue:e=>this.setValue(e),open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),isOpen:()=>this.isOpen(),clear:()=>this.clear(),focus:()=>this.focus(),blur:()=>this.blur(),setNow:()=>this.setNow()}}}isOpen(){return this.element.classList.contains("hakumi-time-picker-open")}handleClickOutside(e){this.element.contains(e.target)||this.close()}toggle(e){this.disabledValue||(e&&e.stopPropagation(),this.element.classList.contains("hakumi-time-picker-open")?this.close():this.open())}open(){this.disabledValue||this.element.classList.contains("hakumi-time-picker-open")||(this.element.classList.add("hakumi-time-picker-open"),this.dropdownTarget.classList.remove("hakumi-time-picker-dropdown-hidden"),this.addClickOutsideListener(),this.scrollToSelectedCells(),this.dispatchOpenChange(!0))}scrollToSelectedCells(){setTimeout(()=>{let e=this.element.querySelectorAll(".hakumi-time-picker-cell-selected"),t=60;e.forEach(i=>{let s=i.closest(".hakumi-time-picker-column-list");if(s){let a=i.offsetTop;s.scrollTop=a-t}})},0)}close(){this.element.classList.contains("hakumi-time-picker-open")&&(this.element.classList.remove("hakumi-time-picker-open"),this.dropdownTarget.classList.add("hakumi-time-picker-dropdown-hidden"),this.removeClickOutsideListener(),this.dispatchOpenChange(!1))}clear(e){e&&e.stopPropagation(),this.setValue("")}focus(){this.inputTarget.focus()}blur(){this.inputTarget.blur()}setNow(){let e=new Date,t=e.getHours(),i=String(e.getMinutes()).padStart(2,"0"),s=String(e.getSeconds()).padStart(2,"0"),a=String(t).padStart(2,"0"),n="";if(this.useTwelveHoursValue){n=t>=12?"PM":"AM";let h=t%12||12;a=String(h).padStart(2,"0")}let o=this.secondOptionTargets.length>0?`${a}:${i}:${s}`:`${a}:${i}`,l=this.useTwelveHoursValue?`${o} ${n}`.trim():o;this.setValue(l)}selectHour(e){this.applyPart("hour",e.currentTarget.dataset.value)}selectMinute(e){this.applyPart("minute",e.currentTarget.dataset.value)}selectSecond(e){this.applyPart("second",e.currentTarget.dataset.value)}selectPeriod(e){this.applyPart("period",e.currentTarget.dataset.value)}setValue(e,{emit:t=!0,scroll:i=!0}={}){let s=e?String(e):"";this.inputTarget.value=s;let a=this.parseTime(s);this.updateSelection(a),this.updateHasValueState(s),this.updateClearVisibility(s),this.isOpen()&&i&&this.scrollToSelectedCells(),t&&this.dispatchChange(s,a)}applyPart(e,t){let i=this.parseTime(this.inputTarget.value);i[e]=t,i.minute||(i.minute=this.defaultValueFor(this.minuteOptionTargets,"00")),this.secondOptionTargets.length>0&&!i.second&&(i.second=this.defaultValueFor(this.secondOptionTargets,"00")),this.useTwelveHoursValue&&!i.period&&(i.period=this.defaultValueFor(this.periodOptionTargets,"AM"));let s=this.formatTime(i);this.setValue(s,{scroll:!1})}updateSelection(e){this.updateOptionSelection(this.hourOptionTargets,e.hour),this.updateOptionSelection(this.minuteOptionTargets,e.minute),this.updateOptionSelection(this.secondOptionTargets,e.second),this.updateOptionSelection(this.periodOptionTargets,e.period)}updateOptionSelection(e,t){e.forEach(i=>{let s=t&&i.dataset.value===t;i.classList.toggle("hakumi-time-picker-cell-selected",!!s)})}updateHasValueState(e){this.element.classList.toggle("hakumi-time-picker-has-value",!!e)}updateClearVisibility(e){this.hasClearBtnTarget&&(this.clearBtnTarget.style.display=e?"":"none")}parseTime(e){if(!e)return{hour:"",minute:"",second:"",period:""};let t=e.trim(),[i,s]=t.split(/\s+/),[a,n,r]=i.split(":");return{hour:a?a.padStart(2,"0"):"",minute:n?n.padStart(2,"0"):"",second:r?r.padStart(2,"0"):"",period:s?s.toUpperCase():""}}formatTime(e){let t=e.hour||this.defaultValueFor(this.hourOptionTargets,"00"),i=e.minute||this.defaultValueFor(this.minuteOptionTargets,"00"),s=e.second||"00",n=this.secondOptionTargets.length>0?`${t}:${i}:${s}`:`${t}:${i}`;if(this.useTwelveHoursValue){let r=e.period||this.defaultValueFor(this.periodOptionTargets,"AM");return`${n} ${r}`.trim()}return n}defaultValueFor(e,t){return e.length&&e[0].dataset.value||t}dispatchChange(e,t){this.element.dispatchEvent(new CustomEvent("hakumi:time-picker:change",{bubbles:!0,detail:{value:e,hour:t.hour,minute:t.minute,second:t.second,period:t.period}}))}dispatchOpenChange(e){this.element.dispatchEvent(new CustomEvent("hakumi:time-picker:open-change",{bubbles:!0,detail:{open:e}}))}};var cs=class extends m{static targets=["sourceList","targetList","sourceCheckbox","targetCheckbox","sourceSelectAll","targetSelectAll","sourceSearch","targetSearch","moveToTarget","moveToSource","sourceCount","targetCount"];static values={disabled:Boolean,showSearch:Boolean,showSelectAll:Boolean,oneWay:Boolean,targetKeys:Array,name:String,pagination:String};setup(){this.#r(),this.#n("source"),this.#n("target"),this.#o()}teardown(){}registerApi(){this.element.hakumiComponent={name:"transfer",version:1,singleton:!1,api:{getTargetKeys:()=>this.getTargetKeys(),setTargetKeys:e=>this.setTargetKeys(e),getSelectedKeys:()=>this.getSelectedKeys(),setSelectedKeys:e=>this.setSelectedKeys(e),moveToTarget:()=>this.moveToTarget(),moveToSource:()=>this.moveToSource(),selectAll:()=>this.selectAll(),unselectAll:()=>this.unselectAll(),isDisabled:()=>this.disabledValue}}}getTargetKeys(){return this.#c("target")}setTargetKeys(e){let t=this.#m(e),i=new Set(t);this.#l("source").concat(this.#l("target")).forEach(a=>{let n=a.dataset.key,r=i.has(n)?this.targetListTarget:this.sourceListTarget;a.parentElement!==r&&r.appendChild(a),this.#i(a,!1)}),this.targetKeysValue=t,this.#r(),this.#n("source"),this.#n("target"),this.#o(),this.#f("set")}getSelectedKeys(){return{source:this.#d("source"),target:this.#d("target")}}setSelectedKeys(e={}){if(Array.isArray(e)){let t=new Set(this.#m(e));this.#l("source").forEach(i=>{this.#i(i,t.has(i.dataset.key))}),this.#l("target").forEach(i=>{this.#i(i,t.has(i.dataset.key))})}else{let t=new Set(this.#m(e.source||e.sourceKeys)),i=new Set(this.#m(e.target||e.targetKeys));this.#l("source").forEach(s=>{this.#i(s,t.has(s.dataset.key))}),this.#l("target").forEach(s=>{this.#i(s,i.has(s.dataset.key))})}this.#n("source"),this.#n("target"),this.#r(),this.#o(),this.#p()}moveToTarget(){this.disabledValue||this.#e("source","target")}moveToSource(){this.disabledValue||this.oneWayValue||this.#e("target","source")}selectAll(){this.#t("source",!0),this.#t("target",!0)}unselectAll(){this.#t("source",!1),this.#t("target",!1)}toggleSelectAll(e){let t=e.params.list;this.#t(t,e.target.checked)}toggleSelection(e){let t=e.params.list,i=e.target,s=i.closest(".hakumi-transfer-list-item");!s||this.disabledValue||i.disabled||(this.#i(s,i.checked),this.#n(t),this.#r(),this.#o(),this.#p())}filterList(e){let t=e.params.list,i=e.target.value.toLowerCase().trim();this.#l(t).forEach(s=>{let a=s.textContent.toLowerCase();s.classList.toggle("hakumi-transfer-list-item-hidden",i&&!a.includes(i))})}#e(e,t){let i=this.#l(e).filter(s=>this.#a(s)&&!this.#s(s));i.length!==0&&(i.forEach(s=>{this.#i(s,!1),this.#h(t).appendChild(s)}),this.targetKeysValue=this.getTargetKeys(),this.#r(),this.#n(e),this.#n(t),this.#o(),this.#f(e==="source"?"toTarget":"toSource"),this.#p())}#t(e,t){this.disabledValue||(this.#l(e).forEach(i=>{this.#i(i,t)}),this.#n(e),this.#r(),this.#o(),this.#p())}#i(e,t){if(!e||this.#s(e))return;let i=e.querySelector("input[type='checkbox']"),s=e.querySelector(".hakumi-checkbox");i&&(i.checked=t),s&&s.classList.toggle("hakumi-checkbox-checked",t),e.classList.toggle("hakumi-transfer-list-item-selected",t)}#s(e){return e.dataset.disabled==="true"||e.querySelector("input")?.disabled}#a(e){return e.classList.contains("hakumi-transfer-list-item-selected")}#n(e){let t=e==="source"?this.hasSourceSelectAllTarget?this.sourceSelectAllTarget:null:this.hasTargetSelectAllTarget?this.targetSelectAllTarget:null;if(!t)return;let i=this.#l(e).filter(o=>!this.#s(o)),s=i.filter(o=>this.#a(o)),a=s.length>0&&s.length<i.length,n=i.length>0&&s.length===i.length;t.indeterminate=a,t.checked=n;let r=t.closest(".hakumi-checkbox");r&&(r.classList.toggle("hakumi-checkbox-checked",n),r.classList.toggle("hakumi-checkbox-indeterminate",a))}#o(){if(this.hasMoveToTargetTarget){let e=this.#d("source").length>0;this.moveToTargetTarget.disabled=this.disabledValue||!e}if(this.hasMoveToSourceTarget){let e=this.#d("target").length>0;this.moveToSourceTarget.disabled=this.disabledValue||this.oneWayValue||!e}}#r(){this.hasSourceCountTarget&&(this.sourceCountTarget.textContent=this.#u("source")),this.hasTargetCountTarget&&(this.targetCountTarget.textContent=this.#u("target"))}#u(e){let t=this.#l(e).length,i=this.#d(e).length;return this.showSelectAllValue?`${i} / ${t}`:`${t}`}#h(e){return e==="source"?this.sourceListTarget:this.targetListTarget}#l(e){let t=this.#h(e);return t?Array.from(t.querySelectorAll(".hakumi-transfer-list-item")):[]}#c(e){return this.#l(e).map(t=>t.dataset.key)}#d(e){return this.#l(e).filter(t=>this.#a(t)).map(t=>t.dataset.key)}#m(e=[]){return e?Array.from(e).map(t=>t.toString()):[]}#f(e){let t={targetKeys:this.getTargetKeys(),sourceKeys:this.#c("source"),direction:e};this.element.dispatchEvent(new CustomEvent("hakumi:transfer:change",{detail:t,bubbles:!0}))}#p(){let e={sourceSelectedKeys:this.#d("source"),targetSelectedKeys:this.#d("target")};this.element.dispatchEvent(new CustomEvent("hakumi:transfer:select-change",{detail:e,bubbles:!0}))}};var ds=class extends m{static targets=["input","label","placeholder","dropdown","clearBtn","tree","selector"];static values={allowClear:Boolean,disabled:Boolean,multiple:Boolean,treeCheckable:Boolean,maxCount:Number};setup(){this.clickOutsideHandler=this.clickOutside.bind(this),document.addEventListener("click",this.clickOutsideHandler)}teardown(){document.removeEventListener("click",this.clickOutsideHandler)}registerApi(){this.element.hakumiComponent={name:"treeSelect",version:1,singleton:!1,api:{getValue:()=>this.getValue(),setValue:e=>this.setValue(e),getLabel:()=>this.getLabel(),open:()=>this.open(),close:()=>this.close(),toggle:()=>this.toggle(),isOpen:()=>this.isOpen(),clear:()=>this.clear(),focus:()=>this.focus(),blur:()=>this.blur(),isDisabled:()=>this.disabledValue,expandAll:()=>this.expandAll(),collapseAll:()=>this.collapseAll(),getExpandedKeys:()=>this.getExpandedKeys(),setExpandedKeys:e=>this.setExpandedKeys(e),getMaxCount:()=>this.maxCountValue,isMaxReached:()=>this.isMaxReached(),addNodes:(e,t)=>this.addNodes(e,t),setLoading:(e,t)=>this.setLoading(e,t),setError:(e,t)=>this.setError(e,t)}}}addNodes(e,t){this.treeApi()?.addNodes?.(e,t)}setLoading(e,t){this.treeApi()?.setLoading?.(e,t)}setError(e,t=!0){this.treeApi()?.setError?.(e,t)}isMaxReached(){return!this.hasMaxCountValue||this.maxCountValue<=0?!1:(this.treeCheckableValue?this.treeApi()?.getCheckedKeys?.()||[]:this.treeApi()?.getSelectedKeys?.()||[]).length>=this.maxCountValue}updateMaxCountState(e){if(!this.hasMaxCountValue||this.maxCountValue<=0)return;let t=e.length>=this.maxCountValue;this.element.classList.toggle("hakumi-tree-select-max-reached",t),this.hasTreeTarget&&this.treeTarget.querySelectorAll(".hakumi-tree-node").forEach(s=>{let a=s.dataset.key,n=e.includes(a),r=s.querySelector(".hakumi-tree-node-content-wrapper"),o=s.querySelector(".hakumi-tree-checkbox");t&&!n?(s.classList.add("hakumi-tree-node-max-disabled"),r&&(r.style.pointerEvents="none"),o&&(o.style.pointerEvents="none")):(s.classList.remove("hakumi-tree-node-max-disabled"),r&&(r.style.pointerEvents=""),o&&(o.style.pointerEvents=""))})}clickOutside(e){this.element.contains(e.target)||this.close()}toggle(e){this.disabledValue||(e&&e.stopPropagation(),this.element.classList.contains("hakumi-tree-select-open")?this.close():this.open())}open(){this.disabledValue||(this.element.classList.add("hakumi-tree-select-open","hakumi-tree-select-focused"),this.dropdownTarget.classList.remove("hakumi-tree-select-dropdown-hidden"))}close(){this.element.classList.remove("hakumi-tree-select-open","hakumi-tree-select-focused"),this.dropdownTarget.classList.add("hakumi-tree-select-dropdown-hidden")}isOpen(){return this.element.classList.contains("hakumi-tree-select-open")}getLabel(){return this.hasLabelTarget&&this.labelTarget.textContent||""}focus(){this.disabledValue||(this.element.classList.add("hakumi-tree-select-focused"),this.selectorTarget?.focus?.())}blur(){this.element.classList.remove("hakumi-tree-select-focused")}clear(e){e&&e.stopPropagation(),this.treeCheckableValue?this.treeApi()?.setCheckedKeys([]):this.treeApi()?.setSelectedKeys([]),this.applySelection([])}onTreeSelect(e){if(this.treeCheckableValue)return;let t=e.detail?.selectedKeys||[];this.applySelection(t,{key:e.detail?.key}),this.multipleValue||this.close()}onTreeCheck(e){if(!this.treeCheckableValue)return;let t=e.detail?.checkedKeys||[];this.applySelection(t,{key:e.detail?.key})}getValue(){let e=this.treeCheckableValue?this.treeApi()?.getCheckedKeys?.()||[]:this.treeApi()?.getSelectedKeys?.()||[];return this.treeCheckableValue||this.multipleValue?e:e[0]||""}setValue(e){let t=Array.isArray(e)?e:e?[e]:[];this.treeCheckableValue?this.treeApi()?.setCheckedKeys(t):this.treeApi()?.setSelectedKeys(t),this.applySelection(t)}expandAll(){this.treeApi()?.expandAll?.()}collapseAll(){this.treeApi()?.collapseAll?.()}getExpandedKeys(){return this.treeApi()?.getExpandedKeys?.()||[]}setExpandedKeys(e){this.treeApi()?.setExpandedKeys?.(e)}applySelection(e,{key:t}={}){let i=this.resolveLabels(e),s=i.join(", "),a=e.length>0;this.hasLabelTarget&&(this.labelTarget.textContent=s,this.labelTarget.style.display=a?"":"none"),this.hasPlaceholderTarget&&(this.placeholderTarget.style.display=a?"none":""),this.hasClearBtnTarget&&this.allowClearValue&&(this.clearBtnTarget.style.display=a?"":"none"),this.element.classList.toggle("hakumi-tree-select-has-value",a),this.inputTarget.value=this.serializeValue(e),this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0})),this.updateMaxCountState(e);let n=this.treeCheckableValue||this.multipleValue?e:e[0]||"",r=this.treeCheckableValue||this.multipleValue?i:i[0]||"";this.dispatchSelect({value:n,label:r,values:e,labels:i,key:t}),this.dispatchChange({value:n,label:r,values:e,labels:i,key:t})}serializeValue(e){return this.treeCheckableValue||this.multipleValue?JSON.stringify(e):e[0]||""}emptyValue(){return this.treeCheckableValue||this.multipleValue?[]:""}resolveLabels(e){return e.map(t=>this.lookupLabel(t)).filter(Boolean)}lookupLabel(e){let t=window.CSS?.escape?window.CSS.escape(String(e)):String(e),i=this.treeTarget?.querySelector(`[data-key="${t}"]`);return i&&(i.dataset.title||i.querySelector(".hakumi-tree-title-text")?.textContent?.trim())||String(e)}treeApi(){return this.treeTarget?.hakumiTree||this.treeTarget?.hakumiComponent?.api}dispatchSelect(e){this.element.dispatchEvent(new CustomEvent("hakumi:tree-select:select",{detail:e,bubbles:!0}))}dispatchChange(e){this.element.dispatchEvent(new CustomEvent("hakumi:tree-select:change",{detail:e,bubbles:!0}))}};var Xo=["http:","https:","data:"],Go=["ready","uploading","done","error","aborted"],ps=class extends m{static targets=["input","list","dropzone","inlineTrigger","avatar","avatarWrapper"];static values={action:String,name:String,accept:String,multiple:Boolean,maxCount:Number,maxSize:Number,disabled:Boolean,listType:String,showUploadList:Boolean,drag:Boolean,headers:Object,data:Object,defaultFileList:Array,withCredentials:Boolean,autoUpload:{type:Boolean,default:!0},inlineTrigger:{type:Boolean,default:!1},avatarShape:String,avatarSize:Number,avatarIcon:String};setup(){this.fileList=this.normalizeFileList(this.defaultFileListValue||[]),this.renderFileList()}teardown(){this.fileList.forEach(e=>{e.xhr&&e.xhr.abort(),e.blobUrl&&e.url&&URL.revokeObjectURL(e.url)})}registerApi(){let e={upload:t=>this.upload(t),uploadAll:()=>this.uploadAll(),remove:t=>this.remove(t),removeAll:()=>this.removeAll(),getFileList:()=>this.getFileList(),setFileList:t=>this.setFileList(t),abort:t=>this.abort(t),abortAll:()=>this.abortAll(),addFile:t=>this.addFile(t),setProgress:(t,i)=>this.setProgress(t,i),setStatus:(t,i,s)=>this.setStatus(t,i,s),simulateUpload:(t,i)=>this.simulateUpload(t,i),openPreview:t=>this.openPreview(t),getPreviewItems:()=>this.getPreviewItems()};this.element.hakumiComponent={name:"upload",version:1,singleton:!1,api:e}}addFile(e){if(!e||typeof e!="object")return null;let t={uid:`upload_${Date.now()}_${Math.random().toString(16).slice(2)}`,name:this.sanitizeFileName(e.name||"file"),status:this.validateStatus(e.status)||"ready",url:this.sanitizeUrl(e.url),percent:this.clampPercent(e.percent||0),size:typeof e.size=="number"?e.size:null,error:typeof e.error=="string"?e.error:null};return this.hasMaxCountValue&&this.fileList.length>=this.maxCountValue?null:(this.fileList.push(t),this.renderFileList(),this.dispatchChange(t),t)}setProgress(e,t){let i=this.resolveRecord(e);i&&(i.percent=this.clampPercent(t),this.renderFileList(),this.dispatchProgress(i,null))}setStatus(e,t,i){let s=this.resolveRecord(e);if(!s)return;let a=this.validateStatus(t);a&&(s.status=a,a==="error"&&i&&(s.error=String(i).slice(0,500)),a==="done"&&(s.percent=100),this.renderFileList(),this.dispatchChange(s),a==="done"?this.dispatchSuccess(s):a==="error"&&this.dispatchError(s,s.error))}simulateUpload(e,t={}){let i=this.resolveRecord(e);if(!i)return Promise.reject(new Error("File not found"));let s=Math.min(Math.max(t.duration||2e3,500),3e4),a=t.success!==!1;return new Promise(n=>{i.status="uploading",i.percent=0,this.renderFileList(),this.dispatchChange(i);let r=Date.now(),o=()=>{let l=Date.now()-r,h=Math.min(l/s*100,100);i.percent=Math.round(h),this.renderFileList(),this.dispatchProgress(i,null),h<100?requestAnimationFrame(o):(a?(i.status="done",this.dispatchSuccess(i)):(i.status="error",i.error=t.error||"Upload failed",this.dispatchError(i,i.error)),this.renderFileList(),this.dispatchChange(i),n(i))};requestAnimationFrame(o)})}sanitizeFileName(e){return typeof e!="string"?"file":e.replace(/[<>:"\/\\|?*\x00-\x1f]/g,"_").slice(0,255)}sanitizeUrl(e){if(!e||typeof e!="string")return null;try{if(e.startsWith("data:"))return e.startsWith("data:image/")?e.slice(0,1024*100):null;let t=new URL(e);if(Xo.includes(t.protocol))return t.href}catch{}return null}validateStatus(e){if(typeof e!="string")return null;let t=e.toLowerCase();return Go.includes(t)?t:null}clampPercent(e){let t=Number(e);return isNaN(t)?0:Math.max(0,Math.min(100,Math.round(t)))}validateFileType(e){if(!this.acceptValue)return!0;let t=this.acceptValue.split(",").map(a=>a.trim().toLowerCase()),i=e.name.toLowerCase(),s=e.type.toLowerCase();return t.some(a=>a.startsWith(".")?i.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-2)):s===a)}getCsrfToken(){let e=document.querySelector('meta[name="csrf-token"]');return e?e.getAttribute("content"):null}triggerInput(e){e&&e.preventDefault(),!this.disabledValue&&this.hasInputTarget&&this.inputTarget.click()}handleInput(e){if(this.disabledValue)return;let t=Array.from(e.target.files||[]);this.listTypeValue==="avatar"&&t.length>0?this.handleAvatarUpload(t[0]):this.addFiles(t),e.target.value=""}dragOver(e){this.disabledValue||(e.preventDefault(),this.hasDropzoneTarget&&this.dropzoneTarget.classList.add("hakumi-upload-drag-hover"))}dragLeave(e){this.disabledValue||(e.preventDefault(),this.hasDropzoneTarget&&this.dropzoneTarget.classList.remove("hakumi-upload-drag-hover"))}drop(e){if(this.disabledValue)return;e.preventDefault(),this.hasDropzoneTarget&&this.dropzoneTarget.classList.remove("hakumi-upload-drag-hover");let t=Array.from(e.dataTransfer?.files||[]);this.addFiles(t)}addFiles(e){if(!e.length)return;let t=this.hasMaxCountValue?this.maxCountValue:null,i=t?Math.max(t-this.fileList.length,0):e.length,s=e.slice(0,i),a=[];s.forEach(r=>{let o=this.buildFileRecord(r);if(!this.validateFileType(r)){o.status="error",o.error="File type not accepted",this.fileList.push(o),this.dispatchError(o);return}this.hasMaxSizeValue&&r.size>this.maxSizeValue?(o.status="error",o.error="File exceeds max size",this.fileList.push(o),this.dispatchError(o)):(this.fileList.push(o),this.dispatchChange(o),a.push(o))}),this.renderFileList();let n=!this.actionValue||this.actionValue==="#";this.autoUploadValue&&!n&&a.length>0&&a.forEach(r=>this.performUpload(r))}upload(e){if(this.disabledValue)return;let t=this.resolveRecord(e);!t||t.status==="uploading"||this.performUpload(t)}uploadAll(){this.disabledValue||this.fileList.forEach(e=>{["ready","error"].includes(e.status)&&this.performUpload(e)})}remove(e){let t=this.resolveRecord(e);t&&(t.xhr&&t.xhr.abort(),t.blobUrl&&t.url&&URL.revokeObjectURL(t.url),this.fileList=this.fileList.filter(i=>i.uid!==t.uid),this.renderFileList(),this.dispatchChange(t))}removeFromEvent(e){let t=e.currentTarget?.dataset?.uid;this.remove(t)}previewFromEvent(e){let t=e.currentTarget?.dataset?.uid;t&&this.openPreview(t)}removeAll(){this.fileList.forEach(e=>{e.xhr&&e.xhr.abort(),e.blobUrl&&e.url&&URL.revokeObjectURL(e.url)}),this.fileList=[],this.renderFileList(),this.dispatchChange(null)}getFileList(){return this.fileList.map(e=>({...e}))}setFileList(e){this.fileList.forEach(t=>{t.xhr&&t.xhr.abort(),t.blobUrl&&t.url&&URL.revokeObjectURL(t.url)}),this.fileList=this.normalizeFileList(e||[]),this.renderFileList(),this.dispatchChange(null)}abort(e){let t=this.resolveRecord(e);!t||!t.xhr||(t.xhr.abort(),t.status="aborted",this.renderFileList(),this.dispatchError(t,"aborted"),this.dispatchChange(t))}abortAll(){this.fileList.forEach(e=>{e.xhr&&e.xhr.abort(),e.status==="uploading"&&(e.status="aborted")}),this.renderFileList(),this.dispatchError(null,"aborted"),this.dispatchChange(null)}performUpload(e){if(!this.actionValue||!e.raw)return;if(this.actionValue==="#"){this.simulateUpload(e.uid,{duration:1500,success:!0});return}e.status="uploading",e.percent=0,this.renderFileList(),this.dispatchChange(e);let t=new XMLHttpRequest;e.xhr=t,this.withCredentialsValue&&(t.withCredentials=!0),t.upload.addEventListener("progress",r=>{r.lengthComputable&&(e.percent=Math.round(r.loaded/r.total*100),this.renderFileList(),this.dispatchProgress(e,r))}),t.addEventListener("load",()=>{if(t.status>=200&&t.status<300){e.status="done",e.percent=100;try{e.response=JSON.parse(t.response)}catch{e.response=t.response}this.renderFileList(),this.dispatchSuccess(e),this.dispatchChange(e)}else e.status="error",e.error=t.statusText||"Upload failed",this.renderFileList(),this.dispatchError(e),this.dispatchChange(e)}),t.addEventListener("error",()=>{e.status="error",e.error="Network error",this.renderFileList(),this.dispatchError(e),this.dispatchChange(e)}),t.addEventListener("abort",()=>{e.status="aborted",this.renderFileList(),this.dispatchError(e,"aborted"),this.dispatchChange(e)}),t.open("POST",this.actionValue);let i=this.getCsrfToken();i&&t.setRequestHeader("X-CSRF-Token",i);let s=this.ensureObject(this.headersValue);s&&Object.entries(s).forEach(([r,o])=>{let l=r.toLowerCase();["cookie","host","origin","referer"].includes(l)||t.setRequestHeader(r,o)});let a=new FormData,n=this.ensureObject(this.dataValue);n&&Object.entries(n).forEach(([r,o])=>{a.append(r,o)}),a.append(this.nameValue||"file",e.raw),t.send(a)}normalizeFileList(e){return(e||[]).map((t,i)=>t instanceof File?this.buildFileRecord(t):{uid:t.uid||`upload_${Date.now()}_${i}`,name:this.sanitizeFileName(t.name||t.filename||"file"),status:this.validateStatus(t.status)||"ready",url:this.sanitizeUrl(t.url),percent:this.clampPercent(t.percent||0),size:t.size,response:t.response,error:typeof t.error=="string"?t.error:null,raw:t.raw||t.file})}buildFileRecord(e){let t={uid:`upload_${Date.now()}_${Math.random().toString(16).slice(2)}`,name:this.sanitizeFileName(e.name),status:"ready",percent:0,size:e.size,raw:e};return this.shouldGeneratePreview(e)&&(t.url=URL.createObjectURL(e),t.blobUrl=!0),t}shouldGeneratePreview(e){return!(!["picture","picture-card"].includes(this.listTypeValue)||!e.type.startsWith("image/")||e.size>10*1024*1024)}resolveRecord(e){if(!e)return null;if(e instanceof File){let t=this.buildFileRecord(e);return this.fileList.push(t),this.renderFileList(),t}return typeof e=="string"?this.fileList.find(t=>t.uid===e):e.uid?this.fileList.find(t=>t.uid===e.uid)||e:null}renderFileList(){if(!this.hasListTarget)return;this.listTarget.classList.toggle("hakumi-upload-list-empty",this.fileList.length===0),this.listTarget.querySelectorAll(".hakumi-upload-list-item:not(.hakumi-upload-list-item-trigger)").forEach(i=>i.remove());let t=this.listTarget.querySelector(".hakumi-upload-list-item-trigger");this.fileList.forEach(i=>{let s=document.createElement("li");s.className=`hakumi-upload-list-item hakumi-upload-list-item-${i.status||"done"}`,s.dataset.uid=i.uid;let a=document.createElement("div");if(a.className="hakumi-upload-list-item-info",["picture","picture-card"].includes(this.listTypeValue)&&i.url){let h=document.createElement("span");h.className="hakumi-upload-list-item-thumbnail";let u=document.createElement("img");u.src=i.url,u.alt=i.name,h.appendChild(u),a.appendChild(h)}let n=document.createElement("span");n.className="hakumi-upload-list-item-name",n.textContent=i.name,a.appendChild(n);let r=document.createElement("div");if(r.className="hakumi-upload-list-item-actions",this.listTypeValue==="picture-card"){if(i.url&&i.status==="done"){let u=document.createElement("button");u.type="button",u.className="hakumi-upload-list-item-action hakumi-upload-list-item-view",u.innerHTML='<svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"/></svg>',u.title="Preview",u.addEventListener("click",c=>{c.stopPropagation(),this.openPreview(i)}),r.appendChild(u)}let h=document.createElement("button");h.type="button",h.className="hakumi-upload-list-item-action hakumi-upload-list-item-remove",h.innerHTML='<svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"/></svg>',h.title="Remove",h.addEventListener("click",u=>{u.stopPropagation(),this.remove(i.uid)}),r.appendChild(h),a.appendChild(r)}else{let h=document.createElement("button");h.type="button",h.className="hakumi-upload-list-item-action hakumi-upload-list-item-remove",h.textContent="\xD7",h.title="Remove",h.addEventListener("click",u=>{u.stopPropagation(),this.remove(i.uid)}),r.appendChild(h),s.appendChild(r)}let o=document.createElement("div");o.className="hakumi-upload-list-item-progress",o.style.setProperty("--hakumi-upload-progress",`${i.percent||0}%`);let l=document.createElement("div");l.className="hakumi-upload-list-item-progress-bar",o.appendChild(l),s.appendChild(a),s.appendChild(o),t?this.listTarget.insertBefore(s,t):this.listTarget.appendChild(s)}),this.updateInlineTriggerVisibility()}updateInlineTriggerVisibility(){if(!this.hasInlineTriggerTarget)return;let e=this.hasMaxCountValue&&this.fileList.length>=this.maxCountValue;this.inlineTriggerTarget.classList.toggle("hakumi-upload-list-item-trigger-hidden",e)}dispatchChange(e){this.element.dispatchEvent(new CustomEvent("hakumi:upload:change",{bubbles:!0,detail:{file:e,fileList:this.getFileList()}}))}dispatchProgress(e,t){this.element.dispatchEvent(new CustomEvent("hakumi:upload:progress",{bubbles:!0,detail:{file:e?{...e}:null,fileList:this.getFileList(),event:t}}))}dispatchSuccess(e){this.element.dispatchEvent(new CustomEvent("hakumi:upload:success",{bubbles:!0,detail:{file:e?{...e}:null,fileList:this.getFileList()}})),window.HakumiComponents?.renderComponent&&e?.name&&window.HakumiComponents.renderComponent("message",{params:{id:"hakumi-upload-message",type:"success",message:`${e.name} uploaded successfully`,duration:3}})}dispatchError(e,t){if(this.element.dispatchEvent(new CustomEvent("hakumi:upload:error",{bubbles:!0,detail:{file:e?{...e}:null,fileList:this.getFileList(),error:t}})),window.HakumiComponents?.renderComponent){let i=t||e?.error||"Upload failed";window.HakumiComponents.renderComponent("message",{params:{id:"hakumi-upload-message",type:"error",message:e?.name?`${e.name}: ${i}`:i,duration:3}})}}ensureObject(e){if(!e)return null;if(typeof e=="object")return e;try{return JSON.parse(e)}catch{return null}}handleAvatarUpload(e){if(!this.hasAvatarTarget||!this.hasAvatarWrapperTarget)return;if(!this.validateFileType(e)){window.HakumiComponents?.renderComponent&&window.HakumiComponents.renderComponent("message",{params:{id:"hakumi-upload-avatar-message",type:"error",message:"Please upload an image file",duration:3}});return}if(this.hasMaxSizeValue&&e.size>this.maxSizeValue){window.HakumiComponents?.renderComponent&&window.HakumiComponents.renderComponent("message",{params:{id:"hakumi-upload-avatar-message",type:"error",message:"File exceeds max size",duration:3}});return}this.avatarWrapperTarget.classList.add("hakumi-upload-avatar-wrapper-loading");let t='<span class="anticon anticon-loading" style="animation: spin 1s linear infinite;"><svg viewBox="0 0 1024 1024" width="1em" height="1em" fill="currentColor"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span>';this.avatarTarget.innerHTML=t;let i=URL.createObjectURL(e),s=this.buildFileRecord(e);s.url=i,s.blobUrl=!0;let a=!this.actionValue||this.actionValue==="#",n=()=>{this.avatarWrapperTarget.classList.remove("hakumi-upload-avatar-wrapper-loading");let r=document.createElement("img");r.src=i,r.alt=e.name,r.style.cssText="width: 100%; height: 100%; object-fit: cover;",this.avatarTarget.innerHTML="",this.avatarTarget.appendChild(r),this.avatarTarget.classList.add("hakumi-avatar-image"),this.dispatchSuccess({...s,status:"done"})};a?setTimeout(n,1500):this.performAvatarUpload(s,n)}performAvatarUpload(e,t){let i=new XMLHttpRequest;this.withCredentialsValue&&(i.withCredentials=!0),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300){try{e.response=JSON.parse(i.response)}catch{e.response=i.response}t()}else this.avatarWrapperTarget?.classList.remove("hakumi-upload-avatar-wrapper-loading"),this.dispatchError(e,i.statusText||"Upload failed")}),i.addEventListener("error",()=>{this.avatarWrapperTarget?.classList.remove("hakumi-upload-avatar-wrapper-loading"),this.dispatchError(e,"Network error")}),i.open("POST",this.actionValue);let s=this.getCsrfToken();s&&i.setRequestHeader("X-CSRF-Token",s);let a=this.ensureObject(this.headersValue);a&&Object.entries(a).forEach(([o,l])=>{let h=o.toLowerCase();["cookie","host","origin","referer"].includes(h)||i.setRequestHeader(o,l)});let n=new FormData,r=this.ensureObject(this.dataValue);r&&Object.entries(r).forEach(([o,l])=>{n.append(o,l)}),n.append(this.nameValue||"file",e.raw),i.send(n)}getPreviewItems(){return this.fileList.filter(e=>e.status==="done"&&e.url).map(e=>({src:e.url,alt:e.name,uid:e.uid}))}openPreview(e){let t=this.resolveRecord(e);if(!t||!t.url)return;let i=this.getPreviewItems(),s=i.findIndex(a=>a.uid===t.uid);s!==-1&&this.#t(i,s)}#e={modal:null,items:[],currentIndex:0};#t(e,t){this.#n(),this.#e.items=e,this.#e.currentIndex=t;let i=document.createElement("div");i.className="hakumi-upload-preview-root",i.innerHTML=`
|
|
83
|
+
<div class="hakumi-upload-preview-mask"></div>
|
|
84
|
+
<div class="hakumi-upload-preview-wrap">
|
|
85
|
+
<div class="hakumi-upload-preview-body">
|
|
86
|
+
<img class="hakumi-upload-preview-img" src="" alt="" />
|
|
87
|
+
</div>
|
|
88
|
+
<div class="hakumi-upload-preview-operations">
|
|
89
|
+
<button type="button" class="hakumi-upload-preview-close" title="Close">
|
|
90
|
+
<svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"/></svg>
|
|
91
|
+
</button>
|
|
92
|
+
</div>
|
|
93
|
+
${e.length>1?`
|
|
94
|
+
<button type="button" class="hakumi-upload-preview-switch hakumi-upload-preview-switch-left" title="Previous">
|
|
95
|
+
<svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"/></svg>
|
|
96
|
+
</button>
|
|
97
|
+
<button type="button" class="hakumi-upload-preview-switch hakumi-upload-preview-switch-right" title="Next">
|
|
98
|
+
<svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V183c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"/></svg>
|
|
99
|
+
</button>
|
|
100
|
+
<div class="hakumi-upload-preview-counter">
|
|
101
|
+
<span class="hakumi-upload-preview-counter-current">${t+1}</span>
|
|
102
|
+
<span>/</span>
|
|
103
|
+
<span class="hakumi-upload-preview-counter-total">${e.length}</span>
|
|
104
|
+
</div>
|
|
105
|
+
`:""}
|
|
106
|
+
</div>
|
|
107
|
+
`,this.#e.modal=i,document.body.appendChild(i),document.body.style.overflow="hidden",this.#i(),i.querySelector(".hakumi-upload-preview-mask").addEventListener("click",()=>this.#n()),i.querySelector(".hakumi-upload-preview-close").addEventListener("click",()=>this.#n()),i.querySelector(".hakumi-upload-preview-switch-left")?.addEventListener("click",()=>this.#s()),i.querySelector(".hakumi-upload-preview-switch-right")?.addEventListener("click",()=>this.#a()),this._previewKeyHandler=s=>{s.key==="Escape"?this.#n():s.key==="ArrowLeft"?this.#s():s.key==="ArrowRight"&&this.#a()},document.addEventListener("keydown",this._previewKeyHandler),requestAnimationFrame(()=>{i.classList.add("hakumi-upload-preview-active")})}#i(){let{modal:e,items:t,currentIndex:i}=this.#e;if(!e)return;let s=t[i],a=e.querySelector(".hakumi-upload-preview-img");a.src=s.src,a.alt=s.alt||"";let n=e.querySelector(".hakumi-upload-preview-counter-current");n&&(n.textContent=i+1)}#s(){let{items:e,currentIndex:t}=this.#e;e.length<=1||(this.#e.currentIndex=(t-1+e.length)%e.length,this.#i())}#a(){let{items:e,currentIndex:t}=this.#e;e.length<=1||(this.#e.currentIndex=(t+1)%e.length,this.#i())}#n(){let{modal:e}=this.#e;e&&(e.classList.remove("hakumi-upload-preview-active"),this._previewKeyHandler&&(document.removeEventListener("keydown",this._previewKeyHandler),this._previewKeyHandler=null),setTimeout(()=>{e.remove(),this.#e.modal=null,document.body.style.overflow=""},300))}};var ms=class extends m{static values={default:{type:String,default:"light"},storageKey:{type:String,default:"theme"},syncSandbox:{type:Boolean,default:!0}};static targets=["sandboxFrame"];static mount(){se.ensureHost({id:"theme",controllerName:"hakumi--theme"})}setup(){window.__hakumiThemeActive&&window.__hakumiThemeActive!==this.element.id||(window.__hakumiThemeActive=this.element.id,this._mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this._handleSystemThemeChange=e=>{se.storage.get(this.storageKeyValue)||this.setTheme(e.matches?"dark":"light")},this._mediaQuery.addEventListener("change",this._handleSystemThemeChange),this.syncSandboxValue&&this.sandboxFrameTargets.forEach(e=>{e.addEventListener("load",this.handleSandboxLoad)}),this.setTheme(this.detectInitialTheme()))}teardown(){window.__hakumiThemeActive===this.element.id&&delete window.__hakumiThemeActive,this._mediaQuery&&this._handleSystemThemeChange&&this._mediaQuery.removeEventListener("change",this._handleSystemThemeChange),this.syncSandboxValue&&this.sandboxFrameTargets.forEach(e=>{e.removeEventListener("load",this.handleSandboxLoad)})}registerApi(){let e={get:()=>this.getTheme(),set:t=>this.setTheme(t),toggle:()=>this.toggle(),clearStored:()=>se.storage.remove(this.storageKeyValue),detect:()=>this.detectInitialTheme()};this.element.hakumiComponent={name:"theme",version:1,singleton:!0,api:e,apply:(t={})=>{t.theme&&this.setTheme(t.theme)}}}toggle(){let t=this.getTheme()==="dark"?"light":"dark";this.setTheme(t),se.storage.set(this.storageKeyValue,t)}getTheme(){return document.documentElement.getAttribute("data-theme")||this.defaultValue}setTheme(e){document.documentElement.setAttribute("data-theme",e),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{theme:e}})),this.syncSandboxValue&&this.syncSandboxFrames(e)}detectInitialTheme(){let e=se.storage.get(this.storageKeyValue);return e||(this._mediaQuery?.matches?"dark":this.defaultValue)}syncSandboxFrames(e){this._currentTheme=e,this.sandboxFrameTargets.forEach(t=>this.postThemeToFrame(t,e))}handleSandboxLoad=e=>{let t=e.currentTarget,i=this._currentTheme||this.getTheme();this.postThemeToFrame(t,i)};postThemeToFrame(e,t){e?.contentWindow&&e.contentWindow.postMessage({theme:t},"*")}};var fs=class extends m{static values={copiedText:String,errorText:String};setup(){}registerApi(){this.element.hakumiComponent={name:"typography",version:1,singleton:!1,api:{copy:e=>this.copy(e||new Event("click")),getCopiedText:()=>this.copiedTextValue,setCopiedText:e=>{this.copiedTextValue=e},setErrorText:e=>{this.errorTextValue=e}}}}async copy(e){let t=e.target?.closest(".hakumi-typography-copy");if(!t)return;e.preventDefault(),e.stopPropagation();let i=this.element.cloneNode(!0),s=i.querySelector(".hakumi-typography-copy");s&&s.remove();let a=i.textContent.trim();try{await navigator.clipboard.writeText(a),this.showSuccessTooltip(t)}catch(n){console.error("[HakumiComponents] Failed to copy text: ",n),this.showErrorTooltip(t)}}showSuccessTooltip(e){let t=document.createElement("div");t.className="hakumi-typography-tooltip hakumi-typography-tooltip-success",t.textContent=this.copiedTextValue;let i=e.getBoundingClientRect();t.style.position="fixed",t.style.top=`${i.top-35}px`,t.style.left=`${i.left+i.width/2}px`,t.style.transform="translateX(-50%)",document.body.appendChild(t),setTimeout(()=>t.classList.add("hakumi-typography-tooltip-visible"),10),setTimeout(()=>{t.classList.remove("hakumi-typography-tooltip-visible"),setTimeout(()=>t.remove(),300)},1e3)}showErrorTooltip(e){let t=document.createElement("div");t.className="hakumi-typography-tooltip hakumi-typography-tooltip-error",t.textContent=this.errorTextValue;let i=e.getBoundingClientRect();t.style.position="fixed",t.style.top=`${i.top-35}px`,t.style.left=`${i.left+i.width/2}px`,t.style.transform="translateX(-50%)",document.body.appendChild(t),setTimeout(()=>t.classList.add("hakumi-typography-tooltip-visible"),10),setTimeout(()=>{t.classList.remove("hakumi-typography-tooltip-visible"),setTimeout(()=>t.remove(),300)},1e3)}};var ka={"hakumi--admin-panel":Ht,"hakumi--affix":Bt,"hakumi--anchor":Rt,"hakumi--back-top":Nt,"hakumi--splitter":Ft,"hakumi--alert":$t,"hakumi--drawer":Kt,"hakumi--message":zt,"hakumi--modal":qt,"hakumi--modal-trigger":Ut,"hakumi--notification":Yt,"hakumi--popconfirm":jt,"hakumi--popover":Xt,"hakumi--progress":Gt,"hakumi--spin":Jt,"hakumi--tooltip":Qt,"hakumi--tour":Zt,"hakumi--avatar-text":ei,"hakumi--calendar":ti,"hakumi--carousel":ii,"hakumi--collapse":si,"hakumi--image":ai,"hakumi--qr-code":gi,"hakumi--segmented":vi,"hakumi--statistic":yi,"hakumi--table":Oi,"hakumi--tabs":Pi,"hakumi--tag":Hi,"hakumi--tag-group":Bi,"hakumi--timeline":Ri,"hakumi--tree":Ni,"hakumi--button":Fi,"hakumi--dropdown":$i,"hakumi--float-button-group":Ki,"hakumi--menu":zi,"hakumi--pagination":qi,"hakumi--steps":Ui,"hakumi--autocomplete":Wi,"hakumi--cascader":Yi,"hakumi--checkbox":ji,"hakumi--checkbox-group":Xi,"hakumi--color-picker":Gi,"hakumi--date-picker":Ji,"hakumi--form-item":Zi,"hakumi--input":es,"hakumi--input-number":ts,"hakumi--input-password":is,"hakumi--input-textarea":ss,"hakumi--mentions":as,"hakumi--radio":ns,"hakumi--rate":rs,"hakumi--select":os,"hakumi--slider":ls,"hakumi--switch":hs,"hakumi--time-picker":us,"hakumi--transfer":cs,"hakumi--tree-select":ds,"hakumi--upload":ps,"hakumi--theme":ms,"hakumi--typography":fs};var ur={renderComponent:Aa,register:je,unregister:Xe,get:Ge,list:Va,ensureId:me,ensureOverlayContainer:Re,DateHelper:L};typeof window<"u"&&(window.HakumiComponents=ur,Re());var Op=e=>{if(!e)throw new Error("[HakumiComponents] Missing Stimulus application");for(let t of Object.values(ka))if(typeof t.mount=="function")try{t.mount()}catch(i){console.error("[HakumiComponents] mount() failed",i)}Object.entries(ka).forEach(([t,i])=>{e.register(t,i)})},Pp=ur;export{L as DateHelper,ur as HakumiComponents,se as Persistence,m as RegistryController,Pp as default,me as ensureId,Re as ensureOverlayContainer,Ge as get,Va as list,je as register,Op as registerHakumiControllers,Aa as renderComponent,Xe as unregister};
|
|
108
|
+
/*! Bundled license information:
|
|
109
|
+
|
|
110
|
+
sortablejs/modular/sortable.esm.js:
|
|
111
|
+
(**!
|
|
112
|
+
* Sortable 1.15.6
|
|
113
|
+
* @author RubaXa <trash@rubaxa.org>
|
|
114
|
+
* @author owenm <owen23355@gmail.com>
|
|
115
|
+
* @license MIT
|
|
116
|
+
*)
|
|
117
|
+
*/
|