@tachybase/module-hera 2.3.15 → 2.3.17

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,5 +1,5 @@
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("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(`
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$1={exports:{}},FileSaver_min=FileSaver_min$1.exports,hasRequiredFileSaver_min;function requireFileSaver_min(){return hasRequiredFileSaver_min||(hasRequiredFileSaver_min=1,function(n,e){(function(s,i){i()})(FileSaver_min,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$1)),FileSaver_min$1.exports}var FileSaver_minExports=requireFileSaver_min();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(`
@@ -13,13 +13,13 @@
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,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`
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$1(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$1.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$1.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$1.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),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="";const{jsx}=(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`
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(null,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="";const{jsx}=(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;
@@ -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=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`
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,hasRequiredToggleSelection;function requireToggleSelection(){return hasRequiredToggleSelection||(hasRequiredToggleSelection=1,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()}}),toggleSelection}var copyToClipboard,hasRequiredCopyToClipboard;function requireCopyToClipboard(){if(hasRequiredCopyToClipboard)return copyToClipboard;hasRequiredCopyToClipboard=1;var n=requireToggleSelection(),e={"text/plain":"Text","text/html":"Url",default:"Text"},s="Copy to clipboard: #{key}, Enter";function i(o){var l=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return o.replace(/#{\s*key\s*}/g,l)}function r(o,l){var a,c,d,u,f,p,m=!1;l||(l={}),a=l.debug||!1;try{d=n(),u=document.createRange(),f=document.getSelection(),p=document.createElement("span"),p.textContent=o,p.ariaHidden="true",p.style.all="unset",p.style.position="fixed",p.style.top=0,p.style.clip="rect(0, 0, 0, 0)",p.style.whiteSpace="pre",p.style.webkitUserSelect="text",p.style.MozUserSelect="text",p.style.msUserSelect="text",p.style.userSelect="text",p.addEventListener("copy",function(x){if(x.stopPropagation(),l.format)if(x.preventDefault(),typeof x.clipboardData=="undefined"){a&&console.warn("unable to use e.clipboardData"),a&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var b=e[l.format]||e.default;window.clipboardData.setData(b,o)}else x.clipboardData.clearData(),x.clipboardData.setData(l.format,o);l.onCopy&&(x.preventDefault(),l.onCopy(x.clipboardData))}),document.body.appendChild(p),u.selectNodeContents(p),f.addRange(u);var g=document.execCommand("copy");if(!g)throw new Error("copy command was unsuccessful");m=!0}catch(x){a&&console.error("unable to copy using execCommand: ",x),a&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(l.format||"text",o),l.onCopy&&l.onCopy(window.clipboardData),m=!0}catch(b){a&&console.error("unable to copy using clipboardData: ",b),a&&console.error("falling back to prompt"),c=i("message"in l?l.message:s),window.prompt(c,o)}}finally{f&&(typeof f.removeRange=="function"?f.removeRange(u):f.removeAllRanges()),p&&document.body.removeChild(p),d()}return m}return copyToClipboard=r,copyToClipboard}var copyToClipboardExports=requireCopyToClipboard();const copy=getDefaultExportFromCjs(copyToClipboardExports),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(`${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(null,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,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"}})});
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(null,[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(null,[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"}})});
@@ -1,19 +1,19 @@
1
1
  module.exports = {
2
- "@tachybase/client": "1.3.15",
3
- "@tachybase/components": "1.3.15",
4
- "@tachybase/server": "1.3.15",
2
+ "@tachybase/client": "1.3.17",
3
+ "@tachybase/components": "1.3.17",
4
+ "@tachybase/server": "1.3.17",
5
5
  "react": "18.3.1",
6
- "@tachybase/schema": "1.3.15",
6
+ "@tachybase/schema": "1.3.17",
7
7
  "@ant-design/icons": "5.3.7",
8
8
  "antd": "5.22.5",
9
9
  "lodash": "4.17.21",
10
- "@tachybase/utils": "1.3.15",
10
+ "@tachybase/utils": "1.3.17",
11
11
  "ahooks": "3.8.4",
12
12
  "react-router-dom": "6.28.1",
13
- "@tachybase/actions": "1.3.15",
13
+ "@tachybase/actions": "1.3.17",
14
14
  "axios": "1.7.7",
15
- "@tachybase/database": "1.3.15",
16
- "@tachybase/evaluators": "1.3.15",
15
+ "@tachybase/database": "1.3.17",
16
+ "@tachybase/evaluators": "1.3.17",
17
17
  "react-dom": "18.3.1",
18
18
  "dayjs": "1.11.13"
19
19
  };
package/dist/index.js CHANGED
@@ -26,12 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
31
  default: () => import_server.default
32
32
  });
33
- module.exports = __toCommonJS(src_exports);
34
- __reExport(src_exports, require("./server"), module.exports);
33
+ module.exports = __toCommonJS(index_exports);
34
+ __reExport(index_exports, require("./server"), module.exports);
35
35
  var import_server = __toESM(require("./server"));
36
36
  // Annotate the CommonJS export names for ESM import in node:
37
37
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"name":"fs-extra","version":"11.2.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=14.14"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^10.1.0","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^17.0.0"},"main":"./lib/index.js","exports":{".":"./lib/index.js","./esm":"./lib/esm.mjs"},"files":["lib/","!lib/**/__tests__/"],"scripts":{"lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit && npm run unit-esm","unit":"nyc node test.js","unit-esm":"node test.mjs"},"sideEffects":false,"_lastModified":"2025-07-01T08:02:04.355Z"}
1
+ {"name":"fs-extra","version":"11.2.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=14.14"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^10.1.0","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^17.0.0"},"main":"./lib/index.js","exports":{".":"./lib/index.js","./esm":"./lib/esm.mjs"},"files":["lib/","!lib/**/__tests__/"],"scripts":{"lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit && npm run unit-esm","unit":"nyc node test.js","unit-esm":"node test.mjs"},"sideEffects":false,"_lastModified":"2025-07-04T04:03:56.185Z"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-hera",
3
3
  "displayName": "Hera platform - Deprecated",
4
- "version": "2.3.15",
4
+ "version": "2.3.17",
5
5
  "description": "Hera platform - Deprecated",
6
6
  "keywords": [
7
7
  "System management"
@@ -27,21 +27,21 @@
27
27
  "throttle-debounce": "^5.0.2",
28
28
  "vitest": "^3.0.5",
29
29
  "ws": "^8.18.0",
30
- "@tachybase/components": "1.3.15",
31
- "@tachybase/schema": "1.3.15"
30
+ "@tachybase/components": "1.3.17",
31
+ "@tachybase/schema": "1.3.17"
32
32
  },
33
33
  "peerDependencies": {
34
- "@tachybase/actions": "1.3.15",
35
- "@tachybase/client": "1.3.15",
36
- "@tachybase/data-source": "1.3.15",
37
- "@tachybase/database": "1.3.15",
38
- "@tachybase/evaluators": "1.3.15",
39
- "@tachybase/module-workflow": "1.3.15",
40
- "@tachybase/schema": "1.3.15",
41
- "@tachybase/module-acl": "1.3.15",
42
- "@tachybase/server": "1.3.15",
43
- "@tachybase/test": "1.3.15",
44
- "@tachybase/utils": "1.3.15"
34
+ "@tachybase/client": "1.3.17",
35
+ "@tachybase/actions": "1.3.17",
36
+ "@tachybase/data-source": "1.3.17",
37
+ "@tachybase/database": "1.3.17",
38
+ "@tachybase/evaluators": "1.3.17",
39
+ "@tachybase/module-acl": "1.3.17",
40
+ "@tachybase/module-workflow": "1.3.17",
41
+ "@tachybase/schema": "1.3.17",
42
+ "@tachybase/server": "1.3.17",
43
+ "@tachybase/test": "1.3.17",
44
+ "@tachybase/utils": "1.3.17"
45
45
  },
46
46
  "description.zh-CN": "赫拉平台(已废弃)",
47
47
  "displayName.zh-CN": "赫拉平台",