react-grab 0.0.54 → 0.0.55

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.
@@ -550,12 +550,21 @@ function delegateEvents(eventNames, document2 = window.document) {
550
550
  }
551
551
  }
552
552
  function setAttribute(node, name, value) {
553
- node.removeAttribute(name);
553
+ if (value == null) node.removeAttribute(name);
554
+ else node.setAttribute(name, value);
554
555
  }
555
556
  function className(node, value) {
556
557
  if (value == null) node.removeAttribute("class");
557
558
  else node.className = value;
558
559
  }
560
+ function addEventListener(node, name, handler, delegate) {
561
+ {
562
+ if (Array.isArray(handler)) {
563
+ node[`$$${name}`] = handler[0];
564
+ node[`$$${name}Data`] = handler[1];
565
+ } else node[`$$${name}`] = handler;
566
+ }
567
+ }
559
568
  function style(node, value, prev) {
560
569
  if (!value) return prev ? setAttribute(node, "style") : value;
561
570
  const nodeStyle = node.style;
@@ -740,7 +749,7 @@ function cleanChildren(parent, current, marker, replacement) {
740
749
  }
741
750
 
742
751
  // dist/styles.css
743
- var styles_default = '/*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-white:#fff;--spacing:.25rem;--font-weight-medium:500;--font-weight-semibold:600;--leading-tight:1.25;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-grab-pink:#b21c8e;--color-grab-pink-light:#fde7f7;--color-grab-pink-border:#f7c5ec;--color-grab-purple:#d239c0}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.top-0{top:calc(var(--spacing)*0)}.bottom-0{bottom:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.z-2147483645{z-index:2147483645}.z-2147483646{z-index:2147483646}.z-\\[2147483645\\]{z-index:2147483645}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mr-1{margin-right:calc(var(--spacing)*1)}.ml-1{margin-left:calc(var(--spacing)*1)}.box-border{box-sizing:border-box}.block{display:block}.flex{display:flex}.hidden{display:none}.inline-block{display:inline-block}.h-2{height:calc(var(--spacing)*2)}.min-h-\\[18px\\]{min-height:18px}.w-2{width:calc(var(--spacing)*2)}.w-\\[150px\\]{width:150px}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.cursor-crosshair{cursor:crosshair}.resize{resize:both}.resize-none{resize:none}.flex-col{flex-direction:column}.items-center{align-items:center}.gap-0\\.5{gap:calc(var(--spacing)*.5)}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-\\[3px\\]{border-radius:3px}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.border-\\[1\\.5px\\]{border-style:var(--tw-border-style);border-width:1.5px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-solid{--tw-border-style:solid;border-style:solid}.border-grab-pink-border{border-color:var(--color-grab-pink-border)}.border-grab-purple{border-color:var(--color-grab-purple)}.border-grab-purple\\/40{border-color:#d239c066}@supports (color:color-mix(in lab, red, red)){.border-grab-purple\\/40{border-color:color-mix(in oklab,var(--color-grab-purple)40%,transparent)}}.border-grab-purple\\/50{border-color:#d239c080}@supports (color:color-mix(in lab, red, red)){.border-grab-purple\\/50{border-color:color-mix(in oklab,var(--color-grab-purple)50%,transparent)}}.border-t-transparent{border-top-color:#0000}.bg-grab-pink-light{background-color:var(--color-grab-pink-light)}.bg-grab-pink\\/20{background-color:#b21c8e33}@supports (color:color-mix(in lab, red, red)){.bg-grab-pink\\/20{background-color:color-mix(in oklab,var(--color-grab-pink)20%,transparent)}}.bg-grab-purple\\/5{background-color:#d239c00d}@supports (color:color-mix(in lab, red, red)){.bg-grab-purple\\/5{background-color:color-mix(in oklab,var(--color-grab-purple)5%,transparent)}}.bg-grab-purple\\/8{background-color:#d239c014}@supports (color:color-mix(in lab, red, red)){.bg-grab-purple\\/8{background-color:color-mix(in oklab,var(--color-grab-purple)8%,transparent)}}.bg-white{background-color:var(--color-white)}.p-0\\.5{padding:calc(var(--spacing)*.5)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\\.5{padding-inline:calc(var(--spacing)*1.5)}.px-\\[3px\\]{padding-inline:3px}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.text-center{text-align:center}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.text-grab-pink{color:var(--color-grab-pink)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.opacity-60{opacity:.6}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition-\\[width\\]{transition-property:width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.will-change-\\[transform\\,width\\,height\\]{will-change:transform,width,height}.outline-none{--tw-outline-style:none;outline-style:none}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}';
752
+ var styles_default = '/*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--font-weight-medium:500;--ease-out:cubic-bezier(0,0,.2,1);--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-grab-pink:#b21c8e;--color-grab-purple:#d239c0;--color-label-tag-border:#730079;--color-label-tag-text:#1e001f;--color-label-gray-border:#b0b0b0;--color-label-success-bg:#d9ffe4;--color-label-success-border:#00bb69;--color-label-success-text:#006e3b;--color-label-divider:#dedede;--color-label-muted:#767676}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.top-0{top:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.z-2147483645{z-index:2147483645}.z-2147483646{z-index:2147483646}.z-2147483647{z-index:2147483647}.z-\\[2147483645\\]{z-index:2147483645}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing)*0)}.mt-\\[2\\.5px\\]{margin-top:2.5px}.-ml-\\[5px\\]{margin-left:-5px}.ml-1{margin-left:calc(var(--spacing)*1)}.box-border{box-sizing:border-box}.flex{display:flex}.hidden{display:none}.h-0{height:calc(var(--spacing)*0)}.h-5{height:calc(var(--spacing)*5)}.h-5\\.5{height:calc(var(--spacing)*5.5)}.h-\\[14px\\]{height:14px}.h-\\[18px\\]{height:18px}.h-fit{height:fit-content}.min-h-\\[14px\\]{min-height:14px}.w-0{width:calc(var(--spacing)*0)}.w-0\\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-\\[18px\\]{width:18px}.w-fit{width:fit-content}.w-full{width:100%}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.-translate-x-1\\/2{--tw-translate-x:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-75{--tw-scale-x:75%;--tw-scale-y:75%;--tw-scale-z:75%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.cursor-crosshair{cursor:crosshair}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-\\[3px\\]{gap:3px}.gap-\\[5px\\]{gap:5px}.rounded-\\[1\\.5px\\]{border-radius:1.5px}.rounded-\\[3px\\]{border-radius:3px}.rounded-full{border-radius:3.40282e38px}.rounded-br-\\[3px\\]{border-bottom-right-radius:3px}.rounded-bl-\\[3px\\]{border-bottom-left-radius:3px}.border{border-style:var(--tw-border-style);border-width:1px}.border-\\[0\\.5px\\]{border-style:var(--tw-border-style);border-width:.5px}.border-t-\\[0\\.5px\\]{border-top-style:var(--tw-border-style);border-top-width:.5px}.border-none{--tw-border-style:none;border-style:none}.border-solid{--tw-border-style:solid;border-style:solid}.border-grab-purple{border-color:var(--color-grab-purple)}.border-grab-purple\\/40{border-color:#d239c066}@supports (color:color-mix(in lab, red, red)){.border-grab-purple\\/40{border-color:color-mix(in oklab,var(--color-grab-purple)40%,transparent)}}.border-grab-purple\\/50{border-color:#d239c080}@supports (color:color-mix(in lab, red, red)){.border-grab-purple\\/50{border-color:color-mix(in oklab,var(--color-grab-purple)50%,transparent)}}.border-label-gray-border{border-color:var(--color-label-gray-border)}.border-label-success-border{border-color:var(--color-label-success-border)}.border-label-tag-border{border-color:var(--color-label-tag-border)}.border-t-label-divider{border-top-color:var(--color-label-divider)}.bg-black{background-color:var(--color-black)}.bg-grab-pink{background-color:var(--color-grab-pink)}.bg-grab-purple\\/5{background-color:#d239c00d}@supports (color:color-mix(in lab, red, red)){.bg-grab-purple\\/5{background-color:color-mix(in oklab,var(--color-grab-purple)5%,transparent)}}.bg-grab-purple\\/8{background-color:#d239c014}@supports (color:color-mix(in lab, red, red)){.bg-grab-purple\\/8{background-color:color-mix(in oklab,var(--color-grab-purple)8%,transparent)}}.bg-label-success-bg{background-color:var(--color-label-success-bg)}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.p-0{padding:calc(var(--spacing)*0)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-\\[5px\\]{padding-inline:5px}.py-\\[5px\\]{padding-block:5px}.py-px{padding-block:1px}.pt-1{padding-top:calc(var(--spacing)*1)}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.leading-3\\.5{--tw-leading:calc(var(--spacing)*3.5);line-height:calc(var(--spacing)*3.5)}.leading-4{--tw-leading:calc(var(--spacing)*4);line-height:calc(var(--spacing)*4)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.tracking-\\[-0\\.04em\\]{--tw-tracking:-.04em;letter-spacing:-.04em}.text-black{color:var(--color-black)}.text-label-muted{color:var(--color-label-muted)}.text-label-success-text{color:var(--color-label-success-text)}.text-label-tag-border{color:var(--color-label-tag-border)}.text-label-tag-text{color:var(--color-label-tag-text)}.text-white{color:var(--color-white)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-100{opacity:1}.opacity-\\[0\\.65\\]{opacity:.65}.brightness-125{--tw-brightness:brightness(125%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[width\\,height\\]{transition-property:width,height;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.will-change-\\[transform\\,width\\,height\\]{will-change:transform,width,height}.outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.hover\\:opacity-80:hover{opacity:.8}.hover\\:opacity-100:hover{opacity:1}}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.react-grab-shimmer{position:relative;overflow:hidden}.react-grab-shimmer:after{content:"";border-radius:inherit;pointer-events:none;background:linear-gradient(90deg,#0000 0%,#fff6 50%,#0000 100%) 0 0/200% 100%;animation:1.5s ease-in-out infinite shimmer;position:absolute;inset:0}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}';
744
753
 
745
754
  // src/utils/is-keyboard-event-triggered-by-input.ts
746
755
  var FORM_TAGS_AND_ROLES = [
@@ -791,6 +800,39 @@ var isKeyboardEventTriggeredByInput = (event) => {
791
800
  return isHotkeyEnabledOnTagName(event, FORM_TAGS_AND_ROLES);
792
801
  };
793
802
 
803
+ // src/utils/is-selection-inside-editable-element.ts
804
+ var isEditableElement = (element) => {
805
+ const tagName = element.tagName.toLowerCase();
806
+ if (tagName === "input" || tagName === "textarea") {
807
+ return true;
808
+ }
809
+ if (element instanceof HTMLElement && element.isContentEditable) {
810
+ return true;
811
+ }
812
+ return false;
813
+ };
814
+ var isSelectionInsideEditableElement = (cursorX, cursorY) => {
815
+ const activeElement = document.activeElement;
816
+ if (activeElement) {
817
+ let current = activeElement;
818
+ while (current) {
819
+ if (isEditableElement(current)) {
820
+ return true;
821
+ }
822
+ current = current.parentElement;
823
+ }
824
+ }
825
+ if (cursorX !== void 0 && cursorY !== void 0) {
826
+ const elementsAtPoint = document.elementsFromPoint(cursorX, cursorY);
827
+ for (const element of elementsAtPoint) {
828
+ if (isEditableElement(element)) {
829
+ return true;
830
+ }
831
+ }
832
+ }
833
+ return false;
834
+ };
835
+
794
836
  // src/utils/mount-root.ts
795
837
  var ATTRIBUTE_NAME = "data-react-grab";
796
838
  var mountRoot = (cssText) => {
@@ -823,18 +865,27 @@ var mountRoot = (cssText) => {
823
865
  return root;
824
866
  };
825
867
 
868
+ // src/utils/build-open-file-url.ts
869
+ var BASE_URL = "https://react-grab.com" ;
870
+ var buildOpenFileUrl = (filePath, lineNumber) => {
871
+ const lineParam = lineNumber ? `&line=${lineNumber}` : "";
872
+ return `${BASE_URL}/open-file?url=${encodeURIComponent(filePath)}${lineParam}`;
873
+ };
874
+
826
875
  // src/constants.ts
827
876
  var VIEWPORT_MARGIN_PX = 8;
828
- var INDICATOR_CLAMP_PADDING_PX = 4;
829
- var CURSOR_OFFSET_PX = 14;
830
877
  var OFFSCREEN_POSITION = -1e3;
831
878
  var SELECTION_LERP_FACTOR = 0.95;
832
879
  var SUCCESS_LABEL_DURATION_MS = 1700;
833
- var PROGRESS_INDICATOR_DELAY_MS = 150;
880
+ var COPIED_LABEL_DURATION_MS = 1500;
881
+ var SELECTION_CURSOR_SETTLE_DELAY_MS = 500;
882
+ var BLUR_DEACTIVATION_THRESHOLD_MS = 500;
834
883
  var DRAG_THRESHOLD_PX = 2;
835
884
  var AUTO_SCROLL_EDGE_THRESHOLD_PX = 25;
836
885
  var AUTO_SCROLL_SPEED_PX = 10;
837
886
  var Z_INDEX_LABEL = 2147483647;
887
+ var MODIFIER_KEYS = ["Meta", "Control", "Shift", "Alt"];
888
+ var LOGO_SVG = `<svg width="294" height="294" viewBox="0 0 294 294" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_0_3)"><mask id="mask0_0_3" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="294" height="294"><path d="M294 0H0V294H294V0Z" fill="white"/></mask><g mask="url(#mask0_0_3)"><path d="M144.599 47.4924C169.712 27.3959 194.548 20.0265 212.132 30.1797C227.847 39.2555 234.881 60.3243 231.926 89.516C231.677 92.0069 231.328 94.5423 230.94 97.1058L228.526 110.14C228.517 110.136 228.505 110.132 228.495 110.127C228.486 110.165 228.479 110.203 228.468 110.24L216.255 105.741C216.256 105.736 216.248 105.728 216.248 105.723C207.915 103.125 199.421 101.075 190.82 99.5888L190.696 99.5588L173.526 97.2648L173.511 97.2631C173.492 97.236 173.467 97.2176 173.447 97.1905C163.862 96.2064 154.233 95.7166 144.599 95.7223C134.943 95.7162 125.295 96.219 115.693 97.2286C110.075 105.033 104.859 113.118 100.063 121.453C95.2426 129.798 90.8624 138.391 86.939 147.193C90.8624 155.996 95.2426 164.588 100.063 172.933C104.866 181.302 110.099 189.417 115.741 197.245C115.749 197.245 115.758 197.246 115.766 197.247L115.752 197.27L115.745 197.283L115.754 197.296L126.501 211.013L126.574 211.089C132.136 217.767 138.126 224.075 144.507 229.974L144.609 230.082L154.572 238.287C154.539 238.319 154.506 238.35 154.472 238.38C154.485 238.392 154.499 238.402 154.513 238.412L143.846 247.482L143.827 247.497C126.56 261.128 109.472 268.745 94.8019 268.745C88.5916 268.837 82.4687 267.272 77.0657 264.208C61.3496 255.132 54.3164 234.062 57.2707 204.871C57.528 202.307 57.8806 199.694 58.2904 197.054C28.3363 185.327 9.52301 167.51 9.52301 147.193C9.52301 129.042 24.2476 112.396 50.9901 100.375C53.3443 99.3163 55.7938 98.3058 58.2904 97.3526C57.8806 94.7023 57.528 92.0803 57.2707 89.516C54.3164 60.3243 61.3496 39.2555 77.0657 30.1797C94.6494 20.0265 119.486 27.3959 144.599 47.4924ZM70.6423 201.315C70.423 202.955 70.2229 204.566 70.0704 206.168C67.6686 229.567 72.5478 246.628 83.3615 252.988L83.5176 253.062C95.0399 259.717 114.015 254.426 134.782 238.38C125.298 229.45 116.594 219.725 108.764 209.314C95.8516 207.742 83.0977 205.066 70.6423 201.315ZM80.3534 163.438C77.34 171.677 74.8666 180.104 72.9484 188.664C81.1787 191.224 89.5657 193.247 98.0572 194.724L98.4618 194.813C95.2115 189.865 92.0191 184.66 88.9311 179.378C85.8433 174.097 83.003 168.768 80.3534 163.438ZM60.759 110.203C59.234 110.839 57.7378 111.475 56.27 112.11C34.7788 121.806 22.3891 134.591 22.3891 147.193C22.3891 160.493 36.4657 174.297 60.7494 184.26C63.7439 171.581 67.8124 159.182 72.9104 147.193C67.822 135.23 63.7566 122.855 60.759 110.203ZM98.4137 99.6404C89.8078 101.145 81.3075 103.206 72.9676 105.809C74.854 114.203 77.2741 122.468 80.2132 130.554L80.3059 130.939C82.9938 125.6 85.8049 120.338 88.8834 115.008C91.9618 109.679 95.1544 104.569 98.4137 99.6404ZM94.9258 38.5215C90.9331 38.4284 86.9866 39.3955 83.4891 41.3243C72.6291 47.6015 67.6975 64.5954 70.0424 87.9446L70.0416 88.2194C70.194 89.8208 70.3941 91.4325 70.6134 93.0624C83.0737 89.3364 95.8263 86.6703 108.736 85.0924C116.57 74.6779 125.28 64.9532 134.773 56.0249C119.877 44.5087 105.895 38.5215 94.9258 38.5215ZM205.737 41.3148C202.268 39.398 198.355 38.4308 194.394 38.5099L194.29 38.512C183.321 38.512 169.34 44.4991 154.444 56.0153C163.93 64.9374 172.634 74.6557 180.462 85.064C193.375 86.6345 206.128 89.3102 218.584 93.0624C218.812 91.4325 219.003 89.8118 219.165 88.2098C221.548 64.7099 216.65 47.6164 205.737 41.3148ZM144.552 64.3097C138.104 70.2614 132.054 76.6306 126.443 83.3765C132.39 82.995 138.426 82.8046 144.552 82.8046C150.727 82.8046 156.778 83.0143 162.707 83.3765C157.08 76.6293 151.015 70.2596 144.552 64.3097Z" fill="white"/><path d="M144.598 47.4924C169.712 27.3959 194.547 20.0265 212.131 30.1797C227.847 39.2555 234.88 60.3243 231.926 89.516C231.677 92.0069 231.327 94.5423 230.941 97.1058L228.526 110.14L228.496 110.127C228.487 110.165 228.478 110.203 228.469 110.24L216.255 105.741L216.249 105.723C207.916 103.125 199.42 101.075 190.82 99.5888L190.696 99.5588L173.525 97.2648L173.511 97.263C173.492 97.236 173.468 97.2176 173.447 97.1905C163.863 96.2064 154.234 95.7166 144.598 95.7223C134.943 95.7162 125.295 96.219 115.693 97.2286C110.075 105.033 104.859 113.118 100.063 121.453C95.2426 129.798 90.8622 138.391 86.939 147.193C90.8622 155.996 95.2426 164.588 100.063 172.933C104.866 181.302 110.099 189.417 115.741 197.245L115.766 197.247L115.752 197.27L115.745 197.283L115.754 197.296L126.501 211.013L126.574 211.089C132.136 217.767 138.126 224.075 144.506 229.974L144.61 230.082L154.572 238.287C154.539 238.319 154.506 238.35 154.473 238.38L154.512 238.412L143.847 247.482L143.827 247.497C126.56 261.13 109.472 268.745 94.8018 268.745C88.5915 268.837 82.4687 267.272 77.0657 264.208C61.3496 255.132 54.3162 234.062 57.2707 204.871C57.528 202.307 57.8806 199.694 58.2904 197.054C28.3362 185.327 9.52298 167.51 9.52298 147.193C9.52298 129.042 24.2476 112.396 50.9901 100.375C53.3443 99.3163 55.7938 98.3058 58.2904 97.3526C57.8806 94.7023 57.528 92.0803 57.2707 89.516C54.3162 60.3243 61.3496 39.2555 77.0657 30.1797C94.6493 20.0265 119.486 27.3959 144.598 47.4924ZM70.6422 201.315C70.423 202.955 70.2229 204.566 70.0704 206.168C67.6686 229.567 72.5478 246.628 83.3615 252.988L83.5175 253.062C95.0399 259.717 114.015 254.426 134.782 238.38C125.298 229.45 116.594 219.725 108.764 209.314C95.8515 207.742 83.0977 205.066 70.6422 201.315ZM80.3534 163.438C77.34 171.677 74.8666 180.104 72.9484 188.664C81.1786 191.224 89.5657 193.247 98.0572 194.724L98.4618 194.813C95.2115 189.865 92.0191 184.66 88.931 179.378C85.8433 174.097 83.003 168.768 80.3534 163.438ZM60.7589 110.203C59.234 110.839 57.7378 111.475 56.2699 112.11C34.7788 121.806 22.3891 134.591 22.3891 147.193C22.3891 160.493 36.4657 174.297 60.7494 184.26C63.7439 171.581 67.8124 159.182 72.9103 147.193C67.822 135.23 63.7566 122.855 60.7589 110.203ZM98.4137 99.6404C89.8078 101.145 81.3075 103.206 72.9676 105.809C74.8539 114.203 77.2741 122.468 80.2132 130.554L80.3059 130.939C82.9938 125.6 85.8049 120.338 88.8834 115.008C91.9618 109.679 95.1544 104.569 98.4137 99.6404ZM94.9258 38.5215C90.9331 38.4284 86.9866 39.3955 83.4891 41.3243C72.629 47.6015 67.6975 64.5954 70.0424 87.9446L70.0415 88.2194C70.194 89.8208 70.3941 91.4325 70.6134 93.0624C83.0737 89.3364 95.8262 86.6703 108.736 85.0924C116.57 74.6779 125.28 64.9532 134.772 56.0249C119.877 44.5087 105.895 38.5215 94.9258 38.5215ZM205.737 41.3148C202.268 39.398 198.355 38.4308 194.394 38.5099L194.291 38.512C183.321 38.512 169.34 44.4991 154.443 56.0153C163.929 64.9374 172.634 74.6557 180.462 85.064C193.374 86.6345 206.129 89.3102 218.584 93.0624C218.813 91.4325 219.003 89.8118 219.166 88.2098C221.548 64.7099 216.65 47.6164 205.737 41.3148ZM144.551 64.3097C138.103 70.2614 132.055 76.6306 126.443 83.3765C132.389 82.995 138.427 82.8046 144.551 82.8046C150.727 82.8046 156.779 83.0143 162.707 83.3765C157.079 76.6293 151.015 70.2596 144.551 64.3097Z" fill="#FF40E0"/></g><mask id="mask1_0_3" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="102" y="84" width="161" height="162"><path d="M235.282 84.827L102.261 112.259L129.693 245.28L262.714 217.848L235.282 84.827Z" fill="white"/></mask><g mask="url(#mask1_0_3)"><path d="M136.863 129.916L213.258 141.224C220.669 142.322 222.495 152.179 215.967 155.856L187.592 171.843L184.135 204.227C183.339 211.678 173.564 213.901 169.624 207.526L129.021 141.831C125.503 136.14 130.245 128.936 136.863 129.916Z" fill="#FF40E0" stroke="#FF40E0" stroke-width="0.817337" stroke-linecap="round" stroke-linejoin="round"/></g></g><defs><clipPath id="clip0_0_3"><rect width="294" height="294" fill="white"/></clipPath></defs></svg>`;
838
889
 
839
890
  // src/utils/lerp.ts
840
891
  var lerp = (start, end, factor) => {
@@ -3322,7 +3373,7 @@ var cn = (...inputs) => {
3322
3373
  };
3323
3374
 
3324
3375
  // src/components/selection-box.tsx
3325
- var _tmpl$ = /* @__PURE__ */ template(`<div>`);
3376
+ var _tmpl$ = /* @__PURE__ */ template(`<div style=overflow:visible>`);
3326
3377
  var SelectionBox = (props) => {
3327
3378
  const [currentX, setCurrentX] = createSignal(props.bounds.x);
3328
3379
  const [currentY, setCurrentY] = createSignal(props.bounds.y);
@@ -3398,7 +3449,7 @@ var SelectionBox = (props) => {
3398
3449
  get children() {
3399
3450
  var _el$ = _tmpl$();
3400
3451
  createRenderEffect((_p$) => {
3401
- var _v$ = cn("fixed box-border", props.variant === "drag" && "pointer-events-none", props.variant !== "drag" && "pointer-events-auto", props.variant === "grabbed" && "z-2147483645", props.variant !== "grabbed" && "z-2147483646", props.variant === "drag" && "border border-dashed border-grab-purple/40 bg-grab-purple/5 will-change-[transform,width,height] cursor-crosshair", props.variant === "selection" && "border border-dashed border-grab-purple/50 bg-grab-purple/8", props.variant === "grabbed" && "border border-solid border-grab-purple bg-grab-purple/8 transition-opacity duration-300 ease-out"), _v$2 = `${currentY()}px`, _v$3 = `${currentX()}px`, _v$4 = `${currentWidth()}px`, _v$5 = `${currentHeight()}px`, _v$6 = props.bounds.borderRadius, _v$7 = props.bounds.transform, _v$8 = opacity(), _v$9 = props.variant === "drag" ? "layout paint size" : void 0;
3452
+ var _v$ = cn("fixed box-border", props.variant === "drag" && "pointer-events-none", props.variant !== "drag" && "pointer-events-auto", props.variant === "grabbed" && "z-2147483645", props.variant !== "grabbed" && "z-2147483646", props.variant === "drag" && "border border-solid border-grab-purple/40 bg-grab-purple/5 will-change-[transform,width,height] cursor-crosshair", props.variant === "selection" && "border border-solid border-grab-purple/50 bg-grab-purple/8 transition-opacity duration-100 ease-out", props.variant === "grabbed" && "border border-solid border-grab-purple bg-grab-purple/8 transition-opacity duration-300 ease-out", props.variant === "processing" && "border border-solid border-grab-purple/50 bg-grab-purple/8"), _v$2 = `${currentY()}px`, _v$3 = `${currentX()}px`, _v$4 = `${currentWidth()}px`, _v$5 = `${currentHeight()}px`, _v$6 = props.bounds.borderRadius, _v$7 = props.bounds.transform, _v$8 = props.isFading ? 0 : opacity(), _v$9 = props.variant === "drag" ? "layout paint size" : void 0;
3402
3453
  _v$ !== _p$.e && className(_el$, _p$.e = _v$);
3403
3454
  _v$2 !== _p$.t && setStyleProperty(_el$, "top", _p$.t = _v$2);
3404
3455
  _v$3 !== _p$.a && setStyleProperty(_el$, "left", _p$.a = _v$3);
@@ -3425,45 +3476,6 @@ var SelectionBox = (props) => {
3425
3476
  });
3426
3477
  };
3427
3478
 
3428
- // src/components/spinner.tsx
3429
- var _tmpl$2 = /* @__PURE__ */ template(`<span class="inline-block w-2 h-2 border-[1.5px] border-grab-dark-pink border-t-transparent rounded-full mr-1 align-middle">`);
3430
- var Spinner = (props) => {
3431
- let spinnerRef;
3432
- onMount(() => {
3433
- if (spinnerRef) {
3434
- spinnerRef.animate([{
3435
- transform: "rotate(0deg)"
3436
- }, {
3437
- transform: "rotate(360deg)"
3438
- }], {
3439
- duration: 600,
3440
- easing: "linear",
3441
- iterations: Infinity
3442
- });
3443
- }
3444
- });
3445
- return (() => {
3446
- var _el$ = _tmpl$2();
3447
- var _ref$ = spinnerRef;
3448
- typeof _ref$ === "function" ? use(_ref$, _el$) : spinnerRef = _el$;
3449
- createRenderEffect((_$p) => style(_el$, props.style, _$p));
3450
- return _el$;
3451
- })();
3452
- };
3453
-
3454
- // src/utils/get-clamped-element-position.ts
3455
- var getClampedElementPosition = (positionLeft, positionTop, elementWidth, elementHeight) => {
3456
- const viewportWidth = window.innerWidth;
3457
- const viewportHeight = window.innerHeight;
3458
- const minLeft = VIEWPORT_MARGIN_PX;
3459
- const minTop = VIEWPORT_MARGIN_PX;
3460
- const maxLeft = viewportWidth - elementWidth - VIEWPORT_MARGIN_PX;
3461
- const maxTop = viewportHeight - elementHeight - VIEWPORT_MARGIN_PX;
3462
- const clampedLeft = Math.max(minLeft, Math.min(positionLeft, maxLeft));
3463
- const clampedTop = Math.max(minTop, Math.min(positionTop, maxTop));
3464
- return { left: clampedLeft, top: clampedTop };
3465
- };
3466
-
3467
3479
  // src/hooks/use-animated-lerp.ts
3468
3480
  var useAnimatedPosition = (options) => {
3469
3481
  const lerpFactor = options.lerpFactor ?? 0.3;
@@ -3510,187 +3522,8 @@ var useAnimatedPosition = (options) => {
3510
3522
  return { x: x3, y: y2 };
3511
3523
  };
3512
3524
 
3513
- // src/hooks/use-fade-in-out.ts
3514
- var useFadeInOut = (options) => {
3515
- const [opacity, setOpacity] = createSignal(0);
3516
- createEffect(
3517
- on(
3518
- () => options.visible,
3519
- (isVisible) => {
3520
- if (isVisible !== false) {
3521
- requestAnimationFrame(() => {
3522
- setOpacity(1);
3523
- });
3524
- } else {
3525
- setOpacity(0);
3526
- return;
3527
- }
3528
- if (options.autoFadeOutAfter !== void 0) {
3529
- const fadeOutTimer = setTimeout(() => {
3530
- setOpacity(0);
3531
- }, options.autoFadeOutAfter);
3532
- onCleanup(() => clearTimeout(fadeOutTimer));
3533
- }
3534
- }
3535
- )
3536
- );
3537
- return opacity;
3538
- };
3539
-
3540
- // src/utils/get-cursor-quadrants.ts
3541
- var getCursorQuadrants = (cursorX, cursorY, elementWidth, elementHeight, offset) => {
3542
- return [
3543
- {
3544
- left: Math.round(cursorX) + offset,
3545
- top: Math.round(cursorY) + offset
3546
- },
3547
- {
3548
- left: Math.round(cursorX) - elementWidth - offset,
3549
- top: Math.round(cursorY) + offset
3550
- },
3551
- {
3552
- left: Math.round(cursorX) + offset,
3553
- top: Math.round(cursorY) - elementHeight - offset
3554
- },
3555
- {
3556
- left: Math.round(cursorX) - elementWidth - offset,
3557
- top: Math.round(cursorY) - elementHeight - offset
3558
- }
3559
- ];
3560
- };
3561
-
3562
- // src/components/label.tsx
3563
- var _tmpl$3 = /* @__PURE__ */ template(`<div class="absolute top-0 left-0 bottom-0 bg-grab-pink/20 rounded-[3px] transition-[width] duration-100 ease-out pointer-events-none">`);
3564
- var _tmpl$22 = /* @__PURE__ */ template(`<span class="inline-block mr-1 font-semibold">\u2713`);
3565
- var _tmpl$32 = /* @__PURE__ */ template(`<div class=mr-1>Copied`);
3566
- var _tmpl$4 = /* @__PURE__ */ template(`<div class=ml-1>to clipboard`);
3567
- var _tmpl$5 = /* @__PURE__ */ template(`<div class="text-[9px] opacity-60 text-center mt-0.5">Click or drag to select`);
3568
- var _tmpl$6 = /* @__PURE__ */ template(`<div class="fixed bg-grab-pink-light text-grab-pink border border-grab-pink-border rounded text-[11px] font-medium font-sans pointer-events-none transition-opacity duration-200 ease-in-out overflow-hidden"style="max-width:calc(100vw - (16px + env(safe-area-inset-left) + env(safe-area-inset-right)))"><div class="relative py-0.5 px-1.5 flex flex-col"><div class="flex items-center text-ellipsis whitespace-nowrap">`);
3569
- var Label = (props) => {
3570
- let labelRef;
3571
- const position = useAnimatedPosition({
3572
- x: () => props.x,
3573
- y: () => props.y,
3574
- lerpFactor: 0.3
3575
- });
3576
- const opacity = useFadeInOut({
3577
- visible: props.visible,
3578
- autoFadeOutAfter: props.variant === "success" ? SUCCESS_LABEL_DURATION_MS : void 0
3579
- });
3580
- const labelBoundingRect = () => labelRef?.getBoundingClientRect();
3581
- const computedPosition = () => {
3582
- const boundingRect = labelBoundingRect();
3583
- if (!boundingRect) return {
3584
- left: position.x(),
3585
- top: position.y()
3586
- };
3587
- const viewportWidth = window.innerWidth;
3588
- const viewportHeight = window.innerHeight;
3589
- const quadrants = getCursorQuadrants(position.x(), position.y(), boundingRect.width, boundingRect.height, CURSOR_OFFSET_PX);
3590
- for (const position2 of quadrants) {
3591
- const fitsHorizontally = position2.left >= VIEWPORT_MARGIN_PX && position2.left + boundingRect.width <= viewportWidth - VIEWPORT_MARGIN_PX;
3592
- const fitsVertically = position2.top >= VIEWPORT_MARGIN_PX && position2.top + boundingRect.height <= viewportHeight - VIEWPORT_MARGIN_PX;
3593
- if (fitsHorizontally && fitsVertically) {
3594
- return position2;
3595
- }
3596
- }
3597
- const fallback = getClampedElementPosition(quadrants[0].left, quadrants[0].top, boundingRect.width, boundingRect.height);
3598
- fallback.left += INDICATOR_CLAMP_PADDING_PX;
3599
- fallback.top += INDICATOR_CLAMP_PADDING_PX;
3600
- return fallback;
3601
- };
3602
- return createComponent(Show, {
3603
- get when() {
3604
- return props.visible !== false;
3605
- },
3606
- get children() {
3607
- var _el$ = _tmpl$6(), _el$3 = _el$.firstChild, _el$4 = _el$3.firstChild;
3608
- var _ref$ = labelRef;
3609
- typeof _ref$ === "function" ? use(_ref$, _el$) : labelRef = _el$;
3610
- insert(_el$, createComponent(Show, {
3611
- get when() {
3612
- return memo(() => props.variant === "processing")() && props.progress !== void 0;
3613
- },
3614
- get children() {
3615
- var _el$2 = _tmpl$3();
3616
- createRenderEffect((_$p) => setStyleProperty(_el$2, "width", `${Math.min(100, Math.max(0, (props.progress ?? 0) * 100))}%`));
3617
- return _el$2;
3618
- }
3619
- }), _el$3);
3620
- insert(_el$4, createComponent(Show, {
3621
- get when() {
3622
- return props.variant === "processing";
3623
- },
3624
- get children() {
3625
- return createComponent(Spinner, {});
3626
- }
3627
- }), null);
3628
- insert(_el$4, createComponent(Show, {
3629
- get when() {
3630
- return props.variant === "success";
3631
- },
3632
- get children() {
3633
- return _tmpl$22();
3634
- }
3635
- }), null);
3636
- insert(_el$4, createComponent(Show, {
3637
- get when() {
3638
- return props.variant === "success";
3639
- },
3640
- get children() {
3641
- return _tmpl$32();
3642
- }
3643
- }), null);
3644
- insert(_el$4, createComponent(Show, {
3645
- get when() {
3646
- return props.variant === "processing";
3647
- },
3648
- children: "Please wait\u2026"
3649
- }), null);
3650
- insert(_el$4, createComponent(Show, {
3651
- get when() {
3652
- return props.variant !== "processing";
3653
- },
3654
- get children() {
3655
- return props.content;
3656
- }
3657
- }), null);
3658
- insert(_el$4, createComponent(Show, {
3659
- get when() {
3660
- return props.variant === "success";
3661
- },
3662
- get children() {
3663
- return _tmpl$4();
3664
- }
3665
- }), null);
3666
- insert(_el$3, createComponent(Show, {
3667
- get when() {
3668
- return memo(() => props.variant === "hover")() && props.showHint;
3669
- },
3670
- get children() {
3671
- return _tmpl$5();
3672
- }
3673
- }), null);
3674
- createRenderEffect((_p$) => {
3675
- var _v$ = `${computedPosition().top}px`, _v$2 = `${computedPosition().left}px`, _v$3 = props.zIndex?.toString() ?? "2147483647", _v$4 = opacity();
3676
- _v$ !== _p$.e && setStyleProperty(_el$, "top", _p$.e = _v$);
3677
- _v$2 !== _p$.t && setStyleProperty(_el$, "left", _p$.t = _v$2);
3678
- _v$3 !== _p$.a && setStyleProperty(_el$, "z-index", _p$.a = _v$3);
3679
- _v$4 !== _p$.o && setStyleProperty(_el$, "opacity", _p$.o = _v$4);
3680
- return _p$;
3681
- }, {
3682
- e: void 0,
3683
- t: void 0,
3684
- a: void 0,
3685
- o: void 0
3686
- });
3687
- return _el$;
3688
- }
3689
- });
3690
- };
3691
-
3692
3525
  // src/components/crosshair.tsx
3693
- var _tmpl$7 = /* @__PURE__ */ template(`<canvas class="fixed top-0 left-0 pointer-events-none z-[2147483645]">`);
3526
+ var _tmpl$2 = /* @__PURE__ */ template(`<canvas class="fixed top-0 left-0 pointer-events-none z-[2147483645]">`);
3694
3527
  var Crosshair = (props) => {
3695
3528
  let canvasRef;
3696
3529
  let context = null;
@@ -3750,7 +3583,7 @@ var Crosshair = (props) => {
3750
3583
  return props.visible !== false;
3751
3584
  },
3752
3585
  get children() {
3753
- var _el$ = _tmpl$7();
3586
+ var _el$ = _tmpl$2();
3754
3587
  var _ref$ = canvasRef;
3755
3588
  typeof _ref$ === "function" ? use(_ref$, _el$) : canvasRef = _el$;
3756
3589
  return _el$;
@@ -3758,93 +3591,697 @@ var Crosshair = (props) => {
3758
3591
  });
3759
3592
  };
3760
3593
 
3761
- // src/components/input-overlay.tsx
3762
- var _tmpl$8 = /* @__PURE__ */ template(`<div data-react-grab-input class="fixed bg-grab-pink-light text-grab-pink border border-grab-pink-border rounded text-[11px] font-medium font-sans overflow-hidden"style="max-width:calc(100vw - (16px + env(safe-area-inset-left) + env(safe-area-inset-right)))"><div class="relative p-0.5 px-[3px] flex flex-col gap-0.5"><textarea placeholder="Make a change"rows=1 class="w-[150px] px-1 py-0.5 bg-white text-grab-pink border border-grab-pink-border rounded-[3px] text-[11px] leading-tight font-sans outline-none resize-none min-h-[18px] overflow-hidden"></textarea><div class="text-[9px] opacity-60 text-center">Enter \u23CE submit &middot; Esc cancel`);
3763
- var InputOverlay = (props) => {
3594
+ // src/components/icon-checkmark.tsx
3595
+ var _tmpl$3 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 9 9"fill=none><path d="M1 4.5L3.5 7L8 1.5"stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round>`);
3596
+ var IconCheckmark = (props) => {
3597
+ const size = () => props.size ?? 9;
3598
+ return (() => {
3599
+ var _el$ = _tmpl$3();
3600
+ createRenderEffect((_p$) => {
3601
+ var _v$ = size(), _v$2 = size(), _v$3 = props.class;
3602
+ _v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
3603
+ _v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
3604
+ _v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
3605
+ return _p$;
3606
+ }, {
3607
+ e: void 0,
3608
+ t: void 0,
3609
+ a: void 0
3610
+ });
3611
+ return _el$;
3612
+ })();
3613
+ };
3614
+
3615
+ // src/components/icon-cursor-simple.tsx
3616
+ var _tmpl$4 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 12 12"fill=none><path fill-rule=evenodd clip-rule=evenodd d="M0.675576 0.0318497C0.491988 -0.0369956 0.285105 0.0078173 0.146461 0.146461C0.0078173 0.285105 -0.0369956 0.491988 0.0318497 0.675576L4.15685 11.6756C4.2337 11.8805 4.43492 12.0117 4.65345 11.9992C4.87197 11.9868 5.057 11.8336 5.11009 11.6213L6.41232 6.41232L11.6213 5.11009C11.8336 5.057 11.9868 4.87197 11.9992 4.65345C12.0117 4.43492 11.8805 4.2337 11.6756 4.15685L0.675576 0.0318497Z"fill=currentColor>`);
3617
+ var IconCursorSimple = (props) => {
3618
+ const size = () => props.size ?? 9;
3619
+ return (() => {
3620
+ var _el$ = _tmpl$4();
3621
+ createRenderEffect((_p$) => {
3622
+ var _v$ = size(), _v$2 = size(), _v$3 = props.class;
3623
+ _v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
3624
+ _v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
3625
+ _v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
3626
+ return _p$;
3627
+ }, {
3628
+ e: void 0,
3629
+ t: void 0,
3630
+ a: void 0
3631
+ });
3632
+ return _el$;
3633
+ })();
3634
+ };
3635
+
3636
+ // src/components/icon-open.tsx
3637
+ var _tmpl$5 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2><path d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6"></path><path d="M11 13l9-9"></path><path d="M15 4h5v5">`);
3638
+ var IconOpen = (props) => {
3639
+ const size = () => props.size ?? 12;
3640
+ return (() => {
3641
+ var _el$ = _tmpl$5();
3642
+ createRenderEffect((_p$) => {
3643
+ var _v$ = size(), _v$2 = size(), _v$3 = props.class;
3644
+ _v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
3645
+ _v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
3646
+ _v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
3647
+ return _p$;
3648
+ }, {
3649
+ e: void 0,
3650
+ t: void 0,
3651
+ a: void 0
3652
+ });
3653
+ return _el$;
3654
+ })();
3655
+ };
3656
+
3657
+ // src/components/icon-return-key.tsx
3658
+ var _tmpl$6 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 12 12"><g fill=none stroke-linecap=round stroke-linejoin=round stroke-width=1 stroke=currentColor><path d=m1.25,6.75h8.5c.5523,0,1-.4477,1-1v-2.5c0-.5523-.4477-1-1-1h-1.75></path><polyline points="3.75 4 1 6.75 3.75 9.5">`);
3659
+ var IconReturnKey = (props) => {
3660
+ const size = () => props.size ?? 14;
3661
+ return (() => {
3662
+ var _el$ = _tmpl$6();
3663
+ createRenderEffect((_p$) => {
3664
+ var _v$ = size(), _v$2 = size(), _v$3 = props.class;
3665
+ _v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
3666
+ _v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
3667
+ _v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
3668
+ return _p$;
3669
+ }, {
3670
+ e: void 0,
3671
+ t: void 0,
3672
+ a: void 0
3673
+ });
3674
+ return _el$;
3675
+ })();
3676
+ };
3677
+
3678
+ // src/components/icon-stop.tsx
3679
+ var _tmpl$7 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 9 9"fill=none><rect x=1 y=1 width=7 height=7 rx=1 fill=currentColor>`);
3680
+ var IconStop = (props) => {
3681
+ const size = () => props.size ?? 9;
3682
+ return (() => {
3683
+ var _el$ = _tmpl$7();
3684
+ createRenderEffect((_p$) => {
3685
+ var _v$ = size(), _v$2 = size(), _v$3 = props.class;
3686
+ _v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
3687
+ _v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
3688
+ _v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
3689
+ return _p$;
3690
+ }, {
3691
+ e: void 0,
3692
+ t: void 0,
3693
+ a: void 0
3694
+ });
3695
+ return _el$;
3696
+ })();
3697
+ };
3698
+
3699
+ // src/components/selection-label.tsx
3700
+ var _tmpl$8 = /* @__PURE__ */ template(`<div style="background-image:linear-gradient(in oklab 180deg, oklab(88.7% 0.086 -0.058) 0%, oklab(83.2% 0.132 -0.089) 100%)"><span>`);
3701
+ var _tmpl$22 = /* @__PURE__ */ template(`<span>`);
3702
+ var _tmpl$32 = /* @__PURE__ */ template(`<button>`);
3703
+ var _tmpl$42 = /* @__PURE__ */ template(`<div>`);
3704
+ var _tmpl$52 = /* @__PURE__ */ template(`<div class="flex items-center h-[18px] rounded-[1.5px] gap-[3px] px-[5px] py-px bg-label-success-bg border-[0.5px] border-solid border-label-success-border"><span class="text-label-success-text text-[12px] leading-4 font-medium tracking-[-0.04em]">`);
3705
+ var _tmpl$62 = /* @__PURE__ */ template(`<div class="absolute w-0 h-0"style="border-left:8px solid transparent;border-right:8px solid transparent;z-index:1">`);
3706
+ var _tmpl$72 = /* @__PURE__ */ template(`<div class="shrink-0 flex flex-col items-start px-2 py-[5px] w-full h-fit rounded-bl-[3px] rounded-br-[3px] border-t-[0.5px] border-t-solid border-t-label-divider">`);
3707
+ var _tmpl$82 = /* @__PURE__ */ template(`<div class="flex items-center gap-[3px]">`);
3708
+ var _tmpl$9 = /* @__PURE__ */ template(`<button class="flex items-center justify-center w-[18px] h-[18px] rounded-full cursor-pointer bg-black border-none transition-opacity hover:opacity-80"title=Stop>`);
3709
+ var _tmpl$0 = /* @__PURE__ */ template(`<div class="flex items-center gap-[3px] react-grab-shimmer rounded-[3px]">`);
3710
+ var _tmpl$1 = /* @__PURE__ */ template(`<div class="shrink-0 flex items-center gap-1 w-full h-[14px]"><span class="text-label-muted text-[11px] leading-3.5 shrink-0 tracking-[-0.04em] font-medium w-fit h-fit">to change`);
3711
+ var _tmpl$10 = /* @__PURE__ */ template(`<div class="shrink-0 flex flex-col justify-center items-start gap-1 w-fit h-fit"><div class="shrink-0 flex items-center gap-[3px] pt-1 w-fit h-fit px-1">`);
3712
+ var _tmpl$11 = /* @__PURE__ */ template(`<div class="shrink-0 flex justify-between items-start w-full min-h-[14px]"><textarea class="text-black text-[11px] leading-3.5 tracking-[-0.04em] font-medium bg-transparent border-none outline-none resize-none flex-1 p-0 m-0"placeholder="type to modify..."rows=1 style=field-sizing:content;min-height:14px></textarea><button class="shrink-0 flex items-center gap-1 w-fit h-fit cursor-pointer bg-transparent border-none p-0 ml-1 mt-[2.5px]">`);
3713
+ var _tmpl$12 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events class="fixed font-sans antialiased transition-opacity duration-300 ease-out"style=z-index:2147483647><div class="relative flex items-center gap-[5px] bg-white rounded-[3px]"style="box-shadow:#00000033 0px 2px 3px">`);
3714
+ var ARROW_HEIGHT = 8;
3715
+ var LABEL_GAP = 4;
3716
+ var IDLE_TIMEOUT_MS = 150;
3717
+ var TagBadge = (props) => {
3718
+ const [isHovered, setIsHovered] = createSignal(false);
3719
+ const handleMouseEnter = () => {
3720
+ setIsHovered(true);
3721
+ props.onHoverChange?.(true);
3722
+ };
3723
+ const handleMouseLeave = () => {
3724
+ setIsHovered(false);
3725
+ props.onHoverChange?.(false);
3726
+ };
3727
+ return (() => {
3728
+ var _el$ = _tmpl$8(), _el$2 = _el$.firstChild;
3729
+ addEventListener(_el$, "click", props.onClick);
3730
+ _el$.addEventListener("mouseleave", handleMouseLeave);
3731
+ _el$.addEventListener("mouseenter", handleMouseEnter);
3732
+ insert(_el$2, () => props.tagName);
3733
+ insert(_el$, createComponent(Show, {
3734
+ get when() {
3735
+ return props.isClickable;
3736
+ },
3737
+ get children() {
3738
+ return createComponent(IconOpen, {
3739
+ size: 10,
3740
+ get ["class"]() {
3741
+ return cn("text-label-tag-border transition-all duration-100", isHovered() ? "opacity-100 scale-100" : "opacity-0 scale-75 -ml-[5px] w-0");
3742
+ }
3743
+ });
3744
+ }
3745
+ }), null);
3746
+ createRenderEffect((_p$) => {
3747
+ var _v$ = cn("flex items-center px-1 py-px h-[18px] rounded-[1.5px] gap-[5px] border-[0.5px] border-solid border-label-tag-border", props.shrink && "shrink-0 w-fit", props.isClickable && "cursor-pointer"), _v$2 = cn("text-label-tag-text text-[12px] leading-4 font-medium tracking-[-0.04em]", props.showMono && "font-mono", props.shrink && "shrink-0 w-fit h-fit");
3748
+ _v$ !== _p$.e && className(_el$, _p$.e = _v$);
3749
+ _v$2 !== _p$.t && className(_el$2, _p$.t = _v$2);
3750
+ return _p$;
3751
+ }, {
3752
+ e: void 0,
3753
+ t: void 0
3754
+ });
3755
+ return _el$;
3756
+ })();
3757
+ };
3758
+ var ActionPill = (props) => {
3759
+ const baseClass = cn("flex items-center h-[18px] rounded-[1.5px] gap-[3px] px-[5px] py-px border-[0.5px] border-solid border-label-gray-border", props.shrink && "shrink-0 w-fit", props.asButton && "cursor-pointer bg-transparent", props.dimmed && "opacity-50 hover:opacity-100 transition-opacity");
3760
+ const content = [memo(() => props.icon), (() => {
3761
+ var _el$3 = _tmpl$22();
3762
+ insert(_el$3, () => props.label);
3763
+ createRenderEffect(() => className(_el$3, cn("text-black text-[12px] leading-4 font-medium tracking-[-0.04em]", props.shrink && "shrink-0 w-fit h-fit")));
3764
+ return _el$3;
3765
+ })()];
3766
+ return props.asButton ? (() => {
3767
+ var _el$4 = _tmpl$32();
3768
+ addEventListener(_el$4, "click", props.onClick);
3769
+ className(_el$4, baseClass);
3770
+ insert(_el$4, content);
3771
+ return _el$4;
3772
+ })() : (() => {
3773
+ var _el$5 = _tmpl$42();
3774
+ addEventListener(_el$5, "click", props.onClick);
3775
+ className(_el$5, baseClass);
3776
+ insert(_el$5, content);
3777
+ createRenderEffect(() => setAttribute(_el$5, "role", props.onClick ? "button" : void 0));
3778
+ return _el$5;
3779
+ })();
3780
+ };
3781
+ var SuccessPill = (props) => (() => {
3782
+ var _el$6 = _tmpl$52(), _el$7 = _el$6.firstChild;
3783
+ insert(_el$6, createComponent(IconCheckmark, {
3784
+ size: 9,
3785
+ "class": "text-label-success-text shrink-0"
3786
+ }), _el$7);
3787
+ insert(_el$7, () => props.hasAgent ? "Completed" : "Copied");
3788
+ return _el$6;
3789
+ })();
3790
+ var Arrow = (props) => (() => {
3791
+ var _el$8 = _tmpl$62();
3792
+ createRenderEffect((_$p) => style(_el$8, {
3793
+ left: `${props.leftPx}px`,
3794
+ ...props.position === "bottom" ? {
3795
+ top: "0",
3796
+ transform: "translateX(-50%) translateY(-100%)"
3797
+ } : {
3798
+ bottom: "0",
3799
+ transform: "translateX(-50%) translateY(100%)"
3800
+ },
3801
+ ...props.position === "bottom" ? {
3802
+ "border-bottom": "8px solid white"
3803
+ } : {
3804
+ "border-top": "8px solid white"
3805
+ }
3806
+ }, _$p));
3807
+ return _el$8;
3808
+ })();
3809
+ var ClickToCopyPill = (props) => createComponent(ActionPill, {
3810
+ get icon() {
3811
+ return createComponent(IconCursorSimple, {
3812
+ size: 9,
3813
+ "class": "text-black shrink-0"
3814
+ });
3815
+ },
3816
+ label: "Click to copy",
3817
+ get onClick() {
3818
+ return props.onClick;
3819
+ },
3820
+ get asButton() {
3821
+ return props.asButton;
3822
+ },
3823
+ get dimmed() {
3824
+ return props.dimmed;
3825
+ },
3826
+ get shrink() {
3827
+ return props.shrink;
3828
+ }
3829
+ });
3830
+ var BottomSection = (props) => (() => {
3831
+ var _el$9 = _tmpl$72();
3832
+ insert(_el$9, () => props.children);
3833
+ return _el$9;
3834
+ })();
3835
+ var SelectionLabel = (props) => {
3764
3836
  let containerRef;
3765
3837
  let inputRef;
3766
- const position = useAnimatedPosition({
3767
- x: () => props.x,
3768
- y: () => props.y,
3769
- lerpFactor: 0.3
3838
+ let isTagCurrentlyHovered = false;
3839
+ const [measuredWidth, setMeasuredWidth] = createSignal(0);
3840
+ const [measuredHeight, setMeasuredHeight] = createSignal(0);
3841
+ const [arrowPosition, setArrowPosition] = createSignal("bottom");
3842
+ const [viewportVersion, setViewportVersion] = createSignal(0);
3843
+ const [isIdle, setIsIdle] = createSignal(false);
3844
+ const isNotProcessing = () => props.status !== "copying" && props.status !== "copied" && props.status !== "fading";
3845
+ const measureContainer = () => {
3846
+ if (containerRef && !isTagCurrentlyHovered) {
3847
+ const rect = containerRef.getBoundingClientRect();
3848
+ setMeasuredWidth(rect.width);
3849
+ setMeasuredHeight(rect.height);
3850
+ }
3851
+ };
3852
+ const handleTagHoverChange = (hovered) => {
3853
+ isTagCurrentlyHovered = hovered;
3854
+ };
3855
+ const handleViewportChange = () => {
3856
+ setViewportVersion((version) => version + 1);
3857
+ };
3858
+ let idleTimeout;
3859
+ const resetIdleTimer = () => {
3860
+ setIsIdle(false);
3861
+ if (idleTimeout) {
3862
+ clearTimeout(idleTimeout);
3863
+ }
3864
+ idleTimeout = setTimeout(() => {
3865
+ setIsIdle(true);
3866
+ }, IDLE_TIMEOUT_MS);
3867
+ };
3868
+ const handleGlobalKeyDown = (event) => {
3869
+ if (event.code === "Enter" && isIdle() && !props.isInputExpanded && isNotProcessing()) {
3870
+ event.preventDefault();
3871
+ event.stopPropagation();
3872
+ props.onToggleExpand?.();
3873
+ }
3874
+ };
3875
+ onMount(() => {
3876
+ measureContainer();
3877
+ window.addEventListener("scroll", handleViewportChange, true);
3878
+ window.addEventListener("resize", handleViewportChange);
3879
+ window.addEventListener("mousemove", resetIdleTimer);
3880
+ window.addEventListener("keydown", handleGlobalKeyDown, {
3881
+ capture: true
3882
+ });
3883
+ resetIdleTimer();
3884
+ });
3885
+ onCleanup(() => {
3886
+ window.removeEventListener("scroll", handleViewportChange, true);
3887
+ window.removeEventListener("resize", handleViewportChange);
3888
+ window.removeEventListener("mousemove", resetIdleTimer);
3889
+ window.removeEventListener("keydown", handleGlobalKeyDown, {
3890
+ capture: true
3891
+ });
3892
+ if (idleTimeout) {
3893
+ clearTimeout(idleTimeout);
3894
+ }
3895
+ });
3896
+ createEffect(() => {
3897
+ if (props.visible) {
3898
+ requestAnimationFrame(measureContainer);
3899
+ }
3900
+ });
3901
+ createEffect(() => {
3902
+ void [props.status, props.isInputExpanded, props.inputValue, isIdle()];
3903
+ requestAnimationFrame(measureContainer);
3904
+ });
3905
+ createEffect(() => {
3906
+ if (props.isInputExpanded && inputRef) {
3907
+ setTimeout(() => {
3908
+ inputRef?.focus();
3909
+ }, 0);
3910
+ }
3770
3911
  });
3771
- const containerBoundingRect = () => containerRef?.getBoundingClientRect();
3772
3912
  const computedPosition = () => {
3773
- const boundingRect = containerBoundingRect();
3774
- if (!boundingRect) return {
3775
- left: position.x(),
3776
- top: position.y()
3777
- };
3913
+ viewportVersion();
3914
+ const bounds = props.selectionBounds;
3915
+ const labelWidth = measuredWidth();
3916
+ const labelHeight = measuredHeight();
3917
+ if (!bounds || labelWidth === 0 || labelHeight === 0) {
3918
+ return {
3919
+ left: -9999,
3920
+ top: -9999,
3921
+ arrowLeft: 0
3922
+ };
3923
+ }
3778
3924
  const viewportWidth = window.innerWidth;
3779
3925
  const viewportHeight = window.innerHeight;
3780
- const quadrants = getCursorQuadrants(position.x(), position.y(), boundingRect.width, boundingRect.height, CURSOR_OFFSET_PX);
3781
- for (const position2 of quadrants) {
3782
- const fitsHorizontally = position2.left >= VIEWPORT_MARGIN_PX && position2.left + boundingRect.width <= viewportWidth - VIEWPORT_MARGIN_PX;
3783
- const fitsVertically = position2.top >= VIEWPORT_MARGIN_PX && position2.top + boundingRect.height <= viewportHeight - VIEWPORT_MARGIN_PX;
3784
- if (fitsHorizontally && fitsVertically) {
3785
- return position2;
3786
- }
3926
+ const selectionCenterX = bounds.x + bounds.width / 2;
3927
+ const selectionBottom = bounds.y + bounds.height;
3928
+ const selectionTop = bounds.y;
3929
+ let positionLeft = selectionCenterX - labelWidth / 2;
3930
+ let positionTop = selectionBottom + ARROW_HEIGHT + LABEL_GAP;
3931
+ if (positionLeft + labelWidth > viewportWidth - VIEWPORT_MARGIN_PX) {
3932
+ positionLeft = viewportWidth - labelWidth - VIEWPORT_MARGIN_PX;
3933
+ }
3934
+ if (positionLeft < VIEWPORT_MARGIN_PX) {
3935
+ positionLeft = VIEWPORT_MARGIN_PX;
3787
3936
  }
3788
- const fallback = getClampedElementPosition(quadrants[0].left, quadrants[0].top, boundingRect.width, boundingRect.height);
3789
- fallback.left += INDICATOR_CLAMP_PADDING_PX;
3790
- fallback.top += INDICATOR_CLAMP_PADDING_PX;
3791
- return fallback;
3937
+ const totalHeightNeeded = labelHeight + ARROW_HEIGHT + LABEL_GAP;
3938
+ const fitsBelow = positionTop + labelHeight <= viewportHeight - VIEWPORT_MARGIN_PX;
3939
+ if (!fitsBelow) {
3940
+ positionTop = selectionTop - totalHeightNeeded;
3941
+ setArrowPosition("top");
3942
+ } else {
3943
+ setArrowPosition("bottom");
3944
+ }
3945
+ if (positionTop < VIEWPORT_MARGIN_PX) {
3946
+ positionTop = VIEWPORT_MARGIN_PX;
3947
+ }
3948
+ const arrowLeft = Math.max(12, Math.min(selectionCenterX - positionLeft, labelWidth - 12));
3949
+ return {
3950
+ left: positionLeft,
3951
+ top: positionTop,
3952
+ arrowLeft
3953
+ };
3792
3954
  };
3793
3955
  const handleKeyDown = (event) => {
3956
+ event.stopPropagation();
3794
3957
  if (event.code === "Enter" && !event.shiftKey) {
3795
3958
  event.preventDefault();
3796
- event.stopPropagation();
3797
- props.onSubmit();
3959
+ props.onSubmit?.();
3798
3960
  } else if (event.code === "Escape") {
3799
3961
  event.preventDefault();
3800
- event.stopPropagation();
3801
- props.onCancel();
3962
+ props.onCancel?.();
3802
3963
  }
3803
3964
  };
3804
3965
  const handleInput = (event) => {
3805
3966
  const target = event.target;
3806
- props.onInput(target.value);
3807
- target.style.height = "auto";
3808
- target.style.height = `${target.scrollHeight}px`;
3967
+ props.onInputChange?.(target.value);
3809
3968
  };
3810
- createEffect(() => {
3811
- if (props.visible && inputRef) {
3812
- inputRef.focus();
3813
- inputRef.style.height = "auto";
3814
- } else if (!props.visible && inputRef) {
3815
- inputRef.blur();
3969
+ const tagDisplay = () => props.tagName || "element";
3970
+ const handleTagClick = (event) => {
3971
+ event.stopPropagation();
3972
+ event.stopImmediatePropagation();
3973
+ if (props.filePath && props.onOpen) {
3974
+ props.onOpen();
3816
3975
  }
3817
- });
3818
- return (() => {
3819
- var _el$ = _tmpl$8(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
3820
- var _ref$ = containerRef;
3821
- typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
3822
- _el$3.$$keydown = handleKeyDown;
3823
- _el$3.$$input = handleInput;
3824
- var _ref$2 = inputRef;
3825
- typeof _ref$2 === "function" ? use(_ref$2, _el$3) : inputRef = _el$3;
3826
- createRenderEffect((_p$) => {
3827
- var _v$ = props.visible ? "block" : "none", _v$2 = `${computedPosition().top}px`, _v$3 = `${computedPosition().left}px`, _v$4 = props.zIndex?.toString() ?? "2147483647", _v$5 = props.visible ? "auto" : "none";
3828
- _v$ !== _p$.e && setStyleProperty(_el$, "display", _p$.e = _v$);
3829
- _v$2 !== _p$.t && setStyleProperty(_el$, "top", _p$.t = _v$2);
3830
- _v$3 !== _p$.a && setStyleProperty(_el$, "left", _p$.a = _v$3);
3831
- _v$4 !== _p$.o && setStyleProperty(_el$, "z-index", _p$.o = _v$4);
3832
- _v$5 !== _p$.i && setStyleProperty(_el$, "pointer-events", _p$.i = _v$5);
3833
- return _p$;
3834
- }, {
3835
- e: void 0,
3836
- t: void 0,
3837
- a: void 0,
3838
- o: void 0,
3839
- i: void 0
3840
- });
3841
- createRenderEffect(() => _el$3.value = props.value);
3842
- return _el$;
3843
- })();
3844
- };
3845
- delegateEvents(["input", "keydown"]);
3846
-
3976
+ };
3977
+ const isTagClickable = () => Boolean(props.filePath && props.onOpen);
3978
+ const stopPropagation = (event) => {
3979
+ event.stopPropagation();
3980
+ event.stopImmediatePropagation();
3981
+ };
3982
+ const handleSubmit = () => props.onSubmit?.();
3983
+ return createComponent(Show, {
3984
+ get when() {
3985
+ return memo(() => props.visible !== false)() && props.selectionBounds;
3986
+ },
3987
+ get children() {
3988
+ var _el$0 = _tmpl$12(), _el$1 = _el$0.firstChild;
3989
+ _el$0.$$click = stopPropagation;
3990
+ _el$0.$$mousedown = stopPropagation;
3991
+ var _ref$ = containerRef;
3992
+ typeof _ref$ === "function" ? use(_ref$, _el$0) : containerRef = _el$0;
3993
+ insert(_el$0, createComponent(Arrow, {
3994
+ get position() {
3995
+ return arrowPosition();
3996
+ },
3997
+ get leftPx() {
3998
+ return computedPosition().arrowLeft;
3999
+ }
4000
+ }), _el$1);
4001
+ insert(_el$1, createComponent(Show, {
4002
+ get when() {
4003
+ return props.status === "copied" || props.status === "fading";
4004
+ },
4005
+ get children() {
4006
+ var _el$10 = _tmpl$82();
4007
+ insert(_el$10, createComponent(TagBadge, {
4008
+ get tagName() {
4009
+ return tagDisplay();
4010
+ },
4011
+ get isClickable() {
4012
+ return isTagClickable();
4013
+ },
4014
+ onClick: handleTagClick,
4015
+ onHoverChange: handleTagHoverChange
4016
+ }), null);
4017
+ insert(_el$10, createComponent(SuccessPill, {
4018
+ get hasAgent() {
4019
+ return props.hasAgent;
4020
+ }
4021
+ }), null);
4022
+ return _el$10;
4023
+ }
4024
+ }), null);
4025
+ insert(_el$1, createComponent(Show, {
4026
+ get when() {
4027
+ return props.status === "copying";
4028
+ },
4029
+ get children() {
4030
+ var _el$11 = _tmpl$0();
4031
+ insert(_el$11, createComponent(TagBadge, {
4032
+ get tagName() {
4033
+ return tagDisplay();
4034
+ },
4035
+ get isClickable() {
4036
+ return isTagClickable();
4037
+ },
4038
+ onClick: handleTagClick,
4039
+ onHoverChange: handleTagHoverChange,
4040
+ showMono: true
4041
+ }), null);
4042
+ insert(_el$11, createComponent(ActionPill, {
4043
+ get icon() {
4044
+ return createComponent(IconCursorSimple, {
4045
+ size: 9,
4046
+ "class": "text-black shrink-0"
4047
+ });
4048
+ },
4049
+ get label() {
4050
+ return props.statusText ?? "Grabbing\u2026";
4051
+ }
4052
+ }), null);
4053
+ insert(_el$11, createComponent(Show, {
4054
+ get when() {
4055
+ return memo(() => !!props.hasAgent)() && props.onAbort;
4056
+ },
4057
+ get children() {
4058
+ var _el$12 = _tmpl$9();
4059
+ _el$12.$$click = (event) => {
4060
+ event.preventDefault();
4061
+ event.stopPropagation();
4062
+ event.stopImmediatePropagation();
4063
+ props.onAbort?.();
4064
+ };
4065
+ _el$12.$$mousedown = (event) => {
4066
+ event.preventDefault();
4067
+ event.stopPropagation();
4068
+ event.stopImmediatePropagation();
4069
+ };
4070
+ insert(_el$12, createComponent(IconStop, {
4071
+ size: 8,
4072
+ "class": "text-white"
4073
+ }));
4074
+ return _el$12;
4075
+ }
4076
+ }), null);
4077
+ return _el$11;
4078
+ }
4079
+ }), null);
4080
+ insert(_el$1, createComponent(Show, {
4081
+ get when() {
4082
+ return memo(() => !!(isNotProcessing() && !isIdle()))() && !props.isInputExpanded;
4083
+ },
4084
+ get children() {
4085
+ var _el$13 = _tmpl$82();
4086
+ insert(_el$13, createComponent(TagBadge, {
4087
+ get tagName() {
4088
+ return tagDisplay();
4089
+ },
4090
+ get isClickable() {
4091
+ return isTagClickable();
4092
+ },
4093
+ onClick: handleTagClick,
4094
+ onHoverChange: handleTagHoverChange,
4095
+ showMono: true
4096
+ }), null);
4097
+ insert(_el$13, createComponent(ClickToCopyPill, {
4098
+ onClick: handleSubmit,
4099
+ asButton: true
4100
+ }), null);
4101
+ return _el$13;
4102
+ }
4103
+ }), null);
4104
+ insert(_el$1, createComponent(Show, {
4105
+ get when() {
4106
+ return memo(() => !!(isNotProcessing() && isIdle()))() && !props.isInputExpanded;
4107
+ },
4108
+ get children() {
4109
+ var _el$14 = _tmpl$10(), _el$15 = _el$14.firstChild;
4110
+ insert(_el$15, createComponent(TagBadge, {
4111
+ get tagName() {
4112
+ return tagDisplay();
4113
+ },
4114
+ get isClickable() {
4115
+ return isTagClickable();
4116
+ },
4117
+ onClick: handleTagClick,
4118
+ onHoverChange: handleTagHoverChange,
4119
+ showMono: true,
4120
+ shrink: true
4121
+ }), null);
4122
+ insert(_el$15, createComponent(ClickToCopyPill, {
4123
+ onClick: handleSubmit,
4124
+ shrink: true
4125
+ }), null);
4126
+ insert(_el$14, createComponent(BottomSection, {
4127
+ get children() {
4128
+ var _el$16 = _tmpl$1(), _el$17 = _el$16.firstChild;
4129
+ insert(_el$16, createComponent(IconReturnKey, {
4130
+ size: 10,
4131
+ "class": "shrink-0 text-black opacity-[0.65]"
4132
+ }), _el$17);
4133
+ return _el$16;
4134
+ }
4135
+ }), null);
4136
+ return _el$14;
4137
+ }
4138
+ }), null);
4139
+ insert(_el$1, createComponent(Show, {
4140
+ get when() {
4141
+ return memo(() => !!isNotProcessing())() && props.isInputExpanded;
4142
+ },
4143
+ get children() {
4144
+ var _el$18 = _tmpl$10(), _el$19 = _el$18.firstChild;
4145
+ insert(_el$19, createComponent(TagBadge, {
4146
+ get tagName() {
4147
+ return tagDisplay();
4148
+ },
4149
+ get isClickable() {
4150
+ return isTagClickable();
4151
+ },
4152
+ onClick: handleTagClick,
4153
+ onHoverChange: handleTagHoverChange,
4154
+ showMono: true,
4155
+ shrink: true
4156
+ }), null);
4157
+ insert(_el$19, createComponent(ClickToCopyPill, {
4158
+ onClick: handleSubmit,
4159
+ dimmed: true,
4160
+ shrink: true
4161
+ }), null);
4162
+ insert(_el$18, createComponent(BottomSection, {
4163
+ get children() {
4164
+ var _el$20 = _tmpl$11(), _el$21 = _el$20.firstChild, _el$22 = _el$21.nextSibling;
4165
+ _el$21.$$keydown = handleKeyDown;
4166
+ _el$21.$$input = handleInput;
4167
+ var _ref$2 = inputRef;
4168
+ typeof _ref$2 === "function" ? use(_ref$2, _el$21) : inputRef = _el$21;
4169
+ _el$22.$$click = handleSubmit;
4170
+ insert(_el$22, createComponent(IconReturnKey, {
4171
+ size: 10,
4172
+ "class": "shrink-0 text-black"
4173
+ }));
4174
+ createRenderEffect(() => _el$21.value = props.inputValue ?? "");
4175
+ return _el$20;
4176
+ }
4177
+ }), null);
4178
+ return _el$18;
4179
+ }
4180
+ }), null);
4181
+ createRenderEffect((_p$) => {
4182
+ var _v$3 = `${computedPosition().top}px`, _v$4 = `${computedPosition().left}px`, _v$5 = props.visible ? "auto" : "none", _v$6 = props.status === "fading" ? 0 : 1, _v$7 = !isNotProcessing() ? "4px" : isIdle() || props.isInputExpanded ? "0" : "4px";
4183
+ _v$3 !== _p$.e && setStyleProperty(_el$0, "top", _p$.e = _v$3);
4184
+ _v$4 !== _p$.t && setStyleProperty(_el$0, "left", _p$.t = _v$4);
4185
+ _v$5 !== _p$.a && setStyleProperty(_el$0, "pointer-events", _p$.a = _v$5);
4186
+ _v$6 !== _p$.o && setStyleProperty(_el$0, "opacity", _p$.o = _v$6);
4187
+ _v$7 !== _p$.i && setStyleProperty(_el$1, "padding", _p$.i = _v$7);
4188
+ return _p$;
4189
+ }, {
4190
+ e: void 0,
4191
+ t: void 0,
4192
+ a: void 0,
4193
+ o: void 0,
4194
+ i: void 0
4195
+ });
4196
+ return _el$0;
4197
+ }
4198
+ });
4199
+ };
4200
+ delegateEvents(["click", "mousedown", "input", "keydown"]);
4201
+
4202
+ // src/components/selection-cursor.tsx
4203
+ var _tmpl$13 = /* @__PURE__ */ template(`<div class="fixed z-2147483647"><button data-react-grab-selection-cursor>`);
4204
+ var SelectionCursor = (props) => {
4205
+ const [isHovered, setIsHovered] = createSignal(false);
4206
+ const [debouncedVisible, setDebouncedVisible] = createSignal(false);
4207
+ createEffect(() => {
4208
+ const isVisible = props.visible !== false;
4209
+ void [props.x, props.y];
4210
+ setDebouncedVisible(false);
4211
+ if (isVisible) {
4212
+ const timeout = setTimeout(() => setDebouncedVisible(true), SELECTION_CURSOR_SETTLE_DELAY_MS);
4213
+ onCleanup(() => clearTimeout(timeout));
4214
+ }
4215
+ });
4216
+ const handleClick = (event) => {
4217
+ event.preventDefault();
4218
+ event.stopPropagation();
4219
+ props.onClick?.();
4220
+ };
4221
+ return createComponent(Show, {
4222
+ get when() {
4223
+ return debouncedVisible();
4224
+ },
4225
+ get children() {
4226
+ return [createComponent(Show, {
4227
+ get when() {
4228
+ return memo(() => !!isHovered())() && props.elementBounds;
4229
+ },
4230
+ get children() {
4231
+ return createComponent(SelectionBox, {
4232
+ variant: "selection",
4233
+ get bounds() {
4234
+ return props.elementBounds;
4235
+ },
4236
+ visible: true
4237
+ });
4238
+ }
4239
+ }), (() => {
4240
+ var _el$ = _tmpl$13(), _el$2 = _el$.firstChild;
4241
+ _el$.addEventListener("mouseleave", () => setIsHovered(false));
4242
+ _el$.addEventListener("mouseenter", () => setIsHovered(true));
4243
+ _el$2.$$click = handleClick;
4244
+ createRenderEffect((_p$) => {
4245
+ var _v$ = `${props.x}px`, _v$2 = `${props.y}px`, _v$3 = cn("absolute left-0 top-0 -translate-x-1/2 -translate-y-1/2 bg-grab-pink cursor-pointer rounded-full transition-[width,height] duration-150", isHovered() ? "w-1 h-5.5 brightness-125" : "w-0.5 h-5 animate-pulse");
4246
+ _v$ !== _p$.e && setStyleProperty(_el$, "left", _p$.e = _v$);
4247
+ _v$2 !== _p$.t && setStyleProperty(_el$, "top", _p$.t = _v$2);
4248
+ _v$3 !== _p$.a && className(_el$2, _p$.a = _v$3);
4249
+ return _p$;
4250
+ }, {
4251
+ e: void 0,
4252
+ t: void 0,
4253
+ a: void 0
4254
+ });
4255
+ return _el$;
4256
+ })(), createComponent(Show, {
4257
+ get when() {
4258
+ return memo(() => !!isHovered())() && props.elementBounds;
4259
+ },
4260
+ get children() {
4261
+ return createComponent(SelectionLabel, {
4262
+ get tagName() {
4263
+ return props.tagName;
4264
+ },
4265
+ get selectionBounds() {
4266
+ return props.elementBounds;
4267
+ },
4268
+ visible: true,
4269
+ get onSubmit() {
4270
+ return props.onClick;
4271
+ }
4272
+ });
4273
+ }
4274
+ })];
4275
+ }
4276
+ });
4277
+ };
4278
+ delegateEvents(["click"]);
4279
+
3847
4280
  // src/components/renderer.tsx
4281
+ var truncateStatus = (status, maxLength = 30) => {
4282
+ if (status.length <= maxLength) return status;
4283
+ return `${status.slice(0, maxLength)}\u2026`;
4284
+ };
3848
4285
  var ReactGrabRenderer = (props) => {
3849
4286
  return [createComponent(Show, {
3850
4287
  get when() {
@@ -3858,6 +4295,9 @@ var ReactGrabRenderer = (props) => {
3858
4295
  },
3859
4296
  get visible() {
3860
4297
  return props.selectionVisible;
4298
+ },
4299
+ get isFading() {
4300
+ return props.selectionLabelStatus === "fading";
3861
4301
  }
3862
4302
  });
3863
4303
  }
@@ -3904,86 +4344,141 @@ var ReactGrabRenderer = (props) => {
3904
4344
  return box.createdAt;
3905
4345
  }
3906
4346
  })
4347
+ }), createComponent(For, {
4348
+ get each() {
4349
+ return memo(() => !!props.agentSessions)() ? Array.from(props.agentSessions.values()) : [];
4350
+ },
4351
+ children: (session) => [createComponent(Show, {
4352
+ get when() {
4353
+ return session.selectionBounds;
4354
+ },
4355
+ get children() {
4356
+ return createComponent(SelectionBox, {
4357
+ variant: "processing",
4358
+ get bounds() {
4359
+ return session.selectionBounds;
4360
+ },
4361
+ visible: true
4362
+ });
4363
+ }
4364
+ }), createComponent(SelectionLabel, {
4365
+ get tagName() {
4366
+ return session.tagName;
4367
+ },
4368
+ get selectionBounds() {
4369
+ return session.selectionBounds;
4370
+ },
4371
+ visible: true,
4372
+ hasAgent: true,
4373
+ get status() {
4374
+ return session.isStreaming ? "copying" : "copied";
4375
+ },
4376
+ get statusText() {
4377
+ return truncateStatus(session.lastStatus || "Please wait\u2026");
4378
+ },
4379
+ onAbort: () => props.onAbortSession?.(session.id)
4380
+ })]
3907
4381
  }), createComponent(Show, {
3908
4382
  get when() {
3909
- return props.labelVariant !== "processing";
4383
+ return memo(() => !!props.selectionLabelVisible)() && props.selectionBounds;
3910
4384
  },
3911
4385
  get children() {
3912
- return createComponent(For, {
3913
- get each() {
3914
- return props.successLabels ?? [];
4386
+ return createComponent(SelectionLabel, {
4387
+ get tagName() {
4388
+ return props.selectionTagName;
3915
4389
  },
3916
- children: (label) => createComponent(Label, {
3917
- variant: "success",
3918
- get content() {
3919
- return memo(() => label.text);
3920
- },
3921
- get x() {
3922
- return props.mouseX ?? 0;
3923
- },
3924
- get y() {
3925
- return props.mouseY ?? 0;
4390
+ get selectionBounds() {
4391
+ return props.selectionBounds;
4392
+ },
4393
+ get visible() {
4394
+ return props.selectionLabelVisible;
4395
+ },
4396
+ get isInputExpanded() {
4397
+ return props.isInputExpanded;
4398
+ },
4399
+ get inputValue() {
4400
+ return props.inputValue;
4401
+ },
4402
+ get hasAgent() {
4403
+ return props.hasAgent;
4404
+ },
4405
+ get status() {
4406
+ return props.selectionLabelStatus;
4407
+ },
4408
+ get filePath() {
4409
+ return props.selectionFilePath;
4410
+ },
4411
+ get lineNumber() {
4412
+ return props.selectionLineNumber;
4413
+ },
4414
+ get onInputChange() {
4415
+ return props.onInputChange;
4416
+ },
4417
+ get onSubmit() {
4418
+ return props.onInputSubmit;
4419
+ },
4420
+ get onCancel() {
4421
+ return props.onInputCancel;
4422
+ },
4423
+ get onToggleExpand() {
4424
+ return props.onToggleExpand;
4425
+ },
4426
+ onOpen: () => {
4427
+ if (props.selectionFilePath) {
4428
+ const openFileUrl = buildOpenFileUrl(props.selectionFilePath, props.selectionLineNumber);
4429
+ window.open(openFileUrl, "_blank");
3926
4430
  }
3927
- })
4431
+ }
3928
4432
  });
3929
4433
  }
4434
+ }), createComponent(For, {
4435
+ get each() {
4436
+ return props.labelInstances ?? [];
4437
+ },
4438
+ children: (instance) => createComponent(SelectionLabel, {
4439
+ get tagName() {
4440
+ return instance.tagName;
4441
+ },
4442
+ get selectionBounds() {
4443
+ return instance.bounds;
4444
+ },
4445
+ visible: true,
4446
+ get status() {
4447
+ return instance.status;
4448
+ }
4449
+ })
3930
4450
  }), createComponent(Show, {
3931
4451
  get when() {
3932
- return memo(() => !!(props.labelVisible && props.labelVariant && props.labelContent !== void 0 && props.labelX !== void 0))() && props.labelY !== void 0;
4452
+ return memo(() => !!(props.nativeSelectionCursorVisible && props.nativeSelectionCursorX !== void 0))() && props.nativeSelectionCursorY !== void 0;
3933
4453
  },
3934
4454
  get children() {
3935
- return createComponent(Label, {
3936
- get variant() {
3937
- return props.labelVariant;
3938
- },
3939
- get content() {
3940
- return props.labelContent;
3941
- },
4455
+ return createComponent(SelectionCursor, {
3942
4456
  get x() {
3943
- return props.labelX;
4457
+ return props.nativeSelectionCursorX;
3944
4458
  },
3945
4459
  get y() {
3946
- return props.labelY;
4460
+ return props.nativeSelectionCursorY;
3947
4461
  },
3948
- get visible() {
3949
- return props.labelVisible;
4462
+ get tagName() {
4463
+ return props.nativeSelectionTagName;
4464
+ },
4465
+ get componentName() {
4466
+ return props.nativeSelectionComponentName;
3950
4467
  },
3951
- get zIndex() {
3952
- return props.labelZIndex;
4468
+ get elementBounds() {
4469
+ return props.nativeSelectionBounds;
3953
4470
  },
3954
- get progress() {
3955
- return props.progress;
4471
+ get visible() {
4472
+ return props.nativeSelectionCursorVisible;
4473
+ },
4474
+ get onClick() {
4475
+ return props.onNativeSelectionCopy;
3956
4476
  },
3957
- get showHint() {
3958
- return props.labelShowHint;
4477
+ get onEnter() {
4478
+ return props.onNativeSelectionEnter;
3959
4479
  }
3960
4480
  });
3961
4481
  }
3962
- }), createComponent(InputOverlay, {
3963
- get x() {
3964
- return props.inputX ?? 0;
3965
- },
3966
- get y() {
3967
- return props.inputY ?? 0;
3968
- },
3969
- get zIndex() {
3970
- return props.labelZIndex;
3971
- },
3972
- get value() {
3973
- return props.inputValue ?? "";
3974
- },
3975
- get visible() {
3976
- return props.inputVisible ?? false;
3977
- },
3978
- get onInput() {
3979
- return props.onInputChange;
3980
- },
3981
- get onSubmit() {
3982
- return props.onInputSubmit;
3983
- },
3984
- get onCancel() {
3985
- return props.onInputCancel;
3986
- }
3987
4482
  })];
3988
4483
  };
3989
4484
 
@@ -4928,20 +5423,47 @@ var getStack = async (element) => {
4928
5423
  return [];
4929
5424
  }
4930
5425
  };
4931
- var formatStack = (stack) => {
5426
+ var formatElementInfo = async (element) => {
5427
+ const html = getHTMLPreview(element);
5428
+ const stack = await getStack(element);
4932
5429
  const isNextProject = checkIsNextProject();
4933
- return stack.map(({ name, source }) => {
4934
- if (!source) return ` at ${name}`;
4935
- if (source.fileName.startsWith("about://React/Server")) {
4936
- return ` at ${name} (Server)`;
4937
- }
4938
- if (!je2(source.fileName)) return ` at ${name}`;
4939
- const framePart = ` at ${name} in ${Q(source.fileName)}`;
4940
- if (isNextProject) {
4941
- return `${framePart}:${source.lineNumber}:${source.columnNumber}`;
4942
- }
4943
- return framePart;
4944
- }).join("\n");
5430
+ let serverBoundary = null;
5431
+ let componentName = null;
5432
+ let fileName = null;
5433
+ let lineNumber = null;
5434
+ let columnNumber = null;
5435
+ for (const frame of stack) {
5436
+ if (!frame.source) continue;
5437
+ if (frame.source.fileName.startsWith("about://React/Server")) {
5438
+ if (!serverBoundary) serverBoundary = frame.name;
5439
+ continue;
5440
+ }
5441
+ if (je2(frame.source.fileName)) {
5442
+ if (!fileName) {
5443
+ fileName = Q(frame.source.fileName);
5444
+ lineNumber = frame.source.lineNumber ?? null;
5445
+ columnNumber = frame.source.columnNumber ?? null;
5446
+ }
5447
+ if (!componentName && checkIsSourceComponentName(frame.name)) {
5448
+ componentName = frame.name;
5449
+ }
5450
+ if (fileName && componentName) {
5451
+ break;
5452
+ }
5453
+ }
5454
+ }
5455
+ if (!componentName || !fileName) {
5456
+ return html;
5457
+ }
5458
+ let result = `${html}
5459
+ in ${componentName} at ${fileName}`;
5460
+ if (isNextProject && lineNumber && columnNumber) {
5461
+ result += `:${lineNumber}:${columnNumber}`;
5462
+ }
5463
+ if (serverBoundary) {
5464
+ result += ` (via Server: ${serverBoundary})`;
5465
+ }
5466
+ return result;
4945
5467
  };
4946
5468
  var getFileName = (stack) => {
4947
5469
  for (const frame of stack) {
@@ -5296,6 +5818,53 @@ var isCLikeKey = (key, code) => {
5296
5818
  return C_LIKE_CHARACTERS.has(key);
5297
5819
  };
5298
5820
 
5821
+ // src/utils/hotkey.ts
5822
+ var keyMatchesCode = (targetKey, code) => {
5823
+ const normalizedTarget = targetKey.toLowerCase();
5824
+ if (code.startsWith("Key")) {
5825
+ return code.slice(3).toLowerCase() === normalizedTarget;
5826
+ }
5827
+ if (code.startsWith("Digit")) {
5828
+ return code.slice(5) === normalizedTarget;
5829
+ }
5830
+ return false;
5831
+ };
5832
+ var isTargetKeyCombination = (event, options) => {
5833
+ if (options.activationShortcut) {
5834
+ return options.activationShortcut(event);
5835
+ }
5836
+ if (options.activationKey) {
5837
+ const { key, metaKey, ctrlKey, shiftKey, altKey } = options.activationKey;
5838
+ const isModifierOnly = !key;
5839
+ if (isModifierOnly) {
5840
+ if (!MODIFIER_KEYS.includes(event.key)) return false;
5841
+ const metaMatches = metaKey ? event.metaKey || event.key === "Meta" : true;
5842
+ const ctrlMatches = ctrlKey ? event.ctrlKey || event.key === "Control" : true;
5843
+ const shiftMatches = shiftKey ? event.shiftKey || event.key === "Shift" : true;
5844
+ const altMatches = altKey ? event.altKey || event.key === "Alt" : true;
5845
+ const allRequiredModifiersPressed = metaMatches && ctrlMatches && shiftMatches && altMatches;
5846
+ const requiredModifierCount = [metaKey, ctrlKey, shiftKey, altKey].filter(Boolean).length;
5847
+ const pressedModifierCount = [
5848
+ event.metaKey || event.key === "Meta",
5849
+ event.ctrlKey || event.key === "Control",
5850
+ event.shiftKey || event.key === "Shift",
5851
+ event.altKey || event.key === "Alt"
5852
+ ].filter(Boolean).length;
5853
+ return allRequiredModifiersPressed && pressedModifierCount >= requiredModifierCount;
5854
+ }
5855
+ const keyMatches = event.key.toLowerCase() === key.toLowerCase() || keyMatchesCode(key, event.code);
5856
+ const hasModifier = metaKey || ctrlKey || shiftKey || altKey;
5857
+ const modifiersMatch = hasModifier ? (metaKey ? event.metaKey : true) && (ctrlKey ? event.ctrlKey : true) && (shiftKey ? event.shiftKey : true) && (altKey ? event.altKey : true) : event.metaKey || event.ctrlKey;
5858
+ return keyMatches && modifiersMatch;
5859
+ }
5860
+ return (event.metaKey || event.ctrlKey) && isCLikeKey(event.key, event.code);
5861
+ };
5862
+
5863
+ // src/utils/is-event-from-overlay.ts
5864
+ var isEventFromOverlay = (event, attribute) => event.composedPath().some(
5865
+ (target) => target instanceof HTMLElement && target.hasAttribute(attribute)
5866
+ );
5867
+
5299
5868
  // src/theme.ts
5300
5869
  var DEFAULT_THEME = {
5301
5870
  enabled: true,
@@ -5408,10 +5977,289 @@ var deepMergeTheme = (baseTheme, partialTheme) => {
5408
5977
  };
5409
5978
  };
5410
5979
 
5980
+ // src/utils/agent-session.ts
5981
+ var STORAGE_KEY = "react-grab:agent-sessions";
5982
+ var generateSessionId = () => `session-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
5983
+ var createSession = (context, position, selectionBounds, tagName) => ({
5984
+ id: generateSessionId(),
5985
+ context,
5986
+ lastStatus: "",
5987
+ isStreaming: true,
5988
+ createdAt: Date.now(),
5989
+ position,
5990
+ selectionBounds,
5991
+ tagName
5992
+ });
5993
+ var getStorage = (storage) => {
5994
+ if (!storage) return null;
5995
+ return storage;
5996
+ };
5997
+ var memorySessions = /* @__PURE__ */ new Map();
5998
+ var saveSessions = (sessions, storage) => {
5999
+ const resolvedStorage = getStorage(storage);
6000
+ if (!resolvedStorage) {
6001
+ memorySessions.clear();
6002
+ sessions.forEach((session, id) => memorySessions.set(id, session));
6003
+ return;
6004
+ }
6005
+ try {
6006
+ const sessionsObject = Object.fromEntries(sessions);
6007
+ resolvedStorage.setItem(STORAGE_KEY, JSON.stringify(sessionsObject));
6008
+ } catch {
6009
+ memorySessions.clear();
6010
+ sessions.forEach((session, id) => memorySessions.set(id, session));
6011
+ }
6012
+ };
6013
+ var saveSessionById = (session, storage) => {
6014
+ const sessions = loadSessions(storage);
6015
+ sessions.set(session.id, session);
6016
+ saveSessions(sessions, storage);
6017
+ };
6018
+ var loadSessions = (storage) => {
6019
+ const resolvedStorage = getStorage(storage);
6020
+ if (!resolvedStorage) {
6021
+ return new Map(memorySessions);
6022
+ }
6023
+ try {
6024
+ const data = resolvedStorage.getItem(STORAGE_KEY);
6025
+ if (!data) return /* @__PURE__ */ new Map();
6026
+ const sessionsObject = JSON.parse(data);
6027
+ return new Map(Object.entries(sessionsObject));
6028
+ } catch {
6029
+ return /* @__PURE__ */ new Map();
6030
+ }
6031
+ };
6032
+ var clearSessions = (storage) => {
6033
+ const resolvedStorage = getStorage(storage);
6034
+ if (!resolvedStorage) {
6035
+ memorySessions.clear();
6036
+ return;
6037
+ }
6038
+ try {
6039
+ resolvedStorage.removeItem(STORAGE_KEY);
6040
+ } catch {
6041
+ memorySessions.clear();
6042
+ }
6043
+ };
6044
+ var clearSessionById = (sessionId, storage) => {
6045
+ const sessions = loadSessions(storage);
6046
+ sessions.delete(sessionId);
6047
+ saveSessions(sessions, storage);
6048
+ };
6049
+ var updateSession = (session, updates, storage) => {
6050
+ const updatedSession = { ...session, ...updates };
6051
+ saveSessionById(updatedSession, storage);
6052
+ return updatedSession;
6053
+ };
6054
+
6055
+ // src/utils/generate-snippet.ts
6056
+ var generateSnippet = async (elements) => {
6057
+ const elementSnippetResults = await Promise.allSettled(
6058
+ elements.map((element) => formatElementInfo(element))
6059
+ );
6060
+ const elementSnippets = elementSnippetResults.map((result) => result.status === "fulfilled" ? result.value : "").filter((snippet) => snippet.trim());
6061
+ if (elementSnippets.length === 0) {
6062
+ return "";
6063
+ }
6064
+ return elementSnippets.join("\n\n");
6065
+ };
6066
+
6067
+ // src/agent.ts
6068
+ var createAgentManager = (agentOptions) => {
6069
+ const [sessions, setSessions] = createSignal(/* @__PURE__ */ new Map());
6070
+ const abortControllers = /* @__PURE__ */ new Map();
6071
+ const sessionElements = /* @__PURE__ */ new Map();
6072
+ const isProcessing = () => sessions().size > 0;
6073
+ const executeSessionStream = async (session, streamIterator) => {
6074
+ const storage = agentOptions?.storage;
6075
+ let didComplete = false;
6076
+ let wasAborted = false;
6077
+ let hadError = false;
6078
+ try {
6079
+ for await (const status of streamIterator) {
6080
+ const currentSessions = sessions();
6081
+ const currentSession = currentSessions.get(session.id);
6082
+ if (!currentSession) break;
6083
+ const updatedSession = updateSession(currentSession, { lastStatus: status }, storage);
6084
+ setSessions((prev) => new Map(prev).set(session.id, updatedSession));
6085
+ agentOptions?.onStatus?.(status, updatedSession);
6086
+ }
6087
+ didComplete = true;
6088
+ const finalSessions = sessions();
6089
+ const finalSession = finalSessions.get(session.id);
6090
+ if (finalSession) {
6091
+ const completedSession = updateSession(finalSession, { isStreaming: false }, storage);
6092
+ setSessions((prev) => new Map(prev).set(session.id, completedSession));
6093
+ agentOptions?.onComplete?.(completedSession);
6094
+ }
6095
+ } catch (error) {
6096
+ const currentSessions = sessions();
6097
+ const currentSession = currentSessions.get(session.id);
6098
+ if (error instanceof Error && error.name === "AbortError") {
6099
+ wasAborted = true;
6100
+ if (currentSession) {
6101
+ const element = sessionElements.get(session.id);
6102
+ agentOptions?.onAbort?.(currentSession, element);
6103
+ }
6104
+ } else {
6105
+ hadError = true;
6106
+ if (currentSession) {
6107
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
6108
+ const errorSession = updateSession(currentSession, {
6109
+ lastStatus: `Error: ${errorMessage}`,
6110
+ isStreaming: false
6111
+ }, storage);
6112
+ setSessions((prev) => new Map(prev).set(session.id, errorSession));
6113
+ if (error instanceof Error) {
6114
+ agentOptions?.onError?.(error, errorSession);
6115
+ }
6116
+ }
6117
+ }
6118
+ } finally {
6119
+ abortControllers.delete(session.id);
6120
+ const removeSession = () => {
6121
+ sessionElements.delete(session.id);
6122
+ clearSessionById(session.id, storage);
6123
+ setSessions((prev) => {
6124
+ const next = new Map(prev);
6125
+ next.delete(session.id);
6126
+ return next;
6127
+ });
6128
+ };
6129
+ if (wasAborted) {
6130
+ removeSession();
6131
+ } else if (didComplete || hadError) {
6132
+ setTimeout(removeSession, 1500);
6133
+ }
6134
+ }
6135
+ };
6136
+ const tryReacquireElement = (session) => {
6137
+ const { selectionBounds, tagName } = session;
6138
+ if (!selectionBounds) return void 0;
6139
+ const centerX = selectionBounds.x + selectionBounds.width / 2;
6140
+ const centerY = selectionBounds.y + selectionBounds.height / 2;
6141
+ const element = document.elementFromPoint(centerX, centerY);
6142
+ if (!element) return void 0;
6143
+ if (tagName && element.tagName.toLowerCase() !== tagName) {
6144
+ return void 0;
6145
+ }
6146
+ return element;
6147
+ };
6148
+ const tryResumeSessions = () => {
6149
+ const storage = agentOptions?.storage;
6150
+ const existingSessions = loadSessions(storage);
6151
+ const streamingSessions = Array.from(existingSessions.values()).filter(
6152
+ (session) => session.isStreaming
6153
+ );
6154
+ if (streamingSessions.length === 0) {
6155
+ clearSessions(storage);
6156
+ return;
6157
+ }
6158
+ if (!agentOptions?.provider?.supportsResume || !agentOptions.provider.resume) {
6159
+ clearSessions(storage);
6160
+ return;
6161
+ }
6162
+ const streamingSessionsMap = new Map(
6163
+ streamingSessions.map((session) => [session.id, session])
6164
+ );
6165
+ setSessions(streamingSessionsMap);
6166
+ saveSessions(streamingSessionsMap, storage);
6167
+ for (const existingSession of streamingSessions) {
6168
+ const reacquiredElement = tryReacquireElement(existingSession);
6169
+ if (reacquiredElement) {
6170
+ sessionElements.set(existingSession.id, reacquiredElement);
6171
+ }
6172
+ const sessionWithResumeStatus = {
6173
+ ...existingSession,
6174
+ lastStatus: existingSession.lastStatus || "Resuming...",
6175
+ position: existingSession.position ?? { x: window.innerWidth / 2, y: window.innerHeight / 2 }
6176
+ };
6177
+ setSessions((prev) => new Map(prev).set(existingSession.id, sessionWithResumeStatus));
6178
+ agentOptions?.onResume?.(sessionWithResumeStatus);
6179
+ const abortController = new AbortController();
6180
+ abortControllers.set(existingSession.id, abortController);
6181
+ const streamIterator = agentOptions.provider.resume(existingSession.id, abortController.signal);
6182
+ void executeSessionStream(existingSession, streamIterator);
6183
+ }
6184
+ };
6185
+ const startSession = async (params) => {
6186
+ const { element, prompt, position, selectionBounds } = params;
6187
+ const storage = agentOptions?.storage;
6188
+ if (!agentOptions?.provider) {
6189
+ return;
6190
+ }
6191
+ const elements = [element];
6192
+ const content = await generateSnippet(elements);
6193
+ const context = { content, prompt, options: agentOptions?.getOptions?.() };
6194
+ const tagName = (element.tagName || "").toLowerCase() || void 0;
6195
+ const session = createSession(context, position, selectionBounds, tagName);
6196
+ session.lastStatus = "Please wait\u2026";
6197
+ sessionElements.set(session.id, element);
6198
+ setSessions((prev) => new Map(prev).set(session.id, session));
6199
+ saveSessionById(session, storage);
6200
+ agentOptions.onStart?.(session);
6201
+ const abortController = new AbortController();
6202
+ abortControllers.set(session.id, abortController);
6203
+ const streamIterator = agentOptions.provider.send(context, abortController.signal);
6204
+ void executeSessionStream(session, streamIterator);
6205
+ };
6206
+ const abortSession = (sessionId) => {
6207
+ const controller = abortControllers.get(sessionId);
6208
+ if (controller) {
6209
+ controller.abort();
6210
+ }
6211
+ };
6212
+ const abortAllSessions = () => {
6213
+ abortControllers.forEach((controller) => controller.abort());
6214
+ abortControllers.clear();
6215
+ setSessions(/* @__PURE__ */ new Map());
6216
+ clearSessions(agentOptions?.storage);
6217
+ };
6218
+ const updateSessionBoundsOnViewportChange = () => {
6219
+ const currentSessions = sessions();
6220
+ if (currentSessions.size === 0) return;
6221
+ const updatedSessions = new Map(currentSessions);
6222
+ let didUpdate = false;
6223
+ for (const [sessionId, session] of currentSessions) {
6224
+ let element = sessionElements.get(sessionId);
6225
+ if (!element || !document.contains(element)) {
6226
+ const reacquiredElement = tryReacquireElement(session);
6227
+ if (reacquiredElement) {
6228
+ sessionElements.set(sessionId, reacquiredElement);
6229
+ element = reacquiredElement;
6230
+ }
6231
+ }
6232
+ if (element && document.contains(element)) {
6233
+ const newBounds = createElementBounds(element);
6234
+ if (newBounds) {
6235
+ updatedSessions.set(sessionId, { ...session, selectionBounds: newBounds });
6236
+ didUpdate = true;
6237
+ }
6238
+ }
6239
+ }
6240
+ if (didUpdate) {
6241
+ setSessions(updatedSessions);
6242
+ }
6243
+ };
6244
+ const getSessionElement = (sessionId) => {
6245
+ return sessionElements.get(sessionId);
6246
+ };
6247
+ return {
6248
+ sessions,
6249
+ isProcessing,
6250
+ tryResumeSessions,
6251
+ startSession,
6252
+ abortSession,
6253
+ abortAllSessions,
6254
+ updateSessionBoundsOnViewportChange,
6255
+ getSessionElement
6256
+ };
6257
+ };
6258
+
5411
6259
  // src/core.tsx
5412
- var _tmpl$9 = /* @__PURE__ */ template(`<span class="font-mono tabular-nums align-middle">1 element`);
6260
+ var _tmpl$14 = /* @__PURE__ */ template(`<span class="tabular-nums align-middle">`);
5413
6261
  var _tmpl$23 = /* @__PURE__ */ template(`<span class="font-mono tabular-nums align-middle">&lt;<!>>`);
5414
- var _tmpl$33 = /* @__PURE__ */ template(`<span class="tabular-nums text-[10px] ml-1 align-middle"> in `);
6262
+ var _tmpl$33 = /* @__PURE__ */ template(`<span class="tabular-nums ml-1 align-middle"> in `);
5415
6263
  var hasInited = false;
5416
6264
  var getScriptOptions = () => {
5417
6265
  if (typeof window === "undefined") return null;
@@ -5461,9 +6309,8 @@ var init = (rawOptions) => {
5461
6309
  hasInited = true;
5462
6310
  const logIntro = () => {
5463
6311
  try {
5464
- const version = "0.0.54";
5465
- const logoSvg = `<svg width="294" height="294" viewBox="0 0 294 294" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_0_3)"><mask id="mask0_0_3" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="294" height="294"><path d="M294 0H0V294H294V0Z" fill="white"/></mask><g mask="url(#mask0_0_3)"><path d="M144.599 47.4924C169.712 27.3959 194.548 20.0265 212.132 30.1797C227.847 39.2555 234.881 60.3243 231.926 89.516C231.677 92.0069 231.328 94.5423 230.94 97.1058L228.526 110.14C228.517 110.136 228.505 110.132 228.495 110.127C228.486 110.165 228.479 110.203 228.468 110.24L216.255 105.741C216.256 105.736 216.248 105.728 216.248 105.723C207.915 103.125 199.421 101.075 190.82 99.5888L190.696 99.5588L173.526 97.2648L173.511 97.2631C173.492 97.236 173.467 97.2176 173.447 97.1905C163.862 96.2064 154.233 95.7166 144.599 95.7223C134.943 95.7162 125.295 96.219 115.693 97.2286C110.075 105.033 104.859 113.118 100.063 121.453C95.2426 129.798 90.8624 138.391 86.939 147.193C90.8624 155.996 95.2426 164.588 100.063 172.933C104.866 181.302 110.099 189.417 115.741 197.245C115.749 197.245 115.758 197.246 115.766 197.247L115.752 197.27L115.745 197.283L115.754 197.296L126.501 211.013L126.574 211.089C132.136 217.767 138.126 224.075 144.507 229.974L144.609 230.082L154.572 238.287C154.539 238.319 154.506 238.35 154.472 238.38C154.485 238.392 154.499 238.402 154.513 238.412L143.846 247.482L143.827 247.497C126.56 261.128 109.472 268.745 94.8019 268.745C88.5916 268.837 82.4687 267.272 77.0657 264.208C61.3496 255.132 54.3164 234.062 57.2707 204.871C57.528 202.307 57.8806 199.694 58.2904 197.054C28.3363 185.327 9.52301 167.51 9.52301 147.193C9.52301 129.042 24.2476 112.396 50.9901 100.375C53.3443 99.3163 55.7938 98.3058 58.2904 97.3526C57.8806 94.7023 57.528 92.0803 57.2707 89.516C54.3164 60.3243 61.3496 39.2555 77.0657 30.1797C94.6494 20.0265 119.486 27.3959 144.599 47.4924ZM70.6423 201.315C70.423 202.955 70.2229 204.566 70.0704 206.168C67.6686 229.567 72.5478 246.628 83.3615 252.988L83.5176 253.062C95.0399 259.717 114.015 254.426 134.782 238.38C125.298 229.45 116.594 219.725 108.764 209.314C95.8516 207.742 83.0977 205.066 70.6423 201.315ZM80.3534 163.438C77.34 171.677 74.8666 180.104 72.9484 188.664C81.1787 191.224 89.5657 193.247 98.0572 194.724L98.4618 194.813C95.2115 189.865 92.0191 184.66 88.9311 179.378C85.8433 174.097 83.003 168.768 80.3534 163.438ZM60.759 110.203C59.234 110.839 57.7378 111.475 56.27 112.11C34.7788 121.806 22.3891 134.591 22.3891 147.193C22.3891 160.493 36.4657 174.297 60.7494 184.26C63.7439 171.581 67.8124 159.182 72.9104 147.193C67.822 135.23 63.7566 122.855 60.759 110.203ZM98.4137 99.6404C89.8078 101.145 81.3075 103.206 72.9676 105.809C74.854 114.203 77.2741 122.468 80.2132 130.554L80.3059 130.939C82.9938 125.6 85.8049 120.338 88.8834 115.008C91.9618 109.679 95.1544 104.569 98.4137 99.6404ZM94.9258 38.5215C90.9331 38.4284 86.9866 39.3955 83.4891 41.3243C72.6291 47.6015 67.6975 64.5954 70.0424 87.9446L70.0416 88.2194C70.194 89.8208 70.3941 91.4325 70.6134 93.0624C83.0737 89.3364 95.8263 86.6703 108.736 85.0924C116.57 74.6779 125.28 64.9532 134.773 56.0249C119.877 44.5087 105.895 38.5215 94.9258 38.5215ZM205.737 41.3148C202.268 39.398 198.355 38.4308 194.394 38.5099L194.29 38.512C183.321 38.512 169.34 44.4991 154.444 56.0153C163.93 64.9374 172.634 74.6557 180.462 85.064C193.375 86.6345 206.128 89.3102 218.584 93.0624C218.812 91.4325 219.003 89.8118 219.165 88.2098C221.548 64.7099 216.65 47.6164 205.737 41.3148ZM144.552 64.3097C138.104 70.2614 132.054 76.6306 126.443 83.3765C132.39 82.995 138.426 82.8046 144.552 82.8046C150.727 82.8046 156.778 83.0143 162.707 83.3765C157.08 76.6293 151.015 70.2596 144.552 64.3097Z" fill="white"/><path d="M144.598 47.4924C169.712 27.3959 194.547 20.0265 212.131 30.1797C227.847 39.2555 234.88 60.3243 231.926 89.516C231.677 92.0069 231.327 94.5423 230.941 97.1058L228.526 110.14L228.496 110.127C228.487 110.165 228.478 110.203 228.469 110.24L216.255 105.741L216.249 105.723C207.916 103.125 199.42 101.075 190.82 99.5888L190.696 99.5588L173.525 97.2648L173.511 97.263C173.492 97.236 173.468 97.2176 173.447 97.1905C163.863 96.2064 154.234 95.7166 144.598 95.7223C134.943 95.7162 125.295 96.219 115.693 97.2286C110.075 105.033 104.859 113.118 100.063 121.453C95.2426 129.798 90.8622 138.391 86.939 147.193C90.8622 155.996 95.2426 164.588 100.063 172.933C104.866 181.302 110.099 189.417 115.741 197.245L115.766 197.247L115.752 197.27L115.745 197.283L115.754 197.296L126.501 211.013L126.574 211.089C132.136 217.767 138.126 224.075 144.506 229.974L144.61 230.082L154.572 238.287C154.539 238.319 154.506 238.35 154.473 238.38L154.512 238.412L143.847 247.482L143.827 247.497C126.56 261.13 109.472 268.745 94.8018 268.745C88.5915 268.837 82.4687 267.272 77.0657 264.208C61.3496 255.132 54.3162 234.062 57.2707 204.871C57.528 202.307 57.8806 199.694 58.2904 197.054C28.3362 185.327 9.52298 167.51 9.52298 147.193C9.52298 129.042 24.2476 112.396 50.9901 100.375C53.3443 99.3163 55.7938 98.3058 58.2904 97.3526C57.8806 94.7023 57.528 92.0803 57.2707 89.516C54.3162 60.3243 61.3496 39.2555 77.0657 30.1797C94.6493 20.0265 119.486 27.3959 144.598 47.4924ZM70.6422 201.315C70.423 202.955 70.2229 204.566 70.0704 206.168C67.6686 229.567 72.5478 246.628 83.3615 252.988L83.5175 253.062C95.0399 259.717 114.015 254.426 134.782 238.38C125.298 229.45 116.594 219.725 108.764 209.314C95.8515 207.742 83.0977 205.066 70.6422 201.315ZM80.3534 163.438C77.34 171.677 74.8666 180.104 72.9484 188.664C81.1786 191.224 89.5657 193.247 98.0572 194.724L98.4618 194.813C95.2115 189.865 92.0191 184.66 88.931 179.378C85.8433 174.097 83.003 168.768 80.3534 163.438ZM60.7589 110.203C59.234 110.839 57.7378 111.475 56.2699 112.11C34.7788 121.806 22.3891 134.591 22.3891 147.193C22.3891 160.493 36.4657 174.297 60.7494 184.26C63.7439 171.581 67.8124 159.182 72.9103 147.193C67.822 135.23 63.7566 122.855 60.7589 110.203ZM98.4137 99.6404C89.8078 101.145 81.3075 103.206 72.9676 105.809C74.8539 114.203 77.2741 122.468 80.2132 130.554L80.3059 130.939C82.9938 125.6 85.8049 120.338 88.8834 115.008C91.9618 109.679 95.1544 104.569 98.4137 99.6404ZM94.9258 38.5215C90.9331 38.4284 86.9866 39.3955 83.4891 41.3243C72.629 47.6015 67.6975 64.5954 70.0424 87.9446L70.0415 88.2194C70.194 89.8208 70.3941 91.4325 70.6134 93.0624C83.0737 89.3364 95.8262 86.6703 108.736 85.0924C116.57 74.6779 125.28 64.9532 134.772 56.0249C119.877 44.5087 105.895 38.5215 94.9258 38.5215ZM205.737 41.3148C202.268 39.398 198.355 38.4308 194.394 38.5099L194.291 38.512C183.321 38.512 169.34 44.4991 154.443 56.0153C163.929 64.9374 172.634 74.6557 180.462 85.064C193.374 86.6345 206.129 89.3102 218.584 93.0624C218.813 91.4325 219.003 89.8118 219.166 88.2098C221.548 64.7099 216.65 47.6164 205.737 41.3148ZM144.551 64.3097C138.103 70.2614 132.055 76.6306 126.443 83.3765C132.389 82.995 138.427 82.8046 144.551 82.8046C150.727 82.8046 156.779 83.0143 162.707 83.3765C157.079 76.6293 151.015 70.2596 144.551 64.3097Z" fill="#FF40E0"/></g><mask id="mask1_0_3" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="102" y="84" width="161" height="162"><path d="M235.282 84.827L102.261 112.259L129.693 245.28L262.714 217.848L235.282 84.827Z" fill="white"/></mask><g mask="url(#mask1_0_3)"><path d="M136.863 129.916L213.258 141.224C220.669 142.322 222.495 152.179 215.967 155.856L187.592 171.843L184.135 204.227C183.339 211.678 173.564 213.901 169.624 207.526L129.021 141.831C125.503 136.14 130.245 128.936 136.863 129.916Z" fill="#FF40E0" stroke="#FF40E0" stroke-width="0.817337" stroke-linecap="round" stroke-linejoin="round"/></g></g><defs><clipPath id="clip0_0_3"><rect width="294" height="294" fill="white"/></clipPath></defs></svg>`;
5466
- const logoDataUri = `data:image/svg+xml;base64,${btoa(logoSvg)}`;
6312
+ const version = "0.0.55";
6313
+ const logoDataUri = `data:image/svg+xml;base64,${btoa(LOGO_SVG)}`;
5467
6314
  console.log(`%cReact Grab${version ? ` v${version}` : ""}%c
5468
6315
  https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid #d75fcb; padding: 4px 4px 4px 24px; border-radius: 4px; background-image: url("${logoDataUri}"); background-size: 16px 16px; background-repeat: no-repeat; background-position: 4px center; display: inline-block; margin-bottom: 4px;`, "");
5469
6316
  if (navigator.onLine && version) {
@@ -5481,9 +6328,7 @@ https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid
5481
6328
  } catch {
5482
6329
  }
5483
6330
  };
5484
- if (options.log !== false) {
5485
- logIntro();
5486
- }
6331
+ logIntro();
5487
6332
  return createRoot((dispose2) => {
5488
6333
  const [theme, setTheme] = createSignal(initialTheme);
5489
6334
  const [isHoldingKeys, setIsHoldingKeys] = createSignal(false);
@@ -5493,32 +6338,45 @@ https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid
5493
6338
  const [dragStartX, setDragStartX] = createSignal(OFFSCREEN_POSITION);
5494
6339
  const [dragStartY, setDragStartY] = createSignal(OFFSCREEN_POSITION);
5495
6340
  const [isCopying, setIsCopying] = createSignal(false);
6341
+ const [selectionLabelStatus, setSelectionLabelStatus] = createSignal("idle");
6342
+ const [labelInstances, setLabelInstances] = createSignal([]);
5496
6343
  const [lastGrabbedElement, setLastGrabbedElement] = createSignal(null);
5497
6344
  const [progressStartTime, setProgressStartTime] = createSignal(null);
5498
- const [progress, setProgress] = createSignal(0);
5499
6345
  const [grabbedBoxes, setGrabbedBoxes] = createSignal([]);
5500
6346
  const [successLabels, setSuccessLabels] = createSignal([]);
5501
6347
  const [isActivated, setIsActivated] = createSignal(false);
5502
6348
  const [isToggleMode, setIsToggleMode] = createSignal(false);
5503
- const [showProgressIndicator, setShowProgressIndicator] = createSignal(false);
5504
6349
  const [didJustDrag, setDidJustDrag] = createSignal(false);
5505
6350
  const [copyStartX, setCopyStartX] = createSignal(OFFSCREEN_POSITION);
5506
6351
  const [copyStartY, setCopyStartY] = createSignal(OFFSCREEN_POSITION);
5507
- const [mouseHasSettled, setMouseHasSettled] = createSignal(false);
5508
6352
  const [viewportVersion, setViewportVersion] = createSignal(0);
5509
6353
  const [isInputMode, setIsInputMode] = createSignal(false);
5510
6354
  const [inputText, setInputText] = createSignal("");
5511
6355
  const [isTouchMode, setIsTouchMode] = createSignal(false);
6356
+ const [selectionFilePath, setSelectionFilePath] = createSignal(void 0);
6357
+ const [selectionLineNumber, setSelectionLineNumber] = createSignal(void 0);
6358
+ const [isToggleFrozen, setIsToggleFrozen] = createSignal(false);
6359
+ const [isInputExpanded, setIsInputExpanded] = createSignal(false);
6360
+ const [frozenElement, setFrozenElement] = createSignal(null);
6361
+ const [nativeSelectionCursorX, setNativeSelectionCursorX] = createSignal(OFFSCREEN_POSITION);
6362
+ const [nativeSelectionCursorY, setNativeSelectionCursorY] = createSignal(OFFSCREEN_POSITION);
6363
+ const [hasNativeSelection, setHasNativeSelection] = createSignal(false);
6364
+ const [nativeSelectionElements, setNativeSelectionElements] = createSignal([]);
6365
+ const [nativeSelectionTagName, setNativeSelectionTagName] = createSignal(void 0);
6366
+ const [nativeSelectionComponentName, setNativeSelectionComponentName] = createSignal(void 0);
6367
+ const nativeSelectionBounds = createMemo(() => {
6368
+ viewportVersion();
6369
+ const elements = nativeSelectionElements();
6370
+ if (elements.length === 0 || !elements[0]) return void 0;
6371
+ return createElementBounds(elements[0]);
6372
+ });
5512
6373
  let holdTimerId = null;
6374
+ let activationTimestamp = null;
5513
6375
  let progressAnimationId = null;
5514
- let progressDelayTimerId = null;
5515
6376
  let keydownSpamTimerId = null;
5516
- let mouseSettleTimerId = null;
5517
6377
  let autoScrollAnimationId = null;
5518
6378
  let previouslyFocusedElement = null;
5519
6379
  const isRendererActive = createMemo(() => isActivated() && !isCopying());
5520
- const hasValidMousePosition = createMemo(() => mouseX() > OFFSCREEN_POSITION && mouseY() > OFFSCREEN_POSITION);
5521
- const isTargetKeyCombination = (event) => (event.metaKey || event.ctrlKey) && isCLikeKey(event.key, event.code);
5522
6380
  const getAutoScrollDirection = (clientX, clientY) => {
5523
6381
  return {
5524
6382
  top: clientY < AUTO_SCROLL_EDGE_THRESHOLD_PX,
@@ -5557,9 +6415,6 @@ https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid
5557
6415
  setSuccessLabels((previousLabels) => previousLabels.filter((label) => label.id !== labelId));
5558
6416
  }, SUCCESS_LABEL_DURATION_MS);
5559
6417
  };
5560
- const wrapInSelectedElementTags = (context) => `<selected_element>
5561
- ${context}
5562
- </selected_element>`;
5563
6418
  const extractElementTagName = (element) => (element.tagName || "").toLowerCase();
5564
6419
  const extractElementTagNameForSuccess = (element) => {
5565
6420
  const tagName = extractElementTagName(element);
@@ -5575,16 +6430,49 @@ ${context}
5575
6430
  }
5576
6431
  }));
5577
6432
  };
5578
- const executeCopyOperation = async (positionX, positionY, operation) => {
6433
+ const createLabelInstance = (bounds, tagName, status, element) => {
6434
+ const instanceId = `label-${Date.now()}-${Math.random().toString(36).slice(2)}`;
6435
+ setLabelInstances((prev) => [...prev, {
6436
+ id: instanceId,
6437
+ bounds,
6438
+ tagName,
6439
+ status,
6440
+ createdAt: Date.now(),
6441
+ element
6442
+ }]);
6443
+ return instanceId;
6444
+ };
6445
+ const updateLabelInstance = (instanceId, status) => {
6446
+ setLabelInstances((prev) => prev.map((instance) => instance.id === instanceId ? {
6447
+ ...instance,
6448
+ status
6449
+ } : instance));
6450
+ };
6451
+ const removeLabelInstance = (instanceId) => {
6452
+ setLabelInstances((prev) => prev.filter((instance) => instance.id !== instanceId));
6453
+ };
6454
+ const executeCopyOperation = async (positionX, positionY, operation, bounds, tagName, element) => {
5579
6455
  setCopyStartX(positionX);
5580
6456
  setCopyStartY(positionY);
5581
6457
  setIsCopying(true);
5582
6458
  startProgressAnimation();
6459
+ const instanceId = bounds && tagName ? createLabelInstance(bounds, tagName, "copying", element) : null;
5583
6460
  await operation().finally(() => {
5584
6461
  setIsCopying(false);
5585
6462
  stopProgressAnimation();
6463
+ if (instanceId) {
6464
+ updateLabelInstance(instanceId, "copied");
6465
+ setTimeout(() => {
6466
+ updateLabelInstance(instanceId, "fading");
6467
+ setTimeout(() => {
6468
+ removeLabelInstance(instanceId);
6469
+ }, 350);
6470
+ }, COPIED_LABEL_DURATION_MS);
6471
+ }
5586
6472
  if (isToggleMode()) {
5587
- deactivateRenderer();
6473
+ setTimeout(() => {
6474
+ deactivateRenderer();
6475
+ }, COPIED_LABEL_DURATION_MS + 350);
5588
6476
  }
5589
6477
  });
5590
6478
  };
@@ -5622,30 +6510,18 @@ ${context}
5622
6510
  return didCopy;
5623
6511
  }
5624
6512
  try {
5625
- const elementSnippetResults = await Promise.allSettled(elements.map(async (element) => {
5626
- const htmlPreview = getHTMLPreview(element);
5627
- if (!isReactProject) {
5628
- return `## HTML Frame:
5629
- ${htmlPreview}`;
5630
- }
5631
- const stack = await getStack(element);
5632
- const formattedStack = formatStack(stack);
5633
- if (formattedStack) {
5634
- return `## HTML Frame:
5635
- ${htmlPreview}
5636
-
5637
- ## Code Location:
5638
- ${formattedStack}`;
6513
+ const elementSnippetResults = await Promise.allSettled(elements.map((element) => formatElementInfo(element)));
6514
+ const elementSnippets = [];
6515
+ for (const result of elementSnippetResults) {
6516
+ if (result.status === "fulfilled" && result.value.trim()) {
6517
+ elementSnippets.push(result.value);
5639
6518
  }
5640
- return `## HTML Frame:
5641
- ${htmlPreview}`;
5642
- }));
5643
- const elementSnippets = elementSnippetResults.map((result) => result.status === "fulfilled" ? result.value : "").filter((snippet) => snippet.trim());
6519
+ }
5644
6520
  if (elementSnippets.length > 0) {
5645
- const wrappedSnippets = elementSnippets.map((snippet) => wrapInSelectedElementTags(snippet)).join("\n\n");
6521
+ const combinedSnippets = elementSnippets.join("\n\n");
5646
6522
  const plainTextContent = extraPrompt ? `${extraPrompt}
5647
6523
 
5648
- ${wrappedSnippets}` : wrappedSnippets;
6524
+ ${combinedSnippets}` : combinedSnippets;
5649
6525
  copiedContent = plainTextContent;
5650
6526
  didCopy = await copyContent(plainTextContent);
5651
6527
  }
@@ -5710,6 +6586,12 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5710
6586
  if (!isRendererActive() || isDragging()) return null;
5711
6587
  return getElementAtPosition(mouseX(), mouseY());
5712
6588
  });
6589
+ createEffect(() => {
6590
+ const element = targetElement();
6591
+ if (element) {
6592
+ setFrozenElement(element);
6593
+ }
6594
+ });
5713
6595
  const selectionBounds = createMemo(() => {
5714
6596
  viewportVersion();
5715
6597
  const element = targetElement();
@@ -5766,7 +6648,14 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5766
6648
  });
5767
6649
  const labelContent = createMemo(() => {
5768
6650
  const element = targetElement();
5769
- if (!element) return _tmpl$9();
6651
+ const copying = isCopying();
6652
+ if (!element) {
6653
+ return (() => {
6654
+ var _el$ = _tmpl$14();
6655
+ insert(_el$, copying ? "Please wait\u2026" : "1 element");
6656
+ return _el$;
6657
+ })();
6658
+ }
5770
6659
  const tagName = extractElementTagName(element);
5771
6660
  const componentName = getNearestComponentName(element);
5772
6661
  if (tagName && componentName) {
@@ -5787,14 +6676,20 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5787
6676
  return _el$8;
5788
6677
  })();
5789
6678
  }
5790
- return _tmpl$9();
6679
+ return (() => {
6680
+ var _el$10 = _tmpl$14();
6681
+ insert(_el$10, copying ? "Please wait\u2026" : "1 element");
6682
+ return _el$10;
6683
+ })();
5791
6684
  });
5792
- const labelPosition = createMemo(() => isCopying() ? {
5793
- x: copyStartX(),
5794
- y: copyStartY()
5795
- } : {
5796
- x: mouseX(),
5797
- y: mouseY()
6685
+ const labelPosition = createMemo(() => {
6686
+ return isCopying() ? {
6687
+ x: copyStartX(),
6688
+ y: copyStartY()
6689
+ } : {
6690
+ x: mouseX(),
6691
+ y: mouseY()
6692
+ };
5798
6693
  });
5799
6694
  const progressPosition = createMemo(() => isCopying() ? {
5800
6695
  x: copyStartX(),
@@ -5811,6 +6706,26 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5811
6706
  options.onElementHover?.(currentElement);
5812
6707
  }
5813
6708
  }));
6709
+ createEffect(on(() => targetElement(), (element) => {
6710
+ const clearSource = () => {
6711
+ setSelectionFilePath(void 0);
6712
+ setSelectionLineNumber(void 0);
6713
+ };
6714
+ if (!element) {
6715
+ clearSource();
6716
+ return;
6717
+ }
6718
+ getStack(element).then((stack) => {
6719
+ for (const frame of stack) {
6720
+ if (frame.source && je2(frame.source.fileName)) {
6721
+ setSelectionFilePath(Q(frame.source.fileName));
6722
+ setSelectionLineNumber(frame.source.lineNumber);
6723
+ return;
6724
+ }
6725
+ }
6726
+ clearSource();
6727
+ }).catch(clearSource);
6728
+ }));
5814
6729
  createEffect(on(() => viewportVersion(), () => {
5815
6730
  const currentBoxes = grabbedBoxes();
5816
6731
  if (currentBoxes.length === 0) return;
@@ -5820,6 +6735,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5820
6735
  }));
5821
6736
  setGrabbedBoxes(updatedBoxes);
5822
6737
  }));
6738
+ createEffect(on(() => viewportVersion(), () => agentManager.updateSessionBoundsOnViewportChange()));
5823
6739
  createEffect(on(() => [isActivated(), isDragging(), isCopying(), isInputMode(), targetElement(), dragBounds()], ([active, dragging, copying, inputMode, target, drag]) => {
5824
6740
  options.onStateChange?.({
5825
6741
  isActive: active,
@@ -5862,23 +6778,47 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5862
6778
  content: contentString
5863
6779
  });
5864
6780
  }));
5865
- const startProgressAnimation = () => {
6781
+ let cursorStyleElement = null;
6782
+ const setCursorOverride = (cursor) => {
6783
+ if (cursor) {
6784
+ if (!cursorStyleElement) {
6785
+ cursorStyleElement = document.createElement("style");
6786
+ cursorStyleElement.setAttribute("data-react-grab-cursor", "");
6787
+ document.head.appendChild(cursorStyleElement);
6788
+ }
6789
+ cursorStyleElement.textContent = `* { cursor: ${cursor} !important; }`;
6790
+ } else if (cursorStyleElement) {
6791
+ cursorStyleElement.remove();
6792
+ cursorStyleElement = null;
6793
+ }
6794
+ };
6795
+ createEffect(on(() => [isActivated(), isCopying(), isDragging(), isInputMode(), targetElement()], ([activated, copying, dragging, inputMode, target]) => {
6796
+ if (copying) {
6797
+ setCursorOverride("progress");
6798
+ } else if (inputMode) {
6799
+ setCursorOverride(null);
6800
+ } else if (activated && dragging) {
6801
+ setCursorOverride("crosshair");
6802
+ } else if (activated && target) {
6803
+ setCursorOverride("copy");
6804
+ } else if (activated) {
6805
+ setCursorOverride("crosshair");
6806
+ } else {
6807
+ setCursorOverride(null);
6808
+ }
6809
+ }));
6810
+ const startProgressAnimation = (duration) => {
5866
6811
  const startTime = Date.now();
6812
+ const animationDuration = options.keyHoldDuration;
5867
6813
  setProgressStartTime(startTime);
5868
- setShowProgressIndicator(false);
5869
- progressDelayTimerId = window.setTimeout(() => {
5870
- setShowProgressIndicator(true);
5871
- progressDelayTimerId = null;
5872
- }, PROGRESS_INDICATOR_DELAY_MS);
5873
6814
  const animateProgress = () => {
5874
6815
  const currentStartTime = progressStartTime();
5875
6816
  if (currentStartTime === null) return;
5876
6817
  const elapsedTime = Date.now() - currentStartTime;
5877
- const normalizedTime = elapsedTime / options.keyHoldDuration;
6818
+ const normalizedTime = elapsedTime / animationDuration;
5878
6819
  const easedProgress = 1 - Math.exp(-normalizedTime);
5879
6820
  const maxProgressBeforeCompletion = 0.95;
5880
6821
  const currentProgress = isCopying() ? Math.min(easedProgress, maxProgressBeforeCompletion) : 1;
5881
- setProgress(currentProgress);
5882
6822
  if (currentProgress < 1) {
5883
6823
  progressAnimationId = requestAnimationFrame(animateProgress);
5884
6824
  }
@@ -5890,13 +6830,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5890
6830
  cancelAnimationFrame(progressAnimationId);
5891
6831
  progressAnimationId = null;
5892
6832
  }
5893
- if (progressDelayTimerId !== null) {
5894
- window.clearTimeout(progressDelayTimerId);
5895
- progressDelayTimerId = null;
5896
- }
5897
6833
  setProgressStartTime(null);
5898
- setProgress(1);
5899
- setShowProgressIndicator(false);
5900
6834
  };
5901
6835
  const startAutoScroll = () => {
5902
6836
  const scroll = () => {
@@ -5926,8 +6860,8 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5926
6860
  const activateRenderer = () => {
5927
6861
  stopProgressAnimation();
5928
6862
  previouslyFocusedElement = document.activeElement;
6863
+ activationTimestamp = Date.now();
5929
6864
  setIsActivated(true);
5930
- document.body.style.cursor = "crosshair";
5931
6865
  options.onActivate?.();
5932
6866
  };
5933
6867
  const deactivateRenderer = () => {
@@ -5936,61 +6870,151 @@ ${plainTextContentOnly}` : plainTextContentOnly;
5936
6870
  setIsActivated(false);
5937
6871
  setIsInputMode(false);
5938
6872
  setInputText("");
5939
- document.body.style.cursor = "";
6873
+ setIsToggleFrozen(false);
6874
+ setIsInputExpanded(false);
6875
+ setFrozenElement(null);
6876
+ setSelectionLabelStatus("idle");
5940
6877
  if (isDragging()) {
5941
6878
  setIsDragging(false);
5942
6879
  document.body.style.userSelect = "";
5943
6880
  }
5944
6881
  if (holdTimerId) window.clearTimeout(holdTimerId);
5945
6882
  if (keydownSpamTimerId) window.clearTimeout(keydownSpamTimerId);
5946
- if (mouseSettleTimerId) {
5947
- window.clearTimeout(mouseSettleTimerId);
5948
- mouseSettleTimerId = null;
5949
- }
5950
- setMouseHasSettled(false);
5951
6883
  stopAutoScroll();
5952
6884
  stopProgressAnimation();
6885
+ activationTimestamp = null;
5953
6886
  if (previouslyFocusedElement instanceof HTMLElement && document.contains(previouslyFocusedElement)) {
5954
6887
  previouslyFocusedElement.focus();
5955
6888
  }
5956
6889
  previouslyFocusedElement = null;
5957
6890
  options.onDeactivate?.();
5958
6891
  };
6892
+ const agentOptions = options.agent ? {
6893
+ ...options.agent,
6894
+ onAbort: (session, element) => {
6895
+ options.agent?.onAbort?.(session, element);
6896
+ if (element && document.contains(element)) {
6897
+ const rect = element.getBoundingClientRect();
6898
+ const centerX = rect.left + rect.width / 2;
6899
+ const centerY = rect.top + rect.height / 2;
6900
+ setMouseX(centerX);
6901
+ setMouseY(centerY);
6902
+ setFrozenElement(element);
6903
+ setInputText(session.context.prompt);
6904
+ setIsInputExpanded(true);
6905
+ setIsInputMode(true);
6906
+ setIsToggleMode(true);
6907
+ setIsToggleFrozen(true);
6908
+ if (!isActivated()) {
6909
+ activateRenderer();
6910
+ }
6911
+ }
6912
+ }
6913
+ } : void 0;
6914
+ const agentManager = createAgentManager(agentOptions);
5959
6915
  const handleInputChange = (value) => {
5960
6916
  setInputText(value);
5961
6917
  };
5962
6918
  const handleInputSubmit = () => {
5963
- if (!isInputMode()) return;
5964
- const element = targetElement();
5965
- const prompt = inputText().trim();
5966
- const currentX = mouseX();
5967
- const currentY = mouseY();
6919
+ const element = frozenElement() || targetElement();
6920
+ const prompt = isInputMode() ? inputText().trim() : "";
6921
+ if (!element) {
6922
+ deactivateRenderer();
6923
+ return;
6924
+ }
6925
+ const elementRect = element.getBoundingClientRect();
6926
+ const computedStyle = window.getComputedStyle(element);
6927
+ const bounds = {
6928
+ x: elementRect.left,
6929
+ y: elementRect.top,
6930
+ width: elementRect.width,
6931
+ height: elementRect.height,
6932
+ borderRadius: computedStyle.borderRadius || "0px",
6933
+ transform: stripTranslateFromTransform(element)
6934
+ };
6935
+ const currentX = bounds.x + bounds.width / 2;
6936
+ const currentY = bounds.y + bounds.height / 2;
6937
+ setMouseX(currentX);
6938
+ setMouseY(currentY);
6939
+ if (options.agent?.provider && prompt) {
6940
+ const positionX = mouseX();
6941
+ const positionY = mouseY();
6942
+ setInputText("");
6943
+ setIsInputMode(false);
6944
+ deactivateRenderer();
6945
+ void agentManager.startSession({
6946
+ element,
6947
+ prompt,
6948
+ position: {
6949
+ x: positionX,
6950
+ y: positionY
6951
+ },
6952
+ selectionBounds: bounds
6953
+ });
6954
+ return;
6955
+ }
5968
6956
  setIsInputMode(false);
5969
6957
  setInputText("");
5970
- if (element) {
5971
- void executeCopyOperation(currentX, currentY, () => copySingleElementToClipboard(element, prompt || void 0)).then(() => {
5972
- deactivateRenderer();
5973
- });
5974
- } else {
6958
+ const tagName = extractElementTagName(element);
6959
+ void executeCopyOperation(currentX, currentY, () => copySingleElementToClipboard(element, prompt || void 0), bounds, tagName, element).then(() => {
5975
6960
  deactivateRenderer();
5976
- }
6961
+ });
5977
6962
  };
5978
6963
  const handleInputCancel = () => {
5979
6964
  if (!isInputMode()) return;
5980
6965
  deactivateRenderer();
5981
6966
  };
6967
+ const handleToggleExpand = () => {
6968
+ setIsToggleMode(true);
6969
+ setIsToggleFrozen(true);
6970
+ setIsInputExpanded(true);
6971
+ setIsInputMode(true);
6972
+ };
6973
+ const handleNativeSelectionCopy = async () => {
6974
+ const elements = nativeSelectionElements();
6975
+ if (elements.length === 0) return;
6976
+ const currentX = nativeSelectionCursorX();
6977
+ const currentY = nativeSelectionCursorY();
6978
+ const bounds = nativeSelectionBounds();
6979
+ const tagName = nativeSelectionTagName();
6980
+ setHasNativeSelection(false);
6981
+ setNativeSelectionCursorX(OFFSCREEN_POSITION);
6982
+ setNativeSelectionCursorY(OFFSCREEN_POSITION);
6983
+ setNativeSelectionElements([]);
6984
+ setNativeSelectionTagName(void 0);
6985
+ setNativeSelectionComponentName(void 0);
6986
+ window.getSelection()?.removeAllRanges();
6987
+ if (elements.length === 1) {
6988
+ await executeCopyOperation(currentX, currentY, () => copySingleElementToClipboard(elements[0]), bounds, tagName);
6989
+ } else {
6990
+ await executeCopyOperation(currentX, currentY, () => copyMultipleElementsToClipboard(elements), bounds, tagName);
6991
+ }
6992
+ };
6993
+ const handleNativeSelectionEnter = () => {
6994
+ const elements = nativeSelectionElements();
6995
+ if (elements.length === 0) return;
6996
+ const bounds = nativeSelectionBounds();
6997
+ const currentX = bounds ? bounds.x + bounds.width / 2 : nativeSelectionCursorX();
6998
+ const currentY = bounds ? bounds.y + bounds.height / 2 : nativeSelectionCursorY();
6999
+ setHasNativeSelection(false);
7000
+ setNativeSelectionCursorX(OFFSCREEN_POSITION);
7001
+ setNativeSelectionCursorY(OFFSCREEN_POSITION);
7002
+ setNativeSelectionElements([]);
7003
+ setNativeSelectionTagName(void 0);
7004
+ setNativeSelectionComponentName(void 0);
7005
+ window.getSelection()?.removeAllRanges();
7006
+ setMouseX(currentX);
7007
+ setMouseY(currentY);
7008
+ setIsToggleMode(true);
7009
+ setIsToggleFrozen(true);
7010
+ setIsInputExpanded(true);
7011
+ activateRenderer();
7012
+ setIsInputMode(true);
7013
+ };
5982
7014
  const handlePointerMove = (clientX, clientY) => {
5983
- if (isInputMode()) return;
7015
+ if (isInputMode() || isToggleFrozen()) return;
5984
7016
  setMouseX(clientX);
5985
7017
  setMouseY(clientY);
5986
- if (mouseSettleTimerId !== null) {
5987
- window.clearTimeout(mouseSettleTimerId);
5988
- }
5989
- setMouseHasSettled(false);
5990
- mouseSettleTimerId = window.setTimeout(() => {
5991
- setMouseHasSettled(true);
5992
- mouseSettleTimerId = null;
5993
- }, 300);
5994
7018
  if (isDragging()) {
5995
7019
  const direction = getAutoScrollDirection(clientX, clientY);
5996
7020
  const isNearEdge = direction.top || direction.bottom || direction.left || direction.right;
@@ -6023,37 +7047,77 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6023
7047
  setDidJustDrag(true);
6024
7048
  const dragRect = calculateDragRectangle(clientX, clientY);
6025
7049
  const elements = getElementsInDrag(dragRect, isValidGrabbableElement);
6026
- if (elements.length > 0) {
6027
- options.onDragEnd?.(elements, dragRect);
6028
- void executeCopyOperation(clientX, clientY, () => copyMultipleElementsToClipboard(elements));
6029
- } else {
6030
- const fallbackElements = getElementsInDragLoose(dragRect, isValidGrabbableElement);
6031
- if (fallbackElements.length > 0) {
6032
- options.onDragEnd?.(fallbackElements, dragRect);
6033
- void executeCopyOperation(clientX, clientY, () => copyMultipleElementsToClipboard(fallbackElements));
7050
+ const selectedElements = elements.length > 0 ? elements : getElementsInDragLoose(dragRect, isValidGrabbableElement);
7051
+ if (selectedElements.length > 0) {
7052
+ options.onDragEnd?.(selectedElements, dragRect);
7053
+ const firstElement = selectedElements[0];
7054
+ const firstElementRect = firstElement.getBoundingClientRect();
7055
+ const bounds = {
7056
+ x: firstElementRect.left,
7057
+ y: firstElementRect.top,
7058
+ width: firstElementRect.width,
7059
+ height: firstElementRect.height,
7060
+ borderRadius: "0px",
7061
+ transform: stripTranslateFromTransform(firstElement)
7062
+ };
7063
+ const tagName = extractElementTagName(firstElement);
7064
+ if (options.agent?.provider) {
7065
+ const centerX = bounds.x + bounds.width / 2;
7066
+ const centerY = bounds.y + bounds.height / 2;
7067
+ setMouseX(centerX);
7068
+ setMouseY(centerY);
7069
+ setFrozenElement(firstElement);
7070
+ setIsToggleMode(true);
7071
+ setIsToggleFrozen(true);
7072
+ setIsInputExpanded(true);
7073
+ setIsInputMode(true);
7074
+ } else {
7075
+ void executeCopyOperation(clientX, clientY, () => copyMultipleElementsToClipboard(selectedElements), bounds, tagName, firstElement);
6034
7076
  }
6035
7077
  }
6036
7078
  } else {
6037
7079
  const element = getElementAtPosition(clientX, clientY);
6038
7080
  if (!element) return;
6039
7081
  setLastGrabbedElement(element);
6040
- void executeCopyOperation(clientX, clientY, () => copySingleElementToClipboard(element));
7082
+ const elementRect = element.getBoundingClientRect();
7083
+ const computedStyle = window.getComputedStyle(element);
7084
+ const bounds = {
7085
+ x: elementRect.left,
7086
+ y: elementRect.top,
7087
+ width: elementRect.width,
7088
+ height: elementRect.height,
7089
+ borderRadius: computedStyle.borderRadius || "0px",
7090
+ transform: stripTranslateFromTransform(element)
7091
+ };
7092
+ const tagName = extractElementTagName(element);
7093
+ void executeCopyOperation(clientX, clientY, () => copySingleElementToClipboard(element), bounds, tagName, element);
6041
7094
  }
6042
7095
  };
6043
7096
  const abortController = new AbortController();
6044
7097
  const eventListenerSignal = abortController.signal;
6045
7098
  window.addEventListener("keydown", (event) => {
6046
- if (event.key === "Escape" && isHoldingKeys()) {
6047
- if (isInputMode()) {
6048
- return;
7099
+ if (isInputMode() || isEventFromOverlay(event, "data-react-grab-ignore-events")) {
7100
+ if (event.key === "Escape" && agentManager.isProcessing()) {
7101
+ agentManager.abortAllSessions();
6049
7102
  }
6050
- deactivateRenderer();
6051
7103
  return;
6052
7104
  }
7105
+ if (event.key === "Escape") {
7106
+ if (agentManager.isProcessing()) {
7107
+ agentManager.abortAllSessions();
7108
+ return;
7109
+ }
7110
+ if (isHoldingKeys()) {
7111
+ deactivateRenderer();
7112
+ return;
7113
+ }
7114
+ }
6053
7115
  if (event.key === "Enter" && isHoldingKeys() && !isInputMode()) {
6054
7116
  event.preventDefault();
6055
7117
  event.stopPropagation();
6056
7118
  setIsToggleMode(true);
7119
+ setIsToggleFrozen(true);
7120
+ setIsInputExpanded(true);
6057
7121
  if (keydownSpamTimerId !== null) {
6058
7122
  window.clearTimeout(keydownSpamTimerId);
6059
7123
  keydownSpamTimerId = null;
@@ -6065,15 +7129,42 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6065
7129
  setIsInputMode(true);
6066
7130
  return;
6067
7131
  }
7132
+ if (event.key.toLowerCase() === "o" && !isInputMode()) {
7133
+ if (isActivated() && (event.metaKey || event.ctrlKey)) {
7134
+ const filePath = selectionFilePath();
7135
+ const lineNumber = selectionLineNumber();
7136
+ if (filePath) {
7137
+ event.preventDefault();
7138
+ event.stopPropagation();
7139
+ if (options.onOpenFile) {
7140
+ options.onOpenFile(filePath, lineNumber);
7141
+ } else {
7142
+ const url = buildOpenFileUrl(filePath, lineNumber);
7143
+ window.open(url, "_blank");
7144
+ }
7145
+ }
7146
+ return;
7147
+ }
7148
+ }
6068
7149
  if (!options.allowActivationInsideInput && isKeyboardEventTriggeredByInput(event)) {
6069
7150
  return;
6070
7151
  }
6071
- if (!isTargetKeyCombination(event)) return;
6072
- if (isActivated() || isHoldingKeys()) {
7152
+ if (!isTargetKeyCombination(event, options)) {
7153
+ if (isActivated() && !isToggleMode() && (event.metaKey || event.ctrlKey)) {
7154
+ if (!MODIFIER_KEYS.includes(event.key) && event.key !== "Enter") {
7155
+ deactivateRenderer();
7156
+ }
7157
+ }
7158
+ if (event.key !== "Enter") {
7159
+ return;
7160
+ }
7161
+ }
7162
+ if ((isActivated() || isHoldingKeys()) && !isInputMode()) {
6073
7163
  event.preventDefault();
6074
7164
  }
6075
7165
  if (isActivated()) {
6076
7166
  if (isToggleMode()) return;
7167
+ if (event.repeat) return;
6077
7168
  if (keydownSpamTimerId !== null) {
6078
7169
  window.clearTimeout(keydownSpamTimerId);
6079
7170
  }
@@ -6098,9 +7189,44 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6098
7189
  });
6099
7190
  window.addEventListener("keyup", (event) => {
6100
7191
  if (!isHoldingKeys() && !isActivated()) return;
6101
- const isReleasingModifier = !event.metaKey && !event.ctrlKey;
6102
- const isReleasingC = isCLikeKey(event.key, event.code);
6103
- if (isReleasingC || isReleasingModifier) {
7192
+ if (isInputMode()) return;
7193
+ const hasCustomShortcut = Boolean(options.activationShortcut || options.activationKey);
7194
+ const getRequiredModifiers = () => {
7195
+ if (options.activationKey) {
7196
+ const {
7197
+ metaKey,
7198
+ ctrlKey,
7199
+ shiftKey,
7200
+ altKey
7201
+ } = options.activationKey;
7202
+ return {
7203
+ metaKey: !!metaKey,
7204
+ ctrlKey: !!ctrlKey,
7205
+ shiftKey: !!shiftKey,
7206
+ altKey: !!altKey
7207
+ };
7208
+ }
7209
+ return {
7210
+ metaKey: true,
7211
+ ctrlKey: true,
7212
+ shiftKey: false,
7213
+ altKey: false
7214
+ };
7215
+ };
7216
+ const requiredModifiers = getRequiredModifiers();
7217
+ const isReleasingModifier = requiredModifiers.metaKey || requiredModifiers.ctrlKey ? !event.metaKey && !event.ctrlKey : requiredModifiers.shiftKey && !event.shiftKey || requiredModifiers.altKey && !event.altKey;
7218
+ const isReleasingActivationKey = options.activationShortcut ? !options.activationShortcut(event) : options.activationKey ? options.activationKey.key ? event.key.toLowerCase() === options.activationKey.key.toLowerCase() || keyMatchesCode(options.activationKey.key, event.code) : false : isCLikeKey(event.key, event.code);
7219
+ if (isActivated()) {
7220
+ if (isReleasingModifier) {
7221
+ if (isToggleMode()) return;
7222
+ deactivateRenderer();
7223
+ } else if (!hasCustomShortcut && isReleasingActivationKey && keydownSpamTimerId !== null) {
7224
+ window.clearTimeout(keydownSpamTimerId);
7225
+ keydownSpamTimerId = null;
7226
+ }
7227
+ return;
7228
+ }
7229
+ if (isReleasingActivationKey || isReleasingModifier) {
6104
7230
  if (isToggleMode()) return;
6105
7231
  deactivateRenderer();
6106
7232
  }
@@ -6110,17 +7236,15 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6110
7236
  });
6111
7237
  window.addEventListener("mousemove", (event) => {
6112
7238
  setIsTouchMode(false);
7239
+ if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
6113
7240
  handlePointerMove(event.clientX, event.clientY);
6114
7241
  }, {
6115
7242
  signal: eventListenerSignal
6116
7243
  });
6117
7244
  window.addEventListener("mousedown", (event) => {
7245
+ if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
6118
7246
  if (isInputMode()) {
6119
- const target = event.target;
6120
- const isClickingInput = target.closest("[data-react-grab-input]");
6121
- if (!isClickingInput) {
6122
- handleInputCancel();
6123
- }
7247
+ handleInputCancel();
6124
7248
  return;
6125
7249
  }
6126
7250
  const didHandle = handlePointerDown(event.clientX, event.clientY);
@@ -6133,6 +7257,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6133
7257
  });
6134
7258
  window.addEventListener("pointerdown", (event) => {
6135
7259
  if (!isRendererActive() || isCopying() || isInputMode()) return;
7260
+ if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
6136
7261
  event.stopPropagation();
6137
7262
  }, {
6138
7263
  signal: eventListenerSignal,
@@ -6146,6 +7271,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6146
7271
  window.addEventListener("touchmove", (event) => {
6147
7272
  if (event.touches.length === 0) return;
6148
7273
  setIsTouchMode(true);
7274
+ if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
6149
7275
  handlePointerMove(event.touches[0].clientX, event.touches[0].clientY);
6150
7276
  }, {
6151
7277
  signal: eventListenerSignal,
@@ -6154,12 +7280,9 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6154
7280
  window.addEventListener("touchstart", (event) => {
6155
7281
  if (event.touches.length === 0) return;
6156
7282
  setIsTouchMode(true);
7283
+ if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
6157
7284
  if (isInputMode()) {
6158
- const target = event.target;
6159
- const isClickingInput = target.closest("[data-react-grab-input]");
6160
- if (!isClickingInput) {
6161
- handleInputCancel();
6162
- }
7285
+ handleInputCancel();
6163
7286
  return;
6164
7287
  }
6165
7288
  const didHandle = handlePointerDown(event.touches[0].clientX, event.touches[0].clientY);
@@ -6177,6 +7300,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6177
7300
  signal: eventListenerSignal
6178
7301
  });
6179
7302
  window.addEventListener("click", (event) => {
7303
+ if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
6180
7304
  if (isRendererActive() || isCopying() || didJustDrag()) {
6181
7305
  event.preventDefault();
6182
7306
  event.stopPropagation();
@@ -6199,6 +7323,9 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6199
7323
  document.addEventListener("visibilitychange", () => {
6200
7324
  if (document.hidden) {
6201
7325
  setGrabbedBoxes([]);
7326
+ if (isActivated() && !isInputMode() && activationTimestamp !== null && Date.now() - activationTimestamp > BLUR_DEACTIVATION_THRESHOLD_MS) {
7327
+ deactivateRenderer();
7328
+ }
6202
7329
  }
6203
7330
  }, {
6204
7331
  signal: eventListenerSignal
@@ -6215,6 +7342,9 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6215
7342
  signal: eventListenerSignal
6216
7343
  });
6217
7344
  document.addEventListener("copy", (event) => {
7345
+ if (isInputMode() || isEventFromOverlay(event, "data-react-grab-ignore-events")) {
7346
+ return;
7347
+ }
6218
7348
  if (isRendererActive() || isCopying()) {
6219
7349
  event.preventDefault();
6220
7350
  }
@@ -6222,18 +7352,118 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6222
7352
  signal: eventListenerSignal,
6223
7353
  capture: true
6224
7354
  });
7355
+ let selectionDebounceTimerId = null;
7356
+ document.addEventListener("selectionchange", () => {
7357
+ if (isRendererActive()) return;
7358
+ if (selectionDebounceTimerId !== null) {
7359
+ window.clearTimeout(selectionDebounceTimerId);
7360
+ }
7361
+ setHasNativeSelection(false);
7362
+ const selection = window.getSelection();
7363
+ if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
7364
+ setNativeSelectionCursorX(OFFSCREEN_POSITION);
7365
+ setNativeSelectionCursorY(OFFSCREEN_POSITION);
7366
+ setNativeSelectionElements([]);
7367
+ setNativeSelectionTagName(void 0);
7368
+ setNativeSelectionComponentName(void 0);
7369
+ return;
7370
+ }
7371
+ selectionDebounceTimerId = window.setTimeout(() => {
7372
+ selectionDebounceTimerId = null;
7373
+ const currentSelection = window.getSelection();
7374
+ if (!currentSelection || currentSelection.isCollapsed || currentSelection.rangeCount === 0) {
7375
+ return;
7376
+ }
7377
+ const range = currentSelection.getRangeAt(0);
7378
+ const rangeRect = range.getBoundingClientRect();
7379
+ if (rangeRect.width === 0 && rangeRect.height === 0) {
7380
+ return;
7381
+ }
7382
+ const isBackward = (() => {
7383
+ if (!currentSelection.anchorNode || !currentSelection.focusNode) return false;
7384
+ const position = currentSelection.anchorNode.compareDocumentPosition(currentSelection.focusNode);
7385
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) return false;
7386
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) return true;
7387
+ return currentSelection.anchorOffset > currentSelection.focusOffset;
7388
+ })();
7389
+ const clientRects = range.getClientRects();
7390
+ if (clientRects.length === 0) {
7391
+ return;
7392
+ }
7393
+ const cursorRect = isBackward ? clientRects[0] : clientRects[clientRects.length - 1];
7394
+ const cursorX = isBackward ? cursorRect.left : cursorRect.right;
7395
+ const cursorY = cursorRect.top + cursorRect.height / 2;
7396
+ if (isSelectionInsideEditableElement(cursorX, cursorY)) {
7397
+ setNativeSelectionCursorX(OFFSCREEN_POSITION);
7398
+ setNativeSelectionCursorY(OFFSCREEN_POSITION);
7399
+ setNativeSelectionElements([]);
7400
+ setNativeSelectionTagName(void 0);
7401
+ setNativeSelectionComponentName(void 0);
7402
+ return;
7403
+ }
7404
+ setNativeSelectionCursorX(cursorX);
7405
+ setNativeSelectionCursorY(cursorY);
7406
+ const container = range.commonAncestorContainer;
7407
+ const element = container.nodeType === Node.ELEMENT_NODE ? container : container.parentElement;
7408
+ if (element && isValidGrabbableElement(element)) {
7409
+ setNativeSelectionElements([element]);
7410
+ setNativeSelectionTagName(extractElementTagName(element) || void 0);
7411
+ setNativeSelectionComponentName(getNearestComponentName(element) || void 0);
7412
+ setHasNativeSelection(true);
7413
+ } else {
7414
+ setNativeSelectionElements([]);
7415
+ setNativeSelectionTagName(void 0);
7416
+ setNativeSelectionComponentName(void 0);
7417
+ }
7418
+ }, 150);
7419
+ }, {
7420
+ signal: eventListenerSignal
7421
+ });
6225
7422
  onCleanup(() => {
6226
7423
  abortController.abort();
6227
7424
  if (holdTimerId) window.clearTimeout(holdTimerId);
6228
7425
  if (keydownSpamTimerId) window.clearTimeout(keydownSpamTimerId);
6229
- if (mouseSettleTimerId) window.clearTimeout(mouseSettleTimerId);
6230
7426
  stopAutoScroll();
6231
7427
  stopProgressAnimation();
6232
7428
  document.body.style.userSelect = "";
6233
- document.body.style.cursor = "";
7429
+ setCursorOverride(null);
6234
7430
  });
6235
7431
  const rendererRoot = mountRoot(styles_default);
6236
- const selectionVisible = createMemo(() => theme().selectionBox.enabled && isRendererActive() && !isDragging() && Boolean(targetElement()));
7432
+ const selectionVisible = createMemo(() => {
7433
+ if (!theme().selectionBox.enabled) return false;
7434
+ return isRendererActive() && !isDragging() && Boolean(targetElement());
7435
+ });
7436
+ const selectionTagName = createMemo(() => {
7437
+ const element = targetElement();
7438
+ if (!element) return void 0;
7439
+ return extractElementTagName(element) || void 0;
7440
+ });
7441
+ const selectionLabelVisible = createMemo(() => {
7442
+ if (!theme().elementLabel.enabled) return false;
7443
+ if (successLabels().length > 0) return false;
7444
+ return isRendererActive() && !isDragging() && Boolean(targetElement());
7445
+ });
7446
+ const computedLabelInstances = createMemo(() => {
7447
+ viewportVersion();
7448
+ return labelInstances().map((instance) => {
7449
+ if (!instance.element || !document.body.contains(instance.element)) {
7450
+ return instance;
7451
+ }
7452
+ const elementRect = instance.element.getBoundingClientRect();
7453
+ const computedStyle = window.getComputedStyle(instance.element);
7454
+ return {
7455
+ ...instance,
7456
+ bounds: {
7457
+ x: elementRect.left,
7458
+ y: elementRect.top,
7459
+ width: elementRect.width,
7460
+ height: elementRect.height,
7461
+ borderRadius: computedStyle.borderRadius || "0px",
7462
+ transform: stripTranslateFromTransform(instance.element)
7463
+ }
7464
+ };
7465
+ });
7466
+ });
6237
7467
  const dragVisible = createMemo(() => theme().dragBox.enabled && isRendererActive() && isDraggingBeyondThreshold());
6238
7468
  const labelVariant = createMemo(() => isCopying() ? "processing" : "hover");
6239
7469
  const labelVisible = createMemo(() => {
@@ -6243,11 +7473,8 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6243
7473
  if (successLabels().length > 0) return false;
6244
7474
  return isRendererActive() && !isDragging() && Boolean(targetElement());
6245
7475
  });
6246
- const progressVisible = createMemo(() => isCopying() && showProgressIndicator() && hasValidMousePosition());
6247
- const crosshairVisible = createMemo(() => theme().crosshair.enabled && isRendererActive() && !isDragging() && !isTouchMode());
6248
- const inputVisible = createMemo(() => theme().inputOverlay.enabled && isInputMode());
7476
+ const crosshairVisible = createMemo(() => theme().crosshair.enabled && isRendererActive() && !isDragging() && !isTouchMode() && !isToggleFrozen());
6249
7477
  const shouldShowGrabbedBoxes = createMemo(() => theme().grabbedBoxes.enabled);
6250
- const shouldShowSuccessLabels = createMemo(() => theme().successLabels.enabled);
6251
7478
  createEffect(on(theme, (currentTheme) => {
6252
7479
  if (currentTheme.hue !== 0) {
6253
7480
  rendererRoot.style.filter = `hue-rotate(${currentTheme.hue}deg)`;
@@ -6263,43 +7490,34 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6263
7490
  get selectionBounds() {
6264
7491
  return selectionBounds();
6265
7492
  },
6266
- get dragVisible() {
6267
- return dragVisible();
7493
+ get selectionFilePath() {
7494
+ return selectionFilePath();
6268
7495
  },
6269
- get dragBounds() {
6270
- return dragBounds();
7496
+ get selectionLineNumber() {
7497
+ return selectionLineNumber();
6271
7498
  },
6272
- get grabbedBoxes() {
6273
- return memo(() => !!shouldShowGrabbedBoxes())() ? grabbedBoxes() : [];
7499
+ get selectionTagName() {
7500
+ return selectionTagName();
6274
7501
  },
6275
- get successLabels() {
6276
- return memo(() => !!shouldShowSuccessLabels())() ? successLabels() : [];
7502
+ get selectionLabelVisible() {
7503
+ return selectionLabelVisible();
6277
7504
  },
6278
- get labelVariant() {
6279
- return labelVariant();
7505
+ get selectionLabelStatus() {
7506
+ return selectionLabelStatus();
6280
7507
  },
6281
- get labelContent() {
6282
- return labelContent();
7508
+ get labelInstances() {
7509
+ return computedLabelInstances();
6283
7510
  },
6284
- get labelX() {
6285
- return labelPosition().x;
7511
+ get dragVisible() {
7512
+ return dragVisible();
6286
7513
  },
6287
- get labelY() {
6288
- return labelPosition().y;
7514
+ get dragBounds() {
7515
+ return dragBounds();
6289
7516
  },
6290
- get labelVisible() {
6291
- return labelVisible();
7517
+ get grabbedBoxes() {
7518
+ return memo(() => !!shouldShowGrabbedBoxes())() ? grabbedBoxes() : [];
6292
7519
  },
6293
7520
  labelZIndex: Z_INDEX_LABEL,
6294
- get labelShowHint() {
6295
- return mouseHasSettled();
6296
- },
6297
- get progressVisible() {
6298
- return progressVisible();
6299
- },
6300
- get progress() {
6301
- return progress();
6302
- },
6303
7521
  get mouseX() {
6304
7522
  return progressPosition().x;
6305
7523
  },
@@ -6309,26 +7527,51 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6309
7527
  get crosshairVisible() {
6310
7528
  return crosshairVisible();
6311
7529
  },
6312
- get inputVisible() {
6313
- return inputVisible();
7530
+ get inputValue() {
7531
+ return inputText();
6314
7532
  },
6315
- get inputX() {
6316
- return mouseX();
7533
+ get isInputExpanded() {
7534
+ return isInputExpanded();
6317
7535
  },
6318
- get inputY() {
6319
- return mouseY();
7536
+ get hasAgent() {
7537
+ return Boolean(options.agent?.provider);
6320
7538
  },
6321
- get inputValue() {
6322
- return inputText();
7539
+ get agentSessions() {
7540
+ return agentManager.sessions();
6323
7541
  },
7542
+ onAbortSession: (sessionId) => agentManager.abortSession(sessionId),
6324
7543
  onInputChange: handleInputChange,
6325
- onInputSubmit: handleInputSubmit,
7544
+ onInputSubmit: () => void handleInputSubmit(),
6326
7545
  onInputCancel: handleInputCancel,
7546
+ onToggleExpand: handleToggleExpand,
7547
+ get nativeSelectionCursorVisible() {
7548
+ return hasNativeSelection();
7549
+ },
7550
+ get nativeSelectionCursorX() {
7551
+ return nativeSelectionCursorX();
7552
+ },
7553
+ get nativeSelectionCursorY() {
7554
+ return nativeSelectionCursorY();
7555
+ },
7556
+ get nativeSelectionTagName() {
7557
+ return nativeSelectionTagName();
7558
+ },
7559
+ get nativeSelectionComponentName() {
7560
+ return nativeSelectionComponentName();
7561
+ },
7562
+ get nativeSelectionBounds() {
7563
+ return nativeSelectionBounds();
7564
+ },
7565
+ onNativeSelectionCopy: () => void handleNativeSelectionCopy(),
7566
+ onNativeSelectionEnter: handleNativeSelectionEnter,
6327
7567
  get theme() {
6328
7568
  return theme();
6329
7569
  }
6330
7570
  }), rendererRoot);
6331
7571
  }
7572
+ if (options.agent?.provider) {
7573
+ agentManager.tryResumeSessions();
7574
+ }
6332
7575
  const copyElementAPI = async (elements) => {
6333
7576
  const elementsArray = Array.isArray(elements) ? elements : [elements];
6334
7577
  if (elementsArray.length === 0) return false;
@@ -6353,6 +7596,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6353
7596
  return {
6354
7597
  activate: () => {
6355
7598
  if (!isActivated()) {
7599
+ setIsToggleMode(true);
6356
7600
  activateRenderer();
6357
7601
  }
6358
7602
  },
@@ -6365,11 +7609,15 @@ ${plainTextContentOnly}` : plainTextContentOnly;
6365
7609
  if (isActivated()) {
6366
7610
  deactivateRenderer();
6367
7611
  } else {
7612
+ setIsToggleMode(true);
6368
7613
  activateRenderer();
6369
7614
  }
6370
7615
  },
6371
7616
  isActive: () => isActivated(),
6372
- dispose: dispose2,
7617
+ dispose: () => {
7618
+ hasInited = false;
7619
+ dispose2();
7620
+ },
6373
7621
  copyElement: copyElementAPI,
6374
7622
  getState: getStateAPI,
6375
7623
  updateTheme: (partialTheme) => {
@@ -6444,4 +7692,4 @@ bippy/dist/source.js:
6444
7692
  *)
6445
7693
  */
6446
7694
 
6447
- export { DEFAULT_THEME, Ee, formatStack, getFileName, getHTMLPreview, getNearestComponentName, getStack, init };
7695
+ export { DEFAULT_THEME, Ee, formatElementInfo, generateSnippet, getFileName, getNearestComponentName, getStack, init };