forked from myliang/xspreadsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxspreadsheet.js
2 lines (2 loc) · 62.4 KB
/
xspreadsheet.js
1
2
!function(e){var t={};function s(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}s.m=e,s.c=t,s.d=function(e,t,i){s.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},s.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=30)}([function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(1);class r{constructor(e="div"){this.tag=e,this._data={},this._clickOutside=null,this.el=document.createElement(e)}data(e,t){return void 0!==t&&(this._data[e]=t),this._data[e]}on(e,t){const[s,...i]=e.split(".");return this.el.addEventListener(s,e=>{for(let t of i){if(console.log("::::::::::",t),"left"===t&&0!==e.button)return;if("right"===t&&2!==e.button)return;"stop"===t&&e.stopPropagation()}t(e)}),this}onClickOutside(e){return this._clickOutside=e,this}class(e){return this.el.className=e,this}attrs(e={}){for(let t of Object.keys(e))this.attr(t,e[t]);return this}attr(e,t){return void 0===t?this.el.getAttribute(e):(this.el.setAttribute(e,t),this)}removeAttr(e){return this.el.removeAttribute(e),this}offset(){const{offsetTop:e,offsetLeft:t,offsetHeight:s,offsetWidth:i}=this.el;return{top:e,left:t,height:s,width:i}}clearStyle(){return this.el.style="",this}styles(e={},t=!1){t&&this.clearStyle();for(let t of Object.keys(e))this.style(t,e[t]);return this}style(e,t){return void 0===t?this.el.style.getPropertyValue(e):(this.el.style.setProperty(e,t),this)}contains(e){return this.el.contains(e)}removeStyle(e){this.el.style.removeProperty(e)}children(e){for(let t of e)this.child(t);return this}child(e){return"string"==typeof e?this.el.appendChild(document.createTextNode(e)):e instanceof r?this.el.appendChild(e.el):e instanceof HTMLElement&&this.el.appendChild(e),this}html(e){return void 0===e?this.el.innerHTML:(this.el.innerHTML=e,this)}val(e){return void 0===e?this.el.value:(this.el.value=e,this)}clone(){return this.el.cloneNode()}isHide(){return"none"===this.style("display")}toggle(){this.isHide()?this.show():this.hide()}disabled(){return this.addClass("disabled"),this}able(){return this.removeClass("disabled"),this}active(e=!0){return e?this.addClass("active"):this.deactive(),this}deactive(){return this.removeClass("active")}isActive(){return this.hasClass("active")}addClass(e){return this.el.className=this.el.className.split(" ").concat(e).join(" "),this}removeClass(e){return this.el.className=this.el.className.split(" ").filter(t=>t!==e).join(" "),this}hasClass(e){return-1!==this.el.className.indexOf(e)}show(e=!1){return e?this.removeStyle("display"):this.style("display","block"),this._clickOutside&&(this.data("_outsidehandler",e=>{if(this.contains(e.target))return!1;this.hide(),i.unbind("click",this.data("_outsidehandler")),this._clickOutside&&this._clickOutside()}),setTimeout(()=>{i.bind("click",this.data("_outsidehandler"))},0)),this}hide(){return this.style("display","none"),this._clickOutside&&i.unbind("click",this.data("_outsidehandler")),this}}t.Element=r,t.h=function(e="div"){return new r(e)}},function(e,t,s){"use strict";function i(e,t,s=window){s.addEventListener(e,t)}function r(e,t,s=window){s.removeEventListener(e,t)}Object.defineProperty(t,"__esModule",{value:!0}),t.bind=i,t.unbind=r,t.mouseMoveUp=function(e,t){i("mousemove",e);const s=i=>{r("mousemove",e),r("mouseup",s),t(i)};i("mouseup",s)}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0);class r extends i.Element{constructor(e="vertical"){super(),this.class(`spreadsheet-menu ${e}`)}}t.Menu=r,t.buildMenu=function(e="vertical"){return new r(e)}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0);class r extends i.Element{constructor(e){super(),this.class("spreadsheet-icon").child(this.img=i.h().class(`spreadsheet-icon-img ${e}`))}replace(e){this.img.class(`spreadsheet-icon-img ${e}`)}}t.Icon=r,t.buildIcon=function(e){return new r(e)}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(3);class n extends i.Element{constructor(){super(),this.iconEl=null,this.class("spreadsheet-item")}static build(){return new n}icon(e){return this.child(this.iconEl=r.buildIcon(e)),this}replaceIcon(e){this.iconEl&&this.iconEl.replace(e)}}t.Item=n,t.buildItem=function(){return new n}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultCell={font:"Microsoft YaHei",format:"normal",fontSize:14,bold:!1,italic:!1,underline:!1,color:"#333",backgroundColor:"#fff",align:"left",valign:"middle",wordWrap:!1,invisible:!1,rowspan:1,colspan:1,text:""},t.getStyleFromCell=function(e){const t={};return e&&(e.font&&(t["font-family"]=e.font),e.fontSize&&(t["font-size"]=`${e.fontSize}px`),e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.underline&&(t["text-decoration"]="underline"),e.color&&(t.color=e.color),e.backgroundColor&&(t["background-color"]=e.backgroundColor),e.align&&(t["text-align"]=e.align),e.valign&&(t["vertical-align"]=e.valign),e.invisible&&(t.display="none"),e.wordWrap&&(t["word-wrap"]="break-word",t["white-space"]="normal")),t}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];t.alphabet=function(e){const[t,s]=[parseInt(e/i.length+""),e%i.length];return t>0?`${i[t-1]}${i[s]}`:i[s]},t.alphabetIndex=function(e){let t=0;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s)-65;t+=s*i.length+r}return t}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(6);t.formulaFilterKey=((e,s)=>{if("="===e[0]){const i=e.substring(1,e.indexOf("("));for(let r of t.formulas)if(r.key.toLowerCase()===i.toLowerCase())return s(r,e.substring(e.indexOf("(")+1,e.indexOf(")")))}return e}),t.formulaRender=((e,s)=>t.formulaFilterKey(e,(e,t)=>e.render(r(t,s))+"")),t.formulaReplaceParam=((e,s,r)=>t.formulaFilterKey(e,(e,t)=>{const n=e=>{const t=/\d+/.exec(e);if(t){let n=e.substring(0,t.index),l=parseInt(e.substring(t.index));return`${i.alphabet(i.alphabetIndex(n)+r)}${l+s}`}return e};return t=-1!==t.indexOf(":")?t.split(":").map(n).join(":"):t.split(",").map(n).join(","),`=${e.key}(${t})`}));const r=(e,t)=>{let s=[];try{if(-1!==e.indexOf(":")){const[r,n]=e.split(":"),l=/\d+/.exec(r),o=/\d+/.exec(n);if(l&&o){let e=r.substring(0,l.index),h=parseInt(r.substring(l.index)),a=n.substring(0,o.index),d=parseInt(n.substring(o.index));if(a===e)for(let r=h;r<=d;r++)s.push(t(r-1,i.alphabetIndex(e)));else for(let r=i.alphabetIndex(e);r<=i.alphabetIndex(a);r++)s.push(t(h-1,r))}}else-1!==e.indexOf(",")&&(s=e.split(",").map(e=>{const s=/\d+/.exec(e);if(s){const r=e.substring(0,s.index),n=e.substring(s.index);return t(parseInt(n)-1,i.alphabetIndex(r))}}))}catch(e){console.log("warning:",e)}return s};t.formulas=[{key:"SUM",title:"求和",render:e=>e.reduce((e,t)=>Number(e)+Number(t),0)},{key:"AVERAGE",title:"平均值",render:e=>e.reduce((e,t)=>Number(e)+Number(t),0)/e.length},{key:"MAX",title:"最大值",render:e=>Math.max(...e.map(e=>Number(e)))},{key:"MIN",title:"最小值",render:e=>Math.min(...e.map(e=>Number(e)))}]},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatRenderHtml=((e,s)=>{for(let i=0;i<t.formats.length;i++)if(t.formats[i].key===e)return t.formats[i].render(s||"");return s||""});const i=e=>{if(/^(-?\d*.?\d*)$/.test(e)){const t=(e=Number(e).toFixed(2).toString()).split(".");return t[0]=t[0].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),t.join(".")}return e},r=e=>e;t.formats=[{key:"normal",title:"Normal",render:r},{key:"text",title:"Text",render:r},{key:"number",title:"Number",label:"1,000.12",render:i},{key:"percent",title:"Percent",label:"10.12%",render:e=>`${i(e)}%`},{key:"RMB",title:"RMB",label:"¥10.00",render:e=>`¥${i(e)}`},{key:"USD",title:"USD",label:"$10.00",render:e=>`$${i(e)}`}]},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0);t.Editorbar=class{constructor(){this.value=null,this.change=(e=>{}),this.el=i.h().class("spreadsheet-editor-bar").children([i.h().class("spreadsheet-formula-bar").children([this.label=i.h().class("spreadsheet-formula-label"),this.textarea=i.h("textarea").on("input",e=>this.input(e))])])}set(e,t){this.label.html(e),this.setValue(t)}setValue(e){this.value=e,this.textarea.val(e&&e.text||"")}input(e){const t=e.target.value;/^\s*$/.test(t)||(this.value?this.value.text=t:this.value={text:t},this.change(this.value))}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=[["rgb(192, 0, 0)","rgb(255, 0, 0)","rgb(255, 192, 3)","rgb(255, 255, 0)","rgb(145, 208, 81)","rgb(0, 175, 80)","rgb(0, 176, 240)","rgb(0, 112, 192)","rgb(0, 32, 96)","rgb(112, 48, 159)"],["rgb(255, 255, 255)","rgb(0, 0, 0)","rgb(231, 230, 230)","rgb(68, 84, 106)","rgb(68, 114, 196)","rgb(237, 125, 49)","rgb(165, 165, 165)","rgb(255, 192, 3)","rgb(91, 155, 213)","rgb(112, 173, 71)"],["rgb(244, 245, 248)","rgb(132, 132, 132)","rgb(208, 206, 206)","rgb(214, 220, 228)","rgb(217, 226, 242)","rgb(250, 229, 213)","rgb(237, 237, 237)","rgb(255, 242, 204)","rgb(222, 235, 246)","rgb(226, 239, 217)"],["rgb(216, 216, 216)","rgb(89, 89, 89)","rgb(175, 171, 171)","rgb(173, 185, 202)","rgb(180, 198, 231)","rgb(247, 203, 172)","rgb(219, 219, 219)","rgb(254, 229, 152)","rgb(189, 215, 238)","rgb(197, 224, 179)"],["rgb(191, 191, 191)","rgb(63, 63, 63)","rgb(117, 112, 112)","rgb(132, 150, 176)","rgb(142, 170, 216)","rgb(244, 177, 131)","rgb(201, 201, 201)","rgb(255, 217, 100)","rgb(157, 194, 229)","rgb(168, 208, 141)"],["rgb(165, 165, 165)","rgb(38, 38, 38)","rgb(58, 56, 56)","rgb(51, 63, 79)","rgb(47, 84, 150)","rgb(197, 91, 17)","rgb(123, 123, 123)","rgb(191, 144, 1)","rgb(46, 117, 181)","rgb(83, 129, 53)"],["rgb(126, 126, 126)","rgb(12, 12, 12)","rgb(23, 22, 22)","rgb(35, 42, 53)","rgb(30, 56, 100)","rgb(131, 61, 11)","rgb(82, 82, 82)","rgb(126, 96, 0)","rgb(31, 78, 121)","rgb(55, 86, 35)"]];class n extends i.Element{constructor(e){super(),this.class("spreadsheet-color-panel").child(i.h("table").child(i.h("tbody").children(r.map(t=>i.h("tr").children(t.map(t=>i.h("td").child(i.h().class("color-cell").on("click",e.bind(null,t)).style("background-color",t))))))))}}t.ColorPanel=n,t.buildColorPanel=function(e){return new n(e)}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(3);class n extends i.Element{constructor(e,t,s){super(),this.class("spreadsheet-dropdown spreadsheet-item"),this.content=i.h().class("spreadsheet-dropdown-content").children(s).onClickOutside(()=>this.deactive()).on("click",e=>this.toggleHandler(e)).style("width",t).hide(),this.child(i.h().class("spreadsheet-dropdown-header").children([this.title="string"==typeof e?i.h().class("spreadsheet-dropdown-title").child(e):e,i.h().class("spreadsheet-dropdown-icon").on("click",e=>this.toggleHandler(e)).child(r.buildIcon("arrow-down"))])).child(this.content)}toggleHandler(e){this.content.isHide()?(this.content.show(),this.active()):(this.content.hide(),this.deactive())}}t.Dropdown=n,t.buildDropdown=function(e,t,s){return new n(e,t,s)}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(4),n=s(3),l=s(11),o=s(2),h=s(10);t.Toolbar=class{constructor(e){this.ss=e,this.target=null,this.currentCell=null,this.change=((e,t)=>{}),this.redo=(()=>!1),this.undo=(()=>!1),this.defaultCell=e.data.cell,this.el=i.h().class("spreadsheet-toolbar").child(o.buildMenu("horizontal").children([this.elUndo=this.buildUndo(),this.elRedo=this.buildRedo(),this.elPaintformat=this.buildPaintformat(),this.elClearformat=this.buildClearformat(),this.elFormat=this.buildFormats(),this.buildSeparator(),this.elFont=this.buildFonts(),this.elFontSize=this.buildFontSizes(),this.buildSeparator(),this.elFontWeight=this.buildFontWeight(),this.elFontStyle=this.buildFontStyle(),this.elTextDecoration=this.buildTextDecoration(),this.elColor=this.buildColor(),this.buildSeparator(),this.elBackgroundColor=this.buildBackgroundColor(),this.elMerge=this.buildMerge(),this.buildSeparator(),this.elAlign=this.buildAligns(),this.elValign=this.buildValigns(),this.elWordWrap=this.buildWordWrap()]))}set(e,t){this.target=e,this.setCell(t)}setCell(e){this.currentCell=e,this.setCellStyle()}setCellStyle(){const{target:e,currentCell:t,defaultCell:s,ss:i}=this;e&&(this.elFormat.title.html(i.getFormat(null!==t&&t.format||s.format).title),this.elFont.title.html(i.getFont(null!==t&&t.font||s.font).title),this.elFontSize.title.html((null!==t&&t.fontSize||s.fontSize)+""),this.elFontWeight.active(null!==t&&void 0!==t.bold&&t.bold!==s.bold),this.elFontStyle.active(null!==t&&void 0!==t.italic&&t.italic!==s.italic),this.elTextDecoration.active(null!==t&&void 0!==t.underline&&t.underline!==s.underline),this.elColor.title.style("border-bottom-color",null!==t&&t.color||s.color),this.elBackgroundColor.title.style("border-bottom-color",null!==t&&t.backgroundColor||s.backgroundColor),this.elAlign.title.replace(`align-${null!==t&&t.align||s.align}`),this.elValign.title.replace(`valign-${null!==t&&t.valign||s.valign}`),this.elWordWrap.active(null!==t&&void 0!==t.wordWrap&&t.wordWrap!==s.wordWrap),null!==t&&t.rowspan&&t.rowspan>1||null!==t&&t.colspan&&t.colspan>1?this.elMerge.active(!0):this.elMerge.active(!1))}setRedoAble(e){e?this.elRedo.able():this.elRedo.disabled()}setUndoAble(e){e?this.elUndo.able():this.elUndo.disabled()}buildSeparator(){return i.h().class("spreadsheet-item-separator")}buildAligns(){const e=n.buildIcon(`align-${this.defaultCell.align}`),t=t=>{e.replace(`align-${t}`),this.change("align",t)};return l.buildDropdown(e,"60px",[o.buildMenu().children(["left","center","right"].map(e=>r.buildItem().child(n.buildIcon(`align-${e}`).style("text-align","center")).on("click",t.bind(null,e))))])}buildValigns(){const e=n.buildIcon(`valign-${this.defaultCell.valign}`),t=t=>{e.replace(`valign-${t}`),this.change("valign",t)};return l.buildDropdown(e,"60px",[o.buildMenu().children(["top","middle","bottom"].map(e=>r.buildItem().child(n.buildIcon(`valign-${e}`).style("text-align","center")).on("click",t.bind(null,e))))])}buildWordWrap(){return a("textwrap",e=>this.change("wordWrap",e))}buildFontWeight(){return a("bold",e=>this.change("bold",e))}buildFontStyle(){return a("italic",e=>this.change("italic",e))}buildTextDecoration(){return a("underline",e=>this.change("underline",e))}buildMerge(){return a("merge",e=>this.change("merge",e))}buildColor(){return l.buildDropdown(n.buildIcon("text-color").styles({"border-bottom":`3px solid ${this.defaultCell.color}`,"margin-top":"2px",height:"16px"}),"auto",[h.buildColorPanel(e=>{this.elColor.title.style("border-bottom-color",e),this.change("color",e)})])}buildBackgroundColor(){return l.buildDropdown(n.buildIcon("cell-color").styles({"border-bottom":`3px solid ${this.defaultCell.backgroundColor}`,"margin-top":"2px",height:"16px"}),"auto",[h.buildColorPanel(e=>{this.elBackgroundColor.title.style("border-bottom-color",e),this.change("backgroundColor",e)})])}buildUndo(){return r.buildItem().child(n.buildIcon("undo")).on("click",e=>{this.undo()?this.elUndo.able():this.elUndo.disabled()}).disabled()}buildRedo(){return r.buildItem().child(n.buildIcon("redo")).on("click",e=>{this.redo()?this.elRedo.able():this.elRedo.disabled()}).disabled()}buildPaintformat(){return a("paintformat",e=>{this.change("paintformat",!0),this.elPaintformat.deactive()})}buildClearformat(){return a("clearformat",e=>{this.change("clearformat",!0),this.elClearformat.deactive()})}buildFormats(){const e=e=>{this.elFormat.title.html(this.ss.getFormat(e.key).title),this.change("format",e.key)};return l.buildDropdown(this.ss.getFormat(this.defaultCell.format).title,"250px",[o.buildMenu().children(this.ss.formats.map(t=>r.buildItem().children([t.title,i.h().class("label").child(t.label||"")]).on("click",e.bind(null,t))))])}buildFonts(){const e=e=>{this.elFont.title.html(e.title),this.change("font",e.key)};return l.buildDropdown(this.ss.getFont(this.defaultCell.font).title,"170px",[o.buildMenu().children(this.ss.fonts.map(t=>r.buildItem().child(t.title).on("click",e.bind(null,t))))])}buildFontSizes(){const e=e=>{this.elFontSize.title.html(`${e}`),this.change("fontSize",e)};return l.buildDropdown(this.defaultCell.fontSize+"","70px",[o.buildMenu().children([6,8,10,12,14,16,18,20,22,24,30,36].map(t=>r.buildItem().child(`${t}`).on("click",e.bind(null,t))))])}};const a=(e,t)=>{const s=r.buildItem().child(n.buildIcon(e));return s.on("click",e=>{let i=s.isActive();i?s.deactive():s.active(),t(!i)}),s}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(4),n=s(2);t.ContextMenu=class{constructor(e){this.table=e,this.el=i.h().class("spreadsheet-contextmenu").style("width","160px").on("click",e=>this.el.hide()).children([n.buildMenu().children([r.buildItem().on("click",t=>e.copy()).children(["copy",i.h().class("label").html("ctrl + c")]),r.buildItem().on("click",t=>e.cut()).children(["cut",i.h().class("label").html("ctrl + x")]),r.buildItem().on("click",t=>e.paste()).children(["paste",i.h().class("label").html("ctrl + v")]),i.h().class("spreadsheet-item-separator"),r.buildItem().on("click",t=>e.insert("row",1)).html("insert row"),r.buildItem().on("click",t=>e.insert("col",1)).html("insert col")])]).onClickOutside(()=>{}).hide()}set(e){const{offsetLeft:t,offsetTop:s}=e.target,i=this.el.el.getBoundingClientRect(),{clientWidth:r,clientHeight:n}=document.documentElement;let l=s+24+e.offsetY,o=t+e.offsetX;e.clientY>n/1.5&&(l-=i.height),e.clientX>r/1.5&&(o-=i.width),this.el.style("left",`${o}px`).style("top",`${l}px`).show()}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(1);t.Resizer=class{constructor(e,t){this.vertical=e,this.change=t,this.moving=!1,this.index=0,this.el=i.h().class("spreadsheet-resizer-wrapper").children([this.resizer=i.h().class(`spreadsheet-resizer ${e?"vertical":"horizontal"}`).on("mousedown",e=>this.mousedown(e)),this.resizerLine=i.h().class(`spreadsheet-resizer-line ${e?"vertical":"horizontal"}`).hide()])}set(e,t){if(this.moving)return;this.index=t;const{vertical:s}=this,{offsetLeft:i,offsetTop:r,offsetHeight:n,offsetWidth:l,parentNode:o}=e;this.resizer.styles({left:`${s?i+l-5:i}px`,top:`${s?r:r+n-5+24}px`,width:`${s?5:l}px`,height:`${s?n:5}px`}),this.resizerLine.styles({left:`${s?i+l:i}px`,top:`${s?r:r+n+24}px`,width:`${s?0:o.parentNode.parentNode.parentNode.parentNode.nextSibling.offsetWidth-15}px`,height:`${s?o.parentNode.parentNode.parentNode.nextSibling.offsetHeight+o.offsetHeight:0}px`})}mousedown(e){let t=e,s=0;this.resizerLine.show(),r.mouseMoveUp(e=>{if(this.moving=!0,null!==t&&1===e.buttons){if(this.vertical){const i=e.x-t.x;s+=i,this.resizer.style("left",`${this.resizer.offset().left+i}px`),this.resizerLine.style("left",`${this.resizerLine.offset().left+i}px`)}else{const i=e.y-t.y;s+=i,this.resizer.style("top",`${this.resizer.offset().top+i}px`),this.resizerLine.style("top",`${this.resizerLine.offset().top+i}px`)}t=e}},e=>{this.change(this.index,s),t=null,this.resizerLine.hide(),s=0,this.moving=!1})}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(1);t.Selector=class{constructor(e,t){this.ss=e,this.table=t,this._offset={left:0,top:0,width:0,height:0},this.change=(()=>{}),this.changeCopy=((e,t,s,i,r,n)=>{}),this.topEl=i.h().class("top-border"),this.rightEl=i.h().class("right-border"),this.bottomEl=i.h().class("bottom-border"),this.leftEl=i.h().class("left-border"),this.areaEl=i.h().class("area-border"),this.cornerEl=i.h().class("corner").on("mousedown",e=>this.cornerMousedown(e)),this.copyEl=i.h().class("copy-border"),this.el=i.h().class("spreadsheet-borders").children([this.topEl,this.rightEl,this.bottomEl,this.leftEl,this.areaEl,this.cornerEl,this.copyEl])}mousedown(e){if(1===e.detail&&"cell"===e.target.getAttribute("type")){if(e.shiftKey)return this.endTarget=e.target,void this.setOffset();this.setCurrentTarget(e.target),r.mouseMoveUp(e=>{1===e.buttons&&"cell"===e.target.getAttribute("type")&&(this.endTarget=e.target,this.setOffset())},e=>{this.change()})}}setCurrentTarget(e){Object.assign(this,{startTarget:e,endTarget:e}),this.setOffset()}cornerMousedown(e){const{select:t}=this.ss;if(null===t)return;const[s,i]=t.stop,[n,l]=t.start;let o=null;r.mouseMoveUp(e=>{const r=e.target.getAttribute("row-index"),h=e.target.getAttribute("col-index");if(r&&h){this.copyEl.show();let e=s-r,a=i-h,d=n-r,c=l-h;const{left:u,top:p,height:f,width:b}=this._offset;if(e<0)this.copyEl.styles({left:`${u-1}px`,top:`${p-1}px`,width:`${b-1}px`,height:`${this.rowsHeight(s-t.rowLen()+1,s+Math.abs(e))-1}px`}),o=["bottom",s+1,l,s+Math.abs(e),i];else if(a<0)this.copyEl.styles({left:`${u-1}px`,top:`${p-1}px`,width:`${this.colsWidth(i-t.colLen()+1,i+Math.abs(a))-1}px`,height:`${f-1}px`}),o=["right",n,i+1,s,i+Math.abs(a)];else if(d>0){const e=this.rowsHeight(n-d,n-1);this.copyEl.styles({left:`${u-1}px`,top:`${p-e-1}px`,width:`${b-1}px`,height:`${e-1}px`}),o=["top",n-d,l,n-1,i]}else if(c>0){const e=this.colsWidth(l-c,l-1);this.copyEl.styles({left:`${u-e-1}px`,top:`${p-1}px`,width:`${e-1}px`,height:`${f-1}px`}),o=["left",n,l-c,s,l-1]}else this.copyEl.styles({left:`${u-1}px`,top:`${p-1}px`,width:`${b-1}px`,height:`${f-1}px`}),o=null}},e=>{if(this.copyEl.hide(),null!==o){const[t,s,i,r,n]=o;this.changeCopy(e,t,s,i,r,n)}})}reload(){this.setOffset()}setOffset(){if(void 0===this.startTarget)return;let{select:e}=this.ss;if(e){const[t,s]=e.start,[i,r]=e.stop;n(t,i,this.table.firsttds,e=>{e.deactive()}),n(s,r,this.table.ths,e=>{e.deactive()})}e=this.ss.buildSelect(this.startTarget,this.endTarget);const[t,s]=e.start,[i,r]=e.stop,l=this.rowsHeight(t,i,e=>e.active()),o=this.colsWidth(s,r,e=>e.active()),h=this.table.td(t,s);if(h){const{left:e,top:t}=h.offset();this._offset={left:e,top:t,width:o,height:l},this.topEl.styles({left:`${e-1}px`,top:`${t-1}px`,width:`${o+1}px`,height:"2px"}),this.rightEl.styles({left:`${e+o-1}px`,top:`${t-1}px`,width:"2px",height:`${l}px`}),this.bottomEl.styles({left:`${e-1}px`,top:`${t+l-1}px`,width:`${o}px`,height:"2px"}),this.leftEl.styles({left:`${e-1}px`,top:`${t-1}px`,width:"2px",height:`${l}px`}),this.areaEl.styles({left:`${e}px`,top:`${t}px`,width:`${o-2}px`,height:`${l-2}px`}),this.cornerEl.styles({left:`${e+o-5}px`,top:`${t+l-5}px`})}}rowsHeight(e,t,s=(e=>{})){let i=0;return n(e,t,this.table.firsttds,e=>{s(e),i+=parseInt(e.offset().height)}),i/=2}colsWidth(e,t,s=(e=>{})){let i=0;return n(e,t,this.table.ths,e=>{s(e),i+=parseInt(e.offset().width)}),i}};const n=(e,t,s,r)=>{for(let n=e;n<=t;n++){const e=s[n+""];e&&(e instanceof i.Element?r(e):e.forEach(e=>r(e)))}};t.DashedSelector=class{constructor(){this.el=i.h().class("spreadsheet-borders dashed").hide()}set(e){if(e._offset){const{left:t,top:s,width:i,height:r}=e._offset;this.el.style("left",`${t-2}px`).style("top",`${s-2}px`).style("width",`${i}px`).style("height",`${r}px`).show()}}hide(){this.el.hide()}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(4),n=s(2),l=s(1);t.Suggest=class extends i.Element{constructor(e,t){super(),this.list=e,this.width=t,this.filterList=[],this.currentIndex=0,this.itemClick=(e=>{}),this.class("spreadsheet-suggest").hide()}documentHandler(e){if(this.el.contains(e.target))return!1;this.hideAndRemoveEvents()}documentKeydownHandler(e){if(console.log("keyCode: ",e),!(this.filterList.length<=0&&"textarea"!==e.target.type))switch(e.keyCode){case 37:e.returnValue=!1;break;case 38:this.filterList[this.currentIndex].deactive(),this.currentIndex--,this.currentIndex<0&&(this.currentIndex=this.filterList.length-1),this.filterList[this.currentIndex].active(),e.returnValue=!1;break;case 39:e.returnValue=!1;break;case 40:this.filterList[this.currentIndex].deactive(),this.currentIndex++,this.currentIndex>this.filterList.length-1&&(this.currentIndex=0),this.filterList[this.currentIndex].active(),e.returnValue=!1;break;case 13:this.filterList[this.currentIndex].el.click(),e.returnValue=!1}}hideAndRemoveEvents(){this.hide(),this.removeEvents()}removeEvents(){l.unbind("click",this.data("_outsidehandler")),l.unbind("keydown",this.data("_keydownhandler"))}clickItemHandler(e){this.itemClick(e),this.hideAndRemoveEvents()}search(e,t){this.removeEvents();const{left:s,top:o,width:h,height:a}=e.offset();this.styles({left:`${s}px`,top:`${o+a+2}px`,width:`${this.width}px`});let d=this.list;/^\s*$/.test(t)||(d=this.list.filter(e=>e[0].startsWith(t.toUpperCase()))),d=d.map(e=>{const t=r.buildItem().on("click",t=>this.clickItemHandler(e)).child(e[0]);return e[1]&&t.child(i.h().class("label").html(e[1])),t}),this.filterList=d,this.currentIndex=0,d.length<=0?d=[r.buildItem().child("No Result")]:(d[0].active(),this.data("_outsidehandler",e=>{this.documentHandler(e)}),this.data("_keydownhandler",e=>this.documentKeydownHandler(e)),setTimeout(()=>{l.bind("click",this.data("_outsidehandler")),l.bind("keydown",this.data("_keydownhandler"))},0)),this.html(""),this.child(n.buildMenu().children(d)).show()}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(16),n=s(5);t.Editor=class{constructor(e,t){this.defaultRowHeight=e,this.formulas=t,this.target=null,this.value=null,this.change=(e=>{});const s=t.map(e=>[e.key,e.title]);this.el=i.h().children([this.editor=i.h().class("spreadsheet-editor").children([this.textarea=i.h("textarea").on("input",e=>this.inputChange(e)),this.textline=i.h().styles({visibility:"hidden",overflow:"hidden",position:"fixed",top:"0",left:"0"})]),this.suggest=new r.Suggest(s,180)]),this.suggest.itemClick=(e=>{console.log(">>>>>>>>>>>>",e);const t=`=${e[0]}()`;this.value&&(this.value.text=t),this.textarea.val(t),this.textline.html(t),this.setTextareaRange(t.length-1)})}onChange(e){this.change=e}set(e,t){this.target=e;const s=this.setValue(t);this.el.show(),this.setTextareaRange(s.length),this.reload()}setValue(e){if(this.setStyle(e),e){this.value=e;const t=e.text||"";return this.textarea.val(t),this.textline.html(t),t}return""}setStyle(e){let t={width:this.textarea.style("width"),height:this.textarea.style("height")};this.textarea.styles(Object.assign(t,n.getStyleFromCell(e)),!0)}clear(){this.el.hide(),this.target=null,this.value=null,this.textarea.val(""),this.textline.html("")}setTextareaRange(e){setTimeout(()=>{this.textarea.el.setSelectionRange(e,e),this.textarea.el.focus()},10)}inputChange(e){const t=e.target.value;/^\s*$/.test(t)||(this.value?this.value.text=t:this.value={text:t},this.autocomplete(t)),this.textline.html(t),this.reload()}autocomplete(e){if("="===e[0])if(e.includes("("))this.suggest.hide();else{const t=e.substring(1);console.log(":::;search word:",t),this.suggest.search(this.editor,t)}else this.suggest.hide()}reload(){if(this.target){const{offsetTop:e,offsetLeft:t,offsetWidth:s,offsetHeight:i}=this.target;this.editor.styles({left:`${t-1}px`,top:`${e-1}px`}),this.textarea.styles({width:`${s-8}px`,height:`${i-2}px`});let r=this.textline.offset().width+16;if(this.value)if(this.value.wordWrap){const e=(parseInt(r/s+"")+(r%s>0?1:0))*this.defaultRowHeight;e>i&&this.textarea.style("height",`${e}px`)}else{const e=document.documentElement.clientWidth-t-24;if(r>s){if(r>e){const t=(parseInt(r/e+"")+(r%e>0?1:0))*this.defaultRowHeight;t>i?this.textarea.style("height",`${t}px`):this.textarea.style("height",`${i}px`),r=e}this.textarea.style("width",`${r}px`)}}}}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(0),r=s(17),n=s(15),l=s(14),o=s(13),h=s(5),a=s(8),d=s(7),c=s(1);t.Table=class{constructor(e,t){this.cols={},this.firsttds={},this.tds={},this.ths={},this.formulaCellIndexs=new Set,this.fixedLeftBody=null,this.state=null,this.currentIndexs=null,this.change=(()=>{}),this.editorChange=(e=>{}),this.clickCell=((e,t,s)=>{}),this.ss=e,this.ss.change=(e=>{this.change(e)}),this.editor=new r.Editor(e.defaultRowHeight(),e.formulas),this.rowResizer=new l.Resizer(!1,(e,t)=>this.changeRowResizer(e,t)),this.colResizer=new l.Resizer(!0,(e,t)=>this.changeColResizer(e,t)),this.contextmenu=new o.ContextMenu(this),this.selector=new n.Selector(this.ss,this),this.selector.change=(()=>this.selectorChange()),this.selector.changeCopy=((e,t,s,i,r,n)=>{this.selectorChangeCopy(e,t,s,i,r,n)}),this.dashedSelector=new n.DashedSelector,this.bodyHeight=t||(()=>document.documentElement.clientHeight-24-41-26),this.el=i.h().class("spreadsheet-table").children([this.colResizer.el,this.rowResizer.el,this.contextmenu.el,this.buildFixedLeft(),this.header=this.buildHeader(),this.buildBody()]).on("contextmenu",e=>{e.returnValue=!1,e.preventDefault()}),c.bind("keydown",e=>{if(e.ctrlKey)67===e.keyCode&&(this.copy(),e.returnValue=!1),88===e.keyCode&&(this.cut(),e.returnValue=!1),86===e.keyCode&&(this.paste(),e.returnValue=!1);else{if("textarea"===e.target.type)return void(9===e.keyCode&&(this.moveRight(),this.currentIndexs&&this.editCell(this.currentIndexs[0],this.currentIndexs[1]),e.returnValue=!1));switch(e.keyCode){case 37:this.moveLeft(),e.returnValue=!1;break;case 38:this.moveUp(),e.returnValue=!1;break;case 39:this.moveRight(),e.returnValue=!1;break;case 40:this.moveDown(),e.returnValue=!1;break;case 9:this.moveRight(),e.returnValue=!1}(e.keyCode>=65&&e.keyCode<=90||e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&this.currentIndexs&&this.editCell(this.currentIndexs[0],this.currentIndexs[1])}})}moveLeft(){this.currentIndexs&&this.currentIndexs[1]>0&&(this.currentIndexs[1]-=1,this.moveSelector())}moveUp(){this.currentIndexs&&this.currentIndexs[0]>0&&(this.currentIndexs[0]-=1,this.moveSelector())}moveDown(){this.currentIndexs&&this.currentIndexs[1]<this.ss.rows().length&&(this.currentIndexs[0]+=1,this.moveSelector())}moveRight(){this.currentIndexs&&this.currentIndexs[0]<this.ss.cols().length&&(this.currentIndexs[1]+=1,this.moveSelector())}moveSelector(){if(this.currentIndexs){const[e,t]=this.currentIndexs,s=this.td(e,t);s&&this.selector.setCurrentTarget(s.el),this.mousedownCell(e,t)}}setValueWithText(e){this.currentIndexs&&this.ss.cellText(e.text,(e,t,s)=>{this.td(e,t).html(this.renderCell(e,t,s))}),this.editor.setValue(e)}setTdWithCell(e,t,s,i=!0){this.setTdStyles(e,t,s),this.setRowHeight(e,t,i),this.td(e,t).html(this.renderCell(e,t,s))}setCellAttr(e,t){this.ss.cellAttr(e,t,(s,i,r)=>{this.setTdWithCell(s,i,r,"wordWrap"===e&&t)}),this.editor.setStyle(this.ss.currentCell())}undo(){return this.ss.undo((e,t,s)=>{this.setTdStylesAndAttrsAndText(e,t,s)})}redo(){return this.ss.redo((e,t,s)=>{this.setTdStylesAndAttrsAndText(e,t,s)})}setTdStylesAndAttrsAndText(e,t,s){let i=this.td(e,t);this.setTdStyles(e,t,s),this.setTdAttrs(e,t,s),i.html(this.renderCell(e,t,s))}copy(){this.ss.copy(),this.dashedSelector.set(this.selector),this.state="copy"}cut(){this.ss.cut(),this.dashedSelector.set(this.selector),this.state="cut"}copyformat(){this.ss.copy(),this.dashedSelector.set(this.selector),this.state="copyformat"}paste(){null!==this.state&&this.ss.select&&(this.ss.paste((e,t,s)=>{let i=this.td(e,t);this.setTdStyles(e,t,s),this.setTdAttrs(e,t,s),"cut"!==this.state&&"copy"!==this.state||i.html(this.renderCell(e,t,s))},this.state,(e,t,s)=>{let i=this.td(e,t);this.setTdStyles(e,t,s),this.setTdAttrs(e,t,s),i.html("")}),this.selector.reload()),"copyformat"===this.state?this.state=null:"cut"===this.state?this.state=null:this.state,this.dashedSelector.hide()}clearformat(){this.ss.clearformat((e,t,s)=>{this.td(e,t).removeAttr("rowspan").removeAttr("colspan").styles({},!0).show(!0)})}merge(){this.ss.merge((e,t,s)=>{this.setTdAttrs(e,t,s).show(!0)},(e,t,s)=>{this.setTdAttrs(e,t,s).show(!0)},(e,t,s)=>{let i=this.td(e,t);s.invisible?i.hide():i.show(!0)})}insert(e,t){this.ss.insert(e,t,(e,t,s)=>{this.setTdStylesAndAttrsAndText(e,t,s)})}td(e,t){return this.tds[`${e}_${t}`]}selectorChange(){"copyformat"===this.state&&this.paste()}selectorChangeCopy(e,t,s,i,r,n){this.ss.batchPaste(t,s,i,r,n,e.ctrlKey,(e,t,s)=>{this.setTdStyles(e,t,s),this.setTdAttrs(e,t,s),this.td(e,t).html(this.renderCell(e,t,s))})}renderCell(e,t,s){if(s){const i=`${e}_${t}`;return s.text&&"="===s.text[0]?this.formulaCellIndexs.add(i):(this.formulaCellIndexs.has(i)&&this.formulaCellIndexs.delete(i),this.reRenderFormulaCells()),a.formatRenderHtml(s.format,this._renderCell(s))}return""}_renderCell(e){if(e){let t=e.text||"";return d.formulaRender(t,(e,t)=>this._renderCell(this.ss.getCell(e,t)))}return""}reRenderFormulaCells(){this.formulaCellIndexs.forEach(e=>{let t=e.split("_");const s=parseInt(t[0]),i=parseInt(t[1]),r=this.renderCell(s,i,this.ss.getCell(s,i));this.td(s,i).html(r)})}setRowHeight(e,t,s){this.ss.cols();const i=this.td(e,t);let r=i.offset().height;const n=i.attr("rowspan");if(n)for(let e=1;e<parseInt(n);e++){let t=this.firsttds[e+""];t&&(r-=parseInt(t[0].attr("height")||0)+1)}this.changeRowHeight(e,r-1)}setTdStyles(e,t,s){return this.td(e,t).styles(h.getStyleFromCell(s),!0)}setTdAttrs(e,t,s){return this.td(e,t).attr("rowspan",s.rowspan||1).attr("colspan",s.colspan||1)}changeRowHeight(e,t){if(t<=this.ss.defaultRowHeight())return;this.ss.row(e,t);const s=this.firsttds[e+""];s&&s.forEach(e=>e.attr("height",t)),this.selector.reload(),this.editor.reload()}changeRowResizer(e,t){const s=this.ss.row(e).height+t;this.changeRowHeight(e,s)}changeColResizer(e,t){const s=this.ss.col(e).width+t;if(s<=this.ss.defaultColWidth())return;this.ss.col(e,s);const i=this.cols[e+""];i&&i.forEach(e=>e.attr("width",s)),this.selector.reload(),this.editor.reload()}buildColGroup(e){const t=this.ss.cols();return i.h("colgroup").children([i.h("col").attr("width","60"),...t.map((e,t)=>{let s=i.h("col").attr("width",e.width);return this.cols[t+""]=this.cols[t+""]||[],this.cols[t+""].push(s),s}),i.h("col").attr("width",e)])}buildFixedLeft(){const e=this.ss.rows();return i.h().class("spreadsheet-fixed").style("width","60px").children([i.h().class("spreadsheet-fixed-header").child(i.h("table").child(i.h("thead").child(i.h("tr").child(i.h("th").child("-"))))),this.fixedLeftBody=i.h().class("spreadsheet-fixed-body").style("height",`${this.bodyHeight()-18}px`).children([i.h("table").child(i.h("tbody").children(e.map((e,t)=>{let s=i.h("td").attr("height",`${e.height}`).child(`${t+1}`).on("mouseover",e=>this.rowResizer.set(e.target,t));return this.firsttdsPush(t,s),i.h("tr").child(s)})))])])}buildHeader(){const e=this.ss.cols(),t=i.h("thead").child(i.h("tr").children([i.h("th"),...e.map((e,t)=>{let s=i.h("th").child(e.title).on("mouseover",e=>this.colResizer.set(e.target,t));return this.ths[t+""]=s,s}),i.h("th")]));return i.h().class("spreadsheet-header").children([i.h("table").children([this.buildColGroup(15),t])])}mousedownCell(e,t){const s=this.editor.value;if(this.currentIndexs&&this.editor.target&&s){const e=this.ss.cellText(s.text,(e,t,s)=>{this.td(e,t).html(this.renderCell(e,t,s))});e&&(e.wordWrap&&this.setRowHeight(this.currentIndexs[0],this.currentIndexs[1],!0),this.editorChange(e))}this.editor.clear(),this.currentIndexs=[e,t];const i=this.ss.currentCell([e,t]);this.clickCell(e,t,i)}editCell(e,t){const s=this.td(e,t);this.editor.set(s.el,this.ss.currentCell())}buildBody(){const e=this.ss.rows(),t=this.ss.cols(),s=(e,t,s)=>{const{select:i}=this.ss;2===s.button&&(this.contextmenu.set(s),i&&i.contains(e,t))||(this.selector.mousedown(s),this.mousedownCell(e,t))},r=(e,t)=>{this.editCell(e,t)},n=i.h("tbody").children(e.map((e,n)=>{let l=i.h("td").attr("height",`${e.height}`).child(`${n+1}`);return this.firsttdsPush(n,l),i.h("tr").children([l,...t.map((e,t)=>{let l=this.ss.getCell(n,t),o=i.h("td").child(this.renderCell(n,t,l)).attr("type","cell").attr("row-index",n+"").attr("col-index",t+"").attr("rowspan",l&&l.rowspan||1).attr("colspan",l&&l.colspan||1).styles(h.getStyleFromCell(l),!0).on("mousedown",e=>s(n,t,e)).on("dblclick",r.bind(null,n,t));return this.tds[`${n}_${t}`]=o,o}),i.h("td")])}));return i.h().class("spreadsheet-body").on("scroll",e=>{this.header.el.scrollLeft=e.target.scrollLeft,this.fixedLeftBody&&(this.fixedLeftBody.el.scrollTop=e.target.scrollTop)}).style("height",`${this.bodyHeight()}px`).children([i.h("table").children([this.buildColGroup(0),n]),this.editor.el,this.selector.el,this.dashedSelector.el])}firsttdsPush(e,t){this.firsttds[`${e}`]=this.firsttds[`${e}`]||[],this.firsttds[`${e}`].push(t)}}},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var s=t.protocol+"//"+t.host,i=s+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var r,n=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(n)?e:(r=0===n.indexOf("//")?n:0===n.indexOf("/")?s+n:i+n.replace(/^\.\//,""),"url("+JSON.stringify(r)+")")})}},function(e,t,s){var i,r,n={},l=(i=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===r&&(r=i.apply(this,arguments)),r}),o=function(e){var t={};return function(e){if("function"==typeof e)return e();if(void 0===t[e]){var s=function(e){return document.querySelector(e)}.call(this,e);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}t[e]=s}return t[e]}}(),h=null,a=0,d=[],c=s(19);function u(e,t){for(var s=0;s<e.length;s++){var i=e[s],r=n[i.id];if(r){r.refs++;for(var l=0;l<r.parts.length;l++)r.parts[l](i.parts[l]);for(;l<i.parts.length;l++)r.parts.push(m(i.parts[l],t))}else{var o=[];for(l=0;l<i.parts.length;l++)o.push(m(i.parts[l],t));n[i.id]={id:i.id,refs:1,parts:o}}}}function p(e,t){for(var s=[],i={},r=0;r<e.length;r++){var n=e[r],l=t.base?n[0]+t.base:n[0],o={css:n[1],media:n[2],sourceMap:n[3]};i[l]?i[l].parts.push(o):s.push(i[l]={id:l,parts:[o]})}return s}function f(e,t){var s=o(e.insertInto);if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var i=d[d.length-1];if("top"===e.insertAt)i?i.nextSibling?s.insertBefore(t,i.nextSibling):s.appendChild(t):s.insertBefore(t,s.firstChild),d.push(t);else if("bottom"===e.insertAt)s.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var r=o(e.insertInto+" "+e.insertAt.before);s.insertBefore(t,r)}}function b(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=d.indexOf(e);t>=0&&d.splice(t,1)}function g(e){var t=document.createElement("style");return e.attrs.type="text/css",x(t,e.attrs),f(e,t),t}function x(e,t){Object.keys(t).forEach(function(s){e.setAttribute(s,t[s])})}function m(e,t){var s,i,r,n;if(t.transform&&e.css){if(!(n=t.transform(e.css)))return function(){};e.css=n}if(t.singleton){var l=a++;s=h||(h=g(t)),i=v.bind(null,s,l,!1),r=v.bind(null,s,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(s=function(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",x(t,e.attrs),f(e,t),t}(t),i=function(e,t,s){var i=s.css,r=s.sourceMap,n=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||n)&&(i=c(i));r&&(i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var l=new Blob([i],{type:"text/css"}),o=e.href;e.href=URL.createObjectURL(l),o&&URL.revokeObjectURL(o)}.bind(null,s,t),r=function(){b(s),s.href&&URL.revokeObjectURL(s.href)}):(s=g(t),i=function(e,t){var s=t.css,i=t.media;i&&e.setAttribute("media",i);if(e.styleSheet)e.styleSheet.cssText=s;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(s))}}.bind(null,s),r=function(){b(s)});return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=l()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var s=p(e,t);return u(s,t),function(e){for(var i=[],r=0;r<s.length;r++){var l=s[r];(o=n[l.id]).refs--,i.push(o)}e&&u(p(e,t),t);for(r=0;r<i.length;r++){var o;if(0===(o=i[r]).refs){for(var h=0;h<o.parts.length;h++)o.parts[h]();delete n[o.id]}}}};var y,w=(y=[],function(e,t){return y[e]=t,y.filter(Boolean).join("\n")});function v(e,t,s,i){var r=s?"":i.css;if(e.styleSheet)e.styleSheet.cssText=w(t,r);else{var n=document.createTextNode(r),l=e.childNodes;l[t]&&e.removeChild(l[t]),l.length?e.insertBefore(n,l[t]):e.appendChild(n)}}},function(e,t,s){e.exports=s.p+"13b240062f9cf9a7f4131b86a426f140.svg"},function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var s=function(e,t){var s=e[1]||"",i=e[3];if(!i)return s;if(t&&"function"==typeof btoa){var r=(l=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(l))))+" */"),n=i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"});return[s].concat(n).concat([r]).join("\n")}var l;return[s].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+s+"}":s}).join("")},t.i=function(e,s){"string"==typeof e&&(e=[[null,e,""]]);for(var i={},r=0;r<this.length;r++){var n=this[r][0];"number"==typeof n&&(i[n]=!0)}for(r=0;r<e.length;r++){var l=e[r];"number"==typeof l[0]&&i[l[0]]||(s&&!l[2]?l[2]=s:s&&(l[2]="("+l[2]+") and ("+s+")"),t.push(l))}},t}},function(e,t){e.exports=function(e){return"string"!=typeof e?e:(/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),/["'() \t\n]/.test(e)?'"'+e.replace(/"/g,'\\"').replace(/\n/g,"\\n")+'"':e)}},function(e,t,s){var i=s(23);(e.exports=s(22)(!1)).push([e.i,"body {\n margin: 0;\n}\n.spreadsheet {\n font-size: 14px;\n line-height: normal;\n user-select: none;\n -moz-user-select: none;\n font-family: Roboto, Helvetica, Arial, sans-serif;\n}\n.spreadsheet .spreadsheet-table {\n position: relative;\n}\n.spreadsheet .spreadsheet-fixed {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 10;\n background: #fff;\n}\n.spreadsheet .spreadsheet-fixed .spreadsheet-fixed-body {\n overflow: hidden;\n}\n.spreadsheet .spreadsheet-fixed .spreadsheet-fixed-header {\n overflow: hidden;\n}\n.spreadsheet .spreadsheet-body {\n overflow: scroll;\n position: relative;\n}\n.spreadsheet .spreadsheet-header {\n overflow: hidden;\n width: 100%;\n}\n.spreadsheet .spreadsheet-header table,\n.spreadsheet .spreadsheet-body table,\n.spreadsheet .spreadsheet-fixed table {\n table-layout: fixed;\n text-align: left;\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n color: #000;\n}\n.spreadsheet .spreadsheet-header table td,\n.spreadsheet .spreadsheet-body table td,\n.spreadsheet .spreadsheet-fixed table td,\n.spreadsheet .spreadsheet-header table th,\n.spreadsheet .spreadsheet-body table th,\n.spreadsheet .spreadsheet-fixed table th {\n transition: background .1s ease,color .1s ease;\n border-bottom: 1px solid #e0e2e4;\n border-right: 1px solid #e0e2e4;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n padding: 0 4px;\n line-height: 22px;\n}\n.spreadsheet .spreadsheet-header table td.active,\n.spreadsheet .spreadsheet-body table td.active,\n.spreadsheet .spreadsheet-fixed table td.active,\n.spreadsheet .spreadsheet-header table th.active,\n.spreadsheet .spreadsheet-body table th.active,\n.spreadsheet .spreadsheet-fixed table th.active {\n background: rgba(75, 137, 255, 0.05) !important;\n}\n.spreadsheet .spreadsheet-header table th,\n.spreadsheet .spreadsheet-body table th,\n.spreadsheet .spreadsheet-fixed table th {\n border-top: 1px solid #e0e2e4;\n text-align: center;\n}\n.spreadsheet .spreadsheet-header table th,\n.spreadsheet .spreadsheet-body table th,\n.spreadsheet .spreadsheet-fixed table th,\n.spreadsheet .spreadsheet-header table td:first-child,\n.spreadsheet .spreadsheet-body table td:first-child,\n.spreadsheet .spreadsheet-fixed table td:first-child {\n font-size: 12px;\n background: #f4f5f8;\n font-weight: normal;\n color: #666;\n}\n.spreadsheet .spreadsheet-header table td:first-child,\n.spreadsheet .spreadsheet-body table td:first-child,\n.spreadsheet .spreadsheet-fixed table td:first-child,\n.spreadsheet .spreadsheet-header table th:first-child,\n.spreadsheet .spreadsheet-body table th:first-child,\n.spreadsheet .spreadsheet-fixed table th:first-child {\n border-left: 1px solid #e0e2e4;\n text-align: center;\n}\n.spreadsheet-editor {\n position: absolute;\n text-align: left;\n border: 2px solid #4b89ff;\n line-height: 0;\n z-index: 10;\n}\n.spreadsheet-editor textarea {\n box-sizing: content-box;\n border: none;\n padding: 0 3px;\n outline-width: 0;\n resize: none;\n text-align: start;\n overflow-y: hidden;\n font-family: inherit;\n font-size: inherit;\n color: inherit;\n white-space: normal;\n word-wrap: break-word;\n line-height: 22px;\n margin: 0;\n}\n.spreadsheet-suggest,\n.spreadsheet-contextmenu {\n position: absolute;\n box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);\n background: #fff;\n z-index: 100;\n}\n.spreadsheet-resizer {\n position: absolute;\n z-index: 11;\n}\n.spreadsheet-resizer.horizontal {\n cursor: row-resize;\n}\n.spreadsheet-resizer.vertical {\n cursor: col-resize;\n}\n.spreadsheet-resizer-line {\n position: absolute;\n z-index: 100;\n}\n.spreadsheet-resizer-line.horizontal {\n border-bottom: 2px dashed #4b89ff;\n}\n.spreadsheet-resizer-line.vertical {\n border-right: 2px dashed #4b89ff;\n}\n.spreadsheet-borders {\n box-sizing: content-box;\n}\n.spreadsheet-borders.dashed {\n border: 2px dashed #4b89ff;\n position: absolute;\n background: rgba(75, 137, 255, 0.03);\n}\n.spreadsheet-borders .left-border,\n.spreadsheet-borders .right-border,\n.spreadsheet-borders .bottom-border,\n.spreadsheet-borders .top-border,\n.spreadsheet-borders .area-border {\n position: absolute;\n font-size: 0;\n pointer-events: none;\n background: #4b89ff;\n}\n.spreadsheet-borders .area-border {\n background: rgba(75, 137, 255, 0.03);\n}\n.spreadsheet-borders .corner {\n cursor: crosshair;\n font-size: 0;\n height: 5px;\n width: 5px;\n border: 2px solid #ffffff;\n position: absolute;\n bottom: -6px;\n right: -6px;\n background: #4b89ff;\n}\n.spreadsheet-borders .copy-border {\n position: absolute;\n pointer-events: none;\n border: 1px dashed #4b89ff;\n background: rgba(75, 137, 255, 0.03);\n}\n.spreadsheet-paint-border {\n position: absolute;\n pointer-events: none;\n border: 1px dashed #4b89ff;\n background: rgba(75, 137, 255, 0.03);\n}\n.spreadsheet-bars .spreadsheet-toolbar {\n height: 40px;\n text-align: left;\n padding: 0 60px;\n border-bottom: 1px solid #e0e2e4;\n background: #f5f6f7;\n}\n.spreadsheet-bars .spreadsheet-toolbar > .spreadsheet-menu > .spreadsheet-item {\n margin: 7px 1px 0;\n}\n.spreadsheet-bars .spreadsheet-editor-bar {\n width: 100%;\n height: 26px;\n line-height: 26px;\n position: relative;\n background: #fff;\n padding: 0;\n}\n.spreadsheet-formula-bar {\n position: relative;\n height: 100%;\n}\n.spreadsheet-formula-bar .spreadsheet-formula-label {\n width: 60px;\n height: 100%;\n box-sizing: border-box;\n display: inline-block;\n text-align: center;\n border-right: 1px solid #e0e2e4;\n background-color: #fff;\n font-size: 12px;\n color: #777;\n user-select: none;\n float: left;\n vertical-align: middle;\n}\n.spreadsheet-formula-bar textarea {\n width: calc(100% - 60px);\n height: 100%;\n box-sizing: border-box;\n font-family: inherit;\n font-size: inherit;\n padding: 4px 10px;\n position: relative;\n float: left;\n resize: none;\n overflow-y: hidden;\n border: none;\n outline-width: 0;\n margin: 0;\n}\n.spreadsheet-formula-bar-resizer {\n cursor: ns-resize;\n height: 4px;\n position: absolute;\n width: 100%;\n left: 0;\n bottom: 0;\n}\n.spreadsheet-menu.vertical > .spreadsheet-item-separator {\n background: #e0e2e4;\n height: 1px;\n margin: 5px 0;\n}\n.spreadsheet-menu.vertical > .spreadsheet-item {\n padding: 2px 10px;\n border-radius: 0;\n}\n.spreadsheet-menu.horizontal > .spreadsheet-item {\n display: inline-block;\n}\n.spreadsheet-menu.horizontal > .spreadsheet-item-separator {\n display: inline-block;\n background: #e0e2e4;\n width: 1px;\n vertical-align: middle;\n height: 18px;\n margin: 0 3px;\n}\n.spreadsheet-menu > .spreadsheet-item {\n border-radius: 2px;\n user-select: none;\n background: 0;\n border: 1px solid transparent;\n outline: none;\n height: 24px;\n color: rgba(0, 0, 0, 0.8);\n line-height: 24px;\n list-style: none;\n cursor: default;\n}\n.spreadsheet-menu > .spreadsheet-item.disabled {\n pointer-events: none;\n opacity: 0.5;\n}\n.spreadsheet-menu > .spreadsheet-item:not(.separator):hover,\n.spreadsheet-menu > .spreadsheet-item.active {\n background: rgba(0, 0, 0, 0.08);\n}\n.spreadsheet-menu > .spreadsheet-item:not(.separator):hover .spreadsheet-icon-img,\n.spreadsheet-menu > .spreadsheet-item.active .spreadsheet-icon-img {\n opacity: 0.7;\n}\n.spreadsheet-menu > .spreadsheet-item:not(.separator):hover .spreadsheet-dropdown-icon,\n.spreadsheet-menu > .spreadsheet-item.active .spreadsheet-dropdown-icon {\n background-color: rgba(0, 0, 0, 0.15);\n opacity: 0.6;\n}\n.spreadsheet-menu > .spreadsheet-item > .label {\n float: right;\n opacity: .8;\n}\n.spreadsheet-dropdown {\n position: relative;\n display: inline-block;\n width: auto!important;\n}\n.spreadsheet-dropdown .spreadsheet-dropdown-content {\n position: absolute;\n top: calc(100% + 5px);\n left: 0;\n z-index: 200;\n background: #fff;\n box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);\n width: auto;\n}\n.spreadsheet-dropdown .spreadsheet-dropdown-header .spreadsheet-dropdown-title {\n padding: 0 5px;\n display: inline-block;\n}\n.spreadsheet-dropdown .spreadsheet-dropdown-header .spreadsheet-dropdown-icon {\n display: inline-block;\n vertical-align: top;\n}\n.spreadsheet-dropdown .spreadsheet-dropdown-header .spreadsheet-dropdown-icon .spreadsheet-icon {\n width: 10px;\n}\n.spreadsheet-dropdown .spreadsheet-dropdown-header .spreadsheet-dropdown-icon .spreadsheet-icon .arrow-down {\n left: -130px;\n}\n.spreadsheet-color-panel {\n padding: 10px;\n width: 100%;\n}\n.spreadsheet-color-panel table {\n border-collapse: separate;\n border-spacing: 0;\n border: none;\n}\n.spreadsheet-color-panel table tr td {\n padding: 0;\n border: none;\n}\n.spreadsheet-color-panel .color-cell {\n width: 20px;\n height: 20px;\n margin: 3px;\n}\n.spreadsheet-color-panel .color-cell:hover {\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);\n}\n.spreadsheet-icon {\n height: 18px;\n width: 18px;\n margin: 0px 4px 3px 3px;\n direction: ltr;\n text-align: left;\n user-select: none;\n vertical-align: middle;\n overflow: hidden;\n position: relative;\n display: inline-block;\n}\n.spreadsheet-icon-img {\n background-image: url("+i(s(21))+");\n position: absolute;\n width: 262px;\n height: 444px;\n opacity: 0.55;\n}\n.spreadsheet-icon-img.undo {\n left: 0;\n top: 0;\n}\n.spreadsheet-icon-img.redo {\n left: -18px;\n top: 0;\n}\n.spreadsheet-icon-img.print {\n left: -36px;\n top: 0;\n}\n.spreadsheet-icon-img.paintformat {\n left: -54px;\n top: 0;\n}\n.spreadsheet-icon-img.clearformat {\n left: -72px;\n top: 0;\n}\n.spreadsheet-icon-img.bold {\n left: -90px;\n top: 0;\n}\n.spreadsheet-icon-img.italic {\n left: -108px;\n top: 0;\n}\n.spreadsheet-icon-img.underline {\n left: -126px;\n top: 0;\n}\n.spreadsheet-icon-img.strikethrough {\n left: -144px;\n top: 0;\n}\n.spreadsheet-icon-img.text-color {\n left: -162px;\n top: 0;\n}\n.spreadsheet-icon-img.cell-color {\n left: -180px;\n top: 0;\n}\n.spreadsheet-icon-img.merge {\n left: -198px;\n top: 0;\n}\n.spreadsheet-icon-img.align-left {\n left: -216px;\n top: 0;\n}\n.spreadsheet-icon-img.align-center {\n left: -234px;\n top: 0;\n}\n.spreadsheet-icon-img.align-right {\n left: 0;\n top: -18px;\n}\n.spreadsheet-icon-img.valign-top {\n left: -18px;\n top: -18px;\n}\n.spreadsheet-icon-img.valign-middle {\n left: -36px;\n top: -18px;\n}\n.spreadsheet-icon-img.valign-bottom {\n left: -54px;\n top: -18px;\n}\n.spreadsheet-icon-img.textwrap {\n left: -72px;\n top: -18px;\n}\n.spreadsheet-icon-img.autofilter {\n left: -90px;\n top: -18px;\n}\n.spreadsheet-icon-img.formula {\n left: -108px;\n top: -18px;\n}\n.spreadsheet-icon-img.arrow-down {\n left: -126px;\n top: -18px;\n}\n.spreadsheet-icon-img.arrow-right {\n left: -144px;\n top: -18px;\n}\n",""])},function(e,t,s){var i=s(24);"string"==typeof i&&(i=[[e.i,i,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};s(20)(i,r);i.locals&&(e.exports=i.locals)},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Select=class{constructor(e,t,s){this.start=e,this.stop=t,this.canMerge=s}forEach(e){const[t,s]=this.start,[i,r]=this.stop;for(let n=t;n<=i;n++)for(let l=s;l<=r;l++)e(n,l,n-t,l-s,i-t+1,r-s+1)}rowIndex(e){return this.start[0]+e%this.rowLen()}colIndex(e){return this.start[1]+e%this.colLen()}rowLen(){return this.stop[0]-this.start[0]+1}colLen(){return this.stop[1]-this.start[1]+1}cellLen(){return this.rowLen()*this.colLen()}contains(e,t){const[s,i]=this.start,[r,n]=this.stop;return s<=e&&r>=e&&i<=t&&n>=t}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fonts=[{key:"Microsoft YaHei",title:"微软雅黑"},{key:"STFangsong",title:"华文仿宋"},{key:"Comic Sans MS",title:"Comic Sans MS"},{key:"Arial",title:"Arial"},{key:"Courier New",title:"Courier New"},{key:"Verdana",title:"Verdana"}]},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(8),r=s(27),n=s(7),l=s(5),o=s(6),h=s(26);class a{constructor(e){this.type=e,this.values=[]}add(e,t,s){this.values.push([e,t,s])}}t.History=a;t.Spreadsheet=class{constructor(e={}){if(this.histories=[],this.histories2=[],this.currentCellIndexes=[0,0],this.select=null,this.copySelect=null,this.cutSelect=null,this.change=(()=>{}),this.formats=e.formats||i.formats,this.fonts=e.fonts||r.fonts,this.formulas=e.formulas||n.formulas,this.data={rowHeight:22,colWidth:100,cell:l.defaultCell},e.data){const{data:t}=e;for(let e of["rowHeight","colWidth","rows","cols","cells"])t[e]&&(this.data[e]=t[e]);Object.assign(this.data.cell,t.cell||{})}}buildSelect(e,t){const s=p(e),i=p(t);let r=s.row,n=s.col,l=i.row,o=i.col;r>l&&(r=i.row,l=s.row),n>o&&(n=i.col,o=s.col);let[a,d]=b((e,t)=>this.getCell(e,t),r,l,n,o),[c,u]=f((e,t)=>this.getCell(e,t),a,d,n,o);for(;;){const[e,t]=b((e,t)=>this.getCell(e,t),a,d,c,u);let[s,i]=f((e,t)=>this.getCell(e,t),a,d,c,u);if(a===e&&d===t&&c===s&&u===i)break;a=e,d=t,c=s,u=i}const g=this.getCell(a,c);let x=a+(g&&g.rowspan||1)-1===d&&c+(g&&g.colspan||1)-1===u;return this.select=new h.Select([a,c],[d,u],!x),this.select}defaultRowHeight(){return this.data.rowHeight||22}defaultColWidth(){return this.data.colWidth||100}copy(){this.copySelect=this.select}cut(){this.cutSelect=this.select}paste(e,t,s){let i=this.copySelect;if(this.cutSelect&&(i=this.cutSelect,this.cutSelect=null),i&&this.select){const r=new a("cells");"copyformat"===t?this.select.forEach((n,l,o,h,a,d)=>{if(i){const a=i.rowIndex(o),d=i.colIndex(h),[c,u]=this.copyCell(a,d,n,l,t,e,s);r.add([n,l],c,u)}}):i.forEach((i,n,l,o,h,a)=>{if(this.select){const h=this.select.start[0]+l,a=this.select.start[1]+o,[d,c]=this.copyCell(i,n,h,a,t,e,s);r.add([h,a],d,c)}}),this.histories.push(r),this.change(this.data)}}insert(e,t,s){if(this.select){const{cells:t}=this.data,[i,r]=this.select.start;if(!t)return;const n=new a("cells");if("row"===e){const e={};Object.keys(t).forEach(r=>{let l=parseInt(r),o=t[l];i<=l&&Object.keys(o).forEach(e=>{let t=parseInt(e);s(l,t,{}),n.add([l,t],o[t],void 0),s(l+1,t,o[t]||{}),n.add([l+1,t],this.getCell(l+1,t),o[t])}),e[i<=l?l+1:l]=t[l]}),this.data.cells=e}else"col"===e&&Object.keys(t).forEach(e=>{let i=parseInt(e),l=t[i],o={};Object.keys(l).forEach(e=>{let t=parseInt(e);r<=t&&(s(i,t,{}),n.add([i,t],l[t],void 0),s(i,t+1,l[t]||{}),n.add([i,t+1],this.getCell(i,t+1),l[t])),o[r<=t?t+1:t]=l[t]}),t[i]=o});this.histories.push(n)}}batchPaste(e,t,s,i,r,n,l){if(this.select){const e=new a("cells");for(let o=t;o<=i;o++)for(let i=s;i<=r;i++){const r=this.select.rowIndex(o-t),h=this.select.colIndex(i-s),[a,d]=this.copyCell(r,h,o,i,n?"seqCopy":"copy",l,()=>{});e.add([o,i],a,d)}this.histories.push(e),this.change(this.data)}}copyCell(e,t,s,i,r,l,o){const h=this.getCell(e,t),a=s-e,d=i-t;if(h){let c=this.getCell(s,i);const u=Object.assign({},h);if(h.merge){const[e,t]=h.merge;u.merge=[e+a,t+d]}if("cut"===r&&o(e,t,this.cell(e,t,{})),"copyformat"===r)c&&c.text&&(u.text=c.text);else{const l=u.text;l&&!/^\s*$/.test(l)&&(/^\d*$/.test(l)&&"seqCopy"===r?u.text=parseInt(l)+(s-e)+(i-t)+"":-1!==l.indexOf("=")&&(u.text=n.formulaReplaceParam(l,a,d)))}return l(s,i,this.cell(s,i,u)),[c,u]}return[null,null]}isRedo(){return this.histories2.length>0}redo(e){const{histories:t,histories2:s}=this;if(s.length>0){const i=s.pop();i&&(this.resetByHistory(i,e,"redo"),t.push(i),this.change(this.data))}return this.isRedo()}isUndo(){return this.histories.length>0}undo(e){const{histories:t,histories2:s}=this;if(t.length>0){const i=t.pop();i&&(this.resetByHistory(i,e,"undo"),s.push(i),this.change(this.data))}return this.isUndo()}resetByHistory(e,t,s){e.values.forEach(([i,r,n])=>{if("cells"===e.type){const e="undo"===s?r:n,l=this.getCell(i[0],i[1]);if(l)if(3===i.length){const s={};s[i[2]]=e,t(i[0],i[1],e?this.cell(i[0],i[1],s,!0):this.cell(i[0],i[1],c(l,i[2])))}else t(i[0],i[1],this.cell(i[0],i[1],e||{}));else if(3===i.length){if(e){const s={};s[i[2]]=e,t(i[0],i[1],this.cell(i[0],i[1],s))}}else t(i[0],i[1],this.cell(i[0],i[1],e||{}))}})}clearformat(e){const{select:t}=this;if(null!==t){const s=new a("cells");t.forEach((t,i,r,n,l,o)=>{let h=this.getCell(t,i);h&&(s.add([t,i],h,{text:h.text}),h=this.cell(t,i,{text:h.text}),e(t,i,h))}),this.histories.push(s),this.change(this.data)}}merge(e,t,s){const{select:i}=this;if(null!==i&&i.cellLen()>1){const r=new a("cells");let n=0,l=[0,0];i.forEach((o,h,a,d,u,p)=>{if(0==n++){l=[o,h];let s={};if(u>1&&(s.rowspan=u),p>1&&(s.colspan=p),i.canMerge){r.add([o,h,"rowspan"],void 0,u),r.add([o,h,"colspan"],void 0,p);let t=this.cell(o,h,s,!0);e(o,h,t)}else{const e=this.getCell(o,h);if(null!==e){r.add([o,h,"rowspan"],e.rowspan,void 0),r.add([o,h,"colspan"],e.colspan,void 0);let s=this.cell(o,h,c(e,"rowspan","colspan","merge"));t(o,h,s)}}}else{let e={invisible:i.canMerge};if(i.canMerge){r.add([o,h,"invisible"],void 0,i.canMerge),e.merge=l;let t=this.cell(o,h,e,!0);s(o,h,t)}else{const e=this.getCell(o,h);if(null!==e){r.add([o,h,"invisible"],e.invisible,void 0);let t=this.cell(o,h,c(e,"rowspan","colspan","merge","invisible"));s(o,h,t)}}}}),this.histories.push(r),i.canMerge=!i.canMerge,this.change(this.data)}}cellAttr(e,t,s){let i={};i[e]=t;const r=t===this.data.cell[e];if(null!==this.select){const n=new a("cells");this.select.forEach((l,o)=>{const h=this.getCell(l,o);n.add([l,o,e],null!==h?h[e]:void 0,t);let a=this.cell(l,o,r?c(h,e):i,!r);s(l,o,a)}),this.histories.push(n)}this.change(this.data)}cellText(e,t){if(this.currentCellIndexes){const s=new a("cells"),[i,r]=this.currentCellIndexes,n=this.getCell(i,r);s.add([i,r,"text"],null!==n?n.text:void 0,e);const l=this.cell(i,r,{text:e},!0);return t(i,r,l),this.histories.push(s),this.change(this.data),l}return null}currentCell(e){void 0!==e&&(this.currentCellIndexes=e);const[t,s]=this.currentCellIndexes;return this.getCell(t,s)}cell(e,t,s,i=!1){return this.data.cells=this.data.cells||{},this.data.cells[e]=this.data.cells[e]||{},this.data.cells[e][t]=this.data.cells[e][t]||{},i?Object.assign(this.data.cells[e][t],s):s&&(this.data.cells[e][t]=s),this.data.cells[e][t]}getCell(e,t){return this.data.cells&&this.data.cells[e]&&this.data.cells[e][t]?this.data.cells[e][t]:null}getFont(e){return this.fonts.filter(t=>t.key===e)[0]}getFormat(e){return this.formats.filter(t=>t.key===e)[0]}row(e,t){const{data:s}=this;return void 0!==t&&(s.rows=s.rows||{},s.rows[e]=s.rows[e]||{},s.rows[e].height=t),Object.assign({height:s.rowHeight},s.rows?s.rows[e]:{})}rows(){const{data:e}=this;let t=d(100,e.rows);return u(t,e=>this.row(e))}col(e,t){const{data:s}=this;return void 0!==t&&(s.cols=s.cols||{},s.cols[e]=s.cols[e]||{},s.cols[e].width=t),Object.assign({width:s.colWidth,title:o.alphabet(e)},s.cols?s.cols[e]:{})}cols(){const{data:e}=this;let t=d(26,e.cols);return u(t,e=>this.col(e))}};const d=function(e,t){if(t){const s=Math.max(...Object.keys(t).map(e=>parseInt(e)));if(s>e)return s}return e},c=function(e,...t){const s={};return e&&Object.keys(e).forEach(i=>{-1===t.indexOf(i)&&(s[i]=e[i])}),s},u=function(e,t){const s=[];for(let i=0;i<e;i++)s.push(t(i));return s},p=e=>{const{offsetTop:t,offsetLeft:s,offsetHeight:i,offsetWidth:r}=e;return{row:parseInt(e.getAttribute("row-index")),col:parseInt(e.getAttribute("col-index")),rowspan:parseInt(e.getAttribute("rowspan")),colspan:parseInt(e.getAttribute("colspan")),left:s,top:t,width:r,height:i}},f=(e,t,s,i,r)=>{let n=i,l=r;for(let r=t;r<=s;r++){let t=i,s=e(r,t);s&&s.merge&&(t+=s.merge[1]-t),t<n&&(n=t);const o=(s=e(r,t=l))?s.colspan:1;if(parseInt(o)>1)t+=parseInt(o);else if(s&&s.merge){const[i,r]=s.merge;t+=e(i,r).colspan+(r-t)}t-1>l&&(l=t-1)}return[n,l]},b=(e,t,s,i,r)=>{let n=t,l=s;for(let s=i;s<=r;s++){let i=t,r=e(i,s);r&&r.merge&&(i+=r.merge[0]-i),i<n&&(n=i);const o=(r=e(i=l,s))?r.rowspan:1;if(parseInt(o)>1)i+=parseInt(o);else if(r&&r.merge){const[t,s]=r.merge;i+=e(t,s).rowspan+(t-i)}i-1>l&&(l=i-1)}return[n,l]}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(28);s(25);const r=s(18),n=s(12),l=s(9),o=s(0);t.LocalSpreadsheet=class{constructor(e,t={}){this.el=e,this.refs={},this.change=(()=>{}),this.ss=new i.Spreadsheet(t.d||{}),this.editorbar=new l.Editorbar,this.editorbar.change=(e=>this.editorbarChange(e)),this.toolbar=new n.Toolbar(this.ss),this.toolbar.change=((e,t)=>this.toolbarChange(e,t)),this.toolbar.undo=(()=>this.table.undo()),this.toolbar.redo=(()=>this.table.redo()),this.table=new r.Table(this.ss,t.bodyHeight),this.table.change=(e=>{this.toolbar.setRedoAble(this.ss.isRedo()),this.toolbar.setUndoAble(this.ss.isUndo()),this.change(e)}),this.table.editorChange=(e=>this.editorChange(e)),this.table.clickCell=((e,t,s)=>this.clickCell(e,t,s)),this.render()}render(){this.el.appendChild(o.h().class("spreadsheet").children([o.h().class("spreadsheet-bars").children([this.toolbar.el,this.editorbar.el]),this.table.el]).el)}toolbarChange(e,t){"merge"!==e?"clearformat"!==e?"paintformat"!==e?this.table.setCellAttr(e,t):this.table.copyformat():this.table.clearformat():this.table.merge()}editorbarChange(e){this.table.setValueWithText(e)}editorChange(e){this.editorbar.setValue(e)}clickCell(e,t,s){const i=this.ss.cols();this.editorbar.set(`${i[t].title}${e+1}`,s),this.toolbar.set(this.table.td(e,t),s)}}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(29);function r(e,t){return new i.LocalSpreadsheet(e,t)}t.default=r,window.xspreadsheet=r}]);
//# sourceMappingURL=xspreadsheet.js.map