{"version":3,"file":"BX_ShapeNotes.min.mjs","sources":["../../../src/shapes/BX_ShapeNotes.ts"],"sourcesContent":["//@ts-nocheck\nimport { getFabricDocument } from '../env';\nimport { TClassProperties } from '../typedefs';\nimport { Textbox } from './Textbox';\nimport { classRegistry } from '../ClassRegistry';\nimport { createRectNotesDefaultControls } from '../controls/commonControls';\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const shapeNotesDefaultValues: Partial<TClassProperties<ShapeNotes>> = {\n  minWidth: 20,\n  dynamicMinWidth: 2,\n  lockScalingFlip: true,\n  noScaleCache: false,\n  _wordJoiners: /[ \\t\\r]/,\n  splitByGrapheme: true,\n  obj_type: 'WBShapeNotes',\n  height: 138,\n  maxHeight: 138,\n  textAlign: 'center',\n  uniformScaling: false,\n  centeredScaling: false,\n  verticalAlign: 'middle',\n  cornerStrokeColor: 'gray',\n  cornerStyle: 'circle',\n  cornerColor: 'white',\n  transparentCorners: false,\n};\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class ShapeNotes extends Textbox {\n  /**selectable\n   * Minimum width of textbox, in pixels.\n   * @type Number\n   * @default\n   */\n  declare minWidth: number;\n\n  /* boardx cusotm function */\n  declare _id: string;\n\n  declare obj_type: string;\n\n  declare locked: boolean;\n\n  declare whiteboardId: string;\n\n  declare userId: string;\n\n  declare timestamp: Date;\n\n  declare verticalAlign: string;\n\n  declare zIndex: number;\n\n  declare lines: object[];\n\n  declare relationship: object[];\n\n  declare icon: string;\n\n  public extendPropeties = [\n    'obj_type',\n    'whiteboardId',\n    'userId',\n    'timestamp',\n    'zIndex',\n    'locked',\n    'verticalAlign',\n    'lines',\n    '_id',\n    'zIndex',\n    'relationship',\n    'icon',\n  ];\n  /**\n   * Minimum calculated width of a textbox, in pixels.\n   * fixed to 2 so that an empty textbox cannot go to 0\n   * and is still selectable without text.\n   * @type Number\n   * @default\n   */\n  declare dynamicMinWidth: number;\n\n  /**\n   * Use this boolean property in order to split strings that have no white space concept.\n   * this is a cheap way to help with chinese/japanese\n   * @type Boolean\n   * @since 2.6.0\n   */\n  declare splitByGrapheme: boolean;\n\n  static textLayoutProperties = [...Textbox.textLayoutProperties, 'width'];\n\n  static ownDefaults: Record<string, any> = shapeNotesDefaultValues;\n\n  static getDefaults() {\n    return {\n      ...super.getDefaults(),\n      controls: createRectNotesDefaultControls(),\n      ...ShapeNotes.ownDefaults,\n    };\n  }\n\n  /**\n   * Unlike superclass's version of this function, Textbox does not update\n   * its width.\n   * @private\n   * @override\n   */\n  initDimensions() {\n    if (this.__skipDimension) {\n      return;\n    }\n\n    this.clearContextTop();\n    this._clearCache();\n\n    const newLines = this._splitText();\n\n    if (this.isEditing) {\n      this.initDelayedCursor();\n\n      const preHeight = this.height;\n      const total = this._getTotalLineHeights() + this.getTopOffset();\n      this.height = Math.max(this.maxHeight, total);\n      const yOffset = this.height - preHeight;\n      this.top += yOffset / 2;\n    } else if (this._textLines && this._textLines.length > 0) {\n      if (this.height === this.maxHeight) {\n        /**\n         * scaling\n         * total height of _textLines < maxHeight\n         */\n        let lineHeights = 0;\n        const tmp = [];\n        for (let i = 0, len = this._textLines.length; i < len; i++) {\n          const heightOfLine = this.getHeightOfLine(i);\n          lineHeights += heightOfLine;\n          if (lineHeights <= this.height - this.getTopOffset()) {\n            tmp.push(this._textLines[i]);\n          }\n        }\n        if (tmp.length > 0) {\n          const preLines = this._textLines.length;\n          this._textLines = tmp;\n          if (tmp.length !== preLines) {\n            // need add ellipsis at last line\n            const lastIndex = this._textLines.length - 1,\n              lastLine = this._textLines[lastIndex];\n            lastLine.pop();\n            lastLine.pop();\n            lastLine.pop();\n            lastLine.push('.');\n            lastLine.push('.');\n            lastLine.push('.');\n          }\n        }\n      } else if (this.height > this.maxHeight) {\n        /**\n         * height > maxHeight\n         * exit editing and _textlines total height > maxHeight\n         */\n        // console.log('### exit editing & initDimensions');\n      }\n    }\n\n    // clear dynamicMinWidth as it will be different after we re-wrap line\n    this.dynamicMinWidth = 0;\n    // wrap lines\n    this._styleMap = this._generateStyleMap(newLines);\n    // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n    if (this.dynamicMinWidth > this.width) {\n      this._set('width', this.dynamicMinWidth);\n    }\n    if (this.textAlign.indexOf('justify') !== -1) {\n      // once text is measured we need to make space fatter to make justified text.\n      this.enlargeSpaces();\n    }\n\n    return this.height;\n  }\n  /**\n   * Generate an object that translates the style object so that it is\n   * broken up by visual lines (new lines and automatic wrapping).\n   * The original text styles object is broken up by actual lines (new lines only),\n   * which is only sufficient for Text / IText\n   * @private\n   */\n  _generateStyleMap(textInfo) {\n    let realLineCount = 0,\n      realLineCharCount = 0,\n      charCount = 0;\n    const map = {};\n\n    for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n      if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n        realLineCharCount = 0;\n        charCount++;\n        realLineCount++;\n      } else if (\n        !this.splitByGrapheme &&\n        this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n        i > 0\n      ) {\n        // this case deals with space's that are removed from end of lines when wrapping\n        realLineCharCount++;\n        charCount++;\n      }\n\n      map[i] = { line: realLineCount, offset: realLineCharCount };\n\n      charCount += textInfo.graphemeLines[i].length;\n      realLineCharCount += textInfo.graphemeLines[i].length;\n    }\n\n    return map;\n  }\n\n  /**\n   * Returns true if object has a style property or has it on a specified line\n   * @param {Number} lineIndex\n   * @return {Boolean}\n   */\n  styleHas(property, lineIndex: number): boolean {\n    if (this._styleMap && !this.isWrapping) {\n      const map = this._styleMap[lineIndex];\n      if (map) {\n        lineIndex = map.line;\n      }\n    }\n    return super.styleHas(property, lineIndex);\n  }\n\n  /**\n   * Returns true if object has no styling or no styling in a line\n   * @param {Number} lineIndex , lineIndex is on wrapped lines.\n   * @return {Boolean}\n   */\n  isEmptyStyles(lineIndex: number): boolean {\n    if (!this.styles) {\n      return true;\n    }\n    let offset = 0,\n      nextLineIndex = lineIndex + 1,\n      nextOffset,\n      shouldLimit = false;\n    const map = this._styleMap[lineIndex],\n      mapNextLine = this._styleMap[lineIndex + 1];\n    if (map) {\n      lineIndex = map.line;\n      offset = map.offset;\n    }\n    if (mapNextLine) {\n      nextLineIndex = mapNextLine.line;\n      shouldLimit = nextLineIndex === lineIndex;\n      nextOffset = mapNextLine.offset;\n    }\n    const obj =\n      typeof lineIndex === 'undefined'\n        ? this.styles\n        : { line: this.styles[lineIndex] };\n    for (const p1 in obj) {\n      for (const p2 in obj[p1]) {\n        if (p2 >= offset && (!shouldLimit || p2 < nextOffset)) {\n          // eslint-disable-next-line no-unused-vars\n          for (const p3 in obj[p1][p2]) {\n            return false;\n          }\n        }\n      }\n    }\n    return true;\n  }\n\n  /**\n   * @param {Number} lineIndex\n   * @param {Number} charIndex\n   * @private\n   */\n  _getStyleDeclaration(lineIndex: number, charIndex: number) {\n    if (this._styleMap && !this.isWrapping) {\n      const map = this._styleMap[lineIndex];\n      if (!map) {\n        return null;\n      }\n      lineIndex = map.line;\n      charIndex = map.offset + charIndex;\n    }\n    return super._getStyleDeclaration(lineIndex, charIndex);\n  }\n\n  /**\n   * @param {Number} lineIndex\n   * @param {Number} charIndex\n   * @param {Object} style\n   * @private\n   */\n  _setStyleDeclaration(lineIndex: number, charIndex: number, style: object) {\n    const map = this._styleMap[lineIndex];\n    lineIndex = map.line;\n    charIndex = map.offset + charIndex;\n\n    this.styles[lineIndex][charIndex] = style;\n  }\n\n  /**\n   * @param {Number} lineIndex\n   * @param {Number} charIndex\n   * @private\n   */\n  _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n    const map = this._styleMap[lineIndex];\n    lineIndex = map.line;\n    charIndex = map.offset + charIndex;\n    delete this.styles[lineIndex][charIndex];\n  }\n\n  /**\n   * probably broken need a fix\n   * Returns the real style line that correspond to the wrapped lineIndex line\n   * Used just to verify if the line does exist or not.\n   * @param {Number} lineIndex\n   * @returns {Boolean} if the line exists or not\n   * @private\n   */\n  _getLineStyle(lineIndex: number): boolean {\n    const map = this._styleMap[lineIndex];\n    return !!this.styles[map.line];\n  }\n\n  /**\n   * Set the line style to an empty object so that is initialized\n   * @param {Number} lineIndex\n   * @param {Object} style\n   * @private\n   */\n  _setLineStyle(lineIndex: number) {\n    const map = this._styleMap[lineIndex];\n    this.styles[map.line] = {};\n  }\n\n  /**\n   * Wraps text using the 'width' property of Textbox. First this function\n   * splits text on newlines, so we preserve newlines entered by the user.\n   * Then it wraps each line using the width of the Textbox by calling\n   * _wrapLine().\n   * @param {Array} lines The string array of text that is split into lines\n   * @param {Number} desiredWidth width you want to wrap to\n   * @returns {Array} Array of lines\n   */\n  _wrapText(lines: Array<any>, desiredWidth: number): Array<any> {\n    const wrapped = [];\n    this.isWrapping = true;\n    for (let i = 0; i < lines.length; i++) {\n      wrapped.push(...this._wrapLine(lines[i], i, desiredWidth));\n    }\n    this.isWrapping = false;\n    return wrapped;\n  }\n\n  /**\n   * Helper function to measure a string of text, given its lineIndex and charIndex offset\n   * It gets called when charBounds are not available yet.\n   * Override if necessary\n   * Use with {@link Textbox#wordSplit}\n   *\n   * @param {CanvasRenderingContext2D} ctx\n   * @param {String} text\n   * @param {number} lineIndex\n   * @param {number} charOffset\n   * @returns {number}\n   */\n  _measureWord(word, lineIndex: number, charOffset = 0): number {\n    let width = 0,\n      prevGrapheme;\n    const skipLeft = true;\n    for (let i = 0, len = word.length; i < len; i++) {\n      const box = this._getGraphemeBox(\n        word[i],\n        lineIndex,\n        i + charOffset,\n        prevGrapheme,\n        skipLeft\n      );\n      width += box.kernedWidth;\n      prevGrapheme = word[i];\n    }\n    return width;\n  }\n\n  /**\n   * Override this method to customize word splitting\n   * Use with {@link Textbox#_measureWord}\n   * @param {string} value\n   * @returns {string[]} array of words\n   */\n  wordSplit(value: string): string[] {\n    return value.split(this._wordJoiners);\n  }\n\n  /**\n   * Wraps a line of text using the width of the Textbox and a context.\n   * @param {Array} line The grapheme array that represent the line\n   * @param {Number} lineIndex\n   * @param {Number} desiredWidth width you want to wrap the line to\n   * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n   * @returns {Array} Array of line(s) into which the given text is wrapped\n   * to.\n   */\n  /** This is the method of char split */\n  graphemeSplitForRectNotes(textstring: string): string[] {\n    const graphemes = [];\n    const words = textstring.split(/\\b/);\n    for (let i = 0; i < words.length; i++) {\n      // 检查单词是否全为拉丁字母，长度不大于16\n      if (/^[a-zA-Z]{1,16}$/.test(words[i])) {\n        graphemes.push(words[i]);\n      } else {\n        for (let j = 0; j < words[i].length; j++) {\n          graphemes.push(words[i][j]);\n        }\n      }\n    }\n    return graphemes;\n  }\n\n  _wrapLine(\n    _line,\n    lineIndex: number,\n    desiredWidth: number,\n    reservedSpace = 0\n  ): Array<any> {\n    const additionalSpace = this._getWidthOfCharSpacing(),\n      splitByGrapheme = this.splitByGrapheme,\n      graphemeLines = [],\n      words = splitByGrapheme\n        ? this.graphemeSplitForRectNotes(_line)\n        : this.wordSplit(_line),\n      infix = splitByGrapheme ? '' : ' ';\n\n    let lineWidth = 0,\n      line = [],\n      // spaces in different languages?\n      offset = 0,\n      infixWidth = 0,\n      largestWordWidth = 0,\n      lineJustStarted = true;\n    // fix a difference between split and graphemeSplit\n    if (words.length === 0) {\n      words.push([]);\n    }\n    desiredWidth -= reservedSpace;\n    // measure words\n    const data = words.map((word) => {\n      // if using splitByGrapheme words are already in graphemes.\n      word = splitByGrapheme ? word : this.graphemeSplitForRectNotes(word);\n      const width = this._measureWord(word, lineIndex, offset);\n      largestWordWidth = Math.max(width, largestWordWidth);\n      offset += word.length + 1;\n      return { word: word, width: width };\n    });\n    const maxWidth = Math.max(\n      desiredWidth,\n      largestWordWidth,\n      this.dynamicMinWidth\n    );\n    // layout words\n    offset = 0;\n    let i;\n    for (i = 0; i < words.length; i++) {\n      const word = data[i].word;\n      const wordWidth = data[i].width;\n      offset += word.length;\n\n      lineWidth += infixWidth + wordWidth - additionalSpace;\n      if (lineWidth > maxWidth && !lineJustStarted) {\n        graphemeLines.push(line);\n        line = [];\n        lineWidth = wordWidth;\n        lineJustStarted = true;\n      } else {\n        lineWidth += additionalSpace;\n      }\n\n      if (!lineJustStarted && !splitByGrapheme) {\n        line.push(infix);\n      }\n      if (word.length > 1) {\n        line = line.concat(word.split(''));\n      } else {\n        line = line.concat(word);\n      }\n\n      infixWidth = splitByGrapheme\n        ? 0\n        : this._measureWord([infix], lineIndex, offset);\n      offset++;\n      lineJustStarted = false;\n    }\n\n    i && graphemeLines.push(line);\n\n    if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n      this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n    }\n    return graphemeLines;\n  }\n\n  /**\n   * Detect if the text line is ended with an hard break\n   * text and itext do not have wrapping, return false\n   * @param {Number} lineIndex text to split\n   * @return {Boolean}\n   */\n  isEndOfWrapping(lineIndex: number): boolean {\n    if (!this._styleMap[lineIndex + 1]) {\n      // is last line, return true;\n      return true;\n    }\n    if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n      // this is last line before a line break, return true;\n      return true;\n    }\n    return false;\n  }\n\n  /**\n   * Detect if a line has a linebreak and so we need to account for it when moving\n   * and counting style.\n   * @return Number\n   */\n  missingNewlineOffset(lineIndex) {\n    if (this.splitByGrapheme) {\n      return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n    }\n    return 1;\n  }\n\n  /**\n   * Gets lines of text to render in the Textbox. This function calculates\n   * text wrapping on the fly every time it is called.\n   * @param {String} text text to split\n   * @returns {Array} Array of lines in the Textbox.\n   * @override\n   */\n  textSplitTextIntoLines(text: string) {\n    const lines = text.split(this._reNewline),\n      newLines = new Array<string[]>(lines.length),\n      newLine = ['\\n'];\n    let newText: string[] = [];\n    for (let i = 0; i < lines.length; i++) {\n      newLines[i] = this.graphemeSplit(lines[i]);\n      newText = newText.concat(newLines[i], newLine);\n    }\n    newText.pop();\n    return {\n      _unwrappedLines: newLines,\n      lines: lines,\n      graphemeText: newText,\n      graphemeLines: newLines,\n    };\n  }\n  _splitTextIntoLines(text) {\n    const width = this.width - this.getLeftOffset();\n\n    const newText = this.textSplitTextIntoLines(text),\n      graphemeLines = this._wrapText(newText.lines, width),\n      lines = new Array(graphemeLines.length);\n    for (let i = 0; i < graphemeLines.length; i++) {\n      lines[i] = graphemeLines[i].join('');\n    }\n    newText.lines = lines;\n    newText.graphemeLines = graphemeLines;\n    return newText;\n  }\n\n  getMinWidth() {\n    return Math.max(this.minWidth, this.dynamicMinWidth);\n  }\n\n  _removeExtraneousStyles() {\n    const linesToKeep = {};\n    for (const prop in this._styleMap) {\n      if (this._textLines[prop]) {\n        linesToKeep[this._styleMap[prop].line] = 1;\n      }\n    }\n    for (const prop in this.styles) {\n      if (!linesToKeep[prop]) {\n        delete this.styles[prop];\n      }\n    }\n  }\n\n  getObject() {\n    const object = {};\n    const keys = [\n      '_id',\n      'angle',\n      'backgroundColor',\n      'fill',\n      'fontFamily',\n      'fontSize',\n      'height',\n      'width',\n      'left',\n      'lines', // the arrows array [{…}]\n      'lockUniScaling',\n      'locked',\n      'lockMovementX', // boolean, lock the verticle movement\n      'lockMovementY', // boolean, lock the horizontal movement\n      'lockScalingFlip', // boolean,  make it can not be inverted by pulling the width to the negative side\n      'fontWeight',\n      'lineHeight',\n      'obj_type',\n      'originX',\n      'originY',\n      'panelObj', // the parent panel string\n      'relationship', // relationship with panel for transform  [1.43, 0, 0, 1.43, 7.031931057304291, 16.531768328466796]\n      'scaleX',\n      'scaleY',\n      'selectable',\n      'text',\n      'textAlign',\n      'top',\n      'userNo',\n      'userId',\n      'whiteboardId',\n      'zIndex',\n      'version',\n      'isPanel',\n      'editable',\n      'path',\n      'strokeWidth',\n      'strokeUniform', // set up to true then strokewidth doesn't change when scaling\n      'stroke', // border color\n      'selectable', // boolean, When set to `false`, an object can not be selected for modification (using either point-click-based or group-based selection). But events still fire on it.\n      'icon',\n      'lineWidth',\n      'fixedLineWidth',\n      'aCoords',\n      'shapeScaleX',\n      'shapeScaleY',\n      'verticalAlign',\n      'maxHeight',\n      'shadow',\n      'subObjs',\n    ];\n    keys.forEach((key) => {\n      object[key] = this[key];\n    });\n    return object;\n  }\n\n  /**\n   * Returns object representation of an instance\n   * @method toObject\n   * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n   * @return {Object} object representation of an instance\n   */\n  toObject(propertiesToInclude: Array<any>): object {\n    return super.toObject(\n      [...this.extendPropeties, 'minWidth', 'splitByGrapheme'].concat(\n        propertiesToInclude\n      )\n    );\n  }\n  /**boardx custom function */\n  getObjectsIntersected() {\n    const objects = this.canvas._getIntersectedObjects(this);\n    objects.filter((obj) => {\n      return obj._id !== this._id && obj.obj_type !== 'WBArrow';\n    });\n    return objects;\n  }\n\n  setLockedShadow(locked) {\n    if (locked) {\n      this.shadow = new fabric.Shadow({\n        blur: 2,\n        offsetX: 0,\n        offsetY: 0,\n        color: 'rgba(0, 0, 0, 0.5)',\n      });\n    } else {\n      this.shadow = new fabric.Shadow({\n        blur: 8,\n        offsetX: 0,\n        offsetY: 4,\n        color: 'rgba(0,0,0,0.04)',\n      });\n    }\n  }\n\n  /* caculate cusor positon in the middle of the textbox */\n  getCenteredTop(rectHeight) {\n    const textHeight = this.height;\n    return (rectHeight - textHeight) / 2;\n  }\n\n  _renderBackground(ctx) {\n    if (!this.backgroundColor) {\n      return;\n    }\n    const dim = this._getNonTransformedDimensions();\n    ctx.fillStyle = this.backgroundColor;\n\n    //ctx.shadowBlur = 20;\n    // ctx.shadowOffsetX = 2 * this.scaleX * canvas.getZoom();\n    // ctx.shadowOffsetY = 6 * this.scaleY * canvas.getZoom();\n    //ctx.shadowColor = 'rgba(0,0,0,0.1)';\n    // ctx.shadowColor = 'rgba(0,0,0,1)';\n\n    //ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n\n    // if there is background color no other shadows\n    // should be casted\n    //this._removeShadow(ctx);\n    /*\n      0: rect\n      1: diamond\n      2: rounded rect\n      3: circle\n      4: hexagon\n      5: triangle\n      6: parallelogramIcon\n      7: star\n      8: cross\n      9: leftside right triangle\n      10: rightside right triangle\n      11: topside semicirle circle\n      12: top-left quarter circle\n      13: Constallation Rect\n      14: Constellation Round\n    */\n\n    const shapeArray = [\n      'M-69,-69L69,-69 69,69 -69,69z',\n      'm-69,0 l69,-69 69,69 -69,69 -69,-69z',\n      'm51.14083,-70l-101.28163,0c-10.96794,0 -19.8592,8.76514 -19.8592,19.5775l0,99.84501c0,10.81235 8.89125,19.5775 19.8592,19.5775l101.28163,0c10.96792,0 19.8592,-8.76516 19.8592,-19.5775l0,-99.84501c0,-10.81237 -8.89127,-19.5775 -19.8592,-19.5775z',\n      'M-69,0a69,69 0 1,0 138,0a69,69 0 1,0 -138,0',\n      'm-60,-35.1325l60.3923,-34.8675l60.3923,34.8675l0,69.73493l-60.3923,34.86799l-60.3923,-34.86799l0,-69.73493z',\n      'm-71,70.74999l70.5,-139.74999l70.5,139.74999l-140.99999,0z',\n      'm-70.21501,70.82836l28,-140.00001l112,0l-28,140.00001l-112,0z',\n      'm-69,-16.38404l52.71168,0l16.28832,-52.61596l16.28833,52.61596l52.71167,0l-42.64457,32.51808l16.28916,52.61596l-42.64459,-32.51897l-42.64458,32.51897l16.28916,-52.61596l-42.64458,-32.51808z',\n      'm-70,-23.40091l46.59909,0l0,-46.59909l47.80182,0l0,46.59909l46.59909,0l0,47.80182l-46.59909,0l0,46.59909l-47.80182,0l0,-46.59909l-46.59909,0l0,-47.80182z',\n      'm69,69l-138,0l0,-138l138,138z',\n      'm-69,70l139,0l0,-139l-139,139z',\n      'm70.87066,36.0449l-140.87066,-0.00205c5.11499,-39.91161 35.12907,-69.54285 70.43538,-69.54285c35.30263,0 65.31841,29.63308 70.43528,69.5449z',\n      'm-69,68.5488c9.55735,-78.68015 68.34233,-137.52537 137.9372,-138.04693l0,90.66818l0,47.38267l-137.9372,-0.00392z',\n      'm30.81958,0.12008l37.68039,34.8592l0,35.52068l-139.99994,0l0,-141.99993l139.99994,0l0,34.81153l-37.68601,36.28619l-0.27367,0.26402l0.2793,0.25831l-0.00001,0z',\n      'm29.19742,0.94831c0.00348,0.00417 0.00696,0.00835 0.01948,0.00209c0.01113,0.01879 0.02435,0.03757 0.03896,0.05566l0,0l0.00139,0.0007l0.00765,0.00557l0.06123,0.04731l0.48914,0.37851l3.91657,3.02875l31.11617,24.06231c-10.70812,24.39489 -35.07657,41.43186 -63.42351,41.43186c-38.23501,0 -69.23061,-30.9958 -69.23061,-69.23053c0,-38.23494 30.9956,-69.23053 69.23061,-69.23053c28.07281,0 52.24365,16.70877 63.10832,40.72522c-17.77729,13.90775 -26.59983,20.96711 -30.9784,24.5504c-2.19729,1.79825 -3.27854,2.72365 -3.8122,3.20102c-0.26509,0.23754 -0.40077,0.36953 -0.47244,0.44593c-0.0334,0.03597 -0.06401,0.07132 -0.08767,0.1068c-0.00974,0.01524 -0.0334,0.05267 -0.04801,0.10465c-0.00765,0.02721 -0.01739,0.07466 -0.01113,0.13338c0.00348,0.03131 0.01113,0.0661 0.02714,0.10228c0.00417,0.01044 0.00905,0.02018 0.01461,0.02992c0.00417,0.00765 0.00905,0.016 0.01461,0.02366c0.00557,0.00835 0.01531,0.02087 0.01809,0.02505z',\n    ];\n\n    ctx.save();\n\n    const svgPath = new Path2D(shapeArray[this.icon]);\n    const m = getFabricDocument()\n      .createElementNS('http://www.w3.org/2000/svg', 'svg')\n      .createSVGMatrix();\n    m.a = this.width / 138;\n    m.b = 0;\n    m.c = 0;\n    m.d = this.height / 138;\n    m.e = 0;\n    m.f = 0;\n    const path = new Path2D();\n    path.addPath(svgPath, m);\n    // ctx.lineWidth = this.lineWidth / (this.width / 138 + this.height / 138) / 2;\n    ctx.lineWidth = this.lineWidth;\n    ctx.strokeStyle = this.stroke;\n    ctx.stroke(path);\n    ctx.fillStyle = this.backgroundColor;\n    ctx.fill(path);\n    ctx.restore();\n  }\n  getTopOffset() {\n    let tOffset = 0;\n    switch (this.icon) {\n      case 0:\n      case 2:\n        tOffset = 40;\n        break;\n      case 1:\n      case 3:\n      case 5:\n        tOffset = this.height / 2;\n        break;\n      case 4:\n        tOffset = this.height / 3;\n        break;\n      default:\n    }\n    return tOffset;\n  }\n  getLeftOffset() {\n    let lOffset = 0;\n    switch (this.icon) {\n      case 0:\n      case 2:\n      case 4:\n        lOffset = 40;\n        break;\n      case 1:\n      case 3:\n      case 5:\n        lOffset = this.width / 2;\n        break;\n      default:\n    }\n    return lOffset;\n  }\n  _getTopOffset() {\n    switch (this.verticalAlign) {\n      case 'middle':\n        return -this._getTotalLineHeight() / 2;\n      case 'bottom':\n        return this.height / 2 - this._getTotalLineHeight();\n      default:\n        return -this.height / 2;\n    }\n  }\n  _getTotalLineHeight() {\n    return this._textLines.reduce(\n      (total, _line, index) => total + this.getHeightOfLine(index),\n      0\n    );\n  }\n\n  _renderText(ctx) {\n    ctx.shadowOffsetX = ctx.shadowOffsetY = ctx.shadowBlur = 0;\n    ctx.shadowColor = '';\n\n    if (this.paintFirst === 'stroke') {\n      this._renderTextStroke(ctx);\n      this._renderTextFill(ctx);\n    } else {\n      this._renderTextFill(ctx);\n      this._renderTextStroke(ctx);\n    }\n  }\n  calcTextHeight() {\n    let lineHeight;\n    let height = 0;\n    for (let i = 0, len = this._textLines.length; i < len; i++) {\n      lineHeight = this.getHeightOfLine(i);\n      height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n    }\n\n    const desiredHeight = this.height * (100 / 138);\n\n    if (height > desiredHeight) {\n      this.set('fontSize', this.fontSize - 2);\n      //@ts-ignore\n      this._splitTextIntoLines(this.text);\n      height = this.maxHeight;\n      return Math.max(height, this.height);\n    }\n    if (\n      height < this.maxHeight &&\n      this.maxHeight - height > 60 &&\n      this.fontSize < 24\n    ) {\n      this.fontSize += 2;\n      //@ts-ignore\n      this._splitTextIntoLines(this.text.trim());\n\n      return Math.max(height, this.height);\n    }\n\n    this.height = this.maxHeight;\n  }\n  _renderTextCommon(ctx, method) {\n    ctx.save();\n    let lineHeights = 0;\n    const left = this._getLeftOffset();\n    const top = this._getTopOffset();\n    const offsets = this._applyPatternGradientTransform(\n      ctx,\n      method === 'fillText' ? this.fill : this.stroke\n    );\n\n    for (let i = 0, len = this._textLines.length; i < len; i++) {\n      const heightOfLine = this.getHeightOfLine(i);\n      const maxHeight = heightOfLine / this.lineHeight;\n      const leftOffset = this._getLineLeftOffset(i);\n      this._renderTextLine(\n        method,\n        ctx,\n        this._textLines[i],\n        left + leftOffset - offsets.offsetX,\n        top + lineHeights + maxHeight - offsets.offsetY,\n        i\n      );\n      lineHeights += heightOfLine;\n    }\n    ctx.restore();\n  }\n  renderEmoji(ctx) {\n    if (this.emoji === undefined) {\n      return;\n    }\n\n    let width = 0;\n    const imageList = [\n      this.canvas.emoji_thumb,\n      this.canvas.emoji_love,\n      this.canvas.emoji_smile,\n      this.canvas.emoji_shock,\n      this.canvas.emoji_question,\n    ];\n    const imageListArray = [];\n    const emojiList = [];\n    for (let i = 0; i < 5; i++) {\n      if (this.emoji[i] !== 0) {\n        imageListArray.push(imageList[i]);\n        emojiList.push(this.emoji[i]);\n        width += 26.6;\n      }\n    }\n\n    if (emojiList.length === 0) return;\n\n    const x = this.width / 2 - width;\n    const y = this.height / 2 - 18;\n    ctx.font = '10px Inter ';\n    ctx.lineJoin = 'round';\n    ctx.save();\n    ctx.translate(x - 10, y);\n    this.drawRoundRectPath(ctx, width, 15, 2);\n    ctx.fillStyle = 'rgba(255, 255, 255, 1)';\n    ctx.fill();\n    ctx.restore();\n\n    //ctx.strokeRect(x - 10, y, width, 16);\n    //ctx.fillRect(x - 10 + 10 / 2, y + 10 / 2, width - 10, 16 - 10);\n    ctx.fillStyle = '#000';\n    const isEmojiThumbExist = !(this.canvas.emoji_thumb === undefined);\n    if (isEmojiThumbExist) {\n      let modifier = 0;\n      for (let i = 0; i < imageListArray.length; i++) {\n        const imageX = this.width / 2 - 33.6 + modifier + 2;\n        const imageY = this.height / 2 - 15;\n        const imageW = 10;\n        const imageH = 10;\n        ctx.drawImage(imageListArray[i], imageX, imageY, imageW, imageH);\n        ctx.fillText(\n          emojiList[i].toString(),\n          this.width / 2 - 20.6 + modifier + 1,\n          y + 12\n        );\n        modifier -= 23.6;\n      }\n    }\n  }\n\n  _getTotalLineHeights() {\n    return this._textLines.reduce(\n      (total, _line, index) => total + this.getHeightOfLine(index),\n      0\n    );\n  }\n\n  _getSVGLeftTopOffsets() {\n    return {\n      textLeft: -this.width / 2,\n      textTop: this._getTopOffset(),\n      lineTop: this.getHeightOfLine(0),\n    };\n  }\n  getWidgetMenuList() {\n    if (this.locked) {\n      return ['objectLock'];\n    }\n    return [\n      'more',\n      'fontSize',\n      'textAlign',\n      'changeFont',\n      'backgroundColor',\n      'fontColor',\n      'borderLineIcon',\n      'fontWeight',\n      'objectLock',\n      'shapeBorderColor',\n      'lineWidth',\n      'borderLineIcon',\n      'delete',\n      'aiassist',\n    ];\n  }\n  getWidgetMenuLength() {\n    if (this.locked) return 50;\n    return 420;\n  }\n  getContextMenuList() {\n    let menuList;\n    if (this.locked) {\n      menuList = [\n        'Export board',\n        'Exporting selected area',\n        'Create Share Back',\n        'Bring forward',\n        'Bring to front',\n        'Send backward',\n        'Send to back',\n        'Copy as image',\n        'Copy As Text',\n      ];\n    } else {\n      menuList = [\n        'Export board',\n        'Exporting selected area',\n        'Create Share Back',\n        'Bring forward',\n        'Bring to front',\n        'Send backward',\n        'Send to back',\n        'Duplicate',\n        'Copy',\n        'Copy as image',\n        'Copy As Text',\n        'Paste',\n        'Cut',\n        'Edit',\n        'Delete',\n      ];\n    }\n    menuList.push('Select All');\n    if (this.locked) {\n      menuList.push('Unlock');\n    } else {\n      menuList.push('Lock');\n    }\n    // const notLockedPanel = this.isPanel && !this.locked;\n    // if (notLockedPanel) {\n    //   menuList.push('Switch to non-panel');\n    // } else {\n    //   menuList.push('Switch to panel');\n    // }\n    return menuList;\n  }\n}\n\nclassRegistry.setClass(ShapeNotes);\n"],"names":["shapeNotesDefaultValues","minWidth","dynamicMinWidth","lockScalingFlip","noScaleCache","_wordJoiners","splitByGrapheme","obj_type","height","maxHeight","textAlign","uniformScaling","centeredScaling","verticalAlign","cornerStrokeColor","cornerStyle","cornerColor","transparentCorners","ShapeNotes","Textbox","constructor","super","arguments","_defineProperty","this","getDefaults","_objectSpread","controls","createRectNotesDefaultControls","ownDefaults","initDimensions","__skipDimension","clearContextTop","_clearCache","newLines","_splitText","isEditing","initDelayedCursor","preHeight","total","_getTotalLineHeights","getTopOffset","Math","max","yOffset","top","_textLines","length","lineHeights","tmp","i","len","getHeightOfLine","push","preLines","lastIndex","lastLine","pop","_styleMap","_generateStyleMap","width","_set","indexOf","enlargeSpaces","textInfo","realLineCount","realLineCharCount","charCount","map","graphemeLines","graphemeText","_reSpaceAndTab","test","line","offset","styleHas","property","lineIndex","isWrapping","isEmptyStyles","styles","nextOffset","nextLineIndex","shouldLimit","mapNextLine","obj","p1","p2","p3","_getStyleDeclaration","charIndex","_setStyleDeclaration","style","_deleteStyleDeclaration","_getLineStyle","_setLineStyle","_wrapText","lines","desiredWidth","wrapped","_wrapLine","_measureWord","word","prevGrapheme","charOffset","undefined","_getGraphemeBox","kernedWidth","wordSplit","value","split","graphemeSplitForRectNotes","textstring","graphemes","words","j","_line","reservedSpace","additionalSpace","_getWidthOfCharSpacing","infix","lineWidth","infixWidth","largestWordWidth","lineJustStarted","data","maxWidth","wordWidth","concat","isEndOfWrapping","missingNewlineOffset","textSplitTextIntoLines","text","_reNewline","Array","newLine","newText","graphemeSplit","_unwrappedLines","_splitTextIntoLines","getLeftOffset","join","getMinWidth","_removeExtraneousStyles","linesToKeep","prop","getObject","object","forEach","key","toObject","propertiesToInclude","extendPropeties","getObjectsIntersected","objects","canvas","_getIntersectedObjects","filter","_id","setLockedShadow","locked","shadow","fabric","Shadow","blur","offsetX","offsetY","color","getCenteredTop","rectHeight","_renderBackground","ctx","backgroundColor","_getNonTransformedDimensions","fillStyle","save","svgPath","Path2D","icon","m","getFabricDocument","createElementNS","createSVGMatrix","a","b","c","d","e","f","path","addPath","strokeStyle","stroke","fill","restore","tOffset","lOffset","_getTopOffset","_getTotalLineHeight","reduce","index","_renderText","shadowOffsetX","shadowOffsetY","shadowBlur","shadowColor","paintFirst","_renderTextStroke","_renderTextFill","calcTextHeight","lineHeight","set","fontSize","trim","_renderTextCommon","method","left","_getLeftOffset","offsets","_applyPatternGradientTransform","heightOfLine","leftOffset","_getLineLeftOffset","_renderTextLine","renderEmoji","emoji","imageList","emoji_thumb","emoji_love","emoji_smile","emoji_shock","emoji_question","imageListArray","emojiList","x","y","font","lineJoin","translate","drawRoundRectPath","modifier","imageX","imageY","imageW","imageH","drawImage","fillText","toString","_getSVGLeftTopOffsets","textLeft","textTop","lineTop","getWidgetMenuList","getWidgetMenuLength","getContextMenuList","menuList","textLayoutProperties","classRegistry","setClass"],"mappings":"uVASO,MAAMA,EAAiE,CAC5EC,SAAU,GACVC,gBAAiB,EACjBC,iBAAiB,EACjBC,cAAc,EACdC,aAAc,UACdC,iBAAiB,EACjBC,SAAU,eACVC,OAAQ,IACRC,UAAW,IACXC,UAAW,SACXC,gBAAgB,EAChBC,iBAAiB,EACjBC,cAAe,SACfC,kBAAmB,OACnBC,YAAa,SACbC,YAAa,QACbC,oBAAoB,GASf,MAAMC,UAAmBC,EAAQC,WAAAA,GAAAC,SAAAC,WAQtCC,EAAAC,KAAA,kBAuByB,CACvB,WACA,eACA,SACA,YACA,SACA,SACA,gBACA,QACA,MACA,SACA,eACA,QACD,CAsBD,kBAAOC,GACL,OAAAC,EAAAA,EAAA,CAAA,EACKL,MAAMI,eAAa,GAAA,CACtBE,SAAUC,KACPV,EAAWW,YAElB,CAQAC,cAAAA,GACE,GAAIN,KAAKO,gBACP,OAGFP,KAAKQ,kBACLR,KAAKS,cAEL,MAAMC,EAAWV,KAAKW,aAEtB,GAAIX,KAAKY,UAAW,CAClBZ,K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