@darkchest/wck 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,444 @@
1
+ (function(){"use strict";var ne=Object.defineProperty,ie=(t,e,o)=>e in t?ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,O=(t,e,o)=>(ie(t,typeof e!="symbol"?e+"":e,o),o);function se(t,e){const o=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)o[n[i]]=!0;return i=>!!o[i]}function ft(t){if(g(t)){const e={};for(let o=0;o<t.length;o++){const n=t[o],i=R(n)?ce(n):ft(n);if(i)for(const s in i)e[s]=i[s]}return e}else if(R(t)||k(t))return t}const re=/;(?![^(]*\))/g,le=/:(.+)/;function ce(t){const e={};return t.split(re).forEach(o=>{if(o){const n=o.split(le);n.length>1&&(e[n[0].trim()]=n[1].trim())}}),e}function ht(t){let e="";if(R(t))e=t;else if(g(t))for(let o=0;o<t.length;o++){const n=ht(t[o]);n&&(e+=n+" ")}else if(k(t))for(const o in t)t[o]&&(e+=o+" ");return e.trim()}function ae(t,e){if(t.length!==e.length)return!1;let o=!0;for(let n=0;o&&n<t.length;n++)o=I(t[n],e[n]);return o}function I(t,e){if(t===e)return!0;let o=gt(t),n=gt(e);if(o||n)return o&&n?t.getTime()===e.getTime():!1;if(o=g(t),n=g(e),o||n)return o&&n?ae(t,e):!1;if(o=k(t),n=k(e),o||n){if(!o||!n)return!1;const i=Object.keys(t).length,s=Object.keys(e).length;if(i!==s)return!1;for(const r in t){const l=t.hasOwnProperty(r),a=e.hasOwnProperty(r);if(l&&!a||!l&&a||!I(t[r],e[r]))return!1}}return String(t)===String(e)}function q(t,e){return t.findIndex(o=>I(o,e))}const de=Object.assign,pe=(t,e)=>{const o=t.indexOf(e);o>-1&&t.splice(o,1)},ue=Object.prototype.hasOwnProperty,Z=(t,e)=>ue.call(t,e),g=Array.isArray,G=t=>mt(t)==="[object Map]",gt=t=>t instanceof Date,R=t=>typeof t=="string",U=t=>typeof t=="symbol",k=t=>t!==null&&typeof t=="object",fe=Object.prototype.toString,mt=t=>fe.call(t),he=t=>mt(t).slice(8,-1),Y=t=>R(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,bt=t=>{const e=Object.create(null);return o=>e[o]||(e[o]=t(o))},ge=/-(\w)/g,me=bt(t=>t.replace(ge,(e,o)=>o?o.toUpperCase():"")),be=/\B([A-Z])/g,vt=bt(t=>t.replace(be,"-$1").toLowerCase()),ve=(t,e)=>!Object.is(t,e),xt=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let xe;function yt(t,e){e=e||xe,e&&e.active&&e.effects.push(t)}const _t=t=>{const e=new Set(t);return e.w=0,e.n=0,e},wt=t=>(t.w&T)>0,kt=t=>(t.n&T)>0,ye=({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=T},_e=t=>{const{deps:e}=t;if(e.length){let o=0;for(let n=0;n<e.length;n++){const i=e[n];wt(i)&&!kt(i)?i.delete(t):e[o++]=i,i.w&=~T,i.n&=~T}e.length=o}},Q=new WeakMap;let M=0,T=1;const X=30,z=[];let A;const V=Symbol(""),Tt=Symbol("");class we{constructor(e,o=null,n){this.fn=e,this.scheduler=o,this.active=!0,this.deps=[],yt(this,n)}run(){if(!this.active)return this.fn();if(!z.includes(this))try{return z.push(A=this),Ee(),T=1<<++M,M<=X?ye(this):$t(this),this.fn()}finally{M<=X&&_e(this),T=1<<--M,Et(),z.pop();const e=z.length;A=e>0?z[e-1]:void 0}}stop(){this.active&&($t(this),this.onStop&&this.onStop(),this.active=!1)}}function $t(t){const{deps:e}=t;if(e.length){for(let o=0;o<e.length;o++)e[o].delete(t);e.length=0}}function ke(t,e){t.effect&&(t=t.effect.fn);const o=new we(t);e&&(de(o,e),e.scope&&yt(o,e.scope)),(!e||!e.lazy)&&o.run();const n=o.run.bind(o);return n.effect=o,n}function Te(t){t.effect.stop()}let N=!0;const tt=[];function $e(){tt.push(N),N=!1}function Ee(){tt.push(N),N=!0}function Et(){const t=tt.pop();N=t===void 0?!0:t}function W(t,e,o){if(!Se())return;let n=Q.get(t);n||Q.set(t,n=new Map);let i=n.get(o);i||n.set(o,i=_t()),Ce(i)}function Se(){return N&&A!==void 0}function Ce(t,e){let o=!1;M<=X?kt(t)||(t.n|=T,o=!wt(t)):o=!t.has(A),o&&(t.add(A),A.deps.push(t))}function et(t,e,o,n,i,s){const r=Q.get(t);if(!r)return;let l=[];if(e==="clear")l=[...r.values()];else if(o==="length"&&g(t))r.forEach((a,c)=>{(c==="length"||c>=n)&&l.push(a)});else switch(o!==void 0&&l.push(r.get(o)),e){case"add":g(t)?Y(o)&&l.push(r.get("length")):(l.push(r.get(V)),G(t)&&l.push(r.get(Tt)));break;case"delete":g(t)||(l.push(r.get(V)),G(t)&&l.push(r.get(Tt)));break;case"set":G(t)&&l.push(r.get(V));break}if(l.length===1)l[0]&&St(l[0]);else{const a=[];for(const c of l)c&&a.push(...c);St(_t(a))}}function St(t,e){for(const o of g(t)?t:[...t])(o!==A||o.allowRecurse)&&(o.scheduler?o.scheduler():o.run())}const Oe=se("__proto__,__v_isRef,__isVue"),Ct=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(U)),Ae=At(),Le=At(!0),Ot=je();function je(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...o){const n=L(this);for(let s=0,r=this.length;s<r;s++)W(n,"get",s+"");const i=n[e](...o);return i===-1||i===!1?n[e](...o.map(L)):i}}),["push","pop","shift","unshift","splice"].forEach(e=>{t[e]=function(...o){$e();const n=L(this)[e].apply(this,o);return Et(),n}}),t}function At(t=!1,e=!1){return function(o,n,i){if(n==="__v_isReactive")return!t;if(n==="__v_isReadonly")return t;if(n==="__v_raw"&&i===(t?e?He:jt:e?Be:Lt).get(o))return o;const s=g(o);if(!t&&s&&Z(Ot,n))return Reflect.get(Ot,n,i);const r=Reflect.get(o,n,i);return(U(n)?Ct.has(n):Oe(n))||(t||W(o,"get",n),e)?r:ot(r)?!s||!Y(n)?r.value:r:k(r)?t?Fe(r):B(r):r}}const Pe=Ie();function Ie(t=!1){return function(e,o,n,i){let s=e[o];if(!t&&!Ke(n)&&(n=L(n),s=L(s),!g(e)&&ot(s)&&!ot(n)))return s.value=n,!0;const r=g(e)&&Y(o)?Number(o)<e.length:Z(e,o),l=Reflect.set(e,o,n,i);return e===L(i)&&(r?ve(n,s)&&et(e,"set",o,n):et(e,"add",o,n)),l}}function Re(t,e){const o=Z(t,e);t[e];const n=Reflect.deleteProperty(t,e);return n&&o&&et(t,"delete",e,void 0),n}function Ne(t,e){const o=Reflect.has(t,e);return(!U(e)||!Ct.has(e))&&W(t,"has",e),o}function De(t){return W(t,"iterate",g(t)?"length":V),Reflect.ownKeys(t)}const Me={get:Ae,set:Pe,deleteProperty:Re,has:Ne,ownKeys:De},ze={get:Le,set(t,e){return!0},deleteProperty(t,e){return!0}},Lt=new WeakMap,Be=new WeakMap,jt=new WeakMap,He=new WeakMap;function Ve(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function We(t){return t.__v_skip||!Object.isExtensible(t)?0:Ve(he(t))}function B(t){return t&&t.__v_isReadonly?t:Pt(t,!1,Me,null,Lt)}function Fe(t){return Pt(t,!0,ze,null,jt)}function Pt(t,e,o,n,i){if(!k(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=i.get(t);if(s)return s;const r=We(t);if(r===0)return t;const l=new Proxy(t,r===2?n:o);return i.set(t,l),l}function Ke(t){return!!(t&&t.__v_isReadonly)}function L(t){const e=t&&t.__v_raw;return e?L(e):t}function ot(t){return!!(t&&t.__v_isRef===!0)}Promise.resolve();let nt=!1;const F=[],Je=Promise.resolve(),K=t=>Je.then(t),It=t=>{F.includes(t)||F.push(t),nt||(nt=!0,K(qe))},qe=()=>{for(const t of F)t();F.length=0,nt=!1},Ze=/^(spellcheck|draggable|form|list|type)$/,it=({el:t,get:e,effect:o,arg:n,modifiers:i})=>{let s;n==="class"&&(t._class=t.className),o(()=>{let r=e();if(n)i?.camel&&(n=me(n)),st(t,n,r,s);else{for(const l in r)st(t,l,r[l],s&&s[l]);for(const l in s)(!r||!(l in r))&&st(t,l,null)}s=r})},st=(t,e,o,n)=>{if(e==="class")t.setAttribute("class",ht(t._class?[t._class,o]:o)||"");else if(e==="style"){o=ft(o);const{style:i}=t;if(!o)t.removeAttribute("style");else if(R(o))o!==n&&(i.cssText=o);else{for(const s in o)rt(i,s,o[s]);if(n&&!R(n))for(const s in n)o[s]==null&&rt(i,s,"")}}else!(t instanceof SVGElement)&&e in t&&!Ze.test(e)?(t[e]=o,e==="value"&&(t._value=o)):e==="true-value"?t._trueValue=o:e==="false-value"?t._falseValue=o:o!=null?t.setAttribute(e,o):t.removeAttribute(e)},Rt=/\s*!important$/,rt=(t,e,o)=>{g(o)?o.forEach(n=>rt(t,e,n)):e.startsWith("--")?t.setProperty(e,o):Rt.test(o)?t.setProperty(vt(e),o.replace(Rt,""),"important"):t[e]=o},$=(t,e)=>{const o=t.getAttribute(e);return o!=null&&t.removeAttribute(e),o},E=(t,e,o,n)=>{t.addEventListener(e,o,n)},Ge=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ue=["ctrl","shift","alt","meta"],Ye={stop:t=>t.stopPropagation(),prevent:t=>t.preventDefault(),self:t=>t.target!==t.currentTarget,ctrl:t=>!t.ctrlKey,shift:t=>!t.shiftKey,alt:t=>!t.altKey,meta:t=>!t.metaKey,left:t=>"button"in t&&t.button!==0,middle:t=>"button"in t&&t.button!==1,right:t=>"button"in t&&t.button!==2,exact:(t,e)=>Ue.some(o=>t[`${o}Key`]&&!e[o])},Nt=({el:t,get:e,exp:o,arg:n,modifiers:i})=>{if(!n)return;let s=Ge.test(o)?e(`(e => ${o}(e))`):e(`($event => { ${o} })`);if(n==="vue:mounted"){K(s);return}else if(n==="vue:unmounted")return()=>s();if(i){n==="click"&&(i.right&&(n="contextmenu"),i.middle&&(n="mouseup"));const r=s;s=l=>{if(!("key"in l&&!(vt(l.key)in i))){for(const a in i){const c=Ye[a];if(c&&c(l,i))return}return r(l)}}}E(t,n,s,i)},Qe=({el:t,get:e,effect:o})=>{const n=t.style.display;o(()=>{t.style.display=e()?n:"none"})},Dt=({el:t,get:e,effect:o})=>{o(()=>{t.textContent=Mt(e())})},Mt=t=>t==null?"":k(t)?JSON.stringify(t,null,2):String(t),Xe=({el:t,get:e,effect:o})=>{o(()=>{t.innerHTML=e()})},to=({el:t,exp:e,get:o,effect:n,modifiers:i})=>{const s=t.type,r=o(`(val) => { ${e} = val }`),{trim:l,number:a=s==="number"}=i||{};if(t.tagName==="SELECT"){const c=t;E(t,"change",()=>{const d=Array.prototype.filter.call(c.options,p=>p.selected).map(p=>a?xt(S(p)):S(p));r(c.multiple?d:d[0])}),n(()=>{const d=o(),p=c.multiple;for(let u=0,x=c.options.length;u<x;u++){const v=c.options[u],y=S(v);if(p)g(d)?v.selected=q(d,y)>-1:v.selected=d.has(y);else if(I(S(v),d)){c.selectedIndex!==u&&(c.selectedIndex=u);return}}!p&&c.selectedIndex!==-1&&(c.selectedIndex=-1)})}else if(s==="checkbox"){E(t,"change",()=>{const d=o(),p=t.checked;if(g(d)){const u=S(t),x=q(d,u),v=x!==-1;if(p&&!v)r(d.concat(u));else if(!p&&v){const y=[...d];y.splice(x,1),r(y)}}else r(zt(t,p))});let c;n(()=>{const d=o();g(d)?t.checked=q(d,S(t))>-1:d!==c&&(t.checked=I(d,zt(t,!0))),c=d})}else if(s==="radio"){E(t,"change",()=>{r(S(t))});let c;n(()=>{const d=o();d!==c&&(t.checked=I(d,S(t)))})}else{const c=d=>l?d.trim():a?xt(d):d;E(t,"compositionstart",eo),E(t,"compositionend",oo),E(t,i?.lazy?"change":"input",()=>{t.composing||r(c(t.value))}),l&&E(t,"change",()=>{t.value=t.value.trim()}),n(()=>{if(t.composing)return;const d=t.value,p=o();document.activeElement===t&&c(d)===p||d!==p&&(t.value=p)})}},S=t=>"_value"in t?t._value:t.value,zt=(t,e)=>{const o=e?"_trueValue":"_falseValue";return o in t?t[o]:e},eo=t=>{t.target.composing=!0},oo=t=>{const e=t.target;e.composing&&(e.composing=!1,no(e,"input"))},no=(t,e)=>{const o=document.createEvent("HTMLEvents");o.initEvent(e,!0,!0),t.dispatchEvent(o)},Bt=Object.create(null),H=(t,e,o)=>Ht(t,`return(${e})`,o),Ht=(t,e,o)=>{const n=Bt[e]||(Bt[e]=io(e));try{return n(t,o)}catch(i){console.error(i)}},io=t=>{try{return new Function("$data","$el",`with($data){${t}}`)}catch(e){return console.error(`${e.message} in expression: ${t}`),()=>{}}},so=({el:t,ctx:e,exp:o,effect:n})=>{K(()=>n(()=>Ht(e.scope,o,t)))},ro={bind:it,on:Nt,show:Qe,text:Dt,html:Xe,model:to,effect:so},lo=(t,e,o)=>{const n=t.parentElement,i=new Comment("v-if");n.insertBefore(i,t);const s=[{exp:e,el:t}];let r,l;for(;(r=t.nextElementSibling)&&(l=null,$(r,"v-else")===""||(l=$(r,"v-else-if")));)n.removeChild(r),s.push({exp:l,el:r});const a=t.nextSibling;n.removeChild(t);let c,d=-1;const p=()=>{c&&(n.insertBefore(i,c.el),c.remove(),c=void 0)};return o.effect(()=>{for(let u=0;u<s.length;u++){const{exp:x,el:v}=s[u];if(!x||H(o.scope,x)){u!==d&&(p(),c=new at(v,o),c.insert(n,i),n.removeChild(i),d=u);return}}d=-1,p()}),a},co=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,Vt=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,ao=/^\(|\)$/g,po=/^[{[]\s*((?:[\w_$]+\s*,?\s*)+)[\]}]$/,uo=(t,e,o)=>{const n=e.match(co);if(!n)return;const i=t.nextSibling,s=t.parentElement,r=new Text("");s.insertBefore(r,t),s.removeChild(t);const l=n[2].trim();let a=n[1].trim().replace(ao,"").trim(),c,d=!1,p,u,x="key",v=t.getAttribute(x)||t.getAttribute(x=":key")||t.getAttribute(x="v-bind:key");v&&(t.removeAttribute(x),x==="key"&&(v=JSON.stringify(v)));let y;(y=a.match(Vt))&&(a=a.replace(Vt,"").trim(),p=y[1].trim(),y[2]&&(u=y[2].trim())),(y=a.match(po))&&(c=y[1].split(",").map(m=>m.trim()),d=a[0]==="[");let ee=!1,j,J,pt;const bo=m=>{const _=new Map,f=[];if(g(m))for(let h=0;h<m.length;h++)f.push(ut(_,m[h],h));else if(typeof m=="number")for(let h=0;h<m;h++)f.push(ut(_,h+1,h));else if(k(m)){let h=0;for(const b in m)f.push(ut(_,m[b],h++,b))}return[f,_]},ut=(m,_,f,h)=>{const b={};c?c.forEach((P,C)=>b[P]=_[d?C:P]):b[a]=_,h?(p&&(b[p]=h),u&&(b[u]=f)):p&&(b[p]=f);const D=Zt(o,b),w=v?H(D.scope,v):f;return m.set(w,f),D.key=w,D},oe=(m,_)=>{const f=new at(t,m);return f.key=m.key,f.insert(s,_),f};return o.effect(()=>{const m=H(o.scope,l),_=pt;if([J,pt]=bo(m),!ee)j=J.map(f=>oe(f,r)),ee=!0;else{for(let w=0;w<j.length;w++)pt.has(j[w].key)||j[w].remove();const f=[];let h=J.length,b,D;for(;h--;){const w=J[h],P=_.get(w.key);let C;P==null?C=oe(w,b?b.el:r):(C=j[P],Object.assign(C.ctx.scope,w.scope),P!==h&&(j[P+1]!==b||D===b)&&(D=C,C.insert(s,b?b.el:r))),f.unshift(b=C)}j=f}}),i},Wt=({el:t,ctx:{scope:{$refs:e}},get:o,effect:n})=>{let i;return n(()=>{const s=o();e[s]=t,i&&s!==i&&delete e[i],i=s}),()=>{i&&delete e[i]}},fo=/^(?:v-|:|@)/,ho=/\.([\w-]+)/g;let lt=!1;const Ft=(t,e)=>{const o=t.nodeType;if(o===1){const n=t;if(n.hasAttribute("v-pre"))return;$(n,"v-cloak");let i;if(i=$(n,"v-if"))return lo(n,i,e);if(i=$(n,"v-for"))return uo(n,i,e);if((i=$(n,"v-scope"))||i===""){const l=i?H(e.scope,i):{};e=Zt(e,l),l.$template&&go(n,l.$template)}const s=$(n,"v-once")!=null;s&&(lt=!0),(i=$(n,"ref"))&&ct(n,Wt,`"${i}"`,e),Kt(n,e);const r=[];for(const{name:l,value:a}of[...n.attributes])fo.test(l)&&l!=="v-cloak"&&(l==="v-model"?r.unshift([l,a]):l[0]==="@"||/^v-on\b/.test(l)?r.push([l,a]):Jt(n,l,a,e));for(const[l,a]of r)Jt(n,l,a,e);s&&(lt=!1)}else if(o===3){const n=t.data;if(n.includes(e.delimiters[0])){let i=[],s=0,r;for(;r=e.delimitersRE.exec(n);){const l=n.slice(s,r.index);l&&i.push(JSON.stringify(l)),i.push(`$s(${r[1]})`),s=r.index+r[0].length}s<n.length&&i.push(JSON.stringify(n.slice(s))),ct(t,Dt,i.join("+"),e)}}else o===11&&Kt(t,e)},Kt=(t,e)=>{let o=t.firstChild;for(;o;)o=Ft(o,e)||o.nextSibling},Jt=(t,e,o,n)=>{let i,s,r;if(e=e.replace(ho,(l,a)=>((r||(r={}))[a]=!0,"")),e[0]===":")i=it,s=e.slice(1);else if(e[0]==="@")i=Nt,s=e.slice(1);else{const l=e.indexOf(":"),a=l>0?e.slice(2,l):e.slice(2);i=ro[a]||n.dirs[a],s=l>0?e.slice(l+1):void 0}i&&(i===it&&s==="ref"&&(i=Wt),ct(t,i,o,n,s,r),t.removeAttribute(e))},ct=(t,e,o,n,i,s)=>{const r=e({el:t,get:(l=o)=>H(n.scope,l,t),effect:n.effect,ctx:n,exp:o,arg:i,modifiers:s});r&&n.cleanups.push(r)},go=(t,e)=>{if(e[0]==="#"){const o=document.querySelector(e);t.appendChild(o.content.cloneNode(!0));return}t.innerHTML=e},qt=t=>{const e={delimiters:["{{","}}"],delimitersRE:/\{\{([^]+?)\}\}/g,...t,scope:t?t.scope:B({}),dirs:t?t.dirs:{},effects:[],blocks:[],cleanups:[],effect:o=>{if(lt)return It(o),o;const n=ke(o,{scheduler:()=>It(n)});return e.effects.push(n),n}};return e},Zt=(t,e={})=>{const o=t.scope,n=Object.create(o);Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)),n.$refs=Object.create(o.$refs);const i=B(new Proxy(n,{set(s,r,l,a){return a===i&&!s.hasOwnProperty(r)?Reflect.set(o,r,l):Reflect.set(s,r,l,a)}}));return Gt(i),{...t,scope:i}},Gt=t=>{for(const e of Object.keys(t))typeof t[e]=="function"&&(t[e]=t[e].bind(t))};class at{constructor(e,o,n=!1){O(this,"template"),O(this,"ctx"),O(this,"key"),O(this,"parentCtx"),O(this,"isFragment"),O(this,"start"),O(this,"end"),this.isFragment=e instanceof HTMLTemplateElement,n?this.template=e:this.isFragment?this.template=e.content.cloneNode(!0):this.template=e.cloneNode(!0),n?this.ctx=o:(this.parentCtx=o,o.blocks.push(this),this.ctx=qt(o)),Ft(this.template,this.ctx)}get el(){return this.start||this.template}insert(e,o=null){if(this.isFragment)if(this.start){let n=this.start,i;for(;n&&(i=n.nextSibling,e.insertBefore(n,o),n!==this.end);)n=i}else this.start=new Text(""),this.end=new Text(""),e.insertBefore(this.end,o),e.insertBefore(this.start,this.end),e.insertBefore(this.template,this.end);else e.insertBefore(this.template,o)}remove(){if(this.parentCtx&&pe(this.parentCtx.blocks,this),this.start){const e=this.start.parentNode;let o=this.start,n;for(;o&&(n=o.nextSibling,e.removeChild(o),o!==this.end);)o=n}else this.template.parentNode.removeChild(this.template);this.teardown()}teardown(){this.ctx.blocks.forEach(e=>{e.teardown()}),this.ctx.effects.forEach(Te),this.ctx.cleanups.forEach(e=>e())}}const Ut=t=>t.replace(/[-.*+?^${}()|[\]\/\\]/g,"\\$&"),Yt=t=>{const e=qt();if(t&&(e.scope=B(t),Gt(e.scope),t.$delimiters)){const[n,i]=e.delimiters=t.$delimiters;e.delimitersRE=new RegExp(Ut(n)+"([^]+?)"+Ut(i),"g")}e.scope.$s=Mt,e.scope.$nextTick=K,e.scope.$refs=Object.create(null);let o;return{directive(n,i){return i?(e.dirs[n]=i,this):e.dirs[n]},mount(n){if(typeof n=="string"&&(n=document.querySelector(n),!n))return;n=n||document.documentElement;let i;return n.hasAttribute("v-scope")?i=[n]:i=[...n.querySelectorAll("[v-scope]")].filter(s=>!s.matches("[v-scope] [v-scope]")),i.length||(i=[n]),o=i.map(s=>new at(s,e,!0)),this},unmount(){o.forEach(n=>n.teardown())}}},Qt=document.currentScript;Qt&&Qt.hasAttribute("init")&&Yt().mount();const Xt=function(t){return!t||!t.tagName?!1:[()=>t.tagName.includes("-"),()=>!!t.shadowRoot,()=>{try{return customElements.get(t.tagName.toLowerCase())!==void 0}catch{return!1}},()=>["__isDarkchest","__componentId"].some(n=>n in t)].some(o=>o())},dt="[@DARKCHEST/LIT]",te={log:(...t)=>console.log(`${dt} `,...t),warn:(...t)=>console.warn(`${dt} `,...t),error:(...t)=>console.error(`${dt} `,...t)};class mo extends HTMLElement{static observedAttributes=["initialtodos","apptitle","enablelocalstorage","initial-todos","app-title","enable-local-storage"];constructor(){super(),this._isDarkchest=!0,this._componentId=Math.random().toString(36).substring(2),this._types={initialTodos:{type:["Array","Object"],attr:"initialTodos"},initialtodos:{type:["Array","Object"],attr:"initialTodos"},"initial-todos":{type:["Array","Object"],attr:"initialTodos"},appTitle:{type:["String"],attr:"appTitle"},apptitle:{type:["String"],attr:"appTitle"},"app-title":{type:["String"],attr:"appTitle"},enableLocalStorage:{type:["Boolean"],attr:"enableLocalStorage"},enablelocalstorage:{type:["Boolean"],attr:"enableLocalStorage"},"enable-local-storage":{type:["Boolean"],attr:"enableLocalStorage"}},this._watchers={},this._listeners=[],this._el=null,this._parent=null,this._children=[],this._eventPrefix="@",this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=`
2
+ *, *::before, *::after {
3
+ padding: 0;
4
+ margin: 0;
5
+ box-sizing: border-box;
6
+ }
7
+ #app {
8
+ font-family: "Avenir", Helvetica, Arial, sans-serif;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ color: #2c3e50;
12
+ max-width: 800px;
13
+ margin: 0 auto;
14
+ padding: 20px;
15
+ }
16
+
17
+ .todo-container {
18
+ background: white;
19
+ border-radius: 10px;
20
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
21
+ padding: 30px;
22
+ }
23
+
24
+ header {
25
+ text-align: center;
26
+ margin-bottom: 30px;
27
+ border-bottom: 1px solid #eee;
28
+ padding-bottom: 20px;
29
+ }
30
+
31
+ .app-title {
32
+ color: #42b983;
33
+ font-size: 2.5rem;
34
+ margin-bottom: 10px;
35
+ }
36
+
37
+ .app-description {
38
+ color: #7f8c8d;
39
+ font-size: 1rem;
40
+ }
41
+
42
+ .add-todo {
43
+ display: flex;
44
+ gap: 10px;
45
+ margin-bottom: 20px;
46
+ }
47
+
48
+ .todo-input {
49
+ flex: 1;
50
+ padding: 12px 15px;
51
+ border: 2px solid #e0e0e0;
52
+ border-radius: 6px;
53
+ font-size: 16px;
54
+ transition: border-color 0.3s;
55
+ }
56
+
57
+ .todo-input:focus {
58
+ border-color: #42b983;
59
+ outline: none;
60
+ }
61
+
62
+ .add-btn, .clear-btn {
63
+ padding: 12px 20px;
64
+ border: none;
65
+ border-radius: 6px;
66
+ font-weight: bold;
67
+ cursor: pointer;
68
+ transition: all 0.3s;
69
+ }
70
+
71
+ .add-btn {
72
+ background-color: #42b983;
73
+ color: white;
74
+ }
75
+
76
+ .add-btn:hover {
77
+ background-color: #3aa876;
78
+ }
79
+
80
+ .clear-btn {
81
+ background-color: #f0f0f0;
82
+ color: #333;
83
+ }
84
+
85
+ .clear-btn:hover {
86
+ background-color: #e0e0e0;
87
+ }
88
+
89
+ .filter-controls {
90
+ display: flex;
91
+ gap: 10px;
92
+ margin-bottom: 25px;
93
+ }
94
+
95
+ .filter-btn {
96
+ flex: 1;
97
+ padding: 10px;
98
+ background-color: #f8f9fa;
99
+ border: 1px solid #dee2e6;
100
+ border-radius: 6px;
101
+ cursor: pointer;
102
+ transition: all 0.3s;
103
+ }
104
+
105
+ .filter-btn.active {
106
+ background-color: #42b983;
107
+ color: white;
108
+ border-color: #42b983;
109
+ }
110
+
111
+ .filter-btn:hover:not(.active) {
112
+ background-color: #e9ecef;
113
+ }
114
+
115
+ .todo-list {
116
+ margin-bottom: 25px;
117
+ }
118
+
119
+ .empty-state {
120
+ text-align: center;
121
+ padding: 40px 20px;
122
+ color: #95a5a6;
123
+ font-style: italic;
124
+ }
125
+
126
+ .todo-item {
127
+ display: flex;
128
+ justify-content: space-between;
129
+ align-items: center;
130
+ padding: 15px;
131
+ border-bottom: 1px solid #f0f0f0;
132
+ transition: all 0.3s;
133
+ border-radius: 6px;
134
+ margin-bottom: 8px;
135
+ background-color: #f9f9f9;
136
+ }
137
+
138
+ .todo-item:hover {
139
+ background-color: #f0f0f0;
140
+ transform: translateY(-2px);
141
+ }
142
+
143
+ .todo-item.completed {
144
+ opacity: 0.8;
145
+ background-color: #f0f9f0;
146
+ }
147
+
148
+ .todo-content {
149
+ display: flex;
150
+ align-items: center;
151
+ gap: 15px;
152
+ flex: 1;
153
+ }
154
+
155
+ .todo-checkbox {
156
+ width: 20px;
157
+ height: 20px;
158
+ cursor: pointer;
159
+ }
160
+
161
+ .todo-text {
162
+ flex: 1;
163
+ cursor: pointer;
164
+ display: flex;
165
+ justify-content: space-between;
166
+ align-items: center;
167
+ }
168
+
169
+ .todo-item.completed .todo-text span:first-child {
170
+ text-decoration: line-through;
171
+ color: #95a5a6;
172
+ }
173
+
174
+ .todo-date {
175
+ font-size: 0.8rem;
176
+ color: #95a5a6;
177
+ }
178
+
179
+ .todo-actions {
180
+ display: flex;
181
+ gap: 8px;
182
+ }
183
+
184
+ .edit-btn, .delete-btn {
185
+ padding: 6px 12px;
186
+ border: none;
187
+ border-radius: 4px;
188
+ font-size: 0.9rem;
189
+ cursor: pointer;
190
+ transition: all 0.2s;
191
+ }
192
+
193
+ .edit-btn {
194
+ background-color: #f0f0f0;
195
+ color: #333;
196
+ }
197
+
198
+ .edit-btn:hover {
199
+ background-color: #e0e0e0;
200
+ }
201
+
202
+ .delete-btn {
203
+ background-color: #ff6b6b;
204
+ color: white;
205
+ }
206
+
207
+ .delete-btn:hover {
208
+ background-color: #ff5252;
209
+ }
210
+
211
+ .stats {
212
+ margin-top: 25px;
213
+ padding-top: 20px;
214
+ border-top: 1px solid #eee;
215
+ color: #7f8c8d;
216
+ }
217
+
218
+ .completion-rate {
219
+ color: #42b983;
220
+ font-weight: bold;
221
+ }
222
+
223
+ .progress-container {
224
+ height: 10px;
225
+ background-color: #f0f0f0;
226
+ border-radius: 5px;
227
+ margin-top: 10px;
228
+ overflow: hidden;
229
+ }
230
+
231
+ .progress-bar {
232
+ height: 100%;
233
+ background-color: #42b983;
234
+ border-radius: 5px;
235
+ transition: width 0.5s ease;
236
+ }
237
+
238
+ footer {
239
+ margin-top: 30px;
240
+ padding-top: 20px;
241
+ border-top: 1px solid #eee;
242
+ text-align: center;
243
+ color: #95a5a6;
244
+ font-size: 0.9rem;
245
+ }
246
+
247
+ .footer-text {
248
+ margin: 5px 0;
249
+ }
250
+
251
+ /* 编辑模态框样式 */
252
+ .modal-overlay {
253
+ position: fixed;
254
+ top: 0;
255
+ left: 0;
256
+ right: 0;
257
+ bottom: 0;
258
+ background-color: rgba(0, 0, 0, 0.5);
259
+ display: flex;
260
+ justify-content: center;
261
+ align-items: center;
262
+ z-index: 1000;
263
+ }
264
+
265
+ .modal {
266
+ background-color: white;
267
+ padding: 30px;
268
+ border-radius: 10px;
269
+ width: 90%;
270
+ max-width: 500px;
271
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
272
+ }
273
+
274
+ .modal h3 {
275
+ margin-top: 0;
276
+ margin-bottom: 20px;
277
+ color: #2c3e50;
278
+ }
279
+
280
+ .edit-input {
281
+ width: 100%;
282
+ padding: 12px 15px;
283
+ border: 2px solid #42b983;
284
+ border-radius: 6px;
285
+ font-size: 16px;
286
+ margin-bottom: 20px;
287
+ }
288
+
289
+ .modal-actions {
290
+ display: flex;
291
+ gap: 10px;
292
+ justify-content: flex-end;
293
+ }
294
+
295
+ .save-btn, .cancel-btn {
296
+ padding: 10px 20px;
297
+ border: none;
298
+ border-radius: 6px;
299
+ font-weight: bold;
300
+ cursor: pointer;
301
+ }
302
+
303
+ .save-btn {
304
+ background-color: #42b983;
305
+ color: white;
306
+ }
307
+
308
+ .save-btn:hover {
309
+ background-color: #3aa876;
310
+ }
311
+
312
+ .cancel-btn {
313
+ background-color: #f0f0f0;
314
+ color: #333;
315
+ }
316
+
317
+ .cancel-btn:hover {
318
+ background-color: #e0e0e0;
319
+ }
320
+ `;const o=document.createElement("div");o.innerHTML=`<div :data-watch-todos="$todos" :data-watch-filter="$filter">
321
+ <div id="app">
322
+ <div class="todo-container">
323
+ <!-- Header Slot -->
324
+ <header>
325
+ <slot name="header">
326
+ <h1 class="app-title">{{ appTitle }}</h1>
327
+ <p class="app-description">使用 Vue2 实现的 Todo List 应用</p>
328
+ </slot>
329
+ </header>
330
+
331
+ <!-- Add Todo Form -->
332
+ <div class="add-todo">
333
+ <input
334
+ type="text"
335
+ v-model="newTodo"
336
+ placeholder="请输入待办事项..."
337
+ @keyup.enter="addTodo"
338
+ class="todo-input"
339
+ />
340
+ <button @click="addTodo" class="add-btn">添加</button>
341
+ <button @click="clearCompleted" class="clear-btn">清除已完成</button>
342
+ </div>
343
+
344
+ <!-- Filter Controls -->
345
+ <div class="filter-controls">
346
+ <button
347
+ @click="filter = 'all'"
348
+ :class="{ active: filter === 'all' }"
349
+ class="filter-btn"
350
+ >
351
+ 全部 ({{ totalTodos }})
352
+ </button>
353
+ <button
354
+ @click="filter = 'active'"
355
+ :class="{ active: filter === 'active' }"
356
+ class="filter-btn"
357
+ >
358
+ 未完成 ({{ activeTodosCount }})
359
+ </button>
360
+ <button
361
+ @click="filter = 'completed'"
362
+ :class="{ active: filter === 'completed' }"
363
+ class="filter-btn"
364
+ >
365
+ 已完成 ({{ completedTodosCount }})
366
+ </button>
367
+ </div>
368
+
369
+ <!-- Todo List -->
370
+ <div class="todo-list">
371
+ <div v-if="filteredTodos.length === 0" class="empty-state">
372
+ <p v-if="todos.length === 0">暂无待办事项,请添加一个吧!</p>
373
+ <p v-else>没有{{ filter === 'active' ? '未完成' : '已完成' }}的事项</p>
374
+ </div>
375
+
376
+ <div
377
+ v-for="todo in filteredTodos"
378
+ :key="todo.id"
379
+ class="todo-item"
380
+ :class="{ completed: todo.completed }"
381
+ >
382
+ <div class="todo-content">
383
+ <input
384
+ type="checkbox"
385
+ v-model="todo.completed"
386
+ class="todo-checkbox"
387
+ :id="'todo-' + todo.id"
388
+ />
389
+ <label :for="'todo-' + todo.id" class="todo-text">
390
+ <span>{{ todo.text }}</span>
391
+ <span class="todo-date">{{ formatDate(todo.createdAt) }}</span>
392
+ </label>
393
+ </div>
394
+ <div class="todo-actions">
395
+ <button @click="editTodo(todo)" class="edit-btn">编辑</button>
396
+ <button @click="deleteTodo(todo.id)" class="delete-btn">删除</button>
397
+ </div>
398
+ </div>
399
+ </div>
400
+
401
+ <!-- Stats -->
402
+ <div class="stats">
403
+ <p v-if="todos.length > 0">
404
+ 已完成 {{ completedTodosCount }} / 总共 {{ totalTodos }} 个待办事项
405
+ <span v-if="hasCompletedTodos" class="completion-rate">
406
+ (完成率: {{ completionRate }}%)
407
+ </span>
408
+ </p>
409
+
410
+ <!-- Progress Bar Slot -->
411
+ <slot name="progress">
412
+ <div class="progress-container">
413
+ <div class="progress-bar" :style="{ width: completionRate + '%' }"></div>
414
+ </div>
415
+ </slot>
416
+ </div>
417
+
418
+ <!-- Footer Slot -->
419
+ <footer>
420
+ <slot name="footer">
421
+ <p class="footer-text">双击事项可标记为完成/未完成</p>
422
+ <p class="footer-text">使用 Vue2 实现 - 包含 Props, Data, Methods, Slots, Watch, Computed, 生命周期</p>
423
+ </slot>
424
+ </footer>
425
+ </div>
426
+
427
+ <!-- Edit Modal -->
428
+ <div v-if="editingTodo" class="modal-overlay" @click="cancelEdit">
429
+ <div class="modal" @click.stop>
430
+ <h3>编辑待办事项</h3>
431
+ <input
432
+ type="text"
433
+ v-model="editingTodo.text"
434
+ @keyup.enter="saveEdit"
435
+ class="edit-input"
436
+ />
437
+ <div class="modal-actions">
438
+ <button @click="saveEdit" class="save-btn">保存</button>
439
+ <button @click="cancelEdit" class="cancel-btn">取消</button>
440
+ </div>
441
+ </div>
442
+ </div>
443
+ </div>
444
+ </div>`,this._el=o.firstElementChild,this.shadowRoot.appendChild(e),this.shadowRoot.appendChild(this._el),this.app=null}connectedCallback(){const e=this;this.app=B({initialTodos:function(){return[]},appTitle:"我的待办清单",enableLocalStorage:!0,newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0,get filteredTodos(){switch(this.filter){case"active":return this.todos.filter(n=>!n.completed);case"completed":return this.todos.filter(n=>n.completed);default:return this.todos}},get activeTodosCount(){return this.todos.filter(n=>!n.completed).length},get completedTodosCount(){return this.todos.filter(n=>n.completed).length},get totalTodos(){return this.todos.length},get completionRate(){return this.totalTodos===0?0:Math.round(this.completedTodosCount/this.totalTodos*100)},get hasCompletedTodos(){return this.completedTodosCount>0},$todos_handler(n,i){e._watchers.$todos=n,i?.split?.(",")?.shift?.()?.trim?.(),this.enableLocalStorage&&localStorage.setItem("vue-todos",JSON.stringify(n)),this.$emit("todos-updated",n)},get $todos(){const n=this.todos;return e._watchers.$todos!==n&&this.$todos_handler(n,e._watchers.$todos),n},$filter_handler(n,i){e._watchers.$filter=n,i?.split?.(",")?.shift?.()?.trim?.(),console.log("过滤器已更改为: "+n)},get $filter(){const n=this.filter;return e._watchers.$filter!==n&&this.$filter_handler(n,e._watchers.$filter),n},addTodo(){this.newTodo.trim()!==""&&(this.todos.push({id:++this.lastTodoId,text:this.newTodo.trim(),completed:!1,createdAt:new Date}),this.newTodo="",console.log("已添加新的待办事项"))},deleteTodo(n){const i=this.todos.findIndex(s=>s.id===n);i!==-1&&(this.todos.splice(i,1),console.log("已删除待办事项 ID: "+n))},editTodo(n){this.editingTodo={...n}},saveEdit(){if(this.editingTodo&&this.editingTodo.text.trim()!==""){const n=this.todos.findIndex(i=>i.id===this.editingTodo.id);n!==-1&&(this.$set(this.todos,n,{...this.editingTodo}),console.log("已更新待办事项 ID: "+this.editingTodo.id))}this.editingTodo=null},cancelEdit(){this.editingTodo=null},clearCompleted(){const n=this.todos.length;this.todos=this.todos.filter(s=>!s.completed);const i=n-this.todos.length;console.log("已清除 "+i+" 个已完成事项")},formatDate(n){return new Date(n).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},$lifecycle_mounted(){console.log("TodoApp 组件已挂载到 DOM"),this.$nextTick(()=>{document.querySelectorAll(".todo-item").forEach(i=>{i.addEventListener("dblclick",()=>{const s=parseInt(i.dataset.id),r=this.todos.findIndex(l=>l.id===s);r!==-1&&(this.todos[r].completed=!this.todos[r].completed,console.log("双击切换待办事项状态 ID: "+s))})})})},$lifecycle_unmounted(){console.log("TodoApp 组件已销毁")},get $el(){return e.$el},get $parent(){return e.$parent},get $children(){return e.$children},get $root(){return e.$root},$emit(n,i){e.dispatchEvent(new CustomEvent(e._eventPrefix+n,{detail:i}))}}),this.$app=Yt(this.app).mount(this._el);let o=this.parentElement;for(;o&&!Xt(o);)o=o.parentElement;o&&(this._parent=o,o._children.push(this)),this.dispatchEvent(new CustomEvent("mounted")),this.app?.$lifecycle_mounted?.(),(function(){const n=(function(){return{newTodo:"",todos:[],filter:"all",editingTodo:null,lastTodoId:0}})();Object.keys(n).forEach(i=>{(e?.constructor?.observedAttributes??[]).indexOf?.(i)>=0?te.info("当前属性 "+i+" 已定义为 prop 属性, 无法初始化."):e.app[i]=n[i]})})()}attributeChangedCallback(e,o,n){if(!this.app){var i=this;setTimeout(function(){i.attributeChangedCallback(e,o,n)},10);return}if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){const s=this._types[e];s&&(this.app[s.attr]=this._typeChcker(n,s.type))}}disconnectedCallback(){this._children&&(this._children.forEach(e=>e.disconnectedCallback()),this._children=[]),this._parent&&(this._parent._children=this._parent._children.filter(e=>e!==this),this._parent=null),Object.keys(this._listeners).forEach(e=>this.off(e)),this._listeners={},this.dispatchEvent(new CustomEvent("unmounted")),this.app?.$lifecycle_unmounted?.(),this.app=null,this.$app.unmount(),this.$app=null,this._el=null}get __isDarkchest(){return this._isDarkchest}get __componentId(){return this._componentId}get $el(){return this._el||null}get $parent(){return this._parent||null}get $children(){return this._children||[]}get $root(){let e=this;for(;e.$parent&&Xt(e.$parent);)e=e.$parent;return e}_typeChcker(e,o){return e}prop(e,o){if((this?.constructor?.observedAttributes??[]).indexOf?.(e)>=0){if(o===void 0)return this.getAttribute(e);this.setAttribute(e,o)}else te.info(`未定义的prop [${e}]`)}get initialTodos(){return this?.app?.initialTodos}set initialTodos(e){this.app.initialTodos=this?._typeChcker?.(e,"Array","Object")}get appTitle(){return this?.app?.appTitle}set appTitle(e){this.app.appTitle=this?._typeChcker?.(e,"String")}get enableLocalStorage(){return this?.app?.enableLocalStorage}set enableLocalStorage(e){this.app.enableLocalStorage=this?._typeChcker?.(e,"Boolean")}on(e,o,n){const i=this._eventPrefix+e;return this._listeners[i]=o,this.addEventListener(i,o,n),this}off(e,o){if(e){const n=this._eventPrefix+e;if(o)this.removeEventListener(n,o),delete this._listeners[n];else{const i=this._listeners[n];i&&(this.removeEventListener(n,i),delete this._listeners[n])}}return this}once(e,o,n){const i=this._eventPrefix+e,s=(...r)=>{this.removeEventListener(i,s),o(...r)};return this.addEventListener(i,s,n),this}addTodo(){return this.app.addTodo()}deleteTodo(e){return this.app.deleteTodo(e)}editTodo(e){return this.app.editTodo(e)}saveEdit(){return this.app.saveEdit()}cancelEdit(){return this.app.cancelEdit()}clearCompleted(){return this.app.clearCompleted()}formatDate(e){return this.app.formatDate(e)}}customElements.define("todo-list",mo)})();