@cp949/mui-react19 2.0.3 → 2.1.0

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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/dist/closables-CeOGJV-d.d.cts +136 -0
  4. package/dist/closables-CeOGJV-d.d.ts +136 -0
  5. package/dist/file-drop/index.cjs +1 -1
  6. package/dist/file-drop/index.cjs.map +1 -1
  7. package/dist/file-drop/index.d.cts +224 -217
  8. package/dist/file-drop/index.d.ts +224 -217
  9. package/dist/file-drop/index.js +1 -1
  10. package/dist/file-drop/index.js.map +1 -1
  11. package/dist/helper/index.cjs +1 -1
  12. package/dist/helper/index.cjs.map +1 -1
  13. package/dist/helper/index.d.cts +22 -38
  14. package/dist/helper/index.d.ts +22 -38
  15. package/dist/helper/index.js +1 -1
  16. package/dist/helper/index.js.map +1 -1
  17. package/dist/hooks/index.cjs +1 -1
  18. package/dist/hooks/index.cjs.map +1 -1
  19. package/dist/hooks/index.d.cts +417 -307
  20. package/dist/hooks/index.d.ts +417 -307
  21. package/dist/hooks/index.js +1 -1
  22. package/dist/hooks/index.js.map +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +1032 -684
  26. package/dist/index.d.ts +1032 -684
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/misc-utils-B2de-HS4.cjs +2 -0
  30. package/dist/misc-utils-B2de-HS4.cjs.map +1 -0
  31. package/dist/misc-utils-BXQ8UU0R.js +2 -0
  32. package/dist/misc-utils-BXQ8UU0R.js.map +1 -0
  33. package/dist/parallel-map-DyuHvxYY.js +2 -0
  34. package/dist/parallel-map-DyuHvxYY.js.map +1 -0
  35. package/dist/parallel-map-_ZhC5iBn.cjs +2 -0
  36. package/dist/parallel-map-_ZhC5iBn.cjs.map +1 -0
  37. package/dist/rolldown-runtime-Chgba0Kb.cjs +1 -0
  38. package/dist/rolldown-runtime-DK3Fl9T5.js +1 -0
  39. package/llm.txt +350 -0
  40. package/package.json +19 -17
  41. package/dist/chunk-2OEB5VHZ.js +0 -2
  42. package/dist/chunk-2OEB5VHZ.js.map +0 -1
  43. package/dist/chunk-4C666HHU.js +0 -2
  44. package/dist/chunk-4C666HHU.js.map +0 -1
  45. package/dist/chunk-M4G6J7DP.cjs +0 -2
  46. package/dist/chunk-M4G6J7DP.cjs.map +0 -1
  47. package/dist/chunk-QNR3IXPA.cjs +0 -2
  48. package/dist/chunk-QNR3IXPA.cjs.map +0 -1
  49. package/dist/closables-BK0Db72u.d.cts +0 -135
  50. package/dist/closables-BK0Db72u.d.ts +0 -135
  51. package/dist/parallel-map-M764G6IE.js +0 -2
  52. package/dist/parallel-map-M764G6IE.js.map +0 -1
  53. package/dist/parallel-map-V2OVUIFQ.cjs +0 -2
  54. package/dist/parallel-map-V2OVUIFQ.cjs.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 jjfive
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -72,6 +72,10 @@ export default function ClientComponent() {
72
72
  }
73
73
  ```
74
74
 
75
+ ## LLM용 API 요약
76
+
77
+ 배포 패키지에 `llm.txt`가 포함됩니다. AI 코딩 도구가 공개 API 시그니처와 사용 제약을 한 번에 읽을 수 있도록 빌드 시 `dist/*.d.ts`에서 생성한 영문 요약입니다. 경로는 `node_modules/@cp949/mui-react19/llm.txt`입니다.
78
+
75
79
  ## 컴포넌트 목록
76
80
 
77
81
  ### 레이아웃 컴포넌트
@@ -88,17 +92,23 @@ export default function ClientComponent() {
88
92
 
89
93
  - `CooldownButton`, `DebouncedButton` - 쿨다운/디바운스 버튼
90
94
  - `FileButton` - 파일 업로드 버튼
95
+ - `PasswordTextField` - 비밀번호 보기/숨기기 토글이 있는 TextField
91
96
  - `CopyButtonWrapper` - 복사 기능 래퍼
92
97
  - `Spoiler` - 스포일러/더보기 컴포넌트
93
98
  - `Hide`, `Show` - 조건부 렌더링 유틸리티
94
99
  - `Paper` - MUI Paper 래퍼
95
100
  - `Mark` - 하이라이트 마크
101
+ - `YmdTypography` - YYYYMMDD/YYMMDD 숫자 날짜를 포맷해 표시하는 Typography
102
+ - `YmTypography` - YYYYMM 숫자 연월을 포맷해 표시하는 Typography
103
+ - `YmdTextField` - YYMMDD/YYYYMMDD 숫자 날짜 입력 TextField
96
104
  - `SmOrUp`, `MdOrDown`, `LgOrUp` 등 - 반응형 조건부 렌더링
97
105
 
98
106
  ### 고급 기능 컴포넌트
99
107
 
100
108
  - `FloatingIndicator` - 플로팅 인디케이터
101
109
  - `DebouncedRender` - 디바운스된 렌더링
110
+ - `SearchBoxDebouncer` - 검색 조건 입력을 모아 한 번만 외부로 전달 (훅: `useDebouncedParams`)
111
+ - `DelayedRender` - 지정한 시간이 지난 뒤에 자식을 렌더링
102
112
  - `SegmentedControl` - 세그먼트 컨트롤
103
113
 
104
114
  ## 훅 (Hooks)
@@ -0,0 +1,136 @@
1
+ import { Subject } from "rxjs";
2
+ //#region src/eventemitter/types.d.ts
3
+ /**
4
+ * `object` should be in either of the following forms:
5
+ * ```
6
+ * interface EventTypes {
7
+ * 'event-with-parameters': any[]
8
+ * 'event-with-example-handler': (...args: any[]) => void
9
+ * }
10
+ * ```
11
+ */
12
+ type ValidEventTypes = string | symbol | object;
13
+ type EventNames<T extends ValidEventTypes> = T extends string | symbol ? T : keyof T;
14
+ type ArgumentMap<T extends object> = { [K in keyof T]: T[K] extends ((...args: any[]) => void) ? Parameters<T[K]> : T[K] extends any[] ? T[K] : any[]; };
15
+ type EventListener<T extends ValidEventTypes, K extends EventNames<T>> = T extends string | symbol ? (...args: any[]) => void : (...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]) => void;
16
+ type EventArgs<T extends ValidEventTypes, K extends EventNames<T>> = Parameters<EventListener<T, K>>;
17
+ //#endregion
18
+ //#region src/eventemitter/eventemitter3.d.ts
19
+ /**
20
+ * Minimal `EventEmitter` interface that is molded against the Node.js
21
+ * `EventEmitter` interface.
22
+ */
23
+ declare class EventEmitter<EventTypes extends ValidEventTypes = string | symbol, Context = any> {
24
+ private _eventsCount;
25
+ private _events;
26
+ /**
27
+ * Return an array listing the events for which the emitter has registered
28
+ * listeners.
29
+ */
30
+ eventNames(): EventNames<EventTypes>[];
31
+ /**
32
+ * Return the listeners registered for a given event.
33
+ */
34
+ listeners<T extends EventNames<EventTypes>>(event: T): EventListener<EventTypes, T>[] | undefined;
35
+ /**
36
+ * Return the number of listeners listening to a given event.
37
+ */
38
+ listenerCount(event: EventNames<EventTypes>): number;
39
+ /**
40
+ * Calls each of the listeners registered for a given event.
41
+ */
42
+ emit<T extends EventNames<EventTypes>>(event: T, ...args: EventArgs<EventTypes, T>): boolean;
43
+ /**
44
+ * Add a listener for a given event.
45
+ */
46
+ on<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): () => void;
47
+ /**
48
+ * Add a listener for a given event.
49
+ */
50
+ addListener<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): () => void;
51
+ /**
52
+ * Add a one-time listener for a given event.
53
+ */
54
+ once<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): () => void;
55
+ /**
56
+ * Remove the listeners of a given event.
57
+ */
58
+ removeListener<T extends EventNames<EventTypes>>(event: T, fn?: EventListener<EventTypes, T>, context?: Context, once?: boolean): this;
59
+ /**
60
+ * Remove the listeners of a given event.
61
+ */
62
+ off<T extends EventNames<EventTypes>>(event: T, fn?: EventListener<EventTypes, T>, context?: Context, once?: boolean): this;
63
+ /**
64
+ * Remove all listeners, or those of the specified event.
65
+ */
66
+ removeAllListeners(event?: EventNames<EventTypes>): this;
67
+ }
68
+ //#endregion
69
+ //#region src/util/closables.d.ts
70
+ type WinEventType = keyof WindowEventMap;
71
+ type WinEventListener<K extends WinEventType> = (this: Window, ev: WindowEventMap[K]) => void;
72
+ type EventOptions = boolean | AddEventListenerOptions;
73
+ type DocEventType = keyof DocumentEventMap;
74
+ type DocEventListener<K extends DocEventType> = (this: Document, ev: DocumentEventMap[K]) => void;
75
+ type ElemEventType = keyof HTMLElementEventMap;
76
+ type ElemEventListener<K extends ElemEventType> = (this: HTMLElement, ev: HTMLElementEventMap[K]) => void;
77
+ declare class Closables {
78
+ #private;
79
+ get events(): EventEmitter<{
80
+ closed: () => void;
81
+ }, any>;
82
+ get closeTrigger$(): Subject<unknown>;
83
+ add: (...closables: (() => void)[]) => this;
84
+ remove: (...closables: (() => void)[]) => this;
85
+ addRx: (...closables: Array<{
86
+ unsubscribe: () => void;
87
+ }>) => this;
88
+ addUnsubscribe: (...closables: Array<{
89
+ unsubscribe: () => void;
90
+ }>) => this;
91
+ addClose: (...closables: Array<{
92
+ close: () => void;
93
+ }>) => this;
94
+ addDispose: (...closables: Array<{
95
+ dispose: () => void;
96
+ }>) => this;
97
+ addDestroy: (...closables: Array<{
98
+ destroy: () => void;
99
+ }>) => this;
100
+ addShutdown: (...closables: Array<{
101
+ shutdown: () => void;
102
+ }>) => this;
103
+ addTerminate: (...closables: Array<{
104
+ terminate: () => void;
105
+ }>) => this;
106
+ addElementListener: <K extends ElemEventType>(elem: HTMLElement, type: K, listener: ElemEventListener<K>, options?: EventOptions) => this;
107
+ addDocumentListener: <K extends DocEventType>(type: K, listener: DocEventListener<K>, options?: EventOptions) => this;
108
+ addWindowListener: <K extends WinEventType>(type: K, listener: WinEventListener<K>, options?: EventOptions) => this;
109
+ get count(): number;
110
+ close: () => void;
111
+ static create: (...closables: (() => void)[]) => Closables;
112
+ static createWindowListener: <K extends WinEventType>(type: K, listener: WinEventListener<K>, options?: EventOptions) => Closables;
113
+ static createDocumentListener: <K extends DocEventType>(type: K, listener: DocEventListener<K>, options?: EventOptions) => Closables;
114
+ static createElementListener: <K extends ElemEventType>(elem: HTMLElement, type: K, listener: ElemEventListener<K>, options?: EventOptions) => Closables;
115
+ static createRx: (...closables: {
116
+ unsubscribe: () => void;
117
+ }[]) => Closables;
118
+ static createClose: (...closables: {
119
+ close: () => void;
120
+ }[]) => Closables;
121
+ static createTerminate: (...closables: {
122
+ terminate: () => void;
123
+ }[]) => Closables;
124
+ static createShutdown: (...closables: {
125
+ shutdown: () => void;
126
+ }[]) => Closables;
127
+ static createDestroy: (...closables: {
128
+ destroy: () => void;
129
+ }[]) => Closables;
130
+ static createDispose: (...closables: {
131
+ dispose: () => void;
132
+ }[]) => Closables;
133
+ }
134
+ //#endregion
135
+ export { Closables as t };
136
+ //# sourceMappingURL=closables-CeOGJV-d.d.cts.map
@@ -0,0 +1,136 @@
1
+ import { Subject } from "rxjs";
2
+ //#region src/eventemitter/types.d.ts
3
+ /**
4
+ * `object` should be in either of the following forms:
5
+ * ```
6
+ * interface EventTypes {
7
+ * 'event-with-parameters': any[]
8
+ * 'event-with-example-handler': (...args: any[]) => void
9
+ * }
10
+ * ```
11
+ */
12
+ type ValidEventTypes = string | symbol | object;
13
+ type EventNames<T extends ValidEventTypes> = T extends string | symbol ? T : keyof T;
14
+ type ArgumentMap<T extends object> = { [K in keyof T]: T[K] extends ((...args: any[]) => void) ? Parameters<T[K]> : T[K] extends any[] ? T[K] : any[]; };
15
+ type EventListener<T extends ValidEventTypes, K extends EventNames<T>> = T extends string | symbol ? (...args: any[]) => void : (...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]) => void;
16
+ type EventArgs<T extends ValidEventTypes, K extends EventNames<T>> = Parameters<EventListener<T, K>>;
17
+ //#endregion
18
+ //#region src/eventemitter/eventemitter3.d.ts
19
+ /**
20
+ * Minimal `EventEmitter` interface that is molded against the Node.js
21
+ * `EventEmitter` interface.
22
+ */
23
+ declare class EventEmitter<EventTypes extends ValidEventTypes = string | symbol, Context = any> {
24
+ private _eventsCount;
25
+ private _events;
26
+ /**
27
+ * Return an array listing the events for which the emitter has registered
28
+ * listeners.
29
+ */
30
+ eventNames(): EventNames<EventTypes>[];
31
+ /**
32
+ * Return the listeners registered for a given event.
33
+ */
34
+ listeners<T extends EventNames<EventTypes>>(event: T): EventListener<EventTypes, T>[] | undefined;
35
+ /**
36
+ * Return the number of listeners listening to a given event.
37
+ */
38
+ listenerCount(event: EventNames<EventTypes>): number;
39
+ /**
40
+ * Calls each of the listeners registered for a given event.
41
+ */
42
+ emit<T extends EventNames<EventTypes>>(event: T, ...args: EventArgs<EventTypes, T>): boolean;
43
+ /**
44
+ * Add a listener for a given event.
45
+ */
46
+ on<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): () => void;
47
+ /**
48
+ * Add a listener for a given event.
49
+ */
50
+ addListener<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): () => void;
51
+ /**
52
+ * Add a one-time listener for a given event.
53
+ */
54
+ once<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): () => void;
55
+ /**
56
+ * Remove the listeners of a given event.
57
+ */
58
+ removeListener<T extends EventNames<EventTypes>>(event: T, fn?: EventListener<EventTypes, T>, context?: Context, once?: boolean): this;
59
+ /**
60
+ * Remove the listeners of a given event.
61
+ */
62
+ off<T extends EventNames<EventTypes>>(event: T, fn?: EventListener<EventTypes, T>, context?: Context, once?: boolean): this;
63
+ /**
64
+ * Remove all listeners, or those of the specified event.
65
+ */
66
+ removeAllListeners(event?: EventNames<EventTypes>): this;
67
+ }
68
+ //#endregion
69
+ //#region src/util/closables.d.ts
70
+ type WinEventType = keyof WindowEventMap;
71
+ type WinEventListener<K extends WinEventType> = (this: Window, ev: WindowEventMap[K]) => void;
72
+ type EventOptions = boolean | AddEventListenerOptions;
73
+ type DocEventType = keyof DocumentEventMap;
74
+ type DocEventListener<K extends DocEventType> = (this: Document, ev: DocumentEventMap[K]) => void;
75
+ type ElemEventType = keyof HTMLElementEventMap;
76
+ type ElemEventListener<K extends ElemEventType> = (this: HTMLElement, ev: HTMLElementEventMap[K]) => void;
77
+ declare class Closables {
78
+ #private;
79
+ get events(): EventEmitter<{
80
+ closed: () => void;
81
+ }, any>;
82
+ get closeTrigger$(): Subject<unknown>;
83
+ add: (...closables: (() => void)[]) => this;
84
+ remove: (...closables: (() => void)[]) => this;
85
+ addRx: (...closables: Array<{
86
+ unsubscribe: () => void;
87
+ }>) => this;
88
+ addUnsubscribe: (...closables: Array<{
89
+ unsubscribe: () => void;
90
+ }>) => this;
91
+ addClose: (...closables: Array<{
92
+ close: () => void;
93
+ }>) => this;
94
+ addDispose: (...closables: Array<{
95
+ dispose: () => void;
96
+ }>) => this;
97
+ addDestroy: (...closables: Array<{
98
+ destroy: () => void;
99
+ }>) => this;
100
+ addShutdown: (...closables: Array<{
101
+ shutdown: () => void;
102
+ }>) => this;
103
+ addTerminate: (...closables: Array<{
104
+ terminate: () => void;
105
+ }>) => this;
106
+ addElementListener: <K extends ElemEventType>(elem: HTMLElement, type: K, listener: ElemEventListener<K>, options?: EventOptions) => this;
107
+ addDocumentListener: <K extends DocEventType>(type: K, listener: DocEventListener<K>, options?: EventOptions) => this;
108
+ addWindowListener: <K extends WinEventType>(type: K, listener: WinEventListener<K>, options?: EventOptions) => this;
109
+ get count(): number;
110
+ close: () => void;
111
+ static create: (...closables: (() => void)[]) => Closables;
112
+ static createWindowListener: <K extends WinEventType>(type: K, listener: WinEventListener<K>, options?: EventOptions) => Closables;
113
+ static createDocumentListener: <K extends DocEventType>(type: K, listener: DocEventListener<K>, options?: EventOptions) => Closables;
114
+ static createElementListener: <K extends ElemEventType>(elem: HTMLElement, type: K, listener: ElemEventListener<K>, options?: EventOptions) => Closables;
115
+ static createRx: (...closables: {
116
+ unsubscribe: () => void;
117
+ }[]) => Closables;
118
+ static createClose: (...closables: {
119
+ close: () => void;
120
+ }[]) => Closables;
121
+ static createTerminate: (...closables: {
122
+ terminate: () => void;
123
+ }[]) => Closables;
124
+ static createShutdown: (...closables: {
125
+ shutdown: () => void;
126
+ }[]) => Closables;
127
+ static createDestroy: (...closables: {
128
+ destroy: () => void;
129
+ }[]) => Closables;
130
+ static createDispose: (...closables: {
131
+ dispose: () => void;
132
+ }[]) => Closables;
133
+ }
134
+ //#endregion
135
+ export { Closables as t };
136
+ //# sourceMappingURL=closables-CeOGJV-d.d.ts.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4;require('../chunk-M4G6J7DP.cjs');function $(...t){return t.filter(e=>e&&e.length>0&&e!==".").flatMap(e=>e.split("/")).filter(e=>e.length>0&&e!==".")}var P= (_class =class t{static join(...e){return t.split(...e).join("/")}static __initStatic() {this.split=(...e)=>{let r=[];return e.forEach(i=>{Array.isArray(i)?i.forEach(s=>{typeof s=="string"&&s.length>0&&r.push(...$(s))}):typeof i=="string"&&i.length>0&&r.push(...$(i))}),r.filter(i=>typeof i=="string"&&i.length>0&&i!==".")}}static pathStartsWith(e,r){return t.segmentsStartsWith(t.split(e),t.split(r))}static segmentsStartsWith(e,r){let i=e,s=r;return s.length>i.length?!1:s.every((o,l)=>o===i[l])}}, _class.__initStatic(), _class),S= exports.PathHolder = (_class2 =class t{constructor(e){;_class2.prototype.__init.call(this);_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);Array.isArray(e)?this.segments=e:this.segments=P.split(e),this.path=this.segments.join("/")}static __initStatic2() {this.EMPTY=new t([])}static __initStatic3() {this.from=(...e)=>new t(P.split(...e))}__init() {this.join=(...e)=>{let r=P.split(...this.segments,...e);return new t(r)}}__init2() {this.changeLast=e=>{if(this.segments.length===0)return new t(e);let r=this.segments.slice();return r[r.length-1]=e,new t(r)}}__init3() {this.parentOrNull=()=>{if(this.segments.length===0)return null;let e=this.segments.slice(0,this.segments.length-1);return new t(e)}}__init4() {this.lastSegmentOrNull=()=>this.segments.length===0?null:this.segments[this.segments.length-1]}__init5() {this.lastSegment=()=>this.segments.length===0?"":this.segments[this.segments.length-1]}__init6() {this.startsWith=e=>typeof e=="string"?P.segmentsStartsWith(this.segments,P.split(e)):Array.isArray(e)?P.segmentsStartsWith(this.segments,e):P.segmentsStartsWith(this.segments,e.segments)}toString(){return this.path}}, _class2.__initStatic2(), _class2.__initStatic3(), _class2);var T=()=>{};function E(t="warn"){let e=t!=="none",r=t==="info"||t==="verbose",i=t==="verbose";return{info:r?(...s)=>console.log(...s):T,verbose:i?(...s)=>console.log(...s):T,debug:i?(...s)=>console.debug(...s):T,warn:e?(...s)=>console.warn(...s):T,error:r?(...s)=>console.error(...s):T}}function C(t){return typeof t>"u"||t===null?"unknown":typeof t=="string"?t:typeof t=="object"&&"message"in t&&typeof t.message=="string"?t.message:String(t)}async function A(t,e,r,i,s="none",o=!0,l=4){let n=E(s);if(e.isFile){let m=await U(e);if(!m){n.debug("FileSystemEntry.getFile() error",e);return}i(m)&&r.push({type:"file",file:m,path:t.join(m.name)});return}if(!e.isDirectory)return;r.push({type:"dir",path:t.join(e.name)});let a=t.join(e.name);n.info(`\u{1F50D} Traversing directory (Entry API): ${e.name} at path: ${a.toString()}`);let c=await V(e,s);n.verbose(` \u{1F4CA} Total children found: ${c.length}`),c.forEach((m,h)=>{n.verbose(` \u{1F4C4} Found [${h}]: ${m.name} (${m.isFile?"file":"directory"})`)});let{simpleParallelMap:I}=await Promise.resolve().then(() => _interopRequireWildcard(require("../parallel-map-V2OVUIFQ.cjs"))),g=Math.max(1,l);if(o&&g>1&&c.length>1)n.info(` \u26A1 Processing ${c.length} items in parallel (custom implementation, concurrency=${g})`),await I(c,async m=>{(m.isFile||m.isDirectory)&&await A(a,m,r,i,s,o,g)},g);else{n.info(` \u{1F4DD} Processing ${c.length} item directly`);for(let m of c)(m.isFile||m.isDirectory)&&await A(a,m,r,i,s,o,g)}}async function U(t){try{return await new Promise((e,r)=>{t.file(i=>{e(i)},i=>{r(i)})})}catch (e2){return null}}async function V(t,e="none"){let r=E(e);try{return await G(t,e)}catch(i){return r.debug(C(i)),[]}}async function G(t,e="none"){let r=E(e),i=t.createReader(),s=[];async function o(){return new Promise((l,n)=>{i.readEntries(a=>{a.length>0?(s=s.concat(a),l(o())):l(s)},a=>{r.warn("readEntries() error",a),n(a)})})}return await o(),s}async function O(t,e,r,i,s="none",o=!0,l=4){let n=E(s);if(e.kind==="file"){let c=await e.getFile();if(!c)return;i(c)&&r.push({type:"file",file:c,path:t.join(c.name)});return}if(e.kind!=="directory")return;r.push({type:"dir",path:t.join(e.name)});let a=t.join(e.name);try{let c=[],g=e.values();n.info(`\u{1F50D} Traversing directory: ${e.name} at path: ${a.toString()}`);for await(let p of g)p&&(c.push(p),n.verbose(` \u{1F4C4} Found: ${p.name} (${p.kind})`));n.verbose(` \u{1F4CA} Total children found: ${c.length}`);let{simpleParallelMap:D}=await Promise.resolve().then(() => _interopRequireWildcard(require("../parallel-map-V2OVUIFQ.cjs"))),m=Math.max(1,l);if(o&&m>1&&c.length>1)n.info(` \u26A1 Processing ${c.length} items in parallel (custom implementation, concurrency=${m})`),await D(c,async p=>{(p.kind==="file"||p.kind==="directory")&&await O(a,p,r,i,s,o,m)},m);else{n.info(` \u{1F4DD} Processing ${c.length} item directly`);for(let p of c)(p.kind==="file"||p.kind==="directory")&&await O(a,p,r,i,s,o,m)}}catch(c){n.warn(`Directory traversal warning for ${e.name}:`,c)}}var R=(t,...e)=>e.every(r=>r in t);async function v(t,e,r,i,s="none",o=!0,l=4){if(R(e,"filesystem","fullPath","isDirectory","isFile")){await A(t,e,r,i,s,o,l);return}if(R(e,"kind","isSameEntry")){await O(t,e,r,i,s,o,l);return}let n=e;i(n)&&r.push({type:"file",file:n,path:t.join(n.name)})}var Y=t=>!0;async function K(t,e=Y){let r="getAsFileSystemHandle"in DataTransferItem.prototype,i="webkitGetAsEntry"in DataTransferItem.prototype;if(!r&&!i){let n=Array.from(t.dataTransfer.files);return n.length===0?[]:n.filter(e).map(a=>({type:"file",file:a,path:S.from(a.name).toString()}))}let s=[],o=Array.prototype.slice.call(t.dataTransfer.items).filter(n=>n.kind==="file").map(n=>i?n.webkitGetAsEntry():r?n.getAsFileSystemHandle():n.getAsFile()).filter(Boolean),{simpleParallelMap:l}=await Promise.resolve().then(() => _interopRequireWildcard(require("../parallel-map-V2OVUIFQ.cjs")));if(o.length>1)await l(o,async n=>{let a=n;await v(S.EMPTY,a,s,e)},4);else for(let n of o){let a=n;await v(S.EMPTY,a,s,e)}return s.map(n=>({...n,path:n.path.toString()}))}var d=class extends Error{constructor(r,i,s){super(s||`File drop error: ${r}`);this.code=r;this.item=i;this.name="FileDropError"}};var F=class t{static normalize(e){return e.replace(/\/+/g,"/").replace(/\/$/,"")||"/"}static join(...e){return t.normalize(e.filter(Boolean).join("/"))}static dirname(e){let r=t.normalize(e),i=r.lastIndexOf("/");return i<=0?"/":r.slice(0,i)}static basename(e,r){let s=t.normalize(e).split("/").pop()||"";return r&&s.endsWith(r)?s.slice(0,-r.length):s}static extname(e){let r=t.basename(e),i=r.lastIndexOf(".");return i>0?r.slice(i):""}static relative(e,r){let i=t.normalize(e).split("/").filter(Boolean),s=t.normalize(r).split("/").filter(Boolean),o=0;for(;o<i.length&&o<s.length&&i[o]===s[o];)o++;let l=i.length-o,n=s.slice(o);return[...Array(l).fill(".."),...n].join("/")||"."}};function z(t,e){if(e.length===0)return!0;let r=F.extname(t.name).toLowerCase();return e.some(i=>i.toLowerCase()===r||i.toLowerCase()===r.slice(1))}function M(t,e){return t.size<=e}function _(t){if(/[<>:"/\\|?*]/.test(t))return!1;for(let r=0;r<t.length;r+=1){let i=t.charCodeAt(r);if(i>=0&&i<=31)return!1}return t.trim().length>0}function q(t){if(t.type)return t.type;let e=F.extname(t.name).toLowerCase();return{".txt":"text/plain",".js":"text/javascript",".ts":"text/typescript",".json":"application/json",".html":"text/html",".css":"text/css",".md":"text/markdown",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml"}[e]||"application/octet-stream"}function j(t,e,r=e){let i=F.extname(t.name),s=q(t);return{type:"file",name:t.name,path:F.normalize(e),pathSegments:e.split("/").filter(Boolean),relativePath:F.normalize(r),size:t.size,lastModified:new Date(t.lastModified),file:t,mimeType:s,extension:i}}function J(t){let e=[];function r(i){let s={type:i.type,name:i.name,path:i.path,pathSegments:i.path.split("/").filter(Boolean),relativePath:i.path,size:_optionalChain([i, 'access', _2 => _2.metadata, 'optionalAccess', _3 => _3.size]),lastModified:_optionalChain([i, 'access', _4 => _4.metadata, 'optionalAccess', _5 => _5.lastModified])};e.push(s),i.children&&i.children.forEach(r)}return r(t),e}function k(t,e){if(!e(t))return null;let r=_optionalChain([t, 'access', _6 => _6.children, 'optionalAccess', _7 => _7.map, 'call', _8 => _8(i=>k(i,e)), 'access', _9 => _9.filter, 'call', _10 => _10(i=>i!==null)]);return{...t,children:r}}function W(t,e){if(e(t))return t;if(t.children)for(let r of t.children){let i=W(r,e);if(i)return i}return null}function N(t){let e={name:"",type:"directory",path:"",children:[]},r=new Map;r.set("",e);let i=[...t].sort((s,o)=>s.pathSegments.length-o.pathSegments.length);for(let s of i){let o={name:s.name,type:s.type,path:s.path,metadata:s.size!==void 0?{size:s.size,lastModified:s.lastModified,extension:F.extname(s.name),mimeType:s.mimeType}:void 0,file:s.file};r.set(s.path,o);let l=F.dirname(s.path),n=r.get(l);if(!n&&l!=="/"&&l!==""){let a=l.split("/").filter(Boolean);n={name:a[a.length-1]||"",type:"directory",path:l,children:[]},r.set(l,n)}!n&&(l===""||l==="/")&&(n=e),n&&(n.children||(n.children=[]),n.children.push(o))}return e}var H= (_class3 =class{__init7() {this.fileCount=0}constructor(e={}){;_class3.prototype.__init7.call(this);this.options=e}filter(e){if(this.options.excludeDirectories&&e.type==="directory")return{accepted:!1};if(e.type==="file"){let r=e.file;if(this.options.maxFiles&&this.fileCount>=this.options.maxFiles)return{accepted:!1,error:new d("TOO_MANY_FILES",e,`Maximum ${this.options.maxFiles} files allowed`)};if(this.options.maxSize&&!M(r,this.options.maxSize))return{accepted:!1,error:new d("FILE_TOO_LARGE",e,`File size ${r.size} exceeds limit ${this.options.maxSize}`)};if(this.options.allowedExtensions&&!z(r,this.options.allowedExtensions))return{accepted:!1,error:new d("INVALID_FILE_TYPE",e,`File type not allowed: ${r.name}`)};this.fileCount++}return this.options.accept&&!this.options.accept(e)?{accepted:!1}:{accepted:!0}}get currentFileCount(){return this.fileCount}reset(){this.fileCount=0}}, _class3);var Q={imagesOnly:()=>({allowedExtensions:[".jpg",".jpeg",".png",".gif",".svg",".webp"],excludeDirectories:!0}),textOnly:()=>({allowedExtensions:[".txt",".md",".json",".js",".ts",".html",".css"],excludeDirectories:!0}),smallFilesOnly:()=>({maxSize:1024*1024,excludeDirectories:!0}),developmentFiles:()=>({allowedExtensions:[".js",".ts",".tsx",".jsx",".json",".md",".html",".css",".scss",".py",".java",".cpp",".c",".h",".yml",".yaml",".toml"]})};var L= (_class4 =class{__init8() {this.processedItems=0}constructor(e,r){;_class4.prototype.__init8.call(this);this.totalItems=e,this.startTime=Date.now(),this.onProgress=_optionalChain([r, 'optionalAccess', _11 => _11.onProgress])}setCurrentItem(e){this.currentItem=e,this.notifyProgress()}completeItem(){this.processedItems++,this.currentItem=void 0,this.notifyProgress()}notifyProgress(){if(!this.onProgress)return;let e=Date.now()-this.startTime,r=this.totalItems>0?Math.round(this.processedItems/this.totalItems*100):0,i;if(this.processedItems>0&&r<100){let o=e/this.processedItems,l=this.totalItems-this.processedItems;i=Math.round(o*l)}let s={totalItems:this.totalItems,processedItems:this.processedItems,currentItem:this.currentItem,percentage:r,estimatedTimeLeft:i};this.onProgress(s)}updateTotalItems(e){this.totalItems=e,this.notifyProgress()}get isComplete(){return this.processedItems>=this.totalItems}get elapsedTime(){return Date.now()-this.startTime}}, _class4);async function X(t){if("dataTransfer"in t){let e="getAsFileSystemHandle"in DataTransferItem.prototype,r="webkitGetAsEntry"in DataTransferItem.prototype;if(!e&&!r)return Array.from(t.dataTransfer.files);let i=Array.from(t.dataTransfer.items).filter(o=>o.kind==="file").map(o=>r?o.webkitGetAsEntry():e?o.getAsFileSystemHandle():o.getAsFile()).filter(Boolean);return(await Promise.all(i.map(o=>o&&o instanceof Promise?o:Promise.resolve(o)))).filter(Boolean)}return"length"in t?Array.from(t):Array.isArray(t)?t:null}async function Z(t,e,r,i={},s,o="warn",l){let n=[],a=[],c=0,{simpleParallelMap:I}=await Promise.resolve().then(() => _interopRequireWildcard(require("../parallel-map-V2OVUIFQ.cjs"))),g=Math.max(1,_nullishCoalesce(_optionalChain([l, 'optionalAccess', _12 => _12.concurrency]), () => (4))),D=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _13 => _13.parallel]), () => (!0)),m=E(o),h=async f=>{if(_optionalChain([s, 'optionalAccess', _14 => _14.aborted]))throw new d("UNKNOWN",void 0,"Operation aborted");try{await v(S.EMPTY,f,n,u=>{c++,r.updateTotalItems(c);let y=j(u,u.name);r.setCurrentItem(y);let w=e.filter(y);return w.error&&(a.push(w.error),_optionalChain([i, 'access', _15 => _15.onError, 'optionalCall', _16 => _16(w.error,y)])),w.accepted||r.completeItem(),w.accepted},o,D,g)}catch(u){let y=u instanceof d?u:new d("UNKNOWN",void 0,String(u));a.push(y),_optionalChain([i, 'access', _17 => _17.onError, 'optionalCall', _18 => _18(y)])}};if(D&&g>1&&t.length>1)m.info(`\u{1F680} Processing ${t.length} handles in parallel (custom implementation, concurrency=${g})`),await I(t,h,g);else{m.info(`\u{1F4DD} Processing ${t.length} handle directly`);for(let f of t)await h(f)}let x=[],b=[];r.updateTotalItems(c),m.info(`\u{1F504} Processing ${n.length} total items from traversal`);for(let f of n)if(f.type==="file"){let u=j(f.file,f.path.toString(),f.path.toString());x.push(u),_optionalChain([i, 'access', _19 => _19.onFile, 'optionalCall', _20 => _20(u)]),r.completeItem(),m.verbose(` \u2705 File: ${f.path.toString()}`)}else{let u={type:"directory",name:f.path.lastSegment(),path:f.path.toString(),pathSegments:f.path.segments,relativePath:f.path.toString()};b.push(u),m.verbose(` \u{1F4C1} Directory: ${f.path.toString()}`)}return m.info(`\u{1F4CA} Final results: ${x.length} files, ${b.length} directories`),{items:x,directories:b,errors:a}}async function B(t,e={}){let r=Date.now(),i=te(e.debug);try{if(_optionalChain([e, 'access', _21 => _21.signal, 'optionalAccess', _22 => _22.aborted]))throw new d("UNKNOWN",void 0,"Operation aborted");let s=await X(t);if(!s)throw new d("UNSUPPORTED_API",void 0,"Unsupported file drop source");let o=s.length,l=new L(o,e.callbacks),n=new H(e.filter);if(s.length>0&&s[0]instanceof File){let h=s,p=[],x=[];for(let f of h){if(_optionalChain([e, 'access', _23 => _23.signal, 'optionalAccess', _24 => _24.aborted]))throw new d("UNKNOWN",void 0,"Operation aborted");let u=j(f,f.name);l.setCurrentItem(u);let y=n.filter(u);y.accepted?(p.push(u),_optionalChain([e, 'access', _25 => _25.callbacks, 'optionalAccess', _26 => _26.onFile, 'optionalCall', _27 => _27(u)])):y.error&&(x.push(y.error),_optionalChain([e, 'access', _28 => _28.callbacks, 'optionalAccess', _29 => _29.onError, 'optionalCall', _30 => _30(y.error,u)])),l.completeItem()}let b=N(p);return{files:p,directories:[],tree:b,metadata:{totalFiles:p.length,totalDirectories:0,totalSize:p.reduce((f,u)=>f+(u.size||0),0),processingTime:Date.now()-r},errors:x}}let{items:a,directories:c,errors:I}=await Z(s,n,l,e.callbacks,e.signal,i,e.processing),g=[...a,...c],D=N(g);return{files:a,directories:c,tree:D,metadata:{totalFiles:a.length,totalDirectories:c.length,totalSize:a.reduce((h,p)=>h+(p.size||0),0),processingTime:Date.now()-r},errors:I}}catch(s){throw s instanceof d?s:new d("UNKNOWN",void 0,String(s))}}async function ee(t,e={}){try{return await B(t,e)}catch(r){return{success:!1,error:r instanceof d?r:new d("UNKNOWN",void 0,String(r))}}}function te(t){return t===!0?"verbose":t===!1?"none":t===void 0?"warn":t}exports.FileDropError = d; exports.FilePathUtils = F; exports.FilterPresets = Q; exports.PathHolder = S; exports.PathUtils = P; exports.buildFileTree = N; exports.filterTree = k; exports.findInTree = W; exports.flattenTree = J; exports.handleFileTreeDropEvent = K; exports.isValidFileName = _; exports.isValidFileSize = M; exports.isValidFileType = z; exports.processFileTreeDrop = B; exports.processFileTreeDropSafe = ee;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(...e){return e.filter(e=>e&&e.length>0&&e!==`.`).flatMap(e=>e.split(`/`)).filter(e=>e.length>0&&e!==`.`)}var t=class t{static join(...e){return t.split(...e).join(`/`)}static split=(...t)=>{let n=[];return t.forEach(t=>{Array.isArray(t)?t.forEach(t=>{typeof t==`string`&&t.length>0&&n.push(...e(t))}):typeof t==`string`&&t.length>0&&n.push(...e(t))}),n.filter(e=>typeof e==`string`&&e.length>0&&e!==`.`)};static pathStartsWith(e,n){return t.segmentsStartsWith(t.split(e),t.split(n))}static segmentsStartsWith(e,t){let n=e,r=t;return r.length>n.length?!1:r.every((e,t)=>e===n[t])}},n=class e{segments;path;constructor(e){this.segments=Array.isArray(e)?e:t.split(e),this.path=this.segments.join(`/`)}static EMPTY=new e([]);static from=(...n)=>new e(t.split(...n));join=(...n)=>{let r=t.split(...this.segments,...n);return new e(r)};changeLast=t=>{if(this.segments.length===0)return new e(t);let n=this.segments.slice();return n[n.length-1]=t,new e(n)};parentOrNull=()=>{if(this.segments.length===0)return null;let t=this.segments.slice(0,this.segments.length-1);return new e(t)};lastSegmentOrNull=()=>this.segments.length===0?null:this.segments[this.segments.length-1];lastSegment=()=>this.segments.length===0?``:this.segments[this.segments.length-1];startsWith=e=>typeof e==`string`?t.segmentsStartsWith(this.segments,t.split(e)):Array.isArray(e)?t.segmentsStartsWith(this.segments,e):t.segmentsStartsWith(this.segments,e.segments);toString(){return this.path}};const r=()=>{};function i(e=`warn`){let t=e!==`none`,n=e===`info`||e===`verbose`,i=e===`verbose`;return{info:n?(...e)=>console.log(...e):r,verbose:i?(...e)=>console.log(...e):r,debug:i?(...e)=>console.debug(...e):r,warn:t?(...e)=>console.warn(...e):r,error:n?(...e)=>console.error(...e):r}}function a(e){return e==null?`unknown`:typeof e==`string`?e:typeof e==`object`&&`message`in e&&typeof e.message==`string`?e.message:String(e)}async function o(e,t,n,r,a=`none`,l=!0,u=4){let d=i(a);if(t.isFile){let i=await s(t);if(!i){d.debug(`FileSystemEntry.getFile() error`,t);return}r(i)&&n.push({type:`file`,file:i,path:e.join(i.name)});return}if(!t.isDirectory)return;n.push({type:`dir`,path:e.join(t.name)});let f=e.join(t.name);d.info(`🔍 Traversing directory (Entry API): ${t.name} at path: ${f.toString()}`);let p=await c(t,a);d.verbose(` 📊 Total children found: ${p.length}`),p.forEach((e,t)=>{d.verbose(` 📄 Found [${t}]: ${e.name} (${e.isFile?`file`:`directory`})`)});let{simpleParallelMap:m}=await Promise.resolve().then(()=>require("../parallel-map-_ZhC5iBn.cjs")),h=Math.max(1,u);if(l&&h>1&&p.length>1)d.info(` ⚡ Processing ${p.length} items in parallel (custom implementation, concurrency=${h})`),await m(p,async e=>{(e.isFile||e.isDirectory)&&await o(f,e,n,r,a,l,h)},h);else{d.info(` 📝 Processing ${p.length} item directly`);for(let e of p)(e.isFile||e.isDirectory)&&await o(f,e,n,r,a,l,h)}}async function s(e){try{return await new Promise((t,n)=>{e.file(e=>{t(e)},e=>{n(e)})})}catch{return null}}async function c(e,t=`none`){let n=i(t);try{return await l(e,t)}catch(e){return n.debug(a(e)),[]}}async function l(e,t=`none`){let n=i(t),r=e.createReader(),a=[];async function o(){return new Promise((e,t)=>{r.readEntries(t=>{t.length>0?(a=a.concat(t),e(o())):e(a)},e=>{n.warn(`readEntries() error`,e),t(e)})})}return await o(),a}async function u(e,t,n,r,a=`none`,o=!0,s=4){let c=i(a);if(t.kind===`file`){let i=await t.getFile();if(!i)return;r(i)&&n.push({type:`file`,file:i,path:e.join(i.name)});return}if(t.kind!==`directory`)return;n.push({type:`dir`,path:e.join(t.name)});let l=e.join(t.name);try{let e=[],i=t.values();c.info(`🔍 Traversing directory: ${t.name} at path: ${l.toString()}`);for await(let t of i)t&&(e.push(t),c.verbose(` 📄 Found: ${t.name} (${t.kind})`));c.verbose(` 📊 Total children found: ${e.length}`);let{simpleParallelMap:d}=await Promise.resolve().then(()=>require("../parallel-map-_ZhC5iBn.cjs")),f=Math.max(1,s);if(o&&f>1&&e.length>1)c.info(` ⚡ Processing ${e.length} items in parallel (custom implementation, concurrency=${f})`),await d(e,async e=>{(e.kind===`file`||e.kind===`directory`)&&await u(l,e,n,r,a,o,f)},f);else{c.info(` 📝 Processing ${e.length} item directly`);for(let t of e)(t.kind===`file`||t.kind===`directory`)&&await u(l,t,n,r,a,o,f)}}catch(e){c.warn(`Directory traversal warning for ${t.name}:`,e)}}const d=(e,...t)=>t.every(t=>t in e);async function f(e,t,n,r,i=`none`,a=!0,s=4){if(d(t,`filesystem`,`fullPath`,`isDirectory`,`isFile`)){await o(e,t,n,r,i,a,s);return}if(d(t,`kind`,`isSameEntry`)){await u(e,t,n,r,i,a,s);return}let c=t;r(c)&&n.push({type:`file`,file:c,path:e.join(c.name)})}const p=e=>!0;async function m(e,t=p){let r=`getAsFileSystemHandle`in DataTransferItem.prototype,i=`webkitGetAsEntry`in DataTransferItem.prototype;if(!r&&!i){let r=Array.from(e.dataTransfer.files);return r.length===0?[]:r.filter(t).map(e=>({type:`file`,file:e,path:n.from(e.name).toString()}))}let a=[],o=Array.prototype.slice.call(e.dataTransfer.items).filter(e=>e.kind===`file`).map(e=>i?e.webkitGetAsEntry():r?e.getAsFileSystemHandle():e.getAsFile()).filter(Boolean),{simpleParallelMap:s}=await Promise.resolve().then(()=>require("../parallel-map-_ZhC5iBn.cjs"));if(o.length>1)await s(o,async e=>{let r=e;await f(n.EMPTY,r,a,t)},4);else for(let e of o){let r=e;await f(n.EMPTY,r,a,t)}return a.map(e=>({...e,path:e.path.toString()}))}var h=class extends Error{code;item;constructor(e,t,n){super(n||`File drop error: ${e}`),this.code=e,this.item=t,this.name=`FileDropError`}},g=class e{static normalize(e){return e.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`}static join(...t){return e.normalize(t.filter(Boolean).join(`/`))}static dirname(t){let n=e.normalize(t),r=n.lastIndexOf(`/`);return r<=0?`/`:n.slice(0,r)}static basename(t,n){let r=e.normalize(t).split(`/`).pop()||``;return n&&r.endsWith(n)?r.slice(0,-n.length):r}static extname(t){let n=e.basename(t),r=n.lastIndexOf(`.`);return r>0?n.slice(r):``}static relative(t,n){let r=e.normalize(t).split(`/`).filter(Boolean),i=e.normalize(n).split(`/`).filter(Boolean),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=r.length-a,s=i.slice(a);return[...Array(o).fill(`..`),...s].join(`/`)||`.`}};function _(e,t){if(t.length===0)return!0;let n=g.extname(e.name).toLowerCase();return t.some(e=>e.toLowerCase()===n||e.toLowerCase()===n.slice(1))}function v(e,t){return e.size<=t}function y(e){if(/[<>:"/\\|?*]/.test(e))return!1;for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=0&&n<=31)return!1}return e.trim().length>0}function b(e){return e.type?e.type:{".txt":`text/plain`,".js":`text/javascript`,".ts":`text/typescript`,".json":`application/json`,".html":`text/html`,".css":`text/css`,".md":`text/markdown`,".pdf":`application/pdf`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".svg":`image/svg+xml`}[g.extname(e.name).toLowerCase()]||`application/octet-stream`}function x(e,t,n=t){let r=g.extname(e.name),i=b(e);return{type:`file`,name:e.name,path:g.normalize(t),pathSegments:t.split(`/`).filter(Boolean),relativePath:g.normalize(n),size:e.size,lastModified:new Date(e.lastModified),file:e,mimeType:i,extension:r}}function S(e){let t=[];function n(e){let r={type:e.type,name:e.name,path:e.path,pathSegments:e.path.split(`/`).filter(Boolean),relativePath:e.path,size:e.metadata?.size,lastModified:e.metadata?.lastModified};t.push(r),e.children&&e.children.forEach(n)}return n(e),t}function C(e,t){if(!t(e))return null;let n=e.children?.map(e=>C(e,t)).filter(e=>e!==null);return{...e,children:n}}function w(e,t){if(t(e))return e;if(e.children)for(let n of e.children){let e=w(n,t);if(e)return e}return null}function T(e){let t={name:``,type:`directory`,path:``,children:[]},n=/* @__PURE__ */ new Map;n.set(``,t);let r=[...e].sort((e,t)=>e.pathSegments.length-t.pathSegments.length);for(let e of r){let r={name:e.name,type:e.type,path:e.path,metadata:e.size===void 0?void 0:{size:e.size,lastModified:e.lastModified,extension:g.extname(e.name),mimeType:e.mimeType},file:e.file};n.set(e.path,r);let i=g.dirname(e.path),a=n.get(i);if(!a&&i!==`/`&&i!==``){let e=i.split(`/`).filter(Boolean);a={name:e[e.length-1]||``,type:`directory`,path:i,children:[]},n.set(i,a)}!a&&(i===``||i===`/`)&&(a=t),a&&(a.children||(a.children=[]),a.children.push(r))}return t}var E=class{options;fileCount=0;constructor(e={}){this.options=e}filter(e){if(this.options.excludeDirectories&&e.type===`directory`)return{accepted:!1};if(e.type===`file`){let t=e.file;if(this.options.maxFiles&&this.fileCount>=this.options.maxFiles)return{accepted:!1,error:new h(`TOO_MANY_FILES`,e,`Maximum ${this.options.maxFiles} files allowed`)};if(this.options.maxSize&&!v(t,this.options.maxSize))return{accepted:!1,error:new h(`FILE_TOO_LARGE`,e,`File size ${t.size} exceeds limit ${this.options.maxSize}`)};if(this.options.allowedExtensions&&!_(t,this.options.allowedExtensions))return{accepted:!1,error:new h(`INVALID_FILE_TYPE`,e,`File type not allowed: ${t.name}`)};this.fileCount++}return this.options.accept&&!this.options.accept(e)?{accepted:!1}:{accepted:!0}}get currentFileCount(){return this.fileCount}reset(){this.fileCount=0}};const D={imagesOnly:()=>({allowedExtensions:[`.jpg`,`.jpeg`,`.png`,`.gif`,`.svg`,`.webp`],excludeDirectories:!0}),textOnly:()=>({allowedExtensions:[`.txt`,`.md`,`.json`,`.js`,`.ts`,`.html`,`.css`],excludeDirectories:!0}),smallFilesOnly:()=>({maxSize:1048576,excludeDirectories:!0}),developmentFiles:()=>({allowedExtensions:[`.js`,`.ts`,`.tsx`,`.jsx`,`.json`,`.md`,`.html`,`.css`,`.scss`,`.py`,`.java`,`.cpp`,`.c`,`.h`,`.yml`,`.yaml`,`.toml`]})};var O=class{startTime;totalItems;processedItems=0;currentItem;onProgress;constructor(e,t){this.totalItems=e,this.startTime=Date.now(),this.onProgress=t?.onProgress}setCurrentItem(e){this.currentItem=e,this.notifyProgress()}completeItem(){this.processedItems++,this.currentItem=void 0,this.notifyProgress()}notifyProgress(){if(!this.onProgress)return;let e=Date.now()-this.startTime,t=this.totalItems>0?Math.round(this.processedItems/this.totalItems*100):0,n;if(this.processedItems>0&&t<100){let t=e/this.processedItems,r=this.totalItems-this.processedItems;n=Math.round(t*r)}let r={totalItems:this.totalItems,processedItems:this.processedItems,currentItem:this.currentItem,percentage:t,estimatedTimeLeft:n};this.onProgress(r)}updateTotalItems(e){this.totalItems=e,this.notifyProgress()}get isComplete(){return this.processedItems>=this.totalItems}get elapsedTime(){return Date.now()-this.startTime}};async function k(e){if(`dataTransfer`in e){let t=`getAsFileSystemHandle`in DataTransferItem.prototype,n=`webkitGetAsEntry`in DataTransferItem.prototype;if(!t&&!n)return Array.from(e.dataTransfer.files);let r=Array.from(e.dataTransfer.items).filter(e=>e.kind===`file`).map(e=>n?e.webkitGetAsEntry():t?e.getAsFileSystemHandle():e.getAsFile()).filter(Boolean);return(await Promise.all(r.map(e=>e&&e instanceof Promise?e:Promise.resolve(e)))).filter(Boolean)}return`length`in e?Array.from(e):Array.isArray(e)?e:null}async function A(e,t,r,a={},o,s=`warn`,c){let l=[],u=[],d=0,{simpleParallelMap:p}=await Promise.resolve().then(()=>require("../parallel-map-_ZhC5iBn.cjs")),m=Math.max(1,c?.concurrency??4),g=c?.parallel??!0,_=i(s),v=async e=>{if(o?.aborted)throw new h(`UNKNOWN`,void 0,`Operation aborted`);try{await f(n.EMPTY,e,l,e=>{d++,r.updateTotalItems(d);let n=x(e,e.name);r.setCurrentItem(n);let i=t.filter(n);return i.error&&(u.push(i.error),a.onError?.(i.error,n)),i.accepted||r.completeItem(),i.accepted},s,g,m)}catch(e){let t=e instanceof h?e:new h(`UNKNOWN`,void 0,String(e));u.push(t),a.onError?.(t)}};if(g&&m>1&&e.length>1)_.info(`🚀 Processing ${e.length} handles in parallel (custom implementation, concurrency=${m})`),await p(e,v,m);else{_.info(`📝 Processing ${e.length} handle directly`);for(let t of e)await v(t)}let y=[],b=[];r.updateTotalItems(d),_.info(`🔄 Processing ${l.length} total items from traversal`);for(let e of l)if(e.type===`file`){let t=x(e.file,e.path.toString(),e.path.toString());y.push(t),a.onFile?.(t),r.completeItem(),_.verbose(` ✅ File: ${e.path.toString()}`)}else{let t={type:`directory`,name:e.path.lastSegment(),path:e.path.toString(),pathSegments:e.path.segments,relativePath:e.path.toString()};b.push(t),_.verbose(` 📁 Directory: ${e.path.toString()}`)}return _.info(`📊 Final results: ${y.length} files, ${b.length} directories`),{items:y,directories:b,errors:u}}async function j(e,t={}){let n=Date.now(),r=N(t.debug);try{if(t.signal?.aborted)throw new h(`UNKNOWN`,void 0,`Operation aborted`);let i=await k(e);if(!i)throw new h(`UNSUPPORTED_API`,void 0,`Unsupported file drop source`);let a=i.length,o=new O(a,t.callbacks),s=new E(t.filter);if(i.length>0&&i[0]instanceof File){let e=i,r=[],a=[];for(let n of e){if(t.signal?.aborted)throw new h(`UNKNOWN`,void 0,`Operation aborted`);let e=x(n,n.name);o.setCurrentItem(e);let i=s.filter(e);i.accepted?(r.push(e),t.callbacks?.onFile?.(e)):i.error&&(a.push(i.error),t.callbacks?.onError?.(i.error,e)),o.completeItem()}return{files:r,directories:[],tree:T(r),metadata:{totalFiles:r.length,totalDirectories:0,totalSize:r.reduce((e,t)=>e+(t.size||0),0),processingTime:Date.now()-n},errors:a}}let{items:c,directories:l,errors:u}=await A(i,s,o,t.callbacks,t.signal,r,t.processing);return{files:c,directories:l,tree:T([...c,...l]),metadata:{totalFiles:c.length,totalDirectories:l.length,totalSize:c.reduce((e,t)=>e+(t.size||0),0),processingTime:Date.now()-n},errors:u}}catch(e){throw e instanceof h?e:new h(`UNKNOWN`,void 0,String(e))}}async function M(e,t={}){try{return await j(e,t)}catch(e){return{success:!1,error:e instanceof h?e:new h(`UNKNOWN`,void 0,String(e))}}}function N(e){return e===!0?`verbose`:e===!1?`none`:e===void 0?`warn`:e}exports.FileDropError=h,exports.FilePathUtils=g,exports.FilterPresets=D,exports.PathHolder=n,exports.PathUtils=t,exports.buildFileTree=T,exports.filterTree=C,exports.findInTree=w,exports.flattenTree=S,exports.handleFileTreeDropEvent=m,exports.isValidFileName=y,exports.isValidFileSize=v,exports.isValidFileType=_,exports.processFileTreeDrop=j,exports.processFileTreeDropSafe=M;
2
2
  //# sourceMappingURL=index.cjs.map