vue-element-ui-x 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +140 -140
  2. package/components.json +12 -12
  3. package/lib/components/Attachments/index.js +17 -17
  4. package/lib/components/EditorSender/index.js +2 -2
  5. package/lib/components/FilesCard/index.js +16 -16
  6. package/lib/components/Prompts/index.js +21 -21
  7. package/lib/index.common.js +1 -1
  8. package/lib/index.esm.js +1 -1
  9. package/lib/index.js +288 -288
  10. package/lib/index.umd.js +1 -1
  11. package/lib/locale/index.js +97 -97
  12. package/lib/locale/lang/ar.js +18 -18
  13. package/lib/locale/lang/ar.umd.js +17 -17
  14. package/lib/locale/lang/de.js +18 -18
  15. package/lib/locale/lang/de.umd.js +17 -17
  16. package/lib/locale/lang/en.js +18 -18
  17. package/lib/locale/lang/en.umd.js +17 -17
  18. package/lib/locale/lang/es.js +18 -18
  19. package/lib/locale/lang/es.umd.js +17 -17
  20. package/lib/locale/lang/fr.js +18 -18
  21. package/lib/locale/lang/fr.umd.js +17 -17
  22. package/lib/locale/lang/it.js +18 -18
  23. package/lib/locale/lang/it.umd.js +17 -17
  24. package/lib/locale/lang/ja.js +18 -18
  25. package/lib/locale/lang/ja.umd.js +17 -17
  26. package/lib/locale/lang/ko.js +18 -18
  27. package/lib/locale/lang/ko.umd.js +17 -17
  28. package/lib/locale/lang/pt-br.js +18 -18
  29. package/lib/locale/lang/pt-br.umd.js +17 -17
  30. package/lib/locale/lang/ru-RU.js +18 -18
  31. package/lib/locale/lang/ru-RU.umd.js +17 -17
  32. package/lib/locale/lang/zh-CN.js +18 -18
  33. package/lib/locale/lang/zh-CN.umd.js +17 -17
  34. package/lib/locale/lang/zh-TW.js +18 -18
  35. package/lib/locale/lang/zh-TW.umd.js +17 -17
  36. package/lib/locale/mixin.js +9 -9
  37. package/lib/mixins/index.js +250 -250
  38. package/package.json +77 -76
@@ -30,7 +30,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, "[data-v-353808b6]:root{--color-primary
30
30
 
31
31
  var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
32
32
  // Module
33
- ___CSS_LOADER_EXPORT___.push([module.id, ":root{--chat-primary: #1890ff;--chat-disabled: #e8e8e8;--chat-highlight: #40A9FF;--chat-text: #333;--chat-text-assistant: #666;--chat-text-secondary: #ccc;--chat-text-placeholder: #bfbfbf;--chat-box: #fff;--chat-box-shadow: 1px 3px 10px 2px rgba(6, 21, 50, .2);--chat-box-mark: rgba(0, 0, 0, .5);--chat-input: #F9F9F9;--chat-card: #F2F6FC;--chat-highlight-card: #E6F7FF;--chat-border: #f1f1f2;--chat-popover: #000;--chat-popover-text: #fff}@-webkit-keyframes antSpinMove{to{opacity:1}}@keyframes antSpinMove{to{opacity:1}}@-webkit-keyframes antRotate{to{transform:rotate(405deg)}}@keyframes antRotate{to{transform:rotate(405deg)}}.ant-spin{font-size:14px;line-height:1.5;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";position:absolute;display:none;text-align:center;vertical-align:middle;opacity:0;transition:transform .3s cubic-bezier(.78,.14,.15,.86)}.ant-spin .ant-spin-dot{position:relative;display:inline-block;font-size:20px;width:1em;height:1em}.ant-spin .ant-spin-dot-spin{transform:rotate(45deg);animation-name:antRotate;animation-duration:1.2s;animation-iteration-count:infinite;animation-timing-function:linear}.ant-spin .ant-spin-dot-item{position:absolute;display:block;width:9px;height:9px;background-color:var(--chat-primary);border-radius:100%;transform:scale(.75);transform-origin:50% 50%;opacity:.3;animation-name:antSpinMove;animation-duration:1s;animation-iteration-count:infinite;animation-timing-function:linear;animation-direction:alternate}.ant-spin .ant-spin-dot-item:nth-child(1){top:0;inset-inline-start:0}.ant-spin .ant-spin-dot-item:nth-child(2){top:0;inset-inline-end:0;animation-delay:.4s}.ant-spin .ant-spin-dot-item:nth-child(3){inset-inline-end:0;bottom:0;animation-delay:.8s}.ant-spin .ant-spin-dot-item:nth-child(4){bottom:0;inset-inline-start:0;animation-delay:1.2s}.ant-spin-spinning{position:static;display:inline-block;opacity:1}.chat-area-pc{position:relative;z-index:10}.chat-area-pc *{margin:0;padding:0;box-sizing:border-box;outline:none;text-indent:0;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;font-size:16px}@keyframes a-chat-dialog{0%{transform:scale(.6);opacity:.4}to{opacity:1;transform:scale(1)}}@keyframes a-chat-check-pc{0%{transform:scale(.4) translate(-50%,-50%);opacity:.4}to{opacity:1;transform:scale(1) translate(-50%,-50%)}}.chat-area-h5{position:relative;z-index:10}.chat-area-h5 *{margin:0;padding:0;box-sizing:border-box;outline:none;text-indent:0;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;font-size:16px}@keyframes a-popup-mark{0%{background:#0000}to{background:var(--chat-box-mark)}}@keyframes a-popup-mark-leave{0%{background:var(--chat-box-mark)}to{background:#0000}}@keyframes a-popup-main{0%{bottom:-100%}to{bottom:0}}@keyframes a-popup-main-leave{0%{bottom:0}to{bottom:-100%}}.chat-rich-text{width:100%;padding:10px;margin:0;background:transparent;border-radius:4px;outline:none;box-sizing:border-box;overflow-y:auto;font-size:16px;color:var(--chat-text);vertical-align:text-bottom;transition:all .4s ease;word-break:break-all}.chat-rich-text-disabled{cursor:not-allowed}.chat-dialog{position:relative;z-index:20;width:100%;height:0}.chat-tip-dialog{position:relative;z-index:21;width:100%;height:0}.call-user-dialog{position:absolute;z-index:2024;border-radius:4px;padding:4px;box-sizing:border-box;width:180px;overflow:hidden;background:var(--chat-box);box-shadow:var(--chat-box-shadow)}.call-user-dialog *{margin:0;padding:0;box-sizing:border-box}.call-user-dialog.chat-view-show{animation:a-chat-dialog .2s ease}.call-user-dialog .call-user-dialog-header{display:flex;align-items:center;justify-content:space-between;background:var(--chat-box);padding:6px 4px}.call-user-dialog .call-user-dialog-header .call-user-dialog-header-title{color:var(--chat-text);font-weight:700;font-size:14px}.call-user-dialog .call-user-dialog-header .call-user-dialog-header-check{color:var(--chat-primary);font-size:12px;cursor:pointer}.call-user-dialog .call-user-dialog-main{max-height:240px;overflow-y:auto}.call-user-dialog .call-user-dialog-item{display:flex;align-items:center;color:var(--chat-text-secondary);background:transparent;cursor:pointer;padding:4px;transition:all .3s ease;font-weight:700;font-size:14px;border-radius:4px}.call-user-dialog .call-user-dialog-item .call-user-dialog-item-name{transition:all .3s ease;color:var(--chat-text-secondary)}.call-user-dialog .call-user-dialog-item:hover{background:var(--chat-card);opacity:.7}.call-user-dialog .call-user-dialog-item:hover .call-user-dialog-item-name{color:var(--chat-primary)}.call-user-dialog .call-user-dialog-item.call-user-dialog-item-active{background:var(--chat-card);opacity:1}.call-user-dialog .call-user-dialog-item.call-user-dialog-item-active .call-user-dialog-item-name{color:var(--chat-primary)}.call-user-dialog .call-user-dialog-item.user-no-match{display:none}.call-user-dialog .call-user-dialog-loading{display:flex;align-items:center;justify-content:center;height:36px}.call-user-dialog .call-user-dialog-empty{display:flex;align-items:center;flex-direction:column;justify-content:center;padding:10px 0}.call-user-dialog .call-user-dialog-empty .match-empty-svg{width:auto;height:40px;margin-bottom:2px}.call-user-dialog .call-user-dialog-empty .empty-label{font-size:12px;color:var(--chat-text-secondary)}.call-user-popup{position:fixed;top:0;left:0;width:100%;height:100%;z-index:10000;background:var(--chat-box-mark)}.call-user-popup div,.call-user-popup p,.call-user-popup span,.call-user-popup label,.call-user-popup a,.call-user-popup ul,.call-user-popup li{margin:0;padding:0;box-sizing:border-box}.call-user-popup .call-user-popup-main{position:absolute;left:0;bottom:0;width:100%;height:86%;display:flex;flex-direction:column;background:var(--chat-box);border-radius:16px 16px 0 0;overflow:hidden;padding:14px}.call-user-popup .call-user-popup-header{display:flex;align-items:center}.call-user-popup .call-user-popup-header .popup-show{font-size:16px;color:var(--chat-text-assistant)}.call-user-popup .call-user-popup-header .popup-check{font-size:18px;color:var(--chat-primary);transition:color .3s ease}.call-user-popup .call-user-popup-header .popup-check.disabled{color:var(--chat-disabled)}.call-user-popup .call-user-popup-header .popup-title{flex:1;font-weight:700;font-size:21px;text-align:center;color:var(--chat-text)}.call-user-popup .call-user-popup-search{display:flex;align-items:center;margin-top:20px;background:var(--chat-input);height:44px;border-radius:4px;padding:0 15px}.call-user-popup .call-user-popup-search .call-user-popup-search-input{width:100%;height:100%;background:transparent;padding-left:8px;outline:none;border:none;font-size:16px;color:var(--chat-text)}.call-user-popup .call-user-popup-search .call-user-popup-search-input::-moz-placeholder{color:var(--chat-text-placeholder);opacity:1}.call-user-popup .call-user-popup-search .call-user-popup-search-input:-ms-input-placeholder{color:var(--chat-text-placeholder)}.call-user-popup .call-user-popup-search .call-user-popup-search-input::-webkit-input-placeholder{color:var(--chat-text-placeholder)}.call-user-popup .call-user-popup-search .call-user-popup-search-input:placeholder-shown{text-overflow:ellipsis}.call-user-popup .call-user-popup-search .icon-search{width:auto;height:30px}.call-user-popup .call-user-popup-body{flex:1;padding-top:25px;overflow-y:auto}.call-user-popup .call-user-popup-body .call-user-popup-item{position:relative;padding:15px 10px;display:flex;align-items:center;border-bottom:1px solid var(--chat-border)}.call-user-popup .call-user-popup-body .call-user-popup-item input{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;width:100%;height:100%;opacity:0;box-sizing:border-box}.call-user-popup .call-user-popup-body .call-user-popup-item .user-popup-check-item-inner{position:relative;top:0;left:0;display:block;width:25px;height:25px;border-radius:50%;background-color:var(--chat-box);border:1px solid var(--chat-border);border-collapse:separate;transition:all .3s;box-sizing:border-box}.call-user-popup .call-user-popup-body .call-user-popup-item .user-popup-check-item-inner:after{position:absolute;top:50%;left:30%;display:table;width:5px;height:9px;border:3px solid var(--chat-box);border-top:0;border-left:0;transform:rotate(45deg) scale(0) translate(-60%,-50%);opacity:0;transition:all .1s cubic-bezier(.71,-.46,.88,.6),opacity .1s;content:\" \"}.call-user-popup .call-user-popup-body .call-user-popup-item.user-popup-check-item-check .user-popup-check-item-inner{background-color:var(--chat-primary);border-color:var(--chat-primary)}.call-user-popup .call-user-popup-body .call-user-popup-item.user-popup-check-item-check .user-popup-check-item-inner:after{position:absolute;display:table;border:3px solid var(--chat-box);border-top:0;border-left:0;transform:rotate(45deg) scale(1) translate(-60%,-50%);opacity:1;transition:all .2s cubic-bezier(.12,.4,.29,1.46) .1s;content:\" \"}.call-user-popup .call-user-popup-body .call-user-dialog-item-sculpture{width:35px;height:35px;border-radius:4px}.call-user-popup .call-user-popup-body .call-user-dialog-item-sculpture span{font-size:16px}.call-user-popup .call-user-popup-body .call-user-dialog-item-name{padding-left:8px;font-size:16px;line-height:35px;color:var(--chat-text)}.call-user-popup .call-user-popup-empty{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;justify-content:center}.call-user-popup .call-user-popup-empty .empty-svg{width:auto;height:60px}.call-user-popup .call-user-popup-empty .empty-label{margin-top:10px;font-size:12px;color:var(--chat-text-secondary)}.call-user-popup .call-user-popup-loading{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;justify-content:center;height:36px}.call-user-popup .call-user-popup-loading .ant-spin{transform:scale(1.5)}.call-user-popup.chat-view-show{animation:a-popup-mark .3s ease}.call-user-popup.chat-view-show .call-user-popup-main{animation:a-popup-main .3s ease}.call-user-popup.chat-view-hidden{animation:a-popup-mark-leave .3s ease-in}.call-user-popup.chat-view-hidden .call-user-popup-main{animation:a-popup-main-leave .3s ease-in}.checkbox-dialog{position:fixed;top:0;left:0;margin:0;padding:0;width:100vw;height:100vh;box-sizing:border-box;background:var(--chat-box-mark);z-index:10000}.checkbox-dialog.chat-view-show .checkbox-dialog-container{transform-origin:0 0 0;animation:a-chat-check-pc .3s ease}.checkbox-dialog *{margin:0;padding:0;box-sizing:border-box}.checkbox-dialog .checkbox-dialog-container{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:684px;height:540px;padding:14px 14px 0;border-radius:4px;background:var(--chat-box);box-shadow:var(--chat-box-shadow);overflow:hidden}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-header{display:flex;align-items:center;justify-content:space-between;height:22px;color:var(--chat-text-secondary);font-size:16px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-header .checkbox-dialog-container-header-close{cursor:pointer;transition:all .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-header .checkbox-dialog-container-header-close:hover{color:var(--chat-text-assistant)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body{display:flex;flex-direction:row;width:100%;height:calc(100% - 22px);padding-top:16px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box{position:relative;width:50%;height:100%;padding-top:20px;padding-bottom:20px;padding-left:20px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search{position:relative;padding-right:20px;margin-bottom:20px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input{position:relative;box-sizing:border-box;margin:0;font-variant:tabular-nums;list-style:none;font-feature-settings:\"tnum\";display:inline-block;width:100%;height:32px;padding:4px 11px;color:var(--chat-text);font-size:14px;line-height:1.5;background-color:var(--chat-box);background-image:none;border:1px solid var(--chat-border);border-radius:4px;transition:all .3s}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input::-moz-placeholder{color:var(--chat-text-placeholder);opacity:1}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:-ms-input-placeholder{color:var(--chat-text-placeholder)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input::-webkit-input-placeholder{color:var(--chat-text-placeholder)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:placeholder-shown{text-overflow:ellipsis}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:focus,.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:hover{border-color:var(--chat-primary);border-right-width:1px!important}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:focus{outline:0}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags{width:100%;height:calc(100% - 98px);overflow-y:auto;overflow-x:hidden}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags:after{display:block;content:\"\";clear:both}@keyframes tag-scale{0%{transform:scale(0)}to{transform:scale(1)}}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .checkbox-dialog-tag-item{float:left;display:flex;align-items:center;justify-content:center;margin-right:8px;margin-bottom:6px;background:var(--chat-card);border-radius:4px;font-size:12px;color:var(--chat-text-assistant);padding:4px 8px;cursor:default;animation:tag-scale .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .checkbox-dialog-tag-item .checkbox-dialog-tag-item-close{cursor:pointer;margin-left:6px;color:var(--chat-text-secondary);transform:scale(.7);transition:color .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .checkbox-dialog-tag-item .checkbox-dialog-tag-item-close:hover{color:var(--chat-primary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .check-empty{height:40%;display:flex;flex-direction:column;align-items:center;justify-content:center}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .check-empty .check-empty-svg{width:auto;height:60px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .check-empty .check-empty-label{margin-top:10px;font-size:12px;color:var(--chat-text-secondary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option{position:absolute;left:20px;bottom:20px;display:flex;align-items:center}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn{position:relative;width:76px;height:36px;text-align:center;color:var(--chat-text-assistant);border:1px solid var(--chat-border);background:transparent;cursor:pointer;outline:none;text-indent:8px;letter-spacing:8px;border-radius:4px;font-size:14px;transition:all .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn.btn-submit{border:none;margin-right:16px;background:var(--chat-primary);color:var(--chat-box)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn.btn-submit.disabled{background:var(--chat-primary);opacity:.4;cursor:not-allowed}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn.btn-close:hover{border-color:var(--chat-primary);color:var(--chat-primary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search-group{color:var(--chat-text-assistant);line-height:1.5;list-style:none;font-feature-settings:\"tnum\";position:absolute;width:calc(100% - 20px);max-height:250px;top:calc(100% + 2px);left:0;z-index:1050;box-sizing:border-box;font-size:14px;font-variant:normal;background-color:var(--chat-box);border-radius:4px;outline:none;box-shadow:var(--chat-box-shadow);overflow-y:auto}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search-group .checkbox-dialog-search-empty{padding:34px 0;text-align:center;color:var(--chat-text-secondary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-right-box{width:50%;height:100%;padding-top:20px;border-left:1px solid var(--chat-border)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-right-box .checkbox-dialog-right-box-title{padding-left:20px;font-size:16px;height:22px;color:var(--chat-text-assistant);font-weight:700}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-right-box .checkbox-dialog-check-group{width:calc(100% + 14px);height:calc(100% - 22px);padding-top:8px;overflow-x:hidden;overflow-y:auto}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item{position:relative;display:flex;align-items:center;padding-left:20px;height:44px;font-size:14px;transition:all .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item:hover{background:var(--chat-card);cursor:pointer}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item input{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;width:100%;height:100%;cursor:pointer;opacity:0;box-sizing:border-box;touch-action:manipulation}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item .checkbox-dialog-check-item-inner{position:relative;top:0;left:0;display:block;width:18px;height:18px;margin-right:12px;border-radius:50%;background-color:var(--chat-box);border:1px solid var(--chat-border);border-collapse:separate;transition:all .3s;box-sizing:border-box}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item .checkbox-dialog-check-item-inner:after{position:absolute;top:50%;left:22%;display:table;width:4px;height:8px;border:2px solid var(--chat-border);border-top:0;border-left:0;transform:rotate(45deg) scale(0) translate(-50%,-50%);opacity:0;transition:all .1s cubic-bezier(.71,-.46,.88,.6),opacity .1s;content:\" \"}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item.checkbox-dialog-check-item-check .checkbox-dialog-check-item-inner{background-color:var(--chat-primary);border-color:var(--chat-primary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item.checkbox-dialog-check-item-check .checkbox-dialog-check-item-inner:after{position:absolute;display:table;border:2px solid var(--chat-box);border-top:0;border-left:0;transform:rotate(45deg) scale(1) translate(-50%,-50%);opacity:1;transition:all .2s cubic-bezier(.12,.4,.29,1.46) .1s;content:\" \"}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item .checkbox-dialog-check-item-label{display:flex;align-items:center;font-size:14px}.call-tag-dialog{position:absolute;z-index:2024;border-radius:4px;padding:4px;box-sizing:border-box;width:180px;overflow:hidden;background:var(--chat-box);box-shadow:var(--chat-box-shadow)}.call-tag-dialog.chat-view-show{animation:a-chat-dialog .2s ease}.call-tag-dialog .call-tag-dialog-header{display:flex;align-items:center;justify-content:space-between;background:var(--chat-box);padding:6px 4px}.call-tag-dialog .call-tag-dialog-header .call-tag-dialog-header-title{color:var(--chat-text);font-weight:700;font-size:14px}.call-tag-dialog .call-tag-dialog-main{max-height:240px;overflow-y:auto}.call-tag-dialog .call-tag-dialog-item{display:flex;align-items:center;color:var(--chat-text-secondary);background:transparent;cursor:pointer;padding:4px 8px;transition:all .3s ease;font-weight:700;font-size:14px;border-radius:4px}.call-tag-dialog .call-tag-dialog-item .call-tag-dialog-item-name{transition:all .3s ease;color:var(--chat-text-secondary)}.call-tag-dialog .call-tag-dialog-item:hover{background:var(--chat-card);opacity:.7}.call-tag-dialog .call-tag-dialog-item:hover .call-tag-dialog-item-name{color:var(--chat-primary)}.call-tag-dialog .call-tag-dialog-item.call-tag-dialog-item-active{background:var(--chat-card);opacity:1}.call-tag-dialog .call-tag-dialog-item.call-tag-dialog-item-active .call-tag-dialog-item-name{color:var(--chat-primary)}.call-tag-dialog .call-tag-dialog-item.tag-no-match{display:none}.chat-select-dialog{position:fixed;min-width:180px;z-index:2024;border-radius:4px;padding:4px;box-sizing:border-box;width:auto;background:var(--chat-box);box-shadow:var(--chat-box-shadow)}.chat-select-dialog .chat-select-dialog-header{display:flex;align-items:center;justify-content:space-between;background:var(--chat-box);padding:6px}.chat-select-dialog .chat-select-dialog-header .chat-select-dialog-header-title{color:var(--chat-text);font-weight:700;font-size:14px}.chat-select-dialog .chat-select-dialog-main{position:relative;z-index:3;max-height:280px;overflow-y:auto}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item{display:flex;align-items:center;color:var(--chat-text-secondary);background:transparent;cursor:pointer;padding:8px;transition:all .3s ease;font-weight:700;font-size:14px;border-radius:6px;min-height:42px}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item .chat-select-dialog-preview{width:42px;height:42px;border-radius:6px;flex-shrink:0;margin-right:12px}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item .chat-select-dialog-name{flex:1;transition:all .3s ease;color:var(--chat-text-secondary)}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item .chat-select-dialog-check{display:inline-block;margin-left:6px;font-size:12px;color:var(--chat-primary)}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item:hover{background:var(--chat-card);opacity:.8}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item:hover .chat-select-dialog-name{color:var(--chat-primary)}.chat-select-dialog .chat-select-arrow{position:absolute;z-index:2;pointer-events:none;width:16px;height:16px;overflow:hidden}.chat-select-dialog .chat-select-arrow:before{box-sizing:border-box;background:var(--chat-box);position:absolute;bottom:0;inset-inline-start:0;width:16px;height:8px;clip-path:path(\"M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z\");content:\"\"}.chat-select-dialog .chat-select-arrow:after{box-sizing:border-box;content:\"\";position:absolute;width:9px;height:9px;bottom:0;inset-inline:0;margin:auto;border-radius:0 0 2px;transform:translateY(50%) rotate(-135deg);box-shadow:var(--chat-box-shadow);z-index:0;background:transparent;opacity:.25}.call-user-dialog-item-sculpture{display:flex;align-items:center;justify-content:center;width:24px;height:24px;margin-right:8px;border-radius:4px;overflow:hidden;background:var(--chat-primary);color:var(--chat-box);white-space:nowrap;font-size:12px}.call-user-dialog-item-sculpture *{margin:0;padding:0;box-sizing:border-box}.call-user-dialog-item-sculpture.is-avatar{background:var(--chat-box)}.call-user-dialog-item-sculpture.is-avatar img{width:100%;height:100%}.call-user-dialog-item-sculpture span{font-size:12px;color:var(--chat-box)}.call-user-dialog-item-name{flex:1;white-space:nowrap;line-height:24px;overflow:hidden;text-overflow:ellipsis;padding-right:10px;color:var(--chat-text-assistant);font-size:14px}.chat-select-dialog-main::-webkit-scrollbar,.call-user-dialog-main::-webkit-scrollbar,.call-tag-dialog-main::-webkit-scrollbar,.checkbox-dialog-check-group::-webkit-scrollbar,.checkbox-dialog-tags::-webkit-scrollbar{width:6px;height:6px}.chat-select-dialog-main::-webkit-scrollbar-thumb,.call-user-dialog-main::-webkit-scrollbar-thumb,.call-tag-dialog-main::-webkit-scrollbar-thumb,.checkbox-dialog-check-group::-webkit-scrollbar-thumb,.checkbox-dialog-tags::-webkit-scrollbar-thumb{border-radius:10px;box-shadow:inset 0 0 5px #61b8b31a;background-color:#0003}.chat-select-dialog-main::-webkit-scrollbar-track,.call-user-dialog-main::-webkit-scrollbar-track,.call-tag-dialog-main::-webkit-scrollbar-track,.checkbox-dialog-check-group::-webkit-scrollbar-track,.checkbox-dialog-tags::-webkit-scrollbar-track{box-shadow:inset 0 0 5px #57afbb1a;border-radius:10px;background:#ededed}.disable-scroll{overflow-y:hidden!important}.chat-placeholder-wrap{position:absolute;top:0;left:0;width:100%;margin:0;padding:10px;box-sizing:border-box;color:var(--chat-text-placeholder);pointer-events:none;font-style:oblique;word-break:break-all;z-index:11}.chat-tip-wrap{position:absolute;top:0;left:0;width:auto;height:100%;margin:0;padding:10px 6px 10px 10px;box-sizing:border-box;pointer-events:none;-webkit-user-select:none;user-select:none;z-index:21}.chat-tip-wrap .chat-tip-tag{position:relative;padding:2px 6px;color:var(--chat-primary);border-radius:8px;pointer-events:visible;cursor:pointer;transition:background .3s ease}.chat-tip-wrap .chat-tip-tag .chat-tip-tag-txt{font-size:18px;font-weight:600;font-family:宋体}.chat-tip-wrap .chat-tip-tag .chat-tip-tag-close{top:-4px;right:-4px;position:absolute;font-size:12px;opacity:0;transition:all .3s ease;color:var(--chat-text)}.chat-tip-wrap .chat-tip-tag .chat-tip-tag-close svg{font-size:inherit}.chat-tip-wrap .chat-tip-tag:hover{background:var(--chat-card)}.chat-tip-wrap .chat-tip-tag:hover .chat-tip-tag-close{opacity:1}.chat-tip-popover{position:absolute}.chat-tip-popover .chat-tip-popover-main{display:flex;align-items:center;padding:8px 10px;background:var(--chat-popover);color:var(--chat-popover-text);font-size:13px;border-radius:8px}.chat-tip-popover .chat-tip-popover-main .chat-tip-popover-code{margin-left:4px;opacity:.7;font-size:12px}.chat-tip-popover .chat-tip-popover-main .chat-tip-popover-code.chat-view-show{display:none}.chat-tip-popover .chat-tip-popover-arrow{position:absolute;z-index:2;pointer-events:none;width:16px;height:16px;overflow:hidden;left:50%;transform:translate(-50%) rotate(-180deg)}.chat-tip-popover .chat-tip-popover-arrow:before{box-sizing:border-box;background:var(--chat-popover);position:absolute;bottom:0;inset-inline-start:0;width:16px;height:8px;clip-path:path(\"M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z\");content:\"\"}.chat-img{min-width:20px;min-height:20px;max-width:100px;max-height:100px;vertical-align:bottom}.chat-tag{margin:0 1px}.chat-grid-input{word-break:break-all}.at-user,.at-tag{color:var(--chat-primary)}.at-select{display:inline-block;cursor:pointer;background:var(--chat-card);color:var(--chat-primary);padding:2px 6px;border-radius:10px;margin:2px;transition:all .3s ease}.at-select svg{margin-left:4px;font-size:12px;transition:all .3s ease}.at-select:hover{color:var(--chat-highlight);background:var(--chat-highlight-card)}.at-select.aim svg{transform:rotate(-180deg)}.at-input{padding:2px 6px;border-radius:10px;margin:0 2px;color:var(--chat-primary);cursor:text;background:var(--chat-card);line-height:1.8}.at-input .input-write{white-space:pre-wrap;word-break:break-all;word-wrap:break-word;padding-left:.1px}.at-input .input-tip{pointer-events:none;-webkit-user-select:none;user-select:none;opacity:.35;word-break:break-all}\n", ""]);
33
+ ___CSS_LOADER_EXPORT___.push([module.id, ":root{--chat-primary: #1890ff;--chat-disabled: #e8e8e8;--chat-highlight: #40A9FF;--chat-text: #333;--chat-text-assistant: #666;--chat-text-secondary: #ccc;--chat-text-placeholder: #bfbfbf;--chat-box: #fff;--chat-box-shadow: 1px 3px 10px 2px rgba(6, 21, 50, .2);--chat-box-mark: rgba(0, 0, 0, .5);--chat-input: #F9F9F9;--chat-card: #F2F6FC;--chat-highlight-card: #E6F7FF;--chat-border: #f1f1f2;--chat-popover: #000;--chat-popover-text: #fff}@-webkit-keyframes antSpinMove{to{opacity:1}}@keyframes antSpinMove{to{opacity:1}}@-webkit-keyframes antRotate{to{transform:rotate(405deg)}}@keyframes antRotate{to{transform:rotate(405deg)}}.ant-spin{font-size:14px;line-height:1.5;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";position:absolute;display:none;text-align:center;vertical-align:middle;opacity:0;transition:transform .3s cubic-bezier(.78,.14,.15,.86)}.ant-spin .ant-spin-dot{position:relative;display:inline-block;font-size:20px;width:1em;height:1em}.ant-spin .ant-spin-dot-spin{transform:rotate(45deg);animation-name:antRotate;animation-duration:1.2s;animation-iteration-count:infinite;animation-timing-function:linear}.ant-spin .ant-spin-dot-item{position:absolute;display:block;width:9px;height:9px;background-color:var(--chat-primary);border-radius:100%;transform:scale(.75);transform-origin:50% 50%;opacity:.3;animation-name:antSpinMove;animation-duration:1s;animation-iteration-count:infinite;animation-timing-function:linear;animation-direction:alternate}.ant-spin .ant-spin-dot-item:nth-child(1){top:0;inset-inline-start:0}.ant-spin .ant-spin-dot-item:nth-child(2){top:0;inset-inline-end:0;animation-delay:.4s}.ant-spin .ant-spin-dot-item:nth-child(3){inset-inline-end:0;bottom:0;animation-delay:.8s}.ant-spin .ant-spin-dot-item:nth-child(4){bottom:0;inset-inline-start:0;animation-delay:1.2s}.ant-spin-spinning{position:static;display:inline-block;opacity:1}.chat-area-pc{position:relative;z-index:10}.chat-area-pc *{margin:0;padding:0;box-sizing:border-box;outline:none;text-indent:0;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;font-size:16px}@keyframes a-chat-dialog{0%{transform:scale(.6);opacity:.4}to{opacity:1;transform:scale(1)}}@keyframes a-chat-check-pc{0%{transform:scale(.4) translate(-50%,-50%);opacity:.4}to{opacity:1;transform:scale(1) translate(-50%,-50%)}}.chat-area-h5{position:relative;z-index:10}.chat-area-h5 *{margin:0;padding:0;box-sizing:border-box;outline:none;text-indent:0;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;font-size:16px}@keyframes a-popup-mark{0%{background:#0000}to{background:var(--chat-box-mark)}}@keyframes a-popup-mark-leave{0%{background:var(--chat-box-mark)}to{background:#0000}}@keyframes a-popup-main{0%{bottom:-100%}to{bottom:0}}@keyframes a-popup-main-leave{0%{bottom:0}to{bottom:-100%}}.chat-rich-text{width:100%;padding:10px;margin:0;background:transparent;border-radius:4px;outline:none;box-sizing:border-box;overflow-y:auto;font-size:16px;color:var(--chat-text);vertical-align:text-bottom;transition:all .4s ease;word-break:break-all}.chat-rich-text-disabled{cursor:not-allowed}.chat-dialog{position:relative;z-index:20;width:100%;height:0}.chat-tip-dialog{position:relative;z-index:21;width:100%;height:0}.call-user-dialog{position:absolute;z-index:2024;border-radius:4px;padding:4px;box-sizing:border-box;width:180px;overflow:hidden;background:var(--chat-box);box-shadow:var(--chat-box-shadow)}.call-user-dialog *{margin:0;padding:0;box-sizing:border-box}.call-user-dialog.chat-view-show{animation:a-chat-dialog .2s ease}.call-user-dialog .call-user-dialog-header{display:flex;align-items:center;justify-content:space-between;background:var(--chat-box);padding:6px 4px}.call-user-dialog .call-user-dialog-header .call-user-dialog-header-title{color:var(--chat-text);font-weight:700;font-size:14px}.call-user-dialog .call-user-dialog-header .call-user-dialog-header-check{color:var(--chat-primary);font-size:12px;cursor:pointer}.call-user-dialog .call-user-dialog-main{max-height:240px;overflow-y:auto}.call-user-dialog .call-user-dialog-item{display:flex;align-items:center;color:var(--chat-text-secondary);background:transparent;cursor:pointer;padding:4px;transition:all .3s ease;font-weight:700;font-size:14px;border-radius:4px}.call-user-dialog .call-user-dialog-item .call-user-dialog-item-name{transition:all .3s ease;color:var(--chat-text-secondary)}.call-user-dialog .call-user-dialog-item:hover{background:var(--chat-card);opacity:.7}.call-user-dialog .call-user-dialog-item:hover .call-user-dialog-item-name{color:var(--chat-primary)}.call-user-dialog .call-user-dialog-item.call-user-dialog-item-active{background:var(--chat-card);opacity:1}.call-user-dialog .call-user-dialog-item.call-user-dialog-item-active .call-user-dialog-item-name{color:var(--chat-primary)}.call-user-dialog .call-user-dialog-item.user-no-match{display:none}.call-user-dialog .call-user-dialog-loading{display:flex;align-items:center;justify-content:center;height:36px}.call-user-dialog .call-user-dialog-empty{display:flex;align-items:center;flex-direction:column;justify-content:center;padding:10px 0}.call-user-dialog .call-user-dialog-empty .match-empty-svg{width:auto;height:40px;margin-bottom:2px}.call-user-dialog .call-user-dialog-empty .empty-label{font-size:12px;color:var(--chat-text-secondary)}.call-user-popup{position:fixed;top:0;left:0;width:100%;height:100%;z-index:10000;background:var(--chat-box-mark)}.call-user-popup div,.call-user-popup p,.call-user-popup span,.call-user-popup label,.call-user-popup a,.call-user-popup ul,.call-user-popup li{margin:0;padding:0;box-sizing:border-box}.call-user-popup .call-user-popup-main{position:absolute;left:0;bottom:0;width:100%;height:86%;display:flex;flex-direction:column;background:var(--chat-box);border-radius:16px 16px 0 0;overflow:hidden;padding:14px}.call-user-popup .call-user-popup-header{display:flex;align-items:center}.call-user-popup .call-user-popup-header .popup-show{font-size:16px;color:var(--chat-text-assistant)}.call-user-popup .call-user-popup-header .popup-check{font-size:18px;color:var(--chat-primary);transition:color .3s ease}.call-user-popup .call-user-popup-header .popup-check.disabled{color:var(--chat-disabled)}.call-user-popup .call-user-popup-header .popup-title{flex:1;font-weight:700;font-size:21px;text-align:center;color:var(--chat-text)}.call-user-popup .call-user-popup-search{display:flex;align-items:center;margin-top:20px;background:var(--chat-input);height:44px;border-radius:4px;padding:0 15px}.call-user-popup .call-user-popup-search .call-user-popup-search-input{width:100%;height:100%;background:transparent;padding-left:8px;outline:none;border:none;font-size:16px;color:var(--chat-text)}.call-user-popup .call-user-popup-search .call-user-popup-search-input::-moz-placeholder{color:var(--chat-text-placeholder);opacity:1}.call-user-popup .call-user-popup-search .call-user-popup-search-input:-ms-input-placeholder{color:var(--chat-text-placeholder)}.call-user-popup .call-user-popup-search .call-user-popup-search-input::-webkit-input-placeholder{color:var(--chat-text-placeholder)}.call-user-popup .call-user-popup-search .call-user-popup-search-input:placeholder-shown{text-overflow:ellipsis}.call-user-popup .call-user-popup-search .icon-search{width:auto;height:30px}.call-user-popup .call-user-popup-body{flex:1;padding-top:25px;overflow-y:auto}.call-user-popup .call-user-popup-body .call-user-popup-item{position:relative;padding:15px 10px;display:flex;align-items:center;border-bottom:1px solid var(--chat-border)}.call-user-popup .call-user-popup-body .call-user-popup-item input{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;width:100%;height:100%;opacity:0;box-sizing:border-box}.call-user-popup .call-user-popup-body .call-user-popup-item .user-popup-check-item-inner{position:relative;top:0;left:0;display:block;width:25px;height:25px;border-radius:50%;background-color:var(--chat-box);border:1px solid var(--chat-border);border-collapse:separate;transition:all .3s;box-sizing:border-box}.call-user-popup .call-user-popup-body .call-user-popup-item .user-popup-check-item-inner:after{position:absolute;top:50%;left:30%;display:table;width:5px;height:9px;border:3px solid var(--chat-box);border-top:0;border-left:0;transform:rotate(45deg) scale(0) translate(-60%,-50%);opacity:0;transition:all .1s cubic-bezier(.71,-.46,.88,.6),opacity .1s;content:\" \"}.call-user-popup .call-user-popup-body .call-user-popup-item.user-popup-check-item-check .user-popup-check-item-inner{background-color:var(--chat-primary);border-color:var(--chat-primary)}.call-user-popup .call-user-popup-body .call-user-popup-item.user-popup-check-item-check .user-popup-check-item-inner:after{position:absolute;display:table;border:3px solid var(--chat-box);border-top:0;border-left:0;transform:rotate(45deg) scale(1) translate(-60%,-50%);opacity:1;transition:all .2s cubic-bezier(.12,.4,.29,1.46) .1s;content:\" \"}.call-user-popup .call-user-popup-body .call-user-dialog-item-sculpture{width:35px;height:35px;border-radius:4px}.call-user-popup .call-user-popup-body .call-user-dialog-item-sculpture span{font-size:16px}.call-user-popup .call-user-popup-body .call-user-dialog-item-name{padding-left:8px;font-size:16px;line-height:35px;color:var(--chat-text)}.call-user-popup .call-user-popup-empty{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;justify-content:center}.call-user-popup .call-user-popup-empty .empty-svg{width:auto;height:60px}.call-user-popup .call-user-popup-empty .empty-label{margin-top:10px;font-size:12px;color:var(--chat-text-secondary)}.call-user-popup .call-user-popup-loading{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;justify-content:center;height:36px}.call-user-popup .call-user-popup-loading .ant-spin{transform:scale(1.5)}.call-user-popup.chat-view-show{animation:a-popup-mark .3s ease}.call-user-popup.chat-view-show .call-user-popup-main{animation:a-popup-main .3s ease}.call-user-popup.chat-view-hidden{animation:a-popup-mark-leave .3s ease-in}.call-user-popup.chat-view-hidden .call-user-popup-main{animation:a-popup-main-leave .3s ease-in}.checkbox-dialog{position:fixed;top:0;left:0;margin:0;padding:0;width:100vw;height:100vh;box-sizing:border-box;background:var(--chat-box-mark);z-index:10000}.checkbox-dialog.chat-view-show .checkbox-dialog-container{transform-origin:0 0 0;animation:a-chat-check-pc .3s ease}.checkbox-dialog *{margin:0;padding:0;box-sizing:border-box}.checkbox-dialog .checkbox-dialog-container{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:684px;height:540px;padding:14px 14px 0;border-radius:4px;background:var(--chat-box);box-shadow:var(--chat-box-shadow);overflow:hidden}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-header{display:flex;align-items:center;justify-content:space-between;height:22px;color:var(--chat-text-secondary);font-size:16px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-header .checkbox-dialog-container-header-close{cursor:pointer;transition:all .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-header .checkbox-dialog-container-header-close:hover{color:var(--chat-text-assistant)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body{display:flex;flex-direction:row;width:100%;height:calc(100% - 22px);padding-top:16px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box{position:relative;width:50%;height:100%;padding-top:20px;padding-bottom:20px;padding-left:20px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search{position:relative;padding-right:20px;margin-bottom:20px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input{position:relative;box-sizing:border-box;margin:0;font-variant:tabular-nums;list-style:none;font-feature-settings:\"tnum\";display:inline-block;width:100%;height:32px;padding:4px 11px;color:var(--chat-text);font-size:14px;line-height:1.5;background-color:var(--chat-box);background-image:none;border:1px solid var(--chat-border);border-radius:4px;transition:all .3s}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input::-moz-placeholder{color:var(--chat-text-placeholder);opacity:1}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:-ms-input-placeholder{color:var(--chat-text-placeholder)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input::-webkit-input-placeholder{color:var(--chat-text-placeholder)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:placeholder-shown{text-overflow:ellipsis}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:focus,.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:hover{border-color:var(--chat-primary);border-right-width:1px!important}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search .checkbox-dialog-search-input:focus{outline:0}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags{width:100%;height:calc(100% - 98px);overflow-y:auto;overflow-x:hidden}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags:after{display:block;content:\"\";clear:both}@keyframes tag-scale{0%{transform:scale(0)}to{transform:scale(1)}}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .checkbox-dialog-tag-item{float:left;display:flex;align-items:center;justify-content:center;margin-right:8px;margin-bottom:6px;background:var(--chat-card);border-radius:4px;font-size:12px;color:var(--chat-text-assistant);padding:4px 8px;cursor:default;animation:tag-scale .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .checkbox-dialog-tag-item .checkbox-dialog-tag-item-close{cursor:pointer;margin-left:6px;color:var(--chat-text-secondary);transform:scale(.7);transition:color .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .checkbox-dialog-tag-item .checkbox-dialog-tag-item-close:hover{color:var(--chat-primary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .check-empty{height:40%;display:flex;flex-direction:column;align-items:center;justify-content:center}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .check-empty .check-empty-svg{width:auto;height:60px}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-tags .check-empty .check-empty-label{margin-top:10px;font-size:12px;color:var(--chat-text-secondary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option{position:absolute;left:20px;bottom:20px;display:flex;align-items:center}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn{position:relative;width:76px;height:36px;text-align:center;color:var(--chat-text-assistant);border:1px solid var(--chat-border);background:transparent;cursor:pointer;outline:none;text-indent:8px;letter-spacing:8px;border-radius:4px;font-size:14px;transition:all .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn.btn-submit{border:none;margin-right:16px;background:var(--chat-primary);color:var(--chat-box)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn.btn-submit.disabled{background:var(--chat-primary);opacity:.4;cursor:not-allowed}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-option .checkbox-dialog-option-btn.btn-close:hover{border-color:var(--chat-primary);color:var(--chat-primary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search-group{color:var(--chat-text-assistant);line-height:1.5;list-style:none;font-feature-settings:\"tnum\";position:absolute;width:calc(100% - 20px);max-height:250px;top:calc(100% + 2px);left:0;z-index:1050;box-sizing:border-box;font-size:14px;font-variant:normal;background-color:var(--chat-box);border-radius:4px;outline:none;box-shadow:var(--chat-box-shadow);overflow-y:auto}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-left-box .checkbox-dialog-search-group .checkbox-dialog-search-empty{padding:34px 0;text-align:center;color:var(--chat-text-secondary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-right-box{width:50%;height:100%;padding-top:20px;border-left:1px solid var(--chat-border)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-right-box .checkbox-dialog-right-box-title{padding-left:20px;font-size:16px;height:22px;color:var(--chat-text-assistant);font-weight:700}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-right-box .checkbox-dialog-check-group{width:calc(100% + 14px);height:calc(100% - 22px);padding-top:8px;overflow-x:hidden;overflow-y:auto}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item{position:relative;display:flex;align-items:center;padding-left:20px;height:44px;font-size:14px;transition:all .3s ease}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item:hover{background:var(--chat-card);cursor:pointer}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item input{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;width:100%;height:100%;cursor:pointer;opacity:0;box-sizing:border-box;touch-action:manipulation}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item .checkbox-dialog-check-item-inner{position:relative;top:0;left:0;display:block;width:18px;height:18px;margin-right:12px;border-radius:50%;background-color:var(--chat-box);border:1px solid var(--chat-border);border-collapse:separate;transition:all .3s;box-sizing:border-box}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item .checkbox-dialog-check-item-inner:after{position:absolute;top:50%;left:22%;display:table;width:4px;height:8px;border:2px solid var(--chat-border);border-top:0;border-left:0;transform:rotate(45deg) scale(0) translate(-50%,-50%);opacity:0;transition:all .1s cubic-bezier(.71,-.46,.88,.6),opacity .1s;content:\" \"}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item.checkbox-dialog-check-item-check .checkbox-dialog-check-item-inner{background-color:var(--chat-primary);border-color:var(--chat-primary)}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item.checkbox-dialog-check-item-check .checkbox-dialog-check-item-inner:after{position:absolute;display:table;border:2px solid var(--chat-box);border-top:0;border-left:0;transform:rotate(45deg) scale(1) translate(-50%,-50%);opacity:1;transition:all .2s cubic-bezier(.12,.4,.29,1.46) .1s;content:\" \"}.checkbox-dialog .checkbox-dialog-container .checkbox-dialog-container-body .checkbox-dialog-check-item .checkbox-dialog-check-item-label{display:flex;align-items:center;font-size:14px}.call-tag-dialog{position:absolute;z-index:2024;border-radius:4px;padding:4px;box-sizing:border-box;width:180px;overflow:hidden;background:var(--chat-box);box-shadow:var(--chat-box-shadow)}.call-tag-dialog.chat-view-show{animation:a-chat-dialog .2s ease}.call-tag-dialog .call-tag-dialog-header{display:flex;align-items:center;justify-content:space-between;background:var(--chat-box);padding:6px 4px}.call-tag-dialog .call-tag-dialog-header .call-tag-dialog-header-title{color:var(--chat-text);font-weight:700;font-size:14px}.call-tag-dialog .call-tag-dialog-main{max-height:240px;overflow-y:auto}.call-tag-dialog .call-tag-dialog-item{display:flex;align-items:center;color:var(--chat-text-secondary);background:transparent;cursor:pointer;padding:4px 8px;transition:all .3s ease;font-weight:700;font-size:14px;border-radius:4px}.call-tag-dialog .call-tag-dialog-item .call-tag-dialog-item-name{transition:all .3s ease;color:var(--chat-text-secondary)}.call-tag-dialog .call-tag-dialog-item:hover{background:var(--chat-card);opacity:.7}.call-tag-dialog .call-tag-dialog-item:hover .call-tag-dialog-item-name{color:var(--chat-primary)}.call-tag-dialog .call-tag-dialog-item.call-tag-dialog-item-active{background:var(--chat-card);opacity:1}.call-tag-dialog .call-tag-dialog-item.call-tag-dialog-item-active .call-tag-dialog-item-name{color:var(--chat-primary)}.call-tag-dialog .call-tag-dialog-item.tag-no-match{display:none}.chat-select-dialog{position:fixed;min-width:180px;z-index:2024;border-radius:4px;padding:4px;box-sizing:border-box;width:auto;background:var(--chat-box);box-shadow:var(--chat-box-shadow)}.chat-select-dialog .chat-select-dialog-header{display:flex;align-items:center;justify-content:space-between;background:var(--chat-box);padding:6px}.chat-select-dialog .chat-select-dialog-header .chat-select-dialog-header-title{color:var(--chat-text);font-weight:700;font-size:14px}.chat-select-dialog .chat-select-dialog-main{position:relative;z-index:3;max-height:280px;overflow-y:auto}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item{display:flex;align-items:center;color:var(--chat-text-secondary);background:transparent;cursor:pointer;padding:8px;transition:all .3s ease;font-weight:700;font-size:14px;border-radius:6px;min-height:42px}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item .chat-select-dialog-preview{width:42px;height:42px;border-radius:6px;flex-shrink:0;margin-right:12px}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item .chat-select-dialog-name{flex:1;transition:all .3s ease;color:var(--chat-text-secondary)}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item .chat-select-dialog-check{display:inline-block;margin-left:6px;font-size:12px;color:var(--chat-primary)}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item:hover{background:var(--chat-card);opacity:.8}.chat-select-dialog .chat-select-dialog-main .chat-select-dialog-item:hover .chat-select-dialog-name{color:var(--chat-primary)}.chat-select-dialog .chat-select-arrow{position:absolute;z-index:2;pointer-events:none;width:16px;height:16px;overflow:hidden}.chat-select-dialog .chat-select-arrow:before{box-sizing:border-box;background:var(--chat-box);position:absolute;bottom:0;inset-inline-start:0;width:16px;height:8px;clip-path:path(\"M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z\");content:\"\"}.chat-select-dialog .chat-select-arrow:after{box-sizing:border-box;content:\"\";position:absolute;width:9px;height:9px;bottom:0;inset-inline:0;margin:auto;border-radius:0 0 2px;transform:translateY(50%) rotate(-135deg);box-shadow:var(--chat-box-shadow);z-index:0;background:transparent;opacity:.25}.call-user-dialog-item-sculpture{display:flex;align-items:center;justify-content:center;width:24px;height:24px;margin-right:8px;border-radius:4px;overflow:hidden;background:var(--chat-primary);color:var(--chat-box);white-space:nowrap;font-size:12px}.call-user-dialog-item-sculpture *{margin:0;padding:0;box-sizing:border-box}.call-user-dialog-item-sculpture.is-avatar{background:var(--chat-box)}.call-user-dialog-item-sculpture.is-avatar img{width:100%;height:100%}.call-user-dialog-item-sculpture span{font-size:12px;color:var(--chat-box)}.call-user-dialog-item-name{flex:1;white-space:nowrap;line-height:24px;overflow:hidden;text-overflow:ellipsis;padding-right:10px;color:var(--chat-text-assistant);font-size:14px}.chat-select-dialog-main::-webkit-scrollbar,.call-user-dialog-main::-webkit-scrollbar,.call-tag-dialog-main::-webkit-scrollbar,.checkbox-dialog-check-group::-webkit-scrollbar,.checkbox-dialog-tags::-webkit-scrollbar{width:6px;height:6px}.chat-select-dialog-main::-webkit-scrollbar-thumb,.call-user-dialog-main::-webkit-scrollbar-thumb,.call-tag-dialog-main::-webkit-scrollbar-thumb,.checkbox-dialog-check-group::-webkit-scrollbar-thumb,.checkbox-dialog-tags::-webkit-scrollbar-thumb{border-radius:10px;box-shadow:inset 0 0 5px #61b8b31a;background-color:#0003}.chat-select-dialog-main::-webkit-scrollbar-track,.call-user-dialog-main::-webkit-scrollbar-track,.call-tag-dialog-main::-webkit-scrollbar-track,.checkbox-dialog-check-group::-webkit-scrollbar-track,.checkbox-dialog-tags::-webkit-scrollbar-track{box-shadow:inset 0 0 5px #57afbb1a;border-radius:10px;background:#ededed}.disable-scroll{overflow-y:hidden!important}.chat-placeholder-wrap{position:absolute;top:0;left:0;width:100%;margin:0;padding:10px;box-sizing:border-box;color:var(--chat-text-placeholder);pointer-events:none;font-style:oblique;word-break:break-all;z-index:11}.chat-tip-wrap{position:absolute;top:0;left:0;width:auto;height:100%;margin:0;padding:10px 6px 10px 10px;box-sizing:border-box;pointer-events:none;-webkit-user-select:none;user-select:none;z-index:21}.chat-tip-wrap .chat-tip-tag{position:relative;padding:2px 6px;color:var(--chat-primary);border-radius:8px;pointer-events:visible;cursor:pointer;transition:background .3s ease}.chat-tip-wrap .chat-tip-tag .chat-tip-tag-txt{font-size:18px;font-weight:600;font-family:宋体,serif}.chat-tip-wrap .chat-tip-tag .chat-tip-tag-close{top:-4px;right:-4px;position:absolute;font-size:12px;opacity:0;transition:all .3s ease;color:var(--chat-text)}.chat-tip-wrap .chat-tip-tag .chat-tip-tag-close svg{font-size:inherit}.chat-tip-wrap .chat-tip-tag:hover{background:var(--chat-card)}.chat-tip-wrap .chat-tip-tag:hover .chat-tip-tag-close{opacity:1}.chat-tip-wrap .chat-custom-tip{pointer-events:visible}.chat-tip-popover{position:absolute}.chat-tip-popover .chat-tip-popover-main{display:flex;align-items:center;padding:8px 10px;background:var(--chat-popover);color:var(--chat-popover-text);font-size:13px;border-radius:8px}.chat-tip-popover .chat-tip-popover-main .chat-tip-popover-code{margin-left:4px;opacity:.7;font-size:12px}.chat-tip-popover .chat-tip-popover-main .chat-tip-popover-code.chat-view-show{display:none}.chat-tip-popover .chat-tip-popover-arrow{position:absolute;z-index:2;pointer-events:none;width:16px;height:16px;overflow:hidden;left:50%;transform:translate(-50%) rotate(-180deg)}.chat-tip-popover .chat-tip-popover-arrow:before{box-sizing:border-box;background:var(--chat-popover);position:absolute;bottom:0;inset-inline-start:0;width:16px;height:8px;clip-path:path(\"M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z\");content:\"\"}.chat-img{min-width:20px;min-height:20px;max-width:100px;max-height:100px;vertical-align:bottom}.chat-tag{margin:0 1px}.chat-grid-input{word-break:break-all}.at-user,.at-tag{color:var(--chat-primary)}.at-select{display:inline-block;cursor:pointer;background:var(--chat-card);color:var(--chat-primary);padding:2px 6px;border-radius:10px;margin:2px;transition:all .3s ease}.at-select svg{margin-left:4px;font-size:12px;transition:all .3s ease}.at-select:hover{color:var(--chat-highlight);background:var(--chat-highlight-card)}.at-select.aim svg{transform:rotate(-180deg)}.at-input{padding:2px 6px;border-radius:10px;margin:0 2px;color:var(--chat-primary);cursor:text;background:var(--chat-card);line-height:1.8}.at-input .input-write{white-space:pre-wrap;word-break:break-all;word-wrap:break-word;padding-left:.1px}.at-input .input-tip{pointer-events:none;-webkit-user-select:none;user-select:none;opacity:.35;word-break:break-all}\n", ""]);
34
34
  // Exports
35
35
  /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ((/* unused pure expression or super */ null && (___CSS_LOADER_EXPORT___)));
36
36
 
@@ -1013,7 +1013,7 @@ var SendButton_component = (0,componentNormalizer/* default */.A)(
1013
1013
 
1014
1014
  /* harmony default export */ const SendButton = (SendButton_component.exports);
1015
1015
  ;// ./node_modules/chatarea/lib/ChatArea.mjs
1016
- var __defProp=Object.defineProperty,__defNormalProp=(t,e,i)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,__publicField=(t,e,i)=>__defNormalProp(t,"symbol"!=typeof e?e+"":e,i);function os(){const t=navigator.userAgent,e=/(?:Windows Phone)/.test(t),i=/(?:SymbianOS)/.test(t)||e,n=/(?:Android)/.test(t),s=/(?:Firefox)/.test(t),a=/(?:iPad|PlayBook)/.test(t)||n&&!/(?:Mobile)/.test(t)||s&&/(?:Tablet)/.test(t),l=/(?:iPhone)/.test(t)&&!a;return{isTablet:a,isPhone:l,isAndroid:n,isPc:!l&&!n&&!i}}function domItVisible(t,e=!1,i="block"){t&&(t.className=t.className.replace(/ chat-view-show| chat-view-hidden/g,""),e?(t.style.display=i,t.className+=" chat-view-show"):(t.className+=" chat-view-hidden",t.style.display="none"))}function hasElmShow(t){return t&&t.classList.contains("chat-view-show")}function updateElmClass(t,e,i){t.classList[i?"add":"remove"](e)}const ELEMENT_EMPTY_KEY="data-set-empty",ELEMENT_RICH_TYPE_KEY="data-set-richType",RICH_WRAP="richWrap",RICH_GRID="richGrid",RICH_MARK="richMark",RICH_INPUT="richInput",RICH_TAG="richTag",ELEMENT_COMPONENT_KEY="data-set-component",sleep=(t=50)=>new Promise(e=>{setTimeout(e,t)}),getBoolean=t=>"false"!==String(t)&&"null"!==String(t)&&"0"!==String(t),debounce=(t,e,i=!1)=>{let n;return function(...s){const a=this,l=i&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,i||t.apply(a,s)},e),l&&t.apply(a,s)}},throttle=(t,e)=>{let i;return function(...n){const s=this;i||(t.apply(s,n),i=!0,setTimeout(function(){i=!1},e))}},upFindElm=(t,e)=>{const i=t.getAttribute("data-set-richType");return i===RICH_GRID?null:i===RICH_MARK||i===RICH_TAG?t:t.parentElement&&e>0?upFindElm(t.parentElement,e-1):null},getObjValue=(t,e,i)=>t&&t[e]?t[e]:i,strictMinifyHtml=t=>t.replace(/\n+/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><").trim(),convertBlocksToSpans=(t,e)=>{const i=document.createElement("div");i.innerHTML=t;i.querySelectorAll("div, p, h1, h2, h3, h4, h5, h6, section, article, header, footer, aside, nav").forEach(t=>{const e=document.createElement("span");for(e.style.display="block",Array.from(t.attributes).forEach(t=>{e.setAttribute(t.name,t.value)});t.firstChild;)e.appendChild(t.firstChild);t.parentNode.replaceChild(e,t)});const n=i.children[0];if(n&&"block"===n.style.display&&(n.style.display="inline-block"),n){for(const t in e)n.dataset[t]="{{"+t+"}}";n.setAttribute("data-set-component","{{data-set-component}}")}return i.innerHTML};function replaceTemplateVariables(t,e){let i=t;for(const[t,n]of Object.entries(e)){const e=`{{${t}}}`;i=i.replace(new RegExp(e,"g"),String(n))}return i}function escapeHtml(t){return t.replace(/[&<>"']/g,t=>{switch(t){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";case"'":return"&#039;";default:return t}}).replace(/\s/g,"&nbsp;")}function pinyinMatch(t,e,i){const n=e.split(/\s+/),s=t.split("").map((t,i)=>{let s=n[i]||"";return""===e&&""===s&&(s=t),{char:t,pinyin:s.toLowerCase(),initial:s?s[0].toLowerCase():""}}),a=(t=>{const e=[];let i="";for(const n of t)/[a-zA-Z]/.test(n)?i+=n.toLowerCase():(i&&(e.push({type:"pinyin",value:i}),i=""),e.push({type:"char",value:n}));return i&&e.push({type:"pinyin",value:i}),e})(i),l=s.length,o=a.length,r=Array.from({length:l+1},()=>Array(o+1).fill(!1));r[0][0]=!0;for(let t=0;t<=l;t++)for(let e=0;e<=o;e++)if(r[t][e]&&e<o){const i=a[e];for(let n=t;n<l;n++){const t=s[n];if("char"===i.type)t.char===i.value&&(r[n+1][e+1]=!0);else{const a=t.pinyin.toLowerCase(),o=t.initial,c=i.value;if(c===o)r[n+1][e+1]=!0;else if(c===a)r[n+1][e+1]=!0;else if(isSubsequence(c,a))r[n+1][e+1]=!0;else for(let t=2;t<=l-n;t++){const i=s.slice(n,n+t),a=i.map(t=>t.pinyin.toLowerCase()).join(""),l=i.map(t=>t.initial).join("");if(c===a||c===l||isSubsequence(c,a)){r[n+t][e+1]=!0;break}}}}}for(let t=0;t<=l;t++)if(r[t][o])return!0;return!1}function isSubsequence(t,e){let i=0,n=0;for(;i<t.length&&n<e.length;)t[i]===e[n]&&i++,n++;return i===t.length}const checkEmptySvg='<svg class="check-empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>',searchEmptySvg='<svg class="empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>',searchSvg='<svg class="icon-search" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M684.8 223.530667a326.272 326.272 0 0 1 24.96 433.621333c2.645333 2.133333 5.290667 4.48 7.850667 7.04L870.4 817.066667c24.789333 24.746667 32.896 56.832 18.133333 71.594666-14.762667 14.805333-46.848 6.656-71.637333-18.090666l-152.789333-152.832a106.282667 106.282667 0 0 1-7.210667-7.936 326.101333 326.101333 0 0 1-433.109333-25.173334c-127.445333-127.445333-127.573333-333.952-0.256-461.269333 127.36-127.36 333.866667-127.232 461.269333 0.213333zM275.328 275.114667a252.885333 252.885333 0 0 0 0.256 357.632 252.885333 252.885333 0 0 0 357.632 0.256 252.885333 252.885333 0 0 0-0.256-357.632 252.885333 252.885333 0 0 0-357.632-0.256z" fill="#9B9B9B"></path></svg>',antdLoading='<div class="ant-spin ant-spin-spinning" aria-live="polite" aria-busy="true"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>',matchEmptySvg='<svg class="match-empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>',checkSvg='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24"><path fill="currentColor" d="M9.218 17.41 19.83 6.796a.99.99 0 1 1 1.389 1.415c-3.545 3.425-4.251 4.105-11.419 11.074a.997.997 0 0 1-1.375.018c-1.924-1.801-3.709-3.568-5.573-5.43a.999.999 0 0 1 1.414-1.413z"></path></svg>',arrowSvg='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24"><path fill="currentColor" d="m20.23 8.653-7.795 9.685a1.2 1.2 0 0 1-1.87 0L2.771 8.652C2.14 7.867 2.698 6.7 3.706 6.7h15.588c1.008 0 1.567 1.167.935 1.952"></path></svg>',closeSvg='<svg focusable="false" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true" fill-rule="evenodd" viewBox="64 64 896 896"><path d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"></path></svg>';class ChatElement{constructor(t){__publicField(this,"target"),__publicField(this,"richText",document.createElement("div")),__publicField(this,"placeholderElm",document.createElement("div")),__publicField(this,"tipElm",null),__publicField(this,"isExternalCallPopup",!1),__publicField(this,"isPointSearchMode",!1),__publicField(this,"checkboxRows",[]),__publicField(this,"customTags",{}),__publicField(this,"selectTags",{}),__publicField(this,"rects",{}),__publicField(this,"pcElms",{containerDialogElm:null,pointDialogElm:null,pointDialogCheckElm:null,pointDialogMainElm:null,pointDialogUsersElm:[],pointDialogActiveElm:null,pointDialogLoadingElm:null,pointDialogEmptyElm:null,checkDialogElm:null,checkDialogSearchResultElm:null,checkDialogUsersElm:null,checkDialogSearchInputElm:null,checkDialogTagsElm:null,customTagDialogElms:{},customTagDialogTagKey:"",customTagDialogActiveElm:null,selectDialogElms:{},selectDialogKey:"",selectDialogAim:null,tipContainerPopoverElm:null,tipPopoverElm:null}),__publicField(this,"h5Elms",{dialogElm:null,dialogMainElm:null,dialogCheckElm:null,dialogShowElm:null,dialogSearchElm:null,dialogEmptyElm:null,dialogLoadingElm:null}),this.target=t,this.createRichText(),this.createPlaceholder(),t.deviceInfo.isPc?this.createPCDialog():this.createH5Dialog()}createRichText(){const{options:t,deviceInfo:e}=this.target,{elm:i}=t;updateElmClass(i,"chat-area-"+(e.isPc?"pc":"h5"),!0),updateElmClass(this.richText,"chat-rich-text",!0),this.richText.setAttribute("data-set-richType",RICH_WRAP),this.richText.setAttribute("contenteditable","true"),i.appendChild(this.richText)}createPlaceholder(){const{options:t}=this.target,{elm:e}=t;updateElmClass(this.placeholderElm,"chat-placeholder-wrap",!0),domItVisible(this.placeholderElm,!0),e.appendChild(this.placeholderElm),this.rects.plaRect=this.placeholderElm.getBoundingClientRect()}createPCDialog(){const{options:t}=this.target,{needDialog:e,elm:i,asyncMatch:n}=t;if(!e)return;const{pcElms:s}=this;s.containerDialogElm=document.createElement("div"),updateElmClass(this.pcElms.containerDialogElm,"chat-dialog",!0),i.nextElementSibling?i.parentElement.insertBefore(s.containerDialogElm,i.nextElementSibling):i.parentElement.appendChild(s.containerDialogElm),n||this.createPCCheckDialog(),this.createPCPointDialog()}createPCCheckDialog(){const{options:t}=this.target,e=this.target.options.dialogLabels.pcPCheckDialog,{pcElms:i}=this;i.checkDialogElm=document.createElement("div"),updateElmClass(i.checkDialogElm,"checkbox-dialog",!0),domItVisible(i.checkDialogElm),i.checkDialogElm.innerHTML=`\n <div class="checkbox-dialog-container">\n <div class="checkbox-dialog-container-header">\n <span>${e.title}</span>\n <span class="checkbox-dialog-container-header-close">⛌</span>\n </div>\n <div class="checkbox-dialog-container-body">\n <div class="checkbox-dialog-left-box">\n <div class="checkbox-dialog-search">\n <input class="checkbox-dialog-search-input" placeholder="${e.searchPlaceholder}" type="text">\n <div class="checkbox-dialog-search-group"></div>\n </div>\n <div class="checkbox-dialog-tags"></div>\n <div class="checkbox-dialog-option">\n <button class="checkbox-dialog-option-btn btn-submit disabled">${e.confirmLabel}</button>\n <button class="checkbox-dialog-option-btn btn-close">${e.cancelLabel}</button>\n </div>\n </div>\n <div class="checkbox-dialog-right-box">\n <div class="checkbox-dialog-right-box-title">${e.userTagTitle}</div>\n <div class="checkbox-dialog-check-group"></div>\n </div>\n </div>\n </div>\n `,i.containerDialogElm.appendChild(i.checkDialogElm),i.checkDialogUsersElm=i.checkDialogElm.querySelector(".checkbox-dialog-check-group"),i.checkDialogSearchResultElm=i.checkDialogElm.querySelector(".checkbox-dialog-search-group"),i.checkDialogSearchInputElm=i.checkDialogElm.querySelector(".checkbox-dialog-search-input"),i.checkDialogTagsElm=i.checkDialogElm.querySelector(".checkbox-dialog-tags");const n=()=>{domItVisible(i.checkDialogElm),updateElmClass(document.body,"disable-scroll")};i.checkDialogElm.querySelector(".checkbox-dialog-container-header-close").onclick=n,i.checkDialogElm.querySelector(".btn-close").onclick=n;const s=i.checkDialogElm.querySelector(".btn-submit");s.onclick=async()=>{if(s.classList.contains("disabled"))return;const e=this.checkboxRows.map(e=>{const i=Object.create(null);return i[t.userProps.id]=e.id,i[t.userProps.name]=e.name,i});await this.target.batchSetTag(e),n()},domItVisible(i.checkDialogSearchResultElm),i.checkDialogSearchResultElm.onclick=t=>{t.stopPropagation()},i.checkDialogSearchInputElm.onclick=t=>{t.stopPropagation()};const a=debounce(t=>{const e=String(t.target.value||"").replace(/'/g,"").trim();if(!e)return void domItVisible(i.checkDialogSearchResultElm);const n=this.target.searchUserList(e).map(t=>t.id);Array.from(i.checkDialogSearchResultElm.children,(t,e)=>{if(e===i.checkDialogSearchResultElm.children.length-1)domItVisible(t,0===n.length);else{const e=t.getAttribute("data-set-id");domItVisible(t,-1!==n.indexOf(e),"flex")}}),domItVisible(i.checkDialogSearchResultElm,!0)},200);i.checkDialogSearchInputElm.oninput=a,i.checkDialogSearchInputElm.onfocus=a}createPCPointDialog(){const{pcElms:t,target:e}=this;t.pointDialogElm=document.createElement("div"),updateElmClass(t.pointDialogElm,"call-user-dialog",!0),domItVisible(t.pointDialogElm);const i=document.createElement("div");updateElmClass(i,"call-user-dialog-header",!0),i.innerHTML=`<span class="call-user-dialog-header-title">${e.options.dialogLabels.pcPointDialog.title}</span>`,t.pointDialogCheckElm=document.createElement("span"),updateElmClass(t.pointDialogCheckElm,"call-user-dialog-header-check",!0),t.pointDialogCheckElm.innerText=e.options.dialogLabels.pcPointDialog.checkLabel,t.pointDialogCheckElm.onclick=()=>{this.target.showPCCheckDialog(),this.isExternalCallPopup=!1},i.appendChild(t.pointDialogCheckElm),t.pointDialogElm.appendChild(i),t.pointDialogMainElm=document.createElement("div"),updateElmClass(t.pointDialogMainElm,"call-user-dialog-main",!0),t.pointDialogElm.appendChild(t.pointDialogMainElm),e.options.asyncMatch&&(t.pointDialogLoadingElm=document.createElement("div"),updateElmClass(t.pointDialogLoadingElm,"call-user-dialog-loading",!0),t.pointDialogLoadingElm.innerHTML=antdLoading,t.pointDialogElm.appendChild(t.pointDialogLoadingElm),domItVisible(t.pointDialogLoadingElm),t.pointDialogEmptyElm=document.createElement("div"),updateElmClass(t.pointDialogEmptyElm,"call-user-dialog-empty",!0),t.pointDialogEmptyElm.innerHTML=`\n ${matchEmptySvg}\n <span class="empty-label">${e.options.dialogLabels.pcPointDialog.emptyLabel}</span>\n `,t.pointDialogElm.appendChild(t.pointDialogEmptyElm),domItVisible(t.pointDialogEmptyElm)),t.containerDialogElm.appendChild(t.pointDialogElm)}createH5Dialog(){const{options:t,chatEvent:e}=this.target,{needDialog:i,dialogLabels:n}=t;if(!i)return;const{h5Elms:s}=this;s.dialogElm=document.createElement("div"),updateElmClass(s.dialogElm,"call-user-popup",!0),s.dialogElm.innerHTML=`\n <div class="call-user-popup-main">\n <div class="call-user-popup-header">\n <span class="popup-show">${n.h5Dialog.cancelLabel}</span>\n <span class="popup-title">${n.h5Dialog.title}</span>\n <span class="popup-check">${n.h5Dialog.confirmLabel}</span>\n </div>\n <div class="call-user-popup-search">\n ${searchSvg}\n <input class="call-user-popup-search-input"\n placeholder="${n.h5Dialog.searchPlaceholder}"\n type="text">\n </div>\n <div class="call-user-popup-body"></div>\n </div>\n `;const a=async()=>{s.dialogElm.className=s.dialogElm.className.replace(/ chat-view-show/g," chat-view-hidden"),s.dialogSearchElm.value="",await sleep(260),domItVisible(s.dialogElm),updateElmClass(document.body,"disable-scroll"),t.asyncMatch&&this.target.updateUserList([]),this.target.chatInput.restCursorPos(this.target.chatInput.vnode,this.target.chatInput.cursorIndex),this.target.chatInput.viewIntoPoint()};s.dialogElm.onclick=a;const l=s.dialogElm.querySelector(".call-user-popup-main");l.onclick=t=>{t.stopPropagation()},s.dialogShowElm=s.dialogElm.querySelector(".popup-show"),s.dialogShowElm.onclick=a,s.dialogCheckElm=s.dialogElm.querySelector(".popup-check"),s.dialogCheckElm.onclick=async()=>{if(s.dialogCheckElm.classList.contains("disabled"))return;const e=s.dialogElm.querySelectorAll(".user-popup-check-item-check")||[];if(0===e.length)return void await a();if(Array.prototype.some.call(e,t=>"isALL"===t.getAttribute("data-set-id")))return await this.target.onceSetTag({[t.userProps.id]:"isALL",[t.userProps.name]:t.dialogLabels.h5Dialog.callEveryLabel}),void await a();const i=Array.from(e,t=>t.getAttribute("data-set-id")),n=t.userList.filter(e=>-1!==i.indexOf(String(e[t.userProps.id])));await this.target.batchSetTag(n),await a()},s.dialogMainElm=s.dialogElm.querySelector(".call-user-popup-body"),s.dialogEmptyElm=document.createElement("div"),updateElmClass(s.dialogEmptyElm,"call-user-popup-empty",!0),this.h5Elms.dialogEmptyElm.innerHTML=`\n ${searchEmptySvg}\n <span class="empty-label">${t.dialogLabels.h5Dialog.searchEmptyLabel}</span>\n `,domItVisible(s.dialogEmptyElm),l.appendChild(s.dialogEmptyElm),t.asyncMatch&&(s.dialogLoadingElm=document.createElement("div"),updateElmClass(s.dialogLoadingElm,"call-user-popup-loading",!0),s.dialogLoadingElm.innerHTML=antdLoading,domItVisible(s.dialogLoadingElm),l.appendChild(s.dialogLoadingElm)),s.dialogSearchElm=s.dialogElm.querySelector(".call-user-popup-search-input"),s.dialogSearchElm.oninput=debounce(i=>{const n=String(i.target.value||"").replace(/'/g,"").trim();if(t.asyncMatch){e.matchKey++;const t=e.matchKey;this.target.updateUserList([]),domItVisible(s.dialogLoadingElm,!0),domItVisible(s.dialogEmptyElm);const i=e.triggerChatEvent("atMatch",n).find(t=>t&&t instanceof Promise);return void(i&&i.then(i=>{t===e.matchKey&&(domItVisible(s.dialogLoadingElm),!i||i.length<=0?domItVisible(s.dialogEmptyElm,!0,"flex"):this.target.updateUserList(i))}))}const a=[];Array.from(this.h5Elms.dialogMainElm.children,t=>{if(!n)return domItVisible(t,!0,"flex"),void a.push(t);pinyinMatch(t.getAttribute("data-set-name")||"",t.getAttribute("data-set-pinyin")||"",n)?(domItVisible(t,!0,"flex"),a.push(t)):domItVisible(t)}),domItVisible(this.h5Elms.dialogEmptyElm,!a.length,"flex")},200),domItVisible(s.dialogElm),document.body.appendChild(s.dialogElm)}updatePCUser(){const{pcElms:t,target:e}=this;t.pointDialogMainElm.innerHTML="",t.pointDialogActiveElm=void 0;const i=document.createDocumentFragment();if(this.target.options.needCallEvery){const t=document.createElement("div");updateElmClass(t,"call-user-dialog-item",!0),t.setAttribute("data-set-id","isALL"),this.userSelectStyleAndEvent(t,{id:"isALL",name:e.options.dialogLabels.pcPointDialog.callEveryLabel}),t.innerHTML=`\n <span class="call-user-dialog-item-sculpture">\n <span style="transform: scale(0.75)">@</span>\n </span>\n <span class="call-user-dialog-item-name">${e.options.dialogLabels.pcPointDialog.callEveryLabel}(${e.options.reformList.length})</span>\n `,i.appendChild(t)}if(e.options.reformList.forEach(t=>{const e=document.createElement("div");updateElmClass(e,"call-user-dialog-item",!0),e.setAttribute("data-set-id",t.id),this.userSelectStyleAndEvent(e,t),this.getUserHtmlTemplate(e,t),i.appendChild(e)}),t.pointDialogMainElm.appendChild(i),t.pointDialogUsersElm=[],Array.from(t.pointDialogMainElm.children||[],(e,i)=>{t.pointDialogUsersElm.push({index:i,elm:e})}),e.options.asyncMatch)return;t.checkDialogUsersElm.innerHTML=`\n <div class="checkbox-dialog-check-item" data-set-value="ALL">\n <input type="checkbox" value>\n <span class="checkbox-dialog-check-item-inner"></span>\n <div class="checkbox-dialog-check-item-label">${e.options.dialogLabels.pcPCheckDialog.checkAllLabel}</div>\n </div>\n `;const n=document.createDocumentFragment();e.options.reformList.forEach(t=>{const e=document.createElement("div");updateElmClass(e,"checkbox-dialog-check-item",!0),e.setAttribute("data-set-value",t.id),e.innerHTML='\n <input type="checkbox" value>\n <span class="checkbox-dialog-check-item-inner"></span>\n ',this.getUserHtmlTemplate(e,t),n.appendChild(e)}),t.checkDialogUsersElm.appendChild(n),t.checkDialogUsersElm&&t.checkDialogUsersElm.children.length&&Array.from(t.checkDialogUsersElm.children,t=>{t.onclick=()=>{const i=t.getAttribute("data-set-value")||"",n=e.options.reformList.find(t=>t.id===i),s=-1===t.className.indexOf("checkbox-dialog-check-item-check");"ALL"===i?this.checkboxRows=s?e.options.reformList.map(t=>t):[]:s?this.checkboxRows.push(n):this.checkboxRows=this.checkboxRows.filter(t=>t.id!==i),this.updateCheckDialogTags()}}),t.checkDialogSearchResultElm.innerHTML="";const s=document.createDocumentFragment();e.options.reformList.forEach(t=>{const i=document.createElement("div");updateElmClass(i,"checkbox-dialog-check-item",!0),i.setAttribute("data-set-id",t.id);const n=document.createElement("div");updateElmClass(n,"checkbox-dialog-check-item-label",!0),this.getUserHtmlTemplate(n,t),i.appendChild(n),i.onclick=()=>{domItVisible(this.pcElms.checkDialogSearchResultElm);const t=i.getAttribute("data-set-id")||"";if(this.pcElms.checkDialogSearchInputElm.value="",this.pcElms.checkDialogSearchInputElm.focus(),this.checkboxRows.some(e=>e.id===t))return;const n=e.options.reformList.find(e=>e.id===t);n&&this.checkboxRows.push(n),this.updateCheckDialogTags()},s.appendChild(i)});const a=document.createElement("div");updateElmClass(a,"checkbox-dialog-search-empty",!0),a.innerText=e.options.dialogLabels.pcPCheckDialog.searchEmptyLabel,s.appendChild(a),t.checkDialogSearchResultElm.appendChild(s)}updateH5User(){const{h5Elms:t,target:e}=this;t.dialogMainElm.innerHTML="";const i=e.options.reformList&&e.options.reformList.length>0,n=document.createDocumentFragment(),s=document.createElement("span");if(s.innerHTML='\n <input type="checkbox" value>\n <span class="user-popup-check-item-inner"></span>\n ',i){const t=document.createElement("div");e.options.needCallEvery&&(updateElmClass(t,"call-user-popup-item",!0),t.setAttribute("data-set-id","isALL"),t.innerHTML=`\n <span class="call-user-dialog-item-sculpture">\n <span style="transform: scale(0.75)">@</span>\n </span>\n <span class="call-user-dialog-item-name">${e.options.dialogLabels.h5Dialog.callEveryLabel}(${e.options.reformList.length})</span>\n `,t.appendChild(s.cloneNode(!0)),t.onclick=()=>{const e=!t.classList.contains("user-popup-check-item-check");Array.from(this.h5Elms.dialogMainElm.children,t=>{updateElmClass(t,"user-popup-check-item-check",e)}),updateElmClass(this.h5Elms.dialogCheckElm,"disabled",!e)},n.appendChild(t)),e.options.reformList.forEach((e,i)=>{const a=document.createElement("div");updateElmClass(a,"call-user-popup-item",!0),a.setAttribute("data-set-id",e.id),a.setAttribute("data-set-name",e.name),a.setAttribute("data-set-pinyin",e.pinyin||""),this.getUserHtmlTemplate(a,e),a.appendChild(s.cloneNode(!0)),n.appendChild(a),a.onclick=e=>{const i=!a.classList.contains("user-popup-check-item-check");updateElmClass(a,"user-popup-check-item-check",i);const n=Array.prototype.every.call(this.h5Elms.dialogMainElm.children,t=>t.classList.contains("user-popup-check-item-check")||"isALL"===t.getAttribute("data-set-id"));updateElmClass(t,"user-popup-check-item-check",n);const s=Array.prototype.some.call(this.h5Elms.dialogMainElm.children,t=>t.classList.contains("user-popup-check-item-check"));updateElmClass(this.h5Elms.dialogCheckElm,"disabled",!s)}})}t.dialogMainElm.appendChild(n)}updateCheckDialogTags(){const t=this.checkboxRows.map(t=>t.id),e=[],i=[],n=document.createElement("div");n.className="check-empty",n.innerHTML=`\n ${checkEmptySvg}\n <span class="check-empty-label">${this.target.options.dialogLabels.pcPCheckDialog.checkEmptyLabel}</span>\n `,Array.from(this.pcElms.checkDialogTagsElm.children,n=>{const s=n.getAttribute("data-set-value");-1===t.indexOf(s)?i.push(n):e.push(s)}),Array.from(this.pcElms.checkDialogUsersElm.children,(e,i)=>{if(0===i)return void updateElmClass(e,"checkbox-dialog-check-item-check",t.length===this.target.options.reformList.length);const n=e.getAttribute("data-set-value");updateElmClass(e,"checkbox-dialog-check-item-check",-1!==t.indexOf(n))}),i.forEach(t=>{this.pcElms.checkDialogTagsElm.removeChild(t)});updateElmClass(this.pcElms.checkDialogElm.querySelector(".btn-submit"),"disabled",t.length<=0),t.length||this.pcElms.checkDialogTagsElm.appendChild(n);const s=this.checkboxRows.filter(t=>-1===e.indexOf(t.id));if(!s.length)return;const a=document.createDocumentFragment();s.forEach(t=>{const e=document.createElement("div");e.setAttribute("class","checkbox-dialog-tag-item"),e.setAttribute("data-set-value",t.id),e.innerHTML=`\n <span>${t.name}</span>\n `;const i=document.createElement("span");i.setAttribute("class","checkbox-dialog-tag-item-close"),i.innerHTML="⛌",i.onclick=()=>{const t=e.getAttribute("data-set-value");this.checkboxRows=this.checkboxRows.filter(e=>e.id!==t),this.updateCheckDialogTags()},e.appendChild(i),a.appendChild(e)}),this.pcElms.checkDialogTagsElm.appendChild(a)}userSelectStyleAndEvent(t,e){t.addEventListener("click",async i=>{const{options:n}=this.target;if(i.stopPropagation(),this.updatePointActiveUserElm(t),this.isPointSearchMode||n.asyncMatch)await this.target.matchSetTag(e);else{const t=n.userList.find(t=>String(t[n.userProps.id])===e.id);await this.target.onceSetTag(t)}this.exitPointDialog()})}bindCustomTrigger(){Object.values(this.pcElms.customTagDialogElms).forEach(t=>{this.pcElms.containerDialogElm.removeChild(t)}),this.pcElms.customTagDialogElms={},this.customTags={},this.target.options.customTrigger.forEach(t=>{t.tagList&&t.tagList.length>0&&(this.customTags[t.prefix]=t.tagList.map(t=>({id:String(t.id),name:String(t.name),pinyin:String(t.pinyin||"")})),this.createCustomTagDialog(t))})}createCustomTagDialog(t){const e=document.createElement("div");e.setAttribute("class","call-tag-dialog"),domItVisible(e);const i=document.createElement("div");i.setAttribute("class","call-tag-dialog-header"),i.innerHTML=`<span class="call-tag-dialog-header-title">${t.dialogTitle||t.prefix}</span>`,e.appendChild(i);const n=document.createElement("div");n.setAttribute("class","call-tag-dialog-main"),t.tagList.forEach(t=>{const e=document.createElement("div");e.setAttribute("class","call-tag-dialog-item"),e.setAttribute("data-set-id",t.id);const i=document.createElement("span");i.setAttribute("class","call-tag-dialog-item-name"),i.innerHTML=t.name,e.appendChild(i),e.addEventListener("click",async i=>{i.stopPropagation(),this.updateActiveCustomTagElm(e),this.isPointSearchMode?await this.target.matchSetCustomTag(t):await this.target.onceSetCustomTag(t),this.exitCustomTagDialog()}),n.appendChild(e)}),e.appendChild(n),this.pcElms.containerDialogElm.appendChild(e),this.pcElms.customTagDialogElms[t.prefix]=e}getUserHtmlTemplate(t,e){const i=document.createElement("span");if(i.setAttribute("class","call-user-dialog-item-sculpture "+(e.avatar?"is-avatar":"")),e.avatar){const t=new Image;t.alt="",t.src=String(e.avatar),i.appendChild(t)}else i.innerHTML=`<span style="transform: scale(0.75)">${e.name.slice(-2)}</span>`;t.appendChild(i);const n=document.createElement("span");n.setAttribute("class","call-user-dialog-item-name"),n.innerHTML=e.name,t.appendChild(n)}updatePointActiveUserElm(t,e=!1){if(this.pcElms.pointDialogActiveElm&&updateElmClass(this.pcElms.pointDialogActiveElm,"call-user-dialog-item-active"),this.pcElms.pointDialogActiveElm=t,t&&(updateElmClass(t,"call-user-dialog-item-active",!0),e)){const e=Array.prototype.filter.call(this.pcElms.pointDialogMainElm.children,t=>-1===t.className.indexOf("user-no-match")),i=t.clientHeight,n=Array.prototype.indexOf.call(e,t)+1-Math.ceil(Math.floor(this.pcElms.pointDialogMainElm.clientHeight/i)/2);this.pcElms.pointDialogMainElm.scrollTop=n>0?n*i:0}}updateActiveCustomTagElm(t,e=!1){if(this.pcElms.customTagDialogActiveElm&&updateElmClass(this.pcElms.customTagDialogActiveElm,"call-tag-dialog-item-active"),this.pcElms.customTagDialogActiveElm=t,t&&(updateElmClass(t,"call-tag-dialog-item-active",!0),e)){const e=this.pcElms.customTagDialogElms[this.pcElms.customTagDialogTagKey].children[1],i=Array.prototype.filter.call(e.children,t=>-1===t.className.indexOf("tag-no-match")),n=t.clientHeight,s=Array.prototype.indexOf.call(i,t)+1-Math.ceil(Math.floor(e.clientHeight/n)/2);e.scrollTop=s>0?s*n:0}}showPointDialog(t){this.exitSelectDialog(),this.exitCustomTagDialog(),this.exitPointDialog(),this.isPointSearchMode=!!t;let e=null;this.pcElms.pointDialogUsersElm.forEach(i=>{const n=i.elm,s=n.getAttribute("data-set-id"),a=t&&t.every(t=>t.id!==s);e||a||(e=n),updateElmClass(n,"user-no-match",a)}),null!==e&&this.updatePointActiveUserElm(e),domItVisible(this.pcElms.pointDialogCheckElm,!this.target.options.asyncMatch&&!this.isPointSearchMode),domItVisible(this.pcElms.pointDialogElm,!0),this.target.chatEvent.debounceEvents.dialogMoveToRange(this.pcElms.pointDialogElm),this.pcElms.pointDialogMainElm.scrollTop=0}showCustomTagDialog(t,e){this.exitSelectDialog(),this.exitCustomTagDialog(),this.exitPointDialog(),this.isPointSearchMode=!!e,this.pcElms.customTagDialogTagKey=t;const i=this.pcElms.customTagDialogElms[t],n=i.children[1];let s=null;Array.from(n.children,t=>{const i=t.getAttribute("data-set-id"),n=e&&e.every(t=>t.id!==i);s||n||(s=t),updateElmClass(t,"tag-no-match",n)}),null!==s&&this.updateActiveCustomTagElm(s),domItVisible(i,!0),this.target.chatEvent.debounceEvents.dialogMoveToRange(i),i.children[1].scrollTop=0}exitPointDialog(){this.updatePointActiveUserElm(),this.target.options.asyncMatch&&this.target.updateUserList([]),domItVisible(this.pcElms.pointDialogElm)}exitCustomTagDialog(){this.updateActiveCustomTagElm();for(const t in this.pcElms.customTagDialogElms)domItVisible(this.pcElms.customTagDialogElms[t])}ruleShowPointDialog(){const{options:t}=this.target;t.needDialog&&t.reformList.length>0&&(this.isExternalCallPopup=!1,this.showPointDialog())}showPlaceholder(){domItVisible(this.placeholderElm,this.target.isEmpty()),this.offsetTipElm()}bindSelectList(){Object.values(this.pcElms.selectDialogElms).forEach(t=>{this.pcElms.containerDialogElm.removeChild(t)}),this.pcElms.selectDialogElms={},this.selectTags={},this.target.options.selectList.forEach(t=>{t.options&&t.options.length>0&&(this.selectTags[t.key]=t.options.map(t=>({id:String(t.id),name:String(t.name),preview:String(t.preview||"")})),this.createSelectDialog(t))})}createSelectDialog(t){const e=document.createElement("div");e.setAttribute("class","chat-select-dialog"),domItVisible(e);const i=document.createElement("div");i.setAttribute("class","chat-select-dialog-header"),i.innerHTML=`<span class="chat-select-dialog-header-title">${t.dialogTitle||t.key}</span>`,e.appendChild(i);const n=document.createElement("div");n.setAttribute("class","chat-select-dialog-main"),t.options.forEach(t=>{const e=document.createElement("div");if(e.setAttribute("class","chat-select-dialog-item"),e.setAttribute("data-set-id",t.id),t.preview){const i=document.createElement("img");i.setAttribute("class","chat-select-dialog-preview"),i.src=String(t.preview),e.appendChild(i)}const i=document.createElement("span");i.setAttribute("class","chat-select-dialog-name"),i.textContent=t.name;const s=document.createElement("span");s.setAttribute("class","chat-select-dialog-check"),s.innerHTML=checkSvg,domItVisible(s),i.appendChild(s),e.appendChild(i),e.onclick=async()=>{await this.target.setSelectTag(t)},n.appendChild(e)}),e.appendChild(n);const s=document.createElement("div");s.setAttribute("class","chat-select-arrow"),e.appendChild(s),this.pcElms.containerDialogElm.appendChild(e),this.pcElms.selectDialogElms[t.key]=e}exitSelectDialog(){for(const t in this.pcElms.selectDialogElms)domItVisible(this.pcElms.selectDialogElms[t]);this.pcElms.selectDialogKey="",this.pcElms.selectDialogAim&&(updateElmClass(this.pcElms.selectDialogAim,"aim"),this.pcElms.selectDialogAim=null)}createTipElm(t){this.tipElm||(this.tipElm=document.createElement("div")),updateElmClass(this.tipElm,"chat-tip-wrap",!0),this.tipElm.innerHTML=`\n <div class="chat-tip-tag">\n <span class="chat-tip-tag-txt">${t.tagLabel||"--"}</span>\n <span class="chat-tip-tag-close">\n ${this.target.deviceInfo.isPc?closeSvg:""}\n </span>\n </div>\n `,this.target.options.elm.appendChild(this.tipElm);const e=this.tipElm.children[0],i=(e.clientHeight-this.target.chatInput.NODE_HEIGHT)/2;this.tipElm.style.top=`-${i}px`,e.onclick=()=>{this.target.deviceInfo.isPc&&this.target.closeTipTag()},e.onmouseenter=()=>{if(this.pcElms.tipContainerPopoverElm&&this.pcElms.tipPopoverElm){domItVisible(this.pcElms.tipPopoverElm,!0);const t=this.pcElms.tipContainerPopoverElm.getBoundingClientRect();this.rects.tipRect=this.tipElm.getBoundingClientRect();const i=(this.pcElms.tipPopoverElm.clientWidth-(this.tipElm.clientWidth+(this.tipElm.clientWidth-e.clientWidth)))/2;this.pcElms.tipPopoverElm.style.left=-i+"px",this.pcElms.tipPopoverElm.style.bottom=t.y-this.rects.tipRect.y+"px",this.pcElms.tipPopoverElm.style.transform=e.style.transform}},e.onmouseleave=()=>{this.pcElms.tipPopoverElm&&domItVisible(this.pcElms.tipPopoverElm)};const n=this.richText.children[0].children[0];this.rects.tipRect=this.tipElm.getBoundingClientRect();const s=this.rects.tipRect;if(this.placeholderElm.style.paddingLeft=s.width+"px",n.style.paddingLeft=s.width-n.offsetLeft+"px",this.offsetTipElm(),this.target.deviceInfo.isPc){this.pcElms.tipContainerPopoverElm||(this.pcElms.tipContainerPopoverElm=document.createElement("div"),updateElmClass(this.pcElms.tipContainerPopoverElm,"chat-tip-dialog",!0)),this.pcElms.tipPopoverElm||(this.pcElms.tipPopoverElm=document.createElement("div")),updateElmClass(this.pcElms.tipPopoverElm,"chat-tip-popover",!0),this.pcElms.tipPopoverElm.innerHTML=`\n <div class="chat-tip-popover-main">\n <span class="chat-tip-popover-txt">${t.popoverLabel||"--"}</span>\n <span class="chat-tip-popover-code ${t.codeLabel?"":"chat-view-show"}">${t.codeLabel||"--"}</span>\n </div>\n <div class="chat-tip-popover-arrow"></div>\n `,this.pcElms.tipContainerPopoverElm.appendChild(this.pcElms.tipPopoverElm),domItVisible(this.pcElms.tipPopoverElm);const{elm:e}=this.target.options;e.parentElement&&(e.nextElementSibling?e.parentElement.insertBefore(this.pcElms.tipContainerPopoverElm,e.nextElementSibling):e.parentElement.appendChild(this.pcElms.tipContainerPopoverElm))}this.target.chatEvent.triggerChatEvent("tipTagState",!0)}offsetTipElm(){if(this.tipElm){const t=this.richText.children[0].children[0];t.style.paddingLeft=this.rects.tipRect.width-t.offsetLeft+"px",this.target.nextTick(()=>{if(this.tipElm){const t=this.tipElm.children[0],e=this.richText.children[0].children[0];t.style.transform=`translateY(${e.offsetTop-this.target.chatInput.NODE_PADDING_DIFF}px)`}})}}removeTipElm(){this.tipElm&&(this.target.options.elm.removeChild(this.tipElm),this.tipElm=null),this.pcElms.tipContainerPopoverElm&&(this.pcElms.tipContainerPopoverElm.removeChild(this.pcElms.tipPopoverElm),this.target.options.elm.parentElement.removeChild(this.pcElms.tipContainerPopoverElm),this.pcElms.tipContainerPopoverElm=null,this.pcElms.tipPopoverElm=null);const t=this.richText.children[0].children[0];this.placeholderElm.style.removeProperty("padding-left"),t.style.removeProperty("padding-left"),this.target.chatInput.setRangeLastText(),this.target.chatEvent.triggerChatEvent("tipTagState",!1)}}class ChatInput{constructor(t){__publicField(this,"target"),__publicField(this,"richText"),__publicField(this,"vnode"),__publicField(this,"cursorIndex"),__publicField(this,"cursorLeft"),__publicField(this,"needCallSpace",!1),__publicField(this,"VOID_KEY","\ufeff"),__publicField(this,"ZERO_WIDTH_KEY","​"),__publicField(this,"INPUT_TAG_WRAP_KEY","​\n​"),__publicField(this,"NODE_HEIGHT",24),__publicField(this,"NODE_PADDING_DIFF",10),__publicField(this,"IME_RECORD",{MARK:void 0,GRID:void 0,TAG:void 0,NODE:void 0,INDEX:void 0}),this.target=t,this.richText=t.chatElement.richText,this.initEditor()}initEditor(t=!1,e){if(t||this.getNodeEmpty(this.richText)){this.richText.innerHTML="";const i=this.getGridElm();this.richText.appendChild(i);const n=i.children[0].children[0];e&&(n.textContent=e,n.setAttribute("data-set-empty","false"));const s=n.childNodes[0];t||this.target.options.autoFocus?this.restCursorPos(s,s.textContent===this.VOID_KEY?1:s.textContent.length):(this.vnode=s,this.cursorIndex=s.textContent===this.VOID_KEY?1:s.textContent.length),this.target.nextTick(()=>{const t=i.getBoundingClientRect();this.NODE_HEIGHT=t.height,this.NODE_PADDING_DIFF=t.top-this.target.options.elm.getBoundingClientRect().top})}}onceCall(t){return new Promise(e=>{const i=this.createChatTagElm(t,"@","at-user","user-id");this.replaceRegContent(i),e()})}onceSearchCall(t,e){return new Promise(i=>{const n=this.createChatTagElm(t,"@","at-user","user-id");this.replaceRegContent(n,e),i()})}onceCustomCall(t,e,i){return new Promise(n=>{const s=this.createChatTagElm(t,i,"at-tag","tag-id");s.children[0].setAttribute("data-set-prefix",i),this.replaceRegContent(s,e),n()})}upDataNodeOrIndex(){var t,e,i;const{focusNode:n,focusOffset:s,anchorOffset:a}=window.getSelection(),l=(null==n?void 0:n.parentNode)||void 0;if(!l||!l.getAttribute||l.getAttribute("data-set-richType")!==RICH_INPUT)return;(null==(i=null==(e=null==(t=null==n?void 0:n.parentNode)?void 0:t.parentNode)?void 0:e.parentNode)?void 0:i.parentNode)===this.richText&&(this.vnode=n,this.cursorIndex=s,this.cursorLeft=a<s?a:s)}keyUpAsKey(t){if(this.upDataNodeOrIndex(),!this.vnode||this.vnode.nodeType!==Node.TEXT_NODE)return!1;const e=this.vnode.textContent||"",i=new RegExp(`${t}([^${t}\\s]*)$`),n=e.slice(0,this.cursorIndex),s=i.exec(n);return s&&2===s.length&&n[n.length-1]===t}getRangeRect(){let t=0,e=0;const i=window.getSelection();if(i.focusNode.nodeType!==Node.TEXT_NODE)return null;const n=i.getRangeAt(0).getClientRects()[0];return n&&(t=n.x,e=n.y),{x:t,y:e}}createChatTagElm(t,e,i,n){const s=document.createElement("span");return s.className=i,s.setAttribute(`data-${n}`,String(t.id)),s.textContent=`${e}${t.name}${this.needCallSpace?" ":""}`,this.createNewDom(s)}createNewDom(t){const e=document.createElement("span");return e.className="chat-tag",e.setAttribute("contenteditable","false"),e.setAttribute("data-set-richType",RICH_TAG),e.appendChild(t),e}restCursorPos(t,e){null==e?e=t.textContent===this.VOID_KEY?1:0:e>t.textContent.length&&(e=t.textContent.length);const i=new Range;i.setStart(t,e),i.setEnd(t,e);const n=window.getSelection();n&&(this.vnode=t,this.cursorIndex=e,this.cursorLeft=e,n.removeAllRanges(),n.addRange(i))}replaceRegContent(t,e=!0){const i=this.vnode.textContent;let n;n="boolean"==typeof e?i.slice(0,e?this.cursorIndex-1:this.cursorIndex):i.slice(0,e-1),0===n.length?(this.vnode.parentElement.setAttribute("data-set-empty","true"),this.vnode.textContent=this.VOID_KEY):this.vnode.textContent=n;let s=i.slice(this.cursorIndex);const a=this.vnode.parentNode.parentNode,l=a.nextSibling;l?a.parentNode.insertBefore(t,l):a.parentNode.appendChild(t);const o=t.previousSibling.childNodes[0],r=o.childNodes[1];r&&o.removeChild(r);const c=this.getGridElm(!0),h=c.childNodes[0];s&&s!==this.VOID_KEY&&(h.setAttribute("data-set-empty","false"),h.innerHTML=s);const d=h.childNodes[1];t.nextSibling?(d&&h.removeChild(d),a.parentNode.insertBefore(c,t.nextSibling)):a.parentNode.appendChild(c),this.restCursorPos(h.childNodes[0])}batchReplaceRegContent(t=[],e=!0){return new Promise(i=>{let n=`<span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="true">${this.VOID_KEY}</span></span>`;t.forEach(t=>{n+=`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-user" data-user-id="${t.id}" contentEditable="false">@${t.name}${this.needCallSpace?" ":""}</span></span><span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="true">${this.VOID_KEY}</span></span>`});const s=document.createElement("div");s.innerHTML=n,this.insetRangeGrid(s,e?1:0),i()})}switchRange(t){var e,i;let{focusNode:n,focusOffset:s}=window.getSelection();n.getAttribute&&n.getAttribute("data-set-richType")===RICH_INPUT&&(n=n.childNodes[0]);let a,l,o=!1;if(n.nodeType===Node.TEXT_NODE){const r=n.textContent.length,c=n.parentNode.parentNode;switch(t){case"ArrowLeft":if(s>0&&n.textContent!==this.VOID_KEY){l=s-1,a=n;break}const t=c.previousSibling;if(t&&t.children[0].classList.contains("at-input")){a=t.children[0].children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:a.textContent.length,o=!0;break}const h=null==(e=null==c?void 0:c.previousSibling)?void 0:e.previousSibling;if(h)a=h.childNodes[0].childNodes[0],l=a.textContent.length;else{const t=c.parentNode.previousSibling;if(t){a=t.lastChild.childNodes[0].childNodes[0],l=a.textContent.length}}break;case"ArrowRight":if(s<r&&n.textContent!==this.VOID_KEY){l=s+1,a=n;break}const d=c.nextSibling;if(d&&d.children[0].classList.contains("at-input")){a=d.children[0].children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0,o=!0;break}const p=null==(i=null==c?void 0:c.nextSibling)?void 0:i.nextSibling;if(p)a=p.childNodes[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0;else{const t=c.parentNode.nextSibling;t&&(a=t.childNodes[0].childNodes[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0)}}}(l||0===l)&&(o?this.setInputTagRange(a,l):this.restCursorPos(a,l))}getGridElm(t=!1){const e=document.createElement("span");if(e.setAttribute("data-set-richType",RICH_MARK),e.innerHTML=`<span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="true">${this.VOID_KEY}<br></span>`,t)return e;const i=document.createElement("p");return i.className="chat-grid-wrap",i.setAttribute("data-set-richType",RICH_GRID),i.appendChild(e),i}updateGrid(){const t=window.getSelection(),e=t.focusNode;if(!e)return;const i=e.parentNode;let n,s,a,l;switch(i.getAttribute("data-set-richType")){case RICH_WRAP:if(n=e.childNodes[t.focusOffset],!n||n.getAttribute("data-set-richType")===RICH_TAG){const t=this.getGridElm(!0),i=t.children[0];n?(i.removeChild(i.childNodes[1]),e.insertBefore(t,n)):e.appendChild(t),this.restCursorPos(i.childNodes[0]);break}if(n.tagName&&"BR"===n.tagName.toLocaleUpperCase()){const t=this.getGridElm(!0),i=t.children[0];e.insertBefore(t,n),e.removeChild(n),t.nextElementSibling&&t.children[0].removeChild(t.children[0].childNodes[1]),this.restCursorPos(i.childNodes[0],i.childNodes[0].textContent.length)}break;case RICH_MARK:const o=i.parentNode,r=Array.prototype.indexOf.call(o.childNodes,i);if(-1===r)break;if(0===r){const e=t.focusNode;e.setAttribute("data-set-empty","true"),e.innerHTML=`${this.VOID_KEY}<br>`,n=e.childNodes[0],this.restCursorPos(n,n.textContent.length);break}let c,h=i.previousSibling;h.getAttribute("data-set-richType")===RICH_TAG?(c=h.previousSibling,o.removeChild(h),o.removeChild(i)):(c=i.previousSibling,o.removeChild(i));n=c.childNodes[0].childNodes[0],n.textContent===this.VOID_KEY&&n.parentNode.appendChild(document.createElement("br")),this.restCursorPos(n,n.textContent.length);break;case RICH_INPUT:if(l=i.parentNode,a=l.parentNode,this.getNodeEmpty(i)){i.setAttribute("data-set-empty","true"),a.childNodes[a.childNodes.length-1]===l&&(i.innerHTML=`${this.VOID_KEY}<br>`),n=i.childNodes[0],this.restCursorPos(n,n.textContent.length);break}if("true"===String(i.getAttribute("data-set-empty"))){i.setAttribute("data-set-empty","false"),n=i.childNodes[0],this.target.chatEvent.isIMEModel?(i.childNodes[1]&&i.removeChild(i.childNodes[1]),n.textContent===this.VOID_KEY&&i.setAttribute("data-set-empty","true")):i.textContent=n.textContent.replace(new RegExp(this.VOID_KEY,"g"),"");const t=i.childNodes[0];this.restCursorPos(t,t.textContent.length)}if(s=i.parentNode.nextSibling,s&&s.nodeType===Node.TEXT_NODE){let t=s.textContent,e=this.getGridElm(!0);e.childNodes[0].textContent=t,e.childNodes[0].setAttribute("data-set-empty","false"),s.parentNode.insertBefore(e,s),s.parentNode.removeChild(s),s=e}s&&s.getAttribute("data-set-richType")===RICH_MARK&&this.markMerge(i.parentNode,s)}}getNodeEmpty(t){const e=new RegExp(`^(${this.ZERO_WIDTH_KEY}|<br>|${this.VOID_KEY})+$`);return!t.innerHTML||e.test(t.innerHTML)}setWrap(t=!0){const e=window.getSelection();let{focusNode:i,focusOffset:n}=e;if(i.nodeType!==Node.TEXT_NODE){if(!i.getAttribute||i.getAttribute("data-set-richType")!==RICH_INPUT)return;i=i.childNodes[0]}const s=i.textContent.slice(n),a=i.parentNode.parentNode,l=a.parentNode,o=Array.prototype.indexOf.call(l.childNodes,a),r=Array.prototype.slice.call(l.childNodes,o+1),c=this.getGridElm();let h=c.children[0].children[0].childNodes[0];(s||r.length>0)&&h.parentNode.removeChild(h.parentNode.childNodes[1]),s&&s!==this.VOID_KEY&&(i.textContent=i.textContent.slice(0,n),h.textContent=s,h.parentElement.setAttribute("data-set-empty","false")),r.forEach(t=>{l.removeChild(t),c.appendChild(t)});const d=l.lastChild.childNodes[0],p=c.lastChild.childNodes[0];if(d.childNodes.length<=1){const t=d.childNodes[0];t.textContent&&t.textContent!==this.VOID_KEY||(d.innerHTML=`${this.VOID_KEY}<br>`,d.setAttribute("data-set-empty","true"))}if(p.parentElement.getAttribute("data-set-richType")!==RICH_MARK)c.appendChild(this.getGridElm(!0));else if(p.childNodes.length<=1){const t=p.childNodes[0];t.textContent&&t.textContent!==this.VOID_KEY||(p.innerHTML=`${this.VOID_KEY}<br>`,p.setAttribute("data-set-empty","true"),h=c.children[0].children[0].childNodes[0])}l.nextSibling?this.richText.insertBefore(c,l.nextSibling):this.richText.appendChild(c),t&&this.restCursorPos(h,h.textContent===this.VOID_KEY?1:0)}selectAll(){const t=document.createRange(),e=this.richText.children[0].children[0].childNodes[0].childNodes[0],i=this.richText.lastElementChild.lastElementChild.childNodes[0].childNodes[0];t.setStart(e,0),t.setEnd(i,i.textContent.length);const n=window.getSelection();n.removeAllRanges(),n.addRange(t)}selectRegionMerge(){const t=window.getSelection();if(t.isCollapsed||t.rangeCount<=0)return;const e=t.getRangeAt(0);if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startContainer===e.endContainer){const t=e.startContainer;if(t.length===e.endOffset-e.startOffset){const e=t.parentNode,i=e.parentNode===e.parentNode.parentNode.lastChild;e.setAttribute("data-set-empty","true"),e.innerHTML="\ufeff"+(i?"<br>":""),this.restCursorPos(e.childNodes[0])}else e.deleteContents()}else if(e.commonAncestorContainer&&e.commonAncestorContainer.getAttribute("data-set-richType")===RICH_GRID){const t=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentNode.parentNode:e.startContainer,i=e.endContainer.nodeType===Node.TEXT_NODE?e.endContainer.parentNode.parentNode:e.endContainer;e.deleteContents(),t.getAttribute("data-set-richType")===i.getAttribute("data-set-richType")&&this.markMerge(t,i)}else if(e.commonAncestorContainer===e.startContainer&&e.startContainer===e.endContainer)this.initEditor(!0);else{const t=t=>{if(t.nodeType===Node.TEXT_NODE)return t.parentNode.parentNode.parentNode;switch(t.getAttribute("data-set-richType")){case RICH_INPUT:return t.parentNode.parentNode;case RICH_MARK:return t.parentNode;case RICH_GRID:return t;default:return null}},i=t(e.startContainer),n=t(e.endContainer);if(!i||!n)return;e.deleteContents(),this.gridMerge(i,n)}return!0}gridElmMerge(){const t=window.getSelection(),{focusNode:e,focusOffset:i,isCollapsed:n}=t;if(!e)return this.restCursorPos(this.vnode,this.cursorIndex),!1;if(i>1)return!1;if(!n)return!1;const s=(t,e)=>(t.parentNode===this.richText||t===t.parentNode.childNodes[0])&&(-1!==Array.prototype.indexOf.call(this.richText.childNodes,t)?t:!(e>=6)&&s(t.parentNode,e+1)),a=s(e,0);if(!a||a===this.richText.childNodes[0]||1===i&&"false"===a.children[0].children[0].getAttribute("data-set-empty"))return!1;const l=a.previousSibling;return this.gridMerge(l,a),!0}delMarkRule(){const t=window.getSelection(),e=t.focusNode;if(!e)return this.restCursorPos(this.vnode,this.cursorIndex),!1;const i=e.textContent,n=e.parentNode,s=n.parentNode,a=s.parentNode;if(!t.isCollapsed||n.getAttribute("data-set-richType")!==RICH_INPUT)return!1;if(i&&1===i.length&&s!==a.childNodes[0]&&(0!==t.focusOffset||i===this.VOID_KEY)){if(i===this.VOID_KEY){const t=s.previousSibling;if(t.children[0].classList.contains("at-input")&&t.children[0].children[0].textContent!==this.VOID_KEY)return this.rangeToInputTag(t.children[0]),!0;const e=t.previousSibling;a.removeChild(t),a.removeChild(s);const i=e.childNodes[0],n=i.childNodes[0];n.textContent===this.VOID_KEY&&e===a.lastChild&&i.appendChild(document.createElement("br")),this.restCursorPos(n,n.textContent.length)}else{n.innerHTML=s===a.lastChild?`${this.VOID_KEY}<br>`:this.VOID_KEY,n.setAttribute("data-set-empty","true");const t=n.childNodes[0];this.restCursorPos(t,1)}return!0}if(0===t.focusOffset){const t=n.parentNode,e=null==t?void 0:t.previousSibling;return!(!e||e.getAttribute("data-set-richType")!==RICH_TAG)&&(e.children[0].classList.contains("at-input")&&e.children[0].children[0].textContent!==this.VOID_KEY?(this.rangeToInputTag(e.children[0]),!0):(this.delTag(e),!0))}}delTag(t){const e=t.previousSibling,i=t.nextSibling;t.parentNode.removeChild(t),this.markMerge(e,i)}gridMerge(t,e,i=!0){t.lastChild.getAttribute("data-set-richType")!==RICH_MARK&&t.appendChild(this.getGridElm(!0)),e.childNodes[0].getAttribute("data-set-richType")!==RICH_MARK&&e.insertBefore(this.getGridElm(!0),e.childNodes[0]);const n=t.lastChild.childNodes[0],s=n.childNodes[0];let a=s.textContent.length;Array.from(e.childNodes,e=>{t.appendChild(e.cloneNode(!0))}),e.childNodes.length>1&&n.childNodes[1]&&n.removeChild(n.childNodes[1]);const l=n.parentNode.nextSibling;if(l){const e=l.children[0].childNodes[0];e&&e.textContent!==this.VOID_KEY&&(n.childNodes[1]&&n.removeChild(n.childNodes[1]),s.textContent=(s.textContent+e.textContent).replace(new RegExp(this.VOID_KEY,"g"),()=>(a--,"")),s.parentElement.setAttribute("data-set-empty","false")),t.removeChild(l)}""===s.textContent&&(s.textContent=this.VOID_KEY,s.parentNode.setAttribute("data-set-empty","true"),a=1),this.richText.removeChild(e),i&&this.restCursorPos(s,a)}markMerge(t,e){const i=t.children[0].childNodes[0];let n=i.textContent.length;if(e){const t=e.children[0].childNodes[0];t&&t.textContent!==this.VOID_KEY&&(i.textContent=(i.textContent+t.textContent).replace(new RegExp(this.VOID_KEY,"g"),()=>(n--,"")),i.parentElement.setAttribute("data-set-empty","false")),e.parentNode.removeChild(e)}""===i.textContent&&(i.textContent=this.VOID_KEY,i.parentNode.setAttribute("data-set-empty","true"),n=1);const s=t.parentNode;i.textContent===this.VOID_KEY&&t===s.lastChild&&(i.parentNode.appendChild(document.createElement("br")),i.parentNode.setAttribute("data-set-empty","true"),n=1),this.restCursorPos(i,n)}setCallSpace(t){this.needCallSpace=t}getWrapNode(t,e=!1){if(t.nodeType===Node.TEXT_NODE)return t.parentNode.parentNode.parentNode;const i=t.getAttribute("data-set-richType");if(e&&i===RICH_TAG)return t.parentNode;switch(i){case RICH_INPUT:return t.parentNode.parentNode;case RICH_MARK:return t.parentNode;case RICH_GRID:return t}}getMarkNode(t,e=!1){if(t.nodeType===Node.TEXT_NODE)return t.parentNode?t.parentNode.parentNode:null;const i=t.getAttribute("data-set-richType");if(e&&i===RICH_TAG)return t;switch(i){case RICH_INPUT:return t.parentNode;case RICH_MARK:return t}}getRichTextNodeIndex(t){const e=this.getMarkNode(t),i=e?e.parentNode:null;return e&&i?{gridIndex:Array.prototype.indexOf.call(this.richText.childNodes,i),markIndex:Array.prototype.indexOf.call(i.childNodes,e)}:{gridIndex:null,markIndex:null}}setWrapNodeByMark(t){const e=document.createElement("p");return e.className="chat-grid-wrap",e.setAttribute("data-set-richType",RICH_GRID),Array.from(t,t=>{e.appendChild(t)}),e}setRangeLastText(){const t=this.richText.childNodes[this.richText.childNodes.length-1],e=t.childNodes[t.childNodes.length-1].children[0].childNodes[0];this.restCursorPos(e,e.textContent===this.VOID_KEY?1:e.textContent.length),this.viewIntoPoint()}viewIntoPoint(){let t,e;const i=window.getSelection(),{focusNode:n,focusOffset:s}=i;if(n&&n.parentElement&&n.parentElement.classList.contains("input-write"))t=n.parentElement.parentElement,e=s;else{if(!this.vnode)return;t=this.getMarkNode(this.vnode),e=this.cursorIndex}if(!t)return;const a=t.getBoundingClientRect(),l=Math.ceil(a.height/this.NODE_HEIGHT),o=Math.floor(t.textContent.length/l)||1,r=(Math.floor(e/o)||1)*this.NODE_HEIGHT,c=a.top+(r-this.NODE_HEIGHT),h=this.richText.parentElement,d=h.getBoundingClientRect(),p=d.top,g=d.top+d.height;if(c<p+this.NODE_PADDING_DIFF){const t=p-c;h.scrollTo(0,h.scrollTop-t)}else if(c>g-this.NODE_HEIGHT){const t=c-g+this.NODE_HEIGHT;h.scrollTo(0,h.scrollTop+t)}}insetRangeGrid(t,e=0){const i=this.vnode.textContent,n=i.slice(0,this.cursorIndex-e);0===n.length?(this.vnode.parentElement.setAttribute("data-set-empty","true"),this.vnode.textContent=this.VOID_KEY):this.vnode.textContent=n;let s=i.slice(this.cursorIndex);const a=[],l=document.createDocumentFragment();Array.from(t.children).forEach((t,e)=>{a.push(t),0!==e&&l.appendChild(t)});const o=a[a.length-1].children[0];s&&s.length>0&&s!==this.VOID_KEY?(o.setAttribute("data-set-empty","false"),o.textContent=o.textContent+s):o.setAttribute("data-set-empty","true");const r=this.getMarkNode(this.vnode),c=r.parentElement,h=r.children[0],d=a[0].textContent;d&&d.length>0&&d!==this.VOID_KEY&&(h.setAttribute("data-set-empty","false"),h.textContent=(h.textContent+d).replace(new RegExp(this.VOID_KEY,"g"),"")),h.childNodes[1]&&h.removeChild(h.childNodes[1]),r.nextElementSibling?(o.childNodes[1]&&o.removeChild(o.childNodes[1]),c.insertBefore(l,r.nextElementSibling)):c.appendChild(l);const p=s&&s!==this.VOID_KEY?s.length:0;if(a.length>1){const t=o.childNodes[0];this.restCursorPos(t,t.textContent===this.VOID_KEY?1:t.textContent.length-p)}else{const t=h.childNodes[0];this.restCursorPos(t,t.textContent===this.VOID_KEY?1:t.textContent.length-p)}}insetRangeGrids(t){const e=document.createDocumentFragment();Array.from(t).forEach(t=>{e.appendChild(t)});const i=this.getWrapNode(this.vnode);this.restCursorPos(this.vnode,this.cursorIndex),this.setWrap(!1);const n=i.nextElementSibling;n&&this.richText.insertBefore(e,n);n&&n.previousElementSibling?(this.gridMerge(i,i.nextElementSibling,!1),this.gridMerge(n.previousElementSibling,n,!0)):this.gridMerge(i,i.nextElementSibling,!0)}getOffsetRange(t,e,i=!1){const n=e.children[0].childNodes[0],s=n.textContent;if(0===t)return{rangeNode:n,rangeIndex:i?s.length:s===this.VOID_KEY?1:0};if(s!==this.VOID_KEY&&s.length>=t)return{rangeNode:n,rangeIndex:i?s.length-t:t};let a,l;if(i?(a=Boolean(e.previousElementSibling&&e.previousElementSibling.previousElementSibling),l=Boolean(e.parentElement.previousElementSibling)):(a=Boolean(e.nextElementSibling&&e.nextElementSibling.nextElementSibling),l=Boolean(e.parentElement.nextElementSibling)),!a&&!l)return{rangeNode:n,rangeIndex:i?s.length===this.VOID_KEY?1:0:s.length===this.VOID_KEY?1:s.length};const o=t-s.length,r=i?a?e.previousElementSibling.previousElementSibling:e.parentElement.previousElementSibling.lastElementChild:a?e.nextElementSibling.nextElementSibling:e.parentElement.nextElementSibling.children[0];return this.getOffsetRange(o,r,i)}rangeToInputTag(t){const e=t.children[0].childNodes[0];this.setInputTagRange(e,e.textContent===this.VOID_KEY?1:e.textContent.length)}watchInputTag(t){if(0===t.childNodes.length||0===t.textContent.length)t.textContent=this.VOID_KEY,this.rangeToInputTag(t.parentElement);else{const e=t.childNodes[0];this.target.nextTick(()=>{if(!this.target.chatEvent.isComposition){const i=window.getSelection().focusOffset,n=t.textContent===this.VOID_KEY||-1===t.textContent.indexOf(this.VOID_KEY)?0:1;let s=!1;1===n&&(e.textContent=e.textContent.replace(this.VOID_KEY,""),s=!0),-1!==t.textContent.indexOf(this.INPUT_TAG_WRAP_KEY[1])&&(t.textContent=t.textContent.replace(new RegExp(this.INPUT_TAG_WRAP_KEY[0],"g"),"").replace(new RegExp(this.INPUT_TAG_WRAP_KEY[1],"g"),this.INPUT_TAG_WRAP_KEY),s=!0),s&&this.setInputTagRange(t.childNodes[0],i-n)}})}domItVisible(t.nextElementSibling,t.textContent===this.VOID_KEY,"inline")}backRuleInputTag(t){if(t.textContent===this.VOID_KEY)return this.delTag(t.parentElement.parentElement),!0;const e=window.getSelection();if(0===e.focusOffset&&e.isCollapsed){const e=t.parentElement.parentElement.previousElementSibling.children[0].childNodes[0];return this.restCursorPos(e,e.textContent===this.VOID_KEY?1:e.textContent.length),!0}if(-1!==e.focusNode.textContent.indexOf(this.INPUT_TAG_WRAP_KEY[1])){const t=this.getDiffInputTagOffset(e.focusNode,e.focusOffset,"left");if(t>0){const i=e.focusNode.textContent.slice(0,e.focusOffset-1-t),n=e.focusNode.textContent.slice(e.focusOffset);return e.focusNode.textContent=i+n,e.focusNode.textContent?this.setInputTagRange(e.focusNode,i.length):(e.focusNode.textContent=this.VOID_KEY,this.watchInputTag(e.focusNode.parentElement),this.setInputTagRange(e.focusNode,1)),!0}}return!1}mergeRuleInputTag(t){this.target.nextTick(()=>{t.childNodes.length>1&&(t.removeChild(t.childNodes[1]),this.watchInputTag(t))})}inputTagSwitchRange(t){const{focusNode:e,focusOffset:i}=window.getSelection(),n=e.textContent.length,s=e.parentElement.parentElement.parentElement;let a,l,o,r=!1;switch(t){case"ArrowLeft":i>0&&e.textContent!==this.VOID_KEY?(o=this.getDiffInputTagOffset(e,i,"left"),l=i-1-o,a=e):(a=s.previousElementSibling.children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:a.textContent.length,r=!0);break;case"ArrowRight":i<n&&e.textContent!==this.VOID_KEY?(o=this.getDiffInputTagOffset(e,i,"right"),l=i+1+o,a=e):(a=s.nextElementSibling.children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0,r=!0)}r?this.restCursorPos(a,l):this.setInputTagRange(a,l)}setInputTagRange(t,e){const i=new Range;i.setStart(t,e),i.setEnd(t,e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(i))}pasteInputTag(t){t=t.replace(new RegExp(this.INPUT_TAG_WRAP_KEY[0],"g"),"").replace(new RegExp(this.INPUT_TAG_WRAP_KEY[1],"g"),this.INPUT_TAG_WRAP_KEY);const e=window.getSelection(),{focusNode:i,focusOffset:n,anchorOffset:s}=e;let a="",l="";e.isCollapsed?(a=i.textContent.slice(0,n)||"",l=i.textContent.slice(n)||""):(a=i.textContent.slice(0,s<n?s:n)||"",l=i.textContent.slice(n>s?n:s)||""),i.textContent=a+t+l,this.setInputTagRange(i,(s<n?s:n)+t.length);const o=i.parentElement;this.watchInputTag(o)}setInputTagWrap(t){const e=window.getSelection(),{focusOffset:i}=e,n=t.textContent,s=n.slice(0,i),a=n.slice(i);t.textContent=s+this.INPUT_TAG_WRAP_KEY+a,this.setInputTagRange(t.childNodes[0],i+this.INPUT_TAG_WRAP_KEY.length),this.watchInputTag(t)}getDiffInputTagOffset(t,e,i){const n="left"===i?t.textContent[e-1]:t.textContent[e];if(-1===this.INPUT_TAG_WRAP_KEY.indexOf(n))return 0;switch(i){case"left":return t.textContent[e-2]===this.INPUT_TAG_WRAP_KEY[1]?2:t.textContent[e-2]===this.INPUT_TAG_WRAP_KEY[0]?3:1;case"right":return t.textContent[e+1]===this.INPUT_TAG_WRAP_KEY[1]?2:t.textContent[e+1]===this.INPUT_TAG_WRAP_KEY[0]?3:1}}}const DEFAULT_OPTIONS={device:"auto",autoFocus:!0,needDialog:!0,needDebounce:!0,asyncMatch:!1,userList:[],reformList:[],placeholder:"",maxLength:-1,copyType:["text"],uploadImage:void 0,needCallEvery:!0,needCallSpace:!1,userProps:{},customTrigger:[],dialogLabels:{pcPointDialog:{},pcPCheckDialog:{},h5Dialog:{}},wrapKeyFun:t=>t.ctrlKey&&["Enter"].includes(t.key),sendKeyFun:t=>!t.ctrlKey&&["Enter"].includes(t.key)},DEFAULT_USER_PROPS={id:"id",name:"name",avatar:"avatar",pinyin:"pinyin"},DEFAULT_PC_POINT_DIALOG={title:"群成员",callEveryLabel:"所有人",checkLabel:"多选",emptyLabel:"暂无数据"},DEFAULT_PC_CHECK_DIALOG={title:"选择要@的人",searchPlaceholder:"搜素人员名称",searchEmptyLabel:"没有匹配到任何结果",userTagTitle:"研讨成员列表",checkAllLabel:"全选",checkEmptyLabel:"请选择需要@的成员",confirmLabel:"确定",cancelLabel:"取消"},DEFAULT_H5_DIALOG={title:"选择提醒的人",callEveryLabel:"所有人",searchPlaceholder:"搜素人员名称",searchEmptyLabel:"没有匹配到任何结果",confirmLabel:"确定",cancelLabel:"收起"},DEFAULT_REDUCE_CONFIG={saveTagData:!1,needUserId:!1,needTagId:!1,needSelectId:!1,wrapClassName:void 0,rowClassName:void 0,imgToText:!1,identifyLink:!1},NotMergeKey=["Backspace","Shift","Tab","CapsLock","Control","Meta","Alt","ContextMenu","Enter","NumpadEnter","Escape","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Home","End","PageUp","PageDown","Insert","Delete","NumLock"],KEY_CODE_MAP={"`":192,"~":192,1:49,"!":49,3:51,"#":51,4:52,$:52,5:53,"%":53,6:54,"^":54,7:55,"&":55,8:56,"*":56,";":186,":":186,"/":191,"?":191,"\\":200,"|":200};class ChatEvent{constructor(t){__publicField(this,"target"),__publicField(this,"outerApply",!1),__publicField(this,"isComposition",!1),__publicField(this,"matchKey",0),__publicField(this,"startOpenIndex",0),__publicField(this,"textLength",0),__publicField(this,"isIMEModel",!1),__publicField(this,"takeIMEModel",!1),__publicField(this,"undoHistory",[]),__publicField(this,"redoHistory",[]),__publicField(this,"doOverHistory",!0),__publicField(this,"notMergeKey",NotMergeKey),__publicField(this,"chatEventModule",{enterSend:[],operate:[],defaultAction:[],atMatch:[],atCheck:[],tagCheck:[],selectCheck:[],tipTagState:[],afterAtCheck:[],afterTagCheck:[],afterSelectCheck:[],showAtDialog:[],showTagDialog:[],showSelectDialog:[],elementClicked:[]}),__publicField(this,"debounceEvents",{recordHistory:()=>{},dialogMoveToRange:t=>{},selectDialogToAim:()=>{},matchPointDialog:()=>{},movePointActiveUserElm:t=>{},moveCustomActiveTagElm:t=>{}}),this.target=t,this.registerEvent(),this.otherEvent()}registerEvent(){const{chatElement:t,options:e,deviceInfo:i,chatInput:n}=this.target;t.richText.addEventListener("keyup",s=>{if(!s.target.classList.contains("input-write"))if(s.stopPropagation(),i.isPc)if(50===+s.keyCode&&n.keyUpAsKey("@"))this.triggerChatEvent("showAtDialog"),e.needDialog&&t.ruleShowPointDialog();else{e.customTrigger.filter(t=>t.keyCode===s.keyCode).map(t=>t.prefix).forEach(i=>{n.keyUpAsKey(i)&&(this.triggerChatEvent("showTagDialog",i),e.needDialog&&t.showCustomTagDialog(i))})}else if((e.reformList.length>0||e.asyncMatch)&&n.keyUpAsKey("@"))this.triggerChatEvent("showAtDialog"),e.needDialog&&this.target.showH5Dialog(),t.isExternalCallPopup=!1;else{const t=e.customTrigger.map(t=>t.prefix),i=t.indexOf(s.key);-1!==i&&n.keyUpAsKey(t[i])&&this.triggerChatEvent("showTagDialog",s.key)}}),t.richText.addEventListener("keydown",s=>{const a=s.target.classList.contains("input-write");if(!i.isPc&&"Unidentified"===s.key&&229===s.keyCode)return a&&n.mergeRuleInputTag(s.target),void(this.isIMEModel=!0);if(!this.isIMEModel)if(hasElmShow(t.pcElms.pointDialogElm))["ArrowUp","ArrowDown","Enter","NumpadEnter"].includes(s.code)?s.preventDefault():["ArrowLeft","ArrowRight"].includes(s.code)&&t.exitPointDialog();else if(t.pcElms.customTagDialogTagKey&&hasElmShow(t.pcElms.customTagDialogElms[t.pcElms.customTagDialogTagKey]))["ArrowUp","ArrowDown","Enter","NumpadEnter"].includes(s.code)?s.preventDefault():["ArrowLeft","ArrowRight"].includes(s.code)&&t.exitCustomTagDialog();else if(this.isComposition||"Backspace"!==s.code&&"Backspace"!==s.key?e.wrapKeyFun(s)||!i.isPc&&"Enter"===s.key?(s.preventDefault(),this.isComposition||(a?n.setInputTagWrap(s.target):n.setWrap(),this.richTextInput())):e.sendKeyFun(s)?(s.preventDefault(),this.isComposition||this.triggerChatEvent("enterSend")):["ArrowLeft","ArrowRight"].includes(s.code)?(s.preventDefault(),this.isComposition||(a?n.inputTagSwitchRange(s.code):n.switchRange(s.code))):(s.ctrlKey||s.metaKey)&&"KeyA"===s.code?(s.preventDefault(),this.isComposition||this.target.isEmpty()||n.selectAll()):(s.ctrlKey||s.metaKey)&&"KeyZ"===s.code?(s.preventDefault(),this.isComposition||this.ruleChatEvent(()=>{this.target.undo()},"defaultAction","UNDO")):(s.ctrlKey||s.metaKey)&&"KeyY"===s.code&&(s.preventDefault(),this.isComposition||this.ruleChatEvent(()=>{this.target.redo()},"defaultAction","REDO")):a&&n.backRuleInputTag(s.target)||n.selectRegionMerge()||n.gridElmMerge()||n.delMarkRule()?(s.preventDefault(),this.richTextInput()):t.tipElm&&this.target.isEmpty()&&t.removeTipElm(),!s.ctrlKey&&!s.altKey&&!s.metaKey){const t=-1===this.notMergeKey.indexOf(s.key);a?(t||"Backspace"===s.code||"Backspace"===s.key)&&n.mergeRuleInputTag(s.target):t&&n.selectRegionMerge()}}),t.richText.addEventListener("beforeinput",e=>{const i=e.target.classList.contains("input-write");if(this.isIMEModel){if("insertParagraph"===e.inputType)return e.preventDefault(),i?n.setInputTagWrap(e.target):n.setWrap(),void this.richTextInput();if("deleteContentBackward"===e.inputType){this.takeIMEModel=!0,e.preventDefault();const s=t.richText.innerHTML,a=window.getSelection(),l=a.focusNode,o=a.focusOffset,r=i?l.parentElement.parentElement.parentElement:l.parentElement.parentElement,c=r.parentElement,h=Array.prototype.indexOf.call(t.richText.children,c),d=Array.prototype.indexOf.call(c.children,r);this.target.nextTick(()=>{t.richText.innerHTML=s;const e=t.richText.children[h].children[d],a=i?e.children[0].children[0].childNodes[0]:e.children[0].childNodes[0];i?(n.setInputTagRange(a,o),n.backRuleInputTag(a.parentElement)||(a.textContent=a.textContent.slice(0,o-1)+a.textContent.slice(o),n.setInputTagRange(a,o-1)),n.watchInputTag(a.parentElement)):(n.restCursorPos(a,o),n.selectRegionMerge()||n.gridElmMerge()||n.delMarkRule()||(a.textContent=a.textContent.slice(0,o-1)+a.textContent.slice(o),n.restCursorPos(a,o-1))),this.target.nextTick(async()=>{await this.richTextInput(),this.takeIMEModel=!1,this.isIMEModel=!1})})}}}),t.richText.addEventListener("input",async s=>{const a=s.target.classList.contains("input-write");if(this.isIMEModel){if(this.takeIMEModel)return;await this.target.nextTick(()=>{a&&n.watchInputTag(s.target),-1!==e.maxLength&&this.ruleMaxLength(),t.showPlaceholder(),this.triggerChatEvent("operate"),this.isIMEModel=!1})}else{if(a)return n.watchInputTag(s.target),void await this.richTextInput();await this.richTextInput(),i.isPc&&!this.isComposition&&this.debounceEvents.matchPointDialog()}}),t.richText.addEventListener("copy",t=>{t.preventDefault(),this.ruleChatEvent(()=>{this.copyRange(t)},"defaultAction","COPY")}),t.richText.addEventListener("cut",t=>{t.preventDefault(),this.ruleChatEvent(()=>{this.copyRange(t),this.removeRange(),t.target.classList.contains("input-write")&&this.target.chatInput.watchInputTag(t.target)},"defaultAction","CUT")}),t.richText.addEventListener("paste",t=>{t.preventDefault();const{options:e,chatInput:i}=this.target;this.ruleChatEvent(()=>{const n=t.clipboardData.getData("text/plain");if("string"==typeof n&&""!==n){if(-1===e.copyType.indexOf("text"))return;if(t.target.classList.contains("input-write"))return i.pasteInputTag(n),void this.richTextInput();let s=document.createElement("div");s.innerHTML=t.clipboardData.getData("application/my-custom-format")||"",i.selectRegionMerge(),s.children[0]&&s.children[0].getAttribute("data-set-richType")===RICH_GRID?this.insertInsideHtml(s.innerHTML):(s.innerHTML=n,this.target.insertText(s.innerText)),s=null}else{if(-1===e.copyType.indexOf("image"))return;const i=(t.clipboardData||t.originalEvent.clipboardData).items||[];Array.from(i,async t=>{if(-1===t.type.indexOf("image"))return;const i=t.getAsFile();if(e.uploadImage){const t=await e.uploadImage(i);this.target.insertHtml(`<img class="chat-img" src="${t}" alt="" />`)}else{const t=new FileReader;t.onload=t=>{this.target.insertHtml(`<img class="chat-img" src="${t.target.result}" alt="" />`)},t.readAsDataURL(i)}})}},"defaultAction","PASTE")}),t.richText.addEventListener("blur",()=>{n.upDataNodeOrIndex()}),t.richText.addEventListener("focus",()=>{n.upDataNodeOrIndex()}),t.richText.addEventListener("click",t=>{n.upDataNodeOrIndex();const i=upFindElm(t.target,5);if(i){const t=i.children[0];if(t.classList.contains("chat-grid-input"))return void this.triggerChatEvent("elementClicked","gridInput",t);if(t.classList.contains("at-input"))return t.children[0].textContent===n.VOID_KEY&&n.rangeToInputTag(t),void this.triggerChatEvent("elementClicked","inputTag",t);if(t.classList.contains("at-select")){const i=t.getAttribute("data-select-key");return this.triggerChatEvent("showSelectDialog",i,t),e.needDialog&&this.target.showPCSelectDialog(i,t),void this.triggerChatEvent("elementClicked","selectTag",t)}if(t.classList.contains("at-user"))return void this.triggerChatEvent("elementClicked","userTag",t);if(t.classList.contains("at-tag"))return void this.triggerChatEvent("elementClicked","customTag",t);if(t.classList.contains("chat-set-html"))return void this.triggerChatEvent("elementClicked","htmlTag",t.children[0])}}),t.richText.addEventListener("dragstart",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("drop",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("compositionstart",()=>{this.isComposition=!0}),t.richText.addEventListener("compositionend",()=>{this.isComposition=!1}),window.addEventListener("click",this.winClick.bind(this)),window.addEventListener("keydown",this.winKeydown.bind(this))}otherEvent(){const{options:t,chatInput:e,chatElement:i}=this.target,{needDebounce:n}=t,s=()=>{const{gridIndex:t,markIndex:n}=e.getRichTextNodeIndex(e.vnode);if(null===t||null==n)return;const s={html:i.richText.innerHTML,gridIndex:t,markIndex:n,cursorIndex:e.cursorIndex};this.undoHistory.push(s),this.undoHistory.length>50&&this.undoHistory.shift()};this.debounceEvents.recordHistory=n?debounce(s,200):s;const a=t=>{let n="0",s="100%";const a=e.getRangeRect();if(!a)return;const l=i.pcElms.containerDialogElm.getBoundingClientRect();let o=a.x-l.x,r=l.y-a.y;const{clientWidth:c,clientHeight:h}=t;a.x>window.innerWidth-c-30&&(o=a.x-c-l.x-16,n="100%"),a.y<h&&(r-=h,s="0"),t.style.transform="translate(0, 0)",t.style.transformOrigin=`${n} ${s}`,t.style.left=o+6+"px",t.style.bottom=`${r}px`,t.style.opacity="1"};this.debounceEvents.dialogMoveToRange=n?debounce(a,120,!0):a;const l=()=>{if(!t.needDialog)return;const n=e.vnode.textContent||"",s=e.cursorIndex,a=n.slice(0,s);let l=-1,o=-1,r="userTag";if(-1!==a.lastIndexOf("@")&&(l=a.lastIndexOf("@")),i.pcElms.customTagDialogTagKey&&-1!==a.lastIndexOf(i.pcElms.customTagDialogTagKey)&&(o=a.lastIndexOf(i.pcElms.customTagDialogTagKey)),o>l&&(r="customTag"),"userTag"===r&&t.asyncMatch){if(l<0)return void i.exitPointDialog();this.matchKey++;const t=this.matchKey;this.startOpenIndex=l+1;const e=a.slice(this.startOpenIndex)||"";if(/\s/gi.test(e))return void i.exitPointDialog();this.target.updateUserList([]),domItVisible(i.pcElms.pointDialogLoadingElm,!0,"flex"),domItVisible(i.pcElms.pointDialogEmptyElm),i.showPointDialog();const n=this.triggerChatEvent("atMatch",e).find(t=>t&&t instanceof Promise);return void(n&&n.then(e=>{t===this.matchKey&&(domItVisible(i.pcElms.pointDialogLoadingElm),!e||e.length<=0?domItVisible(i.pcElms.pointDialogEmptyElm,!0,"flex"):(this.target.updateUserList(e),i.pcElms.pointDialogUsersElm&&i.pcElms.pointDialogUsersElm.length>0&&i.updatePointActiveUserElm(i.pcElms.pointDialogUsersElm[0].elm)))}))}if("userTag"===r&&t.reformList.length<=0)return void i.exitCustomTagDialog();if("customTag"===r&&i.customTags[i.pcElms.customTagDialogTagKey].length<=0)return;const c=()=>{"userTag"===r?i.exitPointDialog():i.exitCustomTagDialog()};if(l<0&&o<0)return i.exitPointDialog(),void i.exitCustomTagDialog();this.startOpenIndex="userTag"===r?l+1:o+1;const h=new RegExp(`^([${e.ZERO_WIDTH_KEY}${e.VOID_KEY}])+$`);if(!a||h.test(a)||s<this.startOpenIndex)return void c();const d=a.slice(this.startOpenIndex)||"";if(/\s/gi.test(d))c();else if(d)if("userTag"===r){const t=this.target.searchUserList(d);t.length>0?i.showPointDialog(t):c()}else{const t=i.customTags[i.pcElms.customTagDialogTagKey].filter(t=>pinyinMatch(t.name,t.pinyin||"",d));t.length>0?i.showCustomTagDialog(i.pcElms.customTagDialogTagKey,t):c()}else"userTag"===r?i.showPointDialog():i.showCustomTagDialog(i.pcElms.customTagDialogTagKey)};this.debounceEvents.matchPointDialog=n?debounce(l,200):l;this.debounceEvents.movePointActiveUserElm=throttle(t=>{if(!i.pcElms.pointDialogActiveElm)return;let e=0;const n=i.pcElms.pointDialogActiveElm.getAttribute("data-set-id");i.pcElms.pointDialogUsersElm.some(t=>{const i=t.elm.getAttribute("data-set-id");return e=t.index,n===i});const s=i.pcElms.pointDialogUsersElm.filter(t=>!t.elm.classList.contains("user-no-match")),a=s.map(t=>t.index);let l;"down"===t?l=e===s[s.length-1].index?s[0]:s[a.indexOf(e)+1]:"up"===t&&(l=e===s[0].index?s[s.length-1]:s[a.indexOf(e)-1]),l&&i.updatePointActiveUserElm(l.elm,!0)},80);this.debounceEvents.moveCustomActiveTagElm=throttle(t=>{if(!i.pcElms.customTagDialogActiveElm)return;const e=i.customTags[i.pcElms.customTagDialogTagKey].map(t=>t.id),n=i.pcElms.customTagDialogActiveElm.getAttribute("data-set-id"),s=e.indexOf(n),a=Array.from(i.pcElms.customTagDialogElms[i.pcElms.customTagDialogTagKey].children[1].children,(t,e)=>({elm:t,index:e})).filter(t=>!t.elm.classList.contains("tag-no-match")),l=a.map(t=>t.index);let o;"down"===t?o=s===a[a.length-1].index?a[0]:a[l.indexOf(s)+1]:"up"===t&&(o=s===a[0].index?a[a.length-1]:a[l.indexOf(s)-1]),o&&i.updateActiveCustomTagElm(o.elm,!0)},80);const o=()=>{const t=i.pcElms.selectDialogAim.getClientRects()[0],e=i.pcElms.selectDialogElms[i.pcElms.selectDialogKey];domItVisible(e,!0);const n=e.querySelector(".chat-select-arrow");let s=e.clientHeight+16;if(s>t.y?(s=-(t.height+16),n.style.top="-16px",n.style.bottom="auto",n.style.transform="rotate(0deg)"):(n.style.transform="rotate(180deg)",n.style.bottom="-16px",n.style.top="auto"),window.innerWidth-t.x<e.clientWidth){const i=e.clientWidth-(window.innerWidth-t.x)-10;e.style.left="auto",e.style.right="10px",n.style.left="auto",n.style.right=i-n.clientWidth/2+t.width/2+"px"}else e.style.left=t.x+"px",e.style.right="auto",n.style.left=t.width/2-n.clientWidth/2+"px",n.style.right="auto";e.style.top=t.y+"px",e.style.transform=`translateY(${-s}px)`;const a=e.querySelector(".chat-select-dialog-main"),l=e.querySelectorAll(".chat-select-dialog-item");let o=0,r=!1,c=0;if(i.pcElms.selectDialogAim.classList.contains("at-select")){const t=i.pcElms.selectDialogAim.getAttribute("data-select-id");updateElmClass(i.pcElms.selectDialogAim,"aim",!0),Array.from(l,e=>{const i=e.lastChild.lastChild,n=t===e.getAttribute("data-set-id");n&&(c=e.clientHeight,r=!0),n||r||(o+=e.clientHeight),domItVisible(i,n,"inline-block")});const e=o-a.clientHeight/2+c/2;a.scrollTop=e>0?e:0}else Array.from(l,t=>{domItVisible(t.lastChild.lastChild,!1,"inline-block")})};this.debounceEvents.selectDialogToAim=n?debounce(o,120):o;const r={html:i.richText.innerHTML,gridIndex:0,markIndex:0,cursorIndex:e.cursorIndex};this.undoHistory=[r]}winClick(){if(!this.target||this.outerApply)return;const{chatElement:t}=this.target;hasElmShow(t.pcElms.pointDialogElm)&&t.exitPointDialog(),t.pcElms.checkDialogSearchResultElm&&domItVisible(t.pcElms.checkDialogSearchResultElm),t.pcElms.customTagDialogTagKey&&hasElmShow(t.pcElms.customTagDialogElms[t.pcElms.customTagDialogTagKey])&&t.exitCustomTagDialog(),t.pcElms.selectDialogKey&&hasElmShow(t.pcElms.selectDialogElms[t.pcElms.selectDialogKey])&&t.exitSelectDialog()}async winKeydown(t){if(!this.target)return;const{chatElement:e,options:i}=this.target;if((t.ctrlKey||t.metaKey)&&"KeyZ"===t.code&&t.preventDefault(),!this.isComposition)if(hasElmShow(e.pcElms.pointDialogElm)){if("ArrowDown"===t.code)return t.preventDefault(),void this.debounceEvents.movePointActiveUserElm("down");if("ArrowUp"===t.code)return t.preventDefault(),void this.debounceEvents.movePointActiveUserElm("up");if(("Enter"===t.code||"NumpadEnter"===t.code)&&e.pcElms.pointDialogActiveElm){t.preventDefault();const n=e.pcElms.pointDialogActiveElm.getAttribute("data-set-id");if(await sleep(100),e.isPointSearchMode||i.asyncMatch)await this.target.matchSetTag(i.reformList.find(t=>t.id===n));else{const t=i.userList.find(t=>String(t[i.userProps.id])===n);await this.target.onceSetTag(t)}e.exitPointDialog()}}else if(e.pcElms.customTagDialogTagKey&&hasElmShow(e.pcElms.customTagDialogElms[e.pcElms.customTagDialogTagKey])){if("ArrowDown"===t.code)return t.preventDefault(),void this.debounceEvents.moveCustomActiveTagElm("down");if("ArrowUp"===t.code)return t.preventDefault(),void this.debounceEvents.moveCustomActiveTagElm("up");if(("Enter"===t.code||"NumpadEnter"===t.code)&&e.pcElms.customTagDialogActiveElm){t.preventDefault();const i=e.pcElms.customTagDialogActiveElm.getAttribute("data-set-id");await sleep(100);const n=e.customTags[e.pcElms.customTagDialogTagKey].find(t=>t.id===i);e.isPointSearchMode?await this.target.matchSetCustomTag(n):await this.target.onceSetCustomTag(n),e.exitCustomTagDialog()}}}async richTextInput(t=!0){const{chatInput:e,deviceInfo:i,chatElement:n,options:s}=this.target;return e.upDataNodeOrIndex(),i.isPc&&e.selectRegionMerge(),await this.target.nextTick(()=>{this.isComposition||e.updateGrid(),this.fixEditor()||(-1!==s.maxLength&&this.ruleMaxLength(),n.showPlaceholder(),this.triggerChatEvent("operate"),t&&this.doOverHistory&&!this.isComposition&&this.debounceEvents.recordHistory(),e.viewIntoPoint())}),!0}ruleMaxLength(){const{options:t,chatElement:e}=this.target;if(this.target.isEmpty()||-1===t.maxLength)return void(this.textLength=0);let i=0,n=0;const s=[];Array.prototype.some.call(e.richText.children,(e,a)=>{const{nodeInfos:l,nodeTextLength:o}=this.getGirdNodeTextInfo(e);if(i+=o,s.push(l),n=a,i>=t.maxLength)return!0});const a=[];Array.from(e.richText.children,(t,e)=>{e>n&&a.push(t)}),a.forEach(t=>e.richText.removeChild(t)),this.deepDelGirdText(s,i)}getGirdNodeTextInfo(t){const{chatInput:e}=this.target,i=[];let n=0;if(1===t.children.length&&t!==t.parentElement.children[0]){const s=t.children[0],a=(s.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=a.length||1,i[0]={node:s,textLength:a.length||1,type:RICH_MARK}}else Array.from(t.children,(t,s)=>{if(t.getAttribute("data-set-richType")===RICH_MARK){const a=(t.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=a.length,i[s]={node:t,textLength:a.length,type:RICH_MARK}}else{const a=(t.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=a.length||1,i[s]={node:t,textLength:a.length||1,type:RICH_TAG}}});return{nodeInfos:i,nodeTextLength:n}}deepDelGirdText(t,e){if(e>this.target.options.maxLength){const i=t[t.length-1];t.pop(),this.deepDelNode(i,t,e)}else this.textLength=e}deepDelNode(t,e,i){const n=t[0].node.parentElement;if(i>this.target.options.maxLength){let s=i-this.target.options.maxLength,a=t[t.length-1];if(a.type===RICH_MARK)if(0===a.textLength||s>=a.textLength)n.removeChild(a.node),t.pop(),s-=a.textLength,a=t[t.length-1],n.removeChild(a.node),t.pop(),s-=a.textLength;else{const t=a.node.childNodes[0];t.textContent=t.textContent.slice(0,a.textLength-s),0===t.textContent&&(t.setAttribute("data-set-empty","true"),t.innerHTML=`${this.target.chatInput.VOID_KEY}<br>`),s=0}else n.removeChild(a.node),t.pop(),s-=a.textLength;s>0?t.length>0?this.deepDelNode(t,e,s+this.target.options.maxLength):(this.target.chatElement.richText.appendChild(n),this.deepDelGirdText(e,s+this.target.options.maxLength)):(this.textLength=this.target.options.maxLength+s,this.target.chatInput.setRangeLastText())}}copyRange(t){const e=window.getSelection();if(e.isCollapsed||e.rangeCount<=0)return t.clipboardData.setData("application/my-custom-format",""),void t.clipboardData.setData("text/plain","");const{chatElement:i,chatInput:n}=this.target,s=e.toString()||"";let a=document.createElement("div");a.innerHTML=s;const l=a.innerText.replace(/\n\n/g,"\n");a=null,t.clipboardData.setData("text/plain",l);const o=e.anchorNode,r=e.focusNode;if(o===r&&o.nodeType===Node.TEXT_NODE)return void t.clipboardData.setData("application/my-custom-format",l);if(o===i.richText&&r===i.richText)return void t.clipboardData.setData("application/my-custom-format",i.richText.innerHTML);const c=n.getWrapNode(o,!0),h=n.getWrapNode(r,!0),d=n.getMarkNode(o,!0),p=n.getMarkNode(r,!0),g=d.getAttribute("data-set-richType")===RICH_MARK,m=p.getAttribute("data-set-richType")===RICH_MARK,u=Array.prototype.indexOf.call(c.childNodes,d),E=Array.prototype.indexOf.call(h.childNodes,p);if(c===h&&c.parentNode===i.richText){const i=u>E,s=Array.prototype.filter.call(c.childNodes,(t,e)=>i?e<u&&e>E:e>u&&e<E).map(t=>t.cloneNode(!0)),a=g?i?o.textContent.slice(0,e.anchorOffset):o.textContent.slice(e.anchorOffset):"",l=m?i?r.textContent.slice(e.focusOffset):r.textContent.slice(0,e.focusOffset):"",h=n.getGridElm(!0),d=n.getGridElm(!0);a&&(h.childNodes[0].innerHTML=a,h.childNodes[0].setAttribute("data-set-empty","false")),l&&(d.childNodes[0].innerHTML=l,d.childNodes[0].setAttribute("data-set-empty","false")),i?(s[0].getAttribute("data-set-richType")!==RICH_MARK&&s.unshift(d),s[s.length-1].getAttribute("data-set-richType")!==RICH_MARK&&s.push(h)):(s[0].getAttribute("data-set-richType")!==RICH_MARK&&s.unshift(h),s[s.length-1].getAttribute("data-set-richType")!==RICH_MARK&&s.push(d));let p=document.createElement("div");const C=n.setWrapNodeByMark(s);return p.appendChild(C),t.clipboardData.setData("application/my-custom-format",p.innerHTML),void(p=null)}if(c.parentNode===i.richText&&h.parentNode===i.richText){const s=Array.prototype.indexOf.call(i.richText.childNodes,c),a=Array.prototype.indexOf.call(i.richText.childNodes,h),l=s>a,d=Array.prototype.filter.call(i.richText.childNodes,(t,e)=>l?e<s&&e>a:e>s&&e<a).map(t=>t.cloneNode(!0)),p=g?l?o.textContent.slice(0,e.anchorOffset):o.textContent.slice(e.anchorOffset):"",C=m?l?r.textContent.slice(e.focusOffset):r.textContent.slice(0,e.focusOffset):"",f=n.getGridElm(!0),x=n.getGridElm(!0);p&&(f.childNodes[0].innerHTML=p,f.childNodes[0].setAttribute("data-set-empty","false")),C&&(x.childNodes[0].innerHTML=C,x.childNodes[0].setAttribute("data-set-empty","false"));const T=Array.prototype.filter.call(c.childNodes,(t,e)=>l?e<u:e>u).map(t=>t.cloneNode(!0)),y=Array.prototype.filter.call(h.childNodes,(t,e)=>l?e>E:e<E).map(t=>t.cloneNode(!0));if(l){T.push(f),y.unshift(x);const t=n.setWrapNodeByMark(T),e=n.setWrapNodeByMark(y);d.push(t),d.unshift(e)}else{T.unshift(f),y.push(x);const t=n.setWrapNodeByMark(T),e=n.setWrapNodeByMark(y);d.unshift(t),d.push(e)}let v=document.createElement("div");return Array.from(d,t=>{v.appendChild(t)}),t.clipboardData.setData("application/my-custom-format",v.innerHTML),void(v=null)}}removeRange(){const{chatInput:t,chatElement:e}=this.target;window.getSelection().getRangeAt(0).deleteContents(),this.target.nextTick(()=>{t.updateGrid(),e.showPlaceholder()})}async setChatHistory(t){const{chatElement:e,chatInput:i}=this.target;this.doOverHistory=!1;const{html:n,gridIndex:s,markIndex:a,cursorIndex:l}=t;e.richText.innerHTML=n;const o=e.richText.childNodes[s].childNodes[a].childNodes[0].childNodes[0];i.restCursorPos(o,l),await this.richTextInput(),this.doOverHistory=!0}async insertInsideHtml(t){const{chatInput:e}=this.target;let i=document.createElement("div");i.innerHTML=t,i.children.length&&(1===i.children.length?e.insetRangeGrid(i.children[0]):e.insetRangeGrids(i.children),i=null,await this.richTextInput())}triggerChatEvent(t,...e){const i=[];return this.chatEventModule[t].forEach(t=>{t&&i.push(t(...e))}),i}ruleChatEvent(t,e,...i){this.triggerChatEvent(e,...i).some(t=>t&&"PREVENT"===t)||(t&&t.bind(this)(),t=null)}fixEditor(){const t=(this.target.chatElement.richText.children[0]||{children:[]}).children[0];if(!t||!t.getAttribute||t.getAttribute("data-set-richType")!==RICH_MARK)return this.target.chatInput.initEditor(!0),this.target.chatElement.showPlaceholder(),this.triggerChatEvent("operate"),!0}}class ChatOperateNode{constructor(t){__publicField(this,"target"),__publicField(this,"rankLen",4),this.target=t}getCurrentNodes(){const t=[];return Array.from(this.target.chatElement.richText.children,(e,i)=>{t.push(this.analyzeGrid(e,i))}),t}getRank(t){let e=t+1+"";const i=this.rankLen-e.length;for(let t=0;t<i;t++)e="0"+e;return e}analyzeGrid(t,e){const i={type:"gridBox",rank:this.getRank(e),children:[]};return Array.from(t.children,(t,e)=>{switch(t.getAttribute("data-set-richType")){case RICH_MARK:i.children.push(this.analyzeMark(t,e,i.rank));break;case RICH_TAG:i.children.push(this.analyzeTag(t,e,i.rank))}}),i}analyzeMark(t,e,i){return{type:"gridInput",rank:i+this.getRank(e),text:t.textContent.replace(new RegExp(this.target.chatInput.VOID_KEY,"g"),"")}}analyzeTag(t,e,i){const n=t.children[0],s={type:"htmlTag",rank:i+this.getRank(e)};return n.classList.contains("at-user")?(s.type="userTag",s.dataset={[this.target.options.userProps.id]:n.getAttribute("data-user-id"),[this.target.options.userProps.name]:n.textContent.slice(1)}):n.classList.contains("at-tag")?(s.type="customTag",s.dataset={id:n.getAttribute("data-tag-id"),name:n.textContent.slice(1),prefix:n.getAttribute("data-set-prefix")}):n.classList.contains("at-select")?(s.type="selectTag",s.dataset={id:n.getAttribute("data-select-id"),name:n.textContent,key:n.getAttribute("data-select-key")}):n.classList.contains("at-input")?(s.type="inputTag",s.dataset={key:n.getAttribute("data-input-key"),placeholder:n.children[1].textContent,value:n.children[0].textContent===this.target.chatInput.VOID_KEY?"":n.children[0].textContent.replace(new RegExp(this.target.chatInput.INPUT_TAG_WRAP_KEY[0],"g"),"")}):(s.type="htmlTag",s.html=t.children[0].innerHTML),s}analyzeGridNodes(t){t.children=t.children||[];const e=t.children;if(0===e.length)return void e.push({type:"gridInput",rank:t.rank+this.getRank(0),text:""});const i=[];e.forEach((t,n)=>{if(n===e.length-1)return;const s=n+1;if("gridInput"===t.type&&"gridInput"===e[s].type){let t=s-i.length;i.push(t)}}),i.forEach(t=>{const i=e[t];e[t-1].text+=i.text,e.splice(t,1)});const n=[];e.forEach((t,i)=>{if(i===e.length-1)return;const s=i+1;if("gridInput"!==t.type&&"gridInput"!==e[s].type){let t=s+n.length;n.push(t)}}),n.forEach(t=>{e.splice(t,0,{type:"gridInput",rank:"",text:""})}),"gridInput"!==e[0].type&&e.unshift({type:"gridInput",rank:"",text:""}),"gridInput"!==e[e.length-1].type&&e.push({type:"gridInput",rank:"",text:""}),e.forEach((e,i)=>{e.rank=t.rank+this.getRank(i)})}analyzeNode(t,e=!1){switch(t.type){case"gridInput":return`<span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="${String(""===t.text)}">${""===t.text?this.target.chatInput.VOID_KEY:escapeHtml(t.text)}${e&&""===t.text?"<br>":""}</span></span>`;case"userTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-user" data-user-id="${t.dataset[this.target.options.userProps.id]}">@${t.dataset[this.target.options.userProps.name]}</span></span>`;case"customTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-tag" data-tag-id="${t.dataset.id}" data-set-prefix="${t.dataset.prefix}">${t.dataset.prefix}${t.dataset.name}</span></span>`;case"selectTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-select" data-select-id="${t.dataset.id}" data-select-key="${t.dataset.key}">${t.dataset.name}${arrowSvg}</span></span>`;case"htmlTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="chat-set-html">${t.html}</span></span>`;case"inputTag":const i=!Boolean(t.dataset.value),n=i?`<span class="input-tip">${t.dataset.placeholder}</span>`:`<span class="input-tip chat-view-show" style="display: none">${t.dataset.placeholder}</span>`;return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-input" contenteditable="false" data-input-key="${t.dataset.key}"><span class="input-write" contenteditable="true">${i?this.target.chatInput.VOID_KEY:t.dataset.value.replace(new RegExp(this.target.chatInput.INPUT_TAG_WRAP_KEY[1],"g"),this.target.chatInput.INPUT_TAG_WRAP_KEY)}</span>${n}</span></span>`;case"gridBox":let s="";return this.analyzeGridNodes(t),t.children.forEach((e,i)=>{s+=this.analyzeNode(e,i===t.children.length-1)}),`<p class="chat-grid-wrap" data-set-richType="${RICH_GRID}">${s}</p>`;default:return""}}async insertNode(t){if("gridBox"===t.type){const e=this.analyzeNode(t);let i=document.createElement("div");i.innerHTML=e;const n=i.children[0],s=parseFloat(t.rank)-1;if(-1===s||s>this.target.chatElement.richText.children.length-1)this.target.chatElement.richText.appendChild(n);else{const t=this.target.chatElement.richText.children[s];if(!t)return;this.target.chatElement.richText.insertBefore(n,t)}const a=n.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(a,a.textContent===this.target.chatInput.VOID_KEY?1:a.textContent.length),i=null,await this.target.chatEvent.richTextInput()}else{const e=(t.text||"").length,i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=this.getNodeByRank(i[0]);if(!n)return;const s=parseFloat(i[1])-1;-1==s?n.children.push(t):n.children.splice(s,0,t),await this.updateNode(n,()=>{if("gridInput"===t.type){const t=-1===s||s>n.children.length-1,i=!t&&s%2==0,a=t?n.children[n.children.length-1]:n.children[i?s:s-1];this.setCursorNode(a,i?e:-1)}else{const e=n.children.indexOf(t);this.setCursorNode(n.children[e+1],0)}})}}async updateNode(t,e){const i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=parseFloat(i[0])-1,s=this.target.chatElement.richText.children[n];if("gridBox"===t.type){if(!s)return;this.analyzeGridNodes(t);let i="";if(t.children.forEach((e,n)=>{i+=this.analyzeNode(e,n===t.children.length-1)}),s.innerHTML=i,e)e();else{const t=s.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:t.textContent.length)}return void await this.target.chatEvent.richTextInput()}const a=parseFloat(i[1])-1,l=s.children[a],o=this.getNodeByRank(t.rank);if(!o||t.type!==o.type)return;let r,c;if("gridInput"===t.type){const e=l.children[0];e.innerHTML=escapeHtml(t.text);const i=""!==e.textContent;e.setAttribute("data-set-empty",String(!i)),i||(e.innerHTML=l.nextElementSibling?this.target.chatInput.VOID_KEY:`${this.target.chatInput.VOID_KEY}<br>`),r=e.childNodes[0],c=r.textContent.length}else if("userTag"===t.type){const e=l.children[0];e.setAttribute("data-user-id",t.dataset[this.target.options.userProps.id]),e.textContent=`@${t.dataset[this.target.options.userProps.name]}`;r=l.nextElementSibling.children[0].childNodes[0]}else if("customTag"===t.type){const e=l.children[0];e.setAttribute("data-tag-id",t.dataset.id),e.setAttribute("data-set-prefix",t.dataset.prefix),e.textContent=`${t.dataset.prefix}${t.dataset.name}`;r=l.nextElementSibling.children[0].childNodes[0]}else if("selectTag"===t.type){const e=l.children[0];e.setAttribute("data-select-id",t.dataset.id),e.setAttribute("data-select-key",t.dataset.key),e.childNodes[0].textContent=t.dataset.name;r=l.nextElementSibling.children[0].childNodes[0]}else if("htmlTag"===t.type){l.children[0].innerHTML=t.html;r=l.nextElementSibling.children[0].childNodes[0]}e?e():this.target.chatInput.restCursorPos(r,c),await this.target.chatEvent.richTextInput()}getNodeByRank(t){if(!t)return null;const e=t.match(new RegExp(`.{1,${this.rankLen}}`,"g"));if(0===e.length)return null;const i=parseFloat(e[0])-1,n=-1===i?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[i];if(!n)return null;if(1===e.length)return this.analyzeGrid(n,-1===i?this.target.chatElement.richText.children.length-1:i);-1===i&&(e[0]=this.getRank(this.target.chatElement.richText.children.length-1));const s=parseFloat(e[1])-1,a=-1===s?n.lastElementChild:n.children[s];if(!a)return null;return a.getAttribute("data-set-richType")===RICH_MARK?this.analyzeMark(a,-1===s?n.children.length-1:s,e[0]):this.analyzeTag(a,-1===s?n.children.length-1:s,e[0])}async delNodeByRank(t){const e=this.getNodeByRank(t);if(e)if("gridBox"===e.type){const e=parseFloat(t)-1,i=this.target.chatElement.richText.children[e],n=i.nextElementSibling||i.previousElementSibling;if(n){const t=n.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:t.textContent.length)}this.target.chatElement.richText.removeChild(i),0===this.target.chatElement.richText.children.length&&this.target.chatInput.initEditor(!0),await this.target.chatEvent.richTextInput()}else if("gridInput"===e.type)e.text="",await this.updateNode(e);else{const i=e.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=this.getNodeByRank(i[0]),s=n.children[parseFloat(i[1])-1-1],a=s.text.length;n.children=n.children.filter(e=>e.rank!==t),await this.updateNode(n,()=>{this.setCursorNode(s,a)})}}async coverNodes(t){if(t.length<0)return;let e="";t.forEach(t=>{e+=this.analyzeNode(t)}),this.target.chatElement.richText.innerHTML=e,this.target.chatInput.setRangeLastText(),await this.target.chatEvent.richTextInput()}setCursorNode(t,e=-1){const i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=parseFloat(i[0])-1,s=-1===n?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[n];let a=null;if("gridInput"===t.type){const t=parseFloat(i[1])-1;a=-1===t?s.lastElementChild:s.children[t]}else if("gridBox"===t.type)a=-1===e?s.lastElementChild:s.children[0];else if("inputTag"===t.type){const t=parseFloat(i[1])-1,n=s.children[t].children[0].children[0].childNodes[0],a=n.textContent===this.target.chatInput.VOID_KEY?1:-1===e?n.textContent.length:e;this.target.chatInput.setInputTagRange(n,a)}else{const t=parseFloat(i[1])-1,n=s.children[t];a=-1===e?n.nextElementSibling:n.previousElementSibling,e=-1===e?0:-1}if(a){const t=a.children[0].childNodes[0];-1===e&&(e=t.textContent.length),this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:e)}}getCursorNode(){const t=window.getSelection(),e=t.focusNode;if(e&&e.parentElement&&e.parentElement.classList.contains("input-write")){const i=e.parentElement.parentElement.parentElement;return{node:this.analyzeTag(i,Array.prototype.indexOf.call(i.parentElement.children,i),this.getRank(Array.prototype.indexOf.call(this.target.chatElement.richText.children,i.parentElement))),offset:e.textContent===this.target.chatInput.VOID_KEY?0:t.focusOffset}}const i=this.target.chatInput.vnode.parentElement.parentElement;return{node:this.analyzeMark(i,Array.prototype.indexOf.call(i.parentElement.children,i),this.getRank(Array.prototype.indexOf.call(this.target.chatElement.richText.children,i.parentElement))),offset:this.target.chatInput.vnode.textContent===this.target.chatInput.VOID_KEY?0:this.target.chatInput.cursorIndex}}setSelectNodes(t,e,i=0,n=-1){let s,a;const l=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),o=e.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),r=this.target.chatElement.richText.children[parseFloat(l[0])-1],c=this.target.chatElement.richText.children[parseFloat(o[0])-1];if("gridInput"===t.type)s=r.children[parseFloat(l[1])-1];else if("gridBox"===t.type)s=-1===i?r.lastElementChild:r.children[0];else{const t=parseFloat(l[1])-1,e=r.children[t];s=-1===i?e.nextElementSibling:e.previousElementSibling,i=-1===i?0:-1}if("gridInput"===e.type)a=c.children[parseFloat(o[1])-1];else if("gridBox"===t.type)a=-1===n?c.lastElementChild:c.children[0];else{const t=parseFloat(o[1])-1,e=c.children[t];a=-1===n?e.nextElementSibling:e.previousElementSibling,n=-1===n?0:-1}const h=s.children[0].childNodes[0],d=a.children[0].childNodes[0],p=document.createRange(),g=parseFloat(t.rank)>parseFloat(e.rank);p[g?"setEnd":"setStart"](h,h.textContent===this.target.chatInput.VOID_KEY?1:-1===i?h.textContent.length:i),p[g?"setStart":"setEnd"](d,d.textContent===this.target.chatInput.VOID_KEY?1:-1===n?d.textContent.length:n);const m=window.getSelection();m.removeAllRanges(),m.addRange(p)}getElmByRank(t){const e=t.match(new RegExp(`.{1,${this.rankLen}}`,"g")),i=parseFloat(e[0])-1,n=-1===i?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[i];if(1===e.length)return n;const s=parseFloat(e[1])-1;return-1===s?n.lastElementChild:n.children[s]}getRankByElm(t){const e=this.target.chatElement.richText.children;let i=null,n=null;return Array.prototype.find.call(e,(e,s)=>t===e?(i=s,!0):Array.prototype.find.call(e.children,(e,a)=>e===t&&(i=s,n=a,!0))),(null!==i?this.getRank(i):"")+(null!==n?this.getRank(n):"")}}class ChatComponent{constructor(t){__publicField(this,"target"),__publicField(this,"components",{}),__publicField(this,"eventTypes",[]),this.target=t}useComponent(t){t.props=t.props||{},t.template=strictMinifyHtml(t.template||""),t.template=convertBlocksToSpans(t.template||"",t.props),this.components[t.name]=t;const e=/bind-([a-zA-Z]+)="([^"]*)"/g,i=[];let n;for(;null!==(n=e.exec(t.template));)i.push({eventType:n[1],handlerName:n[2]});i.forEach(t=>{this.useComponentEvent(t.eventType)})}useComponentEvent(t){if(this.eventTypes.includes(t))return;this.eventTypes.push(t);this.target.chatElement.richText.addEventListener(t,e=>{this.componentEventRecognizer(e,t)})}componentEventRecognizer(t,e){const i=t.target,n=upFindElm(i,20);if(!n||!n.classList.contains("chat-tag")||!n.children[0].classList.contains("chat-set-html"))return;const s=n.children[0].children[0],a=s.getAttribute("data-set-component");if(!a)return;const l=this.components[a];if(!l)return;const o=l.methods,r=this.deppComponentEvent(s,e).reverse();let c=!1,h=0;const d=()=>{if(c)return;const n=r[h];if(i===n||n.contains(i)){const i=n.getAttribute("bind-"+e),a=Object.create(null);for(const t in s.dataset)t in l.props&&(a[t]=s.dataset[t]);const r={componentElm:s,targetElm:n,data:a,eventType:e,eventName:i,stopPropagation:()=>{c=!0}};o[i]&&o[i](r,t)}h<r.length-1&&(h++,d())};d()}deppComponentEvent(t,e){const i=[];return t.getAttribute("bind-"+e)&&i.push(t),t.children&&t.children.length>0&&Array.from(t.children).forEach(t=>{i.push(...this.deppComponentEvent(t,e))}),i}async insertComponent(t,e){const i=this.components[t];if(!i)return;const n=Object.assign({},i.props,e),s=replaceTemplateVariables(i.template,{...n,[ELEMENT_COMPONENT_KEY]:i.name}),a=await this.target.insertHtml(s);return await this.target.chatEvent.richTextInput(),a}async removeComponentElm(t){const e=upFindElm(t,20);e&&(this.target.chatInput.delTag(e),await this.target.chatEvent.richTextInput())}async updateComponentElm(t,e){var i,n;const s=upFindElm(t,20);if(!s)return;const a=null==(n=null==(i=null==s?void 0:s.children[0])?void 0:i.children[0])?void 0:n.getAttribute("data-set-component");if(!a)return;const l=this.components[a];if(!l)return;const o=Object.assign({},l.props,e);s.children[0].innerHTML=replaceTemplateVariables(l.template,{...o,[ELEMENT_COMPONENT_KEY]:l.name}),await this.target.chatEvent.richTextInput()}getComponentElms(t){const e=[],i=this.target.chatElement.richText.querySelectorAll(".chat-tag");return Array.from(i,i=>{this.isComponentElm(i,t)&&e.push(i)}),e}isComponentElm(t,e){return!!(t&&t.children[0]&&t.children[0].children[0])&&t.children[0].children[0].getAttribute("data-set-component")===e}}const arrObSort=function(t,e,i){return t.forEach(t=>{if(i in t){const n=e.indexOf(String(t[i]));-1!==n&&(e[n]=t)}}),e.filter(t=>t[i])};class ChatArea{constructor(t){switch(__publicField(this,"options"),__publicField(this,"deviceInfo",os()),__publicField(this,"chatElement"),__publicField(this,"chatInput"),__publicField(this,"chatEvent"),this.options=Object.assign({},DEFAULT_OPTIONS,t),this.options.device=this.options.device.toLocaleLowerCase(),this.deviceInfo.isTablet&&(this.deviceInfo.isPc=!1),this.options.device){case"pc":this.deviceInfo.isPc=!0;break;case"h5":this.deviceInfo.isPc=!1}this.options.userProps=Object.assign({},DEFAULT_USER_PROPS,t.userProps||{}),this.options.dialogLabels.pcPointDialog=Object.assign({},DEFAULT_PC_POINT_DIALOG,getObjValue(t.dialogLabels,"pcPointDialog",{})),this.options.dialogLabels.pcPCheckDialog=Object.assign({},DEFAULT_PC_CHECK_DIALOG,getObjValue(t.dialogLabels,"pcPCheckDialog",{})),this.options.dialogLabels.h5Dialog=Object.assign({},DEFAULT_H5_DIALOG,getObjValue(t.dialogLabels,"h5Dialog",{})),this.chatElement=new ChatElement(this),this.chatInput=new ChatInput(this),this.chatEvent=new ChatEvent(this),this.updateConfig(t);const e=this;Object.defineProperty(this,"richText",{get:()=>e.chatElement.richText}),Object.defineProperty(this,"textLength",{get:()=>e.chatEvent.textLength}),this.options.autoFocus&&this.nextTick(()=>{this.chatElement.richText.focus()})}updateConfig(t){void 0!==t.copyType&&(this.options.copyType=t.copyType),t.userProps&&(this.options.userProps=Object.assign({},DEFAULT_USER_PROPS,t.userProps)),void 0!==t.uploadImage&&(this.options.uploadImage=t.uploadImage),void 0!==t.placeholder&&(this.chatElement.placeholderElm.textContent=t.placeholder),void 0!==t.maxLength&&(this.options.maxLength=t.maxLength<=0?-1:t.maxLength,this.chatEvent.ruleMaxLength()),this.options.asyncMatch?(this.options.needCallEvery=!1,this.updateUserList([])):(void 0!==t.needCallEvery||t.userList)&&(this.options.needCallEvery=getBoolean(void 0===t.needCallEvery?this.options.needCallEvery:t.needCallEvery),this.updateUserList(t.userList)),void 0!==t.needCallSpace&&this.chatInput.setCallSpace(getBoolean(t.needCallSpace)),void 0!==t.wrapKeyFun&&(this.options.wrapKeyFun=t.wrapKeyFun),void 0!==t.sendKeyFun&&(this.options.sendKeyFun=t.sendKeyFun),t.customTrigger&&(this.options.customTrigger=t.customTrigger.map(t=>(t.keyCode=KEY_CODE_MAP[t.prefix]||null,t)),this.options.needDialog&&this.deviceInfo.isPc&&this.chatElement.bindCustomTrigger()),t.selectList&&(this.options.selectList=t.selectList,this.options.needDialog&&this.deviceInfo.isPc&&this.chatElement.bindSelectList())}updateUserList(t=void 0){const{options:e,chatElement:i}=this;if(t){e.userList=JSON.parse(JSON.stringify(t));const i={[e.userProps.id]:"isALL",[e.userProps.name]:""};e.userList.unshift(i),e.reformList=t.map(t=>({id:String(t[e.userProps.id]),name:String(t[e.userProps.name]||""),avatar:String(t[e.userProps.avatar]||""),pinyin:String(t[e.userProps.pinyin]||"")}))}const n=e.userList[0];n&&"isALL"===n[e.userProps.id]&&(n[e.userProps.name]=this.deviceInfo.isPc?e.dialogLabels.pcPointDialog.callEveryLabel:e.dialogLabels.h5Dialog.callEveryLabel),e.needDialog&&(this.deviceInfo.isPc?i.updatePCUser():i.updateH5User())}searchUserList(t){return this.options.reformList.filter(e=>pinyinMatch(e.name,e.pinyin||"",t))}getReduceNode(t){const e=Object.assign({},DEFAULT_REDUCE_CONFIG,t||{});e.saveTagData&&(e.needUserId=!0,e.needTagId=!0,e.needSelectId=!0);const i=/(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g,n=this.chatElement.richText.cloneNode(!0).children||[],s=document.createElement("div");return e.wrapClassName&&(s.className=e.wrapClassName),Array.from(n,(t,n)=>{const a=document.createElement("p");Array.from(t.children,t=>{const n=t.children[0];this.chatInput.getNodeEmpty(n)||(n.removeAttribute("data-set-richType"),n.removeAttribute("contenteditable"),n.removeAttribute("data-set-empty"),e.needUserId||n.removeAttribute("data-user-id"),e.needTagId||(n.removeAttribute("data-set-prefix"),n.removeAttribute("data-tag-id")),e.needSelectId||(n.removeAttribute("data-select-id"),n.removeAttribute("data-select-key")),e.imgToText&&n.firstChild&&"IMG"===n.firstChild.tagName&&(n.classList.add("img-to-text"),n.innerHTML=`[${n.firstChild.getAttribute("data-img-text")||"you need set data-img-text"}]`),e.identifyLink&&n.classList.contains("chat-grid-input")&&(n.innerHTML=n.innerHTML.replace(i,t=>`<a class="chat-grid-link" href="${t}" target="_blank">${t}</a>`)),n.classList.contains("at-select")&&(n.classList.remove("aim"),n.removeChild(n.lastChild)),n.classList.contains("at-input")&&(e.saveTagData?n.setAttribute("data-input-tip",n.children[1].textContent):n.removeAttribute("data-input-key"),n.textContent=n.children[0].textContent!==this.chatInput.VOID_KEY?n.children[0].textContent:n.children[1].textContent,n.textContent=n.textContent.replace(new RegExp(this.chatInput.INPUT_TAG_WRAP_KEY[0],"g"),"")),a.appendChild(n))}),e.rowClassName&&(a.className=e.rowClassName),a.innerHTML||(a.innerHTML="<br>"),s.appendChild(a)}),s}getText(t){let e="";const i=this.getReduceNode(t);return Array.from(i.children,(t,i)=>{e=e+(i>0?"\n":"")+t.textContent}),e}getHtml(t){return this.getReduceNode(t).innerHTML}async reverseAnalysis(t,e){if(!t)return;const i=document.createElement("div");i.innerHTML=t;const n=i.children;Array.from(n,t=>{t.className="chat-grid-wrap",t.setAttribute("data-set-richType",RICH_GRID);const e=t.children,i={},n=[];Array.from(e,(s,a)=>{if(-1!==s.className.indexOf("chat-grid-input")){const t=s.textContent||"";return s.className="",s.setAttribute("data-set-richType",RICH_MARK),void(s.innerHTML=`<span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="false">${escapeHtml(t)}</span>`)}if(s.tagName&&"BR"===s.tagName.toLocaleUpperCase()){const e=this.chatInput.getGridElm(!0);return t.removeChild(s),void t.appendChild(e)}const l=s.cloneNode(!0);l.setAttribute("contenteditable","false");const o=document.createElement("span");if(o.className="chat-tag",o.setAttribute("contenteditable","false"),o.setAttribute("data-set-richType",RICH_TAG),o.appendChild(l),i[a]=o,a!==e.length-1){-1===e[a+1].className.indexOf("chat-grid-input")&&n.push(a)}else n.push(a);0===a&&n.push(-1)});for(const n in i){const s=Number(n),a=i[n].lastChild;if(a.classList.contains("at-select"))a.innerHTML=`${a.textContent}${arrowSvg}`;else if(a.classList.contains("at-input")){const t=""===a.textContent,e=t?`<span class="input-tip">${a.getAttribute("data-input-tip")}</span>`:`<span class="input-tip chat-view-hidden" style="display: none">${a.getAttribute("data-input-tip")}</span>`;a.innerHTML=`<span class="input-write" contenteditable="true">${t?this.chatInput.VOID_KEY:a.textContent.replace(new RegExp(this.chatInput.INPUT_TAG_WRAP_KEY[1],"g"),this.chatInput.INPUT_TAG_WRAP_KEY)}</span>${e}`,a.removeAttribute("data-input-tip")}s===e.length-1?(t.removeChild(e[s]),t.appendChild(i[n])):(t.insertBefore(i[n],e[s+1]),t.removeChild(e[s]))}const s=[],a=t.children;n.forEach(t=>{t===a.length-1?s.push("isEnd"):s.push(a[t+1])}),s.forEach(e=>{const i=this.chatInput.getGridElm(!0);if("isEnd"===e)t.appendChild(i);else{const n=i.children[0];n.childNodes.length>1&&n.removeChild(n.childNodes[1]),t.insertBefore(i,e)}})}),e?(this.chatInput.setRangeLastText(),await this.chatEvent.insertInsideHtml(i.innerHTML)):(this.chatElement.richText.innerHTML=i.innerHTML,this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput())}async insertHtml(t){if(!t)return;const e=document.createElement("span");e.innerHTML=t,e.className="chat-set-html";const i=this.chatInput.createNewDom(e);return this.chatInput.replaceRegContent(i,!1),await this.chatEvent.richTextInput(),i}async insertText(t){if(!t)return;t=escapeHtml(t);const e=new RegExp(`[${this.chatInput.ZERO_WIDTH_KEY}|${this.chatInput.VOID_KEY}]`,"ig"),i=t.replace(e,"");if(!i)return;const n=i.split("\n");let s="";n.forEach(t=>{const e=""!==t;s+=`<p class="chat-grid-wrap" data-set-richType="${RICH_GRID}"><span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="${e?"false":"true"}">${e?t:this.chatInput.VOID_KEY+"<br>"}</span></span></p>`}),await this.chatEvent.insertInsideHtml(s)}getCallUserList(){const t=this.chatElement.richText.querySelectorAll(".at-user");if(t&&t.length>0){const e=Array.from(t,t=>t.dataset.userId);return arrObSort(this.options.userList,e,this.options.userProps.id)}return[]}getCallUserTagList(){const t=this.chatElement.richText.querySelectorAll(".at-user");if(t&&t.length>0){const e=[];return Array.from(t,t=>{e.some(e=>e[this.options.userProps.id]===t.dataset.userId)||e.push({[this.options.userProps.id]:t.dataset.userId,[this.options.userProps.name]:t.textContent.slice(1)})}),e}return[]}getCustomTagList(){const t=Object.keys(this.chatElement.customTags),e={},i=this.chatElement.richText.querySelectorAll(".at-tag");return t.forEach(t=>{let n=Array.prototype.filter.call(i,e=>e.getAttribute("data-set-prefix")===String(t)).map(t=>t.getAttribute("data-tag-id"));n=n.filter((t,e)=>n.indexOf(t)===e),e[t]=arrObSort(this.chatElement.customTags[t],n,"id")}),e}getSelectTagList(){const t=Object.keys(this.chatElement.selectTags),e={},i=this.chatElement.richText.querySelectorAll(".at-select");return t.forEach(t=>{let n=Array.prototype.filter.call(i,e=>e.getAttribute("data-select-key")===String(t)).map(t=>t.getAttribute("data-select-id"));n=n.filter((t,e)=>n.indexOf(t)===e),e[t]=arrObSort(this.chatElement.selectTags[t],n,"id")}),e}getInputTagList(){const t={},e=this.chatElement.richText.querySelectorAll(".at-input");return Array.from(e,e=>{const i=e.getAttribute("data-input-key"),n=e.children[0].textContent===this.chatInput.VOID_KEY?null:e.children[0].textContent;t[i]||(t[i]=[]),t[i].push(n)}),t}async clear(t){this.chatInput.initEditor(!0,t),this.clearHistory(),await this.chatEvent.richTextInput(!1)}isEmpty(t=!1){if((this.chatElement.richText.querySelectorAll(".chat-tag")||[]).length>0)return!1;const e=new RegExp(`^(${this.chatInput.ZERO_WIDTH_KEY}|<br>|${this.chatInput.VOID_KEY})+$`),i=this.chatElement.richText.querySelectorAll(".chat-grid-input")||[];return t?Array.prototype.every.call(i,t=>!t.innerHTML||!t.textContent||!t.textContent.trim()||e.test(t.innerHTML)):Array.prototype.every.call(i,t=>!t.innerHTML||!t.textContent||e.test(t.innerHTML))}dispose(){if(this.options.elm.removeChild(this.chatElement.richText),this.options.elm.removeChild(this.chatElement.placeholderElm),this.options.needDialog)if(this.deviceInfo.isPc){const t=this.chatElement.pcElms.containerDialogElm.parentElement;t&&t.removeChild(this.chatElement.pcElms.containerDialogElm)}else document.body.removeChild(this.chatElement.h5Elms.dialogElm)}showPCPointDialog(){this.options.needDialog&&(this.insertText("@"),this.options.asyncMatch&&domItVisible(this.chatElement.pcElms.pointDialogEmptyElm,!0,"flex"),this.chatEvent.outerApply=!0,this.chatElement.showPointDialog(),sleep(50).then(()=>{this.chatEvent.outerApply=!1}))}showPCCheckDialog(){this.options.needDialog&&!this.options.asyncMatch&&(this.chatEvent.winClick(),this.chatElement.checkboxRows=[],domItVisible(this.chatElement.pcElms.checkDialogElm,!0),updateElmClass(document.body,"disable-scroll",!0),this.chatElement.pcElms.checkDialogTagsElm.scrollTop=0,this.chatElement.pcElms.checkDialogUsersElm.scrollTop=0,this.chatElement.pcElms.checkDialogSearchInputElm.value="",this.chatElement.updateCheckDialogTags(),this.chatElement.isExternalCallPopup=!0)}showPCCustomTagDialog(t){this.options.needDialog&&!this.options.asyncMatch&&(this.insertText(t),this.chatEvent.outerApply=!0,this.chatElement.showCustomTagDialog(t),sleep(50).then(()=>{this.chatEvent.outerApply=!1}))}showPCSelectDialog(t,e){this.chatElement.exitCustomTagDialog(),this.chatElement.exitPointDialog(),this.chatEvent.outerApply=!0,e&&(this.chatElement.exitSelectDialog(),this.chatElement.pcElms.selectDialogAim=e),this.chatElement.pcElms.selectDialogKey=t,this.chatEvent.debounceEvents.selectDialogToAim(),sleep(50).then(()=>{this.chatEvent.outerApply=!1})}showH5Dialog(){this.chatElement.richText&&this.chatElement.richText.blur(),Array.from(this.chatElement.h5Elms.dialogMainElm.children,t=>{t.style.display="",updateElmClass(t,"user-popup-check-item-check")}),updateElmClass(this.chatElement.h5Elms.dialogCheckElm,"disabled",!0),domItVisible(this.chatElement.h5Elms.dialogElm,!0),updateElmClass(document.body,"disable-scroll",!0),this.options.asyncMatch&&domItVisible(this.chatElement.h5Elms.dialogEmptyElm,!0,"flex"),this.chatElement.h5Elms.dialogMainElm.scrollTop=0,this.chatElement.isExternalCallPopup=!0}disabled(){this.chatElement.richText.setAttribute("contenteditable","false"),updateElmClass(this.chatElement.richText,"chat-rich-text-disabled",!0)}enable(){this.chatElement.richText.setAttribute("contenteditable","true"),updateElmClass(this.chatElement.richText,"chat-rich-text-disabled"),this.chatInput.setRangeLastText()}async setUserTag(t){this.chatEvent.triggerChatEvent("atCheck",[t]);const e=this.chatInput.createChatTagElm({id:t[this.options.userProps.id],name:t[this.options.userProps.name]},"@","at-user","user-id");this.chatInput.replaceRegContent(e,!1),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async setCustomTag(t,e){this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,!1,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",t,e)}async setSelectTag(t,e){if(e||(e=this.chatElement.pcElms.selectDialogKey),this.chatEvent.triggerChatEvent("selectCheck",t,e),this.chatElement.pcElms.selectDialogAim&&this.chatElement.pcElms.selectDialogAim.classList.contains("at-select")){const e=this.chatElement.pcElms.selectDialogAim.getAttribute("data-select-id"),i=this.chatElement.pcElms.selectDialogAim.parentElement.nextElementSibling.childNodes[0].childNodes[0];if(this.chatInput.restCursorPos(i),e===t.id)return;this.chatElement.pcElms.selectDialogAim.setAttribute("data-select-id",t.id),this.chatElement.pcElms.selectDialogAim.childNodes[0].textContent=t.name}else{const i=document.createElement("span");i.setAttribute("class","at-select"),i.setAttribute("data-select-key",e),i.setAttribute("data-select-id",t.id),i.innerHTML=`${t.name}${arrowSvg}`;const n=this.chatInput.createNewDom(i);this.chatInput.replaceRegContent(n,!1)}await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterSelectCheck",t,e)}async setInputTag(t,e,i=""){const n=document.createElement("span");n.setAttribute("class","at-input"),n.setAttribute("contenteditable","false"),n.setAttribute("data-input-key",t);const s=document.createElement("span");s.setAttribute("class","input-write"),s.setAttribute("contenteditable","true"),s.textContent=i||this.chatInput.VOID_KEY;const a=document.createElement("span");a.setAttribute("class","input-tip"),a.textContent="["+(e||"Please input")+"]",n.appendChild(s),n.appendChild(a);const l=this.chatInput.createNewDom(n);this.chatInput.replaceRegContent(l,!1),i&&this.chatInput.watchInputTag(s),this.chatInput.rangeToInputTag(n),await this.chatEvent.richTextInput()}async matchSetTag(t){this.chatEvent.triggerChatEvent("atCheck",[t]),await this.chatInput.onceSearchCall(t,this.chatEvent.startOpenIndex),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async onceSetTag(t){this.chatEvent.triggerChatEvent("atCheck",[t]),await this.chatInput.onceCall({id:t[this.options.userProps.id],name:t[this.options.userProps.name]}),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async batchSetTag(t){this.chatEvent.triggerChatEvent("atCheck",t);const e=[];for(let i=0;i<=t.length-1;)e.push({id:t[i][this.options.userProps.id],name:t[i][this.options.userProps.name]}),i++;await this.chatInput.batchReplaceRegContent(e,!this.chatElement.isExternalCallPopup),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",t)}async onceSetCustomTag(t,e){e||(e=this.chatElement.pcElms.customTagDialogTagKey),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,!0,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",t,e)}async matchSetCustomTag(t,e){e||(e=this.chatElement.pcElms.customTagDialogTagKey),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,this.chatEvent.startOpenIndex,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",e)}async undo(){const{chatEvent:t}=this;if(!t.doOverHistory||!t.undoHistory||t.undoHistory.length<=1)return;const e=t.undoHistory[t.undoHistory.length-2],i=t.undoHistory[t.undoHistory.length-1];t.redoHistory.push(i),t.undoHistory.pop(),await t.setChatHistory(e)}async redo(){const{chatEvent:t}=this;if(!t.doOverHistory||!t.redoHistory||t.redoHistory.length<1)return;const e=t.redoHistory[t.redoHistory.length-1];t.redoHistory.pop(),t.undoHistory.push(e),await t.setChatHistory(e)}clearHistory(){const{gridIndex:t,markIndex:e}=this.chatInput.getRichTextNodeIndex(this.chatInput.vnode);this.chatEvent.undoHistory=null===t||null==e?[{html:this.chatElement.richText.innerHTML,gridIndex:0,markIndex:0,cursorIndex:this.chatInput.cursorIndex}]:[{html:this.chatElement.richText.innerHTML,gridIndex:t,markIndex:e,cursorIndex:this.chatInput.cursorIndex}],this.chatEvent.redoHistory=[]}cursorMove(t){if(0===t)return void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const e=new RegExp(`[${this.chatInput.ZERO_WIDTH_KEY}|${this.chatInput.VOID_KEY}]`,"ig");if(t>0){const i=this.chatInput.vnode.textContent.replace(e,"").slice(this.chatInput.cursorIndex);if(i.length>=t)return this.chatInput.cursorIndex+=t,void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const n=this.chatInput.vnode.parentElement.parentElement,s=n.parentElement;let a=Boolean(n.nextElementSibling&&n.nextElementSibling.nextElementSibling);const l=Boolean(s.nextElementSibling);if(!a&&!l)return this.chatInput.cursorIndex+=i.length,0===this.chatInput.cursorIndex&&(this.chatInput.cursorIndex=1),void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const o=t-i.length-1,r=a?n.nextElementSibling.nextElementSibling:s.nextElementSibling.children[0],{rangeNode:c,rangeIndex:h}=this.chatInput.getOffsetRange(o,r);this.chatInput.restCursorPos(c,h)}else if(t<0){let i=Math.abs(t);const n=this.chatInput.vnode.textContent.replace(e,"").slice(0,this.chatInput.cursorIndex);if(n.length>=i)return this.chatInput.cursorIndex-=i,void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const s=this.chatInput.vnode.parentElement.parentElement,a=s.parentElement,l=Boolean(s.previousElementSibling&&s.previousElementSibling.previousElementSibling),o=Boolean(a.previousElementSibling);if(!l&&!o)return void this.chatInput.restCursorPos(this.chatInput.vnode);i=i-n.length-1;const r=l?s.previousElementSibling.previousElementSibling:a.previousElementSibling.lastElementChild,{rangeNode:c,rangeIndex:h}=this.chatInput.getOffsetRange(i,r,!0);this.chatInput.restCursorPos(c,h)}}async cursorDel(t){if(0===t)return void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const e=this.chatInput.vnode,i=this.chatInput.cursorIndex;this.cursorMove(t);const n=this.chatInput.vnode,s=this.chatInput.cursorIndex,a=document.createRange();t<0?(a.setStart(n,s),a.setEnd(e,i)):(a.setStart(e,i),a.setEnd(n,s));const l=window.getSelection();l.removeAllRanges(),l.addRange(a),(this.chatInput.selectRegionMerge()||this.chatInput.gridElmMerge()||this.chatInput.delMarkRule())&&await this.chatEvent.richTextInput()}async delUserTags(t){const e=t||this.options.userList.map(t=>t[this.options.userProps.id]),i=this.chatElement.richText.querySelectorAll(".at-user"),n=[];Array.from(i,t=>{const i=t.getAttribute("data-user-id");e.some(t=>String(t)===i)&&n.push(t.parentElement)});for(let t=0;t<n.length;){const e=n[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delCustomTags(t,e){const i=this.options.customTrigger.find(e=>e.prefix===t);if(!i||0===i.tagList.length)return;const n=e||i.tagList.map(t=>t.id),s=this.chatElement.richText.querySelectorAll(".at-tag"),a=[];Array.from(s,e=>{const i=e.getAttribute("data-set-prefix"),s=e.getAttribute("data-tag-id");i===t&&n.some(t=>String(t)===s)&&a.push(e.parentElement)});for(let t=0;t<a.length;){const e=a[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delSelectTags(t,e){const i=this.options.selectList.find(e=>e.key===t);if(!i||0===i.options.length)return;const n=e||i.options.map(t=>t.id),s=this.chatElement.richText.querySelectorAll(".at-select"),a=[];Array.from(s,e=>{const i=e.getAttribute("data-select-key"),s=e.getAttribute("data-select-id");i===t&&n.some(t=>String(t)===s)&&a.push(e.parentElement)});for(let t=0;t<a.length;){const e=a[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delInputTags(t){const e=this.chatElement.richText.querySelectorAll(".at-input"),i=[];Array.from(e,e=>{if(t){const n=e.getAttribute("data-input-key");t.some(t=>String(t)===n)&&i.push(e.parentElement)}else i.push(e.parentElement)});for(let t=0;t<i.length;){const e=i[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}openTipTag(t){this.chatElement.createTipElm(t),this.chatInput.setRangeLastText()}closeTipTag(){this.chatElement.tipElm&&this.chatElement.removeTipElm()}addEventListener(t,e){this.chatEvent.chatEventModule[t].push(e)}removeEventListener(t,e){const i=this.chatEvent.chatEventModule[t],n=i.indexOf(e);-1!==n&&i.splice(n,1)}revisePCPointDialogLabel(t){this.options.needDialog&&(this.options.dialogLabels.pcPointDialog=Object.assign({},DEFAULT_PC_POINT_DIALOG,t||{}),this.chatElement.pcElms.pointDialogElm.querySelector(".call-user-dialog-header-title").textContent=this.options.dialogLabels.pcPointDialog.title,this.chatElement.pcElms.pointDialogCheckElm.textContent=this.options.dialogLabels.pcPointDialog.checkLabel,this.chatElement.pcElms.pointDialogEmptyElm&&(this.chatElement.pcElms.pointDialogEmptyElm.children[1].textContent=this.options.dialogLabels.pcPointDialog.emptyLabel),this.options.asyncMatch||this.updateUserList())}revisePCCheckDialogLabel(t){this.options.needDialog&&!this.options.asyncMatch&&(this.options.dialogLabels.pcPCheckDialog=Object.assign({},DEFAULT_PC_CHECK_DIALOG,t||{}),this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-container-header").children[0].textContent=this.options.dialogLabels.pcPCheckDialog.title,this.chatElement.pcElms.checkDialogSearchInputElm.setAttribute("placeholder",this.options.dialogLabels.pcPCheckDialog.searchPlaceholder),this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-search-empty").textContent=this.options.dialogLabels.pcPCheckDialog.searchEmptyLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-right-box-title").textContent=this.options.dialogLabels.pcPCheckDialog.userTagTitle,this.chatElement.pcElms.checkDialogUsersElm.children[0].children[2].textContent=this.options.dialogLabels.pcPCheckDialog.checkAllLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".btn-submit").textContent=this.options.dialogLabels.pcPCheckDialog.confirmLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".btn-close").textContent=this.options.dialogLabels.pcPCheckDialog.cancelLabel)}reviseH5DialogLabel(t){this.options.needDialog&&(this.options.dialogLabels.h5Dialog=Object.assign({},DEFAULT_H5_DIALOG,t||{}),this.chatElement.h5Elms.dialogElm.querySelector(".popup-title").textContent=this.options.dialogLabels.h5Dialog.title,this.chatElement.h5Elms.dialogSearchElm.setAttribute("placeholder",this.options.dialogLabels.h5Dialog.searchPlaceholder),this.chatElement.h5Elms.dialogEmptyElm.children[1].textContent=this.options.dialogLabels.h5Dialog.searchEmptyLabel,this.chatElement.h5Elms.dialogCheckElm.textContent=this.options.dialogLabels.h5Dialog.confirmLabel,this.chatElement.h5Elms.dialogShowElm.textContent=this.options.dialogLabels.h5Dialog.cancelLabel,this.options.asyncMatch||this.updateUserList())}async nextTick(t){return new Promise(e=>{requestAnimationFrame(()=>{const i=t();i instanceof Promise?i.then(()=>{e()}):e()})})}createOperateNode(){return new ChatOperateNode(this)}createChatComponent(){return new ChatComponent(this)}}__publicField(ChatArea,"version","5.8.5");
1016
+ var __defProp=Object.defineProperty,__defNormalProp=(t,e,i)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,__publicField=(t,e,i)=>__defNormalProp(t,"symbol"!=typeof e?e+"":e,i);function os(){const t=navigator.userAgent,e=/(?:Windows Phone)/.test(t),i=/(?:SymbianOS)/.test(t)||e,n=/(?:Android)/.test(t),s=/(?:Firefox)/.test(t),a=/(?:iPad|PlayBook)/.test(t)||n&&!/(?:Mobile)/.test(t)||s&&/(?:Tablet)/.test(t),l=/(?:iPhone)/.test(t)&&!a;return{isTablet:a,isPhone:l,isAndroid:n,isPc:!l&&!n&&!i}}function domItVisible(t,e=!1,i="block"){t&&(t.className=t.className.replace(/ chat-view-show| chat-view-hidden/g,""),e?(t.style.display=i,t.className+=" chat-view-show"):(t.className+=" chat-view-hidden",t.style.display="none"))}function hasElmShow(t){return t&&t.classList.contains("chat-view-show")}function updateElmClass(t,e,i){t.classList[i?"add":"remove"](e)}const ELEMENT_EMPTY_KEY="data-set-empty",ELEMENT_RICH_TYPE_KEY="data-set-richType",RICH_WRAP="richWrap",RICH_GRID="richGrid",RICH_MARK="richMark",RICH_INPUT="richInput",RICH_TAG="richTag",CHAT_COPY_KEY="application/chatarea-custom-format",ELEMENT_COMPONENT_KEY="data-set-component",checkEmptySvg='<svg class="check-empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>',searchEmptySvg='<svg class="empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>',searchSvg='<svg class="icon-search" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M684.8 223.530667a326.272 326.272 0 0 1 24.96 433.621333c2.645333 2.133333 5.290667 4.48 7.850667 7.04L870.4 817.066667c24.789333 24.746667 32.896 56.832 18.133333 71.594666-14.762667 14.805333-46.848 6.656-71.637333-18.090666l-152.789333-152.832a106.282667 106.282667 0 0 1-7.210667-7.936 326.101333 326.101333 0 0 1-433.109333-25.173334c-127.445333-127.445333-127.573333-333.952-0.256-461.269333 127.36-127.36 333.866667-127.232 461.269333 0.213333zM275.328 275.114667a252.885333 252.885333 0 0 0 0.256 357.632 252.885333 252.885333 0 0 0 357.632 0.256 252.885333 252.885333 0 0 0-0.256-357.632 252.885333 252.885333 0 0 0-357.632-0.256z" fill="#9B9B9B"></path></svg>',antdLoading='<div class="ant-spin ant-spin-spinning" aria-live="polite" aria-busy="true"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>',matchEmptySvg='<svg class="match-empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>',checkSvg='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24"><path fill="currentColor" d="M9.218 17.41 19.83 6.796a.99.99 0 1 1 1.389 1.415c-3.545 3.425-4.251 4.105-11.419 11.074a.997.997 0 0 1-1.375.018c-1.924-1.801-3.709-3.568-5.573-5.43a.999.999 0 0 1 1.414-1.413z"></path></svg>',arrowSvg='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24"><path fill="currentColor" d="m20.23 8.653-7.795 9.685a1.2 1.2 0 0 1-1.87 0L2.771 8.652C2.14 7.867 2.698 6.7 3.706 6.7h15.588c1.008 0 1.567 1.167.935 1.952"></path></svg>',closeSvg='<svg focusable="false" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true" fill-rule="evenodd" viewBox="64 64 896 896"><path d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"></path></svg>',sleep=(t=50)=>new Promise(e=>{setTimeout(e,t)}),getBoolean=t=>"false"!==String(t)&&"null"!==String(t)&&"0"!==String(t),debounce=(t,e,i=!1)=>{let n;return function(...s){const a=this,l=i&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,i||t.apply(a,s)},e),l&&t.apply(a,s)}},throttle=(t,e)=>{let i;return function(...n){const s=this;i||(t.apply(s,n),i=!0,setTimeout(function(){i=!1},e))}},upFindElm=(t,e)=>{const i=t.getAttribute("data-set-richType");return i===RICH_GRID?null:i===RICH_MARK||i===RICH_TAG?t:t.parentElement&&e>0?upFindElm(t.parentElement,e-1):null},getObjValue=(t,e,i)=>t&&t[e]?t[e]:i,strictMinifyHtml=t=>t.replace(/\n+/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><").trim(),convertBlocksToSpans=(t,e)=>{const i=document.createElement("div");i.innerHTML=t;i.querySelectorAll("div, p, h1, h2, h3, h4, h5, h6, section, article, header, footer, aside, nav").forEach(t=>{const e=document.createElement("span");for(e.style.display="block",Array.from(t.attributes).forEach(t=>{e.setAttribute(t.name,t.value)});t.firstChild;)e.appendChild(t.firstChild);t.parentNode.replaceChild(e,t)});const n=i.children[0];if(n&&"block"===n.style.display&&(n.style.display="inline-block"),n){for(const t in e)n.dataset[t]="{{"+t+"}}";n.setAttribute("data-set-component","{{data-set-component}}")}return i.innerHTML};function replaceTemplateVariables(t,e){let i=t;for(const[t,n]of Object.entries(e)){const e=`{{${t}}}`;i=i.replace(new RegExp(e,"g"),String(n))}return i}function escapeHtml(t){let e=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");return e=e.replace(/[&<>"']/g,t=>{switch(t){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";case"'":return"&#039;";default:return t}}),e=e.replace(/ /g,"&nbsp;"),e}function unescapeHtml(t){let e=t.replace(/&nbsp;/g," ");return e=e.replace(/&amp;|&lt;|&gt;|&quot;|&#039;/g,t=>{switch(t){case"&amp;":return"&";case"&lt;":return"<";case"&gt;":return">";case"&quot;":return'"';case"&#039;":return"'";default:return t}}),e}function escapeChatHtml(t){return parseHtml(t).map(t=>extractPChildren(t)).map(t=>t.map(t=>{let e="",i="",n="",s="",a="",l="";switch(getOuterSpanClass(t)){case"chat-grid-input":n=removeOuterTag(t,"span",1),s=getCustomAttributeValue(n,"data-set-empty"),i=removeOuterTag(n,"span",1),e="false"===String(s)?replaceNativeNodeContent(t,i):t;break;case"chat-tag":switch(a=removeOuterTag(t,"span",1),l=getOuterSpanClass(a),l){case"at-user":case"at-tag":i=removeOuterTag(a,"span",1),e=replaceNativeNodeContent(t,i);break;case"at-select":i=removeOuterTag(a.replace(arrowSvg,""),"span",1),e=replaceNativeNodeContent(t,i+arrowSvg,escapeHtml(i)+arrowSvg);break;case"at-input":e=replaceSpecificContent(t);break;default:e=t}}return e})).map(t=>t.join("")).map(t=>'<p class="chat-grid-wrap" data-set-richtype="richGrid">'+t+"</p>").join("")}function parseHtml(t){const e=[];let i=[],n=0;const s=t.split(/(<\/?p[^>]*>)/gi);for(const t of s)t&&(t.startsWith("<p")&&!t.startsWith("</p")?(n++,i.push(t),1===n&&i.length>1&&(i=[t])):t.startsWith("</p")?(i.push(t),n--,0===n&&(e.push(i.join("").trim()),i=[])):n>0&&i.push(t));return e}function extractPChildren(t){const e=[];let i=[],n=0;const s=t.replace(/^<p[^>]*>/,"").replace(/<\/p>\s*$/,"").split(/(<\/?[^>]+\/?>)/g);for(const t of s){const s=t.trim();s&&(s.startsWith("<")&&s.endsWith("/>")?0===n?e.push(t):i.push(t):!s.startsWith("<")||s.startsWith("</")||s.startsWith("<!")?s.startsWith("</")?(n--,i.push(t),0===n&&(e.push(i.join("").trim()),i=[])):n>0&&i.push(t):(n++,i.push(t)))}if(i.length>0){const t=i.join("").trim();t&&e.push(t)}return e}function getOuterSpanClass(t){const e=t.match(/<span[^>]*?class="([^"]*)"/i);return e?e[1]:null}function getCustomAttributeValue(t,e){const i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`${i}=("([^"]*)"|'([^']*)'|([^\\s>]+))`),s=t.match(n);return s&&(s[2]||s[3]||s[4])||null}function removeOuterTag(t,e,i=1){const n=t.indexOf(">")+1,s=t.lastIndexOf(`</${e}`),a=t.substring(n,s);return i<=1?a:removeOuterTag(a,e,i-1)}function replaceNativeNodeContent(t,e,i){return t.replace(e,i||escapeHtml(e))}function replaceSpecificContent(t){let e=t.replace(/(<span class="input-write" contenteditable="true">)(.*?)(<\/span>)/,(t,e,i,n)=>`${e}${escapeHtml(i)}${n}`);return e=e.replace(/(<span class="[^"]*input-tip[^"]*"[^>]*>)(.*?)(<\/span>)/,(t,e,i,n)=>`${e}${escapeHtml(i)}${n}`),e}function isKeyType(t,e){switch(e){case"text-delete":return"Backspace"===t.key||"Backspace"===t.code;case"text-move":return"ArrowLeft"===t.key||"ArrowRight"===t.key||"ArrowLeft"===t.code||"ArrowRight"===t.code;case"text-select-all":return(t.ctrlKey||t.metaKey)&&("A"===t.key||"a"===t.key||"KeyA"===t.code);case"text-undo":return(t.ctrlKey||t.metaKey)&&("Z"===t.key||"z"===t.key||"KeyZ"===t.code);case"text-redo":return(t.ctrlKey||t.metaKey)&&("Y"===t.key||"y"===t.key||"KeyY"===t.code);case"text-write":return t.isComposing||!t.ctrlKey&&!t.altKey&&!t.metaKey&&!["Backspace","Shift","Tab","CapsLock","Control","Meta","Alt","ContextMenu","Enter","NumpadEnter","Escape","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Home","End","PageUp","PageDown","Insert","Delete","NumLock"].includes(t.key);case"dialog-options":return"ArrowUp"===t.key||"ArrowDown"===t.key||"Enter"===t.key||"ArrowUp"===t.code||"ArrowDown"===t.code||"Enter"===t.code||"NumpadEnter"===t.code;case"IME":return"Unidentified"===t.key||229===t.keyCode;default:return!1}}function pinyinMatch(t,e,i){const n=e.split(/\s+/),s=t.split("").map((t,i)=>{let s=n[i]||"";return""===e&&""===s&&(s=t),{char:t,pinyin:s.toLowerCase(),initial:s?s[0].toLowerCase():""}}),a=(t=>{const e=[];let i="";for(const n of t)/[a-zA-Z]/.test(n)?i+=n.toLowerCase():(i&&(e.push({type:"pinyin",value:i}),i=""),e.push({type:"char",value:n}));return i&&e.push({type:"pinyin",value:i}),e})(i),l=s.length,o=a.length,r=Array.from({length:l+1},()=>Array(o+1).fill(!1));r[0][0]=!0;for(let t=0;t<=l;t++)for(let e=0;e<=o;e++)if(r[t][e]&&e<o){const i=a[e];for(let n=t;n<l;n++){const t=s[n];if("char"===i.type)t.char===i.value&&(r[n+1][e+1]=!0);else{const a=t.pinyin.toLowerCase(),o=t.initial,c=i.value;if(c===o)r[n+1][e+1]=!0;else if(c===a)r[n+1][e+1]=!0;else if(isSubsequence(c,a))r[n+1][e+1]=!0;else for(let t=2;t<=l-n;t++){const i=s.slice(n,n+t),a=i.map(t=>t.pinyin.toLowerCase()).join(""),l=i.map(t=>t.initial).join("");if(c===a||c===l||isSubsequence(c,a)){r[n+t][e+1]=!0;break}}}}}for(let t=0;t<=l;t++)if(r[t][o])return!0;return!1}function isSubsequence(t,e){let i=0,n=0;for(;i<t.length&&n<e.length;)t[i]===e[n]&&i++,n++;return i===t.length}class ChatElement{constructor(t){__publicField(this,"target"),__publicField(this,"richText",document.createElement("div")),__publicField(this,"placeholderElm",document.createElement("div")),__publicField(this,"tipElm",null),__publicField(this,"isExternalCallPopup",!1),__publicField(this,"isPointSearchMode",!1),__publicField(this,"checkboxRows",[]),__publicField(this,"customTags",{}),__publicField(this,"selectTags",{}),__publicField(this,"rects",{}),__publicField(this,"pcElms",{containerDialogElm:null,pointDialogElm:null,pointDialogCheckElm:null,pointDialogMainElm:null,pointDialogUsersElm:[],pointDialogActiveElm:null,pointDialogLoadingElm:null,pointDialogEmptyElm:null,checkDialogElm:null,checkDialogSearchResultElm:null,checkDialogUsersElm:null,checkDialogSearchInputElm:null,checkDialogTagsElm:null,customTagDialogElms:{},customTagDialogTagKey:"",customTagDialogActiveElm:null,selectDialogElms:{},selectDialogKey:"",selectDialogAim:null,tipContainerPopoverElm:null,tipPopoverElm:null}),__publicField(this,"h5Elms",{dialogElm:null,dialogMainElm:null,dialogCheckElm:null,dialogShowElm:null,dialogSearchElm:null,dialogEmptyElm:null,dialogLoadingElm:null}),this.target=t,this.createRichText(),this.createPlaceholder(),t.deviceInfo.isPc?this.createPCDialog():this.createH5Dialog()}createRichText(){const{options:t,deviceInfo:e}=this.target,{elm:i}=t;updateElmClass(i,"chat-area-"+(e.isPc?"pc":"h5"),!0),updateElmClass(this.richText,"chat-rich-text",!0),this.richText.setAttribute("data-set-richType",RICH_WRAP),this.richText.setAttribute("contenteditable","true"),i.appendChild(this.richText)}createPlaceholder(){const{options:t}=this.target,{elm:e}=t;updateElmClass(this.placeholderElm,"chat-placeholder-wrap",!0),domItVisible(this.placeholderElm,!0),e.appendChild(this.placeholderElm),this.rects.plaRect=this.placeholderElm.getBoundingClientRect()}createPCDialog(){const{options:t}=this.target,{needDialog:e,elm:i,asyncMatch:n}=t;if(!e)return;const{pcElms:s}=this;s.containerDialogElm=document.createElement("div"),updateElmClass(this.pcElms.containerDialogElm,"chat-dialog",!0),i.nextElementSibling?i.parentElement.insertBefore(s.containerDialogElm,i.nextElementSibling):i.parentElement.appendChild(s.containerDialogElm),n||this.createPCCheckDialog(),this.createPCPointDialog()}createPCCheckDialog(){const{options:t}=this.target,e=this.target.options.dialogLabels.pcPCheckDialog,{pcElms:i}=this;i.checkDialogElm=document.createElement("div"),updateElmClass(i.checkDialogElm,"checkbox-dialog",!0),domItVisible(i.checkDialogElm),i.checkDialogElm.innerHTML=`\n <div class="checkbox-dialog-container">\n <div class="checkbox-dialog-container-header">\n <span>${e.title}</span>\n <span class="checkbox-dialog-container-header-close">⛌</span>\n </div>\n <div class="checkbox-dialog-container-body">\n <div class="checkbox-dialog-left-box">\n <div class="checkbox-dialog-search">\n <input class="checkbox-dialog-search-input" placeholder="${e.searchPlaceholder}" type="text">\n <div class="checkbox-dialog-search-group"></div>\n </div>\n <div class="checkbox-dialog-tags"></div>\n <div class="checkbox-dialog-option">\n <button class="checkbox-dialog-option-btn btn-submit disabled">${e.confirmLabel}</button>\n <button class="checkbox-dialog-option-btn btn-close">${e.cancelLabel}</button>\n </div>\n </div>\n <div class="checkbox-dialog-right-box">\n <div class="checkbox-dialog-right-box-title">${e.userTagTitle}</div>\n <div class="checkbox-dialog-check-group"></div>\n </div>\n </div>\n </div>\n `,i.containerDialogElm.appendChild(i.checkDialogElm),i.checkDialogUsersElm=i.checkDialogElm.querySelector(".checkbox-dialog-check-group"),i.checkDialogSearchResultElm=i.checkDialogElm.querySelector(".checkbox-dialog-search-group"),i.checkDialogSearchInputElm=i.checkDialogElm.querySelector(".checkbox-dialog-search-input"),i.checkDialogTagsElm=i.checkDialogElm.querySelector(".checkbox-dialog-tags");const n=()=>{domItVisible(i.checkDialogElm),updateElmClass(document.body,"disable-scroll")};i.checkDialogElm.querySelector(".checkbox-dialog-container-header-close").onclick=n,i.checkDialogElm.querySelector(".btn-close").onclick=n;const s=i.checkDialogElm.querySelector(".btn-submit");s.onclick=async()=>{if(s.classList.contains("disabled"))return;const e=this.checkboxRows.map(e=>{const i=Object.create(null);return i[t.userProps.id]=e.id,i[t.userProps.name]=e.name,i});await this.target.batchSetTag(e),n()},domItVisible(i.checkDialogSearchResultElm),i.checkDialogSearchResultElm.onclick=t=>{t.stopPropagation()},i.checkDialogSearchInputElm.onclick=t=>{t.stopPropagation()};const a=debounce(t=>{const e=String(t.target.value||"").replace(/'/g,"").trim();if(!e)return void domItVisible(i.checkDialogSearchResultElm);const n=this.target.searchUserList(e).map(t=>t.id);Array.from(i.checkDialogSearchResultElm.children,(t,e)=>{if(e===i.checkDialogSearchResultElm.children.length-1)domItVisible(t,0===n.length);else{const e=t.getAttribute("data-set-id");domItVisible(t,-1!==n.indexOf(e),"flex")}}),domItVisible(i.checkDialogSearchResultElm,!0)},200);i.checkDialogSearchInputElm.oninput=a,i.checkDialogSearchInputElm.onfocus=a}createPCPointDialog(){const{pcElms:t,target:e}=this;t.pointDialogElm=document.createElement("div"),updateElmClass(t.pointDialogElm,"call-user-dialog",!0),domItVisible(t.pointDialogElm);const i=document.createElement("div");updateElmClass(i,"call-user-dialog-header",!0),i.innerHTML=`<span class="call-user-dialog-header-title">${e.options.dialogLabels.pcPointDialog.title}</span>`,t.pointDialogCheckElm=document.createElement("span"),updateElmClass(t.pointDialogCheckElm,"call-user-dialog-header-check",!0),t.pointDialogCheckElm.innerText=e.options.dialogLabels.pcPointDialog.checkLabel,t.pointDialogCheckElm.onclick=()=>{this.target.showPCCheckDialog(),this.isExternalCallPopup=!1},i.appendChild(t.pointDialogCheckElm),t.pointDialogElm.appendChild(i),t.pointDialogMainElm=document.createElement("div"),updateElmClass(t.pointDialogMainElm,"call-user-dialog-main",!0),t.pointDialogElm.appendChild(t.pointDialogMainElm),e.options.asyncMatch&&(t.pointDialogLoadingElm=document.createElement("div"),updateElmClass(t.pointDialogLoadingElm,"call-user-dialog-loading",!0),t.pointDialogLoadingElm.innerHTML=antdLoading,t.pointDialogElm.appendChild(t.pointDialogLoadingElm),domItVisible(t.pointDialogLoadingElm),t.pointDialogEmptyElm=document.createElement("div"),updateElmClass(t.pointDialogEmptyElm,"call-user-dialog-empty",!0),t.pointDialogEmptyElm.innerHTML=`\n ${matchEmptySvg}\n <span class="empty-label">${e.options.dialogLabels.pcPointDialog.emptyLabel}</span>\n `,t.pointDialogElm.appendChild(t.pointDialogEmptyElm),domItVisible(t.pointDialogEmptyElm)),t.containerDialogElm.appendChild(t.pointDialogElm)}createH5Dialog(){const{options:t,chatEvent:e}=this.target,{needDialog:i,dialogLabels:n}=t;if(!i)return;const{h5Elms:s}=this;s.dialogElm=document.createElement("div"),updateElmClass(s.dialogElm,"call-user-popup",!0),s.dialogElm.innerHTML=`\n <div class="call-user-popup-main">\n <div class="call-user-popup-header">\n <span class="popup-show">${n.h5Dialog.cancelLabel}</span>\n <span class="popup-title">${n.h5Dialog.title}</span>\n <span class="popup-check">${n.h5Dialog.confirmLabel}</span>\n </div>\n <div class="call-user-popup-search">\n ${searchSvg}\n <input class="call-user-popup-search-input"\n placeholder="${n.h5Dialog.searchPlaceholder}"\n type="text">\n </div>\n <div class="call-user-popup-body"></div>\n </div>\n `;const a=async()=>{s.dialogElm.className=s.dialogElm.className.replace(/ chat-view-show/g," chat-view-hidden"),s.dialogSearchElm.value="",await sleep(260),domItVisible(s.dialogElm),updateElmClass(document.body,"disable-scroll"),t.asyncMatch&&this.target.updateUserList([]),this.target.chatInput.restCursorPos(this.target.chatInput.vnode,this.target.chatInput.cursorIndex),this.target.chatInput.viewIntoPoint()};s.dialogElm.onclick=a;const l=s.dialogElm.querySelector(".call-user-popup-main");l.onclick=t=>{t.stopPropagation()},s.dialogShowElm=s.dialogElm.querySelector(".popup-show"),s.dialogShowElm.onclick=a,s.dialogCheckElm=s.dialogElm.querySelector(".popup-check"),s.dialogCheckElm.onclick=async()=>{if(s.dialogCheckElm.classList.contains("disabled"))return;const e=s.dialogElm.querySelectorAll(".user-popup-check-item-check")||[];if(0===e.length)return void await a();if(Array.prototype.some.call(e,t=>"isALL"===t.getAttribute("data-set-id")))return await this.target.onceSetTag({[t.userProps.id]:"isALL",[t.userProps.name]:t.dialogLabels.h5Dialog.callEveryLabel}),void await a();const i=Array.from(e,t=>t.getAttribute("data-set-id")),n=t.userList.filter(e=>-1!==i.indexOf(String(e[t.userProps.id])));await this.target.batchSetTag(n),await a()},s.dialogMainElm=s.dialogElm.querySelector(".call-user-popup-body"),s.dialogEmptyElm=document.createElement("div"),updateElmClass(s.dialogEmptyElm,"call-user-popup-empty",!0),this.h5Elms.dialogEmptyElm.innerHTML=`\n ${searchEmptySvg}\n <span class="empty-label">${t.dialogLabels.h5Dialog.searchEmptyLabel}</span>\n `,domItVisible(s.dialogEmptyElm),l.appendChild(s.dialogEmptyElm),t.asyncMatch&&(s.dialogLoadingElm=document.createElement("div"),updateElmClass(s.dialogLoadingElm,"call-user-popup-loading",!0),s.dialogLoadingElm.innerHTML=antdLoading,domItVisible(s.dialogLoadingElm),l.appendChild(s.dialogLoadingElm)),s.dialogSearchElm=s.dialogElm.querySelector(".call-user-popup-search-input"),s.dialogSearchElm.oninput=debounce(i=>{const n=String(i.target.value||"").replace(/'/g,"").trim();if(t.asyncMatch){e.matchKey++;const t=e.matchKey;this.target.updateUserList([]),domItVisible(s.dialogLoadingElm,!0),domItVisible(s.dialogEmptyElm);const i=e.triggerChatEvent("atMatch",n).find(t=>t&&t instanceof Promise);return void(i&&i.then(i=>{t===e.matchKey&&(domItVisible(s.dialogLoadingElm),!i||i.length<=0?domItVisible(s.dialogEmptyElm,!0,"flex"):this.target.updateUserList(i))}))}const a=[];Array.from(this.h5Elms.dialogMainElm.children,t=>{if(!n)return domItVisible(t,!0,"flex"),void a.push(t);pinyinMatch(t.getAttribute("data-set-name")||"",t.getAttribute("data-set-pinyin")||"",n)?(domItVisible(t,!0,"flex"),a.push(t)):domItVisible(t)}),domItVisible(this.h5Elms.dialogEmptyElm,!a.length,"flex")},200),domItVisible(s.dialogElm),document.body.appendChild(s.dialogElm)}updatePCUser(){const{pcElms:t,target:e}=this;t.pointDialogMainElm.innerHTML="",t.pointDialogActiveElm=void 0;const i=document.createDocumentFragment();if(this.target.options.needCallEvery){const t=document.createElement("div");updateElmClass(t,"call-user-dialog-item",!0),t.setAttribute("data-set-id","isALL"),this.userSelectStyleAndEvent(t,{id:"isALL",name:e.options.dialogLabels.pcPointDialog.callEveryLabel}),t.innerHTML=`\n <span class="call-user-dialog-item-sculpture">\n <span style="transform: scale(0.75)">@</span>\n </span>\n <span class="call-user-dialog-item-name">${e.options.dialogLabels.pcPointDialog.callEveryLabel}(${e.options.reformList.length})</span>\n `,i.appendChild(t)}if(e.options.reformList.forEach(t=>{const e=document.createElement("div");updateElmClass(e,"call-user-dialog-item",!0),e.setAttribute("data-set-id",t.id),this.userSelectStyleAndEvent(e,t),this.getUserHtmlTemplate(e,t),i.appendChild(e)}),t.pointDialogMainElm.appendChild(i),t.pointDialogUsersElm=[],Array.from(t.pointDialogMainElm.children||[],(e,i)=>{t.pointDialogUsersElm.push({index:i,elm:e})}),e.options.asyncMatch)return;t.checkDialogUsersElm.innerHTML=`\n <div class="checkbox-dialog-check-item" data-set-value="ALL">\n <input type="checkbox" value>\n <span class="checkbox-dialog-check-item-inner"></span>\n <div class="checkbox-dialog-check-item-label">${e.options.dialogLabels.pcPCheckDialog.checkAllLabel}</div>\n </div>\n `;const n=document.createDocumentFragment();e.options.reformList.forEach(t=>{const e=document.createElement("div");updateElmClass(e,"checkbox-dialog-check-item",!0),e.setAttribute("data-set-value",t.id),e.innerHTML='\n <input type="checkbox" value>\n <span class="checkbox-dialog-check-item-inner"></span>\n ',this.getUserHtmlTemplate(e,t),n.appendChild(e)}),t.checkDialogUsersElm.appendChild(n),t.checkDialogUsersElm&&t.checkDialogUsersElm.children.length&&Array.from(t.checkDialogUsersElm.children,t=>{t.onclick=()=>{const i=t.getAttribute("data-set-value")||"",n=e.options.reformList.find(t=>t.id===i),s=-1===t.className.indexOf("checkbox-dialog-check-item-check");"ALL"===i?this.checkboxRows=s?e.options.reformList.map(t=>t):[]:s?this.checkboxRows.push(n):this.checkboxRows=this.checkboxRows.filter(t=>t.id!==i),this.updateCheckDialogTags()}}),t.checkDialogSearchResultElm.innerHTML="";const s=document.createDocumentFragment();e.options.reformList.forEach(t=>{const i=document.createElement("div");updateElmClass(i,"checkbox-dialog-check-item",!0),i.setAttribute("data-set-id",t.id);const n=document.createElement("div");updateElmClass(n,"checkbox-dialog-check-item-label",!0),this.getUserHtmlTemplate(n,t),i.appendChild(n),i.onclick=()=>{domItVisible(this.pcElms.checkDialogSearchResultElm);const t=i.getAttribute("data-set-id")||"";if(this.pcElms.checkDialogSearchInputElm.value="",this.pcElms.checkDialogSearchInputElm.focus(),this.checkboxRows.some(e=>e.id===t))return;const n=e.options.reformList.find(e=>e.id===t);n&&this.checkboxRows.push(n),this.updateCheckDialogTags()},s.appendChild(i)});const a=document.createElement("div");updateElmClass(a,"checkbox-dialog-search-empty",!0),a.innerText=e.options.dialogLabels.pcPCheckDialog.searchEmptyLabel,s.appendChild(a),t.checkDialogSearchResultElm.appendChild(s)}updateH5User(){const{h5Elms:t,target:e}=this;t.dialogMainElm.innerHTML="";const i=e.options.reformList&&e.options.reformList.length>0,n=document.createDocumentFragment(),s=document.createElement("span");if(s.innerHTML='\n <input type="checkbox" value>\n <span class="user-popup-check-item-inner"></span>\n ',i){const t=document.createElement("div");e.options.needCallEvery&&(updateElmClass(t,"call-user-popup-item",!0),t.setAttribute("data-set-id","isALL"),t.innerHTML=`\n <span class="call-user-dialog-item-sculpture">\n <span style="transform: scale(0.75)">@</span>\n </span>\n <span class="call-user-dialog-item-name">${e.options.dialogLabels.h5Dialog.callEveryLabel}(${e.options.reformList.length})</span>\n `,t.appendChild(s.cloneNode(!0)),t.onclick=()=>{const e=!t.classList.contains("user-popup-check-item-check");Array.from(this.h5Elms.dialogMainElm.children,t=>{updateElmClass(t,"user-popup-check-item-check",e)}),updateElmClass(this.h5Elms.dialogCheckElm,"disabled",!e)},n.appendChild(t)),e.options.reformList.forEach((e,i)=>{const a=document.createElement("div");updateElmClass(a,"call-user-popup-item",!0),a.setAttribute("data-set-id",e.id),a.setAttribute("data-set-name",e.name),a.setAttribute("data-set-pinyin",e.pinyin||""),this.getUserHtmlTemplate(a,e),a.appendChild(s.cloneNode(!0)),n.appendChild(a),a.onclick=e=>{const i=!a.classList.contains("user-popup-check-item-check");updateElmClass(a,"user-popup-check-item-check",i);const n=Array.prototype.every.call(this.h5Elms.dialogMainElm.children,t=>t.classList.contains("user-popup-check-item-check")||"isALL"===t.getAttribute("data-set-id"));updateElmClass(t,"user-popup-check-item-check",n);const s=Array.prototype.some.call(this.h5Elms.dialogMainElm.children,t=>t.classList.contains("user-popup-check-item-check"));updateElmClass(this.h5Elms.dialogCheckElm,"disabled",!s)}})}t.dialogMainElm.appendChild(n)}updateCheckDialogTags(){const t=this.checkboxRows.map(t=>t.id),e=[],i=[],n=document.createElement("div");n.className="check-empty",n.innerHTML=`\n ${checkEmptySvg}\n <span class="check-empty-label">${this.target.options.dialogLabels.pcPCheckDialog.checkEmptyLabel}</span>\n `,Array.from(this.pcElms.checkDialogTagsElm.children,n=>{const s=n.getAttribute("data-set-value");-1===t.indexOf(s)?i.push(n):e.push(s)}),Array.from(this.pcElms.checkDialogUsersElm.children,(e,i)=>{if(0===i)return void updateElmClass(e,"checkbox-dialog-check-item-check",t.length===this.target.options.reformList.length);const n=e.getAttribute("data-set-value");updateElmClass(e,"checkbox-dialog-check-item-check",-1!==t.indexOf(n))}),i.forEach(t=>{this.pcElms.checkDialogTagsElm.removeChild(t)});updateElmClass(this.pcElms.checkDialogElm.querySelector(".btn-submit"),"disabled",t.length<=0),t.length||this.pcElms.checkDialogTagsElm.appendChild(n);const s=this.checkboxRows.filter(t=>-1===e.indexOf(t.id));if(!s.length)return;const a=document.createDocumentFragment();s.forEach(t=>{const e=document.createElement("div");e.setAttribute("class","checkbox-dialog-tag-item"),e.setAttribute("data-set-value",t.id),e.innerHTML=`\n <span>${t.name}</span>\n `;const i=document.createElement("span");i.setAttribute("class","checkbox-dialog-tag-item-close"),i.innerHTML="⛌",i.onclick=()=>{const t=e.getAttribute("data-set-value");this.checkboxRows=this.checkboxRows.filter(e=>e.id!==t),this.updateCheckDialogTags()},e.appendChild(i),a.appendChild(e)}),this.pcElms.checkDialogTagsElm.appendChild(a)}userSelectStyleAndEvent(t,e){t.addEventListener("click",async i=>{const{options:n}=this.target;if(i.stopPropagation(),this.updatePointActiveUserElm(t),this.isPointSearchMode||n.asyncMatch)await this.target.matchSetTag(e);else{const t=n.userList.find(t=>String(t[n.userProps.id])===e.id);await this.target.onceSetTag(t)}this.exitPointDialog()})}bindCustomTrigger(){Object.values(this.pcElms.customTagDialogElms).forEach(t=>{this.pcElms.containerDialogElm.removeChild(t)}),this.pcElms.customTagDialogElms={},this.customTags={},this.target.options.customTrigger.forEach(t=>{t.tagList&&t.tagList.length>0&&(this.customTags[t.prefix]=t.tagList.map(t=>({id:String(t.id),name:String(t.name),pinyin:String(t.pinyin||"")})),this.createCustomTagDialog(t))})}createCustomTagDialog(t){const e=document.createElement("div");e.setAttribute("class","call-tag-dialog"),domItVisible(e);const i=document.createElement("div");i.setAttribute("class","call-tag-dialog-header"),i.innerHTML=`<span class="call-tag-dialog-header-title">${t.dialogTitle||t.prefix}</span>`,e.appendChild(i);const n=document.createElement("div");n.setAttribute("class","call-tag-dialog-main"),t.tagList.forEach(t=>{const e=document.createElement("div");e.setAttribute("class","call-tag-dialog-item"),e.setAttribute("data-set-id",t.id);const i=document.createElement("span");i.setAttribute("class","call-tag-dialog-item-name"),i.innerHTML=t.name,e.appendChild(i),e.addEventListener("click",async i=>{i.stopPropagation(),this.updateActiveCustomTagElm(e),this.isPointSearchMode?await this.target.matchSetCustomTag(t):await this.target.onceSetCustomTag(t),this.exitCustomTagDialog()}),n.appendChild(e)}),e.appendChild(n),this.pcElms.containerDialogElm.appendChild(e),this.pcElms.customTagDialogElms[t.prefix]=e}getUserHtmlTemplate(t,e){const i=document.createElement("span");if(i.setAttribute("class","call-user-dialog-item-sculpture "+(e.avatar?"is-avatar":"")),e.avatar){const t=new Image;t.alt="",t.src=String(e.avatar),i.appendChild(t)}else i.innerHTML=`<span style="transform: scale(0.75)">${e.name.slice(-2)}</span>`;t.appendChild(i);const n=document.createElement("span");n.setAttribute("class","call-user-dialog-item-name"),n.innerHTML=e.name,t.appendChild(n)}updatePointActiveUserElm(t,e=!1){if(this.pcElms.pointDialogActiveElm&&updateElmClass(this.pcElms.pointDialogActiveElm,"call-user-dialog-item-active"),this.pcElms.pointDialogActiveElm=t,t&&(updateElmClass(t,"call-user-dialog-item-active",!0),e)){const e=Array.prototype.filter.call(this.pcElms.pointDialogMainElm.children,t=>-1===t.className.indexOf("user-no-match")),i=t.clientHeight,n=Array.prototype.indexOf.call(e,t)+1-Math.ceil(Math.floor(this.pcElms.pointDialogMainElm.clientHeight/i)/2);this.pcElms.pointDialogMainElm.scrollTop=n>0?n*i:0}}updateActiveCustomTagElm(t,e=!1){if(this.pcElms.customTagDialogActiveElm&&updateElmClass(this.pcElms.customTagDialogActiveElm,"call-tag-dialog-item-active"),this.pcElms.customTagDialogActiveElm=t,t&&(updateElmClass(t,"call-tag-dialog-item-active",!0),e)){const e=this.pcElms.customTagDialogElms[this.pcElms.customTagDialogTagKey].children[1],i=Array.prototype.filter.call(e.children,t=>-1===t.className.indexOf("tag-no-match")),n=t.clientHeight,s=Array.prototype.indexOf.call(i,t)+1-Math.ceil(Math.floor(e.clientHeight/n)/2);e.scrollTop=s>0?s*n:0}}showPointDialog(t){this.exitSelectDialog(),this.exitCustomTagDialog(),this.exitPointDialog(),this.isPointSearchMode=!!t;let e=null;this.pcElms.pointDialogUsersElm.forEach(i=>{const n=i.elm,s=n.getAttribute("data-set-id"),a=t&&t.every(t=>t.id!==s);e||a||(e=n),updateElmClass(n,"user-no-match",a)}),null!==e&&this.updatePointActiveUserElm(e),domItVisible(this.pcElms.pointDialogCheckElm,!this.target.options.asyncMatch&&!this.isPointSearchMode),domItVisible(this.pcElms.pointDialogElm,!0),this.target.chatEvent.debounceEvents.dialogMoveToRange(this.pcElms.pointDialogElm),this.pcElms.pointDialogMainElm.scrollTop=0}showCustomTagDialog(t,e){this.exitSelectDialog(),this.exitCustomTagDialog(),this.exitPointDialog(),this.isPointSearchMode=!!e,this.pcElms.customTagDialogTagKey=t;const i=this.pcElms.customTagDialogElms[t],n=i.children[1];let s=null;Array.from(n.children,t=>{const i=t.getAttribute("data-set-id"),n=e&&e.every(t=>t.id!==i);s||n||(s=t),updateElmClass(t,"tag-no-match",n)}),null!==s&&this.updateActiveCustomTagElm(s),domItVisible(i,!0),this.target.chatEvent.debounceEvents.dialogMoveToRange(i),i.children[1].scrollTop=0}exitPointDialog(){this.updatePointActiveUserElm(),this.target.options.asyncMatch&&this.target.updateUserList([]),domItVisible(this.pcElms.pointDialogElm)}exitCustomTagDialog(){this.updateActiveCustomTagElm();for(const t in this.pcElms.customTagDialogElms)domItVisible(this.pcElms.customTagDialogElms[t])}ruleShowPointDialog(){const{options:t}=this.target;t.needDialog&&t.reformList.length>0&&(this.isExternalCallPopup=!1,this.showPointDialog())}showPlaceholder(){domItVisible(this.placeholderElm,this.target.isEmpty()),this.offsetTipElm()}bindSelectList(){Object.values(this.pcElms.selectDialogElms).forEach(t=>{this.pcElms.containerDialogElm.removeChild(t)}),this.pcElms.selectDialogElms={},this.selectTags={},this.target.options.selectList.forEach(t=>{t.options&&t.options.length>0&&(this.selectTags[t.key]=t.options.map(t=>({id:String(t.id),name:String(t.name),preview:String(t.preview||"")})),this.createSelectDialog(t))})}createSelectDialog(t){const e=document.createElement("div");e.setAttribute("class","chat-select-dialog"),domItVisible(e);const i=document.createElement("div");i.setAttribute("class","chat-select-dialog-header"),i.innerHTML=`<span class="chat-select-dialog-header-title">${t.dialogTitle||t.key}</span>`,e.appendChild(i);const n=document.createElement("div");n.setAttribute("class","chat-select-dialog-main"),t.options.forEach(t=>{const e=document.createElement("div");if(e.setAttribute("class","chat-select-dialog-item"),e.setAttribute("data-set-id",t.id),t.preview){const i=document.createElement("img");i.setAttribute("class","chat-select-dialog-preview"),i.src=String(t.preview),e.appendChild(i)}const i=document.createElement("span");i.setAttribute("class","chat-select-dialog-name"),i.textContent=t.name;const s=document.createElement("span");s.setAttribute("class","chat-select-dialog-check"),s.innerHTML=checkSvg,domItVisible(s),i.appendChild(s),e.appendChild(i),e.onclick=async()=>{await this.target.setSelectTag(t)},n.appendChild(e)}),e.appendChild(n);const s=document.createElement("div");s.setAttribute("class","chat-select-arrow"),e.appendChild(s),this.pcElms.containerDialogElm.appendChild(e),this.pcElms.selectDialogElms[t.key]=e}exitSelectDialog(){for(const t in this.pcElms.selectDialogElms)domItVisible(this.pcElms.selectDialogElms[t]);this.pcElms.selectDialogKey="",this.pcElms.selectDialogAim&&(updateElmClass(this.pcElms.selectDialogAim,"aim"),this.pcElms.selectDialogAim=null)}createTipElm(t){this.tipElm||(this.tipElm=document.createElement("div")),updateElmClass(this.tipElm,"chat-tip-wrap",!0),this.tipElm.innerHTML=`\n <div class="chat-tip-tag">\n <span class="chat-tip-tag-txt">${t.tagLabel||"--"}</span>\n <span class="chat-tip-tag-close">\n ${this.target.deviceInfo.isPc?closeSvg:""}\n </span>\n </div>\n `,this.target.options.elm.appendChild(this.tipElm);const e=this.tipElm.children[0],i=(e.clientHeight-this.target.chatInput.NODE_HEIGHT)/2;if(this.tipElm.style.top=`-${i}px`,e.onclick=()=>{this.target.deviceInfo.isPc&&this.target.closeTipTag()},e.onmouseenter=()=>{if(this.pcElms.tipContainerPopoverElm&&this.pcElms.tipPopoverElm){domItVisible(this.pcElms.tipPopoverElm,!0);const t=this.pcElms.tipContainerPopoverElm.getBoundingClientRect();this.rects.tipRect=this.tipElm.getBoundingClientRect();const i=(this.pcElms.tipPopoverElm.clientWidth-(this.tipElm.clientWidth+(this.tipElm.clientWidth-e.clientWidth)))/2;this.pcElms.tipPopoverElm.style.left=-i+"px",this.pcElms.tipPopoverElm.style.bottom=t.y-this.rects.tipRect.y+"px",this.pcElms.tipPopoverElm.style.transform=e.style.transform}},e.onmouseleave=()=>{this.pcElms.tipPopoverElm&&domItVisible(this.pcElms.tipPopoverElm)},this.offsetApplyElm(),this.target.deviceInfo.isPc){this.pcElms.tipContainerPopoverElm||(this.pcElms.tipContainerPopoverElm=document.createElement("div"),updateElmClass(this.pcElms.tipContainerPopoverElm,"chat-tip-dialog",!0)),this.pcElms.tipPopoverElm||(this.pcElms.tipPopoverElm=document.createElement("div")),updateElmClass(this.pcElms.tipPopoverElm,"chat-tip-popover",!0),this.pcElms.tipPopoverElm.innerHTML=`\n <div class="chat-tip-popover-main">\n <span class="chat-tip-popover-txt">${t.popoverLabel||"--"}</span>\n <span class="chat-tip-popover-code ${t.codeLabel?"":"chat-view-show"}">${t.codeLabel||"--"}</span>\n </div>\n <div class="chat-tip-popover-arrow"></div>\n `,this.pcElms.tipContainerPopoverElm.appendChild(this.pcElms.tipPopoverElm),domItVisible(this.pcElms.tipPopoverElm);const{elm:e}=this.target.options;e.parentElement&&(e.nextElementSibling?e.parentElement.insertBefore(this.pcElms.tipContainerPopoverElm,e.nextElementSibling):e.parentElement.appendChild(this.pcElms.tipContainerPopoverElm))}this.target.chatEvent.triggerChatEvent("tipTagState",!0)}createCustomTipElm(t){this.tipElm||(this.tipElm=document.createElement("div")),updateElmClass(this.tipElm,"chat-tip-wrap",!0),this.tipElm.innerHTML=`<div class="chat-custom-tip">${t}</div>`,this.target.options.elm.appendChild(this.tipElm);const e=this.tipElm.children[0],i=(e.clientHeight-this.target.chatInput.NODE_HEIGHT)/2;return this.tipElm.style.top=`-${i}px`,this.offsetApplyElm(),this.target.chatEvent.triggerChatEvent("tipTagState",!0),e.children[0]}offsetApplyElm(){if(!this.tipElm)return;const t=this.richText.children[0].children[0];this.rects.tipRect=this.tipElm.getBoundingClientRect();const e=this.rects.tipRect;this.placeholderElm.style.paddingLeft=e.width+"px",t.style.paddingLeft=e.width-t.offsetLeft+"px",this.offsetTipElm()}offsetTipElm(){if(this.tipElm){const t=this.richText.children[0].children[0];t.style.paddingLeft=this.rects.tipRect.width-t.offsetLeft+"px",this.target.nextTick(()=>{if(this.tipElm){const t=this.tipElm.children[0],e=this.richText.children[0].children[0];t.style.transform=`translateY(${e.offsetTop-this.target.chatInput.NODE_PADDING_DIFF}px)`}})}}removeTipElm(){this.tipElm&&(this.target.options.elm.removeChild(this.tipElm),this.tipElm=null),this.pcElms.tipContainerPopoverElm&&(this.pcElms.tipContainerPopoverElm.removeChild(this.pcElms.tipPopoverElm),this.target.options.elm.parentElement.removeChild(this.pcElms.tipContainerPopoverElm),this.pcElms.tipContainerPopoverElm=null,this.pcElms.tipPopoverElm=null);const t=this.richText.children[0].children[0];this.placeholderElm.style.removeProperty("padding-left"),t.style.removeProperty("padding-left"),this.target.chatInput.setRangeLastRecord(),this.target.chatEvent.triggerChatEvent("tipTagState",!1)}}class ChatInput{constructor(t){__publicField(this,"target"),__publicField(this,"richText"),__publicField(this,"vnode"),__publicField(this,"cursorIndex"),__publicField(this,"inputTag_vnode"),__publicField(this,"inputTag_cursorIndex"),__publicField(this,"lastCursorType","gridInput"),__publicField(this,"needCallSpace",!1),__publicField(this,"VOID_KEY","\ufeff"),__publicField(this,"ZERO_WIDTH_KEY","​"),__publicField(this,"INPUT_TAG_WRAP_KEY","​\n​"),__publicField(this,"NODE_HEIGHT",24),__publicField(this,"NODE_PADDING_DIFF",10),this.target=t,this.richText=t.chatElement.richText,this.initEditor()}initEditor(t=!1,e){if(t||this.getNodeEmpty(this.richText)){this.richText.innerHTML="";const i=this.getGridElm();this.richText.appendChild(i);const n=i.children[0].children[0];e&&(n.textContent=e,n.setAttribute("data-set-empty","false"));const s=n.childNodes[0];t||this.target.options.autoFocus?this.restCursorPos(s,s.textContent===this.VOID_KEY?1:s.textContent.length):this.updateGridInputCursor(s,s.textContent.length),this.target.nextTick(()=>{const t=i.getBoundingClientRect();this.NODE_HEIGHT=t.height,this.NODE_PADDING_DIFF=t.top-this.target.options.elm.getBoundingClientRect().top})}}onceCall(t){return new Promise(e=>{const i=this.createChatTagElm(t,"@","at-user","user-id");this.replaceRegContent(i),e()})}onceSearchCall(t,e){return new Promise(i=>{const n=this.createChatTagElm(t,"@","at-user","user-id");this.replaceRegContent(n,e),i()})}onceCustomCall(t,e,i){return new Promise(n=>{const s=this.createChatTagElm(t,i,"at-tag","tag-id");s.children[0].setAttribute("data-set-prefix",i),this.replaceRegContent(s,e),n()})}getCurrentCursorKey(){if(this.updateNodeCursor(),!this.vnode||this.vnode.nodeType!==Node.TEXT_NODE)return"";return(this.vnode.textContent||"")[this.cursorIndex-1]}getRangeRect(){let t=0,e=0;const i=getSelection();if(i.focusNode.nodeType!==Node.TEXT_NODE)return null;const n=i.getRangeAt(0).getClientRects()[0];return n&&(t=n.x,e=n.y),{x:t,y:e}}createChatTagElm(t,e,i,n){const s=document.createElement("span");return s.className=i,s.setAttribute(`data-${n}`,String(t.id)),s.textContent=`${e}${t.name}${this.needCallSpace?" ":""}`,this.createNewDom(s)}createNewDom(t){const e=document.createElement("span");return e.className="chat-tag",e.setAttribute("contenteditable","false"),e.setAttribute("data-set-richType",RICH_TAG),e.appendChild(t),e}replaceRegContent(t,e=!0){const i=this.vnode.textContent;let n;n="boolean"==typeof e?i.slice(0,e?this.cursorIndex-1:this.cursorIndex):i.slice(0,e-1),0===n.length?(this.vnode.parentElement.setAttribute("data-set-empty","true"),this.vnode.textContent=this.VOID_KEY):this.vnode.textContent=n;let s=i.slice(this.cursorIndex);const a=this.vnode.parentNode.parentNode,l=a.nextSibling;l?a.parentNode.insertBefore(t,l):a.parentNode.appendChild(t);const o=t.previousSibling.childNodes[0],r=o.childNodes[1];r&&o.removeChild(r);const c=this.getGridElm(!0),h=c.childNodes[0];s&&s!==this.VOID_KEY&&(h.setAttribute("data-set-empty","false"),h.innerHTML=s);const d=h.childNodes[1];t.nextSibling?(d&&h.removeChild(d),a.parentNode.insertBefore(c,t.nextSibling)):a.parentNode.appendChild(c),this.restCursorPos(h.childNodes[0])}batchReplaceRegContent(t=[],e=!0){return new Promise(i=>{let n=`<span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="true">${this.VOID_KEY}</span></span>`;t.forEach(t=>{n+=`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-user" data-user-id="${t.id}" contentEditable="false">@${t.name}${this.needCallSpace?" ":""}</span></span><span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="true">${this.VOID_KEY}</span></span>`});const s=document.createElement("div");s.innerHTML=n,this.insetRangeGrid(s,e?1:0),i()})}switchRange(t){var e,i;let{focusNode:n,focusOffset:s}=getSelection();n.getAttribute&&n.getAttribute("data-set-richType")===RICH_INPUT&&(n=n.childNodes[0]);let a,l,o=!1;if(n.nodeType===Node.TEXT_NODE){const r=n.textContent.length,c=n.parentNode.parentNode;switch(t){case"ArrowLeft":if(s>0&&n.textContent!==this.VOID_KEY){l=s-1,a=n;break}const t=c.previousSibling;if(t&&t.children[0].classList.contains("at-input")){a=t.children[0].children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:a.textContent.length,o=!0;break}const h=null==(e=null==c?void 0:c.previousSibling)?void 0:e.previousSibling;if(h)a=h.childNodes[0].childNodes[0],l=a.textContent.length;else{const t=c.parentNode.previousSibling;if(t){a=t.lastChild.childNodes[0].childNodes[0],l=a.textContent.length}}break;case"ArrowRight":if(s<r&&n.textContent!==this.VOID_KEY){l=s+1,a=n;break}const d=c.nextSibling;if(d&&d.children[0].classList.contains("at-input")){a=d.children[0].children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0,o=!0;break}const p=null==(i=null==c?void 0:c.nextSibling)?void 0:i.nextSibling;if(p)a=p.childNodes[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0;else{const t=c.parentNode.nextSibling;t&&(a=t.childNodes[0].childNodes[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0)}}}(l||0===l)&&(o?this.setInputTagRange(a,l):this.restCursorPos(a,l))}getGridElm(t=!1){const e=document.createElement("span");if(e.setAttribute("data-set-richType",RICH_MARK),e.innerHTML=`<span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="true">${this.VOID_KEY}<br></span>`,t)return e;const i=document.createElement("p");return i.className="chat-grid-wrap",i.setAttribute("data-set-richType",RICH_GRID),i.appendChild(e),i}updateGrid(){const t=getSelection(),e=t.focusNode;if(!e)return;const i=e.parentNode;let n,s,a,l;switch(i.getAttribute("data-set-richType")){case RICH_WRAP:if(!e.getAttribute||e.getAttribute("data-set-richType")!==RICH_GRID)break;if(n=e.childNodes[t.focusOffset],!n||n.getAttribute("data-set-richType")===RICH_TAG){const t=this.getGridElm(!0),i=t.children[0];n?(i.removeChild(i.childNodes[1]),e.insertBefore(t,n)):e.appendChild(t),this.restCursorPos(i.childNodes[0]);break}if(n.tagName&&"BR"===n.tagName.toLocaleUpperCase()){const t=this.getGridElm(!0),i=t.children[0];e.insertBefore(t,n),e.removeChild(n),t.nextElementSibling&&t.children[0].removeChild(t.children[0].childNodes[1]),this.restCursorPos(i.childNodes[0],i.childNodes[0].textContent.length)}break;case RICH_MARK:const o=i.parentNode,r=Array.prototype.indexOf.call(o.childNodes,i);if(-1===r)break;if(0===r){const e=t.focusNode;e.setAttribute("data-set-empty","true"),e.innerHTML=`${this.VOID_KEY}<br>`,n=e.childNodes[0],this.restCursorPos(n,n.textContent.length);break}let c,h=i.previousSibling;h.getAttribute("data-set-richType")===RICH_TAG?(c=h.previousSibling,o.removeChild(h),o.removeChild(i)):(c=i.previousSibling,o.removeChild(i));n=c.childNodes[0].childNodes[0],n.textContent===this.VOID_KEY&&n.parentNode.appendChild(document.createElement("br")),this.restCursorPos(n,n.textContent.length);break;case RICH_INPUT:if(l=i.parentNode,a=l.parentNode,this.getNodeEmpty(i)){i.setAttribute("data-set-empty","true"),a.childNodes[a.childNodes.length-1]===l&&(i.innerHTML=`${this.VOID_KEY}<br>`),n=i.childNodes[0],this.restCursorPos(n,n.textContent.length);break}if("true"===String(i.getAttribute("data-set-empty"))){i.setAttribute("data-set-empty","false"),n=i.childNodes[0],this.target.chatEvent.isIMEModel?(i.childNodes[1]&&i.removeChild(i.childNodes[1]),n.textContent===this.VOID_KEY&&i.setAttribute("data-set-empty","true")):i.textContent=n.textContent.replace(new RegExp(this.VOID_KEY,"g"),"");const t=i.childNodes[0];this.restCursorPos(t,t.textContent.length)}if(s=i.parentNode.nextSibling,s&&s.nodeType===Node.TEXT_NODE){let t=s.textContent,e=this.getGridElm(!0);e.childNodes[0].textContent=t,e.childNodes[0].setAttribute("data-set-empty","false"),s.parentNode.insertBefore(e,s),s.parentNode.removeChild(s),s=e}s&&s.getAttribute("data-set-richType")===RICH_MARK&&this.markMerge(i.parentNode,s)}}getNodeEmpty(t){const e=new RegExp(`^(${this.ZERO_WIDTH_KEY}|<br>|${this.VOID_KEY})+$`);return!t.innerHTML||e.test(t.innerHTML)}setWrap(t=!0){const e=getSelection();let{focusNode:i,focusOffset:n}=e;if(i.nodeType!==Node.TEXT_NODE){if(!i.getAttribute||i.getAttribute("data-set-richType")!==RICH_INPUT)return;i=i.childNodes[0]}const s=i.textContent.slice(n),a=i.parentNode.parentNode,l=a.parentNode,o=Array.prototype.indexOf.call(l.childNodes,a),r=Array.prototype.slice.call(l.childNodes,o+1),c=this.getGridElm();let h=c.children[0].children[0].childNodes[0];(s||r.length>0)&&h.parentNode.removeChild(h.parentNode.childNodes[1]),s&&s!==this.VOID_KEY&&(i.textContent=i.textContent.slice(0,n),h.textContent=s,h.parentElement.setAttribute("data-set-empty","false")),r.forEach(t=>{l.removeChild(t),c.appendChild(t)});const d=l.lastChild.childNodes[0],p=c.lastChild.childNodes[0];if(d.childNodes.length<=1){const t=d.childNodes[0];t.textContent&&t.textContent!==this.VOID_KEY||(d.innerHTML=`${this.VOID_KEY}<br>`,d.setAttribute("data-set-empty","true"))}if(p.parentElement.getAttribute("data-set-richType")!==RICH_MARK)c.appendChild(this.getGridElm(!0));else if(p.childNodes.length<=1){const t=p.childNodes[0];t.textContent&&t.textContent!==this.VOID_KEY||(p.innerHTML=`${this.VOID_KEY}<br>`,p.setAttribute("data-set-empty","true"),h=c.children[0].children[0].childNodes[0])}l.nextSibling?this.richText.insertBefore(c,l.nextSibling):this.richText.appendChild(c),t&&this.restCursorPos(h,h.textContent===this.VOID_KEY?1:0)}selectAll(){const t=document.createRange(),e=this.richText.children[0].children[0].childNodes[0].childNodes[0],i=this.richText.lastElementChild.lastElementChild.childNodes[0].childNodes[0];t.setStart(e,0),t.setEnd(i,i.textContent.length);const n=getSelection();n.removeAllRanges(),n.addRange(t)}selectRegionMerge(){const t=getSelection();if(t.isCollapsed||t.rangeCount<=0)return;const e=t.getRangeAt(0);if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startContainer===e.endContainer){const t=e.startContainer;if(t.length===e.endOffset-e.startOffset){const e=t.parentNode,i=e.parentNode===e.parentNode.parentNode.lastChild;e.setAttribute("data-set-empty","true"),e.innerHTML="\ufeff"+(i?"<br>":""),this.restCursorPos(e.childNodes[0])}else e.deleteContents()}else if(e.commonAncestorContainer&&e.commonAncestorContainer.getAttribute("data-set-richType")===RICH_GRID){const t=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentNode.parentNode:e.startContainer,i=e.endContainer.nodeType===Node.TEXT_NODE?e.endContainer.parentNode.parentNode:e.endContainer;e.deleteContents(),t.getAttribute("data-set-richType")===i.getAttribute("data-set-richType")&&this.markMerge(t,i)}else if(e.commonAncestorContainer===e.startContainer&&e.startContainer===e.endContainer)this.initEditor(!0);else{const t=t=>{if(t.nodeType===Node.TEXT_NODE)return t.parentNode.parentNode.parentNode;switch(t.getAttribute("data-set-richType")){case RICH_INPUT:return t.parentNode.parentNode;case RICH_MARK:return t.parentNode;case RICH_GRID:return t;default:return null}},i=t(e.startContainer),n=t(e.endContainer);if(!i||!n)return;e.deleteContents(),this.gridMerge(i,n)}return!0}gridElmMerge(){const t=getSelection(),{focusNode:e,focusOffset:i,isCollapsed:n}=t;if(!e)return this.restCursorPos(this.vnode,this.cursorIndex),!1;if(i>1)return!1;if(!n)return!1;const s=(t,e)=>(t.parentNode===this.richText||t===t.parentNode.childNodes[0])&&(-1!==Array.prototype.indexOf.call(this.richText.childNodes,t)?t:!(e>=6)&&s(t.parentNode,e+1)),a=s(e,0);if(!a||a===this.richText.childNodes[0]||1===i&&"false"===a.children[0].children[0].getAttribute("data-set-empty"))return!1;const l=a.previousSibling;return this.gridMerge(l,a),!0}delMarkRule(){const t=getSelection(),e=t.focusNode;if(!e)return this.restCursorPos(this.vnode,this.cursorIndex),!1;const i=e.textContent,n=e.parentNode,s=n.parentNode,a=s.parentNode;if(!t.isCollapsed||n.getAttribute("data-set-richType")!==RICH_INPUT)return!1;if(i&&1===i.length&&s!==a.childNodes[0]&&(0!==t.focusOffset||i===this.VOID_KEY)){if(i===this.VOID_KEY){const t=s.previousSibling;if(t.children[0].classList.contains("at-input")&&t.children[0].children[0].textContent!==this.VOID_KEY)return this.rangeToInputTag(t.children[0]),!0;const e=t.previousSibling;a.removeChild(t),a.removeChild(s);const i=e.childNodes[0],n=i.childNodes[0];n.textContent===this.VOID_KEY&&e===a.lastChild&&i.appendChild(document.createElement("br")),this.restCursorPos(n,n.textContent.length)}else{n.innerHTML=s===a.lastChild?`${this.VOID_KEY}<br>`:this.VOID_KEY,n.setAttribute("data-set-empty","true");const t=n.childNodes[0];this.restCursorPos(t,1)}return!0}if(0===t.focusOffset){const t=n.parentNode,e=null==t?void 0:t.previousSibling;return!(!e||e.getAttribute("data-set-richType")!==RICH_TAG)&&(e.children[0].classList.contains("at-input")&&e.children[0].children[0].textContent!==this.VOID_KEY?(this.rangeToInputTag(e.children[0]),!0):(this.delTag(e),!0))}}delTag(t){const e=t.previousSibling,i=t.nextSibling;t.parentNode.removeChild(t),this.markMerge(e,i)}gridMerge(t,e,i=!0){t.lastChild.getAttribute("data-set-richType")!==RICH_MARK&&t.appendChild(this.getGridElm(!0)),e.childNodes[0].getAttribute("data-set-richType")!==RICH_MARK&&e.insertBefore(this.getGridElm(!0),e.childNodes[0]);const n=t.lastChild.childNodes[0],s=n.childNodes[0];let a=s.textContent.length;Array.from(e.childNodes,e=>{t.appendChild(e.cloneNode(!0))}),e.childNodes.length>1&&n.childNodes[1]&&n.removeChild(n.childNodes[1]);const l=n.parentNode.nextSibling;if(l){const e=l.children[0].childNodes[0];e&&e.textContent!==this.VOID_KEY&&(n.childNodes[1]&&n.removeChild(n.childNodes[1]),s.textContent=(s.textContent+e.textContent).replace(new RegExp(this.VOID_KEY,"g"),()=>(a--,"")),s.parentElement.setAttribute("data-set-empty","false")),t.removeChild(l)}""===s.textContent&&(s.textContent=this.VOID_KEY,s.parentNode.setAttribute("data-set-empty","true"),a=1),this.richText.removeChild(e),i&&this.restCursorPos(s,a)}markMerge(t,e){const i=t.children[0].childNodes[0];let n=i.textContent.length;if(e){const t=e.children[0].childNodes[0];t&&t.textContent!==this.VOID_KEY&&(i.textContent=(i.textContent+t.textContent).replace(new RegExp(this.VOID_KEY,"g"),()=>(n--,"")),i.parentElement.setAttribute("data-set-empty","false")),e.parentNode.removeChild(e)}""===i.textContent&&(i.textContent=this.VOID_KEY,i.parentNode.setAttribute("data-set-empty","true"),n=1);const s=t.parentNode;i.textContent===this.VOID_KEY&&t===s.lastChild&&(i.parentNode.appendChild(document.createElement("br")),i.parentNode.setAttribute("data-set-empty","true"),n=1),this.restCursorPos(i,n)}setCallSpace(t){this.needCallSpace=t}getWrapNode(t,e=!1){if(t.nodeType===Node.TEXT_NODE)return t.parentNode.parentNode.parentNode;const i=t.getAttribute("data-set-richType");if(e&&i===RICH_TAG)return t.parentNode;switch(i){case RICH_INPUT:return t.parentNode.parentNode;case RICH_MARK:return t.parentNode;case RICH_GRID:return t}}getMarkNode(t,e=!1){if(t.nodeType===Node.TEXT_NODE)return t.parentNode?t.parentNode.parentNode:null;const i=t.getAttribute("data-set-richType");if(e&&i===RICH_TAG)return t;switch(i){case RICH_INPUT:return t.parentNode;case RICH_MARK:return t}}getRichTextNodeIndex(){let t,e,i,n=null,s=null,a=null;switch(this.lastCursorType){case"inputTag":if(!this.inputTag_vnode)break;if(e=upFindElm(this.inputTag_vnode.parentElement,5),!e)break;i=e.parentElement,n=Array.prototype.indexOf.call(this.richText.children,i),a=Array.prototype.indexOf.call(i.children,e);break;case"gridInput":if(!this.vnode)break;if(t=upFindElm(this.vnode.parentElement,5),!t)break;i=t.parentElement,n=Array.prototype.indexOf.call(this.richText.children,i),s=Array.prototype.indexOf.call(i.children,t)}return{gridIndex:n,markIndex:s,tagIndex:a}}setWrapNodeByMark(t){const e=document.createElement("p");return e.className="chat-grid-wrap",e.setAttribute("data-set-richType",RICH_GRID),Array.from(t,t=>{e.appendChild(t)}),e}insetRangeGrid(t,e=0){const i=this.vnode.textContent,n=i.slice(0,this.cursorIndex-e);0===n.length?(this.vnode.parentElement.setAttribute("data-set-empty","true"),this.vnode.textContent=this.VOID_KEY):this.vnode.textContent=n;let s=i.slice(this.cursorIndex);const a=[],l=document.createDocumentFragment();Array.from(t.children).forEach((t,e)=>{a.push(t),0!==e&&l.appendChild(t)});const o=a[a.length-1].children[0];s&&s.length>0&&s!==this.VOID_KEY?(o.setAttribute("data-set-empty","false"),o.textContent=o.textContent+s):o.setAttribute("data-set-empty","true");const r=this.getMarkNode(this.vnode),c=r.parentElement,h=r.children[0],d=a[0].textContent;d&&d.length>0&&d!==this.VOID_KEY&&(h.setAttribute("data-set-empty","false"),h.textContent=(h.textContent+d).replace(new RegExp(this.VOID_KEY,"g"),"")),h.childNodes[1]&&h.removeChild(h.childNodes[1]),r.nextElementSibling?(o.childNodes[1]&&o.removeChild(o.childNodes[1]),c.insertBefore(l,r.nextElementSibling)):c.appendChild(l);const p=s&&s!==this.VOID_KEY?s.length:0;if(a.length>1){const t=o.childNodes[0];this.restCursorPos(t,t.textContent===this.VOID_KEY?1:t.textContent.length-p)}else{const t=h.childNodes[0];this.restCursorPos(t,t.textContent===this.VOID_KEY?1:t.textContent.length-p)}}insetRangeGrids(t){const e=document.createDocumentFragment();Array.from(t).forEach(t=>{e.appendChild(t)});const i=this.getWrapNode(this.vnode);this.restCursorPos(this.vnode,this.cursorIndex),this.setWrap(!1);const n=i.nextElementSibling;n&&this.richText.insertBefore(e,n);n&&n.previousElementSibling?(this.gridMerge(i,i.nextElementSibling,!1),this.gridMerge(n.previousElementSibling,n,!0)):this.gridMerge(i,i.nextElementSibling,!0)}getOffsetRange(t,e,i=!1){const n=e.children[0].childNodes[0],s=n.textContent;if(0===t)return{rangeNode:n,rangeIndex:i?s.length:s===this.VOID_KEY?1:0};if(s!==this.VOID_KEY&&s.length>=t)return{rangeNode:n,rangeIndex:i?s.length-t:t};let a,l;if(i?(a=Boolean(e.previousElementSibling&&e.previousElementSibling.previousElementSibling),l=Boolean(e.parentElement.previousElementSibling)):(a=Boolean(e.nextElementSibling&&e.nextElementSibling.nextElementSibling),l=Boolean(e.parentElement.nextElementSibling)),!a&&!l)return{rangeNode:n,rangeIndex:i?s.length===this.VOID_KEY?1:0:s.length===this.VOID_KEY?1:s.length};const o=t-s.length,r=i?a?e.previousElementSibling.previousElementSibling:e.parentElement.previousElementSibling.lastElementChild:a?e.nextElementSibling.nextElementSibling:e.parentElement.nextElementSibling.children[0];return this.getOffsetRange(o,r,i)}isInInputTag(){const t=getSelection().focusNode;return!!t&&(t.classList&&t.classList.contains("input-write")?t:t.nodeType===Node.TEXT_NODE&&(!!(t.parentElement&&t.parentElement.classList&&t.parentElement.classList.contains("input-write"))&&t.parentElement))}rangeToInputTag(t){const e=t.children[0].childNodes[0];this.setInputTagRange(e,e.textContent===this.VOID_KEY?1:e.textContent.length)}watchInputTag(t){if(0===t.childNodes.length||0===t.textContent.length)t.textContent=this.VOID_KEY,this.rangeToInputTag(t.parentElement);else{const e=t.childNodes[0];this.target.nextTick(()=>{if(!this.target.chatEvent.isComposition){const i=getSelection().focusOffset,n=t.textContent===this.VOID_KEY||-1===t.textContent.indexOf(this.VOID_KEY)?0:1;let s=!1;1===n&&(e.textContent=e.textContent.replace(this.VOID_KEY,""),s=!0),-1!==t.textContent.indexOf(this.INPUT_TAG_WRAP_KEY[1])&&(t.textContent=t.textContent.replace(new RegExp(this.INPUT_TAG_WRAP_KEY[0],"g"),"").replace(new RegExp(this.INPUT_TAG_WRAP_KEY[1],"g"),this.INPUT_TAG_WRAP_KEY),s=!0),s&&this.setInputTagRange(t.childNodes[0],i-n)}})}domItVisible(t.nextElementSibling,t.textContent===this.VOID_KEY,"inline")}backRuleInputTag(t){if(t.textContent===this.VOID_KEY)return this.delTag(t.parentElement.parentElement),!0;const e=getSelection();if(0===e.focusOffset&&e.isCollapsed){const e=t.parentElement.parentElement.previousElementSibling.children[0].childNodes[0];return this.restCursorPos(e,e.textContent===this.VOID_KEY?1:e.textContent.length),!0}if(-1!==e.focusNode.textContent.indexOf(this.INPUT_TAG_WRAP_KEY[1])){const t=this.getDiffInputTagOffset(e.focusNode,e.focusOffset,"left");if(t>0){const i=e.focusNode.textContent.slice(0,e.focusOffset-1-t),n=e.focusNode.textContent.slice(e.focusOffset);return e.focusNode.textContent=i+n,e.focusNode.textContent?this.setInputTagRange(e.focusNode,i.length):(e.focusNode.textContent=this.VOID_KEY,this.watchInputTag(e.focusNode.parentElement),this.setInputTagRange(e.focusNode,1)),!0}}return!1}mergeRuleInputTag(t){this.target.nextTick(()=>{t.childNodes.length>1&&(t.removeChild(t.childNodes[1]),this.watchInputTag(t))})}inputTagSwitchRange(t){const{focusNode:e,focusOffset:i}=getSelection(),n=e.textContent.length,s=e.parentElement.parentElement.parentElement;let a,l,o,r=!1;switch(t){case"ArrowLeft":i>0&&e.textContent!==this.VOID_KEY?(o=this.getDiffInputTagOffset(e,i,"left"),l=i-1-o,a=e):(a=s.previousElementSibling.children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:a.textContent.length,r=!0);break;case"ArrowRight":i<n&&e.textContent!==this.VOID_KEY?(o=this.getDiffInputTagOffset(e,i,"right"),l=i+1+o,a=e):(a=s.nextElementSibling.children[0].childNodes[0],l=a.textContent===this.VOID_KEY?1:0,r=!0)}r?this.restCursorPos(a,l):this.setInputTagRange(a,l)}pasteInputTag(t){t=t.replace(new RegExp(this.INPUT_TAG_WRAP_KEY[0],"g"),"").replace(new RegExp(this.INPUT_TAG_WRAP_KEY[1],"g"),this.INPUT_TAG_WRAP_KEY);const e=getSelection(),{focusNode:i,focusOffset:n,anchorOffset:s}=e;let a="",l="";e.isCollapsed?(a=i.textContent.slice(0,n)||"",l=i.textContent.slice(n)||""):(a=i.textContent.slice(0,s<n?s:n)||"",l=i.textContent.slice(n>s?n:s)||""),i.textContent=a+t+l,this.setInputTagRange(i,(s<n?s:n)+t.length);const o=i.parentElement;this.watchInputTag(o)}setInputTagWrap(t){const e=getSelection(),{focusOffset:i}=e,n=t.textContent,s=n.slice(0,i),a=n.slice(i);t.textContent=s+this.INPUT_TAG_WRAP_KEY+a,this.setInputTagRange(t.childNodes[0],i+this.INPUT_TAG_WRAP_KEY.length),this.watchInputTag(t)}getDiffInputTagOffset(t,e,i){const n="left"===i?t.textContent[e-1]:t.textContent[e];if(-1===this.INPUT_TAG_WRAP_KEY.indexOf(n))return 0;switch(i){case"left":return t.textContent[e-2]===this.INPUT_TAG_WRAP_KEY[1]?2:t.textContent[e-2]===this.INPUT_TAG_WRAP_KEY[0]?3:1;case"right":return t.textContent[e+1]===this.INPUT_TAG_WRAP_KEY[1]?2:t.textContent[e+1]===this.INPUT_TAG_WRAP_KEY[0]?3:1}}updateNodeCursor(){const{focusNode:t,focusOffset:e}=getSelection();if(!t||t.nodeType!==Node.TEXT_NODE)return;const i=upFindElm(t.parentElement,5);if(!i)return;const n=i.getAttribute("data-set-richType");if(n&&i.parentElement.parentElement===this.richText)switch(n){case RICH_MARK:this.updateGridInputCursor(t,e);break;case RICH_TAG:i.children[0].classList.contains("at-input")&&this.updateInputTagCursor(t,e)}}updateGridInputCursor(t,e){this.lastCursorType="gridInput",this.vnode=t,this.cursorIndex=t.textContent===this.VOID_KEY?1:e}updateInputTagCursor(t,e){this.lastCursorType="inputTag",this.inputTag_vnode=t,this.inputTag_cursorIndex=t.textContent===this.VOID_KEY?1:e}restCursorPos(t,e){null==e?e=t.textContent===this.VOID_KEY?1:0:e>t.textContent.length&&(e=t.textContent.length);const i=new Range;i.setStart(t,e),i.setEnd(t,e);const n=getSelection();n.removeAllRanges(),n.addRange(i),this.updateGridInputCursor(t,e)}setInputTagRange(t,e){null==e?e=t.textContent===this.VOID_KEY?1:0:e>t.textContent.length&&(e=t.textContent.length);const i=new Range;i.setStart(t,e),i.setEnd(t,e);const n=getSelection();n.removeAllRanges(),n.addRange(i),this.updateInputTagCursor(t,e)}setRangeLastRecord(){switch(this.lastCursorType){case"gridInput":this.restCursorPos(this.vnode,this.cursorIndex);break;case"inputTag":this.setInputTagRange(this.inputTag_vnode,this.inputTag_cursorIndex)}}setRangeLastText(){const t=this.richText.childNodes[this.richText.childNodes.length-1],e=t.childNodes[t.childNodes.length-1].children[0].childNodes[0];this.restCursorPos(e,e.textContent===this.VOID_KEY?1:e.textContent.length),this.viewIntoPoint()}viewIntoPoint(){let t,e;const i=getSelection(),{focusNode:n,focusOffset:s}=i;if(n&&n.parentElement&&n.parentElement.classList.contains("input-write"))t=n.parentElement.parentElement,e=s;else{if(!this.vnode)return;t=this.getMarkNode(this.vnode),e=this.cursorIndex}if(!t)return;const a=t.getBoundingClientRect(),l=Math.ceil(a.height/this.NODE_HEIGHT),o=Math.floor(t.textContent.length/l)||1,r=(Math.floor(e/o)||1)*this.NODE_HEIGHT,c=a.top+(r-this.NODE_HEIGHT),h=this.richText.parentElement,d=h.getBoundingClientRect(),p=d.top,g=d.top+d.height;if(c<p+this.NODE_PADDING_DIFF){const t=p-c;h.scrollTo(0,h.scrollTop-t)}else if(c>g-this.NODE_HEIGHT){const t=c-g+this.NODE_HEIGHT;h.scrollTo(0,h.scrollTop+t)}}}class ChatEvent{constructor(t){__publicField(this,"target"),__publicField(this,"outerApply",!1),__publicField(this,"isComposition",!1),__publicField(this,"matchKey",0),__publicField(this,"startOpenIndex",0),__publicField(this,"textLength",0),__publicField(this,"isIMEModel",!1),__publicField(this,"takeIMEModel",!1),__publicField(this,"undoHistory",[]),__publicField(this,"redoHistory",[]),__publicField(this,"doOverHistory",!0),__publicField(this,"chatEventModule",{enterSend:[],operate:[],defaultAction:[],atMatch:[],atCheck:[],tagCheck:[],selectCheck:[],tipTagState:[],afterAtCheck:[],afterTagCheck:[],afterSelectCheck:[],showAtDialog:[],showTagDialog:[],showSelectDialog:[],elementClicked:[]}),__publicField(this,"debounceEvents",{recordHistory:()=>{},dialogMoveToRange:t=>{},selectDialogToAim:()=>{},matchPointDialog:()=>{},movePointActiveUserElm:t=>{},moveCustomActiveTagElm:t=>{}}),this.target=t,this.registerEvent(),this.otherEvent()}registerEvent(){const{chatElement:t,options:e,chatInput:i}=this.target;t.richText.addEventListener("keyup",this.onKeyUp.bind(this)),t.richText.addEventListener("keydown",this.onKeyDown.bind(this)),t.richText.addEventListener("beforeinput",this.onBeforeinput.bind(this)),t.richText.addEventListener("input",this.onInput.bind(this)),t.richText.addEventListener("copy",t=>{t.preventDefault(),this.ruleChatEvent(()=>{this.copyRange(t)},"defaultAction","COPY")}),t.richText.addEventListener("cut",t=>{t.preventDefault(),this.ruleChatEvent(()=>{this.copyRange(t),this.removeRange(),t.target.classList.contains("input-write")&&this.target.chatInput.watchInputTag(t.target)},"defaultAction","CUT")}),t.richText.addEventListener("paste",t=>{t.preventDefault();const{options:e,chatInput:i}=this.target;this.ruleChatEvent(()=>{const n=t.clipboardData.getData("text/plain");if("string"==typeof n&&""!==n){if(-1===e.copyType.indexOf("text"))return;if(this.removeRange(),t.target.classList.contains("input-write"))return i.pasteInputTag(n),void this.richTextInput();const s=t.clipboardData.getData(CHAT_COPY_KEY)||"";if(s&&-1!==s.indexOf(RICH_GRID))return void this.insertInsideHtml(escapeChatHtml(s));this.target.insertText(n)}else{if(-1===e.copyType.indexOf("image"))return;this.removeRange();const i=(t.clipboardData||t.originalEvent.clipboardData).items||[];Array.from(i,async t=>{if(-1===t.type.indexOf("image"))return;const i=t.getAsFile();if(e.uploadImage){const t=await e.uploadImage(i);this.target.insertHtml(`<img class="chat-img" src="${t}" alt="" />`)}else{const t=new FileReader;t.onload=t=>{this.target.insertHtml(`<img class="chat-img" src="${t.target.result}" alt="" />`)},t.readAsDataURL(i)}})}},"defaultAction","PASTE")}),t.richText.addEventListener("blur",()=>{i.updateNodeCursor()}),t.richText.addEventListener("focus",()=>{i.updateNodeCursor()}),t.richText.addEventListener("click",t=>{i.updateNodeCursor();const n=upFindElm(t.target,10);if(n){const t=n.children[0];if(t.classList.contains("chat-grid-input"))return void this.triggerChatEvent("elementClicked","gridInput",t);if(t.classList.contains("at-input"))return t.children[0].textContent===i.VOID_KEY&&i.rangeToInputTag(t),void this.triggerChatEvent("elementClicked","inputTag",t);if(t.classList.contains("at-select")){const i=t.getAttribute("data-select-key");return this.triggerChatEvent("showSelectDialog",i,t),e.needDialog&&this.target.showPCSelectDialog(i,t),void this.triggerChatEvent("elementClicked","selectTag",t)}if(t.classList.contains("at-user"))return void this.triggerChatEvent("elementClicked","userTag",t);if(t.classList.contains("at-tag"))return void this.triggerChatEvent("elementClicked","customTag",t);if(t.classList.contains("chat-set-html"))return void this.triggerChatEvent("elementClicked","htmlTag",t.children[0])}}),t.richText.addEventListener("dragstart",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("drop",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("compositionstart",()=>{this.isComposition=!0}),t.richText.addEventListener("compositionend",()=>{this.isComposition=!1}),window.addEventListener("click",this.winClick.bind(this)),window.addEventListener("keydown",this.winKeydown.bind(this))}onKeyUp(t){if(this.target.chatInput.isInInputTag())return;t.stopPropagation();const e=this.target.chatInput.getCurrentCursorKey();if(this.target.deviceInfo.isPc)if("@"!==t.key&&"2"!==String(t.key)||"@"!==e){this.target.options.customTrigger.filter(e=>e.keyMap.includes(String(t.key))).map(t=>t.prefix).forEach(t=>{e===t&&(this.triggerChatEvent("showTagDialog",t),this.target.options.needDialog&&this.target.chatElement.showCustomTagDialog(t))})}else this.triggerChatEvent("showAtDialog"),this.target.options.needDialog&&this.target.chatElement.ruleShowPointDialog();else if((this.target.options.reformList.length>0||this.target.options.asyncMatch)&&"@"===e)this.triggerChatEvent("showAtDialog"),this.target.options.needDialog&&this.target.showH5Dialog(),this.target.chatElement.isExternalCallPopup=!1;else{this.target.options.customTrigger.map(t=>t.prefix).forEach(t=>{e===t&&this.triggerChatEvent("showTagDialog",t)})}}onKeyDown(t){const e=this.target.chatInput.isInInputTag();if(!this.target.deviceInfo.isPc&&isKeyType(t,"IME"))return e&&this.target.chatInput.mergeRuleInputTag(e),void(this.isIMEModel=!0);this.isIMEModel||(hasElmShow(this.target.chatElement.pcElms.pointDialogElm)?isKeyType(t,"dialog-options")?t.preventDefault():isKeyType(t,"text-move")&&this.target.chatElement.exitPointDialog():this.target.chatElement.pcElms.customTagDialogTagKey&&hasElmShow(this.target.chatElement.pcElms.customTagDialogElms[this.target.chatElement.pcElms.customTagDialogTagKey])?isKeyType(t,"dialog-options")?t.preventDefault():isKeyType(t,"text-move")&&this.target.chatElement.exitCustomTagDialog():(!this.isComposition&&isKeyType(t,"text-delete")?e?(this.target.chatInput.backRuleInputTag(e)&&(t.preventDefault(),this.richTextInput()),this.target.chatInput.mergeRuleInputTag(e)):this.target.chatInput.selectRegionMerge()||this.target.chatInput.gridElmMerge()||this.target.chatInput.delMarkRule()?(t.preventDefault(),this.richTextInput()):this.target.chatElement.tipElm&&this.target.isEmpty()&&this.target.chatElement.removeTipElm():this.target.options.wrapKeyFun(t)||!this.target.deviceInfo.isPc&&"Enter"===t.key?(t.preventDefault(),this.isComposition||(e?this.target.chatInput.setInputTagWrap(e):this.target.chatInput.setWrap(),this.richTextInput())):this.target.options.sendKeyFun(t)?(t.preventDefault(),this.isComposition||this.triggerChatEvent("enterSend")):isKeyType(t,"text-move")?(t.preventDefault(),this.isComposition||(e?this.target.chatInput.inputTagSwitchRange(t.code):this.target.chatInput.switchRange(t.code))):isKeyType(t,"text-select-all")?(t.preventDefault(),this.isComposition||this.target.isEmpty()||this.target.chatInput.selectAll()):isKeyType(t,"text-undo")?(t.preventDefault(),this.isComposition||this.ruleChatEvent(()=>{this.target.undo()},"defaultAction","UNDO")):isKeyType(t,"text-redo")&&(t.preventDefault(),this.isComposition||this.ruleChatEvent(()=>{this.target.redo()},"defaultAction","REDO")),this.target.deviceInfo.isPc&&!getSelection().isCollapsed&&isKeyType(t,"text-write")&&this.target.chatInput.selectRegionMerge()))}onBeforeinput(t){const e=this.target.chatInput.isInInputTag();if(this.isIMEModel){if("insertParagraph"===t.inputType)return t.preventDefault(),e?this.target.chatInput.setInputTagWrap(e):this.target.chatInput.setWrap(),void this.richTextInput();if("deleteContentBackward"===t.inputType){this.takeIMEModel=!0,t.preventDefault();const i=this.target.chatElement.richText.innerHTML,n=getSelection(),s=n.focusNode,a=n.focusOffset;let l=-1,o=-1;if(s.nodeType!==Node.TEXT_NODE){const t=s;if(!t||!t.getAttribute||t.getAttribute("data-set-richType")!==RICH_GRID)return;l=Array.prototype.indexOf.call(this.target.chatElement.richText.children,t),o=0}else{const t=e?s.parentElement.parentElement.parentElement:s.parentElement.parentElement,i=t.parentElement;l=Array.prototype.indexOf.call(this.target.chatElement.richText.children,i),o=Array.prototype.indexOf.call(i.children,t)}this.target.nextTick(()=>{if(this.target.chatElement.richText.innerHTML=i,-1===l||-1===o)return this.takeIMEModel=!1,void(this.isIMEModel=!1);const t=this.target.chatElement.richText.children[l].children[o],n=e?t.children[0].children[0].childNodes[0]:t.children[0].childNodes[0];e?(this.target.chatInput.setInputTagRange(n,a),this.target.chatInput.backRuleInputTag(n.parentElement)||(n.textContent=n.textContent.slice(0,a-1)+n.textContent.slice(a),this.target.chatInput.setInputTagRange(n,a-1)),this.target.chatInput.watchInputTag(n.parentElement)):(this.target.chatInput.restCursorPos(n,a),this.target.chatInput.selectRegionMerge()||this.target.chatInput.gridElmMerge()||this.target.chatInput.delMarkRule()||(n.textContent=n.textContent.slice(0,a-1)+n.textContent.slice(a),this.target.chatInput.restCursorPos(n,a-1))),this.target.nextTick(async()=>{await this.richTextInput(),this.takeIMEModel=!1,this.isIMEModel=!1})})}}}onInput(){const t=this.target.chatInput.isInInputTag();if(this.isIMEModel){if(this.takeIMEModel)return;this.target.nextTick(()=>{t&&this.target.chatInput.watchInputTag(t),this.richTextInput()})}else{if(t)return this.target.chatInput.watchInputTag(t),void this.richTextInput();this.richTextInput().then(()=>{this.target.deviceInfo.isPc&&!this.isComposition&&this.debounceEvents.matchPointDialog()})}}winClick(){if(!this.target||this.outerApply)return;const{chatElement:t}=this.target;hasElmShow(t.pcElms.pointDialogElm)&&t.exitPointDialog(),t.pcElms.checkDialogSearchResultElm&&domItVisible(t.pcElms.checkDialogSearchResultElm),t.pcElms.customTagDialogTagKey&&hasElmShow(t.pcElms.customTagDialogElms[t.pcElms.customTagDialogTagKey])&&t.exitCustomTagDialog(),t.pcElms.selectDialogKey&&hasElmShow(t.pcElms.selectDialogElms[t.pcElms.selectDialogKey])&&t.exitSelectDialog()}async winKeydown(t){if(!this.target)return;const{chatElement:e,options:i}=this.target;if((t.ctrlKey||t.metaKey)&&"KeyZ"===t.code&&t.preventDefault(),!this.isComposition)if(hasElmShow(e.pcElms.pointDialogElm)){if("ArrowDown"===t.code)return t.preventDefault(),void this.debounceEvents.movePointActiveUserElm("down");if("ArrowUp"===t.code)return t.preventDefault(),void this.debounceEvents.movePointActiveUserElm("up");if(("Enter"===t.code||"NumpadEnter"===t.code)&&e.pcElms.pointDialogActiveElm){t.preventDefault();const n=e.pcElms.pointDialogActiveElm.getAttribute("data-set-id");if(await sleep(100),e.isPointSearchMode||i.asyncMatch)await this.target.matchSetTag(i.reformList.find(t=>t.id===n));else{const t=i.userList.find(t=>String(t[i.userProps.id])===n);await this.target.onceSetTag(t)}e.exitPointDialog()}}else if(e.pcElms.customTagDialogTagKey&&hasElmShow(e.pcElms.customTagDialogElms[e.pcElms.customTagDialogTagKey])){if("ArrowDown"===t.code)return t.preventDefault(),void this.debounceEvents.moveCustomActiveTagElm("down");if("ArrowUp"===t.code)return t.preventDefault(),void this.debounceEvents.moveCustomActiveTagElm("up");if(("Enter"===t.code||"NumpadEnter"===t.code)&&e.pcElms.customTagDialogActiveElm){t.preventDefault();const i=e.pcElms.customTagDialogActiveElm.getAttribute("data-set-id");await sleep(100);const n=e.customTags[e.pcElms.customTagDialogTagKey].find(t=>t.id===i);e.isPointSearchMode?await this.target.matchSetCustomTag(n):await this.target.onceSetCustomTag(n),e.exitCustomTagDialog()}}}otherEvent(){const{options:t,chatInput:e,chatElement:i}=this.target,{needDebounce:n}=t,s=()=>{const{gridIndex:t,markIndex:n,tagIndex:s}=e.getRichTextNodeIndex();null!==n?this.undoHistory.push({html:i.richText.innerHTML,gridIndex:t,markIndex:n,tagIndex:s,cursorIndex:e.cursorIndex,inputTag_cursorIndex:e.inputTag_cursorIndex,type:"gridInput"}):null!==s&&this.undoHistory.push({html:i.richText.innerHTML,gridIndex:t,markIndex:n,tagIndex:s,cursorIndex:e.cursorIndex,inputTag_cursorIndex:e.inputTag_cursorIndex,type:"inputTag"}),this.undoHistory.length>50&&this.undoHistory.shift()};this.debounceEvents.recordHistory=n?debounce(s,200):s;const a=t=>{let n="0",s="100%";const a=e.getRangeRect();if(!a)return;const l=i.pcElms.containerDialogElm.getBoundingClientRect();let o=a.x-l.x,r=l.y-a.y;const{clientWidth:c,clientHeight:h}=t;a.x>window.innerWidth-c-30&&(o=a.x-c-l.x-16,n="100%"),a.y<h&&(r-=h,s="0"),t.style.transform="translate(0, 0)",t.style.transformOrigin=`${n} ${s}`,t.style.left=o+6+"px",t.style.bottom=`${r}px`,t.style.opacity="1"};this.debounceEvents.dialogMoveToRange=n?debounce(a,120,!0):a;const l=()=>{if(!t.needDialog||!t.asyncMatch&&0===t.reformList.length&&0===t.customTrigger.length)return;const n=e.getCurrentCursorKey();if(!t.asyncMatch&&"@"===n)return void i.ruleShowPointDialog();if(t.customTrigger.some(t=>{if(n===t.prefix)return i.showCustomTagDialog(t.prefix),!0}))return;const s=e.vnode.textContent||"",a=e.cursorIndex,l=s.slice(0,a);let o=-1,r=-1,c="userTag";if(-1!==l.lastIndexOf("@")&&(o=l.lastIndexOf("@")),i.pcElms.customTagDialogTagKey&&-1!==l.lastIndexOf(i.pcElms.customTagDialogTagKey)&&(r=l.lastIndexOf(i.pcElms.customTagDialogTagKey)),r>o&&(c="customTag"),"userTag"===c&&t.asyncMatch){if(o<0)return void i.exitPointDialog();this.matchKey++;const t=this.matchKey;this.startOpenIndex=o+1;const e=l.slice(this.startOpenIndex)||"";if(/\s/gi.test(e))return void i.exitPointDialog();this.target.updateUserList([]),domItVisible(i.pcElms.pointDialogLoadingElm,!0,"flex"),domItVisible(i.pcElms.pointDialogEmptyElm),i.showPointDialog();const n=this.triggerChatEvent("atMatch",e).find(t=>t&&t instanceof Promise);return void(n&&n.then(e=>{t===this.matchKey&&(domItVisible(i.pcElms.pointDialogLoadingElm),!e||e.length<=0?domItVisible(i.pcElms.pointDialogEmptyElm,!0,"flex"):(this.target.updateUserList(e),i.pcElms.pointDialogUsersElm&&i.pcElms.pointDialogUsersElm.length>0&&i.updatePointActiveUserElm(i.pcElms.pointDialogUsersElm[0].elm)))}))}if("userTag"===c&&t.reformList.length<=0)return void i.exitCustomTagDialog();if("customTag"===c&&i.customTags[i.pcElms.customTagDialogTagKey].length<=0)return;const h=()=>{"userTag"===c?i.exitPointDialog():i.exitCustomTagDialog()};if(o<0&&r<0)return i.exitPointDialog(),void i.exitCustomTagDialog();this.startOpenIndex="userTag"===c?o+1:r+1;const d=new RegExp(`^([${e.ZERO_WIDTH_KEY}${e.VOID_KEY}])+$`);if(!l||d.test(l)||a<this.startOpenIndex)return void h();const p=l.slice(this.startOpenIndex)||"";if(/\s/gi.test(p))h();else if(p)if("userTag"===c){i.isExternalCallPopup=!1;const t=this.target.searchUserList(p);t.length>0?i.showPointDialog(t):h()}else{const t=i.customTags[i.pcElms.customTagDialogTagKey].filter(t=>pinyinMatch(t.name,t.pinyin||"",p));t.length>0?i.showCustomTagDialog(i.pcElms.customTagDialogTagKey,t):h()}else"userTag"===c?i.ruleShowPointDialog():i.showCustomTagDialog(i.pcElms.customTagDialogTagKey)};this.debounceEvents.matchPointDialog=n?debounce(l,200):l;this.debounceEvents.movePointActiveUserElm=throttle(t=>{if(!i.pcElms.pointDialogActiveElm)return;let e=0;const n=i.pcElms.pointDialogActiveElm.getAttribute("data-set-id");i.pcElms.pointDialogUsersElm.some(t=>{const i=t.elm.getAttribute("data-set-id");return e=t.index,n===i});const s=i.pcElms.pointDialogUsersElm.filter(t=>!t.elm.classList.contains("user-no-match")),a=s.map(t=>t.index);let l;"down"===t?l=e===s[s.length-1].index?s[0]:s[a.indexOf(e)+1]:"up"===t&&(l=e===s[0].index?s[s.length-1]:s[a.indexOf(e)-1]),l&&i.updatePointActiveUserElm(l.elm,!0)},80);this.debounceEvents.moveCustomActiveTagElm=throttle(t=>{if(!i.pcElms.customTagDialogActiveElm)return;const e=i.customTags[i.pcElms.customTagDialogTagKey].map(t=>t.id),n=i.pcElms.customTagDialogActiveElm.getAttribute("data-set-id"),s=e.indexOf(n),a=Array.from(i.pcElms.customTagDialogElms[i.pcElms.customTagDialogTagKey].children[1].children,(t,e)=>({elm:t,index:e})).filter(t=>!t.elm.classList.contains("tag-no-match")),l=a.map(t=>t.index);let o;"down"===t?o=s===a[a.length-1].index?a[0]:a[l.indexOf(s)+1]:"up"===t&&(o=s===a[0].index?a[a.length-1]:a[l.indexOf(s)-1]),o&&i.updateActiveCustomTagElm(o.elm,!0)},80);const o=()=>{const t=i.pcElms.selectDialogAim.getClientRects()[0],e=i.pcElms.selectDialogElms[i.pcElms.selectDialogKey];domItVisible(e,!0);const n=e.querySelector(".chat-select-arrow");let s=e.clientHeight+16;if(s>t.y?(s=-(t.height+16),n.style.top="-16px",n.style.bottom="auto",n.style.transform="rotate(0deg)"):(n.style.transform="rotate(180deg)",n.style.bottom="-16px",n.style.top="auto"),window.innerWidth-t.x<e.clientWidth){const i=e.clientWidth-(window.innerWidth-t.x)-10;e.style.left="auto",e.style.right="10px",n.style.left="auto",n.style.right=i-n.clientWidth/2+t.width/2+"px"}else e.style.left=t.x+"px",e.style.right="auto",n.style.left=t.width/2-n.clientWidth/2+"px",n.style.right="auto";e.style.top=t.y+"px",e.style.transform=`translateY(${-s}px)`;const a=e.children[1],l=a.children;let o=0,r=!1,c=0;if(i.pcElms.selectDialogAim.classList.contains("at-select")){const t=i.pcElms.selectDialogAim.getAttribute("data-select-id");updateElmClass(i.pcElms.selectDialogAim,"aim",!0),Array.from(l,e=>{const i=e.lastChild.lastChild,n=t===e.getAttribute("data-set-id");n&&(c=e.clientHeight,r=!0),n||r||(o+=e.clientHeight),domItVisible(i,n,"inline-block")});const e=o-a.clientHeight/2+c/2;a.scrollTop=e>0?e:0}else Array.from(l,t=>{domItVisible(t.lastChild.lastChild,!1,"inline-block")})};this.debounceEvents.selectDialogToAim=n?debounce(o,120):o;const r={html:i.richText.innerHTML,gridIndex:0,markIndex:0,tagIndex:0,type:e.lastCursorType,cursorIndex:e.cursorIndex,inputTag_cursorIndex:e.inputTag_cursorIndex};this.undoHistory=[r]}async richTextInput(t=!0){const{chatInput:e,deviceInfo:i,chatElement:n,options:s}=this.target;return e.updateNodeCursor(),i.isPc&&e.selectRegionMerge(),await this.target.nextTick(()=>{this.isComposition||e.updateGrid(),this.fixEditor()||(-1!==s.maxLength&&this.ruleMaxLength(),n.showPlaceholder(),this.triggerChatEvent("operate"),i.isPc&&t&&this.doOverHistory&&!this.isComposition&&this.debounceEvents.recordHistory(),e.viewIntoPoint())}),!0}ruleMaxLength(){const{options:t,chatElement:e}=this.target;if(this.target.isEmpty()||-1===t.maxLength)return void(this.textLength=0);let i=0,n=0;const s=[];Array.prototype.some.call(e.richText.children,(e,a)=>{const{nodeInfos:l,nodeTextLength:o}=this.getGirdNodeTextInfo(e);if(i+=o,s.push(l),n=a,i>=t.maxLength)return!0});const a=[];Array.from(e.richText.children,(t,e)=>{e>n&&a.push(t)}),a.forEach(t=>e.richText.removeChild(t)),this.deepDelGirdText(s,i)}getGirdNodeTextInfo(t){const{chatInput:e}=this.target,i=[];let n=0;if(1===t.children.length&&t!==t.parentElement.children[0]){const s=t.children[0],a=(s.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=a.length||1,i[0]={node:s,textLength:a.length||1,type:RICH_MARK}}else Array.from(t.children,(t,s)=>{if(t.getAttribute("data-set-richType")===RICH_MARK){const a=(t.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=a.length,i[s]={node:t,textLength:a.length,type:RICH_MARK}}else{const a=(t.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=a.length||1,i[s]={node:t,textLength:a.length||1,type:RICH_TAG}}});return{nodeInfos:i,nodeTextLength:n}}deepDelGirdText(t,e){if(e>this.target.options.maxLength){const i=t[t.length-1];t.pop(),this.deepDelNode(i,t,e)}else this.textLength=e}deepDelNode(t,e,i){const n=t[0].node.parentElement;if(i>this.target.options.maxLength){let s=i-this.target.options.maxLength,a=t[t.length-1];if(a.type===RICH_MARK)if(0===a.textLength||s>=a.textLength)n.removeChild(a.node),t.pop(),s-=a.textLength,a=t[t.length-1],n.removeChild(a.node),t.pop(),s-=a.textLength;else{const t=a.node.childNodes[0];t.textContent=t.textContent.slice(0,a.textLength-s),0===t.textContent&&(t.setAttribute("data-set-empty","true"),t.innerHTML=`${this.target.chatInput.VOID_KEY}<br>`),s=0}else n.removeChild(a.node),t.pop(),s-=a.textLength;s>0?t.length>0?this.deepDelNode(t,e,s+this.target.options.maxLength):(this.target.chatElement.richText.appendChild(n),this.deepDelGirdText(e,s+this.target.options.maxLength)):(this.textLength=this.target.options.maxLength+s,this.target.chatInput.setRangeLastText())}}copyRange(t){const e=getSelection();if(e.isCollapsed||e.rangeCount<=0)return t.clipboardData.setData(CHAT_COPY_KEY,""),void t.clipboardData.setData("text/plain","");const{chatElement:i,chatInput:n}=this.target,s=e.toString()||"";let a=document.createElement("div");a.innerHTML=escapeHtml(s);const l=a.textContent.replace(/\n\n/g,"\n");a=null,t.clipboardData.setData("text/plain",l);const o=e.anchorNode,r=e.focusNode;if(o===r&&o.nodeType===Node.TEXT_NODE)return void t.clipboardData.setData(CHAT_COPY_KEY,l);if(o===i.richText&&r===i.richText)return void t.clipboardData.setData(CHAT_COPY_KEY,i.richText.innerHTML);const c=n.getWrapNode(o,!0),h=n.getWrapNode(r,!0),d=n.getMarkNode(o,!0),p=n.getMarkNode(r,!0),g=d.getAttribute("data-set-richType")===RICH_MARK,u=p.getAttribute("data-set-richType")===RICH_MARK,m=Array.prototype.indexOf.call(c.childNodes,d),E=Array.prototype.indexOf.call(h.childNodes,p);if(c===h&&c.parentNode===i.richText){const i=m>E,s=Array.prototype.filter.call(c.childNodes,(t,e)=>i?e<m&&e>E:e>m&&e<E).map(t=>t.cloneNode(!0)),a=g?i?o.textContent.slice(0,e.anchorOffset):o.textContent.slice(e.anchorOffset):"",l=u?i?r.textContent.slice(e.focusOffset):r.textContent.slice(0,e.focusOffset):"",h=n.getGridElm(!0),d=n.getGridElm(!0);a&&(h.childNodes[0].innerHTML=a,h.childNodes[0].setAttribute("data-set-empty","false")),l&&(d.childNodes[0].innerHTML=l,d.childNodes[0].setAttribute("data-set-empty","false")),i?(s[0].getAttribute("data-set-richType")!==RICH_MARK&&s.unshift(d),s[s.length-1].getAttribute("data-set-richType")!==RICH_MARK&&s.push(h)):(s[0].getAttribute("data-set-richType")!==RICH_MARK&&s.unshift(h),s[s.length-1].getAttribute("data-set-richType")!==RICH_MARK&&s.push(d));let p=document.createElement("div");const C=n.setWrapNodeByMark(s);return p.appendChild(C),t.clipboardData.setData(CHAT_COPY_KEY,p.innerHTML),void(p=null)}if(c.parentNode===i.richText&&h.parentNode===i.richText){const s=Array.prototype.indexOf.call(i.richText.childNodes,c),a=Array.prototype.indexOf.call(i.richText.childNodes,h),l=s>a,d=Array.prototype.filter.call(i.richText.childNodes,(t,e)=>l?e<s&&e>a:e>s&&e<a).map(t=>t.cloneNode(!0)),p=g?l?o.textContent.slice(0,e.anchorOffset):o.textContent.slice(e.anchorOffset):"",C=u?l?r.textContent.slice(e.focusOffset):r.textContent.slice(0,e.focusOffset):"",f=n.getGridElm(!0),T=n.getGridElm(!0);p&&(f.childNodes[0].innerHTML=p,f.childNodes[0].setAttribute("data-set-empty","false")),C&&(T.childNodes[0].innerHTML=C,T.childNodes[0].setAttribute("data-set-empty","false"));const x=Array.prototype.filter.call(c.childNodes,(t,e)=>l?e<m:e>m).map(t=>t.cloneNode(!0)),y=Array.prototype.filter.call(h.childNodes,(t,e)=>l?e>E:e<E).map(t=>t.cloneNode(!0));if(l){x.push(f),y.unshift(T);const t=n.setWrapNodeByMark(x),e=n.setWrapNodeByMark(y);d.push(t),d.unshift(e)}else{x.unshift(f),y.push(T);const t=n.setWrapNodeByMark(x),e=n.setWrapNodeByMark(y);d.unshift(t),d.push(e)}let I=document.createElement("div");return Array.from(d,t=>{I.appendChild(t)}),t.clipboardData.setData(CHAT_COPY_KEY,I.innerHTML),void(I=null)}}async removeRange(){const t=getSelection().getRangeAt(0);t&&!t.collapsed&&(this.target.chatInput.selectRegionMerge(),await this.richTextInput())}async setChatHistory(t){const{chatElement:e,chatInput:i}=this.target;this.doOverHistory=!1;const{html:n,gridIndex:s,markIndex:a,tagIndex:l,cursorIndex:o,inputTag_cursorIndex:r,type:c}=t;if(e.richText.innerHTML=n,"inputTag"===c){const t=e.richText.children[s].children[l].children[0].children[0].childNodes[0];i.setInputTagRange(t,r)}else{const t=e.richText.children[s].children[a].children[0].childNodes[0];i.restCursorPos(t,o)}await this.richTextInput(),this.doOverHistory=!0}async insertInsideHtml(t,e=!0){const{chatInput:i}=this.target;i.updateNodeCursor();let n=document.createElement("div");n.innerHTML=t,n.children.length&&(e&&Array.from(n.children,t=>{Array.from(t.children,(e,n)=>{const s=e.getAttribute("data-set-richType");if(s===RICH_MARK){const s=e.children[0];s.textContent&&s.textContent!==i.VOID_KEY?s.textContent=unescapeHtml(s.textContent):(s.setAttribute("data-set-empty","true"),s.innerHTML=n===t.children.length-1?`${i.VOID_KEY}<br>`:i.VOID_KEY)}else if(s===RICH_TAG){const t=e.children[0];t.classList.contains("at-input")?(t.children[1].textContent=unescapeHtml(t.children[1].textContent),t.children[0].textContent&&t.children[0].textContent!==i.VOID_KEY?t.children[0].textContent=unescapeHtml(t.children[0].textContent):(t.children[0].textContent=i.VOID_KEY,domItVisible(t.children[1],!0,"inline"))):t.classList.contains("at-user")||t.classList.contains("at-tag")?t.textContent=unescapeHtml(t.textContent):t.classList.contains("at-select")&&(t.childNodes[0].textContent=unescapeHtml(t.childNodes[0].textContent))}})}),1===n.children.length?i.insetRangeGrid(n.children[0]):i.insetRangeGrids(n.children),n=null,await this.richTextInput())}triggerChatEvent(t,...e){const i=[];return this.chatEventModule[t].forEach(t=>{t&&i.push(t(...e))}),i}ruleChatEvent(t,e,...i){this.triggerChatEvent(e,...i).some(t=>t&&"PREVENT"===t)||(t&&t.bind(this)(),t=null)}fixEditor(){const t=()=>{this.target.chatInput.initEditor(!0),this.target.chatElement.showPlaceholder(),this.textLength=0,this.triggerChatEvent("operate")};if(0===this.target.chatElement.richText.childNodes.length)return t(),!0;const e=this.target.chatElement.richText.childNodes[0];if(!e.getAttribute||e.getAttribute("data-set-richType")!==RICH_GRID||0===e.childNodes.length)return t(),!0;const i=e.childNodes[0];if(!i.getAttribute||i.getAttribute("data-set-richType")!==RICH_MARK||0===i.childNodes.length)return t(),!0;const n=i.childNodes[0];if(!n.getAttribute||n.getAttribute("data-set-richType")!==RICH_INPUT||0===n.childNodes.length)return t(),!0;return 0===n.childNodes[0].textContent.length?(t(),!0):void 0}}class ChatOperateNode{constructor(t){__publicField(this,"target"),__publicField(this,"rankLen",4),this.target=t}getCurrentNodes(){const t=[];return Array.from(this.target.chatElement.richText.children,(e,i)=>{t.push(this.analyzeGrid(e,i))}),t}getRank(t){let e=t+1+"";const i=this.rankLen-e.length;for(let t=0;t<i;t++)e="0"+e;return e}analyzeGrid(t,e){const i={type:"gridBox",rank:this.getRank(e),children:[]};return Array.from(t.children,(t,e)=>{switch(t.getAttribute("data-set-richType")){case RICH_MARK:i.children.push(this.analyzeMark(t,e,i.rank));break;case RICH_TAG:i.children.push(this.analyzeTag(t,e,i.rank))}}),i}analyzeMark(t,e,i){return{type:"gridInput",rank:i+this.getRank(e),text:t.textContent.replace(new RegExp(this.target.chatInput.VOID_KEY,"g"),"")}}analyzeTag(t,e,i){const n=t.children[0],s={type:"htmlTag",rank:i+this.getRank(e)};return n.classList.contains("at-user")?(s.type="userTag",s.dataset={[this.target.options.userProps.id]:n.getAttribute("data-user-id"),[this.target.options.userProps.name]:n.textContent.slice(1)}):n.classList.contains("at-tag")?(s.type="customTag",s.dataset={id:n.getAttribute("data-tag-id"),name:n.textContent.slice(1),prefix:n.getAttribute("data-set-prefix")}):n.classList.contains("at-select")?(s.type="selectTag",s.dataset={id:n.getAttribute("data-select-id"),name:n.textContent,key:n.getAttribute("data-select-key")}):n.classList.contains("at-input")?(s.type="inputTag",s.dataset={key:n.getAttribute("data-input-key"),placeholder:n.children[1].textContent,value:n.children[0].textContent===this.target.chatInput.VOID_KEY?"":n.children[0].textContent.replace(new RegExp(this.target.chatInput.INPUT_TAG_WRAP_KEY[0],"g"),"")}):(s.type="htmlTag",s.html=t.children[0].innerHTML),s}analyzeGridNodes(t){t.children=t.children||[];const e=t.children;if(0===e.length)return void e.push({type:"gridInput",rank:t.rank+this.getRank(0),text:""});const i=[];e.forEach((t,n)=>{if(n===e.length-1)return;const s=n+1;if("gridInput"===t.type&&"gridInput"===e[s].type){let t=s-i.length;i.push(t)}}),i.forEach(t=>{const i=e[t];e[t-1].text+=i.text,e.splice(t,1)});const n=[];e.forEach((t,i)=>{if(i===e.length-1)return;const s=i+1;if("gridInput"!==t.type&&"gridInput"!==e[s].type){let t=s+n.length;n.push(t)}}),n.forEach(t=>{e.splice(t,0,{type:"gridInput",rank:"",text:""})}),"gridInput"!==e[0].type&&e.unshift({type:"gridInput",rank:"",text:""}),"gridInput"!==e[e.length-1].type&&e.push({type:"gridInput",rank:"",text:""}),e.forEach((e,i)=>{e.rank=t.rank+this.getRank(i)})}analyzeNode(t,e=!1){switch(t.type){case"gridInput":return`<span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="${String(""===t.text)}">${""===t.text?this.target.chatInput.VOID_KEY:escapeHtml(t.text)}${e&&""===t.text?"<br>":""}</span></span>`;case"userTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-user" data-user-id="${t.dataset[this.target.options.userProps.id]}">@${escapeHtml(t.dataset[this.target.options.userProps.name])}</span></span>`;case"customTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-tag" data-tag-id="${t.dataset.id}" data-set-prefix="${t.dataset.prefix}">${t.dataset.prefix}${escapeHtml(t.dataset.name)}</span></span>`;case"selectTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-select" data-select-id="${t.dataset.id}" data-select-key="${t.dataset.key}">${escapeHtml(t.dataset.name)}${arrowSvg}</span></span>`;case"htmlTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="chat-set-html">${t.html}</span></span>`;case"inputTag":const i=!Boolean(t.dataset.value),n=escapeHtml(t.dataset.placeholder),s=escapeHtml((t.dataset.value||"").replace(new RegExp(this.target.chatInput.INPUT_TAG_WRAP_KEY[1],"g"),this.target.chatInput.INPUT_TAG_WRAP_KEY)),a=i?`<span class="input-tip">${n}</span>`:`<span class="input-tip chat-view-show" style="display: none">${n}</span>`;return`<span class="chat-tag" contenteditable="false" data-set-richType="${RICH_TAG}"><span class="at-input" contenteditable="false" data-input-key="${t.dataset.key}"><span class="input-write" contenteditable="true">${i?this.target.chatInput.VOID_KEY:s}</span>${a}</span></span>`;case"gridBox":let l="";return this.analyzeGridNodes(t),t.children.forEach((e,i)=>{l+=this.analyzeNode(e,i===t.children.length-1)}),`<p class="chat-grid-wrap" data-set-richType="${RICH_GRID}">${l}</p>`;default:return""}}async insertNode(t){if("gridBox"===t.type){const e=this.analyzeNode(t);let i=document.createElement("div");i.innerHTML=e;const n=i.children[0],s=parseFloat(t.rank)-1;if(-1===s||s>this.target.chatElement.richText.children.length-1)this.target.chatElement.richText.appendChild(n);else{const t=this.target.chatElement.richText.children[s];if(!t)return;this.target.chatElement.richText.insertBefore(n,t)}const a=n.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(a,a.textContent===this.target.chatInput.VOID_KEY?1:a.textContent.length),i=null,await this.target.chatEvent.richTextInput()}else{const e=(t.text||"").length,i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=this.getNodeByRank(i[0]);if(!n)return;const s=parseFloat(i[1])-1;-1==s?n.children.push(t):n.children.splice(s,0,t),await this.updateNode(n,()=>{if("gridInput"===t.type){const t=-1===s||s>n.children.length-1,i=!t&&s%2==0,a=t?n.children[n.children.length-1]:n.children[i?s:s-1];this.setCursorNode(a,i?e:-1)}else if("inputTag"===t.type){const e=this.getElmByRank(t.rank).nextElementSibling;this.target.chatInput.updateGridInputCursor(e.children[0].childNodes[0],0),this.setCursorNode(t,-1)}else{const e=n.children.indexOf(t);this.setCursorNode(n.children[e+1],0)}})}}async updateNode(t,e){const i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=parseFloat(i[0])-1,s=this.target.chatElement.richText.children[n];if("gridBox"===t.type){if(!s)return;this.analyzeGridNodes(t);let i="";if(t.children.forEach((e,n)=>{i+=this.analyzeNode(e,n===t.children.length-1)}),s.innerHTML=i,e)e();else{const t=s.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:t.textContent.length)}return void await this.target.chatEvent.richTextInput()}const a=parseFloat(i[1])-1,l=s.children[a],o=this.getNodeByRank(t.rank);if(!o||t.type!==o.type)return;let r,c;if("gridInput"===t.type){const e=l.children[0];e.innerHTML=escapeHtml(t.text);const i=""!==e.textContent;e.setAttribute("data-set-empty",String(!i)),i||(e.innerHTML=l.nextElementSibling?this.target.chatInput.VOID_KEY:`${this.target.chatInput.VOID_KEY}<br>`),r=e.childNodes[0],c=r.textContent.length}else if("userTag"===t.type){const e=l.children[0];e.setAttribute("data-user-id",t.dataset[this.target.options.userProps.id]),e.textContent=`@${t.dataset[this.target.options.userProps.name]}`;r=l.nextElementSibling.children[0].childNodes[0]}else if("customTag"===t.type){const e=l.children[0];e.setAttribute("data-tag-id",t.dataset.id),e.setAttribute("data-set-prefix",t.dataset.prefix),e.textContent=`${t.dataset.prefix}${t.dataset.name}`;r=l.nextElementSibling.children[0].childNodes[0]}else if("selectTag"===t.type){const e=l.children[0];e.setAttribute("data-select-id",t.dataset.id),e.setAttribute("data-select-key",t.dataset.key),e.childNodes[0].textContent=t.dataset.name;r=l.nextElementSibling.children[0].childNodes[0]}else if("inputTag"===t.type){const i=l.children[0];i.setAttribute("data-input-key",t.dataset.key),i.children[0].textContent=""===t.dataset.value?this.target.chatInput.VOID_KEY:t.dataset.value,i.children[1].textContent=t.dataset.placeholder,domItVisible(i.children[1],""===t.dataset.value,"inline-block"),e=()=>{this.target.chatInput.rangeToInputTag(i)}}else if("htmlTag"===t.type){l.children[0].innerHTML=t.html;r=l.nextElementSibling.children[0].childNodes[0]}e?e():this.target.chatInput.restCursorPos(r,c),await this.target.chatEvent.richTextInput()}getNodeByRank(t){if(!t)return null;const e=t.match(new RegExp(`.{1,${this.rankLen}}`,"g"));if(0===e.length)return null;const i=parseFloat(e[0])-1,n=-1===i?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[i];if(!n)return null;if(1===e.length)return this.analyzeGrid(n,-1===i?this.target.chatElement.richText.children.length-1:i);-1===i&&(e[0]=this.getRank(this.target.chatElement.richText.children.length-1));const s=parseFloat(e[1])-1,a=-1===s?n.lastElementChild:n.children[s];if(!a)return null;return a.getAttribute("data-set-richType")===RICH_MARK?this.analyzeMark(a,-1===s?n.children.length-1:s,e[0]):this.analyzeTag(a,-1===s?n.children.length-1:s,e[0])}async delNodeByRank(t){const e=this.getNodeByRank(t);if(e)if("gridBox"===e.type){const e=parseFloat(t)-1,i=this.target.chatElement.richText.children[e],n=i.nextElementSibling||i.previousElementSibling;if(n){const t=n.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:t.textContent.length)}this.target.chatElement.richText.removeChild(i),0===this.target.chatElement.richText.children.length&&this.target.chatInput.initEditor(!0),await this.target.chatEvent.richTextInput()}else if("gridInput"===e.type)e.text="",await this.updateNode(e);else{const i=e.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=this.getNodeByRank(i[0]),s=n.children[parseFloat(i[1])-1-1],a=s.text.length;n.children=n.children.filter(e=>e.rank!==t),await this.updateNode(n,()=>{this.setCursorNode(s,a)})}}async coverNodes(t){if(t.length<0)return;let e="";t.forEach(t=>{e+=this.analyzeNode(t)}),this.target.chatElement.richText.innerHTML=e,this.target.chatInput.setRangeLastText(),await this.target.chatEvent.richTextInput()}setCursorNode(t,e=-1){const i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=parseFloat(i[0])-1,s=-1===n?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[n];let a=null;if("gridInput"===t.type){const t=parseFloat(i[1])-1;a=-1===t?s.lastElementChild:s.children[t]}else if("gridBox"===t.type)a=-1===e?s.lastElementChild:s.children[0];else if("inputTag"===t.type){const t=parseFloat(i[1])-1,n=s.children[t].children[0].children[0].childNodes[0],a=n.textContent===this.target.chatInput.VOID_KEY?1:-1===e?n.textContent.length:e;this.target.chatInput.setInputTagRange(n,a)}else{const t=parseFloat(i[1])-1,n=s.children[t];a=-1===e?n.nextElementSibling:n.previousElementSibling,e=-1===e?0:-1}if(a){const t=a.children[0].childNodes[0];-1===e&&(e=t.textContent.length),this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:e)}}getCursorNode(){const t=getSelection(),e=t.focusNode;if(e&&e.parentElement&&e.parentElement.classList.contains("input-write")){const i=e.parentElement.parentElement.parentElement;return{node:this.analyzeTag(i,Array.prototype.indexOf.call(i.parentElement.children,i),this.getRank(Array.prototype.indexOf.call(this.target.chatElement.richText.children,i.parentElement))),offset:e.textContent===this.target.chatInput.VOID_KEY?0:t.focusOffset}}const i=this.target.chatInput.vnode.parentElement.parentElement;return{node:this.analyzeMark(i,Array.prototype.indexOf.call(i.parentElement.children,i),this.getRank(Array.prototype.indexOf.call(this.target.chatElement.richText.children,i.parentElement))),offset:this.target.chatInput.vnode.textContent===this.target.chatInput.VOID_KEY?0:this.target.chatInput.cursorIndex}}setSelectNodes(t,e,i=0,n=-1){let s,a;const l=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),o=e.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),r=this.target.chatElement.richText.children[parseFloat(l[0])-1],c=this.target.chatElement.richText.children[parseFloat(o[0])-1];if("gridInput"===t.type)s=r.children[parseFloat(l[1])-1];else if("gridBox"===t.type)s=-1===i?r.lastElementChild:r.children[0];else{const t=parseFloat(l[1])-1,e=r.children[t];s=-1===i?e.nextElementSibling:e.previousElementSibling,i=-1===i?0:-1}if("gridInput"===e.type)a=c.children[parseFloat(o[1])-1];else if("gridBox"===t.type)a=-1===n?c.lastElementChild:c.children[0];else{const t=parseFloat(o[1])-1,e=c.children[t];a=-1===n?e.nextElementSibling:e.previousElementSibling,n=-1===n?0:-1}const h=s.children[0].childNodes[0],d=a.children[0].childNodes[0],p=document.createRange(),g=parseFloat(t.rank)>parseFloat(e.rank);p[g?"setEnd":"setStart"](h,h.textContent===this.target.chatInput.VOID_KEY?1:-1===i?h.textContent.length:i),p[g?"setStart":"setEnd"](d,d.textContent===this.target.chatInput.VOID_KEY?1:-1===n?d.textContent.length:n);const u=getSelection();u.removeAllRanges(),u.addRange(p)}getElmByRank(t){const e=t.match(new RegExp(`.{1,${this.rankLen}}`,"g")),i=parseFloat(e[0])-1,n=-1===i?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[i];if(1===e.length)return n;const s=parseFloat(e[1])-1;return-1===s?n.lastElementChild:n.children[s]}getRankByElm(t){const e=this.target.chatElement.richText.children;let i=null,n=null;return Array.prototype.find.call(e,(e,s)=>t===e?(i=s,!0):Array.prototype.find.call(e.children,(e,a)=>e===t&&(i=s,n=a,!0))),(null!==i?this.getRank(i):"")+(null!==n?this.getRank(n):"")}}class ChatComponent{constructor(t){__publicField(this,"target"),__publicField(this,"components",{}),__publicField(this,"eventTypes",[]),this.target=t}useComponent(t){t.props=t.props||{},t.template=strictMinifyHtml(t.template||""),t.template=convertBlocksToSpans(t.template||"",t.props),this.components[t.name]=t;const e=/bind-([a-zA-Z]+)="([^"]*)"/g,i=[];let n;for(;null!==(n=e.exec(t.template));)i.push({eventType:n[1],handlerName:n[2]});i.forEach(t=>{this.useComponentEvent(t.eventType)})}useComponentEvent(t){if(this.eventTypes.includes(t))return;this.eventTypes.push(t);this.target.chatElement.richText.addEventListener(t,e=>{this.componentEventRecognizer(e,t)})}componentEventRecognizer(t,e){const i=t.target,n=upFindElm(i,20);if(!n||!n.classList.contains("chat-tag")||!n.children[0].classList.contains("chat-set-html"))return;const s=n.children[0].children[0],a=s.getAttribute("data-set-component");if(!a)return;const l=this.components[a];if(!l)return;const o=l.methods,r=this.deppComponentEvent(s,e).reverse();let c=!1,h=0;const d=()=>{if(c)return;const n=r[h];if(i===n||n.contains(i)){const i=n.getAttribute("bind-"+e),a=Object.create(null);for(const t in s.dataset)t in l.props&&(a[t]=s.dataset[t]);const r={componentElm:s,targetElm:n,data:a,eventType:e,eventName:i,stopPropagation:()=>{c=!0}};o[i]&&o[i](r,t)}h<r.length-1&&(h++,d())};d()}deppComponentEvent(t,e){const i=[];return t.getAttribute("bind-"+e)&&i.push(t),t.children&&t.children.length>0&&Array.from(t.children).forEach(t=>{i.push(...this.deppComponentEvent(t,e))}),i}async insertComponent(t,e){const i=this.components[t];if(!i)return;const n=Object.assign({},i.props,e),s=replaceTemplateVariables(i.template,{...n,[ELEMENT_COMPONENT_KEY]:i.name}),a=await this.target.insertHtml(s);return await this.target.chatEvent.richTextInput(),a}async removeComponentElm(t){const e=upFindElm(t,20);e&&(this.target.chatInput.delTag(e),await this.target.chatEvent.richTextInput())}async updateComponentElm(t,e){var i,n;const s=upFindElm(t,20);if(!s)return;const a=null==(n=null==(i=null==s?void 0:s.children[0])?void 0:i.children[0])?void 0:n.getAttribute("data-set-component");if(!a)return;const l=this.components[a];if(!l)return;const o=Object.assign({},l.props,e);s.children[0].innerHTML=replaceTemplateVariables(l.template,{...o,[ELEMENT_COMPONENT_KEY]:l.name}),await this.target.chatEvent.richTextInput()}getComponentElms(t){const e=[],i=this.target.chatElement.richText.querySelectorAll(".chat-tag");return Array.from(i,i=>{this.isComponentElm(i,t)&&e.push(i)}),e}isComponentElm(t,e){return!!(t&&t.children[0]&&t.children[0].children[0])&&t.children[0].children[0].getAttribute("data-set-component")===e}}const DEFAULT_OPTIONS={device:"auto",autoFocus:!0,needDialog:!0,needDebounce:!0,asyncMatch:!1,userList:[],reformList:[],placeholder:"",maxLength:-1,copyType:["text"],uploadImage:void 0,needCallEvery:!0,needCallSpace:!1,userProps:{},customTrigger:[],dialogLabels:{pcPointDialog:{},pcPCheckDialog:{},h5Dialog:{}},wrapKeyFun:t=>t.ctrlKey&&["Enter"].includes(t.key),sendKeyFun:t=>!t.ctrlKey&&["Enter"].includes(t.key)},DEFAULT_USER_PROPS={id:"id",name:"name",avatar:"avatar",pinyin:"pinyin"},DEFAULT_PC_POINT_DIALOG={title:"群成员",callEveryLabel:"所有人",checkLabel:"多选",emptyLabel:"暂无数据"},DEFAULT_PC_CHECK_DIALOG={title:"选择要@的人",searchPlaceholder:"搜素人员名称",searchEmptyLabel:"没有匹配到任何结果",userTagTitle:"研讨成员列表",checkAllLabel:"全选",checkEmptyLabel:"请选择需要@的成员",confirmLabel:"确定",cancelLabel:"取消"},DEFAULT_H5_DIALOG={title:"选择提醒的人",callEveryLabel:"所有人",searchPlaceholder:"搜素人员名称",searchEmptyLabel:"没有匹配到任何结果",confirmLabel:"确定",cancelLabel:"收起"},DEFAULT_REDUCE_CONFIG={saveTagData:!1,needUserId:!1,needTagId:!1,needSelectId:!1,needTipKey:!1,wrapClassName:void 0,rowClassName:void 0,imgToText:!1,identifyLink:!1},KEY_CODE_MAP={"`":["`","~"],"~":["`","~"],1:["1","!"],"!":["1","!"],3:["3","#"],"#":["3","#"],4:["4","$"],$:["4","$"],5:["5","%"],"%":["5","%"],6:["6","^"],"^":["6","^"],7:["7","&"],"&":["7","&"],8:["8","*"],"*":["8","*"],";":[";",":"],":":[";",":"],"/":["/","?"],"?":["/","?"],"\\":["\\","|"],"|":["\\","|"]},arrObSort=function(t,e,i){return t.forEach(t=>{if(i in t){const n=e.indexOf(String(t[i]));-1!==n&&(e[n]=t)}}),e.filter(t=>t[i])};class ChatArea{constructor(t){switch(__publicField(this,"options"),__publicField(this,"deviceInfo",os()),__publicField(this,"chatElement"),__publicField(this,"chatInput"),__publicField(this,"chatEvent"),this.options=Object.assign({},DEFAULT_OPTIONS,t),this.options.device=this.options.device.toLocaleLowerCase(),this.deviceInfo.isTablet&&(this.deviceInfo.isPc=!1),this.options.device){case"pc":this.deviceInfo.isPc=!0;break;case"h5":this.deviceInfo.isPc=!1}this.options.userProps=Object.assign({},DEFAULT_USER_PROPS,t.userProps||{}),this.options.dialogLabels.pcPointDialog=Object.assign({},DEFAULT_PC_POINT_DIALOG,getObjValue(t.dialogLabels,"pcPointDialog",{})),this.options.dialogLabels.pcPCheckDialog=Object.assign({},DEFAULT_PC_CHECK_DIALOG,getObjValue(t.dialogLabels,"pcPCheckDialog",{})),this.options.dialogLabels.h5Dialog=Object.assign({},DEFAULT_H5_DIALOG,getObjValue(t.dialogLabels,"h5Dialog",{})),this.chatElement=new ChatElement(this),this.chatInput=new ChatInput(this),this.chatEvent=new ChatEvent(this),this.updateConfig(t);const e=this;Object.defineProperty(this,"richText",{get:()=>e.chatElement.richText}),Object.defineProperty(this,"textLength",{get:()=>e.chatEvent.textLength}),this.options.autoFocus&&this.nextTick(()=>{this.chatElement.richText.focus()})}updateConfig(t){void 0!==t.copyType&&(this.options.copyType=t.copyType),t.userProps&&(this.options.userProps=Object.assign({},DEFAULT_USER_PROPS,t.userProps)),void 0!==t.uploadImage&&(this.options.uploadImage=t.uploadImage),void 0!==t.placeholder&&(this.chatElement.placeholderElm.textContent=t.placeholder),void 0!==t.maxLength&&(this.options.maxLength=t.maxLength<=0?-1:t.maxLength,this.chatEvent.ruleMaxLength()),this.options.asyncMatch?(this.options.needCallEvery=!1,this.updateUserList([])):(void 0!==t.needCallEvery||t.userList)&&(this.options.needCallEvery=getBoolean(void 0===t.needCallEvery?this.options.needCallEvery:t.needCallEvery),this.updateUserList(t.userList)),void 0!==t.needCallSpace&&this.chatInput.setCallSpace(getBoolean(t.needCallSpace)),void 0!==t.wrapKeyFun&&(this.options.wrapKeyFun=t.wrapKeyFun),void 0!==t.sendKeyFun&&(this.options.sendKeyFun=t.sendKeyFun),t.customTrigger&&(this.options.customTrigger=t.customTrigger.map(t=>(t.keyMap||(t.keyMap=KEY_CODE_MAP[t.prefix]||[]),t)),this.options.needDialog&&this.deviceInfo.isPc&&this.chatElement.bindCustomTrigger()),t.selectList&&(this.options.selectList=t.selectList,this.options.needDialog&&this.deviceInfo.isPc&&this.chatElement.bindSelectList())}updateUserList(t=void 0){const{options:e,chatElement:i}=this;if(t){e.userList=JSON.parse(JSON.stringify(t));const i={[e.userProps.id]:"isALL",[e.userProps.name]:""};e.userList.unshift(i),e.reformList=t.map(t=>({id:String(t[e.userProps.id]),name:String(t[e.userProps.name]||""),avatar:String(t[e.userProps.avatar]||""),pinyin:String(t[e.userProps.pinyin]||"")}))}const n=e.userList[0];n&&"isALL"===n[e.userProps.id]&&(n[e.userProps.name]=this.deviceInfo.isPc?e.dialogLabels.pcPointDialog.callEveryLabel:e.dialogLabels.h5Dialog.callEveryLabel),e.needDialog&&(this.deviceInfo.isPc?i.updatePCUser():i.updateH5User())}searchUserList(t){return this.options.reformList.filter(e=>pinyinMatch(e.name,e.pinyin||"",t))}getReduceNode(t){const e=Object.assign({},DEFAULT_REDUCE_CONFIG,t||{});e.saveTagData&&(e.needUserId=!0,e.needTagId=!0,e.needSelectId=!0,e.needTipKey=!0);const i=/(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g,n=this.chatElement.richText.cloneNode(!0).children||[],s=document.createElement("div");return e.wrapClassName&&(s.className=e.wrapClassName),Array.from(n,(t,n)=>{const a=document.createElement("p");Array.from(t.children,t=>{const n=t.children[0];this.chatInput.getNodeEmpty(n)||(n.removeAttribute("data-set-richType"),n.removeAttribute("contenteditable"),n.removeAttribute("data-set-empty"),e.needUserId||n.removeAttribute("data-user-id"),e.needTagId||(n.removeAttribute("data-set-prefix"),n.removeAttribute("data-tag-id")),e.needSelectId||(n.removeAttribute("data-select-id"),n.removeAttribute("data-select-key")),e.imgToText&&n.firstChild&&"IMG"===n.firstChild.tagName&&(n.classList.add("img-to-text"),n.innerHTML=`[${n.firstChild.getAttribute("data-img-text")||"you need set data-img-text"}]`),e.identifyLink&&n.classList.contains("chat-grid-input")&&(n.innerHTML=n.innerHTML.replace(i,t=>`<a class="chat-grid-link" href="${t}" target="_blank">${t}</a>`)),n.classList.contains("at-select")&&(n.classList.remove("aim"),n.removeChild(n.lastChild)),n.classList.contains("at-input")&&(e.needTipKey?n.setAttribute("data-input-tip",n.children[1].textContent):n.removeAttribute("data-input-key"),n.textContent=n.children[0].textContent!==this.chatInput.VOID_KEY?n.children[0].textContent:n.children[1].textContent,n.textContent=n.textContent.replace(new RegExp(this.chatInput.INPUT_TAG_WRAP_KEY[0],"g"),"")),a.appendChild(n))}),e.rowClassName&&(a.className=e.rowClassName),a.innerHTML||(a.innerHTML="<br>"),s.appendChild(a)}),s}getText(t){let e="";const i=this.getReduceNode(t);return Array.from(i.children,(t,i)=>{e=e+(i>0?"\n":"")+t.textContent}),e}getHtml(t){return this.getReduceNode(t).innerHTML}async reverseAnalysis(t,e){if(!t)return;const i=document.createElement("div");i.innerHTML=t;const n=i.children;Array.from(n,t=>{t.className="chat-grid-wrap",t.setAttribute("data-set-richType",RICH_GRID);const e=t.children,i={},n=[];Array.from(e,(s,a)=>{if(-1!==s.className.indexOf("chat-grid-input")){const t=s.textContent||"";return s.hasAttribute("class")&&s.removeAttribute("class"),s.setAttribute("data-set-richType",RICH_MARK),void(s.innerHTML=`<span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="false">${escapeHtml(t)}</span>`)}if(s.tagName&&"BR"===s.tagName.toLocaleUpperCase()){const e=this.chatInput.getGridElm(!0);return t.removeChild(s),void t.appendChild(e)}const l=s.cloneNode(!0);l.setAttribute("contenteditable","false");const o=document.createElement("span");if(o.className="chat-tag",o.setAttribute("contenteditable","false"),o.setAttribute("data-set-richType",RICH_TAG),o.appendChild(l),i[a]=o,a!==e.length-1){-1===e[a+1].className.indexOf("chat-grid-input")&&n.push(a)}else n.push(a);0===a&&n.push(-1)});for(const n in i){const s=Number(n),a=i[n].lastChild;if(a.classList.contains("at-select"))a.innerHTML=`${escapeHtml(a.textContent)}${arrowSvg}`;else if(a.classList.contains("at-input")){const t=escapeHtml(a.getAttribute("data-input-tip")),e=escapeHtml((a.textContent||"").replace(new RegExp(this.chatInput.INPUT_TAG_WRAP_KEY[1],"g"),this.chatInput.INPUT_TAG_WRAP_KEY)),i=""===a.textContent,n=i?`<span class="input-tip">${t}</span>`:`<span class="input-tip chat-view-hidden" style="display: none">${t}</span>`;a.innerHTML=`<span class="input-write" contenteditable="true">${i?this.chatInput.VOID_KEY:e}</span>${n}`,a.removeAttribute("data-input-tip")}s===e.length-1?(t.removeChild(e[s]),t.appendChild(i[n])):(t.insertBefore(i[n],e[s+1]),t.removeChild(e[s]))}const s=[],a=t.children;n.forEach(t=>{t===a.length-1?s.push("isEnd"):s.push(a[t+1])}),s.forEach(e=>{const i=this.chatInput.getGridElm(!0);if("isEnd"===e)t.appendChild(i);else{const n=i.children[0];n.childNodes.length>1&&n.removeChild(n.childNodes[1]),t.insertBefore(i,e)}})}),e?(this.chatInput.setRangeLastText(),await this.chatEvent.insertInsideHtml(i.innerHTML,!1)):(this.chatElement.richText.innerHTML=i.innerHTML,this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput())}async insertHtml(t){if(!t)return;const e=document.createElement("span");e.innerHTML=t,e.className="chat-set-html";const i=this.chatInput.createNewDom(e);return this.chatInput.replaceRegContent(i,!1),await this.chatEvent.richTextInput(),i}async insertText(t){if(!t)return;t=escapeHtml(t);const e=new RegExp(`[${this.chatInput.ZERO_WIDTH_KEY}|${this.chatInput.VOID_KEY}]`,"ig"),i=t.replace(e,"");if(!i)return;const n=i.split("\n");let s="";n.forEach(t=>{const e=""!==t;s+=`<p class="chat-grid-wrap" data-set-richType="${RICH_GRID}"><span data-set-richType="${RICH_MARK}"><span class="chat-grid-input" data-set-richType="${RICH_INPUT}" data-set-empty="${e?"false":"true"}">${e?t:this.chatInput.VOID_KEY+"<br>"}</span></span></p>`}),await this.chatEvent.insertInsideHtml(s)}getCallUserList(){const t=this.chatElement.richText.querySelectorAll(".at-user");if(t&&t.length>0){const e=Array.from(t,t=>t.dataset.userId);return arrObSort(this.options.userList,e,this.options.userProps.id)}return[]}getCallUserTagList(){const t=this.chatElement.richText.querySelectorAll(".at-user");if(t&&t.length>0){const e=[];return Array.from(t,t=>{e.some(e=>e[this.options.userProps.id]===t.dataset.userId)||e.push({[this.options.userProps.id]:t.dataset.userId,[this.options.userProps.name]:t.textContent.slice(1)})}),e}return[]}getCustomTagList(){const t=Object.keys(this.chatElement.customTags),e={},i=this.chatElement.richText.querySelectorAll(".at-tag");return t.forEach(t=>{let n=Array.prototype.filter.call(i,e=>e.getAttribute("data-set-prefix")===String(t)).map(t=>t.getAttribute("data-tag-id"));n=n.filter((t,e)=>n.indexOf(t)===e),e[t]=arrObSort(this.chatElement.customTags[t],n,"id")}),e}getSelectTagList(){const t=Object.keys(this.chatElement.selectTags),e={},i=this.chatElement.richText.querySelectorAll(".at-select");return t.forEach(t=>{let n=Array.prototype.filter.call(i,e=>e.getAttribute("data-select-key")===String(t)).map(t=>t.getAttribute("data-select-id"));n=n.filter((t,e)=>n.indexOf(t)===e),e[t]=arrObSort(this.chatElement.selectTags[t],n,"id")}),e}getInputTagList(){const t={},e=this.chatElement.richText.querySelectorAll(".at-input");return Array.from(e,e=>{const i=e.getAttribute("data-input-key"),n=e.children[0].textContent===this.chatInput.VOID_KEY?null:e.children[0].textContent;t[i]||(t[i]=[]),t[i].push(n)}),t}async clear(t){this.chatInput.initEditor(!0,t),this.clearHistory(),await this.chatEvent.richTextInput(!1)}lineBreak(){this.cursorToLastRecord(),"inputTag"===this.chatInput.lastCursorType?this.chatInput.setInputTagWrap(this.chatInput.inputTag_vnode.parentElement):this.chatInput.setWrap(!0)}isEmpty(t=!1){if(0===this.chatElement.richText.children.length)return!0;if(-1!==this.chatElement.richText.innerHTML.indexOf("chat-tag"))return!1;if(1===this.chatElement.richText.children.length){const t=this.chatElement.richText.children[0],e=t.children[0].children[0];if(1===t.children.length&&(0===e.textContent.length||e.textContent===this.chatInput.VOID_KEY))return!0}return!!t&&""===this.chatElement.richText.textContent.trim()}dispose(){if(this.options.elm.removeChild(this.chatElement.richText),this.options.elm.removeChild(this.chatElement.placeholderElm),this.options.needDialog)if(this.deviceInfo.isPc){const t=this.chatElement.pcElms.containerDialogElm.parentElement;t&&t.removeChild(this.chatElement.pcElms.containerDialogElm)}else document.body.removeChild(this.chatElement.h5Elms.dialogElm)}showPCPointDialog(){this.options.needDialog&&(this.insertText("@"),this.options.asyncMatch&&domItVisible(this.chatElement.pcElms.pointDialogEmptyElm,!0,"flex"),this.chatEvent.outerApply=!0,this.chatElement.showPointDialog(),sleep(50).then(()=>{this.chatEvent.outerApply=!1}))}showPCCheckDialog(){this.options.needDialog&&!this.options.asyncMatch&&(this.chatEvent.winClick(),this.chatElement.checkboxRows=[],domItVisible(this.chatElement.pcElms.checkDialogElm,!0),updateElmClass(document.body,"disable-scroll",!0),this.chatElement.pcElms.checkDialogTagsElm.scrollTop=0,this.chatElement.pcElms.checkDialogUsersElm.scrollTop=0,this.chatElement.pcElms.checkDialogSearchInputElm.value="",this.chatElement.updateCheckDialogTags(),this.chatElement.isExternalCallPopup=!0)}showPCCustomTagDialog(t){this.options.needDialog&&!this.options.asyncMatch&&(this.insertText(t),this.chatEvent.outerApply=!0,this.chatElement.showCustomTagDialog(t),sleep(50).then(()=>{this.chatEvent.outerApply=!1}))}showPCSelectDialog(t,e){this.chatElement.exitCustomTagDialog(),this.chatElement.exitPointDialog(),this.chatEvent.outerApply=!0,e&&(this.chatElement.exitSelectDialog(),this.chatElement.pcElms.selectDialogAim=e),this.chatElement.pcElms.selectDialogKey=t,this.chatEvent.debounceEvents.selectDialogToAim(),sleep(50).then(()=>{this.chatEvent.outerApply=!1})}showH5Dialog(){this.chatElement.richText&&this.chatElement.richText.blur(),Array.from(this.chatElement.h5Elms.dialogMainElm.children,t=>{t.style.display="",updateElmClass(t,"user-popup-check-item-check")}),updateElmClass(this.chatElement.h5Elms.dialogCheckElm,"disabled",!0),domItVisible(this.chatElement.h5Elms.dialogElm,!0),updateElmClass(document.body,"disable-scroll",!0),this.options.asyncMatch&&domItVisible(this.chatElement.h5Elms.dialogEmptyElm,!0,"flex"),this.chatElement.h5Elms.dialogMainElm.scrollTop=0,this.chatElement.isExternalCallPopup=!0}disabled(){this.chatElement.richText.setAttribute("contenteditable","false"),updateElmClass(this.chatElement.richText,"chat-rich-text-disabled",!0)}enable(){this.chatElement.richText.setAttribute("contenteditable","true"),updateElmClass(this.chatElement.richText,"chat-rich-text-disabled"),this.chatInput.setRangeLastText()}async setUserTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",[t]);const e=this.chatInput.createChatTagElm({id:t[this.options.userProps.id],name:t[this.options.userProps.name]},"@","at-user","user-id");this.chatInput.replaceRegContent(e,!1),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async setCustomTag(t,e){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,!1,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",t,e)}async setSelectTag(t,e){if(this.chatInput.updateNodeCursor(),e||(e=this.chatElement.pcElms.selectDialogKey),this.chatEvent.triggerChatEvent("selectCheck",t,e),this.chatElement.pcElms.selectDialogAim&&this.chatElement.pcElms.selectDialogAim.classList.contains("at-select")){const e=this.chatElement.pcElms.selectDialogAim.getAttribute("data-select-id"),i=this.chatElement.pcElms.selectDialogAim.parentElement.nextElementSibling.childNodes[0].childNodes[0];if(this.chatInput.restCursorPos(i),e===t.id)return;this.chatElement.pcElms.selectDialogAim.setAttribute("data-select-id",t.id),this.chatElement.pcElms.selectDialogAim.childNodes[0].textContent=t.name}else{const i=document.createElement("span");i.setAttribute("class","at-select"),i.setAttribute("data-select-key",e),i.setAttribute("data-select-id",t.id),i.innerHTML=`${escapeHtml(t.name)}${arrowSvg}`;const n=this.chatInput.createNewDom(i);this.chatInput.replaceRegContent(n,!1)}await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterSelectCheck",t,e)}async setInputTag(t,e,i=""){this.chatInput.updateNodeCursor();const n=document.createElement("span");n.setAttribute("class","at-input"),n.setAttribute("contenteditable","false"),n.setAttribute("data-input-key",t);const s=document.createElement("span");s.setAttribute("class","input-write"),s.setAttribute("contenteditable","true"),s.textContent=i||this.chatInput.VOID_KEY;const a=document.createElement("span");a.setAttribute("class","input-tip"),a.textContent="["+(e||"Please input")+"]",n.appendChild(s),n.appendChild(a);const l=this.chatInput.createNewDom(n);this.chatInput.replaceRegContent(l,!1),i&&this.chatInput.watchInputTag(s),this.chatInput.rangeToInputTag(n),await this.chatEvent.richTextInput()}async matchSetTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",[t]),await this.chatInput.onceSearchCall(t,this.chatEvent.startOpenIndex),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async onceSetTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",[t]),await this.chatInput.onceCall({id:t[this.options.userProps.id],name:t[this.options.userProps.name]}),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async batchSetTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",t);const e=[];for(let i=0;i<=t.length-1;)e.push({id:t[i][this.options.userProps.id],name:t[i][this.options.userProps.name]}),i++;await this.chatInput.batchReplaceRegContent(e,!this.chatElement.isExternalCallPopup),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",t)}async onceSetCustomTag(t,e){this.chatInput.updateNodeCursor(),e||(e=this.chatElement.pcElms.customTagDialogTagKey),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,!0,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",t,e)}async matchSetCustomTag(t,e){this.chatInput.updateNodeCursor(),e||(e=this.chatElement.pcElms.customTagDialogTagKey),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,this.chatEvent.startOpenIndex,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",e)}async undo(){const{chatEvent:t}=this;if(!t.doOverHistory||!t.undoHistory||t.undoHistory.length<=1)return;const e=t.undoHistory[t.undoHistory.length-2],i=t.undoHistory[t.undoHistory.length-1];t.redoHistory.push(i),t.undoHistory.pop(),await t.setChatHistory(e)}async redo(){const{chatEvent:t}=this;if(!t.doOverHistory||!t.redoHistory||t.redoHistory.length<1)return;const e=t.redoHistory[t.redoHistory.length-1];t.redoHistory.pop(),t.undoHistory.push(e),await t.setChatHistory(e)}clearHistory(){const{gridIndex:t,markIndex:e,tagIndex:i}=this.chatInput.getRichTextNodeIndex();this.chatEvent.undoHistory=[{html:this.chatElement.richText.innerHTML,gridIndex:t||0,markIndex:e||0,tagIndex:i||0,type:this.chatInput.lastCursorType,cursorIndex:this.chatInput.cursorIndex,inputTag_cursorIndex:this.chatInput.inputTag_cursorIndex}],this.chatEvent.redoHistory=[]}cursorMove(t){if(0===t)return void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const e=new RegExp(`[${this.chatInput.ZERO_WIDTH_KEY}|${this.chatInput.VOID_KEY}]`,"ig");if(t>0){const i=this.chatInput.vnode.textContent.replace(e,"").slice(this.chatInput.cursorIndex);if(i.length>=t)return this.chatInput.cursorIndex+=t,void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const n=this.chatInput.vnode.parentElement.parentElement,s=n.parentElement;let a=Boolean(n.nextElementSibling&&n.nextElementSibling.nextElementSibling);const l=Boolean(s.nextElementSibling);if(!a&&!l)return this.chatInput.cursorIndex+=i.length,0===this.chatInput.cursorIndex&&(this.chatInput.cursorIndex=1),void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const o=t-i.length-1,r=a?n.nextElementSibling.nextElementSibling:s.nextElementSibling.children[0],{rangeNode:c,rangeIndex:h}=this.chatInput.getOffsetRange(o,r);this.chatInput.restCursorPos(c,h)}else if(t<0){let i=Math.abs(t);const n=this.chatInput.vnode.textContent.replace(e,"").slice(0,this.chatInput.cursorIndex);if(n.length>=i)return this.chatInput.cursorIndex-=i,void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const s=this.chatInput.vnode.parentElement.parentElement,a=s.parentElement,l=Boolean(s.previousElementSibling&&s.previousElementSibling.previousElementSibling),o=Boolean(a.previousElementSibling);if(!l&&!o)return void this.chatInput.restCursorPos(this.chatInput.vnode);i=i-n.length-1;const r=l?s.previousElementSibling.previousElementSibling:a.previousElementSibling.lastElementChild,{rangeNode:c,rangeIndex:h}=this.chatInput.getOffsetRange(i,r,!0);this.chatInput.restCursorPos(c,h)}}async cursorDel(t){if(0===t)return void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const e=this.chatInput.vnode,i=this.chatInput.cursorIndex;this.cursorMove(t);const n=this.chatInput.vnode,s=this.chatInput.cursorIndex,a=document.createRange();t<0?(a.setStart(n,s),a.setEnd(e,i)):(a.setStart(e,i),a.setEnd(n,s));const l=getSelection();l.removeAllRanges(),l.addRange(a),await this.chatEvent.removeRange()}cursorToLastRecord(){this.chatInput.setRangeLastRecord()}async delUserTags(t){const e=t||this.options.userList.map(t=>t[this.options.userProps.id]),i=this.chatElement.richText.querySelectorAll(".at-user"),n=[];Array.from(i,t=>{const i=t.getAttribute("data-user-id");e.some(t=>String(t)===i)&&n.push(t.parentElement)});for(let t=0;t<n.length;){const e=n[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delCustomTags(t,e){const i=this.options.customTrigger.find(e=>e.prefix===t);if(!i||0===i.tagList.length)return;const n=e||i.tagList.map(t=>t.id),s=this.chatElement.richText.querySelectorAll(".at-tag"),a=[];Array.from(s,e=>{const i=e.getAttribute("data-set-prefix"),s=e.getAttribute("data-tag-id");i===t&&n.some(t=>String(t)===s)&&a.push(e.parentElement)});for(let t=0;t<a.length;){const e=a[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delSelectTags(t,e){const i=this.options.selectList.find(e=>e.key===t);if(!i||0===i.options.length)return;const n=e||i.options.map(t=>t.id),s=this.chatElement.richText.querySelectorAll(".at-select"),a=[];Array.from(s,e=>{const i=e.getAttribute("data-select-key"),s=e.getAttribute("data-select-id");i===t&&n.some(t=>String(t)===s)&&a.push(e.parentElement)});for(let t=0;t<a.length;){const e=a[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delInputTags(t){const e=this.chatElement.richText.querySelectorAll(".at-input"),i=[];Array.from(e,e=>{if(t){const n=e.getAttribute("data-input-key");t.some(t=>String(t)===n)&&i.push(e.parentElement)}else i.push(e.parentElement)});for(let t=0;t<i.length;){const e=i[t];this.chatInput.delTag(e),t++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}openTipTag(t){this.chatElement.createTipElm(t),this.cursorToLastRecord()}openCustomTipTag(t){const e=this.chatElement.createCustomTipElm(t);return this.cursorToLastRecord(),e}closeTipTag(){this.chatElement.tipElm&&this.chatElement.removeTipElm()}addEventListener(t,e){this.chatEvent.chatEventModule[t].push(e)}removeEventListener(t,e){const i=this.chatEvent.chatEventModule[t],n=i.indexOf(e);-1!==n&&i.splice(n,1)}revisePCPointDialogLabel(t){this.options.needDialog&&(this.options.dialogLabels.pcPointDialog=Object.assign({},DEFAULT_PC_POINT_DIALOG,t||{}),this.chatElement.pcElms.pointDialogElm.querySelector(".call-user-dialog-header-title").textContent=this.options.dialogLabels.pcPointDialog.title,this.chatElement.pcElms.pointDialogCheckElm.textContent=this.options.dialogLabels.pcPointDialog.checkLabel,this.chatElement.pcElms.pointDialogEmptyElm&&(this.chatElement.pcElms.pointDialogEmptyElm.children[1].textContent=this.options.dialogLabels.pcPointDialog.emptyLabel),this.options.asyncMatch||this.updateUserList())}revisePCCheckDialogLabel(t){this.options.needDialog&&!this.options.asyncMatch&&(this.options.dialogLabels.pcPCheckDialog=Object.assign({},DEFAULT_PC_CHECK_DIALOG,t||{}),this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-container-header").children[0].textContent=this.options.dialogLabels.pcPCheckDialog.title,this.chatElement.pcElms.checkDialogSearchInputElm.setAttribute("placeholder",this.options.dialogLabels.pcPCheckDialog.searchPlaceholder),this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-search-empty").textContent=this.options.dialogLabels.pcPCheckDialog.searchEmptyLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-right-box-title").textContent=this.options.dialogLabels.pcPCheckDialog.userTagTitle,this.chatElement.pcElms.checkDialogUsersElm.children[0].children[2].textContent=this.options.dialogLabels.pcPCheckDialog.checkAllLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".btn-submit").textContent=this.options.dialogLabels.pcPCheckDialog.confirmLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".btn-close").textContent=this.options.dialogLabels.pcPCheckDialog.cancelLabel)}reviseH5DialogLabel(t){this.options.needDialog&&(this.options.dialogLabels.h5Dialog=Object.assign({},DEFAULT_H5_DIALOG,t||{}),this.chatElement.h5Elms.dialogElm.querySelector(".popup-title").textContent=this.options.dialogLabels.h5Dialog.title,this.chatElement.h5Elms.dialogSearchElm.setAttribute("placeholder",this.options.dialogLabels.h5Dialog.searchPlaceholder),this.chatElement.h5Elms.dialogEmptyElm.children[1].textContent=this.options.dialogLabels.h5Dialog.searchEmptyLabel,this.chatElement.h5Elms.dialogCheckElm.textContent=this.options.dialogLabels.h5Dialog.confirmLabel,this.chatElement.h5Elms.dialogShowElm.textContent=this.options.dialogLabels.h5Dialog.cancelLabel,this.options.asyncMatch||this.updateUserList())}async nextTick(t){return new Promise(e=>{requestAnimationFrame(()=>{const i=t();i instanceof Promise?i.then(()=>{e()}):e()})})}createOperateNode(){return new ChatOperateNode(this)}createChatComponent(){return new ChatComponent(this)}}__publicField(ChatArea,"version","6.0.3");
1017
1017
  // EXTERNAL MODULE: ./node_modules/chatarea/lib/ChatArea.css
1018
1018
  var lib_ChatArea = __webpack_require__(2736);
1019
1019
  ;// ./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/EditorSender/src/main.vue?vue&type=script&lang=js