import{a as r,c as n}from"./chunk-IDIB3GMX.js";n();n();import{$encodedName as $}from"@typespec/compiler";n();import{createTypeSpecLibrary as y,paramMessage as b}from"@typespec/compiler";var d=y({name:"@typespec/xml",diagnostics:{"ns-enum-not-declaration":{severity:"error",messages:{default:"Enum member used as namespace must be part of an enum marked with @nsDeclaration."}},"invalid-ns-declaration-member":{severity:"error",messages:{default:b`Enum member ${"name"} must have a value that is the XML namespace url.`}},"ns-missing-prefix":{severity:"error",messages:{default:"When using a string namespace you must provide a prefix as the 2nd argument."}},"prefix-not-allowed":{severity:"error",messages:{default:"@ns decorator cannot have the prefix parameter set when using an enum member."}},"ns-not-uri":{severity:"error",messages:{default:"Namespace namespace is not a valid URI."}}},state:{attribute:{description:"Mark a model property to be serialized as xml attribute"},unwrapped:{description:"Mark a model property to be serialized without a node wrapping the content."},ns:{description:"Namespace data"},nsDeclaration:{description:"Mark an enum that declares Xml Namespaces"}}}),{reportDiagnostic:s,createStateSymbol:k,stateKeys:i}=d;var u=r((e,t,a)=>{e.call($,t,"application/xml",a)},"$name"),c=r((e,t)=>{e.program.stateSet(i.attribute).add(t)},"$attribute");function D(e,t){return e.stateSet(i.attribute).has(t)}r(D,"isAttribute");var l=r((e,t)=>{e.program.stateSet(i.unwrapped).add(t)},"$unwrapped");function S(e,t){return e.stateSet(i.unwrapped).has(t)}r(S,"isUnwrapped");var g=r((e,t)=>{e.program.stateSet(i.nsDeclaration).add(t)},"$nsDeclarations");function x(e,t){return e.stateSet(i.nsDeclaration).has(t)}r(x,"isNsDeclarationsEnum");var f=r((e,t,a,o)=>{let p=T(e,a,o);p&&w(e,p.namespace)&&e.program.stateMap(i.nsDeclaration).set(t,p)},"$ns");function h(e,t){return e.stateMap(i.nsDeclaration).get(t)}r(h,"getNs");function T(e,t,a){switch(t.kind){case"String":if(!a){s(e.program,{code:"ns-missing-prefix",target:e.decoratorTarget});return}return{namespace:t.value,prefix:a};case"EnumMember":if(!x(e.program,t.enum)){s(e.program,{code:"ns-enum-not-declaration",target:e.decoratorTarget});return}if(a!==void 0&&s(e.program,{code:"prefix-not-allowed",target:e.getArgumentTarget(1),format:{name:t.name}}),typeof t.value!="string"){s(e.program,{code:"invalid-ns-declaration-member",target:e.decoratorTarget,format:{name:t.name}});return}return{namespace:t.value,prefix:t.name};default:return}}r(T,"getData");function w(e,t){try{return new URL(t),!0}catch{return s(e.program,{code:"ns-not-uri",target:e.getArgumentTarget(0),format:{namespace:t}}),!1}}r(w,"validateNamespaceIsUri");n();import{getEncode as v}from"@typespec/compiler";function E(e,t){let a=v(e,t);if(a)return a;let o=X(t.kind==="Scalar"?t:t.type);if(o!==void 0)return{encoding:o,type:e.checker.getStdType("string")}}r(E,"getXmlEncoding");function X(e){switch(e.name){case"utcDateTime":case"offsetDateTime":return"TypeSpec.Xml.Encoding.xmlDateTime";case"plainDate":return"TypeSpec.Xml.Encoding.xmlDate";case"plainTime":return"TypeSpec.Xml.Encoding.xmlTime";case"duration":return"TypeSpec.Xml.Encoding.xmlDuration";case"bytes":return"TypeSpec.Xml.Encoding.xmlBase64Binary";default:return}}r(X,"getDefaultEncoding");n();var M={"TypeSpec.Xml":{attribute:c,name:u,ns:f,nsDeclarations:g,unwrapped:l}};export{c as $attribute,M as $decorators,d as $lib,u as $name,f as $ns,g as $nsDeclarations,l as $unwrapped,h as getNs,E as getXmlEncoding,D as isAttribute,S as isUnwrapped};
