PageSourceSearch

https://pumasafety.com.au/assets/vendor/@lexical/link/link.index-cIZJDVl.js

js pumasafety.com.au collected 2026-09-24 12:51:04 UTC 16,158 bytes, 7 lines download raw bytes

1/**
2 * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1.
3 * Original file: /npm/@lexical/[email protected]/LexicalLink.prod.mjs
4 *
5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6 */
7import{addClassNamesToElement as Le,isHTMLAnchorElement as K,mergeRegister as V,objectKlassEquals as be,$insertNodeToNearestRootAtCaret as Ne,$findMatchingParent as A}from"@lexical/utils";import{createCommand as ve,defineExtension as B,shallowMergeConfig as z,safeCast as Te,ElementNode as Ce,$copyNode as j,$isRangeSelection as U,COMMAND_PRIORITY_EDITOR as Ue,PASTE_COMMAND as Se,$getSelection as S,$isElementNode as O,COMMAND_PRIORITY_LOW as ee,TextNode as Oe,$isTextNode as P,$applyNodeReplacement as te,$getChildCaret as ne,$rewindSiblingCaret as Re,$isNodeSelection as G,$normalizeSelection__EXPERIMENTAL as H,$setSelection as Ae,isDOMNode as Ee,getNearestEditorFromDOMNode as Pe,$getNearestNodeFromDOMNode as Me,$createTextNode as re,$caretFromPoint as ye,$normalizeCaret as ie,$isLineBreakNode as se,$isSiblingCaret as $e,$setPointFromCaret as De}from"lexical";import{namedSignals as le,effect as Ie}from"@lexical/extension";const we=new Set(["http:","https:","mailto:","sms:","tel:"]);class R extends Ce{__url;__target;__rel;__title;static getType(){return"link"}static clone(e){return new R(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e="",t={},r){super(r);const{target:g=null,rel:l=null,title:o=null}=t;this.__url=e,this.__target=g,this.__rel=l,this.__title=o}afterCloneFrom(e){super.afterCloneFrom(e),this.__url=e.__url,this.__rel=e.__rel,this.__target=e.__target,this.__title=e.__title}createDOM(e){const t=document.createElement("a");return this.updateLinkDOM(null,t,e),Le(t,e.theme.link),t}updateLinkDOM(e,t,r){if(K(t)){e&&e.__url===this.__url||(t.href=this.sanitizeUrl(this.__url));for(const g of["target","rel","title"]){const l=`__${g}`,o=this[l];e&&e[l]===o||(o?t[g]=o:t.removeAttribute(g))}}}updateDOM(e,t,r){return this.updateLinkDOM(e,t,r),!1}static importDOM(){return{a:e=>({conversion:We,priority:1})}}static importJSON(e){return M().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setURL(e.url).setRel(e.rel||null).setTarget(e.target||null).setTitle(e.title||null)}sanitizeUrl(e){e=Y(e);try{const t=new URL(Y(e));if(!we.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(e){const t=this.getWritable();return t.__url=e,t}getTarget(){return this.getLatest().__target}setTarget(e){const t=this.getWritable();return t.__target=e,t}getRel(){return this.getLatest().__rel}setRel(e){const t=this.getWritable();return t.__rel=e,t}getTitle(){return this.getLatest().__title}setTitle(e){const t=this.getWritable();return t.__title=e,t}insertNewAfter(e,t=!0){const r=j(this);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!U(t))return!1;const g=t.anchor.getNode(),l=t.focus.getNode();return this.isParentOf(g)&&this.isParentOf(l)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}shouldMergeAdjacentLink(e){return this.getType()===e.getType()&&this.__url===e.__url&&this.__target===e.__target&&this.__rel===e.__rel&&this.__title===e.__title}}function oe(n){const e=ye(n,"next");return[e,e.getFlipped()]}function ae(n,e){for(const t of e)if(t.origin.isAttached()){const r=ie(t);return void De(n,r)}}function Fe(n){const e=S();let t=null,r=null;function g(){U(e)&&(ae(e.anchor,t),ae(e.focus,r),H(e))}U(e)&&(t=oe(e.anchor),r=oe(e.focus));let l=!1;for(const s of ne(n,"next")){const f=s.origin;if(O(f)&&!f.isInline()){const d=f.getChildren();if(d.length>0){const i=j(n);i.append(...d),f.append(i),l=!0}Ne(f,Re(s),{$shouldSplit:()=>!1})}}function o(s,f,d){const[i,a]=s,u=h=>$e(h)&&h.origin.is(f);if(!u(i)&&!u(a))return s;const c=ie(ne(d,"next"));return[c,c.getFlipped()]}if(n.isAttached()){const s=n.getPreviousSibling();if(T(s)&&s.shouldMergeAdjacentLink(n))return t&&(t=o(t,s,n)),r&&(r=o(r,s,n)),s.append(...n.getChildren()),n.remove(),void g();const f=n.getNextSibling();T(f)&&n.shouldMergeAdjacentLink(f)&&(t&&(t=o(t,n,f)),r&&(r=o(r,n,f)),n.append(...f.getChildren()),f.remove(),l=!0)}if(l){if(!n.canBeEmpty()&&n.isEmpty()){const s=n.getParent();n.remove(),s&&s.isEmpty()&&s.remove()}g()}}function We(n){let e=null;if(K(n)){const t=n.textContent;(t!==null&&t!==""||n.children.length>0)&&(e=M(n.getAttribute("href")||"",{rel:n.getAttribute("rel"),target:n.getAttribute("target"),title:n.getAttribute("title")}))}return{node:e}}function M(n="",e){return te(new R(n,e))}function T(n){return n instanceof R}class E extends R{__isUnlinked;constructor(e="",t={},r){super(e,t,r),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}afterCloneFrom(e){super.afterCloneFrom(e),this.__isUnlinked=e.__isUnlinked}static getType(){return"autolink"}static clone(e){return new E(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}shouldMergeAdjacentLink(e){return!1}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,r){return super.updateDOM(e,t,r)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){return F().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(e,t=!0){const r=F(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(r,t),r}}function F(n="",e){return te(new E(n,e))}function b(n){return n instanceof E}const W=ve("TOGGLE_LINK_COMMAND");function ue(n,e){if(n.type==="element"){const t=n.getNode();return O(t)||(function(r,...g){const l=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",r);for(const s of g)o.append("v",s);throw l.search=o.toString(),Error(`Minified Lexical error #${r}; visit ${l.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(252),t.getChildren()[n.offset+e]||null}return null}function y(n,e={}){let t;if(n&&typeof n=="object"){const{url:i,...a}=n;t=i,e={...a,...e}}else t=n;const{target:r,title:g}=e,l=e.rel===void 0?"noreferrer":e.rel,o=S();if(o===null||!U(o)&&!G(o))return;if(G(o)){const i=o.getNodes();
7return i.length===0?void 0:void i.forEach(a=>{if(t===null){const u=A(a,c=>!b(c)&&T(c));u&&(u.insertBefore(a),u.getChildren().length===0&&u.remove())}else{const u=A(a,c=>!b(c)&&T(c));if(u)u.setURL(t),r!==void 0&&u.setTarget(r),l!==void 0&&u.setRel(l);else{const c=M(t,{rel:l,target:r});a.insertBefore(c),c.append(a)}}})}if(o.isCollapsed()&&t===null)for(const i of o.getNodes()){const a=A(i,u=>!b(u)&&T(u));return void(a!==null&&(a.getChildren().forEach(u=>{a.insertBefore(u)}),a.remove()))}const s=o.extract();if(t===null){const i=new Set;return void s.forEach(a=>{const u=A(a,c=>!b(c)&&T(c));if(u!==null){const c=u.getKey();if(i.has(c))return;(function(h,p){const L=new Set(p.filter(x=>h.isParentOf(x)).map(x=>x.getKey())),_=h.getChildren(),m=x=>L.has(x.getKey())||O(x)&&p.some(C=>h.isParentOf(C)&&x.isParentOf(C)),k=_.filter(m);if(k.length===_.length)return _.forEach(x=>h.insertBefore(x)),void h.remove();const N=_.findIndex(m),v=_.findLastIndex(m),D=N===0,I=v===_.length-1;if(D)k.forEach(x=>h.insertBefore(x));else if(I)for(let x=k.length-1;x>=0;x--)h.insertAfter(k[x]);else{for(let C=k.length-1;C>=0;C--)h.insertAfter(k[C]);const x=_.slice(v+1);if(x.length>0){const C=j(h);k[k.length-1].insertAfter(C),x.forEach(w=>C.append(w))}}})(u,s),i.add(c)}})}const f=new Set,d=i=>{f.has(i.getKey())||(f.add(i.getKey()),i.setURL(t),r!==void 0&&i.setTarget(r),l!==void 0&&i.setRel(l),g!==void 0&&i.setTitle(g))};if(s.length===1){const i=s[0],a=A(i,T);if(a!==null)return d(a)}(function(i){const a=S();if(!U(a))return i();const u=H(a),c=u.isBackward(),h=ue(u.anchor,c?-1:0),p=ue(u.focus,c?0:-1);if(i(),h||p){const L=S();if(U(L)){const _=L.clone();if(h){const m=h.getParent();m&&_.anchor.set(m.getKey(),h.getIndexWithinParent()+(c?1:0),"element")}if(p){const m=p.getParent();m&&_.focus.set(m.getKey(),p.getIndexWithinParent()+(c?0:1),"element")}Ae(H(_))}}})(()=>{let i=null;for(const a of s){if(!a.isAttached())continue;const u=A(a,T);if(u){d(u);continue}if(O(a)){if(!a.isInline())continue;if(T(a)){if(!(b(a)||i!==null&&i.getParentOrThrow().isParentOf(a))){d(a),i=a;continue}for(const h of a.getChildren())a.insertBefore(h);a.remove();continue}}const c=a.getPreviousSibling();T(c)&&c.is(i)?c.append(a):(i=M(t,{rel:l,target:r,title:g}),a.insertAfter(i),i.append(a))}})}const Je=/^\+?[0-9\s()-]{5,}$/;function Y(n){return n.match(/^[a-z][a-z0-9+.-]*:/i)||n.match(/^[/#.]/)?n:n.includes("@")?`mailto:${n}`:Je.test(n)?`tel:${n}`:`https://${n}`}function ce(n,e){return V(n.registerNodeTransform(R,Fe),n.registerCommand(W,t=>{const r=e.validateUrl.peek(),g=e.attributes.peek();if(t===null)return y(null),!0;if(typeof t=="string")return!(r!==void 0&&!r(t))&&(y(t,g),!0);{const{url:l,target:o,rel:s,title:f}=t;return y(l,{...g,rel:s,target:o,title:f}),!0}},Ue),Ie(()=>{const t=e.validateUrl.value;if(!t)return;const r=e.attributes.value;return n.registerCommand(Se,g=>{const l=S();if(!U(l)||l.isCollapsed()||!be(g,ClipboardEvent)||g.clipboardData===null)return!1;const o=g.clipboardData.getData("text");return!!t(o)&&!l.getNodes().some(s=>O(s))&&(n.dispatchCommand(W,{...r,url:o}),g.preventDefault(),!0)},ee)}))}const Z=B({build:(n,e,t)=>le(e),config:{attributes:void 0,validateUrl:void 0},mergeConfig(n,e){const t=z(n,e);return n.attributes&&(t.attributes=z(n.attributes,t.attributes)),t},name:"@lexical/link/Link",nodes:()=>[R],register:(n,e,t)=>ce(n,t.getOutput())});function ge(n,e,t={}){const r=l=>{const o=l.target;if(!Ee(o))return;const s=Pe(o);if(s===null)return;let f=null,d=null;if(s.update(()=>{const u=Me(o);if(u!==null){const c=A(u,O);if(!e.disabled.peek())if(T(c))f=c.sanitizeUrl(c.getURL()),d=c.getTarget();else{const h=(function(p,L){let _=p;for(;_!=null;){if(L(_))return _;_=_.parentNode}return null})(o,K);h!==null&&(f=h.href,d=h.target)}}}),f===null||f==="")return;const i=n.getEditorState().read(S,{editor:n});if(U(i)&&!i.isCollapsed())return void l.preventDefault();const a=l.type==="auxclick"&&l.button===1;window.open(f,e.newTab.peek()||a||l.metaKey||l.ctrlKey||d==="_blank"?"_blank":"_self"),l.preventDefault()},g=l=>{l.button===1&&r(l)};return n.registerRootListener(l=>{if(l)return l.addEventListener("click",r,t),l.addEventListener("mouseup",g,t),()=>{l.removeEventListener("click",r),l.removeEventListener("mouseup",g)}})}const Ke=B({build:(n,e,t)=>le(e),config:Te({disabled:!1,newTab:!1}),dependencies:[Z],name:"@lexical/link/ClickableLink",register:(n,e,t)=>ge(n,t.getOutput())});function Be(n,e=t=>t){return t=>{const r=n.exec(t);return r===null?null:{index:r.index,length:r[0].length,text:r[0],url:e(r[0])}}}function q(n,e){for(let t=0;t<e.length;t++){const r=e[t](n);if(r)return r}return null}const fe=/[.,;\s]/;function J(n,e){return e.test(n)}function de(n,e){return J(n[n.length-1],e)}function X(n,e){return J(n[0],e)}function he(n,e){let t=n.getPreviousSibling();return O(t)&&(t=t.getLastDescendant()),t===null||se(t)||P(t)&&de(t.getTextContent(),e)}function _e(n,e){let t=n.getNextSibling();return O(t)&&(t=t.getFirstDescendant()),t===null||se(t)||P(t)&&X(t.getTextContent(),e)}function ze(n,e,t,r,g){return(n>0?J(r[n-1],t):he(g[0],t))?e<r.length?J(r[e],t):_e(g[g.length-1],t):!1}function je(n,e,t){const r=[],g=[],l=[];let o=0,s=0;const f=[...n];for(;f.length>0;){const d=f[0],i=d.getTextContent().length,a=s;s+i<=e?(r.push(d),o+=i):a>=t?l.push(d):g.push(d),s+=i,f.shift()}return[o,r,g,l]}function Ge(n,e,t,r){const g=F(r.url,r.attributes);if(n.length===1){let l,o=n[0];e===0?[l,o]=o.splitText(t):[,l,o]=o.splitText(e,t);const s=re(r.text);return s.setFormat(l.getFormat()),s.setDetail(l.getDetail()),s.setStyle(l.getStyle()),g.append(s),l.replace(g),o}if(n.length>1){const l=n[0];let o,s=l.getTextContent().length;e===0?o=l:[,o]=l.splitText(e);const f=[];let d;for(let c=1;c<n.length;c++){const h=n[c],p=h.getTextContent().length,L=s;if(L<t)if(s+p<=t)f.push(h);else{const[_,m]=h.splitText(t-L);f.push(_),d=m}s+=p}const i=S(),a=i?i.getNodes().find(P):void 0,u=re(o.getTextContent());return u.setFormat(o.getFormat()),u.setDetail(o.getDetail()),u.setStyle(o.getStyle()),g.append(u,...f),a&&a===o&&(U(i)?u.select(i.anchor.offset,i.focus.offset):G(i)&&u.select(0,u.getTextContent().length)),o.replace(g),d}}function pe(n,e,t,r){const g=n.getChildren(),l=g.length;for(let d=0;d<l;d++){const i=g[d];if(!P(i)||!i.isSimpleText())return $(n),void t(null,n.getURL())}const o=n.getTextContent(),s=q(o,e);
7if(s===null||s.text!==o||!he(n,r)||!_e(n,r))return $(n),void t(null,n.getURL());const f=n.getURL();if(f!==s.url&&(n.setURL(s.url),t(s.url,f)),s.attributes){const d=n.getRel();d!==s.attributes.rel&&(n.setRel(s.attributes.rel||null),t(s.attributes.rel||null,d));const i=n.getTarget();i!==s.attributes.target&&(n.setTarget(s.attributes.target||null),t(s.attributes.target||null,i))}}function $(n){const e=n.getChildren();for(let t=e.length-1;t>=0;t--)n.insertAfter(e[t]);return n.remove(),e.map(t=>t.getLatest())}const me={changeHandlers:[],excludeParents:[],matchers:[],separatorRegex:fe};function ke(n,e=me){const{matchers:t,changeHandlers:r,excludeParents:g,separatorRegex:l=fe}=e,o=(s,f)=>{for(const d of r)d(s,f)};return V(n.registerNodeTransform(Oe,s=>{const f=s.getParentOrThrow(),d=s.getPreviousSibling();if(b(f))pe(f,t,o,l);else if(!T(f)&&!g.some(i=>i(f))){if(s.isSimpleText()&&(X(s.getTextContent(),l)||!b(d))){const i=(function(a){const u=[a];let c=a.getNextSibling();for(;c!==null&&P(c)&&c.isSimpleText()&&(u.push(c),!/[\s]/.test(c.getTextContent()));)c=c.getNextSibling();return u})(s);(function(a,u,c,h){for(const N of a){const v=N.getParent();if(b(v)&&!v.getIsUnlinked())return}let p=[...a];const L=p.map(N=>N.getTextContent()).join("");let _,m=L,k=0;for(;(_=q(m,u))&&_!==null;){const N=_.index,v=N+_.length;if(ze(k+N,k+v,h,L,p)){const[D,,I,x]=je(p,k+N,k+v);let C=!1;for(const xe of I){const Q=xe.getParent();if(b(Q)&&!Q.getIsUnlinked()){C=!0;break}}if(C){k+=v,m=m.substring(v);continue}const w=Ge(I,k+N-D,k+v-D,_);p=w?[w,...x]:x,c(_.url,null),k=0}else k+=v;m=m.substring(v)}})(i,t,o,l)}(function(i,a,u,c){const h=i.getParent(),p=i.getPreviousSibling(),L=i.getNextSibling(),_=i.getTextContent();if(!b(h)||h.getIsUnlinked()){if(b(p)&&!p.getIsUnlinked()&&p.is(i.getPreviousSibling())&&i.getParent()===p.getParent()){if(!X(_,c))return $(p),void u(null,p.getURL());if(m=_,p.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(m):/^\.[a-zA-Z0-9]{1,}/.test(m)){const k=p.getTextContent()+_,N=q(k,a);N!==null&&N.text===k&&(p.append(i),pe(p,a,u,c),u(null,p.getURL()))}}var m;!b(L)||L.getIsUnlinked()||de(_,c)||L.is(i.getNextSibling())&&i.getParent()===L.getParent()&&($(L),u(null,L.getURL()))}})(s,t,o,l)}}),n.registerCommand(W,s=>{const f=S();return s!==null||!U(f)||f.extract().forEach(d=>{const i=d.getParent();b(i)&&(i.setIsUnlinked(!i.getIsUnlinked()),i.markDirty())}),!1},ee))}const He=B({config:me,dependencies:[Z],mergeConfig(n,e){const t=z(n,e);for(const r of["matchers","changeHandlers","excludeParents"]){const g=e[r];Array.isArray(g)&&(t[r]=[...n[r],...g])}return t},name:"@lexical/link/AutoLink",nodes:[E],register:ke}),Ye=y;export{F as $createAutoLinkNode,M as $createLinkNode,b as $isAutoLinkNode,T as $isLinkNode,y as $toggleLink,He as AutoLinkExtension,E as AutoLinkNode,Ke as ClickableLinkExtension,Z as LinkExtension,R as LinkNode,W as TOGGLE_LINK_COMMAND,Be as createLinkMatcherWithRegExp,Y as formatUrl,ke as registerAutoLink,ge as registerClickableLink,ce as registerLink,Ye as toggleLink};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.