{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAmBM,SAAS,0CACd,2CAA2C;AAC3C,MAAkB,EAClB,MAAW,EACX,GAAsC;IAEtC,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEzC,CAAA,GAAA,kCAAO,EAAE,CAAA,GAAA,mBAAK,EAAE,OAAO,aAAa,cAAc,WAAW,OAAO,mBAAmB;QACrF,IAAI,YAAY,OAAO,YAAY;QACnC,IAAI,CAAC,aAAa,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,QAAQ,UAAU,UAAU,KAAK,IAAI,OAAO,UAAU,UAAU,CAAC;QACrE,IAAI,CAAC,OAAO,aAAa,OAAO,eAAe,IAAI,OAAO,GACxD,YAAY;aAEZ,YAAY;IAEhB;IAEA,OAAO;QACL,YAAY;YACV,iBAAiB;YACjB,gCAAgC;YAChC,OAAO;gBACL,YAAY;gBACZ,kBAAkB;gBAClB,yBAAyB;YAC3B;YACA,SAAQ,CAAC;gBACP,sDAAsD;gBACtD,IAAI,cAAc,CAAC,CAAA,GAAA,wCAAa,EAAE,EAAE,WAAW,GAC7C;gBAEF,IAAI,YAAY,OAAO,YAAY;gBACnC,IAAI,UAAU,IAAI,OAAO,EAAE;gBAC3B,IAAI,CAAC,aAAa,CAAC,SACjB;gBAEF,IAAI,QAAQ,SAAS,WAAW;gBAChC,MAAM,cAAc,CAAC;gBACrB,MAAM,WAAW,CAAC;gBAClB,UAAU,eAAe;gBACzB,UAAU,QAAQ,CAAC;YACrB;QACF;oBACA;IACF;AACF","sources":["packages/react-aria/src/tokenfield/useToken.ts"],"sourcesContent":["/*\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing\n */\n\nimport {HTMLAttributes, RefObject, useRef, useState} from 'react';\nimport {isVirtualClick} from '../utils/isVirtualEvent';\nimport {useEvent} from '../utils/useEvent';\n\nexport interface TokenProps {}\n\nexport interface TokenAria {\n  /** Props for the token element. */\n  tokenProps: HTMLAttributes<HTMLSpanElement>;\n  /** Whether the token is currently selected. */\n  isSelected: boolean;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a token within a token field.\n * A token field allows users to enter text with inline tokens.\n */\nexport function useToken(\n  // Unused but matches the normal signature.\n  _props: TokenProps,\n  _state: any,\n  ref: RefObject<HTMLSpanElement | null>\n): TokenAria {\n  let [isSelected, setSelected] = useState(false);\n\n  useEvent(useRef(typeof document !== 'undefined' ? document : null), 'selectionchange', () => {\n    let selection = window.getSelection();\n    if (!selection || !ref.current) {\n      return;\n    }\n\n    let range = selection.rangeCount === 0 ? null : selection.getRangeAt(0);\n    if (!range?.collapsed && range?.intersectsNode(ref.current)) {\n      setSelected(true);\n    } else {\n      setSelected(false);\n    }\n  });\n\n  return {\n    tokenProps: {\n      contentEditable: false,\n      suppressContentEditableWarning: true,\n      style: {\n        userSelect: 'all',\n        WebkitUserSelect: 'all',\n        WebkitTapHighlightColor: 'transparent'\n      },\n      onClick(e) {\n        // Select the token when a screen reader clicks on it.\n        if (isSelected || !isVirtualClick(e.nativeEvent)) {\n          return;\n        }\n        let selection = window.getSelection();\n        let wrapper = ref.current?.parentElement;\n        if (!selection || !wrapper) {\n          return;\n        }\n        let range = document.createRange();\n        range.setStartBefore(wrapper);\n        range.setEndAfter(wrapper);\n        selection.removeAllRanges();\n        selection.addRange(range);\n      }\n    },\n    isSelected\n  };\n}\n"],"names":[],"version":3,"file":"useToken.cjs.map"}