@unnoodle/browser 0.1.0 → 0.1.1
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/README.md +29 -0
- package/dist/flow/index.cjs +2 -0
- package/dist/flow/index.cjs.map +1 -0
- package/dist/flow/index.d.cts +142 -0
- package/dist/flow/index.d.ts +142 -0
- package/dist/flow/index.js +2 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/index.cjs +333 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +333 -159
- package/dist/index.js.map +1 -1
- package/package.json +27 -16
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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=`
|
|
1
|
+
function ae(n){return Array.isArray?Array.isArray(n):oo(n)==="[object Array]"}function ni(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-Infinity?"-0":t}function ii(n){return n==null?"":ni(n)}function ne(n){return typeof n=="string"}function eo(n){return typeof n=="number"}function ri(n){return n===true||n===false||si(n)&&oo(n)=="[object Boolean]"}function to(n){return typeof n=="object"}function si(n){return to(n)&&n!==null}function J(n){return n!=null}function yt(n){return !n.trim().length}function oo(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}var ai="Incorrect 'index' type",li=n=>`Invalid value for key ${n}`,di=n=>`Pattern length exceeds max of ${n}.`,ci=n=>`Missing ${n} property in key`,ui=n=>`Property 'weight' in key '${n}' must be a positive integer`,Kt=Object.prototype.hasOwnProperty,wt=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(o=>{let i=no(o);this._keys.push(i),this._keyMap[i.id]=i,e+=i.weight;}),this._keys.forEach(o=>{o.weight/=e;});}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function no(n){let t=null,e=null,o=null,i=1,r=null;if(ne(n)||ae(n))o=n,t=Yt(n),e=xt(n);else {if(!Kt.call(n,"name"))throw new Error(ci("name"));let s=n.name;if(o=s,Kt.call(n,"weight")&&(i=n.weight,i<=0))throw new Error(ui(s));t=Yt(s),e=xt(s),r=n.getFn;}return {path:t,id:e,weight:i,src:o,getFn:r}}function Yt(n){return ae(n)?n:n.split(".")}function xt(n){return ae(n)?n.join("."):n}function pi(n,t){let e=[],o=false,i=(r,s,a)=>{if(J(r))if(!s[a])e.push(r);else {let l=s[a],d=r[l];if(!J(d))return;if(a===s.length-1&&(ne(d)||eo(d)||ri(d)))e.push(ii(d));else if(ae(d)){o=true;for(let u=0,m=d.length;u<m;u+=1)i(d[u],s,a+1);}else s.length&&i(d,s,a+1);}};return i(n,ne(t)?t.split("."):t,0),o?e:e[0]}var mi={includeMatches:false,findAllMatches:false,minMatchCharLength:1},hi={isCaseSensitive:false,ignoreDiacritics:false,includeScore:false,keys:[],shouldSort:true,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},gi={location:0,threshold:.6,distance:100},fi={useExtendedSearch:false,getFn:pi,ignoreLocation:false,ignoreFieldNorm:false,fieldNormWeight:1},S={...hi,...mi,...gi,...fi},vi=/[^ ]+/g;function bi(n=1,t=3){let e=new Map,o=Math.pow(10,t);return {get(i){let r=i.match(vi).length;if(e.has(r))return e.get(r);let s=1/Math.pow(r,.5*n),a=parseFloat(Math.round(s*o)/o);return e.set(r,a),a},clear(){e.clear();}}}var Me=class{constructor({getFn:t=S.getFn,fieldNormWeight:e=S.fieldNormWeight}={}){this.norm=bi(e,3),this.getFn=t,this.isCreated=false,this.setIndexRecords();}setSources(t=[]){this.docs=t;}setIndexRecords(t=[]){this.records=t;}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,o)=>{this._keysMap[e.id]=o;});}create(){this.isCreated||!this.docs.length||(this.isCreated=true,ne(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e);}):this.docs.forEach((t,e)=>{this._addObject(t,e);}),this.norm.clear());}add(t){let e=this.size();ne(t)?this._addString(t,e):this._addObject(t,e);}removeAt(t){this.records.splice(t,1);for(let e=t,o=this.size();e<o;e+=1)this.records[e].i-=1;}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!J(t)||yt(t))return;let o={v:t,i:e,n:this.norm.get(t)};this.records.push(o);}_addObject(t,e){let o={i:e,$:{}};this.keys.forEach((i,r)=>{let s=i.getFn?i.getFn(t):this.getFn(t,i.path);if(J(s)){if(ae(s)){let a=[],l=[{nestedArrIndex:-1,value:s}];for(;l.length;){let{nestedArrIndex:d,value:u}=l.pop();if(J(u))if(ne(u)&&!yt(u)){let m={v:u,i:d,n:this.norm.get(u)};a.push(m);}else ae(u)&&u.forEach((m,v)=>{l.push({nestedArrIndex:v,value:m});});}o.$[r]=a;}else if(ne(s)&&!yt(s)){let a={v:s,n:this.norm.get(s)};o.$[r]=a;}}}),this.records.push(o);}toJSON(){return {keys:this.keys,records:this.records}}};function io(n,t,{getFn:e=S.getFn,fieldNormWeight:o=S.fieldNormWeight}={}){let i=new Me({getFn:e,fieldNormWeight:o});return i.setKeys(n.map(no)),i.setSources(t),i.create(),i}function yi(n,{getFn:t=S.getFn,fieldNormWeight:e=S.fieldNormWeight}={}){let{keys:o,records:i}=n,r=new Me({getFn:t,fieldNormWeight:e});return r.setKeys(o),r.setIndexRecords(i),r}function $e(n,{errors:t=0,currentLocation:e=0,expectedLocation:o=0,distance:i=S.distance,ignoreLocation:r=S.ignoreLocation}={}){let s=t/n.length;if(r)return s;let a=Math.abs(o-e);return i?s+a/i:a?1:s}function wi(n=[],t=S.minMatchCharLength){let e=[],o=-1,i=-1,r=0;for(let s=n.length;r<s;r+=1){let a=n[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=t&&e.push([o,i]),o=-1);}return n[r-1]&&r-o>=t&&e.push([o,r-1]),e}var pe=32;function xi(n,t,e,{location:o=S.location,distance:i=S.distance,threshold:r=S.threshold,findAllMatches:s=S.findAllMatches,minMatchCharLength:a=S.minMatchCharLength,includeMatches:l=S.includeMatches,ignoreLocation:d=S.ignoreLocation}={}){if(t.length>pe)throw new Error(di(pe));let u=t.length,m=n.length,v=Math.max(0,Math.min(o,m)),f=r,x=v,y=a>1||l,L=y?Array(m):[],R;for(;(R=n.indexOf(t,x))>-1;){let g=$e(t,{currentLocation:R,expectedLocation:v,distance:i,ignoreLocation:d});if(f=Math.min(g,f),x=R+u,y){let b=0;for(;b<u;)L[R+b]=1,b+=1;}}x=-1;let H=[],I=1,q=u+m,N=1<<u-1;for(let g=0;g<u;g+=1){let b=0,T=q;for(;b<T;)$e(t,{errors:g,currentLocation:v+T,expectedLocation:v,distance:i,ignoreLocation:d})<=f?b=T:q=T,T=Math.floor((q-b)/2+b);q=T;let D=Math.max(1,v-T+1),z=s?m:Math.min(v+T,m)+u,_=Array(z+2);_[z+1]=(1<<g)-1;for(let G=z;G>=D;G-=1){let K=G-1,Y=e[n.charAt(K)];if(y&&(L[K]=+!!Y),_[G]=(_[G+1]<<1|1)&Y,g&&(_[G]|=(H[G+1]|H[G])<<1|1|H[G+1]),_[G]&N&&(I=$e(t,{errors:g,currentLocation:K,expectedLocation:v,distance:i,ignoreLocation:d}),I<=f)){if(f=I,x=K,x<=v)break;D=Math.max(1,2*v-x);}}if($e(t,{errors:g+1,currentLocation:v,expectedLocation:v,distance:i,ignoreLocation:d})>f)break;H=_;}let h={isMatch:x>=0,score:Math.max(.001,I)};if(y){let g=wi(L,a);g.length?l&&(h.indices=g):h.isMatch=false;}return h}function ki(n){let t={};for(let e=0,o=n.length;e<o;e+=1){let i=n.charAt(e);t[i]=(t[i]||0)|1<<o-e-1;}return t}var Ie=String.prototype.normalize?(n=>n.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,"")):(n=>n),ze=class{constructor(t,{location:e=S.location,threshold:o=S.threshold,distance:i=S.distance,includeMatches:r=S.includeMatches,findAllMatches:s=S.findAllMatches,minMatchCharLength:a=S.minMatchCharLength,isCaseSensitive:l=S.isCaseSensitive,ignoreDiacritics:d=S.ignoreDiacritics,ignoreLocation:u=S.ignoreLocation}={}){if(this.options={location:e,threshold:o,distance:i,includeMatches:r,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:l,ignoreDiacritics:d,ignoreLocation:u},t=l?t:t.toLowerCase(),t=d?Ie(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;let m=(f,x)=>{this.chunks.push({pattern:f,alphabet:ki(f),startIndex:x});},v=this.pattern.length;if(v>pe){let f=0,x=v%pe,y=v-x;for(;f<y;)m(this.pattern.substr(f,pe),f),f+=pe;if(x){let L=v-pe;m(this.pattern.substr(L),L);}}else m(this.pattern,0);}searchIn(t){let{isCaseSensitive:e,ignoreDiacritics:o,includeMatches:i}=this.options;if(t=e?t:t.toLowerCase(),t=o?Ie(t):t,this.pattern===t){let y={isMatch:true,score:0};return i&&(y.indices=[[0,t.length-1]]),y}let{location:r,distance:s,threshold:a,findAllMatches:l,minMatchCharLength:d,ignoreLocation:u}=this.options,m=[],v=0,f=false;this.chunks.forEach(({pattern:y,alphabet:L,startIndex:R})=>{let{isMatch:H,score:I,indices:q}=xi(t,y,L,{location:r+R,distance:s,threshold:a,findAllMatches:l,minMatchCharLength:d,includeMatches:i,ignoreLocation:u});H&&(f=true),v+=I,H&&q&&(m=[...m,...q]);});let x={isMatch:f,score:f?v/this.chunks.length:1};return f&&i&&(x.indices=m),x}},ie=class{constructor(t){this.pattern=t;}static isMultiMatch(t){return Xt(t,this.multiRegex)}static isSingleMatch(t){return Xt(t,this.singleRegex)}search(){}};function Xt(n,t){let e=n.match(t);return e?e[1]:null}var kt=class extends ie{constructor(t){super(t);}static get type(){return "exact"}static get multiRegex(){return /^="(.*)"$/}static get singleRegex(){return /^=(.*)$/}search(t){let e=t===this.pattern;return {isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},Et=class extends ie{constructor(t){super(t);}static get type(){return "inverse-exact"}static get multiRegex(){return /^!"(.*)"$/}static get singleRegex(){return /^!(.*)$/}search(t){let o=t.indexOf(this.pattern)===-1;return {isMatch:o,score:o?0:1,indices:[0,t.length-1]}}},Tt=class extends ie{constructor(t){super(t);}static get type(){return "prefix-exact"}static get multiRegex(){return /^\^"(.*)"$/}static get singleRegex(){return /^\^(.*)$/}search(t){let e=t.startsWith(this.pattern);return {isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},Ct=class extends ie{constructor(t){super(t);}static get type(){return "inverse-prefix-exact"}static get multiRegex(){return /^!\^"(.*)"$/}static get singleRegex(){return /^!\^(.*)$/}search(t){let e=!t.startsWith(this.pattern);return {isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},Mt=class extends ie{constructor(t){super(t);}static get type(){return "suffix-exact"}static get multiRegex(){return /^"(.*)"\$$/}static get singleRegex(){return /^(.*)\$$/}search(t){let e=t.endsWith(this.pattern);return {isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}},At=class extends ie{constructor(t){super(t);}static get type(){return "inverse-suffix-exact"}static get multiRegex(){return /^!"(.*)"\$$/}static get singleRegex(){return /^!(.*)\$$/}search(t){let e=!t.endsWith(this.pattern);return {isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},Ue=class extends ie{constructor(t,{location:e=S.location,threshold:o=S.threshold,distance:i=S.distance,includeMatches:r=S.includeMatches,findAllMatches:s=S.findAllMatches,minMatchCharLength:a=S.minMatchCharLength,isCaseSensitive:l=S.isCaseSensitive,ignoreDiacritics:d=S.ignoreDiacritics,ignoreLocation:u=S.ignoreLocation}={}){super(t),this._bitapSearch=new ze(t,{location:e,threshold:o,distance:i,includeMatches:r,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:l,ignoreDiacritics:d,ignoreLocation:u});}static get type(){return "fuzzy"}static get multiRegex(){return /^"(.*)"$/}static get singleRegex(){return /^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}},Ne=class extends ie{constructor(t){super(t);}static get type(){return "include"}static get multiRegex(){return /^'"(.*)"$/}static get singleRegex(){return /^'(.*)$/}search(t){let e=0,o,i=[],r=this.pattern.length;for(;(o=t.indexOf(this.pattern,e))>-1;)e=o+r,i.push([o,e-1]);let s=!!i.length;return {isMatch:s,score:s?0:1,indices:i}}},Lt=[kt,Ne,Tt,Ct,At,Mt,Et,Ue],Jt=Lt.length,Ei=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ti="|";function Ci(n,t={}){return n.split(Ti).map(e=>{let o=e.trim().split(Ei).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){let a=o[r],l=false,d=-1;for(;!l&&++d<Jt;){let u=Lt[d],m=u.isMultiMatch(a);m&&(i.push(new u(m,t)),l=true);}if(!l)for(d=-1;++d<Jt;){let u=Lt[d],m=u.isSingleMatch(a);if(m){i.push(new u(m,t));break}}}return i})}var Mi=new Set([Ue.type,Ne.type]),St=class{constructor(t,{isCaseSensitive:e=S.isCaseSensitive,ignoreDiacritics:o=S.ignoreDiacritics,includeMatches:i=S.includeMatches,minMatchCharLength:r=S.minMatchCharLength,ignoreLocation:s=S.ignoreLocation,findAllMatches:a=S.findAllMatches,location:l=S.location,threshold:d=S.threshold,distance:u=S.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:o,includeMatches:i,minMatchCharLength:r,findAllMatches:a,ignoreLocation:s,location:l,threshold:d,distance:u},t=e?t:t.toLowerCase(),t=o?Ie(t):t,this.pattern=t,this.query=Ci(this.pattern,this.options);}static condition(t,e){return e.useExtendedSearch}searchIn(t){let e=this.query;if(!e)return {isMatch:false,score:1};let{includeMatches:o,isCaseSensitive:i,ignoreDiacritics:r}=this.options;t=i?t:t.toLowerCase(),t=r?Ie(t):t;let s=0,a=[],l=0;for(let d=0,u=e.length;d<u;d+=1){let m=e[d];a.length=0,s=0;for(let v=0,f=m.length;v<f;v+=1){let x=m[v],{isMatch:y,indices:L,score:R}=x.search(t);if(y){if(s+=1,l+=R,o){let H=x.constructor.type;Mi.has(H)?a=[...a,...L]:a.push(L);}}else {l=0,s=0,a.length=0;break}}if(s){let v={isMatch:true,score:l/s};return o&&(v.indices=a),v}}return {isMatch:false,score:1}}},Ht=[];function Ai(...n){Ht.push(...n);}function Rt(n,t){for(let e=0,o=Ht.length;e<o;e+=1){let i=Ht[e];if(i.condition(n,t))return new i(n,t)}return new ze(n,t)}var Oe={AND:"$and",OR:"$or"},Pt={PATH:"$path",PATTERN:"$val"},Bt=n=>!!(n[Oe.AND]||n[Oe.OR]),Li=n=>!!n[Pt.PATH],Si=n=>!ae(n)&&to(n)&&!Bt(n),Qt=n=>({[Oe.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function ro(n,t,{auto:e=true}={}){let o=i=>{let r=Object.keys(i),s=Li(i);if(!s&&r.length>1&&!Bt(i))return o(Qt(i));if(Si(i)){let l=s?i[Pt.PATH]:r[0],d=s?i[Pt.PATTERN]:i[l];if(!ne(d))throw new Error(li(l));let u={keyId:xt(l),pattern:d};return e&&(u.searcher=Rt(d,t)),u}let a={children:[],operator:r[0]};return r.forEach(l=>{let d=i[l];ae(d)&&d.forEach(u=>{a.children.push(o(u));});}),a};return Bt(n)||(n=Qt(n)),o(n)}function Hi(n,{ignoreFieldNorm:t=S.ignoreFieldNorm}){n.forEach(e=>{let o=1;e.matches.forEach(({key:i,norm:r,score:s})=>{let a=i?i.weight:null;o*=Math.pow(s===0&&a?Number.EPSILON:s,(a||1)*(t?1:r));}),e.score=o;});}function Ri(n,t){let e=n.matches;t.matches=[],J(e)&&e.forEach(o=>{if(!J(o.indices)||!o.indices.length)return;let{indices:i,value:r}=o,s={indices:i,value:r};o.key&&(s.key=o.key.src),o.idx>-1&&(s.refIndex=o.idx),t.matches.push(s);});}function Pi(n,t){t.score=n.score;}function Bi(n,t,{includeMatches:e=S.includeMatches,includeScore:o=S.includeScore}={}){let i=[];return e&&i.push(Ri),o&&i.push(Pi),n.map(r=>{let{idx:s}=r,a={item:t[s],refIndex:s};return i.length&&i.forEach(l=>{l(r,a);}),a})}var le=class{constructor(t,e={},o){this.options={...S,...e},this.options.useExtendedSearch,this._keyStore=new wt(this.options.keys),this.setCollection(t,o);}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Me))throw new Error(ai);this._myIndex=e||io(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight});}add(t){J(t)&&(this._docs.push(t),this._myIndex.add(t));}remove(t=()=>false){let e=[];for(let o=0,i=this._docs.length;o<i;o+=1){let r=this._docs[o];t(r,o)&&(this.removeAt(o),o-=1,i-=1,e.push(r));}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t);}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){let{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options,l=ne(t)?ne(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Hi(l,{ignoreFieldNorm:a}),r&&l.sort(s),eo(e)&&e>-1&&(l=l.slice(0,e)),Bi(l,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t){let e=Rt(t,this.options),{records:o}=this._myIndex,i=[];return o.forEach(({v:r,i:s,n:a})=>{if(!J(r))return;let{isMatch:l,score:d,indices:u}=e.searchIn(r);l&&i.push({item:r,idx:s,matches:[{score:d,value:r,norm:a,indices:u}]});}),i}_searchLogical(t){let e=ro(t,this.options),o=(a,l,d)=>{if(!a.children){let{keyId:m,searcher:v}=a,f=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(l,m),searcher:v});return f&&f.length?[{idx:d,item:l,matches:f}]:[]}let u=[];for(let m=0,v=a.children.length;m<v;m+=1){let f=a.children[m],x=o(f,l,d);if(x.length)u.push(...x);else if(a.operator===Oe.AND)return []}return u},i=this._myIndex.records,r={},s=[];return i.forEach(({$:a,i:l})=>{if(J(a)){let d=o(e,a,l);d.length&&(r[l]||(r[l]={idx:l,item:a,matches:[]},s.push(r[l])),d.forEach(({matches:u})=>{r[l].matches.push(...u);}));}}),s}_searchObjectList(t){let e=Rt(t,this.options),{keys:o,records:i}=this._myIndex,r=[];return i.forEach(({$:s,i:a})=>{if(!J(s))return;let l=[];o.forEach((d,u)=>{l.push(...this._findMatches({key:d,value:s[u],searcher:e}));}),l.length&&r.push({idx:a,item:s,matches:l});}),r}_findMatches({key:t,value:e,searcher:o}){if(!J(e))return [];let i=[];if(ae(e))e.forEach(({v:r,i:s,n:a})=>{if(!J(r))return;let{isMatch:l,score:d,indices:u}=o.searchIn(r);l&&i.push({score:d,key:t,value:r,idx:s,norm:a,indices:u});});else {let{v:r,n:s}=e,{isMatch:a,score:l,indices:d}=o.searchIn(r);a&&i.push({score:l,key:t,value:r,norm:s,indices:d});}return i}};le.version="7.1.0";le.createIndex=io;le.parseIndex=yi;le.config=S;le.parseQuery=ro;Ai(St);var Di="https://api.unnoodle.com";function U(n){return n.baseUrl?.replace(/\/$/,"")??Di}function O(n){return {"Content-Type":"application/json","X-Unnoodle-Api-Key":n.apiKey}}function Q(n){if(typeof n.getAuthToken!="function")return null;try{return n.getAuthToken()??null}catch{return null}}var A=class extends Error{constructor(t,e,o){super(t),this.name="ApiError",this.status=e,this.body=o;}};async function qe(n,t){let e=`${U(n)}/api/init`,o=O(n),i=t!==void 0?t:Q(n);i&&(o.Authorization=`Bearer ${i}`);let r=await fetch(e,{method:"POST",headers:o,body:JSON.stringify({context:n.context})});if(!r.ok){let s=await r.text().catch(()=>"");throw new A(`Unnoodle /api/init error: ${r.status} ${r.statusText}`,r.status,s)}return r.json()}async function Fe(n,t,e,o){let i=`${U(n)}/api/contexts/${t}/glossary/search?q=${encodeURIComponent(e)}`,r=O(n),s=o!==void 0?o:Q(n);s&&(r.Authorization=`Bearer ${s}`);let a=await fetch(i,{headers:r});if(!a.ok){let l=await a.text().catch(()=>"");throw new A(`Unnoodle search error: ${a.status} ${a.statusText}`,a.status,l)}return a.json()}async function _e(n,t){let e=`${U(n)}/api/auth/login`,o=await fetch(e,{method:"POST",headers:O(n),body:JSON.stringify(t)});if(!o.ok){let i=await o.text().catch(()=>"");throw new A(`Unnoodle login error: ${o.status} ${o.statusText}`,o.status,i)}return o.json()}async function Ve(n){let t=`${U(n)}/api/auth/oauth/providers`;try{let e=await fetch(t,{headers:O(n)});return e.ok?e.json():{googleEnabled:!1,microsoftEnabled:!1}}catch{return {googleEnabled:false,microsoftEnabled:false}}}async function Ae(n,t,e){let o=`${U(n)}/api/glossary/${t}/discussions`,i=O(n),r=e!==void 0?e:Q(n);r&&(i.Authorization=`Bearer ${r}`);let s=await fetch(o,{headers:i});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle discussions error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Ge(n,t,e,o){let i=`${U(n)}/api/glossary/${t}/discussions`,r={...O(n),Authorization:`Bearer ${o}`},s=await fetch(i,{method:"POST",headers:r,body:JSON.stringify({body:e})});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle post comment error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function We(n,t,e,o){let i=`${U(n)}/api/glossary/${t}`,r={...O(n),Authorization:`Bearer ${o}`},s=await fetch(i,{method:"PUT",headers:r,body:JSON.stringify(e)});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle update term error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function je(n,t,e,o,i){let r=`${U(n)}/api/sdk/glossary/ai-generate`,s={...O(n),Authorization:`Bearer ${i}`},a;try{a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({term:t,context:e,pageUrl:o})});}catch(d){throw new A(d instanceof Error?d.message:"Network error",0,"")}if(!a.ok){let d=await a.text().catch(()=>"");throw new A(`Unnoodle ai-generate error: ${a.status} ${a.statusText}`,a.status,d)}return (await a.json()).definition}async function Ze(n,t,e,o,i){let r=`${U(n)}/api/contexts/${t}/glossary`,s={...O(n),Authorization:`Bearer ${i}`},a;try{a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({term:e,definition:o,status:"PENDING",aiGenerated:!0})});}catch(l){throw new A(l instanceof Error?l.message:"Network error",0,"")}if(!a.ok){let l=await a.text().catch(()=>"");throw new A(`Unnoodle create suggested term error: ${a.status} ${a.statusText}`,a.status,l)}return a.json()}async function Ke(n,t,e,o,i){let r=`${U(n)}/api/contexts/${t}/glossary`,s={...O(n),Authorization:`Bearer ${i}`},a;try{a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({term:e,definition:o})});}catch(l){throw new A(l instanceof Error?l.message:"Network error",0,"")}if(!a.ok){let l=await a.text().catch(()=>"");throw new A(`Unnoodle create glossary term error: ${a.status} ${a.statusText}`,a.status,l)}return a.json()}async function Ye(n,t,e){let o=`${U(n)}/api/product-memories`,i={...O(n),Authorization:`Bearer ${e}`},r;try{r=await fetch(o,{method:"POST",headers:i,body:JSON.stringify(t)});}catch(s){throw new A(s instanceof Error?s.message:"Network error",0,"")}if(!r.ok){let s=await r.text().catch(()=>"");throw new A(`Unnoodle create-product-memory error: ${r.status} ${r.statusText}`,r.status,s)}return r.json()}async function Xe(n,t,e,o){let i=`${U(n)}/api/product-memories/${t}/entries`,r={...O(n),Authorization:`Bearer ${o}`},s=await fetch(i,{method:"POST",headers:r,body:JSON.stringify(e)});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle add-entry error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Je(n,t,e,o,i){let r=`${U(n)}/api/product-memories/${t}/entries/${e}`,s={...O(n),Authorization:`Bearer ${i}`},a=await fetch(r,{method:"PATCH",headers:s,body:JSON.stringify(o)});if(!a.ok){let l=await a.text().catch(()=>"");throw new A(`Unnoodle update-entry error: ${a.status} ${a.statusText}`,a.status,l)}return a.json()}async function fe(n,t,e){let o=`${U(n)}/api/product-memories?page=${t}&size=20`,i={...O(n)},r=e!==void 0?e:Q(n);r&&(i.Authorization=`Bearer ${r}`);let s=await fetch(o,{headers:i});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle list-memories error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Qe(n,t,e){let o=`${U(n)}/api/product-memories/${t}`,i={...O(n)};e&&(i.Authorization=`Bearer ${e}`);let r=await fetch(o,{headers:i});if(!r.ok){let s=await r.text().catch(()=>"");throw new A(`Unnoodle get-memory error: ${r.status} ${r.statusText}`,r.status,s)}return r.json()}async function et(n,t,e){let o=`${U(n)}/api/product-memories/${t}`,i={...O(n),Authorization:`Bearer ${e}`},r=await fetch(o,{method:"DELETE",headers:i});if(!r.ok){let s=await r.text().catch(()=>"");throw new A(`Unnoodle delete-memory error: ${r.status} ${r.statusText}`,r.status,s)}}async function tt(n,t,e,o){let i=`${U(n)}/api/product-memories/${t}/entries/${e}`,r={...O(n),Authorization:`Bearer ${o}`},s=await fetch(i,{method:"DELETE",headers:r});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle delete-entry error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function Le(n,t,e){let o=`${U(n)}/api/contexts/${t}/discussions`,i=O(n),r=e!==void 0?e:Q(n);r&&(i.Authorization=`Bearer ${r}`);let s=await fetch(o,{headers:i});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle GET context discussions error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function ot(n,t,e,o){let i=`${U(n)}/api/contexts/${t}/discussions`,r={...O(n),Authorization:`Bearer ${o}`},s=await fetch(i,{method:"POST",headers:r,body:JSON.stringify({body:e})});if(!s.ok){let a=await s.text().catch(()=>"");throw new A(`Unnoodle POST context discussion error: ${s.status} ${s.statusText}`,s.status,a)}return s.json()}async function nt(n,t,e,o,i){let r=`${U(n)}/api/contexts/${t}/discussions/${e}/replies`,s={...O(n),Authorization:`Bearer ${i}`},a=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({body:o})});if(!a.ok){let l=await a.text().catch(()=>"");throw new A(`Unnoodle POST context reply error: ${a.status} ${a.statusText}`,a.status,l)}return a.json()}var Se=class extends A{constructor(t,e){super("Ask rate limited",429,t),this.name="AskRateLimitedError",this.retryAfter=e;}},ve=class extends A{constructor(t,e){super("Ask unavailable",503,t),this.name="AskBusyError",this.retryAfter=e;}},$i=15e3;function ao(n,t){let e=O(n),o=t!==void 0?t:Q(n);return o&&(e.Authorization=`Bearer ${o}`),e}function so(n){let t=Number(n.headers.get("Retry-After")??"0");return Number.isFinite(t)&&t>0?t:0}async function lo(n,t,e,o,i){let r=`${U(n)}/api/ask`,s=ao(n,o),a=new AbortController,l=false,d=setTimeout(()=>{l=true,a.abort();},$i),u=()=>a.abort();i&&(i.aborted?a.abort():i.addEventListener("abort",u));try{let m;try{m=await fetch(r,{method:"POST",headers:s,body:JSON.stringify({question:t,pageUrl:e}),signal:a.signal});}catch(f){throw i?.aborted&&!l?f:l?new A("Ask timed out",0,""):new A(f instanceof Error?f.message:"Network error",0,"")}if(m.ok)return await m.json();let v=await m.text().catch(()=>"");throw m.status===429?new Se(v,so(m)):m.status===503?new ve(v,so(m)):new A(`Unnoodle ask error: ${m.status} ${m.statusText}`,m.status,v)}finally{clearTimeout(d),i&&i.removeEventListener("abort",u);}}async function co(n,t){let e=`${U(n)}/api/ask/status`,o=ao(n,t),i;try{i=await fetch(e,{headers:o});}catch(r){throw new A(r instanceof Error?r.message:"Network error",0,"")}if(!i.ok){let r=await i.text().catch(()=>"");throw new A(`Unnoodle ask-status error: ${i.status} ${i.statusText}`,i.status,r)}return i.json()}var zi={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 Ui(n){let t=n.getAttribute("role");return t||(zi[n.tagName.toLowerCase()]??null)}function Ni(n,t){if(!(n instanceof HTMLElement)||!(t instanceof HTMLElement))return;let e=window.getComputedStyle(n);for(let o of Array.from(e))try{t.style.setProperty(o,e.getPropertyValue(o));}catch{}}function uo(n,t){Ni(n,t);let e=n.children,o=t.children;for(let i=0;i<e.length;i++){let r=e[i],s=o[i];r&&s&&uo(r,s);}}function Oi(n){n.querySelectorAll("img[src]").forEach(t=>{let e=t.getAttribute("src");if(e&&!e.startsWith("http")&&!e.startsWith("data:"))try{t.setAttribute("src",new URL(e,window.location.href).href);}catch{}}),n.querySelectorAll("source[srcset]").forEach(t=>{let e=t.getAttribute("srcset");if(e){let o=e.split(",").map(i=>{let[r,s]=i.trim().split(/\s+/);if(!r||r.startsWith("http")||r.startsWith("data:"))return i;try{let a=new URL(r,window.location.href).href;return s?`${a} ${s}`:a}catch{return i}}).join(", ");t.setAttribute("srcset",o);}});}function qi(n){n.querySelectorAll("script").forEach(e=>e.remove());let t=[n,...Array.from(n.querySelectorAll("*"))];for(let e of t){let o=[];for(let i of Array.from(e.attributes))/^on/i.test(i.name)&&o.push(i.name);o.forEach(i=>e.removeAttribute(i));}}function po(n){let t=n.getBoundingClientRect(),e=n.cloneNode(true);return uo(n,e),Oi(e),qi(e),{html:e.outerHTML,naturalWidth:t.width,naturalHeight:t.height,tag:n.tagName.toLowerCase(),role:Ui(n),text:(n.textContent??"").trim().replace(/\s+/g," "),rect:t,id:n.id||void 0,dataTestId:n.getAttribute("data-testid")||void 0}}var mo="unnoodle-pick-ring",Fi=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
pointer-events: none;
|
|
4
4
|
z-index: 2147483645;
|
|
@@ -7,7 +7,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
7
7
|
background: rgba(92, 78, 250, 0.06);
|
|
8
8
|
transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s;
|
|
9
9
|
box-shadow: 0 0 0 9999px rgba(0,0,0,0.08);
|
|
10
|
-
`,
|
|
10
|
+
`,_i=new Set(["unnoodle-btn-host","unnoodle-panel-host",mo]),it=class{constructor(t){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=t;}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 t=document.createElement("div");t.id=mo,t.setAttribute("data-testid","unnoodle-pick-ring"),t.style.cssText=Fi,t.style.pointerEvents="none",t.style.display="none",document.body.appendChild(t),this.ring=t;}removeRing(){this.ring?.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(t){let e=t;for(;e;){if(_i.has(e.id))return true;e=e.parentElement;}return false}handleMouseover(t){let e=t.target;if(!e||this.isExcluded(e)||(this.currentTarget=e,document.documentElement.style.cursor="crosshair",!this.ring))return;let o=e.getBoundingClientRect();this.ring.style.display="block",this.ring.style.top=`${o.top}px`,this.ring.style.left=`${o.left}px`,this.ring.style.width=`${o.width}px`,this.ring.style.height=`${o.height}px`;}handleClick(t){let e=t.target;!e||this.isExcluded(e)||(t.preventDefault(),t.stopPropagation(),this.teardown(),this.callbacks.onPick(e));}handleKeydown(t){t.key==="Escape"&&this.stop();}};var Vi="unnoodle-overlay-arrow",ho="#5C4EFA";var go="unn-arrow-head";function fo(n,t){let e=n.left>t.right,o=e?n.left:n.right,i=n.top+n.height/2,r=e?t.right:t.left,s=t.top+t.height/2,a=Math.abs(r-o)*.4,l=e?o-a:o+a,d=e?r+a:r-a;return `M ${o} ${i} C ${l} ${i}, ${d} ${s}, ${r} ${s}`}function Gi(){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.id=Vi,n.setAttribute("data-testid","unnoodle-overlay-arrow"),n.style.cssText=`
|
|
11
11
|
position: fixed;
|
|
12
12
|
top: 0;
|
|
13
13
|
left: 0;
|
|
@@ -16,8 +16,8 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
16
16
|
pointer-events: none;
|
|
17
17
|
z-index: 2147483644;
|
|
18
18
|
overflow: visible;
|
|
19
|
-
`;let
|
|
20
|
-
`).replace(/\\t/g," ")}function
|
|
19
|
+
`;let t=document.createElementNS("http://www.w3.org/2000/svg","defs"),e=document.createElementNS("http://www.w3.org/2000/svg","marker");e.setAttribute("id",go),e.setAttribute("markerWidth","8"),e.setAttribute("markerHeight","8"),e.setAttribute("refX","6"),e.setAttribute("refY","3"),e.setAttribute("orient","auto"),e.setAttribute("markerUnits","strokeWidth");let o=document.createElementNS("http://www.w3.org/2000/svg","polygon");o.setAttribute("points","0 0, 6 3, 0 6"),o.setAttribute("fill",ho),e.appendChild(o),t.appendChild(e),n.appendChild(t);let i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("data-testid","unnoodle-arrow-path"),i.setAttribute("fill","none"),i.setAttribute("stroke",ho),i.setAttribute("stroke-width",String(1.5)),i.setAttribute("stroke-dasharray","5 4"),i.setAttribute("stroke-linecap","round"),i.setAttribute("marker-end",`url(#${go})`),n.appendChild(i),n}var rt=class{constructor(){this.svg=null;}draw(t,e){this.remove();let o=Gi();o.querySelector("path").setAttribute("d",fo(t,e)),document.body.appendChild(o),this.svg=o;}update(t,e){if(!this.svg)return;let o=this.svg.querySelector("path");o&&o.setAttribute("d",fo(t,e));}remove(){this.svg?.remove(),this.svg=null;}};var st=class{async execute(t,e,o,i,r,s=false){return {memory:await Ye(t,{title:o,explanation:i||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},watchForChanges:s},e)}}},at=class{constructor(t){this.memoryId=t;}async execute(t,e,o,i,r){return {memory:await Xe(t,this.memoryId,{explanation:i,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}},e)}}};var Dt=class{constructor(t,e,o,i,r,s,a,l,d={type:"new-memory"}){this.panel=t;this.picker=e;this.arrow=o;this.orchestrator=i;this.config=r;this.getToken=s;this.getGlossary=a;this.onSaveComplete=l;this.mode=d;this.state="idle";this.pickedElement=null;this.snapshot=null;this.scrollHandler=null;this.resizeHandler=null;this.homeData=null;}setHomeData(t){this.homeData=t;}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();},(t,e,o)=>{console.log("[unnoodle] Save callback triggered",{title:t,explanation:e,watchForChanges:o}),this.onSaveWithTitle(t,e,o);},()=>{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();},t=>{console.log("[unnoodle] Save callback triggered (add entry mode)",{explanation:t}),this.onSaveWithExplanation(t);},()=>{console.log("[unnoodle] Cancel callback triggered (add entry mode)"),this.cancel();}));}_onElementPicked(t){this.onElementPicked(t);}cancel(){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"),this.onSaveComplete?.(),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(t){if(console.log("[unnoodle] onElementPicked called",{state:this.state,element:t}),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=t,this.panel.setFormPickingMode(false),console.log("[unnoodle] onElementPicked - creating snapshot"),this.snapshot=po(t),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(t,e,o){await this.performSave(t,e,o);}async onSaveWithExplanation(t){await this.performSave("",t,false);}async performSave(t,e,o){if(console.log("[unnoodle] performSave called",{title:t,explanation:e,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 i=this.getToken();if(console.log("[unnoodle] performSave - token obtained:",!!i),!i){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,i,t,e,this.snapshot,o),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"),this.onSaveComplete?.(),console.log("[unnoodle] performSave completed successfully");}catch(r){console.log("[unnoodle] performSave - orchestrator failed",r),this.state="form-open";}}updateArrow(){if(!this.pickedElement)return;let t=this.panel.element.shadowRoot?.querySelector(".panel-shell")??this.panel.element;this.arrow.update(t.getBoundingClientRect(),this.pickedElement.getBoundingClientRect());}startTrackingArrow(){this.stopTrackingArrow();let t=()=>this.updateArrow();this.scrollHandler=t,this.resizeHandler=t,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(){if(!this.pickedElement)return;let e=(this.panel.element.shadowRoot?.querySelector(".panel-shell")??this.panel.element).getBoundingClientRect(),o=this.pickedElement.getBoundingClientRect();this.arrow.draw(e,o);}cleanup(){this.stopTrackingArrow(),this.arrow.remove(),this.pickedElement=null,this.snapshot=null,this.state="idle";}};function $t(n,t,e,o,i,r,s={type:"new-memory"}){let a=r??new st,l=new Dt(n,new it({onPick:d=>l._onElementPicked(d),onCancel:()=>l.onCancelCapture()}),new rt,a,t,e,o,i,s);return l}function ee(n){return n.replace(/\\n/g,`
|
|
20
|
+
`).replace(/\\t/g," ")}function vo(n,t){let e=document.createElement("div");e.id="unnoodle-btn-host",e.style.cssText="position:fixed;right:14px;top:50%;transform:translateY(-50%);z-index:2147483647;";let o=e.attachShadow({mode:"open"}),i=document.createElement("style");if(i.textContent=ee(`
|
|
21
21
|
:host { all: initial; }
|
|
22
22
|
|
|
23
23
|
/* Wrapper \u2014 gives ::after tooltip a positioning context */
|
|
@@ -120,7 +120,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
120
120
|
}
|
|
121
121
|
.trigger:not(.dragging):hover ~ .tip,
|
|
122
122
|
.trigger:not(.dragging):focus-visible ~ .tip { opacity: 1; }
|
|
123
|
-
`),
|
|
123
|
+
`),t){let b=document.createElement("style");b.textContent=ee(t),o.appendChild(b);}o.appendChild(i);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",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),n());});let a=document.createElement("span");a.className="tip";let l=/mac/i.test(navigator.platform||navigator.userAgent);a.textContent=l?"\u2318U":"Ctrl+U",r.appendChild(s),r.appendChild(a),o.appendChild(r);let d=false,u=false,m=0,v=0,f=0,x=0;function y(){let b=parseFloat(e.style.right)||14,T=e.style.top,D=T.endsWith("%")?parseFloat(T)/100*window.innerHeight-68:parseFloat(T)||window.innerHeight/2-68;return {right:b,topPx:D}}function L(b){if(b.button!==0)return;d=true,u=false,s.classList.add("dragging"),m=b.clientX,v=b.clientY;let T=y();f=T.right,x=T.topPx,b.preventDefault();}function R(b){if(!d)return;let T=b.clientX-m,D=b.clientY-v;(Math.abs(T)>3||Math.abs(D)>3)&&(u=true);let z=lt(f-T,8,window.innerWidth-46),_=lt(x+D,8,window.innerHeight-160);e.style.right=`${z}px`,e.style.top=`${_}px`,e.style.transform="none";}function H(b){d&&(d=false,s.classList.remove("dragging"),u||n(),b.preventDefault());}function I(b){let T=b.touches[0];if(!T)return;d=true,u=false,s.classList.add("dragging"),m=T.clientX,v=T.clientY;let D=y();f=D.right,x=D.topPx;}function q(b){if(!d)return;let T=b.touches[0];if(!T)return;let D=T.clientX-m,z=T.clientY-v;(Math.abs(D)>3||Math.abs(z)>3)&&(u=true);let _=lt(f-D,8,window.innerWidth-46),V=lt(x+z,8,window.innerHeight-160);e.style.right=`${_}px`,e.style.top=`${V}px`,e.style.transform="none",b.preventDefault();}function N(){d&&(d=false,s.classList.remove("dragging"),u||n());}return s.addEventListener("mousedown",L),document.addEventListener("mousemove",R),document.addEventListener("mouseup",H),s.addEventListener("touchstart",I,{passive:true}),document.addEventListener("touchmove",q,{passive:false}),document.addEventListener("touchend",N),{element:e,cleanup:()=>{s.removeEventListener("mousedown",L),s.removeEventListener("touchstart",I),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",H),document.removeEventListener("touchmove",q),document.removeEventListener("touchend",N),e.remove();},setProgress:b=>{s.classList.toggle("loading",b),s.setAttribute("aria-busy",String(b));}}}function lt(n,t,e){return Math.min(Math.max(n,t),e)}var bo=`
|
|
124
124
|
:host {
|
|
125
125
|
all: initial;
|
|
126
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
|
|
@@ -1263,7 +1263,119 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1263
1263
|
}
|
|
1264
1264
|
.add-term-input:focus { border-color: var(--unn-color-brand-primary); }
|
|
1265
1265
|
.add-term-input + .add-term-input { margin-top: 6px; }
|
|
1266
|
-
|
|
1266
|
+
/* \u2500\u2500 Ask view (LQ-12) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
1267
|
+
.home-ask-entry {
|
|
1268
|
+
display: flex; align-items: center; gap: 6px; width: 100%;
|
|
1269
|
+
margin: 0 0 6px 0; padding: 8px 10px; cursor: pointer; text-align: left;
|
|
1270
|
+
font-family: inherit; font-size: var(--w-font-base);
|
|
1271
|
+
color: var(--unn-color-text-primary);
|
|
1272
|
+
background: var(--unn-color-bg-tertiary);
|
|
1273
|
+
border: 1px solid var(--unn-color-border-default); border-radius: 6px;
|
|
1274
|
+
}
|
|
1275
|
+
.home-ask-entry:hover { border-color: var(--unn-color-brand-primary); }
|
|
1276
|
+
.ask-view { display: flex; flex-direction: column; }
|
|
1277
|
+
.askv-head { padding: 10px 12px 4px; }
|
|
1278
|
+
.askv-title {
|
|
1279
|
+
font-size: var(--w-font-md); font-weight: var(--w-weight-semi);
|
|
1280
|
+
color: var(--unn-color-text-primary);
|
|
1281
|
+
}
|
|
1282
|
+
.askv-notice {
|
|
1283
|
+
display: flex; align-items: flex-start; gap: 8px; margin: 8px 12px;
|
|
1284
|
+
padding: 8px 10px; border-radius: 6px; line-height: 1.4;
|
|
1285
|
+
font-size: var(--w-font-sm); color: var(--unn-color-text-muted);
|
|
1286
|
+
background: var(--unn-color-bg-tertiary);
|
|
1287
|
+
border: 1px solid var(--unn-color-border-default);
|
|
1288
|
+
}
|
|
1289
|
+
.askv-notice-dismiss {
|
|
1290
|
+
flex: 0 0 auto; cursor: pointer; font-family: inherit;
|
|
1291
|
+
font-size: var(--w-font-sm); padding: 2px 8px; border-radius: 4px;
|
|
1292
|
+
background: transparent; color: var(--unn-color-brand-primary);
|
|
1293
|
+
border: 1px solid var(--unn-color-border-default);
|
|
1294
|
+
}
|
|
1295
|
+
.askv-form { padding: 8px 12px 0; }
|
|
1296
|
+
.askv-form-footer {
|
|
1297
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
1298
|
+
margin-top: 6px;
|
|
1299
|
+
}
|
|
1300
|
+
.askv-counter { font-size: var(--w-font-xs); color: var(--unn-color-text-muted); }
|
|
1301
|
+
.askv-limits, .askv-provenance {
|
|
1302
|
+
padding: 6px 12px; font-size: var(--w-font-xs);
|
|
1303
|
+
color: var(--unn-color-text-muted);
|
|
1304
|
+
}
|
|
1305
|
+
.askv-disabled {
|
|
1306
|
+
margin: 8px 12px; padding: 10px; border-radius: 6px;
|
|
1307
|
+
font-size: var(--w-font-base); color: var(--unn-color-text-muted);
|
|
1308
|
+
background: var(--unn-color-bg-tertiary);
|
|
1309
|
+
border: 1px solid var(--unn-color-border-default);
|
|
1310
|
+
}
|
|
1311
|
+
.askv-result { padding: 0 12px 12px; }
|
|
1312
|
+
.askv-staleness { font-size: var(--w-font-xs); margin: 6px 0; }
|
|
1313
|
+
.askv-tone-ok { color: var(--unn-color-text-muted); }
|
|
1314
|
+
.askv-tone-muted { color: var(--unn-color-text-muted); opacity: 0.85; }
|
|
1315
|
+
.askv-tone-warn { color: #b45309; }
|
|
1316
|
+
.askv-loading {
|
|
1317
|
+
display: flex; align-items: center; gap: 8px; padding: 12px 0;
|
|
1318
|
+
font-size: var(--w-font-base); color: var(--unn-color-text-muted);
|
|
1319
|
+
}
|
|
1320
|
+
.askv-spinner {
|
|
1321
|
+
width: 12px; height: 12px; border-radius: 50%;
|
|
1322
|
+
border: 2px solid var(--unn-color-border-default);
|
|
1323
|
+
border-top-color: var(--unn-color-brand-primary);
|
|
1324
|
+
animation: askv-spin 0.7s linear infinite;
|
|
1325
|
+
}
|
|
1326
|
+
@keyframes askv-spin { to { transform: rotate(360deg); } }
|
|
1327
|
+
.askv-answer {
|
|
1328
|
+
font-size: var(--w-font-base); line-height: 1.55; white-space: pre-wrap;
|
|
1329
|
+
color: var(--unn-color-text-primary);
|
|
1330
|
+
}
|
|
1331
|
+
.askv-unnarrated {
|
|
1332
|
+
font-size: var(--w-font-base); line-height: 1.5; margin-bottom: 8px;
|
|
1333
|
+
color: var(--unn-color-text-muted);
|
|
1334
|
+
}
|
|
1335
|
+
.ask-chip {
|
|
1336
|
+
display: inline-block; margin: 0 2px; padding: 1px 6px;
|
|
1337
|
+
border-radius: 10px; font-size: var(--w-font-xs); white-space: nowrap;
|
|
1338
|
+
background: var(--unn-color-bg-tertiary);
|
|
1339
|
+
color: var(--unn-color-text-primary);
|
|
1340
|
+
border: 1px solid var(--unn-color-border-default);
|
|
1341
|
+
}
|
|
1342
|
+
.askv-section { margin-top: 12px; }
|
|
1343
|
+
.askv-section-title {
|
|
1344
|
+
font-size: var(--w-font-xxs); letter-spacing: 0.06em;
|
|
1345
|
+
color: var(--unn-color-text-muted); margin-bottom: 4px;
|
|
1346
|
+
}
|
|
1347
|
+
.askv-path { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 3px 0; }
|
|
1348
|
+
.askv-path-arrow { color: var(--unn-color-text-muted); font-size: var(--w-font-xs); }
|
|
1349
|
+
.askv-note {
|
|
1350
|
+
padding: 6px 8px; margin-bottom: 4px; cursor: pointer; border-radius: 6px;
|
|
1351
|
+
border: 1px solid var(--unn-color-border-default);
|
|
1352
|
+
}
|
|
1353
|
+
.askv-note:hover { border-color: var(--unn-color-brand-primary); }
|
|
1354
|
+
.askv-note-title {
|
|
1355
|
+
font-size: var(--w-font-base); font-weight: var(--w-weight-semi);
|
|
1356
|
+
color: var(--unn-color-text-primary);
|
|
1357
|
+
}
|
|
1358
|
+
.askv-note-route, .askv-note-body {
|
|
1359
|
+
font-size: var(--w-font-xs); color: var(--unn-color-text-muted); margin-top: 2px;
|
|
1360
|
+
}
|
|
1361
|
+
.askv-confidence-row {
|
|
1362
|
+
display: flex; gap: 6px; flex-wrap: wrap;
|
|
1363
|
+
font-size: var(--w-font-xs); color: var(--unn-color-text-muted);
|
|
1364
|
+
}
|
|
1365
|
+
.askv-confidence-claim { color: var(--unn-color-text-primary); }
|
|
1366
|
+
.askv-error {
|
|
1367
|
+
display: flex; align-items: center; justify-content: space-between; gap: 8px;
|
|
1368
|
+
margin-top: 10px; padding: 8px 10px; border-radius: 6px;
|
|
1369
|
+
font-size: var(--w-font-base); color: #b42318;
|
|
1370
|
+
background: var(--unn-color-bg-tertiary); border: 1px solid #f3c6c2;
|
|
1371
|
+
}
|
|
1372
|
+
.askv-retry {
|
|
1373
|
+
flex: 0 0 auto; cursor: pointer; font-family: inherit;
|
|
1374
|
+
font-size: var(--w-font-sm); padding: 3px 8px; border-radius: 4px;
|
|
1375
|
+
background: var(--unn-color-brand-primary); color: #fff; border: none;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
`,yo=`
|
|
1267
1379
|
.panel-shell {
|
|
1268
1380
|
position: static !important;
|
|
1269
1381
|
width: 100vw !important; height: 100vh !important;
|
|
@@ -1279,11 +1391,11 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1279
1391
|
/* Fallback bg if CSS vars haven't re-resolved after adoptNode */
|
|
1280
1392
|
background: var(--unn-color-bg-primary, #ffffff) !important;
|
|
1281
1393
|
}
|
|
1282
|
-
`;function
|
|
1394
|
+
`;function wo(n,t,e){let o=e?.googleEnabled===true,i=e?.microsoftEnabled===true,r=o||i,d=r?`${r?`<div class="sso-divider" data-testid="widget-sso-divider">
|
|
1283
1395
|
<div class="sso-divider-line"></div>
|
|
1284
1396
|
<span class="sso-divider-text">or sign in with</span>
|
|
1285
1397
|
<div class="sso-divider-line"></div>
|
|
1286
|
-
</div>`:""}<div class="sso-buttons">${
|
|
1398
|
+
</div>`:""}<div class="sso-buttons">${o?`<button class="sso-btn" type="button" data-testid="widget-sso-google-btn" aria-label="Continue with Google">
|
|
1287
1399
|
<svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true">
|
|
1288
1400
|
<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
1401
|
<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"/>
|
|
@@ -1291,7 +1403,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1291
1403
|
<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
1404
|
</svg>
|
|
1293
1405
|
<span>Continue with Google</span>
|
|
1294
|
-
</button>`:""}${
|
|
1406
|
+
</button>`:""}${i?`<button class="sso-btn" type="button" data-testid="widget-sso-microsoft-btn" aria-label="Continue with Microsoft">
|
|
1295
1407
|
<svg width="18" height="18" viewBox="0 0 23 23" aria-hidden="true">
|
|
1296
1408
|
<rect x="1" y="1" width="10" height="10" fill="#F25022"/>
|
|
1297
1409
|
<rect x="12" y="1" width="10" height="10" fill="#7FBA00"/>
|
|
@@ -1299,9 +1411,9 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1299
1411
|
<rect x="12" y="12" width="10" height="10" fill="#FFB900"/>
|
|
1300
1412
|
</svg>
|
|
1301
1413
|
<span>Continue with Microsoft</span>
|
|
1302
|
-
</button>`:""}</div>`:"";
|
|
1414
|
+
</button>`:""}</div>`:"";n.innerHTML=`
|
|
1303
1415
|
<div class="login-form">
|
|
1304
|
-
${
|
|
1416
|
+
${t.onBack?'<button class="login-back-btn" data-testid="widget-login-back" type="button">\u2039 Back</button>':""}
|
|
1305
1417
|
<h2 class="login-heading">Sign in to Unnoodle</h2>
|
|
1306
1418
|
<p class="login-sub">Access your team's glossary</p>
|
|
1307
1419
|
<div class="login-error" role="alert" data-testid="widget-login-error"></div>
|
|
@@ -1320,22 +1432,22 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1320
1432
|
<button class="form-submit" id="unn-submit" data-testid="widget-login-submit">Sign in</button>
|
|
1321
1433
|
${d}
|
|
1322
1434
|
</div>
|
|
1323
|
-
`;let
|
|
1435
|
+
`;let u=n.querySelector('[data-testid="widget-login-back"]');if(u&&t.onBack){let y=t.onBack;u.addEventListener("click",()=>y());}let m=n.querySelector("#unn-email"),v=n.querySelector("#unn-password"),f=n.querySelector("#unn-submit"),x=y=>{y.preventDefault();let L=m.value.trim(),R=v.value;!L||!R||t.onLogin(L,R);};if(f.addEventListener("click",x),v.addEventListener("keydown",y=>{y.key==="Enter"&&x(y);}),t.onSsoLogin){let y=t.onSsoLogin;o&&n.querySelector('[data-testid="widget-sso-google-btn"]')?.addEventListener("click",()=>y("google")),i&&n.querySelector('[data-testid="widget-sso-microsoft-btn"]')?.addEventListener("click",()=>y("microsoft"));}m.focus();}function xo(n,t){let e=n.querySelector("#unn-submit");e&&(e.disabled=t,e.textContent=t?"Signing in\u2026":"Sign in");}function ko(n,t){let e=n.querySelector(".login-error");e&&(e.textContent=t,e.classList.add("visible"));}function P(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Eo(n,t,e,o){let i=P(t.authorName??"Unknown"),r=t.createdAt?new Date(t.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"",s=(t.replies??[]).length===0?'<div class="clarif-empty-replies">No replies yet.</div>':t.replies.map(d=>`
|
|
1324
1436
|
<div class="clarif-reply-item">
|
|
1325
1437
|
<div class="discussion-meta">
|
|
1326
1438
|
<span class="discussion-meta-dot"></span>
|
|
1327
|
-
${
|
|
1328
|
-
${new Date(
|
|
1439
|
+
${P(d.authorName??"Unknown")} ·
|
|
1440
|
+
${new Date(d.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}
|
|
1329
1441
|
</div>
|
|
1330
|
-
<p class="discussion-body" style="-webkit-line-clamp:unset">${
|
|
1331
|
-
</div>`
|
|
1442
|
+
<p class="discussion-body" style="-webkit-line-clamp:unset">${P(d.body)}</p>
|
|
1443
|
+
</div>`).join(""),a=e?`<div class="clarif-reply-form" data-testid="widget-reply-form">
|
|
1332
1444
|
<textarea class="ask-textarea" data-testid="widget-reply-textarea"
|
|
1333
1445
|
placeholder="Write a reply\u2026" maxlength="2000" rows="3"></textarea>
|
|
1334
1446
|
<div class="ask-actions">
|
|
1335
1447
|
<button class="ask-submit" data-testid="widget-reply-submit">Reply</button>
|
|
1336
1448
|
</div>
|
|
1337
1449
|
<p class="ask-error" style="display:none"></p>
|
|
1338
|
-
</div>`:"";if(
|
|
1450
|
+
</div>`:"";if(n.innerHTML=`
|
|
1339
1451
|
<div class="term-detail-view" data-testid="widget-clarif-detail">
|
|
1340
1452
|
<div class="detail-back">
|
|
1341
1453
|
<button class="back-btn" data-testid="widget-back-btn">← Back</button>
|
|
@@ -1343,22 +1455,88 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1343
1455
|
<div class="detail-content">
|
|
1344
1456
|
<div class="detail-body">
|
|
1345
1457
|
<div class="clarif-label">CLARIFICATION</div>
|
|
1346
|
-
<p class="clarif-question">${
|
|
1458
|
+
<p class="clarif-question">${P(t.body)}</p>
|
|
1347
1459
|
<div class="discussion-meta" style="margin-top:6px">
|
|
1348
1460
|
<span class="discussion-meta-dot"></span>
|
|
1349
|
-
${
|
|
1461
|
+
${i} · ${r}
|
|
1350
1462
|
</div>
|
|
1351
1463
|
</div>
|
|
1352
1464
|
</div>
|
|
1353
1465
|
<div class="discussions-section">
|
|
1354
|
-
<div class="discussions-heading">Replies (${(
|
|
1466
|
+
<div class="discussions-heading">Replies (${(t.replies??[]).length})</div>
|
|
1355
1467
|
${s}
|
|
1356
1468
|
</div>
|
|
1357
1469
|
${a}
|
|
1358
1470
|
</div>
|
|
1359
|
-
`,
|
|
1471
|
+
`,n.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>o.onBack?.()),e){let d=n.querySelector('[data-testid="widget-reply-textarea"]'),u=n.querySelector('[data-testid="widget-reply-submit"]'),m=n.querySelector(".ask-error");u.addEventListener("click",()=>{let v=d.value.trim();v&&(m.style.display="none",u.disabled=true,u.textContent="Posting\u2026",o.onPostReply?.(t.contextId,t.id,v));});}}function To(n,t){n.querySelector(".strip-idle").style.display="none";let e=n.querySelector(".pick-mode-prompt");e.style.display="flex",n.querySelector(".capture-describe-view").style.display="none";let o=n.querySelector('[data-testid="widget-context-strip-cancel-btn"]'),i=o.cloneNode(true);i.addEventListener("click",t),o.replaceWith(i);}function Co(n,t,e,o){n.querySelector(".strip-idle").style.display="none",n.querySelector(".pick-mode-prompt").style.display="none";let i=n.querySelector(".capture-describe-view");i.style.display="flex";let r=i.querySelector('[data-testid="widget-capture-snapshot-preview"]');r.innerHTML=t.html;let s=i.querySelector('[data-testid="widget-capture-pick-again-btn"]'),a=s.cloneNode(true);a.addEventListener("click",o),s.replaceWith(a);let l=i.querySelector('[data-testid="widget-capture-save-btn"]'),d=l.cloneNode(true);i.querySelector(".capture-error").style.display="none",d.addEventListener("click",()=>{let u=i.querySelector('[data-testid="widget-capture-description-input"]');e(u.value.trim());}),l.replaceWith(d);}function Mo(n,t){let e=n.querySelector('[data-testid="widget-capture-save-btn"]');e&&(e.disabled=t,e.textContent=t?"Saving\u2026":"Save");}function Ao(n,t){let e=n.querySelector(".capture-error");e&&(e.textContent=t,e.style.display=t?"block":"none");}function Lo(n){n.querySelector(".strip-idle").style.display="flex",n.querySelector(".pick-mode-prompt").style.display="none",n.querySelector(".capture-describe-view").style.display="none";let t=n.querySelector('[data-testid="widget-capture-description-input"]');t&&(t.value="");let e=n.querySelector(".capture-error");e&&(e.textContent="",e.style.display="none");}var Wi="Your question is sent to OpenAI. Names of buttons and fields are never sent \u2014 only page routes and your team's notes.",So=false;function ji(n,t,e){return e(n??"").replace(/\[n\d+\]/g,i=>{let r=i.slice(1,-1),s=t?.[r];if(!s)return "";let a=`${e(s.kind??"")} \xB7 ${e(s.routeClass??"")}`;return `<span class="ask-chip" data-ref="${r}" data-testid="widget-ask-chip-${r}" title="${e(s.tier??"")}">${a}</span>`})}function Zi(n,t,e){if(!t)return "";let o=e(n);return `<span class="ask-chip" data-ref="${o}" data-testid="widget-ask-path-chip-${o}">${e(t.kind??"")} \xB7 ${e(t.routeClass??"")}</span>`}var Ki=3600;function Yi(n,t){let e=n?Date.parse(n):NaN,o=Number.isNaN(e)?Date.now()-Math.max(0,t)*1e3:e,i=new Date(o);return Number.isNaN(i.getTime())?"":`${String(i.getHours()).padStart(2,"0")}:${String(i.getMinutes()).padStart(2,"0")}`}function Ho(n){let t=n?.graph,e=n?.stalenessSeconds??0,o=()=>`graph as of ${Yi(n?.builtAt,e)} \xB7 generation ${n?.generation??0}`;switch(t){case "warm":return {text:o(),tone:e>Ki?"warn":"ok"};case "stale":return {text:o(),tone:"warn"};case "cold":return {text:"graph warming up \u2014 team notes only",tone:"muted"};case "empty":case "none":case "erased":return {text:"no graph yet \u2014 team notes only",tone:"muted"};case "no-anchor":return {text:"",tone:"muted"};default:return {text:"",tone:"muted"}}}function Xi(n){return Ho({graph:n.graph,generation:n.generation,builtAt:"",stalenessSeconds:n.stalenessSeconds})}function Ro(n,t,e){let o=null,i=h=>e(String(h??""));function r(){return n.querySelector('[data-testid="widget-ask-view"]')}function s(){return n.querySelector('[data-testid="widget-ask-result"]')}function a(){return n.querySelector('[data-testid="widget-ask-input"]')}function l(){return n.querySelector('[data-testid="widget-ask-submit"]')}function d(){r()||R(o);}function u(h,g){return h.text?`<div class="askv-staleness askv-tone-${h.tone}" data-testid="${g}">${i(h.text)}</div>`:""}function m(h){return !h||h.length===0?"":`
|
|
1472
|
+
<div class="askv-section" data-testid="widget-ask-notes">
|
|
1473
|
+
<div class="askv-section-title">FROM YOUR TEAM'S NOTES</div>
|
|
1474
|
+
${h.map(b=>`
|
|
1475
|
+
<div class="askv-note" data-testid="widget-ask-note" data-memory-id="${Number(b.memoryId)||0}">
|
|
1476
|
+
<div class="askv-note-title">${i(b.title)}</div>
|
|
1477
|
+
${b.route?`<div class="askv-note-route">${i(b.route)}</div>`:""}
|
|
1478
|
+
<div class="askv-note-body">${i(b.explanation)}</div>
|
|
1479
|
+
</div>`).join("")}
|
|
1480
|
+
</div>`}function v(h){let g=h.paths??[];if(g.length===0)return "";let b=g.map(T=>{let D=(T.refs??[]).map(z=>Zi(z,h.references?.[z],e)).filter(Boolean).join('<span class="askv-path-arrow">\u2192</span>');return D?`<div class="askv-path" data-testid="widget-ask-path">${D}</div>`:""}).filter(Boolean).join("");return b?`
|
|
1481
|
+
<div class="askv-section" data-testid="widget-ask-paths">
|
|
1482
|
+
<div class="askv-section-title">WHAT THE GRAPH SHOWS</div>
|
|
1483
|
+
${b}
|
|
1484
|
+
</div>`:""}function f(h){let g=h.confidence??[];return g.length===0?"":`
|
|
1485
|
+
<div class="askv-section" data-testid="widget-ask-confidence">
|
|
1486
|
+
<div class="askv-section-title">CONFIDENCE</div>
|
|
1487
|
+
${g.map(T=>`
|
|
1488
|
+
<div class="askv-confidence-row" data-testid="widget-ask-confidence-row">
|
|
1489
|
+
<span class="askv-confidence-claim">${i(T.claim)}</span>
|
|
1490
|
+
<span class="askv-confidence-basis">${i(T.basis)}</span>
|
|
1491
|
+
<span class="askv-confidence-assumption">${i(T.assumption)}</span>
|
|
1492
|
+
</div>`).join("")}
|
|
1493
|
+
</div>`}function x(h){let g=h.provenance;if(!g)return "";let b=[`retrieval ${Math.max(0,Math.round(h.timing?.retrievalMs??0))} ms`,`model ${Math.max(0,Math.round(h.timing?.modelMs??0))} ms`,`notes ${g.notes}`,`model ${g.model}`,`${g.flowsConsidered??0} flow${(g.flowsConsidered??0)===1?"":"s"} considered`];return g.appBuild&&b.push(`build ${g.appBuild}`),`<div class="askv-provenance" data-testid="widget-ask-provenance">${i(b.join(" \xB7 "))}</div>`}function y(){n.querySelectorAll('[data-testid="widget-ask-note"]').forEach(h=>{h.addEventListener("click",()=>{let g=Number(h.dataset.memoryId);g&&t.onOpenMemory?.(g);});});}function L(){let h=a();if(!h)return;let g=h.value.trim();g&&t.onAsk(g);}function R(h){o=h;let g=h!==null&&h.enabled===false,b=So||g?"":`<div class="askv-notice" data-testid="widget-ask-first-use-notice">
|
|
1494
|
+
<span>${i(Wi)}</span>
|
|
1495
|
+
<button class="askv-notice-dismiss" data-testid="widget-ask-notice-dismiss" aria-label="Dismiss">Got it</button>
|
|
1496
|
+
</div>`,T=g?`<div class="askv-disabled" data-testid="widget-ask-disabled">
|
|
1497
|
+
Ask is turned off for this workspace.
|
|
1498
|
+
</div>`:`<div class="askv-form">
|
|
1499
|
+
<textarea class="ask-textarea" data-testid="widget-ask-input" rows="3"
|
|
1500
|
+
maxlength="500"
|
|
1501
|
+
placeholder="How do I create an invoice?" aria-label="Your question"></textarea>
|
|
1502
|
+
<div class="askv-form-footer">
|
|
1503
|
+
<span class="askv-counter" data-testid="widget-ask-counter">0/500</span>
|
|
1504
|
+
<button class="ask-submit" data-testid="widget-ask-submit">Ask</button>
|
|
1505
|
+
</div>
|
|
1506
|
+
</div>`,D=h&&h.enabled&&h.limits?`<div class="askv-limits" data-testid="widget-ask-limits">${i(`${Math.max(0,h.limits.remainingToday)} of ${h.limits.perDay} questions left today`)}</div>`:"";if(n.innerHTML=`
|
|
1507
|
+
<div class="ask-view" data-testid="widget-ask-view">
|
|
1508
|
+
<div class="detail-back">
|
|
1509
|
+
<button class="back-btn" data-testid="widget-back-btn">← Back</button>
|
|
1510
|
+
</div>
|
|
1511
|
+
<div class="askv-head">
|
|
1512
|
+
<div class="askv-title">Ask about this product</div>
|
|
1513
|
+
${h?u(Xi(h),"widget-ask-status-staleness"):""}
|
|
1514
|
+
</div>
|
|
1515
|
+
${b}
|
|
1516
|
+
${T}
|
|
1517
|
+
${D}
|
|
1518
|
+
<div class="askv-result" data-testid="widget-ask-result"></div>
|
|
1519
|
+
</div>
|
|
1520
|
+
`,n.querySelector('[data-testid="widget-back-btn"]')?.addEventListener("click",()=>t.onBack?.()),n.querySelector('[data-testid="widget-ask-notice-dismiss"]')?.addEventListener("click",()=>{So=true,n.querySelector('[data-testid="widget-ask-first-use-notice"]')?.remove();}),!g){let z=a(),_=n.querySelector('[data-testid="widget-ask-counter"]');z?.addEventListener("input",()=>{_&&(_.textContent=`${z.value.length}/500`);}),z?.addEventListener("keydown",V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),L());}),l()?.addEventListener("click",L);}}function H(){d();let h=a();h&&(h.disabled=true);let g=l();g&&(g.disabled=true,g.textContent="Asking\u2026");let b=s();b&&(b.innerHTML=`
|
|
1521
|
+
<div class="askv-loading" data-testid="widget-ask-loading">
|
|
1522
|
+
<span class="askv-spinner" aria-hidden="true"></span>
|
|
1523
|
+
<span>Asking\u2026</span>
|
|
1524
|
+
</div>`);}function I(){let h=a();h&&(h.disabled=false);let g=l();g&&(g.disabled=false,g.textContent="Ask"),n.querySelector('[data-testid="widget-ask-loading"]')?.remove();}function q(h){d(),I();let g=s();if(!g)return;let b=typeof h.answer=="string"&&h.answer.trim()!=="",T=b?`<div class="askv-answer" data-testid="widget-ask-answer">${ji(h.answer,h.references??{},e)}</div>`:`<div class="askv-unnarrated" data-testid="widget-ask-unnarrated">
|
|
1525
|
+
Unnoodle couldn't write this up, so here is what it found.
|
|
1526
|
+
</div>`;g.innerHTML=`
|
|
1527
|
+
${u(Ho(h.provenance),"widget-ask-staleness")}
|
|
1528
|
+
${T}
|
|
1529
|
+
${b?"":v(h)}
|
|
1530
|
+
${m(h.notes??[])}
|
|
1531
|
+
${f(h)}
|
|
1532
|
+
${x(h)}
|
|
1533
|
+
`;let D=a();D&&(D.value="");let z=n.querySelector('[data-testid="widget-ask-counter"]');z&&(z.textContent="0/500"),y();}function N(h,g){d(),I();let b=s();b&&(b.innerHTML=`
|
|
1534
|
+
<div class="askv-error" data-testid="widget-ask-error" data-retryable="${g?"true":"false"}" role="alert">
|
|
1535
|
+
<span>${i(h)}</span>
|
|
1536
|
+
${g?'<button class="askv-retry" data-testid="widget-ask-retry">Try again</button>':""}
|
|
1537
|
+
</div>`,n.querySelector('[data-testid="widget-ask-retry"]')?.addEventListener("click",L));}return {render:R,setLoading:H,clearLoading:I,showAnswer:q,showError:N}}function It(n,t){let e=document.createElement("div");e.className="capture-form-container",e.setAttribute("data-testid","widget-capture-form");let o=`
|
|
1360
1538
|
<style>
|
|
1361
|
-
${
|
|
1539
|
+
${ee(`
|
|
1362
1540
|
.capture-form-container {
|
|
1363
1541
|
display: flex;
|
|
1364
1542
|
flex-direction: column;
|
|
@@ -1532,10 +1710,10 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1532
1710
|
}
|
|
1533
1711
|
`)}
|
|
1534
1712
|
</style>
|
|
1535
|
-
<h2 class="capture-form-header">${
|
|
1536
|
-
${
|
|
1713
|
+
<h2 class="capture-form-header">${t.headerText||(t.showTitle?"New Product Memory":"Add Entry")}</h2>
|
|
1714
|
+
${t.subheaderText?`<p class="capture-form-subheader">${t.subheaderText}</p>`:""}
|
|
1537
1715
|
|
|
1538
|
-
${
|
|
1716
|
+
${t.showTitle?`
|
|
1539
1717
|
<div class="capture-form-field">
|
|
1540
1718
|
<label class="capture-form-label" for="capture-form-title">Title *</label>
|
|
1541
1719
|
<input
|
|
@@ -1602,7 +1780,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1602
1780
|
Save
|
|
1603
1781
|
</button>
|
|
1604
1782
|
</div>
|
|
1605
|
-
`;
|
|
1783
|
+
`;e.innerHTML=o;let i=e.querySelector("#capture-form-title"),r=e.querySelector("#capture-form-explanation"),s=e.querySelector(".capture-form-snapshot-container"),a=e.querySelector('[data-testid="widget-capture-form-pick-btn"]'),l=e.querySelector('[data-testid="widget-capture-form-save"]'),d=e.querySelector('[data-testid="widget-capture-form-cancel"]'),u=e.querySelector('[data-testid="widget-capture-form-error"]'),m=e.querySelector('[data-testid="widget-capture-form-watch-toggle"]');return console.log("[unnoodle] Form elements found:",{titleInput:i,explanationTextarea:r,snapshotContainer:s,pickBtn:a,saveBtn:l,cancelBtn:d,errorEl:u}),a.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),n.onPickElement();}),d.addEventListener("click",()=>{console.log("[unnoodle] Cancel button clicked"),n.onCancel();}),l.addEventListener("click",()=>{console.log("[unnoodle] Save button clicked");let f=i?i.value.trim():"",x=r.value.trim();if(t.showTitle&&!f){u.textContent="Title is required",u.classList.add("visible");return}if(!x){u.textContent="Explanation is required",u.classList.add("visible");return}u.classList.remove("visible"),n.onSave(f,x,m.checked);}),{element:e,controller:{setSnapshot:f=>{if(f)s.className="capture-form-snapshot-container",s.innerHTML=`<div class="capture-form-snapshot-preview">${f.html}</div>`;else {s.className="capture-form-snapshot-container",s.innerHTML=`
|
|
1606
1784
|
<div class="capture-form-snapshot-empty">No UI state captured yet</div>
|
|
1607
1785
|
<button
|
|
1608
1786
|
type="button"
|
|
@@ -1611,7 +1789,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1611
1789
|
>
|
|
1612
1790
|
Pick UI state
|
|
1613
1791
|
</button>
|
|
1614
|
-
`;let
|
|
1792
|
+
`;let x=s.querySelector('[data-testid="widget-capture-form-pick-btn"]');x&&x.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),n.onPickElement();});}},setPickingMode:f=>{if(f){s.className="capture-form-snapshot-container picking",s.innerHTML=`
|
|
1615
1793
|
<div class="capture-form-snapshot-empty">UI state capture in progress...</div>
|
|
1616
1794
|
<button
|
|
1617
1795
|
type="button"
|
|
@@ -1620,7 +1798,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1620
1798
|
>
|
|
1621
1799
|
Cancel capture
|
|
1622
1800
|
</button>
|
|
1623
|
-
`;let
|
|
1801
|
+
`;let x=s.querySelector('[data-testid="widget-capture-form-cancel-capture-btn"]');x&&x.addEventListener("click",()=>{console.log("[unnoodle] Cancel capture clicked"),n.onCancelCapture();});}else {s.className="capture-form-snapshot-container",s.innerHTML=`
|
|
1624
1802
|
<div class="capture-form-snapshot-empty">No UI state captured yet</div>
|
|
1625
1803
|
<button
|
|
1626
1804
|
type="button"
|
|
@@ -1629,7 +1807,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1629
1807
|
>
|
|
1630
1808
|
Pick UI state
|
|
1631
1809
|
</button>
|
|
1632
|
-
`;let
|
|
1810
|
+
`;let x=s.querySelector('[data-testid="widget-capture-form-pick-btn"]');x&&x.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),n.onPickElement();});}},setLoading:f=>{l.disabled=f,l.textContent=f?"Saving\u2026":"Save",a.disabled=f,d.disabled=f,i&&(i.disabled=f),r.disabled=f;},setError:f=>{u.textContent=f,u.classList.add("visible");},clear:()=>{i&&(i.value=""),r.value="",s.className="capture-form-snapshot-container",s.innerHTML=`
|
|
1633
1811
|
<div class="capture-form-snapshot-empty">No UI state captured yet</div>
|
|
1634
1812
|
<button
|
|
1635
1813
|
type="button"
|
|
@@ -1638,10 +1816,10 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1638
1816
|
>
|
|
1639
1817
|
Pick UI state
|
|
1640
1818
|
</button>
|
|
1641
|
-
`;let
|
|
1819
|
+
`;let f=s.querySelector('[data-testid="widget-capture-form-pick-btn"]');f&&f.addEventListener("click",()=>{console.log("[unnoodle] Pick button clicked"),n.onPickElement();}),u.classList.remove("visible"),u.textContent="";}}}}var re="data-unnoodle-state-banner";function Po(n,t,e,o){He(n);let i=document.createElement("div");i.setAttribute(re,"true"),i.setAttribute("data-testid","state-change-banner"),i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.innerHTML=`
|
|
1642
1820
|
<style>
|
|
1643
|
-
${
|
|
1644
|
-
[${
|
|
1821
|
+
${ee(`
|
|
1822
|
+
[${re}] {
|
|
1645
1823
|
display: flex;
|
|
1646
1824
|
flex-direction: column;
|
|
1647
1825
|
gap: 8px;
|
|
@@ -1651,23 +1829,23 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1651
1829
|
font-size: 13px;
|
|
1652
1830
|
flex-shrink: 0;
|
|
1653
1831
|
}
|
|
1654
|
-
[${
|
|
1832
|
+
[${re}] .scb-heading {
|
|
1655
1833
|
font-weight: 600;
|
|
1656
1834
|
color: var(--unn-color-text-primary, #111);
|
|
1657
1835
|
display: flex;
|
|
1658
1836
|
align-items: center;
|
|
1659
1837
|
gap: 6px;
|
|
1660
1838
|
}
|
|
1661
|
-
[${
|
|
1839
|
+
[${re}] .scb-meaning {
|
|
1662
1840
|
color: var(--unn-color-text-body, #444);
|
|
1663
1841
|
font-size: 12px;
|
|
1664
1842
|
}
|
|
1665
|
-
[${
|
|
1843
|
+
[${re}] .scb-actions {
|
|
1666
1844
|
display: flex;
|
|
1667
1845
|
gap: 6px;
|
|
1668
1846
|
align-items: center;
|
|
1669
1847
|
}
|
|
1670
|
-
[${
|
|
1848
|
+
[${re}] .scb-save-btn {
|
|
1671
1849
|
padding: 4px 12px;
|
|
1672
1850
|
background: var(--unn-color-brand-primary, #4f46e5);
|
|
1673
1851
|
color: #fff;
|
|
@@ -1677,10 +1855,10 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1677
1855
|
font-weight: 500;
|
|
1678
1856
|
cursor: pointer;
|
|
1679
1857
|
}
|
|
1680
|
-
[${
|
|
1858
|
+
[${re}] .scb-save-btn:hover {
|
|
1681
1859
|
opacity: 0.88;
|
|
1682
1860
|
}
|
|
1683
|
-
[${
|
|
1861
|
+
[${re}] .scb-dismiss-btn {
|
|
1684
1862
|
padding: 4px 10px;
|
|
1685
1863
|
background: transparent;
|
|
1686
1864
|
color: var(--unn-color-text-muted, #888);
|
|
@@ -1689,7 +1867,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1689
1867
|
font-size: 12px;
|
|
1690
1868
|
cursor: pointer;
|
|
1691
1869
|
}
|
|
1692
|
-
[${
|
|
1870
|
+
[${re}] .scb-dismiss-btn:hover {
|
|
1693
1871
|
background: var(--unn-color-bg-hover, #e9e9e9);
|
|
1694
1872
|
}
|
|
1695
1873
|
`)}
|
|
@@ -1698,7 +1876,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1698
1876
|
<span aria-hidden="true">\u{1F50D}</span>
|
|
1699
1877
|
New state detected \u2014 Save it?
|
|
1700
1878
|
</div>
|
|
1701
|
-
${
|
|
1879
|
+
${t?`<div class="scb-meaning" data-testid="state-change-banner-meaning">${t}</div>`:""}
|
|
1702
1880
|
<div class="scb-actions">
|
|
1703
1881
|
<button type="button" class="scb-save-btn" data-testid="state-change-banner-save">
|
|
1704
1882
|
Save new state
|
|
@@ -1707,7 +1885,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1707
1885
|
Dismiss
|
|
1708
1886
|
</button>
|
|
1709
1887
|
</div>
|
|
1710
|
-
`;let r=
|
|
1888
|
+
`;let r=i.querySelector('[data-testid="state-change-banner-save"]'),s=i.querySelector('[data-testid="state-change-banner-dismiss"]');r.addEventListener("click",()=>{He(n),e();}),s.addEventListener("click",()=>{He(n),o();}),n.prepend(i);}function He(n){n.querySelector(`[${re}]`)?.remove();}function be(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var dt=class{constructor(t,e={}){this.container=t,this.callbacks=e;}showAllTerms(t,e){console.log("DEBUG: ListViewManager.showAllTerms called with",e.length,"terms");let o=`
|
|
1711
1889
|
<div class="list-view" data-testid="widget-terms-list-view">
|
|
1712
1890
|
<div class="list-header">
|
|
1713
1891
|
<button class="list-back-btn" data-testid="widget-back-to-home">
|
|
@@ -1715,17 +1893,17 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1715
1893
|
</button>
|
|
1716
1894
|
<div class="list-title">
|
|
1717
1895
|
<h2>Vocabulary</h2>
|
|
1718
|
-
<span class="list-count">${
|
|
1896
|
+
<span class="list-count">${e.length} terms</span>
|
|
1719
1897
|
</div>
|
|
1720
1898
|
<button class="list-add-btn" data-testid="widget-add-term">
|
|
1721
1899
|
+ Add
|
|
1722
1900
|
</button>
|
|
1723
1901
|
</div>
|
|
1724
1902
|
<div class="list-body">
|
|
1725
|
-
${this.renderTermsList(
|
|
1903
|
+
${this.renderTermsList(e)}
|
|
1726
1904
|
</div>
|
|
1727
1905
|
</div>
|
|
1728
|
-
`;this.container.innerHTML=
|
|
1906
|
+
`;this.container.innerHTML=o,this.attachTermsListeners();}showAllClarifications(t,e){console.log("DEBUG: ListViewManager.showAllClarifications called with",t.length,"discussions");let o=`
|
|
1729
1907
|
<div class="list-view" data-testid="widget-clarifications-list-view">
|
|
1730
1908
|
<div class="list-header">
|
|
1731
1909
|
<button class="list-back-btn" data-testid="widget-back-to-home">
|
|
@@ -1733,17 +1911,17 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1733
1911
|
</button>
|
|
1734
1912
|
<div class="list-title">
|
|
1735
1913
|
<h2>Clarifications</h2>
|
|
1736
|
-
<span class="list-count">${
|
|
1914
|
+
<span class="list-count">${t.length} questions</span>
|
|
1737
1915
|
</div>
|
|
1738
1916
|
<button class="list-add-btn" data-testid="widget-ask-question">
|
|
1739
1917
|
+ Ask
|
|
1740
1918
|
</button>
|
|
1741
1919
|
</div>
|
|
1742
1920
|
<div class="list-body">
|
|
1743
|
-
${this.renderClarificationsList(
|
|
1921
|
+
${this.renderClarificationsList(t)}
|
|
1744
1922
|
</div>
|
|
1745
1923
|
</div>
|
|
1746
|
-
`;this.container.innerHTML=
|
|
1924
|
+
`;this.container.innerHTML=o,this.attachClarificationsListeners();}showAllMemories(t,e){console.log("DEBUG: ListViewManager.showAllMemories called with",t.length,"memories");let o=`
|
|
1747
1925
|
<div class="list-view" data-testid="widget-memories-list-view">
|
|
1748
1926
|
<div class="list-header">
|
|
1749
1927
|
<button class="list-back-btn" data-testid="widget-back-to-home">
|
|
@@ -1751,27 +1929,27 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1751
1929
|
</button>
|
|
1752
1930
|
<div class="list-title">
|
|
1753
1931
|
<h2>Product Memories</h2>
|
|
1754
|
-
<span class="list-count">${
|
|
1932
|
+
<span class="list-count">${t.length} memories</span>
|
|
1755
1933
|
</div>
|
|
1756
1934
|
<button class="list-add-btn" data-testid="widget-new-memory">
|
|
1757
1935
|
+ New
|
|
1758
1936
|
</button>
|
|
1759
1937
|
</div>
|
|
1760
1938
|
<div class="list-body">
|
|
1761
|
-
${this.renderMemoriesList(
|
|
1939
|
+
${this.renderMemoriesList(t)}
|
|
1762
1940
|
</div>
|
|
1763
1941
|
</div>
|
|
1764
|
-
`;this.container.innerHTML=
|
|
1942
|
+
`;this.container.innerHTML=o,this.attachMemoriesListeners();}renderTermsList(t){return t.length===0?`
|
|
1765
1943
|
<div class="list-empty">
|
|
1766
1944
|
<div class="list-empty-title">No vocabulary terms yet.</div>
|
|
1767
1945
|
<div class="list-empty-text">Start building your shared vocabulary.</div>
|
|
1768
1946
|
</div>
|
|
1769
|
-
`:
|
|
1770
|
-
<div class="list-item" data-testid="widget-term-list-item" data-term-id="${
|
|
1947
|
+
`:t.map(e=>`
|
|
1948
|
+
<div class="list-item" data-testid="widget-term-list-item" data-term-id="${e.id}">
|
|
1771
1949
|
<div class="list-item-main">
|
|
1772
|
-
<div class="list-item-title">${
|
|
1773
|
-
<div class="list-item-subtitle">${
|
|
1774
|
-
${
|
|
1950
|
+
<div class="list-item-title">${be(e.term)}</div>
|
|
1951
|
+
<div class="list-item-subtitle">${be(e.definition)}</div>
|
|
1952
|
+
${e.abbreviation?`<div class="list-item-tag">${be(e.abbreviation)}</div>`:""}
|
|
1775
1953
|
</div>
|
|
1776
1954
|
<div class="list-item-action">
|
|
1777
1955
|
<svg viewBox="0 0 24 24" width="12" height="12">
|
|
@@ -1779,19 +1957,19 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1779
1957
|
</svg>
|
|
1780
1958
|
</div>
|
|
1781
1959
|
</div>
|
|
1782
|
-
`).join("")}renderClarificationsList(
|
|
1960
|
+
`).join("")}renderClarificationsList(t){return t.length===0?`
|
|
1783
1961
|
<div class="list-empty">
|
|
1784
1962
|
<div class="list-empty-title">No questions yet.</div>
|
|
1785
1963
|
<div class="list-empty-text">Ask if something about this interface is unclear.</div>
|
|
1786
1964
|
</div>
|
|
1787
|
-
`:
|
|
1788
|
-
<div class="list-item" data-testid="widget-clarification-list-item" data-discussion-id="${
|
|
1965
|
+
`:t.map(e=>`
|
|
1966
|
+
<div class="list-item" data-testid="widget-clarification-list-item" data-discussion-id="${e.id}">
|
|
1789
1967
|
<div class="list-item-main">
|
|
1790
|
-
<div class="list-item-title">${
|
|
1968
|
+
<div class="list-item-title">${be(e.body)}</div>
|
|
1791
1969
|
<div class="list-item-subtitle">
|
|
1792
|
-
${
|
|
1793
|
-
${new Date(
|
|
1794
|
-
${
|
|
1970
|
+
${be(e.authorName||"Unknown")} \xB7
|
|
1971
|
+
${new Date(e.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}
|
|
1972
|
+
${e.replies&&e.replies.length>0?` \xB7 ${e.replies.length} replies`:""}
|
|
1795
1973
|
</div>
|
|
1796
1974
|
</div>
|
|
1797
1975
|
<div class="list-item-action">
|
|
@@ -1800,18 +1978,18 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1800
1978
|
</svg>
|
|
1801
1979
|
</div>
|
|
1802
1980
|
</div>
|
|
1803
|
-
`).join("")}renderMemoriesList(
|
|
1981
|
+
`).join("")}renderMemoriesList(t){return t.length===0?`
|
|
1804
1982
|
<div class="list-empty">
|
|
1805
1983
|
<div class="list-empty-title">No captures yet.</div>
|
|
1806
1984
|
<div class="list-empty-text">Capture elements so teammates can understand the interface faster.</div>
|
|
1807
1985
|
</div>
|
|
1808
|
-
`:
|
|
1809
|
-
<div class="list-item" data-testid="widget-memory-list-item" data-memory-id="${
|
|
1986
|
+
`:t.map(e=>`
|
|
1987
|
+
<div class="list-item" data-testid="widget-memory-list-item" data-memory-id="${e.id}">
|
|
1810
1988
|
<div class="list-item-main">
|
|
1811
|
-
<div class="list-item-title">${
|
|
1989
|
+
<div class="list-item-title">${be(e.title)}</div>
|
|
1812
1990
|
<div class="list-item-subtitle">
|
|
1813
|
-
${
|
|
1814
|
-
${new Date(
|
|
1991
|
+
${e.entryCount} entries \xB7
|
|
1992
|
+
${new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}
|
|
1815
1993
|
</div>
|
|
1816
1994
|
</div>
|
|
1817
1995
|
<div class="list-item-action">
|
|
@@ -1820,7 +1998,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1820
1998
|
</svg>
|
|
1821
1999
|
</div>
|
|
1822
2000
|
</div>
|
|
1823
|
-
`).join("")}attachTermsListeners(){
|
|
2001
|
+
`).join("")}attachTermsListeners(){this.container.querySelector('[data-testid="widget-back-to-home"]')?.addEventListener("click",()=>this.callbacks.onBackToHome?.()),this.container.querySelector('[data-testid="widget-add-term"]')?.addEventListener("click",()=>this.callbacks.onAddTerm?.()),this.container.querySelectorAll('[data-testid="widget-term-list-item"]').forEach(i=>{i.addEventListener("click",()=>{let r=parseInt(i.getAttribute("data-term-id")||"0",10);this.callbacks.onTermClick?.(r);});});}attachClarificationsListeners(){this.container.querySelector('[data-testid="widget-back-to-home"]')?.addEventListener("click",()=>this.callbacks.onBackToHome?.());let e=this.container.querySelector('[data-testid="widget-add-clarification"]');e?.addEventListener("click",()=>{e?.getAttribute("data-requires-login")==="true"?this.callbacks.onRequireLogin?.():this.callbacks.onAddDiscussion?.();}),this.container.querySelectorAll('[data-testid="widget-clarification-list-item"]').forEach(i=>{i.addEventListener("click",()=>{let r=parseInt(i.getAttribute("data-discussion-id")||"0",10);this.callbacks.onDiscussionClick?.(r);});});}attachMemoriesListeners(){this.container.querySelector('[data-testid="widget-back-to-home"]')?.addEventListener("click",()=>this.callbacks.onBackToHome?.());let e=this.container.querySelector('[data-testid="widget-add-memory"]');e?.addEventListener("click",()=>{e?.getAttribute("data-requires-login")==="true"?this.callbacks.onRequireLogin?.():this.callbacks.onAddMemory?.();}),this.container.querySelectorAll('[data-testid="widget-memory-list-item"]').forEach(i=>{i.addEventListener("click",()=>{let r=parseInt(i.getAttribute("data-memory-id")||"0",10);this.callbacks.onMemoryClick?.(r);});});}};function Bo(){return `
|
|
1824
2002
|
.list-view {
|
|
1825
2003
|
height: 100%;
|
|
1826
2004
|
display: flex;
|
|
@@ -1970,12 +2148,12 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
1970
2148
|
color: var(--unn-color-text-secondary, #6b7280);
|
|
1971
2149
|
line-height: 1.5;
|
|
1972
2150
|
}
|
|
1973
|
-
`}var
|
|
1974
|
-
<div class="concept-row" data-testid="widget-term-card" data-term-id="${
|
|
1975
|
-
<span class="concept-name">${
|
|
1976
|
-
${
|
|
2151
|
+
`}var Do=320,$o=800,Io="unnoodle_panel_width",zo="unnoodle_panel_side";function Uo(n,t){let{host:e,shadow:o,panelShell:i,popoutBtn:r,dockBtn:s,closeBtn:a,pinLeftBtn:l,pinRightBtn:d,halfBtn:u,halfExitBtn:m,fullscreenBtn:v,fullscreenExitBtn:f,resizeHandle:x}=n,y=400;try{let M=localStorage.getItem(Io);if(M){let F=Number(M);Number.isFinite(F)&&F>=Do&&(y=F);}}catch{}i.style.width=`${y}px`;let L="right";try{let M=localStorage.getItem(zo);(M==="left"||M==="right")&&(L=M);}catch{}let R=null,H=false,I=null,q=false,N=false,h=false,g=false,b=0,T=0;function D(){if(H)return;i.classList.add("open"),e.setAttribute("data-panel-open","true");let F=document.getElementById("unnoodle-rail-host")?34:0;if(F&&(i.style.right=`${F}px`),!N){let oe=L==="right"?"margin-right":"margin-left";document.body.style.transition=`${oe} 0.28s cubic-bezier(0.4,0,0.2,1)`,L==="right"?(document.body.style.marginRight=`${y+F}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${y}px`,document.body.style.marginRight=F?`${F}px`:"");}let Z=document.getElementById("unnoodle-btn-host");Z&&(Z.style.display="none");}function z(){if(H)return;q&&(q=false,i.classList.remove("half-screen"),u.hidden=false,m.hidden=true),N&&(N=false,i.classList.remove("fullscreen"),v.hidden=false,f.hidden=true,h=false),i.classList.remove("open"),e.removeAttribute("data-panel-open"),i.style.right="";let F=document.getElementById("unnoodle-rail-host")?34:0;document.body.style.marginRight=F?`${F}px`:"",document.body.style.marginLeft="";let Z=document.getElementById("unnoodle-btn-host");Z&&Z.style.removeProperty("display");}function _(){if(H){R&&!R.closed&&R.focus();return}let M=window.open("about:blank","unnoodle_panel","width=440,height=720,resizable=yes,scrollbars=no,status=no,location=no,toolbar=no,menubar=no");if(!M){t.onToast?.("Allow popups for this site to use the detached panel.");return}let F=t.shadowTokens?t.shadowTokens.replace(/:host\b/g,":root"):"";M.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>'+(F?`<style>${F}</style>`:"")+'</head><body style="height:100%"></body></html>'),M.document.close();let Z=document.createElement("style");Z.setAttribute("data-unnoodle-popout","true"),Z.textContent=ee(yo),o.appendChild(Z);let oe=M.document.adoptNode(e);oe.style.cssText="display:block;width:100%;height:100%;",M.document.body.appendChild(oe),R=M,H=true,i.classList.add("open"),r.hidden=true,s.hidden=false,a.hidden=true,document.body.style.marginRight="",document.body.style.marginLeft="";let se=document.getElementById("unnoodle-btn-host");se&&(se.style.display="none"),t.onPopout?.(),M.addEventListener("beforeunload",()=>{V(true);}),I=setInterval(()=>{M.closed&&(clearInterval(I),I=null,V(true));},500);}function V(M=false){if(!H)return;H=false,I&&(clearInterval(I),I=null);let F=document.adoptNode(e);F.style.cssText="",document.body.appendChild(F);let Z=o.querySelector("[data-unnoodle-popout]");Z&&Z.remove(),i.classList.remove("open"),e.removeAttribute("data-panel-open"),r.hidden=false,s.hidden=true,a.hidden=false;let oe=document.getElementById("unnoodle-btn-host");oe&&oe.style.removeProperty("display"),!M&&R&&!R.closed&&R.close(),R=null,t.onReattach?.();}function G(M){L=M;try{localStorage.setItem(zo,M);}catch{}M==="left"?(i.classList.add("left-side"),l.classList.add("active"),d.classList.remove("active")):(i.classList.remove("left-side"),d.classList.add("active"),l.classList.remove("active")),i.classList.contains("open")&&!H&&!N&&(document.body.style.marginRight=M==="right"?`${y}px`:"",document.body.style.marginLeft=M==="left"?`${y}px`:"");}L==="left"&&G("left");function K(){if(q=!q,q){if(N&&(N=false,i.classList.remove("fullscreen"),v.hidden=false,f.hidden=true,h=false),i.classList.add("half-screen"),u.hidden=true,m.hidden=false,i.classList.contains("open")&&!H){let M=document.getElementById("unnoodle-rail-host")?34:0,F=Math.round(window.innerWidth*.5);L==="right"?(document.body.style.marginRight=`${F+M}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${F}px`,document.body.style.marginRight=M?`${M}px`:"");}}else if(i.classList.remove("half-screen"),u.hidden=false,m.hidden=true,i.classList.contains("open")&&!H){let M=document.getElementById("unnoodle-rail-host")?34:0;L==="right"?(document.body.style.marginRight=`${y+M}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${y}px`,document.body.style.marginRight=M?`${M}px`:"");}}function Y(){if(N=!N,N)q&&(q=false,i.classList.remove("half-screen"),u.hidden=false,m.hidden=true),h=i.classList.contains("open")&&!H,i.classList.add("fullscreen"),v.hidden=true,f.hidden=false,document.body.style.marginRight="",document.body.style.marginLeft="";else {if(i.classList.remove("fullscreen"),v.hidden=false,f.hidden=true,h&&i.classList.contains("open")){let M=document.getElementById("unnoodle-rail-host")?34:0;L==="right"?(document.body.style.marginRight=`${y+M}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${y}px`,document.body.style.marginRight=M?`${M}px`:"");}h=false;}}function te(M){if(!g||H)return;let F=window.innerWidth>0?Math.floor(window.innerWidth*.6):$o,Z=Math.min($o,F),oe=L==="right"?b-M.clientX:M.clientX-b,se=Math.max(Do,Math.min(Z,T+oe));if(y=se,i.style.width=`${se}px`,i.classList.contains("open")&&!N){let ye=document.getElementById("unnoodle-rail-host")?34:0;L==="right"?(document.body.style.marginRight=`${se+ye}px`,document.body.style.marginLeft=""):(document.body.style.marginLeft=`${se}px`,document.body.style.marginRight=ye?`${ye}px`:"");}}function j(){if(g){g=false,document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",j);try{localStorage.setItem(Io,String(y));}catch{}}}function X(){document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",j),H&&V(false),document.body.style.marginRight="",document.body.style.marginLeft="";let M=document.getElementById("unnoodle-btn-host");M&&M.style.removeProperty("display");}let E=()=>{z(),t.onClose?.();};return a.addEventListener("click",E),s.addEventListener("click",()=>V(false)),r.addEventListener("click",()=>_()),l.addEventListener("click",()=>G("left")),d.addEventListener("click",()=>G("right")),u.addEventListener("click",()=>K()),m.addEventListener("click",()=>K()),v.addEventListener("click",()=>Y()),f.addEventListener("click",()=>Y()),x.addEventListener("mousedown",M=>{H||(g=true,b=M.clientX,T=y,document.addEventListener("mousemove",te),document.addEventListener("mouseup",j),M.preventDefault());}),{show:D,hide:z,popout:_,cleanup:X,isPopout:()=>H,currentWidth:()=>y}}var de=5;function No(n,t,e,o,i){let{onTermClick:r,onRequireLogin:s,onAddConcept:a,onOpenSearch:l,onCaptureUiState:d,onShowAllConcepts:u,onOpenAsk:m}=o;t&&(t.textContent=e.context.name);let v=e.glossary;function f(h){return new RegExp(`\\b${h.term.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i").test(document.body?.innerText??"")}let x=h=>h.map(g=>`
|
|
2152
|
+
<div class="concept-row" data-testid="widget-term-card" data-term-id="${g.id}">
|
|
2153
|
+
<span class="concept-name">${P(g.term)}</span>
|
|
2154
|
+
${g.abbreviation?`<span class="concept-abbr">${P(g.abbreviation)}</span>`:""}
|
|
1977
2155
|
<span class="concept-chevron"><svg viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"/></svg></span>
|
|
1978
|
-
</div>`).join("");function
|
|
2156
|
+
</div>`).join("");function y(h,g){let b=h.filter(f),T=h.filter(E=>!f(E)),D=b.length>0&&T.length>0;if(h.length===0)return g?'<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 z=b.length>0?`<div class="concept-subheading">Used on this page</div>${x(b)}`:"",_=D?'<div class="concept-subheading">Other concepts in this context</div>':"";if(g)return z+_+x(T);let V=b.slice(0,de),G=Math.max(de-V.length,0),K=T.slice(0,G),Y=T.slice(G),te=b.slice(de),j=h.length>de?`<div class="home-concepts-hidden" style="display:none">${x(te)}${x(Y)}</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 (V.length>0?`<div class="concept-subheading">Used on this page</div>${x(V)}`:"")+_+x(K)+j}let L=y(v,false);n.innerHTML=`
|
|
1979
2157
|
<div class="home-view" data-testid="widget-home-view">
|
|
1980
2158
|
<div class="context-strip" data-testid="widget-context-strip" style="display:none !important">
|
|
1981
2159
|
<!-- idle state -->
|
|
@@ -2002,6 +2180,9 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2002
2180
|
</div>
|
|
2003
2181
|
</div>
|
|
2004
2182
|
</div>
|
|
2183
|
+
<button class="home-ask-entry" data-testid="widget-ask-entry">
|
|
2184
|
+
Ask about this product\u2026
|
|
2185
|
+
</button>
|
|
2005
2186
|
<div class="home-search-bar" data-testid="widget-home-search-bar">
|
|
2006
2187
|
<input class="home-search-input" id="unn-home-search" type="search"
|
|
2007
2188
|
placeholder="Search\u2026" autocomplete="off" aria-label="Search"
|
|
@@ -2026,9 +2207,9 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2026
2207
|
<button class="home-section-add" data-testid="widget-add-concept">+</button>
|
|
2027
2208
|
</div>
|
|
2028
2209
|
<div class="home-section-helper">Key terms used in this product.</div>
|
|
2029
|
-
${
|
|
2210
|
+
${L}
|
|
2030
2211
|
</div>
|
|
2031
|
-
<div class="home-section" data-section="clarifications" data-context-id="${
|
|
2212
|
+
<div class="home-section" data-section="clarifications" data-context-id="${e.context.id}">
|
|
2032
2213
|
<div class="home-section-header">
|
|
2033
2214
|
<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
2215
|
<button class="home-section-add" data-testid="widget-ask-question-btn">+</button>
|
|
@@ -2040,26 +2221,26 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2040
2221
|
</div>
|
|
2041
2222
|
</div>
|
|
2042
2223
|
</div>
|
|
2043
|
-
`;let
|
|
2224
|
+
`;let R=h=>{h.querySelectorAll("[data-testid='widget-term-card']").forEach(g=>{g.addEventListener("click",()=>{let b=Number(g.dataset.termId),T=v.find(D=>D.id===b);T&&r?.(T);});});};R(n);function H(){let h=n.querySelector("[data-testid='widget-show-all-concepts']");h&&h.addEventListener("click",g=>{g.preventDefault(),u?.();});}H();function I(h){let g=n.querySelector("[data-section='concepts']");if(!g)return;let b=g.querySelector(".home-section-header");if(!b)return;let T=h.length>=2,D=h.toLowerCase(),z=T?v.filter(V=>V.term.toLowerCase().includes(D)||V.definition.toLowerCase().includes(D)||(V.abbreviation??"").toLowerCase().includes(D)):v,_=document.createElement("div");for(_.innerHTML=y(z,T);g.lastChild&&g.lastChild!==b;)g.removeChild(g.lastChild);for(;_.firstChild;)g.appendChild(_.firstChild);R(g);}n.querySelector("[data-testid='widget-search-toggle']")?.addEventListener("click",()=>{l?.();}),n.querySelector("[data-testid='widget-ask-entry']")?.addEventListener("click",()=>{m?.();});let q=n.querySelector("[data-testid='widget-home-search-input']"),N;q?.addEventListener("input",()=>{clearTimeout(N),N=setTimeout(()=>{I(q.value);},200);}),n.querySelector("[data-testid='widget-add-concept']")?.addEventListener("click",()=>{if(!i){s?.();return}let h=n.querySelector("[data-section='concepts']");h&&ut(h,void 0,a);}),n.querySelector("[data-testid='widget-add-concept-empty']")?.addEventListener("click",()=>{if(!i){s?.();return}let h=n.querySelector("[data-section='concepts']");h&&ut(h,void 0,a);}),n.querySelector("[data-testid='widget-add-ui-meaning']")?.addEventListener("click",()=>{d?.();}),n.querySelector("[data-testid='widget-add-ui-meaning-empty']")?.addEventListener("click",()=>{d?.();}),n.querySelector("[data-testid='widget-add-ui-meaning-btn']")?.addEventListener("click",()=>{d?.();});}function Oo(n,t,e,o){let{onRequireLogin:i,onClarificationClick:r,onShowAllClarifications:s,onAskQuestion:a}=o,l=n.querySelector("[data-section='clarifications']");if(!l)return;let d=l.querySelector(".clarifications-body");if(!d)return;let m=l.querySelector(".home-section-header")?.querySelector(".home-section-add");if(m&&m.addEventListener("click",()=>{if(e){let y=Number(l.dataset.contextId);ct(l,y,a);}else i?.();}),t.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 y=d.querySelector('[data-testid="widget-ask-question-empty"]');y&&y.addEventListener("click",()=>{if(e){let L=Number(l.dataset.contextId);ct(l,L,a);}else i?.();});return}let v=t.slice(0,de).map(y=>{let L=y.authorName?P(y.authorName):"Unknown",R=y.createdAt?new Date(y.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"",H=(y.replies??[]).map(I=>`
|
|
2044
2225
|
<div class="discussion-reply">
|
|
2045
|
-
<div class="discussion-meta"><span class="discussion-meta-dot"></span>${
|
|
2046
|
-
<p class="discussion-body">${
|
|
2047
|
-
</div>`
|
|
2048
|
-
<div class="discussion-card" data-discussion-id="${
|
|
2226
|
+
<div class="discussion-meta"><span class="discussion-meta-dot"></span>${P(I.authorName??"Unknown")} \xB7 ${new Date(I.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}</div>
|
|
2227
|
+
<p class="discussion-body">${P(I.body)}</p>
|
|
2228
|
+
</div>`).join("");return `
|
|
2229
|
+
<div class="discussion-card" data-discussion-id="${y.id}">
|
|
2049
2230
|
<div class="discussion-card-main">
|
|
2050
|
-
<div class="discussion-meta"><span class="discussion-meta-dot"></span>${
|
|
2051
|
-
<p class="discussion-body">${
|
|
2052
|
-
${
|
|
2231
|
+
<div class="discussion-meta"><span class="discussion-meta-dot"></span>${L} \xB7 ${R}</div>
|
|
2232
|
+
<p class="discussion-body">${P(y.body)}</p>
|
|
2233
|
+
${H?`<div class="discussion-replies">${H}</div>`:""}
|
|
2053
2234
|
</div>
|
|
2054
2235
|
<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(""),
|
|
2236
|
+
</div>`}).join(""),f=t.length>de?`<a href="#" class="home-show-more home-show-more-clarifications" data-testid="widget-show-all-clarifications">Show all ${t.length} clarifications \u2192</a>`:"";d.innerHTML=v+f,d.querySelectorAll(".discussion-card").forEach(y=>{y.addEventListener("click",()=>{let L=Number(y.dataset.discussionId),R=t.find(H=>H.id===L);R&&r?.(R);});});let x=d.querySelector("[data-testid='widget-show-all-clarifications']");x&&x.addEventListener("click",y=>{y.preventDefault(),s?.();});}function ct(n,t,e){let o=n.querySelector(".clarifications-body");if(!o||o.querySelector(".ask-form"))return;let i=o.querySelector(".section-empty");i&&(i.style.display="none");let r=document.createElement("div");r.className="ask-form",r.innerHTML=`
|
|
2056
2237
|
<textarea class="ask-textarea" placeholder="Your question\u2026" maxlength="2000" rows="3"></textarea>
|
|
2057
2238
|
<div class="ask-actions">
|
|
2058
2239
|
<button class="ask-cancel">Cancel</button>
|
|
2059
2240
|
<button class="ask-submit" data-testid="widget-ask-submit">Send</button>
|
|
2060
2241
|
</div>
|
|
2061
2242
|
<p class="ask-error" style="display:none"></p>
|
|
2062
|
-
`,
|
|
2243
|
+
`,o.insertBefore(r,o.firstChild);let s=r.querySelector(".ask-textarea"),a=r.querySelector(".ask-cancel"),l=r.querySelector(".ask-submit");s.focus(),a.addEventListener("click",()=>{r.remove(),i&&(i.style.display="");}),l.addEventListener("click",()=>{let d=s.value.trim();d&&(l.disabled=true,l.textContent="Sending\u2026",e?.(t,d),r.remove());});}function ut(n,t,e){if(n.querySelector(".add-term-form"))return;let o=t??n.querySelector(".home-section-helper")??n.querySelector(".home-section-header");if(!o)return;let i=document.createElement("div");i.className="add-term-form",i.innerHTML=`
|
|
2063
2244
|
<input class="add-term-input" type="text" placeholder="Term name\u2026" maxlength="100" data-testid="widget-add-term-name" />
|
|
2064
2245
|
<textarea class="add-term-input ask-textarea" placeholder="Definition\u2026" maxlength="5000" rows="3" data-testid="widget-add-term-definition"></textarea>
|
|
2065
2246
|
<div class="ask-actions">
|
|
@@ -2067,7 +2248,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2067
2248
|
<button class="ask-submit" data-testid="widget-add-term-submit">Add</button>
|
|
2068
2249
|
</div>
|
|
2069
2250
|
<p class="ask-error" style="display:none" data-testid="widget-add-term-error"></p>
|
|
2070
|
-
`,
|
|
2251
|
+
`,o.after(i);let r=i.querySelector("[data-testid='widget-add-term-name']"),s=i.querySelector("[data-testid='widget-add-term-definition']"),a=i.querySelector("[data-testid='widget-add-term-cancel']"),l=i.querySelector("[data-testid='widget-add-term-submit']"),d=i.querySelector("[data-testid='widget-add-term-error']");r.focus(),a.addEventListener("click",()=>i.remove()),l.addEventListener("click",()=>{let u=r.value.trim(),m=s.value.trim();if(!u||!m){d.textContent="Both term and definition are required.",d.style.display="";return}d.style.display="none",l.disabled=true,l.textContent="Adding\u2026",e?.(u,m),i.remove();});}function zt(n,t,e,o,i,r,s,a,l,d,u,m,v,f,x,y,L,R,H,I,q,N,h,g,b,T,D,z,_,V,G){let K=document.createElement("div");K.id="unnoodle-panel-host",K.setAttribute("data-testid","widget-panel-host");let Y=K.attachShadow({mode:"open"}),te=document.createElement("style");te.textContent=ee(bo);let j=document.createElement("div");j.className="panel",j.setAttribute("role","complementary"),j.setAttribute("aria-label","Unnoodle Glossary");let X=document.createElement("div");X.className="panel-header",X.innerHTML=`
|
|
2071
2252
|
<div class="panel-header-brand">
|
|
2072
2253
|
<span class="panel-title">Unnoodle</span>
|
|
2073
2254
|
<span class="panel-title-sep">\xB7</span>
|
|
@@ -2104,7 +2285,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2104
2285
|
<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
2286
|
</button>
|
|
2106
2287
|
</div>
|
|
2107
|
-
`;let
|
|
2288
|
+
`;let E=document.createElement("div");E.className="panel-body";let M=document.createElement("div");M.className="panel-footer",M.innerHTML='<a href="https://unnoodle.com" target="_blank" rel="noopener">Product knowledge powered by Unnoodle</a>',j.appendChild(X),j.appendChild(E),j.appendChild(M);let F=document.createElement("div");F.className="panel-resize-handle",F.setAttribute("data-testid","widget-panel-resize-handle"),j.appendChild(F);let Z=document.createElement("div");if(Z.className="panel-shell",Z.appendChild(j),L){let c=document.createElement("style");c.textContent=ee(L),Y.appendChild(c);}Y.appendChild(te);let oe=document.createElement("style");oe.textContent=ee(Bo()),Y.appendChild(oe),Y.appendChild(Z);let se=X.querySelector(".panel-close"),ye=X.querySelector(".panel-popout"),Yo=X.querySelector(".panel-dock"),Xo=X.querySelector(".panel-pin-left"),Jo=X.querySelector(".panel-pin-right"),Qo=X.querySelector(".panel-half"),en=X.querySelector(".panel-half-exit"),tn=X.querySelector(".panel-fullscreen"),on=X.querySelector(".panel-fullscreen-exit"),Re=Uo({host:K,shadow:Y,panelShell:Z,popoutBtn:ye,dockBtn:Yo,closeBtn:se,pinLeftBtn:Xo,pinRightBtn:Jo,halfBtn:Qo,halfExitBtn:en,fullscreenBtn:tn,fullscreenExitBtn:on,resizeHandle:F},{...o&&{onClose:o},...f&&{onPopout:f},...x&&{onReattach:x},onToast:c=>Wt(c),...L&&{shadowTokens:L}});function nn(){Re.show();}function rn(){Re.hide();}function sn(){Re.popout();}function an(){E.innerHTML=`
|
|
2108
2289
|
<div class="skeleton-home" data-testid="widget-loading">
|
|
2109
2290
|
<div class="skeleton-loading-header">
|
|
2110
2291
|
<div class="skeleton-loading-brand">Unnoodle</div>
|
|
@@ -2129,23 +2310,23 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2129
2310
|
</div>
|
|
2130
2311
|
</div>
|
|
2131
2312
|
</div>
|
|
2132
|
-
`;}function
|
|
2313
|
+
`;}function ln(c){E.innerHTML=`
|
|
2133
2314
|
<div class="state-center" data-testid="widget-panel-error">
|
|
2134
2315
|
<svg class="state-error-icon" viewBox="0 0 24 24" stroke-width="1.5" aria-hidden="true">
|
|
2135
2316
|
<circle cx="12" cy="12" r="10"/>
|
|
2136
2317
|
<line x1="12" y1="8" x2="12" y2="12"/>
|
|
2137
2318
|
<line x1="12" y1="16" x2="12.01" y2="16"/>
|
|
2138
2319
|
</svg>
|
|
2139
|
-
<p class="state-msg">${
|
|
2320
|
+
<p class="state-msg">${P(c)}</p>
|
|
2140
2321
|
</div>
|
|
2141
|
-
`;}let
|
|
2322
|
+
`;}let Pe=false;function dn(c){wo(E,{onLogin:n,...y&&{onSsoLogin:p=>y(p)},onBack:Be?()=>{let p=Be;Be=p,gt(p);}:null},c);}function cn(c){xo(E,c);}function un(c){ko(E,c);}let Be=null,me=null,he=null,we=null,ke=null;function gt(c){if(Be=c,ke=c,vn(c),me&&Gt(me.discussions,me.canPost),c.productMemories!==void 0){let p=c.productMemories.slice(0,5);jt(p);}}function mn(c,p){bn(c,null,c.length,p);}function hn(c){ft(),ke&&we?.showAllTerms(ke,c);}function gn(c,p){ft(),we?.showAllClarifications(c,p);}function fn(c,p){ft(),we?.showAllMemories(c,p);}function ft(){if(!we){let c={onTermClick:p=>{let k=ke?.glossary.find(w=>w.id===p);k&&a&&a(k);},onDiscussionClick:p=>{if(N&&me){let k=me.discussions.find(w=>w.id===p);k&&N(k);}},onMemoryClick:p=>{m&&m(p);},onBackToHome:()=>{i?.();},onAddTerm:()=>{if(!Pe){H?.();return}let p=E.querySelector("[data-testid='widget-terms-list-view']");if(p){let k=p.querySelector(".list-header");k&&ut(p,k,I);}},onAddDiscussion:()=>{let p=E.querySelector('[data-section="clarifications"]'),k=ke?.context.id;p&&k&&ct(p,k,R);},onAddMemory:()=>d?.(),onRequireLogin:()=>H?.()};we=new dt(E,c);}}function vn(c){No(E,X.querySelector(".panel-subtitle"),c,{...a&&{onTermClick:a},...H&&{onRequireLogin:H},...I&&{onAddConcept:I},...q&&{onOpenSearch:q},...d&&{onCaptureUiState:d},...D&&{onShowAllConcepts:D},...N&&{onClarificationClick:N},...z&&{onShowAllClarifications:z},...R&&{onAskQuestion:R},...G&&{onOpenAsk:G}},Pe);}function Gt(c,p){me={discussions:c,canPost:p},Oo(E,c,p,{...H&&{onRequireLogin:H},...N&&{onClarificationClick:N},...z&&{onShowAllClarifications:z},...R&&{onAskQuestion:R}});}function bn(c,p,k,w){E.innerHTML=`
|
|
2142
2323
|
<div class="search-bar">
|
|
2143
2324
|
<input class="search-input" id="unn-search" type="search"
|
|
2144
2325
|
placeholder="Search terms\u2026" autocomplete="off"
|
|
2145
|
-
value="${
|
|
2326
|
+
value="${P(w)}" aria-label="Search glossary terms"
|
|
2146
2327
|
data-testid="widget-glossary-search" />
|
|
2147
2328
|
</div>
|
|
2148
|
-
<div class="action-bar" id="unn-action-bar" style="display:${
|
|
2329
|
+
<div class="action-bar" id="unn-action-bar" style="display:${Pe?"flex":"none"}">
|
|
2149
2330
|
<div class="action-bar-tabs">
|
|
2150
2331
|
<button class="tab-btn active" data-testid="widget-glossary-tab">Glossary</button>
|
|
2151
2332
|
<button class="tab-btn" data-testid="widget-ui-states-tab">UI States</button>
|
|
@@ -2161,43 +2342,43 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2161
2342
|
</div>
|
|
2162
2343
|
<div class="terms-list" id="unn-terms-list" data-testid="widget-glossary-list">
|
|
2163
2344
|
${""}
|
|
2164
|
-
${
|
|
2345
|
+
${c.length===0?wn(w):c.map(yn).join("")}
|
|
2165
2346
|
</div>
|
|
2166
|
-
`;let
|
|
2347
|
+
`;let C=E.querySelector("#unn-search"),$;C.addEventListener("input",()=>{clearTimeout($),$=setTimeout(()=>{t(C.value);},220);}),a&&E.querySelector("#unn-terms-list").addEventListener("click",ge=>{let De=ge.target.closest("[data-testid='widget-term-card']");if(!De)return;let Ce=De.closest("[data-term-id]");if(!Ce)return;let ei=parseInt(Ce.getAttribute("data-term-id")??"-1",10),Zt=c.find(ti=>ti.id===ei);Zt&&a(Zt);});let B=E.querySelector('[data-testid="widget-ui-state-capture-btn"]');B?.addEventListener("click",()=>{B.disabled||(B.disabled=true,B.textContent="Capturing\u2026",d?.(),setTimeout(()=>{B&&(B.disabled=false,B.innerHTML=`
|
|
2167
2348
|
<svg viewBox="0 0 24 24" aria-hidden="true" style="width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2">
|
|
2168
2349
|
<circle cx="12" cy="12" r="3"/>
|
|
2169
2350
|
<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
2351
|
</svg>
|
|
2171
2352
|
Capture
|
|
2172
|
-
`);},2e3));})
|
|
2173
|
-
<div class="term-item" data-term-id="${
|
|
2353
|
+
`);},2e3));}),E.querySelector('[data-testid="widget-ui-states-tab"]')?.addEventListener("click",()=>u?.()),C.focus();}function yn(c){let p=c.abbreviation?`<span class="term-abbr">${P(c.abbreviation)}</span>`:"",k=e?`<a class="term-link" href="${P(e)}/glossary/${c.id}" target="_blank" rel="noopener">View details \u2192</a>`:"";return `
|
|
2354
|
+
<div class="term-item" data-term-id="${c.id}" data-testid="widget-glossary-item">
|
|
2174
2355
|
<div class="term-card" data-testid="widget-term-card">
|
|
2175
|
-
<div class="term-name">${
|
|
2176
|
-
<div class="term-def">${
|
|
2356
|
+
<div class="term-name">${P(c.term)}${p}</div>
|
|
2357
|
+
<div class="term-def">${P(c.definition)}</div>
|
|
2177
2358
|
</div>
|
|
2178
|
-
${
|
|
2359
|
+
${k}
|
|
2179
2360
|
</div>
|
|
2180
|
-
`}function
|
|
2361
|
+
`}function wn(c){return `<div class="no-results" data-testid="widget-glossary-empty">${c?`No results for "${P(c)}"`:"No terms found."}</div>`}function xn(){Re.cleanup(),K.remove();}function kn(c,p,k){let w=p.length===0?'<div class="discussions-empty" data-testid="widget-discussion-empty">No comments yet. Be the first to comment!</div>':p.map(W=>`<div class="discussion-post" data-testid="widget-discussion-post">${P(W.body)}</div>`).join(""),C=k?.showEdit?'<button class="action-btn edit-btn" data-testid="widget-edit-btn">Edit Term</button>':"";E.innerHTML=`
|
|
2181
2362
|
<div class="term-detail-view">
|
|
2182
2363
|
<div class="detail-back">
|
|
2183
2364
|
<button class="back-btn" data-testid="widget-back-btn">\u2190 Back to list</button>
|
|
2184
2365
|
</div>
|
|
2185
2366
|
<div class="detail-content">
|
|
2186
2367
|
<div data-testid="widget-term-detail" class="detail-body">
|
|
2187
|
-
<h3 class="detail-term-name">${
|
|
2188
|
-
<p class="detail-term-def">${
|
|
2368
|
+
<h3 class="detail-term-name">${P(c.term)}</h3>
|
|
2369
|
+
<p class="detail-term-def">${P(c.definition)}</p>
|
|
2189
2370
|
</div>
|
|
2190
2371
|
</div>
|
|
2191
2372
|
<div class="detail-actions">
|
|
2192
2373
|
<button class="action-btn" data-testid="widget-add-comment-btn">Add Comment</button>
|
|
2193
|
-
${
|
|
2374
|
+
${C}
|
|
2194
2375
|
</div>
|
|
2195
2376
|
<div class="discussions-section">
|
|
2196
2377
|
<div class="discussions-heading">Discussion</div>
|
|
2197
|
-
${
|
|
2378
|
+
${w}
|
|
2198
2379
|
</div>
|
|
2199
2380
|
</div>
|
|
2200
|
-
`,
|
|
2381
|
+
`,E.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>i?.()),E.querySelector('[data-testid="widget-add-comment-btn"]').addEventListener("click",()=>{r?.(c.id,"");}),k?.showEdit&&E.querySelector('[data-testid="widget-edit-btn"]')?.addEventListener("click",()=>{l?.(c.id);});}function En(c){E.innerHTML=`
|
|
2201
2382
|
<div class="comment-form-view">
|
|
2202
2383
|
<div class="detail-back">
|
|
2203
2384
|
<button class="back-btn" data-testid="widget-back-btn">\u2190 Back</button>
|
|
@@ -2209,7 +2390,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2209
2390
|
></textarea>
|
|
2210
2391
|
<button class="comment-submit" data-testid="widget-comment-submit">Submit Comment</button>
|
|
2211
2392
|
</div>
|
|
2212
|
-
`,
|
|
2393
|
+
`,E.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>i?.());let k=E.querySelector('[data-testid="widget-comment-submit"]'),w=E.querySelector('[data-testid="widget-comment-body"]');k.addEventListener("click",()=>{let C=w.value.trim();C&&r?.(c,C);});}function Tn(c){E.innerHTML=`
|
|
2213
2394
|
<div class="edit-form-view">
|
|
2214
2395
|
<div class="detail-back">
|
|
2215
2396
|
<button class="back-btn" data-testid="widget-back-btn">\u2190 Back</button>
|
|
@@ -2221,7 +2402,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2221
2402
|
id="unn-edit-term"
|
|
2222
2403
|
type="text"
|
|
2223
2404
|
data-testid="widget-edit-term-input"
|
|
2224
|
-
value="${
|
|
2405
|
+
value="${P(c.term)}"
|
|
2225
2406
|
/>
|
|
2226
2407
|
</div>
|
|
2227
2408
|
<div>
|
|
@@ -2230,29 +2411,29 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2230
2411
|
class="edit-textarea"
|
|
2231
2412
|
id="unn-edit-def"
|
|
2232
2413
|
data-testid="widget-edit-definition-input"
|
|
2233
|
-
>${
|
|
2414
|
+
>${P(c.definition)}</textarea>
|
|
2234
2415
|
</div>
|
|
2235
2416
|
<button class="edit-submit" data-testid="widget-edit-submit">Save Changes</button>
|
|
2236
2417
|
</div>
|
|
2237
|
-
`,
|
|
2418
|
+
`,E.querySelector('[data-testid="widget-back-btn"]').addEventListener("click",()=>i?.());let k=E.querySelector('[data-testid="widget-edit-term-input"]'),w=E.querySelector('[data-testid="widget-edit-definition-input"]');E.querySelector('[data-testid="widget-edit-submit"]').addEventListener("click",()=>{s?.(c.id,{term:k.value,definition:w.value});});}function Cn(c){}function Mn(c){}function An(c){}function Ln(c){}function Sn(c,p){if(c.length===0)return;let k=E.querySelector(".suggestions-section");k&&k.remove();let w=E.querySelector(".terms-list");if(!w)return;let C=document.createElement("div");C.className="suggestions-section",C.innerHTML=`
|
|
2238
2419
|
<div class="suggestions-heading" data-testid="widget-suggestions-heading">
|
|
2239
2420
|
Suggested Terms
|
|
2240
2421
|
</div>
|
|
2241
|
-
${
|
|
2422
|
+
${c.map($=>`
|
|
2242
2423
|
<div class="suggestion-item" data-testid="widget-suggestion-item">
|
|
2243
2424
|
<div class="suggestion-info">
|
|
2244
|
-
<span class="suggestion-term">${
|
|
2245
|
-
<span class="suggestion-count">mentioned ${
|
|
2425
|
+
<span class="suggestion-term">${P($.term)}</span>
|
|
2426
|
+
<span class="suggestion-count">mentioned ${$.count}\xD7</span>
|
|
2246
2427
|
</div>
|
|
2247
2428
|
<button
|
|
2248
2429
|
class="suggestion-add"
|
|
2249
2430
|
data-testid="widget-suggestion-add"
|
|
2250
|
-
data-term="${
|
|
2431
|
+
data-term="${P($.term)}"
|
|
2251
2432
|
>+ Add</button>
|
|
2252
2433
|
</div>`).join("")}
|
|
2253
|
-
`,
|
|
2434
|
+
`,C.querySelectorAll(".suggestion-add").forEach($=>{$.addEventListener("click",()=>{let B=$.dataset.term??"";p(B);});}),w.after(C);}function Hn(c,p,k,w){j.querySelector(".ai-modal-overlay")?.remove();let C=document.createElement("div");C.className="ai-modal-overlay",C.setAttribute("data-testid","widget-ai-modal"),C.innerHTML=`
|
|
2254
2435
|
<div class="ai-modal-title">AI Generated Definition</div>
|
|
2255
|
-
<div class="ai-modal-term">${
|
|
2436
|
+
<div class="ai-modal-term">${P(c)}</div>
|
|
2256
2437
|
<div>
|
|
2257
2438
|
<label class="ai-modal-label" for="unn-ai-def">Review & edit the definition:</label>
|
|
2258
2439
|
<textarea
|
|
@@ -2260,14 +2441,14 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2260
2441
|
id="unn-ai-def"
|
|
2261
2442
|
data-testid="widget-ai-definition"
|
|
2262
2443
|
maxlength="500"
|
|
2263
|
-
>${
|
|
2444
|
+
>${P(p)}</textarea>
|
|
2264
2445
|
<div class="ai-modal-char-count" id="unn-ai-char">0 / 500</div>
|
|
2265
2446
|
</div>
|
|
2266
2447
|
<div class="ai-modal-actions">
|
|
2267
2448
|
<button class="ai-modal-cancel" data-testid="widget-ai-cancel">Cancel</button>
|
|
2268
2449
|
<button class="ai-modal-submit" data-testid="widget-ai-submit">Submit for Approval</button>
|
|
2269
2450
|
</div>
|
|
2270
|
-
`;let
|
|
2451
|
+
`;let $=C.querySelector('[data-testid="widget-ai-definition"]'),B=C.querySelector("#unn-ai-char"),W=()=>{B.textContent=`${$.value.length} / 500`;};$.addEventListener("input",W),W(),C.querySelector('[data-testid="widget-ai-submit"]').addEventListener("click",()=>{k($.value);}),C.querySelector('[data-testid="widget-ai-cancel"]').addEventListener("click",()=>{C.remove(),w();}),j.appendChild(C);}function Rn(c){let p=j.querySelector('[data-testid="widget-ai-submit"]');p&&(p.disabled=c,p.textContent=c?"Submitting\u2026":"Submit for Approval");}function Wt(c){j.querySelector(".toast")?.remove();let p=document.createElement("div");p.className="toast",p.setAttribute("data-testid","widget-toast"),p.textContent=c,j.appendChild(p),setTimeout(()=>p.remove(),4e3);}function Pn(c){Pe=c;let p=E.querySelector("#unn-action-bar");p&&(p.style.display=c?"flex":"none");}function Bn(c,p,k,w=false){if(!w){E.innerHTML=`
|
|
2271
2452
|
<div class="action-bar" id="unn-action-bar" style="display:flex">
|
|
2272
2453
|
<div class="action-bar-tabs">
|
|
2273
2454
|
<button class="tab-btn" data-testid="widget-glossary-tab">Glossary</button>
|
|
@@ -2283,13 +2464,13 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2283
2464
|
</button>
|
|
2284
2465
|
</div>
|
|
2285
2466
|
<div class="ui-states-list" id="unn-ui-states-list" data-testid="widget-ui-states-list"></div>
|
|
2286
|
-
|
|
2467
|
+
`,E.querySelector('[data-testid="widget-glossary-tab"]')?.addEventListener("click",()=>i?.());let W=E.querySelector('[data-testid="widget-ui-state-capture-btn"]');W?.addEventListener("click",()=>{W.disabled||(W.disabled=true,W.textContent="Capturing\u2026",d?.(),setTimeout(()=>{W&&(W.disabled=false,W.innerHTML=`
|
|
2287
2468
|
<svg viewBox="0 0 24 24" aria-hidden="true" style="width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2">
|
|
2288
2469
|
<circle cx="12" cy="12" r="3"/>
|
|
2289
2470
|
<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
2471
|
</svg>
|
|
2291
2472
|
Capture
|
|
2292
|
-
`);},2e3));});}let
|
|
2473
|
+
`);},2e3));});}let C=E.querySelector("#unn-ui-states-list");if(!C)return;if(E.querySelector(".load-more-container")?.remove(),c.length===0&&!w){C.innerHTML=`
|
|
2293
2474
|
<div class="ui-states-empty" data-testid="widget-ui-states-empty">
|
|
2294
2475
|
<svg class="ui-states-empty-icon" viewBox="0 0 24 24" stroke-width="1.5" aria-hidden="true">
|
|
2295
2476
|
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
@@ -2300,50 +2481,50 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2300
2481
|
Click <strong>Capture</strong> to snapshot an element.
|
|
2301
2482
|
</p>
|
|
2302
2483
|
</div>
|
|
2303
|
-
`;return}let
|
|
2484
|
+
`;return}let $=c.map(B=>Dn(B)).join("");if(C.insertAdjacentHTML("beforeend",$),C.querySelectorAll('[data-testid="widget-ui-state-detail-btn"]').forEach(B=>{let W=parseInt(B.dataset.stateId??"-1",10);B.addEventListener("click",()=>{isNaN(W)||m?.(W);});}),k){let B=document.createElement("div");B.className="load-more-container",B.innerHTML=`
|
|
2304
2485
|
<button class="load-more-btn" data-testid="widget-ui-states-load-more"
|
|
2305
|
-
data-page="${
|
|
2486
|
+
data-page="${p+1}">
|
|
2306
2487
|
Load more
|
|
2307
2488
|
</button>
|
|
2308
|
-
`,
|
|
2309
|
-
<div class="ui-state-item" data-testid="widget-ui-state-item" data-state-id="${
|
|
2310
|
-
<div class="ui-state-url" title="${
|
|
2489
|
+
`,B.querySelector('[data-testid="widget-ui-states-load-more"]')?.addEventListener("click",()=>u?.()),E.appendChild(B);}}function Dn(c){let p=vt(c.updatedAt),k=c.entryCount;return `
|
|
2490
|
+
<div class="ui-state-item" data-testid="widget-ui-state-item" data-state-id="${c.id}">
|
|
2491
|
+
<div class="ui-state-url" title="${P(c.title)}">${P(c.title)}</div>
|
|
2311
2492
|
<div class="ui-state-meta">
|
|
2312
|
-
<span>${
|
|
2313
|
-
<span class="ui-state-role-badge">${
|
|
2493
|
+
<span>${P(p)}</span>
|
|
2494
|
+
<span class="ui-state-role-badge">${k} ${k===1?"entry":"entries"}</span>
|
|
2314
2495
|
</div>
|
|
2315
2496
|
<div class="ui-state-actions">
|
|
2316
2497
|
<button class="view-detail-btn"
|
|
2317
2498
|
data-testid="widget-ui-state-detail-btn"
|
|
2318
|
-
data-state-id="${
|
|
2499
|
+
data-state-id="${c.id}">
|
|
2319
2500
|
View Details
|
|
2320
2501
|
</button>
|
|
2321
2502
|
</div>
|
|
2322
2503
|
</div>
|
|
2323
|
-
`}function
|
|
2324
|
-
<div class="pm-entry" data-entry-id="${
|
|
2504
|
+
`}function $n(c){let p=c.entries.map((w,C)=>{let $=vt(w.capturedAt),B=P(w.capturedByRole??"");return `
|
|
2505
|
+
<div class="pm-entry" data-entry-id="${w.id}">
|
|
2325
2506
|
<div class="detail-meta-section">
|
|
2326
2507
|
<div class="detail-meta-row">
|
|
2327
|
-
<span>${
|
|
2328
|
-
${
|
|
2329
|
-
${
|
|
2508
|
+
<span>${P($)}</span>
|
|
2509
|
+
${B?`<span class="ui-state-role-badge">${B}</span>`:""}
|
|
2510
|
+
${w.capturedByName?`<span>${P(w.capturedByName)}</span>`:""}
|
|
2330
2511
|
</div>
|
|
2331
2512
|
</div>
|
|
2332
|
-
${
|
|
2333
|
-
<div class="product-memory-section" data-testid="widget-product-memory-section-${
|
|
2334
|
-
<div class="product-memory-heading">Entry ${
|
|
2335
|
-
${
|
|
2513
|
+
${w.snapshotHtml?`<div class="ui-state-snapshot-preview" data-testid="widget-ui-state-snapshot-preview-${w.id}"></div>`:""}
|
|
2514
|
+
<div class="product-memory-section" data-testid="widget-product-memory-section-${w.id}">
|
|
2515
|
+
<div class="product-memory-heading">Entry ${C+1} \xB7 Explanation</div>
|
|
2516
|
+
${w.explanation?`
|
|
2336
2517
|
<div class="product-memory-read-mode" data-testid="widget-product-memory-read">
|
|
2337
|
-
<div class="product-memory-text" data-testid="widget-product-memory-text">${
|
|
2518
|
+
<div class="product-memory-text" data-testid="widget-product-memory-text">${P(w.explanation)}</div>
|
|
2338
2519
|
<div class="product-memory-actions">
|
|
2339
2520
|
<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="${
|
|
2521
|
+
<button class="product-memory-delete-entry-btn" data-testid="widget-product-memory-delete-entry-btn" data-entry-id="${w.id}" title="Delete Entry">\u{1F5D1}</button>
|
|
2341
2522
|
</div>
|
|
2342
2523
|
</div>
|
|
2343
2524
|
<div class="product-memory-write-mode" data-testid="widget-product-memory-write" style="display:none">
|
|
2344
2525
|
<textarea class="product-memory-textarea" data-testid="widget-product-memory-textarea"
|
|
2345
2526
|
placeholder="Describe what this snapshot represents\u2026"
|
|
2346
|
-
maxlength="2000">${
|
|
2527
|
+
maxlength="2000">${P(w.explanation)}</textarea>
|
|
2347
2528
|
<div class="product-memory-actions">
|
|
2348
2529
|
<button class="product-memory-cancel-btn" data-testid="widget-product-memory-cancel-btn">Cancel</button>
|
|
2349
2530
|
<button class="product-memory-save-btn" data-testid="widget-product-memory-save-btn">Save</button>
|
|
@@ -2359,17 +2540,17 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2359
2540
|
</div>`}
|
|
2360
2541
|
</div>
|
|
2361
2542
|
</div>
|
|
2362
|
-
`}).join('<hr class="pm-entry-divider">');
|
|
2543
|
+
`}).join('<hr class="pm-entry-divider">');E.innerHTML=`
|
|
2363
2544
|
<div class="ui-state-detail-view" data-testid="widget-ui-state-detail">
|
|
2364
2545
|
<div class="detail-back">
|
|
2365
2546
|
<button class="back-btn" data-testid="widget-ui-state-back-btn">\u2190 Captures</button>
|
|
2366
2547
|
</div>
|
|
2367
|
-
<div class="detail-page-title">${
|
|
2368
|
-
${
|
|
2548
|
+
<div class="detail-page-title">${P(c.title)}</div>
|
|
2549
|
+
${c.entries.length===0?`<div class="ui-states-empty" data-testid="widget-ui-states-empty">
|
|
2369
2550
|
<p class="ui-states-empty-text">No entries yet. Capture an element to get started.</p>
|
|
2370
|
-
</div>`:
|
|
2551
|
+
</div>`:p}
|
|
2371
2552
|
<div class="detail-actions">
|
|
2372
|
-
<button class="detail-delete-btn" data-testid="widget-delete-memory-btn" data-memory-id="${
|
|
2553
|
+
<button class="detail-delete-btn" data-testid="widget-delete-memory-btn" data-memory-id="${c.id}">
|
|
2373
2554
|
Delete Memory
|
|
2374
2555
|
</button>
|
|
2375
2556
|
<button class="detail-add-btn" data-testid="widget-add-entry-btn">
|
|
@@ -2377,17 +2558,17 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2377
2558
|
</button>
|
|
2378
2559
|
</div>
|
|
2379
2560
|
</div>
|
|
2380
|
-
`,
|
|
2561
|
+
`,c.entries.forEach(w=>{if(!w.snapshotHtml)return;let C=E.querySelector(`[data-testid="widget-ui-state-snapshot-preview-${w.id}"]`);C&&(C.innerHTML=w.snapshotHtml);}),E.querySelector('[data-testid="widget-ui-state-back-btn"]')?.addEventListener("click",()=>i?.()),E.querySelector('[data-testid="widget-add-entry-btn"]')?.addEventListener("click",()=>g?.(c.id)),c.entries.forEach(w=>{let C=E.querySelector(`[data-testid="widget-product-memory-section-${w.id}"]`);if(!C)return;let $=C.querySelector('[data-testid="widget-product-memory-read"]'),B=C.querySelector('[data-testid="widget-product-memory-write"]'),W=C.querySelector('[data-testid="widget-product-memory-textarea"]'),ue=C.querySelector('[data-testid="widget-product-memory-save-btn"]'),ge=C.querySelector('[data-testid="widget-product-memory-edit-btn"]'),De=C.querySelector('[data-testid="widget-product-memory-cancel-btn"]');ge?.addEventListener("click",()=>{$&&($.style.display="none"),B&&(B.style.display=""),W?.focus();}),De?.addEventListener("click",()=>{B&&(B.style.display="none"),$&&($.style.display="");}),ue?.addEventListener("click",()=>{let Ce=W?.value.trim()??"";Ce&&(ue&&(ue.disabled=true,ue.textContent="Saving\u2026"),v?.(c.id,w.id,Ce));});}),c.entries.forEach(w=>{E.querySelector(`[data-testid="widget-product-memory-delete-entry-btn"][data-entry-id="${w.id}"]`)?.addEventListener("click",$=>{$.preventDefault(),confirm("Are you sure you want to delete this entry? This action cannot be undone.")&&T?.(c.id,w.id);});}),E.querySelector('[data-testid="widget-delete-memory-btn"]')?.addEventListener("click",w=>{w.preventDefault(),confirm(`Are you sure you want to delete "${c.title}"? This will delete all entries and cannot be undone.`)&&b?.(c.id);});}function vt(c){try{let p=Math.floor((Date.now()-new Date(c).getTime())/1e3);return p<60?"just now":p<3600?`${Math.floor(p/60)}m ago`:p<86400?`${Math.floor(p/3600)}h ago`:p<604800?`${Math.floor(p/86400)}d ago`:new Date(c).toLocaleDateString()}catch{return "unknown time"}}function In(c,p,k,w){console.log("[unnoodle] showNewMemoryForm called");let C=E;if(console.log("[unnoodle] Using body element:",C),!C){console.log("[unnoodle] No body element available, returning early");return}console.log("[unnoodle] Creating capture form...");let{element:$,controller:B}=It({onPickElement:c,onCancelCapture:p,onSave:k,onCancel:w},{showTitle:true});console.log("[unnoodle] Capture form created:",$),he=B,console.log("[unnoodle] Clearing bodyEl and appending form..."),C.innerHTML="",C.appendChild($),console.log("[unnoodle] Form appended successfully, bodyEl.innerHTML length is now:",C.innerHTML.length);}function zn(c,p,k,w,C){let $=E;if(!$)return;let{element:B,controller:W}=It({onPickElement:p,onCancelCapture:k,onSave:(ue,ge)=>{w(ge);},onCancel:()=>{C();}},{showTitle:false,headerText:c,subheaderText:"Add new entry"});he=W,$.innerHTML="",$.appendChild(B);}function Un(c){he&&he.setSnapshot(c);}function Nn(c){he&&he.setPickingMode(c);}function On(c,p,k){Po(E,c,p,k);}function qn(){He(E);}let bt=null;function Ee(){return bt||(bt=Ro(E,{onAsk:c=>V?.(c),onOpenMemory:c=>m?.(c),onBack:()=>i?.()},P)),bt}function Fn(c){Ee().render(c);}function _n(){Ee().setLoading();}function Vn(){Ee().clearLoading();}function Gn(c){Ee().showAnswer(c);}function Wn(c,p){Ee().showError(c,p);}return {element:K,show:nn,hide:rn,showLogin:dn,setLoginLoading:cn,setLoginError:un,setLoading:an,showTerms:gt,showSearchResults:mn,setError:ln,showTermDetail:kn,showCommentForm:En,showEditForm:Tn,setCommentLoading:Cn,setCommentError:Mn,setEditLoading:An,setEditError:Ln,showSuggestedTerms:Sn,showAiModal:Hn,setAiModalLoading:Rn,showToast:Wt,setAuthenticated:Pn,showMemoriesList:Bn,showMemoryDetail:$n,cleanup:xn,popout:sn,loadClarifications:Gt,showClarificationDetail:jn,enterPickMode:Zn,showCaptureDescribe:Kn,setCaptureLoading:Yn,setCaptureError:Xn,exitCaptureMode:Jn,restoreHomeView:Qn,showHomeMemoryItems:jt,showAllConcepts:hn,showAllClarifications:gn,showAllMemories:fn,showNewMemoryForm:In,showAddEntryForm:zn,updateFormSnapshot:Un,setFormPickingMode:Nn,showStateChangeNotification:On,hideStateChangeNotification:qn,showAsk:Fn,setAskLoading:_n,clearAskLoading:Vn,showAskAnswer:Gn,showAskError:Wn};function jn(c,p){Eo(E,c,p,{onBack:()=>i?.(),...h&&{onPostReply:h}});}function Te(){return E.querySelector('[data-testid="widget-context-strip"]')}function Zn(c){let p=Te();p&&To(p,c);}function Kn(c,p,k){let w=Te();w&&Co(w,c,p,k);}function Yn(c){let p=Te();p&&Mo(p,c);}function Xn(c){let p=Te();p&&Ao(p,c);}function Jn(){let c=Te();c&&Lo(c);}function Qn(c){console.log("[unnoodle] restoreHomeView called with data:",c),gt(c);}function jt(c){let p=E.querySelector('[data-section="memory"]');if(p){if(p.querySelectorAll(".memory-item, .section-empty, .home-show-more-memories").forEach(k=>k.remove()),c.length===0){let k=document.createElement("div");k.className="section-empty",k.innerHTML=`
|
|
2381
2562
|
<div class="section-empty-title">No captures yet.</div>
|
|
2382
2563
|
<div class="section-empty-text">Capture elements on this screen so teammates can understand the interface faster.</div>
|
|
2383
2564
|
<button class="section-empty-action" data-testid="widget-add-ui-meaning-empty">Add Capture</button>
|
|
2384
|
-
`,
|
|
2565
|
+
`,k.querySelector('[data-testid="widget-add-ui-meaning-empty"]')?.addEventListener("click",()=>{d?.();}),p.appendChild(k);return}for(let k of c.slice(0,de)){let w=document.createElement("div");w.className="memory-item",w.setAttribute("data-testid","widget-memory-item"),w.setAttribute("data-ui-state-id",String(k.id));let C=P(k.title),$=vt(k.updatedAt),B=k.entryCount;w.innerHTML=`
|
|
2385
2566
|
<div class="memory-item-content">
|
|
2386
|
-
<div class="memory-item-title">${
|
|
2387
|
-
<div class="memory-item-meta">${
|
|
2567
|
+
<div class="memory-item-title">${C}</div>
|
|
2568
|
+
<div class="memory-item-meta">${$} \xB7 ${B} ${B===1?"entry":"entries"}</div>
|
|
2388
2569
|
</div>
|
|
2389
2570
|
<span class="concept-chevron"><svg viewBox="0 0 24 24" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg></span>
|
|
2390
|
-
`,
|
|
2571
|
+
`,w.addEventListener("click",()=>{m?.(k.id);}),p.appendChild(w);}if(c.length>de){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 ${c.length} memories \u2192`,k.addEventListener("click",w=>{w.preventDefault(),_?.();}),p.appendChild(k);}}}}var qo=`
|
|
2391
2572
|
:host {
|
|
2392
2573
|
all: initial;
|
|
2393
2574
|
}
|
|
@@ -2620,14 +2801,7 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2620
2801
|
opacity: 1;
|
|
2621
2802
|
pointer-events: auto;
|
|
2622
2803
|
}
|
|
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=`
|
|
2804
|
+
`;function Ut(n){let t=document.createElement("div");if(t.className="rail-identity rail-section",n){let e=document.createElement("div");e.className="rail-avatar",e.textContent=n,e.style.position="relative";let o=document.createElement("span");o.className="rail-tooltip",o.textContent="Profile",e.appendChild(o),t.appendChild(e);}else {let e=document.createElement("button");e.className="rail-item",e.type="button",e.tabIndex=0,e.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 o=document.createElement("span");o.className="rail-tooltip",o.textContent="Profile",e.appendChild(o),t.appendChild(e);}return t}function Nt(n,t){let e=document.createElement("div");e.className="rail-core rail-section";let o={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:o.house,label:"Overview",cb:t.onOverview},{key:"memory",icon:o.brain,label:"Memory",cb:t.onMemory},{key:"vocabulary",icon:o.book,label:"Vocabulary",cb:t.onVocabulary},{key:"clarifications",icon:o.question,label:"Clarifications",cb:t.onClarifications}].forEach(r=>{let s=document.createElement("button");s.className="rail-item"+(n.activeSection===r.key?" active":""),s.type="button",s.tabIndex=0,s.innerHTML=(r.key==="memory"?`<div class="rail-glow${n.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),e.appendChild(s);}),e}function Ot(n,t){let e=document.createElement("div");e.className="rail-auth rail-section";let o=document.createElement("button");o.className="rail-auth-btn",o.type="button",o.tabIndex=0;let i,r;n?(i='<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",o.addEventListener("click",t.onLogout)):(i='<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",o.addEventListener("click",t.onLogin)),o.innerHTML=i;let s=document.createElement("span");return s.className="rail-tooltip",s.textContent=r,o.appendChild(s),e.appendChild(o),e}function Fo(n,t){let e=document.createElement("div");e.id="unnoodle-rail-host";let o=e.attachShadow({mode:"open"}),i=document.createElement("style");i.textContent=qo,o.appendChild(i);let r=Ut(n.initials),s=Nt({activeSection:n.activeSection,hasMemoryGlow:n.hasMemoryGlow},t),a=Ot(n.isLoggedIn,t),l=document.createElement("div");l.className="rail-shell";let d=document.createElement("nav");d.className="rail",d.appendChild(r),d.appendChild(s),d.appendChild(a),l.appendChild(d),o.appendChild(l);let u=34;document.body.style.transition="margin-right 0.28s cubic-bezier(0.4,0,0.2,1)",document.body.style.marginRight=`${u}px`;function m(f){d.removeChild(r),d.removeChild(s),d.removeChild(a),r=Ut(f.initials??n.initials),s=Nt({activeSection:f.activeSection??n.activeSection,hasMemoryGlow:f.hasMemoryGlow??n.hasMemoryGlow},t),a=Ot(f.isLoggedIn??n.isLoggedIn,t),d.appendChild(r),d.appendChild(s),d.appendChild(a),Object.assign(n,f);}function v(){e.remove(),document.body.style.marginRight="";}return {element:e,setState:m,cleanup:v}}function _o(n,t,e,o,i,r,s,a,l,d,u,m,v,f,x,y,L,R,H,I,q,N,h,g,b,T,D,z,_,V,G,K){let Y=zt(t,e,o,i,r,s,a,l,d,u,m,v,f,x,y,L,R,H,I,q,N,h,g,b,T,D,z,_,V,G,K),te=vo(n,R);document.body.appendChild(Y.element),document.body.appendChild(te.element);let j=()=>{te.cleanup(),Y.cleanup();};return {panel:Y,setProgress:te.setProgress,cleanup:j}}function Vo(n,t,e){let o=zt(...e),i=Fo(n,t);document.body.appendChild(o.element),document.body.appendChild(i.element);let r=()=>{i.cleanup(),o.cleanup();};return {panel:o,setRailState:i.setState,cleanup:r}}var Ji=new Set(["INPUT","TEXTAREA","SCRIPT","STYLE","CODE","PRE","KBD","SAMP","VAR","NOSCRIPT","BUTTON","SELECT","OPTION","OPTGROUP"]),Qi=new Set(["unnoodle-panel-host","unnoodle-btn-host"]),Go="unnoodle-highlight",er=["border-bottom: 1px dotted currentColor","cursor: pointer","opacity: 0.85","text-decoration: none"].join("; ");function Wo(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var pt=class{constructor(t){this.highlights=[];this.onTermClick=t;}apply(t){this.remove();let e=t.filter(r=>r.status==="ACTIVE");if(e.length===0)return;let{regex:o,termMap:i}=this.buildPattern(e);this.walkAndHighlight(document.body,o,i);}remove(){for(let t=this.highlights.length-1;t>=0;t--){let e=this.highlights[t],o=e.parentNode;o&&(o.replaceChild(document.createTextNode(e.textContent??""),e),o.normalize());}this.highlights=[];}buildPattern(t){let e=new Map,o=[...t].sort((s,a)=>a.term.length-s.term.length),i=[];for(let s of o){let a=s.term.toLowerCase();if(e.has(a)||(e.set(a,s),i.push(Wo(s.term))),s.abbreviation){let l=s.abbreviation.toLowerCase();e.has(l)||(e.set(l,s),i.push(Wo(s.abbreviation)));}}return i.length===0?{regex:/(?!)/g,termMap:e}:{regex:new RegExp(`\\b(${i.join("|")})\\b`,"gi"),termMap:e}}walkAndHighlight(t,e,o){if(t.nodeType===Node.ELEMENT_NODE){let i=t;if(Qi.has(i.id)||i.classList.contains(Go)||i.getAttribute("contenteditable")!=null||Ji.has(i.tagName))return;for(let r of Array.from(i.childNodes))this.walkAndHighlight(r,e,o);}else t.nodeType===Node.TEXT_NODE&&this.highlightTextNode(t,e,o);}highlightTextNode(t,e,o){let i=t.textContent??"";if(!i.trim())return;e.lastIndex=0;let r=[],s=0,a;for(;(a=e.exec(i))!==null;){let u=a[0],m=o.get(u.toLowerCase());if(!m)continue;a.index>s&&r.push(i.slice(s,a.index));let v=document.createElement("span");v.className=Go,v.dataset.termId=String(m.id),v.textContent=u,v.title=m.definition.length>120?`${m.definition.slice(0,120)}\u2026`:m.definition,v.style.cssText=er,v.addEventListener("click",f=>{f.stopPropagation(),this.onTermClick(m);}),r.push(v),this.highlights.push(v),s=a.index+u.length;}if(r.length===0)return;r.push(i.slice(s));let l=t.parentNode;if(!l)return;let d=t.nextSibling;l.removeChild(t);for(let u of r)typeof u=="string"?u&&l.insertBefore(document.createTextNode(u),d):l.insertBefore(u,d);}};var jo=new Set(["INPUT","TEXTAREA","SCRIPT","STYLE","CODE","PRE","KBD","SAMP","VAR","NOSCRIPT","BUTTON","SELECT","OPTION","OPTGROUP"]),Zo=new Set(["unnoodle-panel-host","unnoodle-btn-host"]),tr=5,or=2,nr=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"]),mt=class{scan(t){let e=this.buildGlossarySet(t),o=this.extractText(document.body),i=new Map,r=/[A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*/g,s;for(;(s=r.exec(o))!==null;){let a=s[0].split(/\s+/);for(let l=0;l<a.length;l++)if(!nr.has(a[l]))for(let d=1;d<=Math.min(3,a.length-l);d++){let u=a.slice(l,l+d).join(" ");u.length<2||e.has(u.toLowerCase())||i.set(u,(i.get(u)??0)+1);}}return [...i.entries()].filter(([,a])=>a>=or).sort((a,l)=>l[1]-a[1]).slice(0,tr).map(([a,l])=>({term:a,count:l}))}getPageContext(t){let e=t.toLowerCase(),o=Array.from(document.body.querySelectorAll("p, li, blockquote, td, section, article"));for(let i of o){if(jo.has(i.tagName)||Zo.has(i.id))continue;let r=i.textContent??"";if(r.toLowerCase().includes(e))return r.slice(0,500).trim()}return ""}buildGlossarySet(t){let e=new Set;for(let o of t)e.add(o.term.toLowerCase()),o.abbreviation&&e.add(o.abbreviation.toLowerCase());return e}extractText(t){if(t.nodeType===Node.ELEMENT_NODE){let e=t;return Zo.has(e.id)||jo.has(e.tagName)||e.getAttribute("contenteditable")!=null?"":Array.from(e.childNodes).map(o=>this.extractText(o)).join(" ")}return t.nodeType===Node.TEXT_NODE?t.textContent??"":""}};var ir="This account uses two-factor authentication, which this panel doesn't support yet. Sign in from your Unnoodle workspace instead.",ht=class{constructor(t){this.askInFlight=null;this.askRetryTimer=null;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=t;}getUserInitials(){let t=this.config.userName,e=this.config.userEmail;if(!t&&this.authToken)try{let o=this.authToken;if(o){let i=o.split(".");if(i.length===3&&typeof i[1]=="string"){let r=JSON.parse(atob(i[1]));t=r.name,e=r.email;}}}catch{}if(t){let o=t.trim().split(" ");if(o.length===1)return o[0]&&o[0][0]?o[0][0].toUpperCase():"?";let i=o[0]&&o[0][0]?o[0][0]:"",r=o[o.length-1],s=r&&r[0]?r[0]:"";return (i+s).toUpperCase()||"?"}return e&&e[0]?e[0].toUpperCase():"?"}init(){if(!this.config)throw new Error("WidgetController: config is not set");let t=this.config.theme?.shadowTokens;if(this.config.useRail){let e=!!this.resolveToken(),o=e?this.getUserInitials():null,i={isLoggedIn:e,initials:o,activeSection:"overview",hasMemoryGlow:false},r={onOverview:()=>this.open(),onMemory:()=>{this.isOpen||this.open();let l=!!this.resolveToken();this.cachedResponse?.productMemories?this.ui?.panel.showAllMemories(this.cachedResponse.productMemories,l):this.cachedHomeMemories?this.ui?.panel.showAllMemories(this.cachedHomeMemories,l):this.ui?.panel.showAllMemories?.([],l);},onVocabulary:()=>{this.isOpen||this.open(),this.cachedResponse?this.ui?.panel.showAllConcepts(this.cachedResponse.glossary):this.ui?.panel.showAllConcepts?.([]);},onClarifications:()=>{this.isOpen||this.open();let l=!!this.resolveToken();this.cachedDiscussions?this.ui?.panel.showAllClarifications(this.cachedDiscussions,l):this.ui?.panel.showAllClarifications?.([],l);},onLogin:()=>{this.isOpen||(this.isOpen=true,this.ui?.panel.show()),this.showLoginWithProviders();},onLogout:()=>{this.clearAuthToken(),this.showLoginWithProviders();}},s=[(l,d)=>this.handleLogin(l,d),l=>this.handleSearch(l),this.config.workspaceUrl,()=>{this.isOpen=false,this.highlighter?.remove();},()=>this.handleBack(),(l,d)=>this.handleAddComment(l,d),(l,d)=>this.handleEditTerm(l,d),l=>this.handleTermClick(l),l=>this.handleRequestEdit(l),()=>{this.resolveToken()?this.captureModeController?.start():this.showLoginWithProviders();},()=>{this.loadMemories(0,false);},l=>{this.handleViewMemoryDetail(l);},(l,d,u)=>{this.handleUpdateEntryExplanation(l,d,u);},()=>{this.isOpen=false,this.highlighter?.remove();},()=>{this.isOpen=false;},l=>{this.handleSsoLogin(l);},t,(l,d)=>{this.handleAskQuestion(l,d);},()=>{this.resolveToken()||this.showLoginWithProviders();},(l,d)=>{this.handleCreateTerm(l,d);},()=>{this.cachedResponse&&(this.ui?.panel.showSearchResults(this.cachedResponse.glossary,""),this.ui?.panel.setAuthenticated(!!this.resolveToken()));},l=>{this.handleClarificationClick(l);},(l,d,u)=>{this.handlePostReply(l,d,u);},l=>{this.handleAddEntryToMemory(l);},l=>{this.handleDeleteMemory(l);},(l,d)=>{this.handleDeleteEntry(l,d);},()=>{this.cachedResponse&&this.ui?.panel.showAllConcepts(this.cachedResponse.glossary);},()=>{this.cachedDiscussions&&this.ui?.panel.showAllClarifications(this.cachedDiscussions,!!this.resolveToken());},()=>{this.cachedResponse?.productMemories&&this.ui?.panel.showAllMemories(this.cachedResponse.productMemories,!!this.resolveToken());},l=>{this.handleAsk(l);},()=>{this.handleOpenAsk();}],a=Vo(i,r,s);this.ui={panel:a.panel,setProgress:()=>{},cleanup:a.cleanup},this.rail=a;}else this.ui=_o(()=>this.toggle(),(e,o)=>this.handleLogin(e,o),e=>this.handleSearch(e),this.config.workspaceUrl,()=>{this.isOpen=false,this.highlighter?.remove();},()=>this.handleBack(),(e,o)=>this.handleAddComment(e,o),(e,o)=>this.handleEditTerm(e,o),e=>this.handleTermClick(e),e=>this.handleRequestEdit(e),()=>{console.log("[unnoodle] onCaptureUiState callback triggered",{captureModeController:!!this.captureModeController,ui:!!this.ui}),this.resolveToken()?this.captureModeController?.start():this.showLoginWithProviders();},()=>{this.loadMemories(0,false);},e=>{this.handleViewMemoryDetail(e);},(e,o,i)=>{this.handleUpdateEntryExplanation(e,o,i);},()=>{this.isOpen=false,this.highlighter?.remove();},()=>{this.isOpen=false;},e=>{this.handleSsoLogin(e);},t,(e,o)=>{this.handleAskQuestion(e,o);},()=>{this.resolveToken()||this.showLoginWithProviders();},(e,o)=>{this.handleCreateTerm(e,o);},()=>{this.cachedResponse&&(this.ui?.panel.showSearchResults(this.cachedResponse.glossary,""),this.ui?.panel.setAuthenticated(!!this.resolveToken()));},e=>{this.handleClarificationClick(e);},(e,o,i)=>{this.handlePostReply(e,o,i);},e=>{this.handleAddEntryToMemory(e);},e=>{this.handleDeleteMemory(e);},(e,o)=>{this.handleDeleteEntry(e,o);},()=>{console.log("DEBUG: onShowAllConcepts called, cachedResponse:",!!this.cachedResponse),this.cachedResponse&&(console.log("DEBUG: Calling showAllConcepts with",this.cachedResponse.glossary.length,"terms"),this.ui?.panel.showAllConcepts(this.cachedResponse.glossary));},()=>{console.log("DEBUG: onShowAllClarifications called, cachedDiscussions:",!!this.cachedDiscussions),this.cachedDiscussions&&(console.log("DEBUG: Calling showAllClarifications with",this.cachedDiscussions.length,"discussions"),this.ui?.panel.showAllClarifications(this.cachedDiscussions,!!this.resolveToken()));},()=>{console.log("DEBUG: onShowAllMemories called",{hasCachedResponse:!!this.cachedResponse,hasResponseMemories:!!this.cachedResponse?.productMemories,hasCachedHomeMemories:!!this.cachedHomeMemories}),this.cachedResponse?.productMemories?(console.log("DEBUG: Using cached memories from main response",this.cachedResponse.productMemories.length),this.ui?.panel.showAllMemories(this.cachedResponse.productMemories,!!this.resolveToken())):this.cachedHomeMemories?(console.log("DEBUG: Using cached memories from separate cache",this.cachedHomeMemories.length),this.ui?.panel.showAllMemories(this.cachedHomeMemories,!!this.resolveToken())):(console.log("DEBUG: No cached memories, fetching via API"),this.loadAllMemories());},e=>{this.handleAsk(e);},()=>{this.handleOpenAsk();});if(this.captureModeController=$t(this.ui.panel,this.config,()=>this.resolveToken(),()=>this.cachedResponse?.glossary??[],()=>{this.loadHomeMemoryItems();}),this.keydownHandler=e=>{(e.metaKey||e.ctrlKey)&&e.key==="u"&&(e.preventDefault(),this.toggle());},document.addEventListener("keydown",this.keydownHandler),this.highlighter=new pt(e=>this.handleTermClick(e)),this.suggester=new mt,this.config._plugins)for(let e of this.config._plugins)try{e.onInit?.(this.config);}catch{}}open(){this.isOpen||!this.ui||(this.isOpen=true,this.ui.panel.show(),this.loadTerms());}close(){!this.isOpen||!this.ui||(this.isOpen=false,this.abortAsk(),this.highlighter?.remove(),this.ui.panel.hide());}toggle(){this.isOpen?this.close():this.open();}setProgress(t){this.ui?.setProgress(t);}destroy(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.tokenExpiryTimer!==null&&(clearTimeout(this.tokenExpiryTimer),this.tokenExpiryTimer=null),this.abortAsk(),this.highlighter?.remove(),this.highlighter=null,this.suggester=null,this.captureModeController=null,this.activeSuggestion=null,this.ssoProviders=null,this.ssoPopupCleanup?.(),this.ssoPopupCleanup=null,this.ui?.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{}}resolveToken(){return this.authToken?this.authToken:typeof this.config.getAuthToken=="function"?this.config.getAuthToken()??null:null}clearAuthToken(){this.authToken=null;try{sessionStorage.removeItem(this.sessionKey);}catch{}}scheduleTokenExpiry(t){this.tokenExpiryTimer!==null&&(clearTimeout(this.tokenExpiryTimer),this.tokenExpiryTimer=null);try{let e=t.split(".");if(e.length!==3)return;let o=e[1];if(!o)return;let i=o.replace(/-/g,"+").replace(/_/g,"/"),r=JSON.parse(atob(i));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{}}async showLoginWithProviders(){this.ui&&(this.ssoProviders||(this.ssoProviders=await Ve(this.config)),this.ui&&this.ui.panel.showLogin(this.ssoProviders));}handleSsoLogin(t){if(!this.ui)return;let e=this.config.baseUrl?.replace(/\/$/,"")??"https://api.unnoodle.com",o=`${e}/api/auth/oauth/${t}?widget=true`,i=window.open(o,"unnoodle-sso","width=500,height=650,scrollbars=yes,resizable=yes");this.ssoPopupCleanup?.(),this.ssoPopupCleanup=null;let r=()=>{clearInterval(a),window.removeEventListener("message",s),this.ssoPopupCleanup=null;},s=l=>{try{let u=new URL(e).origin;if(l.origin!==u)return}catch{}if(!l.data||typeof l.data!="object"||l.data.type!=="unnoodle-oauth-token"||typeof l.data.token!="string")return;r();let d=l.data.token;if(d){this.authToken=d;try{sessionStorage.setItem(this.sessionKey,d);}catch{}if(this.scheduleTokenExpiry(d),i?.close(),this.pendingAction){let u=this.pendingAction;this.pendingAction=null,u();}else this.fetchTerms(d);}},a=setInterval(()=>{i?.closed&&r();},500);this.ssoPopupCleanup=r,window.addEventListener("message",s);}loadTerms(){if(this.cachedResponse){this.ui?.panel.showTerms(this.cachedResponse),this.captureModeController?.setHomeData(this.cachedResponse),this.highlighter?.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,this.ui?.panel.loadClarifications(this.cachedResponse.clarifications,!!this.resolveToken())):this.cachedDiscussions?this.ui?.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,this.ui?.panel.showHomeMemoryItems(this.cachedResponse.productMemories)):this.cachedHomeMemories?(console.log("[DEBUG] Using cached home memories from separate cache",this.cachedHomeMemories.length),this.ui?.panel.showHomeMemoryItems(this.cachedHomeMemories)):this.loadHomeMemoryItems();return}this.fetchTerms(this.resolveToken());}async handleLogin(t,e){if(this.ui){this.ui.panel.setLoginLoading(true);try{let o=await _e(this.config,{email:t,password:e});if(o.mfaPending){this.pendingAction=null,this.ui.panel.setLoginError(ir);return}this.authToken=o.token;try{sessionStorage.setItem(this.sessionKey,o.token);}catch{}if(this.scheduleTokenExpiry(o.token),this.pendingAction){let i=this.pendingAction;this.pendingAction=null,i();}else await this.fetchTerms(o.token);}catch(o){let i=o instanceof A&&o.status===401?"Invalid email or password.":"Login failed. Please try again.";this.ui.panel.setLoginError(i);}finally{this.ui?.panel.setLoginLoading(false);}}}async handleTermClick(t){if(!this.ui)return;this.currentTerm=t;let e=this.resolveToken();this.ui.panel.setLoading();try{let o=await Ae(this.config,t.id,e??void 0);this.ui&&this.ui.panel.showTermDetail(t,o,{showEdit:!0});}catch{this.ui&&this.ui.panel.showTermDetail(t,[],{showEdit:true});}}async handleOpenAsk(){if(!this.resolveToken()){this.showLoginWithProviders();return}let t=await co(this.config,this.resolveToken()).catch(()=>null);this.ui?.panel.showAsk(t);}async handleAsk(t){if(this.askInFlight)return;let e=new AbortController;this.askInFlight=e,this.ui?.panel.setAskLoading();try{for(let o=0;;o++)try{let i=await lo(this.config,t,typeof location<"u"?location.href:"",this.resolveToken(),e.signal);this.ui?.panel.showAskAnswer(i);return}catch(i){if(e.signal.aborted)return;if(i instanceof ve&&o===0){if(await this.sleep((i.retryAfter||2)*1e3),e.signal.aborted)return;continue}if(i instanceof ve){this.ui?.panel.showAskError("Unnoodle is busy right now. Try again in a moment.",!0);return}if(i instanceof Se){this.ui?.panel.showAskError(this.rateLimitMessage(i),!1);return}if(i instanceof A&&(i.status===401||i.status===403)){this.showLoginWithProviders();return}this.ui?.panel.showAskError("Couldn't reach Unnoodle. Try again.",!0);return}}finally{this.askInFlight===e&&(this.askInFlight=null,this.ui?.panel.clearAskLoading());}}rateLimitMessage(t){let e=Math.max(0,Math.round(t.retryAfter));if(e<=0)return "You've reached today's question limit \u2014 try again later.";if(e<90)return `Too many questions just now \u2014 try again in ${e} second${e===1?"":"s"}.`;let o=Math.round(e/60);return `Too many questions just now \u2014 try again in ${o} minute${o===1?"":"s"}.`}sleep(t){return new Promise(e=>{this.askRetryTimer=setTimeout(e,t);})}abortAsk(){this.askInFlight?.abort(),this.askInFlight=null,this.askRetryTimer!==null&&(clearTimeout(this.askRetryTimer),this.askRetryTimer=null);}handleBack(){this.abortAsk(),!(!this.ui||!this.cachedResponse)&&(this.currentTerm=null,this.pendingAction=null,this.ui.panel.showTerms(this.cachedResponse),this.captureModeController?.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(t,e){this.ui&&(e?this.submitComment(t,e):this.resolveToken()?this.ui.panel.showCommentForm(t):(this.pendingAction=()=>this.ui?.panel.showCommentForm(t),this.showLoginWithProviders()));}handleRequestEdit(t){if(!this.ui)return;let e=this.currentTerm??this.cachedResponse?.glossary.find(i=>i.id===t)??null;if(!e)return;this.resolveToken()?this.ui.panel.showEditForm(e):(this.pendingAction=()=>this.ui?.panel.showEditForm(e),this.showLoginWithProviders());}handleEditTerm(t,e){this.submitEdit(t,e);}async submitComment(t,e){let o=this.resolveToken();if(!(!o||!this.ui)){this.ui.panel.setCommentLoading(true);try{await Ge(this.config,t,e,o);let i=await Ae(this.config,t,o);this.ui&&this.currentTerm&&this.ui.panel.showTermDetail(this.currentTerm,i,{showEdit:!0});}catch(i){let r=i instanceof A?i.message:"Failed to post comment. Please try again.";this.ui?.panel.setCommentError(r);}finally{this.ui?.panel.setCommentLoading(false);}}}async submitEdit(t,e){let o=this.resolveToken();if(!(!o||!this.ui)){this.ui.panel.setEditLoading(true);try{await We(this.config,t,e,o),this.cachedResponse=null,this.fuseIndex=null,await this.fetchTerms(o);}catch(i){let r=i instanceof A?i.message:"Failed to update term. Please try again.";this.ui?.panel.setEditError(r);}finally{this.ui?.panel.setEditLoading(false);}}}async fetchTerms(t){if(!(this.isFetching||!this.ui)){this.isFetching=true,this.setProgress(true),this.ui.panel.setLoading();try{let e=await qe(this.config,t);if(this.cachedResponse=e,this.highlighter?.apply(e.glossary),this.config._plugins)for(let o of this.config._plugins)try{o.onResponse?.(e);}catch{}if(this.ui){if(this.ui.panel.showTerms(e),this.captureModeController?.setHomeData(e),this.showSuggestions(e.glossary),this.ui.panel.setAuthenticated(!!this.resolveToken()),e.clarifications!==void 0){let o=e.clarifications.slice(0,5);this.cachedDiscussions=o,this.cachedResponse.clarifications=o,this.ui.panel.loadClarifications(o,!!this.resolveToken());}else this.fetchDiscussions(e.context.id);if(e.productMemories!==void 0){let o=e.productMemories.slice(0,5);this.cachedHomeMemories=o,this.cachedResponse.productMemories=o,this.ui.panel.showHomeMemoryItems(o);}else this.loadHomeMemoryItems();}}catch(e){let o=e instanceof Error?e:new Error(String(e));if(this.config._plugins)for(let i of this.config._plugins)try{i.onError?.(o);}catch{}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(t){if(this.ui)try{let o=(await Le(this.config,t,this.resolveToken())).slice(0,5);this.cachedDiscussions=o,this.cachedResponse&&(this.cachedResponse.clarifications=o),this.ui.panel.loadClarifications(o,!!this.resolveToken());}catch{this.ui&&this.ui.panel.loadClarifications([],!!this.resolveToken());}}async handleCreateTerm(t,e){let o=this.resolveToken();if(!(!o||!this.ui||!this.cachedResponse))try{await Ke(this.config,this.cachedResponse.context.id,t,e,o),await this.fetchTerms(o);}catch(i){let r=i instanceof A?i.message:"Failed to add term. Please try again.";this.ui.panel.showToast(r);}}async handleAskQuestion(t,e){let o=this.resolveToken();if(!(!o||!this.ui))try{await ot(this.config,t,e,o),await this.fetchDiscussions(t);}catch(i){let r=i instanceof A?i.message:"Failed to post question. Please try again.";this.ui.panel.showToast(r);}}handleClarificationClick(t){if(!this.ui)return;this.currentDiscussion=t;let e=!!this.resolveToken();this.ui.panel.showClarificationDetail(t,e);}async handlePostReply(t,e,o){let i=this.resolveToken();if(!(!i||!this.ui))try{await nt(this.config,t,e,o,i);let r=await Le(this.config,t,i);this.cachedDiscussions=r;let s=r.find(a=>a.id===e);s&&(this.currentDiscussion=s,this.ui.panel.showClarificationDetail(s,!0)),this.ui.panel.loadClarifications(r,!0);}catch(r){let s=r instanceof A?r.message:"Failed to post reply. Please try again.";this.ui?.panel.showToast(s);}}async handleSearch(t){if(!this.ui||!this.cachedResponse)return;let e=t.trim();if(!e){this.ui.panel.showTerms(this.cachedResponse),this.captureModeController?.setHomeData(this.cachedResponse),this.loadHomeMemoryItems();return}this.fuseIndex||(this.fuseIndex=this.buildFuseIndex(this.cachedResponse.glossary));let i=this.fuseIndex.search(e).map(r=>r.item);this.ui.panel.showSearchResults(i,e);try{let r=this.resolveToken(),s=await Fe(this.config,this.cachedResponse.context.id,e,r);this.ui&&this.ui.panel.showSearchResults(s,e);}catch{}}buildFuseIndex(t){return new le(t,{keys:[{name:"term",weight:3},{name:"abbreviation",weight:2},{name:"definition",weight:1}],threshold:.35,includeScore:true,ignoreLocation:true,minMatchCharLength:2})}showSuggestions(t){if(!this.ui||!this.suggester)return;let e=this.suggester.scan(t);e.length!==0&&this.ui.panel.showSuggestedTerms(e,o=>this.handleAddSuggestion(o));}handleAddSuggestion(t){if(!this.ui)return;if(this.activeSuggestion=t,!this.resolveToken()){this.pendingAction=()=>this.openAiGenerateFlow(t),this.showLoginWithProviders();return}this.openAiGenerateFlow(t);}async openAiGenerateFlow(t){if(!this.ui)return;let e=this.resolveToken();if(!e)return;let o=this.suggester?.getPageContext(t)??"",i=typeof window<"u"?window.location.href:"";this.ui.panel.setAiModalLoading(false);try{let r=await je(this.config,t,o,i,e);this.ui?.panel.showAiModal(t,r,s=>{this.submitSuggestedTerm(t,s);},()=>{this.cachedResponse&&this.ui&&(this.ui.panel.showTerms(this.cachedResponse),this.captureModeController?.setHomeData(this.cachedResponse),this.showSuggestions(this.cachedResponse.glossary),this.loadHomeMemoryItems());});}catch{this.ui?.panel.showAiModal(t,"",r=>{this.submitSuggestedTerm(t,r);},()=>{this.cachedResponse&&this.ui&&(this.ui.panel.showTerms(this.cachedResponse),this.captureModeController?.setHomeData(this.cachedResponse),this.showSuggestions(this.cachedResponse.glossary),this.loadHomeMemoryItems());});}}async loadMemories(t,e=false){if(!this.ui)return;let o=this.resolveToken();try{let i=await fe(this.config,t,o);e||(this.memories=[]),this.memories=[...this.memories,...i.content],this.memoriesPage=i.number,this.hasMoreMemories=!i.last,this.ui.panel.showMemoriesList(i.content,i.number,!i.last,e);}catch(i){let r=i instanceof A?i.message:"Could not load Product Memories.";this.ui.panel.showToast(r);}}async loadAllMemories(){if(!this.ui)return;let t=this.resolveToken();try{let e=await fe(this.config,0,t);this.ui?.panel.showAllMemories(e.content,!!t);}catch(e){console.error("[unnoodle] loadAllMemories failed:",e),this.ui?.panel.showAllMemories([],false);}}async loadHomeMemoryItems(){if(!this.ui)return;let t=this.resolveToken();try{let o=(await fe(this.config,0,t)).content.slice(0,5);this.cachedHomeMemories=o,this.cachedResponse&&(this.cachedResponse.productMemories=o),this.ui?.panel.showHomeMemoryItems(o);}catch(e){console.error("loadHomeMemoryItems failed:",e),this.ui?.panel.showHomeMemoryItems([]);}}async handleViewMemoryDetail(t){if(!this.ui)return;let e=this.resolveToken();try{let o=await Qe(this.config,t,e);this.currentMemory=o,this.ui.panel.showMemoryDetail(o);}catch{this.ui.panel.showToast("Could not load memory details.");}}async handleUpdateEntryExplanation(t,e,o){if(!this.ui)return;let i=this.resolveToken();if(i)try{let r=await Je(this.config,t,e,{explanation:o},i);this.currentMemory=r,this.ui.panel.showMemoryDetail(r),this.ui.panel.showToast("Explanation saved \u2713");}catch{this.ui.panel.showToast("Could not save explanation.");}}handleAddEntryToMemory(t){if(!this.ui||!this.currentMemory)return;if(!this.resolveToken()){this.showLoginWithProviders();return}$t(this.ui.panel,this.config,()=>this.resolveToken(),()=>this.cachedResponse?.glossary??[],()=>{this.handleViewMemoryDetail(t);},new at(t),{type:"add-entry",memoryTitle:this.currentMemory.title}).start();}async handleDeleteMemory(t){if(!this.ui)return;let e=this.resolveToken();if(e)try{await et(this.config,t,e),this.ui.panel.showToast("Memory deleted \u2713"),await this.loadMemories(0,!1);}catch{this.ui.panel.showToast("Could not delete memory.");}}async handleDeleteEntry(t,e){if(!this.ui)return;let o=this.resolveToken();if(o)try{let i=await tt(this.config,t,e,o);this.currentMemory=i,this.ui.panel.showMemoryDetail(i),this.ui.panel.showToast("Entry deleted \u2713");}catch{this.ui.panel.showToast("Could not delete entry.");}}async submitSuggestedTerm(t,e){if(!this.ui||!this.cachedResponse)return;let o=this.resolveToken();if(o){this.ui.panel.setAiModalLoading(true);try{await Ze(this.config,this.cachedResponse.context.id,t,e,o),this.ui.panel.showTerms(this.cachedResponse),this.captureModeController?.setHomeData(this.cachedResponse),this.showSuggestions(this.cachedResponse.glossary),this.loadHomeMemoryItems(),this.ui.panel.showToast("Term submitted for approval"),this.activeSuggestion=null;}catch(i){this.ui.panel.setAiModalLoading(false);i instanceof A?i.message:"Failed to submit term. Please try again.";}}}};function qt(n){return {textContent:n.textContent??"",innerHTML:n.innerHTML}}var Ft=class{constructor(){this.observer=null;this.timerId=null;this.pendingMutations=[];this.watchedEl=null;this.callback=null;this.preBatchState=null;}watch(t,e){this.unwatch(),this.watchedEl=t,this.callback=e,this.preBatchState=qt(t),this.observer=new MutationObserver(o=>{for(let i of o)this.pendingMutations.push(i);this.scheduleFlush();}),this.observer.observe(t,{childList:true,subtree:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true});}unwatch(){this.timerId!==null&&(clearTimeout(this.timerId),this.timerId=null),this.observer?.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 t=[...this.pendingMutations];if(this.pendingMutations=[],!this.watchedEl||!this.callback||!this.preBatchState)return;let e=this.computeDiff(t,this.preBatchState,this.watchedEl);e?(this.preBatchState=qt(this.watchedEl),this.callback(e)):this.preBatchState=qt(this.watchedEl);}computeDiff(t,e,o){let i=t.filter(l=>!(l.type==="attributes"&&l.attributeName==="style"));if(i.length===0)return null;let r=i.find(l=>l.type==="attributes");if(r){let l=r.attributeName;return {type:"attribute",attribute:l,before:r.oldValue??"",after:o.getAttribute(l)??""}}let s=i.find(l=>l.type==="characterData");if(s)return {type:"text",before:s.oldValue??"",after:s.target.data};let a=i.filter(l=>l.type==="childList");if(a.length>0){let l=[];for(let u of a){for(let m of Array.from(u.addedNodes))l.push(m);for(let m of Array.from(u.removedNodes))l.push(m);}return l.every(u=>u.nodeType===Node.TEXT_NODE)?{type:"text",before:e.textContent,after:o.textContent??""}:{type:"structure",before:e.innerHTML,after:o.innerHTML}}return null}};var rr=/\b(loading|spinner|submitting|saving|please wait)\b/i,sr=/\b(error|failed|invalid|failure|try again|went wrong)\b/i,ar=/\b(success|saved|complete|done|submitted|finished)\b/i,lr=[[/\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 Ko(n){return new Set(n.split(/\s+/).filter(Boolean))}function dr(n,t){let e=Ko(n);return [...Ko(t)].filter(o=>!e.has(o)).join(" ")}function cr(n,t){if(n.type==="text"){let e=n.after;return rr.test(e)?"Loading state":sr.test(e)?"Error state":ar.test(e)?"Success state":null}if(n.type==="attribute"){let{attribute:e,after:o}=n;if(e==="class"){let i=dr(n.before,o);if(i){for(let[r,s]of lr)if(r.test(i))return s}return null}if(e==="disabled")return t.hasAttribute("disabled")?"Disabled state":"Enabled state";if(e==="aria-expanded")return o==="true"?"Expanded state":"Collapsed state";if(e==="aria-selected")return o==="true"?"Selected state":null;if(e==="aria-busy")return o==="true"?"Loading state":null;if(e==="aria-label"){let i=o.trim();return i?`Label changed to: ${i}`:null}return null}return null}var ur="unnoodle-live-ring",pr=`
|
|
2631
2805
|
position: fixed;
|
|
2632
2806
|
pointer-events: none;
|
|
2633
2807
|
z-index: 2147483645;
|
|
@@ -2635,5 +2809,5 @@ var _n=Object.defineProperty,Gn=Object.defineProperties;var Vn=Object.getOwnProp
|
|
|
2635
2809
|
border-radius: 4px;
|
|
2636
2810
|
background: rgba(92, 78, 250, 0.10);
|
|
2637
2811
|
box-shadow: 0 0 0 1px rgba(92, 78, 250, 0.35), 0 0 8px rgba(92, 78, 250, 0.25);
|
|
2638
|
-
`,
|
|
2812
|
+
`,_t=class{constructor(){this.ring=null;}show(t){this.hide(),t.scrollIntoView({behavior:"smooth",block:"center"});let e=t.getBoundingClientRect(),o=document.createElement("div");o.id=ur,o.setAttribute("data-testid","unnoodle-live-ring"),o.style.cssText=pr,o.style.top=`${e.top}px`,o.style.left=`${e.left}px`,o.style.width=`${e.width}px`,o.style.height=`${e.height}px`,document.body.appendChild(o),this.ring=o;}hide(){this.ring?.remove(),this.ring=null;}};function mr(n,t){try{let e=new URL(n),o=new URL(t);return e.origin===o.origin&&e.pathname===o.pathname}catch{return n===t}}var Vt=class{constructor(t,e){this.stateWatcher=t;this.targetingEngine=e;}load(t,e){if(this.unload(),!t.watchForChanges)return;let o=t.entries[0];if(!o||!mr(o.url,window.location.href))return;let i=o.targetingMetadata;if(!i)return;let r={...i.id!==void 0&&{id:i.id},...i.dataTestId!==void 0&&{dataTestId:i.dataTestId},tag:i.tag,role:i.role??null,text:i.text??"",url:o.url},s=this.targetingEngine.resolve(r);s&&this.stateWatcher.watch(s,e);}unload(){this.stateWatcher.unwatch();}};var ce=null;function hr(n){if(!(typeof document>"u")&&br(n)){if(ce){let t=`unnoodle_token_${n.apiKey.slice(-8)}`,e=null;try{e=sessionStorage.getItem(t);}catch{}if(ce.destroy(),ce=null,e)try{sessionStorage.setItem(t,e);}catch{}}ce=new ht(n),ce.init();}}function gr(){ce?.open();}function fr(){ce?.close();}function vr(){ce?.destroy(),ce=null;}var pa={init:hr,open:gr,close:fr,destroy:vr};function br(n){return !n||typeof n!="object"?(console.warn("[Unnoodle] initUnnoodle() requires a config object."),false):!n.apiKey||typeof n.apiKey!="string"||n.apiKey.trim()===""?(console.warn("[Unnoodle] initUnnoodle() requires a non-empty `apiKey` string (e.g. pk_live_xxx)."),false):!n.context||typeof n.context!="string"||n.context.trim()===""?(console.warn("[Unnoodle] initUnnoodle() requires a non-empty `context` string."),false):(n.environment&&!["dev","staging","prod"].includes(n.environment)&&console.warn(`[Unnoodle] Invalid environment "${n.environment}". Must be "dev", "staging", or "prod". Defaulting to "prod".`),true)}export{_t as LiveRenderer,Vt as MemoryDetailController,Ft as StateWatcher,pa as Unnoodle,fr as closeUnnoodle,vr as destroyUnnoodle,cr as inferMeaning,hr as initUnnoodle,gr as openUnnoodle};//# sourceMappingURL=index.js.map
|
|
2639
2813
|
//# sourceMappingURL=index.js.map
|