open-grid 0.2.0 → 0.3.1

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.
@@ -1,90 +0,0 @@
1
- "use strict";class qe{constructor(){this.listeners=new Map}on(e,t){const s=this.listeners.get(e)??[];return s.push({handler:t,once:!1}),this.listeners.set(e,s),this}once(e,t){const s=this.listeners.get(e)??[];return s.push({handler:t,once:!0}),this.listeners.set(e,s),this}off(e,t){if(!t)return this.listeners.delete(e),this;const s=this.listeners.get(e);if(s){const n=s.filter(i=>i.handler!==t);n.length===0?this.listeners.delete(e):this.listeners.set(e,n)}return this}emit(e,...t){const s=this.listeners.get(e);if(!s||s.length===0)return!1;const n=[];for(const i of s)i.handler(...t),i.once||n.push(i);return n.length!==s.length&&(n.length===0?this.listeners.delete(e):this.listeners.set(e,n)),!0}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}listenerCount(e){var t;return((t=this.listeners.get(e))==null?void 0:t.length)??0}}let Ye=0;function Re(){return`og-r-${++Ye}`}class Xe{constructor(e="_ogRowId"){this._data=[],this._original=[],this._meta=new Map,this._displayIndexes=[],this._idMap=new Map,this._findQuery="",this._findFields=[],this._idField=e}setData(e){this._data=e.map(t=>{const s=Re(),n={...t,[this._idField]:s};return this._meta.set(s,{state:"none",rowId:s}),n}),this._original=this._data.map(t=>({...t})),this._rebuildIdMap(),this._displayIndexes=this._data.map((t,s)=>s)}getData(){return this._displayIndexes.map(e=>this._data[e])}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(e,t="last"){const s=Re(),n={...e,[this._idField]:s};if(this._meta.set(s,{state:"added",rowId:s}),t==="last"){const i=this._data.push(n)-1;this._idMap.set(s,i),this._displayIndexes.push(i)}else if(t==="first")this._data.unshift(n),this._rebuildIdMap(),this._displayIndexes.unshift(0);else{const i=Math.min(t,this._displayIndexes.length),o=i<this._displayIndexes.length?this._displayIndexes[i]:this._data.length;this._data.splice(o,0,n),this._rebuildIdMap(),this._displayIndexes=this._data.map((l,r)=>r)}}removeRow(e){const t=this._displayIndexes[e];if(t===void 0)return;const s=this._data[t],n=s[this._idField],i=this._meta.get(n);return(i==null?void 0:i.state)==="added"?(this._data.splice(t,1),this._meta.delete(n)):this._meta.set(n,{...i,state:"removed"}),this._rebuildIdMap(),this._displayIndexes=this._data.map((o,l)=>({r:o,i:l})).filter(({r:o})=>{var l;return((l=this._meta.get(o[this._idField]))==null?void 0:l.state)!=="removed"}).map(({i:o})=>o),s}moveRow(e,t){const s=this._displayIndexes[e],n=this._displayIndexes[t];if(s===void 0||n===void 0)return;const[i]=this._data.splice(s,1),o=s<n?n-1:n;this._data.splice(o,0,i),this._rebuildIdMap(),this._displayIndexes=this._data.map((l,r)=>({r:l,i:r})).filter(({r:l})=>{var r;return((r=this._meta.get(l[this._idField]))==null?void 0:r.state)!=="removed"}).map(({i:l})=>l)}updateCell(e,t,s){const n=this._displayIndexes[e];if(n===void 0)return!1;const o=this._data[n][this._idField],l=this._meta.get(o);return(l==null?void 0:l.state)==="none"&&this._meta.set(o,{...l,state:"edited",original:{...this._original[n]}}),this._data[n][t]=s,!0}getRowByIndex(e){const t=this._displayIndexes[e];return t!==void 0?this._data[t]:void 0}getCellValue(e,t){var s;return(s=this.getRowByIndex(e))==null?void 0:s[t]}getEditedRows(){return this._data.filter(e=>{var t;return((t=this._meta.get(e[this._idField]))==null?void 0:t.state)==="edited"})}getChangedRows(){return this.getEditedRows()}getAddedRows(){return this._data.filter(e=>{var t;return((t=this._meta.get(e[this._idField]))==null?void 0:t.state)==="added"})}getRemovedRows(){return this._data.filter(e=>{var t;return((t=this._meta.get(e[this._idField]))==null?void 0:t.state)==="removed"})}getChanges(){const e=[],t=[],s=[];for(const n of this._data){const i=n[this._idField],o=this._meta.get(i),l=(o==null?void 0:o.state)??"none";if(l==="added")e.push({...n});else if(l==="removed")s.push({...n});else if(l==="edited"){const r=o.original??{},a=Object.keys(n).filter(c=>c!==this._idField&&n[c]!==r[c]);t.push({...n,_changedFields:a})}}return{added:e,edited:t,removed:s}}getChangedColumns(){return this._data.filter(e=>{var t;return((t=this._meta.get(e[this._idField]))==null?void 0:t.state)==="edited"}).map(e=>{var n;const t=((n=this._meta.get(e[this._idField]))==null?void 0:n.original)??{},s=[];for(const i of Object.keys(e))i!==this._idField&&e[i]!==t[i]&&s.push({field:i,oldValue:t[i],newValue:e[i]});return{row:{...e},fields:s.map(i=>i.field),diff:s}})}getOriginalRow(e){const t=this._displayIndexes[e];if(t===void 0)return;const s=this._data[t],n=this._meta.get(s[this._idField]);if(!(!n||n.state==="added"))return n.state==="edited"&&n.original?{...n.original}:{...this._original[t]}}getRowsWithState(e){return this._data.map(t=>{var n;const s=((n=this._meta.get(t[this._idField]))==null?void 0:n.state)??"none";return{...t,[e]:s}})}getRowState(e){var s;const t=this.getRowByIndex(e);return t?((s=this._meta.get(t[this._idField]))==null?void 0:s.state)??"none":"none"}applySort(e){const t=n=>{var i,o;return((o=this._meta.get((i=this._data[n])==null?void 0:i[this._idField]))==null?void 0:o.state)!=="removed"};if(e.length===0){this._displayIndexes=this._data.map((n,i)=>i).filter(t);return}const s=this._displayIndexes.filter(t).map(n=>{const i=this._data[n];return{idx:n,keys:e.map(o=>i[o.field])}});s.sort((n,i)=>{for(let o=0;o<e.length;o++){const l=e[o].dir,r=n.keys[o],a=i.keys[o];let c=0;if(r==null&&a==null)c=0;else if(r==null)c=-1;else if(a==null)c=1;else if(typeof r=="number"&&typeof a=="number")c=r-a;else{const h=String(r),u=String(a);c=h<u?-1:h>u?1:0}if(c!==0)return l==="asc"?c:-c}return 0}),this._displayIndexes=s.map(n=>n.idx)}applyFilter(e){const t=Object.keys(e);this._displayIndexes=this._data.map((s,n)=>({r:s,i:n})).filter(({r:s})=>{var n;if(((n=this._meta.get(s[this._idField]))==null?void 0:n.state)==="removed"||t.length>0&&!t.every(i=>{const o=s[i];return e[i].every(l=>Ge(o,l))}))return!1;if(this._findQuery&&this._findFields.length>0){const i=this._findQuery;if(!this._findFields.some(l=>{const r=s[l];return r!=null&&String(r).toLowerCase().includes(i)}))return!1}return!0}).map(({i:s})=>s)}setFindFilter(e,t){this._findQuery=e.toLowerCase(),this._findFields=t}_rebuildIdMap(){this._idMap.clear(),this._data.forEach((e,t)=>{this._idMap.set(e[this._idField],t)})}}function Ge(d,e){const t=d,s=e.value;switch(e.operator){case"=":return t==s;case"!=":return t!=s;case">":return t>s;case">=":return t>=s;case"<":return t<s;case"<=":return t<=s;case"contains":return String(t).includes(String(s));case"startsWith":return String(t).startsWith(String(s));case"endsWith":return String(t).endsWith(String(s));default:return!0}}class Qe{constructor(e,t){this._totalRows=0,this._scrollTop=0,this._viewportHeight=0,this._rafId=null,this._onScroll=()=>{this._scrollTop=this.container.scrollTop,this._scheduleRender()},this.container=e,this.rowHeight=t.rowHeight,this.overscan=t.overscan??5,this.onRender=t.onRender,this.container.addEventListener("scroll",this._onScroll,{passive:!0})}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null;const e=this.getVisibleRange();this.onRender(e.startIndex,e.endIndex)}))}getVisibleRange(){const e=Math.ceil(this._viewportHeight/this.rowHeight),t=Math.max(0,Math.floor(this._scrollTop/this.rowHeight)-this.overscan),s=Math.min(this._totalRows-1,t+e+this.overscan*2),n=t*this.rowHeight;return{startIndex:t,endIndex:s,offsetY:n}}setTotalRows(e){this._totalRows=e,this._updateSpacerHeight(),this._scheduleRender()}setViewportHeight(e){this._viewportHeight=e,this._scheduleRender()}setRowHeight(e){this.rowHeight=e,this._updateSpacerHeight(),this._scheduleRender()}scrollToRow(e){const t=e*this.rowHeight,s=t+this.rowHeight,n=this._scrollTop+this._viewportHeight;if(t<this._scrollTop)this._scrollTop=t,this.container.scrollTop=t;else if(s>n){const i=s-this._viewportHeight;this._scrollTop=i,this.container.scrollTop=i}}getTotalHeight(){return this._totalRows*this.rowHeight}_updateSpacerHeight(){const e=this.container.querySelector(".og-spacer");e&&(e.style.height=`${this.getTotalHeight()}px`)}destroy(){this.container.removeEventListener("scroll",this._onScroll),this._rafId!==null&&cancelAnimationFrame(this._rafId)}}class re{constructor(e,t=0){this._flatLeaves=[],this._maxDepth=1,this._frozenCount=0,this._columns=e,this._frozenCount=t,this._process()}_process(){const e=[];let t=0;const s=(n,i)=>{for(const o of n)o.children&&o.children.length>0?(s(o.children,i+1),this._maxDepth=Math.max(this._maxDepth,i+1)):e.push({...o,_colIndex:t++,_depth:i,_leaf:!0})};this._maxDepth=1,s(this._columns,1),this._flatLeaves=e}get leaves(){return this._flatLeaves}get visibleLeaves(){return this._flatLeaves.filter(e=>!e.hidden)}get headerDepth(){return this._maxDepth}get frozenCount(){return this._frozenCount}setFrozen(e){this._frozenCount=e}setColumns(e){this._columns=e,this._process()}hideColumn(e){const t=Array.isArray(e)?e:[e];this._flatLeaves.forEach(s=>{t.includes(s.field)&&(s.hidden=!0)})}showColumn(e){const t=Array.isArray(e)?e:[e];this._flatLeaves.forEach(s=>{t.includes(s.field)&&(s.hidden=!1)})}addColumn(e,t="last"){t==="last"?this._columns.push(e):t==="first"?this._columns.unshift(e):this._columns.splice(t,0,e),this._process()}removeColumn(e){const t=s=>s.filter(n=>n.field===e?!1:(n.children&&(n.children=t(n.children)),!0));this._columns=t(this._columns),this._process()}getColumnByField(e){return this._flatLeaves.find(t=>t.field===e)}getColumnByIndex(e){return this._flatLeaves[e]}getColumnIndex(e){return this._flatLeaves.findIndex(t=>t.field===e)}buildHeaderCells(){const e=Array.from({length:this._maxDepth},()=>[]);let t=0;const s=(n,i)=>{let o=0;for(const l of n)if(!l.hidden)if(l.children&&l.children.length>0){const r=s(l.children,i+1);r>0&&(e[i-1].push({column:l,colIndex:t,depth:i,colSpan:r,rowSpan:1}),o+=r)}else e[i-1].push({column:l,colIndex:t++,depth:i,colSpan:1,rowSpan:this._maxDepth-i+1}),o++;return o};return s(this._columns,1),e}computeWidths(e,t=100){const s=this.visibleLeaves,n=s.filter(r=>r.flex),i=s.filter(r=>!r.flex&&r.width).reduce((r,a)=>r+a.width,0),o=n.reduce((r,a)=>r+(a.flex??1),0),l=Math.max(0,e-i);return s.map(r=>r.flex?Math.round(r.flex/o*l):r.width??t)}}class Je{constructor(e,t,s){this._field="",this._outsideHandler=null,this._onApply=t,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
- `,e.appendChild(this._el)}open(e,t,s){var E;this._field=e,this._el.innerHTML="";const n=document.createElement("div");n.textContent="필터",n.style.cssText="font-weight:600;margin-bottom:8px;color:var(--og-text-color,#333);",this._el.appendChild(n);const i=document.createElement("div");i.style.cssText="display:flex;gap:4px;margin-bottom:6px;";const o=document.createElement("select");o.style.cssText="flex:1;padding:3px 4px;border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;font-size:12px;";const l=[{label:"포함",value:"contains"},{label:"같음",value:"="},{label:"같지 않음",value:"!="},{label:"시작",value:"startsWith"},{label:"끝남",value:"endsWith"},{label:"보다 큼",value:">"},{label:"보다 작음",value:"<"},{label:"이상",value:">="},{label:"이하",value:"<="}];for(const w of l){const C=document.createElement("option");C.value=w.value,C.textContent=w.label,o.appendChild(C)}s[0]&&(o.value=s[0].operator),i.appendChild(o),this._el.appendChild(i);const r=document.createElement("input");r.type="text",r.placeholder="필터 값 입력...",r.value=((E=s[0])==null?void 0:E.value)??"",r.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
- `,r.addEventListener("keydown",w=>{w.key==="Enter"?h.click():w.key==="Escape"&&this.close()}),this._el.appendChild(r);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 h=document.createElement("button");h.textContent="적용",h.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
- `,h.addEventListener("click",()=>{const w=r.value.trim();w?this._onApply(this._field,[{operator:o.value,value:w}]):this._onClear(this._field),this.close()}),a.appendChild(c),a.appendChild(h),this._el.appendChild(a);const u=t.getBoundingClientRect(),g=this._el.parentElement.getBoundingClientRect();this._el.style.top=`${u.bottom-g.top+2}px`,this._el.style.left=`${Math.min(u.left-g.left,g.width-220)}px`,this._el.style.display="block",requestAnimationFrame(()=>r.focus()),this._outsideHandler&&document.removeEventListener("mousedown",this._outsideHandler),this._outsideHandler=w=>{!this._el.contains(w.target)&&w.target!==t&&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 Ze=10;function et(d,e=Ze){const t=Math.pow(10,e);return Math.round(d*t)/t}class x{constructor(e,t){this._c=e,this._s=t<0?0:t}static from(e){if(e instanceof x)return e;if(typeof e=="bigint")return new x(e,0);const t=String(e).trim();if(!t||t==="null"||t==="undefined"||t==="NaN")return new x(0n,0);const s=t.startsWith("-"),n=s?t.slice(1):t,i=n.indexOf(".");let o,l;if(i===-1)o=BigInt(n),l=0;else{const r=n.slice(i+1);o=BigInt(n.slice(0,i)+r),l=r.length}return new x(s?-o:o,l)}static zero(){return new x(0n,0)}static one(){return new x(1n,0)}static _align(e,t){return e._s===t._s?[e._c,t._c,e._s]:e._s>t._s?[e._c,t._c*10n**BigInt(e._s-t._s),e._s]:[e._c*10n**BigInt(t._s-e._s),t._c,t._s]}add(e){const[t,s,n]=x._align(this,x.from(e));return new x(t+s,n)}sub(e){const[t,s,n]=x._align(this,x.from(e));return new x(t-s,n)}mul(e){const t=x.from(e);return new x(this._c*t._c,this._s+t._s)}div(e,t=20){const s=x.from(e);if(s._c===0n)throw new Error("OGDecimal: division by zero");const i=this._c*10n**BigInt(t+s._s)/s._c;return new x(i,t+this._s)}mod(e){const t=x.from(e),[s,n,i]=x._align(this,t);return new x(s%n,i)}neg(){return new x(-this._c,this._s)}abs(){return new x(this._c<0n?-this._c:this._c,this._s)}eq(e){const[t,s]=x._align(this,x.from(e));return t===s}gt(e){const[t,s]=x._align(this,x.from(e));return t>s}lt(e){const[t,s]=x._align(this,x.from(e));return t<s}gte(e){return!this.lt(e)}lte(e){return!this.gt(e)}isZero(){return this._c===0n}isNeg(){return this._c<0n}isPos(){return this._c>0n}toFixed(e){let t=this._c,s=this._s;if(s<e)t=t*10n**BigInt(e-s);else if(s>e){const c=10n**BigInt(s-e),h=c/2n,u=t<0n,g=u?-t:t,E=g%c;let w=g/c;E>=h&&(w+=1n),t=u?-w:w}s=e;const n=t<0n,o=(n?-t:t).toString().padStart(e+1,"0"),l=o.slice(0,o.length-e)||"0",r=e>0?"."+o.slice(o.length-e):"";return(n?"-":"")+l+r}toString(){if(this._s===0)return this._c.toString();let e=this._c,t=this._s;for(;t>0&&e!==0n&&e%10n===0n;)e/=10n,t--;return new x(e,t).toFixed(t)}toNumber(){return parseFloat(this.toFixed(20))}static sum(e){return e.reduce((t,s)=>t.add(s),x.zero())}static avg(e,t=20){return e.length?x.sum(e).div(e.length,t):x.zero()}static min(e){if(!e.length)throw new Error("OGDecimal.min: empty array");return e.map(x.from).reduce((t,s)=>t.lt(s)?t:s)}static max(e){if(!e.length)throw new Error("OGDecimal.max: empty array");return e.map(x.from).reduce((t,s)=>t.gt(s)?t:s)}}function tt(d,e,t=30){return new st(d,e,t).parse()}class st{constructor(e,t,s){this._ctx=t,this._prec=s,this._pos=0,this._src=e.trim()}parse(){const e=this._additive();if(this._skip(),this._pos<this._src.length)throw new SyntaxError(`FormulaEngine: 예상치 못한 토큰 '${this._src[this._pos]}' (위치 ${this._pos})`);return e}_additive(){let e=this._multiplicative();for(this._skip();this._pos<this._src.length;){const t=this._src[this._pos];if(t!=="+"&&t!=="-")break;this._pos++,this._skip();const s=this._multiplicative();e=t==="+"?e.add(s):e.sub(s),this._skip()}return e}_multiplicative(){let e=this._unary();for(this._skip();this._pos<this._src.length;){const t=this._src[this._pos];if(t!=="*"&&t!=="/"&&t!=="%")break;this._pos++,this._skip();const s=this._unary();t==="*"?e=e.mul(s):t==="/"?e=e.div(s,this._prec):e=e.mod(s),this._skip()}return e}_unary(){return this._skip(),this._src[this._pos]==="-"?(this._pos++,this._unary().neg()):this._primary()}_primary(){this._skip();const e=this._src[this._pos];if(e==="("){this._pos++;const t=this._additive();if(this._skip(),this._src[this._pos]!==")")throw new SyntaxError("FormulaEngine: 닫는 괄호 ) 누락");return this._pos++,t}return e==="["?this._fieldRef():this._literal()}_fieldRef(){this._pos++;const e=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 t=this._src.slice(e,this._pos);this._pos++;const s=this._ctx[t];if(s==null)throw new ReferenceError(`FormulaEngine: 필드 '[${t}]'가 행 데이터에 없습니다`);return x.from(s)}_literal(){const e=this._pos;for(;this._pos<this._src.length&&/[0-9.]/.test(this._src[this._pos]);)this._pos++;const t=this._src.slice(e,this._pos);if(!t)throw new SyntaxError(`FormulaEngine: 숫자 또는 [필드]를 기대했지만 '${this._src[this._pos]??"EOF"}' 발견 (위치 ${e})`);return x.from(t)}_skip(){for(;this._pos<this._src.length&&/\s/.test(this._src[this._pos]);)this._pos++}}function be(d,e){if(d==null||d==="")return d??"";const t=typeof e=="string"?{type:e}:e,s=t.char??"*";switch(t.type){case"ssn":return it(d,s);case"phone":case"mobile":return nt(d,s);case"email":return ot(d,s);case"credit":return rt(d,s);case"account":return lt(d,s,t.visiblePrefix??3,t.visibleSuffix??4);case"password":return s.repeat(Math.max(d.length,6));case"name":return at(d,s);case"ip":return dt(d,s);case"partial":return ee(d,s,t.visiblePrefix??0,t.visibleSuffix??4);default:return d}}function it(d,e){const t=d.replace(/[^0-9]/g,"");if(t.length<7){const o=d.includes("-")?"-":"",l=d.indexOf("-")>=0?d.indexOf("-"):6;return d.slice(0,l)+o+e.repeat(Math.max(1,d.length-l-o.length))}const s=t.slice(0,6),n=t[6],i=t.length-7;return`${s}-${n}${e.repeat(i)}`}function nt(d,e){const t=d.replace(/[^0-9]/g,"");return t.length===11?`${t.slice(0,3)}-${e.repeat(4)}-${t.slice(7)}`:t.length===10?t.startsWith("02")?`${t.slice(0,2)}-${e.repeat(4)}-${t.slice(6)}`:`${t.slice(0,3)}-${e.repeat(3)}-${t.slice(6)}`:t.length===9?`${t.slice(0,2)}-${e.repeat(3)}-${t.slice(5)}`:ee(d,e,3,4)}function ot(d,e){const t=d.indexOf("@");if(t<0)return ee(d,e,2,0);const s=d.slice(0,t),n=d.slice(t),i=Math.min(2,s.length),o=s.slice(0,i),l=Math.max(s.length-i,3);return`${o}${e.repeat(l)}${n}`}function rt(d,e){const t=d.replace(/[^0-9]/g,"");if(t.length<8)return d;const s=t.slice(0,4),n=t.slice(-4),i=t.length-8,o=e.repeat(Math.max(i,8)),l=[s];for(let r=0;r<o.length;r+=4){const a=o.slice(r,r+4);a&&l.push(a)}return l.push(n),l.join("-")}function lt(d,e,t,s){const n=d.replace(/[^0-9]/g,"");if(n.length<=t+s)return ee(n,e,t,s);const i=n.slice(0,t),o=n.slice(-s),l=n.length-t-s;return`${i}-${e.repeat(l)}-${o}`}function at(d,e){const t=d.trim();return t.length===0?d:t.length===1?e:t.length===2?`${t[0]}${e}`:`${t[0]}${e.repeat(t.length-2)}${t[t.length-1]}`}function dt(d,e){const t=d.split(".");if(t.length!==4)return ee(d,e,3,0);const s=n=>e.repeat(Math.max(n.length,3));return`${t[0]}.${t[1]}.${s(t[2])}.${s(t[3])}`}function ee(d,e,t,s){if(d.length<=t+s)return d;const n=d.slice(0,t),i=s>0?d.slice(-s):"",o=d.length-t-s;return`${n}${e.repeat(o)}${i}`}function Be(d){const e=d.column;if(!e.formula)return null;const t=e.formulaPrecision??30;try{let s;return typeof e.formula=="function"?s=e.formula(d.row,x):s=tt(e.formula,d.row,t),s instanceof x?e.precision!=null?s.toFixed(e.precision):s.toString():typeof s=="string"?s:e.precision!=null?x.from(s).toFixed(e.precision):String(s)}catch(s){return console.warn("[OpenGrid] Formula error:",s),"#ERR"}}function ct(d,e,t){if(d==null||d==="")return"";let s=Number(d);if(isNaN(s))return String(d);if(t!=null&&(s=et(s,t)),!e)return t!=null?s.toFixed(t):String(s);if(e.includes(",")){const n=e.includes(".")?e.split(".")[1].length:t??0;return s.toLocaleString("ko-KR",{minimumFractionDigits:n,maximumFractionDigits:n})}return String(s)}function We(d,e="yyyy-MM-dd"){if(!d)return"";const t=d instanceof Date?d:new Date(d);if(isNaN(t.getTime()))return String(d);const s=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return e.replace("yyyy",String(s)).replace("MM",n).replace("dd",i)}function ht(d,e,t){const s=be(d,e.mask),n=document.createElement("span");n.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 o=document.createElement("button");return o.title="클릭하면 원문 표시",o.setAttribute("aria-label","마스킹 해제"),o.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>',o.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;",o.addEventListener("mouseover",()=>{o.style.color="var(--og-primary,#1976d2)",o.style.background="rgba(25,118,210,0.08)"}),o.addEventListener("mouseout",()=>{o.style.color="#c0c0c0",o.style.background="none"}),o.addEventListener("click",l=>{l.stopPropagation(),i.textContent=d,i.style.fontFamily="",i.style.letterSpacing="",i.style.color="",o.remove(),(e._maskRevealedRows??(e._maskRevealedRows=new Set)).add(t)}),n.appendChild(i),n.appendChild(o),n}class le{render(e){var r;const t=document.createElement("span");t.className="og-cell-text";const s=Be(e);if(s!==null)return t.textContent=s,t.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",t;const{value:n,column:i,rowIndex:o}=e;let l;if(i.valueMap&&n!=null&&i.valueMap[n]?l=i.valueMap[n]:l=n==null?"":String(n),i.mask){const a=i._maskRevealed===!0,c=((r=i._maskRevealedRows)==null?void 0:r.has(o))===!0;if(!a&&!c)return ht(l,i,o)}return t.textContent=l,t.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",t}}class ut{constructor(e=[],t){this._opts=e.map(s=>typeof s=="string"?{label:s,value:s}:{label:s.label??s.text??String(s.value??""),value:s.value}),this._fn=t??null}render(e){const t=document.createElement("span");t.className="og-cell-text",t.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;";const s=e.value;if(s==null||s==="")return t;const n=String(s),o=(this._fn?this._fn(e.row,e.rowIndex).map(l=>typeof l=="string"?{label:l,value:l}:{label:l.label??l.text??String(l.value??""),value:l.value}):this._opts).find(l=>String(l.value)===n);return t.textContent=o?o.label:n,t}}class ae{render(e){const t=document.createElement("span");t.className="og-cell-number";const s=Be(e);return s!==null?(t.textContent=s,t.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;",t):(t.textContent=ct(e.value,e.column.format??"#,##0",e.column.precision),t.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;",t)}}class de{render(e){const t=document.createElement("span");return t.className="og-cell-date",t.textContent=We(e.value,e.column.format),t.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",t}}class ce{render(e){const t=document.createElement("span");t.className="og-cell-checkbox",t.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("input");return s.type="checkbox",s.checked=!!e.value,s.disabled=!0,s.style.cssText+="cursor:pointer;pointer-events:none;",t.appendChild(s),t}}class ke{constructor(e){this.def=e}render(e){var i,o,l;const t=document.createElement("span");t.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 n=(o=this.def)==null?void 0:o.label;return typeof n=="function"?s.textContent=n(e.value,e.row):s.textContent=n??String(e.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
- ${((l=this.def)==null?void 0:l.style)??""}
22
- `,s.addEventListener("mouseover",()=>s.style.background="var(--og-primary-light,#e3f2fd)"),s.addEventListener("mouseout",()=>s.style.background="var(--og-row-bg,#fff)"),t.appendChild(s),t}}class Ee{constructor(e,t){this.colorMap=e,this.labelMap=t}render(e){var l,r,a;const t=document.createElement("span");t.style.cssText="display:flex;align-items:center;height:100%;";const s=document.createElement("span"),n=e.value==null?"":String(e.value),i=((l=this.labelMap)==null?void 0:l[n])??((r=e.column.valueMap)==null?void 0:r[n])??n;s.textContent=i;const o=((a=this.colorMap)==null?void 0:a[n])??"#666";return s.style.cssText=`
23
- display:inline-block;padding:2px 8px;border-radius:12px;font-size:11px;
24
- background:${o}22;color:${o};border:1px solid ${o}66;
25
- white-space:nowrap;
26
- `,t.appendChild(s),t}}class Se{constructor(e,t){this.hrefFn=e,this.target=t}render(e){const t=document.createElement("a");return t.className="og-cell-link",t.textContent=e.value==null?"":String(e.value),t.href=this.hrefFn?this.hrefFn(e.value,e.row):"#",this.target&&(t.target=this.target),t.style.cssText="color:var(--og-primary,#1976d2);text-decoration:underline;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",this.hrefFn||t.addEventListener("click",s=>s.preventDefault()),t}}class gt{constructor(e){this.templateFn=e}render(e){const t=document.createElement("div");return t.className="og-cell-template",t.style.cssText="display:flex;align-items:center;height:100%;overflow:hidden;",t.innerHTML=this.templateFn(e.value,e.row,e.rowIndex),t}}class _t{constructor(e){this.def=e}render(e){var a,c,h,u,g;const t=document.createElement("span");t.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("img"),n=(a=this.def)!=null&&a.srcFn?this.def.srcFn(e.value,e.row):String(e.value??"");s.src=n;const i=((c=this.def)==null?void 0:c.width)??28,o=((h=this.def)==null?void 0:h.height)??28,l=((u=this.def)==null?void 0:u.radius)??4;s.style.cssText=`width:${i}px;height:${o}px;object-fit:cover;border-radius:${l}px;display:block;`;const r=(g=this.def)==null?void 0:g.alt;return s.alt=typeof r=="function"?r(e.value,e.row):r??"",s.onerror=()=>{s.style.display="none"},t.appendChild(s),t}}class pt{constructor(e){this.def=e}render(e){var a,c,h,u;const t=document.createElement("span");t.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,n=Number(e.value)||0,i=Math.min(100,Math.max(0,n/s*100)),o=(c=this.def)!=null&&c.colorFn?this.def.colorFn(n):((h=this.def)==null?void 0:h.color)??"var(--og-primary,#1976d2)",l=document.createElement("div");l.className="og-progress-track",l.style.cssText="flex:1;height:10px;background:#e0e0e0;border-radius:5px;overflow:hidden;";const r=document.createElement("div");if(r.className="og-progress-fill",r.style.cssText=`width:${i}%;height:100%;background:${o};border-radius:5px;`,l.appendChild(r),t.appendChild(l),((u=this.def)==null?void 0:u.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)}%`,t.appendChild(g)}return t}}class ft{constructor(e){this.def=e}render(e){var c,h,u,g;const t=document.createElement("span");t.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=Array.isArray(e.value)?e.value.map(Number):[];if(!s.length)return t.textContent="-",t;const n=((c=this.def)==null?void 0:c.width)??80,i=((h=this.def)==null?void 0:h.height)??22,o=((u=this.def)==null?void 0:u.color)??"#1976d2",l=((g=this.def)==null?void 0:g.chartType)??"bar",r=document.createElement("canvas");r.width=n,r.height=i,r.style.cssText="display:block;";const a=r.getContext("2d");if(a){const E=Math.max(...s,1),w=Math.min(...s,0),C=E-w||1,M=s.length;if(l==="bar"){const p=n/M;s.forEach((v,_)=>{const F=(v-w)/C*(i-2);a.fillStyle=o,a.fillRect(_*p+1,i-F-1,p-2,F)})}else{const p=s.map((v,_)=>({x:_/(M-1||1)*n,y:i-(v-w)/C*(i-4)-2}));l==="area"&&(a.fillStyle=o+"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=o,a.lineWidth=1.5,a.beginPath(),p.forEach((v,_)=>_===0?a.moveTo(v.x,v.y):a.lineTo(v.x,v.y)),a.stroke()}}return t.appendChild(r),t}}class Le{render(e){const t=document.createElement("span");t.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=!!e.value,n=document.createElement("span");n.className="og-switch"+(s?" og-switch--on":""),n.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);`,n.appendChild(i),t.appendChild(n),t}}class mt{constructor(e){this.def=e}render(e){var o,l;const t=document.createElement("span");t.style.cssText="display:flex;align-items:center;gap:1px;height:100%;";const s=((o=this.def)==null?void 0:o.max)??5,n=Math.round(Number(e.value)||0),i=((l=this.def)==null?void 0:l.color)??"#ffa000";for(let r=1;r<=s;r++){const a=document.createElement("span");a.textContent="★",a.style.cssText=`font-size:14px;color:${r<=n?i:"#e0e0e0"};line-height:1;`,t.appendChild(a)}return t}}class he{render(e){const t=document.createElement("span");t.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=!!e.value,s.setAttribute("aria-checked",e.value?"true":"false"),s.setAttribute("aria-label",e.column.header??"선택"),e.column.group&&(s.name=`og-radio-${e.rowIndex}-${e.column.group}`),s.style.cssText="width:14px;height:14px;cursor:pointer;accent-color:var(--og-primary,#1976d2);",t.appendChild(s),t}}class ue{render(e){const t=document.createElement("span");if(t.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;overflow:hidden;",!e.value)return t;const s=document.createElement("img");return s.src=String(e.value),s.alt=e.column.alt??e.column.field,s.style.cssText="max-width:100%;max-height:100%;object-fit:contain;display:block;",s.setAttribute("role","img"),t.appendChild(s),t}}function wt(d){const e=document.createElement("div");return e.innerHTML=d,e.querySelectorAll("script,iframe,object,embed").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const s of[...t.attributes])s.name.startsWith("on")&&t.removeAttribute(s.name);if(t.tagName==="A"){const s=t.getAttribute("href")??"";/^javascript:/i.test(s)&&t.removeAttribute("href")}}),e.innerHTML}class ge{render(e){const t=document.createElement("span");t.style.cssText="display:block;overflow:hidden;width:100%;";const s=e.column.sanitize!==!1,n=String(e.value??"");return t.innerHTML=s?wt(n):n,t}}const yt=["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"],bt="2331112";function Fe(d){let e="",t=!0;for(const s of d)e+=(t?"1":"0").repeat(+s),t=!t;return e}function vt(d){const e=[104];for(const s of d){const n=s.charCodeAt(0)-32;n>=0&&n<=94&&e.push(n)}let t=104;for(let s=1;s<e.length;s++)t+=e[s]*s;return e.push(t%103),e.map(s=>Fe(yt[s])).join("")+Fe(bt)+"11"}class _e{render(e){const t=String(e.value??""),s=e.column.barcodeHeight??28,n=document.createElement("div");n.style.cssText="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;overflow:hidden;gap:1px;",n.setAttribute("role","img"),n.setAttribute("aria-label",`바코드: ${t}`),n.innerHTML=xt(t,s);const i=document.createElement("span");return i.textContent=t,i.style.cssText="font-size:9px;font-family:monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;",n.appendChild(i),n}}function xt(d,e){if(!d)return"";const t=vt(d),s=1.4,n=6,i=t.length*s+n*2,o=[];let l=0,r=n;for(;l<t.length;)if(t[l]==="1"){let a=0;for(;l+a<t.length&&t[l+a]==="1";)a++;o.push(`<rect x="${r.toFixed(2)}" y="0" width="${(a*s).toFixed(2)}" height="${e}"/>`),r+=a*s,l+=a}else r+=s,l++;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${i.toFixed(2)} ${e}" width="${i.toFixed(2)}" height="${e}" style="display:block" aria-hidden="true"><g fill="currentColor">${o.join("")}</g></svg>`}function Ct(d){const e=d.renderer;if(!e)switch(d.type){case"number":return new ae;case"date":return new de;case"boolean":return new ce;case"radio":return new he;case"img":return new ue;case"html":return new ge;case"barcode":return new _e;case"select":return new ut(d.options??[],d.optionsFn);default:return new le}if(typeof e=="string")switch(e){case"number":return new ae;case"date":return new de;case"checkbox":return new ce;case"button":return new ke;case"link":return new Se;case"badge":return new Ee;case"switch":return new Le;case"radio":return new he;case"img":return new ue;case"html":return new ge;case"barcode":return new _e;default:return new le}switch(e.type){case"button":return new ke(e);case"checkbox":return new ce;case"link":return new Se(e.hrefFn,e.target);case"template":return new gt(e.templateFn);case"badge":return new Ee(e.colorMap,e.labelMap??e.valueMap);case"image":return new _t(e);case"progress":return new pt(e);case"sparkline":return new ft(e);case"switch":return new Le;case"rating":return new mt(e);case"number":return new ae;case"date":return new de;case"radio":return new he;case"img":return new ue;case"html":return new ge;case"barcode":return new _e;default:return new le}}class Mt{constructor(e,t,s){this._cellMap=new Map,this._root=e,this._opts=t,this._cbs=s,this._header=S("div","og-header"),this._header.style.cssText="flex-shrink:0;overflow-x:auto;overflow-y:hidden;border-bottom:1px solid var(--og-border-color,#e0e0e0);scrollbar-width:none;",this._bodyWrap=S("div","og-body-wrapper"),this._bodyWrap.style.cssText="flex:1;overflow:auto;position:relative;",this._bodyWrap.style.setProperty("--scrollbar-size","8px"),this._body=S("div","og-body"),this._body.style.cssText="position:relative;",this._bodyWrap.appendChild(this._body),e.appendChild(this._header),e.appendChild(this._bodyWrap),this._bodyWrap.addEventListener("scroll",()=>{this._header.scrollLeft=this._bodyWrap.scrollLeft},{passive:!0})}get bodyWrapper(){return this._bodyWrap}updateSize(e,t){this._bodyWrap.style.height=`${e-t}px`}renderHeader(e,t,s,n,i){var g,E;this._header.innerHTML="";const o=i._frozenCount??0;let l=0;i.stateColumn&&(l+=24),i.draggable&&(l+=18),i.rowNumber&&(l+=44),i.checkColumn&&(l+=36);const r=l+t.reduce((w,C,M)=>w+(s[M]??i.defaultColumnWidth),0);this._header.style.background="var(--og-header-bg,#f5f5f5)";const a=S("table");a.setAttribute("role","presentation"),a.style.cssText=`table-layout:fixed;border-collapse:collapse;width:${r}px;background:var(--og-header-bg,#f5f5f5);`;const c=e.length;let h=0;const u=(w,C,M,p="")=>{const v=S("th",`og-header-cell og-extra-col ${p}`);v.setAttribute("rowspan",String(c)),v.textContent=M,De(v,{width:`${C}px`,minWidth:`${C}px`,textAlign:"center",borderRight:"1px solid var(--og-border-color,#e0e0e0)",borderBottom:"1px solid var(--og-border-color,#e0e0e0)",padding:"0",fontSize:"11px",color:"#999",userSelect:"none",boxSizing:"border-box",background:"var(--og-header-bg,#f5f5f5)"}),o>0&&(v.style.position="sticky",v.style.left=`${h}px`,v.style.zIndex="4"),h+=C,w.appendChild(v)};for(let w=0;w<e.length;w++){const C=S("tr","og-header-row");if(C.style.height=`${i.headerHeight}px`,w===0&&(i.stateColumn&&u(C,24,""),i.draggable&&u(C,18,""),i.rowNumber&&u(C,44,"No"),i.checkColumn)){const M=S("th","og-header-cell og-extra-col");M.setAttribute("rowspan",String(c)),M.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);background:var(--og-header-bg,#f5f5f5);box-sizing:border-box;",o>0&&(M.style.position="sticky",M.style.left=`${h}px`,M.style.zIndex="4"),h+=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)),M.appendChild(p),C.appendChild(M)}for(const M of e[w]??[]){const p=S("th","og-header-cell"),v=M.column;M.colSpan>1&&(p.colSpan=M.colSpan),M.rowSpan>1&&(p.rowSpan=M.rowSpan);const _=M.colSpan===1?t.findIndex(m=>m.field===v.field):-1;if(M.colSpan===1){const m=_>=0?s[_]??i.defaultColumnWidth:v.width??i.defaultColumnWidth;p.style.width=`${m}px`,p.style.minWidth=`${m}px`}const F=n.find(m=>m.field===v.field),A=v.sortable!==!1&&i.sortable&&M.colSpan===1;if(p.setAttribute("role","columnheader"),p.setAttribute("scope","col"),A&&(p.setAttribute("aria-sort",F?F.dir==="asc"?"ascending":"descending":"none"),p.tabIndex=_===0?0:-1,p.addEventListener("keydown",m=>{if(m.key==="Enter"||m.key===" ")m.preventDefault(),this._cbs.onHeaderClick(v.field,m.shiftKey);else if(m.key==="ArrowRight"){m.preventDefault();const b=p.nextElementSibling;(b==null?void 0:b.tagName)==="TH"&&b.focus()}else if(m.key==="ArrowLeft"){m.preventDefault();const b=p.previousElementSibling;(b==null?void 0:b.tagName)==="TH"&&b.focus()}})),_>=0&&_<o){let m=0;i.stateColumn&&(m+=24),i.draggable&&(m+=18),i.rowNumber&&(m+=44),i.checkColumn&&(m+=36);for(let b=0;b<_;b++)m+=s[b]??i.defaultColumnWidth;p.classList.add("og-frozen"),_===o-1&&p.classList.add("og-frozen-last"),p.style.left=`${m}px`}De(p,{padding:"4px 8px",boxSizing:"border-box",textAlign:v.headerAlign??"center",borderRight:"1px solid var(--og-border-color,#e0e0e0)",borderBottom:"1px solid var(--og-border-color,#e0e0e0)",userSelect:"none",cursor:A?"pointer":"default",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",position:"relative"});const H=S("span");if(H.textContent=v.header??v.field,H.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",p.appendChild(H),F){p.classList.add("og-sorted");const m=S("span","og-sort-icon");m.textContent=F.dir==="asc"?" ↑":" ↓",p.appendChild(m)}if(v.filterable!==!1&&i.filterable&&M.colSpan===1){const m=S("span","og-filter-icon"),b=((E=(g=i._activeFilters)==null?void 0:g[v.field])==null?void 0:E.length)>0;m.textContent=b?"⊿":"▿",m.title="필터",m.style.cssText="margin-left:3px;cursor:pointer;font-size:10px;opacity:0.6;",b&&m.classList.add("og-filter-icon--active"),m.addEventListener("click",k=>{k.stopPropagation(),this._cbs.onFilterIconClick(v.field,m)}),p.appendChild(m)}if(v.resizable!==!1){const m=S("div","og-resize-handle");m.style.cssText="position:absolute;right:0;top:0;bottom:0;width:4px;cursor:col-resize;z-index:1;",p.appendChild(m);const b=_;Rt(m,p,k=>{b>=0&&this._cbs.onColResize(b,k)})}i.columnReorder&&_>=0&&M.colSpan===1&&(p.draggable=!0,p.addEventListener("dragstart",m=>{var b;this._cbs.onColDragStart(_),p.classList.add("og-col-dragging"),(b=m.dataTransfer)==null||b.setData("text/plain",String(_))}),p.addEventListener("dragend",()=>{p.classList.remove("og-col-dragging"),this._header.querySelectorAll(".og-col-drop-over").forEach(m=>m.classList.remove("og-col-drop-over"))}),p.addEventListener("dragover",m=>{m.preventDefault();const b=this._cbs.getColDragIdx();b!==null&&b!==_&&(this._header.querySelectorAll(".og-col-drop-over").forEach(k=>k.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",m=>{m.preventDefault(),p.classList.remove("og-col-drop-over"),this._cbs.onColDrop(_)})),A&&p.addEventListener("click",m=>{m.target.classList.contains("og-resize-handle")||this._cbs.onHeaderClick(v.field,m.shiftKey)}),C.appendChild(p)}a.appendChild(C)}this._header.appendChild(a)}renderBody(e,t,s,n,i,o,l,r,a,c,h=null,u,g,E={},w){var p,v;Object.keys(E).length&&(o={...o,...E}),this._body.innerHTML="",this._cellMap.clear(),this._body.style.height=`${r}px`;const C=o._frozenCount??0;{let _=0;o.stateColumn&&(_+=24),o.draggable&&(_+=18),o.rowNumber&&(_+=44),o.checkColumn&&(_+=36);const F=_+n.reduce((A,H,$)=>A+(i[$]??o.defaultColumnWidth),0);this._body.style.minWidth=`${F}px`}if(t<e)return;const M=document.createDocumentFragment();for(let _=e;_<=t;_++){const F=h?h[_]:null,A=F&&F._isGroup===!0,H=F&&F._isTree===!0;if(A){const f=F,L=`__${f._groupField}:${f._groupValue}`,D=S("div","og-group-row"),te=l+(_-e)*o.rowHeight;D.style.cssText=[`top:${te}px;height:${o.rowHeight}px;`,"display:flex;align-items:stretch;cursor:pointer;",`padding-left:${4+f._depth*12}px;`,"background:var(--og-header-bg,#f5f5f5);","border-bottom:1px solid var(--og-border-color,#e0e0e0);"].join(""),D.setAttribute("role","row"),D.setAttribute("aria-expanded",f._expanded?"true":"false"),D.setAttribute("aria-rowindex",String(_+1)),D.setAttribute("aria-level",String(f._depth+1));let P=0;if(o.stateColumn&&(P+=24),o.draggable&&(P+=18),o.rowNumber&&(P+=44),o.checkColumn&&(P+=36),P>0){const y=S("div","og-group-state-cell");y.style.cssText=[`width:${P}px;min-width:${P}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 I=f._states??{added:0,edited:0,removed:0};if(I.added>0){const z=S("span");z.textContent=`+${I.added}`,z.style.cssText="color:var(--og-row-added-bg,#2e7d32);background:#e8f5e9;padding:1px 3px;border-radius:3px;",y.appendChild(z)}if(I.edited>0){const z=S("span");z.textContent=`M${I.edited}`,z.style.cssText="color:#e65100;background:#fff8e1;padding:1px 3px;border-radius:3px;",y.appendChild(z)}if(I.removed>0){const z=S("span");z.textContent=`D${I.removed}`,z.style.cssText="color:var(--og-row-removed-bg,#c62828);background:#ffebee;padding:1px 3px;border-radius:3px;",y.appendChild(z)}D.appendChild(y)}let O=!1;for(let y=0;y<n.length;y++){const I=n[y],z=i[y]??o.defaultColumnWidth,se=f._summaryFmt!==void 0&&I.field in(f._summaryFmt??{}),B=S("div","og-group-cell");if(B.style.cssText=[`width:${z}px;min-width:${z}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(""),se){const U=f._summaryFmt[I.field];B.textContent=U!==""?U:"-",B.style.justifyContent="flex-end",B.style.color="var(--og-primary,#1976d2)",B.style.fontWeight="600"}else if(!O){O=!0;const U=S("span","og-group-arrow");U.textContent=f._expanded?"▾ ":"▸ ",U.style.cssText="color:var(--og-primary,#1976d2);margin-right:4px;flex-shrink:0;",B.appendChild(U);const j=S("span","og-group-label");j.textContent=`${f._groupLabel} (${f._childCount}건)`,j.style.cssText="overflow:hidden;text-overflow:ellipsis;font-weight:600;",B.appendChild(j),B.style.gap="0"}D.appendChild(B)}D.addEventListener("click",()=>u==null?void 0:u(L)),M.appendChild(D);continue}const $=H?F:null,m=$?$.data:h?F:s.getRowByIndex(_);if(!m)continue;const b=H||A?"none":s.getRowState(_),k=S("div","og-row");k.setAttribute("role","row"),k.setAttribute("aria-rowindex",String(_+1));const K=l+(_-e)*o.rowHeight;k.style.top=`${K}px`,k.style.height=`${o.rowHeight}px`;let T=_%2===0?"var(--og-row-bg,#fff)":"var(--og-row-alt-bg,#fafafa)";k.style.background=T,b==="added"&&k.classList.add("og-state-added"),b==="edited"&&k.classList.add("og-state-edited"),b==="removed"&&k.classList.add("og-state-removed"),a.has(_)&&k.classList.add("og-selected"),k.setAttribute("aria-selected",a.has(_)?"true":"false"),b==="added"&&(T="var(--og-row-added-bg,#e8f5e9)"),b==="edited"&&(T="var(--og-row-edited-bg,#fff8e1)"),b==="removed"&&(T="var(--og-row-removed-bg,#ffebee)"),a.has(_)&&(T="var(--og-row-selected-bg,#bbdefb)");const ne=_;k.addEventListener("click",f=>{this._cbs.onCellClick(ne,-1,f)});const oe=new Map;let V=0;if(o.stateColumn){const f=S("div","og-cell og-col-state"),L={added:"✚",edited:"✎",removed:"✖",none:""},D={added:"#2e7d32",edited:"#bf360c",removed:"#c62828",none:""};f.textContent=L[b]??"",f.style.color=D[b]??"",f.title=b,C>0&&(f.style.position="sticky",f.style.left=`${V}px`,f.style.zIndex="2",f.style.background=T),V+=24,k.appendChild(f)}const J=this._cbs.getDndManager();if(o.draggable&&J){const f=J.attachHandle(k,_,o._totalRows??t+1);C>0&&(f.style.position="sticky",f.style.left=`${V}px`,f.style.zIndex="2",f.style.background=T),V+=18,k.appendChild(f)}if(o.rowNumber){const f=S("div","og-cell og-col-rownum");f.textContent=String(_+1),C>0&&(f.style.position="sticky",f.style.left=`${V}px`,f.style.zIndex="2",f.style.background=T),V+=44,k.appendChild(f)}if(o.checkColumn){const f=S("div","og-cell og-col-check"),L=document.createElement("input");L.type="checkbox",L.checked=c.has(_),L.setAttribute("aria-label",`${_+1}행 선택`),L.addEventListener("click",D=>D.stopPropagation()),L.addEventListener("change",D=>{D.stopPropagation(),this._cbs.onRowCheck(_,L.checked)}),f.appendChild(L),C>0&&(f.style.position="sticky",f.style.left=`${V}px`,f.style.zIndex="2",f.style.background=T),V+=36,k.appendChild(f)}for(let f=0;f<n.length;f++){const L=n[f],D=i[f]??o.defaultColumnWidth,te=o.editable&&L.editable!==!1,P=f===0,O=w&&!w.isEmpty?w.getInfo(_,f):null;if(O!=null&&O.hidden){const R=S("div","og-cell og-cell--merge-ph");R.style.cssText=`width:${D}px;min-width:${D}px;flex-shrink:0;visibility:hidden;box-sizing:border-box;`,k.appendChild(R);continue}const y=S("div","og-cell");y.setAttribute("role","gridcell"),y.setAttribute("aria-colindex",String(f+1));const I=(O==null?void 0:O.rowSpan)??1,z=(O==null?void 0:O.colSpan)??1,se=I>1?I*o.rowHeight:o.rowHeight;let B=D;if(z>1)for(let R=1;R<z;R++)B+=i[f+R]??o.defaultColumnWidth;const U=f<C;let j=0;if(U){o.stateColumn&&(j+=24),o.draggable&&(j+=18),o.rowNumber&&(j+=44),o.checkColumn&&(j+=36);for(let R=0;R<f;R++)j+=i[R]??o.defaultColumnWidth;y.classList.add("og-frozen-cell"),f===C-1&&y.classList.add("og-frozen-last")}y.style.width=`${B}px`,y.style.minWidth=`${B}px`,y.style.maxWidth=`${B}px`,I>1&&(y.style.height=`${se}px`),U&&(y.style.background=T),$&&P&&(y.style.padding="0"),y.style.overflow="hidden",I>1?(y.style.height=`${se}px`,y.style.position="absolute",y.style.zIndex="3",y.style.background=T&&T!=="inherit"?T:"var(--og-row-bg, #fff)",y.style.borderBottom="1px solid var(--og-border-color, #e0e0e0)"):U&&(y.style.position="sticky",y.style.left=`${j}px`,y.style.zIndex="1"),L.type==="number"||L.align==="right"?y.classList.add("og-cell--right"):L.align==="center"&&y.classList.add("og-cell--center"),te&&y.classList.add("og-cell--editable"),te||y.setAttribute("aria-readonly","true"),z>1&&y.setAttribute("aria-colspan",String(z)),I>1&&y.setAttribute("aria-rowspan",String(I)),((p=o._focusCell)==null?void 0:p.ri)===_&&((v=o._focusCell)==null?void 0:v.ci)===f&&(y.classList.add("og-cell-focused"),y.tabIndex=-1);const Ce=m?m[L.field]:null;y.setAttribute("aria-label",`${L.header}: ${Ce==null?"":String(Ce)}`);let Me=y;if($&&P){const R=S("div","og-tree-cell"),q=$._ancestorHasMore??[];for(let N=0;N<$._depth;N++){const Y=S("span","og-tree-guide");q[N]&&Y.classList.add("og-tree-guide--line"),R.appendChild(Y)}if($._depth>0){const N=S("span","og-tree-connector");N.classList.add($._isLastChild?"og-tree-connector--last":"og-tree-connector--mid"),R.appendChild(N)}const ie=S("span","og-tree-toggle-wrap");if(!$._hasChildren){const N=S("span","og-tree-leaf-dot");ie.appendChild(N)}R.appendChild(ie);const W=document.createElement("i");if($._hasChildren){const N=Te(L.treeNodeIcon,m,!0,$._expanded);W.className=$._expanded?`${N} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--open og-tree-node-icon--toggle`:`${N} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--toggle`,W.setAttribute("role","button"),W.setAttribute("tabindex","0"),W.setAttribute("aria-expanded",$._expanded?"true":"false"),W.setAttribute("aria-label",$._expanded?"접기":"펼치기"),W.addEventListener("click",Y=>{Y.stopPropagation(),g==null||g($._treeId)}),W.addEventListener("keydown",Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),Y.stopPropagation(),g==null||g($._treeId))})}else{const N=Te(L.treeNodeIcon,m,!1,!1);W.setAttribute("aria-hidden","true"),W.className=`${N} og-tree-node-icon og-tree-node-icon--leaf`}R.appendChild(W),y.appendChild(R),Me=R}if(L.cellStyle){const R=m[L.field],q=typeof L.cellStyle=="function"?L.cellStyle(R,m,_):L.cellStyle;Object.assign(y.style,q)}const je=Ct(L).render({value:m[L.field],row:m,rowIndex:_,column:L,colIndex:f,isSelected:a.has(_),rowState:b});Me.appendChild(je);const X=_,G=f;if(y.addEventListener("click",R=>{R.stopPropagation(),this._cbs.onCellClick(X,G,R)}),y.addEventListener("dblclick",R=>{R.stopPropagation(),this._cbs.onCellDblClick(X,G,R)}),y.addEventListener("mouseover",R=>{R.stopPropagation(),this._cbs.onCellMouseOver(X,G,R)}),y.addEventListener("mouseout",R=>{R.stopPropagation(),this._cbs.onCellMouseOut(X,G,R)}),y.addEventListener("mousedown",R=>{R.stopPropagation(),this._cbs.onCellMouseDown(X,G,R)}),y.addEventListener("mouseup",R=>{R.stopPropagation(),this._cbs.onCellMouseUp(X,G,R)}),y.addEventListener("mousemove",R=>{R.stopPropagation(),this._cbs.onCellMouseMove(X,G,R)}),oe.set(f,y),I>1){const R=document.createElement("div");R.style.cssText=[`width:${D}px;min-width:${D}px;height:${o.rowHeight}px;`,"flex-shrink:0;box-sizing:border-box;","border-right:1px solid var(--og-border-color,#e0e0e0);"].join(""),k.appendChild(R);let q=0;o.stateColumn&&(q+=24),o.draggable&&(q+=18),o.rowNumber&&(q+=44),o.checkColumn&&(q+=36);for(let W=0;W<f;W++)q+=i[W]??o.defaultColumnWidth;const ie=l+(_-e)*o.rowHeight;y.style.left=`${q}px`,y.style.top=`${ie}px`,M.appendChild(y)}else k.appendChild(y)}this._cellMap.set(_,oe),M.appendChild(k)}if(s.rowCount===0){const _=S("div","og-empty-message");_.textContent="데이터가 없습니다.",_.style.cssText="width:100%;",M.appendChild(_)}this._body.appendChild(M)}getCellEl(e,t){var s;return(s=this._cellMap.get(e))==null?void 0:s.get(t)}destroy(){this._root.innerHTML=""}}function Te(d,e,t,s){let n;return d?typeof d=="function"?n=d(e,t,s):t?n=s?d.branchOpen??"bi-folder2-open":d.branch??"bi-folder2":n=d.leaf??"bi-file-earmark":n=t?s?"bi-folder2-open":"bi-folder2":"bi-file-earmark",n.startsWith("bi ")?n:`bi ${n}`}function S(d,e){const t=document.createElement(d);return e&&(t.className=e),t}function De(d,e){Object.assign(d.style,e)}function $e(d,e,t="text/plain;charset=utf-8"){const s=new Blob([d],{type:t}),n=URL.createObjectURL(s),i=document.createElement("a");i.href=n,i.download=e,i.click(),URL.revokeObjectURL(n)}function Rt(d,e,t){let s=0,n=0;d.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),s=i.clientX,n=e.offsetWidth;const o=r=>{const a=Math.max(40,n+r.clientX-s);e.style.width=`${a}px`,e.style.minWidth=`${a}px`},l=r=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l),t(Math.max(40,n+r.clientX-s))};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)})}class kt{constructor(e){this._selectedRows=new Set,this._checkedRows=new Set,this._data=e}get selectedRows(){return this._selectedRows}get checkedRows(){return this._checkedRows}selectSingle(e){this._selectedRows.clear(),this._selectedRows.add(e)}selectToggle(e){this._selectedRows.has(e)?this._selectedRows.delete(e):this._selectedRows.add(e)}clearSelection(){this._selectedRows.clear()}check(e,t){t?this._checkedRows.add(e):this._checkedRows.delete(e)}checkAll(e,t){if(e)for(let s=0;s<t;s++)this._checkedRows.add(s);else this._checkedRows.clear()}checkByValue(e,t){for(let s=0;s<this._data.rowCount;s++)t.includes(this._data.getCellValue(s,e))&&this._checkedRows.add(s)}uncheckAll(){this._checkedRows.clear()}checkById(e){}addCheckById(e){}uncheckById(e){}getSelections(){return[...this._selectedRows].map(e=>this._data.getRowByIndex(e)).filter(Boolean)}getChecked(){return[...this._checkedRows].map(e=>({row:this._data.getRowByIndex(e),rowIndex:e}))}getAllChecked(){return this.getChecked().map(e=>e.row)}getActiveRow(){return this._selectedRows.size>0?[...this._selectedRows][0]:-1}activate(e){this._selectedRows.clear(),this._selectedRows.add(e)}deselect(){this._selectedRows.clear()}reset(){this._selectedRows.clear(),this._checkedRows.clear()}}class pe{constructor(){this._onKeyDown=e=>{e.stopPropagation(),e.key==="Enter"?(e.preventDefault(),this._onCommit(this.input.value)):e.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._onCommit(this.input.value)}}mount(e,t,s,n){this._container=e,this._onCommit=s,this._onCancel=n,e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","true"),this.input=document.createElement("input"),this.input.type="date",this.input.className="og-cell-input",this.input.setAttribute("aria-label",t.column.header??"날짜 선택");const i=t.value;if(i){const o=i instanceof Date?i:new Date(i);isNaN(o.getTime())||(this.input.value=We(o,"yyyy-MM-dd"))}this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),e.appendChild(this.input)}getValue(){var e;return(e=this.input)==null?void 0:e.value}focus(){var e;(e=this.input)==null||e.focus()}destroy(){var e,t,s;(e=this._container)==null||e.setAttribute("aria-expanded","false"),(t=this.input)==null||t.removeEventListener("keydown",this._onKeyDown),(s=this.input)==null||s.removeEventListener("blur",this._onBlur)}}function Ae(d){return d.map(e=>typeof e=="string"?{label:e,value:e}:{label:e.label??e.text??String(e.value??""),value:e.value})}class fe{constructor(e=[],t){this._options=Ae(e),this._optionsFn=t??null}mount(e,t,s,n){this._container=e,this._onCommit=s,this._onCancel=n,e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-expanded","true"),this.select=document.createElement("select"),this.select.className="og-cell-select",this.select.setAttribute("aria-label",t.column.header??"선택");const i=this._optionsFn?Ae(this._optionsFn(t.row,t.rowIndex)):this._options;for(const l of i){const r=document.createElement("option");r.value=String(l.value),r.textContent=l.label,this.select.appendChild(r)}const o=t.value==null?"":String(t.value);i.some(l=>String(l.value)===o)&&(this.select.value=o),this.select.addEventListener("change",()=>s(this.select.value)),this.select.addEventListener("blur",()=>s(this.select.value)),this.select.addEventListener("keydown",l=>{l.key==="Escape"&&n()}),e.appendChild(this.select)}getValue(){var e;return(e=this.select)==null?void 0:e.value}focus(){var e;(e=this.select)==null||e.focus()}destroy(){var e;(e=this._container)==null||e.setAttribute("aria-expanded","false")}}class me{constructor(){this._onKeyDown=e=>{e.stopPropagation(),e.key==="Enter"||e.key==="Tab"?(e.preventDefault(),this._onCommit(this.input.value)):e.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._onCommit(this.input.value)}}mount(e,t,s,n){this._onCommit=s,this._onCancel=n,this.input=document.createElement("input"),this.input.type="text",this.input.value=t.value==null?"":String(t.value),this.input.style.cssText=`
31
- width:100%;height:100%;border:none;outline:none;padding:0 8px;
32
- font-size:var(--og-font-size,13px);font-family:var(--og-font-family,sans-serif);
33
- background:var(--og-row-bg,#fff);box-sizing:border-box;
34
- `,this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),e.appendChild(this.input)}getValue(){var e;return(e=this.input)==null?void 0:e.value}focus(){var e,t;(e=this.input)==null||e.focus(),(t=this.input)==null||t.select()}destroy(){var e,t;(e=this.input)==null||e.removeEventListener("keydown",this._onKeyDown),(t=this.input)==null||t.removeEventListener("blur",this._onBlur)}}class we{constructor(e){this._onKeyDown=t=>{t.stopPropagation(),t.key==="Enter"||t.key==="Tab"?(t.preventDefault(),this._commit()):t.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._commit()},this.min=e==null?void 0:e.min,this.max=e==null?void 0:e.max,this.step=e==null?void 0:e.step}mount(e,t,s,n){this._onCommit=s,this._onCancel=n,this.input=document.createElement("input"),this.input.type="number",this.input.value=t.value==null?"":String(t.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=`
35
- width:100%;height:100%;border:none;outline:none;padding:0 8px;
36
- font-size:var(--og-font-size,13px);text-align:right;
37
- background:var(--og-row-bg,#fff);box-sizing:border-box;
38
- `,this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),e.appendChild(this.input)}_commit(){const e=this.input.value===""?null:Number(this.input.value);this._onCommit(e)}getValue(){var e,t;return((e=this.input)==null?void 0:e.value)===""?null:Number((t=this.input)==null?void 0:t.value)}focus(){var e,t;(e=this.input)==null||e.focus(),(t=this.input)==null||t.select()}destroy(){var e,t;(e=this.input)==null||e.removeEventListener("keydown",this._onKeyDown),(t=this.input)==null||t.removeEventListener("blur",this._onBlur)}}class ye{mount(e,t,s,n){this._onCommit=s,e.style.cssText+="display:flex;align-items:center;justify-content:center;",this.chk=document.createElement("input"),this.chk.type="checkbox",this.chk.checked=!!t.value,this.chk.style.cursor="pointer",this.chk.addEventListener("change",()=>s(this.chk.checked)),e.appendChild(this.chk)}getValue(){var e;return(e=this.chk)==null?void 0:e.checked}focus(){var e;(e=this.chk)==null||e.focus()}destroy(){}}function ze(d){const e=d.editor;if(!e)switch(d.type){case"number":return new we;case"date":return new pe;case"boolean":return new ye;case"select":return new fe(d.options??[],d.optionsFn);default:return new me}if(typeof e=="string")switch(e){case"number":return new we;case"date":return new pe;case"select":return new fe(d.options??[],d.optionsFn);case"checkbox":return new ye;default:return new me}switch(e.type){case"number":{const t={};return e.min!=null&&(t.min=e.min),e.max!=null&&(t.max=e.max),e.step!=null&&(t.step=e.step),new we(t)}case"date":return new pe;case"select":return new fe(e.options??[],d.optionsFn);case"checkbox":return new ye;default:return new me}}function Z(d){const e=typeof d.renderer=="string"?d.renderer:d.renderer&&typeof d.renderer=="object"?d.renderer.type:"";return d.type==="boolean"||d.type==="checkbox"||e==="checkbox"||e==="switch"}class Et{constructor(e){this._activeEditor=null,this._editCell=null,this._focusCell=null,this._dragColIdx=null,this._d=e}get activeEditor(){return this._activeEditor}get editCell(){return this._editCell}get focusCell(){return this._focusCell}get dragColIdx(){return this._dragColIdx}set dragColIdx(e){this._dragColIdx=e}setFocusCell(e,t){this._focusCell={ri:e,ci:t},this._d.scrollToRow(e),this._d.doRender();const s=this._d.getVisibleLeaves()[t],n=this._d.data.getRowByIndex(e);if(s&&n){const i=n[s.field];this._d.announce(`${e+1}행 ${t+1}열, ${s.header}: ${i==null?"빈 값":String(i)}`)}}clearFocusCell(){this._focusCell=null}startEditByKey(e,t){var a,c,h;const s=this._d.getVisibleLeaves()[t];if(!s)return;if(Z(s)){const u=this._d.getOptions();if(s.editable!==!1&&(s.editable!==void 0||u.editable)){const E=this._d.data.getRowByIndex(e);E&&this._d.writeCell(e,s.field,!E[s.field])}return}const n=this._d.data.getRowByIndex(e);if(s.editable===!1||typeof s.editable=="function"&&!s.editable(n,e))return;this.commitEdit();const i=(a=this._d.getRenderer())==null?void 0:a.getCellEl(e,t);if(!i)return;i.innerHTML="";const o=ze(s);this._activeEditor=o,this._editCell={ri:e,ci:t};const l={type:"editStart",rowIndex:e,columnIndex:t,field:s.field,oldValue:n==null?void 0:n[s.field],newValue:n==null?void 0:n[s.field],row:n,column:s};this._d.emit("editStart",l),(h=(c=this._d.getOptions()).onEditStart)==null||h.call(c,l),i.classList.add("og-editing");const r={value:n==null?void 0:n[s.field],row:n,rowIndex:e,column:s,colIndex:t,isSelected:!0,rowState:"none"};o.mount(i,r,u=>this.commitEditWithValue(e,t,u),()=>this.cancelEdit()),requestAnimationFrame(()=>o.focus())}startEdit(e,t,s){var h,u;const n=this._d.getOptions();if(!n.editable)return;const i=this._d.getVisibleLeaves()[t];if(!i||Z(i))return;const o=this._d.data.getRowByIndex(e);if(i.editable===!1||typeof i.editable=="function"&&!i.editable(o,e)||!i.editable&&!n.editable)return;this.commitEdit();const l=(h=this._d.getRenderer())==null?void 0:h.getCellEl(e,t);if(!l)return;l.innerHTML="";const r=ze(i);this._activeEditor=r,this._editCell={ri:e,ci:t};const a={type:"editStart",rowIndex:e,columnIndex:t,field:i.field,oldValue:o==null?void 0:o[i.field],newValue:o==null?void 0:o[i.field],row:o,column:i};this._d.emit("editStart",a),(u=n.onEditStart)==null||u.call(n,a),l.classList.add("og-editing");const c={value:o==null?void 0:o[i.field],row:o,rowIndex:e,column:i,colIndex:t,isSelected:!0,rowState:"none"};r.mount(l,c,g=>this.commitEditWithValue(e,t,g),()=>this.cancelEdit()),requestAnimationFrame(()=>r.focus())}commitEdit(){if(!this._activeEditor||!this._editCell)return;const e=this._activeEditor.getValue(),{ri:t,ci:s}=this._editCell;this._finishEdit(t,s,e,!1)}commitEditWithValue(e,t,s){this._finishEdit(e,t,s,!1)}cancelEdit(){if(!this._editCell)return;const{ri:e,ci:t}=this._editCell;this._finishEdit(e,t,void 0,!0)}_finishEdit(e,t,s,n){var l,r,a;if(!this._activeEditor)return;const i=this._d.getVisibleLeaves()[t],o=(l=this._d.getRenderer())==null?void 0:l.getCellEl(e,t);if(o&&(this._activeEditor.destroy(),o.classList.remove("og-editing")),this._activeEditor=null,this._editCell=null,!n&&i){const c=this._d.data.getCellValue(e,i.field);if(s!==c){this._d.data.updateCell(e,i.field,s);const h=this._d.data.getRowByIndex(e),u=this._d.getOptions(),g={type:"editEnd",rowIndex:e,columnIndex:t,field:i.field,oldValue:c,newValue:s,row:h,column:i};this._d.emit("editEnd",g),(r=u.onEditEnd)==null||r.call(u,g),this._d.emit("dataChange",this._d.data.getData()),(a=u.onDataChange)==null||a.call(u,this._d.data.getData())}}this._d.doRender(),requestAnimationFrame(()=>this._d.getContainer().focus({preventScroll:!0}))}}class St{constructor(e,t,s,n,i){this._selects=new Map,this._selected={},this._config=t,this._onFilter=s,this._onReset=n,this._el=document.createElement("fieldset"),this._el.className="og-filter-select";const o=document.createElement("legend");o.className="og-filter-select-legend",o.textContent=t.legend??"필터",this._el.appendChild(o);const l=document.createElement("div");l.className="og-filter-select-row";for(const a of t.columns){const c=`og-fsel-${a.field}`,h=document.createElement("div");h.className="og-filter-select-group";const u=document.createElement("label");u.htmlFor=c,u.textContent=a.label,u.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)),h.appendChild(u),h.appendChild(g),l.appendChild(h),this._selects.set(a.field,g)}const r=document.createElement("button");r.type="button",r.textContent="초기화",r.className="og-filter-select-reset",r.setAttribute("aria-label","필터 초기화"),r.addEventListener("click",()=>this._reset()),this._el.appendChild(l),this._el.appendChild(r),e.insertBefore(this._el,e.firstChild)}_resolve(e,t){if(e.options)return e.options;let s=e.data??[];e.dependsOn&&e.dependsOnKey&&t&&(s=s.filter(o=>String(o[e.dependsOnKey]??"")===t));const n=e.valueKey??"value",i=e.textKey??n;return s.map(o=>({value:String(o[n]??""),text:String(o[i]??o[n]??"")}))}_fill(e,t,s){e.innerHTML="";const n=document.createElement("option");n.value="",n.textContent="전체",e.appendChild(n);for(const i of t){const o=document.createElement("option");o.value=i.value,o.textContent=i.text,e.appendChild(o)}e.disabled=!s}_onChange(e,t){const s=this._config.columns.find(i=>i.field===e),n=s.filterKey??s.field;t?(this._selected[e]=t,this._onFilter(n,[{operator:"=",value:t}])):(delete this._selected[e],this._onReset(n)),this._cascade(e)}_cascade(e){const t=this._selected[e]??"";for(const s of this._config.columns){if(s.dependsOn!==e)continue;const n=this._selects.get(s.field);if(!n)continue;const i=s.filterKey??s.field;t?(this._fill(n,this._resolve(s,t),!0),n.value="",delete this._selected[s.field],this._onReset(i)):(this._fill(n,[],!1),delete this._selected[s.field],this._onReset(i),this._cascade(s.field))}}_reset(){this._selected={};for(const e of this._config.columns){const t=this._selects.get(e.field),s=e.filterKey??e.field;t&&(e.dependsOn?this._fill(t,[],!1):(t.value="",t.disabled=!1),this._onReset(s))}}reset(){this._reset()}destroy(){this._el.remove()}}class Lt{constructor(e,t,s){this._page=1,this._totalRows=0,this._pageSize=t,this._onChange=s,this._el=document.createElement("div"),this._el.className="og-pagination",this._el.style.cssText=`
39
- display:flex;align-items:center;justify-content:center;gap:4px;
40
- padding:6px 8px;border-top:1px solid var(--og-border-color,#e0e0e0);
41
- background:var(--og-header-bg,#f5f5f5);flex-shrink:0;user-select:none;
42
- font-size:12px;color:var(--og-text-color,#333);
43
- `,e.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(e){this._totalRows=e,this._page>this.totalPages&&(this._page=this.totalPages),this._render()}setPageSize(e){this._pageSize=e,this._page=1,this._render(),this._emit()}goTo(e){const t=Math.max(1,Math.min(e,this.totalPages));t!==this._page&&(this._page=t,this._render(),this._emit())}getRange(){const e=(this._page-1)*this._pageSize,t=Math.min(e+this._pageSize-1,this._totalRows-1);return{start:e,end:t}}_emit(){this._onChange({page:this._page,pageSize:this._pageSize,totalRows:this._totalRows,totalPages:this.totalPages})}_render(){this._el.innerHTML="";const e=this.totalPages,t=document.createElement("span");t.style.cssText="display:flex;align-items:center;gap:3px;margin-right:8px;";const s=document.createElement("span");s.textContent="행/페이지:",s.style.color="#888";const n=document.createElement("select");n.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 h=document.createElement("option");h.value=String(c),h.textContent=String(c),c===this._pageSize&&(h.selected=!0),n.appendChild(h)}n.addEventListener("change",()=>this.setPageSize(Number(n.value))),t.appendChild(s),t.appendChild(n),this._el.appendChild(t);const i=document.createElement("span"),{start:o,end:l}=this.getRange();i.textContent=this._totalRows>0?`${o+1}–${l+1} / ${this._totalRows}건`:"0건",i.style.cssText="margin-right:8px;color:#888;",this._el.appendChild(i);const r=(c,h,u)=>{const g=document.createElement("button");return g.textContent=c,g.disabled=u,g.style.cssText=`
44
- min-width:28px;height:24px;padding:0 6px;
45
- border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;
46
- background:${u?"#f5f5f5":"#fff"};
47
- color:${u?"#bbb":"var(--og-text-color,#333)"};
48
- cursor:${u?"default":"pointer"};font-size:12px;
49
- `,u||g.addEventListener("click",()=>this.goTo(h)),g};this._el.appendChild(r("«",1,this._page===1)),this._el.appendChild(r("‹",this._page-1,this._page===1));const a=Ft(this._page,e);for(const c of a)if(c===-1){const h=document.createElement("span");h.textContent="…",h.style.padding="0 3px",this._el.appendChild(h)}else{const h=r(String(c),c,c===this._page);c===this._page&&(h.style.background="var(--og-primary,#1976d2)",h.style.color="#fff",h.style.borderColor="var(--og-primary,#1976d2)"),this._el.appendChild(h)}this._el.appendChild(r("›",this._page+1,this._page===e)),this._el.appendChild(r("»",e,this._page===e))}destroy(){this._el.remove()}}function Ft(d,e){if(e<=7)return Array.from({length:e},(s,n)=>n+1);const t=[1];d>3&&t.push(-1);for(let s=Math.max(2,d-1);s<=Math.min(e-1,d+1);s++)t.push(s);return d<e-2&&t.push(-1),t.push(e),t}class Tt{constructor(e,t,s){this._drag=null,this._bodyEl=e,this._rowHeight=t,this._onDrop=s,this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this)}attachHandle(e,t,s){const n=document.createElement("div");return n.className="og-drag-handle",n.innerHTML="⠿",n.style.cssText=`
50
- width:18px;min-width:18px;height:100%;
51
- display:flex;align-items:center;justify-content:center;
52
- cursor:grab;font-size:14px;color:#bbb;flex-shrink:0;
53
- user-select:none;border-right:1px solid var(--og-border-color,#e0e0e0);
54
- `,n.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),this._startDrag(i,e,t,s)}),n}_startDrag(e,t,s,n){const i=t.getBoundingClientRect(),o=document.createElement("div");o.style.cssText=`
55
- position:fixed;left:${i.left}px;top:${i.top}px;
56
- width:${i.width}px;height:${i.height}px;
57
- background:rgba(25,118,210,0.12);border:2px dashed #1976d2;
58
- box-sizing:border-box;pointer-events:none;z-index:9999;
59
- border-radius:2px;opacity:0.9;
60
- `,document.body.appendChild(o);const l=document.createElement("div");l.style.cssText=`
61
- position:absolute;left:0;right:0;height:2px;
62
- background:#1976d2;pointer-events:none;z-index:9998;display:none;
63
- `,this._bodyEl.appendChild(l),this._drag={fromIndex:s,startY:e.clientY,ghostEl:o,indicator:l,rowHeight:this._rowHeight,totalRows:n,bodyEl:this._bodyEl,currentTarget:s},document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp)}_onMouseMove(e){if(!this._drag)return;const t=this._drag,s=e.clientY-t.startY,n=t.ghostEl.getBoundingClientRect();t.ghostEl.style.top=`${n.top+s}px`,t.startY=e.clientY;const i=t.bodyEl.getBoundingClientRect(),o=e.clientY-i.top+t.bodyEl.scrollTop,l=Math.max(0,Math.min(t.totalRows-1,Math.round(o/t.rowHeight)));t.currentTarget=l;const r=l*t.rowHeight;t.indicator.style.display="block",t.indicator.style.top=`${r}px`}_onMouseUp(e){if(document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),!this._drag)return;const{fromIndex:t,currentTarget:s,ghostEl:n,indicator:i}=this._drag;this._drag=null,n.remove(),i.remove(),t!==s&&this._onDrop(t,s)}destroy(){var e,t;document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),(e=this._drag)==null||e.ghostEl.remove(),(t=this._drag)==null||t.indicator.remove(),this._drag=null}}class Q{constructor(){this._map=new Map}static _key(e,t){return`${e}:${t}`}applyMergeCells(e){this._map.clear();for(const t of e){const s=Math.max(1,t.rowSpan??1),n=Math.max(1,t.colSpan??1);this._map.set(Q._key(t.row,t.col),{rowSpan:s,colSpan:n,hidden:!1});for(let i=0;i<s;i++)for(let o=0;o<n;o++)i===0&&o===0||this._map.set(Q._key(t.row+i,t.col+o),{rowSpan:1,colSpan:1,hidden:!0})}}applyAutoMerge(e,t,s){var n,i;this._map.clear();for(let o=0;o<t.length;o++){const l=t[o],r=s[o];let a=0;for(let c=1;c<=e.length;c++){const h=(n=e[c-1])==null?void 0:n[r],u=c<e.length?(i=e[c])==null?void 0:i[r]:void 0;if(c===e.length||u!==h){const g=c-a;if(g>1){this._map.set(Q._key(a,l),{rowSpan:g,colSpan:1,hidden:!1});for(let E=a+1;E<c;E++)this._map.set(Q._key(E,l),{rowSpan:1,colSpan:1,hidden:!0})}a=c}}}}getInfo(e,t){return this._map.get(Q._key(e,t))??null}clear(){this._map.clear()}get isEmpty(){return this._map.size===0}}const Dt=[{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 $t{constructor(e,t){this._anchor=e,this._actions=t,this._el=null,this._docClick=null,this._docKey=null,this._docScroll=null,this._docMouseMove=null,this._focusIdx=-1}open(e,t){this.close();const s=t??Dt,n=document.createElement("div");n.className="og-context-menu",n.setAttribute("role","menu");for(const i of s){if(i.type==="divider"){const r=document.createElement("div");r.className="og-cm-divider",r.setAttribute("role","separator"),n.appendChild(r);continue}const o=document.createElement("button");if(o.className="og-cm-item",o.setAttribute("role","menuitem"),o.setAttribute("tabindex","-1"),i.disabled&&(o.classList.add("og-cm-disabled"),o.setAttribute("aria-disabled","true")),i.icon){const r=document.createElement("span");if(r.className="og-cm-icon",/^[a-zA-Z][\w-]*(\s+[\w-]+)+$/.test(i.icon.trim())){const a=document.createElement("i");a.className=i.icon,r.appendChild(a)}else r.textContent=i.icon;r.setAttribute("aria-hidden","true"),o.appendChild(r)}const l=document.createElement("span");l.className="og-cm-label",l.textContent=i.label??"",o.appendChild(l),o.addEventListener("click",r=>{r.stopPropagation(),i.disabled||this._runAction(i),this.close()}),n.appendChild(o)}this._anchor.appendChild(n),this._el=n,this._docMouseMove=i=>{if(!this._el)return;const o=this._el.getBoundingClientRect();(i.clientX<o.left-4||i.clientX>o.right+4||i.clientY<o.top-4||i.clientY>o.bottom+4)&&this.close()},this._position(n,e.clientX,e.clientY,()=>{this._el===n&&document.addEventListener("mousemove",this._docMouseMove,{capture:!0,passive:!0})}),this._docClick=i=>{n.contains(i.target)||this.close()},this._docKey=i=>{if(i.key==="Escape"){this.close();return}if(i.key==="ArrowDown"){i.preventDefault(),this._moveFocus(1);return}if(i.key==="ArrowUp"){i.preventDefault(),this._moveFocus(-1);return}if(i.key==="Enter"){const o=n.querySelector(".og-cm-item:focus");o==null||o.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 e;(e=this._el)==null||e.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(e,t,s,n){e.style.cssText="position:fixed;visibility:hidden;left:0;top:0;",requestAnimationFrame(()=>{const{width:i,height:o}=e.getBoundingClientRect(),l=window.innerWidth,r=window.innerHeight,a=t+i>l?Math.max(0,t-i):t,c=s+o>r?Math.max(0,s-o):s;e.style.cssText=`position:fixed;left:${a}px;top:${c}px;z-index:9999;`,n==null||n()})}_moveFocus(e){var s;if(!this._el)return;const t=Array.from(this._el.querySelectorAll(".og-cm-item:not(.og-cm-disabled)"));t.length&&(this._focusIdx=(this._focusIdx+e+t.length)%t.length,(s=t[this._focusIdx])==null||s.focus())}_runAction(e){if(typeof e.action=="function"){e.action();return}switch(e.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 Ie{constructor(e,t){this._sheets=new Map,this._active="",this._onSwitch=t,this._tabBar=this._buildTabBar(e)}add(e,t=[],s=[]){if(this._sheets.has(e))throw new Error(`WorksheetManager: 시트 '${e}'이 이미 존재합니다`);this._sheets.set(e,{name:e,columns:t,data:s}),this._renderTabs(),this._sheets.size===1&&this.switch(e)}remove(e){if(!this._sheets.has(e))return;if(this._sheets.size===1)throw new Error("WorksheetManager: 마지막 시트는 삭제할 수 없습니다");const t=this._active===e;this._sheets.delete(e),this._renderTabs(),t&&this.switch(this._sheets.keys().next().value)}rename(e,t){if(!this._sheets.has(e))return;if(this._sheets.has(t))throw new Error(`WorksheetManager: 시트 '${t}'이 이미 존재합니다`);this._sheets.get(e);const s=Array.from(this._sheets.entries()).map(([n,i])=>n===e?[t,{...i,name:t}]:[n,i]);this._sheets=new Map(s),this._active===e&&(this._active=t),this._renderTabs()}switch(e){const t=this._sheets.get(e);if(!t)throw new Error(`WorksheetManager: 시트 '${e}'을 찾을 수 없습니다`);this._active=e,this._renderTabs(),this._onSwitch(e,t)}get(e){return this._sheets.get(e)}getNames(){return Array.from(this._sheets.keys())}getActive(){return this._active}syncData(e,t){const s=this._sheets.get(e);s&&(s.data=t)}destroy(){this._tabBar.remove()}_buildTabBar(e){const t=document.createElement("div");return t.className="og-sheet-tabs",e.appendChild(t),t}_renderTabs(){this._tabBar.innerHTML="";for(const t of this._sheets.keys()){const s=document.createElement("button");s.className="og-sheet-tab",s.textContent=t,s.setAttribute("role","tab"),s.setAttribute("aria-selected",t===this._active?"true":"false"),t===this._active&&s.classList.add("og-sheet-tab--active"),s.addEventListener("click",()=>{t!==this._active&&this.switch(t)}),s.addEventListener("dblclick",()=>this._startRename(s,t)),this._tabBar.appendChild(s)}const e=document.createElement("button");e.className="og-sheet-add",e.textContent="+",e.setAttribute("aria-label","새 워크시트 추가"),e.addEventListener("click",()=>{const t=`Sheet${this._sheets.size+1}`;this.add(t,[],[]),this.switch(t)}),this._tabBar.appendChild(e)}_startRename(e,t){const s=document.createElement("input");s.className="og-sheet-tab-rename",s.value=t,e.replaceWith(s),s.focus(),s.select();const n=()=>{const i=s.value.trim()||t;try{i!==t?this.rename(t,i):this._renderTabs()}catch{this._renderTabs()}};s.addEventListener("blur",n),s.addEventListener("keydown",i=>{i.key==="Enter"&&s.blur(),i.key==="Escape"&&(s.value=t,s.blur())})}}class At{constructor(e){this._d=e}_readCssVar(e){return getComputedStyle(this._d.getContainer()).getPropertyValue(e).trim()}_hexToXlsxRgb(e){const t=e.trim(),s=t.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 n=t.replace("#","").toUpperCase();return n.length===3?n[0]+n[0]+n[1]+n[1]+n[2]+n[2]:n.length===6?n:""}exportExcel(e){const t=typeof e=="string"?{filename:e}:e??{};let s=t.filename??"export";s.toLowerCase().endsWith(".xlsx")||(s+=".xlsx");const n=t.sheetName??(this._d.getOptions().ariaLabel||"Sheet1"),i=this._d.getData(),o=this._d.getColLayout().visibleLeaves.filter(r=>{var a;return!((a=t.exceptFields)!=null&&a.includes(r.field))}),l=t.includeHeader!==!1;Promise.resolve().then(()=>require("./xlsx.min-Bx-LxWOf.cjs")).then(r=>r.xlsx_min).then(({utils:r,writeFile:a})=>{var m;const c=[];l&&c.push(o.map(b=>b.header));for(const b of i)c.push(o.map(k=>{const K=b[k.field];if(t.maskOnExport&&k.mask&&this._d.getMaskEnabled(k.field))return be(K==null?"":String(K),k.mask);const T=K;return T==null||T===""?"":k.type==="number"&&typeof T=="number"?T:typeof T=="boolean"?T?"✓":"":typeof T=="object"?"":String(T)}));const h=r.aoa_to_sheet(c),u=this._d.getColWidths(),g=this._d.getColLayout();h["!cols"]=o.map(b=>({wpx:u[g.getColumnIndex(b.field)]??100})),h["!rows"]=c.map((b,k)=>({hpx:k===0&&l?22:19}));const E=t.styleMode??"theme";let w="1565C0",C="FFFFFF",M="FFFFFF",p="EEF2FF",v="212121",_="BDBDBD",F=10;if(E==="theme"){const b=K=>this._hexToXlsxRgb(K);w=b(this._readCssVar("--og-header-bg"))||w,C=b(this._readCssVar("--og-header-color"))||C,M=b(this._readCssVar("--og-row-bg"))||M,p=b(this._readCssVar("--og-row-alt-bg"))||p,v=b(this._readCssVar("--og-row-color"))||v,_=b(this._readCssVar("--og-border-color"))||_;const k=this._readCssVar("--og-font-size");k&&(F=Math.max(8,Math.round(parseFloat(k)*.75)))}const A=E==="none",H={hdrFont:A?{}:{bold:!0,color:{rgb:C},sz:F,name:"맑은 고딕"},dataFont:A?{}:{sz:F,color:{rgb:v},name:"맑은 고딕"},hdrFill:A?{}:{patternType:"solid",fgColor:{rgb:w}},evenFill:A?{}:{patternType:"solid",fgColor:{rgb:M}},oddFill:A?{}:{patternType:"solid",fgColor:{rgb:p}},hdrBorder:A?{}:{top:{style:"medium",color:{rgb:w}},bottom:{style:"medium",color:{rgb:w}},left:{style:"thin",color:{rgb:w}},right:{style:"thin",color:{rgb:w}}},dataBorder:A?{}:{top:{style:"thin",color:{rgb:_}},bottom:{style:"thin",color:{rgb:_}},left:{style:"thin",color:{rgb:_}},right:{style:"thin",color:{rgb:_}}}};c.forEach((b,k)=>{const K=l&&k===0,ne=(l?k-1:k)%2===0;b.forEach((oe,V)=>{const J=r.encode_cell({r:k,c:V});h[J]||(h[J]={t:"s",v:""});const f=o[V],L=f.type==="number"||f.align==="right",D=K?"center":L?"right":f.align??"left";h[J].s={font:K?H.hdrFont:H.dataFont,fill:K?H.hdrFill:ne?H.evenFill:H.oddFill,border:K?H.hdrBorder:H.dataBorder,alignment:{horizontal:D,vertical:"center",wrapText:!1}}})});const $=r.book_new();r.book_append_sheet($,h,n),a($,s,{cellStyles:!0}),(m=t.onAfter)==null||m.call(t,new Blob([]))}).catch(()=>{console.error("Excel 내보내기 실패: xlsx 패키지를 확인하세요.")})}exportCsv(e){const t=typeof e=="string"?{filename:e}:e??{},s=this._d.getData(),n=this._d.getColLayout().visibleLeaves,i=n.map(r=>`"${r.header}"`).join(","),o=s.map(r=>n.map(a=>{const c=r[a.field]??"";if(t.maskOnExport&&a.mask&&this._d.getMaskEnabled(a.field))return be(String(c),a.mask);const h=c;return typeof h=="string"&&h.includes(",")?`"${h}"`:h}).join(",")),l=t.filename??"export.csv";$e("\uFEFF"+[i,...o].join(`
64
- `),l)}exportJson(e){const t=typeof e=="string"?e:(e==null?void 0:e.filename)??"export.json";$e(JSON.stringify(this._d.getData(),null,2),t,"application/json")}print(e){const t=(e==null?void 0:e.title)??"OPEN_GRID",s=(e==null?void 0:e.footerText)??"",n=this._d.getData(),i=this._d.getColLayout().visibleLeaves.filter(h=>{var u;return!((u=e==null?void 0:e.excludeFields)!=null&&u.includes(h.field))}),o=i.map(h=>`<th>${h.header??h.field}</th>`).join(""),l=n.map(h=>`<tr>${i.map(u=>`<td>${String(h[u.field]??"")}</td>`).join("")}</tr>`).join(""),r=s?`<div class="og-print-footer">${s}</div>`:"",a=`<!DOCTYPE html>
65
- <html lang="ko"><head>
66
- <meta charset="UTF-8"><title>${t}</title>
67
- <style>
68
- @page{margin:0;}
69
- body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;font-size:12px;margin:0;padding:1cm;}
70
- h2{margin:0 0 10px;font-size:14px;color:#333;}
71
- p{margin:0 0 8px;font-size:11px;color:#999;}
72
- table{border-collapse:collapse;width:100%;}
73
- th,td{border:1px solid #ccc;padding:5px 8px;text-align:left;white-space:nowrap;}
74
- th{background:#f5f5f5;font-weight:600;color:#333;}
75
- tr:nth-child(even) td{background:#fafafa;}
76
- .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;}
77
- </style>
78
- </head><body>
79
- <h2>${t}</h2>
80
- <p>${n.length}행 × ${i.length}열 · ${new Date().toLocaleString("ko-KR")}</p>
81
- <table>
82
- <thead><tr>${o}</tr></thead>
83
- <tbody>${l}</tbody>
84
- </table>
85
- ${r}
86
- <script>window.addEventListener('load',()=>{window.print();window.addEventListener('afterprint',()=>window.close());});<\/script>
87
- </body></html>`,c=window.open("","_blank","width=960,height=640");c&&(c.document.write(a),c.document.close())}exportSheetsExcel(e){const t=this._d.getWsManager();if(!t){this.exportExcel(e??"workbook");return}const s=e??"workbook.xlsx";Promise.resolve().then(()=>require("./xlsx.min-Bx-LxWOf.cjs")).then(n=>n.xlsx_min).then(({utils:n,writeFile:i})=>{const o=n.book_new(),l=this._d.getOptions();for(const r of t.getNames()){const a=t.get(r),c=a.columns.length?a.columns:l.columns,h=[c.map(g=>g.header)];for(const g of a.data)h.push(c.map(E=>{const w=g[E.field];return w==null?"":typeof w=="boolean"?w?"✓":"":E.type==="number"&&typeof w=="number"?w:String(w)}));const u=n.aoa_to_sheet(h);u["!cols"]=c.map(()=>({wpx:100})),n.book_append_sheet(o,u,r)}i(o,s.endsWith(".xlsx")?s:s+".xlsx",{cellStyles:!0})}).catch(()=>console.error("exportSheetsExcel: xlsx 패키지를 확인하세요."))}}class zt{constructor(e){this._d=e}fmtNum(e,t){if(!t)return Math.round(e).toLocaleString("ko-KR");const s=t.includes("#")||t.includes(","),n=t.match(/\.(\d+)$/),i=n?parseInt(n[1],10):/^\d+$/.test(t)?parseInt(t,10):0,o=Math.abs(e).toFixed(i),[l="0",r]=o.split("."),a=s?l.replace(/\B(?=(\d{3})+(?!\d))/g,","):l,c=r!==void 0?`${a}.${r}`:a;return e<0?`-${c}`:c}computeValues(){const e=this._d.getOptions().footer;if(!e||e.length===0)return[];const t=this._d.getData();return e.filter(s=>s.field&&s.op).map(s=>{const n=s.field,i=s.op,o=t.map(h=>h[n]).filter(h=>h!=null&&h!=="");let l=null;const r=i.toUpperCase();if(r==="SUM")l=o.length>0?x.sum(o.map(h=>String(h))):null;else if(r==="AVG")l=o.length>0?x.sum(o.map(h=>String(h))).div(x.from(String(o.length))):null;else if(r==="COUNT"){const h=o.length;return{_field:n,_value:h,_formatted:h.toLocaleString("ko-KR")}}else r==="MAX"?l=o.length>0?x.max(o.map(h=>String(h))):null:r==="MIN"&&(l=o.length>0?x.min(o.map(h=>String(h))):null);if(!l)return{_field:n,_value:null,_formatted:""};const a=l.toNumber(),c=this.fmtNum(a,s.format);return{_field:n,_value:a,_formatted:c}})}render(){var h;const e=this._d.getContainer(),t=e.querySelector(".og-footer-bar");t==null||t.remove();const s=this._d.getOptions(),n=s.footer;if(!n||n.length===0)return;const i=this._d.getColLayout().visibleLeaves,o=this._d.getColWidths()??i.map(u=>u.width??100),l=new Map(this.computeValues().map(u=>[u._field,u])),r=document.createElement("div");r.className="og-footer-bar",r.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 u=document.createElement("div");u.style.cssText=`width:${a}px;flex-shrink:0;border-right:1px solid var(--og-border-color,#e0e0e0);`,r.appendChild(u)}let c=0;for(const u of n){const g=Math.max(1,u.colspan??1);let E=0;for(let v=0;v<g;v++)E+=o[c+v]??100;const w=i[c];c+=g;const C=document.createElement("div");C.style.cssText=[`width:${E}px;min-width:${E}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 M=u.field,p=M?l.get(M):null;if(p){const v=p._formatted??String(p._value??""),_=u.label?`${u.label}: `:"";C.textContent=_+v,C.title=`${((h=u.op)==null?void 0:h.toUpperCase())??""} = ${v}`,C.style.color="var(--og-primary,#1976d2)",C.style.textAlign=u.align??((w==null?void 0:w.type)==="number","right")}else u.label&&(C.textContent=u.label,C.style.textAlign=u.align??"left",C.style.color="var(--og-row-color,#212121)");r.appendChild(C)}s.footerPosition==="top"?e.insertBefore(r,e.firstChild):e.appendChild(r)}}class It{constructor(e){this._d=e}handleKeyDown(e){const t=this._d.getEditMgr();if(t.activeEditor)return;this._d.handleCellKeyEvt("cellKeyDown",e);const s=this._d.getData(),n=this._d.getColLayout(),i=s.rowCount,o=n.visibleLeaves.length;if(i===0||o===0)return;if((e.ctrlKey||e.metaKey)&&e.key==="c"){e.preventDefault(),this._copyToClipboard();return}if((e.ctrlKey||e.metaKey)&&e.key==="v"){e.preventDefault(),this._pasteFromClipboard();return}const l=this._d.getOptions();if((e.ctrlKey||e.metaKey)&&l.draggable&&t.focusCell){if(e.key==="ArrowDown"){e.preventDefault();const r=t.focusCell.ci!==void 0?t.focusCell.ri:0;r<i-1&&(this._d.handleRowDrop(r,r+1),this._d.setFocusCell(r+1,t.focusCell.ci),this._d.announce(`행 ${r+1}을(를) ${r+2}번째 위치로 이동`));return}if(e.key==="ArrowUp"){e.preventDefault();const r=t.focusCell.ri;r>0&&(this._d.handleRowDrop(r,r-1),this._d.setFocusCell(r-1,t.focusCell.ci),this._d.announce(`행 ${r+1}을(를) ${r}번째 위치로 이동`));return}}switch(e.key){case"ArrowDown":{e.preventDefault();const r=t.focusCell,a=r?Math.min(r.ri+1,i-1):0;this._d.setFocusCell(a,(r==null?void 0:r.ci)??0);break}case"ArrowUp":{e.preventDefault();const r=t.focusCell,a=r?Math.max(r.ri-1,0):0;this._d.setFocusCell(a,(r==null?void 0:r.ci)??0);break}case"ArrowRight":{e.preventDefault();const r=t.focusCell;if(!r){this._d.setFocusCell(0,0);break}r.ci<o-1?this._d.setFocusCell(r.ri,r.ci+1):r.ri<i-1&&this._d.setFocusCell(r.ri+1,0);break}case"ArrowLeft":{e.preventDefault();const r=t.focusCell;if(!r){this._d.setFocusCell(0,0);break}r.ci>0?this._d.setFocusCell(r.ri,r.ci-1):r.ri>0&&this._d.setFocusCell(r.ri-1,o-1);break}case"Tab":{e.preventDefault();const r=t.focusCell;if(!r){this._d.setFocusCell(0,0);break}e.shiftKey?r.ci>0?this._d.setFocusCell(r.ri,r.ci-1):r.ri>0&&this._d.setFocusCell(r.ri-1,o-1):r.ci<o-1?this._d.setFocusCell(r.ri,r.ci+1):r.ri<i-1&&this._d.setFocusCell(r.ri+1,0);break}case"Home":{if(e.preventDefault(),e.ctrlKey||e.metaKey)this._d.setFocusCell(0,0);else{const r=t.focusCell;this._d.setFocusCell((r==null?void 0:r.ri)??0,0)}break}case"End":{if(e.preventDefault(),e.ctrlKey||e.metaKey)this._d.setFocusCell(i-1,o-1);else{const r=t.focusCell;this._d.setFocusCell((r==null?void 0:r.ri)??0,o-1)}break}case"PageDown":{e.preventDefault();const r=t.focusCell,a=this._d.getOptions().pageSize??10,c=Math.min(r?r.ri+a:a-1,i-1);this._d.setFocusCell(c,(r==null?void 0:r.ci)??0);break}case"PageUp":{e.preventDefault();const r=t.focusCell,a=this._d.getOptions().pageSize??10,c=r?Math.max(r.ri-a,0):0;this._d.setFocusCell(c,(r==null?void 0:r.ci)??0);break}case" ":{if(t.focusCell){e.preventDefault();const r=t.focusCell.ri,a=this._d.getRowMgr();this._d.getOptions().checkColumn?(a.check(r,!a.checkedRows.has(r)),this._d.doRender()):(a.selectToggle(r),this._d.doRender())}break}case"F2":case"Enter":{t.focusCell&&this._d.getOptions().editable&&(e.preventDefault(),t.startEditByKey(t.focusCell.ri,t.focusCell.ci));break}case"Escape":{t.clearFocusCell(),this._d.doRender();break}}}_copyToClipboard(){var o;if(!this._d.getOptions().clipboard)return;const t=this._d.getEditMgr(),s=this._d.getColLayout(),n=this._d.getData();let i="";if(t.focusCell){const{ri:l,ci:r}=t.focusCell,a=s.visibleLeaves[r];a&&(i=String(n.getCellValue(l,a.field)??""))}else if(this._d.getRowMgr().selectedRows.size>0){const l=s.visibleLeaves;i=[...this._d.getRowMgr().selectedRows].sort((a,c)=>a-c).map(a=>{const c=n.getRowByIndex(a);return l.map(h=>String((c==null?void 0:c[h.field])??"")).join(" ")}).join(`
88
- `)}i&&((o=navigator.clipboard)==null||o.writeText(i).catch(()=>{}))}_pasteFromClipboard(){var s;const e=this._d.getOptions();if(!e.clipboard||!e.editable)return;const t=this._d.getEditMgr();t.focusCell&&((s=navigator.clipboard)==null||s.readText().then(n=>{if(!n)return;const{ri:i,ci:o}=t.focusCell,l=n.split(`
89
- `),r=this._d.getColLayout().visibleLeaves,a=this._d.getData();for(let c=0;c<l.length;c++){const h=l[c].split(" ");for(let u=0;u<h.length;u++){const g=i+c,E=o+u,w=r[E];w&&g<a.rowCount&&a.updateCell(g,w.field,h[u])}}this._d.emit("dataChange",a.getData()),this._d.doRender()}).catch(()=>{}))}}class Ht{constructor(e){this._bar=null,this._input=null,this._count=null,this._filter="",this._d=e}get findFilter(){return this._filter}init(e){const t=document.createElement("div");t.className="og-find-bar",t.hidden=!0;const s=document.createElement("span");s.className="og-find-label",s.textContent="찾기";const n=document.createElement("input");n.type="text",n.className="og-find-input",n.placeholder="검색어 입력...",n.setAttribute("aria-label","그리드 내 검색");const i=document.createElement("span");i.className="og-find-count";const o=document.createElement("button");o.className="og-find-close",o.textContent="✕",o.setAttribute("aria-label","찾기 닫기"),t.appendChild(s),t.appendChild(n),t.appendChild(i),t.appendChild(o),e.insertBefore(t,e.firstChild),n.addEventListener("input",()=>{this._filter=n.value.trim(),this._apply()}),n.addEventListener("keydown",l=>{l.key==="Escape"&&this.close()}),o.addEventListener("click",()=>this.close()),this._bar=t,this._input=n,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 n,i;const e=this._d.getData(),t=this._d.getColLayout().visibleLeaves.map(o=>o.field);e.setFindFilter(this._filter,t),e.applyFilter(this._d.getFilters());const s=e.rowCount;(n=this._d.getVs())==null||n.setTotalRows(s),(i=this._d.getPagination())==null||i.setTotalRows(s),this._count&&(this._count.textContent=this._filter?`${s}건`:""),this._d.doRender()}}function Ne(d){return d&&d._isGroup===!0}function He(d,e,t=[],s=new Set,n){return e.length?Ke(d,e,0,t,s,"",n):[]}function Ke(d,e,t,s,n,i,o){const l=e[t],r=new Map;for(const c of d){const h=c[l];r.has(h)||r.set(h,[]),r.get(h).push(c)}const a=[];for(const[c,h]of r){const u=`${i}__${l}:${c}`,g=n.has(u);let E;t<e.length-1?E=Ke(h,e,t+1,s,n,u,o):E=h;const{summary:w,summaryFmt:C}=Bt(h,s),M=Wt(h,o);a.push({_isGroup:!0,_groupField:l,_groupValue:c,_groupLabel:c==null?"(없음)":String(c),_depth:t,_expanded:g,_childCount:h.length,_summary:w,_summaryFmt:C,_states:M,children:E})}return a}function Bt(d,e){const t={},s={};for(const n of e){const i=d.map(a=>a[n.field]).filter(a=>a!=null&&a!=="");let o=null;const l=n.op.toUpperCase();if(l==="SUM")o=i.length>0?x.sum(i.map(String)):null;else if(l==="AVG")o=i.length>0?x.sum(i.map(String)).div(x.from(String(i.length))):null;else if(l==="COUNT"){t[n.field]=d.length,s[n.field]=d.length.toLocaleString("ko-KR");continue}else l==="MAX"?o=i.length>0?x.max(i.map(String)):null:l==="MIN"&&(o=i.length>0?x.min(i.map(String)):null);if(!o){t[n.field]=null,s[n.field]="";continue}const r=o.toNumber();t[n.field]=r,s[n.field]=Nt(r,n.format)}return{summary:t,summaryFmt:s}}function Wt(d,e){if(!e)return{added:0,edited:0,removed:0};let t=0,s=0,n=0;for(const i of d){const o=e(i);o==="added"?t++:o==="edited"?s++:o==="removed"&&n++}return{added:t,edited:s,removed:n}}function Nt(d,e){if(e==null)return d%1===0?d.toLocaleString("ko-KR"):parseFloat(d.toFixed(6)).toLocaleString("ko-KR",{minimumFractionDigits:2,maximumFractionDigits:6});const t=e.includes("#")||e.includes(","),s=e.match(/\.(\d+)$/),n=s?parseInt(s[1],10):/^\d+$/.test(e)?parseInt(e,10):0,i=Math.abs(d).toFixed(n),[o="0",l]=i.split("."),r=t?o.replace(/\B(?=(\d{3})+(?!\d))/g,","):o,a=l!==void 0?`${r}.${l}`:r;return d<0?`-${a}`:a}function Oe(d){const e=[];for(const t of d)if(e.push(t),t._expanded)for(const s of t.children)Ne(s)?e.push(...Oe([s])):e.push(s);return e}function Ve(d,e=""){const t=[];for(const s of d){const n=`${e}__${s._groupField}:${s._groupValue}`;t.push(n);const i=s.children.filter(o=>Ne(o));i.length&&t.push(...Ve(i,n))}return t}function ve(d,e,t=new Set){const{idField:s,parentIdField:n,expandOnLoad:i=!1}=e,o=new Map,l=[];for(const c of d){const h=c[s],u={_isTree:!0,_treeId:h,_treeParentId:c[n],_depth:0,_expanded:i||t.has(h),_hasChildren:!1,_childCount:0,_isLastChild:!1,_ancestorHasMore:[],data:c,children:[]};o.set(h,u)}for(const c of o.values()){const h=c._treeParentId;if(h==null||h===""||!o.has(h))l.push(c);else{const g=o.get(h);g.children.push(c),g._hasChildren=!0}}function r(c,h){for(const u of c)u._depth=h,u._childCount=Pe(u),r(u.children,h+1)}r(l,0);function a(c,h){for(let u=0;u<c.length;u++){const g=c[u],E=u===c.length-1;g._isLastChild=E,g._ancestorHasMore=h,g.children.length>0&&a(g.children,[...h,!E])}}return a(l,[]),l}function Pe(d){let e=d.children.length;for(const t of d.children)e+=Pe(t);return e}function Ue(d){const e=[];for(const t of d)e.push(t),t._expanded&&t.children.length>0&&e.push(...Ue(t.children));return e}function Kt(d,e){d.has(e)?d.delete(e):d.add(e)}function xe(d){const e=[];for(const t of d)e.push(t._treeId),t.children.length&&e.push(...xe(t.children));return e}class Ot{constructor(e){this._groupFields=[],this._groupExpandedKeys=new Set,this._groupFlatRows=[],this._isGroupMode=!1,this._treeRoots=[],this._treeFlatRows=[],this._treeExpandedKeys=new Set,this._isTreeMode=!1,this._d=e}get isGroupMode(){return this._isGroupMode}get isTreeMode(){return this._isTreeMode}get groupFlatRows(){return this._groupFlatRows}get treeFlatRows(){return this._treeFlatRows}groupBy(e){this._groupFields=e,this._groupExpandedKeys.clear(),this._isGroupMode=e.length>0,this.rebuildGroups()}clearGroup(){var t;this._groupFields=[],this._groupExpandedKeys.clear(),this._isGroupMode=!1,this._groupFlatRows=[];const e=this._d.getData().length;(t=this._d.getVs())==null||t.setTotalRows(e),this._d.doRender()}expandAll(){if(!this._isGroupMode)return;const e=He(this._d.getData(),this._groupFields,this._getSummaryDefs());Ve(e).forEach(t=>this._groupExpandedKeys.add(t)),this.rebuildGroups()}collapseAll(){this._groupExpandedKeys.clear(),this._isGroupMode&&this.rebuildGroups()}handleGroupToggle(e){this._groupExpandedKeys.has(e)?this._groupExpandedKeys.delete(e):this._groupExpandedKeys.add(e),this.rebuildGroups()}rebuildGroups(){var i;const e=this._d.getData(),t=this._d.getDataLayer(),s=o=>{const l=e.indexOf(o);return l>=0?t.getRowState(l):"none"},n=He(e,this._groupFields,this._getSummaryDefs(),this._groupExpandedKeys,s);this._groupFlatRows=Oe(n),(i=this._d.getVs())==null||i.setTotalRows(this._groupFlatRows.length),this._d.doRenderFull(this._groupFlatRows.length)}enableTree(){this._isTreeMode=!0,this._isGroupMode=!1;const e=this._d.getOptions();if(e.expandOnLoad){const t=ve(this._d.getData(),{idField:e.treeId,parentIdField:e.treeParentId});xe(t).forEach(s=>this._treeExpandedKeys.add(s))}this.rebuildTree()}disableTree(){var t;this._isTreeMode=!1,this._treeRoots=[],this._treeFlatRows=[],this._treeExpandedKeys.clear();const e=this._d.getData().length;(t=this._d.getVs())==null||t.setTotalRows(e),this._d.doRender()}expandNodes(e,t=!0){const s=Array.isArray(e)?e:[e];for(const n of s)t?this._treeExpandedKeys.add(n):this._treeExpandedKeys.delete(n);this._isTreeMode&&this.rebuildTree()}expandAllNodes(){this._isTreeMode&&(xe(this._treeRoots).forEach(e=>this._treeExpandedKeys.add(e)),this.rebuildTree())}collapseAllNodes(){this._isTreeMode&&(this._treeExpandedKeys.clear(),this.rebuildTree())}handleTreeToggle(e){Kt(this._treeExpandedKeys,e),this.rebuildTree()}rebuildTree(){var t;const e=this._d.getOptions();this._treeRoots=ve(this._d.getData(),{idField:e.treeId,parentIdField:e.treeParentId,expandOnLoad:e.expandOnLoad},this._treeExpandedKeys),this._treeFlatRows=Ue(this._treeRoots),(t=this._d.getVs())==null||t.setTotalRows(this._treeFlatRows.length),this._d.doRenderFull(this._treeFlatRows.length)}_getSummaryDefs(){const e=this._d.getOptions().summary;if(!e)return[];if(e.rows&&e.rows.length>0)return e.fields.flatMap(s=>e.rows.map(n=>({field:s,op:n.op,format:n.format})));const t=Array.isArray(e.ops)?e.ops:e.ops?[e.ops]:["SUM"];return e.fields.map(s=>({field:s,op:t[0]??"SUM",format:e.format}))}}class Vt{constructor(e){this._sortList=[],this._filters={},this._d=e}get sortList(){return this._sortList}get filters(){return this._filters}handleSortClick(e,t){var l;const s=this._d.getOptions();if(!s.sortable)return;const n=this._sortList.findIndex(r=>r.field===e);if(n>=0){const r=this._sortList[n];r.dir==="asc"?r.dir="desc":this._sortList.splice(n,1)}else(!t||!s.multiSort)&&(this._sortList=[]),this._sortList.push({field:e,dir:"asc"});this._d.getData().applySort(this._sortList),this._d.renderHeader(),this._d.doRender();const i=this._sortList.find(r=>r.field===e),o=i?i.dir==="asc"?"오름차순":"내림차순":"정렬 해제";this._d.announce(`${e} ${o} 정렬`),this._d.emit("sortChange",{sortList:this._sortList}),(l=s.onSortChange)==null||l.call(s,{field:e,dir:(i==null?void 0:i.dir)??"asc",sortList:this._sortList})}sort(e,t="asc"){if(Array.isArray(e))this._sortList=e;else{const s=this._sortList.findIndex(n=>n.field===e);s>=0?this._sortList[s].dir=t:this._sortList=[{field:e,dir:t}],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(e){this._sortList=[...e],this._d.getData().applySort(this._sortList)}getSortState(){return[...this._sortList]}setFilter(e,t){var s,n;this._filters[e]=t,this.applyFilters(),this._d.renderHeader(),this._d.doRender(),this._d.emit("filterChange",{field:e,filterItems:t,allFilters:this._filters}),(n=(s=this._d.getOptions()).onFilterChange)==null||n.call(s,{field:e,filterItems:t,allFilters:this._filters})}resetFilter(e){e?delete this._filters[e]:this._filters={},this.applyFilters(),this._d.renderHeader(),this._d.doRender()}getFilterState(){return{...this._filters}}restoreFilter(e){this._filters={...e},this.applyFilters()}applyFilters(){var s,n;const e=this._d.getData();e.setFindFilter(this._d.getFindFilter(),this._d.getColLayout().visibleLeaves.map(i=>i.field)),e.applyFilter(this._filters);const t=e.rowCount;(s=this._d.getVs())==null||s.setTotalRows(t),(n=this._d.getPagination())==null||n.setTotalRows(t)}}class Pt{constructor(e){this._d=e}handleCellClick(e,t,s){var a,c,h,u,g,E,w;const n=this._d.getOptions(),i=this._d.getRowMgr(),o=this._d.getEditMgr();n.selection==="single"||n.selection==="row"?i.selectSingle(e):n.selection==="multiple"&&(s.ctrlKey||s.metaKey?i.selectToggle(e):i.selectSingle(e));const l=this._d.getData().getRowByIndex(e),r=this._d.getColLayout().visibleLeaves[t];if(l&&r){const C=r.editable!==!1&&(r.editable!==void 0||n.editable);if(Z(r)&&C){const F=l[r.field];this._d.writeCell(e,r.field,!F)}if(r.type==="radio"){const F=r.group;for(const A of this._d.getColLayout().visibleLeaves)A.type==="radio"&&A.field!==r.field&&(!F||A.group===F)&&this._d.getData().updateCell(e,A.field,!1);this._d.writeCell(e,r.field,!0)}const M={type:"cellClick",rowIndex:e,columnIndex:t,field:r.field,value:l[r.field],row:l,column:r,target:s.target,originalEvent:s};this._d.emit("cellClick",M),(a=n.onCellClick)==null||a.call(n,M);const p={type:"rowClick",rowIndex:e,row:l,target:s.target,originalEvent:s};this._d.emit("rowClick",p),(c=n.onRowClick)==null||c.call(n,p);const v=r.type==="select";!(o.activeEditor!=null&&((h=o.editCell)==null?void 0:h.ri)===e&&((u=o.editCell)==null?void 0:u.ci)===t)&&(n.editMode==="click"||v)&&!Z(r)&&o.startEdit(e,t,s)}o.activeEditor&&((g=o.editCell)==null?void 0:g.ri)===e&&((E=o.editCell)==null?void 0:E.ci)===t||(this._d.doRender(),this._d.emit("selectionChange",{rows:i.getSelections(),rowIndexes:[...i.selectedRows]}),(w=n.onSelectionChange)==null||w.call(n,{rows:i.getSelections(),rowIndexes:[...i.selectedRows],cells:[]}))}handleCellDblClick(e,t,s){var a,c;const n=this._d.getData().getRowByIndex(e),i=this._d.getColLayout().visibleLeaves[t];if(!n||!i)return;const o=this._d.getOptions(),l={type:"cellDblClick",rowIndex:e,columnIndex:t,field:i.field,value:n[i.field],row:n,column:i,target:s.target,originalEvent:s};this._d.emit("cellDblClick",l),(a=o.onCellDblClick)==null||a.call(o,l);const r={type:"rowDblClick",rowIndex:e,row:n,target:s.target,originalEvent:s};this._d.emit("rowDblClick",r),(c=o.onRowDblClick)==null||c.call(o,r),o.editMode==="dblclick"&&this._d.getEditMgr().startEdit(e,t,s)}handleCellMouseOver(e,t,s){var a,c;const n=this._d.getData().getRowByIndex(e),i=this._d.getColLayout().visibleLeaves[t];if(!n||!i)return;const o=this._d.getOptions(),l={type:"cellMouseOver",rowIndex:e,columnIndex:t,field:i.field,value:n[i.field],row:n,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseOver",l),(a=o.onCellMouseOver)==null||a.call(o,l);const r={type:"rowMouseOver",rowIndex:e,row:n,target:s.target,originalEvent:s};this._d.emit("rowMouseOver",r),(c=o.onRowMouseOver)==null||c.call(o,r)}handleCellMouseOut(e,t,s){var a,c;const n=this._d.getData().getRowByIndex(e),i=this._d.getColLayout().visibleLeaves[t];if(!n||!i)return;const o=this._d.getOptions(),l={type:"cellMouseOut",rowIndex:e,columnIndex:t,field:i.field,value:n[i.field],row:n,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseOut",l),(a=o.onCellMouseOut)==null||a.call(o,l);const r={type:"rowMouseOut",rowIndex:e,row:n,target:s.target,originalEvent:s};this._d.emit("rowMouseOut",r),(c=o.onRowMouseOut)==null||c.call(o,r)}handleCellMouseDown(e,t,s){var a,c;const n=this._d.getData().getRowByIndex(e),i=this._d.getColLayout().visibleLeaves[t];if(!n||!i)return;const o=this._d.getOptions(),l={type:"cellMouseDown",rowIndex:e,columnIndex:t,field:i.field,value:n[i.field],row:n,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseDown",l),(a=o.onCellMouseDown)==null||a.call(o,l);const r={type:"rowMouseDown",rowIndex:e,row:n,target:s.target,originalEvent:s};this._d.emit("rowMouseDown",r),(c=o.onRowMouseDown)==null||c.call(o,r)}handleCellMouseUp(e,t,s){var a,c;const n=this._d.getData().getRowByIndex(e),i=this._d.getColLayout().visibleLeaves[t];if(!n||!i)return;const o=this._d.getOptions(),l={type:"cellMouseUp",rowIndex:e,columnIndex:t,field:i.field,value:n[i.field],row:n,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseUp",l),(a=o.onCellMouseUp)==null||a.call(o,l);const r={type:"rowMouseUp",rowIndex:e,row:n,target:s.target,originalEvent:s};this._d.emit("rowMouseUp",r),(c=o.onRowMouseUp)==null||c.call(o,r)}handleCellMouseMove(e,t,s){var a,c;const n=this._d.getData().getRowByIndex(e),i=this._d.getColLayout().visibleLeaves[t];if(!n||!i)return;const o=this._d.getOptions(),l={type:"cellMouseMove",rowIndex:e,columnIndex:t,field:i.field,value:n[i.field],row:n,column:i,target:s.target,originalEvent:s};this._d.emit("cellMouseMove",l),(a=o.onCellMouseMove)==null||a.call(o,l);const r={type:"rowMouseMove",rowIndex:e,row:n,target:s.target,originalEvent:s};this._d.emit("rowMouseMove",r),(c=o.onRowMouseMove)==null||c.call(o,r)}handleCellKeyEvt(e,t){var c,h,u;const s=this._d.getEditMgr();if(!s.focusCell||s.activeEditor)return;const{ri:n,ci:i}=s.focusCell,o=this._d.getData().getRowByIndex(n),l=this._d.getColLayout().visibleLeaves[i];if(!o||!l)return;const r=this._d.getOptions(),a={type:e,rowIndex:n,columnIndex:i,field:l.field,value:o[l.field],row:o,column:l,key:t.key,target:this._d.getContainer(),originalEvent:t};this._d.emit(e,a),e==="cellKeyDown"?(c=r.onCellKeyDown)==null||c.call(r,a):e==="cellKeyUp"?(h=r.onCellKeyUp)==null||h.call(r,a):(u=r.onCellKeyPress)==null||u.call(r,a)}}class Ut{constructor(){this._triggers=new Map}add(e,t){this._triggers.has(e)||this._triggers.set(e,[]),this._triggers.get(e).push(t)}remove(e,t){const s=this._triggers.get(e);if(s){const n=s.indexOf(t);n>=0&&s.splice(n,1)}}clear(e){e?this._triggers.delete(e):this._triggers.clear()}mkCtx(e,t){let s=!1;return{operation:e,args:t,result:void 0,extra:{},timestamp:Date.now(),get cancelled(){return s},cancel(){s=!0}}}exec(e,t){const s=this._triggers.get(e)??[];for(const n of s)if(n(t),t.cancelled)return!1;if(e.startsWith("after:")){const n=this._triggers.get("complete")??[];for(const i of n)i(t)}return!0}}const jt="_ogRowId";class qt extends qe{constructor(e,t){var n;super(),this._vs=null,this._ro=null,this._renderer=null,this._trigMgr=new Ut,this._destroyed=!1,this._colWidths=[],this._filterPanel=null,this._filterSelect=null,this._pagination=null,this._dnd=null,this._mergeEngine=new Q,this._liveRegion=null,this._ctxMenu=null,this._cmHandler=null,this._cmKbdHandler=null,this._wsManager=null;const s=typeof e=="string"?document.querySelector(e):e;if(!s)throw new Error(`OpenGrid: container not found: ${e}`);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,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 데이터 그리드",...t},this._data=new Xe(jt),this._rowMgr=new kt(this._data),this._colLayout=new re(this._options.columns,this._options.frozenColumns),this._editMgr=new Et({data:this._data,colLayout:this._colLayout,getRenderer:()=>this._renderer,getContainer:()=>this._container,getOptions:()=>this._options,emit:(i,...o)=>this.emit(i,...o),doRender:()=>this._doRender(...this._visRange()),announce:i=>this._announce(i),writeCell:(i,o,l)=>this.writeCell(i,o,l),scrollToRow:i=>{var o;return(o=this._vs)==null?void 0:o.scrollToRow(i)},getVisibleLeaves:()=>this._colLayout.visibleLeaves}),this._exportMgr=new At({getData:()=>this._data.getData(),getColLayout:()=>this._colLayout,getColWidths:()=>this._colWidths,getOptions:()=>this._options,getContainer:()=>this._container,getMaskEnabled:i=>this.getMaskEnabled(i),getWsManager:()=>this._wsManager}),this._footerMgr=new zt({getData:()=>this._data.getData(),getColLayout:()=>this._colLayout,getColWidths:()=>this._colWidths,getOptions:()=>this._options,getContainer:()=>this._container}),this._kbdMgr=new It({getEditMgr:()=>this._editMgr,getRowMgr:()=>this._rowMgr,getData:()=>this._data,getColLayout:()=>this._colLayout,getOptions:()=>this._options,setFocusCell:(i,o)=>this._setFocusCell(i,o),handleRowDrop:(i,o)=>this._handleRowDrop(i,o),doRender:()=>this._doRender(...this._visRange()),announce:i=>this._announce(i),emit:(i,...o)=>this.emit(i,...o),visRange:()=>this._visRange(),handleCellKeyEvt:(i,o)=>this._handleCellKeyEvt(i,o)}),this._sfMgr=new Vt({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:i=>this._announce(i),emit:(i,...o)=>this.emit(i,...o)}),this._findMgr=new Ht({getColLayout:()=>this._colLayout,getData:()=>this._data,getFilters:()=>this._sfMgr.filters,getVs:()=>this._vs,getPagination:()=>this._pagination,doRender:()=>this._doRender(...this._visRange())}),this._cellEvt=new Pt({getData:()=>this._data,getColLayout:()=>this._colLayout,getOptions:()=>this._options,getEditMgr:()=>this._editMgr,getRowMgr:()=>this._rowMgr,emit:(i,...o)=>this.emit(i,...o),writeCell:(i,o,l)=>this.writeCell(i,o,l),doRender:()=>this._doRender(...this._visRange()),getContainer:()=>this._container}),this._grpMgr=new Ot({getData:()=>this._data.getData(),getDataLayer:()=>this._data,getOptions:()=>this._options,getVs:()=>this._vs,doRenderFull:i=>this._doRender(0,i-1),doRender:()=>this._doRender(...this._visRange())}),this._mount(),this._bindOptionEvents(),(n=this._options.defaultSort)!=null&&n.length&&this._sfMgr.initSort(this._options.defaultSort),requestAnimationFrame(()=>{var i,o;this.emit("ready",this),(o=(i=this._options).onReady)==null||o.call(i,this)})}_mount(){var s,n;this._container.classList.add("og-container");const e=this._options.height,t=this._options.width;this._container.style.height=typeof e=="number"?`${e}px`:String(e),this._container.style.width=typeof t=="number"?`${t}px`:String(t),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,o]of Object.entries(this._options.cssVars))this._container.style.setProperty(i,o);this._renderer=new Mt(this._container,this._options,{onHeaderClick:(i,o)=>this._handleSortClick(i,o),onCellClick:(i,o,l)=>this._handleCellClick(i,o,l),onCellDblClick:(i,o,l)=>this._handleCellDblClick(i,o,l),onCellMouseOver:(i,o,l)=>this._handleCellMouseOver(i,o,l),onCellMouseOut:(i,o,l)=>this._handleCellMouseOut(i,o,l),onCellMouseDown:(i,o,l)=>this._handleCellMouseDown(i,o,l),onCellMouseUp:(i,o,l)=>this._handleCellMouseUp(i,o,l),onCellMouseMove:(i,o,l)=>this._handleCellMouseMove(i,o,l),onRowCheck:(i,o)=>this._handleRowCheck(i,o),onAllCheck:i=>this._handleAllCheck(i),onColResize:(i,o)=>this._handleColResize(i,o),onFilterIconClick:(i,o)=>this._handleFilterIconClick(i,o),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}),this._filterPanel=new Je(this._container,(i,o)=>this.setFilter(i,o),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 Qe(this._renderer.bodyWrapper,{rowHeight:this._options.rowHeight,onRender:(i,o)=>this._doRender(i,o)}),this._options.draggable&&(this._dnd=new Tt(this._renderer.bodyWrapper,this._options.rowHeight,(i,o)=>this._handleRowDrop(i,o))),this._options.pagination&&(this._pagination=new Lt(this._container,this._options.pageSize,i=>{this.emit("pageChange",i),this._doRender(...this._visRange())})),this._findMgr.init(this._container),this._initContextMenu(),(n=this._options.worksheets)!=null&&n.length&&this._initWorksheets(),this._ro=new ResizeObserver(()=>this._onResize()),this._ro.observe(this._container),this._onResize()}_initContextMenu(){const e=this._options.contextMenu;e!==!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 $t(this._container,{onSortAsc:()=>{const t=this._colLayout.visibleLeaves[0];t&&this.orderBy(t.field,"asc")},onSortDesc:()=>{const t=this._colLayout.visibleLeaves[0];t&&this.orderBy(t.field,"desc")},onFind:()=>this._findMgr.open(),onExcel:()=>this.exportExcel(),onCsv:()=>this.exportCsv(),onPrint:()=>this.print()}),this._cmHandler=t=>{var l;const s=t.target.closest(".og-cell");if(!s)return;t.preventDefault();const n=Number(s.dataset.colIndex??-1),i=this._colLayout.visibleLeaves[n];i&&this._ctxMenu&&(this._ctxMenu._actions.onSortAsc=()=>this.orderBy(i.field,"asc"),this._ctxMenu._actions.onSortDesc=()=>this.orderBy(i.field,"desc"));const o=Array.isArray(e)?e:void 0;(l=this._ctxMenu)==null||l.open(t,o)},this._container.addEventListener("contextmenu",this._cmHandler),this._cmKbdHandler=t=>{var s;if(t.shiftKey&&t.key==="F10"){t.preventDefault();const n=this._container.getBoundingClientRect(),i={clientX:n.left+80,clientY:n.top+40};(s=this._ctxMenu)==null||s.open(i)}},this._container.addEventListener("keydown",this._cmKbdHandler))}openContextMenu(e,t){var s;(s=this._ctxMenu)==null||s.open(e,t)}closeContextMenu(){var e;(e=this._ctxMenu)==null||e.close()}setFilterSelect(e){var t;(t=this._filterSelect)==null||t.destroy(),this._filterSelect=null,e&&(this._container.id||(this._container.id=`og-${Math.random().toString(36).slice(2,7)}`),this._filterSelect=new St(this._container,e,(s,n)=>this.setFilter(s,n),s=>this.resetFilter(s),this._container.id))}setOptions(e){var t;if(Object.assign(this._options,e),"contextMenu"in e&&((t=this._ctxMenu)==null||t.destroy(),this._ctxMenu=null,this._initContextMenu()),"groupBy"in e||"summary"in e){const s=e.groupBy??[];s.length>0?this._grpMgr.groupBy(s):this.clearGroup();return}this._renderHeader(),this._doRender(...this._visRange())}setMaskEnabled(e,t){var n;const s=this._colLayout.getColumnByField(e);s&&(t?(s._maskRevealed=!1,(n=s._maskRevealedRows)==null||n.clear()):s._maskRevealed=!0,this._doRender(...this._visRange()))}getMaskEnabled(e){const t=this._colLayout.getColumnByField(e);return t?t._maskRevealed!==!0:!1}_initWorksheets(){const e=this._options.worksheets;this._wsManager=new Ie(this._container,(t,s)=>{this._data.setData(s.data),this._colLayout=new re(s.columns.length?s.columns:this._options.columns,this._options.frozenColumns),this._doRender(...this._visRange()),this._renderHeader()});for(const t of e)this._wsManager.add(t.name,t.columns??this._options.columns,t.data??[])}addWorksheet(e,t,s){this._wsManager||(this._wsManager=new Ie(this._container,(n,i)=>{this._data.setData(i.data),this._colLayout=new re(i.columns.length?i.columns:this._options.columns,this._options.frozenColumns),this._doRender(...this._visRange()),this._renderHeader()})),this._wsManager.add(e,t??this._options.columns,s??[])}removeWorksheet(e){var t;(t=this._wsManager)==null||t.remove(e)}switchWorksheet(e){var t;(t=this._wsManager)==null||t.switch(e)}renameWorksheet(e,t){var s;(s=this._wsManager)==null||s.rename(e,t)}getWorksheet(e){var t;return(t=this._wsManager)==null?void 0:t.get(e)}getWorksheetNames(){var e;return((e=this._wsManager)==null?void 0:e.getNames())??[]}exportSheetsExcel(e){this._exportMgr.exportSheetsExcel(e)}_paginationHeight(){return this._options.pagination?38:0}_onResize(){const{width:e,height:t}=this._container.getBoundingClientRect();if(!e)return;const s=t-this._options.headerHeight-this._paginationHeight();this._renderer.updateSize(t-this._paginationHeight(),this._options.headerHeight),this._vs.setViewportHeight(s),this._recalcWidths(e),this._renderHeader(),this._doRender(...this._visRange())}_recalcWidths(e){this._colWidths=this._colLayout.computeWidths(e-(this._options.stateColumn?24:0)-(this._options.draggable?18:0)-(this._options.rowNumber?44:0)-(this._options.checkColumn?36:0),this._options.defaultColumnWidth)}_renderHeader(){var e;(e=this._renderer)==null||e.renderHeader(this._colLayout.buildHeaderCells(),this._colLayout.visibleLeaves,this._colWidths,this._sfMgr.sortList,{...this._options,_activeFilters:this._sfMgr.filters,_frozenCount:this._colLayout.frozenCount})}_doRender(e,t){var n;if(!this._renderer||!this._vs)return;const s=this._vs.getVisibleRange();this._renderer.renderBody(e,t,this._data,this._colLayout.visibleLeaves,this._colWidths,this._options,s.offsetY,this._vs.getTotalHeight(),this._rowMgr.selectedRows,this._rowMgr.checkedRows,this._grpMgr.isGroupMode?this._grpMgr.groupFlatRows:this._grpMgr.isTreeMode?this._grpMgr.treeFlatRows:null,i=>this._grpMgr.handleGroupToggle(i),this._grpMgr.isTreeMode?i=>this._grpMgr.handleTreeToggle(i):void 0,{_totalRows:this._data.rowCount,_frozenCount:this._colLayout.frozenCount,_focusCell:this._editMgr.focusCell},this._mergeEngine),(n=this._options.footer)!=null&&n.length&&this._renderFooterEl()}_handleGroupToggle(e){this._grpMgr.handleGroupToggle(e)}_visRange(){var t;if(this._options.pagination&&this._pagination){const{start:s,end:n}=this._pagination.getRange();return[s,n]}const e=(t=this._vs)==null?void 0:t.getVisibleRange();return[(e==null?void 0:e.startIndex)??0,Math.min(((e==null?void 0:e.endIndex)??30)+this._visCount()+5,this._data.rowCount-1)]}_visCount(){const e=this._container.getBoundingClientRect().height;return Math.ceil((e-this._options.headerHeight-this._paginationHeight())/this._options.rowHeight)+5}_handleSortClick(e,t){this._sfMgr.handleSortClick(e,t)}_isToggleCol(e){return Z(e)}_handleCellClick(e,t,s){this._cellEvt.handleCellClick(e,t,s)}_handleCellDblClick(e,t,s){this._cellEvt.handleCellDblClick(e,t,s)}_handleCellMouseOver(e,t,s){this._cellEvt.handleCellMouseOver(e,t,s)}_handleCellMouseOut(e,t,s){this._cellEvt.handleCellMouseOut(e,t,s)}_handleCellMouseDown(e,t,s){this._cellEvt.handleCellMouseDown(e,t,s)}_handleCellMouseUp(e,t,s){this._cellEvt.handleCellMouseUp(e,t,s)}_handleCellMouseMove(e,t,s){this._cellEvt.handleCellMouseMove(e,t,s)}_handleCellKeyEvt(e,t){this._cellEvt.handleCellKeyEvt(e,t)}_handleRowCheck(e,t){this._rowMgr.check(e,t),this._doRender(...this._visRange()),this.emit("rowCheck",{rowIndex:e,checked:t,row:this._data.getRowByIndex(e)})}_handleFilterIconClick(e,t){var n,i;if((n=this._filterPanel)!=null&&n.isOpen){this._filterPanel.close();return}const s=this._sfMgr.filters[e]??[];(i=this._filterPanel)==null||i.open(e,t,s)}_handleAllCheck(e){this._rowMgr.checkAll(e,this._data.rowCount),this._doRender(...this._visRange()),this.emit("allCheck",{checked:e})}_handleRowDrop(e,t){var s,n;this._data.moveRow(e,t),this._doRender(...this._visRange()),this.emit("rowDrop",{fromIndex:e,toIndex:t}),(n=(s=this._options).onRowDrop)==null||n.call(s,{fromIndex:e,toIndex:t})}reorderRow(e,t){this._data.moveRow(e,t),this._doRender(...this._visRange())}_handleColResize(e,t){this._colWidths[e]!==void 0&&(this._colWidths[e]=t),this._doRender(...this._visRange())}_handleKeyDown(e){this._kbdMgr.handleKeyDown(e)}_setFocusCell(e,t){this._rowMgr.selectSingle(e),this._editMgr.setFocusCell(e,t)}_announce(e){this._liveRegion&&(this._liveRegion.textContent="",setTimeout(()=>{this._liveRegion&&(this._liveRegion.textContent=e)},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(e){var s;const t=this._trigMgr.mkCtx("setData",[e]);this._trigMgr.exec("before:setData",t)&&(this._rowMgr.reset(),this._data.setData(e),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()),t.result=e.length,this._trigMgr.exec("after:setData",t))}getData(){return this._data.getData()}getSourceRows(){return this._data.getOriginalData()}pushData(e){var n,i;const t=[...this._data.getAllData(),...e];this._data.setData(t);const s=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s)}prefixData(e){var n,i;const t=[...e,...this._data.getAllData()];this._data.setData(t);const s=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s)}clearData(){var e,t;this._rowMgr.reset(),this._data.clearData(),(e=this._vs)==null||e.setTotalRows(0),(t=this._pagination)==null||t.setTotalRows(0),this._doRender(0,-1),this.emit("dataChange",[])}insertRow(e,t="last"){var o,l,r,a;const s=this._trigMgr.mkCtx("insertRow",[e,t]);if(!this._trigMgr.exec("before:insertRow",s))return;const n=t==="before"?0:t==="after"?this._data.rowCount:t;this._data.addRow(e,n);const i=this._data.rowCount;(o=this._vs)==null||o.setTotalRows(i),(l=this._pagination)==null||l.setTotalRows(i),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(a=(r=this._options).onDataChange)==null||a.call(r,this._data.getData()),s.result={rowCount:i,item:e},this._trigMgr.exec("after:insertRow",s)}pushRow(e){var n,i,o,l;(Array.isArray(e)?e:[e]).forEach(r=>this._data.addRow(r,"last"));const s=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(l=(o=this._options).onDataChange)==null||l.call(o,this._data.getData())}appendRows(e){this.pushRow(e)}unshiftRow(e){var n,i,o,l;(Array.isArray(e)?e:[e]).forEach(r=>this._data.addRow(r,"first"));const s=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(s),(i=this._pagination)==null||i.setTotalRows(s),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(l=(o=this._options).onDataChange)==null||l.call(o,this._data.getData())}prependRows(e){this.unshiftRow(e)}deleteRow(e){var o,l,r,a;const t=this._trigMgr.mkCtx("deleteRow",[e]),s=Array.isArray(e)?[...e]:[e];if(t.extra={rows:s.map(c=>this._data.getRowByIndex(c))},!this._trigMgr.exec("before:deleteRow",t))return;const n=s.sort((c,h)=>h-c);n.forEach(c=>this._data.removeRow(c));const i=this._data.rowCount;(o=this._vs)==null||o.setTotalRows(i),(l=this._pagination)==null||l.setTotalRows(i),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(a=(r=this._options).onDataChange)==null||a.call(r,this._data.getData()),t.result={deleted:n.length,rowCount:i},this._trigMgr.exec("after:deleteRow",t)}deleteById(e){}readCell(e,t){return this._data.getCellValue(e,t)}getDisplayValue(e,t){const s=this.readCell(e,t);return s==null?"":String(s)}writeCell(e,t,s){var c,h,u,g;const n=this.readCell(e,t),i=this._trigMgr.mkCtx("writeCell",[e,t,s]);if(i.extra={oldValue:n,rowIndex:e,field:t},!this._trigMgr.exec("before:writeCell",i))return;this._data.updateCell(e,t,s);const o=this._data.getRowByIndex(e),l=this._colLayout.getColumnByField(t),r=this._colLayout.getColumnIndex(t),a={type:"editEnd",rowIndex:e,columnIndex:r,field:t,oldValue:n,newValue:s,row:o,column:l};this.emit("editEnd",a),(h=(c=this._options).onEditEnd)==null||h.call(c,a),this.emit("dataChange",this._data.getData()),(g=(u=this._options).onDataChange)==null||g.call(u,this._data.getData()),this._doRender(...this._visRange()),i.result={rowIndex:e,field:t,oldValue:n,newValue:s},this._trigMgr.exec("after:writeCell",i)}getRowAt(e){return this._data.getRowByIndex(e)}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(e){return this._data.getOriginalRow(e)}getRowsWithState(e){return this._data.getRowsWithState(e)}undo(){}redo(){}clearHistory(){}getColumnDefs(){return this._colLayout.visibleLeaves}getAllColumnDefs(){return this._colLayout.leaves}getColumnCount(){return this._colLayout.visibleLeaves.length}applyColumns(e){const t=this._trigMgr.mkCtx("applyColumns",[e]);this._trigMgr.exec("before:applyColumns",t)&&(this._colLayout.setColumns(e),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange()),t.result={columnCount:e.length},this._trigMgr.exec("after:applyColumns",t))}insertColumn(e,t){this._colLayout.addColumn(e,t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}deleteColumn(e){this._colLayout.removeColumn(e),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}_reorderColumn(e,t){var o,l;const s=this._colLayout.visibleLeaves.map(r=>r);if(e<0||t<0||e>=s.length||t>=s.length)return;const n=[...this._options.columns],[i]=n.splice(e,1);n.splice(t,0,i),this._options.columns=n,this.applyColumns(n),(l=(o=this._options).onColumnReorder)==null||l.call(o,{fromIndex:e,toIndex:t,field:i.field??""})}hideColumn(e){this._colLayout.hideColumn(e),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}showColumn(e){this._colLayout.showColumn(e),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}getColumnIndex(e){return this._colLayout.getColumnIndex(e)}getFieldAt(e){var t;return((t=this._colLayout.getColumnByIndex(e))==null?void 0:t.field)??""}getColValues(e,t=!1){return this._data.getData().map(s=>s[e])}getUniqueValues(e,t=!1){return[...new Set(this.getColValues(e,t))]}setColWidths(e){}calcColWidths(e=!1){return[]}getSelections(){return this._rowMgr.getSelections()}getActiveRow(){return this._rowMgr.getActiveRow()}activate(e){this._rowMgr.activate(e),this._doRender(...this._visRange())}deselect(){this._rowMgr.deselect(),this._doRender(...this._visRange())}getChecked(){return this._rowMgr.getChecked()}getAllChecked(){return this._rowMgr.getAllChecked()}checkById(e){}addCheckById(e){}checkByValue(e,t){this._rowMgr.checkByValue(e,t),this._doRender(...this._visRange())}uncheckById(e){}uncheckAll(){this._rowMgr.uncheckAll(),this._doRender(...this._visRange())}orderBy(e,t="asc"){const s=this._trigMgr.mkCtx("orderBy",[e,t]);this._trigMgr.exec("before:orderBy",s)&&(this._sfMgr.sort(e,t),s.result={sortList:this._sfMgr.sortList},this._trigMgr.exec("after:orderBy",s))}resetOrder(){this._sfMgr.resetSort()}setFilter(e,t){const s=this._trigMgr.mkCtx("setFilter",[e,t]);this._trigMgr.exec("before:setFilter",s)&&(this._sfMgr.setFilter(e,t),s.result={field:e,filteredCount:this._data.rowCount},this._trigMgr.exec("after:setFilter",s))}resetFilter(e){this._sfMgr.resetFilter(e)}getFilterState(){return this._sfMgr.getFilterState()}restoreFilter(e){this._sfMgr.restoreFilter(e)}_applyFilters(){this._sfMgr.applyFilters()}freeze(e){this._colLayout.setFrozen(e),this._renderHeader(),this._doRender(...this._visRange())}mergeCells(e){this._mergeEngine.applyMergeCells(e),this._doRender(...this._visRange())}autoMerge(e){const t=this._colLayout.visibleLeaves,s=[],n=[];for(const i of e){const o=t.findIndex(l=>l.field===i);o>=0&&(s.push(o),n.push(i))}this._mergeEngine.applyAutoMerge(this._data.getData(),s,n),this._doRender(...this._visRange())}clearMerge(){this._mergeEngine.clear(),this._doRender(...this._visRange())}freezeRows(e){}groupBy(e){const t=this._trigMgr.mkCtx("groupBy",[e]);this._trigMgr.exec("before:groupBy",t)&&(this._grpMgr.groupBy(e),t.result={fields:e},this._trigMgr.exec("after:groupBy",t))}clearGroup(){this._grpMgr.clearGroup()}expandAll(){this._grpMgr.expandAll()}collapseAll(){this._grpMgr.collapseAll()}enableTree(){this._grpMgr.enableTree()}disableTree(){this._grpMgr.disableTree()}expandNodes(e,t=!0){this._grpMgr.expandNodes(e,t)}expandAllNodes(){this._grpMgr.expandAllNodes()}collapseAllNodes(){this._grpMgr.collapseAllNodes()}addTreeRow(e,t,s){}exportExcel(e){this._exportMgr.exportExcel(e)}exportCsv(e){this._exportMgr.exportCsv(e)}exportJson(e){this._exportMgr.exportJson(e)}print(e){this._exportMgr.print(e)}toArray(e=!0){const t=this._data.getData();if(e)return t;const s=this._colLayout.visibleLeaves;return t.map(n=>s.map(i=>n[i.field]))}jumpToRow(e){var t;this._rowMgr.selectSingle(e),(t=this._vs)==null||t.scrollToRow(e),this._doRender(...this._visRange())}jumpToCol(e){}getScrollPos(){var e,t;return{x:((e=this._renderer)==null?void 0:e.bodyWrapper.scrollLeft)??0,y:((t=this._renderer)==null?void 0:t.bodyWrapper.scrollTop)??0}}setFooter(e){this._options.footer=e,this._renderFooterEl()}getFooterData(){return this._footerMgr.computeValues()}getFooterValue(e){var t;return((t=this._footerMgr.computeValues().find(s=>s._field===e))==null?void 0:t._value)??null}_renderFooterEl(){this._footerMgr.render()}resize(e,t){e&&(this._container.style.width=`${e}px`),t&&(this._container.style.height=`${t}px`),this._onResize()}setTheme(e){this._container.setAttribute("data-og-theme",e)}setThemeVar(e,t){this._container.style.setProperty(e,t)}addTrigger(e,t){return this._trigMgr.add(e,t),this}removeTrigger(e,t){return this._trigMgr.remove(e,t),this}clearTriggers(e){return this._trigMgr.clear(e),this}_mkCtx(e,t){return this._trigMgr.mkCtx(e,t)}_trig(e,t){return this._trigMgr.exec(e,t)}destroy(){var e,t,s,n,i,o,l,r;this._destroyed||(this._destroyed=!0,this._trigMgr.clear(),(e=this._ro)==null||e.disconnect(),(t=this._vs)==null||t.destroy(),(s=this._filterPanel)==null||s.destroy(),(n=this._dnd)==null||n.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(),(o=this._wsManager)==null||o.destroy(),(l=this._renderer)==null||l.destroy(),(r=this._liveRegion)==null||r.remove(),this._liveRegion=null,this._container.innerHTML="",this._container.classList.remove("og-container"),this.removeAllListeners())}}exports.OpenGrid=qt;exports.buildTree=ve;
90
- //# sourceMappingURL=OpenGrid-CAodJLLm.cjs.map