@embedpdf/utils 2.0.0 → 2.0.2

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),e=require("@embedpdf/utils"),i=t.defineComponent({__name:"counter-rotate-container",props:{rect:{},rotation:{}},setup(i){const n=i,a=t.computed(()=>e.getCounterRotation(n.rect,n.rotation)),s=t.computed(()=>({style:{position:"absolute",left:`${n.rect.origin.x}px`,top:`${n.rect.origin.y}px`,transform:a.value.matrix,transformOrigin:"0 0",width:`${a.value.width}px`,height:`${a.value.height}px`,pointerEvents:"none",zIndex:3},onPointerdown:t=>{t.stopPropagation(),t.preventDefault()},onTouchstart:t=>{t.stopPropagation(),t.preventDefault()}})),r=t.computed(()=>({origin:{x:n.rect.origin.x,y:n.rect.origin.y},size:{width:a.value.width,height:a.value.height}}));return(e,i)=>t.renderSlot(e.$slots,"default",{menuWrapperProps:s.value,matrix:a.value.matrix,rect:r.value})}});class n{constructor(t,e){this.config=t,this.onUpdate=e,this.state="idle",this.startPoint=null,this.startElement=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.currentVertices=[],this.currentVertices=t.vertices||[]}updateConfig(t){this.config={...this.config,...t},this.currentVertices=t.vertices||[]}startDrag(t,e){this.state="dragging",this.startPoint={x:t,y:e},this.startElement={...this.config.element},this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"move",changes:{rect:this.startElement}}})}startResize(t,e,i){this.state="resizing",this.activeHandle=t,this.startPoint={x:e,y:i},this.startElement={...this.config.element},this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"resize",changes:{rect:this.startElement},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio}}})}startVertexEdit(t,e,i){this.currentVertices=[...this.config.vertices??this.currentVertices],t<0||t>=this.currentVertices.length||(this.state="vertex-editing",this.activeVertexIndex=t,this.startPoint={x:e,y:i},this.startVertices=[...this.currentVertices],this.onUpdate({state:"start",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:t}}}))}move(t,e){if("idle"!==this.state&&this.startPoint)if("dragging"===this.state&&this.startElement){const i=this.calculateDelta(t,e),n=this.calculateDragPosition(i);this.currentPosition=n,this.onUpdate({state:"move",transformData:{type:"move",changes:{rect:n}}})}else if("resizing"===this.state&&this.activeHandle&&this.startElement){const i=this.calculateDelta(t,e),n=this.calculateResizePosition(i,this.activeHandle);this.currentPosition=n,this.onUpdate({state:"move",transformData:{type:"resize",changes:{rect:n},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio}}})}else if("vertex-editing"===this.state&&null!==this.activeVertexIndex){const i=this.calculateVertexPosition(t,e);this.currentVertices=i,this.onUpdate({state:"move",transformData:{type:"vertex-edit",changes:{vertices:i},metadata:{vertexIndex:this.activeVertexIndex}}})}}end(){if("idle"===this.state)return;const t=this.state,e=this.activeHandle,i=this.activeVertexIndex;if("vertex-editing"===t)this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.currentVertices},metadata:{vertexIndex:i||void 0}}});else{const i=this.getCurrentPosition();this.onUpdate({state:"end",transformData:{type:"dragging"===t?"move":"resize",changes:{rect:i},metadata:"dragging"===t?void 0:{handle:e||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}})}this.reset()}cancel(){"idle"!==this.state&&("vertex-editing"===this.state?this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:this.activeVertexIndex||void 0}}}):this.startElement&&this.onUpdate({state:"end",transformData:{type:"dragging"===this.state?"move":"resize",changes:{rect:this.startElement},metadata:"dragging"===this.state?void 0:{handle:this.activeHandle||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}}),this.reset())}reset(){this.state="idle",this.startPoint=null,this.startElement=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[]}getCurrentPosition(){return this.currentPosition||this.config.element}calculateDelta(t,e){if(!this.startPoint)return{x:0,y:0};const i={x:t-this.startPoint.x,y:e-this.startPoint.y};return this.transformDelta(i)}transformDelta(t){const{pageRotation:e=0,scale:i=1}=this.config,n=e*Math.PI/2,a=Math.cos(n),s=Math.sin(n),r=t.x/i,o=t.y/i;return{x:a*r+s*o,y:-s*r+a*o}}clampPoint(t){var e;const i=null==(e=this.config.constraints)?void 0:e.boundingBox;return i?{x:Math.max(0,Math.min(t.x,i.width)),y:Math.max(0,Math.min(t.y,i.height))}:t}calculateVertexPosition(t,e){if(null===this.activeVertexIndex)return this.startVertices;const i=this.calculateDelta(t,e),n=[...this.startVertices],a=n[this.activeVertexIndex],s={x:a.x+i.x,y:a.y+i.y};return n[this.activeVertexIndex]=this.clampPoint(s),n}calculateDragPosition(t){if(!this.startElement)return this.config.element;const e={origin:{x:this.startElement.origin.x+t.x,y:this.startElement.origin.y+t.y},size:{width:this.startElement.size.width,height:this.startElement.size.height}};return this.applyConstraints(e)}calculateResizePosition(t,e){var i;if(!this.startElement)return this.config.element;let{origin:{x:n,y:a},size:{width:s,height:r}}=this.startElement;switch(e){case"se":s+=t.x,r+=t.y;break;case"sw":n+=t.x,s-=t.x,r+=t.y;break;case"ne":s+=t.x,a+=t.y,r-=t.y;break;case"nw":n+=t.x,s-=t.x,a+=t.y,r-=t.y;break;case"n":a+=t.y,r-=t.y;break;case"s":r+=t.y;break;case"e":s+=t.x;break;case"w":n+=t.x,s-=t.x}if(this.config.maintainAspectRatio&&this.startElement){const t=this.startElement.size.width/this.startElement.size.height;if(["n","s","e","w"].includes(e))if("n"===e||"s"===e){const e=r*t,i=e-s;s=e,n-=i/2}else{const i=s/t,o=i-r;r=i,"w"===e&&(n=this.startElement.origin.x+this.startElement.size.width-s),a-=o/2}else{Math.abs(s-this.startElement.size.width)>Math.abs(r-this.startElement.size.height)?r=s/t:s=r*t,e.includes("w")&&(n=this.startElement.origin.x+this.startElement.size.width-s),e.includes("n")&&(a=this.startElement.origin.y+this.startElement.size.height-r)}}const o=null==(i=this.config.constraints)?void 0:i.boundingBox;if(o)switch(e){case"e":s=Math.min(s,o.width-n);break;case"s":r=Math.min(r,o.height-a);break;case"se":s=Math.min(s,o.width-n),r=Math.min(r,o.height-a);break;case"w":n<0&&(s+=n,n=0);break;case"n":a<0&&(r+=a,a=0);break;case"sw":n<0&&(s+=n,n=0),r=Math.min(r,o.height-a);break;case"nw":n<0&&(s+=n,n=0),a<0&&(r+=a,a=0);break;case"ne":s=Math.min(s,o.width-n),a<0&&(r+=a,a=0)}return this.applyConstraints({origin:{x:n,y:a},size:{width:s,height:r}})}applyConstraints(t){const{constraints:e}=this.config;if(!e)return t;let{origin:{x:i,y:n},size:{width:a,height:s}}=t;return a=Math.max(e.minWidth||1,a),s=Math.max(e.minHeight||1,s),e.maxWidth&&(a=Math.min(e.maxWidth,a)),e.maxHeight&&(s=Math.min(e.maxHeight,s)),e.boundingBox&&(i=Math.max(0,Math.min(i,e.boundingBox.width-a)),n=Math.max(0,Math.min(n,e.boundingBox.height-s))),{origin:{x:i,y:n},size:{width:a,height:s}}}}function a(t,e){return"n"===t||"s"===t?"ns-resize":"e"===t||"w"===t?"ew-resize":e%2==0?{nw:"nwse-resize",ne:"nesw-resize",sw:"nesw-resize",se:"nwse-resize"}[t]:{nw:"nesw-resize",ne:"nwse-resize",sw:"nwse-resize",se:"nesw-resize"}[t]}function s(t,e,i){const n=-t/2;return"center"===i?n:"outside"===i?n-e:n+e}const r=e=>t.toRaw(t.isRef(e)?t.unref(e):e),o=(t,e=0)=>{const i=Number(t);return Number.isFinite(i)?i:e},l=t=>{var e,i,n,a;return{origin:{x:o(null==(e=null==t?void 0:t.origin)?void 0:e.x),y:o(null==(i=null==t?void 0:t.origin)?void 0:i.y)},size:{width:o(null==(n=null==t?void 0:t.size)?void 0:n.width),height:o(null==(a=null==t?void 0:t.size)?void 0:a.height)}}},c=(t=[])=>t.map(t=>({x:o(null==t?void 0:t.x),y:o(null==t?void 0:t.y)})),h=t=>void 0===t?void 0:Boolean(t),d=t=>void 0===t?void 0:o(t),u=t=>t?r(t):void 0;function p(e){const i=t.ref(null),{onUpdate:a,element:s,vertices:o,constraints:p,maintainAspectRatio:v,pageRotation:m,scale:g,enabled:x}=e,f={element:l(r(s)),vertices:o?c(r(o)):void 0,constraints:u(p),maintainAspectRatio:h(void 0===x?void 0:r(v)),pageRotation:d(void 0===m?void 0:r(m)),scale:d(void 0===g?void 0:r(g))};i.value||(i.value=t.markRaw(new n(f,t=>null==a?void 0:a(t)))),t.watch(()=>({element:s,vertices:o,constraints:p,maintainAspectRatio:v,pageRotation:m,scale:g}),t=>{var e;null==(e=i.value)||e.updateConfig({element:l(r(t.element)),vertices:t.vertices?c(r(t.vertices)):void 0,constraints:u(t.constraints),maintainAspectRatio:h(void 0===t.maintainAspectRatio?void 0:r(t.maintainAspectRatio)),pageRotation:d(void 0===t.pageRotation?void 0:r(t.pageRotation)),scale:d(void 0===t.scale?void 0:r(t.scale))})},{deep:!0}),t.onUnmounted(()=>{i.value=null});const y=()=>Boolean(void 0===x||r(x)),P=t=>{var e,n,a;y()&&(t.preventDefault(),t.stopPropagation(),null==(e=i.value)||e.startDrag(t.clientX,t.clientY),null==(a=(n=t.currentTarget).setPointerCapture)||a.call(n,t.pointerId))},w=t=>{var e;return null==(e=i.value)?void 0:e.move(t.clientX,t.clientY)},z=t=>{var e,n,a;null==(e=i.value)||e.end(),null==(a=(n=t.currentTarget).releasePointerCapture)||a.call(n,t.pointerId)},R=t=>{var e,n,a;null==(e=i.value)||e.cancel(),null==(a=(n=t.currentTarget).releasePointerCapture)||a.call(n,t.pointerId)};return{dragProps:t.computed(()=>y()?{onPointerdown:P,onPointermove:w,onPointerup:z,onPointercancel:R}:{}),createResizeProps:t=>({onPointerdown:e=>{var n,a,s;y()&&(e.preventDefault(),e.stopPropagation(),null==(n=i.value)||n.startResize(t,e.clientX,e.clientY),null==(s=(a=e.currentTarget).setPointerCapture)||s.call(a,e.pointerId))},onPointermove:w,onPointerup:z,onPointercancel:R}),createVertexProps:t=>({onPointerdown:e=>{var n,a,s;y()&&(e.preventDefault(),e.stopPropagation(),null==(n=i.value)||n.startVertexEdit(t,e.clientX,e.clientY),null==(s=(a=e.currentTarget).setPointerCapture)||s.call(a,e.pointerId))},onPointermove:w,onPointerup:z,onPointercancel:R})}}exports.CounterRotate=i,exports.deepToRaw=function(e){const i=e=>Array.isArray(e)?e.map(t=>i(t)):t.isRef(e)||t.isReactive(e)||t.isProxy(e)?i(t.toRaw(e)):e&&"object"==typeof e?Object.keys(e).reduce((t,n)=>(t[n]=i(e[n]),t),{}):e;return i(e)},exports.useDoublePressProps=function(e,{delay:i=300,tolerancePx:n=18}={}){const a=t.ref({t:0,x:0,y:0});return e?{onDblclick:t=>{null==e||e(t)},onPointerupCapture:t=>{if(!e)return;if("mouse"===t.pointerType||!1===t.isPrimary)return;const s=performance.now(),r=t.clientX,o=t.clientY,l=s-a.value.t<=i,c=r-a.value.x,h=o-a.value.y;l&&c*c+h*h<=n*n&&(null==e||e(t)),a.value={t:s,x:r,y:o}}}:{}},exports.useDragResize=p,exports.useInteractionHandles=function(e){const{controller:i,resizeUI:n,vertexUI:o,includeVertices:h=!1,handleAttrs:d,vertexAttrs:u}=e,{dragProps:v,createResizeProps:m,createVertexProps:g}=p(i),x=t.computed(()=>l(r(i.element))),f=t.computed(()=>i.vertices?c(r(i.vertices)):void 0),y=t.computed(()=>Number(r(i.scale??1))),P=t.computed(()=>Number(r(i.pageRotation??0))),w=t.computed(()=>void 0===i.maintainAspectRatio?void 0:Boolean(r(i.maintainAspectRatio))),z=t.computed(()=>r(i.constraints??void 0));return{dragProps:v,resize:t.computed(()=>function(t,e={}){const{handleSize:i=8,spacing:n=1,offsetMode:r="outside",includeSides:o=!1,zIndex:l=3,rotationAwareCursor:c=!0}=e,h=(t.pageRotation??0)%4,d=t=>({[t]:s(i,n,r)+"px"});return[["nw",{...d("top"),...d("left")}],["ne",{...d("top"),...d("right")}],["sw",{...d("bottom"),...d("left")}],["se",{...d("bottom"),...d("right")}],...o?[["n",{...d("top"),left:`calc(50% - ${i/2}px)`}],["s",{...d("bottom"),left:`calc(50% - ${i/2}px)`}],["w",{...d("left"),top:`calc(50% - ${i/2}px)`}],["e",{...d("right"),top:`calc(50% - ${i/2}px)`}]]:[]].map(([t,e])=>({handle:t,style:{position:"absolute",width:i+"px",height:i+"px",borderRadius:"50%",zIndex:l,cursor:c?a(t,h):"default",touchAction:"none",...e},attrs:{"data-epdf-handle":t}}))}({element:x.value,scale:y.value,pageRotation:P.value,maintainAspectRatio:w.value,constraints:z.value},n).map(t=>{var e;return{key:(null==(e=t.attrs)?void 0:e["data-epdf-handle"])??t.handle,style:t.style,...m(t.handle),...t.attrs??{},...(null==d?void 0:d(t.handle))??{}}})),vertices:t.computed(()=>{if(!h)return[];const t=f.value??[];return function(t,e={},i){const{vertexSize:n=12,zIndex:a=4}=e,s=t.element,r=t.scale??1;return(i??t.vertices??[]).map((t,e)=>({handle:"nw",style:{position:"absolute",left:(t.x-s.origin.x)*r-n/2+"px",top:(t.y-s.origin.y)*r-n/2+"px",width:n+"px",height:n+"px",borderRadius:"50%",cursor:"pointer",zIndex:a,touchAction:"none"},attrs:{"data-epdf-vertex":e}}))}({element:x.value,scale:y.value,vertices:t},o,t).map((t,e)=>({key:e,style:t.style,...g(e),...t.attrs??{},...(null==u?void 0:u(e))??{}}))})}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),e=require("@embedpdf/utils"),i=t.defineComponent({__name:"counter-rotate-container",props:{rect:{},rotation:{}},setup(i){const n=i,s=t.computed(()=>e.getCounterRotation(n.rect,n.rotation)),a=t.computed(()=>({style:{position:"absolute",left:`${n.rect.origin.x}px`,top:`${n.rect.origin.y}px`,transform:s.value.matrix,transformOrigin:"0 0",width:`${s.value.width}px`,height:`${s.value.height}px`,pointerEvents:"none",zIndex:3},onPointerdown:t=>{t.stopPropagation(),t.preventDefault()},onTouchstart:t=>{t.stopPropagation(),t.preventDefault()}})),r=t.computed(()=>({origin:{x:n.rect.origin.x,y:n.rect.origin.y},size:{width:s.value.width,height:s.value.height}}));return(e,i)=>t.renderSlot(e.$slots,"default",{menuWrapperProps:a.value,matrix:s.value.matrix,rect:r.value})}});class n{constructor(t,e){this.config=t,this.onUpdate=e,this.state="idle",this.startPoint=null,this.startElement=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.currentVertices=[],this.currentVertices=t.vertices||[]}updateConfig(t){this.config={...this.config,...t},this.currentVertices=t.vertices||[]}startDrag(t,e){this.state="dragging",this.startPoint={x:t,y:e},this.startElement={...this.config.element},this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"move",changes:{rect:this.startElement}}})}startResize(t,e,i){this.state="resizing",this.activeHandle=t,this.startPoint={x:e,y:i},this.startElement={...this.config.element},this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"resize",changes:{rect:this.startElement},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio}}})}startVertexEdit(t,e,i){this.currentVertices=[...this.config.vertices??this.currentVertices],t<0||t>=this.currentVertices.length||(this.state="vertex-editing",this.activeVertexIndex=t,this.startPoint={x:e,y:i},this.startVertices=[...this.currentVertices],this.onUpdate({state:"start",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:t}}}))}move(t,e){if("idle"!==this.state&&this.startPoint)if("dragging"===this.state&&this.startElement){const i=this.calculateDelta(t,e),n=this.calculateDragPosition(i);this.currentPosition=n,this.onUpdate({state:"move",transformData:{type:"move",changes:{rect:n}}})}else if("resizing"===this.state&&this.activeHandle&&this.startElement){const i=this.calculateDelta(t,e),n=this.calculateResizePosition(i,this.activeHandle);this.currentPosition=n,this.onUpdate({state:"move",transformData:{type:"resize",changes:{rect:n},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio}}})}else if("vertex-editing"===this.state&&null!==this.activeVertexIndex){const i=this.calculateVertexPosition(t,e);this.currentVertices=i,this.onUpdate({state:"move",transformData:{type:"vertex-edit",changes:{vertices:i},metadata:{vertexIndex:this.activeVertexIndex}}})}}end(){if("idle"===this.state)return;const t=this.state,e=this.activeHandle,i=this.activeVertexIndex;if("vertex-editing"===t)this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.currentVertices},metadata:{vertexIndex:i||void 0}}});else{const i=this.getCurrentPosition();this.onUpdate({state:"end",transformData:{type:"dragging"===t?"move":"resize",changes:{rect:i},metadata:"dragging"===t?void 0:{handle:e||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}})}this.reset()}cancel(){"idle"!==this.state&&("vertex-editing"===this.state?this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:this.activeVertexIndex||void 0}}}):this.startElement&&this.onUpdate({state:"end",transformData:{type:"dragging"===this.state?"move":"resize",changes:{rect:this.startElement},metadata:"dragging"===this.state?void 0:{handle:this.activeHandle||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}}),this.reset())}reset(){this.state="idle",this.startPoint=null,this.startElement=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[]}getCurrentPosition(){return this.currentPosition||this.config.element}calculateDelta(t,e){if(!this.startPoint)return{x:0,y:0};const i={x:t-this.startPoint.x,y:e-this.startPoint.y};return this.transformDelta(i)}transformDelta(t){const{pageRotation:e=0,scale:i=1}=this.config,n=e*Math.PI/2,s=Math.cos(n),a=Math.sin(n),r=t.x/i,o=t.y/i;return{x:s*r+a*o,y:-a*r+s*o}}clampPoint(t){var e;const i=null==(e=this.config.constraints)?void 0:e.boundingBox;return i?{x:Math.max(0,Math.min(t.x,i.width)),y:Math.max(0,Math.min(t.y,i.height))}:t}calculateVertexPosition(t,e){if(null===this.activeVertexIndex)return this.startVertices;const i=this.calculateDelta(t,e),n=[...this.startVertices],s=n[this.activeVertexIndex],a={x:s.x+i.x,y:s.y+i.y};return n[this.activeVertexIndex]=this.clampPoint(a),n}calculateDragPosition(t){if(!this.startElement)return this.config.element;const e={origin:{x:this.startElement.origin.x+t.x,y:this.startElement.origin.y+t.y},size:{width:this.startElement.size.width,height:this.startElement.size.height}};return this.applyConstraints(e)}calculateResizePosition(t,e){if(!this.startElement)return this.config.element;const i=function(t){return{x:t.includes("e")?"left":t.includes("w")?"right":"center",y:t.includes("s")?"top":t.includes("n")?"bottom":"center"}}(e),n=this.startElement.size.width/this.startElement.size.height||1;let s=this.applyResizeDelta(t,i);return this.config.maintainAspectRatio&&(s=this.enforceAspectRatio(s,i,n)),s=this.clampToBounds(s,i,n),this.applyConstraints(s)}applyResizeDelta(t,e){const i=this.startElement;let n=i.origin.x,s=i.origin.y,a=i.size.width,r=i.size.height;return"left"===e.x?a+=t.x:"right"===e.x&&(n+=t.x,a-=t.x),"top"===e.y?r+=t.y:"bottom"===e.y&&(s+=t.y,r-=t.y),{origin:{x:n,y:s},size:{width:a,height:r}}}enforceAspectRatio(t,e,i){const n=this.startElement;let{x:s,y:a}=t.origin,{width:r,height:o}=t.size;if("center"===e.x||"center"===e.y)"center"===e.y?(o=r/i,a=n.origin.y+(n.size.height-o)/2):(r=o*i,s=n.origin.x+(n.size.width-r)/2);else{Math.abs(r-n.size.width)>=Math.abs(o-n.size.height)?o=r/i:r=o*i}return"right"===e.x&&(s=n.origin.x+n.size.width-r),"bottom"===e.y&&(a=n.origin.y+n.size.height-o),{origin:{x:s,y:a},size:{width:r,height:o}}}clampToBounds(t,e,i){var n;const s=null==(n=this.config.constraints)?void 0:n.boundingBox;if(!s)return t;const a=this.startElement;let{x:r,y:o}=t.origin,{width:l,height:c}=t.size;l=Math.max(1,l),c=Math.max(1,c);const h="left"===e.x?a.origin.x:a.origin.x+a.size.width,d="top"===e.y?a.origin.y:a.origin.y+a.size.height,u="left"===e.x?s.width-h:"right"===e.x?h:2*Math.min(a.origin.x,s.width-a.origin.x-a.size.width)+a.size.width,p="top"===e.y?s.height-d:"bottom"===e.y?d:2*Math.min(a.origin.y,s.height-a.origin.y-a.size.height)+a.size.height;if(this.config.maintainAspectRatio){const t=l>u?u/l:1,e=c>p?p/c:1,i=Math.min(t,e);i<1&&(l*=i,c*=i)}else l=Math.min(l,u),c=Math.min(c,p);return r="left"===e.x?h:"right"===e.x?h-l:a.origin.x+(a.size.width-l)/2,o="top"===e.y?d:"bottom"===e.y?d-c:a.origin.y+(a.size.height-c)/2,r=Math.max(0,Math.min(r,s.width-l)),o=Math.max(0,Math.min(o,s.height-c)),{origin:{x:r,y:o},size:{width:l,height:c}}}applyConstraints(t){const{constraints:e}=this.config;if(!e)return t;let{origin:{x:i,y:n},size:{width:s,height:a}}=t;const r=e.minWidth??1,o=e.minHeight??1,l=e.maxWidth,c=e.maxHeight;if(this.config.maintainAspectRatio&&s>0&&a>0){const t=s/a;s<r&&(s=r,a=s/t),a<o&&(a=o,s=a*t),void 0!==l&&s>l&&(s=l,a=s/t),void 0!==c&&a>c&&(a=c,s=a*t)}else s=Math.max(r,s),a=Math.max(o,a),void 0!==l&&(s=Math.min(l,s)),void 0!==c&&(a=Math.min(c,a));return e.boundingBox&&(i=Math.max(0,Math.min(i,e.boundingBox.width-s)),n=Math.max(0,Math.min(n,e.boundingBox.height-a))),{origin:{x:i,y:n},size:{width:s,height:a}}}}function s(t,e){return"n"===t||"s"===t?"ns-resize":"e"===t||"w"===t?"ew-resize":e%2==0?{nw:"nwse-resize",ne:"nesw-resize",sw:"nesw-resize",se:"nwse-resize"}[t]:{nw:"nesw-resize",ne:"nwse-resize",sw:"nwse-resize",se:"nesw-resize"}[t]}function a(t,e,i){const n=-t/2;return"center"===i?n:"outside"===i?n-e:n+e}const r=e=>t.toRaw(t.isRef(e)?t.unref(e):e),o=(t,e=0)=>{const i=Number(t);return Number.isFinite(i)?i:e},l=t=>{var e,i,n,s;return{origin:{x:o(null==(e=null==t?void 0:t.origin)?void 0:e.x),y:o(null==(i=null==t?void 0:t.origin)?void 0:i.y)},size:{width:o(null==(n=null==t?void 0:t.size)?void 0:n.width),height:o(null==(s=null==t?void 0:t.size)?void 0:s.height)}}},c=(t=[])=>t.map(t=>({x:o(null==t?void 0:t.x),y:o(null==t?void 0:t.y)})),h=t=>void 0===t?void 0:Boolean(t),d=t=>void 0===t?void 0:o(t),u=t=>t?r(t):void 0;function p(e){const i=t.ref(null),{onUpdate:s,element:a,vertices:o,constraints:p,maintainAspectRatio:g,pageRotation:v,scale:m,enabled:x}=e,f={element:l(r(a)),vertices:o?c(r(o)):void 0,constraints:u(p),maintainAspectRatio:h(void 0===x?void 0:r(g)),pageRotation:d(void 0===v?void 0:r(v)),scale:d(void 0===m?void 0:r(m))};i.value||(i.value=t.markRaw(new n(f,t=>null==s?void 0:s(t)))),t.watch(()=>({element:a,vertices:o,constraints:p,maintainAspectRatio:g,pageRotation:v,scale:m}),t=>{var e;null==(e=i.value)||e.updateConfig({element:l(r(t.element)),vertices:t.vertices?c(r(t.vertices)):void 0,constraints:u(t.constraints),maintainAspectRatio:h(void 0===t.maintainAspectRatio?void 0:r(t.maintainAspectRatio)),pageRotation:d(void 0===t.pageRotation?void 0:r(t.pageRotation)),scale:d(void 0===t.scale?void 0:r(t.scale))})},{deep:!0}),t.onUnmounted(()=>{i.value=null});const y=()=>Boolean(void 0===x||r(x)),z=t=>{var e,n,s;y()&&(t.preventDefault(),t.stopPropagation(),null==(e=i.value)||e.startDrag(t.clientX,t.clientY),null==(s=(n=t.currentTarget).setPointerCapture)||s.call(n,t.pointerId))},P=t=>{var e;return null==(e=i.value)?void 0:e.move(t.clientX,t.clientY)},w=t=>{var e,n,s;null==(e=i.value)||e.end(),null==(s=(n=t.currentTarget).releasePointerCapture)||s.call(n,t.pointerId)},R=t=>{var e,n,s;null==(e=i.value)||e.cancel(),null==(s=(n=t.currentTarget).releasePointerCapture)||s.call(n,t.pointerId)};return{dragProps:t.computed(()=>y()?{onPointerdown:z,onPointermove:P,onPointerup:w,onPointercancel:R}:{}),createResizeProps:t=>({onPointerdown:e=>{var n,s,a;y()&&(e.preventDefault(),e.stopPropagation(),null==(n=i.value)||n.startResize(t,e.clientX,e.clientY),null==(a=(s=e.currentTarget).setPointerCapture)||a.call(s,e.pointerId))},onPointermove:P,onPointerup:w,onPointercancel:R}),createVertexProps:t=>({onPointerdown:e=>{var n,s,a;y()&&(e.preventDefault(),e.stopPropagation(),null==(n=i.value)||n.startVertexEdit(t,e.clientX,e.clientY),null==(a=(s=e.currentTarget).setPointerCapture)||a.call(s,e.pointerId))},onPointermove:P,onPointerup:w,onPointercancel:R})}}exports.CounterRotate=i,exports.deepToRaw=function(e){const i=e=>Array.isArray(e)?e.map(t=>i(t)):t.isRef(e)||t.isReactive(e)||t.isProxy(e)?i(t.toRaw(e)):e&&"object"==typeof e?Object.keys(e).reduce((t,n)=>(t[n]=i(e[n]),t),{}):e;return i(e)},exports.useDoublePressProps=function(e,{delay:i=300,tolerancePx:n=18}={}){const s=t.ref({t:0,x:0,y:0});return e?{onDblclick:t=>{null==e||e(t)},onPointerupCapture:t=>{if(!e)return;if("mouse"===t.pointerType||!1===t.isPrimary)return;const a=performance.now(),r=t.clientX,o=t.clientY,l=a-s.value.t<=i,c=r-s.value.x,h=o-s.value.y;l&&c*c+h*h<=n*n&&(null==e||e(t)),s.value={t:a,x:r,y:o}}}:{}},exports.useDragResize=p,exports.useInteractionHandles=function(e){const{controller:i,resizeUI:n,vertexUI:o,includeVertices:h=!1,handleAttrs:d,vertexAttrs:u}=e,{dragProps:g,createResizeProps:v,createVertexProps:m}=p(i),x=t.computed(()=>l(r(i.element))),f=t.computed(()=>i.vertices?c(r(i.vertices)):void 0),y=t.computed(()=>Number(r(i.scale??1))),z=t.computed(()=>Number(r(i.pageRotation??0))),P=t.computed(()=>void 0===i.maintainAspectRatio?void 0:Boolean(r(i.maintainAspectRatio))),w=t.computed(()=>r(i.constraints??void 0));return{dragProps:g,resize:t.computed(()=>function(t,e={}){const{handleSize:i=8,spacing:n=1,offsetMode:r="outside",includeSides:o=!1,zIndex:l=3,rotationAwareCursor:c=!0}=e,h=(t.pageRotation??0)%4,d=t=>({[t]:a(i,n,r)+"px"});return[["nw",{...d("top"),...d("left")}],["ne",{...d("top"),...d("right")}],["sw",{...d("bottom"),...d("left")}],["se",{...d("bottom"),...d("right")}],...o?[["n",{...d("top"),left:`calc(50% - ${i/2}px)`}],["s",{...d("bottom"),left:`calc(50% - ${i/2}px)`}],["w",{...d("left"),top:`calc(50% - ${i/2}px)`}],["e",{...d("right"),top:`calc(50% - ${i/2}px)`}]]:[]].map(([t,e])=>({handle:t,style:{position:"absolute",width:i+"px",height:i+"px",borderRadius:"50%",zIndex:l,cursor:c?s(t,h):"default",touchAction:"none",...e},attrs:{"data-epdf-handle":t}}))}({element:x.value,scale:y.value,pageRotation:z.value,maintainAspectRatio:P.value,constraints:w.value},n).map(t=>{var e;return{key:(null==(e=t.attrs)?void 0:e["data-epdf-handle"])??t.handle,style:t.style,...v(t.handle),...t.attrs??{},...(null==d?void 0:d(t.handle))??{}}})),vertices:t.computed(()=>{if(!h)return[];const t=f.value??[];return function(t,e={},i){const{vertexSize:n=12,zIndex:s=4}=e,a=t.element,r=t.scale??1;return(i??t.vertices??[]).map((t,e)=>({handle:"nw",style:{position:"absolute",left:(t.x-a.origin.x)*r-n/2+"px",top:(t.y-a.origin.y)*r-n/2+"px",width:n+"px",height:n+"px",borderRadius:"50%",cursor:"pointer",zIndex:s,touchAction:"none"},attrs:{"data-epdf-vertex":e}}))}({element:x.value,scale:y.value,vertices:t},o,t).map((t,e)=>({key:e,style:t.style,...m(e),...t.attrs??{},...(null==u?void 0:u(e))??{}}))})}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/vue/components/counter-rotate-container.vue","../../src/shared/plugin-interaction-primitives/drag-resize-controller.ts","../../src/shared/plugin-interaction-primitives/utils.ts","../../src/vue/utils/interaction-normalize.ts","../../src/vue/hooks/use-drag-resize.ts","../../src/vue/utils/deep-to-raw.ts","../../src/vue/hooks/use-double-press-props.ts","../../src/vue/hooks/use-interaction-handles.ts"],"sourcesContent":["<template>\n <slot\n :menu-wrapper-props=\"menuWrapperProps\"\n :matrix=\"counterRotation.matrix\"\n :rect=\"adjustedRect\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, type CSSProperties } from 'vue';\nimport type { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nconst props = defineProps<CounterRotateProps>();\n\nconst counterRotation = computed(() => getCounterRotation(props.rect, props.rotation));\n\nconst menuWrapperProps = computed(() => ({\n style: {\n position: 'absolute',\n left: `${props.rect.origin.x}px`,\n top: `${props.rect.origin.y}px`,\n transform: counterRotation.value.matrix,\n transformOrigin: '0 0',\n width: `${counterRotation.value.width}px`,\n height: `${counterRotation.value.height}px`,\n pointerEvents: 'none',\n zIndex: 3,\n } as CSSProperties,\n onPointerdown: (e: PointerEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n onTouchstart: (e: TouchEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n}));\n\nconst adjustedRect = computed(() => ({\n origin: { x: props.rect.origin.x, y: props.rect.origin.y },\n size: { width: counterRotation.value.width, height: counterRotation.value.height },\n}));\n</script>\n","import { Position, Rect } from '@embedpdf/models';\n\nexport interface DragResizeConfig {\n element: Rect;\n vertices?: Position[];\n constraints?: {\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n boundingBox?: { width: number; height: number }; // page bounds\n };\n maintainAspectRatio?: boolean;\n pageRotation?: number;\n scale?: number;\n}\n\nexport type InteractionState = 'idle' | 'dragging' | 'resizing' | 'vertex-editing';\nexport type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w';\n\nexport interface TransformData {\n type: 'move' | 'resize' | 'vertex-edit';\n changes: {\n rect?: Rect;\n vertices?: Position[];\n };\n metadata?: {\n handle?: ResizeHandle;\n vertexIndex?: number;\n maintainAspectRatio?: boolean;\n };\n}\n\nexport interface InteractionEvent {\n state: 'start' | 'move' | 'end';\n transformData?: TransformData;\n}\n\n/**\n * Pure geometric controller that manages drag/resize/vertex-edit logic.\n */\nexport class DragResizeController {\n private state: InteractionState = 'idle';\n private startPoint: Position | null = null;\n private startElement: Rect | null = null;\n private activeHandle: ResizeHandle | null = null;\n private currentPosition: Rect | null = null;\n\n // Vertex editing state - pure geometric\n private activeVertexIndex: number | null = null;\n private startVertices: Position[] = [];\n private currentVertices: Position[] = [];\n\n constructor(\n private config: DragResizeConfig,\n private onUpdate: (event: InteractionEvent) => void,\n ) {\n this.currentVertices = config.vertices || [];\n }\n\n updateConfig(config: Partial<DragResizeConfig>) {\n this.config = { ...this.config, ...config };\n this.currentVertices = config.vertices || [];\n }\n\n startDrag(clientX: number, clientY: number) {\n this.state = 'dragging';\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'move',\n changes: {\n rect: this.startElement,\n },\n },\n });\n }\n\n startResize(handle: ResizeHandle, clientX: number, clientY: number) {\n this.state = 'resizing';\n this.activeHandle = handle;\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n startVertexEdit(vertexIndex: number, clientX: number, clientY: number) {\n // Refresh vertices from latest config before validating index\n this.currentVertices = [...(this.config.vertices ?? this.currentVertices)];\n if (vertexIndex < 0 || vertexIndex >= this.currentVertices.length) return;\n\n this.state = 'vertex-editing';\n this.activeVertexIndex = vertexIndex;\n this.startPoint = { x: clientX, y: clientY };\n this.startVertices = [...this.currentVertices];\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex,\n },\n },\n });\n }\n\n move(clientX: number, clientY: number) {\n if (this.state === 'idle' || !this.startPoint) return;\n\n if (this.state === 'dragging' && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateDragPosition(delta);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'move',\n changes: {\n rect: position,\n },\n },\n });\n } else if (this.state === 'resizing' && this.activeHandle && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateResizePosition(delta, this.activeHandle);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'resize',\n changes: {\n rect: position,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n } else if (this.state === 'vertex-editing' && this.activeVertexIndex !== null) {\n const vertices = this.calculateVertexPosition(clientX, clientY);\n this.currentVertices = vertices;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex,\n },\n },\n });\n }\n }\n\n end() {\n if (this.state === 'idle') return;\n\n const wasState = this.state;\n const handle = this.activeHandle;\n const vertexIndex = this.activeVertexIndex;\n\n if (wasState === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.currentVertices,\n },\n metadata: {\n vertexIndex: vertexIndex || undefined,\n },\n },\n });\n } else {\n const finalPosition = this.getCurrentPosition();\n this.onUpdate({\n state: 'end',\n transformData: {\n type: wasState === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: finalPosition,\n },\n metadata:\n wasState === 'dragging'\n ? undefined\n : {\n handle: handle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n cancel() {\n if (this.state === 'idle') return;\n\n if (this.state === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex || undefined,\n },\n },\n });\n } else if (this.startElement) {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: this.state === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata:\n this.state === 'dragging'\n ? undefined\n : {\n handle: this.activeHandle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n private reset() {\n this.state = 'idle';\n this.startPoint = null;\n this.startElement = null;\n this.activeHandle = null;\n this.currentPosition = null;\n this.activeVertexIndex = null;\n this.startVertices = [];\n }\n\n private getCurrentPosition() {\n return this.currentPosition || this.config.element;\n }\n\n private calculateDelta(clientX: number, clientY: number): Position {\n if (!this.startPoint) return { x: 0, y: 0 };\n\n const rawDelta: Position = {\n x: clientX - this.startPoint.x,\n y: clientY - this.startPoint.y,\n };\n\n return this.transformDelta(rawDelta);\n }\n\n private transformDelta(delta: Position): Position {\n const { pageRotation = 0, scale = 1 } = this.config;\n\n const rad = (pageRotation * Math.PI) / 2;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n\n const scaledX = delta.x / scale;\n const scaledY = delta.y / scale;\n\n return {\n x: cos * scaledX + sin * scaledY,\n y: -sin * scaledX + cos * scaledY,\n };\n }\n\n private clampPoint(p: Position): Position {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return p;\n return {\n x: Math.max(0, Math.min(p.x, bbox.width)),\n y: Math.max(0, Math.min(p.y, bbox.height)),\n };\n }\n\n private calculateVertexPosition(clientX: number, clientY: number): Position[] {\n if (this.activeVertexIndex === null) return this.startVertices;\n\n const delta = this.calculateDelta(clientX, clientY);\n const newVertices = [...this.startVertices];\n const currentVertex = newVertices[this.activeVertexIndex];\n\n const moved = {\n x: currentVertex.x + delta.x,\n y: currentVertex.y + delta.y,\n };\n newVertices[this.activeVertexIndex] = this.clampPoint(moved);\n\n return newVertices;\n }\n\n private calculateDragPosition(delta: Position): Rect {\n if (!this.startElement) return this.config.element;\n\n const position: Rect = {\n origin: {\n x: this.startElement.origin.x + delta.x,\n y: this.startElement.origin.y + delta.y,\n },\n size: {\n width: this.startElement.size.width,\n height: this.startElement.size.height,\n },\n };\n\n return this.applyConstraints(position);\n }\n\n private calculateResizePosition(delta: Position, handle: ResizeHandle): Rect {\n if (!this.startElement) return this.config.element;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = this.startElement;\n\n switch (handle) {\n case 'se':\n width += delta.x;\n height += delta.y;\n break;\n case 'sw':\n x += delta.x;\n width -= delta.x;\n height += delta.y;\n break;\n case 'ne':\n width += delta.x;\n y += delta.y;\n height -= delta.y;\n break;\n case 'nw':\n x += delta.x;\n width -= delta.x;\n y += delta.y;\n height -= delta.y;\n break;\n case 'n':\n y += delta.y;\n height -= delta.y;\n break;\n case 's':\n height += delta.y;\n break;\n case 'e':\n width += delta.x;\n break;\n case 'w':\n x += delta.x;\n width -= delta.x;\n break;\n }\n\n // Maintain aspect ratio if needed\n if (this.config.maintainAspectRatio && this.startElement) {\n const aspectRatio = this.startElement.size.width / this.startElement.size.height;\n\n if (['n', 's', 'e', 'w'].includes(handle)) {\n if (handle === 'n' || handle === 's') {\n const newWidth = height * aspectRatio;\n const widthDiff = newWidth - width;\n width = newWidth;\n x -= widthDiff / 2;\n } else {\n const newHeight = width / aspectRatio;\n const heightDiff = newHeight - height;\n height = newHeight;\n if (handle === 'w') {\n x = this.startElement.origin.x + this.startElement.size.width - width;\n }\n y -= heightDiff / 2;\n }\n } else {\n const widthChange = Math.abs(width - this.startElement.size.width);\n const heightChange = Math.abs(height - this.startElement.size.height);\n if (widthChange > heightChange) {\n height = width / aspectRatio;\n } else {\n width = height * aspectRatio;\n }\n if (handle.includes('w')) {\n x = this.startElement.origin.x + this.startElement.size.width - width;\n }\n if (handle.includes('n')) {\n y = this.startElement.origin.y + this.startElement.size.height - height;\n }\n }\n }\n\n // Handle-aware bounding box clamping to avoid shifting opposite edge\n const bbox = this.config.constraints?.boundingBox;\n if (bbox) {\n switch (handle) {\n case 'e':\n width = Math.min(width, bbox.width - x);\n break;\n case 's':\n height = Math.min(height, bbox.height - y);\n break;\n case 'se':\n width = Math.min(width, bbox.width - x);\n height = Math.min(height, bbox.height - y);\n break;\n case 'w':\n if (x < 0) {\n width += x;\n x = 0;\n }\n break;\n case 'n':\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n case 'sw':\n if (x < 0) {\n width += x;\n x = 0;\n }\n height = Math.min(height, bbox.height - y);\n break;\n case 'nw':\n if (x < 0) {\n width += x;\n x = 0;\n }\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n case 'ne':\n width = Math.min(width, bbox.width - x);\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n }\n }\n\n return this.applyConstraints({ origin: { x, y }, size: { width, height } });\n }\n\n private applyConstraints(position: Rect): Rect {\n const { constraints } = this.config;\n if (!constraints) return position;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = position;\n\n // Apply size constraints\n width = Math.max(constraints.minWidth || 1, width);\n height = Math.max(constraints.minHeight || 1, height);\n\n if (constraints.maxWidth) width = Math.min(constraints.maxWidth, width);\n if (constraints.maxHeight) height = Math.min(constraints.maxHeight, height);\n\n // Apply bounding box constraints\n if (constraints.boundingBox) {\n x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));\n y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n}\n","import type { Position, Rect } from '@embedpdf/models';\nimport type { ResizeHandle, DragResizeConfig } from './drag-resize-controller';\n\nexport type QuarterTurns = 0 | 1 | 2 | 3;\n\nexport interface ResizeUI {\n handleSize?: number; // px (default 8)\n spacing?: number; // px distance from the box edge (default 1)\n offsetMode?: 'outside' | 'inside' | 'center'; // default 'outside'\n includeSides?: boolean; // default false\n zIndex?: number; // default 3\n rotationAwareCursor?: boolean; // default true\n}\n\nexport interface VertexUI {\n vertexSize?: number; // px (default 12)\n zIndex?: number; // default 4\n}\n\nexport interface HandleDescriptor {\n handle: ResizeHandle;\n style: Record<string, number | string>;\n attrs?: Record<string, any>;\n}\n\nfunction diagonalCursor(handle: ResizeHandle, rot: QuarterTurns): string {\n // Standard cursors; diagonals flip on odd quarter-turns\n const diag0: Record<'nw' | 'ne' | 'sw' | 'se', string> = {\n nw: 'nwse-resize',\n ne: 'nesw-resize',\n sw: 'nesw-resize',\n se: 'nwse-resize',\n };\n if (handle === 'n' || handle === 's') return 'ns-resize';\n if (handle === 'e' || handle === 'w') return 'ew-resize';\n if (rot % 2 === 0) return diag0[handle as 'nw' | 'ne' | 'sw' | 'se'];\n return { nw: 'nesw-resize', ne: 'nwse-resize', sw: 'nwse-resize', se: 'nesw-resize' }[\n handle as 'nw' | 'ne' | 'sw' | 'se'\n ]!;\n}\n\nfunction edgeOffset(k: number, spacing: number, mode: 'outside' | 'inside' | 'center') {\n // Base puts the handle centered on the edge\n const base = -k / 2;\n if (mode === 'center') return base;\n // outside moves further out (more negative), inside moves in (less negative)\n return mode === 'outside' ? base - spacing : base + spacing;\n}\n\nexport function describeResizeFromConfig(\n cfg: DragResizeConfig,\n ui: ResizeUI = {},\n): HandleDescriptor[] {\n const {\n handleSize = 8,\n spacing = 1,\n offsetMode = 'outside',\n includeSides = false,\n zIndex = 3,\n rotationAwareCursor = true,\n } = ui;\n\n const rotation = ((cfg.pageRotation ?? 0) % 4) as QuarterTurns;\n\n const off = (edge: 'top' | 'right' | 'bottom' | 'left') => ({\n [edge]: edgeOffset(handleSize, spacing, offsetMode) + 'px',\n });\n\n const corners: Array<[ResizeHandle, Record<string, number | string>]> = [\n ['nw', { ...off('top'), ...off('left') }],\n ['ne', { ...off('top'), ...off('right') }],\n ['sw', { ...off('bottom'), ...off('left') }],\n ['se', { ...off('bottom'), ...off('right') }],\n ];\n const sides: Array<[ResizeHandle, Record<string, number | string>]> = includeSides\n ? [\n ['n', { ...off('top'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['s', { ...off('bottom'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['w', { ...off('left'), top: `calc(50% - ${handleSize / 2}px)` }],\n ['e', { ...off('right'), top: `calc(50% - ${handleSize / 2}px)` }],\n ]\n : [];\n\n const all = [...corners, ...sides];\n\n return all.map(([handle, pos]) => ({\n handle,\n style: {\n position: 'absolute',\n width: handleSize + 'px',\n height: handleSize + 'px',\n borderRadius: '50%',\n zIndex,\n cursor: rotationAwareCursor ? diagonalCursor(handle, rotation) : 'default',\n touchAction: 'none',\n ...(pos as any),\n },\n attrs: { 'data-epdf-handle': handle },\n }));\n}\n\nexport function describeVerticesFromConfig(\n cfg: DragResizeConfig,\n ui: VertexUI = {},\n liveVertices?: Position[],\n): HandleDescriptor[] {\n const { vertexSize = 12, zIndex = 4 } = ui;\n const rect: Rect = cfg.element;\n const scale = cfg.scale ?? 1;\n const verts = liveVertices ?? cfg.vertices ?? [];\n\n return verts.map((v, i) => {\n const left = (v.x - rect.origin.x) * scale - vertexSize / 2;\n const top = (v.y - rect.origin.y) * scale - vertexSize / 2;\n return {\n handle: 'nw', // not used; kept for type\n style: {\n position: 'absolute',\n left: left + 'px',\n top: top + 'px',\n width: vertexSize + 'px',\n height: vertexSize + 'px',\n borderRadius: '50%',\n cursor: 'pointer',\n zIndex,\n touchAction: 'none',\n },\n attrs: { 'data-epdf-vertex': i },\n };\n });\n}\n","import { isRef, unref, toRaw, type Ref } from 'vue';\nimport type { Rect, Position } from '@embedpdf/models';\nimport type { DragResizeConfig } from '../../shared/plugin-interaction-primitives';\n\nexport type MaybeRef<T> = T | Ref<T>;\n\nexport const norm = <T>(v: MaybeRef<T>): T => toRaw(isRef(v) ? unref(v) : (v as T));\n\nexport const toNum = (n: unknown, fallback = 0): number => {\n const v = Number(n);\n return Number.isFinite(v) ? v : fallback;\n};\n\nexport const rectDTO = (r: any): Rect => ({\n origin: { x: toNum(r?.origin?.x), y: toNum(r?.origin?.y) },\n size: { width: toNum(r?.size?.width), height: toNum(r?.size?.height) },\n});\n\nexport const vertsDTO = (arr: any[] = []): Position[] =>\n arr.map((p) => ({ x: toNum(p?.x), y: toNum(p?.y) }));\n\nexport const boolDTO = (b: unknown): boolean | undefined =>\n b === undefined ? undefined : Boolean(b);\n\nexport const numDTO = (n: unknown): number | undefined => (n === undefined ? undefined : toNum(n));\n\nexport const constraintsDTO = (\n c: MaybeRef<DragResizeConfig['constraints']> | undefined,\n): DragResizeConfig['constraints'] | undefined => (c ? norm(c) : undefined);\n","import { ref, watch, computed, onUnmounted, markRaw, type Ref } from 'vue';\nimport type { Position, Rect } from '@embedpdf/models';\nimport {\n DragResizeController,\n type DragResizeConfig,\n type InteractionEvent,\n type ResizeHandle,\n} from '../../shared/plugin-interaction-primitives';\nimport {\n norm,\n rectDTO,\n vertsDTO,\n constraintsDTO,\n boolDTO,\n numDTO,\n type MaybeRef,\n} from '../utils/interaction-normalize';\n\nexport interface UseDragResizeOptions {\n element: MaybeRef<Rect>;\n vertices?: MaybeRef<Position[]>;\n constraints?: MaybeRef<DragResizeConfig['constraints']>;\n maintainAspectRatio?: MaybeRef<boolean>;\n pageRotation?: MaybeRef<number>;\n scale?: MaybeRef<number>;\n onUpdate?: (event: InteractionEvent) => void;\n enabled?: MaybeRef<boolean>;\n}\n\nexport function useDragResize(options: UseDragResizeOptions) {\n const controller = ref<DragResizeController | null>(null);\n\n const {\n onUpdate,\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n enabled,\n } = options;\n\n // Build initial plain config\n const initialCfg: DragResizeConfig = {\n element: rectDTO(norm(element)),\n vertices: vertices ? vertsDTO(norm(vertices)) : undefined,\n constraints: constraintsDTO(constraints),\n maintainAspectRatio: boolDTO(enabled === undefined ? undefined : norm(maintainAspectRatio!)),\n pageRotation: numDTO(pageRotation === undefined ? undefined : norm(pageRotation!)),\n scale: numDTO(scale === undefined ? undefined : norm(scale!)),\n };\n\n if (!controller.value) {\n controller.value = markRaw(new DragResizeController(initialCfg, (ev) => onUpdate?.(ev)));\n }\n\n // Reactive updates → always normalize before passing to controller\n watch(\n () => ({\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n }),\n (nc) => {\n controller.value?.updateConfig({\n element: rectDTO(norm(nc.element)),\n vertices: nc.vertices ? vertsDTO(norm(nc.vertices)) : undefined,\n constraints: constraintsDTO(nc.constraints),\n maintainAspectRatio: boolDTO(\n nc.maintainAspectRatio === undefined ? undefined : norm(nc.maintainAspectRatio!),\n ),\n pageRotation: numDTO(nc.pageRotation === undefined ? undefined : norm(nc.pageRotation!)),\n scale: numDTO(nc.scale === undefined ? undefined : norm(nc.scale!)),\n });\n },\n { deep: true },\n );\n\n onUnmounted(() => {\n controller.value = null;\n });\n\n const isEnabled = () => Boolean(enabled === undefined ? true : norm(enabled));\n\n // Pointer handlers\n const handleDragStart = (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startDrag(e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n };\n const handleMove = (e: PointerEvent) => controller.value?.move(e.clientX, e.clientY);\n const handleEnd = (e: PointerEvent) => {\n controller.value?.end();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n const handleCancel = (e: PointerEvent) => {\n controller.value?.cancel();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n\n const createResizeProps = (handle: ResizeHandle) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startResize(handle, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const createVertexProps = (vertexIndex: number) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startVertexEdit(vertexIndex, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const dragProps = computed(() =>\n isEnabled()\n ? {\n onPointerdown: handleDragStart,\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n }\n : {},\n );\n\n return { dragProps, createResizeProps, createVertexProps };\n}\n","import { toRaw, isRef, isReactive, isProxy } from 'vue';\n\nexport function deepToRaw<T extends Record<string, any>>(sourceObj: T): T {\n const objectIterator = (input: any): any => {\n if (Array.isArray(input)) {\n return input.map((item) => objectIterator(item));\n }\n if (isRef(input) || isReactive(input) || isProxy(input)) {\n return objectIterator(toRaw(input));\n }\n if (input && typeof input === 'object') {\n return Object.keys(input).reduce((acc, key) => {\n acc[key as keyof typeof acc] = objectIterator(input[key]);\n return acc;\n }, {} as T);\n }\n return input;\n };\n\n return objectIterator(sourceObj);\n}\n","import { ref } from 'vue';\n\ntype DoublePressOptions = {\n delay?: number; // ms between taps\n tolerancePx?: number; // spatial tolerance\n};\n\ntype DoubleHandler = ((e: PointerEvent | MouseEvent) => void) | undefined;\n\ntype DoubleProps = {\n onDblclick?: (e: MouseEvent) => void;\n onPointerupCapture?: (e: PointerEvent) => void;\n};\n\n/**\n * Vue composable for handling double-press/double-tap interactions.\n *\n * @param onDouble - Callback to invoke on double press/tap\n * @param options - Configuration for delay and spatial tolerance\n * @returns Event handler props to be spread on an element with v-bind\n *\n * @example\n * ```vue\n * <script setup>\n * import { useDoublePressProps } from '@embedpdf/utils/vue';\n *\n * const handleDoubleClick = (e) => {\n * console.log('Double clicked!');\n * };\n *\n * const doubleProps = useDoublePressProps(handleDoubleClick);\n * </script>\n *\n * <template>\n * <div v-bind=\"doubleProps\">\n * Double click/tap me\n * </div>\n * </template>\n * ```\n */\nexport function useDoublePressProps(\n onDouble?: DoubleHandler,\n { delay = 300, tolerancePx = 18 }: DoublePressOptions = {},\n): DoubleProps {\n const last = ref({ t: 0, x: 0, y: 0 });\n\n const handlePointerUp = (e: PointerEvent) => {\n if (!onDouble) return;\n\n // Ignore mouse (it will use native dblclick),\n // and ignore non-primary pointers (multi-touch, etc.)\n if (e.pointerType === 'mouse' || e.isPrimary === false) return;\n\n const now = performance.now();\n const x = e.clientX;\n const y = e.clientY;\n\n const withinTime = now - last.value.t <= delay;\n const dx = x - last.value.x;\n const dy = y - last.value.y;\n const withinDist = dx * dx + dy * dy <= tolerancePx * tolerancePx;\n\n if (withinTime && withinDist) {\n onDouble?.(e);\n }\n\n last.value = { t: now, x, y };\n };\n\n const handleDouble = (e: MouseEvent) => {\n onDouble?.(e);\n };\n\n return onDouble\n ? {\n // Vue uses lowercase 'c' in dblclick\n onDblclick: handleDouble,\n onPointerupCapture: handlePointerUp,\n }\n : {};\n}\n","import { computed, type CSSProperties } from 'vue';\nimport { useDragResize, type UseDragResizeOptions } from './use-drag-resize';\nimport {\n describeResizeFromConfig,\n describeVerticesFromConfig,\n type ResizeUI,\n type VertexUI,\n} from '../../shared/plugin-interaction-primitives/utils';\nimport type { Position, Rect } from '@embedpdf/models';\nimport { norm, rectDTO, vertsDTO } from '../utils/interaction-normalize';\n\nexport type HandleElementProps = {\n key: string | number;\n style: CSSProperties;\n onPointerdown: (e: PointerEvent) => void;\n onPointermove: (e: PointerEvent) => void;\n onPointerup: (e: PointerEvent) => void;\n onPointercancel: (e: PointerEvent) => void;\n} & Record<string, any>;\n\nexport interface UseInteractionHandlesOptions {\n controller: UseDragResizeOptions; // may contain refs\n resizeUI?: ResizeUI;\n vertexUI?: VertexUI;\n includeVertices?: boolean;\n handleAttrs?: (\n h: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w',\n ) => Record<string, any> | void;\n vertexAttrs?: (i: number) => Record<string, any> | void;\n}\n\nexport function useInteractionHandles(opts: UseInteractionHandlesOptions) {\n const {\n controller,\n resizeUI,\n vertexUI,\n includeVertices = false,\n handleAttrs,\n vertexAttrs,\n } = opts;\n\n // Owns live interaction handlers\n const { dragProps, createResizeProps, createVertexProps } = useDragResize(controller);\n\n // Plain snapshots for the *descriptor* helpers\n const elementPlain = computed<Rect>(() => rectDTO(norm(controller.element)));\n const verticesPlain = computed<Position[] | undefined>(() =>\n controller.vertices ? vertsDTO(norm(controller.vertices)) : undefined,\n );\n const scalePlain = computed<number>(() => Number(norm(controller.scale ?? 1)));\n const rotationPlain = computed<number>(() => Number(norm(controller.pageRotation ?? 0)));\n const maintainPlain = computed<boolean | undefined>(() =>\n controller.maintainAspectRatio === undefined\n ? undefined\n : Boolean(norm(controller.maintainAspectRatio)),\n );\n const constraintsPlain = computed(() => norm(controller.constraints ?? undefined));\n\n const resize = computed<HandleElementProps[]>(() => {\n const desc = describeResizeFromConfig(\n {\n element: elementPlain.value,\n scale: scalePlain.value,\n pageRotation: rotationPlain.value,\n maintainAspectRatio: maintainPlain.value,\n constraints: constraintsPlain.value,\n },\n resizeUI,\n );\n return desc.map((d) => ({\n key: (d.attrs?.['data-epdf-handle'] as string) ?? d.handle,\n style: d.style as CSSProperties,\n ...createResizeProps(d.handle),\n ...(d.attrs ?? {}),\n ...(handleAttrs?.(d.handle) ?? {}),\n }));\n });\n\n const vertices = computed<HandleElementProps[]>(() => {\n if (!includeVertices) return [];\n const verts = verticesPlain.value ?? [];\n const desc = describeVerticesFromConfig(\n { element: elementPlain.value, scale: scalePlain.value, vertices: verts },\n vertexUI,\n verts,\n );\n return desc.map((d, i) => ({\n key: i,\n style: d.style as CSSProperties,\n ...createVertexProps(i),\n ...(d.attrs ?? {}),\n ...(vertexAttrs?.(i) ?? {}),\n }));\n });\n\n return { dragProps, resize, vertices };\n}\n"],"names":["props","__props","counterRotation","computed","getCounterRotation","rect","rotation","menuWrapperProps","style","position","left","origin","x","top","y","transform","value","matrix","transformOrigin","width","height","pointerEvents","zIndex","onPointerdown","e","stopPropagation","preventDefault","onTouchstart","adjustedRect","size","_renderSlot","_ctx","$slots","DragResizeController","constructor","config","onUpdate","this","state","startPoint","startElement","activeHandle","currentPosition","activeVertexIndex","startVertices","currentVertices","vertices","updateConfig","startDrag","clientX","clientY","element","transformData","type","changes","startResize","handle","metadata","maintainAspectRatio","startVertexEdit","vertexIndex","length","move","delta","calculateDelta","calculateDragPosition","calculateResizePosition","calculateVertexPosition","end","wasState","finalPosition","getCurrentPosition","reset","cancel","rawDelta","transformDelta","pageRotation","scale","rad","Math","PI","cos","sin","scaledX","scaledY","clampPoint","p","bbox","_a","constraints","boundingBox","max","min","newVertices","currentVertex","moved","applyConstraints","aspectRatio","includes","newWidth","widthDiff","newHeight","heightDiff","abs","minWidth","minHeight","maxWidth","maxHeight","diagonalCursor","rot","nw","ne","sw","se","edgeOffset","k","spacing","mode","base","norm","v","toRaw","isRef","unref","toNum","n","fallback","Number","isFinite","rectDTO","r","_b","_c","_d","vertsDTO","arr","map","boolDTO","b","Boolean","numDTO","constraintsDTO","c","useDragResize","options","controller","ref","enabled","initialCfg","markRaw","ev","watch","nc","deep","onUnmounted","isEnabled","handleDragStart","currentTarget","setPointerCapture","call","pointerId","handleMove","handleEnd","releasePointerCapture","handleCancel","dragProps","onPointermove","onPointerup","onPointercancel","createResizeProps","createVertexProps","sourceObj","objectIterator","input","Array","isArray","item","isReactive","isProxy","Object","keys","reduce","acc","key","onDouble","delay","tolerancePx","last","t","onDblclick","onPointerupCapture","pointerType","isPrimary","now","performance","withinTime","dx","dy","opts","resizeUI","vertexUI","includeVertices","handleAttrs","vertexAttrs","elementPlain","verticesPlain","scalePlain","rotationPlain","maintainPlain","constraintsPlain","resize","cfg","ui","handleSize","offsetMode","includeSides","rotationAwareCursor","off","edge","pos","borderRadius","cursor","touchAction","attrs","describeResizeFromConfig","d","verts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AAAvI,EAAU,sBAAkCyI,EAAEzK,OACpDhD,MAAOyN,EAAEzN,SACNiK,EAAkBwD,EAAEzK,WACnByK,EAAEF,OAAS,CAAA,MACX,MAAArB,OAAA,EAAAA,EAAcuB,EAAEzK,UAAW,CAAA,MAqBPV,SAjBX3C,EAAAA,SAA+B,KAC9C,IAAKsM,EAAiB,MAAO,GAC7B,MAAMyB,EAAQrB,EAAc7L,OAAS,GAMrC,OLeG,SACLmM,EACAC,EAAe,CAAA,EACfe,GAEA,MAAMC,WAAEA,EAAa,GAAA9M,OAAIA,EAAS,GAAM8L,EAClC/M,EAAa8M,EAAIhK,QACjB0B,EAAQsI,EAAItI,OAAS,EAG3B,OAFcsJ,GAAgBhB,EAAIrK,UAAY,IAEjC0F,IAAI,CAAChB,EAAG6G,KAGZ,CACL7K,OAAQ,KACRhD,MAAO,CACLC,SAAU,WACVC,MANU8G,EAAE5G,EAAIP,EAAKM,OAAOC,GAAKiE,EAAQuJ,EAAa,EAMzC,KACbvN,KANS2G,EAAE1G,EAAIT,EAAKM,OAAOG,GAAK+D,EAAQuJ,EAAa,EAM1C,KACXjN,MAAOiN,EAAa,KACpBhN,OAAQgN,EAAa,KACrBR,aAAc,MACdC,OAAQ,UACRvM,SACAwM,YAAa,QAEfC,MAAO,CAAE,mBAAoBM,KAGnC,CKjDiBC,CACX,CAAEnL,QAASyJ,EAAa5L,MAAO6D,MAAOiI,EAAW9L,MAAO8B,SAAUoL,GAClE1B,EACA0B,GAEU1F,IAAI,CAACyF,EAAGI,KAAA,CAClB9C,IAAK8C,EACL7N,MAAOyN,EAAEzN,SACNkK,EAAkB2D,MACjBJ,EAAEF,OAAS,CAAA,MACX,MAAApB,OAAA,EAAAA,EAAc0B,KAAM,CAAA,OAK9B"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/components/counter-rotate-container.vue","../../src/shared/plugin-interaction-primitives/drag-resize-controller.ts","../../src/shared/plugin-interaction-primitives/utils.ts","../../src/vue/utils/interaction-normalize.ts","../../src/vue/hooks/use-drag-resize.ts","../../src/vue/utils/deep-to-raw.ts","../../src/vue/hooks/use-double-press-props.ts","../../src/vue/hooks/use-interaction-handles.ts"],"sourcesContent":["<template>\n <slot\n :menu-wrapper-props=\"menuWrapperProps\"\n :matrix=\"counterRotation.matrix\"\n :rect=\"adjustedRect\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, type CSSProperties } from 'vue';\nimport type { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nconst props = defineProps<CounterRotateProps>();\n\nconst counterRotation = computed(() => getCounterRotation(props.rect, props.rotation));\n\nconst menuWrapperProps = computed(() => ({\n style: {\n position: 'absolute',\n left: `${props.rect.origin.x}px`,\n top: `${props.rect.origin.y}px`,\n transform: counterRotation.value.matrix,\n transformOrigin: '0 0',\n width: `${counterRotation.value.width}px`,\n height: `${counterRotation.value.height}px`,\n pointerEvents: 'none',\n zIndex: 3,\n } as CSSProperties,\n onPointerdown: (e: PointerEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n onTouchstart: (e: TouchEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n}));\n\nconst adjustedRect = computed(() => ({\n origin: { x: props.rect.origin.x, y: props.rect.origin.y },\n size: { width: counterRotation.value.width, height: counterRotation.value.height },\n}));\n</script>\n","import { Position, Rect } from '@embedpdf/models';\n\nexport interface DragResizeConfig {\n element: Rect;\n vertices?: Position[];\n constraints?: {\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n boundingBox?: { width: number; height: number }; // page bounds\n };\n maintainAspectRatio?: boolean;\n pageRotation?: number;\n scale?: number;\n}\n\nexport type InteractionState = 'idle' | 'dragging' | 'resizing' | 'vertex-editing';\nexport type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w';\n\nexport interface TransformData {\n type: 'move' | 'resize' | 'vertex-edit';\n changes: {\n rect?: Rect;\n vertices?: Position[];\n };\n metadata?: {\n handle?: ResizeHandle;\n vertexIndex?: number;\n maintainAspectRatio?: boolean;\n };\n}\n\nexport interface InteractionEvent {\n state: 'start' | 'move' | 'end';\n transformData?: TransformData;\n}\n\n/** Anchor describes which edges stay fixed when resizing. */\ntype Anchor = {\n x: 'left' | 'right' | 'center';\n y: 'top' | 'bottom' | 'center';\n};\n\n/**\n * Derive anchor from handle.\n * - 'e' means we're dragging east → left edge is anchored\n * - 'nw' means we're dragging north-west → bottom-right corner is anchored\n */\nfunction getAnchor(handle: ResizeHandle): Anchor {\n return {\n x: handle.includes('e') ? 'left' : handle.includes('w') ? 'right' : 'center',\n y: handle.includes('s') ? 'top' : handle.includes('n') ? 'bottom' : 'center',\n };\n}\n\n/**\n * Pure geometric controller that manages drag/resize/vertex-edit logic.\n */\nexport class DragResizeController {\n private state: InteractionState = 'idle';\n private startPoint: Position | null = null;\n private startElement: Rect | null = null;\n private activeHandle: ResizeHandle | null = null;\n private currentPosition: Rect | null = null;\n\n // Vertex editing state - pure geometric\n private activeVertexIndex: number | null = null;\n private startVertices: Position[] = [];\n private currentVertices: Position[] = [];\n\n constructor(\n private config: DragResizeConfig,\n private onUpdate: (event: InteractionEvent) => void,\n ) {\n this.currentVertices = config.vertices || [];\n }\n\n updateConfig(config: Partial<DragResizeConfig>) {\n this.config = { ...this.config, ...config };\n this.currentVertices = config.vertices || [];\n }\n\n startDrag(clientX: number, clientY: number) {\n this.state = 'dragging';\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'move',\n changes: {\n rect: this.startElement,\n },\n },\n });\n }\n\n startResize(handle: ResizeHandle, clientX: number, clientY: number) {\n this.state = 'resizing';\n this.activeHandle = handle;\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n startVertexEdit(vertexIndex: number, clientX: number, clientY: number) {\n // Refresh vertices from latest config before validating index\n this.currentVertices = [...(this.config.vertices ?? this.currentVertices)];\n if (vertexIndex < 0 || vertexIndex >= this.currentVertices.length) return;\n\n this.state = 'vertex-editing';\n this.activeVertexIndex = vertexIndex;\n this.startPoint = { x: clientX, y: clientY };\n this.startVertices = [...this.currentVertices];\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex,\n },\n },\n });\n }\n\n move(clientX: number, clientY: number) {\n if (this.state === 'idle' || !this.startPoint) return;\n\n if (this.state === 'dragging' && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateDragPosition(delta);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'move',\n changes: {\n rect: position,\n },\n },\n });\n } else if (this.state === 'resizing' && this.activeHandle && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateResizePosition(delta, this.activeHandle);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'resize',\n changes: {\n rect: position,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n } else if (this.state === 'vertex-editing' && this.activeVertexIndex !== null) {\n const vertices = this.calculateVertexPosition(clientX, clientY);\n this.currentVertices = vertices;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex,\n },\n },\n });\n }\n }\n\n end() {\n if (this.state === 'idle') return;\n\n const wasState = this.state;\n const handle = this.activeHandle;\n const vertexIndex = this.activeVertexIndex;\n\n if (wasState === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.currentVertices,\n },\n metadata: {\n vertexIndex: vertexIndex || undefined,\n },\n },\n });\n } else {\n const finalPosition = this.getCurrentPosition();\n this.onUpdate({\n state: 'end',\n transformData: {\n type: wasState === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: finalPosition,\n },\n metadata:\n wasState === 'dragging'\n ? undefined\n : {\n handle: handle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n cancel() {\n if (this.state === 'idle') return;\n\n if (this.state === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex || undefined,\n },\n },\n });\n } else if (this.startElement) {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: this.state === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata:\n this.state === 'dragging'\n ? undefined\n : {\n handle: this.activeHandle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n private reset() {\n this.state = 'idle';\n this.startPoint = null;\n this.startElement = null;\n this.activeHandle = null;\n this.currentPosition = null;\n this.activeVertexIndex = null;\n this.startVertices = [];\n }\n\n private getCurrentPosition() {\n return this.currentPosition || this.config.element;\n }\n\n private calculateDelta(clientX: number, clientY: number): Position {\n if (!this.startPoint) return { x: 0, y: 0 };\n\n const rawDelta: Position = {\n x: clientX - this.startPoint.x,\n y: clientY - this.startPoint.y,\n };\n\n return this.transformDelta(rawDelta);\n }\n\n private transformDelta(delta: Position): Position {\n const { pageRotation = 0, scale = 1 } = this.config;\n\n const rad = (pageRotation * Math.PI) / 2;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n\n const scaledX = delta.x / scale;\n const scaledY = delta.y / scale;\n\n return {\n x: cos * scaledX + sin * scaledY,\n y: -sin * scaledX + cos * scaledY,\n };\n }\n\n private clampPoint(p: Position): Position {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return p;\n return {\n x: Math.max(0, Math.min(p.x, bbox.width)),\n y: Math.max(0, Math.min(p.y, bbox.height)),\n };\n }\n\n private calculateVertexPosition(clientX: number, clientY: number): Position[] {\n if (this.activeVertexIndex === null) return this.startVertices;\n\n const delta = this.calculateDelta(clientX, clientY);\n const newVertices = [...this.startVertices];\n const currentVertex = newVertices[this.activeVertexIndex];\n\n const moved = {\n x: currentVertex.x + delta.x,\n y: currentVertex.y + delta.y,\n };\n newVertices[this.activeVertexIndex] = this.clampPoint(moved);\n\n return newVertices;\n }\n\n private calculateDragPosition(delta: Position): Rect {\n if (!this.startElement) return this.config.element;\n\n const position: Rect = {\n origin: {\n x: this.startElement.origin.x + delta.x,\n y: this.startElement.origin.y + delta.y,\n },\n size: {\n width: this.startElement.size.width,\n height: this.startElement.size.height,\n },\n };\n\n return this.applyConstraints(position);\n }\n\n /**\n * Calculate the new rect after a resize operation.\n * Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints\n */\n private calculateResizePosition(delta: Position, handle: ResizeHandle): Rect {\n if (!this.startElement) return this.config.element;\n\n const anchor = getAnchor(handle);\n const aspectRatio = this.startElement.size.width / this.startElement.size.height || 1;\n\n // Step 1: Apply delta to get raw resize\n let rect = this.applyResizeDelta(delta, anchor);\n\n // Step 2: Enforce aspect ratio if enabled\n if (this.config.maintainAspectRatio) {\n rect = this.enforceAspectRatio(rect, anchor, aspectRatio);\n }\n\n // Step 3: Clamp to bounding box\n rect = this.clampToBounds(rect, anchor, aspectRatio);\n\n // Step 4: Apply min/max constraints\n return this.applyConstraints(rect);\n }\n\n /**\n * Apply the mouse delta to produce a raw (unconstrained) resized rect.\n */\n private applyResizeDelta(delta: Position, anchor: Anchor): Rect {\n const start = this.startElement!;\n let x = start.origin.x;\n let y = start.origin.y;\n let width = start.size.width;\n let height = start.size.height;\n\n // Horizontal: if anchor is left, right edge moves; if anchor is right, left edge moves\n if (anchor.x === 'left') {\n width += delta.x;\n } else if (anchor.x === 'right') {\n x += delta.x;\n width -= delta.x;\n }\n // anchor.x === 'center' means no horizontal resize from this handle\n\n // Vertical: if anchor is top, bottom edge moves; if anchor is bottom, top edge moves\n if (anchor.y === 'top') {\n height += delta.y;\n } else if (anchor.y === 'bottom') {\n y += delta.y;\n height -= delta.y;\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n /**\n * Enforce aspect ratio while respecting the anchor.\n * For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.\n * For corner handles, the anchor corner stays fixed.\n */\n private enforceAspectRatio(rect: Rect, anchor: Anchor, aspectRatio: number): Rect {\n const start = this.startElement!;\n let { x, y } = rect.origin;\n let { width, height } = rect.size;\n\n const isEdgeHandle = anchor.x === 'center' || anchor.y === 'center';\n\n if (isEdgeHandle) {\n // Edge handle: one dimension drives, the other follows, centered on the non-moving axis\n if (anchor.y === 'center') {\n // Horizontal edge (e/w): width is primary\n height = width / aspectRatio;\n // Center vertically relative to original\n y = start.origin.y + (start.size.height - height) / 2;\n } else {\n // Vertical edge (n/s): height is primary\n width = height * aspectRatio;\n // Center horizontally relative to original\n x = start.origin.x + (start.size.width - width) / 2;\n }\n } else {\n // Corner handle: pick the dominant axis based on which changed more\n const dw = Math.abs(width - start.size.width);\n const dh = Math.abs(height - start.size.height);\n\n if (dw >= dh) {\n height = width / aspectRatio;\n } else {\n width = height * aspectRatio;\n }\n }\n\n // Reposition based on anchor\n if (anchor.x === 'right') {\n x = start.origin.x + start.size.width - width;\n }\n if (anchor.y === 'bottom') {\n y = start.origin.y + start.size.height - height;\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n /**\n * Clamp rect to bounding box while respecting anchor and aspect ratio.\n */\n private clampToBounds(rect: Rect, anchor: Anchor, aspectRatio: number): Rect {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return rect;\n\n const start = this.startElement!;\n let { x, y } = rect.origin;\n let { width, height } = rect.size;\n\n // Ensure positive dimensions\n width = Math.max(1, width);\n height = Math.max(1, height);\n\n // Calculate anchor points (the edges/corners that must stay fixed)\n const anchorX = anchor.x === 'left' ? start.origin.x : start.origin.x + start.size.width;\n const anchorY = anchor.y === 'top' ? start.origin.y : start.origin.y + start.size.height;\n\n // Calculate max available space from anchor\n const maxW =\n anchor.x === 'left'\n ? bbox.width - anchorX\n : anchor.x === 'right'\n ? anchorX\n : Math.min(start.origin.x, bbox.width - start.origin.x - start.size.width) * 2 +\n start.size.width;\n\n const maxH =\n anchor.y === 'top'\n ? bbox.height - anchorY\n : anchor.y === 'bottom'\n ? anchorY\n : Math.min(start.origin.y, bbox.height - start.origin.y - start.size.height) * 2 +\n start.size.height;\n\n if (this.config.maintainAspectRatio) {\n // Find the scaling factor that fits both constraints\n const scaleW = width > maxW ? maxW / width : 1;\n const scaleH = height > maxH ? maxH / height : 1;\n const scale = Math.min(scaleW, scaleH);\n\n if (scale < 1) {\n width *= scale;\n height *= scale;\n }\n } else {\n // Clamp independently\n width = Math.min(width, maxW);\n height = Math.min(height, maxH);\n }\n\n // Recompute position based on anchor\n if (anchor.x === 'left') {\n x = anchorX;\n } else if (anchor.x === 'right') {\n x = anchorX - width;\n } else {\n x = start.origin.x + (start.size.width - width) / 2;\n }\n\n if (anchor.y === 'top') {\n y = anchorY;\n } else if (anchor.y === 'bottom') {\n y = anchorY - height;\n } else {\n y = start.origin.y + (start.size.height - height) / 2;\n }\n\n // Final clamp to ensure we're within bounds (handles center anchor edge cases)\n x = Math.max(0, Math.min(x, bbox.width - width));\n y = Math.max(0, Math.min(y, bbox.height - height));\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n private applyConstraints(position: Rect): Rect {\n const { constraints } = this.config;\n if (!constraints) return position;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = position;\n\n const minW = constraints.minWidth ?? 1;\n const minH = constraints.minHeight ?? 1;\n const maxW = constraints.maxWidth;\n const maxH = constraints.maxHeight;\n\n if (this.config.maintainAspectRatio && width > 0 && height > 0) {\n const ratio = width / height;\n\n // Enforce mins (scale up)\n if (width < minW) {\n width = minW;\n height = width / ratio;\n }\n if (height < minH) {\n height = minH;\n width = height * ratio;\n }\n\n // Enforce maxes (scale down)\n if (maxW !== undefined && width > maxW) {\n width = maxW;\n height = width / ratio;\n }\n if (maxH !== undefined && height > maxH) {\n height = maxH;\n width = height * ratio;\n }\n } else {\n width = Math.max(minW, width);\n height = Math.max(minH, height);\n if (maxW !== undefined) width = Math.min(maxW, width);\n if (maxH !== undefined) height = Math.min(maxH, height);\n }\n\n // Clamp position to bounding box\n if (constraints.boundingBox) {\n x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));\n y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n}\n","import type { Position, Rect } from '@embedpdf/models';\nimport type { ResizeHandle, DragResizeConfig } from './drag-resize-controller';\n\nexport type QuarterTurns = 0 | 1 | 2 | 3;\n\nexport interface ResizeUI {\n handleSize?: number; // px (default 8)\n spacing?: number; // px distance from the box edge (default 1)\n offsetMode?: 'outside' | 'inside' | 'center'; // default 'outside'\n includeSides?: boolean; // default false\n zIndex?: number; // default 3\n rotationAwareCursor?: boolean; // default true\n}\n\nexport interface VertexUI {\n vertexSize?: number; // px (default 12)\n zIndex?: number; // default 4\n}\n\nexport interface HandleDescriptor {\n handle: ResizeHandle;\n style: Record<string, number | string>;\n attrs?: Record<string, any>;\n}\n\nfunction diagonalCursor(handle: ResizeHandle, rot: QuarterTurns): string {\n // Standard cursors; diagonals flip on odd quarter-turns\n const diag0: Record<'nw' | 'ne' | 'sw' | 'se', string> = {\n nw: 'nwse-resize',\n ne: 'nesw-resize',\n sw: 'nesw-resize',\n se: 'nwse-resize',\n };\n if (handle === 'n' || handle === 's') return 'ns-resize';\n if (handle === 'e' || handle === 'w') return 'ew-resize';\n if (rot % 2 === 0) return diag0[handle as 'nw' | 'ne' | 'sw' | 'se'];\n return { nw: 'nesw-resize', ne: 'nwse-resize', sw: 'nwse-resize', se: 'nesw-resize' }[\n handle as 'nw' | 'ne' | 'sw' | 'se'\n ]!;\n}\n\nfunction edgeOffset(k: number, spacing: number, mode: 'outside' | 'inside' | 'center') {\n // Base puts the handle centered on the edge\n const base = -k / 2;\n if (mode === 'center') return base;\n // outside moves further out (more negative), inside moves in (less negative)\n return mode === 'outside' ? base - spacing : base + spacing;\n}\n\nexport function describeResizeFromConfig(\n cfg: DragResizeConfig,\n ui: ResizeUI = {},\n): HandleDescriptor[] {\n const {\n handleSize = 8,\n spacing = 1,\n offsetMode = 'outside',\n includeSides = false,\n zIndex = 3,\n rotationAwareCursor = true,\n } = ui;\n\n const rotation = ((cfg.pageRotation ?? 0) % 4) as QuarterTurns;\n\n const off = (edge: 'top' | 'right' | 'bottom' | 'left') => ({\n [edge]: edgeOffset(handleSize, spacing, offsetMode) + 'px',\n });\n\n const corners: Array<[ResizeHandle, Record<string, number | string>]> = [\n ['nw', { ...off('top'), ...off('left') }],\n ['ne', { ...off('top'), ...off('right') }],\n ['sw', { ...off('bottom'), ...off('left') }],\n ['se', { ...off('bottom'), ...off('right') }],\n ];\n const sides: Array<[ResizeHandle, Record<string, number | string>]> = includeSides\n ? [\n ['n', { ...off('top'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['s', { ...off('bottom'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['w', { ...off('left'), top: `calc(50% - ${handleSize / 2}px)` }],\n ['e', { ...off('right'), top: `calc(50% - ${handleSize / 2}px)` }],\n ]\n : [];\n\n const all = [...corners, ...sides];\n\n return all.map(([handle, pos]) => ({\n handle,\n style: {\n position: 'absolute',\n width: handleSize + 'px',\n height: handleSize + 'px',\n borderRadius: '50%',\n zIndex,\n cursor: rotationAwareCursor ? diagonalCursor(handle, rotation) : 'default',\n touchAction: 'none',\n ...(pos as any),\n },\n attrs: { 'data-epdf-handle': handle },\n }));\n}\n\nexport function describeVerticesFromConfig(\n cfg: DragResizeConfig,\n ui: VertexUI = {},\n liveVertices?: Position[],\n): HandleDescriptor[] {\n const { vertexSize = 12, zIndex = 4 } = ui;\n const rect: Rect = cfg.element;\n const scale = cfg.scale ?? 1;\n const verts = liveVertices ?? cfg.vertices ?? [];\n\n return verts.map((v, i) => {\n const left = (v.x - rect.origin.x) * scale - vertexSize / 2;\n const top = (v.y - rect.origin.y) * scale - vertexSize / 2;\n return {\n handle: 'nw', // not used; kept for type\n style: {\n position: 'absolute',\n left: left + 'px',\n top: top + 'px',\n width: vertexSize + 'px',\n height: vertexSize + 'px',\n borderRadius: '50%',\n cursor: 'pointer',\n zIndex,\n touchAction: 'none',\n },\n attrs: { 'data-epdf-vertex': i },\n };\n });\n}\n","import { isRef, unref, toRaw, type Ref } from 'vue';\nimport type { Rect, Position } from '@embedpdf/models';\nimport type { DragResizeConfig } from '../../shared/plugin-interaction-primitives';\n\nexport type MaybeRef<T> = T | Ref<T>;\n\nexport const norm = <T>(v: MaybeRef<T>): T => toRaw(isRef(v) ? unref(v) : (v as T));\n\nexport const toNum = (n: unknown, fallback = 0): number => {\n const v = Number(n);\n return Number.isFinite(v) ? v : fallback;\n};\n\nexport const rectDTO = (r: any): Rect => ({\n origin: { x: toNum(r?.origin?.x), y: toNum(r?.origin?.y) },\n size: { width: toNum(r?.size?.width), height: toNum(r?.size?.height) },\n});\n\nexport const vertsDTO = (arr: any[] = []): Position[] =>\n arr.map((p) => ({ x: toNum(p?.x), y: toNum(p?.y) }));\n\nexport const boolDTO = (b: unknown): boolean | undefined =>\n b === undefined ? undefined : Boolean(b);\n\nexport const numDTO = (n: unknown): number | undefined => (n === undefined ? undefined : toNum(n));\n\nexport const constraintsDTO = (\n c: MaybeRef<DragResizeConfig['constraints']> | undefined,\n): DragResizeConfig['constraints'] | undefined => (c ? norm(c) : undefined);\n","import { ref, watch, computed, onUnmounted, markRaw, type Ref } from 'vue';\nimport type { Position, Rect } from '@embedpdf/models';\nimport {\n DragResizeController,\n type DragResizeConfig,\n type InteractionEvent,\n type ResizeHandle,\n} from '../../shared/plugin-interaction-primitives';\nimport {\n norm,\n rectDTO,\n vertsDTO,\n constraintsDTO,\n boolDTO,\n numDTO,\n type MaybeRef,\n} from '../utils/interaction-normalize';\n\nexport interface UseDragResizeOptions {\n element: MaybeRef<Rect>;\n vertices?: MaybeRef<Position[]>;\n constraints?: MaybeRef<DragResizeConfig['constraints']>;\n maintainAspectRatio?: MaybeRef<boolean>;\n pageRotation?: MaybeRef<number>;\n scale?: MaybeRef<number>;\n onUpdate?: (event: InteractionEvent) => void;\n enabled?: MaybeRef<boolean>;\n}\n\nexport function useDragResize(options: UseDragResizeOptions) {\n const controller = ref<DragResizeController | null>(null);\n\n const {\n onUpdate,\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n enabled,\n } = options;\n\n // Build initial plain config\n const initialCfg: DragResizeConfig = {\n element: rectDTO(norm(element)),\n vertices: vertices ? vertsDTO(norm(vertices)) : undefined,\n constraints: constraintsDTO(constraints),\n maintainAspectRatio: boolDTO(enabled === undefined ? undefined : norm(maintainAspectRatio!)),\n pageRotation: numDTO(pageRotation === undefined ? undefined : norm(pageRotation!)),\n scale: numDTO(scale === undefined ? undefined : norm(scale!)),\n };\n\n if (!controller.value) {\n controller.value = markRaw(new DragResizeController(initialCfg, (ev) => onUpdate?.(ev)));\n }\n\n // Reactive updates → always normalize before passing to controller\n watch(\n () => ({\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n }),\n (nc) => {\n controller.value?.updateConfig({\n element: rectDTO(norm(nc.element)),\n vertices: nc.vertices ? vertsDTO(norm(nc.vertices)) : undefined,\n constraints: constraintsDTO(nc.constraints),\n maintainAspectRatio: boolDTO(\n nc.maintainAspectRatio === undefined ? undefined : norm(nc.maintainAspectRatio!),\n ),\n pageRotation: numDTO(nc.pageRotation === undefined ? undefined : norm(nc.pageRotation!)),\n scale: numDTO(nc.scale === undefined ? undefined : norm(nc.scale!)),\n });\n },\n { deep: true },\n );\n\n onUnmounted(() => {\n controller.value = null;\n });\n\n const isEnabled = () => Boolean(enabled === undefined ? true : norm(enabled));\n\n // Pointer handlers\n const handleDragStart = (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startDrag(e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n };\n const handleMove = (e: PointerEvent) => controller.value?.move(e.clientX, e.clientY);\n const handleEnd = (e: PointerEvent) => {\n controller.value?.end();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n const handleCancel = (e: PointerEvent) => {\n controller.value?.cancel();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n\n const createResizeProps = (handle: ResizeHandle) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startResize(handle, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const createVertexProps = (vertexIndex: number) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startVertexEdit(vertexIndex, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const dragProps = computed(() =>\n isEnabled()\n ? {\n onPointerdown: handleDragStart,\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n }\n : {},\n );\n\n return { dragProps, createResizeProps, createVertexProps };\n}\n","import { toRaw, isRef, isReactive, isProxy } from 'vue';\n\nexport function deepToRaw<T extends Record<string, any>>(sourceObj: T): T {\n const objectIterator = (input: any): any => {\n if (Array.isArray(input)) {\n return input.map((item) => objectIterator(item));\n }\n if (isRef(input) || isReactive(input) || isProxy(input)) {\n return objectIterator(toRaw(input));\n }\n if (input && typeof input === 'object') {\n return Object.keys(input).reduce((acc, key) => {\n acc[key as keyof typeof acc] = objectIterator(input[key]);\n return acc;\n }, {} as T);\n }\n return input;\n };\n\n return objectIterator(sourceObj);\n}\n","import { ref } from 'vue';\n\ntype DoublePressOptions = {\n delay?: number; // ms between taps\n tolerancePx?: number; // spatial tolerance\n};\n\ntype DoubleHandler = ((e: PointerEvent | MouseEvent) => void) | undefined;\n\ntype DoubleProps = {\n onDblclick?: (e: MouseEvent) => void;\n onPointerupCapture?: (e: PointerEvent) => void;\n};\n\n/**\n * Vue composable for handling double-press/double-tap interactions.\n *\n * @param onDouble - Callback to invoke on double press/tap\n * @param options - Configuration for delay and spatial tolerance\n * @returns Event handler props to be spread on an element with v-bind\n *\n * @example\n * ```vue\n * <script setup>\n * import { useDoublePressProps } from '@embedpdf/utils/vue';\n *\n * const handleDoubleClick = (e) => {\n * console.log('Double clicked!');\n * };\n *\n * const doubleProps = useDoublePressProps(handleDoubleClick);\n * </script>\n *\n * <template>\n * <div v-bind=\"doubleProps\">\n * Double click/tap me\n * </div>\n * </template>\n * ```\n */\nexport function useDoublePressProps(\n onDouble?: DoubleHandler,\n { delay = 300, tolerancePx = 18 }: DoublePressOptions = {},\n): DoubleProps {\n const last = ref({ t: 0, x: 0, y: 0 });\n\n const handlePointerUp = (e: PointerEvent) => {\n if (!onDouble) return;\n\n // Ignore mouse (it will use native dblclick),\n // and ignore non-primary pointers (multi-touch, etc.)\n if (e.pointerType === 'mouse' || e.isPrimary === false) return;\n\n const now = performance.now();\n const x = e.clientX;\n const y = e.clientY;\n\n const withinTime = now - last.value.t <= delay;\n const dx = x - last.value.x;\n const dy = y - last.value.y;\n const withinDist = dx * dx + dy * dy <= tolerancePx * tolerancePx;\n\n if (withinTime && withinDist) {\n onDouble?.(e);\n }\n\n last.value = { t: now, x, y };\n };\n\n const handleDouble = (e: MouseEvent) => {\n onDouble?.(e);\n };\n\n return onDouble\n ? {\n // Vue uses lowercase 'c' in dblclick\n onDblclick: handleDouble,\n onPointerupCapture: handlePointerUp,\n }\n : {};\n}\n","import { computed, type CSSProperties } from 'vue';\nimport { useDragResize, type UseDragResizeOptions } from './use-drag-resize';\nimport {\n describeResizeFromConfig,\n describeVerticesFromConfig,\n type ResizeUI,\n type VertexUI,\n} from '../../shared/plugin-interaction-primitives/utils';\nimport type { Position, Rect } from '@embedpdf/models';\nimport { norm, rectDTO, vertsDTO } from '../utils/interaction-normalize';\n\nexport type HandleElementProps = {\n key: string | number;\n style: CSSProperties;\n onPointerdown: (e: PointerEvent) => void;\n onPointermove: (e: PointerEvent) => void;\n onPointerup: (e: PointerEvent) => void;\n onPointercancel: (e: PointerEvent) => void;\n} & Record<string, any>;\n\nexport interface UseInteractionHandlesOptions {\n controller: UseDragResizeOptions; // may contain refs\n resizeUI?: ResizeUI;\n vertexUI?: VertexUI;\n includeVertices?: boolean;\n handleAttrs?: (\n h: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w',\n ) => Record<string, any> | void;\n vertexAttrs?: (i: number) => Record<string, any> | void;\n}\n\nexport function useInteractionHandles(opts: UseInteractionHandlesOptions) {\n const {\n controller,\n resizeUI,\n vertexUI,\n includeVertices = false,\n handleAttrs,\n vertexAttrs,\n } = opts;\n\n // Owns live interaction handlers\n const { dragProps, createResizeProps, createVertexProps } = useDragResize(controller);\n\n // Plain snapshots for the *descriptor* helpers\n const elementPlain = computed<Rect>(() => rectDTO(norm(controller.element)));\n const verticesPlain = computed<Position[] | undefined>(() =>\n controller.vertices ? vertsDTO(norm(controller.vertices)) : undefined,\n );\n const scalePlain = computed<number>(() => Number(norm(controller.scale ?? 1)));\n const rotationPlain = computed<number>(() => Number(norm(controller.pageRotation ?? 0)));\n const maintainPlain = computed<boolean | undefined>(() =>\n controller.maintainAspectRatio === undefined\n ? undefined\n : Boolean(norm(controller.maintainAspectRatio)),\n );\n const constraintsPlain = computed(() => norm(controller.constraints ?? undefined));\n\n const resize = computed<HandleElementProps[]>(() => {\n const desc = describeResizeFromConfig(\n {\n element: elementPlain.value,\n scale: scalePlain.value,\n pageRotation: rotationPlain.value,\n maintainAspectRatio: maintainPlain.value,\n constraints: constraintsPlain.value,\n },\n resizeUI,\n );\n return desc.map((d) => ({\n key: (d.attrs?.['data-epdf-handle'] as string) ?? d.handle,\n style: d.style as CSSProperties,\n ...createResizeProps(d.handle),\n ...(d.attrs ?? {}),\n ...(handleAttrs?.(d.handle) ?? {}),\n }));\n });\n\n const vertices = computed<HandleElementProps[]>(() => {\n if (!includeVertices) return [];\n const verts = verticesPlain.value ?? [];\n const desc = describeVerticesFromConfig(\n { element: elementPlain.value, scale: scalePlain.value, vertices: verts },\n vertexUI,\n verts,\n );\n return desc.map((d, i) => ({\n key: i,\n style: d.style as CSSProperties,\n ...createVertexProps(i),\n ...(d.attrs ?? {}),\n ...(vertexAttrs?.(i) ?? {}),\n }));\n });\n\n return { dragProps, resize, vertices };\n}\n"],"names":["props","__props","counterRotation","computed","getCounterRotation","rect","rotation","menuWrapperProps","style","position","left","origin","x","top","y","transform","value","matrix","transformOrigin","width","height","pointerEvents","zIndex","onPointerdown","e","stopPropagation","preventDefault","onTouchstart","adjustedRect","size","_renderSlot","_ctx","$slots","DragResizeController","constructor","config","onUpdate","this","state","startPoint","startElement","activeHandle","currentPosition","activeVertexIndex","startVertices","currentVertices","vertices","updateConfig","startDrag","clientX","clientY","element","transformData","type","changes","startResize","handle","metadata","maintainAspectRatio","startVertexEdit","vertexIndex","length","move","delta","calculateDelta","calculateDragPosition","calculateResizePosition","calculateVertexPosition","end","wasState","finalPosition","getCurrentPosition","reset","cancel","rawDelta","transformDelta","pageRotation","scale","rad","Math","PI","cos","sin","scaledX","scaledY","clampPoint","p","bbox","_a","constraints","boundingBox","max","min","newVertices","currentVertex","moved","applyConstraints","anchor","includes","getAnchor","aspectRatio","applyResizeDelta","enforceAspectRatio","clampToBounds","start","abs","anchorX","anchorY","maxW","maxH","scaleW","scaleH","minW","minWidth","minH","minHeight","maxWidth","maxHeight","ratio","diagonalCursor","rot","nw","ne","sw","se","edgeOffset","k","spacing","mode","base","norm","v","toRaw","isRef","unref","toNum","n","fallback","Number","isFinite","rectDTO","r","_b","_c","_d","vertsDTO","arr","map","boolDTO","b","Boolean","numDTO","constraintsDTO","c","useDragResize","options","controller","ref","enabled","initialCfg","markRaw","ev","watch","nc","deep","onUnmounted","isEnabled","handleDragStart","currentTarget","setPointerCapture","call","pointerId","handleMove","handleEnd","releasePointerCapture","handleCancel","dragProps","onPointermove","onPointerup","onPointercancel","createResizeProps","createVertexProps","sourceObj","objectIterator","input","Array","isArray","item","isReactive","isProxy","Object","keys","reduce","acc","key","onDouble","delay","tolerancePx","last","t","onDblclick","onPointerupCapture","pointerType","isPrimary","now","performance","withinTime","dx","dy","opts","resizeUI","vertexUI","includeVertices","handleAttrs","vertexAttrs","elementPlain","verticesPlain","scalePlain","rotationPlain","maintainPlain","constraintsPlain","resize","cfg","ui","handleSize","offsetMode","includeSides","rotationAwareCursor","off","edge","pos","borderRadius","cursor","touchAction","attrs","describeResizeFromConfig","d","verts","liveVertices","vertexSize","i","describeVerticesFromConfig"],"mappings":"gOAkBA,MAAMA,EAAQC,EAERC,EAAkBC,EAAAA,SAAS,IAAMC,EAAAA,mBAAmBJ,EAAMK,KAAML,EAAMM,WAEtEC,EAAmBJ,EAAAA,SAAS,KAAA,CAChCK,MAAO,CACLC,SAAU,WACVC,KAAM,GAAGV,EAAMK,KAAKM,OAAOC,MAC3BC,IAAK,GAAGb,EAAMK,KAAKM,OAAOG,MAC1BC,UAAWb,EAAgBc,MAAMC,OACjCC,gBAAiB,MACjBC,MAAO,GAAGjB,EAAgBc,MAAMG,UAChCC,OAAQ,GAAGlB,EAAgBc,MAAMI,WACjCC,cAAe,OACfC,OAAQ,GAEVC,cAAgBC,IACdA,EAAEC,kBACFD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