@unnoodle/browser 0.1.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,2639 @@
1
+ 'use strict';var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnPropertyDescriptors;var Yt=Object.getOwnPropertySymbols;var Wn=Object.prototype.hasOwnProperty,jn=Object.prototype.propertyIsEnumerable;var Xt=(i,e,t)=>e in i?_n(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,S=(i,e)=>{for(var t in e||(e={}))Wn.call(e,t)&&Xt(i,t,e[t]);if(Yt)for(var t of Yt(e))jn.call(e,t)&&Xt(i,t,e[t]);return i},J=(i,e)=>Gn(i,Vn(e));function me(i){return Array.isArray?Array.isArray(i):ro(i)==="[object Array]"}function Kn(i){if(typeof i=="string")return i;let e=i+"";return e=="0"&&1/i==-Infinity?"-0":e}function Yn(i){return i==null?"":Kn(i)}function ce(i){return typeof i=="string"}function no(i){return typeof i=="number"}function Xn(i){return i===true||i===false||Jn(i)&&ro(i)=="[object Boolean]"}function io(i){return typeof i=="object"}function Jn(i){return io(i)&&i!==null}function ie(i){return i!=null}function xt(i){return !i.trim().length}function ro(i){return i==null?i===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(i)}var Qn="Incorrect 'index' type",ei=i=>`Invalid value for key ${i}`,ti=i=>`Pattern length exceeds max of ${i}.`,oi=i=>`Missing ${i} property in key`,ni=i=>`Property 'weight' in key '${i}' must be a positive integer`,Jt=Object.prototype.hasOwnProperty,kt=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(n=>{let o=so(n);this._keys.push(o),this._keyMap[o.id]=o,t+=o.weight;}),this._keys.forEach(n=>{n.weight/=t;});}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function so(i){let e=null,t=null,n=null,o=1,r=null;if(ce(i)||me(i))n=i,e=Qt(i),t=Et(i);else {if(!Jt.call(i,"name"))throw new Error(oi("name"));let s=i.name;if(n=s,Jt.call(i,"weight")&&(o=i.weight,o<=0))throw new Error(ni(s));e=Qt(s),t=Et(s),r=i.getFn;}return {path:e,id:t,weight:o,src:n,getFn:r}}function Qt(i){return me(i)?i:i.split(".")}function Et(i){return me(i)?i.join("."):i}function ii(i,e){let t=[],n=false,o=(r,s,a)=>{if(ie(r))if(!s[a])t.push(r);else {let c=s[a],d=r[c];if(!ie(d))return;if(a===s.length-1&&(ce(d)||no(d)||Xn(d)))t.push(Yn(d));else if(me(d)){n=true;for(let l=0,p=d.length;l<p;l+=1)o(d[l],s,a+1);}else s.length&&o(d,s,a+1);}};return o(i,ce(e)?e.split("."):e,0),n?t:t[0]}var ri={includeMatches:false,findAllMatches:false,minMatchCharLength:1},si={isCaseSensitive:false,ignoreDiacritics:false,includeScore:false,keys:[],shouldSort:true,sortFn:(i,e)=>i.score===e.score?i.idx<e.idx?-1:1:i.score<e.score?-1:1},ai={location:0,threshold:.6,distance:100},li={useExtendedSearch:false,getFn:ii,ignoreLocation:false,ignoreFieldNorm:false,fieldNormWeight:1},M=S(S(S(S({},si),ri),ai),li),di=/[^ ]+/g;function ci(i=1,e=3){let t=new Map,n=Math.pow(10,e);return {get(o){let r=o.match(di).length;if(t.has(r))return t.get(r);let s=1/Math.pow(r,.5*i),a=parseFloat(Math.round(s*n)/n);return t.set(r,a),a},clear(){t.clear();}}}var Ae=class{constructor({getFn:e=M.getFn,fieldNormWeight:t=M.fieldNormWeight}={}){this.norm=ci(t,3),this.getFn=e,this.isCreated=false,this.setIndexRecords();}setSources(e=[]){this.docs=e;}setIndexRecords(e=[]){this.records=e;}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,n)=>{this._keysMap[t.id]=n;});}create(){this.isCreated||!this.docs.length||(this.isCreated=true,ce(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t);}):this.docs.forEach((e,t)=>{this._addObject(e,t);}),this.norm.clear());}add(e){let t=this.size();ce(e)?this._addString(e,t):this._addObject(e,t);}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)this.records[t].i-=1;}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!ie(e)||xt(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n);}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((o,r)=>{let s=o.getFn?o.getFn(e):this.getFn(e,o.path);if(ie(s)){if(me(s)){let a=[],c=[{nestedArrIndex:-1,value:s}];for(;c.length;){let{nestedArrIndex:d,value:l}=c.pop();if(ie(l))if(ce(l)&&!xt(l)){let p={v:l,i:d,n:this.norm.get(l)};a.push(p);}else me(l)&&l.forEach((p,h)=>{c.push({nestedArrIndex:h,value:p});});}n.$[r]=a;}else if(ce(s)&&!xt(s)){let a={v:s,n:this.norm.get(s)};n.$[r]=a;}}}),this.records.push(n);}toJSON(){return {keys:this.keys,records:this.records}}};function ao(i,e,{getFn:t=M.getFn,fieldNormWeight:n=M.fieldNormWeight}={}){let o=new Ae({getFn:t,fieldNormWeight:n});return o.setKeys(i.map(so)),o.setSources(e),o.create(),o}function ui(i,{getFn:e=M.getFn,fieldNormWeight:t=M.fieldNormWeight}={}){let{keys:n,records:o}=i,r=new Ae({getFn:e,fieldNormWeight:t});return r.setKeys(n),r.setIndexRecords(o),r}function Ne(i,{errors:e=0,currentLocation:t=0,expectedLocation:n=0,distance:o=M.distance,ignoreLocation:r=M.ignoreLocation}={}){let s=e/i.length;if(r)return s;let a=Math.abs(n-t);return o?s+a/o:a?1:s}function pi(i=[],e=M.minMatchCharLength){let t=[],n=-1,o=-1,r=0;for(let s=i.length;r<s;r+=1){let a=i[r];a&&n===-1?n=r:!a&&n!==-1&&(o=r-1,o-n+1>=e&&t.push([n,o]),n=-1);}return i[r-1]&&r-n>=e&&t.push([n,r-1]),t}var ye=32;function hi(i,e,t,{location:n=M.location,distance:o=M.distance,threshold:r=M.threshold,findAllMatches:s=M.findAllMatches,minMatchCharLength:a=M.minMatchCharLength,includeMatches:c=M.includeMatches,ignoreLocation:d=M.ignoreLocation}={}){if(e.length>ye)throw new Error(ti(ye));let l=e.length,p=i.length,h=Math.max(0,Math.min(n,p)),m=r,v=h,f=a>1||c,y=f?Array(p):[],A;for(;(A=i.indexOf(e,v))>-1;){let _=Ne(e,{currentLocation:A,expectedLocation:h,distance:o,ignoreLocation:d});if(m=Math.min(_,m),v=A+l,f){let C=0;for(;C<l;)y[A+C]=1,C+=1;}}v=-1;let L=[],N=1,U=l+p,F=1<<l-1;for(let _=0;_<l;_+=1){let C=0,$=U;for(;C<$;)Ne(e,{errors:_,currentLocation:h+$,expectedLocation:h,distance:o,ignoreLocation:d})<=m?C=$:U=$,$=Math.floor((U-C)/2+C);U=$;let Y=Math.max(1,h-$+1),H=s?p:Math.min(h+$,p)+l,P=Array(H+2);P[H+1]=(1<<_)-1;for(let I=H;I>=Y;I-=1){let X=I-1,j=t[i.charAt(X)];if(f&&(y[X]=+!!j),P[I]=(P[I+1]<<1|1)&j,_&&(P[I]|=(L[I+1]|L[I])<<1|1|L[I+1]),P[I]&F&&(N=Ne(e,{errors:_,currentLocation:X,expectedLocation:h,distance:o,ignoreLocation:d}),N<=m)){if(m=N,v=X,v<=h)break;Y=Math.max(1,2*h-v);}}if(Ne(e,{errors:_+1,currentLocation:h,expectedLocation:h,distance:o,ignoreLocation:d})>m)break;L=P;}let Q={isMatch:v>=0,score:Math.max(.001,N)};if(f){let _=pi(y,a);_.length?c&&(Q.indices=_):Q.isMatch=false;}return Q}function mi(i){let e={};for(let t=0,n=i.length;t<n;t+=1){let o=i.charAt(t);e[o]=(e[o]||0)|1<<n-t-1;}return e}var Ue=String.prototype.normalize?(i=>i.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(i=>i),Fe=class{constructor(e,{location:t=M.location,threshold:n=M.threshold,distance:o=M.distance,includeMatches:r=M.includeMatches,findAllMatches:s=M.findAllMatches,minMatchCharLength:a=M.minMatchCharLength,isCaseSensitive:c=M.isCaseSensitive,ignoreDiacritics:d=M.ignoreDiacritics,ignoreLocation:l=M.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:o,includeMatches:r,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:l},e=c?e:e.toLowerCase(),e=d?Ue(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let p=(m,v)=>{this.chunks.push({pattern:m,alphabet:mi(m),startIndex:v});},h=this.pattern.length;if(h>ye){let m=0,v=h%ye,f=h-v;for(;m<f;)p(this.pattern.substr(m,ye),m),m+=ye;if(v){let y=h-ye;p(this.pattern.substr(y),y);}}else p(this.pattern,0);}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:o}=this.options;if(e=t?e:e.toLowerCase(),e=n?Ue(e):e,this.pattern===e){let f={isMatch:true,score:0};return o&&(f.indices=[[0,e.length-1]]),f}let{location:r,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:d,ignoreLocation:l}=this.options,p=[],h=0,m=false;this.chunks.forEach(({pattern:f,alphabet:y,startIndex:A})=>{let{isMatch:L,score:N,indices:U}=hi(e,f,y,{location:r+A,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:d,includeMatches:o,ignoreLocation:l});L&&(m=true),h+=N,L&&U&&(p=[...p,...U]);});let v={isMatch:m,score:m?h/this.chunks.length:1};return m&&o&&(v.indices=p),v}},ue=class{constructor(e){this.pattern=e;}static isMultiMatch(e){return eo(e,this.multiRegex)}static isSingleMatch(e){return eo(e,this.singleRegex)}search(){}};function eo(i,e){let t=i.match(e);return t?t[1]:null}var Tt=class extends ue{constructor(e){super(e);}static get type(){return "exact"}static get multiRegex(){return /^="(.*)"$/}static get singleRegex(){return /^=(.*)$/}search(e){let t=e===this.pattern;return {isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},Ct=class extends ue{constructor(e){super(e);}static get type(){return "inverse-exact"}static get multiRegex(){return /^!"(.*)"$/}static get singleRegex(){return /^!(.*)$/}search(e){let n=e.indexOf(this.pattern)===-1;return {isMatch:n,score:n?0:1,indices:[0,e.length-1]}}},Mt=class extends ue{constructor(e){super(e);}static get type(){return "prefix-exact"}static get multiRegex(){return /^\^"(.*)"$/}static get singleRegex(){return /^\^(.*)$/}search(e){let t=e.startsWith(this.pattern);return {isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},Lt=class extends ue{constructor(e){super(e);}static get type(){return "inverse-prefix-exact"}static get multiRegex(){return /^!\^"(.*)"$/}static get singleRegex(){return /^!\^(.*)$/}search(e){let t=!e.startsWith(this.pattern);return {isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},St=class extends ue{constructor(e){super(e);}static get type(){return "suffix-exact"}static get multiRegex(){return /^"(.*)"\$$/}static get singleRegex(){return /^(.*)\$$/}search(e){let t=e.endsWith(this.pattern);return {isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},At=class extends ue{constructor(e){super(e);}static get type(){return "inverse-suffix-exact"}static get multiRegex(){return /^!"(.*)"\$$/}static get singleRegex(){return /^!(.*)\$$/}search(e){let t=!e.endsWith(this.pattern);return {isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},Oe=class extends ue{constructor(e,{location:t=M.location,threshold:n=M.threshold,distance:o=M.distance,includeMatches:r=M.includeMatches,findAllMatches:s=M.findAllMatches,minMatchCharLength:a=M.minMatchCharLength,isCaseSensitive:c=M.isCaseSensitive,ignoreDiacritics:d=M.ignoreDiacritics,ignoreLocation:l=M.ignoreLocation}={}){super(e),this._bitapSearch=new Fe(e,{location:t,threshold:n,distance:o,includeMatches:r,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:l});}static get type(){return "fuzzy"}static get multiRegex(){return /^"(.*)"$/}static get singleRegex(){return /^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}},qe=class extends ue{constructor(e){super(e);}static get type(){return "include"}static get multiRegex(){return /^'"(.*)"$/}static get singleRegex(){return /^'(.*)$/}search(e){let t=0,n,o=[],r=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+r,o.push([n,t-1]);let s=!!o.length;return {isMatch:s,score:s?0:1,indices:o}}},Ht=[Tt,qe,Mt,Lt,At,St,Ct,Oe],to=Ht.length,gi=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,fi="|";function vi(i,e={}){return i.split(fi).map(t=>{let n=t.trim().split(gi).filter(r=>r&&!!r.trim()),o=[];for(let r=0,s=n.length;r<s;r+=1){let a=n[r],c=false,d=-1;for(;!c&&++d<to;){let l=Ht[d],p=l.isMultiMatch(a);p&&(o.push(new l(p,e)),c=true);}if(!c)for(d=-1;++d<to;){let l=Ht[d],p=l.isSingleMatch(a);if(p){o.push(new l(p,e));break}}}return o})}var bi=new Set([Oe.type,qe.type]),Pt=class{constructor(e,{isCaseSensitive:t=M.isCaseSensitive,ignoreDiacritics:n=M.ignoreDiacritics,includeMatches:o=M.includeMatches,minMatchCharLength:r=M.minMatchCharLength,ignoreLocation:s=M.ignoreLocation,findAllMatches:a=M.findAllMatches,location:c=M.location,threshold:d=M.threshold,distance:l=M.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:r,findAllMatches:a,ignoreLocation:s,location:c,threshold:d,distance:l},e=t?e:e.toLowerCase(),e=n?Ue(e):e,this.pattern=e,this.query=vi(this.pattern,this.options);}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return {isMatch:false,score:1};let{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:r}=this.options;e=o?e:e.toLowerCase(),e=r?Ue(e):e;let s=0,a=[],c=0;for(let d=0,l=t.length;d<l;d+=1){let p=t[d];a.length=0,s=0;for(let h=0,m=p.length;h<m;h+=1){let v=p[h],{isMatch:f,indices:y,score:A}=v.search(e);if(f){if(s+=1,c+=A,n){let L=v.constructor.type;bi.has(L)?a=[...a,...y]:a.push(y);}}else {c=0,s=0,a.length=0;break}}if(s){let h={isMatch:true,score:c/s};return n&&(h.indices=a),h}}return {isMatch:false,score:1}}},Rt=[];function yi(...i){Rt.push(...i);}function Dt(i,e){for(let t=0,n=Rt.length;t<n;t+=1){let o=Rt[t];if(o.condition(i,e))return new o(i,e)}return new Fe(i,e)}var _e={AND:"$and",OR:"$or"},Bt={PATH:"$path",PATTERN:"$val"},It=i=>!!(i[_e.AND]||i[_e.OR]),wi=i=>!!i[Bt.PATH],xi=i=>!me(i)&&io(i)&&!It(i),oo=i=>({[_e.AND]:Object.keys(i).map(e=>({[e]:i[e]}))});function lo(i,e,{auto:t=true}={}){let n=o=>{let r=Object.keys(o),s=wi(o);if(!s&&r.length>1&&!It(o))return n(oo(o));if(xi(o)){let c=s?o[Bt.PATH]:r[0],d=s?o[Bt.PATTERN]:o[c];if(!ce(d))throw new Error(ei(c));let l={keyId:Et(c),pattern:d};return t&&(l.searcher=Dt(d,e)),l}let a={children:[],operator:r[0]};return r.forEach(c=>{let d=o[c];me(d)&&d.forEach(l=>{a.children.push(n(l));});}),a};return It(i)||(i=oo(i)),n(i)}function ki(i,{ignoreFieldNorm:e=M.ignoreFieldNorm}){i.forEach(t=>{let n=1;t.matches.forEach(({key:o,norm:r,score:s})=>{let a=o?o.weight:null;n*=Math.pow(s===0&&a?Number.EPSILON:s,(a||1)*(e?1:r));}),t.score=n;});}function Ei(i,e){let t=i.matches;e.matches=[],ie(t)&&t.forEach(n=>{if(!ie(n.indices)||!n.indices.length)return;let{indices:o,value:r}=n,s={indices:o,value:r};n.key&&(s.key=n.key.src),n.idx>-1&&(s.refIndex=n.idx),e.matches.push(s);});}function Ti(i,e){e.score=i.score;}function Ci(i,e,{includeMatches:t=M.includeMatches,includeScore:n=M.includeScore}={}){let o=[];return t&&o.push(Ei),n&&o.push(Ti),i.map(r=>{let{idx:s}=r,a={item:e[s],refIndex:s};return o.length&&o.forEach(c=>{c(r,a);}),a})}var ge=class{constructor(e,t={},n){this.options=S(S({},M),t),this.options.useExtendedSearch,this._keyStore=new kt(this.options.keys),this.setCollection(e,n);}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Ae))throw new Error(Qn);this._myIndex=t||ao(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight});}add(e){ie(e)&&(this._docs.push(e),this._myIndex.add(e));}remove(e=()=>false){let t=[];for(let n=0,o=this._docs.length;n<o;n+=1){let r=this._docs[n];e(r,n)&&(this.removeAt(n),n-=1,o-=1,t.push(r));}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e);}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){let{includeMatches:n,includeScore:o,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options,c=ce(e)?ce(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return ki(c,{ignoreFieldNorm:a}),r&&c.sort(s),no(t)&&t>-1&&(c=c.slice(0,t)),Ci(c,this._docs,{includeMatches:n,includeScore:o})}_searchStringList(e){let t=Dt(e,this.options),{records:n}=this._myIndex,o=[];return n.forEach(({v:r,i:s,n:a})=>{if(!ie(r))return;let{isMatch:c,score:d,indices:l}=t.searchIn(r);c&&o.push({item:r,idx:s,matches:[{score:d,value:r,norm:a,indices:l}]});}),o}_searchLogical(e){let t=lo(e,this.options),n=(a,c,d)=>{if(!a.children){let{keyId:p,searcher:h}=a,m=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(c,p),searcher:h});return m&&m.length?[{idx:d,item:c,matches:m}]:[]}let l=[];for(let p=0,h=a.children.length;p<h;p+=1){let m=a.children[p],v=n(m,c,d);if(v.length)l.push(...v);else if(a.operator===_e.AND)return []}return l},o=this._myIndex.records,r={},s=[];return o.forEach(({$:a,i:c})=>{if(ie(a)){let d=n(t,a,c);d.length&&(r[c]||(r[c]={idx:c,item:a,matches:[]},s.push(r[c])),d.forEach(({matches:l})=>{r[c].matches.push(...l);}));}}),s}_searchObjectList(e){let t=Dt(e,this.options),{keys:n,records:o}=this._myIndex,r=[];return o.forEach(({$:s,i:a})=>{if(!ie(s))return;let c=[];n.forEach((d,l)=>{c.push(...this._findMatches({key:d,value:s[l],searcher:t}));}),c.length&&r.push({idx:a,item:s,matches:c});}),r}_findMatches({key:e,value:t,searcher:n}){if(!ie(t))return [];let o=[];if(me(t))t.forEach(({v:r,i:s,n:a})=>{if(!ie(r))return;let{isMatch:c,score:d,indices:l}=n.searchIn(r);c&&o.push({score:d,key:e,value:r,idx:s,norm:a,indices:l});});else {let{v:r,n:s}=t,{isMatch:a,score:c,indices:d}=n.searchIn(r);a&&o.push({score:c,key:e,value:r,norm:s,indices:d});}return o}};ge.version="7.1.0";ge.createIndex=ao;ge.parseIndex=ui;ge.config=M;ge.parseQuery=lo;yi(Pt);var Mi="https://api.unnoodle.com";function V(i){var e,t;return (t=(e=i.baseUrl)==null?void 0:e.replace(/\/$/,""))!=null?t:Mi}function W(i){return {"Content-Type":"application/json","X-Unnoodle-Api-Key":i.apiKey}}function de(i){var e;if(typeof i.getAuthToken!="function")return null;try{return (e=i.getAuthToken())!=null?e:null}catch(t){return null}}var D=class extends Error{constructor(e,t,n){super(e),this.name="ApiError",this.status=t,this.body=n;}};async function Ge(i,e){let t=`${V(i)}/api/init`,n=W(i),o=e!==void 0?e:de(i);o&&(n.Authorization=`Bearer ${o}`);let r=await fetch(t,{method:"POST",headers:n,body:JSON.stringify({context:i.context})});if(!r.ok){let s=await r.text().catch(()=>"");throw new D(`Unnoodle /api/init error: ${r.status} ${r.statusText}`,r.status,s)}return r.json()}async function Ve(i,e,t,n){let o=`${V(i)}/api/contexts/${e}/glossary/search?q=${encodeURIComponent(t)}`,r=W(i),s=n!==void 0?n:de(i);s&&(r.Authorization=`Bearer ${s}`);let a=await fetch(o,{headers:r});if(!a.ok){let c=await a.text().catch(()=>"");throw new D(`Unnoodle search error: ${a.status} ${a.statusText}`,a.status,c)}return a.json()}async function We(i,e){let t=`${V(i)}/api/auth/login`,n=await fetch(t,{method:"POST",headers:W(i),body:JSON.stringify(e)});if(!n.ok){let o=await n.text().catch(()=>"");throw new D(`Unnoodle login error: ${n.status} ${n.statusText}`,n.status,o)}return n.json()}async function je(i){let e=`${V(i)}/api/auth/oauth/providers`;try{let t=await fetch(e,{headers:W(i)});return t.ok?t.json():{googleEnabled:!1,microsoftEnabled:!1}}catch(t){return {googleEnabled:false,microsoftEnabled:false}}}async function He(i,e,t){let n=`${V(i)}/api/glossary/${e}/discussions`,o=W(i),r=t!==void 0?t:de(i);r&&(o.Authorization=`Bearer ${r}`);let s=await fetch(n,{headers:o});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle discussions error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Ze(i,e,t,n){let o=`${V(i)}/api/glossary/${e}/discussions`,r=J(S({},W(i)),{Authorization:`Bearer ${n}`}),s=await fetch(o,{method:"POST",headers:r,body:JSON.stringify({body:t})});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle post comment error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Ke(i,e,t,n){let o=`${V(i)}/api/glossary/${e}`,r=J(S({},W(i)),{Authorization:`Bearer ${n}`}),s=await fetch(o,{method:"PUT",headers:r,body:JSON.stringify(t)});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle update term error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Ye(i,e,t,n,o){let r=`${V(i)}/api/sdk/glossary/ai-generate`,s=J(S({},W(i)),{Authorization:`Bearer ${o}`}),a;try{a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({term:e,context:t,pageUrl:n})});}catch(d){throw new D(d instanceof Error?d.message:"Network error",0,"")}if(!a.ok){let d=await a.text().catch(()=>"");throw new D(`Unnoodle ai-generate error: ${a.status} ${a.statusText}`,a.status,d)}return (await a.json()).definition}async function Xe(i,e,t,n,o){let r=`${V(i)}/api/contexts/${e}/glossary`,s=J(S({},W(i)),{Authorization:`Bearer ${o}`}),a;try{a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({term:t,definition:n,status:"PENDING",aiGenerated:!0})});}catch(c){throw new D(c instanceof Error?c.message:"Network error",0,"")}if(!a.ok){let c=await a.text().catch(()=>"");throw new D(`Unnoodle create suggested term error: ${a.status} ${a.statusText}`,a.status,c)}return a.json()}async function Je(i,e,t,n,o){let r=`${V(i)}/api/contexts/${e}/glossary`,s=J(S({},W(i)),{Authorization:`Bearer ${o}`}),a;try{a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({term:t,definition:n})});}catch(c){throw new D(c instanceof Error?c.message:"Network error",0,"")}if(!a.ok){let c=await a.text().catch(()=>"");throw new D(`Unnoodle create glossary term error: ${a.status} ${a.statusText}`,a.status,c)}return a.json()}async function Qe(i,e,t){let n=`${V(i)}/api/product-memories`,o=J(S({},W(i)),{Authorization:`Bearer ${t}`}),r;try{r=await fetch(n,{method:"POST",headers:o,body:JSON.stringify(e)});}catch(s){throw new D(s instanceof Error?s.message:"Network error",0,"")}if(!r.ok){let s=await r.text().catch(()=>"");throw new D(`Unnoodle create-product-memory error: ${r.status} ${r.statusText}`,r.status,s)}return r.json()}async function et(i,e,t,n){let o=`${V(i)}/api/product-memories/${e}/entries`,r=J(S({},W(i)),{Authorization:`Bearer ${n}`}),s=await fetch(o,{method:"POST",headers:r,body:JSON.stringify(t)});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle add-entry error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function tt(i,e,t,n,o){let r=`${V(i)}/api/product-memories/${e}/entries/${t}`,s=J(S({},W(i)),{Authorization:`Bearer ${o}`}),a=await fetch(r,{method:"PATCH",headers:s,body:JSON.stringify(n)});if(!a.ok){let c=await a.text().catch(()=>"");throw new D(`Unnoodle update-entry error: ${a.status} ${a.statusText}`,a.status,c)}return a.json()}async function Ee(i,e,t){let n=`${V(i)}/api/product-memories?page=${e}&size=20`,o=S({},W(i)),r=t!==void 0?t:de(i);r&&(o.Authorization=`Bearer ${r}`);let s=await fetch(n,{headers:o});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle list-memories error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function ot(i,e,t){let n=`${V(i)}/api/product-memories/${e}`,o=S({},W(i));t&&(o.Authorization=`Bearer ${t}`);let r=await fetch(n,{headers:o});if(!r.ok){let s=await r.text().catch(()=>"");throw new D(`Unnoodle get-memory error: ${r.status} ${r.statusText}`,r.status,s)}return r.json()}async function nt(i,e,t){let n=`${V(i)}/api/product-memories/${e}`,o=J(S({},W(i)),{Authorization:`Bearer ${t}`}),r=await fetch(n,{method:"DELETE",headers:o});if(!r.ok){let s=await r.text().catch(()=>"");throw new D(`Unnoodle delete-memory error: ${r.status} ${r.statusText}`,r.status,s)}}async function it(i,e,t,n){let o=`${V(i)}/api/product-memories/${e}/entries/${t}`,r=J(S({},W(i)),{Authorization:`Bearer ${n}`}),s=await fetch(o,{method:"DELETE",headers:r});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle delete-entry error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Pe(i,e,t){let n=`${V(i)}/api/contexts/${e}/discussions`,o=W(i),r=t!==void 0?t:de(i);r&&(o.Authorization=`Bearer ${r}`);let s=await fetch(n,{headers:o});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle GET context discussions error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function rt(i,e,t,n){let o=`${V(i)}/api/contexts/${e}/discussions`,r=J(S({},W(i)),{Authorization:`Bearer ${n}`}),s=await fetch(o,{method:"POST",headers:r,body:JSON.stringify({body:t})});if(!s.ok){let a=await s.text().catch(()=>"");throw new D(`Unnoodle POST context discussion error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function st(i,e,t,n,o){let r=`${V(i)}/api/contexts/${e}/discussions/${t}/replies`,s=J(S({},W(i)),{Authorization:`Bearer ${o}`}),a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({body:n})});if(!a.ok){let c=await a.text().catch(()=>"");throw new D(`Unnoodle POST context reply error: ${a.status} ${a.statusText}`,a.status,c)}return a.json()}var Si={button:"button",a:"link",input:"textbox",select:"listbox",textarea:"textbox",img:"img",table:"table",nav:"navigation",main:"main",header:"banner",footer:"contentinfo",aside:"complementary",section:"region",form:"form",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",li:"listitem",ul:"list",ol:"list"};function Ai(i){var t;let e=i.getAttribute("role");return e||((t=Si[i.tagName.toLowerCase()])!=null?t:null)}function Hi(i,e){if(!(i instanceof HTMLElement)||!(e instanceof HTMLElement))return;let t=window.getComputedStyle(i);for(let n of Array.from(t))try{e.style.setProperty(n,t.getPropertyValue(n));}catch(o){}}function co(i,e){Hi(i,e);let t=i.children,n=e.children;for(let o=0;o<t.length;o++){let r=t[o],s=n[o];r&&s&&co(r,s);}}function Pi(i){i.querySelectorAll("img[src]").forEach(e=>{let t=e.getAttribute("src");if(t&&!t.startsWith("http")&&!t.startsWith("data:"))try{e.setAttribute("src",new URL(t,window.location.href).href);}catch(n){}}),i.querySelectorAll("source[srcset]").forEach(e=>{let t=e.getAttribute("srcset");if(t){let n=t.split(",").map(o=>{let[r,s]=o.trim().split(/\s+/);if(!r||r.startsWith("http")||r.startsWith("data:"))return o;try{let a=new URL(r,window.location.href).href;return s?`${a} ${s}`:a}catch(a){return o}}).join(", ");e.setAttribute("srcset",n);}});}function Ri(i){i.querySelectorAll("script").forEach(t=>t.remove());let e=[i,...Array.from(i.querySelectorAll("*"))];for(let t of e){let n=[];for(let o of Array.from(t.attributes))/^on/i.test(o.name)&&n.push(o.name);n.forEach(o=>t.removeAttribute(o));}}function uo(i){var n;let e=i.getBoundingClientRect(),t=i.cloneNode(true);return co(i,t),Pi(t),Ri(t),{html:t.outerHTML,naturalWidth:e.width,naturalHeight:e.height,tag:i.tagName.toLowerCase(),role:Ai(i),text:((n=i.textContent)!=null?n:"").trim().replace(/\s+/g," "),rect:e,id:i.id||void 0,dataTestId:i.getAttribute("data-testid")||void 0}}var po="unnoodle-pick-ring",Di=`
2
+ position: fixed;
3
+ pointer-events: none;
4
+ z-index: 2147483645;
5
+ border: 2px dashed #5C4EFA;
6
+ border-radius: 4px;
7
+ background: rgba(92, 78, 250, 0.06);
8
+ transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s;
9
+ box-shadow: 0 0 0 9999px rgba(0,0,0,0.08);
10
+ `,Bi=new Set(["unnoodle-btn-host","unnoodle-panel-host",po]),at=class{constructor(e){this.ring=null;this.currentTarget=null;this.boundMouseover=this.handleMouseover.bind(this);this.boundClick=this.handleClick.bind(this);this.boundKeydown=this.handleKeydown.bind(this);this.callbacks=e;}start(){this.createRing(),document.addEventListener("mouseover",this.boundMouseover,true),document.addEventListener("click",this.boundClick,true),document.addEventListener("keydown",this.boundKeydown,true);}stop(){this.teardown(),this.callbacks.onCancel();}createRing(){let e=document.createElement("div");e.id=po,e.setAttribute("data-testid","unnoodle-pick-ring"),e.style.cssText=Di,e.style.pointerEvents="none",e.style.display="none",document.body.appendChild(e),this.ring=e;}removeRing(){var e;(e=this.ring)==null||e.remove(),this.ring=null;}teardown(){document.removeEventListener("mouseover",this.boundMouseover,true),document.removeEventListener("click",this.boundClick,true),document.removeEventListener("keydown",this.boundKeydown,true),this.removeRing(),this.currentTarget=null,document.documentElement.style.removeProperty("cursor");}isExcluded(e){let t=e;for(;t;){if(Bi.has(t.id))return true;t=t.parentElement;}return false}handleMouseover(e){let t=e.target;if(!t||this.isExcluded(t)||(this.currentTarget=t,document.documentElement.style.cursor="crosshair",!this.ring))return;let n=t.getBoundingClientRect();this.ring.style.display="block",this.ring.style.top=`${n.top}px`,this.ring.style.left=`${n.left}px`,this.ring.style.width=`${n.width}px`,this.ring.style.height=`${n.height}px`;}handleClick(e){let t=e.target;!t||this.isExcluded(t)||(e.preventDefault(),e.stopPropagation(),this.teardown(),this.callbacks.onPick(t));}handleKeydown(e){e.key==="Escape"&&this.stop();}};var Ii="unnoodle-overlay-arrow",ho="#5C4EFA";var mo="unn-arrow-head";function go(i,e){let t=i.left>e.right,n=t?i.left:i.right,o=i.top+i.height/2,r=t?e.right:e.left,s=e.top+e.height/2,a=Math.abs(r-n)*.4,c=t?n-a:n+a,d=t?r+a:r-a;return `M ${n} ${o} C ${c} ${o}, ${d} ${s}, ${r} ${s}`}function $i(){let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.id=Ii,i.setAttribute("data-testid","unnoodle-overlay-arrow"),i.style.cssText=`
11
+ position: fixed;
12
+ top: 0;
13
+ left: 0;
14
+ width: 100vw;
15
+ height: 100vh;
16
+ pointer-events: none;
17
+ z-index: 2147483644;
18
+ overflow: visible;
19
+ `;let e=document.createElementNS("http://www.w3.org/2000/svg","defs"),t=document.createElementNS("http://www.w3.org/2000/svg","marker");t.setAttribute("id",mo),t.setAttribute("markerWidth","8"),t.setAttribute("markerHeight","8"),t.setAttribute("refX","6"),t.setAttribute("refY","3"),t.setAttribute("orient","auto"),t.setAttribute("markerUnits","strokeWidth");let n=document.createElementNS("http://www.w3.org/2000/svg","polygon");n.setAttribute("points","0 0, 6 3, 0 6"),n.setAttribute("fill",ho),t.appendChild(n),e.appendChild(t),i.appendChild(e);let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("data-testid","unnoodle-arrow-path"),o.setAttribute("fill","none"),o.setAttribute("stroke",ho),o.setAttribute("stroke-width",String(1.5)),o.setAttribute("stroke-dasharray","5 4"),o.setAttribute("stroke-linecap","round"),o.setAttribute("marker-end",`url(#${mo})`),i.appendChild(o),i}var lt=class{constructor(){this.svg=null;}draw(e,t){this.remove();let n=$i();n.querySelector("path").setAttribute("d",go(e,t)),document.body.appendChild(n),this.svg=n;}update(e,t){if(!this.svg)return;let n=this.svg.querySelector("path");n&&n.setAttribute("d",go(e,t));}remove(){var e;(e=this.svg)==null||e.remove(),this.svg=null;}};var dt=class{async execute(e,t,n,o,r,s=false){return {memory:await Qe(e,{title:n,explanation:o||n,snapshotHtml:r.html,url:window.location.href,pageTitle:document.title,capturedAt:new Date().toISOString(),targetingMetadata:{id:r.id,dataTestId:r.dataTestId,tag:r.tag,role:r.role,text:r.text},watchForChanges:s},t)}}},ct=class{constructor(e){this.memoryId=e;}async execute(e,t,n,o,r){return {memory:await et(e,this.memoryId,{explanation:o,snapshotHtml:r.html,url:window.location.href,pageTitle:document.title,capturedAt:new Date().toISOString(),targetingMetadata:{id:r.id,dataTestId:r.dataTestId,tag:r.tag,role:r.role,text:r.text}},t)}}};var $t=class{constructor(e,t,n,o,r,s,a,c,d={type:"new-memory"}){this.panel=e;this.picker=t;this.arrow=n;this.orchestrator=o;this.config=r;this.getToken=s;this.getGlossary=a;this.onSaveComplete=c;this.mode=d;this.state="idle";this.pickedElement=null;this.snapshot=null;this.scrollHandler=null;this.resizeHandler=null;this.homeData=null;}setHomeData(e){this.homeData=e;}start(){console.log("[unnoodle] CaptureModeController.start() called",{state:this.state,mode:this.mode}),this.state==="idle"&&(this.state="form-open",this.mode.type==="new-memory"?this.panel.showNewMemoryForm(()=>{console.log("[unnoodle] Pick element callback triggered"),this.onPickElementClicked();},()=>{console.log("[unnoodle] Cancel capture callback triggered"),this.onCancelCapture();},(e,t,n)=>{console.log("[unnoodle] Save callback triggered",{title:e,explanation:t,watchForChanges:n}),this.onSaveWithTitle(e,t,n);},()=>{console.log("[unnoodle] Cancel callback triggered"),this.cancel();}):this.panel.showAddEntryForm(this.mode.memoryTitle,()=>{console.log("[unnoodle] Pick element callback triggered (add entry mode)"),this.onPickElementClicked();},()=>{console.log("[unnoodle] Cancel capture callback triggered (add entry mode)"),this.onCancelCapture();},e=>{console.log("[unnoodle] Save callback triggered (add entry mode)",{explanation:e}),this.onSaveWithExplanation(e);},()=>{console.log("[unnoodle] Cancel callback triggered (add entry mode)"),this.cancel();}));}_onElementPicked(e){this.onElementPicked(e);}cancel(){var e;console.log("[unnoodle] cancel() called, current state:",this.state),this.cleanup(),console.log("[unnoodle] Restoring home view after cancel"),this.homeData?this.panel.restoreHomeView(this.homeData):this.panel.exitCaptureMode(),console.log("[unnoodle] Calling onSaveComplete to reload home memories"),(e=this.onSaveComplete)==null||e.call(this),console.log("[unnoodle] cancel() completed");}onPickElementClicked(){this.state==="form-open"&&(this.state="picking",this.panel.setFormPickingMode(true),this.picker.start());}onCancelCapture(){console.log("[unnoodle] onCancelCapture() called, current state:",this.state),this.state==="picking"&&(this.state="form-open",this.panel.setFormPickingMode(false),console.log("[unnoodle] Exited picking mode, returned to form"));}onElementPicked(e){if(console.log("[unnoodle] onElementPicked called",{state:this.state,element:e}),this.state!=="picking"){console.log("[unnoodle] onElementPicked - wrong state, expected 'picking', got",this.state);return}console.log("[unnoodle] onElementPicked - setting state to form-open"),this.state="form-open",this.pickedElement=e,this.panel.setFormPickingMode(false),console.log("[unnoodle] onElementPicked - creating snapshot"),this.snapshot=uo(e),console.log("[unnoodle] onElementPicked - snapshot created:",this.snapshot),console.log("[unnoodle] onElementPicked - updating form snapshot"),this.panel.updateFormSnapshot(this.snapshot),console.log("[unnoodle] onElementPicked - drawing arrow"),this.redrawArrow(),this.startTrackingArrow(),console.log("[unnoodle] onElementPicked completed, state:",this.state);}async onSaveWithTitle(e,t,n){await this.performSave(e,t,n);}async onSaveWithExplanation(e){await this.performSave("",e,false);}async performSave(e,t,n){var r;if(console.log("[unnoodle] performSave called",{title:e,explanation:t,state:this.state,snapshot:this.snapshot}),this.state!=="form-open"){console.log("[unnoodle] performSave - wrong state, returning");return}if(!this.snapshot){console.log("[unnoodle] performSave - no snapshot, user didn't pick element, returning");return}this.state="saving",console.log("[unnoodle] performSave - state set to saving, getting token");let o=this.getToken();if(console.log("[unnoodle] performSave - token obtained:",!!o),!o){console.log("[unnoodle] performSave - no token, returning to form-open state"),this.state="form-open";return}try{console.log("[unnoodle] performSave - executing orchestrator"),await this.orchestrator.execute(this.config,o,e,t,this.snapshot,n),console.log("[unnoodle] performSave - orchestrator success, cleaning up"),this.cleanup(),console.log("[unnoodle] Restoring home view after save"),this.homeData?this.panel.restoreHomeView(this.homeData):this.panel.exitCaptureMode(),console.log("[unnoodle] Showing toast"),this.panel.showToast("Captured \u2713"),console.log("[unnoodle] Calling onSaveComplete callback"),(r=this.onSaveComplete)==null||r.call(this),console.log("[unnoodle] performSave completed successfully");}catch(s){console.log("[unnoodle] performSave - orchestrator failed",s),this.state="form-open";}}updateArrow(){var t,n;if(!this.pickedElement)return;let e=(n=(t=this.panel.element.shadowRoot)==null?void 0:t.querySelector(".panel-shell"))!=null?n:this.panel.element;this.arrow.update(e.getBoundingClientRect(),this.pickedElement.getBoundingClientRect());}startTrackingArrow(){this.stopTrackingArrow();let e=()=>this.updateArrow();this.scrollHandler=e,this.resizeHandler=e,window.addEventListener("scroll",this.scrollHandler,{capture:true,passive:true}),window.addEventListener("resize",this.resizeHandler,{passive:true});}stopTrackingArrow(){this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:true}),this.scrollHandler=null),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null);}redrawArrow(){var o,r;if(!this.pickedElement)return;let t=((r=(o=this.panel.element.shadowRoot)==null?void 0:o.querySelector(".panel-shell"))!=null?r:this.panel.element).getBoundingClientRect(),n=this.pickedElement.getBoundingClientRect();this.arrow.draw(t,n);}cleanup(){this.stopTrackingArrow(),this.arrow.remove(),this.pickedElement=null,this.snapshot=null,this.state="idle";}};function zt(i,e,t,n,o,r,s={type:"new-memory"}){let a=r!=null?r:new dt,c=new $t(i,new at({onPick:d=>c._onElementPicked(d),onCancel:()=>c.onCancelCapture()}),new lt,a,e,t,n,o,s);return c}function re(i){return i.replace(/\\n/g,`
20
+ `).replace(/\\t/g," ")}function fo(i,e){let t=document.createElement("div");t.id="unnoodle-btn-host",t.style.cssText="position:fixed;right:14px;top:50%;transform:translateY(-50%);z-index:2147483647;";let n=t.attachShadow({mode:"open"}),o=document.createElement("style");if(o.textContent=re(`
21
+ :host { all: initial; }
22
+
23
+ /* Wrapper \u2014 gives ::after tooltip a positioning context */
24
+ .btn-wrap {
25
+ position: relative;
26
+ display: inline-flex;
27
+ align-items: center;
28
+ }
29
+
30
+ /* Rounded-square trigger button */
31
+ .trigger {
32
+ width: 38px; height: 38px;
33
+ border-radius: 4px;
34
+ border: none; padding: 0; cursor: pointer;
35
+ position: relative;
36
+ display: flex; align-items: center; justify-content: center; gap: 0;
37
+ background: linear-gradient(160deg, #2c3440 0%, #1a1f27 100%);
38
+ /* Layered box-shadow \u2014 creates a "gradient shadow" depth effect */
39
+ box-shadow:
40
+ 0 1px 2px rgba(0,0,0,0.30),
41
+ 0 3px 8px rgba(0,0,0,0.38),
42
+ 0 8px 20px rgba(0,0,0,0.22),
43
+ 0 1px 0 rgba(255,255,255,0.06) inset;
44
+ color: rgba(255,255,255,0.85);
45
+ font-family: var(--unn-font-family, system-ui, sans-serif);
46
+ font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
47
+ /* Text shadow for glyph depth */
48
+ text-shadow: 0 1px 3px rgba(0,0,0,0.65), 0 -1px 0 rgba(255,255,255,0.10);
49
+ -webkit-user-select: none; user-select: none;
50
+ transition:
51
+ transform 0.18s cubic-bezier(0.34,1.35,0.64,1),
52
+ box-shadow 0.18s ease,
53
+ filter 0.18s ease;
54
+ }
55
+
56
+ /*
57
+ * Spinning progress ring \u2014 only visible when .trigger has .loading class.
58
+ * Toggle via setProgress(true/false) from the returned API.
59
+ * Uses the mask XOR trick: outer box minus content-box = thin padding ring.
60
+ * The conic-gradient rotates to give a sweeping arc effect.
61
+ */
62
+ .trigger.loading::after {
63
+ content: '';
64
+ position: absolute;
65
+ /* 1px gap + 1px border = 2px outside button edge */
66
+ inset: -2px;
67
+ border-radius: 6px; /* 4px + 2px */
68
+ padding: 1px; /* controls ring thickness */
69
+ background: conic-gradient(
70
+ from 0deg,
71
+ transparent 0deg,
72
+ rgba(0,0,0,0.75) 80deg,
73
+ transparent 160deg
74
+ );
75
+ /* Hollow ring mask: reveal only the 1px padding strip */
76
+ -webkit-mask:
77
+ linear-gradient(#fff 0 0) content-box,
78
+ linear-gradient(#fff 0 0);
79
+ mask:
80
+ linear-gradient(#fff 0 0) content-box,
81
+ linear-gradient(#fff 0 0);
82
+ -webkit-mask-composite: destination-out;
83
+ mask-composite: exclude;
84
+ pointer-events: none;
85
+ animation: unn-ring-spin 2.4s linear infinite;
86
+ }
87
+
88
+ @keyframes unn-ring-spin {
89
+ to { transform: rotate(360deg); }
90
+ }
91
+
92
+ .trigger.dragging { transition: none; }
93
+
94
+ .trigger:not(.dragging):hover {
95
+ transform: scale(1.08);
96
+ box-shadow:
97
+ 0 2px 4px rgba(0,0,0,0.35),
98
+ 0 6px 16px rgba(0,0,0,0.48),
99
+ 0 14px 32px rgba(0,0,0,0.22),
100
+ 0 1px 0 rgba(255,255,255,0.10) inset;
101
+ filter: brightness(1.18);
102
+ }
103
+ .trigger:not(.dragging):active { transform: scale(0.94); }
104
+ .trigger:focus-visible { outline: 2px solid rgba(255,255,255,0.55); outline-offset: 2px; }
105
+
106
+ /* Tooltip */
107
+ .tip {
108
+ position: absolute;
109
+ right: calc(100% + 10px);
110
+ top: 50%; transform: translateY(-50%);
111
+ background: rgba(18,18,26,0.90);
112
+ color: #fff;
113
+ font-family: var(--unn-font-family, system-ui, sans-serif);
114
+ font-size: 9px; font-weight: 500;
115
+ white-space: nowrap;
116
+ padding: 3px 7px; border-radius: 4px;
117
+ opacity: 0; pointer-events: none;
118
+ transition: opacity 0.15s ease;
119
+ backdrop-filter: blur(4px);
120
+ }
121
+ .trigger:not(.dragging):hover ~ .tip,
122
+ .trigger:not(.dragging):focus-visible ~ .tip { opacity: 1; }
123
+ `),e){let C=document.createElement("style");C.textContent=re(e),n.appendChild(C);}n.appendChild(o);let r=document.createElement("div");r.className="btn-wrap";let s=document.createElement("button");s.className="trigger",s.setAttribute("aria-label","Open Unnoodle"),s.setAttribute("data-testid","widget-trigger-button"),s.textContent="U\u2229",s.addEventListener("keydown",C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),i());});let a=document.createElement("span");a.className="tip";let c=/mac/i.test(navigator.platform||navigator.userAgent);a.textContent=c?"\u2318U":"Ctrl+U",r.appendChild(s),r.appendChild(a),n.appendChild(r);let d=false,l=false,p=0,h=0,m=0,v=0;function f(){let C=parseFloat(t.style.right)||14,$=t.style.top,Y=$.endsWith("%")?parseFloat($)/100*window.innerHeight-68:parseFloat($)||window.innerHeight/2-68;return {right:C,topPx:Y}}function y(C){if(C.button!==0)return;d=true,l=false,s.classList.add("dragging"),p=C.clientX,h=C.clientY;let $=f();m=$.right,v=$.topPx,C.preventDefault();}function A(C){if(!d)return;let $=C.clientX-p,Y=C.clientY-h;(Math.abs($)>3||Math.abs(Y)>3)&&(l=true);let H=ut(m-$,8,window.innerWidth-46),P=ut(v+Y,8,window.innerHeight-160);t.style.right=`${H}px`,t.style.top=`${P}px`,t.style.transform="none";}function L(C){d&&(d=false,s.classList.remove("dragging"),l||i(),C.preventDefault());}function N(C){let $=C.touches[0];if(!$)return;d=true,l=false,s.classList.add("dragging"),p=$.clientX,h=$.clientY;let Y=f();m=Y.right,v=Y.topPx;}function U(C){if(!d)return;let $=C.touches[0];if(!$)return;let Y=$.clientX-p,H=$.clientY-h;(Math.abs(Y)>3||Math.abs(H)>3)&&(l=true);let P=ut(m-Y,8,window.innerWidth-46),O=ut(v+H,8,window.innerHeight-160);t.style.right=`${P}px`,t.style.top=`${O}px`,t.style.transform="none",C.preventDefault();}function F(){d&&(d=false,s.classList.remove("dragging"),l||i());}return s.addEventListener("mousedown",y),document.addEventListener("mousemove",A),document.addEventListener("mouseup",L),s.addEventListener("touchstart",N,{passive:true}),document.addEventListener("touchmove",U,{passive:false}),document.addEventListener("touchend",F),{element:t,cleanup:()=>{s.removeEventListener("mousedown",y),s.removeEventListener("touchstart",N),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",L),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",F),t.remove();},setProgress:C=>{s.classList.toggle("loading",C),s.setAttribute("aria-busy",String(C));}}}function ut(i,e,t){return Math.min(Math.max(i,e),t)}var vo=`
124
+ :host {
125
+ all: initial;
126
+ /* \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
127
+ Widget scale tokens \u2014 change values here to affect everywhere
128
+ \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 */
129
+
130
+ /* Font sizes */
131
+ --w-font-xxs: 10px; /* product-memory heading */
132
+ --w-font-xs: 10px; /* footer, panel subtitle, upper labels */
133
+ --w-font-sm: 11px; /* form labels, tab-btn, section headings */
134
+ --w-font-base: 12px; /* body text, search, buttons, term defs */
135
+ --w-font-md: 13px; /* term names, inputs, form-submit */
136
+ --w-font-display: 13px; /* AI modal term emphasis */
137
+ --w-font-lg: 13px; /* panel title */
138
+ --w-font-xl: 15px; /* login heading */
139
+
140
+ /* Font weights */
141
+ --w-weight-normal: 400;
142
+ --w-weight-medium: 400; /* labels, tab-btn */
143
+ --w-weight-semi: 500; /* headings, buttons */
144
+ --w-weight-bold: 600; /* term detail name */
145
+
146
+ /* Spacing \u2014 vertical */
147
+ --w-space-v-xs: 4px; /* small inner gaps */
148
+ --w-space-v-sm: 8px; /* post padding, pm textarea */
149
+ --w-space-v-md: 10px; /* section padding-top/bottom, term items */
150
+ --w-space-v-lg: 12px; /* header, discussions, meta padding-v */
151
+ --w-space-v-xl: 20px; /* login form padding-top/bottom */
152
+
153
+ /* Spacing \u2014 horizontal */
154
+ --w-space-h-sm: 12px; /* login form inner padding */
155
+ --w-space-h-md: 16px; /* global horizontal gutter */
156
+ --w-space-h-lg: 18px; /* login outer horizontal padding */
157
+
158
+ /* Spacing \u2014 numeric scale (used by home view, skeleton loaders) */
159
+ --w-space-1: 4px;
160
+ --w-space-2: 8px;
161
+ --w-space-3: 12px;
162
+ --w-space-4: 16px;
163
+
164
+ /* Border */
165
+ --w-border-width: 1px; /* all interactive element borders */
166
+
167
+ /* Border radii */
168
+ --w-radius-xs: 3px; /* tiny elements, pm editor btn */
169
+ --w-radius-1: 4px; /* home view rows, search bar */
170
+ --w-radius-sm: 4px; /* tabs, capture-btn, suggestions, pm btns */
171
+ --w-radius-md: 5px; /* action-btn */
172
+ --w-radius-lg: 6px; /* inputs, SSO btns, form submits, toast, modal */
173
+ --w-radius-pill: 10px; /* term pills */
174
+
175
+ /* Panel dimensions */
176
+ --w-panel-width: 400px;
177
+
178
+ /* Spinner */
179
+ --w-spinner-size: 34px;
180
+ --w-spinner-border: 3px;
181
+ }
182
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
183
+
184
+ .panel-shell {
185
+ position: fixed; top: 0; right: 0; bottom: 0;
186
+ width: var(--w-panel-width); max-width: 100vw;
187
+ z-index: 2147483647;
188
+ transform: translateX(100%);
189
+ transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), width 0.28s cubic-bezier(0.4,0,0.2,1);
190
+
191
+ border-left: 0.5px solid var(--unn-color-border-default);
192
+ box-shadow: inset 6px 0 12px rgba(0,0,0,0.06), inset -4px 0 10px rgba(0,0,0,0.04), inset 0 6px 12px rgba(0,0,0,0.06), inset 0 -4px 10px rgba(0,0,0,0.04);
193
+ padding: 3px;
194
+ display: flex; flex-direction: column;
195
+ background: var(--unn-color-bg-secondary, #f5f5f7);
196
+ }
197
+ .panel-shell.open { transform: translateX(0); }
198
+ .panel {
199
+ flex: 1; min-height: 0;
200
+ display: flex; flex-direction: column;
201
+ font-family: var(--unn-font-family);
202
+ background: var(--unn-color-bg-primary);
203
+ border-radius: 6px;
204
+ overflow: hidden;
205
+ }
206
+
207
+ /* Header */
208
+ .panel-header {
209
+ display: flex; align-items: center; justify-content: space-between;
210
+ padding: 5px 6px 5px 12px;
211
+ background: linear-gradient(160deg, #2c3440 0%, #1a1f27 100%);
212
+ color: var(--unn-color-text-inverse);
213
+ border-radius: 6px 6px 0 0; flex-shrink: 0;
214
+ }
215
+ .panel-header-brand { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
216
+ .panel-title { font-size: var(--w-font-base); font-weight: var(--w-weight-bold); letter-spacing: 0.01em; white-space: nowrap; }
217
+ .panel-title-sep { font-size: var(--w-font-xs); opacity: 0.35; line-height: 1; }
218
+ .panel-subtitle { font-size: var(--w-font-xs); opacity: 0.60; white-space: nowrap; }
219
+ .panel-header-actions { display: flex; align-items: center; gap: 1px; flex-shrink: 0; }
220
+ .panel-header-separator { width: 1px; height: 11px; background: rgba(255,255,255,0.25); margin: 0 3px; flex-shrink: 0; }
221
+ .panel-close, .panel-popout, .panel-dock, .panel-pin-left, .panel-pin-right,
222
+ .panel-half, .panel-half-exit,
223
+ .panel-fullscreen, .panel-fullscreen-exit {
224
+ background: none; border: none; cursor: pointer; color: var(--unn-color-text-inverse);
225
+ width: 24px; height: 24px;
226
+ display: flex; align-items: center; justify-content: center;
227
+ border-radius: var(--w-radius-xs); opacity: 0.75; transition: opacity 0.15s, background 0.15s;
228
+ }
229
+ .panel-close:hover, .panel-popout:hover, .panel-dock:hover,
230
+ .panel-pin-left:hover, .panel-pin-right:hover,
231
+ .panel-half:hover, .panel-half-exit:hover,
232
+ .panel-fullscreen:hover, .panel-fullscreen-exit:hover { opacity: 1; background: rgba(255,255,255,0.18); }
233
+ .panel-close svg, .panel-popout svg, .panel-dock svg,
234
+ .panel-half svg, .panel-half-exit svg,
235
+ .panel-fullscreen svg, .panel-fullscreen-exit svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
236
+ .panel-pin-left svg, .panel-pin-right svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 16; }
237
+ .panel-pin-right svg { transform: scaleX(-1); }
238
+ .panel-popout[hidden], .panel-dock[hidden] { display: none !important; }
239
+ .panel-half[hidden], .panel-half-exit[hidden] { display: none !important; }
240
+ .panel-pin-left.active, .panel-pin-right.active { background: rgba(255,255,255,0.25) !important; opacity: 1 !important; }
241
+
242
+ /* Left-side docking */
243
+ .panel-shell.left-side {
244
+ right: auto; left: 0;
245
+ transform: translateX(-100%);
246
+ border-left: none;
247
+ border-right: 0.5px solid var(--unn-color-border-default);
248
+ }
249
+ .panel-shell.left-side.open { transform: translateX(0); }
250
+
251
+ /* Half-screen (50vw) */
252
+ .panel-shell.half-screen {
253
+ width: 50vw !important; max-width: 50vw !important;
254
+ }
255
+
256
+ /* Fullscreen */
257
+ .panel-shell.fullscreen {
258
+ left: 0 !important; right: 0 !important;
259
+ width: 100vw !important; max-width: 100vw !important;
260
+ transform: none !important;
261
+ border-radius: 0 !important;
262
+ border: none !important;
263
+ box-shadow: none !important;
264
+ padding: 0 !important;
265
+ background: transparent !important;
266
+ }
267
+ .panel-shell.fullscreen.open { transform: none !important; }
268
+ .panel-shell.fullscreen .panel { border-radius: 0 !important; }
269
+ .panel-fullscreen[hidden], .panel-fullscreen-exit[hidden] { display: none !important; }
270
+
271
+ /* Body */
272
+ .panel-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
273
+
274
+ /* Footer */
275
+ .panel-footer {
276
+ padding: 4px 14px; border-top: 1px solid var(--unn-color-border-default);
277
+ display: flex; align-items: center; justify-content: center; flex-shrink: 0;
278
+ }
279
+ .panel-footer a { font-size: var(--w-font-xs); color: var(--unn-color-text-subtle); text-decoration: none; opacity: 0.8; }
280
+ .panel-footer a:hover { color: var(--unn-color-text-muted); opacity: 1; }
281
+
282
+ /* ---- Utility states ---- */
283
+ .state-center {
284
+ flex: 1; display: flex; flex-direction: column;
285
+ align-items: center; justify-content: center;
286
+ gap: 14px; padding: 24px;
287
+ }
288
+ .spinner {
289
+ width: var(--w-spinner-size); height: var(--w-spinner-size);
290
+ border: var(--w-spinner-border) solid var(--unn-color-border-default); border-top-color: var(--unn-color-brand-primary);
291
+ border-radius: 50%;
292
+ animation: spin 0.7s linear infinite;
293
+ }
294
+ @keyframes spin { to { transform: rotate(360deg); } }
295
+ .state-msg { font-size: var(--w-font-base); color: var(--unn-color-text-muted); text-align: center; line-height: 1.5; }
296
+ .state-error-icon { stroke: var(--unn-color-status-error); fill: none; width: 40px; height: 40px; }
297
+
298
+ /* ---- Login view ---- */
299
+ .login-form {
300
+ padding: var(--w-space-v-xl) var(--w-space-h-lg);
301
+ display: flex; flex-direction: column; gap: 14px;
302
+ }
303
+ .login-heading {
304
+ font-size: var(--w-font-xl); font-weight: var(--w-weight-semi); color: var(--unn-color-text-primary); text-align: center;
305
+ }
306
+ .login-sub {
307
+ font-size: var(--w-font-sm); color: var(--unn-color-text-muted); text-align: center; margin-top: -8px;
308
+ }
309
+ .form-field { display: flex; flex-direction: column; gap: 5px; }
310
+ .form-label { font-size: var(--w-font-sm); font-weight: var(--w-weight-medium); color: var(--unn-color-text-body); }
311
+ .form-input {
312
+ width: 100%; padding: 9px 12px;
313
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); border-radius: var(--w-radius-lg);
314
+ font-size: var(--w-font-md); color: var(--unn-color-text-primary);
315
+ outline: none; transition: border-color 0.15s;
316
+ }
317
+ .form-input:focus { border-color: var(--unn-color-brand-primary); }
318
+ .form-submit {
319
+ width: 100%; padding: 10px 16px;
320
+ background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse);
321
+ border: none; border-radius: var(--w-radius-lg);
322
+ font-size: var(--w-font-md); font-weight: var(--w-weight-semi); cursor: pointer;
323
+ transition: opacity 0.15s, transform 0.1s;
324
+ }
325
+ .form-submit:hover { opacity: 0.9; }
326
+ .form-submit:active { transform: scale(0.98); }
327
+ .form-submit:disabled { opacity: 0.6; cursor: not-allowed; }
328
+ .login-error {
329
+ font-size: var(--w-font-sm); color: var(--unn-color-status-error);
330
+ background: var(--unn-color-error-tint); border: 1px solid var(--unn-color-error-tint-border);
331
+ border-radius: var(--w-radius-sm); padding: 8px 10px;
332
+ display: none;
333
+ }
334
+ .login-error.visible { display: block; }
335
+ .login-back-btn {
336
+ all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 3px;
337
+ font-size: var(--w-font-sm); color: var(--unn-color-text-muted);
338
+ margin-bottom: -4px;
339
+ }
340
+ .login-back-btn:hover { color: var(--unn-color-text-primary); }
341
+
342
+ /* ---- SSO buttons ---- */
343
+ .sso-divider {
344
+ display: flex; align-items: center; gap: 10px; margin: 4px 0;
345
+ }
346
+ .sso-divider-line {
347
+ flex: 1; height: 1px; background: var(--unn-color-border-default);
348
+ }
349
+ .sso-divider-text {
350
+ font-size: var(--w-font-xs); color: var(--unn-color-text-muted); white-space: nowrap;
351
+ }
352
+ .sso-buttons { display: flex; flex-direction: column; gap: 8px; }
353
+ .sso-btn {
354
+ display: flex; align-items: center; justify-content: center; gap: 10px;
355
+ width: 100%; padding: 9px 12px;
356
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); border-radius: var(--w-radius-lg);
357
+ background: var(--unn-color-bg-primary); color: var(--unn-color-text-primary);
358
+ font-size: var(--w-font-base); font-weight: var(--w-weight-medium); cursor: pointer;
359
+ transition: background 0.15s, border-color 0.15s;
360
+ }
361
+ .sso-btn:hover { background: var(--unn-color-bg-subtle); border-color: var(--unn-color-border-default); }
362
+ .sso-btn svg { flex-shrink: 0; }
363
+
364
+ /* ---- Search ---- */
365
+ .search-bar {
366
+ padding: var(--w-space-v-md) var(--w-space-h-md); border-bottom: 1px solid var(--unn-color-border-default);
367
+ flex-shrink: 0;
368
+ }
369
+ .search-input {
370
+ width: 100%; padding: 8px 12px;
371
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); border-radius: var(--w-radius-lg);
372
+ font-size: var(--w-font-base); color: var(--unn-color-text-primary);
373
+ outline: none; transition: border-color 0.15s;
374
+ }
375
+ .search-input:focus { border-color: var(--unn-color-brand-primary); }
376
+
377
+ /* ---- Terms list ---- */
378
+ .terms-list { flex: 1; overflow-y: auto; padding: 0; }
379
+ .context-label {
380
+ padding: 10px 18px 6px;
381
+ font-size: var(--w-font-xs); font-weight: var(--w-weight-semi); color: var(--unn-color-text-subtle);
382
+ text-transform: uppercase; letter-spacing: 0.05em;
383
+ }
384
+ .term-item {
385
+ padding: var(--w-space-v-md) var(--w-space-h-md);
386
+ border-bottom: 1px solid var(--unn-color-border-default);
387
+ cursor: default;
388
+ transition: background 0.1s;
389
+ }
390
+ .term-item:hover { background: var(--unn-color-bg-secondary); }
391
+ .term-name {
392
+ font-size: var(--w-font-md); font-weight: var(--w-weight-semi); color: var(--unn-color-text-primary);
393
+ display: flex; align-items: center; gap: 6px;
394
+ }
395
+ .term-abbr {
396
+ font-size: var(--w-font-xxs); font-weight: var(--w-weight-medium);
397
+ background: var(--unn-color-accent-tint-bg); color: var(--unn-color-accent-strong);
398
+ border-radius: var(--w-radius-xs); padding: 1px 5px;
399
+ }
400
+ .term-def {
401
+ font-size: var(--w-font-sm); color: var(--unn-color-text-muted); margin-top: 4px; line-height: 1.5;
402
+ }
403
+ .term-link {
404
+ font-size: var(--w-font-xs); color: var(--unn-color-brand-primary);
405
+ text-decoration: none; margin-top: 4px; display: inline-block;
406
+ }
407
+ .term-link:hover { text-decoration: underline; }
408
+ .no-results {
409
+ padding: 28px 18px; text-align: center;
410
+ font-size: var(--w-font-base); color: var(--unn-color-text-subtle);
411
+ }
412
+
413
+ /* ---- Term card (clickable row inside list item) ---- */
414
+ .term-card {
415
+ cursor: pointer;
416
+ }
417
+ .term-card:hover .term-name { color: var(--unn-color-brand-primary); }
418
+
419
+ /* ---- Term detail view ---- */
420
+ .term-detail-view {
421
+ display: flex; flex-direction: column; flex: 1; overflow-y: auto;
422
+ }
423
+ .detail-back {
424
+ display: flex; align-items: center;
425
+ padding: 10px 18px; border-bottom: 1px solid var(--unn-color-border-default); flex-shrink: 0;
426
+ }
427
+ .back-btn {
428
+ background: none; border: none; cursor: pointer;
429
+ font-size: var(--w-font-base); color: var(--unn-color-brand-primary); font-weight: var(--w-weight-medium);
430
+ display: flex; align-items: center; gap: 4px; padding: 4px 0;
431
+ }
432
+ .back-btn:hover { text-decoration: underline; }
433
+ .detail-content {
434
+ padding: 18px 18px 10px;
435
+ }
436
+ .detail-term-name {
437
+ font-size: var(--w-font-xl); font-weight: var(--w-weight-bold); color: var(--unn-color-text-primary);
438
+ }
439
+ .detail-term-def {
440
+ font-size: var(--w-font-base); color: var(--unn-color-text-muted); margin-top: 8px; line-height: 1.6;
441
+ }
442
+ .detail-actions {
443
+ display: flex; gap: 8px;
444
+ padding: 10px 18px; border-bottom: 1px solid var(--unn-color-border-default); flex-shrink: 0;
445
+ }
446
+ .action-btn {
447
+ padding: 7px 14px; border-radius: var(--w-radius-md); font-size: var(--w-font-base); font-weight: var(--w-weight-medium);
448
+ cursor: pointer; border: var(--w-border-width) solid var(--unn-color-brand-primary);
449
+ background: var(--unn-color-bg-primary); color: var(--unn-color-brand-primary);
450
+ transition: background 0.15s, color 0.15s;
451
+ }
452
+ .action-btn:hover { background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse); }
453
+ .discussions-section { padding: var(--w-space-v-lg) var(--w-space-h-md); flex: 1; }
454
+ .discussions-heading {
455
+ font-size: var(--w-font-xs); font-weight: var(--w-weight-semi); color: var(--unn-color-text-subtle);
456
+ text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px;
457
+ }
458
+ .discussion-post {
459
+ padding: var(--w-space-v-sm) var(--w-space-h-sm);
460
+ border-bottom: 1px solid var(--unn-color-border-default);
461
+ font-size: var(--w-font-base); color: var(--unn-color-text-body);
462
+ line-height: 1.5;
463
+ }
464
+ .discussion-post:last-child { border-bottom: none; }
465
+ .discussions-empty {
466
+ font-size: var(--w-font-base); color: var(--unn-color-text-subtle); text-align: center; padding: 16px 0;
467
+ }
468
+
469
+ /* ---- Comment form view ---- */
470
+ .comment-form-view {
471
+ display: flex; flex-direction: column; flex: 1; overflow-y: auto;
472
+ }
473
+ .comment-textarea {
474
+ margin: var(--w-space-v-lg) var(--w-space-h-md); padding: var(--w-space-v-sm) 12px;
475
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); border-radius: var(--w-radius-lg);
476
+ font-size: var(--w-font-base); color: var(--unn-color-text-primary); min-height: 100px; resize: vertical;
477
+ outline: none; transition: border-color 0.15s;
478
+ font-family: inherit;
479
+ }
480
+ .comment-textarea:focus { border-color: var(--unn-color-brand-primary); }
481
+ .comment-submit {
482
+ margin: 0 18px; padding: 10px 16px;
483
+ background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse);
484
+ border: none; border-radius: var(--w-radius-lg);
485
+ font-size: var(--w-font-md); font-weight: var(--w-weight-semi); cursor: pointer;
486
+ transition: opacity 0.15s;
487
+ }
488
+ .comment-submit:hover { opacity: 0.9; }
489
+ .comment-submit:disabled { opacity: 0.6; cursor: not-allowed; }
490
+
491
+ /* ---- Edit form view ---- */
492
+ .edit-form-view {
493
+ display: flex; flex-direction: column; flex: 1; overflow-y: auto;
494
+ padding: var(--w-space-v-lg) var(--w-space-h-md); gap: 12px;
495
+ }
496
+ .edit-label {
497
+ font-size: var(--w-font-sm); font-weight: var(--w-weight-medium); color: var(--unn-color-text-body);
498
+ margin-bottom: 4px; display: block;
499
+ }
500
+ .edit-input {
501
+ width: 100%; padding: 9px 12px;
502
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); border-radius: var(--w-radius-lg);
503
+ font-size: var(--w-font-md); color: var(--unn-color-text-primary);
504
+ outline: none; transition: border-color 0.15s;
505
+ }
506
+ .edit-input:focus { border-color: var(--unn-color-brand-primary); }
507
+ .edit-textarea {
508
+ width: 100%; padding: 9px 12px;
509
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); border-radius: var(--w-radius-lg);
510
+ font-size: var(--w-font-base); color: var(--unn-color-text-primary); min-height: 80px; resize: vertical;
511
+ outline: none; transition: border-color 0.15s;
512
+ font-family: inherit;
513
+ }
514
+ .edit-textarea:focus { border-color: var(--unn-color-brand-primary); }
515
+ .edit-submit {
516
+ padding: 10px 16px;
517
+ background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse);
518
+ border: none; border-radius: var(--w-radius-lg);
519
+ font-size: var(--w-font-md); font-weight: var(--w-weight-semi); cursor: pointer;
520
+ transition: opacity 0.15s;
521
+ }
522
+ .edit-submit:hover { opacity: 0.9; }
523
+
524
+ /* ---- Suggested terms section ---- */
525
+ .suggestions-section { padding: var(--w-space-v-md) var(--w-space-h-md) 16px; }
526
+ .suggestions-heading {
527
+ font-size: var(--w-font-xs); font-weight: var(--w-weight-semi); color: var(--unn-color-text-subtle);
528
+ text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
529
+ }
530
+ .suggestion-item {
531
+ display: flex; align-items: center; justify-content: space-between;
532
+ padding: 8px 0; border-bottom: 1px solid var(--unn-color-border-default);
533
+ }
534
+ .suggestion-item:last-child { border-bottom: none; }
535
+ .suggestion-info { display: flex; flex-direction: column; gap: 2px; }
536
+ .suggestion-term { font-size: var(--w-font-base); font-weight: var(--w-weight-semi); color: var(--unn-color-text-primary); }
537
+ .suggestion-count { font-size: var(--w-font-xs); color: var(--unn-color-text-subtle); }
538
+ .suggestion-add {
539
+ padding: 4px 10px; border-radius: var(--w-radius-sm); font-size: var(--w-font-sm); font-weight: var(--w-weight-medium);
540
+ cursor: pointer; border: var(--w-border-width) solid var(--unn-color-brand-primary);
541
+ background: var(--unn-color-bg-primary); color: var(--unn-color-brand-primary);
542
+ flex-shrink: 0;
543
+ transition: background 0.15s, color 0.15s;
544
+ }
545
+ .suggestion-add:hover { background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse); }
546
+
547
+ /* ---- AI definition modal ---- */
548
+ .ai-modal-overlay {
549
+ position: absolute; inset: 0;
550
+ background: rgba(255,255,255,0.96);
551
+ display: flex; flex-direction: column;
552
+ z-index: 10; padding: 24px 20px; gap: 14px;
553
+ overflow-y: auto;
554
+ }
555
+ .ai-modal-title {
556
+ font-size: var(--w-font-md); font-weight: var(--w-weight-semi); color: var(--unn-color-text-primary);
557
+ }
558
+ .ai-modal-term {
559
+ font-size: var(--w-font-display); font-weight: var(--w-weight-bold); color: var(--unn-color-brand-primary);
560
+ }
561
+ .ai-modal-label {
562
+ font-size: var(--w-font-sm); font-weight: var(--w-weight-medium); color: var(--unn-color-text-body); margin-bottom: 4px; display: block;
563
+ }
564
+ .ai-modal-textarea {
565
+ width: 100%; padding: 9px 12px;
566
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); border-radius: var(--w-radius-lg);
567
+ font-size: var(--w-font-base); color: var(--unn-color-text-primary); min-height: 120px; resize: vertical;
568
+ outline: none; transition: border-color 0.15s;
569
+ font-family: inherit;
570
+ }
571
+ .ai-modal-textarea:focus { border-color: var(--unn-color-brand-primary); }
572
+ .ai-modal-char-count { font-size: var(--w-font-xs); color: var(--unn-color-text-subtle); text-align: right; }
573
+ .ai-modal-actions { display: flex; gap: 8px; }
574
+ .ai-modal-submit {
575
+ flex: 1; padding: 10px 16px;
576
+ background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse);
577
+ border: none; border-radius: var(--w-radius-lg);
578
+ font-size: var(--w-font-md); font-weight: var(--w-weight-semi); cursor: pointer;
579
+ transition: opacity 0.15s;
580
+ }
581
+ .ai-modal-submit:hover { opacity: 0.9; }
582
+ .ai-modal-submit:disabled { opacity: 0.6; cursor: not-allowed; }
583
+ .ai-modal-cancel {
584
+ padding: 10px 16px; border-radius: var(--w-radius-lg); font-size: var(--w-font-md);
585
+ font-weight: var(--w-weight-medium); cursor: pointer;
586
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); background: var(--unn-color-bg-primary); color: var(--unn-color-text-body);
587
+ transition: border-color 0.15s;
588
+ }
589
+ .ai-modal-cancel:hover { border-color: var(--unn-color-text-subtle); }
590
+
591
+ /* ---- Toast notification ---- */
592
+ .toast {
593
+ position: absolute; bottom: 60px; left: 16px; right: 16px;
594
+ background: var(--unn-color-brand-dark); color: var(--unn-color-text-inverse);
595
+ padding: 10px 14px; border-radius: var(--w-radius-lg);
596
+ font-size: var(--w-font-base); font-weight: var(--w-weight-medium);
597
+ z-index: 20; text-align: center;
598
+ animation: toast-in 0.2s ease;
599
+ }
600
+ @keyframes toast-in {
601
+ from { opacity: 0; transform: translateY(8px); }
602
+ to { opacity: 1; transform: translateY(0); }
603
+ }
604
+
605
+ /* ---- UI States action bar (captures + tab nav) ---- */
606
+ .action-bar {
607
+ display: flex; align-items: center; justify-content: space-between;
608
+ padding: 8px 18px; border-bottom: 1px solid var(--unn-color-border-default);
609
+ flex-shrink: 0; gap: 8px;
610
+ }
611
+ .action-bar-tabs { display: flex; gap: 4px; }
612
+ .tab-btn {
613
+ padding: 5px 12px; border-radius: var(--w-radius-sm); font-size: var(--w-font-sm); font-weight: var(--w-weight-medium);
614
+ cursor: pointer; border: var(--w-border-width) solid transparent;
615
+ background: var(--unn-color-bg-tertiary); color: var(--unn-color-text-muted);
616
+ transition: background 0.15s, color 0.15s;
617
+ }
618
+ .tab-btn:hover { background: var(--unn-color-border-default); color: var(--unn-color-text-body); }
619
+ .tab-btn.active {
620
+ background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse); border-color: var(--unn-color-brand-primary);
621
+ }
622
+ .capture-btn {
623
+ padding: 5px 12px; border-radius: var(--w-radius-sm); font-size: var(--w-font-sm); font-weight: var(--w-weight-semi);
624
+ cursor: pointer;
625
+ border: var(--w-border-width) solid var(--unn-color-brand-primary); background: var(--unn-color-bg-primary); color: var(--unn-color-brand-primary);
626
+ transition: background 0.15s, color 0.15s, opacity 0.15s;
627
+ display: flex; align-items: center; gap: 5px;
628
+ white-space: nowrap;
629
+ }
630
+ .capture-btn:hover { background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse); }
631
+ .capture-btn:active { transform: scale(0.97); }
632
+ .capture-btn:disabled { opacity: 0.5; cursor: not-allowed; }
633
+ .capture-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }
634
+
635
+ /* ---- UI States list view ---- */
636
+ .ui-states-list {
637
+ flex: 1; overflow-y: auto; padding: 0;
638
+ }
639
+ .ui-state-item {
640
+ padding: var(--w-space-v-md) var(--w-space-h-md); border-bottom: 1px solid var(--unn-color-border-default);
641
+ transition: background 0.1s;
642
+ }
643
+ .ui-state-item:hover { background: var(--unn-color-bg-secondary); }
644
+ .ui-state-url {
645
+ font-size: var(--w-font-base); font-weight: var(--w-weight-semi); color: var(--unn-color-text-primary);
646
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
647
+ max-width: 280px;
648
+ }
649
+ .ui-state-meta {
650
+ font-size: var(--w-font-xs); color: var(--unn-color-text-subtle); margin-top: 3px;
651
+ display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
652
+ }
653
+ .ui-state-role-badge {
654
+ font-size: var(--w-font-xxs); font-weight: var(--w-weight-semi); padding: 1px 6px;
655
+ border-radius: var(--w-radius-xs); background: var(--unn-color-accent-tint-bg); color: var(--unn-color-accent-strong);
656
+ text-transform: uppercase; letter-spacing: 0.04em;
657
+ }
658
+ .ui-state-terms-preview {
659
+ font-size: var(--w-font-xs); color: var(--unn-color-text-muted); margin-top: 4px;
660
+ }
661
+ .ui-state-actions {
662
+ margin-top: 8px; display: flex; gap: 6px;
663
+ }
664
+ .view-detail-btn {
665
+ padding: 4px 10px; border-radius: var(--w-radius-sm); font-size: var(--w-font-sm); font-weight: var(--w-weight-medium);
666
+ cursor: pointer; border: var(--w-border-width) solid var(--unn-color-brand-primary);
667
+ background: var(--unn-color-bg-primary); color: var(--unn-color-brand-primary);
668
+ transition: background 0.15s, color 0.15s;
669
+ }
670
+ .view-detail-btn:hover { background: var(--unn-color-brand-primary); color: var(--unn-color-text-inverse); }
671
+
672
+ /* ---- Load more ---- */
673
+ .load-more-container { padding: var(--w-space-v-md) var(--w-space-h-md); text-align: center; }
674
+ .load-more-btn {
675
+ width: 100%; padding: 8px 16px; border-radius: var(--w-radius-lg);
676
+ font-size: var(--w-font-base); font-weight: var(--w-weight-medium); cursor: pointer;
677
+ border: var(--w-border-width) solid var(--unn-color-border-subtle); background: var(--unn-color-bg-primary); color: var(--unn-color-text-body);
678
+ transition: background 0.15s;
679
+ }
680
+ .load-more-btn:hover { background: var(--unn-color-bg-tertiary); }
681
+
682
+ /* ---- UI States empty state ---- */
683
+ .ui-states-empty {
684
+ padding: 40px 18px; text-align: center;
685
+ }
686
+ .ui-states-empty-icon {
687
+ width: 40px; height: 40px; stroke: var(--unn-color-border-subtle); fill: none;
688
+ margin: 0 auto 12px;
689
+ }
690
+ .ui-states-empty-text {
691
+ font-size: var(--w-font-base); color: var(--unn-color-text-subtle); line-height: 1.5;
692
+ }
693
+
694
+ /* ---- UI State detail view ---- */
695
+ .ui-state-detail-view {
696
+ display: flex; flex-direction: column; flex: 1; overflow-y: auto;
697
+ }
698
+ .detail-meta-section { padding: var(--w-space-v-lg) var(--w-space-h-md); border-bottom: 1px solid var(--unn-color-border-default); }
699
+ .detail-page-title {
700
+ font-size: var(--w-font-lg, 15px); font-weight: var(--w-weight-semi); color: var(--unn-color-text-primary);
701
+ padding: var(--w-space-v-md) var(--w-space-h-md) 2px; flex-shrink: 0;
702
+ }
703
+ .detail-meta-row {
704
+ display: flex; gap: 12px; font-size: var(--w-font-sm); color: var(--unn-color-text-muted);
705
+ flex-wrap: wrap; align-items: center;
706
+ }
707
+ .detail-section { padding: var(--w-space-v-md) var(--w-space-h-md); border-bottom: 1px solid var(--unn-color-border-default); }
708
+ .detail-section-heading {
709
+ font-size: var(--w-font-xs); font-weight: var(--w-weight-semi); color: var(--unn-color-text-subtle);
710
+ text-transform: uppercase; letter-spacing: 0.05em;
711
+ margin-bottom: 8px; display: flex; justify-content: space-between;
712
+ align-items: center; cursor: pointer; user-select: none;
713
+ }
714
+ .detail-section-heading svg {
715
+ width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2;
716
+ transition: transform 0.2s;
717
+ }
718
+ .detail-section-heading.collapsed svg { transform: rotate(-90deg); }
719
+ .detail-section-content { display: flex; flex-wrap: wrap; gap: 6px; }
720
+ .detail-section-content.collapsed { display: none; }
721
+ .detail-section-list {
722
+ font-size: var(--w-font-sm); color: var(--unn-color-text-body); line-height: 1.6;
723
+ padding-left: 16px;
724
+ }
725
+ .detail-section-list.collapsed { display: none; }
726
+
727
+ /* ---- Term pill / link in state detail ---- */
728
+ .ui-state-term-link {
729
+ display: inline-flex; align-items: center;
730
+ padding: 3px 10px; border-radius: var(--w-radius-pill);
731
+ font-size: var(--w-font-xs); font-weight: var(--w-weight-semi);
732
+ background: var(--unn-color-accent-tint-bg); color: var(--unn-color-accent-strong);
733
+ cursor: pointer; border: none;
734
+ transition: background 0.15s, color 0.15s;
735
+ }
736
+ .ui-state-term-link:hover { background: var(--unn-color-accent-strong); color: var(--unn-color-text-inverse); }
737
+
738
+ /* ---- Product Memory section ---- */
739
+ .product-memory-section {
740
+ padding: 10px var(--w-space-h-md);
741
+ border-top: 1px solid var(--unn-color-border-default);
742
+ }
743
+ .product-memory-heading {
744
+ font-size: var(--w-font-xxs); font-weight: var(--w-weight-bold); color: var(--unn-color-text-muted);
745
+ text-transform: uppercase; letter-spacing: 0.05em;
746
+ margin-bottom: 8px;
747
+ }
748
+ .product-memory-text {
749
+ font-size: var(--w-font-base); color: var(--unn-color-text-primary); line-height: 1.6;
750
+ white-space: pre-wrap; word-break: break-word;
751
+ margin-bottom: 8px;
752
+ }
753
+ .product-memory-textarea {
754
+ width: 100%; box-sizing: border-box;
755
+ font-size: var(--w-font-base); color: var(--unn-color-text-primary); line-height: 1.6;
756
+ border: 1px solid var(--unn-color-border-subtle); border-radius: var(--w-radius-sm);
757
+ padding: 8px 10px; resize: vertical; min-height: 80px;
758
+ font-family: inherit; background: var(--unn-color-bg-primary);
759
+ margin-bottom: 8px;
760
+ }
761
+ .product-memory-textarea:focus {
762
+ outline: none; border-color: var(--unn-color-brand-primary);
763
+ box-shadow: 0 0 0 2px var(--unn-focus-ring-color);
764
+ }
765
+ .product-memory-actions {
766
+ display: flex; gap: 6px; justify-content: flex-end;
767
+ }
768
+ .product-memory-edit-btn {
769
+ font-size: var(--w-font-sm); font-weight: var(--w-weight-semi); color: var(--unn-color-accent);
770
+ background: none; border: none; cursor: pointer;
771
+ padding: 4px 8px; border-radius: var(--w-radius-xs);
772
+ }
773
+ .product-memory-edit-btn:hover { background: var(--unn-color-accent-tint-bg); }
774
+ .product-memory-delete-entry-btn {
775
+ font-size: var(--w-font-sm); color: var(--unn-color-text-muted);
776
+ background: none; border: none; cursor: pointer;
777
+ padding: 4px 6px; border-radius: var(--w-radius-xs);
778
+ opacity: 0.7;
779
+ }
780
+ .product-memory-delete-entry-btn:hover {
781
+ background: #fee; color: #d63; opacity: 1;
782
+ }
783
+ .product-memory-save-btn {
784
+ font-size: var(--w-font-sm); font-weight: var(--w-weight-semi); color: var(--unn-color-text-inverse);
785
+ background: var(--unn-color-brand-primary); border: none; cursor: pointer;
786
+ padding: 5px 14px; border-radius: var(--w-radius-sm);
787
+ }
788
+ .product-memory-save-btn:hover { opacity: 0.85; }
789
+ .product-memory-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
790
+ .product-memory-cancel-btn {
791
+ font-size: var(--w-font-sm); font-weight: var(--w-weight-semi); color: var(--unn-color-text-muted);
792
+ background: none; border: 1px solid var(--unn-color-border-subtle); cursor: pointer;
793
+ padding: 4px 10px; border-radius: var(--w-radius-sm);
794
+ }
795
+ .product-memory-cancel-btn:hover { background: var(--unn-color-bg-tertiary); }
796
+ .detail-actions {
797
+ display: flex;
798
+ gap: 6px;
799
+ justify-content: space-between;
800
+ align-items: center;
801
+ padding: var(--w-space-v-md) var(--w-space-h-md);
802
+ border-top: 1px solid var(--unn-color-border-subtle);
803
+ margin-top: 4px;
804
+ }
805
+ .detail-delete-btn, .detail-add-btn {
806
+ font-size: var(--w-font-xs); font-weight: 500; border: none;
807
+ border-radius: var(--w-radius-sm); cursor: pointer; padding: 5px 12px;
808
+ }
809
+ .detail-delete-btn {
810
+ background: var(--unn-color-bg-tertiary);
811
+ color: var(--unn-color-text-muted);
812
+ }
813
+ .detail-delete-btn:hover {
814
+ background: var(--unn-color-border-default);
815
+ }
816
+ .detail-add-btn {
817
+ background: var(--unn-color-brand-primary);
818
+ color: #fff;
819
+ }
820
+ .detail-add-btn:hover {
821
+ opacity: 0.88;
822
+ }
823
+
824
+ /* ---- Snapshot preview in state-detail view ---- */
825
+ .ui-state-snapshot-preview {
826
+ max-height: 180px; overflow: hidden;
827
+ border-bottom: 1px solid var(--unn-color-border-default);
828
+ background: var(--unn-color-bg-secondary);
829
+ padding: 6px var(--w-space-h-md);
830
+ }
831
+ .ui-state-snapshot-preview * { pointer-events: none; }
832
+
833
+ /* ---- Replay highlight (glossary terms on page) ---- */
834
+ .unnoodle-replay-highlight {
835
+ background: var(--unn-color-accent-tint);
836
+ border-bottom: 2px solid var(--unn-color-brand-primary);
837
+ border-radius: 2px;
838
+ animation: replay-pulse 0.6s ease-out;
839
+ }
840
+ @keyframes replay-pulse {
841
+ from { background: var(--unn-color-accent-tint-strong); }
842
+ to { background: var(--unn-color-accent-tint); }
843
+ }
844
+
845
+ /* ---- Drag-resize handle ---- */
846
+ .panel-resize-handle {
847
+ position: absolute; left: 0; top: 0; bottom: 0;
848
+ width: 6px; cursor: col-resize; z-index: 10;
849
+ }
850
+ .panel-resize-handle:hover { background: var(--unn-color-accent-tint); }
851
+ .panel-shell.left-side .panel-resize-handle { left: auto; right: 0; }
852
+
853
+ /* ---- Skeleton loaders ---- */
854
+ @keyframes skeleton-shimmer {
855
+ 0% { background-position: -400px 0; }
856
+ 100% { background-position: 400px 0; }
857
+ }
858
+ .skeleton-line {
859
+ border-radius: 4px;
860
+ background: linear-gradient(90deg,
861
+ var(--unn-color-border) 25%,
862
+ color-mix(in srgb, var(--unn-color-border) 40%, var(--unn-color-bg)) 50%,
863
+ var(--unn-color-border) 75%);
864
+ background-size: 800px 100%;
865
+ animation: skeleton-shimmer 1.4s infinite linear;
866
+ }
867
+ .skeleton-home {
868
+ padding: 0;
869
+ display: flex;
870
+ flex-direction: column;
871
+ align-items: center;
872
+ justify-content: center;
873
+ height: 100%;
874
+ text-align: center;
875
+ }
876
+ .skeleton-loading-header {
877
+ padding: 0 24px 32px;
878
+ }
879
+ .skeleton-loading-brand {
880
+ font-size: 20px; font-weight: 700;
881
+ color: var(--unn-color-brand-primary);
882
+ letter-spacing: -0.01em;
883
+ margin-bottom: 12px;
884
+ }
885
+ .skeleton-loading-title {
886
+ font-size: var(--w-font-base); font-weight: 600;
887
+ color: var(--unn-color-text-primary);
888
+ margin-bottom: 6px;
889
+ }
890
+ .skeleton-loading-sub {
891
+ font-size: var(--w-font-sm);
892
+ color: var(--unn-color-text-subtle);
893
+ }
894
+ .skeleton-body {
895
+ width: 100%; padding: 0 24px;
896
+ display: flex; flex-direction: column; gap: 16px;
897
+ }
898
+ .skeleton-strip {
899
+ padding: 10px 0 8px;
900
+ }
901
+ .skeleton-section {
902
+ display: flex;
903
+ flex-direction: column;
904
+ gap: 6px;
905
+ padding-bottom: var(--w-space-2);
906
+ }
907
+ .skeleton-section-head {
908
+ height: 9px;
909
+ width: 28%;
910
+ border-radius: 4px;
911
+ background: linear-gradient(90deg,
912
+ var(--unn-color-border) 25%,
913
+ color-mix(in srgb, var(--unn-color-border) 40%, var(--unn-color-bg)) 50%,
914
+ var(--unn-color-border) 75%);
915
+ background-size: 800px 100%;
916
+ animation: skeleton-shimmer 1.4s infinite linear;
917
+ margin-bottom: 4px;
918
+ }
919
+ .skeleton-row {
920
+ height: 24px;
921
+ display: flex;
922
+ align-items: center;
923
+ border-radius: var(--w-radius-1);
924
+ }
925
+
926
+ /* ---- Home view layout ---- */
927
+ .home-view {
928
+ display: flex; flex-direction: column; height: 100%; overflow: hidden;
929
+ background: var(--unn-color-bg-primary);
930
+ }
931
+
932
+ /* ---- Context strip \u2014 always visible action toolbar ---- */
933
+ .context-strip {
934
+ display: flex; align-items: center; gap: 6px;
935
+ padding: 6px 10px;
936
+ border-bottom: 1px solid var(--unn-color-border-default);
937
+ flex-shrink: 0;
938
+ min-height: 38px;
939
+ }
940
+ .strip-idle {
941
+ display: flex; align-items: center; gap: 6px; width: 100%;
942
+ }
943
+ .strip-btn {
944
+ display: inline-flex; align-items: center; gap: 4px;
945
+ padding: 3px 10px; border-radius: var(--w-radius-lg);
946
+ border: 1px solid var(--unn-color-border-default);
947
+ background: var(--unn-color-bg-secondary);
948
+ color: var(--unn-color-text-secondary); font-size: var(--w-font-sm);
949
+ cursor: pointer; transition: background 0.15s, color 0.15s;
950
+ }
951
+ .strip-btn:hover { background: var(--unn-color-bg-hover); color: var(--unn-color-text-primary); }
952
+ .strip-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
953
+ /* Pick-mode state */
954
+ .pick-mode-prompt {
955
+ display: none; align-items: center; gap: 8px; width: 100%;
956
+ }
957
+ .pick-prompt-text {
958
+ flex: 1; font-size: var(--w-font-sm); color: var(--unn-color-text-secondary);
959
+ font-style: italic;
960
+ }
961
+ .strip-cancel-btn {
962
+ padding: 2px 8px; border-radius: var(--w-radius-lg);
963
+ border: 1px solid var(--unn-color-border-default);
964
+ background: transparent; color: var(--unn-color-text-secondary);
965
+ font-size: var(--w-font-xs); cursor: pointer;
966
+ }
967
+ .strip-cancel-btn:hover { color: var(--unn-color-text-primary); border-color: var(--unn-color-text-primary); }
968
+ /* Capture-describe view */
969
+ .capture-describe-view {
970
+ display: none; flex-direction: column; gap: 6px; width: 100%; padding: 4px 0;
971
+ }
972
+ .capture-snapshot-preview {
973
+ max-height: 120px; overflow: hidden; border-radius: var(--w-radius-1);
974
+ border: 1px solid var(--unn-color-border-default);
975
+ background: var(--unn-color-bg-secondary);
976
+ }
977
+ .capture-snapshot-meta {
978
+ font-size: var(--w-font-xs); color: var(--unn-color-text-secondary); padding: 2px 4px;
979
+ }
980
+ .capture-description-input {
981
+ width: 100%; box-sizing: border-box; resize: none;
982
+ border: 1px solid var(--unn-color-border-default);
983
+ border-radius: var(--w-radius-1);
984
+ background: var(--unn-color-bg-secondary);
985
+ color: var(--unn-color-text-primary); font-size: var(--w-font-sm);
986
+ padding: 6px 8px; outline: none; font-family: inherit;
987
+ }
988
+ .capture-description-input:focus { border-color: var(--unn-color-accent); }
989
+ .capture-error {
990
+ font-size: var(--w-font-xs); color: var(--unn-color-error, #d32f2f); margin: 0;
991
+ }
992
+ .capture-actions {
993
+ display: flex; gap: 6px; justify-content: flex-end;
994
+ }
995
+ .capture-save-btn {
996
+ padding: 3px 12px; border-radius: var(--w-radius-lg);
997
+ border: none; background: var(--unn-color-accent); color: #fff;
998
+ font-size: var(--w-font-sm); cursor: pointer;
999
+ }
1000
+ .capture-save-btn:disabled { opacity: 0.6; cursor: not-allowed; }
1001
+ /* Search bar \u2014 always visible */
1002
+ .home-search-bar {
1003
+ padding: 8px 10px 2px;
1004
+ flex-shrink: 0;
1005
+ }
1006
+ .home-search-input {
1007
+ width: 100%; box-sizing: border-box; height: 26px;
1008
+ border: 1px solid var(--unn-color-border-default);
1009
+ border-radius: var(--w-radius-lg);
1010
+ background: var(--unn-color-bg-secondary);
1011
+ color: var(--unn-color-text-primary); font-size: var(--w-font-sm);
1012
+ padding: 0 10px; outline: none;
1013
+ transition: border-color 0.15s, box-shadow 0.15s;
1014
+ }
1015
+ .home-search-input:focus {
1016
+ border-color: var(--unn-color-brand-primary);
1017
+ box-shadow: 0 0 0 3px var(--unn-color-brand-tint);
1018
+ }
1019
+
1020
+ /* Sections scroll area */
1021
+ .home-sections {
1022
+ flex: 1; overflow-y: auto;
1023
+ padding: 10px 10px 20px;
1024
+ display: flex; flex-direction: column; gap: 24px;
1025
+ }
1026
+
1027
+ /* ---- Sections \u2014 no card border, grouped by heading + spacing ---- */
1028
+ .home-section { /* bare container, no border/bg */ }
1029
+ .home-section:not(:last-child) {
1030
+ border-bottom: 1px solid var(--unn-color-border-default);
1031
+ padding-bottom: 20px;
1032
+ }
1033
+ .home-section-header {
1034
+ display: flex; align-items: center; justify-content: space-between;
1035
+ padding: 0 0 6px;
1036
+ }
1037
+ .home-section-title {
1038
+ display: flex; align-items: center; gap: 6px;
1039
+ font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
1040
+ text-transform: uppercase; color: var(--unn-color-text-muted);
1041
+ }
1042
+ .home-section-dot {
1043
+ width: 12px; height: 12px; flex-shrink: 0;
1044
+ display: flex; align-items: center; justify-content: center;
1045
+ }
1046
+ .home-section-dot svg {
1047
+ width: 12px; height: 12px; display: block;
1048
+ }
1049
+ .home-section-add {
1050
+ font-size: 15px; font-weight: 400; line-height: 1;
1051
+ color: var(--unn-color-brand-primary);
1052
+ background: transparent;
1053
+ border: none; cursor: pointer;
1054
+ padding: 0 2px; border-radius: var(--w-radius-sm);
1055
+ transition: color 0.15s; flex-shrink: 0;
1056
+ }
1057
+ .home-section-add:hover { color: var(--unn-color-accent-strong); }
1058
+ .home-section-add:disabled { color: var(--unn-color-text-subtle); cursor: default; }
1059
+ .home-section-show-all {
1060
+ font-size: 10px; font-weight: 400; line-height: 1;
1061
+ color: var(--unn-color-text-secondary);
1062
+ background: transparent;
1063
+ border: none; cursor: pointer;
1064
+ padding: 2px 4px; border-radius: var(--w-radius-sm);
1065
+ transition: color 0.15s; flex-shrink: 0;
1066
+ margin-right: 4px;
1067
+ }
1068
+ .home-section-show-all:hover {
1069
+ color: var(--unn-color-text);
1070
+ background: var(--unn-color-surface-subtle);
1071
+ }
1072
+ .home-section-helper {
1073
+ font-size: 10px; color: var(--unn-color-text-subtle);
1074
+ margin: -4px 0 6px; line-height: 1.4;
1075
+ }
1076
+
1077
+ /* ---- Concept rows ---- */
1078
+ .concept-row {
1079
+ display: flex; align-items: center; gap: 8px;
1080
+ padding: 6px 6px; cursor: pointer;
1081
+ margin: 0 -6px;
1082
+ transition: background 0.12s;
1083
+ border-radius: var(--w-radius-sm);
1084
+ }
1085
+ .concept-row:hover { background: var(--unn-color-bg-secondary); }
1086
+ .concept-row:hover .concept-name { color: var(--unn-color-brand-primary); }
1087
+ .concept-name {
1088
+ flex: 1; font-size: var(--w-font-base); font-weight: 500;
1089
+ color: var(--unn-color-text-primary);
1090
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
1091
+ transition: color 0.12s;
1092
+ }
1093
+ .concept-abbr {
1094
+ font-size: var(--w-font-xs); color: var(--unn-color-accent-strong);
1095
+ background: var(--unn-color-accent-tint-bg);
1096
+ border-radius: var(--w-radius-pill);
1097
+ padding: 1px 7px; white-space: nowrap; flex-shrink: 0; font-weight: 500;
1098
+ }
1099
+ .concept-chevron {
1100
+ flex-shrink: 0; color: var(--unn-color-text-subtle);
1101
+ opacity: 0.35; transition: opacity 0.12s, color 0.12s;
1102
+ }
1103
+ .concept-chevron svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.5; }
1104
+ .concept-row:hover .concept-chevron { opacity: 1; color: var(--unn-color-brand-primary); }
1105
+ .concept-subheading {
1106
+ font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
1107
+ text-transform: uppercase; color: var(--unn-color-text-subtle);
1108
+ padding: 8px 0 4px; margin-top: 4px;
1109
+ }
1110
+ .concept-subheading:first-child { margin-top: 0; }
1111
+
1112
+ /* ---- Section empty states ---- */
1113
+ .section-empty { padding: 14px 0 6px; text-align: left; }
1114
+ .section-empty-title {
1115
+ font-size: var(--w-font-sm); font-weight: 600;
1116
+ color: var(--unn-color-text-body); margin-bottom: 4px;
1117
+ }
1118
+ .section-empty-text {
1119
+ font-size: var(--w-font-sm); color: var(--unn-color-text-subtle); line-height: 1.5;
1120
+ margin-bottom: 12px;
1121
+ }
1122
+ .section-empty-action {
1123
+ all: unset; display: inline-flex; cursor: pointer;
1124
+ font-size: var(--w-font-sm); font-weight: 500;
1125
+ color: var(--unn-color-text-primary);
1126
+ border: 1px solid var(--unn-color-border-default);
1127
+ border-radius: var(--w-radius-sm);
1128
+ padding: 5px 12px;
1129
+ transition: background 0.15s, border-color 0.15s;
1130
+ }
1131
+ .section-empty-action:hover {
1132
+ background: var(--unn-color-bg-secondary);
1133
+ border-color: var(--unn-color-text-muted);
1134
+ }
1135
+
1136
+ /* ---- Memory items in PRODUCT MEMORY home section ---- */
1137
+ .memory-item {
1138
+ display: flex; align-items: center; gap: 8px;
1139
+ padding: 6px 6px; cursor: pointer;
1140
+ margin: 0 -6px;
1141
+ transition: background 0.12s;
1142
+ border-radius: var(--w-radius-sm);
1143
+ }
1144
+ .memory-item:hover { background: var(--unn-color-bg-secondary); }
1145
+ .memory-item:hover .memory-item-title { color: var(--unn-color-brand-primary); }
1146
+ .memory-item:hover .concept-chevron { opacity: 1; color: var(--unn-color-brand-primary); }
1147
+ .memory-item-content {
1148
+ flex: 1; min-width: 0;
1149
+ }
1150
+ .memory-item-title {
1151
+ font-size: var(--w-font-base); font-weight: 500;
1152
+ color: var(--unn-color-text-primary);
1153
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
1154
+ transition: color 0.12s;
1155
+ }
1156
+ .memory-item-meta {
1157
+ font-size: var(--w-font-xs); color: var(--unn-color-text-subtle);
1158
+ margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
1159
+ }
1160
+
1161
+ /* ---- Show-all link ---- */
1162
+ .home-show-more {
1163
+ display: block; width: 100%; box-sizing: border-box;
1164
+ padding: 6px 0; font-size: var(--w-font-xs); font-weight: 500;
1165
+ color: var(--unn-color-brand-primary); cursor: pointer; text-align: left;
1166
+ margin-top: 2px; text-decoration: none;
1167
+ transition: color 0.15s;
1168
+ }
1169
+ .home-show-more:hover {
1170
+ color: var(--unn-color-accent-strong);
1171
+ text-decoration: underline;
1172
+ }
1173
+
1174
+ /* ---- Discussion cards in home ---- */
1175
+ .discussion-card {
1176
+ display: flex; align-items: flex-start; gap: 8px;
1177
+ padding: 6px 6px; cursor: pointer;
1178
+ margin: 0 -6px;
1179
+ transition: background 0.12s;
1180
+ border-radius: var(--w-radius-sm);
1181
+ }
1182
+ .discussion-card:hover { background: var(--unn-color-bg-tertiary); }
1183
+ .discussion-card:hover .concept-chevron { opacity: 1; color: var(--unn-color-brand-primary); }
1184
+ .discussion-card-main {
1185
+ flex: 1;
1186
+ }
1187
+ .discussion-meta {
1188
+ display: flex; align-items: center; gap: 5px;
1189
+ font-size: 10px; color: var(--unn-color-text-subtle);
1190
+ margin-bottom: 3px; font-weight: 500;
1191
+ }
1192
+ .discussion-meta-dot {
1193
+ width: 4px; height: 4px; border-radius: 50%;
1194
+ background: var(--unn-color-brand-secondary); flex-shrink: 0;
1195
+ }
1196
+ .discussion-body {
1197
+ margin: 0; font-size: var(--w-font-sm); color: var(--unn-color-text-body);
1198
+ white-space: pre-wrap; word-break: break-word; line-height: 1.5;
1199
+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
1200
+ }
1201
+ .discussion-replies { margin-top: 5px; padding-left: 10px; border-left: 2px solid var(--unn-color-border-default); }
1202
+ .discussion-reply { margin-top: 4px; }
1203
+
1204
+ /* ---- Clarification detail view ---- */
1205
+ .clarif-label {
1206
+ font-size: var(--w-font-xs); font-weight: 600; letter-spacing: 0.06em;
1207
+ text-transform: uppercase; color: var(--unn-color-text-subtle);
1208
+ margin-bottom: 6px;
1209
+ }
1210
+ .clarif-question {
1211
+ margin: 0 0 4px; font-size: var(--w-font-md);
1212
+ color: var(--unn-color-text-primary); line-height: 1.5;
1213
+ font-weight: var(--w-weight-semi); white-space: pre-wrap; word-break: break-word;
1214
+ }
1215
+ .clarif-empty-replies {
1216
+ font-size: var(--w-font-sm); color: var(--unn-color-text-subtle);
1217
+ padding: 6px 0;
1218
+ }
1219
+ .clarif-reply-item {
1220
+ padding: 6px 0;
1221
+ border-bottom: 1px solid var(--unn-color-border-subtle);
1222
+ }
1223
+ .clarif-reply-item:last-child { border-bottom: none; }
1224
+ .clarif-reply-form {
1225
+ padding: 10px 12px 12px;
1226
+ border-top: 1px solid var(--unn-color-border-default);
1227
+ margin-top: 6px;
1228
+ }
1229
+
1230
+ /* ---- Ask Question form ---- */
1231
+ .ask-form { padding: 10px 12px; border-bottom: 1px solid var(--unn-color-border-default); }
1232
+ .ask-textarea {
1233
+ width: 100%; box-sizing: border-box;
1234
+ border: 1px solid var(--unn-color-border-default);
1235
+ border-radius: var(--w-radius-sm);
1236
+ background: var(--unn-color-bg-secondary);
1237
+ color: var(--unn-color-text-primary); font-size: var(--w-font-sm);
1238
+ padding: 7px 10px; resize: vertical; outline: none; font-family: inherit;
1239
+ transition: border-color 0.15s;
1240
+ }
1241
+ .ask-textarea:focus { border-color: var(--unn-color-brand-primary); }
1242
+ .ask-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
1243
+ .ask-cancel, .ask-submit {
1244
+ font-size: var(--w-font-xs); font-weight: 500; border: none;
1245
+ border-radius: var(--w-radius-sm); cursor: pointer; padding: 5px 12px;
1246
+ }
1247
+ .ask-cancel { background: var(--unn-color-bg-tertiary); color: var(--unn-color-text-muted); }
1248
+ .ask-cancel:hover { background: var(--unn-color-border-default); }
1249
+ .ask-submit { background: var(--unn-color-brand-primary); color: #fff; }
1250
+ .ask-submit:hover { opacity: 0.88; }
1251
+ .ask-submit:disabled { opacity: 0.5; cursor: default; }
1252
+
1253
+ /* ---- Add Term form ---- */
1254
+ .add-term-form { padding: 10px 12px; border-bottom: 1px solid var(--unn-color-border-default); }
1255
+ .add-term-input {
1256
+ width: 100%; box-sizing: border-box;
1257
+ border: 1px solid var(--unn-color-border-default);
1258
+ border-radius: var(--w-radius-sm);
1259
+ background: var(--unn-color-bg-secondary);
1260
+ color: var(--unn-color-text-primary); font-size: var(--w-font-sm);
1261
+ padding: 7px 10px; outline: none; font-family: inherit;
1262
+ transition: border-color 0.15s;
1263
+ }
1264
+ .add-term-input:focus { border-color: var(--unn-color-brand-primary); }
1265
+ .add-term-input + .add-term-input { margin-top: 6px; }
1266
+ `,bo=`
1267
+ .panel-shell {
1268
+ position: static !important;
1269
+ width: 100vw !important; height: 100vh !important;
1270
+ transform: none !important;
1271
+ max-width: 100vw !important;
1272
+ border-radius: 0 !important;
1273
+ box-shadow: none !important;
1274
+ }
1275
+ .panel-shell.open { transform: none !important; }
1276
+ .panel {
1277
+ border-radius: 0 !important;
1278
+ border: none !important;
1279
+ /* Fallback bg if CSS vars haven't re-resolved after adoptNode */
1280
+ background: var(--unn-color-bg-primary, #ffffff) !important;
1281
+ }
1282
+ `;function yo(i,e,t){let n=(t==null?void 0:t.googleEnabled)===true,o=(t==null?void 0:t.microsoftEnabled)===true,r=n||o,d=r?`${r?`<div class="sso-divider" data-testid="widget-sso-divider">
1283
+ <div class="sso-divider-line"></div>
1284
+ <span class="sso-divider-text">or sign in with</span>
1285
+ <div class="sso-divider-line"></div>
1286
+ </div>`:""}<div class="sso-buttons">${n?`<button class="sso-btn" type="button" data-testid="widget-sso-google-btn" aria-label="Continue with Google">
1287
+ <svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true">
1288
+ <path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
1289
+ <path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
1290
+ <path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z"/>
1291
+ <path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
1292
+ </svg>
1293
+ <span>Continue with Google</span>
1294
+ </button>`:""}${o?`<button class="sso-btn" type="button" data-testid="widget-sso-microsoft-btn" aria-label="Continue with Microsoft">
1295
+ <svg width="18" height="18" viewBox="0 0 23 23" aria-hidden="true">
1296
+ <rect x="1" y="1" width="10" height="10" fill="#F25022"/>
1297
+ <rect x="12" y="1" width="10" height="10" fill="#7FBA00"/>
1298
+ <rect x="1" y="12" width="10" height="10" fill="#00A4EF"/>
1299
+ <rect x="12" y="12" width="10" height="10" fill="#FFB900"/>
1300
+ </svg>
1301
+ <span>Continue with Microsoft</span>
1302
+ </button>`:""}</div>`:"";i.innerHTML=`
1303
+ <div class="login-form">
1304
+ ${e.onBack?'<button class="login-back-btn" data-testid="widget-login-back" type="button">\u2039 Back</button>':""}
1305
+ <h2 class="login-heading">Sign in to Unnoodle</h2>
1306
+ <p class="login-sub">Access your team's glossary</p>
1307
+ <div class="login-error" role="alert" data-testid="widget-login-error"></div>
1308
+ <div class="form-field">
1309
+ <label class="form-label" for="unn-email">Email</label>
1310
+ <input class="form-input" id="unn-email" type="email"
1311
+ autocomplete="email" placeholder="you@company.com" required
1312
+ data-testid="widget-login-email" />
1313
+ </div>
1314
+ <div class="form-field">
1315
+ <label class="form-label" for="unn-password">Password</label>
1316
+ <input class="form-input" id="unn-password" type="password"
1317
+ autocomplete="current-password" placeholder="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" required
1318
+ data-testid="widget-login-password" />
1319
+ </div>
1320
+ <button class="form-submit" id="unn-submit" data-testid="widget-login-submit">Sign in</button>
1321
+ ${d}
1322
+ </div>
1323
+ `;let l=i.querySelector('[data-testid="widget-login-back"]');if(l&&e.onBack){let f=e.onBack;l.addEventListener("click",()=>f());}let p=i.querySelector("#unn-email"),h=i.querySelector("#unn-password"),m=i.querySelector("#unn-submit"),v=f=>{f.preventDefault();let y=p.value.trim(),A=h.value;!y||!A||e.onLogin(y,A);};if(m.addEventListener("click",v),h.addEventListener("keydown",f=>{f.key==="Enter"&&v(f);}),e.onSsoLogin){let f=e.onSsoLogin;if(n){let y=i.querySelector('[data-testid="widget-sso-google-btn"]');y==null||y.addEventListener("click",()=>f("google"));}if(o){let y=i.querySelector('[data-testid="widget-sso-microsoft-btn"]');y==null||y.addEventListener("click",()=>f("microsoft"));}}p.focus();}function wo(i,e){let t=i.querySelector("#unn-submit");t&&(t.disabled=e,t.textContent=e?"Signing in\u2026":"Sign in");}function xo(i,e){let t=i.querySelector(".login-error");t&&(t.textContent=e,t.classList.add("visible"));}function B(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ko(i,e,t,n){var d,l,p;let o=B((d=e.authorName)!=null?d:"Unknown"),r=e.createdAt?new Date(e.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"",s=((l=e.replies)!=null?l:[]).length===0?'<div class="clarif-empty-replies">No replies yet.</div>':e.replies.map(h=>{var m;return `
1324
+ <div class="clarif-reply-item">
1325
+ <div class="discussion-meta">
1326
+ <span class="discussion-meta-dot"></span>
1327
+ ${B((m=h.authorName)!=null?m:"Unknown")} &middot;
1328
+ ${new Date(h.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}
1329
+ </div>
1330
+ <p class="discussion-body" style="-webkit-line-clamp:unset">${B(h.body)}</p>
1331
+ </div>`}).join(""),a=t?`<div class="clarif-reply-form" data-testid="widget-reply-form">
1332
+ <textarea class="ask-textarea" data-testid="widget-reply-textarea"
1333
+ placeholder="Write a reply\u2026" maxlength="2000" rows="3"></textarea>
1334
+ <div class="ask-actions">
1335
+ <button class="ask-submit" data-testid="widget-reply-submit">Reply</button>
1336
+ </div>
1337
+ <p class="ask-error" style="display:none"></p>
1338
+ </div>`:"";if(i.innerHTML=`
1339
+ <div class="term-detail-view" data-testid="widget-clarif-detail">
1340
+ <div class="detail-back">
1341
+ <button class="back-btn" data-testid="widget-back-btn">&#8592; Back</button>
1342
+ </div>
1343
+ <div class="detail-content">
1344
+ <div class="detail-body">
1345
+ <div class="clarif-label">CLARIFICATION</div>
1346
+ <p class="clarif-question">${B(e.body)}</p>
1347
+ <div class="discussion-meta" style="margin-top:6px">
1348
+ <span class="discussion-meta-dot"></span>
1349
+ ${o} &middot; ${r}
1350
+ </div>
1351
+ </div>
1352
+ </div>
1353
+ <div class="discussions-section">
1354
+ <div class="discussions-heading">Replies (${((p=e.replies)!=null?p:[]).length})</div>
1355
+ ${s}
1356
+ </div>
1357
+ ${a}
1358
+ </div>
1359
+ `,i.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>{var h;return (h=n.onBack)==null?void 0:h.call(n)}),t){let h=i.querySelector('[data-testid="widget-reply-textarea"]'),m=i.querySelector('[data-testid="widget-reply-submit"]'),v=i.querySelector(".ask-error");m.addEventListener("click",()=>{var y;let f=h.value.trim();f&&(v.style.display="none",m.disabled=true,m.textContent="Posting\u2026",(y=n.onPostReply)==null||y.call(n,e.contextId,e.id,f));});}}function Eo(i,e){i.querySelector(".strip-idle").style.display="none";let t=i.querySelector(".pick-mode-prompt");t.style.display="flex",i.querySelector(".capture-describe-view").style.display="none";let n=i.querySelector('[data-testid="widget-context-strip-cancel-btn"]'),o=n.cloneNode(true);o.addEventListener("click",e),n.replaceWith(o);}function To(i,e,t,n){i.querySelector(".strip-idle").style.display="none",i.querySelector(".pick-mode-prompt").style.display="none";let o=i.querySelector(".capture-describe-view");o.style.display="flex";let r=o.querySelector('[data-testid="widget-capture-snapshot-preview"]');r.innerHTML=e.html;let s=o.querySelector('[data-testid="widget-capture-pick-again-btn"]'),a=s.cloneNode(true);a.addEventListener("click",n),s.replaceWith(a);let c=o.querySelector('[data-testid="widget-capture-save-btn"]'),d=c.cloneNode(true);o.querySelector(".capture-error").style.display="none",d.addEventListener("click",()=>{let l=o.querySelector('[data-testid="widget-capture-description-input"]');t(l.value.trim());}),c.replaceWith(d);}function Co(i,e){let t=i.querySelector('[data-testid="widget-capture-save-btn"]');t&&(t.disabled=e,t.textContent=e?"Saving\u2026":"Save");}function Mo(i,e){let t=i.querySelector(".capture-error");t&&(t.textContent=e,t.style.display=e?"block":"none");}function Lo(i){i.querySelector(".strip-idle").style.display="flex",i.querySelector(".pick-mode-prompt").style.display="none",i.querySelector(".capture-describe-view").style.display="none";let e=i.querySelector('[data-testid="widget-capture-description-input"]');e&&(e.value="");let t=i.querySelector(".capture-error");t&&(t.textContent="",t.style.display="none");}function Nt(i,e){let t=document.createElement("div");t.className="capture-form-container",t.setAttribute("data-testid","widget-capture-form");let n=`
1360
+ <style>
1361
+ ${re(`
1362
+ .capture-form-container {
1363
+ display: flex;
1364
+ flex-direction: column;
1365
+ gap: var(--w-space-4);
1366
+ padding: var(--w-space-h-md);
1367
+ background: var(--unn-color-bg-primary);
1368
+ overflow-y: auto;
1369
+ flex: 1;
1370
+ height: 100%;
1371
+ }
1372
+ .capture-form-header {
1373
+ font-size: var(--w-font-xl);
1374
+ font-weight: var(--w-weight-bold);
1375
+ color: var(--unn-color-text-primary);
1376
+ margin: 0 0 4px 0;
1377
+ line-height: 1.3;
1378
+ }
1379
+ .capture-form-subheader {
1380
+ font-size: var(--w-font-md);
1381
+ font-weight: var(--w-weight-medium);
1382
+ color: var(--unn-color-text-secondary);
1383
+ margin: 0 0 16px 0;
1384
+ }
1385
+ .capture-form-field {
1386
+ display: flex;
1387
+ flex-direction: column;
1388
+ gap: 5px;
1389
+ }
1390
+ .capture-form-label {
1391
+ font-size: var(--w-font-sm);
1392
+ font-weight: var(--w-weight-medium);
1393
+ color: var(--unn-color-text-body);
1394
+ }
1395
+ .capture-form-input,
1396
+ .capture-form-textarea {
1397
+ width: 100%;
1398
+ padding: 9px 12px;
1399
+ border: var(--w-border-width) solid var(--unn-color-border-subtle);
1400
+ border-radius: var(--w-radius-lg);
1401
+ font-size: var(--w-font-md);
1402
+ font-family: inherit;
1403
+ color: var(--unn-color-text-primary);
1404
+ outline: none;
1405
+ transition: border-color 0.15s;
1406
+ box-sizing: border-box;
1407
+ }
1408
+ .capture-form-input:focus,
1409
+ .capture-form-textarea:focus {
1410
+ border-color: var(--unn-color-brand-primary);
1411
+ }
1412
+ .capture-form-textarea {
1413
+ min-height: 100px;
1414
+ resize: vertical;
1415
+ }
1416
+ .capture-form-snapshot-container {
1417
+ border: var(--w-border-width) solid var(--unn-color-border-default);
1418
+ border-radius: var(--w-radius-1);
1419
+ padding: 12px;
1420
+ background: var(--unn-color-bg-secondary);
1421
+ min-height: 80px;
1422
+ display: flex;
1423
+ flex-direction: column;
1424
+ align-items: center;
1425
+ justify-content: center;
1426
+ gap: 8px;
1427
+ transition: border 0.2s;
1428
+ }
1429
+ .capture-form-snapshot-container.picking {
1430
+ border: 2px dashed var(--unn-color-brand-primary);
1431
+ }
1432
+ .capture-form-snapshot-empty {
1433
+ color: var(--unn-color-text-subtle);
1434
+ font-size: var(--w-font-sm);
1435
+ }
1436
+ .capture-form-snapshot-preview {
1437
+ max-width: 100%;
1438
+ overflow: hidden;
1439
+ }
1440
+ .capture-form-pick-btn {
1441
+ padding: 3px 10px;
1442
+ background: var(--unn-color-bg-secondary);
1443
+ border: var(--w-border-width) solid var(--unn-color-border-default);
1444
+ border-radius: var(--w-radius-lg);
1445
+ font-size: var(--w-font-sm);
1446
+ font-weight: var(--w-weight-medium);
1447
+ color: var(--unn-color-text-secondary);
1448
+ cursor: pointer;
1449
+ transition: all 0.15s;
1450
+ }
1451
+ .capture-form-pick-btn:hover {
1452
+ background: var(--unn-color-bg-hover);
1453
+ color: var(--unn-color-text-primary);
1454
+ }
1455
+ .capture-form-pick-btn:active {
1456
+ background: var(--unn-color-bg-subtle);
1457
+ }
1458
+ .capture-form-cancel-capture-btn {
1459
+ padding: 3px 10px;
1460
+ background: var(--unn-color-bg-tertiary);
1461
+ border: var(--w-border-width) solid var(--unn-color-border-default);
1462
+ border-radius: var(--w-radius-lg);
1463
+ font-size: var(--w-font-sm);
1464
+ font-weight: var(--w-weight-medium);
1465
+ color: var(--unn-color-text-muted);
1466
+ cursor: pointer;
1467
+ transition: all 0.15s;
1468
+ }
1469
+ .capture-form-cancel-capture-btn:hover {
1470
+ background: var(--unn-color-border-default);
1471
+ }
1472
+ .capture-form-actions {
1473
+ display: flex;
1474
+ gap: 6px;
1475
+ justify-content: flex-end;
1476
+ margin-top: 6px;
1477
+ }
1478
+ .capture-form-save-btn,
1479
+ .capture-form-cancel-btn {
1480
+ font-size: var(--w-font-xs);
1481
+ font-weight: 500;
1482
+ border: none;
1483
+ border-radius: var(--w-radius-sm);
1484
+ cursor: pointer;
1485
+ padding: 5px 12px;
1486
+ }
1487
+ .capture-form-save-btn {
1488
+ background: var(--unn-color-brand-primary);
1489
+ color: #fff;
1490
+ }
1491
+ .capture-form-save-btn:hover:not(:disabled) {
1492
+ opacity: 0.88;
1493
+ }
1494
+ .capture-form-save-btn:disabled {
1495
+ opacity: 0.5;
1496
+ cursor: default;
1497
+ }
1498
+ .capture-form-cancel-btn {
1499
+ background: var(--unn-color-bg-tertiary);
1500
+ color: var(--unn-color-text-muted);
1501
+ }
1502
+ .capture-form-cancel-btn:hover {
1503
+ background: var(--unn-color-border-default);
1504
+ }
1505
+ .capture-form-watch-row {
1506
+ display: flex;
1507
+ align-items: center;
1508
+ gap: 8px;
1509
+ margin-top: 2px;
1510
+ }
1511
+ .capture-form-watch-checkbox {
1512
+ width: 16px;
1513
+ height: 16px;
1514
+ cursor: pointer;
1515
+ accent-color: var(--unn-color-brand-primary);
1516
+ flex-shrink: 0;
1517
+ }
1518
+ .capture-form-watch-label {
1519
+ font-size: var(--w-font-sm);
1520
+ color: var(--unn-color-text-body);
1521
+ cursor: pointer;
1522
+ user-select: none;
1523
+ }
1524
+ .capture-form-error {
1525
+ color: var(--unn-color-status-error);
1526
+ font-size: var(--w-font-sm);
1527
+ margin-top: -8px;
1528
+ display: none;
1529
+ }
1530
+ .capture-form-error.visible {
1531
+ display: block;
1532
+ }
1533
+ `)}
1534
+ </style>
1535
+ <h2 class="capture-form-header">${e.headerText||(e.showTitle?"New Product Memory":"Add Entry")}</h2>
1536
+ ${e.subheaderText?`<p class="capture-form-subheader">${e.subheaderText}</p>`:""}
1537
+
1538
+ ${e.showTitle?`
1539
+ <div class="capture-form-field">
1540
+ <label class="capture-form-label" for="capture-form-title">Title *</label>
1541
+ <input
1542
+ type="text"
1543
+ id="capture-form-title"
1544
+ class="capture-form-input"
1545
+ placeholder="e.g., User profile page redesign"
1546
+ data-testid="widget-capture-form-title"
1547
+ />
1548
+ </div>
1549
+ `:""}
1550
+
1551
+ <div class="capture-form-field">
1552
+ <label class="capture-form-label">Captured UI State</label>
1553
+ <div class="capture-form-snapshot-container" data-testid="widget-capture-form-snapshot">
1554
+ <div class="capture-form-snapshot-empty">No UI state captured yet</div>
1555
+ <button
1556
+ type="button"
1557
+ class="capture-form-pick-btn"
1558
+ data-testid="widget-capture-form-pick-btn"
1559
+ >
1560
+ Pick UI state
1561
+ </button>
1562
+ </div>
1563
+ </div>
1564
+
1565
+ <div class="capture-form-field">
1566
+ <label class="capture-form-label" for="capture-form-explanation">Explanation *</label>
1567
+ <textarea
1568
+ id="capture-form-explanation"
1569
+ class="capture-form-textarea"
1570
+ placeholder="Describe what this UI state means in your product..."
1571
+ data-testid="widget-capture-form-explanation"
1572
+ ></textarea>
1573
+ </div>
1574
+
1575
+ <div class="capture-form-watch-row">
1576
+ <input
1577
+ type="checkbox"
1578
+ id="capture-form-watch"
1579
+ class="capture-form-watch-checkbox"
1580
+ data-testid="widget-capture-form-watch-toggle"
1581
+ />
1582
+ <label class="capture-form-watch-label" for="capture-form-watch">
1583
+ Watch for changes
1584
+ </label>
1585
+ </div>
1586
+
1587
+ <div class="capture-form-error" data-testid="widget-capture-form-error"></div>
1588
+
1589
+ <div class="capture-form-actions">
1590
+ <button
1591
+ type="button"
1592
+ class="capture-form-cancel-btn"
1593
+ data-testid="widget-capture-form-cancel"
1594
+ >
1595
+ Cancel
1596
+ </button>
1597
+ <button
1598
+ type="button"
1599
+ class="capture-form-save-btn"
1600
+ data-testid="widget-capture-form-save"
1601
+ >
1602
+ Save
1603
+ </button>
1604
+ </div>
1605
+ `;t.innerHTML=n;let o=t.querySelector("#capture-form-title"),r=t.querySelector("#capture-form-explanation"),s=t.querySelector(".capture-form-snapshot-container"),a=t.querySelector('[data-testid="widget-capture-form-pick-btn"]'),c=t.querySelector('[data-testid="widget-capture-form-save"]'),d=t.querySelector('[data-testid="widget-capture-form-cancel"]'),l=t.querySelector('[data-testid="widget-capture-form-error"]'),p=t.querySelector('[data-testid="widget-capture-form-watch-toggle"]');return console.log("[unnoodle] Form elements found:",{titleInput:o,explanationTextarea:r,snapshotContainer:s,pickBtn:a,saveBtn:c,cancelBtn:d,errorEl:l}),a.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),i.onPickElement();}),d.addEventListener("click",()=>{console.log("[unnoodle] Cancel button clicked"),i.onCancel();}),c.addEventListener("click",()=>{console.log("[unnoodle] Save button clicked");let m=o?o.value.trim():"",v=r.value.trim();if(e.showTitle&&!m){l.textContent="Title is required",l.classList.add("visible");return}if(!v){l.textContent="Explanation is required",l.classList.add("visible");return}l.classList.remove("visible"),i.onSave(m,v,p.checked);}),{element:t,controller:{setSnapshot:m=>{if(m)s.className="capture-form-snapshot-container",s.innerHTML=`<div class="capture-form-snapshot-preview">${m.html}</div>`;else {s.className="capture-form-snapshot-container",s.innerHTML=`
1606
+ <div class="capture-form-snapshot-empty">No UI state captured yet</div>
1607
+ <button
1608
+ type="button"
1609
+ class="capture-form-pick-btn"
1610
+ data-testid="widget-capture-form-pick-btn"
1611
+ >
1612
+ Pick UI state
1613
+ </button>
1614
+ `;let v=s.querySelector('[data-testid="widget-capture-form-pick-btn"]');v&&v.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),i.onPickElement();});}},setPickingMode:m=>{if(m){s.className="capture-form-snapshot-container picking",s.innerHTML=`
1615
+ <div class="capture-form-snapshot-empty">UI state capture in progress...</div>
1616
+ <button
1617
+ type="button"
1618
+ class="capture-form-cancel-capture-btn"
1619
+ data-testid="widget-capture-form-cancel-capture-btn"
1620
+ >
1621
+ Cancel capture
1622
+ </button>
1623
+ `;let v=s.querySelector('[data-testid="widget-capture-form-cancel-capture-btn"]');v&&v.addEventListener("click",()=>{console.log("[unnoodle] Cancel capture clicked"),i.onCancelCapture();});}else {s.className="capture-form-snapshot-container",s.innerHTML=`
1624
+ <div class="capture-form-snapshot-empty">No UI state captured yet</div>
1625
+ <button
1626
+ type="button"
1627
+ class="capture-form-pick-btn"
1628
+ data-testid="widget-capture-form-pick-btn"
1629
+ >
1630
+ Pick UI state
1631
+ </button>
1632
+ `;let v=s.querySelector('[data-testid="widget-capture-form-pick-btn"]');v&&v.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),i.onPickElement();});}},setLoading:m=>{c.disabled=m,c.textContent=m?"Saving\u2026":"Save",a.disabled=m,d.disabled=m,o&&(o.disabled=m),r.disabled=m;},setError:m=>{l.textContent=m,l.classList.add("visible");},clear:()=>{o&&(o.value=""),r.value="",s.className="capture-form-snapshot-container",s.innerHTML=`
1633
+ <div class="capture-form-snapshot-empty">No UI state captured yet</div>
1634
+ <button
1635
+ type="button"
1636
+ class="capture-form-pick-btn"
1637
+ data-testid="widget-capture-form-pick-btn"
1638
+ >
1639
+ Pick UI state
1640
+ </button>
1641
+ `;let m=s.querySelector('[data-testid="widget-capture-form-pick-btn"]');m&&m.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),i.onPickElement();}),l.classList.remove("visible"),l.textContent="";}}}}var pe="data-unnoodle-state-banner";function So(i,e,t,n){Re(i);let o=document.createElement("div");o.setAttribute(pe,"true"),o.setAttribute("data-testid","state-change-banner"),o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),o.innerHTML=`
1642
+ <style>
1643
+ ${re(`
1644
+ [${pe}] {
1645
+ display: flex;
1646
+ flex-direction: column;
1647
+ gap: 8px;
1648
+ padding: 10px 12px;
1649
+ background: var(--unn-color-bg-secondary, #f0f4ff);
1650
+ border-bottom: 2px solid var(--unn-color-brand-primary, #4f46e5);
1651
+ font-size: 13px;
1652
+ flex-shrink: 0;
1653
+ }
1654
+ [${pe}] .scb-heading {
1655
+ font-weight: 600;
1656
+ color: var(--unn-color-text-primary, #111);
1657
+ display: flex;
1658
+ align-items: center;
1659
+ gap: 6px;
1660
+ }
1661
+ [${pe}] .scb-meaning {
1662
+ color: var(--unn-color-text-body, #444);
1663
+ font-size: 12px;
1664
+ }
1665
+ [${pe}] .scb-actions {
1666
+ display: flex;
1667
+ gap: 6px;
1668
+ align-items: center;
1669
+ }
1670
+ [${pe}] .scb-save-btn {
1671
+ padding: 4px 12px;
1672
+ background: var(--unn-color-brand-primary, #4f46e5);
1673
+ color: #fff;
1674
+ border: none;
1675
+ border-radius: 4px;
1676
+ font-size: 12px;
1677
+ font-weight: 500;
1678
+ cursor: pointer;
1679
+ }
1680
+ [${pe}] .scb-save-btn:hover {
1681
+ opacity: 0.88;
1682
+ }
1683
+ [${pe}] .scb-dismiss-btn {
1684
+ padding: 4px 10px;
1685
+ background: transparent;
1686
+ color: var(--unn-color-text-muted, #888);
1687
+ border: 1px solid var(--unn-color-border-subtle, #ddd);
1688
+ border-radius: 4px;
1689
+ font-size: 12px;
1690
+ cursor: pointer;
1691
+ }
1692
+ [${pe}] .scb-dismiss-btn:hover {
1693
+ background: var(--unn-color-bg-hover, #e9e9e9);
1694
+ }
1695
+ `)}
1696
+ </style>
1697
+ <div class="scb-heading">
1698
+ <span aria-hidden="true">\u{1F50D}</span>
1699
+ New state detected \u2014 Save it?
1700
+ </div>
1701
+ ${e?`<div class="scb-meaning" data-testid="state-change-banner-meaning">${e}</div>`:""}
1702
+ <div class="scb-actions">
1703
+ <button type="button" class="scb-save-btn" data-testid="state-change-banner-save">
1704
+ Save new state
1705
+ </button>
1706
+ <button type="button" class="scb-dismiss-btn" data-testid="state-change-banner-dismiss">
1707
+ Dismiss
1708
+ </button>
1709
+ </div>
1710
+ `;let r=o.querySelector('[data-testid="state-change-banner-save"]'),s=o.querySelector('[data-testid="state-change-banner-dismiss"]');r.addEventListener("click",()=>{Re(i),t();}),s.addEventListener("click",()=>{Re(i),n();}),i.prepend(o);}function Re(i){let e=i.querySelector(`[${pe}]`);e==null||e.remove();}function Te(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var pt=class{constructor(e,t={}){this.container=e,this.callbacks=t;}showAllTerms(e,t){console.log("DEBUG: ListViewManager.showAllTerms called with",t.length,"terms");let n=`
1711
+ <div class="list-view" data-testid="widget-terms-list-view">
1712
+ <div class="list-header">
1713
+ <button class="list-back-btn" data-testid="widget-back-to-home">
1714
+ \u2190 Back
1715
+ </button>
1716
+ <div class="list-title">
1717
+ <h2>Vocabulary</h2>
1718
+ <span class="list-count">${t.length} terms</span>
1719
+ </div>
1720
+ <button class="list-add-btn" data-testid="widget-add-term">
1721
+ + Add
1722
+ </button>
1723
+ </div>
1724
+ <div class="list-body">
1725
+ ${this.renderTermsList(t)}
1726
+ </div>
1727
+ </div>
1728
+ `;this.container.innerHTML=n,this.attachTermsListeners();}showAllClarifications(e,t){console.log("DEBUG: ListViewManager.showAllClarifications called with",e.length,"discussions");let n=`
1729
+ <div class="list-view" data-testid="widget-clarifications-list-view">
1730
+ <div class="list-header">
1731
+ <button class="list-back-btn" data-testid="widget-back-to-home">
1732
+ \u2190 Back
1733
+ </button>
1734
+ <div class="list-title">
1735
+ <h2>Clarifications</h2>
1736
+ <span class="list-count">${e.length} questions</span>
1737
+ </div>
1738
+ <button class="list-add-btn" data-testid="widget-ask-question">
1739
+ + Ask
1740
+ </button>
1741
+ </div>
1742
+ <div class="list-body">
1743
+ ${this.renderClarificationsList(e)}
1744
+ </div>
1745
+ </div>
1746
+ `;this.container.innerHTML=n,this.attachClarificationsListeners();}showAllMemories(e,t){console.log("DEBUG: ListViewManager.showAllMemories called with",e.length,"memories");let n=`
1747
+ <div class="list-view" data-testid="widget-memories-list-view">
1748
+ <div class="list-header">
1749
+ <button class="list-back-btn" data-testid="widget-back-to-home">
1750
+ \u2190 Back
1751
+ </button>
1752
+ <div class="list-title">
1753
+ <h2>Product Memories</h2>
1754
+ <span class="list-count">${e.length} memories</span>
1755
+ </div>
1756
+ <button class="list-add-btn" data-testid="widget-new-memory">
1757
+ + New
1758
+ </button>
1759
+ </div>
1760
+ <div class="list-body">
1761
+ ${this.renderMemoriesList(e)}
1762
+ </div>
1763
+ </div>
1764
+ `;this.container.innerHTML=n,this.attachMemoriesListeners();}renderTermsList(e){return e.length===0?`
1765
+ <div class="list-empty">
1766
+ <div class="list-empty-title">No vocabulary terms yet.</div>
1767
+ <div class="list-empty-text">Start building your shared vocabulary.</div>
1768
+ </div>
1769
+ `:e.map(t=>`
1770
+ <div class="list-item" data-testid="widget-term-list-item" data-term-id="${t.id}">
1771
+ <div class="list-item-main">
1772
+ <div class="list-item-title">${Te(t.term)}</div>
1773
+ <div class="list-item-subtitle">${Te(t.definition)}</div>
1774
+ ${t.abbreviation?`<div class="list-item-tag">${Te(t.abbreviation)}</div>`:""}
1775
+ </div>
1776
+ <div class="list-item-action">
1777
+ <svg viewBox="0 0 24 24" width="12" height="12">
1778
+ <polyline points="9 18 15 12 9 6"></polyline>
1779
+ </svg>
1780
+ </div>
1781
+ </div>
1782
+ `).join("")}renderClarificationsList(e){return e.length===0?`
1783
+ <div class="list-empty">
1784
+ <div class="list-empty-title">No questions yet.</div>
1785
+ <div class="list-empty-text">Ask if something about this interface is unclear.</div>
1786
+ </div>
1787
+ `:e.map(t=>`
1788
+ <div class="list-item" data-testid="widget-clarification-list-item" data-discussion-id="${t.id}">
1789
+ <div class="list-item-main">
1790
+ <div class="list-item-title">${Te(t.body)}</div>
1791
+ <div class="list-item-subtitle">
1792
+ ${Te(t.authorName||"Unknown")} \xB7
1793
+ ${new Date(t.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}
1794
+ ${t.replies&&t.replies.length>0?` \xB7 ${t.replies.length} replies`:""}
1795
+ </div>
1796
+ </div>
1797
+ <div class="list-item-action">
1798
+ <svg viewBox="0 0 24 24" width="12" height="12">
1799
+ <polyline points="9 18 15 12 9 6"></polyline>
1800
+ </svg>
1801
+ </div>
1802
+ </div>
1803
+ `).join("")}renderMemoriesList(e){return e.length===0?`
1804
+ <div class="list-empty">
1805
+ <div class="list-empty-title">No captures yet.</div>
1806
+ <div class="list-empty-text">Capture elements so teammates can understand the interface faster.</div>
1807
+ </div>
1808
+ `:e.map(t=>`
1809
+ <div class="list-item" data-testid="widget-memory-list-item" data-memory-id="${t.id}">
1810
+ <div class="list-item-main">
1811
+ <div class="list-item-title">${Te(t.title)}</div>
1812
+ <div class="list-item-subtitle">
1813
+ ${t.entryCount} entries \xB7
1814
+ ${new Date(t.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}
1815
+ </div>
1816
+ </div>
1817
+ <div class="list-item-action">
1818
+ <svg viewBox="0 0 24 24" width="12" height="12">
1819
+ <polyline points="9 18 15 12 9 6"></polyline>
1820
+ </svg>
1821
+ </div>
1822
+ </div>
1823
+ `).join("")}attachTermsListeners(){let e=this.container.querySelector('[data-testid="widget-back-to-home"]');e==null||e.addEventListener("click",()=>{var o,r;return (r=(o=this.callbacks).onBackToHome)==null?void 0:r.call(o)});let t=this.container.querySelector('[data-testid="widget-add-term"]');t==null||t.addEventListener("click",()=>{var o,r;return (r=(o=this.callbacks).onAddTerm)==null?void 0:r.call(o)}),this.container.querySelectorAll('[data-testid="widget-term-list-item"]').forEach(o=>{o.addEventListener("click",()=>{var s,a;let r=parseInt(o.getAttribute("data-term-id")||"0",10);(a=(s=this.callbacks).onTermClick)==null||a.call(s,r);});});}attachClarificationsListeners(){let e=this.container.querySelector('[data-testid="widget-back-to-home"]');e==null||e.addEventListener("click",()=>{var o,r;return (r=(o=this.callbacks).onBackToHome)==null?void 0:r.call(o)});let t=this.container.querySelector('[data-testid="widget-add-clarification"]');t==null||t.addEventListener("click",()=>{var o,r,s,a;(t==null?void 0:t.getAttribute("data-requires-login"))==="true"?(r=(o=this.callbacks).onRequireLogin)==null||r.call(o):(a=(s=this.callbacks).onAddDiscussion)==null||a.call(s);}),this.container.querySelectorAll('[data-testid="widget-clarification-list-item"]').forEach(o=>{o.addEventListener("click",()=>{var s,a;let r=parseInt(o.getAttribute("data-discussion-id")||"0",10);(a=(s=this.callbacks).onDiscussionClick)==null||a.call(s,r);});});}attachMemoriesListeners(){let e=this.container.querySelector('[data-testid="widget-back-to-home"]');e==null||e.addEventListener("click",()=>{var o,r;return (r=(o=this.callbacks).onBackToHome)==null?void 0:r.call(o)});let t=this.container.querySelector('[data-testid="widget-add-memory"]');t==null||t.addEventListener("click",()=>{var o,r,s,a;(t==null?void 0:t.getAttribute("data-requires-login"))==="true"?(r=(o=this.callbacks).onRequireLogin)==null||r.call(o):(a=(s=this.callbacks).onAddMemory)==null||a.call(s);}),this.container.querySelectorAll('[data-testid="widget-memory-list-item"]').forEach(o=>{o.addEventListener("click",()=>{var s,a;let r=parseInt(o.getAttribute("data-memory-id")||"0",10);(a=(s=this.callbacks).onMemoryClick)==null||a.call(s,r);});});}};function Ao(){return `
1824
+ .list-view {
1825
+ height: 100%;
1826
+ display: flex;
1827
+ flex-direction: column;
1828
+ }
1829
+
1830
+ .list-header {
1831
+ display: flex;
1832
+ align-items: center;
1833
+ gap: var(--w-space-2, 8px);
1834
+ padding: var(--w-space-h-md) var(--w-space-h-md) var(--w-space-v-md);
1835
+ border-bottom: 1px solid var(--unn-color-border-subtle, #e2e8f0);
1836
+ background: var(--unn-color-surface, #ffffff);
1837
+ }
1838
+
1839
+ .list-back-btn, .list-add-btn {
1840
+ background: none;
1841
+ border: none;
1842
+ cursor: pointer;
1843
+ font-size: var(--w-font-base);
1844
+ color: var(--unn-color-brand-primary);
1845
+ font-weight: var(--w-weight-medium);
1846
+ display: flex;
1847
+ align-items: center;
1848
+ gap: 4px;
1849
+ padding: 4px 0;
1850
+ transition: all 0.15s ease;
1851
+ }
1852
+
1853
+ .list-back-btn:hover, .list-add-btn:hover {
1854
+ text-decoration: underline;
1855
+ }
1856
+
1857
+ .list-title {
1858
+ flex: 1;
1859
+ display: flex;
1860
+ flex-direction: column;
1861
+ gap: var(--w-space-1, 4px);
1862
+ }
1863
+
1864
+ .list-title h2 {
1865
+ margin: 0;
1866
+ font-size: var(--w-font-lg);
1867
+ font-weight: var(--w-weight-semi);
1868
+ color: var(--unn-color-text, #111827);
1869
+ }
1870
+
1871
+ .list-count {
1872
+ font-size: var(--w-font-sm);
1873
+ color: var(--unn-color-text-secondary, #6b7280);
1874
+ }
1875
+
1876
+ .list-body {
1877
+ flex: 1;
1878
+ overflow-y: auto;
1879
+ padding: var(--w-space-v-sm);
1880
+ }
1881
+
1882
+ .list-item {
1883
+ display: flex;
1884
+ align-items: center;
1885
+ gap: var(--w-space-3, 12px);
1886
+ padding: var(--w-space-v-sm);
1887
+ border-radius: var(--w-radius-1);
1888
+ cursor: pointer;
1889
+ transition: background-color 0.15s ease;
1890
+ border: 1px solid transparent;
1891
+ }
1892
+
1893
+ .list-item:hover {
1894
+ background: var(--unn-color-bg-secondary);
1895
+ }
1896
+
1897
+ .list-item:hover .list-item-title {
1898
+ color: var(--unn-color-brand-primary);
1899
+ }
1900
+
1901
+ .list-item-main {
1902
+ flex: 1;
1903
+ display: flex;
1904
+ flex-direction: column;
1905
+ gap: var(--w-space-1, 4px);
1906
+ min-width: 0;
1907
+ }
1908
+
1909
+ .list-item-title {
1910
+ font-size: var(--w-font-base);
1911
+ font-weight: var(--w-weight-medium);
1912
+ color: var(--unn-color-text, #111827);
1913
+ word-break: break-word;
1914
+ line-height: 1.4;
1915
+ }
1916
+
1917
+ .list-item-subtitle {
1918
+ font-size: var(--w-font-sm);
1919
+ color: var(--unn-color-text-secondary, #6b7280);
1920
+ line-height: 1.4;
1921
+ }
1922
+
1923
+ .list-item-tag {
1924
+ font-size: var(--w-font-xs);
1925
+ color: var(--unn-color-accent, #3b82f6);
1926
+ background: var(--unn-color-accent-subtle, #dbeafe);
1927
+ padding: 2px 6px;
1928
+ border-radius: var(--w-radius-sm, 4px);
1929
+ align-self: flex-start;
1930
+ margin-top: 2px;
1931
+ }
1932
+
1933
+ .list-item-action {
1934
+ flex-shrink: 0;
1935
+ color: var(--unn-color-text-subtle);
1936
+ opacity: 0.35;
1937
+ transition: opacity 0.12s, color 0.12s;
1938
+ }
1939
+
1940
+ .list-item-action svg {
1941
+ stroke: currentColor;
1942
+ fill: none;
1943
+ stroke-width: 2.5;
1944
+ }
1945
+
1946
+ .list-item:hover .list-item-action {
1947
+ opacity: 1;
1948
+ color: var(--unn-color-brand-primary);
1949
+ }
1950
+
1951
+ .list-empty {
1952
+ display: flex;
1953
+ flex-direction: column;
1954
+ align-items: center;
1955
+ justify-content: center;
1956
+ text-align: center;
1957
+ padding: var(--w-space-v-xl) var(--w-space-4);
1958
+ height: 200px;
1959
+ }
1960
+
1961
+ .list-empty-title {
1962
+ font-size: var(--w-font-lg);
1963
+ font-weight: var(--w-weight-medium);
1964
+ color: var(--unn-color-text, #111827);
1965
+ margin-bottom: var(--w-space-2, 8px);
1966
+ }
1967
+
1968
+ .list-empty-text {
1969
+ font-size: var(--w-font-base);
1970
+ color: var(--unn-color-text-secondary, #6b7280);
1971
+ line-height: 1.5;
1972
+ }
1973
+ `}var Ho=320,Po=800,Ro="unnoodle_panel_width",Do="unnoodle_panel_side";function Bo(i,e){let{host:t,shadow:n,panelShell:o,popoutBtn:r,dockBtn:s,closeBtn:a,pinLeftBtn:c,pinRightBtn:d,halfBtn:l,halfExitBtn:p,fullscreenBtn:h,fullscreenExitBtn:m,resizeHandle:v}=i,f=400;try{let w=localStorage.getItem(Ro);if(w){let q=Number(w);Number.isFinite(q)&&q>=Ho&&(f=q);}}catch(w){}o.style.width=`${f}px`;let y="right";try{let w=localStorage.getItem(Do);(w==="left"||w==="right")&&(y=w);}catch(w){}let A=null,L=false,N=null,U=false,F=false,Q=false,_=false,C=0,$=0;function Y(){if(L)return;o.classList.add("open"),t.setAttribute("data-panel-open","true");let q=document.getElementById("unnoodle-rail-host")?34:0;if(q&&(o.style.right=`${q}px`),!F){let se=y==="right"?"margin-right":"margin-left";document.body.style.transition=`${se} 0.28s cubic-bezier(0.4,0,0.2,1)`,y==="right"?(document.body.style.marginRight=`${f+q}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${f}px`,document.body.style.marginRight=q?`${q}px`:"");}let ee=document.getElementById("unnoodle-btn-host");ee&&(ee.style.display="none");}function H(){if(L)return;U&&(U=false,o.classList.remove("half-screen"),l.hidden=false,p.hidden=true),F&&(F=false,o.classList.remove("fullscreen"),h.hidden=false,m.hidden=true,Q=false),o.classList.remove("open"),t.removeAttribute("data-panel-open"),o.style.right="";let q=document.getElementById("unnoodle-rail-host")?34:0;document.body.style.marginRight=q?`${q}px`:"",document.body.style.marginLeft="";let ee=document.getElementById("unnoodle-btn-host");ee&&ee.style.removeProperty("display");}function P(){var be,De;if(L){A&&!A.closed&&A.focus();return}let w=window.open("about:blank","unnoodle_panel","width=440,height=720,resizable=yes,scrollbars=no,status=no,location=no,toolbar=no,menubar=no");if(!w){(be=e.onToast)==null||be.call(e,"Allow popups for this site to use the detached panel.");return}let q=e.shadowTokens?e.shadowTokens.replace(/:host\b/g,":root"):"";w.document.write('<!DOCTYPE html><html><head><meta charset="utf-8"><title>Unnoodle</title><style>*{margin:0;padding:0;box-sizing:border-box;}html,body{height:100%;overflow:hidden;}</style>'+(q?`<style>${q}</style>`:"")+'</head><body style="height:100%"></body></html>'),w.document.close();let ee=document.createElement("style");ee.setAttribute("data-unnoodle-popout","true"),ee.textContent=re(bo),n.appendChild(ee);let se=w.document.adoptNode(t);se.style.cssText="display:block;width:100%;height:100%;",w.document.body.appendChild(se),A=w,L=true,o.classList.add("open"),r.hidden=true,s.hidden=false,a.hidden=true,document.body.style.marginRight="",document.body.style.marginLeft="";let ne=document.getElementById("unnoodle-btn-host");ne&&(ne.style.display="none"),(De=e.onPopout)==null||De.call(e),w.addEventListener("beforeunload",()=>{O(true);}),N=setInterval(()=>{w.closed&&(clearInterval(N),N=null,O(true));},500);}function O(w=false){var ne;if(!L)return;L=false,N&&(clearInterval(N),N=null);let q=document.adoptNode(t);q.style.cssText="",document.body.appendChild(q);let ee=n.querySelector("[data-unnoodle-popout]");ee&&ee.remove(),o.classList.remove("open"),t.removeAttribute("data-panel-open"),r.hidden=false,s.hidden=true,a.hidden=false;let se=document.getElementById("unnoodle-btn-host");se&&se.style.removeProperty("display"),!w&&A&&!A.closed&&A.close(),A=null,(ne=e.onReattach)==null||ne.call(e);}function I(w){y=w;try{localStorage.setItem(Do,w);}catch(q){}w==="left"?(o.classList.add("left-side"),c.classList.add("active"),d.classList.remove("active")):(o.classList.remove("left-side"),d.classList.add("active"),c.classList.remove("active")),o.classList.contains("open")&&!L&&!F&&(document.body.style.marginRight=w==="right"?`${f}px`:"",document.body.style.marginLeft=w==="left"?`${f}px`:"");}y==="left"&&I("left");function X(){if(U=!U,U){if(F&&(F=false,o.classList.remove("fullscreen"),h.hidden=false,m.hidden=true,Q=false),o.classList.add("half-screen"),l.hidden=true,p.hidden=false,o.classList.contains("open")&&!L){let w=document.getElementById("unnoodle-rail-host")?34:0,q=Math.round(window.innerWidth*.5);y==="right"?(document.body.style.marginRight=`${q+w}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${q}px`,document.body.style.marginRight=w?`${w}px`:"");}}else if(o.classList.remove("half-screen"),l.hidden=false,p.hidden=true,o.classList.contains("open")&&!L){let w=document.getElementById("unnoodle-rail-host")?34:0;y==="right"?(document.body.style.marginRight=`${f+w}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${f}px`,document.body.style.marginRight=w?`${w}px`:"");}}function j(){if(F=!F,F)U&&(U=false,o.classList.remove("half-screen"),l.hidden=false,p.hidden=true),Q=o.classList.contains("open")&&!L,o.classList.add("fullscreen"),h.hidden=true,m.hidden=false,document.body.style.marginRight="",document.body.style.marginLeft="";else {if(o.classList.remove("fullscreen"),h.hidden=false,m.hidden=true,Q&&o.classList.contains("open")){let w=document.getElementById("unnoodle-rail-host")?34:0;y==="right"?(document.body.style.marginRight=`${f+w}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${f}px`,document.body.style.marginRight=w?`${w}px`:"");}Q=false;}}function K(w){if(!_||L)return;let q=window.innerWidth>0?Math.floor(window.innerWidth*.6):Po,ee=Math.min(Po,q),se=y==="right"?C-w.clientX:w.clientX-C,ne=Math.max(Ho,Math.min(ee,$+se));if(f=ne,o.style.width=`${ne}px`,o.classList.contains("open")&&!F){let be=document.getElementById("unnoodle-rail-host")?34:0;y==="right"?(document.body.style.marginRight=`${ne+be}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${ne}px`,document.body.style.marginRight=be?`${be}px`:"");}}function b(){if(_){_=false,document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",b);try{localStorage.setItem(Ro,String(f));}catch(w){}}}function ae(){document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",b),L&&O(false),document.body.style.marginRight="",document.body.style.marginLeft="";let w=document.getElementById("unnoodle-btn-host");w&&w.style.removeProperty("display");}let ve=()=>{var w;H(),(w=e.onClose)==null||w.call(e);};return a.addEventListener("click",ve),s.addEventListener("click",()=>O(false)),r.addEventListener("click",()=>P()),c.addEventListener("click",()=>I("left")),d.addEventListener("click",()=>I("right")),l.addEventListener("click",()=>X()),p.addEventListener("click",()=>X()),h.addEventListener("click",()=>j()),m.addEventListener("click",()=>j()),v.addEventListener("mousedown",w=>{L||(_=true,C=w.clientX,$=f,document.addEventListener("mousemove",K),document.addEventListener("mouseup",b),w.preventDefault());}),{show:Y,hide:H,popout:P,cleanup:ae,isPopout:()=>L,currentWidth:()=>f}}var fe=5;function Io(i,e,t,n,o){var F,Q,_,C,$,Y;let{onTermClick:r,onRequireLogin:s,onAddConcept:a,onOpenSearch:c,onCaptureUiState:d,onShowAllConcepts:l}=n;e&&(e.textContent=t.context.name);let p=t.glossary;function h(H){var O,I;return new RegExp(`\\b${H.term.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i").test((I=(O=document.body)==null?void 0:O.innerText)!=null?I:"")}let m=H=>H.map(P=>`
1974
+ <div class="concept-row" data-testid="widget-term-card" data-term-id="${P.id}">
1975
+ <span class="concept-name">${B(P.term)}</span>
1976
+ ${P.abbreviation?`<span class="concept-abbr">${B(P.abbreviation)}</span>`:""}
1977
+ <span class="concept-chevron"><svg viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"/></svg></span>
1978
+ </div>`).join("");function v(H,P){let O=H.filter(h),I=H.filter(ne=>!h(ne)),X=O.length>0&&I.length>0;if(H.length===0)return P?'<div class="section-empty" data-testid="widget-glossary-empty"><div class="section-empty-title">No matching concepts.</div></div>':'<div class="section-empty"><div class="section-empty-title">No product concepts defined yet.</div><div class="section-empty-text">Start building shared vocabulary for this context.</div><button class="section-empty-action" data-testid="widget-add-concept-empty">Add Concept</button></div>';let j=O.length>0?`<div class="concept-subheading">Used on this page</div>${m(O)}`:"",K=X?'<div class="concept-subheading">Other concepts in this context</div>':"";if(P)return j+K+m(I);let b=O.slice(0,fe),ae=Math.max(fe-b.length,0),ve=I.slice(0,ae),w=I.slice(ae),q=O.slice(fe),ee=H.length>fe?`<div class="home-concepts-hidden" style="display:none">${m(q)}${m(w)}</div><a href="#" class="home-show-more home-show-more-concepts" data-testid="widget-show-all-concepts">Show all ${H.length} vocabulary \u2192</a>`:"";return (b.length>0?`<div class="concept-subheading">Used on this page</div>${m(b)}`:"")+K+m(ve)+ee}let f=v(p,false);i.innerHTML=`
1979
+ <div class="home-view" data-testid="widget-home-view">
1980
+ <div class="context-strip" data-testid="widget-context-strip" style="display:none !important">
1981
+ <!-- idle state -->
1982
+ <div class="strip-idle">
1983
+ <button class="strip-btn" data-testid="widget-add-ui-meaning-btn" aria-label="Add UI Meaning">
1984
+ <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12 1v4M12 19v4M4.22 4.22l2.83 2.83M16.95 16.95l2.83 2.83M1 12h4M19 12h4M4.22 19.78l2.83-2.83M16.95 7.05l2.83-2.83"/></svg>
1985
+ Add UI Meaning
1986
+ </button>
1987
+ </div>
1988
+ <!-- pick-mode state -->
1989
+ <div class="pick-mode-prompt" data-testid="widget-pick-mode-prompt">
1990
+ <span class="pick-prompt-text">Click any element on the page&hellip;</span>
1991
+ <button class="strip-cancel-btn" data-testid="widget-context-strip-cancel-btn" aria-label="Cancel pick mode">Cancel</button>
1992
+ </div>
1993
+ <!-- capture-describe state -->
1994
+ <div class="capture-describe-view" data-testid="widget-capture-describe-view">
1995
+ <div class="capture-snapshot-preview" data-testid="widget-capture-snapshot-preview"></div>
1996
+ <textarea class="capture-description-input" data-testid="widget-capture-description-input"
1997
+ placeholder="Describe what this UI state means\u2026" rows="3" maxlength="2000"></textarea>
1998
+ <p class="capture-error" style="display:none"></p>
1999
+ <div class="capture-actions">
2000
+ <button class="strip-cancel-btn" data-testid="widget-capture-pick-again-btn">Pick Again</button>
2001
+ <button class="capture-save-btn" data-testid="widget-capture-save-btn">Save</button>
2002
+ </div>
2003
+ </div>
2004
+ </div>
2005
+ <div class="home-search-bar" data-testid="widget-home-search-bar">
2006
+ <input class="home-search-input" id="unn-home-search" type="search"
2007
+ placeholder="Search\u2026" autocomplete="off" aria-label="Search"
2008
+ data-testid="widget-home-search-input" />
2009
+ </div>
2010
+ <div class="home-sections">
2011
+ <div class="home-section" data-section="memory">
2012
+ <div class="home-section-header">
2013
+ <span class="home-section-title"><span class="home-section-dot"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="currentColor" viewBox="0 0 256 256"><path d="M248,124a56.11,56.11,0,0,0-32-50.61V72a48,48,0,0,0-88-26.49A48,48,0,0,0,40,72v1.39a56,56,0,0,0,0,101.2V176a48,48,0,0,0,88,26.49A48,48,0,0,0,216,176v-1.41A56.09,56.09,0,0,0,248,124ZM88,208a32,32,0,0,1-31.81-28.56A55.87,55.87,0,0,0,64,180h8a8,8,0,0,0,0-16H64A40,40,0,0,1,50.67,86.27,8,8,0,0,0,56,78.73V72a32,32,0,0,1,64,0v68.26A47.8,47.8,0,0,0,88,128a8,8,0,0,0,0,16,32,32,0,0,1,0,64Zm104-44h-8a8,8,0,0,0,0,16h8a55.87,55.87,0,0,0,7.81-.56A32,32,0,1,1,168,144a8,8,0,0,0,0-16,47.8,47.8,0,0,0-32,12.26V72a32,32,0,0,1,64,0v6.73a8,8,0,0,0,5.33,7.54A40,40,0,0,1,192,164Zm16-52a8,8,0,0,1-8,8h-4a36,36,0,0,1-36-36V80a8,8,0,0,1,16,0v4a20,20,0,0,0,20,20h4A8,8,0,0,1,208,112ZM60,120H56a8,8,0,0,1,0-16h4A20,20,0,0,0,80,84V80a8,8,0,0,1,16,0v4A36,36,0,0,1,60,120Z"></path></svg></span>PRODUCT MEMORY</span>
2014
+ <button class="home-section-add" data-testid="widget-add-ui-meaning">+</button>
2015
+ </div>
2016
+ <div class="home-section-helper">Explain what elements on this screen do.</div>
2017
+ <div class="section-empty">
2018
+ <div class="section-empty-title">No UI explanations yet.</div>
2019
+ <div class="section-empty-text">Explain what elements on this screen do so teammates can understand the interface faster.</div>
2020
+ <button class="section-empty-action" data-testid="widget-add-ui-meaning-empty">Add UI Meaning</button>
2021
+ </div>
2022
+ </div>
2023
+ <div class="home-section" data-section="concepts">
2024
+ <div class="home-section-header">
2025
+ <span class="home-section-title"><span class="home-section-dot"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="currentColor" viewBox="0 0 256 256"><path d="M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64ZM160,88h40a8,8,0,0,1,0,16H160a8,8,0,0,1,0-16Zm48,40a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,128Zm0,32a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,160Z"></path></svg></span>PRODUCT VOCABULARY</span>
2026
+ <button class="home-section-add" data-testid="widget-add-concept">+</button>
2027
+ </div>
2028
+ <div class="home-section-helper">Key terms used in this product.</div>
2029
+ ${f}
2030
+ </div>
2031
+ <div class="home-section" data-section="clarifications" data-context-id="${t.context.id}">
2032
+ <div class="home-section-header">
2033
+ <span class="home-section-title"><span class="home-section-dot"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="currentColor" viewBox="0 0 256 256"><path d="M225.86,102.82c-3.77-3.94-7.67-8-9.14-11.57-1.36-3.27-1.44-8.69-1.52-13.94-.15-9.76-.31-20.82-8-28.51s-18.75-7.85-28.51-8c-5.25-.08-10.67-.16-13.94-1.52-3.56-1.47-7.63-5.37-11.57-9.14C146.28,23.51,138.44,16,128,16s-18.27,7.51-25.18,14.14c-3.94,3.77-8,7.67-11.57,9.14C88,40.64,82.56,40.72,77.31,40.8c-9.76.15-20.82.31-28.51,8S41,67.55,40.8,77.31c-.08,5.25-.16,10.67-1.52,13.94-1.47,3.56-5.37,7.63-9.14,11.57C23.51,109.72,16,117.56,16,128s7.51,18.27,14.14,25.18c3.77,3.94,7.67,8,9.14,11.57,1.36,3.27,1.44,8.69,1.52,13.94.15,9.76.31,20.82,8,28.51s18.75,7.85,28.51,8c5.25.08,10.67.16,13.94,1.52,3.56,1.47,7.63,5.37,11.57,9.14C109.72,232.49,117.56,240,128,240s18.27-7.51,25.18-14.14c3.94-3.77,8-7.67,11.57-9.14,3.27-1.36,8.69-1.44,13.94-1.52,9.76-.15,20.82-.31,28.51-8s7.85-18.75,8-28.51c.08-5.25.16-10.67,1.52-13.94,1.47-3.56,5.37-7.63,9.14-11.57C232.49,146.28,240,138.44,240,128S232.49,109.73,225.86,102.82Zm-11.55,39.29c-4.79,5-9.75,10.17-12.38,16.52-2.52,6.1-2.63,13.07-2.73,19.82-.1,7-.21,14.33-3.32,17.43s-10.39,3.22-17.43,3.32c-6.75.1-13.72.21-19.82,2.73-6.35,2.63-11.52,7.59-16.52,12.38S132,224,128,224s-9.15-4.92-14.11-9.69-10.17-9.75-16.52-12.38c-6.1-2.52-13.07-2.63-19.82-2.73-7-.1-14.33-.21-17.43-3.32s-3.22-10.39-3.32-17.43c-.1-6.75-.21-13.72-2.73-19.82-2.63-6.35-7.59-11.52-12.38-16.52S32,132,32,128s4.92-9.15,9.69-14.11,9.75-10.17,12.38-16.52c2.52-6.1,2.63-13.07,2.73-19.82.1-7,.21-14.33,3.32-17.43S70.51,56.9,77.55,56.8c6.75-.1,13.72-.21,19.82-2.73,6.35-2.63,11.52-7.59,16.52-12.38S124,32,128,32s9.15,4.92,14.11,9.69,10.17,9.75,16.52,12.38c6.1,2.52,13.07,2.63,19.82,2.73,7,.1,14.33.21,17.43,3.32s3.22,10.39,3.32,17.43c.1,6.75.21,13.72,2.73,19.82,2.63,6.35,7.59,11.52,12.38,16.52S224,124,224,128,219.08,137.15,214.31,142.11ZM140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180Zm28-72c0,17.38-13.76,31.93-32,35.28V144a8,8,0,0,1-16,0v-8a8,8,0,0,1,8-8c13.23,0,24-9,24-20s-10.77-20-24-20-24,9-24,20v4a8,8,0,0,1-16,0v-4c0-19.85,17.94-36,40-36S168,88.15,168,108Z"></path></svg></span>CLARIFICATIONS</span>
2034
+ <button class="home-section-add" data-testid="widget-ask-question-btn">+</button>
2035
+ </div>
2036
+ <div class="home-section-helper">Ask if something on this page is unclear. Owners will respond.</div>
2037
+ <div class="clarifications-body">
2038
+ <div class="skeleton-row"><div class="skeleton-line" style="width:70%;height:9px;border-radius:4px;"></div></div>
2039
+ </div>
2040
+ </div>
2041
+ </div>
2042
+ </div>
2043
+ `;let y=H=>{H.querySelectorAll("[data-testid='widget-term-card']").forEach(P=>{P.addEventListener("click",()=>{let O=Number(P.dataset.termId),I=p.find(X=>X.id===O);I&&(r==null||r(I));});});};y(i);function A(){let H=i.querySelector("[data-testid='widget-show-all-concepts']");H&&H.addEventListener("click",P=>{P.preventDefault(),l==null||l();});}A();function L(H){let P=i.querySelector("[data-section='concepts']");if(!P)return;let O=P.querySelector(".home-section-header");if(!O)return;let I=H.length>=2,X=H.toLowerCase(),j=I?p.filter(b=>{var ae;return b.term.toLowerCase().includes(X)||b.definition.toLowerCase().includes(X)||((ae=b.abbreviation)!=null?ae:"").toLowerCase().includes(X)}):p,K=document.createElement("div");for(K.innerHTML=v(j,I);P.lastChild&&P.lastChild!==O;)P.removeChild(P.lastChild);for(;K.firstChild;)P.appendChild(K.firstChild);y(P);}(F=i.querySelector("[data-testid='widget-search-toggle']"))==null||F.addEventListener("click",()=>{c==null||c();});let N=i.querySelector("[data-testid='widget-home-search-input']"),U;N==null||N.addEventListener("input",()=>{clearTimeout(U),U=setTimeout(()=>{L(N.value);},200);}),(Q=i.querySelector("[data-testid='widget-add-concept']"))==null||Q.addEventListener("click",()=>{if(!o){s==null||s();return}let H=i.querySelector("[data-section='concepts']");H&&mt(H,void 0,a);}),(_=i.querySelector("[data-testid='widget-add-concept-empty']"))==null||_.addEventListener("click",()=>{if(!o){s==null||s();return}let H=i.querySelector("[data-section='concepts']");H&&mt(H,void 0,a);}),(C=i.querySelector("[data-testid='widget-add-ui-meaning']"))==null||C.addEventListener("click",()=>{d==null||d();}),($=i.querySelector("[data-testid='widget-add-ui-meaning-empty']"))==null||$.addEventListener("click",()=>{d==null||d();}),(Y=i.querySelector("[data-testid='widget-add-ui-meaning-btn']"))==null||Y.addEventListener("click",()=>{d==null||d();});}function $o(i,e,t,n){let{onRequireLogin:o,onClarificationClick:r,onShowAllClarifications:s,onAskQuestion:a}=n,c=i.querySelector("[data-section='clarifications']");if(!c)return;let d=c.querySelector(".clarifications-body");if(!d)return;let l=c.querySelector(".home-section-header"),p=l==null?void 0:l.querySelector(".home-section-add");if(p&&p.addEventListener("click",()=>{if(t){let f=Number(c.dataset.contextId);ht(c,f,a);}else o==null||o();}),e.length===0){d.innerHTML='<div class="section-empty"><div class="section-empty-title">No questions yet.</div><div class="section-empty-text">Ask here if something about this interface is unclear.</div><button class="section-empty-action" data-testid="widget-ask-question-empty">Ask Question</button></div>';let f=d.querySelector('[data-testid="widget-ask-question-empty"]');f&&f.addEventListener("click",()=>{if(t){let y=Number(c.dataset.contextId);ht(c,y,a);}else o==null||o();});return}let h=e.slice(0,fe).map(f=>{var N;let y=f.authorName?B(f.authorName):"Unknown",A=f.createdAt?new Date(f.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"",L=((N=f.replies)!=null?N:[]).map(U=>{var F;return `
2044
+ <div class="discussion-reply">
2045
+ <div class="discussion-meta"><span class="discussion-meta-dot"></span>${B((F=U.authorName)!=null?F:"Unknown")} \xB7 ${new Date(U.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}</div>
2046
+ <p class="discussion-body">${B(U.body)}</p>
2047
+ </div>`}).join("");return `
2048
+ <div class="discussion-card" data-discussion-id="${f.id}">
2049
+ <div class="discussion-card-main">
2050
+ <div class="discussion-meta"><span class="discussion-meta-dot"></span>${y} \xB7 ${A}</div>
2051
+ <p class="discussion-body">${B(f.body)}</p>
2052
+ ${L?`<div class="discussion-replies">${L}</div>`:""}
2053
+ </div>
2054
+ <span class="concept-chevron"><svg viewBox="0 0 24 24" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg></span>
2055
+ </div>`}).join(""),m=e.length>fe?`<a href="#" class="home-show-more home-show-more-clarifications" data-testid="widget-show-all-clarifications">Show all ${e.length} clarifications \u2192</a>`:"";d.innerHTML=h+m,d.querySelectorAll(".discussion-card").forEach(f=>{f.addEventListener("click",()=>{let y=Number(f.dataset.discussionId),A=e.find(L=>L.id===y);A&&(r==null||r(A));});});let v=d.querySelector("[data-testid='widget-show-all-clarifications']");v&&v.addEventListener("click",f=>{f.preventDefault(),s==null||s();});}function ht(i,e,t){let n=i.querySelector(".clarifications-body");if(!n||n.querySelector(".ask-form"))return;let o=n.querySelector(".section-empty");o&&(o.style.display="none");let r=document.createElement("div");r.className="ask-form",r.innerHTML=`
2056
+ <textarea class="ask-textarea" placeholder="Your question\u2026" maxlength="2000" rows="3"></textarea>
2057
+ <div class="ask-actions">
2058
+ <button class="ask-cancel">Cancel</button>
2059
+ <button class="ask-submit" data-testid="widget-ask-submit">Send</button>
2060
+ </div>
2061
+ <p class="ask-error" style="display:none"></p>
2062
+ `,n.insertBefore(r,n.firstChild);let s=r.querySelector(".ask-textarea"),a=r.querySelector(".ask-cancel"),c=r.querySelector(".ask-submit");s.focus(),a.addEventListener("click",()=>{r.remove(),o&&(o.style.display="");}),c.addEventListener("click",()=>{let d=s.value.trim();d&&(c.disabled=true,c.textContent="Sending\u2026",t==null||t(e,d),r.remove());});}function mt(i,e,t){var l;if(i.querySelector(".add-term-form"))return;let n=(l=e!=null?e:i.querySelector(".home-section-helper"))!=null?l:i.querySelector(".home-section-header");if(!n)return;let o=document.createElement("div");o.className="add-term-form",o.innerHTML=`
2063
+ <input class="add-term-input" type="text" placeholder="Term name\u2026" maxlength="100" data-testid="widget-add-term-name" />
2064
+ <textarea class="add-term-input ask-textarea" placeholder="Definition\u2026" maxlength="5000" rows="3" data-testid="widget-add-term-definition"></textarea>
2065
+ <div class="ask-actions">
2066
+ <button class="ask-cancel" data-testid="widget-add-term-cancel">Cancel</button>
2067
+ <button class="ask-submit" data-testid="widget-add-term-submit">Add</button>
2068
+ </div>
2069
+ <p class="ask-error" style="display:none" data-testid="widget-add-term-error"></p>
2070
+ `,n.after(o);let r=o.querySelector("[data-testid='widget-add-term-name']"),s=o.querySelector("[data-testid='widget-add-term-definition']"),a=o.querySelector("[data-testid='widget-add-term-cancel']"),c=o.querySelector("[data-testid='widget-add-term-submit']"),d=o.querySelector("[data-testid='widget-add-term-error']");r.focus(),a.addEventListener("click",()=>o.remove()),c.addEventListener("click",()=>{let p=r.value.trim(),h=s.value.trim();if(!p||!h){d.textContent="Both term and definition are required.",d.style.display="";return}d.style.display="none",c.disabled=true,c.textContent="Adding\u2026",t==null||t(p,h),o.remove();});}function Ut(i,e,t,n,o,r,s,a,c,d,l,p,h,m,v,f,y,A,L,N,U,F,Q,_,C,$,Y,H,P){let O=document.createElement("div");O.id="unnoodle-panel-host",O.setAttribute("data-testid","widget-panel-host");let I=O.attachShadow({mode:"open"}),X=document.createElement("style");X.textContent=re(vo);let j=document.createElement("div");j.className="panel",j.setAttribute("role","complementary"),j.setAttribute("aria-label","Unnoodle Glossary");let K=document.createElement("div");K.className="panel-header",K.innerHTML=`
2071
+ <div class="panel-header-brand">
2072
+ <span class="panel-title">Unnoodle</span>
2073
+ <span class="panel-title-sep">\xB7</span>
2074
+ <span class="panel-subtitle">Glossary</span>
2075
+ </div>
2076
+ <div class="panel-header-actions">
2077
+ <button class="panel-pin-left" aria-label="Pin to left" data-testid="widget-panel-pin-left" title="Dock to left side">
2078
+ <svg viewBox="0 0 256 256" aria-hidden="true"><rect x="32" y="48" width="192" height="160" rx="8" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="88" y1="48" x2="88" y2="208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>
2079
+ </button>
2080
+ <button class="panel-pin-right active" aria-label="Pin to right" data-testid="widget-panel-pin-right" title="Dock to right side">
2081
+ <svg viewBox="0 0 256 256" aria-hidden="true"><rect x="32" y="48" width="192" height="160" rx="8" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="88" y1="48" x2="88" y2="208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>
2082
+ </button>
2083
+ <div class="panel-header-separator" aria-hidden="true"></div>
2084
+ <button class="panel-half" aria-label="Expand to half width" data-testid="widget-panel-half" title="Expand to 50% width">
2085
+ <svg viewBox="0 0 256 256" aria-hidden="true"><path d="M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm-64,80h64v16H136Zm0-16V88h64v16Zm0,48h64v16H136Zm64-80H136V56h64ZM56,56h64V200H56ZM200,200H136V184h64v16Z"/></svg>
2086
+ </button>
2087
+ <button class="panel-half-exit" aria-label="Exit half width" data-testid="widget-panel-half-exit" title="Restore width" hidden>
2088
+ <svg viewBox="0 0 256 256" aria-hidden="true"><path d="M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200Z"/></svg>
2089
+ </button>
2090
+ <button class="panel-fullscreen" aria-label="Fullscreen" data-testid="widget-panel-fullscreen" title="Expand to full width">
2091
+ <svg viewBox="0 0 256 256" aria-hidden="true"><path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"/></svg>
2092
+ </button>
2093
+ <button class="panel-fullscreen-exit" aria-label="Exit fullscreen" data-testid="widget-panel-fullscreen-exit" title="Exit fullscreen" hidden>
2094
+ <svg viewBox="0 0 256 256" aria-hidden="true"><path d="M136,40V96a8,8,0,0,0,8,8h56a8,8,0,0,0,0-16H160V40a8,8,0,0,0-16,0ZM96,152H40a8,8,0,0,0,0,16H96v56a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm64,0a8,8,0,0,0-8,8v56a8,8,0,0,0,16,0V168h56a8,8,0,0,0,0-16ZM96,104h56a8,8,0,0,0,0-16H112V40a8,8,0,0,0-16,0V96A8,8,0,0,0,96,104Z"/></svg>
2095
+ </button>
2096
+ <!-- popout temporarily disabled \u2014 TODO: fix CSS vars after adoptNode -->
2097
+ <button class="panel-popout" aria-label="Pop out panel" data-testid="widget-panel-popout" title="Open in separate window" hidden>
2098
+ <svg viewBox="0 0 256 256" aria-hidden="true"><path d="M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"/></svg>
2099
+ </button>
2100
+ <button class="panel-dock" aria-label="Dock panel" data-testid="widget-panel-dock" title="Dock back to main window" hidden>
2101
+ <svg viewBox="0 0 256 256" aria-hidden="true"><path d="M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"/></svg>
2102
+ </button>
2103
+ <button class="panel-close" aria-label="Close panel" data-testid="widget-panel-close">
2104
+ <svg viewBox="0 0 256 256" aria-hidden="true"><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/></svg>
2105
+ </button>
2106
+ </div>
2107
+ `;let b=document.createElement("div");b.className="panel-body";let ae=document.createElement("div");ae.className="panel-footer",ae.innerHTML='<a href="https://unnoodle.com" target="_blank" rel="noopener">Product knowledge powered by Unnoodle</a>',j.appendChild(K),j.appendChild(b),j.appendChild(ae);let ve=document.createElement("div");ve.className="panel-resize-handle",ve.setAttribute("data-testid","widget-panel-resize-handle"),j.appendChild(ve);let w=document.createElement("div");if(w.className="panel-shell",w.appendChild(j),y){let u=document.createElement("style");u.textContent=re(y),I.appendChild(u);}I.appendChild(X);let q=document.createElement("style");q.textContent=re(Ao()),I.appendChild(q),I.appendChild(w);let ee=K.querySelector(".panel-close"),se=K.querySelector(".panel-popout"),ne=K.querySelector(".panel-dock"),be=K.querySelector(".panel-pin-left"),De=K.querySelector(".panel-pin-right"),Wo=K.querySelector(".panel-half"),jo=K.querySelector(".panel-half-exit"),Zo=K.querySelector(".panel-fullscreen"),Ko=K.querySelector(".panel-fullscreen-exit"),Be=Bo({host:O,shadow:I,panelShell:w,popoutBtn:se,dockBtn:ne,closeBtn:ee,pinLeftBtn:be,pinRightBtn:De,halfBtn:Wo,halfExitBtn:jo,fullscreenBtn:Zo,fullscreenExitBtn:Ko,resizeHandle:ve},S(J(S(S(S({},n&&{onClose:n}),m&&{onPopout:m}),v&&{onReattach:v}),{onToast:u=>Zt(u)}),y&&{shadowTokens:y}));function Yo(){Be.show();}function Xo(){Be.hide();}function Jo(){Be.popout();}function Qo(){b.innerHTML=`
2108
+ <div class="skeleton-home" data-testid="widget-loading">
2109
+ <div class="skeleton-loading-header">
2110
+ <div class="skeleton-loading-brand">Unnoodle</div>
2111
+ <div class="skeleton-loading-title">Loading knowledge for this context\u2026</div>
2112
+ <div class="skeleton-loading-sub">Helping your team understand this interface</div>
2113
+ </div>
2114
+ <div class="skeleton-body">
2115
+ <div class="skeleton-section">
2116
+ <div class="skeleton-section-head"></div>
2117
+ <div class="skeleton-row"><div class="skeleton-line" style="width:55%;height:9px;"></div></div>
2118
+ </div>
2119
+ <div class="skeleton-section">
2120
+ <div class="skeleton-section-head"></div>
2121
+ <div class="skeleton-row"><div class="skeleton-line" style="width:72%;height:9px;"></div></div>
2122
+ <div class="skeleton-row"><div class="skeleton-line" style="width:48%;height:9px;"></div></div>
2123
+ <div class="skeleton-row"><div class="skeleton-line" style="width:63%;height:9px;"></div></div>
2124
+ <div class="skeleton-row"><div class="skeleton-line" style="width:38%;height:9px;"></div></div>
2125
+ </div>
2126
+ <div class="skeleton-section">
2127
+ <div class="skeleton-section-head"></div>
2128
+ <div class="skeleton-row"><div class="skeleton-line" style="width:80%;height:9px;"></div></div>
2129
+ </div>
2130
+ </div>
2131
+ </div>
2132
+ `;}function en(u){b.innerHTML=`
2133
+ <div class="state-center" data-testid="widget-panel-error">
2134
+ <svg class="state-error-icon" viewBox="0 0 24 24" stroke-width="1.5" aria-hidden="true">
2135
+ <circle cx="12" cy="12" r="10"/>
2136
+ <line x1="12" y1="8" x2="12" y2="12"/>
2137
+ <line x1="12" y1="16" x2="12.01" y2="16"/>
2138
+ </svg>
2139
+ <p class="state-msg">${B(u)}</p>
2140
+ </div>
2141
+ `;}let Ie=false;function tn(u){yo(b,J(S({onLogin:i},f&&{onSsoLogin:g=>f(g)}),{onBack:$e?()=>{let g=$e;$e=g,bt(g);}:null}),u);}function on(u){wo(b,u);}function nn(u){xo(b,u);}let $e=null,we=null,xe=null,le=null,he=null;function bt(u){if($e=u,he=u,cn(u),we&&jt(we.discussions,we.canPost),u.productMemories!==void 0){let g=u.productMemories.slice(0,5);Kt(g);}}function sn(u,g){un(u,null,u.length,g);}function an(u){yt(),he&&(le==null||le.showAllTerms(he,u));}function ln(u,g){yt(),le==null||le.showAllClarifications(u,g);}function dn(u,g){yt(),le==null||le.showAllMemories(u,g);}function yt(){if(!le){let u={onTermClick:g=>{let x=he==null?void 0:he.glossary.find(k=>k.id===g);x&&a&&a(x);},onDiscussionClick:g=>{if(F&&we){let x=we.discussions.find(k=>k.id===g);x&&F(x);}},onMemoryClick:g=>{p&&p(g);},onBackToHome:()=>{o==null||o();},onAddTerm:()=>{if(!Ie){L==null||L();return}let g=b.querySelector("[data-testid='widget-terms-list-view']");if(g){let x=g.querySelector(".list-header");x&&mt(g,x,N);}},onAddDiscussion:()=>{let g=b.querySelector('[data-section="clarifications"]'),x=he==null?void 0:he.context.id;g&&x&&ht(g,x,A);},onAddMemory:()=>d==null?void 0:d(),onRequireLogin:()=>L==null?void 0:L()};le=new pt(b,u);}}function cn(u){Io(b,K.querySelector(".panel-subtitle"),u,S(S(S(S(S(S(S(S(S({},a&&{onTermClick:a}),L&&{onRequireLogin:L}),N&&{onAddConcept:N}),U&&{onOpenSearch:U}),d&&{onCaptureUiState:d}),Y&&{onShowAllConcepts:Y}),F&&{onClarificationClick:F}),H&&{onShowAllClarifications:H}),A&&{onAskQuestion:A}),Ie);}function jt(u,g){we={discussions:u,canPost:g},$o(b,u,g,S(S(S(S({},L&&{onRequireLogin:L}),F&&{onClarificationClick:F}),H&&{onShowAllClarifications:H}),A&&{onAskQuestion:A}));}function un(u,g,x,k){b.innerHTML=`
2142
+ <div class="search-bar">
2143
+ <input class="search-input" id="unn-search" type="search"
2144
+ placeholder="Search terms\u2026" autocomplete="off"
2145
+ value="${B(k)}" aria-label="Search glossary terms"
2146
+ data-testid="widget-glossary-search" />
2147
+ </div>
2148
+ <div class="action-bar" id="unn-action-bar" style="display:${Ie?"flex":"none"}">
2149
+ <div class="action-bar-tabs">
2150
+ <button class="tab-btn active" data-testid="widget-glossary-tab">Glossary</button>
2151
+ <button class="tab-btn" data-testid="widget-ui-states-tab">UI States</button>
2152
+ </div>
2153
+ <button class="capture-btn" data-testid="widget-ui-state-capture-btn"
2154
+ title="Capture the current page state">
2155
+ <svg viewBox="0 0 24 24" aria-hidden="true">
2156
+ <circle cx="12" cy="12" r="3"/>
2157
+ <path d="M3 9a2 2 0 0 1 2-2h1l2-3h8l2 3h1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
2158
+ </svg>
2159
+ Capture
2160
+ </button>
2161
+ </div>
2162
+ <div class="terms-list" id="unn-terms-list" data-testid="widget-glossary-list">
2163
+ ${""}
2164
+ ${u.length===0?hn(k):u.map(pn).join("")}
2165
+ </div>
2166
+ `;let T=b.querySelector("#unn-search"),E;T.addEventListener("input",()=>{clearTimeout(E),E=setTimeout(()=>{e(T.value);},220);}),a&&b.querySelector("#unn-terms-list").addEventListener("click",G=>{var Se;let te=G.target.closest("[data-testid='widget-term-card']");if(!te)return;let ke=te.closest("[data-term-id]");if(!ke)return;let Me=parseInt((Se=ke.getAttribute("data-term-id"))!=null?Se:"-1",10),Le=u.find(qn=>qn.id===Me);Le&&a(Le);});let R=b.querySelector('[data-testid="widget-ui-state-capture-btn"]');R==null||R.addEventListener("click",()=>{R.disabled||(R.disabled=true,R.textContent="Capturing\u2026",d==null||d(),setTimeout(()=>{R&&(R.disabled=false,R.innerHTML=`
2167
+ <svg viewBox="0 0 24 24" aria-hidden="true" style="width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2">
2168
+ <circle cx="12" cy="12" r="3"/>
2169
+ <path d="M3 9a2 2 0 0 1 2-2h1l2-3h8l2 3h1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
2170
+ </svg>
2171
+ Capture
2172
+ `);},2e3));});let z=b.querySelector('[data-testid="widget-ui-states-tab"]');z==null||z.addEventListener("click",()=>l==null?void 0:l()),T.focus();}function pn(u){let g=u.abbreviation?`<span class="term-abbr">${B(u.abbreviation)}</span>`:"",x=t?`<a class="term-link" href="${B(t)}/glossary/${u.id}" target="_blank" rel="noopener">View details \u2192</a>`:"";return `
2173
+ <div class="term-item" data-term-id="${u.id}" data-testid="widget-glossary-item">
2174
+ <div class="term-card" data-testid="widget-term-card">
2175
+ <div class="term-name">${B(u.term)}${g}</div>
2176
+ <div class="term-def">${B(u.definition)}</div>
2177
+ </div>
2178
+ ${x}
2179
+ </div>
2180
+ `}function hn(u){return `<div class="no-results" data-testid="widget-glossary-empty">${u?`No results for "${B(u)}"`:"No terms found."}</div>`}function mn(){Be.cleanup(),O.remove();}function gn(u,g,x){let k=g.length===0?'<div class="discussions-empty" data-testid="widget-discussion-empty">No comments yet. Be the first to comment!</div>':g.map(z=>`<div class="discussion-post" data-testid="widget-discussion-post">${B(z.body)}</div>`).join(""),T=x!=null&&x.showEdit?'<button class="action-btn edit-btn" data-testid="widget-edit-btn">Edit Term</button>':"";if(b.innerHTML=`
2181
+ <div class="term-detail-view">
2182
+ <div class="detail-back">
2183
+ <button class="back-btn" data-testid="widget-back-btn">\u2190 Back to list</button>
2184
+ </div>
2185
+ <div class="detail-content">
2186
+ <div data-testid="widget-term-detail" class="detail-body">
2187
+ <h3 class="detail-term-name">${B(u.term)}</h3>
2188
+ <p class="detail-term-def">${B(u.definition)}</p>
2189
+ </div>
2190
+ </div>
2191
+ <div class="detail-actions">
2192
+ <button class="action-btn" data-testid="widget-add-comment-btn">Add Comment</button>
2193
+ ${T}
2194
+ </div>
2195
+ <div class="discussions-section">
2196
+ <div class="discussions-heading">Discussion</div>
2197
+ ${k}
2198
+ </div>
2199
+ </div>
2200
+ `,b.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>o==null?void 0:o()),b.querySelector('[data-testid="widget-add-comment-btn"]').addEventListener("click",()=>{r==null||r(u.id,"");}),x!=null&&x.showEdit){let z=b.querySelector('[data-testid="widget-edit-btn"]');z==null||z.addEventListener("click",()=>{c==null||c(u.id);});}}function fn(u){b.innerHTML=`
2201
+ <div class="comment-form-view">
2202
+ <div class="detail-back">
2203
+ <button class="back-btn" data-testid="widget-back-btn">\u2190 Back</button>
2204
+ </div>
2205
+ <textarea
2206
+ class="comment-textarea"
2207
+ data-testid="widget-comment-body"
2208
+ placeholder="Share your thoughts on this term\u2026"
2209
+ ></textarea>
2210
+ <button class="comment-submit" data-testid="widget-comment-submit">Submit Comment</button>
2211
+ </div>
2212
+ `,b.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>o==null?void 0:o());let x=b.querySelector('[data-testid="widget-comment-submit"]'),k=b.querySelector('[data-testid="widget-comment-body"]');x.addEventListener("click",()=>{let T=k.value.trim();T&&(r==null||r(u,T));});}function vn(u){b.innerHTML=`
2213
+ <div class="edit-form-view">
2214
+ <div class="detail-back">
2215
+ <button class="back-btn" data-testid="widget-back-btn">\u2190 Back</button>
2216
+ </div>
2217
+ <div>
2218
+ <label class="edit-label" for="unn-edit-term">Term</label>
2219
+ <input
2220
+ class="edit-input"
2221
+ id="unn-edit-term"
2222
+ type="text"
2223
+ data-testid="widget-edit-term-input"
2224
+ value="${B(u.term)}"
2225
+ />
2226
+ </div>
2227
+ <div>
2228
+ <label class="edit-label" for="unn-edit-def">Definition</label>
2229
+ <textarea
2230
+ class="edit-textarea"
2231
+ id="unn-edit-def"
2232
+ data-testid="widget-edit-definition-input"
2233
+ >${B(u.definition)}</textarea>
2234
+ </div>
2235
+ <button class="edit-submit" data-testid="widget-edit-submit">Save Changes</button>
2236
+ </div>
2237
+ `,b.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>o==null?void 0:o());let x=b.querySelector('[data-testid="widget-edit-term-input"]'),k=b.querySelector('[data-testid="widget-edit-definition-input"]');b.querySelector('[data-testid="widget-edit-submit"]').addEventListener("click",()=>{s==null||s(u.id,{term:x.value,definition:k.value});});}function bn(u){}function yn(u){}function wn(u){}function xn(u){}function kn(u,g){if(u.length===0)return;let x=b.querySelector(".suggestions-section");x&&x.remove();let k=b.querySelector(".terms-list");if(!k)return;let T=document.createElement("div");T.className="suggestions-section",T.innerHTML=`
2238
+ <div class="suggestions-heading" data-testid="widget-suggestions-heading">
2239
+ Suggested Terms
2240
+ </div>
2241
+ ${u.map(E=>`
2242
+ <div class="suggestion-item" data-testid="widget-suggestion-item">
2243
+ <div class="suggestion-info">
2244
+ <span class="suggestion-term">${B(E.term)}</span>
2245
+ <span class="suggestion-count">mentioned ${E.count}\xD7</span>
2246
+ </div>
2247
+ <button
2248
+ class="suggestion-add"
2249
+ data-testid="widget-suggestion-add"
2250
+ data-term="${B(E.term)}"
2251
+ >+ Add</button>
2252
+ </div>`).join("")}
2253
+ `,T.querySelectorAll(".suggestion-add").forEach(E=>{E.addEventListener("click",()=>{var z;let R=(z=E.dataset.term)!=null?z:"";g(R);});}),k.after(T);}function En(u,g,x,k){var te;(te=j.querySelector(".ai-modal-overlay"))==null||te.remove();let T=document.createElement("div");T.className="ai-modal-overlay",T.setAttribute("data-testid","widget-ai-modal"),T.innerHTML=`
2254
+ <div class="ai-modal-title">AI Generated Definition</div>
2255
+ <div class="ai-modal-term">${B(u)}</div>
2256
+ <div>
2257
+ <label class="ai-modal-label" for="unn-ai-def">Review &amp; edit the definition:</label>
2258
+ <textarea
2259
+ class="ai-modal-textarea"
2260
+ id="unn-ai-def"
2261
+ data-testid="widget-ai-definition"
2262
+ maxlength="500"
2263
+ >${B(g)}</textarea>
2264
+ <div class="ai-modal-char-count" id="unn-ai-char">0 / 500</div>
2265
+ </div>
2266
+ <div class="ai-modal-actions">
2267
+ <button class="ai-modal-cancel" data-testid="widget-ai-cancel">Cancel</button>
2268
+ <button class="ai-modal-submit" data-testid="widget-ai-submit">Submit for Approval</button>
2269
+ </div>
2270
+ `;let E=T.querySelector('[data-testid="widget-ai-definition"]'),R=T.querySelector("#unn-ai-char"),z=()=>{R.textContent=`${E.value.length} / 500`;};E.addEventListener("input",z),z(),T.querySelector('[data-testid="widget-ai-submit"]').addEventListener("click",()=>{x(E.value);}),T.querySelector('[data-testid="widget-ai-cancel"]').addEventListener("click",()=>{T.remove(),k();}),j.appendChild(T);}function Tn(u){let g=j.querySelector('[data-testid="widget-ai-submit"]');g&&(g.disabled=u,g.textContent=u?"Submitting\u2026":"Submit for Approval");}function Zt(u){var x;(x=j.querySelector(".toast"))==null||x.remove();let g=document.createElement("div");g.className="toast",g.setAttribute("data-testid","widget-toast"),g.textContent=u,j.appendChild(g),setTimeout(()=>g.remove(),4e3);}function Cn(u){Ie=u;let g=b.querySelector("#unn-action-bar");g&&(g.style.display=u?"flex":"none");}function Mn(u,g,x,k=false){var R,z;if(!k){b.innerHTML=`
2271
+ <div class="action-bar" id="unn-action-bar" style="display:flex">
2272
+ <div class="action-bar-tabs">
2273
+ <button class="tab-btn" data-testid="widget-glossary-tab">Glossary</button>
2274
+ <button class="tab-btn active" data-testid="widget-ui-states-tab">Captures</button>
2275
+ </div>
2276
+ <button class="capture-btn" data-testid="widget-ui-state-capture-btn"
2277
+ title="Capture the current page state">
2278
+ <svg viewBox="0 0 24 24" aria-hidden="true" style="width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2">
2279
+ <circle cx="12" cy="12" r="3"/>
2280
+ <path d="M3 9a2 2 0 0 1 2-2h1l2-3h8l2 3h1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
2281
+ </svg>
2282
+ Capture
2283
+ </button>
2284
+ </div>
2285
+ <div class="ui-states-list" id="unn-ui-states-list" data-testid="widget-ui-states-list"></div>
2286
+ `;let Z=b.querySelector('[data-testid="widget-glossary-tab"]');Z==null||Z.addEventListener("click",()=>o==null?void 0:o());let G=b.querySelector('[data-testid="widget-ui-state-capture-btn"]');G==null||G.addEventListener("click",()=>{G.disabled||(G.disabled=true,G.textContent="Capturing\u2026",d==null||d(),setTimeout(()=>{G&&(G.disabled=false,G.innerHTML=`
2287
+ <svg viewBox="0 0 24 24" aria-hidden="true" style="width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2">
2288
+ <circle cx="12" cy="12" r="3"/>
2289
+ <path d="M3 9a2 2 0 0 1 2-2h1l2-3h8l2 3h1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
2290
+ </svg>
2291
+ Capture
2292
+ `);},2e3));});}let T=b.querySelector("#unn-ui-states-list");if(!T)return;if((R=b.querySelector(".load-more-container"))==null||R.remove(),u.length===0&&!k){T.innerHTML=`
2293
+ <div class="ui-states-empty" data-testid="widget-ui-states-empty">
2294
+ <svg class="ui-states-empty-icon" viewBox="0 0 24 24" stroke-width="1.5" aria-hidden="true">
2295
+ <rect x="3" y="3" width="18" height="18" rx="2"/>
2296
+ <path d="M9 9h6M9 12h6M9 15h4"/>
2297
+ </svg>
2298
+ <p class="ui-states-empty-text">
2299
+ No captures yet.<br/>
2300
+ Click <strong>Capture</strong> to snapshot an element.
2301
+ </p>
2302
+ </div>
2303
+ `;return}let E=u.map(Z=>Ln(Z)).join("");if(T.insertAdjacentHTML("beforeend",E),T.querySelectorAll('[data-testid="widget-ui-state-detail-btn"]').forEach(Z=>{var te;let G=parseInt((te=Z.dataset.stateId)!=null?te:"-1",10);Z.addEventListener("click",()=>{isNaN(G)||p==null||p(G);});}),x){let Z=document.createElement("div");Z.className="load-more-container",Z.innerHTML=`
2304
+ <button class="load-more-btn" data-testid="widget-ui-states-load-more"
2305
+ data-page="${g+1}">
2306
+ Load more
2307
+ </button>
2308
+ `,(z=Z.querySelector('[data-testid="widget-ui-states-load-more"]'))==null||z.addEventListener("click",()=>l==null?void 0:l()),b.appendChild(Z);}}function Ln(u){let g=wt(u.updatedAt),x=u.entryCount;return `
2309
+ <div class="ui-state-item" data-testid="widget-ui-state-item" data-state-id="${u.id}">
2310
+ <div class="ui-state-url" title="${B(u.title)}">${B(u.title)}</div>
2311
+ <div class="ui-state-meta">
2312
+ <span>${B(g)}</span>
2313
+ <span class="ui-state-role-badge">${x} ${x===1?"entry":"entries"}</span>
2314
+ </div>
2315
+ <div class="ui-state-actions">
2316
+ <button class="view-detail-btn"
2317
+ data-testid="widget-ui-state-detail-btn"
2318
+ data-state-id="${u.id}">
2319
+ View Details
2320
+ </button>
2321
+ </div>
2322
+ </div>
2323
+ `}function Sn(u){var k,T;let g=u.entries.map((E,R)=>{var G;let z=wt(E.capturedAt),Z=B((G=E.capturedByRole)!=null?G:"");return `
2324
+ <div class="pm-entry" data-entry-id="${E.id}">
2325
+ <div class="detail-meta-section">
2326
+ <div class="detail-meta-row">
2327
+ <span>${B(z)}</span>
2328
+ ${Z?`<span class="ui-state-role-badge">${Z}</span>`:""}
2329
+ ${E.capturedByName?`<span>${B(E.capturedByName)}</span>`:""}
2330
+ </div>
2331
+ </div>
2332
+ ${E.snapshotHtml?`<div class="ui-state-snapshot-preview" data-testid="widget-ui-state-snapshot-preview-${E.id}"></div>`:""}
2333
+ <div class="product-memory-section" data-testid="widget-product-memory-section-${E.id}">
2334
+ <div class="product-memory-heading">Entry ${R+1} \xB7 Explanation</div>
2335
+ ${E.explanation?`
2336
+ <div class="product-memory-read-mode" data-testid="widget-product-memory-read">
2337
+ <div class="product-memory-text" data-testid="widget-product-memory-text">${B(E.explanation)}</div>
2338
+ <div class="product-memory-actions">
2339
+ <button class="product-memory-edit-btn" data-testid="widget-product-memory-edit-btn">Edit</button>
2340
+ <button class="product-memory-delete-entry-btn" data-testid="widget-product-memory-delete-entry-btn" data-entry-id="${E.id}" title="Delete Entry">\u{1F5D1}</button>
2341
+ </div>
2342
+ </div>
2343
+ <div class="product-memory-write-mode" data-testid="widget-product-memory-write" style="display:none">
2344
+ <textarea class="product-memory-textarea" data-testid="widget-product-memory-textarea"
2345
+ placeholder="Describe what this snapshot represents\u2026"
2346
+ maxlength="2000">${B(E.explanation)}</textarea>
2347
+ <div class="product-memory-actions">
2348
+ <button class="product-memory-cancel-btn" data-testid="widget-product-memory-cancel-btn">Cancel</button>
2349
+ <button class="product-memory-save-btn" data-testid="widget-product-memory-save-btn">Save</button>
2350
+ </div>
2351
+ </div>`:`
2352
+ <div class="product-memory-write-mode" data-testid="widget-product-memory-write">
2353
+ <textarea class="product-memory-textarea" data-testid="widget-product-memory-textarea"
2354
+ placeholder="Describe what this snapshot represents\u2026"
2355
+ maxlength="2000"></textarea>
2356
+ <div class="product-memory-actions">
2357
+ <button class="product-memory-save-btn" data-testid="widget-product-memory-save-btn">Add Explanation</button>
2358
+ </div>
2359
+ </div>`}
2360
+ </div>
2361
+ </div>
2362
+ `}).join('<hr class="pm-entry-divider">');b.innerHTML=`
2363
+ <div class="ui-state-detail-view" data-testid="widget-ui-state-detail">
2364
+ <div class="detail-back">
2365
+ <button class="back-btn" data-testid="widget-ui-state-back-btn">\u2190 Captures</button>
2366
+ </div>
2367
+ <div class="detail-page-title">${B(u.title)}</div>
2368
+ ${u.entries.length===0?`<div class="ui-states-empty" data-testid="widget-ui-states-empty">
2369
+ <p class="ui-states-empty-text">No entries yet. Capture an element to get started.</p>
2370
+ </div>`:g}
2371
+ <div class="detail-actions">
2372
+ <button class="detail-delete-btn" data-testid="widget-delete-memory-btn" data-memory-id="${u.id}">
2373
+ Delete Memory
2374
+ </button>
2375
+ <button class="detail-add-btn" data-testid="widget-add-entry-btn">
2376
+ + Add Entry
2377
+ </button>
2378
+ </div>
2379
+ </div>
2380
+ `,u.entries.forEach(E=>{if(!E.snapshotHtml)return;let R=b.querySelector(`[data-testid="widget-ui-state-snapshot-preview-${E.id}"]`);R&&(R.innerHTML=E.snapshotHtml);}),(k=b.querySelector('[data-testid="widget-ui-state-back-btn"]'))==null||k.addEventListener("click",()=>o==null?void 0:o()),(T=b.querySelector('[data-testid="widget-add-entry-btn"]'))==null||T.addEventListener("click",()=>_==null?void 0:_(u.id)),u.entries.forEach(E=>{let R=b.querySelector(`[data-testid="widget-product-memory-section-${E.id}"]`);if(!R)return;let z=R.querySelector('[data-testid="widget-product-memory-read"]'),Z=R.querySelector('[data-testid="widget-product-memory-write"]'),G=R.querySelector('[data-testid="widget-product-memory-textarea"]'),te=R.querySelector('[data-testid="widget-product-memory-save-btn"]'),ke=R.querySelector('[data-testid="widget-product-memory-edit-btn"]'),Me=R.querySelector('[data-testid="widget-product-memory-cancel-btn"]');ke==null||ke.addEventListener("click",()=>{z&&(z.style.display="none"),Z&&(Z.style.display=""),G==null||G.focus();}),Me==null||Me.addEventListener("click",()=>{Z&&(Z.style.display="none"),z&&(z.style.display="");}),te==null||te.addEventListener("click",()=>{var Se;let Le=(Se=G==null?void 0:G.value.trim())!=null?Se:"";Le&&(te&&(te.disabled=true,te.textContent="Saving\u2026"),h==null||h(u.id,E.id,Le));});}),u.entries.forEach(E=>{let R=b.querySelector(`[data-testid="widget-product-memory-delete-entry-btn"][data-entry-id="${E.id}"]`);R==null||R.addEventListener("click",z=>{z.preventDefault(),confirm("Are you sure you want to delete this entry? This action cannot be undone.")&&($==null||$(u.id,E.id));});});let x=b.querySelector('[data-testid="widget-delete-memory-btn"]');x==null||x.addEventListener("click",E=>{E.preventDefault(),confirm(`Are you sure you want to delete "${u.title}"? This will delete all entries and cannot be undone.`)&&(C==null||C(u.id));});}function wt(u){try{let g=Math.floor((Date.now()-new Date(u).getTime())/1e3);return g<60?"just now":g<3600?`${Math.floor(g/60)}m ago`:g<86400?`${Math.floor(g/3600)}h ago`:g<604800?`${Math.floor(g/86400)}d ago`:new Date(u).toLocaleDateString()}catch(g){return "unknown time"}}function An(u,g,x,k){console.log("[unnoodle] showNewMemoryForm called");let T=b;if(console.log("[unnoodle] Using body element:",T),!T){console.log("[unnoodle] No body element available, returning early");return}console.log("[unnoodle] Creating capture form...");let{element:E,controller:R}=Nt({onPickElement:u,onCancelCapture:g,onSave:x,onCancel:k},{showTitle:true});console.log("[unnoodle] Capture form created:",E),xe=R,console.log("[unnoodle] Clearing bodyEl and appending form..."),T.innerHTML="",T.appendChild(E),console.log("[unnoodle] Form appended successfully, bodyEl.innerHTML length is now:",T.innerHTML.length);}function Hn(u,g,x,k,T){let E=b;if(!E)return;let{element:R,controller:z}=Nt({onPickElement:g,onCancelCapture:x,onSave:(Z,G)=>{k(G);},onCancel:()=>{T();}},{showTitle:false,headerText:u,subheaderText:"Add new entry"});xe=z,E.innerHTML="",E.appendChild(R);}function Pn(u){xe&&xe.setSnapshot(u);}function Rn(u){xe&&xe.setPickingMode(u);}function Dn(u,g,x){So(b,u,g,x);}function Bn(){Re(b);}return {element:O,show:Yo,hide:Xo,showLogin:tn,setLoginLoading:on,setLoginError:nn,setLoading:Qo,showTerms:bt,showSearchResults:sn,setError:en,showTermDetail:gn,showCommentForm:fn,showEditForm:vn,setCommentLoading:bn,setCommentError:yn,setEditLoading:wn,setEditError:xn,showSuggestedTerms:kn,showAiModal:En,setAiModalLoading:Tn,showToast:Zt,setAuthenticated:Cn,showMemoriesList:Mn,showMemoryDetail:Sn,cleanup:mn,popout:Jo,loadClarifications:jt,showClarificationDetail:In,enterPickMode:$n,showCaptureDescribe:zn,setCaptureLoading:Nn,setCaptureError:Un,exitCaptureMode:Fn,restoreHomeView:On,showHomeMemoryItems:Kt,showAllConcepts:an,showAllClarifications:ln,showAllMemories:dn,showNewMemoryForm:An,showAddEntryForm:Hn,updateFormSnapshot:Pn,setFormPickingMode:Rn,showStateChangeNotification:Dn,hideStateChangeNotification:Bn};function In(u,g){ko(b,u,g,S({onBack:()=>o==null?void 0:o()},Q&&{onPostReply:Q}));}function Ce(){return b.querySelector('[data-testid="widget-context-strip"]')}function $n(u){let g=Ce();g&&Eo(g,u);}function zn(u,g,x){let k=Ce();k&&To(k,u,g,x);}function Nn(u){let g=Ce();g&&Co(g,u);}function Un(u){let g=Ce();g&&Mo(g,u);}function Fn(){let u=Ce();u&&Lo(u);}function On(u){console.log("[unnoodle] restoreHomeView called with data:",u),bt(u);}function Kt(u){var x;let g=b.querySelector('[data-section="memory"]');if(g){if(g.querySelectorAll(".memory-item, .section-empty, .home-show-more-memories").forEach(k=>k.remove()),u.length===0){let k=document.createElement("div");k.className="section-empty",k.innerHTML=`
2381
+ <div class="section-empty-title">No captures yet.</div>
2382
+ <div class="section-empty-text">Capture elements on this screen so teammates can understand the interface faster.</div>
2383
+ <button class="section-empty-action" data-testid="widget-add-ui-meaning-empty">Add Capture</button>
2384
+ `,(x=k.querySelector('[data-testid="widget-add-ui-meaning-empty"]'))==null||x.addEventListener("click",()=>{d==null||d();}),g.appendChild(k);return}for(let k of u.slice(0,fe)){let T=document.createElement("div");T.className="memory-item",T.setAttribute("data-testid","widget-memory-item"),T.setAttribute("data-ui-state-id",String(k.id));let E=B(k.title),R=wt(k.updatedAt),z=k.entryCount;T.innerHTML=`
2385
+ <div class="memory-item-content">
2386
+ <div class="memory-item-title">${E}</div>
2387
+ <div class="memory-item-meta">${R} \xB7 ${z} ${z===1?"entry":"entries"}</div>
2388
+ </div>
2389
+ <span class="concept-chevron"><svg viewBox="0 0 24 24" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg></span>
2390
+ `,T.addEventListener("click",()=>{p==null||p(k.id);}),g.appendChild(T);}if(u.length>fe){let k=document.createElement("a");k.className="home-show-more home-show-more-memories",k.setAttribute("data-testid","widget-show-all-memories"),k.setAttribute("href","#"),k.textContent=`Show all ${u.length} memories \u2192`,k.addEventListener("click",T=>{T.preventDefault(),P==null||P();}),g.appendChild(k);}}}}var zo=`
2391
+ :host {
2392
+ all: initial;
2393
+ }
2394
+ /* Rail shell \u2014 fixed to right edge, pushes body content like panel-shell */
2395
+ .rail-shell {
2396
+ position: fixed;
2397
+ top: 0;
2398
+ right: 0;
2399
+ bottom: 0;
2400
+ width: 34px;
2401
+ z-index: 2147483647;
2402
+ display: flex;
2403
+ flex-direction: column;
2404
+ padding: 3px;
2405
+ background: var(--unn-color-bg-secondary, #f5f5f7);
2406
+ border-left: 0.5px solid var(--unn-color-border-default, #e0e0e0);
2407
+ box-shadow: inset 6px 0 12px rgba(0,0,0,0.06), inset -4px 0 10px rgba(0,0,0,0.04), inset 0 6px 12px rgba(0,0,0,0.06), inset 0 -4px 10px rgba(0,0,0,0.04);
2408
+ transition: width 0.28s cubic-bezier(0.4,0,0.2,1);
2409
+ box-sizing: border-box;
2410
+ }
2411
+ .rail {
2412
+ flex: 1;
2413
+ width: 100%;
2414
+ background: linear-gradient(160deg, #2c3440 0%, #1a1f27 100%);
2415
+ box-shadow:
2416
+ 0 1px 2px rgba(0,0,0,0.30),
2417
+ 0 3px 8px rgba(0,0,0,0.38),
2418
+ 0 8px 20px rgba(0,0,0,0.22),
2419
+ 0 1px 0 rgba(255,255,255,0.06) inset;
2420
+ border-radius: 6px;
2421
+ display: flex;
2422
+ flex-direction: column;
2423
+ align-items: stretch;
2424
+ box-sizing: border-box;
2425
+ overflow: hidden;
2426
+ }
2427
+ .rail-section {
2428
+ display: flex;
2429
+ flex-direction: column;
2430
+ align-items: center;
2431
+ padding-top: 16px;
2432
+ padding-bottom: 16px;
2433
+ }
2434
+ .rail-identity {
2435
+ margin-bottom: 18px;
2436
+ display: flex;
2437
+ flex-direction: column;
2438
+ align-items: center;
2439
+ }
2440
+ .rail-avatar {
2441
+ width: 28px;
2442
+ height: 28px;
2443
+ border-radius: 50%;
2444
+ background: linear-gradient(160deg, #2c3440 0%, #1a1f27 100%);
2445
+ color: #fff;
2446
+ font-family: var(--unn-font-family, system-ui, sans-serif);
2447
+ font-size: 11px;
2448
+ font-weight: 700;
2449
+ letter-spacing: 0.5px;
2450
+ display: flex;
2451
+ align-items: center;
2452
+ justify-content: center;
2453
+ text-shadow: 0 1px 3px rgba(0,0,0,0.65), 0 -1px 0 rgba(255,255,255,0.10);
2454
+ user-select: none;
2455
+ }
2456
+ .rail-avatar--icon {
2457
+ background: none;
2458
+ width: auto;
2459
+ height: auto;
2460
+ }
2461
+ .rail-core {
2462
+ flex: 1;
2463
+ display: flex;
2464
+ flex-direction: column;
2465
+ align-items: center;
2466
+ gap: 14px;
2467
+ }
2468
+ .rail-item {
2469
+ width: 100%;
2470
+ min-height: 32px;
2471
+ display: flex;
2472
+ align-items: center;
2473
+ justify-content: center;
2474
+ border: none;
2475
+ background: none;
2476
+ cursor: pointer;
2477
+ outline: none;
2478
+ padding: 0;
2479
+ position: relative;
2480
+ transition: background 120ms;
2481
+ }
2482
+ .rail-item.active {
2483
+ background: rgba(255,255,255,0.10);
2484
+ }
2485
+ .rail-item .icon {
2486
+ width: 18px;
2487
+ height: 18px;
2488
+ display: block;
2489
+ transition: transform 120ms, opacity 120ms;
2490
+ fill: #ffffff;
2491
+ opacity: 0.65;
2492
+ }
2493
+ .rail-item.active .icon {
2494
+ opacity: 1;
2495
+ }
2496
+ .rail-item:hover .icon {
2497
+ transform: scale(1.05);
2498
+ opacity: 1;
2499
+ }
2500
+ .rail-item .label {
2501
+ display: none !important;
2502
+ }
2503
+
2504
+ /* Tooltip styles for rail icons */
2505
+ .rail-tooltip {
2506
+ position: absolute;
2507
+ left: 110%;
2508
+ top: 50%;
2509
+ transform: translateY(-50%);
2510
+ background: #222;
2511
+ color: #fff;
2512
+ font-size: 13px;
2513
+ font-family: var(--unn-font-family, system-ui, sans-serif);
2514
+ padding: 4px 10px;
2515
+ border-radius: 4px;
2516
+ white-space: nowrap;
2517
+ box-shadow: 0 2px 8px rgba(0,0,0,0.18);
2518
+ opacity: 0;
2519
+ pointer-events: none;
2520
+ z-index: 10;
2521
+ transition: opacity 0.08s;
2522
+ }
2523
+ .rail-item:hover .rail-tooltip {
2524
+ opacity: 1;
2525
+ pointer-events: auto;
2526
+ }
2527
+ .rail-auth-btn {
2528
+ position: relative;
2529
+ }
2530
+ .rail-auth-btn .rail-tooltip {
2531
+ position: absolute;
2532
+ left: 110%;
2533
+ top: 50%;
2534
+ transform: translateY(-50%);
2535
+ background: #222;
2536
+ color: #fff;
2537
+ font-size: 13px;
2538
+ font-family: var(--unn-font-family, system-ui, sans-serif);
2539
+ padding: 4px 10px;
2540
+ border-radius: 4px;
2541
+ white-space: nowrap;
2542
+ box-shadow: 0 2px 8px rgba(0,0,0,0.18);
2543
+ opacity: 0;
2544
+ pointer-events: none;
2545
+ z-index: 10;
2546
+ transition: opacity 0.08s;
2547
+ }
2548
+ .rail-auth-btn:hover .rail-tooltip {
2549
+ opacity: 1;
2550
+ pointer-events: auto;
2551
+ }
2552
+ .rail-glow {
2553
+ position: absolute;
2554
+ left: 2px;
2555
+ top: 50%;
2556
+ transform: translateY(-50%);
2557
+ width: 28px;
2558
+ height: 28px;
2559
+ border-radius: 50%;
2560
+ background: radial-gradient(circle, #fff 0%, #fff 80%, transparent 100%);
2561
+ opacity: 0.55;
2562
+ filter: blur(4px);
2563
+ z-index: 0;
2564
+ pointer-events: none;
2565
+ animation: rail-glow-pulse 2s infinite alternate;
2566
+ display: none;
2567
+ }
2568
+ .rail-glow.active {
2569
+ display: block;
2570
+ }
2571
+ @keyframes rail-glow-pulse {
2572
+ 0% { opacity: 0.35; }
2573
+ 100% { opacity: 0.6; }
2574
+ }
2575
+
2576
+ .rail-auth {
2577
+ margin-bottom: 12px;
2578
+ display: flex;
2579
+ flex-direction: column;
2580
+ align-items: center;
2581
+ }
2582
+ .rail-auth-btn {
2583
+ width: 100%;
2584
+ min-height: 32px;
2585
+ display: flex;
2586
+ align-items: center;
2587
+ justify-content: center;
2588
+ border: none;
2589
+ background: none;
2590
+ cursor: pointer;
2591
+ outline: none;
2592
+ padding: 0;
2593
+ font-family: var(--unn-font-family, system-ui, sans-serif);
2594
+ font-size: 14px;
2595
+ font-weight: 400;
2596
+ color: #222;
2597
+ transition: background 120ms;
2598
+ }
2599
+ .rail-auth-btn .icon {
2600
+ width: 18px;
2601
+ height: 18px;
2602
+ display: block;
2603
+ transition: transform 120ms;
2604
+ fill: #ffffff;
2605
+ }
2606
+ .rail-auth-btn:hover .icon {
2607
+ transform: scale(1.05);
2608
+ }
2609
+ .rail-auth-btn .label {
2610
+ opacity: 0;
2611
+ margin-left: 16px;
2612
+ font-size: 14px;
2613
+ font-weight: 400;
2614
+ color: #fff;
2615
+ white-space: nowrap;
2616
+ pointer-events: none;
2617
+ transition: opacity 150ms;
2618
+ }
2619
+ .rail:hover .rail-auth-btn .label {
2620
+ opacity: 1;
2621
+ pointer-events: auto;
2622
+ }
2623
+
2624
+ /* ---- Brand icon (U\u2229) at top of rail ---- */
2625
+ .rail-brand {
2626
+ padding-top: 7px;
2627
+ padding-bottom: 2px;
2628
+ flex-shrink: 0;
2629
+ }
2630
+ `;function Ft(i){let e=document.createElement("div");if(e.className="rail-identity rail-section",i){let t=document.createElement("div");t.className="rail-avatar",t.textContent=i,t.style.position="relative";let n=document.createElement("span");n.className="rail-tooltip",n.textContent="Profile",t.appendChild(n),e.appendChild(t);}else {let t=document.createElement("button");t.className="rail-item",t.type="button",t.tabIndex=0,t.innerHTML='<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#ffffff" viewBox="0 0 256 256"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24ZM74.08,197.5a64,64,0,0,1,107.84,0,87.83,87.83,0,0,1-107.84,0ZM96,120a32,32,0,1,1,32,32A32,32,0,0,1,96,120Zm97.76,66.41a79.66,79.66,0,0,0-36.06-28.75,48,48,0,1,0-59.4,0,79.66,79.66,0,0,0-36.06,28.75,88,88,0,1,1,131.52,0Z"></path></svg>';let n=document.createElement("span");n.className="rail-tooltip",n.textContent="Profile",t.appendChild(n),e.appendChild(t);}return e}function Ot(i,e){let t=document.createElement("div");t.className="rail-core rail-section";let n={house:'<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#ffffff" viewBox="0 0 256 256"><path d="M240,208H224V136l2.34,2.34A8,8,0,0,0,237.66,127L139.31,28.68a16,16,0,0,0-22.62,0L18.34,127a8,8,0,0,0,11.32,11.31L32,136v72H16a8,8,0,0,0,0,16H240a8,8,0,0,0,0-16ZM48,120l80-80,80,80v88H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48Zm96,88H112V160h32Z"></path></svg>',brain:'<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#ffffff" viewBox="0 0 256 256"><path d="M248,124a56.11,56.11,0,0,0-32-50.61V72a48,48,0,0,0-88-26.49A48,48,0,0,0,40,72v1.39a56,56,0,0,0,0,101.2V176a48,48,0,0,0,88,26.49A48,48,0,0,0,216,176v-1.41A56.09,56.09,0,0,0,248,124ZM88,208a32,32,0,0,1-31.81-28.56A55.87,55.87,0,0,0,64,180h8a8,8,0,0,0,0-16H64A40,40,0,0,1,50.67,86.27,8,8,0,0,0,56,78.73V72a32,32,0,0,1,64,0v68.26A47.8,47.8,0,0,0,88,128a8,8,0,0,0,0,16,32,32,0,0,1,0,64Zm104-44h-8a8,8,0,0,0,0,16h8a55.87,55.87,0,0,0,7.81-.56A32,32,0,1,1,168,144a8,8,0,0,0,0-16,47.8,47.8,0,0,0-32,12.26V72a32,32,0,0,1,64,0v6.73a8,8,0,0,0,5.33,7.54A40,40,0,0,1,192,164Zm16-52a8,8,0,0,1-8,8h-4a36,36,0,0,1-36-36V80a8,8,0,0,1,16,0v4a20,20,0,0,0,20,20h4A8,8,0,0,1,208,112ZM60,120H56a8,8,0,0,1,0-16h4A20,20,0,0,0,80,84V80a8,8,0,0,1,16,0v4A36,36,0,0,1,60,120Z"></path></svg>',book:'<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#ffffff" viewBox="0 0 256 256"><path d="M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64ZM160,88h40a8,8,0,0,1,0,16H160a8,8,0,0,1,0-16Zm48,40a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,128Zm0,32a8,8,0,0,1-8,8H160a8,8,0,0,1,0-16h40A8,8,0,0,1,208,160Z"></path></svg>',question:'<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#ffffff" viewBox="0 0 256 256"><path d="M225.86,102.82c-3.77-3.94-7.67-8-9.14-11.57-1.36-3.27-1.44-8.69-1.52-13.94-.15-9.76-.31-20.82-8-28.51s-18.75-7.85-28.51-8c-5.25-.08-10.67-.16-13.94-1.52-3.56-1.47-7.63-5.37-11.57-9.14C146.28,23.51,138.44,16,128,16s-18.27,7.51-25.18,14.14c-3.94,3.77-8,7.67-11.57,9.14C88,40.64,82.56,40.72,77.31,40.8c-9.76.15-20.82.31-28.51,8S41,67.55,40.8,77.31c-.08,5.25-.16,10.67-1.52,13.94-1.47,3.56-5.37,7.63-9.14,11.57C23.51,109.72,16,117.56,16,128s7.51,18.27,14.14,25.18c3.77,3.94,7.67,8,9.14,11.57,1.36,3.27,1.44,8.69,1.52,13.94.15,9.76.31,20.82,8,28.51s18.75,7.85,28.51,8c5.25.08,10.67.16,13.94,1.52,3.56,1.47,7.63,5.37,11.57,9.14C109.72,232.49,117.56,240,128,240s18.27-7.51,25.18-14.14c3.94-3.77,8-7.67,11.57-9.14,3.27-1.36,8.69-1.44,13.94-1.52,9.76-.15,20.82-.31,28.51-8s7.85-18.75,8-28.51c.08-5.25.16-10.67,1.52-13.94,1.47-3.56,5.37-7.63,9.14-11.57C232.49,146.28,240,138.44,240,128S232.49,109.73,225.86,102.82Zm-11.55,39.29c-4.79,5-9.75,10.17-12.38,16.52-2.52,6.1-2.63,13.07-2.73,19.82-.1,7-.21,14.33-3.32,17.43s-10.39,3.22-17.43,3.32c-6.75.1-13.72.21-19.82,2.73-6.35,2.63-11.52,7.59-16.52,12.38S132,224,128,224s-9.15-4.92-14.11-9.69-10.17-9.75-16.52-12.38c-6.1-2.52-13.07-2.63-19.82-2.73-7-.1-14.33-.21-17.43-3.32s-3.22-10.39-3.32-17.43c-.1-6.75-.21-13.72-2.73-19.82-2.63-6.35-7.59-11.52-12.38-16.52S32,132,32,128s4.92-9.15,9.69-14.11,9.75-10.17,12.38-16.52c2.52-6.1,2.63-13.07,2.73-19.82.1-7,.21-14.33,3.32-17.43S70.51,56.9,77.55,56.8c6.75-.1,13.72-.21,19.82-2.73,6.35-2.63,11.52-7.59,16.52-12.38S124,32,128,32s9.15,4.92,14.11,9.69,10.17,9.75,16.52,12.38c6.1,2.52,13.07,2.63,19.82,2.73,7,.1,14.33.21,17.43,3.32s3.22,10.39,3.32,17.43c.1,6.75.21,13.72,2.73,19.82,2.63,6.35,7.59,11.52,12.38,16.52S224,124,224,128,219.08,137.15,214.31,142.11ZM140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180Zm28-72c0,17.38-13.76,31.93-32,35.28V144a8,8,0,0,1-16,0v-8a8,8,0,0,1,8-8c13.23,0,24-9,24-20s-10.77-20-24-20-24,9-24,20v4a8,8,0,0,1-16,0v-4c0-19.85,17.94-36,40-36S168,88.15,168,108Z"></path></svg>'};return [{key:"overview",icon:n.house,label:"Overview",cb:e.onOverview},{key:"memory",icon:n.brain,label:"Memory",cb:e.onMemory},{key:"vocabulary",icon:n.book,label:"Vocabulary",cb:e.onVocabulary},{key:"clarifications",icon:n.question,label:"Clarifications",cb:e.onClarifications}].forEach(r=>{let s=document.createElement("button");s.className="rail-item"+(i.activeSection===r.key?" active":""),s.type="button",s.tabIndex=0,s.innerHTML=(r.key==="memory"?`<div class="rail-glow${i.hasMemoryGlow?" active":""}"></div>`:"")+r.icon;let a=document.createElement("span");a.className="rail-tooltip",a.textContent=r.label,s.appendChild(a),s.addEventListener("click",r.cb),t.appendChild(s);}),t}function qt(i,e){let t=document.createElement("div");t.className="rail-auth rail-section";let n=document.createElement("button");n.className="rail-auth-btn",n.type="button",n.tabIndex=0;let o,r;i?(o='<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#ffffff" viewBox="0 0 256 256"><path d="M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z"></path></svg>',r="Logout",n.addEventListener("click",e.onLogout)):(o='<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#ffffff" viewBox="0 0 256 256"><path d="M141.66,133.66l-40,40a8,8,0,0,1-11.32-11.32L116.69,136H24a8,8,0,0,1,0-16h92.69L90.34,93.66a8,8,0,0,1,11.32-11.32l40,40A8,8,0,0,1,141.66,133.66ZM200,32H136a8,8,0,0,0,0,16h56V208H136a8,8,0,0,0,0,16h64a8,8,0,0,0,8-8V40A8,8,0,0,0,200,32Z"></path></svg>',r="Login",n.addEventListener("click",e.onLogin)),n.innerHTML=o;let s=document.createElement("span");return s.className="rail-tooltip",s.textContent=r,n.appendChild(s),t.appendChild(n),t}function No(i,e){let t=document.createElement("div");t.id="unnoodle-rail-host";let n=t.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent=zo,n.appendChild(o);let r=Ft(i.initials),s=Ot({activeSection:i.activeSection,hasMemoryGlow:i.hasMemoryGlow},e),a=qt(i.isLoggedIn,e),c=document.createElement("div");c.className="rail-shell";let d=document.createElement("nav");d.className="rail",d.appendChild(r),d.appendChild(s),d.appendChild(a),c.appendChild(d),n.appendChild(c);let l=34;document.body.style.transition="margin-right 0.28s cubic-bezier(0.4,0,0.2,1)",document.body.style.marginRight=`${l}px`;function p(m){var v,f,y,A;d.removeChild(r),d.removeChild(s),d.removeChild(a),r=Ft((v=m.initials)!=null?v:i.initials),s=Ot({activeSection:(f=m.activeSection)!=null?f:i.activeSection,hasMemoryGlow:(y=m.hasMemoryGlow)!=null?y:i.hasMemoryGlow},e),a=qt((A=m.isLoggedIn)!=null?A:i.isLoggedIn,e),d.appendChild(r),d.appendChild(s),d.appendChild(a),Object.assign(i,m);}function h(){t.remove(),document.body.style.marginRight="";}return {element:t,setState:p,cleanup:h}}function Uo(i,e,t,n,o,r,s,a,c,d,l,p,h,m,v,f,y,A,L,N,U,F,Q,_,C,$,Y,H,P,O){let I=Ut(e,t,n,o,r,s,a,c,d,l,p,h,m,v,f,y,A,L,N,U,F,Q,_,C,$,Y,H,P,O),X=fo(i,A);document.body.appendChild(I.element),document.body.appendChild(X.element);let j=()=>{X.cleanup(),I.cleanup();};return {panel:I,setProgress:X.setProgress,cleanup:j}}function Fo(i,e,t){let n=Ut(...t),o=No(i,e);document.body.appendChild(n.element),document.body.appendChild(o.element);let r=()=>{o.cleanup(),n.cleanup();};return {panel:n,setRailState:o.setState,cleanup:r}}var zi=new Set(["INPUT","TEXTAREA","SCRIPT","STYLE","CODE","PRE","KBD","SAMP","VAR","NOSCRIPT","BUTTON","SELECT","OPTION","OPTGROUP"]),Ni=new Set(["unnoodle-panel-host","unnoodle-btn-host"]),Oo="unnoodle-highlight",Ui=["border-bottom: 1px dotted currentColor","cursor: pointer","opacity: 0.85","text-decoration: none"].join("; ");function qo(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var gt=class{constructor(e){this.highlights=[];this.onTermClick=e;}apply(e){this.remove();let t=e.filter(r=>r.status==="ACTIVE");if(t.length===0)return;let{regex:n,termMap:o}=this.buildPattern(t);this.walkAndHighlight(document.body,n,o);}remove(){var e;for(let t=this.highlights.length-1;t>=0;t--){let n=this.highlights[t],o=n.parentNode;o&&(o.replaceChild(document.createTextNode((e=n.textContent)!=null?e:""),n),o.normalize());}this.highlights=[];}buildPattern(e){let t=new Map,n=[...e].sort((s,a)=>a.term.length-s.term.length),o=[];for(let s of n){let a=s.term.toLowerCase();if(t.has(a)||(t.set(a,s),o.push(qo(s.term))),s.abbreviation){let c=s.abbreviation.toLowerCase();t.has(c)||(t.set(c,s),o.push(qo(s.abbreviation)));}}return o.length===0?{regex:/(?!)/g,termMap:t}:{regex:new RegExp(`\\b(${o.join("|")})\\b`,"gi"),termMap:t}}walkAndHighlight(e,t,n){if(e.nodeType===Node.ELEMENT_NODE){let o=e;if(Ni.has(o.id)||o.classList.contains(Oo)||o.getAttribute("contenteditable")!=null||zi.has(o.tagName))return;for(let r of Array.from(o.childNodes))this.walkAndHighlight(r,t,n);}else e.nodeType===Node.TEXT_NODE&&this.highlightTextNode(e,t,n);}highlightTextNode(e,t,n){var l;let o=(l=e.textContent)!=null?l:"";if(!o.trim())return;t.lastIndex=0;let r=[],s=0,a;for(;(a=t.exec(o))!==null;){let p=a[0],h=n.get(p.toLowerCase());if(!h)continue;a.index>s&&r.push(o.slice(s,a.index));let m=document.createElement("span");m.className=Oo,m.dataset.termId=String(h.id),m.textContent=p,m.title=h.definition.length>120?`${h.definition.slice(0,120)}\u2026`:h.definition,m.style.cssText=Ui,m.addEventListener("click",v=>{v.stopPropagation(),this.onTermClick(h);}),r.push(m),this.highlights.push(m),s=a.index+p.length;}if(r.length===0)return;r.push(o.slice(s));let c=e.parentNode;if(!c)return;let d=e.nextSibling;c.removeChild(e);for(let p of r)typeof p=="string"?p&&c.insertBefore(document.createTextNode(p),d):c.insertBefore(p,d);}};var _o=new Set(["INPUT","TEXTAREA","SCRIPT","STYLE","CODE","PRE","KBD","SAMP","VAR","NOSCRIPT","BUTTON","SELECT","OPTION","OPTGROUP"]),Go=new Set(["unnoodle-panel-host","unnoodle-btn-host"]),Fi=5,Oi=2,qi=new Set(["The","This","These","Those","That","Then","There","They","Their","When","Where","What","Why","How","With","From","Into","Has","Have","Was","Were","For","But","And","Or","In","On","At","By","Us","We","He","She","It","Our","Its","You","Your","His","Her","An","As","Be","Do","To","If","Of","So","Up","I"]),ft=class{scan(e){var a;let t=this.buildGlossarySet(e),n=this.extractText(document.body),o=new Map,r=/[A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*/g,s;for(;(s=r.exec(n))!==null;){let c=s[0].split(/\s+/);for(let d=0;d<c.length;d++)if(!qi.has(c[d]))for(let l=1;l<=Math.min(3,c.length-d);l++){let p=c.slice(d,d+l).join(" ");p.length<2||t.has(p.toLowerCase())||o.set(p,((a=o.get(p))!=null?a:0)+1);}}return [...o.entries()].filter(([,c])=>c>=Oi).sort((c,d)=>d[1]-c[1]).slice(0,Fi).map(([c,d])=>({term:c,count:d}))}getPageContext(e){var o;let t=e.toLowerCase(),n=Array.from(document.body.querySelectorAll("p, li, blockquote, td, section, article"));for(let r of n){if(_o.has(r.tagName)||Go.has(r.id))continue;let s=(o=r.textContent)!=null?o:"";if(s.toLowerCase().includes(t))return s.slice(0,500).trim()}return ""}buildGlossarySet(e){let t=new Set;for(let n of e)t.add(n.term.toLowerCase()),n.abbreviation&&t.add(n.abbreviation.toLowerCase());return t}extractText(e){var t;if(e.nodeType===Node.ELEMENT_NODE){let n=e;return Go.has(n.id)||_o.has(n.tagName)||n.getAttribute("contenteditable")!=null?"":Array.from(n.childNodes).map(o=>this.extractText(o)).join(" ")}return e.nodeType===Node.TEXT_NODE&&(t=e.textContent)!=null?t:""}};var vt=class{constructor(e){this.ui=null;this.rail=null;this.isOpen=false;this.isFetching=false;this.keydownHandler=null;this.authToken=null;this.tokenExpiryTimer=null;this.cachedResponse=null;this.cachedDiscussions=null;this.cachedHomeMemories=null;this.highlighter=null;this.suggester=null;this.captureModeController=null;this.activeSuggestion=null;this.ssoProviders=null;this.ssoPopupCleanup=null;this.fuseIndex=null;this.currentTerm=null;this.currentDiscussion=null;this.currentMemory=null;this.memories=[];this.memoriesPage=0;this.hasMoreMemories=false;this.pendingAction=null;this.sessionKey="unnoodle_jwt";this.config=e;}getUserInitials(){let e=this.config.userName,t=this.config.userEmail;if(!e&&this.authToken)try{let n=this.authToken;if(n){let o=n.split(".");if(o.length===3&&typeof o[1]=="string"){let r=JSON.parse(atob(o[1]));e=r.name,t=r.email;}}}catch(n){}if(e){let n=e.trim().split(" ");if(n.length===1)return n[0]&&n[0][0]?n[0][0].toUpperCase():"?";let o=n[0]&&n[0][0]?n[0][0]:"",r=n[n.length-1],s=r&&r[0]?r[0]:"";return (o+s).toUpperCase()||"?"}return t&&t[0]?t[0].toUpperCase():"?"}init(){var t,n;if(!this.config)throw new Error("WidgetController: config is not set");let e=(t=this.config.theme)==null?void 0:t.shadowTokens;if(this.config.useRail){let o=!!this.resolveToken(),r=o?this.getUserInitials():null,s={isLoggedIn:o,initials:r,activeSection:"overview",hasMemoryGlow:false},a={onOverview:()=>this.open(),onMemory:()=>{var p,h,m,v,f,y;this.isOpen||this.open();let l=!!this.resolveToken();(p=this.cachedResponse)!=null&&p.productMemories?(h=this.ui)==null||h.panel.showAllMemories(this.cachedResponse.productMemories,l):this.cachedHomeMemories?(m=this.ui)==null||m.panel.showAllMemories(this.cachedHomeMemories,l):(y=(v=this.ui)==null?void 0:(f=v.panel).showAllMemories)==null||y.call(f,[],l);},onVocabulary:()=>{var l,p,h,m;this.isOpen||this.open(),this.cachedResponse?(l=this.ui)==null||l.panel.showAllConcepts(this.cachedResponse.glossary):(m=(p=this.ui)==null?void 0:(h=p.panel).showAllConcepts)==null||m.call(h,[]);},onClarifications:()=>{var p,h,m,v;this.isOpen||this.open();let l=!!this.resolveToken();this.cachedDiscussions?(p=this.ui)==null||p.panel.showAllClarifications(this.cachedDiscussions,l):(v=(h=this.ui)==null?void 0:(m=h.panel).showAllClarifications)==null||v.call(m,[],l);},onLogin:()=>{var l;this.isOpen||(this.isOpen=true,(l=this.ui)==null||l.panel.show()),this.showLoginWithProviders();},onLogout:()=>{this.clearAuthToken(),this.showLoginWithProviders();}},c=[(l,p)=>this.handleLogin(l,p),l=>this.handleSearch(l),this.config.workspaceUrl,()=>{var l;this.isOpen=false,(l=this.highlighter)==null||l.remove();},()=>this.handleBack(),(l,p)=>this.handleAddComment(l,p),(l,p)=>this.handleEditTerm(l,p),l=>this.handleTermClick(l),l=>this.handleRequestEdit(l),()=>{var l;this.resolveToken()?(l=this.captureModeController)==null||l.start():this.showLoginWithProviders();},()=>{this.loadMemories(0,false);},l=>{this.handleViewMemoryDetail(l);},(l,p,h)=>{this.handleUpdateEntryExplanation(l,p,h);},()=>{var l;this.isOpen=false,(l=this.highlighter)==null||l.remove();},()=>{this.isOpen=false;},l=>{this.handleSsoLogin(l);},e,(l,p)=>{this.handleAskQuestion(l,p);},()=>{this.resolveToken()||this.showLoginWithProviders();},(l,p)=>{this.handleCreateTerm(l,p);},()=>{var l,p;this.cachedResponse&&((l=this.ui)==null||l.panel.showSearchResults(this.cachedResponse.glossary,""),(p=this.ui)==null||p.panel.setAuthenticated(!!this.resolveToken()));},l=>{this.handleClarificationClick(l);},(l,p,h)=>{this.handlePostReply(l,p,h);},l=>{this.handleAddEntryToMemory(l);},l=>{this.handleDeleteMemory(l);},(l,p)=>{this.handleDeleteEntry(l,p);},()=>{var l;this.cachedResponse&&((l=this.ui)==null||l.panel.showAllConcepts(this.cachedResponse.glossary));},()=>{var l;this.cachedDiscussions&&((l=this.ui)==null||l.panel.showAllClarifications(this.cachedDiscussions,!!this.resolveToken()));},()=>{var l,p;(l=this.cachedResponse)!=null&&l.productMemories&&((p=this.ui)==null||p.panel.showAllMemories(this.cachedResponse.productMemories,!!this.resolveToken()));}],d=Fo(s,a,c);this.ui={panel:d.panel,setProgress:()=>{},cleanup:d.cleanup},this.rail=d;}else this.ui=Uo(()=>this.toggle(),(o,r)=>this.handleLogin(o,r),o=>this.handleSearch(o),this.config.workspaceUrl,()=>{var o;this.isOpen=false,(o=this.highlighter)==null||o.remove();},()=>this.handleBack(),(o,r)=>this.handleAddComment(o,r),(o,r)=>this.handleEditTerm(o,r),o=>this.handleTermClick(o),o=>this.handleRequestEdit(o),()=>{var o;console.log("[unnoodle] onCaptureUiState callback triggered",{captureModeController:!!this.captureModeController,ui:!!this.ui}),this.resolveToken()?(o=this.captureModeController)==null||o.start():this.showLoginWithProviders();},()=>{this.loadMemories(0,false);},o=>{this.handleViewMemoryDetail(o);},(o,r,s)=>{this.handleUpdateEntryExplanation(o,r,s);},()=>{var o;this.isOpen=false,(o=this.highlighter)==null||o.remove();},()=>{this.isOpen=false;},o=>{this.handleSsoLogin(o);},e,(o,r)=>{this.handleAskQuestion(o,r);},()=>{this.resolveToken()||this.showLoginWithProviders();},(o,r)=>{this.handleCreateTerm(o,r);},()=>{var o,r;this.cachedResponse&&((o=this.ui)==null||o.panel.showSearchResults(this.cachedResponse.glossary,""),(r=this.ui)==null||r.panel.setAuthenticated(!!this.resolveToken()));},o=>{this.handleClarificationClick(o);},(o,r,s)=>{this.handlePostReply(o,r,s);},o=>{this.handleAddEntryToMemory(o);},o=>{this.handleDeleteMemory(o);},(o,r)=>{this.handleDeleteEntry(o,r);},()=>{var o;console.log("DEBUG: onShowAllConcepts called, cachedResponse:",!!this.cachedResponse),this.cachedResponse&&(console.log("DEBUG: Calling showAllConcepts with",this.cachedResponse.glossary.length,"terms"),(o=this.ui)==null||o.panel.showAllConcepts(this.cachedResponse.glossary));},()=>{var o;console.log("DEBUG: onShowAllClarifications called, cachedDiscussions:",!!this.cachedDiscussions),this.cachedDiscussions&&(console.log("DEBUG: Calling showAllClarifications with",this.cachedDiscussions.length,"discussions"),(o=this.ui)==null||o.panel.showAllClarifications(this.cachedDiscussions,!!this.resolveToken()));},()=>{var o,r,s,a;console.log("DEBUG: onShowAllMemories called",{hasCachedResponse:!!this.cachedResponse,hasResponseMemories:!!((o=this.cachedResponse)!=null&&o.productMemories),hasCachedHomeMemories:!!this.cachedHomeMemories}),(r=this.cachedResponse)!=null&&r.productMemories?(console.log("DEBUG: Using cached memories from main response",this.cachedResponse.productMemories.length),(s=this.ui)==null||s.panel.showAllMemories(this.cachedResponse.productMemories,!!this.resolveToken())):this.cachedHomeMemories?(console.log("DEBUG: Using cached memories from separate cache",this.cachedHomeMemories.length),(a=this.ui)==null||a.panel.showAllMemories(this.cachedHomeMemories,!!this.resolveToken())):(console.log("DEBUG: No cached memories, fetching via API"),this.loadAllMemories());});if(this.captureModeController=zt(this.ui.panel,this.config,()=>this.resolveToken(),()=>{var o,r;return (r=(o=this.cachedResponse)==null?void 0:o.glossary)!=null?r:[]},()=>{this.loadHomeMemoryItems();}),this.keydownHandler=o=>{(o.metaKey||o.ctrlKey)&&o.key==="u"&&(o.preventDefault(),this.toggle());},document.addEventListener("keydown",this.keydownHandler),this.highlighter=new gt(o=>this.handleTermClick(o)),this.suggester=new ft,this.config._plugins)for(let o of this.config._plugins)try{(n=o.onInit)==null||n.call(o,this.config);}catch(r){}}open(){this.isOpen||!this.ui||(this.isOpen=true,this.ui.panel.show(),this.loadTerms());}close(){var e;!this.isOpen||!this.ui||(this.isOpen=false,(e=this.highlighter)==null||e.remove(),this.ui.panel.hide());}toggle(){this.isOpen?this.close():this.open();}setProgress(e){var t;(t=this.ui)==null||t.setProgress(e);}destroy(){var e,t,n;this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.tokenExpiryTimer!==null&&(clearTimeout(this.tokenExpiryTimer),this.tokenExpiryTimer=null),(e=this.highlighter)==null||e.remove(),this.highlighter=null,this.suggester=null,this.captureModeController=null,this.activeSuggestion=null,this.ssoProviders=null,(t=this.ssoPopupCleanup)==null||t.call(this),this.ssoPopupCleanup=null,(n=this.ui)==null||n.cleanup(),this.ui=null,this.authToken=null,this.cachedResponse=null,this.cachedDiscussions=null,this.cachedHomeMemories=null,this.fuseIndex=null,this.currentTerm=null,this.pendingAction=null;try{sessionStorage.removeItem(this.sessionKey);}catch(o){}}resolveToken(){var e;return this.authToken?this.authToken:typeof this.config.getAuthToken=="function"&&(e=this.config.getAuthToken())!=null?e:null}clearAuthToken(){this.authToken=null;try{sessionStorage.removeItem(this.sessionKey);}catch(e){}}scheduleTokenExpiry(e){this.tokenExpiryTimer!==null&&(clearTimeout(this.tokenExpiryTimer),this.tokenExpiryTimer=null);try{let t=e.split(".");if(t.length!==3)return;let n=t[1];if(!n)return;let o=n.replace(/-/g,"+").replace(/_/g,"/"),r=JSON.parse(atob(o));if(typeof r.exp!="number")return;let a=r.exp*1e3-Date.now();if(a<=0){this.clearAuthToken();return}this.tokenExpiryTimer=setTimeout(()=>{this.tokenExpiryTimer=null,this.clearAuthToken(),this.isOpen&&this.ui&&this.showLoginWithProviders();},a);}catch(t){}}async showLoginWithProviders(){this.ui&&(this.ssoProviders||(this.ssoProviders=await je(this.config)),this.ui&&this.ui.panel.showLogin(this.ssoProviders));}handleSsoLogin(e){var c,d,l;if(!this.ui)return;let t=(d=(c=this.config.baseUrl)==null?void 0:c.replace(/\/$/,""))!=null?d:"https://api.unnoodle.com",n=`${t}/api/auth/oauth/${e}?widget=true`,o=window.open(n,"unnoodle-sso","width=500,height=650,scrollbars=yes,resizable=yes");(l=this.ssoPopupCleanup)==null||l.call(this),this.ssoPopupCleanup=null;let r=()=>{clearInterval(a),window.removeEventListener("message",s),this.ssoPopupCleanup=null;},s=p=>{try{let m=new URL(t).origin;if(p.origin!==m)return}catch(m){}if(!p.data||typeof p.data!="object"||p.data.type!=="unnoodle-oauth-token"||typeof p.data.token!="string")return;r();let h=p.data.token;if(h){this.authToken=h;try{sessionStorage.setItem(this.sessionKey,h);}catch(m){}if(this.scheduleTokenExpiry(h),o==null||o.close(),this.pendingAction){let m=this.pendingAction;this.pendingAction=null,m();}else this.fetchTerms(h);}},a=setInterval(()=>{o!=null&&o.closed&&r();},500);this.ssoPopupCleanup=r,window.addEventListener("message",s);}loadTerms(){var e,t,n,o,r,s,a;if(this.cachedResponse){(e=this.ui)==null||e.panel.showTerms(this.cachedResponse),(t=this.captureModeController)==null||t.setHomeData(this.cachedResponse),(n=this.highlighter)==null||n.apply(this.cachedResponse.glossary),this.showSuggestions(this.cachedResponse.glossary),this.cachedResponse.clarifications!==void 0?(console.log("[DEBUG] Loading clarifications from main response cache",this.cachedResponse.clarifications.length),this.cachedDiscussions=this.cachedResponse.clarifications,(o=this.ui)==null||o.panel.loadClarifications(this.cachedResponse.clarifications,!!this.resolveToken())):this.cachedDiscussions?(r=this.ui)==null||r.panel.loadClarifications(this.cachedDiscussions,!!this.resolveToken()):this.fetchDiscussions(this.cachedResponse.context.id),this.cachedResponse.productMemories!==void 0?(console.log("[DEBUG] Loading memories from main response cache",this.cachedResponse.productMemories.length),this.cachedHomeMemories=this.cachedResponse.productMemories,(s=this.ui)==null||s.panel.showHomeMemoryItems(this.cachedResponse.productMemories)):this.cachedHomeMemories?(console.log("[DEBUG] Using cached home memories from separate cache",this.cachedHomeMemories.length),(a=this.ui)==null||a.panel.showHomeMemoryItems(this.cachedHomeMemories)):this.loadHomeMemoryItems();return}this.fetchTerms(this.resolveToken());}async handleLogin(e,t){var n;if(this.ui){this.ui.panel.setLoginLoading(true);try{let o=await We(this.config,{email:e,password:t});this.authToken=o.token;try{sessionStorage.setItem(this.sessionKey,o.token);}catch(r){}if(this.scheduleTokenExpiry(o.token),this.pendingAction){let r=this.pendingAction;this.pendingAction=null,r();}else await this.fetchTerms(o.token);}catch(o){let r=o instanceof D&&o.status===401?"Invalid email or password.":"Login failed. Please try again.";this.ui.panel.setLoginError(r);}finally{(n=this.ui)==null||n.panel.setLoginLoading(false);}}}async handleTermClick(e){if(!this.ui)return;this.currentTerm=e;let t=this.resolveToken();this.ui.panel.setLoading();try{let n=await He(this.config,e.id,t!=null?t:void 0);this.ui&&this.ui.panel.showTermDetail(e,n,{showEdit:!0});}catch(n){this.ui&&this.ui.panel.showTermDetail(e,[],{showEdit:true});}}handleBack(){var e;!this.ui||!this.cachedResponse||(this.currentTerm=null,this.pendingAction=null,this.ui.panel.showTerms(this.cachedResponse),(e=this.captureModeController)==null||e.setHomeData(this.cachedResponse),this.cachedResponse.clarifications!==void 0?(this.cachedDiscussions=this.cachedResponse.clarifications,this.ui.panel.loadClarifications(this.cachedResponse.clarifications,!!this.resolveToken())):this.cachedDiscussions&&this.ui.panel.loadClarifications(this.cachedDiscussions,!!this.resolveToken()),this.cachedResponse.productMemories!==void 0?(this.cachedHomeMemories=this.cachedResponse.productMemories,this.ui.panel.showHomeMemoryItems(this.cachedResponse.productMemories)):this.cachedHomeMemories?this.ui.panel.showHomeMemoryItems(this.cachedHomeMemories):this.loadHomeMemoryItems());}handleAddComment(e,t){this.ui&&(t?this.submitComment(e,t):this.resolveToken()?this.ui.panel.showCommentForm(e):(this.pendingAction=()=>{var o;return (o=this.ui)==null?void 0:o.panel.showCommentForm(e)},this.showLoginWithProviders()));}handleRequestEdit(e){var o,r,s;if(!this.ui)return;let t=(s=(r=this.currentTerm)!=null?r:(o=this.cachedResponse)==null?void 0:o.glossary.find(a=>a.id===e))!=null?s:null;if(!t)return;this.resolveToken()?this.ui.panel.showEditForm(t):(this.pendingAction=()=>{var a;return (a=this.ui)==null?void 0:a.panel.showEditForm(t)},this.showLoginWithProviders());}handleEditTerm(e,t){this.submitEdit(e,t);}async submitComment(e,t){var o,r;let n=this.resolveToken();if(!(!n||!this.ui)){this.ui.panel.setCommentLoading(true);try{await Ze(this.config,e,t,n);let s=await He(this.config,e,n);this.ui&&this.currentTerm&&this.ui.panel.showTermDetail(this.currentTerm,s,{showEdit:!0});}catch(s){let a=s instanceof D?s.message:"Failed to post comment. Please try again.";(o=this.ui)==null||o.panel.setCommentError(a);}finally{(r=this.ui)==null||r.panel.setCommentLoading(false);}}}async submitEdit(e,t){var o,r;let n=this.resolveToken();if(!(!n||!this.ui)){this.ui.panel.setEditLoading(true);try{await Ke(this.config,e,t,n),this.cachedResponse=null,this.fuseIndex=null,await this.fetchTerms(n);}catch(s){let a=s instanceof D?s.message:"Failed to update term. Please try again.";(o=this.ui)==null||o.panel.setEditError(a);}finally{(r=this.ui)==null||r.panel.setEditLoading(false);}}}async fetchTerms(e){var t,n,o,r;if(!(this.isFetching||!this.ui)){this.isFetching=true,this.setProgress(true),this.ui.panel.setLoading();try{let s=await Ge(this.config,e);if(this.cachedResponse=s,(t=this.highlighter)==null||t.apply(s.glossary),this.config._plugins)for(let a of this.config._plugins)try{(n=a.onResponse)==null||n.call(a,s);}catch(c){}if(this.ui){if(this.ui.panel.showTerms(s),(o=this.captureModeController)==null||o.setHomeData(s),this.showSuggestions(s.glossary),this.ui.panel.setAuthenticated(!!this.resolveToken()),s.clarifications!==void 0){let a=s.clarifications.slice(0,5);this.cachedDiscussions=a,this.cachedResponse.clarifications=a,this.ui.panel.loadClarifications(a,!!this.resolveToken());}else this.fetchDiscussions(s.context.id);if(s.productMemories!==void 0){let a=s.productMemories.slice(0,5);this.cachedHomeMemories=a,this.cachedResponse.productMemories=a,this.ui.panel.showHomeMemoryItems(a);}else this.loadHomeMemoryItems();}}catch(s){let a=s instanceof Error?s:new Error(String(s));if(this.config._plugins)for(let c of this.config._plugins)try{(r=c.onError)==null||r.call(c,a);}catch(d){}this.ui&&this.ui.panel.setError("Could not load terms. Please check your connection and try again.");}finally{this.isFetching=false,this.setProgress(false);}}}async fetchDiscussions(e){if(this.ui)try{let n=(await Pe(this.config,e,this.resolveToken())).slice(0,5);this.cachedDiscussions=n,this.cachedResponse&&(this.cachedResponse.clarifications=n),this.ui.panel.loadClarifications(n,!!this.resolveToken());}catch(t){this.ui&&this.ui.panel.loadClarifications([],!!this.resolveToken());}}async handleCreateTerm(e,t){let n=this.resolveToken();if(!(!n||!this.ui||!this.cachedResponse))try{await Je(this.config,this.cachedResponse.context.id,e,t,n),await this.fetchTerms(n);}catch(o){let r=o instanceof D?o.message:"Failed to add term. Please try again.";this.ui.panel.showToast(r);}}async handleAskQuestion(e,t){let n=this.resolveToken();if(!(!n||!this.ui))try{await rt(this.config,e,t,n),await this.fetchDiscussions(e);}catch(o){let r=o instanceof D?o.message:"Failed to post question. Please try again.";this.ui.panel.showToast(r);}}handleClarificationClick(e){if(!this.ui)return;this.currentDiscussion=e;let t=!!this.resolveToken();this.ui.panel.showClarificationDetail(e,t);}async handlePostReply(e,t,n){var r;let o=this.resolveToken();if(!(!o||!this.ui))try{await st(this.config,e,t,n,o);let s=await Pe(this.config,e,o);this.cachedDiscussions=s;let a=s.find(c=>c.id===t);a&&(this.currentDiscussion=a,this.ui.panel.showClarificationDetail(a,!0)),this.ui.panel.loadClarifications(s,!0);}catch(s){let a=s instanceof D?s.message:"Failed to post reply. Please try again.";(r=this.ui)==null||r.panel.showToast(a);}}async handleSearch(e){var r;if(!this.ui||!this.cachedResponse)return;let t=e.trim();if(!t){this.ui.panel.showTerms(this.cachedResponse),(r=this.captureModeController)==null||r.setHomeData(this.cachedResponse),this.loadHomeMemoryItems();return}this.fuseIndex||(this.fuseIndex=this.buildFuseIndex(this.cachedResponse.glossary));let o=this.fuseIndex.search(t).map(s=>s.item);this.ui.panel.showSearchResults(o,t);try{let s=this.resolveToken(),a=await Ve(this.config,this.cachedResponse.context.id,t,s);this.ui&&this.ui.panel.showSearchResults(a,t);}catch(s){}}buildFuseIndex(e){return new ge(e,{keys:[{name:"term",weight:3},{name:"abbreviation",weight:2},{name:"definition",weight:1}],threshold:.35,includeScore:true,ignoreLocation:true,minMatchCharLength:2})}showSuggestions(e){if(!this.ui||!this.suggester)return;let t=this.suggester.scan(e);t.length!==0&&this.ui.panel.showSuggestedTerms(t,n=>this.handleAddSuggestion(n));}handleAddSuggestion(e){if(!this.ui)return;if(this.activeSuggestion=e,!this.resolveToken()){this.pendingAction=()=>this.openAiGenerateFlow(e),this.showLoginWithProviders();return}this.openAiGenerateFlow(e);}async openAiGenerateFlow(e){var r,s,a,c;if(!this.ui)return;let t=this.resolveToken();if(!t)return;let n=(s=(r=this.suggester)==null?void 0:r.getPageContext(e))!=null?s:"",o=typeof window!="undefined"?window.location.href:"";this.ui.panel.setAiModalLoading(false);try{let d=await Ye(this.config,e,n,o,t);(a=this.ui)==null||a.panel.showAiModal(e,d,l=>{this.submitSuggestedTerm(e,l);},()=>{var l;this.cachedResponse&&this.ui&&(this.ui.panel.showTerms(this.cachedResponse),(l=this.captureModeController)==null||l.setHomeData(this.cachedResponse),this.showSuggestions(this.cachedResponse.glossary),this.loadHomeMemoryItems());});}catch(d){(c=this.ui)==null||c.panel.showAiModal(e,"",l=>{this.submitSuggestedTerm(e,l);},()=>{var l;this.cachedResponse&&this.ui&&(this.ui.panel.showTerms(this.cachedResponse),(l=this.captureModeController)==null||l.setHomeData(this.cachedResponse),this.showSuggestions(this.cachedResponse.glossary),this.loadHomeMemoryItems());});}}async loadMemories(e,t=false){if(!this.ui)return;let n=this.resolveToken();try{let o=await Ee(this.config,e,n);t||(this.memories=[]),this.memories=[...this.memories,...o.content],this.memoriesPage=o.number,this.hasMoreMemories=!o.last,this.ui.panel.showMemoriesList(o.content,o.number,!o.last,t);}catch(o){let r=o instanceof D?o.message:"Could not load Product Memories.";this.ui.panel.showToast(r);}}async loadAllMemories(){var t,n;if(!this.ui)return;let e=this.resolveToken();try{let o=await Ee(this.config,0,e);(t=this.ui)==null||t.panel.showAllMemories(o.content,!!e);}catch(o){console.error("[unnoodle] loadAllMemories failed:",o),(n=this.ui)==null||n.panel.showAllMemories([],false);}}async loadHomeMemoryItems(){var t,n;if(!this.ui)return;let e=this.resolveToken();try{let r=(await Ee(this.config,0,e)).content.slice(0,5);this.cachedHomeMemories=r,this.cachedResponse&&(this.cachedResponse.productMemories=r),(t=this.ui)==null||t.panel.showHomeMemoryItems(r);}catch(o){console.error("loadHomeMemoryItems failed:",o),(n=this.ui)==null||n.panel.showHomeMemoryItems([]);}}async handleViewMemoryDetail(e){if(!this.ui)return;let t=this.resolveToken();try{let n=await ot(this.config,e,t);this.currentMemory=n,this.ui.panel.showMemoryDetail(n);}catch(n){this.ui.panel.showToast("Could not load memory details.");}}async handleUpdateEntryExplanation(e,t,n){if(!this.ui)return;let o=this.resolveToken();if(o)try{let r=await tt(this.config,e,t,{explanation:n},o);this.currentMemory=r,this.ui.panel.showMemoryDetail(r),this.ui.panel.showToast("Explanation saved \u2713");}catch(r){this.ui.panel.showToast("Could not save explanation.");}}handleAddEntryToMemory(e){if(!this.ui||!this.currentMemory)return;if(!this.resolveToken()){this.showLoginWithProviders();return}zt(this.ui.panel,this.config,()=>this.resolveToken(),()=>{var o,r;return (r=(o=this.cachedResponse)==null?void 0:o.glossary)!=null?r:[]},()=>{this.handleViewMemoryDetail(e);},new ct(e),{type:"add-entry",memoryTitle:this.currentMemory.title}).start();}async handleDeleteMemory(e){if(!this.ui)return;let t=this.resolveToken();if(t)try{await nt(this.config,e,t),this.ui.panel.showToast("Memory deleted \u2713"),await this.loadMemories(0,!1);}catch(n){this.ui.panel.showToast("Could not delete memory.");}}async handleDeleteEntry(e,t){if(!this.ui)return;let n=this.resolveToken();if(n)try{let o=await it(this.config,e,t,n);this.currentMemory=o,this.ui.panel.showMemoryDetail(o),this.ui.panel.showToast("Entry deleted \u2713");}catch(o){this.ui.panel.showToast("Could not delete entry.");}}async submitSuggestedTerm(e,t){var o;if(!this.ui||!this.cachedResponse)return;let n=this.resolveToken();if(n){this.ui.panel.setAiModalLoading(true);try{await Xe(this.config,this.cachedResponse.context.id,e,t,n),this.ui.panel.showTerms(this.cachedResponse),(o=this.captureModeController)==null||o.setHomeData(this.cachedResponse),this.showSuggestions(this.cachedResponse.glossary),this.loadHomeMemoryItems(),this.ui.panel.showToast("Term submitted for approval"),this.activeSuggestion=null;}catch(r){this.ui.panel.setAiModalLoading(false);r instanceof D?r.message:"Failed to submit term. Please try again.";}}}};function _t(i){var e;return {textContent:(e=i.textContent)!=null?e:"",innerHTML:i.innerHTML}}var Gt=class{constructor(){this.observer=null;this.timerId=null;this.pendingMutations=[];this.watchedEl=null;this.callback=null;this.preBatchState=null;}watch(e,t){this.unwatch(),this.watchedEl=e,this.callback=t,this.preBatchState=_t(e),this.observer=new MutationObserver(n=>{for(let o of n)this.pendingMutations.push(o);this.scheduleFlush();}),this.observer.observe(e,{childList:true,subtree:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true});}unwatch(){var e;this.timerId!==null&&(clearTimeout(this.timerId),this.timerId=null),(e=this.observer)==null||e.disconnect(),this.observer=null,this.pendingMutations=[],this.preBatchState=null,this.watchedEl=null,this.callback=null;}scheduleFlush(){this.timerId!==null&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>this.flush(),500);}flush(){this.timerId=null;let e=[...this.pendingMutations];if(this.pendingMutations=[],!this.watchedEl||!this.callback||!this.preBatchState)return;let t=this.computeDiff(e,this.preBatchState,this.watchedEl);t?(this.preBatchState=_t(this.watchedEl),this.callback(t)):this.preBatchState=_t(this.watchedEl);}computeDiff(e,t,n){var c,d,l,p;let o=e.filter(h=>!(h.type==="attributes"&&h.attributeName==="style"));if(o.length===0)return null;let r=o.find(h=>h.type==="attributes");if(r){let h=r.attributeName;return {type:"attribute",attribute:h,before:(c=r.oldValue)!=null?c:"",after:(d=n.getAttribute(h))!=null?d:""}}let s=o.find(h=>h.type==="characterData");if(s)return {type:"text",before:(l=s.oldValue)!=null?l:"",after:s.target.data};let a=o.filter(h=>h.type==="childList");if(a.length>0){let h=[];for(let v of a){for(let f of Array.from(v.addedNodes))h.push(f);for(let f of Array.from(v.removedNodes))h.push(f);}return h.every(v=>v.nodeType===Node.TEXT_NODE)?{type:"text",before:t.textContent,after:(p=n.textContent)!=null?p:""}:{type:"structure",before:t.innerHTML,after:n.innerHTML}}return null}};var _i=/\b(loading|spinner|submitting|saving|please wait)\b/i,Gi=/\b(error|failed|invalid|failure|try again|went wrong)\b/i,Vi=/\b(success|saved|complete|done|submitted|finished)\b/i,Wi=[[/\b(loading|spinner|pending|busy)\b/,"Loading state"],[/\b(disabled|inactive|unavailable)\b/,"Disabled state"],[/\b(error|invalid|danger|fail)\b/,"Error state"],[/\b(success|valid|done|complete)\b/,"Success state"],[/\b(active|selected|open|checked|focused)\b/,"Active state"],[/\b(collapsed|closed|hidden)\b/,"Collapsed state"]];function Vo(i){return new Set(i.split(/\s+/).filter(Boolean))}function ji(i,e){let t=Vo(i);return [...Vo(e)].filter(n=>!t.has(n)).join(" ")}function Zi(i,e){if(i.type==="text"){let t=i.after;return _i.test(t)?"Loading state":Gi.test(t)?"Error state":Vi.test(t)?"Success state":null}if(i.type==="attribute"){let{attribute:t,after:n}=i;if(t==="class"){let o=ji(i.before,n);if(o){for(let[r,s]of Wi)if(r.test(o))return s}return null}if(t==="disabled")return e.hasAttribute("disabled")?"Disabled state":"Enabled state";if(t==="aria-expanded")return n==="true"?"Expanded state":"Collapsed state";if(t==="aria-selected")return n==="true"?"Selected state":null;if(t==="aria-busy")return n==="true"?"Loading state":null;if(t==="aria-label"){let o=n.trim();return o?`Label changed to: ${o}`:null}return null}return null}var Ki="unnoodle-live-ring",Yi=`
2631
+ position: fixed;
2632
+ pointer-events: none;
2633
+ z-index: 2147483645;
2634
+ border: 2px solid #5C4EFA;
2635
+ border-radius: 4px;
2636
+ background: rgba(92, 78, 250, 0.10);
2637
+ box-shadow: 0 0 0 1px rgba(92, 78, 250, 0.35), 0 0 8px rgba(92, 78, 250, 0.25);
2638
+ `,Vt=class{constructor(){this.ring=null;}show(e){this.hide(),e.scrollIntoView({behavior:"smooth",block:"center"});let t=e.getBoundingClientRect(),n=document.createElement("div");n.id=Ki,n.setAttribute("data-testid","unnoodle-live-ring"),n.style.cssText=Yi,n.style.top=`${t.top}px`,n.style.left=`${t.left}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,document.body.appendChild(n),this.ring=n;}hide(){var e;(e=this.ring)==null||e.remove(),this.ring=null;}};function Xi(i,e){try{let t=new URL(i),n=new URL(e);return t.origin===n.origin&&t.pathname===n.pathname}catch(t){return i===e}}var Wt=class{constructor(e,t){this.stateWatcher=e;this.targetingEngine=t;}load(e,t){var a,c;if(this.unload(),!e.watchForChanges)return;let n=e.entries[0];if(!n||!Xi(n.url,window.location.href))return;let o=n.targetingMetadata;if(!o)return;let r=J(S(S({},o.id!==void 0&&{id:o.id}),o.dataTestId!==void 0&&{dataTestId:o.dataTestId}),{tag:o.tag,role:(a=o.role)!=null?a:null,text:(c=o.text)!=null?c:"",url:n.url}),s=this.targetingEngine.resolve(r);s&&this.stateWatcher.watch(s,t);}unload(){this.stateWatcher.unwatch();}};var oe=null;function Ji(i){if(typeof document!="undefined"&&or(i)){if(oe){let e=`unnoodle_token_${i.apiKey.slice(-8)}`,t=null;try{t=sessionStorage.getItem(e);}catch(n){}if(oe.destroy(),oe=null,t)try{sessionStorage.setItem(e,t);}catch(n){}}oe=new vt(i),oe.init();}}function Qi(){oe==null||oe.open();}function er(){oe==null||oe.close();}function tr(){oe==null||oe.destroy(),oe=null;}var Js={init:Ji,open:Qi,close:er,destroy:tr};function or(i){return !i||typeof i!="object"?(console.warn("[Unnoodle] initUnnoodle() requires a config object."),false):!i.apiKey||typeof i.apiKey!="string"||i.apiKey.trim()===""?(console.warn("[Unnoodle] initUnnoodle() requires a non-empty `apiKey` string (e.g. pk_live_xxx)."),false):!i.context||typeof i.context!="string"||i.context.trim()===""?(console.warn("[Unnoodle] initUnnoodle() requires a non-empty `context` string."),false):(i.environment&&!["dev","staging","prod"].includes(i.environment)&&console.warn(`[Unnoodle] Invalid environment "${i.environment}". Must be "dev", "staging", or "prod". Defaulting to "prod".`),true)}exports.LiveRenderer=Vt;exports.MemoryDetailController=Wt;exports.StateWatcher=Gt;exports.Unnoodle=Js;exports.closeUnnoodle=er;exports.destroyUnnoodle=tr;exports.inferMeaning=Zi;exports.initUnnoodle=Ji;exports.openUnnoodle=Qi;//# sourceMappingURL=index.cjs.map
2639
+ //# sourceMappingURL=index.cjs.map