/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{ka as c,ob as p}from"./ACTJS4TX.js";import{u as d}from"./AYSQIO6L.js";var V=250,g=new Set(["add","all","alter","and","any","as","asc","backup","between","by","case","check","column","constraint","create","database","date","default","delete","desc","distinct","drop","exec","exists","foreign","from","full","group","having","in","index","inner","insert","into","is","join","key","left","like","limit","not","null","on","or","order","outer","primary","procedure","right","rownum","select","set","shape","subtype","table","top","truncate","union","unique","update","values","view","where"]),w=new Set(["objectid","globalid","created_date","created_user","last_edited_date","last_edited_user","fid","shape","shape_length","shape_area"]),x=/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F018}-\u{1F270}\u{238C}-\u{2454}\u{20D0}-\u{20FF}\u{FE0F}]/u;function n(e){return!e||e.trim().length===0}function s(e){return e.length>V}function l(e,r){return x.test(e)?!0:r==="item"?/[><~`$^+=|\\]/u.test(e):/[/<>\\]/u.test(e)}async function b(e,r){let t=r,a=await t.getUsername(),y={q:new d().match(e).in("title").and().match(a).in("owner"),filter:"type:Solution",authentication:t},h=(await p(y)).results.map(i=>i.title),{folders:m}=await c(t),f=m.map(i=>i.title),u=[...h,...f].map(i=>i.trim().toLowerCase()),o=e.toLowerCase(),F=u.filter(i=>i===o),T=u.filter(i=>i.startsWith(o));return{conflictingNames:F,similiarNames:T}}async function L(e,r,t=!1){return n(e)?{isValid:!1,errorType:"empty"}:s(e)?{isValid:!1,errorType:"exceed-length"}:l(e,"folder")||l(e,"item")?{isValid:!1,errorType:"special-character"}:!t&&r&&(await b(e.trim(),r)).conflictingNames.length>0?{isValid:!1,errorType:"not-unique"}:{isValid:!0,errorType:null}}function C(e){return n(e)?{isValid:!1,errorType:"empty"}:s(e)?{isValid:!1,errorType:"exceed-length"}:l(e,"item")?{isValid:!1,errorType:"special-character"}:{isValid:!0,errorType:null}}function v(e,r,t=!1){if(e.length>r)return{isValid:!1,errorType:"exceed-length"};let a=[];return e.includes("<")&&a.push("<"),e.includes(">")&&a.push(">"),!t&&e.includes("/")&&a.push("/"),a.length>0?{isValid:!1,errorType:"special-character"}:{isValid:!0,errorType:null}}function S(e){return n(e)?{isValid:!1,errorType:"empty"}:s(e)?{isValid:!1,errorType:"exceed-length"}:{isValid:!0,errorType:null}}function k(e,r=[]){return n(e)?{isValid:!1,errorType:"empty"}:/^[\p{L}][\p{L}\p{N}\p{M}_]*$/u.test(e)?e.length>31?{isValid:!1,errorType:"exceed-length"}:g.has(e.toLowerCase())?{isValid:!1,errorType:"sql-keyword"}:w.has(e.toLowerCase())?{isValid:!1,errorType:"system-field"}:r.includes(e.toLowerCase())?{isValid:!1,errorType:"duplicate-field"}:{isValid:!0,errorType:null}:{isValid:!1,errorType:"invalid-format"}}function q(e){return e<1||e>4e3?{isValid:!1,errorType:"out-of-range"}:{isValid:!0,errorType:null}}function N(e,r,t=!1){return t?{isValid:!0,errorType:null}:e.trim().length===0?{isValid:!1,errorType:"empty"}:e.length>r?{isValid:!1,errorType:"exceed-length"}:{isValid:!0,errorType:null}}export{g as a,b,L as c,C as d,v as e,S as f,k as g,q as h,N as i};
