<commit_before>import { CompareService } from 'app/compare/compare.service';
import { settingsSelector } from 'app/dim-api/selectors';
import { loadoutDialogOpen } from 'app/loadout/LoadoutDrawer';
import { showMobileInspect } from 'app/mobile-inspect/mobile-inspect';
import { Inspect } from 'app/mobile-inspect/MobileInspect';
import clsx from 'clsx';
import React, { useRef, useState } from 'react';
import { ConnectDragSource, DragSource, DragSourceConnector, DragSourceSpec } from 'react-dnd';
import { BehaviorSubject } from 'rxjs';
import store from '../store/store';
import { stackableDrag } from './actions';
import { showDragGhost } from './drag-ghost-item';
import { DimItem } from './item-types';

interface ExternalProps {
  item: DimItem;
  inspect?: Inspect;
  isPhonePortrait?: boolean;
  children?: React.ReactNode;
}

interface InternalProps {
  connectDragSource: ConnectDragSource;
}

type Props = InternalProps & ExternalProps;

export const mobileDragType = 'mobile-drag';

function dragType(props: ExternalProps): string {
  const item = props.item;
  if ($featureFlags.mobileInspect && props.isPhonePortrait) {
    return mobileDragType;
  }
  return item.notransfer ? `${item.owner}-${item.bucket.type}` : item.bucket.type!;
}

export interface DragObject {
  item: DimItem;
}

export const isDragging$ = new BehaviorSubject(false);
export let isDragging = false;

const LONGPRESS_TIMEOUT = 200;

let dragTimeout: number | null = null;

const dragSpec: DragSourceSpec<Props, DragObject> = {
  beginDrag(props) {
    if (props.item.maxStackSize > 1 && props.item.amount > 1 && !props.item.uniqueStack) {
      store.dispatch(stackableDrag(true));
    }

    dragTimeout = requestAnimationFrame(() => {
      dragTimeout = null;
      // The colorblind filters interact badly with this
      const color = settingsSelector(store.getState()).colorA11y;
      if (!color || color === '-') {
        document.body.classList.add('drag-perf-show');
      }
    });

    isDragging = true;
    isDragging$.next(true);
    return { item: props.item };
  },

  endDrag(props) {<commit_msg>Close item popup on drag<commit_after>import { CompareService } from 'app/compare/compare.service';
import { settingsSelector } from 'app/dim-api/selectors';
import { hideItemPopup } from 'app/item-popup/item-popup';
import { loadoutDialogOpen } from 'app/loadout/LoadoutDrawer';
import { showMobileInspect } from 'app/mobile-inspect/mobile-inspect';
import { Inspect } from 'app/mobile-inspect/MobileInspect';
import clsx from 'clsx';
import React, { useRef, useState } from 'react';
import { ConnectDragSource, DragSource, DragSourceConnector, DragSourceSpec } from 'react-dnd';
import { BehaviorSubject } from 'rxjs';
import store from '../store/store';
import { stackableDrag } from './actions';
import { showDragGhost } from './drag-ghost-item';
import { DimItem } from './item-types';

interface ExternalProps {
  item: DimItem;
  inspect?: Inspect;
  isPhonePortrait?: boolean;
  children?: React.ReactNode;
}

interface InternalProps {
  connectDragSource: ConnectDragSource;
}

type Props = InternalProps & ExternalProps;

export const mobileDragType = 'mobile-drag';

function dragType(props: ExternalProps): string {
  const item = props.item;
  if ($featureFlags.mobileInspect && props.isPhonePortrait) {
    return mobileDragType;
  }
  return item.notransfer ? `${item.owner}-${item.bucket.type}` : item.bucket.type!;
}

export interface DragObject {
  item: DimItem;
}

export const isDragging$ = new BehaviorSubject(false);
export let isDragging = false;

const LONGPRESS_TIMEOUT = 200;

let dragTimeout: number | null = null;

const dragSpec: DragSourceSpec<Props, DragObject> = {
  beginDrag(props) {
    hideItemPopup();

    if (props.item.maxStackSize > 1 && props.item.amount > 1 && !props.item.uniqueStack) {
      store.dispatch(stackableDrag(true));
    }

    dragTimeout = requestAnimationFrame(() => {
      dragTimeout = null;
      // The colorblind filters interact badly with this
      const color = settingsSelector(store.getState()).colorA11y;
      if (!color || color === '-') {
        document.body.classList.add('drag-perf-show');
      }
    });

    isDragging = true;
    isDragging$.next(true);
    return { item: props.item };
  },

  endDrag(props) {
{'fraction_non_alphanumeric': 0.12976744186046513, 'fraction_numerical': 0.0032558139534883722, 'mean_word_length': 4.26438188494492, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5704474', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1299, 'n_words': 317}