@weatherboard/annotation 0.4.0 → 0.7.0

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.
Files changed (75) hide show
  1. package/ADOPTING.md +147 -10
  2. package/COMPATIBILITY.md +29 -0
  3. package/README.md +84 -10
  4. package/dist/anchor.cjs +1 -1
  5. package/dist/anchor.cjs.map +2 -2
  6. package/dist/anchor.mjs.map +2 -2
  7. package/dist/arming.d.cts +18 -21
  8. package/dist/arming.d.mts +18 -21
  9. package/dist/arming.d.ts +18 -21
  10. package/dist/bootstrap-runtime.d.cts +30 -0
  11. package/dist/bootstrap-runtime.d.mts +30 -0
  12. package/dist/bootstrap-runtime.d.ts +30 -0
  13. package/dist/bootstrap.cjs +2 -0
  14. package/dist/bootstrap.cjs.map +7 -0
  15. package/dist/bootstrap.d.cts +8 -0
  16. package/dist/bootstrap.d.mts +8 -0
  17. package/dist/bootstrap.d.ts +8 -0
  18. package/dist/bootstrap.mjs +2 -0
  19. package/dist/bootstrap.mjs.map +7 -0
  20. package/dist/host.cjs +1 -1
  21. package/dist/host.cjs.map +3 -3
  22. package/dist/host.mjs +1 -1
  23. package/dist/host.mjs.map +3 -3
  24. package/dist/index.cjs +4 -4
  25. package/dist/index.cjs.map +4 -4
  26. package/dist/index.d.cts +10 -4
  27. package/dist/index.d.mts +10 -4
  28. package/dist/index.d.ts +10 -4
  29. package/dist/index.mjs +4 -4
  30. package/dist/index.mjs.map +4 -4
  31. package/dist/markers.cjs +2 -2
  32. package/dist/markers.cjs.map +2 -2
  33. package/dist/markers.mjs +2 -2
  34. package/dist/markers.mjs.map +2 -2
  35. package/dist/page-capture.cjs +2 -0
  36. package/dist/page-capture.cjs.map +7 -0
  37. package/dist/page-capture.d.cts +115 -0
  38. package/dist/page-capture.d.mts +115 -0
  39. package/dist/page-capture.d.ts +115 -0
  40. package/dist/page-capture.mjs +2 -0
  41. package/dist/page-capture.mjs.map +7 -0
  42. package/dist/protocol.cjs +1 -1
  43. package/dist/protocol.cjs.map +3 -3
  44. package/dist/protocol.d.cts +19 -0
  45. package/dist/protocol.d.mts +19 -0
  46. package/dist/protocol.d.ts +19 -0
  47. package/dist/protocol.mjs +1 -1
  48. package/dist/protocol.mjs.map +3 -3
  49. package/dist/read.cjs +1 -1
  50. package/dist/read.cjs.map +2 -2
  51. package/dist/read.mjs +1 -1
  52. package/dist/read.mjs.map +2 -2
  53. package/dist/screenshot.d.cts +56 -7
  54. package/dist/screenshot.d.mts +56 -7
  55. package/dist/screenshot.d.ts +56 -7
  56. package/dist/selection.cjs +5 -0
  57. package/dist/selection.cjs.map +7 -0
  58. package/dist/selection.d.cts +27 -0
  59. package/dist/selection.d.mts +27 -0
  60. package/dist/selection.d.ts +27 -0
  61. package/dist/selection.mjs +5 -0
  62. package/dist/selection.mjs.map +7 -0
  63. package/dist/session.d.cts +17 -0
  64. package/dist/session.d.mts +17 -0
  65. package/dist/session.d.ts +17 -0
  66. package/dist/shortcut.d.cts +52 -0
  67. package/dist/shortcut.d.mts +52 -0
  68. package/dist/shortcut.d.ts +52 -0
  69. package/dist/toolbar.d.cts +13 -0
  70. package/dist/toolbar.d.mts +13 -0
  71. package/dist/toolbar.d.ts +13 -0
  72. package/dist/transport.d.cts +10 -0
  73. package/dist/transport.d.mts +10 -0
  74. package/dist/transport.d.ts +10 -0
  75. package/package.json +45 -10
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var we=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var Ze=e=>{throw TypeError(e)};var Ct=(e,t)=>{for(var n in t)we(e,n,{get:t[n],enumerable:!0})},wt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vt(t))!St.call(e,o)&&o!==n&&we(e,o,{get:()=>t[o],enumerable:!(r=Tt(t,o))||r.enumerable});return e};var Ot=e=>wt(we({},"__esModule",{value:!0}),e);var Qe=(e,t,n)=>t.has(e)||Ze("Cannot "+n);var L=(e,t,n)=>(Qe(e,t,"read from private field"),n?n.call(e):t.get(e)),Oe=(e,t,n)=>t.has(e)?Ze("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),et=(e,t,n,r)=>(Qe(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);var qt={};Ct(qt,{ANNOTATION_ARMED_COOKIE:()=>le,ANNOTATION_ARMED_COOKIES:()=>J,ANNOTATION_ARMED_VALUE:()=>_e,ANNOTATION_TOKEN_PARAM:()=>Re,ANNOTATION_TOKEN_PARAMS:()=>z,CAPTURE_TOKEN_PARAM:()=>j,CAPTURE_TOKEN_STORAGE_KEY:()=>te,DEFAULT_LABELS:()=>Ge,DEFAULT_LIMIT:()=>gt,HTTP_TRANSPORT_TIMEOUT_MS:()=>He,LEGACY_ANNOTATION_ARMED_COOKIE:()=>Me,LEGACY_ANNOTATION_TOKEN_PARAM:()=>ke,MAX_CHAIN:()=>Ie,MAX_SCREENSHOT_BYTES:()=>it,MAX_SCREENSHOT_EDGE:()=>st,MAX_TEXT:()=>pe,NAME_ATTR:()=>ie,OVERLAY_ID:()=>Ne,READ_TOKEN_PARAM:()=>Y,READ_TOKEN_STORAGE_KEY:()=>re,REVIEW_RUN_PARAM:()=>V,REVIEW_RUN_STORAGE_KEY:()=>ne,RingBuffer:()=>K,SCREENSHOT_TIMEOUT_MS:()=>lt,SDK_VERSION:()=>G,SRC_ATTR:()=>W,TOOLBAR_ID:()=>We,armedCookie:()=>nt,assertConcreteEndpoint:()=>De,assertConcreteOrigin:()=>D,attachScreenshot:()=>ee,captureScreenshot:()=>Xe,captureScreenshotSync:()=>qe,clearedCookie:()=>ce,collectSourceChain:()=>Le,createAnnotationSdk:()=>Ae,createAnnotationToolbar:()=>je,createEgress:()=>Ee,createOverlay:()=>de,defaultStateCollectorOptions:()=>ze,describeArg:()=>Ve,domPath:()=>Fe,emptyAnnotationState:()=>ct,findAnnotatedAncestor:()=>Pe,findCaptureSource:()=>Ke,firstStack:()=>Te,fitWithin:()=>Be,formatConsoleArgs:()=>Ye,httpTransport:()=>at,installStateCollector:()=>bt,intrinsicSize:()=>$e,isAnnotatableBuild:()=>xe,isAnnotationArmed:()=>ue,isFailedStatus:()=>ve,isMediaElement:()=>Q,isParentMessage:()=>se,mountAnnotation:()=>mt,parseSourceRef:()=>fe,postMessageTransport:()=>be,readAnnotationToken:()=>rt,readArming:()=>dt,refusalReason:()=>he,resolveScreenshotOptions:()=>ye,resolveTarget:()=>me,safeIssueUrl:()=>Z,safeRefusalReason:()=>ge,selectionOf:()=>tt,summariseText:()=>Ue});module.exports=Ot(qt);var G="1",W="data-src",ie="data-src-name";function tt(e){return e.selection==="region"?"region":"element"}var Rt=new Set(["annotate:enable","annotate:disable","annotate:ping"]);function se(e){if(typeof e!="object"||e===null)return!1;let t=e.type;return typeof t=="string"&&Rt.has(t)}function D(e){if(!e||e==="*")throw new Error("[annotation] a concrete parent origin is required; '*' would broadcast annotation payloads to any embedder.");return e}var Re="ai_annotate",le="ai_annotate_armed",j="ai_capture",V="ai_run",Y="ai_read",_e="1";function nt(e=le){return`${e}=${_e}; Path=/; SameSite=Lax; Secure`}function ce(e){return`${e}=; Path=/; SameSite=Lax; Secure; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT`}var ke="pits_annotate",Me="pits_annotate_armed",z=[Re,ke],J=[le,Me];function ue(e){return e.split(";").some(t=>{let n=t.trimStart();return J.some(r=>n.startsWith(`${r}=`))})}function rt(e){for(let t of z){let n=e.get(t);if(n!==null&&n.length>0)return n}return null}var Ne="ai-annotation-overlay",_t="2147483000";function de(e){let t=e.createElement("div");t.id=Ne,t.style.cssText=["position:fixed","top:0","left:0","pointer-events:none",`z-index:${_t}`,"display:none","box-sizing:border-box","border:2px solid #2563eb","background:rgba(37,99,235,0.12)","border-radius:2px"].join(";");let n=e.createElement("div");return n.style.cssText=["position:absolute","left:0","top:-20px","font:11px/16px ui-monospace,SFMono-Regular,Menlo,monospace","color:#fff","background:#2563eb","padding:1px 5px","border-radius:2px","white-space:nowrap","max-width:60vw","overflow:hidden","text-overflow:ellipsis"].join(";"),t.appendChild(n),e.body.appendChild(t),{show(r,o){t.style.display="block",t.style.transform=`translate(${r.x}px, ${r.y}px)`,t.style.width=`${r.w}px`,t.style.height=`${r.h}px`,n.style.top=r.y<20?"100%":"-20px",n.textContent=o??"",n.style.display=o?"block":"none"},hide(){t.style.display="none"},destroy(){t.remove()},contains(r){return r instanceof Node&&t.contains(r)}}}var pe=200,Ie=8;function fe(e){if(!e)return null;let t=e.lastIndexOf(":");if(t<=0)return null;let n=e.lastIndexOf(":",t-1);if(n<=0)return null;let r=e.slice(0,n),o=Number(e.slice(n+1,t)),a=Number(e.slice(t+1));return!r||!Number.isFinite(o)||!Number.isFinite(a)?null:{file:r,line:o,column:a}}function Le(e,t=Ie){let n=[],r=e;for(;r&&n.length<t;){let o=fe(r.getAttribute(W));if(o){let a=n[n.length-1];a&&a.file===o.file&&a.line===o.line||n.push(o)}r=r.parentElement}return n}function Pe(e){let t=e;for(;t;){if(fe(t.getAttribute(W)))return t;t=t.parentElement}return null}function kt(e){let t=e.classList;return(typeof t?.value=="string"?t.value:"").split(/\s+/).filter(Boolean)}function Fe(e,t=6){let n=[],r=e;for(;r&&n.length<t;){let o=(r.tagName||"").toLowerCase();if(!o||o==="html")break;let a=o;if(r.id)return n.unshift(`${o}#${r.id}`),n.join(" > ");let s=kt(r).slice(0,2);if(s.length>0&&(a+=`.${s.join(".")}`),n.unshift(a),o==="body")break;r=r.parentElement}return n.join(" > ")}function Ue(e){if(!e)return;let t=e.replace(/\s+/g," ").trim();if(t)return t.length>pe?`${t.slice(0,pe-1)}\u2026`:t}function me(e,t){let n=Pe(e),r=Le(e),o=r[0],a={domPath:Fe(e),boundingBox:t.boundingBox};o&&(a.source=o),r.length>0&&(a.sourceChain=r);let s=n?.getAttribute(ie);s&&(a.componentName=s);let c=Ue(e.textContent);return c&&(a.textContent=c),a}var Mt=2048;function Z(e){if(typeof e!="string"||e.length===0||e.length>Mt)return;let t;try{t=new URL(e)}catch{return}if(!(t.protocol!=="https:"&&t.protocol!=="http:"))return t.href}var ot=300;function ge(e){if(typeof e!="string")return;let t=e.replace(/[\u0000-\u001f\u007f-\u009f]+/g," ").replace(/\s+/g," ").trim();if(t.length!==0)return t.length>ot?`${t.slice(0,ot-1).trimEnd()}\u2026`:t}function he(e){return ge(e?.reason)}function be(e,t=window){let n=D(e);return{name:"postMessage",carries:()=>!0,send(r){t.parent.postMessage(r,n)}}}function De(e){if(!e||e==="*")throw new Error("[annotation] a concrete ingest endpoint is required; '*' is not an address and an empty one posts nowhere.");let t;try{t=new URL(e)}catch{throw new Error(`[annotation] the ingest endpoint must be an absolute URL, got ${JSON.stringify(e)}; a relative one resolves against the product's own origin and the capture is lost there.`)}if(t.protocol!=="https:"&&t.protocol!=="http:")throw new Error(`[annotation] the ingest endpoint must be http(s), got ${t.protocol}`);return t.toString()}var He=8e3;function at(e){let t=De(e.endpoint);if(!e.captureToken)throw new Error("[annotation] a capture token is required; the ingest rejects an unsigned capture and the reviewer would only find out after writing one.");let n=e.captureToken,r=e.timeoutMs??He,o=e.fetch??globalThis.fetch;return{name:"http",carries:a=>a==="annotate:capture",async send(a){if(!o)throw new Error("[annotation] no fetch implementation is available for the ingest");let s=new AbortController,c=setTimeout(()=>s.abort(),r);try{let f=await o(t,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},credentials:"omit",body:JSON.stringify(a),signal:s.signal});if(!f.ok){let m;try{let p=await f.json?.();m=ge(p?.error)}catch{m=void 0}let g=new Error(`[annotation] the ingest rejected the capture: ${m??`HTTP ${f.status}`}`);throw g.status=f.status,m!==void 0&&(g.reason=m),g}try{let m=await f.json?.(),g=Z(m?.issueUrl);if(g!==void 0)return{issueUrl:g}}catch{}return{}}catch(f){throw s.signal.aborted?new Error(`[annotation] the capture timed out after ${r}ms`,{cause:f}):f}finally{clearTimeout(c)}}}}function Ee(e,t){let n=(r,o)=>{let a={message:r,transport:e.name,error:o};if(t){t(a);return}console.error("[annotation] a capture could not be delivered",a)};return async r=>{if(!e.carries(r.type))return{status:"declined"};try{return{status:"sent",receipt:await e.send(r)??{}}}catch(o){return n(r,o),{status:"failed",error:o}}}}var it=49152,st=480,lt=250,Nt=[{edge:480,quality:.7},{edge:240,quality:.5}],It=["image/webp","image/jpeg"];function ye(e,t){let n=e===!1?{enabled:!1}:e??{};return{enabled:n.enabled??!0,maxBytes:n.maxBytes??49152,maxEdge:n.maxEdge??480,timeoutMs:n.timeoutMs??250,createCanvas:n.createCanvas??(()=>t?.createElement("canvas")??null)}}var Lt=new Set(["IMG","CANVAS","VIDEO"]),Pt="img,canvas,video",Ft=4;function Q(e){return!!e&&Lt.has(e.tagName.toUpperCase())}function Ke(e,t=Ft){if(!e)return null;if(Q(e))return e;let n=e.querySelector?.(Pt)??null;if(Q(n))return n;let r=e.parentElement??null;for(let o=0;r&&o<t;o++){if(Q(r))return r;r=r.parentElement??null}return null}function $e(e){let t=e.tagName.toUpperCase(),n=t==="IMG"?{w:e.naturalWidth,h:e.naturalHeight}:t==="VIDEO"?{w:e.videoWidth,h:e.videoHeight}:{w:e.width,h:e.height},r=Math.floor(n.w??0),o=Math.floor(n.h??0);return!Number.isFinite(r)||!Number.isFinite(o)||r<1||o<1||t==="IMG"&&e.complete===!1?null:{w:r,h:o}}function Be(e,t){let n=Math.min(1,t/Math.max(e.w,e.h));return{w:Math.max(1,Math.round(e.w*n)),h:Math.max(1,Math.round(e.h*n))}}function Ut(e,t,n,r){let o;try{o=r.createCanvas()}catch{return null}if(!o)return null;try{o.width=t.w,o.height=t.h;let a=o.getContext("2d");if(!a)return null;a.drawImage(e,0,0,t.w,t.h);for(let s of It){let c;try{c=o.toDataURL(s,n)}catch{return null}if(!(typeof c!="string"||!c.startsWith(`data:${s}`)))return c.length<=r.maxBytes?c:null}return null}catch{return null}}function qe(e,t){if(!t.enabled)return null;let n=Ke(e);if(!n)return null;let r=$e(n);if(!r)return null;for(let o of Nt){let a=Be(r,Math.min(t.maxEdge,o.edge)),s=Ut(n,a,o.quality,t);if(s)return{dataUrl:s,region:"element"}}return null}function Xe(e,t){return t.enabled?new Promise(n=>{let r=!1,o=s=>{r||(r=!0,n(s))},a=setTimeout(()=>o(null),t.timeoutMs);a.unref?.(),Promise.resolve().then(()=>qe(e,t)).then(o,()=>o(null)).finally(()=>clearTimeout(a))}):Promise.resolve(null)}async function ee(e,t,n){let r;try{r=await Xe(t,n)}catch{r=null}return r?{...e,screenshot:r}:e}var Dt={consoleErrors:[],failedRequests:[],featureFlags:{}},ct=()=>({...Dt});function Ae(e){let t=e.parentOrigin===void 0?null:D(e.parentOrigin),n=window,r=n.document,o=ye(e.screenshot,r),a=!1,s=null,c=0,f=null,m=!1,g=e.transport??(t===null?null:be(t,n));if(g===null)throw new Error("[annotation] the SDK needs a `transport` or a `parentOrigin`; with neither there is nowhere for a capture to go and every one of them would be lost in silence.");let p=Ee(g,e.onEgressError),u=l=>{let d=l.getBoundingClientRect();return{x:d.x,y:d.y,w:d.width,h:d.height}},A=l=>me(l,{boundingBox:u(l)}),T=l=>{if(l.componentName&&l.source){let d=l.source.file.split("/").pop()??l.source.file;return`${l.componentName} \xB7 ${d}:${l.source.line}`}return l.source?`${l.source.file}:${l.source.line}`:l.componentName??null},x=l=>{!a||m||c||(c=n.requestAnimationFrame(()=>{c=0;let d=r.elementFromPoint(l.clientX,l.clientY);if(!d||s&&s.contains(d)||e.ignoreElement?.(d)||d===f)return;f=d;let b=A(d);s?.show(b.boundingBox,T(b)),p({type:"annotate:hover",target:b})}))},R=(l,d)=>({schemaVersion:1,capturedAt:new Date().toISOString(),build:e.build,page:{url:n.location.href,route:e.getRoute(),viewport:{w:n.innerWidth,h:n.innerHeight,dpr:n.devicePixelRatio},userAgent:n.navigator.userAgent},target:A(l),state:{consoleErrors:d.consoleErrors,failedRequests:d.failedRequests,featureFlags:d.featureFlags},comment:""}),N=l=>{let d={type:"annotate:capture",payload:l},b=()=>{p(d).then(O=>e.onCaptureResult?.(O,b))};b()},_=l=>{if(!a)return;let d=l.target;if(!(d instanceof Element)||e.ignoreElement?.(d)||(l.preventDefault(),l.stopPropagation(),m))return;let b=R(d,e.getState()),O=e.collectComment;if(!O){if(!o.enabled){N(b);return}ee(b,d,o).then(C=>N(C),()=>N(b));return}let $={x:l.clientX,y:l.clientY},B=o.enabled?ee(b,d,o).then(C=>C,()=>b):Promise.resolve(b),I=()=>{m=!0;let C=null,ae=O({target:b.target,point:$}).then(y=>y,y=>(C={error:y},null));Promise.all([B,ae]).then(([y,U])=>{if(m=!1,C!==null){e.onCaptureResult?.({status:"failed",error:C.error},I);return}U!==null&&N(U===""?y:{...y,comment:U})})};I()},P=l=>{!a||m||l.key!=="Escape"||(p({type:"annotate:cancel"}),k())};function F(){a||(a=!0,s??(s=de(r)),r.addEventListener("mousemove",x,!0),r.addEventListener("click",_,!0),r.addEventListener("keydown",P,!0))}function k(){a&&(a=!1,f=null,c&&(n.cancelAnimationFrame(c),c=0),r.removeEventListener("mousemove",x,!0),r.removeEventListener("click",_,!0),r.removeEventListener("keydown",P,!0),s?.hide())}let S=l=>{if(l.origin===t&&se(l.data))switch(l.data.type){case"annotate:enable":F();break;case"annotate:disable":k();break;case"annotate:ping":p({type:"annotate:ready",sdkVersion:"1",build:e.build});break}};return t!==null&&n.addEventListener("message",S),p({type:"annotate:ready",sdkVersion:"1",build:e.build}),{enable:F,disable:k,isEnabled:()=>a,destroy(){k(),t!==null&&n.removeEventListener("message",S),s?.destroy(),s=null}}}var te="ai.annotation.capture",ne="ai.annotation.run",re="ai.annotation.read",ut=[...z,j,Y,V];function v(e,t){try{return e()}catch{return t}}function Ht(e){return v(()=>e?.sessionStorage??null,null)}function dt(e={}){let t=e.doc??document,n=t.defaultView??null,r=e.storage===void 0?Ht(n):e.storage,o=e.url??t.URL,a=v(()=>new URL(o),null),s=null,c=null,f=null;if(a!==null&&(s=a.searchParams.get(j)||null,c=a.searchParams.get(Y)||null,f=a.searchParams.get(V)||null,ut.some(u=>a.searchParams.has(u)))){for(let A of ut)a.searchParams.delete(A);let u=e.history??n?.history;v(()=>{u?.replaceState(n?.history?.state??null,"",a.toString())},void 0)}let m=()=>{for(let p of J)v(()=>{t.cookie=ce(p)},void 0);r&&(v(()=>r.removeItem(te),void 0),v(()=>r.removeItem(re),void 0),v(()=>r.removeItem(ne),void 0))},g=ue(v(()=>t.cookie,""));return g?(r&&(s!==null?v(()=>r.setItem(te,s),void 0):s=v(()=>r.getItem(te),null),c!==null?v(()=>r.setItem(re,c),void 0):c=v(()=>r.getItem(re),null),f!==null?v(()=>r.setItem(ne,f),void 0):f=v(()=>r.getItem(ne),null)),{armed:g,captureToken:s,readToken:c,runId:f,disarm:m}):{armed:!1,captureToken:null,readToken:null,runId:null,disarm:m}}var Kt=["preview","staging","development"];function xe(e){return Kt.includes(e.env)}var Ge={region:"Annotation",expand:"Open the annotation toolbar",collapse:"Close the annotation toolbar",start:"Start annotating",stop:"Stop annotating",done:"Done",comment:"What is wrong here?",placeholder:"The heading wraps onto three lines on mobile\u2026",send:"Send",cancel:"Cancel",sent:"Sent",issue:"View issue",failed:"That did not send",retry:"Retry"},We="ai-annotation-toolbar",$t="2147483001",ft=288,pt=190,H=12,Bt=`
1
+ "use strict";var Gt=Object.create;var Ae=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var qt=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var ft=e=>{throw TypeError(e)};var Jt=(e,t)=>{for(var n in t)Ae(e,n,{get:t[n],enumerable:!0})},mt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xt(t))!jt.call(e,o)&&o!==n&&Ae(e,o,{get:()=>t[o],enumerable:!(r=Yt(t,o))||r.enumerable});return e};var zt=(e,t,n)=>(n=e!=null?Gt(qt(e)):{},mt(t||!e||!e.__esModule?Ae(n,"default",{value:e,enumerable:!0}):n,e)),Zt=e=>mt(Ae({},"__esModule",{value:!0}),e);var gt=(e,t,n)=>t.has(e)||ft("Cannot "+n);var K=(e,t,n)=>(gt(e,t,"read from private field"),n?n.call(e):t.get(e)),Ke=(e,t,n)=>t.has(e)?ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ht=(e,t,n,r)=>(gt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);var xn={};Jt(xn,{ANNOTATION_ARMED_COOKIE:()=>xe,ANNOTATION_ARMED_COOKIES:()=>se,ANNOTATION_ARMED_VALUE:()=>Ve,ANNOTATION_MODE_HEADER:()=>Et,ANNOTATION_OPEN_INTENT_STORAGE_KEY:()=>pe,ANNOTATION_TOKENS_COOKIE:()=>F,ANNOTATION_TOKEN_PARAM:()=>Fe,ANNOTATION_TOKEN_PARAMS:()=>ie,CAPTURE_TOKEN_PARAM:()=>re,CAPTURE_TOKEN_STORAGE_KEY:()=>M,DEFAULT_HOTKEY:()=>at,DEFAULT_LABELS:()=>it,DEFAULT_LIMIT:()=>Dt,FIRST_PARTY_ANNOTATION_MODE:()=>bt,HTTP_TRANSPORT_TIMEOUT_MS:()=>Je,LEGACY_ANNOTATION_ARMED_COOKIE:()=>Be,LEGACY_ANNOTATION_TOKEN_PARAM:()=>He,MAX_CHAIN:()=>We,MAX_SCREENSHOT_BYTES:()=>Ze,MAX_SCREENSHOT_EDGE:()=>ce,MAX_TEXT:()=>_e,MAX_VIEWPORT_DATA_URL_LENGTH:()=>Rt,MAX_VIEWPORT_IMAGE_BYTES:()=>_t,MAX_VIEWPORT_WIDTH:()=>St,NAME_ATTR:()=>ye,OVERLAY_ID:()=>$e,READ_TOKEN_PARAM:()=>ae,READ_TOKEN_STORAGE_KEY:()=>P,REARM_BEFORE_EXPIRY_S:()=>Pe,REVIEW_RUN_PARAM:()=>oe,REVIEW_RUN_STORAGE_KEY:()=>L,RingBuffer:()=>J,SCREENSHOT_TIMEOUT_MS:()=>Qe,SDK_VERSION:()=>te,SRC_ATTR:()=>ne,TOOLBAR_ID:()=>st,VIEWPORT_TIMEOUT_MS:()=>ze,armedCookie:()=>Tt,assertConcreteEndpoint:()=>je,assertConcreteOrigin:()=>X,attachScreenshot:()=>de,captureScreenshot:()=>ot,captureScreenshotSync:()=>rt,clearedCookie:()=>ve,collectSourceChain:()=>Ge,createAnnotationSdk:()=>Me,createAnnotationToolbar:()=>lt,createEgress:()=>Ie,createOverlay:()=>Se,defaultStateCollectorOptions:()=>dt,describeArg:()=>ut,domPath:()=>Xe,emptyAnnotationState:()=>wt,findAnnotatedAncestor:()=>Ye,findCaptureSource:()=>et,firstStack:()=>Le,fitWithin:()=>nt,formatConsoleArgs:()=>ct,httpTransport:()=>Ot,installStateCollector:()=>Ft,intrinsicSize:()=>tt,isAnnotatableBuild:()=>me,isAnnotationArmed:()=>Oe,isFailedStatus:()=>Ue,isMediaElement:()=>ue,isParentMessage:()=>Te,matchesHotkey:()=>ge,mountAnnotation:()=>Ut,needsArming:()=>fe,parseSourceRef:()=>Re,postMessageTransport:()=>Ce,readAnnotationToken:()=>xt,readArming:()=>Mt,refusalReason:()=>ke,resolveScreenshotOptions:()=>Ne,resolveTarget:()=>we,safeIssueUrl:()=>C,safeRefusalReason:()=>le,selectionOf:()=>At,summariseText:()=>qe,tokenExpiry:()=>q});module.exports=Zt(xn);var te="1",Et="x-weatherboard-annotation-mode",bt="first-party",ne="data-src",ye="data-src-name";function At(e){return e.selection==="region"?"region":"element"}function Qt(e){try{return JSON.stringify(e)??String(e)}catch{return"[unserialisable]"}}function yt(e,t){console.error(`[annotation] ${e}: protocol drift, nothing was acted on: ${Qt(t)}`)}var en=new Set(["annotate:enable","annotate:disable","annotate:ping"]);function Te(e){if(typeof e!="object"||e===null)return!1;let t=e.type;return typeof t=="string"&&en.has(t)}function X(e){if(!e||e==="*")throw new Error("[annotation] a concrete parent origin is required; '*' would broadcast annotation payloads to any embedder.");return e}var Fe="ai_annotate",xe="ai_annotate_armed",re="ai_capture",oe="ai_run",ae="ai_read",Ve="1";function Tt(e=xe){return`${e}=${Ve}; Path=/; SameSite=Lax; Secure`}function ve(e){return`${e}=; Path=/; SameSite=Lax; Secure; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT`}var He="pits_annotate",Be="pits_annotate_armed",ie=[Fe,He],se=[xe,Be];function Oe(e){return e.split(";").some(t=>{let n=t.trimStart();return se.some(r=>n.startsWith(`${r}=`))})}function xt(e){for(let t of ie){let n=e.get(t);if(n!==null&&n.length>0)return n}return null}var $e="ai-annotation-overlay",tn="2147483000";function Se(e){let t=e.createElement("div");t.id=$e,t.style.cssText=["position:fixed","top:0","left:0","pointer-events:none",`z-index:${tn}`,"display:none","box-sizing:border-box","border:2px solid #2563eb","background:rgba(37,99,235,0.12)","border-radius:2px"].join(";");let n=e.createElement("div");return n.style.cssText=["position:absolute","left:0","top:-20px","font:11px/16px ui-monospace,SFMono-Regular,Menlo,monospace","color:#fff","background:#2563eb","padding:1px 5px","border-radius:2px","white-space:nowrap","max-width:60vw","overflow:hidden","text-overflow:ellipsis"].join(";"),t.appendChild(n),e.body.appendChild(t),{show(r,o){t.style.display="block",t.style.transform=`translate(${r.x}px, ${r.y}px)`,t.style.width=`${r.w}px`,t.style.height=`${r.h}px`,n.style.top=r.y<20?"100%":"-20px",n.textContent=o??"",n.style.display=o?"block":"none"},hide(){t.style.display="none"},destroy(){t.remove()},contains(r){return r instanceof Node&&t.contains(r)}}}var _e=200,We=8;function Re(e){if(!e)return null;let t=e.lastIndexOf(":");if(t<=0)return null;let n=e.lastIndexOf(":",t-1);if(n<=0)return null;let r=e.slice(0,n),o=Number(e.slice(n+1,t)),a=Number(e.slice(t+1));return!r||!Number.isFinite(o)||!Number.isFinite(a)?null:{file:r,line:o,column:a}}function Ge(e,t=We){let n=[],r=e;for(;r&&n.length<t;){let o=Re(r.getAttribute(ne));if(o){let a=n[n.length-1];a&&a.file===o.file&&a.line===o.line||n.push(o)}r=r.parentElement}return n}function Ye(e){let t=e;for(;t;){if(Re(t.getAttribute(ne)))return t;t=t.parentElement}return null}function nn(e){let t=e.classList;return(typeof t?.value=="string"?t.value:"").split(/\s+/).filter(Boolean)}function Xe(e,t=6){let n=[],r=e;for(;r&&n.length<t;){let o=(r.tagName||"").toLowerCase();if(!o||o==="html")break;let a=o;if(r.id)return n.unshift(`${o}#${r.id}`),n.join(" > ");let i=nn(r).slice(0,2);if(i.length>0&&(a+=`.${i.join(".")}`),n.unshift(a),o==="body")break;r=r.parentElement}return n.join(" > ")}function qe(e){if(!e)return;let t=e.replace(/\s+/g," ").trim();if(t)return t.length>_e?`${t.slice(0,_e-1)}\u2026`:t}function we(e,t){let n=Ye(e),r=Ge(e),o=r[0],a={domPath:Xe(e),boundingBox:t.boundingBox};o&&(a.source=o),r.length>0&&(a.sourceChain=r);let i=n?.getAttribute(ye);i&&(a.componentName=i);let s=qe(e.textContent);return s&&(a.textContent=s),a}var rn=2048;function C(e){if(typeof e!="string"||e.length===0||e.length>rn)return;let t;try{t=new URL(e)}catch{return}if(!(t.protocol!=="https:"&&t.protocol!=="http:"))return t.href}var vt=300;function le(e){if(typeof e!="string")return;let t=e.replace(/[\u0000-\u001f\u007f-\u009f]+/g," ").replace(/\s+/g," ").trim();if(t.length!==0)return t.length>vt?`${t.slice(0,vt-1).trimEnd()}\u2026`:t}function ke(e){return le(e?.reason)}function Ce(e,t=window){let n=X(e);return{name:"postMessage",carries:()=>!0,send(r){t.parent.postMessage(r,n)}}}function je(e){if(!e||e==="*")throw new Error("[annotation] a concrete ingest endpoint is required; '*' is not an address and an empty one posts nowhere.");let t;try{t=new URL(e)}catch{throw new Error(`[annotation] the ingest endpoint must be an absolute URL, got ${JSON.stringify(e)}; a relative one resolves against the product's own origin and the capture is lost there.`)}if(t.protocol!=="https:"&&t.protocol!=="http:")throw new Error(`[annotation] the ingest endpoint must be http(s), got ${t.protocol}`);return t.toString()}var Je=8e3;function Ot(e){let t=je(e.endpoint);if(!e.captureToken)throw new Error("[annotation] a capture token is required; the ingest rejects an unsigned capture and the reviewer would only find out after writing one.");let n=e.captureToken,r=e.timeoutMs??Je,o=e.fetch??globalThis.fetch;return{name:"http",carries:a=>a==="annotate:capture",async send(a){if(!o)throw new Error("[annotation] no fetch implementation is available for the ingest");let i=new AbortController,s=setTimeout(()=>i.abort(),r);try{let c=await o(t,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},credentials:"omit",body:JSON.stringify(a),signal:i.signal});if(!c.ok){let p;try{let f=await c.json?.();p=le(f?.error)}catch{p=void 0}let g=new Error(`[annotation] the ingest rejected the capture: ${p??`HTTP ${c.status}`}`);throw g.status=c.status,p!==void 0&&(g.reason=p),g}try{let p=await c.json?.(),g=C(p?.progressUrl);if(p?.kind==="saved"&&typeof p.feedbackId=="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(p.feedbackId)){let u=C(p.recoveryUrl);return{...g?{progressUrl:g}:{},saved:{feedbackId:p.feedbackId,...u?{recoveryUrl:u}:{},message:le(p.error)??"Capture saved. Finish filing in the console."}}}let f=C(p?.issueUrl??p?.url);if(f!==void 0||g!==void 0)return{...f?{issueUrl:f}:{},...g?{progressUrl:g}:{}}}catch{}return{}}catch(c){throw i.signal.aborted?new Error(`[annotation] the capture timed out after ${r}ms`,{cause:c}):c}finally{clearTimeout(s)}}}}function Ie(e,t){let n=(r,o)=>{let a={message:r,transport:e.name,error:o};if(t){t(a);return}console.error("[annotation] a capture could not be delivered",a)};return async r=>{if(!e.carries(r.type))return{status:"declined"};try{return{status:"sent",receipt:await e.send(r)??{}}}catch(o){return n(r,o),{status:"failed",error:o}}}}var St=1600,_t=1048576,Rt=23+4*Math.ceil(349525.3333333333),ze=4e3,on=()=>import("./page-capture.cjs"),Ze=48*1024,ce=480,Qe=250,an=[{edge:ce,quality:.7},{edge:ce/2,quality:.5}],sn=["image/webp","image/jpeg"];function Ne(e,t){let n=e===!1?{enabled:!1}:e??{},r=n.createCanvas??(()=>t?.createElement("canvas")??null);return{enabled:n.enabled??!0,maxBytes:n.maxBytes??Ze,maxEdge:n.maxEdge??ce,timeoutMs:n.timeoutMs??Qe,createCanvas:r,doc:t??null,page:n.page??!0,maxViewportWidth:n.maxViewportWidth??1600,maxViewportBytes:n.maxViewportBytes??1048576,viewportTimeoutMs:n.viewportTimeoutMs??ze,loadRenderer:n.loadRenderer??null,readCanvas:n.readCanvas??null}}var ln=new Set(["IMG","CANVAS","VIDEO"]),un="img,canvas,video",cn=4;function ue(e){return!!e&&ln.has(e.tagName.toUpperCase())}function et(e,t=cn){if(!e)return null;if(ue(e))return e;let n=e.querySelector?.(un)??null;if(ue(n))return n;let r=e.parentElement??null;for(let o=0;r&&o<t;o++){if(ue(r))return r;r=r.parentElement??null}return null}function tt(e){let t=e.tagName.toUpperCase(),n=t==="IMG"?{w:e.naturalWidth,h:e.naturalHeight}:t==="VIDEO"?{w:e.videoWidth,h:e.videoHeight}:{w:e.width,h:e.height},r=Math.floor(n.w??0),o=Math.floor(n.h??0);return!Number.isFinite(r)||!Number.isFinite(o)||r<1||o<1||t==="IMG"&&e.complete===!1?null:{w:r,h:o}}function nt(e,t){let n=Math.min(1,t/Math.max(e.w,e.h));return{w:Math.max(1,Math.round(e.w*n)),h:Math.max(1,Math.round(e.h*n))}}function dn(e,t,n,r){let o;try{o=r.createCanvas()}catch{return null}if(!o)return null;try{o.width=t.w,o.height=t.h;let a=o.getContext("2d");if(!a)return null;a.drawImage(e,0,0,t.w,t.h);for(let i of sn){let s;try{s=o.toDataURL(i,n)}catch{return null}if(!(typeof s!="string"||!s.startsWith(`data:${i}`)))return s.length<=r.maxBytes?s:null}return null}catch{return null}}function rt(e,t){if(!t.enabled)return null;let n=et(e);if(!n)return null;let r=tt(n);if(!r)return null;for(let o of an){let a=nt(r,Math.min(t.maxEdge,o.edge)),i=dn(n,a,o.quality,t);if(i)return{dataUrl:i,region:"element"}}return null}function pn(e,t){let n=e.doc;return!e.page||n===null?Promise.resolve(null):new Promise(r=>{let o=!1,a=c=>{o||(o=!0,r(c))},i=setTimeout(()=>a(null),e.viewportTimeoutMs);i.unref?.();let s={maxWidth:e.maxViewportWidth,maxBytes:e.maxViewportBytes,createCanvas:e.createCanvas,loadRenderer:e.loadRenderer,readCanvas:e.readCanvas};on().then(({captureViewport:c})=>c(n,s,t)).then(a,()=>a(null)).finally(()=>clearTimeout(i))})}async function ot(e,t,n=null){if(!t.enabled)return null;let r=await pn(t,n);return r||fn(e,t)}function fn(e,t){return new Promise(n=>{let r=!1,o=i=>{r||(r=!0,n(i))},a=setTimeout(()=>o(null),t.timeoutMs);a.unref?.(),Promise.resolve().then(()=>rt(e,t)).then(o,()=>o(null)).finally(()=>clearTimeout(a))})}async function de(e,t,n,r=null){let o;try{o=await ot(t,n,r)}catch{o=null}return o?{...e,screenshot:o}:e}var mn={consoleErrors:[],failedRequests:[],featureFlags:{}},wt=()=>({...mn});function Me(e){let t=e.parentOrigin===void 0?null:X(e.parentOrigin),n=window,r=n.document,o=Ne(e.screenshot,r),a=!1,i=null,s=0,c=null,p=!1,g=e.transport??(t===null?null:Ce(t,n));if(g===null)throw new Error("[annotation] the SDK needs a `transport` or a `parentOrigin`; with neither there is nowhere for a capture to go and every one of them would be lost in silence.");let f=Ie(g,e.onEgressError),u=d=>{let m=d.getBoundingClientRect();return{x:m.x,y:m.y,w:m.width,h:m.height}},b=d=>we(d,{boundingBox:u(d)}),A=d=>{if(d.componentName&&d.source){let m=d.source.file.split("/").pop()??d.source.file;return`${d.componentName} \xB7 ${m}:${d.source.line}`}return d.source?`${d.source.file}:${d.source.line}`:d.componentName??null},T=d=>{!a||p||s||(s=n.requestAnimationFrame(()=>{s=0;let m=r.elementFromPoint(d.clientX,d.clientY);if(!m||i&&i.contains(m)||e.ignoreElement?.(m)||m===c)return;c=m;let y=b(m);i?.show(y.boundingBox,A(y)),f({type:"annotate:hover",target:y})}))},w=(d,m)=>({schemaVersion:1,capturedAt:new Date().toISOString(),build:e.build,page:{url:n.location.href,route:e.getRoute(),viewport:{w:n.innerWidth,h:n.innerHeight,dpr:n.devicePixelRatio},userAgent:n.navigator.userAgent},target:b(d),state:{consoleErrors:m.consoleErrors,failedRequests:m.failedRequests,featureFlags:m.featureFlags},comment:""}),D=d=>{let m={type:"annotate:capture",payload:d},y=()=>{f(m).then(k=>e.onCaptureResult?.(k,y))};y()},I=d=>{if(!a)return;let m=d.target;if(!(m instanceof Element)||e.ignoreElement?.(m)||(d.preventDefault(),d.stopPropagation(),p))return;let y=w(m,e.getState()),k=e.collectComment;if(!k){if(!o.enabled){D(y);return}de(y,m,o,e.ignoreElement??null).then(_=>D(_),()=>D(y));return}let B={x:d.clientX,y:d.clientY},$=o.enabled?de(y,m,o,e.ignoreElement??null).then(_=>_,()=>y):Promise.resolve(y),W=()=>{p=!0;let _=null,G=k({target:y.target,point:B}).then(S=>S,S=>(_={error:S},null));Promise.all([$,G]).then(([S,Y])=>{if(p=!1,_!==null){e.onCaptureResult?.({status:"failed",error:_.error},W);return}Y!==null&&D(Y===""?S:{...S,comment:Y})})};W()},V=d=>{!a||p||d.key!=="Escape"||(f({type:"annotate:cancel"}),N())};function H(){a||(a=!0,i??(i=Se(r)),r.addEventListener("mousemove",T,!0),r.addEventListener("click",I,!0),r.addEventListener("keydown",V,!0))}function N(){a&&(a=!1,c=null,s&&(n.cancelAnimationFrame(s),s=0),r.removeEventListener("mousemove",T,!0),r.removeEventListener("click",I,!0),r.removeEventListener("keydown",V,!0),i?.hide())}let v=d=>{if(d.origin===t&&Te(d.data))switch(d.data.type){case"annotate:enable":H();break;case"annotate:disable":N();break;case"annotate:ping":f({type:"annotate:ready",sdkVersion:"1",build:e.build});break;default:{let m=d.data;yt("frame",m);break}}};return t!==null&&n.addEventListener("message",v),f({type:"annotate:ready",sdkVersion:"1",build:e.build}),{enable:H,disable:N,isEnabled:()=>a,destroy(){N(),t!==null&&n.removeEventListener("message",v),i?.destroy(),i=null}}}var M="ai.annotation.capture",P="ai.annotation.read",L="ai.annotation.run",gn="ai.annotation.attempt",hn="__weatherboardAnnotationAttemptV1",En="ai-annotation-startup-status";function kt(e,t,n){if(e!==null)try{delete e[hn]}catch{}if(t!==null)try{t.removeItem(gn)}catch{}n?.getElementById?.(En)?.remove()}var pe="ai.annotation.open",Ct=600*1e3;var F="ai_annotation_tokens",Pe=300;function q(e){if(!e)return null;let t=e.split(".");if(t[0]!=="v3"||t.length!==9&&t.length!==10)return null;let n=t[t.length-2];if(!n||!/^\d+$/.test(n))return null;let r=Number(n);return Number.isSafeInteger(r)?r:null}function fe(e,t,n=Math.floor(Date.now()/1e3)){let r=q(e);if(r===null||r-n<=Pe)return!0;if(t!==null){let o=q(t);if(o===null||o-n<=Pe)return!0}return!1}function It(e){let t=e.split(";").map(n=>n.trim()).find(n=>n.startsWith(`${F}=`));return t?h(()=>{let n=JSON.parse(decodeURIComponent(t.slice(F.length+1)));if(!n||typeof n!="object")return null;let r=n;return typeof r.captureToken!="string"||r.readToken!==null&&typeof r.readToken!="string"||r.runId!==null&&typeof r.runId!="string"?null:{captureToken:r.captureToken,readToken:r.readToken,runId:r.runId}},null):null}var Nt=[...ie,re,ae,oe];function h(e,t){try{return e()}catch{return t}}function bn(e){return h(()=>e?.sessionStorage??null,null)}function Mt(e={}){let t=e.doc??document,n=t.defaultView??null,r=e.storage===void 0?bn(n):e.storage,o=e.url??t.URL,a=h(()=>new URL(o),null),i=null,s=null,c=null;if(a!==null&&(i=a.searchParams.get(re)||null,s=a.searchParams.get(ae)||null,c=a.searchParams.get(oe)||null,Nt.some(b=>a.searchParams.has(b)))){for(let A of Nt)a.searchParams.delete(A);let b=e.history??n?.history;h(()=>{b?.replaceState(n?.history?.state??null,"",a.toString())},void 0)}let p=()=>{h(()=>{t.cookie=`${F}=; Max-Age=0; Secure; SameSite=Lax; Path=/`},void 0);for(let u of se)h(()=>{t.cookie=ve(u)},void 0);r&&(h(()=>r.removeItem(M),void 0),h(()=>r.removeItem(P),void 0),h(()=>r.removeItem(L),void 0)),kt(n,r,t)},g=Oe(h(()=>t.cookie,""));if(!g)return It(h(()=>t.cookie,""))&&h(()=>{t.cookie=`${F}=; Max-Age=0; Secure; SameSite=Lax; Path=/`},void 0),{armed:!1,captureToken:null,readToken:null,runId:null,disarm:p};r&&(i!==null?h(()=>r.setItem(M,i),void 0):i=h(()=>r.getItem(M),null),s!==null?h(()=>r.setItem(P,s),void 0):s=h(()=>r.getItem(P),null),c!==null?h(()=>r.setItem(L,c),void 0):c=h(()=>r.getItem(L),null));let f=h(()=>t.cookie,"");if(i===null){let u=It(f);u&&!fe(u.captureToken,u.readToken)&&(i=u.captureToken,s??(s=u.readToken),c??(c=u.runId),r&&(h(()=>r.setItem(M,i),void 0),s&&h(()=>r.setItem(P,s),void 0),c&&h(()=>r.setItem(L,c),void 0)))}if(i!==null){let u=q(i),b=s===null?null:q(s),A=Math.floor(Date.now()/1e3),T=Math.min(u??0,s===null?1/0:b??0);if(T>A){let w=encodeURIComponent(JSON.stringify({captureToken:i,readToken:s,runId:c}));h(()=>{t.cookie=`${F}=${w}; Max-Age=${T-A}; Secure; SameSite=Lax; Path=/`},void 0)}}return{armed:g,captureToken:i,readToken:s,runId:c,disarm:p}}var An=["preview","staging","development"];function me(e){return An.includes(e.env)}var at="Mod+Shift+Period";function ge(e,t){let n=t.split("+"),r=n.pop();if(!r||e.repeat||n.some(c=>!["Mod","Meta","Ctrl","Shift","Alt"].includes(c)))return!1;let o=n.includes("Mod"),a=n.includes("Meta"),i=n.includes("Ctrl");return(o?e.metaKey!==e.ctrlKey&&!a&&!i:e.metaKey===a&&e.ctrlKey===i)&&e.shiftKey===n.includes("Shift")&&e.altKey===n.includes("Alt")&&(e.code===r||e.key.toLowerCase()===r.toLowerCase()||r==="Period"&&e.key===".")}var it={region:"Annotation",expand:"Open the annotation toolbar",collapse:"Close the annotation toolbar",start:"Start annotating",stop:"Stop annotating",done:"Done",comment:"What is wrong here?",placeholder:"The heading wraps onto three lines on mobile\u2026",send:"Send",cancel:"Cancel",sent:"Sent",issue:"View issue",failed:"That did not send",retry:"Retry"},st="ai-annotation-toolbar",yn="2147483001",Lt=288,Pt=190,j=12,Tn=`
2
2
  :host{
3
3
  --ai-bg:#fff;
4
4
  --ai-fg:#18181b;
@@ -18,7 +18,7 @@
18
18
  --ai-radius-control:6px;
19
19
  --ai-radius-card:8px;
20
20
  --ai-radius-pill:999px;
21
- all:initial;position:fixed;right:16px;bottom:16px;z-index:${$t};
21
+ all:initial;position:fixed;right:16px;bottom:16px;z-index:${yn};
22
22
  font:13px/1.45 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
23
23
  color-scheme:light}
24
24
  *,*::before,*::after{box-sizing:border-box}
@@ -41,7 +41,7 @@ button:focus-visible{outline:2px solid var(--ai-accent);outline-offset:2px}
41
41
  padding:var(--ai-space-2)}
42
42
  .toggle[aria-pressed="true"]{background:var(--ai-accent);border-color:var(--ai-accent);
43
43
  color:var(--ai-invert-fg)}
44
- .composer{position:fixed;width:${ft}px;background:var(--ai-bg);color:var(--ai-fg);
44
+ .composer{position:fixed;width:${Lt}px;background:var(--ai-bg);color:var(--ai-fg);
45
45
  border:1px solid var(--ai-line);border-radius:var(--ai-radius-card);
46
46
  padding:var(--ai-space-4);display:flex;flex-direction:column;gap:var(--ai-space-3)}
47
47
  .where{margin:0;font:11px/16px ui-monospace,SFMono-Regular,Menlo,monospace;
@@ -61,5 +61,5 @@ textarea:focus-visible{outline:2px solid var(--ai-accent);outline-offset:1px}
61
61
  .toast a{color:var(--ai-invert-fg)}
62
62
  .toast button{background:transparent;border-color:var(--ai-invert-line);
63
63
  color:var(--ai-invert-fg)}
64
- `;function h(e,t,n){let r=e.createElement(t);if(n)for(let o of Object.keys(n))r.setAttribute(o,n[o]??"");return r}function je(e={}){let t={...Ge,...e.labels},n=e.doc??document,r=e.win??window;if(e.armed===!1)return{owns:()=>!1,attach:()=>{},collectComment:()=>Promise.resolve(""),showResult:()=>{},isExpanded:()=>!1,destroy:()=>{}};let o=h(n,"div",{id:We}),a=o.attachShadow({mode:"open"}),s=h(n,"style");s.textContent=Bt,a.appendChild(s);let c=h(n,"style");a.appendChild(c);let f=h(n,"div",{id:"ai-annotation-bar",class:"bar",role:"region","aria-label":t.region}),m=h(n,"div",{class:"panel",id:"ai-annotation-panel",hidden:""}),g=h(n,"button",{type:"button",id:"ai-annotation-toggle",class:"toggle","aria-pressed":"false"});g.textContent=t.start;let p=h(n,"button",{type:"button",id:"ai-annotation-done"});p.textContent=t.done,m.appendChild(g),m.appendChild(p);let u=h(n,"button",{type:"button",id:"ai-annotation-pill",class:"pill","aria-expanded":"false","aria-controls":"ai-annotation-panel","aria-label":t.expand}),A=h(n,"span",{class:"dot","aria-hidden":"true"}),T=h(n,"span");T.textContent=t.region,u.appendChild(A),u.appendChild(T),f.appendChild(u),f.appendChild(m),a.appendChild(f);let x=h(n,"div",{id:"ai-annotation-composer",class:"composer",role:"dialog","aria-modal":"false","aria-labelledby":"ai-annotation-comment",hidden:""}),R=h(n,"p",{class:"where"}),N=h(n,"label",{id:"ai-annotation-comment",for:"ai-annotation-input"});N.textContent=t.comment;let _=h(n,"textarea",{id:"ai-annotation-input",placeholder:t.placeholder,rows:"3"}),P=h(n,"button",{type:"button",id:"ai-annotation-cancel"});P.textContent=t.cancel;let F=h(n,"button",{type:"button",id:"ai-annotation-send",class:"primary"});F.textContent=t.send;let k=h(n,"div",{class:"row"});k.appendChild(P),k.appendChild(F),x.appendChild(R),x.appendChild(N),x.appendChild(_),x.appendChild(k),a.appendChild(x);let S=h(n,"div",{id:"ai-annotation-toast",class:"toast",role:"status",hidden:""}),l=h(n,"span"),d=h(n,"a",{id:"ai-annotation-issue",target:"_blank",rel:"noopener noreferrer",hidden:""}),b=h(n,"button",{type:"button",id:"ai-annotation-retry",hidden:""});b.textContent=t.retry,S.appendChild(l),S.appendChild(d),S.appendChild(b),a.appendChild(S),n.body.appendChild(o);let O=null,$=!1,B=null,I=null,C=null,ae=()=>{},y=(i,E)=>{E?i.removeAttribute("hidden"):i.setAttribute("hidden","")},U=i=>{$=i,y(m,i),u.setAttribute("aria-expanded",String(i)),u.setAttribute("aria-label",i?t.collapse:t.expand)},Se=i=>{g.setAttribute("aria-pressed",String(i)),g.textContent=i?t.stop:t.start,f.setAttribute("class",i?"bar on":"bar"),i?O?.enable():O?.disable()};u.addEventListener("click",()=>U(!$)),g.addEventListener("click",()=>{Se(O?.isEnabled()!==!0)});let Je=()=>{C!==null&&clearTimeout(C),q(null),o.remove()};p.addEventListener("click",()=>{Se(!1),U(!1),e.onDone?.(),Je()});let q=i=>{let E=B;B=null,y(x,!1),E&&E(i),I instanceof HTMLElement&&I.focus(),I=null};P.addEventListener("click",()=>q(null)),F.addEventListener("click",()=>q(_.value)),x.addEventListener("keydown",i=>{if(i.key==="Escape"){i.stopPropagation(),q(null);return}i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.preventDefault(),q(_.value))});let Et=i=>new Promise(E=>{B=E,_.value="",R.textContent=yt(i),At(i),y(S,!1),y(x,!0),I=n.activeElement,_.focus()});function yt(i){let{source:E,componentName:w}=i.target;return E?`${E.file}:${E.line}`:w??""}function At(i){let E=i.target.boundingBox,w=E.y+E.h+H,X=w+pt<=r.innerHeight?w:Math.max(H,E.y-pt-H),Ce=Math.min(Math.max(H,E.x),Math.max(H,r.innerWidth-ft-H));c.textContent=`.composer{left:${Math.round(Ce)}px;top:${Math.round(X)}px}`}let xt=(i,E)=>{C!==null&&clearTimeout(C);let w=i.status==="sent",X=i.status==="sent"?Z(i.receipt.issueUrl):void 0;S.setAttribute("class",w?"toast":"toast bad"),S.setAttribute("role",w?"status":"alert");let Ce=w?void 0:he(i.error);l.textContent=w?t.sent:Ce??t.failed,y(d,w&&X!==void 0),X!==void 0&&(d.setAttribute("href",X),d.textContent=t.issue),y(b,!w),y(S,!0),w&&(C=setTimeout(()=>y(S,!1),6e3)),ae=E};return b.addEventListener("click",()=>{y(S,!1),ae()}),{owns:i=>i instanceof Node&&(i===o||o.contains(i)),attach:i=>{O=i,Se(i.isEnabled())},collectComment:Et,showResult:xt,isExpanded:()=>$,destroy:Je}}function mt(e){let t=e.toolbar?.armed;if(e.arming&&t!==void 0)throw new Error("[annotation] pass `arming` OR `toolbar.armed`, not both; two answers to whether this page may offer an annotation UI is how one of them stops being checked.");let n=(e.arming?e.arming.armed:t)!==!1&&xe(e.build),r=je({...e.toolbar,armed:n,onDone:()=>{e.arming?.disarm(),o.destroy(),e.toolbar?.onDone?.()}}),o=Ae({...e,collectComment:r.collectComment,onCaptureResult:r.showResult,ignoreElement:r.owns});return r.attach(o),{sdk:o,toolbar:r,destroy(){r.destroy(),o.destroy()}}}var gt=20;var M,oe,K=class{constructor(t=20){Oe(this,M,[]);Oe(this,oe);et(this,oe,Math.max(1,t))}push(t){L(this,M).push(t),L(this,M).length>L(this,oe)&&L(this,M).shift()}toArray(){return[...L(this,M)]}get size(){return L(this,M).length}};M=new WeakMap,oe=new WeakMap;function Ve(e){if(typeof e=="string")return e;if(e instanceof Error)return`${e.name}: ${e.message}`;if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{try{return`[${Object.getPrototypeOf(e)?.constructor?.name??"object"}]`}catch{return"[object]"}}try{return String(e)}catch{return"[unrenderable]"}}var ht=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;function Ye(e){return ht(e.map(Ve).join(" "),500)}function Te(e){for(let t of e)if(t instanceof Error&&typeof t.stack=="string")return ht(t.stack,2e3)}function ve(e){return e===0||e<200||e>=300}var ze=()=>({limit:20,getFeatureFlags:()=>({}),now:()=>new Date().toISOString()});function bt(e,t=ze()){let n=new K(t.limit),r=new K(t.limit),o=(p,u)=>{n.push({level:p,message:Ye(u),...Te(u)?{stack:Te(u)}:{},at:t.now()})},a=e.console.error,s=e.console.warn;e.console.error=function(...u){try{o("error",u)}catch{}return a.apply(e.console,u)},e.console.warn=function(...u){try{o("warn",u)}catch{}return s.apply(e.console,u)};let c=e.fetch,f=(p,u)=>{let A=typeof p=="string"?p:p instanceof URL?p.href:p?.url??String(p),T=u?.method??p?.method??"GET";return{url:A,method:T.toUpperCase()}};typeof c=="function"&&(e.fetch=async function(u,A){try{let T=await c.call(e,u,A);if(ve(T.status)){let{url:x,method:R}=f(u,A);r.push({url:x,method:R,status:T.status,at:t.now()})}return T}catch(T){let{url:x,method:R}=f(u,A);throw r.push({url:x,method:R,status:0,at:t.now()}),T}});let m=e.XMLHttpRequest,g=m?.prototype?.open;return typeof g=="function"&&(m.prototype.open=function(u,A,...T){return this.__aiAnnotateMethod=u.toUpperCase(),this.__aiAnnotateUrl=String(A),this.addEventListener("loadend",()=>{try{ve(this.status)&&r.push({url:this.__aiAnnotateUrl??"",method:this.__aiAnnotateMethod??"GET",status:this.status,at:t.now()})}catch{}}),g.apply(this,[u,A,...T])}),{getState(){return{consoleErrors:n.toArray(),failedRequests:r.toArray(),featureFlags:t.getFeatureFlags()}},destroy(){e.console.error=a,e.console.warn=s,typeof c=="function"&&(e.fetch=c),typeof g=="function"&&(m.prototype.open=g)}}}
64
+ `;function E(e,t,n){let r=e.createElement(t);if(n)for(let o of Object.keys(n))r.setAttribute(o,n[o]??"");return r}function lt(e={}){let t={...it,...e.labels},n=e.doc??document,r=e.win??window;if(e.armed===!1)return{owns:()=>!1,attach:()=>{},collectComment:()=>Promise.resolve(""),showResult:()=>{},isExpanded:()=>!1,setVisible:()=>{},isVisible:()=>!1,destroy:()=>{}};let o=E(n,"div",{id:st}),a=o.attachShadow({mode:"open"}),i=E(n,"style");i.textContent=Tn,a.appendChild(i);let s=E(n,"style");a.appendChild(s);let c=E(n,"div",{id:"ai-annotation-bar",class:"bar",role:"region","aria-label":t.region}),p=E(n,"div",{class:"panel",id:"ai-annotation-panel",hidden:""}),g=E(n,"button",{type:"button",id:"ai-annotation-toggle",class:"toggle","aria-pressed":"false"});g.textContent=t.start;let f=E(n,"button",{type:"button",id:"ai-annotation-done"});f.textContent=t.done,p.appendChild(g),p.appendChild(f);let u=E(n,"button",{type:"button",id:"ai-annotation-pill",class:"pill","aria-expanded":"false","aria-controls":"ai-annotation-panel","aria-label":t.expand}),b=E(n,"span",{class:"dot","aria-hidden":"true"}),A=E(n,"span");A.textContent=t.region,u.appendChild(b),u.appendChild(A),c.appendChild(u),c.appendChild(p),a.appendChild(c);let T=E(n,"div",{id:"ai-annotation-composer",class:"composer",role:"dialog","aria-modal":"false","aria-labelledby":"ai-annotation-comment",hidden:""}),w=E(n,"p",{class:"where"}),D=E(n,"label",{id:"ai-annotation-comment",for:"ai-annotation-input"});D.textContent=t.comment;let I=E(n,"textarea",{id:"ai-annotation-input",placeholder:t.placeholder,rows:"3"}),V=E(n,"button",{type:"button",id:"ai-annotation-cancel"});V.textContent=t.cancel;let H=E(n,"button",{type:"button",id:"ai-annotation-send",class:"primary"});H.textContent=t.send;let N=E(n,"div",{class:"row"});N.appendChild(V),N.appendChild(H),T.appendChild(w),T.appendChild(D),T.appendChild(I),T.appendChild(N),a.appendChild(T);let v=E(n,"div",{id:"ai-annotation-toast",class:"toast",role:"status",hidden:""}),d=E(n,"span"),m=E(n,"a",{id:"ai-annotation-progress",target:"_blank",rel:"noopener noreferrer",hidden:""});m.textContent="View progress";let y=E(n,"a",{id:"ai-annotation-recovery",target:"_blank",rel:"noopener noreferrer",hidden:""});y.textContent="Open saved capture";let k=E(n,"a",{id:"ai-annotation-issue",target:"_blank",rel:"noopener noreferrer",hidden:""});k.textContent=t.issue;let B=E(n,"button",{type:"button",id:"ai-annotation-retry",hidden:""});B.textContent=t.retry,v.appendChild(d),v.appendChild(m),v.appendChild(y),v.appendChild(k),v.appendChild(B),a.appendChild(v),e.dormant||n.body.appendChild(o);let $=null,W=!1,_=null,G=null,S=null,Y=()=>{},R=(l,x)=>{x?l.removeAttribute("hidden"):l.setAttribute("hidden","")},Ee=l=>{W=l,R(p,l),u.setAttribute("aria-expanded",String(l)),u.setAttribute("aria-label",l?t.collapse:t.expand)},be=l=>{g.setAttribute("aria-pressed",String(l)),g.textContent=l?t.stop:t.start,c.setAttribute("class",l?"bar on":"bar"),l?$?.enable():$?.disable()};u.addEventListener("click",()=>Ee(!W)),g.addEventListener("click",()=>{be($?.isEnabled()!==!0)});let pt=()=>{S!==null&&clearTimeout(S),z(null),o.remove()};f.addEventListener("click",()=>{be(!1),Ee(!1),e.onDone?.(),pt()});let z=l=>{let x=_;_=null,R(T,!1),x&&x(l),G instanceof HTMLElement&&G.focus(),G=null};V.addEventListener("click",()=>z(null)),H.addEventListener("click",()=>z(I.value)),T.addEventListener("keydown",l=>{if(l.key==="Escape"){l.stopPropagation(),z(null);return}l.key==="Enter"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),z(I.value))});let Vt=l=>new Promise(x=>{_=x,I.value="",w.textContent=Ht(l),Bt(l),R(v,!1),R(T,!0),G=n.activeElement,I.focus()});function Ht(l){let{source:x,componentName:O}=l.target;return x?`${x.file}:${x.line}`:O??""}function Bt(l){let x=l.target.boundingBox,O=x.y+x.h+j,Z=O+Pt<=r.innerHeight?O:Math.max(j,x.y-Pt-j),Q=Math.min(Math.max(j,x.x),Math.max(j,r.innerWidth-Lt-j));s.textContent=`.composer{left:${Math.round(Q)}px;top:${Math.round(Z)}px}`}let $t=(l,x)=>{S!==null&&clearTimeout(S),o.parentElement!==n.body&&n.body.appendChild(o);let O=l.status==="sent",Z=l.status==="sent"?C(l.receipt.issueUrl):void 0,Q=l.status==="sent"?C(l.receipt.progressUrl):void 0;v.setAttribute("class",O?"toast":"toast bad"),v.setAttribute("role",O?"status":"alert");let Wt=O?void 0:ke(l.error),ee=l.status==="sent"?l.receipt.saved:void 0;d.textContent=ee?`${ee.message} Capture ID: ${ee.feedbackId}`:O?t.sent:Wt??t.failed;let De=C(ee?.recoveryUrl);R(m,O&&Q!==void 0),R(y,O&&De!==void 0),R(k,O&&Z!==void 0),Q&&m.setAttribute("href",Q),De&&y.setAttribute("href",De),Z&&k.setAttribute("href",Z),R(B,!O),R(v,!0),O&&!ee&&(S=setTimeout(()=>R(v,!1),6e3)),Y=x};return B.addEventListener("click",()=>{R(v,!1),Y()}),{owns:l=>l instanceof Node&&(l===o||o.contains(l)),attach:l=>{$=l,be(l.isEnabled())},collectComment:Vt,showResult:$t,isExpanded:()=>W,setVisible:l=>{l?(o.parentElement!==n.body&&n.body.appendChild(o),Ee(!0)):(be(!1),Ee(!1),o.remove())},isVisible:()=>o.parentElement===n.body,destroy:pt}}function Ut(e){let t=e.hotkey??null,n=e.toolbar?.doc??document,r=()=>{try{let f=(n.defaultView??window).sessionStorage,u=Number(f.getItem(pe));return f.removeItem(pe),u>0&&Date.now()-u<Ct}catch{return!1}},o=!0,a=e.toolbar?.armed;if(e.arming&&a!==void 0)throw new Error("[annotation] pass `arming` OR `toolbar.armed`, not both; two answers to whether this page may offer an annotation UI is how one of them stops being checked.");let i=(e.arming?e.arming.armed:a)!==!1&&me(e.build),s=lt({...e.toolbar,armed:i,dormant:t!==null,onDone:()=>{o=!1,t&&n.removeEventListener("keydown",p,!0),e.arming?.disarm(),c.destroy(),e.toolbar?.onDone?.()}}),c=Me({...e,collectComment:s.collectComment,onCaptureResult:s.showResult,ignoreElement:s.owns});s.attach(c);let p=f=>{!o||!t||!ge(f,t)||!me(e.build)||g()||(f.preventDefault(),s.setVisible(!s.isVisible()))},g=()=>!!e.arming&&(!e.arming.armed||fe(e.arming.captureToken,e.arming.readToken));return t&&(n.addEventListener("keydown",p,!0),i&&!g()&&r()&&s.setVisible(!0)),{sdk:c,toolbar:s,destroy(){o=!1,t&&n.removeEventListener("keydown",p,!0),s.destroy(),c.destroy()}}}var Dt=20;var U,he,J=class{constructor(t=20){Ke(this,U,[]);Ke(this,he);ht(this,he,Math.max(1,t))}push(t){K(this,U).push(t),K(this,U).length>K(this,he)&&K(this,U).shift()}toArray(){return[...K(this,U)]}get size(){return K(this,U).length}};U=new WeakMap,he=new WeakMap;function ut(e){if(typeof e=="string")return e;if(e instanceof Error)return`${e.name}: ${e.message}`;if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{try{return`[${Object.getPrototypeOf(e)?.constructor?.name??"object"}]`}catch{return"[object]"}}try{return String(e)}catch{return"[unrenderable]"}}var Kt=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;function ct(e){return Kt(e.map(ut).join(" "),500)}function Le(e){for(let t of e)if(t instanceof Error&&typeof t.stack=="string")return Kt(t.stack,2e3)}function Ue(e){return e===0||e<200||e>=300}var dt=()=>({limit:20,getFeatureFlags:()=>({}),now:()=>new Date().toISOString()});function Ft(e,t=dt()){let n=new J(t.limit),r=new J(t.limit),o=(f,u)=>{n.push({level:f,message:ct(u),...Le(u)?{stack:Le(u)}:{},at:t.now()})},a=e.console.error,i=e.console.warn;e.console.error=function(...u){try{o("error",u)}catch{}return a.apply(e.console,u)},e.console.warn=function(...u){try{o("warn",u)}catch{}return i.apply(e.console,u)};let s=e.fetch,c=(f,u)=>{let b=typeof f=="string"?f:f instanceof URL?f.href:f?.url??String(f),A=u?.method??f?.method??"GET";return{url:b,method:A.toUpperCase()}};typeof s=="function"&&(e.fetch=async function(u,b){try{let A=await s.call(e,u,b);if(Ue(A.status)){let{url:T,method:w}=c(u,b);r.push({url:T,method:w,status:A.status,at:t.now()})}return A}catch(A){let{url:T,method:w}=c(u,b);throw r.push({url:T,method:w,status:0,at:t.now()}),A}});let p=e.XMLHttpRequest,g=p?.prototype?.open;return typeof g=="function"&&(p.prototype.open=function(u,b,...A){return this.__aiAnnotateMethod=u.toUpperCase(),this.__aiAnnotateUrl=String(b),this.addEventListener("loadend",()=>{try{Ue(this.status)&&r.push({url:this.__aiAnnotateUrl??"",method:this.__aiAnnotateMethod??"GET",status:this.status,at:t.now()})}catch{}}),g.apply(this,[u,b,...A])}),{getState(){return{consoleErrors:n.toArray(),failedRequests:r.toArray(),featureFlags:t.getFeatureFlags()}},destroy(){e.console.error=a,e.console.warn=i,typeof s=="function"&&(e.fetch=s),typeof g=="function"&&(p.prototype.open=g)}}}
65
65
  //# sourceMappingURL=index.cjs.map