mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-28 07:54:13 +08:00
10 lines
24 KiB
JavaScript
10 lines
24 KiB
JavaScript
|
import{A as $,a_ as ye,a$ as xe,b0 as ie,q as ee,an as Ie,o as j,p as Ee,ao as Oe,b1 as Se,b2 as Ce,b as Ae,y as we,u as Me,b3 as Te,D as le,d as A,i as y,g as z,Y as ze,Z as X,F as Re,B as oe,S as W,f as G,a9 as J,t as U,l as _e}from"./index-Csmv4Fkv.js";import{D as ke}from"./DocumentTitle-DG90V81t.js";import{f as Pe}from"./time-CHbJgbks.js";import{I as ae}from"./IconReload--QlVe2wP.js";const $e=()=>{const[n,r]=$([]),[e,t]=$([]),s=async()=>{const[{rules:l},{providers:a}]=await Promise.all([ye(),xe()]);r(Object.values(l)),t(Object.values(a))};return{rules:n,ruleProviders:e,updateRules:s,updateAllRuleProvider:async()=>{await Promise.all(e().map(l=>ie(l.name))),await s()},updateRuleProviderByName:async l=>{await ie(l),await s()}}};function P(n,r,e){let t=e.initialDeps??[],s;return()=>{var i,o,l,a;let u;e.key&&((i=e.debug)!=null&&i.call(e))&&(u=Date.now());const c=n();if(!(c.length!==t.length||c.some((b,f)=>t[f]!==b)))return s;t=c;let p;if(e.key&&((o=e.debug)!=null&&o.call(e))&&(p=Date.now()),s=r(...c),e.key&&((l=e.debug)!=null&&l.call(e))){const b=Math.round((Date.now()-u)*100)/100,f=Math.round((Date.now()-p)*100)/100,w=f/16,E=(O,T)=>{for(O=String(O);O.length<T;)O=" "+O;return O};console.info(`%c⏱ ${E(f,5)} /${E(b,5)} ms`,`
|
||
|
font-size: .6rem;
|
||
|
font-weight: bold;
|
||
|
color: hsl(${Math.max(0,Math.min(120-120*w,120))}deg 100% 31%);`,e==null?void 0:e.key)}return(a=e==null?void 0:e.onChange)==null||a.call(e,s),s}}function Z(n,r){if(n===void 0)throw new Error("Unexpected undefined");return n}const Ue=(n,r)=>Math.abs(n-r)<1,Ve=(n,r,e)=>{let t;return function(...s){n.clearTimeout(t),t=n.setTimeout(()=>r.apply(this,s),e)}},Ne=n=>n,Fe=n=>{const r=Math.max(n.startIndex-n.overscan,0),e=Math.min(n.endIndex+n.overscan,n.count-1),t=[];for(let s=r;s<=e;s++)t.push(s);return t},De=(n,r)=>{const e=n.scrollElement;if(!e)return;const t=n.targetWindow;if(!t)return;const s=o=>{const{width:l,height:a}=o;r({width:Math.round(l),height:Math.round(a)})};if(s(e.getBoundingClientRect()),!t.ResizeObserver)return()=>{};const i=new t.ResizeObserver(o=>{const l=o[0];if(l!=null&&l.borderBoxSize){const a=l.borderBoxSize[0];if(a){s({width:a.inlineSize,height:a.blockSize});return}}s(e.getBoundingClientRect())});return i.observe(e,{box:"border-box"}),()=>{i.unobserve(e)}},ce={passive:!0},We=typeof window>"u"?!0:"onscrollend"in window,je=(n,r)=>{const e=n.scrollElement;if(!e)return;const t=n.targetWindow;if(!t)return;let s=0;const i=n.options.useScrollendEvent&&We?()=>{}:Ve(t,()=>{r(s,!1)},n.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:c,isRtl:h}=n.options;s=c?e.scrollLeft*(h&&-1||1):e.scrollTop,i(),r(s,u)},l=o(!0),a=o(!1);return a(),e.addEventListener("scroll",l,ce),e.addEventListener("scrollend",a,ce),()=>{e.removeEventListener("scroll",l),e.removeEventListener("scrollend",a)}},He=(n,r,e)=>{if(r!=null&&r.borderBoxSize){const t=r.borderBoxSize[0];if(t)return Math.round(t[e.options.horizontal?"inlineSize":"blockSize"])}return Math.round(n.getBoundingClientRect()[e.options.horizontal?"width":"height"])},Be=(n,{adjustments:r=0,behavior:e},t)=>{var s,i;const o=n+r;(i=(s=t.scrollElement)==null?void 0:s.scrollTo)==null||i.call(s,{[t.options.horizontal?"left":"top"]:o,behavior:e})};class Ke{constructor(r){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(i=>{this._measureElement(i.target,i)})}));return{disconnect:()=>{var s;(s=t())==null||s.disconnect(),e=null},observe:s=>{var i;return(i=t())==null?void 0:i.observe(s,{box:"border-box"})},unobserve:s=>{var i;return(i=t())==null?void 0:i.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,s])=>{typeof s>"u"&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ne,rangeExtractor:Fe,onChange:()=>{},measureElement:He,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,...e}},this.notify=e=>{var t,s;(s=(t=this.options).onChange)==null||s.call(t,this,e)},this.maybeNotify=P(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=thi
|
||
|
* @name match-sorter
|
||
|
* @license MIT license.
|
||
|
* @copyright (c) 2020 Kent C. Dodds
|
||
|
* @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
|
||
|
*/const x={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},Ge=(n,r)=>String(n.rankedValue).localeCompare(String(r.rankedValue));function te(n,r,e){e===void 0&&(e={});const{keys:t,threshold:s=x.MATCHES,baseSort:i=Ge,sorter:o=u=>u.sort((c,h)=>tt(c,h,i))}=e,l=n.reduce(a,[]);return o(l).map(u=>{let{item:c}=u;return c});function a(u,c,h){const p=Je(c,t,r,e),{rank:b,keyThreshold:f=s}=p;return b>=f&&u.push({...p,item:c,index:h}),u}}te.rankings=x;function Je(n,r,e,t){if(!r){const i=n;return{rankedValue:i,rank:de(i,e,t),keyIndex:-1,keyThreshold:t.threshold}}return rt(n,r).reduce((i,o,l)=>{let{rank:a,rankedValue:u,keyIndex:c,keyThreshold:h}=i,{itemValue:p,attributes:b}=o,f=de(p,e,t),w=u;const{minRanking:E,maxRanking:O,threshold:T}=b;return f<E&&f>=x.MATCHES?f=E:f>O&&(f=O),f>a&&(a=f,c=l,h=T,w=p),{rankedValue:w,rank:a,keyIndex:c,keyThreshold:h}},{rankedValue:n,rank:x.NO_MATCH,keyIndex:-1,keyThreshold:t.threshold})}function de(n,r,e){return n=fe(n,e),r=fe(r,e),r.length>n.length?x.NO_MATCH:n===r?x.CASE_SENSITIVE_EQUAL:(n=n.toLowerCase(),r=r.toLowerCase(),n===r?x.EQUAL:n.startsWith(r)?x.STARTS_WITH:n.includes(` ${r}`)?x.WORD_STARTS_WITH:n.includes(r)?x.CONTAINS:r.length===1?x.NO_MATCH:Ze(n).includes(r)?x.ACRONYM:et(n,r))}function Ze(n){let r="";return n.split(" ").forEach(t=>{t.split("-").forEach(i=>{r+=i.substr(0,1)})}),r}function et(n,r){let e=0,t=0;function s(a,u,c){for(let h=c,p=u.length;h<p;h++)if(u[h]===a)return e+=1,h+1;return-1}function i(a){const u=1/a,c=e/r.length;return x.MATCHES+c*u}const o=s(r[0],n,0);if(o<0)return x.NO_MATCH;t=o;for(let a=1,u=r.length;a<u;a++){const c=r[a];if(t=s(c,n,t),!(t>-1))return x.NO_MATCH}const l=t-o;return i(l)}function tt(n,r,e){const{rank:i,keyIndex:o}=n,{rank:l,keyIndex:a}=r;return i===l?o===a?e(n,r):o<a?-1:1:i>l?-1:1}function fe(n,r){let{keepDiacritics:e}=r;return n=`${n}`,e||(n=Xe(n)),n}function st(n,r){typeof r=="object"&&(r=r.key);let e;if(typeof r=="function")e=r(n);else if(n==null)e=null;else if(Object.hasOwnProperty.call(n,r))e=n[r];else{if(r.includes("."))return nt(r,n);e=null}return e==null?[]:Array.isArray(e)?e:[String(e)]}function nt(n,r){const e=n.split(".");let t=[r];for(let s=0,i=e.length;s<i;s++){const o=e[s];let l=[];for(let a=0,u=t.length;a<u;a++){const c=t[a];if(c!=null)if(Object.hasOwnProperty.call(c,o)){const h=c[o];h!=null&&l.push(h)}else o==="*"&&(l=l.concat(c))}t=l}return Array.isArray(t[0])?[].concat(...t):t}function rt(n,r){const e=[];for(let t=0,s=r.length;t<s;t++){const i=r[t],o=it(i),l=st(n,i);for(let a=0,u=l.length;a<u;a++)e.push({itemValue:l[a],attributes:o})}return e}const me={maxRanking:1/0,minRanking:-1/0};function it(n){return typeof n=="string"?me:{...me,...n}}var ge=U("<div class=relative>"),lt=U('<div class="flex h-full flex-col gap-2"><div class="flex w-full flex-wrap items-center gap-2"><div class="tabs-boxed tabs gap-2"></div><div class="join flex flex-1 items-center"><input class="input input-sm join-item input-primary min-w-0 flex-1"type=search></div></div><div class="flex-1 overflow-y-auto">'),ot=U('<button><span></span><div class="badge badge-sm">'),at=U('<div class="badge badge-sm">'),ct=U('<div class="absolute inset-x-0 top-0 pb-2 last:pb-0"><div class="card card-bordered card-compact bg-base-200 p-4"><div class="flex items-center gap-2"><span class=break-all></span></div><div class="text-xs text-slate-500">'),ut=U('<div class="absolute inset-x-0 top-0 pb-2 last:pb-0"><div class="card card-bordered card-compact bg-base-200 p-4"><div class="flex items-center gap-2 pr-8"><span class=break-all></span><div class="badge badge-sm"></div></div><div class="text-xs text-slate-500">');const gt=()=>{const n=Ae();if(!we())return n("/setup",{replace:!0}),null;const[r]=Me(),{rules:e,ruleProviders:t,updateRules:s,updateAllRuleProvider:i,updateRuleProviderByName:o}=$e();j(s);const{map:l,setWithCallback:a}=Te(),[u,c]=$(!1),h=(I,M)=>{I.stopPropagation(),a(M,()=>o(M))},p=async I=>{I.stopPropagation(),c(!0);try{await i()}catch{}c(!1)},[b,f]=$("rules"),w=()=>[{type:"rules",name:r("rules"),count:e().length},{ty
|