open-grid 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  All notable changes to OPEN_GRID will be documented in this file.
4
4
 
5
+ ## [1.0.8] - 2026-07-01
6
+
7
+ ### Fixed
8
+ - **`grid.override('getDisplayValue')` 커스터마이징이 셀 화면에 반영되지 않던 버그 수정** —
9
+ 텍스트·불리언 등 셀 렌더 경로가 내부적으로 `getDisplayValue()`를 거치지 않아,
10
+ `getDisplayValue`를 오버라이드해도 셀에 표시되는 값이 바뀌지 않던 문제를 고쳤다.
11
+ 이제 렌더러가 인스턴스 콜백을 통해 `getDisplayValue()` 결과를 표시값으로 사용한다.
12
+ 오버라이드·전략이 등록되지 않은 경우 기존 렌더 경로로 폴백하므로 기존 동작은
13
+ 100% 보존된다(출력 바이트 동일, 회귀 없음). 단위 테스트 408건 통과.
14
+
15
+ ## [1.0.7] - 2026-06-27
16
+
17
+ ### Fixed
18
+ - **워크시트(다중 시트) 데이터 미표시 버그 수정** — `addWorksheet()`로 시트를 추가하거나 탭을
19
+ 전환할 때 헤더·탭은 그려지지만 **데이터 행이 렌더되지 않던** 문제를 고쳤다. 원인은 시트 전환
20
+ 콜백이 내부 데이터만 갱신하고 가상 스크롤(virtual scroll)의 총 행수를 갱신하지 않아 보이는
21
+ 행 범위가 비어 있었던 것. 시트 전환 시 `setData`와 동일한 경로(총 행수·aria·컬럼 폭 재계산)를
22
+ 거치도록 통합해 시트마다 컬럼 구성이 달라도 올바르게 표시된다.
23
+
24
+ ## [1.0.6] - 2026-06-26
25
+
26
+ ### Changed
27
+ - 메타데이터·문서 정리(기능·동작 변경 없음). 발행 패키지를 경량화(소스맵 제외)했다.
28
+
5
29
  ## [1.0.5] - 2026-06-24
6
30
 
7
31
  ### Changed
@@ -0,0 +1,90 @@
1
+ "use strict";class re{constructor(){this.listeners=new Map}on(t,e){const s=this.listeners.get(t)??[];return s.push({handler:e,once:!1}),this.listeners.set(t,s),this}once(t,e){const s=this.listeners.get(t)??[];return s.push({handler:e,once:!0}),this.listeners.set(t,s),this}off(t,e){if(!e)return this.listeners.delete(t),this;const s=this.listeners.get(t);if(s){const o=s.filter(i=>i.handler!==e);o.length===0?this.listeners.delete(t):this.listeners.set(t,o)}return this}emit(t,...e){const s=this.listeners.get(t);if(!s||s.length===0)return!1;const o=[];for(const i of s)i.handler(...e),i.once||o.push(i);return o.length!==s.length&&(o.length===0?this.listeners.delete(t):this.listeners.set(t,o)),!0}removeAllListeners(t){return t?this.listeners.delete(t):this.listeners.clear(),this}listenerCount(t){var e;return((e=this.listeners.get(t))==null?void 0:e.length)??0}}let le=0;function Dt(){return`og-r-${++le}`}class ae{constructor(t="_ogRowId"){this._data=[],this._original=[],this._meta=new Map,this._displayIndexes=[],this._idMap=new Map,this._findQuery="",this._findFields=[],this._getStrategy=(e,s)=>s,this._idField=t}setStrategyResolver(t){this._getStrategy=t}setData(t){this._data=t.map(e=>{const s=Dt(),o={...e,[this._idField]:s};return this._meta.set(s,{state:"none",rowId:s}),o}),this._original=this._data.map(e=>({...e})),this._rebuildIdMap(),this._displayIndexes=this._data.map((e,s)=>s)}getData(){return this._displayIndexes.map(t=>this._data[t])}getOriginalData(){return[...this._original]}getAllData(){return[...this._data]}clearData(){this._data=[],this._original=[],this._meta.clear(),this._idMap.clear(),this._displayIndexes=[]}get rowCount(){return this._displayIndexes.length}get totalRowCount(){return this._data.length}addRow(t,e="last"){const s=Dt(),o={...t,[this._idField]:s};if(this._meta.set(s,{state:"added",rowId:s}),e==="last"){const i=this._data.push(o)-1;this._idMap.set(s,i),this._displayIndexes.push(i)}else if(e==="first")this._data.unshift(o),this._rebuildIdMap(),this._displayIndexes.unshift(0);else{const i=Math.min(e,this._displayIndexes.length),n=i<this._displayIndexes.length?this._displayIndexes[i]:this._data.length;this._data.splice(n,0,o),this._rebuildIdMap(),this._displayIndexes=this._data.map((r,l)=>l)}}removeRow(t){const e=this._displayIndexes[t];if(e===void 0)return;const s=this._data[e],o=s[this._idField],i=this._meta.get(o);return(i==null?void 0:i.state)==="added"?(this._data.splice(e,1),this._meta.delete(o)):this._meta.set(o,{...i,state:"removed"}),this._rebuildIdMap(),this._displayIndexes=this._data.map((n,r)=>({r:n,i:r})).filter(({r:n})=>{var r;return((r=this._meta.get(n[this._idField]))==null?void 0:r.state)!=="removed"}).map(({i:n})=>n),s}moveRow(t,e){const s=this._displayIndexes[t],o=this._displayIndexes[e];if(s===void 0||o===void 0)return;const[i]=this._data.splice(s,1),n=s<o?o-1:o;this._data.splice(n,0,i),this._rebuildIdMap(),this._displayIndexes=this._data.map((r,l)=>({r,i:l})).filter(({r})=>{var l;return((l=this._meta.get(r[this._idField]))==null?void 0:l.state)!=="removed"}).map(({i:r})=>r)}updateCell(t,e,s){const o=this._displayIndexes[t];if(o===void 0)return!1;const n=this._data[o][this._idField],r=this._meta.get(n);return(r==null?void 0:r.state)==="none"&&this._meta.set(n,{...r,state:"edited",original:{...this._original[o]}}),this._data[o][e]=s,!0}getRowByIndex(t){const e=this._displayIndexes[t];return e!==void 0?this._data[e]:void 0}getCellValue(t,e){var s;return(s=this.getRowByIndex(t))==null?void 0:s[e]}getEditedRows(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="edited"})}getChangedRows(){return this.getEditedRows()}getAddedRows(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="added"})}getRemovedRows(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="removed"})}getChanges(){const t=[],e=[],s=[];for(const o of this._data){const i=o[this._idField],n=this._meta.get(i),r=(n==null?void 0:n.state)??"none";if(r==="added")t.push({...o});else if(r==="removed")s.push({...o});else if(r==="edited"){const l=n.original??{},a=Object.keys(o).filter(c=>c!==this._idField&&o[c]!==l[c]);e.push({...o,_changedFields:a})}}return{added:t,edited:e,removed:s}}getChangedColumns(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="edited"}).map(t=>{var o;const e=((o=this._meta.get(t[this._idField]))==null?void 0:o.original)??{},s=[];for(const i of Object.keys(t))i!==this._idField&&t[i]!==e[i]&&s.push({field:i,oldValue:e[i],newValue:t[i]});return{row:{...t},fields:s.map(i=>i.field),diff:s}})}getOriginalRow(t){const e=this._displayIndexes[t];if(e===void 0)return;const s=this._data[e],o=this._meta.get(s[this._idField]);if(!(!o||o.state==="added"))return o.state==="edited"&&o.original?{...o.original}:{...this._original[e]}}getRowsWithState(t){return this._data.map(e=>{var o;const s=((o=this._meta.get(e[this._idField]))==null?void 0:o.state)??"none";return{...e,[t]:s}})}getRowState(t){var s;const e=this.getRowByIndex(t);return e?((s=this._meta.get(e[this._idField]))==null?void 0:s.state)??"none":"none"}applySort(t){const e=i=>{var n,r;return((r=this._meta.get((n=this._data[i])==null?void 0:n[this._idField]))==null?void 0:r.state)!=="removed"};if(t.length===0){this._displayIndexes=this._data.map((i,n)=>n).filter(e);return}const s=this._displayIndexes.filter(e).map(i=>{const n=this._data[i];return{idx:i,keys:t.map(r=>n[r.field])}}),o=this._getStrategy("sortComparator",(i,n,r,l)=>{if(i==null&&n==null)return 0;if(i==null)return-1;if(n==null)return 1;if(typeof i=="number"&&typeof n=="number")return i-n;const a=String(i),c=String(n);return a<c?-1:a>c?1:0});s.sort((i,n)=>{for(let r=0;r<t.length;r++){const l=t[r].dir,a=t[r].field,c=i.keys[r],u=n.keys[r],h=o(c,u,a,l);if(h!==0)return l==="asc"?h:-h}return 0}),this._displayIndexes=s.map(i=>i.idx)}applyFilter(t){const e=Object.keys(t),s=this._getStrategy("filterPredicate",(o,i,n)=>de(o,i));this._displayIndexes=this._data.map((o,i)=>({r:o,i})).filter(({r:o})=>{var i;if(((i=this._meta.get(o[this._idField]))==null?void 0:i.state)==="removed"||e.length>0&&!e.every(n=>{const r=o[n];return t[n].every(l=>s(r,l,n))}))return!1;if(this._findQuery&&this._findFields.length>0){const n=this._findQuery;if(!this._findFields.some(l=>{const a=o[l];return a!=null&&String(a).toLowerCase().includes(n)}))return!1}return!0}).map(({i:o})=>o)}setFindFilter(t,e){this._findQuery=t.toLowerCase(),this._findFields=e}_rebuildIdMap(){this._idMap.clear(),this._data.forEach((t,e)=>{this._idMap.set(t[this._idField],e)})}}function de(d,t){const e=d,s=t.value;switch(t.operator){case"=":return e==s;case"!=":return e!=s;case">":return e>s;case">=":return e>=s;case"<":return e<s;case"<=":return e<=s;case"contains":return String(e).includes(String(s));case"startsWith":return String(e).startsWith(String(s));case"endsWith":return String(e).endsWith(String(s));default:return!0}}class ce{constructor(t,e){this._totalRows=0,this._scrollTop=0,this._viewportHeight=0,this._rafId=null,this._onScroll=()=>{this._scrollTop=this.container.scrollTop,this._scheduleRender()},this.container=t,this.rowHeight=e.rowHeight,this.overscan=e.overscan??5,this.onRender=e.onRender,this.container.addEventListener("scroll",this._onScroll,{passive:!0})}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null;const t=this.getVisibleRange();this.onRender(t.startIndex,t.endIndex)}))}getVisibleRange(){const t=Math.ceil(this._viewportHeight/this.rowHeight),e=Math.max(0,Math.floor(this._scrollTop/this.rowHeight)-this.overscan),s=Math.min(this._totalRows-1,e+t+this.overscan*2),o=e*this.rowHeight;return{startIndex:e,endIndex:s,offsetY:o}}setTotalRows(t){this._totalRows=t,this._updateSpacerHeight(),this._scheduleRender()}setViewportHeight(t){this._viewportHeight=t,this._scheduleRender()}setRowHeight(t){this.rowHeight=t,this._updateSpacerHeight(),this._scheduleRender()}scrollToRow(t){const e=t*this.rowHeight,s=e+this.rowHeight,o=this._scrollTop+this._viewportHeight;if(e<this._scrollTop)this._scrollTop=e,this.container.scrollTop=e;else if(s>o){const i=s-this._viewportHeight;this._scrollTop=i,this.container.scrollTop=i}}getTotalHeight(){return this._totalRows*this.rowHeight}_updateSpacerHeight(){const t=this.container.querySelector(".og-spacer");t&&(t.style.height=`${this.getTotalHeight()}px`)}destroy(){this.container.removeEventListener("scroll",this._onScroll),this._rafId!==null&&cancelAnimationFrame(this._rafId)}}class $t{constructor(t,e=0){this._flatLeaves=[],this._maxDepth=1,this._frozenCount=0,this._columns=t,this._frozenCount=e,this._process()}_process(){const t=[];let e=0;const s=(o,i)=>{for(const n of o)n.children&&n.children.length>0?(s(n.children,i+1),this._maxDepth=Math.max(this._maxDepth,i+1)):t.push({...n,_colIndex:e++,_depth:i,_leaf:!0})};this._maxDepth=1,s(this._columns,1),this._flatLeaves=t}get leaves(){return this._flatLeaves}get visibleLeaves(){return this._flatLeaves.filter(t=>!t.hidden)}get headerDepth(){return this._maxDepth}get frozenCount(){return this._frozenCount}setFrozen(t){this._frozenCount=t}setColumns(t){this._columns=t,this._process()}hideColumn(t){const e=Array.isArray(t)?t:[t];this._flatLeaves.forEach(s=>{e.includes(s.field)&&(s.hidden=!0)})}showColumn(t){const e=Array.isArray(t)?t:[t];this._flatLeaves.forEach(s=>{e.includes(s.field)&&(s.hidden=!1)})}addColumn(t,e="last"){e==="last"?this._columns.push(t):e==="first"?this._columns.unshift(t):this._columns.splice(e,0,t),this._process()}removeColumn(t){const e=s=>s.filter(o=>o.field===t?!1:(o.children&&(o.children=e(o.children)),!0));this._columns=e(this._columns),this._process()}getColumnByField(t){return this._flatLeaves.find(e=>e.field===t)}getColumnByIndex(t){return this._flatLeaves[t]}getColumnIndex(t){return this._flatLeaves.findIndex(e=>e.field===t)}buildHeaderCells(){const t=Array.from({length:this._maxDepth},()=>[]);let e=0;const s=(o,i)=>{let n=0;for(const r of o)if(!r.hidden)if(r.children&&r.children.length>0){const l=s(r.children,i+1);l>0&&(t[i-1].push({column:r,colIndex:e,depth:i,colSpan:l,rowSpan:1}),n+=l)}else t[i-1].push({column:r,colIndex:e++,depth:i,colSpan:1,rowSpan:this._maxDepth-i+1}),n++;return n};return s(this._columns,1),t}computeWidths(t,e=100){const s=this.visibleLeaves,o=s.filter(l=>l.flex),i=s.filter(l=>!l.flex&&l.width).reduce((l,a)=>l+a.width,0),n=o.reduce((l,a)=>l+(a.flex??1),0),r=Math.max(0,t-i);return s.map(l=>l.flex?Math.round(l.flex/n*r):l.width??e)}}class he{constructor(t,e,s){this._field="",this._outsideHandler=null,this._onApply=e,this._onClear=s,this._el=document.createElement("div"),this._el.className="og-filter-panel",this._el.style.cssText=`
2
+ position:absolute;z-index:1000;min-width:200px;max-width:280px;
3
+ background:var(--og-row-bg,#fff);border:1px solid var(--og-border-color,#e0e0e0);
4
+ border-radius:4px;box-shadow:0 4px 16px rgba(0,0,0,0.15);
5
+ padding:10px;box-sizing:border-box;display:none;font-size:13px;
6
+ `,t.appendChild(this._el)}open(t,e,s){var k;this._field=t,this._el.innerHTML="";const o=document.createElement("div");o.textContent="필터",o.style.cssText="font-weight:600;margin-bottom:8px;color:var(--og-text-color,#333);",this._el.appendChild(o);const i=document.createElement("div");i.style.cssText="display:flex;gap:4px;margin-bottom:6px;";const n=document.createElement("select");n.style.cssText="flex:1;padding:3px 4px;border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;font-size:12px;";const r=[{label:"포함",value:"contains"},{label:"같음",value:"="},{label:"같지 않음",value:"!="},{label:"시작",value:"startsWith"},{label:"끝남",value:"endsWith"},{label:"보다 큼",value:">"},{label:"보다 작음",value:"<"},{label:"이상",value:">="},{label:"이하",value:"<="}];for(const y of r){const b=document.createElement("option");b.value=y.value,b.textContent=y.label,n.appendChild(b)}s[0]&&(n.value=s[0].operator),i.appendChild(n),this._el.appendChild(i);const l=document.createElement("input");l.type="text",l.placeholder="필터 값 입력...",l.value=((k=s[0])==null?void 0:k.value)??"",l.style.cssText=`
7
+ width:100%;padding:4px 6px;border:1px solid var(--og-border-color,#e0e0e0);
8
+ border-radius:3px;font-size:12px;box-sizing:border-box;margin-bottom:8px;
9
+ outline:none;
10
+ `,l.addEventListener("keydown",y=>{y.key==="Enter"?u.click():y.key==="Escape"&&this.close()}),this._el.appendChild(l);const a=document.createElement("div");a.style.cssText="display:flex;gap:6px;justify-content:flex-end;";const c=document.createElement("button");c.textContent="초기화",c.style.cssText=`
11
+ padding:3px 10px;border:1px solid var(--og-border-color,#e0e0e0);
12
+ border-radius:3px;background:#fff;cursor:pointer;font-size:12px;color:#666;
13
+ `,c.addEventListener("click",()=>{this._onClear(this._field),this.close()});const u=document.createElement("button");u.textContent="적용",u.style.cssText=`
14
+ padding:3px 10px;border:1px solid var(--og-primary,#1976d2);
15
+ border-radius:3px;background:var(--og-primary,#1976d2);
16
+ color:#fff;cursor:pointer;font-size:12px;
17
+ `,u.addEventListener("click",()=>{const y=l.value.trim();y?this._onApply(this._field,[{operator:n.value,value:y}]):this._onClear(this._field),this.close()}),a.appendChild(c),a.appendChild(u),this._el.appendChild(a);const h=e.getBoundingClientRect(),g=this._el.parentElement.getBoundingClientRect();this._el.style.top=`${h.bottom-g.top+2}px`,this._el.style.left=`${Math.min(h.left-g.left,g.width-220)}px`,this._el.style.display="block",requestAnimationFrame(()=>l.focus()),this._outsideHandler&&document.removeEventListener("mousedown",this._outsideHandler),this._outsideHandler=y=>{!this._el.contains(y.target)&&y.target!==e&&this.close()},setTimeout(()=>document.addEventListener("mousedown",this._outsideHandler),0)}close(){this._el.style.display="none",this._outsideHandler&&(document.removeEventListener("mousedown",this._outsideHandler),this._outsideHandler=null)}get isOpen(){return this._el.style.display!=="none"}destroy(){this.close(),this._el.remove()}}const ue=10;function ge(d,t=ue){const e=Math.pow(10,t);return Math.round(d*e)/e}class C{constructor(t,e){this._c=t,this._s=e<0?0:e}static from(t){if(t instanceof C)return t;if(typeof t=="bigint")return new C(t,0);const e=String(t).trim();if(!e||e==="null"||e==="undefined"||e==="NaN")return new C(0n,0);const s=e.startsWith("-"),o=s?e.slice(1):e,i=o.indexOf(".");let n,r;if(i===-1)n=BigInt(o),r=0;else{const l=o.slice(i+1);n=BigInt(o.slice(0,i)+l),r=l.length}return new C(s?-n:n,r)}static zero(){return new C(0n,0)}static one(){return new C(1n,0)}static _align(t,e){return t._s===e._s?[t._c,e._c,t._s]:t._s>e._s?[t._c,e._c*10n**BigInt(t._s-e._s),t._s]:[t._c*10n**BigInt(e._s-t._s),e._c,e._s]}add(t){const[e,s,o]=C._align(this,C.from(t));return new C(e+s,o)}sub(t){const[e,s,o]=C._align(this,C.from(t));return new C(e-s,o)}mul(t){const e=C.from(t);return new C(this._c*e._c,this._s+e._s)}div(t,e=20){const s=C.from(t);if(s._c===0n)throw new Error("OGDecimal: division by zero");const i=this._c*10n**BigInt(e+s._s)/s._c;return new C(i,e+this._s)}mod(t){const e=C.from(t),[s,o,i]=C._align(this,e);return new C(s%o,i)}neg(){return new C(-this._c,this._s)}abs(){return new C(this._c<0n?-this._c:this._c,this._s)}eq(t){const[e,s]=C._align(this,C.from(t));return e===s}gt(t){const[e,s]=C._align(this,C.from(t));return e>s}lt(t){const[e,s]=C._align(this,C.from(t));return e<s}gte(t){return!this.lt(t)}lte(t){return!this.gt(t)}isZero(){return this._c===0n}isNeg(){return this._c<0n}isPos(){return this._c>0n}toFixed(t){let e=this._c,s=this._s;if(s<t)e=e*10n**BigInt(t-s);else if(s>t){const c=10n**BigInt(s-t),u=c/2n,h=e<0n,g=h?-e:e,k=g%c;let y=g/c;k>=u&&(y+=1n),e=h?-y:y}s=t;const o=e<0n,n=(o?-e:e).toString().padStart(t+1,"0"),r=n.slice(0,n.length-t)||"0",l=t>0?"."+n.slice(n.length-t):"";return(o?"-":"")+r+l}toString(){if(this._s===0)return this._c.toString();let t=this._c,e=this._s;for(;e>0&&t!==0n&&t%10n===0n;)t/=10n,e--;return new C(t,e).toFixed(e)}toNumber(){return parseFloat(this.toFixed(20))}static sum(t){return t.reduce((e,s)=>e.add(s),C.zero())}static avg(t,e=20){return t.length?C.sum(t).div(t.length,e):C.zero()}static min(t){if(!t.length)throw new Error("OGDecimal.min: empty array");return t.map(C.from).reduce((e,s)=>e.lt(s)?e:s)}static max(t){if(!t.length)throw new Error("OGDecimal.max: empty array");return t.map(C.from).reduce((e,s)=>e.gt(s)?e:s)}}function Xt(d,t,e=30){return new pe(d,t,e).parse()}class pe{constructor(t,e,s){this._ctx=e,this._prec=s,this._pos=0,this._src=t.trim()}parse(){const t=this._additive();if(this._skip(),this._pos<this._src.length)throw new SyntaxError(`FormulaEngine: 예상치 못한 토큰 '${this._src[this._pos]}' (위치 ${this._pos})`);return t}_additive(){let t=this._multiplicative();for(this._skip();this._pos<this._src.length;){const e=this._src[this._pos];if(e!=="+"&&e!=="-")break;this._pos++,this._skip();const s=this._multiplicative();t=e==="+"?t.add(s):t.sub(s),this._skip()}return t}_multiplicative(){let t=this._unary();for(this._skip();this._pos<this._src.length;){const e=this._src[this._pos];if(e!=="*"&&e!=="/"&&e!=="%")break;this._pos++,this._skip();const s=this._unary();e==="*"?t=t.mul(s):e==="/"?t=t.div(s,this._prec):t=t.mod(s),this._skip()}return t}_unary(){return this._skip(),this._src[this._pos]==="-"?(this._pos++,this._unary().neg()):this._primary()}_primary(){this._skip();const t=this._src[this._pos];if(t==="("){this._pos++;const e=this._additive();if(this._skip(),this._src[this._pos]!==")")throw new SyntaxError("FormulaEngine: 닫는 괄호 ) 누락");return this._pos++,e}return t==="["?this._fieldRef():this._literal()}_fieldRef(){this._pos++;const t=this._pos;for(;this._pos<this._src.length&&this._src[this._pos]!=="]";)this._pos++;if(this._pos>=this._src.length)throw new SyntaxError("FormulaEngine: 닫는 ] 누락");const e=this._src.slice(t,this._pos);this._pos++;const s=this._ctx[e];if(s==null)throw new ReferenceError(`FormulaEngine: 필드 '[${e}]'가 행 데이터에 없습니다`);return C.from(s)}_literal(){const t=this._pos;for(;this._pos<this._src.length&&/[0-9.]/.test(this._src[this._pos]);)this._pos++;const e=this._src.slice(t,this._pos);if(!e)throw new SyntaxError(`FormulaEngine: 숫자 또는 [필드]를 기대했지만 '${this._src[this._pos]??"EOF"}' 발견 (위치 ${t})`);return C.from(e)}_skip(){for(;this._pos<this._src.length&&/\s/.test(this._src[this._pos]);)this._pos++}}function Rt(d,t){if(d==null||d==="")return d??"";const e=typeof t=="string"?{type:t}:t,s=e.char??"*";switch(e.type){case"ssn":return _e(d,s);case"phone":case"mobile":return fe(d,s);case"email":return me(d,s);case"credit":return ye(d,s);case"account":return we(d,s,e.visiblePrefix??3,e.visibleSuffix??4);case"password":return s.repeat(Math.max(d.length,6));case"name":return be(d,s);case"ip":return ve(d,s);case"partial":return lt(d,s,e.visiblePrefix??0,e.visibleSuffix??4);default:return d}}function _e(d,t){const e=d.replace(/[^0-9]/g,"");if(e.length<7){const n=d.includes("-")?"-":"",r=d.indexOf("-")>=0?d.indexOf("-"):6;return d.slice(0,r)+n+t.repeat(Math.max(1,d.length-r-n.length))}const s=e.slice(0,6),o=e[6],i=e.length-7;return`${s}-${o}${t.repeat(i)}`}function fe(d,t){const e=d.replace(/[^0-9]/g,"");return e.length===11?`${e.slice(0,3)}-${t.repeat(4)}-${e.slice(7)}`:e.length===10?e.startsWith("02")?`${e.slice(0,2)}-${t.repeat(4)}-${e.slice(6)}`:`${e.slice(0,3)}-${t.repeat(3)}-${e.slice(6)}`:e.length===9?`${e.slice(0,2)}-${t.repeat(3)}-${e.slice(5)}`:lt(d,t,3,4)}function me(d,t){const e=d.indexOf("@");if(e<0)return lt(d,t,2,0);const s=d.slice(0,e),o=d.slice(e),i=Math.min(2,s.length),n=s.slice(0,i),r=Math.max(s.length-i,3);return`${n}${t.repeat(r)}${o}`}function ye(d,t){const e=d.replace(/[^0-9]/g,"");if(e.length<8)return d;const s=e.slice(0,4),o=e.slice(-4),i=e.length-8,n=t.repeat(Math.max(i,8)),r=[s];for(let l=0;l<n.length;l+=4){const a=n.slice(l,l+4);a&&r.push(a)}return r.push(o),r.join("-")}function we(d,t,e,s){const o=d.replace(/[^0-9]/g,"");if(o.length<=e+s)return lt(o,t,e,s);const i=o.slice(0,e),n=o.slice(-s),r=o.length-e-s;return`${i}-${t.repeat(r)}-${n}`}function be(d,t){const e=d.trim();return e.length===0?d:e.length===1?t:e.length===2?`${e[0]}${t}`:`${e[0]}${t.repeat(e.length-2)}${e[e.length-1]}`}function ve(d,t){const e=d.split(".");if(e.length!==4)return lt(d,t,3,0);const s=o=>t.repeat(Math.max(o.length,3));return`${e[0]}.${e[1]}.${s(e[2])}.${s(e[3])}`}function lt(d,t,e,s){if(d.length<=e+s)return d;const o=d.slice(0,e),i=s>0?d.slice(-s):"",n=d.length-e-s;return`${o}${t.repeat(n)}${i}`}let nt=null;function xe(d){nt=d}function Yt(d){const t=d.column;if(!t.formula)return null;const e=t.formulaPrecision??30;try{let s;return typeof t.formula=="function"?s=t.formula(d.row,C):s=Xt(t.formula,d.row,e),s instanceof C?t.precision!=null?s.toFixed(t.precision):s.toString():typeof s=="string"?s:t.precision!=null?C.from(s).toFixed(t.precision):String(s)}catch(s){return console.warn("[OpenGrid] Formula error:",s),"#ERR"}}function Ce(d,t,e,s,o,i){if(nt){const p=nt(d,o??"",i);if(p!=null)return p}if(d==null||d==="")return"";let n=Number(d);if(isNaN(n))return String(d);if(e!=null&&(n=ge(n,e)),s)try{return new Intl.NumberFormat(void 0,{style:"currency",currency:s,...e!=null?{minimumFractionDigits:e,maximumFractionDigits:e}:{}}).format(n)}catch{}if(!t)return e!=null?n.toFixed(e):String(n);const r=t.indexOf(";"),l=r>=0?t.slice(r+1):null,a=n<0&&l!=null?l:r>=0?t.slice(0,r):t,c=n<0&&l!=null?Math.abs(n):n,u=a.match(/[#0][#0,]*(?:\.[#0]+)?/);if(!u)return String(n);const h=u[0],g=a.slice(0,u.index),k=a.slice(u.index+h.length),y=h.includes(","),b=h.includes(".")?h.split(".")[1].length:e??0,x=c.toLocaleString("ko-KR",{minimumFractionDigits:b,maximumFractionDigits:b,useGrouping:y});return g+x+k}function Jt(d,t="yyyy-MM-dd",e,s){if(nt){const l=nt(d,e??"",s);if(l!=null)return l}if(!d)return"";const o=d instanceof Date?d:new Date(d);if(isNaN(o.getTime()))return String(d);const i=o.getFullYear(),n=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0");return t.replace("yyyy",String(i)).replace("MM",n).replace("dd",r)}function Me(d,t,e){const s=Rt(d,t.mask),o=document.createElement("span");o.style.cssText="display:flex;align-items:center;gap:3px;overflow:hidden;width:100%;box-sizing:border-box;";const i=document.createElement("span");i.style.cssText="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:monospace;letter-spacing:0.4px;color:var(--og-mask-text,#888);",i.textContent=s;const n=document.createElement("button");return n.title="클릭하면 원문 표시",n.setAttribute("aria-label","마스킹 해제"),n.innerHTML='<svg width="13" height="13" viewBox="0 0 16 16" fill="currentColor"><path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8z"/><path d="M8 5.5A2.5 2.5 0 1 0 8 10.5 2.5 2.5 0 0 0 8 5.5zm0 4A1.5 1.5 0 1 1 8 6.5a1.5 1.5 0 0 1 0 3z" fill="#fff"/></svg>',n.style.cssText="flex-shrink:0;background:none;border:none;cursor:pointer;color:#c0c0c0;padding:1px 2px;line-height:0;border-radius:3px;display:flex;align-items:center;",n.addEventListener("mouseover",()=>{n.style.color="var(--og-primary,#1976d2)",n.style.background="rgba(25,118,210,0.08)"}),n.addEventListener("mouseout",()=>{n.style.color="#c0c0c0",n.style.background="none"}),n.addEventListener("click",r=>{r.stopPropagation(),i.textContent=d,i.style.fontFamily="",i.style.letterSpacing="",i.style.color="",n.remove(),(t._maskRevealedRows??(t._maskRevealedRows=new Set)).add(e)}),o.appendChild(i),o.appendChild(n),o}class gt{render(t){var l;const e=document.createElement("span");e.className="og-cell-text";const s=Yt(t);if(s!==null)return e.textContent=s,e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",e;const{value:o,column:i,rowIndex:n}=t;if(t.displayValue!=null)return e.textContent=t.displayValue,e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",e;let r;if(i.valueMap&&o!=null&&i.valueMap[o]?r=i.valueMap[o]:r=o==null?"":String(o),i.mask){const a=i._maskRevealed===!0,c=((l=i._maskRevealedRows)==null?void 0:l.has(n))===!0;if(!a&&!c)return Me(r,i,n)}return e.textContent=r,e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",e}}class ke{constructor(t=[],e){this._opts=t.map(s=>typeof s=="string"?{label:s,value:s}:{label:s.label??s.text??String(s.value??""),value:s.value}),this._fn=e??null}render(t){const e=document.createElement("span");e.className="og-cell-text",e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;";const s=t.value;if(s==null||s==="")return e;const o=String(s),n=(this._fn?this._fn(t.row,t.rowIndex).map(r=>typeof r=="string"?{label:r,value:r}:{label:r.label??r.text??String(r.value??""),value:r.value}):this._opts).find(r=>String(r.value)===o);return e.textContent=n?n.label:o,e}}class pt{render(t){const e=document.createElement("span");e.className="og-cell-number";const s=Yt(t);return s!==null?(e.textContent=s,e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;",e):(e.textContent=Ce(t.value,t.column.format??"#,##0",t.column.precision,t.column.currency,t.column.field,t.row),e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;",e)}}class _t{render(t){const e=document.createElement("span");return e.className="og-cell-date",e.textContent=Jt(t.value,t.column.format,t.column.field,t.row),e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",e}}class ft{render(t){const e=document.createElement("span");e.className="og-cell-checkbox",e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("input");return s.type="checkbox",s.checked=!!t.value,s.disabled=!0,s.style.cssText+="cursor:pointer;pointer-events:none;",e.appendChild(s),e}}class At{constructor(t){this.def=t}render(t){var i,n,r;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("button");s.className=`og-cell-btn${(i=this.def)!=null&&i.buttonClass?" "+this.def.buttonClass:""}`;const o=(n=this.def)==null?void 0:n.label;return typeof o=="function"?s.textContent=o(t.value,t.row):s.textContent=o??String(t.value??"btn"),s.style.cssText=`
18
+ padding:2px 10px;border:1px solid var(--og-primary,#1976d2);
19
+ border-radius:4px;background:var(--og-row-bg,#fff);color:var(--og-primary,#1976d2);
20
+ cursor:pointer;font-size:12px;white-space:nowrap;transition:background 0.12s;
21
+ ${((r=this.def)==null?void 0:r.style)??""}
22
+ `,s.addEventListener("mouseover",()=>s.style.background="var(--og-primary-light,#e3f2fd)"),s.addEventListener("mouseout",()=>s.style.background="var(--og-row-bg,#fff)"),e.appendChild(s),e}}class Ht{constructor(t,e){this.colorMap=t,this.labelMap=e}render(t){var r,l,a;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;height:100%;";const s=document.createElement("span"),o=t.value==null?"":String(t.value),i=((r=this.labelMap)==null?void 0:r[o])??((l=t.column.valueMap)==null?void 0:l[o])??o;s.textContent=i;const n=((a=this.colorMap)==null?void 0:a[o])??"#666";return s.style.cssText=`
23
+ display:inline-block;padding:2px 8px;border-radius:12px;font-size:11px;
24
+ background:${n}22;color:${n};border:1px solid ${n}66;
25
+ white-space:nowrap;
26
+ `,e.appendChild(s),e}}class zt{constructor(t,e){this.hrefFn=t,this.target=e}render(t){const e=document.createElement("a");return e.className="og-cell-link",e.textContent=t.value==null?"":String(t.value),e.href=this.hrefFn?this.hrefFn(t.value,t.row):"#",this.target&&(e.target=this.target),e.style.cssText="color:var(--og-primary,#1976d2);text-decoration:underline;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",this.hrefFn||e.addEventListener("click",s=>s.preventDefault()),e}}class Re{constructor(t){this.templateFn=t}render(t){const e=document.createElement("div");return e.className="og-cell-template",e.style.cssText="display:flex;align-items:center;height:100%;overflow:hidden;",e.innerHTML=this.templateFn(t.value,t.row,t.rowIndex),e}}class Ee{constructor(t){this.def=t}render(t){var a,c,u,h,g;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("img"),o=(a=this.def)!=null&&a.srcFn?this.def.srcFn(t.value,t.row):String(t.value??"");s.src=o;const i=((c=this.def)==null?void 0:c.width)??28,n=((u=this.def)==null?void 0:u.height)??28,r=((h=this.def)==null?void 0:h.radius)??4;s.style.cssText=`width:${i}px;height:${n}px;object-fit:cover;border-radius:${r}px;display:block;`;const l=(g=this.def)==null?void 0:g.alt;return s.alt=typeof l=="function"?l(t.value,t.row):l??"",s.onerror=()=>{s.style.display="none"},e.appendChild(s),e}}class Se{constructor(t){this.def=t}render(t){var a,c,u,h;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;gap:5px;width:100%;padding:0 4px;box-sizing:border-box;";const s=((a=this.def)==null?void 0:a.max)??100,o=Number(t.value)||0,i=Math.min(100,Math.max(0,o/s*100)),n=(c=this.def)!=null&&c.colorFn?this.def.colorFn(o):((u=this.def)==null?void 0:u.color)??"var(--og-primary,#1976d2)",r=document.createElement("div");r.className="og-progress-track",r.style.cssText="flex:1;height:10px;background:#e0e0e0;border-radius:5px;overflow:hidden;";const l=document.createElement("div");if(l.className="og-progress-fill",l.style.cssText=`width:${i}%;height:100%;background:${n};border-radius:5px;`,r.appendChild(l),e.appendChild(r),((h=this.def)==null?void 0:h.showLabel)!==!1){const g=document.createElement("span");g.style.cssText="font-size:11px;color:#666;white-space:nowrap;min-width:28px;text-align:right;",g.textContent=`${Math.round(i)}%`,e.appendChild(g)}return e}}class Le{constructor(t){this.def=t}render(t){var c,u,h,g;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=Array.isArray(t.value)?t.value.map(Number):[];if(!s.length)return e.textContent="-",e;const o=((c=this.def)==null?void 0:c.width)??80,i=((u=this.def)==null?void 0:u.height)??22,n=((h=this.def)==null?void 0:h.color)??"#1976d2",r=((g=this.def)==null?void 0:g.chartType)??"bar",l=document.createElement("canvas");l.width=o,l.height=i,l.style.cssText="display:block;";const a=l.getContext("2d");if(a){const k=Math.max(...s,1),y=Math.min(...s,0),b=k-y||1,x=s.length;if(r==="bar"){const p=o/x;s.forEach((v,T)=>{const A=(v-y)/b*(i-2);a.fillStyle=n,a.fillRect(T*p+1,i-A-1,p-2,A)})}else{const p=s.map((v,T)=>({x:T/(x-1||1)*o,y:i-(v-y)/b*(i-4)-2}));r==="area"&&(a.fillStyle=n+"33",a.beginPath(),a.moveTo(p[0].x,i),p.forEach(v=>a.lineTo(v.x,v.y)),a.lineTo(p[p.length-1].x,i),a.closePath(),a.fill()),a.strokeStyle=n,a.lineWidth=1.5,a.beginPath(),p.forEach((v,T)=>T===0?a.moveTo(v.x,v.y):a.lineTo(v.x,v.y)),a.stroke()}}return e.appendChild(l),e}}class It{render(t){const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=!!t.value,o=document.createElement("span");o.className="og-switch"+(s?" og-switch--on":""),o.style.cssText=`display:inline-block;width:34px;height:18px;border-radius:9px;
27
+ background:${s?"var(--og-primary,#1976d2)":"#bdbdbd"};
28
+ position:relative;transition:background 0.2s;cursor:pointer;flex-shrink:0;pointer-events:none;`;const i=document.createElement("span");return i.style.cssText=`position:absolute;top:2px;left:${s?"16px":"2px"};
29
+ width:14px;height:14px;border-radius:50%;background:#fff;
30
+ transition:left 0.2s;box-shadow:0 1px 3px rgba(0,0,0,0.3);`,o.appendChild(i),e.appendChild(o),e}}class Te{constructor(t){this.def=t}render(t){var n,r;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;gap:1px;height:100%;";const s=((n=this.def)==null?void 0:n.max)??5,o=Math.round(Number(t.value)||0),i=((r=this.def)==null?void 0:r.color)??"#ffa000";for(let l=1;l<=s;l++){const a=document.createElement("span");a.textContent="★",a.style.cssText=`font-size:14px;color:${l<=o?i:"#e0e0e0"};line-height:1;`,e.appendChild(a)}return e}}class mt{render(t){const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;pointer-events:none;";const s=document.createElement("input");return s.type="radio",s.checked=!!t.value,s.setAttribute("aria-checked",t.value?"true":"false"),s.setAttribute("aria-label",t.column.header??"선택"),t.column.group&&(s.name=`og-radio-${t.rowIndex}-${t.column.group}`),s.style.cssText="width:14px;height:14px;cursor:pointer;accent-color:var(--og-primary,#1976d2);",e.appendChild(s),e}}class yt{render(t){const e=document.createElement("span");if(e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;overflow:hidden;",!t.value)return e;const s=document.createElement("img");return s.src=String(t.value),s.alt=t.column.alt??t.column.field,s.style.cssText="max-width:100%;max-height:100%;object-fit:contain;display:block;",s.setAttribute("role","img"),e.appendChild(s),e}}function Fe(d){const t=document.createElement("div");return t.innerHTML=d,t.querySelectorAll("script,iframe,object,embed").forEach(e=>e.remove()),t.querySelectorAll("*").forEach(e=>{for(const s of[...e.attributes])s.name.startsWith("on")&&e.removeAttribute(s.name);if(e.tagName==="A"){const s=e.getAttribute("href")??"";/^javascript:/i.test(s)&&e.removeAttribute("href")}}),t.innerHTML}class wt{render(t){const e=document.createElement("span");e.style.cssText="display:block;overflow:hidden;width:100%;";const s=t.column.sanitize!==!1,o=String(t.value??"");return e.innerHTML=s?Fe(o):o,e}}const De=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232"],$e="2331112";function Bt(d){let t="",e=!0;for(const s of d)t+=(e?"1":"0").repeat(+s),e=!e;return t}function Ae(d){const t=[104];for(const s of d){const o=s.charCodeAt(0)-32;o>=0&&o<=94&&t.push(o)}let e=104;for(let s=1;s<t.length;s++)e+=t[s]*s;return t.push(e%103),t.map(s=>Bt(De[s])).join("")+Bt($e)+"11"}class bt{render(t){const e=String(t.value??""),s=t.column.barcodeHeight??28,o=document.createElement("div");o.style.cssText="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;overflow:hidden;gap:1px;",o.setAttribute("role","img"),o.setAttribute("aria-label",`바코드: ${e}`),o.innerHTML=He(e,s);const i=document.createElement("span");return i.textContent=e,i.style.cssText="font-size:9px;font-family:monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;",o.appendChild(i),o}}function He(d,t){if(!d)return"";const e=Ae(d),s=1.4,o=6,i=e.length*s+o*2,n=[];let r=0,l=o;for(;r<e.length;)if(e[r]==="1"){let a=0;for(;r+a<e.length&&e[r+a]==="1";)a++;n.push(`<rect x="${l.toFixed(2)}" y="0" width="${(a*s).toFixed(2)}" height="${t}"/>`),l+=a*s,r+=a}else l+=s,r++;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${i.toFixed(2)} ${t}" width="${i.toFixed(2)}" height="${t}" style="display:block" aria-hidden="true"><g fill="currentColor">${n.join("")}</g></svg>`}function ze(d){const t=d.renderer;if(!t)switch(d.type){case"number":return new pt;case"date":return new _t;case"boolean":return new ft;case"radio":return new mt;case"img":return new yt;case"html":return new wt;case"barcode":return new bt;case"select":return new ke(d.options??[],d.optionsFn);default:return new gt}if(typeof t=="string")switch(t){case"number":return new pt;case"date":return new _t;case"checkbox":return new ft;case"button":return new At;case"link":return new zt;case"badge":return new Ht;case"switch":return new It;case"radio":return new mt;case"img":return new yt;case"html":return new wt;case"barcode":return new bt;default:return new gt}switch(t.type){case"button":return new At(t);case"checkbox":return new ft;case"link":return new zt(t.hrefFn,t.target);case"template":return new Re(t.templateFn);case"badge":return new Ht(t.colorMap,t.labelMap??t.valueMap);case"image":return new Ee(t);case"progress":return new Se(t);case"sparkline":return new Le(t);case"switch":return new It;case"rating":return new Te(t);case"number":return new pt;case"date":return new _t;case"radio":return new mt;case"img":return new yt;case"html":return new wt;case"barcode":return new bt;default:return new gt}}class Ie{constructor(t,e,s){this._cellMap=new Map,this._root=t,this._opts=e,this._cbs=s,this._header=D("div","og-header"),this._header.style.cssText="flex-shrink:0;overflow-x:auto;overflow-y:hidden;border:0;border-bottom:1px solid var(--og-border-color,#e0e0e0);scrollbar-width:none;",this._bodyWrap=D("div","og-body-wrapper"),this._bodyWrap.style.cssText="flex:1;overflow:auto;position:relative;",this._bodyWrap.style.setProperty("--scrollbar-size","8px"),this._body=D("div","og-body"),this._body.style.cssText="position:relative;",this._bodyWrap.appendChild(this._body),t.appendChild(this._header),t.appendChild(this._bodyWrap),this._bodyWrap.addEventListener("scroll",()=>{this._header.scrollLeft=this._bodyWrap.scrollLeft},{passive:!0})}get bodyWrapper(){return this._bodyWrap}updateSize(t,e){this._bodyWrap.style.height=`${t-e}px`}getHeaderHeight(){return this._header.offsetHeight}renderHeader(t,e,s,o,i){var g,k;this._header.innerHTML="";const n=i._frozenCount??0;let r=0;i.stateColumn&&(r+=24),i.draggable&&(r+=18),i.rowNumber&&(r+=44),i.checkColumn&&(r+=36);const l=r+e.reduce((y,b,x)=>y+(s[x]??i.defaultColumnWidth),0);this._header.style.background="var(--og-header-bg,#f5f5f5)";const a=D("table","og-header-table");a.setAttribute("role","presentation"),a.style.cssText=`table-layout:fixed;border-collapse:collapse;border-spacing:0;margin:0;width:${l}px;background:var(--og-header-bg,#f5f5f5);`;const c=t.length;let u=0;const h=(y,b,x,p="")=>{const v=D("th",`og-header-cell og-extra-col ${p}`);v.setAttribute("rowspan",String(c)),v.textContent=x,Wt(v,{width:`${b}px`,minWidth:`${b}px`,textAlign:"center",borderRight:"1px solid var(--og-border-color,#e0e0e0)",borderBottom:"1px solid var(--og-border-color,#e0e0e0)",borderTop:"0",borderLeft:"0",lineHeight:"normal",verticalAlign:"middle",padding:"0",fontSize:"11px",color:"#999",userSelect:"none",boxSizing:"border-box",background:"var(--og-header-bg,#f5f5f5)"}),n>0&&(v.style.position="sticky",v.style.left=`${u}px`,v.style.zIndex="4"),u+=b,y.appendChild(v)};for(let y=0;y<t.length;y++){const b=D("tr","og-header-row");if(b.style.height=`${i.headerHeight}px`,y===0&&(i.stateColumn&&h(b,24,""),i.draggable&&h(b,18,""),i.rowNumber&&h(b,44,"No"),i.checkColumn)){const x=D("th","og-header-cell og-extra-col");x.setAttribute("rowspan",String(c)),x.style.cssText="width:36px;min-width:36px;text-align:center;border-right:1px solid var(--og-border-color,#e0e0e0);border-bottom:1px solid var(--og-border-color,#e0e0e0);border-top:0;border-left:0;line-height:normal;vertical-align:middle;background:var(--og-header-bg,#f5f5f5);box-sizing:border-box;",n>0&&(x.style.position="sticky",x.style.left=`${u}px`,x.style.zIndex="4"),u+=36;const p=document.createElement("input");p.type="checkbox",p.setAttribute("aria-label","전체 행 선택"),p.style.cssText="width:16px;height:16px;",p.addEventListener("change",()=>this._cbs.onAllCheck(p.checked)),x.appendChild(p),b.appendChild(x)}for(const x of t[y]??[]){const p=D("th","og-header-cell"),v=x.column;x.colSpan>1&&(p.colSpan=x.colSpan),x.rowSpan>1&&(p.rowSpan=x.rowSpan);const T=x.colSpan===1?e.findIndex(_=>_.field===v.field):-1;if(x.colSpan===1){const _=T>=0?s[T]??i.defaultColumnWidth:v.width??i.defaultColumnWidth;p.style.width=`${_}px`,p.style.minWidth=`${_}px`}const A=o.find(_=>_.field===v.field),E=v.sortable!==!1&&i.sortable&&x.colSpan===1;if(p.setAttribute("role","columnheader"),p.setAttribute("scope","col"),E&&(p.setAttribute("aria-sort",A?A.dir==="asc"?"ascending":"descending":"none"),p.tabIndex=T===0?0:-1,p.addEventListener("keydown",_=>{if(_.key==="Enter"||_.key===" ")_.preventDefault(),this._cbs.onHeaderClick(v.field,_.shiftKey);else if(_.key==="ArrowRight"){_.preventDefault();const M=p.nextElementSibling;(M==null?void 0:M.tagName)==="TH"&&M.focus()}else if(_.key==="ArrowLeft"){_.preventDefault();const M=p.previousElementSibling;(M==null?void 0:M.tagName)==="TH"&&M.focus()}})),T>=0&&T<n){let _=0;i.stateColumn&&(_+=24),i.draggable&&(_+=18),i.rowNumber&&(_+=44),i.checkColumn&&(_+=36);for(let M=0;M<T;M++)_+=s[M]??i.defaultColumnWidth;p.classList.add("og-frozen"),T===n-1&&p.classList.add("og-frozen-last"),p.style.left=`${_}px`}const f=v.header??v.field,$=typeof f=="string"&&f.indexOf(`
31
+ `)>=0,B=v.headerWrap===!0||$;Wt(p,{padding:"4px 8px",boxSizing:"border-box",background:"var(--og-header-bg)",color:"var(--og-header-color)",lineHeight:B?"1.3":"normal",verticalAlign:"middle",fontSize:"var(--og-font-size)",textAlign:v.headerAlign??"center",borderTop:"0",borderLeft:"0",borderRight:"1px solid var(--og-border-color,#e0e0e0)",borderBottom:"1px solid var(--og-border-color,#e0e0e0)",userSelect:"none",cursor:E?"pointer":"default",whiteSpace:B?"normal":"nowrap",overflow:B?"visible":"hidden",textOverflow:B?"clip":"ellipsis",wordBreak:B?"break-word":"normal",position:"relative"}),p.title=(typeof v.tooltip=="string"?v.tooltip:f)??"";const z=D("span");if(B?(z.style.cssText="overflow:visible;text-overflow:clip;white-space:normal;word-break:break-word;",String(f).split(`
32
+ `).forEach((M,F)=>{F>0&&z.appendChild(document.createElement("br")),z.appendChild(document.createTextNode(M))})):(z.textContent=f,z.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"),p.appendChild(z),A){p.classList.add("og-sorted");const _=D("span","og-sort-icon");_.textContent=A.dir==="asc"?" ↑":" ↓",p.appendChild(_)}if(v.filterable!==!1&&i.filterable&&x.colSpan===1){const _=D("span","og-filter-icon"),M=((k=(g=i._activeFilters)==null?void 0:g[v.field])==null?void 0:k.length)>0;_.textContent=M?"⊿":"▿",_.title="필터",_.style.cssText="margin-left:3px;cursor:pointer;font-size:10px;opacity:0.6;",M&&_.classList.add("og-filter-icon--active"),_.addEventListener("click",F=>{F.stopPropagation(),this._cbs.onFilterIconClick(v.field,_)}),p.appendChild(_)}if(v.resizable!==!1){const _=D("div","og-resize-handle");_.style.cssText="position:absolute;right:0;top:0;bottom:0;width:4px;cursor:col-resize;z-index:1;",p.appendChild(_);const M=T;Be(_,p,F=>{M>=0&&this._cbs.onColResize(M,F)})}i.columnReorder&&T>=0&&x.colSpan===1&&(p.draggable=!0,p.addEventListener("dragstart",_=>{var M;this._cbs.onColDragStart(T),p.classList.add("og-col-dragging"),(M=_.dataTransfer)==null||M.setData("text/plain",String(T))}),p.addEventListener("dragend",()=>{p.classList.remove("og-col-dragging"),this._header.querySelectorAll(".og-col-drop-over").forEach(_=>_.classList.remove("og-col-drop-over"))}),p.addEventListener("dragover",_=>{_.preventDefault();const M=this._cbs.getColDragIdx();M!==null&&M!==T&&(this._header.querySelectorAll(".og-col-drop-over").forEach(F=>F.classList.remove("og-col-drop-over")),p.classList.add("og-col-drop-over"))}),p.addEventListener("dragleave",()=>{p.classList.remove("og-col-drop-over")}),p.addEventListener("drop",_=>{_.preventDefault(),p.classList.remove("og-col-drop-over"),this._cbs.onColDrop(T)})),E&&p.addEventListener("click",_=>{_.target.classList.contains("og-resize-handle")||this._cbs.onHeaderClick(v.field,_.shiftKey)}),b.appendChild(p)}a.appendChild(b)}this._header.appendChild(a)}renderBody(t,e,s,o,i,n,r,l,a,c,u=null,h,g,k={},y){var v,T,A,E;Object.keys(k).length&&(n={...n,...k}),this._body.innerHTML="",this._cellMap.clear();const b=n.autoHeight===!0;this._body.classList.toggle("og-autoheight",b),this._body.style.height=b?"":`${l}px`;const x=n._frozenCount??0;{let f=0;n.stateColumn&&(f+=24),n.draggable&&(f+=18),n.rowNumber&&(f+=44),n.checkColumn&&(f+=36);const $=f+o.reduce((B,z,S)=>B+(i[S]??n.defaultColumnWidth),0);this._body.style.minWidth=`${$}px`}if(e<t)return;const p=document.createDocumentFragment();for(let f=t;f<=e;f++){const $=u?u[f]:null,B=$&&$._isGroup===!0,z=$&&$._isTree===!0;if(B){const m=$,L=`__${m._groupField}:${m._groupValue}`,H=D("div","og-group-row"),at=r+(f-t)*n.rowHeight;H.style.cssText=[b?"":`top:${at}px;height:${n.rowHeight}px;`,"display:flex;align-items:stretch;cursor:pointer;",`padding-left:${4+m._depth*12}px;`,"background:var(--og-header-bg,#f5f5f5);","border:0;border-bottom:1px solid var(--og-border-color,#e0e0e0);"].join(""),H.setAttribute("role","row"),H.setAttribute("aria-expanded",m._expanded?"true":"false"),H.setAttribute("aria-rowindex",String(f+1)),H.setAttribute("aria-level",String(m._depth+1));let G=0;if(n.stateColumn&&(G+=24),n.draggable&&(G+=18),n.rowNumber&&(G+=44),n.checkColumn&&(G+=36),G>0){const w=D("div","og-group-state-cell");w.style.cssText=[`width:${G}px;min-width:${G}px;flex-shrink:0;`,"display:flex;align-items:center;justify-content:center;","font-size:10px;font-weight:700;gap:2px;","border-right:1px solid var(--og-border-color,#e0e0e0);"].join("");const O=m._states??{added:0,edited:0,removed:0};if(O.added>0){const I=D("span");I.textContent=`+${O.added}`,I.style.cssText="color:var(--og-row-added-bg,#2e7d32);background:#e8f5e9;padding:1px 3px;border-radius:3px;",w.appendChild(I)}if(O.edited>0){const I=D("span");I.textContent=`M${O.edited}`,I.style.cssText="color:#e65100;background:#fff8e1;padding:1px 3px;border-radius:3px;",w.appendChild(I)}if(O.removed>0){const I=D("span");I.textContent=`D${O.removed}`,I.style.cssText="color:var(--og-row-removed-bg,#c62828);background:#ffebee;padding:1px 3px;border-radius:3px;",w.appendChild(I)}H.appendChild(w)}let j=!1;for(let w=0;w<o.length;w++){const O=o[w],I=i[w]??n.defaultColumnWidth,dt=m._summaryFmt!==void 0&&O.field in(m._summaryFmt??{}),N=D("div","og-group-cell");if(N.style.cssText=[`width:${I}px;min-width:${I}px;flex-shrink:0;`,"padding:2px 8px;box-sizing:border-box;overflow:hidden;","border-right:1px solid var(--og-border-color,#e0e0e0);","display:flex;align-items:center;","white-space:nowrap;text-overflow:ellipsis;"].join(""),dt){const q=m._summaryFmt[O.field];N.textContent=q!==""?q:"-",N.style.justifyContent="flex-end",N.style.color="var(--og-primary,#1976d2)",N.style.fontWeight="600"}else if(!j){j=!0;const q=D("span","og-group-arrow");q.textContent=m._expanded?"▾ ":"▸ ",q.style.cssText="color:var(--og-primary,#1976d2);margin-right:4px;flex-shrink:0;",N.appendChild(q);const X=D("span","og-group-label");X.textContent=`${m._groupLabel} (${m._childCount}건)`,X.style.cssText="overflow:hidden;text-overflow:ellipsis;font-weight:600;",N.appendChild(X),N.style.gap="0"}H.appendChild(N)}H.addEventListener("click",()=>h==null?void 0:h(L)),p.appendChild(H);continue}const S=z?$:null,_=S?S.data:u?$:s.getRowByIndex(f);if(!_)continue;const M=z||B?"none":s.getRowState(f),F=D("div","og-row");if(F.setAttribute("role","row"),F.setAttribute("aria-rowindex",String(f+1)),!b){const m=r+(f-t)*n.rowHeight;F.style.top=`${m}px`,F.style.height=`${n.rowHeight}px`}let W=f%2===0?"var(--og-row-bg,#fff)":"var(--og-row-alt-bg,#fafafa)";F.style.background=W,M==="added"&&F.classList.add("og-state-added"),M==="edited"&&F.classList.add("og-state-edited"),M==="removed"&&F.classList.add("og-state-removed"),a.has(f)&&F.classList.add("og-selected"),F.setAttribute("aria-selected",a.has(f)?"true":"false"),M==="added"&&(W="var(--og-row-added-bg,#e8f5e9)"),M==="edited"&&(W="var(--og-row-edited-bg,#fff8e1)"),M==="removed"&&(W="var(--og-row-removed-bg,#ffebee)"),a.has(f)&&(W="var(--og-row-selected-bg,#bbdefb)");const Tt=f;F.addEventListener("click",m=>{this._cbs.onCellClick(Tt,-1,m)});const it=new Map;let V=0;if(n.stateColumn){const m=D("div","og-cell og-col-state"),L={added:"✚",edited:"✎",removed:"✖",none:""},H={added:"#2e7d32",edited:"#bf360c",removed:"#c62828",none:""};m.textContent=L[M]??"",m.style.color=H[M]??"",m.title=M,x>0&&(m.style.position="sticky",m.style.left=`${V}px`,m.style.zIndex="2",m.style.background=W),V+=24,F.appendChild(m)}const et=this._cbs.getDndManager();if(n.draggable&&et){const m=et.attachHandle(F,f,n._totalRows??e+1);x>0&&(m.style.position="sticky",m.style.left=`${V}px`,m.style.zIndex="2",m.style.background=W),V+=18,F.appendChild(m)}if(n.rowNumber){const m=D("div","og-cell og-col-rownum");m.textContent=String(f+1),x>0&&(m.style.position="sticky",m.style.left=`${V}px`,m.style.zIndex="2",m.style.background=W),V+=44,F.appendChild(m)}if(n.checkColumn){const m=D("div","og-cell og-col-check"),L=document.createElement("input");L.type="checkbox",L.checked=c.has(f),L.setAttribute("aria-label",`${f+1}행 선택`),L.addEventListener("click",H=>H.stopPropagation()),L.addEventListener("change",H=>{H.stopPropagation(),this._cbs.onRowCheck(f,L.checked)}),m.appendChild(L),x>0&&(m.style.position="sticky",m.style.left=`${V}px`,m.style.zIndex="2",m.style.background=W),V+=36,F.appendChild(m)}for(let m=0;m<o.length;m++){const L=o[m],H=i[m]??n.defaultColumnWidth,at=n.editable&&L.editable!==!1,G=m===0,j=y&&!y.isEmpty?y.getInfo(f,m):null;if(j!=null&&j.hidden){const R=D("div","og-cell og-cell--merge-ph");R.style.cssText=`width:${H}px;min-width:${H}px;flex-shrink:0;visibility:hidden;box-sizing:border-box;`,F.appendChild(R);continue}const w=D("div","og-cell");w.setAttribute("role","gridcell"),w.setAttribute("aria-colindex",String(m+1));const O=(j==null?void 0:j.rowSpan)??1,I=(j==null?void 0:j.colSpan)??1,dt=O>1?O*n.rowHeight:n.rowHeight;let N=H;if(I>1)for(let R=1;R<I;R++)N+=i[m+R]??n.defaultColumnWidth;const q=m<x;let X=0;if(q){n.stateColumn&&(X+=24),n.draggable&&(X+=18),n.rowNumber&&(X+=44),n.checkColumn&&(X+=36);for(let R=0;R<m;R++)X+=i[R]??n.defaultColumnWidth;w.classList.add("og-frozen-cell"),m===x-1&&w.classList.add("og-frozen-last")}w.style.width=`${N}px`,w.style.minWidth=`${N}px`,w.style.maxWidth=`${N}px`,O>1&&(w.style.height=`${dt}px`),q&&(w.style.background=W),S&&G&&(w.style.padding="0"),w.style.overflow="hidden",O>1?(w.style.height=`${dt}px`,w.style.position="absolute",w.style.zIndex="3",w.style.background=W&&W!=="inherit"?W:"var(--og-row-bg, #fff)",w.style.borderTop="0",w.style.borderLeft="0",w.style.borderBottom="1px solid var(--og-border-color, #e0e0e0)"):q&&(w.style.position="sticky",w.style.left=`${X}px`,w.style.zIndex="1"),L.type==="number"||L.align==="right"?w.classList.add("og-cell--right"):L.align==="center"&&w.classList.add("og-cell--center"),at&&w.classList.add("og-cell--editable"),L.wrap&&w.classList.add("og-cell--wrap"),at||w.setAttribute("aria-readonly","true"),I>1&&w.setAttribute("aria-colspan",String(I)),O>1&&w.setAttribute("aria-rowspan",String(O)),((v=n._focusCell)==null?void 0:v.ri)===f&&((T=n._focusCell)==null?void 0:T.ci)===m&&(w.classList.add("og-cell-focused"),w.tabIndex=-1);const st=_?_[L.field]:null;w.setAttribute("aria-label",`${L.header}: ${st==null?"":String(st)}`),L.tooltip!=null?w.title=typeof L.tooltip=="function"?String(L.tooltip(st,_)??""):String(L.tooltip):n.tooltips&&st!=null&&st!==""&&(w.title=String(st));let Ft=w;if(S&&G){const R=D("div","og-tree-cell"),Y=S._ancestorHasMore??[];for(let P=0;P<S._depth;P++){const J=D("span","og-tree-guide");Y[P]&&J.classList.add("og-tree-guide--line"),R.appendChild(J)}if(S._depth>0){const P=D("span","og-tree-connector");P.classList.add(S._isLastChild?"og-tree-connector--last":"og-tree-connector--mid"),R.appendChild(P)}const ct=D("span","og-tree-toggle-wrap");if(!S._hasChildren){const P=D("span","og-tree-leaf-dot");ct.appendChild(P)}R.appendChild(ct);const K=document.createElement("i");if(S._hasChildren){const P=Ot(L.treeNodeIcon,_,!0,S._expanded);K.className=S._expanded?`${P} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--open og-tree-node-icon--toggle`:`${P} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--toggle`,K.setAttribute("role","button"),K.setAttribute("tabindex","0"),K.setAttribute("aria-expanded",S._expanded?"true":"false"),K.setAttribute("aria-label",S._expanded?"접기":"펼치기"),K.addEventListener("click",J=>{J.stopPropagation(),g==null||g(S._treeId)}),K.addEventListener("keydown",J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.stopPropagation(),g==null||g(S._treeId))})}else{const P=Ot(L.treeNodeIcon,_,!1,!1);K.setAttribute("aria-hidden","true"),K.className=`${P} og-tree-node-icon og-tree-node-icon--leaf`}R.appendChild(K),w.appendChild(R),Ft=R}if(L.cellStyle){const R=_[L.field],Y=typeof L.cellStyle=="function"?L.cellStyle(R,_,f):L.cellStyle;Object.assign(w.style,Y)}const ne=ze(L).render({value:_[L.field],row:_,rowIndex:f,column:L,colIndex:m,isSelected:a.has(f),rowState:M,displayValue:((E=(A=this._cbs).getDisplayText)==null?void 0:E.call(A,f,L.field))??null});Ft.appendChild(ne);const Q=f,Z=m;if(w.addEventListener("click",R=>{R.stopPropagation(),this._cbs.onCellClick(Q,Z,R)}),w.addEventListener("dblclick",R=>{R.stopPropagation(),this._cbs.onCellDblClick(Q,Z,R)}),w.addEventListener("mouseover",R=>{R.stopPropagation(),this._cbs.onCellMouseOver(Q,Z,R)}),w.addEventListener("mouseout",R=>{R.stopPropagation(),this._cbs.onCellMouseOut(Q,Z,R)}),w.addEventListener("mousedown",R=>{R.stopPropagation(),this._cbs.onCellMouseDown(Q,Z,R)}),w.addEventListener("mouseup",R=>{R.stopPropagation(),this._cbs.onCellMouseUp(Q,Z,R)}),w.addEventListener("mousemove",R=>{R.stopPropagation(),this._cbs.onCellMouseMove(Q,Z,R)}),it.set(m,w),O>1){const R=document.createElement("div");R.style.cssText=[`width:${H}px;min-width:${H}px;height:${n.rowHeight}px;`,"flex-shrink:0;box-sizing:border-box;","border-right:1px solid var(--og-border-color,#e0e0e0);"].join(""),F.appendChild(R);let Y=0;n.stateColumn&&(Y+=24),n.draggable&&(Y+=18),n.rowNumber&&(Y+=44),n.checkColumn&&(Y+=36);for(let K=0;K<m;K++)Y+=i[K]??n.defaultColumnWidth;const ct=r+(f-t)*n.rowHeight;w.style.left=`${Y}px`,w.style.top=`${ct}px`,p.appendChild(w)}else F.appendChild(w)}this._cellMap.set(f,it),p.appendChild(F)}if(s.rowCount===0){const f=D("div","og-empty-message");f.textContent="데이터가 없습니다.",f.style.cssText="width:100%;",p.appendChild(f)}this._body.appendChild(p)}getCellEl(t,e){var s;return(s=this._cellMap.get(t))==null?void 0:s.get(e)}destroy(){this._root.innerHTML=""}}function Ot(d,t,e,s){let o;return d?typeof d=="function"?o=d(t,e,s):e?o=s?d.branchOpen??"bi-folder2-open":d.branch??"bi-folder2":o=d.leaf??"bi-file-earmark":o=e?s?"bi-folder2-open":"bi-folder2":"bi-file-earmark",o.startsWith("bi ")?o:`bi ${o}`}function D(d,t){const e=document.createElement(d);return t&&(e.className=t),e}function Wt(d,t){Object.assign(d.style,t)}function Nt(d,t,e="text/plain;charset=utf-8"){const s=new Blob([d],{type:e}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=t,i.click(),URL.revokeObjectURL(o)}function Be(d,t,e){let s=0,o=0;d.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),s=i.clientX,o=t.offsetWidth;const n=l=>{const a=Math.max(40,o+l.clientX-s);t.style.width=`${a}px`,t.style.minWidth=`${a}px`},r=l=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),e(Math.max(40,o+l.clientX-s))};document.addEventListener("mousemove",n),document.addEventListener("mouseup",r)})}class Oe{constructor(t){this._selectedRows=new Set,this._checkedRows=new Set,this._data=t}get selectedRows(){return this._selectedRows}get checkedRows(){return this._checkedRows}selectSingle(t){this._selectedRows.clear(),this._selectedRows.add(t)}selectToggle(t){this._selectedRows.has(t)?this._selectedRows.delete(t):this._selectedRows.add(t)}clearSelection(){this._selectedRows.clear()}check(t,e){e?this._checkedRows.add(t):this._checkedRows.delete(t)}checkAll(t,e){if(t)for(let s=0;s<e;s++)this._checkedRows.add(s);else this._checkedRows.clear()}checkByValue(t,e){for(let s=0;s<this._data.rowCount;s++)e.includes(this._data.getCellValue(s,t))&&this._checkedRows.add(s)}uncheckAll(){this._checkedRows.clear()}checkById(t){}addCheckById(t){}uncheckById(t){}getSelections(){return[...this._selectedRows].map(t=>this._data.getRowByIndex(t)).filter(Boolean)}getChecked(){return[...this._checkedRows].map(t=>({row:this._data.getRowByIndex(t),rowIndex:t}))}getAllChecked(){return this.getChecked().map(t=>t.row)}getActiveRow(){return this._selectedRows.size>0?[...this._selectedRows][0]:-1}activate(t){this._selectedRows.clear(),this._selectedRows.add(t)}deselect(){this._selectedRows.clear()}reset(){this._selectedRows.clear(),this._checkedRows.clear()}}class vt{constructor(){this._onKeyDown=t=>{t.stopPropagation(),t.key==="Enter"?(t.preventDefault(),this._onCommit(this.input.value)):t.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._onCommit(this.input.value)}}mount(t,e,s,o){this._container=t,this._onCommit=s,this._onCancel=o,t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","true"),this.input=document.createElement("input"),this.input.type="date",this.input.className="og-cell-input",this.input.setAttribute("aria-label",e.column.header??"날짜 선택");const i=e.value;if(i){const n=i instanceof Date?i:new Date(i);isNaN(n.getTime())||(this.input.value=Jt(n,"yyyy-MM-dd"))}this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),t.appendChild(this.input)}getValue(){var t;return(t=this.input)==null?void 0:t.value}focus(){var t;(t=this.input)==null||t.focus()}destroy(){var t,e,s;(t=this._container)==null||t.setAttribute("aria-expanded","false"),(e=this.input)==null||e.removeEventListener("keydown",this._onKeyDown),(s=this.input)==null||s.removeEventListener("blur",this._onBlur)}}function Kt(d){return d.map(t=>typeof t=="string"?{label:t,value:t}:{label:t.label??t.text??String(t.value??""),value:t.value})}class xt{constructor(t=[],e){this._options=Kt(t),this._optionsFn=e??null}mount(t,e,s,o){this._container=t,this._onCommit=s,this._onCancel=o,t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-expanded","true"),this.select=document.createElement("select"),this.select.className="og-cell-select",this.select.setAttribute("aria-label",e.column.header??"선택");const i=this._optionsFn?Kt(this._optionsFn(e.row,e.rowIndex)):this._options;for(const r of i){const l=document.createElement("option");l.value=String(r.value),l.textContent=r.label,this.select.appendChild(l)}const n=e.value==null?"":String(e.value);i.some(r=>String(r.value)===n)&&(this.select.value=n),this.select.addEventListener("change",()=>s(this.select.value)),this.select.addEventListener("blur",()=>s(this.select.value)),this.select.addEventListener("keydown",r=>{r.key==="Escape"&&o()}),t.appendChild(this.select)}getValue(){var t;return(t=this.select)==null?void 0:t.value}focus(){var t;(t=this.select)==null||t.focus()}destroy(){var t;(t=this._container)==null||t.setAttribute("aria-expanded","false")}}class Ct{constructor(){this._onKeyDown=t=>{t.stopPropagation(),t.key==="Enter"||t.key==="Tab"?(t.preventDefault(),this._onCommit(this.input.value)):t.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._onCommit(this.input.value)}}mount(t,e,s,o){this._onCommit=s,this._onCancel=o,this.input=document.createElement("input"),this.input.type="text",this.input.value=e.value==null?"":String(e.value),this.input.style.cssText=`
33
+ width:100%;height:100%;border:none;outline:none;padding:0 8px;
34
+ font-size:var(--og-font-size,13px);font-family:var(--og-font-family,sans-serif);
35
+ background:var(--og-row-bg,#fff);box-sizing:border-box;
36
+ `,this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),t.appendChild(this.input)}getValue(){var t;return(t=this.input)==null?void 0:t.value}focus(){var t,e;(t=this.input)==null||t.focus(),(e=this.input)==null||e.select()}destroy(){var t,e;(t=this.input)==null||t.removeEventListener("keydown",this._onKeyDown),(e=this.input)==null||e.removeEventListener("blur",this._onBlur)}}class Mt{constructor(t){this._onKeyDown=e=>{e.stopPropagation(),e.key==="Enter"||e.key==="Tab"?(e.preventDefault(),this._commit()):e.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._commit()},this.min=t==null?void 0:t.min,this.max=t==null?void 0:t.max,this.step=t==null?void 0:t.step}mount(t,e,s,o){this._onCommit=s,this._onCancel=o,this.input=document.createElement("input"),this.input.type="number",this.input.value=e.value==null?"":String(e.value),this.min!=null&&(this.input.min=String(this.min)),this.max!=null&&(this.input.max=String(this.max)),this.step!=null&&(this.input.step=String(this.step)),this.input.style.cssText=`
37
+ width:100%;height:100%;border:none;outline:none;padding:0 8px;
38
+ font-size:var(--og-font-size,13px);text-align:right;
39
+ background:var(--og-row-bg,#fff);box-sizing:border-box;
40
+ `,this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),t.appendChild(this.input)}_commit(){const t=this.input.value===""?null:Number(this.input.value);this._onCommit(t)}getValue(){var t,e;return((t=this.input)==null?void 0:t.value)===""?null:Number((e=this.input)==null?void 0:e.value)}focus(){var t,e;(t=this.input)==null||t.focus(),(e=this.input)==null||e.select()}destroy(){var t,e;(t=this.input)==null||t.removeEventListener("keydown",this._onKeyDown),(e=this.input)==null||e.removeEventListener("blur",this._onBlur)}}class kt{mount(t,e,s,o){this._onCommit=s,t.style.cssText+="display:flex;align-items:center;justify-content:center;",this.chk=document.createElement("input"),this.chk.type="checkbox",this.chk.checked=!!e.value,this.chk.style.cursor="pointer",this.chk.addEventListener("change",()=>s(this.chk.checked)),t.appendChild(this.chk)}getValue(){var t;return(t=this.chk)==null?void 0:t.checked}focus(){var t;(t=this.chk)==null||t.focus()}destroy(){}}function Pt(d){const t=d.editor;if(!t)switch(d.type){case"number":return new Mt;case"date":return new vt;case"boolean":return new kt;case"select":return new xt(d.options??[],d.optionsFn);default:return new Ct}if(typeof t=="string")switch(t){case"number":return new Mt;case"date":return new vt;case"select":return new xt(d.options??[],d.optionsFn);case"checkbox":return new kt;default:return new Ct}switch(t.type){case"number":{const e={};return t.min!=null&&(e.min=t.min),t.max!=null&&(e.max=t.max),t.step!=null&&(e.step=t.step),new Mt(e)}case"date":return new vt;case"select":return new xt(t.options??[],d.optionsFn);case"checkbox":return new kt;default:return new Ct}}function rt(d){const t=typeof d.renderer=="string"?d.renderer:d.renderer&&typeof d.renderer=="object"?d.renderer.type:"";return d.type==="boolean"||d.type==="checkbox"||t==="checkbox"||t==="switch"}class We{constructor(t){this._activeEditor=null,this._editCell=null,this._focusCell=null,this._dragColIdx=null,this._d=t}get activeEditor(){return this._activeEditor}get editCell(){return this._editCell}get focusCell(){return this._focusCell}get dragColIdx(){return this._dragColIdx}set dragColIdx(t){this._dragColIdx=t}setFocusCell(t,e){this._focusCell={ri:t,ci:e},this._d.scrollToRow(t),this._d.doRender();const s=this._d.getVisibleLeaves()[e],o=this._d.data.getRowByIndex(t);if(s&&o){const i=o[s.field];this._d.announce(`${t+1}행 ${e+1}열, ${s.header}: ${i==null?"빈 값":String(i)}`)}}clearFocusCell(){this._focusCell=null}startEditByKey(t,e){var a,c,u;const s=this._d.getVisibleLeaves()[e];if(!s)return;if(rt(s)){const h=this._d.getOptions();if(s.editable!==!1&&(s.editable!==void 0||h.editable)){const k=this._d.data.getRowByIndex(t);k&&this._d.writeCell(t,s.field,!k[s.field])}return}const o=this._d.data.getRowByIndex(t);if(s.editable===!1||typeof s.editable=="function"&&!s.editable(o,t))return;this.commitEdit();const i=(a=this._d.getRenderer())==null?void 0:a.getCellEl(t,e);if(!i)return;i.innerHTML="";const n=Pt(s);this._activeEditor=n,this._editCell={ri:t,ci:e};const r={type:"editStart",rowIndex:t,columnIndex:e,field:s.field,oldValue:o==null?void 0:o[s.field],newValue:o==null?void 0:o[s.field],row:o,column:s};this._d.emit("editStart",r),(u=(c=this._d.getOptions()).onEditStart)==null||u.call(c,r),i.classList.add("og-editing");const l={value:o==null?void 0:o[s.field],row:o,rowIndex:t,column:s,colIndex:e,isSelected:!0,rowState:"none"};n.mount(i,l,h=>this.commitEditWithValue(t,e,h),()=>this.cancelEdit()),requestAnimationFrame(()=>n.focus())}startEdit(t,e,s){var u,h;const o=this._d.getOptions();if(!o.editable)return;const i=this._d.getVisibleLeaves()[e];if(!i||rt(i))return;const n=this._d.data.getRowByIndex(t);if(i.editable===!1||typeof i.editable=="function"&&!i.editable(n,t)||!i.editable&&!o.editable)return;this.commitEdit();const r=(u=this._d.getRenderer())==null?void 0:u.getCellEl(t,e);if(!r)return;r.innerHTML="";const l=Pt(i);this._activeEditor=l,this._editCell={ri:t,ci:e};const a={type:"editStart",rowIndex:t,columnIndex:e,field:i.field,oldValue:n==null?void 0:n[i.field],newValue:n==null?void 0:n[i.field],row:n,column:i};this._d.emit("editStart",a),(h=o.onEditStart)==null||h.call(o,a),r.classList.add("og-editing");const c={value:n==null?void 0:n[i.field],row:n,rowIndex:t,column:i,colIndex:e,isSelected:!0,rowState:"none"};l.mount(r,c,g=>this.commitEditWithValue(t,e,g),()=>this.cancelEdit()),requestAnimationFrame(()=>l.focus())}commitEdit(){if(!this._activeEditor||!this._editCell)return;const t=this._activeEditor.getValue(),{ri:e,ci:s}=this._editCell;this._finishEdit(e,s,t,!1)}commitEditWithValue(t,e,s){this._finishEdit(t,e,s,!1)}cancelEdit(){if(!this._editCell)return;const{ri:t,ci:e}=this._editCell;this._finishEdit(t,e,void 0,!0)}_finishEdit(t,e,s,o){var r,l,a;if(!this._activeEditor)return;const i=this._d.getVisibleLeaves()[e],n=(r=this._d.getRenderer())==null?void 0:r.getCellEl(t,e);if(n&&(this._activeEditor.destroy(),n.classList.remove("og-editing")),this._activeEditor=null,this._editCell=null,!o&&i){const c=this._d.data.getCellValue(t,i.field);if(s!==c){this._d.data.updateCell(t,i.field,s);const u=this._d.data.getRowByIndex(t),h=this._d.getOptions(),g={type:"editEnd",rowIndex:t,columnIndex:e,field:i.field,oldValue:c,newValue:s,row:u,column:i};this._d.emit("editEnd",g),(l=h.onEditEnd)==null||l.call(h,g),this._d.emit("dataChange",this._d.data.getData()),(a=h.onDataChange)==null||a.call(h,this._d.data.getData())}}this._d.doRender(),requestAnimationFrame(()=>this._d.getContainer().focus({preventScroll:!0}))}}class Ne{constructor(t,e,s,o,i){this._selects=new Map,this._selected={},this._config=e,this._onFilter=s,this._onReset=o,this._el=document.createElement("fieldset"),this._el.className="og-filter-select";const n=document.createElement("legend");n.className="og-filter-select-legend",n.textContent=e.legend??"필터",this._el.appendChild(n);const r=document.createElement("div");r.className="og-filter-select-row";for(const a of e.columns){const c=`og-fsel-${a.field}`,u=document.createElement("div");u.className="og-filter-select-group";const h=document.createElement("label");h.htmlFor=c,h.textContent=a.label,h.className="og-filter-select-label";const g=document.createElement("select");g.id=c,g.className="og-filter-select-sel",g.setAttribute("aria-label",a.label),i&&g.setAttribute("aria-controls",i),a.dependsOn?this._fill(g,[],!1):this._fill(g,this._resolve(a,""),!0),g.addEventListener("change",()=>this._onChange(a.field,g.value)),u.appendChild(h),u.appendChild(g),r.appendChild(u),this._selects.set(a.field,g)}const l=document.createElement("button");l.type="button",l.textContent="초기화",l.className="og-filter-select-reset",l.setAttribute("aria-label","필터 초기화"),l.addEventListener("click",()=>this._reset()),this._el.appendChild(r),this._el.appendChild(l),t.insertBefore(this._el,t.firstChild)}_resolve(t,e){if(t.options)return t.options;let s=t.data??[];t.dependsOn&&t.dependsOnKey&&e&&(s=s.filter(n=>String(n[t.dependsOnKey]??"")===e));const o=t.valueKey??"value",i=t.textKey??o;return s.map(n=>({value:String(n[o]??""),text:String(n[i]??n[o]??"")}))}_fill(t,e,s){t.innerHTML="";const o=document.createElement("option");o.value="",o.textContent="전체",t.appendChild(o);for(const i of e){const n=document.createElement("option");n.value=i.value,n.textContent=i.text,t.appendChild(n)}t.disabled=!s}_onChange(t,e){const s=this._config.columns.find(i=>i.field===t),o=s.filterKey??s.field;e?(this._selected[t]=e,this._onFilter(o,[{operator:"=",value:e}])):(delete this._selected[t],this._onReset(o)),this._cascade(t)}_cascade(t){const e=this._selected[t]??"";for(const s of this._config.columns){if(s.dependsOn!==t)continue;const o=this._selects.get(s.field);if(!o)continue;const i=s.filterKey??s.field;e?(this._fill(o,this._resolve(s,e),!0),o.value="",delete this._selected[s.field],this._onReset(i)):(this._fill(o,[],!1),delete this._selected[s.field],this._onReset(i),this._cascade(s.field))}}_reset(){this._selected={};for(const t of this._config.columns){const e=this._selects.get(t.field),s=t.filterKey??t.field;e&&(t.dependsOn?this._fill(e,[],!1):(e.value="",e.disabled=!1),this._onReset(s))}}reset(){this._reset()}destroy(){this._el.remove()}}class Ke{constructor(t,e,s){this._page=1,this._totalRows=0,this._pageSize=e,this._onChange=s,this._el=document.createElement("div"),this._el.className="og-pagination",this._el.style.cssText=`
41
+ display:flex;align-items:center;justify-content:center;gap:4px;
42
+ padding:6px 8px;border-top:1px solid var(--og-border-color,#e0e0e0);
43
+ background:var(--og-header-bg,#f5f5f5);flex-shrink:0;user-select:none;
44
+ font-size:12px;color:var(--og-text-color,#333);
45
+ `,t.appendChild(this._el),this._render()}get page(){return this._page}get pageSize(){return this._pageSize}get totalPages(){return Math.max(1,Math.ceil(this._totalRows/this._pageSize))}setTotalRows(t){this._totalRows=t,this._page>this.totalPages&&(this._page=this.totalPages),this._render()}setPageSize(t){this._pageSize=t,this._page=1,this._render(),this._emit()}goTo(t){const e=Math.max(1,Math.min(t,this.totalPages));e!==this._page&&(this._page=e,this._render(),this._emit())}getRange(){const t=(this._page-1)*this._pageSize,e=Math.min(t+this._pageSize-1,this._totalRows-1);return{start:t,end:e}}_emit(){this._onChange({page:this._page,pageSize:this._pageSize,totalRows:this._totalRows,totalPages:this.totalPages})}_render(){this._el.innerHTML="";const t=this.totalPages,e=document.createElement("span");e.style.cssText="display:flex;align-items:center;gap:3px;margin-right:8px;";const s=document.createElement("span");s.textContent="행/페이지:",s.style.color="#888";const o=document.createElement("select");o.style.cssText="padding:2px 4px;border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;font-size:11px;cursor:pointer;";for(const c of[10,20,50,100,200]){const u=document.createElement("option");u.value=String(c),u.textContent=String(c),c===this._pageSize&&(u.selected=!0),o.appendChild(u)}o.addEventListener("change",()=>this.setPageSize(Number(o.value))),e.appendChild(s),e.appendChild(o),this._el.appendChild(e);const i=document.createElement("span"),{start:n,end:r}=this.getRange();i.textContent=this._totalRows>0?`${n+1}–${r+1} / ${this._totalRows}건`:"0건",i.style.cssText="margin-right:8px;color:#888;",this._el.appendChild(i);const l=(c,u,h)=>{const g=document.createElement("button");return g.textContent=c,g.disabled=h,g.style.cssText=`
46
+ min-width:28px;height:24px;padding:0 6px;
47
+ border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;
48
+ background:${h?"#f5f5f5":"#fff"};
49
+ color:${h?"#bbb":"var(--og-text-color,#333)"};
50
+ cursor:${h?"default":"pointer"};font-size:12px;
51
+ `,h||g.addEventListener("click",()=>this.goTo(u)),g};this._el.appendChild(l("«",1,this._page===1)),this._el.appendChild(l("‹",this._page-1,this._page===1));const a=Pe(this._page,t);for(const c of a)if(c===-1){const u=document.createElement("span");u.textContent="…",u.style.padding="0 3px",this._el.appendChild(u)}else{const u=l(String(c),c,c===this._page);c===this._page&&(u.style.background="var(--og-primary,#1976d2)",u.style.color="#fff",u.style.borderColor="var(--og-primary,#1976d2)"),this._el.appendChild(u)}this._el.appendChild(l("›",this._page+1,this._page===t)),this._el.appendChild(l("»",t,this._page===t))}destroy(){this._el.remove()}}function Pe(d,t){if(t<=7)return Array.from({length:t},(s,o)=>o+1);const e=[1];d>3&&e.push(-1);for(let s=Math.max(2,d-1);s<=Math.min(t-1,d+1);s++)e.push(s);return d<t-2&&e.push(-1),e.push(t),e}class Ve{constructor(t,e,s,o){this._dx=e-t.left,this._dy=s-t.top;const i=document.createElement("div");i.className="og-drag-ghost",i.style.cssText=`position:fixed;left:0;top:0;width:${t.width}px;height:${Math.min(t.height,40)}px;transform:translate(${t.left}px,${t.top}px);background:rgba(25,118,210,0.12);border:2px dashed #1976d2;box-sizing:border-box;pointer-events:none;z-index:10000;border-radius:3px;opacity:0.92;display:flex;align-items:center;padding-left:10px;font-size:12px;color:#1565c0;font-weight:600;white-space:nowrap;overflow:hidden;`,o>1&&(i.textContent=`${o}개 행 이동`),document.body.appendChild(i),this._el=i}move(t,e){this._el.style.transform=`translate(${t-this._dx}px,${e-this._dy}px)`}destroy(){this._el.remove()}}class Vt{constructor(t="#1976d2"){const e=document.createElement("div");e.className="og-drop-indicator",e.style.cssText="position:absolute;left:0;right:0;display:none;align-items:center;pointer-events:none;z-index:9998;transform:translateY(-50%);";const s=i=>{const n=document.createElement("div"),r=i==="left"?`border-left:7px solid ${t}`:`border-right:7px solid ${t}`;return n.style.cssText=`width:0;height:0;flex-shrink:0;border-top:5px solid transparent;border-bottom:5px solid transparent;${r};`,n},o=document.createElement("div");o.style.cssText=`flex:1;height:3px;background:${t};border-radius:2px;box-shadow:0 0 0 1px rgba(255,255,255,0.7);`,e.append(s("left"),o,s("right")),this._el=e}showIn(t,e){this._el.parentElement!==t&&(this._el.remove(),t.appendChild(this._el)),this._el.style.display="flex",this._el.style.top=`${e}px`}hide(){this._el.style.display="none"}destroy(){this._el.remove()}}const jt=(d,t,e)=>Math.max(t,Math.min(e,d));class je{constructor(t,e,s,o=null,i=()=>1){this._bodyEl=t,this._rowHeight=e,this._onDrop=s,this._cross=o,this._getDragCount=i,this._drag=null,this._selfIndicator=new Vt("#1976d2"),this._crossIndicator=new Vt("#2e7d32"),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this)}attachHandle(t,e,s){const o=document.createElement("div");return o.className="og-drag-handle",o.innerHTML="⠿",o.style.cssText=`
52
+ width:18px;min-width:18px;height:100%;
53
+ display:flex;align-items:center;justify-content:center;
54
+ cursor:grab;font-size:14px;color:#bbb;flex-shrink:0;
55
+ user-select:none;border-right:1px solid var(--og-border-color,#e0e0e0);
56
+ `,o.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),this._startDrag(i,t,e,s)}),o}_startDrag(t,e,s,o){const i=e.getBoundingClientRect(),n=this._getDragCount(s);this._drag={fromIndex:s,bodyEl:this._bodyEl,rowHeight:this._rowHeight,totalRows:o,ghost:new Ve(i,t.clientX,t.clientY,n),currentTarget:s,crossTarget:null},document.addEventListener("mousemove",this._onMouseMove,!0),document.addEventListener("mouseup",this._onMouseUp,!0)}_onMouseMove(t){if(!this._drag)return;const e=this._drag;if(e.ghost.move(t.clientX,t.clientY),this._cross){const i=this._cross.resolveTarget(t.clientX,t.clientY);if(i&&i.bodyEl!==e.bodyEl){const n=i.bodyEl.getBoundingClientRect(),r=t.clientY-n.top+i.bodyEl.scrollTop,l=jt(Math.round(r/i.rowHeight),0,i.totalRows);e.crossTarget={bodyEl:i.bodyEl,index:l},this._selfIndicator.hide(),this._crossIndicator.showIn(i.bodyEl,l*i.rowHeight);return}}e.crossTarget=null,this._crossIndicator.hide();const s=e.bodyEl.getBoundingClientRect(),o=t.clientY-s.top+e.bodyEl.scrollTop;e.currentTarget=jt(Math.round(o/e.rowHeight),0,e.totalRows-1),this._selfIndicator.showIn(e.bodyEl,e.currentTarget*e.rowHeight)}_onMouseUp(t){if(document.removeEventListener("mousemove",this._onMouseMove,!0),document.removeEventListener("mouseup",this._onMouseUp,!0),!this._drag)return;const{fromIndex:e,currentTarget:s,ghost:o,crossTarget:i}=this._drag;this._drag=null,o.destroy(),this._selfIndicator.hide(),this._crossIndicator.hide(),i&&this._cross?this._cross.onCrossDrop(e,i.bodyEl,i.index):e!==s&&this._onDrop(e,s)}destroy(){var t;document.removeEventListener("mousemove",this._onMouseMove,!0),document.removeEventListener("mouseup",this._onMouseUp,!0),(t=this._drag)==null||t.ghost.destroy(),this._selfIndicator.destroy(),this._crossIndicator.destroy(),this._drag=null}}class tt{constructor(){this._map=new Map}static _key(t,e){return`${t}:${e}`}applyMergeCells(t){this._map.clear();for(const e of t){const s=Math.max(1,e.rowSpan??1),o=Math.max(1,e.colSpan??1);this._map.set(tt._key(e.row,e.col),{rowSpan:s,colSpan:o,hidden:!1});for(let i=0;i<s;i++)for(let n=0;n<o;n++)i===0&&n===0||this._map.set(tt._key(e.row+i,e.col+n),{rowSpan:1,colSpan:1,hidden:!0})}}applyAutoMerge(t,e,s){var o,i;this._map.clear();for(let n=0;n<e.length;n++){const r=e[n],l=s[n];let a=0;for(let c=1;c<=t.length;c++){const u=(o=t[c-1])==null?void 0:o[l],h=c<t.length?(i=t[c])==null?void 0:i[l]:void 0;if(c===t.length||h!==u){const g=c-a;if(g>1){this._map.set(tt._key(a,r),{rowSpan:g,colSpan:1,hidden:!1});for(let k=a+1;k<c;k++)this._map.set(tt._key(k,r),{rowSpan:1,colSpan:1,hidden:!0})}a=c}}}}getInfo(t,e){return this._map.get(tt._key(t,e))??null}clear(){this._map.clear()}get isEmpty(){return this._map.size===0}}const Ue=[{id:"sort-asc",label:"오름차순 정렬",icon:"↑",action:"sortAsc"},{id:"sort-desc",label:"내림차순 정렬",icon:"↓",action:"sortDesc"},{type:"divider"},{id:"find",label:"찾기",icon:"🔍",action:"find"},{type:"divider"},{id:"excel",label:"Excel로 저장",icon:"📊",action:"excel"},{id:"csv",label:"CSV로 저장",icon:"📄",action:"csv"},{id:"print",label:"인쇄",icon:"🖨",action:"print"}];class Ge{constructor(t,e){this._anchor=t,this._actions=e,this._el=null,this._docClick=null,this._docKey=null,this._docScroll=null,this._docMouseMove=null,this._focusIdx=-1}open(t,e){this.close();const s=e??Ue,o=document.createElement("div");o.className="og-context-menu",o.setAttribute("role","menu");for(const r of s){if(r.type==="divider"){const c=document.createElement("div");c.className="og-cm-divider",c.setAttribute("role","separator"),o.appendChild(c);continue}const l=document.createElement("button");if(l.className="og-cm-item",l.setAttribute("role","menuitem"),l.setAttribute("tabindex","-1"),r.disabled&&(l.classList.add("og-cm-disabled"),l.setAttribute("aria-disabled","true")),r.icon){const c=document.createElement("span");if(c.className="og-cm-icon",/^[a-zA-Z][\w-]*(\s+[\w-]+)+$/.test(r.icon.trim())){const u=document.createElement("i");u.className=r.icon,c.appendChild(u)}else c.textContent=r.icon;c.setAttribute("aria-hidden","true"),l.appendChild(c)}const a=document.createElement("span");a.className="og-cm-label",a.textContent=r.label??"",l.appendChild(a),l.addEventListener("click",c=>{c.stopPropagation(),r.disabled||this._runAction(r),this.close()}),o.appendChild(l)}const i=this._anchor.closest("[data-og-theme]"),n=i==null?void 0:i.getAttribute("data-og-theme");n&&o.setAttribute("data-og-theme",n),document.body.appendChild(o),this._el=o,this._docMouseMove=r=>{if(!this._el)return;const l=this._el.getBoundingClientRect();(r.clientX<l.left-4||r.clientX>l.right+4||r.clientY<l.top-4||r.clientY>l.bottom+4)&&this.close()},this._position(o,t.clientX,t.clientY,()=>{this._el===o&&document.addEventListener("mousemove",this._docMouseMove,{capture:!0,passive:!0})}),this._docClick=r=>{o.contains(r.target)||this.close()},this._docKey=r=>{if(r.key==="Escape"){this.close();return}if(r.key==="ArrowDown"){r.preventDefault(),this._moveFocus(1);return}if(r.key==="ArrowUp"){r.preventDefault(),this._moveFocus(-1);return}if(r.key==="Enter"){const l=o.querySelector(".og-cm-item:focus");l==null||l.click()}},this._docScroll=()=>this.close(),setTimeout(()=>{document.addEventListener("click",this._docClick),document.addEventListener("keydown",this._docKey),window.addEventListener("scroll",this._docScroll,{passive:!0})},0),this._focusIdx=-1,this._moveFocus(1)}close(){var t;(t=this._el)==null||t.remove(),this._el=null,this._docClick&&document.removeEventListener("click",this._docClick),this._docKey&&document.removeEventListener("keydown",this._docKey),this._docScroll&&window.removeEventListener("scroll",this._docScroll),this._docMouseMove&&document.removeEventListener("mousemove",this._docMouseMove,{capture:!0}),this._docClick=this._docKey=this._docScroll=this._docMouseMove=null,this._focusIdx=-1}destroy(){this.close()}_position(t,e,s,o){t.style.cssText="position:fixed;visibility:hidden;left:0;top:0;",requestAnimationFrame(()=>{const{width:i,height:n}=t.getBoundingClientRect(),r=window.innerWidth,l=window.innerHeight,a=e+i>r?Math.max(0,e-i):e,c=s+n>l?Math.max(0,s-n):s;t.style.cssText=`position:fixed;left:${a}px;top:${c}px;z-index:9999;`,o==null||o()})}_moveFocus(t){var s;if(!this._el)return;const e=Array.from(this._el.querySelectorAll(".og-cm-item:not(.og-cm-disabled)"));e.length&&(this._focusIdx=(this._focusIdx+t+e.length)%e.length,(s=e[this._focusIdx])==null||s.focus())}_runAction(t){if(typeof t.action=="function"){t.action();return}switch(t.action){case"sortAsc":this._actions.onSortAsc();break;case"sortDesc":this._actions.onSortDesc();break;case"find":this._actions.onFind();break;case"excel":this._actions.onExcel();break;case"csv":this._actions.onCsv();break;case"print":this._actions.onPrint();break}}}class Ut{constructor(t,e){this._sheets=new Map,this._active="",this._onSwitch=e,this._tabBar=this._buildTabBar(t)}add(t,e=[],s=[]){if(this._sheets.has(t))throw new Error(`WorksheetManager: 시트 '${t}'이 이미 존재합니다`);this._sheets.set(t,{name:t,columns:e,data:s}),this._renderTabs(),this._sheets.size===1&&this.switch(t)}remove(t){if(!this._sheets.has(t))return;if(this._sheets.size===1)throw new Error("WorksheetManager: 마지막 시트는 삭제할 수 없습니다");const e=this._active===t;this._sheets.delete(t),this._renderTabs(),e&&this.switch(this._sheets.keys().next().value)}rename(t,e){if(!this._sheets.has(t))return;if(this._sheets.has(e))throw new Error(`WorksheetManager: 시트 '${e}'이 이미 존재합니다`);this._sheets.get(t);const s=Array.from(this._sheets.entries()).map(([o,i])=>o===t?[e,{...i,name:e}]:[o,i]);this._sheets=new Map(s),this._active===t&&(this._active=e),this._renderTabs()}switch(t){const e=this._sheets.get(t);if(!e)throw new Error(`WorksheetManager: 시트 '${t}'을 찾을 수 없습니다`);this._active=t,this._renderTabs(),this._onSwitch(t,e)}get(t){return this._sheets.get(t)}getNames(){return Array.from(this._sheets.keys())}getActive(){return this._active}syncData(t,e){const s=this._sheets.get(t);s&&(s.data=e)}destroy(){this._tabBar.remove()}_buildTabBar(t){const e=document.createElement("div");return e.className="og-sheet-tabs",t.appendChild(e),e}_renderTabs(){this._tabBar.innerHTML="";for(const e of this._sheets.keys()){const s=document.createElement("button");s.className="og-sheet-tab",s.textContent=e,s.setAttribute("role","tab"),s.setAttribute("aria-selected",e===this._active?"true":"false"),e===this._active&&s.classList.add("og-sheet-tab--active"),s.addEventListener("click",()=>{e!==this._active&&this.switch(e)}),s.addEventListener("dblclick",()=>this._startRename(s,e)),this._tabBar.appendChild(s)}const t=document.createElement("button");t.className="og-sheet-add",t.textContent="+",t.setAttribute("aria-label","새 워크시트 추가"),t.addEventListener("click",()=>{const e=`Sheet${this._sheets.size+1}`;this.add(e,[],[]),this.switch(e)}),this._tabBar.appendChild(t)}_startRename(t,e){const s=document.createElement("input");s.className="og-sheet-tab-rename",s.value=e,t.replaceWith(s),s.focus(),s.select();const o=()=>{const i=s.value.trim()||e;try{i!==e?this.rename(e,i):this._renderTabs()}catch{this._renderTabs()}};s.addEventListener("blur",o),s.addEventListener("keydown",i=>{i.key==="Enter"&&s.blur(),i.key==="Escape"&&(s.value=e,s.blur())})}}class qe{constructor(t){this._d=t}_readCssVar(t){return getComputedStyle(this._d.getContainer()).getPropertyValue(t).trim()}_hexToXlsxRgb(t){const e=t.trim(),s=e.match(/^rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/i);if(s)return[s[1],s[2],s[3]].map(i=>parseInt(i).toString(16).padStart(2,"0")).join("").toUpperCase();const o=e.replace("#","").toUpperCase();return o.length===3?o[0]+o[0]+o[1]+o[1]+o[2]+o[2]:o.length===6?o:""}exportExcel(t){const e=typeof t=="string"?{filename:t}:t??{};let s=e.filename??"export";s.toLowerCase().endsWith(".xlsx")||(s+=".xlsx");const o=e.sheetName??(this._d.getOptions().ariaLabel||"Sheet1"),i=this._d.getData(),n=this._d.getColLayout().visibleLeaves.filter(a=>{var c;return!((c=e.exceptFields)!=null&&c.includes(a.field))}),r=e.includeHeader!==!1,l=(this._d.getStrategy??((a,c)=>c))("cellSerializer",(a,c,u)=>c.type==="number"&&typeof a=="number"?a:typeof a=="boolean"?a?"✓":"":typeof a=="object"?"":String(a));Promise.resolve().then(()=>require("./xlsx.min-Bx-LxWOf.cjs")).then(a=>a.xlsx_min).then(({utils:a,writeFile:c})=>{var z;const u=[];r&&u.push(n.map(S=>S.header));for(const S of i)u.push(n.map(_=>{const M=S[_.field];if(e.maskOnExport&&_.mask&&this._d.getMaskEnabled(_.field))return Rt(M==null?"":String(M),_.mask);const F=M;return F==null||F===""?"":l(F,_,S)}));const h=a.aoa_to_sheet(u),g=this._d.getColWidths(),k=this._d.getColLayout();h["!cols"]=n.map(S=>({wpx:g[k.getColumnIndex(S.field)]??100})),h["!rows"]=u.map((S,_)=>({hpx:_===0&&r?22:19}));const y=e.styleMode??"theme";let b="1565C0",x="FFFFFF",p="FFFFFF",v="EEF2FF",T="212121",A="BDBDBD",E=10;if(y==="theme"){const S=M=>this._hexToXlsxRgb(M);b=S(this._readCssVar("--og-header-bg"))||b,x=S(this._readCssVar("--og-header-color"))||x,p=S(this._readCssVar("--og-row-bg"))||p,v=S(this._readCssVar("--og-row-alt-bg"))||v,T=S(this._readCssVar("--og-row-color"))||T,A=S(this._readCssVar("--og-border-color"))||A;const _=this._readCssVar("--og-font-size");_&&(E=Math.max(8,Math.round(parseFloat(_)*.75)))}const f=y==="none",$={hdrFont:f?{}:{bold:!0,color:{rgb:x},sz:E,name:"맑은 고딕"},dataFont:f?{}:{sz:E,color:{rgb:T},name:"맑은 고딕"},hdrFill:f?{}:{patternType:"solid",fgColor:{rgb:b}},evenFill:f?{}:{patternType:"solid",fgColor:{rgb:p}},oddFill:f?{}:{patternType:"solid",fgColor:{rgb:v}},hdrBorder:f?{}:{top:{style:"medium",color:{rgb:b}},bottom:{style:"medium",color:{rgb:b}},left:{style:"thin",color:{rgb:b}},right:{style:"thin",color:{rgb:b}}},dataBorder:f?{}:{top:{style:"thin",color:{rgb:A}},bottom:{style:"thin",color:{rgb:A}},left:{style:"thin",color:{rgb:A}},right:{style:"thin",color:{rgb:A}}}};u.forEach((S,_)=>{const M=r&&_===0,W=(r?_-1:_)%2===0;S.forEach((Tt,it)=>{const V=a.encode_cell({r:_,c:it});h[V]||(h[V]={t:"s",v:""});const et=n[it],m=et.type==="number"||et.align==="right",L=M?"center":m?"right":et.align??"left";h[V].s={font:M?$.hdrFont:$.dataFont,fill:M?$.hdrFill:W?$.evenFill:$.oddFill,border:M?$.hdrBorder:$.dataBorder,alignment:{horizontal:L,vertical:"center",wrapText:!1}}})});const B=a.book_new();a.book_append_sheet(B,h,o),c(B,s,{cellStyles:!0}),(z=e.onAfter)==null||z.call(e,new Blob([]))}).catch(()=>{console.error("Excel 내보내기 실패: xlsx 패키지를 확인하세요.")})}exportCsv(t){const e=typeof t=="string"?{filename:t}:t??{},s=this._d.getData(),o=this._d.getColLayout().visibleLeaves,i=o.map(l=>`"${l.header}"`).join(","),n=s.map(l=>o.map(a=>{const c=l[a.field]??"";if(e.maskOnExport&&a.mask&&this._d.getMaskEnabled(a.field))return Rt(String(c),a.mask);const u=c;return typeof u=="string"&&u.includes(",")?`"${u}"`:u}).join(",")),r=e.filename??"export.csv";Nt("\uFEFF"+[i,...n].join(`
57
+ `),r)}exportJson(t){const e=typeof t=="string"?t:(t==null?void 0:t.filename)??"export.json";Nt(JSON.stringify(this._d.getData(),null,2),e,"application/json")}print(t){const e=(t==null?void 0:t.title)??"OPEN_GRID",s=(t==null?void 0:t.footerText)??"",o=this._d.getData(),i=this._d.getColLayout().visibleLeaves.filter(u=>{var h;return!((h=t==null?void 0:t.excludeFields)!=null&&h.includes(u.field))}),n=i.map(u=>`<th>${u.header??u.field}</th>`).join(""),r=o.map(u=>`<tr>${i.map(h=>`<td>${String(u[h.field]??"")}</td>`).join("")}</tr>`).join(""),l=s?`<div class="og-print-footer">${s}</div>`:"",a=`<!DOCTYPE html>
58
+ <html lang="ko"><head>
59
+ <meta charset="UTF-8"><title>${e}</title>
60
+ <style>
61
+ @page{margin:0;}
62
+ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;font-size:12px;margin:0;padding:1cm;}
63
+ h2{margin:0 0 10px;font-size:14px;color:#333;}
64
+ p{margin:0 0 8px;font-size:11px;color:#999;}
65
+ table{border-collapse:collapse;width:100%;}
66
+ th,td{border:1px solid #ccc;padding:5px 8px;text-align:left;white-space:nowrap;}
67
+ th{background:#f5f5f5;font-weight:600;color:#333;}
68
+ tr:nth-child(even) td{background:#fafafa;}
69
+ .og-print-footer{position:fixed;bottom:0;left:0;right:0;padding:6px 1cm;font-size:10px;color:#888;border-top:1px solid #e5e7eb;background:#fff;text-align:center;}
70
+ </style>
71
+ </head><body>
72
+ <h2>${e}</h2>
73
+ <p>${o.length}행 × ${i.length}열 · ${new Date().toLocaleString("ko-KR")}</p>
74
+ <table>
75
+ <thead><tr>${n}</tr></thead>
76
+ <tbody>${r}</tbody>
77
+ </table>
78
+ ${l}
79
+ <script>window.addEventListener('load',()=>{window.print();window.addEventListener('afterprint',()=>window.close());});<\/script>
80
+ </body></html>`,c=window.open("","_blank","width=960,height=640");c&&(c.document.write(a),c.document.close())}exportSheetsExcel(t){const e=this._d.getWsManager();if(!e){this.exportExcel(t??"workbook");return}const s=t??"workbook.xlsx",o=(this._d.getStrategy??((i,n)=>n))("cellSerializer",(i,n,r)=>typeof i=="boolean"?i?"✓":"":n.type==="number"&&typeof i=="number"?i:String(i));Promise.resolve().then(()=>require("./xlsx.min-Bx-LxWOf.cjs")).then(i=>i.xlsx_min).then(({utils:i,writeFile:n})=>{const r=i.book_new(),l=this._d.getOptions();for(const a of e.getNames()){const c=e.get(a),u=c.columns.length?c.columns:l.columns,h=[u.map(k=>k.header)];for(const k of c.data)h.push(u.map(y=>{const b=k[y.field];return b==null?"":o(b,y,k)}));const g=i.aoa_to_sheet(h);g["!cols"]=u.map(()=>({wpx:100})),i.book_append_sheet(r,g,a)}n(r,s.endsWith(".xlsx")?s:s+".xlsx",{cellStyles:!0})}).catch(()=>console.error("exportSheetsExcel: xlsx 패키지를 확인하세요."))}}class Xe{constructor(t){this._d=t}fmtNum(t,e){if(!e)return Math.round(t).toLocaleString("ko-KR");const s=e.match(/[#0][#0,]*(?:\.[#0]+)?|\d+/),o=s?e.slice(0,s.index):"",i=s?e.slice(s.index+s[0].length):"",n=s?s[0]:e,r=n.includes("#")||n.includes(","),l=n.match(/\.(\d+)$/),a=l?parseInt(l[1],10):/^\d+$/.test(n)?parseInt(n,10):0,c=Math.abs(t).toFixed(a),[u="0",h]=c.split("."),g=r?u.replace(/\B(?=(\d{3})+(?!\d))/g,","):u,k=h!==void 0?`${g}.${h}`:g,y=`${o}${k}${i}`;return t<0?`-${y}`:y}computeValues(){const t=this._d.getOptions().footer;if(!t||t.length===0)return[];const e=this._d.getData();return t.filter(s=>s.field&&s.op).map(s=>{const o=s.field,i=s.op,n=e.map(h=>h[o]).filter(h=>h!=null&&h!=="");let r=null;const l=i.toUpperCase(),a=(this._d.getStrategy??((h,g)=>g))("summaryOp",null);if(a){const h=a(l,n,o);if(h!=null)return{_field:o,_value:h,_formatted:this.fmtNum(h,s.format)}}if(l==="SUM")r=n.length>0?C.sum(n.map(h=>String(h))):null;else if(l==="AVG")r=n.length>0?C.sum(n.map(h=>String(h))).div(C.from(String(n.length))):null;else if(l==="COUNT"){const h=n.length;return{_field:o,_value:h,_formatted:h.toLocaleString("ko-KR")}}else l==="MAX"?r=n.length>0?C.max(n.map(h=>String(h))):null:l==="MIN"&&(r=n.length>0?C.min(n.map(h=>String(h))):null);if(!r)return{_field:o,_value:null,_formatted:""};const c=r.toNumber(),u=this.fmtNum(c,s.format);return{_field:o,_value:c,_formatted:u}})}render(){var u;const t=this._d.getContainer(),e=t.querySelector(".og-footer-bar");e==null||e.remove();const s=this._d.getOptions(),o=s.footer;if(!o||o.length===0)return;const i=this._d.getColLayout().visibleLeaves,n=this._d.getColWidths()??i.map(h=>h.width??100),r=new Map(this.computeValues().map(h=>[h._field,h])),l=document.createElement("div");l.className="og-footer-bar",l.style.cssText=["display:flex;align-items:stretch;",`min-height:${s.footerHeight}px;`,"border-top:2px solid var(--og-primary,#1976d2);","background:var(--og-header-bg,#f5f5f5);","overflow:hidden;flex-shrink:0;font-size:13px;font-weight:600;"].join("");let a=0;if(s.stateColumn&&(a+=24),s.draggable&&(a+=18),s.rowNumber&&(a+=44),s.checkColumn&&(a+=36),a>0){const h=document.createElement("div");h.style.cssText=`width:${a}px;flex-shrink:0;border-right:1px solid var(--og-border-color,#e0e0e0);`,l.appendChild(h)}let c=0;for(const h of o){const g=Math.max(1,h.colspan??1);let k=0;for(let v=0;v<g;v++)k+=n[c+v]??100;const y=i[c];c+=g;const b=document.createElement("div");b.style.cssText=[`width:${k}px;min-width:${k}px;flex-shrink:0;`,"padding:4px 8px;box-sizing:border-box;overflow:hidden;","border-right:1px solid var(--og-border-color,#e0e0e0);","white-space:nowrap;text-overflow:ellipsis;"].join("");const x=h.field,p=x?r.get(x):null;if(p){const v=p._formatted??String(p._value??""),T=h.label?`${h.label}: `:"";b.textContent=T+v,b.title=`${((u=h.op)==null?void 0:u.toUpperCase())??""} = ${v}`,b.style.color="var(--og-primary,#1976d2)",b.style.textAlign=h.align??((y==null?void 0:y.type)==="number","right")}else h.label&&(b.textContent=h.label,b.style.textAlign=h.align??"left",b.style.color="var(--og-row-color,#212121)");l.appendChild(b)}s.footerPosition==="top"?t.insertBefore(l,t.firstChild):t.appendChild(l)}}class Ye{constructor(t){this._d=t}handleKeyDown(t){const e=this._d.getEditMgr();if(e.activeEditor)return;this._d.handleCellKeyEvt("cellKeyDown",t);const s=this._d.getData(),o=this._d.getColLayout(),i=s.rowCount,n=o.visibleLeaves.length;if(i===0||n===0)return;if((t.ctrlKey||t.metaKey)&&t.key==="c"){t.preventDefault(),this._copyToClipboard();return}if((t.ctrlKey||t.metaKey)&&t.key==="v"){t.preventDefault(),this._pasteFromClipboard();return}const r=this._d.getOptions();if((t.ctrlKey||t.metaKey)&&r.draggable&&e.focusCell){if(t.key==="ArrowDown"){t.preventDefault();const l=e.focusCell.ci!==void 0?e.focusCell.ri:0;l<i-1&&(this._d.handleRowDrop(l,l+1),this._d.setFocusCell(l+1,e.focusCell.ci),this._d.announce(`행 ${l+1}을(를) ${l+2}번째 위치로 이동`));return}if(t.key==="ArrowUp"){t.preventDefault();const l=e.focusCell.ri;l>0&&(this._d.handleRowDrop(l,l-1),this._d.setFocusCell(l-1,e.focusCell.ci),this._d.announce(`행 ${l+1}을(를) ${l}번째 위치로 이동`));return}}switch(t.key){case"ArrowDown":{t.preventDefault();const l=e.focusCell,a=l?Math.min(l.ri+1,i-1):0;this._d.setFocusCell(a,(l==null?void 0:l.ci)??0);break}case"ArrowUp":{t.preventDefault();const l=e.focusCell,a=l?Math.max(l.ri-1,0):0;this._d.setFocusCell(a,(l==null?void 0:l.ci)??0);break}case"ArrowRight":{t.preventDefault();const l=e.focusCell;if(!l){this._d.setFocusCell(0,0);break}l.ci<n-1?this._d.setFocusCell(l.ri,l.ci+1):l.ri<i-1&&this._d.setFocusCell(l.ri+1,0);break}case"ArrowLeft":{t.preventDefault();const l=e.focusCell;if(!l){this._d.setFocusCell(0,0);break}l.ci>0?this._d.setFocusCell(l.ri,l.ci-1):l.ri>0&&this._d.setFocusCell(l.ri-1,n-1);break}case"Tab":{t.preventDefault();const l=e.focusCell;if(!l){this._d.setFocusCell(0,0);break}t.shiftKey?l.ci>0?this._d.setFocusCell(l.ri,l.ci-1):l.ri>0&&this._d.setFocusCell(l.ri-1,n-1):l.ci<n-1?this._d.setFocusCell(l.ri,l.ci+1):l.ri<i-1&&this._d.setFocusCell(l.ri+1,0);break}case"Home":{if(t.preventDefault(),t.ctrlKey||t.metaKey)this._d.setFocusCell(0,0);else{const l=e.focusCell;this._d.setFocusCell((l==null?void 0:l.ri)??0,0)}break}case"End":{if(t.preventDefault(),t.ctrlKey||t.metaKey)this._d.setFocusCell(i-1,n-1);else{const l=e.focusCell;this._d.setFocusCell((l==null?void 0:l.ri)??0,n-1)}break}case"PageDown":{t.preventDefault();const l=e.focusCell,a=this._d.getOptions().pageSize??10,c=Math.min(l?l.ri+a:a-1,i-1);this._d.setFocusCell(c,(l==null?void 0:l.ci)??0);break}case"PageUp":{t.preventDefault();const l=e.focusCell,a=this._d.getOptions().pageSize??10,c=l?Math.max(l.ri-a,0):0;this._d.setFocusCell(c,(l==null?void 0:l.ci)??0);break}case" ":{if(e.focusCell){t.preventDefault();const l=e.focusCell.ri,a=this._d.getRowMgr();this._d.getOptions().checkColumn?(a.check(l,!a.checkedRows.has(l)),this._d.doRender()):(a.selectToggle(l),this._d.doRender())}break}case"F2":case"Enter":{e.focusCell&&this._d.getOptions().editable&&(t.preventDefault(),e.startEditByKey(e.focusCell.ri,e.focusCell.ci));break}case"Escape":{e.clearFocusCell(),this._d.doRender();break}}}_copyToClipboard(){var n;if(!this._d.getOptions().clipboard)return;const e=this._d.getEditMgr(),s=this._d.getColLayout(),o=this._d.getData();let i="";if(e.focusCell){const{ri:r,ci:l}=e.focusCell,a=s.visibleLeaves[l];a&&(i=String(o.getCellValue(r,a.field)??""))}else if(this._d.getRowMgr().selectedRows.size>0){const r=s.visibleLeaves;i=[...this._d.getRowMgr().selectedRows].sort((a,c)=>a-c).map(a=>{const c=o.getRowByIndex(a);return r.map(u=>String((c==null?void 0:c[u.field])??"")).join(" ")}).join(`
81
+ `)}i&&((n=navigator.clipboard)==null||n.writeText(i).catch(()=>{}))}_pasteFromClipboard(){var s;const t=this._d.getOptions();if(!t.clipboard||!t.editable)return;const e=this._d.getEditMgr();e.focusCell&&((s=navigator.clipboard)==null||s.readText().then(o=>{if(!o)return;const{ri:i,ci:n}=e.focusCell,r=o.split(`
82
+ `),l=this._d.getColLayout().visibleLeaves,a=this._d.getData();for(let c=0;c<r.length;c++){const u=r[c].split(" ");for(let h=0;h<u.length;h++){const g=i+c,k=n+h,y=l[k];y&&g<a.rowCount&&a.updateCell(g,y.field,u[h])}}this._d.emit("dataChange",a.getData()),this._d.doRender()}).catch(()=>{}))}}class Je{constructor(t){this._bar=null,this._input=null,this._count=null,this._filter="",this._d=t}get findFilter(){return this._filter}init(t){const e=document.createElement("div");e.className="og-find-bar",e.hidden=!0;const s=document.createElement("span");s.className="og-find-label",s.textContent="찾기";const o=document.createElement("input");o.type="text",o.className="og-find-input",o.placeholder="검색어 입력...",o.setAttribute("aria-label","그리드 내 검색");const i=document.createElement("span");i.className="og-find-count";const n=document.createElement("button");n.className="og-find-close",n.textContent="✕",n.setAttribute("aria-label","찾기 닫기"),e.appendChild(s),e.appendChild(o),e.appendChild(i),e.appendChild(n),t.insertBefore(e,t.firstChild),o.addEventListener("input",()=>{this._filter=o.value.trim(),this._apply()}),o.addEventListener("keydown",r=>{r.key==="Escape"&&this.close()}),n.addEventListener("click",()=>this.close()),this._bar=e,this._input=o,this._count=i}open(){this._bar&&(this._bar.hidden=!1,this._input.focus(),this._input.select())}close(){this._bar&&(this._bar.hidden=!0,this._filter="",this._input.value="",this._count&&(this._count.textContent=""),this._apply())}_apply(){var o,i;const t=this._d.getData(),e=this._d.getColLayout().visibleLeaves.map(n=>n.field);t.setFindFilter(this._filter,e),t.applyFilter(this._d.getFilters());const s=t.rowCount;(o=this._d.getVs())==null||o.setTotalRows(s),(i=this._d.getPagination())==null||i.setTotalRows(s),this._count&&(this._count.textContent=this._filter?`${s}건`:""),this._d.doRender()}}function Qt(d){return d&&d._isGroup===!0}function Gt(d,t,e=[],s=new Set,o,i){return t.length?Zt(d,t,0,e,s,"",o,i):[]}function Zt(d,t,e,s,o,i,n,r){const l=t[e],a=new Map;for(const u of d){const h=r?r(u,t.slice(e)):u[l];a.has(h)||a.set(h,[]),a.get(h).push(u)}const c=[];for(const[u,h]of a){const g=`${i}__${l}:${u}`,k=o.has(g);let y;e<t.length-1?y=Zt(h,t,e+1,s,o,g,n,r):y=h;const{summary:b,summaryFmt:x}=Qe(h,s),p=Ze(h,n);c.push({_isGroup:!0,_groupField:l,_groupValue:u,_groupLabel:u==null?"(없음)":String(u),_depth:e,_expanded:k,_childCount:h.length,_summary:b,_summaryFmt:x,_states:p,children:y})}return c}function Qe(d,t){const e={},s={};for(const o of t){const i=d.map(a=>a[o.field]).filter(a=>a!=null&&a!=="");let n=null;const r=o.op.toUpperCase();if(r==="SUM")n=i.length>0?C.sum(i.map(String)):null;else if(r==="AVG")n=i.length>0?C.sum(i.map(String)).div(C.from(String(i.length))):null;else if(r==="COUNT"){e[o.field]=d.length,s[o.field]=d.length.toLocaleString("ko-KR");continue}else r==="MAX"?n=i.length>0?C.max(i.map(String)):null:r==="MIN"&&(n=i.length>0?C.min(i.map(String)):null);if(!n){e[o.field]=null,s[o.field]="";continue}const l=n.toNumber();e[o.field]=l,s[o.field]=ts(l,o.format)}return{summary:e,summaryFmt:s}}function Ze(d,t){if(!t)return{added:0,edited:0,removed:0};let e=0,s=0,o=0;for(const i of d){const n=t(i);n==="added"?e++:n==="edited"?s++:n==="removed"&&o++}return{added:e,edited:s,removed:o}}function ts(d,t){if(t==null)return d%1===0?d.toLocaleString("ko-KR"):parseFloat(d.toFixed(6)).toLocaleString("ko-KR",{minimumFractionDigits:2,maximumFractionDigits:6});const e=t.includes("#")||t.includes(","),s=t.match(/\.(\d+)$/),o=s?parseInt(s[1],10):/^\d+$/.test(t)?parseInt(t,10):0,i=Math.abs(d).toFixed(o),[n="0",r]=i.split("."),l=e?n.replace(/\B(?=(\d{3})+(?!\d))/g,","):n,a=r!==void 0?`${l}.${r}`:l;return d<0?`-${a}`:a}function te(d){const t=[];for(const e of d)if(t.push(e),e._expanded)for(const s of e.children)Qt(s)?t.push(...te([s])):t.push(s);return t}function ee(d,t=""){const e=[];for(const s of d){const o=`${t}__${s._groupField}:${s._groupValue}`;e.push(o);const i=s.children.filter(n=>Qt(n));i.length&&e.push(...ee(i,o))}return e}function Et(d,t,e=new Set){const{idField:s,parentIdField:o,expandOnLoad:i=!1}=t,n=new Map,r=[];for(const c of d){const u=c[s],h={_isTree:!0,_treeId:u,_treeParentId:c[o],_depth:0,_expanded:i||e.has(u),_hasChildren:!1,_childCount:0,_isLastChild:!1,_ancestorHasMore:[],data:c,children:[]};n.set(u,h)}for(const c of n.values()){const u=c._treeParentId;if(u==null||u===""||!n.has(u))r.push(c);else{const g=n.get(u);g.children.push(c),g._hasChildren=!0}}function l(c,u){for(const h of c)h._depth=u,h._childCount=se(h),l(h.children,u+1)}l(r,0);function a(c,u){for(let h=0;h<c.length;h++){const g=c[h],k=h===c.length-1;g._isLastChild=k,g._ancestorHasMore=u,g.children.length>0&&a(g.children,[...u,!k])}}return a(r,[]),r}function se(d){let t=d.children.length;for(const e of d.children)t+=se(e);return t}function ie(d){const t=[];for(const e of d)t.push(e),e._expanded&&e.children.length>0&&t.push(...ie(e.children));return t}function es(d,t){d.has(t)?d.delete(t):d.add(t)}function St(d){const t=[];for(const e of d)t.push(e._treeId),e.children.length&&t.push(...St(e.children));return t}class ss{constructor(t){this._groupFields=[],this._groupExpandedKeys=new Set,this._groupFlatRows=[],this._isGroupMode=!1,this._treeRoots=[],this._treeFlatRows=[],this._treeExpandedKeys=new Set,this._isTreeMode=!1,this._d=t}get isGroupMode(){return this._isGroupMode}get isTreeMode(){return this._isTreeMode}get groupFlatRows(){return this._groupFlatRows}get treeFlatRows(){return this._treeFlatRows}groupBy(t){this._groupFields=t,this._groupExpandedKeys.clear(),this._isGroupMode=t.length>0,this.rebuildGroups()}clearGroup(){var e;this._groupFields=[],this._groupExpandedKeys.clear(),this._isGroupMode=!1,this._groupFlatRows=[];const t=this._d.getData().length;(e=this._d.getVs())==null||e.setTotalRows(t),this._d.doRender()}expandAll(){if(!this._isGroupMode)return;const t=Gt(this._d.getData(),this._groupFields,this._getSummaryDefs(),void 0,void 0,this._groupKeyFn());ee(t).forEach(e=>this._groupExpandedKeys.add(e)),this.rebuildGroups()}_groupKeyFn(){return this._d.getStrategy?this._d.getStrategy("groupKeyFn",void 0):void 0}collapseAll(){this._groupExpandedKeys.clear(),this._isGroupMode&&this.rebuildGroups()}handleGroupToggle(t){this._groupExpandedKeys.has(t)?this._groupExpandedKeys.delete(t):this._groupExpandedKeys.add(t),this.rebuildGroups()}rebuildGroups(){var i;const t=this._d.getData(),e=this._d.getDataLayer(),s=n=>{const r=t.indexOf(n);return r>=0?e.getRowState(r):"none"},o=Gt(t,this._groupFields,this._getSummaryDefs(),this._groupExpandedKeys,s,this._groupKeyFn());this._groupFlatRows=te(o),(i=this._d.getVs())==null||i.setTotalRows(this._groupFlatRows.length),this._d.doRenderFull(this._groupFlatRows.length)}enableTree(){this._isTreeMode=!0,this._isGroupMode=!1;const t=this._d.getOptions();if(t.expandOnLoad){const e=Et(this._d.getData(),{idField:t.treeId,parentIdField:t.treeParentId});St(e).forEach(s=>this._treeExpandedKeys.add(s))}this.rebuildTree()}disableTree(){var e;this._isTreeMode=!1,this._treeRoots=[],this._treeFlatRows=[],this._treeExpandedKeys.clear();const t=this._d.getData().length;(e=this._d.getVs())==null||e.setTotalRows(t),this._d.doRender()}expandNodes(t,e=!0){const s=Array.isArray(t)?t:[t];for(const o of s)e?this._treeExpandedKeys.add(o):this._treeExpandedKeys.delete(o);this._isTreeMode&&this.rebuildTree()}expandAllNodes(){this._isTreeMode&&(St(this._treeRoots).forEach(t=>this._treeExpandedKeys.add(t)),this.rebuildTree())}collapseAllNodes(){this._isTreeMode&&(this._treeExpandedKeys.clear(),this.rebuildTree())}handleTreeToggle(t){es(this._treeExpandedKeys,t),this.rebuildTree()}rebuildTree(){var e;const t=this._d.getOptions();this._treeRoots=Et(this._d.getData(),{idField:t.treeId,parentIdField:t.treeParentId,expandOnLoad:t.expandOnLoad},this._treeExpandedKeys),this._treeFlatRows=ie(this._treeRoots),(e=this._d.getVs())==null||e.setTotalRows(this._treeFlatRows.length),this._d.doRenderFull(this._treeFlatRows.length)}_getSummaryDefs(){const t=this._d.getOptions().summary;if(!t)return[];if(t.rows&&t.rows.length>0)return t.fields.flatMap(s=>t.rows.map(o=>({field:s,op:o.op,format:o.format})));const e=Array.isArray(t.ops)?t.ops:t.ops?[t.ops]:["SUM"];return t.fields.map(s=>({field:s,op:e[0]??"SUM",format:t.format}))}}class is{constructor(t){this._sortList=[],this._filters={},this._d=t}get sortList(){return this._sortList}get filters(){return this._filters}handleSortClick(t,e){var r;const s=this._d.getOptions();if(!s.sortable)return;const o=this._sortList.findIndex(l=>l.field===t);if(o>=0){const l=this._sortList[o];l.dir==="asc"?l.dir="desc":this._sortList.splice(o,1)}else(!e||!s.multiSort)&&(this._sortList=[]),this._sortList.push({field:t,dir:"asc"});this._d.getData().applySort(this._sortList),this._d.renderHeader(),this._d.doRender();const i=this._sortList.find(l=>l.field===t),n=i?i.dir==="asc"?"오름차순":"내림차순":"정렬 해제";this._d.announce(`${t} ${n} 정렬`),this._d.emit("sortChange",{sortList:this._sortList}),(r=s.onSortChange)==null||r.call(s,{field:t,dir:(i==null?void 0:i.dir)??"asc",sortList:this._sortList})}sort(t,e="asc"){if(Array.isArray(t))this._sortList=t;else{const s=this._sortList.findIndex(o=>o.field===t);s>=0?this._sortList[s].dir=e:this._sortList=[{field:t,dir:e}],this._d.getOptions().multiSort||(this._sortList=this._sortList.slice(-1))}this._d.getData().applySort(this._sortList),this._d.renderHeader(),this._d.doRender(),this._d.emit("sortChange",{sortList:this._sortList})}resetSort(){this._sortList=[],this._d.getData().applySort([]),this._d.renderHeader(),this._d.doRender()}initSort(t){this._sortList=[...t],this._d.getData().applySort(this._sortList)}getSortState(){return[...this._sortList]}setFilter(t,e){var s,o;this._filters[t]=e,this.applyFilters(),this._d.renderHeader(),this._d.doRender(),this._d.emit("filterChange",{field:t,filterItems:e,allFilters:this._filters}),(o=(s=this._d.getOptions()).onFilterChange)==null||o.call(s,{field:t,filterItems:e,allFilters:this._filters})}resetFilter(t){t?delete this._filters[t]:this._filters={},this.applyFilters(),this._d.renderHeader(),this._d.doRender()}getFilterState(){return{...this._filters}}restoreFilter(t){this._filters={...t},this.applyFilters()}applyFilters(){var s,o;const t=this._d.getData();t.setFindFilter(this._d.getFindFilter(),this._d.getColLayout().visibleLeaves.map(i=>i.field)),t.applyFilter(this._filters);const e=t.rowCount;(s=this._d.getVs())==null||s.setTotalRows(e),(o=this._d.getPagination())==null||o.setTotalRows(e)}}class os{constructor(t){this._d=t}handleCellClick(t,e,s){var a,c,u,h,g,k,y;const o=this._d.getOptions(),i=this._d.getRowMgr(),n=this._d.getEditMgr();o.selection==="single"||o.selection==="row"?i.selectSingle(t):o.selection==="multiple"&&(s.ctrlKey||s.metaKey?i.selectToggle(t):i.selectSingle(t));const r=this._d.getData().getRowByIndex(t),l=this._d.getColLayout().visibleLeaves[e];if(r&&l){const b=l.editable!==!1&&(l.editable!==void 0||o.editable);if(rt(l)&&b){const E=r[l.field];this._d.writeCell(t,l.field,!E)}if(l.type==="radio"){const E=l.group;for(const f of this._d.getColLayout().visibleLeaves)f.type==="radio"&&f.field!==l.field&&(!E||f.group===E)&&this._d.getData().updateCell(t,f.field,!1);this._d.writeCell(t,l.field,!0)}let x=r[l.field];if(x===void 0&&l.formula)try{const E=l.formulaPrecision??30,f=Xt(l.formula,r,E);x=f instanceof C?l.precision!=null?f.toFixed(l.precision):f.toString():String(f)}catch{}const p={type:"cellClick",rowIndex:t,columnIndex:e,field:l.field,value:x,row:r,column:l,target:s.target,originalEvent:s};this._d.emit("cellClick",p),(a=o.onCellClick)==null||a.call(o,p);const v={type:"rowClick",rowIndex:t,row:r,target:s.target,originalEvent:s};this._d.emit("rowClick",v),(c=o.onRowClick)==null||c.call(o,v);const T=l.type==="select";!(n.activeEditor!=null&&((u=n.editCell)==null?void 0:u.ri)===t&&((h=n.editCell)==null?void 0:h.ci)===e)&&(o.editMode==="click"||T)&&!rt(l)&&n.startEdit(t,e,s)}n.activeEditor&&((g=n.editCell)==null?void 0:g.ri)===t&&((k=n.editCell)==null?void 0:k.ci)===e||(this._d.doRender(),this._d.emit("selectionChange",{rows:i.getSelections(),rowIndexes:[...i.selectedRows]}),(y=o.onSelectionChange)==null||y.call(o,{rows:i.getSelections(),rowIndexes:[...i.selectedRows],cells:[]}))}handleCellDblClick(t,e,s){var a,c;const o=this._d.getData().getRowByIndex(t),i=this._d.getColLayout().visibleLeaves[e];if(!o||!i)return;const n=this._d.getOptions(),r={type:"cellDblClick",rowIndex:t,columnIndex:e,field:i.field,value:o[i.field],row:o,column:i,target:s.target,originalEvent:s};this._d.emit("cellDblClick",r),(a=n.onCellDblClick)==null||a.call(n,r);const l={type:"rowDblClick",rowIndex:t,row:o,target:s.target,originalEvent:s};this._d.emit("rowDblClick",l),(c=n.onRowDblClick)==null||c.call(n,l),n.editMode==="dblclick"&&this._d.getEditMgr().startEdit(t,e,s)}handleCellMouseOver(t,e,s){var a,c;const o=this._d.getData().getRowByIndex(t),i=this._d.getColLayout().visibleLeaves[e];if(!o||!i)return;const n=this._d.getOptions(),r={type:"cellMouseOver",rowIndex:t,columnIndex:e,field:i.field,value:o[i.field],row:o,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseOver",r),(a=n.onCellMouseOver)==null||a.call(n,r);const l={type:"rowMouseOver",rowIndex:t,row:o,target:s.target,originalEvent:s};this._d.emit("rowMouseOver",l),(c=n.onRowMouseOver)==null||c.call(n,l)}handleCellMouseOut(t,e,s){var a,c;const o=this._d.getData().getRowByIndex(t),i=this._d.getColLayout().visibleLeaves[e];if(!o||!i)return;const n=this._d.getOptions(),r={type:"cellMouseOut",rowIndex:t,columnIndex:e,field:i.field,value:o[i.field],row:o,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseOut",r),(a=n.onCellMouseOut)==null||a.call(n,r);const l={type:"rowMouseOut",rowIndex:t,row:o,target:s.target,originalEvent:s};this._d.emit("rowMouseOut",l),(c=n.onRowMouseOut)==null||c.call(n,l)}handleCellMouseDown(t,e,s){var a,c;const o=this._d.getData().getRowByIndex(t),i=this._d.getColLayout().visibleLeaves[e];if(!o||!i)return;const n=this._d.getOptions(),r={type:"cellMouseDown",rowIndex:t,columnIndex:e,field:i.field,value:o[i.field],row:o,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseDown",r),(a=n.onCellMouseDown)==null||a.call(n,r);const l={type:"rowMouseDown",rowIndex:t,row:o,target:s.target,originalEvent:s};this._d.emit("rowMouseDown",l),(c=n.onRowMouseDown)==null||c.call(n,l)}handleCellMouseUp(t,e,s){var a,c;const o=this._d.getData().getRowByIndex(t),i=this._d.getColLayout().visibleLeaves[e];if(!o||!i)return;const n=this._d.getOptions(),r={type:"cellMouseUp",rowIndex:t,columnIndex:e,field:i.field,value:o[i.field],row:o,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseUp",r),(a=n.onCellMouseUp)==null||a.call(n,r);const l={type:"rowMouseUp",rowIndex:t,row:o,target:s.target,originalEvent:s};this._d.emit("rowMouseUp",l),(c=n.onRowMouseUp)==null||c.call(n,l)}handleCellMouseMove(t,e,s){var a,c;const o=this._d.getData().getRowByIndex(t),i=this._d.getColLayout().visibleLeaves[e];if(!o||!i)return;const n=this._d.getOptions(),r={type:"cellMouseMove",rowIndex:t,columnIndex:e,field:i.field,value:o[i.field],row:o,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseMove",r),(a=n.onCellMouseMove)==null||a.call(n,r);const l={type:"rowMouseMove",rowIndex:t,row:o,target:s.target,originalEvent:s};this._d.emit("rowMouseMove",l),(c=n.onRowMouseMove)==null||c.call(n,l)}handleCellKeyEvt(t,e){var c,u,h;const s=this._d.getEditMgr();if(!s.focusCell||s.activeEditor)return;const{ri:o,ci:i}=s.focusCell,n=this._d.getData().getRowByIndex(o),r=this._d.getColLayout().visibleLeaves[i];if(!n||!r)return;const l=this._d.getOptions(),a={type:t,rowIndex:o,columnIndex:i,field:r.field,value:n[r.field],row:n,column:r,key:e.key,target:this._d.getContainer(),originalEvent:e};this._d.emit(t,a),t==="cellKeyDown"?(c=l.onCellKeyDown)==null||c.call(l,a):t==="cellKeyUp"?(u=l.onCellKeyUp)==null||u.call(l,a):(h=l.onCellKeyPress)==null||h.call(l,a)}}class ns{constructor(){this._triggers=new Map}add(t,e){this._triggers.has(t)||this._triggers.set(t,[]),this._triggers.get(t).push(e)}remove(t,e){const s=this._triggers.get(t);if(s){const o=s.indexOf(e);o>=0&&s.splice(o,1)}}clear(t){t?this._triggers.delete(t):this._triggers.clear()}mkCtx(t,e){let s=!1;return{operation:t,args:e,result:void 0,extra:{},timestamp:Date.now(),get cancelled(){return s},cancel(){s=!0}}}exec(t,e){const s=this._triggers.get(t)??[];for(const o of s)if(o(e),e.cancelled)return!1;if(t.startsWith("after:")){const o=this._triggers.get("complete")??[];for(const i of o)i(e)}return!0}}const ut="";function oe(d){const t=Object.entries(d).filter(([,e])=>e!==ut).map(([e,s])=>` ${JSON.stringify(e)}: src[${JSON.stringify(s)}],`);return`// crossGridMapping 옵션에 이 함수를 그대로 지정하세요.
83
+ function mapRow(src) {
84
+ return {
85
+ `+t.join(`
86
+ `)+(t.length?`
87
+ `:"")+` };
88
+ }`}function rs(d){return t=>{const e={};for(const[s,o]of Object.entries(d))o!==ut&&(e[s]=t[o]);return e}}function ls(d,t){if(d.length!==t.length)return!1;const e=new Set(t);return d.every(s=>e.has(s))}function as(d,t){return new Promise(e=>{const s=new Set(d.map(E=>E.field)),o={};for(const E of t)o[E.field]=s.has(E.field)?E.field:ut;const i=document.createElement("div");i.className="og-mapper-overlay",i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label","그리드 필드 매핑"),i.style.cssText="position:fixed;inset:0;z-index:100000;background:rgba(0,0,0,0.45);display:flex;align-items:center;justify-content:center;font-family:var(--og-font-family,-apple-system,sans-serif);";const n=document.createElement("div");n.style.cssText="background:#fff;border-radius:10px;box-shadow:0 12px 40px rgba(0,0,0,0.3);width:min(620px,92vw);max-height:88vh;overflow:auto;color:#222;",i.appendChild(n);const r=document.createElement("div");r.style.cssText="padding:18px 20px 8px;",r.innerHTML='<div style="font-size:16px;font-weight:700;">필드 매핑</div><div style="font-size:12.5px;color:#666;margin-top:4px;line-height:1.5;">두 그리드의 필드 구조가 다릅니다. <b>타깃 필드</b>마다 어떤 <b>소스 필드</b>의 값을 가져올지 지정하세요. 아래 스크립트를 복사해 <code>crossGridMapping</code> 에 baking 하면 다음부터는 이 창 없이 자동 변환됩니다.</div>',n.appendChild(r);const l=document.createElement("div");l.style.cssText="padding:6px 20px;";const a='<option value="">(비움)</option>'+d.map(E=>`<option value="${ot(E.field)}">${ot(E.header)} &lt;${ot(E.field)}&gt;</option>`).join("");for(const E of t){const f=document.createElement("div");f.style.cssText="display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid #f0f0f0;";const $=document.createElement("div");$.style.cssText="flex:1;font-size:13px;min-width:0;",$.innerHTML=`<span style="font-weight:600;">${ot(E.header)}</span><span style="color:#999;font-size:11.5px;"> &lt;${ot(E.field)}&gt;</span>`;const B=document.createElement("span");B.textContent="←",B.style.cssText="color:#888;flex-shrink:0;";const z=document.createElement("select");z.style.cssText="flex:1;min-width:0;padding:6px 8px;border:1px solid #ccc;border-radius:6px;font-size:13px;background:#fff;",z.innerHTML=a,z.value=o[E.field]??ut,z.addEventListener("change",()=>{o[E.field]=z.value,y()}),f.append($,B,z),l.appendChild(f)}n.appendChild(l);const c=document.createElement("div");c.style.cssText="padding:10px 20px 4px;";const u=document.createElement("div");u.style.cssText="display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;",u.innerHTML='<span style="font-size:12.5px;font-weight:600;color:#444;">생성된 변환 스크립트</span>';const h=document.createElement("button");h.type="button",h.textContent="복사",h.style.cssText="font-size:12px;padding:4px 10px;border:1px solid #ccc;border-radius:6px;background:#f7f7f7;cursor:pointer;",u.appendChild(h);const g=document.createElement("pre");g.style.cssText="margin:0;background:#0d1117;color:#c9d1d9;padding:12px;border-radius:8px;font-family:ui-monospace,Consolas,monospace;font-size:12px;line-height:1.5;overflow:auto;max-height:180px;",c.append(u,g),n.appendChild(c);function k(){return oe(o)}function y(){g.textContent=k()}y(),h.addEventListener("click",()=>{var f;const E=k();(f=navigator.clipboard)==null||f.writeText(E).then(()=>{h.textContent="복사됨!",setTimeout(()=>h.textContent="복사",1200)},()=>{h.textContent="복사 실패",setTimeout(()=>h.textContent="복사",1200)})});const b=document.createElement("div");b.style.cssText="display:flex;justify-content:flex-end;gap:8px;padding:14px 20px 18px;";const x=document.createElement("button");x.type="button",x.textContent="취소",x.style.cssText="font-size:13px;padding:8px 16px;border:1px solid #ccc;border-radius:7px;background:#fff;cursor:pointer;";const p=document.createElement("button");p.type="button",p.textContent="적용 후 이동",p.style.cssText="font-size:13px;padding:8px 16px;border:0;border-radius:7px;background:#1976d2;color:#fff;cursor:pointer;font-weight:600;",b.append(x,p),n.appendChild(b);let v=!1;function T(E){v||(v=!0,document.removeEventListener("keydown",A),i.remove(),e(E))}function A(E){E.key==="Escape"&&T(null)}x.addEventListener("click",()=>T(null)),i.addEventListener("mousedown",E=>{E.target===i&&T(null)}),p.addEventListener("click",()=>T({mapping:{...o},script:k()})),document.addEventListener("keydown",A),document.body.appendChild(i),p.focus()})}function ot(d){return String(d).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}class ds{constructor(){this._map=new Map}register(t,e){this._map.set(t,e)}unregister(t){this._map.delete(t)}get(t){return this._map.get(t)}get size(){return this._map.size}resolveAt(t,e,s){const o=document.elementFromPoint(t,e),i=o==null?void 0:o.closest(".og-body-wrapper");if(!i)return null;const n=this._map.get(i);return!n||n===s?null:n}}const ht=new ds;class cs{constructor(t,e){this._originals=new Map,this._hadOwn=new Map,this._stack=new Map,this._strategies=new Map,this._callPath=[],this._host=t,this._strict=(e==null?void 0:e.strict)??!0,this._maxDepth=(e==null?void 0:e.maxDepth)??32}override(t,e,s={}){if(typeof e!="function")throw new TypeError(`OverrideKernel.override: fn for "${t}" must be a function`);if(!this._originals.has(t)){const i=this._host[t];if(typeof i!="function")throw new TypeError(`OverrideKernel.override: host["${t}"] is not a function`);this._hadOwn.set(t,Object.prototype.hasOwnProperty.call(this._host,t)),this._originals.set(t,i.bind(this._host))}const o=this._stack.get(t)??[];return o.push({fn:e,opts:s}),this._stack.set(t,o),this._host[t]=this._buildDispatcher(t),this._host}_buildDispatcher(t){var a;const e=this._originals.get(t),s=this._stack.get(t)??[],o=s.reduce((c,u)=>(...h)=>u.fn(c,...h),e),i=((a=s[s.length-1])==null?void 0:a.opts)??{},n=i.reentrant===!0,r=i.onError==="fallback",l=this;return function(...c){if(!n&&l._callPath.indexOf(t)!==-1)return e(...c);if(l._callPath.length>=l._maxDepth){if(l._strict&&!r)throw new Error(`OverrideKernel: max override depth (${l._maxDepth}) exceeded at "${t}"`);return e(...c)}l._callPath.push(t);try{return o(...c)}catch(u){if(r&&!l._strict)return console.warn(`[og.override:${t}]`,u),e(...c);if(r&&l._strict)return console.warn(`[og.override:${t}]`,u),e(...c);throw u}finally{l._callPath.pop()}}}strategy(t,e){if(typeof e!="function")throw new TypeError(`OverrideKernel.strategy: fn for "${t}" must be a function`);return this._strategies.set(t,e),this._host}getStrategy(t,e){return this._strategies.get(t)??e}hasStrategy(t){return this._strategies.has(t)}restore(t){return this._originals.has(t)?(this._hadOwn.get(t)?this._host[t]=this._originals.get(t):delete this._host[t],this._originals.delete(t),this._hadOwn.delete(t),this._stack.delete(t),this._host):this._host}restoreAll(){for(const t of[...this._originals.keys()])this.restore(t);return this._strategies.clear(),this._callPath=[],this._host}hasOverride(t){return this._originals.has(t)}getOverrideNames(){return[...this._originals.keys()]}}const qt="_ogRowId",U=class U extends re{constructor(t,e){var i;super(),this._vs=null,this._ro=null,this._renderer=null,this._trigMgr=new ns,this._destroyed=!1,this._autoHeightWarned=!1,this._colWidths=[],this._userWidths=new Map,this._filterPanel=null,this._filterSelect=null,this._pagination=null,this._dnd=null,this._mergeEngine=new tt,this._liveRegion=null,this._ctxMenu=null,this._cmHandler=null,this._cmKbdHandler=null,this._wsManager=null;const s=typeof t=="string"?document.querySelector(t):t;if(!s)throw new Error(`OpenGrid: container not found: ${t}`);this._container=s,this._options={height:"100%",width:"100%",rowHeight:32,headerHeight:34,footerHeight:30,autoHeight:!1,fillWidth:!1,defaultColumnWidth:100,editable:!1,editMode:"dblclick",history:!0,historySize:100,selection:"single",clipboard:!0,sortable:!0,multiSort:!0,filterable:!0,defaultSort:[],frozenColumns:0,frozenRows:0,rowNumber:!1,stateColumn:!1,checkColumn:!1,draggable:!1,crossGrid:!1,crossGridMapping:"auto",mergeCells:!1,groupBy:[],summary:void 0,treeMode:"auto",treeId:"id",treeParentId:"parentId",expandOnLoad:!1,pagination:!1,pageSize:50,footer:void 0,footerPosition:"bottom",theme:"default",cssVars:{},ariaLabel:"OPEN_GRID 데이터 그리드",...e},this._data=new ae(qt),this._rowMgr=new Oe(this._data),this._colLayout=new $t(this._options.columns,this._options.frozenColumns),this._editMgr=new We({data:this._data,colLayout:this._colLayout,getRenderer:()=>this._renderer,getContainer:()=>this._container,getOptions:()=>this._options,emit:(n,...r)=>this.emit(n,...r),doRender:()=>this._doRender(...this._visRange()),announce:n=>this._announce(n),writeCell:(n,r,l)=>this.writeCell(n,r,l),scrollToRow:n=>{var r;return(r=this._vs)==null?void 0:r.scrollToRow(n)},getVisibleLeaves:()=>this._colLayout.visibleLeaves}),this._exportMgr=new qe({getData:()=>this._data.getData(),getColLayout:()=>this._colLayout,getColWidths:()=>this._colWidths,getOptions:()=>this._options,getContainer:()=>this._container,getMaskEnabled:n=>this.getMaskEnabled(n),getWsManager:()=>this._wsManager,getStrategy:(n,r)=>this._ovk.getStrategy(n,r)}),this._footerMgr=new Xe({getData:()=>this._data.getData(),getColLayout:()=>this._colLayout,getColWidths:()=>this._colWidths,getOptions:()=>this._options,getContainer:()=>this._container,getStrategy:(n,r)=>this._ovk.getStrategy(n,r)}),this._kbdMgr=new Ye({getEditMgr:()=>this._editMgr,getRowMgr:()=>this._rowMgr,getData:()=>this._data,getColLayout:()=>this._colLayout,getOptions:()=>this._options,setFocusCell:(n,r)=>this._setFocusCell(n,r),handleRowDrop:(n,r)=>this._handleRowDrop(n,r),doRender:()=>this._doRender(...this._visRange()),announce:n=>this._announce(n),emit:(n,...r)=>this.emit(n,...r),visRange:()=>this._visRange(),handleCellKeyEvt:(n,r)=>this._handleCellKeyEvt(n,r)}),this._sfMgr=new is({getData:()=>this._data,getColLayout:()=>this._colLayout,getFindFilter:()=>this._findMgr.findFilter,getVs:()=>this._vs,getPagination:()=>this._pagination,getOptions:()=>this._options,renderHeader:()=>this._renderHeader(),doRender:()=>this._doRender(...this._visRange()),announce:n=>this._announce(n),emit:(n,...r)=>this.emit(n,...r)}),this._findMgr=new Je({getColLayout:()=>this._colLayout,getData:()=>this._data,getFilters:()=>this._sfMgr.filters,getVs:()=>this._vs,getPagination:()=>this._pagination,doRender:()=>this._doRender(...this._visRange())}),this._cellEvt=new os({getData:()=>this._data,getColLayout:()=>this._colLayout,getOptions:()=>this._options,getEditMgr:()=>this._editMgr,getRowMgr:()=>this._rowMgr,emit:(n,...r)=>this.emit(n,...r),writeCell:(n,r,l)=>this.writeCell(n,r,l),doRender:()=>this._doRender(...this._visRange()),getContainer:()=>this._container}),this._grpMgr=new ss({getData:()=>this._data.getData(),getDataLayer:()=>this._data,getOptions:()=>this._options,getVs:()=>this._vs,doRenderFull:n=>this._doRender(0,n-1),doRender:()=>this._doRender(...this._visRange()),getStrategy:(n,r)=>this._ovk.getStrategy(n,r)}),this._ovk=new cs(this,{strict:this._options.overrideStrict??!0}),this._data.setStrategyResolver((n,r)=>this._ovk.getStrategy(n,r)),xe((n,r,l)=>{var a;return((a=this._ovk.getStrategy("displayFormatter",null))==null?void 0:a(n,r,l))??null}),this._mount(),this._bindOptionEvents(),(i=this._options.defaultSort)!=null&&i.length&&this._sfMgr.initSort(this._options.defaultSort),this.override=Object.assign((n,r,l)=>this._ovk.override(n,r,l),{strategy:(n,r)=>this._ovk.strategy(n,r)});const o=this.destroy.bind(this);this.destroy=()=>{try{o()}finally{this._ovk.restoreAll()}};for(const[n,r]of U._defaultStrategies)this._ovk.strategy(n,r);for(const[n,r,l]of U._defaultOverrides)this._ovk.override(n,r,l);requestAnimationFrame(()=>{var n,r;this.emit("ready",this),(r=(n=this._options).onReady)==null||r.call(n,this)})}static defaultOverride(t,e,s={}){return U._defaultOverrides.push([t,e,s]),U}restore(t){return this._ovk.restore(t),this}restoreAll(){return this._ovk.restoreAll(),this}hasOverride(t){return this._ovk.hasOverride(t)}getOverrideNames(){return this._ovk.getOverrideNames()}getStrategy(t,e){return this._ovk.getStrategy(t,e)}_mount(){var s,o;this._container.classList.add("og-container");const t=this._options.height,e=this._options.width;this._container.style.height=typeof t=="number"?`${t}px`:String(t),this._container.style.width=typeof e=="number"?`${e}px`:String(e),this._container.style.display="flex",this._container.style.flexDirection="column",this._container.style.overflow="hidden",this._container.style.boxSizing="border-box",this._container.style.border="1px solid var(--og-border-color, #e0e0e0)",this._container.style.fontFamily="var(--og-font-family, -apple-system, sans-serif)",this._container.style.fontSize="var(--og-font-size, 13px)",this._container.setAttribute("data-og-theme",this._options.theme);for(const[i,n]of Object.entries(this._options.cssVars))this._container.style.setProperty(i,n);this._renderer=new Ie(this._container,this._options,{onHeaderClick:(i,n)=>this._handleSortClick(i,n),onCellClick:(i,n,r)=>this._handleCellClick(i,n,r),onCellDblClick:(i,n,r)=>this._handleCellDblClick(i,n,r),onCellMouseOver:(i,n,r)=>this._handleCellMouseOver(i,n,r),onCellMouseOut:(i,n,r)=>this._handleCellMouseOut(i,n,r),onCellMouseDown:(i,n,r)=>this._handleCellMouseDown(i,n,r),onCellMouseUp:(i,n,r)=>this._handleCellMouseUp(i,n,r),onCellMouseMove:(i,n,r)=>this._handleCellMouseMove(i,n,r),onRowCheck:(i,n)=>this._handleRowCheck(i,n),onAllCheck:i=>this._handleAllCheck(i),onColResize:(i,n)=>this._handleColResize(i,n),onFilterIconClick:(i,n)=>this._handleFilterIconClick(i,n),getDndManager:()=>this._dnd,onColDragStart:i=>{this._editMgr.dragColIdx=i},onColDrop:i=>{this._editMgr.dragColIdx!==null&&this._editMgr.dragColIdx!==i&&this._reorderColumn(this._editMgr.dragColIdx,i),this._editMgr.dragColIdx=null},getColDragIdx:()=>this._editMgr.dragColIdx,getDisplayText:(i,n)=>this.hasOverride("getDisplayValue")||this._ovk.hasStrategy("displayFormatter")?this.getDisplayValue(i,n):null}),this._filterPanel=new he(this._container,(i,n)=>this.setFilter(i,n),i=>this.resetFilter(i)),this._container.setAttribute("role","grid"),this._container.setAttribute("aria-label",this._options.ariaLabel??((s=this._options.cssVars)==null?void 0:s["aria-label"])??"OPEN_GRID 데이터 그리드"),this._container.setAttribute("aria-rowcount","0"),this._container.setAttribute("aria-colcount",String(this._options.columns.filter(i=>!i.hidden).length)),this._liveRegion=document.createElement("div"),this._liveRegion.setAttribute("aria-live","polite"),this._liveRegion.setAttribute("aria-atomic","true"),this._liveRegion.className="og-live-region",this._container.insertAdjacentElement("beforebegin",this._liveRegion),this._container.tabIndex=0,this._container.addEventListener("keydown",i=>this._handleKeyDown(i)),this._container.addEventListener("keyup",i=>this._handleCellKeyEvt("cellKeyUp",i)),this._container.addEventListener("keypress",i=>this._handleCellKeyEvt("cellKeyPress",i)),this._vs=new ce(this._renderer.bodyWrapper,{rowHeight:this._options.rowHeight,onRender:(i,n)=>this._doRender(i,n)}),ht.register(this._renderer.bodyWrapper,this),this._options.draggable&&(this._dnd=new je(this._renderer.bodyWrapper,this._options.rowHeight,(i,n)=>this._handleRowDrop(i,n),this._options.crossGrid?{resolveTarget:(i,n)=>{const r=ht.resolveAt(i,n,this);return!r||!r._options.crossGrid?null:{bodyEl:r._crossBodyEl(),rowHeight:r._options.rowHeight,totalRows:r._data.rowCount}},onCrossDrop:(i,n,r)=>this._handleCrossGridDrop(i,n,r)}:void 0,i=>this._dragRowSet(i).length)),this._options.pagination&&(this._pagination=new Ke(this._container,this._options.pageSize,i=>{this.emit("pageChange",i),this._doRender(...this._visRange())})),this._findMgr.init(this._container),this._initContextMenu(),(o=this._options.worksheets)!=null&&o.length&&this._initWorksheets(),this._ro=new ResizeObserver(()=>this._onResize()),this._ro.observe(this._container),this._onResize()}_initContextMenu(){const t=this._options.contextMenu;t!==!1&&(this._cmHandler&&this._container.removeEventListener("contextmenu",this._cmHandler),this._cmKbdHandler&&this._container.removeEventListener("keydown",this._cmKbdHandler),this._cmHandler=this._cmKbdHandler=null,this._ctxMenu=new Ge(this._container,{onSortAsc:()=>{const e=this._colLayout.visibleLeaves[0];e&&this.orderBy(e.field,"asc")},onSortDesc:()=>{const e=this._colLayout.visibleLeaves[0];e&&this.orderBy(e.field,"desc")},onFind:()=>this._findMgr.open(),onExcel:()=>this.exportExcel(),onCsv:()=>this.exportCsv(),onPrint:()=>this.print()}),this._cmHandler=e=>{var r;const s=e.target.closest(".og-cell");if(!s)return;e.preventDefault();const o=Number(s.dataset.colIndex??-1),i=this._colLayout.visibleLeaves[o];i&&this._ctxMenu&&(this._ctxMenu._actions.onSortAsc=()=>this.orderBy(i.field,"asc"),this._ctxMenu._actions.onSortDesc=()=>this.orderBy(i.field,"desc"));const n=Array.isArray(t)?t:void 0;(r=this._ctxMenu)==null||r.open(e,n)},this._container.addEventListener("contextmenu",this._cmHandler),this._cmKbdHandler=e=>{var s;if(e.shiftKey&&e.key==="F10"){e.preventDefault();const o=this._container.getBoundingClientRect(),i={clientX:o.left+80,clientY:o.top+40};(s=this._ctxMenu)==null||s.open(i)}},this._container.addEventListener("keydown",this._cmKbdHandler))}openContextMenu(t,e){var s;(s=this._ctxMenu)==null||s.open(t,e)}closeContextMenu(){var t;(t=this._ctxMenu)==null||t.close()}setFilterSelect(t){var e;(e=this._filterSelect)==null||e.destroy(),this._filterSelect=null,t&&(this._container.id||(this._container.id=`og-${Math.random().toString(36).slice(2,7)}`),this._filterSelect=new Ne(this._container,t,(s,o)=>this.setFilter(s,o),s=>this.resetFilter(s),this._container.id))}setOptions(t){var e;if(Object.assign(this._options,t),"contextMenu"in t&&((e=this._ctxMenu)==null||e.destroy(),this._ctxMenu=null,this._initContextMenu()),"groupBy"in t||"summary"in t){const s=t.groupBy??[];s.length>0?this._grpMgr.groupBy(s):this.clearGroup();return}this._renderHeader(),this._doRender(...this._visRange())}setMaskEnabled(t,e){var o;const s=this._colLayout.getColumnByField(t);s&&(e?(s._maskRevealed=!1,(o=s._maskRevealedRows)==null||o.clear()):s._maskRevealed=!0,this._doRender(...this._visRange()))}getMaskEnabled(t){const e=this._colLayout.getColumnByField(t);return e?e._maskRevealed!==!0:!1}_initWorksheets(){const t=this._options.worksheets;this._wsManager=new Ut(this._container,(e,s)=>this._loadWorksheetState(s));for(const e of t)this._wsManager.add(e.name,e.columns??this._options.columns,e.data??[])}_loadWorksheetState(t){var s,o;this._rowMgr.reset(),this._data.setData(t.data),this._colLayout=new $t(t.columns.length?t.columns:this._options.columns,this._options.frozenColumns),(s=this._vs)==null||s.setTotalRows(this._data.rowCount),(o=this._pagination)==null||o.setTotalRows(this._data.rowCount),this._container.setAttribute("aria-rowcount",String(this._data.rowCount)),this._container.setAttribute("aria-colcount",String(this._colLayout.visibleLeaves.length));const{width:e}=this._container.getBoundingClientRect();e&&this._recalcWidths(e),this._renderHeader(),this._doRender(...this._visRange())}addWorksheet(t,e,s){this._wsManager||(this._wsManager=new Ut(this._container,(o,i)=>this._loadWorksheetState(i))),this._wsManager.add(t,e??this._options.columns,s??[])}removeWorksheet(t){var e;(e=this._wsManager)==null||e.remove(t)}switchWorksheet(t){var e;(e=this._wsManager)==null||e.switch(t)}renameWorksheet(t,e){var s;(s=this._wsManager)==null||s.rename(t,e)}getWorksheet(t){var e;return(e=this._wsManager)==null?void 0:e.get(t)}getWorksheetNames(){var t;return((t=this._wsManager)==null?void 0:t.getNames())??[]}exportSheetsExcel(t){this._exportMgr.exportSheetsExcel(t)}_paginationHeight(){return this._options.pagination?38:0}_onResize(){const{width:t}=this._container.getBoundingClientRect();t&&(this._recalcWidths(t),this._renderHeader(),this._doRender(...this._visRange()))}_recalcWidths(t){this._colWidths=this._colLayout.computeWidths(t-(this._options.stateColumn?24:0)-(this._options.draggable?18:0)-(this._options.rowNumber?44:0)-(this._options.checkColumn?36:0),this._options.defaultColumnWidth),this._userWidths.size&&this._colLayout.visibleLeaves.forEach((e,s)=>{const o=this._userWidths.get(e.field);o!=null&&(this._colWidths[s]=o)})}_renderHeader(){var t;(t=this._renderer)==null||t.renderHeader(this._colLayout.buildHeaderCells(),this._colLayout.visibleLeaves,this._colWidths,this._sfMgr.sortList,{...this._options,_activeFilters:this._sfMgr.filters,_frozenCount:this._colLayout.frozenCount}),this._syncHeaderLayout()}_syncHeaderLayout(){if(!this._renderer||!this._vs)return;const{height:t}=this._container.getBoundingClientRect();if(!t)return;const e=this._renderer.getHeaderHeight(),s=e>this._options.headerHeight?e:this._options.headerHeight;this._renderer.updateSize(t-this._paginationHeight(),s),this._vs.setViewportHeight(t-s-this._paginationHeight())}_doRender(t,e){var i;if(!this._renderer||!this._vs)return;const s=this._vs.getVisibleRange(),o=this._options.autoHeight===!0;o&&([t,e]=this._visRange(),!this._autoHeightWarned&&e-t+1>2e3&&(this._autoHeightWarned=!0,console.warn(`[OpenGrid] autoHeight 는 가상 스크롤이 아니라 전 행(${e-t+1}행)을 렌더합니다. 행이 많으면 고정 rowHeight(가상 스크롤) 사용을 권장합니다.`))),this._renderer.renderBody(t,e,this._data,this._colLayout.visibleLeaves,this._colWidths,this._options,o?0:s.offsetY,o?0:this._vs.getTotalHeight(),this._rowMgr.selectedRows,this._rowMgr.checkedRows,this._grpMgr.isGroupMode?this._grpMgr.groupFlatRows:this._grpMgr.isTreeMode?this._grpMgr.treeFlatRows:null,n=>this._grpMgr.handleGroupToggle(n),this._grpMgr.isTreeMode?n=>this._grpMgr.handleTreeToggle(n):void 0,{_totalRows:this._data.rowCount,_frozenCount:this._colLayout.frozenCount,_focusCell:this._editMgr.focusCell},this._mergeEngine),(i=this._options.footer)!=null&&i.length&&this._renderFooterEl()}_handleGroupToggle(t){this._grpMgr.handleGroupToggle(t)}_visRange(){var e;if(this._options.pagination&&this._pagination){const{start:s,end:o}=this._pagination.getRange();return[s,o]}if(this._options.autoHeight)return[0,(this._grpMgr.isGroupMode?this._grpMgr.groupFlatRows.length:this._grpMgr.isTreeMode?this._grpMgr.treeFlatRows.length:this._data.rowCount)-1];const t=(e=this._vs)==null?void 0:e.getVisibleRange();return[(t==null?void 0:t.startIndex)??0,Math.min(((t==null?void 0:t.endIndex)??30)+this._visCount()+5,this._data.rowCount-1)]}_visCount(){const t=this._container.getBoundingClientRect().height;return Math.ceil((t-this._options.headerHeight-this._paginationHeight())/this._options.rowHeight)+5}_handleSortClick(t,e){this._sfMgr.handleSortClick(t,e)}_isToggleCol(t){return rt(t)}_handleCellClick(t,e,s){this._cellEvt.handleCellClick(t,e,s)}_handleCellDblClick(t,e,s){this._cellEvt.handleCellDblClick(t,e,s)}_handleCellMouseOver(t,e,s){this._cellEvt.handleCellMouseOver(t,e,s)}_handleCellMouseOut(t,e,s){this._cellEvt.handleCellMouseOut(t,e,s)}_handleCellMouseDown(t,e,s){this._cellEvt.handleCellMouseDown(t,e,s)}_handleCellMouseUp(t,e,s){this._cellEvt.handleCellMouseUp(t,e,s)}_handleCellMouseMove(t,e,s){this._cellEvt.handleCellMouseMove(t,e,s)}_handleCellKeyEvt(t,e){this._cellEvt.handleCellKeyEvt(t,e)}_handleRowCheck(t,e){this._rowMgr.check(t,e),this._doRender(...this._visRange()),this.emit("rowCheck",{rowIndex:t,checked:e,row:this._data.getRowByIndex(t)})}_handleFilterIconClick(t,e){var o,i;if((o=this._filterPanel)!=null&&o.isOpen){this._filterPanel.close();return}const s=this._sfMgr.filters[t]??[];(i=this._filterPanel)==null||i.open(t,e,s)}_handleAllCheck(t){this._rowMgr.checkAll(t,this._data.rowCount),this._doRender(...this._visRange()),this.emit("allCheck",{checked:t})}_handleRowDrop(t,e){var s,o;this._data.moveRow(t,e),this._doRender(...this._visRange()),this.emit("rowDrop",{fromIndex:t,toIndex:e}),(o=(s=this._options).onRowDrop)==null||o.call(s,{fromIndex:t,toIndex:e})}_crossBodyEl(){return this._renderer.bodyWrapper}_dragRowSet(t){const e=[...this._rowMgr.selectedRows];return e.length>1&&e.includes(t)?e.sort((s,o)=>s-o):[t]}_handleCrossGridDrop(t,e,s){const o=ht.get(e);!o||o===this||this.moveRowsTo(o,this._dragRowSet(t),s)}async moveRowsTo(t,e,s){const o=t;if(!o||o===this||!e.length)return!1;const i=[...new Set(e)].sort((c,u)=>c-u),n=s??o._data.rowCount;let r=i.map(c=>{const u={...this._data.getRowByIndex(c)};return delete u[qt],u});const l=await this._resolveCrossTransform(o);if(l===!1)return!1;l&&(r=r.map(c=>l(c)));const a={sourceGrid:this,targetGrid:o,rows:r,sourceIndexes:i,targetIndex:n};return this._fireGridDropBefore(a)===!1||a.cancel||o._fireGridDropBefore(a)===!1||a.cancel?!1:(r.forEach((c,u)=>o.insertRow(c,n+u)),[...i].sort((c,u)=>u-c).forEach(c=>this.deleteRow(c)),this._fireGridDropAfter(a),o._fireGridDropAfter(a),this._fireGridDropComplete(a),o._fireGridDropComplete(a),!0)}async moveCheckedTo(t){const e=this._rowMgr.getChecked().map(s=>s.rowIndex);return e.length?(this._rowMgr.uncheckAll(),this.moveRowsTo(t,e)):!1}async _resolveCrossTransform(t){var r,l;const e=this._options.crossGridMapping;if(typeof e=="function")return e;if(e!=="interactive")return null;const s=this._colLayout.visibleLeaves.map(a=>({field:a.field,header:a.header})),o=t._colLayout.visibleLeaves.map(a=>({field:a.field,header:a.header}));if(ls(s.map(a=>a.field),o.map(a=>a.field)))return null;const i=await as(s,o);if(!i)return!1;const n={sourceGrid:this,targetGrid:t,mapping:i.mapping,script:i.script};return this.emit("gridDropMapping",n),(l=(r=this._options).onGridDropMapping)==null||l.call(r,n),console.log(`[OpenGrid] cross-grid mapping script:
89
+ `+oe(i.mapping)),rs(i.mapping)}_fireGridDropBefore(t){var e,s;return this.emit("gridDropBefore",t),(s=(e=this._options).onGridDropBefore)==null?void 0:s.call(e,t)}_fireGridDropAfter(t){var e,s;this.emit("gridDropAfter",t),(s=(e=this._options).onGridDropAfter)==null||s.call(e,t)}_fireGridDropComplete(t){var e,s;this.emit("gridDropComplete",t),(s=(e=this._options).onGridDropComplete)==null||s.call(e,t)}reorderRow(t,e){this._data.moveRow(t,e),this._doRender(...this._visRange())}_handleColResize(t,e){this._colWidths[t]!==void 0&&(this._colWidths[t]=e);const s=this._colLayout.visibleLeaves[t];s&&this._userWidths.set(s.field,e),this._renderHeader(),this._doRender(...this._visRange())}_handleKeyDown(t){this._kbdMgr.handleKeyDown(t)}_setFocusCell(t,e){this._rowMgr.selectSingle(t),this._editMgr.setFocusCell(t,e)}_announce(t){this._liveRegion&&(this._liveRegion.textContent="",setTimeout(()=>{this._liveRegion&&(this._liveRegion.textContent=t)},50))}_bindOptionEvents(){this._options.onCellClick&&this.on("cellClick",this._options.onCellClick),this._options.onCellDblClick&&this.on("cellDblClick",this._options.onCellDblClick),this._options.onRowClick&&this.on("rowClick",this._options.onRowClick),this._options.onEditStart&&this.on("editStart",this._options.onEditStart),this._options.onEditEnd&&this.on("editEnd",this._options.onEditEnd),this._options.onSortChange&&this.on("sortChange",this._options.onSortChange),this._options.onFilterChange&&this.on("filterChange",this._options.onFilterChange),this._options.onScroll&&this.on("scroll",this._options.onScroll),this._options.onDataChange&&this.on("dataChange",this._options.onDataChange),this._options.onSelectionChange&&this.on("selectionChange",this._options.onSelectionChange),this._options.onRowDblClick&&this.on("rowDblClick",this._options.onRowDblClick),this._options.onRowMouseOver&&this.on("rowMouseOver",this._options.onRowMouseOver),this._options.onRowMouseOut&&this.on("rowMouseOut",this._options.onRowMouseOut),this._options.onRowMouseDown&&this.on("rowMouseDown",this._options.onRowMouseDown),this._options.onRowMouseUp&&this.on("rowMouseUp",this._options.onRowMouseUp),this._options.onRowMouseMove&&this.on("rowMouseMove",this._options.onRowMouseMove),this._options.onCellMouseOver&&this.on("cellMouseOver",this._options.onCellMouseOver),this._options.onCellMouseOut&&this.on("cellMouseOut",this._options.onCellMouseOut),this._options.onCellMouseDown&&this.on("cellMouseDown",this._options.onCellMouseDown),this._options.onCellMouseUp&&this.on("cellMouseUp",this._options.onCellMouseUp),this._options.onCellMouseMove&&this.on("cellMouseMove",this._options.onCellMouseMove),this._options.onCellKeyDown&&this.on("cellKeyDown",this._options.onCellKeyDown),this._options.onCellKeyUp&&this.on("cellKeyUp",this._options.onCellKeyUp),this._options.onCellKeyPress&&this.on("cellKeyPress",this._options.onCellKeyPress)}setData(t){var s;const e=this._trigMgr.mkCtx("setData",[t]);this._trigMgr.exec("before:setData",e)&&(this._rowMgr.reset(),this._data.setData(t),this._applyFilters(),this._grpMgr.isTreeMode?this._grpMgr.rebuildTree():this._grpMgr.isGroupMode?this._grpMgr.rebuildGroups():(s=this._vs)==null||s.setTotalRows(this._data.rowCount),this._container.setAttribute("aria-rowcount",String(this._data.rowCount)),this._container.setAttribute("aria-colcount",String(this._colLayout.visibleLeaves.length)),this._announce(`${this._data.rowCount}행 데이터 로드됨`),this.emit("dataChange",this._data.getData()),e.result=t.length,this._trigMgr.exec("after:setData",e))}getData(){return this._data.getData()}getSourceRows(){return this._data.getOriginalData()}pushData(t){var o,i;const e=[...this._data.getAllData(),...t];this._data.setData(e);const s=this._data.rowCount;(o=this._vs)==null||o.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s)}prefixData(t){var o,i;const e=[...t,...this._data.getAllData()];this._data.setData(e);const s=this._data.rowCount;(o=this._vs)==null||o.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s)}clearData(){var t,e;this._rowMgr.reset(),this._data.clearData(),(t=this._vs)==null||t.setTotalRows(0),(e=this._pagination)==null||e.setTotalRows(0),this._doRender(0,-1),this.emit("dataChange",[])}insertRow(t,e="last"){var n,r,l,a;const s=this._trigMgr.mkCtx("insertRow",[t,e]);if(!this._trigMgr.exec("before:insertRow",s))return;const o=e==="before"?0:e==="after"?this._data.rowCount:e;this._data.addRow(t,o);const i=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(i),(r=this._pagination)==null||r.setTotalRows(i),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(a=(l=this._options).onDataChange)==null||a.call(l,this._data.getData()),s.result={rowCount:i,item:t},this._trigMgr.exec("after:insertRow",s)}pushRow(t){var o,i,n,r;(Array.isArray(t)?t:[t]).forEach(l=>this._data.addRow(l,"last"));const s=this._data.rowCount;(o=this._vs)==null||o.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(r=(n=this._options).onDataChange)==null||r.call(n,this._data.getData())}appendRows(t){this.pushRow(t)}unshiftRow(t){var o,i,n,r;(Array.isArray(t)?t:[t]).forEach(l=>this._data.addRow(l,"first"));const s=this._data.rowCount;(o=this._vs)==null||o.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(r=(n=this._options).onDataChange)==null||r.call(n,this._data.getData())}prependRows(t){this.unshiftRow(t)}deleteRow(t){var n,r,l,a;const e=this._trigMgr.mkCtx("deleteRow",[t]),s=Array.isArray(t)?[...t]:[t];if(e.extra={rows:s.map(c=>this._data.getRowByIndex(c))},!this._trigMgr.exec("before:deleteRow",e))return;const o=s.sort((c,u)=>u-c);o.forEach(c=>this._data.removeRow(c));const i=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(i),(r=this._pagination)==null||r.setTotalRows(i),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(a=(l=this._options).onDataChange)==null||a.call(l,this._data.getData()),e.result={deleted:o.length,rowCount:i},this._trigMgr.exec("after:deleteRow",e)}deleteById(t){}readCell(t,e){return this._data.getCellValue(t,e)}getDisplayValue(t,e){const s=this.readCell(t,e);return this._ovk.getStrategy("displayFormatter",(i,n,r)=>i==null?"":String(i))(s,e,this._data.getRowByIndex(t))}writeCell(t,e,s){var c,u,h,g;const o=this.readCell(t,e),i=this._trigMgr.mkCtx("writeCell",[t,e,s]);if(i.extra={oldValue:o,rowIndex:t,field:e},!this._trigMgr.exec("before:writeCell",i))return;this._data.updateCell(t,e,s);const n=this._data.getRowByIndex(t),r=this._colLayout.getColumnByField(e),l=this._colLayout.getColumnIndex(e),a={type:"editEnd",rowIndex:t,columnIndex:l,field:e,oldValue:o,newValue:s,row:n,column:r};this.emit("editEnd",a),(u=(c=this._options).onEditEnd)==null||u.call(c,a),this.emit("dataChange",this._data.getData()),(g=(h=this._options).onDataChange)==null||g.call(h,this._data.getData()),this._doRender(...this._visRange()),i.result={rowIndex:t,field:e,oldValue:o,newValue:s},this._trigMgr.exec("after:writeCell",i)}getRowAt(t){return this._data.getRowByIndex(t)}getChanges(){return this._data.getChanges()}getEditedRows(){return this._data.getEditedRows()}getChangedRows(){return this._data.getChangedRows()}getChangedColumns(){return this._data.getChangedColumns()}getAddedRows(){return this._data.getAddedRows()}getRemovedRows(){return this._data.getRemovedRows()}getOriginalRow(t){return this._data.getOriginalRow(t)}getRowsWithState(t){return this._data.getRowsWithState(t)}undo(){}redo(){}clearHistory(){}getColumnDefs(){return this._colLayout.visibleLeaves}getAllColumnDefs(){return this._colLayout.leaves}getColumnCount(){return this._colLayout.visibleLeaves.length}applyColumns(t){const e=this._trigMgr.mkCtx("applyColumns",[t]);this._trigMgr.exec("before:applyColumns",e)&&(this._colLayout.setColumns(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange()),e.result={columnCount:t.length},this._trigMgr.exec("after:applyColumns",e))}insertColumn(t,e){this._colLayout.addColumn(t,e),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}deleteColumn(t){this._colLayout.removeColumn(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}_reorderColumn(t,e){var n,r;const s=this._colLayout.visibleLeaves.map(l=>l);if(t<0||e<0||t>=s.length||e>=s.length)return;const o=[...this._options.columns],[i]=o.splice(t,1);o.splice(e,0,i),this._options.columns=o,this.applyColumns(o),(r=(n=this._options).onColumnReorder)==null||r.call(n,{fromIndex:t,toIndex:e,field:i.field??""})}hideColumn(t){this._colLayout.hideColumn(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}showColumn(t){this._colLayout.showColumn(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}getColumnIndex(t){return this._colLayout.getColumnIndex(t)}getFieldAt(t){var e;return((e=this._colLayout.getColumnByIndex(t))==null?void 0:e.field)??""}getColValues(t,e=!1){return this._data.getData().map(s=>s[t])}getUniqueValues(t,e=!1){return[...new Set(this.getColValues(t,e))]}setColWidths(t){}calcColWidths(t=!1){return[]}getSelections(){return this._rowMgr.getSelections()}getActiveRow(){return this._rowMgr.getActiveRow()}activate(t){this._rowMgr.activate(t),this._doRender(...this._visRange())}deselect(){this._rowMgr.deselect(),this._doRender(...this._visRange())}getChecked(){return this._rowMgr.getChecked()}getAllChecked(){return this._rowMgr.getAllChecked()}checkById(t){}addCheckById(t){}checkByValue(t,e){this._rowMgr.checkByValue(t,e),this._doRender(...this._visRange())}uncheckById(t){}uncheckAll(){this._rowMgr.uncheckAll(),this._doRender(...this._visRange())}orderBy(t,e="asc"){const s=this._trigMgr.mkCtx("orderBy",[t,e]);this._trigMgr.exec("before:orderBy",s)&&(this._sfMgr.sort(t,e),s.result={sortList:this._sfMgr.sortList},this._trigMgr.exec("after:orderBy",s))}resetOrder(){this._sfMgr.resetSort()}setFilter(t,e){const s=this._trigMgr.mkCtx("setFilter",[t,e]);this._trigMgr.exec("before:setFilter",s)&&(this._sfMgr.setFilter(t,e),s.result={field:t,filteredCount:this._data.rowCount},this._trigMgr.exec("after:setFilter",s))}resetFilter(t){this._sfMgr.resetFilter(t)}getFilterState(){return this._sfMgr.getFilterState()}restoreFilter(t){this._sfMgr.restoreFilter(t)}_applyFilters(){this._sfMgr.applyFilters()}freeze(t){this._colLayout.setFrozen(t),this._renderHeader(),this._doRender(...this._visRange())}mergeCells(t){this._mergeEngine.applyMergeCells(t),this._doRender(...this._visRange())}autoMerge(t){const e=this._colLayout.visibleLeaves,s=[],o=[];for(const i of t){const n=e.findIndex(r=>r.field===i);n>=0&&(s.push(n),o.push(i))}this._mergeEngine.applyAutoMerge(this._data.getData(),s,o),this._doRender(...this._visRange())}clearMerge(){this._mergeEngine.clear(),this._doRender(...this._visRange())}freezeRows(t){}groupBy(t){const e=this._trigMgr.mkCtx("groupBy",[t]);this._trigMgr.exec("before:groupBy",e)&&(this._grpMgr.groupBy(t),e.result={fields:t},this._trigMgr.exec("after:groupBy",e))}clearGroup(){this._grpMgr.clearGroup()}expandAll(){this._grpMgr.expandAll()}collapseAll(){this._grpMgr.collapseAll()}enableTree(){this._grpMgr.enableTree()}disableTree(){this._grpMgr.disableTree()}expandNodes(t,e=!0){this._grpMgr.expandNodes(t,e)}expandAllNodes(){this._grpMgr.expandAllNodes()}collapseAllNodes(){this._grpMgr.collapseAllNodes()}addTreeRow(t,e,s){}exportExcel(t){this._exportMgr.exportExcel(t)}exportCsv(t){this._exportMgr.exportCsv(t)}exportJson(t){this._exportMgr.exportJson(t)}print(t){this._exportMgr.print(t)}toArray(t=!0){const e=this._data.getData();if(t)return e;const s=this._colLayout.visibleLeaves;return e.map(o=>s.map(i=>o[i.field]))}jumpToRow(t){var e;this._rowMgr.selectSingle(t),(e=this._vs)==null||e.scrollToRow(t),this._doRender(...this._visRange())}jumpToCol(t){}getScrollPos(){var t,e;return{x:((t=this._renderer)==null?void 0:t.bodyWrapper.scrollLeft)??0,y:((e=this._renderer)==null?void 0:e.bodyWrapper.scrollTop)??0}}setFooter(t){this._options.footer=t,this._renderFooterEl()}getFooterData(){return this._footerMgr.computeValues()}getFooterValue(t){var e;return((e=this._footerMgr.computeValues().find(s=>s._field===t))==null?void 0:e._value)??null}_renderFooterEl(){this._footerMgr.render()}resize(t,e){t&&(this._container.style.width=`${t}px`),e&&(this._container.style.height=`${e}px`),this._onResize()}setTheme(t){this._container.setAttribute("data-og-theme",t)}setThemeVar(t,e){this._container.style.setProperty(t,e)}addTrigger(t,e){return this._trigMgr.add(t,e),this}removeTrigger(t,e){return this._trigMgr.remove(t,e),this}clearTriggers(t){return this._trigMgr.clear(t),this}_mkCtx(t,e){return this._trigMgr.mkCtx(t,e)}_trig(t,e){return this._trigMgr.exec(t,e)}destroy(){var t,e,s,o,i,n,r,l;this._destroyed||(this._destroyed=!0,this._renderer&&ht.unregister(this._renderer.bodyWrapper),this._trigMgr.clear(),(t=this._ro)==null||t.disconnect(),(e=this._vs)==null||e.destroy(),(s=this._filterPanel)==null||s.destroy(),(o=this._dnd)==null||o.destroy(),this._cmHandler&&this._container.removeEventListener("contextmenu",this._cmHandler),this._cmKbdHandler&&this._container.removeEventListener("keydown",this._cmKbdHandler),this._cmHandler=this._cmKbdHandler=null,(i=this._ctxMenu)==null||i.destroy(),(n=this._wsManager)==null||n.destroy(),(r=this._renderer)==null||r.destroy(),(l=this._liveRegion)==null||l.remove(),this._liveRegion=null,this._container.innerHTML="",this._container.classList.remove("og-container"),this.removeAllListeners())}};U._defaultOverrides=[],U._defaultStrategies=[],U.defaults={strategy(t,e){return U._defaultStrategies.push([t,e]),U}};let Lt=U;exports.OpenGrid=Lt;exports.buildTree=Et;
90
+ //# sourceMappingURL=OpenGrid-CZRcxruq.cjs.map