ht-emr 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas-editor.js +1503 -307
- package/dist/canvas-editor.js.map +1 -1
- package/dist/canvas-editor.umd.cjs +26 -26
- package/dist/canvas-editor.umd.cjs.map +1 -1
- package/dist/src/editor/core/cursor/Cursor.d.ts +100 -0
- package/dist/src/editor/core/cursor/CursorAgent.d.ts +79 -0
- package/dist/src/editor/core/draw/Draw.d.ts +533 -0
- package/dist/src/editor/core/draw/particle/MacroParticle.d.ts +0 -5
- package/dist/src/editor/core/event/CanvasEvent.d.ts +143 -0
- package/dist/src/editor/core/position/Position.d.ts +132 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +278 -0
- package/dist/src/editor/index.d.ts +58 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="canvas-editor-style",e.appendChild(document.createTextNode(`.ce-select-control-popup{max-width:160px;min-width:69px;max-height:225px;position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;overflow-y:auto}.ce-select-control-popup ul{list-style:none;padding:3px 0;margin:0;box-sizing:border-box}.ce-select-control-popup ul li{font-size:13px;padding:0 20px;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#666;height:36px;line-height:36px;box-sizing:border-box;cursor:pointer}.ce-select-control-popup ul li:hover{background-color:#eef2fd}.ce-select-control-popup ul li.active{color:var(--COLOR-HOVER, #5175f4);font-weight:700}.ce-calculator{position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;padding:8px;width:200px}.ce-calculator-display{width:100%;height:40px;line-height:40px;text-align:right;padding:0 10px;margin-bottom:8px;border:1px solid #e4e7ed;border-radius:4px;background-color:#f5f7fa;font-size:16px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.ce-calculator-buttons{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ce-calculator-button{width:100%;height:36px;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;font-size:14px;cursor:pointer;transition:all .2s;box-sizing:border-box}.ce-calculator-button:hover{background-color:#eef2fd;border-color:#c6d1ff}.ce-calculator-button:active{background-color:#e1e8ff}.ce-calculator-button.operator{background-color:#f5f7fa}.ce-calculator-button.operator:hover{background-color:#eef2fd}.ce-calculator-button.equal{background-color:var(--COLOR-HOVER, #5175f4);color:#fff;border-color:var(--COLOR-HOVER, #5175f4)}.ce-calculator-button.equal:hover{background-color:var(--COLOR-HOVER, #6a84ff);border-color:var(--COLOR-HOVER, #6a84ff)}.ce-calculator-button.utility{background-color:#f0f2f5}.ce-calculator-button.utility:hover{background-color:#e6e8eb}.ce-date-container{display:none;width:300px;overflow:hidden;left:0;right:0;position:absolute;z-index:1;color:#606266;background:#fff;border-radius:4px;padding:10px;-webkit-user-select:none;user-select:none;border:1px solid #e4e7ed;box-shadow:0 2px 12px #0000001a}.ce-date-container.active{display:block}.ce-date-wrap{display:none}.ce-date-wrap.active{display:block}.ce-date-title{display:flex;justify-content:center;align-items:center;text-align:center;color:#606266;font-size:16px}.ce-date-title>span{display:inline-block}.ce-date-title>span:not(.ce-date-title__now){font-family:cursive;cursor:pointer}.ce-date-title>span:not(.ce-date-title__now):hover{color:#5175f4}.ce-date-title .ce-date-title__pre-year,.ce-date-title .ce-date-title__pre-month{width:15%}.ce-date-title .ce-date-title__now{width:40%}.ce-date-title .ce-date-title__next-year,.ce-date-title .ce-date-title__next-month{width:15%}.ce-date-week{width:100%;display:flex;justify-content:center;margin-top:15px;padding-bottom:5px;border-bottom:1px solid #e4e7ed}.ce-date-week>span{list-style:none;width:calc(100%/7);text-align:center;color:#606266;font-size:14px}.ce-date-day{width:100%;display:flex;flex-wrap:wrap;align-items:center;margin-top:5px}.ce-date-day>div{width:calc(100%/7);height:40px;text-align:center;color:#606266;font-size:14px;cursor:pointer;line-height:40px;border-radius:4px}.ce-date-day>div:hover{color:#5175f4;opacity:.8}.ce-date-day>div.active{color:#5175f4;font-weight:700}.ce-date-day>div.disable{color:#c0c4cc}.ce-date-day>div.select{color:#fff;background-color:#5175f4}.ce-time-wrap{display:none;padding:10px;height:286px}.ce-time-wrap ::-webkit-scrollbar{width:0}.ce-time-wrap.active{display:flex}.ce-time-wrap li{list-style:none}.ce-time-wrap>li{width:33.3%;height:100%;text-align:center}.ce-time-wrap>li>span{transform:translateY(-5px);display:inline-block}.ce-time-wrap>li>ol{height:calc(100% - 20px);overflow-y:auto;border:1px solid #e2e2e2;position:relative}.ce-time-wrap>li:first-child>ol{border-right:0}.ce-time-wrap>li:last-child>ol{border-left:0}.ce-time-wrap>li>ol>li{line-height:30px;cursor:pointer;transition:all .3s}.ce-time-wrap>li>ol>li:hover{background-color:#eaeaea}.ce-time-wrap>li>ol>li.active{color:#fff;background:#5175f4}.ce-date-menu{width:100%;height:28px;display:flex;justify-content:flex-end;align-items:center;padding-top:10px;position:relative;border-top:1px solid #e4e7ed}.ce-date-menu button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;appearance:none;text-align:center;box-sizing:border-box;outline:none;transition:.1s;font-weight:500;-webkit-user-select:none;user-select:none;padding:7px 15px;font-size:12px;border-radius:3px;margin:0 0 0 10px}.ce-date-menu button:hover{color:#5175f4;border-color:#5175f4}.ce-date-menu button.ce-date-menu__time{border:1px solid transparent;position:absolute;left:0;margin-left:0}.ce-date-menu button.ce-date-menu__time:hover{color:#5175f4}.ce-block-item{position:absolute;z-index:0;background-color:#fff;border:1px solid rgb(235 236 240)}.ce-block-item .ce-resizer-selection{width:100%;height:100%}.ce-block-item .ce-resizer-mask{position:absolute;inset:0;z-index:1;background-color:transparent}.ce-table-tool__row{position:absolute;width:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed}.ce-table-tool__row .ce-table-tool__row__item{width:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__row .ce-table-tool__row__item:after{content:"";position:absolute;bottom:0;left:2px;width:8px;height:1px;background-color:#c0c6cf}.ce-table-tool__row .ce-table-tool__row__item:hover{background-color:#dadce0}.ce-table-tool__row .ce-table-tool__row__item:last-child:after{display:none}.ce-table-tool__quick__add{width:16px;height:16px;position:absolute;border-radius:50%;background-color:#e2e6ed;cursor:pointer}.ce-table-tool__quick__add:after{content:"+";color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%,-55%)}.ce-table-tool__select{width:16px;height:18px;position:absolute;border-radius:3px;cursor:pointer}.ce-table-tool__select:hover{background-color:#e2e6ed}.ce-table-tool__select:after{content:":::";color:#aaaaab;position:absolute;top:50%;left:50%;transform:translate(-75%,-50%) rotate(-90deg)}.ce-table-tool__col{position:absolute;height:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed;display:flex}.ce-table-tool__col .ce-table-tool__col__item{height:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__col .ce-table-tool__col__item:after{content:"";position:absolute;top:2px;left:-1px;width:1px;height:8px;z-index:1;background-color:#c0c6cf}.ce-table-tool__col .ce-table-tool__col__item:hover{background-color:#dadce0}.ce-table-tool__col .ce-table-tool__col__item:first-child:after{display:none}.ce-table-tool__row .ce-table-tool__row__item.active,.ce-table-tool__col .ce-table-tool__col__item.active{background-color:#c4d7fa}.ce-table-tool__col .ce-table-tool__anchor{right:-5px;width:10px;height:12px;z-index:9;position:absolute;cursor:col-resize}.ce-table-tool__row .ce-table-tool__anchor{bottom:-5px;left:0;width:12px;height:10px;z-index:9;position:absolute;cursor:row-resize}.ce-table-anchor__line{z-index:9;position:absolute;border:1px dotted #000000}.ce-table-tool__border{position:absolute;z-index:1;background:transparent;pointer-events:none}.ce-table-tool__border__row{position:absolute;cursor:row-resize;pointer-events:auto}.ce-table-tool__border__col{position:absolute;cursor:col-resize;pointer-events:auto}.ce-resizer-selection{position:absolute;border:1px solid;pointer-events:none}.ce-resizer-selection .resizer-handle{position:absolute;z-index:9;width:10px;height:10px;box-shadow:0 1px 4px #0000004d;border-radius:5px;border:2px solid #ffffff;box-sizing:border-box;pointer-events:initial}.ce-resizer-selection .handle-0{cursor:nw-resize}.ce-resizer-selection .handle-1{cursor:n-resize}.ce-resizer-selection .handle-2{cursor:ne-resize}.ce-resizer-selection .handle-3{cursor:e-resize}.ce-resizer-selection .handle-4{cursor:se-resize}.ce-resizer-selection .handle-5{cursor:s-resize}.ce-resizer-selection .handle-6{cursor:sw-resize}.ce-resizer-selection .handle-7{cursor:w-resize}.ce-resizer-size-view{display:flex;align-items:center;height:20px;white-space:nowrap;position:absolute;z-index:9;top:-30px;left:0;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px}.ce-resizer-size-view span{color:#fff;font-size:12px}.ce-resizer-image{position:absolute;opacity:.5}.ce-image-previewer{position:fixed;left:0;top:0;z-index:1000;width:100%;height:100%;overflow:hidden;background:#f2f4f7;display:flex;align-items:center;justify-content:center;animation:previewerAnimation .3s}@keyframes previewerAnimation{0%{opacity:.1}to{opacity:1}}.ce-image-previewer .image-close{width:24px;height:24px;display:inline-block;position:absolute;right:50px;top:30px;z-index:99;cursor:pointer;background:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M23.97%207l1.415%201.414-7.779%207.778%207.779%207.779-1.414%201.414-7.779-7.779-7.778%207.779L7%2023.97l7.778-7.779L7%208.414%208.414%207l7.778%207.778L23.971%207z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e") no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .image-close:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-container{position:relative}.ce-image-previewer .ce-image-container img{cursor:move;position:relative}.ce-image-previewer .ce-image-menu{height:50px;position:absolute;bottom:50px;z-index:99;display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i{width:32px;height:32px;margin:0 8px;cursor:pointer;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .ce-image-menu i:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-menu i.zoom-in{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%2014v-4h2v4h4v2h-4v4h-2v-4h-4v-2h4zm8.749%2010.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.zoom-out{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M22.749%2024.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010zm-5-11h10v2H10v-2z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.rotate{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M16%204c6.627%200%2012%205.373%2012%2012a11.97%2011.97%200%2001-4%208.944V23h-.86A9.968%209.968%200%200026%2016c0-5.523-4.477-10-10-10S6%2010.477%206%2016c0%205.185%203.947%209.449%209%209.95v2.009C8.84%2027.451%204%2022.291%204%2016%204%209.373%209.373%204%2016%204z'%20fill-rule='nonzero'/%3e%3cpath%20d='M19.879%2027.328l1.767-6.717%204.95%204.95z'/%3e%3c/g%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.original-size{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%204h24v24H4V4zm2%202v20h20V6H6zm4%205h2v10h-2V11zm5%202h2v2h-2v-2zm0%204h2v2h-2v-2zm5-6h2v10h-2V11z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-download{background-image:url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4.5%2015v3.5h15V15H21v5H3v-5h1.5zm8.232-11.226v9.196l4.05-4.05%201.06%201.06-5.834%205.834-5.833-5.833%201.06-1.06%203.998%203.996V3.774h1.5z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu .image-navigate{display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i.image-pre{background-image:url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.5%204.063L6.875%2010l5.625%205.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-next{background-image:url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.5%204.063L13.125%2010%207.5%2015.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu .image-count{color:#000;font-size:20px}.ce-image-previewer .ce-image-menu i.disabled{cursor:not-allowed;opacity:.5}.ce-contextmenu-container{z-index:9;position:fixed;display:none;padding:4px;overflow-x:hidden;overflow-y:auto;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.ce-contextmenu-content{display:flex;flex-direction:column}.ce-contextmenu-content .ce-contextmenu-sub-item:after{position:absolute;content:"";width:16px;height:16px;right:12px;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M0%200h16v16H0z'/%3e%3cg%20fill='%23767C85'%3e%3cpath%20d='M7%2012.243l-.707-.707%204.243-4.243.707.707z'/%3e%3cpath%20d='M6.293%204.464L7%203.757%2011.243%208l-.707.707z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-content .ce-contextmenu-item{min-width:140px;padding:0 32px 0 16px;height:30px;display:flex;align-items:center;white-space:nowrap;box-sizing:border-box;cursor:pointer}.ce-contextmenu-content .ce-contextmenu-item.hover{background:#1937580a}.ce-contextmenu-content .ce-contextmenu-item span{max-width:300px;font-size:12px;color:#3d4757;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.ce-contextmenu-content .ce-contextmenu-item span.ce-shortcut{color:#767c85;height:30px;flex:1;text-align:right;line-height:30px;margin-left:20px}.ce-contextmenu-content .ce-contextmenu-item i{width:16px;height:16px;vertical-align:middle;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;flex-shrink:0;margin-right:8px}.ce-contextmenu-divider{background-color:#e2e6ed;margin:4px 16px;height:1px}.ce-contextmenu-print{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M12%204h-1V2H5v2H4V2a1%201%200%20011-1h6a1%201%200%20011%201v2zm0%205v4a1%201%200%2001-1%201H5a1%201%200%2001-1-1V9h1v4h6V9h1z'/%3e%3cpath%20d='M12%2012v-1h2V5H2v6h2v1H2a1%201%200%2001-1-1V5a1%201%200%20011-1h12a1%201%200%20011%201v6a1%201%200%2001-1%201h-2z'/%3e%3cpath%20d='M3%208h10v1H3zm8-2h2v1h-2z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image{background-image:url("data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_0-公共_x2F_02工具栏_x2F_插入图片-16px-'%3e%3cg%20id='Group-19'%20transform='translate(1%201)'%3e%3cpath%20id='Combined-Shape'%20class='st0'%20d='M1%200h12c.6%200%201%20.4%201%201v11c0%20.6-.4%201-1%201H1c-.6%200-1-.4-1-1V1c0-.6.4-1%201-1zm0%201v11h12V1H1z'/%3e%3ccircle%20id='椭圆形'%20class='st0'%20cx='10'%20cy='4'%20r='1'/%3e%3cpath%20id='Path'%20class='st0'%20d='M8.5%2011.2l-4-4.1L1%2010.7V9.2c1.7-1.6%202.7-2.5%203-2.8.4-.5.7-.4%201%200L8.5%2010%2011%207.3c.4-.5.6-.5%201-.1l2%202.8v1.5l-2.5-3.4-3%203.1z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image-change{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cg%20transform='translate(2%204)'%20fill='%233D4757'%3e%3ccircle%20fill-rule='nonzero'%20cx='3'%20cy='1'%20r='1'/%3e%3cpath%20d='M7.473%208.223L3.47%204.107%200%207.667v-1.5C1.715%204.6%202.707%203.664%202.975%203.358c.402-.457.651-.39%201.042%200L7.473%207%209.96%204.349c.414-.462.62-.462%201.011-.071L13%207.06v1.5l-2.51-3.41-3.017%203.072z'/%3e%3c/g%3e%3cpath%20d='M6%201.5H1.5v12h13v-4V13a.5.5%200%2001-.5.5H2a.5.5%200%2001-.5-.5V2a.5.5%200%2001.5-.5h4zm8.5%208V6l-.5.5h1l-.5-.5v3.5zM6%201.5h4L9.5%201v1l.5-.5H6z'%20stroke='%233D4757'/%3e%3cpath%20d='M13.085%201.316l-3.814%204a1%201%200%20001.458%201.368l3.815-4a1%201%200%2010-1.459-1.368z'%20fill='%233D4757'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%233D4757'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M4%207v1h2V7zm-3%20.5L4%205v5zM1%201h12v1H1zm0%2012h12v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-top-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M8%205H7v3h1zm-.5-3L10%205H5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='10.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-bottom-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M7%2011h1V8H7zm.5%203L5%2011h5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='2.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-left-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M11%207v1h3V7zm-3%20.5L11%205v5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%204%207.5)'%20x='-2'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-right-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M5%208V7H2v1zm3-.5L5%2010V5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%2012%207.5)'%20x='6'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%206.5h6v2h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M2%2012h11v1H2zM2%202h11v1H2zm.63%203L7%209.35l-.635.65L2%205.63z'/%3e%3cpath%20fill='%233D4757'%20d='M2%209.363L6.355%205%207%205.707%202.695%2010z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M1%2013h12v1H1zM1%201h12v1H1zm0%204h1v1H1zm1%201h1v1H2zm1%201h1v1H3zm1-1h1v1H4zm1-1h1v1H5zM4%208h1v1H4zM2%208h1v1H2zm3%201h1v1H5zM1%209h1v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M5.5%207.5v-6h4v6z'/%3e%3cpath%20fill='%233D4757'%20d='M13%2015V3h1v12zM1%2015V3h1v12zm4%200v-1h1v1zm1-1v-1h1v1zm1-1v-1h1v1zm-1-1v-1h1v1zm-1-1v-1h1v1zm3%201v-1h1v1zm0%202v-1h1v1zm1-3v-1h1v1zm0%204v-1h1v1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-table{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M14%2013h-1v-3H2v3H1v-3a1%201%200%20011-1h11a1%201%200%20011%201v3z'%20fill-rule='nonzero'/%3e%3cpath%20d='M5.625%202L10%206.375%209.375%207%205%202.625z'/%3e%3cpath%20d='M5%206.375L9.375%202l.625.625L5.625%207z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M8%207.5L10%206v3zm-1%200L5%206v3z'/%3e%3cpath%20d='M9%207h3v1H9zM3%207h3v1H3z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cancel-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M3%207.5L5%206v3zm9%200L10%206v3z'/%3e%3cpath%20d='M4%207h3v1H4zm4%200h3v1H8z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-vertical-align{background-image:url("data:image/svg+xml,%3csvg%20height='16'%20viewBox='0%200%2016%2016'%20width='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2zm0-3h8v1H2zm0-3h12v1H2zm0-6h12v1H2zm0%203h8v1H2z'%20fill='%233d4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%208H7v6h1zm-.5-3L10%208H5zM2%203h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-middle{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%2012H7v3h1zm-.5-3l2.5%203H5zM7%203h1V0H7zm.5%203L5%203h5zM2%207h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%209h1V3H7zm.5%203L5%209h5zM2%2013h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-border-all{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill='%233D4757'%20d='M3%208h11v1H3z'/%3e%3cpath%20fill='%233D4757'%20d='M9%203v11H8V3z'/%3e%3c/svg%3e")}.ce-contextmenu-border-empty{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-dash{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23000000'/%3e%3c/svg%3e")}.ce-contextmenu-border-external{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-internal{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-contextmenu-border-td{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20d='M8.5%202.5%20v6%20h-6'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%203%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-left{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M3%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%2014%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-right{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M14%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-forward{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M14%203%20l-11%2011'%20/%3e%3c/svg%3e")}.ce-contextmenu-border-td-back{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M3%203%20l11%2011'%20/%3e%3c/svg%3e")}.ce-hyperlink-popup{background:#fff;box-shadow:0 2px 12px #626b8433;border-radius:2px;color:#3d4757;padding:12px 16px;position:absolute;z-index:1;text-align:center;display:none}.ce-hyperlink-popup a{min-width:100px;max-width:300px;font-size:12px;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;color:#00f}.ce-zone-indicator>div{padding:3px 6px;color:#000;font-size:12px;background:#dae7fc;position:absolute;transform-origin:0 0}.ce-zone-indicator-border__top,.ce-zone-indicator-border__bottom,.ce-zone-indicator-border__left,.ce-zone-indicator-border__right{display:block;position:absolute;z-index:0}.ce-zone-indicator-border__top{border-top:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__bottom{border-top:2px dashed rgb(238,238,238);width:100%}.ce-zone-indicator-border__left{border-left:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__right{border-right:2px dashed rgb(238,238,238)}.ce-zone-tip{display:none;align-items:center;height:30px;white-space:nowrap;position:fixed;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px;z-index:9;transition:all .3s;outline:none;-webkit-user-select:none;user-select:none;pointer-events:none;transform:translate(10px,10px)}.ce-zone-tip.show{display:flex}.ce-zone-tip span{color:#fff;font-size:12px}.ce-inputarea{min-width:60px!important;min-height:0;margin:0;padding:0;left:0;top:0;letter-spacing:0;font-size:12px;position:absolute;z-index:-1;outline:none;resize:none;border:none;overflow:hidden;color:transparent;-webkit-user-select:none;user-select:none;caret-color:transparent;background-color:transparent;white-space:pre}.ce-cursor{width:1px;height:20px;left:0;right:0;position:absolute;outline:none;background-color:#000;pointer-events:none}.ce-cursor.ce-cursor--animation{animation-duration:1s;animation-iteration-count:infinite;animation-name:cursorAnimation}@keyframes cursorAnimation{0%{opacity:1}13%{opacity:0}50%{opacity:0}63%{opacity:1}to{opacity:1}}.ce-float-image{position:absolute;opacity:.5;pointer-events:none}.ce-button-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:flex;justify-content:center;align-items:center;z-index:1000}.ce-button-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-button-input-modal__textarea{width:100%;min-height:100px;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;line-height:1.5;resize:vertical;outline:none;box-sizing:border-box;font-family:inherit}.ce-button-input-modal__textarea:focus{border-color:#5175f4}.ce-button-input-modal__textarea::placeholder{color:#c0c4cc}.ce-button-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-input-modal__cancel,.ce-button-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-button-edit-modal{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:flex;justify-content:center;align-items:center;z-index:1000}.ce-button-edit-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-edit-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:16px}.ce-button-edit-modal__form{display:flex;flex-direction:column;gap:12px}.ce-button-edit-modal__field{display:flex;align-items:center;gap:8px}.ce-button-edit-modal__field label{min-width:80px;font-size:13px;color:#606266}.ce-button-edit-modal__field input{flex:1;padding:8px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-button-edit-modal__field input:focus{border-color:#5175f4}.ce-button-edit-modal__field input::placeholder{color:#c0c4cc}.ce-button-edit-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-edit-modal__cancel,.ce-button-edit-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-edit-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-edit-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-edit-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-number-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:flex;justify-content:center;align-items:center;z-index:1000}.ce-number-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:300px;max-width:400px;box-shadow:0 4px 20px #00000026}.ce-number-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-number-input-modal__hint{font-size:12px;color:#909399;margin-bottom:12px}.ce-number-input-modal__input{width:100%;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-number-input-modal__input:focus{border-color:#5175f4}.ce-number-input-modal__input::placeholder{color:#c0c4cc}.ce-number-input-modal__error{font-size:12px;color:#f56c6c;margin-top:8px}.ce-number-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-number-input-modal__cancel,.ce-number-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-number-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-number-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-number-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.tooth-position-edit-modal,.tooth-position-create-modal{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000}.tooth-position-modal__mask{position:absolute;top:0;left:0;width:100%;height:100%;background:#00000080}.tooth-position-modal__container{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background:#fff;border-radius:8px;box-shadow:0 4px 12px #00000026;min-width:400px;max-width:90vw}.tooth-position-modal__header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #e8e8e8}.tooth-position-modal__header span{font-size:16px;font-weight:500;color:#333}.tooth-position-modal__close{font-size:20px;cursor:pointer;color:#999;line-height:1}.tooth-position-modal__close:hover{color:#333}.tooth-position-modal__content{padding:20px;max-height:60vh;overflow-y:auto}.tooth-section{margin-bottom:20px}.tooth-section:last-child{margin-bottom:0}.tooth-section-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px;padding-left:8px;border-left:3px solid #1890ff}.tooth-row{display:flex;align-items:center;margin-bottom:8px}.tooth-row:last-child{margin-bottom:0}.tooth-row-label{width:30px;font-size:13px;color:#666}.tooth-buttons{display:flex;gap:8px;flex-wrap:wrap}.letter-buttons{margin-left:30px}.tooth-checkbox{display:flex;align-items:center;cursor:pointer}.tooth-checkbox input{display:none}.tooth-checkbox span{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid #d9d9d9;border-radius:4px;background:#f5f5f5;font-size:14px;color:#333;transition:all .2s}.tooth-checkbox input:checked+span{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-checkbox:hover span{border-color:#1890ff}.tooth-position-modal__footer{display:flex;justify-content:flex-end;gap:10px;padding:16px 20px;border-top:1px solid #e8e8e8}.tooth-position-modal__footer .btn-cancel,.tooth-position-modal__footer .btn-confirm{padding:8px 20px;font-size:14px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.tooth-position-modal__footer .btn-cancel:hover{color:#1890ff;border-color:#1890ff}.tooth-position-modal__footer .btn-confirm{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-position-modal__footer .btn-confirm:hover{background:#40a9ff;border-color:#40a9ff}.tooth-grid-container{display:flex;flex-direction:column;align-items:center;padding:15px 20px;background:#fafafa;border-radius:8px;margin-bottom:15px;position:relative}.tooth-quick-buttons{display:flex;gap:6px;margin-bottom:16px}.tooth-quick-buttons-left{display:flex;flex-direction:column;gap:6px;flex:1}.tooth-quick-buttons-row{display:flex;gap:6px}.tooth-quick-btn{padding:6px 12px;font-size:12px;border:1px solid #d9d9d9;border-radius:4px;cursor:pointer;background:#fff;color:#333;transition:all .2s;white-space:nowrap}.tooth-quick-btn:hover{border-color:#1890ff;color:#1890ff}.tooth-quick-btn.selected{background:#0ff;border-color:#0ff;color:#fff}.tooth-quick-btn--clear{background:#ff6b6b;border-color:#ff6b6b;color:#fff}.tooth-quick-btn--clear:hover{background:#ff5252;border-color:#ff5252;color:#fff}.tooth-grid-container:before{content:"";position:absolute;left:50%;top:20px;bottom:20px;width:2px;background:#000;transform:translate(-50%);z-index:1}.tooth-grid-container:after{content:"";position:absolute;left:20px;right:20px;top:50%;height:2px;background:#000;transform:translateY(-50%);z-index:1}.tooth-grid-letter-row,.tooth-grid-number-row{display:flex;align-items:center;justify-content:center;position:relative;z-index:2}.tooth-grid-half{display:flex;align-items:center;justify-content:center;gap:4px}.tooth-grid-half.left{justify-content:flex-end;padding-right:15px}.tooth-grid-half.right{justify-content:flex-start;padding-left:15px}.tooth-grid-divider-v,.tooth-grid-divider-h{display:none}.tooth-grid-number-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;transition:all .2s;box-sizing:border-box;border:1px solid #d9d9d9;border-radius:12px}.upper-number-row .tooth-grid-number-item{border-top:none;border-radius:0 0 12px 12px}.lower-number-row .tooth-grid-number-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-number-item[data-value="1"],.tooth-grid-number-item[data-value="2"],.tooth-grid-number-item[data-value="3"]{border-radius:50px}.upper-number-row .tooth-grid-number-item[data-value="1"],.upper-number-row .tooth-grid-number-item[data-value="2"],.upper-number-row .tooth-grid-number-item[data-value="3"]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-number-row .tooth-grid-number-item[data-value="1"],.lower-number-row .tooth-grid-number-item[data-value="2"],.lower-number-row .tooth-grid-number-item[data-value="3"]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-number-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-number-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;transition:all .2s;box-sizing:border-box;border-radius:12px}.upper-letter-row .tooth-grid-letter-item{border-top:none;border-radius:0 0 12px 12px}.lower-letter-row .tooth-grid-letter-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-letter-item[data-value=A],.tooth-grid-letter-item[data-value=B],.tooth-grid-letter-item[data-value=C]{border-radius:50px}.upper-letter-row .tooth-grid-letter-item[data-value=A],.upper-letter-row .tooth-grid-letter-item[data-value=B],.upper-letter-row .tooth-grid-letter-item[data-value=C]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-letter-row .tooth-grid-letter-item[data-value=A],.lower-letter-row .tooth-grid-letter-item[data-value=B],.lower-letter-row .tooth-grid-letter-item[data-value=C]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-letter-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-letter-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-row.hidden,.tooth-grid-number-row.hidden{display:none}.tooth-grid-letter-row{margin-bottom:8px}.tooth-grid-number-row.upper-number-row{margin-bottom:15px}.tooth-grid-number-row.lower-number-row{margin-top:15px}.tooth-grid-letter-row.lower-letter-row{margin-top:8px}.tooth-preview-section{padding-top:10px;border-top:1px solid #e8e8e8}.tooth-preview-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.tooth-preview-wrapper{display:flex;gap:15px}.tooth-preview-container{display:flex;justify-content:center;align-items:center;padding:10px;background:#fafafa;border-radius:8px;flex:1;min-height:60px}.tooth-preview-grid{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;gap:0;width:100%;min-height:70px;position:relative}.tooth-preview-grid:before{content:"";position:absolute;left:50%;top:0;bottom:0;width:1px;background:#000;transform:translate(-50%)}.tooth-preview-grid:after{content:"";position:absolute;top:50%;left:0;right:0;height:1px;background:#000;transform:translateY(-50%)}.tooth-preview-quadrant{display:flex;align-items:center;padding:5px 10px;font-size:12px;flex-wrap:wrap;gap:4px;justify-content:center}.tooth-preview-upper-left{justify-content:flex-end}.tooth-preview-upper-right{justify-content:flex-start}.tooth-preview-lower-left{justify-content:flex-end}.tooth-preview-lower-right{justify-content:flex-start}.tooth-preview-tooth{position:relative;display:inline;margin:0 4px}.tooth-preview-tooth-value{font-size:12px}.tooth-preview-tooth-value--deciduous{font-size:10px}.tooth-preview-tooth-bracket{font-size:12px}.tooth-preview-supernumerary{font-size:9px;vertical-align:super;margin:0 1px}.tooth-preview-surface{font-size:9px;vertical-align:super;margin-left:1px}.tooth-extra-panel{width:100px;display:flex;flex-direction:column;gap:10px}.tooth-surface-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-surface-title{font-size:12px;font-weight:500;color:#333;margin-bottom:8px;text-align:center}.tooth-surface-grid{display:flex;flex-direction:column;gap:4px;align-items:center}.tooth-surface-row{display:flex;gap:4px;justify-content:center}.tooth-surface-item{width:30px;height:30px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px dashed #d9d9d9;border-radius:5px;transition:all .2s;box-sizing:border-box}.tooth-surface-item--indent{margin-left:17px}.tooth-surface-item:hover{border-color:#1890ff;color:#1890ff}.tooth-surface-item.selected{background:#1890ff;border-color:#1890ff;border-style:solid;color:#fff}.tooth-supernumerary-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-supernumerary-title{font-size:12px;font-weight:500;color:#333;margin-bottom:4px;text-align:center}.tooth-supernumerary-hint{font-size:10px;color:#999;font-weight:400}.tooth-supernumerary-grid{display:flex;gap:8px;justify-content:center;margin-top:8px}.tooth-supernumerary-item{width:30px;height:35px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;border-bottom:none;border-radius:50px;transition:all .2s;box-sizing:border-box}.tooth-supernumerary-item:hover{border-color:#1890ff;color:#1890ff}.tooth-supernumerary-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.dialog-mask{position:fixed;left:0;top:0;width:100%;height:100%;opacity:.5;background:#000;z-index:99}.dialog-container{position:fixed;inset:0;overflow:auto;z-index:999;margin:0;display:flex;justify-content:center;align-items:center}.dialog{position:absolute;padding:0 30px 30px;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.dialog-title{position:relative;border-bottom:1px solid #e2e6ed;margin-bottom:30px;height:60px;display:flex;align-items:center;justify-content:space-between}.dialog-title i{width:16px;height:16px;cursor:pointer;display:inline-block;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.9%208.192l4.242%204.243-.707.707L8.192%208.9%203.95%2013.142l-.707-.707%204.242-4.243L3.243%203.95l.707-.707%204.242%204.242%204.243-4.242.707.707L8.9%208.192z'%20fill='%236A6A6A'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.dialog-option__item{margin-bottom:18px;display:flex;align-items:center;justify-content:space-between}.dialog-option__item span{margin-right:12px;font-size:14px;color:#3d4757;position:relative}.dialog-option__item input,.dialog-option__item textarea,.dialog-option__item select{width:276px;height:30px;border-radius:2px;border:1px solid #d3d3d3;min-height:30px;padding:5px;box-sizing:border-box;outline:none;appearance:none;-webkit-user-select:none;user-select:none;font-family:inherit}.dialog-option__item input:focus,.dialog-option__item textarea:focus{border-color:#4991f2}.dialog-option__item--require:before{content:"*";color:#f56c6c;margin-right:4px;position:absolute;left:-8px}.dialog-menu{display:flex;align-items:center;justify-content:flex-end}.dialog-menu button{position:relative;display:inline-block;border:1px solid #e2e6ed;border-radius:2px;background:#fff;line-height:22px;padding:0 16px;white-space:nowrap;cursor:pointer}.dialog-menu button:hover{background:#1937580a}.dialog-menu__cancel{margin-right:16px}.dialog-menu button[type=submit]{color:#fff;background:#4991f2;border-color:#4991f2}.dialog-menu button[type=submit]:hover{background:#5b9cf3;border-color:#5b9cf3}.dialog-radio-group{display:flex;flex-direction:column;gap:8px}.dialog-radio-group--horizontal{flex-direction:row;gap:16px}.dialog-radio-item{display:flex;align-items:center;cursor:pointer;font-size:14px;color:#3d4757}.dialog-radio-item input[type=radio]{width:16px;height:16px;margin:0 6px 0 0;cursor:pointer;appearance:auto}.dialog-radio-item span{margin:0}`)),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
-
(function(l,Qe){typeof exports=="object"&&typeof module<"u"?Qe(exports):typeof define=="function"&&define.amd?define(["exports"],Qe):(l=typeof globalThis<"u"?globalThis:l||self,Qe(l["canvas-editor"]={}))})(this,(function(l){"use strict";const Qe="0.6.
|
|
2
|
+
(function(l,Qe){typeof exports=="object"&&typeof module<"u"?Qe(exports):typeof define=="function"&&define.amd?define(["exports"],Qe):(l=typeof globalThis<"u"?globalThis:l||self,Qe(l["canvas-editor"]={}))})(this,(function(l){"use strict";const Qe="0.6.4";l.MaxHeightRatio=void 0,(function(o){o.HALF="half",o.ONE_THIRD="one-third",o.QUARTER="quarter"})(l.MaxHeightRatio||(l.MaxHeightRatio={})),l.NumberType=void 0,(function(o){o.ARABIC="arabic",o.CHINESE="chinese"})(l.NumberType||(l.NumberType={})),l.ImageDisplay=void 0,(function(o){o.INLINE="inline",o.BLOCK="block",o.SURROUND="surround",o.FLOAT_TOP="float-top",o.FLOAT_BOTTOM="float-bottom"})(l.ImageDisplay||(l.ImageDisplay={})),l.LocationPosition=void 0,(function(o){o.BEFORE="before",o.AFTER="after",o.OUTER_BEFORE="outer-before",o.OUTER_AFTER="outer-after"})(l.LocationPosition||(l.LocationPosition={})),l.FlexDirection=void 0,(function(o){o.ROW="row",o.COLUMN="column"})(l.FlexDirection||(l.FlexDirection={}));const _="",Ni=`
|
|
3
3
|
`,fo=" ",Fi=" ",Vr=["·","、",":",":",",",",",".","。",";",";","?","?","!","!"],yi={[l.MaxHeightRatio.HALF]:1/2,[l.MaxHeightRatio.ONE_THIRD]:1/3,[l.MaxHeightRatio.QUARTER]:1/4},To={ENGLISH:"A-Za-z",NUMBER:"0-9.$¥",SPANISH:"A-Za-zÁÉÍÓÚáéíóúÑñÜü",FRENCH:"A-Za-zÀÂÇàâçÉéÈèÊêËëÎîÏïÔôÙùÛûŸÿ",GERMAN:"A-Za-zÄäÖöÜüß",RUSSIAN:"А-Яа-яЁё",PORTUGUESE:"A-Za-zÁÉÍÓÚáéíóúÃÕãõÇç",ITALIAN:"A-Za-zÀàÈèÉéÌìÍíÎîÓóÒòÙù",DUTCH:"A-Za-zÀàÁáÂâÄäÈèÉéÊêËëÌìÍíÎîÏïÓóÒòÔôÖöÙùÛûÜü",SWEDISH:"A-Za-zÅåÄäÖö",GREEK:"ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω"},Yr="中";l.RowFlex=void 0,(function(o){o.LEFT="left",o.CENTER="center",o.RIGHT="right",o.ALIGNMENT="alignment",o.JUSTIFY="justify"})(l.RowFlex||(l.RowFlex={}));const mo=/[0-9.]/,Dr=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,Ur=/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,wr=new RegExp(`${Ur.source}|${Dr.source}`,"g"),Zr=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,po=new RegExp(`^[${_}
|
|
4
4
|
]`),Qr=/[^0-9\+\-\.eE,]/,vr=/\s/;function Kr(o,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{o.apply(this,n)},t)}}function Hr(o,t){let e=0,n;return function(...i){const r=Date.now();r-e>=t?(window.clearTimeout(n),o.apply(this,i),e=r):(window.clearTimeout(n),n=window.setTimeout(()=>{o.apply(this,i),e=r},t))}}function Lo(o,t){if(!o||typeof o!="object")return o;let e={};return Array.isArray(o)?e=o.map(n=>Lo(n,t)):Object.keys(o).forEach(n=>{t.includes(n)||(e[n]=Lo(o[n],t))}),e}function at(o){if(typeof structuredClone=="function")return structuredClone(o);if(!o||typeof o!="object")return o;let t={};return Array.isArray(o)?t=o.map(e=>at(e)):Object.keys(o).forEach(e=>{t[e]=at(o[e])}),t}function Io(o){return o&&o.nodeType===1&&o.tagName.toLowerCase()==="body"}function Wi(o,t,e){if(o&&!Io(o))for(o=o;o;){if(!t||t(o)||Io(o))return t&&!t(o)&&Io(o)?null:o;o=o.parentNode}return null}function lt(){function o(){return((1+Math.random())*65536|0).toString(16).substring(1)}return o()+o()+"-"+o()+"-"+o()+"-"+o()+"-"+o()+o()+o()}function ct(o){const t=[];if(Intl.Segmenter){const n=new Intl.Segmenter().segment(o);for(const{segment:i}of n)t.push(i)}else{const e=new Map;for(const i of o.matchAll(wr))e.set(i.index,i[0]);let n=0;for(;n<o.length;){const i=e.get(n);i?(t.push(i),n+=i.length):(t.push(o[n]),n++)}}return t}function bi(o,t){const e=document.createElement("a");e.href=o,e.download=t,e.click()}function _r(o,t){xr(3,o,t)}function xr(o,t,e){let n=0,i=0;const r=function(s){n=new Date().getTime()-i<300?n+1:0,i=new Date().getTime(),n>=o-1&&(e(s),n=0)};t.addEventListener("click",r)}function Dn(o){return Object.prototype.toString.call(o)==="[object Object]"}function Po(o){return Array.isArray(o)}function Mo(o){return Object.prototype.toString.call(o)==="[object Number]"}function Gr(o){return Object.prototype.toString.call(o)==="[object String]"}function Vi(o,t){if(Dn(o)&&Dn(t)){const e=t;for(const[n,i]of Object.entries(o))e[n]?e[n]=Vi(i,e[n]):e[n]=i}else Po(o)&&Po(t)&&t.push(...o);return t}function Oo(o){if(typeof queueMicrotask=="function"){queueMicrotask(()=>{o()});return}if(typeof Promise<"u"){Promise.resolve().then(()=>{o()});return}setTimeout(()=>{o()},0)}function Ar(o){const t=["零","一","二","三","四","五","六","七","八","九"],e=["","十","百","千","万","十","百","千","亿","十","百","千","万","十","百","千","亿"];if(!o||isNaN(o))return"零";const n=o.toString().split("");let i="";for(let r=0;r<n.length;r++){const s=n.length-1-r;i=`${e[r]}${i}`,i=`${t[Number(n[s])]}${i}`}return i=i.replace(/零(千|百|十)/g,"零").replace(/十零/g,"十"),i=i.replace(/零+/g,"零"),i=i.replace(/零亿/g,"亿").replace(/零万/g,"万"),i=i.replace(/亿万/g,"亿"),i=i.replace(/零+$/,""),i=i.replace(/^一十/g,"十"),i}function Ye(o,t,e){for(let n=0;n<o.length;n++){const i=o[n],r=t[i];r!==void 0?e[i]=r:delete e[i]}}function Yi(o,t){if(!(!t.length||!o.length))for(let e=o.length-1;e>=0;e--)t.includes(o[e])&&o.splice(e,1)}function Dt(o,t){const e={};for(const n in o)t.includes(n)&&(e[n]=o[n]);return e}function ie(o,t){const e={};for(const n in o)t.includes(n)||(e[n]=o[n]);return e}function kr(o){const e=new TextEncoder().encode(o),n=Array.from(e,r=>String.fromCharCode(r));return window.btoa(n.join(""))}function Jr(o){let t=o.parentElement;for(;t;){const n=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"))return t;t=t.parentElement}return document.documentElement}function Di(o,t){return o.length!==t.length?!1:!o.some(e=>!t.includes(e))}function Br(o,t){if(!Dn(o)||!Dn(t))return!1;const e=Object.keys(o),n=Object.keys(t);return e.length!==n.length?!1:!e.some(i=>t[i]!==o[i])}function $r(o,t){const e=o.x,n=o.x+o.width,i=o.y,r=o.y+o.height,s=t.x,a=t.x+t.width,c=t.y,d=t.y+t.height;return!(e>a||n<s||i>d||r<c)}function Ui(o){return o==null}function Un(o){return o.replace(/\r\n|\r/g,`
|
|
5
5
|
`)}function wi(o,t,e=0){const n=Math.max(0,Math.floor(e));if(n>=o.length)return typeof t=="string"&&t===""?{index:o.length,length:0}:{index:-1,length:0};if(typeof t=="string"){if(t==="")return{index:n,length:0};const c=o.indexOf(t,n);return c===-1?{index:-1,length:0}:{index:c,length:t.length}}const i=t.flags,r=i.includes("g")?i:i+"g",s=new RegExp(t.source,r);s.lastIndex=n;const a=s.exec(o);return a?{index:a.index,length:a[0].length}:{index:-1,length:0}}function Zi(o,t){if(!t){o.scrollTop=0;return}const e=[];let n=t.offsetParent;for(;n&&o!==n&&o.contains(n);)e.push(n),n=n.offsetParent;const i=t.offsetTop+e.reduce((c,d)=>c+d.offsetTop,0),r=i+t.offsetHeight,s=o.scrollTop,a=s+o.clientHeight;i<s?o.scrollTop=i:r>a&&(o.scrollTop=r-o.clientHeight)}function bt(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function zr(o,t){return o.performance.enabled&&t>=o.performance.threshold}function Co(o,t,e,n=[],i){if(!zr(o,e))return;const r={duration:Number(e.toFixed(2)),breakdown:n.map(s=>({label:s.label,duration:Number(s.duration.toFixed(2))})),...i};console.log(`[canvas-editor perf] ${t}`,r)}const jr=12,qr={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},de="editor-component",z="ce",Tn=`${z}-clipboard`,So={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1,inputTraceEnabled:!0,deleteTraceEnabled:!0}};var Zt;(function(o){o.UP="top",o.DOWN="down",o.LEFT="left",o.RIGHT="right"})(Zt||(Zt={}));const ve=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),tl=typeof navigator<"u"&&/iPad|iPhone/.test(navigator.userAgent),el=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),nl=typeof navigator<"u"&&/Firefox/.test(navigator.userAgent);l.ElementType=void 0,(function(o){o.TEXT="text",o.TEXTFIELD="TextField",o.BUTTON="button",o.IMAGE="image",o.TABLE="table",o.HYPERLINK="hyperlink",o.SUPERSCRIPT="superscript",o.SUBSCRIPT="subscript",o.SEPARATOR="separator",o.PAGE_BREAK="pageBreak",o.CONTROL="control",o.AREA="area",o.CHECKBOX="checkbox",o.RADIO="radio",o.LATEX="latex",o.TAB="tab",o.DATE="date",o.BLOCK="block",o.TITLE="title",o.LIST="list",o.SPLIT_TAG="splitTag",o.LABEL="label",o.MENSTRUAL_HISTORY="menstrualHistory",o.FETAL_HEART_POSITION="fetalHeartPosition",o.TOOTH_POSITION="toothPosition",o.SPECIAL_SYMBOLS="specialSymbols",o.MACRO="macro",o.CUSTOM_MACRO="customMacro",o.REUSABLE_ITEM="reusableItem",o.SUB_TEMPLATE="subTemplate"})(l.ElementType||(l.ElementType={}));const Re=["bold","color","highlight","font","size","italic","underline","strikeout","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime"],Bt=["rowFlex","rowMargin"],ol=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","areaId","hyperlinkId","dateId","dateFormat","groupIds","rowMargin","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime"],il=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","dashArray","trList","tdPadding","tableToolDisabled","borderType","borderColor","borderWidth","borderExternalWidth","translateX","width","height","url","colgroup","valueList","control","checkbox","radio","dateFormat","block","level","title","listType","listStyle","listWrap","groupIds","conceptId","imgDisplay","imgFloatPosition","imgToolDisabled","imgPreviewDisabled","imgCrop","imgCaption","textDecoration","extension","externalId","areaId","area","hide","label","labelId","lineWidth","deletePerson","newElEditPerson","deleteTime","newElEditTime","dictCode","macroConfig","menstrualData","menstrualHistoryId","fetalHeartData","fetalHeartPositionId","toothPositionData","toothPositionId","reusableItemConfig","templateId","subTemplateExpanded"],sl=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],Be=["tdId","trId","tableId"],Eo=["level","titleId","title"],mn=["listId","listType","listStyle"],Xo=["control","controlId","controlComponent"],Gt=["font","size","bold","highlight","italic","strikeout","deletePerson","newElEditPerson","deleteTime","color","newElEditTime"],Ke=["areaId","area"],No=[...Be,...Eo,...mn,...Ke],$t=[l.ElementType.TEXT,l.ElementType.HYPERLINK,l.ElementType.SUBSCRIPT,l.ElementType.SUPERSCRIPT,l.ElementType.CONTROL,l.ElementType.DATE],rl=[l.ElementType.IMAGE,l.ElementType.LATEX],ll=[l.ElementType.BLOCK,l.ElementType.PAGE_BREAK,l.ElementType.SEPARATOR,l.ElementType.TABLE],al=["HR","TABLE","UL","OL"],cl=[l.ElementType.TITLE,l.ElementType.LIST];class $e{static sandbox=["allow-scripts","allow-same-origin"];static allow=["fullscreen"];element;constructor(t){this.element=t}_defineIframeProperties(t){Object.defineProperties(t,{parent:{get:()=>null},__POWERED_BY_CANVAS_EDITOR__:{get:()=>!0}})}render(t){const{iframeBlock:e}=this.element.block||{},n=document.createElement("iframe");n.setAttribute("data-id",this.element.id),n.sandbox.add(...e?.sandbox||$e.sandbox),n.setAttribute("allow",[e?.allow||$e.allow].join(" ")),n.style.border="none",n.style.width="100%",n.style.height="100%",e?.src?n.src=e.src:e?.srcdoc&&(n.srcdoc=e.srcdoc),t.append(n),this._defineIframeProperties(n.contentWindow)}}class Qi{draw;options;imageCache;container;floatImageContainer;floatImage;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.imageCache=new Map,this.floatImageContainer=null,this.floatImage=null}getOriginalMainImageList(){const t=[],e=n=>{for(const i of n)if(i.type===l.ElementType.TABLE){const r=i.trList;for(let s=0;s<r.length;s++){const a=r[s];for(let c=0;c<a.tdList.length;c++){const d=a.tdList[c];e(d.value)}}}else i.type===l.ElementType.IMAGE&&t.push(i)};return e(this.draw.getOriginalMainElementList()),t}_countImagesBeforeTarget(t,e){let n=0;for(const i of t){if(i===e)break;if(i.type===l.ElementType.TABLE){const r=i.trList;for(const s of r)for(const a of s.tdList)n+=this._countImagesBeforeTarget(a.value,e)}else i.type===l.ElementType.IMAGE&&n++}return n}createFloatImage(t){const{scale:e}=this.options;let n=this.floatImageContainer,i=this.floatImage;n||(n=document.createElement("div"),n.classList.add(`${z}-float-image`),this.container.append(n),this.floatImageContainer=n),i||(i=document.createElement("img"),n.append(i),this.floatImage=i),n.style.display="none",i.style.width=`${t.width*e}px`,i.style.height=`${t.height*e}px`;const r=this.draw.getHeight(),s=this.draw.getPageGap(),a=this.draw.getPageNo()*(r+s),c=t.imgFloatPosition;n.style.left=`${c.x*e}px`,n.style.top=`${a+c.y*e}px`,i.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const n=parseFloat(this.floatImageContainer.style.left)+t,i=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${n}px`,this.floatImageContainer.style.top=`${i}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=(t-Math.ceil(t/8)*8)/2,r=(e-Math.ceil(e/8)*8)/2,s=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
|
|
@@ -60,29 +60,29 @@ trailer
|
|
|
60
60
|
%%EOF
|
|
61
61
|
`,c+d}boxes(t){t||(t={});const[e,n,i,r]=this.resolveScale(t),s=[];for(let a=0;a<this._tree.chld.length;a++){const{x:c,y:d,w:R,h:u}=this._tree.chld[a].bbox;s.push({x:e+c*i,y:n+d*r,w:R*i,h:u*r})}return s}box(t){t||(t={});const[e,n,i,r]=this.resolveScale(t);return{x:e+this._tree.bbox.x*i,y:n+this._tree.bbox.y*r,w:this._tree.bbox.w*i,h:this._tree.bbox.h*r}}}class Hi extends Qi{static convertLaTextToSVG(t){return new pl(t).svg({SCALE_X:10,SCALE_Y:10,MARGIN_X:0,MARGIN_Y:0})}render(t,e,n,i){const{scale:r}=this.options,s=e.width*r,a=e.height*r;if(this.imageCache.has(e.value)){const c=this.imageCache.get(e.value);t.drawImage(c,n,i,s,a)}else{const c=new Promise((d,R)=>{const u=new Image;u.src=e.laTexSVG,u.onload=()=>{t.drawImage(u,n,i,s,a),this.imageCache.set(e.value,u),d(e)},u.onerror=h=>{R(h)}});this.addImageObserver(c)}}}l.ListType=void 0,(function(o){o.UL="ul",o.OL="ol"})(l.ListType||(l.ListType={}));var He;(function(o){o.DISC="disc",o.CIRCLE="circle",o.SQUARE="square",o.CHECKBOX="checkbox"})(He||(He={}));var _i;(function(o){o.DECIMAL="decimal"})(_i||(_i={})),l.ListStyle=void 0,(function(o){o.DISC="disc",o.CIRCLE="circle",o.SQUARE="square",o.DECIMAL="decimal",o.CHECKBOX="checkbox"})(l.ListStyle||(l.ListStyle={}));const Ll={inheritStyle:!1},Wo={[He.DISC]:"•",[He.CIRCLE]:"◦",[He.SQUARE]:"▫︎",[He.CHECKBOX]:"☑️"},Il={[l.ListType.OL]:"ol",[l.ListType.UL]:"ul"},Pl={[l.ListStyle.DISC]:"disc",[l.ListStyle.CIRCLE]:"circle",[l.ListStyle.SQUARE]:"square",[l.ListStyle.DECIMAL]:"decimal",[l.ListStyle.CHECKBOX]:"checkbox"};l.TitleLevel=void 0,(function(o){o.FIRST="first",o.SECOND="second",o.THIRD="third",o.FOURTH="fourth",o.FIFTH="fifth",o.SIXTH="sixth"})(l.TitleLevel||(l.TitleLevel={}));const Ml={defaultFirstSize:26,defaultSecondSize:24,defaultThirdSize:22,defaultFourthSize:20,defaultFifthSize:18,defaultSixthSize:16},xi={[l.TitleLevel.FIRST]:"defaultFirstSize",[l.TitleLevel.SECOND]:"defaultSecondSize",[l.TitleLevel.THIRD]:"defaultThirdSize",[l.TitleLevel.FOURTH]:"defaultFourthSize",[l.TitleLevel.FIFTH]:"defaultFifthSize",[l.TitleLevel.SIXTH]:"defaultSixthSize"},bo={[l.TitleLevel.FIRST]:1,[l.TitleLevel.SECOND]:2,[l.TitleLevel.THIRD]:3,[l.TitleLevel.FOURTH]:4,[l.TitleLevel.FIFTH]:5,[l.TitleLevel.SIXTH]:6},Ol={H1:l.TitleLevel.FIRST,H2:l.TitleLevel.SECOND,H3:l.TitleLevel.THIRD,H4:l.TitleLevel.FOURTH,H5:l.TitleLevel.FIFTH,H6:l.TitleLevel.SIXTH};l.BlockType=void 0,(function(o){o.IFRAME="iframe",o.VIDEO="video"})(l.BlockType||(l.BlockType={})),l.ControlType=void 0,(function(o){o.TEXT="text",o.SELECT="select",o.CHECKBOX="checkbox",o.RADIO="radio",o.DATE="date",o.NUMBER="number",o.TEXTFIELD="TextField",o.BUTTON="button",o.MENSTRUAL_HISTORY="menstrualHistory"})(l.ControlType||(l.ControlType={})),l.ControlComponent=void 0,(function(o){o.PREFIX="prefix",o.POSTFIX="postfix",o.PRE_TEXT="preText",o.PRETEXTFIX="preTextFix",o.PRETEXTFIX_TEXT="preTextFixText",o.POSTTEXTFIX="postTextFix",o.POSTTEXTFIX_TEXT="postTextFixText",o.POST_TEXT="postText",o.PLACEHOLDER="placeholder",o.TEXTFIXLABEL="textFixLabel",o.VALUE="value",o.DELETEPERSON="deletePerson",o.CHECKBOX="checkbox",o.RADIO="radio",o.UNDERLINE="underline"})(l.ControlComponent||(l.ControlComponent={})),l.ControlIndentation=void 0,(function(o){o.ROW_START="rowStart",o.VALUE_START="valueStart"})(l.ControlIndentation||(l.ControlIndentation={})),l.ControlState=void 0,(function(o){o.ACTIVE="active",o.INACTIVE="inactive"})(l.ControlState||(l.ControlState={}));var Gi;(function(o){o.NUMBER="number",o.OPERATOR="operator",o.UTILITY="utility",o.EQUAL="equal"})(Gi||(Gi={})),l.EditorComponent=void 0,(function(o){o.COMPONENT="component",o.MENU="menu",o.MAIN="main",o.FOOTER="footer",o.CONTEXTMENU="contextmenu",o.POPUP="popup",o.CATALOG="catalog",o.COMMENT="comment"})(l.EditorComponent||(l.EditorComponent={}));var ge;(function(o){o.PAGE="page",o.TABLE="table"})(ge||(ge={})),l.EditorMode=void 0,(function(o){o.EDIT="edit",o.CLEAN="clean",o.READONLY="readonly",o.FORM="form",o.PRINT="print",o.DESIGN="design",o.GRAFFITI="graffiti"})(l.EditorMode||(l.EditorMode={})),l.EditorZone=void 0,(function(o){o.HEADER="header",o.MAIN="main",o.FOOTER="footer"})(l.EditorZone||(l.EditorZone={})),l.PageMode=void 0,(function(o){o.PAGING="paging",o.CONTINUITY="continuity"})(l.PageMode||(l.PageMode={})),l.PaperDirection=void 0,(function(o){o.VERTICAL="vertical",o.HORIZONTAL="horizontal"})(l.PaperDirection||(l.PaperDirection={})),l.WordBreak=void 0,(function(o){o.BREAK_ALL="break-all",o.BREAK_WORD="break-word"})(l.WordBreak||(l.WordBreak={})),l.RenderMode=void 0,(function(o){o.SPEED="speed",o.COMPATIBILITY="compatibility"})(l.RenderMode||(l.RenderMode={})),l.TableBorder=void 0,(function(o){o.ALL="all",o.EMPTY="empty",o.EXTERNAL="external",o.INTERNAL="internal",o.DASH="dash"})(l.TableBorder||(l.TableBorder={})),l.TdBorder=void 0,(function(o){o.TOP="top",o.RIGHT="right",o.BOTTOM="bottom",o.LEFT="left"})(l.TdBorder||(l.TdBorder={})),l.TdSlash=void 0,(function(o){o.FORWARD="forward",o.BACK="back"})(l.TdSlash||(l.TdSlash={})),l.BackgroundSize=void 0,(function(o){o.CONTAIN="contain",o.COVER="cover"})(l.BackgroundSize||(l.BackgroundSize={})),l.BackgroundRepeat=void 0,(function(o){o.REPEAT="repeat",o.NO_REPEAT="no-repeat",o.REPEAT_X="repeat-x",o.REPEAT_Y="repeat-y"})(l.BackgroundRepeat||(l.BackgroundRepeat={}));const Cl={color:"#FFFFFF",image:"",size:l.BackgroundSize.COVER,repeat:l.BackgroundRepeat.NO_REPEAT,applyPageNumbers:[]};l.VerticalAlign=void 0,(function(o){o.TOP="top",o.MIDDLE="middle",o.BOTTOM="bottom"})(l.VerticalAlign||(l.VerticalAlign={}));const Sl={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#ffffff",verticalAlign:l.VerticalAlign.BOTTOM},El={placeholderColor:"#9c9b9b",bracketColor:"#2284FE",textFixColor:"blue",prefix:"[",postfix:"]",preTextFix:"{",postTextFix:"}",textFixLabel:"",preTextFixText:"",postTextFixText:"",borderWidth:1,borderColor:"#000000",activeBackgroundColor:"",disabledBackgroundColor:"",existValueBackgroundColor:"",noValueBackgroundColor:""},Xl={bottom:30,inactiveAlpha:1,maxHeightRadio:l.MaxHeightRatio.HALF,disabled:!1,editable:!0},Nl={opacity:.1,backgroundColor:"#E99D00",activeOpacity:.5,activeBackgroundColor:"#E99D00",disabled:!1,deletable:!0},Fl={top:30,inactiveAlpha:1,maxHeightRadio:l.MaxHeightRatio.HALF,disabled:!1,editable:!0},yl={defaultColor:"#1976d2",defaultBackgroundColor:"#e3f2fd",defaultBorderRadius:4,defaultPadding:[4,4,4,4]},Wl={color:"#666666",font:"Microsoft YaHei",size:12,top:5},bl={disabled:!0,color:"#CCCCCC",lineWidth:1.5},Vl={font:"Microsoft YaHei",fontSize:12,lineDash:[3,1]},pn={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},Yl={bottom:60,size:12,font:"Microsoft YaHei",color:"#000000",rowFlex:l.RowFlex.CENTER,format:pn.PAGE_NO,numberType:l.NumberType.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0,maxPageNo:null},Ai={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Microsoft YaHei"},Dl={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#000000",verticalAlign:l.VerticalAlign.BOTTOM},Ul={lineWidth:1,strokeStyle:"#000000"},wl={tdPadding:[5,5,5,5],defaultTrMinHeight:24,defaultColMinWidth:40,defaultBorderColor:"#000000",overflow:!0};l.WatermarkType=void 0,(function(o){o.TEXT="text",o.IMAGE="image"})(l.WatermarkType||(l.WatermarkType={}));const Vo={data:"",type:l.WatermarkType.TEXT,width:0,height:0,color:"#AEB5C0",opacity:.3,size:200,font:"Microsoft YaHei",repeat:!1,gap:[10,10],numberType:l.NumberType.ARABIC},Zl={tipDisabled:!0};l.LineNumberType=void 0,(function(o){o.PAGE="page",o.CONTINUITY="continuity"})(l.LineNumberType||(l.LineNumberType={}));const Ql={size:12,font:"Microsoft YaHei",color:"#000000",disabled:!0,right:20,type:l.LineNumberType.CONTINUITY},vl={color:"#000000",lineWidth:1,padding:[0,5,0,5],disabled:!0},Kl={top:0,left:5},Hl={defaultLineColor:"#000000",defaultLineWidth:2},_l={disabled:!0,color:"#CCCCCC",radius:1};function Yo(o={}){const t={...wl,...o.table},e={...Fl,...o.header},n={...Xl,...o.footer},i={...Yl,...o.pageNumber},r={...Vo,...o.watermark},s={...El,...o.control},a={...Sl,...o.checkbox},c={...Dl,...o.radio},d={...qr,...o.cursor},R={...Ml,...o.title},u={...Ai,...o.placeholder},h={...Nl,...o.group},g={...Vl,...o.pageBreak},f={...Zl,...o.zone},T={...Cl,...o.background},p={...bl,...o.lineBreak},m={..._l,...o.whiteSpace},I={...Ul,...o.separator},L={...Ql,...o.lineNumber},P={...vl,...o.pageBorder},O={...Kl,...o.badge},S={...Hl,...o.graffiti},F={...yl,...o.label},N={...Wl,...o.imgCaption},V={...Ll,...o.list},Y={print:{...So.print,...o.modeRule?.print},readonly:{...So.readonly,...o.modeRule?.readonly},form:{...So.form,...o.modeRule?.form}};return{mode:l.EditorMode.EDIT,locale:"zhCN",defaultType:"TEXT",defaultColor:"#000000",defaultFont:"SimSun",defaultSize:16,minSize:5,maxSize:72,defaultRowMargin:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,highlightMarginHeight:8,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",margins:[75.591,56.693,56.693,56.693],pageMode:l.PageMode.PAGING,renderMode:l.RenderMode.SPEED,defaultHyperlinkColor:"#0000FF",paperDirection:l.PaperDirection.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:l.WordBreak.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[To.ENGLISH,To.NUMBER],contextMenuDisableKeys:[],shortcutDisableKeys:[],scrollContainerSelector:"",pageOuterSelectionDisable:!1,...o,table:t,header:e,footer:n,pageNumber:i,watermark:r,control:s,checkbox:a,radio:c,cursor:d,title:R,placeholder:u,group:h,pageBreak:g,zone:f,background:T,lineBreak:p,whiteSpace:m,separator:I,lineNumber:L,pageBorder:P,badge:O,modeRule:Y,graffiti:S,label:F,imgCaption:N,list:V,performance:{enabled:!1,threshold:16,...o.performance}}}const ki=new Map;function xl(o){return ki.get(o)}function Qn(o,t){ki.set(o,t)}function Do(o){const t=[];for(let e=0;e<o.length;e++){const n=o[e],i=ct(n.value);for(let r=0;r<i.length;r++)t.push({...n,value:i[r]})}return t}function Vt(o,t){const{isHandleFirstElement:e=!0,isForceCompensation:n=!1,editorOptions:i}=t,r=o[0];(n||e&&r?.type!==l.ElementType.LIST&&(r?.type&&r.type!==l.ElementType.TEXT||!po.test(r?.value)))&&o.unshift({value:_});let s=0;for(;s<o.length;){let a=o[s];if(a.type===l.ElementType.TITLE){o.splice(s,1);const c=a.valueList||[];if(Vt(c,{...t,isHandleFirstElement:!1,isForceCompensation:!1}),c.length){const d=a.titleId||lt(),R=i.title;for(let u=0;u<c.length;u++){const h=c[u];h.title=a.title,a.level&&(h.titleId=d,h.level=a.level),vn(h)&&(h.size||(h.size=R[xi[h.level]]),h.bold===void 0&&(h.bold=!0)),o.splice(s,0,h),s++}}s--}else if(a.type===l.ElementType.LIST){o.splice(s,1);const c=a.valueList||[];if(Vt(c,{...t,isHandleFirstElement:!0,isForceCompensation:!1}),c.length){const d=lt();for(let R=0;R<c.length;R++){const u=c[R];u.listId=d,u.listType=a.listType,u.listStyle=a.listStyle,o.splice(s,0,u),s++}}s--}else if(a.type===l.ElementType.AREA){o.splice(s,1);const c=a?.valueList||[];if(Vt(c,{...t,isHandleFirstElement:!0,isForceCompensation:!0}),c.length){const d=lt();for(let R=0;R<c.length;R++){const u=c[R];if(u.areaId=a.areaId||d,u.area=a.area,u.areaIndex=R,u.type===l.ElementType.TABLE){const h=u.trList;for(let g=0;g<h.length;g++){const f=h[g];for(let T=0;T<f.tdList.length;T++){const m=f.tdList[T].value;for(let I=0;I<m.length;I++){const L=m[I];L.areaId=a.areaId||d,L.area=a.area}}}}o.splice(s,0,u),s++}}s--}else if(a.type===l.ElementType.TABLE){const c=a.id||lt();if(a.id=c,a.trList){const{defaultTrMinHeight:d}=i.table;for(let R=0;R<a.trList.length;R++){const u=a.trList[R],h=u.id||lt();u.id=h,(!u.minHeight||u.minHeight<d)&&(u.minHeight=d),u.height<u.minHeight&&(u.height=u.minHeight);for(let g=0;g<u.tdList.length;g++){const f=u.tdList[g],T=f.id||lt();f.id=T,Vt(f.value,{...t,isHandleFirstElement:!0,isForceCompensation:!0}),!f.value[0].size&&f.value[1]?.size&&vn(f.value[1])&&(f.value[0].size=f.value[1].size);for(let p=0;p<f.value.length;p++){const m=f.value[p];m.tdId=T,m.trId=h,m.tableId=c}}}}}else if(a.type===l.ElementType.HYPERLINK){o.splice(s,1);const c=Do(a.valueList||[]);if(c.length){const d=lt();for(let R=0;R<c.length;R++){const u=c[R];u.type=a.type,u.url=a.url,u.hyperlinkId=d,o.splice(s,0,u),s++}}s--}else if(a.type===l.ElementType.DATE){o.splice(s,1);const c=Do(a.valueList||[]);if(c.length){const d=lt();for(let R=0;R<c.length;R++){const u=c[R];u.type=a.type,u.dateFormat=a.dateFormat,u.dateId=d,o.splice(s,0,u),s++}}s--}else if(a.type===l.ElementType.CONTROL){if(!a.control){s++;continue}if(a.control.type=="TextField"){const{preTextFix:c,postTextFix:d,preTextFixText:R,postTextFixText:u,value:h,placeholder:g,code:f,type:T,valueSets:p}=a.control,m=T,{editorOptions:{control:I,checkbox:L,radio:P}}=t,O=a.controlId||lt();o.splice(s,1);const S=Dt(a,[...No,...Bt]),F=Dt(a.control,Gt),N={...F,color:i.control.textFixColor,fontWeight:"blod"},V={...F,color:void 0},Y=ct(c||I.preTextFix);for(let b=0;b<Y.length;b++){const E=Y[b];o.splice(s,0,{...S,...N,controlId:O,value:E,type:a.type,control:a.control,controlComponent:l.ControlComponent.PRETEXTFIX}),s++}if(R){const b=ct(R);for(let E=0;E<b.length;E++){const C=b[E];o.splice(s,0,{...S,...F,controlId:O,value:C,type:a.type,control:a.control,controlComponent:l.ControlComponent.PRETEXTFIX_TEXT}),s++}}if(h&&h.length||m===l.ControlType.CHECKBOX||m===l.ControlType.RADIO||m===l.ControlType.SELECT&&f&&(!h||!h.length)){let b=h?at(h):[];if(m===l.ControlType.CHECKBOX){const E=f?f.split(","):[];if(Array.isArray(p)&&p.length){const C=b.reduce((y,W)=>y.concat(W.value.split("").map(D=>({...W,value:D}))),[]);let M=0;for(let y=0;y<p.length;y++){const W=p[y];o.splice(s,0,{...S,...F,controlId:O,value:"",type:a.type,control:a.control,controlComponent:l.ControlComponent.CHECKBOX,checkbox:{code:W.code,value:E.includes(W.code)}}),s++;const D=ct(W.value);for(let U=0;U<D.length;U++){const Q=D[U],G=U===D.length-1;o.splice(s,0,{...S,...V,...C[M],controlId:O,value:Q===`
|
|
62
62
|
`?_:Q,letterSpacing:G?L.gap:0,control:a.control,controlComponent:l.ControlComponent.VALUE}),M++,s++}}}}else if(m===l.ControlType.RADIO){if(Array.isArray(p)&&p.length){const E=b.reduce((M,y)=>M.concat(y.value.split("").map(W=>({...y,value:W}))),[]);let C=0;for(let M=0;M<p.length;M++){const y=p[M];o.splice(s,0,{...S,...F,controlId:O,value:"",type:a.type,control:a.control,controlComponent:l.ControlComponent.RADIO,radio:{code:y.code,value:f===y.code}}),s++;const W=ct(y.value);for(let D=0;D<W.length;D++){const U=W[D],Q=D===W.length-1;o.splice(s,0,{...S,...V,...E[C],controlId:O,value:U===`
|
|
63
|
-
`?_:U,letterSpacing:Q?P.gap:0,control:a.control,controlComponent:l.ControlComponent.VALUE}),C++,s++}}}}else{if((!h||!h.length)&&Array.isArray(p)&&p.length){const E=f?f.split(",").map(C=>C.trim()).filter(C=>C):[];if(E.length>1){const C=[];for(const M of E){const y=p.find(W=>W.code===M);y&&C.push({value:y.value})}C.length>0&&(b=C)}else if(E.length===1){const C=p.find(M=>M.code===E[0]);C&&(b=[{value:C.value}])}}for(let E=0;E<b.length;E++){const C=b[E];if(C.type===l.ElementType.CONTROL&&C.control){const M=C,y=M.controlId||lt(),W=M.control?.value||[],D=M.control?.placeholder||"",U=M.control?.type,Q=U===l.ControlType.TEXTFIELD,G=U===l.ControlType.TEXT,H=U===l.ControlType.CHECKBOX,j=U===l.ControlType.RADIO,st=U===l.ControlType.BUTTON,it=Q?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,nt=Q?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,et={...S,controlId:y,type:l.ElementType.CONTROL,control:M.control},dt=Q?i.control.textFixColor:G?"#87d068":st?"transparent":i.control.bracketColor,tt=st?"#1677FF":void 0,ht=Q?M.control?.preTextFix||I.preTextFix:M.control?.prefix||I.prefix,ut=ct(ht);for(let w=0;w<ut.length;w++)o.splice(s,0,{...et,color:dt,highlight:tt,originControlId:O,value:ut[w],controlComponent:it}),s++;if(st){const w=M.control.buttonLabel||M.control.label||"按钮",Z=ct(w);for(let J=0;J<Z.length;J++){const x=Z[J];o.splice(s,0,{...et,originControlId:O,value:x,controlComponent:l.ControlComponent.VALUE,color:"#fff",highlight:"#1677FF"}),s++}}else if(H){const w=M.control?.valueSets||[],Z=M.control?.code||"",J=Z?Z.split(","):[];for(let x=0;x<w.length;x++){const A=w[x];o.splice(s,0,{...et,originControlId:O,value:"",controlComponent:l.ControlComponent.CHECKBOX,checkbox:{code:A.code,value:J.includes(A.code)}}),s++;const $=ct(A.value||"");for(let B=0;B<$.length;B++){const
|
|
64
|
-
`?_:
|
|
65
|
-
`?_:B,letterSpacing:
|
|
66
|
-
`?_:
|
|
67
|
-
`?_:Z.value,controlComponent:l.ControlComponent.VALUE});s++}}else if(D){const w=ct(D);for(let Z=0;Z<w.length;Z++)o.splice(s,0,{...et,color:i.control.placeholderColor,originControlId:O,value:w[Z],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}else if((U===l.ControlType.SELECT||U===l.ControlType.DATE||U===l.ControlType.NUMBER)&&!M.control?.code&&D){const Z=ct(D);for(let J=0;J<Z.length;J++)o.splice(s,0,{...et,color:i.control.placeholderColor,originControlId:O,value:Z[J],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}const
|
|
63
|
+
`?_:U,letterSpacing:Q?P.gap:0,control:a.control,controlComponent:l.ControlComponent.VALUE}),C++,s++}}}}else{if((!h||!h.length)&&Array.isArray(p)&&p.length){const E=f?f.split(",").map(C=>C.trim()).filter(C=>C):[];if(E.length>1){const C=[];for(const M of E){const y=p.find(W=>W.code===M);y&&C.push({value:y.value})}C.length>0&&(b=C)}else if(E.length===1){const C=p.find(M=>M.code===E[0]);C&&(b=[{value:C.value}])}}for(let E=0;E<b.length;E++){const C=b[E];if(C.type===l.ElementType.CONTROL&&C.control){const M=C,y=M.controlId||lt(),W=M.control?.value||[],D=M.control?.placeholder||"",U=M.control?.type,Q=U===l.ControlType.TEXTFIELD,G=U===l.ControlType.TEXT,H=U===l.ControlType.CHECKBOX,j=U===l.ControlType.RADIO,st=U===l.ControlType.BUTTON,it=Q?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,nt=Q?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,et={...S,controlId:y,type:l.ElementType.CONTROL,control:M.control},dt=Q?i.control.textFixColor:G?"#87d068":st?"transparent":i.control.bracketColor,tt=st?"#1677FF":void 0,ht=Q?M.control?.preTextFix||I.preTextFix:M.control?.prefix||I.prefix,ut=ct(ht);for(let w=0;w<ut.length;w++)o.splice(s,0,{...et,color:dt,highlight:tt,originControlId:O,value:ut[w],controlComponent:it}),s++;if(st){const w=M.control.buttonLabel||M.control.label||"按钮",Z=ct(w);for(let J=0;J<Z.length;J++){const x=Z[J];o.splice(s,0,{...et,originControlId:O,value:x,controlComponent:l.ControlComponent.VALUE,color:"#fff",highlight:"#1677FF"}),s++}}else if(H){const w=M.control?.valueSets||[],Z=M.control?.code||"",J=Z?Z.split(","):[];for(let x=0;x<w.length;x++){const A=w[x];o.splice(s,0,{...et,originControlId:O,value:"",controlComponent:l.ControlComponent.CHECKBOX,checkbox:{code:A.code,value:J.includes(A.code)}}),s++;const $=ct(A.value||"");for(let B=0;B<$.length;B++){const pt=$[B],Xt=B===$.length-1;o.splice(s,0,{...et,...V,originControlId:O,value:pt===`
|
|
64
|
+
`?_:pt,letterSpacing:Xt?L.gap:0,controlComponent:l.ControlComponent.VALUE}),s++}}}else if(j){const w=M.control?.valueSets||[],Z=M.control?.code||"";for(let J=0;J<w.length;J++){const x=w[J];o.splice(s,0,{...et,originControlId:O,value:"",controlComponent:l.ControlComponent.RADIO,radio:{code:x.code,value:Z===x.code}}),s++;const A=ct(x.value||"");for(let $=0;$<A.length;$++){const B=A[$],pt=$===A.length-1;o.splice(s,0,{...et,...V,originControlId:O,value:B===`
|
|
65
|
+
`?_:B,letterSpacing:pt?P.gap:0,controlComponent:l.ControlComponent.VALUE}),s++}}}else if(W.length>0)for(let w=0;w<W.length;w++){const Z=W[w];if(Z.type===l.ElementType.CONTROL&&Z.control){const J=Z,x=J.controlId||lt(),A=J.control?.value||[],$=J.control?.type===l.ControlType.TEXTFIELD,B=J.control?.type===l.ControlType.TEXT,pt={...et,controlId:x,control:J.control},Xt=$?i.control.textFixColor:B?"#87d068":i.control.bracketColor,Lt=$?J.control?.preTextFix||I.preTextFix:J.control?.prefix||I.prefix,yt=ct(Lt);for(let Tt=0;Tt<yt.length;Tt++)o.splice(s,0,{...pt,color:Xt,originControlId:y,value:yt[Tt],controlComponent:$?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX}),s++;for(let Tt=0;Tt<A.length;Tt++){const Pt=A[Tt];if(Pt.type===l.ElementType.MENSTRUAL_HISTORY||Pt.type===l.ElementType.FETAL_HEART_POSITION||Pt.type===l.ElementType.TOOTH_POSITION||Pt.type===l.ElementType.MACRO||Pt.type===l.ElementType.CUSTOM_MACRO||Pt.type===l.ElementType.REUSABLE_ITEM||Pt.type===l.ElementType.LIST||Pt.type===l.ElementType.SPECIAL_SYMBOLS){const Qt=Pt.id||lt();Pt.id||(Pt.id=Qt);const be=J.control?.value?.find(jt=>jt.id===Qt||jt.type===Pt.type&&jt.value===Pt.value);be&&Qn(Qt,be),o.splice(s,0,{...pt,...Pt,id:Qt,originControlId:y,controlComponent:l.ControlComponent.VALUE,type:Pt.type})}else o.splice(s,0,{...pt,...V,...Pt,originControlId:y,value:Pt.value===`
|
|
66
|
+
`?_:Pt.value,controlComponent:l.ControlComponent.VALUE});s++}if(A.length===0){const Tt=J.control?.placeholder||"";if(Tt){const Pt=ct(Tt);for(let Kt=0;Kt<Pt.length;Kt++)o.splice(s,0,{...pt,color:i.control.placeholderColor,originControlId:y,value:Pt[Kt],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}}const Yt=$?J.control?.postTextFix||I.postTextFix:J.control?.postfix||I.postfix,St=ct(Yt);for(let Tt=0;Tt<St.length;Tt++)o.splice(s,0,{...pt,color:Xt,originControlId:y,value:St[Tt],controlComponent:$?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX}),s++}else{if(Z.type===l.ElementType.MENSTRUAL_HISTORY||Z.type===l.ElementType.FETAL_HEART_POSITION||Z.type===l.ElementType.TOOTH_POSITION||Z.type===l.ElementType.MACRO||Z.type===l.ElementType.CUSTOM_MACRO||Z.type===l.ElementType.REUSABLE_ITEM||Z.type===l.ElementType.LIST||Z.type===l.ElementType.SPECIAL_SYMBOLS){const x=Z.id||lt();Z.id||(Z.id=x);const A=M.control?.value?.find($=>$.id===x||$.type===Z.type&&$.value===Z.value);A&&Qn(x,A),o.splice(s,0,{...et,...Z,id:x,originControlId:O,controlComponent:l.ControlComponent.VALUE,type:Z.type})}else o.splice(s,0,{...et,...V,...Z,originControlId:O,value:Z.value===`
|
|
67
|
+
`?_:Z.value,controlComponent:l.ControlComponent.VALUE});s++}}else if(D){const w=ct(D);for(let Z=0;Z<w.length;Z++)o.splice(s,0,{...et,color:i.control.placeholderColor,originControlId:O,value:w[Z],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}else if((U===l.ControlType.SELECT||U===l.ControlType.DATE||U===l.ControlType.NUMBER)&&!M.control?.code&&D){const Z=ct(D);for(let J=0;J<Z.length;J++)o.splice(s,0,{...et,color:i.control.placeholderColor,originControlId:O,value:Z[J],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}const K=Q?M.control?.postTextFix||I.postTextFix:M.control?.postfix||I.postfix,v=ct(K);for(let w=0;w<v.length;w++)o.splice(s,0,{...et,color:dt,highlight:tt,originControlId:O,value:v[w],controlComponent:nt}),s++}else if(C.type===l.ElementType.MENSTRUAL_HISTORY||C.type===l.ElementType.FETAL_HEART_POSITION||C.type===l.ElementType.TOOTH_POSITION||C.type===l.ElementType.MACRO||C.type===l.ElementType.CUSTOM_MACRO||C.type===l.ElementType.REUSABLE_ITEM||C.type===l.ElementType.LIST||C.type===l.ElementType.SPECIAL_SYMBOLS){const M=C.id||lt();C.id||(C.id=M);const y=h?.find(W=>W.id===M||W.type===C.type&&W.value===C.value);y&&Qn(M,y),o.splice(s,0,{...S,...C,id:M,controlId:O,control:a.control,controlComponent:l.ControlComponent.VALUE,type:C.type}),s++}else{const M=ct(C.value||"");for(let y=0;y<M.length;y++){const W=M[y];o.splice(s,0,{...S,...V,...C,controlId:O,value:W===`
|
|
68
68
|
`?_:W,type:C.type||l.ElementType.TEXT,control:a.control,controlComponent:l.ControlComponent.VALUE}),s++}}}}}else if(g){const b={...F,color:i.control.placeholderColor},E=ct(g);for(let C=0;C<E.length;C++){const M=E[C];o.splice(s,0,{...S,...b,controlId:O,value:M===`
|
|
69
69
|
`?_:M,type:a.type,control:a.control,controlComponent:l.ControlComponent.PLACEHOLDER}),s++}}if(u){const b=ct(u);for(let E=0;E<b.length;E++){const C=b[E];o.splice(s,0,{...S,...F,controlId:O,value:C,type:a.type,control:a.control,controlComponent:l.ControlComponent.POSTTEXTFIX_TEXT}),s++}}const X=ct(d||I.postTextFix);for(let b=0;b<X.length;b++){const E=X[b];o.splice(s,0,{...S,...N,controlId:O,value:E,type:a.type,control:a.control,controlComponent:l.ControlComponent.POSTTEXTFIX}),s++}s--}else{const{prefix:c,postfix:d,preText:R,postText:u,value:h,placeholder:g,code:f,type:T,valueSets:p}=a.control,{editorOptions:{control:m,checkbox:I,radio:L}}=t,P=a.controlId||lt();o.splice(s,1);const O=Dt(a,[...No,...Bt]),S=Dt(a.control,Gt),F={...S,color:T===l.ControlType.TEXT?"#87d068":T===l.ControlType.BUTTON?"transparent":i.control.bracketColor,highlight:T===l.ControlType.BUTTON?"#1677FF":void 0},N={...S,color:void 0},V=ct(c||m.prefix);for(let X=0;X<V.length;X++){const b=V[X];o.splice(s,0,{...O,...F,controlId:P,value:b===`
|
|
70
70
|
`?_:b,type:a.type,control:a.control,controlComponent:l.ControlComponent.PREFIX}),s++}if(R){const X=ct(R);for(let b=0;b<X.length;b++){const E=X[b];o.splice(s,0,{...O,...S,controlId:P,value:E,type:a.type,control:a.control,controlComponent:l.ControlComponent.PRE_TEXT}),s++}}if(h&&h.length||T===l.ControlType.CHECKBOX||T===l.ControlType.RADIO||T===l.ControlType.BUTTON||T===l.ControlType.SELECT&&f&&(!h||!h.length)){let X=h?at(h):[];if(T===l.ControlType.CHECKBOX){const b=f?f.split(","):[];if(Array.isArray(p)&&p.length){const E=X.reduce((M,y)=>M.concat(y.value.split("").map(W=>({...y,value:W}))),[]);let C=0;for(let M=0;M<p.length;M++){const y=p[M];o.splice(s,0,{...O,...S,controlId:P,value:"",type:a.type,control:a.control,controlComponent:l.ControlComponent.CHECKBOX,checkbox:{code:y.code,value:b.includes(y.code)}}),s++;const W=ct(y.value);for(let D=0;D<W.length;D++){const U=W[D],Q=D===W.length-1;o.splice(s,0,{...O,...N,...E[C],controlId:P,value:U===`
|
|
71
71
|
`?_:U,letterSpacing:Q?I.gap:0,control:a.control,controlComponent:l.ControlComponent.VALUE}),C++,s++}}}}else if(T===l.ControlType.RADIO){if(Array.isArray(p)&&p.length){const b=X.reduce((C,M)=>C.concat(M.value.split("").map(y=>({...M,value:y}))),[]);let E=0;for(let C=0;C<p.length;C++){const M=p[C];o.splice(s,0,{...O,...S,controlId:P,value:"",type:a.type,control:a.control,controlComponent:l.ControlComponent.RADIO,radio:{code:M.code,value:f===M.code}}),s++;const y=ct(M.value);for(let W=0;W<y.length;W++){const D=y[W],U=W===y.length-1;o.splice(s,0,{...O,...N,...b[E],controlId:P,value:D===`
|
|
72
|
-
`?_:D,letterSpacing:U?L.gap:0,control:a.control,controlComponent:l.ControlComponent.VALUE}),E++,s++}}}}else{if(T===l.ControlType.BUTTON){const b=a.control.buttonLabel||a.control.label||"按钮",E=ct(b);for(let C=0;C<E.length;C++){const M=E[C];o.splice(s,0,{...O,...S,controlId:P,value:M,type:l.ElementType.CONTROL,control:a.control,controlComponent:l.ControlComponent.VALUE,color:"#fff",highlight:"#1677FF"}),s++}}else if((!h||!h.length)&&Array.isArray(p)&&p.length){const b=f?f.split(","):[];if(b.length>1){const E=[];for(const C of b){const M=p.find(y=>y.code===C.trim());M&&E.push({value:M.value})}E.length>0&&(X=E)}else{const E=p.find(C=>C.code===f);E&&(X=[{value:E.value}])}}if(T!==l.ControlType.BUTTON)for(let b=0;b<X.length;b++){const E=X[b];if(E.type===l.ElementType.CONTROL&&E.control){const C=E,M=C.controlId||lt(),y=C.control?.value||[],W=C.control?.placeholder||"",D=C.control?.type,U=D===l.ControlType.TEXTFIELD,Q=D===l.ControlType.TEXT,G=D===l.ControlType.CHECKBOX,H=D===l.ControlType.RADIO,j=D===l.ControlType.BUTTON,st=U?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,it=U?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,nt={...O,controlId:M,type:l.ElementType.CONTROL,control:C.control},et=U?i.control.textFixColor:Q?"#87d068":j?"transparent":i.control.bracketColor,dt=j?"#1677FF":void 0,tt=U?C.control?.preTextFix||m.preTextFix:C.control?.prefix||m.prefix,ht=ct(tt);for(let
|
|
73
|
-
`?_:B,letterSpacing:
|
|
74
|
-
`?_:$,letterSpacing:B?L.gap:0,controlComponent:l.ControlComponent.VALUE}),s++}}}else if(y.length>0)for(let
|
|
75
|
-
`?_:Tt.value,controlComponent:l.ControlComponent.VALUE}),s++}if(x.length===0){const St=Z.control?.placeholder||"";if(St){const Tt=ct(St);for(let
|
|
76
|
-
`?_:w.value,controlComponent:l.ControlComponent.VALUE}),s++}else if(W){const
|
|
72
|
+
`?_:D,letterSpacing:U?L.gap:0,control:a.control,controlComponent:l.ControlComponent.VALUE}),E++,s++}}}}else{if(T===l.ControlType.BUTTON){const b=a.control.buttonLabel||a.control.label||"按钮",E=ct(b);for(let C=0;C<E.length;C++){const M=E[C];o.splice(s,0,{...O,...S,controlId:P,value:M,type:l.ElementType.CONTROL,control:a.control,controlComponent:l.ControlComponent.VALUE,color:"#fff",highlight:"#1677FF"}),s++}}else if((!h||!h.length)&&Array.isArray(p)&&p.length){const b=f?f.split(","):[];if(b.length>1){const E=[];for(const C of b){const M=p.find(y=>y.code===C.trim());M&&E.push({value:M.value})}E.length>0&&(X=E)}else{const E=p.find(C=>C.code===f);E&&(X=[{value:E.value}])}}if(T!==l.ControlType.BUTTON)for(let b=0;b<X.length;b++){const E=X[b];if(E.type===l.ElementType.CONTROL&&E.control){const C=E,M=C.controlId||lt(),y=C.control?.value||[],W=C.control?.placeholder||"",D=C.control?.type,U=D===l.ControlType.TEXTFIELD,Q=D===l.ControlType.TEXT,G=D===l.ControlType.CHECKBOX,H=D===l.ControlType.RADIO,j=D===l.ControlType.BUTTON,st=U?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,it=U?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,nt={...O,controlId:M,type:l.ElementType.CONTROL,control:C.control},et=U?i.control.textFixColor:Q?"#87d068":j?"transparent":i.control.bracketColor,dt=j?"#1677FF":void 0,tt=U?C.control?.preTextFix||m.preTextFix:C.control?.prefix||m.prefix,ht=ct(tt);for(let v=0;v<ht.length;v++)o.splice(s,0,{...nt,color:et,highlight:dt,originControlId:P,value:ht[v],controlComponent:st}),s++;if(j){const v=C.control.buttonLabel||C.control.label||"按钮",w=ct(v);for(let Z=0;Z<w.length;Z++){const J=w[Z];o.splice(s,0,{...nt,originControlId:P,value:J,controlComponent:l.ControlComponent.VALUE,color:"#fff",highlight:"#1677FF"}),s++}}else if(G){const v=C.control?.valueSets||[],w=C.control?.code||"",Z=w?w.split(","):[];for(let J=0;J<v.length;J++){const x=v[J];o.splice(s,0,{...nt,...S,originControlId:P,value:"",controlComponent:l.ControlComponent.CHECKBOX,checkbox:{code:x.code,value:Z.includes(x.code)}}),s++;const A=ct(x.value||"");for(let $=0;$<A.length;$++){const B=A[$],pt=$===A.length-1;o.splice(s,0,{...nt,...N,originControlId:P,value:B===`
|
|
73
|
+
`?_:B,letterSpacing:pt?I.gap:0,controlComponent:l.ControlComponent.VALUE}),s++}}}else if(H){const v=C.control?.valueSets||[],w=C.control?.code||"";for(let Z=0;Z<v.length;Z++){const J=v[Z];o.splice(s,0,{...nt,...S,originControlId:P,value:"",controlComponent:l.ControlComponent.RADIO,radio:{code:J.code,value:w===J.code}}),s++;const x=ct(J.value||"");for(let A=0;A<x.length;A++){const $=x[A],B=A===x.length-1;o.splice(s,0,{...nt,...N,originControlId:P,value:$===`
|
|
74
|
+
`?_:$,letterSpacing:B?L.gap:0,controlComponent:l.ControlComponent.VALUE}),s++}}}else if(y.length>0)for(let v=0;v<y.length;v++){const w=y[v];if(w.type===l.ElementType.CONTROL&&w.control){const Z=w,J=Z.controlId||lt(),x=Z.control?.value||[],A=Z.control?.type===l.ControlType.TEXTFIELD,$=Z.control?.type===l.ControlType.TEXT,B={...nt,controlId:J,control:Z.control},pt=A?i.control.textFixColor:$?"#87d068":i.control.bracketColor,Xt=A?Z.control?.preTextFix||m.preTextFix:Z.control?.prefix||m.prefix,Lt=ct(Xt);for(let St=0;St<Lt.length;St++)o.splice(s,0,{...B,color:pt,originControlId:M,value:Lt[St],controlComponent:A?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX}),s++;for(let St=0;St<x.length;St++){const Tt=x[St];o.splice(s,0,{...B,...N,...Tt,originControlId:M,value:Tt.value===`
|
|
75
|
+
`?_:Tt.value,controlComponent:l.ControlComponent.VALUE}),s++}if(x.length===0){const St=Z.control?.placeholder||"";if(St){const Tt=ct(St);for(let Pt=0;Pt<Tt.length;Pt++)o.splice(s,0,{...B,color:i.control.placeholderColor,originControlId:M,value:Tt[Pt],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}}const yt=A?Z.control?.postTextFix||m.postTextFix:Z.control?.postfix||m.postfix,Yt=ct(yt);for(let St=0;St<Yt.length;St++)o.splice(s,0,{...B,color:pt,originControlId:M,value:Yt[St],controlComponent:A?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX}),s++}else o.splice(s,0,{...nt,...N,...w,originControlId:P,value:w.value===`
|
|
76
|
+
`?_:w.value,controlComponent:l.ControlComponent.VALUE}),s++}else if(W){const v=ct(W);for(let w=0;w<v.length;w++)o.splice(s,0,{...nt,color:i.control.placeholderColor,originControlId:P,value:v[w],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}else if((D===l.ControlType.SELECT||D===l.ControlType.DATE||D===l.ControlType.NUMBER)&&!C.control?.code&&W){const w=ct(W);for(let Z=0;Z<w.length;Z++)o.splice(s,0,{...nt,color:i.control.placeholderColor,originControlId:P,value:w[Z],controlComponent:l.ControlComponent.PLACEHOLDER}),s++}const ut=U?C.control?.postTextFix||m.postTextFix:C.control?.postfix||m.postfix,K=ct(ut);for(let v=0;v<K.length;v++)o.splice(s,0,{...nt,color:et,highlight:dt,originControlId:P,value:K[v],controlComponent:it}),s++}else if(E.type===l.ElementType.MENSTRUAL_HISTORY||E.type===l.ElementType.FETAL_HEART_POSITION||E.type===l.ElementType.TOOTH_POSITION||E.type===l.ElementType.MACRO||E.type===l.ElementType.CUSTOM_MACRO||E.type===l.ElementType.REUSABLE_ITEM||E.type===l.ElementType.LIST||E.type===l.ElementType.SPECIAL_SYMBOLS){const C=E.id||lt();E.id||(E.id=C);const M=a.control?.value;if(M){const y=M.find(W=>W.id===C||W.type===E.type&&W.value===E.value);y&&Qn(C,y)}o.splice(s,0,{...O,...E,id:C,controlId:P,control:a.control,controlComponent:l.ControlComponent.VALUE,type:E.type}),s++}else{const C=ct(E.value||"");for(let M=0;M<C.length;M++){const y=C[M];o.splice(s,0,{...O,...N,...E,controlId:P,value:y===`
|
|
77
77
|
`?_:y,type:E.type||l.ElementType.TEXT,control:a.control,controlComponent:l.ControlComponent.VALUE}),s++}}}}}else if(g){const X={...S,color:i.control.placeholderColor},b=ct(g);for(let E=0;E<b.length;E++){const C=b[E];o.splice(s,0,{...O,...X,controlId:P,value:C===`
|
|
78
78
|
`?_:C,type:a.type,control:a.control,controlComponent:l.ControlComponent.PLACEHOLDER}),s++}}if(u){const X=ct(u);for(let b=0;b<X.length;b++){const E=X[b];o.splice(s,0,{...O,...S,controlId:P,value:E,type:a.type,control:a.control,controlComponent:l.ControlComponent.POST_TEXT}),s++}}const Y=ct(d||m.postfix);for(let X=0;X<Y.length;X++){const b=Y[X];o.splice(s,0,{...O,...F,controlId:P,value:b===`
|
|
79
79
|
`?_:b,type:a.type,control:a.control,controlComponent:l.ControlComponent.POSTFIX}),s++}s--}}else if((!a.type||$t.includes(a.type))&&a.type!==l.ElementType.SPECIAL_SYMBOLS&&a.value?.length>1){o.splice(s,1);const c=ct(a.value);for(let d=0;d<c.length;d++)o.splice(s+d,0,{...a,value:c[d]});a=o[s]}if((a.value===`
|
|
80
80
|
`||a.value==`\r
|
|
81
81
|
`)&&(a.value=_),(a.type===l.ElementType.IMAGE||a.type===l.ElementType.BLOCK)&&(a.id=a.id||lt()),a.type===l.ElementType.LATEX){const{svg:c,width:d,height:R}=Hi.convertLaTextToSVG(a.value);a.width=a.width||d,a.height=a.height||R,a.laTexSVG=c,a.id=a.id||lt()}(a.type===l.ElementType.MACRO||a.type===l.ElementType.CUSTOM_MACRO||a.type===l.ElementType.REUSABLE_ITEM)&&(a.id=a.id||lt()),(a.type===l.ElementType.MENSTRUAL_HISTORY||a.type===l.ElementType.TOOTH_POSITION||a.type===l.ElementType.FETAL_HEART_POSITION||a.type===l.ElementType.SPECIAL_SYMBOLS)&&(a.id=a.id||lt()),s++}}function Gl(o,t){const e=Object.keys(o),n=Object.keys(t);if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++){const r=e[i];if(r!=="value"&&!(r==="groupIds"&&Array.isArray(o[r])&&Array.isArray(t[r])&&Di(o[r],t[r]))&&o[r]!==t[r])return!1}return!0}function De(o,t={}){const{extraPickAttrs:e}=t,n=[...il];e&&n.push(...e);const i={value:o?.value===_?`
|
|
82
|
-
`:o?.value};return o&&n.forEach(r=>{const s=o[r];s!==void 0&&(i[r]=s)}),i}function
|
|
82
|
+
`:o?.value};return o&&n.forEach(r=>{const s=o[r];s!==void 0&&(i[r]=s)}),i}function Mt(o,t={}){const{extraPickAttrs:e,isClassifyArea:n=!1,isClone:i=!0,editorOptions:r}=t,s=(i?at(o):o).filter(d=>d.type!==l.ElementType.SPLIT_TAG),a=[];let c=0;for(;c<s.length;){let d=s[c];if(c===0&&d.value===_&&!d.listId&&(!d.type||d.type===l.ElementType.TEXT)){c++;continue}if(d.areaId){const u=d.areaId,h=d.area,g=[];for(;c<s.length;){const T=s[c];if(u!==T.areaId){c--;break}delete T.area,delete T.areaId,g.push(T),c++}const f=Mt(g,t);if(n){const T={type:l.ElementType.AREA,value:"",areaId:u,area:h};T.valueList=f,d=T}else{a.splice(c,0,...f);continue}}else if(d.titleId&&d.level){const u=d.titleId;if(u){const h=d.level,g={type:l.ElementType.TITLE,title:d.title,titleId:u,value:"",level:h},f=[];for(;c<s.length;){const T=s[c];if(u!==T.titleId){c--;break}delete T.level,delete T.title,f.push(T),c++}g.valueList=Mt(f,t),d=g}}else if(d.listId&&d.listType){const u=d.listId;if(u){const h=d.listType,g=d.listStyle,f=d?.label,T={type:l.ElementType.LIST,value:"",label:f||"",listId:u,listType:h,listStyle:g},p=[];for(;c<s.length;){const m=s[c];if(u!==m.listId){c--;break}delete m.listType,delete m.listStyle,p.push(m),c++}T.valueList=Mt(p,t),d=T}}else if(d.type===l.ElementType.TABLE){if(d.pagingId){let u=c+1,h=0;for(;u<s.length;){const g=s[u];if(g.pagingId===d.pagingId){d.height+=g.height;const f=g.trList.filter(T=>!T.pagingRepeat).filter(T=>(T.tdList=T.tdList.filter(p=>{if(p.originalId){for(let m=0;m<d.trList.length;m++){const L=d.trList[m].tdList.find(({id:P})=>P===p.originalId);if(L){p.value[0]?.type===l.ElementType.SPLIT_TAG&&p.value.splice(0,1),L.value.push(...p.value),L.rowspan=L.originalRowspan??L.rowspan;break}}return!1}return!0}),!T.originalId));d.trList.push(...f),d.trList?.forEach(T=>T.minHeight=T.originalMinHeight??T.minHeight),u++,h++}else break}c+=h}if(d.trList)for(let u=0;u<d.trList.length;u++){const h=d.trList[u];delete h.id;for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g],T={colspan:f.colspan,rowspan:f.rowspan,value:Mt(f.value,{...t,isClassifyArea:!1})};sl.forEach(p=>{const m=f[p];m!==void 0&&(T[p]=m)}),h.tdList[g]=T}}}else if(d.type===l.ElementType.HYPERLINK){const u=d.hyperlinkId;if(u){const h={type:l.ElementType.HYPERLINK,value:"",url:d.url},g=[];for(;c<s.length;){const f=s[c];if(u!==f.hyperlinkId){c--;break}delete f.type,delete f.url,g.push(f),c++}h.valueList=Mt(g,t),d=h}}else if(d.type===l.ElementType.DATE){const u=d.dateId;if(u){const h={type:l.ElementType.DATE,value:"",dateFormat:d.dateFormat},g=[];for(;c<s.length;){const f=s[c];if(u!==f.dateId){c--;break}delete f.type,delete f.dateFormat,g.push(f),c++}h.valueList=Mt(g,t),d=h}}else if(d.type!==l.ElementType.BUTTON){if(d.controlId){const u=d.controlId;if(!(d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)&&d.controlComponent===l.ControlComponent.VALUE){if(d.type===l.ElementType.MENSTRUAL_HISTORY||d.type===l.ElementType.FETAL_HEART_POSITION||d.type===l.ElementType.TOOTH_POSITION||d.type===l.ElementType.MACRO||d.type===l.ElementType.CUSTOM_MACRO||d.type===l.ElementType.REUSABLE_ITEM||d.type===l.ElementType.LIST||d.type===l.ElementType.SPECIAL_SYMBOLS){let p=!1;for(let m=c-1;m>=0;m--){const I=s[m],L=I.controlComponent===l.ControlComponent.PREFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT;if(I.controlId===u&&L){p=!0;break}if(I.controlId!==u)break}if(!p){const m=at(d);delete m.controlId,delete m.control,delete m.controlComponent,delete m.originControlId,a.push(m),c++;continue}}c++;continue}if(d.controlComponent===l.ControlComponent.PLACEHOLDER||d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT||d.controlComponent===l.ControlComponent.PRE_TEXT||d.controlComponent===l.ControlComponent.CHECKBOX||d.controlComponent===l.ControlComponent.RADIO){c++;continue}const g=(T,p,m,I)=>{if(I===l.ControlType.CHECKBOX||I===l.ControlType.RADIO){let P=-1;for(let O=T;O<s.length&&s[O].controlId===p;O++)P=O;return P}const L=m?[l.ControlComponent.POSTTEXTFIX,l.ControlComponent.POSTTEXTFIX_TEXT]:[l.ControlComponent.POSTFIX];for(let P=T;P<s.length;P++){const O=s[P];if(O.controlId===p&&L.includes(O.controlComponent))return P}return-1},f=(T,p,m)=>{const I=[];let L=T;for(;L<=p;){const P=s[L];if(P.controlId&&P.controlId!==m&&P.control){const V=P.control?.type,Y=V===l.ControlType.TEXTFIELD,X=Y?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,b=P.controlComponent===X,E=V===l.ControlType.CHECKBOX||V===l.ControlType.RADIO;if(b||E&&(P.controlComponent===l.ControlComponent.CHECKBOX||P.controlComponent===l.ControlComponent.RADIO)){const C=g(L+1,P.controlId,Y,V);if(C!==-1){const M=s.slice(L,C+1).map(W=>{const D=at(W);return delete D.originControlId,D}),y=Mt(M,t);y.length>0&&I.push(y[0]),L=C+1;continue}}}if(!(P.controlId===m&&(P.controlComponent===l.ControlComponent.VALUE||!P.controlComponent)&&(!P.originControlId||P.originControlId===m)||P.originControlId===m&&P.controlComponent===l.ControlComponent.VALUE||P.controlId===m&&(P.controlComponent===l.ControlComponent.CHECKBOX||P.controlComponent===l.ControlComponent.RADIO)&&!P.originControlId)){L++;continue}if(P.type===l.ElementType.MENSTRUAL_HISTORY||P.type===l.ElementType.FETAL_HEART_POSITION||P.type===l.ElementType.TOOTH_POSITION||P.type===l.ElementType.MACRO||P.type===l.ElementType.CUSTOM_MACRO||P.type===l.ElementType.REUSABLE_ITEM||P.type===l.ElementType.LIST||P.type===l.ElementType.SPECIAL_SYMBOLS){const V=at(P);delete V.controlId,delete V.control,delete V.controlComponent,delete V.originControlId,I.push(V),L++;continue}if(P.controlComponent===l.ControlComponent.CHECKBOX||P.controlComponent===l.ControlComponent.RADIO){I.push(at(P)),L++;continue}const F=d.control?.type;if(F===l.ControlType.CHECKBOX||F===l.ControlType.RADIO){let V=L-1,Y=!1;for(;V>=T-1;){const X=s[V];if(X.controlId===m&&!X.originControlId)if(X.controlComponent===l.ControlComponent.CHECKBOX){Y=X.checkbox?.value===!0;break}else if(X.controlComponent===l.ControlComponent.RADIO){Y=X.radio?.value===!0;break}else if(X.controlComponent===l.ControlComponent.VALUE){V--;continue}else break;V--}if(Y){const X={value:P.value||""},b=[...Bt,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const E of b){const C=P[E];if(C!==void 0){if(E==="color"&&r){const M=r.control?.bracketColor,y=r.control?.placeholderColor;if(C===M||C===y)continue}X[E]=C}}I.push(X)}}else{const V={value:P.value||""},Y=[...Bt,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const X of Y){const b=P[X];if(b!==void 0){if(X==="color"&&r){const E=r.control?.bracketColor,C=r.control?.placeholderColor;if(b===E||b===C)continue}V[X]=b}}I.push(V)}L++}return I};if(d.controlComponent===l.ControlComponent.PREFIX){const T=d.control?.type===l.ControlType.TEXTFIELD,p=g(c+1,u,T);if(p!==-1){const m=f(c+1,p-1,u),I=Dt(d,Gt),L={...d.control,...I,value:m},P={...Dt(d,Bt),type:l.ElementType.CONTROL,value:"",control:L,controlId:u};d=De(P,{extraPickAttrs:e}),c=p}}if(d.controlComponent===l.ControlComponent.PRETEXTFIX){const T=g(c+1,u,!0);if(T!==-1){const p=f(c+1,T-1,u),m=Dt(d,Gt),I={...d.control,...m,value:p},L={...Dt(d,Bt),type:l.ElementType.CONTROL,value:"",control:I,controlId:u};d=De(L,{extraPickAttrs:e}),c=T}}if(d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){const T=g(c+1,u,!0);if(T!==-1){const p=f(c+1,T-1,u),m=Dt(d,Gt),I={...d.control,...m,value:p},L={...Dt(d,Bt),type:l.ElementType.CONTROL,value:"",control:I,controlId:u};d=De(L,{extraPickAttrs:e}),c=T}}}}const R=De(d,{extraPickAttrs:e});if(!d.type||d.type===l.ElementType.TEXT||d.type===l.ElementType.SUBSCRIPT||d.type===l.ElementType.SUPERSCRIPT)for(;c<s.length;){const u=s[c+1];if(c++,u&&Gl(R,De(u,{extraPickAttrs:e}))){const h=u.value===_?`
|
|
83
83
|
`:u.value;R.value+=h}else break}else c++;a.push(R)}return a}function Ji(o){switch(window.getComputedStyle(o).textAlign){case"left":case"start":return l.RowFlex.LEFT;case"center":return l.RowFlex.CENTER;case"right":case"end":return l.RowFlex.RIGHT;case"justify":return l.RowFlex.ALIGNMENT;case"justify-all":return l.RowFlex.JUSTIFY;default:return l.RowFlex.LEFT}}function Bi(o){return o===l.RowFlex.ALIGNMENT?"justify":o}function Al(o){switch(o){case l.RowFlex.LEFT:return"flex-start";case l.RowFlex.CENTER:return"center";case l.RowFlex.RIGHT:return"flex-end";case l.RowFlex.ALIGNMENT:case l.RowFlex.JUSTIFY:return"space-between";default:return"flex-start"}}function vn(o){return!o.type||$t.includes(o.type)}function kl(o){return!o.type||o.type===l.ElementType.TEXT}function $i(o){return o.filter(t=>vn(t)).map(t=>t.value).join("").replace(new RegExp(_,"g"),"")}function je(o,t){const e=o[t];if(!e)return null;const n=o[t+1];return!e.listId&&e.value===_&&n&&n.value!==_&&e.areaId===n.areaId?n:e}function Ut(o,t,e,n){let i=je(o,e);if(!i)return;const{isBreakWhenWrap:r=!1,editorOptions:s,ignoreContextKeys:a=[]}=n||{},{mode:c}=s||{};c!==l.EditorMode.DESIGN&&i.title?.disabled&&(i=ie(i,Eo));let d=!1;for(let R=0;R<t.length;R++){const u=t[R];if(r&&!i.listId&&po.test(u.value)&&(d=!0),d||!i.listId&&u.type===l.ElementType.LIST){const g=[...Be,...Bt,...Ke];Yi(g,a),Ye(g,i,u),u.valueList?.forEach(f=>{Ye(g,i,f)});continue}u.valueList?.length&&Ut(o,u.valueList,e,n);const h=[...No];nn(u)||h.push(...Bt),Yi(h,a),Ye(h,i,u)}}function Jl(o,t){let e="span";o.type===l.ElementType.SUPERSCRIPT?e="sup":o.type===l.ElementType.SUBSCRIPT&&(e="sub");const n=document.createElement(e);return n.style.fontFamily=o.font||t.defaultFont,o.rowFlex&&(n.style.textAlign=Bi(o.rowFlex)),o.color&&(n.style.color=o.color),o.bold&&(n.style.fontWeight="600"),o.italic&&(n.style.fontStyle="italic"),n.style.fontSize=`${o.size||t.defaultSize}px`,o.highlight&&(n.style.backgroundColor=o.highlight),o.underline&&(n.style.textDecoration="underline",n.style.textDecorationStyle=o.textDecoration?.style||"solid"),o.strikeout&&(n.style.textDecoration+=" line-through"),o.type&&n.setAttribute("data-type",o.type),o.rowMargin&&(n.style.lineHeight=(o.rowMargin??t.defaultRowMargin).toString()),n.innerText=o.value.replace(new RegExp(`${_}`,"g"),`
|
|
84
84
|
`),n}function zi(o){let t=0;const e=new Map;for(let n=0;n<o.length;n++){const i=o[n];if(n===0){if(i.checkbox)continue;i.value=i.value.replace(po,"")}if(i.listWrap){const r=e.get(t)||[];r.push(i),e.set(t,r)}else{const r=i.value.split(`
|
|
85
|
-
`);for(let s=0;s<r.length;s++){s>0&&(t+=1);const a=r[s],c=e.get(t)||[];c.push({...i,value:a}),e.set(t,c)}}}return e}function Bl(o){const t=[];if(!o.length)return t;let e=o[0]?.rowFlex||null;t.push({rowFlex:e,data:[o[0]]});for(let n=1;n<o.length;n++){const i=o[n],r=i.rowFlex||null;e===r&&!nn(i)&&!nn(o[n-1])?t[t.length-1].data.push(i):(t.push({rowFlex:r,data:[i]}),e=r)}for(let n=0;n<t.length;n++){const i=t[n];i.data=
|
|
85
|
+
`);for(let s=0;s<r.length;s++){s>0&&(t+=1);const a=r[s],c=e.get(t)||[];c.push({...i,value:a}),e.set(t,c)}}}return e}function Bl(o){const t=[];if(!o.length)return t;let e=o[0]?.rowFlex||null;t.push({rowFlex:e,data:[o[0]]});for(let n=1;n<o.length;n++){const i=o[n],r=i.rowFlex||null;e===r&&!nn(i)&&!nn(o[n-1])?t[t.length-1].data.push(i):(t.push({rowFlex:r,data:[i]}),e=r)}for(let n=0;n<t.length;n++){const i=t[n];i.data=Mt(i.data)}return t}function qe(o,t){const e=Yo(t);function n(s){const a=document.createElement("div");for(let c=0;c<s.length;c++){const d=s[c];if(d.type===l.ElementType.TABLE){const R=document.createElement("table");R.setAttribute("cellSpacing","0"),R.setAttribute("cellpadding","0"),R.setAttribute("border","0");const u="1px solid #000000";!d.borderType||d.borderType===l.TableBorder.ALL?(R.style.borderTop=u,R.style.borderLeft=u):d.borderType===l.TableBorder.EXTERNAL&&(R.style.border=u),R.style.width=`${d.width}px`;const h=document.createElement("colgroup");for(let f=0;f<d.colgroup.length;f++){const T=d.colgroup[f],p=document.createElement("col");p.setAttribute("width",`${T.width}`),h.append(p)}R.append(h);const g=d.trList;for(let f=0;f<g.length;f++){const T=document.createElement("tr"),p=g[f];T.style.height=`${p.height}px`;for(let m=0;m<p.tdList.length;m++){const I=document.createElement("td");(!d.borderType||d.borderType===l.TableBorder.ALL)&&(I.style.borderBottom=I.style.borderRight="1px solid");const L=p.tdList[m];I.colSpan=L.colspan,I.rowSpan=L.rowspan,I.style.verticalAlign=L.verticalAlign||"top",L.borderTypes?.includes(l.TdBorder.TOP)&&(I.style.borderTop=u),L.borderTypes?.includes(l.TdBorder.RIGHT)&&(I.style.borderRight=u),L.borderTypes?.includes(l.TdBorder.BOTTOM)&&(I.style.borderBottom=u),L.borderTypes?.includes(l.TdBorder.LEFT)&&(I.style.borderLeft=u);const P=qe(L.value,t);I.innerHTML=P.innerHTML,L.backgroundColor&&(I.style.backgroundColor=L.backgroundColor),T.append(I)}R.append(T)}a.append(R)}else if(d.type===l.ElementType.HYPERLINK){const R=document.createElement("a");R.innerText=d.valueList.map(u=>u.value).join(""),d.url&&(R.href=d.url),a.append(R)}else if(d.type===l.ElementType.TITLE){const R=document.createElement(`h${bo[d.level]}`),u=n(d.valueList);R.innerHTML=u.innerHTML,a.append(R)}else if(d.type===l.ElementType.LIST){const R=document.createElement(Il[d.listType]);d.listStyle&&(R.style.listStyleType=Pl[d.listStyle]);const u=Mt(d.valueList);zi(u).forEach(g=>{const f=document.createElement("li"),T=n(g);f.innerHTML=T.innerHTML,R.append(f)}),a.append(R)}else if(d.type===l.ElementType.IMAGE){const R=document.createElement("img");d.value&&(R.src=d.value,R.width=d.width,R.height=d.height),a.append(R)}else if(d.type===l.ElementType.BLOCK){if(d.block?.type===l.BlockType.VIDEO){const R=d.block.videoBlock?.src;if(R){const u=document.createElement("video");u.style.display="block",u.controls=!0,u.src=R,u.width=d.width||t?.width||window.innerWidth,u.height=d.height,a.append(u)}}else if(d.block?.type===l.BlockType.IFRAME){const{src:R,srcdoc:u,sandbox:h,allow:g}=d.block.iframeBlock||{};if(R||u){const f=document.createElement("iframe");f.sandbox.add(...h||$e.sandbox),f.setAttribute("allow",[g||$e.allow].join(" ")),f.style.display="block",f.style.border="none",R?f.src=R:u&&(f.srcdoc=u),f.width=`${d.width||t?.width||window.innerWidth}`,f.height=`${d.height}`,a.append(f)}}}else if(d.type===l.ElementType.SEPARATOR){const R=document.createElement("hr");d.dashArray?.length&&R.setAttribute("data-dash-array",d.dashArray.join(",")),a.append(R)}else if(d.type===l.ElementType.CHECKBOX){const R=document.createElement("input");R.type="checkbox",d.checkbox?.value&&R.setAttribute("checked","true"),a.append(R)}else if(d.type===l.ElementType.RADIO){const R=document.createElement("input");R.type="radio",d.radio?.value&&R.setAttribute("checked","true"),a.append(R)}else if(d.type===l.ElementType.TAB){const R=document.createElement("span");R.innerHTML=`${Fi}${Fi}`,a.append(R)}else if(d.type===l.ElementType.CONTROL){const R=document.createElement("span"),u=n(d.control?.value||[]);R.innerHTML=u.innerHTML,a.append(R)}else if(d.type===l.ElementType.PAGE_BREAK){const R=document.createElement("div");R.style.breakAfter="page",a.append(R)}else if(!d.type||d.type===l.ElementType.LATEX||$t.includes(d.type)){let R="";if(d.type===l.ElementType.DATE?R=d.valueList?.map(h=>h.value).join("")||"":R=d.value,!R)continue;const u=Jl(d,e);s[c-1]?.type===l.ElementType.TITLE&&(R=R.replace(/^\n/,"")),u.innerText=R.replace(new RegExp(`${_}`,"g"),`
|
|
86
86
|
`),a.append(u)}}return a}const i=document.createElement("div"),r=Bl(o);for(let s=0;s<r.length;s++){const a=r[s],c=!a.rowFlex||a.rowFlex===l.RowFlex.LEFT,d=document.createElement("div");if(!c){const R=a.data[0];nn(R)?(d.style.display="flex",d.style.justifyContent=Al(R.rowFlex)):(d.style.textAlign=Bi(a.rowFlex),a.rowFlex==="justify"&&(d.style.textAlignLast="justify"))}d.innerHTML=n(a.data).innerHTML,c?d.childNodes.forEach(R=>{i.append(R.cloneNode(!0))}):i.append(d)}return i}function $l(o){if(!o||o.nodeType!==3)return null;const t=o.parentNode,e=t.nodeName==="FONT"?t.parentNode:t,n=Ji(e),i=o.textContent,r=window.getComputedStyle(e);if(!i||e.nodeName==="STYLE")return null;const s={value:i,color:r.color,bold:Number(r.fontWeight)>500,italic:r.fontStyle.includes("italic"),size:Math.floor(parseFloat(r.fontSize))};return e.nodeName==="SUB"||r.verticalAlign==="sub"?s.type=l.ElementType.SUBSCRIPT:(e.nodeName==="SUP"||r.verticalAlign==="super")&&(s.type=l.ElementType.SUPERSCRIPT),n!==l.RowFlex.LEFT&&(s.rowFlex=n),r.backgroundColor!=="rgba(0, 0, 0, 0)"&&(s.highlight=r.backgroundColor),r.textDecorationLine.includes("underline")&&(s.underline=!0),r.textDecorationLine.includes("line-through")&&(s.strikeout=!0),s}function tn(o,t){const e=[];function n(c){if(c.nodeType===3){const d=$l(c);d&&e.push(d)}else if(c.nodeType===1){const d=c.childNodes;for(let R=0;R<d.length;R++){const u=d[R];if(u.nodeName==="BR")e.push({value:`
|
|
87
87
|
`});else if(u.nodeName==="A"){const h=u,g=h.innerText;g&&e.push({type:l.ElementType.HYPERLINK,value:"",valueList:[{value:g}],url:h.href})}else if(/H[1-6]/.test(u.nodeName)){const g=tn(zl(u,"div").outerHTML,t);e.push({value:"",type:l.ElementType.TITLE,level:Ol[u.nodeName],valueList:g}),u.nextSibling&&!al.includes(u.nextSibling.nodeName)&&e.push({value:`
|
|
88
88
|
`})}else if(u.nodeName==="UL"||u.nodeName==="OL"){const h=u,g={value:"",type:l.ElementType.LIST,valueList:[]};u.nodeName==="OL"?g.listType=l.ListType.OL:(g.listType=l.ListType.UL,g.listStyle=h.style.listStyleType),h.querySelectorAll("li").forEach(f=>{const T=tn(f.innerHTML,t);T.forEach(p=>{p.value===`
|
|
@@ -91,17 +91,17 @@ trailer
|
|
|
91
91
|
`,type:l.ElementType.SEPARATOR});else if(u.nodeName==="IMG"){const{src:h,width:g,height:f}=u;h&&g&&f&&e.push({width:g,height:f,value:h,type:l.ElementType.IMAGE,rowFlex:Ji(u.parentElement)})}else if(u.nodeName==="VIDEO"){const{src:h,width:g,height:f}=u;h&&g&&f&&e.push({value:"",type:l.ElementType.BLOCK,block:{type:l.BlockType.VIDEO,videoBlock:{src:h}},width:g,height:f})}else if(u.nodeName==="IFRAME"){const{src:h,srcdoc:g,width:f,height:T}=u;(h||g)&&f&&T&&e.push({value:"",type:l.ElementType.BLOCK,block:{type:l.BlockType.IFRAME,iframeBlock:{src:h,srcdoc:g}},width:parseInt(f),height:parseInt(T)})}else if(u.nodeName==="TABLE"){const h=u,g={type:l.ElementType.TABLE,value:`
|
|
92
92
|
`,colgroup:[],trList:[]},f=h.querySelectorAll("colgroup col");if(h.querySelectorAll("tr").forEach(T=>{const p=Number(window.getComputedStyle(T).height.replace("px","")),m={height:p,minHeight:p,tdList:[]};T.querySelectorAll("th,td").forEach(I=>{const L=I,P=tn(L.innerHTML,t),O={colspan:L.colSpan,rowspan:L.rowSpan,value:P,verticalAlign:window.getComputedStyle(I).verticalAlign,width:parseFloat(window.getComputedStyle(I).width)};L.style.backgroundColor&&(O.backgroundColor=L.style.backgroundColor),m.tdList.push(O)}),g.trList.push(m)}),g.trList.length){const T=g.trList[0].tdList.reduce((m,I)=>m+I.colspan,0),p=Math.ceil(t.innerWidth/T);for(let m=0;m<T;m++){const I=f[m]?.getAttribute("width");g.colgroup.push({width:I?parseFloat(I):p})}e.push(g)}}else if(u.nodeName==="INPUT"&&u.type===l.ControlComponent.CHECKBOX)e.push({type:l.ElementType.CHECKBOX,value:"",checkbox:{value:u.checked}});else if(u.nodeName==="INPUT"&&u.type===l.ControlComponent.RADIO)e.push({type:l.ElementType.RADIO,value:"",radio:{value:u.checked}});else if(n(u),u.nodeType===1&&R!==d.length-1){const h=u;window.getComputedStyle(h).display==="block"&&!/(\n|\r\n)$/.test(h.textContent)&&e.push({value:`
|
|
93
93
|
`})}}}}const i=document.createElement("div");document.body.appendChild(i);const r=i.attachShadow({mode:"open"}),s=document.createElement("div");s.innerHTML=o,r.appendChild(s);const a=[];return s.childNodes.forEach(c=>{c.nodeType!==1&&!c.textContent?.trim()&&a.push(c)}),a.forEach(c=>c.remove()),n(s),i.remove(),e}function en(o){function t(e){let n="";for(let i=0;i<e.length;i++){const r=e[i];if(r.type===l.ElementType.TABLE){n+=`
|
|
94
|
-
`;const s=r.trList;for(let a=0;a<s.length;a++){const c=s[a];for(let d=0;d<c.tdList.length;d++){const R=c.tdList[d],u=t(
|
|
95
|
-
`:""}`}}}else if(r.type===l.ElementType.TAB)n+=" ";else if(r.type===l.ElementType.HYPERLINK)n+=r.valueList.map(s=>s.value).join("");else if(r.type===l.ElementType.TITLE)n+=`${t(
|
|
94
|
+
`;const s=r.trList;for(let a=0;a<s.length;a++){const c=s[a];for(let d=0;d<c.tdList.length;d++){const R=c.tdList[d],u=t(Mt(R.value)),h=d===0,g=c.tdList.length-1===d;n+=`${h?"":" "}${u}${g?`
|
|
95
|
+
`:""}`}}}else if(r.type===l.ElementType.TAB)n+=" ";else if(r.type===l.ElementType.HYPERLINK)n+=r.valueList.map(s=>s.value).join("");else if(r.type===l.ElementType.TITLE)n+=`${t(Mt(r.valueList))}`;else if(r.type===l.ElementType.LIST){const s=Mt(r.valueList),a=zi(s);let c="";r.listType===l.ListType.UL&&(c=Wo[r.listStyle]),a.forEach((d,R)=>{const u=a.size-1===R;n+=`
|
|
96
96
|
${c||`${R+1}.`}${t(d)}${u?`
|
|
97
97
|
`:""}`})}else if(r.type===l.ElementType.CHECKBOX)n+=r.checkbox?.value?"☑":"□";else if(r.type===l.ElementType.RADIO)n+=r.radio?.value?"☉":"○";else if(!r.type||r.type===l.ElementType.LATEX||$t.includes(r.type)){let s="";if(r.type===l.ElementType.CONTROL){const a=r.control.value?.[0]?.value||"";s=a?`${r.control?.preText||""}${a}${r.control?.postText||""}`:""}else r.type===l.ElementType.DATE?s=r.valueList?.map(a=>a.value).join("")||"":s=r.value;n+=s.replace(new RegExp(`${_}`,"g"),`
|
|
98
|
-
`)}}return n}return t(
|
|
99
|
-
`,r.append(c),a.selectNodeContents(r),s?.removeAllRanges(),s?.addRange(a),document.execCommand("copy"),r.remove()}ql({text:o,elementList:e})}async function ns(o,t){const e=qe(o,t);document.body.append(e);const n=e.innerText;e.remove();const i=e.innerHTML;!n&&!i&&!o.length||await na(n,i,
|
|
100
|
-
`||(t.splice(a,0,R),a++)}a--}a++}}Ut(r,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function os(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=tn(t,{innerWidth:e.getOriginalInnerWidth()});Zo(o,n)}function Qo(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=e.getRange(),{startIndex:i}=n.getRange(),r=e.getElementList(),s=new FileReader;s.readAsDataURL(t),s.onload=()=>{const a=new Image,c=s.result;a.src=c,a.onload=()=>{const d={value:c,type:l.ElementType.IMAGE,width:a.width,height:a.height};~i&&Ut(r,[d],i,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function ia(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:i}=e.getOverride();if(i&&i(t)?.preventDefault!==!1)return;if(!oa(n)){const s=n.getData("text"),a=qi();if(a&&Un(s)===Un(a.text)){Zo(o,a.elementList);return}}ts();let r=!1;for(let s=0;s<n.items.length;s++)if(n.items[s].type==="text/html"){r=!0;break}for(let s=0;s<n.items.length;s++){const a=n.items[s];if(a.kind==="string"){if(a.type==="text/plain"&&!r){a.getAsString(c=>{o.input(c)});break}if(a.type==="text/html"&&r){a.getAsString(c=>{os(o,c)});break}}else if(a.kind==="file"&&a.type.includes("image")){const c=a.getAsFile();c&&Qo(o,c)}}}async function sa(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=await navigator.clipboard.readText(),r=qi();if(r&&Un(i)===Un(r.text)){Zo(o,r.elementList);return}if(ts(),t?.isPlainText)i&&o.input(i);else{const s=await navigator.clipboard.read();let a=!1;for(const c of s)if(c.types.includes("text/html")){a=!0;break}for(const c of s)if(c.types.includes("text/plain")&&!a){const R=await(await c.getType("text/plain")).text();R&&o.input(R)}else if(c.types.includes("text/html")&&a){const R=await(await c.getType("text/html")).text();R&&os(o,R)}else if(c.types.some(d=>d.startsWith("image/"))){const d=c.types.find(u=>u.startsWith("image/")),R=await c.getType(d);Qo(o,R)}}}class ra{draw;container;agentCursorDom;canvasEvent;eventBus;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.canvasEvent=e,this.eventBus=t.getEventBus();const n=document.createElement("textarea");n.autocomplete="off",n.classList.add(`${z}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=i=>this._keyDown(i),n.oninput=this._input.bind(this),n.onpaste=i=>this._paste(i),n.addEventListener("compositionstart",this._compositionstart.bind(this)),n.addEventListener("compositionupdate",this._compositionupdate.bind(this)),n.addEventListener("compositionend",this._compositionend.bind(this)),n.addEventListener("keydown",this._keydown.bind(this)),this.eventBus.on("rangeStyleChange",i=>{this.agentCursorDom.style.fontSize=Math.max(i.size,18)+"px"})}getAgentCursorDom(){return this.agentCursorDom}_keyDown(t){this.draw.isInteractionSuspended()||this.canvasEvent.keydown(t)}_input(t){if(this.draw.isInteractionSuspended())return;const e=t.data;e&&this.canvasEvent.input(e),this.eventBus.isSubscribe("input")&&this.eventBus.emit("input",t)}_paste(t){this.draw.isInteractionSuspended()||this.draw.isReadonly()||!t.clipboardData||(ia(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="1000",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="#000",this.agentCursorDom.style.background="#fff",this.canvasEvent.compositionstart())}_compositionupdate(){if(this.draw.isInteractionSuspended())return;this.agentCursorDom.style.width="9999px";let t=this.agentCursorDom.scrollWidth;const e=this.container.clientWidth,n=Math.max(e-this.agentCursorDom.offsetLeft,100);t>n&&(t=n),this.agentCursorDom.style.width=t+"px"}_compositionend(t){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="-1",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="",this.agentCursorDom.style.background="",this.canvasEvent.compositionend(t))}_keydown(t){this.draw.isInteractionSuspended()||this.canvasEvent.isComposing&&t.code==="Escape"&&this.canvasEvent.compositionCancel()}}class la{ANIMATION_CLASS=`${z}-cursor--animation`;draw;container;options;position;cursorDom;cursorAgent;blinkTimeout;hitLineStartIndex;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${z}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new ra(t,e),this.blinkTimeout=null}getCursorDom(){return this.cursorDom}getAgentDom(){return this.cursorAgent.getAgentCursorDom()}getAgentIsActive(){return this.getAgentDom()===document.activeElement}getAgentDomValue(){return this.getAgentDom().value}clearAgentDomValue(){this.getAgentDom().value=""}getHitLineStartIndex(){return this.hitLineStartIndex}_blinkStart(){this.cursorDom.classList.add(this.ANIMATION_CLASS)}_blinkStop(){this.cursorDom.classList.remove(this.ANIMATION_CLASS)}_setBlinkTimeout(){this._clearBlinkTimeout(),this.blinkTimeout=window.setTimeout(()=>{this._blinkStart()},500)}_clearBlinkTimeout(){this.blinkTimeout&&(this._blinkStop(),window.clearTimeout(this.blinkTimeout),this.blinkTimeout=null)}focus(){if(el&&this.draw.isReadonly())return;const t=this.cursorAgent.getAgentCursorDom();document.activeElement!==t&&(t.focus(),t.setSelectionRange(0,0))}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:n,cursor:i}=this.options,{color:r,width:s,isShow:a=!0,isBlink:c=!0,isFocus:d=!0,hitLineStartIndex:R}={...i,...t},u=this.draw.getHeight(),h=this.draw.getPageGap();this.hitLineStartIndex=R,R&&(e=this.position.getPositionList()[R]);const{metrics:g,coordinate:{leftTop:f,rightTop:T},ascent:p,pageNo:m}=e,P=(this.draw.getZone().isMainActive()?m:this.draw.getPageNo())*(u+h),O=jr*n,S=Math.min(g.height/4,O),F=g.height+S*2,N=this.cursorAgent.getAgentCursorDom();d&&setTimeout(()=>{this.focus()});const V=g.boundingBoxDescent<0?0:g.boundingBoxDescent,Y=f[1]+p+V-(F-S)+P,X=R?f[0]:T[0];if(N.style.left=`${X}px`,N.style.top=`${Y+F-O}px`,!a){this.recoveryCursor();return}const b=this.cursorDom.style.top,E=this.draw.isReadonly();this.cursorDom.style.width=`${s*n}px`,this.cursorDom.style.backgroundColor=r,this.cursorDom.style.left=`${X}px`,this.cursorDom.style.top=`${Y}px`,this.cursorDom.style.display=E?"none":"block",this.cursorDom.style.height=`${F}px`,c?this._setBlinkTimeout():this._clearBlinkTimeout(),Oo(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(b)>Y?Zt.UP:Zt.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:i,coordinate:{leftTop:r,leftBottom:s}}=e,a=Jr(this.container),c={left:0,right:0,top:0,bottom:0},d=a===document.documentElement;if(d)c.right=window.innerWidth,c.bottom=window.innerHeight;else{const{left:T,right:p,top:m,bottom:I}=a.getBoundingClientRect();c.left=T,c.right=p,c.top=m,c.bottom=I}const R=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,u=n===Zt.UP,h=s[0]+(d?0:c.left),g=u?r[1]+R:s[1]+R,{maskMargin:f}=this.options;if(c.top+=f[0],c.bottom-=f[2],!(h>=c.left&&h<=c.right&&g>=c.top&&g<=c.bottom)){const{scrollLeft:T,scrollTop:p}=a;u?a.scroll(T,p-(c.top-g)):a.scroll(T,p+g-c.bottom)}}}var Kn;(function(o){o[o.LEFT=0]="LEFT",o[o.CENTER=1]="CENTER",o[o.RIGHT=2]="RIGHT"})(Kn||(Kn={}));function fe(o){return ve?o.metaKey:o.ctrlKey}l.KeyMap=void 0,(function(o){o.Delete="Delete",o.Backspace="Backspace",o.Enter="Enter",o.Left="ArrowLeft",o.Right="ArrowRight",o.Up="ArrowUp",o.Down="ArrowDown",o.ESC="Escape",o.TAB="Tab",o.META="Meta",o.LEFT_BRACKET="[",o.RIGHT_BRACKET="]",o.COMMA=",",o.PERIOD=".",o.LEFT_ANGLE_BRACKET="<",o.RIGHT_ANGLE_BRACKET=">",o.EQUAL="=",o.MINUS="-",o.PLUS="+",o.A="a",o.B="b",o.C="c",o.D="d",o.E="e",o.F="f",o.G="g",o.H="h",o.I="i",o.J="j",o.K="k",o.L="l",o.M="m",o.N="n",o.O="o",o.P="p",o.Q="q",o.R="r",o.S="s",o.T="t",o.U="u",o.V="v",o.W="w",o.X="x",o.Y="y",o.Z="z",o.A_UPPERCASE="A",o.B_UPPERCASE="B",o.C_UPPERCASE="C",o.D_UPPERCASE="D",o.E_UPPERCASE="E",o.F_UPPERCASE="F",o.G_UPPERCASE="G",o.H_UPPERCASE="H",o.I_UPPERCASE="I",o.J_UPPERCASE="J",o.K_UPPERCASE="K",o.L_UPPERCASE="L",o.M_UPPERCASE="M",o.N_UPPERCASE="N",o.O_UPPERCASE="O",o.P_UPPERCASE="P",o.Q_UPPERCASE="Q",o.R_UPPERCASE="R",o.S_UPPERCASE="S",o.T_UPPERCASE="T",o.U_UPPERCASE="U",o.V_UPPERCASE="V",o.W_UPPERCASE="W",o.X_UPPERCASE="X",o.Y_UPPERCASE="Y",o.Z_UPPERCASE="Z",o.ZERO="0",o.ONE="1",o.TWO="2",o.THREE="3",o.FOUR="4",o.FIVE="5",o.SIX="6",o.SEVEN="7",o.EIGHT="8",o.NINE="9"})(l.KeyMap||(l.KeyMap={}));class Hn{element;control;constructor(t,e){this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){return this.element.control?.code||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),n=t[e],i=[];let r=e;for(;r>0;){const a=t[r];if(a.controlId!==n.controlId||a.controlComponent===l.ControlComponent.PREFIX||a.controlComponent===l.ControlComponent.PRE_TEXT)break;a.controlComponent===l.ControlComponent.VALUE&&i.unshift(a),r--}let s=e+1;for(;s<t.length;){const a=t[s];if(a.controlId!==n.controlId||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT)break;a.controlComponent===l.ControlComponent.VALUE&&i.push(a),s++}return i}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:s}=e.range||this.control.getRange(),a=r[s];let c=s;for(;c>0;){const R=r[c];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT)break;if(R.controlComponent===l.ControlComponent.CHECKBOX){const u=R.checkbox;u.value=t.includes(u.code)}c--}let d=s+1;for(;d<r.length;){const R=r[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POST_TEXT)break;if(R.controlComponent===l.ControlComponent.CHECKBOX){const u=R.checkbox;u.value=t.includes(u.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:s,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:i}=e;return t.key===l.KeyMap.Backspace||t.key===l.KeyMap.Delete?this.control.removeControl(n):i}cut(){return-1}}class vo extends Hn{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:s}=e.range||this.control.getRange(),a=r[s];let c=s;for(;c>0;){const R=r[c];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT)break;if(R.controlComponent===l.ControlComponent.RADIO){const u=R.radio;u.value=t.includes(u.code)}c--}let d=s+1;for(;d<r.length;){const R=r[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POST_TEXT)break;if(R.controlComponent===l.ControlComponent.RADIO){const u=R.radio;u.value=t.includes(u.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:s,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function is(o){const t=o.getDraw(),e=t.getPosition(),n=t.getRange();o.isAllowDrag=!0,o.cacheRange=at(n.getRange()),o.cacheElementList=t.getElementList(),o.cachePositionList=e.getPositionList(),o.cachePositionContext=e.getPositionContext()}function ss(o,t){const{checkbox:e,control:n}=o;if(!n)t.getCheckboxParticle().setSelect(o);else{const i=n?.code?n.code.split(","):[];if(e?.value){const s=i.findIndex(a=>a===e.code);i.splice(s,1)}else e?.code&&i.push(e.code);const r=t.getControl().getActiveControl();r instanceof Hn&&r.setSelect(i)}}function rs(o,t){const{radio:e,control:n}=o;if(!n)t.getRadioParticle().setSelect(o);else{const i=e?.code?[e.code]:[],r=t.getControl().getActiveControl();r instanceof vo&&r.setSelect(i)}}function aa(o,t){const e=t.getDraw();let n=e.isReadonly();const i=e.getRange(),r=e.getPosition(),s=i.getRange();if(o.button===Kn.RIGHT&&(s.isCrossRowCol||!i.getIsCollapsed()))return;const c=o.target.dataset.index;if(c&&e.setPageNo(Number(c)),!t.isAllowDrag&&!n&&s.startIndex!==s.endIndex&&i.getIsPointInRange(o.offsetX,o.offsetY,e.getPageNo())){is(t);return}t.isAllowSelection=!0;const d=at(r.getPositionContext()),R=r.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!R)return;const{index:u,isDirectHit:h,isCheckbox:g,isRadio:f,isImage:T,isLabel:p,isMacro:m,isTable:I,tdValueIndex:L,hitLineStartIndex:P}=R;h&&m&&console.log("mousedown - positionResult:",{index:u,isDirectHit:h,isMacro:m}),t.mouseDownStartPosition={...R,index:I?L:u,originalIndex:u,x:o.offsetX,y:o.offsetY};const O=e.getElementList(),S=r.getPositionList(),F=I?L:u;let N;I?N=e.getTd().value[L]:N=O[F];const V=!!(h&&T),Y=!!(h&&g),X=!!(h&&f),b=!!(h&&p),E=!!(h&&m),C=tt=>tt&&(tt.type===l.ElementType.MACRO||tt.type===l.ElementType.CUSTOM_MACRO||tt.type===l.ElementType.REUSABLE_ITEM||tt.type===l.ElementType.SUB_TEMPLATE||tt.type===l.ElementType.MENSTRUAL_HISTORY||tt.type===l.ElementType.FETAL_HEART_POSITION||tt.type===l.ElementType.TOOTH_POSITION||tt.type===l.ElementType.LIST||tt.type===l.ElementType.SPECIAL_SYMBOLS),M=tt=>tt&&!!tt.originControlId&&!!tt.controlId,y=tt=>tt&&!!tt.originControlId&&!!tt.controlId&&(tt.controlComponent===l.ControlComponent.POSTFIX||tt.controlComponent===l.ControlComponent.POSTTEXTFIX||tt.controlComponent===l.ControlComponent.POST_TEXT||tt.controlComponent===l.ControlComponent.PLACEHOLDER),W=e.getMode()===l.EditorMode.FORM,D=W?e.getControl().getActiveTextControlLimit():null;let U=F;const Q=!!(D&&(!N?.controlId||N.controlId===D.controlId&&(N.originControlId||null)===D.originControlId||D.parentControlId&&N.controlId===D.parentControlId&&!N.originControlId));if(W&&(N?.controlId||N?.originControlId)){let tt;const ht=N.originControlId||N.controlId;for(let ut=F;ut>=0;ut--){const v=O[ut];if(v.controlId===ht&&!v.originControlId&&v.control?.type){tt=v.control.type;break}if(v.controlId!==N.controlId&&v.controlId!==ht)break}if(tt===l.ControlType.TEXT&&M(N))N.controlComponent===l.ControlComponent.PREFIX||N.controlComponent===l.ControlComponent.PRE_TEXT||N.controlComponent===l.ControlComponent.PRETEXTFIX||N.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT?U=Math.max(F-1,0):(N.controlComponent===l.ControlComponent.POSTFIX||N.controlComponent===l.ControlComponent.POST_TEXT||N.controlComponent===l.ControlComponent.POSTTEXTFIX||N.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&(U=F);else if(tt===l.ControlType.TEXTFIELD){const ut=N.controlComponent;if(!M(N)){if(!(F>0&&y(O[F-1]))){if(!(N.controlComponent===l.ControlComponent.VALUE&&C(N))){if(ut===l.ControlComponent.PRETEXTFIX||ut===l.ControlComponent.PRETEXTFIX_TEXT||ut===l.ControlComponent.POSTTEXTFIX||ut===l.ControlComponent.POSTTEXTFIX_TEXT||ut===l.ControlComponent.TEXTFIXLABEL||ut===l.ControlComponent.PREFIX||ut===l.ControlComponent.POSTFIX||ut===l.ControlComponent.PRE_TEXT||ut===l.ControlComponent.POST_TEXT||ut===l.ControlComponent.PLACEHOLDER)for(let v=F+1;v<O.length;v++){const K=O[v];if(K.controlId!==ht&&K.originControlId!==ht)break;if(K.controlComponent===l.ControlComponent.VALUE&&!C(K)){U=v;break}if(K.controlComponent===l.ControlComponent.POSTTEXTFIX||K.controlComponent===l.ControlComponent.POSTFIX){for(let w=F-1;w>=0;w--){const Z=O[w];if(Z.controlId!==ht&&Z.originControlId!==ht)break;if(Z.controlComponent===l.ControlComponent.VALUE&&!C(Z)){U=w;break}}break}}else if(ut===l.ControlComponent.VALUE&&F>0){const v=O[F-1];if(v&&(v.controlId===ht||v.originControlId===ht)&&v.controlComponent===l.ControlComponent.VALUE&&C(v)){let K=!1;for(let w=F-2;w>=0;w--){const Z=O[w];if(Z.controlId!==ht&&Z.originControlId!==ht||Z.controlComponent!==l.ControlComponent.VALUE&&!Z.originControlId&&Z.controlId===ht)break;if(!C(Z)){U=w+1,K=!0;break}}if(!K)for(let w=F;w<O.length;w++){const Z=O[w];if(Z.controlId!==ht&&Z.originControlId!==ht||(Z.controlComponent===l.ControlComponent.POSTTEXTFIX||Z.controlComponent===l.ControlComponent.POSTFIX)&&!Z.originControlId&&Z.controlId===ht)break;if(!C(Z)){U=w,K=!0;break}}}}}}}}}if(~u){Q&&(U=Math.min(Math.max(U,D.startIndex),D.endIndex));let tt=U,ht=U;if(o.shiftKey){const{startIndex:ut}=i.getRange();~ut&&r.getPositionContext().tdId===d.tdId&&(F>ut?tt=ut:ht=ut)}if(Q&&(tt=Math.min(Math.max(tt,D.startIndex),D.endIndex),ht=Math.min(Math.max(ht,D.startIndex),D.endIndex),U=Math.min(Math.max(U,D.startIndex),D.endIndex)),i.setRange(tt,ht),r.setCursorPosition(S[U]),n=e.isReadonly(),Y&&!n)ss(N,e);else if(X&&!n)rs(N,e);else if(N.controlComponent===l.ControlComponent.VALUE&&(N.control?.type===l.ControlType.CHECKBOX||N.control?.type===l.ControlType.RADIO)){let ut=F;for(;ut>0;){const v=O[ut];if(v.controlComponent===l.ControlComponent.CHECKBOX){ss(v,e);break}else if(v.controlComponent===l.ControlComponent.RADIO){rs(v,e);break}ut--}}else{const ut=N?.control?.type===l.ControlType.BUTTON&&!N.control?.buttonText,v=h&&ut;let K=!1;if(W&&N?.controlId&&N?.controlComponent===l.ControlComponent.VALUE&&!N.originControlId)for(let x=F;x>=0;x--){const A=O[x];if(A.controlId!==N.controlId)break;if(A.control?.type===l.ControlType.TEXTFIELD){K=!0;break}}const w=K&&C(N),Z=E&&!w?U+1:void 0;e.render({curIndex:E&&!w?Z:U,isCompute:!1,isSubmitHistory:!1,isSetCursor:!V&&!Y&&!X&&!(v&&W)&&!w});const J=O[U];if(!n&&h&&J?.controlId&&o.button===Kn.LEFT){const A=e.getControl().getActiveControl(),$=A?.getElement()?.control?.type;A&&($===l.ControlType.NUMBER||$===l.ControlType.SELECT)&&A.getElement()?.controlId===J.controlId&&J.controlComponent!==l.ControlComponent.POSTFIX&&J.controlComponent!==l.ControlComponent.POSTTEXTFIX&&J.controlComponent!==l.ControlComponent.POSTTEXTFIX_TEXT&&J.controlComponent!==l.ControlComponent.POST_TEXT&&typeof A.awake=="function"&&A.awake()}}P&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:P})}const G=e.getEventBus();if(b&&G.isSubscribe("labelMousedown")&&G.emit("labelMousedown",{evt:o,element:N}),E&&(N.type===l.ElementType.MACRO||N.type===l.ElementType.CUSTOM_MACRO||N.type===l.ElementType.REUSABLE_ITEM)){const tt=e.getMode();tt===l.EditorMode.EDIT&&N.type===l.ElementType.CUSTOM_MACRO?G.isSubscribe("macroClick")&&G.emit("macroClick",{evt:o,element:N}):tt===l.EditorMode.FORM&&G.isSubscribe("macroValueChange")&&G.emit("macroValueChange",{evt:o,element:N})}if(console.log("检查子模板点击 - isDirectHitMacro:",E,"curElement.type:",N?.type,"ElementType.SUB_TEMPLATE:",l.ElementType.SUB_TEMPLATE),E&&N.type===l.ElementType.SUB_TEMPLATE){console.log("子模板被点击 - isDirectHitMacro:",E,"curElement.type:",N.type);const tt=e.getMode();console.log("当前模式:",tt,"是否表单模式:",tt===l.EditorMode.FORM),tt===l.EditorMode.FORM&&(console.log("准备触发 subTemplateClick 事件, eventBus:",G),console.log("是否订阅了 subTemplateClick:",G.isSubscribe("subTemplateClick")),G.isSubscribe("subTemplateClick")&&(G.emit("subTemplateClick",{evt:o,element:N}),console.log("subTemplateClick 事件已触发")))}else E&&N.type!==l.ElementType.SUB_TEMPLATE&&console.log("isDirectHitMacro 为 true,但 curElement.type 不是 subTemplate:",N.type);const H=e.getPreviewer();if(H.clearResizer(),V){const tt={dragDisable:n||!N.controlId&&e.getMode()===l.EditorMode.FORM};N.type===l.ElementType.LATEX&&(tt.mime="svg",tt.srcKey="laTexSVG"),H.drawResizer(N,S[F],tt),e.getCursor().drawCursor({isShow:!1}),is(t),(N.imgDisplay===l.ImageDisplay.SURROUND||N.imgDisplay===l.ImageDisplay.FLOAT_TOP||N.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(N),G.isSubscribe("imageMousedown")&&G.emit("imageMousedown",{evt:o,element:N})}const j=e.getTableTool();j.dispose(),I&&!n&&e.getMode()!==l.EditorMode.FORM&&j.render();const st=e.getHyperlinkParticle();st.clearHyperlinkPopup(),N.type===l.ElementType.HYPERLINK&&(fe(o)?st.openHyperlink(N):st.drawHyperlinkPopup(N,S[F]));const it=e.getDateParticle();it.clearDatePicker(),N.type===l.ElementType.DATE&&!n&&it.renderDatePicker(N,S[F]);const nt=e.getMenstrualHistoryParticle();nt.clearMenstrualHistoryEditor(),N.type===l.ElementType.MENSTRUAL_HISTORY&&h&&(e.getMode()===l.EditorMode.FORM||e.getMode()===l.EditorMode.EDIT)&&nt.renderMenstrualHistoryEditor(N,S[F]);const et=e.getFetalHeartPositionParticle();et.clearFetalHeartPositionEditor(),N.type===l.ElementType.FETAL_HEART_POSITION&&h&&(e.getMode()===l.EditorMode.FORM||e.getMode()===l.EditorMode.EDIT)&&et.renderFetalHeartPositionEditor(N,S[F]);const dt=e.getToothPositionParticle();dt.clearToothPositionEditor(),N.type===l.ElementType.TOOTH_POSITION&&h&&(e.getMode()===l.EditorMode.FORM||e.getMode()===l.EditorMode.EDIT)&&dt.renderToothPositionEditor(N,S[F])}function _n(o){const t=lt();return Reflect.set(o,"dragId",t),t}function xn(o,t){return t.findIndex(e=>e.dragId===o)}function ls(o,t,e){const n=e.getDraw();if(o.imgDisplay===l.ImageDisplay.SURROUND||o.imgDisplay===l.ImageDisplay.FLOAT_TOP||o.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM){const i=t.offsetX-e.mouseDownStartPosition.x,r=t.offsetY-e.mouseDownStartPosition.y,s=o.imgFloatPosition;o.imgFloatPosition={x:s.x+i,y:s.y+r,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function ca(o,t){if(t.isAllowDrop){const e=t.getDraw();if(e.isReadonly()||e.isDisabled()){t.mousedown(o);return}const n=e.getPosition(),i=n.getPositionList(),r=n.getPositionContext(),s=e.getRange(),a=t.cacheRange,c=t.cacheElementList,d=t.cachePositionList,R=t.cachePositionContext,u=s.getRange(),h=a.startIndex===a.endIndex,g=h?a.startIndex-1:a.startIndex,f=a.endIndex;if(u.startIndex>=g&&u.endIndex<=f&&t.cachePositionContext?.tdId===r.tdId){e.clearSideEffect();let it=!1,nt=!1;if(h){const et=c[f];if(et.type===l.ElementType.IMAGE||et.type===l.ElementType.LATEX){if(ls(et,o,t),et.imgDisplay===l.ImageDisplay.SURROUND||et.imgDisplay===l.ImageDisplay.FLOAT_TOP||et.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(et),it=!0;else{const dt=d[f];e.getPreviewer().drawResizer(et,dt)}nt=et.imgDisplay===l.ImageDisplay.SURROUND}}s.replaceRange({...a}),e.render({isCompute:nt,isSubmitHistory:it,isSetCursor:!1});return}const T=c.slice(g+1,f+1),p=T.find(it=>it.controlId);if(p){const it=c[g+1],nt=c[f];if(!((!it.controlId||it.controlComponent===l.ControlComponent.PREFIX)&&(!nt.controlId||nt.controlComponent===l.ControlComponent.POSTFIX)||it.controlId===nt.controlId&&it.controlComponent===l.ControlComponent.PREFIX&&nt.controlComponent===l.ControlComponent.POSTFIX||it.control?.type===l.ControlType.TEXT&&it.controlComponent===l.ControlComponent.VALUE&&nt.control?.type===l.ControlType.TEXT&&nt.controlComponent===l.ControlComponent.VALUE)){e.render({curIndex:u.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const m=e.getControl(),I=e.getElementList(),L=!p||!!I[u.startIndex].controlId||!m.getIsElementListContainFullControl(T),P=e.getOptions(),O=T.map(it=>{if(!it.type||it.type===l.ElementType.TEXT){const nt={value:it.value},et=Re;return L||et.push(...Xo),et.forEach(dt=>{const tt=it[dt];tt!==void 0&&(nt[dt]=tt)}),nt}else{let nt=at(it);return L&&(nt=ie(nt,Xo)),Vt([nt],{isHandleFirstElement:!1,editorOptions:P}),nt}});Ut(I,O,u.startIndex,{editorOptions:e.getOptions()});const S=c[g],F=d[g],N=_n(c[g]),V=_n(c[f]),Y=O.length;let X=u.startIndex,b=X+Y;const E=m.getActiveControl();if(E&&c[X].controlComponent!==l.ControlComponent.POSTFIX?(b=E.setValue(O),X=b-Y):e.spliceElementList(I,X+1,0,O),!~b){e.render({isSetCursor:!1});return}const C=_n(I[X]),M=_n(I[b]),y=xn(N,c),W=xn(V,c),D=c[W];if(D.controlId&&D.controlComponent!==l.ControlComponent.POSTFIX)s.replaceRange({...a,startIndex:y,endIndex:W}),m.getActiveControl()?.cut();else{let it=!0;if(R?.isTable){const{tableId:nt,trIndex:et,tdIndex:dt}=R;it=!e.getOriginalElementList().some(ht=>ht.id===nt&&ht?.trList?.[et]?.tdList?.[dt]?.deletable===!1)}it&&e.spliceElementList(c,y+1,W-y)}const U=I[u.startIndex],Q=i[u.startIndex];let G=r.index;G&&(U.tableId&&!S.tableId?F.index<G&&(G-=Y):!U.tableId&&S.tableId&&Q.index<G&&(G+=Y),n.setPositionContext({...r,index:G}));const H=xn(C,I),j=xn(M,I);s.setRange(h?j:H,j,u.tableId,u.startTdIndex,u.endTdIndex,u.startTrIndex,u.endTrIndex),e.clearSideEffect();let st=null;if(h){const nt=e.getElementList()[j];(nt.type===l.ElementType.IMAGE||nt.type===l.ElementType.LATEX)&&(ls(nt,o,t),st=nt)}if(e.render({isSetCursor:!1}),E?m.emitControlContentChange():S.controlId&&m.emitControlContentChange({context:{range:a,elementList:c},controlElement:S}),st)if(st.imgDisplay===l.ImageDisplay.SURROUND||st.imgDisplay===l.ImageDisplay.FLOAT_TOP||st.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(st);else{const nt=n.getPositionList()[j];e.getPreviewer().drawResizer(st,nt)}}else t.isAllowDrag&&t.cacheRange?.startIndex!==t.cacheRange?.endIndex&&t.mousedown(o)}function da(o,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:i,y:r,width:s,height:a}=n.getBoundingClientRect();o.x>=i&&o.x<=i+s&&o.y>=r&&o.y<=r+a||t.setIsAllowSelection(!1)}function Ra(o,t){const e=t.getDraw(),n=e.getControl(),i=e.getPageList(),r=e.getPageNo(),s=i[r],c=e.getPosition().getPositionByXY({x:o.offsetX,y:o.offsetY});if(~c.index){const C=e.getElementList(),M=c.isTable?c.tdValueIndex:c.index,y=C[M];y?.control?.type===l.ControlType.BUTTON&&!y.control?.buttonText?s&&(s.style.cursor="pointer"):s&&(s.style.cursor="text")}else s&&(s.style.cursor="text");if(t.isAllowDrag){const C=o.offsetX,M=o.offsetY,{startIndex:y,endIndex:W}=t.cacheRange,D=t.cachePositionList;for(let Q=y+1;Q<=W;Q++){const{coordinate:{leftTop:G,rightBottom:H}}=D[Q];if(C>=G[0]&&C<=H[0]&&M>=G[1]&&M<=H[1])return}const U=t.cacheRange?.startIndex;if(U){const Q=t.cacheElementList[U];Q?.type===l.ElementType.IMAGE&&(Q.imgDisplay===l.ImageDisplay.SURROUND||Q.imgDisplay===l.ImageDisplay.FLOAT_TOP||Q.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(o.movementX,o.movementY))}t.dragover(o),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const R=o.target.dataset.index;R&&e.setPageNo(Number(R));const u=e.getPosition(),h=u.getPositionByXY({x:o.offsetX,y:o.offsetY});if(!~h.index)return;const{index:g,isTable:f,tdValueIndex:T,tdIndex:p,trIndex:m,tableId:I,trId:L,tdId:P}=h,{index:O,isTable:S,tdIndex:F,tdId:N,trIndex:V,tableId:Y}=t.mouseDownStartPosition,X=f?T:g,b=e.getRange();let E;if(P!==N&&P&&N){const C=e.getTdByPosition({...t.mouseDownStartPosition,isTable:!!t.mouseDownStartPosition.tableId,index:t.mouseDownStartPosition.originalIndex??t.mouseDownStartPosition.index}),M=e.getTdByPosition({...h,isTable:!!h.tableId,index:h.index});if(e.isSplitTd(C,M)){const y=(C.valueStartIndex??0)+O,W=(M.valueStartIndex??0)+T;E=[{index:y,element:C.value[O],originalId:C.originalId,isCurrent:!1,length:C.value.length,startIndex:C.valueStartIndex??0},{index:W,element:M.value[T],originalId:M.originalId,isCurrent:!0,length:M.value.length,startIndex:M.valueStartIndex??0}]}}if(f&&S&&P!==N&&!E)b.setRange(X,X,I,F,p,V,m),u.setPositionContext({isTable:!!f,index:g,trIndex:m,tdIndex:p,tdId:P,trId:L,tableId:I});else{let C=~X?X:0;if((S||f)&&Y!==I&&!E)return;u.setPositionContext({isTable:!!f,index:g,trIndex:m,tdIndex:p,tdId:P,trId:L,tableId:I});let M=O,y,W;if(E)[{element:y},{element:W}]=E;else{const Q=e.getElementList();y=Q[M+1],W=Q[C]}if(M===C||y?.controlComponent===l.ControlComponent.PLACEHOLDER&&W?.controlComponent===l.ControlComponent.PLACEHOLDER&&y.controlId===W.controlId)return;if(M>C&&([M,C]=[C,M]),e.getMode()===l.EditorMode.FORM){const Q=n.getActiveTextControlLimit();Q&&(M=Math.min(Math.max(M,Q.startIndex),Q.endIndex),C=Math.min(Math.max(C,Q.startIndex),Q.endIndex));const G=e.getElementList(),H=G[M],j=G[C];if(H?.control?.type===l.ControlType.TEXTFIELD||j?.control?.type===l.ControlType.TEXTFIELD){const st=H?.controlId||j?.controlId;if(st){let it=-1,nt=-1;for(let et=M;et>=0;et--){const dt=G[et];if(dt.controlId!==st)break;if(dt.controlComponent===l.ControlComponent.PRETEXTFIX||dt.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||dt.controlComponent===l.ControlComponent.TEXTFIXLABEL||dt.controlComponent===l.ControlComponent.PREFIX||dt.controlComponent===l.ControlComponent.PRE_TEXT){it=et+1;break}}for(let et=C;et<G.length;et++){const dt=G[et];if(dt.controlId!==st)break;if(dt.controlComponent===l.ControlComponent.POSTTEXTFIX||dt.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||dt.controlComponent===l.ControlComponent.POSTFIX||dt.controlComponent===l.ControlComponent.POST_TEXT){nt=et-1;break}}it!==-1&&M<it&&(M=it),nt!==-1&&C>nt&&(C=nt)}}}let U;if(E){const[Q,G]=E.sort((H,j)=>H.index-j.index);U={originalId:E[0].originalId??E[1].originalId,startIndex:Q.index,endIndex:G.index},Q.isCurrent?(M=Q.index,C=Q.length-1):(M=0,C=U.endIndex-G.startIndex)}b.setRange(M,C,void 0,void 0,void 0,void 0,void 0,U)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function ua(o){const t=o.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),r=i[n.startIndex];if(!r.hide&&!r.control?.hide&&!r.area?.hide)return;let s=n.startIndex;for(;s>0;){const a=i[s];let c=null;a.controlId?(c=t.getControl().removeControl(s),c!==null&&(s=c)):(t.spliceElementList(i,s,1),c=s-1,s--);const d=i[c];if(!d||!d.hide&&!d.control?.hide&&!d.area?.hide){if(c){n.startIndex=c,n.endIndex=c,e.replaceRange(n);const R=t.getPosition(),u=R.getPositionList();R.setCursorPosition(u[c])}break}}}function ha(o,t,e){if(e.originControlId){const n=e.originControlId;for(let i=t;i<o.length;i++){const r=o[i];if(r.controlId===n)return r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX||r.controlComponent===l.ControlComponent.POST_TEXT?{isInParent:!1}:{isInParent:!0,parentControlId:n};if(r.controlId&&r.controlId!==n&&r.originControlId!==n)break}}if(!e.originControlId&&e.controlId){const n=o[t];if(n?.controlId&&n.controlId!==e.controlId&&(n.controlComponent===l.ControlComponent.PREFIX||n.controlComponent===l.ControlComponent.PRETEXTFIX))for(let i=t-1;i>=0;i--){const r=o[i];if(r.controlId===e.controlId&&(r.controlComponent===l.ControlComponent.PREFIX||r.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let s=i-1;s>=0;s--){const a=o[s];if(a.controlId&&a.controlId!==e.controlId&&(a.controlComponent===l.ControlComponent.PRETEXTFIX||a.controlComponent===l.ControlComponent.PREFIX))return{isInParent:!0,parentControlId:a.controlId};if(a.controlId&&a.controlId!==e.controlId&&(a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POSTTEXTFIX))return{isInParent:!1}}break}}if(n?.controlId&&n.controlId!==e.controlId&&!n.originControlId&&(n.controlComponent===l.ControlComponent.POSTFIX||n.controlComponent===l.ControlComponent.POSTTEXTFIX))return e.originControlId===n.controlId?{isInParent:!0,parentControlId:n.controlId}:{isInParent:!1}}return{isInParent:!1}}function ga(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&ua(t);const i=e.getControl(),{startIndex:r,endIndex:s,isCrossRowCol:a}=n.getRange();let c;const d=e.getElementList();if(n.getIsCollapsed()&&r>0){const u=d[r-1],h=d[r],f=e.getPosition().getPositionList(),T=f[r],p=f[r-1],m=T&&p&&T.rowIndex===p.rowIndex,I=u?.controlComponent===l.ControlComponent.PREFIX||u?.controlComponent===l.ControlComponent.PRETEXTFIX||u?.controlComponent===l.ControlComponent.PRE_TEXT||u?.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT,L=u?.controlComponent===l.ControlComponent.POSTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||u?.controlComponent===l.ControlComponent.POST_TEXT,P=!!u?.controlId,O=h?.controlComponent===l.ControlComponent.PLACEHOLDER,S=h?.controlComponent===l.ControlComponent.POSTFIX||h?.controlComponent===l.ControlComponent.POSTTEXTFIX||h?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||h?.controlComponent===l.ControlComponent.POST_TEXT,F=!!h&&!h.controlId&&!h.control;if(O&&I&&P&&m)return;const{isInParent:N,parentControlId:V}=ha(d,r,u);if(L&&P&&m&&N){if(u.originControlId&&V)for(let Y=r;Y<d.length;Y++){const X=d[Y];if(X.controlId===V&&!X.originControlId){if(X.controlComponent===l.ControlComponent.VALUE){n.setRange(Y,Y),e.render({curIndex:Y,isSubmitHistory:!1});return}if(X.controlComponent===l.ControlComponent.POSTFIX||X.controlComponent===l.ControlComponent.POSTTEXTFIX||X.controlComponent===l.ControlComponent.POST_TEXT)return}X.controlId!==V&&X.originControlId}return}if(L&&P&&m&&!N&&!(F&&!O&&!S)){const Y=r-1;c=i.removeControl(Y),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(Y,Y),e.render({curIndex:Y,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}if(S&&h?.controlId&&m){const Y=r;c=i.removeControl(Y),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(Y,Y),e.render({curIndex:Y,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(a){const u=e.getTableParticle().getRangeRowCol();if(!u)return;let h=!1;for(let g=0;g<u.length;g++){const f=u[g];for(let T=0;T<f.length;T++){const p=f[T];p.value.length>1&&(e.spliceElementList(p.value,1,p.value.length-1),h=!0)}}c=h?0:null}else if(i.getActiveControl()&&i.getIsRangeCanCaptureEvent())c=i.keydown(o),c&&i.emitControlContentChange();else{const u=e.getPosition().getCursorPosition();if(!u)return;const{index:h}=u,g=n.getIsCollapsed(),f=e.getElementList();if(g&&h===0){const I=f[h];if(I.value===_){I.listId&&e.getListParticle().unsetList(),o.preventDefault();return}}const T=f[r];if(g&&T.rowFlex&&T.value===_){const I=n.getRangeRowElementList();if(I){const L=f[r-1];I.forEach(P=>{P.rowFlex=L?.rowFlex})}}const p=T.value===_?f[r-1]:T,m=f[s+1];if(p?.titleId&&m?.titleId&&p.level===m.level&&p.titleId!==m.titleId){const I=p.titleId,L=m.titleId;let P=s+1;for(;P<f.length&&f[P]?.titleId===L;)f[P].titleId=I,P++}g?e.spliceElementList(f,h,1):e.spliceElementList(f,r+1,s-r),c=g?h-1:r}e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(r,r),e.render({curIndex:r,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}))}function fa(o){const t=o.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),r=i[n.startIndex+1];if(!r.hide&&!r.control?.hide&&!r.area?.hide)return;const s=n.startIndex+1;for(;s<i.length;){const a=i[s];let c=null;a.controlId?c=t.getControl().removeControl(s):(t.spliceElementList(i,s,1),c=s);const d=i[c];if(!d||!d.hide&&!d.control?.hide&&!d.area?.hide)break}}function Ta(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r,isCrossRowCol:s,splitTdRange:a}=n.getRange(),c=e.getElementList(),d=e.getControl();n.getIsCollapsed()&&fa(t);let R;if(s){const u=e.getTableParticle().getRangeRowCol();if(!u)return;let h=!1;for(let g=0;g<u.length;g++){const f=u[g];for(let T=0;T<f.length;T++){const p=f[T];p.value.length>1&&(e.spliceElementList(p.value,1,p.value.length-1),h=!0)}}R=h?0:null}else if(d.getActiveControl()&&d.getIsRangeWithinControl())R=d.keydown(o),R&&d.emitControlContentChange();else if(c[r+1]?.controlId)R=d.removeControl(r+1);else{e.removeSplitTdOtherRangeElements();const u=e.getPosition(),h=u.getCursorPosition();if(!h)return;const{index:g}=h,f=u.getPositionContext();if(f.isDirectHit&&f.isImage)e.spliceElementList(c,g,1),R=g-1;else{const T=n.getIsCollapsed();if(!T)e.spliceElementList(c,i+1,r-i);else if(c[g+1])e.spliceElementList(c,g+1,1);else{let p=!0;if(f.isTable){const m=e.getTd();if(m?.linkTdNextId){const I=e.getTdById(m.linkTdNextId);I&&(p=!1,e.spliceElementList(I.value,1,1))}}if(p)return}R=T?g:i,R===0&&a&&(R=e.fixPosition(!0)??R)}}e.getGlobalEvent().setCanvasEventAbility(),R===null?(n.setRange(i,i),e.render({curIndex:i,isSubmitHistory:!1})):(n.setRange(R,R),e.render({curIndex:R}))}function ma(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r}=n.getRange(),s=n.getIsCollapsed(),a=e.getElementList(),c=a[i],d=a[r];if(s&&d.listId&&d.value===_&&a[r+1]?.listId!==d.listId){e.getListParticle().unsetList();return}let R={value:_};if(o.shiftKey&&c.listId&&(R.listWrap=!0),Ut(a,[R],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),o.shiftKey&&d.areaId&&d.areaId!==a[r+1]?.areaId&&(R=ie(R,Ke)),!(a[i+1]?.titleId&&(!c.titleId||c.titleId!==a[i+1]?.titleId))&&!(d.titleId&&d.titleId!==a[r+1]?.titleId)){const p=n.getRangeAnchorStyle(a,r);if(p){const m=[...Bt],I=p.controlComponent===l.ControlComponent.POSTFIX||p.controlComponent===l.ControlComponent.POSTTEXTFIX||p.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||p.controlComponent===l.ControlComponent.POST_TEXT,L=p.control?.type===l.ControlType.BUTTON&&!p.control?.buttonText;!I&&!L&&m.push(...Re),m.forEach(P=>{const O=p[P];O!==void 0&&(R[P]=O)})}}const u=e.getControl(),h=u.getActiveControl();let g;const f=h?.getElement();if(f?.control?.type===l.ControlType.BUTTON&&!f.control?.buttonText&&f?.controlId){const p=f.controlId;let m=r;for(;m+1<a.length&&a[m+1]?.controlId===p;)m++;e.spliceElementList(a,m+1,0,[R]),g=m+1}else if(h&&u.getIsRangeWithinControl())g=u.setValue([R]),u.emitControlContentChange();else{const m=e.getPosition().getCursorPosition();if(!m)return;const{index:I}=m;if(s){if(e.spliceElementList(a,I+1,0,[R]),d.titleId&&a[I+2]?.titleId===d.titleId){const L=lt();let P=I+2;for(;P<a.length&&a[P]?.titleId===d.titleId;)a[P].titleId=L,P++}}else e.spliceElementList(a,i+1,r-i,[R]);g=I+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),o.preventDefault()}function as(o){return o&&(o.type===l.ElementType.MACRO||o.type===l.ElementType.CUSTOM_MACRO||o.type===l.ElementType.REUSABLE_ITEM||o.type===l.ElementType.SUB_TEMPLATE||o.type===l.ElementType.MENSTRUAL_HISTORY||o.type===l.ElementType.FETAL_HEART_POSITION||o.type===l.ElementType.TOOTH_POSITION||o.type===l.ElementType.LIST||o.type===l.ElementType.SPECIAL_SYMBOLS)}function pa(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const s=i.getPositionContext(),{index:a}=r;if(a<=0&&!s.isTable)return;const c=e.getRange(),{startIndex:d,endIndex:R}=c.getRange(),u=c.getIsCollapsed(),h=e.getElementList(),g=e.getControl(),f=e.getMode()===l.EditorMode.FORM,T=f?g.getActiveTextControlLimit():null,p=h[a],m=p?.controlComponent===l.ControlComponent.PREFIX||p?.controlComponent===l.ControlComponent.PRETEXTFIX||p?.controlComponent===l.ControlComponent.PRE_TEXT;let I=!1;if(m&&p?.originControlId){const V=p.originControlId;for(let Y=a-1;Y>=0;Y--){const X=h[Y];if(X.controlId===V&&!X.originControlId){I=!0;break}if(X.controlId&&X.controlId!==V&&X.originControlId!==V)break}}if(f&&g.getActiveControl()&&m&&!T&&!I){g.initNextControl({direction:Zt.UP});return}let L=1;if(fe(o)){const V=e.getLetterReg(),Y=o.shiftKey&&!u&&d===r?.index?R:d;if(V.test(h[Y]?.value)){let X=Y-1;for(;X>0;){const b=h[X];if(!V.test(b.value))break;L++,X--}}}if(f){const V=h[d],Y=V?.controlId;if(Y&&V?.controlComponent===l.ControlComponent.VALUE){let X=!1;for(let b=d;b>=0;b--){const E=h[b];if(E.controlId!==Y)break;if(E.control?.type===l.ControlType.TEXTFIELD){X=!0;break}}if(X){if(V.controlComponent===l.ControlComponent.VALUE&&as(V))return;const b=d-L;if(b>=0){const E=h[b];if(E&&E.controlId===Y&&E.controlComponent===l.ControlComponent.VALUE&&as(E))return}}}}const P=T?Math.max(d-L,T.startIndex):d-L;let O=P,S=P;if(o.shiftKey&&r&&(d!==R?d===r.index?(O=d,S=R-L):(O=P,S=R):S=R),!o.shiftKey){const V=h[d];if(V.type===l.ElementType.TABLE){const Y=V.trList,X=Y.length-1,b=Y[X],E=b.tdList.length-1,C=b.tdList[E];i.setPositionContext({isTable:!0,index:d,trIndex:X,tdIndex:E,tdId:C.id,trId:b.id,tableId:V.id}),O=C.value.length-1,S=O}else if(V.tableId&&d===0){const X=e.getOriginalElementList()[s.index],b=e.getTd();if(b?.linkTdPrevId){const E=e.getTdById(b.linkTdPrevId);E&&(i.setPositionContext({...s,isTable:!0,index:E.tableIndex,trIndex:E.trIndex,tdId:E.id,trId:E.trId,tableId:E.tableId}),O=E.value.length-1,S=O)}else{const E=X.trList;t:for(let C=0;C<E.length;C++){const M=E[C];if(M.id!==V.trId)continue;const y=M.tdList;for(let W=0;W<y.length;W++)if(y[W].id===V.tdId){if(C===0&&W===0)i.setPositionContext({isTable:!1}),O=s.index-1,S=O,e.getTableTool().dispose();else{let U=C,Q=W-1;Q<0&&(U=C-1,Q=E[U].tdList.length-1);const G=E[U],H=G.tdList[Q];i.setPositionContext({isTable:!0,index:s.index,trIndex:U,tdIndex:Q,tdId:H.id,trId:G.id,tableId:V.tableId}),O=H.value.length-1,S=O}break t}}}}}if(!~O||!~S)return;const F=e.getElementList();O=Ln(F,O),S=Ln(F,S),c.setRange(O,S);const N=O===S;e.updateTableTool(),e.render({curIndex:N?O:void 0,isSetCursor:N,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function cs(o){return o&&(o.type===l.ElementType.MACRO||o.type===l.ElementType.CUSTOM_MACRO||o.type===l.ElementType.REUSABLE_ITEM||o.type===l.ElementType.SUB_TEMPLATE||o.type===l.ElementType.MENSTRUAL_HISTORY||o.type===l.ElementType.FETAL_HEART_POSITION||o.type===l.ElementType.TOOTH_POSITION||o.type===l.ElementType.LIST||o.type===l.ElementType.SPECIAL_SYMBOLS)}function La(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const{index:s}=r,a=i.getPositionList(),c=i.getPositionContext();if(s>a.length-1&&!c.isTable)return;const d=e.getRange(),{startIndex:R,endIndex:u}=d.getRange(),h=d.getIsCollapsed();let g=e.getElementList();const f=e.getControl(),T=e.getMode()===l.EditorMode.FORM,p=T?f.getActiveTextControlLimit():null,m=g[s],I=m?.controlComponent===l.ControlComponent.POSTFIX||m?.controlComponent===l.ControlComponent.POSTTEXTFIX||m?.controlComponent===l.ControlComponent.POST_TEXT;let L=!1;if(I&&m?.originControlId){const X=m.originControlId;for(let b=s+1;b<g.length;b++){const E=g[b];if(E.controlId===X&&!E.originControlId){L=!0;break}if(E.controlId&&E.controlId!==X&&E.originControlId!==X)break}}if(T&&f.getActiveControl()&&I&&!p&&!L){f.initNextControl({direction:Zt.DOWN});return}let P=1;if(fe(o)){const X=e.getLetterReg(),b=o.shiftKey&&!h&&R===r?.index?u:R;if(X.test(g[b+1]?.value)){let E=b+2;for(;E<g.length;){const C=g[E];if(!X.test(C.value))break;P++,E++}}}if(T){const X=g[u],b=X?.controlId;if(b&&X?.controlComponent===l.ControlComponent.VALUE){let E=!1;for(let C=u;C>=0;C--){const M=g[C];if(M.controlId!==b)break;if(M.control?.type===l.ControlType.TEXTFIELD){E=!0;break}}if(E){if(X.controlComponent===l.ControlComponent.VALUE&&cs(X))return;const C=u+P;if(C<g.length){const M=g[C];if(M&&M.controlId===b&&M.controlComponent===l.ControlComponent.VALUE&&cs(M))return}}}}const O=p?Math.min(u+P,p.endIndex):u+P;let S=O,F=O;if(o.shiftKey&&r&&(R!==u?R===r.index?(S=R,F=O):(S=R+P,F=u):S=R),!o.shiftKey){const X=g[u],b=g[u+1];if(b?.type===l.ElementType.TABLE){const C=b.trList[0],M=C.tdList[0];i.setPositionContext({isTable:!0,index:u+1,trIndex:0,tdIndex:0,tdId:M.id,trId:C.id,tableId:b.id}),S=0,F=0}else if(X.tableId&&!b){const E=e.getTd(),C=E?.linkTdNextId?e.getTdById(E.linkTdNextId):void 0;if(C?.value.length)i.setPositionContext({...c,isTable:!0,index:C.tableIndex,trIndex:C.trIndex,tdId:C.id,trId:C.trId,tableId:C.tableId}),S=0,F=S;else{const y=e.getOriginalElementList()[c.index].trList;t:for(let W=0;W<y.length;W++){const D=y[W];if(D.id!==X.trId)continue;const U=D.tdList;for(let Q=0;Q<U.length;Q++)if(U[Q].id===X.tdId){if(W===y.length-1&&Q===U.length-1)i.setPositionContext({isTable:!1}),S=c.index,F=S,g=e.getElementList(),e.getTableTool().dispose();else{let H=W,j=Q+1;j>U.length-1&&(H=W+1,j=0);const st=y[H],it=st.tdList[j];i.setPositionContext({isTable:!0,index:c.index,trIndex:H,tdIndex:j,tdId:it.id,trId:st.id,tableId:X.tableId}),S=0,F=S}break t}}}}}const N=g.length-1;if(S>N||F>N)return;const V=e.getElementList();S=Ln(V,S,l.LocationPosition.AFTER),F=Ln(V,F,l.LocationPosition.AFTER),d.setRange(S,F);const Y=S===F;e.updateTableTool(),e.render({curIndex:Y?S:void 0,isSetCursor:Y,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Ia(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getControl();if(i.getActiveControl()&&i.getIsRangeWithinControl())i.initNextControl({direction:o.shiftKey?Zt.UP:Zt.DOWN});else{const s=e.getRange(),a=e.getElementList(),{startIndex:c,endIndex:d}=s.getRange(),R=s.getRangeAnchorStyle(a,d),h={...R?Dt(R,Re):null,type:l.ElementType.TAB,value:""};Ut(a,[h],c,{editorOptions:e.getOptions()}),e.insertElementList([h])}}function Ko(o){const{positionList:t,index:e,isUp:n,rowNo:i,cursorX:r}=o;let s=-1;const a=[];if(n){let c=e-1;for(;c>=0;){const d=t[c];if(c--,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.unshift(d)}}}else{let c=e+1;for(;c<t.length;){const d=t[c];if(c++,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.push(d)}}}for(let c=0;c<a.length;c++){const d=a[c],{coordinate:{leftTop:[R],rightTop:[u]}}=d;if(c===a.length-1&&(s=d.index),!(r<R||r>u)){s=d.index;break}}return s}function Pa(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const s=e.getRange(),{startIndex:a,endIndex:c}=s.getRange();let d=i.getPositionList();const R=o.key===l.KeyMap.Up;let u=-1,h=-1;const g=i.getPositionContext();if(!o.shiftKey&&g.isTable&&(R&&r.rowIndex===0||!R&&r.rowIndex===e.getRowCount()-1)){const{index:T,trIndex:p,tdIndex:m,tableId:I}=g;if(R){const L=e.getOriginalElementList();if(p===0)if(L[T].originalId){const O=T-1,S=L[O];for(let F=S.trList.length-1;F>=0;F--){const N=S.trList[F].tdList.find(V=>V.tdIndex===m);if(N?.value.length){i.setPositionContext({isTable:!0,tableId:S.id,index:O,trIndex:F,tdIndex:m}),u=N.value.length-1,h=N.value.length-1;break}}}else i.setPositionContext({isTable:!1}),u=T-1,h=u,e.getTableTool().dispose();else{let P=-1,O=-1;const S=L[T].trList,F=S[p].tdList[m].colIndex;t:for(let Y=p-1;Y>=0;Y--){const b=S[Y].tdList;for(let E=0;E<b.length;E++){const C=b[E];if(C.colIndex===F||C.colIndex+C.colspan-1>=F&&C.colIndex<=F){P=Y,O=E;break t}}}if(!~P||!~O)return;const N=S[P],V=N.tdList[O];i.setPositionContext({isTable:!0,index:T,trIndex:P,tdIndex:O,tdId:V.id,trId:N.id,tableId:I}),u=V.value.length-1,h=u}}else{const L=e.getOriginalElementList(),P=L[T],O=P.trList;if(p===O.length-1){const S=T+1,F=L[S];if(F&&[P.id,P.originalId].includes(F.originalId)){for(let V=m;V>=0;V--)if(F.trList[0].tdList[V].value.length){i.setPositionContext({isTable:!0,index:S,tableId:F.id,trIndex:0,tdIndex:V}),u=0,h=0;break}}else i.setPositionContext({isTable:!1}),u=T,h=u,e.getTableTool().dispose()}else{let S=-1,F=-1;const N=O[p].tdList[m].colIndex;t:for(let X=p+1;X<O.length;X++){const E=O[X].tdList;for(let C=0;C<E.length;C++){const M=E[C];if(M.colIndex===N||M.colIndex+M.colspan-1>=N&&M.colIndex<=N){S=X,F=C;break t}}}if(!~S||!~F)return;const V=O[S],Y=V.tdList[F];i.setPositionContext({isTable:!0,index:T,trIndex:S,tdIndex:F,tdId:Y.id,trId:V.id,tableId:I}),u=Y.value.length-1,h=u}}}else{let T=r;o.shiftKey&&(a===r.index?T=d[c]:T=d[a]);const{index:p,rowNo:m,rowIndex:I,coordinate:{rightTop:[L]}}=T;if(R&&I===0||!R&&I===e.getRowCount()-1)return;const P=Ko({positionList:d,index:p,rowNo:m,isUp:R,cursorX:L});if(P<0)return;u=P,h=P,o.shiftKey&&(a!==c?a===r.index?u=a:h=c:R?h=c:u=a);const S=e.getElementList()[P];if(S.type===l.ElementType.TABLE){const{scale:F}=e.getOptions(),N=e.getMargins(),V=S.trList;let Y=-1,X=-1,b=-1;if(R)t:for(let E=V.length-1;E>=0;E--){const M=V[E].tdList;for(let y=0;y<M.length;y++){const W=M[y],D=W.x*F+N[3],U=W.width*F;if(L>=D&&L<=D+U){const Q=W.positionList,G=Q[Q.length-1],H=Ko({positionList:Q,index:G.index+1,rowNo:G.rowNo-1,isUp:R,cursorX:L})||G.index;Y=E,X=y,b=H;break t}}}else t:for(let E=0;E<V.length;E++){const M=V[E].tdList;for(let y=0;y<M.length;y++){const W=M[y],D=W.x*F+N[3],U=W.width*F;if(L>=D&&L<=D+U){const Q=W.positionList,G=Ko({positionList:Q,index:-1,rowNo:-1,isUp:R,cursorX:L})||0;Y=E,X=y,b=G;break t}}}if(~Y&&~X&&~b){const E=V[Y],C=E.tdList[X];i.setPositionContext({isTable:!0,index:P,trIndex:Y,tdIndex:X,tdId:C.id,trId:E.id,tableId:S.id}),u=b,h=u,d=i.getPositionList()}}}if(!~u||!~h)return;u>h&&([u,h]=[h,u]),s.setRange(u,h);const f=u===h;e.render({curIndex:f?u:void 0,isSetCursor:f,isSubmitHistory:!1,isCompute:!1}),f||(e.getCursor().moveCursorToVisible({cursorPosition:d[R?u:h],direction:R?Zt.UP:Zt.DOWN}),e.updateTableTool())}function Ma(o,t){if(t.isComposing)return;const e=t.getDraw();if(o.key===l.KeyMap.Backspace)ga(o,t);else if(o.key===l.KeyMap.Delete)Ta(o,t);else if(o.key===l.KeyMap.Enter)ma(o,t);else if(o.key===l.KeyMap.Left)pa(o,t);else if(o.key===l.KeyMap.Right)La(o,t);else if(o.key===l.KeyMap.Up||o.key===l.KeyMap.Down)Pa(o,t);else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==l.EditorMode.FORM)return;e.getHistoryManager().undo(),o.preventDefault()}else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==l.EditorMode.FORM)return;e.getHistoryManager().redo(),o.preventDefault()}else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.C)t.copy(),o.preventDefault();else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.X)t.cut(),o.preventDefault();else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.A)t.selectAll(),o.preventDefault();else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const i=e.getEventBus();i.isSubscribe("saved")&&i.emit("saved",e.getValue()),o.preventDefault()}else if(o.key===l.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(l.EditorZone.MAIN),o.preventDefault()}else o.key===l.KeyMap.TAB&&Ia(o,t)}function Oa(o){return/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(o)}function Ca(o){return/[a-zA-Z]/.test(o)}function Sa(o,t){return Oa(o)?t:Ca(o)?"Times New Roman":t}function Ea(o){return o?.type===l.ElementType.CONTROL&&(o.controlComponent===l.ControlComponent.PREFIX||o.controlComponent===l.ControlComponent.PRE_TEXT||o.controlComponent===l.ControlComponent.PRETEXTFIX||o.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)}function Xa(o){return o?.type===l.ElementType.CONTROL&&(o.controlComponent===l.ControlComponent.POSTFIX||o.controlComponent===l.ControlComponent.POST_TEXT||o.controlComponent===l.ControlComponent.POSTTEXTFIX||o.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)}function Ho(o,t,e="input"){const n=bt(),i=t.getDraw(),r=i.getControl(),s=i.getOptions(),a=i.getElementList(),R=i.getPosition().getCursorPosition()?.index;if(i.isReadonly()||i.isDisabled())return;const h=i.getPosition().getCursorPosition();if(!o||!h)return;const g=t.isComposing;if(g&&t.compositionInfo?.value===o)return;const f=i.getRange();if(!f.getIsCanInput())return;const{endIndex:T}=f.getRange(),p=i.getElementList(),m=p[T],I=p[T+1];if(m?.type===l.ElementType.SUB_TEMPLATE&&I?.type===l.ElementType.SUB_TEMPLATE)return;if(i.getMode()===l.EditorMode.FORM){const v=r.getActiveTextControlLimit();if(!r.getActiveControl()||!r.getIsRangeWithinControl()&&!r.getIsRangeInPostfix())return;if(v){const x=f.getRange();if(x.startIndex<v.startIndex||x.endIndex>v.endIndex){const A=Math.min(Math.max(x.endIndex,v.startIndex),v.endIndex);f.setRange(A,A),i.render({curIndex:A,isSubmitHistory:!1});return}}const{endIndex:w}=f.getRange(),Z=i.getElementList(),J=Z[w];if(!J?.originControlId){if(J?.controlId&&J?.controlComponent===l.ControlComponent.VALUE)for(let x=w;x>=0;x--){const A=Z[x];if(A.controlId!==J.controlId||A.originControlId)break;if(A.control?.type===l.ControlType.TEXTFIELD)return}}}const P=f.getDefaultStyle()||t.compositionInfo?.defaultStyle||null,O=t.compositionInfo?.perfStartTime,S=Fa(t,i.getElementList());g||i.getCursor().clearAgentDomValue();const{TEXT:F,HYPERLINK:N,SUBSCRIPT:V,SUPERSCRIPT:Y,DATE:X,TAB:b}=l.ElementType,E=o.replaceAll(`
|
|
101
|
-
`,_),{startIndex:C,endIndex:M}=f.getRange(),y=f.getRangeAnchorStyle(S,C);if(!y)return;const W=C>0?S[C-1]:null,D=!!(y.controlId||y.control),Q={...!D&&W?W:y,...P},G=i.isDesignMode(),H=S[M+1],j=Ea(H)&&!H?.originControlId,st=Xa(y)&&!y.originControlId||y.type===l.ElementType.CONTROL&&y.controlComponent===l.ControlComponent.VALUE&&H?.type!==l.ElementType.CONTROL&&!y.originControlId,it=j||st,nt=it?{...y,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:s.defaultColor,highlight:void 0}:y,et=it||D?nt:Q,dt=ct(E).map(v=>{const K={value:v};if(G||!et.title?.disabled&&!et.control?.disabled){const w=S[M+1];(!et.type||et.type===F||et.type===N&&w?.type===N||et.type===X&&w?.type===X||et.type===V&&w?.type===V||et.type===Y&&w?.type===Y)&&ol.forEach(Z=>{if(Z==="groupIds"&&!w?.groupIds)return;const J=et[Z];J!==void 0&&(K[Z]=J)}),(P||et.type===b)&&Re.forEach(Z=>{const J=P?.[Z]||et[Z];J!==void 0&&(K[Z]=J)}),g&&(K.underline=!0)}if(!it){const w=y.originControlId&&(y.controlComponent===l.ControlComponent.POSTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||y.controlComponent===l.ControlComponent.POST_TEXT),Z=!y.originControlId&&y.controlId&&(y.controlComponent===l.ControlComponent.POSTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||y.controlComponent===l.ControlComponent.POST_TEXT)&&H?.controlId&&H.controlId!==y.controlId,J=y.controlId&&y.originControlId&&(y.controlComponent===l.ControlComponent.VALUE||y.controlComponent===l.ControlComponent.PLACEHOLDER);if(w&&!K.controlId){const x=y.originControlId;let A=null;for(let $=C;$>=0;$--){const B=S[$];if(B.controlId===x&&!B.originControlId&&B.control){A=B.control;break}}K.controlId=x,K.controlComponent=l.ControlComponent.VALUE,A&&(K.control=A)}else if(Z&&!K.controlId){if(H?.controlId&&H.controlId!==y.controlId)if(H.controlComponent===l.ControlComponent.PREFIX||H.controlComponent===l.ControlComponent.PRETEXTFIX)for(let x=C;x>=0;x--){const A=S[x];if(A.controlId===y.controlId&&(A.controlComponent===l.ControlComponent.PREFIX||A.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let $=x-1;$>=0;$--){const B=S[$];if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.PRETEXTFIX||B.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||B.controlComponent===l.ControlComponent.PREFIX||B.controlComponent===l.ControlComponent.PRE_TEXT)){K.controlId=B.controlId,K.controlComponent=l.ControlComponent.VALUE,B.control&&(K.control=B.control);break}if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.POSTFIX||B.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}else(H.controlComponent===l.ControlComponent.POSTFIX||H.controlComponent===l.ControlComponent.POSTTEXTFIX)&&(K.controlId=H.controlId,K.controlComponent=l.ControlComponent.VALUE,H.control&&(K.control=H.control));if(!K.controlId)for(let x=C;x>=0;x--){const A=S[x];if(A.controlId===y.controlId&&(A.controlComponent===l.ControlComponent.PREFIX||A.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let $=x-1;$>=0;$--){const B=S[$];if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.PRETEXTFIX||B.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||B.controlComponent===l.ControlComponent.PREFIX||B.controlComponent===l.ControlComponent.PRE_TEXT)){K.controlId=B.controlId,K.controlComponent=l.ControlComponent.VALUE,B.control&&(K.control=B.control);break}if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.POSTFIX||B.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}}else if(J&&!K.controlId){const x=y.controlId;let A=y.control;if(!A)for(let $=C;$>=0;$--){const B=S[$];if(B.controlId===x&&B.control&&(A=B.control,B.controlComponent===l.ControlComponent.PREFIX||B.controlComponent===l.ControlComponent.PRETEXTFIX))break}K.controlId=x,K.originControlId=y.originControlId,K.controlComponent=l.ControlComponent.VALUE,A&&(K.control=A)}else if(y.controlId&&!y.originControlId){let x=y.control;if(!x)for(let A=C;A>=0;A--){const $=S[A];if($.controlId===y.controlId&&!$.originControlId&&$.control){x=$.control;break}}K.controlId||(K.controlId=y.controlId),x&&!K.control&&(K.control=x),K.controlComponent||(K.controlComponent=l.ControlComponent.VALUE)}else if(!K.controlId&&!K.control&&H?.originControlId&&(H.controlComponent===l.ControlComponent.PREFIX||H.controlComponent===l.ControlComponent.PRETEXTFIX)){const x=H.originControlId;let A=null;for(let $=M;$>=0;$--){const B=S[$];if(B.controlId===x&&!B.originControlId&&B.control){A=B.control;break}}K.controlId=x,K.controlComponent=l.ControlComponent.VALUE,A&&(K.control=A)}}if(v&&v!==_){const w=Sa(v,s.defaultFont);K.font=w}return K});let tt;const ht=a[R],ut=a[R+1];if(g)tt=C;else{const v=w=>{if(dt?.length)for(let Z=0;Z<dt.length;Z++)S.splice(w+Z,0,dt[Z]);return C+dt.length},K=C+1;if(C!==M&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(S,K,M-C)),it)tt=v(K);else if(ht?.originControlId&&(ht?.controlComponent==="postfix"||ht?.controlComponent==="postTextFix"))tt=v(K);else if((ht?.control?.type===l.ControlType.NUMBER||ut?.control?.type===l.ControlType.NUMBER)&&r.getActiveControl()?.getElement()?.control?.type===l.ControlType.NUMBER&&r.getIsRangeWithinControl()){const w=r.getActiveControl();w&&typeof w.awake=="function"&&w.awake(),tt=C}else if((ht?.control?.type===l.ControlType.SELECT||ut?.control?.type===l.ControlType.SELECT)&&r.getActiveControl()?.getElement()?.control?.type===l.ControlType.SELECT&&r.getIsRangeWithinControl()){const w=r.getActiveControl();w&&typeof w.awake=="function"&&w.awake(),tt=C}else ht?.control?.type==="button"||ut?.control?.type==="button"?(ht?.control||ut?.control)?.buttonText?tt=C:r.getActiveControl()&&r.getIsRangeWithinControl()?(r.removePlaceholder(C,{elementList:S}),tt=r.setValue(dt),r.emitControlContentChange()):tt=C:r.getActiveControl()&&r.getIsRangeWithinControl()?(r.removePlaceholder(C,{elementList:S}),tt=r.setValue(dt),r.emitControlContentChange()):(ht?.type==="control"||ut?.type==="control")&&!it?tt=v(K):(Ut(S,dt,C,{editorOptions:s}),i.spliceElementList(S,K,0,dt),tt=C+dt.length)}if(~tt&&!g){const v=bt()-n,K=bt();f.setRange(tt,tt),i.render({curIndex:tt,isSubmitHistory:!g,traceLabel:`input:${e}`}),Co(s,`input:${e}`,bt()-n,[{label:"mutate",duration:v},{label:"renderCall",duration:bt()-K}],{isComposing:g,textLength:dt.length,compositionChainDuration:e==="compositionend"&&O!==void 0?Number((bt()-O).toFixed(2)):void 0})}g&&(t.compositionInfo={value:E,startIndex:tt,endIndex:M,defaultStyle:P,perfStartTime:n})}function Na(o){o.compositionInfo&&(o.compositionInfo=null)}function Fa(o,t){if(!o.compositionInfo||o.isComposing)return t;const{startIndex:e,endIndex:n}=o.compositionInfo;return e!==n&&(o.getDraw().removeSplitTdOtherRangeElements(),o.getDraw().spliceElementList(t,e+1,n-e),o.getDraw().getRange().setRange(e,e)),o.compositionInfo=null,t}async function ya(o){const t=o.getDraw(),e=t.getRange(),{startIndex:n,endIndex:i}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const r=t.getElementList();let s=n,a=i;if(n===i){const h=t.getPosition().getPositionList(),g=h[n],f=g.rowNo,T=g.pageNo,p=[];for(let I=0;I<h.length;I++){const L=h[I];if(L.pageNo>T)break;L.pageNo===T&&L.rowNo===f&&p.push(I)}const m=p[0]-1;s=m<0?0:m,a=p[p.length-1]}const c=t.getOptions();await ns(r.slice(s+1,a+1),c);const d=t.getControl();let R;d.getActiveControl()&&d.getIsRangeWithinControl()?(R=d.cut(),d.emitControlContentChange()):(t.spliceElementList(r,s+1,a-s),R=s),e.setRange(R,R),t.render({curIndex:R})}async function Wa(o,t){const e=o.getDraw(),{copy:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=e.getRange();let r=null;if(i.getRange().isCrossRowCol){const a=i.getRangeTableElement();if(!a)return;const c=e.getTableParticle().getRangeRowCol();if(!c)return;const d={type:l.ElementType.TABLE,value:"",colgroup:[],trList:[]},R=c[0],u=R[0].colIndex,h=R[R.length-1],g=h.colIndex+h.colspan-1;for(let f=u;f<=g;f++)d.colgroup.push(a.colgroup[f]);for(let f=0;f<c.length;f++){const T=c[f],p=a.trList[T[0].rowIndex],m={tdList:[],height:p.height,minHeight:p.minHeight};for(let I=0;I<T.length;I++)m.tdList.push(T[I]);d.trList.push(m)}r=Pt([d])}else r=i.getIsCollapsed()?i.getRangeRowElementList():i.getSelectionElementList();t?.isPlainText&&r?.length&&(r=[{value:en(r)}]),r?.length&&await ns(r,e.getOptions())}function ba(o,t){const e=t.getDraw(),{drop:n}=e.getOverride();if(n&&n(o)?.preventDefault!==!1)return;o.preventDefault();const i=o.dataTransfer?.getData("text");if(i)t.input(i);else{const r=o.dataTransfer?.files;if(!r)return;for(let s=0;s<r.length;s++){const a=r[s];a.type.startsWith("image")&&Qo(t,a)}}}function ds(o){if(!Intl.Segmenter)return null;const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const i=t.getRange().getRangeParagraphInfo();if(!i)return null;const r=i?.elementList?.map(h=>!h.type||h.type!==l.ElementType.CONTROL&&$t.includes(h.type)?h.value:_).join("")||"";if(!r)return null;const s=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,a=i.startIndex,d=new Intl.Segmenter(void 0,{granularity:"word"}).segment(r);let R=-1,u=-1;for(const{segment:h,index:g,isWordLike:f}of d){const T=g+a;if(f&&s>=T&&s<T+h.length){R=T-1,u=R+h.length;break}}return~R&&~u?{startIndex:R,endIndex:u}:null}function Va(o){const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:i}=e,r=t.getLetterReg();let s=0,a=0;const c=mo.test(n);if(c||r.test(n)){const R=t.getElementList();let u=i-1;for(;u>0;){const g=R[u].value;if(c&&mo.test(g)||!c&&r.test(g))s++,u--;else break}let h=i+1;for(;h<R.length;){const g=R[h].value;if(c&&mo.test(g)||!c&&r.test(g))a++,h++;else break}}const d=i-s-1;return d<0?null:{startIndex:d,endIndex:i+a}}function Ya(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(i.isImage&&i.isDirectHit){const a=e.getElementList(),c=e.getEventBus(),d=a[i.index];if(c.isSubscribe("imageDblclick")&&c.emit("imageDblclick",{evt:t,element:d}),d.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&e.getMode()===l.EditorMode.EDIT&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const r=e.getRange(),s=ds(o)||Va(o);s&&(r.setRange(s.startIndex,s.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),r.setRangeStyle())}function Da(o){const t=o.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const i=t.getPosition().getCursorPosition();if(!i)return;const{index:r}=i,s=t.getElementList();let a=0,c=0,d=r-1;for(;d>0;){const f=s[d],T=s[d-1];if(f.value===_&&!f.listWrap||f.listId!==T?.listId||f.titleId!==T?.titleId)break;a++,d--}let R=r+1;for(;R<s.length;){const f=s[R],T=s[R+1];if(f.value===_&&!f.listWrap||f.listId!==T?.listId||f.titleId!==T?.titleId)break;c++,R++}const u=t.getRange();let h=r-a-1;if(s[h]?.value!==_&&(h-=1),h<0)return;let g=r+c+1;(s[g]?.value===_||g>s.length-1)&&(g-=1),u.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const Rs={dblclick:Ya,threeClick:Da};function Ua(o){o.isComposing=!0}function wa(o,t){const e=bt();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),nl?setTimeout(()=>{o.compositionInfo&&Ho(t.data,o,"compositionend")},1):o.compositionInfo&&Ho(t.data,o,"compositionend");else{const s=o.compositionInfo?.cancel;if(Na(o),!s){const a=n.getRange(),{endIndex:c}=a.getRange();n.render({curIndex:c,isSubmitHistory:!1,traceLabel:"compositionend:empty"})}}n.getCursor().clearAgentDomValue(),Co(i,"compositionend",bt()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function Za(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const _o={compositionstart:Ua,compositionend:wa,compositionCancel:Za};function Qa(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Wi(o.target,L=>L===i))return;const a=o.target.dataset.index;a&&e.setPageNo(Number(a));const c=e.getPosition(),d=c.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{isTable:R,tdValueIndex:u,index:h}=d,g=c.getPositionList(),f=R?u:h;~h&&(e.getRange().setRange(f,f),c.setCursorPosition(g[f]));const T=e.getCursor(),{cursor:{dragColor:p,dragWidth:m,dragFloatImageDisabled:I}}=e.getOptions();if(I){const L=t.cacheElementList?.[t.cacheRange.startIndex];if(L?.type===l.ElementType.IMAGE&&(L.imgDisplay===l.ImageDisplay.FLOAT_TOP||L.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM||L.imgDisplay===l.ImageDisplay.SURROUND))return}T.drawCursor({width:m,color:p,isBlink:!1,isFocus:!1})}const va={dragover:Qa};class Ka{isAllowSelection;isComposing;compositionInfo;isAllowDrag;isAllowDrop;cacheRange;cacheElementList;cachePositionList;cachePositionContext;mouseDownStartPosition;draw;pageContainer;pageList;range;position;constructor(t){this.draw=t,this.pageContainer=t.getPageContainer(),this.pageList=t.getPageList(),this.range=this.draw.getRange(),this.position=this.draw.getPosition(),this.isAllowSelection=!1,this.isComposing=!1,this.compositionInfo=null,this.isAllowDrag=!1,this.isAllowDrop=!1,this.cacheRange=null,this.cacheElementList=null,this.cachePositionList=null,this.cachePositionContext=null,this.mouseDownStartPosition=null}getDraw(){return this.draw}register(){this.pageContainer.addEventListener("click",this.click.bind(this)),this.pageContainer.addEventListener("mousedown",this.mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this.mouseup.bind(this)),this.pageContainer.addEventListener("mouseleave",this.mouseleave.bind(this)),this.pageContainer.addEventListener("mousemove",this.mousemove.bind(this)),this.pageContainer.addEventListener("dblclick",this.dblclick.bind(this)),this.pageContainer.addEventListener("dragover",this.dragover.bind(this)),this.pageContainer.addEventListener("drop",this.drop.bind(this)),_r(this.pageContainer,this.threeClick.bind(this))}setIsAllowSelection(t){this.isAllowSelection=t,t||this.applyPainterStyle()}setIsAllowDrag(t){this.isAllowDrag=t,this.isAllowDrop=t}clearPainterStyle(){this.pageList.forEach(t=>{t.style.cursor="text"}),this.draw.setPainterStyle(null)}applyPainterStyle(){const t=this.draw.getPainterStyle();if(!t||this.draw.isReadonly()||this.draw.isDisabled())return;let n=this.range.getSelection();if(!n){const s=ds(this);s&&(n=this.draw.getElementList().slice(s.startIndex+1,s.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(s=>{i.forEach(a=>{const c=a;Reflect.set(s,c,t[c])})}),this.draw.render({isSetCursor:!1});const r=this.draw.getPainterOptions();(!r||!r.isDblclick)&&this.clearPainterStyle()}selectAll(){if(this.position.getPositionContext().isTable)this.draw.getTableOperate().tableSelectAll();else{const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}}mousemove(t){this.draw.isInteractionSuspended()||Ra(t,this)}mousedown(t){this.draw.isInteractionSuspended()||aa(t,this)}click(){this.draw.isInteractionSuspended()||tl&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||ca(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||da(t,this)}keydown(t){this.draw.isInteractionSuspended()||Ma(t,this)}dblclick(t){this.draw.isInteractionSuspended()||Rs.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||Rs.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||Ho(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await ya(this)}async copy(t){this.draw.isInteractionSuspended()||await Wa(this,t)}compositionstart(){this.draw.isInteractionSuspended()||_o.compositionstart(this)}compositionend(t){this.draw.isInteractionSuspended()||_o.compositionend(this,t)}compositionCancel(){this.draw.isInteractionSuspended()||_o.compositionCancel(this)}drop(t){this.draw.isInteractionSuspended()||ba(t,this)}dragover(t){this.draw.isInteractionSuspended()||va.dragover(t,this)}}const us={PAGE_SCALE:"pageScale"};class Ha{draw;options;cursor;canvasEvent;range;previewer;tableTool;hyperlinkParticle;control;dateParticle;imageParticle;dprMediaQueryList;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.canvasEvent=e,this.cursor=null,this.range=t.getRange(),this.previewer=t.getPreviewer(),this.tableTool=t.getTableTool(),this.hyperlinkParticle=t.getHyperlinkParticle(),this.dateParticle=t.getDateParticle(),this.imageParticle=t.getImageParticle(),this.control=t.getControl(),this.dprMediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)}register(){this.cursor=this.draw.getCursor(),this.addEvent()}addEvent(){window.addEventListener("blur",this.clearSideEffect),document.addEventListener("mousedown",this.clearSideEffect),document.addEventListener("mouseup",this.setCanvasEventAbility),document.addEventListener("wheel",this.setPageScale,{passive:!1}),document.addEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.addEventListener("change",this._handleDprChange)}removeEvent(){window.removeEventListener("blur",this.clearSideEffect),document.removeEventListener("mousedown",this.clearSideEffect),document.removeEventListener("mouseup",this.setCanvasEventAbility),document.removeEventListener("wheel",this.setPageScale),document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.removeEventListener("change",this._handleDprChange)}clearSideEffect=t=>{if(!this.cursor)return;if(this.draw.isInteractionSuspended()){this.resetSideEffect();return}const e=t?.composedPath?.()[0]||t.target;if(this.draw.isTargetInsideEditor(e)){this.watchCursorActive();return}this.resetSideEffect()};resetSideEffect=()=>{this.cursor&&(this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage())};setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)};watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{this.cursor?.getAgentIsActive()||this.cursor?.drawCursor({isFocus:!1,isBlink:!1})})}setPageScale=t=>{if(this.draw.isInteractionSuspended()||!this.draw.isTargetInsideEditor(t.target)||this.options.shortcutDisableKeys.includes(us.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const n=e*10+1;n<=30&&this.draw.setPageScale(n/10)}else{const n=e*10-1;n>=5&&this.draw.setPageScale(n/10)}};_handleVisibilityChange=()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}};_handleDprChange=()=>{this.draw.setPageDevicePixel()}}class _a{undoStack=[];redoStack=[];maxRecordCount;constructor(t){this.maxRecordCount=t.getOptions().historyMaxRecordCount+1}undo(){if(this.undoStack.length>1){const t=this.undoStack.pop();this.redoStack.push(t),this.undoStack.length&&this.undoStack[this.undoStack.length-1]()}}redo(){if(this.redoStack.length){const t=this.redoStack.pop();this.undoStack.push(t),t()}}execute(t){for(this.undoStack.push(t),this.redoStack.length&&(this.redoStack=[]);this.undoStack.length>this.maxRecordCount;)this.undoStack.shift()}isCanUndo(){return this.undoStack.length>1}isCanRedo(){return!!this.redoStack.length}isStackEmpty(){return!this.undoStack.length&&!this.redoStack.length}recovery(){this.undoStack=[],this.redoStack=[]}popUndo(){return this.undoStack.pop()}}class xa{cursorPosition;positionContext;positionList;floatPositionList;draw;eventBus;options;constructor(t){this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:i}=this.positionContext;return t[e].trList[n].tdList[i].positionList||[]}getPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalElementList()):this.getOriginalPositionList()}getMainPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalMainElementList()):this.positionList}getOriginalPositionList(){const t=this.draw.getZone();return t.isHeaderActive()?this.draw.getHeader().getPositionList():t.isFooterActive()?this.draw.getFooter().getPositionList():this.positionList}getOriginalMainPositionList(){return this.positionList}getSelectionPositionList(){const{startIndex:t,endIndex:e}=this.draw.getRange().getRange();return t===e?null:this.getPositionList().slice(t+1,e+1)}setPositionList(t){this.positionList=t}setFloatPositionList(t){this.floatPositionList=t}computePageRowPosition(t){const{positionList:e,rowList:n,pageNo:i,startX:r,startY:s,startRowIndex:a,startIndex:c,innerWidth:d,zone:R}=t,{scale:u,table:{tdPadding:h}}=this.options;let g=r,f=s,T=c;for(let p=0;p<n.length;p++){const m=n[p];if(!m.isSurround){const P=m.width+(m.offsetX||0);m.rowFlex===l.RowFlex.CENTER?g+=(d-P)/2:m.rowFlex===l.RowFlex.RIGHT&&(g+=d-P)}g+=m.offsetX||0,f+=m.offsetY||0;const I=g,L=f;for(let P=0;P<m.elementList.length;P++){const O=m.elementList[P],S=O.metrics,F=!O.hide&&(O.imgDisplay!==l.ImageDisplay.INLINE&&O.type===l.ElementType.IMAGE||O.type===l.ElementType.LATEX)?m.ascent-S.height:m.ascent;O.left&&(g+=O.left),O.translateX&&(g+=O.translateX*u);const N={pageNo:i,index:T,value:O.value,rowIndex:a+p,rowNo:p,metrics:S,left:O.left||0,ascent:F,lineHeight:m.height,isFirstLetter:P===0,isLastLetter:P===m.elementList.length-1,coordinate:{leftTop:[g,f],leftBottom:[g,f+m.height],rightTop:[g+S.width,f],rightBottom:[g+S.width,f+m.height]}};if(O.imgDisplay===l.ImageDisplay.SURROUND||O.imgDisplay===l.ImageDisplay.FLOAT_TOP||O.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM){const V=e[e.length-1];V&&(N.metrics=V.metrics,N.coordinate=V.coordinate),O.imgFloatPosition||(O.imgFloatPosition={x:g,y:f,pageNo:i}),this.floatPositionList.push({pageNo:i,element:O,position:N,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:T,zone:R})}if(e.push(N),T++,g+=S.width,O.type===l.ElementType.TABLE&&!O.hide){const V=O.tdPadding||h,Y=V[1]+V[3],X=V[0]+V[2];for(let b=0;b<O.trList.length;b++){const E=O.trList[b];for(let C=0;C<E.tdList.length;C++){const M=E.tdList[C];M.positionList=[];const y=M.rowList,W=this.computePageRowPosition({positionList:M.positionList,rowList:y,pageNo:i,startRowIndex:0,startIndex:0,startX:(M.x+V[3])*u+I+(O.translateX||0)*u,startY:(M.y+V[0])*u+L,innerWidth:(M.width-Y)*u,isTable:!0,index:T-1,tdIndex:C,trIndex:b,zone:R});if(M.verticalAlign===l.VerticalAlign.MIDDLE||M.verticalAlign===l.VerticalAlign.BOTTOM){const D=y.reduce((G,H)=>G+H.height,0),U=(M.height-X)*u-D,Q=M.verticalAlign===l.VerticalAlign.MIDDLE?U/2:U;Math.floor(Q)>0&&M.positionList.forEach(G=>{const{coordinate:{leftTop:H,leftBottom:j,rightBottom:st,rightTop:it}}=G;H[1]+=Q,j[1]+=Q,st[1]+=Q,it[1]+=Q})}g=W.x,f=W.y}}g=I,f=L}}g=r,f+=m.height}return{x:g,y:f,index:T}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),i=n[3],s=this.draw.getHeader().getExtraHeight(),a=n[0]+s;let c=0;for(let d=0;d<e.length;d++){const R=e[d];if(!R?.length)continue;const u=R[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:R,pageNo:d,startRowIndex:c,startIndex:u,startX:i,startY:a,innerWidth:t}),c+=R.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,i=[];return this.computePageRowPosition({positionList:i,innerWidth:n,rowList:[at(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),i}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.eventBus.emit("positionContextChange",{value:t,oldValue:this.positionContext}),this.positionContext=t}getPositionByXY(t){const{x:e,y:n,isTable:i}=t;let{elementList:r,positionList:s}=t;r||(r=this.draw.getOriginalElementList()),s||(s=this.getOriginalPositionList());const a=this.draw.getZone(),c=t.pageNo??this.draw.getPageNo(),d=a.isMainActive(),R=d?c:0;if(!i){const T=this.getFloatPositionByXY({...t,imgDisplays:[l.ImageDisplay.FLOAT_TOP,l.ImageDisplay.SURROUND]});if(T)return T}for(let T=0;T<s.length;T++){const{index:p,pageNo:m,left:I,isFirstLetter:L,coordinate:{leftTop:P,rightTop:O,leftBottom:S}}=s[T];if(R===m){if(m>R)break;if(P[0]-I<=e&&O[0]>=e&&P[1]<=n&&S[1]>=n){let F=T;const N=r[T];if(N.type===l.ElementType.TABLE)for(let Y=0;Y<N.trList.length;Y++){const X=N.trList[Y];for(let b=0;b<X.tdList.length;b++){const E=X.tdList[b],C=this.getPositionByXY({x:e,y:n,td:E,pageNo:c,tablePosition:s[T],isTable:!0,elementList:E.value,positionList:E.positionList});if(~C.index){const{index:M,hitLineStartIndex:y}=C,W=E.value[M];return{index:p,isCheckbox:C.isCheckbox||W.type===l.ElementType.CHECKBOX||W.controlComponent===l.ControlComponent.CHECKBOX,isRadio:W.type===l.ElementType.RADIO||W.controlComponent===l.ControlComponent.RADIO,isControl:!!W.controlId,isImage:C.isImage,isLabel:C.isLabel,isMacro:C.isMacro,isDirectHit:C.isDirectHit,isTable:!0,tdIndex:b,trIndex:Y,tdValueIndex:M,tdId:E.id,trId:X.id,tableId:N.id,hitLineStartIndex:y}}}}if(N.type===l.ElementType.IMAGE||N.type===l.ElementType.LATEX)return{index:F,isDirectHit:!0,isImage:!0};if(N.type===l.ElementType.MENSTRUAL_HISTORY)return{index:F,isDirectHit:!0};if(N.type===l.ElementType.FETAL_HEART_POSITION)return{index:F,isDirectHit:!0};if(N.type===l.ElementType.TOOTH_POSITION){const{scale:Y}=this.options,X=N.width*Y;return e>=P[0]&&e<=P[0]+X?{index:F,isDirectHit:!0}:{index:F}}if(N.type===l.ElementType.CHECKBOX||N.controlComponent===l.ControlComponent.CHECKBOX)return{index:F,isDirectHit:!0,isCheckbox:!0};if(N.type===l.ElementType.LABEL)return{index:F,isDirectHit:!0,isLabel:!0};if(N.type===l.ElementType.MACRO||N.type===l.ElementType.CUSTOM_MACRO||N.type===l.ElementType.REUSABLE_ITEM||N.type===l.ElementType.SUB_TEMPLATE)return{index:F,isDirectHit:!0,isMacro:!0};if(N.type===l.ElementType.TAB&&N.listStyle===l.ListStyle.CHECKBOX){let Y=F-1;for(;Y>0;){const X=r[Y];if(X.value===_&&X.listStyle===l.ListStyle.CHECKBOX)break;Y--}return{index:Y,isDirectHit:!0,isCheckbox:!0}}if(N.type===l.ElementType.RADIO||N.controlComponent===l.ControlComponent.RADIO)return{index:F,isDirectHit:!0,isRadio:!0};let V;if(r[p].value!==_){const Y=O[0]-P[0];e<P[0]+Y/2&&(F=T-1,L&&(V=T))}return{isDirectHit:!0,hitLineStartIndex:V,index:F,isControl:!!N.controlId}}}}if(!i){const T=this.getFloatPositionByXY({...t,imgDisplays:[l.ImageDisplay.FLOAT_BOTTOM]});if(T)return T}let u=!1,h=-1,g;if(i){const{scale:T}=this.options,{td:p,tablePosition:m}=t;if(p&&m){const{leftTop:I}=m.coordinate,L=p.x*T+I[0],P=p.y*T+I[1],O=p.width*T,S=p.height*T;if(!(L<e&&e<L+O&&P<n&&n<P+S))return{index:h}}}const f=s.filter(T=>T.isLastLetter&&T.pageNo===R);for(let T=0;T<f.length;T++){const{index:p,rowNo:m,coordinate:{leftTop:I,leftBottom:L}}=f[T];if(n>I[1]&&n<=L[1]){const P=s.findIndex(N=>N.pageNo===R&&N.rowNo===m),O=r[P],S=s[P],F=O.listStyle===l.ListStyle.CHECKBOX?this.draw.getMargins()[3]:S.coordinate.leftTop[0];if(e<F)~P?S.value===_?h=P:(h=P-1,g=P):h=p;else{if(O.listStyle===l.ListStyle.CHECKBOX&&e<I[0])return{index:P,isDirectHit:!0,isCheckbox:!0};h=p}u=!0;break}}if(!u){if(this.draw.getIsPagingMode()){const p=this.draw.getHeader(),m=p.getHeight(),I=p.getHeaderTop()+m,L=this.draw.getFooter(),O=this.draw.getHeight()-(L.getFooterBottom()+L.getHeight());if(d){if(n<I)return{index:-1,zone:l.EditorZone.HEADER};if(n>O)return{index:-1,zone:l.EditorZone.FOOTER}}else if(n<=O&&n>=I)return{index:-1,zone:l.EditorZone.MAIN}}const T=this.draw.getMargins();if(n<=T[0])for(let p=0;p<s.length;p++){const m=s[p];if(m.pageNo!==R||m.rowNo!==0)continue;const{leftTop:I,rightTop:L}=m.coordinate;if(e<=T[3]||e>=I[0]&&e<=L[0]||s[p+1]?.rowNo!==0)return{index:m.index}}else{const p=f[f.length-1];if(p){const m=p.rowNo;for(let I=0;I<s.length;I++){const L=s[I];if(L.pageNo!==R||L.rowNo!==m)continue;const{leftTop:P,rightTop:O}=L.coordinate;if(e<=T[3]||e>=P[0]&&e<=O[0]||s[I+1]?.rowNo!==m)return{index:L.index}}}}return{index:f[f.length-1]?.index||s.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!r[h]?.controlId}}getFloatPositionByXY(t){const{x:e,y:n}=t,i=t.pageNo??this.draw.getPageNo(),r=this.draw.getZone().getZone(),{scale:s}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:c,element:d,isTable:R,index:u,trIndex:h,tdIndex:g,tdValueIndex:f,zone:T,pageNo:p}=this.floatPositionList[a];if(i===p&&d.type===l.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!T||T===r)){const m=d.imgFloatPosition,I=m.x*s,L=m.y*s,P=d.width*s,O=d.height*s;if(e>=I&&e<=I+P&&n>=L&&n<=L+O)return R?{index:u,isDirectHit:!0,isImage:!0,isTable:R,trIndex:h,tdIndex:g,tdValueIndex:f,tdId:d.tdId,trId:d.trId,tableId:d.tableId}:{index:c.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==l.EditorMode.READONLY){const{index:p,isTable:m,trIndex:I,tdIndex:L,tdValueIndex:P}=e,O=this.draw.getControl(),{newIndex:S}=O.moveCursor({index:p,isTable:m,trIndex:I,tdIndex:L,tdValueIndex:P});m?e.tdValueIndex=S:e.index=S}const{index:n,isCheckbox:i,isRadio:r,isControl:s,isImage:a,isLabel:c,isDirectHit:d,isTable:R,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T}=e;return this.setPositionContext({isTable:R||!1,isCheckbox:i||!1,isRadio:r||!1,isControl:s||!1,isImage:a||!1,isLabel:c||!1,isDirectHit:d||!1,index:n,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T}),e}setSurroundPosition(t){const{scale:e}=this.options,{pageNo:n,row:i,rowElement:r,rowElementRect:s,surroundElementList:a,availableWidth:c}=t;let d=s.x,R=0;if(a.length&&!nn(r)&&!r.control?.minWidth)for(let u=0;u<a.length;u++){const h=a[u],g=h.imgFloatPosition;if(g.pageNo!==n)continue;const f={...g,x:g.x*e,y:g.y*e,width:h.width*e,height:h.height*e};if($r(s,f)){i.isSurround=!0;const T=f.width+f.x-s.x;if(r.left=T,i.width+=T,R+=T,d=f.x+f.width,i.width+r.metrics.width>c){r.left=0,i.width-=R;break}}}return{x:d,rowIncreaseWidth:R}}}class Ga{draw;options;range;listener;eventBus;position;historyManager;defaultStyle;lastRangeStyle;constructor(t){this.draw=t,this.options=t.getOptions(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null,this.lastRangeStyle=null}_isSameRangeStyle(t,e){if(!t||!["type","undo","redo","painter","font","size","bold","italic","underline","strikeout","deletePerson","color","highlight","rowFlex","vertical","rowMargin","level","listType","listStyle","textDecoration","extension"].every(c=>t[c]===e[c])||!(t.dashArray.length===e.dashArray.length&&t.dashArray.every((c,d)=>c===e.dashArray[d])))return!1;const s=t.groupIds||[],a=e.groupIds||[];return s.length===a.length&&s.every((c,d)=>c===a[d])}_emitRangeStyle(t){this._isSameRangeStyle(this.lastRangeStyle,t)||(this.lastRangeStyle={...t,dashArray:[...t.dashArray],groupIds:t.groupIds?[...t.groupIds]:null},this.listener.rangeStyleChange?.(t),this.eventBus.isSubscribe("rangeStyleChange")&&this.eventBus.emit("rangeStyleChange",t))}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}setDefaultStyle(t){t?this.defaultStyle={...this.defaultStyle,...t}:this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=je(t,e);return n?{...n,...this.defaultStyle}:null}getIsRangeChange(t,e,n,i,r,s,a){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==i||this.range.endTdIndex!==r||this.range.startTrIndex!==s||this.range.endTrIndex!==a}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getIsSelection(){const{startIndex:t,endIndex:e}=this.range;return!~t&&!~e?!1:t!==e}getSelection(){const{startIndex:t,endIndex:e,splitTdRange:n}=this.range;if(t===e)return null;if(n)return this.draw.getSplitTdValues(n.originalId).slice(n.startIndex+1,n.endIndex+1);const i=this.draw.getElementList();return i.slice(i[t]?.value===_?t:t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let n=0;n<t.length;n++){const i=t[n];for(let r=0;r<i.length;r++){const s=i[r];e.push(...s.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||$t.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||$t.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=new Map;for(let r=t;r<e+1;r++){const{pageNo:s,rowNo:a}=n[r],c=i.get(s);c?c.has(a)||c.add(a):i.set(s,new Set([a]))}return i}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const i=this.getRangeRow();if(!i)return null;const r=this.position.getPositionList(),s=this.draw.getElementList(),a=[];for(let c=0;c<r.length;c++){const d=r[c],R=i.get(d.pageNo);R&&R.has(d.rowNo)&&a.push(s[c])}return a}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=this.draw.getElementList(),r=new Map;let s=t;for(;s>=0;){const{pageNo:d,rowNo:R}=n[s];let u=r.get(d);u||(u=[],r.set(d,u)),u.includes(R)||u.unshift(R);const h=i[s],g=i[s-1];if(h.value===_&&!h.listWrap||h.listId!==g?.listId||h.titleId!==g?.titleId)break;s--}const a=t===e;if(!a){let d=t+1;for(;d<e;){const{pageNo:R,rowNo:u}=n[d];let h=r.get(R);h||(h=[],r.set(R,h)),h.includes(u)||h.push(u),d++}}let c=e;for(a&&i[t].value===_&&(c+=1);c<n.length;){const d=i[c],R=i[c+1];if(d.value===_&&!d.listWrap||d.listId!==R?.listId||d.titleId!==R?.titleId)break;const{pageNo:u,rowNo:h}=n[c];let g=r.get(u);g||(g=[],r.set(u,g)),g.includes(h)||g.push(h),c++}return r}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const i=[],r=this.getRangeParagraph();if(!r)return null;const s=this.draw.getElementList(),a=this.position.getPositionList();for(let c=0;c<a.length;c++){const d=a[c],R=r.get(d.pageNo);R&&R.includes(d.rowNo)&&(~n||(n=d.index),i.push(s[c]))}return i.length?{elementList:i,startIndex:n}:null}getRangeParagraphElementList(){return this.getRangeParagraphInfo()?.elementList||null}getRangeTableElement(){const t=this.position.getPositionContext();return t.isTable?this.draw.getOriginalElementList()[t.index]:null}getIsSelectAll(){const t=this.draw.getElementList(),{startIndex:e,endIndex:n}=this.range;return e===0&&t.length-1===n&&!this.position.getPositionContext().isTable}getIsPointInRange(t,e,n){const{startIndex:i,endIndex:r}=this.range,s=this.position.getPositionList();for(let a=i+1;a<=r&&s[a];a++){const{coordinate:{leftTop:d,rightBottom:R},pageNo:u}=s[a];if(n===u&&t>=d[0]&&t<=R[0]&&e>=d[1]&&e<=R[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const r of e){const s=n.get(r.groupId);if(s)s.endIndex+=1;else{const{type:a,groupId:c,tableId:d,index:R,tdIndex:u,trIndex:h}=r,g={startIndex:R,endIndex:R};a===ge.TABLE&&(g.tableId=d,g.startTdIndex=u,g.endTdIndex=u,g.startTrIndex=h,g.endTrIndex=h),n.set(c,g)}}const i=[];return n.forEach(r=>{i.push(r)}),i}getIsCanInput(){const{range:{startIndex:t,endIndex:e},elementList:n}=this.getRangeElement(),i=n[t];if(!i)return!1;if(t===e)return(i.controlComponent!==l.ControlComponent.PRE_TEXT||n[t+1]?.controlComponent!==l.ControlComponent.PRE_TEXT)&&i.controlComponent!==l.ControlComponent.POST_TEXT;const r=n[e];return r?!i.controlId&&!r.controlId||(!i.controlId||i.controlComponent===l.ControlComponent.POSTFIX)&&(!r.controlId||r.controlComponent===l.ControlComponent.POSTFIX)||!!i.controlId&&r.controlId===i.controlId&&r.controlComponent!==l.ControlComponent.PRE_TEXT&&r.controlComponent!==l.ControlComponent.POST_TEXT&&r.controlComponent!==l.ControlComponent.POSTFIX:!1}setRange(t,e,n,i,r,s,a,c){this.getIsRangeChange(t,e,n,i,r,s,a)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=i,this.range.endTdIndex=r,this.range.startTrIndex=s,this.range.endTrIndex=a,this.range.isCrossRowCol=!!(i||r||s||a),this.range.splitTdRange=c,this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const R=this.draw.getControl();if(~t&&~e&&!!this.draw.getElementList()[t]?.controlId){R.initControl();return}R.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:r}=this.range;if(!~n&&!~i)return;let s;if(r){const y=this.draw.getOriginalElementList(),W=this.position.getPositionContext();s=y[W.index]}else{const y=~i?i:0,W=this.draw.getElementList();s=this.getRangeAnchorStyle(W,y)}if(!s)return;const a=this.getSelection()||[s],c=s.type||l.ElementType.TEXT,d=s.font||this.options.defaultFont,R=s.size||this.options.defaultSize,u=!~a.findIndex(y=>!y.bold),h=!~a.findIndex(y=>!y.italic),g=!~a.findIndex(y=>!y.underline&&!y.control?.underline),f=!~a.findIndex(y=>!y.strikeout),T=s.color||null,p=s.highlight||null,m=s.rowFlex||null,I=s.vertical||null,L=s.rowMargin??this.options.defaultRowMargin,P=s.dashArray||[],O=s.level||null,S=s.listType||null,F=s.listStyle||null,N=g&&s.textDecoration||null,V=!!this.draw.getPainterStyle(),Y=this.historyManager.isCanUndo(),X=this.historyManager.isCanRedo(),b=s.groupIds||null,E=s.extension??null,C=s.deletePerson??"",M={type:c,undo:Y,redo:X,painter:V,font:d,size:R,bold:u,italic:h,underline:g,strikeout:f,deletePerson:C,color:T,highlight:p,rowFlex:m,vertical:I,rowMargin:L,dashArray:P,level:O,listType:S,listStyle:F,groupIds:b,textDecoration:N,extension:E};this._emitRangeStyle(M)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,i=this.options.defaultSize,r=this.options.defaultRowMargin,s=!!this.draw.getPainterStyle(),a=this.historyManager.isCanUndo(),c=this.historyManager.isCanRedo(),R={type:null,undo:a,redo:c,painter:s,font:n,size:i,bold:!1,italic:!1,underline:!1,strikeout:!1,deletePerson:"123",color:null,highlight:null,rowFlex:null,rowMargin:r,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null,vertical:null};this._emitRangeStyle(R)}shrinkBoundary(t={}){const{elementList:e,range:n}=this.getRangeElement(t),{startIndex:i,endIndex:r}=n;if(!~i&&!~r)return;const s=e[i],a=e[r];if(i===r){if(s.controlComponent===l.ControlComponent.PLACEHOLDER){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId===s.controlId&&(d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)){n.startIndex=c,n.endIndex=c;break}if(d.controlId!==s.controlId&&!d.originControlId)break;c--}}if(s.controlComponent===l.ControlComponent.TEXTFIXLABEL){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId!==s.controlId||d.controlComponent===l.ControlComponent.VALUE||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;break}c--}}}else{if(s.controlComponent===l.ControlComponent.PLACEHOLDER||a.controlComponent===l.ControlComponent.PLACEHOLDER||s.controlComponent===l.ControlComponent.TEXTFIXLABEL||a.controlComponent===l.ControlComponent.TEXTFIXLABEL){let c=r-1;for(;c>0;){const d=e[c];if(d.controlId!==a.controlId||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;return}c--}}if(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PRETEXTFIX||s.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==s.controlId||d.controlComponent===l.ControlComponent.VALUE){n.startIndex=c-1;break}else if(d.controlComponent===l.ControlComponent.PLACEHOLDER){n.startIndex=c-1,n.endIndex=c-1;return}c++}}if(a.controlComponent!==l.ControlComponent.VALUE){let c=r-1;for(;c>0;){const d=e[c];if(d.controlId!==s.controlId||d.controlComponent===l.ControlComponent.VALUE){n.endIndex=c;break}else if(d.controlComponent===l.ControlComponent.PLACEHOLDER){n.startIndex=c,n.endIndex=c;return}c--}}}}render(t,e,n,i,r){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,i,r),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(_,"g"),""):""}getRangeElement(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{splitTdRange:i}=n,r={elementList:e,range:n};return i&&(r.range=i,r.elementList=this.draw.getSplitTdValues(i.originalId)??[]),r}}class Aa{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,i){t.save(),t.fillStyle=e,t.fillRect(0,0,n,i),t.restore()}_drawImage(t,e,n,i){const{background:r,scale:s}=this.options;if(r.size===l.BackgroundSize.CONTAIN){const a=e.width*s,c=e.height*s;if(!r.repeat||r.repeat===l.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,a,c);else{let d=0,R=0;const u=r.repeat===l.BackgroundRepeat.REPEAT||r.repeat===l.BackgroundRepeat.REPEAT_X?Math.ceil(n*s/a):1,h=r.repeat===l.BackgroundRepeat.REPEAT||r.repeat===l.BackgroundRepeat.REPEAT_Y?Math.ceil(i*s/c):1;for(let g=0;g<u;g++){for(let f=0;f<h;f++)t.drawImage(e,d,R,a,c),R+=c;R=0,d+=a}}}else t.drawImage(e,0,0,n*s,i*s)}_renderBackgroundImage(t,e,n){const{background:i}=this.options,r=this.imageCache.get(i.image);if(r)this._drawImage(t,r,e,n);else{const s=new Image;s.setAttribute("crossOrigin","Anonymous"),s.src=i.image,s.onload=()=>{this.imageCache.set(i.image,s),this._drawImage(t,s,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:i,applyPageNumbers:r}}=this.options;if(n&&(!r?.length||r.includes(e))){const{width:s,height:a}=this.options;this._renderBackgroundImage(t,s,a)}else{const s=this.draw.getCanvasWidth(e),a=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,i,s,a)}}}class xo{fillRect;fillColor;fillDecorationStyle;constructor(){this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,i,r,s,a){const c=!this.fillRect.width;if(!c&&(this.fillColor!==s||this.fillDecorationStyle!==a)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,i,r,s,a);return}c&&(this.fillRect.x=e,this.fillRect.y=n),r&&this.fillRect.height<r&&(this.fillRect.height=r),this.fillRect.width+=i,this.fillColor=s,this.fillDecorationStyle=a}}class ka extends xo{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:i,width:r,height:s}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,i,r,s),t.restore(),this.clearFillInfo()}}class Ja{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:i}=this.options,r=this.draw.getWidth(),s=i===l.PageMode.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),a=this.draw.getMargins(),c=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=n,t.beginPath();const d=[a[3],a[0]],R=[r-a[1],a[0]],u=[a[3],s-a[2]],h=[r-a[1],s-a[2]];t.moveTo(d[0]-c,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-c),t.moveTo(R[0]+c,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]-c),t.moveTo(u[0]-c,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]+c),t.moveTo(h[0]+c,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+c),t.stroke(),t.restore()}}class Ba{draw;options;position;range;searchKeyword;searchNavigateIndex;searchOptions;searchMatchList;constructor(t){this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.searchNavigateIndex=null,this.searchOptions=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t,e){this.searchKeyword=t,this.searchNavigateIndex=null,this.searchOptions=e||null}searchNavigatePre(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex-1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===n)return null;this.searchNavigateIndex=this.searchMatchList.length-1-(this.searchKeyword.length-1)}}return this.searchNavigateIndex}searchNavigateNext(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex+1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===n)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:n,rightTop:i},pageNo:r}=t,s=this.draw.getHeight(),a=this.draw.getPageGap(),c=r*(s+a),d=document.createElement("div");d.style.position="absolute";const R=50;d.style.width=`${i[0]-e[0]+R}px`,d.style.height=`${n[1]-e[1]+R}px`,d.style.left=`${e[0]}px`,d.style.top=`${e[1]+c}px`,this.draw.getContainer().append(d),d.scrollIntoView(!1),d.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let i=0;i<this.searchMatchList.length;i++){const r=this.searchMatchList[i];n!==r.groupId&&(n=r.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:i=!0}=this.searchOptions||{},r=i?t.toLocaleLowerCase():t,s=[],a=[],c=e.length,d=[];for(let g=0;g<c;g++)e[g].type===l.ElementType.TABLE&&d.push(g);let R=0,u=0;for(;u<c-1;){const g=d.length?d[R]:c,f=e.slice(u,g);f.length&&a.push({index:u,type:ge.PAGE,elementList:f});const T=e[g];T&&a.push({index:g,type:ge.TABLE,elementList:[T]}),u=g+1,R++}function h(g,f,T,p){if(!g)return;let m=T.map(S=>!S.type||$t.includes(S.type)&&S.controlComponent!==l.ControlComponent.CHECKBOX&&S.controlComponent!==l.ControlComponent.RADIO&&!S.hide&&!S.control?.hide&&!S.area?.hide?S.value:_).filter(Boolean).join("");i&&(m=m.toLocaleLowerCase());const I=[],L=n?new RegExp(g):g;let{index:P,length:O}=wi(m,L);for(;P!==-1&&O!==0;){I.push({index:P,length:O});const S=wi(m,L,P+O);P=S.index,O=S.length}for(let S=0;S<I.length;S++){const{index:F,length:N}=I[S],V=lt();for(let Y=0;Y<N;Y++){const X=F+Y+(p?.startIndex||0);s.push({type:f,index:X,groupId:V,...p})}}}for(let g=0;g<a.length;g++){const f=a[g];if(f.type===ge.TABLE){const T=f.elementList[0];for(let p=0;p<T.trList.length;p++){const m=T.trList[p];for(let I=0;I<m.tdList.length;I++){const L=m.tdList[I],P={tableId:T.id,tableIndex:f.index,trIndex:p,tdIndex:I,tdId:L.id};h(r,f.type,L.value,P)}}}else h(r,f.type,f.elementList,{startIndex:f.index})}return s}compute(t){const e=this.searchOptions?.isLimitSelection&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!n?.length||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:i}=this.range.getRange(),r=i+1;for(const s of this.searchMatchList)s.type===ge.TABLE?s.tableIndex+=r:s.index+=r}render(t,e){if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:i,searchNavigateMatchColor:r}=this.options,s=this.position.getOriginalPositionList(),a=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let c=0;c<this.searchMatchList.length;c++){const d=this.searchMatchList[c];let R=null;if(d.type===ge.TABLE){const{tableIndex:P,trIndex:O,tdIndex:S,index:F}=d;R=a[P]?.trList[O].tdList[S]?.positionList[F]}else R=s[d.index];if(!R)continue;const{coordinate:{leftTop:u,leftBottom:h,rightTop:g},pageNo:f}=R;if(f!==e)continue;if(this.getSearchNavigateIndexList().includes(c)){t.fillStyle=r;const P=this.searchMatchList[c-1];(!P||P.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(R)}else t.fillStyle=i;const p=u[0],m=u[1],I=g[0]-u[0],L=h[1]-u[1];t.fillRect(p,m,I,L)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const r=e?.index;if(Mo(r)){const T=[];i.forEach(p=>{const m=T[T.length-1];!m||m[0].groupId!==p.groupId?T.push([p]):m.push(p)}),i=T[r]}if(!i?.length)return;const s=this.draw.isDesignMode();let a=0,c=0,d="",R="",u=-1;const h=this.draw.getOriginalElementList();for(let T=0;T<i.length;T++){const p=i[T];if(p.type===ge.TABLE){const{tableIndex:m,trIndex:I,tdIndex:L,index:P,tdId:O}=p;R&&O!==R&&(c=0),R=O;const S=m+a,F=h[S].trList[I].tdList[L].value,N=P+c,V=F[N];if(!s&&(V?.control?.deletable===!1||V?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(F,N,1),c--,~u||(u=T);continue}if(d===p.groupId){this.draw.spliceElementList(F,N,1),c--;continue}~u||(u=T);for(let Y=0;Y<t.length;Y++){const X=t[Y];Y===0?V.value=X:(this.draw.spliceElementList(F,N+Y,0,[{...V,value:X}]),c++)}}else{const m=p.index+a,I=h[m];if(!s&&(I?.control?.deletable===!1||I?.title?.deletable===!1)||I.type===l.ElementType.CONTROL&&I.controlComponent!==l.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,m,1),a--,~u||(u=T);continue}if(~u||(u=T),d===p.groupId){this.draw.spliceElementList(h,m,1),a--;continue}for(let L=0;L<t.length;L++){const P=t[L];L===0?I.value=P:(this.draw.spliceElementList(h,m+L,0,[{...I,value:P}]),a++)}}d=p.groupId}if(!~u)return;const g=i[u],f=g.index+(t.length-1);if(g.type===ge.TABLE){const{tableIndex:T,trIndex:p,tdIndex:m,index:I}=g,L=h[T].trList[p].tdList[m].value[I];this.position.setPositionContext({isTable:!0,index:T,trIndex:p,tdIndex:m,tdId:L.tdId,trId:L.trId,tableId:L.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(f,f),this.draw.render({curIndex:f})}}class $a extends xo{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:i,y:r,width:s}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const a=r-3;t.beginPath(),t.moveTo(i,a),t.lineTo(i+s,a),t.stroke(),t.beginPath(),t.moveTo(i,r+3.5),t.lineTo(i+s,r+3.5),t.stroke(),t.restore(),this.clearFillInfo()}}l.TextDecorationStyle=void 0,(function(o){o.SOLID="solid",o.DOUBLE="double",o.DASHED="dashed",o.DOTTED="dotted",o.WAVY="wavy"})(l.TextDecorationStyle||(l.TextDecorationStyle={}));var on;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(on||(on={}));class za extends xo{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,r){const s=e+i;switch(t.beginPath(),r){case on.DASHED:t.setLineDash([3,1]);break;case on.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(s,n),t.stroke()}_drawDouble(t,e,n,i){const s=e+i,a=n+3*this.options.scale;this.options.mode===l.EditorMode.PRINT?t.strokeStyle="transparent":t.strokeStyle="red",t.beginPath(),t.moveTo(e,n),t.lineTo(s,n),t.stroke(),t.beginPath(),t.moveTo(e,a),t.lineTo(s,a),t.stroke()}_drawWave(t,e,n,i){const{scale:r}=this.options,s=1.2*r,a=1/r,c=n+2*s;t.beginPath();for(let d=0;d<i;d++){const R=s*Math.sin(a*d);t.lineTo(e+d,c+R)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:r,width:s}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const a=Math.floor(r+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case l.TextDecorationStyle.WAVY:this._drawWave(t,i,a,s);break;case l.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,a,s);break;case l.TextDecorationStyle.DASHED:this._drawLine(t,i,a,s,on.DASHED);break;case l.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,s,on.DOTTED);break;default:this._drawLine(t,i,a,s);break}t.restore(),this.clearFillInfo()}}class ja{draw;options;ctx;curX;curY;text;curStyle;curColor;cacheMeasureText;constructor(t){this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureBasisWord(t,e){t.save(),t.font=e;const n=this.measureText(t,{value:Yr});return t.restore(),n}measureWord(t,e,n){const i=this.draw.getLetterReg();let r=0,s=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==l.ElementType.TEXT||!i.test(c.value)){s=c;break}r+=this.measureText(t,c).width,a++}return{width:r,endElement:s}}buttonMeasureWord(t,e,n){const i=this.draw.getLetterReg();let r=0,s=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==l.ElementType.TEXT||!i.test(c.value)){s=c;break}r+=this.measureText(t,c).width,a++}return{width:r,endElement:s}}measurePunctuationWidth(t,e){return!e||!Vr.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const s=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:s.actualBoundingBoxAscent,actualBoundingBoxDescent:s.actualBoundingBoxDescent,actualBoundingBoxLeft:s.actualBoundingBoxLeft,actualBoundingBoxRight:s.actualBoundingBoxRight,fontBoundingBoxAscent:s.fontBoundingBoxAscent,fontBoundingBoxDescent:s.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,i=this.cacheMeasureText.get(n);if(i)return i;const r=t.measureText(e.value);return this.cacheMeasureText.set(n,r),r}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,i){if(this.ctx=t,this.options.renderMode===l.RenderMode.COMPATIBILITY){this._setCurXY(n,i),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,i),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,i)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color}_setCurXY(t,e){this.curX=t,this.curY=e}_render(){!this.text||!~this.curX||!~this.curX||(this.ctx.save(),this.ctx.font=this.curStyle,this.ctx.fillStyle=this.curColor||this.options.defaultColor,this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}class sn{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const r=i===l.NumberType.CHINESE?Ar(e):`${e}`;return t.replace(n,r)}render(t,e){const{scale:n,pageNumber:{size:i,font:r,color:s,rowFlex:a,numberType:c,format:d,startPageNo:R,fromPageNo:u}}=this.options;if(e<u)return;let h=d;const g=new RegExp(pn.PAGE_NO);g.test(h)&&(h=sn.formatNumberPlaceholder(h,e+R-u,g,c));const f=new RegExp(pn.PAGE_COUNT);f.test(h)&&(h=sn.formatNumberPlaceholder(h,this.draw.getPageCount()-u,f,c));const T=this.draw.getWidth(),p=this.draw.getHeight(),m=this.draw.getPageNumberBottom(),I=p-m;t.save(),t.fillStyle=s,t.font=`${i*n}px ${r}`;let L=0;const P=this.draw.getMargins(),{width:O}=t.measureText(h);a===l.RowFlex.CENTER?L=(T-O)/2:a===l.RowFlex.RIGHT?L=T-O-P[1]:L=P[3],t.fillText(h,L,I),t.restore()}}class qa{draw;options;scrollContainer;constructor(t){this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,i=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:i>0?i:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,i=0;for(let r=0;r<t.length;r++){const s=t[r],{intersectionHeight:a}=this.getElementVisibleInfo(s);if(i&&!a)break;a&&e.push(r),a>i&&(i=a,n=r)}return{intersectionPageNo:n,visiblePageNoList:e}}_observer=Kr(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150)}class tc{draw;step=5;thresholdPoints=[70,40,10,20];selectionContainer;rangeManager;requestAnimationFrameId;isMousedown;isMoving;clientWidth;clientHeight;containerRect;constructor(t){this.draw=t,this.rangeManager=t.getRange();const{scrollContainerSelector:e}=t.getOptions();this.selectionContainer=e&&document.querySelector(e)||document,this.requestAnimationFrameId=null,this.isMousedown=!1,this.isMoving=!1,this.clientWidth=0,this.clientHeight=0,this.containerRect=null,this._addEvent()}_addEvent(){const t=this.selectionContainer;t.addEventListener("mousedown",this._mousedown),t.addEventListener("mousemove",this._mousemove),t.addEventListener("mouseup",this._mouseup),document.addEventListener("mouseleave",this._mouseup)}removeEvent(){const t=this.selectionContainer;t.removeEventListener("mousedown",this._mousedown),t.removeEventListener("mousemove",this._mousemove),t.removeEventListener("mouseup",this._mouseup),document.removeEventListener("mouseleave",this._mouseup)}_mousedown=t=>{if(this.draw.isInteractionSuspended()){this._mouseup();return}if(!this.draw.isTargetInsideEditor(t.target)){this._mouseup();return}if(this.isMousedown=!0,this.clientWidth=this.selectionContainer instanceof Document?document.documentElement.clientWidth:this.selectionContainer.clientWidth,this.clientHeight=this.selectionContainer instanceof Document?document.documentElement.clientHeight:this.selectionContainer.clientHeight,!(this.selectionContainer instanceof Document)){const e=this.selectionContainer.getBoundingClientRect();this.containerRect=e}};_mouseup=()=>{this.isMousedown=!1,this._stopMove()};_mousemove=t=>{if(this.draw.isInteractionSuspended()||!this.isMousedown||this.rangeManager.getIsCollapsed())return;let{x:e,y:n}=t;this.containerRect&&(e=e-this.containerRect.x,n=n-this.containerRect.y),n<this.thresholdPoints[0]?this._startMove(Zt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Zt.DOWN):e<this.thresholdPoints[2]?this._startMove(Zt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Zt.RIGHT):this._stopMove()};_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Zt.DOWN?e.scrollTo(n,i+this.step):t===Zt.UP?e.scrollTo(n,i-this.step):t===Zt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class ec{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=at(t);for(let n=0;n<t.length;n++){const i=e[n];for(let r=i.tdList.length-1;r>=0;r--){const s=i.tdList[r],{rowspan:a,rowIndex:c,colIndex:d}=s,R=c+a-1;if(R!==r){const u=i.tdList.splice(r,1)[0];e[R]?.tdList.splice(d,0,u)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:r,startTdIndex:s,endTdIndex:a,startTrIndex:c,endTrIndex:d}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!r)return[[h[n].tdList[i]]];let g=h[c].tdList[s],f=h[d].tdList[a];(g.x>f.x||g.y>f.y)&&([g,f]=[f,g]);const T=g.colIndex,p=f.colIndex+(f.colspan-1),m=g.rowIndex,I=f.rowIndex+(f.rowspan-1),L=[];for(let P=0;P<h.length;P++){const O=h[P],S=[];for(let F=0;F<O.tdList.length;F++){const N=O.tdList[F],V=N.colIndex,Y=N.rowIndex;V>=T&&V<=p&&Y>=m&&Y<=I&&S.push(N)}S.length&&L.push(S)}return L.length?L:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:r,height:s,isDrawFullBorder:a,borderExternalWidth:c}=t,{scale:d}=this.options,R=e.lineWidth;c&&(e.lineWidth=c*d),e.beginPath();const u=Math.round(n),h=Math.round(i);e.translate(.5,.5),a?e.rect(u,h,r,s):(e.moveTo(u,h+s),e.lineTo(u,h),e.lineTo(u+r,h)),e.stroke(),c&&(e.lineWidth=R),e.translate(-.5,-.5)}_drawSlash(t,e,n,i){const{scale:r}=this.options;t.save();const s=e.width*r,a=e.height*r,c=Math.round(e.x*r+n),d=Math.round(e.y*r+i);e.slashTypes?.includes(l.TdSlash.FORWARD)&&(t.moveTo(c+s,d),t.lineTo(c,d+a)),e.slashTypes?.includes(l.TdSlash.BACK)&&(t.moveTo(c,d),t.lineTo(c+s,d+a)),t.stroke(),t.restore()}_drawBorder(t,e,n,i){const{colgroup:r,trList:s,borderType:a,borderColor:c,borderWidth:d=1,borderExternalWidth:R}=e;if(!r||!s)return;const{scale:u,table:{defaultBorderColor:h}}=this.options,g=e.width*u,f=e.height*u,T=a===l.TableBorder.EMPTY,p=a===l.TableBorder.EXTERNAL,m=a===l.TableBorder.INTERNAL;t.save(),a===l.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*u,t.strokeStyle=c||h,!T&&!m&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:f,borderExternalWidth:R,isDrawFullBorder:p});for(let I=0;I<s.length;I++){const L=s[I];for(let P=0;P<L.tdList.length;P++){const O=L.tdList[P];if(O.slashTypes?.length&&this._drawSlash(t,O,n,i),!O.borderTypes?.length&&(T||p))continue;const S=O.width*u,F=O.height*u,N=Math.round(O.x*u+n+S),V=Math.round(O.y*u+i);if(t.translate(.5,.5),t.beginPath(),O.borderTypes?.includes(l.TdBorder.TOP)&&(t.moveTo(N-S,V),t.lineTo(N,V),t.stroke()),O.borderTypes?.includes(l.TdBorder.RIGHT)&&(t.moveTo(N,V),t.lineTo(N,V+F),t.stroke()),O.borderTypes?.includes(l.TdBorder.BOTTOM)&&(t.moveTo(N,V+F),t.lineTo(N-S,V+F),t.stroke()),O.borderTypes?.includes(l.TdBorder.LEFT)&&(t.moveTo(N-S,V),t.lineTo(N-S,V+F),t.stroke()),!T&&!p){if((!m||O.colIndex+O.colspan<r.length)&&(t.moveTo(N,V),t.lineTo(N,V+F),R&&R!==d&&O.colIndex+O.colspan===r.length)){const Y=t.lineWidth;t.lineWidth=R*u,t.stroke(),t.beginPath(),t.lineWidth=Y}if(!m||O.rowIndex+O.rowspan<s.length){const Y=R&&R!==d&&O.rowIndex+O.rowspan===s.length;if(Y&&(t.stroke(),t.beginPath()),t.moveTo(N,V+F),t.lineTo(N-S,V+F),Y){const X=t.lineWidth;t.lineWidth=R*u,t.stroke(),t.beginPath(),t.lineWidth=X}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:r}=e;if(!r)return;const{scale:s}=this.options;for(let a=0;a<r.length;a++){const c=r[a];for(let d=0;d<c.tdList.length;d++){const R=c.tdList[d];if(!R.backgroundColor)continue;t.save();const u=R.width*s,h=R.height*s,g=Math.round(R.x*s+n),f=Math.round(R.y*s+i);t.fillStyle=R.backgroundColor,t.fillRect(g,f,u,h),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return e?.length?this.getTdListByColIndex(e,0).reduce((n,i)=>n+i.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,i)=>n+i.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let s=0;s<r.length;s++){const a=r[s],c=a.colIndex,d=c+a.colspan-1;e>=c&&e<=d&&n.push(a)}}return n}getTdListByRowIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let s=0;s<r.length;s++){const a=r[s],c=a.rowIndex,d=c+a.rowspan-1;e>=c&&e<=d&&n.push(a)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let i=0;for(let r=0;r<n.length;r++){const s=n[r],a=n.length-1===r;for(let c=0;c<s.tdList.length;c++){const d=s.tdList[c];let R=0;if(n.length>1&&r!==0){const m=s.tdList[c-1],I=m?m.colIndex+m.colspan:c;for(let L=I;L<e.length;L++)if(this.getRowCountByColIndex(n.slice(0,r),L)===r){R=L;let O=0;for(let S=0;S<L;S++)O+=e[S].width;i=O;break}}else{const m=s.tdList[c-1];m&&(R=m.colIndex+m.colspan)}let u=0;for(let m=0;m<d.colspan;m++)u+=e[m+R].width;let h=0;for(let m=0;m<d.rowspan;m++){const I=n[m+r]||n[r];h+=I.height}const g=s.tdList.length-1===c;let f=a;if(!f&&d.rowspan>1){const m=n.length-1-r;f=d.rowspan-1===m}const T=a&&g;d.isLastRowTd=g,d.isLastColTd=f,d.isLastTd=T,d.x=i;let p=0;for(let m=0;m<r;m++){const I=n[m].tdList;for(let L=0;L<I.length;L++){const P=I[L];if(R>=P.colIndex&&R<P.colIndex+P.colspan){p+=P.height;break}}}d.y=p,d.width=u,d.height=h,d.rowIndex=r,d.colIndex=R,d.trIndex=r,d.tdIndex=c,i+=u,g&&!T&&(i=0)}}}drawRange(t,e,n,i){const{scale:r,rangeAlpha:s,rangeColor:a}=this.options,{type:c,trList:d}=e;if(!d||c!==l.ElementType.TABLE)return;const{isCrossRowCol:R,startTdIndex:u,endTdIndex:h,startTrIndex:g,endTrIndex:f}=this.range.getRange();if(!R)return;let T=d[g].tdList[u],p=d[f].tdList[h];(T.x>p.x||T.y>p.y)&&([T,p]=[p,T]);const m=T.colIndex,I=p.colIndex+(p.colspan-1),L=T.rowIndex,P=p.rowIndex+(p.rowspan-1);t.save();for(let O=0;O<d.length;O++){const S=d[O];for(let F=0;F<S.tdList.length;F++){const N=S.tdList[F],V=N.colIndex,Y=N.rowIndex;if(V>=m&&V<=I&&Y>=L&&Y<=P){const X=N.x*r,b=N.y*r,E=N.width*r,C=N.height*r;t.globalAlpha=s,t.fillStyle=a,t.fillRect(X+n,b+i,E,C)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}findPreRowSpanTd(t,e,n){for(let i=e;i>=0;i--){const r=t[i].tdList.find(s=>s.colIndex===n);if(r)return r}}computeTrHeight(t,e){const{scale:n,table:{tdPadding:i,defaultTrMinHeight:r}}=this.options,s=t.tdPadding||i,a=s[0]+s[2],c=t.trList;for(let u=0;u<c.length;u++){const h=c[u];h.height=h.minHeight||r,h.minHeight=h.height}this.computeRowColInfo(t);const d={},R={};for(let u=0;u<c.length;u++){const h=c[u];if(!h.tdList.length){h.height=0;continue}const g=[],f=[];for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(I=>I.colIndex===p);if(m){const I=e?e(m):m.rowList,L=I.reduce((O,S)=>O+S.height,0);m.rowList=I;const P=L/n+a;m.mainHeight=P,m.rowspan>1?(R[m.colIndex]=m.id,d[m.id]={td:m,rowSpan:[u,u+m.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:P},f.push(P)):m.height<P?(m.height=P,m.realHeight=P,g.push(P)):g.push(m.height)}else{const I=d[R[p]];I?.rowSpan[1]==u&&g.push(I.extraHeight)}}const T=Math.max(...g.length?g:f);Object.values(d).forEach(p=>{p.rowSpan[0]<=u&&p.rowSpan[1]>=u&&(p.extraHeight-=T,p.preHeight+=T,p.preMinHeight+=h.minHeight)}),h.height=T;for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(I=>I.colIndex===p)??this.findPreRowSpanTd(c,u,p);if(m){const I=d[m.id]?.preHeight??0,L=d[m.id]?.preMinHeight??h.minHeight;m.height=T+I,m.realHeight=T+I,m.realMinHeight=L}}}this.computeRowColInfo(t)}}var Te;(function(o){o.ROW="row",o.COL="col"})(Te||(Te={}));class nc{MIN_TD_WIDTH=20;ROW_COL_OFFSET=18;ROW_COL_QUICK_WIDTH=16;ROW_COL_QUICK_OFFSET=5;ROW_COL_QUICK_POSITION=this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2;BORDER_VALUE=4;TABLE_SELECT_OFFSET=20;draw;canvas;options;position;range;container;toolRowContainer;toolRowAddBtn;toolColAddBtn;toolTableSelectBtn;toolColContainer;toolBorderContainer;anchorLine;mousedownX;mousedownY;constructor(t){this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){this.toolRowContainer?.remove(),this.toolRowAddBtn?.remove(),this.toolColAddBtn?.remove(),this.toolTableSelectBtn?.remove(),this.toolColContainer?.remove(),this.toolBorderContainer?.remove(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){if(this.draw.getMode()===l.EditorMode.FORM){this.dispose();return}const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.position.getPositionContext();if(!t)return;this.dispose();const r=this.draw.getOriginalElementList(),s=this.position.getOriginalPositionList(),a=r[e];if(a.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:c,table:{overflow:d}}=this.options,R=s[e],{colgroup:u,trList:h}=a,{coordinate:{leftTop:g}}=R,f=this.draw.getHeight(),T=this.draw.getPageGap(),p=this.draw.getPageNo()*(f+T),m=g[0],I=g[1]+p,L=a.trList[n].tdList[i],P=L.rowIndex,O=L.colIndex,S=a.height*c,F=a.width*c,N=document.createElement("div");N.classList.add(`${z}-table-tool__select`),N.style.height=`${S*c}`,N.style.left=`${m}px`,N.style.top=`${I}px`,N.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,N.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(N),this.toolTableSelectBtn=N;const V=h.map(y=>y.height),Y=document.createElement("div");Y.classList.add(`${z}-table-tool__row`),Y.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let y=0;y<V.length;y++){const W=V[y]*c,D=document.createElement("div");D.classList.add(`${z}-table-tool__row__item`),y===P&&D.classList.add("active"),D.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByRowIndex(h,y),G=Q[0],H=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:G.trIndex,tdIndex:G.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,G.tdIndex,H.tdIndex,G.trIndex,H.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(Y,y)};const U=document.createElement("div");U.classList.add(`${z}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:y,order:Te.ROW})},D.append(U),D.style.height=`${W}px`,Y.append(D)}Y.style.left=`${m}px`,Y.style.top=`${I}px`,this.container.append(Y),this.toolRowContainer=Y;const X=document.createElement("div");X.classList.add(`${z}-table-tool__quick__add`),X.style.height=`${S*c}`,X.style.left=`${m}px`,X.style.top=`${I+S}px`,X.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,X.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(X),this.toolRowAddBtn=X;const b=u.map(y=>y.width),E=document.createElement("div");E.classList.add(`${z}-table-tool__col`),E.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let y=0;y<b.length;y++){const W=b[y]*c,D=document.createElement("div");D.classList.add(`${z}-table-tool__col__item`),y===O&&D.classList.add("active"),D.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByColIndex(h,y),G=Q[0],H=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:G.trIndex,tdIndex:G.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,G.tdIndex,H.tdIndex,G.trIndex,H.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(E,y)};const U=document.createElement("div");U.classList.add(`${z}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:y,order:Te.COL})},D.append(U),D.style.width=`${W}px`,E.append(D)}E.style.left=`${m}px`,E.style.top=`${I}px`,this.container.append(E),this.toolColContainer=E;const C=document.createElement("div");C.classList.add(`${z}-table-tool__quick__add`),C.style.height=`${S*c}`,C.style.left=`${m+F}px`,C.style.top=`${I}px`,C.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,C.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(C),this.toolColAddBtn=C;const M=document.createElement("div");M.classList.add(`${z}-table-tool__border`),M.style.height=`${S}px`,M.style.width=`${F}px`,M.style.left=`${m}px`,M.style.top=`${I}px`;for(let y=0;y<h.length;y++){const W=h[y];for(let D=0;D<W.tdList.length;D++){const U=W.tdList[D],Q=document.createElement("div");Q.classList.add(`${z}-table-tool__border__row`),Q.style.width=`${U.width*c}px`,Q.style.height=`${this.BORDER_VALUE}px`,Q.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,Q.style.left=`${U.x*c}px`,Q.onmousedown=H=>{this._mousedown({evt:H,element:a,index:U.rowIndex+U.rowspan-1,order:Te.ROW})},M.appendChild(Q);const G=document.createElement("div");if(G.classList.add(`${z}-table-tool__border__col`),G.style.width=`${this.BORDER_VALUE}px`,G.style.height=`${U.height*c}px`,G.style.top=`${U.y*c}px`,G.style.left=`${(U.x+U.width)*c-this.BORDER_VALUE/2}px`,G.onmousedown=H=>{this._mousedown({evt:H,element:a,index:U.colIndex+U.colspan-1,order:Te.COL})},M.appendChild(G),d&&U.colIndex===0){const H=document.createElement("div");H.classList.add(`${z}-table-tool__border__col`),H.style.width=`${this.BORDER_VALUE}px`,H.style.height=`${U.height*c}px`,H.style.top=`${U.y*c}px`,H.style.left=`${U.x*c-this.BORDER_VALUE/2}px`,H.onmousedown=j=>{this._mousedown({evt:j,element:a,index:0,isLeftStartBorder:!0,order:Te.COL})},M.appendChild(H)}}}this.container.append(M),this.toolBorderContainer=M}_setAnchorActive(t,e){const n=t.children;for(let i=0;i<n.length;i++){const r=n[i];i===e?r.classList.add("active"):r.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:i,element:r,isLeftStartBorder:s}=t;this.canvas=this.draw.getPage();const{scale:a,table:{overflow:c}}=this.options,d=this.draw.getWidth(),R=this.draw.getHeight(),u=this.draw.getPageGap(),h=this.draw.getPageNo()*(R+u),g=this.position.getPositionContext(),p=(this.position.getOriginalPositionList()[g.index]?.coordinate?.leftTop?.[0]||0)*a,m=this.draw.getMargins(),I=m[0],L=m[1],P=I,O=d-L;this.mousedownX=e.x,this.mousedownY=e.y;const S=e.target,F=this.canvas.getBoundingClientRect(),N=window.getComputedStyle(S).cursor;document.body.style.cursor=N,this.canvas.style.cursor=N;let V=0,Y=0;const X=document.createElement("div");X.classList.add(`${z}-table-anchor__line`),i===Te.ROW?(X.classList.add(`${z}-table-anchor__line__row`),X.style.width=`${d}px`,V=0,Y=h+this.mousedownY-F.top):(X.classList.add(`${z}-table-anchor__line__col`),X.style.height=`${R}px`,V=this.mousedownX-F.left,Y=h),X.style.left=`${V}px`,X.style.top=`${Y}px`,this.container.append(X),this.anchorLine=X;let b=0,E=0;const C=M=>{const y=this._mousemove(M,i,V,Y);y&&(b=y.dx,E=y.dy)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",()=>{let M=!1;if(i===Te.ROW){const y=r.trList,W=y[n]||y[n-1],{defaultTrMinHeight:D}=this.options.table;E<0&&W.height+E<D&&(E=D-W.height),E&&(W.height+=E,W.minHeight=W.height,M=!0)}else{const{colgroup:y}=r;if(y&&b)if(c&&s){y[n].width-b/a<=this.MIN_TD_WIDTH&&(b=(y[n].width-this.MIN_TD_WIDTH)*a);const W=p+(r.translateX||0)*a;W+b<P&&(b=P-W),y[n].width-=b/a,r.width-=b/a,r.translateX=(r.translateX||0)+b/a,M=!0}else{const W=y[n].width;b<0&&W*a+b<this.MIN_TD_WIDTH*a&&(b=this.MIN_TD_WIDTH*a-W*a);const D=y[n+1]?.width;if(b>0&&D&&D*a-b<this.MIN_TD_WIDTH*a&&(b=D*a-this.MIN_TD_WIDTH*a),n===y.length-1){const Q=p+(r.translateX||0)*a+r.width*a;Q+b>O&&(b=O-Q)}b&&(y.length-1!==n&&(y[n+1].width-=b/a),y[n].width+=b/a,M=!0)}}M&&this.draw.render({isSetCursor:!1}),X.remove(),document.removeEventListener("mousemove",C),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const r=t.x-this.mousedownX,s=t.y-this.mousedownY;return e===Te.ROW?this.anchorLine.style.top=`${i+s}px`:this.anchorLine.style.left=`${n+r}px`,t.preventDefault(),{dx:r,dy:s}}}class oc{draw;options;container;hyperlinkPopupContainer;hyperlinkDom;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${z}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:r}=e,s=this.draw.getHeight(),a=this.draw.getPageGap(),c=this.draw.getPageNo()*(s+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+c+r}px`;const d=t.url||"#";this.hyperlinkDom.href=d,this.hyperlinkDom.title=d,this.hyperlinkDom.innerText=d}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class ic{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:r,label:{defaultBackgroundColor:s,defaultColor:a,defaultBorderRadius:c,defaultPadding:d}}=this.options,R=e.label?.backgroundColor||s,u=e.label?.color||a,h=e.label?.borderRadius||c,g=e.label?.padding||d;t.save(),t.font=e.style;const{width:f,height:T,boundingBoxAscent:p}=e.metrics;t.fillStyle=R,this._drawRoundedRect(t,n,i-p,f,T+(g[0]+g[3])*r,h*r),t.fill(),t.fillStyle=u,t.fillText(e.value,n+g[3]*r,i),t.restore()}_drawRoundedRect(t,e,n,i,r,s){t.beginPath(),t.moveTo(e+s,n),t.lineTo(e+i-s,n),t.quadraticCurveTo(e+i,n,e+i,n+s),t.lineTo(e+i,n+r-s),t.quadraticCurveTo(e+i,n+r,e+i-s,n+r),t.lineTo(e+s,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s),t.lineTo(e,n+s),t.quadraticCurveTo(e,n,e+s,n),t.closePath()}}class sc{options;draw;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e,n,i){const r=this.draw.getMode(),s=e.macroConfig;if(e.type==="subTemplate"&&console.log("MacroParticle.render - 子模板元素:",e.type,"当前模式:",r,"label:",e.label),r===l.EditorMode.EDIT){const c=e.label||e.value||"";this._renderEditMode(t,e,n,i,c);return}if(e.type==="macro"){const c=e.label||"",d=e.value||`获取 ${c}`;this._renderPlainText(t,e,n,i,d);return}if(e.type==="customMacro"){const c=s?.type||"text",d=s?.value||"",R=e.label||"";if(r===l.EditorMode.FORM)c==="select"?this._renderSelectControl(t,e,n,i,d):this._renderTextControl(t,e,n,i,d);else{const u=d||`获取 ${R}`;this._renderPlainText(t,e,n,i,u)}return}if(e.type==="reusableItem"){const d=e.reusableItemConfig?.value||"",R=e.label||"";if(r===l.EditorMode.FORM)this._renderTextControl(t,e,n,i,d);else{const u=d||`获取 ${R}`;this._renderPlainText(t,e,n,i,u)}return}if(e.type==="subTemplate"){const c=e.label||"子模板";r===l.EditorMode.FORM?e.subTemplateExpanded||this._renderSubTemplateTag(t,e,n,i,c):this._renderPlainText(t,e,n,i,c);return}const a=e.value||e.label||"";this._renderPlainText(t,e,n,i,a)}_renderPlainText(t,e,n,i,r){t.save(),t.font=e.style,t.fillStyle=e.color||"#000000",t.textBaseline="alphabetic",t.fillText(r,n,i),t.restore()}_renderSubTemplateTag(t,e,n,i,r){const{scale:s}=this.options,a="#722ed1",c="#f9f0ff";t.save(),t.font=e.style;const d=t.measureText(r),R=d.actualBoundingBoxAscent+d.actualBoundingBoxDescent,u=8*s,h=4*s,g=4*s,f=d.width+u*2,T=R+h*2,p=e.metrics,m=n,I=i-p.boundingBoxAscent+(p.boundingBoxAscent+p.boundingBoxDescent-T)/2;t.fillStyle=c,this._drawRoundedRect(t,m,I,f,T,g),t.fill(),t.strokeStyle=a,t.lineWidth=1*s,t.setLineDash([4*s,2*s]),this._drawRoundedRect(t,m,I,f,T,g),t.stroke(),t.fillStyle=a,t.textBaseline="middle",t.fillText(r,n+u,I+T/2),t.restore()}_renderEditMode(t,e,n,i,r){const{scale:s}=this.options,a=e.type==="customMacro",c=e.type==="reusableItem",d=e.type==="subTemplate";let R,u;d?(R="#722ed1",u="#f9f0ff"):c?(R="#52c41a",u="#f6ffed"):a?(R="#fa8c16",u="#fff7e6"):(R="#1677ff",u="#e6f4ff"),t.save(),t.font=e.style;const h=t.measureText(r),g=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent,f=8*s,T=4*s,p=4*s,m=h.width+f*2,I=g+T*2,L=e.metrics,P=n,O=i-L.boundingBoxAscent+(L.boundingBoxAscent+L.boundingBoxDescent-I)/2;t.fillStyle=u,this._drawRoundedRect(t,P,O,m,I,p),t.fill(),t.fillStyle=R,t.textBaseline="middle",t.fillText(r,n+f,O+I/2),t.restore()}_renderTextControl(t,e,n,i,r){const{scale:s,control:a,strikeoutColor:c}=this.options,{placeholderColor:d,bracketColor:R}=a;t.save(),t.font=e.style;const h=`请输入${e.label||""}`,g=r||h,T=t.measureText(g).width;t.fillStyle=R,t.textBaseline="alphabetic",t.fillText("[",n,i);const p=n+t.measureText("[").width;t.fillStyle=r?e.color||"#000000":d,t.fillText(g,p,i);const m=p+T;if(t.fillStyle=R,t.fillText("]",m,i),e.type==="reusableItem"){const I=t.measureText("[").width+T+t.measureText("]").width;if(t.lineWidth=s,this.draw.getMode()===l.EditorMode.PRINT?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const L=i-3*s,P=i+3.5*s;t.beginPath(),t.moveTo(n,L),t.lineTo(n+I,L),t.stroke(),t.beginPath(),t.moveTo(n,P),t.lineTo(n+I,P),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const L=Math.floor(i+2*s)+.5,P=3*s;t.beginPath(),t.moveTo(n,L),t.lineTo(n+I,L),t.stroke(),t.beginPath(),t.moveTo(n,L+P),t.lineTo(n+I,L+P),t.stroke()}}t.restore()}_renderSelectControl(t,e,n,i,r){const{scale:s,control:a}=this.options,{placeholderColor:c,bracketColor:d}=a;t.save(),t.font=e.style;const u=`请选择${e.label||""}`,h=r||u,g=t.measureText(h),f=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent;t.fillStyle=d,t.textBaseline="alphabetic",t.fillText("[",n,i);const T=n+t.measureText("[").width;t.fillStyle=r?e.color||"#000000":c,t.fillText(h,T,i);const p=T+g.width+2*s,m=i-f/2;t.beginPath(),t.moveTo(p,m-2*s),t.lineTo(p+5*s,m-2*s),t.lineTo(p+2.5*s,m+2*s),t.closePath(),t.fillStyle="#666666",t.fill();const I=p+6*s;t.fillStyle=d,t.fillText("]",I,i),t.restore()}_drawRoundedRect(t,e,n,i,r,s){t.beginPath(),t.moveTo(e+s,n),t.lineTo(e+i-s,n),t.quadraticCurveTo(e+i,n,e+i,n+s),t.lineTo(e+i,n+r-s),t.quadraticCurveTo(e+i,n+r,e+i-s,n+r),t.lineTo(e+s,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s),t.lineTo(e,n+s),t.quadraticCurveTo(e,n,e+s,n),t.closePath()}}class rc{draw;position;zone;options;elementList;rowList;positionList;constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=wo(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:n})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],r=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:r,innerWidth:e,zone:l.EditorZone.HEADER})}getHeaderTop(){const{header:{top:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*yi[t])}getHeight(){if(this.options.header.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getHeaderTop()+e-t[0];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let s=0;for(let a=0;a<this.rowList.length;a++){const c=this.rowList[a];if(s+c.height>i)break;r.push(c),s+=c.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:l.EditorZone.HEADER}),t.restore()}}class lc{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class ac{getOffsetY(t){return t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class cc{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){t.save();const{scale:r,separator:{lineWidth:s,strokeStyle:a}}=this.options;t.lineWidth=(e.lineWidth||s)*r,t.strokeStyle=e.color||a,e.dashArray?.length&&t.setLineDash(e.dashArray);const c=Math.round(i);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,c),t.lineTo(n+e.width*r,c),t.stroke(),t.restore()}}class dc{draw;options;i18n;constructor(t){this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,i){const{pageBreak:{font:r,fontSize:s,lineDash:a}}=this.options,c=this.i18n.t("pageBreak.displayName"),{scale:d,defaultRowMargin:R}=this.options,u=s*d,h=e.width*d,g=this.draw.getDefaultBasicRowMarginHeight()*R;t.save(),t.font=`${u}px ${r}`;const f=t.measureText(c),T=(h-f.width)/2;t.setLineDash(a),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+T,i),t.moveTo(n+T+f.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(c,n+T,i+f.actualBoundingBoxAscent-u/2),t.restore()}}class Rc{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:i,font:r,size:s,color:a,repeat:c,gap:d,numberType:R},scale:u}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${s*u}px ${r}`;let f=n;const T=new RegExp(pn.PAGE_NO);T.test(f)&&(f=sn.formatNumberPlaceholder(f,e+1,T,R));const p=new RegExp(pn.PAGE_COUNT);p.test(f)&&(f=sn.formatNumberPlaceholder(f,this.draw.getPageCount(),p,R));const m=t.measureText(f);if(c){const I=this.draw.getPagePixelRatio(),L=document.createElement("canvas"),P=L.getContext("2d"),O=m.width,S=m.actualBoundingBoxAscent+m.actualBoundingBoxDescent,F=Math.sqrt(Math.pow(O,2)+Math.pow(S,2)),N=F+2*d[0]*u,V=F+2*d[1]*u;L.width=N,L.height=V,L.style.width=`${N*I}px`,L.style.height=`${V*I}px`,P.translate(N/2,V/2),P.rotate(-45*Math.PI/180),P.translate(-N/2,-V/2),P.font=`${s*u}px ${r}`,P.fillStyle=a,P.fillText(f,(N-O)/2,(V-S)/2+m.actualBoundingBoxAscent);const Y=t.createPattern(L,"repeat");Y&&(t.fillStyle=Y,t.fillRect(0,0,h,g))}else{const I=h/2,L=g/2;t.fillStyle=a,t.translate(I,L),t.rotate(-45*Math.PI/180),t.fillText(f,-m.width/2,m.actualBoundingBoxAscent-s*u/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:i,opacity:r,repeat:s,gap:a},scale:c}=this.options;if(!this.imageCache.has(i)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const d=this.draw.getWidth(),R=this.draw.getHeight(),u=e*c,h=n*c;if(t.save(),t.globalAlpha=r,s){const g=this.draw.getPagePixelRatio(),f=document.createElement("canvas"),T=f.getContext("2d"),p=Math.sqrt(Math.pow(u,2)+Math.pow(h,2)),m=p+2*a[0]*c,I=p+2*a[1]*c;f.width=m,f.height=I,f.style.width=`${m*g}px`,f.style.height=`${I*g}px`,T.translate(m/2,I/2),T.rotate(-45*Math.PI/180),T.translate(-m/2,-I/2),T.drawImage(this.imageCache.get(i),(m-u)/2,(I-h)/2,u,h);const L=t.createPattern(f,"repeat");L&&(t.fillStyle=L,t.fillRect(0,0,d,R))}else{const g=d/2,f=R/2;t.translate(g,f),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-u/2,-h/2,u,h)}t.restore()}render(t,e){this.options.watermark.type===l.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class uc{draw;control;options;highlightList;highlightMatchResult;constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:r,noValueBackgroundColor:s}}=this.options,a=t[e],c=this.draw.isPrintMode(),d=this.control.getActiveControl()?.getElement();let R=!1,u=!1,h=!1,g=!1;return a.highlight||(R=!c&&!!n&&!!d&&a.controlId===d.controlId&&!this.control.getIsRangeInPostfix()),R||(u=!c&&!!i&&!!a.control?.disabled),u||(h=!c&&!!r&&!!a.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),h||(g=!c&&!!s&&!!a.controlId&&!this.control.getIsExistValueByElementListIndex(t,e)),(R?n:"")||(u?i:"")||(h?r:"")||(g?s:"")}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,i)=>{let r=0;for(;r<n.length;){const s=n[r];if(r++,s.type===l.ElementType.TABLE){const f=s.trList;for(let T=0;T<f.length;T++){const p=f[T];for(let m=0;m<p.tdList.length;m++){const I=p.tdList[m],L={tableId:s.id,tableIndex:r-1,trIndex:T,tdIndex:m,tdId:I.id};e(I.value,L)}}}const a=s?.control;if(!a)continue;const c=this.highlightList.findIndex(f=>f.id===s.controlId||a.conceptId&&a.conceptId===f.conceptId);if(!~c)continue;const d=r;let R=r;for(;R<n.length&&n[R].controlId===s.controlId;)R++;r=R;const u=n.slice(d,R).map(f=>f.controlComponent===l.ControlComponent.VALUE?f:{value:_}),h=this.highlightList[c],{ruleList:g}=h;for(let f=0;f<g.length;f++){const T=g[f],p=t.getMatchList(T.keyword,u);this.highlightMatchResult.push(...p.map(m=>({...m,...T,...i,index:m.index+d})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){if(!this.highlightMatchResult?.length)return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,r=this.draw.getPosition().getOriginalPositionList(),s=this.draw.getOriginalElementList();t.save();for(let a=0;a<this.highlightMatchResult.length;a++){const c=this.highlightMatchResult[a];let d=null;if(c.tableId){const{tableIndex:I,trIndex:L,tdIndex:P,index:O}=c;d=s[I]?.trList[L].tdList[P]?.positionList[O]}else d=r[c.index];if(!d)continue;const{coordinate:{leftTop:R,leftBottom:u,rightTop:h},pageNo:g}=d;if(g!==e)continue;t.fillStyle=c.backgroundColor||i,t.globalAlpha=c.alpha||n;const f=R[0],T=R[1],p=h[0]-R[0],m=u[1]-R[1];t.fillRect(f,T,p,m)}t.restore()}}class hc{borderRect;options;constructor(t){this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,i){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=i),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:i}}=this.options,{x:r,y:s,width:a,height:c}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=i,t.beginPath(),t.rect(r,s,a,c),t.stroke(),t.restore(),this.clearBorderInfo()}}class In{draw;element;control;isPopup;selectDom;options;VALUE_DELIMITER=",";DEFAULT_MULTI_SELECT_DELIMITER=",";constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.selectDom=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getCodes(){return this.element?.control?.code?this.element.control.code.split(","):[]}getText(t){if(!this.element?.control)return null;const e=this.element.control;if(!e.valueSets?.length)return null;const n=e?.multiSelectDelimiter||this.DEFAULT_MULTI_SELECT_DELIMITER,i=e.valueSets,r=[];return t.forEach(s=>{const a=i.find(c=>c.code===s);a&&!Ui(a.value)&&r.push(a.value)}),r.join(n)||null}getValue(t={}){const{elementList:e,range:n}=this.control.mergeControl(t),{startIndex:i}=n,r=e[i],s=[];let a=i;for(;a>=0;){const d=e[a];if(!d||d.controlId!==r.controlId||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT)break;d.controlComponent===l.ControlComponent.VALUE&&s.unshift(d),a--}let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POST_TEXT)break;d.controlComponent===l.ControlComponent.VALUE&&s.push(d),c++}return s}setValue(t,e={},n={}){if(!this.element.control?.selectExclusiveOptions?.inputAble||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...R,...t[h],controlComponent:l.ControlComponent.VALUE};Ut(i,[g],s,{editorOptions:this.options}),c.spliceElementList(i,u+h,0,[g])}return u+t.length-1}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.element.control?.selectExclusiveOptions?.inputAble;if(t.key===l.KeyMap.Backspace)return i!==r?c?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect():s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1):this.clearSelect();if(t.key===l.KeyMap.Delete){if(i!==r)return c?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect();{const d=e[r+1];return(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT)&&d.controlComponent===l.ControlComponent.PLACEHOLDER||d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect()}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=t.elementList||this.control.getElementList(),{startIndex:s}=t.range||this.control.getRange(),a=r[s];let c=-1,d=-1,R=s;for(;R>0;){const g=r[R];if(g.controlId!==a.controlId||g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT){c=R;break}R--}let u=s+1;for(;u<r.length;){const g=r[u];if(g.controlId!==a.controlId||g.controlComponent===l.ControlComponent.POSTFIX||g.controlComponent===l.ControlComponent.POST_TEXT){d=u-1;break}u++}return!~c||!~d?-1:(this.control.getDraw().spliceElementList(r,c+1,d-c,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(R,t),this.control.setControlProperties({code:void 0},{elementList:r,range:{startIndex:R,endIndex:R}}),R)}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),s=this.element.control,a=t?.split(this.VALUE_DELIMITER)||[],c=s.code,d=s.code?.split(this.VALUE_DELIMITER)||[],R=s.isMultiSelect;if(!R&&t===c||R&&Di(d,a)){this.control.repaintControl({curIndex:r.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const u=s.valueSets;if(!Array.isArray(u)||!u.length)return;const h=this.getText(a);if(!h){if(c){const P=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~P&&(this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],f=g?Dt(g,Re):Dt(i[r.startIndex],Gt),T=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~T)return;c||this.control.removePlaceholder(T,e);const p=ie(i[T],Re),m=T+1,I=ct(h),L=this.control.getDraw();for(let P=0;P<I.length;P++){const O={...f,...p,type:l.ElementType.TEXT,value:I[P],controlComponent:l.ControlComponent.VALUE};(O.color===this.options.control.bracketColor||O.color===this.options.control.placeholderColor)&&(O.color=this.options.defaultColor),Ut(i,[O],T,{editorOptions:this.options}),L.spliceElementList(i,m+P,0,[O])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:T,endIndex:T}}),!e.range){const P=m+I.length-1;this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({context:e}),R||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${z}-select-control-popup`),i.setAttribute(de,l.EditorComponent.POPUP);const r=document.createElement("ul");let s=null;for(let h=0;h<e.length;h++){const g=e[h],f=document.createElement("li");let T=this.getCodes();T.includes(g.code)&&(f.classList.add("active"),s=f),f.onclick=()=>{const p=T.findIndex(m=>m===g.code);t.isMultiSelect?~p?T.splice(p,1):T.push(g.code):~p?T=[]:T=[g.code],this.setSelect(T.join(this.VALUE_DELIMITER))},f.append(document.createTextNode(g.value)),r.append(f)}i.append(r);const{coordinate:{leftTop:[a,c]},lineHeight:d}=n,R=this.control.getPreY();i.style.left=`${a}px`,i.style.top=`${c+R+d}px`,this.control.getContainer().append(i),this.selectDom=i,s&&Zi(i,s)}awake(){if(this.isPopup||this.control.getIsDisabledControl())return;const{startIndex:t}=this.control.getRange(),n=this.control.getElementList()[t];if(!n||n.controlId!==this.element.controlId)return;const i=n.controlComponent===l.ControlComponent.PREFIX||n.controlComponent===l.ControlComponent.PRE_TEXT||n.controlComponent===l.ControlComponent.POSTFIX||n.controlComponent===l.ControlComponent.POST_TEXT||n.controlComponent===l.ControlComponent.PLACEHOLDER;!this.control.getIsRangeWithinControl()&&!i||(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){this.isPopup&&(this.selectDom?.remove(),this.isPopup=!1)}}var hs;function q(){return hs.apply(null,arguments)}function gc(o){hs=o}function se(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function _e(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Mt(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Go(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Mt(o,t))return!1;return!0}function kt(o){return o===void 0}function Me(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function Pn(o){return o instanceof Date||Object.prototype.toString.call(o)==="[object Date]"}function gs(o,t){var e=[],n,i=o.length;for(n=0;n<i;++n)e.push(t(o[n],n));return e}function Ue(o,t){for(var e in t)Mt(t,e)&&(o[e]=t[e]);return Mt(t,"toString")&&(o.toString=t.toString),Mt(t,"valueOf")&&(o.valueOf=t.valueOf),o}function me(o,t,e,n){return Ks(o,t,e,n,!0).utc()}function fc(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function Rt(o){return o._pf==null&&(o._pf=fc()),o._pf}var Ao;Array.prototype.some?Ao=Array.prototype.some:Ao=function(o){var t=Object(this),e=t.length>>>0,n;for(n=0;n<e;n++)if(n in t&&o.call(this,t[n],n,t))return!0;return!1};function ko(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Rt(o),e=Ao.call(t.parsedDateParts,function(i){return i!=null}),n=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&e),o._strict&&(n=n&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(o))o._isValid=n;else return n;return o._isValid}function Gn(o){var t=me(NaN);return o!=null?Ue(Rt(t),o):Rt(t).userInvalidated=!0,t}var fs=q.momentProperties=[],Jo=!1;function Bo(o,t){var e,n,i,r=fs.length;if(kt(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),kt(t._i)||(o._i=t._i),kt(t._f)||(o._f=t._f),kt(t._l)||(o._l=t._l),kt(t._strict)||(o._strict=t._strict),kt(t._tzm)||(o._tzm=t._tzm),kt(t._isUTC)||(o._isUTC=t._isUTC),kt(t._offset)||(o._offset=t._offset),kt(t._pf)||(o._pf=Rt(t)),kt(t._locale)||(o._locale=t._locale),r>0)for(e=0;e<r;e++)n=fs[e],i=t[n],kt(i)||(o[n]=i);return o}function Mn(o){Bo(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),Jo===!1&&(Jo=!0,q.updateOffset(this),Jo=!1)}function re(o){return o instanceof Mn||o!=null&&o._isAMomentObject!=null}function Ts(o){q.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function te(o,t){var e=!0;return Ue(function(){if(q.deprecationHandler!=null&&q.deprecationHandler(null,o),e){var n=[],i,r,s,a=arguments.length;for(r=0;r<a;r++){if(i="",typeof arguments[r]=="object"){i+=`
|
|
102
|
-
[`+r+"] ";for(s in arguments[0])
|
|
98
|
+
`)}}return n}return t(Mt(o))}function Uo(o){return Lo(o,["metrics","style"])}function nn(o){return!!o?.type&&(ll.includes(o.type)||o.imgDisplay===l.ImageDisplay.INLINE)}function zl(o,t){const e=document.createElement(t);for(let n=0;n<o.attributes.length;n++){const i=o.attributes[n];e.setAttribute(i.name,i.value)}return e.innerHTML=o.innerHTML,e}function wo(o){const t=[];for(let e=0;e<o.length;e++){const n=o[e];n?.imgDisplay===l.ImageDisplay.SURROUND&&t.push(n)}return t}function jl(o,t){for(let e=o.length-1;e>=0;e--)o[e].imgFloatPosition?.pageNo===t&&o.splice(e,1)}function Ln(o,t,e=l.LocationPosition.BEFORE){if(!o[t]?.hide&&!o[t]?.control?.hide&&!o[t]?.area?.hide)return t;let n=t;if(e===l.LocationPosition.BEFORE)for(n=t-1;n>0;){if(!o[n]?.hide&&!o[n]?.control?.hide&&!o[n]?.area?.hide)return n;n--}else for(n=t+1;n<o.length;){if(!o[n]?.hide&&!o[n]?.control?.hide&&!o[n]?.area?.hide)return n;n++}return n}const ji=`${Tn}-control`;function ql(o){localStorage.setItem(Tn,JSON.stringify({text:o.text,elementList:o.elementList}))}function qi(){const o=localStorage.getItem(Tn);return o?JSON.parse(o):null}function ts(){localStorage.removeItem(Tn)}function ta(o){localStorage.setItem(ji,JSON.stringify(o))}function es(){const o=localStorage.getItem(ji);return o?JSON.parse(o):null}function ea(){return!!es()?.element}async function na(o,t,e){if(!o&&!t&&!e.length)return;const n=new Blob([o],{type:"text/plain"}),i=new Blob([t],{type:"text/html"});if(window.ClipboardItem){const r=new ClipboardItem({[n.type]:n,[i.type]:i});await window.navigator.clipboard.write([r])}else{const r=document.createElement("div");r.setAttribute("contenteditable","true"),r.innerHTML=t,document.body.append(r);const s=window.getSelection(),a=document.createRange(),c=document.createElement("span");c.innerText=`
|
|
99
|
+
`,r.append(c),a.selectNodeContents(r),s?.removeAllRanges(),s?.addRange(a),document.execCommand("copy"),r.remove()}ql({text:o,elementList:e})}async function ns(o,t){const e=qe(o,t);document.body.append(e);const n=e.innerText;e.remove();const i=e.innerHTML;!n&&!i&&!o.length||await na(n,i,Mt(o))}function oa(o){let t=!1;for(let e=0;e<o.items.length;e++)if(o.items[e].kind==="file"){t=!0;break}return t}function Zo(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled()||e.getControl().getIsDisabledPasteControl())return;const n=e.getRange(),{startIndex:i}=n.getRange(),r=e.getElementList();if(~i&&!n.getIsSelectAll()){const s=r[i];if(s?.titleId||s?.listId){let a=0;for(;a<t.length;){const c=t[a];if(s.titleId&&/^\n/.test(c.value))break;if(cl.includes(c.type)){if(t.splice(a,1),c.valueList)for(let d=0;d<c.valueList.length;d++){const R=c.valueList[d];R.value===_||R.value===`
|
|
100
|
+
`||(t.splice(a,0,R),a++)}a--}a++}}Ut(r,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function os(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=tn(t,{innerWidth:e.getOriginalInnerWidth()});Zo(o,n)}function Qo(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=e.getRange(),{startIndex:i}=n.getRange(),r=e.getElementList(),s=new FileReader;s.readAsDataURL(t),s.onload=()=>{const a=new Image,c=s.result;a.src=c,a.onload=()=>{const d={value:c,type:l.ElementType.IMAGE,width:a.width,height:a.height};~i&&Ut(r,[d],i,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function ia(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:i}=e.getOverride();if(i&&i(t)?.preventDefault!==!1)return;if(!oa(n)){const s=n.getData("text"),a=qi();if(a&&Un(s)===Un(a.text)){Zo(o,a.elementList);return}}ts();let r=!1;for(let s=0;s<n.items.length;s++)if(n.items[s].type==="text/html"){r=!0;break}for(let s=0;s<n.items.length;s++){const a=n.items[s];if(a.kind==="string"){if(a.type==="text/plain"&&!r){a.getAsString(c=>{o.input(c)});break}if(a.type==="text/html"&&r){a.getAsString(c=>{os(o,c)});break}}else if(a.kind==="file"&&a.type.includes("image")){const c=a.getAsFile();c&&Qo(o,c)}}}async function sa(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=await navigator.clipboard.readText(),r=qi();if(r&&Un(i)===Un(r.text)){Zo(o,r.elementList);return}if(ts(),t?.isPlainText)i&&o.input(i);else{const s=await navigator.clipboard.read();let a=!1;for(const c of s)if(c.types.includes("text/html")){a=!0;break}for(const c of s)if(c.types.includes("text/plain")&&!a){const R=await(await c.getType("text/plain")).text();R&&o.input(R)}else if(c.types.includes("text/html")&&a){const R=await(await c.getType("text/html")).text();R&&os(o,R)}else if(c.types.some(d=>d.startsWith("image/"))){const d=c.types.find(u=>u.startsWith("image/")),R=await c.getType(d);Qo(o,R)}}}class ra{draw;container;agentCursorDom;canvasEvent;eventBus;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.canvasEvent=e,this.eventBus=t.getEventBus();const n=document.createElement("textarea");n.autocomplete="off",n.classList.add(`${z}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=i=>this._keyDown(i),n.oninput=this._input.bind(this),n.onpaste=i=>this._paste(i),n.addEventListener("compositionstart",this._compositionstart.bind(this)),n.addEventListener("compositionupdate",this._compositionupdate.bind(this)),n.addEventListener("compositionend",this._compositionend.bind(this)),n.addEventListener("keydown",this._keydown.bind(this)),this.eventBus.on("rangeStyleChange",i=>{this.agentCursorDom.style.fontSize=Math.max(i.size,18)+"px"})}getAgentCursorDom(){return this.agentCursorDom}_keyDown(t){this.draw.isInteractionSuspended()||this.canvasEvent.keydown(t)}_input(t){if(this.draw.isInteractionSuspended())return;const e=t.data;e&&this.canvasEvent.input(e),this.eventBus.isSubscribe("input")&&this.eventBus.emit("input",t)}_paste(t){this.draw.isInteractionSuspended()||this.draw.isReadonly()||!t.clipboardData||(ia(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="1000",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="#000",this.agentCursorDom.style.background="#fff",this.canvasEvent.compositionstart())}_compositionupdate(){if(this.draw.isInteractionSuspended())return;this.agentCursorDom.style.width="9999px";let t=this.agentCursorDom.scrollWidth;const e=this.container.clientWidth,n=Math.max(e-this.agentCursorDom.offsetLeft,100);t>n&&(t=n),this.agentCursorDom.style.width=t+"px"}_compositionend(t){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="-1",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="",this.agentCursorDom.style.background="",this.canvasEvent.compositionend(t))}_keydown(t){this.draw.isInteractionSuspended()||this.canvasEvent.isComposing&&t.code==="Escape"&&this.canvasEvent.compositionCancel()}}class la{ANIMATION_CLASS=`${z}-cursor--animation`;draw;container;options;position;cursorDom;cursorAgent;blinkTimeout;hitLineStartIndex;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${z}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new ra(t,e),this.blinkTimeout=null}getCursorDom(){return this.cursorDom}getAgentDom(){return this.cursorAgent.getAgentCursorDom()}getAgentIsActive(){return this.getAgentDom()===document.activeElement}getAgentDomValue(){return this.getAgentDom().value}clearAgentDomValue(){this.getAgentDom().value=""}getHitLineStartIndex(){return this.hitLineStartIndex}_blinkStart(){this.cursorDom.classList.add(this.ANIMATION_CLASS)}_blinkStop(){this.cursorDom.classList.remove(this.ANIMATION_CLASS)}_setBlinkTimeout(){this._clearBlinkTimeout(),this.blinkTimeout=window.setTimeout(()=>{this._blinkStart()},500)}_clearBlinkTimeout(){this.blinkTimeout&&(this._blinkStop(),window.clearTimeout(this.blinkTimeout),this.blinkTimeout=null)}focus(){if(el&&this.draw.isReadonly())return;const t=this.cursorAgent.getAgentCursorDom();document.activeElement!==t&&(t.focus(),t.setSelectionRange(0,0))}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:n,cursor:i}=this.options,{color:r,width:s,isShow:a=!0,isBlink:c=!0,isFocus:d=!0,hitLineStartIndex:R}={...i,...t},u=this.draw.getHeight(),h=this.draw.getPageGap();this.hitLineStartIndex=R,R&&(e=this.position.getPositionList()[R]);const{metrics:g,coordinate:{leftTop:f,rightTop:T},ascent:p,pageNo:m}=e,P=(this.draw.getZone().isMainActive()?m:this.draw.getPageNo())*(u+h),O=jr*n,S=Math.min(g.height/4,O),F=g.height+S*2,N=this.cursorAgent.getAgentCursorDom();d&&setTimeout(()=>{this.focus()});const V=g.boundingBoxDescent<0?0:g.boundingBoxDescent,Y=f[1]+p+V-(F-S)+P,X=R?f[0]:T[0];if(N.style.left=`${X}px`,N.style.top=`${Y+F-O}px`,!a){this.recoveryCursor();return}const b=this.cursorDom.style.top,E=this.draw.isReadonly();this.cursorDom.style.width=`${s*n}px`,this.cursorDom.style.backgroundColor=r,this.cursorDom.style.left=`${X}px`,this.cursorDom.style.top=`${Y}px`,this.cursorDom.style.display=E?"none":"block",this.cursorDom.style.height=`${F}px`,c?this._setBlinkTimeout():this._clearBlinkTimeout(),Oo(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(b)>Y?Zt.UP:Zt.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:i,coordinate:{leftTop:r,leftBottom:s}}=e,a=Jr(this.container),c={left:0,right:0,top:0,bottom:0},d=a===document.documentElement;if(d)c.right=window.innerWidth,c.bottom=window.innerHeight;else{const{left:T,right:p,top:m,bottom:I}=a.getBoundingClientRect();c.left=T,c.right=p,c.top=m,c.bottom=I}const R=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,u=n===Zt.UP,h=s[0]+(d?0:c.left),g=u?r[1]+R:s[1]+R,{maskMargin:f}=this.options;if(c.top+=f[0],c.bottom-=f[2],!(h>=c.left&&h<=c.right&&g>=c.top&&g<=c.bottom)){const{scrollLeft:T,scrollTop:p}=a;u?a.scroll(T,p-(c.top-g)):a.scroll(T,p+g-c.bottom)}}}var Kn;(function(o){o[o.LEFT=0]="LEFT",o[o.CENTER=1]="CENTER",o[o.RIGHT=2]="RIGHT"})(Kn||(Kn={}));function fe(o){return ve?o.metaKey:o.ctrlKey}l.KeyMap=void 0,(function(o){o.Delete="Delete",o.Backspace="Backspace",o.Enter="Enter",o.Left="ArrowLeft",o.Right="ArrowRight",o.Up="ArrowUp",o.Down="ArrowDown",o.ESC="Escape",o.TAB="Tab",o.META="Meta",o.LEFT_BRACKET="[",o.RIGHT_BRACKET="]",o.COMMA=",",o.PERIOD=".",o.LEFT_ANGLE_BRACKET="<",o.RIGHT_ANGLE_BRACKET=">",o.EQUAL="=",o.MINUS="-",o.PLUS="+",o.A="a",o.B="b",o.C="c",o.D="d",o.E="e",o.F="f",o.G="g",o.H="h",o.I="i",o.J="j",o.K="k",o.L="l",o.M="m",o.N="n",o.O="o",o.P="p",o.Q="q",o.R="r",o.S="s",o.T="t",o.U="u",o.V="v",o.W="w",o.X="x",o.Y="y",o.Z="z",o.A_UPPERCASE="A",o.B_UPPERCASE="B",o.C_UPPERCASE="C",o.D_UPPERCASE="D",o.E_UPPERCASE="E",o.F_UPPERCASE="F",o.G_UPPERCASE="G",o.H_UPPERCASE="H",o.I_UPPERCASE="I",o.J_UPPERCASE="J",o.K_UPPERCASE="K",o.L_UPPERCASE="L",o.M_UPPERCASE="M",o.N_UPPERCASE="N",o.O_UPPERCASE="O",o.P_UPPERCASE="P",o.Q_UPPERCASE="Q",o.R_UPPERCASE="R",o.S_UPPERCASE="S",o.T_UPPERCASE="T",o.U_UPPERCASE="U",o.V_UPPERCASE="V",o.W_UPPERCASE="W",o.X_UPPERCASE="X",o.Y_UPPERCASE="Y",o.Z_UPPERCASE="Z",o.ZERO="0",o.ONE="1",o.TWO="2",o.THREE="3",o.FOUR="4",o.FIVE="5",o.SIX="6",o.SEVEN="7",o.EIGHT="8",o.NINE="9"})(l.KeyMap||(l.KeyMap={}));class Hn{element;control;constructor(t,e){this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){return this.element.control?.code||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),n=t[e],i=[];let r=e;for(;r>0;){const a=t[r];if(a.controlId!==n.controlId||a.controlComponent===l.ControlComponent.PREFIX||a.controlComponent===l.ControlComponent.PRE_TEXT)break;a.controlComponent===l.ControlComponent.VALUE&&i.unshift(a),r--}let s=e+1;for(;s<t.length;){const a=t[s];if(a.controlId!==n.controlId||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT)break;a.controlComponent===l.ControlComponent.VALUE&&i.push(a),s++}return i}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:s}=e.range||this.control.getRange(),a=r[s];let c=s;for(;c>0;){const R=r[c];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT)break;if(R.controlComponent===l.ControlComponent.CHECKBOX){const u=R.checkbox;u.value=t.includes(u.code)}c--}let d=s+1;for(;d<r.length;){const R=r[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POST_TEXT)break;if(R.controlComponent===l.ControlComponent.CHECKBOX){const u=R.checkbox;u.value=t.includes(u.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:s,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:i}=e;return t.key===l.KeyMap.Backspace||t.key===l.KeyMap.Delete?this.control.removeControl(n):i}cut(){return-1}}class vo extends Hn{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:s}=e.range||this.control.getRange(),a=r[s];let c=s;for(;c>0;){const R=r[c];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT)break;if(R.controlComponent===l.ControlComponent.RADIO){const u=R.radio;u.value=t.includes(u.code)}c--}let d=s+1;for(;d<r.length;){const R=r[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POST_TEXT)break;if(R.controlComponent===l.ControlComponent.RADIO){const u=R.radio;u.value=t.includes(u.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:s,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function is(o){const t=o.getDraw(),e=t.getPosition(),n=t.getRange();o.isAllowDrag=!0,o.cacheRange=at(n.getRange()),o.cacheElementList=t.getElementList(),o.cachePositionList=e.getPositionList(),o.cachePositionContext=e.getPositionContext()}function ss(o,t){const{checkbox:e,control:n}=o;if(!n)t.getCheckboxParticle().setSelect(o);else{const i=n?.code?n.code.split(","):[];if(e?.value){const s=i.findIndex(a=>a===e.code);i.splice(s,1)}else e?.code&&i.push(e.code);const r=t.getControl().getActiveControl();r instanceof Hn&&r.setSelect(i)}}function rs(o,t){const{radio:e,control:n}=o;if(!n)t.getRadioParticle().setSelect(o);else{const i=e?.code?[e.code]:[],r=t.getControl().getActiveControl();r instanceof vo&&r.setSelect(i)}}function aa(o,t){const e=t.getDraw();let n=e.isReadonly();const i=e.getRange(),r=e.getPosition(),s=i.getRange();if(o.button===Kn.RIGHT&&(s.isCrossRowCol||!i.getIsCollapsed()))return;const c=o.target.dataset.index;if(c&&e.setPageNo(Number(c)),!t.isAllowDrag&&!n&&s.startIndex!==s.endIndex&&i.getIsPointInRange(o.offsetX,o.offsetY,e.getPageNo())){is(t);return}t.isAllowSelection=!0;const d=at(r.getPositionContext()),R=r.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!R)return;const{index:u,isDirectHit:h,isCheckbox:g,isRadio:f,isImage:T,isLabel:p,isMacro:m,isTable:I,tdValueIndex:L,hitLineStartIndex:P}=R;h&&m&&console.log("mousedown - positionResult:",{index:u,isDirectHit:h,isMacro:m}),t.mouseDownStartPosition={...R,index:I?L:u,originalIndex:u,x:o.offsetX,y:o.offsetY};const O=e.getElementList(),S=r.getPositionList(),F=I?L:u;let N;I?N=e.getTd().value[L]:N=O[F];const V=!!(h&&T),Y=!!(h&&g),X=!!(h&&f),b=!!(h&&p),E=!!(h&&m),C=tt=>tt&&(tt.type===l.ElementType.MACRO||tt.type===l.ElementType.CUSTOM_MACRO||tt.type===l.ElementType.REUSABLE_ITEM||tt.type===l.ElementType.SUB_TEMPLATE||tt.type===l.ElementType.MENSTRUAL_HISTORY||tt.type===l.ElementType.FETAL_HEART_POSITION||tt.type===l.ElementType.TOOTH_POSITION||tt.type===l.ElementType.LIST||tt.type===l.ElementType.SPECIAL_SYMBOLS),M=tt=>tt&&!!tt.originControlId&&!!tt.controlId,y=tt=>tt&&!!tt.originControlId&&!!tt.controlId&&(tt.controlComponent===l.ControlComponent.POSTFIX||tt.controlComponent===l.ControlComponent.POSTTEXTFIX||tt.controlComponent===l.ControlComponent.POST_TEXT||tt.controlComponent===l.ControlComponent.PLACEHOLDER),W=e.getMode()===l.EditorMode.FORM,D=W?e.getControl().getActiveTextControlLimit():null;let U=F;const Q=!!(D&&(!N?.controlId||N.controlId===D.controlId&&(N.originControlId||null)===D.originControlId||D.parentControlId&&N.controlId===D.parentControlId&&!N.originControlId));if(W&&(N?.controlId||N?.originControlId)){let tt;const ht=N.originControlId||N.controlId;for(let ut=F;ut>=0;ut--){const K=O[ut];if(K.controlId===ht&&!K.originControlId&&K.control?.type){tt=K.control.type;break}if(K.controlId!==N.controlId&&K.controlId!==ht)break}if(tt===l.ControlType.TEXT&&M(N))N.controlComponent===l.ControlComponent.PREFIX||N.controlComponent===l.ControlComponent.PRE_TEXT||N.controlComponent===l.ControlComponent.PRETEXTFIX||N.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT?U=Math.max(F-1,0):(N.controlComponent===l.ControlComponent.POSTFIX||N.controlComponent===l.ControlComponent.POST_TEXT||N.controlComponent===l.ControlComponent.POSTTEXTFIX||N.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&(U=F);else if(tt===l.ControlType.TEXTFIELD){const ut=N.controlComponent;if(!M(N)){if(!(F>0&&y(O[F-1]))){if(!(N.controlComponent===l.ControlComponent.VALUE&&C(N))){if(ut===l.ControlComponent.PRETEXTFIX||ut===l.ControlComponent.PRETEXTFIX_TEXT||ut===l.ControlComponent.POSTTEXTFIX||ut===l.ControlComponent.POSTTEXTFIX_TEXT||ut===l.ControlComponent.TEXTFIXLABEL||ut===l.ControlComponent.PREFIX||ut===l.ControlComponent.POSTFIX||ut===l.ControlComponent.PRE_TEXT||ut===l.ControlComponent.POST_TEXT||ut===l.ControlComponent.PLACEHOLDER)for(let K=F+1;K<O.length;K++){const v=O[K];if(v.controlId!==ht&&v.originControlId!==ht)break;if(v.controlComponent===l.ControlComponent.VALUE&&!C(v)){U=K;break}if(v.controlComponent===l.ControlComponent.POSTTEXTFIX||v.controlComponent===l.ControlComponent.POSTFIX){for(let w=F-1;w>=0;w--){const Z=O[w];if(Z.controlId!==ht&&Z.originControlId!==ht)break;if(Z.controlComponent===l.ControlComponent.VALUE&&!C(Z)){U=w;break}}break}}else if(ut===l.ControlComponent.VALUE&&F>0){const K=O[F-1];if(K&&(K.controlId===ht||K.originControlId===ht)&&K.controlComponent===l.ControlComponent.VALUE&&C(K)){let v=!1;for(let w=F-2;w>=0;w--){const Z=O[w];if(Z.controlId!==ht&&Z.originControlId!==ht||Z.controlComponent!==l.ControlComponent.VALUE&&!Z.originControlId&&Z.controlId===ht)break;if(!C(Z)){U=w+1,v=!0;break}}if(!v)for(let w=F;w<O.length;w++){const Z=O[w];if(Z.controlId!==ht&&Z.originControlId!==ht||(Z.controlComponent===l.ControlComponent.POSTTEXTFIX||Z.controlComponent===l.ControlComponent.POSTFIX)&&!Z.originControlId&&Z.controlId===ht)break;if(!C(Z)){U=w,v=!0;break}}}}}}}}}if(~u){Q&&(U=Math.min(Math.max(U,D.startIndex),D.endIndex));let tt=U,ht=U;if(o.shiftKey){const{startIndex:ut}=i.getRange();~ut&&r.getPositionContext().tdId===d.tdId&&(F>ut?tt=ut:ht=ut)}if(Q&&(tt=Math.min(Math.max(tt,D.startIndex),D.endIndex),ht=Math.min(Math.max(ht,D.startIndex),D.endIndex),U=Math.min(Math.max(U,D.startIndex),D.endIndex)),i.setRange(tt,ht),r.setCursorPosition(S[U]),n=e.isReadonly(),Y&&!n)ss(N,e);else if(X&&!n)rs(N,e);else if(N.controlComponent===l.ControlComponent.VALUE&&(N.control?.type===l.ControlType.CHECKBOX||N.control?.type===l.ControlType.RADIO)){let ut=F;for(;ut>0;){const K=O[ut];if(K.controlComponent===l.ControlComponent.CHECKBOX){ss(K,e);break}else if(K.controlComponent===l.ControlComponent.RADIO){rs(K,e);break}ut--}}else{const ut=N?.control?.type===l.ControlType.BUTTON&&!N.control?.buttonText,K=h&&ut;let v=!1;if(W&&N?.controlId&&N?.controlComponent===l.ControlComponent.VALUE&&!N.originControlId)for(let x=F;x>=0;x--){const A=O[x];if(A.controlId!==N.controlId)break;if(A.control?.type===l.ControlType.TEXTFIELD){v=!0;break}}const w=v&&C(N),Z=E&&!w?U+1:void 0;e.render({curIndex:E&&!w?Z:U,isCompute:!1,isSubmitHistory:!1,isSetCursor:!V&&!Y&&!X&&!(K&&W)&&!w});const J=O[U];if(!n&&h&&J?.controlId&&o.button===Kn.LEFT){const A=e.getControl().getActiveControl(),$=A?.getElement()?.control?.type;A&&($===l.ControlType.NUMBER||$===l.ControlType.SELECT)&&A.getElement()?.controlId===J.controlId&&J.controlComponent!==l.ControlComponent.POSTFIX&&J.controlComponent!==l.ControlComponent.POSTTEXTFIX&&J.controlComponent!==l.ControlComponent.POSTTEXTFIX_TEXT&&J.controlComponent!==l.ControlComponent.POST_TEXT&&typeof A.awake=="function"&&A.awake()}}P&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:P})}const G=e.getEventBus();if(b&&G.isSubscribe("labelMousedown")&&G.emit("labelMousedown",{evt:o,element:N}),E&&(N.type===l.ElementType.MACRO||N.type===l.ElementType.CUSTOM_MACRO||N.type===l.ElementType.REUSABLE_ITEM)){const tt=e.getMode();tt===l.EditorMode.EDIT&&N.type===l.ElementType.CUSTOM_MACRO?G.isSubscribe("macroClick")&&G.emit("macroClick",{evt:o,element:N}):tt===l.EditorMode.FORM&&G.isSubscribe("macroValueChange")&&G.emit("macroValueChange",{evt:o,element:N})}if(console.log("检查子模板点击 - isDirectHitMacro:",E,"curElement.type:",N?.type,"ElementType.SUB_TEMPLATE:",l.ElementType.SUB_TEMPLATE),E&&N.type===l.ElementType.SUB_TEMPLATE){console.log("子模板被点击 - isDirectHitMacro:",E,"curElement.type:",N.type);const tt=e.getMode();console.log("当前模式:",tt,"是否表单模式:",tt===l.EditorMode.FORM),tt===l.EditorMode.FORM&&(console.log("准备触发 subTemplateClick 事件, eventBus:",G),console.log("是否订阅了 subTemplateClick:",G.isSubscribe("subTemplateClick")),G.isSubscribe("subTemplateClick")&&(G.emit("subTemplateClick",{evt:o,element:N}),console.log("subTemplateClick 事件已触发")))}else E&&N.type!==l.ElementType.SUB_TEMPLATE&&console.log("isDirectHitMacro 为 true,但 curElement.type 不是 subTemplate:",N.type);const H=e.getPreviewer();if(H.clearResizer(),V){const tt={dragDisable:n||!N.controlId&&e.getMode()===l.EditorMode.FORM};N.type===l.ElementType.LATEX&&(tt.mime="svg",tt.srcKey="laTexSVG"),H.drawResizer(N,S[F],tt),e.getCursor().drawCursor({isShow:!1}),is(t),(N.imgDisplay===l.ImageDisplay.SURROUND||N.imgDisplay===l.ImageDisplay.FLOAT_TOP||N.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(N),G.isSubscribe("imageMousedown")&&G.emit("imageMousedown",{evt:o,element:N})}const j=e.getTableTool();j.dispose(),I&&!n&&e.getMode()!==l.EditorMode.FORM&&j.render();const st=e.getHyperlinkParticle();st.clearHyperlinkPopup(),N.type===l.ElementType.HYPERLINK&&(fe(o)?st.openHyperlink(N):st.drawHyperlinkPopup(N,S[F]));const it=e.getDateParticle();it.clearDatePicker(),N.type===l.ElementType.DATE&&!n&&it.renderDatePicker(N,S[F]);const nt=e.getMenstrualHistoryParticle();nt.clearMenstrualHistoryEditor(),N.type===l.ElementType.MENSTRUAL_HISTORY&&h&&(e.getMode()===l.EditorMode.FORM||e.getMode()===l.EditorMode.EDIT)&&nt.renderMenstrualHistoryEditor(N,S[F]);const et=e.getFetalHeartPositionParticle();et.clearFetalHeartPositionEditor(),N.type===l.ElementType.FETAL_HEART_POSITION&&h&&(e.getMode()===l.EditorMode.FORM||e.getMode()===l.EditorMode.EDIT)&&et.renderFetalHeartPositionEditor(N,S[F]);const dt=e.getToothPositionParticle();dt.clearToothPositionEditor(),N.type===l.ElementType.TOOTH_POSITION&&h&&(e.getMode()===l.EditorMode.FORM||e.getMode()===l.EditorMode.EDIT)&&dt.renderToothPositionEditor(N,S[F])}function _n(o){const t=lt();return Reflect.set(o,"dragId",t),t}function xn(o,t){return t.findIndex(e=>e.dragId===o)}function ls(o,t,e){const n=e.getDraw();if(o.imgDisplay===l.ImageDisplay.SURROUND||o.imgDisplay===l.ImageDisplay.FLOAT_TOP||o.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM){const i=t.offsetX-e.mouseDownStartPosition.x,r=t.offsetY-e.mouseDownStartPosition.y,s=o.imgFloatPosition;o.imgFloatPosition={x:s.x+i,y:s.y+r,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function ca(o,t){if(t.isAllowDrop){const e=t.getDraw();if(e.isReadonly()||e.isDisabled()){t.mousedown(o);return}const n=e.getPosition(),i=n.getPositionList(),r=n.getPositionContext(),s=e.getRange(),a=t.cacheRange,c=t.cacheElementList,d=t.cachePositionList,R=t.cachePositionContext,u=s.getRange(),h=a.startIndex===a.endIndex,g=h?a.startIndex-1:a.startIndex,f=a.endIndex;if(u.startIndex>=g&&u.endIndex<=f&&t.cachePositionContext?.tdId===r.tdId){e.clearSideEffect();let it=!1,nt=!1;if(h){const et=c[f];if(et.type===l.ElementType.IMAGE||et.type===l.ElementType.LATEX){if(ls(et,o,t),et.imgDisplay===l.ImageDisplay.SURROUND||et.imgDisplay===l.ImageDisplay.FLOAT_TOP||et.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(et),it=!0;else{const dt=d[f];e.getPreviewer().drawResizer(et,dt)}nt=et.imgDisplay===l.ImageDisplay.SURROUND}}s.replaceRange({...a}),e.render({isCompute:nt,isSubmitHistory:it,isSetCursor:!1});return}const T=c.slice(g+1,f+1),p=T.find(it=>it.controlId);if(p){const it=c[g+1],nt=c[f];if(!((!it.controlId||it.controlComponent===l.ControlComponent.PREFIX)&&(!nt.controlId||nt.controlComponent===l.ControlComponent.POSTFIX)||it.controlId===nt.controlId&&it.controlComponent===l.ControlComponent.PREFIX&&nt.controlComponent===l.ControlComponent.POSTFIX||it.control?.type===l.ControlType.TEXT&&it.controlComponent===l.ControlComponent.VALUE&&nt.control?.type===l.ControlType.TEXT&&nt.controlComponent===l.ControlComponent.VALUE)){e.render({curIndex:u.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const m=e.getControl(),I=e.getElementList(),L=!p||!!I[u.startIndex].controlId||!m.getIsElementListContainFullControl(T),P=e.getOptions(),O=T.map(it=>{if(!it.type||it.type===l.ElementType.TEXT){const nt={value:it.value},et=Re;return L||et.push(...Xo),et.forEach(dt=>{const tt=it[dt];tt!==void 0&&(nt[dt]=tt)}),nt}else{let nt=at(it);return L&&(nt=ie(nt,Xo)),Vt([nt],{isHandleFirstElement:!1,editorOptions:P}),nt}});Ut(I,O,u.startIndex,{editorOptions:e.getOptions()});const S=c[g],F=d[g],N=_n(c[g]),V=_n(c[f]),Y=O.length;let X=u.startIndex,b=X+Y;const E=m.getActiveControl();if(E&&c[X].controlComponent!==l.ControlComponent.POSTFIX?(b=E.setValue(O),X=b-Y):e.spliceElementList(I,X+1,0,O),!~b){e.render({isSetCursor:!1});return}const C=_n(I[X]),M=_n(I[b]),y=xn(N,c),W=xn(V,c),D=c[W];if(D.controlId&&D.controlComponent!==l.ControlComponent.POSTFIX)s.replaceRange({...a,startIndex:y,endIndex:W}),m.getActiveControl()?.cut();else{let it=!0;if(R?.isTable){const{tableId:nt,trIndex:et,tdIndex:dt}=R;it=!e.getOriginalElementList().some(ht=>ht.id===nt&&ht?.trList?.[et]?.tdList?.[dt]?.deletable===!1)}it&&e.spliceElementList(c,y+1,W-y)}const U=I[u.startIndex],Q=i[u.startIndex];let G=r.index;G&&(U.tableId&&!S.tableId?F.index<G&&(G-=Y):!U.tableId&&S.tableId&&Q.index<G&&(G+=Y),n.setPositionContext({...r,index:G}));const H=xn(C,I),j=xn(M,I);s.setRange(h?j:H,j,u.tableId,u.startTdIndex,u.endTdIndex,u.startTrIndex,u.endTrIndex),e.clearSideEffect();let st=null;if(h){const nt=e.getElementList()[j];(nt.type===l.ElementType.IMAGE||nt.type===l.ElementType.LATEX)&&(ls(nt,o,t),st=nt)}if(e.render({isSetCursor:!1}),E?m.emitControlContentChange():S.controlId&&m.emitControlContentChange({context:{range:a,elementList:c},controlElement:S}),st)if(st.imgDisplay===l.ImageDisplay.SURROUND||st.imgDisplay===l.ImageDisplay.FLOAT_TOP||st.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(st);else{const nt=n.getPositionList()[j];e.getPreviewer().drawResizer(st,nt)}}else t.isAllowDrag&&t.cacheRange?.startIndex!==t.cacheRange?.endIndex&&t.mousedown(o)}function da(o,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:i,y:r,width:s,height:a}=n.getBoundingClientRect();o.x>=i&&o.x<=i+s&&o.y>=r&&o.y<=r+a||t.setIsAllowSelection(!1)}function Ra(o,t){const e=t.getDraw(),n=e.getControl(),i=e.getPageList(),r=e.getPageNo(),s=i[r],c=e.getPosition().getPositionByXY({x:o.offsetX,y:o.offsetY});if(~c.index){const C=e.getElementList(),M=c.isTable?c.tdValueIndex:c.index,y=C[M];y?.control?.type===l.ControlType.BUTTON&&!y.control?.buttonText?s&&(s.style.cursor="pointer"):s&&(s.style.cursor="text")}else s&&(s.style.cursor="text");if(t.isAllowDrag){const C=o.offsetX,M=o.offsetY,{startIndex:y,endIndex:W}=t.cacheRange,D=t.cachePositionList;for(let Q=y+1;Q<=W;Q++){const{coordinate:{leftTop:G,rightBottom:H}}=D[Q];if(C>=G[0]&&C<=H[0]&&M>=G[1]&&M<=H[1])return}const U=t.cacheRange?.startIndex;if(U){const Q=t.cacheElementList[U];Q?.type===l.ElementType.IMAGE&&(Q.imgDisplay===l.ImageDisplay.SURROUND||Q.imgDisplay===l.ImageDisplay.FLOAT_TOP||Q.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(o.movementX,o.movementY))}t.dragover(o),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const R=o.target.dataset.index;R&&e.setPageNo(Number(R));const u=e.getPosition(),h=u.getPositionByXY({x:o.offsetX,y:o.offsetY});if(!~h.index)return;const{index:g,isTable:f,tdValueIndex:T,tdIndex:p,trIndex:m,tableId:I,trId:L,tdId:P}=h,{index:O,isTable:S,tdIndex:F,tdId:N,trIndex:V,tableId:Y}=t.mouseDownStartPosition,X=f?T:g,b=e.getRange();let E;if(P!==N&&P&&N){const C=e.getTdByPosition({...t.mouseDownStartPosition,isTable:!!t.mouseDownStartPosition.tableId,index:t.mouseDownStartPosition.originalIndex??t.mouseDownStartPosition.index}),M=e.getTdByPosition({...h,isTable:!!h.tableId,index:h.index});if(e.isSplitTd(C,M)){const y=(C.valueStartIndex??0)+O,W=(M.valueStartIndex??0)+T;E=[{index:y,element:C.value[O],originalId:C.originalId,isCurrent:!1,length:C.value.length,startIndex:C.valueStartIndex??0},{index:W,element:M.value[T],originalId:M.originalId,isCurrent:!0,length:M.value.length,startIndex:M.valueStartIndex??0}]}}if(f&&S&&P!==N&&!E)b.setRange(X,X,I,F,p,V,m),u.setPositionContext({isTable:!!f,index:g,trIndex:m,tdIndex:p,tdId:P,trId:L,tableId:I});else{let C=~X?X:0;if((S||f)&&Y!==I&&!E)return;u.setPositionContext({isTable:!!f,index:g,trIndex:m,tdIndex:p,tdId:P,trId:L,tableId:I});let M=O,y,W;if(E)[{element:y},{element:W}]=E;else{const Q=e.getElementList();y=Q[M+1],W=Q[C]}if(M===C||y?.controlComponent===l.ControlComponent.PLACEHOLDER&&W?.controlComponent===l.ControlComponent.PLACEHOLDER&&y.controlId===W.controlId)return;if(M>C&&([M,C]=[C,M]),e.getMode()===l.EditorMode.FORM){const Q=n.getActiveTextControlLimit();Q&&(M=Math.min(Math.max(M,Q.startIndex),Q.endIndex),C=Math.min(Math.max(C,Q.startIndex),Q.endIndex));const G=e.getElementList(),H=G[M],j=G[C];if(H?.control?.type===l.ControlType.TEXTFIELD||j?.control?.type===l.ControlType.TEXTFIELD){const st=H?.controlId||j?.controlId;if(st){let it=-1,nt=-1;for(let et=M;et>=0;et--){const dt=G[et];if(dt.controlId!==st)break;if(dt.controlComponent===l.ControlComponent.PRETEXTFIX||dt.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||dt.controlComponent===l.ControlComponent.TEXTFIXLABEL||dt.controlComponent===l.ControlComponent.PREFIX||dt.controlComponent===l.ControlComponent.PRE_TEXT){it=et+1;break}}for(let et=C;et<G.length;et++){const dt=G[et];if(dt.controlId!==st)break;if(dt.controlComponent===l.ControlComponent.POSTTEXTFIX||dt.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||dt.controlComponent===l.ControlComponent.POSTFIX||dt.controlComponent===l.ControlComponent.POST_TEXT){nt=et-1;break}}it!==-1&&M<it&&(M=it),nt!==-1&&C>nt&&(C=nt)}}}let U;if(E){const[Q,G]=E.sort((H,j)=>H.index-j.index);U={originalId:E[0].originalId??E[1].originalId,startIndex:Q.index,endIndex:G.index},Q.isCurrent?(M=Q.index,C=Q.length-1):(M=0,C=U.endIndex-G.startIndex)}b.setRange(M,C,void 0,void 0,void 0,void 0,void 0,U)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function ua(o){const t=o.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),r=i[n.startIndex];if(!r.hide&&!r.control?.hide&&!r.area?.hide)return;let s=n.startIndex;for(;s>0;){const a=i[s];let c=null;a.controlId?(c=t.getControl().removeControl(s),c!==null&&(s=c)):(t.spliceElementList(i,s,1),c=s-1,s--);const d=i[c];if(!d||!d.hide&&!d.control?.hide&&!d.area?.hide){if(c){n.startIndex=c,n.endIndex=c,e.replaceRange(n);const R=t.getPosition(),u=R.getPositionList();R.setCursorPosition(u[c])}break}}}function ha(o,t,e){if(e.originControlId){const n=e.originControlId;for(let i=t;i<o.length;i++){const r=o[i];if(r.controlId===n)return r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX||r.controlComponent===l.ControlComponent.POST_TEXT?{isInParent:!1}:{isInParent:!0,parentControlId:n};if(r.controlId&&r.controlId!==n&&r.originControlId!==n)break}}if(!e.originControlId&&e.controlId){const n=o[t];if(n?.controlId&&n.controlId!==e.controlId&&(n.controlComponent===l.ControlComponent.PREFIX||n.controlComponent===l.ControlComponent.PRETEXTFIX))for(let i=t-1;i>=0;i--){const r=o[i];if(r.controlId===e.controlId&&(r.controlComponent===l.ControlComponent.PREFIX||r.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let s=i-1;s>=0;s--){const a=o[s];if(a.controlId&&a.controlId!==e.controlId&&(a.controlComponent===l.ControlComponent.PRETEXTFIX||a.controlComponent===l.ControlComponent.PREFIX))return{isInParent:!0,parentControlId:a.controlId};if(a.controlId&&a.controlId!==e.controlId&&(a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POSTTEXTFIX))return{isInParent:!1}}break}}if(n?.controlId&&n.controlId!==e.controlId&&!n.originControlId&&(n.controlComponent===l.ControlComponent.POSTFIX||n.controlComponent===l.ControlComponent.POSTTEXTFIX))return e.originControlId===n.controlId?{isInParent:!0,parentControlId:n.controlId}:{isInParent:!1}}return{isInParent:!1}}function ga(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&ua(t);const i=e.getControl(),{startIndex:r,endIndex:s,isCrossRowCol:a}=n.getRange();let c;const d=e.getElementList();if(n.getIsCollapsed()&&r>0){const u=d[r-1],h=d[r],f=e.getPosition().getPositionList(),T=f[r],p=f[r-1],m=T&&p&&T.rowIndex===p.rowIndex,I=u?.controlComponent===l.ControlComponent.PREFIX||u?.controlComponent===l.ControlComponent.PRETEXTFIX||u?.controlComponent===l.ControlComponent.PRE_TEXT||u?.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT,L=u?.controlComponent===l.ControlComponent.POSTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||u?.controlComponent===l.ControlComponent.POST_TEXT,P=!!u?.controlId,O=h?.controlComponent===l.ControlComponent.PLACEHOLDER,S=h?.controlComponent===l.ControlComponent.POSTFIX||h?.controlComponent===l.ControlComponent.POSTTEXTFIX||h?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||h?.controlComponent===l.ControlComponent.POST_TEXT,F=!!h&&!h.controlId&&!h.control;if(O&&I&&P&&m)return;const{isInParent:N,parentControlId:V}=ha(d,r,u);if(L&&P&&m&&N){if(u.originControlId&&V)for(let Y=r;Y<d.length;Y++){const X=d[Y];if(X.controlId===V&&!X.originControlId){if(X.controlComponent===l.ControlComponent.VALUE){n.setRange(Y,Y),e.render({curIndex:Y,isSubmitHistory:!1});return}if(X.controlComponent===l.ControlComponent.POSTFIX||X.controlComponent===l.ControlComponent.POSTTEXTFIX||X.controlComponent===l.ControlComponent.POST_TEXT)return}X.controlId!==V&&X.originControlId}return}if(L&&P&&m&&!N&&!(F&&!O&&!S)){const Y=r-1;c=i.removeControl(Y),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(Y,Y),e.render({curIndex:Y,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}if(S&&h?.controlId&&m){const Y=r;c=i.removeControl(Y),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(Y,Y),e.render({curIndex:Y,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(a){const u=e.getTableParticle().getRangeRowCol();if(!u)return;let h=!1;for(let g=0;g<u.length;g++){const f=u[g];for(let T=0;T<f.length;T++){const p=f[T];p.value.length>1&&(e.spliceElementList(p.value,1,p.value.length-1),h=!0)}}c=h?0:null}else if(i.getActiveControl()&&i.getIsRangeCanCaptureEvent())c=i.keydown(o),c&&i.emitControlContentChange();else{const u=e.getPosition().getCursorPosition();if(!u)return;const{index:h}=u,g=n.getIsCollapsed(),f=e.getElementList();if(g&&h===0){const I=f[h];if(I.value===_){I.listId&&e.getListParticle().unsetList(),o.preventDefault();return}}const T=f[r];if(g&&T.rowFlex&&T.value===_){const I=n.getRangeRowElementList();if(I){const L=f[r-1];I.forEach(P=>{P.rowFlex=L?.rowFlex})}}const p=T.value===_?f[r-1]:T,m=f[s+1];if(p?.titleId&&m?.titleId&&p.level===m.level&&p.titleId!==m.titleId){const I=p.titleId,L=m.titleId;let P=s+1;for(;P<f.length&&f[P]?.titleId===L;)f[P].titleId=I,P++}g?e.spliceElementList(f,h,1):e.spliceElementList(f,r+1,s-r),c=g?h-1:r}e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(r,r),e.render({curIndex:r,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}))}function fa(o){const t=o.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),r=i[n.startIndex+1];if(!r.hide&&!r.control?.hide&&!r.area?.hide)return;const s=n.startIndex+1;for(;s<i.length;){const a=i[s];let c=null;a.controlId?c=t.getControl().removeControl(s):(t.spliceElementList(i,s,1),c=s);const d=i[c];if(!d||!d.hide&&!d.control?.hide&&!d.area?.hide)break}}function Ta(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r,isCrossRowCol:s,splitTdRange:a}=n.getRange(),c=e.getElementList(),d=e.getControl();n.getIsCollapsed()&&fa(t);let R;if(s){const u=e.getTableParticle().getRangeRowCol();if(!u)return;let h=!1;for(let g=0;g<u.length;g++){const f=u[g];for(let T=0;T<f.length;T++){const p=f[T];p.value.length>1&&(e.spliceElementList(p.value,1,p.value.length-1),h=!0)}}R=h?0:null}else if(d.getActiveControl()&&d.getIsRangeWithinControl())R=d.keydown(o),R&&d.emitControlContentChange();else if(c[r+1]?.controlId)R=d.removeControl(r+1);else{e.removeSplitTdOtherRangeElements();const u=e.getPosition(),h=u.getCursorPosition();if(!h)return;const{index:g}=h,f=u.getPositionContext();if(f.isDirectHit&&f.isImage)e.spliceElementList(c,g,1),R=g-1;else{const T=n.getIsCollapsed();if(!T)e.spliceElementList(c,i+1,r-i);else if(c[g+1])e.spliceElementList(c,g+1,1);else{let p=!0;if(f.isTable){const m=e.getTd();if(m?.linkTdNextId){const I=e.getTdById(m.linkTdNextId);I&&(p=!1,e.spliceElementList(I.value,1,1))}}if(p)return}R=T?g:i,R===0&&a&&(R=e.fixPosition(!0)??R)}}e.getGlobalEvent().setCanvasEventAbility(),R===null?(n.setRange(i,i),e.render({curIndex:i,isSubmitHistory:!1})):(n.setRange(R,R),e.render({curIndex:R}))}function ma(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r}=n.getRange(),s=n.getIsCollapsed(),a=e.getElementList(),c=a[i],d=a[r];if(s&&d.listId&&d.value===_&&a[r+1]?.listId!==d.listId){e.getListParticle().unsetList();return}let R={value:_};if(o.shiftKey&&c.listId&&(R.listWrap=!0),Ut(a,[R],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),o.shiftKey&&d.areaId&&d.areaId!==a[r+1]?.areaId&&(R=ie(R,Ke)),!(a[i+1]?.titleId&&(!c.titleId||c.titleId!==a[i+1]?.titleId))&&!(d.titleId&&d.titleId!==a[r+1]?.titleId)){const p=n.getRangeAnchorStyle(a,r);if(p){const m=[...Bt],I=p.controlComponent===l.ControlComponent.POSTFIX||p.controlComponent===l.ControlComponent.POSTTEXTFIX||p.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||p.controlComponent===l.ControlComponent.POST_TEXT,L=p.control?.type===l.ControlType.BUTTON&&!p.control?.buttonText;!I&&!L&&m.push(...Re),m.forEach(P=>{const O=p[P];O!==void 0&&(R[P]=O)})}}const u=e.getControl(),h=u.getActiveControl();let g;const f=h?.getElement();if(f?.control?.type===l.ControlType.BUTTON&&!f.control?.buttonText&&f?.controlId){const p=f.controlId;let m=r;for(;m+1<a.length&&a[m+1]?.controlId===p;)m++;e.spliceElementList(a,m+1,0,[R]),g=m+1}else if(h&&u.getIsRangeWithinControl())g=u.setValue([R]),u.emitControlContentChange();else{const m=e.getPosition().getCursorPosition();if(!m)return;const{index:I}=m;if(s){if(e.spliceElementList(a,I+1,0,[R]),d.titleId&&a[I+2]?.titleId===d.titleId){const L=lt();let P=I+2;for(;P<a.length&&a[P]?.titleId===d.titleId;)a[P].titleId=L,P++}}else e.spliceElementList(a,i+1,r-i,[R]);g=I+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),o.preventDefault()}function as(o){return o&&(o.type===l.ElementType.MACRO||o.type===l.ElementType.CUSTOM_MACRO||o.type===l.ElementType.REUSABLE_ITEM||o.type===l.ElementType.SUB_TEMPLATE||o.type===l.ElementType.MENSTRUAL_HISTORY||o.type===l.ElementType.FETAL_HEART_POSITION||o.type===l.ElementType.TOOTH_POSITION||o.type===l.ElementType.LIST||o.type===l.ElementType.SPECIAL_SYMBOLS)}function pa(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const s=i.getPositionContext(),{index:a}=r;if(a<=0&&!s.isTable)return;const c=e.getRange(),{startIndex:d,endIndex:R}=c.getRange(),u=c.getIsCollapsed(),h=e.getElementList(),g=e.getControl(),f=e.getMode()===l.EditorMode.FORM,T=f?g.getActiveTextControlLimit():null,p=h[a],m=p?.controlComponent===l.ControlComponent.PREFIX||p?.controlComponent===l.ControlComponent.PRETEXTFIX||p?.controlComponent===l.ControlComponent.PRE_TEXT;let I=!1;if(m&&p?.originControlId){const V=p.originControlId;for(let Y=a-1;Y>=0;Y--){const X=h[Y];if(X.controlId===V&&!X.originControlId){I=!0;break}if(X.controlId&&X.controlId!==V&&X.originControlId!==V)break}}if(f&&g.getActiveControl()&&m&&!T&&!I){g.initNextControl({direction:Zt.UP});return}let L=1;if(fe(o)){const V=e.getLetterReg(),Y=o.shiftKey&&!u&&d===r?.index?R:d;if(V.test(h[Y]?.value)){let X=Y-1;for(;X>0;){const b=h[X];if(!V.test(b.value))break;L++,X--}}}if(f){const V=h[d],Y=V?.controlId;if(Y&&V?.controlComponent===l.ControlComponent.VALUE){let X=!1;for(let b=d;b>=0;b--){const E=h[b];if(E.controlId!==Y)break;if(E.control?.type===l.ControlType.TEXTFIELD){X=!0;break}}if(X){if(V.controlComponent===l.ControlComponent.VALUE&&as(V))return;const b=d-L;if(b>=0){const E=h[b];if(E&&E.controlId===Y&&E.controlComponent===l.ControlComponent.VALUE&&as(E))return}}}}const P=T?Math.max(d-L,T.startIndex):d-L;let O=P,S=P;if(o.shiftKey&&r&&(d!==R?d===r.index?(O=d,S=R-L):(O=P,S=R):S=R),!o.shiftKey){const V=h[d];if(V.type===l.ElementType.TABLE){const Y=V.trList,X=Y.length-1,b=Y[X],E=b.tdList.length-1,C=b.tdList[E];i.setPositionContext({isTable:!0,index:d,trIndex:X,tdIndex:E,tdId:C.id,trId:b.id,tableId:V.id}),O=C.value.length-1,S=O}else if(V.tableId&&d===0){const X=e.getOriginalElementList()[s.index],b=e.getTd();if(b?.linkTdPrevId){const E=e.getTdById(b.linkTdPrevId);E&&(i.setPositionContext({...s,isTable:!0,index:E.tableIndex,trIndex:E.trIndex,tdId:E.id,trId:E.trId,tableId:E.tableId}),O=E.value.length-1,S=O)}else{const E=X.trList;t:for(let C=0;C<E.length;C++){const M=E[C];if(M.id!==V.trId)continue;const y=M.tdList;for(let W=0;W<y.length;W++)if(y[W].id===V.tdId){if(C===0&&W===0)i.setPositionContext({isTable:!1}),O=s.index-1,S=O,e.getTableTool().dispose();else{let U=C,Q=W-1;Q<0&&(U=C-1,Q=E[U].tdList.length-1);const G=E[U],H=G.tdList[Q];i.setPositionContext({isTable:!0,index:s.index,trIndex:U,tdIndex:Q,tdId:H.id,trId:G.id,tableId:V.tableId}),O=H.value.length-1,S=O}break t}}}}}if(!~O||!~S)return;const F=e.getElementList();O=Ln(F,O),S=Ln(F,S),c.setRange(O,S);const N=O===S;e.updateTableTool(),e.render({curIndex:N?O:void 0,isSetCursor:N,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function cs(o){return o&&(o.type===l.ElementType.MACRO||o.type===l.ElementType.CUSTOM_MACRO||o.type===l.ElementType.REUSABLE_ITEM||o.type===l.ElementType.SUB_TEMPLATE||o.type===l.ElementType.MENSTRUAL_HISTORY||o.type===l.ElementType.FETAL_HEART_POSITION||o.type===l.ElementType.TOOTH_POSITION||o.type===l.ElementType.LIST||o.type===l.ElementType.SPECIAL_SYMBOLS)}function La(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const{index:s}=r,a=i.getPositionList(),c=i.getPositionContext();if(s>a.length-1&&!c.isTable)return;const d=e.getRange(),{startIndex:R,endIndex:u}=d.getRange(),h=d.getIsCollapsed();let g=e.getElementList();const f=e.getControl(),T=e.getMode()===l.EditorMode.FORM,p=T?f.getActiveTextControlLimit():null,m=g[s],I=m?.controlComponent===l.ControlComponent.POSTFIX||m?.controlComponent===l.ControlComponent.POSTTEXTFIX||m?.controlComponent===l.ControlComponent.POST_TEXT;let L=!1;if(I&&m?.originControlId){const X=m.originControlId;for(let b=s+1;b<g.length;b++){const E=g[b];if(E.controlId===X&&!E.originControlId){L=!0;break}if(E.controlId&&E.controlId!==X&&E.originControlId!==X)break}}if(T&&f.getActiveControl()&&I&&!p&&!L){f.initNextControl({direction:Zt.DOWN});return}let P=1;if(fe(o)){const X=e.getLetterReg(),b=o.shiftKey&&!h&&R===r?.index?u:R;if(X.test(g[b+1]?.value)){let E=b+2;for(;E<g.length;){const C=g[E];if(!X.test(C.value))break;P++,E++}}}if(T){const X=g[u],b=X?.controlId;if(b&&X?.controlComponent===l.ControlComponent.VALUE){let E=!1;for(let C=u;C>=0;C--){const M=g[C];if(M.controlId!==b)break;if(M.control?.type===l.ControlType.TEXTFIELD){E=!0;break}}if(E){if(X.controlComponent===l.ControlComponent.VALUE&&cs(X))return;const C=u+P;if(C<g.length){const M=g[C];if(M&&M.controlId===b&&M.controlComponent===l.ControlComponent.VALUE&&cs(M))return}}}}const O=p?Math.min(u+P,p.endIndex):u+P;let S=O,F=O;if(o.shiftKey&&r&&(R!==u?R===r.index?(S=R,F=O):(S=R+P,F=u):S=R),!o.shiftKey){const X=g[u],b=g[u+1];if(b?.type===l.ElementType.TABLE){const C=b.trList[0],M=C.tdList[0];i.setPositionContext({isTable:!0,index:u+1,trIndex:0,tdIndex:0,tdId:M.id,trId:C.id,tableId:b.id}),S=0,F=0}else if(X.tableId&&!b){const E=e.getTd(),C=E?.linkTdNextId?e.getTdById(E.linkTdNextId):void 0;if(C?.value.length)i.setPositionContext({...c,isTable:!0,index:C.tableIndex,trIndex:C.trIndex,tdId:C.id,trId:C.trId,tableId:C.tableId}),S=0,F=S;else{const y=e.getOriginalElementList()[c.index].trList;t:for(let W=0;W<y.length;W++){const D=y[W];if(D.id!==X.trId)continue;const U=D.tdList;for(let Q=0;Q<U.length;Q++)if(U[Q].id===X.tdId){if(W===y.length-1&&Q===U.length-1)i.setPositionContext({isTable:!1}),S=c.index,F=S,g=e.getElementList(),e.getTableTool().dispose();else{let H=W,j=Q+1;j>U.length-1&&(H=W+1,j=0);const st=y[H],it=st.tdList[j];i.setPositionContext({isTable:!0,index:c.index,trIndex:H,tdIndex:j,tdId:it.id,trId:st.id,tableId:X.tableId}),S=0,F=S}break t}}}}}const N=g.length-1;if(S>N||F>N)return;const V=e.getElementList();S=Ln(V,S,l.LocationPosition.AFTER),F=Ln(V,F,l.LocationPosition.AFTER),d.setRange(S,F);const Y=S===F;e.updateTableTool(),e.render({curIndex:Y?S:void 0,isSetCursor:Y,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Ia(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getControl();if(i.getActiveControl()&&i.getIsRangeWithinControl())i.initNextControl({direction:o.shiftKey?Zt.UP:Zt.DOWN});else{const s=e.getRange(),a=e.getElementList(),{startIndex:c,endIndex:d}=s.getRange(),R=s.getRangeAnchorStyle(a,d),h={...R?Dt(R,Re):null,type:l.ElementType.TAB,value:""};Ut(a,[h],c,{editorOptions:e.getOptions()}),e.insertElementList([h])}}function Ko(o){const{positionList:t,index:e,isUp:n,rowNo:i,cursorX:r}=o;let s=-1;const a=[];if(n){let c=e-1;for(;c>=0;){const d=t[c];if(c--,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.unshift(d)}}}else{let c=e+1;for(;c<t.length;){const d=t[c];if(c++,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.push(d)}}}for(let c=0;c<a.length;c++){const d=a[c],{coordinate:{leftTop:[R],rightTop:[u]}}=d;if(c===a.length-1&&(s=d.index),!(r<R||r>u)){s=d.index;break}}return s}function Pa(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const s=e.getRange(),{startIndex:a,endIndex:c}=s.getRange();let d=i.getPositionList();const R=o.key===l.KeyMap.Up;let u=-1,h=-1;const g=i.getPositionContext();if(!o.shiftKey&&g.isTable&&(R&&r.rowIndex===0||!R&&r.rowIndex===e.getRowCount()-1)){const{index:T,trIndex:p,tdIndex:m,tableId:I}=g;if(R){const L=e.getOriginalElementList();if(p===0)if(L[T].originalId){const O=T-1,S=L[O];for(let F=S.trList.length-1;F>=0;F--){const N=S.trList[F].tdList.find(V=>V.tdIndex===m);if(N?.value.length){i.setPositionContext({isTable:!0,tableId:S.id,index:O,trIndex:F,tdIndex:m}),u=N.value.length-1,h=N.value.length-1;break}}}else i.setPositionContext({isTable:!1}),u=T-1,h=u,e.getTableTool().dispose();else{let P=-1,O=-1;const S=L[T].trList,F=S[p].tdList[m].colIndex;t:for(let Y=p-1;Y>=0;Y--){const b=S[Y].tdList;for(let E=0;E<b.length;E++){const C=b[E];if(C.colIndex===F||C.colIndex+C.colspan-1>=F&&C.colIndex<=F){P=Y,O=E;break t}}}if(!~P||!~O)return;const N=S[P],V=N.tdList[O];i.setPositionContext({isTable:!0,index:T,trIndex:P,tdIndex:O,tdId:V.id,trId:N.id,tableId:I}),u=V.value.length-1,h=u}}else{const L=e.getOriginalElementList(),P=L[T],O=P.trList;if(p===O.length-1){const S=T+1,F=L[S];if(F&&[P.id,P.originalId].includes(F.originalId)){for(let V=m;V>=0;V--)if(F.trList[0].tdList[V].value.length){i.setPositionContext({isTable:!0,index:S,tableId:F.id,trIndex:0,tdIndex:V}),u=0,h=0;break}}else i.setPositionContext({isTable:!1}),u=T,h=u,e.getTableTool().dispose()}else{let S=-1,F=-1;const N=O[p].tdList[m].colIndex;t:for(let X=p+1;X<O.length;X++){const E=O[X].tdList;for(let C=0;C<E.length;C++){const M=E[C];if(M.colIndex===N||M.colIndex+M.colspan-1>=N&&M.colIndex<=N){S=X,F=C;break t}}}if(!~S||!~F)return;const V=O[S],Y=V.tdList[F];i.setPositionContext({isTable:!0,index:T,trIndex:S,tdIndex:F,tdId:Y.id,trId:V.id,tableId:I}),u=Y.value.length-1,h=u}}}else{let T=r;o.shiftKey&&(a===r.index?T=d[c]:T=d[a]);const{index:p,rowNo:m,rowIndex:I,coordinate:{rightTop:[L]}}=T;if(R&&I===0||!R&&I===e.getRowCount()-1)return;const P=Ko({positionList:d,index:p,rowNo:m,isUp:R,cursorX:L});if(P<0)return;u=P,h=P,o.shiftKey&&(a!==c?a===r.index?u=a:h=c:R?h=c:u=a);const S=e.getElementList()[P];if(S.type===l.ElementType.TABLE){const{scale:F}=e.getOptions(),N=e.getMargins(),V=S.trList;let Y=-1,X=-1,b=-1;if(R)t:for(let E=V.length-1;E>=0;E--){const M=V[E].tdList;for(let y=0;y<M.length;y++){const W=M[y],D=W.x*F+N[3],U=W.width*F;if(L>=D&&L<=D+U){const Q=W.positionList,G=Q[Q.length-1],H=Ko({positionList:Q,index:G.index+1,rowNo:G.rowNo-1,isUp:R,cursorX:L})||G.index;Y=E,X=y,b=H;break t}}}else t:for(let E=0;E<V.length;E++){const M=V[E].tdList;for(let y=0;y<M.length;y++){const W=M[y],D=W.x*F+N[3],U=W.width*F;if(L>=D&&L<=D+U){const Q=W.positionList,G=Ko({positionList:Q,index:-1,rowNo:-1,isUp:R,cursorX:L})||0;Y=E,X=y,b=G;break t}}}if(~Y&&~X&&~b){const E=V[Y],C=E.tdList[X];i.setPositionContext({isTable:!0,index:P,trIndex:Y,tdIndex:X,tdId:C.id,trId:E.id,tableId:S.id}),u=b,h=u,d=i.getPositionList()}}}if(!~u||!~h)return;u>h&&([u,h]=[h,u]),s.setRange(u,h);const f=u===h;e.render({curIndex:f?u:void 0,isSetCursor:f,isSubmitHistory:!1,isCompute:!1}),f||(e.getCursor().moveCursorToVisible({cursorPosition:d[R?u:h],direction:R?Zt.UP:Zt.DOWN}),e.updateTableTool())}function Ma(o,t){if(t.isComposing)return;const e=t.getDraw();if(o.key===l.KeyMap.Backspace)ga(o,t);else if(o.key===l.KeyMap.Delete)Ta(o,t);else if(o.key===l.KeyMap.Enter)ma(o,t);else if(o.key===l.KeyMap.Left)pa(o,t);else if(o.key===l.KeyMap.Right)La(o,t);else if(o.key===l.KeyMap.Up||o.key===l.KeyMap.Down)Pa(o,t);else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==l.EditorMode.FORM)return;e.getHistoryManager().undo(),o.preventDefault()}else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==l.EditorMode.FORM)return;e.getHistoryManager().redo(),o.preventDefault()}else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.C)t.copy(),o.preventDefault();else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.X)t.cut(),o.preventDefault();else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.A)t.selectAll(),o.preventDefault();else if(fe(o)&&o.key.toLocaleLowerCase()===l.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const i=e.getEventBus();i.isSubscribe("saved")&&i.emit("saved",e.getValue()),o.preventDefault()}else if(o.key===l.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(l.EditorZone.MAIN),o.preventDefault()}else o.key===l.KeyMap.TAB&&Ia(o,t)}function Oa(o){return/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(o)}function Ca(o){return/[a-zA-Z]/.test(o)}function Sa(o,t){return Oa(o)?t:Ca(o)?"Times New Roman":t}function Ea(o){return o?.type===l.ElementType.CONTROL&&(o.controlComponent===l.ControlComponent.PREFIX||o.controlComponent===l.ControlComponent.PRE_TEXT||o.controlComponent===l.ControlComponent.PRETEXTFIX||o.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)}function Xa(o){return o?.type===l.ElementType.CONTROL&&(o.controlComponent===l.ControlComponent.POSTFIX||o.controlComponent===l.ControlComponent.POST_TEXT||o.controlComponent===l.ControlComponent.POSTTEXTFIX||o.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)}function Ho(o,t,e="input"){const n=bt(),i=t.getDraw(),r=i.getControl(),s=i.getOptions(),a=i.getElementList(),R=i.getPosition().getCursorPosition()?.index;if(i.isReadonly()||i.isDisabled())return;const h=i.getPosition().getCursorPosition();if(!o||!h)return;const g=t.isComposing;if(g&&t.compositionInfo?.value===o)return;const f=i.getRange();if(!f.getIsCanInput())return;const{endIndex:T}=f.getRange(),p=i.getElementList(),m=p[T],I=p[T+1];if(m?.type===l.ElementType.SUB_TEMPLATE&&I?.type===l.ElementType.SUB_TEMPLATE)return;if(i.getMode()===l.EditorMode.FORM){const K=r.getActiveTextControlLimit();if(!r.getActiveControl()||!r.getIsRangeWithinControl()&&!r.getIsRangeInPostfix())return;if(K){const x=f.getRange();if(x.startIndex<K.startIndex||x.endIndex>K.endIndex){const A=Math.min(Math.max(x.endIndex,K.startIndex),K.endIndex);f.setRange(A,A),i.render({curIndex:A,isSubmitHistory:!1});return}}const{endIndex:w}=f.getRange(),Z=i.getElementList(),J=Z[w];if(!J?.originControlId){if(J?.controlId&&J?.controlComponent===l.ControlComponent.VALUE)for(let x=w;x>=0;x--){const A=Z[x];if(A.controlId!==J.controlId||A.originControlId)break;if(A.control?.type===l.ControlType.TEXTFIELD)return}}}const P=f.getDefaultStyle()||t.compositionInfo?.defaultStyle||null,O=t.compositionInfo?.perfStartTime,S=Fa(t,i.getElementList());g||i.getCursor().clearAgentDomValue();const{TEXT:F,HYPERLINK:N,SUBSCRIPT:V,SUPERSCRIPT:Y,DATE:X,TAB:b}=l.ElementType,E=o.replaceAll(`
|
|
101
|
+
`,_),{startIndex:C,endIndex:M}=f.getRange(),y=f.getRangeAnchorStyle(S,C);if(!y)return;const W=C>0?S[C-1]:null,D=!!(y.controlId||y.control),Q={...!D&&W?W:y,...P},G=i.isDesignMode(),H=S[M+1],j=Ea(H)&&!H?.originControlId,st=Xa(y)&&!y.originControlId||y.type===l.ElementType.CONTROL&&y.controlComponent===l.ControlComponent.VALUE&&H?.type!==l.ElementType.CONTROL&&!y.originControlId,it=j||st,nt=it?{...y,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:s.defaultColor,highlight:void 0}:y,et=it||D?nt:Q,dt=ct(E).map(K=>{const v={value:K};if(G||!et.title?.disabled&&!et.control?.disabled){const w=S[M+1];(!et.type||et.type===F||et.type===N&&w?.type===N||et.type===X&&w?.type===X||et.type===V&&w?.type===V||et.type===Y&&w?.type===Y)&&ol.forEach(Z=>{if(Z==="groupIds"&&!w?.groupIds)return;const J=et[Z];J!==void 0&&(v[Z]=J)}),(P||et.type===b)&&Re.forEach(Z=>{const J=P?.[Z]||et[Z];J!==void 0&&(v[Z]=J)}),g&&(v.underline=!0)}if(!it){const w=y.originControlId&&(y.controlComponent===l.ControlComponent.POSTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||y.controlComponent===l.ControlComponent.POST_TEXT),Z=!y.originControlId&&y.controlId&&(y.controlComponent===l.ControlComponent.POSTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX||y.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||y.controlComponent===l.ControlComponent.POST_TEXT)&&H?.controlId&&H.controlId!==y.controlId,J=y.controlId&&y.originControlId&&(y.controlComponent===l.ControlComponent.VALUE||y.controlComponent===l.ControlComponent.PLACEHOLDER);if(w&&!v.controlId){const x=y.originControlId;let A=null;for(let $=C;$>=0;$--){const B=S[$];if(B.controlId===x&&!B.originControlId&&B.control){A=B.control;break}}v.controlId=x,v.controlComponent=l.ControlComponent.VALUE,A&&(v.control=A)}else if(Z&&!v.controlId){if(H?.controlId&&H.controlId!==y.controlId)if(H.controlComponent===l.ControlComponent.PREFIX||H.controlComponent===l.ControlComponent.PRETEXTFIX)for(let x=C;x>=0;x--){const A=S[x];if(A.controlId===y.controlId&&(A.controlComponent===l.ControlComponent.PREFIX||A.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let $=x-1;$>=0;$--){const B=S[$];if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.PRETEXTFIX||B.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||B.controlComponent===l.ControlComponent.PREFIX||B.controlComponent===l.ControlComponent.PRE_TEXT)){v.controlId=B.controlId,v.controlComponent=l.ControlComponent.VALUE,B.control&&(v.control=B.control);break}if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.POSTFIX||B.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}else(H.controlComponent===l.ControlComponent.POSTFIX||H.controlComponent===l.ControlComponent.POSTTEXTFIX)&&(v.controlId=H.controlId,v.controlComponent=l.ControlComponent.VALUE,H.control&&(v.control=H.control));if(!v.controlId)for(let x=C;x>=0;x--){const A=S[x];if(A.controlId===y.controlId&&(A.controlComponent===l.ControlComponent.PREFIX||A.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let $=x-1;$>=0;$--){const B=S[$];if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.PRETEXTFIX||B.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||B.controlComponent===l.ControlComponent.PREFIX||B.controlComponent===l.ControlComponent.PRE_TEXT)){v.controlId=B.controlId,v.controlComponent=l.ControlComponent.VALUE,B.control&&(v.control=B.control);break}if(B.controlId&&B.controlId!==y.controlId&&(B.controlComponent===l.ControlComponent.POSTFIX||B.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}}else if(J&&!v.controlId){const x=y.controlId;let A=y.control;if(!A)for(let $=C;$>=0;$--){const B=S[$];if(B.controlId===x&&B.control&&(A=B.control,B.controlComponent===l.ControlComponent.PREFIX||B.controlComponent===l.ControlComponent.PRETEXTFIX))break}v.controlId=x,v.originControlId=y.originControlId,v.controlComponent=l.ControlComponent.VALUE,A&&(v.control=A)}else if(y.controlId&&!y.originControlId){let x=y.control;if(!x)for(let A=C;A>=0;A--){const $=S[A];if($.controlId===y.controlId&&!$.originControlId&&$.control){x=$.control;break}}v.controlId||(v.controlId=y.controlId),x&&!v.control&&(v.control=x),v.controlComponent||(v.controlComponent=l.ControlComponent.VALUE)}else if(!v.controlId&&!v.control&&H?.originControlId&&(H.controlComponent===l.ControlComponent.PREFIX||H.controlComponent===l.ControlComponent.PRETEXTFIX)){const x=H.originControlId;let A=null;for(let $=M;$>=0;$--){const B=S[$];if(B.controlId===x&&!B.originControlId&&B.control){A=B.control;break}}v.controlId=x,v.controlComponent=l.ControlComponent.VALUE,A&&(v.control=A)}}if(K&&K!==_){const w=Sa(K,s.defaultFont);v.font=w}return v});let tt;const ht=a[R],ut=a[R+1];if(g)tt=C;else{const K=w=>{if(dt?.length)for(let Z=0;Z<dt.length;Z++)S.splice(w+Z,0,dt[Z]);return C+dt.length},v=C+1;if(C!==M&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(S,v,M-C)),it)tt=K(v);else if(ht?.originControlId&&(ht?.controlComponent==="postfix"||ht?.controlComponent==="postTextFix"))tt=K(v);else if((ht?.control?.type===l.ControlType.NUMBER||ut?.control?.type===l.ControlType.NUMBER)&&r.getActiveControl()?.getElement()?.control?.type===l.ControlType.NUMBER&&r.getIsRangeWithinControl()){const w=r.getActiveControl();w&&typeof w.awake=="function"&&w.awake(),tt=C}else if((ht?.control?.type===l.ControlType.SELECT||ut?.control?.type===l.ControlType.SELECT)&&r.getActiveControl()?.getElement()?.control?.type===l.ControlType.SELECT&&r.getIsRangeWithinControl()){const w=r.getActiveControl();w&&typeof w.awake=="function"&&w.awake(),tt=C}else ht?.control?.type==="button"||ut?.control?.type==="button"?(ht?.control||ut?.control)?.buttonText?tt=C:r.getActiveControl()&&r.getIsRangeWithinControl()?(r.removePlaceholder(C,{elementList:S}),tt=r.setValue(dt),r.emitControlContentChange()):tt=C:r.getActiveControl()&&r.getIsRangeWithinControl()?(r.removePlaceholder(C,{elementList:S}),tt=r.setValue(dt),r.emitControlContentChange()):(ht?.type==="control"||ut?.type==="control")&&!it?tt=K(v):(Ut(S,dt,C,{editorOptions:s}),i.spliceElementList(S,v,0,dt),tt=C+dt.length)}if(~tt&&!g){const K=bt()-n,v=bt();f.setRange(tt,tt),i.render({curIndex:tt,isSubmitHistory:!g,traceLabel:`input:${e}`}),Co(s,`input:${e}`,bt()-n,[{label:"mutate",duration:K},{label:"renderCall",duration:bt()-v}],{isComposing:g,textLength:dt.length,compositionChainDuration:e==="compositionend"&&O!==void 0?Number((bt()-O).toFixed(2)):void 0})}g&&(t.compositionInfo={value:E,startIndex:tt,endIndex:M,defaultStyle:P,perfStartTime:n})}function Na(o){o.compositionInfo&&(o.compositionInfo=null)}function Fa(o,t){if(!o.compositionInfo||o.isComposing)return t;const{startIndex:e,endIndex:n}=o.compositionInfo;return e!==n&&(o.getDraw().removeSplitTdOtherRangeElements(),o.getDraw().spliceElementList(t,e+1,n-e),o.getDraw().getRange().setRange(e,e)),o.compositionInfo=null,t}async function ya(o){const t=o.getDraw(),e=t.getRange(),{startIndex:n,endIndex:i}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const r=t.getElementList();let s=n,a=i;if(n===i){const h=t.getPosition().getPositionList(),g=h[n],f=g.rowNo,T=g.pageNo,p=[];for(let I=0;I<h.length;I++){const L=h[I];if(L.pageNo>T)break;L.pageNo===T&&L.rowNo===f&&p.push(I)}const m=p[0]-1;s=m<0?0:m,a=p[p.length-1]}const c=t.getOptions();await ns(r.slice(s+1,a+1),c);const d=t.getControl();let R;d.getActiveControl()&&d.getIsRangeWithinControl()?(R=d.cut(),d.emitControlContentChange()):(t.spliceElementList(r,s+1,a-s),R=s),e.setRange(R,R),t.render({curIndex:R})}async function Wa(o,t){const e=o.getDraw(),{copy:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=e.getRange();let r=null;if(i.getRange().isCrossRowCol){const a=i.getRangeTableElement();if(!a)return;const c=e.getTableParticle().getRangeRowCol();if(!c)return;const d={type:l.ElementType.TABLE,value:"",colgroup:[],trList:[]},R=c[0],u=R[0].colIndex,h=R[R.length-1],g=h.colIndex+h.colspan-1;for(let f=u;f<=g;f++)d.colgroup.push(a.colgroup[f]);for(let f=0;f<c.length;f++){const T=c[f],p=a.trList[T[0].rowIndex],m={tdList:[],height:p.height,minHeight:p.minHeight};for(let I=0;I<T.length;I++)m.tdList.push(T[I]);d.trList.push(m)}r=Mt([d])}else r=i.getIsCollapsed()?i.getRangeRowElementList():i.getSelectionElementList();t?.isPlainText&&r?.length&&(r=[{value:en(r)}]),r?.length&&await ns(r,e.getOptions())}function ba(o,t){const e=t.getDraw(),{drop:n}=e.getOverride();if(n&&n(o)?.preventDefault!==!1)return;o.preventDefault();const i=o.dataTransfer?.getData("text");if(i)t.input(i);else{const r=o.dataTransfer?.files;if(!r)return;for(let s=0;s<r.length;s++){const a=r[s];a.type.startsWith("image")&&Qo(t,a)}}}function ds(o){if(!Intl.Segmenter)return null;const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const i=t.getRange().getRangeParagraphInfo();if(!i)return null;const r=i?.elementList?.map(h=>!h.type||h.type!==l.ElementType.CONTROL&&$t.includes(h.type)?h.value:_).join("")||"";if(!r)return null;const s=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,a=i.startIndex,d=new Intl.Segmenter(void 0,{granularity:"word"}).segment(r);let R=-1,u=-1;for(const{segment:h,index:g,isWordLike:f}of d){const T=g+a;if(f&&s>=T&&s<T+h.length){R=T-1,u=R+h.length;break}}return~R&&~u?{startIndex:R,endIndex:u}:null}function Va(o){const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:i}=e,r=t.getLetterReg();let s=0,a=0;const c=mo.test(n);if(c||r.test(n)){const R=t.getElementList();let u=i-1;for(;u>0;){const g=R[u].value;if(c&&mo.test(g)||!c&&r.test(g))s++,u--;else break}let h=i+1;for(;h<R.length;){const g=R[h].value;if(c&&mo.test(g)||!c&&r.test(g))a++,h++;else break}}const d=i-s-1;return d<0?null:{startIndex:d,endIndex:i+a}}function Ya(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(i.isImage&&i.isDirectHit){const a=e.getElementList(),c=e.getEventBus(),d=a[i.index];if(c.isSubscribe("imageDblclick")&&c.emit("imageDblclick",{evt:t,element:d}),d.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&e.getMode()===l.EditorMode.EDIT&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const r=e.getRange(),s=ds(o)||Va(o);s&&(r.setRange(s.startIndex,s.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),r.setRangeStyle())}function Da(o){const t=o.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const i=t.getPosition().getCursorPosition();if(!i)return;const{index:r}=i,s=t.getElementList();let a=0,c=0,d=r-1;for(;d>0;){const f=s[d],T=s[d-1];if(f.value===_&&!f.listWrap||f.listId!==T?.listId||f.titleId!==T?.titleId)break;a++,d--}let R=r+1;for(;R<s.length;){const f=s[R],T=s[R+1];if(f.value===_&&!f.listWrap||f.listId!==T?.listId||f.titleId!==T?.titleId)break;c++,R++}const u=t.getRange();let h=r-a-1;if(s[h]?.value!==_&&(h-=1),h<0)return;let g=r+c+1;(s[g]?.value===_||g>s.length-1)&&(g-=1),u.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const Rs={dblclick:Ya,threeClick:Da};function Ua(o){o.isComposing=!0}function wa(o,t){const e=bt();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),nl?setTimeout(()=>{o.compositionInfo&&Ho(t.data,o,"compositionend")},1):o.compositionInfo&&Ho(t.data,o,"compositionend");else{const s=o.compositionInfo?.cancel;if(Na(o),!s){const a=n.getRange(),{endIndex:c}=a.getRange();n.render({curIndex:c,isSubmitHistory:!1,traceLabel:"compositionend:empty"})}}n.getCursor().clearAgentDomValue(),Co(i,"compositionend",bt()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function Za(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const _o={compositionstart:Ua,compositionend:wa,compositionCancel:Za};function Qa(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Wi(o.target,L=>L===i))return;const a=o.target.dataset.index;a&&e.setPageNo(Number(a));const c=e.getPosition(),d=c.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{isTable:R,tdValueIndex:u,index:h}=d,g=c.getPositionList(),f=R?u:h;~h&&(e.getRange().setRange(f,f),c.setCursorPosition(g[f]));const T=e.getCursor(),{cursor:{dragColor:p,dragWidth:m,dragFloatImageDisabled:I}}=e.getOptions();if(I){const L=t.cacheElementList?.[t.cacheRange.startIndex];if(L?.type===l.ElementType.IMAGE&&(L.imgDisplay===l.ImageDisplay.FLOAT_TOP||L.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM||L.imgDisplay===l.ImageDisplay.SURROUND))return}T.drawCursor({width:m,color:p,isBlink:!1,isFocus:!1})}const va={dragover:Qa};class Ka{isAllowSelection;isComposing;compositionInfo;isAllowDrag;isAllowDrop;cacheRange;cacheElementList;cachePositionList;cachePositionContext;mouseDownStartPosition;draw;pageContainer;pageList;range;position;constructor(t){this.draw=t,this.pageContainer=t.getPageContainer(),this.pageList=t.getPageList(),this.range=this.draw.getRange(),this.position=this.draw.getPosition(),this.isAllowSelection=!1,this.isComposing=!1,this.compositionInfo=null,this.isAllowDrag=!1,this.isAllowDrop=!1,this.cacheRange=null,this.cacheElementList=null,this.cachePositionList=null,this.cachePositionContext=null,this.mouseDownStartPosition=null}getDraw(){return this.draw}register(){this.pageContainer.addEventListener("click",this.click.bind(this)),this.pageContainer.addEventListener("mousedown",this.mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this.mouseup.bind(this)),this.pageContainer.addEventListener("mouseleave",this.mouseleave.bind(this)),this.pageContainer.addEventListener("mousemove",this.mousemove.bind(this)),this.pageContainer.addEventListener("dblclick",this.dblclick.bind(this)),this.pageContainer.addEventListener("dragover",this.dragover.bind(this)),this.pageContainer.addEventListener("drop",this.drop.bind(this)),_r(this.pageContainer,this.threeClick.bind(this))}setIsAllowSelection(t){this.isAllowSelection=t,t||this.applyPainterStyle()}setIsAllowDrag(t){this.isAllowDrag=t,this.isAllowDrop=t}clearPainterStyle(){this.pageList.forEach(t=>{t.style.cursor="text"}),this.draw.setPainterStyle(null)}applyPainterStyle(){const t=this.draw.getPainterStyle();if(!t||this.draw.isReadonly()||this.draw.isDisabled())return;let n=this.range.getSelection();if(!n){const s=ds(this);s&&(n=this.draw.getElementList().slice(s.startIndex+1,s.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(s=>{i.forEach(a=>{const c=a;Reflect.set(s,c,t[c])})}),this.draw.render({isSetCursor:!1});const r=this.draw.getPainterOptions();(!r||!r.isDblclick)&&this.clearPainterStyle()}selectAll(){if(this.position.getPositionContext().isTable)this.draw.getTableOperate().tableSelectAll();else{const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}}mousemove(t){this.draw.isInteractionSuspended()||Ra(t,this)}mousedown(t){this.draw.isInteractionSuspended()||aa(t,this)}click(){this.draw.isInteractionSuspended()||tl&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||ca(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||da(t,this)}keydown(t){this.draw.isInteractionSuspended()||Ma(t,this)}dblclick(t){this.draw.isInteractionSuspended()||Rs.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||Rs.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||Ho(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await ya(this)}async copy(t){this.draw.isInteractionSuspended()||await Wa(this,t)}compositionstart(){this.draw.isInteractionSuspended()||_o.compositionstart(this)}compositionend(t){this.draw.isInteractionSuspended()||_o.compositionend(this,t)}compositionCancel(){this.draw.isInteractionSuspended()||_o.compositionCancel(this)}drop(t){this.draw.isInteractionSuspended()||ba(t,this)}dragover(t){this.draw.isInteractionSuspended()||va.dragover(t,this)}}const us={PAGE_SCALE:"pageScale"};class Ha{draw;options;cursor;canvasEvent;range;previewer;tableTool;hyperlinkParticle;control;dateParticle;imageParticle;dprMediaQueryList;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.canvasEvent=e,this.cursor=null,this.range=t.getRange(),this.previewer=t.getPreviewer(),this.tableTool=t.getTableTool(),this.hyperlinkParticle=t.getHyperlinkParticle(),this.dateParticle=t.getDateParticle(),this.imageParticle=t.getImageParticle(),this.control=t.getControl(),this.dprMediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)}register(){this.cursor=this.draw.getCursor(),this.addEvent()}addEvent(){window.addEventListener("blur",this.clearSideEffect),document.addEventListener("mousedown",this.clearSideEffect),document.addEventListener("mouseup",this.setCanvasEventAbility),document.addEventListener("wheel",this.setPageScale,{passive:!1}),document.addEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.addEventListener("change",this._handleDprChange)}removeEvent(){window.removeEventListener("blur",this.clearSideEffect),document.removeEventListener("mousedown",this.clearSideEffect),document.removeEventListener("mouseup",this.setCanvasEventAbility),document.removeEventListener("wheel",this.setPageScale),document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.removeEventListener("change",this._handleDprChange)}clearSideEffect=t=>{if(!this.cursor)return;if(this.draw.isInteractionSuspended()){this.resetSideEffect();return}const e=t?.composedPath?.()[0]||t.target;if(this.draw.isTargetInsideEditor(e)){this.watchCursorActive();return}this.resetSideEffect()};resetSideEffect=()=>{this.cursor&&(this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage())};setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)};watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{this.cursor?.getAgentIsActive()||this.cursor?.drawCursor({isFocus:!1,isBlink:!1})})}setPageScale=t=>{if(this.draw.isInteractionSuspended()||!this.draw.isTargetInsideEditor(t.target)||this.options.shortcutDisableKeys.includes(us.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const n=e*10+1;n<=30&&this.draw.setPageScale(n/10)}else{const n=e*10-1;n>=5&&this.draw.setPageScale(n/10)}};_handleVisibilityChange=()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}};_handleDprChange=()=>{this.draw.setPageDevicePixel()}}class _a{undoStack=[];redoStack=[];maxRecordCount;constructor(t){this.maxRecordCount=t.getOptions().historyMaxRecordCount+1}undo(){if(this.undoStack.length>1){const t=this.undoStack.pop();this.redoStack.push(t),this.undoStack.length&&this.undoStack[this.undoStack.length-1]()}}redo(){if(this.redoStack.length){const t=this.redoStack.pop();this.undoStack.push(t),t()}}execute(t){for(this.undoStack.push(t),this.redoStack.length&&(this.redoStack=[]);this.undoStack.length>this.maxRecordCount;)this.undoStack.shift()}isCanUndo(){return this.undoStack.length>1}isCanRedo(){return!!this.redoStack.length}isStackEmpty(){return!this.undoStack.length&&!this.redoStack.length}recovery(){this.undoStack=[],this.redoStack=[]}popUndo(){return this.undoStack.pop()}}class xa{cursorPosition;positionContext;positionList;floatPositionList;draw;eventBus;options;constructor(t){this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:i}=this.positionContext;return t[e].trList[n].tdList[i].positionList||[]}getPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalElementList()):this.getOriginalPositionList()}getMainPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalMainElementList()):this.positionList}getOriginalPositionList(){const t=this.draw.getZone();return t.isHeaderActive()?this.draw.getHeader().getPositionList():t.isFooterActive()?this.draw.getFooter().getPositionList():this.positionList}getOriginalMainPositionList(){return this.positionList}getSelectionPositionList(){const{startIndex:t,endIndex:e}=this.draw.getRange().getRange();return t===e?null:this.getPositionList().slice(t+1,e+1)}setPositionList(t){this.positionList=t}setFloatPositionList(t){this.floatPositionList=t}computePageRowPosition(t){const{positionList:e,rowList:n,pageNo:i,startX:r,startY:s,startRowIndex:a,startIndex:c,innerWidth:d,zone:R}=t,{scale:u,table:{tdPadding:h}}=this.options;let g=r,f=s,T=c;for(let p=0;p<n.length;p++){const m=n[p];if(!m.isSurround){const P=m.width+(m.offsetX||0);m.rowFlex===l.RowFlex.CENTER?g+=(d-P)/2:m.rowFlex===l.RowFlex.RIGHT&&(g+=d-P)}g+=m.offsetX||0,f+=m.offsetY||0;const I=g,L=f;for(let P=0;P<m.elementList.length;P++){const O=m.elementList[P],S=O.metrics,F=!O.hide&&(O.imgDisplay!==l.ImageDisplay.INLINE&&O.type===l.ElementType.IMAGE||O.type===l.ElementType.LATEX)?m.ascent-S.height:m.ascent;O.left&&(g+=O.left),O.translateX&&(g+=O.translateX*u);const N={pageNo:i,index:T,value:O.value,rowIndex:a+p,rowNo:p,metrics:S,left:O.left||0,ascent:F,lineHeight:m.height,isFirstLetter:P===0,isLastLetter:P===m.elementList.length-1,coordinate:{leftTop:[g,f],leftBottom:[g,f+m.height],rightTop:[g+S.width,f],rightBottom:[g+S.width,f+m.height]}};if(O.imgDisplay===l.ImageDisplay.SURROUND||O.imgDisplay===l.ImageDisplay.FLOAT_TOP||O.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM){const V=e[e.length-1];V&&(N.metrics=V.metrics,N.coordinate=V.coordinate),O.imgFloatPosition||(O.imgFloatPosition={x:g,y:f,pageNo:i}),this.floatPositionList.push({pageNo:i,element:O,position:N,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:T,zone:R})}if(e.push(N),T++,g+=S.width,O.type===l.ElementType.TABLE&&!O.hide){const V=O.tdPadding||h,Y=V[1]+V[3],X=V[0]+V[2];for(let b=0;b<O.trList.length;b++){const E=O.trList[b];for(let C=0;C<E.tdList.length;C++){const M=E.tdList[C];M.positionList=[];const y=M.rowList,W=this.computePageRowPosition({positionList:M.positionList,rowList:y,pageNo:i,startRowIndex:0,startIndex:0,startX:(M.x+V[3])*u+I+(O.translateX||0)*u,startY:(M.y+V[0])*u+L,innerWidth:(M.width-Y)*u,isTable:!0,index:T-1,tdIndex:C,trIndex:b,zone:R});if(M.verticalAlign===l.VerticalAlign.MIDDLE||M.verticalAlign===l.VerticalAlign.BOTTOM){const D=y.reduce((G,H)=>G+H.height,0),U=(M.height-X)*u-D,Q=M.verticalAlign===l.VerticalAlign.MIDDLE?U/2:U;Math.floor(Q)>0&&M.positionList.forEach(G=>{const{coordinate:{leftTop:H,leftBottom:j,rightBottom:st,rightTop:it}}=G;H[1]+=Q,j[1]+=Q,st[1]+=Q,it[1]+=Q})}g=W.x,f=W.y}}g=I,f=L}}g=r,f+=m.height}return{x:g,y:f,index:T}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),i=n[3],s=this.draw.getHeader().getExtraHeight(),a=n[0]+s;let c=0;for(let d=0;d<e.length;d++){const R=e[d];if(!R?.length)continue;const u=R[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:R,pageNo:d,startRowIndex:c,startIndex:u,startX:i,startY:a,innerWidth:t}),c+=R.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,i=[];return this.computePageRowPosition({positionList:i,innerWidth:n,rowList:[at(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),i}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.eventBus.emit("positionContextChange",{value:t,oldValue:this.positionContext}),this.positionContext=t}getPositionByXY(t){const{x:e,y:n,isTable:i}=t;let{elementList:r,positionList:s}=t;r||(r=this.draw.getOriginalElementList()),s||(s=this.getOriginalPositionList());const a=this.draw.getZone(),c=t.pageNo??this.draw.getPageNo(),d=a.isMainActive(),R=d?c:0;if(!i){const T=this.getFloatPositionByXY({...t,imgDisplays:[l.ImageDisplay.FLOAT_TOP,l.ImageDisplay.SURROUND]});if(T)return T}for(let T=0;T<s.length;T++){const{index:p,pageNo:m,left:I,isFirstLetter:L,coordinate:{leftTop:P,rightTop:O,leftBottom:S}}=s[T];if(R===m){if(m>R)break;if(P[0]-I<=e&&O[0]>=e&&P[1]<=n&&S[1]>=n){let F=T;const N=r[T];if(N.type===l.ElementType.TABLE)for(let Y=0;Y<N.trList.length;Y++){const X=N.trList[Y];for(let b=0;b<X.tdList.length;b++){const E=X.tdList[b],C=this.getPositionByXY({x:e,y:n,td:E,pageNo:c,tablePosition:s[T],isTable:!0,elementList:E.value,positionList:E.positionList});if(~C.index){const{index:M,hitLineStartIndex:y}=C,W=E.value[M];return{index:p,isCheckbox:C.isCheckbox||W.type===l.ElementType.CHECKBOX||W.controlComponent===l.ControlComponent.CHECKBOX,isRadio:W.type===l.ElementType.RADIO||W.controlComponent===l.ControlComponent.RADIO,isControl:!!W.controlId,isImage:C.isImage,isLabel:C.isLabel,isMacro:C.isMacro,isDirectHit:C.isDirectHit,isTable:!0,tdIndex:b,trIndex:Y,tdValueIndex:M,tdId:E.id,trId:X.id,tableId:N.id,hitLineStartIndex:y}}}}if(N.type===l.ElementType.IMAGE||N.type===l.ElementType.LATEX)return{index:F,isDirectHit:!0,isImage:!0};if(N.type===l.ElementType.MENSTRUAL_HISTORY)return{index:F,isDirectHit:!0};if(N.type===l.ElementType.FETAL_HEART_POSITION)return{index:F,isDirectHit:!0};if(N.type===l.ElementType.TOOTH_POSITION){const{scale:Y}=this.options,X=N.width*Y;return e>=P[0]&&e<=P[0]+X?{index:F,isDirectHit:!0}:{index:F}}if(N.type===l.ElementType.CHECKBOX||N.controlComponent===l.ControlComponent.CHECKBOX)return{index:F,isDirectHit:!0,isCheckbox:!0};if(N.type===l.ElementType.LABEL)return{index:F,isDirectHit:!0,isLabel:!0};if(N.type===l.ElementType.MACRO||N.type===l.ElementType.CUSTOM_MACRO||N.type===l.ElementType.REUSABLE_ITEM||N.type===l.ElementType.SUB_TEMPLATE)return{index:F,isDirectHit:!0,isMacro:!0};if(N.type===l.ElementType.TAB&&N.listStyle===l.ListStyle.CHECKBOX){let Y=F-1;for(;Y>0;){const X=r[Y];if(X.value===_&&X.listStyle===l.ListStyle.CHECKBOX)break;Y--}return{index:Y,isDirectHit:!0,isCheckbox:!0}}if(N.type===l.ElementType.RADIO||N.controlComponent===l.ControlComponent.RADIO)return{index:F,isDirectHit:!0,isRadio:!0};let V;if(r[p].value!==_){const Y=O[0]-P[0];e<P[0]+Y/2&&(F=T-1,L&&(V=T))}return{isDirectHit:!0,hitLineStartIndex:V,index:F,isControl:!!N.controlId}}}}if(!i){const T=this.getFloatPositionByXY({...t,imgDisplays:[l.ImageDisplay.FLOAT_BOTTOM]});if(T)return T}let u=!1,h=-1,g;if(i){const{scale:T}=this.options,{td:p,tablePosition:m}=t;if(p&&m){const{leftTop:I}=m.coordinate,L=p.x*T+I[0],P=p.y*T+I[1],O=p.width*T,S=p.height*T;if(!(L<e&&e<L+O&&P<n&&n<P+S))return{index:h}}}const f=s.filter(T=>T.isLastLetter&&T.pageNo===R);for(let T=0;T<f.length;T++){const{index:p,rowNo:m,coordinate:{leftTop:I,leftBottom:L}}=f[T];if(n>I[1]&&n<=L[1]){const P=s.findIndex(N=>N.pageNo===R&&N.rowNo===m),O=r[P],S=s[P],F=O.listStyle===l.ListStyle.CHECKBOX?this.draw.getMargins()[3]:S.coordinate.leftTop[0];if(e<F)~P?S.value===_?h=P:(h=P-1,g=P):h=p;else{if(O.listStyle===l.ListStyle.CHECKBOX&&e<I[0])return{index:P,isDirectHit:!0,isCheckbox:!0};h=p}u=!0;break}}if(!u){if(this.draw.getIsPagingMode()){const p=this.draw.getHeader(),m=p.getHeight(),I=p.getHeaderTop()+m,L=this.draw.getFooter(),O=this.draw.getHeight()-(L.getFooterBottom()+L.getHeight());if(d){if(n<I)return{index:-1,zone:l.EditorZone.HEADER};if(n>O)return{index:-1,zone:l.EditorZone.FOOTER}}else if(n<=O&&n>=I)return{index:-1,zone:l.EditorZone.MAIN}}const T=this.draw.getMargins();if(n<=T[0])for(let p=0;p<s.length;p++){const m=s[p];if(m.pageNo!==R||m.rowNo!==0)continue;const{leftTop:I,rightTop:L}=m.coordinate;if(e<=T[3]||e>=I[0]&&e<=L[0]||s[p+1]?.rowNo!==0)return{index:m.index}}else{const p=f[f.length-1];if(p){const m=p.rowNo;for(let I=0;I<s.length;I++){const L=s[I];if(L.pageNo!==R||L.rowNo!==m)continue;const{leftTop:P,rightTop:O}=L.coordinate;if(e<=T[3]||e>=P[0]&&e<=O[0]||s[I+1]?.rowNo!==m)return{index:L.index}}}}return{index:f[f.length-1]?.index||s.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!r[h]?.controlId}}getFloatPositionByXY(t){const{x:e,y:n}=t,i=t.pageNo??this.draw.getPageNo(),r=this.draw.getZone().getZone(),{scale:s}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:c,element:d,isTable:R,index:u,trIndex:h,tdIndex:g,tdValueIndex:f,zone:T,pageNo:p}=this.floatPositionList[a];if(i===p&&d.type===l.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!T||T===r)){const m=d.imgFloatPosition,I=m.x*s,L=m.y*s,P=d.width*s,O=d.height*s;if(e>=I&&e<=I+P&&n>=L&&n<=L+O)return R?{index:u,isDirectHit:!0,isImage:!0,isTable:R,trIndex:h,tdIndex:g,tdValueIndex:f,tdId:d.tdId,trId:d.trId,tableId:d.tableId}:{index:c.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==l.EditorMode.READONLY){const{index:p,isTable:m,trIndex:I,tdIndex:L,tdValueIndex:P}=e,O=this.draw.getControl(),{newIndex:S}=O.moveCursor({index:p,isTable:m,trIndex:I,tdIndex:L,tdValueIndex:P});m?e.tdValueIndex=S:e.index=S}const{index:n,isCheckbox:i,isRadio:r,isControl:s,isImage:a,isLabel:c,isDirectHit:d,isTable:R,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T}=e;return this.setPositionContext({isTable:R||!1,isCheckbox:i||!1,isRadio:r||!1,isControl:s||!1,isImage:a||!1,isLabel:c||!1,isDirectHit:d||!1,index:n,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T}),e}setSurroundPosition(t){const{scale:e}=this.options,{pageNo:n,row:i,rowElement:r,rowElementRect:s,surroundElementList:a,availableWidth:c}=t;let d=s.x,R=0;if(a.length&&!nn(r)&&!r.control?.minWidth)for(let u=0;u<a.length;u++){const h=a[u],g=h.imgFloatPosition;if(g.pageNo!==n)continue;const f={...g,x:g.x*e,y:g.y*e,width:h.width*e,height:h.height*e};if($r(s,f)){i.isSurround=!0;const T=f.width+f.x-s.x;if(r.left=T,i.width+=T,R+=T,d=f.x+f.width,i.width+r.metrics.width>c){r.left=0,i.width-=R;break}}}return{x:d,rowIncreaseWidth:R}}}class Ga{draw;options;range;listener;eventBus;position;historyManager;defaultStyle;lastRangeStyle;constructor(t){this.draw=t,this.options=t.getOptions(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null,this.lastRangeStyle=null}_isSameRangeStyle(t,e){if(!t||!["type","undo","redo","painter","font","size","bold","italic","underline","strikeout","deletePerson","color","highlight","rowFlex","vertical","rowMargin","level","listType","listStyle","textDecoration","extension"].every(c=>t[c]===e[c])||!(t.dashArray.length===e.dashArray.length&&t.dashArray.every((c,d)=>c===e.dashArray[d])))return!1;const s=t.groupIds||[],a=e.groupIds||[];return s.length===a.length&&s.every((c,d)=>c===a[d])}_emitRangeStyle(t){this._isSameRangeStyle(this.lastRangeStyle,t)||(this.lastRangeStyle={...t,dashArray:[...t.dashArray],groupIds:t.groupIds?[...t.groupIds]:null},this.listener.rangeStyleChange?.(t),this.eventBus.isSubscribe("rangeStyleChange")&&this.eventBus.emit("rangeStyleChange",t))}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}setDefaultStyle(t){t?this.defaultStyle={...this.defaultStyle,...t}:this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=je(t,e);return n?{...n,...this.defaultStyle}:null}getIsRangeChange(t,e,n,i,r,s,a){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==i||this.range.endTdIndex!==r||this.range.startTrIndex!==s||this.range.endTrIndex!==a}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getIsSelection(){const{startIndex:t,endIndex:e}=this.range;return!~t&&!~e?!1:t!==e}getSelection(){const{startIndex:t,endIndex:e,splitTdRange:n}=this.range;if(t===e)return null;if(n)return this.draw.getSplitTdValues(n.originalId).slice(n.startIndex+1,n.endIndex+1);const i=this.draw.getElementList();return i.slice(i[t]?.value===_?t:t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let n=0;n<t.length;n++){const i=t[n];for(let r=0;r<i.length;r++){const s=i[r];e.push(...s.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||$t.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||$t.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=new Map;for(let r=t;r<e+1;r++){const{pageNo:s,rowNo:a}=n[r],c=i.get(s);c?c.has(a)||c.add(a):i.set(s,new Set([a]))}return i}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const i=this.getRangeRow();if(!i)return null;const r=this.position.getPositionList(),s=this.draw.getElementList(),a=[];for(let c=0;c<r.length;c++){const d=r[c],R=i.get(d.pageNo);R&&R.has(d.rowNo)&&a.push(s[c])}return a}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=this.draw.getElementList(),r=new Map;let s=t;for(;s>=0;){const{pageNo:d,rowNo:R}=n[s];let u=r.get(d);u||(u=[],r.set(d,u)),u.includes(R)||u.unshift(R);const h=i[s],g=i[s-1];if(h.value===_&&!h.listWrap||h.listId!==g?.listId||h.titleId!==g?.titleId)break;s--}const a=t===e;if(!a){let d=t+1;for(;d<e;){const{pageNo:R,rowNo:u}=n[d];let h=r.get(R);h||(h=[],r.set(R,h)),h.includes(u)||h.push(u),d++}}let c=e;for(a&&i[t].value===_&&(c+=1);c<n.length;){const d=i[c],R=i[c+1];if(d.value===_&&!d.listWrap||d.listId!==R?.listId||d.titleId!==R?.titleId)break;const{pageNo:u,rowNo:h}=n[c];let g=r.get(u);g||(g=[],r.set(u,g)),g.includes(h)||g.push(h),c++}return r}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const i=[],r=this.getRangeParagraph();if(!r)return null;const s=this.draw.getElementList(),a=this.position.getPositionList();for(let c=0;c<a.length;c++){const d=a[c],R=r.get(d.pageNo);R&&R.includes(d.rowNo)&&(~n||(n=d.index),i.push(s[c]))}return i.length?{elementList:i,startIndex:n}:null}getRangeParagraphElementList(){return this.getRangeParagraphInfo()?.elementList||null}getRangeTableElement(){const t=this.position.getPositionContext();return t.isTable?this.draw.getOriginalElementList()[t.index]:null}getIsSelectAll(){const t=this.draw.getElementList(),{startIndex:e,endIndex:n}=this.range;return e===0&&t.length-1===n&&!this.position.getPositionContext().isTable}getIsPointInRange(t,e,n){const{startIndex:i,endIndex:r}=this.range,s=this.position.getPositionList();for(let a=i+1;a<=r&&s[a];a++){const{coordinate:{leftTop:d,rightBottom:R},pageNo:u}=s[a];if(n===u&&t>=d[0]&&t<=R[0]&&e>=d[1]&&e<=R[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const r of e){const s=n.get(r.groupId);if(s)s.endIndex+=1;else{const{type:a,groupId:c,tableId:d,index:R,tdIndex:u,trIndex:h}=r,g={startIndex:R,endIndex:R};a===ge.TABLE&&(g.tableId=d,g.startTdIndex=u,g.endTdIndex=u,g.startTrIndex=h,g.endTrIndex=h),n.set(c,g)}}const i=[];return n.forEach(r=>{i.push(r)}),i}getIsCanInput(){const{range:{startIndex:t,endIndex:e},elementList:n}=this.getRangeElement(),i=n[t];if(!i)return!1;if(t===e)return(i.controlComponent!==l.ControlComponent.PRE_TEXT||n[t+1]?.controlComponent!==l.ControlComponent.PRE_TEXT)&&i.controlComponent!==l.ControlComponent.POST_TEXT;const r=n[e];return r?!i.controlId&&!r.controlId||(!i.controlId||i.controlComponent===l.ControlComponent.POSTFIX)&&(!r.controlId||r.controlComponent===l.ControlComponent.POSTFIX)||!!i.controlId&&r.controlId===i.controlId&&r.controlComponent!==l.ControlComponent.PRE_TEXT&&r.controlComponent!==l.ControlComponent.POST_TEXT&&r.controlComponent!==l.ControlComponent.POSTFIX:!1}setRange(t,e,n,i,r,s,a,c){this.getIsRangeChange(t,e,n,i,r,s,a)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=i,this.range.endTdIndex=r,this.range.startTrIndex=s,this.range.endTrIndex=a,this.range.isCrossRowCol=!!(i||r||s||a),this.range.splitTdRange=c,this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const R=this.draw.getControl();if(~t&&~e&&!!this.draw.getElementList()[t]?.controlId){R.initControl();return}R.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:r}=this.range;if(!~n&&!~i)return;let s;if(r){const y=this.draw.getOriginalElementList(),W=this.position.getPositionContext();s=y[W.index]}else{const y=~i?i:0,W=this.draw.getElementList();s=this.getRangeAnchorStyle(W,y)}if(!s)return;const a=this.getSelection()||[s],c=s.type||l.ElementType.TEXT,d=s.font||this.options.defaultFont,R=s.size||this.options.defaultSize,u=!~a.findIndex(y=>!y.bold),h=!~a.findIndex(y=>!y.italic),g=!~a.findIndex(y=>!y.underline&&!y.control?.underline),f=!~a.findIndex(y=>!y.strikeout),T=s.color||null,p=s.highlight||null,m=s.rowFlex||null,I=s.vertical||null,L=s.rowMargin??this.options.defaultRowMargin,P=s.dashArray||[],O=s.level||null,S=s.listType||null,F=s.listStyle||null,N=g&&s.textDecoration||null,V=!!this.draw.getPainterStyle(),Y=this.historyManager.isCanUndo(),X=this.historyManager.isCanRedo(),b=s.groupIds||null,E=s.extension??null,C=s.deletePerson??"",M={type:c,undo:Y,redo:X,painter:V,font:d,size:R,bold:u,italic:h,underline:g,strikeout:f,deletePerson:C,color:T,highlight:p,rowFlex:m,vertical:I,rowMargin:L,dashArray:P,level:O,listType:S,listStyle:F,groupIds:b,textDecoration:N,extension:E};this._emitRangeStyle(M)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,i=this.options.defaultSize,r=this.options.defaultRowMargin,s=!!this.draw.getPainterStyle(),a=this.historyManager.isCanUndo(),c=this.historyManager.isCanRedo(),R={type:null,undo:a,redo:c,painter:s,font:n,size:i,bold:!1,italic:!1,underline:!1,strikeout:!1,deletePerson:"123",color:null,highlight:null,rowFlex:null,rowMargin:r,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null,vertical:null};this._emitRangeStyle(R)}shrinkBoundary(t={}){const{elementList:e,range:n}=this.getRangeElement(t),{startIndex:i,endIndex:r}=n;if(!~i&&!~r)return;const s=e[i],a=e[r];if(i===r){if(s.controlComponent===l.ControlComponent.PLACEHOLDER){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId===s.controlId&&(d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)){n.startIndex=c,n.endIndex=c;break}if(d.controlId!==s.controlId&&!d.originControlId)break;c--}}if(s.controlComponent===l.ControlComponent.TEXTFIXLABEL){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId!==s.controlId||d.controlComponent===l.ControlComponent.VALUE||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;break}c--}}}else{if(s.controlComponent===l.ControlComponent.PLACEHOLDER||a.controlComponent===l.ControlComponent.PLACEHOLDER||s.controlComponent===l.ControlComponent.TEXTFIXLABEL||a.controlComponent===l.ControlComponent.TEXTFIXLABEL){let c=r-1;for(;c>0;){const d=e[c];if(d.controlId!==a.controlId||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;return}c--}}if(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PRETEXTFIX||s.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==s.controlId||d.controlComponent===l.ControlComponent.VALUE){n.startIndex=c-1;break}else if(d.controlComponent===l.ControlComponent.PLACEHOLDER){n.startIndex=c-1,n.endIndex=c-1;return}c++}}if(a.controlComponent!==l.ControlComponent.VALUE){let c=r-1;for(;c>0;){const d=e[c];if(d.controlId!==s.controlId||d.controlComponent===l.ControlComponent.VALUE){n.endIndex=c;break}else if(d.controlComponent===l.ControlComponent.PLACEHOLDER){n.startIndex=c,n.endIndex=c;return}c--}}}}render(t,e,n,i,r){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,i,r),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(_,"g"),""):""}getRangeElement(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{splitTdRange:i}=n,r={elementList:e,range:n};return i&&(r.range=i,r.elementList=this.draw.getSplitTdValues(i.originalId)??[]),r}}class Aa{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,i){t.save(),t.fillStyle=e,t.fillRect(0,0,n,i),t.restore()}_drawImage(t,e,n,i){const{background:r,scale:s}=this.options;if(r.size===l.BackgroundSize.CONTAIN){const a=e.width*s,c=e.height*s;if(!r.repeat||r.repeat===l.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,a,c);else{let d=0,R=0;const u=r.repeat===l.BackgroundRepeat.REPEAT||r.repeat===l.BackgroundRepeat.REPEAT_X?Math.ceil(n*s/a):1,h=r.repeat===l.BackgroundRepeat.REPEAT||r.repeat===l.BackgroundRepeat.REPEAT_Y?Math.ceil(i*s/c):1;for(let g=0;g<u;g++){for(let f=0;f<h;f++)t.drawImage(e,d,R,a,c),R+=c;R=0,d+=a}}}else t.drawImage(e,0,0,n*s,i*s)}_renderBackgroundImage(t,e,n){const{background:i}=this.options,r=this.imageCache.get(i.image);if(r)this._drawImage(t,r,e,n);else{const s=new Image;s.setAttribute("crossOrigin","Anonymous"),s.src=i.image,s.onload=()=>{this.imageCache.set(i.image,s),this._drawImage(t,s,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:i,applyPageNumbers:r}}=this.options;if(n&&(!r?.length||r.includes(e))){const{width:s,height:a}=this.options;this._renderBackgroundImage(t,s,a)}else{const s=this.draw.getCanvasWidth(e),a=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,i,s,a)}}}class xo{fillRect;fillColor;fillDecorationStyle;constructor(){this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,i,r,s,a){const c=!this.fillRect.width;if(!c&&(this.fillColor!==s||this.fillDecorationStyle!==a)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,i,r,s,a);return}c&&(this.fillRect.x=e,this.fillRect.y=n),r&&this.fillRect.height<r&&(this.fillRect.height=r),this.fillRect.width+=i,this.fillColor=s,this.fillDecorationStyle=a}}class ka extends xo{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:i,width:r,height:s}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,i,r,s),t.restore(),this.clearFillInfo()}}class Ja{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:i}=this.options,r=this.draw.getWidth(),s=i===l.PageMode.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),a=this.draw.getMargins(),c=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=n,t.beginPath();const d=[a[3],a[0]],R=[r-a[1],a[0]],u=[a[3],s-a[2]],h=[r-a[1],s-a[2]];t.moveTo(d[0]-c,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-c),t.moveTo(R[0]+c,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]-c),t.moveTo(u[0]-c,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]+c),t.moveTo(h[0]+c,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+c),t.stroke(),t.restore()}}class Ba{draw;options;position;range;searchKeyword;searchNavigateIndex;searchOptions;searchMatchList;constructor(t){this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.searchNavigateIndex=null,this.searchOptions=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t,e){this.searchKeyword=t,this.searchNavigateIndex=null,this.searchOptions=e||null}searchNavigatePre(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex-1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===n)return null;this.searchNavigateIndex=this.searchMatchList.length-1-(this.searchKeyword.length-1)}}return this.searchNavigateIndex}searchNavigateNext(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex+1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===n)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:n,rightTop:i},pageNo:r}=t,s=this.draw.getHeight(),a=this.draw.getPageGap(),c=r*(s+a),d=document.createElement("div");d.style.position="absolute";const R=50;d.style.width=`${i[0]-e[0]+R}px`,d.style.height=`${n[1]-e[1]+R}px`,d.style.left=`${e[0]}px`,d.style.top=`${e[1]+c}px`,this.draw.getContainer().append(d),d.scrollIntoView(!1),d.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let i=0;i<this.searchMatchList.length;i++){const r=this.searchMatchList[i];n!==r.groupId&&(n=r.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:i=!0}=this.searchOptions||{},r=i?t.toLocaleLowerCase():t,s=[],a=[],c=e.length,d=[];for(let g=0;g<c;g++)e[g].type===l.ElementType.TABLE&&d.push(g);let R=0,u=0;for(;u<c-1;){const g=d.length?d[R]:c,f=e.slice(u,g);f.length&&a.push({index:u,type:ge.PAGE,elementList:f});const T=e[g];T&&a.push({index:g,type:ge.TABLE,elementList:[T]}),u=g+1,R++}function h(g,f,T,p){if(!g)return;let m=T.map(S=>!S.type||$t.includes(S.type)&&S.controlComponent!==l.ControlComponent.CHECKBOX&&S.controlComponent!==l.ControlComponent.RADIO&&!S.hide&&!S.control?.hide&&!S.area?.hide?S.value:_).filter(Boolean).join("");i&&(m=m.toLocaleLowerCase());const I=[],L=n?new RegExp(g):g;let{index:P,length:O}=wi(m,L);for(;P!==-1&&O!==0;){I.push({index:P,length:O});const S=wi(m,L,P+O);P=S.index,O=S.length}for(let S=0;S<I.length;S++){const{index:F,length:N}=I[S],V=lt();for(let Y=0;Y<N;Y++){const X=F+Y+(p?.startIndex||0);s.push({type:f,index:X,groupId:V,...p})}}}for(let g=0;g<a.length;g++){const f=a[g];if(f.type===ge.TABLE){const T=f.elementList[0];for(let p=0;p<T.trList.length;p++){const m=T.trList[p];for(let I=0;I<m.tdList.length;I++){const L=m.tdList[I],P={tableId:T.id,tableIndex:f.index,trIndex:p,tdIndex:I,tdId:L.id};h(r,f.type,L.value,P)}}}else h(r,f.type,f.elementList,{startIndex:f.index})}return s}compute(t){const e=this.searchOptions?.isLimitSelection&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!n?.length||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:i}=this.range.getRange(),r=i+1;for(const s of this.searchMatchList)s.type===ge.TABLE?s.tableIndex+=r:s.index+=r}render(t,e){if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:i,searchNavigateMatchColor:r}=this.options,s=this.position.getOriginalPositionList(),a=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let c=0;c<this.searchMatchList.length;c++){const d=this.searchMatchList[c];let R=null;if(d.type===ge.TABLE){const{tableIndex:P,trIndex:O,tdIndex:S,index:F}=d;R=a[P]?.trList[O].tdList[S]?.positionList[F]}else R=s[d.index];if(!R)continue;const{coordinate:{leftTop:u,leftBottom:h,rightTop:g},pageNo:f}=R;if(f!==e)continue;if(this.getSearchNavigateIndexList().includes(c)){t.fillStyle=r;const P=this.searchMatchList[c-1];(!P||P.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(R)}else t.fillStyle=i;const p=u[0],m=u[1],I=g[0]-u[0],L=h[1]-u[1];t.fillRect(p,m,I,L)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const r=e?.index;if(Mo(r)){const T=[];i.forEach(p=>{const m=T[T.length-1];!m||m[0].groupId!==p.groupId?T.push([p]):m.push(p)}),i=T[r]}if(!i?.length)return;const s=this.draw.isDesignMode();let a=0,c=0,d="",R="",u=-1;const h=this.draw.getOriginalElementList();for(let T=0;T<i.length;T++){const p=i[T];if(p.type===ge.TABLE){const{tableIndex:m,trIndex:I,tdIndex:L,index:P,tdId:O}=p;R&&O!==R&&(c=0),R=O;const S=m+a,F=h[S].trList[I].tdList[L].value,N=P+c,V=F[N];if(!s&&(V?.control?.deletable===!1||V?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(F,N,1),c--,~u||(u=T);continue}if(d===p.groupId){this.draw.spliceElementList(F,N,1),c--;continue}~u||(u=T);for(let Y=0;Y<t.length;Y++){const X=t[Y];Y===0?V.value=X:(this.draw.spliceElementList(F,N+Y,0,[{...V,value:X}]),c++)}}else{const m=p.index+a,I=h[m];if(!s&&(I?.control?.deletable===!1||I?.title?.deletable===!1)||I.type===l.ElementType.CONTROL&&I.controlComponent!==l.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,m,1),a--,~u||(u=T);continue}if(~u||(u=T),d===p.groupId){this.draw.spliceElementList(h,m,1),a--;continue}for(let L=0;L<t.length;L++){const P=t[L];L===0?I.value=P:(this.draw.spliceElementList(h,m+L,0,[{...I,value:P}]),a++)}}d=p.groupId}if(!~u)return;const g=i[u],f=g.index+(t.length-1);if(g.type===ge.TABLE){const{tableIndex:T,trIndex:p,tdIndex:m,index:I}=g,L=h[T].trList[p].tdList[m].value[I];this.position.setPositionContext({isTable:!0,index:T,trIndex:p,tdIndex:m,tdId:L.tdId,trId:L.trId,tableId:L.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(f,f),this.draw.render({curIndex:f})}}class $a extends xo{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:i,y:r,width:s}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const a=r-3;t.beginPath(),t.moveTo(i,a),t.lineTo(i+s,a),t.stroke(),t.beginPath(),t.moveTo(i,r+3.5),t.lineTo(i+s,r+3.5),t.stroke(),t.restore(),this.clearFillInfo()}}l.TextDecorationStyle=void 0,(function(o){o.SOLID="solid",o.DOUBLE="double",o.DASHED="dashed",o.DOTTED="dotted",o.WAVY="wavy"})(l.TextDecorationStyle||(l.TextDecorationStyle={}));var on;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(on||(on={}));class za extends xo{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,r){const s=e+i;switch(t.beginPath(),r){case on.DASHED:t.setLineDash([3,1]);break;case on.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(s,n),t.stroke()}_drawDouble(t,e,n,i){const s=e+i,a=n+3*this.options.scale;this.options.mode===l.EditorMode.PRINT?t.strokeStyle="transparent":t.strokeStyle="red",t.beginPath(),t.moveTo(e,n),t.lineTo(s,n),t.stroke(),t.beginPath(),t.moveTo(e,a),t.lineTo(s,a),t.stroke()}_drawWave(t,e,n,i){const{scale:r}=this.options,s=1.2*r,a=1/r,c=n+2*s;t.beginPath();for(let d=0;d<i;d++){const R=s*Math.sin(a*d);t.lineTo(e+d,c+R)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:r,width:s}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const a=Math.floor(r+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case l.TextDecorationStyle.WAVY:this._drawWave(t,i,a,s);break;case l.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,a,s);break;case l.TextDecorationStyle.DASHED:this._drawLine(t,i,a,s,on.DASHED);break;case l.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,s,on.DOTTED);break;default:this._drawLine(t,i,a,s);break}t.restore(),this.clearFillInfo()}}class ja{draw;options;ctx;curX;curY;text;curStyle;curColor;cacheMeasureText;constructor(t){this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureBasisWord(t,e){t.save(),t.font=e;const n=this.measureText(t,{value:Yr});return t.restore(),n}measureWord(t,e,n){const i=this.draw.getLetterReg();let r=0,s=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==l.ElementType.TEXT||!i.test(c.value)){s=c;break}r+=this.measureText(t,c).width,a++}return{width:r,endElement:s}}buttonMeasureWord(t,e,n){const i=this.draw.getLetterReg();let r=0,s=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==l.ElementType.TEXT||!i.test(c.value)){s=c;break}r+=this.measureText(t,c).width,a++}return{width:r,endElement:s}}measurePunctuationWidth(t,e){return!e||!Vr.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const s=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:s.actualBoundingBoxAscent,actualBoundingBoxDescent:s.actualBoundingBoxDescent,actualBoundingBoxLeft:s.actualBoundingBoxLeft,actualBoundingBoxRight:s.actualBoundingBoxRight,fontBoundingBoxAscent:s.fontBoundingBoxAscent,fontBoundingBoxDescent:s.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,i=this.cacheMeasureText.get(n);if(i)return i;const r=t.measureText(e.value);return this.cacheMeasureText.set(n,r),r}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,i){if(this.ctx=t,this.options.renderMode===l.RenderMode.COMPATIBILITY){this._setCurXY(n,i),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,i),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,i)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color}_setCurXY(t,e){this.curX=t,this.curY=e}_render(){!this.text||!~this.curX||!~this.curX||(this.ctx.save(),this.ctx.font=this.curStyle,this.ctx.fillStyle=this.curColor||this.options.defaultColor,this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}class sn{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const r=i===l.NumberType.CHINESE?Ar(e):`${e}`;return t.replace(n,r)}render(t,e){const{scale:n,pageNumber:{size:i,font:r,color:s,rowFlex:a,numberType:c,format:d,startPageNo:R,fromPageNo:u}}=this.options;if(e<u)return;let h=d;const g=new RegExp(pn.PAGE_NO);g.test(h)&&(h=sn.formatNumberPlaceholder(h,e+R-u,g,c));const f=new RegExp(pn.PAGE_COUNT);f.test(h)&&(h=sn.formatNumberPlaceholder(h,this.draw.getPageCount()-u,f,c));const T=this.draw.getWidth(),p=this.draw.getHeight(),m=this.draw.getPageNumberBottom(),I=p-m;t.save(),t.fillStyle=s,t.font=`${i*n}px ${r}`;let L=0;const P=this.draw.getMargins(),{width:O}=t.measureText(h);a===l.RowFlex.CENTER?L=(T-O)/2:a===l.RowFlex.RIGHT?L=T-O-P[1]:L=P[3],t.fillText(h,L,I),t.restore()}}class qa{draw;options;scrollContainer;constructor(t){this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,i=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:i>0?i:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,i=0;for(let r=0;r<t.length;r++){const s=t[r],{intersectionHeight:a}=this.getElementVisibleInfo(s);if(i&&!a)break;a&&e.push(r),a>i&&(i=a,n=r)}return{intersectionPageNo:n,visiblePageNoList:e}}_observer=Kr(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150)}class tc{draw;step=5;thresholdPoints=[70,40,10,20];selectionContainer;rangeManager;requestAnimationFrameId;isMousedown;isMoving;clientWidth;clientHeight;containerRect;constructor(t){this.draw=t,this.rangeManager=t.getRange();const{scrollContainerSelector:e}=t.getOptions();this.selectionContainer=e&&document.querySelector(e)||document,this.requestAnimationFrameId=null,this.isMousedown=!1,this.isMoving=!1,this.clientWidth=0,this.clientHeight=0,this.containerRect=null,this._addEvent()}_addEvent(){const t=this.selectionContainer;t.addEventListener("mousedown",this._mousedown),t.addEventListener("mousemove",this._mousemove),t.addEventListener("mouseup",this._mouseup),document.addEventListener("mouseleave",this._mouseup)}removeEvent(){const t=this.selectionContainer;t.removeEventListener("mousedown",this._mousedown),t.removeEventListener("mousemove",this._mousemove),t.removeEventListener("mouseup",this._mouseup),document.removeEventListener("mouseleave",this._mouseup)}_mousedown=t=>{if(this.draw.isInteractionSuspended()){this._mouseup();return}if(!this.draw.isTargetInsideEditor(t.target)){this._mouseup();return}if(this.isMousedown=!0,this.clientWidth=this.selectionContainer instanceof Document?document.documentElement.clientWidth:this.selectionContainer.clientWidth,this.clientHeight=this.selectionContainer instanceof Document?document.documentElement.clientHeight:this.selectionContainer.clientHeight,!(this.selectionContainer instanceof Document)){const e=this.selectionContainer.getBoundingClientRect();this.containerRect=e}};_mouseup=()=>{this.isMousedown=!1,this._stopMove()};_mousemove=t=>{if(this.draw.isInteractionSuspended()||!this.isMousedown||this.rangeManager.getIsCollapsed())return;let{x:e,y:n}=t;this.containerRect&&(e=e-this.containerRect.x,n=n-this.containerRect.y),n<this.thresholdPoints[0]?this._startMove(Zt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Zt.DOWN):e<this.thresholdPoints[2]?this._startMove(Zt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Zt.RIGHT):this._stopMove()};_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Zt.DOWN?e.scrollTo(n,i+this.step):t===Zt.UP?e.scrollTo(n,i-this.step):t===Zt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class ec{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=at(t);for(let n=0;n<t.length;n++){const i=e[n];for(let r=i.tdList.length-1;r>=0;r--){const s=i.tdList[r],{rowspan:a,rowIndex:c,colIndex:d}=s,R=c+a-1;if(R!==r){const u=i.tdList.splice(r,1)[0];e[R]?.tdList.splice(d,0,u)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:r,startTdIndex:s,endTdIndex:a,startTrIndex:c,endTrIndex:d}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!r)return[[h[n].tdList[i]]];let g=h[c].tdList[s],f=h[d].tdList[a];(g.x>f.x||g.y>f.y)&&([g,f]=[f,g]);const T=g.colIndex,p=f.colIndex+(f.colspan-1),m=g.rowIndex,I=f.rowIndex+(f.rowspan-1),L=[];for(let P=0;P<h.length;P++){const O=h[P],S=[];for(let F=0;F<O.tdList.length;F++){const N=O.tdList[F],V=N.colIndex,Y=N.rowIndex;V>=T&&V<=p&&Y>=m&&Y<=I&&S.push(N)}S.length&&L.push(S)}return L.length?L:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:r,height:s,isDrawFullBorder:a,borderExternalWidth:c}=t,{scale:d}=this.options,R=e.lineWidth;c&&(e.lineWidth=c*d),e.beginPath();const u=Math.round(n),h=Math.round(i);e.translate(.5,.5),a?e.rect(u,h,r,s):(e.moveTo(u,h+s),e.lineTo(u,h),e.lineTo(u+r,h)),e.stroke(),c&&(e.lineWidth=R),e.translate(-.5,-.5)}_drawSlash(t,e,n,i){const{scale:r}=this.options;t.save();const s=e.width*r,a=e.height*r,c=Math.round(e.x*r+n),d=Math.round(e.y*r+i);e.slashTypes?.includes(l.TdSlash.FORWARD)&&(t.moveTo(c+s,d),t.lineTo(c,d+a)),e.slashTypes?.includes(l.TdSlash.BACK)&&(t.moveTo(c,d),t.lineTo(c+s,d+a)),t.stroke(),t.restore()}_drawBorder(t,e,n,i){const{colgroup:r,trList:s,borderType:a,borderColor:c,borderWidth:d=1,borderExternalWidth:R}=e;if(!r||!s)return;const{scale:u,table:{defaultBorderColor:h}}=this.options,g=e.width*u,f=e.height*u,T=a===l.TableBorder.EMPTY,p=a===l.TableBorder.EXTERNAL,m=a===l.TableBorder.INTERNAL;t.save(),a===l.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*u,t.strokeStyle=c||h,!T&&!m&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:f,borderExternalWidth:R,isDrawFullBorder:p});for(let I=0;I<s.length;I++){const L=s[I];for(let P=0;P<L.tdList.length;P++){const O=L.tdList[P];if(O.slashTypes?.length&&this._drawSlash(t,O,n,i),!O.borderTypes?.length&&(T||p))continue;const S=O.width*u,F=O.height*u,N=Math.round(O.x*u+n+S),V=Math.round(O.y*u+i);if(t.translate(.5,.5),t.beginPath(),O.borderTypes?.includes(l.TdBorder.TOP)&&(t.moveTo(N-S,V),t.lineTo(N,V),t.stroke()),O.borderTypes?.includes(l.TdBorder.RIGHT)&&(t.moveTo(N,V),t.lineTo(N,V+F),t.stroke()),O.borderTypes?.includes(l.TdBorder.BOTTOM)&&(t.moveTo(N,V+F),t.lineTo(N-S,V+F),t.stroke()),O.borderTypes?.includes(l.TdBorder.LEFT)&&(t.moveTo(N-S,V),t.lineTo(N-S,V+F),t.stroke()),!T&&!p){if((!m||O.colIndex+O.colspan<r.length)&&(t.moveTo(N,V),t.lineTo(N,V+F),R&&R!==d&&O.colIndex+O.colspan===r.length)){const Y=t.lineWidth;t.lineWidth=R*u,t.stroke(),t.beginPath(),t.lineWidth=Y}if(!m||O.rowIndex+O.rowspan<s.length){const Y=R&&R!==d&&O.rowIndex+O.rowspan===s.length;if(Y&&(t.stroke(),t.beginPath()),t.moveTo(N,V+F),t.lineTo(N-S,V+F),Y){const X=t.lineWidth;t.lineWidth=R*u,t.stroke(),t.beginPath(),t.lineWidth=X}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:r}=e;if(!r)return;const{scale:s}=this.options;for(let a=0;a<r.length;a++){const c=r[a];for(let d=0;d<c.tdList.length;d++){const R=c.tdList[d];if(!R.backgroundColor)continue;t.save();const u=R.width*s,h=R.height*s,g=Math.round(R.x*s+n),f=Math.round(R.y*s+i);t.fillStyle=R.backgroundColor,t.fillRect(g,f,u,h),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return e?.length?this.getTdListByColIndex(e,0).reduce((n,i)=>n+i.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,i)=>n+i.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let s=0;s<r.length;s++){const a=r[s],c=a.colIndex,d=c+a.colspan-1;e>=c&&e<=d&&n.push(a)}}return n}getTdListByRowIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let s=0;s<r.length;s++){const a=r[s],c=a.rowIndex,d=c+a.rowspan-1;e>=c&&e<=d&&n.push(a)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let i=0;for(let r=0;r<n.length;r++){const s=n[r],a=n.length-1===r;for(let c=0;c<s.tdList.length;c++){const d=s.tdList[c];let R=0;if(n.length>1&&r!==0){const m=s.tdList[c-1],I=m?m.colIndex+m.colspan:c;for(let L=I;L<e.length;L++)if(this.getRowCountByColIndex(n.slice(0,r),L)===r){R=L;let O=0;for(let S=0;S<L;S++)O+=e[S].width;i=O;break}}else{const m=s.tdList[c-1];m&&(R=m.colIndex+m.colspan)}let u=0;for(let m=0;m<d.colspan;m++)u+=e[m+R].width;let h=0;for(let m=0;m<d.rowspan;m++){const I=n[m+r]||n[r];h+=I.height}const g=s.tdList.length-1===c;let f=a;if(!f&&d.rowspan>1){const m=n.length-1-r;f=d.rowspan-1===m}const T=a&&g;d.isLastRowTd=g,d.isLastColTd=f,d.isLastTd=T,d.x=i;let p=0;for(let m=0;m<r;m++){const I=n[m].tdList;for(let L=0;L<I.length;L++){const P=I[L];if(R>=P.colIndex&&R<P.colIndex+P.colspan){p+=P.height;break}}}d.y=p,d.width=u,d.height=h,d.rowIndex=r,d.colIndex=R,d.trIndex=r,d.tdIndex=c,i+=u,g&&!T&&(i=0)}}}drawRange(t,e,n,i){const{scale:r,rangeAlpha:s,rangeColor:a}=this.options,{type:c,trList:d}=e;if(!d||c!==l.ElementType.TABLE)return;const{isCrossRowCol:R,startTdIndex:u,endTdIndex:h,startTrIndex:g,endTrIndex:f}=this.range.getRange();if(!R)return;let T=d[g].tdList[u],p=d[f].tdList[h];(T.x>p.x||T.y>p.y)&&([T,p]=[p,T]);const m=T.colIndex,I=p.colIndex+(p.colspan-1),L=T.rowIndex,P=p.rowIndex+(p.rowspan-1);t.save();for(let O=0;O<d.length;O++){const S=d[O];for(let F=0;F<S.tdList.length;F++){const N=S.tdList[F],V=N.colIndex,Y=N.rowIndex;if(V>=m&&V<=I&&Y>=L&&Y<=P){const X=N.x*r,b=N.y*r,E=N.width*r,C=N.height*r;t.globalAlpha=s,t.fillStyle=a,t.fillRect(X+n,b+i,E,C)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}findPreRowSpanTd(t,e,n){for(let i=e;i>=0;i--){const r=t[i].tdList.find(s=>s.colIndex===n);if(r)return r}}computeTrHeight(t,e){const{scale:n,table:{tdPadding:i,defaultTrMinHeight:r}}=this.options,s=t.tdPadding||i,a=s[0]+s[2],c=t.trList;for(let u=0;u<c.length;u++){const h=c[u];h.height=h.minHeight||r,h.minHeight=h.height}this.computeRowColInfo(t);const d={},R={};for(let u=0;u<c.length;u++){const h=c[u];if(!h.tdList.length){h.height=0;continue}const g=[],f=[];for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(I=>I.colIndex===p);if(m){const I=e?e(m):m.rowList,L=I.reduce((O,S)=>O+S.height,0);m.rowList=I;const P=L/n+a;m.mainHeight=P,m.rowspan>1?(R[m.colIndex]=m.id,d[m.id]={td:m,rowSpan:[u,u+m.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:P},f.push(P)):m.height<P?(m.height=P,m.realHeight=P,g.push(P)):g.push(m.height)}else{const I=d[R[p]];I?.rowSpan[1]==u&&g.push(I.extraHeight)}}const T=Math.max(...g.length?g:f);Object.values(d).forEach(p=>{p.rowSpan[0]<=u&&p.rowSpan[1]>=u&&(p.extraHeight-=T,p.preHeight+=T,p.preMinHeight+=h.minHeight)}),h.height=T;for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(I=>I.colIndex===p)??this.findPreRowSpanTd(c,u,p);if(m){const I=d[m.id]?.preHeight??0,L=d[m.id]?.preMinHeight??h.minHeight;m.height=T+I,m.realHeight=T+I,m.realMinHeight=L}}}this.computeRowColInfo(t)}}var Te;(function(o){o.ROW="row",o.COL="col"})(Te||(Te={}));class nc{MIN_TD_WIDTH=20;ROW_COL_OFFSET=18;ROW_COL_QUICK_WIDTH=16;ROW_COL_QUICK_OFFSET=5;ROW_COL_QUICK_POSITION=this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2;BORDER_VALUE=4;TABLE_SELECT_OFFSET=20;draw;canvas;options;position;range;container;toolRowContainer;toolRowAddBtn;toolColAddBtn;toolTableSelectBtn;toolColContainer;toolBorderContainer;anchorLine;mousedownX;mousedownY;constructor(t){this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){this.toolRowContainer?.remove(),this.toolRowAddBtn?.remove(),this.toolColAddBtn?.remove(),this.toolTableSelectBtn?.remove(),this.toolColContainer?.remove(),this.toolBorderContainer?.remove(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){if(this.draw.getMode()===l.EditorMode.FORM){this.dispose();return}const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.position.getPositionContext();if(!t)return;this.dispose();const r=this.draw.getOriginalElementList(),s=this.position.getOriginalPositionList(),a=r[e];if(a.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:c,table:{overflow:d}}=this.options,R=s[e],{colgroup:u,trList:h}=a,{coordinate:{leftTop:g}}=R,f=this.draw.getHeight(),T=this.draw.getPageGap(),p=this.draw.getPageNo()*(f+T),m=g[0],I=g[1]+p,L=a.trList[n].tdList[i],P=L.rowIndex,O=L.colIndex,S=a.height*c,F=a.width*c,N=document.createElement("div");N.classList.add(`${z}-table-tool__select`),N.style.height=`${S*c}`,N.style.left=`${m}px`,N.style.top=`${I}px`,N.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,N.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(N),this.toolTableSelectBtn=N;const V=h.map(y=>y.height),Y=document.createElement("div");Y.classList.add(`${z}-table-tool__row`),Y.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let y=0;y<V.length;y++){const W=V[y]*c,D=document.createElement("div");D.classList.add(`${z}-table-tool__row__item`),y===P&&D.classList.add("active"),D.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByRowIndex(h,y),G=Q[0],H=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:G.trIndex,tdIndex:G.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,G.tdIndex,H.tdIndex,G.trIndex,H.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(Y,y)};const U=document.createElement("div");U.classList.add(`${z}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:y,order:Te.ROW})},D.append(U),D.style.height=`${W}px`,Y.append(D)}Y.style.left=`${m}px`,Y.style.top=`${I}px`,this.container.append(Y),this.toolRowContainer=Y;const X=document.createElement("div");X.classList.add(`${z}-table-tool__quick__add`),X.style.height=`${S*c}`,X.style.left=`${m}px`,X.style.top=`${I+S}px`,X.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,X.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(X),this.toolRowAddBtn=X;const b=u.map(y=>y.width),E=document.createElement("div");E.classList.add(`${z}-table-tool__col`),E.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let y=0;y<b.length;y++){const W=b[y]*c,D=document.createElement("div");D.classList.add(`${z}-table-tool__col__item`),y===O&&D.classList.add("active"),D.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByColIndex(h,y),G=Q[0],H=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:G.trIndex,tdIndex:G.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,G.tdIndex,H.tdIndex,G.trIndex,H.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(E,y)};const U=document.createElement("div");U.classList.add(`${z}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:y,order:Te.COL})},D.append(U),D.style.width=`${W}px`,E.append(D)}E.style.left=`${m}px`,E.style.top=`${I}px`,this.container.append(E),this.toolColContainer=E;const C=document.createElement("div");C.classList.add(`${z}-table-tool__quick__add`),C.style.height=`${S*c}`,C.style.left=`${m+F}px`,C.style.top=`${I}px`,C.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,C.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(C),this.toolColAddBtn=C;const M=document.createElement("div");M.classList.add(`${z}-table-tool__border`),M.style.height=`${S}px`,M.style.width=`${F}px`,M.style.left=`${m}px`,M.style.top=`${I}px`;for(let y=0;y<h.length;y++){const W=h[y];for(let D=0;D<W.tdList.length;D++){const U=W.tdList[D],Q=document.createElement("div");Q.classList.add(`${z}-table-tool__border__row`),Q.style.width=`${U.width*c}px`,Q.style.height=`${this.BORDER_VALUE}px`,Q.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,Q.style.left=`${U.x*c}px`,Q.onmousedown=H=>{this._mousedown({evt:H,element:a,index:U.rowIndex+U.rowspan-1,order:Te.ROW})},M.appendChild(Q);const G=document.createElement("div");if(G.classList.add(`${z}-table-tool__border__col`),G.style.width=`${this.BORDER_VALUE}px`,G.style.height=`${U.height*c}px`,G.style.top=`${U.y*c}px`,G.style.left=`${(U.x+U.width)*c-this.BORDER_VALUE/2}px`,G.onmousedown=H=>{this._mousedown({evt:H,element:a,index:U.colIndex+U.colspan-1,order:Te.COL})},M.appendChild(G),d&&U.colIndex===0){const H=document.createElement("div");H.classList.add(`${z}-table-tool__border__col`),H.style.width=`${this.BORDER_VALUE}px`,H.style.height=`${U.height*c}px`,H.style.top=`${U.y*c}px`,H.style.left=`${U.x*c-this.BORDER_VALUE/2}px`,H.onmousedown=j=>{this._mousedown({evt:j,element:a,index:0,isLeftStartBorder:!0,order:Te.COL})},M.appendChild(H)}}}this.container.append(M),this.toolBorderContainer=M}_setAnchorActive(t,e){const n=t.children;for(let i=0;i<n.length;i++){const r=n[i];i===e?r.classList.add("active"):r.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:i,element:r,isLeftStartBorder:s}=t;this.canvas=this.draw.getPage();const{scale:a,table:{overflow:c}}=this.options,d=this.draw.getWidth(),R=this.draw.getHeight(),u=this.draw.getPageGap(),h=this.draw.getPageNo()*(R+u),g=this.position.getPositionContext(),p=(this.position.getOriginalPositionList()[g.index]?.coordinate?.leftTop?.[0]||0)*a,m=this.draw.getMargins(),I=m[0],L=m[1],P=I,O=d-L;this.mousedownX=e.x,this.mousedownY=e.y;const S=e.target,F=this.canvas.getBoundingClientRect(),N=window.getComputedStyle(S).cursor;document.body.style.cursor=N,this.canvas.style.cursor=N;let V=0,Y=0;const X=document.createElement("div");X.classList.add(`${z}-table-anchor__line`),i===Te.ROW?(X.classList.add(`${z}-table-anchor__line__row`),X.style.width=`${d}px`,V=0,Y=h+this.mousedownY-F.top):(X.classList.add(`${z}-table-anchor__line__col`),X.style.height=`${R}px`,V=this.mousedownX-F.left,Y=h),X.style.left=`${V}px`,X.style.top=`${Y}px`,this.container.append(X),this.anchorLine=X;let b=0,E=0;const C=M=>{const y=this._mousemove(M,i,V,Y);y&&(b=y.dx,E=y.dy)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",()=>{let M=!1;if(i===Te.ROW){const y=r.trList,W=y[n]||y[n-1],{defaultTrMinHeight:D}=this.options.table;E<0&&W.height+E<D&&(E=D-W.height),E&&(W.height+=E,W.minHeight=W.height,M=!0)}else{const{colgroup:y}=r;if(y&&b)if(c&&s){y[n].width-b/a<=this.MIN_TD_WIDTH&&(b=(y[n].width-this.MIN_TD_WIDTH)*a);const W=p+(r.translateX||0)*a;W+b<P&&(b=P-W),y[n].width-=b/a,r.width-=b/a,r.translateX=(r.translateX||0)+b/a,M=!0}else{const W=y[n].width;b<0&&W*a+b<this.MIN_TD_WIDTH*a&&(b=this.MIN_TD_WIDTH*a-W*a);const D=y[n+1]?.width;if(b>0&&D&&D*a-b<this.MIN_TD_WIDTH*a&&(b=D*a-this.MIN_TD_WIDTH*a),n===y.length-1){const Q=p+(r.translateX||0)*a+r.width*a;Q+b>O&&(b=O-Q)}b&&(y.length-1!==n&&(y[n+1].width-=b/a),y[n].width+=b/a,M=!0)}}M&&this.draw.render({isSetCursor:!1}),X.remove(),document.removeEventListener("mousemove",C),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const r=t.x-this.mousedownX,s=t.y-this.mousedownY;return e===Te.ROW?this.anchorLine.style.top=`${i+s}px`:this.anchorLine.style.left=`${n+r}px`,t.preventDefault(),{dx:r,dy:s}}}class oc{draw;options;container;hyperlinkPopupContainer;hyperlinkDom;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${z}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:r}=e,s=this.draw.getHeight(),a=this.draw.getPageGap(),c=this.draw.getPageNo()*(s+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+c+r}px`;const d=t.url||"#";this.hyperlinkDom.href=d,this.hyperlinkDom.title=d,this.hyperlinkDom.innerText=d}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class ic{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:r,label:{defaultBackgroundColor:s,defaultColor:a,defaultBorderRadius:c,defaultPadding:d}}=this.options,R=e.label?.backgroundColor||s,u=e.label?.color||a,h=e.label?.borderRadius||c,g=e.label?.padding||d;t.save(),t.font=e.style;const{width:f,height:T,boundingBoxAscent:p}=e.metrics;t.fillStyle=R,this._drawRoundedRect(t,n,i-p,f,T+(g[0]+g[3])*r,h*r),t.fill(),t.fillStyle=u,t.fillText(e.value,n+g[3]*r,i),t.restore()}_drawRoundedRect(t,e,n,i,r,s){t.beginPath(),t.moveTo(e+s,n),t.lineTo(e+i-s,n),t.quadraticCurveTo(e+i,n,e+i,n+s),t.lineTo(e+i,n+r-s),t.quadraticCurveTo(e+i,n+r,e+i-s,n+r),t.lineTo(e+s,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s),t.lineTo(e,n+s),t.quadraticCurveTo(e,n,e+s,n),t.closePath()}}class sc{options;draw;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e,n,i){const r=this.draw.getMode(),s=e.macroConfig;if(e.type==="subTemplate"&&console.log("MacroParticle.render - 子模板元素:",e.type,"当前模式:",r,"label:",e.label),r===l.EditorMode.EDIT){const c=e.label||e.value||"";this._renderEditMode(t,e,n,i,c);return}if(e.type==="macro"){const c=e.label||"",d=e.value||`获取 ${c}`;this._renderPlainText(t,e,n,i,d);return}if(e.type==="customMacro"){const c=s?.type||"text",d=s?.value||"",R=e.label||"";if(r===l.EditorMode.FORM)c==="select"?this._renderSelectControl(t,e,n,i,d):this._renderTextControl(t,e,n,i,d);else{const u=d||`获取 ${R}`;this._renderPlainText(t,e,n,i,u)}return}if(e.type==="reusableItem"){const d=e.reusableItemConfig?.value||"",R=e.label||"";if(r===l.EditorMode.FORM)this._renderTextControl(t,e,n,i,d);else{const u=d||`获取 ${R}`;this._renderPlainText(t,e,n,i,u)}return}if(e.type==="subTemplate"){const c=e.label||"子模板";r===l.EditorMode.FORM?e.subTemplateExpanded||this._renderEditMode(t,e,n,i,c):this._renderPlainText(t,e,n,i,c);return}const a=e.value||e.label||"";this._renderPlainText(t,e,n,i,a)}_renderPlainText(t,e,n,i,r){t.save(),t.font=e.style,t.fillStyle=e.color||"#000000",t.textBaseline="alphabetic",t.fillText(r,n,i),t.restore()}_renderEditMode(t,e,n,i,r){const{scale:s}=this.options,a=e.type==="customMacro",c=e.type==="reusableItem",d=e.type==="subTemplate";let R,u;d?(R="#722ed1",u="#f9f0ff"):c?(R="#52c41a",u="#f6ffed"):a?(R="#fa8c16",u="#fff7e6"):(R="#1677ff",u="#e6f4ff"),t.save(),t.font=e.style;const h=t.measureText(r),g=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent,f=8*s,T=4*s,p=4*s,m=h.width+f*2,I=g+T*2,L=e.metrics,P=n,O=i-L.boundingBoxAscent+(L.boundingBoxAscent+L.boundingBoxDescent-I)/2;t.fillStyle=u,this._drawRoundedRect(t,P,O,m,I,p),t.fill(),t.fillStyle=R,t.textBaseline="middle",t.fillText(r,n+f,O+I/2),t.restore()}_renderTextControl(t,e,n,i,r){const{scale:s,control:a,strikeoutColor:c}=this.options,{placeholderColor:d,bracketColor:R}=a;t.save(),t.font=e.style;const h=`请输入${e.label||""}`,g=r||h,T=t.measureText(g).width;t.fillStyle=R,t.textBaseline="alphabetic",t.fillText("[",n,i);const p=n+t.measureText("[").width;t.fillStyle=r?e.color||"#000000":d,t.fillText(g,p,i);const m=p+T;if(t.fillStyle=R,t.fillText("]",m,i),e.type==="reusableItem"){const I=t.measureText("[").width+T+t.measureText("]").width;if(t.lineWidth=s,this.draw.getMode()===l.EditorMode.PRINT?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const L=i-3*s,P=i+3.5*s;t.beginPath(),t.moveTo(n,L),t.lineTo(n+I,L),t.stroke(),t.beginPath(),t.moveTo(n,P),t.lineTo(n+I,P),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const L=Math.floor(i+2*s)+.5,P=3*s;t.beginPath(),t.moveTo(n,L),t.lineTo(n+I,L),t.stroke(),t.beginPath(),t.moveTo(n,L+P),t.lineTo(n+I,L+P),t.stroke()}}t.restore()}_renderSelectControl(t,e,n,i,r){const{scale:s,control:a}=this.options,{placeholderColor:c,bracketColor:d}=a;t.save(),t.font=e.style;const u=`请选择${e.label||""}`,h=r||u,g=t.measureText(h),f=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent;t.fillStyle=d,t.textBaseline="alphabetic",t.fillText("[",n,i);const T=n+t.measureText("[").width;t.fillStyle=r?e.color||"#000000":c,t.fillText(h,T,i);const p=T+g.width+2*s,m=i-f/2;t.beginPath(),t.moveTo(p,m-2*s),t.lineTo(p+5*s,m-2*s),t.lineTo(p+2.5*s,m+2*s),t.closePath(),t.fillStyle="#666666",t.fill();const I=p+6*s;t.fillStyle=d,t.fillText("]",I,i),t.restore()}_drawRoundedRect(t,e,n,i,r,s){t.beginPath(),t.moveTo(e+s,n),t.lineTo(e+i-s,n),t.quadraticCurveTo(e+i,n,e+i,n+s),t.lineTo(e+i,n+r-s),t.quadraticCurveTo(e+i,n+r,e+i-s,n+r),t.lineTo(e+s,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s),t.lineTo(e,n+s),t.quadraticCurveTo(e,n,e+s,n),t.closePath()}}class rc{draw;position;zone;options;elementList;rowList;positionList;constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=wo(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:n})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],r=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:r,innerWidth:e,zone:l.EditorZone.HEADER})}getHeaderTop(){const{header:{top:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*yi[t])}getHeight(){if(this.options.header.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getHeaderTop()+e-t[0];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let s=0;for(let a=0;a<this.rowList.length;a++){const c=this.rowList[a];if(s+c.height>i)break;r.push(c),s+=c.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:l.EditorZone.HEADER}),t.restore()}}class lc{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class ac{getOffsetY(t){return t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class cc{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){t.save();const{scale:r,separator:{lineWidth:s,strokeStyle:a}}=this.options;t.lineWidth=(e.lineWidth||s)*r,t.strokeStyle=e.color||a,e.dashArray?.length&&t.setLineDash(e.dashArray);const c=Math.round(i);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,c),t.lineTo(n+e.width*r,c),t.stroke(),t.restore()}}class dc{draw;options;i18n;constructor(t){this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,i){const{pageBreak:{font:r,fontSize:s,lineDash:a}}=this.options,c=this.i18n.t("pageBreak.displayName"),{scale:d,defaultRowMargin:R}=this.options,u=s*d,h=e.width*d,g=this.draw.getDefaultBasicRowMarginHeight()*R;t.save(),t.font=`${u}px ${r}`;const f=t.measureText(c),T=(h-f.width)/2;t.setLineDash(a),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+T,i),t.moveTo(n+T+f.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(c,n+T,i+f.actualBoundingBoxAscent-u/2),t.restore()}}class Rc{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:i,font:r,size:s,color:a,repeat:c,gap:d,numberType:R},scale:u}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${s*u}px ${r}`;let f=n;const T=new RegExp(pn.PAGE_NO);T.test(f)&&(f=sn.formatNumberPlaceholder(f,e+1,T,R));const p=new RegExp(pn.PAGE_COUNT);p.test(f)&&(f=sn.formatNumberPlaceholder(f,this.draw.getPageCount(),p,R));const m=t.measureText(f);if(c){const I=this.draw.getPagePixelRatio(),L=document.createElement("canvas"),P=L.getContext("2d"),O=m.width,S=m.actualBoundingBoxAscent+m.actualBoundingBoxDescent,F=Math.sqrt(Math.pow(O,2)+Math.pow(S,2)),N=F+2*d[0]*u,V=F+2*d[1]*u;L.width=N,L.height=V,L.style.width=`${N*I}px`,L.style.height=`${V*I}px`,P.translate(N/2,V/2),P.rotate(-45*Math.PI/180),P.translate(-N/2,-V/2),P.font=`${s*u}px ${r}`,P.fillStyle=a,P.fillText(f,(N-O)/2,(V-S)/2+m.actualBoundingBoxAscent);const Y=t.createPattern(L,"repeat");Y&&(t.fillStyle=Y,t.fillRect(0,0,h,g))}else{const I=h/2,L=g/2;t.fillStyle=a,t.translate(I,L),t.rotate(-45*Math.PI/180),t.fillText(f,-m.width/2,m.actualBoundingBoxAscent-s*u/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:i,opacity:r,repeat:s,gap:a},scale:c}=this.options;if(!this.imageCache.has(i)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const d=this.draw.getWidth(),R=this.draw.getHeight(),u=e*c,h=n*c;if(t.save(),t.globalAlpha=r,s){const g=this.draw.getPagePixelRatio(),f=document.createElement("canvas"),T=f.getContext("2d"),p=Math.sqrt(Math.pow(u,2)+Math.pow(h,2)),m=p+2*a[0]*c,I=p+2*a[1]*c;f.width=m,f.height=I,f.style.width=`${m*g}px`,f.style.height=`${I*g}px`,T.translate(m/2,I/2),T.rotate(-45*Math.PI/180),T.translate(-m/2,-I/2),T.drawImage(this.imageCache.get(i),(m-u)/2,(I-h)/2,u,h);const L=t.createPattern(f,"repeat");L&&(t.fillStyle=L,t.fillRect(0,0,d,R))}else{const g=d/2,f=R/2;t.translate(g,f),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-u/2,-h/2,u,h)}t.restore()}render(t,e){this.options.watermark.type===l.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class uc{draw;control;options;highlightList;highlightMatchResult;constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:r,noValueBackgroundColor:s}}=this.options,a=t[e],c=this.draw.isPrintMode(),d=this.control.getActiveControl()?.getElement();let R=!1,u=!1,h=!1,g=!1;return a.highlight||(R=!c&&!!n&&!!d&&a.controlId===d.controlId&&!this.control.getIsRangeInPostfix()),R||(u=!c&&!!i&&!!a.control?.disabled),u||(h=!c&&!!r&&!!a.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),h||(g=!c&&!!s&&!!a.controlId&&!this.control.getIsExistValueByElementListIndex(t,e)),(R?n:"")||(u?i:"")||(h?r:"")||(g?s:"")}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,i)=>{let r=0;for(;r<n.length;){const s=n[r];if(r++,s.type===l.ElementType.TABLE){const f=s.trList;for(let T=0;T<f.length;T++){const p=f[T];for(let m=0;m<p.tdList.length;m++){const I=p.tdList[m],L={tableId:s.id,tableIndex:r-1,trIndex:T,tdIndex:m,tdId:I.id};e(I.value,L)}}}const a=s?.control;if(!a)continue;const c=this.highlightList.findIndex(f=>f.id===s.controlId||a.conceptId&&a.conceptId===f.conceptId);if(!~c)continue;const d=r;let R=r;for(;R<n.length&&n[R].controlId===s.controlId;)R++;r=R;const u=n.slice(d,R).map(f=>f.controlComponent===l.ControlComponent.VALUE?f:{value:_}),h=this.highlightList[c],{ruleList:g}=h;for(let f=0;f<g.length;f++){const T=g[f],p=t.getMatchList(T.keyword,u);this.highlightMatchResult.push(...p.map(m=>({...m,...T,...i,index:m.index+d})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){if(!this.highlightMatchResult?.length)return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,r=this.draw.getPosition().getOriginalPositionList(),s=this.draw.getOriginalElementList();t.save();for(let a=0;a<this.highlightMatchResult.length;a++){const c=this.highlightMatchResult[a];let d=null;if(c.tableId){const{tableIndex:I,trIndex:L,tdIndex:P,index:O}=c;d=s[I]?.trList[L].tdList[P]?.positionList[O]}else d=r[c.index];if(!d)continue;const{coordinate:{leftTop:R,leftBottom:u,rightTop:h},pageNo:g}=d;if(g!==e)continue;t.fillStyle=c.backgroundColor||i,t.globalAlpha=c.alpha||n;const f=R[0],T=R[1],p=h[0]-R[0],m=u[1]-R[1];t.fillRect(f,T,p,m)}t.restore()}}class hc{borderRect;options;constructor(t){this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,i){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=i),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:i}}=this.options,{x:r,y:s,width:a,height:c}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=i,t.beginPath(),t.rect(r,s,a,c),t.stroke(),t.restore(),this.clearBorderInfo()}}class In{draw;element;control;isPopup;selectDom;options;VALUE_DELIMITER=",";DEFAULT_MULTI_SELECT_DELIMITER=",";constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.selectDom=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getCodes(){return this.element?.control?.code?this.element.control.code.split(","):[]}getText(t){if(!this.element?.control)return null;const e=this.element.control;if(!e.valueSets?.length)return null;const n=e?.multiSelectDelimiter||this.DEFAULT_MULTI_SELECT_DELIMITER,i=e.valueSets,r=[];return t.forEach(s=>{const a=i.find(c=>c.code===s);a&&!Ui(a.value)&&r.push(a.value)}),r.join(n)||null}getValue(t={}){const{elementList:e,range:n}=this.control.mergeControl(t),{startIndex:i}=n,r=e[i],s=[];let a=i;for(;a>=0;){const d=e[a];if(!d||d.controlId!==r.controlId||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT)break;d.controlComponent===l.ControlComponent.VALUE&&s.unshift(d),a--}let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POST_TEXT)break;d.controlComponent===l.ControlComponent.VALUE&&s.push(d),c++}return s}setValue(t,e={},n={}){if(!this.element.control?.selectExclusiveOptions?.inputAble||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...R,...t[h],controlComponent:l.ControlComponent.VALUE};Ut(i,[g],s,{editorOptions:this.options}),c.spliceElementList(i,u+h,0,[g])}return u+t.length-1}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.element.control?.selectExclusiveOptions?.inputAble;if(t.key===l.KeyMap.Backspace)return i!==r?c?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect():s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1):this.clearSelect();if(t.key===l.KeyMap.Delete){if(i!==r)return c?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect();{const d=e[r+1];return(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT)&&d.controlComponent===l.ControlComponent.PLACEHOLDER||d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect()}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=t.elementList||this.control.getElementList(),{startIndex:s}=t.range||this.control.getRange(),a=r[s];let c=-1,d=-1,R=s;for(;R>0;){const g=r[R];if(g.controlId!==a.controlId||g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT){c=R;break}R--}let u=s+1;for(;u<r.length;){const g=r[u];if(g.controlId!==a.controlId||g.controlComponent===l.ControlComponent.POSTFIX||g.controlComponent===l.ControlComponent.POST_TEXT){d=u-1;break}u++}return!~c||!~d?-1:(this.control.getDraw().spliceElementList(r,c+1,d-c,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(R,t),this.control.setControlProperties({code:void 0},{elementList:r,range:{startIndex:R,endIndex:R}}),R)}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),s=this.element.control,a=t?.split(this.VALUE_DELIMITER)||[],c=s.code,d=s.code?.split(this.VALUE_DELIMITER)||[],R=s.isMultiSelect;if(!R&&t===c||R&&Di(d,a)){this.control.repaintControl({curIndex:r.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const u=s.valueSets;if(!Array.isArray(u)||!u.length)return;const h=this.getText(a);if(!h){if(c){const P=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~P&&(this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],f=g?Dt(g,Re):Dt(i[r.startIndex],Gt),T=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~T)return;c||this.control.removePlaceholder(T,e);const p=ie(i[T],Re),m=T+1,I=ct(h),L=this.control.getDraw();for(let P=0;P<I.length;P++){const O={...f,...p,type:l.ElementType.TEXT,value:I[P],controlComponent:l.ControlComponent.VALUE};(O.color===this.options.control.bracketColor||O.color===this.options.control.placeholderColor)&&(O.color=this.options.defaultColor),Ut(i,[O],T,{editorOptions:this.options}),L.spliceElementList(i,m+P,0,[O])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:T,endIndex:T}}),!e.range){const P=m+I.length-1;this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({context:e}),R||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${z}-select-control-popup`),i.setAttribute(de,l.EditorComponent.POPUP);const r=document.createElement("ul");let s=null;for(let h=0;h<e.length;h++){const g=e[h],f=document.createElement("li");let T=this.getCodes();T.includes(g.code)&&(f.classList.add("active"),s=f),f.onclick=()=>{const p=T.findIndex(m=>m===g.code);t.isMultiSelect?~p?T.splice(p,1):T.push(g.code):~p?T=[]:T=[g.code],this.setSelect(T.join(this.VALUE_DELIMITER))},f.append(document.createTextNode(g.value)),r.append(f)}i.append(r);const{coordinate:{leftTop:[a,c]},lineHeight:d}=n,R=this.control.getPreY();i.style.left=`${a}px`,i.style.top=`${c+R+d}px`,this.control.getContainer().append(i),this.selectDom=i,s&&Zi(i,s)}awake(){if(this.isPopup||this.control.getIsDisabledControl())return;const{startIndex:t}=this.control.getRange(),n=this.control.getElementList()[t];if(!n||n.controlId!==this.element.controlId)return;const i=n.controlComponent===l.ControlComponent.PREFIX||n.controlComponent===l.ControlComponent.PRE_TEXT||n.controlComponent===l.ControlComponent.POSTFIX||n.controlComponent===l.ControlComponent.POST_TEXT||n.controlComponent===l.ControlComponent.PLACEHOLDER;!this.control.getIsRangeWithinControl()&&!i||(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){this.isPopup&&(this.selectDom?.remove(),this.isPopup=!1)}}var hs;function q(){return hs.apply(null,arguments)}function gc(o){hs=o}function se(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function _e(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Ot(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Go(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Ot(o,t))return!1;return!0}function kt(o){return o===void 0}function Me(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function Pn(o){return o instanceof Date||Object.prototype.toString.call(o)==="[object Date]"}function gs(o,t){var e=[],n,i=o.length;for(n=0;n<i;++n)e.push(t(o[n],n));return e}function Ue(o,t){for(var e in t)Ot(t,e)&&(o[e]=t[e]);return Ot(t,"toString")&&(o.toString=t.toString),Ot(t,"valueOf")&&(o.valueOf=t.valueOf),o}function me(o,t,e,n){return Ks(o,t,e,n,!0).utc()}function fc(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function Rt(o){return o._pf==null&&(o._pf=fc()),o._pf}var Ao;Array.prototype.some?Ao=Array.prototype.some:Ao=function(o){var t=Object(this),e=t.length>>>0,n;for(n=0;n<e;n++)if(n in t&&o.call(this,t[n],n,t))return!0;return!1};function ko(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Rt(o),e=Ao.call(t.parsedDateParts,function(i){return i!=null}),n=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&e),o._strict&&(n=n&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(o))o._isValid=n;else return n;return o._isValid}function Gn(o){var t=me(NaN);return o!=null?Ue(Rt(t),o):Rt(t).userInvalidated=!0,t}var fs=q.momentProperties=[],Jo=!1;function Bo(o,t){var e,n,i,r=fs.length;if(kt(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),kt(t._i)||(o._i=t._i),kt(t._f)||(o._f=t._f),kt(t._l)||(o._l=t._l),kt(t._strict)||(o._strict=t._strict),kt(t._tzm)||(o._tzm=t._tzm),kt(t._isUTC)||(o._isUTC=t._isUTC),kt(t._offset)||(o._offset=t._offset),kt(t._pf)||(o._pf=Rt(t)),kt(t._locale)||(o._locale=t._locale),r>0)for(e=0;e<r;e++)n=fs[e],i=t[n],kt(i)||(o[n]=i);return o}function Mn(o){Bo(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),Jo===!1&&(Jo=!0,q.updateOffset(this),Jo=!1)}function re(o){return o instanceof Mn||o!=null&&o._isAMomentObject!=null}function Ts(o){q.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function te(o,t){var e=!0;return Ue(function(){if(q.deprecationHandler!=null&&q.deprecationHandler(null,o),e){var n=[],i,r,s,a=arguments.length;for(r=0;r<a;r++){if(i="",typeof arguments[r]=="object"){i+=`
|
|
102
|
+
[`+r+"] ";for(s in arguments[0])Ot(arguments[0],s)&&(i+=s+": "+arguments[0][s]+", ");i=i.slice(0,-2)}else i=arguments[r];n.push(i)}Ts(o+`
|
|
103
103
|
Arguments: `+Array.prototype.slice.call(n).join("")+`
|
|
104
|
-
`+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var ms={};function ps(o,t){q.deprecationHandler!=null&&q.deprecationHandler(o,t),ms[o]||(Ts(t),ms[o]=!0)}q.suppressDeprecationWarnings=!1,q.deprecationHandler=null;function pe(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function Tc(o){var t,e;for(e in o)Mt(o,e)&&(t=o[e],pe(t)?this[e]=t:this["_"+e]=t);this._config=o,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function $o(o,t){var e=Ue({},o),n;for(n in t)Mt(t,n)&&(_e(o[n])&&_e(t[n])?(e[n]={},Ue(e[n],o[n]),Ue(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Mt(o,n)&&!Mt(t,n)&&_e(o[n])&&(e[n]=Ue({},e[n]));return e}function zo(o){o!=null&&this.set(o)}var jo;Object.keys?jo=Object.keys:jo=function(o){var t,e=[];for(t in o)Mt(o,t)&&e.push(t);return e};var mc={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function pc(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return pe(n)?n.call(t,e):n}function Le(o,t,e){var n=""+Math.abs(o),i=t-n.length,r=o>=0;return(r?e?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+n}var qo=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,An=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ti={},rn={};function rt(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(rn[o]=i),t&&(rn[t[0]]=function(){return Le(i.apply(this,arguments),t[1],t[2])}),e&&(rn[e]=function(){return this.localeData().ordinal(i.apply(this,arguments),o)})}function Lc(o){return o.match(/\[[\s\S]/)?o.replace(/^\[|\]$/g,""):o.replace(/\\/g,"")}function Ic(o){var t=o.match(qo),e,n;for(e=0,n=t.length;e<n;e++)rn[t[e]]?t[e]=rn[t[e]]:t[e]=Lc(t[e]);return function(i){var r="",s;for(s=0;s<n;s++)r+=pe(t[s])?t[s].call(i,o):t[s];return r}}function kn(o,t){return o.isValid()?(t=Ls(t,o.localeData()),ti[t]=ti[t]||Ic(t),ti[t](o)):o.localeData().invalidDate()}function Ls(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(An.lastIndex=0;e>=0&&An.test(o);)o=o.replace(An,n),An.lastIndex=0,e-=1;return o}var Pc={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function Mc(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(qo).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var Oc="Invalid date";function Cc(){return this._invalidDate}var Sc="%d",Ec=/\d{1,2}/;function Xc(o){return this._ordinal.replace("%d",o)}var Nc={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function Fc(o,t,e,n){var i=this._relativeTime[e];return pe(i)?i(o,t,e,n):i.replace(/%d/i,o)}function yc(o,t){var e=this._relativeTime[o>0?"future":"past"];return pe(e)?e(t):e.replace(/%s/i,t)}var Is={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function ee(o){return typeof o=="string"?Is[o]||Is[o.toLowerCase()]:void 0}function ei(o){var t={},e,n;for(n in o)Mt(o,n)&&(e=ee(n),e&&(t[e]=o[n]));return t}var Wc={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function bc(o){var t=[],e;for(e in o)Mt(o,e)&&t.push({unit:e,priority:Wc[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var Ps=/\d/,zt=/\d\d/,Ms=/\d{3}/,ni=/\d{4}/,Jn=/[+-]?\d{6}/,Nt=/\d\d?/,Os=/\d\d\d\d?/,Cs=/\d\d\d\d\d\d?/,Bn=/\d{1,3}/,oi=/\d{1,4}/,$n=/[+-]?\d{1,6}/,ln=/\d+/,zn=/[+-]?\d+/,Vc=/Z|[+-]\d\d:?\d\d/gi,jn=/Z|[+-]\d\d(?::?\d\d)?/gi,Yc=/[+-]?\d+(\.\d{1,3})?/,On=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,an=/^[1-9]\d?/,ii=/^([1-9]\d|\d)/,qn;qn={};function ot(o,t,e){qn[o]=pe(t)?t:function(n,i){return n&&e?e:t}}function Dc(o,t){return Mt(qn,o)?qn[o](t._strict,t._locale):new RegExp(Uc(o))}function Uc(o){return Oe(o.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,r){return e||n||i||r}))}function Oe(o){return o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function ne(o){return o<0?Math.ceil(o)||0:Math.floor(o)}function ft(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=ne(t)),e}var si={};function Et(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),Me(t)&&(n=function(r,s){s[t]=ft(r)}),i=o.length,e=0;e<i;e++)si[o[e]]=n}function Cn(o,t){Et(o,function(e,n,i,r){i._w=i._w||{},t(e,i._w,i,r)})}function wc(o,t,e){t!=null&&Mt(si,o)&&si[o](t,e._a,e,o)}function to(o){return o%4===0&&o%100!==0||o%400===0}var xt=0,Ce=1,Ie=2,vt=3,le=4,Se=5,xe=6,Zc=7,Qc=8;rt("Y",0,0,function(){var o=this.year();return o<=9999?Le(o,4):"+"+o}),rt(0,["YY",2],0,function(){return this.year()%100}),rt(0,["YYYY",4],0,"year"),rt(0,["YYYYY",5],0,"year"),rt(0,["YYYYYY",6,!0],0,"year"),ot("Y",zn),ot("YY",Nt,zt),ot("YYYY",oi,ni),ot("YYYYY",$n,Jn),ot("YYYYYY",$n,Jn),Et(["YYYYY","YYYYYY"],xt),Et("YYYY",function(o,t){t[xt]=o.length===2?q.parseTwoDigitYear(o):ft(o)}),Et("YY",function(o,t){t[xt]=q.parseTwoDigitYear(o)}),Et("Y",function(o,t){t[xt]=parseInt(o,10)});function Sn(o){return to(o)?366:365}q.parseTwoDigitYear=function(o){return ft(o)+(ft(o)>68?1900:2e3)};var Ss=cn("FullYear",!0);function vc(){return to(this.year())}function cn(o,t){return function(e){return e!=null?(Es(this,o,e),q.updateOffset(this,t),this):En(this,o)}}function En(o,t){if(!o.isValid())return NaN;var e=o._d,n=o._isUTC;switch(t){case"Milliseconds":return n?e.getUTCMilliseconds():e.getMilliseconds();case"Seconds":return n?e.getUTCSeconds():e.getSeconds();case"Minutes":return n?e.getUTCMinutes():e.getMinutes();case"Hours":return n?e.getUTCHours():e.getHours();case"Date":return n?e.getUTCDate():e.getDate();case"Day":return n?e.getUTCDay():e.getDay();case"Month":return n?e.getUTCMonth():e.getMonth();case"FullYear":return n?e.getUTCFullYear():e.getFullYear();default:return NaN}}function Es(o,t,e){var n,i,r,s,a;if(!(!o.isValid()||isNaN(e))){switch(n=o._d,i=o._isUTC,t){case"Milliseconds":return void(i?n.setUTCMilliseconds(e):n.setMilliseconds(e));case"Seconds":return void(i?n.setUTCSeconds(e):n.setSeconds(e));case"Minutes":return void(i?n.setUTCMinutes(e):n.setMinutes(e));case"Hours":return void(i?n.setUTCHours(e):n.setHours(e));case"Date":return void(i?n.setUTCDate(e):n.setDate(e));case"FullYear":break;default:return}r=e,s=o.month(),a=o.date(),a=a===29&&s===1&&!to(r)?28:a,i?n.setUTCFullYear(r,s,a):n.setFullYear(r,s,a)}}function Kc(o){return o=ee(o),pe(this[o])?this[o]():this}function Hc(o,t){if(typeof o=="object"){o=ei(o);var e=bc(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=ee(o),pe(this[o]))return this[o](t);return this}function _c(o,t){return(o%t+t)%t}var wt;Array.prototype.indexOf?wt=Array.prototype.indexOf:wt=function(o){var t;for(t=0;t<this.length;++t)if(this[t]===o)return t;return-1};function ri(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=_c(t,12);return o+=(t-e)/12,e===1?to(o)?29:28:31-e%7%2}rt("M",["MM",2],"Mo",function(){return this.month()+1}),rt("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),rt("MMMM",0,0,function(o){return this.localeData().months(this,o)}),ot("M",Nt,an),ot("MM",Nt,zt),ot("MMM",function(o,t){return t.monthsShortRegex(o)}),ot("MMMM",function(o,t){return t.monthsRegex(o)}),Et(["M","MM"],function(o,t){t[Ce]=ft(o)-1}),Et(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[Ce]=i:Rt(e).invalidMonth=o});var xc="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Xs="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Ns=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Gc=On,Ac=On;function kc(o,t){return o?se(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Ns).test(t)?"format":"standalone"][o.month()]:se(this._months)?this._months:this._months.standalone}function Jc(o,t){return o?se(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Ns.test(t)?"format":"standalone"][o.month()]:se(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Bc(o,t,e){var n,i,r,s=o.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],n=0;n<12;++n)r=me([2e3,n]),this._shortMonthsParse[n]=this.monthsShort(r,"").toLocaleLowerCase(),this._longMonthsParse[n]=this.months(r,"").toLocaleLowerCase();return e?t==="MMM"?(i=wt.call(this._shortMonthsParse,s),i!==-1?i:null):(i=wt.call(this._longMonthsParse,s),i!==-1?i:null):t==="MMM"?(i=wt.call(this._shortMonthsParse,s),i!==-1?i:(i=wt.call(this._longMonthsParse,s),i!==-1?i:null)):(i=wt.call(this._longMonthsParse,s),i!==-1?i:(i=wt.call(this._shortMonthsParse,s),i!==-1?i:null))}function $c(o,t,e){var n,i,r;if(this._monthsParseExact)return Bc.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=me([2e3,n]),e&&!this._longMonthsParse[n]&&(this._longMonthsParse[n]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[n]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),!e&&!this._monthsParse[n]&&(r="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[n]=new RegExp(r.replace(".",""),"i")),e&&t==="MMMM"&&this._longMonthsParse[n].test(o))return n;if(e&&t==="MMM"&&this._shortMonthsParse[n].test(o))return n;if(!e&&this._monthsParse[n].test(o))return n}}function Fs(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=ft(t);else if(t=o.localeData().monthsParse(t),!Me(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,ri(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function ys(o){return o!=null?(Fs(this,o),q.updateOffset(this,!0),this):En(this,"Month")}function zc(){return ri(this.year(),this.month())}function jc(o){return this._monthsParseExact?(Mt(this,"_monthsRegex")||Ws.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Mt(this,"_monthsShortRegex")||(this._monthsShortRegex=Gc),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function qc(o){return this._monthsParseExact?(Mt(this,"_monthsRegex")||Ws.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Mt(this,"_monthsRegex")||(this._monthsRegex=Ac),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function Ws(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,r,s,a;for(i=0;i<12;i++)r=me([2e3,i]),s=Oe(this.monthsShort(r,"")),a=Oe(this.months(r,"")),t.push(s),e.push(a),n.push(a),n.push(s);t.sort(o),e.sort(o),n.sort(o),this._monthsRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+t.join("|")+")","i")}function td(o,t,e,n,i,r,s){var a;return o<100&&o>=0?(a=new Date(o+400,t,e,n,i,r,s),isFinite(a.getFullYear())&&a.setFullYear(o)):a=new Date(o,t,e,n,i,r,s),a}function Xn(o){var t,e;return o<100&&o>=0?(e=Array.prototype.slice.call(arguments),e[0]=o+400,t=new Date(Date.UTC.apply(null,e)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(o)):t=new Date(Date.UTC.apply(null,arguments)),t}function eo(o,t,e){var n=7+t-e,i=(7+Xn(o,0,n).getUTCDay()-t)%7;return-i+n-1}function bs(o,t,e,n,i){var r=(7+e-n)%7,s=eo(o,n,i),a=1+7*(t-1)+r+s,c,d;return a<=0?(c=o-1,d=Sn(c)+a):a>Sn(o)?(c=o+1,d=a-Sn(o)):(c=o,d=a),{year:c,dayOfYear:d}}function Nn(o,t,e){var n=eo(o.year(),t,e),i=Math.floor((o.dayOfYear()-n-1)/7)+1,r,s;return i<1?(s=o.year()-1,r=i+Ee(s,t,e)):i>Ee(o.year(),t,e)?(r=i-Ee(o.year(),t,e),s=o.year()+1):(s=o.year(),r=i),{week:r,year:s}}function Ee(o,t,e){var n=eo(o,t,e),i=eo(o+1,t,e);return(Sn(o)-n+i)/7}rt("w",["ww",2],"wo","week"),rt("W",["WW",2],"Wo","isoWeek"),ot("w",Nt,an),ot("ww",Nt,zt),ot("W",Nt,an),ot("WW",Nt,zt),Cn(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=ft(o)});function ed(o){return Nn(o,this._week.dow,this._week.doy).week}var nd={dow:0,doy:6};function od(){return this._week.dow}function id(){return this._week.doy}function sd(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function rd(o){var t=Nn(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}rt("d",0,"do","day"),rt("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),rt("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),rt("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),rt("e",0,0,"weekday"),rt("E",0,0,"isoWeekday"),ot("d",Nt),ot("e",Nt),ot("E",Nt),ot("dd",function(o,t){return t.weekdaysMinRegex(o)}),ot("ddd",function(o,t){return t.weekdaysShortRegex(o)}),ot("dddd",function(o,t){return t.weekdaysRegex(o)}),Cn(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Rt(e).invalidWeekday=o}),Cn(["d","e","E"],function(o,t,e,n){t[n]=ft(o)});function ld(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function ad(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function li(o,t){return o.slice(t,7).concat(o.slice(0,t))}var cd="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Vs="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),dd="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Rd=On,ud=On,hd=On;function gd(o,t){var e=se(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?li(e,this._week.dow):o?e[o.day()]:e}function fd(o){return o===!0?li(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function Td(o){return o===!0?li(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function md(o,t,e){var n,i,r,s=o.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)r=me([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(r,"").toLocaleLowerCase();return e?t==="dddd"?(i=wt.call(this._weekdaysParse,s),i!==-1?i:null):t==="ddd"?(i=wt.call(this._shortWeekdaysParse,s),i!==-1?i:null):(i=wt.call(this._minWeekdaysParse,s),i!==-1?i:null):t==="dddd"?(i=wt.call(this._weekdaysParse,s),i!==-1||(i=wt.call(this._shortWeekdaysParse,s),i!==-1)?i:(i=wt.call(this._minWeekdaysParse,s),i!==-1?i:null)):t==="ddd"?(i=wt.call(this._shortWeekdaysParse,s),i!==-1||(i=wt.call(this._weekdaysParse,s),i!==-1)?i:(i=wt.call(this._minWeekdaysParse,s),i!==-1?i:null)):(i=wt.call(this._minWeekdaysParse,s),i!==-1||(i=wt.call(this._weekdaysParse,s),i!==-1)?i:(i=wt.call(this._shortWeekdaysParse,s),i!==-1?i:null))}function pd(o,t,e){var n,i,r;if(this._weekdaysParseExact)return md.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=me([2e3,1]).day(n),e&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(r="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[n]=new RegExp(r.replace(".",""),"i")),e&&t==="dddd"&&this._fullWeekdaysParse[n].test(o))return n;if(e&&t==="ddd"&&this._shortWeekdaysParse[n].test(o))return n;if(e&&t==="dd"&&this._minWeekdaysParse[n].test(o))return n;if(!e&&this._weekdaysParse[n].test(o))return n}}function Ld(o){if(!this.isValid())return o!=null?this:NaN;var t=En(this,"Day");return o!=null?(o=ld(o,this.localeData()),this.add(o-t,"d")):t}function Id(o){if(!this.isValid())return o!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return o==null?t:this.add(o-t,"d")}function Pd(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=ad(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function Md(o){return this._weekdaysParseExact?(Mt(this,"_weekdaysRegex")||ai.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Mt(this,"_weekdaysRegex")||(this._weekdaysRegex=Rd),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function Od(o){return this._weekdaysParseExact?(Mt(this,"_weekdaysRegex")||ai.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Mt(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=ud),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Cd(o){return this._weekdaysParseExact?(Mt(this,"_weekdaysRegex")||ai.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Mt(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=hd),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function ai(){function o(R,u){return u.length-R.length}var t=[],e=[],n=[],i=[],r,s,a,c,d;for(r=0;r<7;r++)s=me([2e3,1]).day(r),a=Oe(this.weekdaysMin(s,"")),c=Oe(this.weekdaysShort(s,"")),d=Oe(this.weekdays(s,"")),t.push(a),e.push(c),n.push(d),i.push(a),i.push(c),i.push(d);t.sort(o),e.sort(o),n.sort(o),i.sort(o),this._weekdaysRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function ci(){return this.hours()%12||12}function Sd(){return this.hours()||24}rt("H",["HH",2],0,"hour"),rt("h",["hh",2],0,ci),rt("k",["kk",2],0,Sd),rt("hmm",0,0,function(){return""+ci.apply(this)+Le(this.minutes(),2)}),rt("hmmss",0,0,function(){return""+ci.apply(this)+Le(this.minutes(),2)+Le(this.seconds(),2)}),rt("Hmm",0,0,function(){return""+this.hours()+Le(this.minutes(),2)}),rt("Hmmss",0,0,function(){return""+this.hours()+Le(this.minutes(),2)+Le(this.seconds(),2)});function Ys(o,t){rt(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}Ys("a",!0),Ys("A",!1);function Ds(o,t){return t._meridiemParse}ot("a",Ds),ot("A",Ds),ot("H",Nt,ii),ot("h",Nt,an),ot("k",Nt,an),ot("HH",Nt,zt),ot("hh",Nt,zt),ot("kk",Nt,zt),ot("hmm",Os),ot("hmmss",Cs),ot("Hmm",Os),ot("Hmmss",Cs),Et(["H","HH"],vt),Et(["k","kk"],function(o,t,e){var n=ft(o);t[vt]=n===24?0:n}),Et(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),Et(["h","hh"],function(o,t,e){t[vt]=ft(o),Rt(e).bigHour=!0}),Et("hmm",function(o,t,e){var n=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n)),Rt(e).bigHour=!0}),Et("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n,2)),t[Se]=ft(o.substr(i)),Rt(e).bigHour=!0}),Et("Hmm",function(o,t,e){var n=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n))}),Et("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n,2)),t[Se]=ft(o.substr(i))});function Ed(o){return(o+"").toLowerCase().charAt(0)==="p"}var Xd=/[ap]\.?m?\.?/i,Nd=cn("Hours",!0);function Fd(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Us={calendar:mc,longDateFormat:Pc,invalidDate:Oc,ordinal:Sc,dayOfMonthOrdinalParse:Ec,relativeTime:Nc,months:xc,monthsShort:Xs,week:nd,weekdays:cd,weekdaysMin:dd,weekdaysShort:Vs,meridiemParse:Xd},Wt={},Fn={},yn;function yd(o,t){var e,n=Math.min(o.length,t.length);for(e=0;e<n;e+=1)if(o[e]!==t[e])return e;return n}function ws(o){return o&&o.toLowerCase().replace("_","-")}function Wd(o){for(var t=0,e,n,i,r;t<o.length;){for(r=ws(o[t]).split("-"),e=r.length,n=ws(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=no(r.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&yd(r,n)>=e-1)break;e--}t++}return yn}function bd(o){return!!(o&&o.match("^[^/\\\\]*$"))}function no(o){var t=null,e;if(Wt[o]===void 0&&typeof module<"u"&&module&&module.exports&&bd(o))try{t=yn._abbr,e=require,e("./locale/"+o),we(t)}catch{Wt[o]=null}return Wt[o]}function we(o,t){var e;return o&&(kt(t)?e=Xe(o):e=di(o,t),e?yn=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),yn._abbr}function di(o,t){if(t!==null){var e,n=Us;if(t.abbr=o,Wt[o]!=null)ps("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=Wt[o]._config;else if(t.parentLocale!=null)if(Wt[t.parentLocale]!=null)n=Wt[t.parentLocale]._config;else if(e=no(t.parentLocale),e!=null)n=e._config;else return Fn[t.parentLocale]||(Fn[t.parentLocale]=[]),Fn[t.parentLocale].push({name:o,config:t}),null;return Wt[o]=new zo($o(n,t)),Fn[o]&&Fn[o].forEach(function(i){di(i.name,i.config)}),we(o),Wt[o]}else return delete Wt[o],null}function Vd(o,t){if(t!=null){var e,n,i=Us;Wt[o]!=null&&Wt[o].parentLocale!=null?Wt[o].set($o(Wt[o]._config,t)):(n=no(o),n!=null&&(i=n._config),t=$o(i,t),n==null&&(t.abbr=o),e=new zo(t),e.parentLocale=Wt[o],Wt[o]=e),we(o)}else Wt[o]!=null&&(Wt[o].parentLocale!=null?(Wt[o]=Wt[o].parentLocale,o===we()&&we(o)):Wt[o]!=null&&delete Wt[o]);return Wt[o]}function Xe(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return yn;if(!se(o)){if(t=no(o),t)return t;o=[o]}return Wd(o)}function Yd(){return jo(Wt)}function Ri(o){var t,e=o._a;return e&&Rt(o).overflow===-2&&(t=e[Ce]<0||e[Ce]>11?Ce:e[Ie]<1||e[Ie]>ri(e[xt],e[Ce])?Ie:e[vt]<0||e[vt]>24||e[vt]===24&&(e[le]!==0||e[Se]!==0||e[xe]!==0)?vt:e[le]<0||e[le]>59?le:e[Se]<0||e[Se]>59?Se:e[xe]<0||e[xe]>999?xe:-1,Rt(o)._overflowDayOfYear&&(t<xt||t>Ie)&&(t=Ie),Rt(o)._overflowWeeks&&t===-1&&(t=Zc),Rt(o)._overflowWeekday&&t===-1&&(t=Qc),Rt(o).overflow=t),o}var Dd=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ud=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,wd=/Z|[+-]\d\d(?::?\d\d)?/,oo=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],ui=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Zd=/^\/?Date\((-?\d+)/i,Qd=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,vd={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Zs(o){var t,e,n=o._i,i=Dd.exec(n)||Ud.exec(n),r,s,a,c,d=oo.length,R=ui.length;if(i){for(Rt(o).iso=!0,t=0,e=d;t<e;t++)if(oo[t][1].exec(i[1])){s=oo[t][0],r=oo[t][2]!==!1;break}if(s==null){o._isValid=!1;return}if(i[3]){for(t=0,e=R;t<e;t++)if(ui[t][1].exec(i[3])){a=(i[2]||" ")+ui[t][0];break}if(a==null){o._isValid=!1;return}}if(!r&&a!=null){o._isValid=!1;return}if(i[4])if(wd.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=s+(a||"")+(c||""),gi(o)}else o._isValid=!1}function Kd(o,t,e,n,i,r){var s=[Hd(o),Xs.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return r&&s.push(parseInt(r,10)),s}function Hd(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function _d(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function xd(o,t,e){if(o){var n=Vs.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Rt(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function Gd(o,t,e){if(o)return vd[o];if(t)return 0;var n=parseInt(e,10),i=n%100,r=(n-i)/100;return r*60+i}function Qs(o){var t=Qd.exec(_d(o._i)),e;if(t){if(e=Kd(t[4],t[3],t[2],t[5],t[6],t[7]),!xd(t[1],e,o))return;o._a=e,o._tzm=Gd(t[8],t[9],t[10]),o._d=Xn.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Rt(o).rfc2822=!0}else o._isValid=!1}function Ad(o){var t=Zd.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(Zs(o),o._isValid===!1)delete o._isValid;else return;if(Qs(o),o._isValid===!1)delete o._isValid;else return;o._strict?o._isValid=!1:q.createFromInputFallback(o)}q.createFromInputFallback=te("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(o){o._d=new Date(o._i+(o._useUTC?" UTC":""))});function dn(o,t,e){return o??t??e}function kd(o){var t=new Date(q.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function hi(o){var t,e,n=[],i,r,s;if(!o._d){for(i=kd(o),o._w&&o._a[Ie]==null&&o._a[Ce]==null&&Jd(o),o._dayOfYear!=null&&(s=dn(o._a[xt],i[xt]),(o._dayOfYear>Sn(s)||o._dayOfYear===0)&&(Rt(o)._overflowDayOfYear=!0),e=Xn(s,0,o._dayOfYear),o._a[Ce]=e.getUTCMonth(),o._a[Ie]=e.getUTCDate()),t=0;t<3&&o._a[t]==null;++t)o._a[t]=n[t]=i[t];for(;t<7;t++)o._a[t]=n[t]=o._a[t]==null?t===2?1:0:o._a[t];o._a[vt]===24&&o._a[le]===0&&o._a[Se]===0&&o._a[xe]===0&&(o._nextDay=!0,o._a[vt]=0),o._d=(o._useUTC?Xn:td).apply(null,n),r=o._useUTC?o._d.getUTCDay():o._d.getDay(),o._tzm!=null&&o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),o._nextDay&&(o._a[vt]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==r&&(Rt(o).weekdayMismatch=!0)}}function Jd(o){var t,e,n,i,r,s,a,c,d;t=o._w,t.GG!=null||t.W!=null||t.E!=null?(r=1,s=4,e=dn(t.GG,o._a[xt],Nn(Ft(),1,4).year),n=dn(t.W,1),i=dn(t.E,1),(i<1||i>7)&&(c=!0)):(r=o._locale._week.dow,s=o._locale._week.doy,d=Nn(Ft(),r,s),e=dn(t.gg,o._a[xt],d.year),n=dn(t.w,d.week),t.d!=null?(i=t.d,(i<0||i>6)&&(c=!0)):t.e!=null?(i=t.e+r,(t.e<0||t.e>6)&&(c=!0)):i=r),n<1||n>Ee(e,r,s)?Rt(o)._overflowWeeks=!0:c!=null?Rt(o)._overflowWeekday=!0:(a=bs(e,n,i,r,s),o._a[xt]=a.year,o._dayOfYear=a.dayOfYear)}q.ISO_8601=function(){},q.RFC_2822=function(){};function gi(o){if(o._f===q.ISO_8601){Zs(o);return}if(o._f===q.RFC_2822){Qs(o);return}o._a=[],Rt(o).empty=!0;var t=""+o._i,e,n,i,r,s,a=t.length,c=0,d,R;for(i=Ls(o._f,o._locale).match(qo)||[],R=i.length,e=0;e<R;e++)r=i[e],n=(t.match(Dc(r,o))||[])[0],n&&(s=t.substr(0,t.indexOf(n)),s.length>0&&Rt(o).unusedInput.push(s),t=t.slice(t.indexOf(n)+n.length),c+=n.length),rn[r]?(n?Rt(o).empty=!1:Rt(o).unusedTokens.push(r),wc(r,n,o)):o._strict&&!n&&Rt(o).unusedTokens.push(r);Rt(o).charsLeftOver=a-c,t.length>0&&Rt(o).unusedInput.push(t),o._a[vt]<=12&&Rt(o).bigHour===!0&&o._a[vt]>0&&(Rt(o).bigHour=void 0),Rt(o).parsedDateParts=o._a.slice(0),Rt(o).meridiem=o._meridiem,o._a[vt]=Bd(o._locale,o._a[vt],o._meridiem),d=Rt(o).era,d!==null&&(o._a[xt]=o._locale.erasConvertYear(d,o._a[xt])),hi(o),Ri(o)}function Bd(o,t,e){var n;return e==null?t:o.meridiemHour!=null?o.meridiemHour(t,e):(o.isPM!=null&&(n=o.isPM(e),n&&t<12&&(t+=12),!n&&t===12&&(t=0)),t)}function $d(o){var t,e,n,i,r,s,a=!1,c=o._f.length;if(c===0){Rt(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)r=0,s=!1,t=Bo({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],gi(t),ko(t)&&(s=!0),r+=Rt(t).charsLeftOver,r+=Rt(t).unusedTokens.length*10,Rt(t).score=r,a?r<n&&(n=r,e=t):(n==null||r<n||s)&&(n=r,e=t,s&&(a=!0));Ue(o,e||t)}function zd(o){if(!o._d){var t=ei(o._i),e=t.day===void 0?t.date:t.day;o._a=gs([t.year,t.month,e,t.hour,t.minute,t.second,t.millisecond],function(n){return n&&parseInt(n,10)}),hi(o)}}function jd(o){var t=new Mn(Ri(vs(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function vs(o){var t=o._i,e=o._f;return o._locale=o._locale||Xe(o._l),t===null||e===void 0&&t===""?Gn({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),re(t)?new Mn(Ri(t)):(Pn(t)?o._d=t:se(e)?$d(o):e?gi(o):qd(o),ko(o)||(o._d=null),o))}function qd(o){var t=o._i;kt(t)?o._d=new Date(q.now()):Pn(t)?o._d=new Date(t.valueOf()):typeof t=="string"?Ad(o):se(t)?(o._a=gs(t.slice(0),function(e){return parseInt(e,10)}),hi(o)):_e(t)?zd(o):Me(t)?o._d=new Date(t):q.createFromInputFallback(o)}function Ks(o,t,e,n,i){var r={};return(t===!0||t===!1)&&(n=t,t=void 0),(e===!0||e===!1)&&(n=e,e=void 0),(_e(o)&&Go(o)||se(o)&&o.length===0)&&(o=void 0),r._isAMomentObject=!0,r._useUTC=r._isUTC=i,r._l=e,r._i=o,r._f=t,r._strict=n,jd(r)}function Ft(o,t,e,n){return Ks(o,t,e,n,!1)}var tR=te("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=Ft.apply(null,arguments);return this.isValid()&&o.isValid()?o<this?this:o:Gn()}),eR=te("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=Ft.apply(null,arguments);return this.isValid()&&o.isValid()?o>this?this:o:Gn()});function Hs(o,t){var e,n;if(t.length===1&&se(t[0])&&(t=t[0]),!t.length)return Ft();for(e=t[0],n=1;n<t.length;++n)(!t[n].isValid()||t[n][o](e))&&(e=t[n]);return e}function nR(){var o=[].slice.call(arguments,0);return Hs("isBefore",o)}function oR(){var o=[].slice.call(arguments,0);return Hs("isAfter",o)}var iR=function(){return Date.now?Date.now():+new Date},Wn=["year","quarter","month","week","day","hour","minute","second","millisecond"];function sR(o){var t,e=!1,n,i=Wn.length;for(t in o)if(Mt(o,t)&&!(wt.call(Wn,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[Wn[n]]){if(e)return!1;parseFloat(o[Wn[n]])!==ft(o[Wn[n]])&&(e=!0)}return!0}function rR(){return this._isValid}function lR(){return ae(NaN)}function io(o){var t=ei(o),e=t.year||0,n=t.quarter||0,i=t.month||0,r=t.week||t.isoWeek||0,s=t.day||0,a=t.hour||0,c=t.minute||0,d=t.second||0,R=t.millisecond||0;this._isValid=sR(t),this._milliseconds=+R+d*1e3+c*6e4+a*1e3*60*60,this._days=+s+r*7,this._months=+i+n*3+e*12,this._data={},this._locale=Xe(),this._bubble()}function so(o){return o instanceof io}function fi(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function aR(o,t,e){var n=Math.min(o.length,t.length),i=Math.abs(o.length-t.length),r=0,s;for(s=0;s<n;s++)ft(o[s])!==ft(t[s])&&r++;return r+i}function _s(o,t){rt(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+Le(~~(e/60),2)+t+Le(~~e%60,2)})}_s("Z",":"),_s("ZZ",""),ot("Z",jn),ot("ZZ",jn),Et(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=Ti(jn,o)});var cR=/([\+\-]|\d\d)/gi;function Ti(o,t){var e=(t||"").match(o),n,i,r;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(cR)||["-",0,0],r=+(i[1]*60)+ft(i[2]),r===0?0:i[0]==="+"?r:-r)}function mi(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(re(o)||Pn(o)?o.valueOf():Ft(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),q.updateOffset(e,!1),e):Ft(o).local()}function pi(o){return-Math.round(o._d.getTimezoneOffset())}q.updateOffset=function(){};function dR(o,t,e){var n=this._offset||0,i;if(!this.isValid())return o!=null?this:NaN;if(o!=null){if(typeof o=="string"){if(o=Ti(jn,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=pi(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?ks(this,ae(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,q.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:pi(this)}function RR(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function uR(o){return this.utcOffset(0,o)}function hR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(pi(this),"m")),this}function gR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=Ti(Vc,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function fR(o){return this.isValid()?(o=o?Ft(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function TR(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function mR(){if(!kt(this._isDSTShifted))return this._isDSTShifted;var o={},t;return Bo(o,this),o=vs(o),o._a?(t=o._isUTC?me(o._a):Ft(o._a),this._isDSTShifted=this.isValid()&&aR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function pR(){return this.isValid()?!this._isUTC:!1}function LR(){return this.isValid()?this._isUTC:!1}function xs(){return this.isValid()?this._isUTC&&this._offset===0:!1}var IR=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,PR=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function ae(o,t){var e=o,n=null,i,r,s;return so(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:Me(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=IR.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:ft(n[Ie])*i,h:ft(n[vt])*i,m:ft(n[le])*i,s:ft(n[Se])*i,ms:ft(fi(n[xe]*1e3))*i}):(n=PR.exec(o))?(i=n[1]==="-"?-1:1,e={y:Ge(n[2],i),M:Ge(n[3],i),w:Ge(n[4],i),d:Ge(n[5],i),h:Ge(n[6],i),m:Ge(n[7],i),s:Ge(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(s=MR(Ft(e.from),Ft(e.to)),e={},e.ms=s.milliseconds,e.M=s.months),r=new io(e),so(o)&&Mt(o,"_locale")&&(r._locale=o._locale),so(o)&&Mt(o,"_isValid")&&(r._isValid=o._isValid),r}ae.fn=io.prototype,ae.invalid=lR;function Ge(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function Gs(o,t){var e={};return e.months=t.month()-o.month()+(t.year()-o.year())*12,o.clone().add(e.months,"M").isAfter(t)&&--e.months,e.milliseconds=+t-+o.clone().add(e.months,"M"),e}function MR(o,t){var e;return o.isValid()&&t.isValid()?(t=mi(t,o),o.isBefore(t)?e=Gs(o,t):(e=Gs(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function As(o,t){return function(e,n){var i,r;return n!==null&&!isNaN(+n)&&(ps(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),r=e,e=n,n=r),i=ae(e,n),ks(this,i,o),this}}function ks(o,t,e,n){var i=t._milliseconds,r=fi(t._days),s=fi(t._months);o.isValid()&&(n=n??!0,s&&Fs(o,En(o,"Month")+s*e),r&&Es(o,"Date",En(o,"Date")+r*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&q.updateOffset(o,r||s))}var OR=As(1,"add"),CR=As(-1,"subtract");function Js(o){return typeof o=="string"||o instanceof String}function SR(o){return re(o)||Pn(o)||Js(o)||Me(o)||XR(o)||ER(o)||o===null||o===void 0}function ER(o){var t=_e(o)&&!Go(o),e=!1,n=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],i,r,s=n.length;for(i=0;i<s;i+=1)r=n[i],e=e||Mt(o,r);return t&&e}function XR(o){var t=se(o),e=!1;return t&&(e=o.filter(function(n){return!Me(n)&&Js(o)}).length===0),t&&e}function NR(o){var t=_e(o)&&!Go(o),e=!1,n=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],i,r;for(i=0;i<n.length;i+=1)r=n[i],e=e||Mt(o,r);return t&&e}function FR(o,t){var e=o.diff(t,"days",!0);return e<-6?"sameElse":e<-1?"lastWeek":e<0?"lastDay":e<1?"sameDay":e<2?"nextDay":e<7?"nextWeek":"sameElse"}function yR(o,t){arguments.length===1&&(arguments[0]?SR(arguments[0])?(o=arguments[0],t=void 0):NR(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||Ft(),n=mi(e,this).startOf("day"),i=q.calendarFormat(this,n)||"sameElse",r=t&&(pe(t[i])?t[i].call(this,e):t[i]);return this.format(r||this.localeData().calendar(i,this,Ft(e)))}function WR(){return new Mn(this)}function bR(o,t){var e=re(o)?o:Ft(o);return this.isValid()&&e.isValid()?(t=ee(t)||"millisecond",t==="millisecond"?this.valueOf()>e.valueOf():e.valueOf()<this.clone().startOf(t).valueOf()):!1}function VR(o,t){var e=re(o)?o:Ft(o);return this.isValid()&&e.isValid()?(t=ee(t)||"millisecond",t==="millisecond"?this.valueOf()<e.valueOf():this.clone().endOf(t).valueOf()<e.valueOf()):!1}function YR(o,t,e,n){var i=re(o)?o:Ft(o),r=re(t)?t:Ft(t);return this.isValid()&&i.isValid()&&r.isValid()?(n=n||"()",(n[0]==="("?this.isAfter(i,e):!this.isBefore(i,e))&&(n[1]===")"?this.isBefore(r,e):!this.isAfter(r,e))):!1}function DR(o,t){var e=re(o)?o:Ft(o),n;return this.isValid()&&e.isValid()?(t=ee(t)||"millisecond",t==="millisecond"?this.valueOf()===e.valueOf():(n=e.valueOf(),this.clone().startOf(t).valueOf()<=n&&n<=this.clone().endOf(t).valueOf())):!1}function UR(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function wR(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function ZR(o,t,e){var n,i,r;if(!this.isValid())return NaN;if(n=mi(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=ee(t),t){case"year":r=ro(this,n)/12;break;case"month":r=ro(this,n);break;case"quarter":r=ro(this,n)/3;break;case"second":r=(this-n)/1e3;break;case"minute":r=(this-n)/6e4;break;case"hour":r=(this-n)/36e5;break;case"day":r=(this-n-i)/864e5;break;case"week":r=(this-n-i)/6048e5;break;default:r=this-n}return e?r:ne(r)}function ro(o,t){if(o.date()<t.date())return-ro(t,o);var e=(t.year()-o.year())*12+(t.month()-o.month()),n=o.clone().add(e,"months"),i,r;return t-n<0?(i=o.clone().add(e-1,"months"),r=(t-n)/(n-i)):(i=o.clone().add(e+1,"months"),r=(t-n)/(i-n)),-(e+r)||0}q.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",q.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function QR(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function vR(o){if(!this.isValid())return null;var t=o!==!0,e=t?this.clone().utc():this;return e.year()<0||e.year()>9999?kn(e,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):pe(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",kn(e,"Z")):kn(e,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function KR(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var o="moment",t="",e,n,i,r;return this.isLocal()||(o=this.utcOffset()===0?"moment.utc":"moment.parseZone",t="Z"),e="["+o+'("]',n=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i="-MM-DD[T]HH:mm:ss.SSS",r=t+'[")]',this.format(e+n+i+r)}function HR(o){o||(o=this.isUtc()?q.defaultFormatUtc:q.defaultFormat);var t=kn(this,o);return this.localeData().postformat(t)}function _R(o,t){return this.isValid()&&(re(o)&&o.isValid()||Ft(o).isValid())?ae({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function xR(o){return this.from(Ft(),o)}function GR(o,t){return this.isValid()&&(re(o)&&o.isValid()||Ft(o).isValid())?ae({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function AR(o){return this.to(Ft(),o)}function Bs(o){var t;return o===void 0?this._locale._abbr:(t=Xe(o),t!=null&&(this._locale=t),this)}var $s=te("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(o){return o===void 0?this.localeData():this.locale(o)});function zs(){return this._locale}var lo=1e3,Rn=60*lo,ao=60*Rn,js=(365*400+97)*24*ao;function un(o,t){return(o%t+t)%t}function qs(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-js:new Date(o,t,e).valueOf()}function tr(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-js:Date.UTC(o,t,e)}function kR(o){var t,e;if(o=ee(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?tr:qs,o){case"year":t=e(this.year(),0,1);break;case"quarter":t=e(this.year(),this.month()-this.month()%3,1);break;case"month":t=e(this.year(),this.month(),1);break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=e(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=un(t+(this._isUTC?0:this.utcOffset()*Rn),ao);break;case"minute":t=this._d.valueOf(),t-=un(t,Rn);break;case"second":t=this._d.valueOf(),t-=un(t,lo);break}return this._d.setTime(t),q.updateOffset(this,!0),this}function JR(o){var t,e;if(o=ee(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?tr:qs,o){case"year":t=e(this.year()+1,0,1)-1;break;case"quarter":t=e(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=e(this.year(),this.month()+1,1)-1;break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=e(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=ao-un(t+(this._isUTC?0:this.utcOffset()*Rn),ao)-1;break;case"minute":t=this._d.valueOf(),t+=Rn-un(t,Rn)-1;break;case"second":t=this._d.valueOf(),t+=lo-un(t,lo)-1;break}return this._d.setTime(t),q.updateOffset(this,!0),this}function BR(){return this._d.valueOf()-(this._offset||0)*6e4}function $R(){return Math.floor(this.valueOf()/1e3)}function zR(){return new Date(this.valueOf())}function jR(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function qR(){var o=this;return{years:o.year(),months:o.month(),date:o.date(),hours:o.hours(),minutes:o.minutes(),seconds:o.seconds(),milliseconds:o.milliseconds()}}function tu(){return this.isValid()?this.toISOString():null}function eu(){return ko(this)}function nu(){return Ue({},Rt(this))}function ou(){return Rt(this).overflow}function iu(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}rt("N",0,0,"eraAbbr"),rt("NN",0,0,"eraAbbr"),rt("NNN",0,0,"eraAbbr"),rt("NNNN",0,0,"eraName"),rt("NNNNN",0,0,"eraNarrow"),rt("y",["y",1],"yo","eraYear"),rt("y",["yy",2],0,"eraYear"),rt("y",["yyy",3],0,"eraYear"),rt("y",["yyyy",4],0,"eraYear"),ot("N",Li),ot("NN",Li),ot("NNN",Li),ot("NNNN",fu),ot("NNNNN",Tu),Et(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Rt(e).era=i:Rt(e).invalidEra=o}),ot("y",ln),ot("yy",ln),ot("yyy",ln),ot("yyyy",ln),ot("yo",mu),Et(["y","yy","yyy","yyyy"],xt),Et(["yo"],function(o,t,e,n){var i;e._locale._eraYearOrdinalRegex&&(i=o.match(e._locale._eraYearOrdinalRegex)),e._locale.eraYearOrdinalParse?t[xt]=e._locale.eraYearOrdinalParse(o,i):t[xt]=parseInt(o,10)});function su(o,t){var e,n,i,r=this._eras||Xe("en")._eras;for(e=0,n=r.length;e<n;++e)switch(typeof r[e].since==="string"&&(i=q(r[e].since).startOf("day"),r[e].since=i.valueOf()),typeof r[e].until){case"undefined":r[e].until=1/0;break;case"string":i=q(r[e].until).startOf("day").valueOf(),r[e].until=i.valueOf();break}return r}function ru(o,t,e){var n,i,r=this.eras(),s,a,c;for(o=o.toUpperCase(),n=0,i=r.length;n<i;++n)if(s=r[n].name.toUpperCase(),a=r[n].abbr.toUpperCase(),c=r[n].narrow.toUpperCase(),e)switch(t){case"N":case"NN":case"NNN":if(a===o)return r[n];break;case"NNNN":if(s===o)return r[n];break;case"NNNNN":if(c===o)return r[n];break}else if([s,a,c].indexOf(o)>=0)return r[n]}function lu(o,t){var e=o.since<=o.until?1:-1;return t===void 0?q(o.since).year():q(o.since).year()+(t-o.offset)*e}function au(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].name;return""}function cu(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].narrow;return""}function du(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].abbr;return""}function Ru(){var o,t,e,n,i=this.localeData().eras();for(o=0,t=i.length;o<t;++o)if(e=i[o].since<=i[o].until?1:-1,n=this.clone().startOf("day").valueOf(),i[o].since<=n&&n<=i[o].until||i[o].until<=n&&n<=i[o].since)return(this.year()-q(i[o].since).year())*e+i[o].offset;return this.year()}function uu(o){return Mt(this,"_erasNameRegex")||Ii.call(this),o?this._erasNameRegex:this._erasRegex}function hu(o){return Mt(this,"_erasAbbrRegex")||Ii.call(this),o?this._erasAbbrRegex:this._erasRegex}function gu(o){return Mt(this,"_erasNarrowRegex")||Ii.call(this),o?this._erasNarrowRegex:this._erasRegex}function Li(o,t){return t.erasAbbrRegex(o)}function fu(o,t){return t.erasNameRegex(o)}function Tu(o,t){return t.erasNarrowRegex(o)}function mu(o,t){return t._eraYearOrdinalRegex||ln}function Ii(){var o=[],t=[],e=[],n=[],i,r,s,a,c,d=this.eras();for(i=0,r=d.length;i<r;++i)s=Oe(d[i].name),a=Oe(d[i].abbr),c=Oe(d[i].narrow),t.push(s),o.push(a),e.push(c),n.push(s),n.push(a),n.push(c);this._erasRegex=new RegExp("^("+n.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+t.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+o.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+e.join("|")+")","i")}rt(0,["gg",2],0,function(){return this.weekYear()%100}),rt(0,["GG",2],0,function(){return this.isoWeekYear()%100});function co(o,t){rt(0,[o,o.length],0,t)}co("gggg","weekYear"),co("ggggg","weekYear"),co("GGGG","isoWeekYear"),co("GGGGG","isoWeekYear"),ot("G",zn),ot("g",zn),ot("GG",Nt,zt),ot("gg",Nt,zt),ot("GGGG",oi,ni),ot("gggg",oi,ni),ot("GGGGG",$n,Jn),ot("ggggg",$n,Jn),Cn(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=ft(o)}),Cn(["gg","GG"],function(o,t,e,n){t[n]=q.parseTwoDigitYear(o)});function pu(o){return er.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function Lu(o){return er.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function Iu(){return Ee(this.year(),1,4)}function Pu(){return Ee(this.isoWeekYear(),1,4)}function Mu(){var o=this.localeData()._week;return Ee(this.year(),o.dow,o.doy)}function Ou(){var o=this.localeData()._week;return Ee(this.weekYear(),o.dow,o.doy)}function er(o,t,e,n,i){var r;return o==null?Nn(this,n,i).year:(r=Ee(o,n,i),t>r&&(t=r),Cu.call(this,o,t,e,n,i))}function Cu(o,t,e,n,i){var r=bs(o,t,e,n,i),s=Xn(r.year,0,r.dayOfYear);return this.year(s.getUTCFullYear()),this.month(s.getUTCMonth()),this.date(s.getUTCDate()),this}rt("Q",0,"Qo","quarter"),ot("Q",Ps),Et("Q",function(o,t){t[Ce]=(ft(o)-1)*3});function Su(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}rt("D",["DD",2],"Do","date"),ot("D",Nt,an),ot("DD",Nt,zt),ot("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Et(["D","DD"],Ie),Et("Do",function(o,t){t[Ie]=ft(o.match(Nt)[0])});var nr=cn("Date",!0);rt("DDD",["DDDD",3],"DDDo","dayOfYear"),ot("DDD",Bn),ot("DDDD",Ms),Et(["DDD","DDDD"],function(o,t,e){e._dayOfYear=ft(o)});function Eu(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}rt("m",["mm",2],0,"minute"),ot("m",Nt,ii),ot("mm",Nt,zt),Et(["m","mm"],le);var Xu=cn("Minutes",!1);rt("s",["ss",2],0,"second"),ot("s",Nt,ii),ot("ss",Nt,zt),Et(["s","ss"],Se);var Nu=cn("Seconds",!1);rt("S",0,0,function(){return~~(this.millisecond()/100)}),rt(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),rt(0,["SSS",3],0,"millisecond"),rt(0,["SSSS",4],0,function(){return this.millisecond()*10}),rt(0,["SSSSS",5],0,function(){return this.millisecond()*100}),rt(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),rt(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),rt(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),rt(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),ot("S",Bn,Ps),ot("SS",Bn,zt),ot("SSS",Bn,Ms);var Ze,or;for(Ze="SSSS";Ze.length<=9;Ze+="S")ot(Ze,ln);function Fu(o,t){t[xe]=ft(("0."+o)*1e3)}for(Ze="S";Ze.length<=9;Ze+="S")Et(Ze,Fu);or=cn("Milliseconds",!1),rt("z",0,0,"zoneAbbr"),rt("zz",0,0,"zoneName");function yu(){return this._isUTC?"UTC":""}function Wu(){return this._isUTC?"Coordinated Universal Time":""}var k=Mn.prototype;k.add=OR,k.calendar=yR,k.clone=WR,k.diff=ZR,k.endOf=JR,k.format=HR,k.from=_R,k.fromNow=xR,k.to=GR,k.toNow=AR,k.get=Kc,k.invalidAt=ou,k.isAfter=bR,k.isBefore=VR,k.isBetween=YR,k.isSame=DR,k.isSameOrAfter=UR,k.isSameOrBefore=wR,k.isValid=eu,k.lang=$s,k.locale=Bs,k.localeData=zs,k.max=eR,k.min=tR,k.parsingFlags=nu,k.set=Hc,k.startOf=kR,k.subtract=CR,k.toArray=jR,k.toObject=qR,k.toDate=zR,k.toISOString=vR,k.inspect=KR,typeof Symbol<"u"&&Symbol.for!=null&&(k[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),k.toJSON=tu,k.toString=QR,k.unix=$R,k.valueOf=BR,k.creationData=iu,k.eraName=au,k.eraNarrow=cu,k.eraAbbr=du,k.eraYear=Ru,k.year=Ss,k.isLeapYear=vc,k.weekYear=pu,k.isoWeekYear=Lu,k.quarter=k.quarters=Su,k.month=ys,k.daysInMonth=zc,k.week=k.weeks=sd,k.isoWeek=k.isoWeeks=rd,k.weeksInYear=Mu,k.weeksInWeekYear=Ou,k.isoWeeksInYear=Iu,k.isoWeeksInISOWeekYear=Pu,k.date=nr,k.day=k.days=Ld,k.weekday=Id,k.isoWeekday=Pd,k.dayOfYear=Eu,k.hour=k.hours=Nd,k.minute=k.minutes=Xu,k.second=k.seconds=Nu,k.millisecond=k.milliseconds=or,k.utcOffset=dR,k.utc=uR,k.local=hR,k.parseZone=gR,k.hasAlignedHourOffset=fR,k.isDST=TR,k.isLocal=pR,k.isUtcOffset=LR,k.isUtc=xs,k.isUTC=xs,k.zoneAbbr=yu,k.zoneName=Wu,k.dates=te("dates accessor is deprecated. Use date instead.",nr),k.months=te("months accessor is deprecated. Use month instead",ys),k.years=te("years accessor is deprecated. Use year instead",Ss),k.zone=te("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",RR),k.isDSTShifted=te("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",mR);function bu(o){return Ft(o*1e3)}function Vu(){return Ft.apply(null,arguments).parseZone()}function ir(o){return o}var Ot=zo.prototype;Ot.calendar=pc,Ot.longDateFormat=Mc,Ot.invalidDate=Cc,Ot.ordinal=Xc,Ot.preparse=ir,Ot.postformat=ir,Ot.relativeTime=Fc,Ot.pastFuture=yc,Ot.set=Tc,Ot.eras=su,Ot.erasParse=ru,Ot.erasConvertYear=lu,Ot.erasAbbrRegex=hu,Ot.erasNameRegex=uu,Ot.erasNarrowRegex=gu,Ot.months=kc,Ot.monthsShort=Jc,Ot.monthsParse=$c,Ot.monthsRegex=qc,Ot.monthsShortRegex=jc,Ot.week=ed,Ot.firstDayOfYear=id,Ot.firstDayOfWeek=od,Ot.weekdays=gd,Ot.weekdaysMin=Td,Ot.weekdaysShort=fd,Ot.weekdaysParse=pd,Ot.weekdaysRegex=Md,Ot.weekdaysShortRegex=Od,Ot.weekdaysMinRegex=Cd,Ot.isPM=Ed,Ot.meridiem=Fd;function Ro(o,t,e,n){var i=Xe(),r=me().set(n,t);return i[e](r,o)}function sr(o,t,e){if(Me(o)&&(t=o,o=void 0),o=o||"",t!=null)return Ro(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=Ro(o,n,e,"month");return i}function Pi(o,t,e,n){typeof o=="boolean"?(Me(t)&&(e=t,t=void 0),t=t||""):(t=o,e=t,o=!1,Me(t)&&(e=t,t=void 0),t=t||"");var i=Xe(),r=o?i._week.dow:0,s,a=[];if(e!=null)return Ro(t,(e+r)%7,n,"day");for(s=0;s<7;s++)a[s]=Ro(t,(s+r)%7,n,"day");return a}function Yu(o,t){return sr(o,t,"months")}function Du(o,t){return sr(o,t,"monthsShort")}function Uu(o,t,e){return Pi(o,t,e,"weekdays")}function wu(o,t,e){return Pi(o,t,e,"weekdaysShort")}function Zu(o,t,e){return Pi(o,t,e,"weekdaysMin")}we("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(o){var t=o%10,e=ft(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),q.lang=te("moment.lang is deprecated. Use moment.locale instead.",we),q.langData=te("moment.langData is deprecated. Use moment.localeData instead.",Xe);var Ne=Math.abs;function Qu(){var o=this._data;return this._milliseconds=Ne(this._milliseconds),this._days=Ne(this._days),this._months=Ne(this._months),o.milliseconds=Ne(o.milliseconds),o.seconds=Ne(o.seconds),o.minutes=Ne(o.minutes),o.hours=Ne(o.hours),o.months=Ne(o.months),o.years=Ne(o.years),this}function rr(o,t,e,n){var i=ae(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function vu(o,t){return rr(this,o,t,1)}function Ku(o,t){return rr(this,o,t,-1)}function lr(o){return o<0?Math.floor(o):Math.ceil(o)}function Hu(){var o=this._milliseconds,t=this._days,e=this._months,n=this._data,i,r,s,a,c;return o>=0&&t>=0&&e>=0||o<=0&&t<=0&&e<=0||(o+=lr(Mi(e)+t)*864e5,t=0,e=0),n.milliseconds=o%1e3,i=ne(o/1e3),n.seconds=i%60,r=ne(i/60),n.minutes=r%60,s=ne(r/60),n.hours=s%24,t+=ne(s/24),c=ne(ar(t)),e+=c,t-=lr(Mi(c)),a=ne(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function ar(o){return o*4800/146097}function Mi(o){return o*146097/4800}function _u(o){if(!this.isValid())return NaN;var t,e,n=this._milliseconds;if(o=ee(o),o==="month"||o==="quarter"||o==="year")switch(t=this._days+n/864e5,e=this._months+ar(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(Mi(this._months)),o){case"week":return t/7+n/6048e5;case"day":return t+n/864e5;case"hour":return t*24+n/36e5;case"minute":return t*1440+n/6e4;case"second":return t*86400+n/1e3;case"millisecond":return Math.floor(t*864e5)+n;default:throw new Error("Unknown unit "+o)}}function Fe(o){return function(){return this.as(o)}}var cr=Fe("ms"),xu=Fe("s"),Gu=Fe("m"),Au=Fe("h"),ku=Fe("d"),Ju=Fe("w"),Bu=Fe("M"),$u=Fe("Q"),zu=Fe("y"),ju=cr;function qu(){return ae(this)}function th(o){return o=ee(o),this.isValid()?this[o+"s"]():NaN}function Ae(o){return function(){return this.isValid()?this._data[o]:NaN}}var eh=Ae("milliseconds"),nh=Ae("seconds"),oh=Ae("minutes"),ih=Ae("hours"),sh=Ae("days"),rh=Ae("months"),lh=Ae("years");function ah(){return ne(this.days()/7)}var ye=Math.round,hn={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function ch(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function dh(o,t,e,n){var i=ae(o).abs(),r=ye(i.as("s")),s=ye(i.as("m")),a=ye(i.as("h")),c=ye(i.as("d")),d=ye(i.as("M")),R=ye(i.as("w")),u=ye(i.as("y")),h=r<=e.ss&&["s",r]||r<e.s&&["ss",r]||s<=1&&["m"]||s<e.m&&["mm",s]||a<=1&&["h"]||a<e.h&&["hh",a]||c<=1&&["d"]||c<e.d&&["dd",c];return e.w!=null&&(h=h||R<=1&&["w"]||R<e.w&&["ww",R]),h=h||d<=1&&["M"]||d<e.M&&["MM",d]||u<=1&&["y"]||["yy",u],h[2]=t,h[3]=+o>0,h[4]=n,ch.apply(null,h)}function Rh(o){return o===void 0?ye:typeof o=="function"?(ye=o,!0):!1}function uh(o,t){return hn[o]===void 0?!1:t===void 0?hn[o]:(hn[o]=t,o==="s"&&(hn.ss=t-1),!0)}function hh(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=hn,i,r;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},hn,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),r=dh(this,!e,n,i),e&&(r=i.pastFuture(+this,r)),i.postformat(r)}var Oi=Math.abs;function gn(o){return(o>0)-(o<0)||+o}function uo(){if(!this.isValid())return this.localeData().invalidDate();var o=Oi(this._milliseconds)/1e3,t=Oi(this._days),e=Oi(this._months),n,i,r,s,a=this.asSeconds(),c,d,R,u;return a?(n=ne(o/60),i=ne(n/60),o%=60,n%=60,r=ne(e/12),e%=12,s=o?o.toFixed(3).replace(/\.?0+$/,""):"",c=a<0?"-":"",d=gn(this._months)!==gn(a)?"-":"",R=gn(this._days)!==gn(a)?"-":"",u=gn(this._milliseconds)!==gn(a)?"-":"",c+"P"+(r?d+r+"Y":"")+(e?d+e+"M":"")+(t?R+t+"D":"")+(i||n||o?"T":"")+(i?u+i+"H":"")+(n?u+n+"M":"")+(o?u+s+"S":"")):"P0D"}var Lt=io.prototype;Lt.isValid=rR,Lt.abs=Qu,Lt.add=vu,Lt.subtract=Ku,Lt.as=_u,Lt.asMilliseconds=cr,Lt.asSeconds=xu,Lt.asMinutes=Gu,Lt.asHours=Au,Lt.asDays=ku,Lt.asWeeks=Ju,Lt.asMonths=Bu,Lt.asQuarters=$u,Lt.asYears=zu,Lt.valueOf=ju,Lt._bubble=Hu,Lt.clone=qu,Lt.get=th,Lt.milliseconds=eh,Lt.seconds=nh,Lt.minutes=oh,Lt.hours=ih,Lt.days=sh,Lt.weeks=ah,Lt.months=rh,Lt.years=lh,Lt.humanize=hh,Lt.toISOString=uo,Lt.toString=uo,Lt.toJSON=uo,Lt.locale=Bs,Lt.localeData=zs,Lt.toIsoString=te("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",uo),Lt.lang=$s,rt("X",0,0,"unix"),rt("x",0,0,"valueOf"),ot("x",zn),ot("X",Yc),Et("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),Et("x",function(o,t,e){e._d=new Date(ft(o))});q.version="2.30.1",gc(Ft),q.fn=k,q.min=nR,q.max=oR,q.now=iR,q.utc=me,q.unix=bu,q.months=Yu,q.isDate=Pn,q.locale=we,q.invalid=Gn,q.duration=ae,q.isMoment=re,q.weekdays=Uu,q.parseZone=Vu,q.localeData=Xe,q.isDuration=so,q.monthsShort=Du,q.weekdaysMin=Zu,q.defineLocale=di,q.updateLocale=Vd,q.locales=Yd,q.weekdaysShort=wu,q.normalizeUnits=ee,q.relativeTimeRounding=Rh,q.relativeTimeThreshold=uh,q.calendarFormat=FR,q.prototype=k,q.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};class Ci{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),r=t?null:i.getTd();n>=e.length&&(n=e.length-1);const s=e[n],a=[];let c=r,d=e,R=n;for(;;){if(R<0&&c?.linkTdPrevId){const T=i.getTdById(c.linkTdPrevId);if(T){d=T.value,R=d.length-1,c=T;continue}}if(R<0)break;const f=d[R];if(f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.PREFIX||f.controlComponent===l.ControlComponent.PRE_TEXT)break;f.controlComponent===l.ControlComponent.VALUE&&a.unshift(f),R--}c=r;let u=e,h=n+1;for(;;){if(h>=u.length&&c?.linkTdNextId){const T=i.getTdById(c.linkTdNextId);if(T){u=T.value,h=0,c=T;continue}}const f=u[h];if(!f||f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.POSTFIX||f.controlComponent===l.ControlComponent.POST_TEXT)break;f.controlComponent===l.ControlComponent.VALUE&&a.push(f),h++}return a.filter(f=>f.type!==l.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=d.controlId;this._removeControlPlaceholders(i,s);const u=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]),h=!!this.element.control?.underline,g=this.options.mode===l.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled&&!h,f=r.startIndex+1,T=[],p=m=>{const I=T.length?T:i,L=T.length?T.length-1:r.startIndex;Ut(I,[m],L,{editorOptions:this.options}),T.push(m)};for(let m=0;m<t.length;m++){const I=t[m];if(I.type===l.ElementType.CONTROL&&I.control){const L=I,P=L.controlId||lt(),O=L.control?.value||[],S=L.control?.type===l.ControlType.TEXTFIELD,F={...u,controlId:P,type:l.ElementType.CONTROL,control:L.control,originControlId:R},N=S?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,V=S?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,Y=S?L.control?.preTextFix||this.options.control.preTextFix:L.control?.prefix||this.options.control.prefix;for(let b=0;b<Y.length;b++){const E={...F,value:Y[b],controlComponent:N};p(E)}for(let b=0;b<O.length;b++){const E=O[b],C={...F,...E,controlComponent:l.ControlComponent.VALUE};(C.color===this.options.control.bracketColor||C.color===this.options.control.placeholderColor)&&(C.color=this.options.defaultColor),p(C)}if(O.length===0){const b=L.control?.placeholder||"";for(let E=0;E<b.length;E++){const C={...F,value:b[E],controlComponent:l.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};p(C)}}const X=S?L.control?.postTextFix||this.options.control.postTextFix:L.control?.postfix||this.options.control.postfix;for(let b=0;b<X.length;b++){const E={...F,value:X[b],controlComponent:V};p(E)}}else if(I.type||I.value){(d.controlComponent===l.ControlComponent.PRE_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.POSTFIX)&&(u.color=this.options.defaultColor);const P={...u,...I,controlComponent:l.ControlComponent.VALUE};(P.color===this.options.control.bracketColor||P.color===this.options.control.placeholderColor||P.color===this.options.control.textFixColor)&&(P.color=this.options.defaultColor),P.strikeout&&delete P.strikeout,g&&(P.textDecoration={style:l.TextDecorationStyle.DOUBLE},P.underline=!0),p(P)}}return T.length&&c.spliceElementList(i,f,0,T),r.startIndex+T.length}_removeControlPlaceholders(t,e){const n=t[e];if(!n?.controlId)return;const i=a=>!!a&&a.controlId===n.controlId&&a.originControlId===n.originControlId;let r=e;for(;r>=0&&i(t[r]);)r--;let s=e+1;for(;s<t.length&&i(t[s]);)s++;for(let a=s-1;a>r;a--)t[a].controlComponent===l.ControlComponent.PLACEHOLDER&&t.splice(a,1)}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:r,endIndex:s}=i;return this.control.getDraw().spliceElementList(n,r+1,s-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(r,t)),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.control.getDraw(),d=!!s.originControlId;if(t.key===l.KeyMap.Backspace)if(this.options.mode===l.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&!d){if(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER)return i;this.strikeout()}else{if(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER)return i;if(i!==r){c.spliceElementList(e,i+1,r-i);const u=e[i+1];return(u?.controlComponent===l.ControlComponent.POSTFIX||u?.controlComponent===l.ControlComponent.POST_TEXT||u?.controlComponent===l.ControlComponent.POSTTEXTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(i),i===0&&e[0].type===l.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i}else{const u=e[i+1];return u?.controlComponent===l.ControlComponent.POSTFIX||u?.controlComponent===l.ControlComponent.POST_TEXT||u?.controlComponent===l.ControlComponent.POSTTEXTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT?(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),i-1):(c.spliceElementList(e,i,1),i===1&&e[0].type===l.ElementType.SPLIT_TAG||i===0?c.fixPosition(!0)??i-1:i-1)}}else if(t.key===l.KeyMap.Delete){const R=e[r+1],u=!!s.originControlId;if(this.options.mode===l.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&!u){if(a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||a.controlComponent===l.ControlComponent.POSTTEXTFIX||a.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER)return r;if(R?.controlComponent===l.ControlComponent.POSTFIX||R?.controlComponent===l.ControlComponent.POST_TEXT||R?.controlComponent===l.ControlComponent.POSTTEXTFIX||R?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)return c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i;this.strikeout()}else{const g=e[r+1];return s.controlComponent===l.ControlComponent.PLACEHOLDER?r:g?.controlComponent===l.ControlComponent.POSTFIX||g?.controlComponent===l.ControlComponent.POST_TEXT||g?.controlComponent===l.ControlComponent.POSTTEXTFIX||g?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT?(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):i!==r?(c.spliceElementList(e,i+1,r-i),i===0&&e[0].type===l.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):g?(c.spliceElementList(e,i+1,1),i===0&&e[0].type===l.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):(c.getTd()?.linkTdNextId&&s.controlId&&this.removeNextControlElement(s.controlId),r)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();n.spliceElementList(i,t+1,e-t);const r=i[t+1];return(r?.controlComponent===l.ControlComponent.POSTFIX||r?.controlComponent===l.ControlComponent.POST_TEXT||r?.controlComponent===l.ControlComponent.POSTTEXTFIX||r?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(t),t}strikeout(t){const e=this.control.getRange(),{endIndex:n}=e,{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return;const s=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=q(new Date).format("YYYY-MM-DD HH:mm:ss");if(s?.length){if(!this.element.strikeout){const d=s.findIndex(R=>!R.strikeout);s.forEach(R=>{R.deletePerson="SWJ",R.deleteTime=c,R.strikeout=!!~d}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),setTimeout(()=>{this.strikeoute()},100)}}else{const d=this.control.getElementList()[a.index],R=this.control.getElementList();if(!this.control.getElementList()[a.index].strikeout&&d?.metrics.width>0){this.control.getElementList()[a.index].strikeout=!0,this.control.getElementList()[a.index].deletePerson="SWJ",this.control.getElementList()[a.index].deleteTime=c;const u=--a.index;setTimeout(()=>{this.strikeoute()},100),setTimeout(()=>{const g=u;this.draws.render({curIndex:g,isSetCursor:!0}),a.index=u,this.position.setCursorPosition(a),this.ranges.setRange(u,u)},100)}else n>=0&&n<R.length&&R[n]?.metrics?.width!==void 0&&R[n].metrics.width<=0&&!R[n]?.strikeout&&(setTimeout(()=>{R.splice(n,1)},100),setTimeout(()=>{const h=n-1;this.draws.render({curIndex:h,isSetCursor:!0}),a.index=h,delete a.value,this.position.setCursorPosition(a),this.ranges.setRange(h,h)},100))}}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:r}=this.ranges.getRange(),a=this.draws.getElementList()[r];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}class dr{draw;options;now;dom;renderOptions;isDatePicker;pickDate;lang;constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${z}-date-container`),t.setAttribute(de,l.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${z}-date-wrap`);const n=document.createElement("div");n.classList.add(`${z}-date-title`);const i=document.createElement("span");i.classList.add(`${z}-date-title__pre-year`),i.innerText="<<";const r=document.createElement("span");r.classList.add(`${z}-date-title__pre-month`),r.innerText="<";const s=document.createElement("span");s.classList.add(`${z}-date-title__now`);const a=document.createElement("span");a.classList.add(`${z}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${z}-date-title__next-year`),c.innerText=">>",n.append(i),n.append(r),n.append(s),n.append(a),n.append(c);const d=document.createElement("div");d.classList.add(`${z}-date-week`);const{weeks:{sun:R,mon:u,tue:h,wed:g,thu:f,fri:T,sat:p}}=this.lang;[R,u,h,g,f,T,p].forEach(b=>{const E=document.createElement("span");E.innerText=`${b}`,d.append(E)});const I=document.createElement("div");I.classList.add(`${z}-date-day`),e.append(n),e.append(d),e.append(I);const L=document.createElement("ul");L.classList.add(`${z}-time-wrap`);let P,O,S;[this.lang.hour,this.lang.minute,this.lang.second].forEach((b,E)=>{const C=document.createElement("li"),M=document.createElement("span");M.innerText=b,C.append(M);const y=document.createElement("ol"),W=E===0,D=E===1,U=W?24:60;for(let Q=0;Q<U;Q++){const G=document.createElement("li");G.innerText=`${String(Q).padStart(2,"0")}`,G.setAttribute("data-id",`${Q}`),y.append(G)}W?P=y:D?O=y:S=y,C.append(y),L.append(C)});const N=document.createElement("div");N.classList.add(`${z}-date-menu`);const V=document.createElement("button");V.classList.add(`${z}-date-menu__time`),V.innerText=this.lang.timeSelect;const Y=document.createElement("button");Y.classList.add(`${z}-date-menu__now`),Y.innerText=this.lang.now;const X=document.createElement("button");return X.classList.add(`${z}-date-menu__submit`),X.innerText=this.lang.confirm,N.append(V),N.append(Y),N.append(X),t.append(e),t.append(L),t.append(N),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:L,title:{preYear:i,preMonth:r,now:s,nextMonth:a,nextYear:c},day:I,time:{hour:P,minute:O,second:S},menu:{time:V,now:Y,submit:X}}}_bindEvent(){this.dom.title.preYear.onclick=()=>{this._preYear()},this.dom.title.preMonth.onclick=()=>{this._preMonth()},this.dom.title.nextMonth.onclick=()=>{this._nextMonth()},this.dom.title.nextYear.onclick=()=>{this._nextYear()},this.dom.menu.time.onclick=()=>{this.isDatePicker=!this.isDatePicker,this._toggleDateTimePicker()},this.dom.menu.now.onclick=()=>{this._now(),this._submit()},this.dom.menu.submit.onclick=()=>{this.dispose(),this._submit()},this.dom.time.hour.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setHours(Number(n)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setMinutes(Number(n)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setSeconds(Number(n)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:n,pageNo:i}}=this.renderOptions,r=this.draw.getHeight(),s=this.draw.getPageGap(),c=(i??this.draw.getPageNo())*(r+s);this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+c+n}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){const t=this.renderOptions?.value;if(t){const e=new Date(t);this.now=this.isInvalidDate(e)?new Date:e}else this.now=new Date;this.pickDate=new Date(this.now)}_getLang(){const t=this.draw.getI18n(),e=t.t.bind(t);return{now:e("datePicker.now"),confirm:e("datePicker.confirm"),return:e("datePicker.return"),timeSelect:e("datePicker.timeSelect"),weeks:{sun:e("datePicker.weeks.sun"),mon:e("datePicker.weeks.mon"),tue:e("datePicker.weeks.tue"),wed:e("datePicker.weeks.wed"),thu:e("datePicker.weeks.thu"),fri:e("datePicker.weeks.fri"),sat:e("datePicker.weeks.sat")},year:e("datePicker.year"),month:e("datePicker.month"),hour:e("datePicker.hour"),minute:e("datePicker.minute"),second:e("datePicker.second")}}_setLangChange(){this.dom.menu.time.innerText=this.lang.timeSelect,this.dom.menu.now.innerText=this.lang.now,this.dom.menu.submit.innerText=this.lang.confirm;const{weeks:{sun:t,mon:e,tue:n,wed:i,thu:r,fri:s,sat:a}}=this.lang,c=[t,e,n,i,r,s,a];this.dom.datePickerWeek.childNodes.forEach((h,g)=>{const f=h;f.innerText=c[g]});const d=this.dom.time.hour.previousElementSibling;d.innerText=this.lang.hour;const R=this.dom.time.minute.previousElementSibling;R.innerText=this.lang.minute;const u=this.dom.time.second.previousElementSibling;u.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();let r=null,s=null,a=null;this.pickDate&&(r=this.pickDate.getFullYear(),s=this.pickDate.getMonth()+1,a=this.pickDate.getDate());const c=this.now.getFullYear(),d=this.now.getMonth()+1;this.dom.title.now.innerText=`${c}${this.lang.year} ${String(d).padStart(2,"0")}${this.lang.month}`;const u=new Date(c,d,0).getDate();let h=new Date(c,d-1,1).getDay();h===0&&(h=7);const g=new Date(c,d-1,0).getDate();this.dom.day.innerHTML="";const f=g-h+1;for(let p=f;p<=g;p++){const m=document.createElement("div");m.classList.add("disable"),m.innerText=`${p}`,m.onclick=()=>{const I=d-2;this.now=new Date(c,I,p),this._setDatePick(c,I,p)},this.dom.day.append(m)}for(let p=1;p<=u;p++){const m=document.createElement("div");e===c&&n===d&&i===p&&m.classList.add("active"),this.pickDate&&r===c&&s===d&&a===p&&m.classList.add("select"),m.innerText=`${p}`,m.onclick=I=>{const L=d-1;this.now=new Date(c,L,p),this._setDatePick(c,L,p),I.stopPropagation()},this.dom.day.append(m)}const T=42-h-u;for(let p=1;p<=T;p++){const m=document.createElement("div");m.classList.add("disable"),m.innerText=`${p}`,m.onclick=()=>{this.now=new Date(c,d,p),this._setDatePick(c,d,p)},this.dom.day.append(m)}}_toggleDateTimePicker(){this.isDatePicker?(this.dom.dateWrap.classList.add("active"),this.dom.timeWrap.classList.remove("active"),this.dom.menu.time.innerText=this.lang.timeSelect):(this.dom.dateWrap.classList.remove("active"),this.dom.timeWrap.classList.add("active"),this.dom.menu.time.innerText=this.lang.return,this._setTimePick())}_setDatePick(t,e,n){this.now=new Date(t,e,n),this.pickDate?.setFullYear(t),this.pickDate?.setMonth(e),this.pickDate?.setDate(n),this._update()}_setTimePick(t=!0){const e=this.pickDate?.getHours()||0,n=this.pickDate?.getMinutes()||0,i=this.pickDate?.getSeconds()||0,{hour:r,minute:s,second:a}=this.dom.time;[r,s,a].forEach(R=>{R.querySelectorAll("li").forEach(u=>u.classList.remove("active"))}),[[r,e],[s,n],[a,i]].forEach(([R,u])=>{const h=R.querySelector(`[data-id='${u}']`);h.classList.add("active"),t&&Zi(R,h)})}_preMonth(){this.now.setMonth(this.now.getMonth()-1),this._update()}_nextMonth(){this.now.setMonth(this.now.getMonth()+1),this._update()}_preYear(){this.now.setFullYear(this.now.getFullYear()-1),this._update()}_nextYear(){this.now.setFullYear(this.now.getFullYear()+1),this._update()}_now(){this.pickDate=new Date,this.dispose()}_toggleVisible(t){t?this.dom.container.classList.add("active"):this.dom.container.classList.remove("active")}_submit(){if(this.options.onSubmit&&this.pickDate){const t=this.renderOptions?.dateFormat,e=this.formatDate(this.pickDate,t);this.options.onSubmit(e)}}formatDate(t,e="YYYY-MM-DD HH:mm:ss"){let n=e;const i=t.getFullYear().toString(),r=(t.getMonth()+1).toString(),s=t.getDate().toString(),a=t.getHours(),c=a%12===0?12:a%12,d=t.getMinutes().toString(),R=t.getSeconds().toString(),u=t.getMilliseconds().toString(),h={"y+":i,"Y+":i,"M+":r,"d+":s,"D+":s,"h+":c.toString(),"H+":a.toString(),"m+":d,"s+":R,"S+":u};for(const g in h){const f=new RegExp("("+g+")").exec(e),T=g;f&&(n=n.replace(f[1],f[1].length===1?h[T]:h[T].padStart(f[1].length,"0")))}return n}render(t){this.renderOptions=t,this.lang=this._getLang(),this._setLangChange(),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}destroy(){this.dom.container.remove()}}class bn{draw;element;control;isPopup;datePicker;options;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:r,endIndex:s}=n;for(let a=r;a<=s;a++){const c=e[a];c.controlComponent===l.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...R,...t[h],controlComponent:l.ControlComponent.VALUE};Ut(i,[g],s,{editorOptions:this.options}),c.spliceElementList(i,u+h,0,[g])}return u+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=this.control.getValueRange(t);if(!r)return-1;const{startIndex:s,endIndex:a}=r;if(!~s||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,s+1,a-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(s,t),s}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),s=this.getValue(e)[0],a=s?Dt(s,Re):Dt(i[r.startIndex],Gt),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=ie(i[c],Re),R=c+1,u=this.control.getDraw();for(let h=0;h<t.length;h++){const g={...a,...d,type:l.ElementType.TEXT,value:t[h],controlComponent:l.ControlComponent.VALUE};(g.color===this.options.control.bracketColor||g.color===this.options.control.placeholderColor)&&(g.color=this.options.defaultColor),Ut(i,[g],c,{editorOptions:this.options}),u.spliceElementList(i,R+h,0,[g])}if(!e.range){const h=R+t.length-1;this.control.repaintControl({curIndex:h}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.control.getDraw();if(t.key===l.KeyMap.Backspace)return i!==r?(c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===l.KeyMap.Delete){if(i!==r)return c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i;{const d=e[r+1];return(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT)&&d.controlComponent===l.ControlComponent.PLACEHOLDER||d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getPosition();if(!t)return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n+1]?.controlId!==this.element.controlId)return;this.datePicker=new dr(this.draw,{onSubmit:this._setDate.bind(this)});const i=this.getValue().map(s=>s.value).join("")||"",r=this.element.control?.dateFormat;this.datePicker.render({value:i,position:t,dateFormat:r}),this.isPopup=!0}destroy(){this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}_setDate(t){t?this.setSelect(t):this.clearSelect(),this.destroy()}}class Vn extends Ci{isPopup;inputPopup;constructor(t,e){super(t,e),this.isPopup=!1,this.inputPopup=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(P=>!kl(P)||Qr.test(P.value)))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const s=at(t),{startIndex:a,endIndex:c}=r,d=i[a];let R=null;for(let P=a;P>=0;P--)if(i[P].controlComponent===l.ControlComponent.PREFIX){R=i[P];break}const u=R?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let P=a;for(;P>0;){const S=i[P];if(S.controlId!==d.controlId||S.controlComponent===l.ControlComponent.PREFIX||S.controlComponent===l.ControlComponent.PRE_TEXT)break;s.unshift(S),P--}let O=c+1;for(;O<i.length;){const S=i[O];if(S.controlId!==d.controlId||S.controlComponent===l.ControlComponent.POSTFIX||S.controlComponent===l.ControlComponent.POST_TEXT)break;s.push(S),O++}}const h=$i(s);if(Number.isNaN(Number(h))||!Number.isFinite(Number(h)))return-1;const g=u?.numberExclusiveOptions,f=g?.maxLength??null,T=g?.decimalPlaces??null,p=h.replace(/[.-]/g,"").length;if(f!=null&&p>f||T!=null&&(h.split(".")[1]||"").length>T)return-1;const m=Number(h),I=g?.minValue,L=g?.maxValue;return I!=null&&m<I||L!=null&&m>L?-1:super.setValue(t,e,n)}_setNumberValue(t){const e=this.control.getElementList(),n=this.control.getRange(),{startIndex:i}=n;let r=null;for(let F=i;F>=0;F--)if(e[F].controlComponent===l.ControlComponent.PREFIX){r=e[F];break}const a=(r?.control||this.element.control)?.numberExclusiveOptions,c=a?.minValue,d=a?.maxValue,R=a?.decimalPlaces,u=a?.minLength,h=a?.maxLength;let g=t;R!=null&&(g=parseFloat(t.toFixed(R)));const f=g.toString(),T=f.replace(/[.-]/g,"").length;if(u!=null&&T<u||h!=null&&T>h||c!=null&&g<c||d!=null&&g>d)return!1;let p=i;for(let F=i;F>=0;F--)if(e[F].controlComponent===l.ControlComponent.PREFIX){p=F;break}let m=p+1;for(let F=p+1;F<e.length;F++)if(e[F].controlComponent===l.ControlComponent.POSTFIX){m=F;break}const I=this.options.mode===l.EditorMode.FORM,L=I&&this.options.modeRule.form.inputTraceEnabled,P=I&&this.options.modeRule.form.deleteTraceEnabled,O=q(new Date).format("YYYY-MM-DD HH:mm:ss");if(P)for(let F=p+1;F<m;F++){const N=e[F];N.controlComponent===l.ControlComponent.VALUE&&!N.strikeout&&N.value&&(N.strikeout=!0,N.deletePerson="SYSTEM",N.deleteTime=O),N.controlComponent===l.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,F,1),m--,F--)}else{const F=p+1,N=m-F;N>0&&this.control.getDraw().spliceElementList(e,F,N),m=p+1}m=p+1;for(let F=p+1;F<e.length;F++)if(e[F].controlComponent===l.ControlComponent.POSTFIX){m=F;break}const S=[];for(let F=0;F<f.length;F++){const N={type:l.ElementType.TEXT,value:f[F],controlComponent:l.ControlComponent.VALUE,controlId:e[p].controlId};L&&(N.textDecoration={style:l.TextDecorationStyle.DOUBLE},N.underline=!0),S.push(N)}for(let F=0;F<S.length;F++)this.control.getDraw().spliceElementList(e,m+F,0,[S[F]]);return this.control.repaintControl({curIndex:m+S.length-1}),this.control.emitControlContentChange(),!0}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e,i=t[n];if(!i||i.controlId!==this.element.controlId)return;let r=null;for(let f=n;f>=0;f--)if(t[f].controlComponent===l.ControlComponent.PREFIX){r=t[f];break}const s=r?.control||this.element.control,c=this.getValue().filter(f=>!f.strikeout),d=c.length>0?$i(c):"",R=s?.numberExclusiveOptions,u=R?.minValue,h=R?.maxValue,g=R?.decimalPlaces;this.inputPopup=new gh({control:this.control,currentValue:d,minValue:u,maxValue:h,decimalPlaces:g,onConfirm:f=>{if(!f||f.trim()==="")return this._clearNumberValue(),!0;const T=parseFloat(f);return Number.isNaN(T)||!Number.isFinite(T)?!1:this._setNumberValue(T)},onClose:()=>{this.destroy()}}),this.inputPopup.create(),this.isPopup=!0}_clearNumberValue(){const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e;let i=n;for(let c=n;c>=0;c--)if(t[c].controlComponent===l.ControlComponent.PREFIX){i=c;break}let r=i+1;for(let c=i+1;c<t.length;c++)if(t[c].controlComponent===l.ControlComponent.POSTFIX){r=c;break}const s=i+1,a=r-s;a>0&&this.control.getDraw().spliceElementList(t,s,a),this.control.addPlaceholder(i),this.control.repaintControl({curIndex:i}),this.control.emitControlContentChange()}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.control.getDraw();if(t.key==="Backspace")return s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT?i:i!==r?(c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key==="Delete"){const R=e[r+1];return s.controlComponent===l.ControlComponent.PLACEHOLDER||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT?this.control.removeControl(i):s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||R?.controlComponent===l.ControlComponent.POSTFIX||R?.controlComponent===l.ControlComponent.POST_TEXT?r:i!==r?(c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}return t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey?(t.preventDefault(),this.awake(),null):r}destroy(){this.inputPopup&&(this.inputPopup.destroy(),this.inputPopup=null),this.isPopup=!1}}class gh{options;popupDom;constructor(t){this.options=t,this.popupDom=null}create(){const{currentValue:t,minValue:e,maxValue:n,decimalPlaces:i,onConfirm:r,onClose:s}=this.options,a=document.createElement("div");a.classList.add(`${z}-number-input-modal`),a.setAttribute(de,l.EditorComponent.POPUP);const c=document.createElement("div");c.classList.add(`${z}-number-input-modal__content`);const d=document.createElement("div");if(d.classList.add(`${z}-number-input-modal__title`),d.textContent="请输入数值",c.appendChild(d),e!==void 0||n!==void 0){const p=document.createElement("div");p.classList.add(`${z}-number-input-modal__hint`);let m="有效范围:";e!==void 0&&n!==void 0?m+=`${e} ~ ${n}`:e!==void 0?m+=`≥ ${e}`:m+=`≤ ${n}`,i!=null&&(m+=`,保留${i}位小数`),p.textContent=m,c.appendChild(p)}const R=document.createElement("input");R.classList.add(`${z}-number-input-modal__input`),R.type="number",R.value=t,R.placeholder="请输入数值",e!==void 0&&(R.min=String(e)),n!==void 0&&(R.max=String(n)),i!=null&&(R.step=(1/Math.pow(10,i)).toString()),setTimeout(()=>{R.focus(),R.select()},100),c.appendChild(R);const u=document.createElement("div");u.classList.add(`${z}-number-input-modal__error`),u.style.display="none",c.appendChild(u);const h=document.createElement("div");h.classList.add(`${z}-number-input-modal__buttons`);const g=document.createElement("button");g.classList.add(`${z}-number-input-modal__cancel`),g.textContent="取消",g.onclick=()=>{s()},h.appendChild(g);const f=document.createElement("button");f.classList.add(`${z}-number-input-modal__confirm`),f.textContent="确定",f.onclick=()=>{const p=R.value.trim();if(!p){r("")&&s();return}const m=parseFloat(p);if(Number.isNaN(m)||!Number.isFinite(m)){u.textContent="请输入有效的数值",u.style.display="block";return}if(i!=null&&(p.split(".")[1]||"").length>i){u.textContent=`小数位数不能超过${i}位`,u.style.display="block";return}if(e!==void 0&&m<e){u.textContent=`数值不能小于 ${e}`,u.style.display="block";return}if(n!==void 0&&m>n){u.textContent=`数值不能大于 ${n}`,u.style.display="block";return}r(p)&&s()},h.appendChild(f),c.appendChild(h),a.appendChild(c),R.onkeydown=p=>{p.key==="Enter"?f.click():p.key==="Escape"&&s()},this.options.control.getContainer().appendChild(a),this.popupDom=a}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class fh{options;mask;container;inputList;optionItemContainers;data;constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this.optionItemContainers=[],this.data=t.data,this._render()}_getFieldValue(t){const e=this.inputList.filter(n=>n.name===t);if(e.length!==0){for(const n of e)if(n instanceof HTMLInputElement&&n.type==="radio"&&n.checked)return n.value;return e[0].value}}_updateFieldVisibility(){this.data.forEach((t,e)=>{if(t.visibleWhen){const{field:n,value:i}=t.visibleWhen,r=this._getFieldValue(n),s=this.optionItemContainers[e];if(s){const a=r===i;s.style.display=a?"":"none"}}})}_render(){const{title:t,onClose:e,onCancel:n,onConfirm:i}=this.options,r=document.createElement("div");r.classList.add("dialog-mask"),r.setAttribute(de,l.EditorComponent.COMPONENT),document.body.append(r);const s=document.createElement("div");s.classList.add("dialog-container"),s.setAttribute(de,l.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),s.append(a);const c=document.createElement("div");c.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const R=document.createElement("i");R.onclick=()=>{e&&e(),this._dispose()},c.append(d),c.append(R),a.append(c);const u=document.createElement("div");u.classList.add("dialog-option");for(let T=0;T<this.data.length;T++){const p=this.data[T],m=document.createElement("div");if(m.classList.add("dialog-option__item"),p.visible===!1&&(m.style.display="none"),p.label){const I=document.createElement("span");I.append(document.createTextNode(p.label)),m.append(I),p.required&&I.classList.add("dialog-option__item--require")}if(p.type==="radio"){const I=document.createElement("div");I.classList.add("dialog-radio-group"),p.horizontal&&I.classList.add("dialog-radio-group--horizontal"),p.options?.forEach(L=>{const P=document.createElement("label");P.classList.add("dialog-radio-item");const O=document.createElement("input");O.type="radio",O.name=p.name,O.value=L.value,L.value===(p.value||"")&&(O.checked=!0);const S=document.createElement("span");S.textContent=L.label,P.append(O),P.append(S),I.append(P),O.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(O)}),m.append(I)}else if(p.type==="select"){const I=document.createElement("select"),L=p.value||"";p.options?.forEach(P=>{const O=document.createElement("option");O.value=P.value,O.label=P.label,P.value===L&&(O.selected=!0),I.append(O)}),I.name=p.name,I.value=L,I.addEventListener("change",()=>{this._updateFieldVisibility()}),p.width&&(I.style.width=`${p.width}px`),m.append(I),this.inputList.push(I)}else if(p.type==="textarea"){const I=document.createElement("textarea");I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),m.append(I),this.inputList.push(I)}else{const I=document.createElement("input");I.type=p.type,I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),m.append(I),this.inputList.push(I)}u.append(m),this.optionItemContainers.push(m)}a.append(u);const h=document.createElement("div");h.classList.add("dialog-menu");const g=document.createElement("button");g.classList.add("dialog-menu__cancel"),g.append(document.createTextNode("取消")),g.type="button",g.onclick=()=>{n&&n(),this._dispose()},h.append(g);const f=document.createElement("button");f.append(document.createTextNode("确定")),f.type="submit",f.onclick=()=>{if(i){const T=new Set,p=[];for(const m of this.inputList)if(!T.has(m.name))if(m instanceof HTMLInputElement&&m.type==="radio"){const I=this.inputList.find(L=>L.name===m.name&&L instanceof HTMLInputElement&&L.checked);I&&(p.push({name:m.name,value:I.value}),T.add(m.name))}else p.push({name:m.name,value:m.value}),T.add(m.name);i(p)}this._dispose()},h.append(f),a.append(h),document.body.append(s),this.container=s,this.mask=r,this._updateFieldVisibility()}_dispose(){this.mask?.remove(),this.container?.remove()}}class ke{draw;element;control;isPopup;datePicker;options;range;static isDeleting=!1;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.range=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(){return[]}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e),s=this.control.getDraw(),{startIndex:a}=r,d=i[a].controlId;let R=a;for(let m=a;m>=0;m--){const I=i[m];if(I.controlId!==d)break;if(I.controlComponent===l.ControlComponent.PREFIX){R=m;break}}let u=a;for(let m=a;m<i.length;m++){const I=i[m];if(I.controlId!==d){u=m;break}if(I.controlComponent===l.ControlComponent.POSTFIX){u=m;break}}const h=R+1,g=u-1;g>=h&&s.spliceElementList(i,h,g-h+1);const f=i[R],T=Dt(f,["control","controlId",...Gt]),p=R+1;for(let m=0;m<t.length;m++){const I={...T,...t[m],controlComponent:l.ControlComponent.VALUE};I.color="#fff",I.highlight="#1677FF",Ut(i,[I],R,{editorOptions:this.options}),s.spliceElementList(i,p+m,0,[I])}return p+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=this.control.getValueRange(t);if(!r)return-1;const{startIndex:s,endIndex:a}=r;if(!~s||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,s+1,a-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(s,t),s}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{endIndex:i}=n,r=e[i];return!!r?.originControlId&&!!r?.controlId&&r.originControlId!==r.controlId&&r.control?.type===l.ControlType.BUTTON&&!r.control?.buttonText&&(t.key===l.KeyMap.Backspace||t.key===l.KeyMap.Delete)?this.control.removeControl(i):r?.controlComponent==="value"&&r.control?.type==="button"&&r.control?.buttonText?t.key===l.KeyMap.Backspace||t.key===l.KeyMap.Delete?(r.controlId&&this.removeByValue(e,r.controlId),i):null:(t.key===l.KeyMap.Backspace&&r?.controlComponent==="value"&&r.control?.type==="button"&&!r.control?.buttonText,null)}removeByValue(t,e){return ke.isDeleting=!0,new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text")&&t[c].controlId===e&&t.splice(c,1);const{startIndex:i,endIndex:r}=this.range.getRange(),s=!0,a=r;this.draw.render({curIndex:a,isSetCursor:s}),setTimeout(()=>{ke.isDeleting=!1},300),n(!0)})}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl()||ke.isDeleting||!this.control.getPosition())return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n]?.controlId!==this.element?.controlId)return;const i=this.control.getDraw().getPosition().getPositionContext();if(!i.isDirectHit||i.index!==n||e[i.index]?.controlId!==this.element?.controlId)return;const r=e[n]?.controlId,s=e[n]?.control;if(!(r?.endsWith("_text")||s?.buttonText)){if(this.options.mode=="form"){const a=e[n].controlId;if(!a)return;const c=e.filter(d=>d.controlId==a);c[0].control.buttonText||this.showInputModal(c)}else if(this.options.mode=="edit"){const a=e[n].controlId,c=e.filter(d=>d.controlId==a);this.showEditModal(c)}}}showInputModal(t){if(this.inputModal){this.closeInputModal();return}this.isPopup=!0,this.inputModal=document.createElement("div"),this.inputModal.classList.add(`${z}-button-input-modal`),this.inputModal.setAttribute(de,l.EditorComponent.POPUP),this.inputModal.oncontextmenu=c=>{c.preventDefault(),c.stopPropagation()};const e=document.createElement("div");e.classList.add(`${z}-button-input-modal__content`),e.oncontextmenu=c=>{c.preventDefault(),c.stopPropagation()};const n=document.createElement("div");n.classList.add(`${z}-button-input-modal__title`),n.innerText="请输入按钮展开文字(用逗号分隔)";const i=document.createElement("textarea");i.classList.add(`${z}-button-input-modal__textarea`),i.placeholder="例如:选项1,选项2,选项3",i.rows=5;const r=document.createElement("div");r.classList.add(`${z}-button-input-modal__buttons`);const s=document.createElement("button");s.classList.add(`${z}-button-input-modal__cancel`),s.innerText="取消",s.onclick=()=>this.closeInputModal();const a=document.createElement("button");a.classList.add(`${z}-button-input-modal__confirm`),a.innerText="确认",a.onclick=()=>{const c=i.value.trim();if(c){const d=c.split(/[,,]/).map((R,u)=>({value:R.trim(),code:String(u+1)})).filter(R=>R.value);if(d.length>0&&t[0]?.controlId){const R={controlId:t[0].controlId,element:[{...t[0],newButtonValue:d}]};this.draw.getCommand().executeButton(R)}}this.closeInputModal()},r.appendChild(s),r.appendChild(a),e.appendChild(n),e.appendChild(i),e.appendChild(r),this.inputModal.appendChild(e),this.draw.getContainer().appendChild(this.inputModal),setTimeout(()=>i.focus(),100),this.inputModal.onclick=c=>{c.target===this.inputModal&&this.closeInputModal()}}closeInputModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}showEditModal(t){const e=t[0]?.control||{},n=e.buttonLabel||e.label||"按钮",i=e.code||"";this.isPopup=!0,new fh({title:"修改按钮属性",data:[{type:"text",label:"按钮标签",name:"buttonLabel",required:!0,placeholder:"请输入按钮标签",value:n},{type:"text",label:"按钮代码",name:"code",placeholder:"请输入按钮代码",value:i}],onClose:()=>{this.isPopup=!1},onCancel:()=>{this.isPopup=!1},onConfirm:r=>{const s=r.find(h=>h.name==="buttonLabel")?.value?.trim()||"按钮",a=r.find(h=>h.name==="code")?.value?.trim()||"",c=this.control.getElementList(),d=t[0]?.controlId;if(d)for(let h=0;h<c.length;h++){const g=c[h];g.controlId===d&&g.control&&(g.control.buttonLabel=s,g.control.label=s,g.control.code=a)}const R=[];for(let h=0;h<s.length;h++)R.push({value:s[h],controlComponent:l.ControlComponent.VALUE});const u=this.setValue(R);u!==-1&&this.control.repaintControl({curIndex:u}),this.isPopup=!1}})}destroy(){this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}}class Rr{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),r=t?null:i.getTd();n>=e.length&&(n=e.length-1);const s=e[n],a=[];let c=r;if(s.controlComponent===l.ControlComponent.PRETEXTFIX||s.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let f=n+1;for(;f<e.length;){const T=e[f];if(T.controlId!==s.controlId||T.controlComponent!==l.ControlComponent.PRETEXTFIX&&T.controlComponent!==l.ControlComponent.PRETEXTFIX_TEXT){n=f-1;break}f++}}let d=e,R=n;for(;;){if(R<0&&c?.linkTdPrevId){const T=i.getTdById(c.linkTdPrevId);if(T){d=T.value,R=d.length-1,c=T;continue}}if(R<0)break;const f=d[R];if(f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.PRETEXTFIX||f.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||f.controlComponent===l.ControlComponent.TEXTFIXLABEL)break;f.controlComponent===l.ControlComponent.VALUE&&a.unshift(f),R--}c=r;let u=e,h=n+1;for(;;){if(h>=u.length&&c?.linkTdNextId){const T=i.getTdById(c.linkTdNextId);if(T){u=T.value,h=0,c=T;continue}}const f=u[h];if(!f||f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.POSTTEXTFIX||f.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||f.controlComponent===l.ControlComponent.TEXTFIXLABEL)break;f.controlComponent===l.ControlComponent.VALUE&&a.push(f),h++}return a.filter(f=>f.type!==l.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(this.options.mode===l.EditorMode.FORM||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=i[s+1];let u=d.originControlId||d.controlId,h=d.originControlId&&(d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT);if(!h&&d.controlId&&(d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT)&&R?.controlId&&R.controlId!==d.controlId)if(R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX)for(let m=s;m>=0;m--){const I=i[m];if(I.controlId===d.controlId&&(I.controlComponent===l.ControlComponent.PREFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let L=m-1;L>=0;L--){const P=i[L];if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.PRETEXTFIX||P.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===l.ControlComponent.PREFIX||P.controlComponent===l.ControlComponent.PRE_TEXT)){u=P.controlId,h=!0;break}if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.POSTFIX||P.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}else(R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POSTTEXTFIX)&&(u=R.controlId,h=!0);if(!h&&d.controlId&&(d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT))for(let m=s;m>=0;m--){const I=i[m];if(I.controlId===d.controlId&&(I.controlComponent===l.ControlComponent.PREFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let L=m-1;L>=0;L--){const P=i[L];if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.PRETEXTFIX||P.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===l.ControlComponent.PREFIX||P.controlComponent===l.ControlComponent.PRE_TEXT)){u=P.controlId,h=!0;break}if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.POSTFIX||P.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}const g=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]);h&&(g.controlId=u,delete g.originControlId);const f=r.startIndex+1,T=[],p=m=>{const I=T.length?T:i,L=T.length?T.length-1:r.startIndex;Ut(I,[m],L,{editorOptions:this.options}),T.push(m)};for(let m=0;m<t.length;m++){const I=t[m];if(I.type===l.ElementType.CONTROL&&I.control){const L=I,P=L.controlId||lt(),O=L.control?.value||[],S=L.control?.type===l.ControlType.TEXTFIELD,F={...g,controlId:P,type:l.ElementType.CONTROL,control:L.control,originControlId:u},N=S?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,V=S?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,Y=S?L.control?.preTextFix||this.options.control.preTextFix:L.control?.prefix||this.options.control.prefix;for(let b=0;b<Y.length;b++){const E={...F,value:Y[b],controlComponent:N};p(E)}for(let b=0;b<O.length;b++){const E=O[b],C={...F,...E,controlComponent:l.ControlComponent.VALUE,type:E.type};(C.color===this.options.control.textFixColor||C.color===this.options.control.placeholderColor)&&(C.color=this.options.defaultColor),p(C)}if(O.length===0){const b=L.control?.placeholder||"";for(let E=0;E<b.length;E++){const C={...F,value:b[E],controlComponent:l.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};p(C)}}const X=S?L.control?.postTextFix||this.options.control.postTextFix:L.control?.postfix||this.options.control.postfix;for(let b=0;b<X.length;b++){const E={...F,value:X[b],controlComponent:V};p(E)}}else if(I.type||I.value){g.color=this.options.defaultColor;const L={...g,...I,controlComponent:l.ControlComponent.VALUE};(L.color===this.options.control.textFixColor||L.color===this.options.control.placeholderColor)&&(L.color=this.options.defaultColor),p(L)}}return T.length&&c.spliceElementList(i,f,0,T),r.startIndex+T.length}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:r,endIndex:s}=i;return this.control.getDraw().spliceElementList(n,r+1,s-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(r,t)),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange(),i=n.startIndex,r=n.endIndex;if(t.key===l.KeyMap.Backspace&&i===r&&i>0){const p=e[i-1],m=p?.controlComponent===l.ControlComponent.POSTFIX||p?.controlComponent===l.ControlComponent.POSTTEXTFIX,I=p?.controlComponent===l.ControlComponent.PLACEHOLDER,L=!!p?.controlId,O=this.draws.getPosition().getPositionList(),S=O[i],F=O[i-1],N=S&&F&&S.rowIndex===F.rowIndex;if((m||I)&&L&&N)return this.control.removeControl(i-1)}this.control.shrinkBoundary();const{startIndex:s,endIndex:a}=n,c=e[s],d=this.control.getDraw(),R=e[a+1],u=!!c?.originControlId&&!!c?.controlId&&c.originControlId!==c.controlId,h=u&&(c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRE_TEXT||c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.POSTFIX||c.controlComponent===l.ControlComponent.POST_TEXT||c.controlComponent===l.ControlComponent.POSTTEXTFIX||c.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PLACEHOLDER||c.controlComponent===l.ControlComponent.TEXTFIXLABEL),g=u&&c.control?.type===l.ControlType.BUTTON&&c.controlComponent===l.ControlComponent.VALUE,f=!!R?.originControlId&&!!R?.controlId&&R.originControlId!==R.controlId&&(R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT||R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||R.controlComponent===l.ControlComponent.PLACEHOLDER||R.controlComponent===l.ControlComponent.TEXTFIXLABEL),T=!!R?.originControlId&&!!R?.controlId&&R.originControlId!==R.controlId&&R.control?.type===l.ControlType.BUTTON;if(t.key===l.KeyMap.Backspace){if(s===a&&(h||g))return this.control.removeControl(s);if(this.options.mode===l.EditorMode.FORM)this.strikeout();else return s!==a?e.slice(s,a+1).some(I=>I.controlComponent===l.ControlComponent.POSTTEXTFIX||I.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)?s:(d.spliceElementList(e,s+1,a-s),this.getValue().length||this.control.addPlaceholder(s),s===0&&e[0].type===l.ElementType.SPLIT_TAG?d.fixPosition(!0)??s:s):c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.POSTTEXTFIX||c.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===l.ControlComponent.TEXTFIXLABEL||c.controlComponent===l.ControlComponent.PLACEHOLDER?s:(d.spliceElementList(e,s,1),this.getValue().length||this.control.addPlaceholder(s-1),s===1&&e[0].type===l.ElementType.SPLIT_TAG||s===0?d.fixPosition(!0)??s-1:s-1)}else if(t.key===l.KeyMap.Delete){if(s===a&&(h||g))return this.control.removeControl(s);if(s===a&&(f||T))return this.control.removeControl(a+1);if(this.options.mode===l.EditorMode.FORM)this.strikeout();else return s!==a?(d.spliceElementList(e,s+1,a-s),this.getValue().length||this.control.addPlaceholder(s),s===0&&e[0].type===l.ElementType.SPLIT_TAG?d.fixPosition(!0)??s:s):(R||d.getTd()?.linkTdNextId&&c.controlId&&this.removeNextControlElement(c.controlId),R&&((c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)&&(R.controlComponent===l.ControlComponent.PLACEHOLDER||R.controlComponent===l.ControlComponent.TEXTFIXLABEL)||R.controlComponent===l.ControlComponent.POSTTEXTFIX||R.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PLACEHOLDER||c.controlComponent===l.ControlComponent.TEXTFIXLABEL)?s:(d.spliceElementList(e,s+1,1),this.getValue().length||this.control.addPlaceholder(s),s===0&&e[0].type===l.ElementType.SPLIT_TAG?d.fixPosition(!0)??s:s))}return a}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}strikeout(t,e={},n={}){const{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return;const s=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=q(new Date).format("YYYY-MM-DD HH:mm:ss");if(s?.length){if(!this.element.strikeout){const d=s.findIndex(R=>!R.strikeout);s.forEach(R=>{R.deletePerson="SWJ",R.deleteTime=c,R.strikeout=!!~d}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),setTimeout(()=>{this.strikeoute()},100)}}else{const d=this.control.getElementList()[a.index];if(!this.control.getElementList()[a.index].strikeout&&d?.metrics.width>0){this.control.getElementList()[a.index].strikeout=!0,this.control.getElementList()[a.index].deletePerson="SWJ",this.control.getElementList()[a.index].deleteTime=c;const R=--a.index;setTimeout(()=>{this.strikeoute()},100),setTimeout(()=>{const h=R;this.draws.render({curIndex:h,isSetCursor:!0}),a.index=R,this.position.setCursorPosition(a),this.ranges.setRange(R,R)},100)}else{const{elementList:R,range:u}=this.control.mergeControl(n),h=u.startIndex;if(h>=0&&h<R.length&&R[h]?.metrics?.width!==void 0&&R[h].metrics.width<=0&&!R[h]?.strikeout){this.draws.spliceElementList(R,u.startIndex,1,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule});const g=!0,f=u.startIndex-1;this.draws.render({curIndex:f,isSetCursor:g}),a.index=f,delete a.value,this.position.setCursorPosition(a),this.ranges.setRange(f,f)}}}}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:r}=this.ranges.getRange(),a=this.draws.getElementList()[r];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}const Th={indent:" ",divider:"────────────────"};class ur{draw;element;control;options;isPopup;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:r,endIndex:s}=n;for(let a=r;a<=s;a++){const c=e[a];c.controlComponent===l.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e),s=this.control.getDraw(),{startIndex:a}=r,d=i[a].controlId;let R=a;for(let m=a;m>=0;m--){const I=i[m];if(I.controlId!==d)break;if(I.controlComponent===l.ControlComponent.PREFIX){R=m;break}}let u=a;for(let m=a;m<i.length;m++){const I=i[m];if(I.controlId!==d){u=m;break}if(I.controlComponent===l.ControlComponent.POSTFIX){u=m;break}}const h=R+1,g=u-1;g>=h&&s.spliceElementList(i,h,g-h+1);const f=i[R],T=Dt(f,["control","controlId",...Gt]),p=R+1;for(let m=0;m<t.length;m++){const I={...T,...t[m],value:t[m].value===`
|
|
104
|
+
`+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var ms={};function ps(o,t){q.deprecationHandler!=null&&q.deprecationHandler(o,t),ms[o]||(Ts(t),ms[o]=!0)}q.suppressDeprecationWarnings=!1,q.deprecationHandler=null;function pe(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function Tc(o){var t,e;for(e in o)Ot(o,e)&&(t=o[e],pe(t)?this[e]=t:this["_"+e]=t);this._config=o,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function $o(o,t){var e=Ue({},o),n;for(n in t)Ot(t,n)&&(_e(o[n])&&_e(t[n])?(e[n]={},Ue(e[n],o[n]),Ue(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Ot(o,n)&&!Ot(t,n)&&_e(o[n])&&(e[n]=Ue({},e[n]));return e}function zo(o){o!=null&&this.set(o)}var jo;Object.keys?jo=Object.keys:jo=function(o){var t,e=[];for(t in o)Ot(o,t)&&e.push(t);return e};var mc={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function pc(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return pe(n)?n.call(t,e):n}function Le(o,t,e){var n=""+Math.abs(o),i=t-n.length,r=o>=0;return(r?e?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+n}var qo=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,An=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ti={},rn={};function rt(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(rn[o]=i),t&&(rn[t[0]]=function(){return Le(i.apply(this,arguments),t[1],t[2])}),e&&(rn[e]=function(){return this.localeData().ordinal(i.apply(this,arguments),o)})}function Lc(o){return o.match(/\[[\s\S]/)?o.replace(/^\[|\]$/g,""):o.replace(/\\/g,"")}function Ic(o){var t=o.match(qo),e,n;for(e=0,n=t.length;e<n;e++)rn[t[e]]?t[e]=rn[t[e]]:t[e]=Lc(t[e]);return function(i){var r="",s;for(s=0;s<n;s++)r+=pe(t[s])?t[s].call(i,o):t[s];return r}}function kn(o,t){return o.isValid()?(t=Ls(t,o.localeData()),ti[t]=ti[t]||Ic(t),ti[t](o)):o.localeData().invalidDate()}function Ls(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(An.lastIndex=0;e>=0&&An.test(o);)o=o.replace(An,n),An.lastIndex=0,e-=1;return o}var Pc={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function Mc(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(qo).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var Oc="Invalid date";function Cc(){return this._invalidDate}var Sc="%d",Ec=/\d{1,2}/;function Xc(o){return this._ordinal.replace("%d",o)}var Nc={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function Fc(o,t,e,n){var i=this._relativeTime[e];return pe(i)?i(o,t,e,n):i.replace(/%d/i,o)}function yc(o,t){var e=this._relativeTime[o>0?"future":"past"];return pe(e)?e(t):e.replace(/%s/i,t)}var Is={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function ee(o){return typeof o=="string"?Is[o]||Is[o.toLowerCase()]:void 0}function ei(o){var t={},e,n;for(n in o)Ot(o,n)&&(e=ee(n),e&&(t[e]=o[n]));return t}var Wc={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function bc(o){var t=[],e;for(e in o)Ot(o,e)&&t.push({unit:e,priority:Wc[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var Ps=/\d/,zt=/\d\d/,Ms=/\d{3}/,ni=/\d{4}/,Jn=/[+-]?\d{6}/,Nt=/\d\d?/,Os=/\d\d\d\d?/,Cs=/\d\d\d\d\d\d?/,Bn=/\d{1,3}/,oi=/\d{1,4}/,$n=/[+-]?\d{1,6}/,ln=/\d+/,zn=/[+-]?\d+/,Vc=/Z|[+-]\d\d:?\d\d/gi,jn=/Z|[+-]\d\d(?::?\d\d)?/gi,Yc=/[+-]?\d+(\.\d{1,3})?/,On=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,an=/^[1-9]\d?/,ii=/^([1-9]\d|\d)/,qn;qn={};function ot(o,t,e){qn[o]=pe(t)?t:function(n,i){return n&&e?e:t}}function Dc(o,t){return Ot(qn,o)?qn[o](t._strict,t._locale):new RegExp(Uc(o))}function Uc(o){return Oe(o.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,r){return e||n||i||r}))}function Oe(o){return o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function ne(o){return o<0?Math.ceil(o)||0:Math.floor(o)}function ft(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=ne(t)),e}var si={};function Et(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),Me(t)&&(n=function(r,s){s[t]=ft(r)}),i=o.length,e=0;e<i;e++)si[o[e]]=n}function Cn(o,t){Et(o,function(e,n,i,r){i._w=i._w||{},t(e,i._w,i,r)})}function wc(o,t,e){t!=null&&Ot(si,o)&&si[o](t,e._a,e,o)}function to(o){return o%4===0&&o%100!==0||o%400===0}var xt=0,Ce=1,Ie=2,vt=3,le=4,Se=5,xe=6,Zc=7,Qc=8;rt("Y",0,0,function(){var o=this.year();return o<=9999?Le(o,4):"+"+o}),rt(0,["YY",2],0,function(){return this.year()%100}),rt(0,["YYYY",4],0,"year"),rt(0,["YYYYY",5],0,"year"),rt(0,["YYYYYY",6,!0],0,"year"),ot("Y",zn),ot("YY",Nt,zt),ot("YYYY",oi,ni),ot("YYYYY",$n,Jn),ot("YYYYYY",$n,Jn),Et(["YYYYY","YYYYYY"],xt),Et("YYYY",function(o,t){t[xt]=o.length===2?q.parseTwoDigitYear(o):ft(o)}),Et("YY",function(o,t){t[xt]=q.parseTwoDigitYear(o)}),Et("Y",function(o,t){t[xt]=parseInt(o,10)});function Sn(o){return to(o)?366:365}q.parseTwoDigitYear=function(o){return ft(o)+(ft(o)>68?1900:2e3)};var Ss=cn("FullYear",!0);function vc(){return to(this.year())}function cn(o,t){return function(e){return e!=null?(Es(this,o,e),q.updateOffset(this,t),this):En(this,o)}}function En(o,t){if(!o.isValid())return NaN;var e=o._d,n=o._isUTC;switch(t){case"Milliseconds":return n?e.getUTCMilliseconds():e.getMilliseconds();case"Seconds":return n?e.getUTCSeconds():e.getSeconds();case"Minutes":return n?e.getUTCMinutes():e.getMinutes();case"Hours":return n?e.getUTCHours():e.getHours();case"Date":return n?e.getUTCDate():e.getDate();case"Day":return n?e.getUTCDay():e.getDay();case"Month":return n?e.getUTCMonth():e.getMonth();case"FullYear":return n?e.getUTCFullYear():e.getFullYear();default:return NaN}}function Es(o,t,e){var n,i,r,s,a;if(!(!o.isValid()||isNaN(e))){switch(n=o._d,i=o._isUTC,t){case"Milliseconds":return void(i?n.setUTCMilliseconds(e):n.setMilliseconds(e));case"Seconds":return void(i?n.setUTCSeconds(e):n.setSeconds(e));case"Minutes":return void(i?n.setUTCMinutes(e):n.setMinutes(e));case"Hours":return void(i?n.setUTCHours(e):n.setHours(e));case"Date":return void(i?n.setUTCDate(e):n.setDate(e));case"FullYear":break;default:return}r=e,s=o.month(),a=o.date(),a=a===29&&s===1&&!to(r)?28:a,i?n.setUTCFullYear(r,s,a):n.setFullYear(r,s,a)}}function Kc(o){return o=ee(o),pe(this[o])?this[o]():this}function Hc(o,t){if(typeof o=="object"){o=ei(o);var e=bc(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=ee(o),pe(this[o]))return this[o](t);return this}function _c(o,t){return(o%t+t)%t}var wt;Array.prototype.indexOf?wt=Array.prototype.indexOf:wt=function(o){var t;for(t=0;t<this.length;++t)if(this[t]===o)return t;return-1};function ri(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=_c(t,12);return o+=(t-e)/12,e===1?to(o)?29:28:31-e%7%2}rt("M",["MM",2],"Mo",function(){return this.month()+1}),rt("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),rt("MMMM",0,0,function(o){return this.localeData().months(this,o)}),ot("M",Nt,an),ot("MM",Nt,zt),ot("MMM",function(o,t){return t.monthsShortRegex(o)}),ot("MMMM",function(o,t){return t.monthsRegex(o)}),Et(["M","MM"],function(o,t){t[Ce]=ft(o)-1}),Et(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[Ce]=i:Rt(e).invalidMonth=o});var xc="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Xs="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Ns=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Gc=On,Ac=On;function kc(o,t){return o?se(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Ns).test(t)?"format":"standalone"][o.month()]:se(this._months)?this._months:this._months.standalone}function Jc(o,t){return o?se(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Ns.test(t)?"format":"standalone"][o.month()]:se(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Bc(o,t,e){var n,i,r,s=o.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],n=0;n<12;++n)r=me([2e3,n]),this._shortMonthsParse[n]=this.monthsShort(r,"").toLocaleLowerCase(),this._longMonthsParse[n]=this.months(r,"").toLocaleLowerCase();return e?t==="MMM"?(i=wt.call(this._shortMonthsParse,s),i!==-1?i:null):(i=wt.call(this._longMonthsParse,s),i!==-1?i:null):t==="MMM"?(i=wt.call(this._shortMonthsParse,s),i!==-1?i:(i=wt.call(this._longMonthsParse,s),i!==-1?i:null)):(i=wt.call(this._longMonthsParse,s),i!==-1?i:(i=wt.call(this._shortMonthsParse,s),i!==-1?i:null))}function $c(o,t,e){var n,i,r;if(this._monthsParseExact)return Bc.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=me([2e3,n]),e&&!this._longMonthsParse[n]&&(this._longMonthsParse[n]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[n]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),!e&&!this._monthsParse[n]&&(r="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[n]=new RegExp(r.replace(".",""),"i")),e&&t==="MMMM"&&this._longMonthsParse[n].test(o))return n;if(e&&t==="MMM"&&this._shortMonthsParse[n].test(o))return n;if(!e&&this._monthsParse[n].test(o))return n}}function Fs(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=ft(t);else if(t=o.localeData().monthsParse(t),!Me(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,ri(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function ys(o){return o!=null?(Fs(this,o),q.updateOffset(this,!0),this):En(this,"Month")}function zc(){return ri(this.year(),this.month())}function jc(o){return this._monthsParseExact?(Ot(this,"_monthsRegex")||Ws.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Ot(this,"_monthsShortRegex")||(this._monthsShortRegex=Gc),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function qc(o){return this._monthsParseExact?(Ot(this,"_monthsRegex")||Ws.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Ot(this,"_monthsRegex")||(this._monthsRegex=Ac),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function Ws(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,r,s,a;for(i=0;i<12;i++)r=me([2e3,i]),s=Oe(this.monthsShort(r,"")),a=Oe(this.months(r,"")),t.push(s),e.push(a),n.push(a),n.push(s);t.sort(o),e.sort(o),n.sort(o),this._monthsRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+t.join("|")+")","i")}function td(o,t,e,n,i,r,s){var a;return o<100&&o>=0?(a=new Date(o+400,t,e,n,i,r,s),isFinite(a.getFullYear())&&a.setFullYear(o)):a=new Date(o,t,e,n,i,r,s),a}function Xn(o){var t,e;return o<100&&o>=0?(e=Array.prototype.slice.call(arguments),e[0]=o+400,t=new Date(Date.UTC.apply(null,e)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(o)):t=new Date(Date.UTC.apply(null,arguments)),t}function eo(o,t,e){var n=7+t-e,i=(7+Xn(o,0,n).getUTCDay()-t)%7;return-i+n-1}function bs(o,t,e,n,i){var r=(7+e-n)%7,s=eo(o,n,i),a=1+7*(t-1)+r+s,c,d;return a<=0?(c=o-1,d=Sn(c)+a):a>Sn(o)?(c=o+1,d=a-Sn(o)):(c=o,d=a),{year:c,dayOfYear:d}}function Nn(o,t,e){var n=eo(o.year(),t,e),i=Math.floor((o.dayOfYear()-n-1)/7)+1,r,s;return i<1?(s=o.year()-1,r=i+Ee(s,t,e)):i>Ee(o.year(),t,e)?(r=i-Ee(o.year(),t,e),s=o.year()+1):(s=o.year(),r=i),{week:r,year:s}}function Ee(o,t,e){var n=eo(o,t,e),i=eo(o+1,t,e);return(Sn(o)-n+i)/7}rt("w",["ww",2],"wo","week"),rt("W",["WW",2],"Wo","isoWeek"),ot("w",Nt,an),ot("ww",Nt,zt),ot("W",Nt,an),ot("WW",Nt,zt),Cn(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=ft(o)});function ed(o){return Nn(o,this._week.dow,this._week.doy).week}var nd={dow:0,doy:6};function od(){return this._week.dow}function id(){return this._week.doy}function sd(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function rd(o){var t=Nn(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}rt("d",0,"do","day"),rt("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),rt("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),rt("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),rt("e",0,0,"weekday"),rt("E",0,0,"isoWeekday"),ot("d",Nt),ot("e",Nt),ot("E",Nt),ot("dd",function(o,t){return t.weekdaysMinRegex(o)}),ot("ddd",function(o,t){return t.weekdaysShortRegex(o)}),ot("dddd",function(o,t){return t.weekdaysRegex(o)}),Cn(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Rt(e).invalidWeekday=o}),Cn(["d","e","E"],function(o,t,e,n){t[n]=ft(o)});function ld(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function ad(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function li(o,t){return o.slice(t,7).concat(o.slice(0,t))}var cd="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Vs="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),dd="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Rd=On,ud=On,hd=On;function gd(o,t){var e=se(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?li(e,this._week.dow):o?e[o.day()]:e}function fd(o){return o===!0?li(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function Td(o){return o===!0?li(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function md(o,t,e){var n,i,r,s=o.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)r=me([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(r,"").toLocaleLowerCase();return e?t==="dddd"?(i=wt.call(this._weekdaysParse,s),i!==-1?i:null):t==="ddd"?(i=wt.call(this._shortWeekdaysParse,s),i!==-1?i:null):(i=wt.call(this._minWeekdaysParse,s),i!==-1?i:null):t==="dddd"?(i=wt.call(this._weekdaysParse,s),i!==-1||(i=wt.call(this._shortWeekdaysParse,s),i!==-1)?i:(i=wt.call(this._minWeekdaysParse,s),i!==-1?i:null)):t==="ddd"?(i=wt.call(this._shortWeekdaysParse,s),i!==-1||(i=wt.call(this._weekdaysParse,s),i!==-1)?i:(i=wt.call(this._minWeekdaysParse,s),i!==-1?i:null)):(i=wt.call(this._minWeekdaysParse,s),i!==-1||(i=wt.call(this._weekdaysParse,s),i!==-1)?i:(i=wt.call(this._shortWeekdaysParse,s),i!==-1?i:null))}function pd(o,t,e){var n,i,r;if(this._weekdaysParseExact)return md.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=me([2e3,1]).day(n),e&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(r="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[n]=new RegExp(r.replace(".",""),"i")),e&&t==="dddd"&&this._fullWeekdaysParse[n].test(o))return n;if(e&&t==="ddd"&&this._shortWeekdaysParse[n].test(o))return n;if(e&&t==="dd"&&this._minWeekdaysParse[n].test(o))return n;if(!e&&this._weekdaysParse[n].test(o))return n}}function Ld(o){if(!this.isValid())return o!=null?this:NaN;var t=En(this,"Day");return o!=null?(o=ld(o,this.localeData()),this.add(o-t,"d")):t}function Id(o){if(!this.isValid())return o!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return o==null?t:this.add(o-t,"d")}function Pd(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=ad(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function Md(o){return this._weekdaysParseExact?(Ot(this,"_weekdaysRegex")||ai.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Ot(this,"_weekdaysRegex")||(this._weekdaysRegex=Rd),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function Od(o){return this._weekdaysParseExact?(Ot(this,"_weekdaysRegex")||ai.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Ot(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=ud),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Cd(o){return this._weekdaysParseExact?(Ot(this,"_weekdaysRegex")||ai.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Ot(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=hd),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function ai(){function o(R,u){return u.length-R.length}var t=[],e=[],n=[],i=[],r,s,a,c,d;for(r=0;r<7;r++)s=me([2e3,1]).day(r),a=Oe(this.weekdaysMin(s,"")),c=Oe(this.weekdaysShort(s,"")),d=Oe(this.weekdays(s,"")),t.push(a),e.push(c),n.push(d),i.push(a),i.push(c),i.push(d);t.sort(o),e.sort(o),n.sort(o),i.sort(o),this._weekdaysRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function ci(){return this.hours()%12||12}function Sd(){return this.hours()||24}rt("H",["HH",2],0,"hour"),rt("h",["hh",2],0,ci),rt("k",["kk",2],0,Sd),rt("hmm",0,0,function(){return""+ci.apply(this)+Le(this.minutes(),2)}),rt("hmmss",0,0,function(){return""+ci.apply(this)+Le(this.minutes(),2)+Le(this.seconds(),2)}),rt("Hmm",0,0,function(){return""+this.hours()+Le(this.minutes(),2)}),rt("Hmmss",0,0,function(){return""+this.hours()+Le(this.minutes(),2)+Le(this.seconds(),2)});function Ys(o,t){rt(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}Ys("a",!0),Ys("A",!1);function Ds(o,t){return t._meridiemParse}ot("a",Ds),ot("A",Ds),ot("H",Nt,ii),ot("h",Nt,an),ot("k",Nt,an),ot("HH",Nt,zt),ot("hh",Nt,zt),ot("kk",Nt,zt),ot("hmm",Os),ot("hmmss",Cs),ot("Hmm",Os),ot("Hmmss",Cs),Et(["H","HH"],vt),Et(["k","kk"],function(o,t,e){var n=ft(o);t[vt]=n===24?0:n}),Et(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),Et(["h","hh"],function(o,t,e){t[vt]=ft(o),Rt(e).bigHour=!0}),Et("hmm",function(o,t,e){var n=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n)),Rt(e).bigHour=!0}),Et("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n,2)),t[Se]=ft(o.substr(i)),Rt(e).bigHour=!0}),Et("Hmm",function(o,t,e){var n=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n))}),Et("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[vt]=ft(o.substr(0,n)),t[le]=ft(o.substr(n,2)),t[Se]=ft(o.substr(i))});function Ed(o){return(o+"").toLowerCase().charAt(0)==="p"}var Xd=/[ap]\.?m?\.?/i,Nd=cn("Hours",!0);function Fd(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Us={calendar:mc,longDateFormat:Pc,invalidDate:Oc,ordinal:Sc,dayOfMonthOrdinalParse:Ec,relativeTime:Nc,months:xc,monthsShort:Xs,week:nd,weekdays:cd,weekdaysMin:dd,weekdaysShort:Vs,meridiemParse:Xd},Wt={},Fn={},yn;function yd(o,t){var e,n=Math.min(o.length,t.length);for(e=0;e<n;e+=1)if(o[e]!==t[e])return e;return n}function ws(o){return o&&o.toLowerCase().replace("_","-")}function Wd(o){for(var t=0,e,n,i,r;t<o.length;){for(r=ws(o[t]).split("-"),e=r.length,n=ws(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=no(r.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&yd(r,n)>=e-1)break;e--}t++}return yn}function bd(o){return!!(o&&o.match("^[^/\\\\]*$"))}function no(o){var t=null,e;if(Wt[o]===void 0&&typeof module<"u"&&module&&module.exports&&bd(o))try{t=yn._abbr,e=require,e("./locale/"+o),we(t)}catch{Wt[o]=null}return Wt[o]}function we(o,t){var e;return o&&(kt(t)?e=Xe(o):e=di(o,t),e?yn=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),yn._abbr}function di(o,t){if(t!==null){var e,n=Us;if(t.abbr=o,Wt[o]!=null)ps("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=Wt[o]._config;else if(t.parentLocale!=null)if(Wt[t.parentLocale]!=null)n=Wt[t.parentLocale]._config;else if(e=no(t.parentLocale),e!=null)n=e._config;else return Fn[t.parentLocale]||(Fn[t.parentLocale]=[]),Fn[t.parentLocale].push({name:o,config:t}),null;return Wt[o]=new zo($o(n,t)),Fn[o]&&Fn[o].forEach(function(i){di(i.name,i.config)}),we(o),Wt[o]}else return delete Wt[o],null}function Vd(o,t){if(t!=null){var e,n,i=Us;Wt[o]!=null&&Wt[o].parentLocale!=null?Wt[o].set($o(Wt[o]._config,t)):(n=no(o),n!=null&&(i=n._config),t=$o(i,t),n==null&&(t.abbr=o),e=new zo(t),e.parentLocale=Wt[o],Wt[o]=e),we(o)}else Wt[o]!=null&&(Wt[o].parentLocale!=null?(Wt[o]=Wt[o].parentLocale,o===we()&&we(o)):Wt[o]!=null&&delete Wt[o]);return Wt[o]}function Xe(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return yn;if(!se(o)){if(t=no(o),t)return t;o=[o]}return Wd(o)}function Yd(){return jo(Wt)}function Ri(o){var t,e=o._a;return e&&Rt(o).overflow===-2&&(t=e[Ce]<0||e[Ce]>11?Ce:e[Ie]<1||e[Ie]>ri(e[xt],e[Ce])?Ie:e[vt]<0||e[vt]>24||e[vt]===24&&(e[le]!==0||e[Se]!==0||e[xe]!==0)?vt:e[le]<0||e[le]>59?le:e[Se]<0||e[Se]>59?Se:e[xe]<0||e[xe]>999?xe:-1,Rt(o)._overflowDayOfYear&&(t<xt||t>Ie)&&(t=Ie),Rt(o)._overflowWeeks&&t===-1&&(t=Zc),Rt(o)._overflowWeekday&&t===-1&&(t=Qc),Rt(o).overflow=t),o}var Dd=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ud=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,wd=/Z|[+-]\d\d(?::?\d\d)?/,oo=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],ui=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Zd=/^\/?Date\((-?\d+)/i,Qd=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,vd={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Zs(o){var t,e,n=o._i,i=Dd.exec(n)||Ud.exec(n),r,s,a,c,d=oo.length,R=ui.length;if(i){for(Rt(o).iso=!0,t=0,e=d;t<e;t++)if(oo[t][1].exec(i[1])){s=oo[t][0],r=oo[t][2]!==!1;break}if(s==null){o._isValid=!1;return}if(i[3]){for(t=0,e=R;t<e;t++)if(ui[t][1].exec(i[3])){a=(i[2]||" ")+ui[t][0];break}if(a==null){o._isValid=!1;return}}if(!r&&a!=null){o._isValid=!1;return}if(i[4])if(wd.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=s+(a||"")+(c||""),gi(o)}else o._isValid=!1}function Kd(o,t,e,n,i,r){var s=[Hd(o),Xs.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return r&&s.push(parseInt(r,10)),s}function Hd(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function _d(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function xd(o,t,e){if(o){var n=Vs.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Rt(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function Gd(o,t,e){if(o)return vd[o];if(t)return 0;var n=parseInt(e,10),i=n%100,r=(n-i)/100;return r*60+i}function Qs(o){var t=Qd.exec(_d(o._i)),e;if(t){if(e=Kd(t[4],t[3],t[2],t[5],t[6],t[7]),!xd(t[1],e,o))return;o._a=e,o._tzm=Gd(t[8],t[9],t[10]),o._d=Xn.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Rt(o).rfc2822=!0}else o._isValid=!1}function Ad(o){var t=Zd.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(Zs(o),o._isValid===!1)delete o._isValid;else return;if(Qs(o),o._isValid===!1)delete o._isValid;else return;o._strict?o._isValid=!1:q.createFromInputFallback(o)}q.createFromInputFallback=te("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(o){o._d=new Date(o._i+(o._useUTC?" UTC":""))});function dn(o,t,e){return o??t??e}function kd(o){var t=new Date(q.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function hi(o){var t,e,n=[],i,r,s;if(!o._d){for(i=kd(o),o._w&&o._a[Ie]==null&&o._a[Ce]==null&&Jd(o),o._dayOfYear!=null&&(s=dn(o._a[xt],i[xt]),(o._dayOfYear>Sn(s)||o._dayOfYear===0)&&(Rt(o)._overflowDayOfYear=!0),e=Xn(s,0,o._dayOfYear),o._a[Ce]=e.getUTCMonth(),o._a[Ie]=e.getUTCDate()),t=0;t<3&&o._a[t]==null;++t)o._a[t]=n[t]=i[t];for(;t<7;t++)o._a[t]=n[t]=o._a[t]==null?t===2?1:0:o._a[t];o._a[vt]===24&&o._a[le]===0&&o._a[Se]===0&&o._a[xe]===0&&(o._nextDay=!0,o._a[vt]=0),o._d=(o._useUTC?Xn:td).apply(null,n),r=o._useUTC?o._d.getUTCDay():o._d.getDay(),o._tzm!=null&&o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),o._nextDay&&(o._a[vt]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==r&&(Rt(o).weekdayMismatch=!0)}}function Jd(o){var t,e,n,i,r,s,a,c,d;t=o._w,t.GG!=null||t.W!=null||t.E!=null?(r=1,s=4,e=dn(t.GG,o._a[xt],Nn(Ft(),1,4).year),n=dn(t.W,1),i=dn(t.E,1),(i<1||i>7)&&(c=!0)):(r=o._locale._week.dow,s=o._locale._week.doy,d=Nn(Ft(),r,s),e=dn(t.gg,o._a[xt],d.year),n=dn(t.w,d.week),t.d!=null?(i=t.d,(i<0||i>6)&&(c=!0)):t.e!=null?(i=t.e+r,(t.e<0||t.e>6)&&(c=!0)):i=r),n<1||n>Ee(e,r,s)?Rt(o)._overflowWeeks=!0:c!=null?Rt(o)._overflowWeekday=!0:(a=bs(e,n,i,r,s),o._a[xt]=a.year,o._dayOfYear=a.dayOfYear)}q.ISO_8601=function(){},q.RFC_2822=function(){};function gi(o){if(o._f===q.ISO_8601){Zs(o);return}if(o._f===q.RFC_2822){Qs(o);return}o._a=[],Rt(o).empty=!0;var t=""+o._i,e,n,i,r,s,a=t.length,c=0,d,R;for(i=Ls(o._f,o._locale).match(qo)||[],R=i.length,e=0;e<R;e++)r=i[e],n=(t.match(Dc(r,o))||[])[0],n&&(s=t.substr(0,t.indexOf(n)),s.length>0&&Rt(o).unusedInput.push(s),t=t.slice(t.indexOf(n)+n.length),c+=n.length),rn[r]?(n?Rt(o).empty=!1:Rt(o).unusedTokens.push(r),wc(r,n,o)):o._strict&&!n&&Rt(o).unusedTokens.push(r);Rt(o).charsLeftOver=a-c,t.length>0&&Rt(o).unusedInput.push(t),o._a[vt]<=12&&Rt(o).bigHour===!0&&o._a[vt]>0&&(Rt(o).bigHour=void 0),Rt(o).parsedDateParts=o._a.slice(0),Rt(o).meridiem=o._meridiem,o._a[vt]=Bd(o._locale,o._a[vt],o._meridiem),d=Rt(o).era,d!==null&&(o._a[xt]=o._locale.erasConvertYear(d,o._a[xt])),hi(o),Ri(o)}function Bd(o,t,e){var n;return e==null?t:o.meridiemHour!=null?o.meridiemHour(t,e):(o.isPM!=null&&(n=o.isPM(e),n&&t<12&&(t+=12),!n&&t===12&&(t=0)),t)}function $d(o){var t,e,n,i,r,s,a=!1,c=o._f.length;if(c===0){Rt(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)r=0,s=!1,t=Bo({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],gi(t),ko(t)&&(s=!0),r+=Rt(t).charsLeftOver,r+=Rt(t).unusedTokens.length*10,Rt(t).score=r,a?r<n&&(n=r,e=t):(n==null||r<n||s)&&(n=r,e=t,s&&(a=!0));Ue(o,e||t)}function zd(o){if(!o._d){var t=ei(o._i),e=t.day===void 0?t.date:t.day;o._a=gs([t.year,t.month,e,t.hour,t.minute,t.second,t.millisecond],function(n){return n&&parseInt(n,10)}),hi(o)}}function jd(o){var t=new Mn(Ri(vs(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function vs(o){var t=o._i,e=o._f;return o._locale=o._locale||Xe(o._l),t===null||e===void 0&&t===""?Gn({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),re(t)?new Mn(Ri(t)):(Pn(t)?o._d=t:se(e)?$d(o):e?gi(o):qd(o),ko(o)||(o._d=null),o))}function qd(o){var t=o._i;kt(t)?o._d=new Date(q.now()):Pn(t)?o._d=new Date(t.valueOf()):typeof t=="string"?Ad(o):se(t)?(o._a=gs(t.slice(0),function(e){return parseInt(e,10)}),hi(o)):_e(t)?zd(o):Me(t)?o._d=new Date(t):q.createFromInputFallback(o)}function Ks(o,t,e,n,i){var r={};return(t===!0||t===!1)&&(n=t,t=void 0),(e===!0||e===!1)&&(n=e,e=void 0),(_e(o)&&Go(o)||se(o)&&o.length===0)&&(o=void 0),r._isAMomentObject=!0,r._useUTC=r._isUTC=i,r._l=e,r._i=o,r._f=t,r._strict=n,jd(r)}function Ft(o,t,e,n){return Ks(o,t,e,n,!1)}var tR=te("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=Ft.apply(null,arguments);return this.isValid()&&o.isValid()?o<this?this:o:Gn()}),eR=te("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=Ft.apply(null,arguments);return this.isValid()&&o.isValid()?o>this?this:o:Gn()});function Hs(o,t){var e,n;if(t.length===1&&se(t[0])&&(t=t[0]),!t.length)return Ft();for(e=t[0],n=1;n<t.length;++n)(!t[n].isValid()||t[n][o](e))&&(e=t[n]);return e}function nR(){var o=[].slice.call(arguments,0);return Hs("isBefore",o)}function oR(){var o=[].slice.call(arguments,0);return Hs("isAfter",o)}var iR=function(){return Date.now?Date.now():+new Date},Wn=["year","quarter","month","week","day","hour","minute","second","millisecond"];function sR(o){var t,e=!1,n,i=Wn.length;for(t in o)if(Ot(o,t)&&!(wt.call(Wn,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[Wn[n]]){if(e)return!1;parseFloat(o[Wn[n]])!==ft(o[Wn[n]])&&(e=!0)}return!0}function rR(){return this._isValid}function lR(){return ae(NaN)}function io(o){var t=ei(o),e=t.year||0,n=t.quarter||0,i=t.month||0,r=t.week||t.isoWeek||0,s=t.day||0,a=t.hour||0,c=t.minute||0,d=t.second||0,R=t.millisecond||0;this._isValid=sR(t),this._milliseconds=+R+d*1e3+c*6e4+a*1e3*60*60,this._days=+s+r*7,this._months=+i+n*3+e*12,this._data={},this._locale=Xe(),this._bubble()}function so(o){return o instanceof io}function fi(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function aR(o,t,e){var n=Math.min(o.length,t.length),i=Math.abs(o.length-t.length),r=0,s;for(s=0;s<n;s++)ft(o[s])!==ft(t[s])&&r++;return r+i}function _s(o,t){rt(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+Le(~~(e/60),2)+t+Le(~~e%60,2)})}_s("Z",":"),_s("ZZ",""),ot("Z",jn),ot("ZZ",jn),Et(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=Ti(jn,o)});var cR=/([\+\-]|\d\d)/gi;function Ti(o,t){var e=(t||"").match(o),n,i,r;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(cR)||["-",0,0],r=+(i[1]*60)+ft(i[2]),r===0?0:i[0]==="+"?r:-r)}function mi(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(re(o)||Pn(o)?o.valueOf():Ft(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),q.updateOffset(e,!1),e):Ft(o).local()}function pi(o){return-Math.round(o._d.getTimezoneOffset())}q.updateOffset=function(){};function dR(o,t,e){var n=this._offset||0,i;if(!this.isValid())return o!=null?this:NaN;if(o!=null){if(typeof o=="string"){if(o=Ti(jn,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=pi(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?ks(this,ae(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,q.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:pi(this)}function RR(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function uR(o){return this.utcOffset(0,o)}function hR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(pi(this),"m")),this}function gR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=Ti(Vc,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function fR(o){return this.isValid()?(o=o?Ft(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function TR(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function mR(){if(!kt(this._isDSTShifted))return this._isDSTShifted;var o={},t;return Bo(o,this),o=vs(o),o._a?(t=o._isUTC?me(o._a):Ft(o._a),this._isDSTShifted=this.isValid()&&aR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function pR(){return this.isValid()?!this._isUTC:!1}function LR(){return this.isValid()?this._isUTC:!1}function xs(){return this.isValid()?this._isUTC&&this._offset===0:!1}var IR=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,PR=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function ae(o,t){var e=o,n=null,i,r,s;return so(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:Me(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=IR.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:ft(n[Ie])*i,h:ft(n[vt])*i,m:ft(n[le])*i,s:ft(n[Se])*i,ms:ft(fi(n[xe]*1e3))*i}):(n=PR.exec(o))?(i=n[1]==="-"?-1:1,e={y:Ge(n[2],i),M:Ge(n[3],i),w:Ge(n[4],i),d:Ge(n[5],i),h:Ge(n[6],i),m:Ge(n[7],i),s:Ge(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(s=MR(Ft(e.from),Ft(e.to)),e={},e.ms=s.milliseconds,e.M=s.months),r=new io(e),so(o)&&Ot(o,"_locale")&&(r._locale=o._locale),so(o)&&Ot(o,"_isValid")&&(r._isValid=o._isValid),r}ae.fn=io.prototype,ae.invalid=lR;function Ge(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function Gs(o,t){var e={};return e.months=t.month()-o.month()+(t.year()-o.year())*12,o.clone().add(e.months,"M").isAfter(t)&&--e.months,e.milliseconds=+t-+o.clone().add(e.months,"M"),e}function MR(o,t){var e;return o.isValid()&&t.isValid()?(t=mi(t,o),o.isBefore(t)?e=Gs(o,t):(e=Gs(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function As(o,t){return function(e,n){var i,r;return n!==null&&!isNaN(+n)&&(ps(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),r=e,e=n,n=r),i=ae(e,n),ks(this,i,o),this}}function ks(o,t,e,n){var i=t._milliseconds,r=fi(t._days),s=fi(t._months);o.isValid()&&(n=n??!0,s&&Fs(o,En(o,"Month")+s*e),r&&Es(o,"Date",En(o,"Date")+r*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&q.updateOffset(o,r||s))}var OR=As(1,"add"),CR=As(-1,"subtract");function Js(o){return typeof o=="string"||o instanceof String}function SR(o){return re(o)||Pn(o)||Js(o)||Me(o)||XR(o)||ER(o)||o===null||o===void 0}function ER(o){var t=_e(o)&&!Go(o),e=!1,n=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],i,r,s=n.length;for(i=0;i<s;i+=1)r=n[i],e=e||Ot(o,r);return t&&e}function XR(o){var t=se(o),e=!1;return t&&(e=o.filter(function(n){return!Me(n)&&Js(o)}).length===0),t&&e}function NR(o){var t=_e(o)&&!Go(o),e=!1,n=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],i,r;for(i=0;i<n.length;i+=1)r=n[i],e=e||Ot(o,r);return t&&e}function FR(o,t){var e=o.diff(t,"days",!0);return e<-6?"sameElse":e<-1?"lastWeek":e<0?"lastDay":e<1?"sameDay":e<2?"nextDay":e<7?"nextWeek":"sameElse"}function yR(o,t){arguments.length===1&&(arguments[0]?SR(arguments[0])?(o=arguments[0],t=void 0):NR(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||Ft(),n=mi(e,this).startOf("day"),i=q.calendarFormat(this,n)||"sameElse",r=t&&(pe(t[i])?t[i].call(this,e):t[i]);return this.format(r||this.localeData().calendar(i,this,Ft(e)))}function WR(){return new Mn(this)}function bR(o,t){var e=re(o)?o:Ft(o);return this.isValid()&&e.isValid()?(t=ee(t)||"millisecond",t==="millisecond"?this.valueOf()>e.valueOf():e.valueOf()<this.clone().startOf(t).valueOf()):!1}function VR(o,t){var e=re(o)?o:Ft(o);return this.isValid()&&e.isValid()?(t=ee(t)||"millisecond",t==="millisecond"?this.valueOf()<e.valueOf():this.clone().endOf(t).valueOf()<e.valueOf()):!1}function YR(o,t,e,n){var i=re(o)?o:Ft(o),r=re(t)?t:Ft(t);return this.isValid()&&i.isValid()&&r.isValid()?(n=n||"()",(n[0]==="("?this.isAfter(i,e):!this.isBefore(i,e))&&(n[1]===")"?this.isBefore(r,e):!this.isAfter(r,e))):!1}function DR(o,t){var e=re(o)?o:Ft(o),n;return this.isValid()&&e.isValid()?(t=ee(t)||"millisecond",t==="millisecond"?this.valueOf()===e.valueOf():(n=e.valueOf(),this.clone().startOf(t).valueOf()<=n&&n<=this.clone().endOf(t).valueOf())):!1}function UR(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function wR(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function ZR(o,t,e){var n,i,r;if(!this.isValid())return NaN;if(n=mi(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=ee(t),t){case"year":r=ro(this,n)/12;break;case"month":r=ro(this,n);break;case"quarter":r=ro(this,n)/3;break;case"second":r=(this-n)/1e3;break;case"minute":r=(this-n)/6e4;break;case"hour":r=(this-n)/36e5;break;case"day":r=(this-n-i)/864e5;break;case"week":r=(this-n-i)/6048e5;break;default:r=this-n}return e?r:ne(r)}function ro(o,t){if(o.date()<t.date())return-ro(t,o);var e=(t.year()-o.year())*12+(t.month()-o.month()),n=o.clone().add(e,"months"),i,r;return t-n<0?(i=o.clone().add(e-1,"months"),r=(t-n)/(n-i)):(i=o.clone().add(e+1,"months"),r=(t-n)/(i-n)),-(e+r)||0}q.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",q.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function QR(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function vR(o){if(!this.isValid())return null;var t=o!==!0,e=t?this.clone().utc():this;return e.year()<0||e.year()>9999?kn(e,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):pe(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",kn(e,"Z")):kn(e,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function KR(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var o="moment",t="",e,n,i,r;return this.isLocal()||(o=this.utcOffset()===0?"moment.utc":"moment.parseZone",t="Z"),e="["+o+'("]',n=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i="-MM-DD[T]HH:mm:ss.SSS",r=t+'[")]',this.format(e+n+i+r)}function HR(o){o||(o=this.isUtc()?q.defaultFormatUtc:q.defaultFormat);var t=kn(this,o);return this.localeData().postformat(t)}function _R(o,t){return this.isValid()&&(re(o)&&o.isValid()||Ft(o).isValid())?ae({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function xR(o){return this.from(Ft(),o)}function GR(o,t){return this.isValid()&&(re(o)&&o.isValid()||Ft(o).isValid())?ae({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function AR(o){return this.to(Ft(),o)}function Bs(o){var t;return o===void 0?this._locale._abbr:(t=Xe(o),t!=null&&(this._locale=t),this)}var $s=te("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(o){return o===void 0?this.localeData():this.locale(o)});function zs(){return this._locale}var lo=1e3,Rn=60*lo,ao=60*Rn,js=(365*400+97)*24*ao;function un(o,t){return(o%t+t)%t}function qs(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-js:new Date(o,t,e).valueOf()}function tr(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-js:Date.UTC(o,t,e)}function kR(o){var t,e;if(o=ee(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?tr:qs,o){case"year":t=e(this.year(),0,1);break;case"quarter":t=e(this.year(),this.month()-this.month()%3,1);break;case"month":t=e(this.year(),this.month(),1);break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=e(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=un(t+(this._isUTC?0:this.utcOffset()*Rn),ao);break;case"minute":t=this._d.valueOf(),t-=un(t,Rn);break;case"second":t=this._d.valueOf(),t-=un(t,lo);break}return this._d.setTime(t),q.updateOffset(this,!0),this}function JR(o){var t,e;if(o=ee(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?tr:qs,o){case"year":t=e(this.year()+1,0,1)-1;break;case"quarter":t=e(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=e(this.year(),this.month()+1,1)-1;break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=e(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=ao-un(t+(this._isUTC?0:this.utcOffset()*Rn),ao)-1;break;case"minute":t=this._d.valueOf(),t+=Rn-un(t,Rn)-1;break;case"second":t=this._d.valueOf(),t+=lo-un(t,lo)-1;break}return this._d.setTime(t),q.updateOffset(this,!0),this}function BR(){return this._d.valueOf()-(this._offset||0)*6e4}function $R(){return Math.floor(this.valueOf()/1e3)}function zR(){return new Date(this.valueOf())}function jR(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function qR(){var o=this;return{years:o.year(),months:o.month(),date:o.date(),hours:o.hours(),minutes:o.minutes(),seconds:o.seconds(),milliseconds:o.milliseconds()}}function tu(){return this.isValid()?this.toISOString():null}function eu(){return ko(this)}function nu(){return Ue({},Rt(this))}function ou(){return Rt(this).overflow}function iu(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}rt("N",0,0,"eraAbbr"),rt("NN",0,0,"eraAbbr"),rt("NNN",0,0,"eraAbbr"),rt("NNNN",0,0,"eraName"),rt("NNNNN",0,0,"eraNarrow"),rt("y",["y",1],"yo","eraYear"),rt("y",["yy",2],0,"eraYear"),rt("y",["yyy",3],0,"eraYear"),rt("y",["yyyy",4],0,"eraYear"),ot("N",Li),ot("NN",Li),ot("NNN",Li),ot("NNNN",fu),ot("NNNNN",Tu),Et(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Rt(e).era=i:Rt(e).invalidEra=o}),ot("y",ln),ot("yy",ln),ot("yyy",ln),ot("yyyy",ln),ot("yo",mu),Et(["y","yy","yyy","yyyy"],xt),Et(["yo"],function(o,t,e,n){var i;e._locale._eraYearOrdinalRegex&&(i=o.match(e._locale._eraYearOrdinalRegex)),e._locale.eraYearOrdinalParse?t[xt]=e._locale.eraYearOrdinalParse(o,i):t[xt]=parseInt(o,10)});function su(o,t){var e,n,i,r=this._eras||Xe("en")._eras;for(e=0,n=r.length;e<n;++e)switch(typeof r[e].since==="string"&&(i=q(r[e].since).startOf("day"),r[e].since=i.valueOf()),typeof r[e].until){case"undefined":r[e].until=1/0;break;case"string":i=q(r[e].until).startOf("day").valueOf(),r[e].until=i.valueOf();break}return r}function ru(o,t,e){var n,i,r=this.eras(),s,a,c;for(o=o.toUpperCase(),n=0,i=r.length;n<i;++n)if(s=r[n].name.toUpperCase(),a=r[n].abbr.toUpperCase(),c=r[n].narrow.toUpperCase(),e)switch(t){case"N":case"NN":case"NNN":if(a===o)return r[n];break;case"NNNN":if(s===o)return r[n];break;case"NNNNN":if(c===o)return r[n];break}else if([s,a,c].indexOf(o)>=0)return r[n]}function lu(o,t){var e=o.since<=o.until?1:-1;return t===void 0?q(o.since).year():q(o.since).year()+(t-o.offset)*e}function au(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].name;return""}function cu(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].narrow;return""}function du(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].abbr;return""}function Ru(){var o,t,e,n,i=this.localeData().eras();for(o=0,t=i.length;o<t;++o)if(e=i[o].since<=i[o].until?1:-1,n=this.clone().startOf("day").valueOf(),i[o].since<=n&&n<=i[o].until||i[o].until<=n&&n<=i[o].since)return(this.year()-q(i[o].since).year())*e+i[o].offset;return this.year()}function uu(o){return Ot(this,"_erasNameRegex")||Ii.call(this),o?this._erasNameRegex:this._erasRegex}function hu(o){return Ot(this,"_erasAbbrRegex")||Ii.call(this),o?this._erasAbbrRegex:this._erasRegex}function gu(o){return Ot(this,"_erasNarrowRegex")||Ii.call(this),o?this._erasNarrowRegex:this._erasRegex}function Li(o,t){return t.erasAbbrRegex(o)}function fu(o,t){return t.erasNameRegex(o)}function Tu(o,t){return t.erasNarrowRegex(o)}function mu(o,t){return t._eraYearOrdinalRegex||ln}function Ii(){var o=[],t=[],e=[],n=[],i,r,s,a,c,d=this.eras();for(i=0,r=d.length;i<r;++i)s=Oe(d[i].name),a=Oe(d[i].abbr),c=Oe(d[i].narrow),t.push(s),o.push(a),e.push(c),n.push(s),n.push(a),n.push(c);this._erasRegex=new RegExp("^("+n.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+t.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+o.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+e.join("|")+")","i")}rt(0,["gg",2],0,function(){return this.weekYear()%100}),rt(0,["GG",2],0,function(){return this.isoWeekYear()%100});function co(o,t){rt(0,[o,o.length],0,t)}co("gggg","weekYear"),co("ggggg","weekYear"),co("GGGG","isoWeekYear"),co("GGGGG","isoWeekYear"),ot("G",zn),ot("g",zn),ot("GG",Nt,zt),ot("gg",Nt,zt),ot("GGGG",oi,ni),ot("gggg",oi,ni),ot("GGGGG",$n,Jn),ot("ggggg",$n,Jn),Cn(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=ft(o)}),Cn(["gg","GG"],function(o,t,e,n){t[n]=q.parseTwoDigitYear(o)});function pu(o){return er.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function Lu(o){return er.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function Iu(){return Ee(this.year(),1,4)}function Pu(){return Ee(this.isoWeekYear(),1,4)}function Mu(){var o=this.localeData()._week;return Ee(this.year(),o.dow,o.doy)}function Ou(){var o=this.localeData()._week;return Ee(this.weekYear(),o.dow,o.doy)}function er(o,t,e,n,i){var r;return o==null?Nn(this,n,i).year:(r=Ee(o,n,i),t>r&&(t=r),Cu.call(this,o,t,e,n,i))}function Cu(o,t,e,n,i){var r=bs(o,t,e,n,i),s=Xn(r.year,0,r.dayOfYear);return this.year(s.getUTCFullYear()),this.month(s.getUTCMonth()),this.date(s.getUTCDate()),this}rt("Q",0,"Qo","quarter"),ot("Q",Ps),Et("Q",function(o,t){t[Ce]=(ft(o)-1)*3});function Su(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}rt("D",["DD",2],"Do","date"),ot("D",Nt,an),ot("DD",Nt,zt),ot("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Et(["D","DD"],Ie),Et("Do",function(o,t){t[Ie]=ft(o.match(Nt)[0])});var nr=cn("Date",!0);rt("DDD",["DDDD",3],"DDDo","dayOfYear"),ot("DDD",Bn),ot("DDDD",Ms),Et(["DDD","DDDD"],function(o,t,e){e._dayOfYear=ft(o)});function Eu(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}rt("m",["mm",2],0,"minute"),ot("m",Nt,ii),ot("mm",Nt,zt),Et(["m","mm"],le);var Xu=cn("Minutes",!1);rt("s",["ss",2],0,"second"),ot("s",Nt,ii),ot("ss",Nt,zt),Et(["s","ss"],Se);var Nu=cn("Seconds",!1);rt("S",0,0,function(){return~~(this.millisecond()/100)}),rt(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),rt(0,["SSS",3],0,"millisecond"),rt(0,["SSSS",4],0,function(){return this.millisecond()*10}),rt(0,["SSSSS",5],0,function(){return this.millisecond()*100}),rt(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),rt(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),rt(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),rt(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),ot("S",Bn,Ps),ot("SS",Bn,zt),ot("SSS",Bn,Ms);var Ze,or;for(Ze="SSSS";Ze.length<=9;Ze+="S")ot(Ze,ln);function Fu(o,t){t[xe]=ft(("0."+o)*1e3)}for(Ze="S";Ze.length<=9;Ze+="S")Et(Ze,Fu);or=cn("Milliseconds",!1),rt("z",0,0,"zoneAbbr"),rt("zz",0,0,"zoneName");function yu(){return this._isUTC?"UTC":""}function Wu(){return this._isUTC?"Coordinated Universal Time":""}var k=Mn.prototype;k.add=OR,k.calendar=yR,k.clone=WR,k.diff=ZR,k.endOf=JR,k.format=HR,k.from=_R,k.fromNow=xR,k.to=GR,k.toNow=AR,k.get=Kc,k.invalidAt=ou,k.isAfter=bR,k.isBefore=VR,k.isBetween=YR,k.isSame=DR,k.isSameOrAfter=UR,k.isSameOrBefore=wR,k.isValid=eu,k.lang=$s,k.locale=Bs,k.localeData=zs,k.max=eR,k.min=tR,k.parsingFlags=nu,k.set=Hc,k.startOf=kR,k.subtract=CR,k.toArray=jR,k.toObject=qR,k.toDate=zR,k.toISOString=vR,k.inspect=KR,typeof Symbol<"u"&&Symbol.for!=null&&(k[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),k.toJSON=tu,k.toString=QR,k.unix=$R,k.valueOf=BR,k.creationData=iu,k.eraName=au,k.eraNarrow=cu,k.eraAbbr=du,k.eraYear=Ru,k.year=Ss,k.isLeapYear=vc,k.weekYear=pu,k.isoWeekYear=Lu,k.quarter=k.quarters=Su,k.month=ys,k.daysInMonth=zc,k.week=k.weeks=sd,k.isoWeek=k.isoWeeks=rd,k.weeksInYear=Mu,k.weeksInWeekYear=Ou,k.isoWeeksInYear=Iu,k.isoWeeksInISOWeekYear=Pu,k.date=nr,k.day=k.days=Ld,k.weekday=Id,k.isoWeekday=Pd,k.dayOfYear=Eu,k.hour=k.hours=Nd,k.minute=k.minutes=Xu,k.second=k.seconds=Nu,k.millisecond=k.milliseconds=or,k.utcOffset=dR,k.utc=uR,k.local=hR,k.parseZone=gR,k.hasAlignedHourOffset=fR,k.isDST=TR,k.isLocal=pR,k.isUtcOffset=LR,k.isUtc=xs,k.isUTC=xs,k.zoneAbbr=yu,k.zoneName=Wu,k.dates=te("dates accessor is deprecated. Use date instead.",nr),k.months=te("months accessor is deprecated. Use month instead",ys),k.years=te("years accessor is deprecated. Use year instead",Ss),k.zone=te("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",RR),k.isDSTShifted=te("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",mR);function bu(o){return Ft(o*1e3)}function Vu(){return Ft.apply(null,arguments).parseZone()}function ir(o){return o}var Ct=zo.prototype;Ct.calendar=pc,Ct.longDateFormat=Mc,Ct.invalidDate=Cc,Ct.ordinal=Xc,Ct.preparse=ir,Ct.postformat=ir,Ct.relativeTime=Fc,Ct.pastFuture=yc,Ct.set=Tc,Ct.eras=su,Ct.erasParse=ru,Ct.erasConvertYear=lu,Ct.erasAbbrRegex=hu,Ct.erasNameRegex=uu,Ct.erasNarrowRegex=gu,Ct.months=kc,Ct.monthsShort=Jc,Ct.monthsParse=$c,Ct.monthsRegex=qc,Ct.monthsShortRegex=jc,Ct.week=ed,Ct.firstDayOfYear=id,Ct.firstDayOfWeek=od,Ct.weekdays=gd,Ct.weekdaysMin=Td,Ct.weekdaysShort=fd,Ct.weekdaysParse=pd,Ct.weekdaysRegex=Md,Ct.weekdaysShortRegex=Od,Ct.weekdaysMinRegex=Cd,Ct.isPM=Ed,Ct.meridiem=Fd;function Ro(o,t,e,n){var i=Xe(),r=me().set(n,t);return i[e](r,o)}function sr(o,t,e){if(Me(o)&&(t=o,o=void 0),o=o||"",t!=null)return Ro(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=Ro(o,n,e,"month");return i}function Pi(o,t,e,n){typeof o=="boolean"?(Me(t)&&(e=t,t=void 0),t=t||""):(t=o,e=t,o=!1,Me(t)&&(e=t,t=void 0),t=t||"");var i=Xe(),r=o?i._week.dow:0,s,a=[];if(e!=null)return Ro(t,(e+r)%7,n,"day");for(s=0;s<7;s++)a[s]=Ro(t,(s+r)%7,n,"day");return a}function Yu(o,t){return sr(o,t,"months")}function Du(o,t){return sr(o,t,"monthsShort")}function Uu(o,t,e){return Pi(o,t,e,"weekdays")}function wu(o,t,e){return Pi(o,t,e,"weekdaysShort")}function Zu(o,t,e){return Pi(o,t,e,"weekdaysMin")}we("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(o){var t=o%10,e=ft(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),q.lang=te("moment.lang is deprecated. Use moment.locale instead.",we),q.langData=te("moment.langData is deprecated. Use moment.localeData instead.",Xe);var Ne=Math.abs;function Qu(){var o=this._data;return this._milliseconds=Ne(this._milliseconds),this._days=Ne(this._days),this._months=Ne(this._months),o.milliseconds=Ne(o.milliseconds),o.seconds=Ne(o.seconds),o.minutes=Ne(o.minutes),o.hours=Ne(o.hours),o.months=Ne(o.months),o.years=Ne(o.years),this}function rr(o,t,e,n){var i=ae(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function vu(o,t){return rr(this,o,t,1)}function Ku(o,t){return rr(this,o,t,-1)}function lr(o){return o<0?Math.floor(o):Math.ceil(o)}function Hu(){var o=this._milliseconds,t=this._days,e=this._months,n=this._data,i,r,s,a,c;return o>=0&&t>=0&&e>=0||o<=0&&t<=0&&e<=0||(o+=lr(Mi(e)+t)*864e5,t=0,e=0),n.milliseconds=o%1e3,i=ne(o/1e3),n.seconds=i%60,r=ne(i/60),n.minutes=r%60,s=ne(r/60),n.hours=s%24,t+=ne(s/24),c=ne(ar(t)),e+=c,t-=lr(Mi(c)),a=ne(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function ar(o){return o*4800/146097}function Mi(o){return o*146097/4800}function _u(o){if(!this.isValid())return NaN;var t,e,n=this._milliseconds;if(o=ee(o),o==="month"||o==="quarter"||o==="year")switch(t=this._days+n/864e5,e=this._months+ar(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(Mi(this._months)),o){case"week":return t/7+n/6048e5;case"day":return t+n/864e5;case"hour":return t*24+n/36e5;case"minute":return t*1440+n/6e4;case"second":return t*86400+n/1e3;case"millisecond":return Math.floor(t*864e5)+n;default:throw new Error("Unknown unit "+o)}}function Fe(o){return function(){return this.as(o)}}var cr=Fe("ms"),xu=Fe("s"),Gu=Fe("m"),Au=Fe("h"),ku=Fe("d"),Ju=Fe("w"),Bu=Fe("M"),$u=Fe("Q"),zu=Fe("y"),ju=cr;function qu(){return ae(this)}function th(o){return o=ee(o),this.isValid()?this[o+"s"]():NaN}function Ae(o){return function(){return this.isValid()?this._data[o]:NaN}}var eh=Ae("milliseconds"),nh=Ae("seconds"),oh=Ae("minutes"),ih=Ae("hours"),sh=Ae("days"),rh=Ae("months"),lh=Ae("years");function ah(){return ne(this.days()/7)}var ye=Math.round,hn={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function ch(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function dh(o,t,e,n){var i=ae(o).abs(),r=ye(i.as("s")),s=ye(i.as("m")),a=ye(i.as("h")),c=ye(i.as("d")),d=ye(i.as("M")),R=ye(i.as("w")),u=ye(i.as("y")),h=r<=e.ss&&["s",r]||r<e.s&&["ss",r]||s<=1&&["m"]||s<e.m&&["mm",s]||a<=1&&["h"]||a<e.h&&["hh",a]||c<=1&&["d"]||c<e.d&&["dd",c];return e.w!=null&&(h=h||R<=1&&["w"]||R<e.w&&["ww",R]),h=h||d<=1&&["M"]||d<e.M&&["MM",d]||u<=1&&["y"]||["yy",u],h[2]=t,h[3]=+o>0,h[4]=n,ch.apply(null,h)}function Rh(o){return o===void 0?ye:typeof o=="function"?(ye=o,!0):!1}function uh(o,t){return hn[o]===void 0?!1:t===void 0?hn[o]:(hn[o]=t,o==="s"&&(hn.ss=t-1),!0)}function hh(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=hn,i,r;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},hn,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),r=dh(this,!e,n,i),e&&(r=i.pastFuture(+this,r)),i.postformat(r)}var Oi=Math.abs;function gn(o){return(o>0)-(o<0)||+o}function uo(){if(!this.isValid())return this.localeData().invalidDate();var o=Oi(this._milliseconds)/1e3,t=Oi(this._days),e=Oi(this._months),n,i,r,s,a=this.asSeconds(),c,d,R,u;return a?(n=ne(o/60),i=ne(n/60),o%=60,n%=60,r=ne(e/12),e%=12,s=o?o.toFixed(3).replace(/\.?0+$/,""):"",c=a<0?"-":"",d=gn(this._months)!==gn(a)?"-":"",R=gn(this._days)!==gn(a)?"-":"",u=gn(this._milliseconds)!==gn(a)?"-":"",c+"P"+(r?d+r+"Y":"")+(e?d+e+"M":"")+(t?R+t+"D":"")+(i||n||o?"T":"")+(i?u+i+"H":"")+(n?u+n+"M":"")+(o?u+s+"S":"")):"P0D"}var It=io.prototype;It.isValid=rR,It.abs=Qu,It.add=vu,It.subtract=Ku,It.as=_u,It.asMilliseconds=cr,It.asSeconds=xu,It.asMinutes=Gu,It.asHours=Au,It.asDays=ku,It.asWeeks=Ju,It.asMonths=Bu,It.asQuarters=$u,It.asYears=zu,It.valueOf=ju,It._bubble=Hu,It.clone=qu,It.get=th,It.milliseconds=eh,It.seconds=nh,It.minutes=oh,It.hours=ih,It.days=sh,It.weeks=ah,It.months=rh,It.years=lh,It.humanize=hh,It.toISOString=uo,It.toString=uo,It.toJSON=uo,It.locale=Bs,It.localeData=zs,It.toIsoString=te("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",uo),It.lang=$s,rt("X",0,0,"unix"),rt("x",0,0,"valueOf"),ot("x",zn),ot("X",Yc),Et("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),Et("x",function(o,t,e){e._d=new Date(ft(o))});q.version="2.30.1",gc(Ft),q.fn=k,q.min=nR,q.max=oR,q.now=iR,q.utc=me,q.unix=bu,q.months=Yu,q.isDate=Pn,q.locale=we,q.invalid=Gn,q.duration=ae,q.isMoment=re,q.weekdays=Uu,q.parseZone=Vu,q.localeData=Xe,q.isDuration=so,q.monthsShort=Du,q.weekdaysMin=Zu,q.defineLocale=di,q.updateLocale=Vd,q.locales=Yd,q.weekdaysShort=wu,q.normalizeUnits=ee,q.relativeTimeRounding=Rh,q.relativeTimeThreshold=uh,q.calendarFormat=FR,q.prototype=k,q.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};class Ci{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),r=t?null:i.getTd();n>=e.length&&(n=e.length-1);const s=e[n],a=[];let c=r,d=e,R=n;for(;;){if(R<0&&c?.linkTdPrevId){const T=i.getTdById(c.linkTdPrevId);if(T){d=T.value,R=d.length-1,c=T;continue}}if(R<0)break;const f=d[R];if(f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.PREFIX||f.controlComponent===l.ControlComponent.PRE_TEXT)break;f.controlComponent===l.ControlComponent.VALUE&&a.unshift(f),R--}c=r;let u=e,h=n+1;for(;;){if(h>=u.length&&c?.linkTdNextId){const T=i.getTdById(c.linkTdNextId);if(T){u=T.value,h=0,c=T;continue}}const f=u[h];if(!f||f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.POSTFIX||f.controlComponent===l.ControlComponent.POST_TEXT)break;f.controlComponent===l.ControlComponent.VALUE&&a.push(f),h++}return a.filter(f=>f.type!==l.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=d.controlId;this._removeControlPlaceholders(i,s);const u=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]),h=!!this.element.control?.underline,g=this.options.mode===l.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled&&!h,f=r.startIndex+1,T=[],p=m=>{const I=T.length?T:i,L=T.length?T.length-1:r.startIndex;Ut(I,[m],L,{editorOptions:this.options}),T.push(m)};for(let m=0;m<t.length;m++){const I=t[m];if(I.type===l.ElementType.CONTROL&&I.control){const L=I,P=L.controlId||lt(),O=L.control?.value||[],S=L.control?.type===l.ControlType.TEXTFIELD,F={...u,controlId:P,type:l.ElementType.CONTROL,control:L.control,originControlId:R},N=S?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,V=S?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,Y=S?L.control?.preTextFix||this.options.control.preTextFix:L.control?.prefix||this.options.control.prefix;for(let b=0;b<Y.length;b++){const E={...F,value:Y[b],controlComponent:N};p(E)}for(let b=0;b<O.length;b++){const E=O[b],C={...F,...E,controlComponent:l.ControlComponent.VALUE};(C.color===this.options.control.bracketColor||C.color===this.options.control.placeholderColor)&&(C.color=this.options.defaultColor),p(C)}if(O.length===0){const b=L.control?.placeholder||"";for(let E=0;E<b.length;E++){const C={...F,value:b[E],controlComponent:l.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};p(C)}}const X=S?L.control?.postTextFix||this.options.control.postTextFix:L.control?.postfix||this.options.control.postfix;for(let b=0;b<X.length;b++){const E={...F,value:X[b],controlComponent:V};p(E)}}else if(I.type||I.value){(d.controlComponent===l.ControlComponent.PRE_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.POSTFIX)&&(u.color=this.options.defaultColor);const P={...u,...I,controlComponent:l.ControlComponent.VALUE};(P.color===this.options.control.bracketColor||P.color===this.options.control.placeholderColor||P.color===this.options.control.textFixColor)&&(P.color=this.options.defaultColor),P.strikeout&&delete P.strikeout,g&&(P.textDecoration={style:l.TextDecorationStyle.DOUBLE},P.underline=!0),p(P)}}return T.length&&c.spliceElementList(i,f,0,T),r.startIndex+T.length}_removeControlPlaceholders(t,e){const n=t[e];if(!n?.controlId)return;const i=a=>!!a&&a.controlId===n.controlId&&a.originControlId===n.originControlId;let r=e;for(;r>=0&&i(t[r]);)r--;let s=e+1;for(;s<t.length&&i(t[s]);)s++;for(let a=s-1;a>r;a--)t[a].controlComponent===l.ControlComponent.PLACEHOLDER&&t.splice(a,1)}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:r,endIndex:s}=i;return this.control.getDraw().spliceElementList(n,r+1,s-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(r,t)),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.control.getDraw(),d=!!s.originControlId;if(t.key===l.KeyMap.Backspace)if(this.options.mode===l.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&!d){if(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER)return i;this.strikeout()}else{if(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER)return i;if(i!==r){c.spliceElementList(e,i+1,r-i);const u=e[i+1];return(u?.controlComponent===l.ControlComponent.POSTFIX||u?.controlComponent===l.ControlComponent.POST_TEXT||u?.controlComponent===l.ControlComponent.POSTTEXTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(i),i===0&&e[0].type===l.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i}else{const u=e[i+1];return u?.controlComponent===l.ControlComponent.POSTFIX||u?.controlComponent===l.ControlComponent.POST_TEXT||u?.controlComponent===l.ControlComponent.POSTTEXTFIX||u?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT?(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),i-1):(c.spliceElementList(e,i,1),i===1&&e[0].type===l.ElementType.SPLIT_TAG||i===0?c.fixPosition(!0)??i-1:i-1)}}else if(t.key===l.KeyMap.Delete){const R=e[r+1],u=!!s.originControlId;if(this.options.mode===l.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&!u){if(a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||a.controlComponent===l.ControlComponent.POSTTEXTFIX||a.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER)return r;if(R?.controlComponent===l.ControlComponent.POSTFIX||R?.controlComponent===l.ControlComponent.POST_TEXT||R?.controlComponent===l.ControlComponent.POSTTEXTFIX||R?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)return c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i;this.strikeout()}else{const g=e[r+1];return s.controlComponent===l.ControlComponent.PLACEHOLDER?r:g?.controlComponent===l.ControlComponent.POSTFIX||g?.controlComponent===l.ControlComponent.POST_TEXT||g?.controlComponent===l.ControlComponent.POSTTEXTFIX||g?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT?(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):i!==r?(c.spliceElementList(e,i+1,r-i),i===0&&e[0].type===l.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):g?(c.spliceElementList(e,i+1,1),i===0&&e[0].type===l.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):(c.getTd()?.linkTdNextId&&s.controlId&&this.removeNextControlElement(s.controlId),r)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();n.spliceElementList(i,t+1,e-t);const r=i[t+1];return(r?.controlComponent===l.ControlComponent.POSTFIX||r?.controlComponent===l.ControlComponent.POST_TEXT||r?.controlComponent===l.ControlComponent.POSTTEXTFIX||r?.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(t),t}strikeout(t){const e=this.control.getRange(),{endIndex:n}=e,{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return;const s=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=q(new Date).format("YYYY-MM-DD HH:mm:ss");if(s?.length){if(!this.element.strikeout){const d=s.findIndex(R=>!R.strikeout);s.forEach(R=>{R.deletePerson="SWJ",R.deleteTime=c,R.strikeout=!!~d}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),setTimeout(()=>{this.strikeoute()},100)}}else{const d=this.control.getElementList()[a.index],R=this.control.getElementList();if(!this.control.getElementList()[a.index].strikeout&&d?.metrics.width>0){this.control.getElementList()[a.index].strikeout=!0,this.control.getElementList()[a.index].deletePerson="SWJ",this.control.getElementList()[a.index].deleteTime=c;const u=--a.index;setTimeout(()=>{this.strikeoute()},100),setTimeout(()=>{const g=u;this.draws.render({curIndex:g,isSetCursor:!0}),a.index=u,this.position.setCursorPosition(a),this.ranges.setRange(u,u)},100)}else n>=0&&n<R.length&&R[n]?.metrics?.width!==void 0&&R[n].metrics.width<=0&&!R[n]?.strikeout&&(setTimeout(()=>{R.splice(n,1)},100),setTimeout(()=>{const h=n-1;this.draws.render({curIndex:h,isSetCursor:!0}),a.index=h,delete a.value,this.position.setCursorPosition(a),this.ranges.setRange(h,h)},100))}}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:r}=this.ranges.getRange(),a=this.draws.getElementList()[r];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}class dr{draw;options;now;dom;renderOptions;isDatePicker;pickDate;lang;constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${z}-date-container`),t.setAttribute(de,l.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${z}-date-wrap`);const n=document.createElement("div");n.classList.add(`${z}-date-title`);const i=document.createElement("span");i.classList.add(`${z}-date-title__pre-year`),i.innerText="<<";const r=document.createElement("span");r.classList.add(`${z}-date-title__pre-month`),r.innerText="<";const s=document.createElement("span");s.classList.add(`${z}-date-title__now`);const a=document.createElement("span");a.classList.add(`${z}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${z}-date-title__next-year`),c.innerText=">>",n.append(i),n.append(r),n.append(s),n.append(a),n.append(c);const d=document.createElement("div");d.classList.add(`${z}-date-week`);const{weeks:{sun:R,mon:u,tue:h,wed:g,thu:f,fri:T,sat:p}}=this.lang;[R,u,h,g,f,T,p].forEach(b=>{const E=document.createElement("span");E.innerText=`${b}`,d.append(E)});const I=document.createElement("div");I.classList.add(`${z}-date-day`),e.append(n),e.append(d),e.append(I);const L=document.createElement("ul");L.classList.add(`${z}-time-wrap`);let P,O,S;[this.lang.hour,this.lang.minute,this.lang.second].forEach((b,E)=>{const C=document.createElement("li"),M=document.createElement("span");M.innerText=b,C.append(M);const y=document.createElement("ol"),W=E===0,D=E===1,U=W?24:60;for(let Q=0;Q<U;Q++){const G=document.createElement("li");G.innerText=`${String(Q).padStart(2,"0")}`,G.setAttribute("data-id",`${Q}`),y.append(G)}W?P=y:D?O=y:S=y,C.append(y),L.append(C)});const N=document.createElement("div");N.classList.add(`${z}-date-menu`);const V=document.createElement("button");V.classList.add(`${z}-date-menu__time`),V.innerText=this.lang.timeSelect;const Y=document.createElement("button");Y.classList.add(`${z}-date-menu__now`),Y.innerText=this.lang.now;const X=document.createElement("button");return X.classList.add(`${z}-date-menu__submit`),X.innerText=this.lang.confirm,N.append(V),N.append(Y),N.append(X),t.append(e),t.append(L),t.append(N),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:L,title:{preYear:i,preMonth:r,now:s,nextMonth:a,nextYear:c},day:I,time:{hour:P,minute:O,second:S},menu:{time:V,now:Y,submit:X}}}_bindEvent(){this.dom.title.preYear.onclick=()=>{this._preYear()},this.dom.title.preMonth.onclick=()=>{this._preMonth()},this.dom.title.nextMonth.onclick=()=>{this._nextMonth()},this.dom.title.nextYear.onclick=()=>{this._nextYear()},this.dom.menu.time.onclick=()=>{this.isDatePicker=!this.isDatePicker,this._toggleDateTimePicker()},this.dom.menu.now.onclick=()=>{this._now(),this._submit()},this.dom.menu.submit.onclick=()=>{this.dispose(),this._submit()},this.dom.time.hour.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setHours(Number(n)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setMinutes(Number(n)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setSeconds(Number(n)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:n,pageNo:i}}=this.renderOptions,r=this.draw.getHeight(),s=this.draw.getPageGap(),c=(i??this.draw.getPageNo())*(r+s);this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+c+n}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){const t=this.renderOptions?.value;if(t){const e=new Date(t);this.now=this.isInvalidDate(e)?new Date:e}else this.now=new Date;this.pickDate=new Date(this.now)}_getLang(){const t=this.draw.getI18n(),e=t.t.bind(t);return{now:e("datePicker.now"),confirm:e("datePicker.confirm"),return:e("datePicker.return"),timeSelect:e("datePicker.timeSelect"),weeks:{sun:e("datePicker.weeks.sun"),mon:e("datePicker.weeks.mon"),tue:e("datePicker.weeks.tue"),wed:e("datePicker.weeks.wed"),thu:e("datePicker.weeks.thu"),fri:e("datePicker.weeks.fri"),sat:e("datePicker.weeks.sat")},year:e("datePicker.year"),month:e("datePicker.month"),hour:e("datePicker.hour"),minute:e("datePicker.minute"),second:e("datePicker.second")}}_setLangChange(){this.dom.menu.time.innerText=this.lang.timeSelect,this.dom.menu.now.innerText=this.lang.now,this.dom.menu.submit.innerText=this.lang.confirm;const{weeks:{sun:t,mon:e,tue:n,wed:i,thu:r,fri:s,sat:a}}=this.lang,c=[t,e,n,i,r,s,a];this.dom.datePickerWeek.childNodes.forEach((h,g)=>{const f=h;f.innerText=c[g]});const d=this.dom.time.hour.previousElementSibling;d.innerText=this.lang.hour;const R=this.dom.time.minute.previousElementSibling;R.innerText=this.lang.minute;const u=this.dom.time.second.previousElementSibling;u.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();let r=null,s=null,a=null;this.pickDate&&(r=this.pickDate.getFullYear(),s=this.pickDate.getMonth()+1,a=this.pickDate.getDate());const c=this.now.getFullYear(),d=this.now.getMonth()+1;this.dom.title.now.innerText=`${c}${this.lang.year} ${String(d).padStart(2,"0")}${this.lang.month}`;const u=new Date(c,d,0).getDate();let h=new Date(c,d-1,1).getDay();h===0&&(h=7);const g=new Date(c,d-1,0).getDate();this.dom.day.innerHTML="";const f=g-h+1;for(let p=f;p<=g;p++){const m=document.createElement("div");m.classList.add("disable"),m.innerText=`${p}`,m.onclick=()=>{const I=d-2;this.now=new Date(c,I,p),this._setDatePick(c,I,p)},this.dom.day.append(m)}for(let p=1;p<=u;p++){const m=document.createElement("div");e===c&&n===d&&i===p&&m.classList.add("active"),this.pickDate&&r===c&&s===d&&a===p&&m.classList.add("select"),m.innerText=`${p}`,m.onclick=I=>{const L=d-1;this.now=new Date(c,L,p),this._setDatePick(c,L,p),I.stopPropagation()},this.dom.day.append(m)}const T=42-h-u;for(let p=1;p<=T;p++){const m=document.createElement("div");m.classList.add("disable"),m.innerText=`${p}`,m.onclick=()=>{this.now=new Date(c,d,p),this._setDatePick(c,d,p)},this.dom.day.append(m)}}_toggleDateTimePicker(){this.isDatePicker?(this.dom.dateWrap.classList.add("active"),this.dom.timeWrap.classList.remove("active"),this.dom.menu.time.innerText=this.lang.timeSelect):(this.dom.dateWrap.classList.remove("active"),this.dom.timeWrap.classList.add("active"),this.dom.menu.time.innerText=this.lang.return,this._setTimePick())}_setDatePick(t,e,n){this.now=new Date(t,e,n),this.pickDate?.setFullYear(t),this.pickDate?.setMonth(e),this.pickDate?.setDate(n),this._update()}_setTimePick(t=!0){const e=this.pickDate?.getHours()||0,n=this.pickDate?.getMinutes()||0,i=this.pickDate?.getSeconds()||0,{hour:r,minute:s,second:a}=this.dom.time;[r,s,a].forEach(R=>{R.querySelectorAll("li").forEach(u=>u.classList.remove("active"))}),[[r,e],[s,n],[a,i]].forEach(([R,u])=>{const h=R.querySelector(`[data-id='${u}']`);h.classList.add("active"),t&&Zi(R,h)})}_preMonth(){this.now.setMonth(this.now.getMonth()-1),this._update()}_nextMonth(){this.now.setMonth(this.now.getMonth()+1),this._update()}_preYear(){this.now.setFullYear(this.now.getFullYear()-1),this._update()}_nextYear(){this.now.setFullYear(this.now.getFullYear()+1),this._update()}_now(){this.pickDate=new Date,this.dispose()}_toggleVisible(t){t?this.dom.container.classList.add("active"):this.dom.container.classList.remove("active")}_submit(){if(this.options.onSubmit&&this.pickDate){const t=this.renderOptions?.dateFormat,e=this.formatDate(this.pickDate,t);this.options.onSubmit(e)}}formatDate(t,e="YYYY-MM-DD HH:mm:ss"){let n=e;const i=t.getFullYear().toString(),r=(t.getMonth()+1).toString(),s=t.getDate().toString(),a=t.getHours(),c=a%12===0?12:a%12,d=t.getMinutes().toString(),R=t.getSeconds().toString(),u=t.getMilliseconds().toString(),h={"y+":i,"Y+":i,"M+":r,"d+":s,"D+":s,"h+":c.toString(),"H+":a.toString(),"m+":d,"s+":R,"S+":u};for(const g in h){const f=new RegExp("("+g+")").exec(e),T=g;f&&(n=n.replace(f[1],f[1].length===1?h[T]:h[T].padStart(f[1].length,"0")))}return n}render(t){this.renderOptions=t,this.lang=this._getLang(),this._setLangChange(),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}destroy(){this.dom.container.remove()}}class bn{draw;element;control;isPopup;datePicker;options;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:r,endIndex:s}=n;for(let a=r;a<=s;a++){const c=e[a];c.controlComponent===l.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...R,...t[h],controlComponent:l.ControlComponent.VALUE};Ut(i,[g],s,{editorOptions:this.options}),c.spliceElementList(i,u+h,0,[g])}return u+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=this.control.getValueRange(t);if(!r)return-1;const{startIndex:s,endIndex:a}=r;if(!~s||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,s+1,a-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(s,t),s}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),s=this.getValue(e)[0],a=s?Dt(s,Re):Dt(i[r.startIndex],Gt),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=ie(i[c],Re),R=c+1,u=this.control.getDraw();for(let h=0;h<t.length;h++){const g={...a,...d,type:l.ElementType.TEXT,value:t[h],controlComponent:l.ControlComponent.VALUE};(g.color===this.options.control.bracketColor||g.color===this.options.control.placeholderColor)&&(g.color=this.options.defaultColor),Ut(i,[g],c,{editorOptions:this.options}),u.spliceElementList(i,R+h,0,[g])}if(!e.range){const h=R+t.length-1;this.control.repaintControl({curIndex:h}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.control.getDraw();if(t.key===l.KeyMap.Backspace)return i!==r?(c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===l.KeyMap.Delete){if(i!==r)return c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i;{const d=e[r+1];return(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT)&&d.controlComponent===l.ControlComponent.PLACEHOLDER||d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POST_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getPosition();if(!t)return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n+1]?.controlId!==this.element.controlId)return;this.datePicker=new dr(this.draw,{onSubmit:this._setDate.bind(this)});const i=this.getValue().map(s=>s.value).join("")||"",r=this.element.control?.dateFormat;this.datePicker.render({value:i,position:t,dateFormat:r}),this.isPopup=!0}destroy(){this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}_setDate(t){t?this.setSelect(t):this.clearSelect(),this.destroy()}}class Vn extends Ci{isPopup;inputPopup;constructor(t,e){super(t,e),this.isPopup=!1,this.inputPopup=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(P=>!kl(P)||Qr.test(P.value)))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const s=at(t),{startIndex:a,endIndex:c}=r,d=i[a];let R=null;for(let P=a;P>=0;P--)if(i[P].controlComponent===l.ControlComponent.PREFIX){R=i[P];break}const u=R?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let P=a;for(;P>0;){const S=i[P];if(S.controlId!==d.controlId||S.controlComponent===l.ControlComponent.PREFIX||S.controlComponent===l.ControlComponent.PRE_TEXT)break;s.unshift(S),P--}let O=c+1;for(;O<i.length;){const S=i[O];if(S.controlId!==d.controlId||S.controlComponent===l.ControlComponent.POSTFIX||S.controlComponent===l.ControlComponent.POST_TEXT)break;s.push(S),O++}}const h=$i(s);if(Number.isNaN(Number(h))||!Number.isFinite(Number(h)))return-1;const g=u?.numberExclusiveOptions,f=g?.maxLength??null,T=g?.decimalPlaces??null,p=h.replace(/[.-]/g,"").length;if(f!=null&&p>f||T!=null&&(h.split(".")[1]||"").length>T)return-1;const m=Number(h),I=g?.minValue,L=g?.maxValue;return I!=null&&m<I||L!=null&&m>L?-1:super.setValue(t,e,n)}_setNumberValue(t){const e=this.control.getElementList(),n=this.control.getRange(),{startIndex:i}=n;let r=null;for(let F=i;F>=0;F--)if(e[F].controlComponent===l.ControlComponent.PREFIX){r=e[F];break}const a=(r?.control||this.element.control)?.numberExclusiveOptions,c=a?.minValue,d=a?.maxValue,R=a?.decimalPlaces,u=a?.minLength,h=a?.maxLength;let g=t;R!=null&&(g=parseFloat(t.toFixed(R)));const f=g.toString(),T=f.replace(/[.-]/g,"").length;if(u!=null&&T<u||h!=null&&T>h||c!=null&&g<c||d!=null&&g>d)return!1;let p=i;for(let F=i;F>=0;F--)if(e[F].controlComponent===l.ControlComponent.PREFIX){p=F;break}let m=p+1;for(let F=p+1;F<e.length;F++)if(e[F].controlComponent===l.ControlComponent.POSTFIX){m=F;break}const I=this.options.mode===l.EditorMode.FORM,L=I&&this.options.modeRule.form.inputTraceEnabled,P=I&&this.options.modeRule.form.deleteTraceEnabled,O=q(new Date).format("YYYY-MM-DD HH:mm:ss");if(P)for(let F=p+1;F<m;F++){const N=e[F];N.controlComponent===l.ControlComponent.VALUE&&!N.strikeout&&N.value&&(N.strikeout=!0,N.deletePerson="SYSTEM",N.deleteTime=O),N.controlComponent===l.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,F,1),m--,F--)}else{const F=p+1,N=m-F;N>0&&this.control.getDraw().spliceElementList(e,F,N),m=p+1}m=p+1;for(let F=p+1;F<e.length;F++)if(e[F].controlComponent===l.ControlComponent.POSTFIX){m=F;break}const S=[];for(let F=0;F<f.length;F++){const N={type:l.ElementType.TEXT,value:f[F],controlComponent:l.ControlComponent.VALUE,controlId:e[p].controlId};L&&(N.textDecoration={style:l.TextDecorationStyle.DOUBLE},N.underline=!0),S.push(N)}for(let F=0;F<S.length;F++)this.control.getDraw().spliceElementList(e,m+F,0,[S[F]]);return this.control.repaintControl({curIndex:m+S.length-1}),this.control.emitControlContentChange(),!0}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e,i=t[n];if(!i||i.controlId!==this.element.controlId)return;let r=null;for(let f=n;f>=0;f--)if(t[f].controlComponent===l.ControlComponent.PREFIX){r=t[f];break}const s=r?.control||this.element.control,c=this.getValue().filter(f=>!f.strikeout),d=c.length>0?$i(c):"",R=s?.numberExclusiveOptions,u=R?.minValue,h=R?.maxValue,g=R?.decimalPlaces;this.inputPopup=new gh({control:this.control,currentValue:d,minValue:u,maxValue:h,decimalPlaces:g,onConfirm:f=>{if(!f||f.trim()==="")return this._clearNumberValue(),!0;const T=parseFloat(f);return Number.isNaN(T)||!Number.isFinite(T)?!1:this._setNumberValue(T)},onClose:()=>{this.destroy()}}),this.inputPopup.create(),this.isPopup=!0}_clearNumberValue(){const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e;let i=n;for(let c=n;c>=0;c--)if(t[c].controlComponent===l.ControlComponent.PREFIX){i=c;break}let r=i+1;for(let c=i+1;c<t.length;c++)if(t[c].controlComponent===l.ControlComponent.POSTFIX){r=c;break}const s=i+1,a=r-s;a>0&&this.control.getDraw().spliceElementList(t,s,a),this.control.addPlaceholder(i),this.control.repaintControl({curIndex:i}),this.control.emitControlContentChange()}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,s=e[i],a=e[r],c=this.control.getDraw();if(t.key==="Backspace")return s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||s.controlComponent===l.ControlComponent.PLACEHOLDER?this.control.removeControl(i):a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT?i:i!==r?(c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key==="Delete"){const R=e[r+1];return s.controlComponent===l.ControlComponent.PLACEHOLDER||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT?this.control.removeControl(i):s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRE_TEXT||R?.controlComponent===l.ControlComponent.POSTFIX||R?.controlComponent===l.ControlComponent.POST_TEXT?r:i!==r?(c.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}return t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey?(t.preventDefault(),this.awake(),null):r}destroy(){this.inputPopup&&(this.inputPopup.destroy(),this.inputPopup=null),this.isPopup=!1}}class gh{options;popupDom;constructor(t){this.options=t,this.popupDom=null}create(){const{currentValue:t,minValue:e,maxValue:n,decimalPlaces:i,onConfirm:r,onClose:s}=this.options,a=document.createElement("div");a.classList.add(`${z}-number-input-modal`),a.setAttribute(de,l.EditorComponent.POPUP);const c=document.createElement("div");c.classList.add(`${z}-number-input-modal__content`);const d=document.createElement("div");if(d.classList.add(`${z}-number-input-modal__title`),d.textContent="请输入数值",c.appendChild(d),e!==void 0||n!==void 0){const p=document.createElement("div");p.classList.add(`${z}-number-input-modal__hint`);let m="有效范围:";e!==void 0&&n!==void 0?m+=`${e} ~ ${n}`:e!==void 0?m+=`≥ ${e}`:m+=`≤ ${n}`,i!=null&&(m+=`,保留${i}位小数`),p.textContent=m,c.appendChild(p)}const R=document.createElement("input");R.classList.add(`${z}-number-input-modal__input`),R.type="number",R.value=t,R.placeholder="请输入数值",e!==void 0&&(R.min=String(e)),n!==void 0&&(R.max=String(n)),i!=null&&(R.step=(1/Math.pow(10,i)).toString()),setTimeout(()=>{R.focus(),R.select()},100),c.appendChild(R);const u=document.createElement("div");u.classList.add(`${z}-number-input-modal__error`),u.style.display="none",c.appendChild(u);const h=document.createElement("div");h.classList.add(`${z}-number-input-modal__buttons`);const g=document.createElement("button");g.classList.add(`${z}-number-input-modal__cancel`),g.textContent="取消",g.onclick=()=>{s()},h.appendChild(g);const f=document.createElement("button");f.classList.add(`${z}-number-input-modal__confirm`),f.textContent="确定",f.onclick=()=>{const p=R.value.trim();if(!p){r("")&&s();return}const m=parseFloat(p);if(Number.isNaN(m)||!Number.isFinite(m)){u.textContent="请输入有效的数值",u.style.display="block";return}if(i!=null&&(p.split(".")[1]||"").length>i){u.textContent=`小数位数不能超过${i}位`,u.style.display="block";return}if(e!==void 0&&m<e){u.textContent=`数值不能小于 ${e}`,u.style.display="block";return}if(n!==void 0&&m>n){u.textContent=`数值不能大于 ${n}`,u.style.display="block";return}r(p)&&s()},h.appendChild(f),c.appendChild(h),a.appendChild(c),R.onkeydown=p=>{p.key==="Enter"?f.click():p.key==="Escape"&&s()},this.options.control.getContainer().appendChild(a),this.popupDom=a}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class fh{options;mask;container;inputList;optionItemContainers;data;constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this.optionItemContainers=[],this.data=t.data,this._render()}_getFieldValue(t){const e=this.inputList.filter(n=>n.name===t);if(e.length!==0){for(const n of e)if(n instanceof HTMLInputElement&&n.type==="radio"&&n.checked)return n.value;return e[0].value}}_updateFieldVisibility(){this.data.forEach((t,e)=>{if(t.visibleWhen){const{field:n,value:i}=t.visibleWhen,r=this._getFieldValue(n),s=this.optionItemContainers[e];if(s){const a=r===i;s.style.display=a?"":"none"}}})}_render(){const{title:t,onClose:e,onCancel:n,onConfirm:i}=this.options,r=document.createElement("div");r.classList.add("dialog-mask"),r.setAttribute(de,l.EditorComponent.COMPONENT),document.body.append(r);const s=document.createElement("div");s.classList.add("dialog-container"),s.setAttribute(de,l.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),s.append(a);const c=document.createElement("div");c.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const R=document.createElement("i");R.onclick=()=>{e&&e(),this._dispose()},c.append(d),c.append(R),a.append(c);const u=document.createElement("div");u.classList.add("dialog-option");for(let T=0;T<this.data.length;T++){const p=this.data[T],m=document.createElement("div");if(m.classList.add("dialog-option__item"),p.visible===!1&&(m.style.display="none"),p.label){const I=document.createElement("span");I.append(document.createTextNode(p.label)),m.append(I),p.required&&I.classList.add("dialog-option__item--require")}if(p.type==="radio"){const I=document.createElement("div");I.classList.add("dialog-radio-group"),p.horizontal&&I.classList.add("dialog-radio-group--horizontal"),p.options?.forEach(L=>{const P=document.createElement("label");P.classList.add("dialog-radio-item");const O=document.createElement("input");O.type="radio",O.name=p.name,O.value=L.value,L.value===(p.value||"")&&(O.checked=!0);const S=document.createElement("span");S.textContent=L.label,P.append(O),P.append(S),I.append(P),O.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(O)}),m.append(I)}else if(p.type==="select"){const I=document.createElement("select"),L=p.value||"";p.options?.forEach(P=>{const O=document.createElement("option");O.value=P.value,O.label=P.label,P.value===L&&(O.selected=!0),I.append(O)}),I.name=p.name,I.value=L,I.addEventListener("change",()=>{this._updateFieldVisibility()}),p.width&&(I.style.width=`${p.width}px`),m.append(I),this.inputList.push(I)}else if(p.type==="textarea"){const I=document.createElement("textarea");I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),m.append(I),this.inputList.push(I)}else{const I=document.createElement("input");I.type=p.type,I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),m.append(I),this.inputList.push(I)}u.append(m),this.optionItemContainers.push(m)}a.append(u);const h=document.createElement("div");h.classList.add("dialog-menu");const g=document.createElement("button");g.classList.add("dialog-menu__cancel"),g.append(document.createTextNode("取消")),g.type="button",g.onclick=()=>{n&&n(),this._dispose()},h.append(g);const f=document.createElement("button");f.append(document.createTextNode("确定")),f.type="submit",f.onclick=()=>{if(i){const T=new Set,p=[];for(const m of this.inputList)if(!T.has(m.name))if(m instanceof HTMLInputElement&&m.type==="radio"){const I=this.inputList.find(L=>L.name===m.name&&L instanceof HTMLInputElement&&L.checked);I&&(p.push({name:m.name,value:I.value}),T.add(m.name))}else p.push({name:m.name,value:m.value}),T.add(m.name);i(p)}this._dispose()},h.append(f),a.append(h),document.body.append(s),this.container=s,this.mask=r,this._updateFieldVisibility()}_dispose(){this.mask?.remove(),this.container?.remove()}}class ke{draw;element;control;isPopup;datePicker;options;range;static isDeleting=!1;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.range=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(){return[]}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e),s=this.control.getDraw(),{startIndex:a}=r,d=i[a].controlId;let R=a;for(let m=a;m>=0;m--){const I=i[m];if(I.controlId!==d)break;if(I.controlComponent===l.ControlComponent.PREFIX){R=m;break}}let u=a;for(let m=a;m<i.length;m++){const I=i[m];if(I.controlId!==d){u=m;break}if(I.controlComponent===l.ControlComponent.POSTFIX){u=m;break}}const h=R+1,g=u-1;g>=h&&s.spliceElementList(i,h,g-h+1);const f=i[R],T=Dt(f,["control","controlId",...Gt]),p=R+1;for(let m=0;m<t.length;m++){const I={...T,...t[m],controlComponent:l.ControlComponent.VALUE};I.color="#fff",I.highlight="#1677FF",Ut(i,[I],R,{editorOptions:this.options}),s.spliceElementList(i,p+m,0,[I])}return p+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=this.control.getValueRange(t);if(!r)return-1;const{startIndex:s,endIndex:a}=r;if(!~s||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,s+1,a-s,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(s,t),s}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{endIndex:i}=n,r=e[i];return!!r?.originControlId&&!!r?.controlId&&r.originControlId!==r.controlId&&r.control?.type===l.ControlType.BUTTON&&!r.control?.buttonText&&(t.key===l.KeyMap.Backspace||t.key===l.KeyMap.Delete)?this.control.removeControl(i):r?.controlComponent==="value"&&r.control?.type==="button"&&r.control?.buttonText?t.key===l.KeyMap.Backspace||t.key===l.KeyMap.Delete?(r.controlId&&this.removeByValue(e,r.controlId),i):null:(t.key===l.KeyMap.Backspace&&r?.controlComponent==="value"&&r.control?.type==="button"&&!r.control?.buttonText,null)}removeByValue(t,e){return ke.isDeleting=!0,new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text")&&t[c].controlId===e&&t.splice(c,1);const{startIndex:i,endIndex:r}=this.range.getRange(),s=!0,a=r;this.draw.render({curIndex:a,isSetCursor:s}),setTimeout(()=>{ke.isDeleting=!1},300),n(!0)})}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl()||ke.isDeleting||!this.control.getPosition())return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n]?.controlId!==this.element?.controlId)return;const i=this.control.getDraw().getPosition().getPositionContext();if(!i.isDirectHit||i.index!==n||e[i.index]?.controlId!==this.element?.controlId)return;const r=e[n]?.controlId,s=e[n]?.control;if(!(r?.endsWith("_text")||s?.buttonText)){if(this.options.mode=="form"){const a=e[n].controlId;if(!a)return;const c=e.filter(d=>d.controlId==a);c[0].control.buttonText||this.showInputModal(c)}else if(this.options.mode=="edit"){const a=e[n].controlId,c=e.filter(d=>d.controlId==a);this.showEditModal(c)}}}showInputModal(t){if(this.inputModal){this.closeInputModal();return}this.isPopup=!0,this.inputModal=document.createElement("div"),this.inputModal.classList.add(`${z}-button-input-modal`),this.inputModal.setAttribute(de,l.EditorComponent.POPUP),this.inputModal.oncontextmenu=c=>{c.preventDefault(),c.stopPropagation()};const e=document.createElement("div");e.classList.add(`${z}-button-input-modal__content`),e.oncontextmenu=c=>{c.preventDefault(),c.stopPropagation()};const n=document.createElement("div");n.classList.add(`${z}-button-input-modal__title`),n.innerText="请输入按钮展开文字(用逗号分隔)";const i=document.createElement("textarea");i.classList.add(`${z}-button-input-modal__textarea`),i.placeholder="例如:选项1,选项2,选项3",i.rows=5;const r=document.createElement("div");r.classList.add(`${z}-button-input-modal__buttons`);const s=document.createElement("button");s.classList.add(`${z}-button-input-modal__cancel`),s.innerText="取消",s.onclick=()=>this.closeInputModal();const a=document.createElement("button");a.classList.add(`${z}-button-input-modal__confirm`),a.innerText="确认",a.onclick=()=>{const c=i.value.trim();if(c){const d=c.split(/[,,]/).map((R,u)=>({value:R.trim(),code:String(u+1)})).filter(R=>R.value);if(d.length>0&&t[0]?.controlId){const R={controlId:t[0].controlId,element:[{...t[0],newButtonValue:d}]};this.draw.getCommand().executeButton(R)}}this.closeInputModal()},r.appendChild(s),r.appendChild(a),e.appendChild(n),e.appendChild(i),e.appendChild(r),this.inputModal.appendChild(e),this.draw.getContainer().appendChild(this.inputModal),setTimeout(()=>i.focus(),100),this.inputModal.onclick=c=>{c.target===this.inputModal&&this.closeInputModal()}}closeInputModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}showEditModal(t){const e=t[0]?.control||{},n=e.buttonLabel||e.label||"按钮",i=e.code||"";this.isPopup=!0,new fh({title:"修改按钮属性",data:[{type:"text",label:"按钮标签",name:"buttonLabel",required:!0,placeholder:"请输入按钮标签",value:n},{type:"text",label:"按钮代码",name:"code",placeholder:"请输入按钮代码",value:i}],onClose:()=>{this.isPopup=!1},onCancel:()=>{this.isPopup=!1},onConfirm:r=>{const s=r.find(h=>h.name==="buttonLabel")?.value?.trim()||"按钮",a=r.find(h=>h.name==="code")?.value?.trim()||"",c=this.control.getElementList(),d=t[0]?.controlId;if(d)for(let h=0;h<c.length;h++){const g=c[h];g.controlId===d&&g.control&&(g.control.buttonLabel=s,g.control.label=s,g.control.code=a)}const R=[];for(let h=0;h<s.length;h++)R.push({value:s[h],controlComponent:l.ControlComponent.VALUE});const u=this.setValue(R);u!==-1&&this.control.repaintControl({curIndex:u}),this.isPopup=!1}})}destroy(){this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}}class Rr{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),r=t?null:i.getTd();n>=e.length&&(n=e.length-1);const s=e[n],a=[];let c=r;if(s.controlComponent===l.ControlComponent.PRETEXTFIX||s.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let f=n+1;for(;f<e.length;){const T=e[f];if(T.controlId!==s.controlId||T.controlComponent!==l.ControlComponent.PRETEXTFIX&&T.controlComponent!==l.ControlComponent.PRETEXTFIX_TEXT){n=f-1;break}f++}}let d=e,R=n;for(;;){if(R<0&&c?.linkTdPrevId){const T=i.getTdById(c.linkTdPrevId);if(T){d=T.value,R=d.length-1,c=T;continue}}if(R<0)break;const f=d[R];if(f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.PRETEXTFIX||f.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||f.controlComponent===l.ControlComponent.TEXTFIXLABEL)break;f.controlComponent===l.ControlComponent.VALUE&&a.unshift(f),R--}c=r;let u=e,h=n+1;for(;;){if(h>=u.length&&c?.linkTdNextId){const T=i.getTdById(c.linkTdNextId);if(T){u=T.value,h=0,c=T;continue}}const f=u[h];if(!f||f.controlId!==s.controlId||f.controlComponent===l.ControlComponent.POSTTEXTFIX||f.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||f.controlComponent===l.ControlComponent.TEXTFIXLABEL)break;f.controlComponent===l.ControlComponent.VALUE&&a.push(f),h++}return a.filter(f=>f.type!==l.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(this.options.mode===l.EditorMode.FORM||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:s,endIndex:a}=r,c=this.control.getDraw();s!==a?c.spliceElementList(i,s+1,a-s,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(s,{elementList:i});const d=i[s],R=i[s+1];let u=d.originControlId||d.controlId,h=d.originControlId&&(d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT);if(!h&&d.controlId&&(d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT)&&R?.controlId&&R.controlId!==d.controlId)if(R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX)for(let m=s;m>=0;m--){const I=i[m];if(I.controlId===d.controlId&&(I.controlComponent===l.ControlComponent.PREFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let L=m-1;L>=0;L--){const P=i[L];if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.PRETEXTFIX||P.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===l.ControlComponent.PREFIX||P.controlComponent===l.ControlComponent.PRE_TEXT)){u=P.controlId,h=!0;break}if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.POSTFIX||P.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}else(R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POSTTEXTFIX)&&(u=R.controlId,h=!0);if(!h&&d.controlId&&(d.controlComponent===l.ControlComponent.POSTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX||d.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===l.ControlComponent.POST_TEXT))for(let m=s;m>=0;m--){const I=i[m];if(I.controlId===d.controlId&&(I.controlComponent===l.ControlComponent.PREFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let L=m-1;L>=0;L--){const P=i[L];if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.PRETEXTFIX||P.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===l.ControlComponent.PREFIX||P.controlComponent===l.ControlComponent.PRE_TEXT)){u=P.controlId,h=!0;break}if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===l.ControlComponent.POSTFIX||P.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}const g=d.type&&!$t.includes(d.type)||d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT?Dt(d,["control","controlId",...Gt]):ie(d,["type"]);h&&(g.controlId=u,delete g.originControlId);const f=r.startIndex+1,T=[],p=m=>{const I=T.length?T:i,L=T.length?T.length-1:r.startIndex;Ut(I,[m],L,{editorOptions:this.options}),T.push(m)};for(let m=0;m<t.length;m++){const I=t[m];if(I.type===l.ElementType.CONTROL&&I.control){const L=I,P=L.controlId||lt(),O=L.control?.value||[],S=L.control?.type===l.ControlType.TEXTFIELD,F={...g,controlId:P,type:l.ElementType.CONTROL,control:L.control,originControlId:u},N=S?l.ControlComponent.PRETEXTFIX:l.ControlComponent.PREFIX,V=S?l.ControlComponent.POSTTEXTFIX:l.ControlComponent.POSTFIX,Y=S?L.control?.preTextFix||this.options.control.preTextFix:L.control?.prefix||this.options.control.prefix;for(let b=0;b<Y.length;b++){const E={...F,value:Y[b],controlComponent:N};p(E)}for(let b=0;b<O.length;b++){const E=O[b],C={...F,...E,controlComponent:l.ControlComponent.VALUE,type:E.type};(C.color===this.options.control.textFixColor||C.color===this.options.control.placeholderColor)&&(C.color=this.options.defaultColor),p(C)}if(O.length===0){const b=L.control?.placeholder||"";for(let E=0;E<b.length;E++){const C={...F,value:b[E],controlComponent:l.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};p(C)}}const X=S?L.control?.postTextFix||this.options.control.postTextFix:L.control?.postfix||this.options.control.postfix;for(let b=0;b<X.length;b++){const E={...F,value:X[b],controlComponent:V};p(E)}}else if(I.type||I.value){g.color=this.options.defaultColor;const L={...g,...I,controlComponent:l.ControlComponent.VALUE};(L.color===this.options.control.textFixColor||L.color===this.options.control.placeholderColor)&&(L.color=this.options.defaultColor),p(L)}}return T.length&&c.spliceElementList(i,f,0,T),r.startIndex+T.length}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:r,endIndex:s}=i;return this.control.getDraw().spliceElementList(n,r+1,s-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(r,t)),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange(),i=n.startIndex,r=n.endIndex;if(t.key===l.KeyMap.Backspace&&i===r&&i>0){const p=e[i-1],m=p?.controlComponent===l.ControlComponent.POSTFIX||p?.controlComponent===l.ControlComponent.POSTTEXTFIX,I=p?.controlComponent===l.ControlComponent.PLACEHOLDER,L=!!p?.controlId,O=this.draws.getPosition().getPositionList(),S=O[i],F=O[i-1],N=S&&F&&S.rowIndex===F.rowIndex;if((m||I)&&L&&N)return this.control.removeControl(i-1)}this.control.shrinkBoundary();const{startIndex:s,endIndex:a}=n,c=e[s],d=this.control.getDraw(),R=e[a+1],u=!!c?.originControlId&&!!c?.controlId&&c.originControlId!==c.controlId,h=u&&(c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRE_TEXT||c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.POSTFIX||c.controlComponent===l.ControlComponent.POST_TEXT||c.controlComponent===l.ControlComponent.POSTTEXTFIX||c.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PLACEHOLDER||c.controlComponent===l.ControlComponent.TEXTFIXLABEL),g=u&&c.control?.type===l.ControlType.BUTTON&&c.controlComponent===l.ControlComponent.VALUE,f=!!R?.originControlId&&!!R?.controlId&&R.originControlId!==R.controlId&&(R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT||R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||R.controlComponent===l.ControlComponent.PLACEHOLDER||R.controlComponent===l.ControlComponent.TEXTFIXLABEL),T=!!R?.originControlId&&!!R?.controlId&&R.originControlId!==R.controlId&&R.control?.type===l.ControlType.BUTTON;if(t.key===l.KeyMap.Backspace){if(s===a&&(h||g))return this.control.removeControl(s);if(this.options.mode===l.EditorMode.FORM)this.strikeout();else return s!==a?e.slice(s,a+1).some(I=>I.controlComponent===l.ControlComponent.POSTTEXTFIX||I.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)?s:(d.spliceElementList(e,s+1,a-s),this.getValue().length||this.control.addPlaceholder(s),s===0&&e[0].type===l.ElementType.SPLIT_TAG?d.fixPosition(!0)??s:s):c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.POSTTEXTFIX||c.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===l.ControlComponent.TEXTFIXLABEL||c.controlComponent===l.ControlComponent.PLACEHOLDER?s:(d.spliceElementList(e,s,1),this.getValue().length||this.control.addPlaceholder(s-1),s===1&&e[0].type===l.ElementType.SPLIT_TAG||s===0?d.fixPosition(!0)??s-1:s-1)}else if(t.key===l.KeyMap.Delete){if(s===a&&(h||g))return this.control.removeControl(s);if(s===a&&(f||T))return this.control.removeControl(a+1);if(this.options.mode===l.EditorMode.FORM)this.strikeout();else return s!==a?(d.spliceElementList(e,s+1,a-s),this.getValue().length||this.control.addPlaceholder(s),s===0&&e[0].type===l.ElementType.SPLIT_TAG?d.fixPosition(!0)??s:s):(R||d.getTd()?.linkTdNextId&&c.controlId&&this.removeNextControlElement(c.controlId),R&&((c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)&&(R.controlComponent===l.ControlComponent.PLACEHOLDER||R.controlComponent===l.ControlComponent.TEXTFIXLABEL)||R.controlComponent===l.ControlComponent.POSTTEXTFIX||R.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PLACEHOLDER||c.controlComponent===l.ControlComponent.TEXTFIXLABEL)?s:(d.spliceElementList(e,s+1,1),this.getValue().length||this.control.addPlaceholder(s),s===0&&e[0].type===l.ElementType.SPLIT_TAG?d.fixPosition(!0)??s:s))}return a}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}strikeout(t,e={},n={}){const{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return;const s=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=q(new Date).format("YYYY-MM-DD HH:mm:ss");if(s?.length){if(!this.element.strikeout){const d=s.findIndex(R=>!R.strikeout);s.forEach(R=>{R.deletePerson="SWJ",R.deleteTime=c,R.strikeout=!!~d}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),setTimeout(()=>{this.strikeoute()},100)}}else{const d=this.control.getElementList()[a.index];if(!this.control.getElementList()[a.index].strikeout&&d?.metrics.width>0){this.control.getElementList()[a.index].strikeout=!0,this.control.getElementList()[a.index].deletePerson="SWJ",this.control.getElementList()[a.index].deleteTime=c;const R=--a.index;setTimeout(()=>{this.strikeoute()},100),setTimeout(()=>{const h=R;this.draws.render({curIndex:h,isSetCursor:!0}),a.index=R,this.position.setCursorPosition(a),this.ranges.setRange(R,R)},100)}else{const{elementList:R,range:u}=this.control.mergeControl(n),h=u.startIndex;if(h>=0&&h<R.length&&R[h]?.metrics?.width!==void 0&&R[h].metrics.width<=0&&!R[h]?.strikeout){this.draws.spliceElementList(R,u.startIndex,1,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule});const g=!0,f=u.startIndex-1;this.draws.render({curIndex:f,isSetCursor:g}),a.index=f,delete a.value,this.position.setCursorPosition(a),this.ranges.setRange(f,f)}}}}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:r}=this.ranges.getRange(),a=this.draws.getElementList()[r];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}const Th={indent:" ",divider:"────────────────"};class ur{draw;element;control;options;isPopup;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:r,endIndex:s}=n;for(let a=r;a<=s;a++){const c=e[a];c.controlComponent===l.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:r}=this.control.mergeControl(e),s=this.control.getDraw(),{startIndex:a}=r,d=i[a].controlId;let R=a;for(let m=a;m>=0;m--){const I=i[m];if(I.controlId!==d)break;if(I.controlComponent===l.ControlComponent.PREFIX){R=m;break}}let u=a;for(let m=a;m<i.length;m++){const I=i[m];if(I.controlId!==d){u=m;break}if(I.controlComponent===l.ControlComponent.POSTFIX){u=m;break}}const h=R+1,g=u-1;g>=h&&s.spliceElementList(i,h,g-h+1);const f=i[R],T=Dt(f,["control","controlId",...Gt]),p=R+1;for(let m=0;m<t.length;m++){const I={...T,...t[m],value:t[m].value===`
|
|
105
105
|
`?_:t[m].value,controlComponent:l.ControlComponent.VALUE};(I.color===this.options.control.bracketColor||I.color===this.options.control.placeholderColor)&&(I.color=this.options.defaultColor),Ut(i,[I],R,{editorOptions:this.options}),s.spliceElementList(i,p+m,0,[I])}return p+t.length-1}keydown(t){if(this.control.getIsDisabledControl()||this.options.mode===l.EditorMode.FORM)return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i}=n,r=e[i];if(t.key===l.KeyMap.Backspace||t.key===l.KeyMap.Delete){const s=r.controlId;let a=i,c=i;for(;a>0&&e[a-1].controlId===s;)a--;for(;c<e.length-1&&e[c+1].controlId===s;)c++;return this.draw.spliceElementList(e,a,c-a+1),a>0?a-1:0}return null}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.options.mode===l.EditorMode.PRINT||this.isPopup||this.control.getIsDisabledControl())return;let t=!1;const e=this.control.getElementList(),n=this.element.controlId;for(let i=0;i<e.length;i++){const r=e[i];r.controlId===n&&r.control&&r.control._justCreated&&(t=!0,delete r.control._justCreated)}t||this.showMenstrualHistoryDialog()}generateDisplayText(t){const{indent:e,divider:n}=Th,{isMenopause:i,periodMin:r,periodMax:s,menarcheAge:a,cycleMin:c,cycleMax:d}=t,R=`${e}月经持续${r}~${s}天`,u=`${e}生理周期持续${c}~${d}天${_}`;let h;return i?h=`初潮年龄${a}岁${n}闭经年龄${t.menopauseAge||"_"}岁`:h=`初潮年龄${a}岁${n}末次日期${t.lastPeriod||"____-__-__"}`,`${_} ${R}
|
|
106
106
|
${h}
|
|
107
107
|
${u} `}textToElements(t){const e=[],n=t.split(`
|
|
@@ -181,8 +181,8 @@ ${u} `}textToElements(t){const e=[],n=t.split(`
|
|
|
181
181
|
<button class="btn-confirm">确认</button>
|
|
182
182
|
</div>
|
|
183
183
|
</div>
|
|
184
|
-
`,document.body.appendChild(this.inputModal);const e=this.inputModal.querySelector(".menstrual-history-modal__mask"),n=this.inputModal.querySelector(".menstrual-history-modal__container"),i=this.inputModal.querySelector(".menstrual-history-modal__close"),r=this.inputModal.querySelector(".btn-cancel"),s=this.inputModal.querySelector(".btn-confirm"),a=this.inputModal.querySelector("#mh-edit-notMenopause"),c=this.inputModal.querySelector("#mh-edit-isMenopauseForm"),d=this.inputModal.querySelectorAll('input[name="mh-edit-isMenopause"]'),R=()=>{this.closeModal()};n.addEventListener("click",u=>{u.stopPropagation()}),e.addEventListener("click",R),i.addEventListener("click",R),r.addEventListener("click",R),d.forEach(u=>{u.addEventListener("change",()=>{const h=u.value==="true";a.style.display=h?"none":"block",c.style.display=h?"block":"none"})}),s.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation();const h=this.inputModal;if(!h)return;const g=h.querySelector('input[name="mh-edit-isMenopause"]:checked')?.value==="true";let f;g?f={isMenopause:!0,periodMin:h.querySelector("#mh-edit-periodMin2")?.value||"_",periodMax:h.querySelector("#mh-edit-periodMax2")?.value||"_",menarcheAge:h.querySelector("#mh-edit-menarcheAge2")?.value||"_",menopauseAge:h.querySelector("#mh-edit-menopauseAge")?.value||"_",cycleMin:h.querySelector("#mh-edit-cycleMin2")?.value||"_",cycleMax:h.querySelector("#mh-edit-cycleMax2")?.value||"_"}:f={isMenopause:!1,periodMin:h.querySelector("#mh-edit-periodMin")?.value||"_",periodMax:h.querySelector("#mh-edit-periodMax")?.value||"_",menarcheAge:h.querySelector("#mh-edit-menarcheAge1")?.value||"_",lastPeriod:h.querySelector("#mh-edit-lastPeriod")?.value||"____-__-__",cycleMin:h.querySelector("#mh-edit-cycleMin")?.value||"_",cycleMax:h.querySelector("#mh-edit-cycleMax")?.value||"_"};const T=this.control.getElementList(),p=this.element.controlId;for(let P=0;P<T.length;P++){const O=T[P];O.controlId===p&&O.control&&(O.control.menstrualData=f)}const m=this.generateDisplayText(f),I=this.textToElements(m);this.closeModal();const L=this.setValue(I);L!==-1&&(this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({}))})}closeModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}destroy(){this.closeModal()}}class mh{controlBorder;textFieldUnderline;draw;range;listener;eventBus;controlSearch;options;controlOptions;activeControl;activeControlValue;preElement;constructor(t){this.controlBorder=new hc(t),this.textFieldUnderline=new ph(t),this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.controlSearch=new uc(this),this.options=t.getOptions(),this.controlOptions=this.options.control,this.activeControl=null,this.activeControlValue=[],this.preElement=null}setHighlightList(t){this.controlSearch.setHighlightList(t)}computeHighlightList(){this.controlSearch.getHighlightList().length&&this.controlSearch.computeHighlightList()}renderHighlightList(t,e){this.controlSearch.getHighlightMatchResult().length&&this.controlSearch.renderHighlightList(t,e)}getDraw(){return this.draw}filterAssistElement(t){return t.filter((e,n)=>{if(e.type===l.ElementType.TABLE){const i=e.trList;for(let r=0;r<i.length;r++){const s=i[r];for(let a=0;a<s.tdList.length;a++){const c=s.tdList[a];c.value=this.filterAssistElement(c.value)}}}if(!e.controlId)return!0;if(e.control?.type===l.ControlType.MENSTRUAL_HISTORY&&this.options.mode===l.EditorMode.PRINT&&(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)||e.control?.type===l.ControlType.SELECT&&this.options.mode===l.EditorMode.PRINT&&(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)||e.control?.type===l.ControlType.NUMBER&&this.options.mode===l.EditorMode.PRINT&&(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)||e.control?.type===l.ControlType.TEXT&&this.options.mode===l.EditorMode.PRINT&&e.strikeout&&e.deletePerson)return!1;if(e.control?.minWidth){if(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)return e.value="",!0}else{const i=this.options.mode===l.EditorMode.FORM;if(e.control?.preText&&e.controlComponent===l.ControlComponent.PRE_TEXT){if(i)return!0;let r=!1,s=n+1;for(;s<t.length;){const a=t[s];if(e.controlId!==a.controlId)break;if(a.controlComponent===l.ControlComponent.VALUE){r=!0;break}s++}return r}if(e.control?.postText&&e.controlComponent===l.ControlComponent.POST_TEXT){if(i)return!0;let r=!1,s=n-1;for(;s<t.length;){const a=t[s];if(e.controlId!==a.controlId)break;if(a.controlComponent===l.ControlComponent.VALUE){r=!0;break}s--}return r}}if(e.control?.preTextFix&&e.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){let i=!1,r=n+1;for(;r<t.length;){const s=t[r];if(e.controlId!==s.controlId)break;if(s.controlComponent===l.ControlComponent.VALUE){i=!0;break}r++}return i}if(e.control?.postTextFix&&e.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){let i=!1,r=n-1;for(;r<t.length;){const s=t[r];if(e.controlId!==s.controlId)break;if(s.controlComponent===l.ControlComponent.VALUE){i=!0;break}r--}return i}return e.controlComponent!==l.ControlComponent.PREFIX&&e.controlComponent!==l.ControlComponent.POSTFIX&&e.controlComponent!==l.ControlComponent.PLACEHOLDER&&e.controlComponent!==l.ControlComponent.PRETEXTFIX&&e.controlComponent!==l.ControlComponent.POSTTEXTFIX&&e.controlComponent!==l.ControlComponent.TEXTFIXLABEL})}getIsRangeCanCaptureEvent(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),i=n[t];if(i.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;if(t===e&&t>0){const s=n[t-1],a=s?.controlComponent===l.ControlComponent.POSTFIX||s?.controlComponent===l.ControlComponent.POSTTEXTFIX,c=s?.controlComponent===l.ControlComponent.PLACEHOLDER,d=!!s?.controlId,R=!!s?.originControlId;let u=!1;if(R){const m=s.originControlId;for(let I=t;I<n.length;I++){const L=n[I];if(L.controlId===m&&!L.originControlId){u=!0;break}if(L.controlId&&L.controlId!==m&&L.originControlId!==m)break}}const g=this.draw.getPosition().getPositionList(),f=g[t],T=g[t-1],p=f&&T&&f.rowIndex===T.rowIndex;if((a||c)&&d&&p&&!u)return!1}if(t===e&&(i.controlComponent===l.ControlComponent.POSTFIX||i.controlComponent===l.ControlComponent.POSTTEXTFIX))return!0;const r=n[e];return!!(i.controlId&&i.controlId===r.controlId&&r.controlComponent!==l.ControlComponent.POSTFIX&&r.controlComponent!==l.ControlComponent.POSTTEXTFIX)}getIsRangeInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(t!==e)return!1;const i=this.getElementList()[t];return i.controlComponent===l.ControlComponent.POSTFIX||i.controlComponent===l.ControlComponent.POSTTEXTFIX}getIsRangeWithinControl(){const{range:{startIndex:t,endIndex:e},elementList:n}=this.range.getRangeElement();if(!~t&&!~e)return!1;const i=n[t],r=n[e];if(i?.controlId&&i.controlId===r.controlId&&r.controlComponent!==l.ControlComponent.POSTFIX&&r.controlComponent!==l.ControlComponent.POSTTEXTFIX&&r.controlComponent!==l.ControlComponent.POSTTEXTFIX_TEXT&&r.controlComponent!==l.ControlComponent.POST_TEXT)return!0;if(r?.originControlId&&(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)){const s=r.originControlId;for(let a=e+1;a<n.length;a++){const c=n[a];if(c.controlId===s)return!0;if(c.controlId&&c.controlId!==s&&c.originControlId!==s)break}}if(!r?.originControlId&&r?.controlId&&(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)){const s=n[e+1];if(s?.controlId&&s.controlId!==r.controlId&&(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRETEXTFIX))return!0;if(s?.controlId&&s.controlId!==r.controlId&&(s.controlComponent===l.ControlComponent.POSTFIX||s.controlComponent===l.ControlComponent.POSTTEXTFIX))return s.originControlId,!0;for(let a=e;a>=0;a--){const c=n[a];if(c.controlId===r.controlId&&(c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let d=a-1;d>=0;d--){const R=n[d];if(R.controlId&&R.controlId!==r.controlId&&(R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT))return!0;if(R.controlId&&R.controlId!==r.controlId&&(R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}}if(r?.originControlId){const s=r.originControlId;for(let a=e+1;a<n.length;a++){const c=n[a];if(c.controlId===s)return!0;if(c.controlId&&c.controlId!==s&&c.originControlId!==s)break}}if(!i?.controlId&&this.activeControl){const a=this.activeControl.getElement()?.controlId;if(a)for(let c=t;c>=0;c--){const d=n[c];if(d.controlId===a&&!d.originControlId){if(d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT)for(let R=e;R<n.length;R++){const u=n[R];if(u.controlId===a&&!u.originControlId){if(u.controlComponent===l.ControlComponent.POSTTEXTFIX||u.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||u.controlComponent===l.ControlComponent.POSTFIX||u.controlComponent===l.ControlComponent.POST_TEXT)return!0;break}}break}}}return!1}getIsElementListContainFullControl(t){if(!t.some(i=>i.controlId))return!1;let e=0,n=0;for(let i=0;i<t.length;i++){const r=t[i];r.controlComponent===l.ControlComponent.PREFIX||r.controlComponent===l.ControlComponent.PRETEXTFIX?e++:(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)&&n++}return!e||!n?!1:e===n}getIsDisabledControl(t={}){if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();if(e===n&&~e&&~n){const r=(t.elementList||this.getElementList())[e];if(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)return!1}return!!this.activeControl.getElement()?.control?.disabled}getIsDisabledPasteControl(t={}){if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();return e===n&&~e&&~n&&(t.elementList||this.getElementList())[e].controlComponent===l.ControlComponent.POSTFIX?!1:!!this.activeControl.getElement()?.control?.pasteDisabled}getIsExistValueByElementListIndex(t,e){const n=t[e];if(!n.controlId)return!1;if(n.control?.type===l.ControlType.CHECKBOX||n.control?.type===l.ControlType.RADIO)return!!n.control?.code;if(n.controlComponent===l.ControlComponent.VALUE)return!0;if(n.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;if(n.controlComponent===l.ControlComponent.PREFIX||n.controlComponent===l.ControlComponent.PRE_TEXT){let i=e+1;for(;i<t.length;){const r=t[i];if(r.controlId!==n.controlId)return!1;if(r.controlComponent===l.ControlComponent.VALUE)return!0;if(r.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;i++}}if(n.controlComponent===l.ControlComponent.PRETEXTFIX||n.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let i=e+1;for(;i<t.length;){const r=t[i];if(r.controlId!==n.controlId)return!1;if(r.controlComponent===l.ControlComponent.VALUE)return!0;if(r.controlComponent===l.ControlComponent.PLACEHOLDER||r.controlComponent===l.ControlComponent.TEXTFIXLABEL)return!1;i++}}if(n.controlComponent===l.ControlComponent.POSTFIX||n.controlComponent===l.ControlComponent.POSTTEXTFIX){let i=e-1;for(;i>=0;){const r=t[i];if(r.controlId!==n.controlId)return!1;if(r.controlComponent===l.ControlComponent.VALUE)return!0;if(r.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;i--}}return!1}getControlHighlight(t,e){return this.controlSearch.getControlHighlight(t,e)}getContainer(){return this.draw.getContainer()}getElementList(){return this.draw.getElementList()}getPosition(){const t=this.draw.getPosition().getPositionList(),{endIndex:e}=this.range.getRange();return t[e]||null}getPreY(){const t=this.draw.getHeight(),e=this.draw.getPageGap();return(this.getPosition()?.pageNo??this.draw.getPageNo())*(t+e)}getRange(){return this.range.getRange()}getValueRange(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];let r=n;for(;r>0;){const a=e[r];if(a.controlId!==i.controlId||a.controlComponent===l.ControlComponent.PREFIX||a.controlComponent===l.ControlComponent.PRE_TEXT||a.controlComponent===l.ControlComponent.PRETEXTFIX||a.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)break;r--}let s=n+1;for(;s<e.length;){const a=e[s];if(a.controlId!==i.controlId||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||a.controlComponent===l.ControlComponent.POSTTEXTFIX||a.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)break;s++}return r===s?null:{startIndex:r,endIndex:s-1}}shrinkBoundary(t={}){this.range.shrinkBoundary(t)}getActiveControl(){return this.activeControl}getActiveTextControlLimit(){if(!this.activeControl)return null;const t=this.activeControl.getElement(),e=t?.controlId,n=t?.originControlId||null;if(!e||t.control?.type!==l.ControlType.TEXT)return null;const i=this.getElementList(),r=n||null;let s=-1,a=-1,c=-1,d=-1;for(let h=0;h<i.length;h++){const g=i[h];g.controlId!==e||(n?g.originControlId!==n:g.originControlId)||(s===-1&&(s=h),a=h,(g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT||g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)&&(c=h),d===-1&&(g.controlComponent===l.ControlComponent.POSTFIX||g.controlComponent===l.ControlComponent.POST_TEXT||g.controlComponent===l.ControlComponent.POSTTEXTFIX||g.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&(d=h))}if(s===-1)return null;const R=c!==-1?c:s,u=d!==-1?d-1:a;return{controlId:e,originControlId:n,parentControlId:r,startIndex:R,endIndex:u<R?R:u}}getActiveNestedTextLimit(){const t=this.getActiveTextControlLimit();return!t?.parentControlId||!this.getElementList().some(n=>n.controlId===t.parentControlId&&!n.originControlId&&n.control?.type===l.ControlType.TEXTFIELD)?null:{controlId:t.controlId,parentControlId:t.parentControlId,startIndex:t.startIndex,endIndex:t.endIndex}}getControlElementList(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];if(!i?.controlId)return[];const r=[];let s=n;for(;s>0;){const c=e[s];if(c.controlId!==i.controlId)break;r.unshift(c),s--}let a=n+1;for(;a<e.length;){const c=e[a];if(c.controlId!==i.controlId)break;r.push(c),a++}return r}updateActiveControlValue(){this.activeControl&&(this.activeControlValue=this.getControlElementList())}emitControlChange(t){if(!this.activeControl)return;const e=this.eventBus.isSubscribe("controlChange");if(!this.listener.controlChange&&!e)return;let n;const i=this.activeControlValue,r=this.activeControl.getElement();i?.length?n=i[0].control:(n=De(at(r)).control,n.value=[]);const s={state:t,control:n,controlId:r.controlId};this.listener.controlChange?.(s),e&&this.eventBus.emit("controlChange",s)}initControl(){const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];if(this.activeControl){if(this.activeControl instanceof In||this.activeControl instanceof bn||this.activeControl instanceof Vn||this.activeControl instanceof ke){const R=this.activeControl.getElement();n?.controlId!==R?.controlId?this.destroyControl():n.controlComponent===l.ControlComponent.POSTFIX?this.activeControl.destroy():this.activeControl.awake()}if(this.activeControl){const R=this.activeControl.getElement(),u=n.controlId,h=R.controlId;if(u&&u===h){this.updateActiveControlValue(),this.preElement=n;return}if(n.originControlId&&n.originControlId===h&&!(this.activeControl.getElement()?.control?.type===l.ControlType.TEXTFIELD&&n.controlId!==h)){this.updateActiveControlValue(),this.preElement=n;return}if(n.originControlId&&n.controlId&&n.controlId,!n.originControlId&&n.controlId&&n.controlId!==h&&(this.activeControl.getElement()?.originControlId,n.controlId),n.controlId&&n.controlId===h&&n.originControlId){this.updateActiveControlValue(),this.preElement=n;return}if(!u){const g=this.getElementList(),f=this.getRange(),{startIndex:T}=f;let p=null;for(let m=T;m>=0;m--){const I=g[m];if(I.controlComponent===l.ControlComponent.PRETEXTFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||I.controlComponent===l.ControlComponent.PREFIX||I.controlComponent===l.ControlComponent.PRE_TEXT){p=I.controlId||null;break}if(I.controlId&&I.controlId!==h||I.controlComponent===l.ControlComponent.POSTTEXTFIX||I.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||I.controlComponent===l.ControlComponent.POSTFIX||I.controlComponent===l.ControlComponent.POST_TEXT)break}if(p===h){this.updateActiveControlValue(),this.preElement=n;return}}}}if(this.destroyControl(),this.draw.isReadonly())return;let r=n.control,s=n;if(n.originControlId&&!r){const R=n.originControlId;for(let u=this.range.getRange().startIndex;u>=0;u--){const h=t[u];if(h.controlId===R&&!h.originControlId&&h.control){r=h.control,s=h;break}if(h.controlId===R&&!h.originControlId&&(h.controlComponent===l.ControlComponent.PRETEXTFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||h.controlComponent===l.ControlComponent.PREFIX||h.controlComponent===l.ControlComponent.PRE_TEXT)){h.control&&(r=h.control,s=h);break}}}else if(!r&&n.controlId){const R=this.getElementList();for(let u=this.range.getRange().startIndex;u>=0;u--){const h=R[u];if(h.controlId!==n.controlId)break;if(h.control){r=h.control,s=h;break}if(h.controlComponent===l.ControlComponent.PRETEXTFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||h.controlComponent===l.ControlComponent.PREFIX||h.controlComponent===l.ControlComponent.PRE_TEXT)break}}if(!r)return;if(r?.type===l.ControlType.TEXTFIELD&&this.draw.getMode()!==l.EditorMode.EDIT)if(n.originControlId){const R=n.controlId;for(let u=this.range.getRange().startIndex;u>=0;u--){const h=t[u];if(h.controlId===R&&h.originControlId===n.originControlId&&h.control&&h.control.type!==l.ControlType.TEXTFIELD){r=h.control,s=h;break}if(h.controlComponent===l.ControlComponent.PREFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX)break}if(r?.type===l.ControlType.TEXTFIELD)return}else return;const a=this.draw.getPosition().getPositionContext(),c=this.range.getRange().startIndex,d=!!(a.isDirectHit&&a.index===c&&t[a.index]?.controlId===s.controlId);if(r?.type===l.ControlType.TEXTFIELD)this.activeControl=new Rr(s,this);else if(r.type===l.ControlType.TEXT)this.activeControl=new Ci(s,this);else if(r.type===l.ControlType.SELECT){const R=new In(s,this);this.activeControl=R,(d||this.draw.getMode()===l.EditorMode.FORM)&&R.awake()}else if(r.type===l.ControlType.CHECKBOX)this.activeControl=new Hn(s,this);else if(r.type===l.ControlType.RADIO)this.activeControl=new vo(s,this);else if(r.type===l.ControlType.DATE){const R=new bn(s,this);this.activeControl=R,R.awake()}else if(r.type===l.ControlType.NUMBER){const R=new Vn(s,this);this.activeControl=R,d&&R.awake()}else if(r.type===l.ControlType.BUTTON){const R=new ke(s,this);if(this.activeControl=R,d){R.awake();return}}else if(r.type===l.ControlType.MENSTRUAL_HISTORY){const R=new ur(s,this);this.activeControl=R,R.awake()}this.updateActiveControlValue(),this.preElement=s,s.controlComponent!==l.ControlComponent.POSTFIX&&s.controlComponent!==l.ControlComponent.POSTTEXTFIX&&this.emitControlChange(l.ControlState.ACTIVE)}destroyControl(t={}){if(!this.activeControl)return;const{isEmitEvent:e=!0}=t;(this.activeControl instanceof In||this.activeControl instanceof bn||this.activeControl instanceof Vn||this.activeControl instanceof ur)&&this.activeControl.destroy(),e&&this.preElement?.controlComponent!==l.ControlComponent.POSTFIX&&this.preElement?.controlComponent!==l.ControlComponent.POSTTEXTFIX&&this.emitControlChange(l.ControlState.INACTIVE),this.preElement=null,this.activeControl=null,this.activeControlValue=[]}repaintControl(t={}){const{curIndex:e,isCompute:n=!0,isSubmitHistory:i=!0,isSetCursor:r=!0}=t;e===void 0?(this.range.clearRange(),this.draw.render({isCompute:n,isSubmitHistory:i,isSetCursor:!1})):(this.range.setRange(e,e),this.draw.render({curIndex:e,isCompute:n,isSetCursor:r,isSubmitHistory:i}))}emitControlContentChange(t){const e=this.eventBus.isSubscribe("controlContentChange");if(!e&&!this.listener.controlContentChange)return;const n=t?.controlElement||this.activeControl?.getElement();if(!n)return;const i=t?.context?.elementList||this.getElementList(),{startIndex:r}=t?.context?.range||this.getRange();if(!i[r]?.controlId)return;const s=t?.controlValue||this.getControlElementList(t?.context);let a;if(s?.length?a=Pt(s)[0].control:(a=n.control,a.value=[]),!a)return;const c={control:a,controlId:n.controlId};this.listener.controlContentChange?.(c),e&&this.eventBus.emit("controlContentChange",c)}reAwakeControl(){if(!this.activeControl)return;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];this.activeControl.setElement(n),(this.activeControl instanceof bn||this.activeControl instanceof In)&&this.activeControl.getIsPopup()&&(this.activeControl.destroy(),this.activeControl.awake())}selectValue(){const t=this.getElementList(),{startIndex:e}=this.getRange(),n=t[e];if(!n?.controlId||n.controlComponent!==l.ControlComponent.VALUE&&t[e+1]?.controlComponent===l.ControlComponent.VALUE)return!1;let i=e;for(;i>0&&t[i].controlComponent===l.ControlComponent.VALUE;)i--;let r=e+1;for(;r<t.length;){if(t[r].controlComponent!==l.ControlComponent.VALUE){r--;break}r++}if(i!==r){const s=this.range.getRange();return this.range.replaceRange({...s,startIndex:i,endIndex:r}),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),!0}return!1}moveCursor(t){const{index:e,trIndex:n,tdIndex:i,tdValueIndex:r}=t;let s=this.draw.getOriginalElementList(),a;const c=t.isTable?r:e;if(t.isTable?(s=s[e].trList[n].tdList[i].value,a=s[r]):a=s[e],a.control?.hide||a.area?.hide){const d=Ln(s,c);return{newIndex:d,newElement:s[d]}}if(a.controlComponent===l.ControlComponent.VALUE)return{newIndex:c,newElement:a};if(a.controlComponent===l.ControlComponent.POSTFIX){let d=c+1;for(;d<s.length;){if(s[d].controlId!==a.controlId)return{newIndex:d-1,newElement:s[d-1]};if(d===s.length-1)return{newIndex:d,newElement:s[d]};d++}}else if(a.controlComponent===l.ControlComponent.PREFIX||a.controlComponent===l.ControlComponent.PRE_TEXT){let d=c+1;for(;d<s.length;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent!==l.ControlComponent.PREFIX&&R.controlComponent!==l.ControlComponent.PRE_TEXT)return{newIndex:d-1,newElement:s[d-1]};d++}}else if(a.controlComponent===l.ControlComponent.PLACEHOLDER){let d=c-1;for(;d>0;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.VALUE||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT||R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)return{newIndex:d,newElement:s[d]};d--}}else if(a.controlComponent===l.ControlComponent.POST_TEXT||a.controlComponent===l.ControlComponent.TEXTFIXLABEL||a.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){let d=c-1;for(;d>0;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.VALUE||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT||R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)return{newIndex:d,newElement:s[d]};d--}}else if(a.controlComponent===l.ControlComponent.POSTTEXTFIX){let d=c+1;for(;d<s.length;){if(s[d].controlId!==a.controlId)return{newIndex:d-1,newElement:s[d-1]};if(d===s.length-1)return{newIndex:d,newElement:s[d]};d++}}else if(a.controlComponent===l.ControlComponent.PRETEXTFIX||a.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let d=c+1;for(;d<s.length;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent!==l.ControlComponent.PRETEXTFIX&&R.controlComponent!==l.ControlComponent.PRETEXTFIX_TEXT)return{newIndex:d-1,newElement:s[d-1]};d++}}return{newIndex:c,newElement:a}}removeControl(t,e={}){const n=e.elementList||this.getElementList(),i=n[t];if(!this.draw.isDesignMode()&&!i?.control?.hide&&!i?.area?.hide){const{deletable:L=!0}=i.control;if(!L)return null;const P=this.draw.getMode();if(P===l.EditorMode.FORM&&this.options.modeRule[P].controlDeletableDisabled)return null}let r=-1,s=-1;const a=!!i.originControlId,c=i.controlId,d=i.originControlId,R=i.control?.type===l.ControlType.BUTTON&&!i.control?.buttonText?`${c}_text`:"";let u=t;for(;u>=0;){const L=n[u];let P=!1;if(a?P=L.controlId===c&&L.originControlId===d:P=L.controlId===c&&!L.originControlId,!P){r=u;break}u--}let h=t;for(;h<n.length;){const L=n[h];let P=!1;if(a?P=L.controlId===c&&L.originControlId===d:P=L.controlId===c&&!L.originControlId,!P){s=h-1;break}h++}if(h===n.length&&(s=h-1),!~r&&!~s)return t;r=~r?r:0;const g=n[r+1],f=g.control,T=f?.type&&[l.ControlType.TEXT,l.ControlType.TEXTFIELD,l.ControlType.DATE,l.ControlType.NUMBER,l.ControlType.SELECT,l.ControlType.BUTTON].includes(f.type);let p=n[0]?.type===l.ElementType.SPLIT_TAG;if(!e.removeNext&&T&&!a&&g.controlComponent!==l.ControlComponent.PREFIX&&g.type!==l.ElementType.SPLIT_TAG)if(e.removePrev)e.removePrev();else{const L=this.draw.getTd();L&&this.createRemoveControlHandler(L,i.controlId,!0)}if(!e.removeNext&&T&&!a&&g.controlComponent!==l.ControlComponent.PRETEXTFIX&&g.type!==l.ElementType.SPLIT_TAG)if(e.removePrev)e.removePrev();else{const L=this.draw.getTd();L&&this.createRemoveControlHandler(L,i.controlId,!0)}if(!e.removePrev&&T&&!a&&n[s].controlComponent!==l.ControlComponent.POSTFIX)if(e.removeNext)e.removeNext();else{const L=this.draw.getTd();p=!!L?.linkTdNextId,L&&this.createRemoveControlHandler(L,i.controlId,!1)}if(!e.removePrev&&T&&!a&&n[s].controlComponent!==l.ControlComponent.POSTTEXTFIX)if(e.removeNext)e.removeNext();else{const L=this.draw.getTd();p=!!L?.linkTdNextId,L&&this.createRemoveControlHandler(L,i.controlId,!1)}this.draw.spliceElementList(n,r+1,s-r);let m=0;if(R)for(let L=n.length-1;L>=0;L--)n[L].controlId===R&&(L<=r&&m++,n.splice(L,1));const I=r-m;return!e.elementList&&p&&r===0?this.draw.fixPosition(!0)??I:I}createRemoveControlHandler(t,e,n){if(n){const i=this.draw.getTdById(t.linkTdPrevId);i&&i.value.splice(-1)[0]?.controlId===e&&this.removeControl(i.value.length-1,{elementList:i.value,removePrev:()=>{this.createRemoveControlHandler(i,e,n)}})}else{const i=this.draw.getTdById(t.linkTdNextId);i&&i.value[1]?.controlId===e&&this.removeControl(1,{elementList:i.value,removeNext:()=>{this.createRemoveControlHandler(i,e,n)}})}}removePlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=n[t+1];if(i.controlComponent===l.ControlComponent.PLACEHOLDER||i.controlComponent===l.ControlComponent.TEXTFIXLABEL||r?.controlComponent===l.ControlComponent.PLACEHOLDER||r?.controlComponent===l.ControlComponent.TEXTFIXLABEL){let s=!1,a=t;for(;a<n.length;){const c=n[a];if(c.controlId!==i.controlId)break;c.controlComponent===l.ControlComponent.PLACEHOLDER||c.controlComponent===l.ControlComponent.TEXTFIXLABEL?(s||(s=!0,this.draw.getHistoryManager().popUndo(),this.draw.submitHistory(t)),n.splice(a,1)):a++}}}addPlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=i.control;if(!r.placeholder)return;let s=t;for(;s>=0;){const g=n[s];if(g.controlId!==i.controlId){s++;break}if(g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT||g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)break;s--}s<0&&(s=0);const a=s+1;if(a<n.length){const g=n[a];if(g.controlId===i.controlId&&(g.controlComponent===l.ControlComponent.PLACEHOLDER||g.controlComponent===l.ControlComponent.VALUE))return}let c=!1,d=s+1;for(;d<n.length;){const g=n[d];if(g.controlId===i.controlId){if(g.controlComponent===l.ControlComponent.POSTFIX||g.controlComponent===l.ControlComponent.POST_TEXT||g.controlComponent===l.ControlComponent.POSTTEXTFIX||g.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)break}else if(g.controlId!==i.controlId&&(g.controlComponent===l.ControlComponent.VALUE||g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT)){c=!0;break}d++}if(c)return;const R=ct(r.placeholder),u=Dt(i,Gt),h=s+1;for(let g=0;g<R.length;g++){const f=R[g],T={...u,value:f===`
|
|
185
|
-
`?_:f,controlId:i.controlId,type:l.ElementType.CONTROL,control:i.control,controlComponent:l.ControlComponent.PLACEHOLDER,color:this.controlOptions.placeholderColor};Ut(n,[T],s,{editorOptions:this.options}),this.draw.spliceElementList(n,h+g,0,[T])}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}setControlProperties(t,e={}){const n=e.elementList||this.getElementList(),{startIndex:i}=e.range||this.getRange(),r=n[i];let s=i;for(;s>0;){const c=n[s];if(c.controlId!==r.controlId)break;c.control={...c.control,...t},s--}let a=i+1;for(;a<n.length;){const c=n[a];if(c.controlId!==r.controlId)break;c.control={...c.control,...t},a++}}keydown(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.keydown(t)}cut(){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.cut()}getValueById(t){const{id:e,groupId:n,conceptId:i,areaId:r}=t,s=[];if(!e&&!i&&!n)return s;const a=new Set,c=(R,u)=>{let h=0;for(;h<R.length;){const g=R[h];if(h++,g.type===l.ElementType.TABLE){const P=g.trList;for(let O=0;O<P.length;O++){const S=P[O];for(let F=0;F<S.tdList.length;F++){const N=S.tdList[F],V=N.originalId??N.id;a.has(V)||(a.add(V),N.linkTdNextId?c(this.draw.getSplitTdValues(V),u):c(N.value,u))}}}if(!g.control||n&&g.control.groupId!==n||e&&g.controlId!==e||i&&g.control.conceptId!==i||r&&g.areaId!==r)continue;const{type:f,code:T,valueSets:p}=g.control;let m=h,I="";const L=[];for(;m<R.length;){const P=R[m];if(P.controlId!==g.controlId)break;(f===l.ControlType.TEXT||f===l.ControlType.TEXTFIELD||f===l.ControlType.DATE||f===l.ControlType.NUMBER)&&P.controlComponent===l.ControlComponent.VALUE&&(I+=P.value,L.push(ie(P,Xo))),m++}if(f===l.ControlType.TEXT||f===l.ControlType.TEXTFIELD||f===l.ControlType.DATE||f===l.ControlType.NUMBER)s.push({...g.control,zone:u,value:I||null,innerText:I||null,elementList:Pt(L)});else if(f===l.ControlType.SELECT||f===l.ControlType.CHECKBOX||f===l.ControlType.RADIO){const P=T?.split(",").map(O=>p?.find(S=>S.code===O)?.value).filter(Boolean).join("");s.push({...g.control,zone:u,value:T||null,innerText:P||null})}h=m}},d=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:R,elementList:u}of d)c(u,R);return s}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const i=(s,a)=>{let c=0;for(;c<s.length;){const d=s[c];if(c++,d.type===l.ElementType.TABLE){const L=d.trList;for(let P=0;P<L.length;P++){const O=L[P];for(let S=0;S<O.tdList.length;S++){const F=O.tdList[S];i(F.value,F.id)}}}if(!d.control||d.type===l.ElementType.SPLIT_TAG)continue;const R=t.find(L=>(!L.groupId||L.groupId===d.control?.groupId)&&(L.id&&d.controlId===L.id||L.conceptId&&d.control.conceptId===L.conceptId||L.areaId&&d.areaId===L.areaId));if(!R)continue;const{value:u,isSubmitHistory:h=!0}=R;e=!0,h&&(n=!0);const{type:g}=d.control,{range:f,fullRange:T}=this.mergeControl({elementList:s,range:{startIndex:c,endIndex:c},tdId:a}),p={range:T??f,elementList:s,tdId:a},m={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(g===l.ControlType.TEXTFIELD){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new Rr(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearValue(p,m)}else if(g===l.ControlType.TEXT){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new Ci(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearValue(p,m)}else if(g===l.ControlType.SELECT){if(Array.isArray(u))continue;const L=new In(d,this);this.activeControl=L,u?L.setSelect(u,p,m):L.clearSelect(p,m)}else if(g===l.ControlType.CHECKBOX){if(Array.isArray(u))continue;const L=new Hn(d,this);this.activeControl=L;const P=u?u.split(","):[];L.setSelect(P,p,m)}else if(g===l.ControlType.RADIO){if(Array.isArray(u))continue;const L=new vo(d,this);this.activeControl=L;const P=u?[u]:[];L.setSelect(P,p,m)}else if(g===l.ControlType.DATE){const L=new bn(d,this);this.activeControl=L,Po(u)?(u.length&&Vt(u,{isHandleFirstElement:!1,editorOptions:this.options}),L.setValue(u,p,m)):Gr(u)?L.setSelect(u,p,m):L.clearSelect(p,m)}else if(g===l.ControlType.NUMBER){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new Vn(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearValue(p,m)}else if(g===l.ControlType.BUTTON){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new ke(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearSelect(p,m)}this.emitControlContentChange({context:p}),this.activeControl=null;let I=c;for(;I<s.length&&s[I].controlId===d.controlId;)I++;c=I}};this.destroyControl({isEmitEvent:!1});const r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const s of r)i(s);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=i=>{let r=0;for(;r<i.length;){const s=i[r];if(r++,s.type===l.ElementType.TABLE){const R=s.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];e(f.value)}}}if(!s.control)continue;const a=t.find(R=>R.id&&s.controlId===R.id||R.conceptId&&s.control.conceptId===R.conceptId||R.areaId&&s.areaId===R.areaId);if(!a)continue;const{extension:c}=a;this.setControlProperties({extension:c},{elementList:i,range:{startIndex:r,endIndex:r}});let d=r;for(;d<i.length&&i[d].controlId===s.controlId;)d++;r=d}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{let a=0;for(;a<s.length;){const c=s[a];if(a++,c.type===l.ElementType.TABLE){const g=c.trList;for(let f=0;f<g.length;f++){const T=g[f];for(let p=0;p<T.tdList.length;p++){const m=T.tdList[p];i(m.value)}}}if(!c.control)continue;const d=t.find(g=>g.id&&c.controlId===g.id||g.conceptId&&c.control.conceptId===g.conceptId||g.areaId&&c.areaId===g.areaId);if(!d)continue;const{properties:R,isSubmitHistory:u=!0}=d;if(e=!0,u&&(n=!0),this.setControlProperties({...c.control,...R,value:c.control.value},{elementList:s,range:{startIndex:a-1,endIndex:a-1}}),Gt.forEach(g=>{const f=R[g];f&&Reflect.set(c,g,f)}),c.control?.type===l.ControlType.NUMBER&&R.numberExclusiveOptions){const g={...c.control.numberExclusiveOptions,...R.numberExclusiveOptions},f=g?.minValue,T=g?.maxValue,p=new Vn(c,this),m=p.getValue({elementList:s,range:{startIndex:a-1,endIndex:a-1}});if(m.length>0){const I=m.map(P=>P.value).join(""),L=Number(I);!Number.isNaN(L)&&Number.isFinite(L)&&(f!=null&&L<f||T!=null&&L>T)&&p.clearValue({elementList:s,range:{startIndex:a-1,endIndex:a-1}},{isAddPlaceholder:!0})}}let h=a;for(;h<s.length&&s[h].controlId===c.controlId;)h++;a=h}},r={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const s in r){const a=r[s];i(a)}if(e){for(const s in r){const a=s,c=Pt(r[a],{isClassifyArea:!0,extraPickAttrs:["id","controlId"]});r[a]=c,Vt(c,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(r),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(i){for(let r=0;r<i.length;r++){const s=i[r];if(s.type===l.ElementType.TABLE){const a=s.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let R=0;R<d.tdList.length;R++){const h=d.tdList[R].value;e(h)}}}if(s.controlId){const a=ie(s,[...Eo,...mn]);t.push(a)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const i of n)e(i);return Pt(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,i){this.controlBorder.recordBorderInfo(t,e,n,i)}drawBorder(t){this.controlBorder.render(t)}startTextFieldUnderline(t,e,n){this.textFieldUnderline.startTextFieldValue(t,e,n)}recordTextFieldUnderlineWidth(t){this.textFieldUnderline.recordValueWidth(t)}drawTextFieldUnderline(t){this.textFieldUnderline.endTextFieldValue(t)}getPreControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(c,d){for(let R=d;R>0;R--){const u=c[R];if(u.type===l.ElementType.TABLE){const g=u.trList||[];for(let f=g.length-1;f>=0;f--){const T=g[f],p=T.tdList;for(let m=p.length-1;m>=0;m--){const I=p[m],L=i(I.value,I.value.length-1);if(L)return{positionContext:{isTable:!0,index:R,trIndex:f,tdIndex:m,tdId:I.id,trId:T.id,tableId:u.id},nextIndex:L.nextIndex}}}}if(!u.controlId||u.controlId===n.controlId)continue;let h=R;for(;h>0;){const g=c[h];if(g.controlComponent===l.ControlComponent.VALUE||g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT||g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)break;h--}return{positionContext:{isTable:!1},nextIndex:h}}return null}const{startIndex:r}=this.range.getRange(),s=this.getElementList(),a=i(s,r);if(a)return{positionContext:e.isTable?e:a.positionContext,nextIndex:a.nextIndex};if(n.tableId){const c=this.draw.getOriginalElementList(),{index:d,trIndex:R,tdIndex:u}=e,h=c[d].trList;for(let f=R;f>=0;f--){const T=h[f],p=T.tdList;for(let m=p.length-1;m>=0;m--){if(R===f&&m>=u)continue;const I=p[m],L=i(I.value,I.value.length-1);if(L)return{positionContext:{isTable:!0,index:e.index,trIndex:f,tdIndex:m,tdId:I.id,trId:T.id,tableId:n.tableId},nextIndex:L.nextIndex}}}const g=i(c,d-1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}getNextControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(c,d){for(let R=d;R<c.length;R++){const u=c[R];if(u.type===l.ElementType.TABLE){const h=u.trList||[];for(let g=0;g<h.length;g++){const f=h[g],T=f.tdList;for(let p=0;p<T.length;p++){const m=T[p],I=i(m.value,0);if(I)return{positionContext:{isTable:!0,index:R,trIndex:g,tdIndex:p,tdId:m.id,trId:f.id,tableId:u.id},nextIndex:I.nextIndex}}}}if(!(!u.controlId||u.controlId===n.controlId||c[R+1]?.controlComponent===l.ControlComponent.PREFIX||c[R+1]?.controlComponent===l.ControlComponent.PRE_TEXT||c[R+1]?.controlComponent===l.ControlComponent.PRETEXTFIX||c[R+1]?.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT))return{positionContext:{isTable:!1},nextIndex:R}}return null}const{endIndex:r}=this.range.getRange(),s=this.getElementList(),a=i(s,r);if(a)return{positionContext:e.isTable?e:a.positionContext,nextIndex:a.nextIndex};if(n.tableId){const c=this.draw.getOriginalElementList(),{index:d,trIndex:R,tdIndex:u}=e,h=c[d].trList;for(let f=R;f<h.length;f++){const T=h[f],p=T.tdList;for(let m=0;m<p.length;m++){if(R===f&&m<=u)continue;const I=p[m],L=i(I.value,0);if(L)return{positionContext:{isTable:!0,index:e.index,trIndex:f,tdIndex:m,tdId:I.id,trId:T.id,tableId:n.tableId},nextIndex:L.nextIndex}}}const g=i(c,d+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=Zt.DOWN}=t;let n=null;if(e===Zt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:i,positionContext:r}=n,s=this.draw.getPosition();s.setPositionContext(r),this.draw.getRange().replaceRange({startIndex:i,endIndex:i}),this.draw.render({curIndex:i,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1});const a=s.getPositionList();this.draw.getCursor().moveCursorToVisible({cursorPosition:a[i],direction:e})}setMinWidthControlInfo(t){const{row:e,rowElement:n,controlRealWidth:i,availableWidth:r}=t;if(!n.control?.minWidth)return;const{scale:s}=this.options,a=n.control.minWidth*s;let c=null;if(n.control?.minWidth&&(n.control?.rowFlex===l.RowFlex.CENTER||n.control?.rowFlex===l.RowFlex.RIGHT)){let R=n.metrics.width,u=e.elementList.length-1;for(;u>=0;){const h=e.elementList[u];if(R+=h.metrics.width,e.elementList[u-1]?.controlComponent===l.ControlComponent.PREFIX){c=h;break}u--}c&&R<a&&(n.control.rowFlex===l.RowFlex.CENTER?c.left=(a-R)/2:n.control.rowFlex===l.RowFlex.RIGHT&&(c.left=a-R-n.metrics.width))}const d=a-i;if(d>0){const R=c?.left||0,u=r-e.width-n.metrics.width,h=Math.min(u,d);n.left=h-R,e.width+=h-R}}mergeControl(t={}){const e=t.elementList||this.getElementList(),n=t.range||this.getRange(),{startIndex:i}=n,r=t.tdId??this.draw.getPosition().getPositionContext().tdId,s=r?this.draw.getTdById(r):void 0,a=e[i];if(!a?.controlId)return{range:n,elementList:[],tdId:r};const c={startIndex:i,endIndex:i},d=[];let R=!1,u=i,h=s,g=e;for(;u>=0;){const m=g[u];if(m.controlId!==a.controlId)break;if(m.type!==l.ElementType.SPLIT_TAG&&(d.unshift(m),R&&(g.splice(u,1),e[0].type===l.ElementType.SPLIT_TAG?e.splice(0,1):(n.startIndex++,n.endIndex++),e.unshift(m)),c.startIndex=u),u===0&&m.controlComponent!==l.ControlComponent.PREFIX&&h?.linkTdPrevId&&(h=this.draw.getTdById(h.linkTdPrevId),h)){g=h.value,u=h.value.length-1,R=!0;continue}if(u===0&&m.controlComponent!==l.ControlComponent.PRETEXTFIX&&h?.linkTdPrevId&&(h=this.draw.getTdById(h.linkTdPrevId),h)){g=h.value,u=h.value.length-1,R=!0;continue}u--}R=!1;let f=i+1,T=s,p=e;for(;f<p.length;){const m=p[f];if(m.controlId!==a.controlId)break;if(m.type!==l.ElementType.SPLIT_TAG&&(d.push(m),R&&(p.splice(f,1),e.push(m),f--)),f===p.length-1&&m.controlComponent!==l.ControlComponent.POSTFIX&&T?.linkTdNextId&&(T=this.draw.getTdById(T.linkTdNextId),T)){p=T.value,f=0,R=!0;continue}if(f===p.length-1&&m.controlComponent!==l.ControlComponent.POSTTEXTFIX&&T?.linkTdNextId&&(T=this.draw.getTdById(T.linkTdNextId),T)){p=T.value,f=0,R=!0;continue}f++}return c.endIndex=c.startIndex+d.length,{range:n,elementList:e,tdId:r,fullRange:{startIndex:c.startIndex,endIndex:c.endIndex-2}}}}class ph{options;currentTextFieldId=null;valueStartX=0;valueWidth=0;valueY=0;constructor(t){this.options=t.getOptions()}startTextFieldValue(t,e,n){this.currentTextFieldId=t,this.valueStartX=e,this.valueY=n,this.valueWidth=0}recordValueWidth(t){this.valueWidth+=t}endTextFieldValue(t){if(!this.currentTextFieldId||this.valueWidth<=0){this.reset();return}const{scale:e}=this.options;t.save(),t.strokeStyle=this.options.defaultColor,t.lineWidth=e,t.beginPath();const n=this.valueY-.5*e;t.moveTo(this.valueStartX,n),t.lineTo(this.valueStartX+this.valueWidth,n),t.stroke(),t.restore(),this.reset()}reset(){this.currentTextFieldId=null,this.valueStartX=0,this.valueWidth=0,this.valueY=0}}class Lh{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{checkbox:e}=t;e?e.value=!e.value:t.checkbox={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:s}=t;const{checkbox:{gap:a,lineWidth:c,fillStyle:d,strokeStyle:R,verticalAlign:u},scale:h}=this.options,{metrics:g,checkbox:f}=r.elementList[i];if(u===l.VerticalAlign.TOP||u===l.VerticalAlign.MIDDLE){let L=i+1,P=null;for(;L<r.elementList.length&&(P=r.elementList[L],!(P.value!==_&&P.value!==fo));)L++;if(P){const{metrics:{boundingBoxAscent:O,boundingBoxDescent:S}}=P,F=O+S;F>g.height&&(u===l.VerticalAlign.TOP?s-=O-g.height:u===l.VerticalAlign.MIDDLE&&(s-=(F-g.height)/2))}}const T=Math.round(n+a*h),p=Math.round(s-g.height+c),m=g.width-a*2*h,I=g.height;e.save(),e.beginPath(),e.translate(.5,.5),f?.value?(e.lineWidth=c,e.strokeStyle=d,e.rect(T,p,m,I),e.stroke(),e.beginPath(),e.fillStyle=d,e.fillRect(T,p,m,I),e.beginPath(),e.strokeStyle=R,e.lineWidth=c*2*h,e.moveTo(T+2*h,p+I/2),e.lineTo(T+m/2,p+I-3*h),e.lineTo(T+m-2*h,p+3*h),e.stroke()):(e.lineWidth=c,e.rect(T,p,m,I),e.stroke()),e.closePath(),e.restore()}}class Ih{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{radio:e}=t;e?e.value=!e.value:t.radio={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:s}=t;const{radio:{gap:a,lineWidth:c,fillStyle:d,strokeStyle:R,verticalAlign:u},scale:h}=this.options,{metrics:g,radio:f}=r.elementList[i];if(u===l.VerticalAlign.TOP||u===l.VerticalAlign.MIDDLE){let L=i+1,P=null;for(;L<r.elementList.length&&(P=r.elementList[L],!(P.value!==_&&P.value!==fo));)L++;if(P){const{metrics:{boundingBoxAscent:O,boundingBoxDescent:S}}=P,F=O+S;F>g.height&&(u===l.VerticalAlign.TOP?s-=O-g.height:u===l.VerticalAlign.MIDDLE&&(s-=(F-g.height)/2))}}const T=Math.round(n+a*h),p=Math.round(s-g.height+c),m=g.width-a*2*h,I=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=f?.value?d:R,e.lineWidth=c,e.arc(T+m/2,p+I/2,m/2,0,Math.PI*2),e.stroke(),f?.value&&(e.beginPath(),e.fillStyle=d,e.arc(T+m/2,p+I/2,m/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const ho={fontSize:11,smallFontSize:9,lineHeight:12,dividerWidth:40,gap:4,totalHeight:36};class Ph{draw;options;inputModal=null;isPopup=!1;constructor(t){this.draw=t,this.options=t.getOptions()}computeSize(t){const e=ho,n=this.options.scale,i=e.fontSize*n,r=e.smallFontSize*n,s=e.gap*n,a=e.dividerWidth*n,d=document.createElement("canvas").getContext("2d"),R=t.menstrualData;d.font=`${i}px "Microsoft YaHei", sans-serif`;let u=a;d.font=`${r}px "Microsoft YaHei", sans-serif`;let h=0;if(R){const f=this.getValue(R.menarcheAge);d.font=`${i}px "Microsoft YaHei", sans-serif`,f&&(u+=d.measureText(`${f}岁`).width+s);let T="";if(R.isMenopause){const P=this.getValue(R.menopauseAge);P&&(T=`${P}岁`)}else{const P=this.getValue(R.lastPeriod);P&&(T=P)}T&&(u+=d.measureText(T).width+s),d.font=`${r}px "Microsoft YaHei", sans-serif`;const p=this.getValue(R.periodMin),m=this.getValue(R.periodMax);if(p||m){const P=`${p||""}~${m||""}`;h=Math.max(h,d.measureText(P).width)}const I=this.getValue(R.cycleMin),L=this.getValue(R.cycleMax);if(I||L){const P=`${I||""}~${L||""}`;h=Math.max(h,d.measureText(P).width)}}else d.font=`${i}px "Microsoft YaHei", sans-serif`,h=d.measureText("~").width;return{width:Math.max(u,h),height:e.totalHeight*n}}getValue(t){return!t||t===""||t==="_"||t==="____-__-__"?"":t}render(t){const{ctx:e,x:n,y:i,element:r}=t,s=r.menstrualData,a=this.options.scale;e.save(),e.font=`${ho.fontSize*a}px "Microsoft YaHei", sans-serif`,e.fillStyle=this.options.defaultColor,e.textBaseline="bottom",s?this.renderWithData(e,n,i,s,a):this.renderEmpty(e,n,i,a),e.restore()}renderEmpty(t,e,n,i){const r=ho,s=r.fontSize*i,a=r.lineHeight*i,c=r.dividerWidth*i,d=n-a*1.5,R=e+c/2;t.font=`${s}px "Microsoft YaHei", sans-serif`;const u=t.measureText("~").width,h=R-u/2;t.fillText("~",h,d+a);const g=d+a*2;this.drawDivider(t,e,g-s/2,c,i),t.fillText("~",h,g+a)}renderWithData(t,e,n,i,r){const s=ho,a=s.fontSize*r,c=s.smallFontSize*r,d=s.lineHeight*r,R=s.gap*r,u=s.dividerWidth*r,h=n-d*2,g=h+d*2;t.font=`${a}px "Microsoft YaHei", sans-serif`;const f=this.getValue(i.menarcheAge);let T=e;if(f){const C=`${f}岁`;t.fillText(C,e,g),T=e+t.measureText(C).width+R}const p=T+u/2,m=h+d;t.font=`${c}px "Microsoft YaHei", sans-serif`;const I=this.getValue(i.periodMin),L=this.getValue(i.periodMax);let P="";I||L?P=`${I||""}~${L||""}`:(t.font=`${a}px "Microsoft YaHei", sans-serif`,P="~");const O=t.measureText(P).width,S=p-O/2;t.fillText(P,S,m),this.drawDivider(t,T,g-a/2,u,r),t.font=`${a}px "Microsoft YaHei", sans-serif`;let F="";if(i.isMenopause){const C=this.getValue(i.menopauseAge);C&&(F=`${C}岁`)}else{const C=this.getValue(i.lastPeriod);C&&(F=C)}F&&t.fillText(F,T+u+R,g);const N=g+d;t.font=`${c}px "Microsoft YaHei", sans-serif`;const V=this.getValue(i.cycleMin),Y=this.getValue(i.cycleMax);let X="";V||Y?X=`${V||""}~${Y||""}`:(t.font=`${a}px "Microsoft YaHei", sans-serif`,X="~");const b=t.measureText(X).width,E=p-b/2;t.fillText(X,E,N)}drawDivider(t,e,n,i,r){t.save(),t.beginPath(),t.strokeStyle=this.options.defaultColor,t.lineWidth=.5*r,t.moveTo(e,n),t.lineTo(e+i,n),t.stroke(),t.restore()}clearMenstrualHistoryEditor(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}renderMenstrualHistoryEditor(t,e){if(this.options.mode===l.EditorMode.PRINT)return;(this.isPopup||this.inputModal)&&this.clearMenstrualHistoryEditor(),this.isPopup=!0;const n=t.menstrualData;this.inputModal=document.createElement("div"),this.inputModal.className="menstrual-history-edit-modal",this.inputModal.setAttribute("editor-component","menstrual-history-edit-modal"),this.inputModal.innerHTML=`
|
|
184
|
+
`,document.body.appendChild(this.inputModal);const e=this.inputModal.querySelector(".menstrual-history-modal__mask"),n=this.inputModal.querySelector(".menstrual-history-modal__container"),i=this.inputModal.querySelector(".menstrual-history-modal__close"),r=this.inputModal.querySelector(".btn-cancel"),s=this.inputModal.querySelector(".btn-confirm"),a=this.inputModal.querySelector("#mh-edit-notMenopause"),c=this.inputModal.querySelector("#mh-edit-isMenopauseForm"),d=this.inputModal.querySelectorAll('input[name="mh-edit-isMenopause"]'),R=()=>{this.closeModal()};n.addEventListener("click",u=>{u.stopPropagation()}),e.addEventListener("click",R),i.addEventListener("click",R),r.addEventListener("click",R),d.forEach(u=>{u.addEventListener("change",()=>{const h=u.value==="true";a.style.display=h?"none":"block",c.style.display=h?"block":"none"})}),s.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation();const h=this.inputModal;if(!h)return;const g=h.querySelector('input[name="mh-edit-isMenopause"]:checked')?.value==="true";let f;g?f={isMenopause:!0,periodMin:h.querySelector("#mh-edit-periodMin2")?.value||"_",periodMax:h.querySelector("#mh-edit-periodMax2")?.value||"_",menarcheAge:h.querySelector("#mh-edit-menarcheAge2")?.value||"_",menopauseAge:h.querySelector("#mh-edit-menopauseAge")?.value||"_",cycleMin:h.querySelector("#mh-edit-cycleMin2")?.value||"_",cycleMax:h.querySelector("#mh-edit-cycleMax2")?.value||"_"}:f={isMenopause:!1,periodMin:h.querySelector("#mh-edit-periodMin")?.value||"_",periodMax:h.querySelector("#mh-edit-periodMax")?.value||"_",menarcheAge:h.querySelector("#mh-edit-menarcheAge1")?.value||"_",lastPeriod:h.querySelector("#mh-edit-lastPeriod")?.value||"____-__-__",cycleMin:h.querySelector("#mh-edit-cycleMin")?.value||"_",cycleMax:h.querySelector("#mh-edit-cycleMax")?.value||"_"};const T=this.control.getElementList(),p=this.element.controlId;for(let P=0;P<T.length;P++){const O=T[P];O.controlId===p&&O.control&&(O.control.menstrualData=f)}const m=this.generateDisplayText(f),I=this.textToElements(m);this.closeModal();const L=this.setValue(I);L!==-1&&(this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({}))})}closeModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}destroy(){this.closeModal()}}class mh{controlBorder;textFieldUnderline;draw;range;listener;eventBus;controlSearch;options;controlOptions;activeControl;activeControlValue;preElement;constructor(t){this.controlBorder=new hc(t),this.textFieldUnderline=new ph(t),this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.controlSearch=new uc(this),this.options=t.getOptions(),this.controlOptions=this.options.control,this.activeControl=null,this.activeControlValue=[],this.preElement=null}setHighlightList(t){this.controlSearch.setHighlightList(t)}computeHighlightList(){this.controlSearch.getHighlightList().length&&this.controlSearch.computeHighlightList()}renderHighlightList(t,e){this.controlSearch.getHighlightMatchResult().length&&this.controlSearch.renderHighlightList(t,e)}getDraw(){return this.draw}filterAssistElement(t){return t.filter((e,n)=>{if(e.type===l.ElementType.TABLE){const i=e.trList;for(let r=0;r<i.length;r++){const s=i[r];for(let a=0;a<s.tdList.length;a++){const c=s.tdList[a];c.value=this.filterAssistElement(c.value)}}}if(!e.controlId)return!0;if(e.control?.type===l.ControlType.MENSTRUAL_HISTORY&&this.options.mode===l.EditorMode.PRINT&&(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)||e.control?.type===l.ControlType.SELECT&&this.options.mode===l.EditorMode.PRINT&&(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)||e.control?.type===l.ControlType.NUMBER&&this.options.mode===l.EditorMode.PRINT&&(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)||e.control?.type===l.ControlType.TEXT&&this.options.mode===l.EditorMode.PRINT&&e.strikeout&&e.deletePerson)return!1;if(e.control?.minWidth){if(e.controlComponent===l.ControlComponent.PREFIX||e.controlComponent===l.ControlComponent.POSTFIX)return e.value="",!0}else{const i=this.options.mode===l.EditorMode.FORM;if(e.control?.preText&&e.controlComponent===l.ControlComponent.PRE_TEXT){if(i)return!0;let r=!1,s=n+1;for(;s<t.length;){const a=t[s];if(e.controlId!==a.controlId)break;if(a.controlComponent===l.ControlComponent.VALUE){r=!0;break}s++}return r}if(e.control?.postText&&e.controlComponent===l.ControlComponent.POST_TEXT){if(i)return!0;let r=!1,s=n-1;for(;s<t.length;){const a=t[s];if(e.controlId!==a.controlId)break;if(a.controlComponent===l.ControlComponent.VALUE){r=!0;break}s--}return r}}if(e.control?.preTextFix&&e.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){let i=!1,r=n+1;for(;r<t.length;){const s=t[r];if(e.controlId!==s.controlId)break;if(s.controlComponent===l.ControlComponent.VALUE){i=!0;break}r++}return i}if(e.control?.postTextFix&&e.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){let i=!1,r=n-1;for(;r<t.length;){const s=t[r];if(e.controlId!==s.controlId)break;if(s.controlComponent===l.ControlComponent.VALUE){i=!0;break}r--}return i}return e.controlComponent!==l.ControlComponent.PREFIX&&e.controlComponent!==l.ControlComponent.POSTFIX&&e.controlComponent!==l.ControlComponent.PLACEHOLDER&&e.controlComponent!==l.ControlComponent.PRETEXTFIX&&e.controlComponent!==l.ControlComponent.POSTTEXTFIX&&e.controlComponent!==l.ControlComponent.TEXTFIXLABEL})}getIsRangeCanCaptureEvent(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),i=n[t];if(i.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;if(t===e&&t>0){const s=n[t-1],a=s?.controlComponent===l.ControlComponent.POSTFIX||s?.controlComponent===l.ControlComponent.POSTTEXTFIX,c=s?.controlComponent===l.ControlComponent.PLACEHOLDER,d=!!s?.controlId,R=!!s?.originControlId;let u=!1;if(R){const m=s.originControlId;for(let I=t;I<n.length;I++){const L=n[I];if(L.controlId===m&&!L.originControlId){u=!0;break}if(L.controlId&&L.controlId!==m&&L.originControlId!==m)break}}const g=this.draw.getPosition().getPositionList(),f=g[t],T=g[t-1],p=f&&T&&f.rowIndex===T.rowIndex;if((a||c)&&d&&p&&!u)return!1}if(t===e&&(i.controlComponent===l.ControlComponent.POSTFIX||i.controlComponent===l.ControlComponent.POSTTEXTFIX))return!0;const r=n[e];return!!(i.controlId&&i.controlId===r.controlId&&r.controlComponent!==l.ControlComponent.POSTFIX&&r.controlComponent!==l.ControlComponent.POSTTEXTFIX)}getIsRangeInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(t!==e)return!1;const i=this.getElementList()[t];return i.controlComponent===l.ControlComponent.POSTFIX||i.controlComponent===l.ControlComponent.POSTTEXTFIX}getIsRangeWithinControl(){const{range:{startIndex:t,endIndex:e},elementList:n}=this.range.getRangeElement();if(!~t&&!~e)return!1;const i=n[t],r=n[e];if(i?.controlId&&i.controlId===r.controlId&&r.controlComponent!==l.ControlComponent.POSTFIX&&r.controlComponent!==l.ControlComponent.POSTTEXTFIX&&r.controlComponent!==l.ControlComponent.POSTTEXTFIX_TEXT&&r.controlComponent!==l.ControlComponent.POST_TEXT)return!0;if(r?.originControlId&&(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)){const s=r.originControlId;for(let a=e+1;a<n.length;a++){const c=n[a];if(c.controlId===s)return!0;if(c.controlId&&c.controlId!==s&&c.originControlId!==s)break}}if(!r?.originControlId&&r?.controlId&&(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)){const s=n[e+1];if(s?.controlId&&s.controlId!==r.controlId&&(s.controlComponent===l.ControlComponent.PREFIX||s.controlComponent===l.ControlComponent.PRETEXTFIX))return!0;if(s?.controlId&&s.controlId!==r.controlId&&(s.controlComponent===l.ControlComponent.POSTFIX||s.controlComponent===l.ControlComponent.POSTTEXTFIX))return s.originControlId,!0;for(let a=e;a>=0;a--){const c=n[a];if(c.controlId===r.controlId&&(c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX)){for(let d=a-1;d>=0;d--){const R=n[d];if(R.controlId&&R.controlId!==r.controlId&&(R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT))return!0;if(R.controlId&&R.controlId!==r.controlId&&(R.controlComponent===l.ControlComponent.POSTFIX||R.controlComponent===l.ControlComponent.POSTTEXTFIX))break}break}}}if(r?.originControlId){const s=r.originControlId;for(let a=e+1;a<n.length;a++){const c=n[a];if(c.controlId===s)return!0;if(c.controlId&&c.controlId!==s&&c.originControlId!==s)break}}if(!i?.controlId&&this.activeControl){const a=this.activeControl.getElement()?.controlId;if(a)for(let c=t;c>=0;c--){const d=n[c];if(d.controlId===a&&!d.originControlId){if(d.controlComponent===l.ControlComponent.PRETEXTFIX||d.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||d.controlComponent===l.ControlComponent.PREFIX||d.controlComponent===l.ControlComponent.PRE_TEXT)for(let R=e;R<n.length;R++){const u=n[R];if(u.controlId===a&&!u.originControlId){if(u.controlComponent===l.ControlComponent.POSTTEXTFIX||u.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||u.controlComponent===l.ControlComponent.POSTFIX||u.controlComponent===l.ControlComponent.POST_TEXT)return!0;break}}break}}}return!1}getIsElementListContainFullControl(t){if(!t.some(i=>i.controlId))return!1;let e=0,n=0;for(let i=0;i<t.length;i++){const r=t[i];r.controlComponent===l.ControlComponent.PREFIX||r.controlComponent===l.ControlComponent.PRETEXTFIX?e++:(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)&&n++}return!e||!n?!1:e===n}getIsDisabledControl(t={}){if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();if(e===n&&~e&&~n){const r=(t.elementList||this.getElementList())[e];if(r.controlComponent===l.ControlComponent.POSTFIX||r.controlComponent===l.ControlComponent.POSTTEXTFIX)return!1}return!!this.activeControl.getElement()?.control?.disabled}getIsDisabledPasteControl(t={}){if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();return e===n&&~e&&~n&&(t.elementList||this.getElementList())[e].controlComponent===l.ControlComponent.POSTFIX?!1:!!this.activeControl.getElement()?.control?.pasteDisabled}getIsExistValueByElementListIndex(t,e){const n=t[e];if(!n.controlId)return!1;if(n.control?.type===l.ControlType.CHECKBOX||n.control?.type===l.ControlType.RADIO)return!!n.control?.code;if(n.controlComponent===l.ControlComponent.VALUE)return!0;if(n.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;if(n.controlComponent===l.ControlComponent.PREFIX||n.controlComponent===l.ControlComponent.PRE_TEXT){let i=e+1;for(;i<t.length;){const r=t[i];if(r.controlId!==n.controlId)return!1;if(r.controlComponent===l.ControlComponent.VALUE)return!0;if(r.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;i++}}if(n.controlComponent===l.ControlComponent.PRETEXTFIX||n.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let i=e+1;for(;i<t.length;){const r=t[i];if(r.controlId!==n.controlId)return!1;if(r.controlComponent===l.ControlComponent.VALUE)return!0;if(r.controlComponent===l.ControlComponent.PLACEHOLDER||r.controlComponent===l.ControlComponent.TEXTFIXLABEL)return!1;i++}}if(n.controlComponent===l.ControlComponent.POSTFIX||n.controlComponent===l.ControlComponent.POSTTEXTFIX){let i=e-1;for(;i>=0;){const r=t[i];if(r.controlId!==n.controlId)return!1;if(r.controlComponent===l.ControlComponent.VALUE)return!0;if(r.controlComponent===l.ControlComponent.PLACEHOLDER)return!1;i--}}return!1}getControlHighlight(t,e){return this.controlSearch.getControlHighlight(t,e)}getContainer(){return this.draw.getContainer()}getElementList(){return this.draw.getElementList()}getPosition(){const t=this.draw.getPosition().getPositionList(),{endIndex:e}=this.range.getRange();return t[e]||null}getPreY(){const t=this.draw.getHeight(),e=this.draw.getPageGap();return(this.getPosition()?.pageNo??this.draw.getPageNo())*(t+e)}getRange(){return this.range.getRange()}getValueRange(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];let r=n;for(;r>0;){const a=e[r];if(a.controlId!==i.controlId||a.controlComponent===l.ControlComponent.PREFIX||a.controlComponent===l.ControlComponent.PRE_TEXT||a.controlComponent===l.ControlComponent.PRETEXTFIX||a.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)break;r--}let s=n+1;for(;s<e.length;){const a=e[s];if(a.controlId!==i.controlId||a.controlComponent===l.ControlComponent.POSTFIX||a.controlComponent===l.ControlComponent.POST_TEXT||a.controlComponent===l.ControlComponent.POSTTEXTFIX||a.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)break;s++}return r===s?null:{startIndex:r,endIndex:s-1}}shrinkBoundary(t={}){this.range.shrinkBoundary(t)}getActiveControl(){return this.activeControl}getActiveTextControlLimit(){if(!this.activeControl)return null;const t=this.activeControl.getElement(),e=t?.controlId,n=t?.originControlId||null;if(!e||t.control?.type!==l.ControlType.TEXT)return null;const i=this.getElementList(),r=n||null;let s=-1,a=-1,c=-1,d=-1;for(let h=0;h<i.length;h++){const g=i[h];g.controlId!==e||(n?g.originControlId!==n:g.originControlId)||(s===-1&&(s=h),a=h,(g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT||g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)&&(c=h),d===-1&&(g.controlComponent===l.ControlComponent.POSTFIX||g.controlComponent===l.ControlComponent.POST_TEXT||g.controlComponent===l.ControlComponent.POSTTEXTFIX||g.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)&&(d=h))}if(s===-1)return null;const R=c!==-1?c:s,u=d!==-1?d-1:a;return{controlId:e,originControlId:n,parentControlId:r,startIndex:R,endIndex:u<R?R:u}}getActiveNestedTextLimit(){const t=this.getActiveTextControlLimit();return!t?.parentControlId||!this.getElementList().some(n=>n.controlId===t.parentControlId&&!n.originControlId&&n.control?.type===l.ControlType.TEXTFIELD)?null:{controlId:t.controlId,parentControlId:t.parentControlId,startIndex:t.startIndex,endIndex:t.endIndex}}getControlElementList(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];if(!i?.controlId)return[];const r=[];let s=n;for(;s>0;){const c=e[s];if(c.controlId!==i.controlId)break;r.unshift(c),s--}let a=n+1;for(;a<e.length;){const c=e[a];if(c.controlId!==i.controlId)break;r.push(c),a++}return r}updateActiveControlValue(){this.activeControl&&(this.activeControlValue=this.getControlElementList())}emitControlChange(t){if(!this.activeControl)return;const e=this.eventBus.isSubscribe("controlChange");if(!this.listener.controlChange&&!e)return;let n;const i=this.activeControlValue,r=this.activeControl.getElement();i?.length?n=i[0].control:(n=De(at(r)).control,n.value=[]);const s={state:t,control:n,controlId:r.controlId};this.listener.controlChange?.(s),e&&this.eventBus.emit("controlChange",s)}initControl(){const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];if(this.activeControl){if(this.activeControl instanceof In||this.activeControl instanceof bn||this.activeControl instanceof Vn||this.activeControl instanceof ke){const R=this.activeControl.getElement();n?.controlId!==R?.controlId?this.destroyControl():n.controlComponent===l.ControlComponent.POSTFIX?this.activeControl.destroy():this.activeControl.awake()}if(this.activeControl){const R=this.activeControl.getElement(),u=n.controlId,h=R.controlId;if(u&&u===h){this.updateActiveControlValue(),this.preElement=n;return}if(n.originControlId&&n.originControlId===h&&!(this.activeControl.getElement()?.control?.type===l.ControlType.TEXTFIELD&&n.controlId!==h)){this.updateActiveControlValue(),this.preElement=n;return}if(n.originControlId&&n.controlId&&n.controlId,!n.originControlId&&n.controlId&&n.controlId!==h&&(this.activeControl.getElement()?.originControlId,n.controlId),n.controlId&&n.controlId===h&&n.originControlId){this.updateActiveControlValue(),this.preElement=n;return}if(!u){const g=this.getElementList(),f=this.getRange(),{startIndex:T}=f;let p=null;for(let m=T;m>=0;m--){const I=g[m];if(I.controlComponent===l.ControlComponent.PRETEXTFIX||I.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||I.controlComponent===l.ControlComponent.PREFIX||I.controlComponent===l.ControlComponent.PRE_TEXT){p=I.controlId||null;break}if(I.controlId&&I.controlId!==h||I.controlComponent===l.ControlComponent.POSTTEXTFIX||I.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||I.controlComponent===l.ControlComponent.POSTFIX||I.controlComponent===l.ControlComponent.POST_TEXT)break}if(p===h){this.updateActiveControlValue(),this.preElement=n;return}}}}if(this.destroyControl(),this.draw.isReadonly())return;let r=n.control,s=n;if(n.originControlId&&!r){const R=n.originControlId;for(let u=this.range.getRange().startIndex;u>=0;u--){const h=t[u];if(h.controlId===R&&!h.originControlId&&h.control){r=h.control,s=h;break}if(h.controlId===R&&!h.originControlId&&(h.controlComponent===l.ControlComponent.PRETEXTFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||h.controlComponent===l.ControlComponent.PREFIX||h.controlComponent===l.ControlComponent.PRE_TEXT)){h.control&&(r=h.control,s=h);break}}}else if(!r&&n.controlId){const R=this.getElementList();for(let u=this.range.getRange().startIndex;u>=0;u--){const h=R[u];if(h.controlId!==n.controlId)break;if(h.control){r=h.control,s=h;break}if(h.controlComponent===l.ControlComponent.PRETEXTFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||h.controlComponent===l.ControlComponent.PREFIX||h.controlComponent===l.ControlComponent.PRE_TEXT)break}}if(!r)return;if(r?.type===l.ControlType.TEXTFIELD&&this.draw.getMode()!==l.EditorMode.EDIT)if(n.originControlId){const R=n.controlId;for(let u=this.range.getRange().startIndex;u>=0;u--){const h=t[u];if(h.controlId===R&&h.originControlId===n.originControlId&&h.control&&h.control.type!==l.ControlType.TEXTFIELD){r=h.control,s=h;break}if(h.controlComponent===l.ControlComponent.PREFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX)break}if(r?.type===l.ControlType.TEXTFIELD)return}else return;const a=this.draw.getPosition().getPositionContext(),c=this.range.getRange().startIndex,d=!!(a.isDirectHit&&a.index===c&&t[a.index]?.controlId===s.controlId);if(r?.type===l.ControlType.TEXTFIELD)this.activeControl=new Rr(s,this);else if(r.type===l.ControlType.TEXT)this.activeControl=new Ci(s,this);else if(r.type===l.ControlType.SELECT){const R=new In(s,this);this.activeControl=R,(d||this.draw.getMode()===l.EditorMode.FORM)&&R.awake()}else if(r.type===l.ControlType.CHECKBOX)this.activeControl=new Hn(s,this);else if(r.type===l.ControlType.RADIO)this.activeControl=new vo(s,this);else if(r.type===l.ControlType.DATE){const R=new bn(s,this);this.activeControl=R,R.awake()}else if(r.type===l.ControlType.NUMBER){const R=new Vn(s,this);this.activeControl=R,d&&R.awake()}else if(r.type===l.ControlType.BUTTON){const R=new ke(s,this);if(this.activeControl=R,d){R.awake();return}}else if(r.type===l.ControlType.MENSTRUAL_HISTORY){const R=new ur(s,this);this.activeControl=R,R.awake()}this.updateActiveControlValue(),this.preElement=s,s.controlComponent!==l.ControlComponent.POSTFIX&&s.controlComponent!==l.ControlComponent.POSTTEXTFIX&&this.emitControlChange(l.ControlState.ACTIVE)}destroyControl(t={}){if(!this.activeControl)return;const{isEmitEvent:e=!0}=t;(this.activeControl instanceof In||this.activeControl instanceof bn||this.activeControl instanceof Vn||this.activeControl instanceof ur)&&this.activeControl.destroy(),e&&this.preElement?.controlComponent!==l.ControlComponent.POSTFIX&&this.preElement?.controlComponent!==l.ControlComponent.POSTTEXTFIX&&this.emitControlChange(l.ControlState.INACTIVE),this.preElement=null,this.activeControl=null,this.activeControlValue=[]}repaintControl(t={}){const{curIndex:e,isCompute:n=!0,isSubmitHistory:i=!0,isSetCursor:r=!0}=t;e===void 0?(this.range.clearRange(),this.draw.render({isCompute:n,isSubmitHistory:i,isSetCursor:!1})):(this.range.setRange(e,e),this.draw.render({curIndex:e,isCompute:n,isSetCursor:r,isSubmitHistory:i}))}emitControlContentChange(t){const e=this.eventBus.isSubscribe("controlContentChange");if(!e&&!this.listener.controlContentChange)return;const n=t?.controlElement||this.activeControl?.getElement();if(!n)return;const i=t?.context?.elementList||this.getElementList(),{startIndex:r}=t?.context?.range||this.getRange();if(!i[r]?.controlId)return;const s=t?.controlValue||this.getControlElementList(t?.context);let a;if(s?.length?a=Mt(s)[0].control:(a=n.control,a.value=[]),!a)return;const c={control:a,controlId:n.controlId};this.listener.controlContentChange?.(c),e&&this.eventBus.emit("controlContentChange",c)}reAwakeControl(){if(!this.activeControl)return;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];this.activeControl.setElement(n),(this.activeControl instanceof bn||this.activeControl instanceof In)&&this.activeControl.getIsPopup()&&(this.activeControl.destroy(),this.activeControl.awake())}selectValue(){const t=this.getElementList(),{startIndex:e}=this.getRange(),n=t[e];if(!n?.controlId||n.controlComponent!==l.ControlComponent.VALUE&&t[e+1]?.controlComponent===l.ControlComponent.VALUE)return!1;let i=e;for(;i>0&&t[i].controlComponent===l.ControlComponent.VALUE;)i--;let r=e+1;for(;r<t.length;){if(t[r].controlComponent!==l.ControlComponent.VALUE){r--;break}r++}if(i!==r){const s=this.range.getRange();return this.range.replaceRange({...s,startIndex:i,endIndex:r}),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),!0}return!1}moveCursor(t){const{index:e,trIndex:n,tdIndex:i,tdValueIndex:r}=t;let s=this.draw.getOriginalElementList(),a;const c=t.isTable?r:e;if(t.isTable?(s=s[e].trList[n].tdList[i].value,a=s[r]):a=s[e],a.control?.hide||a.area?.hide){const d=Ln(s,c);return{newIndex:d,newElement:s[d]}}if(a.controlComponent===l.ControlComponent.VALUE)return{newIndex:c,newElement:a};if(a.controlComponent===l.ControlComponent.POSTFIX){let d=c+1;for(;d<s.length;){if(s[d].controlId!==a.controlId)return{newIndex:d-1,newElement:s[d-1]};if(d===s.length-1)return{newIndex:d,newElement:s[d]};d++}}else if(a.controlComponent===l.ControlComponent.PREFIX||a.controlComponent===l.ControlComponent.PRE_TEXT){let d=c+1;for(;d<s.length;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent!==l.ControlComponent.PREFIX&&R.controlComponent!==l.ControlComponent.PRE_TEXT)return{newIndex:d-1,newElement:s[d-1]};d++}}else if(a.controlComponent===l.ControlComponent.PLACEHOLDER){let d=c-1;for(;d>0;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.VALUE||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT||R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)return{newIndex:d,newElement:s[d]};d--}}else if(a.controlComponent===l.ControlComponent.POST_TEXT||a.controlComponent===l.ControlComponent.TEXTFIXLABEL||a.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){let d=c-1;for(;d>0;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent===l.ControlComponent.VALUE||R.controlComponent===l.ControlComponent.PREFIX||R.controlComponent===l.ControlComponent.PRE_TEXT||R.controlComponent===l.ControlComponent.PRETEXTFIX||R.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)return{newIndex:d,newElement:s[d]};d--}}else if(a.controlComponent===l.ControlComponent.POSTTEXTFIX){let d=c+1;for(;d<s.length;){if(s[d].controlId!==a.controlId)return{newIndex:d-1,newElement:s[d-1]};if(d===s.length-1)return{newIndex:d,newElement:s[d]};d++}}else if(a.controlComponent===l.ControlComponent.PRETEXTFIX||a.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){let d=c+1;for(;d<s.length;){const R=s[d];if(R.controlId!==a.controlId||R.controlComponent!==l.ControlComponent.PRETEXTFIX&&R.controlComponent!==l.ControlComponent.PRETEXTFIX_TEXT)return{newIndex:d-1,newElement:s[d-1]};d++}}return{newIndex:c,newElement:a}}removeControl(t,e={}){const n=e.elementList||this.getElementList(),i=n[t];if(!this.draw.isDesignMode()&&!i?.control?.hide&&!i?.area?.hide){const{deletable:L=!0}=i.control;if(!L)return null;const P=this.draw.getMode();if(P===l.EditorMode.FORM&&this.options.modeRule[P].controlDeletableDisabled)return null}let r=-1,s=-1;const a=!!i.originControlId,c=i.controlId,d=i.originControlId,R=i.control?.type===l.ControlType.BUTTON&&!i.control?.buttonText?`${c}_text`:"";let u=t;for(;u>=0;){const L=n[u];let P=!1;if(a?P=L.controlId===c&&L.originControlId===d:P=L.controlId===c&&!L.originControlId,!P){r=u;break}u--}let h=t;for(;h<n.length;){const L=n[h];let P=!1;if(a?P=L.controlId===c&&L.originControlId===d:P=L.controlId===c&&!L.originControlId,!P){s=h-1;break}h++}if(h===n.length&&(s=h-1),!~r&&!~s)return t;r=~r?r:0;const g=n[r+1],f=g.control,T=f?.type&&[l.ControlType.TEXT,l.ControlType.TEXTFIELD,l.ControlType.DATE,l.ControlType.NUMBER,l.ControlType.SELECT,l.ControlType.BUTTON].includes(f.type);let p=n[0]?.type===l.ElementType.SPLIT_TAG;if(!e.removeNext&&T&&!a&&g.controlComponent!==l.ControlComponent.PREFIX&&g.type!==l.ElementType.SPLIT_TAG)if(e.removePrev)e.removePrev();else{const L=this.draw.getTd();L&&this.createRemoveControlHandler(L,i.controlId,!0)}if(!e.removeNext&&T&&!a&&g.controlComponent!==l.ControlComponent.PRETEXTFIX&&g.type!==l.ElementType.SPLIT_TAG)if(e.removePrev)e.removePrev();else{const L=this.draw.getTd();L&&this.createRemoveControlHandler(L,i.controlId,!0)}if(!e.removePrev&&T&&!a&&n[s].controlComponent!==l.ControlComponent.POSTFIX)if(e.removeNext)e.removeNext();else{const L=this.draw.getTd();p=!!L?.linkTdNextId,L&&this.createRemoveControlHandler(L,i.controlId,!1)}if(!e.removePrev&&T&&!a&&n[s].controlComponent!==l.ControlComponent.POSTTEXTFIX)if(e.removeNext)e.removeNext();else{const L=this.draw.getTd();p=!!L?.linkTdNextId,L&&this.createRemoveControlHandler(L,i.controlId,!1)}this.draw.spliceElementList(n,r+1,s-r);let m=0;if(R)for(let L=n.length-1;L>=0;L--)n[L].controlId===R&&(L<=r&&m++,n.splice(L,1));const I=r-m;return!e.elementList&&p&&r===0?this.draw.fixPosition(!0)??I:I}createRemoveControlHandler(t,e,n){if(n){const i=this.draw.getTdById(t.linkTdPrevId);i&&i.value.splice(-1)[0]?.controlId===e&&this.removeControl(i.value.length-1,{elementList:i.value,removePrev:()=>{this.createRemoveControlHandler(i,e,n)}})}else{const i=this.draw.getTdById(t.linkTdNextId);i&&i.value[1]?.controlId===e&&this.removeControl(1,{elementList:i.value,removeNext:()=>{this.createRemoveControlHandler(i,e,n)}})}}removePlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=n[t+1];if(i.controlComponent===l.ControlComponent.PLACEHOLDER||i.controlComponent===l.ControlComponent.TEXTFIXLABEL||r?.controlComponent===l.ControlComponent.PLACEHOLDER||r?.controlComponent===l.ControlComponent.TEXTFIXLABEL){let s=!1,a=t;for(;a<n.length;){const c=n[a];if(c.controlId!==i.controlId)break;c.controlComponent===l.ControlComponent.PLACEHOLDER||c.controlComponent===l.ControlComponent.TEXTFIXLABEL?(s||(s=!0,this.draw.getHistoryManager().popUndo(),this.draw.submitHistory(t)),n.splice(a,1)):a++}}}addPlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=i.control;if(!r.placeholder)return;let s=t;for(;s>=0;){const g=n[s];if(g.controlId!==i.controlId){s++;break}if(g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT||g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)break;s--}s<0&&(s=0);const a=s+1;if(a<n.length){const g=n[a];if(g.controlId===i.controlId&&(g.controlComponent===l.ControlComponent.PLACEHOLDER||g.controlComponent===l.ControlComponent.VALUE))return}let c=!1,d=s+1;for(;d<n.length;){const g=n[d];if(g.controlId===i.controlId){if(g.controlComponent===l.ControlComponent.POSTFIX||g.controlComponent===l.ControlComponent.POST_TEXT||g.controlComponent===l.ControlComponent.POSTTEXTFIX||g.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT)break}else if(g.controlId!==i.controlId&&(g.controlComponent===l.ControlComponent.VALUE||g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT)){c=!0;break}d++}if(c)return;const R=ct(r.placeholder),u=Dt(i,Gt),h=s+1;for(let g=0;g<R.length;g++){const f=R[g],T={...u,value:f===`
|
|
185
|
+
`?_:f,controlId:i.controlId,type:l.ElementType.CONTROL,control:i.control,controlComponent:l.ControlComponent.PLACEHOLDER,color:this.controlOptions.placeholderColor};Ut(n,[T],s,{editorOptions:this.options}),this.draw.spliceElementList(n,h+g,0,[T])}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}setControlProperties(t,e={}){const n=e.elementList||this.getElementList(),{startIndex:i}=e.range||this.getRange(),r=n[i];let s=i;for(;s>0;){const c=n[s];if(c.controlId!==r.controlId)break;c.control={...c.control,...t},s--}let a=i+1;for(;a<n.length;){const c=n[a];if(c.controlId!==r.controlId)break;c.control={...c.control,...t},a++}}keydown(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.keydown(t)}cut(){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.cut()}getValueById(t){const{id:e,groupId:n,conceptId:i,areaId:r}=t,s=[];if(!e&&!i&&!n)return s;const a=new Set,c=(R,u)=>{let h=0;for(;h<R.length;){const g=R[h];if(h++,g.type===l.ElementType.TABLE){const P=g.trList;for(let O=0;O<P.length;O++){const S=P[O];for(let F=0;F<S.tdList.length;F++){const N=S.tdList[F],V=N.originalId??N.id;a.has(V)||(a.add(V),N.linkTdNextId?c(this.draw.getSplitTdValues(V),u):c(N.value,u))}}}if(!g.control||n&&g.control.groupId!==n||e&&g.controlId!==e||i&&g.control.conceptId!==i||r&&g.areaId!==r)continue;const{type:f,code:T,valueSets:p}=g.control;let m=h,I="";const L=[];for(;m<R.length;){const P=R[m];if(P.controlId!==g.controlId)break;(f===l.ControlType.TEXT||f===l.ControlType.TEXTFIELD||f===l.ControlType.DATE||f===l.ControlType.NUMBER)&&P.controlComponent===l.ControlComponent.VALUE&&(I+=P.value,L.push(ie(P,Xo))),m++}if(f===l.ControlType.TEXT||f===l.ControlType.TEXTFIELD||f===l.ControlType.DATE||f===l.ControlType.NUMBER)s.push({...g.control,zone:u,value:I||null,innerText:I||null,elementList:Mt(L)});else if(f===l.ControlType.SELECT||f===l.ControlType.CHECKBOX||f===l.ControlType.RADIO){const P=T?.split(",").map(O=>p?.find(S=>S.code===O)?.value).filter(Boolean).join("");s.push({...g.control,zone:u,value:T||null,innerText:P||null})}h=m}},d=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:R,elementList:u}of d)c(u,R);return s}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const i=(s,a)=>{let c=0;for(;c<s.length;){const d=s[c];if(c++,d.type===l.ElementType.TABLE){const L=d.trList;for(let P=0;P<L.length;P++){const O=L[P];for(let S=0;S<O.tdList.length;S++){const F=O.tdList[S];i(F.value,F.id)}}}if(!d.control||d.type===l.ElementType.SPLIT_TAG)continue;const R=t.find(L=>(!L.groupId||L.groupId===d.control?.groupId)&&(L.id&&d.controlId===L.id||L.conceptId&&d.control.conceptId===L.conceptId||L.areaId&&d.areaId===L.areaId));if(!R)continue;const{value:u,isSubmitHistory:h=!0}=R;e=!0,h&&(n=!0);const{type:g}=d.control,{range:f,fullRange:T}=this.mergeControl({elementList:s,range:{startIndex:c,endIndex:c},tdId:a}),p={range:T??f,elementList:s,tdId:a},m={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(g===l.ControlType.TEXTFIELD){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new Rr(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearValue(p,m)}else if(g===l.ControlType.TEXT){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new Ci(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearValue(p,m)}else if(g===l.ControlType.SELECT){if(Array.isArray(u))continue;const L=new In(d,this);this.activeControl=L,u?L.setSelect(u,p,m):L.clearSelect(p,m)}else if(g===l.ControlType.CHECKBOX){if(Array.isArray(u))continue;const L=new Hn(d,this);this.activeControl=L;const P=u?u.split(","):[];L.setSelect(P,p,m)}else if(g===l.ControlType.RADIO){if(Array.isArray(u))continue;const L=new vo(d,this);this.activeControl=L;const P=u?[u]:[];L.setSelect(P,p,m)}else if(g===l.ControlType.DATE){const L=new bn(d,this);this.activeControl=L,Po(u)?(u.length&&Vt(u,{isHandleFirstElement:!1,editorOptions:this.options}),L.setValue(u,p,m)):Gr(u)?L.setSelect(u,p,m):L.clearSelect(p,m)}else if(g===l.ControlType.NUMBER){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new Vn(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearValue(p,m)}else if(g===l.ControlType.BUTTON){const L=Array.isArray(u)?u:u?[{value:u}]:[];L.length&&Vt(L,{isHandleFirstElement:!1,editorOptions:this.options});const P=new ke(d,this);this.activeControl=P,L.length?P.setValue(L,p,m):P.clearSelect(p,m)}this.emitControlContentChange({context:p}),this.activeControl=null;let I=c;for(;I<s.length&&s[I].controlId===d.controlId;)I++;c=I}};this.destroyControl({isEmitEvent:!1});const r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const s of r)i(s);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=i=>{let r=0;for(;r<i.length;){const s=i[r];if(r++,s.type===l.ElementType.TABLE){const R=s.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];e(f.value)}}}if(!s.control)continue;const a=t.find(R=>R.id&&s.controlId===R.id||R.conceptId&&s.control.conceptId===R.conceptId||R.areaId&&s.areaId===R.areaId);if(!a)continue;const{extension:c}=a;this.setControlProperties({extension:c},{elementList:i,range:{startIndex:r,endIndex:r}});let d=r;for(;d<i.length&&i[d].controlId===s.controlId;)d++;r=d}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{let a=0;for(;a<s.length;){const c=s[a];if(a++,c.type===l.ElementType.TABLE){const g=c.trList;for(let f=0;f<g.length;f++){const T=g[f];for(let p=0;p<T.tdList.length;p++){const m=T.tdList[p];i(m.value)}}}if(!c.control)continue;const d=t.find(g=>g.id&&c.controlId===g.id||g.conceptId&&c.control.conceptId===g.conceptId||g.areaId&&c.areaId===g.areaId);if(!d)continue;const{properties:R,isSubmitHistory:u=!0}=d;if(e=!0,u&&(n=!0),this.setControlProperties({...c.control,...R,value:c.control.value},{elementList:s,range:{startIndex:a-1,endIndex:a-1}}),Gt.forEach(g=>{const f=R[g];f&&Reflect.set(c,g,f)}),c.control?.type===l.ControlType.NUMBER&&R.numberExclusiveOptions){const g={...c.control.numberExclusiveOptions,...R.numberExclusiveOptions},f=g?.minValue,T=g?.maxValue,p=new Vn(c,this),m=p.getValue({elementList:s,range:{startIndex:a-1,endIndex:a-1}});if(m.length>0){const I=m.map(P=>P.value).join(""),L=Number(I);!Number.isNaN(L)&&Number.isFinite(L)&&(f!=null&&L<f||T!=null&&L>T)&&p.clearValue({elementList:s,range:{startIndex:a-1,endIndex:a-1}},{isAddPlaceholder:!0})}}let h=a;for(;h<s.length&&s[h].controlId===c.controlId;)h++;a=h}},r={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const s in r){const a=r[s];i(a)}if(e){for(const s in r){const a=s,c=Mt(r[a],{isClassifyArea:!0,extraPickAttrs:["id","controlId"]});r[a]=c,Vt(c,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(r),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(i){for(let r=0;r<i.length;r++){const s=i[r];if(s.type===l.ElementType.TABLE){const a=s.trList;for(let c=0;c<a.length;c++){const d=a[c];for(let R=0;R<d.tdList.length;R++){const h=d.tdList[R].value;e(h)}}}if(s.controlId){const a=ie(s,[...Eo,...mn]);t.push(a)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const i of n)e(i);return Mt(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,i){this.controlBorder.recordBorderInfo(t,e,n,i)}drawBorder(t){this.controlBorder.render(t)}startTextFieldUnderline(t,e,n){this.textFieldUnderline.startTextFieldValue(t,e,n)}recordTextFieldUnderlineWidth(t){this.textFieldUnderline.recordValueWidth(t)}drawTextFieldUnderline(t){this.textFieldUnderline.endTextFieldValue(t)}getPreControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(c,d){for(let R=d;R>0;R--){const u=c[R];if(u.type===l.ElementType.TABLE){const g=u.trList||[];for(let f=g.length-1;f>=0;f--){const T=g[f],p=T.tdList;for(let m=p.length-1;m>=0;m--){const I=p[m],L=i(I.value,I.value.length-1);if(L)return{positionContext:{isTable:!0,index:R,trIndex:f,tdIndex:m,tdId:I.id,trId:T.id,tableId:u.id},nextIndex:L.nextIndex}}}}if(!u.controlId||u.controlId===n.controlId)continue;let h=R;for(;h>0;){const g=c[h];if(g.controlComponent===l.ControlComponent.VALUE||g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT||g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)break;h--}return{positionContext:{isTable:!1},nextIndex:h}}return null}const{startIndex:r}=this.range.getRange(),s=this.getElementList(),a=i(s,r);if(a)return{positionContext:e.isTable?e:a.positionContext,nextIndex:a.nextIndex};if(n.tableId){const c=this.draw.getOriginalElementList(),{index:d,trIndex:R,tdIndex:u}=e,h=c[d].trList;for(let f=R;f>=0;f--){const T=h[f],p=T.tdList;for(let m=p.length-1;m>=0;m--){if(R===f&&m>=u)continue;const I=p[m],L=i(I.value,I.value.length-1);if(L)return{positionContext:{isTable:!0,index:e.index,trIndex:f,tdIndex:m,tdId:I.id,trId:T.id,tableId:n.tableId},nextIndex:L.nextIndex}}}const g=i(c,d-1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}getNextControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(c,d){for(let R=d;R<c.length;R++){const u=c[R];if(u.type===l.ElementType.TABLE){const h=u.trList||[];for(let g=0;g<h.length;g++){const f=h[g],T=f.tdList;for(let p=0;p<T.length;p++){const m=T[p],I=i(m.value,0);if(I)return{positionContext:{isTable:!0,index:R,trIndex:g,tdIndex:p,tdId:m.id,trId:f.id,tableId:u.id},nextIndex:I.nextIndex}}}}if(!(!u.controlId||u.controlId===n.controlId||c[R+1]?.controlComponent===l.ControlComponent.PREFIX||c[R+1]?.controlComponent===l.ControlComponent.PRE_TEXT||c[R+1]?.controlComponent===l.ControlComponent.PRETEXTFIX||c[R+1]?.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT))return{positionContext:{isTable:!1},nextIndex:R}}return null}const{endIndex:r}=this.range.getRange(),s=this.getElementList(),a=i(s,r);if(a)return{positionContext:e.isTable?e:a.positionContext,nextIndex:a.nextIndex};if(n.tableId){const c=this.draw.getOriginalElementList(),{index:d,trIndex:R,tdIndex:u}=e,h=c[d].trList;for(let f=R;f<h.length;f++){const T=h[f],p=T.tdList;for(let m=0;m<p.length;m++){if(R===f&&m<=u)continue;const I=p[m],L=i(I.value,0);if(L)return{positionContext:{isTable:!0,index:e.index,trIndex:f,tdIndex:m,tdId:I.id,trId:T.id,tableId:n.tableId},nextIndex:L.nextIndex}}}const g=i(c,d+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=Zt.DOWN}=t;let n=null;if(e===Zt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:i,positionContext:r}=n,s=this.draw.getPosition();s.setPositionContext(r),this.draw.getRange().replaceRange({startIndex:i,endIndex:i}),this.draw.render({curIndex:i,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1});const a=s.getPositionList();this.draw.getCursor().moveCursorToVisible({cursorPosition:a[i],direction:e})}setMinWidthControlInfo(t){const{row:e,rowElement:n,controlRealWidth:i,availableWidth:r}=t;if(!n.control?.minWidth)return;const{scale:s}=this.options,a=n.control.minWidth*s;let c=null;if(n.control?.minWidth&&(n.control?.rowFlex===l.RowFlex.CENTER||n.control?.rowFlex===l.RowFlex.RIGHT)){let R=n.metrics.width,u=e.elementList.length-1;for(;u>=0;){const h=e.elementList[u];if(R+=h.metrics.width,e.elementList[u-1]?.controlComponent===l.ControlComponent.PREFIX){c=h;break}u--}c&&R<a&&(n.control.rowFlex===l.RowFlex.CENTER?c.left=(a-R)/2:n.control.rowFlex===l.RowFlex.RIGHT&&(c.left=a-R-n.metrics.width))}const d=a-i;if(d>0){const R=c?.left||0,u=r-e.width-n.metrics.width,h=Math.min(u,d);n.left=h-R,e.width+=h-R}}mergeControl(t={}){const e=t.elementList||this.getElementList(),n=t.range||this.getRange(),{startIndex:i}=n,r=t.tdId??this.draw.getPosition().getPositionContext().tdId,s=r?this.draw.getTdById(r):void 0,a=e[i];if(!a?.controlId)return{range:n,elementList:[],tdId:r};const c={startIndex:i,endIndex:i},d=[];let R=!1,u=i,h=s,g=e;for(;u>=0;){const m=g[u];if(m.controlId!==a.controlId)break;if(m.type!==l.ElementType.SPLIT_TAG&&(d.unshift(m),R&&(g.splice(u,1),e[0].type===l.ElementType.SPLIT_TAG?e.splice(0,1):(n.startIndex++,n.endIndex++),e.unshift(m)),c.startIndex=u),u===0&&m.controlComponent!==l.ControlComponent.PREFIX&&h?.linkTdPrevId&&(h=this.draw.getTdById(h.linkTdPrevId),h)){g=h.value,u=h.value.length-1,R=!0;continue}if(u===0&&m.controlComponent!==l.ControlComponent.PRETEXTFIX&&h?.linkTdPrevId&&(h=this.draw.getTdById(h.linkTdPrevId),h)){g=h.value,u=h.value.length-1,R=!0;continue}u--}R=!1;let f=i+1,T=s,p=e;for(;f<p.length;){const m=p[f];if(m.controlId!==a.controlId)break;if(m.type!==l.ElementType.SPLIT_TAG&&(d.push(m),R&&(p.splice(f,1),e.push(m),f--)),f===p.length-1&&m.controlComponent!==l.ControlComponent.POSTFIX&&T?.linkTdNextId&&(T=this.draw.getTdById(T.linkTdNextId),T)){p=T.value,f=0,R=!0;continue}if(f===p.length-1&&m.controlComponent!==l.ControlComponent.POSTTEXTFIX&&T?.linkTdNextId&&(T=this.draw.getTdById(T.linkTdNextId),T)){p=T.value,f=0,R=!0;continue}f++}return c.endIndex=c.startIndex+d.length,{range:n,elementList:e,tdId:r,fullRange:{startIndex:c.startIndex,endIndex:c.endIndex-2}}}}class ph{options;currentTextFieldId=null;valueStartX=0;valueWidth=0;valueY=0;constructor(t){this.options=t.getOptions()}startTextFieldValue(t,e,n){this.currentTextFieldId=t,this.valueStartX=e,this.valueY=n,this.valueWidth=0}recordValueWidth(t){this.valueWidth+=t}endTextFieldValue(t){if(!this.currentTextFieldId||this.valueWidth<=0){this.reset();return}const{scale:e}=this.options;t.save(),t.strokeStyle=this.options.defaultColor,t.lineWidth=e,t.beginPath();const n=this.valueY-.5*e;t.moveTo(this.valueStartX,n),t.lineTo(this.valueStartX+this.valueWidth,n),t.stroke(),t.restore(),this.reset()}reset(){this.currentTextFieldId=null,this.valueStartX=0,this.valueWidth=0,this.valueY=0}}class Lh{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{checkbox:e}=t;e?e.value=!e.value:t.checkbox={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:s}=t;const{checkbox:{gap:a,lineWidth:c,fillStyle:d,strokeStyle:R,verticalAlign:u},scale:h}=this.options,{metrics:g,checkbox:f}=r.elementList[i];if(u===l.VerticalAlign.TOP||u===l.VerticalAlign.MIDDLE){let L=i+1,P=null;for(;L<r.elementList.length&&(P=r.elementList[L],!(P.value!==_&&P.value!==fo));)L++;if(P){const{metrics:{boundingBoxAscent:O,boundingBoxDescent:S}}=P,F=O+S;F>g.height&&(u===l.VerticalAlign.TOP?s-=O-g.height:u===l.VerticalAlign.MIDDLE&&(s-=(F-g.height)/2))}}const T=Math.round(n+a*h),p=Math.round(s-g.height+c),m=g.width-a*2*h,I=g.height;e.save(),e.beginPath(),e.translate(.5,.5),f?.value?(e.lineWidth=c,e.strokeStyle=d,e.rect(T,p,m,I),e.stroke(),e.beginPath(),e.fillStyle=d,e.fillRect(T,p,m,I),e.beginPath(),e.strokeStyle=R,e.lineWidth=c*2*h,e.moveTo(T+2*h,p+I/2),e.lineTo(T+m/2,p+I-3*h),e.lineTo(T+m-2*h,p+3*h),e.stroke()):(e.lineWidth=c,e.rect(T,p,m,I),e.stroke()),e.closePath(),e.restore()}}class Ih{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{radio:e}=t;e?e.value=!e.value:t.radio={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:s}=t;const{radio:{gap:a,lineWidth:c,fillStyle:d,strokeStyle:R,verticalAlign:u},scale:h}=this.options,{metrics:g,radio:f}=r.elementList[i];if(u===l.VerticalAlign.TOP||u===l.VerticalAlign.MIDDLE){let L=i+1,P=null;for(;L<r.elementList.length&&(P=r.elementList[L],!(P.value!==_&&P.value!==fo));)L++;if(P){const{metrics:{boundingBoxAscent:O,boundingBoxDescent:S}}=P,F=O+S;F>g.height&&(u===l.VerticalAlign.TOP?s-=O-g.height:u===l.VerticalAlign.MIDDLE&&(s-=(F-g.height)/2))}}const T=Math.round(n+a*h),p=Math.round(s-g.height+c),m=g.width-a*2*h,I=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=f?.value?d:R,e.lineWidth=c,e.arc(T+m/2,p+I/2,m/2,0,Math.PI*2),e.stroke(),f?.value&&(e.beginPath(),e.fillStyle=d,e.arc(T+m/2,p+I/2,m/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const ho={fontSize:11,smallFontSize:9,lineHeight:12,dividerWidth:40,gap:4,totalHeight:36};class Ph{draw;options;inputModal=null;isPopup=!1;constructor(t){this.draw=t,this.options=t.getOptions()}computeSize(t){const e=ho,n=this.options.scale,i=e.fontSize*n,r=e.smallFontSize*n,s=e.gap*n,a=e.dividerWidth*n,d=document.createElement("canvas").getContext("2d"),R=t.menstrualData;d.font=`${i}px "Microsoft YaHei", sans-serif`;let u=a;d.font=`${r}px "Microsoft YaHei", sans-serif`;let h=0;if(R){const f=this.getValue(R.menarcheAge);d.font=`${i}px "Microsoft YaHei", sans-serif`,f&&(u+=d.measureText(`${f}岁`).width+s);let T="";if(R.isMenopause){const P=this.getValue(R.menopauseAge);P&&(T=`${P}岁`)}else{const P=this.getValue(R.lastPeriod);P&&(T=P)}T&&(u+=d.measureText(T).width+s),d.font=`${r}px "Microsoft YaHei", sans-serif`;const p=this.getValue(R.periodMin),m=this.getValue(R.periodMax);if(p||m){const P=`${p||""}~${m||""}`;h=Math.max(h,d.measureText(P).width)}const I=this.getValue(R.cycleMin),L=this.getValue(R.cycleMax);if(I||L){const P=`${I||""}~${L||""}`;h=Math.max(h,d.measureText(P).width)}}else d.font=`${i}px "Microsoft YaHei", sans-serif`,h=d.measureText("~").width;return{width:Math.max(u,h),height:e.totalHeight*n}}getValue(t){return!t||t===""||t==="_"||t==="____-__-__"?"":t}render(t){const{ctx:e,x:n,y:i,element:r}=t,s=r.menstrualData,a=this.options.scale;e.save(),e.font=`${ho.fontSize*a}px "Microsoft YaHei", sans-serif`,e.fillStyle=this.options.defaultColor,e.textBaseline="bottom",s?this.renderWithData(e,n,i,s,a):this.renderEmpty(e,n,i,a),e.restore()}renderEmpty(t,e,n,i){const r=ho,s=r.fontSize*i,a=r.lineHeight*i,c=r.dividerWidth*i,d=n-a*1.5,R=e+c/2;t.font=`${s}px "Microsoft YaHei", sans-serif`;const u=t.measureText("~").width,h=R-u/2;t.fillText("~",h,d+a);const g=d+a*2;this.drawDivider(t,e,g-s/2,c,i),t.fillText("~",h,g+a)}renderWithData(t,e,n,i,r){const s=ho,a=s.fontSize*r,c=s.smallFontSize*r,d=s.lineHeight*r,R=s.gap*r,u=s.dividerWidth*r,h=n-d*2,g=h+d*2;t.font=`${a}px "Microsoft YaHei", sans-serif`;const f=this.getValue(i.menarcheAge);let T=e;if(f){const C=`${f}岁`;t.fillText(C,e,g),T=e+t.measureText(C).width+R}const p=T+u/2,m=h+d;t.font=`${c}px "Microsoft YaHei", sans-serif`;const I=this.getValue(i.periodMin),L=this.getValue(i.periodMax);let P="";I||L?P=`${I||""}~${L||""}`:(t.font=`${a}px "Microsoft YaHei", sans-serif`,P="~");const O=t.measureText(P).width,S=p-O/2;t.fillText(P,S,m),this.drawDivider(t,T,g-a/2,u,r),t.font=`${a}px "Microsoft YaHei", sans-serif`;let F="";if(i.isMenopause){const C=this.getValue(i.menopauseAge);C&&(F=`${C}岁`)}else{const C=this.getValue(i.lastPeriod);C&&(F=C)}F&&t.fillText(F,T+u+R,g);const N=g+d;t.font=`${c}px "Microsoft YaHei", sans-serif`;const V=this.getValue(i.cycleMin),Y=this.getValue(i.cycleMax);let X="";V||Y?X=`${V||""}~${Y||""}`:(t.font=`${a}px "Microsoft YaHei", sans-serif`,X="~");const b=t.measureText(X).width,E=p-b/2;t.fillText(X,E,N)}drawDivider(t,e,n,i,r){t.save(),t.beginPath(),t.strokeStyle=this.options.defaultColor,t.lineWidth=.5*r,t.moveTo(e,n),t.lineTo(e+i,n),t.stroke(),t.restore()}clearMenstrualHistoryEditor(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}renderMenstrualHistoryEditor(t,e){if(this.options.mode===l.EditorMode.PRINT)return;(this.isPopup||this.inputModal)&&this.clearMenstrualHistoryEditor(),this.isPopup=!0;const n=t.menstrualData;this.inputModal=document.createElement("div"),this.inputModal.className="menstrual-history-edit-modal",this.inputModal.setAttribute("editor-component","menstrual-history-edit-modal"),this.inputModal.innerHTML=`
|
|
186
186
|
<div class="menstrual-history-modal__mask"></div>
|
|
187
187
|
<div class="menstrual-history-modal__container">
|
|
188
188
|
<div class="menstrual-history-modal__header">
|
|
@@ -535,7 +535,7 @@ ${u} `}textToElements(t){const e=[],n=t.split(`
|
|
|
535
535
|
<button class="btn-confirm">确定</button>
|
|
536
536
|
</div>
|
|
537
537
|
</div>
|
|
538
|
-
`,document.body.appendChild(a);const c=a.querySelector(".table-properties-modal__mask"),d=a.querySelector(".table-properties-modal__close"),R=a.querySelector(".btn-cancel"),u=a.querySelector(".btn-confirm"),h=()=>{a.remove()};c.addEventListener("click",h),d.addEventListener("click",h),R.addEventListener("click",h),u.addEventListener("click",()=>{const g=parseInt(a.querySelector("#tdPaddingTop").value)||0,f=parseInt(a.querySelector("#tdPaddingRight").value)||0,T=parseInt(a.querySelector("#tdPaddingBottom").value)||0,p=parseInt(a.querySelector("#tdPaddingLeft").value)||0;i.tdPadding=[g,f,T,p],h();const{endIndex:m}=this.range.getRange();this.draw.render({curIndex:m,isCompute:!0})})}}l.AreaMode=void 0,(function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"})(l.AreaMode||(l.AreaMode={}));class Jh{draw;zone;range;position;options;areaInfoMap=new Map;constructor(t){this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange();return this.draw.getElementList()[t]?.areaId||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!t?.area)return!1;switch(t.area.mode){case l.AreaMode.EDIT:return!1;case l.AreaMode.READONLY:return!0;case l.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:r,range:s}=t;if(this.zone.getZone()!==l.EditorZone.MAIN&&this.zone.setZone(l.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),s&&!this.getActiveAreaId()){const{startIndex:c,endIndex:d}=s,R=this.draw.getOriginalMainElementList();if(!R[c]||!R[d])return null;this.range.setRange(s.startIndex,s.endIndex)}else if(r===l.LocationPosition.BEFORE)this.range.setRange(0,0);else{const d=this.draw.getOriginalMainElementList().length-1;this.range.setRange(d,d)}const a=e||lt();return this.draw.insertElementList([{type:l.ElementType.AREA,value:"",areaId:a,valueList:n,area:at(i)}]),a}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const r of this.areaInfoMap){const{area:s,positionList:a}=r[1];if(s?.hide||!s?.backgroundColor&&!s?.borderColor&&!s?.placeholder)continue;const c=a.filter(f=>f.pageNo===e);if(!c.length)continue;t.translate(.5,.5);const d=c[0],R=c[c.length-1],u=n[3],h=Math.ceil(d.coordinate.leftTop[1]),g=Math.ceil(R.coordinate.rightBottom[1]-h);t.textBaseline="middle",s.backgroundColor&&(t.fillStyle=s.backgroundColor,t.fillRect(u,h,i,g)),s.borderColor&&(t.strokeStyle=s.borderColor,t.strokeRect(u,h,i,g)),s.placeholder&&a.length<=1&&new Cr(this.draw).render(t,{placeholder:{...Ai,...s.placeholder},startY:d.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],r=i.areaId;if(r){const s=this.areaInfoMap.get(r);s?(s.elementList.push(i),s.positionList.push(e[n])):this.areaInfoMap.set(r,{id:r,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:Pt(n.elementList)}:null}getContextByAreaId(t,e){const n=this.draw.getOriginalMainElementList();for(let i=0;i<n.length;i++){const r=n[i];if(e?.position===l.LocationPosition.OUTER_BEFORE){if(n[i+1]?.areaId!==t)continue}else if(e?.position===l.LocationPosition.AFTER){if(!(r.areaId===t&&n[i+1]?.areaId!==t))continue}else if(e?.position===l.LocationPosition.OUTER_AFTER){if(!(r.areaId!==t&&n[i-1]?.areaId===t))continue}else if(r.areaId!==t)continue;const s=this.position.getOriginalMainPositionList();return{range:{startIndex:i,endIndex:i},elementPosition:s[i]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const r=["top","hide"];Object.entries(t.properties).forEach(([s,a])=>{if(Ui(a))return;const c=s;n.area[c]=a,r.includes(c)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,r=this.draw.getOriginalMainElementList(),s=t.value;Vt([{type:l.ElementType.AREA,value:"",valueList:s,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(r,i[0].index,i.length,s,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class Bh{draw;options;imageCache;mainBadge;areaBadgeMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,r,s){if(this.imageCache.has(s)){const a=this.imageCache.get(s);t.drawImage(a,e,n,i,r)}else{const a=new Image;a.setAttribute("crossOrigin","Anonymous"),a.src=s,a.onload=()=>{this.imageCache.set(s,a),t.drawImage(a,e,n,i,r)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:r,top:s,width:a,height:c,value:d}=this.mainBadge,R=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),u=(r||i.left)*n,h=(s||i.top)*n+R;this._drawImage(t,u,h,a*n,c*n,d)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:r}=this.options;for(const s of n){const{positionList:a}=s[1],c=a[0];if(c.pageNo!==e)continue;const d=this.areaBadgeMap.get(s[0]);if(!d)continue;const{left:R,top:u,width:h,height:g,value:f}=d,T=(R||r.left)*i,p=(u||r.top)*i+c.coordinate.leftTop[1];this._drawImage(t,T,p,h*i,g*i,f)}}}}}class $h{draw;options;data;pageContainer;isDrawing=!1;startStroke=null;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const r=this.draw.getPageNo();let s=this.data.find(d=>d.pageNo===r);if(this.startStroke&&(s||(s={pageNo:r,strokes:[]},this.data.push(s)),s.strokes.push(this.startStroke),this.startStroke=null),!s?.strokes?.length)return;const{scale:a}=this.options;s.strokes[s.strokes.length-1].points.push(e/a,n/a),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){const n=this.data.find(a=>a.pageNo===e)?.strokes;if(!n?.length)return;const{graffiti:{defaultLineColor:i,defaultLineWidth:r},scale:s}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||i,t.lineWidth=(c.lineWidth||r)*s,t.moveTo(c.points[0]*s,c.points[1]*s);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*s,c.points[d+1]*s);t.stroke()}t.restore()}}const Sr=1024,zh=['[aria-modal="true"]','[role="dialog"]','[data-overlay-active="true"]',".ant-modal-root",".ant-modal-wrap",".ant-modal",".ant-drawer",".ant-select-dropdown",".ant-picker-dropdown",".ant-dropdown",".ant-popover",".ant-tooltip",".ant-cascader-dropdown",".ant-mentions-dropdown"].join(", ");function Er(o,t,e){for(let n=0;n<e.length;n+=Sr){const i=e.slice(n,n+Sr);o.splice(t+n,0,...i)}}class jh{container;pageContainer;pageList;ctxList;pageNo;renderCount;pagePixelRatio;mode;options;position;zone;elementList;listener;eventBus;override;i18n;canvasEvent;globalEvent;cursor;range;margin;background;badge;search;group;area;underline;strikeout;highlight;historyManager;previewer;imageParticle;laTexParticle;textParticle;tableParticle;tableTool;tableOperate;pageNumber;lineNumber;waterMark;placeholder;header;footer;hyperlinkParticle;labelParticle;macroParticle;dateParticle;separatorParticle;pageBreakParticle;superscriptParticle;subscriptParticle;checkboxParticle;radioParticle;menstrualHistoryParticle;fetalHeartPositionParticle;toothPositionParticle;blockParticle;listParticle;lineBreakParticle;whiteSpaceParticle;control;pageBorder;workerManager;scrollObserver;selectionObserver;imageObserver;graffiti;command;interactionPaused;overlayActiveCount;globalShortcutSuspended;LETTER_REG;WORD_LIKE_REG;rowList;pageRowList;painterStyle;painterOptions;visiblePageNoList;intersectionPageNo;lazyRenderIntersectionObserver;printModeData;splitTdValueMap=new Map;tdMap=new Map;constructor(t,e,n,i,r,s){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=r,this.override=s,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Yh(e.locale),this.historyManager=new _a(this),this.position=new xa(this),this.zone=new wh(this),this.range=new Ga(this),this.margin=new Ja(this),this.background=new Aa(this),this.badge=new Bh(this),this.search=new Ba(this),this.group=new vh(this),this.area=new Jh(this),this.underline=new za(this),this.strikeout=new $a(this),this.highlight=new ka(this),this.previewer=new Fh(this),this.imageParticle=new Qi(this),this.laTexParticle=new Hi(this),this.textParticle=new ja(this),this.tableParticle=new ec(this),this.tableTool=new nc(this),this.tableOperate=new kh(this),this.pageNumber=new sn(this),this.lineNumber=new _h(this),this.waterMark=new Rc(this),this.placeholder=new Cr(this),this.header=new rc(this,n.header),this.footer=new Zh(this,n.footer),this.hyperlinkParticle=new oc(this),this.labelParticle=new ic(this),this.macroParticle=new sc(this),this.dateParticle=new yh(this),this.separatorParticle=new cc(this),this.pageBreakParticle=new dc(this),this.superscriptParticle=new lc,this.subscriptParticle=new ac,this.checkboxParticle=new Lh(this),this.radioParticle=new Ih(this),this.menstrualHistoryParticle=new Ph(this),this.fetalHeartPositionParticle=new Mh(this),this.toothPositionParticle=new Oh(this),this.blockParticle=new bh(this),this.listParticle=new Qh(this),this.lineBreakParticle=new Yn(this),this.whiteSpaceParticle=new Kh(this),this.control=new mh(this),this.pageBorder=new xh(this),this.graffiti=new $h(this,n.graffiti),this.scrollObserver=new qa(this),this.selectionObserver=new tc(this),this.imageObserver=new Dh,new Hh(this),this.canvasEvent=new Ka(this),this.cursor=new la(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new Ha(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new Nh(this),new Ah(this);const{letterClass:a}=e;this.LETTER_REG=new RegExp(`[${a.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${a.map(c=>`[^${c}][${c}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.interactionPaused=!1,this.overlayActiveCount=0,this.globalShortcutSuspended=!1,this.mode===l.EditorMode.PRINT&&this.setPrintData(),this.mode,l.EditorMode.FORM,this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData={header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()};const t=at(this.printModeData);["header","main","footer"].forEach(r=>{t[r]=this.control.filterAssistElement(t[r])});const n=t,i=this.removeStrikeout(n);t.main=i.main.filter(r=>!r.strikeout),this.setEditorData(i)}removeStrikeout(t){if(Array.isArray(t))return t.map(e=>this.removeStrikeout(e)).filter(e=>!(e&&typeof e=="object"&&"strikeout"in e&&e.strikeout===!0));if(t&&typeof t=="object"){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this.removeStrikeout(t[n]));return e}return t}clearPrintData(){this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null)}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){if(this.mode===t)return;this.mode=t,this.options.mode=t;const e=new Map,n=r=>{r.forEach(s=>{s.controlId&&(s.controlComponent==="value"&&e.set(s.controlId,!0),s.checked&&e.set(s.controlId,!0))})};n(this.elementList),this.elementList.forEach(r=>{r.type==="table"&&r.trList?.forEach(s=>{s.tdList?.forEach(a=>{n(a.value)})})});const i=r=>{r.forEach(s=>{if(!(!s.control&&!s.controlId)&&(s.controlComponent==="value"&&s.strikeout&&(t===l.EditorMode.PRINT?s.hide=!0:s.hide=!1),!!s.control&&!(s.type!=="control"&&s.control.type!=="button"))){if(s.control.type==="TextField"&&(s.controlComponent==="placeholder"||s.controlComponent==="preTextFix"||s.controlComponent==="preTextFixText"||s.controlComponent==="postTextFix"||s.controlComponent==="postTextFixText"||s.controlComponent==="textFixLabel")&&(t===l.EditorMode.EDIT?s.hide=!1:s.hide=!0),s.control.type==="text"&&(s.controlComponent==="placeholder"||s.controlComponent==="prefix"||s.controlComponent==="postfix")&&(t===l.EditorMode.EDIT||t===l.EditorMode.FORM?s.hide=!1:s.hide=!0),s.control.type==="number"||s.control.type==="select"||s.control.type==="date"||s.control.type==="checkbox"||s.control.type==="radio"){if(s.controlComponent==="placeholder"||s.controlComponent==="prefix"||s.controlComponent==="postfix"){const c=e.get(s.controlId);s.control.type==="select"&&t===l.EditorMode.PRINT||t===l.EditorMode.PRINT&&!c?s.hide=!0:s.hide=!1}s.control.type==="number"&&s.controlComponent==="value"&&(t===l.EditorMode.PRINT&&s.strikeout?s.hide=!0:t!==l.EditorMode.PRINT&&s.strikeout&&(s.hide=!1))}s.control.type==="button"&&(s.hide=!1,s.control.hide=!1),s.control.type==="menstrualHistory"&&(s.controlComponent==="prefix"||s.controlComponent==="postfix")&&(t===l.EditorMode.PRINT?s.hide=!0:s.hide=!1)}})};i(this.elementList),this.elementList.forEach(r=>{r.type==="table"&&r.trList.forEach(s=>{s.tdList.forEach(a=>{i(a.value)})})}),t===l.EditorMode.FORM?(this.elementList.filter(r=>r.type==="control").map(r=>{r.control?.type==="button"&&r.control.buttonText&&(r.color="#1677FF",r.highlight="transparent")}),this.hideTextFieldWhitespace(this.elementList,!0),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):t===l.EditorMode.EDIT?(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!1,!0)),t===l.EditorMode.PRINT?(this.elementList.filter(r=>r?.control?.type==="button").map(r=>{(r?.controlComponent==="prefix"||r?.controlComponent==="postfix")&&(r.color="transparent",r.highlight="transparent"),r?.controlComponent==="value"&&!r.control.buttonText&&(r.color="transparent",r.highlight="transparent")}),this.setPrintData()):(this.clearPrintData(),this.elementList.filter(r=>r?.control?.type==="button").map(r=>{(r?.controlComponent==="prefix"||r?.controlComponent==="postfix")&&!r.control.buttonText&&r.type==="control"&&(r.color="transparent",r.highlight="#1677FF"),r?.controlComponent==="value"&&!r.control.buttonText&&(r.color="#fff",r.highlight="#1677FF"),r?.type==="text"&&r.control.buttonText&&(r.color="#000"),r?.type==="control"&&r?.controlComponent==="value"&&r.control.buttonText&&(r.color="#000",r.highlight="transparent")})),this.mode===l.EditorMode.PRINT&&this.clearPrintData(),this.clearSideEffect(),this.control.destroyControl(),this.range.clearRange(),this.render({isSetCursor:!1,isSubmitHistory:!1})}hideTextFieldWhitespace(t,e){const n=r=>r?/^[\s\u00A0\u2000-\u200B\u3000\n\r\t]+$/.test(r):!1;(r=>{for(let s=0;s<r.length;s++){const a=r[s];if(a.type===l.ElementType.TABLE&&a.trList)for(const c of a.trList)for(const d of c.tdList)this.hideTextFieldWhitespace(d.value,e);a.control?.type===l.ControlType.TEXTFIELD&&a.controlComponent===l.ControlComponent.VALUE&&n(a.value)&&(a.hide=e)}})(t)}updateTextFieldPlaceholderVisibility(t,e,n){const i=[l.ControlType.TEXT,l.ControlType.TEXTFIELD,l.ControlType.SELECT,l.ControlType.DATE,l.ControlType.CHECKBOX,l.ControlType.RADIO,l.ControlType.NUMBER];(s=>{let a=0;for(;a<s.length;){const c=s[a];if(c.type===l.ElementType.TABLE&&c.trList)for(const d of c.trList)for(const R of d.tdList)this.updateTextFieldPlaceholderVisibility(R.value,e,n);if(c.control?.type&&i.includes(c.control.type)&&(c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PRE_TEXT)){const d=c.controlId,R=c.control.type;let u=!1,h=!1,g=!1;const f=[],T=[],p=[];let m=-1,I=a;for(;I<s.length;){const L=s[I];if(L.controlId!==d)break;if((L.controlComponent===l.ControlComponent.PREFIX||L.controlComponent===l.ControlComponent.PRETEXTFIX||L.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)&&T.push(I),L.controlComponent===l.ControlComponent.VALUE&&L.value&&L.value.trim()&&(u=!0),L.controlComponent===l.ControlComponent.VALUE&&(L.type===l.ElementType.MENSTRUAL_HISTORY||L.type===l.ElementType.FETAL_HEART_POSITION||L.type===l.ElementType.TOOTH_POSITION||L.type===l.ElementType.MACRO||L.type===l.ElementType.CUSTOM_MACRO)&&(u=!0),L.controlComponent===l.ControlComponent.VALUE&&L.control&&L.control.type!==R&&(h=!0),L.controlComponent===l.ControlComponent.PLACEHOLDER&&(g=!0,f.push(I)),L.controlComponent===l.ControlComponent.POSTFIX||L.controlComponent===l.ControlComponent.POSTTEXTFIX||L.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){p.push(I),m=I;break}I++}if(!u&&!h)if(g&&f.length>0)for(const L of f)s[L].hide=!e;else e&&c.control?.placeholder&&(m>0?this.control.addPlaceholder(m-1):this.control.addPlaceholder(a));if(n)if(e&&u){for(const L of T)s[L].hide=!0;for(const L of p)s[L].hide=!0}else if(e){for(const L of T)s[L].hide=!1;for(const L of p)s[L].hide=!1}else{for(const L of T)s[L].hide=!0;for(const L of p)s[L].hide=!0}else{for(const L of T)s[L].hide=!1;for(const L of p)s[L].hide=!1}a=I}a++}})(t)}isReadonly(){if(this.area.getActiveAreaInfo()?.area?.mode)return this.area.isReadonly();switch(this.mode){case l.EditorMode.DESIGN:return!1;case l.EditorMode.READONLY:case l.EditorMode.PRINT:case l.EditorMode.GRAFFITI:return!0;case l.EditorMode.FORM:if(this.control.getIsRangeWithinControl()){const t=this.getElementList(),{startIndex:e}=this.range.getRange();if(t[e]?.control?.type===l.ControlType.TEXTFIELD)return!0}return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){if(this.mode===l.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if(this.getTd()?.disabled)return!0;if(t===e){const r=n[t],s=n[t+1];return!!(r?.title?.disabled&&s?.title?.disabled&&r.titleId===s.titleId||r?.control?.disabled&&s?.control?.disabled&&r.controlId===s.controlId)}return n.slice(t+1,e+1).some(r=>r.title?.disabled||r.control?.disabled)}isDesignMode(){return this.mode===l.EditorMode.DESIGN}isPrintMode(){return this.mode===l.EditorMode.PRINT}isGraffitiMode(){return this.mode===l.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===l.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===l.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,s=this.getOriginalElementList()[e],a=s.trList[n].tdList[i],c=this.getTdPadding(s);return a.width-c[1]-c[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===l.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(t){const{table:{tdPadding:e},scale:n}=this.options;return(t?.tdPadding||e).map(r=>r*n)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getEventTarget(t){return t instanceof Element?t:t instanceof Node?t.parentElement:null}isTargetInsideEditor(t){const e=this.getEventTarget(t);return e?this.container.contains(e)?!0:!!Wi(e,n=>!!n&&n.nodeType===1&&!!n.getAttribute(de)):!1}isTargetInsideExternalOverlay(t){const e=this.getEventTarget(t);return!e||this.isTargetInsideEditor(e)?!1:!!e.closest(zh)}pauseInteraction(){this.interactionPaused=!0,this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect()}resumeInteraction(){this.interactionPaused=!1}setOverlayActive(t){this.overlayActiveCount=t?1:0,t&&(this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect())}suspendGlobalShortcut(t){this.globalShortcutSuspended=t}isInteractionSuspended(){return this.interactionPaused||this.overlayActiveCount>0}isGlobalShortcutActive(){return!this.globalShortcutSuspended&&!this.isInteractionSuspended()}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return t[n].trList[i].tdList[r].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return t[n]?.trList?.[i].tdList[r].value||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}getTdByPosition(t){const{index:e,trIndex:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementTextField(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.getElementList(),{isSubmitHistory:s=!0}=e;Vt(t,{isHandleFirstElement:!1,editorOptions:this.options});let a=-1,c=this.control.getActiveControl();if(!c&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),c=this.control.getActiveControl()),c&&this.control.getIsRangeWithinControl()){const d=n===i,R=n+1;d||this.newSpliceElementList(r,R,i-n),this.newSpliceElementList(r,R,0,t),a=n+t.length}else{const d=n===i,R=n+1;d||this.newSpliceElementList(r,R,i-n),this.newSpliceElementList(r,R,0,t),a=n+t.length;const u=r[R-1];t[0].listId&&u&&!u.listId&&u?.value===_&&(!u.type||u.type===l.ElementType.TEXTFIELD)&&(r.splice(n,1),a-=1)}this.control.destroyControl(),~a&&(this.range.setRange(a,a),this.render({curIndex:a,isSubmitHistory:s}))}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:r=!0}=e;Vt(t,{isHandleFirstElement:!1,editorOptions:this.options});let s=-1,a=this.control.getActiveControl();if(!a&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),a=this.control.getActiveControl()),a&&this.control.getIsRangeWithinControl()){const c=this.getElementList(),d=n===i,R=n+1,u=c[n];if(u?.controlComponent===l.ControlComponent.PRE_TEXT||u?.controlComponent===l.ControlComponent.POST_TEXT||u?.controlComponent===l.ControlComponent.PREFIX||u?.controlComponent===l.ControlComponent.POSTFIX)for(let f=0;f<t.length;f++)t[f].control||(t[f].color=this.options.defaultColor);d&&(c[n]?.control?.type===l.ControlType.TEXTFIELD||c[n]?.control?.type===l.ControlType.TEXT)&&this.control.removePlaceholder(n),d||this.newSpliceElementList(c,R,i-n);const g=c[n]?.controlId||c[n-1]?.controlId||c[n+1]?.controlId;for(let f=0;f<t.length;f++){if(t[f]?.control?.type=="button"&&!t[f]?.control?.buttonText&&(t[f]?.controlComponent==="prefix"||t[f]?.controlComponent==="postfix"?(t[f].color="transparent",t[f].highlight="#1677FF"):(t[f].color="#fff",t[f].highlight="#1677FF")),t[f]?.type===l.ElementType.MENSTRUAL_HISTORY||t[f]?.type===l.ElementType.FETAL_HEART_POSITION||t[f]?.type===l.ElementType.TOOTH_POSITION||t[f]?.type===l.ElementType.MACRO||t[f]?.type===l.ElementType.CUSTOM_MACRO||t[f]?.type===l.ElementType.REUSABLE_ITEM||t[f]?.type===l.ElementType.SUB_TEMPLATE||t[f]?.type===l.ElementType.SPECIAL_SYMBOLS){t[f].controlComponent=l.ControlComponent.VALUE;let T=c[n]?.controlId;T||(T=c[n-1]?.controlId),T||(T=c[n+1]?.controlId),!t[f].controlId&&T&&(t[f].controlId=T)}g&&t[f]?.control&&t[f].controlId&&t[f].controlId!==g&&(t[f].originControlId=g)}this.newSpliceElementList(c,R,0,t),s=n+t.length}else{const c=this.getElementList(),d=n===i,R=n+1;if(c[R]?.control?.type=="TextField"||c[n]?.control?.type=="TextField"){d||this.newSpliceElementList(c,R,i-n);for(let u=0;u<t.length;u++)if(t[u]?.type===l.ElementType.MENSTRUAL_HISTORY||t[u]?.type===l.ElementType.FETAL_HEART_POSITION||t[u]?.type===l.ElementType.TOOTH_POSITION||t[u]?.type===l.ElementType.MACRO||t[u]?.type===l.ElementType.CUSTOM_MACRO||t[u]?.type===l.ElementType.REUSABLE_ITEM||t[u]?.type===l.ElementType.SUB_TEMPLATE||t[u]?.type===l.ElementType.SPECIAL_SYMBOLS){t[u].controlComponent=l.ControlComponent.VALUE;const h=c[n]?.controlId||c[R]?.controlId;!t[u].controlId&&h&&(t[u].controlId=h)}this.newSpliceElementList(c,R,0,t),s=n+t.length}else{d||this.spliceElementList(c,R,i-n);for(let h=0;h<t.length;h++)t[h]?.control?.type=="button"&&!t[h]?.control?.buttonText&&(t[h]?.controlComponent==="prefix"||t[h]?.controlComponent==="postfix"?(t[h].color="transparent",t[h].highlight="#1677FF"):(t[h].color="#fff",t[h].highlight="#1677FF"));this.spliceElementList(c,R,0,t),s=n+t.length;const u=c[R-1];t[0].listId&&u&&!u.listId&&u?.value===_&&(!u.type||u.type===l.ElementType.TEXT)&&(c.splice(n,1),s-=1)}}~s&&(this.range.setRange(s,s),this.render({curIndex:s,isSubmitHistory:r}))}appendElementList(t,e={}){if(!t.length)return;Vt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:r=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:r})}spliceElementList(t,e,n,i,r){const{isIgnoreDeletedRule:s=!1}=r||{},{group:a,modeRule:c}=this.options;if(n>0){const d=e+n,u=t[d]?.listId;if(u&&t[e-1]?.listId!==u){let h=d;for(;h<t.length;){const g=t[h];if(g.listId!==u||g.value===_)break;delete g.listId,delete g.listType,delete g.listStyle,h++}}if(!s&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const h=this.getTd()?.deletable;let g=d-1;for(;g>=e;){const f=t[g];(f?.hide||f?.control?.hide||f?.area?.hide||h!==!1&&f?.control?.deletable!==!1&&(!f.controlId||this.mode!==l.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&f?.title?.deletable!==!1&&(a.deletable!==!1||!f.groupIds?.length)&&(f?.area?.deletable!==!1||f?.areaIndex!==0))&&t.splice(g,1),g--}}else t.splice(e,n)}if(i?.length){let d=t[e];for(let R=0;R<i.length;R++)!i[R].controlComponent&&d?.controlComponent&&(i[R].controlId=d.controlId,i[R].control=d.control,i[R].controlComponent=d.controlComponent),d=i[R];Er(t,e,i)}}newSpliceElementList(t,e,n,i,r){const{isIgnoreDeletedRule:s=!1}=r||{},{group:a,modeRule:c}=this.options;if(n>0){const R=e+n,h=t[R]?.listId;if(h&&t[e-1]?.listId!==h){let g=R;for(;g<t.length;){const f=t[g];if(f.listId!==h||f.value===_)break;delete f.listId,delete f.listType,delete f.listStyle,g++}}if(!s&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const g=this.getTd()?.deletable;let f=R-1;for(;f>=e;){const T=t[f];(T?.hide||T?.control?.hide||T?.area?.hide||g!==!1&&T?.control?.deletable!==!1&&(!T.controlId||this.mode!==l.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&T?.title?.deletable!==!1&&(a.deletable!==!1||!T.groupIds?.length)&&(T?.area?.deletable!==!1||T?.areaIndex!==0))&&t.splice(f,1),f--}}else t.splice(e,n)}const d=t[e]?.controlId;if(i?.length){for(let R=0;R<i.length;R++)d&&(i[R].originControlId=d);Er(t,e,i)}}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getMacroParticle(){return this.macroParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getMenstrualHistoryParticle(){return this.menstrualHistoryParticle}getFetalHeartPositionParticle(){return this.fetalHeartPositionParticle}getToothPositionParticle(){return this.toothPositionParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}setCommand(t){this.command=t}getCommand(){return this.command}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,r=!!n&&i!==n;r&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const s=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),r&&this.setMode(i),s}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){this.elementList.length&&setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===l.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===l.PageMode.PAGING){const{height:i}=this.options,r=this.getPagePixelRatio(),s=this.pageList[0];s.style.height=`${i}px`,s.height=i*r,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(l.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((s,a)=>{s.width=n*e,s.height=i*e,s.style.width=`${n}px`,s.style.height=`${i}px`,s.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[a])});const r=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!r,curIndex:r?.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,r)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),r=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,a)=>{s.width=i*n,s.height=r*n,s.style.width=`${i}px`,s.style.height=`${r}px`,this._initPageContext(this.ctxList[a])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,s)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,this._initPageContext(this.ctxList[s])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t;let n=this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(n=this.pageRowList[e].flatMap(r=>r.elementList)),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t);console.log(this.elementList,"所有元素");const{extraPickAttrs:n}=t,i={header:Pt(e.header,{extraPickAttrs:n,editorOptions:this.options}),main:Pt(e.main,{extraPickAttrs:n,isClassifyArea:!0,editorOptions:this.options}),footer:Pt(e.footer,{extraPickAttrs:n,editorOptions:this.options}),graffiti:e.graffiti};return{version:Qe,data:i,options:at(this.options)}}setValue(t,e){const{header:n,main:i,footer:r}=at(t);if(!n&&!i&&!r)return;const{isSetCursor:s=!1}=e||{};[n,i,r].forEach(d=>{d&&Vt(d,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:r}),this.historyManager.recovery();const c=s?i?.length?i.length-1:0:void 0;c!==void 0&&this.range.setRange(c,c),this.render({curIndex:c,isSetCursor:s,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(de,l.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${z}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const r=this.getPagePixelRatio();i.width=e*r,i.height=n*r,i.style.cursor="text";const s=i.getContext("2d");this._initPageContext(s),this.pageList.push(i),this.ctxList.push(s)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,r=t.font||i,s=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${s*e}px ${r}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:r}=this.options,s=t.size||e;let a=1;return s<12?a=s/12:s>30&&(a=1+(s-30)/30),n*a*(t.rowMargin??i)*r}computeRowList(t){const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:r=!1,startX:s=0,startY:a=0,pageHeight:c=0,mainOuterHeight:d=0,surroundElementList:R=[]}=t,{defaultSize:u,scale:h,imgCaption:g,table:{tdPadding:f,defaultTrMinHeight:T},defaultTabWidth:p}=this.options,m=this.getDefaultBasicRowMarginHeight(),L=document.createElement("canvas").getContext("2d"),P=this.listParticle.computeListStyle(L,n),O=[],S=this._collectTextControlValueSet(n);n.length&&O.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:n?.[0]?.rowFlex||n?.[1]?.rowFlex});let F=s,N=a,V=0,Y,X=0,b=0;for(let E=0;E<n.length;E++){const C=O[O.length-1],M=n[E];this.clearElementEffect(M);const y=this.getElementRowMargin(M),W={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},D=C.offsetX||M.listId&&P.get(M.listId)||0,U=e-D,Q=C.elementList.length===1;if(F+=Q?D:0,N+=Q&&C.offsetY||0,(M.control?.type===l.ControlType.TEXTFIELD||M.control?.type===l.ControlType.TEXT)&&!this.isDesignMode()&&(M.controlComponent===l.ControlComponent.PRETEXTFIX||M.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||M.controlComponent===l.ControlComponent.POSTTEXTFIX||M.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||M.controlComponent===l.ControlComponent.TEXTFIXLABEL||M.controlComponent===l.ControlComponent.PLACEHOLDER||M.controlComponent===l.ControlComponent.PREFIX||M.controlComponent===l.ControlComponent.POSTFIX)){const v=M.control?.type===l.ControlType.TEXTFIELD,K=M.controlId,w=!!K&&!!S?.has(K);v?this.mode===l.EditorMode.EDIT?M.hide=!1:M.hide=!0:this.mode===l.EditorMode.EDIT?M.hide=!1:this.mode===l.EditorMode.FORM?M.controlComponent===l.ControlComponent.PLACEHOLDER||M.controlComponent===l.ControlComponent.TEXTFIXLABEL?M.hide=w:M.hide=!1:M.hide=!0}if((M.hide||M.control?.hide||M.area?.hide)&&!this.isDesignMode()){const v=C.elementList[C.elementList.length-1];W.height=v?.metrics.height||this.options.defaultSize*h,W.boundingBoxAscent=v?.metrics.boundingBoxAscent||0,W.boundingBoxDescent=v?.metrics.boundingBoxDescent||0}else if(M.type===l.ElementType.IMAGE||M.type===l.ElementType.LATEX)if(M.imgDisplay===l.ImageDisplay.SURROUND||M.imgDisplay===l.ImageDisplay.FLOAT_TOP||M.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)W.width=0,W.height=0,W.boundingBoxDescent=0;else{const v=M.width*h,K=M.height*h;if(v>U){const w=K*U/v;M.width=U/h,M.height=w/h,W.width=U,W.height=w,W.boundingBoxDescent=w}else W.width=v,W.height=K,W.boundingBoxDescent=K;if(M.imgCaption?.value){const w=M.imgCaption.size||g.size,Z=M.imgCaption.top??g.top,J=(w+Z)*h;W.boundingBoxAscent+=J}}else if(M.type===l.ElementType.TABLE){const v=M.tdPadding||f;if(M.pagingId){let x=E+1,A=0;for(;x<n.length;){const $=n[x];if($.pagingId===M.pagingId){const B=$.trList.filter(Ct=>!Ct.pagingRepeat).filter(Ct=>(Ct.tdList=Ct.tdList.filter(Xt=>{if(Xt.originalId){for(let pt=0;pt<M.trList.length;pt++){const yt=M.trList[pt],Yt=yt.tdList.find(({id:St})=>St===Xt.originalId);if(Yt){Xt.value[0]?.type===l.ElementType.SPLIT_TAG&&Xt.value.splice(0,1),Yt.value.push(...Xt.value.map(St=>this.updateElementTableInfo(St,M,yt,Yt))),Yt.rowspan=Yt.originalRowspan??Yt.rowspan;break}}return!1}return!0}),!Ct.originalId));M.trList.push(...B),M.height+=$.height,x++,A++}else break}A&&n.splice(E+1,A)}M.pagingIndex=M.pagingIndex??0,this.tableParticle.computeTrHeight(M,x=>this.computeRowList({innerWidth:(x.width-(v[1]+v[3]))*h,elementList:x.value,isFromTable:!0,isPagingMode:i})),M.trList?.forEach(x=>{x.tdList.forEach(A=>{this.tdMap.set(A.id,A)})});const K=this.tableParticle.getTableHeight(M),w=this.tableParticle.getTableWidth(M);M.width=w,M.height=K;const Z=w*h,J=K*h;if(W.width=Z,W.height=J,W.boundingBoxDescent=J,W.boundingBoxAscent=-y,n[E+1]?.type===l.ElementType.TABLE&&(W.boundingBoxAscent-=y),i){const x=this.getHeight(),A=this.getMainOuterHeight();let $=A;for(let pt=0;pt<O.length;pt++){const yt=O[pt],Yt=yt.offsetY||0;yt.height+$+Yt>x||O[pt-1]?.isPageBreak?$=A+yt.height+Yt:$+=yt.height+Yt}const B=y*2,Ct=M.trList[0].height*h;($+Ct+B>x||M.pagingIndex!==0&&M.trList[0].pagingRepeat||n[E-1]?.type===l.ElementType.PAGE_BREAK)&&($=A);let Xt=x-($+B);if(J>Xt){const pt=M.trList;let yt=0,Yt=0,St=0;for(let Tt=0;Tt<pt.length;Tt++){const It=pt[Tt],Kt=It.height*h;if($+B+St+Kt>x){const Qt=It;let be=0;const jt={...at(Qt),id:lt(),originalId:Qt.originalId??Qt.id,minHeight:void 0,tdList:M.colgroup.map((mt,oe)=>{if(be--,be>0)return;const Ht=Qt.tdList.find(Ve=>Ve.colIndex===oe),Jt=Ht??this.tableParticle.findPreRowSpanTd(pt,Tt,oe);Ht&&(be=Ht.colspan);const Je=lt();return Jt.originalRowspan=Jt.rowspan,Ht?{...Ht,id:Je,originalId:Ht.originalId??Ht.id,linkTdPrevId:Ht.id,tdIndex:oe,original:Jt}:{id:Je,originalId:Jt.originalId??Jt.id,linkTdPrevId:Jt.id,tdIndex:oe,colIndex:oe,colspan:1,rowspan:1,value:[],rowList:[],original:Jt}}).filter(mt=>!!mt)},ce=jt.tdList,_t=ce.map(mt=>mt.original);_t.forEach((mt,oe)=>{const Ht=[];let Jt=Xt;if(mt.rowspan>1){const Ve=pt.slice(mt.trIndex,mt.trIndex+Tt-mt.trIndex);Jt+=Ve.reduce((ff,Tf)=>Tf.height*h+ff,0)}for(;mt.mainHeight*h>Jt&&mt.rowList?.length;){const Ve=mt.rowList.pop();mt.value.splice(mt.value.length-Ve.elementList.length),Ht.unshift(Ve),mt.mainHeight-=Ve.height}const Je=ce[oe];Je.rowList=Ht,Je.value=Ht.map(Ve=>Ve.elementList).flat()});let Pe=!0;const Ei=Qt.tdList.some(mt=>mt.rowList?.length),br=jt.tdList.some(mt=>mt.rowList?.length),Xi=Qt.minHeight>Xt;if(br||Xi){(Ei||!br&&Xi)&&(Xi&&(Qt.originalMinHeight=Qt.minHeight,Qt.minHeight=Xt,jt.minHeight=Math.max(Qt.originalMinHeight-Xt,T)),jt.tdList.forEach(mt=>{mt.original.linkTdNextId=mt.id,mt.value.length&&mt.value[0].value!==_&&mt.value.unshift({...mt.original.value.slice(-1).pop(),value:_,type:l.ElementType.SPLIT_TAG})}),pt.splice(yt+1,0,jt),yt+=1,Yt=pt.length-yt,Pe=!1),_t.forEach(mt=>{if(mt.rowspan>1){const oe=mt.rowspan-(Tt-mt.trIndex);mt.rowspan=Tt-mt.trIndex+(Ei?1:0);const Ht=jt.tdList.find(Jt=>Jt.colIndex===mt.colIndex);Ei?Ht.rowspan=oe:(Ht.original.linkTdNextId=Ht.id,Qt.tdList.push({...mt,...Ht,rowspan:oe}),Qt.tdList.sort((Jt,Je)=>Jt.colIndex-Je.colIndex),Ht.value=[])}}),Pe&&_t.forEach((mt,oe)=>{mt.value.push(...ce[oe].value)});break}}yt=Tt+1,Yt=pt.length-yt,St+=Kt,Xt-=Kt}if(Yt){const Tt=pt.splice(yt,Yt),It=M.pagingId||lt();M.pagingId=It;const Kt=at(M);Kt.originalId=M.originalId??M.id,Kt.pagingId=It,Kt.pagingIndex=M.pagingIndex+1;const Qt=pt.filter(ce=>ce.pagingRepeat);if(Qt.length){const ce=at(Qt);ce.forEach(_t=>_t.id=lt()),Tt.unshift(...ce)}Kt.trList=Tt,Kt.id=lt(),Kt.trList?.forEach(ce=>{ce.tdList.forEach(_t=>{if(delete _t.valueStartIndex,_t.linkTdPrevId){const Pe=this.getTdById(_t.linkTdPrevId);_t.valueStartIndex=Pe?(Pe.valueStartIndex??0)+Pe.value.length:0,this.splitTdValueMap.has(_t.originalId)?this.splitTdValueMap.get(_t.originalId).push(..._t.value):Pe&&this.splitTdValueMap.set(_t.originalId,[...Pe.value,..._t.value])}_t.value.forEach(Pe=>this.updateElementTableInfo(Pe,Kt,ce,_t))})}),this.spliceElementList(n,E+1,0,[Kt]),this.tableParticle.computeTrHeight(M);const be=this.tableParticle.getTableHeight(M),jt=be*h;M.height=be,W.height=jt,W.boundingBoxDescent=jt}}if(M.pagingId){const pt=this.position.getPositionContext();if(pt.isTable){let yt=-1,Yt=-1,St=E;for(;St<n.length;){const Tt=n[St];if(Tt.pagingId!==M.pagingId)break;const It=Tt.trList.findIndex(Kt=>Kt.id===pt.trId);if(~It){yt=St,Yt=It;break}St++}~yt&&(pt.index=yt,pt.trIndex=Yt,this.position.setPositionContext(pt))}}}this.initTableElementIndex(M,E)}else if(M.type===l.ElementType.SEPARATOR){const{separator:{lineWidth:v}}=this.options,K=M.lineWidth||v;M.width=U/h,W.width=U,W.height=K*h,W.boundingBoxAscent=-y,W.boundingBoxDescent=-y+W.height}else if(M.type===l.ElementType.PAGE_BREAK)M.width=U/h,W.width=U,W.height=u;else if(M.type===l.ElementType.RADIO||M.controlComponent===l.ControlComponent.RADIO){const{width:v,height:K,gap:w}=this.options.radio,Z=v+w*2;M.width=Z,W.width=Z*h,W.height=K*h}else if(M.type===l.ElementType.CHECKBOX||M.controlComponent===l.ControlComponent.CHECKBOX){const{width:v,height:K,gap:w}=this.options.checkbox,Z=v+w*2;M.width=Z,W.width=Z*h,W.height=K*h}else if(M.type===l.ElementType.MENSTRUAL_HISTORY){const v=this.menstrualHistoryParticle.computeSize(M);M.width=v.width/h,W.width=v.width,W.height=v.height,W.boundingBoxAscent=v.height,W.boundingBoxDescent=0}else if(M.type===l.ElementType.FETAL_HEART_POSITION){const v=this.fetalHeartPositionParticle.computeSize(M);M.width=v.width/h,W.width=v.width,W.height=v.height,W.boundingBoxAscent=v.height/2,W.boundingBoxDescent=v.height/2}else if(M.type===l.ElementType.TOOTH_POSITION){const v=this.toothPositionParticle.computeSize(M);M.width=v.width/h,W.width=v.width,W.height=v.height,W.boundingBoxAscent=v.height/2,W.boundingBoxDescent=v.height/2}else if(M.type===l.ElementType.TAB)W.width=p*h,W.height=u*h,W.boundingBoxDescent=0,W.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(L,L.font);else if(M.type===l.ElementType.BLOCK){if(!M.width)W.width=U;else{const v=M.width*h;W.width=Math.min(v,U)}W.height=M.height*h,W.boundingBoxDescent=W.height,W.boundingBoxAscent=0}else if(M.type===l.ElementType.LABEL){const{defaultSize:v,label:{defaultPadding:K}}=this.options;L.font=this.getElementFont(M);const w=this.textParticle.measureText(L,M);W.width=(w.width+K[1]+K[3])*h,W.height=(M.size||v)*h,W.boundingBoxDescent=0,W.boundingBoxAscent=(K[0]+w.actualBoundingBoxAscent)*h}else if(M.type===l.ElementType.MACRO||M.type===l.ElementType.CUSTOM_MACRO||M.type===l.ElementType.REUSABLE_ITEM||M.type===l.ElementType.SUB_TEMPLATE){const{defaultSize:v}=this.options;L.font=this.getElementFont(M);const K=this.getMode(),w=K==="edit",Z=K==="form";if(w){const J=M.label||M.value||"";L.font=this.getElementFont(M);const x=L.measureText(J),A=8*h,$=4*h;W.width=x.width+A*2;const B=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent;W.height=B+$*2;const Ct=this.textParticle.measureBasisWord(L,this.getElementFont(M));W.boundingBoxAscent=Ct.actualBoundingBoxAscent*h,W.boundingBoxDescent=Ct.actualBoundingBoxDescent*h}else if(M.type===l.ElementType.CUSTOM_MACRO){const J=M.macroConfig,x=J?.value||"";if(Z){const A=J?.type||"text",$=this.textParticle.measureText(L,M),B=M.label||"";if(A==="select"){const Ct=x||`请选择${B}`,Xt=L.measureText(Ct),pt=L.measureText("[").width,yt=6*h+2*h;W.width=pt+Xt.width+yt+pt}else{const Ct=x||`请输入${B}`,Xt=L.measureText(Ct),pt=L.measureText("[").width;W.width=pt+Xt.width+pt}W.height=(M.size||v)*h,W.boundingBoxDescent=$.actualBoundingBoxDescent*h,W.boundingBoxAscent=$.actualBoundingBoxAscent*h}else{const A=M.label||"",$=x||`请输入${A}`,B=L.measureText($);W.width=B.width,W.height=(M.size||v)*h,W.boundingBoxDescent=B.actualBoundingBoxDescent,W.boundingBoxAscent=B.actualBoundingBoxAscent}}else if(M.type===l.ElementType.REUSABLE_ITEM){const x=M.reusableItemConfig?.value||"",A=M.label||"";if(Z){const $=this.textParticle.measureText(L,M),B=x||`获取 ${A}`,Ct=L.measureText(B),Xt=L.measureText("[").width;W.width=Xt+Ct.width+Xt,W.height=(M.size||v)*h,W.boundingBoxDescent=$.actualBoundingBoxDescent*h,W.boundingBoxAscent=$.actualBoundingBoxAscent*h}else{const $=x||`获取 ${A}`,B=L.measureText($);W.width=B.width,W.height=(M.size||v)*h,W.boundingBoxDescent=B.actualBoundingBoxDescent,W.boundingBoxAscent=B.actualBoundingBoxAscent}}else if(M.type===l.ElementType.SUB_TEMPLATE){const J=M.label||"子模板";if(Z){const x=this.textParticle.measureText(L,M),A=L.measureText(J),$=8*h;W.width=A.width+$*2,W.height=(M.size||v)*h,W.boundingBoxDescent=x.actualBoundingBoxDescent*h,W.boundingBoxAscent=x.actualBoundingBoxAscent*h}else{const x=L.measureText(J);W.width=x.width,W.height=(M.size||v)*h,W.boundingBoxDescent=x.actualBoundingBoxDescent,W.boundingBoxAscent=x.actualBoundingBoxAscent}}else{const J=M.label||"",x=M.value||`获取 ${J}`,A=L.measureText(x);W.width=A.width,W.height=(M.size||v)*h,W.boundingBoxDescent=A.actualBoundingBoxDescent,W.boundingBoxAscent=A.actualBoundingBoxAscent}}else{const v=M.size||u;(M.type===l.ElementType.SUPERSCRIPT||M.type===l.ElementType.SUBSCRIPT)&&(M.actualSize=Math.ceil(v*.6)),W.height=(M.actualSize||v)*h,L.font=this.getElementFont(M);const K=this.textParticle.measureText(L,M);W.width=K.width*h,M.letterSpacing&&(W.width+=M.letterSpacing*h);const w=this.textParticle.measureBasisWord(L,M.font);W.boundingBoxAscent=w.actualBoundingBoxAscent*h,W.boundingBoxDescent=w.actualBoundingBoxDescent*h,M.type===l.ElementType.SUPERSCRIPT?W.boundingBoxAscent+=W.height/2:M.type===l.ElementType.SUBSCRIPT&&(W.boundingBoxDescent+=W.height/2)}const G=!M.hide&&(M.imgDisplay!==l.ImageDisplay.INLINE&&M.type===l.ElementType.IMAGE||M.type===l.ElementType.LATEX)?W.height+y:W.boundingBoxAscent+y,H=y+W.boundingBoxAscent+W.boundingBoxDescent+y,j=Object.assign(M,{metrics:W,left:0,style:this.getElementFont(M,h)});j.control?.minWidth&&(j.controlComponent&&(b+=W.width),j.controlComponent===l.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:C,rowElement:j,availableWidth:U,controlRealWidth:b}),b=0));const st=n[E-1];let it=n[E+1],nt=C.width+W.width;if(this.options.wordBreak===l.WordBreak.BREAK_WORD&&(!st?.type||st?.type===l.ElementType.TEXT)&&(!M.type||M.type===l.ElementType.TEXT)){const v=`${st?.value||""}${M.value}`;if(this.WORD_LIKE_REG.test(v)){const{width:w,endElement:Z}=this.textParticle.measureWord(L,n,E),J=w*h;Z&&J<=U?(nt+=J,it=Z):st&&(nt+=J)}const K=this.textParticle.measurePunctuationWidth(L,it);nt+=K*h}M.listId&&(M.listId!==Y?X=0:M.value===_&&!M.listWrap&&X++),Y=M.listId;const et=this.position.setSurroundPosition({pageNo:V,rowElement:j,row:C,rowElementRect:{x:F,y:N,height:H,width:W.width},availableWidth:U,surroundElementList:R});F=et.x,nt+=et.rowIncreaseWidth,F+=W.width;let dt=!1;if(this.mode===l.EditorMode.FORM&&M.control?.type===l.ControlType.BUTTON&&M.controlComponent===l.ControlComponent.PREFIX&&C.elementList.filter(v=>v.controlId!==M.controlId).length>0){const v=M.controlId;if(n.some(w=>w.controlId===`${v}_text`&&w.control?.type===l.ControlType.BUTTON)){let w=0;for(let Z=E;Z<n.length;Z++){const J=n[Z];if(J.controlId!==v)break;L.font=this.getElementFont(J);const x=this.textParticle.measureText(L,J);if(w+=x.width*h,J.controlComponent===l.ControlComponent.POSTFIX)break}for(let Z=0;Z<n.length;Z++){const J=n[Z];if(J.controlId===`${v}_text`){L.font=this.getElementFont(J);const x=this.textParticle.measureText(L,J);w+=x.width*h}}dt=C.width+w>U}}const tt=M.type===l.ElementType.SEPARATOR||M.type===l.ElementType.TABLE||st?.type===l.ElementType.TABLE||st?.type===l.ElementType.BLOCK||M.type===l.ElementType.BLOCK||st?.imgDisplay===l.ImageDisplay.INLINE||M.imgDisplay===l.ImageDisplay.INLINE||st?.listId!==M.listId||st?.areaId!==M.areaId&&!M.area?.hide||M.control?.flexDirection===l.FlexDirection.COLUMN&&(M.controlComponent===l.ControlComponent.CHECKBOX||M.controlComponent===l.ControlComponent.RADIO)&&st?.controlComponent===l.ControlComponent.VALUE||E!==0&&M.value===_&&!M.area?.hide||dt,ht=nt>U,ut=tt||ht;if(ut){const v={width:W.width,height:H,startIndex:E,elementList:[j],ascent:G,rowIndex:C.rowIndex+1,rowFlex:n[E]?.rowFlex||n[E+1]?.rowFlex,isPageBreak:M.type===l.ElementType.PAGE_BREAK};if(j.controlComponent!==l.ControlComponent.PREFIX&&j.control?.indentation===l.ControlIndentation.VALUE_START){const K=C.elementList.findIndex(w=>w.controlId===j.controlId&&w.controlComponent!==l.ControlComponent.PREFIX);if(~K){const Z=this.position.computeRowPosition({row:C,innerWidth:this.getInnerWidth()})[K];Z&&(v.offsetX=Z.coordinate.leftTop[0])}}M.listId&&(v.isList=!0,v.offsetX=P.get(M.listId),v.listIndex=X),v.offsetY=!r&&M.area?.top&&M.areaId!==n[E-1]?.areaId?M.area.top*h:0,O.push(v)}else C.width+=W.width,E===0&&(nn(n[1])||n[1]?.areaId)?(C.height=m,C.ascent=m):C.height<H&&(C.height=H,C.ascent=G),C.elementList.push(j);if((ut||E===n.length-1)&&(C.isWidthNotEnough=ht&&!tt,!C.isSurround&&(st?.rowFlex===l.RowFlex.JUSTIFY||st?.rowFlex===l.RowFlex.ALIGNMENT&&C.isWidthNotEnough))){const v=C.elementList[0]?.value===_?C.elementList.slice(1):C.elementList,K=(U-C.width)/(v.length-1);for(let w=0;w<v.length-1;w++){const Z=v[w];Z.metrics.width+=K}C.width=U}if(ut){F=s,N+=C.height,i&&!r&&c&&(N-a+d+H>c||M.type===l.ElementType.PAGE_BREAK)&&(N=a,jl(R,V),V+=1),j.left=0;const v=O[O.length-1];F=this.position.setSurroundPosition({pageNo:V,rowElement:j,row:v,rowElementRect:{x:F,y:N,height:H,width:W.width},availableWidth:U,surroundElementList:R}).x,F+=W.width}}return O}_collectTextControlValueSet(t){if(this.isDesignMode()||this.mode===l.EditorMode.EDIT)return null;const e=new Set;for(let i=0;i<t.length;i++){const r=t[i];r.controlId&&(r.control?.type===l.ControlType.TEXT||r.control?.type===l.ControlType.TEXTFIELD)&&e.add(r.controlId)}const n=new Set;for(let i=0;i<t.length;i++){const r=t[i];r.controlId&&r.controlComponent===l.ControlComponent.VALUE&&e.has(r.controlId)&&n.add(r.controlId)}return n}_computePageList(){const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),r=this.getMainOuterHeight();let s=r,a=0;if(e===l.PageMode.CONTINUITY){t[0]=this.rowList,s+=this.rowList.reduce((u,h)=>u+h.height+(h.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],R=Number(d.style.height.replace("px",""));if(s>R)d.style.height=`${s}px`,d.height=s*c;else{const u=s<i?i:s;d.style.height=`${u}px`,d.height=u*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],R=d.offsetY||0;if(d.height+R+s>i||this.rowList[c-1]?.isPageBreak){if(Number.isInteger(n)&&a>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}s=r+d.height+R,t.push([d]),a++}else s+=d.height+R,t[a].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:r}=e,s=this.getDefaultBasicRowMarginHeight(),a=this.getHighlightMarginHeight();for(let c=0;c<n.length;c++){const d=n[c];for(let R=0;R<d.elementList.length;R++){const u=d.elementList[R],h=d.elementList[R-1],g=u.highlight||this.control.getControlHighlight(r,d.startIndex+R);if(g){h&&h.highlight&&h.highlight!==u.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[f,T]}}=i[d.startIndex+R],p=u.left||0;this.highlight.recordFillInfo(t,f-p,T+s-a,u.metrics.width+p,d.height-2*s+2*a,g)}else h?.highlight&&this.highlight.render(t)}this.highlight.render(t)}}validateNumber(t){return/^\d+$/.test(t)}drawRow(t,e){this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:r,lineBreak:s,whiteSpace:a}=this.options,{rowList:c,pageNo:d,elementList:R,positionList:u,startIndex:h,zone:g,isDrawLineBreak:f=!s.disabled,td:T,isDrawWhiteSpace:p=!a.disabled}=e,m=this.isPrintMode(),I=this.isGraffitiMode(),{isCrossRowCol:L,tableId:P}=this.range.getRange();let O=h;for(let S=0;S<c.length;S++){const F=c[S],N={x:0,y:0,width:0,height:0};let V=null;for(let Y=0;Y<F.elementList.length;Y++){const X=F.elementList[Y],b=X.metrics,{ascent:E,coordinate:{leftTop:[C,M]}}=u[F.startIndex+Y],y=F.elementList[Y-1];if((X.hide||X.control?.hide||X.area?.hide)&&!this.isDesignMode())this.textParticle.complete();else if(X.type===l.ElementType.IMAGE)this.textParticle.complete(),X.imgDisplay!==l.ImageDisplay.SURROUND&&X.imgDisplay!==l.ImageDisplay.FLOAT_TOP&&X.imgDisplay!==l.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.TABLE)L&&(N.x=C,N.y=M,V=X),this.tableParticle.render(t,X,C,M);else if(X.type===l.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.MACRO||X.type===l.ElementType.CUSTOM_MACRO||X.type===l.ElementType.REUSABLE_ITEM||X.type===l.ElementType.SUB_TEMPLATE)this.textParticle.complete(),this.macroParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.DATE){const H=F.elementList[Y+1];(!y||y.dateId!==X.dateId)&&this.textParticle.complete(),this.textParticle.record(t,X,C,M+E),(!H||H.dateId!==X.dateId)&&this.textParticle.complete()}else X.type===l.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,X,C,M+E)):X.type===l.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,X,C,M+E)):X.type===l.ElementType.SEPARATOR?this.separatorParticle.render(t,X,C,M):X.type===l.ElementType.PAGE_BREAK?this.mode!==l.EditorMode.CLEAN&&!m&&this.pageBreakParticle.render(t,X,C,M):X.type===l.ElementType.CHECKBOX||X.controlComponent===l.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F})):X.type===l.ElementType.RADIO||X.controlComponent===l.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F})):X.type===l.ElementType.MENSTRUAL_HISTORY?(this.textParticle.complete(),this.menstrualHistoryParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F,element:X})):X.type===l.ElementType.FETAL_HEART_POSITION?(this.textParticle.complete(),this.fetalHeartPositionParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F,element:X})):X.type===l.ElementType.TOOTH_POSITION?(this.textParticle.complete(),this.toothPositionParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F,element:X})):X.type===l.ElementType.TAB?this.textParticle.complete():X.rowFlex===l.RowFlex.ALIGNMENT||X.rowFlex===l.RowFlex.JUSTIFY?(this.textParticle.record(t,X,C,M+E),this.textParticle.complete()):X.type===l.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,d,X,C,M+E)):(X.left&&this.textParticle.complete(),this.textParticle.record(t,X,C,M+E),(X.width||X.letterSpacing||Zr.test(X.value))&&this.textParticle.complete());if(f&&!m&&this.mode!==l.EditorMode.CLEAN&&!F.isWidthNotEnough&&Y===F.elementList.length-1&&this.lineBreakParticle.render(t,X,C,M+F.height/2),p&&vr.test(X.value)&&this.whiteSpaceParticle.render(t,X,C,M+F.height/2),X.control?.border){y?.control?.border&&y.controlId!==X.controlId&&this.control.drawBorder(t);const H=this.getElementRowMargin(X);this.control.recordBorderInfo(C,M+H,X.metrics.width,F.height-2*H)}else y?.control?.border&&this.control.drawBorder(t);if(X.control?.type===l.ControlType.TEXT){const H=X.controlComponent===l.ControlComponent.VALUE,j=X.controlComponent===l.ControlComponent.POSTFIX||X.controlComponent===l.ControlComponent.POST_TEXT;H&&X.control?.underline&&((!y||y.controlId!==X.controlId||y.controlComponent!==l.ControlComponent.VALUE&&y.controlComponent!==l.ControlComponent.PLACEHOLDER)&&this.control.startTextFieldUnderline(X.controlId,C,M+F.height),this.control.recordTextFieldUnderlineWidth(X.metrics.width)),j&&this.control.drawTextFieldUnderline(t)}else y?.control?.type===l.ControlType.TEXT&&this.control.drawTextFieldUnderline(t);if((X.underline||X.control?.underline)&&X.controlComponent!==l.ControlComponent.PLACEHOLDER&&!(X.control?.type===l.ControlType.TEXT&&X.control?.underline)){y?.type===l.ElementType.SUBSCRIPT&&X.type!==l.ElementType.SUBSCRIPT&&this.underline.render(t);const H=this.getElementRowMargin(X),j=X.left||0;let st=0;X.type===l.ElementType.SUBSCRIPT&&(st=this.subscriptParticle.getOffsetY(X));const it=X.control?.underline?this.options.underlineColor:X.color;this.underline.recordFillInfo(t,C-j,M+F.height-H+st,b.width+j,0,it,X.textDecoration?.style)}else(y?.underline||y?.control?.underline)&&(y?.control?.type===l.ControlType.TEXT&&y?.control?.underline||this.underline.render(t));if(X.strikeout){if(!X.type||$t.includes(X.type)){y&&(y.type===l.ElementType.SUBSCRIPT&&X.type!==l.ElementType.SUBSCRIPT||y.type===l.ElementType.SUPERSCRIPT&&X.type!==l.ElementType.SUPERSCRIPT||this.getElementSize(y)!==this.getElementSize(X))&&this.strikeout.render(t);const H=this.textParticle.measureBasisWord(t,this.getElementFont(X));let j=M+E+H.actualBoundingBoxDescent*n-b.height/2;X.type===l.ElementType.SUBSCRIPT?j+=this.subscriptParticle.getOffsetY(X):X.type===l.ElementType.SUPERSCRIPT&&(j+=this.superscriptParticle.getOffsetY(X)),this.strikeout.recordFillInfo(t,C,j,b.width)}}else y?.strikeout&&this.strikeout.render(t);const{zone:W,splitTdRange:D}=this.range.getRange();let{startIndex:U,endIndex:Q}=this.range.getRange(),G=!1;if(T&&D&&[T.originalId,T.id].includes(D.originalId)&&(G=!0,U=D.startIndex-(T.valueStartIndex??0),Q=D.endIndex-(T.valueStartIndex??0)),W===g&&U!==Q&&U<=O&&O<=Q){const H=this.position.getPositionContext();if(!H.isTable&&!X.tdId||H.tdId===X.tdId||G)if(U===O){const j=R[U+1];j&&j.value===_&&(N.x=C+b.width,N.y=M,N.height=F.height,N.width+=this.options.rangeMinWidth)}else{let j=b.width;j===0&&F.elementList.length===1&&(j=this.options.rangeMinWidth),N.width||(N.x=C,N.y=M,N.height=F.height),N.width+=j}}if(!r.disabled&&X.groupIds&&this.group.recordFillInfo(X,C,M,b.width,F.height),O++,X.type===l.ElementType.TABLE&&!X.hide){const H=X.tdPadding||i,j=H[1]+H[3];for(let st=0;st<X.trList.length;st++){const it=X.trList[st];for(let nt=0;nt<it.tdList.length;nt++){const et=it.tdList[nt];this.drawRow(t,{elementList:et.value,positionList:et.positionList,rowList:et.rowList,pageNo:d,startIndex:0,innerWidth:(et.width-j)*n,zone:g,isDrawLineBreak:f,td:et})}}}}if(F.isList&&this.listParticle.drawListStyle(t,F,u[F.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!m&&!I){if(N.width&&N.height){const{x:Y,y:X,width:b,height:E}=N;this.range.render(t,Y,X,b,E)}if(L&&V&&V.id===P){const{coordinate:{leftTop:[Y,X]}}=u[F.startIndex];this.tableParticle.drawRange(t,V,Y,X)}}}}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:r,pageNo:s}=e;for(let a=0;a<i.length;a++){const c=i[a],d=c.element;if((s===c.pageNo||c.zone===l.EditorZone.HEADER||c.zone==l.EditorZone.FOOTER)&&d.imgDisplay&&r.includes(d.imgDisplay)&&d.type===l.ElementType.IMAGE){const R=d.imgFloatPosition;this.imageParticle.render(t,d,R.x*n,R.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:n,rowList:i,pageNo:r}=t,{inactiveAlpha:s,pageMode:a,header:c,footer:d,pageNumber:R,lineNumber:u,pageBorder:h}=this.options,g=this.mode===l.EditorMode.PRINT,f=this.getInnerWidth(),T=this.ctxList[r];T.globalAlpha=this.zone.isMainActive()?1:s,this._clearPage(r),(!g||!this.options.modeRule[l.EditorMode.PRINT]?.backgroundDisabled)&&this.background.render(T,r),g||this.area.render(T,r),a!==l.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(T,r),g||this.margin.render(T,r),this._drawFloat(T,{pageNo:r,imgDisplays:[l.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(T,r);const p=i[0]?.startIndex;this.drawRow(T,{elementList:e,positionList:n,rowList:i,pageNo:r,startIndex:p,innerWidth:f,zone:l.EditorZone.MAIN}),this.getIsPagingMode()&&(c.disabled||this.header.render(T,r),R.disabled||this.pageNumber.render(T,r),d.disabled||this.footer.render(T,r)),this._drawFloat(T,{pageNo:r,imgDisplays:[l.ImageDisplay.FLOAT_TOP,l.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(T,r),this.elementList.length<=1&&!this.elementList[0]?.listId&&this.placeholder.render(T),u.disabled||this.lineNumber.render(T,r),h.disabled||this.pageBorder.render(T),this.badge.render(T,r),this.isGraffitiMode()&&this.graffiti.render(T,r)}_disconnectLazyRender(){this.lazyRenderIntersectionObserver?.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const r=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[r],pageNo:r})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){const e=bt(),n=[],i=(b,E)=>{n.push({label:b,duration:bt()-E})};this.renderCount++;let r;const{endIndex:s,isCrossRowCol:a}=this.range.getRange(),c=this.position.getPositionContext();if(a)r=this.getOriginalElementList()[c.index];else{const b=~s?s:0,E=this.getElementList();r=je(E,b)}const{header:d,footer:R}=this.options,{isSubmitHistory:u=!0,isSetCursor:h=!0,isCompute:g=!0,isLazy:f=!0,isInit:T=!1,isSourceHistory:p=!1,isFirstRender:m=!1,isDel:I=!1}=t||{};let{curIndex:L}=t||{};const{traceLabel:P}=t||{},O=this.getInnerWidth(),S=this.getIsPagingMode(),F=this.pageRowList.length;if(g){if(this.splitTdValueMap.clear(),this.tdMap.clear(),this.position.setFloatPositionList([]),S){if(!d.disabled){const j=bt();this.header.compute(),i("header.compute",j)}if(!R.disabled){const j=bt();this.footer.compute(),i("footer.compute",j)}}const b=this.getMargins(),E=this.getHeight(),C=this.header.getExtraHeight(),M=this.getMainOuterHeight(),y=b[3],W=b[0]+C,D=wo(this.elementList),U=bt();this.rowList=this.computeRowList({startX:y,startY:W,pageHeight:E,mainOuterHeight:M,isPagingMode:S,innerWidth:O,surroundElementList:D,elementList:this.elementList}),i("computeRowList",U);const Q=bt();this.pageRowList=this._computePageList(),i("computePageList",Q);const G=bt();this.position.computePositionList(),i("computePositionList",G);const H=bt();if(this.area.compute(),i("area.compute",H),!this.isPrintMode()){const j=this.search.getSearchKeyword();if(j){const it=bt();this.search.compute(j),i("search.compute",it)}const st=bt();this.control.computeHighlightList(),i("control.computeHighlightList",st)}if(this.isGraffitiMode()){const j=bt();this.graffiti.compute(),i("graffiti.compute",j)}}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let b=0;b<this.pageRowList.length;b++)this.pageList[b]||this._createPage(b);const N=this.pageRowList.length,V=this.pageList.length;if(V>N){const b=V-N;this.ctxList.splice(N,b),this.pageList.splice(N,b).forEach(E=>E.remove())}const Y=bt();if(f&&S?this._lazyRender():this._immediateRender(),i(f&&S?"lazyRender":"immediateRender",Y),h){if(g&&r?.tableId){const{index:b}=c,C=this.getOriginalElementList()[b];if(r.tableId!==C?.id){const y=this.findTableChildrenElement(!0,r.tableId,r);y&&c.index!==y.originalIndex&&(c.index=y.originalIndex,c.tableId=y.table.id,c.trIndex=y.trIndex,c.trId=y.tr.id,c.tdIndex=y.tdIndex,c.tdId=y.td.id,L=y.elementIndex,this.position.setPositionContext(c),this.range.setRange(L,L),this.updateTableTool())}const M=this.getElementList();M[s]!==r&&(L=M.findIndex(y=>y===r))}L=this.setCursor(L)}else this.range.getIsSelection()&&this.cursor.focus();if(I){let b;const E=this.position.getPositionContext();b=this.range.getRange().startIndex-1,E.index=b}(u&&!m||L!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(L);const X=bt();Oo(()=>{const b=bt();this.range.setRangeStyle(),g&&this.control.getActiveControl()&&this.control.reAwakeControl(),g&&!this.isReadonly()&&this.getMode()!==l.EditorMode.FORM&&c.isTable&&this.getOriginalElementList()[c.index].type===l.ElementType.TABLE&&this.tableTool.render(),g&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),F!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(u||p)&&!T&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"));const E=bt();Co(this.options,P||"render",E-e,[...n,{label:"nextTick.wait",duration:b-X},{label:"nextTick.callback",duration:E-b}],{isCompute:g,pageCount:this.pageRowList.length})}),h&&this.fixPosition()}fixPosition(t=!1){let e;const n=this.position.getPositionContext();if(n.isTable){const i=this.getElementList(),r=this.range.getRange().startIndex;if(t||r>=i.length){const s=this.getTd(),a=n.index+(t?-1:1),d=this.getOriginalElementList()[a];if(!d?.trList)return;e=r-i.length;for(let R=0;R<d.trList.length;R++){const u=d.trList[R],h=u.tdList.find(g=>t?s?.linkTdPrevId===g.id:s?.id===g.linkTdPrevId);if(h){n.index=a,n.trIndex=R,n.tableId=d.id,n.trId=u.id,n.tdId=h?.id,e=t?h.value.length-1:e+(h.value[0]?.type===l.ElementType.SPLIT_TAG?1:0);break}}if(this.position.setPositionContext(n),this.range.setRange(e,e),this.setCursor(e),e===0)return this.fixPosition(t);this.updateTableTool()}}return e}setCursor(t){const e=this.position.getPositionContext(),n=this.position.getPositionList(),i=this.getElementList();if(e.isTable){const{index:s,trIndex:a,tdIndex:c}=e,R=this.getOriginalElementList()[s].trList?.[a].tdList[c].positionList;t===void 0&&R&&(t=R.length-1);const u=R?.[t];this.position.setCursorPosition(u||null)}else t!==void 0&&t>=n.length&&(t=n.length-1),this.position.setCursorPosition(t!==void 0&&t>=0?n[t]:null);let r=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const s=i[t];if(s&&rl.includes(s.type)){r=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(s,a)}}return this.cursor.drawCursor({isShow:r}),t}submitHistory(t){const e=this.position.getPositionContext(),n=Uo(this.elementList),i=Uo(this.header.getElementList()),r=Uo(this.footer.getElementList()),s=at(this.range.getRange()),a=this.pageNo,c=at(e),d=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(d),this.setPageNo(a),this.position.setPositionContext(at(c)),this.header.setElementList(at(i)),this.footer.setElementList(at(r)),this.elementList=at(n),this.range.replaceRange(at(s)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}updateTableTool(){if(this.getMode()===l.EditorMode.FORM){this.getTableTool().dispose();return}if(this.position.getPositionContext().isTable){const t=this.position.getPositionList();t.length&&(this.setPageNo(t[0].pageNo),this.getTableTool().render())}}initTableElementIndex(t,e){t.trList?.forEach((n,i)=>{n.tdList.forEach((r,s)=>{r.tableIndex=e,r.tableId=t.id,r.trIndex=i,r.trId=n.id,r.tdIndex=s,this.tdMap.set(r.id,r)})})}clearElementEffect(t){t.trList?.forEach(e=>{e.minHeight=e.originalMinHeight??e.minHeight,delete e.originalMinHeight,e.tdList.forEach(n=>{delete n.linkTdNextId})})}updateElementTableInfo(t,e,n,i){return t.tableId=e.id,t.trId=n.id,t.tdId=i.id,t}findTableChildrenElement(t,e,n){const i=this.position.getPositionContext(),{index:r}=i,s=this.getOriginalElementList();let a=r;t&&(a=r>s.length?s.length-1:r);for(let c=a;t?c>=0:c<s.length;t?c--:c++){const d=s[c];if(d&&[d.originalId,d.id].includes(e))for(const[R,u]of d.trList.entries())for(const[h,g]of u.tdList.entries()){const f=g.value.findIndex(typeof n=="function"?n:T=>T===n);if(f>=0)return{originalIndex:c,table:d,tr:u,trIndex:R,td:g,tdIndex:h,elementIndex:f}}}}getTdById(t){return this.tdMap.get(t)}getLinkTdPrevHasValue(t){const e=this.getTdById(t);if(e)return e.value.length?e:this.getLinkTdPrevHasValue(e.linkTdPrevId)}getFirstLinkTd(t){const e=this.getTdById(t);return e?.linkTdPrevId?this.getLastLinkTd(e.linkTdPrevId):e}getLastLinkTd(t){const e=this.getTdById(t);return e?.linkTdNextId?this.getLastLinkTd(e.linkTdNextId):e}removeLinkTd(t,e){const n=this.getTdById(e);if(n){if(n.linkTdPrevId){const i=this.getTdById(n.linkTdPrevId);i&&(delete i.linkTdNextId,this.removeLinkTd(t,n.linkTdPrevId))}if(n.linkTdNextId){const i=this.getTdById(n.linkTdNextId);i&&(delete i.linkTdPrevId,this.removeLinkTd(t,n.linkTdNextId))}t[n.tableIndex].trList[n.trIndex].tdList.splice(n.tdIndex,1),this.initTableElementIndex(t[n.tableIndex],n.tableIndex)}}removeLinkTdControl(t,e){const n=this.getTdById(t);if(n){for(let i=0;i<n.value.length;i++)n.value[i].control===e&&(n.value.splice(i,1),i--);n.linkTdNextId&&this.removeLinkTdControl(n.linkTdNextId,e)}}isSplitTd(t,e){return(!!t?.originalId||!!e?.originalId)&&(t?.originalId===e?.originalId||t?.id===e?.originalId||t?.originalId===e?.id)}getSplitTdValues(t){return this.splitTdValueMap.get(t)}removeSplitTdOtherRangeElements(){const{splitTdRange:t}=this.range.getRange();if(!t)return;const{startIndex:e,endIndex:n}=t;let i=this.getTd();if(i)if((i.valueStartIndex??0)>=e){let r=-1;for(;r<0;){const s=this.getTdById(i.linkTdPrevId);if(s){r=e-(s.valueStartIndex??0);const a=Math.max(0,r);this.spliceElementList(s.value,a+1,s.value.length-a-1),i=s}else r=0}}else{let r=1;for(;r>0;){const s=this.getTdById(i.linkTdNextId);if(s){const a=s.valueStartIndex??0;r=n-(a+s.value.length);const c=Math.min(s.value.length,n-a+1);this.spliceElementList(s.value,0,c),i=s}else r=0}}}getTablesByPagingId(t,e,n){const i=[],r=[];if(t[n].pagingId===e){i.push(n),r.push(t[n]);for(let s=n-1;s>=0&&t[s].pagingId===e;s--)r.unshift(t[s]),i.push(s);for(let s=n+1;s<t.length&&t[s].pagingId===e;s++)r.push(t[s]),i.push(s)}return{list:r,startIndex:i.sort()[0]}}}class Xr{executeMode;executeCut;executeCopy;executePaste;executeSelectAll;executeBackspace;executeSetRange;executeReplaceRange;executeSetPositionContext;executeForceUpdate;executeBlur;executeHideCursor;executeUndo;executeRedo;executePainter;executeApplyPainterStyle;executeFormat;executeFont;executeButton;executeEditElementAttribute;executeTriggerControlEditAttribute;executeCopyControl;executePasteControl;executeSize;executeSizeAdd;executeSizeMinus;executeBold;executeItalic;executeUnderline;executeStrikeout;executeSuperscript;executeSubscript;executeColor;executeHighlight;executeTitle;executeList;executeRowFlex;executeVertical;executeRowMargin;executeInsertTable;executeInsertTableTopRow;executeInsertTableBottomRow;executeInsertTableLeftCol;executeInsertTableRightCol;executeDeleteTableRow;executeDeleteTableCol;executeDeleteTable;executeMergeTableCell;executeCancelMergeTableCell;executeSplitVerticalTableCell;executeSplitHorizontalTableCell;executeTableTdVerticalAlign;executeTableBorderType;executeTableBorderColor;executeTableTdBorderType;executeTableTdSlashType;executeTableTdBackgroundColor;executeTableSelectAll;executeTableProperties;executeImage;executeHyperlink;executeDeleteHyperlink;executeCancelHyperlink;executeEditHyperlink;executeSeparator;executePageBreak;executeAddWatermark;executeDeleteWatermark;executeSearch;executeSearchNavigatePre;executeSearchNavigateNext;executeReplace;executePrint;executeReplaceImageElement;executeSaveAsImageElement;executeSetImageCrop;executeSetImageCaption;executeChangeImageDisplay;executePageMode;executePageScale;executePageScaleRecovery;executePageScaleMinus;executePageScaleAdd;executePaperSize;executePaperDirection;executeSetPaperMargin;executeSetMainBadge;executeSetAreaBadge;executeInsertElementList;executeInsertArea;executeSetAreaValue;executeSetAreaProperties;executeLocationArea;executeClearGraffiti;executeAppendElementList;executeUpdateElementById;executeDeleteElementById;executeSetValue;executeRemoveControl;executeTranslate;executeSetLocale;executeLocationCatalog;executeWordTool;executeSetHTML;executeSetGroup;executeDeleteGroup;executeLocationGroup;executeSetZone;executeSetControlValue;executeSetControlValueList;executeSetControlExtension;executeSetControlExtensionList;executeSetControlProperties;executeSetControlPropertiesList;executeSetControlHighlight;executeLocationControl;executeInsertControl;executeInsertTextField;executeJumpControl;executeUpdateOptions;executeSetFormModeTrace;executeInsertTitle;executeFocus;executeComputeElementListHeight;getCatalog;getImage;getPageMode;getOptions;getValue;getValueAsync;getAreaValue;getHTML;getText;getWordCount;getCursorPosition;getRemainingContentHeight;getRange;getRangeText;getRangeContext;getRangeRow;getRangeParagraph;getKeywordRangeList;getKeywordContext;getPaperMargin;getSearchNavigateInfo;getLocale;getGroupIds;getControlValue;getControlList;getContainer;getTitleValue;getPositionContextByEvent;getElementById;getMacroValue;getMacroList;setMacroValue;setMacroValueList;updateMacroProperties;locationMacro;insertSubTemplate;expandSubTemplate;collapseSubTemplate;toggleSubTemplate;constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeButton=t.buttonText.bind(t),this.executeEditElementAttribute=t.editElementAttribute.bind(t),this.executeTriggerControlEditAttribute=t.triggerControlEditAttribute.bind(t),this.executeCopyControl=t.copyControl.bind(t),this.executePasteControl=t.pasteControl.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeVertical=t.vertical.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeTableProperties=t.tableProperties.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeSetFormModeTrace=t.setFormModeTrace.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getPageMode=t.getPageMode.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeInsertTextField=t.insertTextField.bind(t),this.executeJumpControl=t.jumpControl.bind(t),this.getMacroValue=t.getMacroValue.bind(t),this.getMacroList=t.getMacroList.bind(t),this.setMacroValue=t.setMacroValue.bind(t),this.setMacroValueList=t.setMacroValueList.bind(t),this.updateMacroProperties=t.updateMacroProperties.bind(t),this.locationMacro=t.locationMacro.bind(t),this.insertSubTemplate=t.insertSubTemplate.bind(t),this.expandSubTemplate=t.expandSubTemplate.bind(t),this.collapseSubTemplate=t.collapseSubTemplate.bind(t),this.toggleSubTemplate=t.toggleSubTemplate.bind(t)}}function qh(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function tg(o,t){const{width:e,height:n,direction:i=l.PaperDirection.VERTICAL}=t,r=document.createElement("iframe");r.style.visibility="hidden",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.width="0",r.style.height="0",r.style.border="none",document.body.append(r);const s=r.contentWindow,a=s.document;a.open();const c=document.createElement("div"),d=qh(e,n);o.forEach(h=>{const g=document.createElement("img");g.style.width=i===l.PaperDirection.HORIZONTAL?d.height:d.width,g.style.height=i===l.PaperDirection.HORIZONTAL?d.width:d.height,g.src=h,c.append(g)});const R=document.createElement("style"),u=`
|
|
538
|
+
`,document.body.appendChild(a);const c=a.querySelector(".table-properties-modal__mask"),d=a.querySelector(".table-properties-modal__close"),R=a.querySelector(".btn-cancel"),u=a.querySelector(".btn-confirm"),h=()=>{a.remove()};c.addEventListener("click",h),d.addEventListener("click",h),R.addEventListener("click",h),u.addEventListener("click",()=>{const g=parseInt(a.querySelector("#tdPaddingTop").value)||0,f=parseInt(a.querySelector("#tdPaddingRight").value)||0,T=parseInt(a.querySelector("#tdPaddingBottom").value)||0,p=parseInt(a.querySelector("#tdPaddingLeft").value)||0;i.tdPadding=[g,f,T,p],h();const{endIndex:m}=this.range.getRange();this.draw.render({curIndex:m,isCompute:!0})})}}l.AreaMode=void 0,(function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"})(l.AreaMode||(l.AreaMode={}));class Jh{draw;zone;range;position;options;areaInfoMap=new Map;constructor(t){this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange();return this.draw.getElementList()[t]?.areaId||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!t?.area)return!1;switch(t.area.mode){case l.AreaMode.EDIT:return!1;case l.AreaMode.READONLY:return!0;case l.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:r,range:s}=t;if(this.zone.getZone()!==l.EditorZone.MAIN&&this.zone.setZone(l.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),s&&!this.getActiveAreaId()){const{startIndex:c,endIndex:d}=s,R=this.draw.getOriginalMainElementList();if(!R[c]||!R[d])return null;this.range.setRange(s.startIndex,s.endIndex)}else if(r===l.LocationPosition.BEFORE)this.range.setRange(0,0);else{const d=this.draw.getOriginalMainElementList().length-1;this.range.setRange(d,d)}const a=e||lt();return this.draw.insertElementList([{type:l.ElementType.AREA,value:"",areaId:a,valueList:n,area:at(i)}]),a}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const r of this.areaInfoMap){const{area:s,positionList:a}=r[1];if(s?.hide||!s?.backgroundColor&&!s?.borderColor&&!s?.placeholder)continue;const c=a.filter(f=>f.pageNo===e);if(!c.length)continue;t.translate(.5,.5);const d=c[0],R=c[c.length-1],u=n[3],h=Math.ceil(d.coordinate.leftTop[1]),g=Math.ceil(R.coordinate.rightBottom[1]-h);t.textBaseline="middle",s.backgroundColor&&(t.fillStyle=s.backgroundColor,t.fillRect(u,h,i,g)),s.borderColor&&(t.strokeStyle=s.borderColor,t.strokeRect(u,h,i,g)),s.placeholder&&a.length<=1&&new Cr(this.draw).render(t,{placeholder:{...Ai,...s.placeholder},startY:d.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],r=i.areaId;if(r){const s=this.areaInfoMap.get(r);s?(s.elementList.push(i),s.positionList.push(e[n])):this.areaInfoMap.set(r,{id:r,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:Mt(n.elementList)}:null}getContextByAreaId(t,e){const n=this.draw.getOriginalMainElementList();for(let i=0;i<n.length;i++){const r=n[i];if(e?.position===l.LocationPosition.OUTER_BEFORE){if(n[i+1]?.areaId!==t)continue}else if(e?.position===l.LocationPosition.AFTER){if(!(r.areaId===t&&n[i+1]?.areaId!==t))continue}else if(e?.position===l.LocationPosition.OUTER_AFTER){if(!(r.areaId!==t&&n[i-1]?.areaId===t))continue}else if(r.areaId!==t)continue;const s=this.position.getOriginalMainPositionList();return{range:{startIndex:i,endIndex:i},elementPosition:s[i]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const r=["top","hide"];Object.entries(t.properties).forEach(([s,a])=>{if(Ui(a))return;const c=s;n.area[c]=a,r.includes(c)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,r=this.draw.getOriginalMainElementList(),s=t.value;Vt([{type:l.ElementType.AREA,value:"",valueList:s,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(r,i[0].index,i.length,s,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class Bh{draw;options;imageCache;mainBadge;areaBadgeMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,r,s){if(this.imageCache.has(s)){const a=this.imageCache.get(s);t.drawImage(a,e,n,i,r)}else{const a=new Image;a.setAttribute("crossOrigin","Anonymous"),a.src=s,a.onload=()=>{this.imageCache.set(s,a),t.drawImage(a,e,n,i,r)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:r,top:s,width:a,height:c,value:d}=this.mainBadge,R=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),u=(r||i.left)*n,h=(s||i.top)*n+R;this._drawImage(t,u,h,a*n,c*n,d)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:r}=this.options;for(const s of n){const{positionList:a}=s[1],c=a[0];if(c.pageNo!==e)continue;const d=this.areaBadgeMap.get(s[0]);if(!d)continue;const{left:R,top:u,width:h,height:g,value:f}=d,T=(R||r.left)*i,p=(u||r.top)*i+c.coordinate.leftTop[1];this._drawImage(t,T,p,h*i,g*i,f)}}}}}class $h{draw;options;data;pageContainer;isDrawing=!1;startStroke=null;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const r=this.draw.getPageNo();let s=this.data.find(d=>d.pageNo===r);if(this.startStroke&&(s||(s={pageNo:r,strokes:[]},this.data.push(s)),s.strokes.push(this.startStroke),this.startStroke=null),!s?.strokes?.length)return;const{scale:a}=this.options;s.strokes[s.strokes.length-1].points.push(e/a,n/a),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){const n=this.data.find(a=>a.pageNo===e)?.strokes;if(!n?.length)return;const{graffiti:{defaultLineColor:i,defaultLineWidth:r},scale:s}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||i,t.lineWidth=(c.lineWidth||r)*s,t.moveTo(c.points[0]*s,c.points[1]*s);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*s,c.points[d+1]*s);t.stroke()}t.restore()}}const Sr=1024,zh=['[aria-modal="true"]','[role="dialog"]','[data-overlay-active="true"]',".ant-modal-root",".ant-modal-wrap",".ant-modal",".ant-drawer",".ant-select-dropdown",".ant-picker-dropdown",".ant-dropdown",".ant-popover",".ant-tooltip",".ant-cascader-dropdown",".ant-mentions-dropdown"].join(", ");function Er(o,t,e){for(let n=0;n<e.length;n+=Sr){const i=e.slice(n,n+Sr);o.splice(t+n,0,...i)}}class jh{container;pageContainer;pageList;ctxList;pageNo;renderCount;pagePixelRatio;mode;options;position;zone;elementList;listener;eventBus;override;i18n;canvasEvent;globalEvent;cursor;range;margin;background;badge;search;group;area;underline;strikeout;highlight;historyManager;previewer;imageParticle;laTexParticle;textParticle;tableParticle;tableTool;tableOperate;pageNumber;lineNumber;waterMark;placeholder;header;footer;hyperlinkParticle;labelParticle;macroParticle;dateParticle;separatorParticle;pageBreakParticle;superscriptParticle;subscriptParticle;checkboxParticle;radioParticle;menstrualHistoryParticle;fetalHeartPositionParticle;toothPositionParticle;blockParticle;listParticle;lineBreakParticle;whiteSpaceParticle;control;pageBorder;workerManager;scrollObserver;selectionObserver;imageObserver;graffiti;command;interactionPaused;overlayActiveCount;globalShortcutSuspended;LETTER_REG;WORD_LIKE_REG;rowList;pageRowList;painterStyle;painterOptions;visiblePageNoList;intersectionPageNo;lazyRenderIntersectionObserver;printModeData;splitTdValueMap=new Map;tdMap=new Map;constructor(t,e,n,i,r,s){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=r,this.override=s,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Yh(e.locale),this.historyManager=new _a(this),this.position=new xa(this),this.zone=new wh(this),this.range=new Ga(this),this.margin=new Ja(this),this.background=new Aa(this),this.badge=new Bh(this),this.search=new Ba(this),this.group=new vh(this),this.area=new Jh(this),this.underline=new za(this),this.strikeout=new $a(this),this.highlight=new ka(this),this.previewer=new Fh(this),this.imageParticle=new Qi(this),this.laTexParticle=new Hi(this),this.textParticle=new ja(this),this.tableParticle=new ec(this),this.tableTool=new nc(this),this.tableOperate=new kh(this),this.pageNumber=new sn(this),this.lineNumber=new _h(this),this.waterMark=new Rc(this),this.placeholder=new Cr(this),this.header=new rc(this,n.header),this.footer=new Zh(this,n.footer),this.hyperlinkParticle=new oc(this),this.labelParticle=new ic(this),this.macroParticle=new sc(this),this.dateParticle=new yh(this),this.separatorParticle=new cc(this),this.pageBreakParticle=new dc(this),this.superscriptParticle=new lc,this.subscriptParticle=new ac,this.checkboxParticle=new Lh(this),this.radioParticle=new Ih(this),this.menstrualHistoryParticle=new Ph(this),this.fetalHeartPositionParticle=new Mh(this),this.toothPositionParticle=new Oh(this),this.blockParticle=new bh(this),this.listParticle=new Qh(this),this.lineBreakParticle=new Yn(this),this.whiteSpaceParticle=new Kh(this),this.control=new mh(this),this.pageBorder=new xh(this),this.graffiti=new $h(this,n.graffiti),this.scrollObserver=new qa(this),this.selectionObserver=new tc(this),this.imageObserver=new Dh,new Hh(this),this.canvasEvent=new Ka(this),this.cursor=new la(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new Ha(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new Nh(this),new Ah(this);const{letterClass:a}=e;this.LETTER_REG=new RegExp(`[${a.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${a.map(c=>`[^${c}][${c}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.interactionPaused=!1,this.overlayActiveCount=0,this.globalShortcutSuspended=!1,this.mode===l.EditorMode.PRINT&&this.setPrintData(),this.mode,l.EditorMode.FORM,this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData={header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()};const t=at(this.printModeData);["header","main","footer"].forEach(r=>{t[r]=this.control.filterAssistElement(t[r])});const n=t,i=this.removeStrikeout(n);t.main=i.main.filter(r=>!r.strikeout),this.setEditorData(i)}removeStrikeout(t){if(Array.isArray(t))return t.map(e=>this.removeStrikeout(e)).filter(e=>!(e&&typeof e=="object"&&"strikeout"in e&&e.strikeout===!0));if(t&&typeof t=="object"){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this.removeStrikeout(t[n]));return e}return t}clearPrintData(){this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null)}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){if(this.mode===t)return;this.mode=t,this.options.mode=t;const e=new Map,n=r=>{r.forEach(s=>{s.controlId&&(s.controlComponent==="value"&&e.set(s.controlId,!0),s.checked&&e.set(s.controlId,!0))})};n(this.elementList),this.elementList.forEach(r=>{r.type==="table"&&r.trList?.forEach(s=>{s.tdList?.forEach(a=>{n(a.value)})})});const i=r=>{r.forEach(s=>{if(!(!s.control&&!s.controlId)&&(s.controlComponent==="value"&&s.strikeout&&(t===l.EditorMode.PRINT?s.hide=!0:s.hide=!1),!!s.control&&!(s.type!=="control"&&s.control.type!=="button"))){if(s.control.type==="TextField"&&(s.controlComponent==="placeholder"||s.controlComponent==="preTextFix"||s.controlComponent==="preTextFixText"||s.controlComponent==="postTextFix"||s.controlComponent==="postTextFixText"||s.controlComponent==="textFixLabel")&&(t===l.EditorMode.EDIT?s.hide=!1:s.hide=!0),s.control.type==="text"&&(s.controlComponent==="placeholder"||s.controlComponent==="prefix"||s.controlComponent==="postfix")&&(t===l.EditorMode.EDIT||t===l.EditorMode.FORM?s.hide=!1:s.hide=!0),s.control.type==="number"||s.control.type==="select"||s.control.type==="date"||s.control.type==="checkbox"||s.control.type==="radio"){if(s.controlComponent==="placeholder"||s.controlComponent==="prefix"||s.controlComponent==="postfix"){const c=e.get(s.controlId);s.control.type==="select"&&t===l.EditorMode.PRINT||t===l.EditorMode.PRINT&&!c?s.hide=!0:s.hide=!1}s.control.type==="number"&&s.controlComponent==="value"&&(t===l.EditorMode.PRINT&&s.strikeout?s.hide=!0:t!==l.EditorMode.PRINT&&s.strikeout&&(s.hide=!1))}s.control.type==="button"&&(s.hide=!1,s.control.hide=!1),s.control.type==="menstrualHistory"&&(s.controlComponent==="prefix"||s.controlComponent==="postfix")&&(t===l.EditorMode.PRINT?s.hide=!0:s.hide=!1)}})};i(this.elementList),this.elementList.forEach(r=>{r.type==="table"&&r.trList.forEach(s=>{s.tdList.forEach(a=>{i(a.value)})})}),t===l.EditorMode.FORM?(this.elementList.filter(r=>r.type==="control").map(r=>{r.control?.type==="button"&&r.control.buttonText&&(r.color="#1677FF",r.highlight="transparent")}),this.hideTextFieldWhitespace(this.elementList,!0),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):t===l.EditorMode.EDIT?(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!1,!0)),t===l.EditorMode.PRINT?(this.elementList.filter(r=>r?.control?.type==="button").map(r=>{(r?.controlComponent==="prefix"||r?.controlComponent==="postfix")&&(r.color="transparent",r.highlight="transparent"),r?.controlComponent==="value"&&!r.control.buttonText&&(r.color="transparent",r.highlight="transparent")}),this.setPrintData()):(this.clearPrintData(),this.elementList.filter(r=>r?.control?.type==="button").map(r=>{(r?.controlComponent==="prefix"||r?.controlComponent==="postfix")&&!r.control.buttonText&&r.type==="control"&&(r.color="transparent",r.highlight="#1677FF"),r?.controlComponent==="value"&&!r.control.buttonText&&(r.color="#fff",r.highlight="#1677FF"),r?.type==="text"&&r.control.buttonText&&(r.color="#000"),r?.type==="control"&&r?.controlComponent==="value"&&r.control.buttonText&&(r.color="#000",r.highlight="transparent")})),this.mode===l.EditorMode.PRINT&&this.clearPrintData(),this.clearSideEffect(),this.control.destroyControl(),this.range.clearRange(),this.render({isSetCursor:!1,isSubmitHistory:!1})}hideTextFieldWhitespace(t,e){const n=r=>r?/^[\s\u00A0\u2000-\u200B\u3000\n\r\t]+$/.test(r):!1;(r=>{for(let s=0;s<r.length;s++){const a=r[s];if(a.type===l.ElementType.TABLE&&a.trList)for(const c of a.trList)for(const d of c.tdList)this.hideTextFieldWhitespace(d.value,e);a.control?.type===l.ControlType.TEXTFIELD&&a.controlComponent===l.ControlComponent.VALUE&&n(a.value)&&(a.hide=e)}})(t)}updateTextFieldPlaceholderVisibility(t,e,n){const i=[l.ControlType.TEXT,l.ControlType.TEXTFIELD,l.ControlType.SELECT,l.ControlType.DATE,l.ControlType.CHECKBOX,l.ControlType.RADIO,l.ControlType.NUMBER];(s=>{let a=0;for(;a<s.length;){const c=s[a];if(c.type===l.ElementType.TABLE&&c.trList)for(const d of c.trList)for(const R of d.tdList)this.updateTextFieldPlaceholderVisibility(R.value,e,n);if(c.control?.type&&i.includes(c.control.type)&&(c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PRE_TEXT)){const d=c.controlId,R=c.control.type;let u=!1,h=!1,g=!1;const f=[],T=[],p=[];let m=-1,I=a;for(;I<s.length;){const L=s[I];if(L.controlId!==d)break;if((L.controlComponent===l.ControlComponent.PREFIX||L.controlComponent===l.ControlComponent.PRETEXTFIX||L.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT)&&T.push(I),L.controlComponent===l.ControlComponent.VALUE&&L.value&&L.value.trim()&&(u=!0),L.controlComponent===l.ControlComponent.VALUE&&(L.type===l.ElementType.MENSTRUAL_HISTORY||L.type===l.ElementType.FETAL_HEART_POSITION||L.type===l.ElementType.TOOTH_POSITION||L.type===l.ElementType.MACRO||L.type===l.ElementType.CUSTOM_MACRO)&&(u=!0),L.controlComponent===l.ControlComponent.VALUE&&L.control&&L.control.type!==R&&(h=!0),L.controlComponent===l.ControlComponent.PLACEHOLDER&&(g=!0,f.push(I)),L.controlComponent===l.ControlComponent.POSTFIX||L.controlComponent===l.ControlComponent.POSTTEXTFIX||L.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT){p.push(I),m=I;break}I++}if(!u&&!h)if(g&&f.length>0)for(const L of f)s[L].hide=!e;else e&&c.control?.placeholder&&(m>0?this.control.addPlaceholder(m-1):this.control.addPlaceholder(a));if(n)if(e&&u){for(const L of T)s[L].hide=!0;for(const L of p)s[L].hide=!0}else if(e){for(const L of T)s[L].hide=!1;for(const L of p)s[L].hide=!1}else{for(const L of T)s[L].hide=!0;for(const L of p)s[L].hide=!0}else{for(const L of T)s[L].hide=!1;for(const L of p)s[L].hide=!1}a=I}a++}})(t)}isReadonly(){if(this.area.getActiveAreaInfo()?.area?.mode)return this.area.isReadonly();switch(this.mode){case l.EditorMode.DESIGN:return!1;case l.EditorMode.READONLY:case l.EditorMode.PRINT:case l.EditorMode.GRAFFITI:return!0;case l.EditorMode.FORM:if(this.control.getIsRangeWithinControl()){const t=this.getElementList(),{startIndex:e}=this.range.getRange();if(t[e]?.control?.type===l.ControlType.TEXTFIELD)return!0}return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){if(this.mode===l.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if(this.getTd()?.disabled)return!0;if(t===e){const r=n[t],s=n[t+1];return!!(r?.title?.disabled&&s?.title?.disabled&&r.titleId===s.titleId||r?.control?.disabled&&s?.control?.disabled&&r.controlId===s.controlId)}return n.slice(t+1,e+1).some(r=>r.title?.disabled||r.control?.disabled)}isDesignMode(){return this.mode===l.EditorMode.DESIGN}isPrintMode(){return this.mode===l.EditorMode.PRINT}isGraffitiMode(){return this.mode===l.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===l.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===l.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,s=this.getOriginalElementList()[e],a=s.trList[n].tdList[i],c=this.getTdPadding(s);return a.width-c[1]-c[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===l.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(t){const{table:{tdPadding:e},scale:n}=this.options;return(t?.tdPadding||e).map(r=>r*n)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getEventTarget(t){return t instanceof Element?t:t instanceof Node?t.parentElement:null}isTargetInsideEditor(t){const e=this.getEventTarget(t);return e?this.container.contains(e)?!0:!!Wi(e,n=>!!n&&n.nodeType===1&&!!n.getAttribute(de)):!1}isTargetInsideExternalOverlay(t){const e=this.getEventTarget(t);return!e||this.isTargetInsideEditor(e)?!1:!!e.closest(zh)}pauseInteraction(){this.interactionPaused=!0,this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect()}resumeInteraction(){this.interactionPaused=!1}setOverlayActive(t){this.overlayActiveCount=t?1:0,t&&(this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect())}suspendGlobalShortcut(t){this.globalShortcutSuspended=t}isInteractionSuspended(){return this.interactionPaused||this.overlayActiveCount>0}isGlobalShortcutActive(){return!this.globalShortcutSuspended&&!this.isInteractionSuspended()}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return t[n].trList[i].tdList[r].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return t[n]?.trList?.[i].tdList[r].value||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}getTdByPosition(t){const{index:e,trIndex:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementTextField(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.getElementList(),{isSubmitHistory:s=!0}=e;Vt(t,{isHandleFirstElement:!1,editorOptions:this.options});let a=-1,c=this.control.getActiveControl();if(!c&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),c=this.control.getActiveControl()),c&&this.control.getIsRangeWithinControl()){const d=n===i,R=n+1;d||this.newSpliceElementList(r,R,i-n),this.newSpliceElementList(r,R,0,t),a=n+t.length}else{const d=n===i,R=n+1;d||this.newSpliceElementList(r,R,i-n),this.newSpliceElementList(r,R,0,t),a=n+t.length;const u=r[R-1];t[0].listId&&u&&!u.listId&&u?.value===_&&(!u.type||u.type===l.ElementType.TEXTFIELD)&&(r.splice(n,1),a-=1)}this.control.destroyControl(),~a&&(this.range.setRange(a,a),this.render({curIndex:a,isSubmitHistory:s}))}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:r=!0}=e;Vt(t,{isHandleFirstElement:!1,editorOptions:this.options});let s=-1,a=this.control.getActiveControl();if(!a&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),a=this.control.getActiveControl()),a&&this.control.getIsRangeWithinControl()){const c=this.getElementList(),d=n===i,R=n+1,u=c[n];if(u?.controlComponent===l.ControlComponent.PRE_TEXT||u?.controlComponent===l.ControlComponent.POST_TEXT||u?.controlComponent===l.ControlComponent.PREFIX||u?.controlComponent===l.ControlComponent.POSTFIX)for(let f=0;f<t.length;f++)t[f].control||(t[f].color=this.options.defaultColor);d&&(c[n]?.control?.type===l.ControlType.TEXTFIELD||c[n]?.control?.type===l.ControlType.TEXT)&&this.control.removePlaceholder(n),d||this.newSpliceElementList(c,R,i-n);const g=c[n]?.controlId||c[n-1]?.controlId||c[n+1]?.controlId;for(let f=0;f<t.length;f++){if(t[f]?.control?.type=="button"&&!t[f]?.control?.buttonText&&(t[f]?.controlComponent==="prefix"||t[f]?.controlComponent==="postfix"?(t[f].color="transparent",t[f].highlight="#1677FF"):(t[f].color="#fff",t[f].highlight="#1677FF")),t[f]?.type===l.ElementType.MENSTRUAL_HISTORY||t[f]?.type===l.ElementType.FETAL_HEART_POSITION||t[f]?.type===l.ElementType.TOOTH_POSITION||t[f]?.type===l.ElementType.MACRO||t[f]?.type===l.ElementType.CUSTOM_MACRO||t[f]?.type===l.ElementType.REUSABLE_ITEM||t[f]?.type===l.ElementType.SUB_TEMPLATE||t[f]?.type===l.ElementType.SPECIAL_SYMBOLS){t[f].controlComponent=l.ControlComponent.VALUE;let T=c[n]?.controlId;T||(T=c[n-1]?.controlId),T||(T=c[n+1]?.controlId),!t[f].controlId&&T&&(t[f].controlId=T)}g&&t[f]?.control&&t[f].controlId&&t[f].controlId!==g&&(t[f].originControlId=g)}this.newSpliceElementList(c,R,0,t),s=n+t.length}else{const c=this.getElementList(),d=n===i,R=n+1;if(c[R]?.control?.type=="TextField"||c[n]?.control?.type=="TextField"){d||this.newSpliceElementList(c,R,i-n);for(let u=0;u<t.length;u++)if(t[u]?.type===l.ElementType.MENSTRUAL_HISTORY||t[u]?.type===l.ElementType.FETAL_HEART_POSITION||t[u]?.type===l.ElementType.TOOTH_POSITION||t[u]?.type===l.ElementType.MACRO||t[u]?.type===l.ElementType.CUSTOM_MACRO||t[u]?.type===l.ElementType.REUSABLE_ITEM||t[u]?.type===l.ElementType.SUB_TEMPLATE||t[u]?.type===l.ElementType.SPECIAL_SYMBOLS){t[u].controlComponent=l.ControlComponent.VALUE;const h=c[n]?.controlId||c[R]?.controlId;!t[u].controlId&&h&&(t[u].controlId=h)}this.newSpliceElementList(c,R,0,t),s=n+t.length}else{d||this.spliceElementList(c,R,i-n);for(let h=0;h<t.length;h++)t[h]?.control?.type=="button"&&!t[h]?.control?.buttonText&&(t[h]?.controlComponent==="prefix"||t[h]?.controlComponent==="postfix"?(t[h].color="transparent",t[h].highlight="#1677FF"):(t[h].color="#fff",t[h].highlight="#1677FF"));this.spliceElementList(c,R,0,t),s=n+t.length;const u=c[R-1];t[0].listId&&u&&!u.listId&&u?.value===_&&(!u.type||u.type===l.ElementType.TEXT)&&(c.splice(n,1),s-=1)}}~s&&(this.range.setRange(s,s),this.render({curIndex:s,isSubmitHistory:r}))}appendElementList(t,e={}){if(!t.length)return;Vt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:r=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:r})}spliceElementList(t,e,n,i,r){const{isIgnoreDeletedRule:s=!1}=r||{},{group:a,modeRule:c}=this.options;if(n>0){const d=e+n,u=t[d]?.listId;if(u&&t[e-1]?.listId!==u){let h=d;for(;h<t.length;){const g=t[h];if(g.listId!==u||g.value===_)break;delete g.listId,delete g.listType,delete g.listStyle,h++}}if(!s&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const h=this.getTd()?.deletable;let g=d-1;for(;g>=e;){const f=t[g];(f?.hide||f?.control?.hide||f?.area?.hide||h!==!1&&f?.control?.deletable!==!1&&(!f.controlId||this.mode!==l.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&f?.title?.deletable!==!1&&(a.deletable!==!1||!f.groupIds?.length)&&(f?.area?.deletable!==!1||f?.areaIndex!==0))&&t.splice(g,1),g--}}else t.splice(e,n)}if(i?.length){let d=t[e];for(let R=0;R<i.length;R++)!i[R].controlComponent&&d?.controlComponent&&(i[R].controlId=d.controlId,i[R].control=d.control,i[R].controlComponent=d.controlComponent),d=i[R];Er(t,e,i)}}newSpliceElementList(t,e,n,i,r){const{isIgnoreDeletedRule:s=!1}=r||{},{group:a,modeRule:c}=this.options;if(n>0){const R=e+n,h=t[R]?.listId;if(h&&t[e-1]?.listId!==h){let g=R;for(;g<t.length;){const f=t[g];if(f.listId!==h||f.value===_)break;delete f.listId,delete f.listType,delete f.listStyle,g++}}if(!s&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const g=this.getTd()?.deletable;let f=R-1;for(;f>=e;){const T=t[f];(T?.hide||T?.control?.hide||T?.area?.hide||g!==!1&&T?.control?.deletable!==!1&&(!T.controlId||this.mode!==l.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&T?.title?.deletable!==!1&&(a.deletable!==!1||!T.groupIds?.length)&&(T?.area?.deletable!==!1||T?.areaIndex!==0))&&t.splice(f,1),f--}}else t.splice(e,n)}const d=t[e]?.controlId;if(i?.length){for(let R=0;R<i.length;R++)d&&(i[R].originControlId=d);Er(t,e,i)}}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getMacroParticle(){return this.macroParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getMenstrualHistoryParticle(){return this.menstrualHistoryParticle}getFetalHeartPositionParticle(){return this.fetalHeartPositionParticle}getToothPositionParticle(){return this.toothPositionParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}setCommand(t){this.command=t}getCommand(){return this.command}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,r=!!n&&i!==n;r&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const s=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),r&&this.setMode(i),s}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){this.elementList.length&&setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===l.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===l.PageMode.PAGING){const{height:i}=this.options,r=this.getPagePixelRatio(),s=this.pageList[0];s.style.height=`${i}px`,s.height=i*r,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(l.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((s,a)=>{s.width=n*e,s.height=i*e,s.style.width=`${n}px`,s.style.height=`${i}px`,s.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[a])});const r=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!r,curIndex:r?.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,r)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),r=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,a)=>{s.width=i*n,s.height=r*n,s.style.width=`${i}px`,s.style.height=`${r}px`,this._initPageContext(this.ctxList[a])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,s)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,this._initPageContext(this.ctxList[s])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t;let n=this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(n=this.pageRowList[e].flatMap(r=>r.elementList)),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t);console.log(this.elementList,"所有元素");const{extraPickAttrs:n}=t,i={header:Mt(e.header,{extraPickAttrs:n,editorOptions:this.options}),main:Mt(e.main,{extraPickAttrs:n,isClassifyArea:!0,editorOptions:this.options}),footer:Mt(e.footer,{extraPickAttrs:n,editorOptions:this.options}),graffiti:e.graffiti};return{version:Qe,data:i,options:at(this.options)}}setValue(t,e){const{header:n,main:i,footer:r}=at(t);if(!n&&!i&&!r)return;const{isSetCursor:s=!1}=e||{};[n,i,r].forEach(d=>{d&&Vt(d,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:r}),this.historyManager.recovery();const c=s?i?.length?i.length-1:0:void 0;c!==void 0&&this.range.setRange(c,c),this.render({curIndex:c,isSetCursor:s,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(de,l.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${z}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const r=this.getPagePixelRatio();i.width=e*r,i.height=n*r,i.style.cursor="text";const s=i.getContext("2d");this._initPageContext(s),this.pageList.push(i),this.ctxList.push(s)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,r=t.font||i,s=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${s*e}px ${r}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:r}=this.options,s=t.size||e;let a=1;return s<12?a=s/12:s>30&&(a=1+(s-30)/30),n*a*(t.rowMargin??i)*r}computeRowList(t){const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:r=!1,startX:s=0,startY:a=0,pageHeight:c=0,mainOuterHeight:d=0,surroundElementList:R=[]}=t,{defaultSize:u,scale:h,imgCaption:g,table:{tdPadding:f,defaultTrMinHeight:T},defaultTabWidth:p}=this.options,m=this.getDefaultBasicRowMarginHeight(),L=document.createElement("canvas").getContext("2d"),P=this.listParticle.computeListStyle(L,n),O=[],S=this._collectTextControlValueSet(n);n.length&&O.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:n?.[0]?.rowFlex||n?.[1]?.rowFlex});let F=s,N=a,V=0,Y,X=0,b=0;for(let E=0;E<n.length;E++){const C=O[O.length-1],M=n[E];this.clearElementEffect(M);const y=this.getElementRowMargin(M),W={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},D=C.offsetX||M.listId&&P.get(M.listId)||0,U=e-D,Q=C.elementList.length===1;if(F+=Q?D:0,N+=Q&&C.offsetY||0,(M.control?.type===l.ControlType.TEXTFIELD||M.control?.type===l.ControlType.TEXT)&&!this.isDesignMode()&&(M.controlComponent===l.ControlComponent.PRETEXTFIX||M.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||M.controlComponent===l.ControlComponent.POSTTEXTFIX||M.controlComponent===l.ControlComponent.POSTTEXTFIX_TEXT||M.controlComponent===l.ControlComponent.TEXTFIXLABEL||M.controlComponent===l.ControlComponent.PLACEHOLDER||M.controlComponent===l.ControlComponent.PREFIX||M.controlComponent===l.ControlComponent.POSTFIX)){const K=M.control?.type===l.ControlType.TEXTFIELD,v=M.controlId,w=!!v&&!!S?.has(v);K?this.mode===l.EditorMode.EDIT?M.hide=!1:M.hide=!0:this.mode===l.EditorMode.EDIT?M.hide=!1:this.mode===l.EditorMode.FORM?M.controlComponent===l.ControlComponent.PLACEHOLDER||M.controlComponent===l.ControlComponent.TEXTFIXLABEL?M.hide=w:M.hide=!1:M.hide=!0}if((M.hide||M.control?.hide||M.area?.hide)&&!this.isDesignMode()){const K=C.elementList[C.elementList.length-1];W.height=K?.metrics.height||this.options.defaultSize*h,W.boundingBoxAscent=K?.metrics.boundingBoxAscent||0,W.boundingBoxDescent=K?.metrics.boundingBoxDescent||0}else if(M.type===l.ElementType.IMAGE||M.type===l.ElementType.LATEX)if(M.imgDisplay===l.ImageDisplay.SURROUND||M.imgDisplay===l.ImageDisplay.FLOAT_TOP||M.imgDisplay===l.ImageDisplay.FLOAT_BOTTOM)W.width=0,W.height=0,W.boundingBoxDescent=0;else{const K=M.width*h,v=M.height*h;if(K>U){const w=v*U/K;M.width=U/h,M.height=w/h,W.width=U,W.height=w,W.boundingBoxDescent=w}else W.width=K,W.height=v,W.boundingBoxDescent=v;if(M.imgCaption?.value){const w=M.imgCaption.size||g.size,Z=M.imgCaption.top??g.top,J=(w+Z)*h;W.boundingBoxAscent+=J}}else if(M.type===l.ElementType.TABLE){const K=M.tdPadding||f;if(M.pagingId){let x=E+1,A=0;for(;x<n.length;){const $=n[x];if($.pagingId===M.pagingId){const B=$.trList.filter(pt=>!pt.pagingRepeat).filter(pt=>(pt.tdList=pt.tdList.filter(Xt=>{if(Xt.originalId){for(let Lt=0;Lt<M.trList.length;Lt++){const yt=M.trList[Lt],Yt=yt.tdList.find(({id:St})=>St===Xt.originalId);if(Yt){Xt.value[0]?.type===l.ElementType.SPLIT_TAG&&Xt.value.splice(0,1),Yt.value.push(...Xt.value.map(St=>this.updateElementTableInfo(St,M,yt,Yt))),Yt.rowspan=Yt.originalRowspan??Yt.rowspan;break}}return!1}return!0}),!pt.originalId));M.trList.push(...B),M.height+=$.height,x++,A++}else break}A&&n.splice(E+1,A)}M.pagingIndex=M.pagingIndex??0,this.tableParticle.computeTrHeight(M,x=>this.computeRowList({innerWidth:(x.width-(K[1]+K[3]))*h,elementList:x.value,isFromTable:!0,isPagingMode:i})),M.trList?.forEach(x=>{x.tdList.forEach(A=>{this.tdMap.set(A.id,A)})});const v=this.tableParticle.getTableHeight(M),w=this.tableParticle.getTableWidth(M);M.width=w,M.height=v;const Z=w*h,J=v*h;if(W.width=Z,W.height=J,W.boundingBoxDescent=J,W.boundingBoxAscent=-y,n[E+1]?.type===l.ElementType.TABLE&&(W.boundingBoxAscent-=y),i){const x=this.getHeight(),A=this.getMainOuterHeight();let $=A;for(let Lt=0;Lt<O.length;Lt++){const yt=O[Lt],Yt=yt.offsetY||0;yt.height+$+Yt>x||O[Lt-1]?.isPageBreak?$=A+yt.height+Yt:$+=yt.height+Yt}const B=y*2,pt=M.trList[0].height*h;($+pt+B>x||M.pagingIndex!==0&&M.trList[0].pagingRepeat||n[E-1]?.type===l.ElementType.PAGE_BREAK)&&($=A);let Xt=x-($+B);if(J>Xt){const Lt=M.trList;let yt=0,Yt=0,St=0;for(let Tt=0;Tt<Lt.length;Tt++){const Pt=Lt[Tt],Kt=Pt.height*h;if($+B+St+Kt>x){const Qt=Pt;let be=0;const jt={...at(Qt),id:lt(),originalId:Qt.originalId??Qt.id,minHeight:void 0,tdList:M.colgroup.map((mt,oe)=>{if(be--,be>0)return;const Ht=Qt.tdList.find(Ve=>Ve.colIndex===oe),Jt=Ht??this.tableParticle.findPreRowSpanTd(Lt,Tt,oe);Ht&&(be=Ht.colspan);const Je=lt();return Jt.originalRowspan=Jt.rowspan,Ht?{...Ht,id:Je,originalId:Ht.originalId??Ht.id,linkTdPrevId:Ht.id,tdIndex:oe,original:Jt}:{id:Je,originalId:Jt.originalId??Jt.id,linkTdPrevId:Jt.id,tdIndex:oe,colIndex:oe,colspan:1,rowspan:1,value:[],rowList:[],original:Jt}}).filter(mt=>!!mt)},ce=jt.tdList,_t=ce.map(mt=>mt.original);_t.forEach((mt,oe)=>{const Ht=[];let Jt=Xt;if(mt.rowspan>1){const Ve=Lt.slice(mt.trIndex,mt.trIndex+Tt-mt.trIndex);Jt+=Ve.reduce((ff,Tf)=>Tf.height*h+ff,0)}for(;mt.mainHeight*h>Jt&&mt.rowList?.length;){const Ve=mt.rowList.pop();mt.value.splice(mt.value.length-Ve.elementList.length),Ht.unshift(Ve),mt.mainHeight-=Ve.height}const Je=ce[oe];Je.rowList=Ht,Je.value=Ht.map(Ve=>Ve.elementList).flat()});let Pe=!0;const Ei=Qt.tdList.some(mt=>mt.rowList?.length),br=jt.tdList.some(mt=>mt.rowList?.length),Xi=Qt.minHeight>Xt;if(br||Xi){(Ei||!br&&Xi)&&(Xi&&(Qt.originalMinHeight=Qt.minHeight,Qt.minHeight=Xt,jt.minHeight=Math.max(Qt.originalMinHeight-Xt,T)),jt.tdList.forEach(mt=>{mt.original.linkTdNextId=mt.id,mt.value.length&&mt.value[0].value!==_&&mt.value.unshift({...mt.original.value.slice(-1).pop(),value:_,type:l.ElementType.SPLIT_TAG})}),Lt.splice(yt+1,0,jt),yt+=1,Yt=Lt.length-yt,Pe=!1),_t.forEach(mt=>{if(mt.rowspan>1){const oe=mt.rowspan-(Tt-mt.trIndex);mt.rowspan=Tt-mt.trIndex+(Ei?1:0);const Ht=jt.tdList.find(Jt=>Jt.colIndex===mt.colIndex);Ei?Ht.rowspan=oe:(Ht.original.linkTdNextId=Ht.id,Qt.tdList.push({...mt,...Ht,rowspan:oe}),Qt.tdList.sort((Jt,Je)=>Jt.colIndex-Je.colIndex),Ht.value=[])}}),Pe&&_t.forEach((mt,oe)=>{mt.value.push(...ce[oe].value)});break}}yt=Tt+1,Yt=Lt.length-yt,St+=Kt,Xt-=Kt}if(Yt){const Tt=Lt.splice(yt,Yt),Pt=M.pagingId||lt();M.pagingId=Pt;const Kt=at(M);Kt.originalId=M.originalId??M.id,Kt.pagingId=Pt,Kt.pagingIndex=M.pagingIndex+1;const Qt=Lt.filter(ce=>ce.pagingRepeat);if(Qt.length){const ce=at(Qt);ce.forEach(_t=>_t.id=lt()),Tt.unshift(...ce)}Kt.trList=Tt,Kt.id=lt(),Kt.trList?.forEach(ce=>{ce.tdList.forEach(_t=>{if(delete _t.valueStartIndex,_t.linkTdPrevId){const Pe=this.getTdById(_t.linkTdPrevId);_t.valueStartIndex=Pe?(Pe.valueStartIndex??0)+Pe.value.length:0,this.splitTdValueMap.has(_t.originalId)?this.splitTdValueMap.get(_t.originalId).push(..._t.value):Pe&&this.splitTdValueMap.set(_t.originalId,[...Pe.value,..._t.value])}_t.value.forEach(Pe=>this.updateElementTableInfo(Pe,Kt,ce,_t))})}),this.spliceElementList(n,E+1,0,[Kt]),this.tableParticle.computeTrHeight(M);const be=this.tableParticle.getTableHeight(M),jt=be*h;M.height=be,W.height=jt,W.boundingBoxDescent=jt}}if(M.pagingId){const Lt=this.position.getPositionContext();if(Lt.isTable){let yt=-1,Yt=-1,St=E;for(;St<n.length;){const Tt=n[St];if(Tt.pagingId!==M.pagingId)break;const Pt=Tt.trList.findIndex(Kt=>Kt.id===Lt.trId);if(~Pt){yt=St,Yt=Pt;break}St++}~yt&&(Lt.index=yt,Lt.trIndex=Yt,this.position.setPositionContext(Lt))}}}this.initTableElementIndex(M,E)}else if(M.type===l.ElementType.SEPARATOR){const{separator:{lineWidth:K}}=this.options,v=M.lineWidth||K;M.width=U/h,W.width=U,W.height=v*h,W.boundingBoxAscent=-y,W.boundingBoxDescent=-y+W.height}else if(M.type===l.ElementType.PAGE_BREAK)M.width=U/h,W.width=U,W.height=u;else if(M.type===l.ElementType.RADIO||M.controlComponent===l.ControlComponent.RADIO){const{width:K,height:v,gap:w}=this.options.radio,Z=K+w*2;M.width=Z,W.width=Z*h,W.height=v*h}else if(M.type===l.ElementType.CHECKBOX||M.controlComponent===l.ControlComponent.CHECKBOX){const{width:K,height:v,gap:w}=this.options.checkbox,Z=K+w*2;M.width=Z,W.width=Z*h,W.height=v*h}else if(M.type===l.ElementType.MENSTRUAL_HISTORY){const K=this.menstrualHistoryParticle.computeSize(M);M.width=K.width/h,W.width=K.width,W.height=K.height,W.boundingBoxAscent=K.height,W.boundingBoxDescent=0}else if(M.type===l.ElementType.FETAL_HEART_POSITION){const K=this.fetalHeartPositionParticle.computeSize(M);M.width=K.width/h,W.width=K.width,W.height=K.height,W.boundingBoxAscent=K.height/2,W.boundingBoxDescent=K.height/2}else if(M.type===l.ElementType.TOOTH_POSITION){const K=this.toothPositionParticle.computeSize(M);M.width=K.width/h,W.width=K.width,W.height=K.height,W.boundingBoxAscent=K.height/2,W.boundingBoxDescent=K.height/2}else if(M.type===l.ElementType.TAB)W.width=p*h,W.height=u*h,W.boundingBoxDescent=0,W.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(L,L.font);else if(M.type===l.ElementType.BLOCK){if(!M.width)W.width=U;else{const K=M.width*h;W.width=Math.min(K,U)}W.height=M.height*h,W.boundingBoxDescent=W.height,W.boundingBoxAscent=0}else if(M.type===l.ElementType.LABEL){const{defaultSize:K,label:{defaultPadding:v}}=this.options;L.font=this.getElementFont(M);const w=this.textParticle.measureText(L,M);W.width=(w.width+v[1]+v[3])*h,W.height=(M.size||K)*h,W.boundingBoxDescent=0,W.boundingBoxAscent=(v[0]+w.actualBoundingBoxAscent)*h}else if(M.type===l.ElementType.MACRO||M.type===l.ElementType.CUSTOM_MACRO||M.type===l.ElementType.REUSABLE_ITEM||M.type===l.ElementType.SUB_TEMPLATE){const{defaultSize:K}=this.options;L.font=this.getElementFont(M);const v=this.getMode(),w=v===l.EditorMode.EDIT,Z=v===l.EditorMode.FORM;if(w){const J=M.label||M.value||"";L.font=this.getElementFont(M);const x=L.measureText(J),A=8*h,$=4*h;W.width=x.width+A*2;const B=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent;W.height=B+$*2;const pt=this.textParticle.measureBasisWord(L,this.getElementFont(M));W.boundingBoxAscent=pt.actualBoundingBoxAscent*h,W.boundingBoxDescent=pt.actualBoundingBoxDescent*h}else if(M.type===l.ElementType.CUSTOM_MACRO){const J=M.macroConfig,x=J?.value||"";if(Z){const A=J?.type||"text",$=this.textParticle.measureText(L,M),B=M.label||"";if(A==="select"){const pt=x||`请选择${B}`,Xt=L.measureText(pt),Lt=L.measureText("[").width,yt=6*h+2*h;W.width=Lt+Xt.width+yt+Lt}else{const pt=x||`请输入${B}`,Xt=L.measureText(pt),Lt=L.measureText("[").width;W.width=Lt+Xt.width+Lt}W.height=(M.size||K)*h,W.boundingBoxDescent=$.actualBoundingBoxDescent*h,W.boundingBoxAscent=$.actualBoundingBoxAscent*h}else{const A=M.label||"",$=x||`请输入${A}`,B=L.measureText($);W.width=B.width,W.height=(M.size||K)*h,W.boundingBoxDescent=B.actualBoundingBoxDescent,W.boundingBoxAscent=B.actualBoundingBoxAscent}}else if(M.type===l.ElementType.REUSABLE_ITEM){const x=M.reusableItemConfig?.value||"",A=M.label||"";if(Z){const $=this.textParticle.measureText(L,M),B=x||`获取 ${A}`,pt=L.measureText(B),Xt=L.measureText("[").width;W.width=Xt+pt.width+Xt,W.height=(M.size||K)*h,W.boundingBoxDescent=$.actualBoundingBoxDescent*h,W.boundingBoxAscent=$.actualBoundingBoxAscent*h}else{const $=x||`获取 ${A}`,B=L.measureText($);W.width=B.width,W.height=(M.size||K)*h,W.boundingBoxDescent=B.actualBoundingBoxDescent,W.boundingBoxAscent=B.actualBoundingBoxAscent}}else if(M.type===l.ElementType.SUB_TEMPLATE){const J=M.label||"子模板";if(Z){const x=L.measureText(J),A=8*h,$=4*h,B=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent;W.width=x.width+A*2,W.height=B+$*2;const pt=this.textParticle.measureBasisWord(L,this.getElementFont(M));W.boundingBoxAscent=pt.actualBoundingBoxAscent*h,W.boundingBoxDescent=pt.actualBoundingBoxDescent*h}else{const x=L.measureText(J);W.width=x.width,W.height=(M.size||K)*h,W.boundingBoxDescent=x.actualBoundingBoxDescent,W.boundingBoxAscent=x.actualBoundingBoxAscent}}else{const J=M.label||"",x=M.value||`获取 ${J}`,A=L.measureText(x);W.width=A.width,W.height=(M.size||K)*h,W.boundingBoxDescent=A.actualBoundingBoxDescent,W.boundingBoxAscent=A.actualBoundingBoxAscent}}else{const K=M.size||u;(M.type===l.ElementType.SUPERSCRIPT||M.type===l.ElementType.SUBSCRIPT)&&(M.actualSize=Math.ceil(K*.6)),W.height=(M.actualSize||K)*h,L.font=this.getElementFont(M);const v=this.textParticle.measureText(L,M);W.width=v.width*h,M.letterSpacing&&(W.width+=M.letterSpacing*h);const w=this.textParticle.measureBasisWord(L,M.font);W.boundingBoxAscent=w.actualBoundingBoxAscent*h,W.boundingBoxDescent=w.actualBoundingBoxDescent*h,M.type===l.ElementType.SUPERSCRIPT?W.boundingBoxAscent+=W.height/2:M.type===l.ElementType.SUBSCRIPT&&(W.boundingBoxDescent+=W.height/2)}const G=!M.hide&&(M.imgDisplay!==l.ImageDisplay.INLINE&&M.type===l.ElementType.IMAGE||M.type===l.ElementType.LATEX)?W.height+y:W.boundingBoxAscent+y,H=y+W.boundingBoxAscent+W.boundingBoxDescent+y,j=Object.assign(M,{metrics:W,left:0,style:this.getElementFont(M,h)});j.control?.minWidth&&(j.controlComponent&&(b+=W.width),j.controlComponent===l.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:C,rowElement:j,availableWidth:U,controlRealWidth:b}),b=0));const st=n[E-1];let it=n[E+1],nt=C.width+W.width;if(this.options.wordBreak===l.WordBreak.BREAK_WORD&&(!st?.type||st?.type===l.ElementType.TEXT)&&(!M.type||M.type===l.ElementType.TEXT)){const K=`${st?.value||""}${M.value}`;if(this.WORD_LIKE_REG.test(K)){const{width:w,endElement:Z}=this.textParticle.measureWord(L,n,E),J=w*h;Z&&J<=U?(nt+=J,it=Z):st&&(nt+=J)}const v=this.textParticle.measurePunctuationWidth(L,it);nt+=v*h}M.listId&&(M.listId!==Y?X=0:M.value===_&&!M.listWrap&&X++),Y=M.listId;const et=this.position.setSurroundPosition({pageNo:V,rowElement:j,row:C,rowElementRect:{x:F,y:N,height:H,width:W.width},availableWidth:U,surroundElementList:R});F=et.x,nt+=et.rowIncreaseWidth,F+=W.width;let dt=!1;if(this.mode===l.EditorMode.FORM&&M.control?.type===l.ControlType.BUTTON&&M.controlComponent===l.ControlComponent.PREFIX&&C.elementList.filter(K=>K.controlId!==M.controlId).length>0){const K=M.controlId;if(n.some(w=>w.controlId===`${K}_text`&&w.control?.type===l.ControlType.BUTTON)){let w=0;for(let Z=E;Z<n.length;Z++){const J=n[Z];if(J.controlId!==K)break;L.font=this.getElementFont(J);const x=this.textParticle.measureText(L,J);if(w+=x.width*h,J.controlComponent===l.ControlComponent.POSTFIX)break}for(let Z=0;Z<n.length;Z++){const J=n[Z];if(J.controlId===`${K}_text`){L.font=this.getElementFont(J);const x=this.textParticle.measureText(L,J);w+=x.width*h}}dt=C.width+w>U}}const tt=M.type===l.ElementType.SEPARATOR||M.type===l.ElementType.TABLE||st?.type===l.ElementType.TABLE||st?.type===l.ElementType.BLOCK||M.type===l.ElementType.BLOCK||st?.imgDisplay===l.ImageDisplay.INLINE||M.imgDisplay===l.ImageDisplay.INLINE||st?.listId!==M.listId||st?.areaId!==M.areaId&&!M.area?.hide||M.control?.flexDirection===l.FlexDirection.COLUMN&&(M.controlComponent===l.ControlComponent.CHECKBOX||M.controlComponent===l.ControlComponent.RADIO)&&st?.controlComponent===l.ControlComponent.VALUE||E!==0&&M.value===_&&!M.area?.hide||dt,ht=nt>U,ut=tt||ht;if(ut){const K={width:W.width,height:H,startIndex:E,elementList:[j],ascent:G,rowIndex:C.rowIndex+1,rowFlex:n[E]?.rowFlex||n[E+1]?.rowFlex,isPageBreak:M.type===l.ElementType.PAGE_BREAK};if(j.controlComponent!==l.ControlComponent.PREFIX&&j.control?.indentation===l.ControlIndentation.VALUE_START){const v=C.elementList.findIndex(w=>w.controlId===j.controlId&&w.controlComponent!==l.ControlComponent.PREFIX);if(~v){const Z=this.position.computeRowPosition({row:C,innerWidth:this.getInnerWidth()})[v];Z&&(K.offsetX=Z.coordinate.leftTop[0])}}M.listId&&(K.isList=!0,K.offsetX=P.get(M.listId),K.listIndex=X),K.offsetY=!r&&M.area?.top&&M.areaId!==n[E-1]?.areaId?M.area.top*h:0,O.push(K)}else C.width+=W.width,E===0&&(nn(n[1])||n[1]?.areaId)?(C.height=m,C.ascent=m):C.height<H&&(C.height=H,C.ascent=G),C.elementList.push(j);if((ut||E===n.length-1)&&(C.isWidthNotEnough=ht&&!tt,!C.isSurround&&(st?.rowFlex===l.RowFlex.JUSTIFY||st?.rowFlex===l.RowFlex.ALIGNMENT&&C.isWidthNotEnough))){const K=C.elementList[0]?.value===_?C.elementList.slice(1):C.elementList,v=(U-C.width)/(K.length-1);for(let w=0;w<K.length-1;w++){const Z=K[w];Z.metrics.width+=v}C.width=U}if(ut){F=s,N+=C.height,i&&!r&&c&&(N-a+d+H>c||M.type===l.ElementType.PAGE_BREAK)&&(N=a,jl(R,V),V+=1),j.left=0;const K=O[O.length-1];F=this.position.setSurroundPosition({pageNo:V,rowElement:j,row:K,rowElementRect:{x:F,y:N,height:H,width:W.width},availableWidth:U,surroundElementList:R}).x,F+=W.width}}return O}_collectTextControlValueSet(t){if(this.isDesignMode()||this.mode===l.EditorMode.EDIT)return null;const e=new Set;for(let i=0;i<t.length;i++){const r=t[i];r.controlId&&(r.control?.type===l.ControlType.TEXT||r.control?.type===l.ControlType.TEXTFIELD)&&e.add(r.controlId)}const n=new Set;for(let i=0;i<t.length;i++){const r=t[i];r.controlId&&r.controlComponent===l.ControlComponent.VALUE&&e.has(r.controlId)&&n.add(r.controlId)}return n}_computePageList(){const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),r=this.getMainOuterHeight();let s=r,a=0;if(e===l.PageMode.CONTINUITY){t[0]=this.rowList,s+=this.rowList.reduce((u,h)=>u+h.height+(h.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],R=Number(d.style.height.replace("px",""));if(s>R)d.style.height=`${s}px`,d.height=s*c;else{const u=s<i?i:s;d.style.height=`${u}px`,d.height=u*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],R=d.offsetY||0;if(d.height+R+s>i||this.rowList[c-1]?.isPageBreak){if(Number.isInteger(n)&&a>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}s=r+d.height+R,t.push([d]),a++}else s+=d.height+R,t[a].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:r}=e,s=this.getDefaultBasicRowMarginHeight(),a=this.getHighlightMarginHeight();for(let c=0;c<n.length;c++){const d=n[c];for(let R=0;R<d.elementList.length;R++){const u=d.elementList[R],h=d.elementList[R-1],g=u.highlight||this.control.getControlHighlight(r,d.startIndex+R);if(g){h&&h.highlight&&h.highlight!==u.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[f,T]}}=i[d.startIndex+R],p=u.left||0;this.highlight.recordFillInfo(t,f-p,T+s-a,u.metrics.width+p,d.height-2*s+2*a,g)}else h?.highlight&&this.highlight.render(t)}this.highlight.render(t)}}validateNumber(t){return/^\d+$/.test(t)}drawRow(t,e){this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:r,lineBreak:s,whiteSpace:a}=this.options,{rowList:c,pageNo:d,elementList:R,positionList:u,startIndex:h,zone:g,isDrawLineBreak:f=!s.disabled,td:T,isDrawWhiteSpace:p=!a.disabled}=e,m=this.isPrintMode(),I=this.isGraffitiMode(),{isCrossRowCol:L,tableId:P}=this.range.getRange();let O=h;for(let S=0;S<c.length;S++){const F=c[S],N={x:0,y:0,width:0,height:0};let V=null;for(let Y=0;Y<F.elementList.length;Y++){const X=F.elementList[Y],b=X.metrics,{ascent:E,coordinate:{leftTop:[C,M]}}=u[F.startIndex+Y],y=F.elementList[Y-1];if((X.hide||X.control?.hide||X.area?.hide)&&!this.isDesignMode())this.textParticle.complete();else if(X.type===l.ElementType.IMAGE)this.textParticle.complete(),X.imgDisplay!==l.ImageDisplay.SURROUND&&X.imgDisplay!==l.ImageDisplay.FLOAT_TOP&&X.imgDisplay!==l.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.TABLE)L&&(N.x=C,N.y=M,V=X),this.tableParticle.render(t,X,C,M);else if(X.type===l.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.MACRO||X.type===l.ElementType.CUSTOM_MACRO||X.type===l.ElementType.REUSABLE_ITEM||X.type===l.ElementType.SUB_TEMPLATE)this.textParticle.complete(),this.macroParticle.render(t,X,C,M+E);else if(X.type===l.ElementType.DATE){const H=F.elementList[Y+1];(!y||y.dateId!==X.dateId)&&this.textParticle.complete(),this.textParticle.record(t,X,C,M+E),(!H||H.dateId!==X.dateId)&&this.textParticle.complete()}else X.type===l.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,X,C,M+E)):X.type===l.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,X,C,M+E)):X.type===l.ElementType.SEPARATOR?this.separatorParticle.render(t,X,C,M):X.type===l.ElementType.PAGE_BREAK?this.mode!==l.EditorMode.CLEAN&&!m&&this.pageBreakParticle.render(t,X,C,M):X.type===l.ElementType.CHECKBOX||X.controlComponent===l.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F})):X.type===l.ElementType.RADIO||X.controlComponent===l.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F})):X.type===l.ElementType.MENSTRUAL_HISTORY?(this.textParticle.complete(),this.menstrualHistoryParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F,element:X})):X.type===l.ElementType.FETAL_HEART_POSITION?(this.textParticle.complete(),this.fetalHeartPositionParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F,element:X})):X.type===l.ElementType.TOOTH_POSITION?(this.textParticle.complete(),this.toothPositionParticle.render({ctx:t,x:C,y:M+E,index:Y,row:F,element:X})):X.type===l.ElementType.TAB?this.textParticle.complete():X.rowFlex===l.RowFlex.ALIGNMENT||X.rowFlex===l.RowFlex.JUSTIFY?(this.textParticle.record(t,X,C,M+E),this.textParticle.complete()):X.type===l.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,d,X,C,M+E)):(X.left&&this.textParticle.complete(),this.textParticle.record(t,X,C,M+E),(X.width||X.letterSpacing||Zr.test(X.value))&&this.textParticle.complete());if(f&&!m&&this.mode!==l.EditorMode.CLEAN&&!F.isWidthNotEnough&&Y===F.elementList.length-1&&this.lineBreakParticle.render(t,X,C,M+F.height/2),p&&vr.test(X.value)&&this.whiteSpaceParticle.render(t,X,C,M+F.height/2),X.control?.border){y?.control?.border&&y.controlId!==X.controlId&&this.control.drawBorder(t);const H=this.getElementRowMargin(X);this.control.recordBorderInfo(C,M+H,X.metrics.width,F.height-2*H)}else y?.control?.border&&this.control.drawBorder(t);if(X.control?.type===l.ControlType.TEXT){const H=X.controlComponent===l.ControlComponent.VALUE,j=X.controlComponent===l.ControlComponent.POSTFIX||X.controlComponent===l.ControlComponent.POST_TEXT;H&&X.control?.underline&&((!y||y.controlId!==X.controlId||y.controlComponent!==l.ControlComponent.VALUE&&y.controlComponent!==l.ControlComponent.PLACEHOLDER)&&this.control.startTextFieldUnderline(X.controlId,C,M+F.height),this.control.recordTextFieldUnderlineWidth(X.metrics.width)),j&&this.control.drawTextFieldUnderline(t)}else y?.control?.type===l.ControlType.TEXT&&this.control.drawTextFieldUnderline(t);if((X.underline||X.control?.underline)&&X.controlComponent!==l.ControlComponent.PLACEHOLDER&&!(X.control?.type===l.ControlType.TEXT&&X.control?.underline)){y?.type===l.ElementType.SUBSCRIPT&&X.type!==l.ElementType.SUBSCRIPT&&this.underline.render(t);const H=this.getElementRowMargin(X),j=X.left||0;let st=0;X.type===l.ElementType.SUBSCRIPT&&(st=this.subscriptParticle.getOffsetY(X));const it=X.control?.underline?this.options.underlineColor:X.color;this.underline.recordFillInfo(t,C-j,M+F.height-H+st,b.width+j,0,it,X.textDecoration?.style)}else(y?.underline||y?.control?.underline)&&(y?.control?.type===l.ControlType.TEXT&&y?.control?.underline||this.underline.render(t));if(X.strikeout){if(!X.type||$t.includes(X.type)){y&&(y.type===l.ElementType.SUBSCRIPT&&X.type!==l.ElementType.SUBSCRIPT||y.type===l.ElementType.SUPERSCRIPT&&X.type!==l.ElementType.SUPERSCRIPT||this.getElementSize(y)!==this.getElementSize(X))&&this.strikeout.render(t);const H=this.textParticle.measureBasisWord(t,this.getElementFont(X));let j=M+E+H.actualBoundingBoxDescent*n-b.height/2;X.type===l.ElementType.SUBSCRIPT?j+=this.subscriptParticle.getOffsetY(X):X.type===l.ElementType.SUPERSCRIPT&&(j+=this.superscriptParticle.getOffsetY(X)),this.strikeout.recordFillInfo(t,C,j,b.width)}}else y?.strikeout&&this.strikeout.render(t);const{zone:W,splitTdRange:D}=this.range.getRange();let{startIndex:U,endIndex:Q}=this.range.getRange(),G=!1;if(T&&D&&[T.originalId,T.id].includes(D.originalId)&&(G=!0,U=D.startIndex-(T.valueStartIndex??0),Q=D.endIndex-(T.valueStartIndex??0)),W===g&&U!==Q&&U<=O&&O<=Q){const H=this.position.getPositionContext();if(!H.isTable&&!X.tdId||H.tdId===X.tdId||G)if(U===O){const j=R[U+1];j&&j.value===_&&(N.x=C+b.width,N.y=M,N.height=F.height,N.width+=this.options.rangeMinWidth)}else{let j=b.width;j===0&&F.elementList.length===1&&(j=this.options.rangeMinWidth),N.width||(N.x=C,N.y=M,N.height=F.height),N.width+=j}}if(!r.disabled&&X.groupIds&&this.group.recordFillInfo(X,C,M,b.width,F.height),O++,X.type===l.ElementType.TABLE&&!X.hide){const H=X.tdPadding||i,j=H[1]+H[3];for(let st=0;st<X.trList.length;st++){const it=X.trList[st];for(let nt=0;nt<it.tdList.length;nt++){const et=it.tdList[nt];this.drawRow(t,{elementList:et.value,positionList:et.positionList,rowList:et.rowList,pageNo:d,startIndex:0,innerWidth:(et.width-j)*n,zone:g,isDrawLineBreak:f,td:et})}}}}if(F.isList&&this.listParticle.drawListStyle(t,F,u[F.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!m&&!I){if(N.width&&N.height){const{x:Y,y:X,width:b,height:E}=N;this.range.render(t,Y,X,b,E)}if(L&&V&&V.id===P){const{coordinate:{leftTop:[Y,X]}}=u[F.startIndex];this.tableParticle.drawRange(t,V,Y,X)}}}}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:r,pageNo:s}=e;for(let a=0;a<i.length;a++){const c=i[a],d=c.element;if((s===c.pageNo||c.zone===l.EditorZone.HEADER||c.zone==l.EditorZone.FOOTER)&&d.imgDisplay&&r.includes(d.imgDisplay)&&d.type===l.ElementType.IMAGE){const R=d.imgFloatPosition;this.imageParticle.render(t,d,R.x*n,R.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:n,rowList:i,pageNo:r}=t,{inactiveAlpha:s,pageMode:a,header:c,footer:d,pageNumber:R,lineNumber:u,pageBorder:h}=this.options,g=this.mode===l.EditorMode.PRINT,f=this.getInnerWidth(),T=this.ctxList[r];T.globalAlpha=this.zone.isMainActive()?1:s,this._clearPage(r),(!g||!this.options.modeRule[l.EditorMode.PRINT]?.backgroundDisabled)&&this.background.render(T,r),g||this.area.render(T,r),a!==l.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(T,r),g||this.margin.render(T,r),this._drawFloat(T,{pageNo:r,imgDisplays:[l.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(T,r);const p=i[0]?.startIndex;this.drawRow(T,{elementList:e,positionList:n,rowList:i,pageNo:r,startIndex:p,innerWidth:f,zone:l.EditorZone.MAIN}),this.getIsPagingMode()&&(c.disabled||this.header.render(T,r),R.disabled||this.pageNumber.render(T,r),d.disabled||this.footer.render(T,r)),this._drawFloat(T,{pageNo:r,imgDisplays:[l.ImageDisplay.FLOAT_TOP,l.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(T,r),this.elementList.length<=1&&!this.elementList[0]?.listId&&this.placeholder.render(T),u.disabled||this.lineNumber.render(T,r),h.disabled||this.pageBorder.render(T),this.badge.render(T,r),this.isGraffitiMode()&&this.graffiti.render(T,r)}_disconnectLazyRender(){this.lazyRenderIntersectionObserver?.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const r=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[r],pageNo:r})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){const e=bt(),n=[],i=(b,E)=>{n.push({label:b,duration:bt()-E})};this.renderCount++;let r;const{endIndex:s,isCrossRowCol:a}=this.range.getRange(),c=this.position.getPositionContext();if(a)r=this.getOriginalElementList()[c.index];else{const b=~s?s:0,E=this.getElementList();r=je(E,b)}const{header:d,footer:R}=this.options,{isSubmitHistory:u=!0,isSetCursor:h=!0,isCompute:g=!0,isLazy:f=!0,isInit:T=!1,isSourceHistory:p=!1,isFirstRender:m=!1,isDel:I=!1}=t||{};let{curIndex:L}=t||{};const{traceLabel:P}=t||{},O=this.getInnerWidth(),S=this.getIsPagingMode(),F=this.pageRowList.length;if(g){if(this.splitTdValueMap.clear(),this.tdMap.clear(),this.position.setFloatPositionList([]),S){if(!d.disabled){const j=bt();this.header.compute(),i("header.compute",j)}if(!R.disabled){const j=bt();this.footer.compute(),i("footer.compute",j)}}const b=this.getMargins(),E=this.getHeight(),C=this.header.getExtraHeight(),M=this.getMainOuterHeight(),y=b[3],W=b[0]+C,D=wo(this.elementList),U=bt();this.rowList=this.computeRowList({startX:y,startY:W,pageHeight:E,mainOuterHeight:M,isPagingMode:S,innerWidth:O,surroundElementList:D,elementList:this.elementList}),i("computeRowList",U);const Q=bt();this.pageRowList=this._computePageList(),i("computePageList",Q);const G=bt();this.position.computePositionList(),i("computePositionList",G);const H=bt();if(this.area.compute(),i("area.compute",H),!this.isPrintMode()){const j=this.search.getSearchKeyword();if(j){const it=bt();this.search.compute(j),i("search.compute",it)}const st=bt();this.control.computeHighlightList(),i("control.computeHighlightList",st)}if(this.isGraffitiMode()){const j=bt();this.graffiti.compute(),i("graffiti.compute",j)}}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let b=0;b<this.pageRowList.length;b++)this.pageList[b]||this._createPage(b);const N=this.pageRowList.length,V=this.pageList.length;if(V>N){const b=V-N;this.ctxList.splice(N,b),this.pageList.splice(N,b).forEach(E=>E.remove())}const Y=bt();if(f&&S?this._lazyRender():this._immediateRender(),i(f&&S?"lazyRender":"immediateRender",Y),h){if(g&&r?.tableId){const{index:b}=c,C=this.getOriginalElementList()[b];if(r.tableId!==C?.id){const y=this.findTableChildrenElement(!0,r.tableId,r);y&&c.index!==y.originalIndex&&(c.index=y.originalIndex,c.tableId=y.table.id,c.trIndex=y.trIndex,c.trId=y.tr.id,c.tdIndex=y.tdIndex,c.tdId=y.td.id,L=y.elementIndex,this.position.setPositionContext(c),this.range.setRange(L,L),this.updateTableTool())}const M=this.getElementList();M[s]!==r&&(L=M.findIndex(y=>y===r))}L=this.setCursor(L)}else this.range.getIsSelection()&&this.cursor.focus();if(I){let b;const E=this.position.getPositionContext();b=this.range.getRange().startIndex-1,E.index=b}(u&&!m||L!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(L);const X=bt();Oo(()=>{const b=bt();this.range.setRangeStyle(),g&&this.control.getActiveControl()&&this.control.reAwakeControl(),g&&!this.isReadonly()&&this.getMode()!==l.EditorMode.FORM&&c.isTable&&this.getOriginalElementList()[c.index].type===l.ElementType.TABLE&&this.tableTool.render(),g&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),F!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(u||p)&&!T&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"));const E=bt();Co(this.options,P||"render",E-e,[...n,{label:"nextTick.wait",duration:b-X},{label:"nextTick.callback",duration:E-b}],{isCompute:g,pageCount:this.pageRowList.length})}),h&&this.fixPosition()}fixPosition(t=!1){let e;const n=this.position.getPositionContext();if(n.isTable){const i=this.getElementList(),r=this.range.getRange().startIndex;if(t||r>=i.length){const s=this.getTd(),a=n.index+(t?-1:1),d=this.getOriginalElementList()[a];if(!d?.trList)return;e=r-i.length;for(let R=0;R<d.trList.length;R++){const u=d.trList[R],h=u.tdList.find(g=>t?s?.linkTdPrevId===g.id:s?.id===g.linkTdPrevId);if(h){n.index=a,n.trIndex=R,n.tableId=d.id,n.trId=u.id,n.tdId=h?.id,e=t?h.value.length-1:e+(h.value[0]?.type===l.ElementType.SPLIT_TAG?1:0);break}}if(this.position.setPositionContext(n),this.range.setRange(e,e),this.setCursor(e),e===0)return this.fixPosition(t);this.updateTableTool()}}return e}setCursor(t){const e=this.position.getPositionContext(),n=this.position.getPositionList(),i=this.getElementList();if(e.isTable){const{index:s,trIndex:a,tdIndex:c}=e,R=this.getOriginalElementList()[s].trList?.[a].tdList[c].positionList;t===void 0&&R&&(t=R.length-1);const u=R?.[t];this.position.setCursorPosition(u||null)}else t!==void 0&&t>=n.length&&(t=n.length-1),this.position.setCursorPosition(t!==void 0&&t>=0?n[t]:null);let r=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const s=i[t];if(s&&rl.includes(s.type)){r=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(s,a)}}return this.cursor.drawCursor({isShow:r}),t}submitHistory(t){const e=this.position.getPositionContext(),n=Uo(this.elementList),i=Uo(this.header.getElementList()),r=Uo(this.footer.getElementList()),s=at(this.range.getRange()),a=this.pageNo,c=at(e),d=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(d),this.setPageNo(a),this.position.setPositionContext(at(c)),this.header.setElementList(at(i)),this.footer.setElementList(at(r)),this.elementList=at(n),this.range.replaceRange(at(s)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}updateTableTool(){if(this.getMode()===l.EditorMode.FORM){this.getTableTool().dispose();return}if(this.position.getPositionContext().isTable){const t=this.position.getPositionList();t.length&&(this.setPageNo(t[0].pageNo),this.getTableTool().render())}}initTableElementIndex(t,e){t.trList?.forEach((n,i)=>{n.tdList.forEach((r,s)=>{r.tableIndex=e,r.tableId=t.id,r.trIndex=i,r.trId=n.id,r.tdIndex=s,this.tdMap.set(r.id,r)})})}clearElementEffect(t){t.trList?.forEach(e=>{e.minHeight=e.originalMinHeight??e.minHeight,delete e.originalMinHeight,e.tdList.forEach(n=>{delete n.linkTdNextId})})}updateElementTableInfo(t,e,n,i){return t.tableId=e.id,t.trId=n.id,t.tdId=i.id,t}findTableChildrenElement(t,e,n){const i=this.position.getPositionContext(),{index:r}=i,s=this.getOriginalElementList();let a=r;t&&(a=r>s.length?s.length-1:r);for(let c=a;t?c>=0:c<s.length;t?c--:c++){const d=s[c];if(d&&[d.originalId,d.id].includes(e))for(const[R,u]of d.trList.entries())for(const[h,g]of u.tdList.entries()){const f=g.value.findIndex(typeof n=="function"?n:T=>T===n);if(f>=0)return{originalIndex:c,table:d,tr:u,trIndex:R,td:g,tdIndex:h,elementIndex:f}}}}getTdById(t){return this.tdMap.get(t)}getLinkTdPrevHasValue(t){const e=this.getTdById(t);if(e)return e.value.length?e:this.getLinkTdPrevHasValue(e.linkTdPrevId)}getFirstLinkTd(t){const e=this.getTdById(t);return e?.linkTdPrevId?this.getLastLinkTd(e.linkTdPrevId):e}getLastLinkTd(t){const e=this.getTdById(t);return e?.linkTdNextId?this.getLastLinkTd(e.linkTdNextId):e}removeLinkTd(t,e){const n=this.getTdById(e);if(n){if(n.linkTdPrevId){const i=this.getTdById(n.linkTdPrevId);i&&(delete i.linkTdNextId,this.removeLinkTd(t,n.linkTdPrevId))}if(n.linkTdNextId){const i=this.getTdById(n.linkTdNextId);i&&(delete i.linkTdPrevId,this.removeLinkTd(t,n.linkTdNextId))}t[n.tableIndex].trList[n.trIndex].tdList.splice(n.tdIndex,1),this.initTableElementIndex(t[n.tableIndex],n.tableIndex)}}removeLinkTdControl(t,e){const n=this.getTdById(t);if(n){for(let i=0;i<n.value.length;i++)n.value[i].control===e&&(n.value.splice(i,1),i--);n.linkTdNextId&&this.removeLinkTdControl(n.linkTdNextId,e)}}isSplitTd(t,e){return(!!t?.originalId||!!e?.originalId)&&(t?.originalId===e?.originalId||t?.id===e?.originalId||t?.originalId===e?.id)}getSplitTdValues(t){return this.splitTdValueMap.get(t)}removeSplitTdOtherRangeElements(){const{splitTdRange:t}=this.range.getRange();if(!t)return;const{startIndex:e,endIndex:n}=t;let i=this.getTd();if(i)if((i.valueStartIndex??0)>=e){let r=-1;for(;r<0;){const s=this.getTdById(i.linkTdPrevId);if(s){r=e-(s.valueStartIndex??0);const a=Math.max(0,r);this.spliceElementList(s.value,a+1,s.value.length-a-1),i=s}else r=0}}else{let r=1;for(;r>0;){const s=this.getTdById(i.linkTdNextId);if(s){const a=s.valueStartIndex??0;r=n-(a+s.value.length);const c=Math.min(s.value.length,n-a+1);this.spliceElementList(s.value,0,c),i=s}else r=0}}}getTablesByPagingId(t,e,n){const i=[],r=[];if(t[n].pagingId===e){i.push(n),r.push(t[n]);for(let s=n-1;s>=0&&t[s].pagingId===e;s--)r.unshift(t[s]),i.push(s);for(let s=n+1;s<t.length&&t[s].pagingId===e;s++)r.push(t[s]),i.push(s)}return{list:r,startIndex:i.sort()[0]}}}class Xr{executeMode;executeCut;executeCopy;executePaste;executeSelectAll;executeBackspace;executeSetRange;executeReplaceRange;executeSetPositionContext;executeForceUpdate;executeBlur;executeHideCursor;executeUndo;executeRedo;executePainter;executeApplyPainterStyle;executeFormat;executeFont;executeButton;executeEditElementAttribute;executeTriggerControlEditAttribute;executeCopyControl;executePasteControl;executeSize;executeSizeAdd;executeSizeMinus;executeBold;executeItalic;executeUnderline;executeStrikeout;executeSuperscript;executeSubscript;executeColor;executeHighlight;executeTitle;executeList;executeRowFlex;executeVertical;executeRowMargin;executeInsertTable;executeInsertTableTopRow;executeInsertTableBottomRow;executeInsertTableLeftCol;executeInsertTableRightCol;executeDeleteTableRow;executeDeleteTableCol;executeDeleteTable;executeMergeTableCell;executeCancelMergeTableCell;executeSplitVerticalTableCell;executeSplitHorizontalTableCell;executeTableTdVerticalAlign;executeTableBorderType;executeTableBorderColor;executeTableTdBorderType;executeTableTdSlashType;executeTableTdBackgroundColor;executeTableSelectAll;executeTableProperties;executeImage;executeHyperlink;executeDeleteHyperlink;executeCancelHyperlink;executeEditHyperlink;executeSeparator;executePageBreak;executeAddWatermark;executeDeleteWatermark;executeSearch;executeSearchNavigatePre;executeSearchNavigateNext;executeReplace;executePrint;executeReplaceImageElement;executeSaveAsImageElement;executeSetImageCrop;executeSetImageCaption;executeChangeImageDisplay;executePageMode;executePageScale;executePageScaleRecovery;executePageScaleMinus;executePageScaleAdd;executePaperSize;executePaperDirection;executeSetPaperMargin;executeSetMainBadge;executeSetAreaBadge;executeInsertElementList;executeInsertArea;executeSetAreaValue;executeSetAreaProperties;executeLocationArea;executeClearGraffiti;executeAppendElementList;executeUpdateElementById;executeDeleteElementById;executeSetValue;executeRemoveControl;executeTranslate;executeSetLocale;executeLocationCatalog;executeWordTool;executeSetHTML;executeSetGroup;executeDeleteGroup;executeLocationGroup;executeSetZone;executeSetControlValue;executeSetControlValueList;executeSetControlExtension;executeSetControlExtensionList;executeSetControlProperties;executeSetControlPropertiesList;executeSetControlHighlight;executeLocationControl;executeInsertControl;executeInsertTextField;executeJumpControl;executeUpdateOptions;executeSetFormModeTrace;executeInsertTitle;executeFocus;executeComputeElementListHeight;getCatalog;getImage;getPageMode;getOptions;getValue;getValueAsync;getAreaValue;getHTML;getText;getWordCount;getCursorPosition;getRemainingContentHeight;getRange;getRangeText;getRangeContext;getRangeRow;getRangeParagraph;getKeywordRangeList;getKeywordContext;getPaperMargin;getSearchNavigateInfo;getLocale;getGroupIds;getControlValue;getControlList;getContainer;getTitleValue;getPositionContextByEvent;getElementById;getMacroValue;getMacroList;setMacroValue;setMacroValueList;updateMacroProperties;locationMacro;insertSubTemplate;expandSubTemplate;collapseSubTemplate;toggleSubTemplate;constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeButton=t.buttonText.bind(t),this.executeEditElementAttribute=t.editElementAttribute.bind(t),this.executeTriggerControlEditAttribute=t.triggerControlEditAttribute.bind(t),this.executeCopyControl=t.copyControl.bind(t),this.executePasteControl=t.pasteControl.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeVertical=t.vertical.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeTableProperties=t.tableProperties.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeSetFormModeTrace=t.setFormModeTrace.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getPageMode=t.getPageMode.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeInsertTextField=t.insertTextField.bind(t),this.executeJumpControl=t.jumpControl.bind(t),this.getMacroValue=t.getMacroValue.bind(t),this.getMacroList=t.getMacroList.bind(t),this.setMacroValue=t.setMacroValue.bind(t),this.setMacroValueList=t.setMacroValueList.bind(t),this.updateMacroProperties=t.updateMacroProperties.bind(t),this.locationMacro=t.locationMacro.bind(t),this.insertSubTemplate=t.insertSubTemplate.bind(t),this.expandSubTemplate=t.expandSubTemplate.bind(t),this.collapseSubTemplate=t.collapseSubTemplate.bind(t),this.toggleSubTemplate=t.toggleSubTemplate.bind(t)}}function qh(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function tg(o,t){const{width:e,height:n,direction:i=l.PaperDirection.VERTICAL}=t,r=document.createElement("iframe");r.style.visibility="hidden",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.width="0",r.style.height="0",r.style.border="none",document.body.append(r);const s=r.contentWindow,a=s.document;a.open();const c=document.createElement("div"),d=qh(e,n);o.forEach(h=>{const g=document.createElement("img");g.style.width=i===l.PaperDirection.HORIZONTAL?d.height:d.width,g.style.height=i===l.PaperDirection.HORIZONTAL?d.width:d.height,g.src=h,c.append(g)});const R=document.createElement("style"),u=`
|
|
539
539
|
* {
|
|
540
540
|
margin: 0;
|
|
541
541
|
padding: 0;
|
|
@@ -543,7 +543,7 @@ ${u} `}textToElements(t){const e=[],n=t.split(`
|
|
|
543
543
|
@page {
|
|
544
544
|
margin: 0;
|
|
545
545
|
size: ${d.size} ${i===l.PaperDirection.HORIZONTAL?"landscape":"portrait"};
|
|
546
|
-
}`;R.append(document.createTextNode(u)),setTimeout(()=>{a.write(`${R.outerHTML}${c.innerHTML}`),s.print(),a.close(),window.addEventListener("mouseover",()=>{r?.remove()},{once:!0})})}const eg=[l.ControlType.TEXT,l.ControlType.TEXTFIELD],Nr=["id","titleId","listId","areaId","hyperlinkId","dateId","labelId","tableId","trId","tdId","pagingId","menstrualHistoryId","fetalHeartPositionId","toothPositionId"];function go(o,t){for(let e=0;e<o.length;e++){const n=o[e];if(n.type===l.ElementType.CONTROL&&n.controlId===t&&n.control)return at(n);if(n.control?.value?.length){const i=go(n.control.value,t);if(i)return i}if(n.valueList?.length){const i=go(n.valueList,t);if(i)return i}if(n.type===l.ElementType.TABLE&&n.trList?.length)for(let i=0;i<n.trList.length;i++){const r=n.trList[i];for(let s=0;s<r.tdList.length;s++){const a=r.tdList[s],c=go(a.value,t);if(c)return c}}}return null}function ng(o){const t=new Map,e=new Map,n=a=>a&&(t.has(a)||t.set(a,lt()),t.get(a)),i=a=>a&&(e.has(a)||e.set(a,lt()),e.get(a)),r=a=>{a.controlId&&(a.controlId=n(a.controlId)),a.originControlId&&(a.originControlId=n(a.originControlId));for(let c=0;c<Nr.length;c++){const d=Nr[c],R=a[d];if(typeof R=="string"){const u=a;u[d]=i(R)}}a.groupIds?.length&&(a.groupIds=a.groupIds.map(c=>i(c))),a.valueList?.length&&a.valueList.forEach(r),a.control?.value?.length&&a.control.value.forEach(r),a.trList?.length&&a.trList.forEach(c=>{const d=c;typeof d.id=="string"&&(d.id=i(d.id)),c.tdList.forEach(R=>{const u=R;typeof u.id=="string"&&(u.id=i(u.id)),R.value.forEach(r)})})},s=at(o);return r(s),s}function og(o,t,e){let n=-1;const i=!!e;for(let r=0;r<o.length;r++){const s=o[r];if(i?s.controlId===t&&s.originControlId===e:s.controlId===t&&!s.originControlId)n=r;else if(~n)break}return n}class ig{draw;range;position;historyManager;canvasEvent;options;control;workerManager;searchManager;i18n;zone;tableOperate;constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n(),this.zone=t.getZone(),this.tableOperate=t.getTableOperate()}getIsRangeInTextField(){const{startIndex:t}=this.range.getRange(),e=this.draw.getElementList(),n=e[t];if(!n)return!1;let i=null;const r=s=>{if(!s)return null;for(let a=t;a>=0;a--){const c=e[a];if(c.controlId===s&&c.control?.type===l.ControlType.TEXTFIELD&&(c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRE_TEXT))return s}return null};return i=r(n.controlId)||r(n.originControlId),!!i}mode(t){this.draw.setMode(t)}async cut(){this.draw.isReadonly()||this.draw.isDisabled()||await this.canvasEvent.cut()}async copy(t){await this.canvasEvent.copy(t)}paste(t){this.draw.isReadonly()||this.draw.isDisabled()||sa(this.canvasEvent,t)}copyControl(t){if(!t)return;const e=
|
|
546
|
+
}`;R.append(document.createTextNode(u)),setTimeout(()=>{a.write(`${R.outerHTML}${c.innerHTML}`),s.print(),a.close(),window.addEventListener("mouseover",()=>{r?.remove()},{once:!0})})}const eg=[l.ControlType.TEXT,l.ControlType.TEXTFIELD],Nr=["id","titleId","listId","areaId","hyperlinkId","dateId","labelId","tableId","trId","tdId","pagingId","menstrualHistoryId","fetalHeartPositionId","toothPositionId"];function go(o,t){for(let e=0;e<o.length;e++){const n=o[e];if(n.type===l.ElementType.CONTROL&&n.controlId===t&&n.control)return at(n);if(n.control?.value?.length){const i=go(n.control.value,t);if(i)return i}if(n.valueList?.length){const i=go(n.valueList,t);if(i)return i}if(n.type===l.ElementType.TABLE&&n.trList?.length)for(let i=0;i<n.trList.length;i++){const r=n.trList[i];for(let s=0;s<r.tdList.length;s++){const a=r.tdList[s],c=go(a.value,t);if(c)return c}}}return null}function ng(o){const t=new Map,e=new Map,n=a=>a&&(t.has(a)||t.set(a,lt()),t.get(a)),i=a=>a&&(e.has(a)||e.set(a,lt()),e.get(a)),r=a=>{a.controlId&&(a.controlId=n(a.controlId)),a.originControlId&&(a.originControlId=n(a.originControlId));for(let c=0;c<Nr.length;c++){const d=Nr[c],R=a[d];if(typeof R=="string"){const u=a;u[d]=i(R)}}a.groupIds?.length&&(a.groupIds=a.groupIds.map(c=>i(c))),a.valueList?.length&&a.valueList.forEach(r),a.control?.value?.length&&a.control.value.forEach(r),a.trList?.length&&a.trList.forEach(c=>{const d=c;typeof d.id=="string"&&(d.id=i(d.id)),c.tdList.forEach(R=>{const u=R;typeof u.id=="string"&&(u.id=i(u.id)),R.value.forEach(r)})})},s=at(o);return r(s),s}function og(o,t,e){let n=-1;const i=!!e;for(let r=0;r<o.length;r++){const s=o[r];if(i?s.controlId===t&&s.originControlId===e:s.controlId===t&&!s.originControlId)n=r;else if(~n)break}return n}class ig{draw;range;position;historyManager;canvasEvent;options;control;workerManager;searchManager;i18n;zone;tableOperate;constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n(),this.zone=t.getZone(),this.tableOperate=t.getTableOperate()}getIsRangeInTextField(){const{startIndex:t}=this.range.getRange(),e=this.draw.getElementList(),n=e[t];if(!n)return!1;let i=null;const r=s=>{if(!s)return null;for(let a=t;a>=0;a--){const c=e[a];if(c.controlId===s&&c.control?.type===l.ControlType.TEXTFIELD&&(c.controlComponent===l.ControlComponent.PRETEXTFIX||c.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===l.ControlComponent.PREFIX||c.controlComponent===l.ControlComponent.PRE_TEXT))return s}return null};return i=r(n.controlId)||r(n.originControlId),!!i}mode(t){this.draw.setMode(t)}async cut(){this.draw.isReadonly()||this.draw.isDisabled()||await this.canvasEvent.cut()}async copy(t){await this.canvasEvent.copy(t)}paste(t){this.draw.isReadonly()||this.draw.isDisabled()||sa(this.canvasEvent,t)}copyControl(t){if(!t)return;const e=Mt(this.draw.getElementList(),{editorOptions:this.options}),n=go(e,t);n&&ta({element:n})}pasteControl(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=es();if(!e?.element)return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.draw.getElementList(),s=ng(e.element),a=s.controlId;if(!a)return;const c=Do([s]);if(!c.length)return;Vt(c,{isHandleFirstElement:!1,editorOptions:this.options});let d=n,R=n,u=i,h=!1,g;const f=n===i;let T=this.control.getActiveControl();!T&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),T=this.control.getActiveControl());const p=T?.getElement();if(p?.control?.type&&eg.includes(p.control.type)&&this.control.getIsRangeWithinControl()){h=!0,g=p.controlId;const L=r[n];f&&(L?.control?.type===l.ControlType.TEXTFIELD||L?.control?.type===l.ControlType.TEXT)&&this.control.removePlaceholder(n)}else if(p?.controlId){const L=og(r,p.controlId,p.originControlId);~L&&(d=L,R=L,u=L)}Ut(r,c,d,{isBreakWhenWrap:!0,editorOptions:this.options}),g&&c.forEach(L=>{L.controlId===a&&!L.originControlId&&(L.originControlId=g)});const m=d+1;R!==u&&this.draw.spliceElementList(r,R+1,u-R),this.draw.spliceElementList(r,m,0,c);const I=d+c.length;this.range.setRange(I,I),this.draw.render({curIndex:I}),h&&this.control.emitControlContentChange()}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:i}=this.range.getRange(),r=n===i;if(r&&e[n].value===_&&n===0)return;r?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,i-n);const s=r?n-1:n;this.range.setRange(s,s),this.draw.render({curIndex:s})}setRange(t,e,n,i,r,s,a){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,i,r,s,a);const c=t===e;this.draw.render({curIndex:c?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:c})}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setPositionContext(t){const{tableId:e,startTrIndex:n,startTdIndex:i}=t,r=this.draw.getOriginalElementList();if(e){const s=r.findIndex(R=>R.id===e);if(!~s)return;const c=r[s].trList[n],d=c.tdList[i];this.position.setPositionContext({isTable:!0,index:s,trIndex:n,tdIndex:i,tdId:d.id,trId:c.id,tableId:e})}else this.position.setPositionContext({isTable:!1})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}blur(){this.range.clearRange(),this.draw.getCursor().recoveryCursor()}hideCursor(){this.draw.getCursor().recoveryCursor()}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(!t.isDblclick&&this.draw.getPainterStyle()){this.canvasEvent.clearPainterStyle();return}const e=this.range.getSelection();if(!e)return;const n={};e.forEach(i=>{Re.forEach(s=>{const a=s;n[a]===void 0&&Reflect.set(n,a,i[a])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.draw.isReadonly()||this.draw.isDisabled()||this.canvasEvent.applyPainterStyle()}format(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();let r={},s=[];if(i?.length)s=i,r={isSetCursor:!1};else{const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];d?.value===_&&(s.push(d),r={curIndex:a})}s.length&&(s.forEach(a=>{Re.forEach(c=>{delete a[c]})}),this.draw.render(r))}buttonText(t){if(t)if([...t.element].filter(i=>i.newButtonValue&&i.newButtonValue.length>0).length){const i=t.controlId;this.removeButtonElementsByControlId(i+"_text").then(()=>{setTimeout(()=>{this.insertButtonValue(t)},500)})}else{const i=t.controlId;i&&this.removeButtonElementsByControlId(i+"_text")}}triggerControlEditAttribute(t){const n=this.draw.getElementList().filter(r=>r.controlId===t);this.draw.getEventBus().emit("controlEditAttribute",{controlId:t,element:n})}editElementAttribute(t){const e=this.draw.getElementList();if(t.controlId&&t.type==="button"){const n=[];e.forEach((h,g)=>{h.controlId===t.controlId&&h.control?.type==="button"&&n.push(g)});const i=[];let r=null;n.forEach(h=>{const g=e[h];g.controlComponent===l.ControlComponent.VALUE&&(i.push(h),r||(r=g))}),i.sort((h,g)=>g-h).forEach(h=>{e.splice(h,1)});let s=-1;for(let h=0;h<e.length;h++){const g=e[h];if(g.controlId===t.controlId&&g.control?.type==="button"){if(g.controlComponent===l.ControlComponent.PREFIX||g.controlComponent===l.ControlComponent.PRE_TEXT){s=h+1;break}s===-1&&(s=h+1)}}if(s===-1&&n.length>0){const h=[];e.forEach((g,f)=>{g.controlId===t.controlId&&g.control?.type==="button"&&h.push(f)}),h.length>0&&(s=h[0]+1)}const a=t.label||"";for(let h=0;h<a.length;h++){const g={value:a[h],controlId:t.controlId,type:l.ElementType.CONTROL,control:{type:"button",buttonLabel:a,code:t.code,value:[{value:a}],label:a,hide:!1},controlComponent:l.ControlComponent.VALUE,color:r?.color||"#fff",highlight:r?.highlight||"#1677FF",style:r?.style||"16px Microsoft YaHei",hide:!1};e.splice(s+h,0,g)}e.filter(h=>h.controlId===t.controlId&&h.control?.type==="button").forEach(h=>{h.control&&(h.control.buttonLabel=t.label,h.control.label=t.label,h.control.code=t.code,h.control.hide=!1,h.control.value=[{value:t.label}]),h.hide=!1});const{startIndex:c,endIndex:d}=this.range.getRange(),R=!0,u=d;this.draw.render({curIndex:u,isSetCursor:R})}else if(t.controlId){const n=t.controlId;if(e.forEach(r=>{r.controlId===n&&r.control&&(t.label!==void 0&&(r.control.label=t.label),t.placeholder!==void 0&&(r.control.placeholder=t.placeholder),t.code!==void 0&&(r.control.code=t.code),t.value!==void 0&&(r.control.value=t.value?[{value:t.value}]:null),t.valueSets!==void 0&&(r.control.valueSets=t.valueSets),t.dateFormat!==void 0&&(r.control.dateFormat=t.dateFormat),t.numberExclusiveOptions!==void 0&&(r.control.numberExclusiveOptions=t.numberExclusiveOptions),t.underline!==void 0&&(r.control.underline=t.underline))}),t.placeholder!==void 0){const r=t.placeholder,s=[];if(e.forEach((a,c)=>{a.controlId===n&&a.controlComponent==="placeholder"&&s.push({element:a,index:c})}),s.length===r.length)s.forEach((a,c)=>{a.element.value=r[c]===`
|
|
547
547
|
`?_:r[c]});else if(s.length>0){const a={...s[0].element};s.sort((d,R)=>R.index-d.index).forEach(d=>{e.splice(d.index,1)});const c=Math.min(...s.map(d=>d.index));for(let d=0;d<r.length;d++){const R=r[d]===`
|
|
548
|
-
`?_:r[d];e.splice(c+d,0,{...a,value:R})}}}const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isSetCursor:!0})}}delButton(t,e){return new Promise(n=>{for(let i=t.length-1;i>=0;i--)e.some(s=>s.controlId===t[i].controlId&&s.type===t[i].type)&&t.splice(i,1);n(!0)})}editButton(t,e,n){const i=this.draw.getElementList();n=n+1;for(let d=0;d<e.label.length;d++){const R={value:e.label[d],controlId:e.controlId,type:l.ElementType.CONTROL,control:{type:"button",buttonLabel:e.label,code:e.code,value:[{value:e.label}],label:e.label,hide:!1},controlComponent:"value",color:"#fff",highlight:"#1677FF",style:"16px Microsoft YaHei",hide:!1};i.splice(n+d,0,R)}const{startIndex:r,endIndex:s}=this.range.getRange(),a=!0,c=s;this.draw.render({curIndex:c,isSetCursor:a})}removeButtonElementsByControlId(t){return new Promise(e=>{const n=this.draw.getElementList();for(let c=n.length-1;c>=0;c--)n[c].controlId===t&&n.splice(c,1);const{startIndex:i,endIndex:r}=this.range.getRange(),s=!0,a=r;this.draw.render({curIndex:a,isSetCursor:s}),e(!0)})}removeByValue(t,e){return new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text"||t[c].type=="buttonText")&&t[c].control?.buttonLabel===e&&t[c].control?.buttonText&&t.splice(c,1);const{startIndex:i,endIndex:r}=this.range.getRange(),s=!0,a=r;this.draw.render({curIndex:a,isSetCursor:s}),n(!0)})}insertButtonValue(t){const e=this.draw.getElementList(),n=t.controlId,i=t.element[0].newButtonValue,r=t.element[0].control.buttonLabel,s=t.element[0].control.code;if(!i||!i.length)return;let a=-1;for(let p=0;p<e.length;p++)if(e[p].controlId===n&&e[p].control?.type==="button"){a=p;break}if(a===-1)return;const c=n+"_text",d=[];for(let p=0;p<i.length;p++){const m=i[p];d.push({value:m.value,code:m.code})}const R={type:"button",buttonLabel:r,buttonText:!0,label:r,code:s,value:d,hide:!1},u=[];u.push({value:"[",controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.PREFIX,color:"#1677FF",hide:!1});for(let p=0;p<i.length;p++){const m=i[p],I=i.length>1?`${p+1}.${m.value}`:m.value,L=ct(I);for(let P=0;P<L.length;P++)u.push({value:L[P],controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.VALUE,color:"#000",hide:!1});i.length>1&&p<i.length-1&&u.push({value:_,controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.VALUE,color:"#000",hide:!1})}u.push({value:"]",controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.POSTFIX,color:"#1677FF",hide:!1});for(let p=0;p<u.length;p++)e.splice(a+p,0,u[p]);const{startIndex:h,endIndex:g}=this.range.getRange(),f=!0,T=g;this.draw.render({curIndex:T,isSetCursor:f})}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length)r.forEach(s=>{s.font=t}),this.draw.render({isSetCursor:!1});else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({font:t}),d?.value===_?d.font=t:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:r,maxSize:s,defaultSize:a}=this.options;if(t<r||t>s)return;let c={},d=[];const R=this.range.getTextLikeSelectionElementList();if(R?.length)d=R,c={isSetCursor:!1};else{const{endIndex:h}=this.range.getRange(),f=this.draw.getElementList()[h];this.range.setDefaultStyle({size:t}),f?.value===_?(d.push(f),c={curIndex:h}):this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}if(!d.length)return;let u=!1;d.forEach(h=>{!h.size&&t===a||h.size&&h.size===t||(h.size=t,u=!0)}),u&&this.draw.render(c)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let a={},c=[];if(s?.length)c=s,a={isSetCursor:!1};else{const{endIndex:R}=this.range.getRange(),h=this.draw.getElementList()[R],f=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:f+2>r?r:f+2}),h?.value===_?(c.push(h),a={curIndex:R}):this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(R=>{R.size||(R.size=i),!(R.size>=r)&&(R.size+2>r?R.size=r:R.size+=2,d=!0)}),d&&this.draw.render(a)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let a={},c=[];if(s?.length)c=s,a={isSetCursor:!1};else{const{endIndex:R}=this.range.getRange(),h=this.draw.getElementList()[R],f=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:f-2<r?r:f-2}),h?.value===_?(c.push(h),a={curIndex:R}):this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(R=>{R.size||(R.size=i),!(R.size<=r)&&(R.size-2<r?R.size=r:R.size-=2,d=!0)}),d&&this.draw.render(a)}bold(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const r=i.findIndex(s=>!s.bold);i.forEach(s=>{s.bold=!!~r}),this.draw.render({isSetCursor:!1})}else{let r=!0;const{endIndex:s}=this.range.getRange(),c=this.draw.getElementList()[s];this.range.setDefaultStyle({bold:c.bold?!1:!this.range.getDefaultStyle()?.bold}),c?.value===_?c.bold=!c.bold:r=!1,this.draw.render({isSubmitHistory:r,curIndex:s,isCompute:!1})}}italic(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const r=i.findIndex(s=>!s.italic);i.forEach(s=>{s.italic=!!~r}),this.draw.render({isSetCursor:!1})}else{let r=!0;const{endIndex:s}=this.range.getRange(),c=this.draw.getElementList()[s];this.range.setDefaultStyle({italic:c.italic?!1:!this.range.getDefaultStyle()?.italic}),c?.value===_?c.italic=!c.italic:r=!1,this.draw.render({isSubmitHistory:r,curIndex:s,isCompute:!1})}}underline(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length){const s=r.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!Br(a.textDecoration,t));r.forEach(a=>{a.underline=s,s&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d?.underline?!1:!this.range.getDefaultStyle()?.underline}),d?.value===_?d.underline=!d.underline:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}strikeout(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const r=i.findIndex(s=>!s.strikeout);i.forEach(s=>{s.strikeout=!!~r}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let r=!0;const{endIndex:s}=this.range.getRange(),c=this.draw.getElementList()[s];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!this.range.getDefaultStyle()?.strikeout}),c?.value===_?c.strikeout=!c.strikeout:r=!1,this.draw.render({isSubmitHistory:r,curIndex:s,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===l.ElementType.SUPERSCRIPT);i.forEach(s=>{~r?s.type===l.ElementType.SUPERSCRIPT&&(s.type=l.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===l.ElementType.TEXT||s.type===l.ElementType.SUBSCRIPT)&&(s.type=l.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===l.ElementType.SUBSCRIPT);i.forEach(s=>{~r?s.type===l.ElementType.SUBSCRIPT&&(s.type=l.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===l.ElementType.TEXT||s.type===l.ElementType.SUPERSCRIPT)&&(s.type=l.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length)r.forEach(s=>{t?s.color=t:delete s.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({color:t||void 0}),d?.value===_?t?d.color=t:delete d.color:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length)r.forEach(s=>{t?s.highlight=t:delete s.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({highlight:t||void 0}),d?.value===_?t?d.highlight=t:delete d.highlight:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.draw.getElementList(),s=n===i?this.range.getRangeParagraphElementList():r.slice(n+1,i+1);if(!s||!s.length)return;const a=lt(),c=this.draw.getOptions().title;s.forEach(u=>{!u.type&&u.value===_||(t?(u.level=t,u.titleId=a,vn(u)&&(u.size=c[xi[t]],u.bold=!0)):u.titleId&&(delete u.titleId,delete u.title,delete u.level,delete u.size,delete u.bold))});const d=n===i,R=d?i:n;this.draw.render({curIndex:R,isSetCursor:d})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(c=>{c.rowFlex=t});const s=n===i,a=s?i:n;this.draw.render({curIndex:a,isSetCursor:s})}vertical(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(c=>{c.vertical=t});const s=n===i,a=s?i:n;this.draw.render({curIndex:a,isSetCursor:s})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(c=>{c.rowMargin=t});const s=n===i,a=s?i:n;this.draw.render({curIndex:a,isSetCursor:s})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}tableProperties(){this.draw.isReadonly()||this.tableOperate.tableProperties()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!e?.length||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:a,endIndex:c}=this.range.getRange();!~a&&!~c||this.insertElementList([{type:l.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||lt()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),s=r[n];if(s.type!==l.ElementType.HYPERLINK)return null;let a=n;for(;a>0;){if(r[a].hyperlinkId!==s.hyperlinkId){t=a+1;break}a--}let c=n+1;for(;c<r.length;){if(r[c].hyperlinkId!==s.hyperlinkId){e=c-1;break}c++}return c===r.length&&(e=c-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;this.draw.spliceElementList(n,i,r-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const s=i-1;this.range.setRange(s,s),this.draw.render({curIndex:s})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;for(let a=i;a<=r;a++){const c=n[a];delete c.type,delete c.url,delete c.hyperlinkId,delete c.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[r,s]=n;for(let c=r;c<=s;c++){const d=i[c];d.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:a}=this.range.getRange();this.draw.render({curIndex:a,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl())return;const{startIndex:r,endIndex:s}=this.range.getRange();if(!~r&&!~s)return;const a=this.draw.getElementList();let c=-1;const d=a[s+1];if(d&&d.type===l.ElementType.SEPARATOR){if(d.dashArray&&d.dashArray.join()===t.join())return;c=s,Object.assign(d,{dashArray:t,...e})}else{const R={value:Ni,type:l.ElementType.SEPARATOR,dashArray:t,...e};Ut(a,[R],r,{editorOptions:this.options}),r!==0&&a[r].value===_?(this.draw.spliceElementList(a,r,1,[R]),c=r-1):(this.draw.spliceElementList(a,r+1,0,[R]),c=r)}this.range.setRange(c,c),this.draw.render({curIndex:c})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:l.ElementType.PAGE_BREAK,value:Ni}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:r,opacity:s,font:a,gap:c}=Vo;n.watermark.data=t.data,n.watermark.type=t.type||l.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||s,n.watermark.size=t.size||r,n.watermark.font=t.font||a,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||c,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark={...Vo},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=t.id||lt();return this.insertElementList([{...t,id:r,type:l.ElementType.IMAGE}]),r}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:r}=this.options;t!==1&&this.draw.setPageScale(1);const s=await this.draw.getDataURL({pixelRatio:e,mode:l.EditorMode.PRINT});tg(s,{width:i,height:r,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==l.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==l.ElementType.IMAGE||bi(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==l.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];i?.type===l.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===l.ImageDisplay.SURROUND||e===l.ImageDisplay.FLOAT_TOP||e===l.ImageDisplay.FLOAT_BOTTOM){const r=this.position.getPositionList(),{pageNo:s,coordinate:{leftTop:a}}=r[n];t.imgFloatPosition={pageNo:s,x:a[0],y:a[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getPageMode(){return this.options}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:qe(e,t).innerHTML,main:qe(n,t).innerHTML,footer:qe(i,t).innerHTML}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:en(t),main:en(e),footer:en(n)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((c,d)=>c+d.height+(d.offsetY||0),0),r=this.draw.getHeight(),s=this.draw.getMainOuterHeight(),a=r-(s+i);return a>0?a:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=at(t);Vt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=wo(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((s,a)=>s+a.height+(a.offsetY||0),0)}getRange(){return at(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,r=this.range.toString(),s=Pt(this.range.getSelectionElementList()||[]),a=this.draw.getElementList(),c=De(a[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),d=De(a[n],{extraPickAttrs:["id","controlComponent"]}),R=this.draw.getRowList(),u=this.position.getPositionList(),h=u[e],g=u[n],f=h?.pageNo,T=g?.pageNo,p=h?.rowIndex,m=g?.rowIndex,I=R[p],L=R[m];let P=0,O=0;this.draw.getCursor().getHitLineStartIndex()||(P=I?.elementList[0]?.value===_?h?.index-I?.startIndex:h?.index-I?.startIndex+1),h===g?O=P:O=L.elementList[0]?.value===_?g.index-L.startIndex:g.index-L.startIndex+1;const S=[],F=this.draw.getOriginalHeight(),N=this.draw.getOriginalPageGap(),V=this.position.getSelectionPositionList();if(V){let U=null,Q=0,G=null;for(let H=0;H<V.length;H++){const{rowNo:j,pageNo:st,coordinate:{leftTop:it,rightTop:nt},lineHeight:et}=V[H];U===null||U!==j?(G&&S.push(G),G={x:it[0],y:it[1]+st*(F+N),width:nt[0]-it[0],height:et},U=j,Q=it[0]):G.width=nt[0]-Q,H===V.length-1&&G&&S.push(G)}}else{const Q=this.position.getPositionList()[n],{coordinate:{rightTop:G},pageNo:H,lineHeight:j}=Q;S.push({x:G[0],y:G[1]+H*(F+N),width:0,height:j})}const Y=this.draw.getZone().getZone(),{isTable:X,trIndex:b,tdIndex:E,index:C}=this.position.getPositionContext();let M=null;if(X){const Q=this.draw.getOriginalElementList()[C]||null;Q&&(M=Pt([Q])[0])}let y=null,W=null,D=e-1;for(;D>0;){const U=a[D],Q=a[D-1];if(U.titleId&&U.titleId!==Q?.titleId){y=U.titleId,W=u[D].pageNo;break}D--}return at({isCollapsed:i,startElement:c,endElement:d,startPageNo:f,endPageNo:T,startRowNo:p,endRowNo:m,startColNo:P,endColNo:O,rangeRects:S,zone:Y,isTable:X,trIndex:b??null,tdIndex:E??null,tableElement:M,selectionText:r,selectionElementList:s,titleId:y,titleStartPageNo:W})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?Pt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?Pt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),r=this.draw.getOriginalMainElementList();for(let s=0;s<e.length;s++){const a=e[s],{startIndex:c,endIndex:d,tableId:R,startTrIndex:u,startTdIndex:h}=a;let g=i;if(a.tableId){const p=r.find(m=>m.id===R);p&&(g=p.trList?.[u]?.tdList?.[h]?.positionList||[])}const f=at(g[c]),T=at(g[d]);n.push({range:a,startPosition:f,endPosition:T})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:r}=e;i||this.range.shrinkRange(),console.log(t,"payload");const s=at(t),{startIndex:a}=this.range.getRange(),c=this.draw.getElementList();Ut(c,s,a,{ignoreContextKeys:r,isBreakWhenWrap:!0,editorOptions:this.options}),console.log(s,"cloneElementList"),this.draw.insertElementList(s,e),setTimeout(()=>{console.log(c,"elementList")},500)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(at(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function r(a,c=!1){let d=0;for(;d<a.length;){const R=a[d];if(d++,R.type===l.ElementType.TABLE){const u=R.trList;for(let h=0;h<u.length;h++){const g=u[h];for(let f=0;f<g.tdList.length;f++){const T=g.tdList[f];r(T.value,c)}}}R.type===l.ElementType.CONTROL&&R.control?.value&&r(R.control.value,!0),(e&&R.id===e||n&&R.conceptId===n)&&i.push({elementList:a,index:d-1,isInsideControl:c})}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);if(i.length){for(let a=0;a<i.length;a++){const{elementList:c,index:d,isInsideControl:R}=i[a],u=c[d],h=u.controlId&&u.controlComponent===l.ControlComponent.VALUE;if(R||h){if(Object.assign(u,t.properties),u.id){const g=xl(u.id);g&&Object.assign(g,t.properties)}}else{const g=Pt([{...u,...t.properties}],{extraPickAttrs:["id"]});g.length>0&&g[0]?(Ye(Ke,u,g[0]),Vt(g,{isHandleFirstElement:!1,editorOptions:this.options}),c[d]=g[0]):Object.assign(u,t.properties)}}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function r(a){let c=0;for(;c<a.length;){const d=a[c];if(d.type===l.ElementType.TABLE){const R=d.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];r(f.value)}}}d.type===l.ElementType.CONTROL&&d.control?.value&&r(d.control.value),(e&&d.id===e||n&&d.conceptId===n)&&(i=!0,a.splice(c,1),c--),c++}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);i&&this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const r=a=>{let c=0;for(;c<a.length;){const d=a[c];if(c++,d.type===l.ElementType.TABLE){const R=d.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];r(f.value)}}}e&&d.id!==e||n&&d.conceptId!==n||i.push(d)}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);return Pt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if(t?.id||t?.conceptId){const{id:e,conceptId:n}=t;let i=!1;const r=a=>{let c=a.length-1;for(;c>=0;){const d=a[c];if(d.type===l.ElementType.TABLE){const R=d.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];r(f.value)}}}c--,!(!d.control||e&&d.controlId!==e||n&&d.control.conceptId!==n)&&(i=!0,a.splice(c+1,1))}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const a=this.draw.getControl().removeControl(e);if(a===null)return;this.range.setRange(a,a),this.draw.render({curIndex:a})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(m,I){for(let L=0;L<m.length;L++){const P=m[L];if(P.type===l.ElementType.TABLE){const O=P.trList;for(let S=0;S<O.length;S++){const F=O[S];for(let N=0;N<F.tdList.length;N++){const V=F.tdList[N],Y=n(V.value,I);if(Y)return{...Y,isTable:!0,index:L,trIndex:S,tdIndex:N,tdId:V.id,trId:F.id,tableId:P.id}}}}if(P.titleId===I){let O=L;for(;O<m.length;){if(m[O+1]?.titleId!==I)return{isTable:!1,startIndex:O,endIndex:O};O++}}}return null}const i=n(e,t);if(!i)return;const{isTable:r,index:s,startTdIndex:a,endTdIndex:c,startTrIndex:d,endTrIndex:R,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T,endIndex:p}=i;this.position.setPositionContext({isTable:r,index:s,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T}),this.range.setRange(p,p,T,a,c,d,R),this.draw.render({curIndex:p,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===_)for(;n+1<t.length;){const r=t[n+1];if(r.value!==_&&r.value!==fo)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i}=t,r=this.draw.getOriginalInnerWidth(),s=a=>a!==void 0?tn(a,{innerWidth:r}):void 0;this.setValue({header:s(e),main:s(n),footer:s(i)})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:r,trIndex:s,tdIndex:a,tdId:c,trId:d,tableId:R,endIndex:u}=n;this.position.setPositionContext({isTable:i,index:r,trIndex:s,tdIndex:a,tdId:c,trId:d,tableId:R}),this.range.setRange(u,u),this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}updateOptions(t){const e=Yo(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}setFormModeTrace(t){Object.assign(this.options.modeRule.form,t),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){function n(r,s){let a=0;for(;a<r.length;){const c=r[a];if(a++,c.type===l.ElementType.TABLE){const R=c.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g],T=n(f.value,s);if(T)return{...T,positionContext:{isTable:!0,index:a-1,trIndex:u,tdIndex:g,tdId:c.tdId,trId:c.trId,tableId:c.tableId}}}}}if(c?.controlId!==t)continue;let d=a-1;if(e?.position===l.LocationPosition.OUTER_AFTER){if(!(c.controlComponent===l.ControlComponent.POSTFIX&&r[a+1]?.controlComponent!==l.ControlComponent.POST_TEXT))continue}else if(e?.position===l.LocationPosition.OUTER_BEFORE)d-=1;else if(e?.position===l.LocationPosition.AFTER){if(d-=1,c.controlComponent!==l.ControlComponent.PLACEHOLDER&&c.controlComponent!==l.ControlComponent.POSTFIX&&c.controlComponent!==l.ControlComponent.POST_TEXT)continue}else if(c.controlComponent!==l.ControlComponent.PREFIX&&c.controlComponent!==l.ControlComponent.PRE_TEXT||r[a]?.controlComponent===l.ControlComponent.PREFIX||r[a]?.controlComponent===l.ControlComponent.PRE_TEXT)continue;return{zone:s,range:{startIndex:d,endIndex:d},positionContext:{isTable:!1}}}return null}const i=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const r of i){const s=n(r.elementList,r.zone);if(s){this.setZone(s.zone),this.position.setPositionContext(s.positionContext),this.range.replaceRange(s.range),this.draw.render({curIndex:s.range.startIndex,isCompute:!1,isSubmitHistory:!1});break}}}insertTextField(t){if(this.draw.isReadonly()||this.draw.isDisabled()||!t)return;const n=at(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=je(r,i);if(!s)return;const a=[...Be,...Bt,...mn,...Ke];Ye(a,s,n),this.draw.insertElementTextField([n])}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=je(r,i);if(!s)return;const a=r[i],c=a?.controlComponent===l.ControlComponent.POSTFIX||a?.controlComponent===l.ControlComponent.POSTTEXTFIX;let d=!1;if(a?.controlId&&!c)for(let u=i;u>=0;u--){const h=r[u];if(h.controlId!==a.controlId)break;if(h.controlComponent===l.ControlComponent.PRETEXTFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){h.control?.type===l.ControlType.TEXTFIELD&&(d=!0);break}}if(!d&&!c){const u=r[i-1];if(u?.controlId)for(let h=i-1;h>=0;h--){const g=r[h];if(g.controlId!==u.controlId)break;if(g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){g.control?.type===l.ControlType.TEXTFIELD&&(d=!0);break}}}if(d&&t.control?.type===l.ControlType.TEXTFIELD)return;const R=[...Be,...Bt,...mn,...Ke];Ye(R,s,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t?.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(s,a)=>{let c=0;for(;c<s.length;){const d=s[c];if(c++,d.type===l.ElementType.TABLE){const h=d.trList;for(let g=0;g<h.length;g++){const f=h[g];for(let T=0;T<f.tdList.length;T++){const p=f.tdList[T];i(p.value,a)}}}if(d?.title?.conceptId!==e)continue;const R=[];let u=c;for(;u<s.length;){const h=s[u];if(u++,d.titleId!==h.titleId){if(h.level&&bo[h.level]<=bo[d.level])break;R.push(h)}}n.push({...d.title,value:en(R),elementList:Pt(R),zone:a}),c=u}},r=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:s,elementList:a}of r)i(a,s);return n}getPositionContextByEvent(t,e={}){const n=t.target?.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,r=Number(n),s=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:r}),{isDirectHit:a,isTable:c,index:d,trIndex:R,tdIndex:u,tdValueIndex:h,zone:g}=s;if(i&&!a||g&&g!==this.zone.getZone())return null;let f=null,T=null;const p=this.draw.getOriginalElementList();let m=null;const I=this.position.getOriginalPositionList();if(c){const P=p[d].trList?.[R].tdList[u];T=P?.value[h]||null,m=P?.positionList?.[h]||null,f={element:p[d],trIndex:R,tdIndex:u}}else T=p[d]||null,m=I[d]||null;let L=null;if(m){const{pageNo:P,coordinate:{leftTop:O,rightTop:S},lineHeight:F}=m,N=this.draw.getOriginalHeight(),V=this.draw.getOriginalPageGap();L={x:O[0],y:O[1]+P*(N+V),width:S[0]-O[0],height:F}}return{pageNo:r,element:T,rangeRect:L,tableInfo:f}}insertTitle(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=je(r,i);if(!s)return;const a=[...Be,...Bt,...mn,...Ke];n.valueList?.forEach(c=>{Ye(a,s,c)}),this.draw.insertElementList([n])}focus(t){const{position:e=l.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:r}=t||{};let s=-1;if(r)this.range.replaceRange(r),s=e===l.LocationPosition.BEFORE?r.startIndex:r.endIndex;else if(Mo(i)){const c=this.draw.getOriginalRowList();if(s=e===l.LocationPosition.BEFORE?c[i]?.startIndex:c[i+1]?.startIndex-1,!Mo(s))return;this.range.setRange(s,s)}else s=e===l.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(s,s);const a={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~s&&this.range.getIsCollapsed()&&(a.curIndex=s,a.isSetCursor=!0),this.draw.render(a)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if(e?.isAppendLastLineBreak&&e?.position===l.LocationPosition.OUTER_AFTER){const r=this.draw.getOriginalMainElementList();r[r.length-1].areaId===t&&this.draw.appendElementList([{value:_}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getMacroValue(t){const{id:e,dictCode:n,label:i,areaId:r}=t,s=[],a=(d,R)=>{for(const u of d){if(u.type===l.ElementType.TABLE){const g=u.trList;for(const f of g)for(const T of f.tdList)a(T.value,R);continue}if(u.type!==l.ElementType.MACRO&&u.type!==l.ElementType.CUSTOM_MACRO&&u.type!==l.ElementType.REUSABLE_ITEM||e&&u.id!==e||n&&u.dictCode!==n||i&&u.label!==i||r&&u.areaId!==r)continue;const h={id:u.id,type:u.type,label:u.label,dictCode:u.dictCode,zone:R};u.type===l.ElementType.MACRO?h.value=u.value:u.type===l.ElementType.CUSTOM_MACRO?(h.macroConfig=u.macroConfig,h.value=u.macroConfig?.value):u.type===l.ElementType.REUSABLE_ITEM&&(h.reusableItemConfig=u.reusableItemConfig,h.value=u.reusableItemConfig?.value),s.push(h)}},c=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:d,elementList:R}of c)a(R,d);return s}getMacroList(){const t=[],e=i=>{for(const r of i){if(r.type===l.ElementType.TABLE){const s=r.trList;for(const a of s)for(const c of a.tdList)e(c.value);continue}(r.type===l.ElementType.MACRO||r.type===l.ElementType.CUSTOM_MACRO||r.type===l.ElementType.REUSABLE_ITEM)&&t.push(r)}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i);return t}setMacroValue(t){const{id:e,dictCode:n,label:i,areaId:r,value:s,code:a,isSubmitHistory:c=!0}=t;let d=!1;const R=h=>{for(let g=0;g<h.length;g++){const f=h[g];if(f.type===l.ElementType.TABLE){const T=f.trList;for(const p of T)for(const m of p.tdList)R(m.value);continue}f.type!==l.ElementType.MACRO&&f.type!==l.ElementType.CUSTOM_MACRO&&f.type!==l.ElementType.REUSABLE_ITEM||e&&f.id!==e||n&&f.dictCode!==n||i&&f.label!==i||r&&f.areaId!==r||(d=!0,f.type===l.ElementType.MACRO?f.value=s:f.type===l.ElementType.CUSTOM_MACRO?f.macroConfig?(f.macroConfig.value=s,a!==void 0&&(f.macroConfig.code=a)):f.macroConfig={type:"text",value:s}:f.type===l.ElementType.REUSABLE_ITEM&&(f.reusableItemConfig?f.reusableItemConfig.value=s:f.reusableItemConfig={value:s}))}},u=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const h of u)R(h);d&&this.draw.render({isSubmitHistory:c,isSetCursor:!1})}setMacroValueList(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{for(let a=0;a<s.length;a++){const c=s[a];if(c.type===l.ElementType.TABLE){const g=c.trList;for(const f of g)for(const T of f.tdList)i(T.value);continue}if(c.type!==l.ElementType.MACRO&&c.type!==l.ElementType.CUSTOM_MACRO&&c.type!==l.ElementType.REUSABLE_ITEM)continue;const d=t.find(g=>g.id&&c.id===g.id||g.dictCode&&c.dictCode===g.dictCode||g.label&&c.label===g.label||g.areaId&&c.areaId===g.areaId);if(!d)continue;const{value:R,code:u,isSubmitHistory:h=!0}=d;e=!0,h&&(n=!0),c.type===l.ElementType.MACRO?c.value=R:c.type===l.ElementType.CUSTOM_MACRO?c.macroConfig?(c.macroConfig.value=R,u!==void 0&&(c.macroConfig.code=u)):c.macroConfig={type:"text",value:R}:c.type===l.ElementType.REUSABLE_ITEM&&(c.reusableItemConfig?c.reusableItemConfig.value=R:c.reusableItemConfig={value:R})}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const s of r)i(s);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}updateMacroProperties(t){const{id:e,dictCode:n,label:i,areaId:r,properties:s,isSubmitHistory:a=!0}=t;let c=!1;const d=u=>{for(let h=0;h<u.length;h++){const g=u[h];if(g.type===l.ElementType.TABLE){const f=g.trList;for(const T of f)for(const p of T.tdList)d(p.value);continue}g.type!==l.ElementType.MACRO&&g.type!==l.ElementType.CUSTOM_MACRO&&g.type!==l.ElementType.REUSABLE_ITEM||e&&g.id!==e||n&&g.dictCode!==n||i&&g.label!==i||r&&g.areaId!==r||(c=!0,Object.assign(g,s))}},R=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const u of R)d(u);c&&this.draw.render({isSubmitHistory:a,isSetCursor:!1})}locationMacro(t){const{id:e,dictCode:n,label:i,areaId:r}=t,s=(c,d)=>{for(let R=0;R<c.length;R++){const u=c[R];if(u.type===l.ElementType.TABLE){const h=u.trList;for(let g=0;g<h.length;g++){const f=h[g];for(let T=0;T<f.tdList.length;T++){const p=f.tdList[T],m=s(p.value,d);if(m)return{...m,isTable:!0,index:R,trIndex:g,tdIndex:T,tableId:u.tableId,trId:f.id,tdId:p.id}}}}if(!(u.type!==l.ElementType.MACRO&&u.type!==l.ElementType.CUSTOM_MACRO&&u.type!==l.ElementType.REUSABLE_ITEM)&&!(e&&u.id!==e)&&!(n&&u.dictCode!==n)&&!(i&&u.label!==i)&&!(r&&u.areaId!==r))return{zone:d,index:R}}return null},a=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a){const R=s(d,c);if(R){this.setZone(R.zone),this.position.setPositionContext({isTable:R.isTable||!1,index:R.index,trIndex:R.trIndex,tdIndex:R.tdIndex,tableId:R.tableId,trId:R.trId,tdId:R.tdId}),this.range.replaceRange({startIndex:R.index,endIndex:R.index}),this.draw.render({curIndex:R.index,isCompute:!1,isSubmitHistory:!1});break}}}insertSubTemplate(t){const{label:e,templateId:n,isSubmitHistory:i=!0}=t,r={id:lt(),value:e,type:l.ElementType.SUB_TEMPLATE,label:e,templateId:n,subTemplateExpanded:!1};this.insertElementList([r],{isSubmitHistory:i})}expandSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,r=this.draw.getOriginalMainElementList();for(let s=0;s<r.length;s++){const a=r[s];if(a.type===l.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){a.subTemplateExpanded=!0,a.hide=!0;const c=at(n);Vt(c,{isHandleFirstElement:!1,editorOptions:this.options}),r.splice(s+1,0,...c),this.draw.render({isSubmitHistory:i,isCompute:!0});return}}}collapseSubTemplate(t){const{id:e,isSubmitHistory:n=!0}=t,i=this.draw.getOriginalMainElementList();for(let r=0;r<i.length;r++){const s=i[r];if(s.type===l.ElementType.SUB_TEMPLATE&&(!e||s.id===e)){s.subTemplateExpanded=!1,s.hide=!1;let a=r+1;for(;a<i.length&&i[a].type!==l.ElementType.SUB_TEMPLATE;)a++;a>r+1&&i.splice(r+1,a-r-1),this.draw.render({isSubmitHistory:n,isCompute:!0});return}}}toggleSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,r=this.draw.getOriginalMainElementList();for(let s=0;s<r.length;s++){const a=r[s];if(a.type===l.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){if(a.subTemplateExpanded)this.collapseSubTemplate({id:e,isSubmitHistory:i});else{if(!n){console.warn("子模板内容为空,无法展开");return}this.expandSubTemplate({id:e,content:n,isSubmitHistory:i})}return}}}}class sg{rangeStyleChange;visiblePageNoListChange;intersectionPageNoChange;pageSizeChange;pageScaleChange;saved;contentChange;controlChange;controlContentChange;pageModeChange;zoneChange;constructor(){this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class rg{contextMenu;contextMenuList;getContextMenuList;shortcutList;langMap;constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenu=e,this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}disposeContextMenu(){this.contextMenu.dispose()}}const Fr={SELECTED_TEXT:"%s"},fn={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete",EDIT_ATTRIBUTE:"controlEditAttribute",COPY:"controlCopy",PASTE:"controlPaste"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell",TABLE_PROPERTIES:"tableProperties"}},{CONTROL:{DELETE:lg,EDIT_ATTRIBUTE:ag,COPY:cg,PASTE:dg}}=fn;function yr(o,t){if(t!==l.EditorMode.EDIT)return!1;const n=o?.control?.type,i=o?.controlComponent,r=n===l.ControlType.TEXT||n===l.ControlType.TEXTFIELD||n===l.ControlType.NUMBER||n===l.ControlType.SELECT||n===l.ControlType.DATE||n===l.ControlType.CHECKBOX||n===l.ControlType.RADIO||n===l.ControlType.BUTTON,s=i==="prefix"||i==="preText"||i==="preTextFix"||i==="textFixLabel"||n===l.ControlType.BUTTON&&i==="value";return r&&s}const Rg=[{key:cg,name:"复制控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&yr(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeCopyControl(e)}},{key:dg,name:"粘贴控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.editorTextFocus&&o.options.mode===l.EditorMode.EDIT&&ea(),callback:o=>{o.executePasteControl()}},{key:lg,i18nPath:"contextmenu.control.delete",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&o.options.mode!==l.EditorMode.FORM,callback:o=>{o.executeRemoveControl()}},{key:ag,i18nPath:"contextmenu.control.editAttribute",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&yr(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeTriggerControlEditAttribute(e)}}],{GLOBAL:{CUT:ug,COPY:hg,PASTE:gg,SELECT_ALL:fg,PRINT:Tg}}=fn,mg=[{key:ug,i18nPath:"contextmenu.global.cut",shortCut:`${ve?"⌘":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:hg,i18nPath:"contextmenu.global.copy",shortCut:`${ve?"⌘":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:gg,i18nPath:"contextmenu.global.paste",shortCut:`${ve?"⌘":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:fg,i18nPath:"contextmenu.global.selectAll",shortCut:`${ve?"⌘":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:Tg,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:pg,CANCEL:Lg,EDIT:Ig}}=fn,Pg=[{key:pg,i18nPath:"contextmenu.hyperlink.delete",when:o=>!o.isReadonly&&o.startElement?.type===l.ElementType.HYPERLINK,callback:o=>{o.executeDeleteHyperlink()}},{key:Lg,i18nPath:"contextmenu.hyperlink.cancel",when:o=>!o.isReadonly&&o.startElement?.type===l.ElementType.HYPERLINK,callback:o=>{o.executeCancelHyperlink()}},{key:Ig,i18nPath:"contextmenu.hyperlink.edit",when:o=>!o.isReadonly&&o.startElement?.type===l.ElementType.HYPERLINK,callback:(o,t)=>{const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),t.startElement?.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:Mg,SAVE_AS:Og,TEXT_WRAP:Cg,TEXT_WRAP_EMBED:Sg,TEXT_WRAP_UP_DOWN:Eg,TEXT_WRAP_SURROUND:Xg,TEXT_WRAP_FLOAT_TOP:Ng,TEXT_WRAP_FLOAT_BOTTOM:Fg}}=fn,yg=[{key:Mg,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===l.ElementType.IMAGE,callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:Og,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>!o.editorHasSelection&&o.startElement?.type===l.ElementType.IMAGE,callback:o=>{o.executeSaveAsImageElement()}},{key:Cg,i18nPath:"contextmenu.image.textWrap",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===l.ElementType.IMAGE,childMenus:[{key:Sg,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.BLOCK)}},{key:Eg,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.INLINE)}},{key:Xg,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.SURROUND)}},{key:Ng,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.FLOAT_TOP)}},{key:Fg,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:Wg,BORDER_ALL:bg,BORDER_EMPTY:Vg,BORDER_DASH:Yg,BORDER_EXTERNAL:Dg,BORDER_INTERNAL:Ug,BORDER_TD:wg,BORDER_TD_TOP:Zg,BORDER_TD_LEFT:Qg,BORDER_TD_BOTTOM:vg,BORDER_TD_RIGHT:Kg,BORDER_TD_BACK:Hg,BORDER_TD_FORWARD:_g,VERTICAL_ALIGN:xg,VERTICAL_ALIGN_TOP:Gg,VERTICAL_ALIGN_MIDDLE:Ag,VERTICAL_ALIGN_BOTTOM:kg,INSERT_ROW_COL:Jg,INSERT_TOP_ROW:Bg,INSERT_BOTTOM_ROW:$g,INSERT_LEFT_COL:zg,INSERT_RIGHT_COL:jg,DELETE_ROW_COL:qg,DELETE_ROW:tf,DELETE_COL:ef,DELETE_TABLE:nf,MERGE_CELL:of,CANCEL_MERGE_CELL:sf}}=fn,rf=[{isDivider:!0},{key:Wg,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:bg,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.ALL)}},{key:Vg,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.EMPTY)}},{key:Yg,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.DASH)}},{key:Dg,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.EXTERNAL)}},{key:Ug,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.INTERNAL)}},{key:wg,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:Zg,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.TOP)}},{key:Kg,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.RIGHT)}},{key:vg,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.BOTTOM)}},{key:Qg,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.LEFT)}},{key:_g,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(l.TdSlash.FORWARD)}},{key:Hg,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(l.TdSlash.BACK)}}]}]},{key:xg,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:Gg,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(l.VerticalAlign.TOP)}},{key:Ag,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(l.VerticalAlign.MIDDLE)}},{key:kg,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(l.VerticalAlign.BOTTOM)}}]},{key:Jg,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:Bg,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:$g,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:zg,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:jg,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:qg,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:tf,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:ef,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:nf,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:of,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==l.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:sf,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class lf{options;draw;command;range;position;i18n;container;contextMenuList;contextMenuContainerList;contextMenuRelationShip;context;constructor(t,e){this.options=t.getOptions(),this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...mg,...rf,...yg,...Rg,...Pg],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){const{contextMenuDisableKeys:e}=this.options,n=[];for(let i=0;i<t.length;i++){const r=t[i];r.disable||r.key&&e.includes(r.key)||(r.isDivider||r.when?.(this.context))&&n.push(r)}return n}_proxyContextMenuEvent=t=>{this.context=this._getContext();const e=this._filterMenuList(this.contextMenuList);e.some(i=>!i.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()};_handleSideEffect=t=>{const e=t.target;this.contextMenuContainerList.some(i=>i.contains(e))||this.dispose()};_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:n,endIndex:i}=this.range.getRange(),r=!!(~n||~i),s=r&&n!==i,{isTable:a,trIndex:c,tdIndex:d,index:R}=this.position.getPositionContext();let u=null;if(a){const I=this.draw.getOriginalElementList()[R]||null;I&&(u=Pt([I],{extraPickAttrs:["id"]})[0])}const h=a&&!!e,g=this.draw.getElementList(),f=g[n]||null,T=g[i]||null,p=this.draw.getZone().getZone();return{startElement:f,endElement:T,isReadonly:t,editorHasSelection:s,editorTextFocus:r,isCrossRowCol:h,zone:p,isInTable:a,trIndex:c??null,tdIndex:d??null,tableElement:u,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${z}-contextmenu-container`),t.setAttribute(de,l.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:n,top:i,parentMenuContainer:r}=t,s=this._createContextMenuContainer(),a=document.createElement("div");a.classList.add(`${z}-contextmenu-content`);let c=null;r&&this.contextMenuRelationShip.set(r,s);for(let P=0;P<e.length;P++){const O=e[P];if(O.isDivider){if(P!==0&&P!==e.length-1&&!e[P-1]?.isDivider){const S=document.createElement("div");S.classList.add(`${z}-contextmenu-divider`),a.append(S)}}else{const S=document.createElement("div");if(S.classList.add(`${z}-contextmenu-item`),O.childMenus){const Y=this._filterMenuList(O.childMenus);Y.some(b=>!b.isDivider)&&(S.classList.add(`${z}-contextmenu-sub-item`),S.onmouseenter=()=>{this._setHoverStatus(S,!0),this._removeSubMenu(s);const b=S.getBoundingClientRect(),E=b.left+b.width,C=b.top;c=this._render({contextMenuList:Y,left:E,top:C,parentMenuContainer:s})},S.onmouseleave=b=>{(!c||!c.contains(b.relatedTarget))&&this._setHoverStatus(S,!1)})}else S.onmouseenter=()=>{this._setHoverStatus(S,!0),this._removeSubMenu(s)},S.onmouseleave=()=>{this._setHoverStatus(S,!1)},S.onclick=()=>{O.callback&&this.context&&O.callback(this.command,this.context),this.dispose()};const F=document.createElement("i");S.append(F),O.icon&&F.classList.add(`${z}-contextmenu-${O.icon}`);const N=document.createElement("span"),V=O.i18nPath?this._formatName(this.i18n.t(O.i18nPath)):this._formatName(O.name||"");if(N.append(document.createTextNode(V)),S.append(N),O.shortCut){const Y=document.createElement("span");Y.classList.add(`${z}-shortcut`),Y.append(document.createTextNode(O.shortCut)),S.append(Y)}a.append(S)}}const d=document.createElement("div");d.classList.add(`${z}-contextmenu-divider`),a.append(d);const R=document.createElement("div");R.classList.add(`${z}-contextmenu-item`),R.onmouseenter=()=>{this._setHoverStatus(R,!0),this._removeSubMenu(s)},R.onmouseleave=()=>{this._setHoverStatus(R,!1)},R.onclick=()=>{this.dispose()};const u=document.createElement("i");R.append(u);const h=document.createElement("span");h.append(document.createTextNode(this.i18n.t("contextmenu.global.cancel"))),R.append(h),a.append(R),s.append(a),s.style.display="block";const g=window.innerWidth,f=s.getBoundingClientRect(),T=f.width,p=n+T>g?n-T:n;s.style.left=`${p}px`;const m=window.innerHeight,I=f.height,L=i+I>m?i-I:i;return s.style.top=`${L}px`,this.contextMenuContainerList.push(s),s}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){e?(t.parentNode?.querySelectorAll(`${z}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Fr),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const r=new RegExp(Fr.SELECTED_TEXT,"g");if(r.test(i)){const s=this.range.toString();i=i.replace(r,s)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const af=[{key:l.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:l.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:l.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:l.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:l.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:l.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:ve?l.KeyMap.COMMA:l.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:ve?l.KeyMap.PERIOD:l.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:l.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.LEFT)}},{key:l.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.CENTER)}},{key:l.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.RIGHT)}},{key:l.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.ALIGNMENT)}},{key:l.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(l.RowFlex.JUSTIFY)}}],cf=[{key:l.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:l.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.FIRST)}},{key:l.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.SECOND)}},{key:l.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.THIRD)}},{key:l.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.FOURTH)}},{key:l.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.FIFTH)}},{key:l.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.SIXTH)}}],df=[{key:l.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(l.ListType.UL,l.ListStyle.DISC)}},{key:l.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(l.ListType.OL)}}];class Rf{draw;command;globalShortcutList;agentShortcutList;constructor(t,e){this.draw=t,this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...af,...cf,...df]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_globalKeydown=t=>{this.globalShortcutList.length&&this.draw.isGlobalShortcutActive()&&this.draw.isTargetInsideEditor(t.target)&&this._execute(t,this.globalShortcutList)};_agentKeydown(t){this.agentShortcutList.length&&(this.draw.isInteractionSuspended()||this._execute(t,this.agentShortcutList))}_execute(t,e){for(let n=0;n<e.length;n++){const i=e[n];if((i.mod?fe(t)===!!i.mod:t.ctrlKey===!!i.ctrl&&t.metaKey===!!i.meta)&&t.shiftKey===!!i.shift&&t.altKey===!!i.alt&&t.key.toLowerCase()===i.key.toLowerCase()){i.disable||(i?.callback?.(this.command),t.preventDefault());break}}}}class uf{editor;constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class hf{eventHub;constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);n&&n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class gf{paste;copy;drop}class Wr{command;version;listener;eventBus;override;register;destroy;use;draw;constructor(t,e,n={}){const i=Yo(n);e=at(e);let r=[],s=[],a=[],c=[];Array.isArray(e)?s=e:(r=e.header||[],s=e.main,a=e.footer||[],c=e.graffiti||[]),[r,s,a].forEach(f=>{Vt(f,{editorOptions:i,isForceCompensation:!0})}),this.version=Qe,this.listener=new sg,this.eventBus=new hf,this.override=new gf,this.draw=new jh(t,i,{header:r,main:s,footer:a,graffiti:c},this.listener,this.eventBus,this.override);const R=this.draw;this.command=new Xr(new ig(R)),R.setCommand(this.command);const u=new lf(R,this.command),h=new Rf(R,this.command);this.register=new rg({contextMenu:u,shortcut:h,i18n:R.getI18n()}),this.destroy=()=>{R.destroy(),h.removeEvent(),u.removeEvent(),this.eventBus.dangerouslyClearAll()};const g=new uf(this);this.use=g.use.bind(g)}setFormModeTrace(t){this.command.executeSetFormModeTrace(t)}pauseInteraction(){this.draw.pauseInteraction()}resumeInteraction(){this.draw.resumeInteraction()}setOverlayActive(t){this.draw.setOverlayActive(t)}suspendGlobalShortcut(t){this.draw.suspendGlobalShortcut(t)}}l.Command=Xr,l.EDITOR_CLIPBOARD=Tn,l.EDITOR_COMPONENT=de,l.Editor=Wr,l.INTERNAL_CONTEXT_MENU_KEY=fn,l.INTERNAL_SHORTCUT_KEY=us,l.LETTER_CLASS=To,l.createDomFromElementList=qe,l.default=Wr,l.getElementListByHTML=tn,l.getTextFromElementList=en,l.splitText=ct,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
548
|
+
`?_:r[d];e.splice(c+d,0,{...a,value:R})}}}const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isSetCursor:!0})}}delButton(t,e){return new Promise(n=>{for(let i=t.length-1;i>=0;i--)e.some(s=>s.controlId===t[i].controlId&&s.type===t[i].type)&&t.splice(i,1);n(!0)})}editButton(t,e,n){const i=this.draw.getElementList();n=n+1;for(let d=0;d<e.label.length;d++){const R={value:e.label[d],controlId:e.controlId,type:l.ElementType.CONTROL,control:{type:"button",buttonLabel:e.label,code:e.code,value:[{value:e.label}],label:e.label,hide:!1},controlComponent:"value",color:"#fff",highlight:"#1677FF",style:"16px Microsoft YaHei",hide:!1};i.splice(n+d,0,R)}const{startIndex:r,endIndex:s}=this.range.getRange(),a=!0,c=s;this.draw.render({curIndex:c,isSetCursor:a})}removeButtonElementsByControlId(t){return new Promise(e=>{const n=this.draw.getElementList();for(let c=n.length-1;c>=0;c--)n[c].controlId===t&&n.splice(c,1);const{startIndex:i,endIndex:r}=this.range.getRange(),s=!0,a=r;this.draw.render({curIndex:a,isSetCursor:s}),e(!0)})}removeByValue(t,e){return new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text"||t[c].type=="buttonText")&&t[c].control?.buttonLabel===e&&t[c].control?.buttonText&&t.splice(c,1);const{startIndex:i,endIndex:r}=this.range.getRange(),s=!0,a=r;this.draw.render({curIndex:a,isSetCursor:s}),n(!0)})}insertButtonValue(t){const e=this.draw.getElementList(),n=t.controlId,i=t.element[0].newButtonValue,r=t.element[0].control.buttonLabel,s=t.element[0].control.code;if(!i||!i.length)return;let a=-1;for(let p=0;p<e.length;p++)if(e[p].controlId===n&&e[p].control?.type==="button"){a=p;break}if(a===-1)return;const c=n+"_text",d=[];for(let p=0;p<i.length;p++){const m=i[p];d.push({value:m.value,code:m.code})}const R={type:"button",buttonLabel:r,buttonText:!0,label:r,code:s,value:d,hide:!1},u=[];u.push({value:"[",controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.PREFIX,color:"#1677FF",hide:!1});for(let p=0;p<i.length;p++){const m=i[p],I=i.length>1?`${p+1}.${m.value}`:m.value,L=ct(I);for(let P=0;P<L.length;P++)u.push({value:L[P],controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.VALUE,color:"#000",hide:!1});i.length>1&&p<i.length-1&&u.push({value:_,controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.VALUE,color:"#000",hide:!1})}u.push({value:"]",controlId:c,type:l.ElementType.CONTROL,control:R,controlComponent:l.ControlComponent.POSTFIX,color:"#1677FF",hide:!1});for(let p=0;p<u.length;p++)e.splice(a+p,0,u[p]);const{startIndex:h,endIndex:g}=this.range.getRange(),f=!0,T=g;this.draw.render({curIndex:T,isSetCursor:f})}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length)r.forEach(s=>{s.font=t}),this.draw.render({isSetCursor:!1});else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({font:t}),d?.value===_?d.font=t:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:r,maxSize:s,defaultSize:a}=this.options;if(t<r||t>s)return;let c={},d=[];const R=this.range.getTextLikeSelectionElementList();if(R?.length)d=R,c={isSetCursor:!1};else{const{endIndex:h}=this.range.getRange(),f=this.draw.getElementList()[h];this.range.setDefaultStyle({size:t}),f?.value===_?(d.push(f),c={curIndex:h}):this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}if(!d.length)return;let u=!1;d.forEach(h=>{!h.size&&t===a||h.size&&h.size===t||(h.size=t,u=!0)}),u&&this.draw.render(c)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let a={},c=[];if(s?.length)c=s,a={isSetCursor:!1};else{const{endIndex:R}=this.range.getRange(),h=this.draw.getElementList()[R],f=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:f+2>r?r:f+2}),h?.value===_?(c.push(h),a={curIndex:R}):this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(R=>{R.size||(R.size=i),!(R.size>=r)&&(R.size+2>r?R.size=r:R.size+=2,d=!0)}),d&&this.draw.render(a)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:r}=this.options,s=this.range.getTextLikeSelectionElementList();let a={},c=[];if(s?.length)c=s,a={isSetCursor:!1};else{const{endIndex:R}=this.range.getRange(),h=this.draw.getElementList()[R],f=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:f-2<r?r:f-2}),h?.value===_?(c.push(h),a={curIndex:R}):this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(R=>{R.size||(R.size=i),!(R.size<=r)&&(R.size-2<r?R.size=r:R.size-=2,d=!0)}),d&&this.draw.render(a)}bold(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const r=i.findIndex(s=>!s.bold);i.forEach(s=>{s.bold=!!~r}),this.draw.render({isSetCursor:!1})}else{let r=!0;const{endIndex:s}=this.range.getRange(),c=this.draw.getElementList()[s];this.range.setDefaultStyle({bold:c.bold?!1:!this.range.getDefaultStyle()?.bold}),c?.value===_?c.bold=!c.bold:r=!1,this.draw.render({isSubmitHistory:r,curIndex:s,isCompute:!1})}}italic(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const r=i.findIndex(s=>!s.italic);i.forEach(s=>{s.italic=!!~r}),this.draw.render({isSetCursor:!1})}else{let r=!0;const{endIndex:s}=this.range.getRange(),c=this.draw.getElementList()[s];this.range.setDefaultStyle({italic:c.italic?!1:!this.range.getDefaultStyle()?.italic}),c?.value===_?c.italic=!c.italic:r=!1,this.draw.render({isSubmitHistory:r,curIndex:s,isCompute:!1})}}underline(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length){const s=r.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!Br(a.textDecoration,t));r.forEach(a=>{a.underline=s,s&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d?.underline?!1:!this.range.getDefaultStyle()?.underline}),d?.value===_?d.underline=!d.underline:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}strikeout(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const r=i.findIndex(s=>!s.strikeout);i.forEach(s=>{s.strikeout=!!~r}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let r=!0;const{endIndex:s}=this.range.getRange(),c=this.draw.getElementList()[s];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!this.range.getDefaultStyle()?.strikeout}),c?.value===_?c.strikeout=!c.strikeout:r=!1,this.draw.render({isSubmitHistory:r,curIndex:s,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===l.ElementType.SUPERSCRIPT);i.forEach(s=>{~r?s.type===l.ElementType.SUPERSCRIPT&&(s.type=l.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===l.ElementType.TEXT||s.type===l.ElementType.SUBSCRIPT)&&(s.type=l.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const r=i.findIndex(s=>s.type===l.ElementType.SUBSCRIPT);i.forEach(s=>{~r?s.type===l.ElementType.SUBSCRIPT&&(s.type=l.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===l.ElementType.TEXT||s.type===l.ElementType.SUPERSCRIPT)&&(s.type=l.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length)r.forEach(s=>{t?s.color=t:delete s.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({color:t||void 0}),d?.value===_?t?d.color=t:delete d.color:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const r=this.range.getSelectionElementList();if(r?.length)r.forEach(s=>{t?s.highlight=t:delete s.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let s=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({highlight:t||void 0}),d?.value===_?t?d.highlight=t:delete d.highlight:s=!1,this.draw.render({isSubmitHistory:s,curIndex:a,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.draw.getElementList(),s=n===i?this.range.getRangeParagraphElementList():r.slice(n+1,i+1);if(!s||!s.length)return;const a=lt(),c=this.draw.getOptions().title;s.forEach(u=>{!u.type&&u.value===_||(t?(u.level=t,u.titleId=a,vn(u)&&(u.size=c[xi[t]],u.bold=!0)):u.titleId&&(delete u.titleId,delete u.title,delete u.level,delete u.size,delete u.bold))});const d=n===i,R=d?i:n;this.draw.render({curIndex:R,isSetCursor:d})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(c=>{c.rowFlex=t});const s=n===i,a=s?i:n;this.draw.render({curIndex:a,isSetCursor:s})}vertical(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(c=>{c.vertical=t});const s=n===i,a=s?i:n;this.draw.render({curIndex:a,isSetCursor:s})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const r=this.range.getRangeRowElementList();if(!r)return;r.forEach(c=>{c.rowMargin=t});const s=n===i,a=s?i:n;this.draw.render({curIndex:a,isSetCursor:s})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}tableProperties(){this.draw.isReadonly()||this.tableOperate.tableProperties()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!e?.length||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:a,endIndex:c}=this.range.getRange();!~a&&!~c||this.insertElementList([{type:l.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||lt()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),s=r[n];if(s.type!==l.ElementType.HYPERLINK)return null;let a=n;for(;a>0;){if(r[a].hyperlinkId!==s.hyperlinkId){t=a+1;break}a--}let c=n+1;for(;c<r.length;){if(r[c].hyperlinkId!==s.hyperlinkId){e=c-1;break}c++}return c===r.length&&(e=c-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;this.draw.spliceElementList(n,i,r-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const s=i-1;this.range.setRange(s,s),this.draw.render({curIndex:s})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,r]=e;for(let a=i;a<=r;a++){const c=n[a];delete c.type,delete c.url,delete c.hyperlinkId,delete c.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[r,s]=n;for(let c=r;c<=s;c++){const d=i[c];d.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:a}=this.range.getRange();this.draw.render({curIndex:a,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl())return;const{startIndex:r,endIndex:s}=this.range.getRange();if(!~r&&!~s)return;const a=this.draw.getElementList();let c=-1;const d=a[s+1];if(d&&d.type===l.ElementType.SEPARATOR){if(d.dashArray&&d.dashArray.join()===t.join())return;c=s,Object.assign(d,{dashArray:t,...e})}else{const R={value:Ni,type:l.ElementType.SEPARATOR,dashArray:t,...e};Ut(a,[R],r,{editorOptions:this.options}),r!==0&&a[r].value===_?(this.draw.spliceElementList(a,r,1,[R]),c=r-1):(this.draw.spliceElementList(a,r+1,0,[R]),c=r)}this.range.setRange(c,c),this.draw.render({curIndex:c})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:l.ElementType.PAGE_BREAK,value:Ni}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:r,opacity:s,font:a,gap:c}=Vo;n.watermark.data=t.data,n.watermark.type=t.type||l.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||s,n.watermark.size=t.size||r,n.watermark.font=t.font||a,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||c,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark={...Vo},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=t.id||lt();return this.insertElementList([{...t,id:r,type:l.ElementType.IMAGE}]),r}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:r}=this.options;t!==1&&this.draw.setPageScale(1);const s=await this.draw.getDataURL({pixelRatio:e,mode:l.EditorMode.PRINT});tg(s,{width:i,height:r,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==l.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==l.ElementType.IMAGE||bi(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==l.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];i?.type===l.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===l.ImageDisplay.SURROUND||e===l.ImageDisplay.FLOAT_TOP||e===l.ImageDisplay.FLOAT_BOTTOM){const r=this.position.getPositionList(),{pageNo:s,coordinate:{leftTop:a}}=r[n];t.imgFloatPosition={pageNo:s,x:a[0],y:a[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getPageMode(){return this.options}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:qe(e,t).innerHTML,main:qe(n,t).innerHTML,footer:qe(i,t).innerHTML}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:en(t),main:en(e),footer:en(n)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((c,d)=>c+d.height+(d.offsetY||0),0),r=this.draw.getHeight(),s=this.draw.getMainOuterHeight(),a=r-(s+i);return a>0?a:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=at(t);Vt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=wo(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((s,a)=>s+a.height+(a.offsetY||0),0)}getRange(){return at(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,r=this.range.toString(),s=Mt(this.range.getSelectionElementList()||[]),a=this.draw.getElementList(),c=De(a[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),d=De(a[n],{extraPickAttrs:["id","controlComponent"]}),R=this.draw.getRowList(),u=this.position.getPositionList(),h=u[e],g=u[n],f=h?.pageNo,T=g?.pageNo,p=h?.rowIndex,m=g?.rowIndex,I=R[p],L=R[m];let P=0,O=0;this.draw.getCursor().getHitLineStartIndex()||(P=I?.elementList[0]?.value===_?h?.index-I?.startIndex:h?.index-I?.startIndex+1),h===g?O=P:O=L.elementList[0]?.value===_?g.index-L.startIndex:g.index-L.startIndex+1;const S=[],F=this.draw.getOriginalHeight(),N=this.draw.getOriginalPageGap(),V=this.position.getSelectionPositionList();if(V){let U=null,Q=0,G=null;for(let H=0;H<V.length;H++){const{rowNo:j,pageNo:st,coordinate:{leftTop:it,rightTop:nt},lineHeight:et}=V[H];U===null||U!==j?(G&&S.push(G),G={x:it[0],y:it[1]+st*(F+N),width:nt[0]-it[0],height:et},U=j,Q=it[0]):G.width=nt[0]-Q,H===V.length-1&&G&&S.push(G)}}else{const Q=this.position.getPositionList()[n],{coordinate:{rightTop:G},pageNo:H,lineHeight:j}=Q;S.push({x:G[0],y:G[1]+H*(F+N),width:0,height:j})}const Y=this.draw.getZone().getZone(),{isTable:X,trIndex:b,tdIndex:E,index:C}=this.position.getPositionContext();let M=null;if(X){const Q=this.draw.getOriginalElementList()[C]||null;Q&&(M=Mt([Q])[0])}let y=null,W=null,D=e-1;for(;D>0;){const U=a[D],Q=a[D-1];if(U.titleId&&U.titleId!==Q?.titleId){y=U.titleId,W=u[D].pageNo;break}D--}return at({isCollapsed:i,startElement:c,endElement:d,startPageNo:f,endPageNo:T,startRowNo:p,endRowNo:m,startColNo:P,endColNo:O,rangeRects:S,zone:Y,isTable:X,trIndex:b??null,tdIndex:E??null,tableElement:M,selectionText:r,selectionElementList:s,titleId:y,titleStartPageNo:W})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?Mt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?Mt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),r=this.draw.getOriginalMainElementList();for(let s=0;s<e.length;s++){const a=e[s],{startIndex:c,endIndex:d,tableId:R,startTrIndex:u,startTdIndex:h}=a;let g=i;if(a.tableId){const p=r.find(m=>m.id===R);p&&(g=p.trList?.[u]?.tdList?.[h]?.positionList||[])}const f=at(g[c]),T=at(g[d]);n.push({range:a,startPosition:f,endPosition:T})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:r}=e;i||this.range.shrinkRange(),console.log(t,"payload");const s=at(t),{startIndex:a}=this.range.getRange(),c=this.draw.getElementList();Ut(c,s,a,{ignoreContextKeys:r,isBreakWhenWrap:!0,editorOptions:this.options}),console.log(s,"cloneElementList"),this.draw.insertElementList(s,e),setTimeout(()=>{console.log(c,"elementList")},500)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(at(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function r(a,c=!1){let d=0;for(;d<a.length;){const R=a[d];if(d++,R.type===l.ElementType.TABLE){const u=R.trList;for(let h=0;h<u.length;h++){const g=u[h];for(let f=0;f<g.tdList.length;f++){const T=g.tdList[f];r(T.value,c)}}}R.type===l.ElementType.CONTROL&&R.control?.value&&r(R.control.value,!0),(e&&R.id===e||n&&R.conceptId===n)&&i.push({elementList:a,index:d-1,isInsideControl:c})}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);if(i.length){for(let a=0;a<i.length;a++){const{elementList:c,index:d,isInsideControl:R}=i[a],u=c[d],h=u.controlId&&u.controlComponent===l.ControlComponent.VALUE;if(R||h){if(Object.assign(u,t.properties),u.id){const g=xl(u.id);g&&Object.assign(g,t.properties)}}else{const g=Mt([{...u,...t.properties}],{extraPickAttrs:["id"]});g.length>0&&g[0]?(Ye(Ke,u,g[0]),Vt(g,{isHandleFirstElement:!1,editorOptions:this.options}),c[d]=g[0]):Object.assign(u,t.properties)}}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function r(a){let c=0;for(;c<a.length;){const d=a[c];if(d.type===l.ElementType.TABLE){const R=d.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];r(f.value)}}}d.type===l.ElementType.CONTROL&&d.control?.value&&r(d.control.value),(e&&d.id===e||n&&d.conceptId===n)&&(i=!0,a.splice(c,1),c--),c++}}const s=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);i&&this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const r=a=>{let c=0;for(;c<a.length;){const d=a[c];if(c++,d.type===l.ElementType.TABLE){const R=d.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];r(f.value)}}}e&&d.id!==e||n&&d.conceptId!==n||i.push(d)}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);return Mt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if(t?.id||t?.conceptId){const{id:e,conceptId:n}=t;let i=!1;const r=a=>{let c=a.length-1;for(;c>=0;){const d=a[c];if(d.type===l.ElementType.TABLE){const R=d.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g];r(f.value)}}}c--,!(!d.control||e&&d.controlId!==e||n&&d.control.conceptId!==n)&&(i=!0,a.splice(c+1,1))}},s=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of s)r(a);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const a=this.draw.getControl().removeControl(e);if(a===null)return;this.range.setRange(a,a),this.draw.render({curIndex:a})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(m,I){for(let L=0;L<m.length;L++){const P=m[L];if(P.type===l.ElementType.TABLE){const O=P.trList;for(let S=0;S<O.length;S++){const F=O[S];for(let N=0;N<F.tdList.length;N++){const V=F.tdList[N],Y=n(V.value,I);if(Y)return{...Y,isTable:!0,index:L,trIndex:S,tdIndex:N,tdId:V.id,trId:F.id,tableId:P.id}}}}if(P.titleId===I){let O=L;for(;O<m.length;){if(m[O+1]?.titleId!==I)return{isTable:!1,startIndex:O,endIndex:O};O++}}}return null}const i=n(e,t);if(!i)return;const{isTable:r,index:s,startTdIndex:a,endTdIndex:c,startTrIndex:d,endTrIndex:R,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T,endIndex:p}=i;this.position.setPositionContext({isTable:r,index:s,trIndex:u,tdIndex:h,tdId:g,trId:f,tableId:T}),this.range.setRange(p,p,T,a,c,d,R),this.draw.render({curIndex:p,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===_)for(;n+1<t.length;){const r=t[n+1];if(r.value!==_&&r.value!==fo)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i}=t,r=this.draw.getOriginalInnerWidth(),s=a=>a!==void 0?tn(a,{innerWidth:r}):void 0;this.setValue({header:s(e),main:s(n),footer:s(i)})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:r,trIndex:s,tdIndex:a,tdId:c,trId:d,tableId:R,endIndex:u}=n;this.position.setPositionContext({isTable:i,index:r,trIndex:s,tdIndex:a,tdId:c,trId:d,tableId:R}),this.range.setRange(u,u),this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}updateOptions(t){const e=Yo(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}setFormModeTrace(t){Object.assign(this.options.modeRule.form,t),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){function n(r,s){let a=0;for(;a<r.length;){const c=r[a];if(a++,c.type===l.ElementType.TABLE){const R=c.trList;for(let u=0;u<R.length;u++){const h=R[u];for(let g=0;g<h.tdList.length;g++){const f=h.tdList[g],T=n(f.value,s);if(T)return{...T,positionContext:{isTable:!0,index:a-1,trIndex:u,tdIndex:g,tdId:c.tdId,trId:c.trId,tableId:c.tableId}}}}}if(c?.controlId!==t)continue;let d=a-1;if(e?.position===l.LocationPosition.OUTER_AFTER){if(!(c.controlComponent===l.ControlComponent.POSTFIX&&r[a+1]?.controlComponent!==l.ControlComponent.POST_TEXT))continue}else if(e?.position===l.LocationPosition.OUTER_BEFORE)d-=1;else if(e?.position===l.LocationPosition.AFTER){if(d-=1,c.controlComponent!==l.ControlComponent.PLACEHOLDER&&c.controlComponent!==l.ControlComponent.POSTFIX&&c.controlComponent!==l.ControlComponent.POST_TEXT)continue}else if(c.controlComponent!==l.ControlComponent.PREFIX&&c.controlComponent!==l.ControlComponent.PRE_TEXT||r[a]?.controlComponent===l.ControlComponent.PREFIX||r[a]?.controlComponent===l.ControlComponent.PRE_TEXT)continue;return{zone:s,range:{startIndex:d,endIndex:d},positionContext:{isTable:!1}}}return null}const i=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const r of i){const s=n(r.elementList,r.zone);if(s){this.setZone(s.zone),this.position.setPositionContext(s.positionContext),this.range.replaceRange(s.range),this.draw.render({curIndex:s.range.startIndex,isCompute:!1,isSubmitHistory:!1});break}}}insertTextField(t){if(this.draw.isReadonly()||this.draw.isDisabled()||!t)return;const n=at(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=je(r,i);if(!s)return;const a=[...Be,...Bt,...mn,...Ke];Ye(a,s,n),this.draw.insertElementTextField([n])}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=je(r,i);if(!s)return;const a=r[i],c=a?.controlComponent===l.ControlComponent.POSTFIX||a?.controlComponent===l.ControlComponent.POSTTEXTFIX;let d=!1;if(a?.controlId&&!c)for(let u=i;u>=0;u--){const h=r[u];if(h.controlId!==a.controlId)break;if(h.controlComponent===l.ControlComponent.PRETEXTFIX||h.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){h.control?.type===l.ControlType.TEXTFIELD&&(d=!0);break}}if(!d&&!c){const u=r[i-1];if(u?.controlId)for(let h=i-1;h>=0;h--){const g=r[h];if(g.controlId!==u.controlId)break;if(g.controlComponent===l.ControlComponent.PRETEXTFIX||g.controlComponent===l.ControlComponent.PRETEXTFIX_TEXT){g.control?.type===l.ControlType.TEXTFIELD&&(d=!0);break}}}if(d&&t.control?.type===l.ControlType.TEXTFIELD)return;const R=[...Be,...Bt,...mn,...Ke];Ye(R,s,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t?.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(s,a)=>{let c=0;for(;c<s.length;){const d=s[c];if(c++,d.type===l.ElementType.TABLE){const h=d.trList;for(let g=0;g<h.length;g++){const f=h[g];for(let T=0;T<f.tdList.length;T++){const p=f.tdList[T];i(p.value,a)}}}if(d?.title?.conceptId!==e)continue;const R=[];let u=c;for(;u<s.length;){const h=s[u];if(u++,d.titleId!==h.titleId){if(h.level&&bo[h.level]<=bo[d.level])break;R.push(h)}}n.push({...d.title,value:en(R),elementList:Mt(R),zone:a}),c=u}},r=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:s,elementList:a}of r)i(a,s);return n}getPositionContextByEvent(t,e={}){const n=t.target?.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,r=Number(n),s=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:r}),{isDirectHit:a,isTable:c,index:d,trIndex:R,tdIndex:u,tdValueIndex:h,zone:g}=s;if(i&&!a||g&&g!==this.zone.getZone())return null;let f=null,T=null;const p=this.draw.getOriginalElementList();let m=null;const I=this.position.getOriginalPositionList();if(c){const P=p[d].trList?.[R].tdList[u];T=P?.value[h]||null,m=P?.positionList?.[h]||null,f={element:p[d],trIndex:R,tdIndex:u}}else T=p[d]||null,m=I[d]||null;let L=null;if(m){const{pageNo:P,coordinate:{leftTop:O,rightTop:S},lineHeight:F}=m,N=this.draw.getOriginalHeight(),V=this.draw.getOriginalPageGap();L={x:O[0],y:O[1]+P*(N+V),width:S[0]-O[0],height:F}}return{pageNo:r,element:T,rangeRect:L,tableInfo:f}}insertTitle(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),r=this.draw.getElementList(),s=je(r,i);if(!s)return;const a=[...Be,...Bt,...mn,...Ke];n.valueList?.forEach(c=>{Ye(a,s,c)}),this.draw.insertElementList([n])}focus(t){const{position:e=l.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:r}=t||{};let s=-1;if(r)this.range.replaceRange(r),s=e===l.LocationPosition.BEFORE?r.startIndex:r.endIndex;else if(Mo(i)){const c=this.draw.getOriginalRowList();if(s=e===l.LocationPosition.BEFORE?c[i]?.startIndex:c[i+1]?.startIndex-1,!Mo(s))return;this.range.setRange(s,s)}else s=e===l.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(s,s);const a={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~s&&this.range.getIsCollapsed()&&(a.curIndex=s,a.isSetCursor=!0),this.draw.render(a)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if(e?.isAppendLastLineBreak&&e?.position===l.LocationPosition.OUTER_AFTER){const r=this.draw.getOriginalMainElementList();r[r.length-1].areaId===t&&this.draw.appendElementList([{value:_}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getMacroValue(t){const{id:e,dictCode:n,label:i,areaId:r}=t,s=[],a=(d,R)=>{for(const u of d){if(u.type===l.ElementType.TABLE){const g=u.trList;for(const f of g)for(const T of f.tdList)a(T.value,R);continue}if(u.type!==l.ElementType.MACRO&&u.type!==l.ElementType.CUSTOM_MACRO&&u.type!==l.ElementType.REUSABLE_ITEM||e&&u.id!==e||n&&u.dictCode!==n||i&&u.label!==i||r&&u.areaId!==r)continue;const h={id:u.id,type:u.type,label:u.label,dictCode:u.dictCode,zone:R};u.type===l.ElementType.MACRO?h.value=u.value:u.type===l.ElementType.CUSTOM_MACRO?(h.macroConfig=u.macroConfig,h.value=u.macroConfig?.value):u.type===l.ElementType.REUSABLE_ITEM&&(h.reusableItemConfig=u.reusableItemConfig,h.value=u.reusableItemConfig?.value),s.push(h)}},c=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:d,elementList:R}of c)a(R,d);return s}getMacroList(){const t=[],e=i=>{for(const r of i){if(r.type===l.ElementType.TABLE){const s=r.trList;for(const a of s)for(const c of a.tdList)e(c.value);continue}(r.type===l.ElementType.MACRO||r.type===l.ElementType.CUSTOM_MACRO||r.type===l.ElementType.REUSABLE_ITEM)&&t.push(r)}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i);return t}setMacroValue(t){const{id:e,dictCode:n,label:i,areaId:r,value:s,code:a,isSubmitHistory:c=!0}=t;let d=!1;const R=h=>{for(let g=0;g<h.length;g++){const f=h[g];if(f.type===l.ElementType.TABLE){const T=f.trList;for(const p of T)for(const m of p.tdList)R(m.value);continue}f.type!==l.ElementType.MACRO&&f.type!==l.ElementType.CUSTOM_MACRO&&f.type!==l.ElementType.REUSABLE_ITEM||e&&f.id!==e||n&&f.dictCode!==n||i&&f.label!==i||r&&f.areaId!==r||(d=!0,f.type===l.ElementType.MACRO?f.value=s:f.type===l.ElementType.CUSTOM_MACRO?f.macroConfig?(f.macroConfig.value=s,a!==void 0&&(f.macroConfig.code=a)):f.macroConfig={type:"text",value:s}:f.type===l.ElementType.REUSABLE_ITEM&&(f.reusableItemConfig?f.reusableItemConfig.value=s:f.reusableItemConfig={value:s}))}},u=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const h of u)R(h);d&&this.draw.render({isSubmitHistory:c,isSetCursor:!1})}setMacroValueList(t){if(!t.length)return;let e=!1,n=!1;const i=s=>{for(let a=0;a<s.length;a++){const c=s[a];if(c.type===l.ElementType.TABLE){const g=c.trList;for(const f of g)for(const T of f.tdList)i(T.value);continue}if(c.type!==l.ElementType.MACRO&&c.type!==l.ElementType.CUSTOM_MACRO&&c.type!==l.ElementType.REUSABLE_ITEM)continue;const d=t.find(g=>g.id&&c.id===g.id||g.dictCode&&c.dictCode===g.dictCode||g.label&&c.label===g.label||g.areaId&&c.areaId===g.areaId);if(!d)continue;const{value:R,code:u,isSubmitHistory:h=!0}=d;e=!0,h&&(n=!0),c.type===l.ElementType.MACRO?c.value=R:c.type===l.ElementType.CUSTOM_MACRO?c.macroConfig?(c.macroConfig.value=R,u!==void 0&&(c.macroConfig.code=u)):c.macroConfig={type:"text",value:R}:c.type===l.ElementType.REUSABLE_ITEM&&(c.reusableItemConfig?c.reusableItemConfig.value=R:c.reusableItemConfig={value:R})}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const s of r)i(s);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}updateMacroProperties(t){const{id:e,dictCode:n,label:i,areaId:r,properties:s,isSubmitHistory:a=!0}=t;let c=!1;const d=u=>{for(let h=0;h<u.length;h++){const g=u[h];if(g.type===l.ElementType.TABLE){const f=g.trList;for(const T of f)for(const p of T.tdList)d(p.value);continue}g.type!==l.ElementType.MACRO&&g.type!==l.ElementType.CUSTOM_MACRO&&g.type!==l.ElementType.REUSABLE_ITEM||e&&g.id!==e||n&&g.dictCode!==n||i&&g.label!==i||r&&g.areaId!==r||(c=!0,Object.assign(g,s))}},R=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const u of R)d(u);c&&this.draw.render({isSubmitHistory:a,isSetCursor:!1})}locationMacro(t){const{id:e,dictCode:n,label:i,areaId:r}=t,s=(c,d)=>{for(let R=0;R<c.length;R++){const u=c[R];if(u.type===l.ElementType.TABLE){const h=u.trList;for(let g=0;g<h.length;g++){const f=h[g];for(let T=0;T<f.tdList.length;T++){const p=f.tdList[T],m=s(p.value,d);if(m)return{...m,isTable:!0,index:R,trIndex:g,tdIndex:T,tableId:u.tableId,trId:f.id,tdId:p.id}}}}if(!(u.type!==l.ElementType.MACRO&&u.type!==l.ElementType.CUSTOM_MACRO&&u.type!==l.ElementType.REUSABLE_ITEM)&&!(e&&u.id!==e)&&!(n&&u.dictCode!==n)&&!(i&&u.label!==i)&&!(r&&u.areaId!==r))return{zone:d,index:R}}return null},a=[{zone:l.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:l.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:l.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a){const R=s(d,c);if(R){this.setZone(R.zone),this.position.setPositionContext({isTable:R.isTable||!1,index:R.index,trIndex:R.trIndex,tdIndex:R.tdIndex,tableId:R.tableId,trId:R.trId,tdId:R.tdId}),this.range.replaceRange({startIndex:R.index,endIndex:R.index}),this.draw.render({curIndex:R.index,isCompute:!1,isSubmitHistory:!1});break}}}insertSubTemplate(t){const{label:e,templateId:n,isSubmitHistory:i=!0}=t,r={id:lt(),value:e,type:l.ElementType.SUB_TEMPLATE,label:e,templateId:n,subTemplateExpanded:!1};this.insertElementList([r],{isSubmitHistory:i})}expandSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,r=this.draw.getOriginalMainElementList();for(let s=0;s<r.length;s++){const a=r[s];if(a.type===l.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){a.subTemplateExpanded=!0,a.hide=!0;const c=at(n);Vt(c,{isHandleFirstElement:!1,editorOptions:this.options}),r.splice(s+1,0,...c),this.draw.render({isSubmitHistory:i,isCompute:!0});return}}}collapseSubTemplate(t){const{id:e,isSubmitHistory:n=!0}=t,i=this.draw.getOriginalMainElementList();for(let r=0;r<i.length;r++){const s=i[r];if(s.type===l.ElementType.SUB_TEMPLATE&&(!e||s.id===e)){s.subTemplateExpanded=!1,s.hide=!1;let a=r+1;for(;a<i.length&&i[a].type!==l.ElementType.SUB_TEMPLATE;)a++;a>r+1&&i.splice(r+1,a-r-1),this.draw.render({isSubmitHistory:n,isCompute:!0});return}}}toggleSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,r=this.draw.getOriginalMainElementList();for(let s=0;s<r.length;s++){const a=r[s];if(a.type===l.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){if(a.subTemplateExpanded)this.collapseSubTemplate({id:e,isSubmitHistory:i});else{if(!n){console.warn("子模板内容为空,无法展开");return}this.expandSubTemplate({id:e,content:n,isSubmitHistory:i})}return}}}}class sg{rangeStyleChange;visiblePageNoListChange;intersectionPageNoChange;pageSizeChange;pageScaleChange;saved;contentChange;controlChange;controlContentChange;pageModeChange;zoneChange;constructor(){this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class rg{contextMenu;contextMenuList;getContextMenuList;shortcutList;langMap;constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenu=e,this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}disposeContextMenu(){this.contextMenu.dispose()}}const Fr={SELECTED_TEXT:"%s"},fn={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete",EDIT_ATTRIBUTE:"controlEditAttribute",COPY:"controlCopy",PASTE:"controlPaste"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell",TABLE_PROPERTIES:"tableProperties"}},{CONTROL:{DELETE:lg,EDIT_ATTRIBUTE:ag,COPY:cg,PASTE:dg}}=fn;function yr(o,t){if(t!==l.EditorMode.EDIT)return!1;const n=o?.control?.type,i=o?.controlComponent,r=n===l.ControlType.TEXT||n===l.ControlType.TEXTFIELD||n===l.ControlType.NUMBER||n===l.ControlType.SELECT||n===l.ControlType.DATE||n===l.ControlType.CHECKBOX||n===l.ControlType.RADIO||n===l.ControlType.BUTTON,s=i==="prefix"||i==="preText"||i==="preTextFix"||i==="textFixLabel"||n===l.ControlType.BUTTON&&i==="value";return r&&s}const Rg=[{key:cg,name:"复制控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&yr(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeCopyControl(e)}},{key:dg,name:"粘贴控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.editorTextFocus&&o.options.mode===l.EditorMode.EDIT&&ea(),callback:o=>{o.executePasteControl()}},{key:lg,i18nPath:"contextmenu.control.delete",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&o.options.mode!==l.EditorMode.FORM,callback:o=>{o.executeRemoveControl()}},{key:ag,i18nPath:"contextmenu.control.editAttribute",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&yr(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeTriggerControlEditAttribute(e)}}],{GLOBAL:{CUT:ug,COPY:hg,PASTE:gg,SELECT_ALL:fg,PRINT:Tg}}=fn,mg=[{key:ug,i18nPath:"contextmenu.global.cut",shortCut:`${ve?"⌘":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:hg,i18nPath:"contextmenu.global.copy",shortCut:`${ve?"⌘":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:gg,i18nPath:"contextmenu.global.paste",shortCut:`${ve?"⌘":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:fg,i18nPath:"contextmenu.global.selectAll",shortCut:`${ve?"⌘":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:Tg,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:pg,CANCEL:Lg,EDIT:Ig}}=fn,Pg=[{key:pg,i18nPath:"contextmenu.hyperlink.delete",when:o=>!o.isReadonly&&o.startElement?.type===l.ElementType.HYPERLINK,callback:o=>{o.executeDeleteHyperlink()}},{key:Lg,i18nPath:"contextmenu.hyperlink.cancel",when:o=>!o.isReadonly&&o.startElement?.type===l.ElementType.HYPERLINK,callback:o=>{o.executeCancelHyperlink()}},{key:Ig,i18nPath:"contextmenu.hyperlink.edit",when:o=>!o.isReadonly&&o.startElement?.type===l.ElementType.HYPERLINK,callback:(o,t)=>{const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),t.startElement?.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:Mg,SAVE_AS:Og,TEXT_WRAP:Cg,TEXT_WRAP_EMBED:Sg,TEXT_WRAP_UP_DOWN:Eg,TEXT_WRAP_SURROUND:Xg,TEXT_WRAP_FLOAT_TOP:Ng,TEXT_WRAP_FLOAT_BOTTOM:Fg}}=fn,yg=[{key:Mg,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===l.ElementType.IMAGE,callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:Og,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>!o.editorHasSelection&&o.startElement?.type===l.ElementType.IMAGE,callback:o=>{o.executeSaveAsImageElement()}},{key:Cg,i18nPath:"contextmenu.image.textWrap",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===l.ElementType.IMAGE,childMenus:[{key:Sg,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.BLOCK)}},{key:Eg,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.INLINE)}},{key:Xg,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.SURROUND)}},{key:Ng,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.FLOAT_TOP)}},{key:Fg,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,l.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:Wg,BORDER_ALL:bg,BORDER_EMPTY:Vg,BORDER_DASH:Yg,BORDER_EXTERNAL:Dg,BORDER_INTERNAL:Ug,BORDER_TD:wg,BORDER_TD_TOP:Zg,BORDER_TD_LEFT:Qg,BORDER_TD_BOTTOM:vg,BORDER_TD_RIGHT:Kg,BORDER_TD_BACK:Hg,BORDER_TD_FORWARD:_g,VERTICAL_ALIGN:xg,VERTICAL_ALIGN_TOP:Gg,VERTICAL_ALIGN_MIDDLE:Ag,VERTICAL_ALIGN_BOTTOM:kg,INSERT_ROW_COL:Jg,INSERT_TOP_ROW:Bg,INSERT_BOTTOM_ROW:$g,INSERT_LEFT_COL:zg,INSERT_RIGHT_COL:jg,DELETE_ROW_COL:qg,DELETE_ROW:tf,DELETE_COL:ef,DELETE_TABLE:nf,MERGE_CELL:of,CANCEL_MERGE_CELL:sf}}=fn,rf=[{isDivider:!0},{key:Wg,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:bg,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.ALL)}},{key:Vg,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.EMPTY)}},{key:Yg,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.DASH)}},{key:Dg,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.EXTERNAL)}},{key:Ug,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(l.TableBorder.INTERNAL)}},{key:wg,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:Zg,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.TOP)}},{key:Kg,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.RIGHT)}},{key:vg,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.BOTTOM)}},{key:Qg,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(l.TdBorder.LEFT)}},{key:_g,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(l.TdSlash.FORWARD)}},{key:Hg,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(l.TdSlash.BACK)}}]}]},{key:xg,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:Gg,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(l.VerticalAlign.TOP)}},{key:Ag,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(l.VerticalAlign.MIDDLE)}},{key:kg,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(l.VerticalAlign.BOTTOM)}}]},{key:Jg,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:Bg,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:$g,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:zg,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:jg,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:qg,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,childMenus:[{key:tf,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:ef,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:nf,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:of,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==l.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:sf,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==l.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class lf{options;draw;command;range;position;i18n;container;contextMenuList;contextMenuContainerList;contextMenuRelationShip;context;constructor(t,e){this.options=t.getOptions(),this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...mg,...rf,...yg,...Rg,...Pg],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){const{contextMenuDisableKeys:e}=this.options,n=[];for(let i=0;i<t.length;i++){const r=t[i];r.disable||r.key&&e.includes(r.key)||(r.isDivider||r.when?.(this.context))&&n.push(r)}return n}_proxyContextMenuEvent=t=>{this.context=this._getContext();const e=this._filterMenuList(this.contextMenuList);e.some(i=>!i.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()};_handleSideEffect=t=>{const e=t.target;this.contextMenuContainerList.some(i=>i.contains(e))||this.dispose()};_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:n,endIndex:i}=this.range.getRange(),r=!!(~n||~i),s=r&&n!==i,{isTable:a,trIndex:c,tdIndex:d,index:R}=this.position.getPositionContext();let u=null;if(a){const I=this.draw.getOriginalElementList()[R]||null;I&&(u=Mt([I],{extraPickAttrs:["id"]})[0])}const h=a&&!!e,g=this.draw.getElementList(),f=g[n]||null,T=g[i]||null,p=this.draw.getZone().getZone();return{startElement:f,endElement:T,isReadonly:t,editorHasSelection:s,editorTextFocus:r,isCrossRowCol:h,zone:p,isInTable:a,trIndex:c??null,tdIndex:d??null,tableElement:u,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${z}-contextmenu-container`),t.setAttribute(de,l.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:n,top:i,parentMenuContainer:r}=t,s=this._createContextMenuContainer(),a=document.createElement("div");a.classList.add(`${z}-contextmenu-content`);let c=null;r&&this.contextMenuRelationShip.set(r,s);for(let P=0;P<e.length;P++){const O=e[P];if(O.isDivider){if(P!==0&&P!==e.length-1&&!e[P-1]?.isDivider){const S=document.createElement("div");S.classList.add(`${z}-contextmenu-divider`),a.append(S)}}else{const S=document.createElement("div");if(S.classList.add(`${z}-contextmenu-item`),O.childMenus){const Y=this._filterMenuList(O.childMenus);Y.some(b=>!b.isDivider)&&(S.classList.add(`${z}-contextmenu-sub-item`),S.onmouseenter=()=>{this._setHoverStatus(S,!0),this._removeSubMenu(s);const b=S.getBoundingClientRect(),E=b.left+b.width,C=b.top;c=this._render({contextMenuList:Y,left:E,top:C,parentMenuContainer:s})},S.onmouseleave=b=>{(!c||!c.contains(b.relatedTarget))&&this._setHoverStatus(S,!1)})}else S.onmouseenter=()=>{this._setHoverStatus(S,!0),this._removeSubMenu(s)},S.onmouseleave=()=>{this._setHoverStatus(S,!1)},S.onclick=()=>{O.callback&&this.context&&O.callback(this.command,this.context),this.dispose()};const F=document.createElement("i");S.append(F),O.icon&&F.classList.add(`${z}-contextmenu-${O.icon}`);const N=document.createElement("span"),V=O.i18nPath?this._formatName(this.i18n.t(O.i18nPath)):this._formatName(O.name||"");if(N.append(document.createTextNode(V)),S.append(N),O.shortCut){const Y=document.createElement("span");Y.classList.add(`${z}-shortcut`),Y.append(document.createTextNode(O.shortCut)),S.append(Y)}a.append(S)}}const d=document.createElement("div");d.classList.add(`${z}-contextmenu-divider`),a.append(d);const R=document.createElement("div");R.classList.add(`${z}-contextmenu-item`),R.onmouseenter=()=>{this._setHoverStatus(R,!0),this._removeSubMenu(s)},R.onmouseleave=()=>{this._setHoverStatus(R,!1)},R.onclick=()=>{this.dispose()};const u=document.createElement("i");R.append(u);const h=document.createElement("span");h.append(document.createTextNode(this.i18n.t("contextmenu.global.cancel"))),R.append(h),a.append(R),s.append(a),s.style.display="block";const g=window.innerWidth,f=s.getBoundingClientRect(),T=f.width,p=n+T>g?n-T:n;s.style.left=`${p}px`;const m=window.innerHeight,I=f.height,L=i+I>m?i-I:i;return s.style.top=`${L}px`,this.contextMenuContainerList.push(s),s}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){e?(t.parentNode?.querySelectorAll(`${z}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Fr),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const r=new RegExp(Fr.SELECTED_TEXT,"g");if(r.test(i)){const s=this.range.toString();i=i.replace(r,s)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const af=[{key:l.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:l.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:l.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:l.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:l.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:l.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:ve?l.KeyMap.COMMA:l.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:ve?l.KeyMap.PERIOD:l.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:l.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.LEFT)}},{key:l.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.CENTER)}},{key:l.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.RIGHT)}},{key:l.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(l.RowFlex.ALIGNMENT)}},{key:l.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(l.RowFlex.JUSTIFY)}}],cf=[{key:l.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:l.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.FIRST)}},{key:l.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.SECOND)}},{key:l.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.THIRD)}},{key:l.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.FOURTH)}},{key:l.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.FIFTH)}},{key:l.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(l.TitleLevel.SIXTH)}}],df=[{key:l.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(l.ListType.UL,l.ListStyle.DISC)}},{key:l.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(l.ListType.OL)}}];class Rf{draw;command;globalShortcutList;agentShortcutList;constructor(t,e){this.draw=t,this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...af,...cf,...df]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_globalKeydown=t=>{this.globalShortcutList.length&&this.draw.isGlobalShortcutActive()&&this.draw.isTargetInsideEditor(t.target)&&this._execute(t,this.globalShortcutList)};_agentKeydown(t){this.agentShortcutList.length&&(this.draw.isInteractionSuspended()||this._execute(t,this.agentShortcutList))}_execute(t,e){for(let n=0;n<e.length;n++){const i=e[n];if((i.mod?fe(t)===!!i.mod:t.ctrlKey===!!i.ctrl&&t.metaKey===!!i.meta)&&t.shiftKey===!!i.shift&&t.altKey===!!i.alt&&t.key.toLowerCase()===i.key.toLowerCase()){i.disable||(i?.callback?.(this.command),t.preventDefault());break}}}}class uf{editor;constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class hf{eventHub;constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);n&&n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class gf{paste;copy;drop}class Wr{command;version;listener;eventBus;override;register;destroy;use;draw;constructor(t,e,n={}){const i=Yo(n);e=at(e);let r=[],s=[],a=[],c=[];Array.isArray(e)?s=e:(r=e.header||[],s=e.main,a=e.footer||[],c=e.graffiti||[]),[r,s,a].forEach(f=>{Vt(f,{editorOptions:i,isForceCompensation:!0})}),this.version=Qe,this.listener=new sg,this.eventBus=new hf,this.override=new gf,this.draw=new jh(t,i,{header:r,main:s,footer:a,graffiti:c},this.listener,this.eventBus,this.override);const R=this.draw;this.command=new Xr(new ig(R)),R.setCommand(this.command);const u=new lf(R,this.command),h=new Rf(R,this.command);this.register=new rg({contextMenu:u,shortcut:h,i18n:R.getI18n()}),this.destroy=()=>{R.destroy(),h.removeEvent(),u.removeEvent(),this.eventBus.dangerouslyClearAll()};const g=new uf(this);this.use=g.use.bind(g)}setFormModeTrace(t){this.command.executeSetFormModeTrace(t)}pauseInteraction(){this.draw.pauseInteraction()}resumeInteraction(){this.draw.resumeInteraction()}setOverlayActive(t){this.draw.setOverlayActive(t)}suspendGlobalShortcut(t){this.draw.suspendGlobalShortcut(t)}}l.Command=Xr,l.EDITOR_CLIPBOARD=Tn,l.EDITOR_COMPONENT=de,l.Editor=Wr,l.INTERNAL_CONTEXT_MENU_KEY=fn,l.INTERNAL_SHORTCUT_KEY=us,l.LETTER_CLASS=To,l.createDomFromElementList=qe,l.default=Wr,l.getElementListByHTML=tn,l.getTextFromElementList=en,l.splitText=ct,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
549
549
|
//# sourceMappingURL=canvas-editor.umd.cjs.map
|