@tachybase/module-hera 1.9.48 → 2.0.6

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,25 +1,25 @@
1
1
  (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="@tachybase/module-hera",e.appendChild(document.createTextNode('body{margin:0}.x-spreadsheet{-webkit-user-select:none;user-select:none;box-sizing:content-box;-webkit-font-smoothing:antialiased;background:#fff;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;font-size:13px;line-height:normal}.x-spreadsheet textarea{font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif}.x-spreadsheet-sheet{position:relative;overflow:hidden}.x-spreadsheet-table{vertical-align:bottom}.x-spreadsheet-tooltip{color:#fff;z-index:201;background:#000;border-radius:1px;padding:5px 10px;font-family:inherit;font-size:12px;position:absolute}.x-spreadsheet-tooltip:before{pointer-events:none;content:"";background:inherit;z-index:1;width:8px;height:8px;position:absolute;top:-4px;left:calc(50% - 4px);transform:rotate(45deg);box-shadow:1px 1px 3px -1px #0000004d}.x-spreadsheet-color-palette{padding:5px}.x-spreadsheet-color-palette table{border-collapse:separate;border-spacing:2px;background:#fff;margin:0;padding:0}.x-spreadsheet-color-palette table td{cursor:pointer;border:1px solid #0000;margin:0}.x-spreadsheet-color-palette table td:hover{border-color:#ddd}.x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell{width:16px;height:16px}.x-spreadsheet-border-palette{padding:6px}.x-spreadsheet-border-palette table{border-collapse:separate;border-spacing:0;table-layout:fixed;background:#fff;margin:0;padding:0}.x-spreadsheet-border-palette table td{margin:0}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left{border-right:1px solid #eee;padding-right:6px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell{cursor:pointer;text-align:center;width:30px;height:30px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell .x-spreadsheet-icon-img{opacity:.8}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover{background-color:#eee}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-right{padding-left:6px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-toolbar-btn{margin-top:0;margin-bottom:3px}.x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type{position:relative;top:-3px;left:0}.x-spreadsheet-dropdown{position:relative}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-content{z-index:200;background:#fff;position:absolute;box-shadow:1px 2px 5px 2px #33333326}.x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content{top:calc(100% + 5px);left:0}.x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content{top:calc(100% + 5px);right:0}.x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);left:0}.x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);right:0}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-title{padding:0 5px;display:inline-block}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-left{margin-left:4px}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right{width:10px;margin-right:4px}.x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right .arrow-down{left:-130px}.x-spreadsheet-resizer{z-index:11;position:absolute}.x-spreadsheet-resizer .x-spreadsheet-resizer-hover{background-color:#4b89ff40}.x-spreadsheet-resizer .x-spreadsheet-resizer-line{position:absolute}.x-spreadsheet-resizer.horizontal{cursor:row-resize}.x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line{border-bottom:2px dashed #4b89ff;bottom:0;left:0}.x-spreadsheet-resizer.vertical{cursor:col-resize}.x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line{border-right:2px dashed #4b89ff;top:0;right:0}.x-spreadsheet-scrollbar{opacity:.9;z-index:12;background-color:#f4f5f8;position:absolute;bottom:0;right:0}.x-spreadsheet-scrollbar.horizontal{right:15px;overflow:scroll hidden}.x-spreadsheet-scrollbar.horizontal>div{background:#ddd;height:1px}.x-spreadsheet-scrollbar.vertical{bottom:15px;overflow:hidden scroll}.x-spreadsheet-scrollbar.vertical>div{background:#ddd;width:1px}.x-spreadsheet-overlayer{z-index:10;position:absolute;top:0;left:0}.x-spreadsheet-overlayer .x-spreadsheet-overlayer-content{pointer-events:none;width:100%;height:100%;position:absolute;overflow:hidden}.x-spreadsheet-editor,.x-spreadsheet-selector{box-sizing:content-box;pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0;overflow:hidden}.x-spreadsheet-selector .hide-input{z-index:0;position:absolute}.x-spreadsheet-selector .hide-input input{width:0;padding:0;border:none!important}.x-spreadsheet-selector .x-spreadsheet-selector-area{z-index:5;background:#4b89ff1a;border:2px solid #4b89ff;position:absolute}.x-spreadsheet-selector .x-spreadsheet-selector-clipboard,.x-spreadsheet-selector .x-spreadsheet-selector-autofill{z-index:100;background:none;position:absolute}.x-spreadsheet-selector .x-spreadsheet-selector-clipboard{border:2px dashed #4b89ff}.x-spreadsheet-selector .x-spreadsheet-selector-autofill{border:1px dashed #00000073}.x-spreadsheet-selector .x-spreadsheet-selector-corner{pointer-events:auto;cursor:crosshair;background:#4b89ff;border:2px solid #fff;width:5px;height:5px;font-size:0;position:absolute;bottom:-5px;right:-5px}.x-spreadsheet-editor{z-index:20}.x-spreadsheet-editor .x-spreadsheet-editor-area{text-align:left;z-index:100;pointer-events:auto;border:2px solid #4b89ff;line-height:0;position:absolute}.x-spreadsheet-editor .x-spreadsheet-editor-area textarea{box-sizing:content-box;resize:none;text-align:start;color:inherit;white-space:normal;word-wrap:break-word;border:none;outline:none;margin:0;padding:0 3px;font:400 13px/22px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif;overflow-y:hidden}.x-spreadsheet-editor .x-spreadsheet-editor-area .textline{visibility:hidden;position:fixed;top:0;left:0;overflow:hidden}.x-spreadsheet-item{-webkit-user-select:none;user-select:none;color:#000000e6;cursor:default;text-align:left;background:0;border:1px solid #0000;outline:none;height:26px;padding:2px 10px;line-height:26px;list-style:none;overflow:hidden}.x-spreadsheet-item.disabled{pointer-events:none;opacity:.5}.x-spreadsheet-item:hover,.x-spreadsheet-item.active{background:#0000000d}.x-spreadsheet-item.divider{border:none;border-bottom:1px solid #0000001a;height:0;margin:5px 0;padding:0}.x-spreadsheet-item .label{float:right;opacity:.65;font-size:1em}.x-spreadsheet-item.state,.x-spreadsheet-header.state{position:relative;padding-left:35px!important}.x-spreadsheet-item.state:before,.x-spreadsheet-header.state:before{content:"";background:#00000014;border-radius:2px;width:10px;height:10px;position:absolute;top:calc(50% - 5px);left:12px}.x-spreadsheet-item.state.checked:before,.x-spreadsheet-header.state.checked:before{background:#4b89ff}.x-spreadsheet-checkbox{backface-visibility:hidden;vertical-align:baseline;outline:0;font-size:1rem;font-style:normal;line-height:1em;display:inline-block;position:relative}.x-spreadsheet-checkbox>input{z-index:-1;outline:0;position:absolute;top:0;left:0;opacity:0!important}.x-spreadsheet-suggest,.x-spreadsheet-contextmenu,.x-spreadsheet-sort-filter{z-index:100;pointer-events:auto;background:#fff;width:260px;position:absolute;overflow:auto;box-shadow:1px 2px 5px 2px #33333326}.x-spreadsheet-suggest{width:200px}.x-spreadsheet-filter{border:1px solid #e9e9e9;margin:10px;font-size:12px}.x-spreadsheet-filter .x-spreadsheet-header{background:#f8f8f9;border-bottom:1px solid #e9e9e9;border-left:1px solid #0000;padding:.5em .75em}.x-spreadsheet-filter .x-spreadsheet-body{height:200px;overflow-y:auto}.x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item{height:20px;line-height:20px}.x-spreadsheet-sort-filter .x-spreadsheet-buttons{margin:10px}.x-spreadsheet-toolbar,.x-spreadsheet-bottombar{text-align:left;background:#f5f6f7;height:40px;padding:0 30px;display:flex}.x-spreadsheet-bottombar{border-top:1px solid #e0e2e4;position:relative}.x-spreadsheet-bottombar .x-spreadsheet-menu>li{vertical-align:middle;border-right:1px solid #e8eaed;height:40px;padding-top:0;padding-bottom:0;line-height:40px}.x-spreadsheet-menu{-webkit-user-select:none;user-select:none;margin:0;padding:0;list-style:none}.x-spreadsheet-menu>li{float:left;vertical-align:middle;text-align:left;color:#80868b;white-space:nowrap;cursor:pointer;margin:0;padding:.785em 1em;font-weight:700;line-height:1.25em;transition:all .3s}.x-spreadsheet-menu>li.active{color:#000000a6;background-color:#fff}.x-spreadsheet-menu>li .x-spreadsheet-icon{margin:0 6px}.x-spreadsheet-menu>li .x-spreadsheet-icon .x-spreadsheet-icon-img:hover{opacity:.85}.x-spreadsheet-menu>li .x-spreadsheet-dropdown{display:inline-block}.x-spreadsheet-toolbar{border-bottom:1px solid #e0e2e4}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btns{display:inline-flex}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-more{text-align:left;padding:0 6px 6px}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-toolbar-divider{margin-top:0}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn{text-align:center;border:1px solid #0000;border-radius:2px;flex:none;min-width:26px;height:26px;margin:6px 1px 0;padding:0;line-height:26px;display:inline-block}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.disabled{pointer-events:none;opacity:.5}.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn:hover,.x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.active{background:#00000014}.x-spreadsheet-toolbar-divider{vertical-align:middle;border-right:1px solid #e0e2e4;width:0;height:18px;margin:12px 3px 0;display:inline-block}.x-spreadsheet-print{z-index:100;flex-direction:column;width:100%;height:100%;display:flex;position:absolute;top:0;left:0}.x-spreadsheet-print-bar{background:#424242;height:60px;padding:0 30px;line-height:60px}.x-spreadsheet-print-bar .-title{color:#fff;float:left;font-size:1.2em;font-weight:700}.x-spreadsheet-print-bar .-right{float:right;margin-top:12px}.x-spreadsheet-print-content{background:#d0d0d0;flex-direction:row;flex:auto;height:calc(100% - 60px);display:flex}.x-spreadsheet-print-content .-sider{background:#fff;border-left:2px solid #ccc;flex:0 0 300px;width:300px}.x-spreadsheet-print-content .-content{flex:auto;height:100%;overflow:auto scroll}.x-spreadsheet-canvas-card-wraper{margin:40px 20px}.x-spreadsheet-canvas-card{page-break-before:auto;page-break-after:always;background:#fff;margin:auto;box-shadow:0 8px 10px 1px #00000024,0 3px 14px 3px #0000001f,0 4px 5px #0003}.x-spreadsheet-calendar{color:#000000a6;-webkit-user-select:none;user-select:none;background:#fff}.x-spreadsheet-calendar .calendar-header{text-align:center;float:left;background:#f9fafb;width:100%;font-weight:700;line-height:30px}.x-spreadsheet-calendar .calendar-header .calendar-header-left{float:left;padding-left:5px}.x-spreadsheet-calendar .calendar-header .calendar-header-right{float:right}.x-spreadsheet-calendar .calendar-header .calendar-header-right a{border-radius:2px;margin-right:2px;padding:3px 0}.x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover{background:#00000014}.x-spreadsheet-calendar .calendar-body{border-collapse:collapse;border-spacing:0}.x-spreadsheet-calendar .calendar-body th,.x-spreadsheet-calendar .calendar-body td{width:100% / 7;text-align:center;min-width:32px;padding:0;font-weight:700;line-height:30px}.x-spreadsheet-calendar .calendar-body td>.cell:hover{background:#ecf6fd}.x-spreadsheet-calendar .calendar-body td>.cell.active,.x-spreadsheet-calendar .calendar-body td>.cell.active:hover{color:#2185d0;background:#ecf6fd}.x-spreadsheet-calendar .calendar-body td>.cell.disabled{pointer-events:none;opacity:.5}.x-spreadsheet-datepicker{z-index:10;width:auto;position:absolute;top:calc(100% + 5px);left:0;box-shadow:2px 2px 5px #0003}.x-spreadsheet-buttons{justify-content:flex-end;display:flex}.x-spreadsheet-buttons .x-spreadsheet-button{margin-left:8px}.x-spreadsheet-button{white-space:nowrap;text-align:center;cursor:pointer;color:#0009;vertical-align:baseline;zoom:1;-webkit-user-select:none;user-select:none;background:#e0e1e2;border-radius:3px;outline:none;min-height:1em;padding:.75em 1em;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;font-size:1em;font-weight:700;line-height:1em;text-decoration:none;transition:all .1s linear;display:inline-block}.x-spreadsheet-button.active,.x-spreadsheet-button:hover{color:#000c;background-color:#c0c1c2}.x-spreadsheet-button.primary{color:#fff;background-color:#2185d0}.x-spreadsheet-button.primary:hover,.x-spreadsheet-button.primary.active{color:#fff;background-color:#1678c2}.x-spreadsheet-form-input{color:#000000de;font-size:1em;font-weight:400;display:inline-flex;position:relative}.x-spreadsheet-form-input input{z-index:1;-webkit-tap-highlight-color:#fff0;text-align:left;background:#fff;border:1px solid #e9e9e9;border-radius:3px;outline:0;flex:1 0 auto;max-width:100%;height:30px;margin:0;padding:0 8px;line-height:30px;transition:box-shadow .1s,border-color .1s;box-shadow:inset 0 1px 2px #0a0a0a0f}.x-spreadsheet-form-input input:focus{border-color:#4b89ff;box-shadow:inset 0 1px 2px #4b89ff33}.x-spreadsheet-form-select{cursor:pointer;color:#000000de;-webkit-user-select:none;user-select:none;background:#fff;border:1px solid #e9e9e9;border-radius:2px;display:inline-block;position:relative;box-shadow:inset 0 1px 2px #0a0a0a0f}.x-spreadsheet-form-select .input-text{text-overflow:ellipsis;white-space:nowrap;width:auto;min-width:60px;height:30px;padding:0 8px;line-height:30px}.x-spreadsheet-form-fields{flex-flow:wrap;display:flex}.x-spreadsheet-form-fields .x-spreadsheet-form-field{flex:0 auto}.x-spreadsheet-form-fields .x-spreadsheet-form-field .label{margin:0 10px 0 0;display:inline-block}.x-spreadsheet-form-field{vertical-align:middle;margin-bottom:10px;margin-left:10px;display:block}.x-spreadsheet-form-field:first-child{margin-left:0}.x-spreadsheet-form-field.error .x-spreadsheet-form-select,.x-spreadsheet-form-field.error input{border-color:#f04134}.x-spreadsheet-form-field .tip{color:#f04134;font-size:.9em}.x-spreadsheet-dimmer{text-align:center;vertical-align:middle;opacity:0;-webkit-user-select:none;user-select:none;z-index:1000;background-color:#0009;width:100%;height:100%;transition:background-color .5s linear;animation-duration:.5s;animation-fill-mode:both;display:none;position:absolute;top:0!important;left:0!important}.x-spreadsheet-dimmer.active{opacity:1;display:block}form fieldset{border:none}form fieldset label{color:#666;margin-bottom:.5em;font-size:1em;display:block}form fieldset select{background-color:#fff;border:none;border-bottom:2px solid #ddd;border-radius:2px;width:100%;padding:.5em .85em;font-size:1.1em}.x-spreadsheet-modal,.x-spreadsheet-toast{z-index:1001;text-align:left;color:#000000de;background-color:#fff;background-clip:padding-box;border:1px solid #0000001a;border-radius:4px;min-width:360px;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;font-size:13px;line-height:1.25em;position:fixed;box-shadow:0 2px 8px #0003}.x-spreadsheet-toast{background-color:#ffffffd9}.x-spreadsheet-modal-header,.x-spreadsheet-toast-header{background-color:#ffffffd9;background-clip:padding-box;border-bottom:1px solid #0000000d;border-radius:4px 4px 0 0;font-weight:600}.x-spreadsheet-modal-header .x-spreadsheet-icon,.x-spreadsheet-toast-header .x-spreadsheet-icon{border-radius:18px;position:absolute;top:.65em;right:.8em}.x-spreadsheet-modal-header .x-spreadsheet-icon:hover,.x-spreadsheet-toast-header .x-spreadsheet-icon:hover{opacity:1;background:#00000014}.x-spreadsheet-toast-header{color:#f2711c}.x-spreadsheet-modal-header{background:#00000014;border-bottom:1px solid #e0e2e4;font-size:1.0785em}.x-spreadsheet-modal-header,.x-spreadsheet-modal-content,.x-spreadsheet-toast-header,.x-spreadsheet-toast-content{padding:.75em 1em}@media screen and (width >= 320px) and (width <= 480px){.x-spreadsheet-toolbar{display:none}}.x-spreadsheet-icon{text-align:center;vertical-align:middle;-webkit-user-select:none;user-select:none;width:18px;height:18px;margin:1px 1px 2px;line-height:0;display:inline-block;position:relative;overflow:hidden}.x-spreadsheet-icon .x-spreadsheet-icon-img{opacity:.56;width:262px;height:444px;position:absolute}.x-spreadsheet-icon .x-spreadsheet-icon-img.undo{top:0;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.redo{top:0;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.print{top:0;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.paintformat{top:0;left:-54px}.x-spreadsheet-icon .x-spreadsheet-icon-img.clearformat{top:0;left:-72px}.x-spreadsheet-icon .x-spreadsheet-icon-img.font-bold{top:0;left:-90px}.x-spreadsheet-icon .x-spreadsheet-icon-img.font-italic{top:0;left:-108px}.x-spreadsheet-icon .x-spreadsheet-icon-img.underline{top:0;left:-126px}.x-spreadsheet-icon .x-spreadsheet-icon-img.strike{top:0;left:-144px}.x-spreadsheet-icon .x-spreadsheet-icon-img.color{top:0;left:-162px}.x-spreadsheet-icon .x-spreadsheet-icon-img.bgcolor{top:0;left:-180px}.x-spreadsheet-icon .x-spreadsheet-icon-img.merge{top:0;left:-198px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-left{top:0;left:-216px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-center{top:0;left:-234px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-right{top:-18px;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-top{top:-18px;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-middle{top:-18px;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.align-bottom{top:-18px;left:-54px}.x-spreadsheet-icon .x-spreadsheet-icon-img.textwrap{top:-18px;left:-72px}.x-spreadsheet-icon .x-spreadsheet-icon-img.autofilter{top:-18px;left:-90px}.x-spreadsheet-icon .x-spreadsheet-icon-img.formula{top:-18px;left:-108px}.x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-down{top:-18px;left:-126px}.x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-right{top:-18px;left:-144px}.x-spreadsheet-icon .x-spreadsheet-icon-img.link{top:-18px;left:-162px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chart{top:-18px;left:-180px}.x-spreadsheet-icon .x-spreadsheet-icon-img.freeze{top:-18px;left:-198px}.x-spreadsheet-icon .x-spreadsheet-icon-img.ellipsis{top:-18px;left:-216px}.x-spreadsheet-icon .x-spreadsheet-icon-img.add{top:-18px;left:-234px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-all{top:-36px;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-inside{top:-36px;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-horizontal{top:-36px;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-vertical{top:-36px;left:-54px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-outside{top:-36px;left:-72px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-left{top:-36px;left:-90px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-top{top:-36px;left:-108px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-right{top:-36px;left:-126px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-bottom{top:-36px;left:-144px}.x-spreadsheet-icon .x-spreadsheet-icon-img.border-none{top:-36px;left:-162px}.x-spreadsheet-icon .x-spreadsheet-icon-img.line-color{top:-36px;left:-180px}.x-spreadsheet-icon .x-spreadsheet-icon-img.line-type{top:-36px;left:-198px}.x-spreadsheet-icon .x-spreadsheet-icon-img.close{top:-36px;left:-234px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-down{top:-54px;left:0}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-up{top:-54px;left:-18px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-left{top:-54px;left:-36px}.x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-right{top:-54px;left:-54px}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- (function(y,P){typeof exports=="object"&&typeof module!="undefined"?P(exports,require("@tachybase/client"),require("@tachybase/components"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("@ant-design/icons"),require("antd"),require("lodash"),require("@tachybase/evaluators/client"),require("react-dom"),require("ahooks"),require("@tachybase/utils/client"),require("react-router-dom"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/components","react/jsx-runtime","react","@tachybase/schema","@ant-design/icons","antd","lodash","@tachybase/evaluators/client","react-dom","ahooks","@tachybase/utils/client","react-router-dom","dayjs"],P):(y=typeof globalThis!="undefined"?globalThis:y||self,P(y["@tachybase/module-hera"]={},y["@tachybase/client"],y["@tachybase/components"],y.jsxRuntime,y.react,y["@tachybase/schema"],y["@ant-design/icons"],y.antd,y.lodash,y["@tachybase/evaluators"],y["react-dom"],y.ahooks,y["@tachybase/utils"],y["react-router-dom"],y.dayjs))})(this,function(exports,client,components$1,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__,React,schema,icons,antd,_,client$1,ReactDOM,ahooks,client$2,reactRouterDom,dayjs){"use strict";var te=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var J=y=>{throw TypeError(y)};var q=(y,P,A)=>P in y?te(y,P,{enumerable:!0,configurable:!0,writable:!0,value:A}):y[P]=A,S=(y,P)=>{for(var A in P||(P={}))ne.call(P,A)&&q(y,A,P[A]);if(Z)for(var A of Z(P))re.call(P,A)&&q(y,A,P[A]);return y},F=(y,P)=>se(y,ie(P));var Q=(y,P,A)=>q(y,typeof P!="symbol"?P+"":P,A),ee=(y,P,A)=>P.has(y)||J("Cannot "+A);var D=(y,P,A)=>(ee(y,P,"read from private field"),A?A.call(y):P.get(y)),U=(y,P,A)=>P.has(y)?J("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(y):P.set(y,A),N=(y,P,A,M)=>(ee(y,P,"write to private field"),M?M.call(y,A):P.set(y,A),A);var T=(y,P,A)=>new Promise((M,I)=>{var L=n=>{try{$(A.next(n))}catch(e){I(e)}},B=n=>{try{$(A.throw(n))}catch(e){I(e)}},$=n=>n.done?M(n.value):Promise.resolve(n.value).then(L,B);$((A=A.apply(y,P)).next())});var y,P,A,M,I,L;function _interopNamespaceDefault(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>n[s]})}}return e.default=n,Object.freeze(e)}const React__namespace=_interopNamespaceDefault(React);var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var FileSaver_min={exports:{}};(function(n,e){(function(s,i){i()})(commonjsGlobal,function(){function s(d,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(d.type)?new Blob(["\uFEFF",d],{type:d.type}):d}function i(d,u,f){var m=new XMLHttpRequest;m.open("GET",d),m.responseType="blob",m.onload=function(){c(m.response,u,f)},m.onerror=function(){console.error("could not download file")},m.send()}function r(d){var u=new XMLHttpRequest;u.open("HEAD",d,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function o(d){try{d.dispatchEvent(new MouseEvent("click"))}catch(f){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),d.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof commonjsGlobal=="object"&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,a=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(d,u,f){var m=l.URL||l.webkitURL,p=document.createElement("a");u=u||d.name||"download",p.download=u,p.rel="noopener",typeof d=="string"?(p.href=d,p.origin===location.origin?o(p):r(p.href)?i(d,u,f):o(p,p.target="_blank")):(p.href=m.createObjectURL(d),setTimeout(function(){m.revokeObjectURL(p.href)},4e4),setTimeout(function(){o(p)},0))}:"msSaveOrOpenBlob"in navigator?function(d,u,f){if(u=u||d.name||"download",typeof d!="string")navigator.msSaveOrOpenBlob(s(d,f),u);else if(r(d))i(d,u,f);else{var m=document.createElement("a");m.href=d,m.target="_blank",setTimeout(function(){o(m)})}}:function(d,u,f,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof d=="string")return i(d,u,f);var p=d.type==="application/octet-stream",g=/constructor/i.test(l.HTMLElement)||l.safari,x=/CriOS\/[\d]+/.test(navigator.userAgent);if((x||p&&g||a)&&typeof FileReader!="undefined"){var b=new FileReader;b.onloadend=function(){var E=b.result;E=x?E:E.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=E:location=E,m=null},b.readAsDataURL(d)}else{var w=l.URL||l.webkitURL,v=w.createObjectURL(d);m?m.location=v:location.href=v,m=null,setTimeout(function(){w.revokeObjectURL(v)},4e4)}});l.saveAs=c.saveAs=c,n.exports=c})})(FileSaver_min);var FileSaver_minExports=FileSaver_min.exports;const NAMESPACE="@tachybase/module-hera";class Locale{constructor(e){this.app=e}lang(e){return this.app.i18n.t(e,{ns:NAMESPACE})}}const useTranslation=()=>{const{i18n:n}=client.useApp();return{t:(s,i={})=>n.t(s,S({ns:NAMESPACE},i))}},tval=n=>client.tval(n,{ns:NAMESPACE});function lang(n){return client.i18n.t(n,{ns:NAMESPACE})}const LoadingSpin=({children:n,spinning:e})=>{const{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{tip:s("loading..."),indicator:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.LoadingOutlined,{style:{fontSize:24},spin:!0}),spinning:e,children:n})},PDFViewer=React.forwardRef((n,e)=>{const i=client.useApp().AttachmentPreviewManager.get(),{checkedComponent:r}=i["application/pdf"],o=client.useIsMobile(),[l,a]=React.useState(""),[c,d]=React.useState(null),{file:u,width:f=960}=n,{loading:m,data:p}=client.useRequest({url:u,responseType:"arraybuffer"},{refreshDeps:[u]});return React.useImperativeHandle(e,()=>({download(){const g=new Blob([p],{type:"application/pdf"});FileSaver_minExports.saveAs(g,schema.uid()+".pdf")},print(){c.print()}})),React.useEffect(()=>{if(m||!p)return;const g=new Blob([p],{type:"application/pdf"}),x=URL.createObjectURL(g);a(x)},[p,m]),React.useEffect(()=>{if(!l)return;const g=document.createElement("iframe");return g.style.display="none",g.src=l,g.onload=()=>{d(g.contentWindow)},document.body.appendChild(g),()=>{URL.revokeObjectURL(l),document.body.removeChild(g)}},[l]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(LoadingSpin,{spinning:m,children:r({file:{url:l},width:f,noTransformWrapper:!o})})});class Element{constructor(e,s=""){typeof e=="string"?(this.el=document.createElement(e),this.el.className=s):this.el=e,this.data={}}data(e,s){return s!==void 0?(this.data[e]=s,this):this.data[e]}on(e,s){const[i,...r]=e.split(".");let o=i;return o==="mousewheel"&&/Firefox/i.test(window.navigator.userAgent)&&(o="DOMMouseScroll"),this.el.addEventListener(o,l=>{s(l);for(let a=0;a<r.length;a+=1){const c=r[a];if(c==="left"&&l.button!==0||c==="right"&&l.button!==2)return;c==="stop"&&l.stopPropagation()}}),this}offset(e){if(e!==void 0)return Object.keys(e).forEach(l=>{this.css(l,`${e[l]}px`)}),this;const{offsetTop:s,offsetLeft:i,offsetHeight:r,offsetWidth:o}=this.el;return{top:s,left:i,height:r,width:o}}scroll(e){const{el:s}=this;return e!==void 0&&(e.left!==void 0&&(s.scrollLeft=e.left),e.top!==void 0&&(s.scrollTop=e.top)),{left:s.scrollLeft,top:s.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new Element(this.el.parentNode)}children(...e){return arguments.length===0?this.el.childNodes:(e.forEach(s=>this.child(s)),this)}removeChild(e){this.el.removeChild(e)}child(e){let s=e;return typeof e=="string"?s=document.createTextNode(e):e instanceof Element&&(s=e.el),this.el.appendChild(s),this}contains(e){return this.el.contains(e)}className(e){return e!==void 0?(this.el.className=e,this):this.el.className}addClass(e){return this.el.classList.add(e),this}hasClass(e){return this.el.classList.contains(e)}removeClass(e){return this.el.classList.remove(e),this}toggle(e="active"){return this.toggleClass(e)}toggleClass(e){return this.el.classList.toggle(e)}active(e=!0,s="active"){return e?this.addClass(s):this.removeClass(s),this}checked(e=!0){return this.active(e,"checked"),this}disabled(e=!0){return e?this.addClass("disabled"):this.removeClass("disabled"),this}attr(e,s){if(s!==void 0)this.el.setAttribute(e,s);else{if(typeof e=="string")return this.el.getAttribute(e);Object.keys(e).forEach(i=>{this.el.setAttribute(i,e[i])})}return this}removeAttr(e){return this.el.removeAttribute(e),this}html(e){return e!==void 0?(this.el.innerHTML=e,this):this.el.innerHTML}val(e){return e!==void 0?(this.el.value=e,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...e){return e.forEach(s=>this.el.style.removeProperty(s)),this}css(e,s){return s===void 0&&typeof e!="string"?(Object.keys(e).forEach(i=>{this.el.style[i]=e[i]}),this):s!==void 0?(this.el.style[e]=s,this):this.el.style[e]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const h=(n,e="")=>new Element(n,e),alphabets=["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"];function stringAt(n){let e="",s=n;for(;s>=alphabets.length;)s/=alphabets.length,s-=1,e+=alphabets[parseInt(s,10)%alphabets.length];const i=n%alphabets.length;return e+=alphabets[i],e}function indexAt(n){let e=0;for(let s=0;s!==n.length;++s)e=26*e+n.charCodeAt(s)-64;return e-1}function expr2xy(n){let e="",s="";for(let i=0;i<n.length;i+=1)n.charAt(i)>="0"&&n.charAt(i)<="9"?s+=n.charAt(i):e+=n.charAt(i);return[indexAt(e),parseInt(s,10)-1]}function xy2expr(n,e){return`${stringAt(n)}${e+1}`}function expr2expr(n,e,s,i=()=>!0){if(e===0&&s===0)return n;const[r,o]=expr2xy(n);return i(r,o)?xy2expr(r+e,o+s):n}class CellRange{constructor(e,s,i,r,o=0,l=0){this.sri=e,this.sci=s,this.eri=i,this.eci=r,this.w=o,this.h=l}set(e,s,i,r){this.sri=e,this.sci=s,this.eri=i,this.eci=r}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...e){let[s,i]=[0,0];e.length===1?[i,s]=expr2xy(e[0]):e.length===2&&([s,i]=e);const{sri:r,sci:o,eri:l,eci:a}=this;return r<=s&&s<=l&&o<=i&&i<=a}each(e,s=()=>!0){const{sri:i,sci:r,eri:o,eci:l}=this;for(let a=i;a<=o;a+=1)if(s(a))for(let c=r;c<=l;c+=1)e(a,c)}contains(e){return this.sri<=e.sri&&this.sci<=e.sci&&this.eri>=e.eri&&this.eci>=e.eci}within(e){return this.sri>=e.sri&&this.sci>=e.sci&&this.eri<=e.eri&&this.eci<=e.eci}disjoint(e){return this.sri>e.eri||this.sci>e.eci||e.sri>this.eri||e.sci>this.eci}intersects(e){return this.sri<=e.eri&&this.sci<=e.eci&&e.sri<=this.eri&&e.sci<=this.eci}union(e){const{sri:s,sci:i,eri:r,eci:o}=this;return new CellRange(e.sri<s?e.sri:s,e.sci<i?e.sci:i,e.eri>r?e.eri:r,e.eci>o?e.eci:o)}difference(e){const s=[],i=(m,p,g,x)=>{s.push(new CellRange(m,p,g,x))},{sri:r,sci:o,eri:l,eci:a}=this,c=e.sri-r,d=e.sci-o,u=l-e.eri,f=a-e.eci;return c>0?(i(r,o,e.sri-1,a),u>0?(i(e.eri+1,o,l,a),d>0&&i(e.sri,o,e.eri,e.sci-1),f>0&&i(e.sri,e.eci+1,e.eri,a)):(d>0&&i(e.sri,o,l,e.sci-1),f>0&&i(e.sri,e.eci+1,l,a))):u>0&&(i(e.eri+1,o,l,a),d>0&&i(r,o,e.eri,e.sci-1),f>0&&i(r,e.eci+1,e.eri,a)),d>0?(i(r,o,l,e.sci-1),f>0?(i(r,e.eri+1,l,a),c>0&&i(r,e.sci,e.sri-1,e.eci),u>0&&i(e.sri+1,e.sci,l,e.eci)):(c>0&&i(r,e.sci,e.sri-1,a),u>0&&i(e.sri+1,e.sci,l,a))):f>0&&(i(l,e.eci+1,l,a),c>0&&i(r,o,e.sri-1,e.eci),u>0&&i(e.eri+1,o,l,e.eci)),s}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:e,sci:s,eri:i,eci:r}=this;let o=xy2expr(s,e);return this.multiple()&&(o=`${o}:${xy2expr(r,i)}`),o}clone(){const{sri:e,sci:s,eri:i,eci:r,w:o,h:l}=this;return new CellRange(e,s,i,r,o,l)}equals(e){return this.eri===e.eri&&this.eci===e.eci&&this.sri===e.sri&&this.sci===e.sci}static valueOf(e){const s=e.split(":"),[i,r]=expr2xy(s[0]);let[o,l]=[r,i];return s.length>1&&([l,o]=expr2xy(s[1])),new CellRange(r,i,o,l)}}let Selector$1=class{constructor(){this.range=new CellRange(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(e,s){this.ri=e,this.ci=s}size(){return this.range.size()}};class Scroll{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class History{constructor(){this.undoItems=[],this.redoItems=[]}add(e){this.undoItems.push(JSON.stringify(e)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(e,s){const{undoItems:i,redoItems:r}=this;this.canUndo()&&(r.push(JSON.stringify(e)),s(JSON.parse(i.pop())))}redo(e,s){const{undoItems:i,redoItems:r}=this;this.canRedo()&&(i.push(JSON.stringify(e)),s(JSON.parse(r.pop())))}}class Clipboard{constructor(){this.range=null,this.state="clear"}copy(e){return this.range=e,this.state="copy",this}cut(e){return this.range=e,this.state="cut",this}isCopy(){return this.state==="copy"}isCut(){return this.state==="cut"}isClear(){return this.state==="clear"}clear(){this.range=null,this.state="clear"}}class Filter{constructor(e,s,i){this.ci=e,this.operator=s,this.value=i}set(e,s){this.operator=e,this.value=s}includes(e){const{operator:s,value:i}=this;return s==="all"?!0:s==="in"?i.includes(e):!1}vlength(){const{operator:e,value:s}=this;return e==="in"?s.length:0}getData(){const{ci:e,operator:s,value:i}=this;return{ci:e,operator:s,value:i}}}class Sort{constructor(e,s){this.ci=e,this.order=s}asc(){return this.order==="asc"}desc(){return this.order==="desc"}}class AutoFilter{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:e,filters:s,sort:i}){e!=null&&(this.ref=e,this.filters=s.map(r=>new Filter(r.ci,r.operator,r.value)),i&&(this.sort=new Sort(i.ci,i.order)))}getData(){if(this.active()){const{ref:e,filters:s,sort:i}=this;return{ref:e,filters:s.map(r=>r.getData()),sort:i}}return{}}addFilter(e,s,i){const r=this.getFilter(e);r==null?this.filters.push(new Filter(e,s,i)):r.set(s,i)}setSort(e,s){this.sort=s?new Sort(e,s):null}includes(e,s){return this.active()?this.hrange().includes(e,s):!1}getSort(e){const{sort:s}=this;return s&&s.ci===e?s:null}getFilter(e){const{filters:s}=this;for(let i=0;i<s.length;i+=1)if(s[i].ci===e)return s[i];return null}filteredRows(e){const s=new Set,i=new Set;if(this.active()){const{sri:r,eri:o}=this.range(),{filters:l}=this;for(let a=r+1;a<=o;a+=1)for(let c=0;c<l.length;c+=1){const d=l[c],u=e(a,d.ci),f=u?u.text:"";if(d.includes(f))i.add(a);else{s.add(a);break}}}return{rset:s,fset:i}}items(e,s){const i={};if(this.active()){const{sri:r,eri:o}=this.range();for(let l=r+1;l<=o;l+=1){const a=s(l,e);if(a===null||/^\s*$/.test(a.text))i[""]=(i[""]||0)+1;else{const c=a.text,d=(i[c]||0)+1;i[c]=d}}}return i}range(){return CellRange.valueOf(this.ref)}hrange(){const e=this.range();return e.eri=e.sri,e}clear(){this.ref=null,this.filters=[],this.sort=null}active(){return this.ref!==null}}class Merges{constructor(e=[]){this._=e}forEach(e){this._.forEach(e)}deleteWithin(e){this._=this._.filter(s=>!s.within(e))}getFirstIncludes(e,s){for(let i=0;i<this._.length;i+=1){const r=this._[i];if(r.includes(e,s))return r}return null}filterIntersects(e){return new Merges(this._.filter(s=>s.intersects(e)))}intersects(e){for(let s=0;s<this._.length;s+=1)if(this._[s].intersects(e))return!0;return!1}union(e){let s=e;return this._.forEach(i=>{i.intersects(s)&&(s=i.union(s))}),s}add(e){this.deleteWithin(e),this._.push(e)}shift(e,s,i,r){this._.forEach(o=>{const{sri:l,sci:a,eri:c,eci:d}=o,u=o;e==="row"?l>=s?(u.sri+=i,u.eri+=i):l<s&&s<=c&&(u.eri+=i,r(l,a,i,0)):e==="column"&&(a>=s?(u.sci+=i,u.eci+=i):a<s&&s<=d&&(u.eci+=i,r(l,a,0,i)))})}move(e,s,i){this._.forEach(r=>{const o=r;o.within(e)&&(o.eri+=s,o.sri+=s,o.sci+=i,o.eci+=i)})}setData(e){return this._=e.map(s=>CellRange.valueOf(s)),this}getData(){return this._.map(e=>e.toString())}}function cloneDeep(n){return JSON.parse(JSON.stringify(n))}const mergeDeep=(n={},...e)=>(e.forEach(s=>{Object.keys(s).forEach(i=>{const r=s[i];typeof r=="string"||typeof r=="number"||typeof r=="boolean"?n[i]=r:typeof r!="function"&&!Array.isArray(r)&&r instanceof Object?(n[i]=n[i]||{},mergeDeep(n[i],r)):n[i]=r})}),n);function equals(n,e){const s=Object.keys(n);if(s.length!==Object.keys(e).length)return!1;for(let i=0;i<s.length;i+=1){const r=s[i],o=n[r],l=e[r];if(l===void 0)return!1;if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){if(o!==l)return!1}else if(Array.isArray(o)){if(o.length!==l.length)return!1;for(let a=0;a<o.length;a+=1)if(!equals(o[a],l[a]))return!1}else if(typeof o!="function"&&!Array.isArray(o)&&o instanceof Object&&!equals(o,l))return!1}return!0}const sum=(n,e=s=>s)=>{let s=0,i=0;return Object.keys(n).forEach(r=>{s+=e(n[r],r),i+=1}),[s,i]};function deleteProperty(n,e){const s=n[`${e}`];return delete n[`${e}`],s}function rangeReduceIf(n,e,s,i,r,o){let l=s,a=i,c=n;for(;c<e&&!(l>r);c+=1)a=o(c),l+=a;return[c,l-a,a]}function rangeSum(n,e,s){let i=0;for(let r=n;r<e;r+=1)i+=s(r);return i}function rangeEach(n,e,s){for(let i=n;i<e;i+=1)s(i)}function arrayEquals(n,e){if(n.length!==e.length)return!1;for(let s=0;s<n.length;s+=1)if(n[s]!==e[s])return!1;return!0}function digits(n){const e=`${n}`;let s=0,i=!1;for(let r=0;r<e.length;r+=1)i===!0&&(s+=1),e.charAt(r)==="."&&(i=!0);return s}function numberCalc(n,e,s){if(Number.isNaN(e)||Number.isNaN(s))return e+n+s;const i=digits(e),r=digits(s),o=Number(e),l=Number(s);let a=0;if(n==="-")a=o-l;else if(n==="+")a=o+l;else if(n==="*")a=o*l;else if(n==="/")return a=o/l,digits(a)>5?a.toFixed(2):a;return a.toFixed(Math.max(i,r))}const helper_rslib_entry_={cloneDeep,merge:(...n)=>mergeDeep({},...n),equals,arrayEquals,sum,rangeEach,rangeSum,rangeReduceIf,deleteProperty,numberCalc};class Rows{constructor({len:e,height:s}){this._={},this.len=e,this.height=s}getHeight(e){if(this.isHide(e))return 0;const s=this.get(e);return s&&s.height?s.height:this.height}setHeight(e,s){const i=this.getOrNew(e);i.height=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this.get(e);return s&&s.hide}setHide(e,s){const i=this.getOrNew(e);s===!0?i.hide=!0:delete i.hide}setStyle(e,s){const i=this.getOrNew(e);i.style=s}sumHeight(e,s,i){return helper_rslib_entry_.rangeSum(e,s,r=>i&&i.has(r)?0:this.getHeight(r))}totalHeight(){return this.sumHeight(0,this.len)}get(e){return this._[e]}getOrNew(e){return this._[e]=this._[e]||{cells:{}},this._[e]}getCell(e,s){const i=this.get(e);return i!==void 0&&i.cells!==void 0&&i.cells[s]!==void 0?i.cells[s]:null}getCellMerge(e,s){const i=this.getCell(e,s);return i&&i.merge?i.merge:[0,0]}getCellOrNew(e,s){const i=this.getOrNew(e);return i.cells[s]=i.cells[s]||{},i.cells[s]}setCell(e,s,i,r="all"){const o=this.getOrNew(e);r==="all"?o.cells[s]=i:r==="text"?(o.cells[s]=o.cells[s]||{},o.cells[s].text=i.text):r==="format"&&(o.cells[s]=o.cells[s]||{},o.cells[s].style=i.style,i.merge&&(o.cells[s].merge=i.merge))}setCellText(e,s,i){const r=this.getCellOrNew(e,s);r.editable!==!1&&(r.text=i)}copyPaste(e,s,i,r=!1,o=()=>{}){const{sri:l,sci:a,eri:c,eci:d}=e,u=s.sri,f=s.sci,m=s.eri,p=s.eci,[g,x]=e.size(),[b,w]=s.size();let v=!0,E=0;(m<l||p<a)&&(v=!1,E=m<l?b:w);for(let C=l;C<=c;C+=1)if(this._[C]){for(let k=a;k<=d;k+=1)if(this._[C].cells&&this._[C].cells[k])for(let R=u;R<=m;R+=g)for(let j=f;j<=p;j+=x){const O=R+(C-l),K=j+(k-a),W=helper_rslib_entry_.cloneDeep(this._[C].cells[k]);if(r&&W&&W.text&&W.text.length>0){const{text:X}=W;let V=j-f+(R-u)+2;if(v||(V-=E+1),X[0]==="=")W.text=X.replace(/[a-zA-Z]{1,3}\d+/g,z=>{let[H,Y]=[0,0];return l===u?H=V-1:Y=V-1,/^\d+$/.test(z)?z:expr2expr(z,H,Y)});else if(g<=1&&x>1&&(u>c||m<l)||x<=1&&g>1&&(f>d||p<a)||g<=1&&x<=1){const z=/[\\.\d]+$/.exec(X);if(z!==null){const H=Number(z[0])+V-1;W.text=X.substring(0,z.index)+H}}}this.setCell(O,K,W,i),o(O,K,W)}}}cutPaste(e,s){const i={};this.each(r=>{this.eachCells(r,o=>{let l=parseInt(r,10),a=parseInt(o,10);e.includes(r,o)&&(l=s.sri+(l-e.sri),a=s.sci+(a-e.sci)),i[l]=i[l]||{cells:{}},i[l].cells[a]=this._[r].cells[o]})}),this._=i}paste(e,s){if(e.length<=0)return;const{sri:i,sci:r}=s;e.forEach((o,l)=>{const a=i+l;o.forEach((c,d)=>{const u=r+d;this.setCellText(a,u,c)})})}insert(e,s=1){const i={};this.each((r,o)=>{let l=parseInt(r,10);l>=e&&(l+=s,this.eachCells(r,(a,c)=>{c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,0,s,(u,f)=>f>=e)))})),i[l]=o}),this._=i,this.len+=s}delete(e,s){const i=s-e+1,r={};this.each((o,l)=>{const a=parseInt(o,10);a<e?r[a]=l:o>s&&(r[a-i]=l,this.eachCells(o,(c,d)=>{d.text&&d.text[0]==="="&&(d.text=d.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,0,-i,(f,m)=>m>s)))}))}),this._=r,this.len-=i}insertColumn(e,s=1){this.each((i,r)=>{const o={};this.eachCells(i,(l,a)=>{let c=parseInt(l,10);c>=e&&(c+=s,a.text&&a.text[0]==="="&&(a.text=a.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,s,0,u=>u>=e)))),o[c]=a}),r.cells=o})}deleteColumn(e,s){const i=s-e+1;this.each((r,o)=>{const l={};this.eachCells(r,(a,c)=>{const d=parseInt(a,10);d<e?l[d]=c:d>s&&(l[d-i]=c,c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,-i,0,f=>f>s))))}),o.cells=l})}deleteCells(e,s="all"){e.each((i,r)=>{this.deleteCell(i,r,s)})}deleteCell(e,s,i="all"){const r=this.get(e);if(r!==null){const o=this.getCell(e,s);o!==null&&o.editable!==!1&&(i==="all"?delete r.cells[s]:i==="text"?(o.text&&delete o.text,o.value&&delete o.value):i==="format"?(o.style!==void 0&&delete o.style,o.merge&&delete o.merge):i==="merge"&&o.merge&&delete o.merge)}}maxCell(){const e=Object.keys(this._),s=e[e.length-1],i=this._[s];if(i){const{cells:r}=i,o=Object.keys(r),l=o[o.length-1];return[parseInt(s,10),parseInt(l,10)]}return[0,0]}each(e){Object.entries(this._).forEach(([s,i])=>{e(s,i)})}eachCells(e,s){this._[e]&&this._[e].cells&&Object.entries(this._[e].cells).forEach(([i,r])=>{s(i,r)})}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}}class Cols{constructor({len:e,width:s,indexWidth:i,minWidth:r}){this._={},this.len=e,this.width=s,this.indexWidth=i,this.minWidth=r}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}getWidth(e){if(this.isHide(e))return 0;const s=this._[e];return s&&s.width?s.width:this.width}getOrNew(e){return this._[e]=this._[e]||{},this._[e]}setWidth(e,s){const i=this.getOrNew(e);i.width=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this._[e];return s&&s.hide}setHide(e,s){const i=this.getOrNew(e);s===!0?i.hide=!0:delete i.hide}setStyle(e,s){const i=this.getOrNew(e);i.style=s}sumWidth(e,s){return helper_rslib_entry_.rangeSum(e,s,i=>this.getWidth(i))}totalWidth(){return this.sumWidth(0,this.len)}}const en_rslib_entry_={toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};let $languages=["en"];const $messages={en:en_rslib_entry_};function translate(n,e){if(e)for(const s of $languages){if(!e[s])break;let i=e[s];const r=n.match(/(?:\\.|[^.])+/g);for(let o=0;o<r.length;o+=1){const l=r[o],a=i[l];if(!a)break;if(o===r.length-1)return a;i=a}}}function t(n){let e=translate(n,$messages);return!e&&window&&window.x_spreadsheet&&window.x_spreadsheet.$messages&&(e=translate(n,window.x_spreadsheet.$messages)),e||""}function tf(n){return()=>t(n)}function locale(n,e,s=!1){s?$languages=[n]:$languages.unshift(n),e&&($messages[n]=e)}const rules={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function returnMessage(n,e,...s){let i="";return n||(i=t(`validation.${e}`,...s)),[n,i]}class Validator{constructor(e,s,i,r){this.required=s,this.value=i,this.type=e,this.operator=r,this.message=""}parseValue(e){const{type:s}=this;return s==="date"?new Date(e):s==="number"?Number(e):e}equals(e){let s=this.type===e.type&&this.required===e.required&&this.operator===e.operator;return s&&(s=Array.isArray(this.value)?helper_rslib_entry_.arrayEquals(this.value,e.value):this.value===e.value),s}values(){return this.value.split(",")}validate(e){const{required:s,operator:i,value:r,type:o}=this;if(s&&/^\s*$/.test(e))return returnMessage(!1,"required");if(/^\s*$/.test(e))return[!0];if(rules[o]&&!rules[o].test(e))return returnMessage(!1,"notMatch");if(o==="list")return returnMessage(this.values().includes(e),"notIn");if(i){const l=this.parseValue(e);if(i==="be"){const[a,c]=r;return returnMessage(l>=this.parseValue(a)&&l<=this.parseValue(c),"between",a,c)}if(i==="nbe"){const[a,c]=r;return returnMessage(l<this.parseValue(a)||l>this.parseValue(c),"notBetween",a,c)}if(i==="eq")return returnMessage(l===this.parseValue(r),"equal",r);if(i==="neq")return returnMessage(l!==this.parseValue(r),"notEqual",r);if(i==="lt")return returnMessage(l<this.parseValue(r),"lessThan",r);if(i==="lte")return returnMessage(l<=this.parseValue(r),"lessThanEqual",r);if(i==="gt")return returnMessage(l>this.parseValue(r),"greaterThan",r);if(i==="gte")return returnMessage(l>=this.parseValue(r),"greaterThanEqual",r)}return[!0]}}class Validation{constructor(e,s,i){this.refs=s,this.mode=e,this.validator=i}includes(e,s){const{refs:i}=this;for(let r=0;r<i.length;r+=1)if(CellRange.valueOf(i[r]).includes(e,s))return!0;return!1}addRef(e){this.remove(CellRange.valueOf(e)),this.refs.push(e)}remove(e){const s=[];this.refs.forEach(i=>{const r=CellRange.valueOf(i);r.intersects(e)?r.difference(e).forEach(l=>s.push(l.toString())):s.push(i)}),this.refs=s}getData(){const{refs:e,mode:s,validator:i}=this,{type:r,required:o,operator:l,value:a}=i;return{refs:e,mode:s,type:r,required:o,operator:l,value:a}}static valueOf({refs:e,mode:s,type:i,required:r,operator:o,value:l}){return new Validation(s,e,new Validator(i,r,l,o))}}class Validations{constructor(){this._=[],this.errors=new Map}getError(e,s){return this.errors.get(`${e}_${s}`)}validate(e,s,i){const r=this.get(e,s),o=`${e}_${s}`,{errors:l}=this;if(r!==null){const[a,c]=r.validator.validate(i);a?l.delete(o):l.set(o,c)}else l.delete(o);return!0}add(e,s,{type:i,required:r,value:o,operator:l}){const a=new Validator(i,r,o,l),c=this.getByValidator(a);c!==null?c.addRef(s):this._.push(new Validation(e,[s],a))}getByValidator(e){for(let s=0;s<this._.length;s+=1){const i=this._[s];if(i.validator.equals(e))return i}return null}get(e,s){for(let i=0;i<this._.length;i+=1){const r=this._[i];if(r.includes(e,s))return r}return null}remove(e){this.each(s=>{s.remove(e)})}each(e){this._.forEach(s=>e(s))}getData(){return this._.filter(e=>e.refs.length>0).map(e=>e.getData())}setData(e){this._=e.map(s=>Validation.valueOf(s))}}const defaultSettings={mode:"edit",view:{height:()=>document.documentElement.clientHeight,width:()=>document.documentElement.clientWidth},showGrid:!0,showToolbar:!0,showContextmenu:!0,showBottomBar:!0,row:{len:100,height:25},col:{len:26,width:100,indexWidth:60,minWidth:60},style:{bgcolor:"#ffffff",align:"left",valign:"middle",textwrap:!1,strike:!1,underline:!1,color:"#0a0a0a",font:{name:"Arial",size:10,bold:!1,italic:!1},format:"normal"}},toolbarHeight=41,bottombarHeight=41;function canPaste(n,e,s=()=>{}){const{merges:i}=this,r=e.clone(),[o,l]=n.size(),[a,c]=e.size();return o>a&&(r.eri=e.sri+o-1),l>c&&(r.eci=e.sci+l-1),i.intersects(r)?(s(t("error.pasteForMergedCell")),!1):!0}function copyPaste(n,e,s,i=!1){const{rows:r,merges:o}=this;(s==="all"||s==="format")&&(r.deleteCells(e,s),o.deleteWithin(e)),r.copyPaste(n,e,s,i,(l,a,c)=>{if(c&&c.merge){const[d,u]=c.merge;if(d<=0&&u<=0)return;o.add(new CellRange(l,a,l+d,a+u))}})}function cutPaste(n,e){const{clipboard:s,rows:i,merges:r}=this;i.cutPaste(n,e),r.move(n,e.sri-n.sri,e.sci-n.sci),s.clear()}function setStyleBorder(n,e,s){const{styles:i,rows:r}=this,o=r.getCellOrNew(n,e);let l={};o.style!==void 0&&(l=helper_rslib_entry_.cloneDeep(i[o.style])),l=helper_rslib_entry_.merge(l,{border:s}),o.style=this.addStyle(l)}function setStyleBorders({mode:n,style:e,color:s}){const{styles:i,selector:r,rows:o}=this,{sri:l,sci:a,eri:c,eci:d}=r.range,u=!this.isSingleSelected();if(!(!u&&(n==="inside"||n==="horizontal"||n==="vertical")))if(n!=="outside"||u){if(n==="none")r.range.each((f,m)=>{const p=o.getCell(f,m);if(p&&p.style!==void 0){const g=helper_rslib_entry_.cloneDeep(i[p.style]);delete g.border,p.style=this.addStyle(g)}});else if(n==="all"||n==="inside"||n==="outside"||n==="horizontal"||n==="vertical"){const f=[];for(let m=l;m<=c;m+=1)for(let p=a;p<=d;p+=1){const g=[];for(let k=0;k<f.length;k+=1){const[R,j,O,K]=f[k];if(m===R+O+1&&g.push(k),R<=m&&m<=R+O&&p===j){p+=K+1;break}}if(g.forEach(k=>f.splice(k,1)),p>d)break;const x=o.getCell(m,p);let[b,w]=[0,0];x&&x.merge&&([b,w]=x.merge,f.push([m,p,b,w]));const v=b>0&&m+b===c,E=w>0&&p+w===d;let C={};n==="all"?C={bottom:[e,s],top:[e,s],left:[e,s],right:[e,s]}:n==="inside"?(!E&&p<d&&(C.right=[e,s]),!v&&m<c&&(C.bottom=[e,s])):n==="horizontal"?!v&&m<c&&(C.bottom=[e,s]):n==="vertical"?!E&&p<d&&(C.right=[e,s]):n==="outside"&&u&&(l===m&&(C.top=[e,s]),(v||c===m)&&(C.bottom=[e,s]),a===p&&(C.left=[e,s]),(E||d===p)&&(C.right=[e,s])),Object.keys(C).length>0&&setStyleBorder.call(this,m,p,C),p+=w}}else if(n==="top"||n==="bottom")for(let f=a;f<=d;f+=1)n==="top"&&(setStyleBorder.call(this,l,f,{top:[e,s]}),f+=o.getCellMerge(l,f)[1]),n==="bottom"&&(setStyleBorder.call(this,c,f,{bottom:[e,s]}),f+=o.getCellMerge(c,f)[1]);else if(n==="left"||n==="right")for(let f=l;f<=c;f+=1)n==="left"&&(setStyleBorder.call(this,f,a,{left:[e,s]}),f+=o.getCellMerge(f,a)[0]),n==="right"&&(setStyleBorder.call(this,f,d,{right:[e,s]}),f+=o.getCellMerge(f,d)[0])}else setStyleBorder.call(this,l,a,{top:[e,s],bottom:[e,s],left:[e,s],right:[e,s]})}function getCellRowByY(n,e){const{rows:s}=this,i=this.freezeTotalHeight();let r=s.height;i+s.height<n&&(r-=e);const o=this.exceptRowSet;let l=0,a=r,{height:c}=s;for(;l<s.len&&!(a>n);l+=1)o.has(l)||(c=s.getHeight(l),a+=c);return a-=c,a<=0?{ri:-1,top:0,height:c}:{ri:l-1,top:a,height:c}}function getCellColByX(n,e){const{cols:s}=this,i=this.freezeTotalWidth();let r=s.indexWidth;i+s.indexWidth<n&&(r-=e);const[o,l,a]=helper_rslib_entry_.rangeReduceIf(0,s.len,r,s.indexWidth,n,c=>s.getWidth(c));return l<=0?{ci:-1,left:0,width:s.indexWidth}:{ci:o-1,left:l,width:a}}class DataProxy{constructor(e,s){this.settings=helper_rslib_entry_.merge(defaultSettings,s||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new Merges,this.rows=new Rows(this.settings.row),this.cols=new Cols(this.settings.col),this.validations=new Validations,this.hyperlinks={},this.comments={},this.selector=new Selector$1,this.scroll=new Scroll,this.history=new History,this.clipboard=new Clipboard,this.autoFilter=new AutoFilter,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(e,s,i){this.changeData(()=>{this.validations.add(e,s,i)})}removeValidation(){const{range:e}=this.selector;this.changeData(()=>{this.validations.remove(e)})}getSelectedValidator(){const{ri:e,ci:s}=this.selector,i=this.validations.get(e,s);return i?i.validator:null}getSelectedValidation(){const{ri:e,ci:s,range:i}=this.selector,r=this.validations.get(e,s),o={ref:i.toString()};return r!==null&&(o.mode=r.mode,o.validator=r.validator),o}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),e=>{this.setData(e)})}redo(){this.history.redo(this.getData(),e=>{this.setData(e)})}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(e){let s=[];const{sri:i,eri:r,sci:o,eci:l}=this.selector.range;for(let a=i;a<=r;a+=1){const c=[];for(let d=o;d<=l;d+=1){const u=this.getCell(a,d);c.push(u&&u.text||"")}s.push(c)}s=s.map(a=>a.join(" ")).join(`
2
+ (function(y,P){typeof exports=="object"&&typeof module!="undefined"?P(exports,require("@tachybase/client"),require("@tachybase/components"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("@ant-design/icons"),require("antd"),require("lodash"),require("@tachybase/evaluators/client"),require("react-dom"),require("react-router-dom"),require("dayjs"),require("@tachybase/utils/client"),require("ahooks")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/components","react/jsx-runtime","react","@tachybase/schema","@ant-design/icons","antd","lodash","@tachybase/evaluators/client","react-dom","react-router-dom","dayjs","@tachybase/utils/client","ahooks"],P):(y=typeof globalThis!="undefined"?globalThis:y||self,P(y["@tachybase/module-hera"]={},y["@tachybase/client"],y["@tachybase/components"],y.jsxRuntime,y.react,y["@tachybase/schema"],y["@ant-design/icons"],y.antd,y.lodash,y["@tachybase/evaluators"],y["react-dom"],y["react-router-dom"],y.dayjs,y["@tachybase/utils"],y.ahooks))})(this,function(exports,client,components$1,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__,React,schema,icons,antd,_,client$1,ReactDOM,reactRouterDom,dayjs,client$2,ahooks){"use strict";var te=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var J=y=>{throw TypeError(y)};var q=(y,P,S)=>P in y?te(y,P,{enumerable:!0,configurable:!0,writable:!0,value:S}):y[P]=S,D=(y,P)=>{for(var S in P||(P={}))ne.call(P,S)&&q(y,S,P[S]);if(Z)for(var S of Z(P))re.call(P,S)&&q(y,S,P[S]);return y},I=(y,P)=>se(y,ie(P));var Q=(y,P,S)=>q(y,typeof P!="symbol"?P+"":P,S),ee=(y,P,S)=>P.has(y)||J("Cannot "+S);var k=(y,P,S)=>(ee(y,P,"read from private field"),S?S.call(y):P.get(y)),U=(y,P,S)=>P.has(y)?J("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(y):P.set(y,S),N=(y,P,S,M)=>(ee(y,P,"write to private field"),M?M.call(y,S):P.set(y,S),S);var T=(y,P,S)=>new Promise((M,F)=>{var O=n=>{try{$(S.next(n))}catch(e){F(e)}},B=n=>{try{$(S.throw(n))}catch(e){F(e)}},$=n=>n.done?M(n.value):Promise.resolve(n.value).then(O,B);$((S=S.apply(y,P)).next())});var y,P,S,M,F,O;function _interopNamespaceDefault(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>n[s]})}}return e.default=n,Object.freeze(e)}const React__namespace=_interopNamespaceDefault(React);var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var FileSaver_min={exports:{}};(function(n,e){(function(s,i){i()})(commonjsGlobal,function(){function s(d,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(d.type)?new Blob(["\uFEFF",d],{type:d.type}):d}function i(d,u,f){var p=new XMLHttpRequest;p.open("GET",d),p.responseType="blob",p.onload=function(){c(p.response,u,f)},p.onerror=function(){console.error("could not download file")},p.send()}function r(d){var u=new XMLHttpRequest;u.open("HEAD",d,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function o(d){try{d.dispatchEvent(new MouseEvent("click"))}catch(f){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),d.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof commonjsGlobal=="object"&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,a=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(d,u,f){var p=l.URL||l.webkitURL,m=document.createElement("a");u=u||d.name||"download",m.download=u,m.rel="noopener",typeof d=="string"?(m.href=d,m.origin===location.origin?o(m):r(m.href)?i(d,u,f):o(m,m.target="_blank")):(m.href=p.createObjectURL(d),setTimeout(function(){p.revokeObjectURL(m.href)},4e4),setTimeout(function(){o(m)},0))}:"msSaveOrOpenBlob"in navigator?function(d,u,f){if(u=u||d.name||"download",typeof d!="string")navigator.msSaveOrOpenBlob(s(d,f),u);else if(r(d))i(d,u,f);else{var p=document.createElement("a");p.href=d,p.target="_blank",setTimeout(function(){o(p)})}}:function(d,u,f,p){if(p=p||open("","_blank"),p&&(p.document.title=p.document.body.innerText="downloading..."),typeof d=="string")return i(d,u,f);var m=d.type==="application/octet-stream",g=/constructor/i.test(l.HTMLElement)||l.safari,x=/CriOS\/[\d]+/.test(navigator.userAgent);if((x||m&&g||a)&&typeof FileReader!="undefined"){var b=new FileReader;b.onloadend=function(){var w=b.result;w=x?w:w.replace(/^data:[^;]*;/,"data:attachment/file;"),p?p.location.href=w:location=w,p=null},b.readAsDataURL(d)}else{var E=l.URL||l.webkitURL,v=E.createObjectURL(d);p?p.location=v:location.href=v,p=null,setTimeout(function(){E.revokeObjectURL(v)},4e4)}});l.saveAs=c.saveAs=c,n.exports=c})})(FileSaver_min);var FileSaver_minExports=FileSaver_min.exports;const NAMESPACE="@tachybase/module-hera";class Locale{constructor(e){this.app=e}lang(e){return this.app.i18n.t(e,{ns:NAMESPACE})}}const useTranslation=()=>{const{i18n:n}=client.useApp();return{t:(s,i={})=>n.t(s,D({ns:NAMESPACE},i))}},tval=n=>client.tval(n,{ns:NAMESPACE});function lang(n){return client.i18n.t(n,{ns:NAMESPACE})}const LoadingSpin=({children:n,spinning:e})=>{const{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{tip:s("loading..."),indicator:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.LoadingOutlined,{style:{fontSize:24},spin:!0}),spinning:e,children:n})},PDFViewer=React.forwardRef((n,e)=>{const i=client.useApp().AttachmentPreviewManager.get(),{checkedComponent:r}=i["application/pdf"],o=client.useIsMobile(),[l,a]=React.useState(""),[c,d]=React.useState(null),{file:u,width:f=960}=n,{loading:p,data:m}=client.useRequest({url:u,responseType:"arraybuffer"},{refreshDeps:[u]});return React.useImperativeHandle(e,()=>({download(){const g=new Blob([m],{type:"application/pdf"});FileSaver_minExports.saveAs(g,schema.uid()+".pdf")},print(){c.print()}})),React.useEffect(()=>{if(p||!m)return;const g=new Blob([m],{type:"application/pdf"}),x=URL.createObjectURL(g);a(x)},[m,p]),React.useEffect(()=>{if(!l)return;const g=document.createElement("iframe");return g.style.display="none",g.src=l,g.onload=()=>{d(g.contentWindow)},document.body.appendChild(g),()=>{URL.revokeObjectURL(l),document.body.removeChild(g)}},[l]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(LoadingSpin,{spinning:p,children:r({file:{url:l},width:f,noTransformWrapper:!o})})});class Element{constructor(e,s=""){typeof e=="string"?(this.el=document.createElement(e),this.el.className=s):this.el=e,this.data={}}data(e,s){return s!==void 0?(this.data[e]=s,this):this.data[e]}on(e,s){const[i,...r]=e.split(".");let o=i;return o==="mousewheel"&&/Firefox/i.test(window.navigator.userAgent)&&(o="DOMMouseScroll"),this.el.addEventListener(o,l=>{s(l);for(let a=0;a<r.length;a+=1){const c=r[a];if(c==="left"&&l.button!==0||c==="right"&&l.button!==2)return;c==="stop"&&l.stopPropagation()}}),this}offset(e){if(e!==void 0)return Object.keys(e).forEach(l=>{this.css(l,`${e[l]}px`)}),this;const{offsetTop:s,offsetLeft:i,offsetHeight:r,offsetWidth:o}=this.el;return{top:s,left:i,height:r,width:o}}scroll(e){const{el:s}=this;return e!==void 0&&(e.left!==void 0&&(s.scrollLeft=e.left),e.top!==void 0&&(s.scrollTop=e.top)),{left:s.scrollLeft,top:s.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new Element(this.el.parentNode)}children(...e){return arguments.length===0?this.el.childNodes:(e.forEach(s=>this.child(s)),this)}removeChild(e){this.el.removeChild(e)}child(e){let s=e;return typeof e=="string"?s=document.createTextNode(e):e instanceof Element&&(s=e.el),this.el.appendChild(s),this}contains(e){return this.el.contains(e)}className(e){return e!==void 0?(this.el.className=e,this):this.el.className}addClass(e){return this.el.classList.add(e),this}hasClass(e){return this.el.classList.contains(e)}removeClass(e){return this.el.classList.remove(e),this}toggle(e="active"){return this.toggleClass(e)}toggleClass(e){return this.el.classList.toggle(e)}active(e=!0,s="active"){return e?this.addClass(s):this.removeClass(s),this}checked(e=!0){return this.active(e,"checked"),this}disabled(e=!0){return e?this.addClass("disabled"):this.removeClass("disabled"),this}attr(e,s){if(s!==void 0)this.el.setAttribute(e,s);else{if(typeof e=="string")return this.el.getAttribute(e);Object.keys(e).forEach(i=>{this.el.setAttribute(i,e[i])})}return this}removeAttr(e){return this.el.removeAttribute(e),this}html(e){return e!==void 0?(this.el.innerHTML=e,this):this.el.innerHTML}val(e){return e!==void 0?(this.el.value=e,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...e){return e.forEach(s=>this.el.style.removeProperty(s)),this}css(e,s){return s===void 0&&typeof e!="string"?(Object.keys(e).forEach(i=>{this.el.style[i]=e[i]}),this):s!==void 0?(this.el.style[e]=s,this):this.el.style[e]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const h=(n,e="")=>new Element(n,e),alphabets=["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"];function stringAt(n){let e="",s=n;for(;s>=alphabets.length;)s/=alphabets.length,s-=1,e+=alphabets[parseInt(s,10)%alphabets.length];const i=n%alphabets.length;return e+=alphabets[i],e}function indexAt(n){let e=0;for(let s=0;s!==n.length;++s)e=26*e+n.charCodeAt(s)-64;return e-1}function expr2xy(n){let e="",s="";for(let i=0;i<n.length;i+=1)n.charAt(i)>="0"&&n.charAt(i)<="9"?s+=n.charAt(i):e+=n.charAt(i);return[indexAt(e),parseInt(s,10)-1]}function xy2expr(n,e){return`${stringAt(n)}${e+1}`}function expr2expr(n,e,s,i=()=>!0){if(e===0&&s===0)return n;const[r,o]=expr2xy(n);return i(r,o)?xy2expr(r+e,o+s):n}class CellRange{constructor(e,s,i,r,o=0,l=0){this.sri=e,this.sci=s,this.eri=i,this.eci=r,this.w=o,this.h=l}set(e,s,i,r){this.sri=e,this.sci=s,this.eri=i,this.eci=r}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...e){let[s,i]=[0,0];e.length===1?[i,s]=expr2xy(e[0]):e.length===2&&([s,i]=e);const{sri:r,sci:o,eri:l,eci:a}=this;return r<=s&&s<=l&&o<=i&&i<=a}each(e,s=()=>!0){const{sri:i,sci:r,eri:o,eci:l}=this;for(let a=i;a<=o;a+=1)if(s(a))for(let c=r;c<=l;c+=1)e(a,c)}contains(e){return this.sri<=e.sri&&this.sci<=e.sci&&this.eri>=e.eri&&this.eci>=e.eci}within(e){return this.sri>=e.sri&&this.sci>=e.sci&&this.eri<=e.eri&&this.eci<=e.eci}disjoint(e){return this.sri>e.eri||this.sci>e.eci||e.sri>this.eri||e.sci>this.eci}intersects(e){return this.sri<=e.eri&&this.sci<=e.eci&&e.sri<=this.eri&&e.sci<=this.eci}union(e){const{sri:s,sci:i,eri:r,eci:o}=this;return new CellRange(e.sri<s?e.sri:s,e.sci<i?e.sci:i,e.eri>r?e.eri:r,e.eci>o?e.eci:o)}difference(e){const s=[],i=(p,m,g,x)=>{s.push(new CellRange(p,m,g,x))},{sri:r,sci:o,eri:l,eci:a}=this,c=e.sri-r,d=e.sci-o,u=l-e.eri,f=a-e.eci;return c>0?(i(r,o,e.sri-1,a),u>0?(i(e.eri+1,o,l,a),d>0&&i(e.sri,o,e.eri,e.sci-1),f>0&&i(e.sri,e.eci+1,e.eri,a)):(d>0&&i(e.sri,o,l,e.sci-1),f>0&&i(e.sri,e.eci+1,l,a))):u>0&&(i(e.eri+1,o,l,a),d>0&&i(r,o,e.eri,e.sci-1),f>0&&i(r,e.eci+1,e.eri,a)),d>0?(i(r,o,l,e.sci-1),f>0?(i(r,e.eri+1,l,a),c>0&&i(r,e.sci,e.sri-1,e.eci),u>0&&i(e.sri+1,e.sci,l,e.eci)):(c>0&&i(r,e.sci,e.sri-1,a),u>0&&i(e.sri+1,e.sci,l,a))):f>0&&(i(l,e.eci+1,l,a),c>0&&i(r,o,e.sri-1,e.eci),u>0&&i(e.eri+1,o,l,e.eci)),s}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:e,sci:s,eri:i,eci:r}=this;let o=xy2expr(s,e);return this.multiple()&&(o=`${o}:${xy2expr(r,i)}`),o}clone(){const{sri:e,sci:s,eri:i,eci:r,w:o,h:l}=this;return new CellRange(e,s,i,r,o,l)}equals(e){return this.eri===e.eri&&this.eci===e.eci&&this.sri===e.sri&&this.sci===e.sci}static valueOf(e){const s=e.split(":"),[i,r]=expr2xy(s[0]);let[o,l]=[r,i];return s.length>1&&([l,o]=expr2xy(s[1])),new CellRange(r,i,o,l)}}let Selector$1=class{constructor(){this.range=new CellRange(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(e,s){this.ri=e,this.ci=s}size(){return this.range.size()}};class Scroll{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class History{constructor(){this.undoItems=[],this.redoItems=[]}add(e){this.undoItems.push(JSON.stringify(e)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(e,s){const{undoItems:i,redoItems:r}=this;this.canUndo()&&(r.push(JSON.stringify(e)),s(JSON.parse(i.pop())))}redo(e,s){const{undoItems:i,redoItems:r}=this;this.canRedo()&&(i.push(JSON.stringify(e)),s(JSON.parse(r.pop())))}}class Clipboard{constructor(){this.range=null,this.state="clear"}copy(e){return this.range=e,this.state="copy",this}cut(e){return this.range=e,this.state="cut",this}isCopy(){return this.state==="copy"}isCut(){return this.state==="cut"}isClear(){return this.state==="clear"}clear(){this.range=null,this.state="clear"}}class Filter{constructor(e,s,i){this.ci=e,this.operator=s,this.value=i}set(e,s){this.operator=e,this.value=s}includes(e){const{operator:s,value:i}=this;return s==="all"?!0:s==="in"?i.includes(e):!1}vlength(){const{operator:e,value:s}=this;return e==="in"?s.length:0}getData(){const{ci:e,operator:s,value:i}=this;return{ci:e,operator:s,value:i}}}class Sort{constructor(e,s){this.ci=e,this.order=s}asc(){return this.order==="asc"}desc(){return this.order==="desc"}}class AutoFilter{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:e,filters:s,sort:i}){e!=null&&(this.ref=e,this.filters=s.map(r=>new Filter(r.ci,r.operator,r.value)),i&&(this.sort=new Sort(i.ci,i.order)))}getData(){if(this.active()){const{ref:e,filters:s,sort:i}=this;return{ref:e,filters:s.map(r=>r.getData()),sort:i}}return{}}addFilter(e,s,i){const r=this.getFilter(e);r==null?this.filters.push(new Filter(e,s,i)):r.set(s,i)}setSort(e,s){this.sort=s?new Sort(e,s):null}includes(e,s){return this.active()?this.hrange().includes(e,s):!1}getSort(e){const{sort:s}=this;return s&&s.ci===e?s:null}getFilter(e){const{filters:s}=this;for(let i=0;i<s.length;i+=1)if(s[i].ci===e)return s[i];return null}filteredRows(e){const s=new Set,i=new Set;if(this.active()){const{sri:r,eri:o}=this.range(),{filters:l}=this;for(let a=r+1;a<=o;a+=1)for(let c=0;c<l.length;c+=1){const d=l[c],u=e(a,d.ci),f=u?u.text:"";if(d.includes(f))i.add(a);else{s.add(a);break}}}return{rset:s,fset:i}}items(e,s){const i={};if(this.active()){const{sri:r,eri:o}=this.range();for(let l=r+1;l<=o;l+=1){const a=s(l,e);if(a===null||/^\s*$/.test(a.text))i[""]=(i[""]||0)+1;else{const c=a.text,d=(i[c]||0)+1;i[c]=d}}}return i}range(){return CellRange.valueOf(this.ref)}hrange(){const e=this.range();return e.eri=e.sri,e}clear(){this.ref=null,this.filters=[],this.sort=null}active(){return this.ref!==null}}class Merges{constructor(e=[]){this._=e}forEach(e){this._.forEach(e)}deleteWithin(e){this._=this._.filter(s=>!s.within(e))}getFirstIncludes(e,s){for(let i=0;i<this._.length;i+=1){const r=this._[i];if(r.includes(e,s))return r}return null}filterIntersects(e){return new Merges(this._.filter(s=>s.intersects(e)))}intersects(e){for(let s=0;s<this._.length;s+=1)if(this._[s].intersects(e))return!0;return!1}union(e){let s=e;return this._.forEach(i=>{i.intersects(s)&&(s=i.union(s))}),s}add(e){this.deleteWithin(e),this._.push(e)}shift(e,s,i,r){this._.forEach(o=>{const{sri:l,sci:a,eri:c,eci:d}=o,u=o;e==="row"?l>=s?(u.sri+=i,u.eri+=i):l<s&&s<=c&&(u.eri+=i,r(l,a,i,0)):e==="column"&&(a>=s?(u.sci+=i,u.eci+=i):a<s&&s<=d&&(u.eci+=i,r(l,a,0,i)))})}move(e,s,i){this._.forEach(r=>{const o=r;o.within(e)&&(o.eri+=s,o.sri+=s,o.sci+=i,o.eci+=i)})}setData(e){return this._=e.map(s=>CellRange.valueOf(s)),this}getData(){return this._.map(e=>e.toString())}}function cloneDeep(n){return JSON.parse(JSON.stringify(n))}const mergeDeep=(n={},...e)=>(e.forEach(s=>{Object.keys(s).forEach(i=>{const r=s[i];typeof r=="string"||typeof r=="number"||typeof r=="boolean"?n[i]=r:typeof r!="function"&&!Array.isArray(r)&&r instanceof Object?(n[i]=n[i]||{},mergeDeep(n[i],r)):n[i]=r})}),n);function equals(n,e){const s=Object.keys(n);if(s.length!==Object.keys(e).length)return!1;for(let i=0;i<s.length;i+=1){const r=s[i],o=n[r],l=e[r];if(l===void 0)return!1;if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){if(o!==l)return!1}else if(Array.isArray(o)){if(o.length!==l.length)return!1;for(let a=0;a<o.length;a+=1)if(!equals(o[a],l[a]))return!1}else if(typeof o!="function"&&!Array.isArray(o)&&o instanceof Object&&!equals(o,l))return!1}return!0}const sum=(n,e=s=>s)=>{let s=0,i=0;return Object.keys(n).forEach(r=>{s+=e(n[r],r),i+=1}),[s,i]};function deleteProperty(n,e){const s=n[`${e}`];return delete n[`${e}`],s}function rangeReduceIf(n,e,s,i,r,o){let l=s,a=i,c=n;for(;c<e&&!(l>r);c+=1)a=o(c),l+=a;return[c,l-a,a]}function rangeSum(n,e,s){let i=0;for(let r=n;r<e;r+=1)i+=s(r);return i}function rangeEach(n,e,s){for(let i=n;i<e;i+=1)s(i)}function arrayEquals(n,e){if(n.length!==e.length)return!1;for(let s=0;s<n.length;s+=1)if(n[s]!==e[s])return!1;return!0}function digits(n){const e=`${n}`;let s=0,i=!1;for(let r=0;r<e.length;r+=1)i===!0&&(s+=1),e.charAt(r)==="."&&(i=!0);return s}function numberCalc(n,e,s){if(Number.isNaN(e)||Number.isNaN(s))return e+n+s;const i=digits(e),r=digits(s),o=Number(e),l=Number(s);let a=0;if(n==="-")a=o-l;else if(n==="+")a=o+l;else if(n==="*")a=o*l;else if(n==="/")return a=o/l,digits(a)>5?a.toFixed(2):a;return a.toFixed(Math.max(i,r))}const helper_rslib_entry_={cloneDeep,merge:(...n)=>mergeDeep({},...n),equals,arrayEquals,sum,rangeEach,rangeSum,rangeReduceIf,deleteProperty,numberCalc};class Rows{constructor({len:e,height:s}){this._={},this.len=e,this.height=s}getHeight(e){if(this.isHide(e))return 0;const s=this.get(e);return s&&s.height?s.height:this.height}setHeight(e,s){const i=this.getOrNew(e);i.height=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this.get(e);return s&&s.hide}setHide(e,s){const i=this.getOrNew(e);s===!0?i.hide=!0:delete i.hide}setStyle(e,s){const i=this.getOrNew(e);i.style=s}sumHeight(e,s,i){return helper_rslib_entry_.rangeSum(e,s,r=>i&&i.has(r)?0:this.getHeight(r))}totalHeight(){return this.sumHeight(0,this.len)}get(e){return this._[e]}getOrNew(e){return this._[e]=this._[e]||{cells:{}},this._[e]}getCell(e,s){const i=this.get(e);return i!==void 0&&i.cells!==void 0&&i.cells[s]!==void 0?i.cells[s]:null}getCellMerge(e,s){const i=this.getCell(e,s);return i&&i.merge?i.merge:[0,0]}getCellOrNew(e,s){const i=this.getOrNew(e);return i.cells[s]=i.cells[s]||{},i.cells[s]}setCell(e,s,i,r="all"){const o=this.getOrNew(e);r==="all"?o.cells[s]=i:r==="text"?(o.cells[s]=o.cells[s]||{},o.cells[s].text=i.text):r==="format"&&(o.cells[s]=o.cells[s]||{},o.cells[s].style=i.style,i.merge&&(o.cells[s].merge=i.merge))}setCellText(e,s,i){const r=this.getCellOrNew(e,s);r.editable!==!1&&(r.text=i)}copyPaste(e,s,i,r=!1,o=()=>{}){const{sri:l,sci:a,eri:c,eci:d}=e,u=s.sri,f=s.sci,p=s.eri,m=s.eci,[g,x]=e.size(),[b,E]=s.size();let v=!0,w=0;(p<l||m<a)&&(v=!1,w=p<l?b:E);for(let C=l;C<=c;C+=1)if(this._[C]){for(let A=a;A<=d;A+=1)if(this._[C].cells&&this._[C].cells[A])for(let R=u;R<=p;R+=g)for(let j=f;j<=m;j+=x){const L=R+(C-l),V=j+(A-a),W=helper_rslib_entry_.cloneDeep(this._[C].cells[A]);if(r&&W&&W.text&&W.text.length>0){const{text:K}=W;let X=j-f+(R-u)+2;if(v||(X-=w+1),K[0]==="=")W.text=K.replace(/[a-zA-Z]{1,3}\d+/g,z=>{let[H,Y]=[0,0];return l===u?H=X-1:Y=X-1,/^\d+$/.test(z)?z:expr2expr(z,H,Y)});else if(g<=1&&x>1&&(u>c||p<l)||x<=1&&g>1&&(f>d||m<a)||g<=1&&x<=1){const z=/[\\.\d]+$/.exec(K);if(z!==null){const H=Number(z[0])+X-1;W.text=K.substring(0,z.index)+H}}}this.setCell(L,V,W,i),o(L,V,W)}}}cutPaste(e,s){const i={};this.each(r=>{this.eachCells(r,o=>{let l=parseInt(r,10),a=parseInt(o,10);e.includes(r,o)&&(l=s.sri+(l-e.sri),a=s.sci+(a-e.sci)),i[l]=i[l]||{cells:{}},i[l].cells[a]=this._[r].cells[o]})}),this._=i}paste(e,s){if(e.length<=0)return;const{sri:i,sci:r}=s;e.forEach((o,l)=>{const a=i+l;o.forEach((c,d)=>{const u=r+d;this.setCellText(a,u,c)})})}insert(e,s=1){const i={};this.each((r,o)=>{let l=parseInt(r,10);l>=e&&(l+=s,this.eachCells(r,(a,c)=>{c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,0,s,(u,f)=>f>=e)))})),i[l]=o}),this._=i,this.len+=s}delete(e,s){const i=s-e+1,r={};this.each((o,l)=>{const a=parseInt(o,10);a<e?r[a]=l:o>s&&(r[a-i]=l,this.eachCells(o,(c,d)=>{d.text&&d.text[0]==="="&&(d.text=d.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,0,-i,(f,p)=>p>s)))}))}),this._=r,this.len-=i}insertColumn(e,s=1){this.each((i,r)=>{const o={};this.eachCells(i,(l,a)=>{let c=parseInt(l,10);c>=e&&(c+=s,a.text&&a.text[0]==="="&&(a.text=a.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>expr2expr(d,s,0,u=>u>=e)))),o[c]=a}),r.cells=o})}deleteColumn(e,s){const i=s-e+1;this.each((r,o)=>{const l={};this.eachCells(r,(a,c)=>{const d=parseInt(a,10);d<e?l[d]=c:d>s&&(l[d-i]=c,c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,u=>expr2expr(u,-i,0,f=>f>s))))}),o.cells=l})}deleteCells(e,s="all"){e.each((i,r)=>{this.deleteCell(i,r,s)})}deleteCell(e,s,i="all"){const r=this.get(e);if(r!==null){const o=this.getCell(e,s);o!==null&&o.editable!==!1&&(i==="all"?delete r.cells[s]:i==="text"?(o.text&&delete o.text,o.value&&delete o.value):i==="format"?(o.style!==void 0&&delete o.style,o.merge&&delete o.merge):i==="merge"&&o.merge&&delete o.merge)}}maxCell(){const e=Object.keys(this._),s=e[e.length-1],i=this._[s];if(i){const{cells:r}=i,o=Object.keys(r),l=o[o.length-1];return[parseInt(s,10),parseInt(l,10)]}return[0,0]}each(e){Object.entries(this._).forEach(([s,i])=>{e(s,i)})}eachCells(e,s){this._[e]&&this._[e].cells&&Object.entries(this._[e].cells).forEach(([i,r])=>{s(i,r)})}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}}class Cols{constructor({len:e,width:s,indexWidth:i,minWidth:r}){this._={},this.len=e,this.width=s,this.indexWidth=i,this.minWidth=r}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}getWidth(e){if(this.isHide(e))return 0;const s=this._[e];return s&&s.width?s.width:this.width}getOrNew(e){return this._[e]=this._[e]||{},this._[e]}setWidth(e,s){const i=this.getOrNew(e);i.width=s}unhide(e){let s=e;for(;s>0&&(s-=1,this.isHide(s));)this.setHide(s,!1)}isHide(e){const s=this._[e];return s&&s.hide}setHide(e,s){const i=this.getOrNew(e);s===!0?i.hide=!0:delete i.hide}setStyle(e,s){const i=this.getOrNew(e);i.style=s}sumWidth(e,s){return helper_rslib_entry_.rangeSum(e,s,i=>this.getWidth(i))}totalWidth(){return this.sumWidth(0,this.len)}}const en_rslib_entry_={toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};let $languages=["en"];const $messages={en:en_rslib_entry_};function translate(n,e){if(e)for(const s of $languages){if(!e[s])break;let i=e[s];const r=n.match(/(?:\\.|[^.])+/g);for(let o=0;o<r.length;o+=1){const l=r[o],a=i[l];if(!a)break;if(o===r.length-1)return a;i=a}}}function t(n){let e=translate(n,$messages);return!e&&window&&window.x_spreadsheet&&window.x_spreadsheet.$messages&&(e=translate(n,window.x_spreadsheet.$messages)),e||""}function tf(n){return()=>t(n)}function locale(n,e,s=!1){s?$languages=[n]:$languages.unshift(n),e&&($messages[n]=e)}const rules={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function returnMessage(n,e,...s){let i="";return n||(i=t(`validation.${e}`,...s)),[n,i]}class Validator{constructor(e,s,i,r){this.required=s,this.value=i,this.type=e,this.operator=r,this.message=""}parseValue(e){const{type:s}=this;return s==="date"?new Date(e):s==="number"?Number(e):e}equals(e){let s=this.type===e.type&&this.required===e.required&&this.operator===e.operator;return s&&(s=Array.isArray(this.value)?helper_rslib_entry_.arrayEquals(this.value,e.value):this.value===e.value),s}values(){return this.value.split(",")}validate(e){const{required:s,operator:i,value:r,type:o}=this;if(s&&/^\s*$/.test(e))return returnMessage(!1,"required");if(/^\s*$/.test(e))return[!0];if(rules[o]&&!rules[o].test(e))return returnMessage(!1,"notMatch");if(o==="list")return returnMessage(this.values().includes(e),"notIn");if(i){const l=this.parseValue(e);if(i==="be"){const[a,c]=r;return returnMessage(l>=this.parseValue(a)&&l<=this.parseValue(c),"between",a,c)}if(i==="nbe"){const[a,c]=r;return returnMessage(l<this.parseValue(a)||l>this.parseValue(c),"notBetween",a,c)}if(i==="eq")return returnMessage(l===this.parseValue(r),"equal",r);if(i==="neq")return returnMessage(l!==this.parseValue(r),"notEqual",r);if(i==="lt")return returnMessage(l<this.parseValue(r),"lessThan",r);if(i==="lte")return returnMessage(l<=this.parseValue(r),"lessThanEqual",r);if(i==="gt")return returnMessage(l>this.parseValue(r),"greaterThan",r);if(i==="gte")return returnMessage(l>=this.parseValue(r),"greaterThanEqual",r)}return[!0]}}class Validation{constructor(e,s,i){this.refs=s,this.mode=e,this.validator=i}includes(e,s){const{refs:i}=this;for(let r=0;r<i.length;r+=1)if(CellRange.valueOf(i[r]).includes(e,s))return!0;return!1}addRef(e){this.remove(CellRange.valueOf(e)),this.refs.push(e)}remove(e){const s=[];this.refs.forEach(i=>{const r=CellRange.valueOf(i);r.intersects(e)?r.difference(e).forEach(l=>s.push(l.toString())):s.push(i)}),this.refs=s}getData(){const{refs:e,mode:s,validator:i}=this,{type:r,required:o,operator:l,value:a}=i;return{refs:e,mode:s,type:r,required:o,operator:l,value:a}}static valueOf({refs:e,mode:s,type:i,required:r,operator:o,value:l}){return new Validation(s,e,new Validator(i,r,l,o))}}class Validations{constructor(){this._=[],this.errors=new Map}getError(e,s){return this.errors.get(`${e}_${s}`)}validate(e,s,i){const r=this.get(e,s),o=`${e}_${s}`,{errors:l}=this;if(r!==null){const[a,c]=r.validator.validate(i);a?l.delete(o):l.set(o,c)}else l.delete(o);return!0}add(e,s,{type:i,required:r,value:o,operator:l}){const a=new Validator(i,r,o,l),c=this.getByValidator(a);c!==null?c.addRef(s):this._.push(new Validation(e,[s],a))}getByValidator(e){for(let s=0;s<this._.length;s+=1){const i=this._[s];if(i.validator.equals(e))return i}return null}get(e,s){for(let i=0;i<this._.length;i+=1){const r=this._[i];if(r.includes(e,s))return r}return null}remove(e){this.each(s=>{s.remove(e)})}each(e){this._.forEach(s=>e(s))}getData(){return this._.filter(e=>e.refs.length>0).map(e=>e.getData())}setData(e){this._=e.map(s=>Validation.valueOf(s))}}const defaultSettings={mode:"edit",view:{height:()=>document.documentElement.clientHeight,width:()=>document.documentElement.clientWidth},showGrid:!0,showToolbar:!0,showContextmenu:!0,showBottomBar:!0,row:{len:100,height:25},col:{len:26,width:100,indexWidth:60,minWidth:60},style:{bgcolor:"#ffffff",align:"left",valign:"middle",textwrap:!1,strike:!1,underline:!1,color:"#0a0a0a",font:{name:"Arial",size:10,bold:!1,italic:!1},format:"normal"}},toolbarHeight=41,bottombarHeight=41;function canPaste(n,e,s=()=>{}){const{merges:i}=this,r=e.clone(),[o,l]=n.size(),[a,c]=e.size();return o>a&&(r.eri=e.sri+o-1),l>c&&(r.eci=e.sci+l-1),i.intersects(r)?(s(t("error.pasteForMergedCell")),!1):!0}function copyPaste(n,e,s,i=!1){const{rows:r,merges:o}=this;(s==="all"||s==="format")&&(r.deleteCells(e,s),o.deleteWithin(e)),r.copyPaste(n,e,s,i,(l,a,c)=>{if(c&&c.merge){const[d,u]=c.merge;if(d<=0&&u<=0)return;o.add(new CellRange(l,a,l+d,a+u))}})}function cutPaste(n,e){const{clipboard:s,rows:i,merges:r}=this;i.cutPaste(n,e),r.move(n,e.sri-n.sri,e.sci-n.sci),s.clear()}function setStyleBorder(n,e,s){const{styles:i,rows:r}=this,o=r.getCellOrNew(n,e);let l={};o.style!==void 0&&(l=helper_rslib_entry_.cloneDeep(i[o.style])),l=helper_rslib_entry_.merge(l,{border:s}),o.style=this.addStyle(l)}function setStyleBorders({mode:n,style:e,color:s}){const{styles:i,selector:r,rows:o}=this,{sri:l,sci:a,eri:c,eci:d}=r.range,u=!this.isSingleSelected();if(!(!u&&(n==="inside"||n==="horizontal"||n==="vertical")))if(n!=="outside"||u){if(n==="none")r.range.each((f,p)=>{const m=o.getCell(f,p);if(m&&m.style!==void 0){const g=helper_rslib_entry_.cloneDeep(i[m.style]);delete g.border,m.style=this.addStyle(g)}});else if(n==="all"||n==="inside"||n==="outside"||n==="horizontal"||n==="vertical"){const f=[];for(let p=l;p<=c;p+=1)for(let m=a;m<=d;m+=1){const g=[];for(let A=0;A<f.length;A+=1){const[R,j,L,V]=f[A];if(p===R+L+1&&g.push(A),R<=p&&p<=R+L&&m===j){m+=V+1;break}}if(g.forEach(A=>f.splice(A,1)),m>d)break;const x=o.getCell(p,m);let[b,E]=[0,0];x&&x.merge&&([b,E]=x.merge,f.push([p,m,b,E]));const v=b>0&&p+b===c,w=E>0&&m+E===d;let C={};n==="all"?C={bottom:[e,s],top:[e,s],left:[e,s],right:[e,s]}:n==="inside"?(!w&&m<d&&(C.right=[e,s]),!v&&p<c&&(C.bottom=[e,s])):n==="horizontal"?!v&&p<c&&(C.bottom=[e,s]):n==="vertical"?!w&&m<d&&(C.right=[e,s]):n==="outside"&&u&&(l===p&&(C.top=[e,s]),(v||c===p)&&(C.bottom=[e,s]),a===m&&(C.left=[e,s]),(w||d===m)&&(C.right=[e,s])),Object.keys(C).length>0&&setStyleBorder.call(this,p,m,C),m+=E}}else if(n==="top"||n==="bottom")for(let f=a;f<=d;f+=1)n==="top"&&(setStyleBorder.call(this,l,f,{top:[e,s]}),f+=o.getCellMerge(l,f)[1]),n==="bottom"&&(setStyleBorder.call(this,c,f,{bottom:[e,s]}),f+=o.getCellMerge(c,f)[1]);else if(n==="left"||n==="right")for(let f=l;f<=c;f+=1)n==="left"&&(setStyleBorder.call(this,f,a,{left:[e,s]}),f+=o.getCellMerge(f,a)[0]),n==="right"&&(setStyleBorder.call(this,f,d,{right:[e,s]}),f+=o.getCellMerge(f,d)[0])}else setStyleBorder.call(this,l,a,{top:[e,s],bottom:[e,s],left:[e,s],right:[e,s]})}function getCellRowByY(n,e){const{rows:s}=this,i=this.freezeTotalHeight();let r=s.height;i+s.height<n&&(r-=e);const o=this.exceptRowSet;let l=0,a=r,{height:c}=s;for(;l<s.len&&!(a>n);l+=1)o.has(l)||(c=s.getHeight(l),a+=c);return a-=c,a<=0?{ri:-1,top:0,height:c}:{ri:l-1,top:a,height:c}}function getCellColByX(n,e){const{cols:s}=this,i=this.freezeTotalWidth();let r=s.indexWidth;i+s.indexWidth<n&&(r-=e);const[o,l,a]=helper_rslib_entry_.rangeReduceIf(0,s.len,r,s.indexWidth,n,c=>s.getWidth(c));return l<=0?{ci:-1,left:0,width:s.indexWidth}:{ci:o-1,left:l,width:a}}class DataProxy{constructor(e,s){this.settings=helper_rslib_entry_.merge(defaultSettings,s||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new Merges,this.rows=new Rows(this.settings.row),this.cols=new Cols(this.settings.col),this.validations=new Validations,this.hyperlinks={},this.comments={},this.selector=new Selector$1,this.scroll=new Scroll,this.history=new History,this.clipboard=new Clipboard,this.autoFilter=new AutoFilter,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(e,s,i){this.changeData(()=>{this.validations.add(e,s,i)})}removeValidation(){const{range:e}=this.selector;this.changeData(()=>{this.validations.remove(e)})}getSelectedValidator(){const{ri:e,ci:s}=this.selector,i=this.validations.get(e,s);return i?i.validator:null}getSelectedValidation(){const{ri:e,ci:s,range:i}=this.selector,r=this.validations.get(e,s),o={ref:i.toString()};return r!==null&&(o.mode=r.mode,o.validator=r.validator),o}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),e=>{this.setData(e)})}redo(){this.history.redo(this.getData(),e=>{this.setData(e)})}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(e){let s=[];const{sri:i,eri:r,sci:o,eci:l}=this.selector.range;for(let a=i;a<=r;a+=1){const c=[];for(let d=o;d<=l;d+=1){const u=this.getCell(a,d);c.push(u&&u.text||"")}s.push(c)}s=s.map(a=>a.join(" ")).join(`
3
3
  `),e&&(e.clipboardData.clearData(),e.clipboardData.setData("text/plain",s),e.preventDefault()),navigator.clipboard&&navigator.clipboard.writeText(s).then(()=>{},a=>{console.log("text copy to the system clipboard error ",s,a)})}cut(){this.clipboard.cut(this.selector.range)}paste(e="all",s=()=>{}){const{clipboard:i,selector:r}=this;return i.isClear()||!canPaste.call(this,i.range,r.range,s)?!1:(this.changeData(()=>{i.isCopy()?copyPaste.call(this,i.range,r.range,e):i.isCut()&&cutPaste.call(this,i.range,r.range)}),!0)}pasteFromSystemClipboard(e,s){const{selector:i}=this;navigator.clipboard.readText().then(r=>{const o=this.parseClipboardContent(r);let l=i.ri;o.forEach(a=>{let c=i.ci;a.forEach(d=>{this.setCellText(l,c,d,"input"),c+=1}),l+=1}),e(),s(this.rows.getData())})}parseClipboardContent(e){const s=[],i=e.split(`
4
4
  `);let r=0;return i.forEach(o=>{s[r]=o.split(" "),r+=1}),s}pasteFromText(e){let s=[];if(s=/\r\n/.test(e)?e.split(`\r
5
5
  `).map(i=>i.replace(/"/g,"").split(" ")):e.split(`
6
- `).map(i=>i.replace(/"/g,"").split(" ")),s.length){const{rows:i,selector:r}=this;this.changeData(()=>{i.paste(s,r.range)})}}autofill(e,s,i=()=>{}){const r=this.selector.range;return canPaste.call(this,r,e,i)?(this.changeData(()=>{copyPaste.call(this,r,e,s,!0)}),!0):!1}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(e,s){const{selector:i,rows:r,cols:o,merges:l}=this;let{sri:a,sci:c,eri:d,eci:u}=i.range;const f=i.ri,m=i.ci;let[p,g]=[e,s];return e<0&&(p=r.len-1),s<0&&(g=o.len-1),p>f?[a,d]=[f,p]:[a,d]=[p,f],g>m?[c,u]=[m,g]:[c,u]=[g,m],i.range=l.union(new CellRange(a,c,d,u)),i.range=l.union(i.range),i.range}calSelectedRangeByStart(e,s){const{selector:i,rows:r,cols:o,merges:l}=this;let a=l.getFirstIncludes(e,s);return a===null&&(a=new CellRange(e,s,e,s),e===-1&&(a.sri=0,a.eri=r.len-1),s===-1&&(a.sci=0,a.eci=o.len-1)),i.range=a,a}setSelectedCellAttr(e,s){this.changeData(()=>{const{selector:i,styles:r,rows:o}=this;if(e==="merge")s?this.merge():this.unmerge();else if(e==="border")setStyleBorders.call(this,s);else if(e==="formula"){const{ri:l,ci:a,range:c}=i;if(i.multiple()){const[d,u]=i.size(),{sri:f,sci:m,eri:p,eci:g}=c;if(d>1)for(let x=m;x<=g;x+=1){const b=o.getCellOrNew(p+1,x);b.text=`=${s}(${xy2expr(x,f)}:${xy2expr(x,p)})`}else if(u>1){const x=o.getCellOrNew(l,g+1);x.text=`=${s}(${xy2expr(m,l)}:${xy2expr(g,l)})`}}else{const d=o.getCellOrNew(l,a);d.text=`=${s}()`}}else i.range.each((l,a)=>{const c=o.getCellOrNew(l,a);let d={};if(c.style!==void 0&&(d=helper_rslib_entry_.cloneDeep(r[c.style])),e==="format")d.format=s,c.style=this.addStyle(d);else if(e==="font-bold"||e==="font-italic"||e==="font-name"||e==="font-size"){const u={};u[e.split("-")[1]]=s,d.font=Object.assign(d.font||{},u),c.style=this.addStyle(d)}else e==="strike"||e==="textwrap"||e==="underline"||e==="align"||e==="valign"||e==="color"||e==="bgcolor"?(d[e]=s,c.style=this.addStyle(d)):c[e]=s})})}setSelectedCellText(e,s="input"){const{autoFilter:i,selector:r,rows:o}=this,{ri:l,ci:a}=r;let c=l;this.unsortedRowMap.has(l)&&(c=this.unsortedRowMap.get(l));const d=o.getCell(c,a),u=d?d.text:"";if(this.setCellText(c,a,e,s),i.active()){const f=i.getFilter(a);if(f){const m=f.value.findIndex(p=>p===u);m>=0&&f.value.splice(m,1,e)}}}getSelectedCell(){const{ri:e,ci:s}=this.selector;let i=e;return this.unsortedRowMap.has(e)&&(i=this.unsortedRowMap.get(e)),this.rows.getCell(i,s)}xyInSelectedRect(e,s){const{left:i,top:r,width:o,height:l}=this.getSelectedRect(),a=e-this.cols.indexWidth,c=s-this.rows.height;return a>i&&a<i+o&&c>r&&c<r+l}getSelectedRect(){return this.getRect(this.selector.range)}getClipboardRect(){const{clipboard:e}=this;return e.isClear()?{left:-100,top:-100}:this.getRect(e.range)}getRect(e){const{scroll:s,rows:i,cols:r,exceptRowSet:o}=this,{sri:l,sci:a,eri:c,eci:d}=e;if(l<0&&a<0)return{left:0,l:0,top:0,t:0,scroll:s};const u=r.sumWidth(0,a),f=i.sumHeight(0,l,o),m=i.sumHeight(l,c+1,o),p=r.sumWidth(a,d+1);let g=u-s.x,x=f-s.y;const b=this.freezeTotalHeight(),w=this.freezeTotalWidth();return w>0&&w>u&&(g=u),b>0&&b>f&&(x=f),{l:u,t:f,left:g,top:x,height:m,width:p,scroll:s}}getCellRectByXY(e,s){const{scroll:i,merges:r,rows:o,cols:l}=this;let{ri:a,top:c,height:d}=getCellRowByY.call(this,s,i.y),{ci:u,left:f,width:m}=getCellColByX.call(this,e,i.x);if(u===-1&&(m=l.totalWidth()),a===-1&&(d=o.totalHeight()),a>=0||u>=0){const p=r.getFirstIncludes(a,u);p&&(a=p.sri,u=p.sci,{left:f,top:c,width:m,height:d}=this.cellRect(a,u))}return{ri:a,ci:u,left:f,top:c,width:m,height:d}}isSingleSelected(){const{sri:e,sci:s,eri:i,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[l,a]=o.merge;if(e+l===i&&s+a===r)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:e,sci:s,eri:i,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[l,a]=o.merge;if(e+l===i&&s+a===r)return!0}return!1}merge(){const{selector:e,rows:s}=this;if(this.isSingleSelected())return;const[i,r]=e.size();if(i>1||r>1){const{sri:o,sci:l}=e.range;this.changeData(()=>{const a=s.getCellOrNew(o,l);a.merge=[i-1,r-1],this.merges.add(e.range),this.rows.deleteCells(e.range),this.rows.setCell(o,l,a)})}}unmerge(){const{selector:e}=this;if(!this.isSingleSelected())return;const{sri:s,sci:i}=e.range;this.changeData(()=>{this.rows.deleteCell(s,i,"merge"),this.merges.deleteWithin(e.range)})}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:e,selector:s}=this;this.changeData(()=>{e.active()?(e.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):e.ref=s.range.toString()})}setAutoFilter(e,s,i,r){const{autoFilter:o}=this;o.addFilter(e,i,r),o.setSort(e,s),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:e,rows:s}=this;if(!e.active())return;const{sort:i}=e,{rset:r,fset:o}=e.filteredRows((c,d)=>s.getCell(c,d)),l=Array.from(o),a=Array.from(o);i&&l.sort((c,d)=>i.order==="asc"?c-d:i.order==="desc"?d-c:0),this.exceptRowSet=r,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,l.forEach((c,d)=>{this.sortedRowMap.set(a[d],c),this.unsortedRowMap.set(c,a[d])})}deleteCell(e="all"){const{selector:s}=this;this.changeData(()=>{this.rows.deleteCells(s.range,e),(e==="all"||e==="format")&&this.merges.deleteWithin(s.range)})}insert(e,s=1){this.changeData(()=>{const{sri:i,sci:r}=this.selector.range,{rows:o,merges:l,cols:a}=this;let c=i;e==="row"?o.insert(i,s):e==="column"&&(o.insertColumn(r,s),c=r,a.len+=s,Object.keys(a._).reverse().forEach(d=>{const u=parseInt(d,10);u>=r&&(a._[u+s]=a._[u],delete a._[u])})),l.shift(e,c,s,(d,u,f,m)=>{const p=o.getCell(d,u);p.merge[0]+=f,p.merge[1]+=m})})}delete(e){this.changeData(()=>{const{rows:s,merges:i,selector:r,cols:o}=this,{range:l}=r,{sri:a,sci:c,eri:d,eci:u}=r.range,[f,m]=r.range.size();let p=a,g=f;e==="row"?s.delete(a,d):e==="column"&&(s.deleteColumn(c,u),p=l.sci,g=m,o.len-=u-c+1,Object.keys(o._).forEach(x=>{const b=parseInt(x,10);b>=c&&(b>u&&(o._[b-(u-c+1)]=o._[b]),delete o._[b])})),i.shift(e,p,-g,(x,b,w,v)=>{const E=s.getCell(x,b);E.merge[0]+=w,E.merge[1]+=v,E.merge[0]===0&&E.merge[1]===0&&delete E.merge})})}scrollx(e,s){const{scroll:i,freeze:r,cols:o}=this,[,l]=r,[a,c,d]=helper_rslib_entry_.rangeReduceIf(l,o.len,0,0,e,f=>o.getWidth(f));let u=c;e>0&&(u+=d),i.x!==u&&(i.ci=e>0?a:0,i.x=u,s())}scrolly(e,s){const{scroll:i,freeze:r,rows:o}=this,[l]=r,[a,c,d]=helper_rslib_entry_.rangeReduceIf(l,o.len,0,0,e,f=>o.getHeight(f));let u=c;e>0&&(u+=d),i.y!==u&&(i.ri=e>0?a:0,i.y=u,s())}cellRect(e,s){const{rows:i,cols:r}=this,o=r.sumWidth(0,s),l=i.sumHeight(0,e),a=i.getCell(e,s);let c=r.getWidth(s),d=i.getHeight(e);if(a!==null&&a.merge){const[u,f]=a.merge;if(u>0)for(let m=1;m<=u;m+=1)d+=i.getHeight(e+m);if(f>0)for(let m=1;m<=f;m+=1)c+=r.getWidth(s+m)}return{left:o,top:l,width:c,height:d,cell:a}}getCell(e,s){return this.rows.getCell(e,s)}getCellTextOrDefault(e,s){const i=this.getCell(e,s);return i&&i.text?i.text:""}getCellStyle(e,s){const i=this.getCell(e,s);return i&&i.style!==void 0?this.styles[i.style]:null}getCellStyleOrDefault(e,s){const{styles:i,rows:r}=this,o=r.getCell(e,s),l=o&&o.style!==void 0?i[o.style]:{};return helper_rslib_entry_.merge(this.defaultStyle(),l)}getSelectedCellStyle(){const{ri:e,ci:s}=this.selector;return this.getCellStyleOrDefault(e,s)}setCellText(e,s,i,r){const{rows:o,history:l,validations:a}=this;r==="finished"?(o.setCellText(e,s,""),l.add(this.getData()),o.setCellText(e,s,i)):(o.setCellText(e,s,i),this.change(this.getData())),a.validate(e,s,i)}freezeIsActive(){const[e,s]=this.freeze;return e>0||s>0}setFreeze(e,s){this.changeData(()=>{this.freeze=[e,s]})}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(e,s){this.changeData(()=>{this.rows.setHeight(e,s)})}setColWidth(e,s){this.changeData(()=>{this.cols.setWidth(e,s)})}viewHeight(){const{view:e,showToolbar:s,showBottomBar:i}=this.settings;let r=e.height();return i&&(r-=bottombarHeight),s&&(r-=toolbarHeight),r}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[e,s]=this.freeze;return new CellRange(0,0,e-1,s-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:e,cols:s}=this,[i,r]=e.maxCell(),o=e.sumHeight(0,i+1),l=s.sumWidth(0,r+1);return new CellRange(0,0,i,r,l,o)}exceptRowTotalHeight(e,s){const{exceptRowSet:i,rows:r}=this,o=Array.from(i);let l=0;return o.forEach(a=>{if(a<e||a>s){const c=r.getHeight(a);l+=c}}),l}viewRange(){const{scroll:e,rows:s,cols:i,freeze:r,exceptRowSet:o}=this;let{ri:l,ci:a}=e;l<=0&&([l]=r),a<=0&&([,a]=r);let[c,d]=[0,0],[u,f]=[s.len,i.len];for(let m=l;m<s.len&&(o.has(m)||(d+=s.getHeight(m),u=m),!(d>this.viewHeight()));m+=1);for(let m=a;m<i.len&&(c+=i.getWidth(m),f=m,!(c>this.viewWidth()));m+=1);return new CellRange(l,a,u,f,c,d)}eachMergesInView(e,s){this.merges.filterIntersects(e).forEach(i=>s(i))}hideRowsOrCols(){const{rows:e,cols:s,selector:i}=this,[r,o]=i.size(),{sri:l,sci:a,eri:c,eci:d}=i.range;if(r===e.len)for(let u=a;u<=d;u+=1)s.setHide(u,!0);else if(o===s.len)for(let u=l;u<=c;u+=1)e.setHide(u,!0)}unhideRowsOrCols(e,s){this[`${e}s`].unhide(s)}rowEach(e,s,i){let r=0;const{rows:o}=this,l=this.exceptRowSet,a=[...l];let c=0;for(let d=0;d<a.length;d+=1)a[d]<e&&(c+=1);for(let d=e+c;d<=s+c;d+=1)if(l.has(d))c+=1;else{const u=o.getHeight(d);if(u>0&&(i(d,r,u),r+=u,r>this.viewHeight()))break}}colEach(e,s,i){let r=0;const{cols:o}=this;for(let l=e;l<=s;l+=1){const a=o.getWidth(l);if(a>0&&(i(l,r,a),r+=a,r>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(e){const{styles:s}=this;for(let i=0;i<s.length;i+=1){const r=s[i];if(helper_rslib_entry_.equals(r,e))return i}return s.push(e),s.length-1}changeData(e){this.history.add(this.getData()),e(),this.change(this.getData())}setData(e){return Object.keys(e).forEach(s=>{if(s==="merges"||s==="rows"||s==="cols"||s==="validations")this[s].setData(e[s]);else if(s==="freeze"){const[i,r]=expr2xy(e[s]);this.freeze=[r,i]}else s==="autofilter"?this.autoFilter.setData(e[s]):e[s]!==void 0&&(this[s]=e[s])}),this}getData(){const{name:e,freeze:s,styles:i,merges:r,rows:o,cols:l,validations:a,autoFilter:c}=this;return{name:e,freeze:xy2expr(s[1],s[0]),styles:i,merges:r.getData(),rows:o.getData(),cols:l.getData(),validations:a.getData(),autofilter:c.getData()}}}function bind(n,e,s){n.addEventListener(e,s)}function unbind(n,e,s){n.removeEventListener(e,s)}function unbindClickoutside(n){n.xclickoutside&&(unbind(window.document.body,"click",n.xclickoutside),delete n.xclickoutside)}function bindClickoutside(n,e){n.xclickoutside=s=>{s.detail===2||n.contains(s.target)||(e?e(n):(n.hide(),unbindClickoutside(n)))},bind(window.document.body,"click",n.xclickoutside)}function mouseMoveUp(n,e,s){bind(n,"mousemove",e);const i=n;i.xEvtUp=r=>{unbind(n,"mousemove",e),unbind(n,"mouseup",n.xEvtUp),s(r)},bind(n,"mouseup",n.xEvtUp)}function calTouchDirection(n,e,s,i){let r="";Math.abs(n)>Math.abs(e)?(r=n>0?"right":"left",i(r,n,s)):(r=e>0?"down":"up",i(r,e,s))}function bindTouch(n,{move:e,end:s}){let i=0,r=0;bind(n,"touchstart",o=>{const{pageX:l,pageY:a}=o.touches[0];i=l,r=a}),bind(n,"touchmove",o=>{if(!e)return;const{pageX:l,pageY:a}=o.changedTouches[0],c=l-i,d=a-r;(Math.abs(c)>10||Math.abs(d)>10)&&(calTouchDirection(c,d,o,e),i=l,r=a),o.preventDefault()}),bind(n,"touchend",o=>{if(!s)return;const{pageX:l,pageY:a}=o.changedTouches[0],c=l-i,d=a-r;calTouchDirection(c,d,o,s)})}function createEventEmitter(){const n=new Map;function e(l,a){const c=()=>{const u=n.get(l);return Array.isArray(u)&&u.push(a)||!1},d=()=>n.set(l,[].concat(a));return n.has(l)&&c()||d()}function s(l,a){const c=()=>{const d=n.get(l);for(const u of d)u.call(null,...a)};return n.has(l)&&c()}function i(l,a){const c=()=>{const d=n.get(l),u=d.indexOf(a);return u>=0&&d.splice(u,1)&&n.get(l).length===0&&n.delete(l)};return n.has(l)&&c()}function r(l,a){const c=(...d)=>{a.call(null,...d),i(l,c)};return e(l,c)}function o(){n.clear()}return{get current(){return n},on:e,once:r,fire:s,removeListener:i,removeAllListeners:o}}const cssPrefix="x-spreadsheet";class Resizer{constructor(e=!1,s){this.moving=!1,this.vertical=e,this.el=h("div",`${cssPrefix}-resizer ${e?"vertical":"horizontal"}`).children(this.unhideHoverEl=h("div",`${cssPrefix}-resizer-hover`).on("dblclick.stop",i=>this.mousedblclickHandler(i)).css("position","absolute").hide(),this.hoverEl=h("div",`${cssPrefix}-resizer-hover`).on("mousedown.stop",i=>this.mousedownHandler(i)),this.lineEl=h("div",`${cssPrefix}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=s,this.unhideFn=()=>{}}showUnhide(e){this.unhideIndex=e,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(e,s){const{moving:i,vertical:r,hoverEl:o,lineEl:l,el:a,unhideHoverEl:c}=this;if(i)return;this.cRect=e;const{left:d,top:u,width:f,height:m}=e;a.offset({left:r?d+f-5:d,top:r?u:u+m-5}).show(),o.offset({width:r?5:f,height:r?m:5}),l.offset({width:r?0:s.width,height:r?s.height:0}),c.offset({left:r?5-f:d,top:r?u:5-m,width:r?5:f,height:r?m:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(e){let s=e;const{el:i,lineEl:r,cRect:o,vertical:l,minDistance:a}=this;let c=l?o.width:o.height;r.show(),mouseMoveUp(window,d=>{this.moving=!0,s!==null&&d.buttons===1&&(l?(c+=d.movementX,c>a&&i.css("left",`${o.left+c}px`)):(c+=d.movementY,c>a&&i.css("top",`${o.top+c}px`)),s=d)},()=>{s=null,r.hide(),this.moving=!1,this.hide(),this.finishedFn&&(c<a&&(c=a),this.finishedFn(o,c))})}}class Scrollbar{constructor(e){this.vertical=e,this.moveFn=null,this.el=h("div",`${cssPrefix}-scrollbar ${e?"vertical":"horizontal"}`).child(this.contentEl=h("div","")).on("mousemove.stop",()=>{}).on("scroll.stop",s=>{const{scrollTop:i,scrollLeft:r}=s.target;this.moveFn&&this.moveFn(this.vertical?i:r,s)})}move(e){return this.el.scroll(e),this}scroll(){return this.el.scroll()}set(e,s){const i=e-1;if(s>i){const r=this.vertical?"height":"width";this.el.css(r,`${i-15}px`).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(r,`${s}px`)}else this.el.hide();return this}}const selectorHeightBorderWidth=3;let startZIndex=10;class SelectorElement{constructor(e=!1,s=!0){this.useHideInput=e,this.autoFocus=s,this.inputChange=()=>{},this.cornerEl=h("div",`${cssPrefix}-selector-corner`),this.areaEl=h("div",`${cssPrefix}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=h("div",`${cssPrefix}-selector-clipboard`).hide(),this.autofillEl=h("div",`${cssPrefix}-selector-autofill`).hide(),this.el=h("div",`${cssPrefix}-selector`).css("z-index",`${startZIndex}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),e&&(this.hideInput=h("input","").on("compositionend",i=>{this.inputChange(i.target.value)}),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput))),startZIndex+=1}setOffset(e){return this.el.offset(e).show(),this}hide(){return this.el.hide(),this}setAreaOffset(e){const{left:s,top:i,width:r,height:o}=e,l={width:r-selectorHeightBorderWidth+.8,height:o-selectorHeightBorderWidth+.8,left:s-.8,top:i-.8};this.areaEl.offset(l).show(),this.useHideInput&&(this.hideInputDiv.offset(l),this.autoFocus?this.hideInput.val("").focus():this.hideInput.val(""))}setClipboardOffset(e){const{left:s,top:i,width:r,height:o}=e;this.clipboardEl.offset({left:s,top:i,width:r-5,height:o-5})}showAutofill(e){const{left:s,top:i,width:r,height:o}=e;this.autofillEl.offset({width:r-selectorHeightBorderWidth,height:o-selectorHeightBorderWidth,left:s,top:i}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function calBRAreaOffset(n){const{data:e}=this,{left:s,top:i,width:r,height:o,scroll:l,l:a,t:c}=n,d=e.freezeTotalWidth(),u=e.freezeTotalHeight();let f=s-d;d>a&&(f-=l.x);let m=i-u;return u>c&&(m-=l.y),{left:f,top:m,width:r,height:o}}function calTAreaOffset(n){const{data:e}=this,{left:s,width:i,height:r,l:o,t:l,scroll:a}=n,c=e.freezeTotalWidth();let d=s-c;return c>o&&(d-=a.x),{left:d,top:l,width:i,height:r}}function calLAreaOffset(n){const{data:e}=this,{top:s,width:i,height:r,l:o,t:l,scroll:a}=n,c=e.freezeTotalHeight();let d=s-c;return c>l&&(d-=a.y),{left:o,top:d,width:i,height:r}}function setBRAreaOffset(n){const{br:e}=this;e.setAreaOffset(calBRAreaOffset.call(this,n))}function setTLAreaOffset(n){const{tl:e}=this;e.setAreaOffset(n)}function setTAreaOffset(n){const{t:e}=this;e.setAreaOffset(calTAreaOffset.call(this,n))}function setLAreaOffset(n){const{l:e}=this;e.setAreaOffset(calLAreaOffset.call(this,n))}function setLClipboardOffset(n){const{l:e}=this;e.setClipboardOffset(calLAreaOffset.call(this,n))}function setBRClipboardOffset(n){const{br:e}=this;e.setClipboardOffset(calBRAreaOffset.call(this,n))}function setTLClipboardOffset(n){const{tl:e}=this;e.setClipboardOffset(n)}function setTClipboardOffset(n){const{t:e}=this;e.setClipboardOffset(calTAreaOffset.call(this,n))}function setAllAreaOffset(n){setBRAreaOffset.call(this,n),setTLAreaOffset.call(this,n),setTAreaOffset.call(this,n),setLAreaOffset.call(this,n)}function setAllClipboardOffset(n){setBRClipboardOffset.call(this,n),setTLClipboardOffset.call(this,n),setTClipboardOffset.call(this,n),setLClipboardOffset.call(this,n)}class Selector{constructor(e){const{autoFocus:s}=e.settings;this.inputChange=()=>{},this.data=e,this.br=new SelectorElement(!0,s),this.t=new SelectorElement,this.l=new SelectorElement,this.tl=new SelectorElement,this.br.inputChange=i=>{this.inputChange(i)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=h("div",`${cssPrefix}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,startZIndex+=1}resetData(e){this.data=e,this.range=e.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:e,tl:s,t:i,l:r,br:o}=this,l=e.freezeTotalHeight(),a=e.freezeTotalWidth();l>0||a>0?(s.setOffset({width:a,height:l}),i.setOffset({left:a,height:l}),r.setOffset({top:l,width:a}),o.setOffset({left:a,top:l})):(s.hide(),i.hide(),r.hide(),o.setOffset({left:0,top:0}))}resetAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setAllAreaOffset.call(this,e),setAllClipboardOffset.call(this,s),this.resetOffset()}resetBRTAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setTAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setTClipboardOffset.call(this,s),this.resetOffset()}resetBRLAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setLAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setLClipboardOffset.call(this,s),this.resetOffset()}set(e,s,i=!0){const{data:r}=this,o=r.calSelectedRangeByStart(e,s),{sri:l,sci:a}=o;if(i){let[c,d]=[e,s];e<0&&(c=0),s<0&&(d=0),r.selector.setIndexes(c,d),this.indexes=[c,d]}this.moveIndexes=[l,a],this.range=o,this.resetAreaOffset(),this.el.show()}setEnd(e,s,i=!0){const{data:r,lastri:o,lastci:l}=this;if(i){if(e===o&&s===l)return;this.lastri=e,this.lastci=s}this.range=r.calSelectedRangeByEnd(e,s),setAllAreaOffset.call(this,this.data.getSelectedRect())}reset(){const{eri:e,eci:s}=this.data.selector.range;this.setEnd(e,s)}showAutofill(e,s){if(e===-1&&s===-1)return;const{sri:i,sci:r,eri:o,eci:l}=this.range,[a,c]=[e,s],d=i-e,u=r-s,f=o-e,m=l-s;if(u>0)this.arange=new CellRange(i,c,o,r-1);else if(d>0)this.arange=new CellRange(a,r,i-1,l);else if(m<0)this.arange=new CellRange(i,l+1,o,c);else if(f<0)this.arange=new CellRange(o+1,r,a,l);else{this.arange=null;return}if(this.arange!==null){const p=this.data.getRect(this.arange);p.width+=2,p.height+=2;const{br:g,l:x,t:b,tl:w}=this;g.showAutofill(calBRAreaOffset.call(this,p)),x.showAutofill(calLAreaOffset.call(this,p)),b.showAutofill(calTAreaOffset.call(this,p)),w.showAutofill(p)}}hideAutofill(){["br","l","t","tl"].forEach(e=>{this[e].hideAutofill()})}showClipboard(){const e=this.data.getClipboardRect();setAllClipboardOffset.call(this,e),["br","l","t","tl"].forEach(s=>{this[s].showClipboard()})}hideClipboard(){["br","l","t","tl"].forEach(e=>{this[e].hideClipboard()})}}function inputMovePrev(n){n.preventDefault(),n.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}function inputMoveNext(n){n.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}function inputEnter(n){n.preventDefault();const{filterItems:e}=this;e.length<=0||(n.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),e[this.itemIndex].el.click(),this.hide())}function inputKeydownHandler(n){const{keyCode:e}=n;switch(n.ctrlKey&&n.stopPropagation(),e){case 37:n.stopPropagation();break;case 38:inputMovePrev.call(this,n);break;case 39:n.stopPropagation();break;case 40:inputMoveNext.call(this,n);break;case 13:inputEnter.call(this,n);break;case 9:inputEnter.call(this,n);break;default:n.stopPropagation();break}}class Suggest{constructor(e,s,i="200px"){this.filterItems=[],this.items=e,this.el=h("div",`${cssPrefix}-suggest`).css("width",i).hide(),this.itemClick=s,this.itemIndex=-1}setOffset(e){this.el.cssRemoveKeys("top","bottom").offset(e)}hide(){const{el:e}=this;this.filterItems=[],this.itemIndex=-1,e.hide(),unbindClickoutside(this.el.parent())}setItems(e){this.items=e}search(e){let{items:s}=this;if(/^\s*$/.test(e)||(s=s.filter(r=>(r.key||r).startsWith(e.toUpperCase()))),s=s.map(r=>{let{title:o}=r;o?typeof o=="function"&&(o=o()):o=r;const l=h("div",`${cssPrefix}-item`).child(o).on("click.stop",()=>{this.itemClick(r),this.hide()});return r.label&&l.child(h("div","label").html(r.label)),l}),this.filterItems=s,s.length<=0)return;const{el:i}=this;i.html("").children(...s).show(),bindClickoutside(i.parent(),()=>{this.hide()})}bindInputEvents(e){e.on("keydown",s=>inputKeydownHandler.call(this,s))}}class Icon extends Element{constructor(e){super("div",`${cssPrefix}-icon`),this.iconNameEl=h("div",`${cssPrefix}-icon-img ${e}`),this.child(this.iconNameEl)}setName(e){this.iconNameEl.className(`${cssPrefix}-icon-img ${e}`)}}function addMonth(n,e){n.setMonth(n.getMonth()+e)}function weekday(n,e){const s=new Date(n);return s.setDate(e-n.getDay()+1),s}function monthDays(n,e,s){const i=new Date(n,e,1,23,59,59),r=[[],[],[],[],[],[]];for(let o=0;o<6;o+=1)for(let l=0;l<7;l+=1){const a=7*o+l,c=weekday(i,a),d=c.getMonth()!==e,u=c.getMonth()===s.getMonth()&&c.getDate()===s.getDate();r[o][l]={d:c,disabled:d,active:u}}return r}class Calendar{constructor(e){this.value=e,this.cvalue=new Date(e),this.headerLeftEl=h("div","calendar-header-left"),this.bodyEl=h("tbody",""),this.buildAll(),this.el=h("div","x-spreadsheet-calendar").children(h("div","calendar-header").children(this.headerLeftEl,h("div","calendar-header-right").children(h("a","calendar-prev").on("click.stop",()=>this.prev()).child(new Icon("chevron-left")),h("a","calendar-next").on("click.stop",()=>this.next()).child(new Icon("chevron-right")))),h("table","calendar-body").children(h("thead","").child(h("tr","").children(...t("calendar.weeks").map(s=>h("th","cell").child(s)))),this.bodyEl)),this.selectChange=()=>{}}setValue(e){this.value=e,this.cvalue=new Date(e),this.buildAll()}prev(){const{value:e}=this;addMonth(e,-1),this.buildAll()}next(){const{value:e}=this;addMonth(e,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:e}=this;this.headerLeftEl.html(`${t("calendar.months")[e.getMonth()]} ${e.getFullYear()}`)}buildBody(){const{value:e,cvalue:s,bodyEl:i}=this,o=monthDays(e.getFullYear(),e.getMonth(),s).map(l=>{const a=l.map(c=>{let d="cell";return c.disabled&&(d+=" disabled"),c.active&&(d+=" active"),h("td","").child(h("div",d).on("click.stop",()=>{this.selectChange(c.d)}).child(c.d.getDate().toString()))});return h("tr","").children(...a)});i.html("").children(...o)}}class Datepicker{constructor(){this.calendar=new Calendar(new Date),this.el=h("div",`${cssPrefix}-datepicker`).child(this.calendar.el).hide()}setValue(e){const{calendar:s}=this;return typeof e=="string"?/^\d{4}-\d{1,2}-\d{1,2}$/.test(e)&&s.setValue(new Date(e.replace(new RegExp("-","g"),"/"))):e instanceof Date&&s.setValue(e),this}change(e){this.calendar.selectChange=s=>{e(s),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function resetTextareaSize(){const{inputText:n}=this;if(!/^\s*$/.test(n)){const{textlineEl:e,textEl:s,areaOffset:i}=this,r=n.split(`
6
+ `).map(i=>i.replace(/"/g,"").split(" ")),s.length){const{rows:i,selector:r}=this;this.changeData(()=>{i.paste(s,r.range)})}}autofill(e,s,i=()=>{}){const r=this.selector.range;return canPaste.call(this,r,e,i)?(this.changeData(()=>{copyPaste.call(this,r,e,s,!0)}),!0):!1}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(e,s){const{selector:i,rows:r,cols:o,merges:l}=this;let{sri:a,sci:c,eri:d,eci:u}=i.range;const f=i.ri,p=i.ci;let[m,g]=[e,s];return e<0&&(m=r.len-1),s<0&&(g=o.len-1),m>f?[a,d]=[f,m]:[a,d]=[m,f],g>p?[c,u]=[p,g]:[c,u]=[g,p],i.range=l.union(new CellRange(a,c,d,u)),i.range=l.union(i.range),i.range}calSelectedRangeByStart(e,s){const{selector:i,rows:r,cols:o,merges:l}=this;let a=l.getFirstIncludes(e,s);return a===null&&(a=new CellRange(e,s,e,s),e===-1&&(a.sri=0,a.eri=r.len-1),s===-1&&(a.sci=0,a.eci=o.len-1)),i.range=a,a}setSelectedCellAttr(e,s){this.changeData(()=>{const{selector:i,styles:r,rows:o}=this;if(e==="merge")s?this.merge():this.unmerge();else if(e==="border")setStyleBorders.call(this,s);else if(e==="formula"){const{ri:l,ci:a,range:c}=i;if(i.multiple()){const[d,u]=i.size(),{sri:f,sci:p,eri:m,eci:g}=c;if(d>1)for(let x=p;x<=g;x+=1){const b=o.getCellOrNew(m+1,x);b.text=`=${s}(${xy2expr(x,f)}:${xy2expr(x,m)})`}else if(u>1){const x=o.getCellOrNew(l,g+1);x.text=`=${s}(${xy2expr(p,l)}:${xy2expr(g,l)})`}}else{const d=o.getCellOrNew(l,a);d.text=`=${s}()`}}else i.range.each((l,a)=>{const c=o.getCellOrNew(l,a);let d={};if(c.style!==void 0&&(d=helper_rslib_entry_.cloneDeep(r[c.style])),e==="format")d.format=s,c.style=this.addStyle(d);else if(e==="font-bold"||e==="font-italic"||e==="font-name"||e==="font-size"){const u={};u[e.split("-")[1]]=s,d.font=Object.assign(d.font||{},u),c.style=this.addStyle(d)}else e==="strike"||e==="textwrap"||e==="underline"||e==="align"||e==="valign"||e==="color"||e==="bgcolor"?(d[e]=s,c.style=this.addStyle(d)):c[e]=s})})}setSelectedCellText(e,s="input"){const{autoFilter:i,selector:r,rows:o}=this,{ri:l,ci:a}=r;let c=l;this.unsortedRowMap.has(l)&&(c=this.unsortedRowMap.get(l));const d=o.getCell(c,a),u=d?d.text:"";if(this.setCellText(c,a,e,s),i.active()){const f=i.getFilter(a);if(f){const p=f.value.findIndex(m=>m===u);p>=0&&f.value.splice(p,1,e)}}}getSelectedCell(){const{ri:e,ci:s}=this.selector;let i=e;return this.unsortedRowMap.has(e)&&(i=this.unsortedRowMap.get(e)),this.rows.getCell(i,s)}xyInSelectedRect(e,s){const{left:i,top:r,width:o,height:l}=this.getSelectedRect(),a=e-this.cols.indexWidth,c=s-this.rows.height;return a>i&&a<i+o&&c>r&&c<r+l}getSelectedRect(){return this.getRect(this.selector.range)}getClipboardRect(){const{clipboard:e}=this;return e.isClear()?{left:-100,top:-100}:this.getRect(e.range)}getRect(e){const{scroll:s,rows:i,cols:r,exceptRowSet:o}=this,{sri:l,sci:a,eri:c,eci:d}=e;if(l<0&&a<0)return{left:0,l:0,top:0,t:0,scroll:s};const u=r.sumWidth(0,a),f=i.sumHeight(0,l,o),p=i.sumHeight(l,c+1,o),m=r.sumWidth(a,d+1);let g=u-s.x,x=f-s.y;const b=this.freezeTotalHeight(),E=this.freezeTotalWidth();return E>0&&E>u&&(g=u),b>0&&b>f&&(x=f),{l:u,t:f,left:g,top:x,height:p,width:m,scroll:s}}getCellRectByXY(e,s){const{scroll:i,merges:r,rows:o,cols:l}=this;let{ri:a,top:c,height:d}=getCellRowByY.call(this,s,i.y),{ci:u,left:f,width:p}=getCellColByX.call(this,e,i.x);if(u===-1&&(p=l.totalWidth()),a===-1&&(d=o.totalHeight()),a>=0||u>=0){const m=r.getFirstIncludes(a,u);m&&(a=m.sri,u=m.sci,{left:f,top:c,width:p,height:d}=this.cellRect(a,u))}return{ri:a,ci:u,left:f,top:c,width:p,height:d}}isSingleSelected(){const{sri:e,sci:s,eri:i,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[l,a]=o.merge;if(e+l===i&&s+a===r)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:e,sci:s,eri:i,eci:r}=this.selector.range,o=this.getCell(e,s);if(o&&o.merge){const[l,a]=o.merge;if(e+l===i&&s+a===r)return!0}return!1}merge(){const{selector:e,rows:s}=this;if(this.isSingleSelected())return;const[i,r]=e.size();if(i>1||r>1){const{sri:o,sci:l}=e.range;this.changeData(()=>{const a=s.getCellOrNew(o,l);a.merge=[i-1,r-1],this.merges.add(e.range),this.rows.deleteCells(e.range),this.rows.setCell(o,l,a)})}}unmerge(){const{selector:e}=this;if(!this.isSingleSelected())return;const{sri:s,sci:i}=e.range;this.changeData(()=>{this.rows.deleteCell(s,i,"merge"),this.merges.deleteWithin(e.range)})}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:e,selector:s}=this;this.changeData(()=>{e.active()?(e.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):e.ref=s.range.toString()})}setAutoFilter(e,s,i,r){const{autoFilter:o}=this;o.addFilter(e,i,r),o.setSort(e,s),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:e,rows:s}=this;if(!e.active())return;const{sort:i}=e,{rset:r,fset:o}=e.filteredRows((c,d)=>s.getCell(c,d)),l=Array.from(o),a=Array.from(o);i&&l.sort((c,d)=>i.order==="asc"?c-d:i.order==="desc"?d-c:0),this.exceptRowSet=r,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,l.forEach((c,d)=>{this.sortedRowMap.set(a[d],c),this.unsortedRowMap.set(c,a[d])})}deleteCell(e="all"){const{selector:s}=this;this.changeData(()=>{this.rows.deleteCells(s.range,e),(e==="all"||e==="format")&&this.merges.deleteWithin(s.range)})}insert(e,s=1){this.changeData(()=>{const{sri:i,sci:r}=this.selector.range,{rows:o,merges:l,cols:a}=this;let c=i;e==="row"?o.insert(i,s):e==="column"&&(o.insertColumn(r,s),c=r,a.len+=s,Object.keys(a._).reverse().forEach(d=>{const u=parseInt(d,10);u>=r&&(a._[u+s]=a._[u],delete a._[u])})),l.shift(e,c,s,(d,u,f,p)=>{const m=o.getCell(d,u);m.merge[0]+=f,m.merge[1]+=p})})}delete(e){this.changeData(()=>{const{rows:s,merges:i,selector:r,cols:o}=this,{range:l}=r,{sri:a,sci:c,eri:d,eci:u}=r.range,[f,p]=r.range.size();let m=a,g=f;e==="row"?s.delete(a,d):e==="column"&&(s.deleteColumn(c,u),m=l.sci,g=p,o.len-=u-c+1,Object.keys(o._).forEach(x=>{const b=parseInt(x,10);b>=c&&(b>u&&(o._[b-(u-c+1)]=o._[b]),delete o._[b])})),i.shift(e,m,-g,(x,b,E,v)=>{const w=s.getCell(x,b);w.merge[0]+=E,w.merge[1]+=v,w.merge[0]===0&&w.merge[1]===0&&delete w.merge})})}scrollx(e,s){const{scroll:i,freeze:r,cols:o}=this,[,l]=r,[a,c,d]=helper_rslib_entry_.rangeReduceIf(l,o.len,0,0,e,f=>o.getWidth(f));let u=c;e>0&&(u+=d),i.x!==u&&(i.ci=e>0?a:0,i.x=u,s())}scrolly(e,s){const{scroll:i,freeze:r,rows:o}=this,[l]=r,[a,c,d]=helper_rslib_entry_.rangeReduceIf(l,o.len,0,0,e,f=>o.getHeight(f));let u=c;e>0&&(u+=d),i.y!==u&&(i.ri=e>0?a:0,i.y=u,s())}cellRect(e,s){const{rows:i,cols:r}=this,o=r.sumWidth(0,s),l=i.sumHeight(0,e),a=i.getCell(e,s);let c=r.getWidth(s),d=i.getHeight(e);if(a!==null&&a.merge){const[u,f]=a.merge;if(u>0)for(let p=1;p<=u;p+=1)d+=i.getHeight(e+p);if(f>0)for(let p=1;p<=f;p+=1)c+=r.getWidth(s+p)}return{left:o,top:l,width:c,height:d,cell:a}}getCell(e,s){return this.rows.getCell(e,s)}getCellTextOrDefault(e,s){const i=this.getCell(e,s);return i&&i.text?i.text:""}getCellStyle(e,s){const i=this.getCell(e,s);return i&&i.style!==void 0?this.styles[i.style]:null}getCellStyleOrDefault(e,s){const{styles:i,rows:r}=this,o=r.getCell(e,s),l=o&&o.style!==void 0?i[o.style]:{};return helper_rslib_entry_.merge(this.defaultStyle(),l)}getSelectedCellStyle(){const{ri:e,ci:s}=this.selector;return this.getCellStyleOrDefault(e,s)}setCellText(e,s,i,r){const{rows:o,history:l,validations:a}=this;r==="finished"?(o.setCellText(e,s,""),l.add(this.getData()),o.setCellText(e,s,i)):(o.setCellText(e,s,i),this.change(this.getData())),a.validate(e,s,i)}freezeIsActive(){const[e,s]=this.freeze;return e>0||s>0}setFreeze(e,s){this.changeData(()=>{this.freeze=[e,s]})}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(e,s){this.changeData(()=>{this.rows.setHeight(e,s)})}setColWidth(e,s){this.changeData(()=>{this.cols.setWidth(e,s)})}viewHeight(){const{view:e,showToolbar:s,showBottomBar:i}=this.settings;let r=e.height();return i&&(r-=bottombarHeight),s&&(r-=toolbarHeight),r}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[e,s]=this.freeze;return new CellRange(0,0,e-1,s-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:e,cols:s}=this,[i,r]=e.maxCell(),o=e.sumHeight(0,i+1),l=s.sumWidth(0,r+1);return new CellRange(0,0,i,r,l,o)}exceptRowTotalHeight(e,s){const{exceptRowSet:i,rows:r}=this,o=Array.from(i);let l=0;return o.forEach(a=>{if(a<e||a>s){const c=r.getHeight(a);l+=c}}),l}viewRange(){const{scroll:e,rows:s,cols:i,freeze:r,exceptRowSet:o}=this;let{ri:l,ci:a}=e;l<=0&&([l]=r),a<=0&&([,a]=r);let[c,d]=[0,0],[u,f]=[s.len,i.len];for(let p=l;p<s.len&&(o.has(p)||(d+=s.getHeight(p),u=p),!(d>this.viewHeight()));p+=1);for(let p=a;p<i.len&&(c+=i.getWidth(p),f=p,!(c>this.viewWidth()));p+=1);return new CellRange(l,a,u,f,c,d)}eachMergesInView(e,s){this.merges.filterIntersects(e).forEach(i=>s(i))}hideRowsOrCols(){const{rows:e,cols:s,selector:i}=this,[r,o]=i.size(),{sri:l,sci:a,eri:c,eci:d}=i.range;if(r===e.len)for(let u=a;u<=d;u+=1)s.setHide(u,!0);else if(o===s.len)for(let u=l;u<=c;u+=1)e.setHide(u,!0)}unhideRowsOrCols(e,s){this[`${e}s`].unhide(s)}rowEach(e,s,i){let r=0;const{rows:o}=this,l=this.exceptRowSet,a=[...l];let c=0;for(let d=0;d<a.length;d+=1)a[d]<e&&(c+=1);for(let d=e+c;d<=s+c;d+=1)if(l.has(d))c+=1;else{const u=o.getHeight(d);if(u>0&&(i(d,r,u),r+=u,r>this.viewHeight()))break}}colEach(e,s,i){let r=0;const{cols:o}=this;for(let l=e;l<=s;l+=1){const a=o.getWidth(l);if(a>0&&(i(l,r,a),r+=a,r>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(e){const{styles:s}=this;for(let i=0;i<s.length;i+=1){const r=s[i];if(helper_rslib_entry_.equals(r,e))return i}return s.push(e),s.length-1}changeData(e){this.history.add(this.getData()),e(),this.change(this.getData())}setData(e){return Object.keys(e).forEach(s=>{if(s==="merges"||s==="rows"||s==="cols"||s==="validations")this[s].setData(e[s]);else if(s==="freeze"){const[i,r]=expr2xy(e[s]);this.freeze=[r,i]}else s==="autofilter"?this.autoFilter.setData(e[s]):e[s]!==void 0&&(this[s]=e[s])}),this}getData(){const{name:e,freeze:s,styles:i,merges:r,rows:o,cols:l,validations:a,autoFilter:c}=this;return{name:e,freeze:xy2expr(s[1],s[0]),styles:i,merges:r.getData(),rows:o.getData(),cols:l.getData(),validations:a.getData(),autofilter:c.getData()}}}function bind(n,e,s){n.addEventListener(e,s)}function unbind(n,e,s){n.removeEventListener(e,s)}function unbindClickoutside(n){n.xclickoutside&&(unbind(window.document.body,"click",n.xclickoutside),delete n.xclickoutside)}function bindClickoutside(n,e){n.xclickoutside=s=>{s.detail===2||n.contains(s.target)||(e?e(n):(n.hide(),unbindClickoutside(n)))},bind(window.document.body,"click",n.xclickoutside)}function mouseMoveUp(n,e,s){bind(n,"mousemove",e);const i=n;i.xEvtUp=r=>{unbind(n,"mousemove",e),unbind(n,"mouseup",n.xEvtUp),s(r)},bind(n,"mouseup",n.xEvtUp)}function calTouchDirection(n,e,s,i){let r="";Math.abs(n)>Math.abs(e)?(r=n>0?"right":"left",i(r,n,s)):(r=e>0?"down":"up",i(r,e,s))}function bindTouch(n,{move:e,end:s}){let i=0,r=0;bind(n,"touchstart",o=>{const{pageX:l,pageY:a}=o.touches[0];i=l,r=a}),bind(n,"touchmove",o=>{if(!e)return;const{pageX:l,pageY:a}=o.changedTouches[0],c=l-i,d=a-r;(Math.abs(c)>10||Math.abs(d)>10)&&(calTouchDirection(c,d,o,e),i=l,r=a),o.preventDefault()}),bind(n,"touchend",o=>{if(!s)return;const{pageX:l,pageY:a}=o.changedTouches[0],c=l-i,d=a-r;calTouchDirection(c,d,o,s)})}function createEventEmitter(){const n=new Map;function e(l,a){const c=()=>{const u=n.get(l);return Array.isArray(u)&&u.push(a)||!1},d=()=>n.set(l,[].concat(a));return n.has(l)&&c()||d()}function s(l,a){const c=()=>{const d=n.get(l);for(const u of d)u.call(null,...a)};return n.has(l)&&c()}function i(l,a){const c=()=>{const d=n.get(l),u=d.indexOf(a);return u>=0&&d.splice(u,1)&&n.get(l).length===0&&n.delete(l)};return n.has(l)&&c()}function r(l,a){const c=(...d)=>{a.call(null,...d),i(l,c)};return e(l,c)}function o(){n.clear()}return{get current(){return n},on:e,once:r,fire:s,removeListener:i,removeAllListeners:o}}const cssPrefix="x-spreadsheet";class Resizer{constructor(e=!1,s){this.moving=!1,this.vertical=e,this.el=h("div",`${cssPrefix}-resizer ${e?"vertical":"horizontal"}`).children(this.unhideHoverEl=h("div",`${cssPrefix}-resizer-hover`).on("dblclick.stop",i=>this.mousedblclickHandler(i)).css("position","absolute").hide(),this.hoverEl=h("div",`${cssPrefix}-resizer-hover`).on("mousedown.stop",i=>this.mousedownHandler(i)),this.lineEl=h("div",`${cssPrefix}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=s,this.unhideFn=()=>{}}showUnhide(e){this.unhideIndex=e,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(e,s){const{moving:i,vertical:r,hoverEl:o,lineEl:l,el:a,unhideHoverEl:c}=this;if(i)return;this.cRect=e;const{left:d,top:u,width:f,height:p}=e;a.offset({left:r?d+f-5:d,top:r?u:u+p-5}).show(),o.offset({width:r?5:f,height:r?p:5}),l.offset({width:r?0:s.width,height:r?s.height:0}),c.offset({left:r?5-f:d,top:r?u:5-p,width:r?5:f,height:r?p:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(e){let s=e;const{el:i,lineEl:r,cRect:o,vertical:l,minDistance:a}=this;let c=l?o.width:o.height;r.show(),mouseMoveUp(window,d=>{this.moving=!0,s!==null&&d.buttons===1&&(l?(c+=d.movementX,c>a&&i.css("left",`${o.left+c}px`)):(c+=d.movementY,c>a&&i.css("top",`${o.top+c}px`)),s=d)},()=>{s=null,r.hide(),this.moving=!1,this.hide(),this.finishedFn&&(c<a&&(c=a),this.finishedFn(o,c))})}}class Scrollbar{constructor(e){this.vertical=e,this.moveFn=null,this.el=h("div",`${cssPrefix}-scrollbar ${e?"vertical":"horizontal"}`).child(this.contentEl=h("div","")).on("mousemove.stop",()=>{}).on("scroll.stop",s=>{const{scrollTop:i,scrollLeft:r}=s.target;this.moveFn&&this.moveFn(this.vertical?i:r,s)})}move(e){return this.el.scroll(e),this}scroll(){return this.el.scroll()}set(e,s){const i=e-1;if(s>i){const r=this.vertical?"height":"width";this.el.css(r,`${i-15}px`).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(r,`${s}px`)}else this.el.hide();return this}}const selectorHeightBorderWidth=3;let startZIndex=10;class SelectorElement{constructor(e=!1,s=!0){this.useHideInput=e,this.autoFocus=s,this.inputChange=()=>{},this.cornerEl=h("div",`${cssPrefix}-selector-corner`),this.areaEl=h("div",`${cssPrefix}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=h("div",`${cssPrefix}-selector-clipboard`).hide(),this.autofillEl=h("div",`${cssPrefix}-selector-autofill`).hide(),this.el=h("div",`${cssPrefix}-selector`).css("z-index",`${startZIndex}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),e&&(this.hideInput=h("input","").on("compositionend",i=>{this.inputChange(i.target.value)}),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=h("div","hide-input").child(this.hideInput))),startZIndex+=1}setOffset(e){return this.el.offset(e).show(),this}hide(){return this.el.hide(),this}setAreaOffset(e){const{left:s,top:i,width:r,height:o}=e,l={width:r-selectorHeightBorderWidth+.8,height:o-selectorHeightBorderWidth+.8,left:s-.8,top:i-.8};this.areaEl.offset(l).show(),this.useHideInput&&(this.hideInputDiv.offset(l),this.autoFocus?this.hideInput.val("").focus():this.hideInput.val(""))}setClipboardOffset(e){const{left:s,top:i,width:r,height:o}=e;this.clipboardEl.offset({left:s,top:i,width:r-5,height:o-5})}showAutofill(e){const{left:s,top:i,width:r,height:o}=e;this.autofillEl.offset({width:r-selectorHeightBorderWidth,height:o-selectorHeightBorderWidth,left:s,top:i}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function calBRAreaOffset(n){const{data:e}=this,{left:s,top:i,width:r,height:o,scroll:l,l:a,t:c}=n,d=e.freezeTotalWidth(),u=e.freezeTotalHeight();let f=s-d;d>a&&(f-=l.x);let p=i-u;return u>c&&(p-=l.y),{left:f,top:p,width:r,height:o}}function calTAreaOffset(n){const{data:e}=this,{left:s,width:i,height:r,l:o,t:l,scroll:a}=n,c=e.freezeTotalWidth();let d=s-c;return c>o&&(d-=a.x),{left:d,top:l,width:i,height:r}}function calLAreaOffset(n){const{data:e}=this,{top:s,width:i,height:r,l:o,t:l,scroll:a}=n,c=e.freezeTotalHeight();let d=s-c;return c>l&&(d-=a.y),{left:o,top:d,width:i,height:r}}function setBRAreaOffset(n){const{br:e}=this;e.setAreaOffset(calBRAreaOffset.call(this,n))}function setTLAreaOffset(n){const{tl:e}=this;e.setAreaOffset(n)}function setTAreaOffset(n){const{t:e}=this;e.setAreaOffset(calTAreaOffset.call(this,n))}function setLAreaOffset(n){const{l:e}=this;e.setAreaOffset(calLAreaOffset.call(this,n))}function setLClipboardOffset(n){const{l:e}=this;e.setClipboardOffset(calLAreaOffset.call(this,n))}function setBRClipboardOffset(n){const{br:e}=this;e.setClipboardOffset(calBRAreaOffset.call(this,n))}function setTLClipboardOffset(n){const{tl:e}=this;e.setClipboardOffset(n)}function setTClipboardOffset(n){const{t:e}=this;e.setClipboardOffset(calTAreaOffset.call(this,n))}function setAllAreaOffset(n){setBRAreaOffset.call(this,n),setTLAreaOffset.call(this,n),setTAreaOffset.call(this,n),setLAreaOffset.call(this,n)}function setAllClipboardOffset(n){setBRClipboardOffset.call(this,n),setTLClipboardOffset.call(this,n),setTClipboardOffset.call(this,n),setLClipboardOffset.call(this,n)}class Selector{constructor(e){const{autoFocus:s}=e.settings;this.inputChange=()=>{},this.data=e,this.br=new SelectorElement(!0,s),this.t=new SelectorElement,this.l=new SelectorElement,this.tl=new SelectorElement,this.br.inputChange=i=>{this.inputChange(i)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=h("div",`${cssPrefix}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,startZIndex+=1}resetData(e){this.data=e,this.range=e.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:e,tl:s,t:i,l:r,br:o}=this,l=e.freezeTotalHeight(),a=e.freezeTotalWidth();l>0||a>0?(s.setOffset({width:a,height:l}),i.setOffset({left:a,height:l}),r.setOffset({top:l,width:a}),o.setOffset({left:a,top:l})):(s.hide(),i.hide(),r.hide(),o.setOffset({left:0,top:0}))}resetAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setAllAreaOffset.call(this,e),setAllClipboardOffset.call(this,s),this.resetOffset()}resetBRTAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setTAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setTClipboardOffset.call(this,s),this.resetOffset()}resetBRLAreaOffset(){const e=this.data.getSelectedRect(),s=this.data.getClipboardRect();setBRAreaOffset.call(this,e),setLAreaOffset.call(this,e),setBRClipboardOffset.call(this,s),setLClipboardOffset.call(this,s),this.resetOffset()}set(e,s,i=!0){const{data:r}=this,o=r.calSelectedRangeByStart(e,s),{sri:l,sci:a}=o;if(i){let[c,d]=[e,s];e<0&&(c=0),s<0&&(d=0),r.selector.setIndexes(c,d),this.indexes=[c,d]}this.moveIndexes=[l,a],this.range=o,this.resetAreaOffset(),this.el.show()}setEnd(e,s,i=!0){const{data:r,lastri:o,lastci:l}=this;if(i){if(e===o&&s===l)return;this.lastri=e,this.lastci=s}this.range=r.calSelectedRangeByEnd(e,s),setAllAreaOffset.call(this,this.data.getSelectedRect())}reset(){const{eri:e,eci:s}=this.data.selector.range;this.setEnd(e,s)}showAutofill(e,s){if(e===-1&&s===-1)return;const{sri:i,sci:r,eri:o,eci:l}=this.range,[a,c]=[e,s],d=i-e,u=r-s,f=o-e,p=l-s;if(u>0)this.arange=new CellRange(i,c,o,r-1);else if(d>0)this.arange=new CellRange(a,r,i-1,l);else if(p<0)this.arange=new CellRange(i,l+1,o,c);else if(f<0)this.arange=new CellRange(o+1,r,a,l);else{this.arange=null;return}if(this.arange!==null){const m=this.data.getRect(this.arange);m.width+=2,m.height+=2;const{br:g,l:x,t:b,tl:E}=this;g.showAutofill(calBRAreaOffset.call(this,m)),x.showAutofill(calLAreaOffset.call(this,m)),b.showAutofill(calTAreaOffset.call(this,m)),E.showAutofill(m)}}hideAutofill(){["br","l","t","tl"].forEach(e=>{this[e].hideAutofill()})}showClipboard(){const e=this.data.getClipboardRect();setAllClipboardOffset.call(this,e),["br","l","t","tl"].forEach(s=>{this[s].showClipboard()})}hideClipboard(){["br","l","t","tl"].forEach(e=>{this[e].hideClipboard()})}}function inputMovePrev(n){n.preventDefault(),n.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}function inputMoveNext(n){n.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}function inputEnter(n){n.preventDefault();const{filterItems:e}=this;e.length<=0||(n.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),e[this.itemIndex].el.click(),this.hide())}function inputKeydownHandler(n){const{keyCode:e}=n;switch(n.ctrlKey&&n.stopPropagation(),e){case 37:n.stopPropagation();break;case 38:inputMovePrev.call(this,n);break;case 39:n.stopPropagation();break;case 40:inputMoveNext.call(this,n);break;case 13:inputEnter.call(this,n);break;case 9:inputEnter.call(this,n);break;default:n.stopPropagation();break}}class Suggest{constructor(e,s,i="200px"){this.filterItems=[],this.items=e,this.el=h("div",`${cssPrefix}-suggest`).css("width",i).hide(),this.itemClick=s,this.itemIndex=-1}setOffset(e){this.el.cssRemoveKeys("top","bottom").offset(e)}hide(){const{el:e}=this;this.filterItems=[],this.itemIndex=-1,e.hide(),unbindClickoutside(this.el.parent())}setItems(e){this.items=e}search(e){let{items:s}=this;if(/^\s*$/.test(e)||(s=s.filter(r=>(r.key||r).startsWith(e.toUpperCase()))),s=s.map(r=>{let{title:o}=r;o?typeof o=="function"&&(o=o()):o=r;const l=h("div",`${cssPrefix}-item`).child(o).on("click.stop",()=>{this.itemClick(r),this.hide()});return r.label&&l.child(h("div","label").html(r.label)),l}),this.filterItems=s,s.length<=0)return;const{el:i}=this;i.html("").children(...s).show(),bindClickoutside(i.parent(),()=>{this.hide()})}bindInputEvents(e){e.on("keydown",s=>inputKeydownHandler.call(this,s))}}class Icon extends Element{constructor(e){super("div",`${cssPrefix}-icon`),this.iconNameEl=h("div",`${cssPrefix}-icon-img ${e}`),this.child(this.iconNameEl)}setName(e){this.iconNameEl.className(`${cssPrefix}-icon-img ${e}`)}}function addMonth(n,e){n.setMonth(n.getMonth()+e)}function weekday(n,e){const s=new Date(n);return s.setDate(e-n.getDay()+1),s}function monthDays(n,e,s){const i=new Date(n,e,1,23,59,59),r=[[],[],[],[],[],[]];for(let o=0;o<6;o+=1)for(let l=0;l<7;l+=1){const a=7*o+l,c=weekday(i,a),d=c.getMonth()!==e,u=c.getMonth()===s.getMonth()&&c.getDate()===s.getDate();r[o][l]={d:c,disabled:d,active:u}}return r}class Calendar{constructor(e){this.value=e,this.cvalue=new Date(e),this.headerLeftEl=h("div","calendar-header-left"),this.bodyEl=h("tbody",""),this.buildAll(),this.el=h("div","x-spreadsheet-calendar").children(h("div","calendar-header").children(this.headerLeftEl,h("div","calendar-header-right").children(h("a","calendar-prev").on("click.stop",()=>this.prev()).child(new Icon("chevron-left")),h("a","calendar-next").on("click.stop",()=>this.next()).child(new Icon("chevron-right")))),h("table","calendar-body").children(h("thead","").child(h("tr","").children(...t("calendar.weeks").map(s=>h("th","cell").child(s)))),this.bodyEl)),this.selectChange=()=>{}}setValue(e){this.value=e,this.cvalue=new Date(e),this.buildAll()}prev(){const{value:e}=this;addMonth(e,-1),this.buildAll()}next(){const{value:e}=this;addMonth(e,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:e}=this;this.headerLeftEl.html(`${t("calendar.months")[e.getMonth()]} ${e.getFullYear()}`)}buildBody(){const{value:e,cvalue:s,bodyEl:i}=this,o=monthDays(e.getFullYear(),e.getMonth(),s).map(l=>{const a=l.map(c=>{let d="cell";return c.disabled&&(d+=" disabled"),c.active&&(d+=" active"),h("td","").child(h("div",d).on("click.stop",()=>{this.selectChange(c.d)}).child(c.d.getDate().toString()))});return h("tr","").children(...a)});i.html("").children(...o)}}class Datepicker{constructor(){this.calendar=new Calendar(new Date),this.el=h("div",`${cssPrefix}-datepicker`).child(this.calendar.el).hide()}setValue(e){const{calendar:s}=this;return typeof e=="string"?/^\d{4}-\d{1,2}-\d{1,2}$/.test(e)&&s.setValue(new Date(e.replace(new RegExp("-","g"),"/"))):e instanceof Date&&s.setValue(e),this}change(e){this.calendar.selectChange=s=>{e(s),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function resetTextareaSize(){const{inputText:n}=this;if(!/^\s*$/.test(n)){const{textlineEl:e,textEl:s,areaOffset:i}=this,r=n.split(`
7
7
  `),o=Math.max(...r.map(f=>f.length)),a=e.offset().width/n.length,c=(o+1)*a+5,d=this.viewFn().width-i.left-a;let u=r.length;if(c>i.width){let f=c;c>d&&(f=d,u+=parseInt(c/d,10),u+=c%d>0?1:0),s.css("width",`${f}px`)}u*=this.rowHeight,u>i.height&&s.css("height",`${u}px`)}}function insertText({target:n},e){const{value:s,selectionEnd:i}=n,r=`${s.slice(0,i)}${e}${s.slice(i)}`;n.value=r,n.setSelectionRange(i+1,i+1),this.inputText=r,this.textlineEl.html(r),resetTextareaSize.call(this)}function keydownEventHandler(n){const{keyCode:e,altKey:s}=n;e!==13&&e!==9&&n.stopPropagation(),e===13&&s&&(insertText.call(this,n,`
8
- `),n.stopPropagation()),e===13&&!s&&n.preventDefault()}function inputEventHandler(n){const e=n.target.value,{suggest:s,textlineEl:i,validator:r}=this,{cell:o}=this;if(o!==null)if("editable"in o&&o.editable===!0||o.editable===void 0){if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const l=e.lastIndexOf("=");l!==-1?s.search(e.substring(l+1)):s.hide()}i.html(e),resetTextareaSize.call(this),this.change("input",e)}else n.target.value=o.text||"";else{if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const l=e.lastIndexOf("=");l!==-1?s.search(e.substring(l+1)):s.hide()}i.html(e),resetTextareaSize.call(this),this.change("input",e)}}function setTextareaRange(n){const{el:e}=this.textEl;setTimeout(()=>{e.focus(),e.setSelectionRange(n,n)},0)}function setText(n,e){const{textEl:s,textlineEl:i}=this;s.el.blur(),s.val(n),i.html(n),setTextareaRange.call(this,e)}function suggestItemClick(n){const{inputText:e,validator:s}=this;let i=0;if(s&&s.type==="list")this.inputText=n,i=this.inputText.length;else{const r=e.lastIndexOf("="),o=e.substring(0,r+1);let l=e.substring(r+1);l=l.indexOf(")")!==-1?l.substring(l.indexOf(")")):"",this.inputText=`${o+n.key}(`,i=this.inputText.length,this.inputText+=`)${l}`}setText.call(this,this.inputText,i)}function resetSuggestItems(){this.suggest.setItems(this.formulas)}function dateFormat(n){let e=n.getMonth()+1,s=n.getDate();return e<10&&(e=`0${e}`),s<10&&(s=`0${s}`),`${n.getFullYear()}-${e}-${s}`}class Editor{constructor(e,s,i){this.viewFn=s,this.rowHeight=i,this.formulas=e,this.suggest=new Suggest(e,r=>{suggestItemClick.call(this,r)}),this.datepicker=new Datepicker,this.datepicker.change(r=>{this.setText(dateFormat(r)),this.clear()}),this.areaEl=h("div",`${cssPrefix}-editor-area`).children(this.textEl=h("textarea","").on("input",r=>inputEventHandler.call(this,r)).on("paste.stop",()=>{}).on("keydown",r=>keydownEventHandler.call(this,r)),this.textlineEl=h("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",()=>{}).on("mousedown.stop",()=>{}),this.el=h("div",`${cssPrefix}-editor`).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=()=>{}}setFreezeLengths(e,s){this.freeze.w=e,this.freeze.h=s}clear(){this.inputText!==""&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),resetSuggestItems.call(this),this.datepicker.hide()}setOffset(e,s="top"){const{textEl:i,areaEl:r,suggest:o,freeze:l,el:a}=this;if(e){this.areaOffset=e;const{left:c,top:d,width:u,height:f,l:m,t:p}=e,g={left:0,top:0};l.w>m&&l.h>p||(l.w<m&&l.h<p?(g.left=l.w,g.top=l.h):l.w>m?g.top=l.h:l.h>p&&(g.left=l.w)),a.offset(g),r.offset({left:c-g.left-.8,top:d-g.top-.8}),i.offset({width:u-9+.8,height:f-3+.8});const x={left:0};x[s]=f,o.setOffset(x),o.hide()}}setCell(e,s){if(e&&e.editable===!1)return;const{el:i,datepicker:r,suggest:o}=this;i.show(),this.cell=e;const l=e&&e.text||"";if(this.setText(l),this.validator=s,s){const{type:a}=s;a==="date"&&(r.show(),/^\s*$/.test(l)||r.setValue(l)),a==="list"&&(o.setItems(s.values()),o.search(""))}}setText(e){this.inputText=e,setText.call(this,e,e.length),resetTextareaSize.call(this)}}class Button extends Element{constructor(e,s=""){super("div",`${cssPrefix}-button ${s}`),this.child(t(`button.${e}`))}}function dpr(){return window.devicePixelRatio||1}function thinLineWidth(){return dpr()-.5}function npx(n){return parseInt(n*dpr(),10)}function npxLine(n){const e=npx(n);return e>0?e-.5:.5}class DrawBox{constructor(e,s,i,r,o=0){this.x=e,this.y=s,this.width=i,this.height=r,this.padding=o,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}setBorders({top:e,bottom:s,left:i,right:r}){e&&(this.borderTop=e),r&&(this.borderRight=r),s&&(this.borderBottom=s),i&&(this.borderLeft=i)}innerWidth(){return this.width-2*this.padding-2}innerHeight(){return this.height-2*this.padding-2}textx(e){const{width:s,padding:i}=this;let{x:r}=this;return e==="left"?r+=i:e==="center"?r+=s/2:e==="right"&&(r+=s-i),r}texty(e,s){const{height:i,padding:r}=this;let{y:o}=this;return e==="top"?o+=r:e==="middle"?o+=i/2-s/2:e==="bottom"&&(o+=i-r-s),o}topxys(){const{x:e,y:s,width:i}=this;return[[e,s],[e+i,s]]}rightxys(){const{x:e,y:s,width:i,height:r}=this;return[[e+i,s],[e+i,s+r]]}bottomxys(){const{x:e,y:s,width:i,height:r}=this;return[[e,s+r],[e+i,s+r]]}leftxys(){const{x:e,y:s,height:i}=this;return[[e,s],[e,s+i]]}}function drawFontLine(n,e,s,i,r,o,l){const a={x:0,y:0};n==="underline"?r==="bottom"?a.y=0:r==="top"?a.y=-(o+2):a.y=-o/2:n==="strike"&&(r==="bottom"?a.y=o/2:r==="top"&&(a.y=-(o/2+2))),i==="center"?a.x=l/2:i==="right"&&(a.x=l),this.line([e-a.x,s-a.y],[e-a.x+l,s-a.y])}class Draw{constructor(e,s,i){this.el=e,this.ctx=e.getContext("2d"),this.resize(s,i),this.ctx.scale(dpr(),dpr())}resize(e,s){this.el.style.width=`${e}px`,this.el.style.height=`${s}px`,this.el.width=npx(e),this.el.height=npx(s)}clear(){const{width:e,height:s}=this.el;return this.ctx.clearRect(0,0,e,s),this}attr(e){return Object.assign(this.ctx,e),this}save(){return this.ctx.save(),this.ctx.beginPath(),this}restore(){return this.ctx.restore(),this}beginPath(){return this.ctx.beginPath(),this}translate(e,s){return this.ctx.translate(npx(e),npx(s)),this}scale(e,s){return this.ctx.scale(e,s),this}clearRect(e,s,i,r){return this.ctx.clearRect(e,s,i,r),this}fillRect(e,s,i,r){return this.ctx.fillRect(npx(e)-.5,npx(s)-.5,npx(i),npx(r)),this}fillText(e,s,i){return this.ctx.fillText(e,npx(s),npx(i)),this}text(e,s,i={},r=!0){const{ctx:o}=this,{align:l,valign:a,font:c,color:d,strike:u,underline:f}=i,m=s.textx(l);o.save(),o.beginPath(),this.attr({textAlign:l,textBaseline:a,font:`${c.italic?"italic":""} ${c.bold?"bold":""} ${npx(c.size)}px ${c.name}`,fillStyle:d,strokeStyle:d});const p=`${e}`.split(`
9
- `),g=s.innerWidth(),x=[];p.forEach(v=>{const E=o.measureText(v).width;if(r&&E>npx(g)){let C={w:0,len:0,start:0};for(let k=0;k<v.length;k+=1)C.w>=npx(g)&&(x.push(v.substr(C.start,C.len)),C={w:0,len:0,start:k}),C.len+=1,C.w+=o.measureText(v[k]).width+1;C.len>0&&x.push(v.substr(C.start,C.len))}else x.push(v)});const b=(x.length-1)*(c.size+2);let w=s.texty(a,b);return x.forEach(v=>{const E=o.measureText(v).width;this.fillText(v,m,w),u&&drawFontLine.call(this,"strike",m,w,l,a,c.size,E),f&&drawFontLine.call(this,"underline",m,w,l,a,c.size,E),w+=c.size+2}),o.restore(),this}border(e,s){const{ctx:i}=this;return i.lineWidth=thinLineWidth,i.strokeStyle=s,e==="medium"?i.lineWidth=npx(2)-.5:e==="thick"?i.lineWidth=npx(3):e==="dashed"?i.setLineDash([npx(3),npx(2)]):e==="dotted"?i.setLineDash([npx(1),npx(1)]):e==="double"&&i.setLineDash([npx(2),0]),this}line(...e){const{ctx:s}=this;if(e.length>1){s.beginPath();const[i,r]=e[0];s.moveTo(npxLine(i),npxLine(r));for(let o=1;o<e.length;o+=1){const[l,a]=e[o];s.lineTo(npxLine(l),npxLine(a))}s.stroke()}return this}strokeBorders(e){const{ctx:s}=this;s.save();const{borderTop:i,borderRight:r,borderBottom:o,borderLeft:l}=e;i&&(this.border(...i),this.line(...e.topxys())),r&&(this.border(...r),this.line(...e.rightxys())),o&&(this.border(...o),this.line(...e.bottomxys())),l&&(this.border(...l),this.line(...e.leftxys())),s.restore()}dropdown(e){const{ctx:s}=this,{x:i,y:r,width:o,height:l}=e,a=i+o-15,c=r+l-15;s.save(),s.beginPath(),s.moveTo(npx(a),npx(c)),s.lineTo(npx(a+8),npx(c)),s.lineTo(npx(a+4),npx(c+6)),s.closePath(),s.fillStyle="rgba(0, 0, 0, .45)",s.fill(),s.restore()}error(e){const{ctx:s}=this,{x:i,y:r,width:o}=e,l=i+o-1;s.save(),s.beginPath(),s.moveTo(npx(l-8),npx(r-1)),s.lineTo(npx(l),npx(r-1)),s.lineTo(npx(l),npx(r+8)),s.closePath(),s.fillStyle="rgba(255, 0, 0, .65)",s.fill(),s.restore()}frozen(e){const{ctx:s}=this,{x:i,y:r,width:o}=e,l=i+o-1;s.save(),s.beginPath(),s.moveTo(npx(l-8),npx(r-1)),s.lineTo(npx(l),npx(r-1)),s.lineTo(npx(l),npx(r+8)),s.closePath(),s.fillStyle="rgba(0, 255, 0, .85)",s.fill(),s.restore()}rect(e,s){const{ctx:i}=this,{x:r,y:o,width:l,height:a,bgcolor:c}=e;i.save(),i.beginPath(),i.fillStyle=c||"#fff",i.rect(npxLine(r+1),npxLine(o+1),npx(l-2),npx(a-2)),i.clip(),i.fill(),s(),i.restore()}}const baseFonts=[{key:"Arial",title:"Arial"},{key:"Helvetica",title:"Helvetica"},{key:"Source Sans Pro",title:"Source Sans Pro"},{key:"Comic Sans MS",title:"Comic Sans MS"},{key:"Courier New",title:"Courier New"},{key:"Verdana",title:"Verdana"},{key:"Lato",title:"Lato"}],fontSizes=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48},{pt:42,px:56}];function getFontSizePxByPt(n){for(let e=0;e<fontSizes.length;e+=1){const s=fontSizes[e];if(s.pt===n)return s.px}return n}const infixExprToSuffixExpr=n=>{const e=[],s=[];let i=[],r=0,o="",l=1,a="";for(let c=0;c<n.length;c+=1){const d=n.charAt(c);if(d!==" "){if(d>="a"&&d<="z")i.push(d.toUpperCase());else if(d>="0"&&d<="9"||d>="A"&&d<="Z"||d===".")i.push(d);else if(d==='"'){for(c+=1;n.charAt(c)!=='"';)i.push(n.charAt(c)),c+=1;s.push(`"${i.join("")}`),i=[]}else if(d==="-"&&/[+\-*/,(]/.test(a))i.push(d);else{if(d!=="("&&i.length>0&&s.push(i.join("")),d===")"){let u=e.pop();if(r===2)try{const[f,m]=expr2xy(s.pop()),[p,g]=expr2xy(s.pop());let x=0;for(let b=p;b<=f;b+=1)for(let w=g;w<=m;w+=1)s.push(xy2expr(b,w)),x+=1;s.push([u,x])}catch(f){}else if(r===1||r===3)r===3&&s.push(o),s.push([u,l]),l=1;else for(;u!=="("&&(s.push(u),!(e.length<=0));)u=e.pop();r=0}else if(d==="="||d===">"||d==="<"){const u=n.charAt(c+1);o=d,(u==="="||u==="-")&&(o+=u,c+=1),r=3}else if(d===":")r=2;else if(d===",")r===3&&s.push(o),r=1,l+=1;else if(d==="("&&i.length>0)e.push(i.join(""));else{if(e.length>0&&(d==="+"||d==="-")){let u=e[e.length-1];if(u!=="("&&s.push(e.pop()),u==="*"||u==="/")for(;e.length>0&&(u=e[e.length-1],u!=="(");)s.push(e.pop())}else if(e.length>0){const u=e[e.length-1];(u==="*"||u==="/")&&s.push(e.pop())}e.push(d)}i=[]}a=d}}for(i.length>0&&s.push(i.join(""));e.length>0;)s.push(e.pop());return s},evalSubExpr=(n,e)=>{const[s]=n;let i=n;if(s==='"')return n.substring(1);let r=1;if(s==="-"&&(i=n.substring(1),r=-1),i[0]>="0"&&i[0]<="9")return r*Number(i);const[o,l]=expr2xy(i);return r*e(o,l)},evalSuffixExpr=(n,e,s,i)=>{const r=[];for(let o=0;o<n.length;o+=1){const l=n[o],a=l[0];if(l==="+"){const c=r.pop();r.push(numberCalc("+",r.pop(),c))}else if(l==="-")if(r.length===1){const c=r.pop();r.push(numberCalc("*",c,-1))}else{const c=r.pop();r.push(numberCalc("-",r.pop(),c))}else if(l==="*")r.push(numberCalc("*",r.pop(),r.pop()));else if(l==="/"){const c=r.pop();r.push(numberCalc("/",r.pop(),c))}else if(a==="="||a===">"||a==="<"){let c=r.pop();Number.isNaN(c)||(c=Number(c));let d=r.pop();Number.isNaN(d)||(d=Number(d));let u=!1;a==="="?u=d===c:l===">"?u=d>c:l===">="?u=d>=c:l==="<"?u=d<c:l==="<="&&(u=d<=c),r.push(u)}else if(Array.isArray(l)){const[c,d]=l,u=[];for(let f=0;f<d;f+=1)u.push(r.pop());r.push(e[c].render(u.reverse()))}else{if(i.includes(l))return 0;(a>="a"&&a<="z"||a>="A"&&a<="Z")&&i.push(l),r.push(evalSubExpr(l,s)),i.pop()}}return r[0]},cell_rslib_entry_cellRender=(n,e,s,i=[])=>{if(n[0]==="="){const r=infixExprToSuffixExpr(n.substring(1));return r.length<=0?n:evalSuffixExpr(r,e,(o,l)=>cell_rslib_entry_cellRender(s(o,l),e,s,i),i)}return n},cell_rslib_entry_={render:cell_rslib_entry_cellRender},baseFormulas=[{key:"SUM",title:tf("formula.sum"),render:n=>n.reduce((e,s)=>numberCalc("+",e,s),0)},{key:"AVERAGE",title:tf("formula.average"),render:n=>n.reduce((e,s)=>Number(e)+Number(s),0)/n.length},{key:"MAX",title:tf("formula.max"),render:n=>Math.max(...n.map(e=>Number(e)))},{key:"MIN",title:tf("formula.min"),render:n=>Math.min(...n.map(e=>Number(e)))},{key:"IF",title:tf("formula._if"),render:([n,e,s])=>n?e:s},{key:"AND",title:tf("formula.and"),render:n=>n.every(e=>e)},{key:"OR",title:tf("formula.or"),render:n=>n.some(e=>e)},{key:"CONCAT",title:tf("formula.concat"),render:n=>n.join("")}],formulas=baseFormulas,formulam={};baseFormulas.forEach(n=>{formulam[n.key]=n});const formatStringRender=n=>n,formatNumberRender=n=>{if(/^(-?\d*.?\d*)$/.test(n)){const e=Number(n).toFixed(2).toString(),[s,...i]=e.split("\\.");return[s.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),...i]}return n},baseFormats=[{key:"normal",title:tf("format.normal"),type:"string",render:formatStringRender},{key:"text",title:tf("format.text"),type:"string",render:formatStringRender},{key:"number",title:tf("format.number"),type:"number",label:"1,000.12",render:formatNumberRender},{key:"percent",title:tf("format.percent"),type:"number",label:"10.12%",render:n=>`${n}%`},{key:"rmb",title:tf("format.rmb"),type:"number",label:"¥10.00",render:n=>`¥${formatNumberRender(n)}`},{key:"usd",title:tf("format.usd"),type:"number",label:"$10.00",render:n=>`$${formatNumberRender(n)}`},{key:"eur",title:tf("format.eur"),type:"number",label:"€10.00",render:n=>`€${formatNumberRender(n)}`},{key:"date",title:tf("format.date"),type:"date",label:"26/09/2008",render:formatStringRender},{key:"time",title:tf("format.time"),type:"date",label:"15:59:00",render:formatStringRender},{key:"datetime",title:tf("format.datetime"),type:"date",label:"26/09/2008 15:59:00",render:formatStringRender},{key:"duration",title:tf("format.duration"),type:"date",label:"24:01:00",render:formatStringRender}],formatm={};baseFormats.forEach(n=>{formatm[n.key]=n});const cellPaddingWidth=5,tableFixedHeaderCleanStyle={fillStyle:"#f4f5f8"},tableGridStyle={fillStyle:"#fff",lineWidth:thinLineWidth,strokeStyle:"#e6e6e6"};function tableFixedHeaderStyle(){return{textAlign:"center",textBaseline:"middle",font:`500 ${npx(12)}px Source Sans Pro`,fillStyle:"#585757",lineWidth:thinLineWidth(),strokeStyle:"#e6e6e6"}}function getDrawBox(n,e,s,i=0){const{left:r,top:o,width:l,height:a}=n.cellRect(e,s);return new DrawBox(r,o+i,l,a,cellPaddingWidth)}function renderCell(n,e,s,i,r=0){const{sortedRowMap:o,rows:l,cols:a}=e;if(l.isHide(s)||a.isHide(i))return;let c=s;o.has(s)&&(c=o.get(s));const d=e.getCell(c,i);if(d===null)return;let u=!1;"editable"in d&&d.editable===!1&&(u=!0);const f=e.getCellStyleOrDefault(c,i),m=getDrawBox(e,s,i,r);m.bgcolor=f.bgcolor,f.border!==void 0&&(m.setBorders(f.border),n.strokeBorders(m)),n.rect(m,()=>{let p="";p=e.settings.evalPaused?d.text||"":cell_rslib_entry_.render(d.text||"",formulam,(b,w)=>e.getCellTextOrDefault(w,b)),f.format&&(p=formatm[f.format].render(p));const g=Object.assign({},f.font);g.size=getFontSizePxByPt(g.size),n.text(p,m,{align:f.align,valign:f.valign,font:g,color:f.color,strike:f.strike,underline:f.underline},f.textwrap),e.validations.getError(s,i)&&n.error(m),u&&n.frozen(m)})}function renderAutofilter(n){const{data:e,draw:s}=this;if(n){const{autoFilter:i}=e;if(!i.active())return;const r=i.hrange();n.intersects(r)&&r.each((o,l)=>{const a=getDrawBox(e,o,l);s.dropdown(a)})}}function renderContent(n,e,s,i,r){const{draw:o,data:l}=this;o.save(),o.translate(e,s).translate(i,r);const{exceptRowSet:a}=l,c=f=>{const m=a.has(f);if(m){const p=l.rows.getHeight(f);o.translate(0,-p)}return!m},d=l.exceptRowTotalHeight(n.sri,n.eri);o.save(),o.translate(0,-d),n.each((f,m)=>{renderCell(o,l,f,m)},f=>c(f)),o.restore();const u=new Set;o.save(),o.translate(0,-d),l.eachMergesInView(n,({sri:f,sci:m,eri:p})=>{if(a.has(f)){if(!u.has(f)){u.add(f);const g=l.rows.sumHeight(f,p+1);o.translate(0,-g)}}else renderCell(o,l,f,m)}),o.restore(),renderAutofilter.call(this,n),o.restore()}function renderSelectedHeaderCell(n,e,s,i){const{draw:r}=this;r.save(),r.attr({fillStyle:"rgba(75, 137, 255, 0.08)"}).fillRect(n,e,s,i),r.restore()}function renderFixedHeaders(n,e,s,i,r,o){const{draw:l,data:a}=this,c=e.h,d=e.w,u=o+i,f=r+s;l.save(),l.attr(tableFixedHeaderCleanStyle),(n==="all"||n==="left")&&l.fillRect(0,u,s,c),(n==="all"||n==="top")&&l.fillRect(f,0,d,i);const{sri:m,sci:p,eri:g,eci:x}=a.selector.range;l.attr(tableFixedHeaderStyle()),(n==="all"||n==="left")&&(a.rowEach(e.sri,e.eri,(b,w,v)=>{const E=u+w,C=b;l.line([0,E],[s,E]),m<=C&&C<g+1&&renderSelectedHeaderCell.call(this,0,E,s,v),l.fillText(C+1,s/2,E+v/2),b>0&&a.rows.isHide(b-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([5,E+5],[s-5,E+5]),l.restore())}),l.line([0,c+u],[s,c+u]),l.line([s,u],[s,c+u])),(n==="all"||n==="top")&&(a.colEach(e.sci,e.eci,(b,w,v)=>{const E=f+w,C=b;l.line([E,0],[E,i]),p<=C&&C<x+1&&renderSelectedHeaderCell.call(this,E,0,v,i),l.fillText(stringAt(C),E+v/2,i/2),b>0&&a.cols.isHide(b-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([E+5,5],[E+5,i-5]),l.restore())}),l.line([d+f,0],[d+f,i]),l.line([0,i],[d+f,i])),l.restore()}function renderFixedLeftTopCell(n,e){const{draw:s}=this;s.save(),s.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,n,e),s.restore()}function renderContentGrid({sri:n,sci:e,eri:s,eci:i,w:r,h:o},l,a,c,d){const{draw:u,data:f}=this,{settings:m}=f;if(u.save(),u.attr(tableGridStyle).translate(l+c,a+d),!m.showGrid){u.restore();return}f.rowEach(n,s,(p,g,x)=>{p!==n&&u.line([0,g],[r,g]),p===s&&u.line([0,g+x],[r,g+x])}),f.colEach(e,i,(p,g,x)=>{p!==e&&u.line([g,0],[g,o]),p===i&&u.line([g+x,0],[g+x,o])}),u.restore()}function renderFreezeHighlightLine(n,e,s,i){const{draw:r,data:o}=this,l=o.viewWidth()-n,a=o.viewHeight()-e;r.save().translate(n,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),r.line([0,i],[l,i]),r.line([s,0],[s,a]),r.restore()}class Table{constructor(e,s){this.el=e,this.draw=new Draw(e,s.viewWidth(),s.viewHeight()),this.data=s}resetData(e){this.data=e,this.render()}render(){const{data:e}=this,{rows:s,cols:i}=e,r=i.indexWidth,o=s.height;this.draw.resize(e.viewWidth(),e.viewHeight()),this.clear();const l=e.viewRange(),a=e.freezeTotalWidth(),c=e.freezeTotalHeight(),{x:d,y:u}=e.scroll;renderContentGrid.call(this,l,r,o,a,c),renderContent.call(this,l,r,o,-d,-u),renderFixedHeaders.call(this,"all",l,r,o,a,c),renderFixedLeftTopCell.call(this,r,o);const[f,m]=e.freeze;if(f>0||m>0){if(f>0){const g=l.clone();g.sri=0,g.eri=f-1,g.h=c,renderContentGrid.call(this,g,r,o,a,0),renderContent.call(this,g,r,o,-d,0),renderFixedHeaders.call(this,"top",g,r,o,a,0)}if(m>0){const g=l.clone();g.sci=0,g.eci=m-1,g.w=a,renderContentGrid.call(this,g,r,o,0,c),renderFixedHeaders.call(this,"left",g,r,o,0,c),renderContent.call(this,g,r,o,0,-u)}const p=e.freezeViewRange();renderContentGrid.call(this,p,r,o,0,0),renderFixedHeaders.call(this,"all",p,r,o,0,0),renderContent.call(this,p,r,o,0,0),renderFreezeHighlightLine.call(this,r,o,a,c)}}clear(){this.draw.clear()}}const table_rslib_entry_=Table,PAGER_SIZES=[["A3",11.69,16.54],["A4",8.27,11.69],["A5",5.83,8.27],["B4",9.84,13.9],["B5",6.93,9.84]],PAGER_ORIENTATIONS=["landscape","portrait"];function inches2px(n){return parseInt(96*n,10)}function btnClick(n){n==="cancel"?this.el.hide():this.toPrint()}function pagerSizeChange(n){const{paper:e}=this,{value:s}=n.target,i=PAGER_SIZES[s];e.w=inches2px(i[1]),e.h=inches2px(i[2]),this.preview()}function pagerOrientationChange(n){const{paper:e}=this,{value:s}=n.target,i=PAGER_ORIENTATIONS[s];e.orientation=i,this.preview()}let Print$1=class{constructor(e){this.paper={w:inches2px(PAGER_SIZES[0][1]),h:inches2px(PAGER_SIZES[0][2]),padding:50,orientation:PAGER_ORIENTATIONS[0],get width(){return this.orientation==="landscape"?this.h:this.w},get height(){return this.orientation==="landscape"?this.w:this.h}},this.data=e,this.el=h("div",`${cssPrefix}-print`).children(h("div",`${cssPrefix}-print-bar`).children(h("div","-title").child("Print settings"),h("div","-right").children(h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",btnClick.bind(this,"cancel")),new Button("next","primary").on("click",btnClick.bind(this,"next"))))),h("div",`${cssPrefix}-print-content`).children(this.contentEl=h("div","-content"),h("div","-sider").child(h("form","").children(h("fieldset","").children(h("label","").child(`${t("print.size")}`),h("select","").children(...PAGER_SIZES.map((s,i)=>h("option","").attr("value",i).child(`${s[0]} ( ${s[1]}''x${s[2]}'' )`))).on("change",pagerSizeChange.bind(this))),h("fieldset","").children(h("label","").child(`${t("print.orientation")}`),h("select","").children(...PAGER_ORIENTATIONS.map((s,i)=>h("option","").attr("value",i).child(`${t("print.orientations")[i]}`))).on("change",pagerOrientationChange.bind(this))))))).hide()}resetData(e){this.data=e}preview(){const{data:e,paper:s}=this,{width:i,height:r,padding:o}=s,l=i-2*o,a=r-2*o,c=e.contentRange(),d=parseInt(c.h/a,10)+1,u=l/c.w;let f=o;const m=o;u>1&&(f+=(l-c.w)/2);let p=0,g=0;this.contentEl.html(""),this.canvases=[];const x={sri:0,sci:0,eri:0,eci:0};for(let b=0;b<d;b+=1){let w=0,v=0;const E=h("div",`${cssPrefix}-canvas-card`),C=h("canvas",`${cssPrefix}-canvas`);this.canvases.push(C.el);const k=new Draw(C.el,i,r);for(k.save(),k.translate(f,m),u<1&&k.scale(u,u);p<=c.eri;p+=1){const j=e.rows.getHeight(p);if(w+=j,w<a)for(let O=0;O<=c.eci;O+=1)renderCell(k,e,p,O,g),x.eci=O;else{v=-(w-j);break}}x.eri=p,k.restore(),k.save(),k.translate(f,m),u<1&&k.scale(u,u);const R=g;e.eachMergesInView(x,({sri:j,sci:O})=>{renderCell(k,e,j,O,R)}),k.restore(),x.sri=x.eri,x.sci=x.eci,g+=v,this.contentEl.child(h("div",`${cssPrefix}-canvas-card-wraper`).child(E.child(C)))}this.el.show()}toPrint(){this.el.hide();const{paper:e}=this,s=h("iframe","").hide(),{el:i}=s;window.document.body.appendChild(i);const{contentWindow:r}=i,o=r.document,l=document.createElement("style");l.innerHTML=`
8
+ `),n.stopPropagation()),e===13&&!s&&n.preventDefault()}function inputEventHandler(n){const e=n.target.value,{suggest:s,textlineEl:i,validator:r}=this,{cell:o}=this;if(o!==null)if("editable"in o&&o.editable===!0||o.editable===void 0){if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const l=e.lastIndexOf("=");l!==-1?s.search(e.substring(l+1)):s.hide()}i.html(e),resetTextareaSize.call(this),this.change("input",e)}else n.target.value=o.text||"";else{if(this.inputText=e,r)r.type==="list"?s.search(e):s.hide();else{const l=e.lastIndexOf("=");l!==-1?s.search(e.substring(l+1)):s.hide()}i.html(e),resetTextareaSize.call(this),this.change("input",e)}}function setTextareaRange(n){const{el:e}=this.textEl;setTimeout(()=>{e.focus(),e.setSelectionRange(n,n)},0)}function setText(n,e){const{textEl:s,textlineEl:i}=this;s.el.blur(),s.val(n),i.html(n),setTextareaRange.call(this,e)}function suggestItemClick(n){const{inputText:e,validator:s}=this;let i=0;if(s&&s.type==="list")this.inputText=n,i=this.inputText.length;else{const r=e.lastIndexOf("="),o=e.substring(0,r+1);let l=e.substring(r+1);l=l.indexOf(")")!==-1?l.substring(l.indexOf(")")):"",this.inputText=`${o+n.key}(`,i=this.inputText.length,this.inputText+=`)${l}`}setText.call(this,this.inputText,i)}function resetSuggestItems(){this.suggest.setItems(this.formulas)}function dateFormat(n){let e=n.getMonth()+1,s=n.getDate();return e<10&&(e=`0${e}`),s<10&&(s=`0${s}`),`${n.getFullYear()}-${e}-${s}`}class Editor{constructor(e,s,i){this.viewFn=s,this.rowHeight=i,this.formulas=e,this.suggest=new Suggest(e,r=>{suggestItemClick.call(this,r)}),this.datepicker=new Datepicker,this.datepicker.change(r=>{this.setText(dateFormat(r)),this.clear()}),this.areaEl=h("div",`${cssPrefix}-editor-area`).children(this.textEl=h("textarea","").on("input",r=>inputEventHandler.call(this,r)).on("paste.stop",()=>{}).on("keydown",r=>keydownEventHandler.call(this,r)),this.textlineEl=h("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",()=>{}).on("mousedown.stop",()=>{}),this.el=h("div",`${cssPrefix}-editor`).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=()=>{}}setFreezeLengths(e,s){this.freeze.w=e,this.freeze.h=s}clear(){this.inputText!==""&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),resetSuggestItems.call(this),this.datepicker.hide()}setOffset(e,s="top"){const{textEl:i,areaEl:r,suggest:o,freeze:l,el:a}=this;if(e){this.areaOffset=e;const{left:c,top:d,width:u,height:f,l:p,t:m}=e,g={left:0,top:0};l.w>p&&l.h>m||(l.w<p&&l.h<m?(g.left=l.w,g.top=l.h):l.w>p?g.top=l.h:l.h>m&&(g.left=l.w)),a.offset(g),r.offset({left:c-g.left-.8,top:d-g.top-.8}),i.offset({width:u-9+.8,height:f-3+.8});const x={left:0};x[s]=f,o.setOffset(x),o.hide()}}setCell(e,s){if(e&&e.editable===!1)return;const{el:i,datepicker:r,suggest:o}=this;i.show(),this.cell=e;const l=e&&e.text||"";if(this.setText(l),this.validator=s,s){const{type:a}=s;a==="date"&&(r.show(),/^\s*$/.test(l)||r.setValue(l)),a==="list"&&(o.setItems(s.values()),o.search(""))}}setText(e){this.inputText=e,setText.call(this,e,e.length),resetTextareaSize.call(this)}}class Button extends Element{constructor(e,s=""){super("div",`${cssPrefix}-button ${s}`),this.child(t(`button.${e}`))}}function dpr(){return window.devicePixelRatio||1}function thinLineWidth(){return dpr()-.5}function npx(n){return parseInt(n*dpr(),10)}function npxLine(n){const e=npx(n);return e>0?e-.5:.5}class DrawBox{constructor(e,s,i,r,o=0){this.x=e,this.y=s,this.width=i,this.height=r,this.padding=o,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}setBorders({top:e,bottom:s,left:i,right:r}){e&&(this.borderTop=e),r&&(this.borderRight=r),s&&(this.borderBottom=s),i&&(this.borderLeft=i)}innerWidth(){return this.width-2*this.padding-2}innerHeight(){return this.height-2*this.padding-2}textx(e){const{width:s,padding:i}=this;let{x:r}=this;return e==="left"?r+=i:e==="center"?r+=s/2:e==="right"&&(r+=s-i),r}texty(e,s){const{height:i,padding:r}=this;let{y:o}=this;return e==="top"?o+=r:e==="middle"?o+=i/2-s/2:e==="bottom"&&(o+=i-r-s),o}topxys(){const{x:e,y:s,width:i}=this;return[[e,s],[e+i,s]]}rightxys(){const{x:e,y:s,width:i,height:r}=this;return[[e+i,s],[e+i,s+r]]}bottomxys(){const{x:e,y:s,width:i,height:r}=this;return[[e,s+r],[e+i,s+r]]}leftxys(){const{x:e,y:s,height:i}=this;return[[e,s],[e,s+i]]}}function drawFontLine(n,e,s,i,r,o,l){const a={x:0,y:0};n==="underline"?r==="bottom"?a.y=0:r==="top"?a.y=-(o+2):a.y=-o/2:n==="strike"&&(r==="bottom"?a.y=o/2:r==="top"&&(a.y=-(o/2+2))),i==="center"?a.x=l/2:i==="right"&&(a.x=l),this.line([e-a.x,s-a.y],[e-a.x+l,s-a.y])}class Draw{constructor(e,s,i){this.el=e,this.ctx=e.getContext("2d"),this.resize(s,i),this.ctx.scale(dpr(),dpr())}resize(e,s){this.el.style.width=`${e}px`,this.el.style.height=`${s}px`,this.el.width=npx(e),this.el.height=npx(s)}clear(){const{width:e,height:s}=this.el;return this.ctx.clearRect(0,0,e,s),this}attr(e){return Object.assign(this.ctx,e),this}save(){return this.ctx.save(),this.ctx.beginPath(),this}restore(){return this.ctx.restore(),this}beginPath(){return this.ctx.beginPath(),this}translate(e,s){return this.ctx.translate(npx(e),npx(s)),this}scale(e,s){return this.ctx.scale(e,s),this}clearRect(e,s,i,r){return this.ctx.clearRect(e,s,i,r),this}fillRect(e,s,i,r){return this.ctx.fillRect(npx(e)-.5,npx(s)-.5,npx(i),npx(r)),this}fillText(e,s,i){return this.ctx.fillText(e,npx(s),npx(i)),this}text(e,s,i={},r=!0){const{ctx:o}=this,{align:l,valign:a,font:c,color:d,strike:u,underline:f}=i,p=s.textx(l);o.save(),o.beginPath(),this.attr({textAlign:l,textBaseline:a,font:`${c.italic?"italic":""} ${c.bold?"bold":""} ${npx(c.size)}px ${c.name}`,fillStyle:d,strokeStyle:d});const m=`${e}`.split(`
9
+ `),g=s.innerWidth(),x=[];m.forEach(v=>{const w=o.measureText(v).width;if(r&&w>npx(g)){let C={w:0,len:0,start:0};for(let A=0;A<v.length;A+=1)C.w>=npx(g)&&(x.push(v.substr(C.start,C.len)),C={w:0,len:0,start:A}),C.len+=1,C.w+=o.measureText(v[A]).width+1;C.len>0&&x.push(v.substr(C.start,C.len))}else x.push(v)});const b=(x.length-1)*(c.size+2);let E=s.texty(a,b);return x.forEach(v=>{const w=o.measureText(v).width;this.fillText(v,p,E),u&&drawFontLine.call(this,"strike",p,E,l,a,c.size,w),f&&drawFontLine.call(this,"underline",p,E,l,a,c.size,w),E+=c.size+2}),o.restore(),this}border(e,s){const{ctx:i}=this;return i.lineWidth=thinLineWidth,i.strokeStyle=s,e==="medium"?i.lineWidth=npx(2)-.5:e==="thick"?i.lineWidth=npx(3):e==="dashed"?i.setLineDash([npx(3),npx(2)]):e==="dotted"?i.setLineDash([npx(1),npx(1)]):e==="double"&&i.setLineDash([npx(2),0]),this}line(...e){const{ctx:s}=this;if(e.length>1){s.beginPath();const[i,r]=e[0];s.moveTo(npxLine(i),npxLine(r));for(let o=1;o<e.length;o+=1){const[l,a]=e[o];s.lineTo(npxLine(l),npxLine(a))}s.stroke()}return this}strokeBorders(e){const{ctx:s}=this;s.save();const{borderTop:i,borderRight:r,borderBottom:o,borderLeft:l}=e;i&&(this.border(...i),this.line(...e.topxys())),r&&(this.border(...r),this.line(...e.rightxys())),o&&(this.border(...o),this.line(...e.bottomxys())),l&&(this.border(...l),this.line(...e.leftxys())),s.restore()}dropdown(e){const{ctx:s}=this,{x:i,y:r,width:o,height:l}=e,a=i+o-15,c=r+l-15;s.save(),s.beginPath(),s.moveTo(npx(a),npx(c)),s.lineTo(npx(a+8),npx(c)),s.lineTo(npx(a+4),npx(c+6)),s.closePath(),s.fillStyle="rgba(0, 0, 0, .45)",s.fill(),s.restore()}error(e){const{ctx:s}=this,{x:i,y:r,width:o}=e,l=i+o-1;s.save(),s.beginPath(),s.moveTo(npx(l-8),npx(r-1)),s.lineTo(npx(l),npx(r-1)),s.lineTo(npx(l),npx(r+8)),s.closePath(),s.fillStyle="rgba(255, 0, 0, .65)",s.fill(),s.restore()}frozen(e){const{ctx:s}=this,{x:i,y:r,width:o}=e,l=i+o-1;s.save(),s.beginPath(),s.moveTo(npx(l-8),npx(r-1)),s.lineTo(npx(l),npx(r-1)),s.lineTo(npx(l),npx(r+8)),s.closePath(),s.fillStyle="rgba(0, 255, 0, .85)",s.fill(),s.restore()}rect(e,s){const{ctx:i}=this,{x:r,y:o,width:l,height:a,bgcolor:c}=e;i.save(),i.beginPath(),i.fillStyle=c||"#fff",i.rect(npxLine(r+1),npxLine(o+1),npx(l-2),npx(a-2)),i.clip(),i.fill(),s(),i.restore()}}const baseFonts=[{key:"Arial",title:"Arial"},{key:"Helvetica",title:"Helvetica"},{key:"Source Sans Pro",title:"Source Sans Pro"},{key:"Comic Sans MS",title:"Comic Sans MS"},{key:"Courier New",title:"Courier New"},{key:"Verdana",title:"Verdana"},{key:"Lato",title:"Lato"}],fontSizes=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48},{pt:42,px:56}];function getFontSizePxByPt(n){for(let e=0;e<fontSizes.length;e+=1){const s=fontSizes[e];if(s.pt===n)return s.px}return n}const infixExprToSuffixExpr=n=>{const e=[],s=[];let i=[],r=0,o="",l=1,a="";for(let c=0;c<n.length;c+=1){const d=n.charAt(c);if(d!==" "){if(d>="a"&&d<="z")i.push(d.toUpperCase());else if(d>="0"&&d<="9"||d>="A"&&d<="Z"||d===".")i.push(d);else if(d==='"'){for(c+=1;n.charAt(c)!=='"';)i.push(n.charAt(c)),c+=1;s.push(`"${i.join("")}`),i=[]}else if(d==="-"&&/[+\-*/,(]/.test(a))i.push(d);else{if(d!=="("&&i.length>0&&s.push(i.join("")),d===")"){let u=e.pop();if(r===2)try{const[f,p]=expr2xy(s.pop()),[m,g]=expr2xy(s.pop());let x=0;for(let b=m;b<=f;b+=1)for(let E=g;E<=p;E+=1)s.push(xy2expr(b,E)),x+=1;s.push([u,x])}catch(f){}else if(r===1||r===3)r===3&&s.push(o),s.push([u,l]),l=1;else for(;u!=="("&&(s.push(u),!(e.length<=0));)u=e.pop();r=0}else if(d==="="||d===">"||d==="<"){const u=n.charAt(c+1);o=d,(u==="="||u==="-")&&(o+=u,c+=1),r=3}else if(d===":")r=2;else if(d===",")r===3&&s.push(o),r=1,l+=1;else if(d==="("&&i.length>0)e.push(i.join(""));else{if(e.length>0&&(d==="+"||d==="-")){let u=e[e.length-1];if(u!=="("&&s.push(e.pop()),u==="*"||u==="/")for(;e.length>0&&(u=e[e.length-1],u!=="(");)s.push(e.pop())}else if(e.length>0){const u=e[e.length-1];(u==="*"||u==="/")&&s.push(e.pop())}e.push(d)}i=[]}a=d}}for(i.length>0&&s.push(i.join(""));e.length>0;)s.push(e.pop());return s},evalSubExpr=(n,e)=>{const[s]=n;let i=n;if(s==='"')return n.substring(1);let r=1;if(s==="-"&&(i=n.substring(1),r=-1),i[0]>="0"&&i[0]<="9")return r*Number(i);const[o,l]=expr2xy(i);return r*e(o,l)},evalSuffixExpr=(n,e,s,i)=>{const r=[];for(let o=0;o<n.length;o+=1){const l=n[o],a=l[0];if(l==="+"){const c=r.pop();r.push(numberCalc("+",r.pop(),c))}else if(l==="-")if(r.length===1){const c=r.pop();r.push(numberCalc("*",c,-1))}else{const c=r.pop();r.push(numberCalc("-",r.pop(),c))}else if(l==="*")r.push(numberCalc("*",r.pop(),r.pop()));else if(l==="/"){const c=r.pop();r.push(numberCalc("/",r.pop(),c))}else if(a==="="||a===">"||a==="<"){let c=r.pop();Number.isNaN(c)||(c=Number(c));let d=r.pop();Number.isNaN(d)||(d=Number(d));let u=!1;a==="="?u=d===c:l===">"?u=d>c:l===">="?u=d>=c:l==="<"?u=d<c:l==="<="&&(u=d<=c),r.push(u)}else if(Array.isArray(l)){const[c,d]=l,u=[];for(let f=0;f<d;f+=1)u.push(r.pop());r.push(e[c].render(u.reverse()))}else{if(i.includes(l))return 0;(a>="a"&&a<="z"||a>="A"&&a<="Z")&&i.push(l),r.push(evalSubExpr(l,s)),i.pop()}}return r[0]},cell_rslib_entry_cellRender=(n,e,s,i=[])=>{if(n[0]==="="){const r=infixExprToSuffixExpr(n.substring(1));return r.length<=0?n:evalSuffixExpr(r,e,(o,l)=>cell_rslib_entry_cellRender(s(o,l),e,s,i),i)}return n},cell_rslib_entry_={render:cell_rslib_entry_cellRender},baseFormulas=[{key:"SUM",title:tf("formula.sum"),render:n=>n.reduce((e,s)=>numberCalc("+",e,s),0)},{key:"AVERAGE",title:tf("formula.average"),render:n=>n.reduce((e,s)=>Number(e)+Number(s),0)/n.length},{key:"MAX",title:tf("formula.max"),render:n=>Math.max(...n.map(e=>Number(e)))},{key:"MIN",title:tf("formula.min"),render:n=>Math.min(...n.map(e=>Number(e)))},{key:"IF",title:tf("formula._if"),render:([n,e,s])=>n?e:s},{key:"AND",title:tf("formula.and"),render:n=>n.every(e=>e)},{key:"OR",title:tf("formula.or"),render:n=>n.some(e=>e)},{key:"CONCAT",title:tf("formula.concat"),render:n=>n.join("")}],formulas=baseFormulas,formulam={};baseFormulas.forEach(n=>{formulam[n.key]=n});const formatStringRender=n=>n,formatNumberRender=n=>{if(/^(-?\d*.?\d*)$/.test(n)){const e=Number(n).toFixed(2).toString(),[s,...i]=e.split("\\.");return[s.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),...i]}return n},baseFormats=[{key:"normal",title:tf("format.normal"),type:"string",render:formatStringRender},{key:"text",title:tf("format.text"),type:"string",render:formatStringRender},{key:"number",title:tf("format.number"),type:"number",label:"1,000.12",render:formatNumberRender},{key:"percent",title:tf("format.percent"),type:"number",label:"10.12%",render:n=>`${n}%`},{key:"rmb",title:tf("format.rmb"),type:"number",label:"¥10.00",render:n=>`¥${formatNumberRender(n)}`},{key:"usd",title:tf("format.usd"),type:"number",label:"$10.00",render:n=>`$${formatNumberRender(n)}`},{key:"eur",title:tf("format.eur"),type:"number",label:"€10.00",render:n=>`€${formatNumberRender(n)}`},{key:"date",title:tf("format.date"),type:"date",label:"26/09/2008",render:formatStringRender},{key:"time",title:tf("format.time"),type:"date",label:"15:59:00",render:formatStringRender},{key:"datetime",title:tf("format.datetime"),type:"date",label:"26/09/2008 15:59:00",render:formatStringRender},{key:"duration",title:tf("format.duration"),type:"date",label:"24:01:00",render:formatStringRender}],formatm={};baseFormats.forEach(n=>{formatm[n.key]=n});const cellPaddingWidth=5,tableFixedHeaderCleanStyle={fillStyle:"#f4f5f8"},tableGridStyle={fillStyle:"#fff",lineWidth:thinLineWidth,strokeStyle:"#e6e6e6"};function tableFixedHeaderStyle(){return{textAlign:"center",textBaseline:"middle",font:`500 ${npx(12)}px Source Sans Pro`,fillStyle:"#585757",lineWidth:thinLineWidth(),strokeStyle:"#e6e6e6"}}function getDrawBox(n,e,s,i=0){const{left:r,top:o,width:l,height:a}=n.cellRect(e,s);return new DrawBox(r,o+i,l,a,cellPaddingWidth)}function renderCell(n,e,s,i,r=0){const{sortedRowMap:o,rows:l,cols:a}=e;if(l.isHide(s)||a.isHide(i))return;let c=s;o.has(s)&&(c=o.get(s));const d=e.getCell(c,i);if(d===null)return;let u=!1;"editable"in d&&d.editable===!1&&(u=!0);const f=e.getCellStyleOrDefault(c,i),p=getDrawBox(e,s,i,r);p.bgcolor=f.bgcolor,f.border!==void 0&&(p.setBorders(f.border),n.strokeBorders(p)),n.rect(p,()=>{let m="";m=e.settings.evalPaused?d.text||"":cell_rslib_entry_.render(d.text||"",formulam,(b,E)=>e.getCellTextOrDefault(E,b)),f.format&&(m=formatm[f.format].render(m));const g=Object.assign({},f.font);g.size=getFontSizePxByPt(g.size),n.text(m,p,{align:f.align,valign:f.valign,font:g,color:f.color,strike:f.strike,underline:f.underline},f.textwrap),e.validations.getError(s,i)&&n.error(p),u&&n.frozen(p)})}function renderAutofilter(n){const{data:e,draw:s}=this;if(n){const{autoFilter:i}=e;if(!i.active())return;const r=i.hrange();n.intersects(r)&&r.each((o,l)=>{const a=getDrawBox(e,o,l);s.dropdown(a)})}}function renderContent(n,e,s,i,r){const{draw:o,data:l}=this;o.save(),o.translate(e,s).translate(i,r);const{exceptRowSet:a}=l,c=f=>{const p=a.has(f);if(p){const m=l.rows.getHeight(f);o.translate(0,-m)}return!p},d=l.exceptRowTotalHeight(n.sri,n.eri);o.save(),o.translate(0,-d),n.each((f,p)=>{renderCell(o,l,f,p)},f=>c(f)),o.restore();const u=new Set;o.save(),o.translate(0,-d),l.eachMergesInView(n,({sri:f,sci:p,eri:m})=>{if(a.has(f)){if(!u.has(f)){u.add(f);const g=l.rows.sumHeight(f,m+1);o.translate(0,-g)}}else renderCell(o,l,f,p)}),o.restore(),renderAutofilter.call(this,n),o.restore()}function renderSelectedHeaderCell(n,e,s,i){const{draw:r}=this;r.save(),r.attr({fillStyle:"rgba(75, 137, 255, 0.08)"}).fillRect(n,e,s,i),r.restore()}function renderFixedHeaders(n,e,s,i,r,o){const{draw:l,data:a}=this,c=e.h,d=e.w,u=o+i,f=r+s;l.save(),l.attr(tableFixedHeaderCleanStyle),(n==="all"||n==="left")&&l.fillRect(0,u,s,c),(n==="all"||n==="top")&&l.fillRect(f,0,d,i);const{sri:p,sci:m,eri:g,eci:x}=a.selector.range;l.attr(tableFixedHeaderStyle()),(n==="all"||n==="left")&&(a.rowEach(e.sri,e.eri,(b,E,v)=>{const w=u+E,C=b;l.line([0,w],[s,w]),p<=C&&C<g+1&&renderSelectedHeaderCell.call(this,0,w,s,v),l.fillText(C+1,s/2,w+v/2),b>0&&a.rows.isHide(b-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([5,w+5],[s-5,w+5]),l.restore())}),l.line([0,c+u],[s,c+u]),l.line([s,u],[s,c+u])),(n==="all"||n==="top")&&(a.colEach(e.sci,e.eci,(b,E,v)=>{const w=f+E,C=b;l.line([w,0],[w,i]),m<=C&&C<x+1&&renderSelectedHeaderCell.call(this,w,0,v,i),l.fillText(stringAt(C),w+v/2,i/2),b>0&&a.cols.isHide(b-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([w+5,5],[w+5,i-5]),l.restore())}),l.line([d+f,0],[d+f,i]),l.line([0,i],[d+f,i])),l.restore()}function renderFixedLeftTopCell(n,e){const{draw:s}=this;s.save(),s.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,n,e),s.restore()}function renderContentGrid({sri:n,sci:e,eri:s,eci:i,w:r,h:o},l,a,c,d){const{draw:u,data:f}=this,{settings:p}=f;if(u.save(),u.attr(tableGridStyle).translate(l+c,a+d),!p.showGrid){u.restore();return}f.rowEach(n,s,(m,g,x)=>{m!==n&&u.line([0,g],[r,g]),m===s&&u.line([0,g+x],[r,g+x])}),f.colEach(e,i,(m,g,x)=>{m!==e&&u.line([g,0],[g,o]),m===i&&u.line([g+x,0],[g+x,o])}),u.restore()}function renderFreezeHighlightLine(n,e,s,i){const{draw:r,data:o}=this,l=o.viewWidth()-n,a=o.viewHeight()-e;r.save().translate(n,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),r.line([0,i],[l,i]),r.line([s,0],[s,a]),r.restore()}class Table{constructor(e,s){this.el=e,this.draw=new Draw(e,s.viewWidth(),s.viewHeight()),this.data=s}resetData(e){this.data=e,this.render()}render(){const{data:e}=this,{rows:s,cols:i}=e,r=i.indexWidth,o=s.height;this.draw.resize(e.viewWidth(),e.viewHeight()),this.clear();const l=e.viewRange(),a=e.freezeTotalWidth(),c=e.freezeTotalHeight(),{x:d,y:u}=e.scroll;renderContentGrid.call(this,l,r,o,a,c),renderContent.call(this,l,r,o,-d,-u),renderFixedHeaders.call(this,"all",l,r,o,a,c),renderFixedLeftTopCell.call(this,r,o);const[f,p]=e.freeze;if(f>0||p>0){if(f>0){const g=l.clone();g.sri=0,g.eri=f-1,g.h=c,renderContentGrid.call(this,g,r,o,a,0),renderContent.call(this,g,r,o,-d,0),renderFixedHeaders.call(this,"top",g,r,o,a,0)}if(p>0){const g=l.clone();g.sci=0,g.eci=p-1,g.w=a,renderContentGrid.call(this,g,r,o,0,c),renderFixedHeaders.call(this,"left",g,r,o,0,c),renderContent.call(this,g,r,o,0,-u)}const m=e.freezeViewRange();renderContentGrid.call(this,m,r,o,0,0),renderFixedHeaders.call(this,"all",m,r,o,0,0),renderContent.call(this,m,r,o,0,0),renderFreezeHighlightLine.call(this,r,o,a,c)}}clear(){this.draw.clear()}}const table_rslib_entry_=Table,PAGER_SIZES=[["A3",11.69,16.54],["A4",8.27,11.69],["A5",5.83,8.27],["B4",9.84,13.9],["B5",6.93,9.84]],PAGER_ORIENTATIONS=["landscape","portrait"];function inches2px(n){return parseInt(96*n,10)}function btnClick(n){n==="cancel"?this.el.hide():this.toPrint()}function pagerSizeChange(n){const{paper:e}=this,{value:s}=n.target,i=PAGER_SIZES[s];e.w=inches2px(i[1]),e.h=inches2px(i[2]),this.preview()}function pagerOrientationChange(n){const{paper:e}=this,{value:s}=n.target,i=PAGER_ORIENTATIONS[s];e.orientation=i,this.preview()}let Print$1=class{constructor(e){this.paper={w:inches2px(PAGER_SIZES[0][1]),h:inches2px(PAGER_SIZES[0][2]),padding:50,orientation:PAGER_ORIENTATIONS[0],get width(){return this.orientation==="landscape"?this.h:this.w},get height(){return this.orientation==="landscape"?this.w:this.h}},this.data=e,this.el=h("div",`${cssPrefix}-print`).children(h("div",`${cssPrefix}-print-bar`).children(h("div","-title").child("Print settings"),h("div","-right").children(h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",btnClick.bind(this,"cancel")),new Button("next","primary").on("click",btnClick.bind(this,"next"))))),h("div",`${cssPrefix}-print-content`).children(this.contentEl=h("div","-content"),h("div","-sider").child(h("form","").children(h("fieldset","").children(h("label","").child(`${t("print.size")}`),h("select","").children(...PAGER_SIZES.map((s,i)=>h("option","").attr("value",i).child(`${s[0]} ( ${s[1]}''x${s[2]}'' )`))).on("change",pagerSizeChange.bind(this))),h("fieldset","").children(h("label","").child(`${t("print.orientation")}`),h("select","").children(...PAGER_ORIENTATIONS.map((s,i)=>h("option","").attr("value",i).child(`${t("print.orientations")[i]}`))).on("change",pagerOrientationChange.bind(this))))))).hide()}resetData(e){this.data=e}preview(){const{data:e,paper:s}=this,{width:i,height:r,padding:o}=s,l=i-2*o,a=r-2*o,c=e.contentRange(),d=parseInt(c.h/a,10)+1,u=l/c.w;let f=o;const p=o;u>1&&(f+=(l-c.w)/2);let m=0,g=0;this.contentEl.html(""),this.canvases=[];const x={sri:0,sci:0,eri:0,eci:0};for(let b=0;b<d;b+=1){let E=0,v=0;const w=h("div",`${cssPrefix}-canvas-card`),C=h("canvas",`${cssPrefix}-canvas`);this.canvases.push(C.el);const A=new Draw(C.el,i,r);for(A.save(),A.translate(f,p),u<1&&A.scale(u,u);m<=c.eri;m+=1){const j=e.rows.getHeight(m);if(E+=j,E<a)for(let L=0;L<=c.eci;L+=1)renderCell(A,e,m,L,g),x.eci=L;else{v=-(E-j);break}}x.eri=m,A.restore(),A.save(),A.translate(f,p),u<1&&A.scale(u,u);const R=g;e.eachMergesInView(x,({sri:j,sci:L})=>{renderCell(A,e,j,L,R)}),A.restore(),x.sri=x.eri,x.sci=x.eci,g+=v,this.contentEl.child(h("div",`${cssPrefix}-canvas-card-wraper`).child(w.child(C)))}this.el.show()}toPrint(){this.el.hide();const{paper:e}=this,s=h("iframe","").hide(),{el:i}=s;window.document.body.appendChild(i);const{contentWindow:r}=i,o=r.document,l=document.createElement("style");l.innerHTML=`
10
10
  @page { size: ${e.width}px ${e.height}px; };
11
11
  canvas {
12
12
  page-break-before: auto;
13
13
  page-break-after: always;
14
14
  image-rendering: pixelated;
15
15
  };
16
- `,o.head.appendChild(l),this.canvases.forEach(a=>{const c=a.cloneNode(!1);c.getContext("2d").drawImage(a,0,0),o.body.appendChild(c)}),r.print()}};const menuItems$1=[{key:"copy",title:tf("contextmenu.copy"),label:"Ctrl+C"},{key:"cut",title:tf("contextmenu.cut"),label:"Ctrl+X"},{key:"paste",title:tf("contextmenu.paste"),label:"Ctrl+V"},{key:"paste-value",title:tf("contextmenu.pasteValue"),label:"Ctrl+Shift+V"},{key:"paste-format",title:tf("contextmenu.pasteFormat"),label:"Ctrl+Alt+V"},{key:"divider"},{key:"insert-row",title:tf("contextmenu.insertRow")},{key:"insert-column",title:tf("contextmenu.insertColumn")},{key:"divider"},{key:"delete-row",title:tf("contextmenu.deleteRow")},{key:"delete-column",title:tf("contextmenu.deleteColumn")},{key:"delete-cell-text",title:tf("contextmenu.deleteCellText")},{key:"hide",title:tf("contextmenu.hide")},{key:"divider"},{key:"validation",title:tf("contextmenu.validation")},{key:"divider"},{key:"cell-printable",title:tf("contextmenu.cellprintable")},{key:"cell-non-printable",title:tf("contextmenu.cellnonprintable")},{key:"divider"},{key:"cell-editable",title:tf("contextmenu.celleditable")},{key:"cell-non-editable",title:tf("contextmenu.cellnoneditable")}];function buildMenuItem$1(n){return n.key==="divider"?h("div",`${cssPrefix}-item divider`):h("div",`${cssPrefix}-item`).on("click",()=>{this.itemClick(n.key),this.hide()}).children(n.title(),h("div","label").child(n.label||""))}function buildMenu$2(){return menuItems$1.map(n=>buildMenuItem$1.call(this,n))}let ContextMenu$1=class{constructor(e,s=!1){this.menuItems=buildMenu$2.call(this),this.el=h("div",`${cssPrefix}-contextmenu`).children(...this.menuItems).hide(),this.viewFn=e,this.itemClick=()=>{},this.isHide=s,this.setMode("range")}setMode(e){const s=this.menuItems[12];e==="row-col"?s.show():s.hide()}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setPosition(e,s){if(this.isHide)return;const{el:i}=this,{width:r}=i.show().offset(),o=this.viewFn(),l=o.height/2;let a=e;o.width-e<=r&&(a-=r),i.css("left",`${a}px`),s>l?i.css("bottom",`${o.height-s}px`).css("max-height",`${s}px`).css("top","auto"):i.css("top",`${s}px`).css("max-height",`${o.height-s}px`).css("bottom","auto"),bindClickoutside(i)}};function tooltip(n,e){if(e.classList.contains("active"))return;const{left:s,top:i,width:r,height:o}=e.getBoundingClientRect(),l=h("div",`${cssPrefix}-tooltip`).html(n).show();document.body.appendChild(l.el);const a=l.box();l.css("left",`${s+r/2-a.width/2}px`).css("top",`${i+o+2}px`),bind(e,"mouseleave",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)}),bind(e,"click",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)})}class Item{constructor(e,s,i){this.tip="",e&&(this.tip=t(`toolbar.${e.replace(/-[a-z]/g,r=>r[1].toUpperCase())}`)),s&&(this.tip+=` (${s})`),this.tag=e,this.shortcut=s,this.value=i,this.el=this.element(),this.change=()=>{}}element(){const{tip:e}=this;return h("div",`${cssPrefix}-toolbar-btn`).on("mouseenter",s=>{this.tip&&tooltip(this.tip,s.target)}).attr("data-tooltip",e)}setState(){}}class DropdownItem extends Item{dropdown(){}getValue(e){return e}element(){const{tag:e}=this;return this.dd=this.dropdown(),this.dd.change=s=>this.change(e,this.getValue(s)),super.element().child(this.dd)}setState(e){e&&(this.value=e,this.dd.setTitle(e))}}class Dropdown extends Element{constructor(e,s,i,r,...o){super("div",`${cssPrefix}-dropdown ${r}`),this.title=e,this.change=()=>{},this.headerClick=()=>{},typeof e=="string"?this.title=h("div",`${cssPrefix}-dropdown-title`).child(e):i&&this.title.addClass("arrow-left"),this.contentEl=h("div",`${cssPrefix}-dropdown-content`).css("width",s).hide(),this.setContentChildren(...o),this.headerEl=h("div",`${cssPrefix}-dropdown-header`),this.headerEl.on("click",()=>{this.contentEl.css("display")!=="block"?this.show():this.hide()}).children(this.title,i?h("div",`${cssPrefix}-icon arrow-right`).child(h("div",`${cssPrefix}-icon-img arrow-down`)):""),this.children(this.headerEl,this.contentEl)}setContentChildren(...e){this.contentEl.html(""),e.length>0&&this.contentEl.children(...e)}setTitle(e){this.title.html(e),this.hide()}show(){const{contentEl:e}=this;e.show(),this.parent().active(),bindClickoutside(this.parent(),()=>{this.hide()})}hide(){this.parent().active(!1),this.contentEl.hide(),unbindClickoutside(this.parent())}}function buildItemWithIcon(n){return h("div",`${cssPrefix}-item`).child(new Icon(n))}class DropdownAlign extends Dropdown{constructor(e,s){const i=new Icon(`align-${s}`),r=e.map(o=>buildItemWithIcon(`align-${o}`).on("click",()=>{this.setTitle(o),this.change(o)}));super(i,"auto",!0,"bottom-left",...r)}setTitle(e){this.title.setName(`align-${e}`),this.hide()}}class Align extends DropdownItem{constructor(e){super("align","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["left","center","right"],e)}}class Valign extends DropdownItem{constructor(e){super("valign","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["top","middle","bottom"],e)}}class ToggleItem extends Item{element(){const{tag:e}=this;return super.element().child(new Icon(e)).on("click",()=>this.click())}click(){this.change(this.tag,this.toggle())}setState(e){this.el.active(e)}toggle(){return this.el.toggle()}active(){return this.el.hasClass("active")}}class Autofilter extends ToggleItem{constructor(){super("autofilter")}setState(){}}class Bold extends ToggleItem{constructor(){super("font-bold","Ctrl+B")}}class Italic extends ToggleItem{constructor(){super("font-italic","Ctrl+I")}}class Strike extends ToggleItem{constructor(){super("strike","Ctrl+U")}}class Underline extends ToggleItem{constructor(){super("underline","Ctrl+U")}}const themeColorPlaceHolders=["#ffffff","#000100","#e7e5e6","#445569","#5b9cd6","#ed7d31","#a5a5a5","#ffc001","#4371c6","#71ae47"],themeColors=[["#f2f2f2","#7f7f7f","#d0cecf","#d5dce4","#deeaf6","#fce5d5","#ededed","#fff2cd","#d9e2f3","#e3efd9"],["#d8d8d8","#595959","#afabac","#adb8ca","#bdd7ee","#f7ccac","#dbdbdb","#ffe59a","#b3c6e7","#c5e0b3"],["#bfbfbf","#3f3f3f","#756f6f","#8596b0","#9cc2e6","#f4b184","#c9c9c9","#fed964","#8eaada","#a7d08c"],["#a5a5a5","#262626","#3a3839","#333f4f","#2e75b5","#c45a10","#7b7b7b","#bf8e01","#2f5596","#538136"],["#7f7f7f","#0c0c0c","#171516","#222a35","#1f4e7a","#843c0a","#525252","#7e6000","#203864","#365624"]],standardColors=["#c00000","#fe0000","#fdc101","#ffff01","#93d051","#00b04e","#01b0f1","#0170c1","#012060","#7030a0"];function buildTd$1(n){return h("td","").child(h("div",`${cssPrefix}-color-palette-cell`).on("click.stop",()=>this.change(n)).css("background-color",n))}class ColorPalette{constructor(){this.el=h("div",`${cssPrefix}-color-palette`),this.change=()=>{};const e=h("table","").children(h("tbody","").children(h("tr",`${cssPrefix}-theme-color-placeholders`).children(...themeColorPlaceHolders.map(s=>buildTd$1.call(this,s))),...themeColors.map(s=>h("tr",`${cssPrefix}-theme-colors`).children(...s.map(i=>buildTd$1.call(this,i)))),h("tr",`${cssPrefix}-standard-colors`).children(...standardColors.map(s=>buildTd$1.call(this,s)))));this.el.child(e)}}class DropdownColor extends Dropdown{constructor(e,s){const i=new Icon(e).css("height","16px").css("border-bottom",`3px solid ${s}`),r=new ColorPalette;r.change=o=>{this.setTitle(o),this.change(o)},super(i,"auto",!1,"bottom-left",r.el)}setTitle(e){this.title.css("border-color",e),this.hide()}}const lineTypes=[["thin",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" style="user-select: none;"></line></svg>'],["medium",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="2" style="user-select: none;"><line x1="0" y1="1.0" x2="50" y2="1.0" stroke-width="2" stroke="black" style="user-select: none;"></line></svg>'],["thick",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="3" style="user-select: none;"><line x1="0" y1="1.5" x2="50" y2="1.5" stroke-width="3" stroke="black" style="user-select: none;"></line></svg>'],["dashed",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="2" style="user-select: none;"></line></svg>'],["dotted",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="1" style="user-select: none;"></line></svg>']];class DropdownLineType extends Dropdown{constructor(e){const s=new Icon("line-type");let i=0;const r=lineTypes.map((o,l)=>h("div",`${cssPrefix}-item state ${e===o[0]?"checked":""}`).on("click",()=>{r[i].toggle("checked"),r[l].toggle("checked"),i=l,this.hide(),this.change(o)}).child(h("div",`${cssPrefix}-line-type`).html(o[1])));super(s,"auto",!1,"bottom-left",...r)}}function buildTable(...n){return h("table","").child(h("tbody","").children(...n))}function buildTd(n){return h("td","").child(h("div",`${cssPrefix}-border-palette-cell`).child(new Icon(`border-${n}`)).on("click",()=>{this.mode=n;const{mode:e,style:s,color:i}=this;this.change({mode:e,style:s,color:i})}))}class BorderPalette{constructor(){this.color="#000",this.style="thin",this.mode="all",this.change=()=>{},this.ddColor=new DropdownColor("line-color",this.color),this.ddColor.change=s=>{this.color=s},this.ddType=new DropdownLineType(this.style),this.ddType.change=([s])=>{this.style=s},this.el=h("div",`${cssPrefix}-border-palette`);const e=buildTable(h("tr","").children(h("td",`${cssPrefix}-border-palette-left`).child(buildTable(h("tr","").children(...["all","inside","horizontal","vertical","outside"].map(s=>buildTd.call(this,s))),h("tr","").children(...["left","top","right","bottom","none"].map(s=>buildTd.call(this,s))))),h("td",`${cssPrefix}-border-palette-right`).children(h("div",`${cssPrefix}-toolbar-btn`).child(this.ddColor.el),h("div",`${cssPrefix}-toolbar-btn`).child(this.ddType.el))));this.el.child(e)}}class DropdownBorder extends Dropdown{constructor(){const e=new Icon("border-all"),s=new BorderPalette;s.change=i=>{this.change(i),this.hide()},super(e,"auto",!1,"bottom-left",s.el)}}class Border extends DropdownItem{constructor(){super("border")}dropdown(){return new DropdownBorder}}class IconItem extends Item{element(){return super.element().child(new Icon(this.tag)).on("click",()=>this.change(this.tag))}setState(e){this.el.disabled(e)}}class Clearformat extends IconItem{constructor(){super("clearformat")}}class Paintformat extends ToggleItem{constructor(){super("paintformat")}setState(){}}class TextColor extends DropdownItem{constructor(e){super("color",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class FillColor extends DropdownItem{constructor(e){super("bgcolor",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class DropdownFontSize extends Dropdown{constructor(){const e=fontSizes.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(`${s.pt}`),this.change(s)}).child(`${s.pt}`));super("10","60px",!0,"bottom-left",...e)}}let Format$2=class extends DropdownItem{constructor(){super("font-size")}getValue(e){return e.pt}dropdown(){return new DropdownFontSize}};class DropdownFont extends Dropdown{constructor(){const e=baseFonts.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(s.title),this.change(s)}).child(s.title));super(baseFonts[0].title,"160px",!0,"bottom-left",...e)}}class Font extends DropdownItem{constructor(){super("font-name")}getValue(e){return e.key}dropdown(){return new DropdownFont}}class DropdownFormat extends Dropdown{constructor(){let e=baseFormats.slice(0);e.splice(2,0,{key:"divider"}),e.splice(8,0,{key:"divider"}),e=e.map(s=>{const i=h("div",`${cssPrefix}-item`);return s.key==="divider"?i.addClass("divider"):(i.child(s.title()).on("click",()=>{this.setTitle(s.title()),this.change(s)}),s.label&&i.child(h("div","label").html(s.label))),i}),super("Normal","220px",!0,"bottom-left",...e)}setTitle(e){for(let s=0;s<baseFormats.length;s+=1)baseFormats[s].key===e&&this.title.html(baseFormats[s].title());this.hide()}}let Format$1=class extends DropdownItem{constructor(){super("format")}getValue(e){return e.key}dropdown(){return new DropdownFormat}};class DropdownFormula extends Dropdown{constructor(){const e=baseFormulas.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.hide(),this.change(s)}).child(s.key));super(new Icon("formula"),"180px",!0,"bottom-left",...e)}}class Format extends DropdownItem{constructor(){super("formula")}getValue(e){return e.key}dropdown(){return new DropdownFormula}}class Freeze extends ToggleItem{constructor(){super("freeze")}}class Merge extends ToggleItem{constructor(){super("merge")}setState(e,s){this.el.active(e).disabled(s)}}class Redo extends IconItem{constructor(){super("redo","Ctrl+Y")}}class Undo extends IconItem{constructor(){super("undo","Ctrl+Z")}}class Print extends IconItem{constructor(){super("print","Ctrl+P")}}class Textwrap extends ToggleItem{constructor(){super("textwrap")}}let DropdownMore$1=class extends Dropdown{constructor(){const e=new Icon("ellipsis"),s=h("div",`${cssPrefix}-toolbar-more`);super(e,"auto",!1,"bottom-right",s),this.moreBtns=s,this.contentEl.css("max-width","420px")}};class More extends DropdownItem{constructor(){super("more"),this.el.hide()}dropdown(){return new DropdownMore$1}show(){this.el.show()}hide(){this.el.hide()}}function buildDivider(){return h("div",`${cssPrefix}-toolbar-divider`)}function initBtns2(){this.btns2=[],this.items.forEach(n=>{if(Array.isArray(n))n.forEach(({el:e})=>{const s=e.box(),{marginLeft:i,marginRight:r}=e.computedStyle();this.btns2.push([e,s.width+parseInt(i,10)+parseInt(r,10)])});else{const e=n.box(),{marginLeft:s,marginRight:i}=n.computedStyle();this.btns2.push([n,e.width+parseInt(s,10)+parseInt(i,10)])}})}function moreResize(){const{el:n,btns:e,moreEl:s,btns2:i}=this,{moreBtns:r,contentEl:o}=s.dd;n.css("width",`${this.widthFn()}px`);const l=n.box();let a=160,c=12;const d=[],u=[];i.forEach(([f,m],p)=>{a+=m,p===i.length-1||a<l.width?d.push(f):(c+=m,u.push(f))}),e.html("").children(...d),r.html("").children(...u),o.css("width",`${c}px`),u.length>0?s.show():s.hide()}function genBtn(n){const e=new Item;e.el.on("click",()=>{n.onClick&&n.onClick(this.data.getData(),this.data)}),e.tip=n.tip||"";let{el:s}=n;if(n.icon&&(s=h("img").attr("src",n.icon)),s){const i=h("div",`${cssPrefix}-icon`);i.child(s),e.el.child(i)}return e}class Toolbar{constructor(e,s,i=!1){this.data=e,this.change=()=>{},this.widthFn=s,this.isHide=i;const r=e.defaultStyle();this.items=[[this.undoEl=new Undo,this.redoEl=new Redo,new Print,this.paintformatEl=new Paintformat,this.clearformatEl=new Clearformat],buildDivider(),[this.formatEl=new Format$1],buildDivider(),[this.fontEl=new Font,this.fontSizeEl=new Format$2],buildDivider(),[this.boldEl=new Bold,this.italicEl=new Italic,this.underlineEl=new Underline,this.strikeEl=new Strike,this.textColorEl=new TextColor(r.color)],buildDivider(),[this.fillColorEl=new FillColor(r.bgcolor),this.borderEl=new Border,this.mergeEl=new Merge],buildDivider(),[this.alignEl=new Align(r.align),this.valignEl=new Valign(r.valign),this.textwrapEl=new Textwrap],buildDivider(),[this.freezeEl=new Freeze,this.autofilterEl=new Autofilter,this.formulaEl=new Format]];const{extendToolbar:o={}}=e.settings;if(o.left&&o.left.length>0){this.items.unshift(buildDivider());const l=o.left.map(genBtn.bind(this));this.items.unshift(l)}if(o.right&&o.right.length>0){this.items.push(buildDivider());const l=o.right.map(genBtn.bind(this));this.items.push(l)}this.items.push([this.moreEl=new More]),this.el=h("div",`${cssPrefix}-toolbar`),this.btns=h("div",`${cssPrefix}-toolbar-btns`),this.items.forEach(l=>{Array.isArray(l)?l.forEach(a=>{this.btns.child(a.el),a.change=(...c)=>{this.change(...c)}}):this.btns.child(l.el)}),this.el.child(this.btns),i?this.el.hide():(this.reset(),setTimeout(()=>{initBtns2.call(this),moreResize.call(this)},0),bind(window,"resize",()=>{moreResize.call(this)}))}paintformatActive(){return this.paintformatEl.active()}paintformatToggle(){this.paintformatEl.toggle()}trigger(e){this[`${e}El`].click()}resetData(e){this.data=e,this.reset()}reset(){if(this.isHide)return;const{data:e}=this,s=e.getSelectedCellStyle();this.undoEl.setState(!e.canUndo()),this.redoEl.setState(!e.canRedo()),this.mergeEl.setState(e.canUnmerge(),!e.selector.multiple()),this.autofilterEl.setState(!e.canAutofilter());const{font:i,format:r}=s;this.formatEl.setState(r),this.fontEl.setState(i.name),this.fontSizeEl.setState(i.size),this.boldEl.setState(i.bold),this.italicEl.setState(i.italic),this.underlineEl.setState(s.underline),this.strikeEl.setState(s.strike),this.textColorEl.setState(s.color),this.fillColorEl.setState(s.bgcolor),this.alignEl.setState(s.align),this.valignEl.setState(s.valign),this.textwrapEl.setState(s.textwrap),this.freezeEl.setState(e.freezeIsActive())}}class Modal{constructor(e,s,i="600px"){this.title=e,this.el=h("div",`${cssPrefix}-modal`).css("width",i).children(h("div",`${cssPrefix}-modal-header`).children(new Icon("close").on("click.stop",()=>this.hide()),this.title),h("div",`${cssPrefix}-modal-content`).children(...s)).hide()}show(){this.dimmer=h("div",`${cssPrefix}-dimmer active`),document.body.appendChild(this.dimmer.el);const{width:e,height:s}=this.el.show().box(),{clientHeight:i,clientWidth:r}=document.documentElement;this.el.offset({left:(r-e)/2,top:(i-s)/3}),window.xkeydownEsc=o=>{o.keyCode===27&&this.hide()},bind(window,"keydown",window.xkeydownEsc)}hide(){this.el.hide(),document.body.removeChild(this.dimmer.el),unbind(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}class FormInput{constructor(e,s){this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-input`),this.input=h("input","").css("width",e).on("input",i=>this.vchange(i)).attr("placeholder",s),this.el.child(this.input)}focus(){setTimeout(()=>{this.input.el.focus()},10)}hint(e){this.input.attr("placeholder",e)}val(e){return this.input.val(e)}}class FormSelect{constructor(e,s,i,r=l=>l,o=()=>{}){this.key=e,this.getTitle=r,this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-select`),this.suggest=new Suggest(s.map(l=>({key:l,title:this.getTitle(l)})),l=>{this.itemClick(l.key),o(l.key),this.vchange(l.key)},i,this.el),this.el.children(this.itemEl=h("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",()=>this.show())}show(){this.suggest.search("")}itemClick(e){this.key=e,this.itemEl.html(this.getTitle(e))}val(e){return e!==void 0?(this.key=e,this.itemEl.html(this.getTitle(e)),this):this.key}}const patterns={number:/(^\d+$)|(^\d+(\.\d{0,4})?$)/,date:/^\d{4}-\d{1,2}-\d{1,2}$/};class FormField{constructor(e,s,i,r){this.label="",this.rule=s,i&&(this.label=h("label","label").css("width",`${r}px`).html(i)),this.tip=h("div","tip").child("tip").hide(),this.input=e,this.input.vchange=()=>this.validate(),this.el=h("div",`${cssPrefix}-form-field`).children(this.label,e.el,this.tip)}isShow(){return this.el.css("display")!=="none"}show(){this.el.show()}hide(){return this.el.hide(),this}val(e){return this.input.val(e)}hint(e){this.input.hint(e)}validate(){const{input:e,rule:s,tip:i,el:r}=this,o=e.val();return s.required&&/^\s*$/.test(o)?(i.html(t("validation.required")),r.addClass("error"),!1):(s.type||s.pattern)&&!(s.pattern||patterns[s.type]).test(o)?(i.html(t("validation.notMatch")),r.addClass("error"),!1):(r.removeClass("error"),!0)}}const fieldLabelWidth=100;class ModalValidation extends Modal{constructor(){const e=new FormField(new FormSelect("cell",["cell"],"100%",d=>t(`dataValidation.modeType.${d}`)),{required:!0},`${t("dataValidation.range")}:`,fieldLabelWidth),s=new FormField(new FormInput("120px","E3 or E3:F12"),{required:!0,pattern:/^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/}),i=new FormField(new FormSelect("list",["list","number","date","phone","email"],"100%",d=>t(`dataValidation.type.${d}`),d=>this.criteriaSelected(d)),{required:!0},`${t("dataValidation.criteria")}:`,fieldLabelWidth),r=new FormField(new FormSelect("be",["be","nbe","eq","neq","lt","lte","gt","gte"],"160px",d=>t(`dataValidation.operator.${d}`),d=>this.criteriaOperatorSelected(d)),{required:!0}).hide(),o=new FormField(new FormInput("70px","10"),{required:!0}).hide(),l=new FormField(new FormInput("70px","100"),{required:!0,type:"number"}).hide(),a=new FormField(new FormInput("120px","a,b,c"),{required:!0}),c=new FormField(new FormInput("70px","10"),{required:!0,type:"number"}).hide();super(t("contextmenu.validation"),[h("div",`${cssPrefix}-form-fields`).children(e.el,s.el),h("div",`${cssPrefix}-form-fields`).children(i.el,r.el,o.el,l.el,c.el,a.el),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("remove").on("click",()=>this.btnClick("remove")),new Button("save","primary").on("click",()=>this.btnClick("save")))]),this.mf=e,this.rf=s,this.cf=i,this.of=r,this.minvf=o,this.maxvf=l,this.vf=c,this.svf=a,this.change=()=>{}}showVf(e){const s=e==="date"?"2018-11-12":"10",{vf:i}=this;i.input.hint(s),i.show()}criteriaSelected(e){const{of:s,minvf:i,maxvf:r,vf:o,svf:l}=this;e==="date"||e==="number"?(s.show(),i.rule.type=e,r.rule.type=e,e==="date"?(i.hint("2018-11-12"),r.hint("2019-11-12")):(i.hint("10"),r.hint("100")),i.show(),r.show(),o.hide(),l.hide()):(e==="list"?l.show():l.hide(),o.hide(),s.hide(),i.hide(),r.hide())}criteriaOperatorSelected(e){if(!e)return;const{minvf:s,maxvf:i,vf:r}=this;if(e==="be"||e==="nbe")s.show(),i.show(),r.hide();else{const o=this.cf.val();r.rule.type=o,o==="date"?r.hint("2018-11-12"):r.hint("10"),r.show(),s.hide(),i.hide()}}btnClick(e){if(e==="cancel")this.hide();else if(e==="remove")this.change("remove"),this.hide();else if(e==="save"){const s=["mf","rf","cf","of","svf","vf","minvf","maxvf"];for(let c=0;c<s.length;c+=1){const d=this[s[c]];if(d.isShow()&&!d.validate())return}const i=this.mf.val(),r=this.rf.val(),o=this.cf.val(),l=this.of.val();let a=this.svf.val();(o==="number"||o==="date")&&(a=l==="be"||l==="nbe"?[this.minvf.val(),this.maxvf.val()]:this.vf.val()),this.change("save",i,r,{type:o,operator:l,required:!1,value:a}),this.hide()}}setValue(e){if(e){const{mf:s,rf:i,cf:r,of:o,svf:l,vf:a,minvf:c,maxvf:d}=this,{mode:u,ref:f,validator:m}=e,{type:p,operator:g,value:x}=m||{type:"list"};s.val(u||"cell"),i.val(f),r.val(p),o.val(g),Array.isArray(x)?(c.val(x[0]),d.val(x[1])):(l.val(x||""),a.val(x||"")),this.criteriaSelected(p),this.criteriaOperatorSelected(g)}this.show()}}function buildMenu$1(n){return h("div",`${cssPrefix}-item ${n}`)}function buildSortItem(n){return buildMenu$1("state").child(t(`sort.${n}`)).on("click.stop",()=>this.itemClick(n))}function buildFilterBody(n){const{filterbEl:e,filterValues:s}=this;e.html(""),Object.keys(n).forEach((r,o)=>{const l=n[r],a=s.includes(r)?"checked":"";e.child(h("div",`${cssPrefix}-item state ${a}`).on("click.stop",()=>this.filterClick(o,r)).children(r===""?t("filter.empty"):r,h("div","label").html(`(${l})`)))})}function resetFilterHeader(){const{filterhEl:n,filterValues:e,values:s}=this;n.html(`${e.length} / ${s.length}`),n.checked(e.length===s.length)}class SortFilter{constructor(){this.filterbEl=h("div",`${cssPrefix}-body`),this.filterhEl=h("div",`${cssPrefix}-header state`).on("click.stop",()=>this.filterClick(0,"all")),this.el=h("div",`${cssPrefix}-sort-filter`).children(this.sortAscEl=buildSortItem.call(this,"asc"),this.sortDescEl=buildSortItem.call(this,"desc"),buildMenu$1("divider"),h("div",`${cssPrefix}-filter`).children(this.filterhEl,this.filterbEl),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("ok","primary").on("click",()=>this.btnClick("ok")))).hide(),this.ci=null,this.sortDesc=null,this.values=null,this.filterValues=[]}btnClick(e){if(e==="ok"){const{ci:s,sort:i,filterValues:r}=this;this.ok&&this.ok(s,i,"in",r)}this.hide()}itemClick(e){this.sort=e;const{sortAscEl:s,sortDescEl:i}=this;s.checked(e==="asc"),i.checked(e==="desc")}filterClick(e,s){const{filterbEl:i,filterValues:r,values:o}=this,l=i.children();s==="all"?l.length===r.length?(this.filterValues=[],l.forEach(a=>h(a).checked(!1))):(this.filterValues=Array.from(o),l.forEach(a=>h(a).checked(!0))):h(l[e]).toggle("checked")?r.push(s):r.splice(r.findIndex(c=>c===s),1),resetFilterHeader.call(this)}set(e,s,i,r){this.ci=e;const{sortAscEl:o,sortDescEl:l}=this;r!==null?(this.sort=r.order,o.checked(r.asc()),l.checked(r.desc())):(this.sortDesc=null,o.checked(!1),l.checked(!1)),this.values=Object.keys(s),this.filterValues=i?Array.from(i.value):Object.keys(s),buildFilterBody.call(this,s,i),resetFilterHeader.call(this)}setOffset(e){this.el.offset(e).show();let s=1;bindClickoutside(this.el,()=>{s<=0&&this.hide(),s-=1})}show(){this.el.show()}hide(){this.el.hide(),unbindClickoutside(this.el)}}function xtoast(n,e){const s=h("div",`${cssPrefix}-toast`),i=h("div",`${cssPrefix}-dimmer active`),r=()=>{document.body.removeChild(s.el),document.body.removeChild(i.el)};s.children(h("div",`${cssPrefix}-toast-header`).children(new Icon("close").on("click.stop",()=>r()),n),h("div",`${cssPrefix}-toast-content`).html(e)),document.body.appendChild(s.el),document.body.appendChild(i.el);const{width:o,height:l}=s.box(),{clientHeight:a,clientWidth:c}=document.documentElement;s.offset({left:(c-o)/2,top:(a-l)/3})}function throttle$2(n,e){let s;return(...i)=>{const r=this,o=i;s||(s=setTimeout(()=>{s=null,n.apply(r,o)},e))}}function scrollbarMove(){const{data:n,verticalScrollbar:e,horizontalScrollbar:s}=this,{l:i,t:r,left:o,top:l,width:a,height:c}=n.getSelectedRect(),d=this.getTableOffset();if(Math.abs(o)+a>d.width)s.move({left:i+a-d.width});else{const u=n.freezeTotalWidth();o<u&&s.move({left:i-1-u})}if(Math.abs(l)+c>d.height)e.move({top:r+c-d.height-1});else{const u=n.freezeTotalHeight();l<u&&e.move({top:r-1-u})}}function selectorSet(n,e,s,i=!0,r=!1){if(e===-1&&s===-1)return;const{table:o,selector:l,toolbar:a,data:c,contextMenu:d}=this,u=c.getCell(e,s);n?(l.setEnd(e,s,r),this.trigger("cells-selected",u,l.range)):(l.set(e,s,i),this.trigger("cell-selected",u,e,s)),d.setMode(e===-1||s===-1?"row-col":"range"),a.reset(),o.render()}function selectorMove(n,e){const{selector:s,data:i}=this,{rows:r,cols:o}=i;let[l,a]=s.indexes;const{eri:c,eci:d}=s.range;n&&([l,a]=s.moveIndexes),e==="left"?a>0&&(a-=1):e==="right"?(d!==a&&(a=d),a<o.len-1&&(a+=1)):e==="up"?l>0&&(l-=1):e==="down"?(c!==l&&(l=c),l<r.len-1&&(l+=1)):e==="row-first"?a=0:e==="row-last"?a=o.len-1:e==="col-first"?l=0:e==="col-last"&&(l=r.len-1),n&&(s.moveIndexes=[l,a]),selectorSet.call(this,n,l,a),scrollbarMove.call(this)}function overlayerMousemove(n){if(n.buttons!==0||n.target.className===`${cssPrefix}-resizer-hover`)return;const{offsetX:e,offsetY:s}=n,{rowResizer:i,colResizer:r,tableEl:o,data:l}=this,{rows:a,cols:c}=l;if(e>c.indexWidth&&s>a.height){i.hide(),r.hide();return}const d=o.box(),u=l.getCellRectByXY(n.offsetX,n.offsetY);u.ri>=0&&u.ci===-1?(u.width=c.indexWidth,i.show(u,{width:d.width}),a.isHide(u.ri-1)?i.showUnhide(u.ri):i.hideUnhide()):i.hide(),u.ri===-1&&u.ci>=0?(u.height=a.height,r.show(u,{height:d.height}),c.isHide(u.ci-1)?r.showUnhide(u.ci):r.hideUnhide()):r.hide()}function overlayerMousescroll(n){const{verticalScrollbar:e,horizontalScrollbar:s,data:i}=this,{top:r}=e.scroll(),{left:o}=s.scroll(),{rows:l,cols:a}=i,{deltaY:c,deltaX:d}=n,u=(b,w)=>{let v=b,E=0;do E=w(v),v+=1;while(E<=0);return E},f=b=>{if(b>0){const w=i.scroll.ri+1;if(w<l.len){const v=u(w,E=>l.getHeight(E));e.move({top:r+v-1})}}else{const w=i.scroll.ri-1;if(w>=0){const v=u(w,E=>l.getHeight(E));e.move({top:w===0?0:r-v})}}},m=b=>{if(b>0){const w=i.scroll.ci+1;if(w<a.len){const v=u(w,E=>a.getWidth(E));s.move({left:o+v-1})}}else{const w=i.scroll.ci-1;if(w>=0){const v=u(w,E=>a.getWidth(E));s.move({left:w===0?0:o-v})}}},p=Math.abs(c),g=Math.abs(d),x=Math.max(p,g);/Firefox/i.test(window.navigator.userAgent)&&throttle$2(f(n.detail),50),x===g&&throttle$2(m(d),50),x===p&&throttle$2(f(c),50)}function overlayerTouch(n,e){const{verticalScrollbar:s,horizontalScrollbar:i}=this,{top:r}=s.scroll(),{left:o}=i.scroll();n==="left"||n==="right"?i.move({left:o-e}):(n==="up"||n==="down")&&s.move({top:r-e})}function verticalScrollbarSet(){const{data:n,verticalScrollbar:e}=this,{height:s}=this.getTableOffset(),i=n.exceptRowTotalHeight(0,-1);e.set(s,n.rows.totalHeight()-i)}function horizontalScrollbarSet(){const{data:n,horizontalScrollbar:e}=this,{width:s}=this.getTableOffset();n&&e.set(s,n.cols.totalWidth())}function sheetFreeze(){const{selector:n,data:e,editor:s}=this,[i,r]=e.freeze;if(i>0||r>0){const o=e.freezeTotalWidth(),l=e.freezeTotalHeight();s.setFreezeLengths(o,l)}n.resetAreaOffset()}function sheetReset(){const{tableEl:n,overlayerEl:e,overlayerCEl:s,table:i,toolbar:r,selector:o,el:l}=this,a=this.getTableOffset(),c=this.getRect();n.attr(c),e.offset(c),s.offset(a),l.css("width",`${c.width}px`),verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),sheetFreeze.call(this),i.render(),r.reset(),o.reset()}function clearClipboard(){const{data:n,selector:e}=this;n.clearClipboard(),e.hideClipboard()}function copy$2(n){const{data:e,selector:s}=this;e.settings.mode!=="read"&&(e.copy(),e.copyToSystemClipboard(n),s.showClipboard())}function cut(){const{data:n,selector:e}=this;n.settings.mode!=="read"&&(n.cut(),e.showClipboard())}function paste(n,e){const{data:s}=this;if(s.settings.mode!=="read"){if(s.clipboard.isClear()){const i=()=>sheetReset.call(this),r=o=>{this.trigger("pasted-clipboard",o)};s.pasteFromSystemClipboard(i,r)}else if(s.paste(n,i=>xtoast("Tip",i)))sheetReset.call(this);else if(e){const i=e.clipboardData.getData("text/plain");this.data.pasteFromText(i),sheetReset.call(this)}}}function hideRowsOrCols(){this.data.hideRowsOrCols(),sheetReset.call(this)}function unhideRowsOrCols(n,e){this.data.unhideRowsOrCols(n,e),sheetReset.call(this)}function autofilter(){const{data:n}=this;n.autofilter(),sheetReset.call(this)}function toolbarChangePaintformatPaste(){const{toolbar:n}=this;n.paintformatActive()&&(paste.call(this,"format"),clearClipboard.call(this),n.paintformatToggle())}function overlayerMousedown(n){const{selector:e,data:s,table:i,sortFilter:r}=this,{offsetX:o,offsetY:l}=n,a=n.target.className===`${cssPrefix}-selector-corner`,c=s.getCellRectByXY(o,l),{left:d,top:u,width:f,height:m}=c;let{ri:p,ci:g}=c;const{autoFilter:x}=s;if(x.includes(p,g)&&d+f-20<o&&u+m-20<l){const b=x.items(g,(w,v)=>s.rows.getCell(w,v));r.hide(),r.set(g,b,x.getFilter(g),x.getSort(g)),r.setOffset({left:d,top:u+m+2});return}n.shiftKey||(a?e.showAutofill(p,g):selectorSet.call(this,!1,p,g),mouseMoveUp(window,b=>{({ri:p,ci:g}=s.getCellRectByXY(b.offsetX,b.offsetY)),a?e.showAutofill(p,g):b.buttons===1&&!b.shiftKey&&selectorSet.call(this,!0,p,g,!0,!0)},()=>{a&&e.arange&&s.settings.mode!=="read"&&s.autofill(e.arange,"all",b=>xtoast("Tip",b))&&i.render(),e.hideAutofill(),toolbarChangePaintformatPaste.call(this)})),!a&&n.buttons===1&&n.shiftKey&&selectorSet.call(this,!0,p,g)}function editorSetOffset(){const{editor:n,data:e}=this,s=e.getSelectedRect(),i=this.getTableOffset();let r="top";s.top>i.height/2&&(r="bottom"),n.setOffset(s,r)}function editorSet(){const{editor:n,data:e}=this;e.settings.mode!=="read"&&(editorSetOffset.call(this),n.setCell(e.getSelectedCell(),e.getSelectedValidator()),clearClipboard.call(this))}function verticalScrollbarMove(n){const{data:e,table:s,selector:i}=this;e.scrolly(n,()=>{i.resetBRLAreaOffset(),editorSetOffset.call(this),s.render()})}function horizontalScrollbarMove(n){const{data:e,table:s,selector:i}=this;e.scrollx(n,()=>{i.resetBRTAreaOffset(),editorSetOffset.call(this),s.render()})}function rowResizerFinished(n,e){const{ri:s}=n,{table:i,selector:r,data:o}=this,{sri:l,eri:a}=r.range;if(s>=l&&s<=a)for(let c=l;c<=a;c+=1)o.rows.setHeight(c,e);else o.rows.setHeight(s,e);i.render(),r.resetAreaOffset(),verticalScrollbarSet.call(this),editorSetOffset.call(this)}function colResizerFinished(n,e){const{ci:s}=n,{table:i,selector:r,data:o}=this,{sci:l,eci:a}=r.range;if(s>=l&&s<=a)for(let c=l;c<=a;c+=1)o.cols.setWidth(c,e);else o.cols.setWidth(s,e);i.render(),r.resetAreaOffset(),horizontalScrollbarSet.call(this),editorSetOffset.call(this)}function dataSetCellText(n,e="finished"){const{data:s,table:i}=this;if(s.settings.mode==="read")return;s.setSelectedCellText(n,e);const{ri:r,ci:o}=s.selector;e==="finished"?i.render():this.trigger("cell-edited",n,r,o)}function insertDeleteRowColumn(n){const{data:e}=this;e.settings.mode!=="read"&&(n==="insert-row"?e.insert("row"):n==="delete-row"?e.delete("row"):n==="insert-column"?e.insert("column"):n==="delete-column"?e.delete("column"):n==="delete-cell"?e.deleteCell():n==="delete-cell-format"?e.deleteCell("format"):n==="delete-cell-text"?e.deleteCell("text"):n==="cell-printable"?e.setSelectedCellAttr("printable",!0):n==="cell-non-printable"?e.setSelectedCellAttr("printable",!1):n==="cell-editable"?e.setSelectedCellAttr("editable",!0):n==="cell-non-editable"&&e.setSelectedCellAttr("editable",!1),clearClipboard.call(this),sheetReset.call(this))}function toolbarChange(n,e){const{data:s}=this;if(n==="undo")this.undo();else if(n==="redo")this.redo();else if(n==="print")this.print.preview();else if(n==="paintformat")e===!0?copy$2.call(this):clearClipboard.call(this);else if(n==="clearformat")insertDeleteRowColumn.call(this,"delete-cell-format");else if(n!=="link"){if(n!=="chart")if(n==="autofilter")autofilter.call(this);else if(n==="freeze")if(e){const{ri:i,ci:r}=s.selector;this.freeze(i,r)}else this.freeze(0,0);else s.setSelectedCellAttr(n,e),n==="formula"&&!s.selector.multiple()&&editorSet.call(this),sheetReset.call(this)}}function sortFilterChange(n,e,s,i){this.data.setAutoFilter(n,e,s,i),sheetReset.call(this)}function sheetInitEvents(){const{selector:n,overlayerEl:e,rowResizer:s,colResizer:i,verticalScrollbar:r,horizontalScrollbar:o,editor:l,contextMenu:a,toolbar:c,modalValidation:d,sortFilter:u}=this;e.on("mousemove",f=>{overlayerMousemove.call(this,f)}).on("mousedown",f=>{l.clear(),a.hide(),f.buttons===2?(this.data.xyInSelectedRect(f.offsetX,f.offsetY)||overlayerMousedown.call(this,f),a.setPosition(f.offsetX,f.offsetY),f.stopPropagation()):f.detail===2?editorSet.call(this):overlayerMousedown.call(this,f)}).on("mousewheel.stop",f=>{overlayerMousescroll.call(this,f)}).on("mouseout",f=>{const{offsetX:m,offsetY:p}=f;p<=0&&i.hide(),m<=0&&s.hide()}),n.inputChange=f=>{dataSetCellText.call(this,f,"input"),editorSet.call(this)},bindTouch(e.el,{move:(f,m)=>{overlayerTouch.call(this,f,m)}}),c.change=(f,m)=>toolbarChange.call(this,f,m),u.ok=(f,m,p,g)=>sortFilterChange.call(this,f,m,p,g),s.finishedFn=(f,m)=>{rowResizerFinished.call(this,f,m)},i.finishedFn=(f,m)=>{colResizerFinished.call(this,f,m)},s.unhideFn=f=>{unhideRowsOrCols.call(this,"row",f)},i.unhideFn=f=>{unhideRowsOrCols.call(this,"col",f)},r.moveFn=(f,m)=>{verticalScrollbarMove.call(this,f,m)},o.moveFn=(f,m)=>{horizontalScrollbarMove.call(this,f,m)},l.change=(f,m)=>{dataSetCellText.call(this,m,f)},d.change=(f,...m)=>{f==="save"?this.data.addValidation(...m):this.data.removeValidation()},a.itemClick=f=>{f==="validation"?d.setValue(this.data.getSelectedValidation()):f==="copy"?copy$2.call(this):f==="cut"?cut.call(this):f==="paste"?paste.call(this,"all"):f==="paste-value"?paste.call(this,"text"):f==="paste-format"?paste.call(this,"format"):f==="hide"?hideRowsOrCols.call(this):insertDeleteRowColumn.call(this,f)},bind(window,"resize",()=>{this.reload()}),bind(window,"click",f=>{this.focusing=e.contains(f.target)}),bind(window,"paste",f=>{this.focusing&&(paste.call(this,"all",f),f.preventDefault())}),bind(window,"copy",f=>{this.focusing&&(copy$2.call(this,f),f.preventDefault())}),bind(window,"keydown",f=>{if(!this.focusing)return;const m=f.keyCode||f.which,{key:p,ctrlKey:g,shiftKey:x,metaKey:b}=f;if(g||b)switch(m){case 90:this.undo(),f.preventDefault();break;case 89:this.redo(),f.preventDefault();break;case 67:break;case 88:cut.call(this),f.preventDefault();break;case 85:c.trigger("underline"),f.preventDefault();break;case 86:break;case 37:selectorMove.call(this,x,"row-first"),f.preventDefault();break;case 38:selectorMove.call(this,x,"col-first"),f.preventDefault();break;case 39:selectorMove.call(this,x,"row-last"),f.preventDefault();break;case 40:selectorMove.call(this,x,"col-last"),f.preventDefault();break;case 32:selectorSet.call(this,!1,-1,this.data.selector.ci,!1),f.preventDefault();break;case 66:c.trigger("bold");break;case 73:c.trigger("italic");break}else{switch(m){case 32:x&&selectorSet.call(this,!1,this.data.selector.ri,-1,!1);break;case 27:a.hide(),clearClipboard.call(this);break;case 37:selectorMove.call(this,x,"left"),f.preventDefault();break;case 38:selectorMove.call(this,x,"up"),f.preventDefault();break;case 39:selectorMove.call(this,x,"right"),f.preventDefault();break;case 40:selectorMove.call(this,x,"down"),f.preventDefault();break;case 9:l.clear(),selectorMove.call(this,!1,x?"left":"right"),f.preventDefault();break;case 13:l.clear(),selectorMove.call(this,!1,x?"up":"down"),f.preventDefault();break;case 8:insertDeleteRowColumn.call(this,"delete-cell-text"),f.preventDefault();break}p==="Delete"?(insertDeleteRowColumn.call(this,"delete-cell-text"),f.preventDefault()):m>=65&&m<=90||m>=48&&m<=57||m>=96&&m<=105||f.key==="="?(dataSetCellText.call(this,f.key,"input"),editorSet.call(this)):m===113&&editorSet.call(this)}})}class Sheet{constructor(e,s){this.eventMap=createEventEmitter();const{view:i,showToolbar:r,showContextmenu:o}=s.settings;this.el=h("div",`${cssPrefix}-sheet`),this.toolbar=new Toolbar(s,i.width,!r),this.print=new Print$1(s),e.children(this.toolbar.el,this.el,this.print.el),this.data=s,this.tableEl=h("canvas",`${cssPrefix}-table`),this.rowResizer=new Resizer(!1,s.rows.height),this.colResizer=new Resizer(!0,s.cols.minWidth),this.verticalScrollbar=new Scrollbar(!0),this.horizontalScrollbar=new Scrollbar(!1),this.editor=new Editor(formulas,()=>this.getTableOffset(),s.rows.height),this.modalValidation=new ModalValidation,this.contextMenu=new ContextMenu$1(()=>this.getRect(),!o),this.selector=new Selector(s),this.overlayerCEl=h("div",`${cssPrefix}-overlayer-content`).children(this.editor.el,this.selector.el),this.overlayerEl=h("div",`${cssPrefix}-overlayer`).child(this.overlayerCEl),this.sortFilter=new SortFilter,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new table_rslib_entry_(this.tableEl.el,s),sheetInitEvents.call(this),sheetReset.call(this),selectorSet.call(this,!1,0,0)}on(e,s){return this.eventMap.on(e,s),this}trigger(e,...s){const{eventMap:i}=this;i.fire(e,s)}resetData(e){this.editor.clear(),this.data=e,verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),this.toolbar.resetData(e),this.print.resetData(e),this.selector.resetData(e),this.table.resetData(e)}loadData(e){return this.data.setData(e),sheetReset.call(this),this}freeze(e,s){const{data:i}=this;return i.setFreeze(e,s),sheetReset.call(this),this}undo(){this.data.undo(),sheetReset.call(this)}redo(){this.data.redo(),sheetReset.call(this)}reload(){return sheetReset.call(this),this}getRect(){const{data:e}=this;return{width:e.viewWidth(),height:e.viewHeight()}}getTableOffset(){const{rows:e,cols:s}=this.data,{width:i,height:r}=this.getRect();return{width:i-s.indexWidth,height:r-e.height,left:s.indexWidth,top:e.height}}}class DropdownMore extends Dropdown{constructor(e){const s=new Icon("ellipsis");super(s,"auto",!1,"top-left"),this.contentClick=e}reset(e){const s=e.map((i,r)=>h("div",`${cssPrefix}-item`).css("width","150px").css("font-weight","normal").on("click",()=>{this.contentClick(r),this.hide()}).child(i));this.setContentChildren(...s)}setTitle(){}}const menuItems=[{key:"delete",title:tf("contextmenu.deleteSheet")}];function buildMenuItem(n){return h("div",`${cssPrefix}-item`).child(n.title()).on("click",()=>{this.itemClick(n.key),this.hide()})}function buildMenu(){return menuItems.map(n=>buildMenuItem.call(this,n))}class ContextMenu{constructor(){this.el=h("div",`${cssPrefix}-contextmenu`).css("width","160px").children(...buildMenu.call(this)).hide(),this.itemClick=()=>{}}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setOffset(e){const{el:s}=this;s.offset(e),s.show(),bindClickoutside(s)}}class Bottombar{constructor(e=()=>{},s=()=>{},i=()=>{},r=()=>{}){this.swapFunc=s,this.updateFunc=r,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new DropdownMore(o=>{this.clickSwap2(this.items[o])}),this.contextMenu=new ContextMenu,this.contextMenu.itemClick=i,this.el=h("div",`${cssPrefix}-bottombar`).children(this.contextMenu.el,this.menuEl=h("ul",`${cssPrefix}-menu`).child(h("li","").children(new Icon("add").on("click",()=>{e()}),h("span","").child(this.moreEl))))}addItem(e,s,i){this.dataNames.push(e);const r=h("li",s?"active":"").child(e);r.on("click",()=>{this.clickSwap2(r)}).on("contextmenu",o=>{if(i.mode==="read")return;const{offsetLeft:l,offsetHeight:a}=o.target;this.contextMenu.setOffset({left:l,bottom:a+1}),this.deleteEl=r}).on("dblclick",()=>{if(i.mode==="read")return;const o=r.html(),l=new FormInput("auto","");l.val(o),l.input.on("blur",({target:a})=>{const{value:c}=a,d=this.dataNames.findIndex(u=>u===o);this.renameItem(d,c)}),r.html("").child(l.el),l.focus()}),s&&this.clickSwap(r),this.items.push(r),this.menuEl.child(r),this.moreEl.reset(this.dataNames)}renameItem(e,s){this.dataNames.splice(e,1,s),this.moreEl.reset(this.dataNames),this.items[e].html("").child(s),this.updateFunc(e,s)}clear(){this.items.forEach(e=>{this.menuEl.removeChild(e.el)}),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}deleteItem(){const{activeEl:e,deleteEl:s}=this;if(this.items.length>1){const i=this.items.findIndex(r=>r===s);if(this.items.splice(i,1),this.dataNames.splice(i,1),this.menuEl.removeChild(s.el),this.moreEl.reset(this.dataNames),e===s){const[r]=this.items;return this.activeEl=r,this.activeEl.toggle(),[i,0]}return[i,-1]}return[-1]}clickSwap2(e){const s=this.items.findIndex(i=>i===e);this.clickSwap(e),this.activeEl.toggle(),this.swapFunc(s)}clickSwap(e){this.activeEl!==null&&this.activeEl.toggle(),this.activeEl=e}}const B=class B{constructor(e,s={}){U(this,y);U(this,P,1);U(this,A);U(this,M);U(this,I);U(this,L);N(this,y,S({showBottomBar:!0},s)),N(this,A,[]),N(this,L,D(this,y).showBottomBar?new Bottombar(()=>{if(D(this,y).mode==="read")return;const r=this.addSheet();D(this,I).resetData(r)},r=>{const o=D(this,A)[r];D(this,I).resetData(o)},()=>{this.deleteSheet()},(r,o)=>{D(this,A)[r].name=o,D(this,I).trigger("change")}):null),N(this,M,this.addSheet());const i=h("div",`${cssPrefix}`).on("contextmenu",r=>r.preventDefault());e.appendChild(i.el),N(this,I,new Sheet(i,D(this,M))),D(this,L)!==null&&i.child(D(this,L).el)}static makeSheet(e,s={}){if(B.targets.has(e)){const r=B.targets.get(e);if(r)return r}const i=new B(e,s);B.targets.set(e,i)}on(e,s){return D(this,I).on(e,s),this}reRender(){return D(this,I).table.render(),this}cell(e,s,i=0){return D(this,A)[i].getCell(e,s)}cellStyle(e,s,i=0){return D(this,A)[i].getCellStyle(e,s)}cellText(e,s,i,r=0){return D(this,A)[r].setCellText(e,s,i,"finished"),this}deleteSheet(){if(D(this,L)===null)return;const[e,s]=D(this,L).deleteItem();e>=0&&(D(this,A).splice(e,1),s>=0&&D(this,I).resetData(D(this,A)[s]),D(this,I).trigger("change"))}loadData(e){const s=Array.isArray(e)?e:[e];if(D(this,L)!==null&&D(this,L).clear(),N(this,A,[]),s.length>0)for(let i=0;i<s.length;i+=1){const r=s[i],o=this.addSheet(r.name,i===0);o.setData(r),i===0&&D(this,I).resetData(o)}return this}getData(){return D(this,A).map(e=>e.getData())}validate(){const{validations:e}=D(this,M);return e.errors.size<=0}change(e){return D(this,I).on("change",e),this}static locale(e,s){locale(e,s)}addSheet(e,s=!0){const i=e||`sheet${D(this,P)}`,r=new DataProxy(i,D(this,y));return r.change=(...o)=>{D(this,I).trigger("change",...o)},D(this,A).push(r),D(this,L)!==null&&D(this,L).addItem(i,s,D(this,y)),N(this,P,D(this,P)+1),r}};y=new WeakMap,P=new WeakMap,A=new WeakMap,M=new WeakMap,I=new WeakMap,L=new WeakMap,Q(B,"targets",new WeakMap);let Spreadsheet=B;var __webpack_exports__Spreadsheet=Spreadsheet;const ExcelSheet=React.forwardRef(({data:n,className:e},s)=>{const i=React.useRef(null),r=React.useRef(null),o=()=>{if(!i.current)throw new Error("Workbook is not initialized");return i.current.getData()};return React.useImperativeHandle(s,()=>({getData:o})),React.useEffect(()=>{if(r.current){const l=__webpack_exports__Spreadsheet.makeSheet(r.current,{view:{height:()=>{var a;return(a=r.current)==null?void 0:a.offsetHeight},width:()=>{var a;return(a=r.current)==null?void 0:a.offsetWidth}}});l.loadData(n),i.current=l}},[n]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{ref:r,id:"sheet988",className:client.cx(client.css`
16
+ `,o.head.appendChild(l),this.canvases.forEach(a=>{const c=a.cloneNode(!1);c.getContext("2d").drawImage(a,0,0),o.body.appendChild(c)}),r.print()}};const menuItems$1=[{key:"copy",title:tf("contextmenu.copy"),label:"Ctrl+C"},{key:"cut",title:tf("contextmenu.cut"),label:"Ctrl+X"},{key:"paste",title:tf("contextmenu.paste"),label:"Ctrl+V"},{key:"paste-value",title:tf("contextmenu.pasteValue"),label:"Ctrl+Shift+V"},{key:"paste-format",title:tf("contextmenu.pasteFormat"),label:"Ctrl+Alt+V"},{key:"divider"},{key:"insert-row",title:tf("contextmenu.insertRow")},{key:"insert-column",title:tf("contextmenu.insertColumn")},{key:"divider"},{key:"delete-row",title:tf("contextmenu.deleteRow")},{key:"delete-column",title:tf("contextmenu.deleteColumn")},{key:"delete-cell-text",title:tf("contextmenu.deleteCellText")},{key:"hide",title:tf("contextmenu.hide")},{key:"divider"},{key:"validation",title:tf("contextmenu.validation")},{key:"divider"},{key:"cell-printable",title:tf("contextmenu.cellprintable")},{key:"cell-non-printable",title:tf("contextmenu.cellnonprintable")},{key:"divider"},{key:"cell-editable",title:tf("contextmenu.celleditable")},{key:"cell-non-editable",title:tf("contextmenu.cellnoneditable")}];function buildMenuItem$1(n){return n.key==="divider"?h("div",`${cssPrefix}-item divider`):h("div",`${cssPrefix}-item`).on("click",()=>{this.itemClick(n.key),this.hide()}).children(n.title(),h("div","label").child(n.label||""))}function buildMenu$2(){return menuItems$1.map(n=>buildMenuItem$1.call(this,n))}let ContextMenu$1=class{constructor(e,s=!1){this.menuItems=buildMenu$2.call(this),this.el=h("div",`${cssPrefix}-contextmenu`).children(...this.menuItems).hide(),this.viewFn=e,this.itemClick=()=>{},this.isHide=s,this.setMode("range")}setMode(e){const s=this.menuItems[12];e==="row-col"?s.show():s.hide()}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setPosition(e,s){if(this.isHide)return;const{el:i}=this,{width:r}=i.show().offset(),o=this.viewFn(),l=o.height/2;let a=e;o.width-e<=r&&(a-=r),i.css("left",`${a}px`),s>l?i.css("bottom",`${o.height-s}px`).css("max-height",`${s}px`).css("top","auto"):i.css("top",`${s}px`).css("max-height",`${o.height-s}px`).css("bottom","auto"),bindClickoutside(i)}};function tooltip(n,e){if(e.classList.contains("active"))return;const{left:s,top:i,width:r,height:o}=e.getBoundingClientRect(),l=h("div",`${cssPrefix}-tooltip`).html(n).show();document.body.appendChild(l.el);const a=l.box();l.css("left",`${s+r/2-a.width/2}px`).css("top",`${i+o+2}px`),bind(e,"mouseleave",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)}),bind(e,"click",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)})}class Item{constructor(e,s,i){this.tip="",e&&(this.tip=t(`toolbar.${e.replace(/-[a-z]/g,r=>r[1].toUpperCase())}`)),s&&(this.tip+=` (${s})`),this.tag=e,this.shortcut=s,this.value=i,this.el=this.element(),this.change=()=>{}}element(){const{tip:e}=this;return h("div",`${cssPrefix}-toolbar-btn`).on("mouseenter",s=>{this.tip&&tooltip(this.tip,s.target)}).attr("data-tooltip",e)}setState(){}}class DropdownItem extends Item{dropdown(){}getValue(e){return e}element(){const{tag:e}=this;return this.dd=this.dropdown(),this.dd.change=s=>this.change(e,this.getValue(s)),super.element().child(this.dd)}setState(e){e&&(this.value=e,this.dd.setTitle(e))}}class Dropdown extends Element{constructor(e,s,i,r,...o){super("div",`${cssPrefix}-dropdown ${r}`),this.title=e,this.change=()=>{},this.headerClick=()=>{},typeof e=="string"?this.title=h("div",`${cssPrefix}-dropdown-title`).child(e):i&&this.title.addClass("arrow-left"),this.contentEl=h("div",`${cssPrefix}-dropdown-content`).css("width",s).hide(),this.setContentChildren(...o),this.headerEl=h("div",`${cssPrefix}-dropdown-header`),this.headerEl.on("click",()=>{this.contentEl.css("display")!=="block"?this.show():this.hide()}).children(this.title,i?h("div",`${cssPrefix}-icon arrow-right`).child(h("div",`${cssPrefix}-icon-img arrow-down`)):""),this.children(this.headerEl,this.contentEl)}setContentChildren(...e){this.contentEl.html(""),e.length>0&&this.contentEl.children(...e)}setTitle(e){this.title.html(e),this.hide()}show(){const{contentEl:e}=this;e.show(),this.parent().active(),bindClickoutside(this.parent(),()=>{this.hide()})}hide(){this.parent().active(!1),this.contentEl.hide(),unbindClickoutside(this.parent())}}function buildItemWithIcon(n){return h("div",`${cssPrefix}-item`).child(new Icon(n))}class DropdownAlign extends Dropdown{constructor(e,s){const i=new Icon(`align-${s}`),r=e.map(o=>buildItemWithIcon(`align-${o}`).on("click",()=>{this.setTitle(o),this.change(o)}));super(i,"auto",!0,"bottom-left",...r)}setTitle(e){this.title.setName(`align-${e}`),this.hide()}}class Align extends DropdownItem{constructor(e){super("align","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["left","center","right"],e)}}class Valign extends DropdownItem{constructor(e){super("valign","",e)}dropdown(){const{value:e}=this;return new DropdownAlign(["top","middle","bottom"],e)}}class ToggleItem extends Item{element(){const{tag:e}=this;return super.element().child(new Icon(e)).on("click",()=>this.click())}click(){this.change(this.tag,this.toggle())}setState(e){this.el.active(e)}toggle(){return this.el.toggle()}active(){return this.el.hasClass("active")}}class Autofilter extends ToggleItem{constructor(){super("autofilter")}setState(){}}class Bold extends ToggleItem{constructor(){super("font-bold","Ctrl+B")}}class Italic extends ToggleItem{constructor(){super("font-italic","Ctrl+I")}}class Strike extends ToggleItem{constructor(){super("strike","Ctrl+U")}}class Underline extends ToggleItem{constructor(){super("underline","Ctrl+U")}}const themeColorPlaceHolders=["#ffffff","#000100","#e7e5e6","#445569","#5b9cd6","#ed7d31","#a5a5a5","#ffc001","#4371c6","#71ae47"],themeColors=[["#f2f2f2","#7f7f7f","#d0cecf","#d5dce4","#deeaf6","#fce5d5","#ededed","#fff2cd","#d9e2f3","#e3efd9"],["#d8d8d8","#595959","#afabac","#adb8ca","#bdd7ee","#f7ccac","#dbdbdb","#ffe59a","#b3c6e7","#c5e0b3"],["#bfbfbf","#3f3f3f","#756f6f","#8596b0","#9cc2e6","#f4b184","#c9c9c9","#fed964","#8eaada","#a7d08c"],["#a5a5a5","#262626","#3a3839","#333f4f","#2e75b5","#c45a10","#7b7b7b","#bf8e01","#2f5596","#538136"],["#7f7f7f","#0c0c0c","#171516","#222a35","#1f4e7a","#843c0a","#525252","#7e6000","#203864","#365624"]],standardColors=["#c00000","#fe0000","#fdc101","#ffff01","#93d051","#00b04e","#01b0f1","#0170c1","#012060","#7030a0"];function buildTd$1(n){return h("td","").child(h("div",`${cssPrefix}-color-palette-cell`).on("click.stop",()=>this.change(n)).css("background-color",n))}class ColorPalette{constructor(){this.el=h("div",`${cssPrefix}-color-palette`),this.change=()=>{};const e=h("table","").children(h("tbody","").children(h("tr",`${cssPrefix}-theme-color-placeholders`).children(...themeColorPlaceHolders.map(s=>buildTd$1.call(this,s))),...themeColors.map(s=>h("tr",`${cssPrefix}-theme-colors`).children(...s.map(i=>buildTd$1.call(this,i)))),h("tr",`${cssPrefix}-standard-colors`).children(...standardColors.map(s=>buildTd$1.call(this,s)))));this.el.child(e)}}class DropdownColor extends Dropdown{constructor(e,s){const i=new Icon(e).css("height","16px").css("border-bottom",`3px solid ${s}`),r=new ColorPalette;r.change=o=>{this.setTitle(o),this.change(o)},super(i,"auto",!1,"bottom-left",r.el)}setTitle(e){this.title.css("border-color",e),this.hide()}}const lineTypes=[["thin",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" style="user-select: none;"></line></svg>'],["medium",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="2" style="user-select: none;"><line x1="0" y1="1.0" x2="50" y2="1.0" stroke-width="2" stroke="black" style="user-select: none;"></line></svg>'],["thick",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="3" style="user-select: none;"><line x1="0" y1="1.5" x2="50" y2="1.5" stroke-width="3" stroke="black" style="user-select: none;"></line></svg>'],["dashed",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="2" style="user-select: none;"></line></svg>'],["dotted",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="1" style="user-select: none;"></line></svg>']];class DropdownLineType extends Dropdown{constructor(e){const s=new Icon("line-type");let i=0;const r=lineTypes.map((o,l)=>h("div",`${cssPrefix}-item state ${e===o[0]?"checked":""}`).on("click",()=>{r[i].toggle("checked"),r[l].toggle("checked"),i=l,this.hide(),this.change(o)}).child(h("div",`${cssPrefix}-line-type`).html(o[1])));super(s,"auto",!1,"bottom-left",...r)}}function buildTable(...n){return h("table","").child(h("tbody","").children(...n))}function buildTd(n){return h("td","").child(h("div",`${cssPrefix}-border-palette-cell`).child(new Icon(`border-${n}`)).on("click",()=>{this.mode=n;const{mode:e,style:s,color:i}=this;this.change({mode:e,style:s,color:i})}))}class BorderPalette{constructor(){this.color="#000",this.style="thin",this.mode="all",this.change=()=>{},this.ddColor=new DropdownColor("line-color",this.color),this.ddColor.change=s=>{this.color=s},this.ddType=new DropdownLineType(this.style),this.ddType.change=([s])=>{this.style=s},this.el=h("div",`${cssPrefix}-border-palette`);const e=buildTable(h("tr","").children(h("td",`${cssPrefix}-border-palette-left`).child(buildTable(h("tr","").children(...["all","inside","horizontal","vertical","outside"].map(s=>buildTd.call(this,s))),h("tr","").children(...["left","top","right","bottom","none"].map(s=>buildTd.call(this,s))))),h("td",`${cssPrefix}-border-palette-right`).children(h("div",`${cssPrefix}-toolbar-btn`).child(this.ddColor.el),h("div",`${cssPrefix}-toolbar-btn`).child(this.ddType.el))));this.el.child(e)}}class DropdownBorder extends Dropdown{constructor(){const e=new Icon("border-all"),s=new BorderPalette;s.change=i=>{this.change(i),this.hide()},super(e,"auto",!1,"bottom-left",s.el)}}class Border extends DropdownItem{constructor(){super("border")}dropdown(){return new DropdownBorder}}class IconItem extends Item{element(){return super.element().child(new Icon(this.tag)).on("click",()=>this.change(this.tag))}setState(e){this.el.disabled(e)}}class Clearformat extends IconItem{constructor(){super("clearformat")}}class Paintformat extends ToggleItem{constructor(){super("paintformat")}setState(){}}class TextColor extends DropdownItem{constructor(e){super("color",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class FillColor extends DropdownItem{constructor(e){super("bgcolor",void 0,e)}dropdown(){const{tag:e,value:s}=this;return new DropdownColor(e,s)}}class DropdownFontSize extends Dropdown{constructor(){const e=fontSizes.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(`${s.pt}`),this.change(s)}).child(`${s.pt}`));super("10","60px",!0,"bottom-left",...e)}}let Format$2=class extends DropdownItem{constructor(){super("font-size")}getValue(e){return e.pt}dropdown(){return new DropdownFontSize}};class DropdownFont extends Dropdown{constructor(){const e=baseFonts.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.setTitle(s.title),this.change(s)}).child(s.title));super(baseFonts[0].title,"160px",!0,"bottom-left",...e)}}class Font extends DropdownItem{constructor(){super("font-name")}getValue(e){return e.key}dropdown(){return new DropdownFont}}class DropdownFormat extends Dropdown{constructor(){let e=baseFormats.slice(0);e.splice(2,0,{key:"divider"}),e.splice(8,0,{key:"divider"}),e=e.map(s=>{const i=h("div",`${cssPrefix}-item`);return s.key==="divider"?i.addClass("divider"):(i.child(s.title()).on("click",()=>{this.setTitle(s.title()),this.change(s)}),s.label&&i.child(h("div","label").html(s.label))),i}),super("Normal","220px",!0,"bottom-left",...e)}setTitle(e){for(let s=0;s<baseFormats.length;s+=1)baseFormats[s].key===e&&this.title.html(baseFormats[s].title());this.hide()}}let Format$1=class extends DropdownItem{constructor(){super("format")}getValue(e){return e.key}dropdown(){return new DropdownFormat}};class DropdownFormula extends Dropdown{constructor(){const e=baseFormulas.map(s=>h("div",`${cssPrefix}-item`).on("click",()=>{this.hide(),this.change(s)}).child(s.key));super(new Icon("formula"),"180px",!0,"bottom-left",...e)}}class Format extends DropdownItem{constructor(){super("formula")}getValue(e){return e.key}dropdown(){return new DropdownFormula}}class Freeze extends ToggleItem{constructor(){super("freeze")}}class Merge extends ToggleItem{constructor(){super("merge")}setState(e,s){this.el.active(e).disabled(s)}}class Redo extends IconItem{constructor(){super("redo","Ctrl+Y")}}class Undo extends IconItem{constructor(){super("undo","Ctrl+Z")}}class Print extends IconItem{constructor(){super("print","Ctrl+P")}}class Textwrap extends ToggleItem{constructor(){super("textwrap")}}let DropdownMore$1=class extends Dropdown{constructor(){const e=new Icon("ellipsis"),s=h("div",`${cssPrefix}-toolbar-more`);super(e,"auto",!1,"bottom-right",s),this.moreBtns=s,this.contentEl.css("max-width","420px")}};class More extends DropdownItem{constructor(){super("more"),this.el.hide()}dropdown(){return new DropdownMore$1}show(){this.el.show()}hide(){this.el.hide()}}function buildDivider(){return h("div",`${cssPrefix}-toolbar-divider`)}function initBtns2(){this.btns2=[],this.items.forEach(n=>{if(Array.isArray(n))n.forEach(({el:e})=>{const s=e.box(),{marginLeft:i,marginRight:r}=e.computedStyle();this.btns2.push([e,s.width+parseInt(i,10)+parseInt(r,10)])});else{const e=n.box(),{marginLeft:s,marginRight:i}=n.computedStyle();this.btns2.push([n,e.width+parseInt(s,10)+parseInt(i,10)])}})}function moreResize(){const{el:n,btns:e,moreEl:s,btns2:i}=this,{moreBtns:r,contentEl:o}=s.dd;n.css("width",`${this.widthFn()}px`);const l=n.box();let a=160,c=12;const d=[],u=[];i.forEach(([f,p],m)=>{a+=p,m===i.length-1||a<l.width?d.push(f):(c+=p,u.push(f))}),e.html("").children(...d),r.html("").children(...u),o.css("width",`${c}px`),u.length>0?s.show():s.hide()}function genBtn(n){const e=new Item;e.el.on("click",()=>{n.onClick&&n.onClick(this.data.getData(),this.data)}),e.tip=n.tip||"";let{el:s}=n;if(n.icon&&(s=h("img").attr("src",n.icon)),s){const i=h("div",`${cssPrefix}-icon`);i.child(s),e.el.child(i)}return e}class Toolbar{constructor(e,s,i=!1){this.data=e,this.change=()=>{},this.widthFn=s,this.isHide=i;const r=e.defaultStyle();this.items=[[this.undoEl=new Undo,this.redoEl=new Redo,new Print,this.paintformatEl=new Paintformat,this.clearformatEl=new Clearformat],buildDivider(),[this.formatEl=new Format$1],buildDivider(),[this.fontEl=new Font,this.fontSizeEl=new Format$2],buildDivider(),[this.boldEl=new Bold,this.italicEl=new Italic,this.underlineEl=new Underline,this.strikeEl=new Strike,this.textColorEl=new TextColor(r.color)],buildDivider(),[this.fillColorEl=new FillColor(r.bgcolor),this.borderEl=new Border,this.mergeEl=new Merge],buildDivider(),[this.alignEl=new Align(r.align),this.valignEl=new Valign(r.valign),this.textwrapEl=new Textwrap],buildDivider(),[this.freezeEl=new Freeze,this.autofilterEl=new Autofilter,this.formulaEl=new Format]];const{extendToolbar:o={}}=e.settings;if(o.left&&o.left.length>0){this.items.unshift(buildDivider());const l=o.left.map(genBtn.bind(this));this.items.unshift(l)}if(o.right&&o.right.length>0){this.items.push(buildDivider());const l=o.right.map(genBtn.bind(this));this.items.push(l)}this.items.push([this.moreEl=new More]),this.el=h("div",`${cssPrefix}-toolbar`),this.btns=h("div",`${cssPrefix}-toolbar-btns`),this.items.forEach(l=>{Array.isArray(l)?l.forEach(a=>{this.btns.child(a.el),a.change=(...c)=>{this.change(...c)}}):this.btns.child(l.el)}),this.el.child(this.btns),i?this.el.hide():(this.reset(),setTimeout(()=>{initBtns2.call(this),moreResize.call(this)},0),bind(window,"resize",()=>{moreResize.call(this)}))}paintformatActive(){return this.paintformatEl.active()}paintformatToggle(){this.paintformatEl.toggle()}trigger(e){this[`${e}El`].click()}resetData(e){this.data=e,this.reset()}reset(){if(this.isHide)return;const{data:e}=this,s=e.getSelectedCellStyle();this.undoEl.setState(!e.canUndo()),this.redoEl.setState(!e.canRedo()),this.mergeEl.setState(e.canUnmerge(),!e.selector.multiple()),this.autofilterEl.setState(!e.canAutofilter());const{font:i,format:r}=s;this.formatEl.setState(r),this.fontEl.setState(i.name),this.fontSizeEl.setState(i.size),this.boldEl.setState(i.bold),this.italicEl.setState(i.italic),this.underlineEl.setState(s.underline),this.strikeEl.setState(s.strike),this.textColorEl.setState(s.color),this.fillColorEl.setState(s.bgcolor),this.alignEl.setState(s.align),this.valignEl.setState(s.valign),this.textwrapEl.setState(s.textwrap),this.freezeEl.setState(e.freezeIsActive())}}class Modal{constructor(e,s,i="600px"){this.title=e,this.el=h("div",`${cssPrefix}-modal`).css("width",i).children(h("div",`${cssPrefix}-modal-header`).children(new Icon("close").on("click.stop",()=>this.hide()),this.title),h("div",`${cssPrefix}-modal-content`).children(...s)).hide()}show(){this.dimmer=h("div",`${cssPrefix}-dimmer active`),document.body.appendChild(this.dimmer.el);const{width:e,height:s}=this.el.show().box(),{clientHeight:i,clientWidth:r}=document.documentElement;this.el.offset({left:(r-e)/2,top:(i-s)/3}),window.xkeydownEsc=o=>{o.keyCode===27&&this.hide()},bind(window,"keydown",window.xkeydownEsc)}hide(){this.el.hide(),document.body.removeChild(this.dimmer.el),unbind(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}class FormInput{constructor(e,s){this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-input`),this.input=h("input","").css("width",e).on("input",i=>this.vchange(i)).attr("placeholder",s),this.el.child(this.input)}focus(){setTimeout(()=>{this.input.el.focus()},10)}hint(e){this.input.attr("placeholder",e)}val(e){return this.input.val(e)}}class FormSelect{constructor(e,s,i,r=l=>l,o=()=>{}){this.key=e,this.getTitle=r,this.vchange=()=>{},this.el=h("div",`${cssPrefix}-form-select`),this.suggest=new Suggest(s.map(l=>({key:l,title:this.getTitle(l)})),l=>{this.itemClick(l.key),o(l.key),this.vchange(l.key)},i,this.el),this.el.children(this.itemEl=h("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",()=>this.show())}show(){this.suggest.search("")}itemClick(e){this.key=e,this.itemEl.html(this.getTitle(e))}val(e){return e!==void 0?(this.key=e,this.itemEl.html(this.getTitle(e)),this):this.key}}const patterns={number:/(^\d+$)|(^\d+(\.\d{0,4})?$)/,date:/^\d{4}-\d{1,2}-\d{1,2}$/};class FormField{constructor(e,s,i,r){this.label="",this.rule=s,i&&(this.label=h("label","label").css("width",`${r}px`).html(i)),this.tip=h("div","tip").child("tip").hide(),this.input=e,this.input.vchange=()=>this.validate(),this.el=h("div",`${cssPrefix}-form-field`).children(this.label,e.el,this.tip)}isShow(){return this.el.css("display")!=="none"}show(){this.el.show()}hide(){return this.el.hide(),this}val(e){return this.input.val(e)}hint(e){this.input.hint(e)}validate(){const{input:e,rule:s,tip:i,el:r}=this,o=e.val();return s.required&&/^\s*$/.test(o)?(i.html(t("validation.required")),r.addClass("error"),!1):(s.type||s.pattern)&&!(s.pattern||patterns[s.type]).test(o)?(i.html(t("validation.notMatch")),r.addClass("error"),!1):(r.removeClass("error"),!0)}}const fieldLabelWidth=100;class ModalValidation extends Modal{constructor(){const e=new FormField(new FormSelect("cell",["cell"],"100%",d=>t(`dataValidation.modeType.${d}`)),{required:!0},`${t("dataValidation.range")}:`,fieldLabelWidth),s=new FormField(new FormInput("120px","E3 or E3:F12"),{required:!0,pattern:/^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/}),i=new FormField(new FormSelect("list",["list","number","date","phone","email"],"100%",d=>t(`dataValidation.type.${d}`),d=>this.criteriaSelected(d)),{required:!0},`${t("dataValidation.criteria")}:`,fieldLabelWidth),r=new FormField(new FormSelect("be",["be","nbe","eq","neq","lt","lte","gt","gte"],"160px",d=>t(`dataValidation.operator.${d}`),d=>this.criteriaOperatorSelected(d)),{required:!0}).hide(),o=new FormField(new FormInput("70px","10"),{required:!0}).hide(),l=new FormField(new FormInput("70px","100"),{required:!0,type:"number"}).hide(),a=new FormField(new FormInput("120px","a,b,c"),{required:!0}),c=new FormField(new FormInput("70px","10"),{required:!0,type:"number"}).hide();super(t("contextmenu.validation"),[h("div",`${cssPrefix}-form-fields`).children(e.el,s.el),h("div",`${cssPrefix}-form-fields`).children(i.el,r.el,o.el,l.el,c.el,a.el),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("remove").on("click",()=>this.btnClick("remove")),new Button("save","primary").on("click",()=>this.btnClick("save")))]),this.mf=e,this.rf=s,this.cf=i,this.of=r,this.minvf=o,this.maxvf=l,this.vf=c,this.svf=a,this.change=()=>{}}showVf(e){const s=e==="date"?"2018-11-12":"10",{vf:i}=this;i.input.hint(s),i.show()}criteriaSelected(e){const{of:s,minvf:i,maxvf:r,vf:o,svf:l}=this;e==="date"||e==="number"?(s.show(),i.rule.type=e,r.rule.type=e,e==="date"?(i.hint("2018-11-12"),r.hint("2019-11-12")):(i.hint("10"),r.hint("100")),i.show(),r.show(),o.hide(),l.hide()):(e==="list"?l.show():l.hide(),o.hide(),s.hide(),i.hide(),r.hide())}criteriaOperatorSelected(e){if(!e)return;const{minvf:s,maxvf:i,vf:r}=this;if(e==="be"||e==="nbe")s.show(),i.show(),r.hide();else{const o=this.cf.val();r.rule.type=o,o==="date"?r.hint("2018-11-12"):r.hint("10"),r.show(),s.hide(),i.hide()}}btnClick(e){if(e==="cancel")this.hide();else if(e==="remove")this.change("remove"),this.hide();else if(e==="save"){const s=["mf","rf","cf","of","svf","vf","minvf","maxvf"];for(let c=0;c<s.length;c+=1){const d=this[s[c]];if(d.isShow()&&!d.validate())return}const i=this.mf.val(),r=this.rf.val(),o=this.cf.val(),l=this.of.val();let a=this.svf.val();(o==="number"||o==="date")&&(a=l==="be"||l==="nbe"?[this.minvf.val(),this.maxvf.val()]:this.vf.val()),this.change("save",i,r,{type:o,operator:l,required:!1,value:a}),this.hide()}}setValue(e){if(e){const{mf:s,rf:i,cf:r,of:o,svf:l,vf:a,minvf:c,maxvf:d}=this,{mode:u,ref:f,validator:p}=e,{type:m,operator:g,value:x}=p||{type:"list"};s.val(u||"cell"),i.val(f),r.val(m),o.val(g),Array.isArray(x)?(c.val(x[0]),d.val(x[1])):(l.val(x||""),a.val(x||"")),this.criteriaSelected(m),this.criteriaOperatorSelected(g)}this.show()}}function buildMenu$1(n){return h("div",`${cssPrefix}-item ${n}`)}function buildSortItem(n){return buildMenu$1("state").child(t(`sort.${n}`)).on("click.stop",()=>this.itemClick(n))}function buildFilterBody(n){const{filterbEl:e,filterValues:s}=this;e.html(""),Object.keys(n).forEach((r,o)=>{const l=n[r],a=s.includes(r)?"checked":"";e.child(h("div",`${cssPrefix}-item state ${a}`).on("click.stop",()=>this.filterClick(o,r)).children(r===""?t("filter.empty"):r,h("div","label").html(`(${l})`)))})}function resetFilterHeader(){const{filterhEl:n,filterValues:e,values:s}=this;n.html(`${e.length} / ${s.length}`),n.checked(e.length===s.length)}class SortFilter{constructor(){this.filterbEl=h("div",`${cssPrefix}-body`),this.filterhEl=h("div",`${cssPrefix}-header state`).on("click.stop",()=>this.filterClick(0,"all")),this.el=h("div",`${cssPrefix}-sort-filter`).children(this.sortAscEl=buildSortItem.call(this,"asc"),this.sortDescEl=buildSortItem.call(this,"desc"),buildMenu$1("divider"),h("div",`${cssPrefix}-filter`).children(this.filterhEl,this.filterbEl),h("div",`${cssPrefix}-buttons`).children(new Button("cancel").on("click",()=>this.btnClick("cancel")),new Button("ok","primary").on("click",()=>this.btnClick("ok")))).hide(),this.ci=null,this.sortDesc=null,this.values=null,this.filterValues=[]}btnClick(e){if(e==="ok"){const{ci:s,sort:i,filterValues:r}=this;this.ok&&this.ok(s,i,"in",r)}this.hide()}itemClick(e){this.sort=e;const{sortAscEl:s,sortDescEl:i}=this;s.checked(e==="asc"),i.checked(e==="desc")}filterClick(e,s){const{filterbEl:i,filterValues:r,values:o}=this,l=i.children();s==="all"?l.length===r.length?(this.filterValues=[],l.forEach(a=>h(a).checked(!1))):(this.filterValues=Array.from(o),l.forEach(a=>h(a).checked(!0))):h(l[e]).toggle("checked")?r.push(s):r.splice(r.findIndex(c=>c===s),1),resetFilterHeader.call(this)}set(e,s,i,r){this.ci=e;const{sortAscEl:o,sortDescEl:l}=this;r!==null?(this.sort=r.order,o.checked(r.asc()),l.checked(r.desc())):(this.sortDesc=null,o.checked(!1),l.checked(!1)),this.values=Object.keys(s),this.filterValues=i?Array.from(i.value):Object.keys(s),buildFilterBody.call(this,s,i),resetFilterHeader.call(this)}setOffset(e){this.el.offset(e).show();let s=1;bindClickoutside(this.el,()=>{s<=0&&this.hide(),s-=1})}show(){this.el.show()}hide(){this.el.hide(),unbindClickoutside(this.el)}}function xtoast(n,e){const s=h("div",`${cssPrefix}-toast`),i=h("div",`${cssPrefix}-dimmer active`),r=()=>{document.body.removeChild(s.el),document.body.removeChild(i.el)};s.children(h("div",`${cssPrefix}-toast-header`).children(new Icon("close").on("click.stop",()=>r()),n),h("div",`${cssPrefix}-toast-content`).html(e)),document.body.appendChild(s.el),document.body.appendChild(i.el);const{width:o,height:l}=s.box(),{clientHeight:a,clientWidth:c}=document.documentElement;s.offset({left:(c-o)/2,top:(a-l)/3})}function throttle$2(n,e){let s;return(...i)=>{const r=this,o=i;s||(s=setTimeout(()=>{s=null,n.apply(r,o)},e))}}function scrollbarMove(){const{data:n,verticalScrollbar:e,horizontalScrollbar:s}=this,{l:i,t:r,left:o,top:l,width:a,height:c}=n.getSelectedRect(),d=this.getTableOffset();if(Math.abs(o)+a>d.width)s.move({left:i+a-d.width});else{const u=n.freezeTotalWidth();o<u&&s.move({left:i-1-u})}if(Math.abs(l)+c>d.height)e.move({top:r+c-d.height-1});else{const u=n.freezeTotalHeight();l<u&&e.move({top:r-1-u})}}function selectorSet(n,e,s,i=!0,r=!1){if(e===-1&&s===-1)return;const{table:o,selector:l,toolbar:a,data:c,contextMenu:d}=this,u=c.getCell(e,s);n?(l.setEnd(e,s,r),this.trigger("cells-selected",u,l.range)):(l.set(e,s,i),this.trigger("cell-selected",u,e,s)),d.setMode(e===-1||s===-1?"row-col":"range"),a.reset(),o.render()}function selectorMove(n,e){const{selector:s,data:i}=this,{rows:r,cols:o}=i;let[l,a]=s.indexes;const{eri:c,eci:d}=s.range;n&&([l,a]=s.moveIndexes),e==="left"?a>0&&(a-=1):e==="right"?(d!==a&&(a=d),a<o.len-1&&(a+=1)):e==="up"?l>0&&(l-=1):e==="down"?(c!==l&&(l=c),l<r.len-1&&(l+=1)):e==="row-first"?a=0:e==="row-last"?a=o.len-1:e==="col-first"?l=0:e==="col-last"&&(l=r.len-1),n&&(s.moveIndexes=[l,a]),selectorSet.call(this,n,l,a),scrollbarMove.call(this)}function overlayerMousemove(n){if(n.buttons!==0||n.target.className===`${cssPrefix}-resizer-hover`)return;const{offsetX:e,offsetY:s}=n,{rowResizer:i,colResizer:r,tableEl:o,data:l}=this,{rows:a,cols:c}=l;if(e>c.indexWidth&&s>a.height){i.hide(),r.hide();return}const d=o.box(),u=l.getCellRectByXY(n.offsetX,n.offsetY);u.ri>=0&&u.ci===-1?(u.width=c.indexWidth,i.show(u,{width:d.width}),a.isHide(u.ri-1)?i.showUnhide(u.ri):i.hideUnhide()):i.hide(),u.ri===-1&&u.ci>=0?(u.height=a.height,r.show(u,{height:d.height}),c.isHide(u.ci-1)?r.showUnhide(u.ci):r.hideUnhide()):r.hide()}function overlayerMousescroll(n){const{verticalScrollbar:e,horizontalScrollbar:s,data:i}=this,{top:r}=e.scroll(),{left:o}=s.scroll(),{rows:l,cols:a}=i,{deltaY:c,deltaX:d}=n,u=(b,E)=>{let v=b,w=0;do w=E(v),v+=1;while(w<=0);return w},f=b=>{if(b>0){const E=i.scroll.ri+1;if(E<l.len){const v=u(E,w=>l.getHeight(w));e.move({top:r+v-1})}}else{const E=i.scroll.ri-1;if(E>=0){const v=u(E,w=>l.getHeight(w));e.move({top:E===0?0:r-v})}}},p=b=>{if(b>0){const E=i.scroll.ci+1;if(E<a.len){const v=u(E,w=>a.getWidth(w));s.move({left:o+v-1})}}else{const E=i.scroll.ci-1;if(E>=0){const v=u(E,w=>a.getWidth(w));s.move({left:E===0?0:o-v})}}},m=Math.abs(c),g=Math.abs(d),x=Math.max(m,g);/Firefox/i.test(window.navigator.userAgent)&&throttle$2(f(n.detail),50),x===g&&throttle$2(p(d),50),x===m&&throttle$2(f(c),50)}function overlayerTouch(n,e){const{verticalScrollbar:s,horizontalScrollbar:i}=this,{top:r}=s.scroll(),{left:o}=i.scroll();n==="left"||n==="right"?i.move({left:o-e}):(n==="up"||n==="down")&&s.move({top:r-e})}function verticalScrollbarSet(){const{data:n,verticalScrollbar:e}=this,{height:s}=this.getTableOffset(),i=n.exceptRowTotalHeight(0,-1);e.set(s,n.rows.totalHeight()-i)}function horizontalScrollbarSet(){const{data:n,horizontalScrollbar:e}=this,{width:s}=this.getTableOffset();n&&e.set(s,n.cols.totalWidth())}function sheetFreeze(){const{selector:n,data:e,editor:s}=this,[i,r]=e.freeze;if(i>0||r>0){const o=e.freezeTotalWidth(),l=e.freezeTotalHeight();s.setFreezeLengths(o,l)}n.resetAreaOffset()}function sheetReset(){const{tableEl:n,overlayerEl:e,overlayerCEl:s,table:i,toolbar:r,selector:o,el:l}=this,a=this.getTableOffset(),c=this.getRect();n.attr(c),e.offset(c),s.offset(a),l.css("width",`${c.width}px`),verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),sheetFreeze.call(this),i.render(),r.reset(),o.reset()}function clearClipboard(){const{data:n,selector:e}=this;n.clearClipboard(),e.hideClipboard()}function copy$2(n){const{data:e,selector:s}=this;e.settings.mode!=="read"&&(e.copy(),e.copyToSystemClipboard(n),s.showClipboard())}function cut(){const{data:n,selector:e}=this;n.settings.mode!=="read"&&(n.cut(),e.showClipboard())}function paste(n,e){const{data:s}=this;if(s.settings.mode!=="read"){if(s.clipboard.isClear()){const i=()=>sheetReset.call(this),r=o=>{this.trigger("pasted-clipboard",o)};s.pasteFromSystemClipboard(i,r)}else if(s.paste(n,i=>xtoast("Tip",i)))sheetReset.call(this);else if(e){const i=e.clipboardData.getData("text/plain");this.data.pasteFromText(i),sheetReset.call(this)}}}function hideRowsOrCols(){this.data.hideRowsOrCols(),sheetReset.call(this)}function unhideRowsOrCols(n,e){this.data.unhideRowsOrCols(n,e),sheetReset.call(this)}function autofilter(){const{data:n}=this;n.autofilter(),sheetReset.call(this)}function toolbarChangePaintformatPaste(){const{toolbar:n}=this;n.paintformatActive()&&(paste.call(this,"format"),clearClipboard.call(this),n.paintformatToggle())}function overlayerMousedown(n){const{selector:e,data:s,table:i,sortFilter:r}=this,{offsetX:o,offsetY:l}=n,a=n.target.className===`${cssPrefix}-selector-corner`,c=s.getCellRectByXY(o,l),{left:d,top:u,width:f,height:p}=c;let{ri:m,ci:g}=c;const{autoFilter:x}=s;if(x.includes(m,g)&&d+f-20<o&&u+p-20<l){const b=x.items(g,(E,v)=>s.rows.getCell(E,v));r.hide(),r.set(g,b,x.getFilter(g),x.getSort(g)),r.setOffset({left:d,top:u+p+2});return}n.shiftKey||(a?e.showAutofill(m,g):selectorSet.call(this,!1,m,g),mouseMoveUp(window,b=>{({ri:m,ci:g}=s.getCellRectByXY(b.offsetX,b.offsetY)),a?e.showAutofill(m,g):b.buttons===1&&!b.shiftKey&&selectorSet.call(this,!0,m,g,!0,!0)},()=>{a&&e.arange&&s.settings.mode!=="read"&&s.autofill(e.arange,"all",b=>xtoast("Tip",b))&&i.render(),e.hideAutofill(),toolbarChangePaintformatPaste.call(this)})),!a&&n.buttons===1&&n.shiftKey&&selectorSet.call(this,!0,m,g)}function editorSetOffset(){const{editor:n,data:e}=this,s=e.getSelectedRect(),i=this.getTableOffset();let r="top";s.top>i.height/2&&(r="bottom"),n.setOffset(s,r)}function editorSet(){const{editor:n,data:e}=this;e.settings.mode!=="read"&&(editorSetOffset.call(this),n.setCell(e.getSelectedCell(),e.getSelectedValidator()),clearClipboard.call(this))}function verticalScrollbarMove(n){const{data:e,table:s,selector:i}=this;e.scrolly(n,()=>{i.resetBRLAreaOffset(),editorSetOffset.call(this),s.render()})}function horizontalScrollbarMove(n){const{data:e,table:s,selector:i}=this;e.scrollx(n,()=>{i.resetBRTAreaOffset(),editorSetOffset.call(this),s.render()})}function rowResizerFinished(n,e){const{ri:s}=n,{table:i,selector:r,data:o}=this,{sri:l,eri:a}=r.range;if(s>=l&&s<=a)for(let c=l;c<=a;c+=1)o.rows.setHeight(c,e);else o.rows.setHeight(s,e);i.render(),r.resetAreaOffset(),verticalScrollbarSet.call(this),editorSetOffset.call(this)}function colResizerFinished(n,e){const{ci:s}=n,{table:i,selector:r,data:o}=this,{sci:l,eci:a}=r.range;if(s>=l&&s<=a)for(let c=l;c<=a;c+=1)o.cols.setWidth(c,e);else o.cols.setWidth(s,e);i.render(),r.resetAreaOffset(),horizontalScrollbarSet.call(this),editorSetOffset.call(this)}function dataSetCellText(n,e="finished"){const{data:s,table:i}=this;if(s.settings.mode==="read")return;s.setSelectedCellText(n,e);const{ri:r,ci:o}=s.selector;e==="finished"?i.render():this.trigger("cell-edited",n,r,o)}function insertDeleteRowColumn(n){const{data:e}=this;e.settings.mode!=="read"&&(n==="insert-row"?e.insert("row"):n==="delete-row"?e.delete("row"):n==="insert-column"?e.insert("column"):n==="delete-column"?e.delete("column"):n==="delete-cell"?e.deleteCell():n==="delete-cell-format"?e.deleteCell("format"):n==="delete-cell-text"?e.deleteCell("text"):n==="cell-printable"?e.setSelectedCellAttr("printable",!0):n==="cell-non-printable"?e.setSelectedCellAttr("printable",!1):n==="cell-editable"?e.setSelectedCellAttr("editable",!0):n==="cell-non-editable"&&e.setSelectedCellAttr("editable",!1),clearClipboard.call(this),sheetReset.call(this))}function toolbarChange(n,e){const{data:s}=this;if(n==="undo")this.undo();else if(n==="redo")this.redo();else if(n==="print")this.print.preview();else if(n==="paintformat")e===!0?copy$2.call(this):clearClipboard.call(this);else if(n==="clearformat")insertDeleteRowColumn.call(this,"delete-cell-format");else if(n!=="link"){if(n!=="chart")if(n==="autofilter")autofilter.call(this);else if(n==="freeze")if(e){const{ri:i,ci:r}=s.selector;this.freeze(i,r)}else this.freeze(0,0);else s.setSelectedCellAttr(n,e),n==="formula"&&!s.selector.multiple()&&editorSet.call(this),sheetReset.call(this)}}function sortFilterChange(n,e,s,i){this.data.setAutoFilter(n,e,s,i),sheetReset.call(this)}function sheetInitEvents(){const{selector:n,overlayerEl:e,rowResizer:s,colResizer:i,verticalScrollbar:r,horizontalScrollbar:o,editor:l,contextMenu:a,toolbar:c,modalValidation:d,sortFilter:u}=this;e.on("mousemove",f=>{overlayerMousemove.call(this,f)}).on("mousedown",f=>{l.clear(),a.hide(),f.buttons===2?(this.data.xyInSelectedRect(f.offsetX,f.offsetY)||overlayerMousedown.call(this,f),a.setPosition(f.offsetX,f.offsetY),f.stopPropagation()):f.detail===2?editorSet.call(this):overlayerMousedown.call(this,f)}).on("mousewheel.stop",f=>{overlayerMousescroll.call(this,f)}).on("mouseout",f=>{const{offsetX:p,offsetY:m}=f;m<=0&&i.hide(),p<=0&&s.hide()}),n.inputChange=f=>{dataSetCellText.call(this,f,"input"),editorSet.call(this)},bindTouch(e.el,{move:(f,p)=>{overlayerTouch.call(this,f,p)}}),c.change=(f,p)=>toolbarChange.call(this,f,p),u.ok=(f,p,m,g)=>sortFilterChange.call(this,f,p,m,g),s.finishedFn=(f,p)=>{rowResizerFinished.call(this,f,p)},i.finishedFn=(f,p)=>{colResizerFinished.call(this,f,p)},s.unhideFn=f=>{unhideRowsOrCols.call(this,"row",f)},i.unhideFn=f=>{unhideRowsOrCols.call(this,"col",f)},r.moveFn=(f,p)=>{verticalScrollbarMove.call(this,f,p)},o.moveFn=(f,p)=>{horizontalScrollbarMove.call(this,f,p)},l.change=(f,p)=>{dataSetCellText.call(this,p,f)},d.change=(f,...p)=>{f==="save"?this.data.addValidation(...p):this.data.removeValidation()},a.itemClick=f=>{f==="validation"?d.setValue(this.data.getSelectedValidation()):f==="copy"?copy$2.call(this):f==="cut"?cut.call(this):f==="paste"?paste.call(this,"all"):f==="paste-value"?paste.call(this,"text"):f==="paste-format"?paste.call(this,"format"):f==="hide"?hideRowsOrCols.call(this):insertDeleteRowColumn.call(this,f)},bind(window,"resize",()=>{this.reload()}),bind(window,"click",f=>{this.focusing=e.contains(f.target)}),bind(window,"paste",f=>{this.focusing&&(paste.call(this,"all",f),f.preventDefault())}),bind(window,"copy",f=>{this.focusing&&(copy$2.call(this,f),f.preventDefault())}),bind(window,"keydown",f=>{if(!this.focusing)return;const p=f.keyCode||f.which,{key:m,ctrlKey:g,shiftKey:x,metaKey:b}=f;if(g||b)switch(p){case 90:this.undo(),f.preventDefault();break;case 89:this.redo(),f.preventDefault();break;case 67:break;case 88:cut.call(this),f.preventDefault();break;case 85:c.trigger("underline"),f.preventDefault();break;case 86:break;case 37:selectorMove.call(this,x,"row-first"),f.preventDefault();break;case 38:selectorMove.call(this,x,"col-first"),f.preventDefault();break;case 39:selectorMove.call(this,x,"row-last"),f.preventDefault();break;case 40:selectorMove.call(this,x,"col-last"),f.preventDefault();break;case 32:selectorSet.call(this,!1,-1,this.data.selector.ci,!1),f.preventDefault();break;case 66:c.trigger("bold");break;case 73:c.trigger("italic");break}else{switch(p){case 32:x&&selectorSet.call(this,!1,this.data.selector.ri,-1,!1);break;case 27:a.hide(),clearClipboard.call(this);break;case 37:selectorMove.call(this,x,"left"),f.preventDefault();break;case 38:selectorMove.call(this,x,"up"),f.preventDefault();break;case 39:selectorMove.call(this,x,"right"),f.preventDefault();break;case 40:selectorMove.call(this,x,"down"),f.preventDefault();break;case 9:l.clear(),selectorMove.call(this,!1,x?"left":"right"),f.preventDefault();break;case 13:l.clear(),selectorMove.call(this,!1,x?"up":"down"),f.preventDefault();break;case 8:insertDeleteRowColumn.call(this,"delete-cell-text"),f.preventDefault();break}m==="Delete"?(insertDeleteRowColumn.call(this,"delete-cell-text"),f.preventDefault()):p>=65&&p<=90||p>=48&&p<=57||p>=96&&p<=105||f.key==="="?(dataSetCellText.call(this,f.key,"input"),editorSet.call(this)):p===113&&editorSet.call(this)}})}class Sheet{constructor(e,s){this.eventMap=createEventEmitter();const{view:i,showToolbar:r,showContextmenu:o}=s.settings;this.el=h("div",`${cssPrefix}-sheet`),this.toolbar=new Toolbar(s,i.width,!r),this.print=new Print$1(s),e.children(this.toolbar.el,this.el,this.print.el),this.data=s,this.tableEl=h("canvas",`${cssPrefix}-table`),this.rowResizer=new Resizer(!1,s.rows.height),this.colResizer=new Resizer(!0,s.cols.minWidth),this.verticalScrollbar=new Scrollbar(!0),this.horizontalScrollbar=new Scrollbar(!1),this.editor=new Editor(formulas,()=>this.getTableOffset(),s.rows.height),this.modalValidation=new ModalValidation,this.contextMenu=new ContextMenu$1(()=>this.getRect(),!o),this.selector=new Selector(s),this.overlayerCEl=h("div",`${cssPrefix}-overlayer-content`).children(this.editor.el,this.selector.el),this.overlayerEl=h("div",`${cssPrefix}-overlayer`).child(this.overlayerCEl),this.sortFilter=new SortFilter,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new table_rslib_entry_(this.tableEl.el,s),sheetInitEvents.call(this),sheetReset.call(this),selectorSet.call(this,!1,0,0)}on(e,s){return this.eventMap.on(e,s),this}trigger(e,...s){const{eventMap:i}=this;i.fire(e,s)}resetData(e){this.editor.clear(),this.data=e,verticalScrollbarSet.call(this),horizontalScrollbarSet.call(this),this.toolbar.resetData(e),this.print.resetData(e),this.selector.resetData(e),this.table.resetData(e)}loadData(e){return this.data.setData(e),sheetReset.call(this),this}freeze(e,s){const{data:i}=this;return i.setFreeze(e,s),sheetReset.call(this),this}undo(){this.data.undo(),sheetReset.call(this)}redo(){this.data.redo(),sheetReset.call(this)}reload(){return sheetReset.call(this),this}getRect(){const{data:e}=this;return{width:e.viewWidth(),height:e.viewHeight()}}getTableOffset(){const{rows:e,cols:s}=this.data,{width:i,height:r}=this.getRect();return{width:i-s.indexWidth,height:r-e.height,left:s.indexWidth,top:e.height}}}class DropdownMore extends Dropdown{constructor(e){const s=new Icon("ellipsis");super(s,"auto",!1,"top-left"),this.contentClick=e}reset(e){const s=e.map((i,r)=>h("div",`${cssPrefix}-item`).css("width","150px").css("font-weight","normal").on("click",()=>{this.contentClick(r),this.hide()}).child(i));this.setContentChildren(...s)}setTitle(){}}const menuItems=[{key:"delete",title:tf("contextmenu.deleteSheet")}];function buildMenuItem(n){return h("div",`${cssPrefix}-item`).child(n.title()).on("click",()=>{this.itemClick(n.key),this.hide()})}function buildMenu(){return menuItems.map(n=>buildMenuItem.call(this,n))}class ContextMenu{constructor(){this.el=h("div",`${cssPrefix}-contextmenu`).css("width","160px").children(...buildMenu.call(this)).hide(),this.itemClick=()=>{}}hide(){const{el:e}=this;e.hide(),unbindClickoutside(e)}setOffset(e){const{el:s}=this;s.offset(e),s.show(),bindClickoutside(s)}}class Bottombar{constructor(e=()=>{},s=()=>{},i=()=>{},r=()=>{}){this.swapFunc=s,this.updateFunc=r,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new DropdownMore(o=>{this.clickSwap2(this.items[o])}),this.contextMenu=new ContextMenu,this.contextMenu.itemClick=i,this.el=h("div",`${cssPrefix}-bottombar`).children(this.contextMenu.el,this.menuEl=h("ul",`${cssPrefix}-menu`).child(h("li","").children(new Icon("add").on("click",()=>{e()}),h("span","").child(this.moreEl))))}addItem(e,s,i){this.dataNames.push(e);const r=h("li",s?"active":"").child(e);r.on("click",()=>{this.clickSwap2(r)}).on("contextmenu",o=>{if(i.mode==="read")return;const{offsetLeft:l,offsetHeight:a}=o.target;this.contextMenu.setOffset({left:l,bottom:a+1}),this.deleteEl=r}).on("dblclick",()=>{if(i.mode==="read")return;const o=r.html(),l=new FormInput("auto","");l.val(o),l.input.on("blur",({target:a})=>{const{value:c}=a,d=this.dataNames.findIndex(u=>u===o);this.renameItem(d,c)}),r.html("").child(l.el),l.focus()}),s&&this.clickSwap(r),this.items.push(r),this.menuEl.child(r),this.moreEl.reset(this.dataNames)}renameItem(e,s){this.dataNames.splice(e,1,s),this.moreEl.reset(this.dataNames),this.items[e].html("").child(s),this.updateFunc(e,s)}clear(){this.items.forEach(e=>{this.menuEl.removeChild(e.el)}),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}deleteItem(){const{activeEl:e,deleteEl:s}=this;if(this.items.length>1){const i=this.items.findIndex(r=>r===s);if(this.items.splice(i,1),this.dataNames.splice(i,1),this.menuEl.removeChild(s.el),this.moreEl.reset(this.dataNames),e===s){const[r]=this.items;return this.activeEl=r,this.activeEl.toggle(),[i,0]}return[i,-1]}return[-1]}clickSwap2(e){const s=this.items.findIndex(i=>i===e);this.clickSwap(e),this.activeEl.toggle(),this.swapFunc(s)}clickSwap(e){this.activeEl!==null&&this.activeEl.toggle(),this.activeEl=e}}const B=class B{constructor(e,s={}){U(this,y);U(this,P,1);U(this,S);U(this,M);U(this,F);U(this,O);N(this,y,D({showBottomBar:!0},s)),N(this,S,[]),N(this,O,k(this,y).showBottomBar?new Bottombar(()=>{if(k(this,y).mode==="read")return;const r=this.addSheet();k(this,F).resetData(r)},r=>{const o=k(this,S)[r];k(this,F).resetData(o)},()=>{this.deleteSheet()},(r,o)=>{k(this,S)[r].name=o,k(this,F).trigger("change")}):null),N(this,M,this.addSheet());const i=h("div",`${cssPrefix}`).on("contextmenu",r=>r.preventDefault());e.appendChild(i.el),N(this,F,new Sheet(i,k(this,M))),k(this,O)!==null&&i.child(k(this,O).el)}static makeSheet(e,s={}){if(B.targets.has(e)){const r=B.targets.get(e);if(r)return r}const i=new B(e,s);B.targets.set(e,i)}on(e,s){return k(this,F).on(e,s),this}reRender(){return k(this,F).table.render(),this}cell(e,s,i=0){return k(this,S)[i].getCell(e,s)}cellStyle(e,s,i=0){return k(this,S)[i].getCellStyle(e,s)}cellText(e,s,i,r=0){return k(this,S)[r].setCellText(e,s,i,"finished"),this}deleteSheet(){if(k(this,O)===null)return;const[e,s]=k(this,O).deleteItem();e>=0&&(k(this,S).splice(e,1),s>=0&&k(this,F).resetData(k(this,S)[s]),k(this,F).trigger("change"))}loadData(e){const s=Array.isArray(e)?e:[e];if(k(this,O)!==null&&k(this,O).clear(),N(this,S,[]),s.length>0)for(let i=0;i<s.length;i+=1){const r=s[i],o=this.addSheet(r.name,i===0);o.setData(r),i===0&&k(this,F).resetData(o)}return this}getData(){return k(this,S).map(e=>e.getData())}validate(){const{validations:e}=k(this,M);return e.errors.size<=0}change(e){return k(this,F).on("change",e),this}static locale(e,s){locale(e,s)}addSheet(e,s=!0){const i=e||`sheet${k(this,P)}`,r=new DataProxy(i,k(this,y));return r.change=(...o)=>{k(this,F).trigger("change",...o)},k(this,S).push(r),k(this,O)!==null&&k(this,O).addItem(i,s,k(this,y)),N(this,P,k(this,P)+1),r}};y=new WeakMap,P=new WeakMap,S=new WeakMap,M=new WeakMap,F=new WeakMap,O=new WeakMap,Q(B,"targets",new WeakMap);let Spreadsheet=B;var __webpack_exports__Spreadsheet=Spreadsheet;const ExcelSheet=React.forwardRef(({data:n,className:e},s)=>{const i=React.useRef(null),r=React.useRef(null),o=()=>{if(!i.current)throw new Error("Workbook is not initialized");return i.current.getData()};return React.useImperativeHandle(s,()=>({getData:o})),React.useEffect(()=>{if(r.current){const l=__webpack_exports__Spreadsheet.makeSheet(r.current,{view:{height:()=>{var a;return(a=r.current)==null?void 0:a.offsetHeight},width:()=>{var a;return(a=r.current)==null?void 0:a.offsetWidth}}});l.loadData(n),i.current=l}},[n]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{ref:r,id:"sheet988",className:client.cx(client.css`
17
17
  width: 100%;
18
18
  height: 100%;
19
19
  `,e)})});ExcelSheet.displayName="ExcelSheet";/*!
20
20
  * Signature Pad v4.2.0 | https://github.com/szimek/signature_pad
21
21
  * (c) 2024 Szymon Nowak | Released under the MIT license
22
- */class Point{constructor(e,s,i,r){if(isNaN(e)||isNaN(s))throw new Error(`Point is invalid: (${e}, ${s})`);this.x=+e,this.y=+s,this.pressure=i||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class Bezier{static fromPoints(e,s){const i=this.calculateControlPoints(e[0],e[1],e[2]).c2,r=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new Bezier(e[1],i,r,e[2],s.start,s.end)}static calculateControlPoints(e,s,i){const r=e.x-s.x,o=e.y-s.y,l=s.x-i.x,a=s.y-i.y,c={x:(e.x+s.x)/2,y:(e.y+s.y)/2},d={x:(s.x+i.x)/2,y:(s.y+i.y)/2},u=Math.sqrt(r*r+o*o),f=Math.sqrt(l*l+a*a),m=c.x-d.x,p=c.y-d.y,g=f/(u+f),x={x:d.x+m*g,y:d.y+p*g},b=s.x-x.x,w=s.y-x.y;return{c1:new Point(c.x+b,c.y+w),c2:new Point(d.x+b,d.y+w)}}constructor(e,s,i,r,o,l){this.startPoint=e,this.control2=s,this.control1=i,this.endPoint=r,this.startWidth=o,this.endWidth=l}length(){let s=0,i,r;for(let o=0;o<=10;o+=1){const l=o/10,a=this.point(l,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),c=this.point(l,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){const d=a-i,u=c-r;s+=Math.sqrt(d*d+u*u)}i=a,r=c}return s}point(e,s,i,r,o){return s*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e}}class SignatureEventTarget{constructor(){try{this._et=new EventTarget}catch(e){this._et=document}}addEventListener(e,s,i){this._et.addEventListener(e,s,i)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,s,i){this._et.removeEventListener(e,s,i)}}function throttle$1(n,e=250){let s=0,i=null,r,o,l;const a=()=>{s=Date.now(),i=null,r=n.apply(o,l),i||(o=null,l=[])};return function(...d){const u=Date.now(),f=e-(u-s);return o=this,l=d,f<=0||f>e?(i&&(clearTimeout(i),i=null),s=u,r=n.apply(o,l),i||(o=null,l=[])):i||(i=window.setTimeout(a,f)),r}}let SignaturePad$1=class G extends SignatureEventTarget{constructor(e,s={}){super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this._handleMouseDown=i=>{i.buttons===1&&this._strokeBegin(i)},this._handleMouseMove=i=>{this._strokeMoveUpdate(i)},this._handleMouseUp=i=>{i.buttons===1&&this._strokeEnd(i)},this._handleTouchStart=i=>{if(i.cancelable&&i.preventDefault(),i.targetTouches.length===1){const r=i.changedTouches[0];this._strokeBegin(r)}},this._handleTouchMove=i=>{i.cancelable&&i.preventDefault();const r=i.targetTouches[0];this._strokeMoveUpdate(r)},this._handleTouchEnd=i=>{if(i.target===this.canvas){i.cancelable&&i.preventDefault();const o=i.changedTouches[0];this._strokeEnd(o)}},this._handlePointerStart=i=>{i.preventDefault(),this._strokeBegin(i)},this._handlePointerMove=i=>{this._strokeMoveUpdate(i)},this._handlePointerEnd=i=>{this._drawingStroke&&(i.preventDefault(),this._strokeEnd(i))},this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.dotSize=s.dotSize||0,this.penColor=s.penColor||"black",this.backgroundColor=s.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=s.compositeOperation||"source-over",this.canvasContextOptions="canvasContextOptions"in s?s.canvasContextOptions:{},this._strokeMoveUpdate=this.throttle?throttle$1(G.prototype._strokeUpdate,this.throttle):G.prototype._strokeUpdate,this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:s}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,s.width,s.height),e.fillRect(0,0,s.width,s.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0}fromDataURL(e,s={}){return new Promise((i,r)=>{const o=new Image,l=s.ratio||window.devicePixelRatio||1,a=s.width||this.canvas.width/l,c=s.height||this.canvas.height/l,d=s.xOffset||0,u=s.yOffset||0;this._reset(this._getPointGroupOptions()),o.onload=()=>{this._ctx.drawImage(o,d,u,a,c),i()},o.onerror=f=>{r(f)},o.crossOrigin="anonymous",o.src=e,this._isEmpty=!1})}toDataURL(e="image/png",s){switch(e){case"image/svg+xml":return typeof s!="object"&&(s=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(s))}`;default:return typeof s!="number"&&(s=void 0),this.canvas.toDataURL(e,s)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerStart),this.canvas.removeEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.removeEventListener("pointerup",this._handlePointerEnd),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.removeEventListener("mouseup",this._handleMouseUp),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this.canvas.removeEventListener("touchmove",this._handleTouchMove),this.canvas.removeEventListener("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:s=!0}={}){s&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;this._drawingStroke=!0;const i=this._getPointGroupOptions(),r=Object.assign(Object.assign({},i),{points:[]});this._data.push(r),this._reset(i),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const s=e.clientX,i=e.clientY,r=e.pressure!==void 0?e.pressure:e.force!==void 0?e.force:0,o=this._createPoint(s,i,r),l=this._data[this._data.length-1],a=l.points,c=a.length>0&&a[a.length-1],d=c?o.distanceTo(c)<=this.minDistance:!1,u=this._getPointGroupOptions(l);if(!c||!(c&&d)){const f=this._addPoint(o,u);c?f&&this._drawCurve(f,u):this._drawDot(o,u),a.push({time:o.time,x:o.x,y:o.y,pressure:o.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e){this._drawingStroke&&(this._strokeUpdate(e),this._drawingStroke=!1,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerStart),this.canvas.addEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.addEventListener("pointerup",this._handlePointerEnd)}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown),this.canvas.addEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.addEventListener("mouseup",this._handleMouseUp)}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart),this.canvas.addEventListener("touchmove",this._handleTouchMove),this.canvas.addEventListener("touchend",this._handleTouchEnd)}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,s,i){const r=this.canvas.getBoundingClientRect();return new Point(e-r.left,s-r.top,i,new Date().getTime())}_addPoint(e,s){const{_lastPoints:i}=this;if(i.push(e),i.length>2){i.length===3&&i.unshift(i[0]);const r=this._calculateCurveWidths(i[1],i[2],s),o=Bezier.fromPoints(i,r);return i.shift(),o}return null}_calculateCurveWidths(e,s,i){const r=i.velocityFilterWeight*s.velocityFrom(e)+(1-i.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(r,i),l={end:o,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=o,l}_strokeWidth(e,s){return Math.max(s.maxWidth/(e+1),s.minWidth)}_drawCurveSegment(e,s,i){const r=this._ctx;r.moveTo(e,s),r.arc(e,s,i,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,s){const i=this._ctx,r=e.endWidth-e.startWidth,o=Math.ceil(e.length())*2;i.beginPath(),i.fillStyle=s.penColor;for(let l=0;l<o;l+=1){const a=l/o,c=a*a,d=c*a,u=1-a,f=u*u,m=f*u;let p=m*e.startPoint.x;p+=3*f*a*e.control1.x,p+=3*u*c*e.control2.x,p+=d*e.endPoint.x;let g=m*e.startPoint.y;g+=3*f*a*e.control1.y,g+=3*u*c*e.control2.y,g+=d*e.endPoint.y;const x=Math.min(e.startWidth+d*r,s.maxWidth);this._drawCurveSegment(p,g,x)}i.closePath(),i.fill()}_drawDot(e,s){const i=this._ctx,r=s.dotSize>0?s.dotSize:(s.minWidth+s.maxWidth)/2;i.beginPath(),this._drawCurveSegment(e.x,e.y,r),i.closePath(),i.fillStyle=s.penColor,i.fill()}_fromData(e,s,i){for(const r of e){const{points:o}=r,l=this._getPointGroupOptions(r);if(o.length>1)for(let a=0;a<o.length;a+=1){const c=o[a],d=new Point(c.x,c.y,c.pressure,c.time);a===0&&this._reset(l);const u=this._addPoint(d,l);u&&s(u,l)}else this._reset(l),i(o[0],l)}}toSVG({includeBackgroundColor:e=!1}={}){const s=this._data,i=Math.max(window.devicePixelRatio||1,1),r=0,o=0,l=this.canvas.width/i,a=this.canvas.height/i,c=document.createElementNS("http://www.w3.org/2000/svg","svg");if(c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),c.setAttribute("viewBox",`${r} ${o} ${l} ${a}`),c.setAttribute("width",l.toString()),c.setAttribute("height",a.toString()),e&&this.backgroundColor){const d=document.createElement("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill",this.backgroundColor),c.appendChild(d)}return this._fromData(s,(d,{penColor:u})=>{const f=document.createElement("path");if(!isNaN(d.control1.x)&&!isNaN(d.control1.y)&&!isNaN(d.control2.x)&&!isNaN(d.control2.y)){const m=`M ${d.startPoint.x.toFixed(3)},${d.startPoint.y.toFixed(3)} C ${d.control1.x.toFixed(3)},${d.control1.y.toFixed(3)} ${d.control2.x.toFixed(3)},${d.control2.y.toFixed(3)} ${d.endPoint.x.toFixed(3)},${d.endPoint.y.toFixed(3)}`;f.setAttribute("d",m),f.setAttribute("stroke-width",(d.endWidth*2.25).toFixed(3)),f.setAttribute("stroke",u),f.setAttribute("fill","none"),f.setAttribute("stroke-linecap","round"),c.appendChild(f)}},(d,{penColor:u,dotSize:f,minWidth:m,maxWidth:p})=>{const g=document.createElement("circle"),x=f>0?f:(m+p)/2;g.setAttribute("r",x.toString()),g.setAttribute("cx",d.x.toString()),g.setAttribute("cy",d.y.toString()),g.setAttribute("fill",u),c.appendChild(g)}),c.outerHTML}};function throttle(n,e,s){var i=s||{},r=i.noTrailing,o=r===void 0?!1:r,l=i.noLeading,a=l===void 0?!1:l,c=i.debounceMode,d=c===void 0?void 0:c,u,f=!1,m=0;function p(){u&&clearTimeout(u)}function g(b){var w=b||{},v=w.upcomingOnly,E=v===void 0?!1:v;p(),f=!E}function x(){for(var b=arguments.length,w=new Array(b),v=0;v<b;v++)w[v]=arguments[v];var E=this,C=Date.now()-m;if(f)return;function k(){m=Date.now(),e.apply(E,w)}function R(){u=void 0}!a&&d&&!u&&k(),p(),d===void 0&&C>n?a?(m=Date.now(),o||(u=setTimeout(d?R:k,n))):k():o!==!0&&(u=setTimeout(d?R:k,d===void 0?n-C:n))}return x.cancel=g,x}function debounce(n,e,s){var i={},r=i.atBegin,o=r===void 0?!1:r;return throttle(n,e,{debounceMode:o!==!1})}const $=class $ extends React__namespace.PureComponent{constructor(e){super(e),this.canvasRef=React__namespace.createRef(),this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const e=this.canvasRef.current;e&&((!this.props.width||!this.props.height)&&(e.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(e,this.props.options),this.scaleCanvas(e))}componentWillUnmount(){(!this.props.width||!this.props.height)&&window.removeEventListener("resize",this.callResizeHandler),this.signaturePad.off()}get instance(){return this.signaturePad}get canvas(){return this.canvasRef}set dotSize(e){this.signaturePad.dotSize=e}get dotSize(){return this.signaturePad.dotSize}set minWidth(e){this.signaturePad.minWidth=e}get minWidth(){return this.signaturePad.minWidth}set maxWidth(e){this.signaturePad.maxWidth=e}get maxWidth(){return this.signaturePad.maxWidth}set throttle(e){this.signaturePad.throttle=e}get throttle(){return this.signaturePad.throttle}set backgroundColor(e){this.signaturePad.backgroundColor=e}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(e){this.signaturePad.penColor=e}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(e){this.signaturePad.velocityFilterWeight=e}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(e,s={}){this.signaturePad.fromDataURL(e,s)}toDataURL(e,s){return this.signaturePad.toDataURL(e,s)}toSVG(e){return this.signaturePad.toSVG(e)}fromData(e){this.signaturePad.fromData(e)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const e=this.canvasRef.current;e&&this.scaleCanvas(e)}scaleCanvas(e){const s=Math.max(window.devicePixelRatio||1,1),i=(this.props.width||e.offsetWidth)*s,r=(this.props.height||e.offsetHeight)*s,{canvasWidth:o,canvasHeight:l}=this.state;if(i===o&&r===l)return;let a;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(a=this.signaturePad.toDataURL()),e.width=i,e.height=r,this.setState({canvasWidth:i,canvasHeight:r});const c=e.getContext("2d");c&&c.scale(s,s),a?this.signaturePad.fromDataURL(a):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:e}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",S({"data-testid":"canvas-element",ref:this.canvasRef},e))}};$.displayName="react-signature-pad-wrapper",$.defaultProps={redrawOnResize:!1,debounceInterval:150};let SignaturePad=$;const SignatureInput=schema.connect(n=>{const{onChange:e,value:s}=n,i=React.useRef(null);React.useEffect(()=>{s&&i.current.fromDataURL(s)},[]);const r=()=>{i.current&&(i.current.clear(),e&&e(""))},o=()=>{if(i.current){const a=i.current.toDataURL();e&&e(a)}},l={pointerEvents:n.disabled?"none":"auto",opacity:n.disabled?.8:1};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:l,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SignaturePad,{ref:i,options:{penColor:"black",backgroundColor:"lightgrey"}}),!n.disabled&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:r,children:"清空"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:o,children:"确认"})]})]})},schema.mapProps((n,e)=>S({},n))),ErrorBoundaryContext=React.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends React.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var s,i,r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{args:o,reason:"imperative-api"}),this.setState(initialState)}}componentDidCatch(e,s){var i,r;(i=(r=this.props).onError)===null||i===void 0||i.call(r,e,s)}componentDidUpdate(e,s){const{didCatch:i}=this.state,{resetKeys:r}=this.props;if(i&&s.error!==null&&hasArrayChanged(e.resetKeys,r)){var o,l;(o=(l=this.props).onReset)===null||o===void 0||o.call(l,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(initialState)}}render(){const{children:e,fallbackRender:s,FallbackComponent:i,fallback:r}=this.props,{didCatch:o,error:l}=this.state;let a=e;if(o){const c={error:l,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")a=s(c);else if(i)a=React.createElement(i,c);else if(r!==void 0)a=r;else throw l}return React.createElement(ErrorBoundaryContext.Provider,{value:{didCatch:o,error:l,resetErrorBoundary:this.resetErrorBoundary}},a)}}function hasArrayChanged(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return n.length!==e.length||n.some((s,i)=>!Object.is(s,e[i]))}const ErrorBoundaryFallBack=()=>{const{t:n}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:n("Something went wrong. Please contact the developer to resolve the issue.")})},CustomAssociatedField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},useCustomComponent=n=>{const e=client.useApp();return _.filter(e.components,s=>s.__componentType===n).map(s=>({label:s.__componentLabel,value:s.displayName}))};var CustomComponentType=(n=>(n.CUSTOM_FORM_ITEM="FORM_ITEM",n.CUSTOM_FIELD="FIELD",n.CUSTOM_ASSOCIATED_FIELD="ASSOCIATED_FIELD",n))(CustomComponentType||{});const CustomComponentStub=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:"请选择组件"}),CustomComponentDispatcher=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"void",name:n.component,"x-component":n.component,"x-component-props":n}})})},customComponentDispatcherSettings=new client.SchemaSettings({name:"customComponentDispatcherSettings",items:[{name:"component",type:"select",useComponentProps(){var o;const n=useCustomComponent(CustomComponentType.CUSTOM_FORM_ITEM),{t:e}=useTranslation(),s=schema.useField(),i=schema.useFieldSchema(),{dn:r}=client.useDesignable();return{title:e("component"),value:((o=s.componentProps)==null?void 0:o.component)||"CustomComponentStub",options:[{label:"未选择组件",value:"CustomComponentStub"},...n],onChange(l){const a={"x-uid":i["x-uid"]};i["x-component-props"].component=l,i["x-acl-ignore"]=!0,a["x-component-props"]=i["x-component-props"],a["x-acl-ignore"]=!0,s.componentProps.component=l,r.emit("patch",{schema:a})}}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0}}]}),CustomField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},viewerSchema={type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}},useInsertSchema=n=>{const e=schema.useFieldSchema(),{insertAfterBegin:s}=client.useDesignable();return React.useCallback(r=>{e.reduceProperties((l,a)=>a["x-component"]==="AssociationField."+n?a:l,null)||s(_.cloneDeep(r))},[n])},AssociatedFieldImplement=schema.observer(n=>{var E,C,k;const{collection:e,fieldExp:s,dateFieldExp:i,sourceCollection:r,sourceField:o}=n,[l,a]=React.useState(!1),c=useInsertSchema("Viewer"),d=schema.useField(),u=schema.useForm(),f=schema.useFieldSchema(),{designable:m}=client.useDesignable(),p=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=i==null?void 0:i.replace(/{{(.*?)}}/,"$1"),{data:x,loading:b,run:w}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(E=u.values[p])==null?void 0:E.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var R;(R=u.values[p])!=null&&R.id&&u.values[g]&&w()},[(C=u.values[p])==null?void 0:C.id,u.values[g]]),b||!x)return null;if(!((k=x.data)!=null&&k[o+"_id"]))return u.setValues({[f.name]:null}),null;const v=x.data[o];return u.setValues({[f.name]:v}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:R=>{R.stopPropagation(),R.preventDefault(),m&&c(viewerSchema),a(!0)},children:v.name}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{name:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionContextProvider,{value:{visible:l,setVisible:a,openMode:"drawer",snapshot:!1},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RecordProvider,{record:v,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.FormProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(schema.RecursionField,{schema:f,onlyRenderProperties:!0,basePath:d.address,filterProperties:R=>R["x-component"]==="AssociationField.Viewer"})})})})})]})}),AssociatedField=schema.connect(AssociatedFieldImplement),transformFormula$1=n=>n?n.split(/([+\-*/?:()%])/).filter(s=>s):[],CalcResult=props=>{const form=schema.useForm(),fieldSchema=schema.useFieldSchema(),field=schema.useField(),{formula,prefix,suffix,decimal,panel}=props,path=field.path.entire,fieldPath=path==null?void 0:path.replace(`.${fieldSchema.name}`,""),engine=client$1.evaluators.get("math.js"),evaluate=engine.evaluate.bind(engine),defaultValue=fieldSchema.name==="subtotal"?"¥0.00":[],[value,setValue]=React.useState(defaultValue),transformFormulaArray=transformFormula$1(formula);let calculateData=[];const newFormulaArray=n=>{var i;calculateData=[];let e=0;const s={};if(transformFormulaArray.length!==0){for(let r=0;r<transformFormulaArray.length;r++){const o=transformFormulaArray[r];if(!o)continue;const l=!isNaN(Number(o)),a=["+","-","*","/","?",":","(",")","%"].includes(o);if(!l&&!a){let c;const d=/\${(.*?)}/g;if((i=o.match(d))!=null&&i.length){const m=o.match(d)[0].replace(/\${|}/g,""),p=o.split(".")[1];path===fieldPath?c=_.chain(n).get(m).get(p,0).value():c=_.chain(n).get(fieldPath).get(m).get(p,0).value()}else path===fieldPath?c=_.chain(n).get(o,0).value():c=_.chain(n).get(fieldPath).get(o,0).value();c||(c=0),e+=1;const u="var"+e,f=c;s[u]=f,calculateData.push("{{"+u+"}}")}else calculateData.push(o)}return[calculateData.join(""),s]}},fun=()=>T(this,null,function*(){if(!panel&&transformFormulaArray.length){const[n,e]=newFormulaArray(form.values);let s;try{const i=prefix||"",r=suffix||"",o=evaluate(n,e),l=isNaN(o)?o:Number(o).toFixed(decimal||0);s=i+l+r}catch(i){s=`${n}`,console.warn("code: ",n," scopes: ",e,"error: ",s," error message ",i.message)}setValue(s.toString())}else if(panel){let items=[],childrenType="";(yield import("react/jsx-runtime")).default,(yield import("dayjs")).default,childrenType="normal";try{eval(panel)}catch(n){items=[],items.push({key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+n})}const showItems=items.map(n=>({label:n.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:n.children})}));if(childrenType==="normal"){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:showItems});setValue(n)}else if(childrenType==="jsx"&&Array.isArray(items)){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:items.map(e=>e.children)});setValue(n)}}});return React.useEffect(()=>{fun()},[]),schema.useFormEffects(()=>{schema.onFormValuesChange(n=>{fun()})}),typeof value=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value}):value},Expression=n=>{var u;const{value:e="",useCurrentFields:s,onChange:i}=n,r=client.useCompile(),{interfaces:o,getCollectionFields:l}=client.useCollectionManager_deprecated(),a=(u=s==null?void 0:s())!=null?u:[],c=client.useAssociatedFields();console.log(c,"associatedFields",a);const d=a.map(f=>{var m,p;return{label:r(f.uiSchema.title),value:f.name,children:(p=(m=l(f.target))==null?void 0:m.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?p:[]}});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Variable.Input,{value:e,onChange:i,scope:d,changeOnSelect:!0})},ModalHeader=n=>{const{title:e,onOk:s,onCancel:i}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
22
+ */class Point{constructor(e,s,i,r){if(isNaN(e)||isNaN(s))throw new Error(`Point is invalid: (${e}, ${s})`);this.x=+e,this.y=+s,this.pressure=i||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class Bezier{static fromPoints(e,s){const i=this.calculateControlPoints(e[0],e[1],e[2]).c2,r=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new Bezier(e[1],i,r,e[2],s.start,s.end)}static calculateControlPoints(e,s,i){const r=e.x-s.x,o=e.y-s.y,l=s.x-i.x,a=s.y-i.y,c={x:(e.x+s.x)/2,y:(e.y+s.y)/2},d={x:(s.x+i.x)/2,y:(s.y+i.y)/2},u=Math.sqrt(r*r+o*o),f=Math.sqrt(l*l+a*a),p=c.x-d.x,m=c.y-d.y,g=f/(u+f),x={x:d.x+p*g,y:d.y+m*g},b=s.x-x.x,E=s.y-x.y;return{c1:new Point(c.x+b,c.y+E),c2:new Point(d.x+b,d.y+E)}}constructor(e,s,i,r,o,l){this.startPoint=e,this.control2=s,this.control1=i,this.endPoint=r,this.startWidth=o,this.endWidth=l}length(){let s=0,i,r;for(let o=0;o<=10;o+=1){const l=o/10,a=this.point(l,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),c=this.point(l,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){const d=a-i,u=c-r;s+=Math.sqrt(d*d+u*u)}i=a,r=c}return s}point(e,s,i,r,o){return s*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e}}class SignatureEventTarget{constructor(){try{this._et=new EventTarget}catch(e){this._et=document}}addEventListener(e,s,i){this._et.addEventListener(e,s,i)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,s,i){this._et.removeEventListener(e,s,i)}}function throttle$1(n,e=250){let s=0,i=null,r,o,l;const a=()=>{s=Date.now(),i=null,r=n.apply(o,l),i||(o=null,l=[])};return function(...d){const u=Date.now(),f=e-(u-s);return o=this,l=d,f<=0||f>e?(i&&(clearTimeout(i),i=null),s=u,r=n.apply(o,l),i||(o=null,l=[])):i||(i=window.setTimeout(a,f)),r}}let SignaturePad$1=class G extends SignatureEventTarget{constructor(e,s={}){super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this._handleMouseDown=i=>{i.buttons===1&&this._strokeBegin(i)},this._handleMouseMove=i=>{this._strokeMoveUpdate(i)},this._handleMouseUp=i=>{i.buttons===1&&this._strokeEnd(i)},this._handleTouchStart=i=>{if(i.cancelable&&i.preventDefault(),i.targetTouches.length===1){const r=i.changedTouches[0];this._strokeBegin(r)}},this._handleTouchMove=i=>{i.cancelable&&i.preventDefault();const r=i.targetTouches[0];this._strokeMoveUpdate(r)},this._handleTouchEnd=i=>{if(i.target===this.canvas){i.cancelable&&i.preventDefault();const o=i.changedTouches[0];this._strokeEnd(o)}},this._handlePointerStart=i=>{i.preventDefault(),this._strokeBegin(i)},this._handlePointerMove=i=>{this._strokeMoveUpdate(i)},this._handlePointerEnd=i=>{this._drawingStroke&&(i.preventDefault(),this._strokeEnd(i))},this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.dotSize=s.dotSize||0,this.penColor=s.penColor||"black",this.backgroundColor=s.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=s.compositeOperation||"source-over",this.canvasContextOptions="canvasContextOptions"in s?s.canvasContextOptions:{},this._strokeMoveUpdate=this.throttle?throttle$1(G.prototype._strokeUpdate,this.throttle):G.prototype._strokeUpdate,this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:s}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,s.width,s.height),e.fillRect(0,0,s.width,s.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0}fromDataURL(e,s={}){return new Promise((i,r)=>{const o=new Image,l=s.ratio||window.devicePixelRatio||1,a=s.width||this.canvas.width/l,c=s.height||this.canvas.height/l,d=s.xOffset||0,u=s.yOffset||0;this._reset(this._getPointGroupOptions()),o.onload=()=>{this._ctx.drawImage(o,d,u,a,c),i()},o.onerror=f=>{r(f)},o.crossOrigin="anonymous",o.src=e,this._isEmpty=!1})}toDataURL(e="image/png",s){switch(e){case"image/svg+xml":return typeof s!="object"&&(s=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(s))}`;default:return typeof s!="number"&&(s=void 0),this.canvas.toDataURL(e,s)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerStart),this.canvas.removeEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.removeEventListener("pointerup",this._handlePointerEnd),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.removeEventListener("mouseup",this._handleMouseUp),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this.canvas.removeEventListener("touchmove",this._handleTouchMove),this.canvas.removeEventListener("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:s=!0}={}){s&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;this._drawingStroke=!0;const i=this._getPointGroupOptions(),r=Object.assign(Object.assign({},i),{points:[]});this._data.push(r),this._reset(i),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const s=e.clientX,i=e.clientY,r=e.pressure!==void 0?e.pressure:e.force!==void 0?e.force:0,o=this._createPoint(s,i,r),l=this._data[this._data.length-1],a=l.points,c=a.length>0&&a[a.length-1],d=c?o.distanceTo(c)<=this.minDistance:!1,u=this._getPointGroupOptions(l);if(!c||!(c&&d)){const f=this._addPoint(o,u);c?f&&this._drawCurve(f,u):this._drawDot(o,u),a.push({time:o.time,x:o.x,y:o.y,pressure:o.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e){this._drawingStroke&&(this._strokeUpdate(e),this._drawingStroke=!1,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerStart),this.canvas.addEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.addEventListener("pointerup",this._handlePointerEnd)}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown),this.canvas.addEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.addEventListener("mouseup",this._handleMouseUp)}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart),this.canvas.addEventListener("touchmove",this._handleTouchMove),this.canvas.addEventListener("touchend",this._handleTouchEnd)}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,s,i){const r=this.canvas.getBoundingClientRect();return new Point(e-r.left,s-r.top,i,new Date().getTime())}_addPoint(e,s){const{_lastPoints:i}=this;if(i.push(e),i.length>2){i.length===3&&i.unshift(i[0]);const r=this._calculateCurveWidths(i[1],i[2],s),o=Bezier.fromPoints(i,r);return i.shift(),o}return null}_calculateCurveWidths(e,s,i){const r=i.velocityFilterWeight*s.velocityFrom(e)+(1-i.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(r,i),l={end:o,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=o,l}_strokeWidth(e,s){return Math.max(s.maxWidth/(e+1),s.minWidth)}_drawCurveSegment(e,s,i){const r=this._ctx;r.moveTo(e,s),r.arc(e,s,i,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,s){const i=this._ctx,r=e.endWidth-e.startWidth,o=Math.ceil(e.length())*2;i.beginPath(),i.fillStyle=s.penColor;for(let l=0;l<o;l+=1){const a=l/o,c=a*a,d=c*a,u=1-a,f=u*u,p=f*u;let m=p*e.startPoint.x;m+=3*f*a*e.control1.x,m+=3*u*c*e.control2.x,m+=d*e.endPoint.x;let g=p*e.startPoint.y;g+=3*f*a*e.control1.y,g+=3*u*c*e.control2.y,g+=d*e.endPoint.y;const x=Math.min(e.startWidth+d*r,s.maxWidth);this._drawCurveSegment(m,g,x)}i.closePath(),i.fill()}_drawDot(e,s){const i=this._ctx,r=s.dotSize>0?s.dotSize:(s.minWidth+s.maxWidth)/2;i.beginPath(),this._drawCurveSegment(e.x,e.y,r),i.closePath(),i.fillStyle=s.penColor,i.fill()}_fromData(e,s,i){for(const r of e){const{points:o}=r,l=this._getPointGroupOptions(r);if(o.length>1)for(let a=0;a<o.length;a+=1){const c=o[a],d=new Point(c.x,c.y,c.pressure,c.time);a===0&&this._reset(l);const u=this._addPoint(d,l);u&&s(u,l)}else this._reset(l),i(o[0],l)}}toSVG({includeBackgroundColor:e=!1}={}){const s=this._data,i=Math.max(window.devicePixelRatio||1,1),r=0,o=0,l=this.canvas.width/i,a=this.canvas.height/i,c=document.createElementNS("http://www.w3.org/2000/svg","svg");if(c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),c.setAttribute("viewBox",`${r} ${o} ${l} ${a}`),c.setAttribute("width",l.toString()),c.setAttribute("height",a.toString()),e&&this.backgroundColor){const d=document.createElement("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill",this.backgroundColor),c.appendChild(d)}return this._fromData(s,(d,{penColor:u})=>{const f=document.createElement("path");if(!isNaN(d.control1.x)&&!isNaN(d.control1.y)&&!isNaN(d.control2.x)&&!isNaN(d.control2.y)){const p=`M ${d.startPoint.x.toFixed(3)},${d.startPoint.y.toFixed(3)} C ${d.control1.x.toFixed(3)},${d.control1.y.toFixed(3)} ${d.control2.x.toFixed(3)},${d.control2.y.toFixed(3)} ${d.endPoint.x.toFixed(3)},${d.endPoint.y.toFixed(3)}`;f.setAttribute("d",p),f.setAttribute("stroke-width",(d.endWidth*2.25).toFixed(3)),f.setAttribute("stroke",u),f.setAttribute("fill","none"),f.setAttribute("stroke-linecap","round"),c.appendChild(f)}},(d,{penColor:u,dotSize:f,minWidth:p,maxWidth:m})=>{const g=document.createElement("circle"),x=f>0?f:(p+m)/2;g.setAttribute("r",x.toString()),g.setAttribute("cx",d.x.toString()),g.setAttribute("cy",d.y.toString()),g.setAttribute("fill",u),c.appendChild(g)}),c.outerHTML}};function throttle(n,e,s){var i=s||{},r=i.noTrailing,o=r===void 0?!1:r,l=i.noLeading,a=l===void 0?!1:l,c=i.debounceMode,d=c===void 0?void 0:c,u,f=!1,p=0;function m(){u&&clearTimeout(u)}function g(b){var E=b||{},v=E.upcomingOnly,w=v===void 0?!1:v;m(),f=!w}function x(){for(var b=arguments.length,E=new Array(b),v=0;v<b;v++)E[v]=arguments[v];var w=this,C=Date.now()-p;if(f)return;function A(){p=Date.now(),e.apply(w,E)}function R(){u=void 0}!a&&d&&!u&&A(),m(),d===void 0&&C>n?a?(p=Date.now(),o||(u=setTimeout(d?R:A,n))):A():o!==!0&&(u=setTimeout(d?R:A,d===void 0?n-C:n))}return x.cancel=g,x}function debounce(n,e,s){var i={},r=i.atBegin,o=r===void 0?!1:r;return throttle(n,e,{debounceMode:o!==!1})}const $=class $ extends React__namespace.PureComponent{constructor(e){super(e),this.canvasRef=React__namespace.createRef(),this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const e=this.canvasRef.current;e&&((!this.props.width||!this.props.height)&&(e.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(e,this.props.options),this.scaleCanvas(e))}componentWillUnmount(){(!this.props.width||!this.props.height)&&window.removeEventListener("resize",this.callResizeHandler),this.signaturePad.off()}get instance(){return this.signaturePad}get canvas(){return this.canvasRef}set dotSize(e){this.signaturePad.dotSize=e}get dotSize(){return this.signaturePad.dotSize}set minWidth(e){this.signaturePad.minWidth=e}get minWidth(){return this.signaturePad.minWidth}set maxWidth(e){this.signaturePad.maxWidth=e}get maxWidth(){return this.signaturePad.maxWidth}set throttle(e){this.signaturePad.throttle=e}get throttle(){return this.signaturePad.throttle}set backgroundColor(e){this.signaturePad.backgroundColor=e}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(e){this.signaturePad.penColor=e}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(e){this.signaturePad.velocityFilterWeight=e}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(e,s={}){this.signaturePad.fromDataURL(e,s)}toDataURL(e,s){return this.signaturePad.toDataURL(e,s)}toSVG(e){return this.signaturePad.toSVG(e)}fromData(e){this.signaturePad.fromData(e)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const e=this.canvasRef.current;e&&this.scaleCanvas(e)}scaleCanvas(e){const s=Math.max(window.devicePixelRatio||1,1),i=(this.props.width||e.offsetWidth)*s,r=(this.props.height||e.offsetHeight)*s,{canvasWidth:o,canvasHeight:l}=this.state;if(i===o&&r===l)return;let a;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(a=this.signaturePad.toDataURL()),e.width=i,e.height=r,this.setState({canvasWidth:i,canvasHeight:r});const c=e.getContext("2d");c&&c.scale(s,s),a?this.signaturePad.fromDataURL(a):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:e}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",D({"data-testid":"canvas-element",ref:this.canvasRef},e))}};$.displayName="react-signature-pad-wrapper",$.defaultProps={redrawOnResize:!1,debounceInterval:150};let SignaturePad=$;const SignatureInput=schema.connect(n=>{const{onChange:e,value:s}=n,i=React.useRef(null);React.useEffect(()=>{s&&i.current.fromDataURL(s)},[]);const r=()=>{i.current&&(i.current.clear(),e&&e(""))},o=()=>{if(i.current){const a=i.current.toDataURL();e&&e(a)}},l={pointerEvents:n.disabled?"none":"auto",opacity:n.disabled?.8:1};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:l,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SignaturePad,{ref:i,options:{penColor:"black",backgroundColor:"lightgrey"}}),!n.disabled&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:r,children:"清空"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:o,children:"确认"})]})]})},schema.mapProps((n,e)=>D({},n))),ErrorBoundaryContext=React.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends React.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var s,i,r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{args:o,reason:"imperative-api"}),this.setState(initialState)}}componentDidCatch(e,s){var i,r;(i=(r=this.props).onError)===null||i===void 0||i.call(r,e,s)}componentDidUpdate(e,s){const{didCatch:i}=this.state,{resetKeys:r}=this.props;if(i&&s.error!==null&&hasArrayChanged(e.resetKeys,r)){var o,l;(o=(l=this.props).onReset)===null||o===void 0||o.call(l,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(initialState)}}render(){const{children:e,fallbackRender:s,FallbackComponent:i,fallback:r}=this.props,{didCatch:o,error:l}=this.state;let a=e;if(o){const c={error:l,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")a=s(c);else if(i)a=React.createElement(i,c);else if(r!==void 0)a=r;else throw l}return React.createElement(ErrorBoundaryContext.Provider,{value:{didCatch:o,error:l,resetErrorBoundary:this.resetErrorBoundary}},a)}}function hasArrayChanged(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return n.length!==e.length||n.some((s,i)=>!Object.is(s,e[i]))}const ErrorBoundaryFallBack=()=>{const{t:n}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:n("Something went wrong. Please contact the developer to resolve the issue.")})},CustomAssociatedField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},useCustomComponent=n=>{const e=client.useApp();return _.filter(e.components,s=>s.__componentType===n).map(s=>({label:s.__componentLabel,value:s.displayName}))};var CustomComponentType=(n=>(n.CUSTOM_FORM_ITEM="FORM_ITEM",n.CUSTOM_FIELD="FIELD",n.CUSTOM_ASSOCIATED_FIELD="ASSOCIATED_FIELD",n))(CustomComponentType||{});const CustomComponentStub=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:"请选择组件"}),CustomComponentDispatcher=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"void",name:n.component,"x-component":n.component,"x-component-props":n}})})},customComponentDispatcherSettings=new client.SchemaSettings({name:"customComponentDispatcherSettings",items:[{name:"component",type:"select",useComponentProps(){var o;const n=useCustomComponent(CustomComponentType.CUSTOM_FORM_ITEM),{t:e}=useTranslation(),s=schema.useField(),i=schema.useFieldSchema(),{dn:r}=client.useDesignable();return{title:e("component"),value:((o=s.componentProps)==null?void 0:o.component)||"CustomComponentStub",options:[{label:"未选择组件",value:"CustomComponentStub"},...n],onChange(l){const a={"x-uid":i["x-uid"]};i["x-component-props"].component=l,i["x-acl-ignore"]=!0,a["x-component-props"]=i["x-component-props"],a["x-acl-ignore"]=!0,s.componentProps.component=l,r.emit("patch",{schema:a})}}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0}}]}),CustomField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},viewerSchema={type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}},useInsertSchema=n=>{const e=schema.useFieldSchema(),{insertAfterBegin:s}=client.useDesignable();return React.useCallback(r=>{e.reduceProperties((l,a)=>a["x-component"]==="AssociationField."+n?a:l,null)||s(_.cloneDeep(r))},[n])},AssociatedFieldImplement=schema.observer(n=>{var w,C,A;const{collection:e,fieldExp:s,dateFieldExp:i,sourceCollection:r,sourceField:o}=n,[l,a]=React.useState(!1),c=useInsertSchema("Viewer"),d=schema.useField(),u=schema.useForm(),f=schema.useFieldSchema(),{designable:p}=client.useDesignable(),m=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=i==null?void 0:i.replace(/{{(.*?)}}/,"$1"),{data:x,loading:b,run:E}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(w=u.values[m])==null?void 0:w.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var R;(R=u.values[m])!=null&&R.id&&u.values[g]&&E()},[(C=u.values[m])==null?void 0:C.id,u.values[g]]),b||!x)return null;if(!((A=x.data)!=null&&A[o+"_id"]))return u.setValues({[f.name]:null}),null;const v=x.data[o];return u.setValues({[f.name]:v}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:R=>{R.stopPropagation(),R.preventDefault(),p&&c(viewerSchema),a(!0)},children:v.name}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{name:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionContextProvider,{value:{visible:l,setVisible:a,openMode:"drawer",snapshot:!1},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RecordProvider,{record:v,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.FormProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(schema.RecursionField,{schema:f,onlyRenderProperties:!0,basePath:d.address,filterProperties:R=>R["x-component"]==="AssociationField.Viewer"})})})})})]})}),AssociatedField=schema.connect(AssociatedFieldImplement),transformFormula$1=n=>n?n.split(/([+\-*/?:()%])/).filter(s=>s):[],CalcResult=props=>{const form=schema.useForm(),fieldSchema=schema.useFieldSchema(),field=schema.useField(),{formula,prefix,suffix,decimal,panel}=props,path=field.path.entire,fieldPath=path==null?void 0:path.replace(`.${fieldSchema.name}`,""),engine=client$1.evaluators.get("math.js"),evaluate=engine.evaluate.bind(engine),defaultValue=fieldSchema.name==="subtotal"?"¥0.00":[],[value,setValue]=React.useState(defaultValue),transformFormulaArray=transformFormula$1(formula);let calculateData=[];const newFormulaArray=n=>{var i;calculateData=[];let e=0;const s={};if(transformFormulaArray.length!==0){for(let r=0;r<transformFormulaArray.length;r++){const o=transformFormulaArray[r];if(!o)continue;const l=!isNaN(Number(o)),a=["+","-","*","/","?",":","(",")","%"].includes(o);if(!l&&!a){let c;const d=/\${(.*?)}/g;if((i=o.match(d))!=null&&i.length){const p=o.match(d)[0].replace(/\${|}/g,""),m=o.split(".")[1];path===fieldPath?c=_.chain(n).get(p).get(m,0).value():c=_.chain(n).get(fieldPath).get(p).get(m,0).value()}else path===fieldPath?c=_.chain(n).get(o,0).value():c=_.chain(n).get(fieldPath).get(o,0).value();c||(c=0),e+=1;const u="var"+e,f=c;s[u]=f,calculateData.push("{{"+u+"}}")}else calculateData.push(o)}return[calculateData.join(""),s]}},fun=()=>T(this,null,function*(){if(!panel&&transformFormulaArray.length){const[n,e]=newFormulaArray(form.values);let s;try{const i=prefix||"",r=suffix||"",o=evaluate(n,e),l=isNaN(o)?o:Number(o).toFixed(decimal||0);s=i+l+r}catch(i){s=`${n}`,console.warn("code: ",n," scopes: ",e,"error: ",s," error message ",i.message)}setValue(s.toString())}else if(panel){let items=[],childrenType="";(yield import("react/jsx-runtime")).default,(yield import("dayjs")).default,childrenType="normal";try{eval(panel)}catch(n){items=[],items.push({key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+n})}const showItems=items.map(n=>({label:n.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:n.children})}));if(childrenType==="normal"){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:showItems});setValue(n)}else if(childrenType==="jsx"&&Array.isArray(items)){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:items.map(e=>e.children)});setValue(n)}}});return React.useEffect(()=>{fun()},[]),schema.useFormEffects(()=>{schema.onFormValuesChange(n=>{fun()})}),typeof value=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value}):value},Expression=n=>{var u;const{value:e="",useCurrentFields:s,onChange:i}=n,r=client.useCompile(),{interfaces:o,getCollectionFields:l}=client.useCollectionManager_deprecated(),a=(u=s==null?void 0:s())!=null?u:[],c=client.useAssociatedFields();console.log(c,"associatedFields",a);const d=a.map(f=>{var p,m;return{label:r(f.uiSchema.title),value:f.name,children:(m=(p=l(f.target))==null?void 0:p.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?m:[]}});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Variable.Input,{value:e,onChange:i,scope:d,changeOnSelect:!0})},ModalHeader=n=>{const{title:e,onOk:s,onCancel:i}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
23
23
  display: flex;
24
24
  flex-direction: row;
25
25
  justify-content: space-between;
@@ -49,7 +49,7 @@
49
49
  z-index: 1000;
50
50
  display: ${i?"flex":"none"};
51
51
  flex-direction: column;
52
- `,e),children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalHeader,{title:s,onOk:o,onCancel:l}),r]}),document.body):null};ModalFullScreen.displayName="ModalFullScreen";const ExcelFileComponent=n=>{const{title:e,disabled:s,value:i,onChange:r}=n,o=React.useRef(),[l,a]=React.useState(!1),c=()=>{a(!0)},d=()=>{a(!1)},u=()=>{const f=o.current.getData();r(f),a(!1)};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:c,children:s?"查看":"编辑"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalFullScreen,{title:e!=null?e:"Excel",open:l,onOk:u,onCancel:d,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:o,data:i||[]})})]})},ExcelFile=schema.connect(ExcelFileComponent,schema.mapProps(n=>S({},n))),GroupBlockContext=React.createContext({}),GroupSvg=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("svg",{viewBox:"0 0 1024 1024",width:"1em",height:"1em",fill:"currentColor",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("path",{d:"M833.179846 36.584242h-73.160824a36.516572 36.516572 0 0 0 0 73.160824h73.160824c20.173491 0 36.516572 16.343081 36.516572 36.580412v768.060967a36.580412 36.580412 0 0 1-36.516572 36.580412H174.860114a36.580412 36.580412 0 0 1-36.580412-36.580412V146.325478c0-20.173491 16.343081-36.580412 36.580412-36.580412h73.160824a36.516572 36.516572 0 1 0 0-73.160824H174.860114A109.805076 109.805076 0 0 0 65.118879 146.325478v768.060967c0 60.584312 49.156923 109.741235 109.741235 109.741235h658.383572a109.805076 109.805076 0 0 0 109.677395-109.741235V146.325478A109.805076 109.805076 0 0 0 833.179846 36.584242z",fill:"#2C2C2C"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("path",{d:"M357.826013 146.325478h292.451774a36.516572 36.516572 0 0 0 36.580412-36.580412V36.584242A36.516572 36.516572 0 0 0 650.277787 0.00383H357.826013a36.516572 36.516572 0 0 0-36.580412 36.580412v73.160824c0 20.173491 16.343081 36.580412 36.580412 36.580412z m-36.708092 622.888443a36.580412 36.580412 0 0 0 36.580412-36.580412V512.065755a36.516572 36.516572 0 1 0-73.096984 0v220.567754c0 20.173491 16.279241 36.580412 36.516572 36.580412z m146.321647-330.308989v293.728577a36.580412 36.580412 0 1 0 73.160824 0V438.904932a36.580412 36.580412 0 1 0-73.160824 0z m182.838219-146.321647v440.050224a36.644252 36.644252 0 0 0 73.160824 0V292.583285a36.644252 36.644252 0 0 0-73.160824 0z",fill:"#2C2C2C"})]}),GroupIcon=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Icon,S({type:"",component:GroupSvg},n)),InternalGroupBlockProvider=n=>{const e=schema.useField(),{resource:s,service:i}=client.useBlockRequestContext(),[r,o]=React.useState(!1);return i.loading&&!e.loaded?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{}):(e.loaded=!0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(GroupBlockContext.Provider,{value:{props:{resource:n.resource},field:e,service:i,resource:s,visible:r,setVisible:o},children:n.children}))},GroupBlockProvider=n=>{const e=S({},n.params);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.BlockProvider,F(S({name:"group"},n),{params:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalGroupBlockProvider,F(S({},n),{params:e}))}))},createGroupBlockSchema=n=>{const{collection:e,groupField:s}=n,i=[];e==null||e.fields.forEach(o=>{(o.interface==="number"||o.interface==="formula"&&o.dataType==="double")&&i.push({label:o.uiSchema.title,field:[o.name],aggregation:"sum",display:!0})});const r={title:e.title,type:"void","x-acl-action":`${e.name}:list`,"x-decorator":"GroupBlockProvider","x-decorator-props":{collection:e.name,resource_deprecated:"charts",action:"query",groupField:s,params:{collection:e.name,measures:i}},"x-toolbar":"GroupBlockToolbar","x-settings":"groupBlockSettings","x-component":"CardItem",properties:{[client$2.uid()]:{type:"void","x-component":"GroupBlock"}}};return i.length||delete r["x-decorator-props"].resource_deprecated,e.template==="view"&&!i.length&&(delete r["x-decorator-props"].action,delete r["x-decorator-props"].groupField),r},GroupBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useCollectionManager(),s=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,F(S({},s),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(GroupIcon,{}),onCreateBlockSchema:r=>T(this,[r],function*({item:i}){const o=e.getCollection(i.name);n(createGroupBlockSchema({collection:o}))})}))},groupBlockSettings=new client.SchemaSettings({name:"groupBlockSettings",items:[{name:"Configure",Component:"GroupBlockConfigure"},{name:"remove",type:"remove"}]}),GroupBlockToolbar=n=>{const e=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaToolbar,S({title:e.title,settings:e["x-settings"]},n))},GroupBlockConfigure=schema.connect(n=>{var f;const{t:e}=useTranslation(),s=schema.useFieldSchema(),{dn:i}=client.useDesignable(),{service:r}=client.useBlockRequestContext(),o=(f=s["x-decorator-props"])==null?void 0:f.params,l=o==null?void 0:o.measures,a=transformers.option.filter(m=>m.value==="decimal")[0].childrens,c=l.map(m=>({label:m.label,value:m.field[0]})),{scope:d}=React.useContext(GroupBlockContext),u=modalSchema(e,o,c,a);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:S({},d),components:{ArrayItems:components$1.ArrayItems,FormItem:components$1.FormItem,Space:components$1.Space,PullRequestOutlined:icons.PullRequestOutlined},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:e("Configure"),onSubmit:m=>{s["x-decorator-props"].params.config=[...m.configField],i.emit("patch",{schema:{"x-uid":s["x-uid"],"x-decorator-props":s["x-decorator-props"]}}),i.refresh(),r==null||r.refresh()},schema:u},"configure")})}),fieldType=[{label:"字段配置",value:"field"},{label:"请求配置",value:"custom"}],styleOption=[{label:"描述",value:"describe"},{label:"表格",value:"table"}],modalSchema=(n,e,s,i)=>({title:n("Configure Group"),type:"object",properties:{configField:{title:"Config Field",type:"array","x-decorator":"FormItem","x-component":"ArrayItems",default:e.config,items:{type:"object","x-decorator":"ArrayItems.Item",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},type:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("type")}}'},enum:fieldType,required:!0},field:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("field")}}'},"x-visbile":!1,required:!1,enum:s,"x-reactions":{dependencies:[".type"],fulfill:{schema:{required:"{{$deps[0]==='field'}}","x-visible":"{{$deps[0]==='field'}}"}}}},reqUrl:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("reqUrl")}}',addonBefore:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PullRequestOutlined,{})},required:!1,"x-visible":!1,"x-reactions":{dependencies:[".type"],fulfill:{schema:{required:"{{$deps[0]==='custom'}}","x-visible":"{{$deps[0]==='custom'}}"}}}},format:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("format")}}'},enum:transformers.option,required:!0},digits:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("digits")}}'},enum:i,"x-visible":!1,"x-reactions":{dependencies:[".format"],fulfill:{schema:{"x-visible":"{{$deps[0]==='decimal'}}"}}}},style:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("style")}}'},enum:styleOption,required:!0},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:"Add","x-component":"ArrayItems.Addition"}}}}}),CurrencyFormat=(n,e="en-US",s=!1)=>{const i={"zh-CN":"CNY","en-US":"USD","ja-JP":"JPY","ko-KR":"KRW","pt-BR":"BRL","ru-RU":"RUB","tr-TR":"TRY","es-ES":"EUR"}[e];return s&&n&&(n=-n),new Intl.NumberFormat(e,{style:"currency",currency:i}).format(n)},transformers={option:[{label:"Percent",value:"pertent",component:(n,e="en-US")=>new Intl.NumberFormat(e,{style:"percent",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},{label:"Currency",value:"currency",component:CurrencyFormat},{label:"CurrencyNegative",value:"currencyNegative",component:(n,e="en-US")=>CurrencyFormat(n,e,!0)},{label:"Exponential",value:"exponential",component:n=>(+n).toExponential()},{label:"Abbreviation",value:"abbreviation",component:(n,e="en-US")=>new Intl.NumberFormat(e,{notation:"compact"}).format(n)},{label:"Decimal",value:"decimal",childrens:[{label:"1.0",value:"OneDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:1,maximumFractionDigits:1}).format(n)},{label:"1.00",value:"TwoDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},{label:"1.000",value:"ThreeDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:3,maximumFractionDigits:3}).format(n)},{label:"1.0000",value:"FourDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:4,maximumFractionDigits:4}).format(n)},{label:"1.00000",value:"FiveDigits",component:n=>new Intl.NumberFormat("en-US",{style:"decimal",minimumFractionDigits:5,maximumFractionDigits:5}).format(n)}]}]},GroupBlock=n=>{const e=schema.useField(),i=schema.useFieldSchema().parent["x-decorator-props"].params,{service:r}=client.useBlockRequestContext(),{getDataBlocks:o}=client.useFilterBlock();if(r.params.length||o().map(l=>{Object.keys(l.defaultFilter).length&&o().forEach(a=>{a.uid!==l.uid&&a.collection.name===l.collection.name&&(r.params=l.defaultFilter)})}),r.loading&&!e.loaded)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{});if(!(!(i!=null&&i.config)||!("map"in i.config)))return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{style:{fontWeight:600},children:"汇总:"}),i==null?void 0:i.config.map((l,a)=>{if(l)return React.createElement(InternalGroupBlock,F(S({},n),{configItem:l,service:r,key:a}))})]})},fieldTransformers=(n,e,s)=>{const{option:i}=transformers,r=s.auth.getLocale();if(n){const o=n.format,l=n==null?void 0:n.digits;if(o&&o!=="decimal"){const a=i.find(c=>c.value===o).component;return e=String(e).includes(",")?String(e).replace(/,/g,""):e,a(e,r)}else if(o&&o==="decimal"&&l){const a=i.filter(c=>c.value==="decimal")[0].childrens.filter(c=>c.value===l)[0].component;return e=String(e).includes(",")?String(e).replace(/,/g,""):e,a(e)}}},InternalGroupBlock=n=>{const{configItem:e,service:s}=n,r=schema.useFieldSchema().parent["x-decorator-props"].params,[o,l]=React.useState({}),a=client.useAPIClient();if(ahooks.useAsyncEffect(()=>T(this,null,function*(){var d;const c=s!=null&&s.params[0]?s.params[0].filter:s==null?void 0:s.params;e.reqUrl&&l((d=yield a.request({url:e.reqUrl,method:"POST",data:{filter:S({},c),collection:r.collection}}))!=null?d:{})}),[s.params,s.params[0]]),e.style==="describe"){const c=describeItem(e,o,s,r,a);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{style:{marginBottom:"10px"},items:c})}else if(e.style==="table"){const{columns:c,options:d}=tableItem(e,o,s,r,a);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{style:{marginBottom:"10px"},columns:c,dataSource:d,pagination:!1})}},describeItem=(n,e,s,i,r)=>{var l,a,c;const o=[];if(n.type==="field"){const d=(l=s.data)==null?void 0:l.data;if(d){let u=d.map(m=>m[n.field])[0];u=fieldTransformers(n,u,r);const f=i.measures.find(m=>m.field[0]===n.field).label;o.push({key:n.field,label:f,children:u})}}else if(n.type==="custom"&&Object.keys(e).length&&(a=e==null?void 0:e.data)!=null&&a.data){const d=S({},(c=e==null?void 0:e.data)==null?void 0:c.data),u=d.labels;d.values.forEach((f,m)=>{let p="";u.forEach((g,x)=>{x!==0&&(p+=`${g}${fieldTransformers(n,f[x],r)} `)}),o.push({key:m,label:f[0],children:p})})}return o},tableItem=(n,e,s,i,r)=>{var a,c,d;const o=[],l=[];if(n.type==="custom"){if(Object.keys(e).length&&((a=e==null?void 0:e.data)!=null&&a.data)){const u=S({},(c=e==null?void 0:e.data)==null?void 0:c.data);u.labels.forEach((f,m)=>{o.push({title:f,dataIndex:"value"+m,key:m})}),u.values.forEach((f,m)=>{const p={key:m};o.forEach((g,x)=>{const b=typeof f[x]=="string"?f[x]:fieldTransformers(n,f[x],r);p[g.dataIndex]=b}),l.push(p)})}}else if(n.type==="field"){const u=(d=s.data)==null?void 0:d.data;if(u){let f=u.map(p=>p[n.field])[0];f=fieldTransformers(n,f,r);const m=i.measures.find(p=>p.field[0]===n.field).label;o.push({title:"名称",dataIndex:"name",key:"name"},{title:"数量",dataIndex:"number",key:"number"}),l.push({key:m,name:m,number:f})}}return{columns:o,options:l}};class PluginGroupBlock extends client.Plugin{load(){return T(this,null,function*(){this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.groupBlock",{title:tval("Group"),Component:"GroupBlockInitializer"}),this.schemaSettingsManager.add(groupBlockSettings),this.app.addComponents({GroupBlock,GroupBlockConfigure,GroupBlockInitializer,GroupBlockProvider,GroupBlockToolbar})})}}const SchemaSettingsAppends=()=>{const n=schema.useFieldSchema(),{fieldSchema:e}=client.useColumnSchema(),s=e!=null?e:n,{t:i}=useTranslation(),r=client.useCollection(),{dn:o}=client.useDesignable();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:"设置加载关联字段",scope:{fieldFilter(l){return["belongsTo","hasOne"].includes(l.type)}},schema:{type:"object",title:"设置加载关联字段",properties:{appends:{default:_.get(s,"x-component-props.appends",[]),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{placeholder:i("Select context"),popupMatchSelectWidth:!1,collection:`${r.dataSource&&r.dataSource!=="main"?`${r.dataSource}:`:""}${r.name}`,multiple:!0,allowClear:!1}}}},onSubmit:({appends:l})=>{_.set(s["x-component-props"],"appends",l!=null?l:[]),o.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]}}),o.refresh()}},"appends")},customFieldComponentFieldSettings=new client.SchemaSettings({name:"fieldSettings:component:CustomField",items:[{name:"appends",Component:SchemaSettingsAppends}]});class PluginCustomComponents extends client.Plugin{load(){return T(this,null,function*(){this.schemaSettingsManager.add(customFieldComponentFieldSettings)})}}const EmbedLayout=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout,{style:{height:"100%"},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout.Content,{className:client.css`
52
+ `,e),children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalHeader,{title:s,onOk:o,onCancel:l}),r]}),document.body):null};ModalFullScreen.displayName="ModalFullScreen";const ExcelFileComponent=n=>{const{title:e,disabled:s,value:i,onChange:r}=n,o=React.useRef(),[l,a]=React.useState(!1),c=()=>{a(!0)},d=()=>{a(!1)},u=()=>{const f=o.current.getData();r(f),a(!1)};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:c,children:s?"查看":"编辑"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ModalFullScreen,{title:e!=null?e:"Excel",open:l,onOk:u,onCancel:d,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:o,data:i||[]})})]})},ExcelFile=schema.connect(ExcelFileComponent,schema.mapProps(n=>D({},n))),SchemaSettingsAppends=()=>{const n=schema.useFieldSchema(),{fieldSchema:e}=client.useColumnSchema(),s=e!=null?e:n,{t:i}=useTranslation(),r=client.useCollection(),{dn:o}=client.useDesignable();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:"设置加载关联字段",scope:{fieldFilter(l){return["belongsTo","hasOne"].includes(l.type)}},schema:{type:"object",title:"设置加载关联字段",properties:{appends:{default:_.get(s,"x-component-props.appends",[]),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{placeholder:i("Select context"),popupMatchSelectWidth:!1,collection:`${r.dataSource&&r.dataSource!=="main"?`${r.dataSource}:`:""}${r.name}`,multiple:!0,allowClear:!1}}}},onSubmit:({appends:l})=>{_.set(s["x-component-props"],"appends",l!=null?l:[]),o.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]}}),o.refresh()}},"appends")},customFieldComponentFieldSettings=new client.SchemaSettings({name:"fieldSettings:component:CustomField",items:[{name:"appends",Component:SchemaSettingsAppends}]});class PluginCustomComponents extends client.Plugin{load(){return T(this,null,function*(){this.schemaSettingsManager.add(customFieldComponentFieldSettings)})}}const EmbedLayout=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout,{style:{height:"100%"},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Layout.Content,{className:client.css`
53
53
  display: flex;
54
54
  flex-direction: column;
55
55
  position: relative;
@@ -65,7 +65,7 @@
65
65
  z-index: 0;
66
66
  padding: 0px 50px;
67
67
  }
68
- `,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(reactRouterDom.Outlet,{})})});function NotAuthorityResult(){return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Result,{status:"403",title:"403",subTitle:"Sorry, you are not authorized to access this page."})}function useEmbedToken(){const n=new URL(window.location.href),e=client.useAPIClient(),s=n.searchParams.get("token");return s&&e.auth.setToken(s),e.auth.getToken()}const EmbedPage=()=>{const n=useEmbedToken(),e=reactRouterDom.useNavigate(),s=reactRouterDom.useLocation(),i=reactRouterDom.useMatch("/embed/:name");return React.useEffect(()=>()=>{setTimeout(()=>{i&&setTimeout(()=>{window.location.pathname!==s.pathname&&e("/embed/not-authorized")})})},[]),!n||s.pathname==="/embed/not-authorized"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(NotAuthorityResult,{}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(EmbedLayout,{})})};function EmbedSchemaComponent(){const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.name})}function usePageSettingsProps(){const n=reactRouterDom.useMatch("/admin/:name"),e=reactRouterDom.useMatch("/embed/:name"),s=n||e,i=schema.useFieldSchema(),{message:r,notification:o}=antd.App.useApp(),{t:l}=useTranslation();return{title:l("Copy embedded link"),onClick:()=>{const a=window.location.href.replace("/admin","/embed").replace(s.params.name,i["x-uid"]).replace(window.location.search||"","");navigator.clipboard.writeText(a).then(()=>{r.success(l("Copy successful"))}).catch(c=>{o.error({message:l("Copy Failed"),description:c.message,placement:"topRight"})})}}}const keyEmbed="embed",pathEmbed=`/${keyEmbed}`;class EmbedPlugin extends client.Plugin{load(){return T(this,null,function*(){this.router.add(keyEmbed,{path:pathEmbed,Component:EmbedPage}),this.router.add(`${keyEmbed}.page`,{path:`${pathEmbed}/:name`,Component:EmbedSchemaComponent}),this.router.add(`${keyEmbed}.notAuthorized`,{path:`${pathEmbed}/not-authorized`,element:null}),this.schemaSettingsManager.addItem("PageSettings",keyEmbed,{type:"item",useComponentProps:usePageSettingsProps})})}}const{defaultProps:defaultProps$3}=client.interfacesProperties;class ShowFieldCodeInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="codeShow",this.type="object",this.group="advanced",this.title="jsCode(显示)",this.description="通过jsCode, 用于定制化显示用户界面内容.可使用的变量:scopes:{ form, path, recordData, result, setResult, formatFunc, dayjs}; handlers: { setResult, formatFunc }; modules: { dayjs }",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"ViewCode","x-component-props":{jsCode:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=F(S({},defaultProps$3),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.jsCode":{type:"string",title:"JSCode","x-decorator":"FormItem","x-component":"CodeMirror",default:"",required:!0}})}}const ViewCode=n=>{const e=useAction$1(n);return typeof e=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue$1,{value:e}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:e})},ShowValue$1=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction$1(n){var x,b,w,v;const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{jsCode:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),[f,m]=React.useState({items:[],childrenType:""}),p=E=>{let C=E;return typeof E=="number"&&(C=isNaN(E)?E:Number(E).toFixed(+a||0)),`${o}${C}${l}`};React.useEffect(()=>{dynamicCode({jsCode:r,form:e,path:c,recordData:u,result:f},{setResult:m,formatFunc:p})},[]);const g=(x=f==null?void 0:f.items)==null?void 0:x.map(E=>({label:E.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:E.children})}));return f.childrenType==="normal"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:g}):f.childrenType==="jsx"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:(b=f==null?void 0:f.items)==null?void 0:b.map(E=>E.children)}):(v=(w=f.items)==null?void 0:w[0])==null?void 0:v.children}function dynamicCode(a,c){return T(this,arguments,function*({jsCode:n,form:e,path:s,recordData:i,result:r},{setResult:o,formatFunc:l}){try{const d={data:{form:e,path:s,recordData:i,result:r,setResult:o,formatFunc:l},body:{}};yield evalSimulate(n,{ctx:d,lib:{log:console.log,JSON,dayjs}}),o(d.body)}catch(d){o({childrenType:"",items:[{key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+d}]})}})}function evalSimulate(i,r){return T(this,arguments,function*(n,{ctx:e,lib:s}){const o=(function(){return T(this,null,function*(){})}).constructor;try{return yield new o("$root",`with($root) { ${n}; }`)({ctx:e,lib:s})}catch(l){console.log("err",l)}})}const{defaultProps:defaultProps$2}=client.interfacesProperties;class ShowFieldFormulaInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="formulaShow",this.type="object",this.group="advanced",this.title="公式(显示)",this.description="通过公式, 用于定制化显示用户界面内容",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"Viewformula","x-component-props":{formulaString:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=F(S({},defaultProps$2),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.formulaString":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0}})}}const ViewFormula=n=>{const{resultShowValue:e}=useAction(n);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue,{value:e})},ShowValue=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction(n){const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{formulaString:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),f=transformFormula(r),m=getEvaluateArray(f,u);return m?{resultShowValue:getResultShowValue(m,{prefix:o,suffix:l,decimal:a})}:{resultShowValue:""}}function transformFormula(n){return n?n.split(/([+\-*/?:()%])/).filter(s=>s):[]}function getEvaluateArray(n,e){var o;if(n.length<1)return;let s=0;const i=[],r={};for(let l=0;l<n.length;l++){const a=n[l];if(!a)continue;const c=isNumberFunc(a),d=isSymbolFunc(a);if(!c&&!d){let u;const f=/\${(.*?)}/g;if((o=a.match(f))!=null&&o.length){const g=a.match(f)[0].replace(/\${|}/g,""),x=a.split(".")[1],b=_.chain(e).get(g).value();u=_.chain(b).get(x,0).value()}else u=_.chain(e).get(a,0).value();const m=`var${s++}`,p=u!=null?u:0;i.push(`{{${m}}}`),r[m]=p}else i.push(a)}return[i.join(""),r]}function getResultShowValue(n,{prefix:e,suffix:s,decimal:i}){const r=client$1.evaluators.get("math.js"),o=r.evaluate.bind(r),[l,a]=n;let c;try{const d=o(l,a),u=isNaN(d)?d:Number(d).toFixed(+i||0);c=`${e}${u}${s}`}catch(d){c=`${l}`,console.warn("code: ",l," scopes: ",a,"error: ",c," error message ",d.message)}return c}function isNumberFunc(n){return typeof n=="number"&&!isNaN(n)}function isSymbolFunc(n){return["+","-","*","/","?",":","(",")","%"].includes(n)}class PluginFieldAppends extends client.Plugin{load(){return T(this,null,function*(){this.app.addComponents({Viewformula:ViewFormula,ViewCode}),this.app.dataSourceManager.addFieldInterfaces([ShowFieldFormulaInterface,ShowFieldCodeInterface])})}}const usePluginVersion=()=>{var e,s;const{data:n}=client.useRequest({url:"hera:version"});return(s=(e=n==null?void 0:n.data)==null?void 0:e.packageJson)==null?void 0:s.version},useHeraVersion=()=>{const n=usePluginVersion();return{key:"hera-version",eventKey:"hera-version",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:["赫拉系统 - ",n]})}},HeraVersionProvider=({children:n})=>{const{addMenuItem:e}=client.useCurrentUserSettingsMenu(),s=useHeraVersion();return React.useEffect(()=>{e(s,{before:"divider_1"})},[e,s]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:n})};class PluginHeraVersion extends client.Plugin{load(){return T(this,null,function*(){this.app.use(HeraVersionProvider)})}}const OutboundLinkActionInitializer=n=>{const e={title:tval("outbound"),"x-action":"outbound","x-component":"OutboundButton","x-designer":"Action.Designer","x-component-props":{icon:"ShareAltOutlined",useProps:"{{ useOutboundActionProps }}"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,F(S({},n),{schema:e}))};OutboundLinkActionInitializer.displayName="OutboundLinkActionInitializer";const OutboundButton=n=>{const{onClick:e}=client.useProps(n),s=schema.useFieldSchema(),i=window.location.href.split("/",3).join("/"),{t:r}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Popover,{placement:"bottomRight",trigger:"click",autoAdjustOverflow:!0,content:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space.Compact,{style:{width:"100%"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{defaultValue:`${i}/r/${s["x-uid"]}`}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:e,children:r("Copy link")})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Button,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.ShareAltOutlined,{}),r("Outbound")]})})};OutboundButton.displayName="OutboundButton";const OutboundPage=()=>{const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteCollectionManagerProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.id})})})};var toggleSelection=function(){var n=document.getSelection();if(!n.rangeCount)return function(){};for(var e=document.activeElement,s=[],i=0;i<n.rangeCount;i++)s.push(n.getRangeAt(i));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return n.removeAllRanges(),function(){n.type==="Caret"&&n.removeAllRanges(),n.rangeCount||s.forEach(function(r){n.addRange(r)}),e&&e.focus()}},deselectCurrent=toggleSelection,clipboardToIE11Formatting={"text/plain":"Text","text/html":"Url",default:"Text"},defaultMessage="Copy to clipboard: #{key}, Enter";function format(n){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return n.replace(/#{\s*key\s*}/g,e)}function copy(n,e){var s,i,r,o,l,a,c=!1;e||(e={}),s=e.debug||!1;try{r=deselectCurrent(),o=document.createRange(),l=document.getSelection(),a=document.createElement("span"),a.textContent=n,a.ariaHidden="true",a.style.all="unset",a.style.position="fixed",a.style.top=0,a.style.clip="rect(0, 0, 0, 0)",a.style.whiteSpace="pre",a.style.webkitUserSelect="text",a.style.MozUserSelect="text",a.style.msUserSelect="text",a.style.userSelect="text",a.addEventListener("copy",function(u){if(u.stopPropagation(),e.format)if(u.preventDefault(),typeof u.clipboardData=="undefined"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var f=clipboardToIE11Formatting[e.format]||clipboardToIE11Formatting.default;window.clipboardData.setData(f,n)}else u.clipboardData.clearData(),u.clipboardData.setData(e.format,n);e.onCopy&&(u.preventDefault(),e.onCopy(u.clipboardData))}),document.body.appendChild(a),o.selectNodeContents(a),l.addRange(o);var d=document.execCommand("copy");if(!d)throw new Error("copy command was unsuccessful");c=!0}catch(u){s&&console.error("unable to copy using execCommand: ",u),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",n),e.onCopy&&e.onCopy(window.clipboardData),c=!0}catch(f){s&&console.error("unable to copy using clipboardData: ",f),s&&console.error("falling back to prompt"),i=format("message"in e?e.message:defaultMessage),window.prompt(i,n)}}finally{l&&(typeof l.removeRange=="function"?l.removeRange(o):l.removeAllRanges()),a&&document.body.removeChild(a),r()}return c}var copyToClipboard=copy;const copy$1=getDefaultExportFromCjs(copyToClipboard),useOutboundActionProps=()=>{let n=schema.useFieldSchema();const{t:e}=useTranslation();for(;!("x-decorator-props"in n);)n=n.parent;const s=window.location.href.split("/",3).join("/");return{onClick(){return T(this,null,function*(){copy$1(`${s}/r/${n["x-uid"]}`)?antd.message.success(e("Save link successful")):antd.message.success(e("Save link failed"))})}}};class PluginOutbound extends client.Plugin{load(){return T(this,null,function*(){this.app.router.add("outbound",{path:"/r/:id",Component:OutboundPage}),this.app.addScopes({useOutboundActionProps}),this.app.addComponents({OutboundButton,OutboundLinkActionInitializer});const e={type:"item",name:"enableActions.outbound",title:lang("outbound"),Component:"OutboundLinkActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("table:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("details:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("pdfViewer:configureActions",e.name,e)})}}const PDFViewerContext=React.createContext(null),usePDFViewerRef=()=>React.useContext(PDFViewerContext),PDFViewerProvider=n=>{const e=React.useRef(null),s=client.useApp(),{decorator:i}=n,r=s.getComponent(i);return r?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(r,{children:n.children})}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:n.children})},usePDFViewerPrintActionProps=()=>{const n=usePDFViewerRef();return{onClick:()=>T(this,null,function*(){n.current.print()})}},PDFViewerPrintActionInitializer=n=>{const e={title:tval("Print"),"x-action":"print","x-component":"Action","x-designer":"Action.Designer","x-component-props":{useProps:"{{ usePDFViewerPrintActionProps }}",icon:"PrinterOutlined"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,F(S({},n),{schema:e}))},pdfViewActionInitializer=new client.SchemaInitializer({name:"pdfViewer:configureActions",title:"Configure actions",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"enableActions",type:"itemGroup",title:tval("Enable actions"),children:[{name:"print",type:"item",title:tval("Print"),component:"PDFViewerPrintActionInitializer"},{name:"edit",title:tval("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}}}]}]}),PDFViewerBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaInitializerItem,F(S({},e),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PrinterOutlined,{}),onClick:()=>{var s;n({type:"void","x-designer":"Markdown.Void.Designer","x-decorator":"PDFViewerProvider","x-decorator-props":{decorator:(s=e.decorator)!=null?s:""},"x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"pdfViewer:configureActions","x-component":"ActionBar","x-component-props":{},properties:{}},viewer:{type:"void","x-component":"PDFViwer","x-component-props":{target:e.target,usePdfPath:e.usePdfPath}}}})}}))},InternalPDFViewer=n=>{const{usePdfPath:e}=n,s=React.useRef(null),[i,r]=React.useState(0),[,o]=React.useState(0);React.useEffect(()=>{const d=_.debounce(()=>{s.current&&(r(s.current.offsetWidth),o(s.current.offsetHeight))},200),u=new ResizeObserver(()=>{d()});return s.current&&u.observe(s.current),()=>{u.disconnect()}},[s]);const l=usePDFViewerRef(),c=(e!=null?e:()=>"")();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
68
+ `,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(reactRouterDom.Outlet,{})})});function NotAuthorityResult(){return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Result,{status:"403",title:"403",subTitle:"Sorry, you are not authorized to access this page."})}function useEmbedToken(){const n=new URL(window.location.href),e=client.useAPIClient(),s=n.searchParams.get("token");return s&&e.auth.setToken(s),e.auth.getToken()}const EmbedPage=()=>{const n=useEmbedToken(),e=reactRouterDom.useNavigate(),s=reactRouterDom.useLocation(),i=reactRouterDom.useMatch("/embed/:name");return React.useEffect(()=>()=>{setTimeout(()=>{i&&setTimeout(()=>{window.location.pathname!==s.pathname&&e("/embed/not-authorized")})})},[]),!n||s.pathname==="/embed/not-authorized"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(NotAuthorityResult,{}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(EmbedLayout,{})})};function EmbedSchemaComponent(){const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.name})}function usePageSettingsProps(){const n=reactRouterDom.useMatch("/admin/:name"),e=reactRouterDom.useMatch("/embed/:name"),s=n||e,i=schema.useFieldSchema(),{message:r,notification:o}=antd.App.useApp(),{t:l}=useTranslation();return{title:l("Copy embedded link"),onClick:()=>{const a=window.location.href.replace("/admin","/embed").replace(s.params.name,i["x-uid"]).replace(window.location.search||"","");navigator.clipboard.writeText(a).then(()=>{r.success(l("Copy successful"))}).catch(c=>{o.error({message:l("Copy Failed"),description:c.message,placement:"topRight"})})}}}const keyEmbed="embed",pathEmbed=`/${keyEmbed}`;class EmbedPlugin extends client.Plugin{load(){return T(this,null,function*(){this.router.add(keyEmbed,{path:pathEmbed,Component:EmbedPage}),this.router.add(`${keyEmbed}.page`,{path:`${pathEmbed}/:name`,Component:EmbedSchemaComponent}),this.router.add(`${keyEmbed}.notAuthorized`,{path:`${pathEmbed}/not-authorized`,element:null}),this.schemaSettingsManager.addItem("PageSettings",keyEmbed,{type:"item",useComponentProps:usePageSettingsProps})})}}const{defaultProps:defaultProps$3}=client.interfacesProperties;class ShowFieldCodeInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="codeShow",this.type="object",this.group="advanced",this.title="jsCode(显示)",this.description="通过jsCode, 用于定制化显示用户界面内容.可使用的变量:scopes:{ form, path, recordData, result, setResult, formatFunc, dayjs}; handlers: { setResult, formatFunc }; modules: { dayjs }",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"ViewCode","x-component-props":{jsCode:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=I(D({},defaultProps$3),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.jsCode":{type:"string",title:"JSCode","x-decorator":"FormItem","x-component":"CodeMirror",default:"",required:!0}})}}const ViewCode=n=>{const e=useAction$1(n);return typeof e=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue$1,{value:e}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:e})},ShowValue$1=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction$1(n){var x,b,E,v;const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{jsCode:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),[f,p]=React.useState({items:[],childrenType:""}),m=w=>{let C=w;return typeof w=="number"&&(C=isNaN(w)?w:Number(w).toFixed(+a||0)),`${o}${C}${l}`};React.useEffect(()=>{dynamicCode({jsCode:r,form:e,path:c,recordData:u,result:f},{setResult:p,formatFunc:m})},[]);const g=(x=f==null?void 0:f.items)==null?void 0:x.map(w=>({label:w.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:w.children})}));return f.childrenType==="normal"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:g}):f.childrenType==="jsx"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:(b=f==null?void 0:f.items)==null?void 0:b.map(w=>w.children)}):(v=(E=f.items)==null?void 0:E[0])==null?void 0:v.children}function dynamicCode(a,c){return T(this,arguments,function*({jsCode:n,form:e,path:s,recordData:i,result:r},{setResult:o,formatFunc:l}){try{const d={data:{form:e,path:s,recordData:i,result:r,setResult:o,formatFunc:l},body:{}};yield evalSimulate(n,{ctx:d,lib:{log:console.log,JSON,dayjs}}),o(d.body)}catch(d){o({childrenType:"",items:[{key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+d}]})}})}function evalSimulate(i,r){return T(this,arguments,function*(n,{ctx:e,lib:s}){const o=(function(){return T(this,null,function*(){})}).constructor;try{return yield new o("$root",`with($root) { ${n}; }`)({ctx:e,lib:s})}catch(l){console.log("err",l)}})}const{defaultProps:defaultProps$2}=client.interfacesProperties;class ShowFieldFormulaInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="formulaShow",this.type="object",this.group="advanced",this.title="公式(显示)",this.description="通过公式, 用于定制化显示用户界面内容",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"Viewformula","x-component-props":{formulaString:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=I(D({},defaultProps$2),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.formulaString":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0}})}}const ViewFormula=n=>{const{resultShowValue:e}=useAction(n);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue,{value:e})},ShowValue=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction(n){const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{formulaString:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),f=transformFormula(r),p=getEvaluateArray(f,u);return p?{resultShowValue:getResultShowValue(p,{prefix:o,suffix:l,decimal:a})}:{resultShowValue:""}}function transformFormula(n){return n?n.split(/([+\-*/?:()%])/).filter(s=>s):[]}function getEvaluateArray(n,e){var o;if(n.length<1)return;let s=0;const i=[],r={};for(let l=0;l<n.length;l++){const a=n[l];if(!a)continue;const c=isNumberFunc(a),d=isSymbolFunc(a);if(!c&&!d){let u;const f=/\${(.*?)}/g;if((o=a.match(f))!=null&&o.length){const g=a.match(f)[0].replace(/\${|}/g,""),x=a.split(".")[1],b=_.chain(e).get(g).value();u=_.chain(b).get(x,0).value()}else u=_.chain(e).get(a,0).value();const p=`var${s++}`,m=u!=null?u:0;i.push(`{{${p}}}`),r[p]=m}else i.push(a)}return[i.join(""),r]}function getResultShowValue(n,{prefix:e,suffix:s,decimal:i}){const r=client$1.evaluators.get("math.js"),o=r.evaluate.bind(r),[l,a]=n;let c;try{const d=o(l,a),u=isNaN(d)?d:Number(d).toFixed(+i||0);c=`${e}${u}${s}`}catch(d){c=`${l}`,console.warn("code: ",l," scopes: ",a,"error: ",c," error message ",d.message)}return c}function isNumberFunc(n){return typeof n=="number"&&!isNaN(n)}function isSymbolFunc(n){return["+","-","*","/","?",":","(",")","%"].includes(n)}class PluginFieldAppends extends client.Plugin{load(){return T(this,null,function*(){this.app.addComponents({Viewformula:ViewFormula,ViewCode}),this.app.dataSourceManager.addFieldInterfaces([ShowFieldFormulaInterface,ShowFieldCodeInterface])})}}const usePluginVersion=()=>{var e,s;const{data:n}=client.useRequest({url:"hera:version"});return(s=(e=n==null?void 0:n.data)==null?void 0:e.packageJson)==null?void 0:s.version},useHeraVersion=()=>{const n=usePluginVersion();return{key:"hera-version",eventKey:"hera-version",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:["赫拉系统 - ",n]})}},HeraVersionProvider=({children:n})=>{const{addMenuItem:e}=client.useCurrentUserSettingsMenu(),s=useHeraVersion();return React.useEffect(()=>{e(s,{before:"divider_1"})},[e,s]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:n})};class PluginHeraVersion extends client.Plugin{load(){return T(this,null,function*(){this.app.use(HeraVersionProvider)})}}const OutboundLinkActionInitializer=n=>{const e={title:tval("outbound"),"x-action":"outbound","x-component":"OutboundButton","x-designer":"Action.Designer","x-component-props":{icon:"ShareAltOutlined",useProps:"{{ useOutboundActionProps }}"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(D({},n),{schema:e}))};OutboundLinkActionInitializer.displayName="OutboundLinkActionInitializer";const OutboundButton=n=>{const{onClick:e}=client.useProps(n),s=schema.useFieldSchema(),i=window.location.href.split("/",3).join("/"),{t:r}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Popover,{placement:"bottomRight",trigger:"click",autoAdjustOverflow:!0,content:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space.Compact,{style:{width:"100%"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{defaultValue:`${i}/r/${s["x-uid"]}`}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:e,children:r("Copy link")})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Button,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.ShareAltOutlined,{}),r("Outbound")]})})};OutboundButton.displayName="OutboundButton";const OutboundPage=()=>{const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteCollectionManagerProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.id})})})};var toggleSelection=function(){var n=document.getSelection();if(!n.rangeCount)return function(){};for(var e=document.activeElement,s=[],i=0;i<n.rangeCount;i++)s.push(n.getRangeAt(i));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return n.removeAllRanges(),function(){n.type==="Caret"&&n.removeAllRanges(),n.rangeCount||s.forEach(function(r){n.addRange(r)}),e&&e.focus()}},deselectCurrent=toggleSelection,clipboardToIE11Formatting={"text/plain":"Text","text/html":"Url",default:"Text"},defaultMessage="Copy to clipboard: #{key}, Enter";function format(n){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return n.replace(/#{\s*key\s*}/g,e)}function copy(n,e){var s,i,r,o,l,a,c=!1;e||(e={}),s=e.debug||!1;try{r=deselectCurrent(),o=document.createRange(),l=document.getSelection(),a=document.createElement("span"),a.textContent=n,a.ariaHidden="true",a.style.all="unset",a.style.position="fixed",a.style.top=0,a.style.clip="rect(0, 0, 0, 0)",a.style.whiteSpace="pre",a.style.webkitUserSelect="text",a.style.MozUserSelect="text",a.style.msUserSelect="text",a.style.userSelect="text",a.addEventListener("copy",function(u){if(u.stopPropagation(),e.format)if(u.preventDefault(),typeof u.clipboardData=="undefined"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var f=clipboardToIE11Formatting[e.format]||clipboardToIE11Formatting.default;window.clipboardData.setData(f,n)}else u.clipboardData.clearData(),u.clipboardData.setData(e.format,n);e.onCopy&&(u.preventDefault(),e.onCopy(u.clipboardData))}),document.body.appendChild(a),o.selectNodeContents(a),l.addRange(o);var d=document.execCommand("copy");if(!d)throw new Error("copy command was unsuccessful");c=!0}catch(u){s&&console.error("unable to copy using execCommand: ",u),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",n),e.onCopy&&e.onCopy(window.clipboardData),c=!0}catch(f){s&&console.error("unable to copy using clipboardData: ",f),s&&console.error("falling back to prompt"),i=format("message"in e?e.message:defaultMessage),window.prompt(i,n)}}finally{l&&(typeof l.removeRange=="function"?l.removeRange(o):l.removeAllRanges()),a&&document.body.removeChild(a),r()}return c}var copyToClipboard=copy;const copy$1=getDefaultExportFromCjs(copyToClipboard),useOutboundActionProps=()=>{let n=schema.useFieldSchema();const{t:e}=useTranslation();for(;!("x-decorator-props"in n);)n=n.parent;const s=window.location.href.split("/",3).join("/");return{onClick(){return T(this,null,function*(){copy$1(`${s}/r/${n["x-uid"]}`)?antd.message.success(e("Save link successful")):antd.message.success(e("Save link failed"))})}}};class PluginOutbound extends client.Plugin{load(){return T(this,null,function*(){this.app.router.add("outbound",{path:"/r/:id",Component:OutboundPage}),this.app.addScopes({useOutboundActionProps}),this.app.addComponents({OutboundButton,OutboundLinkActionInitializer});const e={type:"item",name:"enableActions.outbound",title:lang("outbound"),Component:"OutboundLinkActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("table:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("details:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("pdfViewer:configureActions",e.name,e)})}}const PDFViewerContext=React.createContext(null),usePDFViewerRef=()=>React.useContext(PDFViewerContext),PDFViewerProvider=n=>{const e=React.useRef(null),s=client.useApp(),{decorator:i}=n,r=s.getComponent(i);return r?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(r,{children:n.children})}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:n.children})},usePDFViewerPrintActionProps=()=>{const n=usePDFViewerRef();return{onClick:()=>T(this,null,function*(){n.current.print()})}},PDFViewerPrintActionInitializer=n=>{const e={title:tval("Print"),"x-action":"print","x-component":"Action","x-designer":"Action.Designer","x-component-props":{useProps:"{{ usePDFViewerPrintActionProps }}",icon:"PrinterOutlined"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(D({},n),{schema:e}))},pdfViewActionInitializer=new client.SchemaInitializer({name:"pdfViewer:configureActions",title:"Configure actions",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"enableActions",type:"itemGroup",title:tval("Enable actions"),children:[{name:"print",type:"item",title:tval("Print"),component:"PDFViewerPrintActionInitializer"},{name:"edit",title:tval("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}}}]}]}),PDFViewerBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaInitializerItem,I(D({},e),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PrinterOutlined,{}),onClick:()=>{var s;n({type:"void","x-designer":"Markdown.Void.Designer","x-decorator":"PDFViewerProvider","x-decorator-props":{decorator:(s=e.decorator)!=null?s:""},"x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"pdfViewer:configureActions","x-component":"ActionBar","x-component-props":{},properties:{}},viewer:{type:"void","x-component":"PDFViwer","x-component-props":{target:e.target,usePdfPath:e.usePdfPath}}}})}}))},InternalPDFViewer=n=>{const{usePdfPath:e}=n,s=React.useRef(null),[i,r]=React.useState(0),[,o]=React.useState(0);React.useEffect(()=>{const d=_.debounce(()=>{s.current&&(r(s.current.offsetWidth),o(s.current.offsetHeight))},200),u=new ResizeObserver(()=>{d()});return s.current&&u.observe(s.current),()=>{u.disconnect()}},[s]);const l=usePDFViewerRef(),c=(e!=null?e:()=>"")();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
69
69
  display: flex;
70
70
  `,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{className:client.css`
71
71
  flex: 1;
@@ -79,4 +79,4 @@
79
79
  div::-webkit-scrollbar {
80
80
  display: none;
81
81
  }
82
- `,children:c?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewer,{file:c,width:i,ref:l}):""})]})};class PluginPDF extends client.Plugin{load(){return T(this,null,function*(){this.app.addScopes({usePDFViewerPrintActionProps}),this.app.addComponents({PDFViewerBlockInitializer,PDFViewerPrintActionInitializer,PDFViewerProvider,PDFViwer:InternalPDFViewer}),this.schemaInitializerManager.add(pdfViewActionInitializer);const e={title:tval("preview block"),name:"previewBlock",type:"itemGroup",children:[]};this.app.schemaInitializerManager.get("popup:common:addBlock").add(e.name,e)})}}const SheetBlockContext=React.createContext({}),InternalSheetBlockProvider=n=>{const e=schema.useField(),s=client.useDataBlockRequest();return s.loading&&!e.loaded?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{}):(e.loaded=!0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SheetBlockContext.Provider,{value:{field:e,service:s},children:n.children}))},SheetBlock=()=>{const n=React.useRef();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:{height:"70vh"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:()=>console.log("data",n.current.getData()),children:"显示数据"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:n})]})},SheetBlockProvider=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockProvider,F(S({name:"sheet"},n),{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalSheetBlockProvider,S({},n))})),createSheetBlockSchema=n=>{const{collection:e}=n;return{title:e.title,type:"void","x-acl-action":`${e.name}:list`,"x-decorator":"SheetBlockProvider","x-decorator-props":{collection:e.name},"x-toolbar":"SheetBlockToolbar","x-settings":"sheetBlockSettings","x-component":"CardItem",properties:{[client$2.uid()]:{type:"void","x-component":"SheetBlock"}}}},SheetBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useCollectionManager(),s=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,F(S({},s),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.TableOutlined,{}),onCreateBlockSchema:r=>T(this,[r],function*({item:i}){const o=e.getCollection(i.name);n(createSheetBlockSchema({collection:o}))})}))},sheetBlockSettings=new client.SchemaSettings({name:"sheetBlockSettings",items:[{name:"remove",type:"remove"}]}),SheetBlockToolbar=n=>{const e=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaToolbar,S({title:e.title,settings:e["x-settings"]},n))};class PluginSheet extends client.Plugin{load(){return T(this,null,function*(){this.app.addComponents({SheetBlock,SheetBlockInitializer,SheetBlockProvider,SheetBlockToolbar}),this.schemaSettingsManager.add(sheetBlockSettings),this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.sheetBlock",{title:tval("Sheet"),Component:"SheetBlockInitializer"})})}}const useGetCustomAssociatedComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_ASSOCIATED_FIELD),useGetCustomComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_FIELD);class ExcelFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="excelField",this.type="json",this.group="advanced",this.order=3,this.title=tval("Excel table"),this.sortable=!0,this.default={interface:"json",type:"json",uiSchema:{type:"object","x-component":"ExcelFile"}},this.availableTypes=["json"],this.hasDefaultValue=!1,this.properties=S({},client.defaultProps)}}class AssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="associated",this.type="object",this.group="relation",this.order=10,this.title="关联字段",this.description="关联字段",this.isAssociation=!0,this.default={type:"belongsTo",uiSchema:{"x-component":"AssociatedField"}},this.availableTypes=["belongsTo"],this.properties=F(S({},client.defaultProps),{"uiSchema.x-component-props.collection":{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceCollection":{type:"string",title:"查询数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceField":{type:"string",title:"查询数据表到关联数据表的路径","x-component":"Input","x-decorator":"FormItem",required:!0},"uiSchema.x-component-props.fieldExp":{type:"string",title:"关联字段",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},"uiSchema.x-component-props.dateFieldExp":{type:"string",title:"关联日期",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0,"x-display":"hidden","x-reactions":[{dependencies:["uiSchema.x-component-props.collection"],fulfill:{state:{value:"{{$deps[0]}}"}}}]},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}),this.filterable={nested:!0,children:[]}}}const{defaultProps:defaultProps$1}=client.interfacesProperties,formulaType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["formula"].includes($deps[0]) ? "visible" : "none"}}'}}}],panelType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["jsCode"].includes($deps[0]) ? "visible" : "none"}}'}}}];class CalcFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="calc2",this.type="object",this.group="advanced",this.title="数据计算(过期)",this.description="数据字段计算",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"CalcResult","x-component-props":{formula:"",prefix:"",suffix:"",decimal:"",panel:""},"x-read-pretty":!0}},this.properties=F(S({},defaultProps$1),{dataType:{type:"string",title:"计算类型","x-decorator":"FormItem","x-component":"Select",enum:[{value:"formula",label:"公式"},{value:"jsCode",label:"代码"}],required:!0,default:"formula",description:"公式:使用公式计算,代码:使用js代码计算"},"uiSchema.x-component-props.formula":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0,"x-reactions":formulaType},"uiSchema.x-component-props.panel":{type:"string",title:"jsCode","x-decorator":"FormItem","x-component":"Input.TextArea",description:"注意,此内容有值计算操作将以此内容为准,而不是公式,适用于面板中的计算",required:!0,"x-reactions":panelType},"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}],"x-reactions":formulaType}})}}const{defaultProps}=client.interfacesProperties;class CustomFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="custom",this.type="object",this.group="advanced",this.title="组件字段",this.description="组件字段",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"CustomField","x-read-pretty":!0}},this.properties=F(S({},defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomComponents() }} ",required:!0,description:"需要在插件中注册相应的组件后可以使用"}})}}class CustomAssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="customAssociated",this.type="object",this.group="relation",this.order=10,this.title="自定义关联字段",this.description="自定义关联字段",this.isAssociation=!0,this.default={type:"virtual",uiSchema:{"x-component":"CustomAssociatedField"}},this.availableTypes=["belongsTo"],this.properties=F(S({},client.defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomAssociatedComponents() }}",required:!0,description:"需要在插件中注册相应的组件后可以使用"},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}),this.filterable={nested:!0,children:[]}}}class SignaturePadFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="signatureSchema",this.type="object",this.group="advanced",this.order=2,this.title=tval("Signature input"),this.sortable=!0,this.default={interface:"signature",type:"json",uiSchema:{type:"signature","x-component":"SignatureInput"}},this.availableTypes=["json"],this.hasDefaultValue=!1,this.properties=S({},client.defaultProps)}}class TstzrangeFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="tstzrange",this.type="object",this.group="datetime",this.order=2,this.title=tval("Date range"),this.sortable=!0,this.default={type:"tstzrange",uiSchema:{type:"object","x-component":"DatePicker.RangePicker","x-component-props":{utc:!1,valueType:"range"}}},this.availableTypes=["tstzrange"],this.hasDefaultValue=!1,this.properties=S({},client.defaultProps)}}const SettingBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),{t:e}=useTranslation(),s=React.useContext(schema.SchemaOptionsContext),{theme:i}=client.useGlobalTheme(),r=client.useSchemaInitializerItem(),o=client.useCollectionManager(),l=client.useAPIClient();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,F(S({},r),{componentType:"FormItem",icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.FormOutlined,{}),onCreateBlockSchema:c=>T(this,[c],function*({item:a}){const d=o.getCollection(a.name),u=d.titleField,f=yield client.FormDialog(e("Pick a data entry for viewing and editing"),()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.APIClientProvider,{apiClient:l,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:s.scope,components:S({},s.components),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(components$1.FormLayout,{layout:"vertical",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{properties:{id:{title:tval("Please select"),required:!0,"x-component":"RemoteSelect","x-component-props":{service:{resource:a.name},fieldNames:{label:u,value:"id"}},"x-decorator":"FormItem"}}}})})})}),i).open({initialValues:{}}),m=client.createFormBlockSchema({dataSource:a.dataSource,collection:d.name,action:"get",filterByTk:f.id,actionInitializers:"editForm:configureActions"});n(m)})}))},usePaginationVisible=()=>{var e;return((e=schema.useFieldSchema()["x-component-props"])==null?void 0:e.mode)==="SubTable"},EditTitle=()=>{var a;const{getCollectionJoinField:n}=client.useCollectionManager_deprecated(),{getField:e}=client.useCollection_deprecated(),s=schema.useField(),i=schema.useFieldSchema(),{t:r}=useTranslation(),{dn:o}=client.useDesignable(),l=e(i.name)||n(i["x-collection-field"]);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:r("Edit field title"),schema:{type:"object",title:r("Edit field title"),properties:{title:{title:r("Field title"),default:s==null?void 0:s.title,description:`${r("Original field title: ")}${l?(a=l==null?void 0:l.uiSchema)==null?void 0:a.title:i.name}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:c})=>{c&&(s.title=c,i.title=c,o.emit("patch",{schema:{"x-uid":i["x-uid"],title:i.title}})),o.refresh()}},"edit-field-title")},IsTablePageSize=()=>{const{dn:n}=client.useDesignable(),e=schema.useFieldSchema(),{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:s("Pagination"),checked:e["x-component-props"].pagination,onChange:i=>{e["x-component-props"].pagination||(e["x-component-props"]=F(S({},e["x-component-props"]),{pagination:!1})),e["x-component-props"].pagination=i,n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-component-props":S({},e==null?void 0:e["x-component-props"])}}),n.refresh()}})},SchemaSettingsDatePickerType=()=>{var a,c,d;const n=schema.useFieldSchema(),e=schema.useField(),{dn:s}=client.useDesignable(),{t:i}=useTranslation(),o=client.useCollectionManager().getCollectionField(n==null?void 0:n["x-collection-field"])||{},l=((a=n==null?void 0:n["x-component-props"])==null?void 0:a.picker)||((d=(c=o==null?void 0:o.uiSchema)==null?void 0:c["x-component-props"])==null?void 0:d.picker)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:i("Date picker type"),schema:{type:"object",properties:{picker:{type:"string",title:tval("Picker type"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:l,enum:[{label:i("default"),value:""},{label:i("year"),value:"year"},{label:i("quarter"),value:"quarter"},{label:i("month"),value:"month"},{label:i("week"),value:"week"}]}}},onSubmit:u=>{const f={"x-uid":n["x-uid"]};f["x-component-props"]=n["x-component-props"]||{},n["x-component-props"]=S(S({},n["x-component-props"]||{}),u),f["x-component-props"]=n["x-component-props"],e.componentProps=n["x-component-props"];const m=e.path.entire.split(".");m.pop();const p=m.join(".");e.query(`${p}.*[0:].${n.name}`).forEach(g=>{g.props.name===n.name&&g.setComponentProps(S({},u))}),s.emit("patch",{schema:f}),s.refresh()}})};SchemaSettingsDatePickerType.displayName="SchemaSettingsDatePickerType";const useCustomPresets1=()=>{const n=schema.useFieldSchema(),{t:e}=useTranslation(),s=getDateRanges(),i=[{label:e("This year"),value:s.thisYear},...Array(5).fill(0).map((r,o)=>({label:client$2.dayjs().year()-o-1+e("year"),value:s.year(client$2.dayjs().year()-o-1)})),{label:e("This month"),value:s.thisMonth},{label:e("Last month"),value:s.lastMonth}];return n.name==="presets"?"{{ useCustomPresets1() }}":i},useCustomPresets=n=>"{{ "+n+"() }}",SchemaSettingsDatePresets=()=>{var l,a,c;const n=schema.useFieldSchema(),{dn:e}=client.useDesignable(),{t:s}=useTranslation(),r=client.useCollectionManager().getCollectionField(n==null?void 0:n["x-collection-field"])||{},o=((l=n==null?void 0:n["x-component-props"])==null?void 0:l.presets)||((c=(a=r==null?void 0:r.uiSchema)==null?void 0:a["x-component-props"])==null?void 0:c.presets)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:s("Date presets"),schema:{type:"object",properties:{presets:{type:"string",title:tval("Date presets"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:o,enum:[{label:s("default"),value:""},{label:s("Chuangxing presets"),value:'{{ useCustomPresets("useCustomPresets1") }}'}]}}},onSubmit:d=>{d.presets||(d.presets=void 0);const u={"x-uid":n["x-uid"]};u["x-component-props"]=n["x-component-props"]||{},n["x-component-props"]=S(S({},n["x-component-props"]||{}),d),u["x-component-props"]=n["x-component-props"],e.emit("patch",{schema:u}),e.refresh()}})};SchemaSettingsDatePresets.displayName="SchemaSettingsDatePresets";const getDateRanges=()=>({now:()=>client$2.dayjs().toISOString(),today:()=>[getStart(0,"day"),getEnd(0,"day")],yesterday:()=>[getStart(-1,"day"),getEnd(-1,"day")],tomorrow:()=>[getStart(1,"day"),getEnd(1,"day")],thisWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],year:n=>[getStart(n-client$2.dayjs().year(),"year"),getEnd(n-client$2.dayjs().year(),"year")],thisIsoWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastIsoWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextIsoWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],thisMonth:()=>[getStart(0,"month"),getEnd(0,"month")],lastMonth:()=>[getStart(-1,"month"),getEnd(-1,"month")],nextMonth:()=>[getStart(1,"month"),getEnd(1,"month")],thisQuarter:()=>[getStart(0,"quarter"),getEnd(0,"quarter")],lastQuarter:()=>[getStart(-1,"quarter"),getEnd(-1,"quarter")],nextQuarter:()=>[getStart(1,"quarter"),getEnd(1,"quarter")],thisYear:()=>[getStart(0,"year"),getEnd(0,"year")],lastYear:()=>[getStart(-1,"year"),getEnd(-1,"year")],nextYear:()=>[getStart(1,"year"),getEnd(1,"year")],last7Days:()=>[getStart(-6,"days"),getEnd(0,"days")],next7Days:()=>[getStart(1,"day"),getEnd(7,"days")],last30Days:()=>[getStart(-29,"days"),getEnd(0,"days")],next30Days:()=>[getStart(1,"day"),getEnd(30,"days")],last90Days:()=>[getStart(-89,"days"),getEnd(0,"days")],next90Days:()=>[getStart(1,"day"),getEnd(90,"days")]}),getStart=(n,e)=>client$2.dayjs().add(n,e==="isoWeek"?"week":e).startOf(e),getEnd=(n,e)=>client$2.dayjs().add(n,e==="isoWeek"?"week":e).endOf(e),SchemaSettingsSubmitDataType=()=>{var i;const{dn:n}=client.useDesignable(),{t:e}=useTranslation(),s=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:e("Select submit data type"),checked:!!((i=s==null?void 0:s["x-action-settings"])!=null&&i.isDeltaChanged),onChange:r=>{s["x-action-settings"].isDeltaChanged=r,n.emit("patch",{schema:{"x-uid":s["x-uid"],"x-action-settings":S({},s["x-action-settings"])}})}})};SchemaSettingsSubmitDataType.displayName="SchemaSettingsSubmitDataType";const LinkManager=()=>{const[n,e]=React.useState(!1),[s,i]=React.useState({}),[r,o]=React.useState([]),{data:l,run:a}=client.useRequest({url:"/link-manage:get"}),{run:c}=client.useRequest({url:"/link-manage:set",params:{id:s.id,link:s.link}});React.useEffect(()=>{l&&o(l.data)},[l]);const d=p=>{i(p),e(!0)},u=()=>{e(!1)},f=()=>{c();const p=r.map(g=>g.id===s.id?s:g);o(p),e(!1),i({})},m=[{title:"名称",dataIndex:"name",key:"name",render:p=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:p})},{title:"链接",dataIndex:"link",key:"link",render:p=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:p})},{title:"Action",key:"action",render:(p,g)=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Space,{size:"middle",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:()=>d(g),children:"编辑"})})}];return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[r&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{columns:m,dataSource:r}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Drawer,{title:"设定链接地址",width:720,onClose:u,open:n,styles:{body:{paddingBottom:80}},extra:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:u,children:"关闭"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:f,type:"primary",children:"提交"})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{layout:"vertical",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"name",label:"Name",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{placeholder:"Please enter Name",defaultValue:s==null?void 0:s.name,disabled:!0})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"link",label:"Link",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{onChange:p=>i(F(S({},s),{link:p.target.value})),placeholder:"Please enter Link",defaultValue:s==null?void 0:s.link})})]})})]})},TokenConfigurationResourceKey="token-configuration",getSSKey=n=>`TACHYBASE_PLUGIN_TOKEN_CONFIGURATION_${n}`,useMapConfiguration=n=>{const e=React.useMemo(()=>{const i=sessionStorage.getItem(getSSKey(n));return i&&JSON.parse(i)},[n]),{data:s}=client.useRequest({resource:TokenConfigurationResourceKey,action:"get",params:{type:n}},{onSuccess(i){sessionStorage.setItem(getSSKey(n),JSON.stringify(i==null?void 0:i.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!e});return e||(s==null?void 0:s.data)},TokenTypes=[{label:"飞书",value:"feishu"}],BaseConfiguration=({type:n,children:e})=>{const[s,i]=ahooks.useBoolean(!1),r=client.useAPIClient(),[o]=antd.Form.useForm(),l=useMapConfiguration(n);React.useEffect(()=>{l&&(o.setFieldsValue(l),i.toggle())},[l]);const a=React.useMemo(()=>r.resource(TokenConfigurationResourceKey),[r]),c=d=>{a.set(F(S({},d),{type:n})).then(u=>{sessionStorage.removeItem(getSSKey(n)),i.toggle(),antd.message.success("保存成功")}).catch(u=>{antd.message.success("保存失败")})};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{disabled:s,form:o,layout:"vertical",onFinish:c,children:[e,s?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,onClick:i.toggle,children:"编辑"}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,type:"primary",htmlType:"submit",children:"保存"})})]})},AMapConfiguration=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(BaseConfiguration,{type:"feishu",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_id",label:"App ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_secret",label:"App Secret",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"chat_id",label:"Chat ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})})]}),components={feishu:AMapConfiguration},tabList=TokenTypes.map(n=>F(S({},n),{component:components[n.value]})),Configuration=()=>{const n=reactRouterDom.useLocation(),e=new URLSearchParams(n.search);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Card,{bordered:!0,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs,{type:"card",defaultActiveKey:e.get("tab"),children:tabList.map(s=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs.TabPane,{tab:s.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(s.component,{type:s.value})},s.value))})})};class PluginSettingsHelper{constructor(e){this.app=e}load(){return T(this,null,function*(){this.app.systemSettingsManager.add("system-services.hera",{title:tval("Hera integration"),icon:"HomeOutlined"}),this.app.systemSettingsManager.add("system-services.hera.token",{title:tval("Third-party integration configuration"),icon:"ShareAltOutlined",Component:Configuration}),this.app.systemSettingsManager.add("system-services.hera.linkmanage",{title:tval("Link manager"),icon:"ShareAltOutlined",Component:LinkManager})})}}class PluginCoreClient extends client.Plugin{afterAdd(){return T(this,null,function*(){yield this.app.pm.add(PluginGroupBlock),yield this.app.pm.add(EmbedPlugin),yield this.app.pm.add(PluginHeraVersion),yield this.app.pm.add(PluginPDF),yield this.app.pm.add(PluginOutbound),yield this.app.pm.add(PluginFieldAppends),yield this.app.pm.add(PluginCustomComponents),yield this.app.pm.add(PluginSheet)})}registerSettings(){return T(this,null,function*(){this.schemaSettingsManager.add(customComponentDispatcherSettings),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePickerType",{Component:SchemaSettingsDatePickerType}),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePresets",{Component:SchemaSettingsDatePresets}),this.schemaSettingsManager.addItem("actionSettings:updateSubmit","submitDataType",{Component:SchemaSettingsSubmitDataType}),this.schemaSettingsManager.addItem("FormItemSettings","hera-divider",{type:"divider",useVisible(){const e=client.useFormulaTitleVisible(),s=usePaginationVisible();return e||s}}),this.schemaSettingsManager.addItem("FormItemSettings","isTablePageSize",{Component:IsTablePageSize,useVisible:usePaginationVisible})})}registerScopesAndComponents(){return T(this,null,function*(){this.app.addScopes({useGetCustomAssociatedComponents,useGetCustomComponents,useCustomPresets1,useCustomPresets}),this.app.addComponents({AssociatedField,CalcResult,CodeMirror:components$1.CodeMirror,CustomAssociatedField,CustomComponentDispatcher,CustomComponentStub,CustomField,EditTitle,Expression,SettingBlock:SettingBlockInitializer,SignatureInput,ExcelFile})})}registerRouters(){return T(this,null,function*(){})}registerSchemaInitializer(){return T(this,null,function*(){const e={name:"setting",title:tval("System setting"),Component:"SettingBlock"},s={type:"item",name:"refreshAction",title:tval("Refresh"),Component:"RefreshActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("page:addBlock",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",s.name,s);const i={name:"addCustomComponent",title:tval("Add custom component"),Component:"BlockItemInitializer",schema:{type:"void","x-editable":!1,"x-decorator":"FormItem","x-settings":"customComponentDispatcherSettings","x-component":"CustomComponentDispatcher","x-component-props":{component:"CustomComponentStub"}}};this.app.schemaInitializerManager.addItem("form:configureFields",i.name,i),this.app.schemaInitializerManager.addItem("details:configureFields",i.name,i)})}registerInterfaces(){return T(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([AssociatedFieldInterface,CalcFieldInterface,CustomFieldInterface,CustomAssociatedFieldInterface,SignaturePadFieldInterface,ExcelFieldInterface,TstzrangeFieldInterface])})}afterLoad(){return T(this,null,function*(){yield this.registerSchemaInitializer()})}load(){return T(this,null,function*(){this.locale=new Locale(this.app),yield new PluginSettingsHelper(this.app).load(),yield this.registerScopesAndComponents(),yield this.registerSettings(),yield this.registerRouters(),yield this.registerInterfaces()})}}exports.CustomComponentType=CustomComponentType,exports.PluginCoreClient=PluginCoreClient,exports.default=PluginCoreClient,exports.usePDFViewerRef=usePDFViewerRef,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
82
+ `,children:c?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewer,{file:c,width:i,ref:l}):""})]})};class PluginPDF extends client.Plugin{load(){return T(this,null,function*(){this.app.addScopes({usePDFViewerPrintActionProps}),this.app.addComponents({PDFViewerBlockInitializer,PDFViewerPrintActionInitializer,PDFViewerProvider,PDFViwer:InternalPDFViewer}),this.schemaInitializerManager.add(pdfViewActionInitializer);const e={title:tval("preview block"),name:"previewBlock",type:"itemGroup",children:[]};this.app.schemaInitializerManager.get("popup:common:addBlock").add(e.name,e)})}}const SheetBlockContext=React.createContext({}),InternalSheetBlockProvider=n=>{const e=schema.useField(),s=client.useDataBlockRequest();return s.loading&&!e.loaded?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Spin,{}):(e.loaded=!0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SheetBlockContext.Provider,{value:{field:e,service:s},children:n.children}))},SheetBlock=()=>{const n=React.useRef();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:{height:"70vh"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:()=>console.log("data",n.current.getData()),children:"显示数据"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ExcelSheet,{ref:n})]})},SheetBlockProvider=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockProvider,I(D({name:"sheet"},n),{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(InternalSheetBlockProvider,D({},n))})),createSheetBlockSchema=n=>{const{collection:e}=n;return{title:e.title,type:"void","x-acl-action":`${e.name}:list`,"x-decorator":"SheetBlockProvider","x-decorator-props":{collection:e.name},"x-toolbar":"SheetBlockToolbar","x-settings":"sheetBlockSettings","x-component":"CardItem",properties:{[client$2.uid()]:{type:"void","x-component":"SheetBlock"}}}},SheetBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useCollectionManager(),s=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,I(D({},s),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.TableOutlined,{}),onCreateBlockSchema:r=>T(this,[r],function*({item:i}){const o=e.getCollection(i.name);n(createSheetBlockSchema({collection:o}))})}))},sheetBlockSettings=new client.SchemaSettings({name:"sheetBlockSettings",items:[{name:"remove",type:"remove"}]}),SheetBlockToolbar=n=>{const e=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaToolbar,D({title:e.title,settings:e["x-settings"]},n))};class PluginSheet extends client.Plugin{load(){return T(this,null,function*(){this.app.addComponents({SheetBlock,SheetBlockInitializer,SheetBlockProvider,SheetBlockToolbar}),this.schemaSettingsManager.add(sheetBlockSettings),this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.sheetBlock",{title:tval("Sheet"),Component:"SheetBlockInitializer"})})}}const useGetCustomAssociatedComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_ASSOCIATED_FIELD),useGetCustomComponents=()=>useCustomComponent(CustomComponentType.CUSTOM_FIELD);class ExcelFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="excelField",this.type="json",this.group="advanced",this.order=3,this.title=tval("Excel table"),this.sortable=!0,this.default={interface:"json",type:"json",uiSchema:{type:"object","x-component":"ExcelFile"}},this.availableTypes=["json"],this.hasDefaultValue=!1,this.properties=D({},client.defaultProps)}}class AssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="associated",this.type="object",this.group="relation",this.order=10,this.title="关联字段",this.description="关联字段",this.isAssociation=!0,this.default={type:"belongsTo",uiSchema:{"x-component":"AssociatedField"}},this.availableTypes=["belongsTo"],this.properties=I(D({},client.defaultProps),{"uiSchema.x-component-props.collection":{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceCollection":{type:"string",title:"查询数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},"uiSchema.x-component-props.sourceField":{type:"string",title:"查询数据表到关联数据表的路径","x-component":"Input","x-decorator":"FormItem",required:!0},"uiSchema.x-component-props.fieldExp":{type:"string",title:"关联字段",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},"uiSchema.x-component-props.dateFieldExp":{type:"string",title:"关联日期",required:!0,"x-component":"Expression","x-decorator":"FormItem","x-component-props":{useCurrentFields:"{{ useCurrentFields }}"}},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0,"x-display":"hidden","x-reactions":[{dependencies:["uiSchema.x-component-props.collection"],fulfill:{state:{value:"{{$deps[0]}}"}}}]},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}),this.filterable={nested:!0,children:[]}}}const{defaultProps:defaultProps$1}=client.interfacesProperties,formulaType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["formula"].includes($deps[0]) ? "visible" : "none"}}'}}}],panelType=[{dependencies:["dataType"],fulfill:{state:{display:'{{["jsCode"].includes($deps[0]) ? "visible" : "none"}}'}}}];class CalcFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="calc2",this.type="object",this.group="advanced",this.title="数据计算(过期)",this.description="数据字段计算",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"CalcResult","x-component-props":{formula:"",prefix:"",suffix:"",decimal:"",panel:""},"x-read-pretty":!0}},this.properties=I(D({},defaultProps$1),{dataType:{type:"string",title:"计算类型","x-decorator":"FormItem","x-component":"Select",enum:[{value:"formula",label:"公式"},{value:"jsCode",label:"代码"}],required:!0,default:"formula",description:"公式:使用公式计算,代码:使用js代码计算"},"uiSchema.x-component-props.formula":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0,"x-reactions":formulaType},"uiSchema.x-component-props.panel":{type:"string",title:"jsCode","x-decorator":"FormItem","x-component":"Input.TextArea",description:"注意,此内容有值计算操作将以此内容为准,而不是公式,适用于面板中的计算",required:!0,"x-reactions":panelType},"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}],"x-reactions":formulaType}})}}const{defaultProps}=client.interfacesProperties;class CustomFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="custom",this.type="object",this.group="advanced",this.title="组件字段",this.description="组件字段",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"CustomField","x-read-pretty":!0}},this.properties=I(D({},defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomComponents() }} ",required:!0,description:"需要在插件中注册相应的组件后可以使用"}})}}class CustomAssociatedFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="customAssociated",this.type="object",this.group="relation",this.order=10,this.title="自定义关联字段",this.description="自定义关联字段",this.isAssociation=!0,this.default={type:"virtual",uiSchema:{"x-component":"CustomAssociatedField"}},this.availableTypes=["belongsTo"],this.properties=I(D({},client.defaultProps),{"uiSchema.x-component-props.component":{type:"string",title:"组件","x-decorator":"FormItem","x-component":"Select",enum:" {{ useGetCustomAssociatedComponents() }}",required:!0,description:"需要在插件中注册相应的组件后可以使用"},target:{type:"string",title:"关联数据表","x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!1},enum:"{{collections}}",required:!0},targetKey:{type:"string",title:"关联数据表键",required:!0,default:"id","x-display":"hidden","x-decorator":"FormItem","x-component":"Input"}}),this.filterable={nested:!0,children:[]}}}class SignaturePadFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="signatureSchema",this.type="object",this.group="advanced",this.order=2,this.title=tval("Signature input"),this.sortable=!0,this.default={interface:"signature",type:"json",uiSchema:{type:"signature","x-component":"SignatureInput"}},this.availableTypes=["json"],this.hasDefaultValue=!1,this.properties=D({},client.defaultProps)}}class TstzrangeFieldInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="tstzrange",this.type="object",this.group="datetime",this.order=2,this.title=tval("Date range"),this.sortable=!0,this.default={type:"tstzrange",uiSchema:{type:"object","x-component":"DatePicker.RangePicker","x-component-props":{utc:!1,valueType:"range"}}},this.availableTypes=["tstzrange"],this.hasDefaultValue=!1,this.properties=D({},client.defaultProps)}}const SettingBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),{t:e}=useTranslation(),s=React.useContext(schema.SchemaOptionsContext),{theme:i}=client.useGlobalTheme(),r=client.useSchemaInitializerItem(),o=client.useCollectionManager(),l=client.useAPIClient();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.DataBlockInitializer,I(D({},r),{componentType:"FormItem",icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.FormOutlined,{}),onCreateBlockSchema:c=>T(this,[c],function*({item:a}){const d=o.getCollection(a.name),u=d.titleField,f=yield client.FormDialog(e("Pick a data entry for viewing and editing"),()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.APIClientProvider,{apiClient:l,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponentOptions,{scope:s.scope,components:D({},s.components),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(components$1.FormLayout,{layout:"vertical",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{properties:{id:{title:tval("Please select"),required:!0,"x-component":"RemoteSelect","x-component-props":{service:{resource:a.name},fieldNames:{label:u,value:"id"}},"x-decorator":"FormItem"}}}})})})}),i).open({initialValues:{}}),p=client.createFormBlockSchema({dataSource:a.dataSource,collection:d.name,action:"get",filterByTk:f.id,actionInitializers:"editForm:configureActions"});n(p)})}))},usePaginationVisible=()=>{var e;return((e=schema.useFieldSchema()["x-component-props"])==null?void 0:e.mode)==="SubTable"},EditTitle=()=>{var a;const{getCollectionJoinField:n}=client.useCollectionManager_deprecated(),{getField:e}=client.useCollection_deprecated(),s=schema.useField(),i=schema.useFieldSchema(),{t:r}=useTranslation(),{dn:o}=client.useDesignable(),l=e(i.name)||n(i["x-collection-field"]);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:r("Edit field title"),schema:{type:"object",title:r("Edit field title"),properties:{title:{title:r("Field title"),default:s==null?void 0:s.title,description:`${r("Original field title: ")}${l?(a=l==null?void 0:l.uiSchema)==null?void 0:a.title:i.name}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:c})=>{c&&(s.title=c,i.title=c,o.emit("patch",{schema:{"x-uid":i["x-uid"],title:i.title}})),o.refresh()}},"edit-field-title")},IsTablePageSize=()=>{const{dn:n}=client.useDesignable(),e=schema.useFieldSchema(),{t:s}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:s("Pagination"),checked:e["x-component-props"].pagination,onChange:i=>{e["x-component-props"].pagination||(e["x-component-props"]=I(D({},e["x-component-props"]),{pagination:!1})),e["x-component-props"].pagination=i,n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-component-props":D({},e==null?void 0:e["x-component-props"])}}),n.refresh()}})},SchemaSettingsDatePickerType=()=>{var a,c,d;const n=schema.useFieldSchema(),e=schema.useField(),{dn:s}=client.useDesignable(),{t:i}=useTranslation(),o=client.useCollectionManager().getCollectionField(n==null?void 0:n["x-collection-field"])||{},l=((a=n==null?void 0:n["x-component-props"])==null?void 0:a.picker)||((d=(c=o==null?void 0:o.uiSchema)==null?void 0:c["x-component-props"])==null?void 0:d.picker)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:i("Date picker type"),schema:{type:"object",properties:{picker:{type:"string",title:tval("Picker type"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:l,enum:[{label:i("default"),value:""},{label:i("year"),value:"year"},{label:i("quarter"),value:"quarter"},{label:i("month"),value:"month"},{label:i("week"),value:"week"}]}}},onSubmit:u=>{const f={"x-uid":n["x-uid"]};f["x-component-props"]=n["x-component-props"]||{},n["x-component-props"]=D(D({},n["x-component-props"]||{}),u),f["x-component-props"]=n["x-component-props"],e.componentProps=n["x-component-props"];const p=e.path.entire.split(".");p.pop();const m=p.join(".");e.query(`${m}.*[0:].${n.name}`).forEach(g=>{g.props.name===n.name&&g.setComponentProps(D({},u))}),s.emit("patch",{schema:f}),s.refresh()}})};SchemaSettingsDatePickerType.displayName="SchemaSettingsDatePickerType";const useCustomPresets1=()=>{const n=schema.useFieldSchema(),{t:e}=useTranslation(),s=getDateRanges(),i=[{label:e("This year"),value:s.thisYear},...Array(5).fill(0).map((r,o)=>({label:client$2.dayjs().year()-o-1+e("year"),value:s.year(client$2.dayjs().year()-o-1)})),{label:e("This month"),value:s.thisMonth},{label:e("Last month"),value:s.lastMonth}];return n.name==="presets"?"{{ useCustomPresets1() }}":i},useCustomPresets=n=>"{{ "+n+"() }}",SchemaSettingsDatePresets=()=>{var l,a,c;const n=schema.useFieldSchema(),{dn:e}=client.useDesignable(),{t:s}=useTranslation(),r=client.useCollectionManager().getCollectionField(n==null?void 0:n["x-collection-field"])||{},o=((l=n==null?void 0:n["x-component-props"])==null?void 0:l.presets)||((c=(a=r==null?void 0:r.uiSchema)==null?void 0:a["x-component-props"])==null?void 0:c.presets)||"";return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsModalItem,{title:s("Date presets"),schema:{type:"object",properties:{presets:{type:"string",title:tval("Date presets"),"x-component":"Select","x-decorator":"FormItem","x-decorator-props":{},default:o,enum:[{label:s("default"),value:""},{label:s("Chuangxing presets"),value:'{{ useCustomPresets("useCustomPresets1") }}'}]}}},onSubmit:d=>{d.presets||(d.presets=void 0);const u={"x-uid":n["x-uid"]};u["x-component-props"]=n["x-component-props"]||{},n["x-component-props"]=D(D({},n["x-component-props"]||{}),d),u["x-component-props"]=n["x-component-props"],e.emit("patch",{schema:u}),e.refresh()}})};SchemaSettingsDatePresets.displayName="SchemaSettingsDatePresets";const getDateRanges=()=>({now:()=>client$2.dayjs().toISOString(),today:()=>[getStart(0,"day"),getEnd(0,"day")],yesterday:()=>[getStart(-1,"day"),getEnd(-1,"day")],tomorrow:()=>[getStart(1,"day"),getEnd(1,"day")],thisWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],year:n=>[getStart(n-client$2.dayjs().year(),"year"),getEnd(n-client$2.dayjs().year(),"year")],thisIsoWeek:()=>[getStart(0,"isoWeek"),getEnd(0,"isoWeek")],lastIsoWeek:()=>[getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],nextIsoWeek:()=>[getStart(1,"isoWeek"),getEnd(1,"isoWeek")],thisMonth:()=>[getStart(0,"month"),getEnd(0,"month")],lastMonth:()=>[getStart(-1,"month"),getEnd(-1,"month")],nextMonth:()=>[getStart(1,"month"),getEnd(1,"month")],thisQuarter:()=>[getStart(0,"quarter"),getEnd(0,"quarter")],lastQuarter:()=>[getStart(-1,"quarter"),getEnd(-1,"quarter")],nextQuarter:()=>[getStart(1,"quarter"),getEnd(1,"quarter")],thisYear:()=>[getStart(0,"year"),getEnd(0,"year")],lastYear:()=>[getStart(-1,"year"),getEnd(-1,"year")],nextYear:()=>[getStart(1,"year"),getEnd(1,"year")],last7Days:()=>[getStart(-6,"days"),getEnd(0,"days")],next7Days:()=>[getStart(1,"day"),getEnd(7,"days")],last30Days:()=>[getStart(-29,"days"),getEnd(0,"days")],next30Days:()=>[getStart(1,"day"),getEnd(30,"days")],last90Days:()=>[getStart(-89,"days"),getEnd(0,"days")],next90Days:()=>[getStart(1,"day"),getEnd(90,"days")]}),getStart=(n,e)=>client$2.dayjs().add(n,e==="isoWeek"?"week":e).startOf(e),getEnd=(n,e)=>client$2.dayjs().add(n,e==="isoWeek"?"week":e).endOf(e),SchemaSettingsSubmitDataType=()=>{var i;const{dn:n}=client.useDesignable(),{t:e}=useTranslation(),s=schema.useFieldSchema();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaSettingsSwitchItem,{title:e("Select submit data type"),checked:!!((i=s==null?void 0:s["x-action-settings"])!=null&&i.isDeltaChanged),onChange:r=>{s["x-action-settings"].isDeltaChanged=r,n.emit("patch",{schema:{"x-uid":s["x-uid"],"x-action-settings":D({},s["x-action-settings"])}})}})};SchemaSettingsSubmitDataType.displayName="SchemaSettingsSubmitDataType";const LinkManager=()=>{const[n,e]=React.useState(!1),[s,i]=React.useState({}),[r,o]=React.useState([]),{data:l,run:a}=client.useRequest({url:"/link-manage:get"}),{run:c}=client.useRequest({url:"/link-manage:set",params:{id:s.id,link:s.link}});React.useEffect(()=>{l&&o(l.data)},[l]);const d=m=>{i(m),e(!0)},u=()=>{e(!1)},f=()=>{c();const m=r.map(g=>g.id===s.id?s:g);o(m),e(!1),i({})},p=[{title:"名称",dataIndex:"name",key:"name",render:m=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:m})},{title:"链接",dataIndex:"link",key:"link",render:m=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{children:m})},{title:"Action",key:"action",render:(m,g)=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Space,{size:"middle",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:()=>d(g),children:"编辑"})})}];return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:[r&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Table,{columns:p,dataSource:r}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Drawer,{title:"设定链接地址",width:720,onClose:u,open:n,styles:{body:{paddingBottom:80}},extra:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:u,children:"关闭"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:f,type:"primary",children:"提交"})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{layout:"vertical",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"name",label:"Name",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{placeholder:"Please enter Name",defaultValue:s==null?void 0:s.name,disabled:!0})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{name:"link",label:"Link",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{onChange:m=>i(I(D({},s),{link:m.target.value})),placeholder:"Please enter Link",defaultValue:s==null?void 0:s.link})})]})})]})},TokenConfigurationResourceKey="token-configuration",getSSKey=n=>`TACHYBASE_PLUGIN_TOKEN_CONFIGURATION_${n}`,useMapConfiguration=n=>{const e=React.useMemo(()=>{const i=sessionStorage.getItem(getSSKey(n));return i&&JSON.parse(i)},[n]),{data:s}=client.useRequest({resource:TokenConfigurationResourceKey,action:"get",params:{type:n}},{onSuccess(i){sessionStorage.setItem(getSSKey(n),JSON.stringify(i==null?void 0:i.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!e});return e||(s==null?void 0:s.data)},TokenTypes=[{label:"飞书",value:"feishu"}],BaseConfiguration=({type:n,children:e})=>{const[s,i]=ahooks.useBoolean(!1),r=client.useAPIClient(),[o]=antd.Form.useForm(),l=useMapConfiguration(n);React.useEffect(()=>{l&&(o.setFieldsValue(l),i.toggle())},[l]);const a=React.useMemo(()=>r.resource(TokenConfigurationResourceKey),[r]),c=d=>{a.set(I(D({},d),{type:n})).then(u=>{sessionStorage.removeItem(getSSKey(n)),i.toggle(),antd.message.success("保存成功")}).catch(u=>{antd.message.success("保存失败")})};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Form,{disabled:s,form:o,layout:"vertical",onFinish:c,children:[e,s?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,onClick:i.toggle,children:"编辑"}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{disabled:!1,type:"primary",htmlType:"submit",children:"保存"})})]})},AMapConfiguration=()=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(BaseConfiguration,{type:"feishu",children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_id",label:"App ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"app_secret",label:"App Secret",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Form.Item,{required:!0,name:"chat_id",label:"Chat ID",children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{})})]}),components={feishu:AMapConfiguration},tabList=TokenTypes.map(n=>I(D({},n),{component:components[n.value]})),Configuration=()=>{const n=reactRouterDom.useLocation(),e=new URLSearchParams(n.search);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Card,{bordered:!0,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs,{type:"card",defaultActiveKey:e.get("tab"),children:tabList.map(s=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Tabs.TabPane,{tab:s.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(s.component,{type:s.value})},s.value))})})};class PluginSettingsHelper{constructor(e){this.app=e}load(){return T(this,null,function*(){this.app.systemSettingsManager.add("system-services.hera",{title:tval("Hera integration"),icon:"HomeOutlined"}),this.app.systemSettingsManager.add("system-services.hera.token",{title:tval("Third-party integration configuration"),icon:"ShareAltOutlined",Component:Configuration,aclSnippet:"pm.system-services.hera.token"}),this.app.systemSettingsManager.add("system-services.hera.linkmanage",{title:tval("Link manager"),icon:"ShareAltOutlined",Component:LinkManager,aclSnippet:"pm.system-services.hera.linkmanage"})})}}class PluginCoreClient extends client.Plugin{afterAdd(){return T(this,null,function*(){yield this.app.pm.add(EmbedPlugin),yield this.app.pm.add(PluginHeraVersion),yield this.app.pm.add(PluginPDF),yield this.app.pm.add(PluginOutbound),yield this.app.pm.add(PluginFieldAppends),yield this.app.pm.add(PluginCustomComponents),yield this.app.pm.add(PluginSheet)})}registerSettings(){return T(this,null,function*(){this.schemaSettingsManager.add(customComponentDispatcherSettings),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePickerType",{Component:SchemaSettingsDatePickerType}),this.schemaSettingsManager.addItem("fieldSettings:component:DatePicker","datePresets",{Component:SchemaSettingsDatePresets}),this.schemaSettingsManager.addItem("actionSettings:updateSubmit","submitDataType",{Component:SchemaSettingsSubmitDataType}),this.schemaSettingsManager.addItem("FormItemSettings","hera-divider",{type:"divider",useVisible(){const e=client.useFormulaTitleVisible(),s=usePaginationVisible();return e||s}}),this.schemaSettingsManager.addItem("FormItemSettings","isTablePageSize",{Component:IsTablePageSize,useVisible:usePaginationVisible})})}registerScopesAndComponents(){return T(this,null,function*(){this.app.addScopes({useGetCustomAssociatedComponents,useGetCustomComponents,useCustomPresets1,useCustomPresets}),this.app.addComponents({AssociatedField,CalcResult,CodeMirror:components$1.CodeMirror,CustomAssociatedField,CustomComponentDispatcher,CustomComponentStub,CustomField,EditTitle,Expression,SettingBlock:SettingBlockInitializer,SignatureInput,ExcelFile})})}registerRouters(){return T(this,null,function*(){})}registerSchemaInitializer(){return T(this,null,function*(){const e={name:"setting",title:tval("System setting"),Component:"SettingBlock"},s={type:"item",name:"refreshAction",title:tval("Refresh"),Component:"RefreshActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("page:addBlock",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",s.name,s);const i={name:"addCustomComponent",title:tval("Add custom component"),Component:"BlockItemInitializer",schema:{type:"void","x-editable":!1,"x-decorator":"FormItem","x-settings":"customComponentDispatcherSettings","x-component":"CustomComponentDispatcher","x-component-props":{component:"CustomComponentStub"}}};this.app.schemaInitializerManager.addItem("form:configureFields",i.name,i),this.app.schemaInitializerManager.addItem("details:configureFields",i.name,i)})}registerInterfaces(){return T(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([AssociatedFieldInterface,CalcFieldInterface,CustomFieldInterface,CustomAssociatedFieldInterface,SignaturePadFieldInterface,ExcelFieldInterface,TstzrangeFieldInterface])})}afterLoad(){return T(this,null,function*(){yield this.registerSchemaInitializer()})}load(){return T(this,null,function*(){this.locale=new Locale(this.app),yield new PluginSettingsHelper(this.app).load(),yield this.registerScopesAndComponents(),yield this.registerSettings(),yield this.registerRouters(),yield this.registerInterfaces()})}}exports.CustomComponentType=CustomComponentType,exports.PluginCoreClient=PluginCoreClient,exports.default=PluginCoreClient,exports.usePDFViewerRef=usePDFViewerRef,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});