{"version":3,"file":"TFQ.mjs","sources":["../../../../../../../packages/sdk/plugins/weather/Typhoon/TFQ.ts"],"sourcesContent":["import * as L from 'leaflet'\nimport { LatLngBounds } from 'leaflet'\nimport { arc } from '@map-sdk/sdk/plugins/weather/Typhoon/Arc'\nimport type { LatLng } from 'leaflet'\nimport type { MyMap } from '@map-sdk/sdk/ShipxyAPISDK'\nimport type { ArcInfo } from '@map-sdk/sdk/plugins/weather/Typhoon/TyphoonService'\n\ninterface TFQOptions extends L.PathOptions {\n  color?: string\n  fill?: boolean\n  weight?: number\n  opacity?: number\n}\n\nclass TFQ extends L.Path {\n  private _arcs: any[]\n  private bounds: L.LatLngBounds[]\n  private latlng!: L.LatLng\n\n  constructor(\n    latlng: L.LatLngLiteral | L.LatLng[],\n    arcs: any[],\n    options?: Partial<TFQOptions>\n  ) {\n    const option = {\n      color: 'red',\n      fill: true,\n      weight: 1,\n      opacity: 1,\n      ...options,\n    }\n    super(option)\n    L.Util.setOptions(this, option)\n    this._setLatLngs(latlng as any)\n    this.bounds = []\n    this._update()\n    this._arcs = arcs\n  }\n\n  getLatLngs(): L.LatLng[] {\n    return [this.latlng]\n  }\n\n  private _setLatLngs(_latlng: LatLng): void {\n    const _ = this as any\n    _._bounds = new LatLngBounds([])\n    this.latlng = L.latLng(_latlng)\n    _._bounds.extend(this.latlng)\n  }\n\n  override setStyle(styleObject: Partial<TFQOptions>): this {\n    return super.setStyle(styleObject)\n  }\n\n  protected _project(): void {\n    const _ = this as any\n    _._point = this._map.latLngToLayerPoint(this.latlng)\n  }\n\n  private _updateBounds(): void {\n    const { _bounds, bounds } = this as any\n    if (!bounds || bounds.length === 0) {\n      throw new Error('bounds is null')\n    }\n    bounds.forEach((bound: any) => {\n      _bounds.extend(bound)\n    })\n  }\n\n  private _update(): void {\n    if (this._map) {\n      this._updateFenQuan()\n      this._updateBounds()\n    }\n  }\n\n  private _updateFenQuan() {\n    if (!this._arcs || this._arcs.length === 0) {\n      throw new Error('arcs is null')\n    }\n\n    const list: ArcInfo[] = []\n    this._arcs.forEach((item) => {\n      const arcInfo = arc(this.latlng, this._map as MyMap, item)\n      list.push(arcInfo as any)\n      this.bounds.push(arcInfo.bounds)\n    })\n\n    const listz = [] as any\n    list.forEach((item: any, index) => {\n      const nextIndex = (index + 1) % list.length\n      const nextItem = list[nextIndex] as any\n      if (index === 0) {\n        listz.push([...item.path, `L${nextItem.start.x},${nextItem.start.y}`])\n      } else {\n        listz.push(\n          item.path.slice(2).concat(`L${nextItem.start.x},${nextItem.start.y}`)\n        )\n      }\n    })\n\n    const { _renderer } = this as any\n    listz.push('z' as any)\n    _renderer._setPath(this, listz.flat().join(' '))\n    _renderer._updateStyle(this.options as any) // 这里假设_renderer._updateStyle接受PathOptions\n  }\n}\n\n// 类工厂方法\nfunction createTFQ(\n  latlng: L.LatLngLiteral | L.LatLng[],\n  arcs: any[],\n  options?: TFQOptions\n): TFQ {\n  return new TFQ(latlng, arcs, options)\n}\n\n// 导出类和工厂函数\nexport { createTFQ, TFQ }\n"],"names":["h","i","Path","constructor","t","s","n","a","color","fill","weight","opacity","super","Util","setOptions","this","_setLatLngs","bounds","_update","_arcs","getLatLngs","latlng","_bounds","L","latLng","extend","setStyle","_project","_point","_map","latLngToLayerPoint","_updateBounds","length","Error","forEach","_updateFenQuan","e","u","push","l","o","path","start","x","y","slice","concat","_renderer","_setPath","flat","join","_updateStyle","options","c","r","p"],"mappings":"iGAAgI,MAAMA,UAAUC,EAAEC,KAAK,WAAAC,CAAYC,EAAEC,EAAEC,GAAG,MAAMC,EAAE,CAACC,MAAM,MAAMC,MAAK,EAAGC,OAAO,EAAEC,QAAQ,KAAKL,GAAGM,MAAML,GAAGN,EAAEY,KAAKC,WAAWC,KAAKR,GAAGQ,KAAKC,YAAYZ,GAAGW,KAAKE,OAAO,GAAGF,KAAKG,UAAUH,KAAKI,MAAMd,CAAC,CAAC,UAAAe,GAAa,MAAM,CAACL,KAAKM,OAAO,CAAC,WAAAL,CAAYZ,GAAWW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